diff options
author | Guennadi Liakhovetski <g.liakhovetski@gmx.de> | 2012-01-28 13:36:24 -0500 |
---|---|---|
committer | Paul Mundt <lethal@linux-sh.org> | 2012-03-28 03:28:25 -0400 |
commit | 4eb80146f8ccd4e01d1320e42611b31cde7f06e7 (patch) | |
tree | 0a009f0d5260915df272b8580a212a78f7becda0 /arch/sh | |
parent | 9b2ffa8d048656baf7f5e764d2586ba59927a25b (diff) |
sh: ecovec: switch SDHI controllers to card polling
Polling for card hotplug events is a better option than using SDHI native
hotplug interrupt, because the latter option forces the controller to stay
permanently powered up and enabled.
Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de>
Signed-off-by: Paul Mundt <lethal@linux-sh.org>
Diffstat (limited to 'arch/sh')
-rw-r--r-- | arch/sh/boards/mach-ecovec24/setup.c | 104 |
1 files changed, 63 insertions, 41 deletions
diff --git a/arch/sh/boards/mach-ecovec24/setup.c b/arch/sh/boards/mach-ecovec24/setup.c index e5ac12b2ce65..d12fe9ddf3da 100644 --- a/arch/sh/boards/mach-ecovec24/setup.c +++ b/arch/sh/boards/mach-ecovec24/setup.c | |||
@@ -522,11 +522,18 @@ static void sdhi0_set_pwr(struct platform_device *pdev, int state) | |||
522 | gpio_set_value(GPIO_PTB6, state); | 522 | gpio_set_value(GPIO_PTB6, state); |
523 | } | 523 | } |
524 | 524 | ||
525 | static int sdhi0_get_cd(struct platform_device *pdev) | ||
526 | { | ||
527 | return !gpio_get_value(GPIO_PTY7); | ||
528 | } | ||
529 | |||
525 | static struct sh_mobile_sdhi_info sdhi0_info = { | 530 | static struct sh_mobile_sdhi_info sdhi0_info = { |
526 | .dma_slave_tx = SHDMA_SLAVE_SDHI0_TX, | 531 | .dma_slave_tx = SHDMA_SLAVE_SDHI0_TX, |
527 | .dma_slave_rx = SHDMA_SLAVE_SDHI0_RX, | 532 | .dma_slave_rx = SHDMA_SLAVE_SDHI0_RX, |
528 | .set_pwr = sdhi0_set_pwr, | 533 | .set_pwr = sdhi0_set_pwr, |
529 | .tmio_caps = MMC_CAP_SDIO_IRQ | MMC_CAP_POWER_OFF_CARD, | 534 | .tmio_caps = MMC_CAP_SDIO_IRQ | MMC_CAP_POWER_OFF_CARD | |
535 | MMC_CAP_NEEDS_POLL, | ||
536 | .get_cd = sdhi0_get_cd, | ||
530 | }; | 537 | }; |
531 | 538 | ||
532 | static struct resource sdhi0_resources[] = { | 539 | static struct resource sdhi0_resources[] = { |
@@ -559,11 +566,18 @@ static void sdhi1_set_pwr(struct platform_device *pdev, int state) | |||
559 | gpio_set_value(GPIO_PTB7, state); | 566 | gpio_set_value(GPIO_PTB7, state); |
560 | } | 567 | } |
561 | 568 | ||
569 | static int sdhi1_get_cd(struct platform_device *pdev) | ||
570 | { | ||
571 | return !gpio_get_value(GPIO_PTW7); | ||
572 | } | ||
573 | |||
562 | static struct sh_mobile_sdhi_info sdhi1_info = { | 574 | static struct sh_mobile_sdhi_info sdhi1_info = { |
563 | .dma_slave_tx = SHDMA_SLAVE_SDHI1_TX, | 575 | .dma_slave_tx = SHDMA_SLAVE_SDHI1_TX, |
564 | .dma_slave_rx = SHDMA_SLAVE_SDHI1_RX, | 576 | .dma_slave_rx = SHDMA_SLAVE_SDHI1_RX, |
565 | .tmio_caps = MMC_CAP_SDIO_IRQ | MMC_CAP_POWER_OFF_CARD, | 577 | .tmio_caps = MMC_CAP_SDIO_IRQ | MMC_CAP_POWER_OFF_CARD | |
578 | MMC_CAP_NEEDS_POLL, | ||
566 | .set_pwr = sdhi1_set_pwr, | 579 | .set_pwr = sdhi1_set_pwr, |
580 | .get_cd = sdhi1_get_cd, | ||
567 | }; | 581 | }; |
568 | 582 | ||
569 | static struct resource sdhi1_resources[] = { | 583 | static struct resource sdhi1_resources[] = { |
@@ -1001,6 +1015,7 @@ extern char ecovec24_sdram_leave_end; | |||
1001 | static int __init arch_setup(void) | 1015 | static int __init arch_setup(void) |
1002 | { | 1016 | { |
1003 | struct clk *clk; | 1017 | struct clk *clk; |
1018 | bool cn12_enabled = false; | ||
1004 | 1019 | ||
1005 | /* register board specific self-refresh code */ | 1020 | /* register board specific self-refresh code */ |
1006 | sh_mobile_register_self_refresh(SUSP_SH_STANDBY | SUSP_SH_SF | | 1021 | sh_mobile_register_self_refresh(SUSP_SH_STANDBY | SUSP_SH_SF | |
@@ -1201,9 +1216,13 @@ static int __init arch_setup(void) | |||
1201 | gpio_direction_input(GPIO_PTR5); | 1216 | gpio_direction_input(GPIO_PTR5); |
1202 | gpio_direction_input(GPIO_PTR6); | 1217 | gpio_direction_input(GPIO_PTR6); |
1203 | 1218 | ||
1219 | /* SD-card slot CN11 */ | ||
1220 | /* Card-detect, used on CN11, either with SDHI0 or with SPI */ | ||
1221 | gpio_request(GPIO_PTY7, NULL); | ||
1222 | gpio_direction_input(GPIO_PTY7); | ||
1223 | |||
1204 | #if defined(CONFIG_MMC_SDHI) || defined(CONFIG_MMC_SDHI_MODULE) | 1224 | #if defined(CONFIG_MMC_SDHI) || defined(CONFIG_MMC_SDHI_MODULE) |
1205 | /* enable SDHI0 on CN11 (needs DS2.4 set to ON) */ | 1225 | /* enable SDHI0 on CN11 (needs DS2.4 set to ON) */ |
1206 | gpio_request(GPIO_FN_SDHI0CD, NULL); | ||
1207 | gpio_request(GPIO_FN_SDHI0WP, NULL); | 1226 | gpio_request(GPIO_FN_SDHI0WP, NULL); |
1208 | gpio_request(GPIO_FN_SDHI0CMD, NULL); | 1227 | gpio_request(GPIO_FN_SDHI0CMD, NULL); |
1209 | gpio_request(GPIO_FN_SDHI0CLK, NULL); | 1228 | gpio_request(GPIO_FN_SDHI0CLK, NULL); |
@@ -1213,23 +1232,6 @@ static int __init arch_setup(void) | |||
1213 | gpio_request(GPIO_FN_SDHI0D0, NULL); | 1232 | gpio_request(GPIO_FN_SDHI0D0, NULL); |
1214 | gpio_request(GPIO_PTB6, NULL); | 1233 | gpio_request(GPIO_PTB6, NULL); |
1215 | gpio_direction_output(GPIO_PTB6, 0); | 1234 | gpio_direction_output(GPIO_PTB6, 0); |
1216 | |||
1217 | #if !defined(CONFIG_MMC_SH_MMCIF) && !defined(CONFIG_MMC_SH_MMCIF_MODULE) | ||
1218 | /* enable SDHI1 on CN12 (needs DS2.6,7 set to ON,OFF) */ | ||
1219 | gpio_request(GPIO_FN_SDHI1CD, NULL); | ||
1220 | gpio_request(GPIO_FN_SDHI1WP, NULL); | ||
1221 | gpio_request(GPIO_FN_SDHI1CMD, NULL); | ||
1222 | gpio_request(GPIO_FN_SDHI1CLK, NULL); | ||
1223 | gpio_request(GPIO_FN_SDHI1D3, NULL); | ||
1224 | gpio_request(GPIO_FN_SDHI1D2, NULL); | ||
1225 | gpio_request(GPIO_FN_SDHI1D1, NULL); | ||
1226 | gpio_request(GPIO_FN_SDHI1D0, NULL); | ||
1227 | gpio_request(GPIO_PTB7, NULL); | ||
1228 | gpio_direction_output(GPIO_PTB7, 0); | ||
1229 | |||
1230 | /* I/O buffer drive ability is high for SDHI1 */ | ||
1231 | __raw_writew((__raw_readw(IODRIVEA) & ~0x3000) | 0x2000 , IODRIVEA); | ||
1232 | #endif /* CONFIG_MMC_SH_MMCIF */ | ||
1233 | #else | 1235 | #else |
1234 | /* enable MSIOF0 on CN11 (needs DS2.4 set to OFF) */ | 1236 | /* enable MSIOF0 on CN11 (needs DS2.4 set to OFF) */ |
1235 | gpio_request(GPIO_FN_MSIOF0_TXD, NULL); | 1237 | gpio_request(GPIO_FN_MSIOF0_TXD, NULL); |
@@ -1241,12 +1243,51 @@ static int __init arch_setup(void) | |||
1241 | gpio_direction_output(GPIO_PTB6, 0); /* disable power by default */ | 1243 | gpio_direction_output(GPIO_PTB6, 0); /* disable power by default */ |
1242 | gpio_request(GPIO_PTY6, NULL); /* write protect */ | 1244 | gpio_request(GPIO_PTY6, NULL); /* write protect */ |
1243 | gpio_direction_input(GPIO_PTY6); | 1245 | gpio_direction_input(GPIO_PTY6); |
1244 | gpio_request(GPIO_PTY7, NULL); /* card detect */ | ||
1245 | gpio_direction_input(GPIO_PTY7); | ||
1246 | 1246 | ||
1247 | spi_register_board_info(spi_bus, ARRAY_SIZE(spi_bus)); | 1247 | spi_register_board_info(spi_bus, ARRAY_SIZE(spi_bus)); |
1248 | #endif | 1248 | #endif |
1249 | 1249 | ||
1250 | /* MMC/SD-card slot CN12 */ | ||
1251 | #if defined(CONFIG_MMC_SH_MMCIF) || defined(CONFIG_MMC_SH_MMCIF_MODULE) | ||
1252 | /* enable MMCIF (needs DS2.6,7 set to OFF,ON) */ | ||
1253 | gpio_request(GPIO_FN_MMC_D7, NULL); | ||
1254 | gpio_request(GPIO_FN_MMC_D6, NULL); | ||
1255 | gpio_request(GPIO_FN_MMC_D5, NULL); | ||
1256 | gpio_request(GPIO_FN_MMC_D4, NULL); | ||
1257 | gpio_request(GPIO_FN_MMC_D3, NULL); | ||
1258 | gpio_request(GPIO_FN_MMC_D2, NULL); | ||
1259 | gpio_request(GPIO_FN_MMC_D1, NULL); | ||
1260 | gpio_request(GPIO_FN_MMC_D0, NULL); | ||
1261 | gpio_request(GPIO_FN_MMC_CLK, NULL); | ||
1262 | gpio_request(GPIO_FN_MMC_CMD, NULL); | ||
1263 | gpio_request(GPIO_PTB7, NULL); | ||
1264 | gpio_direction_output(GPIO_PTB7, 0); | ||
1265 | |||
1266 | cn12_enabled = true; | ||
1267 | #elif defined(CONFIG_MMC_SDHI) || defined(CONFIG_MMC_SDHI_MODULE) | ||
1268 | /* enable SDHI1 on CN12 (needs DS2.6,7 set to ON,OFF) */ | ||
1269 | gpio_request(GPIO_FN_SDHI1WP, NULL); | ||
1270 | gpio_request(GPIO_FN_SDHI1CMD, NULL); | ||
1271 | gpio_request(GPIO_FN_SDHI1CLK, NULL); | ||
1272 | gpio_request(GPIO_FN_SDHI1D3, NULL); | ||
1273 | gpio_request(GPIO_FN_SDHI1D2, NULL); | ||
1274 | gpio_request(GPIO_FN_SDHI1D1, NULL); | ||
1275 | gpio_request(GPIO_FN_SDHI1D0, NULL); | ||
1276 | gpio_request(GPIO_PTB7, NULL); | ||
1277 | gpio_direction_output(GPIO_PTB7, 0); | ||
1278 | |||
1279 | /* Card-detect, used on CN12 with SDHI1 */ | ||
1280 | gpio_request(GPIO_PTW7, NULL); | ||
1281 | gpio_direction_input(GPIO_PTW7); | ||
1282 | |||
1283 | cn12_enabled = true; | ||
1284 | #endif | ||
1285 | |||
1286 | if (cn12_enabled) | ||
1287 | /* I/O buffer drive ability is high for CN12 */ | ||
1288 | __raw_writew((__raw_readw(IODRIVEA) & ~0x3000) | 0x2000, | ||
1289 | IODRIVEA); | ||
1290 | |||
1250 | /* enable Video */ | 1291 | /* enable Video */ |
1251 | gpio_request(GPIO_PTU2, NULL); | 1292 | gpio_request(GPIO_PTU2, NULL); |
1252 | gpio_direction_output(GPIO_PTU2, 1); | 1293 | gpio_direction_output(GPIO_PTU2, 1); |
@@ -1305,25 +1346,6 @@ static int __init arch_setup(void) | |||
1305 | gpio_request(GPIO_PTU5, NULL); | 1346 | gpio_request(GPIO_PTU5, NULL); |
1306 | gpio_direction_output(GPIO_PTU5, 0); | 1347 | gpio_direction_output(GPIO_PTU5, 0); |
1307 | 1348 | ||
1308 | #if defined(CONFIG_MMC_SH_MMCIF) || defined(CONFIG_MMC_SH_MMCIF_MODULE) | ||
1309 | /* enable MMCIF (needs DS2.6,7 set to OFF,ON) */ | ||
1310 | gpio_request(GPIO_FN_MMC_D7, NULL); | ||
1311 | gpio_request(GPIO_FN_MMC_D6, NULL); | ||
1312 | gpio_request(GPIO_FN_MMC_D5, NULL); | ||
1313 | gpio_request(GPIO_FN_MMC_D4, NULL); | ||
1314 | gpio_request(GPIO_FN_MMC_D3, NULL); | ||
1315 | gpio_request(GPIO_FN_MMC_D2, NULL); | ||
1316 | gpio_request(GPIO_FN_MMC_D1, NULL); | ||
1317 | gpio_request(GPIO_FN_MMC_D0, NULL); | ||
1318 | gpio_request(GPIO_FN_MMC_CLK, NULL); | ||
1319 | gpio_request(GPIO_FN_MMC_CMD, NULL); | ||
1320 | gpio_request(GPIO_PTB7, NULL); | ||
1321 | gpio_direction_output(GPIO_PTB7, 0); | ||
1322 | |||
1323 | /* I/O buffer drive ability is high for MMCIF */ | ||
1324 | __raw_writew((__raw_readw(IODRIVEA) & ~0x3000) | 0x2000 , IODRIVEA); | ||
1325 | #endif | ||
1326 | |||
1327 | /* enable I2C device */ | 1349 | /* enable I2C device */ |
1328 | i2c_register_board_info(0, i2c0_devices, | 1350 | i2c_register_board_info(0, i2c0_devices, |
1329 | ARRAY_SIZE(i2c0_devices)); | 1351 | ARRAY_SIZE(i2c0_devices)); |