1 #include "ddk750_help.h"
2 #include "ddk750_reg.h"
3 #include "ddk750_power.h"
5 void ddk750_setDPMS(DPMS_t state
)
8 if(getChipType() == SM750LE
){
9 value
= PEEK32(CRT_DISPLAY_CTRL
);
10 POKE32(CRT_DISPLAY_CTRL
,FIELD_VALUE(value
,CRT_DISPLAY_CTRL
,DPMS
,state
));
12 value
= PEEK32(SYSTEM_CTRL
);
13 value
= FIELD_VALUE(value
,SYSTEM_CTRL
,DPMS
,state
);
14 POKE32(SYSTEM_CTRL
, value
);
18 unsigned int getPowerMode(void)
20 if(getChipType() == SM750LE
)
22 return (FIELD_GET(PEEK32(POWER_MODE_CTRL
), POWER_MODE_CTRL
, MODE
));
27 * SM50x can operate in one of three modes: 0, 1 or Sleep.
28 * On hardware reset, power mode 0 is default.
30 void setPowerMode(unsigned int powerMode
)
32 unsigned int control_value
= 0;
34 control_value
= PEEK32(POWER_MODE_CTRL
);
36 if(getChipType() == SM750LE
)
41 case POWER_MODE_CTRL_MODE_MODE0
:
42 control_value
= FIELD_SET(control_value
, POWER_MODE_CTRL
, MODE
, MODE0
);
45 case POWER_MODE_CTRL_MODE_MODE1
:
46 control_value
= FIELD_SET(control_value
, POWER_MODE_CTRL
, MODE
, MODE1
);
49 case POWER_MODE_CTRL_MODE_SLEEP
:
50 control_value
= FIELD_SET(control_value
, POWER_MODE_CTRL
, MODE
, SLEEP
);
57 /* Set up other fields in Power Control Register */
58 if (powerMode
== POWER_MODE_CTRL_MODE_SLEEP
)
61 #ifdef VALIDATION_CHIP
62 FIELD_SET( control_value
, POWER_MODE_CTRL
, 336CLK
, OFF
) |
64 FIELD_SET( control_value
, POWER_MODE_CTRL
, OSC_INPUT
, OFF
);
69 #ifdef VALIDATION_CHIP
70 FIELD_SET( control_value
, POWER_MODE_CTRL
, 336CLK
, ON
) |
72 FIELD_SET( control_value
, POWER_MODE_CTRL
, OSC_INPUT
, ON
);
75 /* Program new power mode. */
76 POKE32(POWER_MODE_CTRL
, control_value
);
79 void setCurrentGate(unsigned int gate
)
81 unsigned int gate_reg
;
84 /* Get current power mode. */
85 mode
= getPowerMode();
89 case POWER_MODE_CTRL_MODE_MODE0
:
90 gate_reg
= MODE0_GATE
;
93 case POWER_MODE_CTRL_MODE_MODE1
:
94 gate_reg
= MODE1_GATE
;
98 gate_reg
= MODE0_GATE
;
101 POKE32(gate_reg
, gate
);
107 * This function enable/disable the 2D engine.
109 void enable2DEngine(unsigned int enable
)
113 gate
= PEEK32(CURRENT_GATE
);
116 gate
= FIELD_SET(gate
, CURRENT_GATE
, DE
, ON
);
117 gate
= FIELD_SET(gate
, CURRENT_GATE
, CSC
, ON
);
121 gate
= FIELD_SET(gate
, CURRENT_GATE
, DE
, OFF
);
122 gate
= FIELD_SET(gate
, CURRENT_GATE
, CSC
, OFF
);
125 setCurrentGate(gate
);
130 * This function enable/disable the ZV Port.
132 void enableZVPort(unsigned int enable
)
136 /* Enable ZV Port Gate */
137 gate
= PEEK32(CURRENT_GATE
);
140 gate
= FIELD_SET(gate
, CURRENT_GATE
, ZVPORT
, ON
);
142 /* Using Software I2C */
143 gate
= FIELD_SET(gate
, CURRENT_GATE
, GPIO
, ON
);
145 /* Using Hardware I2C */
146 gate
= FIELD_SET(gate
, CURRENT_GATE
, I2C
, ON
);
151 /* Disable ZV Port Gate. There is no way to know whether the GPIO pins are being used
152 or not. Therefore, do not disable the GPIO gate. */
153 gate
= FIELD_SET(gate
, CURRENT_GATE
, ZVPORT
, OFF
);
156 setCurrentGate(gate
);
160 void enableSSP(unsigned int enable
)
164 /* Enable SSP Gate */
165 gate
= PEEK32(CURRENT_GATE
);
167 gate
= FIELD_SET(gate
, CURRENT_GATE
, SSP
, ON
);
169 gate
= FIELD_SET(gate
, CURRENT_GATE
, SSP
, OFF
);
171 setCurrentGate(gate
);
174 void enableDMA(unsigned int enable
)
178 /* Enable DMA Gate */
179 gate
= PEEK32(CURRENT_GATE
);
181 gate
= FIELD_SET(gate
, CURRENT_GATE
, DMA
, ON
);
183 gate
= FIELD_SET(gate
, CURRENT_GATE
, DMA
, OFF
);
185 setCurrentGate(gate
);
189 * This function enable/disable the GPIO Engine
191 void enableGPIO(unsigned int enable
)
195 /* Enable GPIO Gate */
196 gate
= PEEK32(CURRENT_GATE
);
198 gate
= FIELD_SET(gate
, CURRENT_GATE
, GPIO
, ON
);
200 gate
= FIELD_SET(gate
, CURRENT_GATE
, GPIO
, OFF
);
202 setCurrentGate(gate
);
206 * This function enable/disable the PWM Engine
208 void enablePWM(unsigned int enable
)
212 /* Enable PWM Gate */
213 gate
= PEEK32(CURRENT_GATE
);
215 gate
= FIELD_SET(gate
, CURRENT_GATE
, PWM
, ON
);
217 gate
= FIELD_SET(gate
, CURRENT_GATE
, PWM
, OFF
);
219 setCurrentGate(gate
);
223 * This function enable/disable the I2C Engine
225 void enableI2C(unsigned int enable
)
229 /* Enable I2C Gate */
230 gate
= PEEK32(CURRENT_GATE
);
232 gate
= FIELD_SET(gate
, CURRENT_GATE
, I2C
, ON
);
234 gate
= FIELD_SET(gate
, CURRENT_GATE
, I2C
, OFF
);
236 setCurrentGate(gate
);