aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/spi/spi-s3c64xx.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/spi/spi-s3c64xx.c')
-rw-r--r--drivers/spi/spi-s3c64xx.c66
1 files changed, 4 insertions, 62 deletions
diff --git a/drivers/spi/spi-s3c64xx.c b/drivers/spi/spi-s3c64xx.c
index 4989aeb793fd..4ab992bfea83 100644
--- a/drivers/spi/spi-s3c64xx.c
+++ b/drivers/spi/spi-s3c64xx.c
@@ -1148,41 +1148,6 @@ static void s3c64xx_spi_hwinit(struct s3c64xx_spi_driver_data *sdd, int channel)
1148} 1148}
1149 1149
1150#ifdef CONFIG_OF 1150#ifdef CONFIG_OF
1151static int s3c64xx_spi_parse_dt_gpio(struct s3c64xx_spi_driver_data *sdd)
1152{
1153 struct device *dev = &sdd->pdev->dev;
1154 int idx, gpio, ret;
1155
1156 /* find gpios for mosi, miso and clock lines */
1157 for (idx = 0; idx < 3; idx++) {
1158 gpio = of_get_gpio(dev->of_node, idx);
1159 if (!gpio_is_valid(gpio)) {
1160 dev_err(dev, "invalid gpio[%d]: %d\n", idx, gpio);
1161 goto free_gpio;
1162 }
1163 sdd->gpios[idx] = gpio;
1164 ret = gpio_request(gpio, "spi-bus");
1165 if (ret) {
1166 dev_err(dev, "gpio [%d] request failed: %d\n",
1167 gpio, ret);
1168 goto free_gpio;
1169 }
1170 }
1171 return 0;
1172
1173free_gpio:
1174 while (--idx >= 0)
1175 gpio_free(sdd->gpios[idx]);
1176 return -EINVAL;
1177}
1178
1179static void s3c64xx_spi_dt_gpio_free(struct s3c64xx_spi_driver_data *sdd)
1180{
1181 unsigned int idx;
1182 for (idx = 0; idx < 3; idx++)
1183 gpio_free(sdd->gpios[idx]);
1184}
1185
1186static struct s3c64xx_spi_info *s3c64xx_spi_parse_dt(struct device *dev) 1151static struct s3c64xx_spi_info *s3c64xx_spi_parse_dt(struct device *dev)
1187{ 1152{
1188 struct s3c64xx_spi_info *sci; 1153 struct s3c64xx_spi_info *sci;
@@ -1215,15 +1180,6 @@ static struct s3c64xx_spi_info *s3c64xx_spi_parse_dt(struct device *dev)
1215{ 1180{
1216 return dev->platform_data; 1181 return dev->platform_data;
1217} 1182}
1218
1219static int s3c64xx_spi_parse_dt_gpio(struct s3c64xx_spi_driver_data *sdd)
1220{
1221 return -EINVAL;
1222}
1223
1224static void s3c64xx_spi_dt_gpio_free(struct s3c64xx_spi_driver_data *sdd)
1225{
1226}
1227#endif 1183#endif
1228 1184
1229static const struct of_device_id s3c64xx_spi_dt_match[]; 1185static const struct of_device_id s3c64xx_spi_dt_match[];
@@ -1344,10 +1300,7 @@ static int s3c64xx_spi_probe(struct platform_device *pdev)
1344 goto err0; 1300 goto err0;
1345 } 1301 }
1346 1302
1347 if (!sci->cfg_gpio && pdev->dev.of_node) { 1303 if (sci->cfg_gpio && sci->cfg_gpio()) {
1348 if (s3c64xx_spi_parse_dt_gpio(sdd))
1349 return -EBUSY;
1350 } else if (sci->cfg_gpio == NULL || sci->cfg_gpio()) {
1351 dev_err(&pdev->dev, "Unable to config gpio\n"); 1304 dev_err(&pdev->dev, "Unable to config gpio\n");
1352 ret = -EBUSY; 1305 ret = -EBUSY;
1353 goto err0; 1306 goto err0;
@@ -1358,13 +1311,13 @@ static int s3c64xx_spi_probe(struct platform_device *pdev)
1358 if (IS_ERR(sdd->clk)) { 1311 if (IS_ERR(sdd->clk)) {
1359 dev_err(&pdev->dev, "Unable to acquire clock 'spi'\n"); 1312 dev_err(&pdev->dev, "Unable to acquire clock 'spi'\n");
1360 ret = PTR_ERR(sdd->clk); 1313 ret = PTR_ERR(sdd->clk);
1361 goto err1; 1314 goto err0;
1362 } 1315 }
1363 1316
1364 if (clk_prepare_enable(sdd->clk)) { 1317 if (clk_prepare_enable(sdd->clk)) {
1365 dev_err(&pdev->dev, "Couldn't enable clock 'spi'\n"); 1318 dev_err(&pdev->dev, "Couldn't enable clock 'spi'\n");
1366 ret = -EBUSY; 1319 ret = -EBUSY;
1367 goto err1; 1320 goto err0;
1368 } 1321 }
1369 1322
1370 sprintf(clk_name, "spi_busclk%d", sci->src_clk_nr); 1323 sprintf(clk_name, "spi_busclk%d", sci->src_clk_nr);
@@ -1421,9 +1374,6 @@ err3:
1421 clk_disable_unprepare(sdd->src_clk); 1374 clk_disable_unprepare(sdd->src_clk);
1422err2: 1375err2:
1423 clk_disable_unprepare(sdd->clk); 1376 clk_disable_unprepare(sdd->clk);
1424err1:
1425 if (!sdd->cntrlr_info->cfg_gpio && pdev->dev.of_node)
1426 s3c64xx_spi_dt_gpio_free(sdd);
1427err0: 1377err0:
1428 platform_set_drvdata(pdev, NULL); 1378 platform_set_drvdata(pdev, NULL);
1429 spi_master_put(master); 1379 spi_master_put(master);
@@ -1446,9 +1396,6 @@ static int s3c64xx_spi_remove(struct platform_device *pdev)
1446 1396
1447 clk_disable_unprepare(sdd->clk); 1397 clk_disable_unprepare(sdd->clk);
1448 1398
1449 if (!sdd->cntrlr_info->cfg_gpio && pdev->dev.of_node)
1450 s3c64xx_spi_dt_gpio_free(sdd);
1451
1452 platform_set_drvdata(pdev, NULL); 1399 platform_set_drvdata(pdev, NULL);
1453 spi_master_put(master); 1400 spi_master_put(master);
1454 1401
@@ -1467,9 +1414,6 @@ static int s3c64xx_spi_suspend(struct device *dev)
1467 clk_disable_unprepare(sdd->src_clk); 1414 clk_disable_unprepare(sdd->src_clk);
1468 clk_disable_unprepare(sdd->clk); 1415 clk_disable_unprepare(sdd->clk);
1469 1416
1470 if (!sdd->cntrlr_info->cfg_gpio && dev->of_node)
1471 s3c64xx_spi_dt_gpio_free(sdd);
1472
1473 sdd->cur_speed = 0; /* Output Clock is stopped */ 1417 sdd->cur_speed = 0; /* Output Clock is stopped */
1474 1418
1475 return 0; 1419 return 0;
@@ -1481,9 +1425,7 @@ static int s3c64xx_spi_resume(struct device *dev)
1481 struct s3c64xx_spi_driver_data *sdd = spi_master_get_devdata(master); 1425 struct s3c64xx_spi_driver_data *sdd = spi_master_get_devdata(master);
1482 struct s3c64xx_spi_info *sci = sdd->cntrlr_info; 1426 struct s3c64xx_spi_info *sci = sdd->cntrlr_info;
1483 1427
1484 if (!sci->cfg_gpio && dev->of_node) 1428 if (sci->cfg_gpio)
1485 s3c64xx_spi_parse_dt_gpio(sdd);
1486 else
1487 sci->cfg_gpio(); 1429 sci->cfg_gpio();
1488 1430
1489 /* Enable the clock */ 1431 /* Enable the clock */