aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/acpi/scan.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2017-06-23 20:49:12 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2017-06-23 20:49:12 -0400
commitcd5545ae87ed9ca76dba7753b436713ce8df2872 (patch)
tree3b3dc7f0e421dac137f02c5be012d20744c0423e /drivers/acpi/scan.c
parentba6cbdb673c287cee87a965266419fd2111e20c4 (diff)
parente4330d8bf669139a983255d1801733b64c2ae841 (diff)
Merge tag 'acpi-4.12-rc7' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm
Pull ACPI fix from Rafael Wysocki: "This fixes the ACPI-based enumeration of some I2C and SPI devices broken in 4.11. Specifics: - I2C and SPI devices are expected to be enumerated by the I2C and SPI subsystems, respectively, but due to a change made during the 4.11 cycle, in some cases the ACPI core marks them as already enumerated which causes the I2C and SPI subsystems to overlook them, so fix that (Jarkko Nikula)" * tag 'acpi-4.12-rc7' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm: ACPI / scan: Fix enumeration for special SPI and I2C devices
Diffstat (limited to 'drivers/acpi/scan.c')
-rw-r--r--drivers/acpi/scan.c67
1 files changed, 37 insertions, 30 deletions
diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c
index 3a10d7573477..d53162997f32 100644
--- a/drivers/acpi/scan.c
+++ b/drivers/acpi/scan.c
@@ -1428,6 +1428,37 @@ static void acpi_init_coherency(struct acpi_device *adev)
1428 adev->flags.coherent_dma = cca; 1428 adev->flags.coherent_dma = cca;
1429} 1429}
1430 1430
1431static int acpi_check_spi_i2c_slave(struct acpi_resource *ares, void *data)
1432{
1433 bool *is_spi_i2c_slave_p = data;
1434
1435 if (ares->type != ACPI_RESOURCE_TYPE_SERIAL_BUS)
1436 return 1;
1437
1438 /*
1439 * devices that are connected to UART still need to be enumerated to
1440 * platform bus
1441 */
1442 if (ares->data.common_serial_bus.type != ACPI_RESOURCE_SERIAL_TYPE_UART)
1443 *is_spi_i2c_slave_p = true;
1444
1445 /* no need to do more checking */
1446 return -1;
1447}
1448
1449static bool acpi_is_spi_i2c_slave(struct acpi_device *device)
1450{
1451 struct list_head resource_list;
1452 bool is_spi_i2c_slave = false;
1453
1454 INIT_LIST_HEAD(&resource_list);
1455 acpi_dev_get_resources(device, &resource_list, acpi_check_spi_i2c_slave,
1456 &is_spi_i2c_slave);
1457 acpi_dev_free_resource_list(&resource_list);
1458
1459 return is_spi_i2c_slave;
1460}
1461
1431void acpi_init_device_object(struct acpi_device *device, acpi_handle handle, 1462void acpi_init_device_object(struct acpi_device *device, acpi_handle handle,
1432 int type, unsigned long long sta) 1463 int type, unsigned long long sta)
1433{ 1464{
@@ -1443,6 +1474,7 @@ void acpi_init_device_object(struct acpi_device *device, acpi_handle handle,
1443 acpi_bus_get_flags(device); 1474 acpi_bus_get_flags(device);
1444 device->flags.match_driver = false; 1475 device->flags.match_driver = false;
1445 device->flags.initialized = true; 1476 device->flags.initialized = true;
1477 device->flags.spi_i2c_slave = acpi_is_spi_i2c_slave(device);
1446 acpi_device_clear_enumerated(device); 1478 acpi_device_clear_enumerated(device);
1447 device_initialize(&device->dev); 1479 device_initialize(&device->dev);
1448 dev_set_uevent_suppress(&device->dev, true); 1480 dev_set_uevent_suppress(&device->dev, true);
@@ -1727,38 +1759,13 @@ static acpi_status acpi_bus_check_add(acpi_handle handle, u32 lvl_not_used,
1727 return AE_OK; 1759 return AE_OK;
1728} 1760}
1729 1761
1730static int acpi_check_spi_i2c_slave(struct acpi_resource *ares, void *data)
1731{
1732 bool *is_spi_i2c_slave_p = data;
1733
1734 if (ares->type != ACPI_RESOURCE_TYPE_SERIAL_BUS)
1735 return 1;
1736
1737 /*
1738 * devices that are connected to UART still need to be enumerated to
1739 * platform bus
1740 */
1741 if (ares->data.common_serial_bus.type != ACPI_RESOURCE_SERIAL_TYPE_UART)
1742 *is_spi_i2c_slave_p = true;
1743
1744 /* no need to do more checking */
1745 return -1;
1746}
1747
1748static void acpi_default_enumeration(struct acpi_device *device) 1762static void acpi_default_enumeration(struct acpi_device *device)
1749{ 1763{
1750 struct list_head resource_list;
1751 bool is_spi_i2c_slave = false;
1752
1753 /* 1764 /*
1754 * Do not enumerate SPI/I2C slaves as they will be enumerated by their 1765 * Do not enumerate SPI/I2C slaves as they will be enumerated by their
1755 * respective parents. 1766 * respective parents.
1756 */ 1767 */
1757 INIT_LIST_HEAD(&resource_list); 1768 if (!device->flags.spi_i2c_slave) {
1758 acpi_dev_get_resources(device, &resource_list, acpi_check_spi_i2c_slave,
1759 &is_spi_i2c_slave);
1760 acpi_dev_free_resource_list(&resource_list);
1761 if (!is_spi_i2c_slave) {
1762 acpi_create_platform_device(device, NULL); 1769 acpi_create_platform_device(device, NULL);
1763 acpi_device_set_enumerated(device); 1770 acpi_device_set_enumerated(device);
1764 } else { 1771 } else {
@@ -1854,7 +1861,7 @@ static void acpi_bus_attach(struct acpi_device *device)
1854 return; 1861 return;
1855 1862
1856 device->flags.match_driver = true; 1863 device->flags.match_driver = true;
1857 if (ret > 0) { 1864 if (ret > 0 && !device->flags.spi_i2c_slave) {
1858 acpi_device_set_enumerated(device); 1865 acpi_device_set_enumerated(device);
1859 goto ok; 1866 goto ok;
1860 } 1867 }
@@ -1863,10 +1870,10 @@ static void acpi_bus_attach(struct acpi_device *device)
1863 if (ret < 0) 1870 if (ret < 0)
1864 return; 1871 return;
1865 1872
1866 if (device->pnp.type.platform_id) 1873 if (!device->pnp.type.platform_id && !device->flags.spi_i2c_slave)
1867 acpi_default_enumeration(device);
1868 else
1869 acpi_device_set_enumerated(device); 1874 acpi_device_set_enumerated(device);
1875 else
1876 acpi_default_enumeration(device);
1870 1877
1871 ok: 1878 ok:
1872 list_for_each_entry(child, &device->children, node) 1879 list_for_each_entry(child, &device->children, node)