diff options
Diffstat (limited to 'drivers/spi/spi-pxa2xx.c')
-rw-r--r-- | drivers/spi/spi-pxa2xx.c | 62 |
1 files changed, 7 insertions, 55 deletions
diff --git a/drivers/spi/spi-pxa2xx.c b/drivers/spi/spi-pxa2xx.c index f5d84d6f8222..f440dcee852b 100644 --- a/drivers/spi/spi-pxa2xx.c +++ b/drivers/spi/spi-pxa2xx.c | |||
@@ -881,21 +881,6 @@ static int setup(struct spi_device *spi) | |||
881 | rx_thres = RX_THRESH_DFLT; | 881 | rx_thres = RX_THRESH_DFLT; |
882 | } | 882 | } |
883 | 883 | ||
884 | if (!pxa25x_ssp_comp(drv_data) | ||
885 | && (spi->bits_per_word < 4 || spi->bits_per_word > 32)) { | ||
886 | dev_err(&spi->dev, "failed setup: ssp_type=%d, bits/wrd=%d " | ||
887 | "b/w not 4-32 for type non-PXA25x_SSP\n", | ||
888 | drv_data->ssp_type, spi->bits_per_word); | ||
889 | return -EINVAL; | ||
890 | } else if (pxa25x_ssp_comp(drv_data) | ||
891 | && (spi->bits_per_word < 4 | ||
892 | || spi->bits_per_word > 16)) { | ||
893 | dev_err(&spi->dev, "failed setup: ssp_type=%d, bits/wrd=%d " | ||
894 | "b/w not 4-16 for type PXA25x_SSP\n", | ||
895 | drv_data->ssp_type, spi->bits_per_word); | ||
896 | return -EINVAL; | ||
897 | } | ||
898 | |||
899 | /* Only alloc on first setup */ | 884 | /* Only alloc on first setup */ |
900 | chip = spi_get_ctldata(spi); | 885 | chip = spi_get_ctldata(spi); |
901 | if (!chip) { | 886 | if (!chip) { |
@@ -1011,9 +996,6 @@ static int setup(struct spi_device *spi) | |||
1011 | chip->n_bytes = 4; | 996 | chip->n_bytes = 4; |
1012 | chip->read = u32_reader; | 997 | chip->read = u32_reader; |
1013 | chip->write = u32_writer; | 998 | chip->write = u32_writer; |
1014 | } else { | ||
1015 | dev_err(&spi->dev, "invalid wordsize\n"); | ||
1016 | return -ENODEV; | ||
1017 | } | 999 | } |
1018 | chip->bits_per_word = spi->bits_per_word; | 1000 | chip->bits_per_word = spi->bits_per_word; |
1019 | 1001 | ||
@@ -1040,32 +1022,10 @@ static void cleanup(struct spi_device *spi) | |||
1040 | } | 1022 | } |
1041 | 1023 | ||
1042 | #ifdef CONFIG_ACPI | 1024 | #ifdef CONFIG_ACPI |
1043 | static int pxa2xx_spi_acpi_add_dma(struct acpi_resource *res, void *data) | ||
1044 | { | ||
1045 | struct pxa2xx_spi_master *pdata = data; | ||
1046 | |||
1047 | if (res->type == ACPI_RESOURCE_TYPE_FIXED_DMA) { | ||
1048 | const struct acpi_resource_fixed_dma *dma; | ||
1049 | |||
1050 | dma = &res->data.fixed_dma; | ||
1051 | if (pdata->tx_slave_id < 0) { | ||
1052 | pdata->tx_slave_id = dma->request_lines; | ||
1053 | pdata->tx_chan_id = dma->channels; | ||
1054 | } else if (pdata->rx_slave_id < 0) { | ||
1055 | pdata->rx_slave_id = dma->request_lines; | ||
1056 | pdata->rx_chan_id = dma->channels; | ||
1057 | } | ||
1058 | } | ||
1059 | |||
1060 | /* Tell the ACPI core to skip this resource */ | ||
1061 | return 1; | ||
1062 | } | ||
1063 | |||
1064 | static struct pxa2xx_spi_master * | 1025 | static struct pxa2xx_spi_master * |
1065 | pxa2xx_spi_acpi_get_pdata(struct platform_device *pdev) | 1026 | pxa2xx_spi_acpi_get_pdata(struct platform_device *pdev) |
1066 | { | 1027 | { |
1067 | struct pxa2xx_spi_master *pdata; | 1028 | struct pxa2xx_spi_master *pdata; |
1068 | struct list_head resource_list; | ||
1069 | struct acpi_device *adev; | 1029 | struct acpi_device *adev; |
1070 | struct ssp_device *ssp; | 1030 | struct ssp_device *ssp; |
1071 | struct resource *res; | 1031 | struct resource *res; |
@@ -1075,7 +1035,7 @@ pxa2xx_spi_acpi_get_pdata(struct platform_device *pdev) | |||
1075 | acpi_bus_get_device(ACPI_HANDLE(&pdev->dev), &adev)) | 1035 | acpi_bus_get_device(ACPI_HANDLE(&pdev->dev), &adev)) |
1076 | return NULL; | 1036 | return NULL; |
1077 | 1037 | ||
1078 | pdata = devm_kzalloc(&pdev->dev, sizeof(*ssp), GFP_KERNEL); | 1038 | pdata = devm_kzalloc(&pdev->dev, sizeof(*pdata), GFP_KERNEL); |
1079 | if (!pdata) { | 1039 | if (!pdata) { |
1080 | dev_err(&pdev->dev, | 1040 | dev_err(&pdev->dev, |
1081 | "failed to allocate memory for platform data\n"); | 1041 | "failed to allocate memory for platform data\n"); |
@@ -1091,7 +1051,7 @@ pxa2xx_spi_acpi_get_pdata(struct platform_device *pdev) | |||
1091 | ssp->phys_base = res->start; | 1051 | ssp->phys_base = res->start; |
1092 | ssp->mmio_base = devm_ioremap_resource(&pdev->dev, res); | 1052 | ssp->mmio_base = devm_ioremap_resource(&pdev->dev, res); |
1093 | if (IS_ERR(ssp->mmio_base)) | 1053 | if (IS_ERR(ssp->mmio_base)) |
1094 | return PTR_ERR(ssp->mmio_base); | 1054 | return NULL; |
1095 | 1055 | ||
1096 | ssp->clk = devm_clk_get(&pdev->dev, NULL); | 1056 | ssp->clk = devm_clk_get(&pdev->dev, NULL); |
1097 | ssp->irq = platform_get_irq(pdev, 0); | 1057 | ssp->irq = platform_get_irq(pdev, 0); |
@@ -1103,15 +1063,7 @@ pxa2xx_spi_acpi_get_pdata(struct platform_device *pdev) | |||
1103 | ssp->port_id = devid; | 1063 | ssp->port_id = devid; |
1104 | 1064 | ||
1105 | pdata->num_chipselect = 1; | 1065 | pdata->num_chipselect = 1; |
1106 | pdata->rx_slave_id = -1; | 1066 | pdata->enable_dma = true; |
1107 | pdata->tx_slave_id = -1; | ||
1108 | |||
1109 | INIT_LIST_HEAD(&resource_list); | ||
1110 | acpi_dev_get_resources(adev, &resource_list, pxa2xx_spi_acpi_add_dma, | ||
1111 | pdata); | ||
1112 | acpi_dev_free_resource_list(&resource_list); | ||
1113 | |||
1114 | pdata->enable_dma = pdata->rx_slave_id >= 0 && pdata->tx_slave_id >= 0; | ||
1115 | 1067 | ||
1116 | return pdata; | 1068 | return pdata; |
1117 | } | 1069 | } |
@@ -1119,6 +1071,7 @@ pxa2xx_spi_acpi_get_pdata(struct platform_device *pdev) | |||
1119 | static struct acpi_device_id pxa2xx_spi_acpi_match[] = { | 1071 | static struct acpi_device_id pxa2xx_spi_acpi_match[] = { |
1120 | { "INT33C0", 0 }, | 1072 | { "INT33C0", 0 }, |
1121 | { "INT33C1", 0 }, | 1073 | { "INT33C1", 0 }, |
1074 | { "80860F0E", 0 }, | ||
1122 | { }, | 1075 | { }, |
1123 | }; | 1076 | }; |
1124 | MODULE_DEVICE_TABLE(acpi, pxa2xx_spi_acpi_match); | 1077 | MODULE_DEVICE_TABLE(acpi, pxa2xx_spi_acpi_match); |
@@ -1190,11 +1143,13 @@ static int pxa2xx_spi_probe(struct platform_device *pdev) | |||
1190 | drv_data->ioaddr = ssp->mmio_base; | 1143 | drv_data->ioaddr = ssp->mmio_base; |
1191 | drv_data->ssdr_physical = ssp->phys_base + SSDR; | 1144 | drv_data->ssdr_physical = ssp->phys_base + SSDR; |
1192 | if (pxa25x_ssp_comp(drv_data)) { | 1145 | if (pxa25x_ssp_comp(drv_data)) { |
1146 | master->bits_per_word_mask = SPI_BPW_RANGE_MASK(4, 16); | ||
1193 | drv_data->int_cr1 = SSCR1_TIE | SSCR1_RIE; | 1147 | drv_data->int_cr1 = SSCR1_TIE | SSCR1_RIE; |
1194 | drv_data->dma_cr1 = 0; | 1148 | drv_data->dma_cr1 = 0; |
1195 | drv_data->clear_sr = SSSR_ROR; | 1149 | drv_data->clear_sr = SSSR_ROR; |
1196 | drv_data->mask_sr = SSSR_RFS | SSSR_TFS | SSSR_ROR; | 1150 | drv_data->mask_sr = SSSR_RFS | SSSR_TFS | SSSR_ROR; |
1197 | } else { | 1151 | } else { |
1152 | master->bits_per_word_mask = SPI_BPW_RANGE_MASK(4, 32); | ||
1198 | drv_data->int_cr1 = SSCR1_TIE | SSCR1_RIE | SSCR1_TINTE; | 1153 | drv_data->int_cr1 = SSCR1_TIE | SSCR1_RIE | SSCR1_TINTE; |
1199 | drv_data->dma_cr1 = DEFAULT_DMA_CR1; | 1154 | drv_data->dma_cr1 = DEFAULT_DMA_CR1; |
1200 | drv_data->clear_sr = SSSR_ROR | SSSR_TINT; | 1155 | drv_data->clear_sr = SSSR_ROR | SSSR_TINT; |
@@ -1214,7 +1169,7 @@ static int pxa2xx_spi_probe(struct platform_device *pdev) | |||
1214 | if (platform_info->enable_dma) { | 1169 | if (platform_info->enable_dma) { |
1215 | status = pxa2xx_spi_dma_setup(drv_data); | 1170 | status = pxa2xx_spi_dma_setup(drv_data); |
1216 | if (status) { | 1171 | if (status) { |
1217 | dev_warn(dev, "failed to setup DMA, using PIO\n"); | 1172 | dev_dbg(dev, "no DMA channels available, using PIO\n"); |
1218 | platform_info->enable_dma = false; | 1173 | platform_info->enable_dma = false; |
1219 | } | 1174 | } |
1220 | } | 1175 | } |
@@ -1299,9 +1254,6 @@ static int pxa2xx_spi_remove(struct platform_device *pdev) | |||
1299 | /* Disconnect from the SPI framework */ | 1254 | /* Disconnect from the SPI framework */ |
1300 | spi_unregister_master(drv_data->master); | 1255 | spi_unregister_master(drv_data->master); |
1301 | 1256 | ||
1302 | /* Prevent double remove */ | ||
1303 | platform_set_drvdata(pdev, NULL); | ||
1304 | |||
1305 | return 0; | 1257 | return 0; |
1306 | } | 1258 | } |
1307 | 1259 | ||