aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/spi/spi-omap2-mcspi.c
diff options
context:
space:
mode:
authorGrant Likely <grant.likely@secretlab.ca>2013-02-05 07:30:13 -0500
committerGrant Likely <grant.likely@secretlab.ca>2013-02-05 07:30:13 -0500
commitf305a0a8d7fcd1a600bd0b727cd8137ed223f721 (patch)
tree982681a7e3c643096b65b9626ae993597155979d /drivers/spi/spi-omap2-mcspi.c
parent766ed70447e0a9cfb23d068a4a929e18e54b0022 (diff)
parentd560040f7d6fbe0a2990b8f6edca1815e19e72f5 (diff)
Merge branch 'broonie/spi-next' of git://git.kernel.org/pub/scm/linux/kernel/git/broonie/misc.git
Minor features and bug fixes for PXA, OMAP and GPIO deivce drivers and a cosmetic change to the bitbang driver. Signed-off-by: Grant Likely <grant.likely@secretlab.ca>
Diffstat (limited to 'drivers/spi/spi-omap2-mcspi.c')
-rw-r--r--drivers/spi/spi-omap2-mcspi.c34
1 files changed, 26 insertions, 8 deletions
diff --git a/drivers/spi/spi-omap2-mcspi.c b/drivers/spi/spi-omap2-mcspi.c
index 68446dbd5545..69945b014c96 100644
--- a/drivers/spi/spi-omap2-mcspi.c
+++ b/drivers/spi/spi-omap2-mcspi.c
@@ -927,6 +927,7 @@ static void omap2_mcspi_work(struct omap2_mcspi *mcspi, struct spi_message *m)
927 927
928 struct spi_device *spi; 928 struct spi_device *spi;
929 struct spi_transfer *t = NULL; 929 struct spi_transfer *t = NULL;
930 struct spi_master *master;
930 int cs_active = 0; 931 int cs_active = 0;
931 struct omap2_mcspi_cs *cs; 932 struct omap2_mcspi_cs *cs;
932 struct omap2_mcspi_device_config *cd; 933 struct omap2_mcspi_device_config *cd;
@@ -935,6 +936,7 @@ static void omap2_mcspi_work(struct omap2_mcspi *mcspi, struct spi_message *m)
935 u32 chconf; 936 u32 chconf;
936 937
937 spi = m->spi; 938 spi = m->spi;
939 master = spi->master;
938 cs = spi->controller_state; 940 cs = spi->controller_state;
939 cd = spi->controller_data; 941 cd = spi->controller_data;
940 942
@@ -952,6 +954,14 @@ static void omap2_mcspi_work(struct omap2_mcspi *mcspi, struct spi_message *m)
952 if (!t->speed_hz && !t->bits_per_word) 954 if (!t->speed_hz && !t->bits_per_word)
953 par_override = 0; 955 par_override = 0;
954 } 956 }
957 if (cd && cd->cs_per_word) {
958 chconf = mcspi->ctx.modulctrl;
959 chconf &= ~OMAP2_MCSPI_MODULCTRL_SINGLE;
960 mcspi_write_reg(master, OMAP2_MCSPI_MODULCTRL, chconf);
961 mcspi->ctx.modulctrl =
962 mcspi_read_cs_reg(spi, OMAP2_MCSPI_MODULCTRL);
963 }
964
955 965
956 if (!cs_active) { 966 if (!cs_active) {
957 omap2_mcspi_force_cs(spi, 1); 967 omap2_mcspi_force_cs(spi, 1);
@@ -1013,6 +1023,14 @@ static void omap2_mcspi_work(struct omap2_mcspi *mcspi, struct spi_message *m)
1013 if (cs_active) 1023 if (cs_active)
1014 omap2_mcspi_force_cs(spi, 0); 1024 omap2_mcspi_force_cs(spi, 0);
1015 1025
1026 if (cd && cd->cs_per_word) {
1027 chconf = mcspi->ctx.modulctrl;
1028 chconf |= OMAP2_MCSPI_MODULCTRL_SINGLE;
1029 mcspi_write_reg(master, OMAP2_MCSPI_MODULCTRL, chconf);
1030 mcspi->ctx.modulctrl =
1031 mcspi_read_cs_reg(spi, OMAP2_MCSPI_MODULCTRL);
1032 }
1033
1016 omap2_mcspi_set_enable(spi, 0); 1034 omap2_mcspi_set_enable(spi, 0);
1017 1035
1018 m->status = status; 1036 m->status = status;
@@ -1020,7 +1038,7 @@ static void omap2_mcspi_work(struct omap2_mcspi *mcspi, struct spi_message *m)
1020} 1038}
1021 1039
1022static int omap2_mcspi_transfer_one_message(struct spi_master *master, 1040static int omap2_mcspi_transfer_one_message(struct spi_master *master,
1023 struct spi_message *m) 1041 struct spi_message *m)
1024{ 1042{
1025 struct omap2_mcspi *mcspi; 1043 struct omap2_mcspi *mcspi;
1026 struct spi_transfer *t; 1044 struct spi_transfer *t;
@@ -1041,7 +1059,7 @@ static int omap2_mcspi_transfer_one_message(struct spi_master *master,
1041 || (len && !(rx_buf || tx_buf)) 1059 || (len && !(rx_buf || tx_buf))
1042 || (t->bits_per_word && 1060 || (t->bits_per_word &&
1043 ( t->bits_per_word < 4 1061 ( t->bits_per_word < 4
1044 || t->bits_per_word > 32))) { 1062 || t->bits_per_word > 32))) {
1045 dev_dbg(mcspi->dev, "transfer: %d Hz, %d %s%s, %d bpw\n", 1063 dev_dbg(mcspi->dev, "transfer: %d Hz, %d %s%s, %d bpw\n",
1046 t->speed_hz, 1064 t->speed_hz,
1047 len, 1065 len,
@@ -1052,8 +1070,8 @@ static int omap2_mcspi_transfer_one_message(struct spi_master *master,
1052 } 1070 }
1053 if (t->speed_hz && t->speed_hz < (OMAP2_MCSPI_MAX_FREQ >> 15)) { 1071 if (t->speed_hz && t->speed_hz < (OMAP2_MCSPI_MAX_FREQ >> 15)) {
1054 dev_dbg(mcspi->dev, "speed_hz %d below minimum %d Hz\n", 1072 dev_dbg(mcspi->dev, "speed_hz %d below minimum %d Hz\n",
1055 t->speed_hz, 1073 t->speed_hz,
1056 OMAP2_MCSPI_MAX_FREQ >> 15); 1074 OMAP2_MCSPI_MAX_FREQ >> 15);
1057 return -EINVAL; 1075 return -EINVAL;
1058 } 1076 }
1059 1077
@@ -1099,7 +1117,7 @@ static int omap2_mcspi_master_setup(struct omap2_mcspi *mcspi)
1099 return ret; 1117 return ret;
1100 1118
1101 mcspi_write_reg(master, OMAP2_MCSPI_WAKEUPENABLE, 1119 mcspi_write_reg(master, OMAP2_MCSPI_WAKEUPENABLE,
1102 OMAP2_MCSPI_WAKEUPENABLE_WKEN); 1120 OMAP2_MCSPI_WAKEUPENABLE_WKEN);
1103 ctx->wakeupenable = OMAP2_MCSPI_WAKEUPENABLE_WKEN; 1121 ctx->wakeupenable = OMAP2_MCSPI_WAKEUPENABLE_WKEN;
1104 1122
1105 omap2_mcspi_set_master_mode(master); 1123 omap2_mcspi_set_master_mode(master);
@@ -1228,7 +1246,7 @@ static int omap2_mcspi_probe(struct platform_device *pdev)
1228 1246
1229 sprintf(dma_ch_name, "rx%d", i); 1247 sprintf(dma_ch_name, "rx%d", i);
1230 dma_res = platform_get_resource_byname(pdev, IORESOURCE_DMA, 1248 dma_res = platform_get_resource_byname(pdev, IORESOURCE_DMA,
1231 dma_ch_name); 1249 dma_ch_name);
1232 if (!dma_res) { 1250 if (!dma_res) {
1233 dev_dbg(&pdev->dev, "cannot get DMA RX channel\n"); 1251 dev_dbg(&pdev->dev, "cannot get DMA RX channel\n");
1234 status = -ENODEV; 1252 status = -ENODEV;
@@ -1238,7 +1256,7 @@ static int omap2_mcspi_probe(struct platform_device *pdev)
1238 mcspi->dma_channels[i].dma_rx_sync_dev = dma_res->start; 1256 mcspi->dma_channels[i].dma_rx_sync_dev = dma_res->start;
1239 sprintf(dma_ch_name, "tx%d", i); 1257 sprintf(dma_ch_name, "tx%d", i);
1240 dma_res = platform_get_resource_byname(pdev, IORESOURCE_DMA, 1258 dma_res = platform_get_resource_byname(pdev, IORESOURCE_DMA,
1241 dma_ch_name); 1259 dma_ch_name);
1242 if (!dma_res) { 1260 if (!dma_res) {
1243 dev_dbg(&pdev->dev, "cannot get DMA TX channel\n"); 1261 dev_dbg(&pdev->dev, "cannot get DMA TX channel\n");
1244 status = -ENODEV; 1262 status = -ENODEV;
@@ -1254,7 +1272,7 @@ static int omap2_mcspi_probe(struct platform_device *pdev)
1254 pinctrl = devm_pinctrl_get_select_default(&pdev->dev); 1272 pinctrl = devm_pinctrl_get_select_default(&pdev->dev);
1255 if (IS_ERR(pinctrl)) 1273 if (IS_ERR(pinctrl))
1256 dev_warn(&pdev->dev, 1274 dev_warn(&pdev->dev,
1257 "pins are not configured from the driver\n"); 1275 "pins are not configured from the driver\n");
1258 1276
1259 pm_runtime_use_autosuspend(&pdev->dev); 1277 pm_runtime_use_autosuspend(&pdev->dev);
1260 pm_runtime_set_autosuspend_delay(&pdev->dev, SPI_AUTOSUSPEND_TIMEOUT); 1278 pm_runtime_set_autosuspend_delay(&pdev->dev, SPI_AUTOSUSPEND_TIMEOUT);