Commit f67f6c00 authored by Arnd Bergmann's avatar Arnd Bergmann Committed by Krzysztof Kozlowski

ARM: s3c24xx: move s3cmci pinctrl handling into board files

Rather than call the internal s3c_gpio_cfgall_range() function
through a platform header, move the code into the set_power
callback that is already exported by the board, and add
a default implementation.

In DT mode, the code already does not set the pin config,
so nothing changes there.
Signed-off-by: default avatarArnd Bergmann <arnd@arndb.de>
Acked-by: default avatarUlf Hansson <ulf.hansson@linaro.org>
Link: https://lore.kernel.org/r/20200806182059.2431-29-krzk@kernel.org
[krzk: Rebase and correct set_power in mach-h1940.c]
Signed-off-by: default avatarKrzysztof Kozlowski <krzk@kernel.org>
parent 673085f4
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
#include "regs-clock.h" #include "regs-clock.h"
#include "regs-irq.h" #include "regs-irq.h"
#include <mach/irqs.h>
static inline void s3c_pm_debug_init_uart(void) static inline void s3c_pm_debug_init_uart(void)
{ {
......
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
#include <linux/list.h> #include <linux/list.h>
#include <linux/timer.h> #include <linux/timer.h>
#include <linux/init.h> #include <linux/init.h>
#include <linux/gpio/machine.h>
#include <linux/gpio.h> #include <linux/gpio.h>
#include <linux/device.h> #include <linux/device.h>
#include <linux/platform_device.h> #include <linux/platform_device.h>
...@@ -121,6 +122,19 @@ static struct s3c2410_uartcfg amlm5900_uartcfgs[] = { ...@@ -121,6 +122,19 @@ static struct s3c2410_uartcfg amlm5900_uartcfgs[] = {
} }
}; };
static struct gpiod_lookup_table amlm5900_mmc_gpio_table = {
.dev_id = "s3c2410-sdi",
.table = {
/* bus pins */
GPIO_LOOKUP_IDX("GPIOE", 5, "bus", 0, GPIO_ACTIVE_HIGH),
GPIO_LOOKUP_IDX("GPIOE", 6, "bus", 1, GPIO_ACTIVE_HIGH),
GPIO_LOOKUP_IDX("GPIOE", 7, "bus", 2, GPIO_ACTIVE_HIGH),
GPIO_LOOKUP_IDX("GPIOE", 8, "bus", 3, GPIO_ACTIVE_HIGH),
GPIO_LOOKUP_IDX("GPIOE", 9, "bus", 4, GPIO_ACTIVE_HIGH),
GPIO_LOOKUP_IDX("GPIOE", 10, "bus", 5, GPIO_ACTIVE_HIGH),
{ },
},
};
static struct platform_device *amlm5900_devices[] __initdata = { static struct platform_device *amlm5900_devices[] __initdata = {
#ifdef CONFIG_FB_S3C2410 #ifdef CONFIG_FB_S3C2410
...@@ -216,6 +230,7 @@ static void __init amlm5900_init(void) ...@@ -216,6 +230,7 @@ static void __init amlm5900_init(void)
s3c24xx_fb_set_platdata(&amlm5900_fb_info); s3c24xx_fb_set_platdata(&amlm5900_fb_info);
#endif #endif
s3c_i2c0_set_platdata(NULL); s3c_i2c0_set_platdata(NULL);
gpiod_add_lookup_table(&amlm5900_mmc_gpio_table);
platform_add_devices(amlm5900_devices, ARRAY_SIZE(amlm5900_devices)); platform_add_devices(amlm5900_devices, ARRAY_SIZE(amlm5900_devices));
} }
......
...@@ -134,7 +134,7 @@ static struct platform_device at2440evb_device_eth = { ...@@ -134,7 +134,7 @@ static struct platform_device at2440evb_device_eth = {
}; };
static struct s3c24xx_mci_pdata at2440evb_mci_pdata __initdata = { static struct s3c24xx_mci_pdata at2440evb_mci_pdata __initdata = {
/* Intentionally left blank */ .set_power = s3c24xx_mci_def_set_power,
}; };
static struct gpiod_lookup_table at2440evb_mci_gpio_table = { static struct gpiod_lookup_table at2440evb_mci_gpio_table = {
...@@ -142,10 +142,18 @@ static struct gpiod_lookup_table at2440evb_mci_gpio_table = { ...@@ -142,10 +142,18 @@ static struct gpiod_lookup_table at2440evb_mci_gpio_table = {
.table = { .table = {
/* Card detect S3C2410_GPG(10) */ /* Card detect S3C2410_GPG(10) */
GPIO_LOOKUP("GPIOG", 10, "cd", GPIO_ACTIVE_LOW), GPIO_LOOKUP("GPIOG", 10, "cd", GPIO_ACTIVE_LOW),
/* bus pins */
GPIO_LOOKUP_IDX("GPIOE", 5, "bus", 0, GPIO_ACTIVE_HIGH),
GPIO_LOOKUP_IDX("GPIOE", 6, "bus", 1, GPIO_ACTIVE_HIGH),
GPIO_LOOKUP_IDX("GPIOE", 7, "bus", 2, GPIO_ACTIVE_HIGH),
GPIO_LOOKUP_IDX("GPIOE", 8, "bus", 3, GPIO_ACTIVE_HIGH),
GPIO_LOOKUP_IDX("GPIOE", 9, "bus", 4, GPIO_ACTIVE_HIGH),
GPIO_LOOKUP_IDX("GPIOE", 10, "bus", 5, GPIO_ACTIVE_HIGH),
{ }, { },
}, },
}; };
/* 7" LCD panel */ /* 7" LCD panel */
static struct s3c2410fb_display at2440evb_lcd_cfg __initdata = { static struct s3c2410fb_display at2440evb_lcd_cfg __initdata = {
......
...@@ -487,6 +487,20 @@ static struct platform_device gta02_audio = { ...@@ -487,6 +487,20 @@ static struct platform_device gta02_audio = {
.id = -1, .id = -1,
}; };
static struct gpiod_lookup_table gta02_mmc_gpio_table = {
.dev_id = "s3c2410-sdi",
.table = {
/* bus pins */
GPIO_LOOKUP_IDX("GPIOE", 5, "bus", 0, GPIO_ACTIVE_HIGH),
GPIO_LOOKUP_IDX("GPIOE", 6, "bus", 1, GPIO_ACTIVE_HIGH),
GPIO_LOOKUP_IDX("GPIOE", 7, "bus", 2, GPIO_ACTIVE_HIGH),
GPIO_LOOKUP_IDX("GPIOE", 8, "bus", 3, GPIO_ACTIVE_HIGH),
GPIO_LOOKUP_IDX("GPIOE", 9, "bus", 4, GPIO_ACTIVE_HIGH),
GPIO_LOOKUP_IDX("GPIOE", 10, "bus", 5, GPIO_ACTIVE_HIGH),
{ },
},
};
static void __init gta02_map_io(void) static void __init gta02_map_io(void)
{ {
s3c24xx_init_io(gta02_iodesc, ARRAY_SIZE(gta02_iodesc)); s3c24xx_init_io(gta02_iodesc, ARRAY_SIZE(gta02_iodesc));
...@@ -543,6 +557,7 @@ static void __init gta02_machine_init(void) ...@@ -543,6 +557,7 @@ static void __init gta02_machine_init(void)
S3C_GPIO_PULL_NONE); S3C_GPIO_PULL_NONE);
gpiod_add_lookup_table(&gta02_audio_gpio_table); gpiod_add_lookup_table(&gta02_audio_gpio_table);
gpiod_add_lookup_table(&gta02_mmc_gpio_table);
platform_add_devices(gta02_devices, ARRAY_SIZE(gta02_devices)); platform_add_devices(gta02_devices, ARRAY_SIZE(gta02_devices));
pm_power_off = gta02_poweroff; pm_power_off = gta02_poweroff;
......
...@@ -445,6 +445,8 @@ static struct platform_device h1940_device_bluetooth = { ...@@ -445,6 +445,8 @@ static struct platform_device h1940_device_bluetooth = {
static void h1940_set_mmc_power(unsigned char power_mode, unsigned short vdd) static void h1940_set_mmc_power(unsigned char power_mode, unsigned short vdd)
{ {
s3c24xx_mci_def_set_power(power_mode, vdd);
switch (power_mode) { switch (power_mode) {
case MMC_POWER_OFF: case MMC_POWER_OFF:
gpio_set_value(H1940_LATCH_SD_POWER, 0); gpio_set_value(H1940_LATCH_SD_POWER, 0);
...@@ -470,6 +472,13 @@ static struct gpiod_lookup_table h1940_mmc_gpio_table = { ...@@ -470,6 +472,13 @@ static struct gpiod_lookup_table h1940_mmc_gpio_table = {
GPIO_LOOKUP("GPIOF", 5, "cd", GPIO_ACTIVE_LOW), GPIO_LOOKUP("GPIOF", 5, "cd", GPIO_ACTIVE_LOW),
/* Write protect S3C2410_GPH(8) */ /* Write protect S3C2410_GPH(8) */
GPIO_LOOKUP("GPIOH", 8, "wp", GPIO_ACTIVE_LOW), GPIO_LOOKUP("GPIOH", 8, "wp", GPIO_ACTIVE_LOW),
/* bus pins */
GPIO_LOOKUP_IDX("GPIOE", 5, "bus", 0, GPIO_ACTIVE_HIGH),
GPIO_LOOKUP_IDX("GPIOE", 6, "bus", 1, GPIO_ACTIVE_HIGH),
GPIO_LOOKUP_IDX("GPIOE", 7, "bus", 2, GPIO_ACTIVE_HIGH),
GPIO_LOOKUP_IDX("GPIOE", 8, "bus", 3, GPIO_ACTIVE_HIGH),
GPIO_LOOKUP_IDX("GPIOE", 9, "bus", 4, GPIO_ACTIVE_HIGH),
GPIO_LOOKUP_IDX("GPIOE", 10, "bus", 5, GPIO_ACTIVE_HIGH),
{ }, { },
}, },
}; };
......
...@@ -234,7 +234,7 @@ static struct s3c2410fb_mach_info mini2440_fb_info __initdata = { ...@@ -234,7 +234,7 @@ static struct s3c2410fb_mach_info mini2440_fb_info __initdata = {
static struct s3c24xx_mci_pdata mini2440_mmc_cfg __initdata = { static struct s3c24xx_mci_pdata mini2440_mmc_cfg __initdata = {
.wprotect_invert = 1, .wprotect_invert = 1,
.set_power = NULL, .set_power = s3c24xx_mci_def_set_power,
.ocr_avail = MMC_VDD_32_33|MMC_VDD_33_34, .ocr_avail = MMC_VDD_32_33|MMC_VDD_33_34,
}; };
...@@ -245,6 +245,13 @@ static struct gpiod_lookup_table mini2440_mmc_gpio_table = { ...@@ -245,6 +245,13 @@ static struct gpiod_lookup_table mini2440_mmc_gpio_table = {
GPIO_LOOKUP("GPIOG", 8, "cd", GPIO_ACTIVE_LOW), GPIO_LOOKUP("GPIOG", 8, "cd", GPIO_ACTIVE_LOW),
/* Write protect S3C2410_GPH(8) */ /* Write protect S3C2410_GPH(8) */
GPIO_LOOKUP("GPIOH", 8, "wp", GPIO_ACTIVE_HIGH), GPIO_LOOKUP("GPIOH", 8, "wp", GPIO_ACTIVE_HIGH),
/* bus pins */
GPIO_LOOKUP_IDX("GPIOE", 5, "bus", 0, GPIO_ACTIVE_HIGH),
GPIO_LOOKUP_IDX("GPIOE", 6, "bus", 1, GPIO_ACTIVE_HIGH),
GPIO_LOOKUP_IDX("GPIOE", 7, "bus", 2, GPIO_ACTIVE_HIGH),
GPIO_LOOKUP_IDX("GPIOE", 8, "bus", 3, GPIO_ACTIVE_HIGH),
GPIO_LOOKUP_IDX("GPIOE", 9, "bus", 4, GPIO_ACTIVE_HIGH),
GPIO_LOOKUP_IDX("GPIOE", 10, "bus", 5, GPIO_ACTIVE_HIGH),
{ }, { },
}, },
}; };
......
...@@ -368,6 +368,8 @@ static struct s3c2410fb_mach_info n30_fb_info __initdata = { ...@@ -368,6 +368,8 @@ static struct s3c2410fb_mach_info n30_fb_info __initdata = {
static void n30_sdi_set_power(unsigned char power_mode, unsigned short vdd) static void n30_sdi_set_power(unsigned char power_mode, unsigned short vdd)
{ {
s3c24xx_mci_def_set_power(power_mode, vdd);
switch (power_mode) { switch (power_mode) {
case MMC_POWER_ON: case MMC_POWER_ON:
case MMC_POWER_UP: case MMC_POWER_UP:
...@@ -393,6 +395,13 @@ static struct gpiod_lookup_table n30_mci_gpio_table = { ...@@ -393,6 +395,13 @@ static struct gpiod_lookup_table n30_mci_gpio_table = {
/* Write protect S3C2410_GPG(10) */ /* Write protect S3C2410_GPG(10) */
GPIO_LOOKUP("GPIOG", 10, "wp", GPIO_ACTIVE_LOW), GPIO_LOOKUP("GPIOG", 10, "wp", GPIO_ACTIVE_LOW),
{ }, { },
/* bus pins */
GPIO_LOOKUP_IDX("GPIOE", 5, "bus", 0, GPIO_ACTIVE_HIGH),
GPIO_LOOKUP_IDX("GPIOE", 6, "bus", 1, GPIO_ACTIVE_HIGH),
GPIO_LOOKUP_IDX("GPIOE", 7, "bus", 2, GPIO_ACTIVE_HIGH),
GPIO_LOOKUP_IDX("GPIOE", 8, "bus", 3, GPIO_ACTIVE_HIGH),
GPIO_LOOKUP_IDX("GPIOE", 9, "bus", 4, GPIO_ACTIVE_HIGH),
GPIO_LOOKUP_IDX("GPIOE", 10, "bus", 5, GPIO_ACTIVE_HIGH),
}, },
}; };
......
...@@ -223,6 +223,20 @@ static struct gpiod_lookup_table qt2410_spi_gpiod_table = { ...@@ -223,6 +223,20 @@ static struct gpiod_lookup_table qt2410_spi_gpiod_table = {
}, },
}; };
static struct gpiod_lookup_table qt2410_mmc_gpiod_table = {
.dev_id = "s3c2410-sdi",
.table = {
/* bus pins */
GPIO_LOOKUP_IDX("GPIOE", 5, "bus", 0, GPIO_ACTIVE_HIGH),
GPIO_LOOKUP_IDX("GPIOE", 6, "bus", 1, GPIO_ACTIVE_HIGH),
GPIO_LOOKUP_IDX("GPIOE", 7, "bus", 2, GPIO_ACTIVE_HIGH),
GPIO_LOOKUP_IDX("GPIOE", 8, "bus", 3, GPIO_ACTIVE_HIGH),
GPIO_LOOKUP_IDX("GPIOE", 9, "bus", 4, GPIO_ACTIVE_HIGH),
GPIO_LOOKUP_IDX("GPIOE", 10, "bus", 5, GPIO_ACTIVE_HIGH),
{ },
},
};
/* Board devices */ /* Board devices */
static struct platform_device *qt2410_devices[] __initdata = { static struct platform_device *qt2410_devices[] __initdata = {
...@@ -347,6 +361,7 @@ static void __init qt2410_machine_init(void) ...@@ -347,6 +361,7 @@ static void __init qt2410_machine_init(void)
gpiod_add_lookup_table(&qt2410_spi_gpiod_table); gpiod_add_lookup_table(&qt2410_spi_gpiod_table);
s3c_gpio_setpull(S3C2410_GPB(0), S3C_GPIO_PULL_NONE); s3c_gpio_setpull(S3C2410_GPB(0), S3C_GPIO_PULL_NONE);
gpiod_add_lookup_table(&qt2410_led_gpio_table); gpiod_add_lookup_table(&qt2410_led_gpio_table);
gpiod_add_lookup_table(&qt2410_mmc_gpiod_table);
platform_add_devices(qt2410_devices, ARRAY_SIZE(qt2410_devices)); platform_add_devices(qt2410_devices, ARRAY_SIZE(qt2410_devices));
s3c_pm_init(); s3c_pm_init();
} }
......
...@@ -548,6 +548,8 @@ static struct platform_device rx1950_backlight = { ...@@ -548,6 +548,8 @@ static struct platform_device rx1950_backlight = {
static void rx1950_set_mmc_power(unsigned char power_mode, unsigned short vdd) static void rx1950_set_mmc_power(unsigned char power_mode, unsigned short vdd)
{ {
s3c24xx_mci_def_set_power(power_mode, vdd);
switch (power_mode) { switch (power_mode) {
case MMC_POWER_OFF: case MMC_POWER_OFF:
gpio_direction_output(S3C2410_GPJ(1), 0); gpio_direction_output(S3C2410_GPJ(1), 0);
...@@ -573,6 +575,13 @@ static struct gpiod_lookup_table rx1950_mmc_gpio_table = { ...@@ -573,6 +575,13 @@ static struct gpiod_lookup_table rx1950_mmc_gpio_table = {
GPIO_LOOKUP("GPIOF", 5, "cd", GPIO_ACTIVE_LOW), GPIO_LOOKUP("GPIOF", 5, "cd", GPIO_ACTIVE_LOW),
/* Write protect S3C2410_GPH(8) */ /* Write protect S3C2410_GPH(8) */
GPIO_LOOKUP("GPIOH", 8, "wp", GPIO_ACTIVE_LOW), GPIO_LOOKUP("GPIOH", 8, "wp", GPIO_ACTIVE_LOW),
/* bus pins */
GPIO_LOOKUP_IDX("GPIOE", 5, "bus", 0, GPIO_ACTIVE_HIGH),
GPIO_LOOKUP_IDX("GPIOE", 6, "bus", 1, GPIO_ACTIVE_HIGH),
GPIO_LOOKUP_IDX("GPIOE", 7, "bus", 2, GPIO_ACTIVE_HIGH),
GPIO_LOOKUP_IDX("GPIOE", 8, "bus", 3, GPIO_ACTIVE_HIGH),
GPIO_LOOKUP_IDX("GPIOE", 9, "bus", 4, GPIO_ACTIVE_HIGH),
GPIO_LOOKUP_IDX("GPIOE", 10, "bus", 5, GPIO_ACTIVE_HIGH),
{ }, { },
}, },
}; };
......
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
// derived from linux/arch/arm/mach-s3c2410/mach-bast.c, written by // derived from linux/arch/arm/mach-s3c2410/mach-bast.c, written by
// Ben Dooks <ben@simtec.co.uk> // Ben Dooks <ben@simtec.co.uk>
#include <linux/gpio/machine.h>
#include <linux/kernel.h> #include <linux/kernel.h>
#include <linux/types.h> #include <linux/types.h>
#include <linux/interrupt.h> #include <linux/interrupt.h>
...@@ -101,6 +102,19 @@ static struct s3c2410_uartcfg tct_hammer_uartcfgs[] = { ...@@ -101,6 +102,19 @@ static struct s3c2410_uartcfg tct_hammer_uartcfgs[] = {
} }
}; };
static struct gpiod_lookup_table tct_hammer_mmc_gpio_table = {
.dev_id = "s3c2410-sdi",
.table = {
/* bus pins */
GPIO_LOOKUP_IDX("GPIOE", 5, "bus", 0, GPIO_ACTIVE_HIGH),
GPIO_LOOKUP_IDX("GPIOE", 6, "bus", 1, GPIO_ACTIVE_HIGH),
GPIO_LOOKUP_IDX("GPIOE", 7, "bus", 2, GPIO_ACTIVE_HIGH),
GPIO_LOOKUP_IDX("GPIOE", 8, "bus", 3, GPIO_ACTIVE_HIGH),
GPIO_LOOKUP_IDX("GPIOE", 9, "bus", 4, GPIO_ACTIVE_HIGH),
GPIO_LOOKUP_IDX("GPIOE", 10, "bus", 5, GPIO_ACTIVE_HIGH),
{ },
},
};
static struct platform_device *tct_hammer_devices[] __initdata = { static struct platform_device *tct_hammer_devices[] __initdata = {
&s3c_device_adc, &s3c_device_adc,
...@@ -129,6 +143,7 @@ static void __init tct_hammer_init_time(void) ...@@ -129,6 +143,7 @@ static void __init tct_hammer_init_time(void)
static void __init tct_hammer_init(void) static void __init tct_hammer_init(void)
{ {
s3c_i2c0_set_platdata(NULL); s3c_i2c0_set_platdata(NULL);
gpiod_add_lookup_table(&tct_hammer_mmc_gpio_table);
platform_add_devices(tct_hammer_devices, ARRAY_SIZE(tct_hammer_devices)); platform_add_devices(tct_hammer_devices, ARRAY_SIZE(tct_hammer_devices));
} }
......
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
// //
// Base Samsung platform device definitions // Base Samsung platform device definitions
#include <linux/gpio.h>
#include <linux/kernel.h> #include <linux/kernel.h>
#include <linux/types.h> #include <linux/types.h>
#include <linux/interrupt.h> #include <linux/interrupt.h>
...@@ -39,6 +40,7 @@ ...@@ -39,6 +40,7 @@
#include <mach/irqs.h> #include <mach/irqs.h>
#include <mach/map.h> #include <mach/map.h>
#include <mach/gpio-samsung.h>
#ifdef CONFIG_PLAT_S3C24XX #ifdef CONFIG_PLAT_S3C24XX
#include <mach/regs-s3c2443-clock.h> #include <mach/regs-s3c2443-clock.h>
...@@ -46,6 +48,7 @@ ...@@ -46,6 +48,7 @@
#include <plat/cpu.h> #include <plat/cpu.h>
#include <plat/devs.h> #include <plat/devs.h>
#include <plat/gpio-cfg.h>
#include <linux/soc/samsung/s3c-adc.h> #include <linux/soc/samsung/s3c-adc.h>
#include <linux/platform_data/ata-samsung_cf.h> #include <linux/platform_data/ata-samsung_cf.h>
#include <plat/fb.h> #include <plat/fb.h>
...@@ -835,16 +838,42 @@ struct platform_device s3c_device_rtc = { ...@@ -835,16 +838,42 @@ struct platform_device s3c_device_rtc = {
/* SDI */ /* SDI */
#ifdef CONFIG_PLAT_S3C24XX #ifdef CONFIG_PLAT_S3C24XX
void s3c24xx_mci_def_set_power(unsigned char power_mode, unsigned short vdd)
{
switch (power_mode) {
case MMC_POWER_ON:
case MMC_POWER_UP:
/* Configure GPE5...GPE10 pins in SD mode */
s3c_gpio_cfgall_range(S3C2410_GPE(5), 6, S3C_GPIO_SFN(2),
S3C_GPIO_PULL_NONE);
break;
case MMC_POWER_OFF:
default:
gpio_direction_output(S3C2410_GPE(5), 0);
break;
}
}
static struct resource s3c_sdi_resource[] = { static struct resource s3c_sdi_resource[] = {
[0] = DEFINE_RES_MEM(S3C24XX_PA_SDI, S3C24XX_SZ_SDI), [0] = DEFINE_RES_MEM(S3C24XX_PA_SDI, S3C24XX_SZ_SDI),
[1] = DEFINE_RES_IRQ(IRQ_SDI), [1] = DEFINE_RES_IRQ(IRQ_SDI),
}; };
static struct s3c24xx_mci_pdata s3cmci_def_pdata = {
/* This is currently here to avoid a number of if (host->pdata)
* checks. Any zero fields to ensure reasonable defaults are picked. */
.no_wprotect = 1,
.no_detect = 1,
.set_power = s3c24xx_mci_def_set_power,
};
struct platform_device s3c_device_sdi = { struct platform_device s3c_device_sdi = {
.name = "s3c2410-sdi", .name = "s3c2410-sdi",
.id = -1, .id = -1,
.num_resources = ARRAY_SIZE(s3c_sdi_resource), .num_resources = ARRAY_SIZE(s3c_sdi_resource),
.resource = s3c_sdi_resource, .resource = s3c_sdi_resource,
.dev.platform_data = &s3cmci_def_pdata,
}; };
void __init s3c24xx_mci_set_platdata(struct s3c24xx_mci_pdata *pdata) void __init s3c24xx_mci_set_platdata(struct s3c24xx_mci_pdata *pdata)
......
...@@ -24,10 +24,6 @@ ...@@ -24,10 +24,6 @@
#include <linux/of.h> #include <linux/of.h>
#include <linux/of_device.h> #include <linux/of_device.h>
#include <linux/mmc/slot-gpio.h> #include <linux/mmc/slot-gpio.h>
#include <plat/gpio-cfg.h>
#include <mach/gpio-samsung.h>
#include <linux/platform_data/mmc-s3cmci.h> #include <linux/platform_data/mmc-s3cmci.h>
#include "s3cmci.h" #include "s3cmci.h"
...@@ -306,7 +302,8 @@ static inline void clear_imask(struct s3cmci_host *host) ...@@ -306,7 +302,8 @@ static inline void clear_imask(struct s3cmci_host *host)
static void s3cmci_check_sdio_irq(struct s3cmci_host *host) static void s3cmci_check_sdio_irq(struct s3cmci_host *host)
{ {
if (host->sdio_irqen) { if (host->sdio_irqen) {
if (gpio_get_value(S3C2410_GPE(8)) == 0) { if (host->pdata->bus[3] &&
gpiod_get_value(host->pdata->bus[3]) == 0) {
pr_debug("%s: signalling irq\n", __func__); pr_debug("%s: signalling irq\n", __func__);
mmc_signal_sdio_irq(host->mmc); mmc_signal_sdio_irq(host->mmc);
} }
...@@ -1205,33 +1202,20 @@ static void s3cmci_set_ios(struct mmc_host *mmc, struct mmc_ios *ios) ...@@ -1205,33 +1202,20 @@ static void s3cmci_set_ios(struct mmc_host *mmc, struct mmc_ios *ios)
switch (ios->power_mode) { switch (ios->power_mode) {
case MMC_POWER_ON: case MMC_POWER_ON:
case MMC_POWER_UP: case MMC_POWER_UP:
/* Configure GPE5...GPE10 pins in SD mode */
if (!host->pdev->dev.of_node)
s3c_gpio_cfgall_range(S3C2410_GPE(5), 6, S3C_GPIO_SFN(2),
S3C_GPIO_PULL_NONE);
if (host->pdata->set_power)
host->pdata->set_power(ios->power_mode, ios->vdd);
if (!host->is2440) if (!host->is2440)
mci_con |= S3C2410_SDICON_FIFORESET; mci_con |= S3C2410_SDICON_FIFORESET;
break; break;
case MMC_POWER_OFF: case MMC_POWER_OFF:
default: default:
if (!host->pdev->dev.of_node)
gpio_direction_output(S3C2410_GPE(5), 0);
if (host->is2440) if (host->is2440)
mci_con |= S3C2440_SDICON_SDRESET; mci_con |= S3C2440_SDICON_SDRESET;
if (host->pdata->set_power)
host->pdata->set_power(ios->power_mode, ios->vdd);
break; break;
} }
if (host->pdata->set_power)
host->pdata->set_power(ios->power_mode, ios->vdd);
s3cmci_set_clk(host, ios); s3cmci_set_clk(host, ios);
/* Set CLOCK_ENABLE */ /* Set CLOCK_ENABLE */
...@@ -1309,13 +1293,6 @@ static const struct mmc_host_ops s3cmci_ops = { ...@@ -1309,13 +1293,6 @@ static const struct mmc_host_ops s3cmci_ops = {
.enable_sdio_irq = s3cmci_enable_sdio_irq, .enable_sdio_irq = s3cmci_enable_sdio_irq,
}; };
static struct s3c24xx_mci_pdata s3cmci_def_pdata = {
/* This is currently here to avoid a number of if (host->pdata)
* checks. Any zero fields to ensure reasonable defaults are picked. */
.no_wprotect = 1,
.no_detect = 1,
};
#ifdef CONFIG_ARM_S3C24XX_CPUFREQ #ifdef CONFIG_ARM_S3C24XX_CPUFREQ
static int s3cmci_cpufreq_transition(struct notifier_block *nb, static int s3cmci_cpufreq_transition(struct notifier_block *nb,
...@@ -1469,24 +1446,21 @@ static int s3cmci_probe_pdata(struct s3cmci_host *host) ...@@ -1469,24 +1446,21 @@ static int s3cmci_probe_pdata(struct s3cmci_host *host)
int i, ret; int i, ret;
host->is2440 = platform_get_device_id(pdev)->driver_data; host->is2440 = platform_get_device_id(pdev)->driver_data;
pdata = pdev->dev.platform_data;
if (!pdata) {
dev_err(&pdev->dev, "need platform data");
return -ENXIO;
}
for (i = S3C2410_GPE(5); i <= S3C2410_GPE(10); i++) { for (i = 0; i < 6; i++) {
ret = gpio_request(i, dev_name(&pdev->dev)); pdata->bus[i] = devm_gpiod_get_index(&pdev->dev, "bus", i,
if (ret) { GPIOD_OUT_LOW);
if (IS_ERR(pdata->bus[i])) {
dev_err(&pdev->dev, "failed to get gpio %d\n", i); dev_err(&pdev->dev, "failed to get gpio %d\n", i);
return PTR_ERR(pdata->bus[i]);
for (i--; i >= S3C2410_GPE(5); i--)
gpio_free(i);
return ret;
} }
} }
if (!pdev->dev.platform_data)
pdev->dev.platform_data = &s3cmci_def_pdata;
pdata = pdev->dev.platform_data;
if (pdata->no_wprotect) if (pdata->no_wprotect)
mmc->caps2 |= MMC_CAP2_NO_WRITE_PROTECT; mmc->caps2 |= MMC_CAP2_NO_WRITE_PROTECT;
...@@ -1541,7 +1515,6 @@ static int s3cmci_probe(struct platform_device *pdev) ...@@ -1541,7 +1515,6 @@ static int s3cmci_probe(struct platform_device *pdev)
struct s3cmci_host *host; struct s3cmci_host *host;
struct mmc_host *mmc; struct mmc_host *mmc;
int ret; int ret;
int i;
mmc = mmc_alloc_host(sizeof(struct s3cmci_host), &pdev->dev); mmc = mmc_alloc_host(sizeof(struct s3cmci_host), &pdev->dev);
if (!mmc) { if (!mmc) {
...@@ -1585,7 +1558,7 @@ static int s3cmci_probe(struct platform_device *pdev) ...@@ -1585,7 +1558,7 @@ static int s3cmci_probe(struct platform_device *pdev)
"failed to get io memory region resource.\n"); "failed to get io memory region resource.\n");
ret = -ENOENT; ret = -ENOENT;
goto probe_free_gpio; goto probe_free_host;
} }
host->mem = request_mem_region(host->mem->start, host->mem = request_mem_region(host->mem->start,
...@@ -1594,7 +1567,7 @@ static int s3cmci_probe(struct platform_device *pdev) ...@@ -1594,7 +1567,7 @@ static int s3cmci_probe(struct platform_device *pdev)
if (!host->mem) { if (!host->mem) {
dev_err(&pdev->dev, "failed to request io memory region.\n"); dev_err(&pdev->dev, "failed to request io memory region.\n");
ret = -ENOENT; ret = -ENOENT;
goto probe_free_gpio; goto probe_free_host;
} }
host->base = ioremap(host->mem->start, resource_size(host->mem)); host->base = ioremap(host->mem->start, resource_size(host->mem));
...@@ -1718,11 +1691,6 @@ static int s3cmci_probe(struct platform_device *pdev) ...@@ -1718,11 +1691,6 @@ static int s3cmci_probe(struct platform_device *pdev)
probe_free_mem_region: probe_free_mem_region:
release_mem_region(host->mem->start, resource_size(host->mem)); release_mem_region(host->mem->start, resource_size(host->mem));
probe_free_gpio:
if (!pdev->dev.of_node)
for (i = S3C2410_GPE(5); i <= S3C2410_GPE(10); i++)
gpio_free(i);
probe_free_host: probe_free_host:
mmc_free_host(mmc); mmc_free_host(mmc);
...@@ -1748,7 +1716,6 @@ static int s3cmci_remove(struct platform_device *pdev) ...@@ -1748,7 +1716,6 @@ static int s3cmci_remove(struct platform_device *pdev)
{ {
struct mmc_host *mmc = platform_get_drvdata(pdev); struct mmc_host *mmc = platform_get_drvdata(pdev);
struct s3cmci_host *host = mmc_priv(mmc); struct s3cmci_host *host = mmc_priv(mmc);
int i;
s3cmci_shutdown(pdev); s3cmci_shutdown(pdev);
...@@ -1761,10 +1728,6 @@ static int s3cmci_remove(struct platform_device *pdev) ...@@ -1761,10 +1728,6 @@ static int s3cmci_remove(struct platform_device *pdev)
free_irq(host->irq, host); free_irq(host->irq, host);
if (!pdev->dev.of_node)
for (i = S3C2410_GPE(5); i <= S3C2410_GPE(10); i++)
gpio_free(i);
iounmap(host->base); iounmap(host->base);
release_mem_region(host->mem->start, resource_size(host->mem)); release_mem_region(host->mem->start, resource_size(host->mem));
......
...@@ -35,6 +35,7 @@ struct s3c24xx_mci_pdata { ...@@ -35,6 +35,7 @@ struct s3c24xx_mci_pdata {
unsigned long ocr_avail; unsigned long ocr_avail;
void (*set_power)(unsigned char power_mode, void (*set_power)(unsigned char power_mode,
unsigned short vdd); unsigned short vdd);
struct gpio_desc *bus[6];
}; };
/** /**
...@@ -44,6 +45,7 @@ struct s3c24xx_mci_pdata { ...@@ -44,6 +45,7 @@ struct s3c24xx_mci_pdata {
* Copy the platform data supplied by @pdata so that this can be marked * Copy the platform data supplied by @pdata so that this can be marked
* __initdata. * __initdata.
*/ */
extern void s3c24xx_mci_def_set_power(unsigned char power_mode, unsigned short vdd);
extern void s3c24xx_mci_set_platdata(struct s3c24xx_mci_pdata *pdata); extern void s3c24xx_mci_set_platdata(struct s3c24xx_mci_pdata *pdata);
#endif /* _ARCH_NCI_H */ #endif /* _ARCH_NCI_H */
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment