diff options
Diffstat (limited to 'drivers/spi/spi-s3c64xx.c')
-rw-r--r-- | drivers/spi/spi-s3c64xx.c | 77 |
1 files changed, 23 insertions, 54 deletions
diff --git a/drivers/spi/spi-s3c64xx.c b/drivers/spi/spi-s3c64xx.c index 8f492ed317cc..7cfbe9d3381f 100644 --- a/drivers/spi/spi-s3c64xx.c +++ b/drivers/spi/spi-s3c64xx.c | |||
@@ -134,7 +134,6 @@ struct s3c64xx_spi_dma_data { | |||
134 | unsigned ch; | 134 | unsigned ch; |
135 | enum dma_transfer_direction direction; | 135 | enum dma_transfer_direction direction; |
136 | enum dma_ch dmach; | 136 | enum dma_ch dmach; |
137 | struct property *dma_prop; | ||
138 | }; | 137 | }; |
139 | 138 | ||
140 | /** | 139 | /** |
@@ -319,16 +318,15 @@ static void prepare_dma(struct s3c64xx_spi_dma_data *dma, | |||
319 | static int acquire_dma(struct s3c64xx_spi_driver_data *sdd) | 318 | static int acquire_dma(struct s3c64xx_spi_driver_data *sdd) |
320 | { | 319 | { |
321 | struct samsung_dma_req req; | 320 | struct samsung_dma_req req; |
321 | struct device *dev = &sdd->pdev->dev; | ||
322 | 322 | ||
323 | sdd->ops = samsung_dma_get_ops(); | 323 | sdd->ops = samsung_dma_get_ops(); |
324 | 324 | ||
325 | req.cap = DMA_SLAVE; | 325 | req.cap = DMA_SLAVE; |
326 | req.client = &s3c64xx_spi_dma_client; | 326 | req.client = &s3c64xx_spi_dma_client; |
327 | 327 | ||
328 | req.dt_dmach_prop = sdd->rx_dma.dma_prop; | 328 | sdd->rx_dma.ch = sdd->ops->request(sdd->rx_dma.dmach, &req, dev, "rx"); |
329 | sdd->rx_dma.ch = sdd->ops->request(sdd->rx_dma.dmach, &req); | 329 | sdd->tx_dma.ch = sdd->ops->request(sdd->tx_dma.dmach, &req, dev, "tx"); |
330 | req.dt_dmach_prop = sdd->tx_dma.dma_prop; | ||
331 | sdd->tx_dma.ch = sdd->ops->request(sdd->tx_dma.dmach, &req); | ||
332 | 330 | ||
333 | return 1; | 331 | return 1; |
334 | } | 332 | } |
@@ -1053,49 +1051,6 @@ static void s3c64xx_spi_hwinit(struct s3c64xx_spi_driver_data *sdd, int channel) | |||
1053 | flush_fifo(sdd); | 1051 | flush_fifo(sdd); |
1054 | } | 1052 | } |
1055 | 1053 | ||
1056 | static int s3c64xx_spi_get_dmares( | ||
1057 | struct s3c64xx_spi_driver_data *sdd, bool tx) | ||
1058 | { | ||
1059 | struct platform_device *pdev = sdd->pdev; | ||
1060 | struct s3c64xx_spi_dma_data *dma_data; | ||
1061 | struct property *prop; | ||
1062 | struct resource *res; | ||
1063 | char prop_name[15], *chan_str; | ||
1064 | |||
1065 | if (tx) { | ||
1066 | dma_data = &sdd->tx_dma; | ||
1067 | dma_data->direction = DMA_MEM_TO_DEV; | ||
1068 | chan_str = "tx"; | ||
1069 | } else { | ||
1070 | dma_data = &sdd->rx_dma; | ||
1071 | dma_data->direction = DMA_DEV_TO_MEM; | ||
1072 | chan_str = "rx"; | ||
1073 | } | ||
1074 | |||
1075 | if (!sdd->pdev->dev.of_node) { | ||
1076 | res = platform_get_resource(pdev, IORESOURCE_DMA, tx ? 0 : 1); | ||
1077 | if (!res) { | ||
1078 | dev_err(&pdev->dev, "Unable to get SPI-%s dma resource\n", | ||
1079 | chan_str); | ||
1080 | return -ENXIO; | ||
1081 | } | ||
1082 | dma_data->dmach = res->start; | ||
1083 | return 0; | ||
1084 | } | ||
1085 | |||
1086 | sprintf(prop_name, "%s-dma-channel", chan_str); | ||
1087 | prop = of_find_property(pdev->dev.of_node, prop_name, NULL); | ||
1088 | if (!prop) { | ||
1089 | dev_err(&pdev->dev, "%s dma channel property not specified\n", | ||
1090 | chan_str); | ||
1091 | return -ENXIO; | ||
1092 | } | ||
1093 | |||
1094 | dma_data->dmach = DMACH_DT_PROP; | ||
1095 | dma_data->dma_prop = prop; | ||
1096 | return 0; | ||
1097 | } | ||
1098 | |||
1099 | #ifdef CONFIG_OF | 1054 | #ifdef CONFIG_OF |
1100 | static int s3c64xx_spi_parse_dt_gpio(struct s3c64xx_spi_driver_data *sdd) | 1055 | static int s3c64xx_spi_parse_dt_gpio(struct s3c64xx_spi_driver_data *sdd) |
1101 | { | 1056 | { |
@@ -1194,6 +1149,7 @@ static inline struct s3c64xx_spi_port_config *s3c64xx_spi_get_port_config( | |||
1194 | static int s3c64xx_spi_probe(struct platform_device *pdev) | 1149 | static int s3c64xx_spi_probe(struct platform_device *pdev) |
1195 | { | 1150 | { |
1196 | struct resource *mem_res; | 1151 | struct resource *mem_res; |
1152 | struct resource *res; | ||
1197 | struct s3c64xx_spi_driver_data *sdd; | 1153 | struct s3c64xx_spi_driver_data *sdd; |
1198 | struct s3c64xx_spi_info *sci = pdev->dev.platform_data; | 1154 | struct s3c64xx_spi_info *sci = pdev->dev.platform_data; |
1199 | struct spi_master *master; | 1155 | struct spi_master *master; |
@@ -1252,13 +1208,26 @@ static int s3c64xx_spi_probe(struct platform_device *pdev) | |||
1252 | 1208 | ||
1253 | sdd->cur_bpw = 8; | 1209 | sdd->cur_bpw = 8; |
1254 | 1210 | ||
1255 | ret = s3c64xx_spi_get_dmares(sdd, true); | 1211 | if (!sdd->pdev->dev.of_node) { |
1256 | if (ret) | 1212 | res = platform_get_resource(pdev, IORESOURCE_DMA, 0); |
1257 | goto err0; | 1213 | if (!res) { |
1214 | dev_err(&pdev->dev, "Unable to get SPI tx dma " | ||
1215 | "resource\n"); | ||
1216 | return -ENXIO; | ||
1217 | } | ||
1218 | sdd->tx_dma.dmach = res->start; | ||
1258 | 1219 | ||
1259 | ret = s3c64xx_spi_get_dmares(sdd, false); | 1220 | res = platform_get_resource(pdev, IORESOURCE_DMA, 1); |
1260 | if (ret) | 1221 | if (!res) { |
1261 | goto err0; | 1222 | dev_err(&pdev->dev, "Unable to get SPI rx dma " |
1223 | "resource\n"); | ||
1224 | return -ENXIO; | ||
1225 | } | ||
1226 | sdd->rx_dma.dmach = res->start; | ||
1227 | } | ||
1228 | |||
1229 | sdd->tx_dma.direction = DMA_MEM_TO_DEV; | ||
1230 | sdd->rx_dma.direction = DMA_DEV_TO_MEM; | ||
1262 | 1231 | ||
1263 | master->dev.of_node = pdev->dev.of_node; | 1232 | master->dev.of_node = pdev->dev.of_node; |
1264 | master->bus_num = sdd->port_id; | 1233 | master->bus_num = sdd->port_id; |