9
0
Fork 0

Merge branch 'for-next/spi'

This commit is contained in:
Sascha Hauer 2014-03-07 09:25:56 +01:00
commit 3d551bce2b
10 changed files with 99 additions and 91 deletions

View File

@ -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)

View File

@ -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)

View File

@ -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)

View File

@ -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)

View File

@ -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)

View File

@ -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)

View File

@ -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)

View File

@ -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)

View File

@ -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);

View File

@ -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;
@ -157,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;
@ -227,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;
@ -310,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;
@ -414,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)
{
@ -473,28 +446,22 @@ 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,
},
#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,
},
#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 __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 __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 __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,
};
static int imx_spi_dt_probe(struct imx_spi *imx)
@ -526,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;
enum imx_spi_devtype version;
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;
@ -552,21 +523,9 @@ static int imx_spi_probe(struct device_d *dev)
goto err_free;
}
#ifdef CONFIG_DRIVER_SPI_IMX_0_0
if (cpu_is_mx27())
version = SPI_IMX_VER_0_0;
#endif
#ifdef CONFIG_DRIVER_SPI_IMX_0_7
if (cpu_is_mx25() || cpu_is_mx35())
version = SPI_IMX_VER_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;
#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);
@ -582,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 */
}
};
@ -597,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);