diff options
| -rw-r--r-- | Documentation/devicetree/bindings/spi/spi-samsung.txt | 8 | ||||
| -rw-r--r-- | drivers/spi/spi-s3c64xx.c | 66 |
2 files changed, 6 insertions, 68 deletions
diff --git a/Documentation/devicetree/bindings/spi/spi-samsung.txt b/Documentation/devicetree/bindings/spi/spi-samsung.txt index a15ffeddfba4..86aa061f069f 100644 --- a/Documentation/devicetree/bindings/spi/spi-samsung.txt +++ b/Documentation/devicetree/bindings/spi/spi-samsung.txt | |||
| @@ -31,9 +31,6 @@ Required Board Specific Properties: | |||
| 31 | 31 | ||
| 32 | - #address-cells: should be 1. | 32 | - #address-cells: should be 1. |
| 33 | - #size-cells: should be 0. | 33 | - #size-cells: should be 0. |
| 34 | - gpios: The gpio specifier for clock, mosi and miso interface lines (in the | ||
| 35 | order specified). The format of the gpio specifier depends on the gpio | ||
| 36 | controller. | ||
| 37 | 34 | ||
| 38 | Optional Board Specific Properties: | 35 | Optional Board Specific Properties: |
| 39 | 36 | ||
| @@ -86,9 +83,8 @@ Example: | |||
| 86 | spi_0: spi@12d20000 { | 83 | spi_0: spi@12d20000 { |
| 87 | #address-cells = <1>; | 84 | #address-cells = <1>; |
| 88 | #size-cells = <0>; | 85 | #size-cells = <0>; |
| 89 | gpios = <&gpa2 4 2 3 0>, | 86 | pinctrl-names = "default"; |
| 90 | <&gpa2 6 2 3 0>, | 87 | pinctrl-0 = <&spi0_bus>; |
| 91 | <&gpa2 7 2 3 0>; | ||
| 92 | 88 | ||
| 93 | w25q80bw@0 { | 89 | w25q80bw@0 { |
| 94 | #address-cells = <1>; | 90 | #address-cells = <1>; |
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 |
| 1151 | static 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 | |||
| 1173 | free_gpio: | ||
| 1174 | while (--idx >= 0) | ||
| 1175 | gpio_free(sdd->gpios[idx]); | ||
| 1176 | return -EINVAL; | ||
| 1177 | } | ||
| 1178 | |||
| 1179 | static 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 | |||
| 1186 | static struct s3c64xx_spi_info *s3c64xx_spi_parse_dt(struct device *dev) | 1151 | static 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 | |||
| 1219 | static int s3c64xx_spi_parse_dt_gpio(struct s3c64xx_spi_driver_data *sdd) | ||
| 1220 | { | ||
| 1221 | return -EINVAL; | ||
| 1222 | } | ||
| 1223 | |||
| 1224 | static void s3c64xx_spi_dt_gpio_free(struct s3c64xx_spi_driver_data *sdd) | ||
| 1225 | { | ||
| 1226 | } | ||
| 1227 | #endif | 1183 | #endif |
| 1228 | 1184 | ||
| 1229 | static const struct of_device_id s3c64xx_spi_dt_match[]; | 1185 | static 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); |
| 1422 | err2: | 1375 | err2: |
| 1423 | clk_disable_unprepare(sdd->clk); | 1376 | clk_disable_unprepare(sdd->clk); |
| 1424 | err1: | ||
| 1425 | if (!sdd->cntrlr_info->cfg_gpio && pdev->dev.of_node) | ||
| 1426 | s3c64xx_spi_dt_gpio_free(sdd); | ||
| 1427 | err0: | 1377 | err0: |
| 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 */ |
