spi: imx: Use device ids
To let the driver work on all SoCs without the use of cpu_is_*() Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
This commit is contained in:
parent
c68acd82f6
commit
0ad1e8d8df
|
@ -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)
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue