1111#include <linux/clk.h>
1212#include <linux/delay.h>
1313#include <linux/gpio.h>
14+ #include <linux/gpio/machine.h>
1415#include <linux/init.h>
1516#include <linux/io.h>
1617#include <linux/irq.h>
@@ -170,22 +171,32 @@ static struct spi_board_info n800_spi_board_info[] __initdata = {
170171 * GPIO23 and GPIO9 slot 2 EMMC on N810
171172 *
172173 */
173- #define N8X0_SLOT_SWITCH_GPIO 96
174- #define N810_EMMC_VSD_GPIO 23
175- #define N810_EMMC_VIO_GPIO 9
176-
177174static int slot1_cover_open ;
178175static int slot2_cover_open ;
179176static struct device * mmc_device ;
180177
181- static int n8x0_mmc_switch_slot (struct device * dev , int slot )
182- {
183- #ifdef CONFIG_MMC_DEBUG
184- dev_dbg (dev , "Choose slot %d\n" , slot + 1 );
185- #endif
186- gpio_set_value (N8X0_SLOT_SWITCH_GPIO , slot );
187- return 0 ;
188- }
178+ static struct gpiod_lookup_table nokia8xx_mmc_gpio_table = {
179+ .dev_id = "mmci-omap.0" ,
180+ .table = {
181+ /* Slot switch, GPIO 96 */
182+ GPIO_LOOKUP ("gpio-80-111" , 16 ,
183+ "switch" , GPIO_ACTIVE_HIGH ),
184+ { }
185+ },
186+ };
187+
188+ static struct gpiod_lookup_table nokia810_mmc_gpio_table = {
189+ .dev_id = "mmci-omap.0" ,
190+ .table = {
191+ /* Slot index 1, VSD power, GPIO 23 */
192+ GPIO_LOOKUP_IDX ("gpio-16-31" , 7 ,
193+ "vsd" , 1 , GPIO_ACTIVE_HIGH ),
194+ /* Slot index 1, VIO power, GPIO 9 */
195+ GPIO_LOOKUP_IDX ("gpio-0-15" , 9 ,
196+ "vsd" , 1 , GPIO_ACTIVE_HIGH ),
197+ { }
198+ },
199+ };
189200
190201static int n8x0_mmc_set_power_menelaus (struct device * dev , int slot ,
191202 int power_on , int vdd )
@@ -256,31 +267,13 @@ static int n8x0_mmc_set_power_menelaus(struct device *dev, int slot,
256267 return 0 ;
257268}
258269
259- static void n810_set_power_emmc (struct device * dev ,
260- int power_on )
261- {
262- dev_dbg (dev , "Set EMMC power %s\n" , power_on ? "on" : "off" );
263-
264- if (power_on ) {
265- gpio_set_value (N810_EMMC_VSD_GPIO , 1 );
266- msleep (1 );
267- gpio_set_value (N810_EMMC_VIO_GPIO , 1 );
268- msleep (1 );
269- } else {
270- gpio_set_value (N810_EMMC_VIO_GPIO , 0 );
271- msleep (50 );
272- gpio_set_value (N810_EMMC_VSD_GPIO , 0 );
273- msleep (50 );
274- }
275- }
276-
277270static int n8x0_mmc_set_power (struct device * dev , int slot , int power_on ,
278271 int vdd )
279272{
280273 if (board_is_n800 () || slot == 0 )
281274 return n8x0_mmc_set_power_menelaus (dev , slot , power_on , vdd );
282275
283- n810_set_power_emmc ( dev , power_on );
276+ /* The n810 power will be handled by GPIO code in the driver */
284277
285278 return 0 ;
286279}
@@ -418,13 +411,6 @@ static void n8x0_mmc_shutdown(struct device *dev)
418411static void n8x0_mmc_cleanup (struct device * dev )
419412{
420413 menelaus_unregister_mmc_callback ();
421-
422- gpio_free (N8X0_SLOT_SWITCH_GPIO );
423-
424- if (board_is_n810 ()) {
425- gpio_free (N810_EMMC_VSD_GPIO );
426- gpio_free (N810_EMMC_VIO_GPIO );
427- }
428414}
429415
430416/*
@@ -433,7 +419,6 @@ static void n8x0_mmc_cleanup(struct device *dev)
433419 */
434420static struct omap_mmc_platform_data mmc1_data = {
435421 .nr_slots = 0 ,
436- .switch_slot = n8x0_mmc_switch_slot ,
437422 .init = n8x0_mmc_late_init ,
438423 .cleanup = n8x0_mmc_cleanup ,
439424 .shutdown = n8x0_mmc_shutdown ,
@@ -463,14 +448,9 @@ static struct omap_mmc_platform_data mmc1_data = {
463448
464449static struct omap_mmc_platform_data * mmc_data [OMAP24XX_NR_MMC ];
465450
466- static struct gpio n810_emmc_gpios [] __initdata = {
467- { N810_EMMC_VSD_GPIO , GPIOF_OUT_INIT_LOW , "MMC slot 2 Vddf" },
468- { N810_EMMC_VIO_GPIO , GPIOF_OUT_INIT_LOW , "MMC slot 2 Vdd" },
469- };
470-
471451static void __init n8x0_mmc_init (void )
472452{
473- int err ;
453+ gpiod_add_lookup_table ( & nokia8xx_mmc_gpio_table ) ;
474454
475455 if (board_is_n810 ()) {
476456 mmc1_data .slots [0 ].name = "external" ;
@@ -483,20 +463,7 @@ static void __init n8x0_mmc_init(void)
483463 */
484464 mmc1_data .slots [1 ].name = "internal" ;
485465 mmc1_data .slots [1 ].ban_openended = 1 ;
486- }
487-
488- err = gpio_request_one (N8X0_SLOT_SWITCH_GPIO , GPIOF_OUT_INIT_LOW ,
489- "MMC slot switch" );
490- if (err )
491- return ;
492-
493- if (board_is_n810 ()) {
494- err = gpio_request_array (n810_emmc_gpios ,
495- ARRAY_SIZE (n810_emmc_gpios ));
496- if (err ) {
497- gpio_free (N8X0_SLOT_SWITCH_GPIO );
498- return ;
499- }
466+ gpiod_add_lookup_table (& nokia810_mmc_gpio_table );
500467 }
501468
502469 mmc1_data .nr_slots = 2 ;
0 commit comments