Skip to contentSkip to conversation

Dollar Cove TI PMIC support for Intel Cherry Trail

PATCH Superseded Takashi Iwai 4 participants 22 messages Aug 24, 2017 – Sep 5, 2017

Subsystems (5)

v2 of 5 Superseded Latest is v5 →

lore
Share & tools
lore
#0 lore raw

v2 cover Dollar Cove TI PMIC support for Intel Cherry Trail

Hi,

this is the revised patch set to add the support for Dollar Cove TI PMIC found on some Intel Cherry Trail laptops / tablets. All drivers are based on the original code from Intel downstream patches, with lots of rewrites and cleanups. MFD driver is implemented as a stand-alone like a few other variants, and the input driver got a diet in a minimalistic form.

The patch set has been tested on ASUS E100H and E200H, as well as on HP x210.

v1->v2:
- Minor cleanups in mfd driver code as suggested by Andy
- Move power-button driver to platform/x86, driver renames accordingly
- Add missing wake-irq cleanup to power-button driver
- get_raw_temp cleanup in opregion driver, mention about register endianess

thanks,

Takashi

===

Takashi Iwai (3):
mfd: Add support for Cherry Trail Dollar Cove TI PMIC platform/x86: Add support for Dollar Cove TI power button ACPI / PMIC: Add opregion driver for Intel Dollar Cove TI PMIC

 drivers/acpi/Kconfig                      |   6 +
 drivers/acpi/Makefile                     |   1 +
 drivers/acpi/pmic/intel_pmic_dc_ti.c      | 139 +++++++++++++++++++++++
 drivers/mfd/Kconfig                       |  13 +++
 drivers/mfd/Makefile                      |   1 +
 drivers/mfd/intel_soc_pmic_dc_ti.c        | 182 ++++++++++++++++++++++++++++++
 drivers/platform/x86/Kconfig              |   8 ++
 drivers/platform/x86/Makefile             |   1 +
 drivers/platform/x86/intel_dc_ti_pwrbtn.c |  96 ++++++++++++++++
 9 files changed, 447 insertions(+)
 create mode 100644 drivers/acpi/pmic/intel_pmic_dc_ti.c
 create mode 100644 drivers/mfd/intel_soc_pmic_dc_ti.c
 create mode 100644 drivers/platform/x86/intel_dc_ti_pwrbtn.c
Signature · 1 line
2.14.0
#1 lore raw

PATCH v2 1/3 mfd: Add support for Cherry Trail Dollar Cove TI PMIC

This patch adds the MFD driver for Dollar Cove TI PMIC (ACPI INT33F5) that is found on some Intel Cherry Trail devices.
The driver is based on the original work by Intel, found at:
https://github.com/01org/ProductionKernelQuilts

This is a minimal version for adding the basic resources. Currently, only ACPI PMIC opregion and the external power-button are used.

Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=193891

---
v1->v2:
* Minor cleanups as suggested by Andy

 drivers/mfd/Kconfig                |  13 +++
 drivers/mfd/Makefile               |   1 +
 drivers/mfd/intel_soc_pmic_dc_ti.c | 182 +++++++++++++++++++++++++++++++++++++
 3 files changed, 196 insertions(+)
 create mode 100644 drivers/mfd/intel_soc_pmic_dc_ti.c
drivers/mfd/Kconfig +13 -0
index 94ad2c1c3d90..28c12bb50c9f 100644
@@ -496,6 +496,19 @@ config INTEL_SOC_PMIC_CHTWC
 	  available before any devices using it are probed. This option also
 	  causes the designware-i2c driver to be builtin for the same reason.
 
+config INTEL_SOC_PMIC_DC_TI
+	tristate "Support for Dollar Cove TI PMIC"
+	depends on GPIOLIB
+	depends on I2C
+	depends on ACPI
+	depends on X86
+	select MFD_CORE
+	select REGMAP_I2C
+	select REGMAP_IRQ
+	help
+	  Select this option for supporting Dollar Cove TI PMIC device that is
+	  found on some Intel Cherry Trail systems.
+
 config MFD_INTEL_LPSS
 	tristate
 	select COMMON_CLK
drivers/mfd/Makefile +1 -0
index 080793b3fd0e..16c4fe519d30 100644
@@ -216,6 +216,7 @@ intel-soc-pmic-objs		:= intel_soc_pmic_core.o intel_soc_pmic_crc.o
 obj-$(CONFIG_INTEL_SOC_PMIC)	+= intel-soc-pmic.o
 obj-$(CONFIG_INTEL_SOC_PMIC_BXTWC)	+= intel_soc_pmic_bxtwc.o
 obj-$(CONFIG_INTEL_SOC_PMIC_CHTWC)	+= intel_soc_pmic_chtwc.o
+obj-$(CONFIG_INTEL_SOC_PMIC_DC_TI)	+= intel_soc_pmic_dc_ti.o
 obj-$(CONFIG_MFD_MT6397)	+= mt6397-core.o
 
 obj-$(CONFIG_MFD_ALTERA_A10SR)	+= altera-a10sr.o
drivers/mfd/intel_soc_pmic_dc_ti.c new file +182 -0

182 lines not on this page · raw message

Signature · 1 line
2.14.0
Reviewed-by on v2 1/3
#2 lore raw

Re: [PATCH v2 1/3] mfd: Add support for Cherry Trail Dollar Cove TI PMIC

Quoted 10 lines · Takashi Iwai

This patch adds the MFD driver for Dollar Cove TI PMIC (ACPI INT33F5) that is found on some Intel Cherry Trail devices.
The driver is based on the original work by Intel, found at:
https://github.com/01org/ProductionKernelQuilts

This is a minimal version for adding the basic resources. Currently, only ACPI PMIC opregion and the external power-button are used.

Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=193891

Reviewed-by on v2 1/3
#3 lore raw

Re: [PATCH v2 1/3] mfd: Add support for Cherry Trail Dollar Cove TI PMIC

In reply to Takashi Iwai
Quoted 8 lines · Takashi Iwai

This patch adds the MFD driver for Dollar Cove TI PMIC (ACPI INT33F5) that is found on some Intel Cherry Trail devices.
The driver is based on the original work by Intel, found at:
https://github.com/01org/ProductionKernelQuilts

This is a minimal version for adding the basic resources. Currently, only ACPI PMIC opregion and the external power-button are used.

JFYI, IRQ registers are called as IRQ and MIRQ in datasheet. Though I think we better to be in align with existing drivers.

Quoted 239 lines

Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=193891

---
v1->v2:
* Minor cleanups as suggested by Andy

 drivers/mfd/Kconfig                |  13 +++
 drivers/mfd/Makefile               |   1 +
 drivers/mfd/intel_soc_pmic_dc_ti.c | 182 +++++++++++++++++++++++++++++++++++++
 3 files changed, 196 insertions(+)
 create mode 100644 drivers/mfd/intel_soc_pmic_dc_ti.c
drivers/mfd/Kconfig +13 -0
index 94ad2c1c3d90..28c12bb50c9f 100644
@@ -496,6 +496,19 @@ config INTEL_SOC_PMIC_CHTWC
          available before any devices using it are probed. This option also
          causes the designware-i2c driver to be builtin for the same reason.
 
+config INTEL_SOC_PMIC_DC_TI
+       tristate "Support for Dollar Cove TI PMIC"
+       depends on GPIOLIB
+       depends on I2C
+       depends on ACPI
+       depends on X86
+       select MFD_CORE
+       select REGMAP_I2C
+       select REGMAP_IRQ
+       help
+         Select this option for supporting Dollar Cove TI PMIC device that is
+         found on some Intel Cherry Trail systems.
+
 config MFD_INTEL_LPSS
        tristate
        select COMMON_CLK
drivers/mfd/Makefile +1 -0
index 080793b3fd0e..16c4fe519d30 100644
@@ -216,6 +216,7 @@ intel-soc-pmic-objs         := intel_soc_pmic_core.o intel_soc_pmic_crc.o
 obj-$(CONFIG_INTEL_SOC_PMIC)   += intel-soc-pmic.o
 obj-$(CONFIG_INTEL_SOC_PMIC_BXTWC)     += intel_soc_pmic_bxtwc.o
 obj-$(CONFIG_INTEL_SOC_PMIC_CHTWC)     += intel_soc_pmic_chtwc.o
+obj-$(CONFIG_INTEL_SOC_PMIC_DC_TI)     += intel_soc_pmic_dc_ti.o
 obj-$(CONFIG_MFD_MT6397)       += mt6397-core.o
 
 obj-$(CONFIG_MFD_ALTERA_A10SR) += altera-a10sr.o
drivers/mfd/intel_soc_pmic_dc_ti.c new file +182 -1
new file mode 100644
index 000000000000..3ba1625eb44b
@@ -0,0 +1,182 @@
+/*
+ * Device access for Dollar Cove TI PMIC
+ * Copyright (c) 2014, Intel Corporation.
+ *   Author: Ramakrishna Pallala <[email protected]>
+ *
+ * Cleanup and forward-ported
+ *   Copyright (c) 2017 Takashi Iwai <[email protected]>
+ */
+
+#include <linux/acpi.h>
+#include <linux/interrupt.h>
+#include <linux/i2c.h>
+#include <linux/module.h>
+#include <linux/regmap.h>
+#include <linux/mfd/core.h>
+#include <linux/mfd/intel_soc_pmic.h>
+
+#define DC_TI_IRQLVL1          0x01
+#define DC_TI_MASK_IRQLVL1     0x02
+
+/* Level 1 IRQs */
+enum {
+       DC_TI_PWRBTN = 0,       /* power button */
+       DC_TI_DIETMPWARN,       /* thermal */
+       DC_TI_ADCCMPL,          /* ADC */
+       /* no irq 3 */
+       DC_TI_VBATLOW = 4,      /* battery */
+       DC_TI_VBUSDET,          /* power source */
+       /* no irq 6 */
+       DC_TI_CCEOCAL = 7,      /* battery */
+};
+
+static struct resource power_button_resources[] = {
+       DEFINE_RES_IRQ(DC_TI_PWRBTN),
+};
+
+static struct resource thermal_resources[] = {
+       DEFINE_RES_IRQ(DC_TI_DIETMPWARN),
+};
+
+static struct resource adc_resources[] = {
+       DEFINE_RES_IRQ(DC_TI_ADCCMPL),
+};
+
+static struct resource pwrsrc_resources[] = {
+       DEFINE_RES_IRQ(DC_TI_VBUSDET),
+};
+
+static struct resource battery_resources[] = {
+       DEFINE_RES_IRQ(DC_TI_VBATLOW),
+       DEFINE_RES_IRQ(DC_TI_CCEOCAL),
+};
+
+static struct mfd_cell dc_ti_dev[] = {
+       {
+               .name = "dc_ti_pwrbtn",
+               .num_resources = ARRAY_SIZE(power_button_resources),
+               .resources = power_button_resources,
+       },
+       {
+               .name = "dc_ti_adc",
+               .num_resources = ARRAY_SIZE(adc_resources),
+               .resources = adc_resources,
+       },
+       {
+               .name = "dc_ti_thermal",
+               .num_resources = ARRAY_SIZE(thermal_resources),
+               .resources = thermal_resources,
+       },
+       {
+               .name = "dc_ti_pwrsrc",
+               .num_resources = ARRAY_SIZE(pwrsrc_resources),
+               .resources = pwrsrc_resources,
+       },
+       {
+               .name = "dc_ti_battery",
+               .num_resources = ARRAY_SIZE(battery_resources),
+               .resources = battery_resources,
+       },
+       {
+               .name = "dc_ti_region",
+       },
+};
+
+static const struct regmap_config dc_ti_regmap_config = {
+       .reg_bits = 8,
+       .val_bits = 8,
+       .max_register = 128,
+       .cache_type = REGCACHE_NONE,
+};
+
+static const struct regmap_irq dc_ti_irqs[] = {
+       REGMAP_IRQ_REG(DC_TI_PWRBTN, 0, BIT(DC_TI_PWRBTN)),
+       REGMAP_IRQ_REG(DC_TI_DIETMPWARN, 0, BIT(DC_TI_DIETMPWARN)),
+       REGMAP_IRQ_REG(DC_TI_ADCCMPL, 0, BIT(DC_TI_ADCCMPL)),
+       REGMAP_IRQ_REG(DC_TI_VBATLOW, 0, BIT(DC_TI_VBATLOW)),
+       REGMAP_IRQ_REG(DC_TI_VBUSDET, 0, BIT(DC_TI_VBUSDET)),
+       REGMAP_IRQ_REG(DC_TI_CCEOCAL, 0, BIT(DC_TI_CCEOCAL)),
+};
+
+static const struct regmap_irq_chip dc_ti_irq_chip = {
+       .name = KBUILD_MODNAME,
+       .irqs = dc_ti_irqs,
+       .num_irqs = ARRAY_SIZE(dc_ti_irqs),
+       .num_regs = 1,
+       .status_base = DC_TI_IRQLVL1,
+       .mask_base = DC_TI_MASK_IRQLVL1,
+       .ack_base = DC_TI_IRQLVL1,
+};
+
+static int dc_ti_probe(struct i2c_client *i2c)
+{
+       struct device *dev = &i2c->dev;
+       struct intel_soc_pmic *pmic;
+       int ret;
+
+       pmic = devm_kzalloc(dev, sizeof(*pmic), GFP_KERNEL);
+       if (!pmic)
+               return -ENOMEM;
+
+       i2c_set_clientdata(i2c, pmic);
+
+       pmic->regmap = devm_regmap_init_i2c(i2c, &dc_ti_regmap_config);
+       if (IS_ERR(pmic->regmap))
+               return PTR_ERR(pmic->regmap);
+       pmic->irq = i2c->irq;
+
+       ret = devm_regmap_add_irq_chip(dev, pmic->regmap, pmic->irq,
+                                      IRQF_ONESHOT, 0,
+                                      &dc_ti_irq_chip, &pmic->irq_chip_data);
+       if (ret)
+               return ret;
+
+       return devm_mfd_add_devices(dev, PLATFORM_DEVID_NONE, dc_ti_dev,
+                                   ARRAY_SIZE(dc_ti_dev), NULL, 0,
+                                   regmap_irq_get_domain(pmic->irq_chip_data));
+}
+
+static void dc_ti_shutdown(struct i2c_client *i2c)
+{
+       struct intel_soc_pmic *pmic = i2c_get_clientdata(i2c);
+
+       disable_irq(pmic->irq);
+}
+
+static int __maybe_unused dc_ti_suspend(struct device *dev)
+{
+       struct intel_soc_pmic *pmic = dev_get_drvdata(dev);
+
+       disable_irq(pmic->irq);
+       return 0;
+}
+
+static int __maybe_unused dc_ti_resume(struct device *dev)
+{
+       struct intel_soc_pmic *pmic = dev_get_drvdata(dev);
+
+       enable_irq(pmic->irq);
+       return 0;
+}
+
+static SIMPLE_DEV_PM_OPS(dc_ti_pm_ops, dc_ti_suspend, dc_ti_resume);
+
+static const struct acpi_device_id dc_ti_acpi_ids[] = {
+       { "INT33F5" },
+       { },
+};
+MODULE_DEVICE_TABLE(acpi, dc_ti_acpi_ids);
+
+static struct i2c_driver dc_ti_i2c_driver = {
+       .driver = {
+               .name = KBUILD_MODNAME,
+               .pm = &dc_ti_pm_ops,
+               .acpi_match_table = dc_ti_acpi_ids,
+       },
+       .probe_new = dc_ti_probe,
+       .shutdown = dc_ti_shutdown,
+};
+module_i2c_driver(dc_ti_i2c_driver);
+
+MODULE_DESCRIPTION("I2C driver for Intel SoC Dollar Cove TI PMIC");
+MODULE_LICENSE("GPL v2");
--

2.14.0

Signature · 2 lines
With Best Regards,
Andy Shevchenko
#4 lore raw

Re: [PATCH v2 1/3] mfd: Add support for Cherry Trail Dollar Cove TI PMIC

In reply to Takashi Iwai
Quoted 62 lines · Takashi Iwai

This patch adds the MFD driver for Dollar Cove TI PMIC (ACPI INT33F5) that is found on some Intel Cherry Trail devices.
The driver is based on the original work by Intel, found at:
https://github.com/01org/ProductionKernelQuilts

This is a minimal version for adding the basic resources. Currently, only ACPI PMIC opregion and the external power-button are used.

Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=193891

---
v1->v2:
* Minor cleanups as suggested by Andy

 drivers/mfd/Kconfig                |  13 +++
 drivers/mfd/Makefile               |   1 +
 drivers/mfd/intel_soc_pmic_dc_ti.c | 182 +++++++++++++++++++++++++++++++++++++
 3 files changed, 196 insertions(+)
 create mode 100644 drivers/mfd/intel_soc_pmic_dc_ti.c
drivers/mfd/Kconfig +13 -0
index 94ad2c1c3d90..28c12bb50c9f 100644
@@ -496,6 +496,19 @@ config INTEL_SOC_PMIC_CHTWC
 	  available before any devices using it are probed. This option also
 	  causes the designware-i2c driver to be builtin for the same reason.
 
+config INTEL_SOC_PMIC_DC_TI
+	tristate "Support for Dollar Cove TI PMIC"
+	depends on GPIOLIB
+	depends on I2C
+	depends on ACPI
+	depends on X86
+	select MFD_CORE
+	select REGMAP_I2C
+	select REGMAP_IRQ
+	help
+	  Select this option for supporting Dollar Cove TI PMIC device that is
+	  found on some Intel Cherry Trail systems.
+
 config MFD_INTEL_LPSS
 	tristate
 	select COMMON_CLK
drivers/mfd/Makefile +1 -0
index 080793b3fd0e..16c4fe519d30 100644
@@ -216,6 +216,7 @@ intel-soc-pmic-objs		:= intel_soc_pmic_core.o intel_soc_pmic_crc.o
 obj-$(CONFIG_INTEL_SOC_PMIC)	+= intel-soc-pmic.o
 obj-$(CONFIG_INTEL_SOC_PMIC_BXTWC)	+= intel_soc_pmic_bxtwc.o
 obj-$(CONFIG_INTEL_SOC_PMIC_CHTWC)	+= intel_soc_pmic_chtwc.o
+obj-$(CONFIG_INTEL_SOC_PMIC_DC_TI)	+= intel_soc_pmic_dc_ti.o
 obj-$(CONFIG_MFD_MT6397)	+= mt6397-core.o
 
 obj-$(CONFIG_MFD_ALTERA_A10SR)	+= altera-a10sr.o
drivers/mfd/intel_soc_pmic_dc_ti.c new file +0 -0
new file mode 100644
index 000000000000..3ba1625eb44b

drivers/mfd/intel_soc_pmic_dc_ti.c line 2

Quoted 2 lines
drivers/mfd/intel_soc_pmic_dc_ti.c new file +2 -0
@@ -0,0 +1,182 @@
+/*
+ * Device access for Dollar Cove TI PMIC

Nit: '\n' here please.

drivers/mfd/intel_soc_pmic_dc_ti.c line 7

Quoted 5 lines
drivers/mfd/intel_soc_pmic_dc_ti.c new file +5 -0
+ * Copyright (c) 2014, Intel Corporation.
+ *   Author: Ramakrishna Pallala <[email protected]>
+ *
+ * Cleanup and forward-ported
+ *   Copyright (c) 2017 Takashi Iwai <[email protected]>

No licence header?

drivers/mfd/intel_soc_pmic_dc_ti.c line 16

Quoted 9 lines
drivers/mfd/intel_soc_pmic_dc_ti.c new file +9 -0
+ */
+
+#include <linux/acpi.h>
+#include <linux/interrupt.h>
+#include <linux/i2c.h>
+#include <linux/module.h>
+#include <linux/regmap.h>
+#include <linux/mfd/core.h>
+#include <linux/mfd/intel_soc_pmic.h>

Alphabetical.

drivers/mfd/intel_soc_pmic_dc_ti.c line 26

Quoted 9 lines
drivers/mfd/intel_soc_pmic_dc_ti.c new file +9 -0
+#define DC_TI_IRQLVL1		0x01
+#define DC_TI_MASK_IRQLVL1	0x02
+
+/* Level 1 IRQs */
+enum {
+	DC_TI_PWRBTN = 0,	/* power button */
+	DC_TI_DIETMPWARN,	/* thermal */
+	DC_TI_ADCCMPL,		/* ADC */
+	/* no irq 3 */

"No IRQ 3"

drivers/mfd/intel_soc_pmic_dc_ti.c line 29

Quoted 3 lines
drivers/mfd/intel_soc_pmic_dc_ti.c new file +3 -0
+	DC_TI_VBATLOW = 4,	/* battery */
+	DC_TI_VBUSDET,		/* power source */
+	/* no irq 6 */

Here too.

Quoted 13 lines
drivers/mfd/intel_soc_pmic_dc_ti.c new file +13 -0
+	DC_TI_CCEOCAL = 7,	/* battery */
+};
+
+static struct resource power_button_resources[] = {
+	DEFINE_RES_IRQ(DC_TI_PWRBTN),
+};
+
+static struct resource thermal_resources[] = {
+	DEFINE_RES_IRQ(DC_TI_DIETMPWARN),
+};
+
+static struct resource adc_resources[] = {
+	DEFINE_RES_IRQ(DC_TI_ADCCMPL),

drivers/mfd/intel_soc_pmic_dc_ti.c line 52

Quoted 10 lines
drivers/mfd/intel_soc_pmic_dc_ti.c new file +10 -0
+};
+
+static struct resource pwrsrc_resources[] = {
+	DEFINE_RES_IRQ(DC_TI_VBUSDET),
+};
+
+static struct resource battery_resources[] = {
+	DEFINE_RES_IRQ(DC_TI_VBATLOW),
+	DEFINE_RES_IRQ(DC_TI_CCEOCAL),
+};

Nice. Thanks for using those.

drivers/mfd/intel_soc_pmic_dc_ti.c line 60

Quoted 7 lines
drivers/mfd/intel_soc_pmic_dc_ti.c new file +7 -0
+static struct mfd_cell dc_ti_dev[] = {
+	{
+		.name = "dc_ti_pwrbtn",
+		.num_resources = ARRAY_SIZE(power_button_resources),
+		.resources = power_button_resources,
+	},
+	{

Place these on the same line.

Quoted 12 lines
drivers/mfd/intel_soc_pmic_dc_ti.c new file +12 -0
+		.name = "dc_ti_adc",
+		.num_resources = ARRAY_SIZE(adc_resources),
+		.resources = adc_resources,
+	},
+	{
+		.name = "dc_ti_thermal",
+		.num_resources = ARRAY_SIZE(thermal_resources),
+		.resources = thermal_resources,
+	},
+	{
+		.name = "dc_ti_pwrsrc",
+		.num_resources = ARRAY_SIZE(pwrsrc_resources),

drivers/mfd/intel_soc_pmic_dc_ti.c line 82

Quoted 10 lines
drivers/mfd/intel_soc_pmic_dc_ti.c new file +10 -0
+		.resources = pwrsrc_resources,
+	},
+	{
+		.name = "dc_ti_battery",
+		.num_resources = ARRAY_SIZE(battery_resources),
+		.resources = battery_resources,
+	},
+	{
+		.name = "dc_ti_region",
+	},

This should be a one line entry:

	{ .name = "dc_ti_region" },
Quoted 58 lines
drivers/mfd/intel_soc_pmic_dc_ti.c new file +58 -0
+};
+
+static const struct regmap_config dc_ti_regmap_config = {
+	.reg_bits = 8,
+	.val_bits = 8,
+	.max_register = 128,
+	.cache_type = REGCACHE_NONE,
+};
+
+static const struct regmap_irq dc_ti_irqs[] = {
+	REGMAP_IRQ_REG(DC_TI_PWRBTN, 0, BIT(DC_TI_PWRBTN)),
+	REGMAP_IRQ_REG(DC_TI_DIETMPWARN, 0, BIT(DC_TI_DIETMPWARN)),
+	REGMAP_IRQ_REG(DC_TI_ADCCMPL, 0, BIT(DC_TI_ADCCMPL)),
+	REGMAP_IRQ_REG(DC_TI_VBATLOW, 0, BIT(DC_TI_VBATLOW)),
+	REGMAP_IRQ_REG(DC_TI_VBUSDET, 0, BIT(DC_TI_VBUSDET)),
+	REGMAP_IRQ_REG(DC_TI_CCEOCAL, 0, BIT(DC_TI_CCEOCAL)),
+};
+
+static const struct regmap_irq_chip dc_ti_irq_chip = {
+	.name = KBUILD_MODNAME,
+	.irqs = dc_ti_irqs,
+	.num_irqs = ARRAY_SIZE(dc_ti_irqs),
+	.num_regs = 1,
+	.status_base = DC_TI_IRQLVL1,
+	.mask_base = DC_TI_MASK_IRQLVL1,
+	.ack_base = DC_TI_IRQLVL1,
+};
+
+static int dc_ti_probe(struct i2c_client *i2c)
+{
+	struct device *dev = &i2c->dev;
+	struct intel_soc_pmic *pmic;
+	int ret;
+
+	pmic = devm_kzalloc(dev, sizeof(*pmic), GFP_KERNEL);
+	if (!pmic)
+		return -ENOMEM;
+
+	i2c_set_clientdata(i2c, pmic);
+
+	pmic->regmap = devm_regmap_init_i2c(i2c, &dc_ti_regmap_config);
+	if (IS_ERR(pmic->regmap))
+		return PTR_ERR(pmic->regmap);
+	pmic->irq = i2c->irq;
+
+	ret = devm_regmap_add_irq_chip(dev, pmic->regmap, pmic->irq,
+				       IRQF_ONESHOT, 0,
+				       &dc_ti_irq_chip, &pmic->irq_chip_data);
+	if (ret)
+		return ret;
+
+	return devm_mfd_add_devices(dev, PLATFORM_DEVID_NONE, dc_ti_dev,
+				    ARRAY_SIZE(dc_ti_dev), NULL, 0,
+				    regmap_irq_get_domain(pmic->irq_chip_data));
+}
+
+static void dc_ti_shutdown(struct i2c_client *i2c)
+{

drivers/mfd/intel_soc_pmic_dc_ti.c line 150

Quoted 10 lines
drivers/mfd/intel_soc_pmic_dc_ti.c new file +10 -0
+	struct intel_soc_pmic *pmic = i2c_get_clientdata(i2c);
+
+	disable_irq(pmic->irq);
+}
+
+static int __maybe_unused dc_ti_suspend(struct device *dev)
+{
+	struct intel_soc_pmic *pmic = dev_get_drvdata(dev);
+
+	disable_irq(pmic->irq);

'\n' here.

drivers/mfd/intel_soc_pmic_dc_ti.c line 158

Quoted 8 lines
drivers/mfd/intel_soc_pmic_dc_ti.c new file +8 -0
+	return 0;
+}
+
+static int __maybe_unused dc_ti_resume(struct device *dev)
+{
+	struct intel_soc_pmic *pmic = dev_get_drvdata(dev);
+
+	enable_irq(pmic->irq);

'\n' here.

Quoted 4 lines
drivers/mfd/intel_soc_pmic_dc_ti.c new file +4 -0
+	return 0;
+}
+
+static SIMPLE_DEV_PM_OPS(dc_ti_pm_ops, dc_ti_suspend, dc_ti_resume);

drivers/mfd/intel_soc_pmic_dc_ti.c line 172

Quoted 10 lines
drivers/mfd/intel_soc_pmic_dc_ti.c new file +10 -0
+
+static const struct acpi_device_id dc_ti_acpi_ids[] = {
+	{ "INT33F5" },
+	{ },
+};
+MODULE_DEVICE_TABLE(acpi, dc_ti_acpi_ids);
+
+static struct i2c_driver dc_ti_i2c_driver = {
+	.driver = {
+		.name = KBUILD_MODNAME,

This makes grepping for device/driver matches difficult. Please just use the raw "" string.

Quoted 10 lines
drivers/mfd/intel_soc_pmic_dc_ti.c new file +10 -0
+		.pm = &dc_ti_pm_ops,
+		.acpi_match_table = dc_ti_acpi_ids,
+	},
+	.probe_new = dc_ti_probe,
+	.shutdown = dc_ti_shutdown,
+};
+module_i2c_driver(dc_ti_i2c_driver);
+
+MODULE_DESCRIPTION("I2C driver for Intel SoC Dollar Cove TI PMIC");
+MODULE_LICENSE("GPL v2");
Signature · 4 lines
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog
#5 lore raw

Re: [PATCH v2 1/3] mfd: Add support for Cherry Trail Dollar Cove TI PMIC

Quoted 10 lines · Lee Jones

drivers/mfd/intel_soc_pmic_dc_ti.c line 60

Quoted 8 lines
drivers/mfd/intel_soc_pmic_dc_ti.c new file +7 -0
+static struct mfd_cell dc_ti_dev[] = {
+	{
+		.name = "dc_ti_pwrbtn",
+		.num_resources = ARRAY_SIZE(power_button_resources),
+		.resources = power_button_resources,
+	},
+	{

Place these on the same line.

Does this and ...

Quoted 8 lines

drivers/mfd/intel_soc_pmic_dc_ti.c line 82

Quoted 4 lines
drivers/mfd/intel_soc_pmic_dc_ti.c new file +4 -0
+	},
+	{
+		.name = "dc_ti_region",
+	},

This should be a one line entry:

	{ .name = "dc_ti_region" },

.... this match together? The result would be like:

static struct mfd_cell dc_ti_dev[] = {
	{
		.name = "dc_ti_pwrbtn",
		.num_resources = ARRAY_SIZE(power_button_resources),
		.resources = power_button_resources,
	}, {
		.name = "chtdc_ti_adc",
		.num_resources = ARRAY_SIZE(adc_resources),
	.....
	}, {	.name = "chtdc_ti_region",	},
};

which I find a bit inconsistent.

thanks,

Takashi

#6 lore raw

Re: [PATCH v2 1/3] mfd: Add support for Cherry Trail Dollar Cove TI PMIC

Quoted 39 lines · Takashi Iwai
Quoted 10 lines · Lee Jones

drivers/mfd/intel_soc_pmic_dc_ti.c line 60

Quoted 8 lines
drivers/mfd/intel_soc_pmic_dc_ti.c new file +7 -0
+static struct mfd_cell dc_ti_dev[] = {
+	{
+		.name = "dc_ti_pwrbtn",
+		.num_resources = ARRAY_SIZE(power_button_resources),
+		.resources = power_button_resources,
+	},
+	{

Place these on the same line.

Does this and ...

Quoted 8 lines

drivers/mfd/intel_soc_pmic_dc_ti.c line 82

Quoted 4 lines
drivers/mfd/intel_soc_pmic_dc_ti.c new file +4 -0
+	},
+	{
+		.name = "dc_ti_region",
+	},

This should be a one line entry:

	{ .name = "dc_ti_region" },

.... this match together? The result would be like:

static struct mfd_cell dc_ti_dev[] = {
	{
		.name = "dc_ti_pwrbtn",
		.num_resources = ARRAY_SIZE(power_button_resources),
		.resources = power_button_resources,
	}, {
		.name = "chtdc_ti_adc",
		.num_resources = ARRAY_SIZE(adc_resources),
	.....
	}, {	.name = "chtdc_ti_region",	},
};
Quoted 1 line

which I find a bit inconsistent.

No, it doesn't.

The single lines need to be on their own.

Signature · 4 lines
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog
#7 lore raw

Re: [PATCH v2 1/3] mfd: Add support for Cherry Trail Dollar Cove TI PMIC

Quoted 42 lines · Lee Jones
Quoted 39 lines · Takashi Iwai
Quoted 10 lines · Lee Jones

drivers/mfd/intel_soc_pmic_dc_ti.c line 60

Quoted 8 lines
drivers/mfd/intel_soc_pmic_dc_ti.c new file +7 -0
+static struct mfd_cell dc_ti_dev[] = {
+	{
+		.name = "dc_ti_pwrbtn",
+		.num_resources = ARRAY_SIZE(power_button_resources),
+		.resources = power_button_resources,
+	},
+	{

Place these on the same line.

Does this and ...

Quoted 8 lines

drivers/mfd/intel_soc_pmic_dc_ti.c line 82

Quoted 4 lines
drivers/mfd/intel_soc_pmic_dc_ti.c new file +4 -0
+	},
+	{
+		.name = "dc_ti_region",
+	},

This should be a one line entry:

	{ .name = "dc_ti_region" },

.... this match together? The result would be like:

static struct mfd_cell dc_ti_dev[] = {
	{
		.name = "dc_ti_pwrbtn",
		.num_resources = ARRAY_SIZE(power_button_resources),
		.resources = power_button_resources,
	}, {
		.name = "chtdc_ti_adc",
		.num_resources = ARRAY_SIZE(adc_resources),
	.....
	}, {	.name = "chtdc_ti_region",	},
};
Quoted 3 lines
Quoted 1 line

which I find a bit inconsistent.

No, it doesn't.

Heh, I find such a mixture annoying, but it's a matter of taste.

Quoted 1 line

The single lines need to be on their own.

So did I already in the v5 patch submitted yesterday.

thanks,

Takashi

#8 lore raw

Re: [PATCH v2 1/3] mfd: Add support for Cherry Trail Dollar Cove TI PMIC

Quoted 44 lines · Takashi Iwai
Quoted 42 lines · Lee Jones
Quoted 39 lines · Takashi Iwai
Quoted 10 lines · Lee Jones

drivers/mfd/intel_soc_pmic_dc_ti.c line 60

Quoted 8 lines
drivers/mfd/intel_soc_pmic_dc_ti.c new file +7 -0
+static struct mfd_cell dc_ti_dev[] = {
+	{
+		.name = "dc_ti_pwrbtn",
+		.num_resources = ARRAY_SIZE(power_button_resources),
+		.resources = power_button_resources,
+	},
+	{

Place these on the same line.

Does this and ...

Quoted 8 lines

drivers/mfd/intel_soc_pmic_dc_ti.c line 82

Quoted 4 lines
drivers/mfd/intel_soc_pmic_dc_ti.c new file +4 -0
+	},
+	{
+		.name = "dc_ti_region",
+	},

This should be a one line entry:

	{ .name = "dc_ti_region" },

.... this match together? The result would be like:

static struct mfd_cell dc_ti_dev[] = {
	{
		.name = "dc_ti_pwrbtn",
		.num_resources = ARRAY_SIZE(power_button_resources),
		.resources = power_button_resources,
	}, {
		.name = "chtdc_ti_adc",
		.num_resources = ARRAY_SIZE(adc_resources),
	.....
	}, {	.name = "chtdc_ti_region",	},
};
Quoted 5 lines
Quoted 3 lines
Quoted 1 line

which I find a bit inconsistent.

No, it doesn't.

Heh, I find such a mixture annoying, but it's a matter of taste.

Coding style is always a matter of taste. :)

Quoted 3 lines
Quoted 1 line

The single lines need to be on their own.

So did I already in the v5 patch submitted yesterday.

I saw it, thanks.

Signature · 4 lines
Lee Jones
Linaro STMicroelectronics Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog
#9 lore raw

PATCH v2 2/3 platform/x86: Add support for Dollar Cove TI power button

In reply to Takashi Iwai

This provides a new input driver for supporting the power button on Dollar Cove TI PMIC, found on Cherrytrail-based devices. The patch is based on the original work by Intel, found at:
https://github.com/01org/ProductionKernelQuilts

Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=193891

---
v1->v2:
* Move power-button driver to platform/x86, driver renames accordingly
* Add missing wake-irq cleanup to power-button driver

 drivers/platform/x86/Kconfig              |  8 +++
 drivers/platform/x86/Makefile             |  1 +
 drivers/platform/x86/intel_dc_ti_pwrbtn.c | 96 +++++++++++++++++++++++++++++++
 3 files changed, 105 insertions(+)
 create mode 100644 drivers/platform/x86/intel_dc_ti_pwrbtn.c
drivers/platform/x86/Kconfig +8 -0
index 80b87954f6dd..25ab9f6ba533 100644
@@ -1139,6 +1139,14 @@ config SILEAD_DMI
 	  with the OS-image for the device. This option supplies the missing
 	  information. Enable this for x86 tablets with Silead touchscreens.
 
+config INTEL_DC_TI_PWRBTN
+	tristate "Dollar Cove TI power button driver"
+	depends on INTEL_SOC_PMIC_DC_TI
+	depends on INPUT
+	help
+	  Say Y here fi you want to have a power button driver for
+	  Dollar Cove TI PMIC.
+
 endif # X86_PLATFORM_DEVICES
 
 config PMC_ATOM
drivers/platform/x86/Makefile +1 -0
index 91cec1751461..1ce5c18d249e 100644
@@ -83,3 +83,4 @@ obj-$(CONFIG_PMC_ATOM)		+= pmc_atom.o
 obj-$(CONFIG_MLX_PLATFORM)	+= mlx-platform.o
 obj-$(CONFIG_MLX_CPLD_PLATFORM)	+= mlxcpld-hotplug.o
 obj-$(CONFIG_INTEL_TURBO_MAX_3) += intel_turbo_max_3.o
+obj-$(CONFIG_INTEL_DC_TI_PWRBTN)	+= intel_dc_ti_pwrbtn.o
drivers/platform/x86/intel_dc_ti_pwrbtn.c new file +96 -0

96 lines not on this page · raw message

Signature · 1 line
2.14.0
Reviewed-by on v2 2/3
#10 lore raw

Re: [PATCH v2 2/3] platform/x86: Add support for Dollar Cove TI power button

Quoted 1 line · Takashi Iwai

+static struct platform_device_id dc_ti_pwrbtn_id_table[] = {

const?

Regardless,

Acked-by on v2 2/3
#11 lore raw

Re: [PATCH v2 2/3] platform/x86: Add support for Dollar Cove TI power button

In reply to Takashi Iwai
Quoted 7 lines · Takashi Iwai

This provides a new input driver for supporting the power button on Dollar Cove TI PMIC, found on Cherrytrail-based devices. The patch is based on the original work by Intel, found at:
https://github.com/01org/ProductionKernelQuilts

Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=193891

Are you going to submit it via MFD?

Quoted 144 lines

---
v1->v2:
* Move power-button driver to platform/x86, driver renames accordingly
* Add missing wake-irq cleanup to power-button driver

 drivers/platform/x86/Kconfig              |  8 +++
 drivers/platform/x86/Makefile             |  1 +
 drivers/platform/x86/intel_dc_ti_pwrbtn.c | 96 +++++++++++++++++++++++++++++++
 3 files changed, 105 insertions(+)
 create mode 100644 drivers/platform/x86/intel_dc_ti_pwrbtn.c
drivers/platform/x86/Kconfig +8 -0
index 80b87954f6dd..25ab9f6ba533 100644
@@ -1139,6 +1139,14 @@ config SILEAD_DMI
          with the OS-image for the device. This option supplies the missing
          information. Enable this for x86 tablets with Silead touchscreens.
 
+config INTEL_DC_TI_PWRBTN
+       tristate "Dollar Cove TI power button driver"
+       depends on INTEL_SOC_PMIC_DC_TI
+       depends on INPUT
+       help
+         Say Y here fi you want to have a power button driver for
+         Dollar Cove TI PMIC.
+
 endif # X86_PLATFORM_DEVICES
 
 config PMC_ATOM
drivers/platform/x86/Makefile +1 -0
index 91cec1751461..1ce5c18d249e 100644
@@ -83,3 +83,4 @@ obj-$(CONFIG_PMC_ATOM)                += pmc_atom.o
 obj-$(CONFIG_MLX_PLATFORM)     += mlx-platform.o
 obj-$(CONFIG_MLX_CPLD_PLATFORM)        += mlxcpld-hotplug.o
 obj-$(CONFIG_INTEL_TURBO_MAX_3) += intel_turbo_max_3.o
+obj-$(CONFIG_INTEL_DC_TI_PWRBTN)       += intel_dc_ti_pwrbtn.o
drivers/platform/x86/intel_dc_ti_pwrbtn.c new file +96 -1
new file mode 100644
index 000000000000..1a40f55699fb
@@ -0,0 +1,96 @@
+/*
+ * Power-button driver for Dollar Cove TI PMIC
+ * Copyright (C) 2014 Intel Corp
+ * Copyright (c) 2017 Takashi Iwai <[email protected]>
+ */
+
+#include <linux/init.h>
+#include <linux/input.h>
+#include <linux/interrupt.h>
+#include <linux/device.h>
+#include <linux/mfd/intel_soc_pmic.h>
+#include <linux/module.h>
+#include <linux/platform_device.h>
+#include <linux/pm_wakeirq.h>
+#include <linux/slab.h>
+
+#define DC_TI_SIRQ_REG         0x3
+#define SIRQ_PWRBTN_REL                (1 << 0)
+
+static irqreturn_t dc_ti_pwrbtn_interrupt(int irq, void *dev_id)
+{
+       struct input_dev *input = dev_id;
+       struct device *dev = input->dev.parent;
+       struct regmap *regmap = dev_get_drvdata(dev);
+       int state;
+
+       if (!regmap_read(regmap, DC_TI_SIRQ_REG, &state)) {
+               dev_dbg(dev, "SIRQ_REG=0x%x\n", state);
+               state &= SIRQ_PWRBTN_REL;
+               input_event(input, EV_KEY, KEY_POWER, !state);
+               input_sync(input);
+       }
+
+       return IRQ_HANDLED;
+}
+
+static int dc_ti_pwrbtn_probe(struct platform_device *pdev)
+{
+       struct device *dev = &pdev->dev;
+       struct intel_soc_pmic *pmic = dev_get_drvdata(dev->parent);
+       struct input_dev *input;
+       int irq;
+       int ret;
+
+       irq = platform_get_irq(pdev, 0);
+       if (irq < 0)
+               return -EINVAL;
+       input = devm_input_allocate_device(dev);
+       if (!input)
+               return -ENOMEM;
+       input->name = pdev->name;
+       input->phys = "power-button/input0";
+       input->id.bustype = BUS_HOST;
+       input->dev.parent = dev;
+       input_set_capability(input, EV_KEY, KEY_POWER);
+       ret = input_register_device(input);
+       if (ret)
+               return ret;
+
+       dev_set_drvdata(dev, pmic->regmap);
+
+       ret = devm_request_threaded_irq(dev, irq, NULL, dc_ti_pwrbtn_interrupt,
+                                       0, KBUILD_MODNAME, input);
+       if (ret)
+               return ret;
+
+       device_init_wakeup(dev, true);
+       dev_pm_set_wake_irq(dev, irq);
+       return 0;
+}
+
+static int dc_ti_pwrbtn_remove(struct platform_device *pdev)
+{
+       dev_pm_clear_wake_irq(&pdev->dev);
+       device_init_wakeup(&pdev->dev, false);
+       return 0;
+}
+
+static struct platform_device_id dc_ti_pwrbtn_id_table[] = {
+       { .name = "dc_ti_pwrbtn" },
+       {},
+};
+MODULE_DEVICE_TABLE(platform, dc_ti_pwrbtn_id_table);
+
+static struct platform_driver dc_ti_pwrbtn_driver = {
+       .driver = {
+               .name = KBUILD_MODNAME,
+       },
+       .probe  = dc_ti_pwrbtn_probe,
+       .remove = dc_ti_pwrbtn_remove,
+       .id_table = dc_ti_pwrbtn_id_table,
+};
+module_platform_driver(dc_ti_pwrbtn_driver);
+
+MODULE_DESCRIPTION("Power-button driver for Dollar Cove TI PMIC");
+MODULE_LICENSE("GPL v2");
--

2.14.0

Signature · 2 lines
With Best Regards,
Andy Shevchenko
#12 lore raw

Re: [PATCH v2 2/3] platform/x86: Add support for Dollar Cove TI power button

Quoted 11 lines · Andy Shevchenko
Quoted 7 lines · Takashi Iwai

This provides a new input driver for supporting the power button on Dollar Cove TI PMIC, found on Cherrytrail-based devices. The patch is based on the original work by Intel, found at:
https://github.com/01org/ProductionKernelQuilts

Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=193891

Are you going to submit it via MFD?

I really don't mind who takes what. The driver codes are small, so it should be OK to go through a single tree, presumably MFD, if all people agree.

OTOH, if Lee can prepare an immutable branch, other two can go via other trees, too.

What do you guys think better?

thanks,

Takashi

#13 lore raw

Re: [PATCH v2 2/3] platform/x86: Add support for Dollar Cove TI power button

Quoted 14 lines · Takashi Iwai
Quoted 11 lines · Andy Shevchenko
Quoted 7 lines · Takashi Iwai

This provides a new input driver for supporting the power button on Dollar Cove TI PMIC, found on Cherrytrail-based devices. The patch is based on the original work by Intel, found at:
https://github.com/01org/ProductionKernelQuilts

Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=193891

Are you going to submit it via MFD?

Quoted 8 lines

I really don't mind who takes what. The driver codes are small, so it should be OK to go through a single tree, presumably MFD, if all people agree.

OTOH, if Lee can prepare an immutable branch, other two can go via other trees, too.

What do you guys think better?

As a co-maintainer of PDx86 I prefer to go with MFD or whatever first patch is related to.

Signature · 2 lines
With Best Regards,
Andy Shevchenko
#14 lore raw

PATCH v2 3/3 ACPI / PMIC: Add opregion driver for Intel Dollar Cove TI PMIC

In reply to Takashi Iwai

This patch adds the opregion driver for Dollar Cove TI PMIC on Intel Cherry Trail devices. The patch is based on the original work by Intel, found at:
https://github.com/01org/ProductionKernelQuilts
with many cleanups and rewrites.

The driver is currently provided only as built-in to follow other PMIC opregion drivers convention.

The re-enumeration of devices at probe is required for fixing the issues on HP x2 210 G2. See bug#195689.

Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=193891
Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=195689

---
v1->v2:
* get_raw_temp cleanup in opregion driver, mention about register endianess

 drivers/acpi/Kconfig                 |   6 ++
 drivers/acpi/Makefile                |   1 +
 drivers/acpi/pmic/intel_pmic_dc_ti.c | 139 +++++++++++++++++++++++++++++++++++
 3 files changed, 146 insertions(+)
 create mode 100644 drivers/acpi/pmic/intel_pmic_dc_ti.c
drivers/acpi/Kconfig +6 -0
index 1ce52f84dc23..9da8dcefde7b 100644
@@ -521,6 +521,12 @@ config CHT_WC_PMIC_OPREGION
 	help
 	  This config adds ACPI operation region support for CHT Whiskey Cove PMIC.
 
+config DC_TI_PMIC_OPREGION
+	bool "ACPI operation region support for Dollar Cove TI PMIC"
+	depends on INTEL_SOC_PMIC_DC_TI
+	help
+	  This config adds ACPI operation region support for Dollar Cove TI PMIC.
+
 endif
 
 config ACPI_CONFIGFS
drivers/acpi/Makefile +1 -0
index b1aacfc62b1f..0a9008b971af 100644
@@ -103,6 +103,7 @@ obj-$(CONFIG_CRC_PMIC_OPREGION) += pmic/intel_pmic_crc.o
 obj-$(CONFIG_XPOWER_PMIC_OPREGION) += pmic/intel_pmic_xpower.o
 obj-$(CONFIG_BXT_WC_PMIC_OPREGION) += pmic/intel_pmic_bxtwc.o
 obj-$(CONFIG_CHT_WC_PMIC_OPREGION) += pmic/intel_pmic_chtwc.o
+obj-$(CONFIG_DC_TI_PMIC_OPREGION) += pmic/intel_pmic_dc_ti.o
 
 obj-$(CONFIG_ACPI_CONFIGFS)	+= acpi_configfs.o
 
drivers/acpi/pmic/intel_pmic_dc_ti.c new file +139 -0

139 lines not on this page · raw message

Signature · 1 line
2.14.0
Reviewed-by on v2 3/3
#15 lore raw

Re: [PATCH v2 3/3] ACPI / PMIC: Add opregion driver for Intel Dollar Cove TI PMIC

Quoted 72 lines · Takashi Iwai

This patch adds the opregion driver for Dollar Cove TI PMIC on Intel Cherry Trail devices. The patch is based on the original work by Intel, found at:
https://github.com/01org/ProductionKernelQuilts
with many cleanups and rewrites.

The driver is currently provided only as built-in to follow other PMIC opregion drivers convention.

The re-enumeration of devices at probe is required for fixing the issues on HP x2 210 G2. See bug#195689.

Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=193891
Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=195689

---
v1->v2:
* get_raw_temp cleanup in opregion driver, mention about register endianess

 drivers/acpi/Kconfig                 |   6 ++
 drivers/acpi/Makefile                |   1 +
 drivers/acpi/pmic/intel_pmic_dc_ti.c | 139 +++++++++++++++++++++++++++++++++++
 3 files changed, 146 insertions(+)
 create mode 100644 drivers/acpi/pmic/intel_pmic_dc_ti.c
drivers/acpi/Kconfig +6 -0
index 1ce52f84dc23..9da8dcefde7b 100644
@@ -521,6 +521,12 @@ config CHT_WC_PMIC_OPREGION
 	help
 	  This config adds ACPI operation region support for CHT Whiskey Cove PMIC.
 
+config DC_TI_PMIC_OPREGION
+	bool "ACPI operation region support for Dollar Cove TI PMIC"
+	depends on INTEL_SOC_PMIC_DC_TI
+	help
+	  This config adds ACPI operation region support for Dollar Cove TI PMIC.
+
 endif
 
 config ACPI_CONFIGFS
drivers/acpi/Makefile +1 -0
index b1aacfc62b1f..0a9008b971af 100644
@@ -103,6 +103,7 @@ obj-$(CONFIG_CRC_PMIC_OPREGION) += pmic/intel_pmic_crc.o
 obj-$(CONFIG_XPOWER_PMIC_OPREGION) += pmic/intel_pmic_xpower.o
 obj-$(CONFIG_BXT_WC_PMIC_OPREGION) += pmic/intel_pmic_bxtwc.o
 obj-$(CONFIG_CHT_WC_PMIC_OPREGION) += pmic/intel_pmic_chtwc.o
+obj-$(CONFIG_DC_TI_PMIC_OPREGION) += pmic/intel_pmic_dc_ti.o
 
 obj-$(CONFIG_ACPI_CONFIGFS)	+= acpi_configfs.o
 
drivers/acpi/pmic/intel_pmic_dc_ti.c new file +11 -0
new file mode 100644
index 000000000000..a2be1270eeeb
@@ -0,0 +1,139 @@
+/*
+ * Dollar Cove TI PMIC operation region driver
+ * Copyright (C) 2014 Intel Corporation. All rights reserved.
+ *
+ * Rewritten and cleaned up
+ * Copyright (C) 2017 Takashi Iwai <[email protected]>
+ */
+
+#include <linux/acpi.h>
+#include <linux/init.h>
+#include <linux/mfd/intel_soc_pmic.h>

drivers/acpi/pmic/intel_pmic_dc_ti.c line 21

Quoted 10 lines
drivers/acpi/pmic/intel_pmic_dc_ti.c new file +10 -0
+#include <linux/platform_device.h>
+#include "intel_pmic.h"
+
+/* registers stored in 16bit BE (high:low, total 10bit) */
+#define DC_TI_VBAT	0x54
+#define DC_TI_DIETEMP	0x56
+#define DC_TI_BPTHERM	0x58
+#define DC_TI_GPADC	0x5a
+
+static struct pmic_table dc_ti_power_table[] = {

const?

Quoted 6 lines
drivers/acpi/pmic/intel_pmic_dc_ti.c new file +6 -0
+	{ .address = 0x00, .reg = 0x41 },
+	{ .address = 0x04, .reg = 0x42 },
+	{ .address = 0x08, .reg = 0x43 },
+	{ .address = 0x0c, .reg = 0x45 },
+	{ .address = 0x10, .reg = 0x46 },
+	{ .address = 0x14, .reg = 0x47 },

drivers/acpi/pmic/intel_pmic_dc_ti.c line 37

Quoted 10 lines
drivers/acpi/pmic/intel_pmic_dc_ti.c new file +10 -0
+	{ .address = 0x18, .reg = 0x48 },
+	{ .address = 0x1c, .reg = 0x49 },
+	{ .address = 0x20, .reg = 0x4a },
+	{ .address = 0x24, .reg = 0x4b },
+	{ .address = 0x28, .reg = 0x4c },
+	{ .address = 0x2c, .reg = 0x4d },
+	{ .address = 0x30, .reg = 0x4e },
+};
+
+static struct pmic_table dc_ti_thermal_table[] = {

const?

Quoted 51 lines
drivers/acpi/pmic/intel_pmic_dc_ti.c new file +51 -0
+	{
+		.address = 0x00,
+		.reg = DC_TI_GPADC
+	},
+	{
+		.address = 0x0c,
+		.reg = DC_TI_GPADC
+	},
+	/* TMP2 -> SYSTEMP */
+	{
+		.address = 0x18,
+		.reg = DC_TI_GPADC
+	},
+	/* TMP3 -> BPTHERM */
+	{
+		.address = 0x24,
+		.reg = DC_TI_BPTHERM
+	},
+	{
+		.address = 0x30,
+		.reg = DC_TI_GPADC
+	},
+	/* TMP5 -> DIETEMP */
+	{
+		.address = 0x3c,
+		.reg = DC_TI_DIETEMP
+	},
+};
+
+static int dc_ti_pmic_get_power(struct regmap *regmap, int reg, int bit,
+				u64 *value)
+{
+	int data;
+
+	if (regmap_read(regmap, reg, &data))
+		return -EIO;
+
+	*value = data & 1;
+	return 0;
+}
+
+static int dc_ti_pmic_update_power(struct regmap *regmap, int reg, int bit,
+				   bool on)
+{
+	return regmap_update_bits(regmap, reg, 1, on);
+}
+
+static int dc_ti_pmic_get_raw_temp(struct regmap *regmap, int reg)
+{
+	u8 buf[2];
+	unsigned int val;

drivers/acpi/pmic/intel_pmic_dc_ti.c line 98

Quoted 10 lines
drivers/acpi/pmic/intel_pmic_dc_ti.c new file +10 -0
+
+	if (regmap_bulk_read(regmap, reg, buf, 2))
+		return -EIO;
+
+	/* stored in big-endian */
+	val = buf[0] & 0x03;
+	return (val << 8) | buf[1];
+}
+
+static struct intel_pmic_opregion_data dc_ti_pmic_opregion_data = {

const?

Quoted 16 lines
drivers/acpi/pmic/intel_pmic_dc_ti.c new file +16 -0
+	.get_power = dc_ti_pmic_get_power,
+	.update_power = dc_ti_pmic_update_power,
+	.get_raw_temp = dc_ti_pmic_get_raw_temp,
+	.power_table = dc_ti_power_table,
+	.power_table_count = ARRAY_SIZE(dc_ti_power_table),
+	.thermal_table = dc_ti_thermal_table,
+	.thermal_table_count = ARRAY_SIZE(dc_ti_thermal_table),
+};
+
+static int dc_ti_pmic_opregion_probe(struct platform_device *pdev)
+{
+	struct intel_soc_pmic *pmic = dev_get_drvdata(pdev->dev.parent);
+	int err;
+
+	err = intel_pmic_install_opregion_handler(&pdev->dev,
+			ACPI_HANDLE(pdev->dev.parent), pmic->regmap,

drivers/acpi/pmic/intel_pmic_dc_ti.c line 124

Quoted 10 lines
drivers/acpi/pmic/intel_pmic_dc_ti.c new file +10 -0
+			&dc_ti_pmic_opregion_data);
+	if (err < 0)
+		return err;
+
+	/* Re-enumerate devices depending on PMIC */
+	acpi_walk_dep_device_list(ACPI_HANDLE(pdev->dev.parent));
+	return 0;
+}
+
+static struct platform_device_id dc_ti_pmic_opregion_id_table[] = {

const?

Regardless of the above,

#16 lore raw

Re: [PATCH v2 3/3] ACPI / PMIC: Add opregion driver for Intel Dollar Cove TI PMIC

Quoted 97 lines · Mika Westerberg
Quoted 72 lines · Takashi Iwai

This patch adds the opregion driver for Dollar Cove TI PMIC on Intel Cherry Trail devices. The patch is based on the original work by Intel, found at:
https://github.com/01org/ProductionKernelQuilts
with many cleanups and rewrites.

The driver is currently provided only as built-in to follow other PMIC opregion drivers convention.

The re-enumeration of devices at probe is required for fixing the issues on HP x2 210 G2. See bug#195689.

Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=193891
Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=195689

---
v1->v2:
* get_raw_temp cleanup in opregion driver, mention about register endianess

 drivers/acpi/Kconfig                 |   6 ++
 drivers/acpi/Makefile                |   1 +
 drivers/acpi/pmic/intel_pmic_dc_ti.c | 139 +++++++++++++++++++++++++++++++++++
 3 files changed, 146 insertions(+)
 create mode 100644 drivers/acpi/pmic/intel_pmic_dc_ti.c
drivers/acpi/Kconfig +6 -0
index 1ce52f84dc23..9da8dcefde7b 100644
@@ -521,6 +521,12 @@ config CHT_WC_PMIC_OPREGION
 	help
 	  This config adds ACPI operation region support for CHT Whiskey Cove PMIC.
 
+config DC_TI_PMIC_OPREGION
+	bool "ACPI operation region support for Dollar Cove TI PMIC"
+	depends on INTEL_SOC_PMIC_DC_TI
+	help
+	  This config adds ACPI operation region support for Dollar Cove TI PMIC.
+
 endif
 
 config ACPI_CONFIGFS
drivers/acpi/Makefile +1 -0
index b1aacfc62b1f..0a9008b971af 100644
@@ -103,6 +103,7 @@ obj-$(CONFIG_CRC_PMIC_OPREGION) += pmic/intel_pmic_crc.o
 obj-$(CONFIG_XPOWER_PMIC_OPREGION) += pmic/intel_pmic_xpower.o
 obj-$(CONFIG_BXT_WC_PMIC_OPREGION) += pmic/intel_pmic_bxtwc.o
 obj-$(CONFIG_CHT_WC_PMIC_OPREGION) += pmic/intel_pmic_chtwc.o
+obj-$(CONFIG_DC_TI_PMIC_OPREGION) += pmic/intel_pmic_dc_ti.o
 
 obj-$(CONFIG_ACPI_CONFIGFS)	+= acpi_configfs.o
 
drivers/acpi/pmic/intel_pmic_dc_ti.c new file +11 -0
new file mode 100644
index 000000000000..a2be1270eeeb
@@ -0,0 +1,139 @@
+/*
+ * Dollar Cove TI PMIC operation region driver
+ * Copyright (C) 2014 Intel Corporation. All rights reserved.
+ *
+ * Rewritten and cleaned up
+ * Copyright (C) 2017 Takashi Iwai <[email protected]>
+ */
+
+#include <linux/acpi.h>
+#include <linux/init.h>
+#include <linux/mfd/intel_soc_pmic.h>

drivers/acpi/pmic/intel_pmic_dc_ti.c line 21

Quoted 10 lines
drivers/acpi/pmic/intel_pmic_dc_ti.c new file +10 -0
+#include <linux/platform_device.h>
+#include "intel_pmic.h"
+
+/* registers stored in 16bit BE (high:low, total 10bit) */
+#define DC_TI_VBAT	0x54
+#define DC_TI_DIETEMP	0x56
+#define DC_TI_BPTHERM	0x58
+#define DC_TI_GPADC	0x5a
+
+static struct pmic_table dc_ti_power_table[] = {

const?

Quoted 10 lines
drivers/acpi/pmic/intel_pmic_dc_ti.c new file +10 -0
+	{ .address = 0x00, .reg = 0x41 },
+	{ .address = 0x04, .reg = 0x42 },
+	{ .address = 0x08, .reg = 0x43 },
+	{ .address = 0x0c, .reg = 0x45 },
+	{ .address = 0x10, .reg = 0x46 },
+	{ .address = 0x14, .reg = 0x47 },
+	{ .address = 0x18, .reg = 0x48 },
+	{ .address = 0x1c, .reg = 0x49 },
+	{ .address = 0x20, .reg = 0x4a },
+	{ .address = 0x24, .reg = 0x4b },
Quoted 8 lines

drivers/acpi/pmic/intel_pmic_dc_ti.c line 37

Quoted 6 lines
drivers/acpi/pmic/intel_pmic_dc_ti.c new file +6 -0
+	{ .address = 0x28, .reg = 0x4c },
+	{ .address = 0x2c, .reg = 0x4d },
+	{ .address = 0x30, .reg = 0x4e },
+};
+
+static struct pmic_table dc_ti_thermal_table[] = {

const?

Oh yeah, I was too lazy. Will cover up in the next round.

thanks,

Takashi

#17 lore raw

Re: [PATCH v2 3/3] ACPI / PMIC: Add opregion driver for Intel Dollar Cove TI PMIC

Quoted 109 lines · Takashi Iwai
Quoted 97 lines · Mika Westerberg
Quoted 72 lines · Takashi Iwai

This patch adds the opregion driver for Dollar Cove TI PMIC on Intel Cherry Trail devices. The patch is based on the original work by Intel, found at:
https://github.com/01org/ProductionKernelQuilts
with many cleanups and rewrites.

The driver is currently provided only as built-in to follow other PMIC opregion drivers convention.

The re-enumeration of devices at probe is required for fixing the issues on HP x2 210 G2. See bug#195689.

Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=193891
Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=195689

---
v1->v2:
* get_raw_temp cleanup in opregion driver, mention about register endianess

 drivers/acpi/Kconfig                 |   6 ++
 drivers/acpi/Makefile                |   1 +
 drivers/acpi/pmic/intel_pmic_dc_ti.c | 139 +++++++++++++++++++++++++++++++++++
 3 files changed, 146 insertions(+)
 create mode 100644 drivers/acpi/pmic/intel_pmic_dc_ti.c
drivers/acpi/Kconfig +6 -0
index 1ce52f84dc23..9da8dcefde7b 100644
@@ -521,6 +521,12 @@ config CHT_WC_PMIC_OPREGION
 	help
 	  This config adds ACPI operation region support for CHT Whiskey Cove PMIC.
 
+config DC_TI_PMIC_OPREGION
+	bool "ACPI operation region support for Dollar Cove TI PMIC"
+	depends on INTEL_SOC_PMIC_DC_TI
+	help
+	  This config adds ACPI operation region support for Dollar Cove TI PMIC.
+
 endif
 
 config ACPI_CONFIGFS
drivers/acpi/Makefile +1 -0
index b1aacfc62b1f..0a9008b971af 100644
@@ -103,6 +103,7 @@ obj-$(CONFIG_CRC_PMIC_OPREGION) += pmic/intel_pmic_crc.o
 obj-$(CONFIG_XPOWER_PMIC_OPREGION) += pmic/intel_pmic_xpower.o
 obj-$(CONFIG_BXT_WC_PMIC_OPREGION) += pmic/intel_pmic_bxtwc.o
 obj-$(CONFIG_CHT_WC_PMIC_OPREGION) += pmic/intel_pmic_chtwc.o
+obj-$(CONFIG_DC_TI_PMIC_OPREGION) += pmic/intel_pmic_dc_ti.o
 
 obj-$(CONFIG_ACPI_CONFIGFS)	+= acpi_configfs.o
 
drivers/acpi/pmic/intel_pmic_dc_ti.c new file +11 -0
new file mode 100644
index 000000000000..a2be1270eeeb
@@ -0,0 +1,139 @@
+/*
+ * Dollar Cove TI PMIC operation region driver
+ * Copyright (C) 2014 Intel Corporation. All rights reserved.
+ *
+ * Rewritten and cleaned up
+ * Copyright (C) 2017 Takashi Iwai <[email protected]>
+ */
+
+#include <linux/acpi.h>
+#include <linux/init.h>
+#include <linux/mfd/intel_soc_pmic.h>

drivers/acpi/pmic/intel_pmic_dc_ti.c line 21

Quoted 10 lines
drivers/acpi/pmic/intel_pmic_dc_ti.c new file +10 -0
+#include <linux/platform_device.h>
+#include "intel_pmic.h"
+
+/* registers stored in 16bit BE (high:low, total 10bit) */
+#define DC_TI_VBAT	0x54
+#define DC_TI_DIETEMP	0x56
+#define DC_TI_BPTHERM	0x58
+#define DC_TI_GPADC	0x5a
+
+static struct pmic_table dc_ti_power_table[] = {

const?

Quoted 10 lines
drivers/acpi/pmic/intel_pmic_dc_ti.c new file +10 -0
+	{ .address = 0x00, .reg = 0x41 },
+	{ .address = 0x04, .reg = 0x42 },
+	{ .address = 0x08, .reg = 0x43 },
+	{ .address = 0x0c, .reg = 0x45 },
+	{ .address = 0x10, .reg = 0x46 },
+	{ .address = 0x14, .reg = 0x47 },
+	{ .address = 0x18, .reg = 0x48 },
+	{ .address = 0x1c, .reg = 0x49 },
+	{ .address = 0x20, .reg = 0x4a },
+	{ .address = 0x24, .reg = 0x4b },
Quoted 8 lines

drivers/acpi/pmic/intel_pmic_dc_ti.c line 37

Quoted 6 lines
drivers/acpi/pmic/intel_pmic_dc_ti.c new file +6 -0
+	{ .address = 0x28, .reg = 0x4c },
+	{ .address = 0x2c, .reg = 0x4d },
+	{ .address = 0x30, .reg = 0x4e },
+};
+
+static struct pmic_table dc_ti_thermal_table[] = {

const?

Quoted 1 line

Oh yeah, I was too lazy. Will cover up in the next round.

It seems that power_table and thermal_table are non-const in the definition. Also opregion_data is also passed as non-const to intel_pmic_install_opregion_handler().

So only id_table[] can be const, so far.

(It's a good hint for further cleanup patches ;)

thanks,

Takashi

Reviewed-by on v2 3/3
#18 lore raw

Re: [PATCH v2 3/3] ACPI / PMIC: Add opregion driver for Intel Dollar Cove TI PMIC

In reply to Takashi Iwai
Quoted 6 lines · Takashi Iwai

This patch adds the opregion driver for Dollar Cove TI PMIC on Intel Cherry Trail devices. The patch is based on the original work by Intel, found at:
https://github.com/01org/ProductionKernelQuilts
with many cleanups and rewrites.

Quoted 6 lines

The driver is currently provided only as built-in to follow other PMIC opregion drivers convention.

The re-enumeration of devices at probe is required for fixing the issues on HP x2 210 G2. See bug#195689.

One comment below, otherwise

Quoted 135 lines

Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=193891
Bugzilla: https://bugzilla.kernel.org/show_bug.cgi?id=195689

---
v1->v2:
* get_raw_temp cleanup in opregion driver, mention about register endianess

 drivers/acpi/Kconfig                 |   6 ++
 drivers/acpi/Makefile                |   1 +
 drivers/acpi/pmic/intel_pmic_dc_ti.c | 139 +++++++++++++++++++++++++++++++++++
 3 files changed, 146 insertions(+)
 create mode 100644 drivers/acpi/pmic/intel_pmic_dc_ti.c
drivers/acpi/Kconfig +6 -0
index 1ce52f84dc23..9da8dcefde7b 100644
@@ -521,6 +521,12 @@ config CHT_WC_PMIC_OPREGION
        help
          This config adds ACPI operation region support for CHT Whiskey Cove PMIC.
 
+config DC_TI_PMIC_OPREGION
+       bool "ACPI operation region support for Dollar Cove TI PMIC"
+       depends on INTEL_SOC_PMIC_DC_TI
+       help
+         This config adds ACPI operation region support for Dollar Cove TI PMIC.
+
 endif
 
 config ACPI_CONFIGFS
drivers/acpi/Makefile +1 -0
index b1aacfc62b1f..0a9008b971af 100644
@@ -103,6 +103,7 @@ obj-$(CONFIG_CRC_PMIC_OPREGION) += pmic/intel_pmic_crc.o
 obj-$(CONFIG_XPOWER_PMIC_OPREGION) += pmic/intel_pmic_xpower.o
 obj-$(CONFIG_BXT_WC_PMIC_OPREGION) += pmic/intel_pmic_bxtwc.o
 obj-$(CONFIG_CHT_WC_PMIC_OPREGION) += pmic/intel_pmic_chtwc.o
+obj-$(CONFIG_DC_TI_PMIC_OPREGION) += pmic/intel_pmic_dc_ti.o
 
 obj-$(CONFIG_ACPI_CONFIGFS)    += acpi_configfs.o
 
drivers/acpi/pmic/intel_pmic_dc_ti.c new file +86 -0
new file mode 100644
index 000000000000..a2be1270eeeb
@@ -0,0 +1,139 @@
+/*
+ * Dollar Cove TI PMIC operation region driver
+ * Copyright (C) 2014 Intel Corporation. All rights reserved.
+ *
+ * Rewritten and cleaned up
+ * Copyright (C) 2017 Takashi Iwai <[email protected]>
+ */
+
+#include <linux/acpi.h>
+#include <linux/init.h>
+#include <linux/mfd/intel_soc_pmic.h>
+#include <linux/platform_device.h>
+#include "intel_pmic.h"
+
+/* registers stored in 16bit BE (high:low, total 10bit) */
+#define DC_TI_VBAT     0x54
+#define DC_TI_DIETEMP  0x56
+#define DC_TI_BPTHERM  0x58
+#define DC_TI_GPADC    0x5a
+
+static struct pmic_table dc_ti_power_table[] = {
+       { .address = 0x00, .reg = 0x41 },
+       { .address = 0x04, .reg = 0x42 },
+       { .address = 0x08, .reg = 0x43 },
+       { .address = 0x0c, .reg = 0x45 },
+       { .address = 0x10, .reg = 0x46 },
+       { .address = 0x14, .reg = 0x47 },
+       { .address = 0x18, .reg = 0x48 },
+       { .address = 0x1c, .reg = 0x49 },
+       { .address = 0x20, .reg = 0x4a },
+       { .address = 0x24, .reg = 0x4b },
+       { .address = 0x28, .reg = 0x4c },
+       { .address = 0x2c, .reg = 0x4d },
+       { .address = 0x30, .reg = 0x4e },
+};
+
+static struct pmic_table dc_ti_thermal_table[] = {
+       {
+               .address = 0x00,
+               .reg = DC_TI_GPADC
+       },
+       {
+               .address = 0x0c,
+               .reg = DC_TI_GPADC
+       },
+       /* TMP2 -> SYSTEMP */
+       {
+               .address = 0x18,
+               .reg = DC_TI_GPADC
+       },
+       /* TMP3 -> BPTHERM */
+       {
+               .address = 0x24,
+               .reg = DC_TI_BPTHERM
+       },
+       {
+               .address = 0x30,
+               .reg = DC_TI_GPADC
+       },
+       /* TMP5 -> DIETEMP */
+       {
+               .address = 0x3c,
+               .reg = DC_TI_DIETEMP
+       },
+};
+
+static int dc_ti_pmic_get_power(struct regmap *regmap, int reg, int bit,
+                               u64 *value)
+{
+       int data;
+
+       if (regmap_read(regmap, reg, &data))
+               return -EIO;
+
+       *value = data & 1;
+       return 0;
+}
+
+static int dc_ti_pmic_update_power(struct regmap *regmap, int reg, int bit,
+                                  bool on)
+{
+       return regmap_update_bits(regmap, reg, 1, on);
+}
+
+static int dc_ti_pmic_get_raw_temp(struct regmap *regmap, int reg)
+{

drivers/acpi/pmic/intel_pmic_dc_ti.c line 95

Quoted 10 lines
drivers/acpi/pmic/intel_pmic_dc_ti.c new file +9 -0
+       u8 buf[2];
+       unsigned int val;
+
+       if (regmap_bulk_read(regmap, reg, buf, 2))
+               return -EIO;
+
+       /* stored in big-endian */
 
+       val = buf[0] & 0x03;
+       return (val << 8) | buf[1];

Do you need a temporary variable at all?

       return ((buf[0] & 0x03) << 8) | buf[1];
Quoted 47 lines
drivers/acpi/pmic/intel_pmic_dc_ti.c new file +44 -1
+}
+
+static struct intel_pmic_opregion_data dc_ti_pmic_opregion_data = {
+       .get_power = dc_ti_pmic_get_power,
+       .update_power = dc_ti_pmic_update_power,
+       .get_raw_temp = dc_ti_pmic_get_raw_temp,
+       .power_table = dc_ti_power_table,
+       .power_table_count = ARRAY_SIZE(dc_ti_power_table),
+       .thermal_table = dc_ti_thermal_table,
+       .thermal_table_count = ARRAY_SIZE(dc_ti_thermal_table),
+};
+
+static int dc_ti_pmic_opregion_probe(struct platform_device *pdev)
+{
+       struct intel_soc_pmic *pmic = dev_get_drvdata(pdev->dev.parent);
+       int err;
+
+       err = intel_pmic_install_opregion_handler(&pdev->dev,
+                       ACPI_HANDLE(pdev->dev.parent), pmic->regmap,
+                       &dc_ti_pmic_opregion_data);
+       if (err < 0)
+               return err;
+
+       /* Re-enumerate devices depending on PMIC */
+       acpi_walk_dep_device_list(ACPI_HANDLE(pdev->dev.parent));
+       return 0;
+}
+
+static struct platform_device_id dc_ti_pmic_opregion_id_table[] = {
+       { .name = "dc_ti_region" },
+       {},
+};
+
+static struct platform_driver dc_ti_pmic_opregion_driver = {
+       .probe = dc_ti_pmic_opregion_probe,
+       .driver = {
+               .name = "dollar_cove_ti_pmic",
+       },
+       .id_table = dc_ti_pmic_opregion_id_table,
+};
+module_platform_driver(dc_ti_pmic_opregion_driver);
+
+MODULE_DESCRIPTION("Dollar Cove TI PMIC opregion driver");
+MODULE_LICENSE("GPL v2");
--

2.14.0

Signature · 2 lines
With Best Regards,
Andy Shevchenko
#19 lore raw

Re: [PATCH v2 3/3] ACPI / PMIC: Add opregion driver for Intel Dollar Cove TI PMIC

Quoted 16 lines · Andy Shevchenko
Quoted 6 lines · Takashi Iwai

This patch adds the opregion driver for Dollar Cove TI PMIC on Intel Cherry Trail devices. The patch is based on the original work by Intel, found at:
https://github.com/01org/ProductionKernelQuilts
with many cleanups and rewrites.

Quoted 6 lines

The driver is currently provided only as built-in to follow other PMIC opregion drivers convention.

The re-enumeration of devices at probe is required for fixing the issues on HP x2 210 G2. See bug#195689.

One comment below, otherwise

(snip)

Quoted 10 lines
Quoted 9 lines
drivers/acpi/pmic/intel_pmic_dc_ti.c new file +9 -0
+static int dc_ti_pmic_get_raw_temp(struct regmap *regmap, int reg)
+{
+       u8 buf[2];
+       unsigned int val;
+
+       if (regmap_bulk_read(regmap, reg, buf, 2))
+               return -EIO;
+
+       /* stored in big-endian */
Quoted 6 lines

drivers/acpi/pmic/intel_pmic_dc_ti.c line 95

Quoted 2 lines
drivers/acpi/pmic/intel_pmic_dc_ti.c new file +2 -0
+       val = buf[0] & 0x03;
+       return (val << 8) | buf[1];

Do you need a temporary variable at all?

       return ((buf[0] & 0x03) << 8) | buf[1];

Right it can be dropped. Will address it in the next round.

thanks,

Takashi

#20 lore raw
In reply to Takashi Iwai
Quoted 12 lines · Takashi Iwai

Hi,

this is the revised patch set to add the support for Dollar Cove TI PMIC found on some Intel Cherry Trail laptops / tablets. All drivers are based on the original code from Intel downstream patches, with lots of rewrites and cleanups. MFD driver is implemented as a stand-alone like a few other variants, and the input driver got a diet in a minimalistic form.

The patch set has been tested on ASUS E100H and E200H, as well as on HP x210.

Quoted 8 lines

v1->v2:
- Minor cleanups in mfd driver code as suggested by Andy
- Move power-button driver to platform/x86, driver renames accordingly
- Add missing wake-irq cleanup to power-button driver
- get_raw_temp cleanup in opregion driver, mention about register endianess

Global comment to the series, we agreed with Hans to follow the pattern for Intel PMIC driver (module / file) names:

intel_XXX_<PLATFORM><PMIC>, where <PLATFORM> is 3 letter encoded Intel platform name, like cht for CherryTrail and <PMIC> is two letter abbreviation from ZZZ Cove, like wc for Whiskey Cove.

Here I understand that there is a potential of two PMIC variants for the same platform DC from Intel, DC from TI. I dunno if former will be a case in the future, though we may use something like

intel_XXX_chtdc_ti

for the latter one.

Quoted 28 lines

thanks,

Takashi

===

Takashi Iwai (3):
mfd: Add support for Cherry Trail Dollar Cove TI PMIC platform/x86: Add support for Dollar Cove TI power button ACPI / PMIC: Add opregion driver for Intel Dollar Cove TI PMIC

 drivers/acpi/Kconfig                      |   6 +
 drivers/acpi/Makefile                     |   1 +
 drivers/acpi/pmic/intel_pmic_dc_ti.c      | 139 +++++++++++++++++++++++
 drivers/mfd/Kconfig                       |  13 +++
 drivers/mfd/Makefile                      |   1 +
 drivers/mfd/intel_soc_pmic_dc_ti.c        | 182 ++++++++++++++++++++++++++++++
 drivers/platform/x86/Kconfig              |   8 ++
 drivers/platform/x86/Makefile             |   1 +
 drivers/platform/x86/intel_dc_ti_pwrbtn.c |  96 ++++++++++++++++
 9 files changed, 447 insertions(+)
 create mode 100644 drivers/acpi/pmic/intel_pmic_dc_ti.c
 create mode 100644 drivers/mfd/intel_soc_pmic_dc_ti.c
 create mode 100644 drivers/platform/x86/intel_dc_ti_pwrbtn.c

--
2.14.0

Signature · 2 lines
With Best Regards,
Andy Shevchenko
#21 lore raw
Quoted 30 lines · Andy Shevchenko
Quoted 12 lines · Takashi Iwai

Hi,

this is the revised patch set to add the support for Dollar Cove TI PMIC found on some Intel Cherry Trail laptops / tablets. All drivers are based on the original code from Intel downstream patches, with lots of rewrites and cleanups. MFD driver is implemented as a stand-alone like a few other variants, and the input driver got a diet in a minimalistic form.

The patch set has been tested on ASUS E100H and E200H, as well as on HP x210.

Quoted 8 lines

v1->v2:
- Minor cleanups in mfd driver code as suggested by Andy
- Move power-button driver to platform/x86, driver renames accordingly
- Add missing wake-irq cleanup to power-button driver
- get_raw_temp cleanup in opregion driver, mention about register endianess

Global comment to the series, we agreed with Hans to follow the pattern for Intel PMIC driver (module / file) names:

intel_XXX_<PLATFORM><PMIC>, where <PLATFORM> is 3 letter encoded Intel platform name, like cht for CherryTrail and <PMIC> is two letter abbreviation from ZZZ Cove, like wc for Whiskey Cove.

Quoted 7 lines

Here I understand that there is a potential of two PMIC variants for the same platform DC from Intel, DC from TI. I dunno if former will be a case in the future, though we may use something like

intel_XXX_chtdc_ti

for the latter one.

Noted.

Also I forgot again to add Hans to Cc. Will put him in the next round.

thanks,

Takashi