All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v3 0/3] Dollar Cove TI PMIC support for Intel Cherry Trail
@ 2017-08-25 13:44 Takashi Iwai
  2017-08-25 13:44 ` [PATCH v3 1/3] mfd: Add support for Cherry Trail Dollar Cove TI PMIC Takashi Iwai
                   ` (2 more replies)
  0 siblings, 3 replies; 10+ messages in thread
From: Takashi Iwai @ 2017-08-25 13:44 UTC (permalink / raw)
  To: Lee Jones
  Cc: Darren Hart, Andy Shevchenko, Rafael J . Wysocki,
	Mika Westerberg, Johannes Stezenbach, Hans de Goede,
	platform-driver-x86, linux-acpi, linux-kernel

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.

v2->v3:
- Rename dc_ti with chtdc_ti in all places
- Driver/kconfig renames accordingly
- A few constifications
- Added acks by Andy and Mika

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_chtdc_ti.c      | 137 ++++++++++++++++++++
 drivers/mfd/Kconfig                          |  13 ++
 drivers/mfd/Makefile                         |   1 +
 drivers/mfd/intel_soc_pmic_chtdc_ti.c        | 183 +++++++++++++++++++++++++++
 drivers/platform/x86/Kconfig                 |   8 ++
 drivers/platform/x86/Makefile                |   1 +
 drivers/platform/x86/intel_chtdc_ti_pwrbtn.c |  97 ++++++++++++++
 9 files changed, 447 insertions(+)
 create mode 100644 drivers/acpi/pmic/intel_pmic_chtdc_ti.c
 create mode 100644 drivers/mfd/intel_soc_pmic_chtdc_ti.c
 create mode 100644 drivers/platform/x86/intel_chtdc_ti_pwrbtn.c

-- 
2.14.0

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [PATCH v3 1/3] mfd: Add support for Cherry Trail Dollar Cove TI PMIC
  2017-08-25 13:44 [PATCH v3 0/3] Dollar Cove TI PMIC support for Intel Cherry Trail Takashi Iwai
@ 2017-08-25 13:44 ` Takashi Iwai
  2017-08-28 22:31   ` Rafael J. Wysocki
  2017-08-25 13:44 ` [PATCH v3 2/3] platform/x86: Add support for Dollar Cove TI power button Takashi Iwai
  2017-08-25 13:44 ` [PATCH v3 3/3] ACPI / PMIC: Add opregion driver for Intel Dollar Cove TI PMIC Takashi Iwai
  2 siblings, 1 reply; 10+ messages in thread
From: Takashi Iwai @ 2017-08-25 13:44 UTC (permalink / raw)
  To: Lee Jones
  Cc: Darren Hart, Andy Shevchenko, Rafael J . Wysocki,
	Mika Westerberg, Johannes Stezenbach, Hans de Goede,
	platform-driver-x86, linux-acpi, linux-kernel

This patch adds the MFD driver for Dollar Cove (TI version) PMIC with
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: Mika Westerberg <mika.westerberg@linux.intel.com>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
---
v2->v3:
* Rename dc_ti with chtdc_ti in all places
* Driver/kconfig renames accordingly
* Added acks by Andy and Mika
v1->v2:
* Minor cleanups as suggested by Andy

 drivers/mfd/Kconfig                   |  13 +++
 drivers/mfd/Makefile                  |   1 +
 drivers/mfd/intel_soc_pmic_chtdc_ti.c | 183 ++++++++++++++++++++++++++++++++++
 3 files changed, 197 insertions(+)
 create mode 100644 drivers/mfd/intel_soc_pmic_chtdc_ti.c

diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig
index 94ad2c1c3d90..36e7d60f1314 100644
--- a/drivers/mfd/Kconfig
+++ b/drivers/mfd/Kconfig
@@ -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_CHTDC_TI
+	tristate "Support for Intel Cherry Trail 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 version) PMIC
+	  device that is found on some Intel Cherry Trail systems.
+
 config MFD_INTEL_LPSS
 	tristate
 	select COMMON_CLK
diff --git a/drivers/mfd/Makefile b/drivers/mfd/Makefile
index 080793b3fd0e..50ae64d2b22a 100644
--- a/drivers/mfd/Makefile
+++ b/drivers/mfd/Makefile
@@ -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_CHTDC_TI)	+= intel_soc_pmic_chtdc_ti.o
 obj-$(CONFIG_MFD_MT6397)	+= mt6397-core.o
 
 obj-$(CONFIG_MFD_ALTERA_A10SR)	+= altera-a10sr.o
diff --git a/drivers/mfd/intel_soc_pmic_chtdc_ti.c b/drivers/mfd/intel_soc_pmic_chtdc_ti.c
new file mode 100644
index 000000000000..404adb6fc475
--- /dev/null
+++ b/drivers/mfd/intel_soc_pmic_chtdc_ti.c
@@ -0,0 +1,183 @@
+/*
+ * Device access for Dollar Cove TI PMIC
+ * Copyright (c) 2014, Intel Corporation.
+ *   Author: Ramakrishna Pallala <ramakrishna.pallala@intel.com>
+ *
+ * Cleanup and forward-ported
+ *   Copyright (c) 2017 Takashi Iwai <tiwai@suse.de>
+ */
+
+#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 CHTDC_TI_IRQLVL1	0x01
+#define CHTDC_TI_MASK_IRQLVL1	0x02
+
+/* Level 1 IRQs */
+enum {
+	CHTDC_TI_PWRBTN = 0,	/* power button */
+	CHTDC_TI_DIETMPWARN,	/* thermal */
+	CHTDC_TI_ADCCMPL,	/* ADC */
+	/* no irq 3 */
+	CHTDC_TI_VBATLOW = 4,	/* battery */
+	CHTDC_TI_VBUSDET,	/* power source */
+	/* no irq 6 */
+	CHTDC_TI_CCEOCAL = 7,	/* battery */
+};
+
+static struct resource power_button_resources[] = {
+	DEFINE_RES_IRQ(CHTDC_TI_PWRBTN),
+};
+
+static struct resource thermal_resources[] = {
+	DEFINE_RES_IRQ(CHTDC_TI_DIETMPWARN),
+};
+
+static struct resource adc_resources[] = {
+	DEFINE_RES_IRQ(CHTDC_TI_ADCCMPL),
+};
+
+static struct resource pwrsrc_resources[] = {
+	DEFINE_RES_IRQ(CHTDC_TI_VBUSDET),
+};
+
+static struct resource battery_resources[] = {
+	DEFINE_RES_IRQ(CHTDC_TI_VBATLOW),
+	DEFINE_RES_IRQ(CHTDC_TI_CCEOCAL),
+};
+
+static struct mfd_cell chtdc_ti_dev[] = {
+	{
+		.name = "chtdc_ti_pwrbtn",
+		.num_resources = ARRAY_SIZE(power_button_resources),
+		.resources = power_button_resources,
+	},
+	{
+		.name = "chtdc_ti_adc",
+		.num_resources = ARRAY_SIZE(adc_resources),
+		.resources = adc_resources,
+	},
+	{
+		.name = "chtdc_ti_thermal",
+		.num_resources = ARRAY_SIZE(thermal_resources),
+		.resources = thermal_resources,
+	},
+	{
+		.name = "chtdc_ti_pwrsrc",
+		.num_resources = ARRAY_SIZE(pwrsrc_resources),
+		.resources = pwrsrc_resources,
+	},
+	{
+		.name = "chtdc_ti_battery",
+		.num_resources = ARRAY_SIZE(battery_resources),
+		.resources = battery_resources,
+	},
+	{
+		.name = "chtdc_ti_region",
+	},
+};
+
+static const struct regmap_config chtdc_ti_regmap_config = {
+	.reg_bits = 8,
+	.val_bits = 8,
+	.max_register = 128,
+	.cache_type = REGCACHE_NONE,
+};
+
+static const struct regmap_irq chtdc_ti_irqs[] = {
+	REGMAP_IRQ_REG(CHTDC_TI_PWRBTN, 0, BIT(CHTDC_TI_PWRBTN)),
+	REGMAP_IRQ_REG(CHTDC_TI_DIETMPWARN, 0, BIT(CHTDC_TI_DIETMPWARN)),
+	REGMAP_IRQ_REG(CHTDC_TI_ADCCMPL, 0, BIT(CHTDC_TI_ADCCMPL)),
+	REGMAP_IRQ_REG(CHTDC_TI_VBATLOW, 0, BIT(CHTDC_TI_VBATLOW)),
+	REGMAP_IRQ_REG(CHTDC_TI_VBUSDET, 0, BIT(CHTDC_TI_VBUSDET)),
+	REGMAP_IRQ_REG(CHTDC_TI_CCEOCAL, 0, BIT(CHTDC_TI_CCEOCAL)),
+};
+
+static const struct regmap_irq_chip chtdc_ti_irq_chip = {
+	.name = KBUILD_MODNAME,
+	.irqs = chtdc_ti_irqs,
+	.num_irqs = ARRAY_SIZE(chtdc_ti_irqs),
+	.num_regs = 1,
+	.status_base = CHTDC_TI_IRQLVL1,
+	.mask_base = CHTDC_TI_MASK_IRQLVL1,
+	.ack_base = CHTDC_TI_IRQLVL1,
+};
+
+static int chtdc_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, &chtdc_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,
+				       &chtdc_ti_irq_chip,
+				       &pmic->irq_chip_data);
+	if (ret)
+		return ret;
+
+	return devm_mfd_add_devices(dev, PLATFORM_DEVID_NONE, chtdc_ti_dev,
+				    ARRAY_SIZE(chtdc_ti_dev), NULL, 0,
+				    regmap_irq_get_domain(pmic->irq_chip_data));
+}
+
+static void chtdc_ti_shutdown(struct i2c_client *i2c)
+{
+	struct intel_soc_pmic *pmic = i2c_get_clientdata(i2c);
+
+	disable_irq(pmic->irq);
+}
+
+static int __maybe_unused chtdc_ti_suspend(struct device *dev)
+{
+	struct intel_soc_pmic *pmic = dev_get_drvdata(dev);
+
+	disable_irq(pmic->irq);
+	return 0;
+}
+
+static int __maybe_unused chtdc_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(chtdc_ti_pm_ops, chtdc_ti_suspend, chtdc_ti_resume);
+
+static const struct acpi_device_id chtdc_ti_acpi_ids[] = {
+	{ "INT33F5" },
+	{ },
+};
+MODULE_DEVICE_TABLE(acpi, chtdc_ti_acpi_ids);
+
+static struct i2c_driver chtdc_ti_i2c_driver = {
+	.driver = {
+		.name = KBUILD_MODNAME,
+		.pm = &chtdc_ti_pm_ops,
+		.acpi_match_table = chtdc_ti_acpi_ids,
+	},
+	.probe_new = chtdc_ti_probe,
+	.shutdown = chtdc_ti_shutdown,
+};
+module_i2c_driver(chtdc_ti_i2c_driver);
+
+MODULE_DESCRIPTION("I2C driver for Intel SoC Dollar Cove TI PMIC");
+MODULE_LICENSE("GPL v2");
-- 
2.14.0

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH v3 2/3] platform/x86: Add support for Dollar Cove TI power button
  2017-08-25 13:44 [PATCH v3 0/3] Dollar Cove TI PMIC support for Intel Cherry Trail Takashi Iwai
  2017-08-25 13:44 ` [PATCH v3 1/3] mfd: Add support for Cherry Trail Dollar Cove TI PMIC Takashi Iwai
@ 2017-08-25 13:44 ` Takashi Iwai
  2017-08-25 13:44 ` [PATCH v3 3/3] ACPI / PMIC: Add opregion driver for Intel Dollar Cove TI PMIC Takashi Iwai
  2 siblings, 0 replies; 10+ messages in thread
From: Takashi Iwai @ 2017-08-25 13:44 UTC (permalink / raw)
  To: Lee Jones
  Cc: Darren Hart, Andy Shevchenko, Rafael J . Wysocki,
	Mika Westerberg, Johannes Stezenbach, Hans de Goede,
	platform-driver-x86, linux-acpi, linux-kernel

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
Reviewed-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Acked-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
---
v2->v3:
* Rename dc_ti with chtdc_ti in all places
* Driver/kconfig renames accordingly
* Constification
* Added acks by Andy and Mika
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_chtdc_ti_pwrbtn.c | 97 ++++++++++++++++++++++++++++
 3 files changed, 106 insertions(+)
 create mode 100644 drivers/platform/x86/intel_chtdc_ti_pwrbtn.c

diff --git a/drivers/platform/x86/Kconfig b/drivers/platform/x86/Kconfig
index 80b87954f6dd..764c80ce3ea5 100644
--- a/drivers/platform/x86/Kconfig
+++ b/drivers/platform/x86/Kconfig
@@ -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_CHTDC_TI_PWRBTN
+	tristate "Intel Cherry Trail Dollar Cove TI power button driver"
+	depends on INTEL_SOC_PMIC_CHTDC_TI
+	depends on INPUT
+	help
+	  Say Y here fi you want to have a power button driver for
+	  Dollar Cove TI PMIC on Intel Cherry Trail devices.
+
 endif # X86_PLATFORM_DEVICES
 
 config PMC_ATOM
diff --git a/drivers/platform/x86/Makefile b/drivers/platform/x86/Makefile
index 91cec1751461..6a14fdbcecbe 100644
--- a/drivers/platform/x86/Makefile
+++ b/drivers/platform/x86/Makefile
@@ -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_CHTDC_TI_PWRBTN)	+= intel_chtdc_ti_pwrbtn.o
diff --git a/drivers/platform/x86/intel_chtdc_ti_pwrbtn.c b/drivers/platform/x86/intel_chtdc_ti_pwrbtn.c
new file mode 100644
index 000000000000..7cf0eab2be53
--- /dev/null
+++ b/drivers/platform/x86/intel_chtdc_ti_pwrbtn.c
@@ -0,0 +1,97 @@
+/*
+ * Power-button driver for Dollar Cove TI PMIC
+ * Copyright (C) 2014 Intel Corp
+ * Copyright (c) 2017 Takashi Iwai <tiwai@suse.de>
+ */
+
+#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 CHTDC_TI_SIRQ_REG	0x3
+#define SIRQ_PWRBTN_REL		(1 << 0)
+
+static irqreturn_t chtdc_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, CHTDC_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 chtdc_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,
+					chtdc_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 chtdc_ti_pwrbtn_remove(struct platform_device *pdev)
+{
+	dev_pm_clear_wake_irq(&pdev->dev);
+	device_init_wakeup(&pdev->dev, false);
+	return 0;
+}
+
+static const struct platform_device_id chtdc_ti_pwrbtn_id_table[] = {
+	{ .name = "chtdc_ti_pwrbtn" },
+	{},
+};
+MODULE_DEVICE_TABLE(platform, chtdc_ti_pwrbtn_id_table);
+
+static struct platform_driver chtdc_ti_pwrbtn_driver = {
+	.driver = {
+		.name = KBUILD_MODNAME,
+	},
+	.probe	= chtdc_ti_pwrbtn_probe,
+	.remove	= chtdc_ti_pwrbtn_remove,
+	.id_table = chtdc_ti_pwrbtn_id_table,
+};
+module_platform_driver(chtdc_ti_pwrbtn_driver);
+
+MODULE_DESCRIPTION("Power-button driver for Dollar Cove TI PMIC");
+MODULE_LICENSE("GPL v2");
-- 
2.14.0

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH v3 3/3] ACPI / PMIC: Add opregion driver for Intel Dollar Cove TI PMIC
  2017-08-25 13:44 [PATCH v3 0/3] Dollar Cove TI PMIC support for Intel Cherry Trail Takashi Iwai
  2017-08-25 13:44 ` [PATCH v3 1/3] mfd: Add support for Cherry Trail Dollar Cove TI PMIC Takashi Iwai
  2017-08-25 13:44 ` [PATCH v3 2/3] platform/x86: Add support for Dollar Cove TI power button Takashi Iwai
@ 2017-08-25 13:44 ` Takashi Iwai
  2017-08-25 15:24   ` Andy Shevchenko
  2 siblings, 1 reply; 10+ messages in thread
From: Takashi Iwai @ 2017-08-25 13:44 UTC (permalink / raw)
  To: Lee Jones
  Cc: Darren Hart, Andy Shevchenko, Rafael J . Wysocki,
	Mika Westerberg, Johannes Stezenbach, Hans de Goede,
	platform-driver-x86, linux-acpi, linux-kernel

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
Reviewed-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
---
v2->v3:
* Rename dc_ti with chtdc_ti in all places
* Driver/kconfig renames accordingly
* Constification
* Added acks by Andy and Mika
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_chtdc_ti.c | 137 ++++++++++++++++++++++++++++++++
 3 files changed, 144 insertions(+)
 create mode 100644 drivers/acpi/pmic/intel_pmic_chtdc_ti.c

diff --git a/drivers/acpi/Kconfig b/drivers/acpi/Kconfig
index 1ce52f84dc23..2252556d5903 100644
--- a/drivers/acpi/Kconfig
+++ b/drivers/acpi/Kconfig
@@ -521,6 +521,12 @@ config CHT_WC_PMIC_OPREGION
 	help
 	  This config adds ACPI operation region support for CHT Whiskey Cove PMIC.
 
+config CHTDC_TI_PMIC_OPREGION
+	bool "ACPI operation region support for Dollar Cove TI PMIC"
+	depends on INTEL_SOC_PMIC_CHTDC_TI
+	help
+	  This config adds ACPI operation region support for Dollar Cove TI PMIC.
+
 endif
 
 config ACPI_CONFIGFS
diff --git a/drivers/acpi/Makefile b/drivers/acpi/Makefile
index b1aacfc62b1f..9f48343fa99f 100644
--- a/drivers/acpi/Makefile
+++ b/drivers/acpi/Makefile
@@ -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_CHTDC_TI_PMIC_OPREGION) += pmic/intel_pmic_chtdc_ti.o
 
 obj-$(CONFIG_ACPI_CONFIGFS)	+= acpi_configfs.o
 
diff --git a/drivers/acpi/pmic/intel_pmic_chtdc_ti.c b/drivers/acpi/pmic/intel_pmic_chtdc_ti.c
new file mode 100644
index 000000000000..99b69a1737ad
--- /dev/null
+++ b/drivers/acpi/pmic/intel_pmic_chtdc_ti.c
@@ -0,0 +1,137 @@
+/*
+ * Dollar Cove TI PMIC operation region driver
+ * Copyright (C) 2014 Intel Corporation. All rights reserved.
+ *
+ * Rewritten and cleaned up
+ * Copyright (C) 2017 Takashi Iwai <tiwai@suse.de>
+ */
+
+#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 CHTDC_TI_VBAT		0x54
+#define CHTDC_TI_DIETEMP	0x56
+#define CHTDC_TI_BPTHERM	0x58
+#define CHTDC_TI_GPADC		0x5a
+
+static struct pmic_table chtdc_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 chtdc_ti_thermal_table[] = {
+	{
+		.address = 0x00,
+		.reg = CHTDC_TI_GPADC
+	},
+	{
+		.address = 0x0c,
+		.reg = CHTDC_TI_GPADC
+	},
+	/* TMP2 -> SYSTEMP */
+	{
+		.address = 0x18,
+		.reg = CHTDC_TI_GPADC
+	},
+	/* TMP3 -> BPTHERM */
+	{
+		.address = 0x24,
+		.reg = CHTDC_TI_BPTHERM
+	},
+	{
+		.address = 0x30,
+		.reg = CHTDC_TI_GPADC
+	},
+	/* TMP5 -> DIETEMP */
+	{
+		.address = 0x3c,
+		.reg = CHTDC_TI_DIETEMP
+	},
+};
+
+static int chtdc_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 chtdc_ti_pmic_update_power(struct regmap *regmap, int reg, int bit,
+				      bool on)
+{
+	return regmap_update_bits(regmap, reg, 1, on);
+}
+
+static int chtdc_ti_pmic_get_raw_temp(struct regmap *regmap, int reg)
+{
+	u8 buf[2];
+
+	if (regmap_bulk_read(regmap, reg, buf, 2))
+		return -EIO;
+
+	/* stored in big-endian */
+	return ((buf[0] & 0x03) << 8) | buf[1];
+}
+
+static struct intel_pmic_opregion_data chtdc_ti_pmic_opregion_data = {
+	.get_power = chtdc_ti_pmic_get_power,
+	.update_power = chtdc_ti_pmic_update_power,
+	.get_raw_temp = chtdc_ti_pmic_get_raw_temp,
+	.power_table = chtdc_ti_power_table,
+	.power_table_count = ARRAY_SIZE(chtdc_ti_power_table),
+	.thermal_table = chtdc_ti_thermal_table,
+	.thermal_table_count = ARRAY_SIZE(chtdc_ti_thermal_table),
+};
+
+static int chtdc_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,
+			&chtdc_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 const struct platform_device_id chtdc_ti_pmic_opregion_id_table[] = {
+	{ .name = "chtdc_ti_region" },
+	{},
+};
+
+static struct platform_driver chtdc_ti_pmic_opregion_driver = {
+	.probe = chtdc_ti_pmic_opregion_probe,
+	.driver = {
+		.name = "dollar_cove_ti_pmic",
+	},
+	.id_table = chtdc_ti_pmic_opregion_id_table,
+};
+module_platform_driver(chtdc_ti_pmic_opregion_driver);
+
+MODULE_DESCRIPTION("Dollar Cove TI PMIC opregion driver");
+MODULE_LICENSE("GPL v2");
-- 
2.14.0

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* Re: [PATCH v3 3/3] ACPI / PMIC: Add opregion driver for Intel Dollar Cove TI PMIC
  2017-08-25 13:44 ` [PATCH v3 3/3] ACPI / PMIC: Add opregion driver for Intel Dollar Cove TI PMIC Takashi Iwai
@ 2017-08-25 15:24   ` Andy Shevchenko
  2017-08-25 15:38     ` Takashi Iwai
  0 siblings, 1 reply; 10+ messages in thread
From: Andy Shevchenko @ 2017-08-25 15:24 UTC (permalink / raw)
  To: Takashi Iwai
  Cc: Lee Jones, Darren Hart, Andy Shevchenko, Rafael J . Wysocki,
	Mika Westerberg, Johannes Stezenbach, Hans de Goede,
	Platform Driver, linux-acpi, linux-kernel

On Fri, Aug 25, 2017 at 4:44 PM, Takashi Iwai <tiwai@suse.de> wrote:

One really minor nit (fine if it will be ignored):

> +config CHTDC_TI_PMIC_OPREGION

CHTDC_TI_PMIC_OPREGION -> CHT_DC_TI_PMIC_OPREGION

>  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_CHTDC_TI_PMIC_OPREGION) += pmic/intel_pmic_chtdc_ti.o

Ditto (as you can notice by above context).

-- 
With Best Regards,
Andy Shevchenko

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH v3 3/3] ACPI / PMIC: Add opregion driver for Intel Dollar Cove TI PMIC
  2017-08-25 15:24   ` Andy Shevchenko
@ 2017-08-25 15:38     ` Takashi Iwai
  2017-08-26 12:52       ` Rafael J. Wysocki
  0 siblings, 1 reply; 10+ messages in thread
From: Takashi Iwai @ 2017-08-25 15:38 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: Lee Jones, Darren Hart, Andy Shevchenko, Rafael J . Wysocki,
	Mika Westerberg, Johannes Stezenbach, Hans de Goede,
	Platform Driver, linux-acpi, linux-kernel

On Fri, 25 Aug 2017 17:24:19 +0200,
Andy Shevchenko wrote:
> 
> On Fri, Aug 25, 2017 at 4:44 PM, Takashi Iwai <tiwai@suse.de> wrote:
> 
> One really minor nit (fine if it will be ignored):
> 
> > +config CHTDC_TI_PMIC_OPREGION
> 
> CHTDC_TI_PMIC_OPREGION -> CHT_DC_TI_PMIC_OPREGION

Ah, the world is inconsistent...

> >  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_CHTDC_TI_PMIC_OPREGION) += pmic/intel_pmic_chtdc_ti.o
> 
> Ditto (as you can notice by above context).

... where the file name is combined.

I really don't mind, too.

Rafael, please let me know if you want a resubmission with this
correction.


thanks,

Takashi

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH v3 3/3] ACPI / PMIC: Add opregion driver for Intel Dollar Cove TI PMIC
  2017-08-25 15:38     ` Takashi Iwai
@ 2017-08-26 12:52       ` Rafael J. Wysocki
  2017-08-28  6:50         ` [PATCH v4] " Takashi Iwai
  0 siblings, 1 reply; 10+ messages in thread
From: Rafael J. Wysocki @ 2017-08-26 12:52 UTC (permalink / raw)
  To: Takashi Iwai
  Cc: Andy Shevchenko, Lee Jones, Darren Hart, Andy Shevchenko,
	Mika Westerberg, Johannes Stezenbach, Hans de Goede,
	Platform Driver, linux-acpi, linux-kernel

On Friday, August 25, 2017 5:38:11 PM CEST Takashi Iwai wrote:
> On Fri, 25 Aug 2017 17:24:19 +0200,
> Andy Shevchenko wrote:
> > 
> > On Fri, Aug 25, 2017 at 4:44 PM, Takashi Iwai <tiwai@suse.de> wrote:
> > 
> > One really minor nit (fine if it will be ignored):
> > 
> > > +config CHTDC_TI_PMIC_OPREGION
> > 
> > CHTDC_TI_PMIC_OPREGION -> CHT_DC_TI_PMIC_OPREGION
> 
> Ah, the world is inconsistent...
> 
> > >  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_CHTDC_TI_PMIC_OPREGION) += pmic/intel_pmic_chtdc_ti.o
> > 
> > Ditto (as you can notice by above context).
> 
> ... where the file name is combined.
> 
> I really don't mind, too.
> 
> Rafael, please let me know if you want a resubmission with this
> correction.

Yes, please (but just this one patch should be sufficient).

Thanks,
Rafael

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [PATCH v4] ACPI / PMIC: Add opregion driver for Intel Dollar Cove TI PMIC
  2017-08-26 12:52       ` Rafael J. Wysocki
@ 2017-08-28  6:50         ` Takashi Iwai
  0 siblings, 0 replies; 10+ messages in thread
From: Takashi Iwai @ 2017-08-28  6:50 UTC (permalink / raw)
  To: Rafael J. Wysocki
  Cc: Andy Shevchenko, Lee Jones, Darren Hart, Andy Shevchenko,
	Mika Westerberg, Johannes Stezenbach, Hans de Goede,
	Platform Driver, linux-acpi, linux-kernel

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
Reviewed-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
---

I'm resending only this one as v4 patch.

v3->v4:
* Rename CHTDC_* with CHT_DC_* in Kconfig/Makefile
* add cht_ prefix to the driver name string to align with others
v2->v3:
* Rename dc_ti with chtdc_ti in all places
* Driver/kconfig renames accordingly
* Constification
* Added acks by Andy and Mika
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_chtdc_ti.c | 137 ++++++++++++++++++++++++++++++++
 3 files changed, 144 insertions(+)
 create mode 100644 drivers/acpi/pmic/intel_pmic_chtdc_ti.c

diff --git a/drivers/acpi/Kconfig b/drivers/acpi/Kconfig
index 1ce52f84dc23..176fae699891 100644
--- a/drivers/acpi/Kconfig
+++ b/drivers/acpi/Kconfig
@@ -521,6 +521,12 @@ config CHT_WC_PMIC_OPREGION
 	help
 	  This config adds ACPI operation region support for CHT Whiskey Cove PMIC.
 
+config CHT_DC_TI_PMIC_OPREGION
+	bool "ACPI operation region support for Dollar Cove TI PMIC"
+	depends on INTEL_SOC_PMIC_CHTDC_TI
+	help
+	  This config adds ACPI operation region support for Dollar Cove TI PMIC.
+
 endif
 
 config ACPI_CONFIGFS
diff --git a/drivers/acpi/Makefile b/drivers/acpi/Makefile
index b1aacfc62b1f..cd228822d4a3 100644
--- a/drivers/acpi/Makefile
+++ b/drivers/acpi/Makefile
@@ -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_CHT_DC_TI_PMIC_OPREGION) += pmic/intel_pmic_chtdc_ti.o
 
 obj-$(CONFIG_ACPI_CONFIGFS)	+= acpi_configfs.o
 
diff --git a/drivers/acpi/pmic/intel_pmic_chtdc_ti.c b/drivers/acpi/pmic/intel_pmic_chtdc_ti.c
new file mode 100644
index 000000000000..109c1e9c9c7a
--- /dev/null
+++ b/drivers/acpi/pmic/intel_pmic_chtdc_ti.c
@@ -0,0 +1,137 @@
+/*
+ * Dollar Cove TI PMIC operation region driver
+ * Copyright (C) 2014 Intel Corporation. All rights reserved.
+ *
+ * Rewritten and cleaned up
+ * Copyright (C) 2017 Takashi Iwai <tiwai@suse.de>
+ */
+
+#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 CHTDC_TI_VBAT		0x54
+#define CHTDC_TI_DIETEMP	0x56
+#define CHTDC_TI_BPTHERM	0x58
+#define CHTDC_TI_GPADC		0x5a
+
+static struct pmic_table chtdc_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 chtdc_ti_thermal_table[] = {
+	{
+		.address = 0x00,
+		.reg = CHTDC_TI_GPADC
+	},
+	{
+		.address = 0x0c,
+		.reg = CHTDC_TI_GPADC
+	},
+	/* TMP2 -> SYSTEMP */
+	{
+		.address = 0x18,
+		.reg = CHTDC_TI_GPADC
+	},
+	/* TMP3 -> BPTHERM */
+	{
+		.address = 0x24,
+		.reg = CHTDC_TI_BPTHERM
+	},
+	{
+		.address = 0x30,
+		.reg = CHTDC_TI_GPADC
+	},
+	/* TMP5 -> DIETEMP */
+	{
+		.address = 0x3c,
+		.reg = CHTDC_TI_DIETEMP
+	},
+};
+
+static int chtdc_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 chtdc_ti_pmic_update_power(struct regmap *regmap, int reg, int bit,
+				      bool on)
+{
+	return regmap_update_bits(regmap, reg, 1, on);
+}
+
+static int chtdc_ti_pmic_get_raw_temp(struct regmap *regmap, int reg)
+{
+	u8 buf[2];
+
+	if (regmap_bulk_read(regmap, reg, buf, 2))
+		return -EIO;
+
+	/* stored in big-endian */
+	return ((buf[0] & 0x03) << 8) | buf[1];
+}
+
+static struct intel_pmic_opregion_data chtdc_ti_pmic_opregion_data = {
+	.get_power = chtdc_ti_pmic_get_power,
+	.update_power = chtdc_ti_pmic_update_power,
+	.get_raw_temp = chtdc_ti_pmic_get_raw_temp,
+	.power_table = chtdc_ti_power_table,
+	.power_table_count = ARRAY_SIZE(chtdc_ti_power_table),
+	.thermal_table = chtdc_ti_thermal_table,
+	.thermal_table_count = ARRAY_SIZE(chtdc_ti_thermal_table),
+};
+
+static int chtdc_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,
+			&chtdc_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 const struct platform_device_id chtdc_ti_pmic_opregion_id_table[] = {
+	{ .name = "chtdc_ti_region" },
+	{},
+};
+
+static struct platform_driver chtdc_ti_pmic_opregion_driver = {
+	.probe = chtdc_ti_pmic_opregion_probe,
+	.driver = {
+		.name = "cht_dollar_cove_ti_pmic",
+	},
+	.id_table = chtdc_ti_pmic_opregion_id_table,
+};
+module_platform_driver(chtdc_ti_pmic_opregion_driver);
+
+MODULE_DESCRIPTION("Dollar Cove TI PMIC opregion driver");
+MODULE_LICENSE("GPL v2");
-- 
2.14.0


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* Re: [PATCH v3 1/3] mfd: Add support for Cherry Trail Dollar Cove TI PMIC
  2017-08-25 13:44 ` [PATCH v3 1/3] mfd: Add support for Cherry Trail Dollar Cove TI PMIC Takashi Iwai
@ 2017-08-28 22:31   ` Rafael J. Wysocki
  2017-08-29  5:15     ` Takashi Iwai
  0 siblings, 1 reply; 10+ messages in thread
From: Rafael J. Wysocki @ 2017-08-28 22:31 UTC (permalink / raw)
  To: Takashi Iwai
  Cc: Lee Jones, Darren Hart, Andy Shevchenko, Rafael J . Wysocki,
	Mika Westerberg, Johannes Stezenbach, Hans de Goede,
	Platform Driver, ACPI Devel Maling List,
	Linux Kernel Mailing List

On Fri, Aug 25, 2017 at 3:44 PM, Takashi Iwai <tiwai@suse.de> wrote:
> This patch adds the MFD driver for Dollar Cove (TI version) PMIC with
> 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: Mika Westerberg <mika.westerberg@linux.intel.com>
> Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
> Signed-off-by: Takashi Iwai <tiwai@suse.de>

I need an ACK from Lee on this one.

> ---
> v2->v3:
> * Rename dc_ti with chtdc_ti in all places
> * Driver/kconfig renames accordingly
> * Added acks by Andy and Mika
> v1->v2:
> * Minor cleanups as suggested by Andy
>
>  drivers/mfd/Kconfig                   |  13 +++
>  drivers/mfd/Makefile                  |   1 +
>  drivers/mfd/intel_soc_pmic_chtdc_ti.c | 183 ++++++++++++++++++++++++++++++++++
>  3 files changed, 197 insertions(+)
>  create mode 100644 drivers/mfd/intel_soc_pmic_chtdc_ti.c
>
> diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig
> index 94ad2c1c3d90..36e7d60f1314 100644
> --- a/drivers/mfd/Kconfig
> +++ b/drivers/mfd/Kconfig
> @@ -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_CHTDC_TI
> +       tristate "Support for Intel Cherry Trail 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 version) PMIC
> +         device that is found on some Intel Cherry Trail systems.
> +
>  config MFD_INTEL_LPSS
>         tristate
>         select COMMON_CLK
> diff --git a/drivers/mfd/Makefile b/drivers/mfd/Makefile
> index 080793b3fd0e..50ae64d2b22a 100644
> --- a/drivers/mfd/Makefile
> +++ b/drivers/mfd/Makefile
> @@ -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_CHTDC_TI)  += intel_soc_pmic_chtdc_ti.o
>  obj-$(CONFIG_MFD_MT6397)       += mt6397-core.o
>
>  obj-$(CONFIG_MFD_ALTERA_A10SR) += altera-a10sr.o
> diff --git a/drivers/mfd/intel_soc_pmic_chtdc_ti.c b/drivers/mfd/intel_soc_pmic_chtdc_ti.c
> new file mode 100644
> index 000000000000..404adb6fc475
> --- /dev/null
> +++ b/drivers/mfd/intel_soc_pmic_chtdc_ti.c
> @@ -0,0 +1,183 @@
> +/*
> + * Device access for Dollar Cove TI PMIC
> + * Copyright (c) 2014, Intel Corporation.
> + *   Author: Ramakrishna Pallala <ramakrishna.pallala@intel.com>
> + *
> + * Cleanup and forward-ported
> + *   Copyright (c) 2017 Takashi Iwai <tiwai@suse.de>
> + */
> +
> +#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 CHTDC_TI_IRQLVL1       0x01
> +#define CHTDC_TI_MASK_IRQLVL1  0x02
> +
> +/* Level 1 IRQs */
> +enum {
> +       CHTDC_TI_PWRBTN = 0,    /* power button */
> +       CHTDC_TI_DIETMPWARN,    /* thermal */
> +       CHTDC_TI_ADCCMPL,       /* ADC */
> +       /* no irq 3 */
> +       CHTDC_TI_VBATLOW = 4,   /* battery */
> +       CHTDC_TI_VBUSDET,       /* power source */
> +       /* no irq 6 */
> +       CHTDC_TI_CCEOCAL = 7,   /* battery */
> +};
> +
> +static struct resource power_button_resources[] = {
> +       DEFINE_RES_IRQ(CHTDC_TI_PWRBTN),
> +};
> +
> +static struct resource thermal_resources[] = {
> +       DEFINE_RES_IRQ(CHTDC_TI_DIETMPWARN),
> +};
> +
> +static struct resource adc_resources[] = {
> +       DEFINE_RES_IRQ(CHTDC_TI_ADCCMPL),
> +};
> +
> +static struct resource pwrsrc_resources[] = {
> +       DEFINE_RES_IRQ(CHTDC_TI_VBUSDET),
> +};
> +
> +static struct resource battery_resources[] = {
> +       DEFINE_RES_IRQ(CHTDC_TI_VBATLOW),
> +       DEFINE_RES_IRQ(CHTDC_TI_CCEOCAL),
> +};
> +
> +static struct mfd_cell chtdc_ti_dev[] = {
> +       {
> +               .name = "chtdc_ti_pwrbtn",
> +               .num_resources = ARRAY_SIZE(power_button_resources),
> +               .resources = power_button_resources,
> +       },
> +       {
> +               .name = "chtdc_ti_adc",
> +               .num_resources = ARRAY_SIZE(adc_resources),
> +               .resources = adc_resources,
> +       },
> +       {
> +               .name = "chtdc_ti_thermal",
> +               .num_resources = ARRAY_SIZE(thermal_resources),
> +               .resources = thermal_resources,
> +       },
> +       {
> +               .name = "chtdc_ti_pwrsrc",
> +               .num_resources = ARRAY_SIZE(pwrsrc_resources),
> +               .resources = pwrsrc_resources,
> +       },
> +       {
> +               .name = "chtdc_ti_battery",
> +               .num_resources = ARRAY_SIZE(battery_resources),
> +               .resources = battery_resources,
> +       },
> +       {
> +               .name = "chtdc_ti_region",
> +       },
> +};
> +
> +static const struct regmap_config chtdc_ti_regmap_config = {
> +       .reg_bits = 8,
> +       .val_bits = 8,
> +       .max_register = 128,
> +       .cache_type = REGCACHE_NONE,
> +};
> +
> +static const struct regmap_irq chtdc_ti_irqs[] = {
> +       REGMAP_IRQ_REG(CHTDC_TI_PWRBTN, 0, BIT(CHTDC_TI_PWRBTN)),
> +       REGMAP_IRQ_REG(CHTDC_TI_DIETMPWARN, 0, BIT(CHTDC_TI_DIETMPWARN)),
> +       REGMAP_IRQ_REG(CHTDC_TI_ADCCMPL, 0, BIT(CHTDC_TI_ADCCMPL)),
> +       REGMAP_IRQ_REG(CHTDC_TI_VBATLOW, 0, BIT(CHTDC_TI_VBATLOW)),
> +       REGMAP_IRQ_REG(CHTDC_TI_VBUSDET, 0, BIT(CHTDC_TI_VBUSDET)),
> +       REGMAP_IRQ_REG(CHTDC_TI_CCEOCAL, 0, BIT(CHTDC_TI_CCEOCAL)),
> +};
> +
> +static const struct regmap_irq_chip chtdc_ti_irq_chip = {
> +       .name = KBUILD_MODNAME,
> +       .irqs = chtdc_ti_irqs,
> +       .num_irqs = ARRAY_SIZE(chtdc_ti_irqs),
> +       .num_regs = 1,
> +       .status_base = CHTDC_TI_IRQLVL1,
> +       .mask_base = CHTDC_TI_MASK_IRQLVL1,
> +       .ack_base = CHTDC_TI_IRQLVL1,
> +};
> +
> +static int chtdc_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, &chtdc_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,
> +                                      &chtdc_ti_irq_chip,
> +                                      &pmic->irq_chip_data);
> +       if (ret)
> +               return ret;
> +
> +       return devm_mfd_add_devices(dev, PLATFORM_DEVID_NONE, chtdc_ti_dev,
> +                                   ARRAY_SIZE(chtdc_ti_dev), NULL, 0,
> +                                   regmap_irq_get_domain(pmic->irq_chip_data));
> +}
> +
> +static void chtdc_ti_shutdown(struct i2c_client *i2c)
> +{
> +       struct intel_soc_pmic *pmic = i2c_get_clientdata(i2c);
> +
> +       disable_irq(pmic->irq);
> +}
> +
> +static int __maybe_unused chtdc_ti_suspend(struct device *dev)
> +{
> +       struct intel_soc_pmic *pmic = dev_get_drvdata(dev);
> +
> +       disable_irq(pmic->irq);
> +       return 0;
> +}
> +
> +static int __maybe_unused chtdc_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(chtdc_ti_pm_ops, chtdc_ti_suspend, chtdc_ti_resume);
> +
> +static const struct acpi_device_id chtdc_ti_acpi_ids[] = {
> +       { "INT33F5" },
> +       { },
> +};
> +MODULE_DEVICE_TABLE(acpi, chtdc_ti_acpi_ids);
> +
> +static struct i2c_driver chtdc_ti_i2c_driver = {
> +       .driver = {
> +               .name = KBUILD_MODNAME,
> +               .pm = &chtdc_ti_pm_ops,
> +               .acpi_match_table = chtdc_ti_acpi_ids,
> +       },
> +       .probe_new = chtdc_ti_probe,
> +       .shutdown = chtdc_ti_shutdown,
> +};
> +module_i2c_driver(chtdc_ti_i2c_driver);
> +
> +MODULE_DESCRIPTION("I2C driver for Intel SoC Dollar Cove TI PMIC");
> +MODULE_LICENSE("GPL v2");
> --
> 2.14.0
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-acpi" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH v3 1/3] mfd: Add support for Cherry Trail Dollar Cove TI PMIC
  2017-08-28 22:31   ` Rafael J. Wysocki
@ 2017-08-29  5:15     ` Takashi Iwai
  0 siblings, 0 replies; 10+ messages in thread
From: Takashi Iwai @ 2017-08-29  5:15 UTC (permalink / raw)
  To: Rafael J. Wysocki
  Cc: Lee Jones, Darren Hart, Andy Shevchenko, Rafael J . Wysocki,
	Mika Westerberg, Johannes Stezenbach, Hans de Goede,
	Platform Driver, ACPI Devel Maling List,
	Linux Kernel Mailing List

On Tue, 29 Aug 2017 00:31:15 +0200,
Rafael J. Wysocki wrote:
> 
> On Fri, Aug 25, 2017 at 3:44 PM, Takashi Iwai <tiwai@suse.de> wrote:
> > This patch adds the MFD driver for Dollar Cove (TI version) PMIC with
> > 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: Mika Westerberg <mika.westerberg@linux.intel.com>
> > Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
> > Signed-off-by: Takashi Iwai <tiwai@suse.de>
> 
> I need an ACK from Lee on this one.

Yeah, the MFD patch is prerequisite for patches 2 and 3, of course...

Lee, could you review the patch 1?


thanks,

Takashi

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2017-08-29  5:15 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-08-25 13:44 [PATCH v3 0/3] Dollar Cove TI PMIC support for Intel Cherry Trail Takashi Iwai
2017-08-25 13:44 ` [PATCH v3 1/3] mfd: Add support for Cherry Trail Dollar Cove TI PMIC Takashi Iwai
2017-08-28 22:31   ` Rafael J. Wysocki
2017-08-29  5:15     ` Takashi Iwai
2017-08-25 13:44 ` [PATCH v3 2/3] platform/x86: Add support for Dollar Cove TI power button Takashi Iwai
2017-08-25 13:44 ` [PATCH v3 3/3] ACPI / PMIC: Add opregion driver for Intel Dollar Cove TI PMIC Takashi Iwai
2017-08-25 15:24   ` Andy Shevchenko
2017-08-25 15:38     ` Takashi Iwai
2017-08-26 12:52       ` Rafael J. Wysocki
2017-08-28  6:50         ` [PATCH v4] " Takashi Iwai

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.