diff options
author | Mika Westerberg <mika.westerberg@linux.intel.com> | 2013-05-13 06:45:10 -0400 |
---|---|---|
committer | Mark Brown <broonie@opensource.wolfsonmicro.com> | 2013-05-13 09:59:00 -0400 |
commit | cddb339badb03dd96a5272195eec17e7899df154 (patch) | |
tree | d11714017ae5d73c3bb3ead41bf2a53ce735e85f | |
parent | 6dc81f6fc0eaf0714bc6e959f8769705f41fd708 (diff) |
spi/pxa2xx: convert to dma_request_slave_channel_compat()
Now that we have these nice DMA API helper functions we can take advantage
of those instead of open-coding the channel/request line extraction from
ACPI. Use the _compat version which still allows passing the
channel/request line from platform data.
Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
-rw-r--r-- | drivers/spi/spi-pxa2xx-dma.c | 11 | ||||
-rw-r--r-- | drivers/spi/spi-pxa2xx.c | 34 |
2 files changed, 8 insertions, 37 deletions
diff --git a/drivers/spi/spi-pxa2xx-dma.c b/drivers/spi/spi-pxa2xx-dma.c index c735c5a008a2..f4cb744bf23f 100644 --- a/drivers/spi/spi-pxa2xx-dma.c +++ b/drivers/spi/spi-pxa2xx-dma.c | |||
@@ -327,22 +327,23 @@ void pxa2xx_spi_dma_start(struct driver_data *drv_data) | |||
327 | int pxa2xx_spi_dma_setup(struct driver_data *drv_data) | 327 | int pxa2xx_spi_dma_setup(struct driver_data *drv_data) |
328 | { | 328 | { |
329 | struct pxa2xx_spi_master *pdata = drv_data->master_info; | 329 | struct pxa2xx_spi_master *pdata = drv_data->master_info; |
330 | struct device *dev = &drv_data->pdev->dev; | ||
330 | dma_cap_mask_t mask; | 331 | dma_cap_mask_t mask; |
331 | 332 | ||
332 | dma_cap_zero(mask); | 333 | dma_cap_zero(mask); |
333 | dma_cap_set(DMA_SLAVE, mask); | 334 | dma_cap_set(DMA_SLAVE, mask); |
334 | 335 | ||
335 | drv_data->dummy = devm_kzalloc(&drv_data->pdev->dev, SZ_2K, GFP_KERNEL); | 336 | drv_data->dummy = devm_kzalloc(dev, SZ_2K, GFP_KERNEL); |
336 | if (!drv_data->dummy) | 337 | if (!drv_data->dummy) |
337 | return -ENOMEM; | 338 | return -ENOMEM; |
338 | 339 | ||
339 | drv_data->tx_chan = dma_request_channel(mask, pxa2xx_spi_dma_filter, | 340 | drv_data->tx_chan = dma_request_slave_channel_compat(mask, |
340 | pdata); | 341 | pxa2xx_spi_dma_filter, pdata, dev, "tx"); |
341 | if (!drv_data->tx_chan) | 342 | if (!drv_data->tx_chan) |
342 | return -ENODEV; | 343 | return -ENODEV; |
343 | 344 | ||
344 | drv_data->rx_chan = dma_request_channel(mask, pxa2xx_spi_dma_filter, | 345 | drv_data->rx_chan = dma_request_slave_channel_compat(mask, |
345 | pdata); | 346 | pxa2xx_spi_dma_filter, pdata, dev, "rx"); |
346 | if (!drv_data->rx_chan) { | 347 | if (!drv_data->rx_chan) { |
347 | dma_release_channel(drv_data->tx_chan); | 348 | dma_release_channel(drv_data->tx_chan); |
348 | drv_data->tx_chan = NULL; | 349 | drv_data->tx_chan = NULL; |
diff --git a/drivers/spi/spi-pxa2xx.c b/drivers/spi/spi-pxa2xx.c index e5d782332ca5..d20b31ae96d3 100644 --- a/drivers/spi/spi-pxa2xx.c +++ b/drivers/spi/spi-pxa2xx.c | |||
@@ -1040,32 +1040,10 @@ static void cleanup(struct spi_device *spi) | |||
1040 | } | 1040 | } |
1041 | 1041 | ||
1042 | #ifdef CONFIG_ACPI | 1042 | #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 * | 1043 | static struct pxa2xx_spi_master * |
1065 | pxa2xx_spi_acpi_get_pdata(struct platform_device *pdev) | 1044 | pxa2xx_spi_acpi_get_pdata(struct platform_device *pdev) |
1066 | { | 1045 | { |
1067 | struct pxa2xx_spi_master *pdata; | 1046 | struct pxa2xx_spi_master *pdata; |
1068 | struct list_head resource_list; | ||
1069 | struct acpi_device *adev; | 1047 | struct acpi_device *adev; |
1070 | struct ssp_device *ssp; | 1048 | struct ssp_device *ssp; |
1071 | struct resource *res; | 1049 | struct resource *res; |
@@ -1103,15 +1081,7 @@ pxa2xx_spi_acpi_get_pdata(struct platform_device *pdev) | |||
1103 | ssp->port_id = devid; | 1081 | ssp->port_id = devid; |
1104 | 1082 | ||
1105 | pdata->num_chipselect = 1; | 1083 | pdata->num_chipselect = 1; |
1106 | pdata->rx_slave_id = -1; | 1084 | 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 | 1085 | ||
1116 | return pdata; | 1086 | return pdata; |
1117 | } | 1087 | } |
@@ -1214,7 +1184,7 @@ static int pxa2xx_spi_probe(struct platform_device *pdev) | |||
1214 | if (platform_info->enable_dma) { | 1184 | if (platform_info->enable_dma) { |
1215 | status = pxa2xx_spi_dma_setup(drv_data); | 1185 | status = pxa2xx_spi_dma_setup(drv_data); |
1216 | if (status) { | 1186 | if (status) { |
1217 | dev_warn(dev, "failed to setup DMA, using PIO\n"); | 1187 | dev_dbg(dev, "no DMA channels available, using PIO\n"); |
1218 | platform_info->enable_dma = false; | 1188 | platform_info->enable_dma = false; |
1219 | } | 1189 | } |
1220 | } | 1190 | } |