summaryrefslogtreecommitdiff
path: root/arch/arm/mach-mx23
diff options
context:
space:
mode:
authorRichard Zhu <r65037@freescale.com>2010-03-10 11:30:22 +0800
committerAlejandro Gonzalez <alex.gonzalez@digi.com>2010-05-25 11:17:18 +0200
commitc5d471596d41aa71765f7a4342b8cbcac685c4ad (patch)
treea6d0beaf61af7cf2671b97ebb1447b16711dead5 /arch/arm/mach-mx23
parent37c2fd371d8960cef3c7fd7c889475021c362b8f (diff)
ENGR00121415 MX23 SSP SD/MMC driver MXS msl codes porting
porting the SSP SD/MMC driver to the new MSL codes based on MXS model. Signed-off-by: Richard Zhu <r65037@freescale.com> Signed-off-by: Alejandro Gonzalez <alex.gonzalez@digi.com>
Diffstat (limited to 'arch/arm/mach-mx23')
-rw-r--r--arch/arm/mach-mx23/clock.c20
-rw-r--r--arch/arm/mach-mx23/device.c128
-rw-r--r--arch/arm/mach-mx23/mx23evk.c4
-rw-r--r--arch/arm/mach-mx23/mx23evk_pins.c177
4 files changed, 154 insertions, 175 deletions
diff --git a/arch/arm/mach-mx23/clock.c b/arch/arm/mach-mx23/clock.c
index c2ea53e71e3a..a3ff8aee15e5 100644
--- a/arch/arm/mach-mx23/clock.c
+++ b/arch/arm/mach-mx23/clock.c
@@ -382,20 +382,21 @@ static int ssp_set_parent(struct clk *clk, struct clk *parent)
if (clk->bypass_reg) {
if (clk->parent == parent)
+ return 0;
+ if (parent == &ref_io_clk)
__raw_writel(1 << clk->bypass_bits,
- clk->bypass_reg + SET_REGISTER);
- else
- __raw_writel(0 << clk->bypass_bits,
clk->bypass_reg + CLR_REGISTER);
-
+ else
+ __raw_writel(1 << clk->bypass_bits,
+ clk->bypass_reg + SET_REGISTER);
+ clk->parent = parent;
ret = 0;
}
return ret;
}
-static struct clk ssp_clk[] = {
- {
+static struct clk ssp_clk = {
.parent = &ref_io_clk,
.get_rate = ssp_get_rate,
.enable = mx23_raw_enable,
@@ -410,7 +411,6 @@ static struct clk ssp_clk[] = {
.bypass_bits = 3,
.set_rate = ssp_set_rate,
.set_parent = ssp_set_parent,
- },
};
static unsigned long ssp_get_rate(struct clk *clk)
@@ -559,6 +559,10 @@ static struct clk_lookup onchip_clocks[] = {
.clk = &lradc_clk,
},
{
+ .con_id = "ssp.0",
+ .clk = &ssp_clk,
+ },
+ {
.con_id = "emi",
.clk = &emi_clk,
},
@@ -579,6 +583,8 @@ static void mx23_clock_scan(void)
dis_lcdif_clk.parent = &ref_xtal_clk;
if (reg & BM_CLKCTRL_CLKSEQ_BYPASS_EMI)
emi_clk.parent = &ref_xtal_clk;
+ if (reg & BM_CLKCTRL_CLKSEQ_BYPASS_SSP)
+ ssp_clk.parent = &ref_xtal_clk;
};
diff --git a/arch/arm/mach-mx23/device.c b/arch/arm/mach-mx23/device.c
index 9af9601718fd..488f0f46a64b 100644
--- a/arch/arm/mach-mx23/device.c
+++ b/arch/arm/mach-mx23/device.c
@@ -396,6 +396,132 @@ static void __init mx23_init_dcp(void)
}
#endif
+#if defined(CONFIG_MMC_MXS) || defined(CONFIG_MMC_MXS_MODULE)
+#define MMC0_POWER MXS_PIN_TO_GPIO(PINID_PWM3)
+#define MMC0_WP MXS_PIN_TO_GPIO(PINID_PWM4)
+
+static int mxs_mmc_get_wp_mmc0(void)
+{
+ return gpio_get_value(MMC0_WP);
+}
+
+static int mxs_mmc_hw_init_mmc0(void)
+{
+ int ret = 0;
+
+ /* Configure write protect GPIO pin */
+ ret = gpio_request(MMC0_WP, "mmc0_wp");
+ if (ret) {
+ pr_err("wp\r\n");
+ goto out_wp;
+ }
+ gpio_set_value(MMC0_WP, 0);
+ gpio_direction_input(MMC0_WP);
+
+ /* Configure POWER pin as gpio to drive power to MMC slot */
+ ret = gpio_request(MMC0_POWER, "mmc0_power");
+ if (ret) {
+ pr_err("power\r\n");
+ goto out_power;
+ }
+ gpio_direction_output(MMC0_POWER, 0);
+ mdelay(100);
+
+ return 0;
+
+out_power:
+ gpio_free(MMC0_WP);
+out_wp:
+ return ret;
+}
+
+static void mxs_mmc_hw_release_mmc0(void)
+{
+ gpio_free(MMC0_POWER);
+ gpio_free(MMC0_WP);
+
+}
+
+static void mxs_mmc_cmd_pullup_mmc0(int enable)
+{
+ mxs_set_pullup(PINID_SSP1_CMD, enable, "mmc0_cmd");
+}
+
+static unsigned long mxs_mmc_setclock_mmc0(unsigned long hz)
+{
+ struct clk *ssp = clk_get(NULL, "ssp.0"), *parent;
+
+ if (hz > 1000000)
+ parent = clk_get(NULL, "ref_io.0");
+ else
+ parent = clk_get(NULL, "xtal.0");
+
+ clk_set_parent(ssp, parent);
+ clk_set_rate(ssp, 2 * hz);
+ clk_put(parent);
+ clk_put(ssp);
+
+ return hz;
+}
+
+static struct mxs_mmc_platform_data mx23_mmc0_data = {
+ .hw_init = mxs_mmc_hw_init_mmc0,
+ .hw_release = mxs_mmc_hw_release_mmc0,
+ .get_wp = mxs_mmc_get_wp_mmc0,
+ .cmd_pullup = mxs_mmc_cmd_pullup_mmc0,
+ .setclock = mxs_mmc_setclock_mmc0,
+ .caps = MMC_CAP_4_BIT_DATA,
+ .min_clk = 400000,
+ .max_clk = 48000000,
+ .read_uA = 50000,
+ .write_uA = 70000,
+ .clock_mmc = "ssp.0",
+ .power_mmc = NULL,
+};
+
+static struct resource mx23_mmc0_resource[] = {
+ {
+ .flags = IORESOURCE_MEM,
+ .start = SSP1_PHYS_ADDR,
+ .end = SSP1_PHYS_ADDR + 0x2000 - 1,
+ },
+ {
+ .flags = IORESOURCE_DMA,
+ .start = MXS_DMA_CHANNEL_AHB_APBH_SSP1,
+ .end = MXS_DMA_CHANNEL_AHB_APBH_SSP1,
+ },
+ {
+ .flags = IORESOURCE_IRQ,
+ .start = IRQ_SSP1_DMA,
+ .end = IRQ_SSP1_DMA,
+ },
+ {
+ .flags = IORESOURCE_IRQ,
+ .start = IRQ_SSP_ERROR,
+ .end = IRQ_SSP_ERROR,
+ },
+};
+
+static void __init mx23_init_mmc(void)
+{
+ struct platform_device *pdev;
+
+ pdev = mxs_get_device("mxs-mmc", 0);
+ if (pdev == NULL || IS_ERR(pdev))
+ return;
+ pdev->resource = mx23_mmc0_resource;
+ pdev->num_resources = ARRAY_SIZE(mx23_mmc0_resource);
+ pdev->dev.platform_data = &mx23_mmc0_data;
+
+ mxs_add_device(pdev, 2);
+}
+#else
+static void mx23_init_mmc(void)
+{
+ ;
+}
+#endif
+
int __init mx23_device_init(void)
{
mx23_init_dma();
@@ -407,7 +533,7 @@ int __init mx23_device_init(void)
mx23_init_ts();
mx23_init_rtc();
mx23_init_dcp();
-
+ mx23_init_mmc();
return 0;
}
diff --git a/arch/arm/mach-mx23/mx23evk.c b/arch/arm/mach-mx23/mx23evk.c
index 02c315bce3bd..4bf7ae35e167 100644
--- a/arch/arm/mach-mx23/mx23evk.c
+++ b/arch/arm/mach-mx23/mx23evk.c
@@ -46,10 +46,8 @@ static void __init mx23evk_device_init(void)
static void __init mx23evk_init_machine(void)
{
-#if 0
- mx23_gpio_init();
-#endif
mx23_pinctrl_init();
+ mx23_gpio_init();
mx23evk_pins_init();
mx23_device_init();
mx23evk_device_init();
diff --git a/arch/arm/mach-mx23/mx23evk_pins.c b/arch/arm/mach-mx23/mx23evk_pins.c
index 983d0d68f62d..d4060ef35e2c 100644
--- a/arch/arm/mach-mx23/mx23evk_pins.c
+++ b/arch/arm/mach-mx23/mx23evk_pins.c
@@ -324,120 +324,9 @@ static struct pin_desc mx23evk_fixed_pins[] = {
#if defined(CONFIG_MMC_MXS) || defined(CONFIG_MMC_MXS_MODULE)
/* Configurations of SSP0 SD/MMC port pins */
{
- .name = "SSP0_DATA0",
- .id = PINID_SSP0_DATA0,
- .fun = PIN_FUN1,
- .strength = PAD_8MA,
- .voltage = PAD_3_3V,
- .pullup = 1,
- .drive = 1,
- .pull = 1,
- },
- {
- .name = "SSP0_DATA1",
- .id = PINID_SSP0_DATA1,
- .fun = PIN_FUN1,
- .strength = PAD_8MA,
- .voltage = PAD_3_3V,
- .pullup = 1,
- .drive = 1,
- .pull = 1,
- },
- {
- .name = "SSP0_DATA2",
- .id = PINID_SSP0_DATA2,
- .fun = PIN_FUN1,
- .strength = PAD_8MA,
- .voltage = PAD_3_3V,
- .pullup = 1,
- .drive = 1,
- .pull = 1,
- },
- {
- .name = "SSP0_DATA3",
- .id = PINID_SSP0_DATA3,
- .fun = PIN_FUN1,
- .strength = PAD_8MA,
- .voltage = PAD_3_3V,
- .pullup = 1,
- .drive = 1,
- .pull = 1,
- },
- {
- .name = "SSP0_DATA4",
- .id = PINID_SSP0_DATA4,
- .fun = PIN_FUN1,
- .strength = PAD_8MA,
- .voltage = PAD_3_3V,
- .pullup = 1,
- .drive = 1,
- .pull = 1,
- },
- {
- .name = "SSP0_DATA5",
- .id = PINID_SSP0_DATA5,
- .fun = PIN_FUN1,
- .strength = PAD_8MA,
- .voltage = PAD_3_3V,
- .pullup = 1,
- .drive = 1,
- .pull = 1,
- },
- {
- .name = "SSP0_DATA6",
- .id = PINID_SSP0_DATA6,
- .fun = PIN_FUN1,
- .strength = PAD_8MA,
- .voltage = PAD_3_3V,
- .pullup = 1,
- .drive = 1,
- .pull = 1,
- },
- {
- .name = "SSP0_DATA7",
- .id = PINID_SSP0_DATA7,
- .fun = PIN_FUN1,
- .strength = PAD_8MA,
- .voltage = PAD_3_3V,
- .pullup = 1,
- .drive = 1,
- .pull = 1,
- },
- {
- .name = "SSP0_CMD",
- .id = PINID_SSP0_CMD,
- .fun = PIN_FUN1,
- .strength = PAD_8MA,
- .voltage = PAD_3_3V,
- .pullup = 1,
- .drive = 1,
- .pull = 1,
- },
- {
- .name = "SSP0_DETECT",
- .id = PINID_SSP0_DETECT,
- .fun = PIN_FUN1,
- .strength = PAD_8MA,
- .voltage = PAD_3_3V,
- .pullup = 0,
- .drive = 1,
- .pull = 0,
- },
- {
- .name = "SSP0_SCK",
- .id = PINID_SSP0_SCK,
- .fun = PIN_FUN1,
- .strength = PAD_8MA,
- .voltage = PAD_3_3V,
- .pullup = 0,
- .drive = 1,
- .pull = 0,
- },
- /* Configurations of SSP1 SD/MMC port pins */
- {
.name = "SSP1_DATA0",
- .id = PINID_GPMI_D00,
- .fun = PIN_FUN2,
+ .id = PINID_SSP1_DATA0,
+ .fun = PIN_FUN1,
.strength = PAD_8MA,
.voltage = PAD_3_3V,
.pullup = 1,
@@ -446,8 +335,8 @@ static struct pin_desc mx23evk_fixed_pins[] = {
},
{
.name = "SSP1_DATA1",
- .id = PINID_GPMI_D01,
- .fun = PIN_FUN2,
+ .id = PINID_SSP1_DATA1,
+ .fun = PIN_FUN1,
.strength = PAD_8MA,
.voltage = PAD_3_3V,
.pullup = 1,
@@ -456,8 +345,8 @@ static struct pin_desc mx23evk_fixed_pins[] = {
},
{
.name = "SSP1_DATA2",
- .id = PINID_GPMI_D02,
- .fun = PIN_FUN2,
+ .id = PINID_SSP1_DATA2,
+ .fun = PIN_FUN1,
.strength = PAD_8MA,
.voltage = PAD_3_3V,
.pullup = 1,
@@ -466,48 +355,8 @@ static struct pin_desc mx23evk_fixed_pins[] = {
},
{
.name = "SSP1_DATA3",
- .id = PINID_GPMI_D03,
- .fun = PIN_FUN2,
- .strength = PAD_8MA,
- .voltage = PAD_3_3V,
- .pullup = 1,
- .drive = 1,
- .pull = 1,
- },
- {
- .name = "SSP1_DATA4",
- .id = PINID_GPMI_D04,
- .fun = PIN_FUN2,
- .strength = PAD_8MA,
- .voltage = PAD_3_3V,
- .pullup = 1,
- .drive = 1,
- .pull = 1,
- },
- {
- .name = "SSP1_DATA5",
- .id = PINID_GPMI_D05,
- .fun = PIN_FUN2,
- .strength = PAD_8MA,
- .voltage = PAD_3_3V,
- .pullup = 1,
- .drive = 1,
- .pull = 1,
- },
- {
- .name = "SSP1_DATA6",
- .id = PINID_GPMI_D06,
- .fun = PIN_FUN2,
- .strength = PAD_8MA,
- .voltage = PAD_3_3V,
- .pullup = 1,
- .drive = 1,
- .pull = 1,
- },
- {
- .name = "SSP1_DATA7",
- .id = PINID_GPMI_D07,
- .fun = PIN_FUN2,
+ .id = PINID_SSP1_DATA3,
+ .fun = PIN_FUN1,
.strength = PAD_8MA,
.voltage = PAD_3_3V,
.pullup = 1,
@@ -516,8 +365,8 @@ static struct pin_desc mx23evk_fixed_pins[] = {
},
{
.name = "SSP1_CMD",
- .id = PINID_GPMI_RDY1,
- .fun = PIN_FUN2,
+ .id = PINID_SSP1_CMD,
+ .fun = PIN_FUN1,
.strength = PAD_8MA,
.voltage = PAD_3_3V,
.pullup = 1,
@@ -526,7 +375,7 @@ static struct pin_desc mx23evk_fixed_pins[] = {
},
{
.name = "SSP1_DETECT",
- .id = PINID_GPMI_RDY0,
+ .id = PINID_SSP1_DETECT,
.fun = PIN_FUN1,
.strength = PAD_8MA,
.voltage = PAD_3_3V,
@@ -536,8 +385,8 @@ static struct pin_desc mx23evk_fixed_pins[] = {
},
{
.name = "SSP1_SCK",
- .id = PINID_GPMI_WRN,
- .fun = PIN_FUN2,
+ .id = PINID_SSP1_SCK,
+ .fun = PIN_FUN1,
.strength = PAD_8MA,
.voltage = PAD_3_3V,
.pullup = 0,