diff options
author | Lubomir Rintel <lkundrak@v3.sk> | 2018-10-10 13:09:29 -0400 |
---|---|---|
committer | Mark Brown <broonie@kernel.org> | 2018-10-11 10:28:04 -0400 |
commit | 87ae1d2d70772d661162de03e56c8d1cc5f12650 (patch) | |
tree | bd6c3e470eea67a8523d1eb783263d53266047d7 /drivers/spi/spi-pxa2xx.c | |
parent | 55ef8262f2b1b31762b045b14182db3cc8f607d1 (diff) |
spi: pxa2xx: Add devicetree support
The MMP2 platform, that uses device tree, has this controller. Let's add
devicetree alongside platform & PCI.
Signed-off-by: Lubomir Rintel <lkundrak@v3.sk>
Signed-off-by: Mark Brown <broonie@kernel.org>
Diffstat (limited to 'drivers/spi/spi-pxa2xx.c')
-rw-r--r-- | drivers/spi/spi-pxa2xx.c | 73 |
1 files changed, 44 insertions, 29 deletions
diff --git a/drivers/spi/spi-pxa2xx.c b/drivers/spi/spi-pxa2xx.c index 8baa5b038f15..612cc49db28f 100644 --- a/drivers/spi/spi-pxa2xx.c +++ b/drivers/spi/spi-pxa2xx.c | |||
@@ -33,6 +33,7 @@ | |||
33 | #include <linux/clk.h> | 33 | #include <linux/clk.h> |
34 | #include <linux/pm_runtime.h> | 34 | #include <linux/pm_runtime.h> |
35 | #include <linux/acpi.h> | 35 | #include <linux/acpi.h> |
36 | #include <linux/of_device.h> | ||
36 | 37 | ||
37 | #include "spi-pxa2xx.h" | 38 | #include "spi-pxa2xx.h" |
38 | 39 | ||
@@ -1335,9 +1336,6 @@ static void cleanup(struct spi_device *spi) | |||
1335 | kfree(chip); | 1336 | kfree(chip); |
1336 | } | 1337 | } |
1337 | 1338 | ||
1338 | #ifdef CONFIG_PCI | ||
1339 | #ifdef CONFIG_ACPI | ||
1340 | |||
1341 | static const struct acpi_device_id pxa2xx_spi_acpi_match[] = { | 1339 | static const struct acpi_device_id pxa2xx_spi_acpi_match[] = { |
1342 | { "INT33C0", LPSS_LPT_SSP }, | 1340 | { "INT33C0", LPSS_LPT_SSP }, |
1343 | { "INT33C1", LPSS_LPT_SSP }, | 1341 | { "INT33C1", LPSS_LPT_SSP }, |
@@ -1349,23 +1347,6 @@ static const struct acpi_device_id pxa2xx_spi_acpi_match[] = { | |||
1349 | }; | 1347 | }; |
1350 | MODULE_DEVICE_TABLE(acpi, pxa2xx_spi_acpi_match); | 1348 | MODULE_DEVICE_TABLE(acpi, pxa2xx_spi_acpi_match); |
1351 | 1349 | ||
1352 | static int pxa2xx_spi_get_port_id(struct acpi_device *adev) | ||
1353 | { | ||
1354 | unsigned int devid; | ||
1355 | int port_id = -1; | ||
1356 | |||
1357 | if (adev && adev->pnp.unique_id && | ||
1358 | !kstrtouint(adev->pnp.unique_id, 0, &devid)) | ||
1359 | port_id = devid; | ||
1360 | return port_id; | ||
1361 | } | ||
1362 | #else /* !CONFIG_ACPI */ | ||
1363 | static int pxa2xx_spi_get_port_id(struct acpi_device *adev) | ||
1364 | { | ||
1365 | return -1; | ||
1366 | } | ||
1367 | #endif | ||
1368 | |||
1369 | /* | 1350 | /* |
1370 | * PCI IDs of compound devices that integrate both host controller and private | 1351 | * PCI IDs of compound devices that integrate both host controller and private |
1371 | * integrated DMA engine. Please note these are not used in module | 1352 | * integrated DMA engine. Please note these are not used in module |
@@ -1412,6 +1393,37 @@ static const struct pci_device_id pxa2xx_spi_pci_compound_match[] = { | |||
1412 | { }, | 1393 | { }, |
1413 | }; | 1394 | }; |
1414 | 1395 | ||
1396 | static const struct of_device_id pxa2xx_spi_of_match[] = { | ||
1397 | { .compatible = "marvell,mmp2-ssp", .data = (void *)MMP2_SSP }, | ||
1398 | {}, | ||
1399 | }; | ||
1400 | MODULE_DEVICE_TABLE(of, pxa2xx_spi_of_match); | ||
1401 | |||
1402 | #ifdef CONFIG_ACPI | ||
1403 | |||
1404 | static int pxa2xx_spi_get_port_id(struct acpi_device *adev) | ||
1405 | { | ||
1406 | unsigned int devid; | ||
1407 | int port_id = -1; | ||
1408 | |||
1409 | if (adev && adev->pnp.unique_id && | ||
1410 | !kstrtouint(adev->pnp.unique_id, 0, &devid)) | ||
1411 | port_id = devid; | ||
1412 | return port_id; | ||
1413 | } | ||
1414 | |||
1415 | #else /* !CONFIG_ACPI */ | ||
1416 | |||
1417 | static int pxa2xx_spi_get_port_id(struct acpi_device *adev) | ||
1418 | { | ||
1419 | return -1; | ||
1420 | } | ||
1421 | |||
1422 | #endif /* CONFIG_ACPI */ | ||
1423 | |||
1424 | |||
1425 | #ifdef CONFIG_PCI | ||
1426 | |||
1415 | static bool pxa2xx_spi_idma_filter(struct dma_chan *chan, void *param) | 1427 | static bool pxa2xx_spi_idma_filter(struct dma_chan *chan, void *param) |
1416 | { | 1428 | { |
1417 | struct device *dev = param; | 1429 | struct device *dev = param; |
@@ -1422,6 +1434,8 @@ static bool pxa2xx_spi_idma_filter(struct dma_chan *chan, void *param) | |||
1422 | return true; | 1434 | return true; |
1423 | } | 1435 | } |
1424 | 1436 | ||
1437 | #endif /* CONFIG_PCI */ | ||
1438 | |||
1425 | static struct pxa2xx_spi_master * | 1439 | static struct pxa2xx_spi_master * |
1426 | pxa2xx_spi_init_pdata(struct platform_device *pdev) | 1440 | pxa2xx_spi_init_pdata(struct platform_device *pdev) |
1427 | { | 1441 | { |
@@ -1431,11 +1445,15 @@ pxa2xx_spi_init_pdata(struct platform_device *pdev) | |||
1431 | struct resource *res; | 1445 | struct resource *res; |
1432 | const struct acpi_device_id *adev_id = NULL; | 1446 | const struct acpi_device_id *adev_id = NULL; |
1433 | const struct pci_device_id *pcidev_id = NULL; | 1447 | const struct pci_device_id *pcidev_id = NULL; |
1448 | const struct of_device_id *of_id = NULL; | ||
1434 | enum pxa_ssp_type type; | 1449 | enum pxa_ssp_type type; |
1435 | 1450 | ||
1436 | adev = ACPI_COMPANION(&pdev->dev); | 1451 | adev = ACPI_COMPANION(&pdev->dev); |
1437 | 1452 | ||
1438 | if (dev_is_pci(pdev->dev.parent)) | 1453 | if (pdev->dev.of_node) |
1454 | of_id = of_match_device(pdev->dev.driver->of_match_table, | ||
1455 | &pdev->dev); | ||
1456 | else if (dev_is_pci(pdev->dev.parent)) | ||
1439 | pcidev_id = pci_match_id(pxa2xx_spi_pci_compound_match, | 1457 | pcidev_id = pci_match_id(pxa2xx_spi_pci_compound_match, |
1440 | to_pci_dev(pdev->dev.parent)); | 1458 | to_pci_dev(pdev->dev.parent)); |
1441 | else if (adev) | 1459 | else if (adev) |
@@ -1448,6 +1466,8 @@ pxa2xx_spi_init_pdata(struct platform_device *pdev) | |||
1448 | type = (enum pxa_ssp_type)adev_id->driver_data; | 1466 | type = (enum pxa_ssp_type)adev_id->driver_data; |
1449 | else if (pcidev_id) | 1467 | else if (pcidev_id) |
1450 | type = (enum pxa_ssp_type)pcidev_id->driver_data; | 1468 | type = (enum pxa_ssp_type)pcidev_id->driver_data; |
1469 | else if (of_id) | ||
1470 | type = (enum pxa_ssp_type)of_id->data; | ||
1451 | else | 1471 | else |
1452 | return NULL; | 1472 | return NULL; |
1453 | 1473 | ||
@@ -1466,11 +1486,13 @@ pxa2xx_spi_init_pdata(struct platform_device *pdev) | |||
1466 | if (IS_ERR(ssp->mmio_base)) | 1486 | if (IS_ERR(ssp->mmio_base)) |
1467 | return NULL; | 1487 | return NULL; |
1468 | 1488 | ||
1489 | #ifdef CONFIG_PCI | ||
1469 | if (pcidev_id) { | 1490 | if (pcidev_id) { |
1470 | pdata->tx_param = pdev->dev.parent; | 1491 | pdata->tx_param = pdev->dev.parent; |
1471 | pdata->rx_param = pdev->dev.parent; | 1492 | pdata->rx_param = pdev->dev.parent; |
1472 | pdata->dma_filter = pxa2xx_spi_idma_filter; | 1493 | pdata->dma_filter = pxa2xx_spi_idma_filter; |
1473 | } | 1494 | } |
1495 | #endif | ||
1474 | 1496 | ||
1475 | ssp->clk = devm_clk_get(&pdev->dev, NULL); | 1497 | ssp->clk = devm_clk_get(&pdev->dev, NULL); |
1476 | ssp->irq = platform_get_irq(pdev, 0); | 1498 | ssp->irq = platform_get_irq(pdev, 0); |
@@ -1484,14 +1506,6 @@ pxa2xx_spi_init_pdata(struct platform_device *pdev) | |||
1484 | return pdata; | 1506 | return pdata; |
1485 | } | 1507 | } |
1486 | 1508 | ||
1487 | #else /* !CONFIG_PCI */ | ||
1488 | static inline struct pxa2xx_spi_master * | ||
1489 | pxa2xx_spi_init_pdata(struct platform_device *pdev) | ||
1490 | { | ||
1491 | return NULL; | ||
1492 | } | ||
1493 | #endif | ||
1494 | |||
1495 | static int pxa2xx_spi_fw_translate_cs(struct spi_controller *master, | 1509 | static int pxa2xx_spi_fw_translate_cs(struct spi_controller *master, |
1496 | unsigned int cs) | 1510 | unsigned int cs) |
1497 | { | 1511 | { |
@@ -1836,6 +1850,7 @@ static struct platform_driver driver = { | |||
1836 | .name = "pxa2xx-spi", | 1850 | .name = "pxa2xx-spi", |
1837 | .pm = &pxa2xx_spi_pm_ops, | 1851 | .pm = &pxa2xx_spi_pm_ops, |
1838 | .acpi_match_table = ACPI_PTR(pxa2xx_spi_acpi_match), | 1852 | .acpi_match_table = ACPI_PTR(pxa2xx_spi_acpi_match), |
1853 | .of_match_table = of_match_ptr(pxa2xx_spi_of_match), | ||
1839 | }, | 1854 | }, |
1840 | .probe = pxa2xx_spi_probe, | 1855 | .probe = pxa2xx_spi_probe, |
1841 | .remove = pxa2xx_spi_remove, | 1856 | .remove = pxa2xx_spi_remove, |