Re: [PATCH v2 1/3] mfd: Add Cherry Trail Whiskey Cove PMIC driver
Hi, On 23-03-17 17:44, Lee Jones wrote: On Mon, 20 Mar 2017, Hans de Goede wrote: Add mfd driver for Intel CHT Whiskey Cove PMIC, based on various non upstreamed CHT Whiskey Cove PMIC patches. This is a somewhat minimal version which adds irqchip support and cells for: ACPI PMIC opregion support, the i2c-controller driving the external charger irc and the pwrsrc/extcon block. Further cells can be added in the future if/when drivers are upstreamed for them. Cc: Bin GaoCc: Felipe Balbi Cc: Andy Shevchenko Signed-off-by: Hans de Goede Reviewed-by: Andy Shevchenko --- Changes in v2: -Since this uses plain mfd and not the intel_soc_pmic stuff give it its own Kconfig and allow this to be built as a module -Add missing #include Changes in v3: -Drop #include again, not the right fix for the build errors -Error out when the upper byte of the register-address passed to the regmap functions is 0 rather then hardcoding an address in that case -Various minor style tweaks / cleanups -Move defines of regulator register addresses to intel_pmic_chtwc.c, it is the only place where they are used -Drop now empty include/linux/mfd/intel_chtwc.h -Rename intel_soc_pmic_chtwc.c to intel_cht_wc.c to match Kconfig option name -Add irqchip support -Add external charger cell -Add pwrsrc cell Changes in v4: -Use PLATFORM_DEVID_NONE --- drivers/mfd/Kconfig| 11 ++ drivers/mfd/Makefile | 1 + drivers/mfd/intel_soc_pmic_chtwc.c | 244 + 3 files changed, 256 insertions(+) create mode 100644 drivers/mfd/intel_soc_pmic_chtwc.c diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig index 55ecdfb..d427a10 100644 --- a/drivers/mfd/Kconfig +++ b/drivers/mfd/Kconfig @@ -437,6 +437,17 @@ config INTEL_SOC_PMIC thermal, charger and related power management functions on these systems. +config INTEL_SOC_PMIC_CHTWC + tristate "Support for Intel Cherry Trail Whiskey Cove PMIC" + depends on ACPI + depends on I2C Nit: Any reason why these can't be on one line? No, fixed for v5. + select MFD_CORE + select REGMAP_I2C + select REGMAP_IRQ + help + Select this option to enable support for the Intel Cherry Trail + Whiskey Cove PMIC 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 31ce076..d2ca514 100644 --- a/drivers/mfd/Makefile +++ b/drivers/mfd/Makefile @@ -209,6 +209,7 @@ obj-$(CONFIG_MFD_SKY81452) += sky81452.o intel-soc-pmic-objs:= intel_soc_pmic_core.o intel_soc_pmic_crc.o intel-soc-pmic-$(CONFIG_INTEL_PMC_IPC) += intel_soc_pmic_bxtwc.o obj-$(CONFIG_INTEL_SOC_PMIC) += intel-soc-pmic.o +obj-$(CONFIG_INTEL_SOC_PMIC_CHTWC) += intel_soc_pmic_chtwc.o obj-$(CONFIG_MFD_MT6397) += mt6397-core.o obj-$(CONFIG_MFD_ALTERA_A10SR) += altera-a10sr.o diff --git a/drivers/mfd/intel_soc_pmic_chtwc.c b/drivers/mfd/intel_soc_pmic_chtwc.c new file mode 100644 index 000..50aec44 --- /dev/null +++ b/drivers/mfd/intel_soc_pmic_chtwc.c @@ -0,0 +1,244 @@ +/* + * MFD core driver for Intel Cherrytrail Whiskey Cove PMIC + * Copyright (C) 2017 Hans de Goede + * + * Based on various non upstream patches to support the CHT Whiskey Cove PMIC: + * Copyright (C) 2013-2015 Intel Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms and conditions of the GNU General Public License, + * version 2, as published by the Free Software Foundation. + * + * This program is distributed in the hope it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + */ We have a shortened version of the licence now -- any reason why it can't be used here? No reason, fixed for v5. +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +/* PMIC device registers */ +#define REG_OFFSET_MASKGENMASK(7, 0) +#define REG_ADDR_MASK GENMASK(15, 8) +#define REG_ADDR_SHIFT 8 + +#define CHT_WC_IRQLVL1 0x6e02 +#define CHT_WC_IRQLVL1_MASK0x6e0e + +/* Whiskey Cove PMIC share same ACPI ID between different platforms */ +#define CHT_WC_HRV 3 + +/* Level 1 IRQs (level 2 IRQs are handled in the child device drivers) */ +enum { + CHT_WC_PWRSRC_IRQ = 0, + CHT_WC_THRM_IRQ, + CHT_WC_BCU_IRQ, + CHT_WC_ADC_IRQ, + CHT_WC_EXT_CHGR_IRQ, + CHT_WC_GPIO_IRQ, + /* There is no irq 6 */ + CHT_WC_CRIT_IRQ = 7, +}; + +static struct resource cht_wc_pwrsrc_resources[] = { +
Re: [PATCH v2 1/3] mfd: Add Cherry Trail Whiskey Cove PMIC driver
Hi, On 23-03-17 17:44, Lee Jones wrote: On Mon, 20 Mar 2017, Hans de Goede wrote: Add mfd driver for Intel CHT Whiskey Cove PMIC, based on various non upstreamed CHT Whiskey Cove PMIC patches. This is a somewhat minimal version which adds irqchip support and cells for: ACPI PMIC opregion support, the i2c-controller driving the external charger irc and the pwrsrc/extcon block. Further cells can be added in the future if/when drivers are upstreamed for them. Cc: Bin Gao Cc: Felipe Balbi Cc: Andy Shevchenko Signed-off-by: Hans de Goede Reviewed-by: Andy Shevchenko --- Changes in v2: -Since this uses plain mfd and not the intel_soc_pmic stuff give it its own Kconfig and allow this to be built as a module -Add missing #include Changes in v3: -Drop #include again, not the right fix for the build errors -Error out when the upper byte of the register-address passed to the regmap functions is 0 rather then hardcoding an address in that case -Various minor style tweaks / cleanups -Move defines of regulator register addresses to intel_pmic_chtwc.c, it is the only place where they are used -Drop now empty include/linux/mfd/intel_chtwc.h -Rename intel_soc_pmic_chtwc.c to intel_cht_wc.c to match Kconfig option name -Add irqchip support -Add external charger cell -Add pwrsrc cell Changes in v4: -Use PLATFORM_DEVID_NONE --- drivers/mfd/Kconfig| 11 ++ drivers/mfd/Makefile | 1 + drivers/mfd/intel_soc_pmic_chtwc.c | 244 + 3 files changed, 256 insertions(+) create mode 100644 drivers/mfd/intel_soc_pmic_chtwc.c diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig index 55ecdfb..d427a10 100644 --- a/drivers/mfd/Kconfig +++ b/drivers/mfd/Kconfig @@ -437,6 +437,17 @@ config INTEL_SOC_PMIC thermal, charger and related power management functions on these systems. +config INTEL_SOC_PMIC_CHTWC + tristate "Support for Intel Cherry Trail Whiskey Cove PMIC" + depends on ACPI + depends on I2C Nit: Any reason why these can't be on one line? No, fixed for v5. + select MFD_CORE + select REGMAP_I2C + select REGMAP_IRQ + help + Select this option to enable support for the Intel Cherry Trail + Whiskey Cove PMIC 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 31ce076..d2ca514 100644 --- a/drivers/mfd/Makefile +++ b/drivers/mfd/Makefile @@ -209,6 +209,7 @@ obj-$(CONFIG_MFD_SKY81452) += sky81452.o intel-soc-pmic-objs:= intel_soc_pmic_core.o intel_soc_pmic_crc.o intel-soc-pmic-$(CONFIG_INTEL_PMC_IPC) += intel_soc_pmic_bxtwc.o obj-$(CONFIG_INTEL_SOC_PMIC) += intel-soc-pmic.o +obj-$(CONFIG_INTEL_SOC_PMIC_CHTWC) += intel_soc_pmic_chtwc.o obj-$(CONFIG_MFD_MT6397) += mt6397-core.o obj-$(CONFIG_MFD_ALTERA_A10SR) += altera-a10sr.o diff --git a/drivers/mfd/intel_soc_pmic_chtwc.c b/drivers/mfd/intel_soc_pmic_chtwc.c new file mode 100644 index 000..50aec44 --- /dev/null +++ b/drivers/mfd/intel_soc_pmic_chtwc.c @@ -0,0 +1,244 @@ +/* + * MFD core driver for Intel Cherrytrail Whiskey Cove PMIC + * Copyright (C) 2017 Hans de Goede + * + * Based on various non upstream patches to support the CHT Whiskey Cove PMIC: + * Copyright (C) 2013-2015 Intel Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms and conditions of the GNU General Public License, + * version 2, as published by the Free Software Foundation. + * + * This program is distributed in the hope it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + */ We have a shortened version of the licence now -- any reason why it can't be used here? No reason, fixed for v5. +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +/* PMIC device registers */ +#define REG_OFFSET_MASKGENMASK(7, 0) +#define REG_ADDR_MASK GENMASK(15, 8) +#define REG_ADDR_SHIFT 8 + +#define CHT_WC_IRQLVL1 0x6e02 +#define CHT_WC_IRQLVL1_MASK0x6e0e + +/* Whiskey Cove PMIC share same ACPI ID between different platforms */ +#define CHT_WC_HRV 3 + +/* Level 1 IRQs (level 2 IRQs are handled in the child device drivers) */ +enum { + CHT_WC_PWRSRC_IRQ = 0, + CHT_WC_THRM_IRQ, + CHT_WC_BCU_IRQ, + CHT_WC_ADC_IRQ, + CHT_WC_EXT_CHGR_IRQ, + CHT_WC_GPIO_IRQ, + /* There is no irq 6 */ + CHT_WC_CRIT_IRQ = 7, +}; + +static struct resource cht_wc_pwrsrc_resources[] = { + DEFINE_RES_IRQ(CHT_WC_PWRSRC_IRQ), +}; + +static struct resource cht_wc_ext_charger_resources[] = { + DEFINE_RES_IRQ(CHT_WC_EXT_CHGR_IRQ), +}; +
Re: [PATCH v2 1/3] mfd: Add Cherry Trail Whiskey Cove PMIC driver
On Mon, 20 Mar 2017, Hans de Goede wrote: > Add mfd driver for Intel CHT Whiskey Cove PMIC, based on various non > upstreamed CHT Whiskey Cove PMIC patches. > > This is a somewhat minimal version which adds irqchip support and cells > for: ACPI PMIC opregion support, the i2c-controller driving the external > charger irc and the pwrsrc/extcon block. > > Further cells can be added in the future if/when drivers are upstreamed > for them. > > Cc: Bin Gao> Cc: Felipe Balbi > Cc: Andy Shevchenko > Signed-off-by: Hans de Goede > Reviewed-by: Andy Shevchenko > --- > Changes in v2: > -Since this uses plain mfd and not the intel_soc_pmic stuff give it > its own Kconfig and allow this to be built as a module > -Add missing #include > Changes in v3: > -Drop #include again, not the right fix for the build errors > -Error out when the upper byte of the register-address passed to the regmap > functions is 0 rather then hardcoding an address in that case > -Various minor style tweaks / cleanups > -Move defines of regulator register addresses to intel_pmic_chtwc.c, > it is the only place where they are used > -Drop now empty include/linux/mfd/intel_chtwc.h > -Rename intel_soc_pmic_chtwc.c to intel_cht_wc.c to match Kconfig option name > -Add irqchip support > -Add external charger cell > -Add pwrsrc cell > Changes in v4: > -Use PLATFORM_DEVID_NONE > --- > drivers/mfd/Kconfig| 11 ++ > drivers/mfd/Makefile | 1 + > drivers/mfd/intel_soc_pmic_chtwc.c | 244 > + > 3 files changed, 256 insertions(+) > create mode 100644 drivers/mfd/intel_soc_pmic_chtwc.c > > diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig > index 55ecdfb..d427a10 100644 > --- a/drivers/mfd/Kconfig > +++ b/drivers/mfd/Kconfig > @@ -437,6 +437,17 @@ config INTEL_SOC_PMIC > thermal, charger and related power management functions > on these systems. > > +config INTEL_SOC_PMIC_CHTWC > + tristate "Support for Intel Cherry Trail Whiskey Cove PMIC" > + depends on ACPI > + depends on I2C Nit: Any reason why these can't be on one line? > + select MFD_CORE > + select REGMAP_I2C > + select REGMAP_IRQ > + help > + Select this option to enable support for the Intel Cherry Trail > + Whiskey Cove PMIC 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 31ce076..d2ca514 100644 > --- a/drivers/mfd/Makefile > +++ b/drivers/mfd/Makefile > @@ -209,6 +209,7 @@ obj-$(CONFIG_MFD_SKY81452)+= sky81452.o > intel-soc-pmic-objs := intel_soc_pmic_core.o intel_soc_pmic_crc.o > intel-soc-pmic-$(CONFIG_INTEL_PMC_IPC) += intel_soc_pmic_bxtwc.o > obj-$(CONFIG_INTEL_SOC_PMIC) += intel-soc-pmic.o > +obj-$(CONFIG_INTEL_SOC_PMIC_CHTWC) += intel_soc_pmic_chtwc.o > obj-$(CONFIG_MFD_MT6397) += mt6397-core.o > > obj-$(CONFIG_MFD_ALTERA_A10SR) += altera-a10sr.o > diff --git a/drivers/mfd/intel_soc_pmic_chtwc.c > b/drivers/mfd/intel_soc_pmic_chtwc.c > new file mode 100644 > index 000..50aec44 > --- /dev/null > +++ b/drivers/mfd/intel_soc_pmic_chtwc.c > @@ -0,0 +1,244 @@ > +/* > + * MFD core driver for Intel Cherrytrail Whiskey Cove PMIC > + * Copyright (C) 2017 Hans de Goede > + * > + * Based on various non upstream patches to support the CHT Whiskey Cove > PMIC: > + * Copyright (C) 2013-2015 Intel Corporation. All rights reserved. > + * > + * This program is free software; you can redistribute it and/or modify it > + * under the terms and conditions of the GNU General Public License, > + * version 2, as published by the Free Software Foundation. > + * > + * This program is distributed in the hope it will be useful, but WITHOUT > + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or > + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for > + * more details. > + */ We have a shortened version of the licence now -- any reason why it can't be used here? > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > + > +/* PMIC device registers */ > +#define REG_OFFSET_MASK GENMASK(7, 0) > +#define REG_ADDR_MASKGENMASK(15, 8) > +#define REG_ADDR_SHIFT 8 > + > +#define CHT_WC_IRQLVL1 0x6e02 > +#define CHT_WC_IRQLVL1_MASK 0x6e0e > + > +/* Whiskey Cove PMIC share same ACPI ID between different platforms */ > +#define CHT_WC_HRV 3 > + > +/* Level 1 IRQs (level 2 IRQs are handled in the child device drivers) */ > +enum { > + CHT_WC_PWRSRC_IRQ = 0, > + CHT_WC_THRM_IRQ, > + CHT_WC_BCU_IRQ, > + CHT_WC_ADC_IRQ, > +
Re: [PATCH v2 1/3] mfd: Add Cherry Trail Whiskey Cove PMIC driver
On Mon, 20 Mar 2017, Hans de Goede wrote: > Add mfd driver for Intel CHT Whiskey Cove PMIC, based on various non > upstreamed CHT Whiskey Cove PMIC patches. > > This is a somewhat minimal version which adds irqchip support and cells > for: ACPI PMIC opregion support, the i2c-controller driving the external > charger irc and the pwrsrc/extcon block. > > Further cells can be added in the future if/when drivers are upstreamed > for them. > > Cc: Bin Gao > Cc: Felipe Balbi > Cc: Andy Shevchenko > Signed-off-by: Hans de Goede > Reviewed-by: Andy Shevchenko > --- > Changes in v2: > -Since this uses plain mfd and not the intel_soc_pmic stuff give it > its own Kconfig and allow this to be built as a module > -Add missing #include > Changes in v3: > -Drop #include again, not the right fix for the build errors > -Error out when the upper byte of the register-address passed to the regmap > functions is 0 rather then hardcoding an address in that case > -Various minor style tweaks / cleanups > -Move defines of regulator register addresses to intel_pmic_chtwc.c, > it is the only place where they are used > -Drop now empty include/linux/mfd/intel_chtwc.h > -Rename intel_soc_pmic_chtwc.c to intel_cht_wc.c to match Kconfig option name > -Add irqchip support > -Add external charger cell > -Add pwrsrc cell > Changes in v4: > -Use PLATFORM_DEVID_NONE > --- > drivers/mfd/Kconfig| 11 ++ > drivers/mfd/Makefile | 1 + > drivers/mfd/intel_soc_pmic_chtwc.c | 244 > + > 3 files changed, 256 insertions(+) > create mode 100644 drivers/mfd/intel_soc_pmic_chtwc.c > > diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig > index 55ecdfb..d427a10 100644 > --- a/drivers/mfd/Kconfig > +++ b/drivers/mfd/Kconfig > @@ -437,6 +437,17 @@ config INTEL_SOC_PMIC > thermal, charger and related power management functions > on these systems. > > +config INTEL_SOC_PMIC_CHTWC > + tristate "Support for Intel Cherry Trail Whiskey Cove PMIC" > + depends on ACPI > + depends on I2C Nit: Any reason why these can't be on one line? > + select MFD_CORE > + select REGMAP_I2C > + select REGMAP_IRQ > + help > + Select this option to enable support for the Intel Cherry Trail > + Whiskey Cove PMIC 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 31ce076..d2ca514 100644 > --- a/drivers/mfd/Makefile > +++ b/drivers/mfd/Makefile > @@ -209,6 +209,7 @@ obj-$(CONFIG_MFD_SKY81452)+= sky81452.o > intel-soc-pmic-objs := intel_soc_pmic_core.o intel_soc_pmic_crc.o > intel-soc-pmic-$(CONFIG_INTEL_PMC_IPC) += intel_soc_pmic_bxtwc.o > obj-$(CONFIG_INTEL_SOC_PMIC) += intel-soc-pmic.o > +obj-$(CONFIG_INTEL_SOC_PMIC_CHTWC) += intel_soc_pmic_chtwc.o > obj-$(CONFIG_MFD_MT6397) += mt6397-core.o > > obj-$(CONFIG_MFD_ALTERA_A10SR) += altera-a10sr.o > diff --git a/drivers/mfd/intel_soc_pmic_chtwc.c > b/drivers/mfd/intel_soc_pmic_chtwc.c > new file mode 100644 > index 000..50aec44 > --- /dev/null > +++ b/drivers/mfd/intel_soc_pmic_chtwc.c > @@ -0,0 +1,244 @@ > +/* > + * MFD core driver for Intel Cherrytrail Whiskey Cove PMIC > + * Copyright (C) 2017 Hans de Goede > + * > + * Based on various non upstream patches to support the CHT Whiskey Cove > PMIC: > + * Copyright (C) 2013-2015 Intel Corporation. All rights reserved. > + * > + * This program is free software; you can redistribute it and/or modify it > + * under the terms and conditions of the GNU General Public License, > + * version 2, as published by the Free Software Foundation. > + * > + * This program is distributed in the hope it will be useful, but WITHOUT > + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or > + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for > + * more details. > + */ We have a shortened version of the licence now -- any reason why it can't be used here? > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > + > +/* PMIC device registers */ > +#define REG_OFFSET_MASK GENMASK(7, 0) > +#define REG_ADDR_MASKGENMASK(15, 8) > +#define REG_ADDR_SHIFT 8 > + > +#define CHT_WC_IRQLVL1 0x6e02 > +#define CHT_WC_IRQLVL1_MASK 0x6e0e > + > +/* Whiskey Cove PMIC share same ACPI ID between different platforms */ > +#define CHT_WC_HRV 3 > + > +/* Level 1 IRQs (level 2 IRQs are handled in the child device drivers) */ > +enum { > + CHT_WC_PWRSRC_IRQ = 0, > + CHT_WC_THRM_IRQ, > + CHT_WC_BCU_IRQ, > + CHT_WC_ADC_IRQ, > + CHT_WC_EXT_CHGR_IRQ, > + CHT_WC_GPIO_IRQ, > + /* There is no irq 6 */ > + CHT_WC_CRIT_IRQ = 7, > +}; > + > +static struct resource cht_wc_pwrsrc_resources[] = { > +
[PATCH v2 1/3] mfd: Add Cherry Trail Whiskey Cove PMIC driver
Add mfd driver for Intel CHT Whiskey Cove PMIC, based on various non upstreamed CHT Whiskey Cove PMIC patches. This is a somewhat minimal version which adds irqchip support and cells for: ACPI PMIC opregion support, the i2c-controller driving the external charger irc and the pwrsrc/extcon block. Further cells can be added in the future if/when drivers are upstreamed for them. Cc: Bin GaoCc: Felipe Balbi Cc: Andy Shevchenko Signed-off-by: Hans de Goede Reviewed-by: Andy Shevchenko --- Changes in v2: -Since this uses plain mfd and not the intel_soc_pmic stuff give it its own Kconfig and allow this to be built as a module -Add missing #include Changes in v3: -Drop #include again, not the right fix for the build errors -Error out when the upper byte of the register-address passed to the regmap functions is 0 rather then hardcoding an address in that case -Various minor style tweaks / cleanups -Move defines of regulator register addresses to intel_pmic_chtwc.c, it is the only place where they are used -Drop now empty include/linux/mfd/intel_chtwc.h -Rename intel_soc_pmic_chtwc.c to intel_cht_wc.c to match Kconfig option name -Add irqchip support -Add external charger cell -Add pwrsrc cell Changes in v4: -Use PLATFORM_DEVID_NONE --- drivers/mfd/Kconfig| 11 ++ drivers/mfd/Makefile | 1 + drivers/mfd/intel_soc_pmic_chtwc.c | 244 + 3 files changed, 256 insertions(+) create mode 100644 drivers/mfd/intel_soc_pmic_chtwc.c diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig index 55ecdfb..d427a10 100644 --- a/drivers/mfd/Kconfig +++ b/drivers/mfd/Kconfig @@ -437,6 +437,17 @@ config INTEL_SOC_PMIC thermal, charger and related power management functions on these systems. +config INTEL_SOC_PMIC_CHTWC + tristate "Support for Intel Cherry Trail Whiskey Cove PMIC" + depends on ACPI + depends on I2C + select MFD_CORE + select REGMAP_I2C + select REGMAP_IRQ + help + Select this option to enable support for the Intel Cherry Trail + Whiskey Cove PMIC 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 31ce076..d2ca514 100644 --- a/drivers/mfd/Makefile +++ b/drivers/mfd/Makefile @@ -209,6 +209,7 @@ obj-$(CONFIG_MFD_SKY81452) += sky81452.o intel-soc-pmic-objs:= intel_soc_pmic_core.o intel_soc_pmic_crc.o intel-soc-pmic-$(CONFIG_INTEL_PMC_IPC) += intel_soc_pmic_bxtwc.o obj-$(CONFIG_INTEL_SOC_PMIC) += intel-soc-pmic.o +obj-$(CONFIG_INTEL_SOC_PMIC_CHTWC) += intel_soc_pmic_chtwc.o obj-$(CONFIG_MFD_MT6397) += mt6397-core.o obj-$(CONFIG_MFD_ALTERA_A10SR) += altera-a10sr.o diff --git a/drivers/mfd/intel_soc_pmic_chtwc.c b/drivers/mfd/intel_soc_pmic_chtwc.c new file mode 100644 index 000..50aec44 --- /dev/null +++ b/drivers/mfd/intel_soc_pmic_chtwc.c @@ -0,0 +1,244 @@ +/* + * MFD core driver for Intel Cherrytrail Whiskey Cove PMIC + * Copyright (C) 2017 Hans de Goede + * + * Based on various non upstream patches to support the CHT Whiskey Cove PMIC: + * Copyright (C) 2013-2015 Intel Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms and conditions of the GNU General Public License, + * version 2, as published by the Free Software Foundation. + * + * This program is distributed in the hope it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +/* PMIC device registers */ +#define REG_OFFSET_MASKGENMASK(7, 0) +#define REG_ADDR_MASK GENMASK(15, 8) +#define REG_ADDR_SHIFT 8 + +#define CHT_WC_IRQLVL1 0x6e02 +#define CHT_WC_IRQLVL1_MASK0x6e0e + +/* Whiskey Cove PMIC share same ACPI ID between different platforms */ +#define CHT_WC_HRV 3 + +/* Level 1 IRQs (level 2 IRQs are handled in the child device drivers) */ +enum { + CHT_WC_PWRSRC_IRQ = 0, + CHT_WC_THRM_IRQ, + CHT_WC_BCU_IRQ, + CHT_WC_ADC_IRQ, + CHT_WC_EXT_CHGR_IRQ, + CHT_WC_GPIO_IRQ, + /* There is no irq 6 */ + CHT_WC_CRIT_IRQ = 7, +}; + +static struct resource cht_wc_pwrsrc_resources[] = { + DEFINE_RES_IRQ(CHT_WC_PWRSRC_IRQ), +}; + +static struct resource cht_wc_ext_charger_resources[] = { + DEFINE_RES_IRQ(CHT_WC_EXT_CHGR_IRQ), +}; + +static struct mfd_cell cht_wc_dev[] = { + { + .name = "cht_wcove_pwrsrc", +
[PATCH v2 1/3] mfd: Add Cherry Trail Whiskey Cove PMIC driver
Add mfd driver for Intel CHT Whiskey Cove PMIC, based on various non upstreamed CHT Whiskey Cove PMIC patches. This is a somewhat minimal version which adds irqchip support and cells for: ACPI PMIC opregion support, the i2c-controller driving the external charger irc and the pwrsrc/extcon block. Further cells can be added in the future if/when drivers are upstreamed for them. Cc: Bin Gao Cc: Felipe Balbi Cc: Andy Shevchenko Signed-off-by: Hans de Goede Reviewed-by: Andy Shevchenko --- Changes in v2: -Since this uses plain mfd and not the intel_soc_pmic stuff give it its own Kconfig and allow this to be built as a module -Add missing #include Changes in v3: -Drop #include again, not the right fix for the build errors -Error out when the upper byte of the register-address passed to the regmap functions is 0 rather then hardcoding an address in that case -Various minor style tweaks / cleanups -Move defines of regulator register addresses to intel_pmic_chtwc.c, it is the only place where they are used -Drop now empty include/linux/mfd/intel_chtwc.h -Rename intel_soc_pmic_chtwc.c to intel_cht_wc.c to match Kconfig option name -Add irqchip support -Add external charger cell -Add pwrsrc cell Changes in v4: -Use PLATFORM_DEVID_NONE --- drivers/mfd/Kconfig| 11 ++ drivers/mfd/Makefile | 1 + drivers/mfd/intel_soc_pmic_chtwc.c | 244 + 3 files changed, 256 insertions(+) create mode 100644 drivers/mfd/intel_soc_pmic_chtwc.c diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig index 55ecdfb..d427a10 100644 --- a/drivers/mfd/Kconfig +++ b/drivers/mfd/Kconfig @@ -437,6 +437,17 @@ config INTEL_SOC_PMIC thermal, charger and related power management functions on these systems. +config INTEL_SOC_PMIC_CHTWC + tristate "Support for Intel Cherry Trail Whiskey Cove PMIC" + depends on ACPI + depends on I2C + select MFD_CORE + select REGMAP_I2C + select REGMAP_IRQ + help + Select this option to enable support for the Intel Cherry Trail + Whiskey Cove PMIC 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 31ce076..d2ca514 100644 --- a/drivers/mfd/Makefile +++ b/drivers/mfd/Makefile @@ -209,6 +209,7 @@ obj-$(CONFIG_MFD_SKY81452) += sky81452.o intel-soc-pmic-objs:= intel_soc_pmic_core.o intel_soc_pmic_crc.o intel-soc-pmic-$(CONFIG_INTEL_PMC_IPC) += intel_soc_pmic_bxtwc.o obj-$(CONFIG_INTEL_SOC_PMIC) += intel-soc-pmic.o +obj-$(CONFIG_INTEL_SOC_PMIC_CHTWC) += intel_soc_pmic_chtwc.o obj-$(CONFIG_MFD_MT6397) += mt6397-core.o obj-$(CONFIG_MFD_ALTERA_A10SR) += altera-a10sr.o diff --git a/drivers/mfd/intel_soc_pmic_chtwc.c b/drivers/mfd/intel_soc_pmic_chtwc.c new file mode 100644 index 000..50aec44 --- /dev/null +++ b/drivers/mfd/intel_soc_pmic_chtwc.c @@ -0,0 +1,244 @@ +/* + * MFD core driver for Intel Cherrytrail Whiskey Cove PMIC + * Copyright (C) 2017 Hans de Goede + * + * Based on various non upstream patches to support the CHT Whiskey Cove PMIC: + * Copyright (C) 2013-2015 Intel Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms and conditions of the GNU General Public License, + * version 2, as published by the Free Software Foundation. + * + * This program is distributed in the hope it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +/* PMIC device registers */ +#define REG_OFFSET_MASKGENMASK(7, 0) +#define REG_ADDR_MASK GENMASK(15, 8) +#define REG_ADDR_SHIFT 8 + +#define CHT_WC_IRQLVL1 0x6e02 +#define CHT_WC_IRQLVL1_MASK0x6e0e + +/* Whiskey Cove PMIC share same ACPI ID between different platforms */ +#define CHT_WC_HRV 3 + +/* Level 1 IRQs (level 2 IRQs are handled in the child device drivers) */ +enum { + CHT_WC_PWRSRC_IRQ = 0, + CHT_WC_THRM_IRQ, + CHT_WC_BCU_IRQ, + CHT_WC_ADC_IRQ, + CHT_WC_EXT_CHGR_IRQ, + CHT_WC_GPIO_IRQ, + /* There is no irq 6 */ + CHT_WC_CRIT_IRQ = 7, +}; + +static struct resource cht_wc_pwrsrc_resources[] = { + DEFINE_RES_IRQ(CHT_WC_PWRSRC_IRQ), +}; + +static struct resource cht_wc_ext_charger_resources[] = { + DEFINE_RES_IRQ(CHT_WC_EXT_CHGR_IRQ), +}; + +static struct mfd_cell cht_wc_dev[] = { + { + .name = "cht_wcove_pwrsrc", + .num_resources = ARRAY_SIZE(cht_wc_pwrsrc_resources), + .resources = cht_wc_pwrsrc_resources, + }, + { + .name =