aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/spi/spi-s3c64xx.c
diff options
context:
space:
mode:
authorPadmavathi Venna <padma.v@samsung.com>2013-01-18 06:47:03 -0500
committerMark Brown <broonie@opensource.wolfsonmicro.com>2013-01-29 01:28:52 -0500
commitb5be04d35dbb2e00ab27a97bfd26e17019e857ef (patch)
tree967d77cab993164bdd77f072c945844aca72a433 /drivers/spi/spi-s3c64xx.c
parente7ba5f1d0f6292e1b99c63cc4bb74c70232e9065 (diff)
spi: s3c64xx: Modify SPI driver to use generic DMA DT support
This patch modifies the SPI driver to use generic dma dt bindings support. This passes all the required arguments to dma dev request functon which in turn calls the dma_request_slave_channel or dma__ request_channel based on DT or non-DT respectively. Signed-off-by: Padmavathi Venna <padma.v@samsung.com> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Diffstat (limited to 'drivers/spi/spi-s3c64xx.c')
-rw-r--r--drivers/spi/spi-s3c64xx.c77
1 files changed, 23 insertions, 54 deletions
diff --git a/drivers/spi/spi-s3c64xx.c b/drivers/spi/spi-s3c64xx.c
index ad93231a8038..51a8c4216ebb 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,
319static int acquire_dma(struct s3c64xx_spi_driver_data *sdd) 318static 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}
@@ -1054,49 +1052,6 @@ static void s3c64xx_spi_hwinit(struct s3c64xx_spi_driver_data *sdd, int channel)
1054 flush_fifo(sdd); 1052 flush_fifo(sdd);
1055} 1053}
1056 1054
1057static int s3c64xx_spi_get_dmares(
1058 struct s3c64xx_spi_driver_data *sdd, bool tx)
1059{
1060 struct platform_device *pdev = sdd->pdev;
1061 struct s3c64xx_spi_dma_data *dma_data;
1062 struct property *prop;
1063 struct resource *res;
1064 char prop_name[15], *chan_str;
1065
1066 if (tx) {
1067 dma_data = &sdd->tx_dma;
1068 dma_data->direction = DMA_MEM_TO_DEV;
1069 chan_str = "tx";
1070 } else {
1071 dma_data = &sdd->rx_dma;
1072 dma_data->direction = DMA_DEV_TO_MEM;
1073 chan_str = "rx";
1074 }
1075
1076 if (!sdd->pdev->dev.of_node) {
1077 res = platform_get_resource(pdev, IORESOURCE_DMA, tx ? 0 : 1);
1078 if (!res) {
1079 dev_err(&pdev->dev, "Unable to get SPI-%s dma "
1080 "resource\n", chan_str);
1081 return -ENXIO;
1082 }
1083 dma_data->dmach = res->start;
1084 return 0;
1085 }
1086
1087 sprintf(prop_name, "%s-dma-channel", chan_str);
1088 prop = of_find_property(pdev->dev.of_node, prop_name, NULL);
1089 if (!prop) {
1090 dev_err(&pdev->dev, "%s dma channel property not specified\n",
1091 chan_str);
1092 return -ENXIO;
1093 }
1094
1095 dma_data->dmach = DMACH_DT_PROP;
1096 dma_data->dma_prop = prop;
1097 return 0;
1098}
1099
1100#ifdef CONFIG_OF 1055#ifdef CONFIG_OF
1101static int s3c64xx_spi_parse_dt_gpio(struct s3c64xx_spi_driver_data *sdd) 1056static int s3c64xx_spi_parse_dt_gpio(struct s3c64xx_spi_driver_data *sdd)
1102{ 1057{
@@ -1198,6 +1153,7 @@ static inline struct s3c64xx_spi_port_config *s3c64xx_spi_get_port_config(
1198static int __init s3c64xx_spi_probe(struct platform_device *pdev) 1153static int __init s3c64xx_spi_probe(struct platform_device *pdev)
1199{ 1154{
1200 struct resource *mem_res; 1155 struct resource *mem_res;
1156 struct resource *res;
1201 struct s3c64xx_spi_driver_data *sdd; 1157 struct s3c64xx_spi_driver_data *sdd;
1202 struct s3c64xx_spi_info *sci = pdev->dev.platform_data; 1158 struct s3c64xx_spi_info *sci = pdev->dev.platform_data;
1203 struct spi_master *master; 1159 struct spi_master *master;
@@ -1256,13 +1212,26 @@ static int __init s3c64xx_spi_probe(struct platform_device *pdev)
1256 1212
1257 sdd->cur_bpw = 8; 1213 sdd->cur_bpw = 8;
1258 1214
1259 ret = s3c64xx_spi_get_dmares(sdd, true); 1215 if (!sdd->pdev->dev.of_node) {
1260 if (ret) 1216 res = platform_get_resource(pdev, IORESOURCE_DMA, 0);
1261 goto err0; 1217 if (!res) {
1218 dev_err(&pdev->dev, "Unable to get SPI tx dma "
1219 "resource\n");
1220 return -ENXIO;
1221 }
1222 sdd->tx_dma.dmach = res->start;
1223
1224 res = platform_get_resource(pdev, IORESOURCE_DMA, 1);
1225 if (!res) {
1226 dev_err(&pdev->dev, "Unable to get SPI rx dma "
1227 "resource\n");
1228 return -ENXIO;
1229 }
1230 sdd->rx_dma.dmach = res->start;
1231 }
1262 1232
1263 ret = s3c64xx_spi_get_dmares(sdd, false); 1233 sdd->tx_dma.direction = DMA_MEM_TO_DEV;
1264 if (ret) 1234 sdd->rx_dma.direction = DMA_DEV_TO_MEM;
1265 goto err0;
1266 1235
1267 master->dev.of_node = pdev->dev.of_node; 1236 master->dev.of_node = pdev->dev.of_node;
1268 master->bus_num = sdd->port_id; 1237 master->bus_num = sdd->port_id;