aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/spi/spi-pxa2xx.c
diff options
context:
space:
mode:
authorJarkko Nikula <jarkko.nikula@linux.intel.com>2015-10-28 09:13:43 -0400
committerMark Brown <broonie@kernel.org>2015-10-29 22:18:05 -0400
commit0db642151ad80967e9e1c2abf3e19bd7902ecdc9 (patch)
treec1739c82c82a973749e32a167f92c6acfa69856b /drivers/spi/spi-pxa2xx.c
parentb7c08cf85c9a3a4b05474b7acacc9fbce8fb3eaf (diff)
spi: pxa2xx: Rework self-initiated platform data creation for non-ACPI
Extend the pxa2xx_spi_acpi_get_pdata() so that it can create platform data also on platforms that do not support ACPI or if CONFIG_ACPI is not set. Now it is expected that "pxa2xx-spi" platform device is either created with explicit platform data or has an ACPI companion device. However there is only little in pxa2xx_spi_acpi_get_pdata() that is really dependent on ACPI companion and it can be reworked to cover also cases where "pxa2xx-spi" device doesn't have ACPI companion and is created without platform data. Do this by renaming the pxa2xx_spi_acpi_get_pdata(), moving it outside of CONFIG_ACPI test and changing a few runtime tests there to support non-ACPI case. Only port/bus ID setting based on ACPI _UID is dependent on ACPI and is moved to own function inside CONFIG_ACPI. Purpose of this to support non-ACPI case for those PCI enumerated compound devices that integrate both LPSS SPI host controller and integrated DMA engine under the same PCI ID and which are registered in MFD layer instead of in spi-pxa2xx-pci.c. Signed-off-by: Jarkko Nikula <jarkko.nikula@linux.intel.com> Signed-off-by: Mark Brown <broonie@kernel.org>
Diffstat (limited to 'drivers/spi/spi-pxa2xx.c')
-rw-r--r--drivers/spi/spi-pxa2xx.c38
1 files changed, 26 insertions, 12 deletions
diff --git a/drivers/spi/spi-pxa2xx.c b/drivers/spi/spi-pxa2xx.c
index f759c082f0f7..2e951084987d 100644
--- a/drivers/spi/spi-pxa2xx.c
+++ b/drivers/spi/spi-pxa2xx.c
@@ -1300,6 +1300,7 @@ static void cleanup(struct spi_device *spi)
1300 kfree(chip); 1300 kfree(chip);
1301} 1301}
1302 1302
1303#ifdef CONFIG_PCI
1303#ifdef CONFIG_ACPI 1304#ifdef CONFIG_ACPI
1304 1305
1305static const struct acpi_device_id pxa2xx_spi_acpi_match[] = { 1306static const struct acpi_device_id pxa2xx_spi_acpi_match[] = {
@@ -1313,6 +1314,23 @@ static const struct acpi_device_id pxa2xx_spi_acpi_match[] = {
1313}; 1314};
1314MODULE_DEVICE_TABLE(acpi, pxa2xx_spi_acpi_match); 1315MODULE_DEVICE_TABLE(acpi, pxa2xx_spi_acpi_match);
1315 1316
1317static int pxa2xx_spi_get_port_id(struct acpi_device *adev)
1318{
1319 unsigned int devid;
1320 int port_id = -1;
1321
1322 if (adev && adev->pnp.unique_id &&
1323 !kstrtouint(adev->pnp.unique_id, 0, &devid))
1324 port_id = devid;
1325 return port_id;
1326}
1327#else /* !CONFIG_ACPI */
1328static int pxa2xx_spi_get_port_id(struct acpi_device *adev)
1329{
1330 return -1;
1331}
1332#endif
1333
1316/* 1334/*
1317 * PCI IDs of compound devices that integrate both host controller and private 1335 * PCI IDs of compound devices that integrate both host controller and private
1318 * integrated DMA engine. Please note these are not used in module 1336 * integrated DMA engine. Please note these are not used in module
@@ -1347,7 +1365,7 @@ static bool pxa2xx_spi_idma_filter(struct dma_chan *chan, void *param)
1347} 1365}
1348 1366
1349static struct pxa2xx_spi_master * 1367static struct pxa2xx_spi_master *
1350pxa2xx_spi_acpi_get_pdata(struct platform_device *pdev) 1368pxa2xx_spi_init_pdata(struct platform_device *pdev)
1351{ 1369{
1352 struct pxa2xx_spi_master *pdata; 1370 struct pxa2xx_spi_master *pdata;
1353 struct acpi_device *adev; 1371 struct acpi_device *adev;
@@ -1355,19 +1373,18 @@ pxa2xx_spi_acpi_get_pdata(struct platform_device *pdev)
1355 struct resource *res; 1373 struct resource *res;
1356 const struct acpi_device_id *adev_id = NULL; 1374 const struct acpi_device_id *adev_id = NULL;
1357 const struct pci_device_id *pcidev_id = NULL; 1375 const struct pci_device_id *pcidev_id = NULL;
1358 unsigned int devid;
1359 int type; 1376 int type;
1360 1377
1361 adev = ACPI_COMPANION(&pdev->dev); 1378 adev = ACPI_COMPANION(&pdev->dev);
1362 if (!adev)
1363 return NULL;
1364 1379
1365 if (dev_is_pci(pdev->dev.parent)) 1380 if (dev_is_pci(pdev->dev.parent))
1366 pcidev_id = pci_match_id(pxa2xx_spi_pci_compound_match, 1381 pcidev_id = pci_match_id(pxa2xx_spi_pci_compound_match,
1367 to_pci_dev(pdev->dev.parent)); 1382 to_pci_dev(pdev->dev.parent));
1368 else 1383 else if (adev)
1369 adev_id = acpi_match_device(pdev->dev.driver->acpi_match_table, 1384 adev_id = acpi_match_device(pdev->dev.driver->acpi_match_table,
1370 &pdev->dev); 1385 &pdev->dev);
1386 else
1387 return NULL;
1371 1388
1372 if (adev_id) 1389 if (adev_id)
1373 type = (int)adev_id->driver_data; 1390 type = (int)adev_id->driver_data;
@@ -1401,10 +1418,7 @@ pxa2xx_spi_acpi_get_pdata(struct platform_device *pdev)
1401 ssp->irq = platform_get_irq(pdev, 0); 1418 ssp->irq = platform_get_irq(pdev, 0);
1402 ssp->type = type; 1419 ssp->type = type;
1403 ssp->pdev = pdev; 1420 ssp->pdev = pdev;
1404 1421 ssp->port_id = pxa2xx_spi_get_port_id(adev);
1405 ssp->port_id = -1;
1406 if (adev->pnp.unique_id && !kstrtouint(adev->pnp.unique_id, 0, &devid))
1407 ssp->port_id = devid;
1408 1422
1409 pdata->num_chipselect = 1; 1423 pdata->num_chipselect = 1;
1410 pdata->enable_dma = true; 1424 pdata->enable_dma = true;
@@ -1412,9 +1426,9 @@ pxa2xx_spi_acpi_get_pdata(struct platform_device *pdev)
1412 return pdata; 1426 return pdata;
1413} 1427}
1414 1428
1415#else 1429#else /* !CONFIG_PCI */
1416static inline struct pxa2xx_spi_master * 1430static inline struct pxa2xx_spi_master *
1417pxa2xx_spi_acpi_get_pdata(struct platform_device *pdev) 1431pxa2xx_spi_init_pdata(struct platform_device *pdev)
1418{ 1432{
1419 return NULL; 1433 return NULL;
1420} 1434}
@@ -1433,7 +1447,7 @@ static int pxa2xx_spi_probe(struct platform_device *pdev)
1433 1447
1434 platform_info = dev_get_platdata(dev); 1448 platform_info = dev_get_platdata(dev);
1435 if (!platform_info) { 1449 if (!platform_info) {
1436 platform_info = pxa2xx_spi_acpi_get_pdata(pdev); 1450 platform_info = pxa2xx_spi_init_pdata(pdev);
1437 if (!platform_info) { 1451 if (!platform_info) {
1438 dev_err(&pdev->dev, "missing platform data\n"); 1452 dev_err(&pdev->dev, "missing platform data\n");
1439 return -ENODEV; 1453 return -ENODEV;