1 #include "ddk750_help.h" 2 #include "ddk750_reg.h" 3 #include "ddk750_power.h" 4 ddk750_setDPMS(DPMS_t state)5void ddk750_setDPMS(DPMS_t state) 6 { 7 unsigned int value; 8 9 if (sm750_get_chip_type() == SM750LE) { 10 value = PEEK32(CRT_DISPLAY_CTRL) & ~CRT_DISPLAY_CTRL_DPMS_MASK; 11 value |= (state << CRT_DISPLAY_CTRL_DPMS_SHIFT); 12 POKE32(CRT_DISPLAY_CTRL, value); 13 } else { 14 value = PEEK32(SYSTEM_CTRL); 15 value = (value & ~SYSTEM_CTRL_DPMS_MASK) | state; 16 POKE32(SYSTEM_CTRL, value); 17 } 18 } 19 getPowerMode(void)20static unsigned int getPowerMode(void) 21 { 22 if (sm750_get_chip_type() == SM750LE) 23 return 0; 24 return PEEK32(POWER_MODE_CTRL) & POWER_MODE_CTRL_MODE_MASK; 25 } 26 27 28 /* 29 * SM50x can operate in one of three modes: 0, 1 or Sleep. 30 * On hardware reset, power mode 0 is default. 31 */ setPowerMode(unsigned int powerMode)32void setPowerMode(unsigned int powerMode) 33 { 34 unsigned int control_value = 0; 35 36 control_value = PEEK32(POWER_MODE_CTRL) & ~POWER_MODE_CTRL_MODE_MASK; 37 38 if (sm750_get_chip_type() == SM750LE) 39 return; 40 41 switch (powerMode) { 42 case POWER_MODE_CTRL_MODE_MODE0: 43 control_value |= POWER_MODE_CTRL_MODE_MODE0; 44 break; 45 46 case POWER_MODE_CTRL_MODE_MODE1: 47 control_value |= POWER_MODE_CTRL_MODE_MODE1; 48 break; 49 50 case POWER_MODE_CTRL_MODE_SLEEP: 51 control_value |= POWER_MODE_CTRL_MODE_SLEEP; 52 break; 53 54 default: 55 break; 56 } 57 58 /* Set up other fields in Power Control Register */ 59 if (powerMode == POWER_MODE_CTRL_MODE_SLEEP) { 60 control_value &= ~POWER_MODE_CTRL_OSC_INPUT; 61 #ifdef VALIDATION_CHIP 62 control_value &= ~POWER_MODE_CTRL_336CLK; 63 #endif 64 } else { 65 control_value |= POWER_MODE_CTRL_OSC_INPUT; 66 #ifdef VALIDATION_CHIP 67 control_value |= POWER_MODE_CTRL_336CLK; 68 #endif 69 } 70 71 /* Program new power mode. */ 72 POKE32(POWER_MODE_CTRL, control_value); 73 } 74 setCurrentGate(unsigned int gate)75void setCurrentGate(unsigned int gate) 76 { 77 unsigned int gate_reg; 78 unsigned int mode; 79 80 /* Get current power mode. */ 81 mode = getPowerMode(); 82 83 switch (mode) { 84 case POWER_MODE_CTRL_MODE_MODE0: 85 gate_reg = MODE0_GATE; 86 break; 87 88 case POWER_MODE_CTRL_MODE_MODE1: 89 gate_reg = MODE1_GATE; 90 break; 91 92 default: 93 gate_reg = MODE0_GATE; 94 break; 95 } 96 POKE32(gate_reg, gate); 97 } 98 99 100 101 /* 102 * This function enable/disable the 2D engine. 103 */ enable2DEngine(unsigned int enable)104void enable2DEngine(unsigned int enable) 105 { 106 u32 gate; 107 108 gate = PEEK32(CURRENT_GATE); 109 if (enable) 110 gate |= (CURRENT_GATE_DE | CURRENT_GATE_CSC); 111 else 112 gate &= ~(CURRENT_GATE_DE | CURRENT_GATE_CSC); 113 114 setCurrentGate(gate); 115 } 116 enableDMA(unsigned int enable)117void enableDMA(unsigned int enable) 118 { 119 u32 gate; 120 121 /* Enable DMA Gate */ 122 gate = PEEK32(CURRENT_GATE); 123 if (enable) 124 gate |= CURRENT_GATE_DMA; 125 else 126 gate &= ~CURRENT_GATE_DMA; 127 128 setCurrentGate(gate); 129 } 130 131 /* 132 * This function enable/disable the GPIO Engine 133 */ enableGPIO(unsigned int enable)134void enableGPIO(unsigned int enable) 135 { 136 u32 gate; 137 138 /* Enable GPIO Gate */ 139 gate = PEEK32(CURRENT_GATE); 140 if (enable) 141 gate |= CURRENT_GATE_GPIO; 142 else 143 gate &= ~CURRENT_GATE_GPIO; 144 145 setCurrentGate(gate); 146 } 147 148 /* 149 * This function enable/disable the I2C Engine 150 */ enableI2C(unsigned int enable)151void enableI2C(unsigned int enable) 152 { 153 u32 gate; 154 155 /* Enable I2C Gate */ 156 gate = PEEK32(CURRENT_GATE); 157 if (enable) 158 gate |= CURRENT_GATE_I2C; 159 else 160 gate &= ~CURRENT_GATE_I2C; 161 162 setCurrentGate(gate); 163 } 164 165 166