aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/spi/spi-pl022.c
diff options
context:
space:
mode:
authorLinus Walleij <linus.walleij@linaro.org>2011-06-16 04:14:28 -0400
committerGrant Likely <grant.likely@secretlab.ca>2011-06-16 10:26:58 -0400
commit083be3f05371b8fe0606f3abf029beeeff66d633 (patch)
tree6c4f95fb743b512381e84c239bb6ea0c9cf8b74f /drivers/spi/spi-pl022.c
parente892bac102805f905e463a2cc7d0f870358cc1d5 (diff)
spi/pl022: initialize burstsize from FIFO trigger level
Configure the DMA burstsize from the FIFO trigger level supplied with the controller configuration data. This is based on a patch from Virupax, but I rewrote it differently. Reported-by: Virupax Sadashivpetimath <virupax.sadashivpetimath@stericsson.com> Signed-off-by: Linus Walleij <linus.walleij@linaro.org> Signed-off-by: Grant Likely <grant.likely@secretlab.ca>
Diffstat (limited to 'drivers/spi/spi-pl022.c')
-rw-r--r--drivers/spi/spi-pl022.c55
1 files changed, 53 insertions, 2 deletions
diff --git a/drivers/spi/spi-pl022.c b/drivers/spi/spi-pl022.c
index 25417054a456..f4b7b72b373e 100644
--- a/drivers/spi/spi-pl022.c
+++ b/drivers/spi/spi-pl022.c
@@ -381,6 +381,8 @@ struct pl022 {
381 enum ssp_reading read; 381 enum ssp_reading read;
382 enum ssp_writing write; 382 enum ssp_writing write;
383 u32 exp_fifo_level; 383 u32 exp_fifo_level;
384 enum ssp_rx_level_trig rx_lev_trig;
385 enum ssp_tx_level_trig tx_lev_trig;
384 /* DMA settings */ 386 /* DMA settings */
385#ifdef CONFIG_DMA_ENGINE 387#ifdef CONFIG_DMA_ENGINE
386 struct dma_chan *dma_rx_channel; 388 struct dma_chan *dma_rx_channel;
@@ -907,12 +909,10 @@ static int configure_dma(struct pl022 *pl022)
907 struct dma_slave_config rx_conf = { 909 struct dma_slave_config rx_conf = {
908 .src_addr = SSP_DR(pl022->phybase), 910 .src_addr = SSP_DR(pl022->phybase),
909 .direction = DMA_FROM_DEVICE, 911 .direction = DMA_FROM_DEVICE,
910 .src_maxburst = pl022->vendor->fifodepth >> 1,
911 }; 912 };
912 struct dma_slave_config tx_conf = { 913 struct dma_slave_config tx_conf = {
913 .dst_addr = SSP_DR(pl022->phybase), 914 .dst_addr = SSP_DR(pl022->phybase),
914 .direction = DMA_TO_DEVICE, 915 .direction = DMA_TO_DEVICE,
915 .dst_maxburst = pl022->vendor->fifodepth >> 1,
916 }; 916 };
917 unsigned int pages; 917 unsigned int pages;
918 int ret; 918 int ret;
@@ -926,6 +926,54 @@ static int configure_dma(struct pl022 *pl022)
926 if (!rxchan || !txchan) 926 if (!rxchan || !txchan)
927 return -ENODEV; 927 return -ENODEV;
928 928
929 /*
930 * If supplied, the DMA burstsize should equal the FIFO trigger level.
931 * Notice that the DMA engine uses one-to-one mapping. Since we can
932 * not trigger on 2 elements this needs explicit mapping rather than
933 * calculation.
934 */
935 switch (pl022->rx_lev_trig) {
936 case SSP_RX_1_OR_MORE_ELEM:
937 rx_conf.src_maxburst = 1;
938 break;
939 case SSP_RX_4_OR_MORE_ELEM:
940 rx_conf.src_maxburst = 4;
941 break;
942 case SSP_RX_8_OR_MORE_ELEM:
943 rx_conf.src_maxburst = 8;
944 break;
945 case SSP_RX_16_OR_MORE_ELEM:
946 rx_conf.src_maxburst = 16;
947 break;
948 case SSP_RX_32_OR_MORE_ELEM:
949 rx_conf.src_maxburst = 32;
950 break;
951 default:
952 rx_conf.src_maxburst = pl022->vendor->fifodepth >> 1;
953 break;
954 }
955
956 switch (pl022->tx_lev_trig) {
957 case SSP_TX_1_OR_MORE_EMPTY_LOC:
958 tx_conf.dst_maxburst = 1;
959 break;
960 case SSP_TX_4_OR_MORE_EMPTY_LOC:
961 tx_conf.dst_maxburst = 4;
962 break;
963 case SSP_TX_8_OR_MORE_EMPTY_LOC:
964 tx_conf.dst_maxburst = 8;
965 break;
966 case SSP_TX_16_OR_MORE_EMPTY_LOC:
967 tx_conf.dst_maxburst = 16;
968 break;
969 case SSP_TX_32_OR_MORE_EMPTY_LOC:
970 tx_conf.dst_maxburst = 32;
971 break;
972 default:
973 tx_conf.dst_maxburst = pl022->vendor->fifodepth >> 1;
974 break;
975 }
976
929 switch (pl022->read) { 977 switch (pl022->read) {
930 case READING_NULL: 978 case READING_NULL:
931 /* Use the same as for writing */ 979 /* Use the same as for writing */
@@ -1871,6 +1919,9 @@ static int pl022_setup(struct spi_device *spi)
1871 goto err_config_params; 1919 goto err_config_params;
1872 } 1920 }
1873 1921
1922 pl022->rx_lev_trig = chip_info->rx_lev_trig;
1923 pl022->tx_lev_trig = chip_info->tx_lev_trig;
1924
1874 /* Now set controller state based on controller data */ 1925 /* Now set controller state based on controller data */
1875 chip->xfer_type = chip_info->com_mode; 1926 chip->xfer_type = chip_info->com_mode;
1876 if (!chip_info->cs_control) { 1927 if (!chip_info->cs_control) {