aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorShawn Guo <shawn.guo@linaro.org>2012-05-05 08:24:01 -0400
committerShawn Guo <shawn.guo@linaro.org>2012-05-12 20:05:31 -0400
commitef9b4d3996624f65ffa928bd7767f0e186687c15 (patch)
treea0172896d66edf625d7c600e78525ee91401c25e
parente0bf141db2e649830a1851f7c5c01f3b9b410778 (diff)
mmc: mxs-mmc: get rid of the use of cpu_is_xxx
The register HW_SSP_VERSION is broken for ssp version detection, as the address of the register is different between imx23 and imx28. Let's use platform_device_id to detect the device, so that the use of cpu_is_xxx can be removed. Signed-off-by: Shawn Guo <shawn.guo@linaro.org> Acked-by: Chris Ball <cjb@laptop.org>
-rw-r--r--arch/arm/mach-mxs/devices/platform-mxs-mmc.c21
-rw-r--r--arch/arm/mach-mxs/include/mach/devices-common.h1
-rw-r--r--drivers/clk/mxs/clk-imx23.c4
-rw-r--r--drivers/clk/mxs/clk-imx28.c8
-rw-r--r--drivers/mmc/host/mxs-mmc.c32
5 files changed, 40 insertions, 26 deletions
diff --git a/arch/arm/mach-mxs/devices/platform-mxs-mmc.c b/arch/arm/mach-mxs/devices/platform-mxs-mmc.c
index bef9d923f54e..b33c9d05c552 100644
--- a/arch/arm/mach-mxs/devices/platform-mxs-mmc.c
+++ b/arch/arm/mach-mxs/devices/platform-mxs-mmc.c
@@ -17,8 +17,9 @@
17#include <mach/mx28.h> 17#include <mach/mx28.h>
18#include <mach/devices-common.h> 18#include <mach/devices-common.h>
19 19
20#define mxs_mxs_mmc_data_entry_single(soc, _id, hwid) \ 20#define mxs_mxs_mmc_data_entry_single(soc, _devid, _id, hwid) \
21 { \ 21 { \
22 .devid = _devid, \
22 .id = _id, \ 23 .id = _id, \
23 .iobase = soc ## _SSP ## hwid ## _BASE_ADDR, \ 24 .iobase = soc ## _SSP ## hwid ## _BASE_ADDR, \
24 .dma = soc ## _DMA_SSP ## hwid, \ 25 .dma = soc ## _DMA_SSP ## hwid, \
@@ -26,23 +27,23 @@
26 .irq_dma = soc ## _INT_SSP ## hwid ## _DMA, \ 27 .irq_dma = soc ## _INT_SSP ## hwid ## _DMA, \
27 } 28 }
28 29
29#define mxs_mxs_mmc_data_entry(soc, _id, hwid) \ 30#define mxs_mxs_mmc_data_entry(soc, _devid, _id, hwid) \
30 [_id] = mxs_mxs_mmc_data_entry_single(soc, _id, hwid) 31 [_id] = mxs_mxs_mmc_data_entry_single(soc, _devid, _id, hwid)
31 32
32 33
33#ifdef CONFIG_SOC_IMX23 34#ifdef CONFIG_SOC_IMX23
34const struct mxs_mxs_mmc_data mx23_mxs_mmc_data[] __initconst = { 35const struct mxs_mxs_mmc_data mx23_mxs_mmc_data[] __initconst = {
35 mxs_mxs_mmc_data_entry(MX23, 0, 1), 36 mxs_mxs_mmc_data_entry(MX23, "imx23-mmc", 0, 1),
36 mxs_mxs_mmc_data_entry(MX23, 1, 2), 37 mxs_mxs_mmc_data_entry(MX23, "imx23-mmc", 1, 2),
37}; 38};
38#endif 39#endif
39 40
40#ifdef CONFIG_SOC_IMX28 41#ifdef CONFIG_SOC_IMX28
41const struct mxs_mxs_mmc_data mx28_mxs_mmc_data[] __initconst = { 42const struct mxs_mxs_mmc_data mx28_mxs_mmc_data[] __initconst = {
42 mxs_mxs_mmc_data_entry(MX28, 0, 0), 43 mxs_mxs_mmc_data_entry(MX28, "imx28-mmc", 0, 0),
43 mxs_mxs_mmc_data_entry(MX28, 1, 1), 44 mxs_mxs_mmc_data_entry(MX28, "imx28-mmc", 1, 1),
44 mxs_mxs_mmc_data_entry(MX28, 2, 2), 45 mxs_mxs_mmc_data_entry(MX28, "imx28-mmc", 2, 2),
45 mxs_mxs_mmc_data_entry(MX28, 3, 3), 46 mxs_mxs_mmc_data_entry(MX28, "imx28-mmc", 3, 3),
46}; 47};
47#endif 48#endif
48 49
@@ -70,6 +71,6 @@ struct platform_device *__init mxs_add_mxs_mmc(
70 }, 71 },
71 }; 72 };
72 73
73 return mxs_add_platform_device("mxs-mmc", data->id, 74 return mxs_add_platform_device(data->devid, data->id,
74 res, ARRAY_SIZE(res), pdata, sizeof(*pdata)); 75 res, ARRAY_SIZE(res), pdata, sizeof(*pdata));
75} 76}
diff --git a/arch/arm/mach-mxs/include/mach/devices-common.h b/arch/arm/mach-mxs/include/mach/devices-common.h
index f2e383955d88..2b37689c74ee 100644
--- a/arch/arm/mach-mxs/include/mach/devices-common.h
+++ b/arch/arm/mach-mxs/include/mach/devices-common.h
@@ -89,6 +89,7 @@ struct platform_device * __init mxs_add_mxs_i2c(
89/* mmc */ 89/* mmc */
90#include <mach/mmc.h> 90#include <mach/mmc.h>
91struct mxs_mxs_mmc_data { 91struct mxs_mxs_mmc_data {
92 const char *devid;
92 int id; 93 int id;
93 resource_size_t iobase; 94 resource_size_t iobase;
94 resource_size_t dma; 95 resource_size_t dma;
diff --git a/drivers/clk/mxs/clk-imx23.c b/drivers/clk/mxs/clk-imx23.c
index 96562f5f92f7..f7be225f544c 100644
--- a/drivers/clk/mxs/clk-imx23.c
+++ b/drivers/clk/mxs/clk-imx23.c
@@ -93,8 +93,8 @@ static struct clk_lookup xbus_lookups[] __initdata = {
93}; 93};
94 94
95static struct clk_lookup ssp_lookups[] __initdata = { 95static struct clk_lookup ssp_lookups[] __initdata = {
96 { .dev_id = "mxs-mmc.0", }, 96 { .dev_id = "imx23-mmc.0", },
97 { .dev_id = "mxs-mmc.1", }, 97 { .dev_id = "imx23-mmc.1", },
98 { .dev_id = "80010000.ssp", }, 98 { .dev_id = "80010000.ssp", },
99 { .dev_id = "80034000.ssp", }, 99 { .dev_id = "80034000.ssp", },
100}; 100};
diff --git a/drivers/clk/mxs/clk-imx28.c b/drivers/clk/mxs/clk-imx28.c
index a7ff4f106ce2..2826a2606a29 100644
--- a/drivers/clk/mxs/clk-imx28.c
+++ b/drivers/clk/mxs/clk-imx28.c
@@ -148,22 +148,22 @@ static struct clk_lookup xbus_lookups[] __initdata = {
148}; 148};
149 149
150static struct clk_lookup ssp0_lookups[] __initdata = { 150static struct clk_lookup ssp0_lookups[] __initdata = {
151 { .dev_id = "mxs-mmc.0", }, 151 { .dev_id = "imx28-mmc.0", },
152 { .dev_id = "80010000.ssp", }, 152 { .dev_id = "80010000.ssp", },
153}; 153};
154 154
155static struct clk_lookup ssp1_lookups[] __initdata = { 155static struct clk_lookup ssp1_lookups[] __initdata = {
156 { .dev_id = "mxs-mmc.1", }, 156 { .dev_id = "imx28-mmc.1", },
157 { .dev_id = "80012000.ssp", }, 157 { .dev_id = "80012000.ssp", },
158}; 158};
159 159
160static struct clk_lookup ssp2_lookups[] __initdata = { 160static struct clk_lookup ssp2_lookups[] __initdata = {
161 { .dev_id = "mxs-mmc.2", }, 161 { .dev_id = "imx28-mmc.2", },
162 { .dev_id = "80014000.ssp", }, 162 { .dev_id = "80014000.ssp", },
163}; 163};
164 164
165static struct clk_lookup ssp3_lookups[] __initdata = { 165static struct clk_lookup ssp3_lookups[] __initdata = {
166 { .dev_id = "mxs-mmc.3", }, 166 { .dev_id = "imx28-mmc.3", },
167 { .dev_id = "80016000.ssp", }, 167 { .dev_id = "80016000.ssp", },
168}; 168};
169 169
diff --git a/drivers/mmc/host/mxs-mmc.c b/drivers/mmc/host/mxs-mmc.c
index a699a8673766..92395563cd82 100644
--- a/drivers/mmc/host/mxs-mmc.c
+++ b/drivers/mmc/host/mxs-mmc.c
@@ -42,7 +42,6 @@
42#include <linux/pinctrl/consumer.h> 42#include <linux/pinctrl/consumer.h>
43#include <linux/stmp_device.h> 43#include <linux/stmp_device.h>
44 44
45#include <mach/mxs.h>
46#include <mach/mmc.h> 45#include <mach/mmc.h>
47 46
48#define DRIVER_NAME "mxs-mmc" 47#define DRIVER_NAME "mxs-mmc"
@@ -50,8 +49,7 @@
50/* card detect polling timeout */ 49/* card detect polling timeout */
51#define MXS_MMC_DETECT_TIMEOUT (HZ/2) 50#define MXS_MMC_DETECT_TIMEOUT (HZ/2)
52 51
53#define SSP_VERSION_LATEST 4 52#define ssp_is_old(host) ((host)->devid == IMX23_MMC)
54#define ssp_is_old(host) ((host)->version < SSP_VERSION_LATEST)
55 53
56/* SSP registers */ 54/* SSP registers */
57#define HW_SSP_CTRL0 0x000 55#define HW_SSP_CTRL0 0x000
@@ -123,8 +121,6 @@
123#define HW_SSP_STATUS(h) (ssp_is_old(h) ? 0x0c0 : 0x100) 121#define HW_SSP_STATUS(h) (ssp_is_old(h) ? 0x0c0 : 0x100)
124#define BM_SSP_STATUS_CARD_DETECT (1 << 28) 122#define BM_SSP_STATUS_CARD_DETECT (1 << 28)
125#define BM_SSP_STATUS_SDIO_IRQ (1 << 17) 123#define BM_SSP_STATUS_SDIO_IRQ (1 << 17)
126#define HW_SSP_VERSION (cpu_is_mx23() ? 0x110 : 0x130)
127#define BP_SSP_VERSION_MAJOR (24)
128 124
129#define BF_SSP(value, field) (((value) << BP_SSP_##field) & BM_SSP_##field) 125#define BF_SSP(value, field) (((value) << BP_SSP_##field) & BM_SSP_##field)
130 126
@@ -139,6 +135,11 @@
139 135
140#define SSP_PIO_NUM 3 136#define SSP_PIO_NUM 3
141 137
138enum mxs_mmc_id {
139 IMX23_MMC,
140 IMX28_MMC,
141};
142
142struct mxs_mmc_host { 143struct mxs_mmc_host {
143 struct mmc_host *mmc; 144 struct mmc_host *mmc;
144 struct mmc_request *mrq; 145 struct mmc_request *mrq;
@@ -158,7 +159,7 @@ struct mxs_mmc_host {
158 enum dma_transfer_direction slave_dirn; 159 enum dma_transfer_direction slave_dirn;
159 u32 ssp_pio_words[SSP_PIO_NUM]; 160 u32 ssp_pio_words[SSP_PIO_NUM];
160 161
161 unsigned int version; 162 enum mxs_mmc_id devid;
162 unsigned char bus_width; 163 unsigned char bus_width;
163 spinlock_t lock; 164 spinlock_t lock;
164 int sdio_irq_en; 165 int sdio_irq_en;
@@ -678,6 +679,19 @@ static bool mxs_mmc_dma_filter(struct dma_chan *chan, void *param)
678 return true; 679 return true;
679} 680}
680 681
682static struct platform_device_id mxs_mmc_ids[] = {
683 {
684 .name = "imx23-mmc",
685 .driver_data = IMX23_MMC,
686 }, {
687 .name = "imx28-mmc",
688 .driver_data = IMX28_MMC,
689 }, {
690 /* sentinel */
691 }
692};
693MODULE_DEVICE_TABLE(platform, mxs_mmc_ids);
694
681static int mxs_mmc_probe(struct platform_device *pdev) 695static int mxs_mmc_probe(struct platform_device *pdev)
682{ 696{
683 struct mxs_mmc_host *host; 697 struct mxs_mmc_host *host;
@@ -712,10 +726,7 @@ static int mxs_mmc_probe(struct platform_device *pdev)
712 goto out_mmc_free; 726 goto out_mmc_free;
713 } 727 }
714 728
715 /* only major verion does matter */ 729 host->devid = pdev->id_entry->driver_data;
716 host->version = readl(host->base + HW_SSP_VERSION) >>
717 BP_SSP_VERSION_MAJOR;
718
719 host->mmc = mmc; 730 host->mmc = mmc;
720 host->res = r; 731 host->res = r;
721 host->dma_res = dmares; 732 host->dma_res = dmares;
@@ -866,6 +877,7 @@ static const struct dev_pm_ops mxs_mmc_pm_ops = {
866static struct platform_driver mxs_mmc_driver = { 877static struct platform_driver mxs_mmc_driver = {
867 .probe = mxs_mmc_probe, 878 .probe = mxs_mmc_probe,
868 .remove = mxs_mmc_remove, 879 .remove = mxs_mmc_remove,
880 .id_table = mxs_mmc_ids,
869 .driver = { 881 .driver = {
870 .name = DRIVER_NAME, 882 .name = DRIVER_NAME,
871 .owner = THIS_MODULE, 883 .owner = THIS_MODULE,