diff options
author | Brian Niebuhr <bniebuhr@efjohnson.com> | 2010-08-20 07:32:49 -0400 |
---|---|---|
committer | Sekhar Nori <nsekhar@ti.com> | 2010-11-18 08:08:29 -0500 |
commit | cf90fe73504764cbcc2552c7ea69b1866059db30 (patch) | |
tree | 6437d026e5ee4781da5f805e65d03eeb7c478e24 /drivers/spi/davinci_spi.c | |
parent | 47f44671c0dc92e2b77ff3dd843f742d12510477 (diff) |
spi: davinci: remove non-useful interrupt mode support
The interrupt mode support as it stands is another version
of poll mode. Even when interrupt mode is selected, the code
tight loops on interrupt status register, rendering it totally
useless. A completion variable is initialized, but never used.
Remove this fake interrupt mode since users can anyway use
poll mode with no functional difference. A usefully implemented
interrupt mode support can be added later.
Signed-off-by: Brian Niebuhr <bniebuhr@efjohnson.com>
Tested-By: Michael Williamson <michael.williamson@criticallink.com>
Signed-off-by: Sekhar Nori <nsekhar@ti.com>
Diffstat (limited to 'drivers/spi/davinci_spi.c')
-rw-r--r-- | drivers/spi/davinci_spi.c | 126 |
1 files changed, 19 insertions, 107 deletions
diff --git a/drivers/spi/davinci_spi.c b/drivers/spi/davinci_spi.c index 54d06f409b65..198f062da370 100644 --- a/drivers/spi/davinci_spi.c +++ b/drivers/spi/davinci_spi.c | |||
@@ -59,8 +59,6 @@ | |||
59 | #define SPIPC0_SPIENA_MASK BIT(8) /* nREADY */ | 59 | #define SPIPC0_SPIENA_MASK BIT(8) /* nREADY */ |
60 | 60 | ||
61 | #define SPIINT_MASKALL 0x0101035F | 61 | #define SPIINT_MASKALL 0x0101035F |
62 | #define SPI_INTLVL_1 0x000001FFu | ||
63 | #define SPI_INTLVL_0 0x00000000u | ||
64 | 62 | ||
65 | /* SPIDAT1 (upper 16 bit defines) */ | 63 | /* SPIDAT1 (upper 16 bit defines) */ |
66 | #define SPIDAT1_CSHOLD_MASK BIT(12) | 64 | #define SPIDAT1_CSHOLD_MASK BIT(12) |
@@ -92,14 +90,8 @@ | |||
92 | #define SPIFLG_DESYNC_MASK BIT(3) | 90 | #define SPIFLG_DESYNC_MASK BIT(3) |
93 | #define SPIFLG_BITERR_MASK BIT(4) | 91 | #define SPIFLG_BITERR_MASK BIT(4) |
94 | #define SPIFLG_OVRRUN_MASK BIT(6) | 92 | #define SPIFLG_OVRRUN_MASK BIT(6) |
95 | #define SPIFLG_RX_INTR_MASK BIT(8) | ||
96 | #define SPIFLG_TX_INTR_MASK BIT(9) | ||
97 | #define SPIFLG_BUF_INIT_ACTIVE_MASK BIT(24) | 93 | #define SPIFLG_BUF_INIT_ACTIVE_MASK BIT(24) |
98 | 94 | ||
99 | #define SPIINT_BITERR_INTR BIT(4) | ||
100 | #define SPIINT_OVRRUN_INTR BIT(6) | ||
101 | #define SPIINT_RX_INTR BIT(8) | ||
102 | #define SPIINT_TX_INTR BIT(9) | ||
103 | #define SPIINT_DMA_REQ_EN BIT(16) | 95 | #define SPIINT_DMA_REQ_EN BIT(16) |
104 | 96 | ||
105 | /* SPI Controller registers */ | 97 | /* SPI Controller registers */ |
@@ -136,8 +128,6 @@ struct davinci_spi { | |||
136 | resource_size_t pbase; | 128 | resource_size_t pbase; |
137 | void __iomem *base; | 129 | void __iomem *base; |
138 | size_t region_size; | 130 | size_t region_size; |
139 | u32 irq; | ||
140 | struct completion done; | ||
141 | 131 | ||
142 | const void *tx; | 132 | const void *tx; |
143 | void *rx; | 133 | void *rx; |
@@ -611,7 +601,7 @@ static int davinci_spi_check_error(struct davinci_spi *davinci_spi, | |||
611 | static int davinci_spi_bufs_pio(struct spi_device *spi, struct spi_transfer *t) | 601 | static int davinci_spi_bufs_pio(struct spi_device *spi, struct spi_transfer *t) |
612 | { | 602 | { |
613 | struct davinci_spi *davinci_spi; | 603 | struct davinci_spi *davinci_spi; |
614 | int int_status, count, ret; | 604 | int status, count, ret; |
615 | u8 conv; | 605 | u8 conv; |
616 | u32 tx_data, data1_reg_val; | 606 | u32 tx_data, data1_reg_val; |
617 | u32 buf_val, flg_val; | 607 | u32 buf_val, flg_val; |
@@ -627,8 +617,6 @@ static int davinci_spi_bufs_pio(struct spi_device *spi, struct spi_transfer *t) | |||
627 | conv = davinci_spi->bytes_per_word[spi->chip_select]; | 617 | conv = davinci_spi->bytes_per_word[spi->chip_select]; |
628 | data1_reg_val = ioread32(davinci_spi->base + SPIDAT1); | 618 | data1_reg_val = ioread32(davinci_spi->base + SPIDAT1); |
629 | 619 | ||
630 | INIT_COMPLETION(davinci_spi->done); | ||
631 | |||
632 | ret = davinci_spi_bufs_prep(spi, davinci_spi); | 620 | ret = davinci_spi_bufs_prep(spi, davinci_spi); |
633 | if (ret) | 621 | if (ret) |
634 | return ret; | 622 | return ret; |
@@ -638,9 +626,10 @@ static int davinci_spi_bufs_pio(struct spi_device *spi, struct spi_transfer *t) | |||
638 | 626 | ||
639 | count = t->len / conv; | 627 | count = t->len / conv; |
640 | 628 | ||
629 | clear_io_bits(davinci_spi->base + SPIINT, SPIINT_MASKALL); | ||
630 | |||
641 | /* Determine the command to execute READ or WRITE */ | 631 | /* Determine the command to execute READ or WRITE */ |
642 | if (t->tx_buf) { | 632 | if (t->tx_buf) { |
643 | clear_io_bits(davinci_spi->base + SPIINT, SPIINT_MASKALL); | ||
644 | 633 | ||
645 | while (1) { | 634 | while (1) { |
646 | tx_data = davinci_spi->get_tx(davinci_spi); | 635 | tx_data = davinci_spi->get_tx(davinci_spi); |
@@ -668,45 +657,25 @@ static int davinci_spi_bufs_pio(struct spi_device *spi, struct spi_transfer *t) | |||
668 | break; | 657 | break; |
669 | } | 658 | } |
670 | } else { | 659 | } else { |
671 | if (pdata->poll_mode) { | 660 | while (1) { |
672 | while (1) { | 661 | /* keeps the serial clock going */ |
673 | /* keeps the serial clock going */ | 662 | if ((ioread32(davinci_spi->base + SPIBUF) |
674 | if ((ioread32(davinci_spi->base + SPIBUF) | 663 | & SPIBUF_TXFULL_MASK) == 0) |
675 | & SPIBUF_TXFULL_MASK) == 0) | 664 | iowrite32(data1_reg_val, |
676 | iowrite32(data1_reg_val, | 665 | davinci_spi->base + SPIDAT1); |
677 | davinci_spi->base + SPIDAT1); | ||
678 | 666 | ||
679 | while (ioread32(davinci_spi->base + SPIBUF) & | 667 | while (ioread32(davinci_spi->base + SPIBUF) & |
680 | SPIBUF_RXEMPTY_MASK) | 668 | SPIBUF_RXEMPTY_MASK) |
681 | cpu_relax(); | 669 | cpu_relax(); |
682 | 670 | ||
683 | flg_val = ioread32(davinci_spi->base + SPIFLG); | 671 | flg_val = ioread32(davinci_spi->base + SPIFLG); |
684 | buf_val = ioread32(davinci_spi->base + SPIBUF); | 672 | buf_val = ioread32(davinci_spi->base + SPIBUF); |
685 | |||
686 | davinci_spi->get_rx(buf_val, davinci_spi); | ||
687 | |||
688 | count--; | ||
689 | if (count <= 0) | ||
690 | break; | ||
691 | } | ||
692 | } else { /* Receive in Interrupt mode */ | ||
693 | int i; | ||
694 | |||
695 | for (i = 0; i < count; i++) { | ||
696 | set_io_bits(davinci_spi->base + SPIINT, | ||
697 | SPIINT_BITERR_INTR | ||
698 | | SPIINT_OVRRUN_INTR | ||
699 | | SPIINT_RX_INTR); | ||
700 | 673 | ||
701 | iowrite32(data1_reg_val, | 674 | davinci_spi->get_rx(buf_val, davinci_spi); |
702 | davinci_spi->base + SPIDAT1); | ||
703 | 675 | ||
704 | while (ioread32(davinci_spi->base + SPIINT) & | 676 | count--; |
705 | SPIINT_RX_INTR) | 677 | if (count <= 0) |
706 | cpu_relax(); | 678 | break; |
707 | } | ||
708 | iowrite32((data1_reg_val & 0x0ffcffff), | ||
709 | davinci_spi->base + SPIDAT1); | ||
710 | } | 679 | } |
711 | } | 680 | } |
712 | 681 | ||
@@ -714,9 +683,9 @@ static int davinci_spi_bufs_pio(struct spi_device *spi, struct spi_transfer *t) | |||
714 | * Check for bit error, desync error,parity error,timeout error and | 683 | * Check for bit error, desync error,parity error,timeout error and |
715 | * receive overflow errors | 684 | * receive overflow errors |
716 | */ | 685 | */ |
717 | int_status = ioread32(davinci_spi->base + SPIFLG); | 686 | status = ioread32(davinci_spi->base + SPIFLG); |
718 | 687 | ||
719 | ret = davinci_spi_check_error(davinci_spi, int_status); | 688 | ret = davinci_spi_check_error(davinci_spi, status); |
720 | if (ret != 0) | 689 | if (ret != 0) |
721 | return ret; | 690 | return ret; |
722 | 691 | ||
@@ -854,38 +823,6 @@ static int davinci_spi_bufs_dma(struct spi_device *spi, struct spi_transfer *t) | |||
854 | } | 823 | } |
855 | 824 | ||
856 | /** | 825 | /** |
857 | * davinci_spi_irq - IRQ handler for DaVinci SPI | ||
858 | * @irq: IRQ number for this SPI Master | ||
859 | * @context_data: structure for SPI Master controller davinci_spi | ||
860 | */ | ||
861 | static irqreturn_t davinci_spi_irq(s32 irq, void *context_data) | ||
862 | { | ||
863 | struct davinci_spi *davinci_spi = context_data; | ||
864 | u32 int_status, rx_data = 0; | ||
865 | irqreturn_t ret = IRQ_NONE; | ||
866 | |||
867 | int_status = ioread32(davinci_spi->base + SPIFLG); | ||
868 | |||
869 | while ((int_status & SPIFLG_RX_INTR_MASK)) { | ||
870 | if (likely(int_status & SPIFLG_RX_INTR_MASK)) { | ||
871 | ret = IRQ_HANDLED; | ||
872 | |||
873 | rx_data = ioread32(davinci_spi->base + SPIBUF); | ||
874 | davinci_spi->get_rx(rx_data, davinci_spi); | ||
875 | |||
876 | /* Disable Receive Interrupt */ | ||
877 | iowrite32(~(SPIINT_RX_INTR | SPIINT_TX_INTR), | ||
878 | davinci_spi->base + SPIINT); | ||
879 | } else | ||
880 | (void)davinci_spi_check_error(davinci_spi, int_status); | ||
881 | |||
882 | int_status = ioread32(davinci_spi->base + SPIFLG); | ||
883 | } | ||
884 | |||
885 | return ret; | ||
886 | } | ||
887 | |||
888 | /** | ||
889 | * davinci_spi_probe - probe function for SPI Master Controller | 826 | * davinci_spi_probe - probe function for SPI Master Controller |
890 | * @pdev: platform_device structure which contains plateform specific data | 827 | * @pdev: platform_device structure which contains plateform specific data |
891 | */ | 828 | */ |
@@ -943,22 +880,11 @@ static int davinci_spi_probe(struct platform_device *pdev) | |||
943 | goto release_region; | 880 | goto release_region; |
944 | } | 881 | } |
945 | 882 | ||
946 | davinci_spi->irq = platform_get_irq(pdev, 0); | ||
947 | if (davinci_spi->irq <= 0) { | ||
948 | ret = -EINVAL; | ||
949 | goto unmap_io; | ||
950 | } | ||
951 | |||
952 | ret = request_irq(davinci_spi->irq, davinci_spi_irq, IRQF_DISABLED, | ||
953 | dev_name(&pdev->dev), davinci_spi); | ||
954 | if (ret) | ||
955 | goto unmap_io; | ||
956 | |||
957 | /* Allocate tmp_buf for tx_buf */ | 883 | /* Allocate tmp_buf for tx_buf */ |
958 | davinci_spi->tmp_buf = kzalloc(SPI_BUFSIZ, GFP_KERNEL); | 884 | davinci_spi->tmp_buf = kzalloc(SPI_BUFSIZ, GFP_KERNEL); |
959 | if (davinci_spi->tmp_buf == NULL) { | 885 | if (davinci_spi->tmp_buf == NULL) { |
960 | ret = -ENOMEM; | 886 | ret = -ENOMEM; |
961 | goto irq_free; | 887 | goto unmap_io; |
962 | } | 888 | } |
963 | 889 | ||
964 | davinci_spi->bitbang.master = spi_master_get(master); | 890 | davinci_spi->bitbang.master = spi_master_get(master); |
@@ -1034,8 +960,6 @@ static int davinci_spi_probe(struct platform_device *pdev) | |||
1034 | davinci_spi->get_rx = davinci_spi_rx_buf_u8; | 960 | davinci_spi->get_rx = davinci_spi_rx_buf_u8; |
1035 | davinci_spi->get_tx = davinci_spi_tx_buf_u8; | 961 | davinci_spi->get_tx = davinci_spi_tx_buf_u8; |
1036 | 962 | ||
1037 | init_completion(&davinci_spi->done); | ||
1038 | |||
1039 | /* Reset In/OUT SPI module */ | 963 | /* Reset In/OUT SPI module */ |
1040 | iowrite32(0, davinci_spi->base + SPIGCR0); | 964 | iowrite32(0, davinci_spi->base + SPIGCR0); |
1041 | udelay(100); | 965 | udelay(100); |
@@ -1062,21 +986,12 @@ static int davinci_spi_probe(struct platform_device *pdev) | |||
1062 | /* master mode default */ | 986 | /* master mode default */ |
1063 | set_io_bits(davinci_spi->base + SPIGCR1, SPIGCR1_MASTER_MASK); | 987 | set_io_bits(davinci_spi->base + SPIGCR1, SPIGCR1_MASTER_MASK); |
1064 | 988 | ||
1065 | if (davinci_spi->pdata->intr_level) | ||
1066 | iowrite32(SPI_INTLVL_1, davinci_spi->base + SPILVL); | ||
1067 | else | ||
1068 | iowrite32(SPI_INTLVL_0, davinci_spi->base + SPILVL); | ||
1069 | |||
1070 | ret = spi_bitbang_start(&davinci_spi->bitbang); | 989 | ret = spi_bitbang_start(&davinci_spi->bitbang); |
1071 | if (ret) | 990 | if (ret) |
1072 | goto free_clk; | 991 | goto free_clk; |
1073 | 992 | ||
1074 | dev_info(&pdev->dev, "Controller at 0x%p\n", davinci_spi->base); | 993 | dev_info(&pdev->dev, "Controller at 0x%p\n", davinci_spi->base); |
1075 | 994 | ||
1076 | if (!pdata->poll_mode) | ||
1077 | dev_info(&pdev->dev, "Operating in interrupt mode" | ||
1078 | " using IRQ %d\n", davinci_spi->irq); | ||
1079 | |||
1080 | return ret; | 995 | return ret; |
1081 | 996 | ||
1082 | free_clk: | 997 | free_clk: |
@@ -1086,8 +1001,6 @@ put_master: | |||
1086 | spi_master_put(master); | 1001 | spi_master_put(master); |
1087 | free_tmp_buf: | 1002 | free_tmp_buf: |
1088 | kfree(davinci_spi->tmp_buf); | 1003 | kfree(davinci_spi->tmp_buf); |
1089 | irq_free: | ||
1090 | free_irq(davinci_spi->irq, davinci_spi); | ||
1091 | unmap_io: | 1004 | unmap_io: |
1092 | iounmap(davinci_spi->base); | 1005 | iounmap(davinci_spi->base); |
1093 | release_region: | 1006 | release_region: |
@@ -1121,7 +1034,6 @@ static int __exit davinci_spi_remove(struct platform_device *pdev) | |||
1121 | clk_put(davinci_spi->clk); | 1034 | clk_put(davinci_spi->clk); |
1122 | spi_master_put(master); | 1035 | spi_master_put(master); |
1123 | kfree(davinci_spi->tmp_buf); | 1036 | kfree(davinci_spi->tmp_buf); |
1124 | free_irq(davinci_spi->irq, davinci_spi); | ||
1125 | iounmap(davinci_spi->base); | 1037 | iounmap(davinci_spi->base); |
1126 | release_mem_region(davinci_spi->pbase, davinci_spi->region_size); | 1038 | release_mem_region(davinci_spi->pbase, davinci_spi->region_size); |
1127 | 1039 | ||