Re: [PATCH v2 9/9] mfd: mt6360: Merge different sub-devices i2c read/write
Lee Jones 於 2020年7月29日 週三 下午6:12寫道: > > On Wed, 29 Jul 2020, Gene Chen wrote: > > > Lee Jones 於 2020年7月27日 週一 下午8:43寫道: > > > > > > On Fri, 17 Jul 2020, Gene Chen wrote: > > > > > > > From: Gene Chen > > > > > > > > Remove unuse register definition. > > > > > > This should not be in here. > > > > > > > Merge different sub-devices i2c read/write function into one regmap, > > > > > > "I2C", "functions", "Regmap". > > > > > > > ACK > > > > > > because pmic and ldo part need crc bits for access protection. > > > > > > "PMIC", "LDO", "CRC". > > > > > > > ACK > > > > > > Signed-off-by: Gene Chen > > > > --- > > > > drivers/mfd/Kconfig| 1 + > > > > drivers/mfd/mt6360-core.c | 229 > > > > +- > > > > include/linux/mfd/mt6360.h | 240 > > > > - > > > > 3 files changed, 204 insertions(+), 266 deletions(-) > > > > delete mode 100644 include/linux/mfd/mt6360.h > > > > > > > > diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig > > > > index a37d7d1..0684ddc 100644 > > > > --- a/drivers/mfd/Kconfig > > > > +++ b/drivers/mfd/Kconfig > > > > @@ -913,6 +913,7 @@ config MFD_MT6360 > > > > select MFD_CORE > > > > select REGMAP_I2C > > > > select REGMAP_IRQ > > > > + select CRC8 > > > > depends on I2C > > > > help > > > > Say Y here to enable MT6360 PMU/PMIC/LDO functional support. > > > > diff --git a/drivers/mfd/mt6360-core.c b/drivers/mfd/mt6360-core.c > > > > index 3186a7c..97ef1ad 100644 > > > > --- a/drivers/mfd/mt6360-core.c > > > > +++ b/drivers/mfd/mt6360-core.c > > > > @@ -14,7 +14,46 @@ > > > > #include > > > > #include > > > > > > > > -#include > > > > +enum { > > > > + MT6360_SLAVE_TCPC = 0, > > > > + MT6360_SLAVE_PMIC, > > > > + MT6360_SLAVE_LDO, > > > > + MT6360_SLAVE_PMU, > > > > + MT6360_SLAVE_MAX, > > > > +}; > > > > + > > > > +struct mt6360_data { > > > > + struct i2c_client *i2c[MT6360_SLAVE_MAX]; > > > > + struct device *dev; > > > > + struct regmap *regmap; > > > > + struct regmap_irq_chip_data *irq_data; > > > > + unsigned int chip_rev;mt6360_data > > > > + u8 crc8_tbl[CRC8_TABLE_SIZE]; > > > > +}; > > > > > > Make sure all of these entries are still used. > > > > > > > +#define MT6360_PMU_SLAVEID 0x34 > > > > +#define MT6360_PMIC_SLAVEID 0x1A > > > > +#define MT6360_LDO_SLAVEID 0x64 > > > > +#define MT6360_TCPC_SLAVEID 0x4E > > > > > > Can these be placed into ID order? > > > > > > > ACK > > > > > > +#define MT6360_REG_TCPCSTART 0x00 > > > > +#define MT6360_REG_TCPCEND 0xFF > > > > +#define MT6360_REG_PMICSTART 0x100 > > > > +#define MT6360_REG_PMICEND 0x13B > > > > +#define MT6360_REG_LDOSTART 0x200 > > > > +#define MT6360_REG_LDOEND0x21C > > > > +#define MT6360_REG_PMUSTART 0x300 > > > > +#define MT6360_PMU_DEV_INFO 0x300 > > > > +#define MT6360_PMU_CHG_IRQ1 0x3D0 > > > > +#define MT6360_PMU_CHG_MASK1 0x3F0 > > > > +#define MT6360_REG_PMUEND0x3FF > > > > + > > > > +/* from 0x3D0 to 0x3DF */ > > > > > > We don't need this in here. > > > > > > > ACK > > > > > > +#define MT6360_PMU_IRQ_REGNUM16 > > > > + > > > > +#define CHIP_VEN_MASK0xF0 > > > > +#define CHIP_VEN_MT6360 0x50 > > > > +#define CHIP_REV_MASK0x0F > > > > > > > > /* reg 0 -> 0 ~ 7 */ > > > > #define MT6360_CHG_TREG_EVT 4 > > > > @@ -220,12 +259,6 @@ static const struct regmap_irq_chip > > > > mt6360_irq_chip = { > > > > .use_ack = true, >
Re: [PATCH v2 9/9] mfd: mt6360: Merge different sub-devices i2c read/write
Gene Chen 於 2020年7月30日 週四 上午10:56寫道: > > Lee Jones 於 2020年7月29日 週三 下午6:12寫道: > > > > On Wed, 29 Jul 2020, Gene Chen wrote: > > > > > Lee Jones 於 2020年7月27日 週一 下午8:43寫道: > > > > > > > > On Fri, 17 Jul 2020, Gene Chen wrote: > > > > > > > > > From: Gene Chen > > > > > > > > > > Remove unuse register definition. > > > > > > > > This should not be in here. > > > > > > > > > Merge different sub-devices i2c read/write function into one regmap, > > > > > > > > "I2C", "functions", "Regmap". > > > > > > > > > > ACK > > > > > > > > because pmic and ldo part need crc bits for access protection. > > > > > > > > "PMIC", "LDO", "CRC". > > > > > > > > > > ACK > > > > > > > > Signed-off-by: Gene Chen > > > > > --- > > > > > drivers/mfd/Kconfig| 1 + > > > > > drivers/mfd/mt6360-core.c | 229 > > > > > +- > > > > > include/linux/mfd/mt6360.h | 240 > > > > > - > > > > > 3 files changed, 204 insertions(+), 266 deletions(-) > > > > > delete mode 100644 include/linux/mfd/mt6360.h > > > > > > > > > > diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig > > > > > index a37d7d1..0684ddc 100644 > > > > > --- a/drivers/mfd/Kconfig > > > > > +++ b/drivers/mfd/Kconfig > > > > > @@ -913,6 +913,7 @@ config MFD_MT6360 > > > > > select MFD_CORE > > > > > select REGMAP_I2C > > > > > select REGMAP_IRQ > > > > > + select CRC8 > > > > > depends on I2C > > > > > help > > > > > Say Y here to enable MT6360 PMU/PMIC/LDO functional support. > > > > > diff --git a/drivers/mfd/mt6360-core.c b/drivers/mfd/mt6360-core.c > > > > > index 3186a7c..97ef1ad 100644 > > > > > --- a/drivers/mfd/mt6360-core.c > > > > > +++ b/drivers/mfd/mt6360-core.c > > > > > @@ -14,7 +14,46 @@ > > > > > #include > > > > > #include > > > > > > > > > > -#include > > > > > +enum { > > > > > + MT6360_SLAVE_TCPC = 0, > > > > > + MT6360_SLAVE_PMIC, > > > > > + MT6360_SLAVE_LDO, > > > > > + MT6360_SLAVE_PMU, > > > > > + MT6360_SLAVE_MAX, > > > > > +}; > > > > > + > > > > > +struct mt6360_data { > > > > > + struct i2c_client *i2c[MT6360_SLAVE_MAX]; > > > > > + struct device *dev; > > > > > + struct regmap *regmap; > > > > > + struct regmap_irq_chip_data *irq_data; > > > > > + unsigned int chip_rev;mt6360_data > > > > > + u8 crc8_tbl[CRC8_TABLE_SIZE]; > > > > > +}; > > > > > > > > Make sure all of these entries are still used. > > > > > > > > > +#define MT6360_PMU_SLAVEID 0x34 > > > > > +#define MT6360_PMIC_SLAVEID 0x1A > > > > > +#define MT6360_LDO_SLAVEID 0x64 > > > > > +#define MT6360_TCPC_SLAVEID 0x4E > > > > > > > > Can these be placed into ID order? > > > > > > > > > > ACK > > > > > > > > +#define MT6360_REG_TCPCSTART 0x00 > > > > > +#define MT6360_REG_TCPCEND 0xFF > > > > > +#define MT6360_REG_PMICSTART 0x100 > > > > > +#define MT6360_REG_PMICEND 0x13B > > > > > +#define MT6360_REG_LDOSTART 0x200 > > > > > +#define MT6360_REG_LDOEND0x21C > > > > > +#define MT6360_REG_PMUSTART 0x300 > > > > > +#define MT6360_PMU_DEV_INFO 0x300 > > > > > +#define MT6360_PMU_CHG_IRQ1 0x3D0 > > > > > +#define MT6360_PMU_CHG_MASK1 0x3F0 > > > > > +#define MT6360_REG_PMUEND0x3FF > > > > > + > > > > > +/* from 0x3D0 to 0x3DF */ > > > > > > > > We don't need this in here. > > > > > > > > > > ACK > > &g
Re: [PATCH v2 4/9] mfd: mt6360: Combine mt6360 pmic/ldo resouces into mt6360 regulator resources
Lee Jones 於 2020年7月28日 週二 下午2:54寫道: > > On Tue, 28 Jul 2020, Gene Chen wrote: > > > Lee Jones 於 2020年7月27日 週一 下午7:29寫道: > > > > > > On Fri, 17 Jul 2020, Gene Chen wrote: > > > > > > > From: Gene Chen > > > > > > > > Combine mt6360 pmic/ldo resouces into mt6360 regulator resources > > > > to simplify the similar resources object. > > > > > > Do the sub-devices actually share these resources, or are you doing > > > this just to make the code simpler? > > > > > > > They are different resources used by different bucks and ldos without > > sharing relations. > > I just to make the code simpler. > > I don't think that's sensible. > > You should only share resources with child devices that consume them. > At first, I separated regulators into two drivers, mt6360-pmic.c and mt6360-ldo.c, according to default-on power or not. Then, I merged two drivers into mt6360-regulator.c and merged their resources as well. Therefore, for every device of BUCK/LDO, I'll find resources according to their name and request IRQs. > > > > Signed-off-by: Gene Chen > > > > --- > > > > drivers/mfd/mt6360-core.c | 11 +++ > > > > 1 file changed, 3 insertions(+), 8 deletions(-) > > > > > > > > diff --git a/drivers/mfd/mt6360-core.c b/drivers/mfd/mt6360-core.c > > > > index 7cc1b59..665e26f 100644 > > > > --- a/drivers/mfd/mt6360-core.c > > > > +++ b/drivers/mfd/mt6360-core.c > > > > @@ -265,7 +265,7 @@ static const struct resource mt6360_led_resources[] > > > > = { > > > > DEFINE_RES_IRQ_NAMED(MT6360_FLED1_STRB_TO_EVT, > > > > "fled1_strb_to_evt"), > > > > }; > > > > > > > > -static const struct resource mt6360_pmic_resources[] = { > > > > +static const struct resource mt6360_regulator_resources[] = { > > > > DEFINE_RES_IRQ_NAMED(MT6360_BUCK1_PGB_EVT, "buck1_pgb_evt"), > > > > DEFINE_RES_IRQ_NAMED(MT6360_BUCK1_OC_EVT, "buck1_oc_evt"), > > > > DEFINE_RES_IRQ_NAMED(MT6360_BUCK1_OV_EVT, "buck1_ov_evt"), > > > > @@ -278,9 +278,6 @@ static const struct resource > > > > mt6360_pmic_resources[] = { > > > > DEFINE_RES_IRQ_NAMED(MT6360_LDO7_OC_EVT, "ldo7_oc_evt"), > > > > DEFINE_RES_IRQ_NAMED(MT6360_LDO6_PGB_EVT, "ldo6_pgb_evt"), > > > > DEFINE_RES_IRQ_NAMED(MT6360_LDO7_PGB_EVT, "ldo7_pgb_evt"), > > > > -}; > > > > - > > > > -static const struct resource mt6360_ldo_resources[] = { > > > > DEFINE_RES_IRQ_NAMED(MT6360_LDO1_OC_EVT, "ldo1_oc_evt"), > > > > DEFINE_RES_IRQ_NAMED(MT6360_LDO2_OC_EVT, "ldo2_oc_evt"), > > > > DEFINE_RES_IRQ_NAMED(MT6360_LDO3_OC_EVT, "ldo3_oc_evt"), > > > > @@ -298,10 +295,8 @@ static const struct mfd_cell mt6360_devs[] = { > > > > NULL, 0, 0, "mediatek,mt6360-chg"), > > > > OF_MFD_CELL("mt6360-led", mt6360_led_resources, > > > > NULL, 0, 0, "mediatek,mt6360-led"), > > > > - OF_MFD_CELL("mt6360-pmic", mt6360_pmic_resources, > > > > - NULL, 0, 0, "mediatek,mt6360-pmic"), > > > > - OF_MFD_CELL("mt6360-ldo", mt6360_ldo_resources, > > > > - NULL, 0, 0, "mediatek,mt6360-ldo"), > > > > + OF_MFD_CELL("mt6360-regulator", mt6360_regulator_resources, > > > > + NULL, 0, 0, "mediatek,mt6360-regulator"), > > > > OF_MFD_CELL("mt6360-tcpc", NULL, > > > > NULL, 0, 0, "mediatek,mt6360-tcpc"), > > > > }; > > > > > -- > Lee Jones [李琼斯] > Senior Technical Lead - Developer Services > Linaro.org │ Open source software for Arm SoCs > Follow Linaro: Facebook | Twitter | Blog
[PATCH v3 0/2] regulator: mt6360: Add support for MT6360 regulator
This patch series add MT6360 regulator support contains driver and binding document Gene Chen (2) regulator: mt6360: Add support for MT6360 regulator regulator: mt6360: Add DT binding documentation Documentation/devicetree/bindings/regulator/mt6360-regulator.yaml | 109 ++ drivers/regulator/Kconfig |9 drivers/regulator/Makefile|1 drivers/regulator/mt6360-regulator.c | 458 ++ include/dt-bindings/regulator/mediatek,mt6360-regulator.h | 16 5 files changed, 593 insertions(+) changelogs between v1 & v2 - regulator: merge regmap to mfd driver for r/w with crc changelogs between v2 & v3 - Move regmap define to MFD parent driver - Add bindings document
[PATCH v3 2/2] regulator: mt6360: Add DT binding documentation
From: Gene Chen Add a devicetree binding documentation for the mt6360 regulator driver. Signed-off-by: Gene Chen --- .../bindings/regulator/mt6360-regulator.yaml | 109 + 1 file changed, 109 insertions(+) create mode 100644 Documentation/devicetree/bindings/regulator/mt6360-regulator.yaml diff --git a/Documentation/devicetree/bindings/regulator/mt6360-regulator.yaml b/Documentation/devicetree/bindings/regulator/mt6360-regulator.yaml new file mode 100644 index 000..bd66754 --- /dev/null +++ b/Documentation/devicetree/bindings/regulator/mt6360-regulator.yaml @@ -0,0 +1,109 @@ +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/regulator/mt6360-regulator.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: MT6360 Regulator from MediaTek Integrated + +maintainers: + - Gene Chen + +description: | + list of regulators provided by this controller, must be named + after their hardware counterparts buck1/2 or ldo1/2/3/5/6/7 + +properties: + compatible: +const: mediatek,mt6360-regulator + + LDO_VIN3-supply: +description: Input supply phandle(s) for LDO3 + +patternProperties: + "^buck[12]$": +$ref: "regulator.yaml#" + + "^ldo[123567]$": +$ref: "regulator.yaml#" + +required: + - compatible + +additionalProperties: false + +examples: + - | +#include +#include +regulator { + compatible = "mediatek,mt6360-regulator"; + LDO_VIN3-supply = <&BUCK2>; + buck1 { +regulator-compatible = "BUCK1"; +regulator-name = "mt6360,buck1"; +regulator-min-microvolt = <30>; +regulator-max-microvolt = <130>; +regulator-allowed-modes = ; + }; + BUCK2: buck2 { +regulator-compatible = "BUCK2"; +regulator-name = "mt6360,buck2"; +regulator-min-microvolt = <30>; +regulator-max-microvolt = <130>; +regulator-allowed-modes = ; + }; + ldo6 { +regulator-compatible = "LDO6"; +regulator-name = "mt6360,ldo6"; +regulator-min-microvolt = <50>; +regulator-max-microvolt = <210>; +regulator-allowed-modes = ; + }; + ldo7 { +regulator-compatible = "LDO7"; +regulator-name = "mt6360,ldo7"; +regulator-min-microvolt = <50>; +regulator-max-microvolt = <210>; +regulator-allowed-modes = ; + }; + ldo1 { +regulator-compatible = "LDO1"; +regulator-name = "mt6360,ldo1"; +regulator-min-microvolt = <120>; +regulator-max-microvolt = <360>; +regulator-allowed-modes = ; + }; +ldo2 { +regulator-compatible = "LDO2"; +regulator-name = "mt6360,ldo2"; +regulator-min-microvolt = <120>; +regulator-max-microvolt = <360>; +regulator-allowed-modes = ; + }; + ldo3 { +regulator-compatible = "LDO3"; +regulator-name = "mt6360,ldo3"; +regulator-min-microvolt = <120>; +regulator-max-microvolt = <360>; +regulator-allowed-modes = ; + }; + ldo5 { +regulator-compatible = "LDO5"; +regulator-name = "mt6360,ldo5"; +regulator-min-microvolt = <270>; +regulator-max-microvolt = <360>; +regulator-allowed-modes = ; + }; +}; +... -- 2.7.4
[PATCH v3 1/2] regulator: mt6360: Add support for MT6360 regulator
From: Gene Chen Add MT6360 regulator driver that contains two BUCKs and six LDOs Signed-off-by: Gene Chen --- drivers/regulator/Kconfig | 9 + drivers/regulator/Makefile | 1 + drivers/regulator/mt6360-regulator.c | 458 + .../regulator/mediatek,mt6360-regulator.h | 16 + 4 files changed, 484 insertions(+) create mode 100644 drivers/regulator/mt6360-regulator.c create mode 100644 include/dt-bindings/regulator/mediatek,mt6360-regulator.h diff --git a/drivers/regulator/Kconfig b/drivers/regulator/Kconfig index de17ef7..8a6c3c6 100644 --- a/drivers/regulator/Kconfig +++ b/drivers/regulator/Kconfig @@ -711,6 +711,15 @@ config REGULATOR_MT6358 This driver supports the control of different power rails of device through regulator interface. +config REGULATOR_MT6360 + tristate "MT6360 SubPMIC Regulator" + depends on MFD_MT6360 + help + Say Y here to enable MT6360 regulator support. + This is support MT6360 PMIC/LDO part include + 2-channel buck with Thermal Shutdown and Overload Protection + 6-channel High PSRR and Low Dropout LDO. + config REGULATOR_MT6380 tristate "MediaTek MT6380 PMIC" depends on MTK_PMIC_WRAP diff --git a/drivers/regulator/Makefile b/drivers/regulator/Makefile index d8d3ecf..821a33f 100644 --- a/drivers/regulator/Makefile +++ b/drivers/regulator/Makefile @@ -88,6 +88,7 @@ obj-$(CONFIG_REGULATOR_MPQ7920) += mpq7920.o obj-$(CONFIG_REGULATOR_MT6311) += mt6311-regulator.o obj-$(CONFIG_REGULATOR_MT6323) += mt6323-regulator.o obj-$(CONFIG_REGULATOR_MT6358) += mt6358-regulator.o +obj-$(CONFIG_REGULATOR_MT6360) += mt6360-regulator.o obj-$(CONFIG_REGULATOR_MT6380) += mt6380-regulator.o obj-$(CONFIG_REGULATOR_MT6397) += mt6397-regulator.o obj-$(CONFIG_REGULATOR_QCOM_LABIBB) += qcom-labibb-regulator.o diff --git a/drivers/regulator/mt6360-regulator.c b/drivers/regulator/mt6360-regulator.c new file mode 100644 index 000..f01d1cc --- /dev/null +++ b/drivers/regulator/mt6360-regulator.c @@ -0,0 +1,458 @@ +// SPDX-License-Identifier: GPL-2.0-only +// +// Copyright (C) 2020 MediaTek Inc. +// +// Author: Gene Chen + +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +enum { + MT6360_REGULATOR_BUCK1 = 0, + MT6360_REGULATOR_BUCK2, + MT6360_REGULATOR_LDO6, + MT6360_REGULATOR_LDO7, + MT6360_REGULATOR_LDO1, + MT6360_REGULATOR_LDO2, + MT6360_REGULATOR_LDO3, + MT6360_REGULATOR_LDO5, + MT6360_REGULATOR_MAX, +}; + +struct mt6360_irq_mapping { + const char *name; + irq_handler_t handler; +}; + +struct mt6360_regulator_desc { + const struct regulator_desc desc; + unsigned int mode_reg; + unsigned int mode_mask; + unsigned int state_reg; + unsigned int state_mask; + const struct mt6360_irq_mapping *irq_tables; + int irq_table_size; +}; + +struct mt6360_regulator_data { + struct device *dev; + struct regmap *regmap; +}; + +static irqreturn_t mt6360_pgb_event_handler(int irq, void *data) +{ + struct regulator_dev *rdev = data; + + regulator_notifier_call_chain(rdev, REGULATOR_EVENT_FAIL, NULL); + return IRQ_HANDLED; +} + +static irqreturn_t mt6360_oc_event_handler(int irq, void *data) +{ + struct regulator_dev *rdev = data; + + regulator_notifier_call_chain(rdev, REGULATOR_EVENT_OVER_CURRENT, NULL); + return IRQ_HANDLED; +} + +static irqreturn_t mt6360_ov_event_handler(int irq, void *data) +{ + struct regulator_dev *rdev = data; + + regulator_notifier_call_chain(rdev, REGULATOR_EVENT_REGULATION_OUT, NULL); + return IRQ_HANDLED; +} + +static irqreturn_t mt6360_uv_event_handler(int irq, void *data) +{ + struct regulator_dev *rdev = data; + + regulator_notifier_call_chain(rdev, REGULATOR_EVENT_UNDER_VOLTAGE, NULL); + return IRQ_HANDLED; +} + +static const struct mt6360_irq_mapping buck1_irq_tbls[] = { + { "buck1_pgb_evt", mt6360_pgb_event_handler }, + { "buck1_oc_evt", mt6360_oc_event_handler }, + { "buck1_ov_evt", mt6360_ov_event_handler }, + { "buck1_uv_evt", mt6360_uv_event_handler }, +}; + +static const struct mt6360_irq_mapping buck2_irq_tbls[] = { + { "buck2_pgb_evt", mt6360_pgb_event_handler }, + { "buck2_oc_evt", mt6360_oc_event_handler }, + { "buck2_ov_evt", mt6360_ov_event_handler }, + { "buck2_uv_evt", mt6360_uv_event_handler }, +}; + +static const struct mt6360_irq_mapping ldo6_irq_tbls[] = { + { "ldo6_pgb_evt", mt6360_pgb_event_handler }, + { "ldo6_oc_evt", mt6360_oc_event_handler }, +}; + +static const struct mt6360_irq_mapping ldo7_irq_tbls[] = { + { "ldo7_pgb_evt", mt6360_pg
[PATCH] dt-bindings: mfd: mediatek: Add bindings for MT6360 PMIC
From: Gene Chen Add bindings for MT6360 PMIC Signed-off-by: Gene Chen --- Documentation/devicetree/bindings/mfd/mt6360.yaml | 142 ++ 1 file changed, 142 insertions(+) create mode 100644 Documentation/devicetree/bindings/mfd/mt6360.yaml diff --git a/Documentation/devicetree/bindings/mfd/mt6360.yaml b/Documentation/devicetree/bindings/mfd/mt6360.yaml new file mode 100644 index 000..5ad1afd --- /dev/null +++ b/Documentation/devicetree/bindings/mfd/mt6360.yaml @@ -0,0 +1,142 @@ +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/mfd/mt6360.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: MT6360 PMIC from MediaTek Integrated + +maintainers: + - Gene Chen + +description: | + MT6360 is a PMIC device with the following sub modules. + It is interfaced to host controller using I2C interface. + + This document describes the binding for PMIC device and its sub module. + +properties: + compatible: +const: mediatek,mt6360 + + reg: +description: + I2C device address. +maxItems: 1 + + wakeup-source: true + + interrupts: +maxItems: 1 + + interrupt-names: + enum: +- IRQB + + interrupt-controller: true + + "#interrupt-cells": +const: 1 +description: + The first cell is the IRQ number. + + regulator: +$ref: ../regulator/mt6360-regulator.yaml + +required: + - compatible + - reg + - interrupts + - interrupt-controller + - "#interrupt-cells" + +additionalProperties: false + +examples: + - | +#include +#include +i2c { +#address-cells = <1>; +#size-cells = <0>; + +mt6360@34 { +compatible = "mediatek,mt6360"; +reg = <0x34>; +wakeup-source; +interrupts-extended = <&gpio26 0 IRQ_TYPE_LEVEL_LOW>; +interrupt-names = "IRQB"; +interrupt-controller; +#interrupt-cells = <1>; +regulator { +compatible = "mediatek,mt6360-regulator"; +LDO_VIN3-supply = <&BUCK2>; +buck1 { +regulator-compatible = "BUCK1"; +regulator-name = "mt6360,buck1"; +regulator-min-microvolt = <30>; +regulator-max-microvolt = <130>; +regulator-allowed-modes = ; +}; +BUCK2: buck2 { +regulator-compatible = "BUCK2"; +regulator-name = "mt6360,buck2"; +regulator-min-microvolt = <30>; +regulator-max-microvolt = <130>; +regulator-allowed-modes = ; +}; +ldo6 { +regulator-compatible = "LDO6"; +regulator-name = "mt6360,ldo6"; +regulator-min-microvolt = <50>; +regulator-max-microvolt = <210>; +regulator-allowed-modes = ; +}; +ldo7 { +regulator-compatible = "LDO7"; +regulator-name = "mt6360,ldo7"; +regulator-min-microvolt = <50>; +regulator-max-microvolt = <210>; +regulator-allowed-modes = ; +}; +ldo1 { +regulator-compatible = "LDO1"; +regulator-name = "mt6360,ldo1"; +regulator-min-microvolt = <120>; +regulator-max-microvolt = <360>; +regulator-allowed-modes = ; +}; +ldo2 { +regulator-compatible = "LDO2"; +regulator-name = "mt6360,ldo2"; +regulator-min-microvolt = <120>; +regulator-max-microvolt = <360>; +regulator-allowed-modes = ; +}; +ldo3 { +regulator-compatible = "LDO3"; +regulator-name = "mt6360,ldo3"; +regulator-min-microvolt = <120>; +regulator-max-microvolt = <360>; +regulator-allowed-modes = ; +}; +ldo5 { +regulator-compatible = "LDO5"; +regulator-name = "mt6360,ldo5"; +regulator-min-microvolt = <270>; +regulator-max-microvolt = <360>; +regulator-allowed-modes = ; +}; +}; +}; +}; -- 2.7.4
Re: [PATCH 9/9] mfd: mt6360: Merge different sub-devices I2C read/write
Mark Brown 於 2020年8月6日 週四 上午12:10寫道: > > On Wed, Aug 05, 2020 at 12:33:02AM +0800, Gene Chen wrote: > > From: Gene Chen > > > > Remove unuse register definition. > > Merge different sub-devices I2C read/write functions into one Regmap, > > because PMIC and LDO part need CRC bits for access protection. > > It's not clear why this isn't just done in the device regmap, there's > exactly one user? because I use one regmap to access 4 I2C devices, I need change the regmap_bus struct to fit I2C read/write with CRC bit Therefore, MFD reviewer suggests I can move the regmap api to regmap folder such as regmap-ac97.c Is it okay to apply this change?
Re: [PATCH 9/9] mfd: mt6360: Merge different sub-devices I2C read/write
Mark Brown 於 2020年8月6日 週四 下午8:13寫道: > > On Thu, Aug 06, 2020 at 11:30:56AM +0800, Gene Chen wrote: > > Mark Brown 於 2020年8月6日 週四 上午12:10寫道: > > > > It's not clear why this isn't just done in the device regmap, there's > > > exactly one user? > > > because I use one regmap to access 4 I2C devices, > > There appears to be only one device here? > > > I need change the regmap_bus struct to fit I2C read/write with CRC bit > > Therefore, MFD reviewer suggests I can move the regmap api to regmap > > folder such as regmap-ac97.c > > AC'97 is an industry standard bus used by a range of devices in > different subsystems. You can already have custom operations for a > device just in a regular regmap using the reg_read() and reg_write() > operations which are there so devices that individual device support > doesn't need to be added to the regmap core. > I need use regmap_raw_read to access MT6360 TYPEC part, so we need implement bus read control > You really also need to write a much clearer changelog, I would be hard > pressed to tell from the changelog that this was moving things to the > regmap core rather than shuffling regmaps within the device. MT6360 has 4 I2C worker devices First, I increase reg_bits from 8 to 16 bits. Higher 8 bits, bank, indicated which worker device I want access Then, if worker devices is PMIC or LDO part, I need calculate or check CRC8 bits when we write or read data. CRC8 bits is calculated by 3 parts. 1'st part include 1 byte is worker address and R/W in LSB. 2'nd part include 1 byte is register address 3'nd part include written data or read data from MT6360 I also need 1 dummy byte when write data @Lee Jones, I found out drivers/iio/chemical/bme680_spi.c implement their own regmap_bus too. Can I move regmap control back to mt6360-core.c?
Re: [PATCH resend] dt-bindings: mfd: mediatek: Add bindings for MT6360 PMIC
Vaittinen, Matti 於 2021年1月11日 週一 下午5:13寫道: > > Hello Peeps, > > On Thu, 2020-12-24 at 11:19 +0800, Gene Chen wrote: > > From: Gene Chen > > > > Add bindings for MT6360 PMIC > > > > Signed-off-by: Gene Chen > > --- > > Documentation/devicetree/bindings/mfd/mt6360.yaml | 69 > > +++ > > 1 file changed, 69 insertions(+) > > create mode 100644 Documentation/devicetree/bindings/mfd/mt6360.yaml > > > > diff --git a/Documentation/devicetree/bindings/mfd/mt6360.yaml > > b/Documentation/devicetree/bindings/mfd/mt6360.yaml > > new file mode 100644 > > index 000..2781c31 > > --- /dev/null > > +++ b/Documentation/devicetree/bindings/mfd/mt6360.yaml > > @@ -0,0 +1,69 @@ > > +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) > > +%YAML 1.2 > > +--- > > +$id: http://devicetree.org/schemas/mfd/mt6360.yaml# > > +$schema: http://devicetree.org/meta-schemas/core.yaml# > > + > > +title: MT6360 PMIC from MediaTek Integrated > > + > > +maintainers: > > + - Gene Chen > > + > > +description: | > > + MT6360 is a PMIC device with the following sub modules. > > + It is interfaced to host controller using I2C interface. > > + > > + This document describes the binding for PMIC device and its sub > > module. > > + > > +properties: > > + compatible: > > +const: mediatek,mt6360 > > + > > + reg: > > +description: > > + I2C device address. > > +maxItems: 1 > > + > > + wakeup-source: true > > + > > + interrupts: > > +maxItems: 1 > > + > > + interrupt-names: > > + enum: > > +- IRQB > > + > > + interrupt-controller: true > > + > > + "#interrupt-cells": > > +const: 1 > > +description: > > + The first cell is the IRQ number. > > + > > +required: > > + - compatible > > + - reg > > + - interrupts > > + - interrupt-controller > > + - "#interrupt-cells" > > + > > +additionalProperties: false > > + > > +examples: > > + - | > > +#include > > +#include > > +i2c { > > +#address-cells = <1>; > > +#size-cells = <0>; > > + > > +mt6360@34 { > > +compatible = "mediatek,mt6360"; > > +reg = <0x34>; > > +wakeup-source; > > +interrupts-extended = <&gpio26 0 IRQ_TYPE_LEVEL_LOW>; > > +interrupt-names = "IRQB"; > > +interrupt-controller; > > +#interrupt-cells = <1>; > > Out of the curiosity - is this the complete node? I would assume some > sub-devices like regulators here? > After all sub-devices module review done, I will add new patch to add reference description. e.g. max77650.yaml leds: $ref: ../leds/leds-max77650.yaml > > +}; > > +}; >
Re: [PATCH v3 2/2] power: supply: mt6360_charger: add MT6360 charger support
Sebastian Reichel 於 2021年1月7日 週四 上午4:16寫道: > > Hi Gene, > > I have a bunch of comments, please take a look at my inline > comments. > > On Thu, Dec 24, 2020 at 03:48:04PM +0800, Gene Chen wrote: > > From: Gene Chen > > > > Add basic support for the battery charger for MT6360 PMIC > > > > Signed-off-by: Gene Chen > > --- > > drivers/power/supply/Kconfig | 10 + > > drivers/power/supply/Makefile |1 + > > drivers/power/supply/mt6360_charger.c | 1054 > > + > > 3 files changed, 1065 insertions(+) > > create mode 100644 drivers/power/supply/mt6360_charger.c > > > > diff --git a/drivers/power/supply/Kconfig b/drivers/power/supply/Kconfig > > index eec646c..dd63bed 100644 > > --- a/drivers/power/supply/Kconfig > > +++ b/drivers/power/supply/Kconfig > > @@ -567,6 +567,16 @@ config CHARGER_MP2629 > > Battery charger. This driver provides Battery charger power > > management > > functions on the systems. > > > > +config CHARGER_MT6360 > > + tristate "Mediatek MT6360 Charger Driver" > > + depends on MFD_MT6360 > > + depends on REGULATOR > > + help > > + Say Y here to enable MT6360 Charger Part. > > + The device supports High-Accuracy Voltage/Current Regulation, > > + Average Input Current Regulation, Battery Tempature Sensing, > > + Over-Temperature Protection, DPDM Detection for BC1.2 > > + > > config CHARGER_QCOM_SMBB > > tristate "Qualcomm Switch-Mode Battery Charger and Boost" > > depends on MFD_SPMI_PMIC || COMPILE_TEST > > diff --git a/drivers/power/supply/Makefile b/drivers/power/supply/Makefile > > index dd4b863..9bd0804 100644 > > --- a/drivers/power/supply/Makefile > > +++ b/drivers/power/supply/Makefile > > @@ -77,6 +77,7 @@ obj-$(CONFIG_CHARGER_MAX77693) += max77693_charger.o > > obj-$(CONFIG_CHARGER_MAX8997)+= max8997_charger.o > > obj-$(CONFIG_CHARGER_MAX8998)+= max8998_charger.o > > obj-$(CONFIG_CHARGER_MP2629) += mp2629_charger.o > > +obj-$(CONFIG_CHARGER_MT6360) += mt6360_charger.o > > obj-$(CONFIG_CHARGER_QCOM_SMBB) += qcom_smbb.o > > obj-$(CONFIG_CHARGER_BQ2415X)+= bq2415x_charger.o > > obj-$(CONFIG_CHARGER_BQ24190)+= bq24190_charger.o > > diff --git a/drivers/power/supply/mt6360_charger.c > > b/drivers/power/supply/mt6360_charger.c > > new file mode 100644 > > index 000..f1dcb97 > > --- /dev/null > > +++ b/drivers/power/supply/mt6360_charger.c > > @@ -0,0 +1,1054 @@ > > +// SPDX-License-Identifier: GPL-2.0 > > +/* > > + * Copyright (c) 2019 MediaTek Inc. > > 2019-2021? :) > ACK > > + */ > > + > > +#include > > +#include > > +#include > > +#include > > +#include > > +#include > > change of.h to after implementing my later > change request. > ACK > > +#include > > +#include > > +#include > > + > > +#define MT6360_PMU_CHG_CTRL1 0x311 > > +#define MT6360_PMU_CHG_CTRL2 0x312 > > +#define MT6360_PMU_CHG_CTRL3 0x313 > > +#define MT6360_PMU_CHG_CTRL4 0x314 > > +#define MT6360_PMU_CHG_CTRL5 0x315 > > +#define MT6360_PMU_CHG_CTRL6 0x316 > > +#define MT6360_PMU_CHG_CTRL7 0x317 > > +#define MT6360_PMU_CHG_CTRL8 0x318 > > +#define MT6360_PMU_CHG_CTRL9 0x319 > > +#define MT6360_PMU_CHG_CTRL100x31A > > +#define MT6360_PMU_CHG_CTRL110x31B > > +#define MT6360_PMU_CHG_CTRL120x31C > > +#define MT6360_PMU_CHG_CTRL130x31D > > +#define MT6360_PMU_DEVICE_TYPE 0x322 > > +#define MT6360_PMU_USB_STATUS1 0x327 > > +#define MT6360_PMU_CHG_CTRL170x32B > > +#define MT6360_PMU_CHG_CTRL180x32C > > +#define MT6360_PMU_CHG_STAT 0x34A > > +#define MT6360_PMU_CHG_CTRL190x361 > > +#define MT6360_PMU_FOD_STAT 0x3E7 > > + > > +/* MT6360_PMU_CHG_CTRL1 */ > > +#define MT6360_FSLP_SHFT (3) > > +#define MT6360_FSLP_MASK BIT(MT6360_FSLP_SHFT) > > +#define MT6360_HIZ_SHFT (2) > > +#define MT6360_HIZ_MASK BIT(MT6360_HIZ_SHFT) > > +#define MT6360_OPA_MODE_SHFT (0) > > +#define MT6360_OPA_MODE_MASK BIT(MT6360_OPA_MODE_SHFT) > > +/* MT6360_PMU_CHG_CTRL2 */ > > +#define MT6360_TE_SHFT (4) > > +#define MT6360_TE_MASK BIT(MT6360_TE_SHFT) > > +#define MT6360_IINLMTSEL_SHFT(2) > > +#define MT6360_IINLMTSEL_MASKGENMASK(3, 2) > > +#d
Re: [PATCH] mfd: mt6360: Fix MFD cell names and compatibles
Hi Lee, This change exists in [PATCH v7 03/11] mfd: mt6360: Indicate sub-dev compatible name by using "-". Does patch v7 also merge together to mfd-next? 於 2021年1月11日 週一 下午8:35寫道: > > From: Matthias Brugger > > MFD cell names and compatibles use '_' instead of '-', which is common > practice for names and the standard for DT compatibles. > This will also fix the probing for the drivers already implemented > (mt6360-adc and mt6360-tcpc). > > Fixes: 7edd363421da ("mfd: Add support for PMIC MT6360") > Fixes: 1f4877218f7e ("iio: adc: mt6360: Add ADC driver for MT6360") > Fixes: e1aefcdd394f ("usb typec: mt6360: Add support for mt6360 Type-C > driver") > Signed-off-by: Matthias Brugger > > --- > > drivers/mfd/mt6360-core.c | 24 > 1 file changed, 12 insertions(+), 12 deletions(-) > > diff --git a/drivers/mfd/mt6360-core.c b/drivers/mfd/mt6360-core.c > index 4661c1b29a72..14e649ffe50f 100644 > --- a/drivers/mfd/mt6360-core.c > +++ b/drivers/mfd/mt6360-core.c > @@ -292,18 +292,18 @@ static const struct resource mt6360_ldo_resources[] = { > }; > > static const struct mfd_cell mt6360_devs[] = { > - OF_MFD_CELL("mt6360_adc", mt6360_adc_resources, > - NULL, 0, 0, "mediatek,mt6360_adc"), > - OF_MFD_CELL("mt6360_chg", mt6360_chg_resources, > - NULL, 0, 0, "mediatek,mt6360_chg"), > - OF_MFD_CELL("mt6360_led", mt6360_led_resources, > - NULL, 0, 0, "mediatek,mt6360_led"), > - OF_MFD_CELL("mt6360_pmic", mt6360_pmic_resources, > - NULL, 0, 0, "mediatek,mt6360_pmic"), > - OF_MFD_CELL("mt6360_ldo", mt6360_ldo_resources, > - NULL, 0, 0, "mediatek,mt6360_ldo"), > - OF_MFD_CELL("mt6360_tcpc", NULL, > - NULL, 0, 0, "mediatek,mt6360_tcpc"), > + OF_MFD_CELL("mt6360-adc", mt6360_adc_resources, > + NULL, 0, 0, "mediatek,mt6360-adc"), > + OF_MFD_CELL("mt6360-chg", mt6360_chg_resources, > + NULL, 0, 0, "mediatek,mt6360-chg"), > + OF_MFD_CELL("mt6360-led", mt6360_led_resources, > + NULL, 0, 0, "mediatek,mt6360-led"), > + OF_MFD_CELL("mt6360-pmic", mt6360_pmic_resources, > + NULL, 0, 0, "mediatek,mt6360-pmic"), > + OF_MFD_CELL("mt6360-ldo", mt6360_ldo_resources, > + NULL, 0, 0, "mediatek,mt6360-ldo"), > + OF_MFD_CELL("mt6360-tcpc", NULL, > + NULL, 0, 0, "mediatek,mt6360-tcpc"), > }; > > static const unsigned short mt6360_slave_addr[MT6360_SLAVE_MAX] = { > -- > 2.29.2 >
[PATCH v13 3/5] dt-bindings: leds: Add LED_FUNCTION_MOONLIGHT definitions
From: Gene Chen Add LED_FUNCTION_MOONLIGHT definitions Signed-off-by: Gene Chen Acked-by: Jacek Anaszewski Acked-by: Rob Herring --- include/dt-bindings/leds/common.h | 1 + 1 file changed, 1 insertion(+) diff --git a/include/dt-bindings/leds/common.h b/include/dt-bindings/leds/common.h index 52b619d..843e65d 100644 --- a/include/dt-bindings/leds/common.h +++ b/include/dt-bindings/leds/common.h @@ -78,6 +78,7 @@ #define LED_FUNCTION_INDICATOR "indicator" #define LED_FUNCTION_LAN "lan" #define LED_FUNCTION_MAIL "mail" +#define LED_FUNCTION_MOONLIGHT "moonlight" #define LED_FUNCTION_MTD "mtd" #define LED_FUNCTION_PANIC "panic" #define LED_FUNCTION_PROGRAMMING "programming" -- 2.7.4
[PATCH v13 0/5] leds: mt6360: Add LED driver for MT6360
In-Reply-To: This patch series add MT6360 LED support contains driver and binding document Gene Chen (5) leds: flash: Add flash registration with undefined CONFIG_LEDS_CLASS_FLASH leds: flash: Fix multicolor no-ops registration by return 0 dt-bindings: leds: Add LED_COLOR_ID_MOONLIGHT definitions dt-bindings: leds: Add bindings for MT6360 LED leds: mt6360: Add LED driver for MT6360 Documentation/devicetree/bindings/leds/leds-mt6360.yaml | 159 +++ drivers/leds/Kconfig| 13 drivers/leds/Makefile |1 drivers/leds/leds-mt6360.c | 827 include/dt-bindings/leds/common.h |1 include/linux/led-class-flash.h | 42 include/linux/led-class-multicolor.h| 42 7 files changed, 1049 insertions(+), 36 deletions(-) changelogs between v1 & v2 - add led driver with mfd changelogs between v2 & v3 - independent add led driver - add dt-binding document - refactor macros definition for easy to debug - parse device tree by fwnode - use devm*ext to register led class device changelogs between v3 & v4 - fix binding document description - use GENMASK and add unit postfix to definition - isink register led class device changelogs between v4 & v5 - change rgb isink to multicolor control - add binding reference to mfd yaml changelogs between v5 & v6 - Use DT to decide RGB LED is multicolor device or indicator device only changelogs between v6 & v7 - Add binding multicolor device sample code - Add flash ops mutex lock - Remove V4L2 init with indicator device changelogs between v7 & v8 - Add mutex for led fault get ops - Fix flash and multicolor no-ops return 0 - Add LED_FUNCTION_MOONLIGHT changelogs between v8 & v9 - reuse api in flash and multicolor header changelogs between v9 & v10 - add comment for reuse registration functions in flash and multicolor changelogs between v10 & v11 - match dt-binding reg property comment to the functionality name - remove exist patch in linux-next - dicide multicolor channel by color definitiion changelogs between v11 & v12 - Fix print size_t by %zu - Fix dt-binding name regular experssion changelogs between v12 & v13 - Fix kbuild test rebot build error
[PATCH v13 1/5] leds: flash: Add flash registration with undefined CONFIG_LEDS_CLASS_FLASH
From: Gene Chen Add flash registration with undefined CONFIG_LEDS_CLASS_FLASH, and move the same registration functions outside of #ifdef block. Signed-off-by: Gene Chen Acked-by: Jacek Anaszewski --- include/linux/led-class-flash.h | 42 - 1 file changed, 33 insertions(+), 9 deletions(-) diff --git a/include/linux/led-class-flash.h b/include/linux/led-class-flash.h index 21a3358..612b4ca 100644 --- a/include/linux/led-class-flash.h +++ b/include/linux/led-class-flash.h @@ -85,6 +85,7 @@ static inline struct led_classdev_flash *lcdev_to_flcdev( return container_of(lcdev, struct led_classdev_flash, led_cdev); } +#if IS_ENABLED(CONFIG_LEDS_CLASS_FLASH) /** * led_classdev_flash_register_ext - register a new object of LED class with * init data and with support for flash LEDs @@ -98,12 +99,6 @@ int led_classdev_flash_register_ext(struct device *parent, struct led_classdev_flash *fled_cdev, struct led_init_data *init_data); -static inline int led_classdev_flash_register(struct device *parent, - struct led_classdev_flash *fled_cdev) -{ - return led_classdev_flash_register_ext(parent, fled_cdev, NULL); -} - /** * led_classdev_flash_unregister - unregisters an object of led_classdev class *with support for flash LEDs @@ -118,15 +113,44 @@ int devm_led_classdev_flash_register_ext(struct device *parent, struct led_init_data *init_data); +void devm_led_classdev_flash_unregister(struct device *parent, + struct led_classdev_flash *fled_cdev); + +#else + +static inline int led_classdev_flash_register_ext(struct device *parent, + struct led_classdev_flash *fled_cdev, + struct led_init_data *init_data) +{ + return 0; +} + +static inline void led_classdev_flash_unregister(struct led_classdev_flash *fled_cdev) {}; +static inline int devm_led_classdev_flash_register_ext(struct device *parent, +struct led_classdev_flash *fled_cdev, +struct led_init_data *init_data) +{ + return 0; +} + +static inline void devm_led_classdev_flash_unregister(struct device *parent, + struct led_classdev_flash *fled_cdev) +{}; + +#endif /* IS_ENABLED(CONFIG_LEDS_CLASS_FLASH) */ + +static inline int led_classdev_flash_register(struct device *parent, + struct led_classdev_flash *fled_cdev) +{ + return led_classdev_flash_register_ext(parent, fled_cdev, NULL); +} + static inline int devm_led_classdev_flash_register(struct device *parent, struct led_classdev_flash *fled_cdev) { return devm_led_classdev_flash_register_ext(parent, fled_cdev, NULL); } -void devm_led_classdev_flash_unregister(struct device *parent, - struct led_classdev_flash *fled_cdev); - /** * led_set_flash_strobe - setup flash strobe * @fled_cdev: the flash LED to set strobe on -- 2.7.4
[PATCH v13 2/5] leds: flash: Fix multicolor no-ops registration by return 0
From: Gene Chen Fix multicolor no-ops registration by return 0, and move the same registration functions outside of #ifdef block. Signed-off-by: Gene Chen Acked-by: Jacek Anaszewski --- include/linux/led-class-multicolor.h | 42 +--- 1 file changed, 15 insertions(+), 27 deletions(-) diff --git a/include/linux/led-class-multicolor.h b/include/linux/led-class-multicolor.h index 5116f9a..210d57b 100644 --- a/include/linux/led-class-multicolor.h +++ b/include/linux/led-class-multicolor.h @@ -44,12 +44,6 @@ int led_classdev_multicolor_register_ext(struct device *parent, struct led_classdev_mc *mcled_cdev, struct led_init_data *init_data); -static inline int led_classdev_multicolor_register(struct device *parent, - struct led_classdev_mc *mcled_cdev) -{ - return led_classdev_multicolor_register_ext(parent, mcled_cdev, NULL); -} - /** * led_classdev_multicolor_unregister - unregisters an object of led_classdev * class with support for multicolor LEDs @@ -68,13 +62,6 @@ int devm_led_classdev_multicolor_register_ext(struct device *parent, struct led_classdev_mc *mcled_cdev, struct led_init_data *init_data); -static inline int devm_led_classdev_multicolor_register(struct device *parent, -struct led_classdev_mc *mcled_cdev) -{ - return devm_led_classdev_multicolor_register_ext(parent, mcled_cdev, -NULL); -} - void devm_led_classdev_multicolor_unregister(struct device *parent, struct led_classdev_mc *mcled_cdev); #else @@ -83,27 +70,33 @@ static inline int led_classdev_multicolor_register_ext(struct device *parent, struct led_classdev_mc *mcled_cdev, struct led_init_data *init_data) { - return -EINVAL; -} - -static inline int led_classdev_multicolor_register(struct device *parent, - struct led_classdev_mc *mcled_cdev) -{ - return led_classdev_multicolor_register_ext(parent, mcled_cdev, NULL); + return 0; } static inline void led_classdev_multicolor_unregister(struct led_classdev_mc *mcled_cdev) {}; static inline int led_mc_calc_color_components(struct led_classdev_mc *mcled_cdev, enum led_brightness brightness) { - return -EINVAL; + return 0; } static inline int devm_led_classdev_multicolor_register_ext(struct device *parent, struct led_classdev_mc *mcled_cdev, struct led_init_data *init_data) { - return -EINVAL; + return 0; +} + +static inline void devm_led_classdev_multicolor_unregister(struct device *parent, + struct led_classdev_mc *mcled_cdev) +{}; + +#endif /* IS_ENABLED(CONFIG_LEDS_CLASS_MULTICOLOR) */ + +static inline int led_classdev_multicolor_register(struct device *parent, + struct led_classdev_mc *mcled_cdev) +{ + return led_classdev_multicolor_register_ext(parent, mcled_cdev, NULL); } static inline int devm_led_classdev_multicolor_register(struct device *parent, @@ -113,9 +106,4 @@ static inline int devm_led_classdev_multicolor_register(struct device *parent, NULL); } -static inline void devm_led_classdev_multicolor_unregister(struct device *parent, - struct led_classdev_mc *mcled_cdev) -{}; - -#endif /* IS_ENABLED(CONFIG_LEDS_CLASS_MULTICOLOR) */ #endif /* _LINUX_MULTICOLOR_LEDS_H_INCLUDED */ -- 2.7.4
[PATCH v13 4/5] dt-bindings: leds: Add bindings for MT6360 LED
From: Gene Chen Add bindings document for LED support on MT6360 PMIC Signed-off-by: Gene Chen Reviewed-by: Rob Herring --- .../devicetree/bindings/leds/leds-mt6360.yaml | 159 + 1 file changed, 159 insertions(+) create mode 100644 Documentation/devicetree/bindings/leds/leds-mt6360.yaml diff --git a/Documentation/devicetree/bindings/leds/leds-mt6360.yaml b/Documentation/devicetree/bindings/leds/leds-mt6360.yaml new file mode 100644 index 000..cb1f4b7 --- /dev/null +++ b/Documentation/devicetree/bindings/leds/leds-mt6360.yaml @@ -0,0 +1,159 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/leds/leds-mt6360.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: LED driver for MT6360 PMIC from MediaTek Integrated. + +maintainers: + - Gene Chen + +description: | + This module is part of the MT6360 MFD device. + see Documentation/devicetree/bindings/mfd/mt6360.yaml + Add MT6360 LED driver include 2-channel Flash LED with torch/strobe mode, + and 4-channel RGB LED support Register/Flash/Breath Mode + +properties: + compatible: +const: mediatek,mt6360-led + + "#address-cells": +const: 1 + + "#size-cells": +const: 0 + +patternProperties: + "^(multi-)?led@[0-5]$": +type: object +$ref: common.yaml# +description: + Properties for a single LED. + +properties: + reg: +description: Index of the LED. +enum: + - 0 # LED output ISINK1 + - 1 # LED output ISINK2 + - 2 # LED output ISINK3 + - 3 # LED output ISINKML + - 4 # LED output FLASH1 + - 5 # LED output FLASH2 + +unevaluatedProperties: false + +required: + - compatible + - "#address-cells" + - "#size-cells" + +additionalProperties: false + +examples: + - | + #include + led-controller { + compatible = "mediatek,mt6360-led"; + #address-cells = <1>; + #size-cells = <0>; + + multi-led@0 { + reg = <0>; + function = LED_FUNCTION_INDICATOR; + color = ; + led-max-microamp = <24000>; + #address-cells = <1>; + #size-cells = <0>; + led@0 { + reg = <0>; + color = ; + }; + led@1 { + reg = <1>; + color = ; + }; + led@2 { + reg = <2>; + color = ; + }; + }; + led@3 { + reg = <3>; + function = LED_FUNCTION_MOONLIGHT; + color = ; + led-max-microamp = <15>; + }; + led@4 { + reg = <4>; + function = LED_FUNCTION_FLASH; + color = ; + function-enumerator = <1>; + led-max-microamp = <20>; + flash-max-microamp = <50>; + flash-max-timeout-us = <1024000>; + }; + led@5 { + reg = <5>; + function = LED_FUNCTION_FLASH; + color = ; + function-enumerator = <2>; + led-max-microamp = <20>; + flash-max-microamp = <50>; + flash-max-timeout-us = <1024000>; + }; + }; + + - | + + led-controller { + compatible = "mediatek,mt6360-led"; + #address-cells = <1>; + #size-cells = <0>; + + led@0 { + reg = <0>; + function = LED_FUNCTION_INDICATOR; + color = ; + led-max-microamp = <24000>; + }; + led@1 { + reg = <1>; + function = LED_FUNCTION_INDICATOR; + color = ; + led-max-microamp = <24000>; + }; + led@2 { + reg = <2>; + function = LED_FUNCTION_INDICATOR; + color = ; + led-max-microamp = <24000>; + }; + led@3 { + reg = <3>; + function = LED_FUNCTION_MOONLIGHT; + color = ; + led-max-microamp = <15>; + }; + led@4 { + reg = <4>; + function = LED_FUNCTION_FLASH; + color = ; + function-enumerator = <1>; + led-max-microamp = <20>; + flash-max-microamp = <50>; + flash-max-timeout-us = <1024000>; + }; + led@5 { + reg = <5>; + function = LED_FUNCTION_FLASH; + color = ; + function-enumerator = <2>; + led-max-microamp = <20>; + flash-max-microamp = <50>; + flash-max-timeout-us = <1024000>; + }; + }; +... -- 2.7.4
[PATCH v13 5/5] leds: mt6360: Add LED driver for MT6360
From: Gene Chen Add MT6360 LED driver include 2-channel Flash LED with torch/strobe mode, 3-channel RGB LED support Register/Flash/Breath Mode, and 1-channel for moonlight LED. Signed-off-by: Gene Chen --- drivers/leds/Kconfig | 13 + drivers/leds/Makefile | 1 + drivers/leds/leds-mt6360.c | 827 + 3 files changed, 841 insertions(+) create mode 100644 drivers/leds/leds-mt6360.c diff --git a/drivers/leds/Kconfig b/drivers/leds/Kconfig index 1c181df..4f533bc 100644 --- a/drivers/leds/Kconfig +++ b/drivers/leds/Kconfig @@ -271,6 +271,19 @@ config LEDS_MT6323 This option enables support for on-chip LED drivers found on Mediatek MT6323 PMIC. +config LEDS_MT6360 + tristate "LED Support for Mediatek MT6360 PMIC" + depends on LEDS_CLASS && OF + depends on LEDS_CLASS_FLASH || !LEDS_CLASS_FLASH + depends on LEDS_CLASS_MULTICOLOR || !LEDS_CLASS_MULTICOLOR + depends on V4L2_FLASH_LED_CLASS || !V4L2_FLASH_LED_CLASS + depends on MFD_MT6360 + help + This option enables support for dual Flash LED drivers found on + Mediatek MT6360 PMIC. + Independent current sources supply for each flash LED support torch + and strobe mode. + config LEDS_S3C24XX tristate "LED Support for Samsung S3C24XX GPIO LEDs" depends on LEDS_CLASS diff --git a/drivers/leds/Makefile b/drivers/leds/Makefile index c2c7d7a..5596427 100644 --- a/drivers/leds/Makefile +++ b/drivers/leds/Makefile @@ -66,6 +66,7 @@ obj-$(CONFIG_LEDS_MIKROTIK_RB532) += leds-rb532.o obj-$(CONFIG_LEDS_MLXCPLD) += leds-mlxcpld.o obj-$(CONFIG_LEDS_MLXREG) += leds-mlxreg.o obj-$(CONFIG_LEDS_MT6323) += leds-mt6323.o +obj-$(CONFIG_LEDS_MT6360) += leds-mt6360.o obj-$(CONFIG_LEDS_NET48XX) += leds-net48xx.o obj-$(CONFIG_LEDS_NETXBIG) += leds-netxbig.o obj-$(CONFIG_LEDS_NIC78BX) += leds-nic78bx.o diff --git a/drivers/leds/leds-mt6360.c b/drivers/leds/leds-mt6360.c new file mode 100644 index 000..b485e05 --- /dev/null +++ b/drivers/leds/leds-mt6360.c @@ -0,0 +1,827 @@ +// SPDX-License-Identifier: GPL-2.0-only + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +enum { + MT6360_LED_ISNK1 = 0, + MT6360_LED_ISNK2, + MT6360_LED_ISNK3, + MT6360_LED_ISNKML, + MT6360_LED_FLASH1, + MT6360_LED_FLASH2, + MT6360_MAX_LEDS +}; + +#define MT6360_REG_RGBEN 0x380 +#define MT6360_REG_ISNK(_led_no) (0x381 + (_led_no)) +#define MT6360_ISNK_ENMASK(_led_no)BIT(7 - (_led_no)) +#define MT6360_ISNK_MASK GENMASK(4, 0) +#define MT6360_CHRINDSEL_MASK BIT(3) + +/* Virtual definition for multicolor */ +#define MT6360_VIRTUAL_MULTICOLOR (MT6360_MAX_LEDS + 1) +#define MULTICOLOR_NUM_CHANNELS3 + +#define MT6360_REG_FLEDEN 0x37E +#define MT6360_REG_STRBTO 0x373 +#define MT6360_REG_FLEDBASE(_id) (0x372 + 4 * (_id - MT6360_LED_FLASH1)) +#define MT6360_REG_FLEDISTRB(_id) (MT6360_REG_FLEDBASE(_id) + 2) +#define MT6360_REG_FLEDITOR(_id) (MT6360_REG_FLEDBASE(_id) + 3) +#define MT6360_REG_CHGSTAT20x3E1 +#define MT6360_REG_FLEDSTAT1 0x3E9 +#define MT6360_ITORCH_MASK GENMASK(4, 0) +#define MT6360_ISTROBE_MASKGENMASK(6, 0) +#define MT6360_STRBTO_MASK GENMASK(6, 0) +#define MT6360_TORCHEN_MASKBIT(3) +#define MT6360_STROBEN_MASKBIT(2) +#define MT6360_FLCSEN_MASK(_id)BIT(MT6360_LED_FLASH2 - _id) +#define MT6360_FLEDCHGVINOVP_MASK BIT(3) +#define MT6360_FLED1STRBTO_MASKBIT(11) +#define MT6360_FLED2STRBTO_MASKBIT(10) +#define MT6360_FLED1STRB_MASK BIT(9) +#define MT6360_FLED2STRB_MASK BIT(8) +#define MT6360_FLED1SHORT_MASK BIT(7) +#define MT6360_FLED2SHORT_MASK BIT(6) +#define MT6360_FLEDLVF_MASKBIT(3) + +#define MT6360_ISNKRGB_STEPUA 2000 +#define MT6360_ISNKRGB_MAXUA 24000 +#define MT6360_ISNKML_STEPUA 5000 +#define MT6360_ISNKML_MAXUA15 + +#define MT6360_ITORCH_MINUA25000 +#define MT6360_ITORCH_STEPUA 12500 +#define MT6360_ITORCH_MAXUA40 +#define MT6360_ISTRB_MINUA 5 +#define MT6360_ISTRB_STEPUA12500 +#define MT6360_ISTRB_MAXUA 150 +#define MT6360_STRBTO_MINUS64000 +#define MT6360_STRBTO_STEPUS 32000 +#define MT6360_STRBTO_MAXUS2432000 + +#define STATE_OFF 0 +#define STATE_KEEP 1 +#define STATE_ON 2 + +struct mt6360_led { + union { + struct led_classdev isnk; +
Re: [PATCH] dt-bindings: mfd: mediatek: Add bindings for MT6360 PMIC
Dear Reviewers, Should I wait for all sub-devices dt-binding review done, then send the integral binding document? Gene Chen 於 2020年11月13日 週五 下午1:54寫道: > > Dear Reviewers, > >Please let me know if there is anything need to be revised. > > Gene Chen 於 2020年8月20日 週四 下午4:36寫道: > > > > From: Gene Chen > > > > Add bindings for MT6360 PMIC > > > > Signed-off-by: Gene Chen > > --- > > Documentation/devicetree/bindings/mfd/mt6360.yaml | 142 > > ++ > > 1 file changed, 142 insertions(+) > > create mode 100644 Documentation/devicetree/bindings/mfd/mt6360.yaml > > > > diff --git a/Documentation/devicetree/bindings/mfd/mt6360.yaml > > b/Documentation/devicetree/bindings/mfd/mt6360.yaml > > new file mode 100644 > > index 000..5ad1afd > > --- /dev/null > > +++ b/Documentation/devicetree/bindings/mfd/mt6360.yaml > > @@ -0,0 +1,142 @@ > > +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) > > +%YAML 1.2 > > +--- > > +$id: http://devicetree.org/schemas/mfd/mt6360.yaml# > > +$schema: http://devicetree.org/meta-schemas/core.yaml# > > + > > +title: MT6360 PMIC from MediaTek Integrated > > + > > +maintainers: > > + - Gene Chen > > + > > +description: | > > + MT6360 is a PMIC device with the following sub modules. > > + It is interfaced to host controller using I2C interface. > > + > > + This document describes the binding for PMIC device and its sub module. > > + > > +properties: > > + compatible: > > +const: mediatek,mt6360 > > + > > + reg: > > +description: > > + I2C device address. > > +maxItems: 1 > > + > > + wakeup-source: true > > + > > + interrupts: > > +maxItems: 1 > > + > > + interrupt-names: > > + enum: > > +- IRQB > > + > > + interrupt-controller: true > > + > > + "#interrupt-cells": > > +const: 1 > > +description: > > + The first cell is the IRQ number. > > + > > + regulator: > > +$ref: ../regulator/mt6360-regulator.yaml > > + > > +required: > > + - compatible > > + - reg > > + - interrupts > > + - interrupt-controller > > + - "#interrupt-cells" > > + > > +additionalProperties: false > > + > > +examples: > > + - | > > +#include > > +#include > > +i2c { > > +#address-cells = <1>; > > +#size-cells = <0>; > > + > > +mt6360@34 { > > +compatible = "mediatek,mt6360"; > > +reg = <0x34>; > > +wakeup-source; > > +interrupts-extended = <&gpio26 0 IRQ_TYPE_LEVEL_LOW>; > > +interrupt-names = "IRQB"; > > +interrupt-controller; > > +#interrupt-cells = <1>; > > +regulator { > > +compatible = "mediatek,mt6360-regulator"; > > +LDO_VIN3-supply = <&BUCK2>; > > +buck1 { > > +regulator-compatible = "BUCK1"; > > +regulator-name = "mt6360,buck1"; > > +regulator-min-microvolt = <30>; > > +regulator-max-microvolt = <130>; > > +regulator-allowed-modes = > + MT6360_OPMODE_LP > > + MT6360_OPMODE_ULP>; > > +}; > > +BUCK2: buck2 { > > +regulator-compatible = "BUCK2"; > > +regulator-name = "mt6360,buck2"; > > +regulator-min-microvolt = <30>; > > +regulator-max-microvolt = <130>; > > +regulator-allowed-modes = > + MT6360_OPMODE_LP > > + MT6360_OPMODE_ULP>; > > +}; > > +ldo6 { > > +regulator-compatible = "LDO6"; > > +regulator-name = "mt6360,ldo6"; > > +regulator-min-microvolt = <50>; > > +regulator-max-microvolt = <210>; > > +regulator-allowed-modes = > +
Re: [PATCH v2 2/2] power: supply: mt6360_charger: add MT6360 charger support
Resend again, Gene Chen 於 2020年11月19日 週四 上午10:24寫道: > > Dear Reviewers, > >Please let me know if there is anything need to be revised. > > Gene Chen 於 2020年11月3日 週二 下午6:41寫道: > > > > From: Gene Chen > > > > Add basic support for the battery charger for MT6360 PMIC > > > > Signed-off-by: Gene Chen > > --- > > drivers/power/supply/Kconfig | 10 + > > drivers/power/supply/Makefile |1 + > > drivers/power/supply/mt6360_charger.c | 1022 > > + > > 3 files changed, 1033 insertions(+) > > create mode 100644 drivers/power/supply/mt6360_charger.c > > > > diff --git a/drivers/power/supply/Kconfig b/drivers/power/supply/Kconfig > > index faf2830..e2d53a3 100644 > > --- a/drivers/power/supply/Kconfig > > +++ b/drivers/power/supply/Kconfig > > @@ -562,6 +562,16 @@ config CHARGER_MP2629 > > Battery charger. This driver provides Battery charger power > > management > > functions on the systems. > > > > +config CHARGER_MT6360 > > + tristate "Mediatek MT6360 Charger Driver" > > + depends on MFD_MT6360 > > + depends on REGULATOR > > + help > > + Say Y here to enable MT6360 Charger Part. > > + The device supports High-Accuracy Voltage/Current Regulation, > > + Average Input Current Regulation, Battery Tempature Sensing, > > + Over-Temperature Protection, DPDM Detection for BC1.2 > > + > > config CHARGER_QCOM_SMBB > > tristate "Qualcomm Switch-Mode Battery Charger and Boost" > > depends on MFD_SPMI_PMIC || COMPILE_TEST > > diff --git a/drivers/power/supply/Makefile b/drivers/power/supply/Makefile > > index b3c694a..9abecb9c 100644 > > --- a/drivers/power/supply/Makefile > > +++ b/drivers/power/supply/Makefile > > @@ -77,6 +77,7 @@ obj-$(CONFIG_CHARGER_MAX77693)+= > > max77693_charger.o > > obj-$(CONFIG_CHARGER_MAX8997) += max8997_charger.o > > obj-$(CONFIG_CHARGER_MAX8998) += max8998_charger.o > > obj-$(CONFIG_CHARGER_MP2629) += mp2629_charger.o > > +obj-$(CONFIG_CHARGER_MT6360) += mt6360_charger.o > > obj-$(CONFIG_CHARGER_QCOM_SMBB)+= qcom_smbb.o > > obj-$(CONFIG_CHARGER_BQ2415X) += bq2415x_charger.o > > obj-$(CONFIG_CHARGER_BQ24190) += bq24190_charger.o > > diff --git a/drivers/power/supply/mt6360_charger.c > > b/drivers/power/supply/mt6360_charger.c > > new file mode 100644 > > index 000..5631875 > > --- /dev/null > > +++ b/drivers/power/supply/mt6360_charger.c > > @@ -0,0 +1,1022 @@ > > +// SPDX-License-Identifier: GPL-2.0 > > +/* > > + * Copyright (c) 2019 MediaTek Inc. > > + */ > > + > > +#include > > +#include > > +#include > > +#include > > +#include > > +#include > > +#include > > +#include > > +#include > > + > > +#define MT6360_PMU_CHG_CTRL1 0x311 > > +#define MT6360_PMU_CHG_CTRL2 0x312 > > +#define MT6360_PMU_CHG_CTRL3 0x313 > > +#define MT6360_PMU_CHG_CTRL4 0x314 > > +#define MT6360_PMU_CHG_CTRL5 0x315 > > +#define MT6360_PMU_CHG_CTRL6 0x316 > > +#define MT6360_PMU_CHG_CTRL7 0x317 > > +#define MT6360_PMU_CHG_CTRL8 0x318 > > +#define MT6360_PMU_CHG_CTRL9 0x319 > > +#define MT6360_PMU_CHG_CTRL10 0x31A > > +#define MT6360_PMU_CHG_CTRL11 0x31B > > +#define MT6360_PMU_CHG_CTRL12 0x31C > > +#define MT6360_PMU_CHG_CTRL13 0x31D > > +#define MT6360_PMU_DEVICE_TYPE 0x322 > > +#define MT6360_PMU_USB_STATUS1 0x327 > > +#define MT6360_PMU_CHG_CTRL17 0x32B > > +#define MT6360_PMU_CHG_CTRL18 0x32C > > +#define MT6360_PMU_CHG_STAT0x34A > > +#define MT6360_PMU_CHG_CTRL19 0x361 > > +#define MT6360_PMU_FOD_STAT0x3E7 > > + > > +/* MT6360_PMU_CHG_CTRL1 */ > > +#define MT6360_FSLP_SHFT (3) > > +#define MT6360_FSLP_MASK BIT(MT6360_FSLP_SHFT) > > +#define MT6360_HIZ_SHFT(2) > > +#define MT6360_HIZ_MASKBIT(MT6360_HIZ_SHFT) > > +#define MT6360_OPA_MODE_SHFT (0) > > +#define MT6360_OPA_MODE_MASK BIT(MT6360_OPA_MODE_SHFT) > > +/* MT6360_PMU_CHG_CTRL2 */ > > +#define MT6360_TE_SHFT (4) > > +#define MT6360_TE_MASK BIT(MT6360_TE_SHFT) > > +#define MT6360_IINLMTSEL_SHFT (2) > > +#define MT6360_IINLMTSEL_MASK GENMASK(3, 2) > > +#define MT6360_CHG_EN_SHFT (0) > > +#define MT6360_CHG_EN_MASK BIT(MT6360_CHG_EN_SHFT) > > +/* MT6360_PMU_CHG_CTRL3 */ > > +#define MT
[PATCH v4 1/2] dt-bindings: power: Add bindings document for Charger support on MT6360 PMIC
From: Gene Chen Add bindings document for Charger support on MT6360 PMIC Signed-off-by: Gene Chen Reviewed-by: Rob Herring --- .../bindings/power/supply/mt6360_charger.yaml | 48 ++ 1 file changed, 48 insertions(+) create mode 100644 Documentation/devicetree/bindings/power/supply/mt6360_charger.yaml diff --git a/Documentation/devicetree/bindings/power/supply/mt6360_charger.yaml b/Documentation/devicetree/bindings/power/supply/mt6360_charger.yaml new file mode 100644 index 000..b89b15a --- /dev/null +++ b/Documentation/devicetree/bindings/power/supply/mt6360_charger.yaml @@ -0,0 +1,48 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/power/supply/mt6360_charger.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Battery charger driver for MT6360 PMIC from MediaTek Integrated. + +maintainers: + - Gene Chen + +description: | + This module is part of the MT6360 MFD device. + Provides Battery Charger, Boost for OTG devices and BC1.2 detection. + +properties: + compatible: +const: mediatek,mt6360-chg + + richtek,vinovp-microvolt: +description: Maximum CHGIN regulation voltage in uV. +enum: [ 550, 650, 1100, 1450 ] + + + usb-otg-vbus-regulator: +type: object +description: OTG boost regulator. +$ref: /schemas/regulator/regulator.yaml# + +required: + - compatible + +additionalProperties: false + +examples: + - | +mt6360_charger: charger { + compatible = "mediatek,mt6360-chg"; + richtek,vinovp-microvolt = <1450>; + + otg_vbus_regulator: usb-otg-vbus-regulator { +regulator-compatible = "usb-otg-vbus"; +regulator-name = "usb-otg-vbus"; +regulator-min-microvolt = <4425000>; +regulator-max-microvolt = <5825000>; + }; +}; +... -- 2.7.4
[PATCH v4 0/2] power: supply: mt6360_charger: add MT6360 charger support
This patch series add MT6360 Charger support contains driver and binding document Gene Chen (2) dt-bindings: power: Add bindings document for Charger support on MT6360 PMIC power: supply: mt6360_charger: add MT6360 charger support Documentation/devicetree/bindings/power/supply/mt6360_charger.yaml | 48 drivers/power/supply/Kconfig | 10 drivers/power/supply/Makefile |1 drivers/power/supply/mt6360_charger.c | 914 ++ 4 files changed, 973 insertions(+) changelogs between v1 & v2 - Add binding property with unit and custom name prefix - Remove extcon device, redundant brackets and interrupts - Fix power supply prop "charger type" changelogs between v2 & v3 - Add register selector to value mapping changelogs between v3 & v4 - move pdata vinovp to mt6360_chg_info - remove unuse sysfs attribute - refactor debug log and warning - add power supply prop input voltage limit
[PATCH v4 2/2] power: supply: mt6360_charger: add MT6360 charger support
From: Gene Chen Add basic support for the battery charger for MT6360 PMIC Signed-off-by: Gene Chen --- drivers/power/supply/Kconfig | 10 + drivers/power/supply/Makefile | 1 + drivers/power/supply/mt6360_charger.c | 914 ++ 3 files changed, 925 insertions(+) create mode 100644 drivers/power/supply/mt6360_charger.c diff --git a/drivers/power/supply/Kconfig b/drivers/power/supply/Kconfig index eec646c..dd63bed 100644 --- a/drivers/power/supply/Kconfig +++ b/drivers/power/supply/Kconfig @@ -567,6 +567,16 @@ config CHARGER_MP2629 Battery charger. This driver provides Battery charger power management functions on the systems. +config CHARGER_MT6360 + tristate "Mediatek MT6360 Charger Driver" + depends on MFD_MT6360 + depends on REGULATOR + help + Say Y here to enable MT6360 Charger Part. + The device supports High-Accuracy Voltage/Current Regulation, + Average Input Current Regulation, Battery Tempature Sensing, + Over-Temperature Protection, DPDM Detection for BC1.2 + config CHARGER_QCOM_SMBB tristate "Qualcomm Switch-Mode Battery Charger and Boost" depends on MFD_SPMI_PMIC || COMPILE_TEST diff --git a/drivers/power/supply/Makefile b/drivers/power/supply/Makefile index dd4b863..9bd0804 100644 --- a/drivers/power/supply/Makefile +++ b/drivers/power/supply/Makefile @@ -77,6 +77,7 @@ obj-$(CONFIG_CHARGER_MAX77693)+= max77693_charger.o obj-$(CONFIG_CHARGER_MAX8997) += max8997_charger.o obj-$(CONFIG_CHARGER_MAX8998) += max8998_charger.o obj-$(CONFIG_CHARGER_MP2629) += mp2629_charger.o +obj-$(CONFIG_CHARGER_MT6360) += mt6360_charger.o obj-$(CONFIG_CHARGER_QCOM_SMBB)+= qcom_smbb.o obj-$(CONFIG_CHARGER_BQ2415X) += bq2415x_charger.o obj-$(CONFIG_CHARGER_BQ24190) += bq24190_charger.o diff --git a/drivers/power/supply/mt6360_charger.c b/drivers/power/supply/mt6360_charger.c new file mode 100644 index 000..d80bdad --- /dev/null +++ b/drivers/power/supply/mt6360_charger.c @@ -0,0 +1,914 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Copyright (c) 2021 MediaTek Inc. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define MT6360_PMU_CHG_CTRL1 0x311 +#define MT6360_PMU_CHG_CTRL2 0x312 +#define MT6360_PMU_CHG_CTRL3 0x313 +#define MT6360_PMU_CHG_CTRL4 0x314 +#define MT6360_PMU_CHG_CTRL5 0x315 +#define MT6360_PMU_CHG_CTRL6 0x316 +#define MT6360_PMU_CHG_CTRL7 0x317 +#define MT6360_PMU_CHG_CTRL8 0x318 +#define MT6360_PMU_CHG_CTRL9 0x319 +#define MT6360_PMU_CHG_CTRL10 0x31A +#define MT6360_PMU_DEVICE_TYPE 0x322 +#define MT6360_PMU_USB_STATUS1 0x327 +#define MT6360_PMU_CHG_STAT0x34A +#define MT6360_PMU_CHG_CTRL19 0x361 +#define MT6360_PMU_FOD_STAT0x3E7 + +/* MT6360_PMU_CHG_CTRL1 */ +#define MT6360_FSLP_SHFT (3) +#define MT6360_FSLP_MASK BIT(MT6360_FSLP_SHFT) +#define MT6360_OPA_MODE_SHFT (0) +#define MT6360_OPA_MODE_MASK BIT(MT6360_OPA_MODE_SHFT) +/* MT6360_PMU_CHG_CTRL2 */ +#define MT6360_IINLMTSEL_SHFT (2) +#define MT6360_IINLMTSEL_MASK GENMASK(3, 2) +/* MT6360_PMU_CHG_CTRL3 */ +#define MT6360_IAICR_SHFT (2) +#define MT6360_IAICR_MASK GENMASK(7, 2) +#define MT6360_ILIM_EN_MASKBIT(0) +/* MT6360_PMU_CHG_CTRL4 */ +#define MT6360_VOREG_SHFT (1) +#define MT6360_VOREG_MASK GENMASK(7, 1) +/* MT6360_PMU_CHG_CTRL5 */ +#define MT6360_VOBST_MASK GENMASK(7, 2) +/* MT6360_PMU_CHG_CTRL6 */ +#define MT6360_VMIVR_SHFT (1) +#define MT6360_VMIVR_MASK GENMASK(7, 1) +/* MT6360_PMU_CHG_CTRL7 */ +#define MT6360_ICHG_SHFT (2) +#define MT6360_ICHG_MASK GENMASK(7, 2) +/* MT6360_PMU_CHG_CTRL8 */ +#define MT6360_IPREC_SHFT (0) +#define MT6360_IPREC_MASK GENMASK(3, 0) +/* MT6360_PMU_CHG_CTRL9 */ +#define MT6360_IEOC_SHFT (4) +#define MT6360_IEOC_MASK GENMASK(7, 4) +/* MT6360_PMU_CHG_CTRL10 */ +#define MT6360_OTG_OC_MASK GENMASK(3, 0) +/* MT6360_PMU_DEVICE_TYPE */ +#define MT6360_USBCHGEN_MASK BIT(7) +/* MT6360_PMU_USB_STATUS1 */ +#define MT6360_USB_STATUS_SHFT (4) +#define MT6360_USB_STATUS_MASK GENMASK(6, 4) +/* MT6360_PMU_CHG_STAT */ +#define MT6360_CHG_STAT_SHFT (6) +#define MT6360_CHG_STAT_MASK GENMASK(7, 6) +#define MT6360_VBAT_LVL_MASK BIT(5) +/* MT6360_PMU_CHG_CTRL19 */ +#define MT6360_VINOVP_SHFT (5) +#define MT6360_VINOVP_MASK GENMASK(6, 5) +/* MT6360_PMU_FOD_STAT */ +#define MT6360_CHRDET_EXT_MASK BIT(4) + +/* uV */ +#define MT6360_VMIVR_MIN 390 +#define MT6360_VMIVR_MAX 1340 +#define MT6360_VMIVR_STEP 10 +/* uA */ +#define MT6360_ICHG_MIN10 +#define MT6360_ICHG_MAX500 +#define MT6360_ICHG_STEP 10 +/* uV */ +#define MT6360_VOREG_MIN 390 +#define MT6360_VOREG_MAX 471 +#define MT6360_VOREG_STEP 1 +/* uA */ +#de
Re: [PATCH v7 04/11] mfd: mt6360: Combine mt6360 pmic/ldo resources into mt6360 regulator resources
Matthias Brugger 於 2021年1月12日 週二 下午8:32寫道: > > > > On 12/11/2020 11:39, Gene Chen wrote: > > From: Gene Chen > > > > Combine mt6360 pmic/ldo resources into mt6360 regulator resources > > to simplify the similar resources object. > > > > Signed-off-by: Gene Chen > > Acked-for-MFD-by: Lee Jones > > --- > > drivers/mfd/mt6360-core.c | 11 +++ > > 1 file changed, 3 insertions(+), 8 deletions(-) > > > > diff --git a/drivers/mfd/mt6360-core.c b/drivers/mfd/mt6360-core.c > > index 692e47b..5119e51 100644 > > --- a/drivers/mfd/mt6360-core.c > > +++ b/drivers/mfd/mt6360-core.c > > @@ -265,7 +265,7 @@ static const struct resource mt6360_led_resources[] = { > > DEFINE_RES_IRQ_NAMED(MT6360_FLED1_STRB_TO_EVT, "fled1_strb_to_evt"), > > }; > > > > -static const struct resource mt6360_pmic_resources[] = { > > +static const struct resource mt6360_regulator_resources[] = { > > DEFINE_RES_IRQ_NAMED(MT6360_BUCK1_PGB_EVT, "buck1_pgb_evt"), > > DEFINE_RES_IRQ_NAMED(MT6360_BUCK1_OC_EVT, "buck1_oc_evt"), > > DEFINE_RES_IRQ_NAMED(MT6360_BUCK1_OV_EVT, "buck1_ov_evt"), > > @@ -278,9 +278,6 @@ static const struct resource mt6360_pmic_resources[] = { > > DEFINE_RES_IRQ_NAMED(MT6360_LDO7_OC_EVT, "ldo7_oc_evt"), > > DEFINE_RES_IRQ_NAMED(MT6360_LDO6_PGB_EVT, "ldo6_pgb_evt"), > > DEFINE_RES_IRQ_NAMED(MT6360_LDO7_PGB_EVT, "ldo7_pgb_evt"), > > -}; > > - > > -static const struct resource mt6360_ldo_resources[] = { > > DEFINE_RES_IRQ_NAMED(MT6360_LDO1_OC_EVT, "ldo1_oc_evt"), > > DEFINE_RES_IRQ_NAMED(MT6360_LDO2_OC_EVT, "ldo2_oc_evt"), > > DEFINE_RES_IRQ_NAMED(MT6360_LDO3_OC_EVT, "ldo3_oc_evt"), > > @@ -298,10 +295,8 @@ static const struct mfd_cell mt6360_devs[] = { > > NULL, 0, 0, "mediatek,mt6360-chg"), > > OF_MFD_CELL("mt6360-led", mt6360_led_resources, > > NULL, 0, 0, "mediatek,mt6360-led"), > > - OF_MFD_CELL("mt6360-pmic", mt6360_pmic_resources, > > - NULL, 0, 0, "mediatek,mt6360-pmic"), > > - OF_MFD_CELL("mt6360-ldo", mt6360_ldo_resources, > > - NULL, 0, 0, "mediatek,mt6360-ldo"), > > + OF_MFD_CELL("mt6360-regulator", mt6360_regulator_resources, > > + NULL, 0, 0, "mediatek,mt6360-regulator"), > > As discussed with the MFD maintainer [1], the regulator (and probably all > cells) > shouldn't have a DT binding. > > So please send a new version which fixes that. > > Regards, > Matthias > > [1] > https://lore.kernel.org/linux-mediatek/2021064118.ge4...@sirena.org.uk/ > Should I use parent's device to find sub-devices of_node if without compatible name? I trace the function mfd_add_device, if (IS_ENABLED(CONFIG_OF) && parent->of_node && cell->of_compatible) { . ret = mfd_match_of_node_to_dev(pdev, np, cell); . } which is binding mfd sub-device with compatible. Does it be removed in the feature? > > OF_MFD_CELL("mt6360-tcpc", NULL, > > NULL, 0, 0, "mediatek,mt6360-tcpc"), > > }; > >
[PATCH resend v13 0/5] leds: mt6360: Add LED driver for MT6360
This patch series add MT6360 LED support contains driver and binding document Gene Chen (5) leds: flash: Add flash registration with undefined CONFIG_LEDS_CLASS_FLASH leds: flash: Fix multicolor no-ops registration by return 0 dt-bindings: leds: Add LED_COLOR_ID_MOONLIGHT definitions dt-bindings: leds: Add bindings for MT6360 LED leds: mt6360: Add LED driver for MT6360 Documentation/devicetree/bindings/leds/leds-mt6360.yaml | 159 +++ drivers/leds/Kconfig| 13 drivers/leds/Makefile |1 drivers/leds/leds-mt6360.c | 827 include/dt-bindings/leds/common.h |1 include/linux/led-class-flash.h | 42 include/linux/led-class-multicolor.h| 42 7 files changed, 1049 insertions(+), 36 deletions(-) changelogs between v1 & v2 - add led driver with mfd changelogs between v2 & v3 - independent add led driver - add dt-binding document - refactor macros definition for easy to debug - parse device tree by fwnode - use devm*ext to register led class device changelogs between v3 & v4 - fix binding document description - use GENMASK and add unit postfix to definition - isink register led class device changelogs between v4 & v5 - change rgb isink to multicolor control - add binding reference to mfd yaml changelogs between v5 & v6 - Use DT to decide RGB LED is multicolor device or indicator device only changelogs between v6 & v7 - Add binding multicolor device sample code - Add flash ops mutex lock - Remove V4L2 init with indicator device changelogs between v7 & v8 - Add mutex for led fault get ops - Fix flash and multicolor no-ops return 0 - Add LED_FUNCTION_MOONLIGHT changelogs between v8 & v9 - reuse api in flash and multicolor header changelogs between v9 & v10 - add comment for reuse registration functions in flash and multicolor changelogs between v10 & v11 - match dt-binding reg property comment to the functionality name - remove exist patch in linux-next - dicide multicolor channel by color definitiion changelogs between v11 & v12 - Fix print size_t by %zu - Fix dt-binding name regular experssion changelogs between v12 & v13 - Fix kbuild test rebot build error
[PATCH resend v13 1/5] leds: flash: Add flash registration with undefined CONFIG_LEDS_CLASS_FLASH
From: Gene Chen Add flash registration with undefined CONFIG_LEDS_CLASS_FLASH, and move the same registration functions outside of #ifdef block. Signed-off-by: Gene Chen Acked-by: Jacek Anaszewski --- include/linux/led-class-flash.h | 42 - 1 file changed, 33 insertions(+), 9 deletions(-) diff --git a/include/linux/led-class-flash.h b/include/linux/led-class-flash.h index 21a3358..612b4ca 100644 --- a/include/linux/led-class-flash.h +++ b/include/linux/led-class-flash.h @@ -85,6 +85,7 @@ static inline struct led_classdev_flash *lcdev_to_flcdev( return container_of(lcdev, struct led_classdev_flash, led_cdev); } +#if IS_ENABLED(CONFIG_LEDS_CLASS_FLASH) /** * led_classdev_flash_register_ext - register a new object of LED class with * init data and with support for flash LEDs @@ -98,12 +99,6 @@ int led_classdev_flash_register_ext(struct device *parent, struct led_classdev_flash *fled_cdev, struct led_init_data *init_data); -static inline int led_classdev_flash_register(struct device *parent, - struct led_classdev_flash *fled_cdev) -{ - return led_classdev_flash_register_ext(parent, fled_cdev, NULL); -} - /** * led_classdev_flash_unregister - unregisters an object of led_classdev class *with support for flash LEDs @@ -118,15 +113,44 @@ int devm_led_classdev_flash_register_ext(struct device *parent, struct led_init_data *init_data); +void devm_led_classdev_flash_unregister(struct device *parent, + struct led_classdev_flash *fled_cdev); + +#else + +static inline int led_classdev_flash_register_ext(struct device *parent, + struct led_classdev_flash *fled_cdev, + struct led_init_data *init_data) +{ + return 0; +} + +static inline void led_classdev_flash_unregister(struct led_classdev_flash *fled_cdev) {}; +static inline int devm_led_classdev_flash_register_ext(struct device *parent, +struct led_classdev_flash *fled_cdev, +struct led_init_data *init_data) +{ + return 0; +} + +static inline void devm_led_classdev_flash_unregister(struct device *parent, + struct led_classdev_flash *fled_cdev) +{}; + +#endif /* IS_ENABLED(CONFIG_LEDS_CLASS_FLASH) */ + +static inline int led_classdev_flash_register(struct device *parent, + struct led_classdev_flash *fled_cdev) +{ + return led_classdev_flash_register_ext(parent, fled_cdev, NULL); +} + static inline int devm_led_classdev_flash_register(struct device *parent, struct led_classdev_flash *fled_cdev) { return devm_led_classdev_flash_register_ext(parent, fled_cdev, NULL); } -void devm_led_classdev_flash_unregister(struct device *parent, - struct led_classdev_flash *fled_cdev); - /** * led_set_flash_strobe - setup flash strobe * @fled_cdev: the flash LED to set strobe on -- 2.7.4
[PATCH resend v13 2/5] leds: flash: Fix multicolor no-ops registration by return 0
From: Gene Chen Fix multicolor no-ops registration by return 0, and move the same registration functions outside of #ifdef block. Signed-off-by: Gene Chen Acked-by: Jacek Anaszewski --- include/linux/led-class-multicolor.h | 42 +--- 1 file changed, 15 insertions(+), 27 deletions(-) diff --git a/include/linux/led-class-multicolor.h b/include/linux/led-class-multicolor.h index 5116f9a..210d57b 100644 --- a/include/linux/led-class-multicolor.h +++ b/include/linux/led-class-multicolor.h @@ -44,12 +44,6 @@ int led_classdev_multicolor_register_ext(struct device *parent, struct led_classdev_mc *mcled_cdev, struct led_init_data *init_data); -static inline int led_classdev_multicolor_register(struct device *parent, - struct led_classdev_mc *mcled_cdev) -{ - return led_classdev_multicolor_register_ext(parent, mcled_cdev, NULL); -} - /** * led_classdev_multicolor_unregister - unregisters an object of led_classdev * class with support for multicolor LEDs @@ -68,13 +62,6 @@ int devm_led_classdev_multicolor_register_ext(struct device *parent, struct led_classdev_mc *mcled_cdev, struct led_init_data *init_data); -static inline int devm_led_classdev_multicolor_register(struct device *parent, -struct led_classdev_mc *mcled_cdev) -{ - return devm_led_classdev_multicolor_register_ext(parent, mcled_cdev, -NULL); -} - void devm_led_classdev_multicolor_unregister(struct device *parent, struct led_classdev_mc *mcled_cdev); #else @@ -83,27 +70,33 @@ static inline int led_classdev_multicolor_register_ext(struct device *parent, struct led_classdev_mc *mcled_cdev, struct led_init_data *init_data) { - return -EINVAL; -} - -static inline int led_classdev_multicolor_register(struct device *parent, - struct led_classdev_mc *mcled_cdev) -{ - return led_classdev_multicolor_register_ext(parent, mcled_cdev, NULL); + return 0; } static inline void led_classdev_multicolor_unregister(struct led_classdev_mc *mcled_cdev) {}; static inline int led_mc_calc_color_components(struct led_classdev_mc *mcled_cdev, enum led_brightness brightness) { - return -EINVAL; + return 0; } static inline int devm_led_classdev_multicolor_register_ext(struct device *parent, struct led_classdev_mc *mcled_cdev, struct led_init_data *init_data) { - return -EINVAL; + return 0; +} + +static inline void devm_led_classdev_multicolor_unregister(struct device *parent, + struct led_classdev_mc *mcled_cdev) +{}; + +#endif /* IS_ENABLED(CONFIG_LEDS_CLASS_MULTICOLOR) */ + +static inline int led_classdev_multicolor_register(struct device *parent, + struct led_classdev_mc *mcled_cdev) +{ + return led_classdev_multicolor_register_ext(parent, mcled_cdev, NULL); } static inline int devm_led_classdev_multicolor_register(struct device *parent, @@ -113,9 +106,4 @@ static inline int devm_led_classdev_multicolor_register(struct device *parent, NULL); } -static inline void devm_led_classdev_multicolor_unregister(struct device *parent, - struct led_classdev_mc *mcled_cdev) -{}; - -#endif /* IS_ENABLED(CONFIG_LEDS_CLASS_MULTICOLOR) */ #endif /* _LINUX_MULTICOLOR_LEDS_H_INCLUDED */ -- 2.7.4
[PATCH resend v13 4/5] dt-bindings: leds: Add bindings for MT6360 LED
From: Gene Chen Add bindings document for LED support on MT6360 PMIC Signed-off-by: Gene Chen Reviewed-by: Rob Herring --- .../devicetree/bindings/leds/leds-mt6360.yaml | 159 + 1 file changed, 159 insertions(+) create mode 100644 Documentation/devicetree/bindings/leds/leds-mt6360.yaml diff --git a/Documentation/devicetree/bindings/leds/leds-mt6360.yaml b/Documentation/devicetree/bindings/leds/leds-mt6360.yaml new file mode 100644 index 000..cb1f4b7 --- /dev/null +++ b/Documentation/devicetree/bindings/leds/leds-mt6360.yaml @@ -0,0 +1,159 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/leds/leds-mt6360.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: LED driver for MT6360 PMIC from MediaTek Integrated. + +maintainers: + - Gene Chen + +description: | + This module is part of the MT6360 MFD device. + see Documentation/devicetree/bindings/mfd/mt6360.yaml + Add MT6360 LED driver include 2-channel Flash LED with torch/strobe mode, + and 4-channel RGB LED support Register/Flash/Breath Mode + +properties: + compatible: +const: mediatek,mt6360-led + + "#address-cells": +const: 1 + + "#size-cells": +const: 0 + +patternProperties: + "^(multi-)?led@[0-5]$": +type: object +$ref: common.yaml# +description: + Properties for a single LED. + +properties: + reg: +description: Index of the LED. +enum: + - 0 # LED output ISINK1 + - 1 # LED output ISINK2 + - 2 # LED output ISINK3 + - 3 # LED output ISINKML + - 4 # LED output FLASH1 + - 5 # LED output FLASH2 + +unevaluatedProperties: false + +required: + - compatible + - "#address-cells" + - "#size-cells" + +additionalProperties: false + +examples: + - | + #include + led-controller { + compatible = "mediatek,mt6360-led"; + #address-cells = <1>; + #size-cells = <0>; + + multi-led@0 { + reg = <0>; + function = LED_FUNCTION_INDICATOR; + color = ; + led-max-microamp = <24000>; + #address-cells = <1>; + #size-cells = <0>; + led@0 { + reg = <0>; + color = ; + }; + led@1 { + reg = <1>; + color = ; + }; + led@2 { + reg = <2>; + color = ; + }; + }; + led@3 { + reg = <3>; + function = LED_FUNCTION_MOONLIGHT; + color = ; + led-max-microamp = <15>; + }; + led@4 { + reg = <4>; + function = LED_FUNCTION_FLASH; + color = ; + function-enumerator = <1>; + led-max-microamp = <20>; + flash-max-microamp = <50>; + flash-max-timeout-us = <1024000>; + }; + led@5 { + reg = <5>; + function = LED_FUNCTION_FLASH; + color = ; + function-enumerator = <2>; + led-max-microamp = <20>; + flash-max-microamp = <50>; + flash-max-timeout-us = <1024000>; + }; + }; + + - | + + led-controller { + compatible = "mediatek,mt6360-led"; + #address-cells = <1>; + #size-cells = <0>; + + led@0 { + reg = <0>; + function = LED_FUNCTION_INDICATOR; + color = ; + led-max-microamp = <24000>; + }; + led@1 { + reg = <1>; + function = LED_FUNCTION_INDICATOR; + color = ; + led-max-microamp = <24000>; + }; + led@2 { + reg = <2>; + function = LED_FUNCTION_INDICATOR; + color = ; + led-max-microamp = <24000>; + }; + led@3 { + reg = <3>; + function = LED_FUNCTION_MOONLIGHT; + color = ; + led-max-microamp = <15>; + }; + led@4 { + reg = <4>; + function = LED_FUNCTION_FLASH; + color = ; + function-enumerator = <1>; + led-max-microamp = <20>; + flash-max-microamp = <50>; + flash-max-timeout-us = <1024000>; + }; + led@5 { + reg = <5>; + function = LED_FUNCTION_FLASH; + color = ; + function-enumerator = <2>; + led-max-microamp = <20>; + flash-max-microamp = <50>; + flash-max-timeout-us = <1024000>; + }; + }; +... -- 2.7.4
[PATCH resend v13 3/5] dt-bindings: leds: Add LED_FUNCTION_MOONLIGHT definitions
From: Gene Chen Add LED_FUNCTION_MOONLIGHT definitions Signed-off-by: Gene Chen Acked-by: Jacek Anaszewski Acked-by: Rob Herring --- include/dt-bindings/leds/common.h | 1 + 1 file changed, 1 insertion(+) diff --git a/include/dt-bindings/leds/common.h b/include/dt-bindings/leds/common.h index 52b619d..843e65d 100644 --- a/include/dt-bindings/leds/common.h +++ b/include/dt-bindings/leds/common.h @@ -78,6 +78,7 @@ #define LED_FUNCTION_INDICATOR "indicator" #define LED_FUNCTION_LAN "lan" #define LED_FUNCTION_MAIL "mail" +#define LED_FUNCTION_MOONLIGHT "moonlight" #define LED_FUNCTION_MTD "mtd" #define LED_FUNCTION_PANIC "panic" #define LED_FUNCTION_PROGRAMMING "programming" -- 2.7.4
[PATCH resend v13 5/5] leds: mt6360: Add LED driver for MT6360
From: Gene Chen Add MT6360 LED driver include 2-channel Flash LED with torch/strobe mode, 3-channel RGB LED support Register/Flash/Breath Mode, and 1-channel for moonlight LED. Signed-off-by: Gene Chen --- drivers/leds/Kconfig | 13 + drivers/leds/Makefile | 1 + drivers/leds/leds-mt6360.c | 826 + 3 files changed, 840 insertions(+) create mode 100644 drivers/leds/leds-mt6360.c diff --git a/drivers/leds/Kconfig b/drivers/leds/Kconfig index 849d3c5..3c1999d 100644 --- a/drivers/leds/Kconfig +++ b/drivers/leds/Kconfig @@ -271,6 +271,19 @@ config LEDS_MT6323 This option enables support for on-chip LED drivers found on Mediatek MT6323 PMIC. +config LEDS_MT6360 + tristate "LED Support for Mediatek MT6360 PMIC" + depends on LEDS_CLASS && OF + depends on LEDS_CLASS_FLASH || !LEDS_CLASS_FLASH + depends on LEDS_CLASS_MULTICOLOR || !LEDS_CLASS_MULTICOLOR + depends on V4L2_FLASH_LED_CLASS || !V4L2_FLASH_LED_CLASS + depends on MFD_MT6360 + help + This option enables support for dual Flash LED drivers found on + Mediatek MT6360 PMIC. + Independent current sources supply for each flash LED support torch + and strobe mode. + config LEDS_S3C24XX tristate "LED Support for Samsung S3C24XX GPIO LEDs" depends on LEDS_CLASS diff --git a/drivers/leds/Makefile b/drivers/leds/Makefile index 73e603e..cdb1ffb 100644 --- a/drivers/leds/Makefile +++ b/drivers/leds/Makefile @@ -68,6 +68,7 @@ obj-$(CONFIG_LEDS_MIKROTIK_RB532) += leds-rb532.o obj-$(CONFIG_LEDS_MLXCPLD) += leds-mlxcpld.o obj-$(CONFIG_LEDS_MLXREG) += leds-mlxreg.o obj-$(CONFIG_LEDS_MT6323) += leds-mt6323.o +obj-$(CONFIG_LEDS_MT6360) += leds-mt6360.o obj-$(CONFIG_LEDS_NET48XX) += leds-net48xx.o obj-$(CONFIG_LEDS_NETXBIG) += leds-netxbig.o obj-$(CONFIG_LEDS_NIC78BX) += leds-nic78bx.o diff --git a/drivers/leds/leds-mt6360.c b/drivers/leds/leds-mt6360.c new file mode 100644 index 000..86caaac --- /dev/null +++ b/drivers/leds/leds-mt6360.c @@ -0,0 +1,826 @@ +// SPDX-License-Identifier: GPL-2.0-only + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +enum { + MT6360_LED_ISNK1 = 0, + MT6360_LED_ISNK2, + MT6360_LED_ISNK3, + MT6360_LED_ISNKML, + MT6360_LED_FLASH1, + MT6360_LED_FLASH2, + MT6360_MAX_LEDS +}; + +#define MT6360_REG_RGBEN 0x380 +#define MT6360_REG_ISNK(_led_no) (0x381 + (_led_no)) +#define MT6360_ISNK_ENMASK(_led_no)BIT(7 - (_led_no)) +#define MT6360_ISNK_MASK GENMASK(4, 0) +#define MT6360_CHRINDSEL_MASK BIT(3) + +/* Virtual definition for multicolor */ +#define MT6360_VIRTUAL_MULTICOLOR (MT6360_MAX_LEDS + 1) +#define MULTICOLOR_NUM_CHANNELS3 + +#define MT6360_REG_FLEDEN 0x37E +#define MT6360_REG_STRBTO 0x373 +#define MT6360_REG_FLEDBASE(_id) (0x372 + 4 * (_id - MT6360_LED_FLASH1)) +#define MT6360_REG_FLEDISTRB(_id) (MT6360_REG_FLEDBASE(_id) + 2) +#define MT6360_REG_FLEDITOR(_id) (MT6360_REG_FLEDBASE(_id) + 3) +#define MT6360_REG_CHGSTAT20x3E1 +#define MT6360_REG_FLEDSTAT1 0x3E9 +#define MT6360_ITORCH_MASK GENMASK(4, 0) +#define MT6360_ISTROBE_MASKGENMASK(6, 0) +#define MT6360_STRBTO_MASK GENMASK(6, 0) +#define MT6360_TORCHEN_MASKBIT(3) +#define MT6360_STROBEN_MASKBIT(2) +#define MT6360_FLCSEN_MASK(_id)BIT(MT6360_LED_FLASH2 - _id) +#define MT6360_FLEDCHGVINOVP_MASK BIT(3) +#define MT6360_FLED1STRBTO_MASKBIT(11) +#define MT6360_FLED2STRBTO_MASKBIT(10) +#define MT6360_FLED1STRB_MASK BIT(9) +#define MT6360_FLED2STRB_MASK BIT(8) +#define MT6360_FLED1SHORT_MASK BIT(7) +#define MT6360_FLED2SHORT_MASK BIT(6) +#define MT6360_FLEDLVF_MASKBIT(3) + +#define MT6360_ISNKRGB_STEPUA 2000 +#define MT6360_ISNKRGB_MAXUA 24000 +#define MT6360_ISNKML_STEPUA 5000 +#define MT6360_ISNKML_MAXUA15 + +#define MT6360_ITORCH_MINUA25000 +#define MT6360_ITORCH_STEPUA 12500 +#define MT6360_ITORCH_MAXUA40 +#define MT6360_ISTRB_MINUA 5 +#define MT6360_ISTRB_STEPUA12500 +#define MT6360_ISTRB_MAXUA 150 +#define MT6360_STRBTO_MINUS64000 +#define MT6360_STRBTO_STEPUS 32000 +#define MT6360_STRBTO_MAXUS2432000 + +#define STATE_OFF 0 +#define STATE_KEEP 1 +#define STATE_ON 2 + +struct mt6360_led { + union { + struct led_classdev isnk; +
[PATCH resend] dt-bindings: mfd: mediatek: Add bindings for MT6360 PMIC
From: Gene Chen Add bindings for MT6360 PMIC Signed-off-by: Gene Chen --- Documentation/devicetree/bindings/mfd/mt6360.yaml | 69 +++ 1 file changed, 69 insertions(+) create mode 100644 Documentation/devicetree/bindings/mfd/mt6360.yaml diff --git a/Documentation/devicetree/bindings/mfd/mt6360.yaml b/Documentation/devicetree/bindings/mfd/mt6360.yaml new file mode 100644 index 000..2781c31 --- /dev/null +++ b/Documentation/devicetree/bindings/mfd/mt6360.yaml @@ -0,0 +1,69 @@ +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/mfd/mt6360.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: MT6360 PMIC from MediaTek Integrated + +maintainers: + - Gene Chen + +description: | + MT6360 is a PMIC device with the following sub modules. + It is interfaced to host controller using I2C interface. + + This document describes the binding for PMIC device and its sub module. + +properties: + compatible: +const: mediatek,mt6360 + + reg: +description: + I2C device address. +maxItems: 1 + + wakeup-source: true + + interrupts: +maxItems: 1 + + interrupt-names: + enum: +- IRQB + + interrupt-controller: true + + "#interrupt-cells": +const: 1 +description: + The first cell is the IRQ number. + +required: + - compatible + - reg + - interrupts + - interrupt-controller + - "#interrupt-cells" + +additionalProperties: false + +examples: + - | +#include +#include +i2c { +#address-cells = <1>; +#size-cells = <0>; + +mt6360@34 { +compatible = "mediatek,mt6360"; +reg = <0x34>; +wakeup-source; +interrupts-extended = <&gpio26 0 IRQ_TYPE_LEVEL_LOW>; +interrupt-names = "IRQB"; +interrupt-controller; +#interrupt-cells = <1>; +}; +}; -- 2.7.4
[PATCH v3 0/2] power: supply: mt6360_charger: add MT6360 charger support
This patch series add MT6360 Charger support contains driver and binding document Gene Chen (2) dt-bindings: power: Add bindings document for Charger support on MT6360 PMIC power: supply: mt6360_charger: add MT6360 charger support Documentation/devicetree/bindings/power/supply/mt6360_charger.yaml | 48 drivers/power/supply/Kconfig | 10 drivers/power/supply/Makefile |1 drivers/power/supply/mt6360_charger.c | 1022 ++ 4 files changed, 1081 insertions(+) changelogs between v1 & v2 - Add binding property with unit and custom name prefix - Remove extcon device, redundant brackets and interrupts - Fix power supply prop "charger type" changelogs between v2 & v3 - Add register selector to value mapping
[PATCH v3 1/2] dt-bindings: power: Add bindings document for Charger support on MT6360 PMIC
From: Gene Chen Add bindings document for Charger support on MT6360 PMIC Signed-off-by: Gene Chen Reviewed-by: Rob Herring --- .../bindings/power/supply/mt6360_charger.yaml | 48 ++ 1 file changed, 48 insertions(+) create mode 100644 Documentation/devicetree/bindings/power/supply/mt6360_charger.yaml diff --git a/Documentation/devicetree/bindings/power/supply/mt6360_charger.yaml b/Documentation/devicetree/bindings/power/supply/mt6360_charger.yaml new file mode 100644 index 000..b89b15a --- /dev/null +++ b/Documentation/devicetree/bindings/power/supply/mt6360_charger.yaml @@ -0,0 +1,48 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/power/supply/mt6360_charger.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Battery charger driver for MT6360 PMIC from MediaTek Integrated. + +maintainers: + - Gene Chen + +description: | + This module is part of the MT6360 MFD device. + Provides Battery Charger, Boost for OTG devices and BC1.2 detection. + +properties: + compatible: +const: mediatek,mt6360-chg + + richtek,vinovp-microvolt: +description: Maximum CHGIN regulation voltage in uV. +enum: [ 550, 650, 1100, 1450 ] + + + usb-otg-vbus-regulator: +type: object +description: OTG boost regulator. +$ref: /schemas/regulator/regulator.yaml# + +required: + - compatible + +additionalProperties: false + +examples: + - | +mt6360_charger: charger { + compatible = "mediatek,mt6360-chg"; + richtek,vinovp-microvolt = <1450>; + + otg_vbus_regulator: usb-otg-vbus-regulator { +regulator-compatible = "usb-otg-vbus"; +regulator-name = "usb-otg-vbus"; +regulator-min-microvolt = <4425000>; +regulator-max-microvolt = <5825000>; + }; +}; +... -- 2.7.4
[PATCH v3 2/2] power: supply: mt6360_charger: add MT6360 charger support
From: Gene Chen Add basic support for the battery charger for MT6360 PMIC Signed-off-by: Gene Chen --- drivers/power/supply/Kconfig | 10 + drivers/power/supply/Makefile |1 + drivers/power/supply/mt6360_charger.c | 1054 + 3 files changed, 1065 insertions(+) create mode 100644 drivers/power/supply/mt6360_charger.c diff --git a/drivers/power/supply/Kconfig b/drivers/power/supply/Kconfig index eec646c..dd63bed 100644 --- a/drivers/power/supply/Kconfig +++ b/drivers/power/supply/Kconfig @@ -567,6 +567,16 @@ config CHARGER_MP2629 Battery charger. This driver provides Battery charger power management functions on the systems. +config CHARGER_MT6360 + tristate "Mediatek MT6360 Charger Driver" + depends on MFD_MT6360 + depends on REGULATOR + help + Say Y here to enable MT6360 Charger Part. + The device supports High-Accuracy Voltage/Current Regulation, + Average Input Current Regulation, Battery Tempature Sensing, + Over-Temperature Protection, DPDM Detection for BC1.2 + config CHARGER_QCOM_SMBB tristate "Qualcomm Switch-Mode Battery Charger and Boost" depends on MFD_SPMI_PMIC || COMPILE_TEST diff --git a/drivers/power/supply/Makefile b/drivers/power/supply/Makefile index dd4b863..9bd0804 100644 --- a/drivers/power/supply/Makefile +++ b/drivers/power/supply/Makefile @@ -77,6 +77,7 @@ obj-$(CONFIG_CHARGER_MAX77693)+= max77693_charger.o obj-$(CONFIG_CHARGER_MAX8997) += max8997_charger.o obj-$(CONFIG_CHARGER_MAX8998) += max8998_charger.o obj-$(CONFIG_CHARGER_MP2629) += mp2629_charger.o +obj-$(CONFIG_CHARGER_MT6360) += mt6360_charger.o obj-$(CONFIG_CHARGER_QCOM_SMBB)+= qcom_smbb.o obj-$(CONFIG_CHARGER_BQ2415X) += bq2415x_charger.o obj-$(CONFIG_CHARGER_BQ24190) += bq24190_charger.o diff --git a/drivers/power/supply/mt6360_charger.c b/drivers/power/supply/mt6360_charger.c new file mode 100644 index 000..f1dcb97 --- /dev/null +++ b/drivers/power/supply/mt6360_charger.c @@ -0,0 +1,1054 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Copyright (c) 2019 MediaTek Inc. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define MT6360_PMU_CHG_CTRL1 0x311 +#define MT6360_PMU_CHG_CTRL2 0x312 +#define MT6360_PMU_CHG_CTRL3 0x313 +#define MT6360_PMU_CHG_CTRL4 0x314 +#define MT6360_PMU_CHG_CTRL5 0x315 +#define MT6360_PMU_CHG_CTRL6 0x316 +#define MT6360_PMU_CHG_CTRL7 0x317 +#define MT6360_PMU_CHG_CTRL8 0x318 +#define MT6360_PMU_CHG_CTRL9 0x319 +#define MT6360_PMU_CHG_CTRL10 0x31A +#define MT6360_PMU_CHG_CTRL11 0x31B +#define MT6360_PMU_CHG_CTRL12 0x31C +#define MT6360_PMU_CHG_CTRL13 0x31D +#define MT6360_PMU_DEVICE_TYPE 0x322 +#define MT6360_PMU_USB_STATUS1 0x327 +#define MT6360_PMU_CHG_CTRL17 0x32B +#define MT6360_PMU_CHG_CTRL18 0x32C +#define MT6360_PMU_CHG_STAT0x34A +#define MT6360_PMU_CHG_CTRL19 0x361 +#define MT6360_PMU_FOD_STAT0x3E7 + +/* MT6360_PMU_CHG_CTRL1 */ +#define MT6360_FSLP_SHFT (3) +#define MT6360_FSLP_MASK BIT(MT6360_FSLP_SHFT) +#define MT6360_HIZ_SHFT(2) +#define MT6360_HIZ_MASKBIT(MT6360_HIZ_SHFT) +#define MT6360_OPA_MODE_SHFT (0) +#define MT6360_OPA_MODE_MASK BIT(MT6360_OPA_MODE_SHFT) +/* MT6360_PMU_CHG_CTRL2 */ +#define MT6360_TE_SHFT (4) +#define MT6360_TE_MASK BIT(MT6360_TE_SHFT) +#define MT6360_IINLMTSEL_SHFT (2) +#define MT6360_IINLMTSEL_MASK GENMASK(3, 2) +#define MT6360_CHG_EN_SHFT (0) +#define MT6360_CHG_EN_MASK BIT(MT6360_CHG_EN_SHFT) +/* MT6360_PMU_CHG_CTRL3 */ +#define MT6360_IAICR_SHFT (2) +#define MT6360_IAICR_MASK GENMASK(7, 2) +#define MT6360_ILIM_EN_MASKBIT(0) +/* MT6360_PMU_CHG_CTRL4 */ +#define MT6360_VOREG_SHFT (1) +#define MT6360_VOREG_MASK GENMASK(7, 1) +/* MT6360_PMU_CHG_CTRL5 */ +#define MT6360_VOBST_MASK GENMASK(7, 2) +/* MT6360_PMU_CHG_CTRL6 */ +#define MT6360_VMIVR_SHFT (1) +#define MT6360_VMIVR_MASK GENMASK(7, 1) +/* MT6360_PMU_CHG_CTRL7 */ +#define MT6360_ICHG_SHFT (2) +#define MT6360_ICHG_MASK GENMASK(7, 2) +/* MT6360_PMU_CHG_CTRL8 */ +#define MT6360_IPREC_SHFT (0) +#define MT6360_IPREC_MASK GENMASK(3, 0) +/* MT6360_PMU_CHG_CTRL9 */ +#define MT6360_IEOC_SHFT (4) +#define MT6360_IEOC_MASK GENMASK(7, 4) +/* MT6360_PMU_CHG_CTRL10 */ +#define MT6360_LBP_SHFT(4) +#define MT6360_LBP_MASKGENMASK(7, 4) +#define MT6360_OTG_OC_SHFT (0) +#define MT6360_OTG_OC_MASK GENMASK(3, 0) +/* MT6360_PMU_CHG_CTRL11 */ +#define MT6360_SYSREG_SHFT (2) +#define MT6360_SYSREG_MASK GENMASK(4, 2) +#define MT6360_VREC_SHFT (0) +#define MT6360_VREC_MASK GENMASK(2, 0) +/* MT6360_PMU_CHG_CTRL12 */ +#define MT6360_WT_FC_SHFT (5) +#define MT6360_WT_FC_MASK GENMASK(7, 5) +/* MT6360_PMU_CH
Re: [PATCH v13 3/5] dt-bindings: leds: Add LED_FUNCTION_MOONLIGHT definitions
Gene Chen 於 2021年3月2日 週二 下午2:08寫道: > > Pavel Machek 於 2021年2月19日 週五 下午6:47寫道: > > > > Hi! > > > > > From: Gene Chen > > > > > > Add LED_FUNCTION_MOONLIGHT definitions > > > > > > Signed-off-by: Gene Chen > > > Acked-by: Jacek Anaszewski > > > Acked-by: Rob Herring > > > > No, sorry, I don't believe we need another define for flash/torch. > > > > As previous discuss, > > We use term "Moonlight" as reference says > > "When you are trying to imitate moonlight you need to use low voltage, > > softer lighting. You don’t want something that’s too bright" > > which is focus on brightness instead of color. > > If any concern about this change, maybe we use LED_FUNCTION_INDICATOR instead? > (refs: https://lkml.org/lkml/2020/11/24/1267) Is there any update? > > Best regards, > > Pavel > > -- > > http://www.livejournal.com/~pavelmachek
Re: [PATCH v4 2/2] power: supply: mt6360_charger: add MT6360 charger support
Gene Chen 於 2021年3月2日 週二 下午3:27寫道: > > Gene Chen 於 2021年1月18日 週一 下午8:42寫道: > > > > From: Gene Chen > > > > Add basic support for the battery charger for MT6360 PMIC > > > > Signed-off-by: Gene Chen > > --- > > drivers/power/supply/Kconfig | 10 + > > drivers/power/supply/Makefile | 1 + > > drivers/power/supply/mt6360_charger.c | 914 > > ++ > > 3 files changed, 925 insertions(+) > > create mode 100644 drivers/power/supply/mt6360_charger.c > > > > diff --git a/drivers/power/supply/Kconfig b/drivers/power/supply/Kconfig > > index eec646c..dd63bed 100644 > > --- a/drivers/power/supply/Kconfig > > +++ b/drivers/power/supply/Kconfig > > @@ -567,6 +567,16 @@ config CHARGER_MP2629 > > Battery charger. This driver provides Battery charger power > > management > > functions on the systems. > > > > +config CHARGER_MT6360 > > + tristate "Mediatek MT6360 Charger Driver" > > + depends on MFD_MT6360 > > + depends on REGULATOR > > + help > > + Say Y here to enable MT6360 Charger Part. > > + The device supports High-Accuracy Voltage/Current Regulation, > > + Average Input Current Regulation, Battery Tempature Sensing, > > + Over-Temperature Protection, DPDM Detection for BC1.2 > > + > > config CHARGER_QCOM_SMBB > > tristate "Qualcomm Switch-Mode Battery Charger and Boost" > > depends on MFD_SPMI_PMIC || COMPILE_TEST > > diff --git a/drivers/power/supply/Makefile b/drivers/power/supply/Makefile > > index dd4b863..9bd0804 100644 > > --- a/drivers/power/supply/Makefile > > +++ b/drivers/power/supply/Makefile > > @@ -77,6 +77,7 @@ obj-$(CONFIG_CHARGER_MAX77693)+= > > max77693_charger.o > > obj-$(CONFIG_CHARGER_MAX8997) += max8997_charger.o > > obj-$(CONFIG_CHARGER_MAX8998) += max8998_charger.o > > obj-$(CONFIG_CHARGER_MP2629) += mp2629_charger.o > > +obj-$(CONFIG_CHARGER_MT6360) += mt6360_charger.o > > obj-$(CONFIG_CHARGER_QCOM_SMBB)+= qcom_smbb.o > > obj-$(CONFIG_CHARGER_BQ2415X) += bq2415x_charger.o > > obj-$(CONFIG_CHARGER_BQ24190) += bq24190_charger.o > > diff --git a/drivers/power/supply/mt6360_charger.c > > b/drivers/power/supply/mt6360_charger.c > > new file mode 100644 > > index 000..d80bdad > > --- /dev/null > > +++ b/drivers/power/supply/mt6360_charger.c > > @@ -0,0 +1,914 @@ > > +// SPDX-License-Identifier: GPL-2.0 > > +/* > > + * Copyright (c) 2021 MediaTek Inc. > > + */ > > + > > +#include > > +#include > > +#include > > +#include > > +#include > > +#include > > +#include > > +#include > > +#include > > +#include > > + > > +#define MT6360_PMU_CHG_CTRL1 0x311 > > +#define MT6360_PMU_CHG_CTRL2 0x312 > > +#define MT6360_PMU_CHG_CTRL3 0x313 > > +#define MT6360_PMU_CHG_CTRL4 0x314 > > +#define MT6360_PMU_CHG_CTRL5 0x315 > > +#define MT6360_PMU_CHG_CTRL6 0x316 > > +#define MT6360_PMU_CHG_CTRL7 0x317 > > +#define MT6360_PMU_CHG_CTRL8 0x318 > > +#define MT6360_PMU_CHG_CTRL9 0x319 > > +#define MT6360_PMU_CHG_CTRL10 0x31A > > +#define MT6360_PMU_DEVICE_TYPE 0x322 > > +#define MT6360_PMU_USB_STATUS1 0x327 > > +#define MT6360_PMU_CHG_STAT0x34A > > +#define MT6360_PMU_CHG_CTRL19 0x361 > > +#define MT6360_PMU_FOD_STAT0x3E7 > > + > > +/* MT6360_PMU_CHG_CTRL1 */ > > +#define MT6360_FSLP_SHFT (3) > > +#define MT6360_FSLP_MASK BIT(MT6360_FSLP_SHFT) > > +#define MT6360_OPA_MODE_SHFT (0) > > +#define MT6360_OPA_MODE_MASK BIT(MT6360_OPA_MODE_SHFT) > > +/* MT6360_PMU_CHG_CTRL2 */ > > +#define MT6360_IINLMTSEL_SHFT (2) > > +#define MT6360_IINLMTSEL_MASK GENMASK(3, 2) > > +/* MT6360_PMU_CHG_CTRL3 */ > > +#define MT6360_IAICR_SHFT (2) > > +#define MT6360_IAICR_MASK GENMASK(7, 2) > > +#define MT6360_ILIM_EN_MASKBIT(0) > > +/* MT6360_PMU_CHG_CTRL4 */ > > +#define MT6360_VOREG_SHFT (1) > > +#define MT6360_VOREG_MASK GENMASK(7, 1) > > +/* MT6360_PMU_CHG_CTRL5 */ > > +#define MT6360_VOBST_MASK GENMASK(7, 2) > > +/* MT6360_PMU_CHG_CTRL6 */ > > +#define MT6360_VMIVR_SHFT (1) > > +#define MT6360_VMIVR_MASK GENMASK(7, 1) > > +/* MT6360_PMU_CHG_CTRL7 */ > > +#define MT6360_ICHG_SHFT (2) > > +#define MT6360_ICHG_MASK GENMASK(7, 2) > > +/* MT6360_PMU_CHG_CTRL8 */ > &g
Re: [PATCH v7 04/11] mfd: mt6360: Combine mt6360 pmic/ldo resources into mt6360 regulator resources
Gene Chen 於 2021年3月2日 週二 下午3:16寫道: > > Lee Jones 於 2021年1月15日 週五 下午3:32寫道: > > > > On Fri, 15 Jan 2021, Gene Chen wrote: > > > > > Matthias Brugger 於 2021年1月12日 週二 下午8:32寫道: > > > > > > > > > > > > > > > > On 12/11/2020 11:39, Gene Chen wrote: > > > > > From: Gene Chen > > > > > > > > > > Combine mt6360 pmic/ldo resources into mt6360 regulator resources > > > > > to simplify the similar resources object. > > > > > > > > > > Signed-off-by: Gene Chen > > > > > Acked-for-MFD-by: Lee Jones > > > > > --- > > > > > drivers/mfd/mt6360-core.c | 11 +++ > > > > > 1 file changed, 3 insertions(+), 8 deletions(-) > > > > > > > > > > diff --git a/drivers/mfd/mt6360-core.c b/drivers/mfd/mt6360-core.c > > > > > index 692e47b..5119e51 100644 > > > > > --- a/drivers/mfd/mt6360-core.c > > > > > +++ b/drivers/mfd/mt6360-core.c > > > > > @@ -265,7 +265,7 @@ static const struct resource > > > > > mt6360_led_resources[] = { > > > > > DEFINE_RES_IRQ_NAMED(MT6360_FLED1_STRB_TO_EVT, > > > > > "fled1_strb_to_evt"), > > > > > }; > > > > > > > > > > -static const struct resource mt6360_pmic_resources[] = { > > > > > +static const struct resource mt6360_regulator_resources[] = { > > > > > DEFINE_RES_IRQ_NAMED(MT6360_BUCK1_PGB_EVT, "buck1_pgb_evt"), > > > > > DEFINE_RES_IRQ_NAMED(MT6360_BUCK1_OC_EVT, "buck1_oc_evt"), > > > > > DEFINE_RES_IRQ_NAMED(MT6360_BUCK1_OV_EVT, "buck1_ov_evt"), > > > > > @@ -278,9 +278,6 @@ static const struct resource > > > > > mt6360_pmic_resources[] = { > > > > > DEFINE_RES_IRQ_NAMED(MT6360_LDO7_OC_EVT, "ldo7_oc_evt"), > > > > > DEFINE_RES_IRQ_NAMED(MT6360_LDO6_PGB_EVT, "ldo6_pgb_evt"), > > > > > DEFINE_RES_IRQ_NAMED(MT6360_LDO7_PGB_EVT, "ldo7_pgb_evt"), > > > > > -}; > > > > > - > > > > > -static const struct resource mt6360_ldo_resources[] = { > > > > > DEFINE_RES_IRQ_NAMED(MT6360_LDO1_OC_EVT, "ldo1_oc_evt"), > > > > > DEFINE_RES_IRQ_NAMED(MT6360_LDO2_OC_EVT, "ldo2_oc_evt"), > > > > > DEFINE_RES_IRQ_NAMED(MT6360_LDO3_OC_EVT, "ldo3_oc_evt"), > > > > > @@ -298,10 +295,8 @@ static const struct mfd_cell mt6360_devs[] = { > > > > > NULL, 0, 0, "mediatek,mt6360-chg"), > > > > > OF_MFD_CELL("mt6360-led", mt6360_led_resources, > > > > > NULL, 0, 0, "mediatek,mt6360-led"), > > > > > - OF_MFD_CELL("mt6360-pmic", mt6360_pmic_resources, > > > > > - NULL, 0, 0, "mediatek,mt6360-pmic"), > > > > > - OF_MFD_CELL("mt6360-ldo", mt6360_ldo_resources, > > > > > - NULL, 0, 0, "mediatek,mt6360-ldo"), > > > > > + OF_MFD_CELL("mt6360-regulator", mt6360_regulator_resources, > > > > > + NULL, 0, 0, "mediatek,mt6360-regulator"), > > > > > > > > As discussed with the MFD maintainer [1], the regulator (and probably > > > > all cells) > > > > shouldn't have a DT binding. > > > > > > > > So please send a new version which fixes that. > > > > > > > > Regards, > > > > Matthias > > > > > > > > [1] > > > > https://lore.kernel.org/linux-mediatek/2021064118.ge4...@sirena.org.uk/ > > > > I don't think Mark is correct here. > > > > We usually do implement compatible strings for sub-devices and they do > > tend to have their own device nodes. > > > > It's a very long time ago since I coded this up myself, but from > > memory, you can't have 2 devices share a compatible string. > > > > Either Mark or Lee suggestion is work. > Is there a conclusion that we can apply it? > If MFD is already supported of_compatible, we prefer use of_compatible > mapping. > Is there any update? > > > Should I use parent's device to find sub-devices of_node if without > > > compatible name? > > > I trace the function mfd_add_device, > > > > > > if (IS_ENABLED(CONFIG_OF) && parent->of_node && cell->of_compatible) { > > > . > > > ret = mfd_match_of_node_to_dev(pdev, np, cell); > > > . > > > } > > > > > > which is binding mfd sub-device with compatible. Does it be removed in > > > the feature? > > > > > > > > OF_MFD_CELL("mt6360-tcpc", NULL, > > > > > NULL, 0, 0, "mediatek,mt6360-tcpc"), > > > > > }; > > > > > > > > > -- > > Lee Jones [李琼斯] > > Senior Technical Lead - Developer Services > > Linaro.org │ Open source software for Arm SoCs > > Follow Linaro: Facebook | Twitter | Blog
Re: [PATCH v6 2/2] leds: mt6360: Add LED driver for MT6360
Jacek Anaszewski 於 2020年11月18日 週三 上午6:25寫道: > > Hi Gene, > > On 11/17/20 11:55 AM, Gene Chen wrote: > > From: Gene Chen > > > > Add MT6360 LED driver include 2-channel Flash LED with torch/strobe mode, > > 3-channel RGB LED support Register/Flash/Breath Mode, and 1-channel for > > moonlight LED. > > > > Signed-off-by: Gene Chen > > --- > > drivers/leds/Kconfig | 13 + > > drivers/leds/Makefile | 1 + > > drivers/leds/leds-mt6360.c | 817 > > + > > 3 files changed, 831 insertions(+) > > create mode 100644 drivers/leds/leds-mt6360.c > > > > diff --git a/drivers/leds/Kconfig b/drivers/leds/Kconfig > > index 1c181df..4f533bc 100644 > > --- a/drivers/leds/Kconfig > > +++ b/drivers/leds/Kconfig > > @@ -271,6 +271,19 @@ config LEDS_MT6323 > > This option enables support for on-chip LED drivers found on > > Mediatek MT6323 PMIC. > > > > +config LEDS_MT6360 > > + tristate "LED Support for Mediatek MT6360 PMIC" > > + depends on LEDS_CLASS && OF > > + depends on LEDS_CLASS_FLASH || !LEDS_CLASS_FLASH > > + depends on LEDS_CLASS_MULTICOLOR || !LEDS_CLASS_MULTICOLOR > > + depends on V4L2_FLASH_LED_CLASS || !V4L2_FLASH_LED_CLASS > > + depends on MFD_MT6360 > > + help > > + This option enables support for dual Flash LED drivers found on > > + Mediatek MT6360 PMIC. > > + Independent current sources supply for each flash LED support torch > > + and strobe mode. > > + > > config LEDS_S3C24XX > > tristate "LED Support for Samsung S3C24XX GPIO LEDs" > > depends on LEDS_CLASS > > diff --git a/drivers/leds/Makefile b/drivers/leds/Makefile > > index c2c7d7a..5596427 100644 > > --- a/drivers/leds/Makefile > > +++ b/drivers/leds/Makefile > > @@ -66,6 +66,7 @@ obj-$(CONFIG_LEDS_MIKROTIK_RB532) += leds-rb532.o > > obj-$(CONFIG_LEDS_MLXCPLD) += leds-mlxcpld.o > > obj-$(CONFIG_LEDS_MLXREG) += leds-mlxreg.o > > obj-$(CONFIG_LEDS_MT6323) += leds-mt6323.o > > +obj-$(CONFIG_LEDS_MT6360)+= leds-mt6360.o > > obj-$(CONFIG_LEDS_NET48XX) += leds-net48xx.o > > obj-$(CONFIG_LEDS_NETXBIG) += leds-netxbig.o > > obj-$(CONFIG_LEDS_NIC78BX) += leds-nic78bx.o > > diff --git a/drivers/leds/leds-mt6360.c b/drivers/leds/leds-mt6360.c > > new file mode 100644 > > index 000..e3a30bd > > --- /dev/null > > +++ b/drivers/leds/leds-mt6360.c > > @@ -0,0 +1,817 @@ > > +// SPDX-License-Identifier: GPL-2.0-only > > + > > +#include > > +#include > > +#include > > +#include > > +#include > > +#include > > +#include > > +#include > > +#include > > +#include > > +#include > > +#include > > +#include > > + > > +enum { > > + MT6360_LED_ISNK1 = 0, > > + MT6360_LED_ISNK2, > > + MT6360_LED_ISNK3, > > + MT6360_LED_ISNKML, > > + MT6360_LED_FLASH1, > > + MT6360_LED_FLASH2, > > + MT6360_LED_MULTICOLOR, > > + MT6360_MAX_LEDS = MT6360_LED_MULTICOLOR > > +}; > > + > > +#define MT6360_REG_RGBEN 0x380 > > +#define MT6360_REG_ISNK(_led_no) (0x381 + (_led_no)) > > +#define MT6360_ISNK_ENMASK(_led_no) BIT(7 - (_led_no)) > > +#define MT6360_ISNK_MASK GENMASK(4, 0) > > +#define MT6360_CHRINDSEL_MASKBIT(3) > > + > > +#define MULTICOLOR_NUM_CHANNELS 3 > > + > > +#define MT6360_REG_FLEDEN0x37E > > +#define MT6360_REG_STRBTO0x373 > > +#define MT6360_REG_FLEDBASE(_id) (0x372 + 4 * (_id - > > MT6360_LED_FLASH1)) > > +#define MT6360_REG_FLEDISTRB(_id)(MT6360_REG_FLEDBASE(_id) + 2) > > +#define MT6360_REG_FLEDITOR(_id) (MT6360_REG_FLEDBASE(_id) + 3) > > +#define MT6360_REG_CHGSTAT2 0x3E1 > > +#define MT6360_REG_FLEDSTAT1 0x3E9 > > +#define MT6360_ITORCH_MASK GENMASK(4, 0) > > +#define MT6360_ISTROBE_MASK GENMASK(6, 0) > > +#define MT6360_STRBTO_MASK GENMASK(6, 0) > > +#define MT6360_TORCHEN_MASK BIT(3) > > +#define MT6360_STROBEN_MASK BIT(2) > > +#define MT6360_FLCSEN_MASK(_id) BIT(MT6360_LED_FLASH2 - _id) > > +#define MT6360_FLEDCHGVINOVP_MASKBIT(3) > > +#define MT6360_FLED1STRBTO_MASK BIT(11) > > +#define MT6360_FLED2STRBTO_MASK BIT(10)
Re: [PATCH v6 1/2] dt-bindings: leds: Add bindings for MT6360 LED
Jacek Anaszewski 於 2020年11月18日 週三 上午6:24寫道: > > Hi Gene, > > Thank you for the patch. > > On 11/17/20 11:55 AM, Gene Chen wrote: > > From: Gene Chen > > > > Add bindings document for LED support on MT6360 PMIC > > > > Signed-off-by: Gene Chen > > --- > > .../devicetree/bindings/leds/leds-mt6360.yaml | 114 > > + > > 1 file changed, 114 insertions(+) > > create mode 100644 Documentation/devicetree/bindings/leds/leds-mt6360.yaml > > > > diff --git a/Documentation/devicetree/bindings/leds/leds-mt6360.yaml > > b/Documentation/devicetree/bindings/leds/leds-mt6360.yaml > > new file mode 100644 > > index 000..871db4d > > --- /dev/null > > +++ b/Documentation/devicetree/bindings/leds/leds-mt6360.yaml > > @@ -0,0 +1,114 @@ > > +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) > > +%YAML 1.2 > > +--- > > +$id: http://devicetree.org/schemas/leds/leds-mt6360.yaml# > > +$schema: http://devicetree.org/meta-schemas/core.yaml# > > + > > +title: LED driver for MT6360 PMIC from MediaTek Integrated. > > + > > +maintainers: > > + - Gene Chen > > + > > +description: | > > + This module is part of the MT6360 MFD device. > > + see Documentation/devicetree/bindings/mfd/mt6360.yaml > > + Add MT6360 LED driver include 2-channel Flash LED with torch/strobe mode, > > + and 4-channel RGB LED support Register/Flash/Breath Mode > > What actually is the Register mode? > Register mode is equal to S/W mode. Red LED indicator ic default is H/W mode. LED enable when charger plug in. > > + > > +properties: > > + compatible: > > +const: mediatek,mt6360-led > > + > > + "#address-cells": > > +const: 1 > > + > > + "#size-cells": > > +const: 0 > > + > > +patternProperties: > > + "^led@[0-6]$": > > +type: object > > +$ref: common.yaml# > > +description: > > + Properties for a single LED. > > + > > +properties: > > + reg: > > +description: Index of the LED. > > +enum: > > + - 0 # LED output INDICATOR1_RED > > + - 1 # LED output INDICATOR1_GREEN > > + - 2 # LED output INDICATOR1_BLUE > > + - 3 # LED output INDICATOR2_ML > > + - 4 # LED output FLED1 > > + - 5 # LED output FLED2 > > + - 6 # LED output MULTICOLOR > > + > > +unevaluatedProperties: false > > + > > +required: > > + - compatible > > + - "#address-cells" > > + - "#size-cells" > > + > > +additionalProperties: false > > + > > +examples: > > + - | > > + #include > > + led-controller { > > + compatible = "mediatek,mt6360-led"; > > + #address-cells = <1>; > > + #size-cells = <0>; > > + > > + led@0 { > > + reg = <0>; > > + function = LED_FUNCTION_INDICATOR; > > + color = ; > > + led-max-microamp = <24000>; > > + }; > > + led@3 { > > + reg = <3>; > > + function = LED_FUNCTION_INDICATOR; > > + color = ; > > You should really have here LED_COLOR_ID_MOONLIGHT if this is > a moonlight LED. You'll need to add it to dt-bindings/leds/common.h. > > > + led-max-microamp = <15>; > > + }; > > + led@4 { > > + reg = <4>; > > + function = LED_FUNCTION_FLASH; > > + color = ; > > + function-enumerator = <1>; > > + led-max-microamp = <20>; > > + flash-max-microamp = <50>; > > + flash-max-timeout-us = <1024000>; > > + }; > > + led@5 { > > + reg = <5>; > > + function = LED_FUNCTION_FLASH; > > + color = ; > > + function-enumerator = <2>; > > + led-max-microamp = <20>; > > + flash-max-microamp = <50>; > > + flash-max-timeout-us = <1024000>; > > + }; > > + led@6 { > > + reg = <6>; > > + function = LED_FUNCTION_INDICATOR; > > + color = ; > > + led-max-microamp = <24000>; > > + #address-cells = <1>; > > + #size-cells = <0>; > > + > > + led@1 { > > + reg = <1>; > > + function = LED_FUNCTION_INDICATOR; > > + color = ; > > + }; > > + led@2 { > > + reg = <2>; > > + function = LED_FUNCTION_INDICATOR; > > + color = ; > > + }; > > + }; > > It is of little avail to have multicolor LED with only two LEDs. > I propose not to allow such setup - i.e. you should have either > one multicolor LED comprising three sub-LEDs (regs: 0, 1, 2), > and with main color property set to LED_COLOR_ID_RGB, or three separate > LEDs. > > Effectively, you should have two separate DT examples here to make it > clear: one for the case with three LED class devices and one with > LED multicolor class device. > ACK > > + }; > > +... > > > > -- > Best regards, > Jacek Anaszewski
[PATCH v7 1/5] leds: flash: Add flash registration with undefined CONFIG_LEDS_CLASS_FLASH
From: Gene Chen Add flash registration with undefined CONFIG_LEDS_CLASS_FLASH Signed-off-by: Gene Chen --- include/linux/led-class-flash.h | 36 1 file changed, 36 insertions(+) diff --git a/include/linux/led-class-flash.h b/include/linux/led-class-flash.h index 21a3358..4f56c28 100644 --- a/include/linux/led-class-flash.h +++ b/include/linux/led-class-flash.h @@ -85,6 +85,7 @@ static inline struct led_classdev_flash *lcdev_to_flcdev( return container_of(lcdev, struct led_classdev_flash, led_cdev); } +#if IS_ENABLED(CONFIG_LEDS_CLASS_FLASH) /** * led_classdev_flash_register_ext - register a new object of LED class with * init data and with support for flash LEDs @@ -127,6 +128,41 @@ static inline int devm_led_classdev_flash_register(struct device *parent, void devm_led_classdev_flash_unregister(struct device *parent, struct led_classdev_flash *fled_cdev); +#else + +static inline int led_classdev_flash_register_ext(struct device *parent, + struct led_classdev_flash *fled_cdev, + struct led_init_data *init_data) +{ + return -EINVAL; +} + +static inline int led_classdev_flash_register(struct device *parent, + struct led_classdev_flash *fled_cdev) +{ + return led_classdev_flash_register_ext(parent, fled_cdev, NULL); +} + +static inline void led_classdev_flash_unregister(struct led_classdev_flash *fled_cdev) {}; +static inline int devm_led_classdev_flash_register_ext(struct device *parent, +struct led_classdev_flash *fled_cdev, +struct led_init_data *init_data) +{ + return -EINVAL; +} + +static inline int devm_led_classdev_flash_register(struct device *parent, +struct led_classdev_flash *fled_cdev) +{ + return devm_led_classdev_flash_register_ext(parent, fled_cdev, NULL); +} + +void devm_led_classdev_flash_unregister(struct device *parent, + struct led_classdev_flash *fled_cdev) +{}; + +#endif /* IS_ENABLED(CONFIG_LEDS_CLASS_FLASH) */ + /** * led_set_flash_strobe - setup flash strobe * @fled_cdev: the flash LED to set strobe on -- 2.7.4
[PATCH v7 0/5] leds: mt6360: Add LED driver for MT6360
In-Reply-To: Gene Chen (5) leds: flash: Add flash registration with undefined CONFIG_LEDS_CLASS_FLASH dt-bindings: leds: Add LED_COLOR_ID_MOONLIGHT definitions dt-bindings: leds: common: Increase LED_COLOR_ID_* maximum size dt-bindings: leds: Add bindings for MT6360 LED leds: mt6360: Add LED driver for MT6360 Documentation/devicetree/bindings/leds/common.yaml |2 Documentation/devicetree/bindings/leds/leds-mt6360.yaml | 164 +++ drivers/leds/Kconfig| 13 drivers/leds/Makefile |1 drivers/leds/leds-mt6360.c | 808 include/dt-bindings/leds/common.h |3 include/linux/led-class-flash.h | 36 7 files changed, 1025 insertions(+), 2 deletions(-) changelogs between v1 & v2 - add led driver with mfd changelogs between v2 & v3 - independent add led driver - add dt-binding document - refactor macros definition for easy to debug - parse device tree by fwnode - use devm*ext to register led class device changelogs between v3 & v4 - fix binding document description - use GENMASK and add unit postfix to definition - isink register led class device changelogs between v4 & v5 - change rgb isink to multicolor control - add binding reference to mfd yaml changelogs between v5 & v6 - Use DT to decide RGB LED is multicolor device or indicator device only changelogs between v6 & v7 - Add binding multicolor device sample code - Add flash ops mutex lock - Remove V4L2 init with indicator device
[PATCH v7 2/5] dt-bindings: leds: Add LED_COLOR_ID_MOONLIGHT definitions
From: Gene Chen Add LED_COLOR_ID_MOONLIGHT definitions Signed-off-by: Gene Chen --- include/dt-bindings/leds/common.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/include/dt-bindings/leds/common.h b/include/dt-bindings/leds/common.h index 52b619d..1409e9a 100644 --- a/include/dt-bindings/leds/common.h +++ b/include/dt-bindings/leds/common.h @@ -33,7 +33,8 @@ #define LED_COLOR_ID_MULTI 8 /* For multicolor LEDs */ #define LED_COLOR_ID_RGB 9 /* For multicolor LEDs that can do arbitrary color, so this would include RGBW and similar */ -#define LED_COLOR_ID_MAX 10 +#define LED_COLOR_ID_MOONLIGHT 10 +#define LED_COLOR_ID_MAX 11 /* Standard LED functions */ /* Keyboard LEDs, usually it would be input4::capslock etc. */ -- 2.7.4
[PATCH v7 3/5] dt-bindings: leds: common: Increase LED_COLOR_ID_* maximum size
From: Gene Chen Increase LED_COLOR_ID_* maximum size Signed-off-by: Gene Chen --- Documentation/devicetree/bindings/leds/common.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Documentation/devicetree/bindings/leds/common.yaml b/Documentation/devicetree/bindings/leds/common.yaml index a2a541b..f356b61 100644 --- a/Documentation/devicetree/bindings/leds/common.yaml +++ b/Documentation/devicetree/bindings/leds/common.yaml @@ -43,7 +43,7 @@ properties: LED_COLOR_ID available, add a new one. $ref: /schemas/types.yaml#definitions/uint32 minimum: 0 -maximum: 8 +maximum: 10 function-enumerator: description: -- 2.7.4
[PATCH v7 4/5] dt-bindings: leds: Add bindings for MT6360 LED
From: Gene Chen Add bindings document for LED support on MT6360 PMIC Signed-off-by: Gene Chen --- .../devicetree/bindings/leds/leds-mt6360.yaml | 164 + 1 file changed, 164 insertions(+) create mode 100644 Documentation/devicetree/bindings/leds/leds-mt6360.yaml diff --git a/Documentation/devicetree/bindings/leds/leds-mt6360.yaml b/Documentation/devicetree/bindings/leds/leds-mt6360.yaml new file mode 100644 index 000..9bd6cbe --- /dev/null +++ b/Documentation/devicetree/bindings/leds/leds-mt6360.yaml @@ -0,0 +1,164 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/leds/leds-mt6360.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: LED driver for MT6360 PMIC from MediaTek Integrated. + +maintainers: + - Gene Chen + +description: | + This module is part of the MT6360 MFD device. + see Documentation/devicetree/bindings/mfd/mt6360.yaml + Add MT6360 LED driver include 2-channel Flash LED with torch/strobe mode, + and 4-channel RGB LED support Register/Flash/Breath Mode + +properties: + compatible: +const: mediatek,mt6360-led + + "#address-cells": +const: 1 + + "#size-cells": +const: 0 + +patternProperties: + "^led@[0-6]$": +type: object +$ref: common.yaml# +description: + Properties for a single LED. + +properties: + reg: +description: Index of the LED. +enum: + - 0 # LED output INDICATOR1_RED + - 1 # LED output INDICATOR1_GREEN + - 2 # LED output INDICATOR1_BLUE + - 3 # LED output INDICATOR2_ML + - 4 # LED output FLED1 + - 5 # LED output FLED2 + - 6 # LED output MULTICOLOR + +unevaluatedProperties: false + +required: + - compatible + - "#address-cells" + - "#size-cells" + +additionalProperties: false + +examples: + - | + #include + led-controller { + compatible = "mediatek,mt6360-led"; + #address-cells = <1>; + #size-cells = <0>; + + led@3 { + reg = <3>; + function = LED_FUNCTION_INDICATOR; + color = ; + led-max-microamp = <15>; + }; + led@4 { + reg = <4>; + function = LED_FUNCTION_FLASH; + color = ; + function-enumerator = <1>; + led-max-microamp = <20>; + flash-max-microamp = <50>; + flash-max-timeout-us = <1024000>; + }; + led@5 { + reg = <5>; + function = LED_FUNCTION_FLASH; + color = ; + function-enumerator = <2>; + led-max-microamp = <20>; + flash-max-microamp = <50>; + flash-max-timeout-us = <1024000>; + }; + led@6 { + reg = <6>; + function = LED_FUNCTION_INDICATOR; + color = ; + led-max-microamp = <24000>; + #address-cells = <1>; + #size-cells = <0>; + + led@0 { + reg = <0>; + function = LED_FUNCTION_INDICATOR; + color = ; + }; + led@1 { + reg = <1>; + function = LED_FUNCTION_INDICATOR; + color = ; + }; + led@2 { + reg = <2>; + function = LED_FUNCTION_INDICATOR; + color = ; + }; + }; + }; + + - | + + led-controller { + compatible = "mediatek,mt6360-led"; + #address-cells = <1>; + #size-cells = <0>; + + led@0 { + reg = <0>; + function = LED_FUNCTION_INDICATOR; + color = ; + led-max-microamp = <24000>; + }; + led@1 { + reg = <1>; + function = LED_FUNCTION_INDICATOR; + color = ; + led-max-microamp = <24000>; + }; + led@2 { + reg = <2>; + function = LED_FUNCTION_INDICATOR; + color = ; + led-max-microamp = <24000>; + }; + led@3 { + reg = <3>; + function = LED_FUNCTION_INDICATOR; + color = ; + led-max-microamp = <15>; + }; + led@4 { + reg = <4>; + function = LED_FUNCTION_FLASH; + color = ; + function-enumerator = <1>; + led-max-microamp = <20>; + flash-max-microamp = <50>; + flash-max-timeout-us = <1024000>; + }; + led@5 { + reg = <5>; + function = LED_FUNCTION_FLASH; + color = ; + function-enumerator = <2>; + led-max-microamp = <20>; + flash-max-microamp = <50>; + flash-max-timeout-us = <1024000>; + }; + }; +... -- 2.7.4
[PATCH v7 5/5] leds: mt6360: Add LED driver for MT6360
From: Gene Chen Add MT6360 LED driver include 2-channel Flash LED with torch/strobe mode, 3-channel RGB LED support Register/Flash/Breath Mode, and 1-channel for moonlight LED. Signed-off-by: Gene Chen --- drivers/leds/Kconfig | 13 + drivers/leds/Makefile | 1 + drivers/leds/leds-mt6360.c | 808 + 3 files changed, 822 insertions(+) create mode 100644 drivers/leds/leds-mt6360.c diff --git a/drivers/leds/Kconfig b/drivers/leds/Kconfig index 1c181df..4f533bc 100644 --- a/drivers/leds/Kconfig +++ b/drivers/leds/Kconfig @@ -271,6 +271,19 @@ config LEDS_MT6323 This option enables support for on-chip LED drivers found on Mediatek MT6323 PMIC. +config LEDS_MT6360 + tristate "LED Support for Mediatek MT6360 PMIC" + depends on LEDS_CLASS && OF + depends on LEDS_CLASS_FLASH || !LEDS_CLASS_FLASH + depends on LEDS_CLASS_MULTICOLOR || !LEDS_CLASS_MULTICOLOR + depends on V4L2_FLASH_LED_CLASS || !V4L2_FLASH_LED_CLASS + depends on MFD_MT6360 + help + This option enables support for dual Flash LED drivers found on + Mediatek MT6360 PMIC. + Independent current sources supply for each flash LED support torch + and strobe mode. + config LEDS_S3C24XX tristate "LED Support for Samsung S3C24XX GPIO LEDs" depends on LEDS_CLASS diff --git a/drivers/leds/Makefile b/drivers/leds/Makefile index c2c7d7a..5596427 100644 --- a/drivers/leds/Makefile +++ b/drivers/leds/Makefile @@ -66,6 +66,7 @@ obj-$(CONFIG_LEDS_MIKROTIK_RB532) += leds-rb532.o obj-$(CONFIG_LEDS_MLXCPLD) += leds-mlxcpld.o obj-$(CONFIG_LEDS_MLXREG) += leds-mlxreg.o obj-$(CONFIG_LEDS_MT6323) += leds-mt6323.o +obj-$(CONFIG_LEDS_MT6360) += leds-mt6360.o obj-$(CONFIG_LEDS_NET48XX) += leds-net48xx.o obj-$(CONFIG_LEDS_NETXBIG) += leds-netxbig.o obj-$(CONFIG_LEDS_NIC78BX) += leds-nic78bx.o diff --git a/drivers/leds/leds-mt6360.c b/drivers/leds/leds-mt6360.c new file mode 100644 index 000..8432901 --- /dev/null +++ b/drivers/leds/leds-mt6360.c @@ -0,0 +1,808 @@ +// SPDX-License-Identifier: GPL-2.0-only + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +enum { + MT6360_LED_ISNK1 = 0, + MT6360_LED_ISNK2, + MT6360_LED_ISNK3, + MT6360_LED_ISNKML, + MT6360_LED_FLASH1, + MT6360_LED_FLASH2, + MT6360_LED_MULTICOLOR, + MT6360_MAX_LEDS = MT6360_LED_MULTICOLOR +}; + +#define MT6360_REG_RGBEN 0x380 +#define MT6360_REG_ISNK(_led_no) (0x381 + (_led_no)) +#define MT6360_ISNK_ENMASK(_led_no)BIT(7 - (_led_no)) +#define MT6360_ISNK_MASK GENMASK(4, 0) +#define MT6360_CHRINDSEL_MASK BIT(3) + +#define MULTICOLOR_NUM_CHANNELS3 + +#define MT6360_REG_FLEDEN 0x37E +#define MT6360_REG_STRBTO 0x373 +#define MT6360_REG_FLEDBASE(_id) (0x372 + 4 * (_id - MT6360_LED_FLASH1)) +#define MT6360_REG_FLEDISTRB(_id) (MT6360_REG_FLEDBASE(_id) + 2) +#define MT6360_REG_FLEDITOR(_id) (MT6360_REG_FLEDBASE(_id) + 3) +#define MT6360_REG_CHGSTAT20x3E1 +#define MT6360_REG_FLEDSTAT1 0x3E9 +#define MT6360_ITORCH_MASK GENMASK(4, 0) +#define MT6360_ISTROBE_MASKGENMASK(6, 0) +#define MT6360_STRBTO_MASK GENMASK(6, 0) +#define MT6360_TORCHEN_MASKBIT(3) +#define MT6360_STROBEN_MASKBIT(2) +#define MT6360_FLCSEN_MASK(_id)BIT(MT6360_LED_FLASH2 - _id) +#define MT6360_FLEDCHGVINOVP_MASK BIT(3) +#define MT6360_FLED1STRBTO_MASKBIT(11) +#define MT6360_FLED2STRBTO_MASKBIT(10) +#define MT6360_FLED1STRB_MASK BIT(9) +#define MT6360_FLED2STRB_MASK BIT(8) +#define MT6360_FLED1SHORT_MASK BIT(7) +#define MT6360_FLED2SHORT_MASK BIT(6) +#define MT6360_FLEDLVF_MASKBIT(3) + +#define MT6360_ISNKRGB_STEPUA 2000 +#define MT6360_ISNKRGB_MAXUA 24000 +#define MT6360_ISNKML_STEPUA 5000 +#define MT6360_ISNKML_MAXUA15 + +#define MT6360_ITORCH_MINUA25000 +#define MT6360_ITORCH_STEPUA 12500 +#define MT6360_ITORCH_MAXUA40 +#define MT6360_ISTRB_MINUA 5 +#define MT6360_ISTRB_STEPUA12500 +#define MT6360_ISTRB_MAXUA 150 +#define MT6360_STRBTO_MINUS64000 +#define MT6360_STRBTO_STEPUS 32000 +#define MT6360_STRBTO_MAXUS2432000 + +#define STATE_OFF 0 +#define STATE_KEEP 1 +#define STATE_ON 2 + +struct mt6360_led { + union { + struct led_classdev isnk; + struct led_classdev_mc mc; +
Re: [PATCH v7 4/5] dt-bindings: leds: Add bindings for MT6360 LED
Rob Herring 於 2020年11月19日 週四 上午5:25寫道: > > On Wed, 18 Nov 2020 18:47:41 +0800, Gene Chen wrote: > > From: Gene Chen > > > > Add bindings document for LED support on MT6360 PMIC > > > > Signed-off-by: Gene Chen > > --- > > .../devicetree/bindings/leds/leds-mt6360.yaml | 164 > > + > > 1 file changed, 164 insertions(+) > > create mode 100644 Documentation/devicetree/bindings/leds/leds-mt6360.yaml > > > > > My bot found errors running 'make dt_binding_check' on your patch: > > yamllint warnings/errors: > ./Documentation/devicetree/bindings/leds/leds-mt6360.yaml:57:2: [warning] > wrong indentation: expected 2 but found 1 (indentation) > > dtschema/dtc warnings/errors: > /builds/robherring/linux-dt-review/Documentation/devicetree/bindings/leds/leds-mt6360.example.dt.yaml: > led-controller: led@3:color:0:0: 10 is greater than the maximum of 9 > From schema: > /builds/robherring/linux-dt-review/Documentation/devicetree/bindings/leds/leds-mt6360.yaml > /builds/robherring/linux-dt-review/Documentation/devicetree/bindings/leds/leds-mt6360.example.dt.yaml: > led-controller: led@3:color:0:0: 10 is greater than the maximum of 9 > From schema: > /builds/robherring/linux-dt-review/Documentation/devicetree/bindings/leds/leds-mt6360.yaml > > ACK, I will add description to this patch by “this patch depends on patch [PATCH v7 3/5] dt-bindings: leds: common: Increase LED_COLOR_ID_* maximum size" > See https://patchwork.ozlabs.org/patch/1402193 > > The base for the patch is generally the last rc1. Any dependencies > should be noted. > > If you already ran 'make dt_binding_check' and didn't see the above > error(s), then make sure 'yamllint' is installed and dt-schema is up to > date: > > pip3 install dtschema --upgrade > > Please check and re-submit. >
Re: [PATCH v7 2/5] dt-bindings: leds: Add LED_COLOR_ID_MOONLIGHT definitions
Pavel Machek 於 2020年11月19日 週四 上午5:37寫道: > > Hi! > > > From: Gene Chen > > > > Add LED_COLOR_ID_MOONLIGHT definitions > > Why is moonlight a color? Camera flashes are usually white, no? > > At least it needs a comment... > > Best regards, > Pavel > Moonlight has more current level(150mA) from general RGB LED (24mA). It can be used as night-light and usually use color AMBER. Camera flashes are usually use two flash LED. One is YELLOW, and one is WHITE. > > > > Signed-off-by: Gene Chen > > --- > > include/dt-bindings/leds/common.h | 3 ++- > > 1 file changed, 2 insertions(+), 1 deletion(-) > > > > diff --git a/include/dt-bindings/leds/common.h > > b/include/dt-bindings/leds/common.h > > index 52b619d..1409e9a 100644 > > --- a/include/dt-bindings/leds/common.h > > +++ b/include/dt-bindings/leds/common.h > > @@ -33,7 +33,8 @@ > > #define LED_COLOR_ID_MULTI 8 /* For multicolor LEDs */ > > #define LED_COLOR_ID_RGB 9 /* For multicolor LEDs that can do > > arbitrary color, > > so this would include RGBW and > > similar */ > > -#define LED_COLOR_ID_MAX 10 > > +#define LED_COLOR_ID_MOONLIGHT 10 > > +#define LED_COLOR_ID_MAX 11 > > > > /* Standard LED functions */ > > /* Keyboard LEDs, usually it would be input4::capslock etc. */ > > -- > http://www.livejournal.com/~pavelmachek
Re: [PATCH v2 2/2] power: supply: mt6360_charger: add MT6360 charger support
Dear Reviewers, Please let me know if there is anything need to be revised. Gene Chen 於 2020年11月3日 週二 下午6:41寫道: > > From: Gene Chen > > Add basic support for the battery charger for MT6360 PMIC > > Signed-off-by: Gene Chen > --- > drivers/power/supply/Kconfig | 10 + > drivers/power/supply/Makefile |1 + > drivers/power/supply/mt6360_charger.c | 1022 > + > 3 files changed, 1033 insertions(+) > create mode 100644 drivers/power/supply/mt6360_charger.c > > diff --git a/drivers/power/supply/Kconfig b/drivers/power/supply/Kconfig > index faf2830..e2d53a3 100644 > --- a/drivers/power/supply/Kconfig > +++ b/drivers/power/supply/Kconfig > @@ -562,6 +562,16 @@ config CHARGER_MP2629 > Battery charger. This driver provides Battery charger power > management > functions on the systems. > > +config CHARGER_MT6360 > + tristate "Mediatek MT6360 Charger Driver" > + depends on MFD_MT6360 > + depends on REGULATOR > + help > + Say Y here to enable MT6360 Charger Part. > + The device supports High-Accuracy Voltage/Current Regulation, > + Average Input Current Regulation, Battery Tempature Sensing, > + Over-Temperature Protection, DPDM Detection for BC1.2 > + > config CHARGER_QCOM_SMBB > tristate "Qualcomm Switch-Mode Battery Charger and Boost" > depends on MFD_SPMI_PMIC || COMPILE_TEST > diff --git a/drivers/power/supply/Makefile b/drivers/power/supply/Makefile > index b3c694a..9abecb9c 100644 > --- a/drivers/power/supply/Makefile > +++ b/drivers/power/supply/Makefile > @@ -77,6 +77,7 @@ obj-$(CONFIG_CHARGER_MAX77693)+= max77693_charger.o > obj-$(CONFIG_CHARGER_MAX8997) += max8997_charger.o > obj-$(CONFIG_CHARGER_MAX8998) += max8998_charger.o > obj-$(CONFIG_CHARGER_MP2629) += mp2629_charger.o > +obj-$(CONFIG_CHARGER_MT6360) += mt6360_charger.o > obj-$(CONFIG_CHARGER_QCOM_SMBB)+= qcom_smbb.o > obj-$(CONFIG_CHARGER_BQ2415X) += bq2415x_charger.o > obj-$(CONFIG_CHARGER_BQ24190) += bq24190_charger.o > diff --git a/drivers/power/supply/mt6360_charger.c > b/drivers/power/supply/mt6360_charger.c > new file mode 100644 > index 000..5631875 > --- /dev/null > +++ b/drivers/power/supply/mt6360_charger.c > @@ -0,0 +1,1022 @@ > +// SPDX-License-Identifier: GPL-2.0 > +/* > + * Copyright (c) 2019 MediaTek Inc. > + */ > + > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > + > +#define MT6360_PMU_CHG_CTRL1 0x311 > +#define MT6360_PMU_CHG_CTRL2 0x312 > +#define MT6360_PMU_CHG_CTRL3 0x313 > +#define MT6360_PMU_CHG_CTRL4 0x314 > +#define MT6360_PMU_CHG_CTRL5 0x315 > +#define MT6360_PMU_CHG_CTRL6 0x316 > +#define MT6360_PMU_CHG_CTRL7 0x317 > +#define MT6360_PMU_CHG_CTRL8 0x318 > +#define MT6360_PMU_CHG_CTRL9 0x319 > +#define MT6360_PMU_CHG_CTRL10 0x31A > +#define MT6360_PMU_CHG_CTRL11 0x31B > +#define MT6360_PMU_CHG_CTRL12 0x31C > +#define MT6360_PMU_CHG_CTRL13 0x31D > +#define MT6360_PMU_DEVICE_TYPE 0x322 > +#define MT6360_PMU_USB_STATUS1 0x327 > +#define MT6360_PMU_CHG_CTRL17 0x32B > +#define MT6360_PMU_CHG_CTRL18 0x32C > +#define MT6360_PMU_CHG_STAT0x34A > +#define MT6360_PMU_CHG_CTRL19 0x361 > +#define MT6360_PMU_FOD_STAT0x3E7 > + > +/* MT6360_PMU_CHG_CTRL1 */ > +#define MT6360_FSLP_SHFT (3) > +#define MT6360_FSLP_MASK BIT(MT6360_FSLP_SHFT) > +#define MT6360_HIZ_SHFT(2) > +#define MT6360_HIZ_MASKBIT(MT6360_HIZ_SHFT) > +#define MT6360_OPA_MODE_SHFT (0) > +#define MT6360_OPA_MODE_MASK BIT(MT6360_OPA_MODE_SHFT) > +/* MT6360_PMU_CHG_CTRL2 */ > +#define MT6360_TE_SHFT (4) > +#define MT6360_TE_MASK BIT(MT6360_TE_SHFT) > +#define MT6360_IINLMTSEL_SHFT (2) > +#define MT6360_IINLMTSEL_MASK GENMASK(3, 2) > +#define MT6360_CHG_EN_SHFT (0) > +#define MT6360_CHG_EN_MASK BIT(MT6360_CHG_EN_SHFT) > +/* MT6360_PMU_CHG_CTRL3 */ > +#define MT6360_IAICR_SHFT (2) > +#define MT6360_IAICR_MASK GENMASK(7, 2) > +#define MT6360_ILIM_EN_MASKBIT(0) > +/* MT6360_PMU_CHG_CTRL4 */ > +#define MT6360_VOREG_SHFT (1) > +#define MT6360_VOREG_MASK GENMASK(7, 1) > +/* MT6360_PMU_CHG_CTRL5 */ > +#define MT6360_VOBST_MASK GENMASK(7, 2) > +/* MT6360_PMU_CHG_CTRL6 */ > +#define MT6360_VMIVR_SHFT (1) > +#define MT6360_VMIVR_MASK GENMASK(7, 1) > +/* MT6360_PMU_CHG_CTRL7 */ > +#define MT6360_ICHG_SHFT (2) > +#define MT6360_ICHG_MASK GENMASK(7, 2) > +/* MT6360_PMU_CHG_CTRL8 */ > +#define MT636
[PATCH v12 3/5] dt-bindings: leds: Add LED_FUNCTION_MOONLIGHT definitions
From: Gene Chen Add LED_FUNCTION_MOONLIGHT definitions Signed-off-by: Gene Chen Acked-by: Jacek Anaszewski Acked-by: Rob Herring --- include/dt-bindings/leds/common.h | 1 + 1 file changed, 1 insertion(+) diff --git a/include/dt-bindings/leds/common.h b/include/dt-bindings/leds/common.h index 52b619d..843e65d 100644 --- a/include/dt-bindings/leds/common.h +++ b/include/dt-bindings/leds/common.h @@ -78,6 +78,7 @@ #define LED_FUNCTION_INDICATOR "indicator" #define LED_FUNCTION_LAN "lan" #define LED_FUNCTION_MAIL "mail" +#define LED_FUNCTION_MOONLIGHT "moonlight" #define LED_FUNCTION_MTD "mtd" #define LED_FUNCTION_PANIC "panic" #define LED_FUNCTION_PROGRAMMING "programming" -- 2.7.4
[PATCH v12 0/5] leds: mt6360: Add LED driver for MT6360
This patch series add MT6360 LED support contains driver and binding document Gene Chen (5) leds: flash: Add flash registration with undefined CONFIG_LEDS_CLASS_FLASH leds: flash: Fix multicolor no-ops registration by return 0 dt-bindings: leds: Add LED_COLOR_ID_MOONLIGHT definitions dt-bindings: leds: Add bindings for MT6360 LED leds: mt6360: Add LED driver for MT6360 Documentation/devicetree/bindings/leds/leds-mt6360.yaml | 159 +++ drivers/leds/Kconfig| 13 drivers/leds/Makefile |1 drivers/leds/leds-mt6360.c | 827 include/dt-bindings/leds/common.h |1 include/linux/led-class-flash.h | 42 include/linux/led-class-multicolor.h| 42 7 files changed, 1049 insertions(+), 36 deletions(-) changelogs between v1 & v2 - add led driver with mfd changelogs between v2 & v3 - independent add led driver - add dt-binding document - refactor macros definition for easy to debug - parse device tree by fwnode - use devm*ext to register led class device changelogs between v3 & v4 - fix binding document description - use GENMASK and add unit postfix to definition - isink register led class device changelogs between v4 & v5 - change rgb isink to multicolor control - add binding reference to mfd yaml changelogs between v5 & v6 - Use DT to decide RGB LED is multicolor device or indicator device only changelogs between v6 & v7 - Add binding multicolor device sample code - Add flash ops mutex lock - Remove V4L2 init with indicator device changelogs between v7 & v8 - Add mutex for led fault get ops - Fix flash and multicolor no-ops return 0 - Add LED_FUNCTION_MOONLIGHT changelogs between v8 & v9 - reuse api in flash and multicolor header changelogs between v9 & v10 - add comment for reuse registration functions in flash and multicolor changelogs between v10 & v11 - match dt-binding reg property comment to the functionality name - remove exist patch in linux-next - dicide multicolor channel by color definitiion changelogs between v11 & v12 - Fix print size_t by %lu - Fix dt-binding name regular experssion
[PATCH v12 4/5] dt-bindings: leds: Add bindings for MT6360 LED
From: Gene Chen Add bindings document for LED support on MT6360 PMIC Signed-off-by: Gene Chen --- .../devicetree/bindings/leds/leds-mt6360.yaml | 159 + 1 file changed, 159 insertions(+) create mode 100644 Documentation/devicetree/bindings/leds/leds-mt6360.yaml diff --git a/Documentation/devicetree/bindings/leds/leds-mt6360.yaml b/Documentation/devicetree/bindings/leds/leds-mt6360.yaml new file mode 100644 index 000..cb1f4b7 --- /dev/null +++ b/Documentation/devicetree/bindings/leds/leds-mt6360.yaml @@ -0,0 +1,159 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/leds/leds-mt6360.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: LED driver for MT6360 PMIC from MediaTek Integrated. + +maintainers: + - Gene Chen + +description: | + This module is part of the MT6360 MFD device. + see Documentation/devicetree/bindings/mfd/mt6360.yaml + Add MT6360 LED driver include 2-channel Flash LED with torch/strobe mode, + and 4-channel RGB LED support Register/Flash/Breath Mode + +properties: + compatible: +const: mediatek,mt6360-led + + "#address-cells": +const: 1 + + "#size-cells": +const: 0 + +patternProperties: + "^(multi-)?led@[0-5]$": +type: object +$ref: common.yaml# +description: + Properties for a single LED. + +properties: + reg: +description: Index of the LED. +enum: + - 0 # LED output ISINK1 + - 1 # LED output ISINK2 + - 2 # LED output ISINK3 + - 3 # LED output ISINKML + - 4 # LED output FLASH1 + - 5 # LED output FLASH2 + +unevaluatedProperties: false + +required: + - compatible + - "#address-cells" + - "#size-cells" + +additionalProperties: false + +examples: + - | + #include + led-controller { + compatible = "mediatek,mt6360-led"; + #address-cells = <1>; + #size-cells = <0>; + + multi-led@0 { + reg = <0>; + function = LED_FUNCTION_INDICATOR; + color = ; + led-max-microamp = <24000>; + #address-cells = <1>; + #size-cells = <0>; + led@0 { + reg = <0>; + color = ; + }; + led@1 { + reg = <1>; + color = ; + }; + led@2 { + reg = <2>; + color = ; + }; + }; + led@3 { + reg = <3>; + function = LED_FUNCTION_MOONLIGHT; + color = ; + led-max-microamp = <15>; + }; + led@4 { + reg = <4>; + function = LED_FUNCTION_FLASH; + color = ; + function-enumerator = <1>; + led-max-microamp = <20>; + flash-max-microamp = <50>; + flash-max-timeout-us = <1024000>; + }; + led@5 { + reg = <5>; + function = LED_FUNCTION_FLASH; + color = ; + function-enumerator = <2>; + led-max-microamp = <20>; + flash-max-microamp = <50>; + flash-max-timeout-us = <1024000>; + }; + }; + + - | + + led-controller { + compatible = "mediatek,mt6360-led"; + #address-cells = <1>; + #size-cells = <0>; + + led@0 { + reg = <0>; + function = LED_FUNCTION_INDICATOR; + color = ; + led-max-microamp = <24000>; + }; + led@1 { + reg = <1>; + function = LED_FUNCTION_INDICATOR; + color = ; + led-max-microamp = <24000>; + }; + led@2 { + reg = <2>; + function = LED_FUNCTION_INDICATOR; + color = ; + led-max-microamp = <24000>; + }; + led@3 { + reg = <3>; + function = LED_FUNCTION_MOONLIGHT; + color = ; + led-max-microamp = <15>; + }; + led@4 { + reg = <4>; + function = LED_FUNCTION_FLASH; + color = ; + function-enumerator = <1>; + led-max-microamp = <20>; + flash-max-microamp = <50>; + flash-max-timeout-us = <1024000>; + }; + led@5 { + reg = <5>; + function = LED_FUNCTION_FLASH; + color = ; + function-enumerator = <2>; + led-max-microamp = <20>; + flash-max-microamp = <50>; + flash-max-timeout-us = <1024000>; + }; + }; +... -- 2.7.4
[PATCH v12 1/5] leds: flash: Add flash registration with undefined CONFIG_LEDS_CLASS_FLASH
From: Gene Chen Add flash registration with undefined CONFIG_LEDS_CLASS_FLASH, and move the same registration functions outside of #ifdef block. Signed-off-by: Gene Chen Acked-by: Jacek Anaszewski --- include/linux/led-class-flash.h | 42 - 1 file changed, 33 insertions(+), 9 deletions(-) diff --git a/include/linux/led-class-flash.h b/include/linux/led-class-flash.h index 21a3358..612b4ca 100644 --- a/include/linux/led-class-flash.h +++ b/include/linux/led-class-flash.h @@ -85,6 +85,7 @@ static inline struct led_classdev_flash *lcdev_to_flcdev( return container_of(lcdev, struct led_classdev_flash, led_cdev); } +#if IS_ENABLED(CONFIG_LEDS_CLASS_FLASH) /** * led_classdev_flash_register_ext - register a new object of LED class with * init data and with support for flash LEDs @@ -98,12 +99,6 @@ int led_classdev_flash_register_ext(struct device *parent, struct led_classdev_flash *fled_cdev, struct led_init_data *init_data); -static inline int led_classdev_flash_register(struct device *parent, - struct led_classdev_flash *fled_cdev) -{ - return led_classdev_flash_register_ext(parent, fled_cdev, NULL); -} - /** * led_classdev_flash_unregister - unregisters an object of led_classdev class *with support for flash LEDs @@ -118,15 +113,44 @@ int devm_led_classdev_flash_register_ext(struct device *parent, struct led_init_data *init_data); +void devm_led_classdev_flash_unregister(struct device *parent, + struct led_classdev_flash *fled_cdev); + +#else + +static inline int led_classdev_flash_register_ext(struct device *parent, + struct led_classdev_flash *fled_cdev, + struct led_init_data *init_data) +{ + return 0; +} + +static inline void led_classdev_flash_unregister(struct led_classdev_flash *fled_cdev) {}; +static inline int devm_led_classdev_flash_register_ext(struct device *parent, +struct led_classdev_flash *fled_cdev, +struct led_init_data *init_data) +{ + return 0; +} + +static inline void devm_led_classdev_flash_unregister(struct device *parent, + struct led_classdev_flash *fled_cdev) +{}; + +#endif /* IS_ENABLED(CONFIG_LEDS_CLASS_FLASH) */ + +static inline int led_classdev_flash_register(struct device *parent, + struct led_classdev_flash *fled_cdev) +{ + return led_classdev_flash_register_ext(parent, fled_cdev, NULL); +} + static inline int devm_led_classdev_flash_register(struct device *parent, struct led_classdev_flash *fled_cdev) { return devm_led_classdev_flash_register_ext(parent, fled_cdev, NULL); } -void devm_led_classdev_flash_unregister(struct device *parent, - struct led_classdev_flash *fled_cdev); - /** * led_set_flash_strobe - setup flash strobe * @fled_cdev: the flash LED to set strobe on -- 2.7.4
[PATCH v12 5/5] leds: mt6360: Add LED driver for MT6360
From: Gene Chen Add MT6360 LED driver include 2-channel Flash LED with torch/strobe mode, 3-channel RGB LED support Register/Flash/Breath Mode, and 1-channel for moonlight LED. Signed-off-by: Gene Chen --- drivers/leds/Kconfig | 13 + drivers/leds/Makefile | 1 + drivers/leds/leds-mt6360.c | 827 + 3 files changed, 841 insertions(+) create mode 100644 drivers/leds/leds-mt6360.c diff --git a/drivers/leds/Kconfig b/drivers/leds/Kconfig index 1c181df..4f533bc 100644 --- a/drivers/leds/Kconfig +++ b/drivers/leds/Kconfig @@ -271,6 +271,19 @@ config LEDS_MT6323 This option enables support for on-chip LED drivers found on Mediatek MT6323 PMIC. +config LEDS_MT6360 + tristate "LED Support for Mediatek MT6360 PMIC" + depends on LEDS_CLASS && OF + depends on LEDS_CLASS_FLASH || !LEDS_CLASS_FLASH + depends on LEDS_CLASS_MULTICOLOR || !LEDS_CLASS_MULTICOLOR + depends on V4L2_FLASH_LED_CLASS || !V4L2_FLASH_LED_CLASS + depends on MFD_MT6360 + help + This option enables support for dual Flash LED drivers found on + Mediatek MT6360 PMIC. + Independent current sources supply for each flash LED support torch + and strobe mode. + config LEDS_S3C24XX tristate "LED Support for Samsung S3C24XX GPIO LEDs" depends on LEDS_CLASS diff --git a/drivers/leds/Makefile b/drivers/leds/Makefile index c2c7d7a..5596427 100644 --- a/drivers/leds/Makefile +++ b/drivers/leds/Makefile @@ -66,6 +66,7 @@ obj-$(CONFIG_LEDS_MIKROTIK_RB532) += leds-rb532.o obj-$(CONFIG_LEDS_MLXCPLD) += leds-mlxcpld.o obj-$(CONFIG_LEDS_MLXREG) += leds-mlxreg.o obj-$(CONFIG_LEDS_MT6323) += leds-mt6323.o +obj-$(CONFIG_LEDS_MT6360) += leds-mt6360.o obj-$(CONFIG_LEDS_NET48XX) += leds-net48xx.o obj-$(CONFIG_LEDS_NETXBIG) += leds-netxbig.o obj-$(CONFIG_LEDS_NIC78BX) += leds-nic78bx.o diff --git a/drivers/leds/leds-mt6360.c b/drivers/leds/leds-mt6360.c new file mode 100644 index 000..42d18a8 --- /dev/null +++ b/drivers/leds/leds-mt6360.c @@ -0,0 +1,827 @@ +// SPDX-License-Identifier: GPL-2.0-only + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +enum { + MT6360_LED_ISNK1 = 0, + MT6360_LED_ISNK2, + MT6360_LED_ISNK3, + MT6360_LED_ISNKML, + MT6360_LED_FLASH1, + MT6360_LED_FLASH2, + MT6360_MAX_LEDS +}; + +#define MT6360_REG_RGBEN 0x380 +#define MT6360_REG_ISNK(_led_no) (0x381 + (_led_no)) +#define MT6360_ISNK_ENMASK(_led_no)BIT(7 - (_led_no)) +#define MT6360_ISNK_MASK GENMASK(4, 0) +#define MT6360_CHRINDSEL_MASK BIT(3) + +/* Virtual definition for multicolor */ +#define MT6360_VIRTUAL_MULTICOLOR (MT6360_MAX_LEDS + 1) +#define MULTICOLOR_NUM_CHANNELS3 + +#define MT6360_REG_FLEDEN 0x37E +#define MT6360_REG_STRBTO 0x373 +#define MT6360_REG_FLEDBASE(_id) (0x372 + 4 * (_id - MT6360_LED_FLASH1)) +#define MT6360_REG_FLEDISTRB(_id) (MT6360_REG_FLEDBASE(_id) + 2) +#define MT6360_REG_FLEDITOR(_id) (MT6360_REG_FLEDBASE(_id) + 3) +#define MT6360_REG_CHGSTAT20x3E1 +#define MT6360_REG_FLEDSTAT1 0x3E9 +#define MT6360_ITORCH_MASK GENMASK(4, 0) +#define MT6360_ISTROBE_MASKGENMASK(6, 0) +#define MT6360_STRBTO_MASK GENMASK(6, 0) +#define MT6360_TORCHEN_MASKBIT(3) +#define MT6360_STROBEN_MASKBIT(2) +#define MT6360_FLCSEN_MASK(_id)BIT(MT6360_LED_FLASH2 - _id) +#define MT6360_FLEDCHGVINOVP_MASK BIT(3) +#define MT6360_FLED1STRBTO_MASKBIT(11) +#define MT6360_FLED2STRBTO_MASKBIT(10) +#define MT6360_FLED1STRB_MASK BIT(9) +#define MT6360_FLED2STRB_MASK BIT(8) +#define MT6360_FLED1SHORT_MASK BIT(7) +#define MT6360_FLED2SHORT_MASK BIT(6) +#define MT6360_FLEDLVF_MASKBIT(3) + +#define MT6360_ISNKRGB_STEPUA 2000 +#define MT6360_ISNKRGB_MAXUA 24000 +#define MT6360_ISNKML_STEPUA 5000 +#define MT6360_ISNKML_MAXUA15 + +#define MT6360_ITORCH_MINUA25000 +#define MT6360_ITORCH_STEPUA 12500 +#define MT6360_ITORCH_MAXUA40 +#define MT6360_ISTRB_MINUA 5 +#define MT6360_ISTRB_STEPUA12500 +#define MT6360_ISTRB_MAXUA 150 +#define MT6360_STRBTO_MINUS64000 +#define MT6360_STRBTO_STEPUS 32000 +#define MT6360_STRBTO_MAXUS2432000 + +#define STATE_OFF 0 +#define STATE_KEEP 1 +#define STATE_ON 2 + +struct mt6360_led { + union { + struct led_classdev isnk; +
[PATCH v12 2/5] leds: flash: Fix multicolor no-ops registration by return 0
From: Gene Chen Fix multicolor no-ops registration by return 0, and move the same registration functions outside of #ifdef block. Signed-off-by: Gene Chen Acked-by: Jacek Anaszewski --- include/linux/led-class-multicolor.h | 42 +--- 1 file changed, 15 insertions(+), 27 deletions(-) diff --git a/include/linux/led-class-multicolor.h b/include/linux/led-class-multicolor.h index 5116f9a..210d57b 100644 --- a/include/linux/led-class-multicolor.h +++ b/include/linux/led-class-multicolor.h @@ -44,12 +44,6 @@ int led_classdev_multicolor_register_ext(struct device *parent, struct led_classdev_mc *mcled_cdev, struct led_init_data *init_data); -static inline int led_classdev_multicolor_register(struct device *parent, - struct led_classdev_mc *mcled_cdev) -{ - return led_classdev_multicolor_register_ext(parent, mcled_cdev, NULL); -} - /** * led_classdev_multicolor_unregister - unregisters an object of led_classdev * class with support for multicolor LEDs @@ -68,13 +62,6 @@ int devm_led_classdev_multicolor_register_ext(struct device *parent, struct led_classdev_mc *mcled_cdev, struct led_init_data *init_data); -static inline int devm_led_classdev_multicolor_register(struct device *parent, -struct led_classdev_mc *mcled_cdev) -{ - return devm_led_classdev_multicolor_register_ext(parent, mcled_cdev, -NULL); -} - void devm_led_classdev_multicolor_unregister(struct device *parent, struct led_classdev_mc *mcled_cdev); #else @@ -83,27 +70,33 @@ static inline int led_classdev_multicolor_register_ext(struct device *parent, struct led_classdev_mc *mcled_cdev, struct led_init_data *init_data) { - return -EINVAL; -} - -static inline int led_classdev_multicolor_register(struct device *parent, - struct led_classdev_mc *mcled_cdev) -{ - return led_classdev_multicolor_register_ext(parent, mcled_cdev, NULL); + return 0; } static inline void led_classdev_multicolor_unregister(struct led_classdev_mc *mcled_cdev) {}; static inline int led_mc_calc_color_components(struct led_classdev_mc *mcled_cdev, enum led_brightness brightness) { - return -EINVAL; + return 0; } static inline int devm_led_classdev_multicolor_register_ext(struct device *parent, struct led_classdev_mc *mcled_cdev, struct led_init_data *init_data) { - return -EINVAL; + return 0; +} + +static inline void devm_led_classdev_multicolor_unregister(struct device *parent, + struct led_classdev_mc *mcled_cdev) +{}; + +#endif /* IS_ENABLED(CONFIG_LEDS_CLASS_MULTICOLOR) */ + +static inline int led_classdev_multicolor_register(struct device *parent, + struct led_classdev_mc *mcled_cdev) +{ + return led_classdev_multicolor_register_ext(parent, mcled_cdev, NULL); } static inline int devm_led_classdev_multicolor_register(struct device *parent, @@ -113,9 +106,4 @@ static inline int devm_led_classdev_multicolor_register(struct device *parent, NULL); } -static inline void devm_led_classdev_multicolor_unregister(struct device *parent, - struct led_classdev_mc *mcled_cdev) -{}; - -#endif /* IS_ENABLED(CONFIG_LEDS_CLASS_MULTICOLOR) */ #endif /* _LINUX_MULTICOLOR_LEDS_H_INCLUDED */ -- 2.7.4
Re: [PATCH v7 2/5] dt-bindings: leds: Add LED_COLOR_ID_MOONLIGHT definitions
Pavel Machek 於 2020年11月19日 週四 下午3:44寫道: > > Hi! > > > > > From: Gene Chen > > > > > > > > Add LED_COLOR_ID_MOONLIGHT definitions > > > > > > Why is moonlight a color? Camera flashes are usually white, no? > > > > > > At least it needs a comment... > > > > > > Best regards, > > > Pavel > > > > > > > Moonlight has more current level(150mA) from general RGB LED (24mA). > > It can be used as night-light and usually use color AMBER. > > Camera flashes are usually use two flash LED. One is YELLOW, and one > >is WHITE. > > From what I seen, night-lights are usually differetent "temperatures" > of white. Cool white + warm white. > > I believe "warm white" would be easier to understand than > "moonlight"... > ACK, I will change color "LED_COLOR_ID_WHITE" > Best regards, > Pavel > > -- > http://www.livejournal.com/~pavelmachek
Re: [PATCH v7 1/5] leds: flash: Add flash registration with undefined CONFIG_LEDS_CLASS_FLASH
Jacek Anaszewski 於 2020年11月24日 週二 上午5:07寫道: > > On 11/23/20 4:20 AM, Gene Chen wrote: > > Jacek Anaszewski 於 2020年11月20日 週五 上午6:29寫道: > >> > >> Hi Gene, > >> > >> On 11/18/20 11:47 AM, Gene Chen wrote: > >>> From: Gene Chen > >>> > >>> Add flash registration with undefined CONFIG_LEDS_CLASS_FLASH > >>> > >>> Signed-off-by: Gene Chen > >>> --- > >>>include/linux/led-class-flash.h | 36 > >>> > >>>1 file changed, 36 insertions(+) > >>> > >>> diff --git a/include/linux/led-class-flash.h > >>> b/include/linux/led-class-flash.h > >>> index 21a3358..4f56c28 100644 > >>> --- a/include/linux/led-class-flash.h > >>> +++ b/include/linux/led-class-flash.h > >>> @@ -85,6 +85,7 @@ static inline struct led_classdev_flash > >>> *lcdev_to_flcdev( > >>>return container_of(lcdev, struct led_classdev_flash, led_cdev); > >>>} > >>> > >>> +#if IS_ENABLED(CONFIG_LEDS_CLASS_FLASH) > >>>/** > >>> * led_classdev_flash_register_ext - register a new object of LED > >>> class with > >>> * init data and with support for flash > >>> LEDs > >>> @@ -127,6 +128,41 @@ static inline int > >>> devm_led_classdev_flash_register(struct device *parent, > >>>void devm_led_classdev_flash_unregister(struct device *parent, > >>>struct led_classdev_flash > >>> *fled_cdev); > >>> > >>> +#else > >>> + > >>> +static inline int led_classdev_flash_register_ext(struct device *parent, > >>> + struct led_classdev_flash *fled_cdev, > >>> + struct led_init_data *init_data) > >>> +{ > >>> + return -EINVAL; > >> > >> s/-EINVAL/0/ > >> > >> The goal here is to assure that client will not fail when using no-op. > >> > >>> +} > >>> + > >>> +static inline int led_classdev_flash_register(struct device *parent, > >>> +struct led_classdev_flash > >>> *fled_cdev) > >>> +{ > >>> + return led_classdev_flash_register_ext(parent, fled_cdev, NULL); > >>> +} > >> > >> This function should be placed after #ifdef block because its > >> shape is the same for both cases. > >> > >>> +static inline void led_classdev_flash_unregister(struct > >>> led_classdev_flash *fled_cdev) {}; > >>> +static inline int devm_led_classdev_flash_register_ext(struct device > >>> *parent, > >>> + struct led_classdev_flash *fled_cdev, > >>> + struct led_init_data *init_data) > >>> +{ > >>> + return -EINVAL; > >> > >> /-EINVAL/0/ > >> > >> Please do the same fix in all no-ops in the led-class-multicolor.h, > >> as we've discussed. > >> > > > > I think return -EINVAL is correct, because I should register flash > > light device if I define FLED in DTS node. > > I don't quite follow your logic here. > > No-op function's purpose is to simplify the code on the caller's side. > Therefore it should report success. > > Please return 0 from it. > Just like those functions in led-class-multicolor.h, caller may use return value to check whether FLED is registered successfully or not. For this case, is returning 0 a little bit misleading? > -- > Best regards, > Jacek Anaszewski
Re: [PATCH v7 2/5] dt-bindings: leds: Add LED_COLOR_ID_MOONLIGHT definitions
Jacek Anaszewski 於 2020年11月24日 週二 上午4:52寫道: > > On 11/23/20 4:00 AM, Gene Chen wrote: > > Jacek Anaszewski 於 2020年11月20日 週五 上午6:26寫道: > >> > >> On 11/19/20 10:57 PM, Pavel Machek wrote: > >>> On Thu 2020-11-19 22:03:14, Jacek Anaszewski wrote: > >>>> Hi Pavel, Gene, > >>>> > >>>> On 11/18/20 10:37 PM, Pavel Machek wrote: > >>>>> Hi! > >>>>> > >>>>>> From: Gene Chen > >>>>>> > >>>>>> Add LED_COLOR_ID_MOONLIGHT definitions > >>>>> > >>>>> Why is moonlight a color? Camera flashes are usually white, no? > >>>>> > >>>>> At least it needs a comment... > >>>> > >>>> That's my fault, In fact I should have asked about adding > >>>> LED_FUNCTION_MOONLIGHT, it was evidently too late for me that evening... > >>> > >>> Aha, that makes more sense. > >>> > >>> But please let's call it "torch" if we do that, as that is already > >>> used in kernel sources... and probably in the interface, too: > >> > >> I'd say that torch is something different that moonlight, > >> but we would need more input from Gene to learn more about > >> the nature of light emitted by ML LED on his device. > >> > >> Please note that torch is usually meant as the other mode of > >> flash LED (sometimes it is called "movie mode"), which is already > >> handled by brightness file of LED class flash device (i.e. its LED class > >> subset), and which also maps to v4l2-flash TORCH mode. > >> > > > > It's used to front camera fill light. > > More brightness than screen backlight, and more soft light than flash. > > I think LED_ID_COLOR_WHITE is okay. > > So why in v6 you assigned LED_COLOR_ID_AMBER to it? > > Regardless of that, now we're talking about LED function - you chose > LED_FUNCTION_INDICATOR for it, but inferring from your above description > - it certainly doesn't fit here. > > Also register names, containing part "ML" indicate that this LED's > intended function is moonlinght, which your description somehow > corroborates. > > Moonlight LEDs become ubiquitous nowadays so sooner or later we will > need to add this function anyway [0]. > > [0] > https://landscapelightingoakville.com/what-is-moon-lighting-and-why-does-it-remain-so-popular/ > We use term "Moonlight" as reference says "When you are trying to imitate moonlight you need to use low voltage, softer lighting. You don’t want something that’s too bright" which is focus on brightness instead of color. So we surpose Moonlight can be white or amber. Should I add LED_FUNCTION_MOONLIGHT and set LED_COLOR_ID_WHITE? > -- > Best regards, > Jacek Anaszewski
Re: [PATCH v7 2/5] dt-bindings: leds: Add LED_COLOR_ID_MOONLIGHT definitions
Fix Typo. Gene Chen 於 2020年11月24日 週二 下午3:33寫道: > > Jacek Anaszewski 於 2020年11月24日 週二 上午4:52寫道: > > > > On 11/23/20 4:00 AM, Gene Chen wrote: > > > Jacek Anaszewski 於 2020年11月20日 週五 上午6:26寫道: > > >> > > >> On 11/19/20 10:57 PM, Pavel Machek wrote: > > >>> On Thu 2020-11-19 22:03:14, Jacek Anaszewski wrote: > > >>>> Hi Pavel, Gene, > > >>>> > > >>>> On 11/18/20 10:37 PM, Pavel Machek wrote: > > >>>>> Hi! > > >>>>> > > >>>>>> From: Gene Chen > > >>>>>> > > >>>>>> Add LED_COLOR_ID_MOONLIGHT definitions > > >>>>> > > >>>>> Why is moonlight a color? Camera flashes are usually white, no? > > >>>>> > > >>>>> At least it needs a comment... > > >>>> > > >>>> That's my fault, In fact I should have asked about adding > > >>>> LED_FUNCTION_MOONLIGHT, it was evidently too late for me that > > >>>> evening... > > >>> > > >>> Aha, that makes more sense. > > >>> > > >>> But please let's call it "torch" if we do that, as that is already > > >>> used in kernel sources... and probably in the interface, too: > > >> > > >> I'd say that torch is something different that moonlight, > > >> but we would need more input from Gene to learn more about > > >> the nature of light emitted by ML LED on his device. > > >> > > >> Please note that torch is usually meant as the other mode of > > >> flash LED (sometimes it is called "movie mode"), which is already > > >> handled by brightness file of LED class flash device (i.e. its LED class > > >> subset), and which also maps to v4l2-flash TORCH mode. > > >> > > > > > > It's used to front camera fill light. > > > More brightness than screen backlight, and more soft light than flash. > > > I think LED_ID_COLOR_WHITE is okay. > > > > So why in v6 you assigned LED_COLOR_ID_AMBER to it? > > we suppose Moonlight can be white or amber. > > Regardless of that, now we're talking about LED function - you chose > > LED_FUNCTION_INDICATOR for it, but inferring from your above description > > - it certainly doesn't fit here. > > > > Also register names, containing part "ML" indicate that this LED's > > intended function is moonlinght, which your description somehow > > corroborates. > > > > Moonlight LEDs become ubiquitous nowadays so sooner or later we will > > need to add this function anyway [0]. > > > > [0] > > https://landscapelightingoakville.com/what-is-moon-lighting-and-why-does-it-remain-so-popular/ > > > > According to reference, > "When you are trying to imitate moonlight you need to use low voltage, > softer lighting. You don’t want something that’s too bright" > which is focus on brightness instead of color. > > So we suppose Moonlight can be white or amber. > > Should I add LED_FUNCTION_MOONLIGHT and set LED_COLOR_ID_WHITE? > > > -- > > Best regards, > > Jacek Anaszewski
[PATCH v8 0/6] leds: mt6360: Add LED driver for MT6360
This patch series add MT6360 LED support contains driver and binding document Gene Chen (6) leds: flash: Add flash registration with undefined CONFIG_LEDS_CLASS_FLASH leds: flash: Fix multicolor registration no-ops by return 0 dt-bindings: leds: Add LED_COLOR_ID_MOONLIGHT definitions dt-bindings: leds: common: Increase LED_COLOR_ID_* maximum size dt-bindings: leds: Add bindings for MT6360 LED leds: mt6360: Add LED driver for MT6360 Documentation/devicetree/bindings/leds/common.yaml |2 Documentation/devicetree/bindings/leds/leds-mt6360.yaml | 164 +++ drivers/leds/Kconfig| 13 drivers/leds/Makefile |1 drivers/leds/leds-mt6360.c | 811 include/dt-bindings/leds/common.h |1 include/linux/led-class-flash.h | 36 include/linux/led-class-multicolor.h|6 8 files changed, 1030 insertions(+), 4 deletions(-) changelogs between v1 & v2 - add led driver with mfd changelogs between v2 & v3 - independent add led driver - add dt-binding document - refactor macros definition for easy to debug - parse device tree by fwnode - use devm*ext to register led class device changelogs between v3 & v4 - fix binding document description - use GENMASK and add unit postfix to definition - isink register led class device changelogs between v4 & v5 - change rgb isink to multicolor control - add binding reference to mfd yaml changelogs between v5 & v6 - Use DT to decide RGB LED is multicolor device or indicator device only changelogs between v6 & v7 - Add binding multicolor device sample code - Add flash ops mutex lock - Remove V4L2 init with indicator device changelogs between v7 & v8 - Add mutex for led fault get ops - Fix flash and multicolor no-ops return 0 - Add LED_FUNCTION_MOONLIGHT
[PATCH v8 1/6] leds: flash: Add flash registration with undefined CONFIG_LEDS_CLASS_FLASH
From: Gene Chen Add flash registration with undefined CONFIG_LEDS_CLASS_FLASH Signed-off-by: Gene Chen --- include/linux/led-class-flash.h | 36 1 file changed, 36 insertions(+) diff --git a/include/linux/led-class-flash.h b/include/linux/led-class-flash.h index 21a3358..5f36eae 100644 --- a/include/linux/led-class-flash.h +++ b/include/linux/led-class-flash.h @@ -85,6 +85,7 @@ static inline struct led_classdev_flash *lcdev_to_flcdev( return container_of(lcdev, struct led_classdev_flash, led_cdev); } +#if IS_ENABLED(CONFIG_LEDS_CLASS_FLASH) /** * led_classdev_flash_register_ext - register a new object of LED class with * init data and with support for flash LEDs @@ -127,6 +128,41 @@ static inline int devm_led_classdev_flash_register(struct device *parent, void devm_led_classdev_flash_unregister(struct device *parent, struct led_classdev_flash *fled_cdev); +#else + +static inline int led_classdev_flash_register_ext(struct device *parent, + struct led_classdev_flash *fled_cdev, + struct led_init_data *init_data) +{ + return 0; +} + +static inline int led_classdev_flash_register(struct device *parent, + struct led_classdev_flash *fled_cdev) +{ + return led_classdev_flash_register_ext(parent, fled_cdev, NULL); +} + +static inline void led_classdev_flash_unregister(struct led_classdev_flash *fled_cdev) {}; +static inline int devm_led_classdev_flash_register_ext(struct device *parent, +struct led_classdev_flash *fled_cdev, +struct led_init_data *init_data) +{ + return 0; +} + +static inline int devm_led_classdev_flash_register(struct device *parent, +struct led_classdev_flash *fled_cdev) +{ + return devm_led_classdev_flash_register_ext(parent, fled_cdev, NULL); +} + +static inline void devm_led_classdev_flash_unregister(struct device *parent, + struct led_classdev_flash *fled_cdev) +{}; + +#endif /* IS_ENABLED(CONFIG_LEDS_CLASS_FLASH) */ + /** * led_set_flash_strobe - setup flash strobe * @fled_cdev: the flash LED to set strobe on -- 2.7.4
[PATCH v8 4/6] dt-bindings: leds: common: Increase LED_COLOR_ID_* maximum size
From: Gene Chen Increase LED_COLOR_ID maximum size for LED_COLOR_ID_RGB Signed-off-by: Gene Chen --- Documentation/devicetree/bindings/leds/common.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Documentation/devicetree/bindings/leds/common.yaml b/Documentation/devicetree/bindings/leds/common.yaml index a2a541b..0c9f912 100644 --- a/Documentation/devicetree/bindings/leds/common.yaml +++ b/Documentation/devicetree/bindings/leds/common.yaml @@ -43,7 +43,7 @@ properties: LED_COLOR_ID available, add a new one. $ref: /schemas/types.yaml#definitions/uint32 minimum: 0 -maximum: 8 +maximum: 9 function-enumerator: description: -- 2.7.4
[PATCH v8 5/6] dt-bindings: leds: Add bindings for MT6360 LED
From: Gene Chen Add bindings document for LED support on MT6360 PMIC Signed-off-by: Gene Chen --- .../devicetree/bindings/leds/leds-mt6360.yaml | 164 + 1 file changed, 164 insertions(+) create mode 100644 Documentation/devicetree/bindings/leds/leds-mt6360.yaml diff --git a/Documentation/devicetree/bindings/leds/leds-mt6360.yaml b/Documentation/devicetree/bindings/leds/leds-mt6360.yaml new file mode 100644 index 000..b2ffbc6 --- /dev/null +++ b/Documentation/devicetree/bindings/leds/leds-mt6360.yaml @@ -0,0 +1,164 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/leds/leds-mt6360.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: LED driver for MT6360 PMIC from MediaTek Integrated. + +maintainers: + - Gene Chen + +description: | + This module is part of the MT6360 MFD device. + see Documentation/devicetree/bindings/mfd/mt6360.yaml + Add MT6360 LED driver include 2-channel Flash LED with torch/strobe mode, + and 4-channel RGB LED support Register/Flash/Breath Mode + +properties: + compatible: +const: mediatek,mt6360-led + + "#address-cells": +const: 1 + + "#size-cells": +const: 0 + +patternProperties: + "^led@[0-6]$": +type: object +$ref: common.yaml# +description: + Properties for a single LED. + +properties: + reg: +description: Index of the LED. +enum: + - 0 # LED output INDICATOR1_RED + - 1 # LED output INDICATOR1_GREEN + - 2 # LED output INDICATOR1_BLUE + - 3 # LED output INDICATOR2_ML + - 4 # LED output FLED1 + - 5 # LED output FLED2 + - 6 # LED output MULTICOLOR + +unevaluatedProperties: false + +required: + - compatible + - "#address-cells" + - "#size-cells" + +additionalProperties: false + +examples: + - | + #include + led-controller { + compatible = "mediatek,mt6360-led"; + #address-cells = <1>; + #size-cells = <0>; + + led@3 { + reg = <3>; + function = LED_FUNCTION_MOONLIGHT; + color = ; + led-max-microamp = <15>; + }; + led@4 { + reg = <4>; + function = LED_FUNCTION_FLASH; + color = ; + function-enumerator = <1>; + led-max-microamp = <20>; + flash-max-microamp = <50>; + flash-max-timeout-us = <1024000>; + }; + led@5 { + reg = <5>; + function = LED_FUNCTION_FLASH; + color = ; + function-enumerator = <2>; + led-max-microamp = <20>; + flash-max-microamp = <50>; + flash-max-timeout-us = <1024000>; + }; + led@6 { + reg = <6>; + function = LED_FUNCTION_INDICATOR; + color = ; + led-max-microamp = <24000>; + #address-cells = <1>; + #size-cells = <0>; + + led@0 { + reg = <0>; + function = LED_FUNCTION_INDICATOR; + color = ; + }; + led@1 { + reg = <1>; + function = LED_FUNCTION_INDICATOR; + color = ; + }; + led@2 { + reg = <2>; + function = LED_FUNCTION_INDICATOR; + color = ; + }; + }; + }; + + - | + + led-controller { + compatible = "mediatek,mt6360-led"; + #address-cells = <1>; + #size-cells = <0>; + + led@0 { + reg = <0>; + function = LED_FUNCTION_INDICATOR; + color = ; + led-max-microamp = <24000>; + }; + led@1 { + reg = <1>; + function = LED_FUNCTION_INDICATOR; + color = ; + led-max-microamp = <24000>; + }; + led@2 { + reg = <2>; + function = LED_FUNCTION_INDICATOR; + color = ; + led-max-microamp = <24000>; + }; + led@3 { + reg = <3>; + function = LED_FUNCTION_MOONLIGHT; + color = ; + led-max-microamp = <15>; + }; + led@4 { + reg = <4>; + function = LED_FUNCTION_FLASH; + color = ; + function-enumerator = <1>; + led-max-microamp = <20>; + flash-max-microamp = <50>; + flash-max-timeout-us = <1024000>; + }; + led@5 { + reg = <5>; + function = LED_FUNCTION_FLASH; + color = ; + function-enumerator = <2>; + led-max-microamp = <20>; + flash-max-microamp = <50>; + flash-max-timeout-us = <1024000>; + }; + }; +... -- 2.7.4
[PATCH v8 6/6] leds: mt6360: Add LED driver for MT6360
From: Gene Chen Add MT6360 LED driver include 2-channel Flash LED with torch/strobe mode, 3-channel RGB LED support Register/Flash/Breath Mode, and 1-channel for moonlight LED. Signed-off-by: Gene Chen --- drivers/leds/Kconfig | 13 + drivers/leds/Makefile | 1 + drivers/leds/leds-mt6360.c | 811 + 3 files changed, 825 insertions(+) create mode 100644 drivers/leds/leds-mt6360.c diff --git a/drivers/leds/Kconfig b/drivers/leds/Kconfig index 1c181df..4f533bc 100644 --- a/drivers/leds/Kconfig +++ b/drivers/leds/Kconfig @@ -271,6 +271,19 @@ config LEDS_MT6323 This option enables support for on-chip LED drivers found on Mediatek MT6323 PMIC. +config LEDS_MT6360 + tristate "LED Support for Mediatek MT6360 PMIC" + depends on LEDS_CLASS && OF + depends on LEDS_CLASS_FLASH || !LEDS_CLASS_FLASH + depends on LEDS_CLASS_MULTICOLOR || !LEDS_CLASS_MULTICOLOR + depends on V4L2_FLASH_LED_CLASS || !V4L2_FLASH_LED_CLASS + depends on MFD_MT6360 + help + This option enables support for dual Flash LED drivers found on + Mediatek MT6360 PMIC. + Independent current sources supply for each flash LED support torch + and strobe mode. + config LEDS_S3C24XX tristate "LED Support for Samsung S3C24XX GPIO LEDs" depends on LEDS_CLASS diff --git a/drivers/leds/Makefile b/drivers/leds/Makefile index c2c7d7a..5596427 100644 --- a/drivers/leds/Makefile +++ b/drivers/leds/Makefile @@ -66,6 +66,7 @@ obj-$(CONFIG_LEDS_MIKROTIK_RB532) += leds-rb532.o obj-$(CONFIG_LEDS_MLXCPLD) += leds-mlxcpld.o obj-$(CONFIG_LEDS_MLXREG) += leds-mlxreg.o obj-$(CONFIG_LEDS_MT6323) += leds-mt6323.o +obj-$(CONFIG_LEDS_MT6360) += leds-mt6360.o obj-$(CONFIG_LEDS_NET48XX) += leds-net48xx.o obj-$(CONFIG_LEDS_NETXBIG) += leds-netxbig.o obj-$(CONFIG_LEDS_NIC78BX) += leds-nic78bx.o diff --git a/drivers/leds/leds-mt6360.c b/drivers/leds/leds-mt6360.c new file mode 100644 index 000..94836bb --- /dev/null +++ b/drivers/leds/leds-mt6360.c @@ -0,0 +1,811 @@ +// SPDX-License-Identifier: GPL-2.0-only + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +enum { + MT6360_LED_ISNK1 = 0, + MT6360_LED_ISNK2, + MT6360_LED_ISNK3, + MT6360_LED_ISNKML, + MT6360_LED_FLASH1, + MT6360_LED_FLASH2, + MT6360_LED_MULTICOLOR, + MT6360_MAX_LEDS = MT6360_LED_MULTICOLOR +}; + +#define MT6360_REG_RGBEN 0x380 +#define MT6360_REG_ISNK(_led_no) (0x381 + (_led_no)) +#define MT6360_ISNK_ENMASK(_led_no)BIT(7 - (_led_no)) +#define MT6360_ISNK_MASK GENMASK(4, 0) +#define MT6360_CHRINDSEL_MASK BIT(3) + +#define MULTICOLOR_NUM_CHANNELS3 + +#define MT6360_REG_FLEDEN 0x37E +#define MT6360_REG_STRBTO 0x373 +#define MT6360_REG_FLEDBASE(_id) (0x372 + 4 * (_id - MT6360_LED_FLASH1)) +#define MT6360_REG_FLEDISTRB(_id) (MT6360_REG_FLEDBASE(_id) + 2) +#define MT6360_REG_FLEDITOR(_id) (MT6360_REG_FLEDBASE(_id) + 3) +#define MT6360_REG_CHGSTAT20x3E1 +#define MT6360_REG_FLEDSTAT1 0x3E9 +#define MT6360_ITORCH_MASK GENMASK(4, 0) +#define MT6360_ISTROBE_MASKGENMASK(6, 0) +#define MT6360_STRBTO_MASK GENMASK(6, 0) +#define MT6360_TORCHEN_MASKBIT(3) +#define MT6360_STROBEN_MASKBIT(2) +#define MT6360_FLCSEN_MASK(_id)BIT(MT6360_LED_FLASH2 - _id) +#define MT6360_FLEDCHGVINOVP_MASK BIT(3) +#define MT6360_FLED1STRBTO_MASKBIT(11) +#define MT6360_FLED2STRBTO_MASKBIT(10) +#define MT6360_FLED1STRB_MASK BIT(9) +#define MT6360_FLED2STRB_MASK BIT(8) +#define MT6360_FLED1SHORT_MASK BIT(7) +#define MT6360_FLED2SHORT_MASK BIT(6) +#define MT6360_FLEDLVF_MASKBIT(3) + +#define MT6360_ISNKRGB_STEPUA 2000 +#define MT6360_ISNKRGB_MAXUA 24000 +#define MT6360_ISNKML_STEPUA 5000 +#define MT6360_ISNKML_MAXUA15 + +#define MT6360_ITORCH_MINUA25000 +#define MT6360_ITORCH_STEPUA 12500 +#define MT6360_ITORCH_MAXUA40 +#define MT6360_ISTRB_MINUA 5 +#define MT6360_ISTRB_STEPUA12500 +#define MT6360_ISTRB_MAXUA 150 +#define MT6360_STRBTO_MINUS64000 +#define MT6360_STRBTO_STEPUS 32000 +#define MT6360_STRBTO_MAXUS2432000 + +#define STATE_OFF 0 +#define STATE_KEEP 1 +#define STATE_ON 2 + +struct mt6360_led { + union { + struct led_classdev isnk; + struct led_classdev_mc mc; +
[PATCH v8 3/6] dt-bindings: leds: Add LED_FUNCTION_MOONLIGHT definitions
From: Gene Chen Add LED_FUNCTION_MOONLIGHT definitions Signed-off-by: Gene Chen --- include/dt-bindings/leds/common.h | 1 + 1 file changed, 1 insertion(+) diff --git a/include/dt-bindings/leds/common.h b/include/dt-bindings/leds/common.h index 52b619d..843e65d 100644 --- a/include/dt-bindings/leds/common.h +++ b/include/dt-bindings/leds/common.h @@ -78,6 +78,7 @@ #define LED_FUNCTION_INDICATOR "indicator" #define LED_FUNCTION_LAN "lan" #define LED_FUNCTION_MAIL "mail" +#define LED_FUNCTION_MOONLIGHT "moonlight" #define LED_FUNCTION_MTD "mtd" #define LED_FUNCTION_PANIC "panic" #define LED_FUNCTION_PROGRAMMING "programming" -- 2.7.4
[PATCH v8 2/6] leds: flash: Fix multicolor registration no-ops by return 0
From: Gene Chen Fix multicolor registration no-ops by return 0 Signed-off-by: Gene Chen --- include/linux/led-class-multicolor.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/include/linux/led-class-multicolor.h b/include/linux/led-class-multicolor.h index 5116f9a..dbf3832 100644 --- a/include/linux/led-class-multicolor.h +++ b/include/linux/led-class-multicolor.h @@ -83,7 +83,7 @@ static inline int led_classdev_multicolor_register_ext(struct device *parent, struct led_classdev_mc *mcled_cdev, struct led_init_data *init_data) { - return -EINVAL; + return 0; } static inline int led_classdev_multicolor_register(struct device *parent, @@ -96,14 +96,14 @@ static inline void led_classdev_multicolor_unregister(struct led_classdev_mc *mc static inline int led_mc_calc_color_components(struct led_classdev_mc *mcled_cdev, enum led_brightness brightness) { - return -EINVAL; + return 0; } static inline int devm_led_classdev_multicolor_register_ext(struct device *parent, struct led_classdev_mc *mcled_cdev, struct led_init_data *init_data) { - return -EINVAL; + return 0; } static inline int devm_led_classdev_multicolor_register(struct device *parent, -- 2.7.4
[PATCH v9 1/6] leds: flash: Add flash registration with undefined CONFIG_LEDS_CLASS_FLASH
From: Gene Chen Add flash registration with undefined CONFIG_LEDS_CLASS_FLASH Signed-off-by: Gene Chen --- include/linux/led-class-flash.h | 42 - 1 file changed, 33 insertions(+), 9 deletions(-) diff --git a/include/linux/led-class-flash.h b/include/linux/led-class-flash.h index 21a3358..612b4ca 100644 --- a/include/linux/led-class-flash.h +++ b/include/linux/led-class-flash.h @@ -85,6 +85,7 @@ static inline struct led_classdev_flash *lcdev_to_flcdev( return container_of(lcdev, struct led_classdev_flash, led_cdev); } +#if IS_ENABLED(CONFIG_LEDS_CLASS_FLASH) /** * led_classdev_flash_register_ext - register a new object of LED class with * init data and with support for flash LEDs @@ -98,12 +99,6 @@ int led_classdev_flash_register_ext(struct device *parent, struct led_classdev_flash *fled_cdev, struct led_init_data *init_data); -static inline int led_classdev_flash_register(struct device *parent, - struct led_classdev_flash *fled_cdev) -{ - return led_classdev_flash_register_ext(parent, fled_cdev, NULL); -} - /** * led_classdev_flash_unregister - unregisters an object of led_classdev class *with support for flash LEDs @@ -118,15 +113,44 @@ int devm_led_classdev_flash_register_ext(struct device *parent, struct led_init_data *init_data); +void devm_led_classdev_flash_unregister(struct device *parent, + struct led_classdev_flash *fled_cdev); + +#else + +static inline int led_classdev_flash_register_ext(struct device *parent, + struct led_classdev_flash *fled_cdev, + struct led_init_data *init_data) +{ + return 0; +} + +static inline void led_classdev_flash_unregister(struct led_classdev_flash *fled_cdev) {}; +static inline int devm_led_classdev_flash_register_ext(struct device *parent, +struct led_classdev_flash *fled_cdev, +struct led_init_data *init_data) +{ + return 0; +} + +static inline void devm_led_classdev_flash_unregister(struct device *parent, + struct led_classdev_flash *fled_cdev) +{}; + +#endif /* IS_ENABLED(CONFIG_LEDS_CLASS_FLASH) */ + +static inline int led_classdev_flash_register(struct device *parent, + struct led_classdev_flash *fled_cdev) +{ + return led_classdev_flash_register_ext(parent, fled_cdev, NULL); +} + static inline int devm_led_classdev_flash_register(struct device *parent, struct led_classdev_flash *fled_cdev) { return devm_led_classdev_flash_register_ext(parent, fled_cdev, NULL); } -void devm_led_classdev_flash_unregister(struct device *parent, - struct led_classdev_flash *fled_cdev); - /** * led_set_flash_strobe - setup flash strobe * @fled_cdev: the flash LED to set strobe on -- 2.7.4
[PATCH v9 2/6] leds: flash: Fix multicolor registration no-ops by return 0
From: Gene Chen Fix multicolor registration no-ops by return 0 Signed-off-by: Gene Chen --- include/linux/led-class-multicolor.h | 42 +--- 1 file changed, 15 insertions(+), 27 deletions(-) diff --git a/include/linux/led-class-multicolor.h b/include/linux/led-class-multicolor.h index 5116f9a..210d57b 100644 --- a/include/linux/led-class-multicolor.h +++ b/include/linux/led-class-multicolor.h @@ -44,12 +44,6 @@ int led_classdev_multicolor_register_ext(struct device *parent, struct led_classdev_mc *mcled_cdev, struct led_init_data *init_data); -static inline int led_classdev_multicolor_register(struct device *parent, - struct led_classdev_mc *mcled_cdev) -{ - return led_classdev_multicolor_register_ext(parent, mcled_cdev, NULL); -} - /** * led_classdev_multicolor_unregister - unregisters an object of led_classdev * class with support for multicolor LEDs @@ -68,13 +62,6 @@ int devm_led_classdev_multicolor_register_ext(struct device *parent, struct led_classdev_mc *mcled_cdev, struct led_init_data *init_data); -static inline int devm_led_classdev_multicolor_register(struct device *parent, -struct led_classdev_mc *mcled_cdev) -{ - return devm_led_classdev_multicolor_register_ext(parent, mcled_cdev, -NULL); -} - void devm_led_classdev_multicolor_unregister(struct device *parent, struct led_classdev_mc *mcled_cdev); #else @@ -83,27 +70,33 @@ static inline int led_classdev_multicolor_register_ext(struct device *parent, struct led_classdev_mc *mcled_cdev, struct led_init_data *init_data) { - return -EINVAL; -} - -static inline int led_classdev_multicolor_register(struct device *parent, - struct led_classdev_mc *mcled_cdev) -{ - return led_classdev_multicolor_register_ext(parent, mcled_cdev, NULL); + return 0; } static inline void led_classdev_multicolor_unregister(struct led_classdev_mc *mcled_cdev) {}; static inline int led_mc_calc_color_components(struct led_classdev_mc *mcled_cdev, enum led_brightness brightness) { - return -EINVAL; + return 0; } static inline int devm_led_classdev_multicolor_register_ext(struct device *parent, struct led_classdev_mc *mcled_cdev, struct led_init_data *init_data) { - return -EINVAL; + return 0; +} + +static inline void devm_led_classdev_multicolor_unregister(struct device *parent, + struct led_classdev_mc *mcled_cdev) +{}; + +#endif /* IS_ENABLED(CONFIG_LEDS_CLASS_MULTICOLOR) */ + +static inline int led_classdev_multicolor_register(struct device *parent, + struct led_classdev_mc *mcled_cdev) +{ + return led_classdev_multicolor_register_ext(parent, mcled_cdev, NULL); } static inline int devm_led_classdev_multicolor_register(struct device *parent, @@ -113,9 +106,4 @@ static inline int devm_led_classdev_multicolor_register(struct device *parent, NULL); } -static inline void devm_led_classdev_multicolor_unregister(struct device *parent, - struct led_classdev_mc *mcled_cdev) -{}; - -#endif /* IS_ENABLED(CONFIG_LEDS_CLASS_MULTICOLOR) */ #endif /* _LINUX_MULTICOLOR_LEDS_H_INCLUDED */ -- 2.7.4
[PATCH v9 4/6] dt-bindings: leds: common: Increase LED_COLOR_ID_* maximum size
From: Gene Chen Increase LED_COLOR_ID maximum size for LED_COLOR_ID_RGB Signed-off-by: Gene Chen --- Documentation/devicetree/bindings/leds/common.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Documentation/devicetree/bindings/leds/common.yaml b/Documentation/devicetree/bindings/leds/common.yaml index a2a541b..0c9f912 100644 --- a/Documentation/devicetree/bindings/leds/common.yaml +++ b/Documentation/devicetree/bindings/leds/common.yaml @@ -43,7 +43,7 @@ properties: LED_COLOR_ID available, add a new one. $ref: /schemas/types.yaml#definitions/uint32 minimum: 0 -maximum: 8 +maximum: 9 function-enumerator: description: -- 2.7.4
[PATCH v9 5/6] dt-bindings: leds: Add bindings for MT6360 LED
From: Gene Chen Add bindings document for LED support on MT6360 PMIC Signed-off-by: Gene Chen --- .../devicetree/bindings/leds/leds-mt6360.yaml | 164 + 1 file changed, 164 insertions(+) create mode 100644 Documentation/devicetree/bindings/leds/leds-mt6360.yaml diff --git a/Documentation/devicetree/bindings/leds/leds-mt6360.yaml b/Documentation/devicetree/bindings/leds/leds-mt6360.yaml new file mode 100644 index 000..b2ffbc6 --- /dev/null +++ b/Documentation/devicetree/bindings/leds/leds-mt6360.yaml @@ -0,0 +1,164 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/leds/leds-mt6360.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: LED driver for MT6360 PMIC from MediaTek Integrated. + +maintainers: + - Gene Chen + +description: | + This module is part of the MT6360 MFD device. + see Documentation/devicetree/bindings/mfd/mt6360.yaml + Add MT6360 LED driver include 2-channel Flash LED with torch/strobe mode, + and 4-channel RGB LED support Register/Flash/Breath Mode + +properties: + compatible: +const: mediatek,mt6360-led + + "#address-cells": +const: 1 + + "#size-cells": +const: 0 + +patternProperties: + "^led@[0-6]$": +type: object +$ref: common.yaml# +description: + Properties for a single LED. + +properties: + reg: +description: Index of the LED. +enum: + - 0 # LED output INDICATOR1_RED + - 1 # LED output INDICATOR1_GREEN + - 2 # LED output INDICATOR1_BLUE + - 3 # LED output INDICATOR2_ML + - 4 # LED output FLED1 + - 5 # LED output FLED2 + - 6 # LED output MULTICOLOR + +unevaluatedProperties: false + +required: + - compatible + - "#address-cells" + - "#size-cells" + +additionalProperties: false + +examples: + - | + #include + led-controller { + compatible = "mediatek,mt6360-led"; + #address-cells = <1>; + #size-cells = <0>; + + led@3 { + reg = <3>; + function = LED_FUNCTION_MOONLIGHT; + color = ; + led-max-microamp = <15>; + }; + led@4 { + reg = <4>; + function = LED_FUNCTION_FLASH; + color = ; + function-enumerator = <1>; + led-max-microamp = <20>; + flash-max-microamp = <50>; + flash-max-timeout-us = <1024000>; + }; + led@5 { + reg = <5>; + function = LED_FUNCTION_FLASH; + color = ; + function-enumerator = <2>; + led-max-microamp = <20>; + flash-max-microamp = <50>; + flash-max-timeout-us = <1024000>; + }; + led@6 { + reg = <6>; + function = LED_FUNCTION_INDICATOR; + color = ; + led-max-microamp = <24000>; + #address-cells = <1>; + #size-cells = <0>; + + led@0 { + reg = <0>; + function = LED_FUNCTION_INDICATOR; + color = ; + }; + led@1 { + reg = <1>; + function = LED_FUNCTION_INDICATOR; + color = ; + }; + led@2 { + reg = <2>; + function = LED_FUNCTION_INDICATOR; + color = ; + }; + }; + }; + + - | + + led-controller { + compatible = "mediatek,mt6360-led"; + #address-cells = <1>; + #size-cells = <0>; + + led@0 { + reg = <0>; + function = LED_FUNCTION_INDICATOR; + color = ; + led-max-microamp = <24000>; + }; + led@1 { + reg = <1>; + function = LED_FUNCTION_INDICATOR; + color = ; + led-max-microamp = <24000>; + }; + led@2 { + reg = <2>; + function = LED_FUNCTION_INDICATOR; + color = ; + led-max-microamp = <24000>; + }; + led@3 { + reg = <3>; + function = LED_FUNCTION_MOONLIGHT; + color = ; + led-max-microamp = <15>; + }; + led@4 { + reg = <4>; + function = LED_FUNCTION_FLASH; + color = ; + function-enumerator = <1>; + led-max-microamp = <20>; + flash-max-microamp = <50>; + flash-max-timeout-us = <1024000>; + }; + led@5 { + reg = <5>; + function = LED_FUNCTION_FLASH; + color = ; + function-enumerator = <2>; + led-max-microamp = <20>; + flash-max-microamp = <50>; + flash-max-timeout-us = <1024000>; + }; + }; +... -- 2.7.4
[PATCH v9 6/6] leds: mt6360: Add LED driver for MT6360
From: Gene Chen Add MT6360 LED driver include 2-channel Flash LED with torch/strobe mode, 3-channel RGB LED support Register/Flash/Breath Mode, and 1-channel for moonlight LED. Signed-off-by: Gene Chen Acked-by: Jacek Anaszewski --- drivers/leds/Kconfig | 13 + drivers/leds/Makefile | 1 + drivers/leds/leds-mt6360.c | 811 + 3 files changed, 825 insertions(+) create mode 100644 drivers/leds/leds-mt6360.c diff --git a/drivers/leds/Kconfig b/drivers/leds/Kconfig index 1c181df..4f533bc 100644 --- a/drivers/leds/Kconfig +++ b/drivers/leds/Kconfig @@ -271,6 +271,19 @@ config LEDS_MT6323 This option enables support for on-chip LED drivers found on Mediatek MT6323 PMIC. +config LEDS_MT6360 + tristate "LED Support for Mediatek MT6360 PMIC" + depends on LEDS_CLASS && OF + depends on LEDS_CLASS_FLASH || !LEDS_CLASS_FLASH + depends on LEDS_CLASS_MULTICOLOR || !LEDS_CLASS_MULTICOLOR + depends on V4L2_FLASH_LED_CLASS || !V4L2_FLASH_LED_CLASS + depends on MFD_MT6360 + help + This option enables support for dual Flash LED drivers found on + Mediatek MT6360 PMIC. + Independent current sources supply for each flash LED support torch + and strobe mode. + config LEDS_S3C24XX tristate "LED Support for Samsung S3C24XX GPIO LEDs" depends on LEDS_CLASS diff --git a/drivers/leds/Makefile b/drivers/leds/Makefile index c2c7d7a..5596427 100644 --- a/drivers/leds/Makefile +++ b/drivers/leds/Makefile @@ -66,6 +66,7 @@ obj-$(CONFIG_LEDS_MIKROTIK_RB532) += leds-rb532.o obj-$(CONFIG_LEDS_MLXCPLD) += leds-mlxcpld.o obj-$(CONFIG_LEDS_MLXREG) += leds-mlxreg.o obj-$(CONFIG_LEDS_MT6323) += leds-mt6323.o +obj-$(CONFIG_LEDS_MT6360) += leds-mt6360.o obj-$(CONFIG_LEDS_NET48XX) += leds-net48xx.o obj-$(CONFIG_LEDS_NETXBIG) += leds-netxbig.o obj-$(CONFIG_LEDS_NIC78BX) += leds-nic78bx.o diff --git a/drivers/leds/leds-mt6360.c b/drivers/leds/leds-mt6360.c new file mode 100644 index 000..94836bb --- /dev/null +++ b/drivers/leds/leds-mt6360.c @@ -0,0 +1,811 @@ +// SPDX-License-Identifier: GPL-2.0-only + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +enum { + MT6360_LED_ISNK1 = 0, + MT6360_LED_ISNK2, + MT6360_LED_ISNK3, + MT6360_LED_ISNKML, + MT6360_LED_FLASH1, + MT6360_LED_FLASH2, + MT6360_LED_MULTICOLOR, + MT6360_MAX_LEDS = MT6360_LED_MULTICOLOR +}; + +#define MT6360_REG_RGBEN 0x380 +#define MT6360_REG_ISNK(_led_no) (0x381 + (_led_no)) +#define MT6360_ISNK_ENMASK(_led_no)BIT(7 - (_led_no)) +#define MT6360_ISNK_MASK GENMASK(4, 0) +#define MT6360_CHRINDSEL_MASK BIT(3) + +#define MULTICOLOR_NUM_CHANNELS3 + +#define MT6360_REG_FLEDEN 0x37E +#define MT6360_REG_STRBTO 0x373 +#define MT6360_REG_FLEDBASE(_id) (0x372 + 4 * (_id - MT6360_LED_FLASH1)) +#define MT6360_REG_FLEDISTRB(_id) (MT6360_REG_FLEDBASE(_id) + 2) +#define MT6360_REG_FLEDITOR(_id) (MT6360_REG_FLEDBASE(_id) + 3) +#define MT6360_REG_CHGSTAT20x3E1 +#define MT6360_REG_FLEDSTAT1 0x3E9 +#define MT6360_ITORCH_MASK GENMASK(4, 0) +#define MT6360_ISTROBE_MASKGENMASK(6, 0) +#define MT6360_STRBTO_MASK GENMASK(6, 0) +#define MT6360_TORCHEN_MASKBIT(3) +#define MT6360_STROBEN_MASKBIT(2) +#define MT6360_FLCSEN_MASK(_id)BIT(MT6360_LED_FLASH2 - _id) +#define MT6360_FLEDCHGVINOVP_MASK BIT(3) +#define MT6360_FLED1STRBTO_MASKBIT(11) +#define MT6360_FLED2STRBTO_MASKBIT(10) +#define MT6360_FLED1STRB_MASK BIT(9) +#define MT6360_FLED2STRB_MASK BIT(8) +#define MT6360_FLED1SHORT_MASK BIT(7) +#define MT6360_FLED2SHORT_MASK BIT(6) +#define MT6360_FLEDLVF_MASKBIT(3) + +#define MT6360_ISNKRGB_STEPUA 2000 +#define MT6360_ISNKRGB_MAXUA 24000 +#define MT6360_ISNKML_STEPUA 5000 +#define MT6360_ISNKML_MAXUA15 + +#define MT6360_ITORCH_MINUA25000 +#define MT6360_ITORCH_STEPUA 12500 +#define MT6360_ITORCH_MAXUA40 +#define MT6360_ISTRB_MINUA 5 +#define MT6360_ISTRB_STEPUA12500 +#define MT6360_ISTRB_MAXUA 150 +#define MT6360_STRBTO_MINUS64000 +#define MT6360_STRBTO_STEPUS 32000 +#define MT6360_STRBTO_MAXUS2432000 + +#define STATE_OFF 0 +#define STATE_KEEP 1 +#define STATE_ON 2 + +struct mt6360_led { + union { + struct led_classdev isnk; +
[PATCH v9 3/6] dt-bindings: leds: Add LED_FUNCTION_MOONLIGHT definitions
From: Gene Chen Add LED_FUNCTION_MOONLIGHT definitions Signed-off-by: Gene Chen Acked-by: Jacek Anaszewski --- include/dt-bindings/leds/common.h | 1 + 1 file changed, 1 insertion(+) diff --git a/include/dt-bindings/leds/common.h b/include/dt-bindings/leds/common.h index 52b619d..843e65d 100644 --- a/include/dt-bindings/leds/common.h +++ b/include/dt-bindings/leds/common.h @@ -78,6 +78,7 @@ #define LED_FUNCTION_INDICATOR "indicator" #define LED_FUNCTION_LAN "lan" #define LED_FUNCTION_MAIL "mail" +#define LED_FUNCTION_MOONLIGHT "moonlight" #define LED_FUNCTION_MTD "mtd" #define LED_FUNCTION_PANIC "panic" #define LED_FUNCTION_PROGRAMMING "programming" -- 2.7.4
[PATCH v9 0/6] leds: mt6360: Add LED driver for MT6360
This patch series add MT6360 LED support contains driver and binding document Gene Chen (6) leds: flash: Add flash registration with undefined CONFIG_LEDS_CLASS_FLASH leds: flash: Fix multicolor registration no-ops by return 0 dt-bindings: leds: Add LED_COLOR_ID_MOONLIGHT definitions dt-bindings: leds: common: Increase LED_COLOR_ID_* maximum size dt-bindings: leds: Add bindings for MT6360 LED leds: mt6360: Add LED driver for MT6360 Documentation/devicetree/bindings/leds/common.yaml |2 Documentation/devicetree/bindings/leds/leds-mt6360.yaml | 164 +++ drivers/leds/Kconfig| 13 drivers/leds/Makefile |1 drivers/leds/leds-mt6360.c | 811 include/dt-bindings/leds/common.h |1 include/linux/led-class-flash.h | 42 include/linux/led-class-multicolor.h| 42 8 files changed, 1039 insertions(+), 37 deletions(-) changelogs between v1 & v2 - add led driver with mfd changelogs between v2 & v3 - independent add led driver - add dt-binding document - refactor macros definition for easy to debug - parse device tree by fwnode - use devm*ext to register led class device changelogs between v3 & v4 - fix binding document description - use GENMASK and add unit postfix to definition - isink register led class device changelogs between v4 & v5 - change rgb isink to multicolor control - add binding reference to mfd yaml changelogs between v5 & v6 - Use DT to decide RGB LED is multicolor device or indicator device only changelogs between v6 & v7 - Add binding multicolor device sample code - Add flash ops mutex lock - Remove V4L2 init with indicator device changelogs between v7 & v8 - Add mutex for led fault get ops - Fix flash and multicolor no-ops return 0 - Add LED_FUNCTION_MOONLIGHT changelogs between v8 & v9 - reuse api in flash and multicolor header
[PATCH v11 0/5] leds: mt6360: Add LED driver for MT6360
This patch series add MT6360 LED support contains driver and binding document Gene Chen (5) leds: flash: Add flash registration with undefined CONFIG_LEDS_CLASS_FLASH leds: flash: Fix multicolor no-ops registration by return 0 dt-bindings: leds: Add LED_COLOR_ID_MOONLIGHT definitions dt-bindings: leds: Add bindings for MT6360 LED leds: mt6360: Add LED driver for MT6360 Documentation/devicetree/bindings/leds/leds-mt6360.yaml | 159 +++ drivers/leds/Kconfig| 13 drivers/leds/Makefile |1 drivers/leds/leds-mt6360.c | 827 include/dt-bindings/leds/common.h |1 include/linux/led-class-flash.h | 42 include/linux/led-class-multicolor.h| 42 7 files changed, 1049 insertions(+), 36 deletions(-) changelogs between v1 & v2 - add led driver with mfd changelogs between v2 & v3 - independent add led driver - add dt-binding document - refactor macros definition for easy to debug - parse device tree by fwnode - use devm*ext to register led class device changelogs between v3 & v4 - fix binding document description - use GENMASK and add unit postfix to definition - isink register led class device changelogs between v4 & v5 - change rgb isink to multicolor control - add binding reference to mfd yaml changelogs between v5 & v6 - Use DT to decide RGB LED is multicolor device or indicator device only changelogs between v6 & v7 - Add binding multicolor device sample code - Add flash ops mutex lock - Remove V4L2 init with indicator device changelogs between v7 & v8 - Add mutex for led fault get ops - Fix flash and multicolor no-ops return 0 - Add LED_FUNCTION_MOONLIGHT changelogs between v8 & v9 - reuse api in flash and multicolor header changelogs between v9 & v10 - add comment for reuse registration functions in flash and multicolor changelogs between v10 & v11 - match dt-binding reg property comment to the functionality name - remove exist patch in linux-next - dicide multicolor channel by color definitiion
[PATCH v11 1/5] leds: flash: Add flash registration with undefined CONFIG_LEDS_CLASS_FLASH
From: Gene Chen Add flash registration with undefined CONFIG_LEDS_CLASS_FLASH, and move the same registration functions outside of #ifdef block. Signed-off-by: Gene Chen Acked-by: Jacek Anaszewski --- include/linux/led-class-flash.h | 42 - 1 file changed, 33 insertions(+), 9 deletions(-) diff --git a/include/linux/led-class-flash.h b/include/linux/led-class-flash.h index 21a3358..612b4ca 100644 --- a/include/linux/led-class-flash.h +++ b/include/linux/led-class-flash.h @@ -85,6 +85,7 @@ static inline struct led_classdev_flash *lcdev_to_flcdev( return container_of(lcdev, struct led_classdev_flash, led_cdev); } +#if IS_ENABLED(CONFIG_LEDS_CLASS_FLASH) /** * led_classdev_flash_register_ext - register a new object of LED class with * init data and with support for flash LEDs @@ -98,12 +99,6 @@ int led_classdev_flash_register_ext(struct device *parent, struct led_classdev_flash *fled_cdev, struct led_init_data *init_data); -static inline int led_classdev_flash_register(struct device *parent, - struct led_classdev_flash *fled_cdev) -{ - return led_classdev_flash_register_ext(parent, fled_cdev, NULL); -} - /** * led_classdev_flash_unregister - unregisters an object of led_classdev class *with support for flash LEDs @@ -118,15 +113,44 @@ int devm_led_classdev_flash_register_ext(struct device *parent, struct led_init_data *init_data); +void devm_led_classdev_flash_unregister(struct device *parent, + struct led_classdev_flash *fled_cdev); + +#else + +static inline int led_classdev_flash_register_ext(struct device *parent, + struct led_classdev_flash *fled_cdev, + struct led_init_data *init_data) +{ + return 0; +} + +static inline void led_classdev_flash_unregister(struct led_classdev_flash *fled_cdev) {}; +static inline int devm_led_classdev_flash_register_ext(struct device *parent, +struct led_classdev_flash *fled_cdev, +struct led_init_data *init_data) +{ + return 0; +} + +static inline void devm_led_classdev_flash_unregister(struct device *parent, + struct led_classdev_flash *fled_cdev) +{}; + +#endif /* IS_ENABLED(CONFIG_LEDS_CLASS_FLASH) */ + +static inline int led_classdev_flash_register(struct device *parent, + struct led_classdev_flash *fled_cdev) +{ + return led_classdev_flash_register_ext(parent, fled_cdev, NULL); +} + static inline int devm_led_classdev_flash_register(struct device *parent, struct led_classdev_flash *fled_cdev) { return devm_led_classdev_flash_register_ext(parent, fled_cdev, NULL); } -void devm_led_classdev_flash_unregister(struct device *parent, - struct led_classdev_flash *fled_cdev); - /** * led_set_flash_strobe - setup flash strobe * @fled_cdev: the flash LED to set strobe on -- 2.7.4
[PATCH v11 3/5] dt-bindings: leds: Add LED_FUNCTION_MOONLIGHT definitions
From: Gene Chen Add LED_FUNCTION_MOONLIGHT definitions Signed-off-by: Gene Chen Acked-by: Jacek Anaszewski Acked-by: Rob Herring --- include/dt-bindings/leds/common.h | 1 + 1 file changed, 1 insertion(+) diff --git a/include/dt-bindings/leds/common.h b/include/dt-bindings/leds/common.h index 52b619d..843e65d 100644 --- a/include/dt-bindings/leds/common.h +++ b/include/dt-bindings/leds/common.h @@ -78,6 +78,7 @@ #define LED_FUNCTION_INDICATOR "indicator" #define LED_FUNCTION_LAN "lan" #define LED_FUNCTION_MAIL "mail" +#define LED_FUNCTION_MOONLIGHT "moonlight" #define LED_FUNCTION_MTD "mtd" #define LED_FUNCTION_PANIC "panic" #define LED_FUNCTION_PROGRAMMING "programming" -- 2.7.4
[PATCH v11 2/5] leds: flash: Fix multicolor no-ops registration by return 0
From: Gene Chen Fix multicolor no-ops registration by return 0, and move the same registration functions outside of #ifdef block. Signed-off-by: Gene Chen Acked-by: Jacek Anaszewski --- include/linux/led-class-multicolor.h | 42 +--- 1 file changed, 15 insertions(+), 27 deletions(-) diff --git a/include/linux/led-class-multicolor.h b/include/linux/led-class-multicolor.h index 5116f9a..210d57b 100644 --- a/include/linux/led-class-multicolor.h +++ b/include/linux/led-class-multicolor.h @@ -44,12 +44,6 @@ int led_classdev_multicolor_register_ext(struct device *parent, struct led_classdev_mc *mcled_cdev, struct led_init_data *init_data); -static inline int led_classdev_multicolor_register(struct device *parent, - struct led_classdev_mc *mcled_cdev) -{ - return led_classdev_multicolor_register_ext(parent, mcled_cdev, NULL); -} - /** * led_classdev_multicolor_unregister - unregisters an object of led_classdev * class with support for multicolor LEDs @@ -68,13 +62,6 @@ int devm_led_classdev_multicolor_register_ext(struct device *parent, struct led_classdev_mc *mcled_cdev, struct led_init_data *init_data); -static inline int devm_led_classdev_multicolor_register(struct device *parent, -struct led_classdev_mc *mcled_cdev) -{ - return devm_led_classdev_multicolor_register_ext(parent, mcled_cdev, -NULL); -} - void devm_led_classdev_multicolor_unregister(struct device *parent, struct led_classdev_mc *mcled_cdev); #else @@ -83,27 +70,33 @@ static inline int led_classdev_multicolor_register_ext(struct device *parent, struct led_classdev_mc *mcled_cdev, struct led_init_data *init_data) { - return -EINVAL; -} - -static inline int led_classdev_multicolor_register(struct device *parent, - struct led_classdev_mc *mcled_cdev) -{ - return led_classdev_multicolor_register_ext(parent, mcled_cdev, NULL); + return 0; } static inline void led_classdev_multicolor_unregister(struct led_classdev_mc *mcled_cdev) {}; static inline int led_mc_calc_color_components(struct led_classdev_mc *mcled_cdev, enum led_brightness brightness) { - return -EINVAL; + return 0; } static inline int devm_led_classdev_multicolor_register_ext(struct device *parent, struct led_classdev_mc *mcled_cdev, struct led_init_data *init_data) { - return -EINVAL; + return 0; +} + +static inline void devm_led_classdev_multicolor_unregister(struct device *parent, + struct led_classdev_mc *mcled_cdev) +{}; + +#endif /* IS_ENABLED(CONFIG_LEDS_CLASS_MULTICOLOR) */ + +static inline int led_classdev_multicolor_register(struct device *parent, + struct led_classdev_mc *mcled_cdev) +{ + return led_classdev_multicolor_register_ext(parent, mcled_cdev, NULL); } static inline int devm_led_classdev_multicolor_register(struct device *parent, @@ -113,9 +106,4 @@ static inline int devm_led_classdev_multicolor_register(struct device *parent, NULL); } -static inline void devm_led_classdev_multicolor_unregister(struct device *parent, - struct led_classdev_mc *mcled_cdev) -{}; - -#endif /* IS_ENABLED(CONFIG_LEDS_CLASS_MULTICOLOR) */ #endif /* _LINUX_MULTICOLOR_LEDS_H_INCLUDED */ -- 2.7.4
[PATCH v11 4/5] dt-bindings: leds: Add bindings for MT6360 LED
From: Gene Chen Add bindings document for LED support on MT6360 PMIC Signed-off-by: Gene Chen --- .../devicetree/bindings/leds/leds-mt6360.yaml | 159 + 1 file changed, 159 insertions(+) create mode 100644 Documentation/devicetree/bindings/leds/leds-mt6360.yaml diff --git a/Documentation/devicetree/bindings/leds/leds-mt6360.yaml b/Documentation/devicetree/bindings/leds/leds-mt6360.yaml new file mode 100644 index 000..73c67b1 --- /dev/null +++ b/Documentation/devicetree/bindings/leds/leds-mt6360.yaml @@ -0,0 +1,159 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/leds/leds-mt6360.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: LED driver for MT6360 PMIC from MediaTek Integrated. + +maintainers: + - Gene Chen + +description: | + This module is part of the MT6360 MFD device. + see Documentation/devicetree/bindings/mfd/mt6360.yaml + Add MT6360 LED driver include 2-channel Flash LED with torch/strobe mode, + and 4-channel RGB LED support Register/Flash/Breath Mode + +properties: + compatible: +const: mediatek,mt6360-led + + "#address-cells": +const: 1 + + "#size-cells": +const: 0 + +patternProperties: + "(^led@[0-5]$|led)": +type: object +$ref: common.yaml# +description: + Properties for a single LED. + +properties: + reg: +description: Index of the LED. +enum: + - 0 # LED output ISINK1 + - 1 # LED output ISINK2 + - 2 # LED output ISINK3 + - 3 # LED output ISINKML + - 4 # LED output FLASH1 + - 5 # LED output FLASH2 + +unevaluatedProperties: false + +required: + - compatible + - "#address-cells" + - "#size-cells" + +additionalProperties: false + +examples: + - | + #include + led-controller { + compatible = "mediatek,mt6360-led"; + #address-cells = <1>; + #size-cells = <0>; + + multi-led@0 { + reg = <0>; + function = LED_FUNCTION_INDICATOR; + color = ; + led-max-microamp = <24000>; + #address-cells = <1>; + #size-cells = <0>; + led@0 { + reg = <0>; + color = ; + }; + led@1 { + reg = <1>; + color = ; + }; + led@2 { + reg = <2>; + color = ; + }; + }; + led@3 { + reg = <3>; + function = LED_FUNCTION_MOONLIGHT; + color = ; + led-max-microamp = <15>; + }; + led@4 { + reg = <4>; + function = LED_FUNCTION_FLASH; + color = ; + function-enumerator = <1>; + led-max-microamp = <20>; + flash-max-microamp = <50>; + flash-max-timeout-us = <1024000>; + }; + led@5 { + reg = <5>; + function = LED_FUNCTION_FLASH; + color = ; + function-enumerator = <2>; + led-max-microamp = <20>; + flash-max-microamp = <50>; + flash-max-timeout-us = <1024000>; + }; + }; + + - | + + led-controller { + compatible = "mediatek,mt6360-led"; + #address-cells = <1>; + #size-cells = <0>; + + led@0 { + reg = <0>; + function = LED_FUNCTION_INDICATOR; + color = ; + led-max-microamp = <24000>; + }; + led@1 { + reg = <1>; + function = LED_FUNCTION_INDICATOR; + color = ; + led-max-microamp = <24000>; + }; + led@2 { + reg = <2>; + function = LED_FUNCTION_INDICATOR; + color = ; + led-max-microamp = <24000>; + }; + led@3 { + reg = <3>; + function = LED_FUNCTION_MOONLIGHT; + color = ; + led-max-microamp = <15>; + }; + led@4 { + reg = <4>; + function = LED_FUNCTION_FLASH; + color = ; + function-enumerator = <1>; + led-max-microamp = <20>; + flash-max-microamp = <50>; + flash-max-timeout-us = <1024000>; + }; + led@5 { + reg = <5>; + function = LED_FUNCTION_FLASH; + color = ; + function-enumerator = <2>; + led-max-microamp = <20>; + flash-max-microamp = <50>; + flash-max-timeout-us = <1024000>; + }; + }; +... -- 2.7.4
[PATCH v11 5/5] leds: mt6360: Add LED driver for MT6360
From: Gene Chen Add MT6360 LED driver include 2-channel Flash LED with torch/strobe mode, 3-channel RGB LED support Register/Flash/Breath Mode, and 1-channel for moonlight LED. Signed-off-by: Gene Chen --- drivers/leds/Kconfig | 13 + drivers/leds/Makefile | 1 + drivers/leds/leds-mt6360.c | 827 + 3 files changed, 841 insertions(+) create mode 100644 drivers/leds/leds-mt6360.c diff --git a/drivers/leds/Kconfig b/drivers/leds/Kconfig index 1c181df..4f533bc 100644 --- a/drivers/leds/Kconfig +++ b/drivers/leds/Kconfig @@ -271,6 +271,19 @@ config LEDS_MT6323 This option enables support for on-chip LED drivers found on Mediatek MT6323 PMIC. +config LEDS_MT6360 + tristate "LED Support for Mediatek MT6360 PMIC" + depends on LEDS_CLASS && OF + depends on LEDS_CLASS_FLASH || !LEDS_CLASS_FLASH + depends on LEDS_CLASS_MULTICOLOR || !LEDS_CLASS_MULTICOLOR + depends on V4L2_FLASH_LED_CLASS || !V4L2_FLASH_LED_CLASS + depends on MFD_MT6360 + help + This option enables support for dual Flash LED drivers found on + Mediatek MT6360 PMIC. + Independent current sources supply for each flash LED support torch + and strobe mode. + config LEDS_S3C24XX tristate "LED Support for Samsung S3C24XX GPIO LEDs" depends on LEDS_CLASS diff --git a/drivers/leds/Makefile b/drivers/leds/Makefile index c2c7d7a..5596427 100644 --- a/drivers/leds/Makefile +++ b/drivers/leds/Makefile @@ -66,6 +66,7 @@ obj-$(CONFIG_LEDS_MIKROTIK_RB532) += leds-rb532.o obj-$(CONFIG_LEDS_MLXCPLD) += leds-mlxcpld.o obj-$(CONFIG_LEDS_MLXREG) += leds-mlxreg.o obj-$(CONFIG_LEDS_MT6323) += leds-mt6323.o +obj-$(CONFIG_LEDS_MT6360) += leds-mt6360.o obj-$(CONFIG_LEDS_NET48XX) += leds-net48xx.o obj-$(CONFIG_LEDS_NETXBIG) += leds-netxbig.o obj-$(CONFIG_LEDS_NIC78BX) += leds-nic78bx.o diff --git a/drivers/leds/leds-mt6360.c b/drivers/leds/leds-mt6360.c new file mode 100644 index 000..42d18a8 --- /dev/null +++ b/drivers/leds/leds-mt6360.c @@ -0,0 +1,827 @@ +// SPDX-License-Identifier: GPL-2.0-only + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +enum { + MT6360_LED_ISNK1 = 0, + MT6360_LED_ISNK2, + MT6360_LED_ISNK3, + MT6360_LED_ISNKML, + MT6360_LED_FLASH1, + MT6360_LED_FLASH2, + MT6360_MAX_LEDS +}; + +#define MT6360_REG_RGBEN 0x380 +#define MT6360_REG_ISNK(_led_no) (0x381 + (_led_no)) +#define MT6360_ISNK_ENMASK(_led_no)BIT(7 - (_led_no)) +#define MT6360_ISNK_MASK GENMASK(4, 0) +#define MT6360_CHRINDSEL_MASK BIT(3) + +/* Virtual definition for multicolor */ +#define MT6360_VIRTUAL_MULTICOLOR (MT6360_MAX_LEDS + 1) +#define MULTICOLOR_NUM_CHANNELS3 + +#define MT6360_REG_FLEDEN 0x37E +#define MT6360_REG_STRBTO 0x373 +#define MT6360_REG_FLEDBASE(_id) (0x372 + 4 * (_id - MT6360_LED_FLASH1)) +#define MT6360_REG_FLEDISTRB(_id) (MT6360_REG_FLEDBASE(_id) + 2) +#define MT6360_REG_FLEDITOR(_id) (MT6360_REG_FLEDBASE(_id) + 3) +#define MT6360_REG_CHGSTAT20x3E1 +#define MT6360_REG_FLEDSTAT1 0x3E9 +#define MT6360_ITORCH_MASK GENMASK(4, 0) +#define MT6360_ISTROBE_MASKGENMASK(6, 0) +#define MT6360_STRBTO_MASK GENMASK(6, 0) +#define MT6360_TORCHEN_MASKBIT(3) +#define MT6360_STROBEN_MASKBIT(2) +#define MT6360_FLCSEN_MASK(_id)BIT(MT6360_LED_FLASH2 - _id) +#define MT6360_FLEDCHGVINOVP_MASK BIT(3) +#define MT6360_FLED1STRBTO_MASKBIT(11) +#define MT6360_FLED2STRBTO_MASKBIT(10) +#define MT6360_FLED1STRB_MASK BIT(9) +#define MT6360_FLED2STRB_MASK BIT(8) +#define MT6360_FLED1SHORT_MASK BIT(7) +#define MT6360_FLED2SHORT_MASK BIT(6) +#define MT6360_FLEDLVF_MASKBIT(3) + +#define MT6360_ISNKRGB_STEPUA 2000 +#define MT6360_ISNKRGB_MAXUA 24000 +#define MT6360_ISNKML_STEPUA 5000 +#define MT6360_ISNKML_MAXUA15 + +#define MT6360_ITORCH_MINUA25000 +#define MT6360_ITORCH_STEPUA 12500 +#define MT6360_ITORCH_MAXUA40 +#define MT6360_ISTRB_MINUA 5 +#define MT6360_ISTRB_STEPUA12500 +#define MT6360_ISTRB_MAXUA 150 +#define MT6360_STRBTO_MINUS64000 +#define MT6360_STRBTO_STEPUS 32000 +#define MT6360_STRBTO_MAXUS2432000 + +#define STATE_OFF 0 +#define STATE_KEEP 1 +#define STATE_ON 2 + +struct mt6360_led { + union { + struct led_classdev isnk; +
Re: [PATCH v11 3/5] dt-bindings: leds: Add LED_FUNCTION_MOONLIGHT definitions
Pavel Machek 於 2020年12月2日 週三 下午8:23寫道: > > On Wed 2020-12-02 18:46:49, Gene Chen wrote: > > From: Gene Chen > > > > Add LED_FUNCTION_MOONLIGHT definitions > > > > Signed-off-by: Gene Chen > > Acked-by: Jacek Anaszewski > > Acked-by: Rob Herring > > --- > > include/dt-bindings/leds/common.h | 1 + > > 1 file changed, 1 insertion(+) > > > > diff --git a/include/dt-bindings/leds/common.h > > b/include/dt-bindings/leds/common.h > > index 52b619d..843e65d 100644 > > --- a/include/dt-bindings/leds/common.h > > +++ b/include/dt-bindings/leds/common.h > > @@ -78,6 +78,7 @@ > > #define LED_FUNCTION_INDICATOR "indicator" > > #define LED_FUNCTION_LAN "lan" > > #define LED_FUNCTION_MAIL "mail" > > +#define LED_FUNCTION_MOONLIGHT "moonlight" > > There's "torch" function that should be used for this. I guess comment > should be added with explanation what exactly that is and how should > the LED be named. > According to mail, 11/25 "Re: [PATCH v7 2/5] dt-bindings: leds: Add LED_COLOR_ID_MOONLIGHT definitions", The Moonlight LED is LED which maximum current more than torch, but less than flash. Such as front camera fill light. I think our channel is moonlight, not torch. I will add this description to comment. We can't exactly define moonlight current level, because every vendor has their own specification. > Best regards, > Pavel > -- > http://www.livejournal.com/~pavelmachek
Re: [PATCH v13 3/5] dt-bindings: leds: Add LED_FUNCTION_MOONLIGHT definitions
Pavel Machek 於 2021年2月19日 週五 下午6:47寫道: > > Hi! > > > From: Gene Chen > > > > Add LED_FUNCTION_MOONLIGHT definitions > > > > Signed-off-by: Gene Chen > > Acked-by: Jacek Anaszewski > > Acked-by: Rob Herring > > No, sorry, I don't believe we need another define for flash/torch. > As previous discuss, > We use term "Moonlight" as reference says > "When you are trying to imitate moonlight you need to use low voltage, > softer lighting. You don’t want something that’s too bright" > which is focus on brightness instead of color. If any concern about this change, maybe we use LED_FUNCTION_INDICATOR instead? (refs: https://lkml.org/lkml/2020/11/24/1267) > Best regards, > Pavel > -- > http://www.livejournal.com/~pavelmachek
Re: [PATCH v7 04/11] mfd: mt6360: Combine mt6360 pmic/ldo resources into mt6360 regulator resources
Lee Jones 於 2021年1月15日 週五 下午3:32寫道: > > On Fri, 15 Jan 2021, Gene Chen wrote: > > > Matthias Brugger 於 2021年1月12日 週二 下午8:32寫道: > > > > > > > > > > > > On 12/11/2020 11:39, Gene Chen wrote: > > > > From: Gene Chen > > > > > > > > Combine mt6360 pmic/ldo resources into mt6360 regulator resources > > > > to simplify the similar resources object. > > > > > > > > Signed-off-by: Gene Chen > > > > Acked-for-MFD-by: Lee Jones > > > > --- > > > > drivers/mfd/mt6360-core.c | 11 +++ > > > > 1 file changed, 3 insertions(+), 8 deletions(-) > > > > > > > > diff --git a/drivers/mfd/mt6360-core.c b/drivers/mfd/mt6360-core.c > > > > index 692e47b..5119e51 100644 > > > > --- a/drivers/mfd/mt6360-core.c > > > > +++ b/drivers/mfd/mt6360-core.c > > > > @@ -265,7 +265,7 @@ static const struct resource mt6360_led_resources[] > > > > = { > > > > DEFINE_RES_IRQ_NAMED(MT6360_FLED1_STRB_TO_EVT, > > > > "fled1_strb_to_evt"), > > > > }; > > > > > > > > -static const struct resource mt6360_pmic_resources[] = { > > > > +static const struct resource mt6360_regulator_resources[] = { > > > > DEFINE_RES_IRQ_NAMED(MT6360_BUCK1_PGB_EVT, "buck1_pgb_evt"), > > > > DEFINE_RES_IRQ_NAMED(MT6360_BUCK1_OC_EVT, "buck1_oc_evt"), > > > > DEFINE_RES_IRQ_NAMED(MT6360_BUCK1_OV_EVT, "buck1_ov_evt"), > > > > @@ -278,9 +278,6 @@ static const struct resource > > > > mt6360_pmic_resources[] = { > > > > DEFINE_RES_IRQ_NAMED(MT6360_LDO7_OC_EVT, "ldo7_oc_evt"), > > > > DEFINE_RES_IRQ_NAMED(MT6360_LDO6_PGB_EVT, "ldo6_pgb_evt"), > > > > DEFINE_RES_IRQ_NAMED(MT6360_LDO7_PGB_EVT, "ldo7_pgb_evt"), > > > > -}; > > > > - > > > > -static const struct resource mt6360_ldo_resources[] = { > > > > DEFINE_RES_IRQ_NAMED(MT6360_LDO1_OC_EVT, "ldo1_oc_evt"), > > > > DEFINE_RES_IRQ_NAMED(MT6360_LDO2_OC_EVT, "ldo2_oc_evt"), > > > > DEFINE_RES_IRQ_NAMED(MT6360_LDO3_OC_EVT, "ldo3_oc_evt"), > > > > @@ -298,10 +295,8 @@ static const struct mfd_cell mt6360_devs[] = { > > > > NULL, 0, 0, "mediatek,mt6360-chg"), > > > > OF_MFD_CELL("mt6360-led", mt6360_led_resources, > > > > NULL, 0, 0, "mediatek,mt6360-led"), > > > > - OF_MFD_CELL("mt6360-pmic", mt6360_pmic_resources, > > > > - NULL, 0, 0, "mediatek,mt6360-pmic"), > > > > - OF_MFD_CELL("mt6360-ldo", mt6360_ldo_resources, > > > > - NULL, 0, 0, "mediatek,mt6360-ldo"), > > > > + OF_MFD_CELL("mt6360-regulator", mt6360_regulator_resources, > > > > + NULL, 0, 0, "mediatek,mt6360-regulator"), > > > > > > As discussed with the MFD maintainer [1], the regulator (and probably all > > > cells) > > > shouldn't have a DT binding. > > > > > > So please send a new version which fixes that. > > > > > > Regards, > > > Matthias > > > > > > [1] > > > https://lore.kernel.org/linux-mediatek/2021064118.ge4...@sirena.org.uk/ > > I don't think Mark is correct here. > > We usually do implement compatible strings for sub-devices and they do > tend to have their own device nodes. > > It's a very long time ago since I coded this up myself, but from > memory, you can't have 2 devices share a compatible string. > Either Mark or Lee suggestion is work. Is there a conclusion that we can apply it? If MFD is already supported of_compatible, we prefer use of_compatible mapping. > > Should I use parent's device to find sub-devices of_node if without > > compatible name? > > I trace the function mfd_add_device, > > > > if (IS_ENABLED(CONFIG_OF) && parent->of_node && cell->of_compatible) { > > . > > ret = mfd_match_of_node_to_dev(pdev, np, cell); > > . > > } > > > > which is binding mfd sub-device with compatible. Does it be removed in > > the feature? > > > > > > OF_MFD_CELL("mt6360-tcpc", NULL, > > > > NULL, 0, 0, "mediatek,mt6360-tcpc"), > > > > }; > > > > > > -- > Lee Jones [李琼斯] > Senior Technical Lead - Developer Services > Linaro.org │ Open source software for Arm SoCs > Follow Linaro: Facebook | Twitter | Blog
Re: [PATCH v4 2/2] power: supply: mt6360_charger: add MT6360 charger support
Gene Chen 於 2021年1月18日 週一 下午8:42寫道: > > From: Gene Chen > > Add basic support for the battery charger for MT6360 PMIC > > Signed-off-by: Gene Chen > --- > drivers/power/supply/Kconfig | 10 + > drivers/power/supply/Makefile | 1 + > drivers/power/supply/mt6360_charger.c | 914 > ++ > 3 files changed, 925 insertions(+) > create mode 100644 drivers/power/supply/mt6360_charger.c > > diff --git a/drivers/power/supply/Kconfig b/drivers/power/supply/Kconfig > index eec646c..dd63bed 100644 > --- a/drivers/power/supply/Kconfig > +++ b/drivers/power/supply/Kconfig > @@ -567,6 +567,16 @@ config CHARGER_MP2629 > Battery charger. This driver provides Battery charger power > management > functions on the systems. > > +config CHARGER_MT6360 > + tristate "Mediatek MT6360 Charger Driver" > + depends on MFD_MT6360 > + depends on REGULATOR > + help > + Say Y here to enable MT6360 Charger Part. > + The device supports High-Accuracy Voltage/Current Regulation, > + Average Input Current Regulation, Battery Tempature Sensing, > + Over-Temperature Protection, DPDM Detection for BC1.2 > + > config CHARGER_QCOM_SMBB > tristate "Qualcomm Switch-Mode Battery Charger and Boost" > depends on MFD_SPMI_PMIC || COMPILE_TEST > diff --git a/drivers/power/supply/Makefile b/drivers/power/supply/Makefile > index dd4b863..9bd0804 100644 > --- a/drivers/power/supply/Makefile > +++ b/drivers/power/supply/Makefile > @@ -77,6 +77,7 @@ obj-$(CONFIG_CHARGER_MAX77693)+= max77693_charger.o > obj-$(CONFIG_CHARGER_MAX8997) += max8997_charger.o > obj-$(CONFIG_CHARGER_MAX8998) += max8998_charger.o > obj-$(CONFIG_CHARGER_MP2629) += mp2629_charger.o > +obj-$(CONFIG_CHARGER_MT6360) += mt6360_charger.o > obj-$(CONFIG_CHARGER_QCOM_SMBB)+= qcom_smbb.o > obj-$(CONFIG_CHARGER_BQ2415X) += bq2415x_charger.o > obj-$(CONFIG_CHARGER_BQ24190) += bq24190_charger.o > diff --git a/drivers/power/supply/mt6360_charger.c > b/drivers/power/supply/mt6360_charger.c > new file mode 100644 > index 000..d80bdad > --- /dev/null > +++ b/drivers/power/supply/mt6360_charger.c > @@ -0,0 +1,914 @@ > +// SPDX-License-Identifier: GPL-2.0 > +/* > + * Copyright (c) 2021 MediaTek Inc. > + */ > + > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > + > +#define MT6360_PMU_CHG_CTRL1 0x311 > +#define MT6360_PMU_CHG_CTRL2 0x312 > +#define MT6360_PMU_CHG_CTRL3 0x313 > +#define MT6360_PMU_CHG_CTRL4 0x314 > +#define MT6360_PMU_CHG_CTRL5 0x315 > +#define MT6360_PMU_CHG_CTRL6 0x316 > +#define MT6360_PMU_CHG_CTRL7 0x317 > +#define MT6360_PMU_CHG_CTRL8 0x318 > +#define MT6360_PMU_CHG_CTRL9 0x319 > +#define MT6360_PMU_CHG_CTRL10 0x31A > +#define MT6360_PMU_DEVICE_TYPE 0x322 > +#define MT6360_PMU_USB_STATUS1 0x327 > +#define MT6360_PMU_CHG_STAT0x34A > +#define MT6360_PMU_CHG_CTRL19 0x361 > +#define MT6360_PMU_FOD_STAT0x3E7 > + > +/* MT6360_PMU_CHG_CTRL1 */ > +#define MT6360_FSLP_SHFT (3) > +#define MT6360_FSLP_MASK BIT(MT6360_FSLP_SHFT) > +#define MT6360_OPA_MODE_SHFT (0) > +#define MT6360_OPA_MODE_MASK BIT(MT6360_OPA_MODE_SHFT) > +/* MT6360_PMU_CHG_CTRL2 */ > +#define MT6360_IINLMTSEL_SHFT (2) > +#define MT6360_IINLMTSEL_MASK GENMASK(3, 2) > +/* MT6360_PMU_CHG_CTRL3 */ > +#define MT6360_IAICR_SHFT (2) > +#define MT6360_IAICR_MASK GENMASK(7, 2) > +#define MT6360_ILIM_EN_MASKBIT(0) > +/* MT6360_PMU_CHG_CTRL4 */ > +#define MT6360_VOREG_SHFT (1) > +#define MT6360_VOREG_MASK GENMASK(7, 1) > +/* MT6360_PMU_CHG_CTRL5 */ > +#define MT6360_VOBST_MASK GENMASK(7, 2) > +/* MT6360_PMU_CHG_CTRL6 */ > +#define MT6360_VMIVR_SHFT (1) > +#define MT6360_VMIVR_MASK GENMASK(7, 1) > +/* MT6360_PMU_CHG_CTRL7 */ > +#define MT6360_ICHG_SHFT (2) > +#define MT6360_ICHG_MASK GENMASK(7, 2) > +/* MT6360_PMU_CHG_CTRL8 */ > +#define MT6360_IPREC_SHFT (0) > +#define MT6360_IPREC_MASK GENMASK(3, 0) > +/* MT6360_PMU_CHG_CTRL9 */ > +#define MT6360_IEOC_SHFT (4) > +#define MT6360_IEOC_MASK GENMASK(7, 4) > +/* MT6360_PMU_CHG_CTRL10 */ > +#define MT6360_OTG_OC_MASK GENMASK(3, 0) > +/* MT6360_PMU_DEVICE_TYPE */ > +#define MT6360_USBCHGEN_MASK BIT(7) > +/* MT6360_PMU_USB_STATUS1 */ > +#define MT6360_USB_STATUS_SHFT (4) > +#define MT6360_USB_STATUS_MASK GENMASK(6, 4) > +/* MT6360_PMU_CHG_STAT */ > +#define MT6360_CHG_STAT_SHFT (6) > +#define MT6360_CHG_STAT_M
Re: [PATCH v3 2/2] power: supply: mt6360_charger: add MT6360 charger support
Sebastian Reichel 於 2021年1月16日 週六 下午6:12寫道: > > Hi, > > On Mon, Jan 11, 2021 at 08:15:33PM +0800, Gene Chen wrote: > > Sebastian Reichel 於 2021年1月7日 週四 上午4:16寫道: > > > > + last_usb_type = mci->psy_usb_type; > > > > + /* Plug in */ > > > > + ret = regmap_read(mci->regmap, MT6360_PMU_USB_STATUS1, > > > > &usb_status); > > > > + if (ret < 0) > > > > + goto out; > > > > + usb_status &= MT6360_USB_STATUS_MASK; > > > > + usb_status >>= MT6360_USB_STATUS_SHFT; > > > > + switch (usb_status) { > > > > + case MT6360_CHG_TYPE_UNDER_GOING: > > > > + dev_info(mci->dev, "%s: under going...\n", __func__); > > > > + goto out; > > > > > > IDK what this is supposed to tell me. Do you mean "detection in > > > progress"? Also why is this info level? I would expect either > > > debug (assuming it happens regularly and is normal) or warning > > > (assuming it should not happen). > > > > > > > When handling attach interrupt and cable plug out at the same > > time, HW change register status. So we don' need to handle this > > attach interrupt at this case. > > So this is basically for debouncing? I suggest adding a comment: > > /* Received attach IRQ followed by detach event, so nothing to do */ > dev_dbg(mci->dev, "under going...\n"); > goto out; > Sorry I have a little misunderstand. under going is "detect in progress". Attachi irq will trigger when power ready(vbus=5V) and bc12 chargedetection done. Another irq, Detachi, is indicated power not ready(vbus=0V) and which is be masked. So, if the usb status is not SDP/NONSTD/CDP/DCP, the result can be ignored. (e.q. NO VBUS/Under going/BC12 disabled/Reserved address) > [...] > > > > > + config.dev = &pdev->dev; > > > > + config.regmap = mci->regmap; > > > > + mci->otg_rdev = devm_regulator_register(&pdev->dev, > > > > &mt6360_otg_rdesc, > > > > + &config); > > > > + if (IS_ERR(mci->otg_rdev)) > > > > + return PTR_ERR(mci->otg_rdev); > > > > + > > > > + ret = mt6360_sysfs_create_group(mci); > > > > + if (ret) { > > > > + dev_err(&pdev->dev, > > > > + "%s: Failed to create sysfs attrs\n", __func__); > > > > + return ret; > > > > + } > > > > > > Use charger_cfg.attr_grp to register custom sysfs group for > > > power-supply devices. Otherwise your code is racy (udev may not pick > > > up the sysfs attributes). Also custom sysfs attributes need to be > > > documented in Documentation/ABI/testing/sysfs-class-power-. > > > > > > Looking at the attributes you are planning to expose, I don't think they > > > are suitable for sysfs anyways. Looks more like a debug interface, which > > > should go into debugfs instead. But it's hard to tell without any > > > documentation > > > being provided :) > > > > ACK, I will change to charger_cfg.attr_grp. > > I assumed the charger algorithm thread is in user space, and take > > control by sysfs node from charger device, like bq24190.c. > > Should I change to debugfs? > > It's hard to tell without knowing more about the attributes > your are trying to expose. In debugfs we have relaxed ABI rules, > so it's easier to adopt naming e.t.c. later. > I briefly classify the whole attributes. There are either unused, or can be replaced by POWER_SUPPLY PROPERTY, so I will remove unuse part. HIZ = VBUS_IN high impedance mode. VMIVR = Maximum input voltage regulation. Let input power can provide at the predetermined voltage level. (like POWER_SUPPLY_PROP_INPUT_VOLTAGE_LIMIT) SYSREG = Config system minimum regulation voltage. OTG_OC = maximum current of battery boost OTG 5V. ICHG = maximum Charging current. (like POWER_SUPPLY_PROP_CONSTANT_CHARGE_CURRENT) IEOC = Like POWER_SUPPLY_PROP_CHARGE_TERM_CURRENT VOREG = Input voltage regulation. (like POWER_SUPPLY_PROP_CONSTANT_CHARGE_VOLTAGE) LBP = Low battery protection for battery boost OTG 5V. VPREC = Pre-charge volatge level. (maybe can add new prop POWER_SUPPLY_PROP_PRECHARGE_VOLTAGE) TE = Charge termination enable/disable. CHG_WDT_EN = Charger Watch dog timer enable/disable. CHG_WDT = Charger Watch dog timer, 8/40/80/160s. WT_FC = Fast charge Timer, 4~20hr. BAT_COMP = Battery IR compensation resistor setting. VCLAMP = Battery IR compensation maximum voltage clamp. USBCHGEN = USB charger detection flow enable/disable. CHG_EN = Battery charging enable/disable. CHRDET_EXT = VBUS_IN is between VBUS_UV_TH(3.7V) and VBUS_OV_TH(10.5V) > -- Sebastian
[PATCH v10 2/6] leds: flash: Fix multicolor no-ops registration by return 0
From: Gene Chen Fix multicolor no-ops registration by return 0, and reuse same registration functions no matter multicolor class exist or not. Signed-off-by: Gene Chen --- include/linux/led-class-multicolor.h | 42 +--- 1 file changed, 15 insertions(+), 27 deletions(-) diff --git a/include/linux/led-class-multicolor.h b/include/linux/led-class-multicolor.h index 5116f9a..210d57b 100644 --- a/include/linux/led-class-multicolor.h +++ b/include/linux/led-class-multicolor.h @@ -44,12 +44,6 @@ int led_classdev_multicolor_register_ext(struct device *parent, struct led_classdev_mc *mcled_cdev, struct led_init_data *init_data); -static inline int led_classdev_multicolor_register(struct device *parent, - struct led_classdev_mc *mcled_cdev) -{ - return led_classdev_multicolor_register_ext(parent, mcled_cdev, NULL); -} - /** * led_classdev_multicolor_unregister - unregisters an object of led_classdev * class with support for multicolor LEDs @@ -68,13 +62,6 @@ int devm_led_classdev_multicolor_register_ext(struct device *parent, struct led_classdev_mc *mcled_cdev, struct led_init_data *init_data); -static inline int devm_led_classdev_multicolor_register(struct device *parent, -struct led_classdev_mc *mcled_cdev) -{ - return devm_led_classdev_multicolor_register_ext(parent, mcled_cdev, -NULL); -} - void devm_led_classdev_multicolor_unregister(struct device *parent, struct led_classdev_mc *mcled_cdev); #else @@ -83,27 +70,33 @@ static inline int led_classdev_multicolor_register_ext(struct device *parent, struct led_classdev_mc *mcled_cdev, struct led_init_data *init_data) { - return -EINVAL; -} - -static inline int led_classdev_multicolor_register(struct device *parent, - struct led_classdev_mc *mcled_cdev) -{ - return led_classdev_multicolor_register_ext(parent, mcled_cdev, NULL); + return 0; } static inline void led_classdev_multicolor_unregister(struct led_classdev_mc *mcled_cdev) {}; static inline int led_mc_calc_color_components(struct led_classdev_mc *mcled_cdev, enum led_brightness brightness) { - return -EINVAL; + return 0; } static inline int devm_led_classdev_multicolor_register_ext(struct device *parent, struct led_classdev_mc *mcled_cdev, struct led_init_data *init_data) { - return -EINVAL; + return 0; +} + +static inline void devm_led_classdev_multicolor_unregister(struct device *parent, + struct led_classdev_mc *mcled_cdev) +{}; + +#endif /* IS_ENABLED(CONFIG_LEDS_CLASS_MULTICOLOR) */ + +static inline int led_classdev_multicolor_register(struct device *parent, + struct led_classdev_mc *mcled_cdev) +{ + return led_classdev_multicolor_register_ext(parent, mcled_cdev, NULL); } static inline int devm_led_classdev_multicolor_register(struct device *parent, @@ -113,9 +106,4 @@ static inline int devm_led_classdev_multicolor_register(struct device *parent, NULL); } -static inline void devm_led_classdev_multicolor_unregister(struct device *parent, - struct led_classdev_mc *mcled_cdev) -{}; - -#endif /* IS_ENABLED(CONFIG_LEDS_CLASS_MULTICOLOR) */ #endif /* _LINUX_MULTICOLOR_LEDS_H_INCLUDED */ -- 2.7.4
[PATCH v10 0/6] leds: mt6360: Add LED driver for MT6360
[PATCH v10 0/6] leds: mt6360: Add LED driver for MT6360 This patch series add MT6360 LED support contains driver and binding document Gene Chen (6) leds: flash: Add flash registration with undefined CONFIG_LEDS_CLASS_FLASH leds: flash: Fix multicolor no-ops registration by return 0 dt-bindings: leds: Add LED_COLOR_ID_MOONLIGHT definitions dt-bindings: leds: common: Increase LED_COLOR_ID_* maximum size dt-bindings: leds: Add bindings for MT6360 LED leds: mt6360: Add LED driver for MT6360 Documentation/devicetree/bindings/leds/common.yaml |2 Documentation/devicetree/bindings/leds/leds-mt6360.yaml | 164 +++ drivers/leds/Kconfig| 13 drivers/leds/Makefile |1 drivers/leds/leds-mt6360.c | 811 include/dt-bindings/leds/common.h |1 include/linux/led-class-flash.h | 42 include/linux/led-class-multicolor.h| 42 8 files changed, 1039 insertions(+), 37 deletions(-) changelogs between v1 & v2 - add led driver with mfd changelogs between v2 & v3 - independent add led driver - add dt-binding document - refactor macros definition for easy to debug - parse device tree by fwnode - use devm*ext to register led class device changelogs between v3 & v4 - fix binding document description - use GENMASK and add unit postfix to definition - isink register led class device changelogs between v4 & v5 - change rgb isink to multicolor control - add binding reference to mfd yaml changelogs between v5 & v6 - Use DT to decide RGB LED is multicolor device or indicator device only changelogs between v6 & v7 - Add binding multicolor device sample code - Add flash ops mutex lock - Remove V4L2 init with indicator device changelogs between v7 & v8 - Add mutex for led fault get ops - Fix flash and multicolor no-ops return 0 - Add LED_FUNCTION_MOONLIGHT changelogs between v8 & v9 - reuse api in flash and multicolor header changelogs between v9 & v10 - add comment for reuse registration functions in flash and multicolor
[PATCH v10 3/6] dt-bindings: leds: Add LED_FUNCTION_MOONLIGHT definitions
From: Gene Chen Add LED_FUNCTION_MOONLIGHT definitions Signed-off-by: Gene Chen Acked-by: Jacek Anaszewski --- include/dt-bindings/leds/common.h | 1 + 1 file changed, 1 insertion(+) diff --git a/include/dt-bindings/leds/common.h b/include/dt-bindings/leds/common.h index 52b619d..843e65d 100644 --- a/include/dt-bindings/leds/common.h +++ b/include/dt-bindings/leds/common.h @@ -78,6 +78,7 @@ #define LED_FUNCTION_INDICATOR "indicator" #define LED_FUNCTION_LAN "lan" #define LED_FUNCTION_MAIL "mail" +#define LED_FUNCTION_MOONLIGHT "moonlight" #define LED_FUNCTION_MTD "mtd" #define LED_FUNCTION_PANIC "panic" #define LED_FUNCTION_PROGRAMMING "programming" -- 2.7.4
[PATCH v10 4/6] dt-bindings: leds: common: Increase LED_COLOR_ID_* maximum size
From: Gene Chen Increase LED_COLOR_ID maximum size for LED_COLOR_ID_RGB Signed-off-by: Gene Chen --- Documentation/devicetree/bindings/leds/common.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Documentation/devicetree/bindings/leds/common.yaml b/Documentation/devicetree/bindings/leds/common.yaml index a2a541b..0c9f912 100644 --- a/Documentation/devicetree/bindings/leds/common.yaml +++ b/Documentation/devicetree/bindings/leds/common.yaml @@ -43,7 +43,7 @@ properties: LED_COLOR_ID available, add a new one. $ref: /schemas/types.yaml#definitions/uint32 minimum: 0 -maximum: 8 +maximum: 9 function-enumerator: description: -- 2.7.4
[PATCH v10 5/6] dt-bindings: leds: Add bindings for MT6360 LED
From: Gene Chen Add bindings document for LED support on MT6360 PMIC Signed-off-by: Gene Chen --- .../devicetree/bindings/leds/leds-mt6360.yaml | 164 + 1 file changed, 164 insertions(+) create mode 100644 Documentation/devicetree/bindings/leds/leds-mt6360.yaml diff --git a/Documentation/devicetree/bindings/leds/leds-mt6360.yaml b/Documentation/devicetree/bindings/leds/leds-mt6360.yaml new file mode 100644 index 000..b2ffbc6 --- /dev/null +++ b/Documentation/devicetree/bindings/leds/leds-mt6360.yaml @@ -0,0 +1,164 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/leds/leds-mt6360.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: LED driver for MT6360 PMIC from MediaTek Integrated. + +maintainers: + - Gene Chen + +description: | + This module is part of the MT6360 MFD device. + see Documentation/devicetree/bindings/mfd/mt6360.yaml + Add MT6360 LED driver include 2-channel Flash LED with torch/strobe mode, + and 4-channel RGB LED support Register/Flash/Breath Mode + +properties: + compatible: +const: mediatek,mt6360-led + + "#address-cells": +const: 1 + + "#size-cells": +const: 0 + +patternProperties: + "^led@[0-6]$": +type: object +$ref: common.yaml# +description: + Properties for a single LED. + +properties: + reg: +description: Index of the LED. +enum: + - 0 # LED output INDICATOR1_RED + - 1 # LED output INDICATOR1_GREEN + - 2 # LED output INDICATOR1_BLUE + - 3 # LED output INDICATOR2_ML + - 4 # LED output FLED1 + - 5 # LED output FLED2 + - 6 # LED output MULTICOLOR + +unevaluatedProperties: false + +required: + - compatible + - "#address-cells" + - "#size-cells" + +additionalProperties: false + +examples: + - | + #include + led-controller { + compatible = "mediatek,mt6360-led"; + #address-cells = <1>; + #size-cells = <0>; + + led@3 { + reg = <3>; + function = LED_FUNCTION_MOONLIGHT; + color = ; + led-max-microamp = <15>; + }; + led@4 { + reg = <4>; + function = LED_FUNCTION_FLASH; + color = ; + function-enumerator = <1>; + led-max-microamp = <20>; + flash-max-microamp = <50>; + flash-max-timeout-us = <1024000>; + }; + led@5 { + reg = <5>; + function = LED_FUNCTION_FLASH; + color = ; + function-enumerator = <2>; + led-max-microamp = <20>; + flash-max-microamp = <50>; + flash-max-timeout-us = <1024000>; + }; + led@6 { + reg = <6>; + function = LED_FUNCTION_INDICATOR; + color = ; + led-max-microamp = <24000>; + #address-cells = <1>; + #size-cells = <0>; + + led@0 { + reg = <0>; + function = LED_FUNCTION_INDICATOR; + color = ; + }; + led@1 { + reg = <1>; + function = LED_FUNCTION_INDICATOR; + color = ; + }; + led@2 { + reg = <2>; + function = LED_FUNCTION_INDICATOR; + color = ; + }; + }; + }; + + - | + + led-controller { + compatible = "mediatek,mt6360-led"; + #address-cells = <1>; + #size-cells = <0>; + + led@0 { + reg = <0>; + function = LED_FUNCTION_INDICATOR; + color = ; + led-max-microamp = <24000>; + }; + led@1 { + reg = <1>; + function = LED_FUNCTION_INDICATOR; + color = ; + led-max-microamp = <24000>; + }; + led@2 { + reg = <2>; + function = LED_FUNCTION_INDICATOR; + color = ; + led-max-microamp = <24000>; + }; + led@3 { + reg = <3>; + function = LED_FUNCTION_MOONLIGHT; + color = ; + led-max-microamp = <15>; + }; + led@4 { + reg = <4>; + function = LED_FUNCTION_FLASH; + color = ; + function-enumerator = <1>; + led-max-microamp = <20>; + flash-max-microamp = <50>; + flash-max-timeout-us = <1024000>; + }; + led@5 { + reg = <5>; + function = LED_FUNCTION_FLASH; + color = ; + function-enumerator = <2>; + led-max-microamp = <20>; + flash-max-microamp = <50>; + flash-max-timeout-us = <1024000>; + }; + }; +... -- 2.7.4
[PATCH v10 6/6] leds: mt6360: Add LED driver for MT6360
From: Gene Chen Add MT6360 LED driver include 2-channel Flash LED with torch/strobe mode, 3-channel RGB LED support Register/Flash/Breath Mode, and 1-channel for moonlight LED. Signed-off-by: Gene Chen Acked-by: Jacek Anaszewski --- drivers/leds/Kconfig | 13 + drivers/leds/Makefile | 1 + drivers/leds/leds-mt6360.c | 811 + 3 files changed, 825 insertions(+) create mode 100644 drivers/leds/leds-mt6360.c diff --git a/drivers/leds/Kconfig b/drivers/leds/Kconfig index 1c181df..4f533bc 100644 --- a/drivers/leds/Kconfig +++ b/drivers/leds/Kconfig @@ -271,6 +271,19 @@ config LEDS_MT6323 This option enables support for on-chip LED drivers found on Mediatek MT6323 PMIC. +config LEDS_MT6360 + tristate "LED Support for Mediatek MT6360 PMIC" + depends on LEDS_CLASS && OF + depends on LEDS_CLASS_FLASH || !LEDS_CLASS_FLASH + depends on LEDS_CLASS_MULTICOLOR || !LEDS_CLASS_MULTICOLOR + depends on V4L2_FLASH_LED_CLASS || !V4L2_FLASH_LED_CLASS + depends on MFD_MT6360 + help + This option enables support for dual Flash LED drivers found on + Mediatek MT6360 PMIC. + Independent current sources supply for each flash LED support torch + and strobe mode. + config LEDS_S3C24XX tristate "LED Support for Samsung S3C24XX GPIO LEDs" depends on LEDS_CLASS diff --git a/drivers/leds/Makefile b/drivers/leds/Makefile index c2c7d7a..5596427 100644 --- a/drivers/leds/Makefile +++ b/drivers/leds/Makefile @@ -66,6 +66,7 @@ obj-$(CONFIG_LEDS_MIKROTIK_RB532) += leds-rb532.o obj-$(CONFIG_LEDS_MLXCPLD) += leds-mlxcpld.o obj-$(CONFIG_LEDS_MLXREG) += leds-mlxreg.o obj-$(CONFIG_LEDS_MT6323) += leds-mt6323.o +obj-$(CONFIG_LEDS_MT6360) += leds-mt6360.o obj-$(CONFIG_LEDS_NET48XX) += leds-net48xx.o obj-$(CONFIG_LEDS_NETXBIG) += leds-netxbig.o obj-$(CONFIG_LEDS_NIC78BX) += leds-nic78bx.o diff --git a/drivers/leds/leds-mt6360.c b/drivers/leds/leds-mt6360.c new file mode 100644 index 000..94836bb --- /dev/null +++ b/drivers/leds/leds-mt6360.c @@ -0,0 +1,811 @@ +// SPDX-License-Identifier: GPL-2.0-only + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +enum { + MT6360_LED_ISNK1 = 0, + MT6360_LED_ISNK2, + MT6360_LED_ISNK3, + MT6360_LED_ISNKML, + MT6360_LED_FLASH1, + MT6360_LED_FLASH2, + MT6360_LED_MULTICOLOR, + MT6360_MAX_LEDS = MT6360_LED_MULTICOLOR +}; + +#define MT6360_REG_RGBEN 0x380 +#define MT6360_REG_ISNK(_led_no) (0x381 + (_led_no)) +#define MT6360_ISNK_ENMASK(_led_no)BIT(7 - (_led_no)) +#define MT6360_ISNK_MASK GENMASK(4, 0) +#define MT6360_CHRINDSEL_MASK BIT(3) + +#define MULTICOLOR_NUM_CHANNELS3 + +#define MT6360_REG_FLEDEN 0x37E +#define MT6360_REG_STRBTO 0x373 +#define MT6360_REG_FLEDBASE(_id) (0x372 + 4 * (_id - MT6360_LED_FLASH1)) +#define MT6360_REG_FLEDISTRB(_id) (MT6360_REG_FLEDBASE(_id) + 2) +#define MT6360_REG_FLEDITOR(_id) (MT6360_REG_FLEDBASE(_id) + 3) +#define MT6360_REG_CHGSTAT20x3E1 +#define MT6360_REG_FLEDSTAT1 0x3E9 +#define MT6360_ITORCH_MASK GENMASK(4, 0) +#define MT6360_ISTROBE_MASKGENMASK(6, 0) +#define MT6360_STRBTO_MASK GENMASK(6, 0) +#define MT6360_TORCHEN_MASKBIT(3) +#define MT6360_STROBEN_MASKBIT(2) +#define MT6360_FLCSEN_MASK(_id)BIT(MT6360_LED_FLASH2 - _id) +#define MT6360_FLEDCHGVINOVP_MASK BIT(3) +#define MT6360_FLED1STRBTO_MASKBIT(11) +#define MT6360_FLED2STRBTO_MASKBIT(10) +#define MT6360_FLED1STRB_MASK BIT(9) +#define MT6360_FLED2STRB_MASK BIT(8) +#define MT6360_FLED1SHORT_MASK BIT(7) +#define MT6360_FLED2SHORT_MASK BIT(6) +#define MT6360_FLEDLVF_MASKBIT(3) + +#define MT6360_ISNKRGB_STEPUA 2000 +#define MT6360_ISNKRGB_MAXUA 24000 +#define MT6360_ISNKML_STEPUA 5000 +#define MT6360_ISNKML_MAXUA15 + +#define MT6360_ITORCH_MINUA25000 +#define MT6360_ITORCH_STEPUA 12500 +#define MT6360_ITORCH_MAXUA40 +#define MT6360_ISTRB_MINUA 5 +#define MT6360_ISTRB_STEPUA12500 +#define MT6360_ISTRB_MAXUA 150 +#define MT6360_STRBTO_MINUS64000 +#define MT6360_STRBTO_STEPUS 32000 +#define MT6360_STRBTO_MAXUS2432000 + +#define STATE_OFF 0 +#define STATE_KEEP 1 +#define STATE_ON 2 + +struct mt6360_led { + union { + struct led_classdev isnk; +
[PATCH v10 1/6] leds: flash: Add flash registration with undefined CONFIG_LEDS_CLASS_FLASH
From: Gene Chen Add flash registration with undefined CONFIG_LEDS_CLASS_FLASH, and reuse same registration functions no matter flash class exist or not. Signed-off-by: Gene Chen --- include/linux/led-class-flash.h | 42 - 1 file changed, 33 insertions(+), 9 deletions(-) diff --git a/include/linux/led-class-flash.h b/include/linux/led-class-flash.h index 21a3358..612b4ca 100644 --- a/include/linux/led-class-flash.h +++ b/include/linux/led-class-flash.h @@ -85,6 +85,7 @@ static inline struct led_classdev_flash *lcdev_to_flcdev( return container_of(lcdev, struct led_classdev_flash, led_cdev); } +#if IS_ENABLED(CONFIG_LEDS_CLASS_FLASH) /** * led_classdev_flash_register_ext - register a new object of LED class with * init data and with support for flash LEDs @@ -98,12 +99,6 @@ int led_classdev_flash_register_ext(struct device *parent, struct led_classdev_flash *fled_cdev, struct led_init_data *init_data); -static inline int led_classdev_flash_register(struct device *parent, - struct led_classdev_flash *fled_cdev) -{ - return led_classdev_flash_register_ext(parent, fled_cdev, NULL); -} - /** * led_classdev_flash_unregister - unregisters an object of led_classdev class *with support for flash LEDs @@ -118,15 +113,44 @@ int devm_led_classdev_flash_register_ext(struct device *parent, struct led_init_data *init_data); +void devm_led_classdev_flash_unregister(struct device *parent, + struct led_classdev_flash *fled_cdev); + +#else + +static inline int led_classdev_flash_register_ext(struct device *parent, + struct led_classdev_flash *fled_cdev, + struct led_init_data *init_data) +{ + return 0; +} + +static inline void led_classdev_flash_unregister(struct led_classdev_flash *fled_cdev) {}; +static inline int devm_led_classdev_flash_register_ext(struct device *parent, +struct led_classdev_flash *fled_cdev, +struct led_init_data *init_data) +{ + return 0; +} + +static inline void devm_led_classdev_flash_unregister(struct device *parent, + struct led_classdev_flash *fled_cdev) +{}; + +#endif /* IS_ENABLED(CONFIG_LEDS_CLASS_FLASH) */ + +static inline int led_classdev_flash_register(struct device *parent, + struct led_classdev_flash *fled_cdev) +{ + return led_classdev_flash_register_ext(parent, fled_cdev, NULL); +} + static inline int devm_led_classdev_flash_register(struct device *parent, struct led_classdev_flash *fled_cdev) { return devm_led_classdev_flash_register_ext(parent, fled_cdev, NULL); } -void devm_led_classdev_flash_unregister(struct device *parent, - struct led_classdev_flash *fled_cdev); - /** * led_set_flash_strobe - setup flash strobe * @fled_cdev: the flash LED to set strobe on -- 2.7.4
Re: [PATCH v7 2/5] dt-bindings: leds: Add LED_COLOR_ID_MOONLIGHT definitions
Jacek Anaszewski 於 2020年11月20日 週五 上午6:26寫道: > > On 11/19/20 10:57 PM, Pavel Machek wrote: > > On Thu 2020-11-19 22:03:14, Jacek Anaszewski wrote: > >> Hi Pavel, Gene, > >> > >> On 11/18/20 10:37 PM, Pavel Machek wrote: > >>> Hi! > >>> > >>>> From: Gene Chen > >>>> > >>>> Add LED_COLOR_ID_MOONLIGHT definitions > >>> > >>> Why is moonlight a color? Camera flashes are usually white, no? > >>> > >>> At least it needs a comment... > >> > >> That's my fault, In fact I should have asked about adding > >> LED_FUNCTION_MOONLIGHT, it was evidently too late for me that evening... > > > > Aha, that makes more sense. > > > > But please let's call it "torch" if we do that, as that is already > > used in kernel sources... and probably in the interface, too: > > I'd say that torch is something different that moonlight, > but we would need more input from Gene to learn more about > the nature of light emitted by ML LED on his device. > > Please note that torch is usually meant as the other mode of > flash LED (sometimes it is called "movie mode"), which is already > handled by brightness file of LED class flash device (i.e. its LED class > subset), and which also maps to v4l2-flash TORCH mode. > It's used to front camera fill light. More brightness than screen backlight, and more soft light than flash. I think LED_ID_COLOR_WHITE is okay. > > ./arch/arm/mach-pxa/ezx.c: .name = "a910::torch", > > > > Best regards, > > Pavel > > > > -- > Best regards, > Jacek Anaszewski
Re: [PATCH v7 1/5] leds: flash: Add flash registration with undefined CONFIG_LEDS_CLASS_FLASH
Jacek Anaszewski 於 2020年11月20日 週五 上午6:29寫道: > > Hi Gene, > > On 11/18/20 11:47 AM, Gene Chen wrote: > > From: Gene Chen > > > > Add flash registration with undefined CONFIG_LEDS_CLASS_FLASH > > > > Signed-off-by: Gene Chen > > --- > > include/linux/led-class-flash.h | 36 > > 1 file changed, 36 insertions(+) > > > > diff --git a/include/linux/led-class-flash.h > > b/include/linux/led-class-flash.h > > index 21a3358..4f56c28 100644 > > --- a/include/linux/led-class-flash.h > > +++ b/include/linux/led-class-flash.h > > @@ -85,6 +85,7 @@ static inline struct led_classdev_flash *lcdev_to_flcdev( > > return container_of(lcdev, struct led_classdev_flash, led_cdev); > > } > > > > +#if IS_ENABLED(CONFIG_LEDS_CLASS_FLASH) > > /** > >* led_classdev_flash_register_ext - register a new object of LED class > > with > >* init data and with support for flash LEDs > > @@ -127,6 +128,41 @@ static inline int > > devm_led_classdev_flash_register(struct device *parent, > > void devm_led_classdev_flash_unregister(struct device *parent, > > struct led_classdev_flash *fled_cdev); > > > > +#else > > + > > +static inline int led_classdev_flash_register_ext(struct device *parent, > > + struct led_classdev_flash *fled_cdev, > > + struct led_init_data *init_data) > > +{ > > + return -EINVAL; > > s/-EINVAL/0/ > > The goal here is to assure that client will not fail when using no-op. > > > +} > > + > > +static inline int led_classdev_flash_register(struct device *parent, > > +struct led_classdev_flash > > *fled_cdev) > > +{ > > + return led_classdev_flash_register_ext(parent, fled_cdev, NULL); > > +} > > This function should be placed after #ifdef block because its > shape is the same for both cases. > > > +static inline void led_classdev_flash_unregister(struct led_classdev_flash > > *fled_cdev) {}; > > +static inline int devm_led_classdev_flash_register_ext(struct device > > *parent, > > + struct led_classdev_flash *fled_cdev, > > + struct led_init_data *init_data) > > +{ > > + return -EINVAL; > > /-EINVAL/0/ > > Please do the same fix in all no-ops in the led-class-multicolor.h, > as we've discussed. > I think return -EINVAL is correct, because I should register flash light device if I define FLED in DTS node. > > +} > > + > > +static inline int devm_led_classdev_flash_register(struct device *parent, > > + struct led_classdev_flash *fled_cdev) > > +{ > > + return devm_led_classdev_flash_register_ext(parent, fled_cdev, NULL); > > +} > > > This function should also be placed after #ifdef block. > Please make the same optimizations in the led-class-multicolor.h as you > are at it. > > > + > > +void devm_led_classdev_flash_unregister(struct device *parent, > > s/void/static inline void/ > > That's the reason why you got warning from buildbot. > ACK > > + struct led_classdev_flash *fled_cdev) > > +{}; > > + > > +#endif /* IS_ENABLED(CONFIG_LEDS_CLASS_FLASH) */ > > + > > /** > >* led_set_flash_strobe - setup flash strobe > >* @fled_cdev: the flash LED to set strobe on > > > > -- > Best regards, > Jacek Anaszewski
[no subject]
>From 66208ef7fcdb4176bf63cd130b3e3197086ac4b3 Mon Sep 17 00:00:00 2001 From: Gene Chen Date: Thu, 22 Aug 2019 14:21:03 +0800 Subject: [PATCH] mfd: mt6360: add pmic mt6360 driver --- drivers/mfd/Kconfig | 12 ++ drivers/mfd/Makefile | 1 + drivers/mfd/mt6360-core.c | 463 ++ 3 files changed, 476 insertions(+) create mode 100644 drivers/mfd/mt6360-core.c diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig index f129f96..a422c76 100644 --- a/drivers/mfd/Kconfig +++ b/drivers/mfd/Kconfig @@ -862,6 +862,18 @@ config MFD_MAX8998 additional drivers must be enabled in order to use the functionality of the device. +config MFD_MT6360 + tristate "Mediatek MT6360 SubPMIC" + select MFD_CORE + select REGMAP_I2C + select REGMAP_IRQ + depends on I2C + help + Say Y here to enable MT6360 PMU/PMIC/LDO functional support. + PMU part include charger, flashlight, rgb led + PMIC part include 2-channel BUCKs and 2-channel LDOs + LDO part include 4-channel LDOs + config MFD_MT6397 tristate "MediaTek MT6397 PMIC Support" select MFD_CORE diff --git a/drivers/mfd/Makefile b/drivers/mfd/Makefile index f026ada..77a8f0b 100644 --- a/drivers/mfd/Makefile +++ b/drivers/mfd/Makefile @@ -241,6 +241,7 @@ 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_MT6360) += mt6360-core.o obj-$(CONFIG_MFD_MT6397) += mt6397-core.o obj-$(CONFIG_MFD_ALTERA_A10SR) += altera-a10sr.o diff --git a/drivers/mfd/mt6360-core.c b/drivers/mfd/mt6360-core.c new file mode 100644 index 000..d3580618 --- /dev/null +++ b/drivers/mfd/mt6360-core.c @@ -0,0 +1,463 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Copyright (c) 2019 MediaTek Inc. + */ + +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +/* reg 0 -> 0 ~ 7 */ +#define MT6360_CHG_TREG_EVT(4) +#define MT6360_CHG_AICR_EVT(5) +#define MT6360_CHG_MIVR_EVT(6) +#define MT6360_PWR_RDY_EVT (7) +/* REG 1 -> 8 ~ 15 */ +#define MT6360_CHG_BATSYSUV_EVT(9) +#define MT6360_FLED_CHG_VINOVP_EVT (11) +#define MT6360_CHG_VSYSUV_EVT (12) +#define MT6360_CHG_VSYSOV_EVT (13) +#define MT6360_CHG_VBATOV_EVT (14) +#define MT6360_CHG_VBUSOV_EVT (15) +/* REG 2 -> 16 ~ 23 */ +/* REG 3 -> 24 ~ 31 */ +#define MT6360_WD_PMU_DET (25) +#define MT6360_WD_PMU_DONE (26) +#define MT6360_CHG_TMRI(27) +#define MT6360_CHG_ADPBADI (29) +#define MT6360_CHG_RVPI(30) +#define MT6360_OTPI(31) +/* REG 4 -> 32 ~ 39 */ +#define MT6360_CHG_AICCMEASL (32) +#define MT6360_CHGDET_DONEI(34) +#define MT6360_WDTMRI (35) +#define MT6360_SSFINISHI (36) +#define MT6360_CHG_RECHGI (37) +#define MT6360_CHG_TERMI (38) +#define MT6360_CHG_IEOCI (39) +/* REG 5 -> 40 ~ 47 */ +#define MT6360_PUMPX_DONEI (40) +#define MT6360_BAT_OVP_ADC_EVT (41) +#define MT6360_TYPEC_OTP_EVT (42) +#define MT6360_ADC_WAKEUP_EVT (43) +#define MT6360_ADC_DONEI (44) +#define MT6360_BST_BATUVI (45) +#define MT6360_BST_VBUSOVI (46) +#define MT6360_BST_OLPI(47) +/* REG 6 -> 48 ~ 55 */ +#define MT6360_ATTACH_I(48) +#define MT6360_DETACH_I(49) +#define MT6360_QC30_STPDONE(51) +#define MT6360_QC_VBUSDET_DONE (52) +#define MT6360_HVDCP_DET (53) +#define MT6360_CHGDETI (54) +#define MT6360_DCDTI (55) +/* REG 7 -> 56 ~ 63 */ +#define MT6360_FOD_DONE_EVT(56) +#define MT6360_FOD_OV_EVT (57) +#define MT6360_CHRDET_UVP_EVT (58) +#define MT6360_CHRDET_OVP_EVT (59) +#define MT6360_CHRDET_EXT_EVT (60) +#define MT6360_FOD_LR_EVT (61) +#define MT6360_FOD_HR_EVT (62) +#define MT6360_FOD_DISCHG_FAIL_EVT (63) +/* REG 8 -> 64 ~ 71 */ +#define MT6360_USBID_EVT (64) +#define MT6360_APWDTRST_EVT(65) +#define MT6360_EN_EVT (66) +#define MT6360_QONB_RST_EVT(67) +#define MT6360_MRSTB_EVT (68) +#define MT6360_OTP_EVT (69) +#define MT6360_VDDAOV_EVT (70) +#define MT6360_SYSUV_EVT (71) +/* REG 9 -> 72 ~ 79 */ +#define MT6360_FLED_STRBPIN_EVT(72) +#define MT6360_FLED_TORPIN_EVT
[PATCH] mfd: mt6360: add pmic mt6360 driver
From: Gene Chen --- drivers/mfd/Kconfig | 12 ++ drivers/mfd/Makefile | 1 + drivers/mfd/mt6360-core.c | 463 ++ 3 files changed, 476 insertions(+) create mode 100644 drivers/mfd/mt6360-core.c diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig index f129f96..a422c76 100644 --- a/drivers/mfd/Kconfig +++ b/drivers/mfd/Kconfig @@ -862,6 +862,18 @@ config MFD_MAX8998 additional drivers must be enabled in order to use the functionality of the device. +config MFD_MT6360 + tristate "Mediatek MT6360 SubPMIC" + select MFD_CORE + select REGMAP_I2C + select REGMAP_IRQ + depends on I2C + help + Say Y here to enable MT6360 PMU/PMIC/LDO functional support. + PMU part include charger, flashlight, rgb led + PMIC part include 2-channel BUCKs and 2-channel LDOs + LDO part include 4-channel LDOs + config MFD_MT6397 tristate "MediaTek MT6397 PMIC Support" select MFD_CORE diff --git a/drivers/mfd/Makefile b/drivers/mfd/Makefile index f026ada..77a8f0b 100644 --- a/drivers/mfd/Makefile +++ b/drivers/mfd/Makefile @@ -241,6 +241,7 @@ 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_MT6360) += mt6360-core.o obj-$(CONFIG_MFD_MT6397) += mt6397-core.o obj-$(CONFIG_MFD_ALTERA_A10SR) += altera-a10sr.o diff --git a/drivers/mfd/mt6360-core.c b/drivers/mfd/mt6360-core.c new file mode 100644 index 000..d3580618 --- /dev/null +++ b/drivers/mfd/mt6360-core.c @@ -0,0 +1,463 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Copyright (c) 2019 MediaTek Inc. + */ + +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +/* reg 0 -> 0 ~ 7 */ +#define MT6360_CHG_TREG_EVT(4) +#define MT6360_CHG_AICR_EVT(5) +#define MT6360_CHG_MIVR_EVT(6) +#define MT6360_PWR_RDY_EVT (7) +/* REG 1 -> 8 ~ 15 */ +#define MT6360_CHG_BATSYSUV_EVT(9) +#define MT6360_FLED_CHG_VINOVP_EVT (11) +#define MT6360_CHG_VSYSUV_EVT (12) +#define MT6360_CHG_VSYSOV_EVT (13) +#define MT6360_CHG_VBATOV_EVT (14) +#define MT6360_CHG_VBUSOV_EVT (15) +/* REG 2 -> 16 ~ 23 */ +/* REG 3 -> 24 ~ 31 */ +#define MT6360_WD_PMU_DET (25) +#define MT6360_WD_PMU_DONE (26) +#define MT6360_CHG_TMRI(27) +#define MT6360_CHG_ADPBADI (29) +#define MT6360_CHG_RVPI(30) +#define MT6360_OTPI(31) +/* REG 4 -> 32 ~ 39 */ +#define MT6360_CHG_AICCMEASL (32) +#define MT6360_CHGDET_DONEI(34) +#define MT6360_WDTMRI (35) +#define MT6360_SSFINISHI (36) +#define MT6360_CHG_RECHGI (37) +#define MT6360_CHG_TERMI (38) +#define MT6360_CHG_IEOCI (39) +/* REG 5 -> 40 ~ 47 */ +#define MT6360_PUMPX_DONEI (40) +#define MT6360_BAT_OVP_ADC_EVT (41) +#define MT6360_TYPEC_OTP_EVT (42) +#define MT6360_ADC_WAKEUP_EVT (43) +#define MT6360_ADC_DONEI (44) +#define MT6360_BST_BATUVI (45) +#define MT6360_BST_VBUSOVI (46) +#define MT6360_BST_OLPI(47) +/* REG 6 -> 48 ~ 55 */ +#define MT6360_ATTACH_I(48) +#define MT6360_DETACH_I(49) +#define MT6360_QC30_STPDONE(51) +#define MT6360_QC_VBUSDET_DONE (52) +#define MT6360_HVDCP_DET (53) +#define MT6360_CHGDETI (54) +#define MT6360_DCDTI (55) +/* REG 7 -> 56 ~ 63 */ +#define MT6360_FOD_DONE_EVT(56) +#define MT6360_FOD_OV_EVT (57) +#define MT6360_CHRDET_UVP_EVT (58) +#define MT6360_CHRDET_OVP_EVT (59) +#define MT6360_CHRDET_EXT_EVT (60) +#define MT6360_FOD_LR_EVT (61) +#define MT6360_FOD_HR_EVT (62) +#define MT6360_FOD_DISCHG_FAIL_EVT (63) +/* REG 8 -> 64 ~ 71 */ +#define MT6360_USBID_EVT (64) +#define MT6360_APWDTRST_EVT(65) +#define MT6360_EN_EVT (66) +#define MT6360_QONB_RST_EVT(67) +#define MT6360_MRSTB_EVT (68) +#define MT6360_OTP_EVT (69) +#define MT6360_VDDAOV_EVT (70) +#define MT6360_SYSUV_EVT (71) +/* REG 9 -> 72 ~ 79 */ +#define MT6360_FLED_STRBPIN_EVT(72) +#define MT6360_FLED_TORPIN_EVT (73) +#define MT6360_FLED_TX_EVT (74) +#define MT6360_FLED_LVF_EVT(75) +#define MT6360_FLED2_SHORT_EVT (78) +#define MT6360_
[PATCH] mfd: mt6360: add pmic mt6360 driver
From: Gene Chen Add mfd driver for mt6360 pmic chip include Battery Charger/USB_PD/Flash LED/RGB LED/LDO/Buck Signed-off-by: Gene Chen --- drivers/mfd/Kconfig | 12 ++ drivers/mfd/Makefile | 1 + drivers/mfd/mt6360-core.c | 463 ++ 3 files changed, 476 insertions(+) create mode 100644 drivers/mfd/mt6360-core.c diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig index f129f96..a422c76 100644 --- a/drivers/mfd/Kconfig +++ b/drivers/mfd/Kconfig @@ -862,6 +862,18 @@ config MFD_MAX8998 additional drivers must be enabled in order to use the functionality of the device. +config MFD_MT6360 + tristate "Mediatek MT6360 SubPMIC" + select MFD_CORE + select REGMAP_I2C + select REGMAP_IRQ + depends on I2C + help + Say Y here to enable MT6360 PMU/PMIC/LDO functional support. + PMU part include charger, flashlight, rgb led + PMIC part include 2-channel BUCKs and 2-channel LDOs + LDO part include 4-channel LDOs + config MFD_MT6397 tristate "MediaTek MT6397 PMIC Support" select MFD_CORE diff --git a/drivers/mfd/Makefile b/drivers/mfd/Makefile index f026ada..77a8f0b 100644 --- a/drivers/mfd/Makefile +++ b/drivers/mfd/Makefile @@ -241,6 +241,7 @@ 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_MT6360) += mt6360-core.o obj-$(CONFIG_MFD_MT6397) += mt6397-core.o obj-$(CONFIG_MFD_ALTERA_A10SR) += altera-a10sr.o diff --git a/drivers/mfd/mt6360-core.c b/drivers/mfd/mt6360-core.c new file mode 100644 index 000..d3580618 --- /dev/null +++ b/drivers/mfd/mt6360-core.c @@ -0,0 +1,463 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Copyright (c) 2019 MediaTek Inc. + */ + +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +/* reg 0 -> 0 ~ 7 */ +#define MT6360_CHG_TREG_EVT(4) +#define MT6360_CHG_AICR_EVT(5) +#define MT6360_CHG_MIVR_EVT(6) +#define MT6360_PWR_RDY_EVT (7) +/* REG 1 -> 8 ~ 15 */ +#define MT6360_CHG_BATSYSUV_EVT(9) +#define MT6360_FLED_CHG_VINOVP_EVT (11) +#define MT6360_CHG_VSYSUV_EVT (12) +#define MT6360_CHG_VSYSOV_EVT (13) +#define MT6360_CHG_VBATOV_EVT (14) +#define MT6360_CHG_VBUSOV_EVT (15) +/* REG 2 -> 16 ~ 23 */ +/* REG 3 -> 24 ~ 31 */ +#define MT6360_WD_PMU_DET (25) +#define MT6360_WD_PMU_DONE (26) +#define MT6360_CHG_TMRI(27) +#define MT6360_CHG_ADPBADI (29) +#define MT6360_CHG_RVPI(30) +#define MT6360_OTPI(31) +/* REG 4 -> 32 ~ 39 */ +#define MT6360_CHG_AICCMEASL (32) +#define MT6360_CHGDET_DONEI(34) +#define MT6360_WDTMRI (35) +#define MT6360_SSFINISHI (36) +#define MT6360_CHG_RECHGI (37) +#define MT6360_CHG_TERMI (38) +#define MT6360_CHG_IEOCI (39) +/* REG 5 -> 40 ~ 47 */ +#define MT6360_PUMPX_DONEI (40) +#define MT6360_BAT_OVP_ADC_EVT (41) +#define MT6360_TYPEC_OTP_EVT (42) +#define MT6360_ADC_WAKEUP_EVT (43) +#define MT6360_ADC_DONEI (44) +#define MT6360_BST_BATUVI (45) +#define MT6360_BST_VBUSOVI (46) +#define MT6360_BST_OLPI(47) +/* REG 6 -> 48 ~ 55 */ +#define MT6360_ATTACH_I(48) +#define MT6360_DETACH_I(49) +#define MT6360_QC30_STPDONE(51) +#define MT6360_QC_VBUSDET_DONE (52) +#define MT6360_HVDCP_DET (53) +#define MT6360_CHGDETI (54) +#define MT6360_DCDTI (55) +/* REG 7 -> 56 ~ 63 */ +#define MT6360_FOD_DONE_EVT(56) +#define MT6360_FOD_OV_EVT (57) +#define MT6360_CHRDET_UVP_EVT (58) +#define MT6360_CHRDET_OVP_EVT (59) +#define MT6360_CHRDET_EXT_EVT (60) +#define MT6360_FOD_LR_EVT (61) +#define MT6360_FOD_HR_EVT (62) +#define MT6360_FOD_DISCHG_FAIL_EVT (63) +/* REG 8 -> 64 ~ 71 */ +#define MT6360_USBID_EVT (64) +#define MT6360_APWDTRST_EVT(65) +#define MT6360_EN_EVT (66) +#define MT6360_QONB_RST_EVT(67) +#define MT6360_MRSTB_EVT (68) +#define MT6360_OTP_EVT (69) +#define MT6360_VDDAOV_EVT (70) +#define MT6360_SYSUV_EVT (71) +/* REG 9 -> 72 ~ 79 */ +#define MT6360_FLED_STRBPIN_EVT(72) +#define MT6360_FLED_TORPIN_EVT (73) +#define MT6360_FLED_TX_EVT
[PATCH] mfd: mt6360: add pmic mt6360 driver
From: Gene Chen Add mfd driver for mt6360 pmic chip include Battery Charger/USB_PD/Flash LED/RGB LED/LDO/Buck Signed-off-by: Gene Chen +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +/* reg 0 -> 0 ~ 7 */ +#define MT6360_CHG_TREG_EVT(4) +#define MT6360_CHG_AICR_EVT(5) +#define MT6360_CHG_MIVR_EVT(6) +#define MT6360_PWR_RDY_EVT (7) +/* REG 1 -> 8 ~ 15 */ +#define MT6360_CHG_BATSYSUV_EVT(9) +#define MT6360_FLED_CHG_VINOVP_EVT (11) +#define MT6360_CHG_VSYSUV_EVT (12) +#define MT6360_CHG_VSYSOV_EVT (13) +#define MT6360_CHG_VBATOV_EVT (14) +#define MT6360_CHG_VBUSOV_EVT (15) +/* REG 2 -> 16 ~ 23 */ +/* REG 3 -> 24 ~ 31 */ +#define MT6360_WD_PMU_DET (25) +#define MT6360_WD_PMU_DONE (26) +#define MT6360_CHG_TMRI(27) +#define MT6360_CHG_ADPBADI (29) +#define MT6360_CHG_RVPI(30) +#define MT6360_OTPI(31) +/* REG 4 -> 32 ~ 39 */ +#define MT6360_CHG_AICCMEASL (32) +#define MT6360_CHGDET_DONEI(34) +#define MT6360_WDTMRI (35) +#define MT6360_SSFINISHI (36) +#define MT6360_CHG_RECHGI (37) +#define MT6360_CHG_TERMI (38) +#define MT6360_CHG_IEOCI (39) +/* REG 5 -> 40 ~ 47 */ +#define MT6360_PUMPX_DONEI (40) +#define MT6360_BAT_OVP_ADC_EVT (41) +#define MT6360_TYPEC_OTP_EVT (42) +#define MT6360_ADC_WAKEUP_EVT (43) +#define MT6360_ADC_DONEI (44) +#define MT6360_BST_BATUVI (45) +#define MT6360_BST_VBUSOVI (46) +#define MT6360_BST_OLPI(47) +/* REG 6 -> 48 ~ 55 */ +#define MT6360_ATTACH_I(48) +#define MT6360_DETACH_I(49) +#define MT6360_QC30_STPDONE(51) +#define MT6360_QC_VBUSDET_DONE (52) +#define MT6360_HVDCP_DET (53) +#define MT6360_CHGDETI (54) +#define MT6360_DCDTI (55) +/* REG 7 -> 56 ~ 63 */ +#define MT6360_FOD_DONE_EVT(56) +#define MT6360_FOD_OV_EVT (57) +#define MT6360_CHRDET_UVP_EVT (58) +#define MT6360_CHRDET_OVP_EVT (59) +#define MT6360_CHRDET_EXT_EVT (60) +#define MT6360_FOD_LR_EVT (61) +#define MT6360_FOD_HR_EVT (62) +#define MT6360_FOD_DISCHG_FAIL_EVT (63) +/* REG 8 -> 64 ~ 71 */ +#define MT6360_USBID_EVT (64) +#define MT6360_APWDTRST_EVT(65) +#define MT6360_EN_EVT (66) +#define MT6360_QONB_RST_EVT(67) +#define MT6360_MRSTB_EVT (68) +#define MT6360_OTP_EVT (69) +#define MT6360_VDDAOV_EVT (70) +#define MT6360_SYSUV_EVT (71) +/* REG 9 -> 72 ~ 79 */ +#define MT6360_FLED_STRBPIN_EVT(72) +#define MT6360_FLED_TORPIN_EVT (73) +#define MT6360_FLED_TX_EVT (74) +#define MT6360_FLED_LVF_EVT(75) +#define MT6360_FLED2_SHORT_EVT (78) +#define MT6360_FLED1_SHORT_EVT (79) +/* REG 10 -> 80 ~ 87 */ +#define MT6360_FLED2_STRB_EVT (80) +#define MT6360_FLED1_STRB_EVT (81) +#define MT6360_FLED2_STRB_TO_EVT (82) +#define MT6360_FLED1_STRB_TO_EVT (83) +#define MT6360_FLED2_TOR_EVT (84) +#define MT6360_FLED1_TOR_EVT (85) +/* REG 11 -> 88 ~ 95 */ +/* REG 12 -> 96 ~ 103 */ +#define MT6360_BUCK1_PGB_EVT (96) +#define MT6360_BUCK1_OC_EVT(100) +#define MT6360_BUCK1_OV_EVT(101) +#define MT6360_BUCK1_UV_EVT(102) +/* REG 13 -> 104 ~ 111 */ +#define MT6360_BUCK2_PGB_EVT (104) +#define MT6360_BUCK2_OC_EVT(108) +#define MT6360_BUCK2_OV_EVT(109) +#define MT6360_BUCK2_UV_EVT(110) +/* REG 14 -> 112 ~ 119 */ +#define MT6360_LDO1_OC_EVT (113) +#define MT6360_LDO2_OC_EVT (114) +#define MT6360_LDO3_OC_EVT (115) +#define MT6360_LDO5_OC_EVT (117) +#define MT6360_LDO6_OC_EVT (118) +#define MT6360_LDO7_OC_EVT (119) +/* REG 15 -> 120 ~ 127 */ +#define MT6360_LDO1_PGB_EVT(121) +#define MT6360_LDO2_PGB_EVT(122) +#define MT6360_LDO3_PGB_EVT(123) +#define MT6360_LDO5_PGB_EVT(125) +#define MT6360_LDO6_PGB_EVT(126) +#define MT6360_LDO7_PGB_EVT(127) + +#define MT6360_REGMAP_IRQ_REG(_irq_evt)\ + REGMAP_IRQ_REG(_irq_evt, (_irq_evt) / 8, BIT((_irq_evt) % 8)) + +#define MT6360_MFD_CELL(_name) \ + { \ + .name = #_name, \ +
Re: [PATCH v3] mfd: mt6360: add pmic mt6360 driver
Hi Jones, Thanks for review, we will fix some comment which your suggestion in next patch Lee Jones 於 2019年10月4日 週五 下午9:33寫道: > > Wolfram, > > Would you be kind enough to grep for your name below? > > On Tue, 24 Sep 2019, Gene Chen wrote: > > > From: Gene Chen > > > > Add mfd driver for mt6360 pmic chip include > > Battery Charger/USB_PD/Flash LED/RGB LED/LDO/Buck > > > > Signed-off-by: Gene Chen > --- > > drivers/mfd/Kconfig| 12 + > > drivers/mfd/Makefile | 1 + > > drivers/mfd/mt6360-core.c | 463 > > + > > include/linux/mfd/mt6360-private.h | 279 ++ > > include/linux/mfd/mt6360.h | 33 +++ > > 5 files changed, 788 insertions(+) > > create mode 100644 drivers/mfd/mt6360-core.c > > create mode 100644 include/linux/mfd/mt6360-private.h > > create mode 100644 include/linux/mfd/mt6360.h > > > > changelogs between v1 & v2 > > - include missing header file > > > > changelogs between v2 & v3 > > - add changelogs > > > > diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig > > index f129f96..a422c76 100644 > > --- a/drivers/mfd/Kconfig > > +++ b/drivers/mfd/Kconfig > > @@ -862,6 +862,18 @@ config MFD_MAX8998 > > additional drivers must be enabled in order to use the functionality > > of the device. > > > > +config MFD_MT6360 > > + tristate "Mediatek MT6360 SubPMIC" > > + select MFD_CORE > > + select REGMAP_I2C > > + select REGMAP_IRQ > > + depends on I2C > > + help > > + Say Y here to enable MT6360 PMU/PMIC/LDO functional support. > > + PMU part include charger, flashlight, rgb led > > + PMIC part include 2-channel BUCKs and 2-channel LDOs > > + LDO part include 4-channel LDOs > > PMU part includes Charger, Flashlight, RGB and LED > PMIC part includes 2-channel BUCKs and 2-channel LDOs > LDO part includes 4-channel LDOs > ACK. RGB LED is one of indicator light, only single feature > > config MFD_MT6397 > > tristate "MediaTek MT6397 PMIC Support" > > select MFD_CORE > > diff --git a/drivers/mfd/Makefile b/drivers/mfd/Makefile > > index f026ada..77a8f0b 100644 > > --- a/drivers/mfd/Makefile > > +++ b/drivers/mfd/Makefile > > @@ -241,6 +241,7 @@ 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_MT6360) += mt6360-core.o > > obj-$(CONFIG_MFD_MT6397) += mt6397-core.o > > > > obj-$(CONFIG_MFD_ALTERA_A10SR) += altera-a10sr.o > > diff --git a/drivers/mfd/mt6360-core.c b/drivers/mfd/mt6360-core.c > > new file mode 100644 > > index 000..d3580618 > > --- /dev/null > > +++ b/drivers/mfd/mt6360-core.c > > @@ -0,0 +1,463 @@ > > +// SPDX-License-Identifier: GPL-2.0 > > +/* > > + * Copyright (c) 2019 MediaTek Inc. > > + */ > > + > > +#include > > +#include > > +#include > > +#include > > +#include > > +#include > > +#include > > +#include > > + > > +#include > > +#include > > + > > +/* reg 0 -> 0 ~ 7 */ > > +#define MT6360_CHG_TREG_EVT (4) > > +#define MT6360_CHG_AICR_EVT (5) > > +#define MT6360_CHG_MIVR_EVT (6) > > +#define MT6360_PWR_RDY_EVT (7) > > +/* REG 1 -> 8 ~ 15 */ > > +#define MT6360_CHG_BATSYSUV_EVT (9) > > +#define MT6360_FLED_CHG_VINOVP_EVT (11) > > +#define MT6360_CHG_VSYSUV_EVT(12) > > +#define MT6360_CHG_VSYSOV_EVT(13) > > +#define MT6360_CHG_VBATOV_EVT(14) > > +#define MT6360_CHG_VBUSOV_EVT(15) > > +/* REG 2 -> 16 ~ 23 */ > > +/* REG 3 -> 24 ~ 31 */ > > +#define MT6360_WD_PMU_DET(25) > > +#define MT6360_WD_PMU_DONE (26) > > +#define MT6360_CHG_TMRI (27) > > +#define MT6360_CHG_ADPBADI (29) > > +#define MT6360_CHG_RVPI (30) > > +#define MT6360_OTPI (31) > > +/* REG 4 -> 32 ~ 39 */ > > +#define MT6360_CHG_AICCMEASL (32) > > +#define MT6360_CHGDET_DONEI (34) > > +#define MT6360_WDTMRI
Re: [PATCH] mfd: mt6360: add pmic mt6360 driver
Lee Jones 於 2019年9月18日 週三 下午6:51寫道: > > On Wed, 18 Sep 2019, Gene Chen wrote: > > > From: Gene Chen > > > > Add mfd driver for mt6360 pmic chip include > > Battery Charger/USB_PD/Flash LED/RGB LED/LDO/Buck > > > > Signed-off-by: Gene Chen > --- > > This looks different from the one you sent before, but I don't see a > version bump or any changelog in this space. Please re-submit with > the differences noted. > the change is 1. add missing include file 2. modify commit message this patch is regarded as version 1 > > drivers/mfd/Kconfig| 12 + > > drivers/mfd/Makefile | 1 + > > drivers/mfd/mt6360-core.c | 463 > > + > > include/linux/mfd/mt6360-private.h | 279 ++ > > include/linux/mfd/mt6360.h | 33 +++ > > 5 files changed, 788 insertions(+) > > create mode 100644 drivers/mfd/mt6360-core.c > > create mode 100644 include/linux/mfd/mt6360-private.h > > create mode 100644 include/linux/mfd/mt6360.h > > -- > Lee Jones [李琼斯] > Linaro Services Technical Lead > Linaro.org │ Open source software for ARM SoCs > Follow Linaro: Facebook | Twitter | Blog
[PATCH v3] mfd: mt6360: add pmic mt6360 driver
From: Gene Chen Add mfd driver for mt6360 pmic chip include Battery Charger/USB_PD/Flash LED/RGB LED/LDO/Buck Signed-off-by: Gene Chen +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +/* reg 0 -> 0 ~ 7 */ +#define MT6360_CHG_TREG_EVT(4) +#define MT6360_CHG_AICR_EVT(5) +#define MT6360_CHG_MIVR_EVT(6) +#define MT6360_PWR_RDY_EVT (7) +/* REG 1 -> 8 ~ 15 */ +#define MT6360_CHG_BATSYSUV_EVT(9) +#define MT6360_FLED_CHG_VINOVP_EVT (11) +#define MT6360_CHG_VSYSUV_EVT (12) +#define MT6360_CHG_VSYSOV_EVT (13) +#define MT6360_CHG_VBATOV_EVT (14) +#define MT6360_CHG_VBUSOV_EVT (15) +/* REG 2 -> 16 ~ 23 */ +/* REG 3 -> 24 ~ 31 */ +#define MT6360_WD_PMU_DET (25) +#define MT6360_WD_PMU_DONE (26) +#define MT6360_CHG_TMRI(27) +#define MT6360_CHG_ADPBADI (29) +#define MT6360_CHG_RVPI(30) +#define MT6360_OTPI(31) +/* REG 4 -> 32 ~ 39 */ +#define MT6360_CHG_AICCMEASL (32) +#define MT6360_CHGDET_DONEI(34) +#define MT6360_WDTMRI (35) +#define MT6360_SSFINISHI (36) +#define MT6360_CHG_RECHGI (37) +#define MT6360_CHG_TERMI (38) +#define MT6360_CHG_IEOCI (39) +/* REG 5 -> 40 ~ 47 */ +#define MT6360_PUMPX_DONEI (40) +#define MT6360_BAT_OVP_ADC_EVT (41) +#define MT6360_TYPEC_OTP_EVT (42) +#define MT6360_ADC_WAKEUP_EVT (43) +#define MT6360_ADC_DONEI (44) +#define MT6360_BST_BATUVI (45) +#define MT6360_BST_VBUSOVI (46) +#define MT6360_BST_OLPI(47) +/* REG 6 -> 48 ~ 55 */ +#define MT6360_ATTACH_I(48) +#define MT6360_DETACH_I(49) +#define MT6360_QC30_STPDONE(51) +#define MT6360_QC_VBUSDET_DONE (52) +#define MT6360_HVDCP_DET (53) +#define MT6360_CHGDETI (54) +#define MT6360_DCDTI (55) +/* REG 7 -> 56 ~ 63 */ +#define MT6360_FOD_DONE_EVT(56) +#define MT6360_FOD_OV_EVT (57) +#define MT6360_CHRDET_UVP_EVT (58) +#define MT6360_CHRDET_OVP_EVT (59) +#define MT6360_CHRDET_EXT_EVT (60) +#define MT6360_FOD_LR_EVT (61) +#define MT6360_FOD_HR_EVT (62) +#define MT6360_FOD_DISCHG_FAIL_EVT (63) +/* REG 8 -> 64 ~ 71 */ +#define MT6360_USBID_EVT (64) +#define MT6360_APWDTRST_EVT(65) +#define MT6360_EN_EVT (66) +#define MT6360_QONB_RST_EVT(67) +#define MT6360_MRSTB_EVT (68) +#define MT6360_OTP_EVT (69) +#define MT6360_VDDAOV_EVT (70) +#define MT6360_SYSUV_EVT (71) +/* REG 9 -> 72 ~ 79 */ +#define MT6360_FLED_STRBPIN_EVT(72) +#define MT6360_FLED_TORPIN_EVT (73) +#define MT6360_FLED_TX_EVT (74) +#define MT6360_FLED_LVF_EVT(75) +#define MT6360_FLED2_SHORT_EVT (78) +#define MT6360_FLED1_SHORT_EVT (79) +/* REG 10 -> 80 ~ 87 */ +#define MT6360_FLED2_STRB_EVT (80) +#define MT6360_FLED1_STRB_EVT (81) +#define MT6360_FLED2_STRB_TO_EVT (82) +#define MT6360_FLED1_STRB_TO_EVT (83) +#define MT6360_FLED2_TOR_EVT (84) +#define MT6360_FLED1_TOR_EVT (85) +/* REG 11 -> 88 ~ 95 */ +/* REG 12 -> 96 ~ 103 */ +#define MT6360_BUCK1_PGB_EVT (96) +#define MT6360_BUCK1_OC_EVT(100) +#define MT6360_BUCK1_OV_EVT(101) +#define MT6360_BUCK1_UV_EVT(102) +/* REG 13 -> 104 ~ 111 */ +#define MT6360_BUCK2_PGB_EVT (104) +#define MT6360_BUCK2_OC_EVT(108) +#define MT6360_BUCK2_OV_EVT(109) +#define MT6360_BUCK2_UV_EVT(110) +/* REG 14 -> 112 ~ 119 */ +#define MT6360_LDO1_OC_EVT (113) +#define MT6360_LDO2_OC_EVT (114) +#define MT6360_LDO3_OC_EVT (115) +#define MT6360_LDO5_OC_EVT (117) +#define MT6360_LDO6_OC_EVT (118) +#define MT6360_LDO7_OC_EVT (119) +/* REG 15 -> 120 ~ 127 */ +#define MT6360_LDO1_PGB_EVT(121) +#define MT6360_LDO2_PGB_EVT(122) +#define MT6360_LDO3_PGB_EVT(123) +#define MT6360_LDO5_PGB_EVT(125) +#define MT6360_LDO6_PGB_EVT(126) +#define MT6360_LDO7_PGB_EVT(127) + +#define MT6360_REGMAP_IRQ_REG(_irq_evt)\ + REGMAP_IRQ_REG(_irq_evt, (_irq_evt) / 8, BIT((_irq_evt) % 8)) + +#define MT6360_MFD_CELL(_name) \ + { \ + .name = #_name, \ +
Re: [PATCH] mfd: mt6360: add pmic mt6360 driver
2019-09-19 15:18 GMT+08:00, Lee Jones : > On Thu, 19 Sep 2019, Gene Chen wrote: > >> Lee Jones 於 2019年9月18日 週三 下午6:51寫道: >> > >> > On Wed, 18 Sep 2019, Gene Chen wrote: >> > >> > > From: Gene Chen >> > > >> > > Add mfd driver for mt6360 pmic chip include >> > > Battery Charger/USB_PD/Flash LED/RGB LED/LDO/Buck >> > > >> > > Signed-off-by: Gene Chen > > > --- >> > >> > This looks different from the one you sent before, but I don't see a >> > version bump or any changelog in this space. Please re-submit with >> > the differences noted. >> > >> >> the change is >> 1. add missing include file >> 2. modify commit message >> >> this patch is regarded as version 1 > > It's different to the first one you sent to the list, so it needs a > version bump and a change log. There also appears to still be issues > with it, if the auto-builders are to be believed. > > Do ensure you thoroughly test your patches before sending upstream. > > Please fix the issues and resubmit your v3 with a nice changelog. > thank you for suggestion may i ask how to disable kbuild test reboot for s390/x86_64/ia64? we want support only cross compiler = aarch64-linux-gnu- and we have test build pass with our patch >> > > drivers/mfd/Kconfig| 12 + >> > > drivers/mfd/Makefile | 1 + >> > > drivers/mfd/mt6360-core.c | 463 >> > > + >> > > include/linux/mfd/mt6360-private.h | 279 ++ >> > > include/linux/mfd/mt6360.h | 33 +++ >> > > 5 files changed, 788 insertions(+) >> > > create mode 100644 drivers/mfd/mt6360-core.c >> > > create mode 100644 include/linux/mfd/mt6360-private.h >> > > create mode 100644 include/linux/mfd/mt6360.h >> > > > -- > Lee Jones [李琼斯] > Linaro Services Technical Lead > Linaro.org │ Open source software for ARM SoCs > Follow Linaro: Facebook | Twitter | Blog >