aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/spi
diff options
context:
space:
mode:
authorShawn Guo <shawn.guo@linaro.org>2011-07-09 13:16:38 -0400
committerGrant Likely <grant.likely@secretlab.ca>2011-07-14 15:46:47 -0400
commit2a64a90a2c64420e880b25dfeec6524ea78926fb (patch)
tree23505af1c30345d87e37301592af6cd8644f707b /drivers/spi
parent66de757c589bedc13f503fb23df67bc86803f371 (diff)
spi/imx: merge type SPI_IMX_VER_0_7 into SPI_IMX_VER_0_4
The only difference between SPI_IMX_VER_0_7 and SPI_IMX_VER_0_4 is .config function. The patch uses cpu_is_mx35 (to be removed) as the temporary solution to consolidate functions spi_imx0_4_config and spi_imx0_7_config into mx31_config. As a result, type SPI_IMX_VER_0_7 can be merged into SPI_IMX_VER_0_4. It also renames function spi_imx0_4_reset to mx31_reset to keep consistency with other function naming. A couple of redundant macros, MX3_CSPISTAT and MX3_CSPISTAT_RR, together with the useless type SPI_IMX_VER_0_5 also get cleaned up. Signed-off-by: Shawn Guo <shawn.guo@linaro.org> Cc: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Cc: Sascha Hauer <s.hauer@pengutronix.de> Cc: Grant Likely <grant.likely@secretlab.ca> Signed-off-by: Grant Likely <grant.likely@secretlab.ca>
Diffstat (limited to 'drivers/spi')
-rw-r--r--drivers/spi/Kconfig5
-rw-r--r--drivers/spi/spi-imx.c70
2 files changed, 19 insertions, 56 deletions
diff --git a/drivers/spi/Kconfig b/drivers/spi/Kconfig
index 9aafa98f3b49..c327cf3d8174 100644
--- a/drivers/spi/Kconfig
+++ b/drivers/spi/Kconfig
@@ -161,10 +161,7 @@ config SPI_IMX_VER_0_0
161 def_bool y if SOC_IMX21 || SOC_IMX27 161 def_bool y if SOC_IMX21 || SOC_IMX27
162 162
163config SPI_IMX_VER_0_4 163config SPI_IMX_VER_0_4
164 def_bool y if SOC_IMX31 164 def_bool y if ARCH_MX25 || SOC_IMX31 || SOC_IMX35 || SOC_IMX51 || SOC_IMX53
165
166config SPI_IMX_VER_0_7
167 def_bool y if ARCH_MX25 || SOC_IMX35 || SOC_IMX51 || SOC_IMX53
168 165
169config SPI_IMX_VER_2_3 166config SPI_IMX_VER_2_3
170 def_bool y if SOC_IMX51 || SOC_IMX53 167 def_bool y if SOC_IMX51 || SOC_IMX53
diff --git a/drivers/spi/spi-imx.c b/drivers/spi/spi-imx.c
index 0fbd378bd1db..615a84c8ccda 100644
--- a/drivers/spi/spi-imx.c
+++ b/drivers/spi/spi-imx.c
@@ -45,9 +45,6 @@
45#define MXC_CSPIINT 0x0c 45#define MXC_CSPIINT 0x0c
46#define MXC_RESET 0x1c 46#define MXC_RESET 0x1c
47 47
48#define MX3_CSPISTAT 0x14
49#define MX3_CSPISTAT_RR (1 << 3)
50
51/* generic defines to abstract from the different register layouts */ 48/* generic defines to abstract from the different register layouts */
52#define MXC_INT_RR (1 << 0) /* Receive data ready interrupt */ 49#define MXC_INT_RR (1 << 0) /* Receive data ready interrupt */
53#define MXC_INT_TE (1 << 1) /* Transmit FIFO empty interrupt */ 50#define MXC_INT_TE (1 << 1) /* Transmit FIFO empty interrupt */
@@ -63,8 +60,6 @@ enum spi_imx_devtype {
63 SPI_IMX_VER_IMX1, 60 SPI_IMX_VER_IMX1,
64 SPI_IMX_VER_0_0, 61 SPI_IMX_VER_0_0,
65 SPI_IMX_VER_0_4, 62 SPI_IMX_VER_0_4,
66 SPI_IMX_VER_0_5,
67 SPI_IMX_VER_0_7,
68 SPI_IMX_VER_2_3, 63 SPI_IMX_VER_2_3,
69}; 64};
70 65
@@ -343,32 +338,7 @@ static void __maybe_unused mx31_trigger(struct spi_imx_data *spi_imx)
343 writel(reg, spi_imx->base + MXC_CSPICTRL); 338 writel(reg, spi_imx->base + MXC_CSPICTRL);
344} 339}
345 340
346static int __maybe_unused spi_imx0_4_config(struct spi_imx_data *spi_imx, 341static int __maybe_unused mx31_config(struct spi_imx_data *spi_imx,
347 struct spi_imx_config *config)
348{
349 unsigned int reg = MX31_CSPICTRL_ENABLE | MX31_CSPICTRL_MASTER;
350 int cs = spi_imx->chipselect[config->cs];
351
352 reg |= spi_imx_clkdiv_2(spi_imx->spi_clk, config->speed_hz) <<
353 MX31_CSPICTRL_DR_SHIFT;
354
355 reg |= (config->bpw - 1) << MX31_CSPICTRL_BC_SHIFT;
356
357 if (config->mode & SPI_CPHA)
358 reg |= MX31_CSPICTRL_PHA;
359 if (config->mode & SPI_CPOL)
360 reg |= MX31_CSPICTRL_POL;
361 if (config->mode & SPI_CS_HIGH)
362 reg |= MX31_CSPICTRL_SSPOL;
363 if (cs < 0)
364 reg |= (cs + 32) << MX31_CSPICTRL_CS_SHIFT;
365
366 writel(reg, spi_imx->base + MXC_CSPICTRL);
367
368 return 0;
369}
370
371static int __maybe_unused spi_imx0_7_config(struct spi_imx_data *spi_imx,
372 struct spi_imx_config *config) 342 struct spi_imx_config *config)
373{ 343{
374 unsigned int reg = MX31_CSPICTRL_ENABLE | MX31_CSPICTRL_MASTER; 344 unsigned int reg = MX31_CSPICTRL_ENABLE | MX31_CSPICTRL_MASTER;
@@ -377,8 +347,12 @@ static int __maybe_unused spi_imx0_7_config(struct spi_imx_data *spi_imx,
377 reg |= spi_imx_clkdiv_2(spi_imx->spi_clk, config->speed_hz) << 347 reg |= spi_imx_clkdiv_2(spi_imx->spi_clk, config->speed_hz) <<
378 MX31_CSPICTRL_DR_SHIFT; 348 MX31_CSPICTRL_DR_SHIFT;
379 349
380 reg |= (config->bpw - 1) << MX35_CSPICTRL_BL_SHIFT; 350 if (cpu_is_mx35()) {
381 reg |= MX31_CSPICTRL_SSCTL; 351 reg |= (config->bpw - 1) << MX35_CSPICTRL_BL_SHIFT;
352 reg |= MX31_CSPICTRL_SSCTL;
353 } else {
354 reg |= (config->bpw - 1) << MX31_CSPICTRL_BC_SHIFT;
355 }
382 356
383 if (config->mode & SPI_CPHA) 357 if (config->mode & SPI_CPHA)
384 reg |= MX31_CSPICTRL_PHA; 358 reg |= MX31_CSPICTRL_PHA;
@@ -387,7 +361,9 @@ static int __maybe_unused spi_imx0_7_config(struct spi_imx_data *spi_imx,
387 if (config->mode & SPI_CS_HIGH) 361 if (config->mode & SPI_CS_HIGH)
388 reg |= MX31_CSPICTRL_SSPOL; 362 reg |= MX31_CSPICTRL_SSPOL;
389 if (cs < 0) 363 if (cs < 0)
390 reg |= (cs + 32) << MX35_CSPICTRL_CS_SHIFT; 364 reg |= (cs + 32) <<
365 (cpu_is_mx35() ? MX35_CSPICTRL_CS_SHIFT :
366 MX31_CSPICTRL_CS_SHIFT);
391 367
392 writel(reg, spi_imx->base + MXC_CSPICTRL); 368 writel(reg, spi_imx->base + MXC_CSPICTRL);
393 369
@@ -399,10 +375,10 @@ static int __maybe_unused mx31_rx_available(struct spi_imx_data *spi_imx)
399 return readl(spi_imx->base + MX31_CSPISTATUS) & MX31_STATUS_RR; 375 return readl(spi_imx->base + MX31_CSPISTATUS) & MX31_STATUS_RR;
400} 376}
401 377
402static void __maybe_unused spi_imx0_4_reset(struct spi_imx_data *spi_imx) 378static void __maybe_unused mx31_reset(struct spi_imx_data *spi_imx)
403{ 379{
404 /* drain receive buffer */ 380 /* drain receive buffer */
405 while (readl(spi_imx->base + MX3_CSPISTAT) & MX3_CSPISTAT_RR) 381 while (readl(spi_imx->base + MX31_CSPISTATUS) & MX31_STATUS_RR)
406 readl(spi_imx->base + MXC_CSPIRXDATA); 382 readl(spi_imx->base + MXC_CSPIRXDATA);
407} 383}
408 384
@@ -563,20 +539,10 @@ static struct spi_imx_devtype_data spi_imx_devtype_data[] = {
563#ifdef CONFIG_SPI_IMX_VER_0_4 539#ifdef CONFIG_SPI_IMX_VER_0_4
564 [SPI_IMX_VER_0_4] = { 540 [SPI_IMX_VER_0_4] = {
565 .intctrl = mx31_intctrl, 541 .intctrl = mx31_intctrl,
566 .config = spi_imx0_4_config, 542 .config = mx31_config,
567 .trigger = mx31_trigger, 543 .trigger = mx31_trigger,
568 .rx_available = mx31_rx_available, 544 .rx_available = mx31_rx_available,
569 .reset = spi_imx0_4_reset, 545 .reset = mx31_reset,
570 .fifosize = 8,
571 },
572#endif
573#ifdef CONFIG_SPI_IMX_VER_0_7
574 [SPI_IMX_VER_0_7] = {
575 .intctrl = mx31_intctrl,
576 .config = spi_imx0_7_config,
577 .trigger = mx31_trigger,
578 .rx_available = mx31_rx_available,
579 .reset = spi_imx0_4_reset,
580 .fifosize = 8, 546 .fifosize = 8,
581 }, 547 },
582#endif 548#endif
@@ -732,7 +698,7 @@ static struct platform_device_id spi_imx_devtype[] = {
732 .driver_data = SPI_IMX_VER_0_0, 698 .driver_data = SPI_IMX_VER_0_0,
733 }, { 699 }, {
734 .name = "imx25-cspi", 700 .name = "imx25-cspi",
735 .driver_data = SPI_IMX_VER_0_7, 701 .driver_data = SPI_IMX_VER_0_4,
736 }, { 702 }, {
737 .name = "imx27-cspi", 703 .name = "imx27-cspi",
738 .driver_data = SPI_IMX_VER_0_0, 704 .driver_data = SPI_IMX_VER_0_0,
@@ -741,16 +707,16 @@ static struct platform_device_id spi_imx_devtype[] = {
741 .driver_data = SPI_IMX_VER_0_4, 707 .driver_data = SPI_IMX_VER_0_4,
742 }, { 708 }, {
743 .name = "imx35-cspi", 709 .name = "imx35-cspi",
744 .driver_data = SPI_IMX_VER_0_7, 710 .driver_data = SPI_IMX_VER_0_4,
745 }, { 711 }, {
746 .name = "imx51-cspi", 712 .name = "imx51-cspi",
747 .driver_data = SPI_IMX_VER_0_7, 713 .driver_data = SPI_IMX_VER_0_4,
748 }, { 714 }, {
749 .name = "imx51-ecspi", 715 .name = "imx51-ecspi",
750 .driver_data = SPI_IMX_VER_2_3, 716 .driver_data = SPI_IMX_VER_2_3,
751 }, { 717 }, {
752 .name = "imx53-cspi", 718 .name = "imx53-cspi",
753 .driver_data = SPI_IMX_VER_0_7, 719 .driver_data = SPI_IMX_VER_0_4,
754 }, { 720 }, {
755 .name = "imx53-ecspi", 721 .name = "imx53-ecspi",
756 .driver_data = SPI_IMX_VER_2_3, 722 .driver_data = SPI_IMX_VER_2_3,