aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/spi/pxa2xx_spi.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/spi/pxa2xx_spi.c')
-rw-r--r--drivers/spi/pxa2xx_spi.c190
1 files changed, 134 insertions, 56 deletions
diff --git a/drivers/spi/pxa2xx_spi.c b/drivers/spi/pxa2xx_spi.c
index e76b1afafe07..95928833855b 100644
--- a/drivers/spi/pxa2xx_spi.c
+++ b/drivers/spi/pxa2xx_spi.c
@@ -23,11 +23,11 @@
23#include <linux/errno.h> 23#include <linux/errno.h>
24#include <linux/interrupt.h> 24#include <linux/interrupt.h>
25#include <linux/platform_device.h> 25#include <linux/platform_device.h>
26#include <linux/spi/pxa2xx_spi.h>
26#include <linux/dma-mapping.h> 27#include <linux/dma-mapping.h>
27#include <linux/spi/spi.h> 28#include <linux/spi/spi.h>
28#include <linux/workqueue.h> 29#include <linux/workqueue.h>
29#include <linux/delay.h> 30#include <linux/delay.h>
30#include <linux/clk.h>
31#include <linux/gpio.h> 31#include <linux/gpio.h>
32#include <linux/slab.h> 32#include <linux/slab.h>
33 33
@@ -35,9 +35,6 @@
35#include <asm/irq.h> 35#include <asm/irq.h>
36#include <asm/delay.h> 36#include <asm/delay.h>
37 37
38#include <mach/dma.h>
39#include <plat/ssp.h>
40#include <mach/pxa2xx_spi.h>
41 38
42MODULE_AUTHOR("Stephen Street"); 39MODULE_AUTHOR("Stephen Street");
43MODULE_DESCRIPTION("PXA2xx SSP SPI Controller"); 40MODULE_DESCRIPTION("PXA2xx SSP SPI Controller");
@@ -46,8 +43,6 @@ MODULE_ALIAS("platform:pxa2xx-spi");
46 43
47#define MAX_BUSES 3 44#define MAX_BUSES 3
48 45
49#define RX_THRESH_DFLT 8
50#define TX_THRESH_DFLT 8
51#define TIMOUT_DFLT 1000 46#define TIMOUT_DFLT 1000
52 47
53#define DMA_INT_MASK (DCSR_ENDINTR | DCSR_STARTINTR | DCSR_BUSERR) 48#define DMA_INT_MASK (DCSR_ENDINTR | DCSR_STARTINTR | DCSR_BUSERR)
@@ -168,7 +163,10 @@ struct chip_data {
168 u8 enable_dma; 163 u8 enable_dma;
169 u8 bits_per_word; 164 u8 bits_per_word;
170 u32 speed_hz; 165 u32 speed_hz;
171 int gpio_cs; 166 union {
167 int gpio_cs;
168 unsigned int frm;
169 };
172 int gpio_cs_inverted; 170 int gpio_cs_inverted;
173 int (*write)(struct driver_data *drv_data); 171 int (*write)(struct driver_data *drv_data);
174 int (*read)(struct driver_data *drv_data); 172 int (*read)(struct driver_data *drv_data);
@@ -181,6 +179,11 @@ static void cs_assert(struct driver_data *drv_data)
181{ 179{
182 struct chip_data *chip = drv_data->cur_chip; 180 struct chip_data *chip = drv_data->cur_chip;
183 181
182 if (drv_data->ssp_type == CE4100_SSP) {
183 write_SSSR(drv_data->cur_chip->frm, drv_data->ioaddr);
184 return;
185 }
186
184 if (chip->cs_control) { 187 if (chip->cs_control) {
185 chip->cs_control(PXA2XX_CS_ASSERT); 188 chip->cs_control(PXA2XX_CS_ASSERT);
186 return; 189 return;
@@ -194,6 +197,9 @@ static void cs_deassert(struct driver_data *drv_data)
194{ 197{
195 struct chip_data *chip = drv_data->cur_chip; 198 struct chip_data *chip = drv_data->cur_chip;
196 199
200 if (drv_data->ssp_type == CE4100_SSP)
201 return;
202
197 if (chip->cs_control) { 203 if (chip->cs_control) {
198 chip->cs_control(PXA2XX_CS_DEASSERT); 204 chip->cs_control(PXA2XX_CS_DEASSERT);
199 return; 205 return;
@@ -203,6 +209,25 @@ static void cs_deassert(struct driver_data *drv_data)
203 gpio_set_value(chip->gpio_cs, !chip->gpio_cs_inverted); 209 gpio_set_value(chip->gpio_cs, !chip->gpio_cs_inverted);
204} 210}
205 211
212static void write_SSSR_CS(struct driver_data *drv_data, u32 val)
213{
214 void __iomem *reg = drv_data->ioaddr;
215
216 if (drv_data->ssp_type == CE4100_SSP)
217 val |= read_SSSR(reg) & SSSR_ALT_FRM_MASK;
218
219 write_SSSR(val, reg);
220}
221
222static int pxa25x_ssp_comp(struct driver_data *drv_data)
223{
224 if (drv_data->ssp_type == PXA25x_SSP)
225 return 1;
226 if (drv_data->ssp_type == CE4100_SSP)
227 return 1;
228 return 0;
229}
230
206static int flush(struct driver_data *drv_data) 231static int flush(struct driver_data *drv_data)
207{ 232{
208 unsigned long limit = loops_per_jiffy << 1; 233 unsigned long limit = loops_per_jiffy << 1;
@@ -214,7 +239,7 @@ static int flush(struct driver_data *drv_data)
214 read_SSDR(reg); 239 read_SSDR(reg);
215 } 240 }
216 } while ((read_SSSR(reg) & SSSR_BSY) && --limit); 241 } while ((read_SSSR(reg) & SSSR_BSY) && --limit);
217 write_SSSR(SSSR_ROR, reg); 242 write_SSSR_CS(drv_data, SSSR_ROR);
218 243
219 return limit; 244 return limit;
220} 245}
@@ -224,7 +249,7 @@ static int null_writer(struct driver_data *drv_data)
224 void __iomem *reg = drv_data->ioaddr; 249 void __iomem *reg = drv_data->ioaddr;
225 u8 n_bytes = drv_data->n_bytes; 250 u8 n_bytes = drv_data->n_bytes;
226 251
227 if (((read_SSSR(reg) & 0x00000f00) == 0x00000f00) 252 if (((read_SSSR(reg) & SSSR_TFL_MASK) == SSSR_TFL_MASK)
228 || (drv_data->tx == drv_data->tx_end)) 253 || (drv_data->tx == drv_data->tx_end))
229 return 0; 254 return 0;
230 255
@@ -252,7 +277,7 @@ static int u8_writer(struct driver_data *drv_data)
252{ 277{
253 void __iomem *reg = drv_data->ioaddr; 278 void __iomem *reg = drv_data->ioaddr;
254 279
255 if (((read_SSSR(reg) & 0x00000f00) == 0x00000f00) 280 if (((read_SSSR(reg) & SSSR_TFL_MASK) == SSSR_TFL_MASK)
256 || (drv_data->tx == drv_data->tx_end)) 281 || (drv_data->tx == drv_data->tx_end))
257 return 0; 282 return 0;
258 283
@@ -279,7 +304,7 @@ static int u16_writer(struct driver_data *drv_data)
279{ 304{
280 void __iomem *reg = drv_data->ioaddr; 305 void __iomem *reg = drv_data->ioaddr;
281 306
282 if (((read_SSSR(reg) & 0x00000f00) == 0x00000f00) 307 if (((read_SSSR(reg) & SSSR_TFL_MASK) == SSSR_TFL_MASK)
283 || (drv_data->tx == drv_data->tx_end)) 308 || (drv_data->tx == drv_data->tx_end))
284 return 0; 309 return 0;
285 310
@@ -306,7 +331,7 @@ static int u32_writer(struct driver_data *drv_data)
306{ 331{
307 void __iomem *reg = drv_data->ioaddr; 332 void __iomem *reg = drv_data->ioaddr;
308 333
309 if (((read_SSSR(reg) & 0x00000f00) == 0x00000f00) 334 if (((read_SSSR(reg) & SSSR_TFL_MASK) == SSSR_TFL_MASK)
310 || (drv_data->tx == drv_data->tx_end)) 335 || (drv_data->tx == drv_data->tx_end))
311 return 0; 336 return 0;
312 337
@@ -507,9 +532,9 @@ static void dma_error_stop(struct driver_data *drv_data, const char *msg)
507 /* Stop and reset */ 532 /* Stop and reset */
508 DCSR(drv_data->rx_channel) = RESET_DMA_CHANNEL; 533 DCSR(drv_data->rx_channel) = RESET_DMA_CHANNEL;
509 DCSR(drv_data->tx_channel) = RESET_DMA_CHANNEL; 534 DCSR(drv_data->tx_channel) = RESET_DMA_CHANNEL;
510 write_SSSR(drv_data->clear_sr, reg); 535 write_SSSR_CS(drv_data, drv_data->clear_sr);
511 write_SSCR1(read_SSCR1(reg) & ~drv_data->dma_cr1, reg); 536 write_SSCR1(read_SSCR1(reg) & ~drv_data->dma_cr1, reg);
512 if (drv_data->ssp_type != PXA25x_SSP) 537 if (!pxa25x_ssp_comp(drv_data))
513 write_SSTO(0, reg); 538 write_SSTO(0, reg);
514 flush(drv_data); 539 flush(drv_data);
515 write_SSCR0(read_SSCR0(reg) & ~SSCR0_SSE, reg); 540 write_SSCR0(read_SSCR0(reg) & ~SSCR0_SSE, reg);
@@ -529,7 +554,7 @@ static void dma_transfer_complete(struct driver_data *drv_data)
529 554
530 /* Clear and disable interrupts on SSP and DMA channels*/ 555 /* Clear and disable interrupts on SSP and DMA channels*/
531 write_SSCR1(read_SSCR1(reg) & ~drv_data->dma_cr1, reg); 556 write_SSCR1(read_SSCR1(reg) & ~drv_data->dma_cr1, reg);
532 write_SSSR(drv_data->clear_sr, reg); 557 write_SSSR_CS(drv_data, drv_data->clear_sr);
533 DCSR(drv_data->tx_channel) = RESET_DMA_CHANNEL; 558 DCSR(drv_data->tx_channel) = RESET_DMA_CHANNEL;
534 DCSR(drv_data->rx_channel) = RESET_DMA_CHANNEL; 559 DCSR(drv_data->rx_channel) = RESET_DMA_CHANNEL;
535 560
@@ -622,7 +647,7 @@ static irqreturn_t dma_transfer(struct driver_data *drv_data)
622 647
623 /* Clear and disable timeout interrupt, do the rest in 648 /* Clear and disable timeout interrupt, do the rest in
624 * dma_transfer_complete */ 649 * dma_transfer_complete */
625 if (drv_data->ssp_type != PXA25x_SSP) 650 if (!pxa25x_ssp_comp(drv_data))
626 write_SSTO(0, reg); 651 write_SSTO(0, reg);
627 652
628 /* finish this transfer, start the next */ 653 /* finish this transfer, start the next */
@@ -635,14 +660,26 @@ static irqreturn_t dma_transfer(struct driver_data *drv_data)
635 return IRQ_NONE; 660 return IRQ_NONE;
636} 661}
637 662
663static void reset_sccr1(struct driver_data *drv_data)
664{
665 void __iomem *reg = drv_data->ioaddr;
666 struct chip_data *chip = drv_data->cur_chip;
667 u32 sccr1_reg;
668
669 sccr1_reg = read_SSCR1(reg) & ~drv_data->int_cr1;
670 sccr1_reg &= ~SSCR1_RFT;
671 sccr1_reg |= chip->threshold;
672 write_SSCR1(sccr1_reg, reg);
673}
674
638static void int_error_stop(struct driver_data *drv_data, const char* msg) 675static void int_error_stop(struct driver_data *drv_data, const char* msg)
639{ 676{
640 void __iomem *reg = drv_data->ioaddr; 677 void __iomem *reg = drv_data->ioaddr;
641 678
642 /* Stop and reset SSP */ 679 /* Stop and reset SSP */
643 write_SSSR(drv_data->clear_sr, reg); 680 write_SSSR_CS(drv_data, drv_data->clear_sr);
644 write_SSCR1(read_SSCR1(reg) & ~drv_data->int_cr1, reg); 681 reset_sccr1(drv_data);
645 if (drv_data->ssp_type != PXA25x_SSP) 682 if (!pxa25x_ssp_comp(drv_data))
646 write_SSTO(0, reg); 683 write_SSTO(0, reg);
647 flush(drv_data); 684 flush(drv_data);
648 write_SSCR0(read_SSCR0(reg) & ~SSCR0_SSE, reg); 685 write_SSCR0(read_SSCR0(reg) & ~SSCR0_SSE, reg);
@@ -658,9 +695,9 @@ static void int_transfer_complete(struct driver_data *drv_data)
658 void __iomem *reg = drv_data->ioaddr; 695 void __iomem *reg = drv_data->ioaddr;
659 696
660 /* Stop SSP */ 697 /* Stop SSP */
661 write_SSSR(drv_data->clear_sr, reg); 698 write_SSSR_CS(drv_data, drv_data->clear_sr);
662 write_SSCR1(read_SSCR1(reg) & ~drv_data->int_cr1, reg); 699 reset_sccr1(drv_data);
663 if (drv_data->ssp_type != PXA25x_SSP) 700 if (!pxa25x_ssp_comp(drv_data))
664 write_SSTO(0, reg); 701 write_SSTO(0, reg);
665 702
666 /* Update total byte transfered return count actual bytes read */ 703 /* Update total byte transfered return count actual bytes read */
@@ -714,24 +751,34 @@ static irqreturn_t interrupt_transfer(struct driver_data *drv_data)
714 } 751 }
715 752
716 if (drv_data->tx == drv_data->tx_end) { 753 if (drv_data->tx == drv_data->tx_end) {
717 write_SSCR1(read_SSCR1(reg) & ~SSCR1_TIE, reg); 754 u32 bytes_left;
718 /* PXA25x_SSP has no timeout, read trailing bytes */ 755 u32 sccr1_reg;
719 if (drv_data->ssp_type == PXA25x_SSP) { 756
720 if (!wait_ssp_rx_stall(reg)) 757 sccr1_reg = read_SSCR1(reg);
721 { 758 sccr1_reg &= ~SSCR1_TIE;
722 int_error_stop(drv_data, "interrupt_transfer: " 759
723 "rx stall failed"); 760 /*
724 return IRQ_HANDLED; 761 * PXA25x_SSP has no timeout, set up rx threshould for the
725 } 762 * remaing RX bytes.
726 if (!drv_data->read(drv_data)) 763 */
727 { 764 if (pxa25x_ssp_comp(drv_data)) {
728 int_error_stop(drv_data, 765
729 "interrupt_transfer: " 766 sccr1_reg &= ~SSCR1_RFT;
730 "trailing byte read failed"); 767
731 return IRQ_HANDLED; 768 bytes_left = drv_data->rx_end - drv_data->rx;
769 switch (drv_data->n_bytes) {
770 case 4:
771 bytes_left >>= 1;
772 case 2:
773 bytes_left >>= 1;
732 } 774 }
733 int_transfer_complete(drv_data); 775
776 if (bytes_left > RX_THRESH_DFLT)
777 bytes_left = RX_THRESH_DFLT;
778
779 sccr1_reg |= SSCR1_RxTresh(bytes_left);
734 } 780 }
781 write_SSCR1(sccr1_reg, reg);
735 } 782 }
736 783
737 /* We did something */ 784 /* We did something */
@@ -742,14 +789,26 @@ static irqreturn_t ssp_int(int irq, void *dev_id)
742{ 789{
743 struct driver_data *drv_data = dev_id; 790 struct driver_data *drv_data = dev_id;
744 void __iomem *reg = drv_data->ioaddr; 791 void __iomem *reg = drv_data->ioaddr;
792 u32 sccr1_reg = read_SSCR1(reg);
793 u32 mask = drv_data->mask_sr;
794 u32 status;
795
796 status = read_SSSR(reg);
797
798 /* Ignore possible writes if we don't need to write */
799 if (!(sccr1_reg & SSCR1_TIE))
800 mask &= ~SSSR_TFS;
801
802 if (!(status & mask))
803 return IRQ_NONE;
745 804
746 if (!drv_data->cur_msg) { 805 if (!drv_data->cur_msg) {
747 806
748 write_SSCR0(read_SSCR0(reg) & ~SSCR0_SSE, reg); 807 write_SSCR0(read_SSCR0(reg) & ~SSCR0_SSE, reg);
749 write_SSCR1(read_SSCR1(reg) & ~drv_data->int_cr1, reg); 808 write_SSCR1(read_SSCR1(reg) & ~drv_data->int_cr1, reg);
750 if (drv_data->ssp_type != PXA25x_SSP) 809 if (!pxa25x_ssp_comp(drv_data))
751 write_SSTO(0, reg); 810 write_SSTO(0, reg);
752 write_SSSR(drv_data->clear_sr, reg); 811 write_SSSR_CS(drv_data, drv_data->clear_sr);
753 812
754 dev_err(&drv_data->pdev->dev, "bad message state " 813 dev_err(&drv_data->pdev->dev, "bad message state "
755 "in interrupt handler\n"); 814 "in interrupt handler\n");
@@ -862,7 +921,7 @@ static unsigned int ssp_get_clk_div(struct ssp_device *ssp, int rate)
862{ 921{
863 unsigned long ssp_clk = clk_get_rate(ssp->clk); 922 unsigned long ssp_clk = clk_get_rate(ssp->clk);
864 923
865 if (ssp->type == PXA25x_SSP) 924 if (ssp->type == PXA25x_SSP || ssp->type == CE4100_SSP)
866 return ((ssp_clk / (2 * rate) - 1) & 0xff) << 8; 925 return ((ssp_clk / (2 * rate) - 1) & 0xff) << 8;
867 else 926 else
868 return ((ssp_clk / rate - 1) & 0xfff) << 8; 927 return ((ssp_clk / rate - 1) & 0xfff) << 8;
@@ -1088,7 +1147,7 @@ static void pump_transfers(unsigned long data)
1088 1147
1089 /* Clear status */ 1148 /* Clear status */
1090 cr1 = chip->cr1 | chip->threshold | drv_data->int_cr1; 1149 cr1 = chip->cr1 | chip->threshold | drv_data->int_cr1;
1091 write_SSSR(drv_data->clear_sr, reg); 1150 write_SSSR_CS(drv_data, drv_data->clear_sr);
1092 } 1151 }
1093 1152
1094 /* see if we need to reload the config registers */ 1153 /* see if we need to reload the config registers */
@@ -1098,7 +1157,7 @@ static void pump_transfers(unsigned long data)
1098 1157
1099 /* stop the SSP, and update the other bits */ 1158 /* stop the SSP, and update the other bits */
1100 write_SSCR0(cr0 & ~SSCR0_SSE, reg); 1159 write_SSCR0(cr0 & ~SSCR0_SSE, reg);
1101 if (drv_data->ssp_type != PXA25x_SSP) 1160 if (!pxa25x_ssp_comp(drv_data))
1102 write_SSTO(chip->timeout, reg); 1161 write_SSTO(chip->timeout, reg);
1103 /* first set CR1 without interrupt and service enables */ 1162 /* first set CR1 without interrupt and service enables */
1104 write_SSCR1(cr1 & SSCR1_CHANGE_MASK, reg); 1163 write_SSCR1(cr1 & SSCR1_CHANGE_MASK, reg);
@@ -1106,7 +1165,7 @@ static void pump_transfers(unsigned long data)
1106 write_SSCR0(cr0, reg); 1165 write_SSCR0(cr0, reg);
1107 1166
1108 } else { 1167 } else {
1109 if (drv_data->ssp_type != PXA25x_SSP) 1168 if (!pxa25x_ssp_comp(drv_data))
1110 write_SSTO(chip->timeout, reg); 1169 write_SSTO(chip->timeout, reg);
1111 } 1170 }
1112 1171
@@ -1233,14 +1292,13 @@ static int setup(struct spi_device *spi)
1233 uint tx_thres = TX_THRESH_DFLT; 1292 uint tx_thres = TX_THRESH_DFLT;
1234 uint rx_thres = RX_THRESH_DFLT; 1293 uint rx_thres = RX_THRESH_DFLT;
1235 1294
1236 if (drv_data->ssp_type != PXA25x_SSP 1295 if (!pxa25x_ssp_comp(drv_data)
1237 && (spi->bits_per_word < 4 || spi->bits_per_word > 32)) { 1296 && (spi->bits_per_word < 4 || spi->bits_per_word > 32)) {
1238 dev_err(&spi->dev, "failed setup: ssp_type=%d, bits/wrd=%d " 1297 dev_err(&spi->dev, "failed setup: ssp_type=%d, bits/wrd=%d "
1239 "b/w not 4-32 for type non-PXA25x_SSP\n", 1298 "b/w not 4-32 for type non-PXA25x_SSP\n",
1240 drv_data->ssp_type, spi->bits_per_word); 1299 drv_data->ssp_type, spi->bits_per_word);
1241 return -EINVAL; 1300 return -EINVAL;
1242 } 1301 } else if (pxa25x_ssp_comp(drv_data)
1243 else if (drv_data->ssp_type == PXA25x_SSP
1244 && (spi->bits_per_word < 4 1302 && (spi->bits_per_word < 4
1245 || spi->bits_per_word > 16)) { 1303 || spi->bits_per_word > 16)) {
1246 dev_err(&spi->dev, "failed setup: ssp_type=%d, bits/wrd=%d " 1304 dev_err(&spi->dev, "failed setup: ssp_type=%d, bits/wrd=%d "
@@ -1259,7 +1317,17 @@ static int setup(struct spi_device *spi)
1259 return -ENOMEM; 1317 return -ENOMEM;
1260 } 1318 }
1261 1319
1262 chip->gpio_cs = -1; 1320 if (drv_data->ssp_type == CE4100_SSP) {
1321 if (spi->chip_select > 4) {
1322 dev_err(&spi->dev, "failed setup: "
1323 "cs number must not be > 4.\n");
1324 kfree(chip);
1325 return -EINVAL;
1326 }
1327
1328 chip->frm = spi->chip_select;
1329 } else
1330 chip->gpio_cs = -1;
1263 chip->enable_dma = 0; 1331 chip->enable_dma = 0;
1264 chip->timeout = TIMOUT_DFLT; 1332 chip->timeout = TIMOUT_DFLT;
1265 chip->dma_burst_size = drv_data->master_info->enable_dma ? 1333 chip->dma_burst_size = drv_data->master_info->enable_dma ?
@@ -1315,7 +1383,7 @@ static int setup(struct spi_device *spi)
1315 | (((spi->mode & SPI_CPOL) != 0) ? SSCR1_SPO : 0); 1383 | (((spi->mode & SPI_CPOL) != 0) ? SSCR1_SPO : 0);
1316 1384
1317 /* NOTE: PXA25x_SSP _could_ use external clocking ... */ 1385 /* NOTE: PXA25x_SSP _could_ use external clocking ... */
1318 if (drv_data->ssp_type != PXA25x_SSP) 1386 if (!pxa25x_ssp_comp(drv_data))
1319 dev_dbg(&spi->dev, "%ld Hz actual, %s\n", 1387 dev_dbg(&spi->dev, "%ld Hz actual, %s\n",
1320 clk_get_rate(ssp->clk) 1388 clk_get_rate(ssp->clk)
1321 / (1 + ((chip->cr0 & SSCR0_SCR(0xfff)) >> 8)), 1389 / (1 + ((chip->cr0 & SSCR0_SCR(0xfff)) >> 8)),
@@ -1350,23 +1418,27 @@ static int setup(struct spi_device *spi)
1350 1418
1351 spi_set_ctldata(spi, chip); 1419 spi_set_ctldata(spi, chip);
1352 1420
1421 if (drv_data->ssp_type == CE4100_SSP)
1422 return 0;
1423
1353 return setup_cs(spi, chip, chip_info); 1424 return setup_cs(spi, chip, chip_info);
1354} 1425}
1355 1426
1356static void cleanup(struct spi_device *spi) 1427static void cleanup(struct spi_device *spi)
1357{ 1428{
1358 struct chip_data *chip = spi_get_ctldata(spi); 1429 struct chip_data *chip = spi_get_ctldata(spi);
1430 struct driver_data *drv_data = spi_master_get_devdata(spi->master);
1359 1431
1360 if (!chip) 1432 if (!chip)
1361 return; 1433 return;
1362 1434
1363 if (gpio_is_valid(chip->gpio_cs)) 1435 if (drv_data->ssp_type != CE4100_SSP && gpio_is_valid(chip->gpio_cs))
1364 gpio_free(chip->gpio_cs); 1436 gpio_free(chip->gpio_cs);
1365 1437
1366 kfree(chip); 1438 kfree(chip);
1367} 1439}
1368 1440
1369static int __init init_queue(struct driver_data *drv_data) 1441static int __devinit init_queue(struct driver_data *drv_data)
1370{ 1442{
1371 INIT_LIST_HEAD(&drv_data->queue); 1443 INIT_LIST_HEAD(&drv_data->queue);
1372 spin_lock_init(&drv_data->lock); 1444 spin_lock_init(&drv_data->lock);
@@ -1454,7 +1526,7 @@ static int destroy_queue(struct driver_data *drv_data)
1454 return 0; 1526 return 0;
1455} 1527}
1456 1528
1457static int __init pxa2xx_spi_probe(struct platform_device *pdev) 1529static int __devinit pxa2xx_spi_probe(struct platform_device *pdev)
1458{ 1530{
1459 struct device *dev = &pdev->dev; 1531 struct device *dev = &pdev->dev;
1460 struct pxa2xx_spi_master *platform_info; 1532 struct pxa2xx_spi_master *platform_info;
@@ -1484,6 +1556,10 @@ static int __init pxa2xx_spi_probe(struct platform_device *pdev)
1484 drv_data->pdev = pdev; 1556 drv_data->pdev = pdev;
1485 drv_data->ssp = ssp; 1557 drv_data->ssp = ssp;
1486 1558
1559 master->dev.parent = &pdev->dev;
1560#ifdef CONFIG_OF
1561 master->dev.of_node = pdev->dev.of_node;
1562#endif
1487 /* the spi->mode bits understood by this driver: */ 1563 /* the spi->mode bits understood by this driver: */
1488 master->mode_bits = SPI_CPOL | SPI_CPHA | SPI_CS_HIGH; 1564 master->mode_bits = SPI_CPOL | SPI_CPHA | SPI_CS_HIGH;
1489 1565
@@ -1500,7 +1576,7 @@ static int __init pxa2xx_spi_probe(struct platform_device *pdev)
1500 1576
1501 drv_data->ioaddr = ssp->mmio_base; 1577 drv_data->ioaddr = ssp->mmio_base;
1502 drv_data->ssdr_physical = ssp->phys_base + SSDR; 1578 drv_data->ssdr_physical = ssp->phys_base + SSDR;
1503 if (ssp->type == PXA25x_SSP) { 1579 if (pxa25x_ssp_comp(drv_data)) {
1504 drv_data->int_cr1 = SSCR1_TIE | SSCR1_RIE; 1580 drv_data->int_cr1 = SSCR1_TIE | SSCR1_RIE;
1505 drv_data->dma_cr1 = 0; 1581 drv_data->dma_cr1 = 0;
1506 drv_data->clear_sr = SSSR_ROR; 1582 drv_data->clear_sr = SSSR_ROR;
@@ -1512,7 +1588,8 @@ static int __init pxa2xx_spi_probe(struct platform_device *pdev)
1512 drv_data->mask_sr = SSSR_TINT | SSSR_RFS | SSSR_TFS | SSSR_ROR; 1588 drv_data->mask_sr = SSSR_TINT | SSSR_RFS | SSSR_TFS | SSSR_ROR;
1513 } 1589 }
1514 1590
1515 status = request_irq(ssp->irq, ssp_int, 0, dev_name(dev), drv_data); 1591 status = request_irq(ssp->irq, ssp_int, IRQF_SHARED, dev_name(dev),
1592 drv_data);
1516 if (status < 0) { 1593 if (status < 0) {
1517 dev_err(&pdev->dev, "cannot get IRQ %d\n", ssp->irq); 1594 dev_err(&pdev->dev, "cannot get IRQ %d\n", ssp->irq);
1518 goto out_error_master_alloc; 1595 goto out_error_master_alloc;
@@ -1561,7 +1638,7 @@ static int __init pxa2xx_spi_probe(struct platform_device *pdev)
1561 | SSCR0_Motorola 1638 | SSCR0_Motorola
1562 | SSCR0_DataSize(8), 1639 | SSCR0_DataSize(8),
1563 drv_data->ioaddr); 1640 drv_data->ioaddr);
1564 if (drv_data->ssp_type != PXA25x_SSP) 1641 if (!pxa25x_ssp_comp(drv_data))
1565 write_SSTO(0, drv_data->ioaddr); 1642 write_SSTO(0, drv_data->ioaddr);
1566 write_SSPSP(0, drv_data->ioaddr); 1643 write_SSPSP(0, drv_data->ioaddr);
1567 1644
@@ -1723,13 +1800,14 @@ static struct platform_driver driver = {
1723 .pm = &pxa2xx_spi_pm_ops, 1800 .pm = &pxa2xx_spi_pm_ops,
1724#endif 1801#endif
1725 }, 1802 },
1803 .probe = pxa2xx_spi_probe,
1726 .remove = pxa2xx_spi_remove, 1804 .remove = pxa2xx_spi_remove,
1727 .shutdown = pxa2xx_spi_shutdown, 1805 .shutdown = pxa2xx_spi_shutdown,
1728}; 1806};
1729 1807
1730static int __init pxa2xx_spi_init(void) 1808static int __init pxa2xx_spi_init(void)
1731{ 1809{
1732 return platform_driver_probe(&driver, pxa2xx_spi_probe); 1810 return platform_driver_register(&driver);
1733} 1811}
1734subsys_initcall(pxa2xx_spi_init); 1812subsys_initcall(pxa2xx_spi_init);
1735 1813