ACPI / PMIC: AXP288: support virtual GPIO in ACPI table
authorAaron Lu <aaron.lu@intel.com>
Mon, 24 Nov 2014 09:32:33 +0000 (17:32 +0800)
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>
Wed, 26 Nov 2014 22:32:06 +0000 (23:32 +0100)
The same virtual GPIO strategy is also used for the AXP288 PMIC in that
various control methods that are used to do power rail handling and
sensor reading/setting will touch GPIO fields defined under the PMIC
device. The GPIO fileds are only defined by the ACPI code while the
actual hardware doesn't really have a GPIO controller, but to make those
control method execution succeed, we have to install a GPIO handler for
the PMIC device handle. Since we do not need the virtual GPIO strategy,
we can simply do nothing in that handler.

Signed-off-by: Aaron Lu <aaron.lu@intel.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
drivers/acpi/pmic/intel_pmic_xpower.c

index f8853e5eb838aab040e3de8548b473327a4ced24..6a082d4de12cb7c0f19c5dac47251f51c10392f2 100644 (file)
@@ -220,13 +220,35 @@ static struct intel_pmic_opregion_data intel_xpower_pmic_opregion_data = {
        .thermal_table_count = ARRAY_SIZE(thermal_table),
 };
 
+static acpi_status intel_xpower_pmic_gpio_handler(u32 function,
+               acpi_physical_address address, u32 bit_width, u64 *value,
+               void *handler_context, void *region_context)
+{
+       return AE_OK;
+}
 
 static int intel_xpower_pmic_opregion_probe(struct platform_device *pdev)
 {
-       struct axp20x_dev *axp20x = dev_get_drvdata(pdev->dev.parent);
-       return intel_pmic_install_opregion_handler(&pdev->dev,
-                       ACPI_HANDLE(pdev->dev.parent), axp20x->regmap,
-                       &intel_xpower_pmic_opregion_data);
+       struct device *parent = pdev->dev.parent;
+       struct axp20x_dev *axp20x = dev_get_drvdata(parent);
+       acpi_status status;
+       int result;
+
+       status = acpi_install_address_space_handler(ACPI_HANDLE(parent),
+                       ACPI_ADR_SPACE_GPIO, intel_xpower_pmic_gpio_handler,
+                       NULL, NULL);
+       if (ACPI_FAILURE(status))
+               return -ENODEV;
+
+       result = intel_pmic_install_opregion_handler(&pdev->dev,
+                                       ACPI_HANDLE(parent), axp20x->regmap,
+                                       &intel_xpower_pmic_opregion_data);
+       if (result)
+               acpi_remove_address_space_handler(ACPI_HANDLE(parent),
+                                                 ACPI_ADR_SPACE_GPIO,
+                                                 intel_xpower_pmic_gpio_handler);
+
+       return result;
 }
 
 static struct platform_driver intel_xpower_pmic_opregion_driver = {