summaryrefslogtreecommitdiff
path: root/firmware/target/arm/imx233/ssp-imx233.c
diff options
context:
space:
mode:
authorAmaury Pouly <amaury.pouly@gmail.com>2012-05-10 00:08:03 +0200
committerAmaury Pouly <amaury.pouly@gmail.com>2012-05-10 00:13:11 +0200
commit645680d62b82455d24fcb178f1cc5208f9942e38 (patch)
tree1a9f928afc34260059bf986fc2caa7fc5b2a2028 /firmware/target/arm/imx233/ssp-imx233.c
parentd29a11b7a8f4ce230e9385a44f352a559bde753f (diff)
downloadrockbox-645680d62b82455d24fcb178f1cc5208f9942e38.tar.gz
rockbox-645680d62b82455d24fcb178f1cc5208f9942e38.zip
imx233: add pinctrl debug code to track pin uses
Past development has proved that one can mistakely use the same pin for two uses without noticing. Since this causes extremely hard to find bugs, the infrastructure will allow to register pin uses and panic when a conflict is detected. The pinctrl debug now shows the pin uses when its support is compiled in. Change-Id: Idb2d5235ce09207d77aa474d6f158e72b933761a
Diffstat (limited to 'firmware/target/arm/imx233/ssp-imx233.c')
-rw-r--r--firmware/target/arm/imx233/ssp-imx233.c14
1 files changed, 11 insertions, 3 deletions
diff --git a/firmware/target/arm/imx233/ssp-imx233.c b/firmware/target/arm/imx233/ssp-imx233.c
index eb7a3a2ad4..cbf537dd07 100644
--- a/firmware/target/arm/imx233/ssp-imx233.c
+++ b/firmware/target/arm/imx233/ssp-imx233.c
@@ -150,12 +150,15 @@ void imx233_ssp_setup_ssp1_sd_mmc_pins(bool enable_pullups, unsigned bus_width,
150 /* SSP_{CMD,SCK} */ 150 /* SSP_{CMD,SCK} */
151 imx233_set_pin_drive_strength(2, 0, drive_strength); 151 imx233_set_pin_drive_strength(2, 0, drive_strength);
152 imx233_set_pin_drive_strength(2, 6, drive_strength); 152 imx233_set_pin_drive_strength(2, 6, drive_strength);
153 imx233_pinctrl_acquire_pin(2, 0, "ssp1 cmd");
154 imx233_pinctrl_acquire_pin(2, 6, "ssp1 sck");
153 imx233_set_pin_function(2, 0, PINCTRL_FUNCTION_MAIN); 155 imx233_set_pin_function(2, 0, PINCTRL_FUNCTION_MAIN);
154 imx233_set_pin_function(2, 6, PINCTRL_FUNCTION_MAIN); 156 imx233_set_pin_function(2, 6, PINCTRL_FUNCTION_MAIN);
155 imx233_enable_pin_pullup(2, 0, enable_pullups); 157 imx233_enable_pin_pullup(2, 0, enable_pullups);
156 /* SSP_DATA{0-3} */ 158 /* SSP_DATA{0-3} */
157 for(unsigned i = 0; i < MIN(bus_width, 4); i++) 159 for(unsigned i = 0; i < MIN(bus_width, 4); i++)
158 { 160 {
161 imx233_pinctrl_acquire_pin(2, 2 + i, "ssp1 data");
159 imx233_set_pin_drive_strength(2, 2 + i, drive_strength); 162 imx233_set_pin_drive_strength(2, 2 + i, drive_strength);
160 imx233_set_pin_function(2, 2 + i, PINCTRL_FUNCTION_MAIN); 163 imx233_set_pin_function(2, 2 + i, PINCTRL_FUNCTION_MAIN);
161 imx233_enable_pin_pullup(2, 2 + i, enable_pullups); 164 imx233_enable_pin_pullup(2, 2 + i, enable_pullups);
@@ -166,12 +169,14 @@ void imx233_ssp_setup_ssp1_sd_mmc_pins(bool enable_pullups, unsigned bus_width,
166 { 169 {
167 if(use_alt) 170 if(use_alt)
168 { 171 {
172 imx233_pinctrl_acquire_pin(0, 22 + i, "ssp1 data");
169 imx233_set_pin_drive_strength(0, 22 + i, drive_strength); 173 imx233_set_pin_drive_strength(0, 22 + i, drive_strength);
170 imx233_set_pin_function(0, 22 + i, PINCTRL_FUNCTION_ALT2); 174 imx233_set_pin_function(0, 22 + i, PINCTRL_FUNCTION_ALT2);
171 imx233_enable_pin_pullup(0, 22 + i, enable_pullups); 175 imx233_enable_pin_pullup(0, 22 + i, enable_pullups);
172 } 176 }
173 else 177 else
174 { 178 {
179 imx233_pinctrl_acquire_pin(0, 4 + i, "ssp1 data");
175 imx233_set_pin_drive_strength(0, 4 + i, drive_strength); 180 imx233_set_pin_drive_strength(0, 4 + i, drive_strength);
176 imx233_set_pin_function(0, 4 + i, PINCTRL_FUNCTION_ALT2); 181 imx233_set_pin_function(0, 4 + i, PINCTRL_FUNCTION_ALT2);
177 imx233_enable_pin_pullup(0, 4 + i, enable_pullups); 182 imx233_enable_pin_pullup(0, 4 + i, enable_pullups);
@@ -183,6 +188,8 @@ void imx233_ssp_setup_ssp2_sd_mmc_pins(bool enable_pullups, unsigned bus_width,
183 unsigned drive_strength) 188 unsigned drive_strength)
184{ 189{
185 /* SSP_{CMD,SCK} */ 190 /* SSP_{CMD,SCK} */
191 imx233_pinctrl_acquire_pin(0, 20, "ssp2 cmd");
192 imx233_pinctrl_acquire_pin(0, 24, "ssp2 sck");
186 imx233_set_pin_drive_strength(0, 20, drive_strength); 193 imx233_set_pin_drive_strength(0, 20, drive_strength);
187 imx233_set_pin_drive_strength(0, 24, drive_strength); 194 imx233_set_pin_drive_strength(0, 24, drive_strength);
188 imx233_set_pin_function(0, 20, PINCTRL_FUNCTION_ALT2); 195 imx233_set_pin_function(0, 20, PINCTRL_FUNCTION_ALT2);
@@ -191,13 +198,13 @@ void imx233_ssp_setup_ssp2_sd_mmc_pins(bool enable_pullups, unsigned bus_width,
191 /* SSP_DATA{0-7}*/ 198 /* SSP_DATA{0-7}*/
192 for(unsigned i = 0; i < bus_width; i++) 199 for(unsigned i = 0; i < bus_width; i++)
193 { 200 {
201 imx233_pinctrl_acquire_pin(0, i, "ssp2 data");
194 imx233_set_pin_drive_strength(0, i, drive_strength); 202 imx233_set_pin_drive_strength(0, i, drive_strength);
195 imx233_set_pin_function(0, i, PINCTRL_FUNCTION_ALT2); 203 imx233_set_pin_function(0, i, PINCTRL_FUNCTION_ALT2);
196 imx233_enable_pin_pullup(0, i, enable_pullups); 204 imx233_enable_pin_pullup(0, i, enable_pullups);
205 imx233_enable_gpio_output(0, i, false);
206 imx233_set_gpio_output(0, i, false);
197 } 207 }
198
199 imx233_enable_gpio_output_mask(0, 0x11000ff, false);
200 imx233_set_gpio_output_mask(0, 0x11000ff, false);
201} 208}
202 209
203void imx233_ssp_set_mode(int ssp, unsigned mode) 210void imx233_ssp_set_mode(int ssp, unsigned mode)
@@ -348,6 +355,7 @@ void imx233_ssp_sdmmc_setup_detect(int ssp, bool enable, ssp_detect_cb_t fn, boo
348 ssp_detect_cb[ssp - 1] = fn; 355 ssp_detect_cb[ssp - 1] = fn;
349 if(enable) 356 if(enable)
350 { 357 {
358 imx233_pinctrl_acquire_pin(bank, pin, ssp == 1 ? "ssp1 detect" : "ssp2 detect");
351 imx233_set_pin_function(bank, pin, PINCTRL_FUNCTION_GPIO); 359 imx233_set_pin_function(bank, pin, PINCTRL_FUNCTION_GPIO);
352 imx233_enable_gpio_output(bank, pin, false); 360 imx233_enable_gpio_output(bank, pin, false);
353 } 361 }