* [PATCH 1/3] spi: imx: drop use of enum
@ 2014-02-10 7:41 Sascha Hauer
2014-02-10 7:41 ` [PATCH 2/3] spi: imx: Use IS_ENABLED to drop ifdefs Sascha Hauer
2014-02-10 7:41 ` [PATCH 3/3] spi: imx: Use device ids Sascha Hauer
0 siblings, 2 replies; 3+ messages in thread
From: Sascha Hauer @ 2014-02-10 7:41 UTC (permalink / raw)
To: barebox
enum imx_spi_devtype is used as index into an array of controller types.
This makes the controller type handling unnecessarily complicated. Just
drop the enum and instead of an array use different statically initialized
structs and referene them by name.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
drivers/spi/imx_spi.c | 69 ++++++++++++++++++---------------------------------
1 file changed, 24 insertions(+), 45 deletions(-)
diff --git a/drivers/spi/imx_spi.c b/drivers/spi/imx_spi.c
index c0c2ed7..80655a7 100644
--- a/drivers/spi/imx_spi.c
+++ b/drivers/spi/imx_spi.c
@@ -107,27 +107,6 @@
#define CSPI_2_3_STAT 0x18
#define CSPI_2_3_STAT_RR (1 << 3)
-enum imx_spi_devtype {
-#ifdef CONFIG_DRIVER_SPI_IMX1
- SPI_IMX_VER_IMX1,
-#endif
-#ifdef CONFIG_DRIVER_SPI_IMX_0_0
- SPI_IMX_VER_0_0,
-#endif
-#ifdef CONFIG_DRIVER_SPI_IMX_0_4
- SPI_IMX_VER_0_4,
-#endif
-#ifdef CONFIG_DRIVER_SPI_IMX_0_5
- SPI_IMX_VER_0_5,
-#endif
-#ifdef CONFIG_DRIVER_SPI_IMX_0_7
- SPI_IMX_VER_0_7,
-#endif
-#ifdef CONFIG_DRIVER_SPI_IMX_2_3
- SPI_IMX_VER_2_3,
-#endif
-};
-
struct imx_spi {
struct spi_master master;
int *cs_array;
@@ -473,29 +452,29 @@ static int imx_spi_transfer(struct spi_device *spi, struct spi_message *mesg)
return 0;
}
-static struct spi_imx_devtype_data spi_imx_devtype_data[] = {
#ifdef CONFIG_DRIVER_SPI_IMX_0_0
- [SPI_IMX_VER_0_0] = {
- .chipselect = cspi_0_0_chipselect,
- .xchg_single = cspi_0_0_xchg_single,
- .init = cspi_0_0_init,
- },
+static struct spi_imx_devtype_data spi_imx_devtype_data_0_0 = {
+ .chipselect = cspi_0_0_chipselect,
+ .xchg_single = cspi_0_0_xchg_single,
+ .init = cspi_0_0_init,
+};
#endif
+
#ifdef CONFIG_DRIVER_SPI_IMX_0_7
- [SPI_IMX_VER_0_7] = {
- .chipselect = cspi_0_7_chipselect,
- .xchg_single = cspi_0_7_xchg_single,
- .init = cspi_0_7_init,
- },
+static struct spi_imx_devtype_data spi_imx_devtype_data_0_7 = {
+ .chipselect = cspi_0_7_chipselect,
+ .xchg_single = cspi_0_7_xchg_single,
+ .init = cspi_0_7_init,
+};
#endif
+
#ifdef CONFIG_DRIVER_SPI_IMX_2_3
- [SPI_IMX_VER_2_3] = {
- .chipselect = cspi_2_3_chipselect,
- .xchg_single = cspi_2_3_xchg_single,
- .init = cspi_2_3_init,
- },
-#endif
+static struct spi_imx_devtype_data spi_imx_devtype_data_2_3 = {
+ .chipselect = cspi_2_3_chipselect,
+ .xchg_single = cspi_2_3_xchg_single,
+ .init = cspi_2_3_init,
};
+#endif
static int imx_spi_dt_probe(struct imx_spi *imx)
{
@@ -526,7 +505,7 @@ static int imx_spi_probe(struct device_d *dev)
struct spi_master *master;
struct imx_spi *imx;
struct spi_imx_master *pdata = dev->platform_data;
- enum imx_spi_devtype version;
+ struct spi_imx_devtype_data *devdata;
int ret;
imx = xzalloc(sizeof(*imx));
@@ -554,19 +533,19 @@ static int imx_spi_probe(struct device_d *dev)
#ifdef CONFIG_DRIVER_SPI_IMX_0_0
if (cpu_is_mx27())
- version = SPI_IMX_VER_0_0;
+ devdata = &spi_imx_devtype_data_0_0;
#endif
#ifdef CONFIG_DRIVER_SPI_IMX_0_7
if (cpu_is_mx25() || cpu_is_mx35())
- version = SPI_IMX_VER_0_7;
+ devdata = &spi_imx_devtype_data_0_7;
#endif
#ifdef CONFIG_DRIVER_SPI_IMX_2_3
if (cpu_is_mx51() || cpu_is_mx53() || cpu_is_mx6())
- version = SPI_IMX_VER_2_3;
+ devdata = &spi_imx_devtype_data_2_3;
#endif
- imx->chipselect = spi_imx_devtype_data[version].chipselect;
- imx->xchg_single = spi_imx_devtype_data[version].xchg_single;
- imx->init = spi_imx_devtype_data[version].init;
+ imx->chipselect = devdata->chipselect;
+ imx->xchg_single = devdata->xchg_single;
+ imx->init = devdata->init;
imx->regs = dev_request_mem_region(dev, 0);
imx->init(imx);
--
1.8.5.3
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH 2/3] spi: imx: Use IS_ENABLED to drop ifdefs
2014-02-10 7:41 [PATCH 1/3] spi: imx: drop use of enum Sascha Hauer
@ 2014-02-10 7:41 ` Sascha Hauer
2014-02-10 7:41 ` [PATCH 3/3] spi: imx: Use device ids Sascha Hauer
1 sibling, 0 replies; 3+ messages in thread
From: Sascha Hauer @ 2014-02-10 7:41 UTC (permalink / raw)
To: barebox
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
drivers/spi/imx_spi.c | 29 ++++++++---------------------
1 file changed, 8 insertions(+), 21 deletions(-)
diff --git a/drivers/spi/imx_spi.c b/drivers/spi/imx_spi.c
index 80655a7..a1b91a9 100644
--- a/drivers/spi/imx_spi.c
+++ b/drivers/spi/imx_spi.c
@@ -136,7 +136,6 @@ static int imx_spi_setup(struct spi_device *spi)
return 0;
}
-#ifdef CONFIG_DRIVER_SPI_IMX_0_0
static unsigned int cspi_0_0_xchg_single(struct imx_spi *imx, unsigned int data)
{
void __iomem *base = imx->regs;
@@ -206,9 +205,7 @@ static void cspi_0_0_init(struct imx_spi *imx)
readl(base + CSPI_0_0_RXDATA);
writel(0, base + CSPI_0_0_INT);
}
-#endif
-#ifdef CONFIG_DRIVER_SPI_IMX_0_7
static unsigned int cspi_0_7_xchg_single(struct imx_spi *imx, unsigned int data)
{
void __iomem *base = imx->regs;
@@ -289,9 +286,7 @@ static void cspi_0_7_init(struct imx_spi *imx)
while (readl(base + CSPI_0_7_STAT) & CSPI_0_7_STAT_RR)
readl(base + CSPI_0_7_RXDATA);
}
-#endif
-#ifdef CONFIG_DRIVER_SPI_IMX_2_3
static unsigned int cspi_2_3_xchg_single(struct imx_spi *imx, unsigned int data)
{
void __iomem *base = imx->regs;
@@ -393,7 +388,6 @@ static void cspi_2_3_chipselect(struct spi_device *spi, int is_active)
static void cspi_2_3_init(struct imx_spi *imx)
{
}
-#endif
static void imx_spi_do_transfer(struct spi_device *spi, struct spi_transfer *t)
{
@@ -452,29 +446,23 @@ static int imx_spi_transfer(struct spi_device *spi, struct spi_message *mesg)
return 0;
}
-#ifdef CONFIG_DRIVER_SPI_IMX_0_0
static struct spi_imx_devtype_data spi_imx_devtype_data_0_0 = {
.chipselect = cspi_0_0_chipselect,
.xchg_single = cspi_0_0_xchg_single,
.init = cspi_0_0_init,
};
-#endif
-#ifdef CONFIG_DRIVER_SPI_IMX_0_7
static struct spi_imx_devtype_data spi_imx_devtype_data_0_7 = {
.chipselect = cspi_0_7_chipselect,
.xchg_single = cspi_0_7_xchg_single,
.init = cspi_0_7_init,
};
-#endif
-#ifdef CONFIG_DRIVER_SPI_IMX_2_3
static struct spi_imx_devtype_data spi_imx_devtype_data_2_3 = {
.chipselect = cspi_2_3_chipselect,
.xchg_single = cspi_2_3_xchg_single,
.init = cspi_2_3_init,
};
-#endif
static int imx_spi_dt_probe(struct imx_spi *imx)
{
@@ -531,18 +519,17 @@ static int imx_spi_probe(struct device_d *dev)
goto err_free;
}
-#ifdef CONFIG_DRIVER_SPI_IMX_0_0
- if (cpu_is_mx27())
+ if (IS_ENABLED(CONFIG_DRIVER_SPI_IMX_0_0) && cpu_is_mx27())
devdata = &spi_imx_devtype_data_0_0;
-#endif
-#ifdef CONFIG_DRIVER_SPI_IMX_0_7
- if (cpu_is_mx25() || cpu_is_mx35())
+
+ if (IS_ENABLED(CONFIG_DRIVER_SPI_IMX_0_0) &&
+ (cpu_is_mx25() || cpu_is_mx35()))
devdata = &spi_imx_devtype_data_0_7;
-#endif
-#ifdef CONFIG_DRIVER_SPI_IMX_2_3
- if (cpu_is_mx51() || cpu_is_mx53() || cpu_is_mx6())
+
+ if (IS_ENABLED(CONFIG_DRIVER_SPI_IMX_2_3) &&
+ (cpu_is_mx51() || cpu_is_mx53() || cpu_is_mx6()))
devdata = &spi_imx_devtype_data_2_3;
-#endif
+
imx->chipselect = devdata->chipselect;
imx->xchg_single = devdata->xchg_single;
imx->init = devdata->init;
--
1.8.5.3
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH 3/3] spi: imx: Use device ids
2014-02-10 7:41 [PATCH 1/3] spi: imx: drop use of enum Sascha Hauer
2014-02-10 7:41 ` [PATCH 2/3] spi: imx: Use IS_ENABLED to drop ifdefs Sascha Hauer
@ 2014-02-10 7:41 ` Sascha Hauer
1 sibling, 0 replies; 3+ messages in thread
From: Sascha Hauer @ 2014-02-10 7:41 UTC (permalink / raw)
To: barebox
To let the driver work on all SoCs without the use of cpu_is_*()
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
arch/arm/mach-imx/devices.c | 14 +++++-
arch/arm/mach-imx/include/mach/devices-imx25.h | 6 +--
arch/arm/mach-imx/include/mach/devices-imx27.h | 4 +-
arch/arm/mach-imx/include/mach/devices-imx31.h | 6 +--
arch/arm/mach-imx/include/mach/devices-imx35.h | 4 +-
arch/arm/mach-imx/include/mach/devices-imx51.h | 6 +--
arch/arm/mach-imx/include/mach/devices-imx53.h | 4 +-
arch/arm/mach-imx/include/mach/devices-imx6.h | 10 ++--
arch/arm/mach-imx/include/mach/devices.h | 4 +-
drivers/spi/imx_spi.c | 66 +++++++++++++++++++-------
10 files changed, 83 insertions(+), 41 deletions(-)
diff --git a/arch/arm/mach-imx/devices.c b/arch/arm/mach-imx/devices.c
index 682f39a..11444ef 100644
--- a/arch/arm/mach-imx/devices.c
+++ b/arch/arm/mach-imx/devices.c
@@ -18,9 +18,19 @@ struct device_d *imx_add_fec_imx6(void *base, struct fec_platform_data *pdata)
return imx_add_device("imx6-fec", -1, base, 0x1000, pdata);
}
-struct device_d *imx_add_spi(void *base, int id, struct spi_imx_master *pdata)
+struct device_d *imx_add_spi_imx27(void *base, int id, struct spi_imx_master *pdata)
{
- return imx_add_device("imx_spi", id, base, 0x1000, pdata);
+ return imx_add_device("imx27-spi", id, base, 0x1000, pdata);
+}
+
+struct device_d *imx_add_spi_imx35(void *base, int id, struct spi_imx_master *pdata)
+{
+ return imx_add_device("imx35-spi", id, base, 0x1000, pdata);
+}
+
+struct device_d *imx_add_spi_imx51(void *base, int id, struct spi_imx_master *pdata)
+{
+ return imx_add_device("imx51-spi", id, base, 0x1000, pdata);
}
struct device_d *imx_add_i2c(void *base, int id, struct i2c_platform_data *pdata)
diff --git a/arch/arm/mach-imx/include/mach/devices-imx25.h b/arch/arm/mach-imx/include/mach/devices-imx25.h
index 5b582b8..eea8a60 100644
--- a/arch/arm/mach-imx/include/mach/devices-imx25.h
+++ b/arch/arm/mach-imx/include/mach/devices-imx25.h
@@ -19,17 +19,17 @@ static inline struct device_d *imx25_add_i2c2(struct i2c_platform_data *pdata)
static inline struct device_d *imx25_add_spi0(struct spi_imx_master *pdata)
{
- return imx_add_spi((void *)MX25_CSPI1_BASE_ADDR, 0, pdata);
+ return imx_add_spi_imx35((void *)MX25_CSPI1_BASE_ADDR, 0, pdata);
}
static inline struct device_d *imx25_add_spi1(struct spi_imx_master *pdata)
{
- return imx_add_spi((void *)MX25_CSPI2_BASE_ADDR, 1, pdata);
+ return imx_add_spi_imx35((void *)MX25_CSPI2_BASE_ADDR, 1, pdata);
}
static inline struct device_d *imx25_add_spi2(struct spi_imx_master *pdata)
{
- return imx_add_spi((void *)MX25_CSPI3_BASE_ADDR, 2, pdata);
+ return imx_add_spi_imx35((void *)MX25_CSPI3_BASE_ADDR, 2, pdata);
}
static inline struct device_d *imx25_add_uart0(void)
diff --git a/arch/arm/mach-imx/include/mach/devices-imx27.h b/arch/arm/mach-imx/include/mach/devices-imx27.h
index 87a3a7c..da2289b 100644
--- a/arch/arm/mach-imx/include/mach/devices-imx27.h
+++ b/arch/arm/mach-imx/include/mach/devices-imx27.h
@@ -4,12 +4,12 @@
static inline struct device_d *imx27_add_spi0(struct spi_imx_master *pdata)
{
- return imx_add_spi((void *)MX27_CSPI1_BASE_ADDR, 0, pdata);
+ return imx_add_spi_imx27((void *)MX27_CSPI1_BASE_ADDR, 0, pdata);
}
static inline struct device_d *imx27_add_spi1(struct spi_imx_master *pdata)
{
- return imx_add_spi((void *)MX27_CSPI2_BASE_ADDR, 1, pdata);
+ return imx_add_spi_imx27((void *)MX27_CSPI2_BASE_ADDR, 1, pdata);
}
static inline struct device_d *imx27_add_i2c0(struct i2c_platform_data *pdata)
diff --git a/arch/arm/mach-imx/include/mach/devices-imx31.h b/arch/arm/mach-imx/include/mach/devices-imx31.h
index 7cf9114..63319fe 100644
--- a/arch/arm/mach-imx/include/mach/devices-imx31.h
+++ b/arch/arm/mach-imx/include/mach/devices-imx31.h
@@ -4,17 +4,17 @@
static inline struct device_d *imx31_add_spi0(struct spi_imx_master *pdata)
{
- return imx_add_spi((void *)MX31_CSPI1_BASE_ADDR, 0, pdata);
+ return imx_add_spi_imx27((void *)MX31_CSPI1_BASE_ADDR, 0, pdata);
}
static inline struct device_d *imx31_add_spi1(struct spi_imx_master *pdata)
{
- return imx_add_spi((void *)MX31_CSPI2_BASE_ADDR, 1, pdata);
+ return imx_add_spi_imx27((void *)MX31_CSPI2_BASE_ADDR, 1, pdata);
}
static inline struct device_d *imx31_add_spi2(struct spi_imx_master *pdata)
{
- return imx_add_spi((void *)MX31_CSPI3_BASE_ADDR, 2, pdata);
+ return imx_add_spi_imx27((void *)MX31_CSPI3_BASE_ADDR, 2, pdata);
}
static inline struct device_d *imx31_add_uart0(void)
diff --git a/arch/arm/mach-imx/include/mach/devices-imx35.h b/arch/arm/mach-imx/include/mach/devices-imx35.h
index 766610d..3e53167 100644
--- a/arch/arm/mach-imx/include/mach/devices-imx35.h
+++ b/arch/arm/mach-imx/include/mach/devices-imx35.h
@@ -19,12 +19,12 @@ static inline struct device_d *imx35_add_i2c2(struct i2c_platform_data *pdata)
static inline struct device_d *imx35_add_spi0(struct spi_imx_master *pdata)
{
- return imx_add_spi((void *)MX35_CSPI1_BASE_ADDR, 0, pdata);
+ return imx_add_spi_imx35((void *)MX35_CSPI1_BASE_ADDR, 0, pdata);
}
static inline struct device_d *imx35_add_spi(struct spi_imx_master *pdata)
{
- return imx_add_spi((void *)MX35_CSPI2_BASE_ADDR, 1, pdata);
+ return imx_add_spi_imx35((void *)MX35_CSPI2_BASE_ADDR, 1, pdata);
}
static inline struct device_d *imx35_add_uart0(void)
diff --git a/arch/arm/mach-imx/include/mach/devices-imx51.h b/arch/arm/mach-imx/include/mach/devices-imx51.h
index 0064478..6895329 100644
--- a/arch/arm/mach-imx/include/mach/devices-imx51.h
+++ b/arch/arm/mach-imx/include/mach/devices-imx51.h
@@ -5,17 +5,17 @@
static inline struct device_d *imx51_add_spi0(struct spi_imx_master *pdata)
{
- return imx_add_spi((void *)MX51_ECSPI1_BASE_ADDR, 0, pdata);
+ return imx_add_spi_imx51((void *)MX51_ECSPI1_BASE_ADDR, 0, pdata);
}
static inline struct device_d *imx51_add_spi1(struct spi_imx_master *pdata)
{
- return imx_add_spi((void *)MX51_ECSPI2_BASE_ADDR, 1, pdata);
+ return imx_add_spi_imx51((void *)MX51_ECSPI2_BASE_ADDR, 1, pdata);
}
static inline struct device_d *imx51_add_cspi(struct spi_imx_master *pdata)
{
- return imx_add_spi((void *)MX51_CSPI_BASE_ADDR, 2, pdata);
+ return imx_add_spi_imx35((void *)MX51_CSPI_BASE_ADDR, 2, pdata);
}
static inline struct device_d *imx51_add_i2c0(struct i2c_platform_data *pdata)
diff --git a/arch/arm/mach-imx/include/mach/devices-imx53.h b/arch/arm/mach-imx/include/mach/devices-imx53.h
index 4621c53..d4e9a4a 100644
--- a/arch/arm/mach-imx/include/mach/devices-imx53.h
+++ b/arch/arm/mach-imx/include/mach/devices-imx53.h
@@ -4,12 +4,12 @@
static inline struct device_d *imx53_add_spi0(struct spi_imx_master *pdata)
{
- return imx_add_spi((void *)MX53_ECSPI1_BASE_ADDR, 0, pdata);
+ return imx_add_spi_imx51((void *)MX53_ECSPI1_BASE_ADDR, 0, pdata);
}
static inline struct device_d *imx53_add_spi1(struct spi_imx_master *pdata)
{
- return imx_add_spi((void *)MX53_ECSPI2_BASE_ADDR, 1, pdata);
+ return imx_add_spi_imx51((void *)MX53_ECSPI2_BASE_ADDR, 1, pdata);
}
static inline struct device_d *imx53_add_i2c0(struct i2c_platform_data *pdata)
diff --git a/arch/arm/mach-imx/include/mach/devices-imx6.h b/arch/arm/mach-imx/include/mach/devices-imx6.h
index 7d41d7f..3a1bfb6 100644
--- a/arch/arm/mach-imx/include/mach/devices-imx6.h
+++ b/arch/arm/mach-imx/include/mach/devices-imx6.h
@@ -48,27 +48,27 @@ static inline struct device_d *imx6_add_fec(struct fec_platform_data *pdata)
static inline struct device_d *imx6_add_spi0(struct spi_imx_master *pdata)
{
- return imx_add_spi((void *)MX6_ECSPI1_BASE_ADDR, 0, pdata);
+ return imx_add_spi_imx51((void *)MX6_ECSPI1_BASE_ADDR, 0, pdata);
}
static inline struct device_d *imx6_add_spi1(struct spi_imx_master *pdata)
{
- return imx_add_spi((void *)MX6_ECSPI2_BASE_ADDR, 1, pdata);
+ return imx_add_spi_imx51((void *)MX6_ECSPI2_BASE_ADDR, 1, pdata);
}
static inline struct device_d *imx6_add_spi2(struct spi_imx_master *pdata)
{
- return imx_add_spi((void *)MX6_ECSPI3_BASE_ADDR, 2, pdata);
+ return imx_add_spi_imx51((void *)MX6_ECSPI3_BASE_ADDR, 2, pdata);
}
static inline struct device_d *imx6_add_spi3(struct spi_imx_master *pdata)
{
- return imx_add_spi((void *)MX6_ECSPI4_BASE_ADDR, 3, pdata);
+ return imx_add_spi_imx51((void *)MX6_ECSPI4_BASE_ADDR, 3, pdata);
}
static inline struct device_d *imx6_add_spi4(struct spi_imx_master *pdata)
{
- return imx_add_spi((void *)MX6_ECSPI5_BASE_ADDR, 4, pdata);
+ return imx_add_spi_imx51((void *)MX6_ECSPI5_BASE_ADDR, 4, pdata);
}
static inline struct device_d *imx6_add_i2c0(struct i2c_platform_data *pdata)
diff --git a/arch/arm/mach-imx/include/mach/devices.h b/arch/arm/mach-imx/include/mach/devices.h
index 5929658..4c07f46 100644
--- a/arch/arm/mach-imx/include/mach/devices.h
+++ b/arch/arm/mach-imx/include/mach/devices.h
@@ -11,7 +11,9 @@
struct device_d *imx_add_fec_imx27(void *base, struct fec_platform_data *pdata);
struct device_d *imx_add_fec_imx6(void *base, struct fec_platform_data *pdata);
-struct device_d *imx_add_spi(void *base, int id, struct spi_imx_master *pdata);
+struct device_d *imx_add_spi_imx27(void *base, int id, struct spi_imx_master *pdata);
+struct device_d *imx_add_spi_imx35(void *base, int id, struct spi_imx_master *pdata);
+struct device_d *imx_add_spi_imx51(void *base, int id, struct spi_imx_master *pdata);
struct device_d *imx_add_i2c(void *base, int id, struct i2c_platform_data *pdata);
struct device_d *imx_add_uart_imx1(void *base, int id);
struct device_d *imx_add_uart_imx21(void *base, int id);
diff --git a/drivers/spi/imx_spi.c b/drivers/spi/imx_spi.c
index a1b91a9..6675729 100644
--- a/drivers/spi/imx_spi.c
+++ b/drivers/spi/imx_spi.c
@@ -446,19 +446,19 @@ static int imx_spi_transfer(struct spi_device *spi, struct spi_message *mesg)
return 0;
}
-static struct spi_imx_devtype_data spi_imx_devtype_data_0_0 = {
+static __maybe_unused struct spi_imx_devtype_data spi_imx_devtype_data_0_0 = {
.chipselect = cspi_0_0_chipselect,
.xchg_single = cspi_0_0_xchg_single,
.init = cspi_0_0_init,
};
-static struct spi_imx_devtype_data spi_imx_devtype_data_0_7 = {
+static __maybe_unused struct spi_imx_devtype_data spi_imx_devtype_data_0_7 = {
.chipselect = cspi_0_7_chipselect,
.xchg_single = cspi_0_7_xchg_single,
.init = cspi_0_7_init,
};
-static struct spi_imx_devtype_data spi_imx_devtype_data_2_3 = {
+static __maybe_unused struct spi_imx_devtype_data spi_imx_devtype_data_2_3 = {
.chipselect = cspi_2_3_chipselect,
.xchg_single = cspi_2_3_xchg_single,
.init = cspi_2_3_init,
@@ -493,9 +493,13 @@ static int imx_spi_probe(struct device_d *dev)
struct spi_master *master;
struct imx_spi *imx;
struct spi_imx_master *pdata = dev->platform_data;
- struct spi_imx_devtype_data *devdata;
+ struct spi_imx_devtype_data *devdata = NULL;
int ret;
+ ret = dev_get_drvdata(dev, (unsigned long *)&devdata);
+ if (ret)
+ return -ENODEV;
+
imx = xzalloc(sizeof(*imx));
master = &imx->master;
@@ -519,17 +523,6 @@ static int imx_spi_probe(struct device_d *dev)
goto err_free;
}
- if (IS_ENABLED(CONFIG_DRIVER_SPI_IMX_0_0) && cpu_is_mx27())
- devdata = &spi_imx_devtype_data_0_0;
-
- if (IS_ENABLED(CONFIG_DRIVER_SPI_IMX_0_0) &&
- (cpu_is_mx25() || cpu_is_mx35()))
- devdata = &spi_imx_devtype_data_0_7;
-
- if (IS_ENABLED(CONFIG_DRIVER_SPI_IMX_2_3) &&
- (cpu_is_mx51() || cpu_is_mx53() || cpu_is_mx6()))
- devdata = &spi_imx_devtype_data_2_3;
-
imx->chipselect = devdata->chipselect;
imx->xchg_single = devdata->xchg_single;
imx->init = devdata->init;
@@ -548,13 +541,49 @@ err_free:
}
static __maybe_unused struct of_device_id imx_spi_dt_ids[] = {
+#if IS_ENABLED(CONFIG_DRIVER_SPI_IMX_0_0)
{
.compatible = "fsl,imx27-cspi",
- }, {
+ .data = (unsigned long)&spi_imx_devtype_data_0_0,
+ },
+#endif
+#if IS_ENABLED(CONFIG_DRIVER_SPI_IMX_0_7)
+ {
.compatible = "fsl,imx35-cspi",
- }, {
+ .data = (unsigned long)&spi_imx_devtype_data_0_7,
+ },
+#endif
+#if IS_ENABLED(CONFIG_DRIVER_SPI_IMX_2_3)
+ {
.compatible = "fsl,imx51-ecspi",
- }, {
+ .data = (unsigned long)&spi_imx_devtype_data_2_3,
+ },
+#endif
+ {
+ /* sentinel */
+ }
+};
+
+static struct platform_device_id imx_spi_ids[] = {
+#if IS_ENABLED(CONFIG_DRIVER_SPI_IMX_0_0)
+ {
+ .name = "imx27-spi",
+ .driver_data = (unsigned long)&spi_imx_devtype_data_0_0,
+ },
+#endif
+#if IS_ENABLED(CONFIG_DRIVER_SPI_IMX_0_7)
+ {
+ .name = "imx35-spi",
+ .driver_data = (unsigned long)&spi_imx_devtype_data_0_7,
+ },
+#endif
+#if IS_ENABLED(CONFIG_DRIVER_SPI_IMX_2_3)
+ {
+ .name = "imx51-spi",
+ .driver_data = (unsigned long)&spi_imx_devtype_data_2_3,
+ },
+#endif
+ {
/* sentinel */
}
};
@@ -563,5 +592,6 @@ static struct driver_d imx_spi_driver = {
.name = "imx_spi",
.probe = imx_spi_probe,
.of_compatible = DRV_OF_COMPAT(imx_spi_dt_ids),
+ .id_table = imx_spi_ids,
};
device_platform_driver(imx_spi_driver);
--
1.8.5.3
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2014-02-10 7:42 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-02-10 7:41 [PATCH 1/3] spi: imx: drop use of enum Sascha Hauer
2014-02-10 7:41 ` [PATCH 2/3] spi: imx: Use IS_ENABLED to drop ifdefs Sascha Hauer
2014-02-10 7:41 ` [PATCH 3/3] spi: imx: Use device ids Sascha Hauer
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox