Support PMIC operation region for CrystalCove and XPower
Subsystems (7)
v2 cover Support PMIC operation region for CrystalCove and XPower
v2:
Place PMIC operation files under drivers/acpi/pmic instead of drivers/acpi/pmic_opregion as suggested by Rafael;
Rename PMIC operation files to make them shorter as suggested by Rafael.
v1:
On Intel Baytrail-T and Baytrail-T-CR platforms, there are two customized ACPI operation regions defined for the Power Management Integrated Circuit device, one is for power resource handling and one is for thermal: sensor temperature reporting, trip point setting, etc. There are different PMIC chips used on those platforms and though each has the same two operation regions and functionality, their implementation is different so every PMIC will need a driver. But since their functionality is similar, some common code is abstracted into the intel_soc_pmic_opregion.c.
The last version is posted here:
https://lkml.org/lkml/2014/9/8/801
Changes since then:
1 Move to drivers/acpi as discussed on the above thread;
2 Added support for XPower AXP288 PMIC operation region support; 3 Since operation region handler can not be removed(at the moment at least),
use bool for the two operation region driver configs instead of tristate; Another reason to do this is that, with Mika's MFD ACPI support patch, all those MFD cell devices created will have the same modalias as their parent's so it doesn't make much sense to compile these drivers into modules.
Patch 1 applies on top of Rafael's pm-next branch, and then patch 2 and patch 3 needs merge of Lee's mfd/ib-mfd-iio-3.19 branch where the PMIC driver XPower AXP288 and iio driver axp288_adc is located.
Aaron Lu (3):
ACPI / pmic_opregion: support PMIC operation region for CrystalCove ACPI / pmic_opregion: support PMIC operation region for XPower AXP288 ACPI / pmic_opregion: AXP288: support virtual GPIO in ACPI table
PATCH v2 1/3 ACPI / pmic_opregion: support PMIC operation region for CrystalCove
The Baytrail-T platform firmware has defined two customized operation regions for PMIC chip Crystal Cove - one is for power resource handling and one is for thermal: sensor temperature reporting, trip point setting, etc. This patch adds support for them on top of the existing Crystal Cove PMIC driver.
The reason to split code into a separate file intel_soc_pmic_opregion.c is that there are more PMIC driver with ACPI operation region support coming and we can re-use those code. The intel_soc_pmic_opregion_data structure is created also for this purpose: when we need to support a new PMIC's operation region, we just need to fill those callbacks and the two register mapping tables.
--- drivers/acpi/Kconfig | 17 ++ drivers/acpi/Makefile | 3 + drivers/acpi/pmic/intel_pmic.c | 341 +++++++++++++++++++++++++++++++++++++ drivers/acpi/pmic/intel_pmic.h | 34 ++++ drivers/acpi/pmic/intel_pmic_crc.c | 216 +++++++++++++++++++++++ drivers/mfd/intel_soc_pmic_crc.c | 3 + 6 files changed, 614 insertions(+) create mode 100644 drivers/acpi/pmic/intel_pmic.c create mode 100644 drivers/acpi/pmic/intel_pmic.h create mode 100644 drivers/acpi/pmic/intel_pmic_crc.c
drivers/acpi/Kconfig +17 -0
@@ -394,4 +394,21 @@ config ACPI_EXTLOG driver adds support for that functionality with corresponding tracepoint which carries that information to userspace. +menuconfig PMIC_OPREGION + bool "PMIC (Power Management Integrated Circuit) operation region support" + help + Select this option to enable support for ACPI operation + region of the PMIC chip. The operation region can be used + to control power rails and sensor reading/writing on the + PMIC chip. + +if PMIC_OPREGION +config CRC_PMIC_OPREGION + bool "ACPI operation region support for CrystalCove PMIC" + depends on INTEL_SOC_PMIC + help + This config adds ACPI operation region support for CrystalCove PMIC. + +endif + endif # ACPI
drivers/acpi/Makefile +3 -0
@@ -88,3 +88,6 @@ obj-$(CONFIG_ACPI_PROCESSOR_AGGREGATOR) += acpi_pad.o obj-$(CONFIG_ACPI_APEI) += apei/ obj-$(CONFIG_ACPI_EXTLOG) += acpi_extlog.o + +obj-$(CONFIG_PMIC_OPREGION) += pmic/intel_pmic.o +obj-$(CONFIG_CRC_PMIC_OPREGION) += pmic/intel_pmic_crc.o
drivers/acpi/pmic/intel_pmic.c new file +341 -0
341 lines not on this page · raw message
drivers/acpi/pmic/intel_pmic.h new file +34 -0
@@ -0,0 +1,34 @@ +#ifndef __INTEL_PMIC_H +#define __INTEL_PMIC_H + +struct pmic_pwr_reg { +int reg;/* corresponding PMIC register */ +int bit;/* control bit for power */ +}; + +struct pmic_pwr_table { +int address;/* operation region address */ +struct pmic_pwr_reg pwr_reg; +}; + +struct pmic_dptf_table { +int address;/* operation region address */ +int reg;/* corresponding thermal register */ +}; + +struct intel_soc_pmic_opregion_data { +int (*get_power)(struct regmap *r,struct pmic_pwr_reg *preg,u64 *value); +int (*update_power)(struct regmap *r,struct pmic_pwr_reg *preg,bool on); +int (*get_raw_temp)(struct regmap *r,int reg); +int (*update_aux)(struct regmap *r,int reg,int raw_temp); +int (*get_policy)(struct regmap *r,int reg,u64 *value); +int (*update_policy)(struct regmap *r,int reg,int enable); +struct pmic_pwr_table *pwr_table; +int pwr_table_count; +struct pmic_dptf_table *dptf_table; +int dptf_table_count; +}; + +int intel_soc_pmic_install_opregion_handler (struct device *dev,acpi_handle handle,struct regmap *regmap,struct intel_soc_pmic_opregion_data *d); + +#endif
drivers/acpi/pmic/intel_pmic_crc.c new file +216 -0
216 lines not on this page · raw message
drivers/mfd/intel_soc_pmic_crc.c +3 -0
@@ -106,6 +106,9 @@ static struct mfd_cell crystal_cove_dev[] = { .num_resources = ARRAY_SIZE(gpio_resources), .resources = gpio_resources, }, + { + .name = "crystal_cove_region", + }, };static struct regmap_config crystal_cove_regmap_config = {
Signature · 1 line
1.9.3
PATCH v2 2/3 ACPI / pmic_opregion: support PMIC operation region for XPower AXP288
In reply to Aaron LuThe Baytrail-T-CR platform firmware has defined two customized operation regions for PMIC chip Dollar Cove XPower - one is for power resource handling and one is for thermal just like the CrystalCove one. This patch adds support for them on top of the common PMIC opregion region code.
--- drivers/acpi/Kconfig | 6 + drivers/acpi/Makefile | 1 + drivers/acpi/pmic/intel_pmic_xpower.c | 277 ++++++++++++++++++++++++++++++++++ drivers/mfd/axp20x.c | 3 + 4 files changed, 287 insertions(+) create mode 100644 drivers/acpi/pmic/intel_pmic_xpower.c
drivers/acpi/Kconfig +6 -0
@@ -409,6 +409,12 @@ config CRC_PMIC_OPREGION help This config adds ACPI operation region support for CrystalCove PMIC. +config XPOWER_PMIC_OPREGION + bool "ACPI operation region support for XPower AXP288 PMIC" + depends on AXP288_ADC + help + This config adds ACPI operation region support for XPower AXP288 PMIC. + endif endif # ACPI
drivers/acpi/Makefile +1 -0
@@ -91,3 +91,4 @@ obj-$(CONFIG_ACPI_EXTLOG) += acpi_extlog.o obj-$(CONFIG_PMIC_OPREGION) += pmic/intel_pmic.o obj-$(CONFIG_CRC_PMIC_OPREGION) += pmic/intel_pmic_crc.o +obj-$(CONFIG_XPOWER_PMIC_OPREGION) += pmic/intel_pmic_xpower.o
drivers/acpi/pmic/intel_pmic_xpower.c new file +277 -0
277 lines not on this page · raw message
drivers/mfd/axp20x.c +3 -0
@@ -354,6 +354,9 @@ static struct mfd_cell axp288_cells[] = { .num_resources = ARRAY_SIZE(axp288_battery_resources), .resources = axp288_battery_resources, }, + { + .name = "axp288_opregion", + }, };static struct axp20x_dev *axp20x_pm_power_off;
Signature · 1 line
1.9.3
PATCH v2 3/3 ACPI / pmic_opregion: AXP288: support virtual GPIO in ACPI table
In reply to Aaron LuThe 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.
--- drivers/acpi/pmic/intel_pmic_xpower.c | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-)
drivers/acpi/pmic/intel_pmic_xpower.c +23 -4
@@ -251,13 +251,32 @@ static struct intel_soc_pmic_opregion_data intel_xpower_pmic_opregion_data = { .dptf_table_count = ARRAY_SIZE(dptf_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_soc_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; + + result =intel_soc_pmic_install_opregion_handler (&pdev->dev, +ACPI_HANDLE (parent), axp20x->regmap, + &intel_xpower_pmic_opregion_data); +if (!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)) + result = -ENODEV ; + } + +return result; }static struct platform_driver intel_xpower_pmic_opregion_driver = {
Signature · 1 line
1.9.3