Skip to contentSkip to conversation

Add Mediatek MT6370 PMIC support

PATCH Superseded ChiaEn Wu 6 participants 28 messages May 31, 2022 – Jun 2, 2022

Subsystems (12)
lore
Share & tools
lore

ChiaEn Wu

author
#0 lore raw

cover Add Mediatek MT6370 PMIC support

From: ChiaEn Wu <[email protected]>

This patch series add Mediatek MT6370 PMIC support. The MT6370 is a highly-integrated smart power management IC, which includes a single cell Li-Ion/Li-Polymer switching battery charger, a USB
Type-C & Power Delivery (PD) controller, dual Flash LED current sources, a RGB LED driver, a backlight WLED driver, a display bias driver and a general LDO for portable devices.

Alice Chen (3):
leds: mt6370: Add Mediatek MT6370 Indicator support
leds: flashlight: mt6370: Add Mediatek MT6370 flashlight support
dt-bindings: leds: Add Mediatek MT6370 flashlight binding
documentation

ChiYuan Huang (7):
mfd: mt6370: Add Mediatek MT6370 support
usb: typec: tcpci_mt6370: Add Mediatek MT6370 tcpci driver
regulator: mt6370: Add mt6370 DisplayBias and VibLDO support
dt-bindings: usb: Add Mediatek MT6370 TCPC binding documentation
dt-bindings: leds: mt6370: Add Mediatek mt6370 indicator documentation
dt-bindings: backlight: Add Mediatek MT6370 backlight binding
documentation
dt-bindings: mfd: Add Mediatek MT6370 binding documentation

ChiaEn Wu (4):
iio: adc: mt6370: Add Mediatek MT6370 support
power: supply: mt6370: Add Mediatek MT6370 charger driver
video: backlight: mt6370: Add Mediatek MT6370 support
dt-bindings: power: supply: Add Mediatek MT6370 Charger binding
documentation

 .../backlight/mediatek,mt6370-backlight.yaml  |  110 ++
 .../leds/mediatek,mt6370-flashlight.yaml      |   48 +
 .../leds/mediatek,mt6370-indicator.yaml       |   57 +
 .../bindings/mfd/mediatek,mt6370.yaml         |  282 ++++
 .../power/supply/mediatek,mt6370-charger.yaml |   60 +
 .../bindings/usb/mediatek,mt6370-tcpc.yaml    |   35 +
 drivers/iio/adc/Kconfig                       |    9 +
 drivers/iio/adc/Makefile                      |    1 +
 drivers/iio/adc/mt6370-adc.c                  |  257 ++++
 drivers/leds/Kconfig                          |   11 +
 drivers/leds/Makefile                         |    1 +
 drivers/leds/flash/Kconfig                    |    9 +
 drivers/leds/flash/Makefile                   |    1 +
 drivers/leds/flash/leds-mt6370-flash.c        |  665 ++++++++++
 drivers/leds/leds-mt6370.c                    |  994 +++++++++++++++
 drivers/mfd/Kconfig                           |   13 +
 drivers/mfd/Makefile                          |    1 +
 drivers/mfd/mt6370.c                          |  273 ++++
 drivers/power/supply/Kconfig                  |   11 +
 drivers/power/supply/Makefile                 |    1 +
 drivers/power/supply/mt6370-charger.c         | 1132 +++++++++++++++++
 drivers/regulator/Kconfig                     |    8 +
 drivers/regulator/Makefile                    |    1 +
 drivers/regulator/mt6370-regulator.c          |  389 ++++++
 drivers/usb/typec/tcpm/Kconfig                |    8 +
 drivers/usb/typec/tcpm/Makefile               |    1 +
 drivers/usb/typec/tcpm/tcpci_mt6370.c         |  212 +++
 drivers/video/backlight/Kconfig               |    8 +
 drivers/video/backlight/Makefile              |    1 +
 drivers/video/backlight/mt6370-backlight.c    |  338 +++++
 .../dt-bindings/iio/adc/mediatek,mt6370_adc.h |   18 +
 include/dt-bindings/mfd/mediatek,mt6370.h     |   83 ++
 32 files changed, 5038 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/leds/backlight/mediatek,mt6370-backlight.yaml
 create mode 100644 Documentation/devicetree/bindings/leds/mediatek,mt6370-flashlight.yaml
 create mode 100644 Documentation/devicetree/bindings/leds/mediatek,mt6370-indicator.yaml
 create mode 100644 Documentation/devicetree/bindings/mfd/mediatek,mt6370.yaml
 create mode 100644 Documentation/devicetree/bindings/power/supply/mediatek,mt6370-charger.yaml
 create mode 100644 Documentation/devicetree/bindings/usb/mediatek,mt6370-tcpc.yaml
 create mode 100644 drivers/iio/adc/mt6370-adc.c
 create mode 100644 drivers/leds/flash/leds-mt6370-flash.c
 create mode 100644 drivers/leds/leds-mt6370.c
 create mode 100644 drivers/mfd/mt6370.c
 create mode 100644 drivers/power/supply/mt6370-charger.c
 create mode 100644 drivers/regulator/mt6370-regulator.c
 create mode 100644 drivers/usb/typec/tcpm/tcpci_mt6370.c
 create mode 100644 drivers/video/backlight/mt6370-backlight.c
 create mode 100644 include/dt-bindings/iio/adc/mediatek,mt6370_adc.h
 create mode 100644 include/dt-bindings/mfd/mediatek,mt6370.h
Signature · 1 line
2.25.1
author
#1 lore raw

PATCH 1/14 mfd: mt6370: Add Mediatek MT6370 support

From: ChiYuan Huang <[email protected]>

Add Mediatek MT6370 MFD support.

---
 drivers/mfd/Kconfig  |  13 +++
 drivers/mfd/Makefile |   1 +
 drivers/mfd/mt6370.c | 273 +++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 287 insertions(+)
 create mode 100644 drivers/mfd/mt6370.c
drivers/mfd/Kconfig +13 -0
index 3b59456f5545..d9a7524a3e0e 100644
@@ -937,6 +937,19 @@ config MFD_MT6360
 	  PMIC part includes 2-channel BUCKs and 2-channel LDOs
 	  LDO part includes 4-channel LDOs
 
+config MFD_MT6370
+	tristate "Mediatek MT6370 SubPMIC"
+	select MFD_CORE
+	select REGMAP_I2C
+	select REGMAP_IRQ
+	depends on I2C
+	help
+	  Say Y here to enable MT6370 SubPMIC functional support.
+	  It integrate single cell battery charger with adc monitoring, RGB
+	  LEDs, dual channel flashlight, WLED backlight driver, display bias
+	  voltage supply, one general purpose LDO, and cc logic
+	  controller with USBPD commmunication capable.
+
 config MFD_MT6397
 	tristate "MediaTek MT6397 PMIC Support"
 	select MFD_CORE
drivers/mfd/Makefile +1 -0
index 858cacf659d6..62b27125420e 100644
@@ -242,6 +242,7 @@ 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_MT6370)	+= mt6370.o
 mt6397-objs			:= mt6397-core.o mt6397-irq.o mt6358-irq.o
 obj-$(CONFIG_MFD_MT6397)	+= mt6397.o
 obj-$(CONFIG_INTEL_SOC_PMIC_MRFLD)	+= intel_soc_pmic_mrfld.o
drivers/mfd/mt6370.c new file +273 -0

273 lines not on this page · raw message

Signature · 1 line
2.25.1
author
#2 lore raw

PATCH 2/14 usb: typec: tcpci_mt6370: Add Mediatek MT6370 tcpci driver

In reply to ChiaEn Wu

From: ChiYuan Huang <[email protected]>

Add chip level mt6370 tcpci driver.

---
 drivers/usb/typec/tcpm/Kconfig        |   8 +
 drivers/usb/typec/tcpm/Makefile       |   1 +
 drivers/usb/typec/tcpm/tcpci_mt6370.c | 212 ++++++++++++++++++++++++++
 3 files changed, 221 insertions(+)
 create mode 100644 drivers/usb/typec/tcpm/tcpci_mt6370.c
drivers/usb/typec/tcpm/Kconfig +8 -0
index 557f392fe24d..f4b7363bc7e9 100644
@@ -35,6 +35,14 @@ config TYPEC_MT6360
 	  USB Type-C. It works with Type-C Port Controller Manager
 	  to provide USB PD and USB Type-C functionalities.
 
+config TYPEC_TCPCI_MT6370
+	tristate "Mediatek MT6370 Type-C driver"
+	depends on MFD_MT6370
+	help
+	  Mediatek MT6370 is a multi-functional IC that includes
+	  USB Type-C. It works with Type-C Port Controller Manager
+	  to provide USB PD and USB Type-C functionalities.
+
 config TYPEC_TCPCI_MAXIM
 	tristate "Maxim TCPCI based Type-C chip driver"
 	help
drivers/usb/typec/tcpm/Makefile +1 -0
index 7d499f3569fd..906d9dced8e7 100644
@@ -6,4 +6,5 @@ typec_wcove-y				:= wcove.o
 obj-$(CONFIG_TYPEC_TCPCI)		+= tcpci.o
 obj-$(CONFIG_TYPEC_RT1711H)		+= tcpci_rt1711h.o
 obj-$(CONFIG_TYPEC_MT6360)		+= tcpci_mt6360.o
+obj-$(CONFIG_TYPEC_TCPCI_MT6370)	+= tcpci_mt6370.o
 obj-$(CONFIG_TYPEC_TCPCI_MAXIM)		+= tcpci_maxim.o
drivers/usb/typec/tcpm/tcpci_mt6370.c new file +212 -0

212 lines not on this page · raw message

Signature · 1 line
2.25.1
author
#3 lore raw

PATCH 3/14 regulator: mt6370: Add mt6370 DisplayBias and VibLDO support

In reply to ChiaEn Wu

From: ChiYuan Huang <[email protected]>

Add mt6370 DisplayBias and VibLDO support.

---
 drivers/regulator/Kconfig            |   8 +
 drivers/regulator/Makefile           |   1 +
 drivers/regulator/mt6370-regulator.c | 389 +++++++++++++++++++++++++++
 3 files changed, 398 insertions(+)
 create mode 100644 drivers/regulator/mt6370-regulator.c
drivers/regulator/Kconfig +8 -0
index cbe0f96ca342..dcb6866dab53 100644
@@ -804,6 +804,14 @@ config REGULATOR_MT6360
 	  2-channel buck with Thermal Shutdown and Overload Protection
 	  6-channel High PSRR and Low Dropout LDO.
 
+config REGULATOR_MT6370
+	tristate "MT6370 SubPMIC Regulator"
+	depends on MFD_MT6370
+	help
+	  Say Y here to enable MT6370 regulator support.
+	  This driver support the control for DisplayBias voltages and one
+	  general purpose LDO which commonly used to drive the vibrator.
+
 config REGULATOR_MT6380
 	tristate "MediaTek MT6380 PMIC"
 	depends on MTK_PMIC_WRAP
drivers/regulator/Makefile +1 -0
index 8d3ee8b6d41d..f1cbff21843e 100644
@@ -97,6 +97,7 @@ obj-$(CONFIG_REGULATOR_MT6323)	+= mt6323-regulator.o
 obj-$(CONFIG_REGULATOR_MT6358)	+= mt6358-regulator.o
 obj-$(CONFIG_REGULATOR_MT6359)	+= mt6359-regulator.o
 obj-$(CONFIG_REGULATOR_MT6360) += mt6360-regulator.o
+obj-$(CONFIG_REGULATOR_MT6370) += mt6370-regulator.o
 obj-$(CONFIG_REGULATOR_MT6380)	+= mt6380-regulator.o
 obj-$(CONFIG_REGULATOR_MT6397)	+= mt6397-regulator.o
 obj-$(CONFIG_REGULATOR_MTK_DVFSRC) += mtk-dvfsrc-regulator.o
drivers/regulator/mt6370-regulator.c new file +389 -0

389 lines not on this page · raw message

Signature · 1 line
2.25.1
maintainer
#4 lore raw

Re: [PATCH 03/14] regulator: mt6370: Add mt6370 DisplayBias and VibLDO support

Quoted 3 lines · ChiaEn Wu

From: ChiYuan Huang <[email protected]>

Add mt6370 DisplayBias and VibLDO support.

Other than one small thing this looks nice and clean:

drivers/regulator/mt6370-regulator.c line 163

Quoted 8 lines
drivers/regulator/mt6370-regulator.c new file +8 -0
+	enable_gpio = fwnode_gpiod_get_index(of_fwnode_handle(np), "enable", 0,
+					     GPIOD_OUT_HIGH |
+					     GPIOD_FLAGS_BIT_NONEXCLUSIVE,
+					     desc->name);
+	if (IS_ERR(enable_gpio)) {
+		config->ena_gpiod = NULL;
+		return 0;
+	}

Please just use the OF APIs - due to ACPI's handling of power for devices the regulator API OF bindings can't be used sensibly on ACPI so it's better to explicitly work on DT only. This won't actually cause problems here but it's a bit clearer.

author
#5 lore raw

PATCH 4/14 iio: adc: mt6370: Add Mediatek MT6370 support

In reply to ChiaEn Wu

From: ChiaEn Wu <[email protected]>

Add Mediatek MT6370 ADC support.

---
 drivers/iio/adc/Kconfig      |   9 ++
 drivers/iio/adc/Makefile     |   1 +
 drivers/iio/adc/mt6370-adc.c | 257 +++++++++++++++++++++++++++++++++++
 3 files changed, 267 insertions(+)
 create mode 100644 drivers/iio/adc/mt6370-adc.c
drivers/iio/adc/Kconfig +9 -0
index 71ab0a06aa82..d7932dd9b773 100644
@@ -737,6 +737,15 @@ config MEDIATEK_MT6360_ADC
 	  is used in smartphones and tablets and supports a 11 channel
 	  general purpose ADC.
 
+config MEDIATEK_MT6370_ADC
+	tristate "Mediatek MT6370 ADC driver"
+	depends on MFD_MT6370
+	help
+	  Say Y here to enable MT6370 ADC support.
+	  Integrated for System Monitoring includes
+	  is used in smartphones and tablets and supports a 9 channel
+	  general purpose ADC.
+
 config MEDIATEK_MT6577_AUXADC
 	tristate "MediaTek AUXADC driver"
 	depends on ARCH_MEDIATEK || COMPILE_TEST
drivers/iio/adc/Makefile +1 -0
index 39d806f6d457..0ce285c7e2d0 100644
@@ -68,6 +68,7 @@ obj-$(CONFIG_MCP320X) += mcp320x.o
 obj-$(CONFIG_MCP3422) += mcp3422.o
 obj-$(CONFIG_MCP3911) += mcp3911.o
 obj-$(CONFIG_MEDIATEK_MT6360_ADC) += mt6360-adc.o
+obj-$(CONFIG_MEDIATEK_MT6370_ADC) += mt6370-adc.o
 obj-$(CONFIG_MEDIATEK_MT6577_AUXADC) += mt6577_auxadc.o
 obj-$(CONFIG_MEN_Z188_ADC) += men_z188_adc.o
 obj-$(CONFIG_MESON_SARADC) += meson_saradc.o
drivers/iio/adc/mt6370-adc.c new file +257 -0

257 lines not on this page · raw message

Signature · 1 line
2.25.1
author
#6 lore raw

PATCH 5/14 power: supply: mt6370: Add Mediatek MT6370 charger driver

In reply to ChiaEn Wu

From: ChiaEn Wu <[email protected]>

Add Mediatek MT6370 charger driver

---
 drivers/power/supply/Kconfig          |   11 +
 drivers/power/supply/Makefile         |    1 +
 drivers/power/supply/mt6370-charger.c | 1132 +++++++++++++++++++++++++
 3 files changed, 1144 insertions(+)
 create mode 100644 drivers/power/supply/mt6370-charger.c
drivers/power/supply/Kconfig +11 -0
index 1aa8323ad9f6..54d8c3ab01cc 100644
@@ -619,6 +619,17 @@ config CHARGER_MT6360
 	  Average Input Current Regulation, Battery Temperature Sensing,
 	  Over-Temperature Protection, DPDM Detection for BC1.2.
 
+config CHARGER_MT6370
+	tristate "Mediatek MT6370 Charger Driver"
+	depends on MFD_MT6370
+	depends on REGULATOR
+	select LINEAR_RANGES
+	help
+	  Say Y here to enable MT6370 Charger Part.
+	  The device supports High-Accuracy Voltage/Current Regulation,
+	  Average Input Current Regulation, Battery Temperature 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
drivers/power/supply/Makefile +1 -0
index 7f02f36aea55..8c9527643c86 100644
@@ -82,6 +82,7 @@ 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_MT6370)	+= mt6370-charger.o
 obj-$(CONFIG_CHARGER_QCOM_SMBB)	+= qcom_smbb.o
 obj-$(CONFIG_CHARGER_BQ2415X)	+= bq2415x_charger.o
 obj-$(CONFIG_CHARGER_BQ24190)	+= bq24190_charger.o
drivers/power/supply/mt6370-charger.c new file +1132 -0

1,132 lines not on this page · raw message

Signature · 1 line
2.25.1
author
#7 lore raw

PATCH 6/14 leds: mt6370: Add Mediatek MT6370 Indicator support

In reply to ChiaEn Wu

From: Alice Chen <[email protected]>

Add Mediatek MT6370 Indicator support

---
 drivers/leds/Kconfig       |  11 +
 drivers/leds/Makefile      |   1 +
 drivers/leds/leds-mt6370.c | 994 +++++++++++++++++++++++++++++++++++++
 3 files changed, 1006 insertions(+)
 create mode 100644 drivers/leds/leds-mt6370.c
drivers/leds/Kconfig +11 -0
index 6090e647daee..0cb2294b3431 100644
@@ -244,6 +244,17 @@ config LEDS_MT6323
 	  This option enables support for on-chip LED drivers found on
 	  Mediatek MT6323 PMIC.
 
+config LEDS_MT6370_RGB
+	tristate "LED Support for Mediatek MT6370 PMIC"
+	depends on LEDS_CLASS
+	depends on MFD_MT6370
+	select LINEAR_RANGE
+	help
+	  Support 4 channels and reg/pwm/breath mode.
+	  Isink4 can also use as a CHG_VIN power good Indicator.
+	  Say Y here to enable support for
+	  MT6370_RGB_LED device.
+
 config LEDS_S3C24XX
 	tristate "LED Support for Samsung S3C24XX GPIO LEDs"
 	depends on LEDS_CLASS
drivers/leds/Makefile +1 -0
index e58ecb36360f..b641fd83f49a 100644
@@ -62,6 +62,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_MT6370_RGB)		+= leds-mt6370.o
 obj-$(CONFIG_LEDS_NET48XX)		+= leds-net48xx.o
 obj-$(CONFIG_LEDS_NETXBIG)		+= leds-netxbig.o
 obj-$(CONFIG_LEDS_NIC78BX)		+= leds-nic78bx.o
drivers/leds/leds-mt6370.c new file +994 -0

994 lines not on this page · raw message

Signature · 1 line
2.25.1
#8 lore raw

Re: [PATCH 06/14] leds: mt6370: Add Mediatek MT6370 Indicator support

Quoted 2 lines · ChiaEn Wu

From: Alice Chen <[email protected]>

All below comments are applicable to the rest of the series as well (one way or another), so please fix all your patches where it's appropriate.

Quoted 2 lines

Add Mediatek MT6370 Indicator support

What indicator?
Please also keep attention on English punctuation (missed period).

...

drivers/leds/Kconfig config LEDS_MT6323 · line 254

Quoted 3 lines
drivers/leds/Kconfig +3 -0
+       help
+         Support 4 channels and reg/pwm/breath mode.
+         Isink4 can also use as a CHG_VIN power good Indicator.

be used

Quoted 2 lines
drivers/leds/Kconfig +2 -0
+         Say Y here to enable support for
+         MT6370_RGB_LED device.

...

drivers/leds/leds-mt6370.c line 11

Quoted 5 lines
drivers/leds/leds-mt6370.c new file +4 -0
+#include <linux/module.h>
+#include <linux/mutex.h>
+#include <linux/platform_device.h>
 
+#include <linux/of.h>

Are you sure this is the correct header? Seems you need mod_devicetable.h instead.

Quoted 2 lines
drivers/leds/leds-mt6370.c new file +2 -0
+#include <linux/property.h>
+#include <linux/regmap.h>

...

drivers/leds/leds-mt6370.c line 118

Quoted 2 lines
drivers/leds/leds-mt6370.c new file +2 -0
+struct mt6370_priv {
+       struct mutex lock;

Do you use regmap locking?

Quoted 13 lines
drivers/leds/leds-mt6370.c new file +11 -0
+       struct device *dev;
 
+       struct regmap *regmap;
 
+       struct regmap_field *fields[F_MAX_FIELDS];
+       const struct reg_field *reg_fields;
+       const struct linear_range *ranges;
+       struct reg_cfg *reg_cfgs;
+       unsigned int leds_count;
+       unsigned int leds_active;
+       bool is_mt6372;
+       struct mt6370_led leds[];
+};

...

drivers/leds/leds-mt6370.c line 249

Quoted 2 lines
drivers/leds/leds-mt6370.c new file +2 -0
+static const unsigned int common_tfreqs[] = {
+       10000, 5000, 2000, 1000, 500, 200, 5, 1

Leave a comma at the end.

drivers/leds/leds-mt6370.c line 253

Quoted 4 lines
drivers/leds/leds-mt6370.c new file +4 -0
+};
+
+static const unsigned int mt6372_tfreqs[] = {
+       8000, 4000, 2000, 1000, 500, 250, 8, 4

Ditto.

Quoted 1 line

+};

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

Re: [PATCH 06/14] leds: mt6370: Add Mediatek MT6370 Indicator support

Quoted 7 lines · Andy Shevchenko
Quoted 2 lines · ChiaEn Wu

From: Alice Chen <[email protected]>

All below comments are applicable to the rest of the series as well (one way or another), so please fix all your patches where it's appropriate.

Forgot to mention, please consider using

  return dev_err_probe();

pattern in the ->probe() and related funcitons. It will save a lot of LOCs.

Quoted 71 lines
Quoted 1 line

Add Mediatek MT6370 Indicator support

What indicator?
Please also keep attention on English punctuation (missed period).

...

drivers/leds/Kconfig config LEDS_MT6323 · line 254

Quoted 3 lines
drivers/leds/Kconfig +3 -0
+       help
+         Support 4 channels and reg/pwm/breath mode.
+         Isink4 can also use as a CHG_VIN power good Indicator.

be used

Quoted 2 lines
drivers/leds/Kconfig +2 -0
+         Say Y here to enable support for
+         MT6370_RGB_LED device.

...

drivers/leds/leds-mt6370.c line 11

Quoted 5 lines
drivers/leds/leds-mt6370.c new file +4 -0
+#include <linux/module.h>
+#include <linux/mutex.h>
+#include <linux/platform_device.h>
 
+#include <linux/of.h>

Are you sure this is the correct header? Seems you need mod_devicetable.h instead.

Quoted 2 lines
drivers/leds/leds-mt6370.c new file +2 -0
+#include <linux/property.h>
+#include <linux/regmap.h>

...

drivers/leds/leds-mt6370.c line 118

Quoted 2 lines
drivers/leds/leds-mt6370.c new file +2 -0
+struct mt6370_priv {
+       struct mutex lock;

Do you use regmap locking?

Quoted 13 lines
drivers/leds/leds-mt6370.c new file +11 -0
+       struct device *dev;
 
+       struct regmap *regmap;
 
+       struct regmap_field *fields[F_MAX_FIELDS];
+       const struct reg_field *reg_fields;
+       const struct linear_range *ranges;
+       struct reg_cfg *reg_cfgs;
+       unsigned int leds_count;
+       unsigned int leds_active;
+       bool is_mt6372;
+       struct mt6370_led leds[];
+};

...

drivers/leds/leds-mt6370.c line 249

Quoted 2 lines
drivers/leds/leds-mt6370.c new file +2 -0
+static const unsigned int common_tfreqs[] = {
+       10000, 5000, 2000, 1000, 500, 200, 5, 1

Leave a comma at the end.

drivers/leds/leds-mt6370.c line 253

Quoted 4 lines
drivers/leds/leds-mt6370.c new file +4 -0
+};
+
+static const unsigned int mt6372_tfreqs[] = {
+       8000, 4000, 2000, 1000, 500, 250, 8, 4

Ditto.

Quoted 1 line

+};

--
With Best Regards,
Andy Shevchenko

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

Re: [PATCH 06/14] leds: mt6370: Add Mediatek MT6370 Indicator support

In reply to Andy Shevchenko
Quoted 4 lines · Andy Shevchenko
Quoted 2 lines · ChiaEn Wu

From: Alice Chen <[email protected]>

Quoted 8 lines

All below comments are applicable to the rest of the series as well (one way or another), so please fix all your patches where it's appropriate.

Quoted 2 lines

Add Mediatek MT6370 Indicator support

What indicator?

It's RGB curent sink type LED driver (maximum supported current is only 24mA).

Quoted 2 lines

Please also keep attention on English punctuation (missed period).

Ack in next.

Quoted 8 lines

...

drivers/leds/Kconfig config LEDS_MT6323 · line 254

Quoted 3 lines
drivers/leds/Kconfig +3 -0
+       help
+         Support 4 channels and reg/pwm/breath mode.
+         Isink4 can also use as a CHG_VIN power good Indicator.

be used

Ack in next.

Quoted 5 lines
Quoted 2 lines
drivers/leds/Kconfig +2 -0
+         Say Y here to enable support for
+         MT6370_RGB_LED device.

...

Quoted 9 lines

drivers/leds/leds-mt6370.c line 11

Quoted 5 lines
drivers/leds/leds-mt6370.c new file +4 -0
+#include <linux/module.h>
+#include <linux/mutex.h>
+#include <linux/platform_device.h>
 
+#include <linux/of.h>

Are you sure this is the correct header? Seems you need mod_devicetable.h instead.

It's the correct header and be used for the struct 'of_device_id'.

Quoted 10 lines
Quoted 2 lines
drivers/leds/leds-mt6370.c new file +2 -0
+#include <linux/property.h>
+#include <linux/regmap.h>

...

drivers/leds/leds-mt6370.c line 118

Quoted 2 lines
drivers/leds/leds-mt6370.c new file +2 -0
+struct mt6370_priv {
+       struct mutex lock;

Do you use regmap locking?

MFD regmap register already the access lock.

This lock is just to guarantee only one user can access the RGB register part.

Sorry, from the comment, do you want us to rename or remove this lock?

Quoted 14 lines

drivers/leds/leds-mt6370.c line 129

Quoted 13 lines
drivers/leds/leds-mt6370.c new file +11 -0
+       struct device *dev;
 
+       struct regmap *regmap;
 
+       struct regmap_field *fields[F_MAX_FIELDS];
+       const struct reg_field *reg_fields;
+       const struct linear_range *ranges;
+       struct reg_cfg *reg_cfgs;
+       unsigned int leds_count;
+       unsigned int leds_active;
+       bool is_mt6372;
+       struct mt6370_led leds[];
+};
Quoted 7 lines

...

drivers/leds/leds-mt6370.c line 249

Quoted 2 lines
drivers/leds/leds-mt6370.c new file +2 -0
+static const unsigned int common_tfreqs[] = {
+       10000, 5000, 2000, 1000, 500, 200, 5, 1

Leave a comma at the end.

Ack in next.

Quoted 7 lines

drivers/leds/leds-mt6370.c line 253

Quoted 4 lines
drivers/leds/leds-mt6370.c new file +4 -0
+};
+
+static const unsigned int mt6372_tfreqs[] = {
+       8000, 4000, 2000, 1000, 500, 250, 8, 4

Ditto.

Ack in next.

Quoted 6 lines
Quoted 1 line

+};

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

Re: [PATCH 06/14] leds: mt6370: Add Mediatek MT6370 Indicator support

Quoted 2 lines · ChiYuan Huang
Quoted 1 line · Andy Shevchenko

On Tue, May 31, 2022 at 1:16 PM ChiaEn Wu <[email protected]> wrote:

...

Quoted 2 lines
Quoted 1 line

What indicator?

It's RGB curent sink type LED driver (maximum supported current is only 24mA).

Make your commit messages a slightly more verbose.

...

Quoted 6 lines
Quoted 5 lines
Quoted 1 line

+#include <linux/of.h>

Are you sure this is the correct header? Seems you need mod_devicetable.h instead.

It's the correct header and be used for the struct 'of_device_id'.

Nope. Run the following command

$ git grep -n 'struct of_device_id {' -- include/linux/

...

Quoted 11 lines
Quoted 5 lines

drivers/leds/leds-mt6370.c line 118

Quoted 2 lines
drivers/leds/leds-mt6370.c new file +2 -0
+struct mt6370_priv {
+       struct mutex lock;

Do you use regmap locking?

MFD regmap register already the access lock.

This lock is just to guarantee only one user can access the RGB register part.

Sorry, from the comment, do you want us to rename or remove this lock?

My point is, since you have two locks, explain why you need each of them.

Quoted 13 lines
Quoted 13 lines
Quoted 13 lines
drivers/leds/leds-mt6370.c new file +11 -0
+       struct device *dev;
 
+       struct regmap *regmap;
 
+       struct regmap_field *fields[F_MAX_FIELDS];
+       const struct reg_field *reg_fields;
+       const struct linear_range *ranges;
+       struct reg_cfg *reg_cfgs;
+       unsigned int leds_count;
+       unsigned int leds_active;
+       bool is_mt6372;
+       struct mt6370_led leds[];
+};
Signature · 2 lines
With Best Regards,
Andy Shevchenko
#12 lore raw

Re: [PATCH 06/14] leds: mt6370: Add Mediatek MT6370 Indicator support

Andy Shevchenko <[email protected]> 於 2022年6月2日 週四 下午5:18寫道:

Quoted 12 lines · ChiYuan Huang
Quoted 2 lines · Andy Shevchenko
Quoted 1 line · ChiaEn Wu

...

Quoted 2 lines
Quoted 1 line

What indicator?

It's RGB curent sink type LED driver (maximum supported current is only 24mA).

Make your commit messages a slightly more verbose.

OK, will refine the commit message in next.

Quoted 4 lines

...

Quoted 2 lines
Quoted 2 lines
Quoted 1 line

+#include <linux/of.h>

Quoted 8 lines
Quoted 4 lines
Quoted 3 lines

Are you sure this is the correct header? Seems you need mod_devicetable.h instead.

It's the correct header and be used for the struct 'of_device_id'.

Nope. Run the following command

$ git grep -n 'struct of_device_id {' -- include/linux/

Got it, thanks.

Quoted 7 lines

...

Quoted 5 lines
Quoted 5 lines

drivers/leds/leds-mt6370.c line 118

Quoted 2 lines
drivers/leds/leds-mt6370.c new file +2 -0
+struct mt6370_priv {
+       struct mutex lock;

Do you use regmap locking?

Quoted 9 lines
Quoted 6 lines

MFD regmap register already the access lock.

This lock is just to guarantee only one user can access the RGB register part.

Sorry, from the comment, do you want us to rename or remove this lock?

My point is, since you have two locks, explain why you need each of them.

OK, will leave a comment line to explain the usage of this lock.

Quoted 18 lines
Quoted 4 lines
Quoted 4 lines
Quoted 3 lines
drivers/leds/leds-mt6370.c new file +2 -0
+       struct device *dev;
 
+       struct regmap *regmap;
Quoted 9 lines
Quoted 9 lines

drivers/leds/leds-mt6370.c line 129

Quoted 9 lines
drivers/leds/leds-mt6370.c new file +9 -0
+       struct regmap_field *fields[F_MAX_FIELDS];
+       const struct reg_field *reg_fields;
+       const struct linear_range *ranges;
+       struct reg_cfg *reg_cfgs;
+       unsigned int leds_count;
+       unsigned int leds_active;
+       bool is_mt6372;
+       struct mt6370_led leds[];
+};

--
With Best Regards,
Andy Shevchenko

author
#13 lore raw

PATCH 7/14 leds: flashlight: mt6370: Add Mediatek MT6370 flashlight support

In reply to ChiaEn Wu

From: Alice Chen <[email protected]>

Add Mediatek MT6370 flashlight support

---
 drivers/leds/flash/Kconfig             |   9 +
 drivers/leds/flash/Makefile            |   1 +
 drivers/leds/flash/leds-mt6370-flash.c | 665 +++++++++++++++++++++++++
 3 files changed, 675 insertions(+)
 create mode 100644 drivers/leds/flash/leds-mt6370-flash.c
drivers/leds/flash/Kconfig +9 -0
index d3eb689b193c..d38e263aaf09 100644
@@ -90,4 +90,13 @@ config LEDS_SGM3140
 	  This option enables support for the SGM3140 500mA Buck/Boost Charge
 	  Pump LED Driver.
 
+config LEDS_MT6370_FLASHLIGHT
+	tristate "Flash LED Support for Mediatek MT6370 PMIC"
+	depends on LEDS_CLASS
+	depends on MFD_MT6370
+	help
+	  Support 2 channels and torch/strobe mode.
+	  Say Y here to enable support for
+	  MT6370_FLASH_LED device.
+
 endif # LEDS_CLASS_FLASH
drivers/leds/flash/Makefile +1 -0
index 0acbddc0b91b..4c4c1710f506 100644
@@ -9,3 +9,4 @@ obj-$(CONFIG_LEDS_MAX77693)	+= leds-max77693.o
 obj-$(CONFIG_LEDS_RT4505)	+= leds-rt4505.o
 obj-$(CONFIG_LEDS_RT8515)	+= leds-rt8515.o
 obj-$(CONFIG_LEDS_SGM3140)	+= leds-sgm3140.o
+obj-$(CONFIG_LEDS_MT6370_FLASHLIGHT)	+= leds-mt6370-flash.o
drivers/leds/flash/leds-mt6370-flash.c new file +665 -0

665 lines not on this page · raw message

Signature · 1 line
2.25.1
#14 lore raw

Re: [PATCH 07/14] leds: flashlight: mt6370: Add Mediatek MT6370 flashlight support

Quoted 4 lines · ChiaEn Wu

From: Alice Chen <[email protected]>

Add Mediatek MT6370 flashlight support

Same comments about the commit message.

...

drivers/leds/flash/leds-mt6370-flash.c line 13

Quoted 3 lines
drivers/leds/flash/leds-mt6370-flash.c new file +3 -0
+#include <linux/platform_device.h>
+#include <linux/property.h>
+#include <linux/regmap.h>

+ blank line?

Quoted 1 line

+#include <media/v4l2-flash-led-class.h>

+ blank line

Quoted 5 lines
drivers/leds/flash/leds-mt6370-flash.c new file +5 -0
+enum {
+       MT6370_LED_FLASH1,
+       MT6370_LED_FLASH2,
+       MT6370_MAX_LEDS
+};

...

drivers/leds/flash/leds-mt6370-flash.c line 200

Quoted 5 lines
drivers/leds/flash/leds-mt6370-flash.c new file +4 -0
+       struct mt6370_led *led = container_of(fl_cdev, struct mt6370_led,
+                                             flash);
 
+       struct mt6370_led *led = container_of(fl_cdev, struct mt6370_led,
+                                             flash);

Make a helper out of this

  #define to_mt637_led()  container_of()

and reuse.

...

Review

Quoted 2 lines
(quoted diff) +2 -0
+       /*
+        * For the flash turn on/off, HW rampping up/down time is 5ms/500us,

ramping

Quoted 1 line

+ * respectively

Period!

Quoted 1 line

+ */

...

drivers/leds/flash/leds-mt6370-flash.c line 564

Quoted 12 lines
drivers/leds/flash/leds-mt6370-flash.c new file +12 -0
+       const char * const states[] = { "off", "keep", "on" };
+       const char *str;
+       int ret;
+
+       if (!fwnode_property_read_string(init_data->fwnode,
+                                        "default-state", &str)) {
+               ret = match_string(states, ARRAY_SIZE(states), str);
+               if (ret < 0)
+                       ret = STATE_OFF;
+
+               led->default_state = ret;
+       }

fwnode_property_match_string()?

...

drivers/leds/flash/leds-mt6370-flash.c line 592

Quoted 4 lines
drivers/leds/flash/leds-mt6370-flash.c new file +4 -0
+       if (!count || count > MT6370_MAX_LEDS) {
+               dev_err(&pdev->dev,
+               "No child node or node count over max led number %lu\n", count);
+               return -EINVAL;

return dev_err_probe(...);

Quoted 1 line

+ }

--
With Best Regards,
Andy Shevchenko

#15 lore raw

Re: [PATCH 07/14] leds: flashlight: mt6370: Add Mediatek MT6370 flashlight support

Thank you for the valuable suggestion.

Andy Shevchenko <[email protected]> 於 2022年6月1日 週三 下午5:57寫道:

Quoted 9 lines · ChiaEn Wu
Quoted 4 lines

From: Alice Chen <[email protected]>

Add Mediatek MT6370 flashlight support

Same comments about the commit message.

Quoted 7 lines

...

drivers/leds/flash/leds-mt6370-flash.c line 13

Quoted 3 lines
drivers/leds/flash/leds-mt6370-flash.c new file +3 -0
+#include <linux/platform_device.h>
+#include <linux/property.h>
+#include <linux/regmap.h>

+ blank line?

Thanks, this will be refined in the new version.

Quoted 4 lines
Quoted 2 lines

+#include <media/v4l2-flash-led-class.h>

+ blank line

Thanks, this will be refined in the new version.

Quoted 12 lines
Quoted 6 lines
drivers/leds/flash/leds-mt6370-flash.c new file +5 -0
+enum {
+       MT6370_LED_FLASH1,
+       MT6370_LED_FLASH2,
+       MT6370_MAX_LEDS
+};

...

Quoted 2 lines
(quoted diff) +2 -0
+       struct mt6370_led *led = container_of(fl_cdev, struct mt6370_led,
+                                             flash);
Quoted 8 lines

Review

Quoted 2 lines
(quoted diff) +2 -0
+       struct mt6370_led *led = container_of(fl_cdev, struct mt6370_led,
+                                             flash);

Make a helper out of this

  #define to_mt637_led()  container_of()

and reuse.

Thanks, this will be refined in the new version.

Quoted 11 lines

...

Review

Quoted 2 lines
(quoted diff) +2 -0
+       /*
+        * For the flash turn on/off, HW rampping up/down time is 5ms/500us,

ramping

Quoted 1 line

+ * respectively

Period!

Thanks, this will be refined in the new version.

Quoted 5 lines
Quoted 2 lines

+ */

...

Quoted 14 lines

drivers/leds/flash/leds-mt6370-flash.c line 564

Quoted 12 lines
drivers/leds/flash/leds-mt6370-flash.c new file +12 -0
+       const char * const states[] = { "off", "keep", "on" };
+       const char *str;
+       int ret;
+
+       if (!fwnode_property_read_string(init_data->fwnode,
+                                        "default-state", &str)) {
+               ret = match_string(states, ARRAY_SIZE(states), str);
+               if (ret < 0)
+                       ret = STATE_OFF;
+
+               led->default_state = ret;
+       }

fwnode_property_match_string()?

Sorry, but I think the use of this function is different from my target. I want to read the string of the "default-state" property and figure out if the string is in the states array.
But the fwnode_property_match_string aimed to figure out if the state in the property array.
One is a property array and another one is a state array.

Quoted 9 lines

...

drivers/leds/flash/leds-mt6370-flash.c line 592

Quoted 4 lines
drivers/leds/flash/leds-mt6370-flash.c new file +4 -0
+       if (!count || count > MT6370_MAX_LEDS) {
+               dev_err(&pdev->dev,
+               "No child node or node count over max led number %lu\n", count);
+               return -EINVAL;

return dev_err_probe(...);

Thanks, will refine in the new version

Quoted 9 lines
Quoted 2 lines

+ }

--
With Best Regards,
Andy Shevchenko

Sincerely,
Alice Chen

#16 lore raw

Re: [PATCH 07/14] leds: flashlight: mt6370: Add Mediatek MT6370 flashlight support

Quoted 2 lines · szuni chen

Andy Shevchenko <[email protected]> 於 2022年6月1日 週三 下午5:57寫道:

Quoted 1 line · ChiaEn Wu

...

Quoted 14 lines
Quoted 6 lines
Quoted 6 lines
drivers/leds/flash/leds-mt6370-flash.c new file +6 -0
+       const char * const states[] = { "off", "keep", "on" };
+       const char *str;
+       int ret;
+
+       if (!fwnode_property_read_string(init_data->fwnode,
+                                        "default-state", &str)) {
Quoted 8 lines

drivers/leds/flash/leds-mt6370-flash.c line 564

Quoted 6 lines
drivers/leds/flash/leds-mt6370-flash.c new file +6 -0
+               ret = match_string(states, ARRAY_SIZE(states), str);
+               if (ret < 0)
+                       ret = STATE_OFF;
+
+               led->default_state = ret;
+       }

fwnode_property_match_string()?

Quoted 6 lines

Sorry, but I think the use of this function is different from my target. I want to read the string of the "default-state" property and figure out if the string is in the states array.
But the fwnode_property_match_string aimed to figure out if the state in the property array.
One is a property array and another one is a state array.

Ah, indeed. Nevertheless you may reduce the code base by doing like the following (I wonder what your code do if there is no default-state property):

led->default_state = STATE_OFF; // it's by default off since
kzalloc(), so I don't see why we need this line at all.

  fwnode_property_read_string(init_data->fwnode, "default-state", &str);
  ret = match_string(states, ARRAY_SIZE(states), str);
  if (ret >= 0)
    led->default_state = ret;
Signature · 2 lines
With Best Regards,
Andy Shevchenko
#17 lore raw

Re: [PATCH 07/14] leds: flashlight: mt6370: Add Mediatek MT6370 flashlight support

Quoted 3 lines · Andy Shevchenko
Quoted 2 lines · szuni chen

Andy Shevchenko <[email protected]> 於 2022年6月1日 週三 下午5:57寫道:

Quoted 1 line · ChiaEn Wu

...

Quoted 25 lines
Quoted 14 lines
Quoted 6 lines
Quoted 6 lines
drivers/leds/flash/leds-mt6370-flash.c new file +6 -0
+       const char * const states[] = { "off", "keep", "on" };
+       const char *str;
+       int ret;
+
+       if (!fwnode_property_read_string(init_data->fwnode,
+                                        "default-state", &str)) {
Quoted 8 lines

drivers/leds/flash/leds-mt6370-flash.c line 564

Quoted 6 lines
drivers/leds/flash/leds-mt6370-flash.c new file +6 -0
+               ret = match_string(states, ARRAY_SIZE(states), str);
+               if (ret < 0)
+                       ret = STATE_OFF;
+
+               led->default_state = ret;
+       }

fwnode_property_match_string()?

Quoted 6 lines

Sorry, but I think the use of this function is different from my target. I want to read the string of the "default-state" property and figure out if the string is in the states array.
But the fwnode_property_match_string aimed to figure out if the state in the property array.
One is a property array and another one is a state array.

Ah, indeed. Nevertheless you may reduce the code base by doing like the following (I wonder what your code do if there is no default-state property):

Quoted 7 lines

led->default_state = STATE_OFF; // it's by default off since
kzalloc(), so I don't see why we need this line at all.

  fwnode_property_read_string(init_data->fwnode, "default-state", &str);
  ret = match_string(states, ARRAY_SIZE(states), str);
  if (ret >= 0)
    led->default_state = ret;

Missed change

  const char *str = states[STATE_OFF];
Signature · 2 lines
With Best Regards,
Andy Shevchenko
author
#18 lore raw

PATCH 8/14 video: backlight: mt6370: Add Mediatek MT6370 support

In reply to ChiaEn Wu

From: ChiaEn Wu <[email protected]>

Add Mediatek MT6370 Backlight support.

---
 drivers/video/backlight/Kconfig            |   8 +
 drivers/video/backlight/Makefile           |   1 +
 drivers/video/backlight/mt6370-backlight.c | 338 +++++++++++++++++++++
 3 files changed, 347 insertions(+)
 create mode 100644 drivers/video/backlight/mt6370-backlight.c
drivers/video/backlight/Kconfig +8 -0
index a003e02e13ce..d9868fbe7488 100644
@@ -268,6 +268,14 @@ config BACKLIGHT_MAX8925
 	  If you have a LCD backlight connected to the WLED output of MAX8925
 	  WLED output, say Y here to enable this driver.
 
+config BACKLIGHT_MT6370
+	tristate "Mediatek MT6370 Backlight Driver"
+	depends on MFD_MT6370
+	help
+	  Say Y here to enable MT6370 Backlight support.
+	  It's commonly used to drive the display WLED. There're 4 channels
+	  inisde, and each channel can provide up to 30mA current.
+
 config BACKLIGHT_APPLE
 	tristate "Apple Backlight Driver"
 	depends on X86 && ACPI
drivers/video/backlight/Makefile +1 -0
index cae2c83422ae..e815f3f1deff 100644
@@ -44,6 +44,7 @@ obj-$(CONFIG_BACKLIGHT_LP855X)		+= lp855x_bl.o
 obj-$(CONFIG_BACKLIGHT_LP8788)		+= lp8788_bl.o
 obj-$(CONFIG_BACKLIGHT_LV5207LP)	+= lv5207lp.o
 obj-$(CONFIG_BACKLIGHT_MAX8925)		+= max8925_bl.o
+obj-$(CONFIG_BACKLIGHT_MT6370)		+= mt6370-backlight.o
 obj-$(CONFIG_BACKLIGHT_OMAP1)		+= omap1_bl.o
 obj-$(CONFIG_BACKLIGHT_PANDORA)		+= pandora_bl.o
 obj-$(CONFIG_BACKLIGHT_PCF50633)	+= pcf50633-backlight.o
drivers/video/backlight/mt6370-backlight.c new file +338 -0

338 lines not on this page · raw message

Signature · 1 line
2.25.1
author
#19 lore raw

PATCH 9/14 dt-bindings: usb: Add Mediatek MT6370 TCPC binding documentation

In reply to ChiaEn Wu

From: ChiYuan Huang <[email protected]>

Add Mediatek MT6370 TCPC binding documentation.

---
 .../bindings/usb/mediatek,mt6370-tcpc.yaml    | 35 +++++++++++++++++++
 1 file changed, 35 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/usb/mediatek,mt6370-tcpc.yaml
Documentation/devicetree/bindings/usb/mediatek,mt6370-tcpc.yaml new file +35 -0
new file mode 100644
index 000000000000..49316633f92f
@@ -0,0 +1,35 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: "http://devicetree.org/schemas/usb/mediatek,mt6370-tcpc.yaml#"
+$schema: "http://devicetree.org/meta-schemas/core.yaml#"
+
+title: Mediatek MT6370 Type-C Port Switch and Power Delivery controller DT bindings
+
+maintainers:
+  - ChiYuan Huang <[email protected]>
+
+description: |
+  Mediatek MT6370 is a multi-functional device. It integrates charger, ADC, flash, RGB indicators,
+  regulators (DSV/VIBLDO), and TypeC Port Switch with Power Delivery controller.
+  This document only describes MT6370 Type-C Port Switch and Power Delivery controller.
+
+properties:
+  compatible:
+    enum:
+      - mediatek,mt6370-tcpc
+
+  interrupts:
+    maxItems: 1
+
+  connector:
+    type: object
+    $ref: /schemas/connector/usb-connector.yaml#
+    description:
+      Properties for usb c connector.
+
+additionalProperties: false
+
+required:
+  - compatible
+  - interrupts
Signature · 1 line
2.25.1
#20 lore raw

Re: [PATCH 09/14] dt-bindings: usb: Add Mediatek MT6370 TCPC binding documentation

Quoted 16 lines · ChiaEn Wu

From: ChiYuan Huang <[email protected]>

Add Mediatek MT6370 TCPC binding documentation.

---
 .../bindings/usb/mediatek,mt6370-tcpc.yaml    | 35 +++++++++++++++++++
 1 file changed, 35 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/usb/mediatek,mt6370-tcpc.yaml
Documentation/devicetree/bindings/usb/mediatek,mt6370-tcpc.yaml new file +0 -0
new file mode 100644
index 000000000000..49316633f92f

Documentation/devicetree/bindings/usb/mediatek,mt6370-tcpc.yaml line 7

Quoted 7 lines
Documentation/devicetree/bindings/usb/mediatek,mt6370-tcpc.yaml new file +7 -0
@@ -0,0 +1,35 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: "http://devicetree.org/schemas/usb/mediatek,mt6370-tcpc.yaml#"
+$schema: "http://devicetree.org/meta-schemas/core.yaml#"
+
+title: Mediatek MT6370 Type-C Port Switch and Power Delivery controller DT bindings

s/DT bindings//

Documentation/devicetree/bindings/usb/mediatek,mt6370-tcpc.yaml line 15

Quoted 8 lines
Documentation/devicetree/bindings/usb/mediatek,mt6370-tcpc.yaml new file +8 -0
+
+maintainers:
+  - ChiYuan Huang <[email protected]>
+
+description: |
+  Mediatek MT6370 is a multi-functional device. It integrates charger, ADC, flash, RGB indicators,
+  regulators (DSV/VIBLDO), and TypeC Port Switch with Power Delivery controller.
+  This document only describes MT6370 Type-C Port Switch and Power Delivery controller.

These lines do not look like wrapped at 80.

Documentation/devicetree/bindings/usb/mediatek,mt6370-tcpc.yaml line 27

Quoted 12 lines
Documentation/devicetree/bindings/usb/mediatek,mt6370-tcpc.yaml new file +12 -0
+
+properties:
+  compatible:
+    enum:
+      - mediatek,mt6370-tcpc
+
+  interrupts:
+    maxItems: 1
+
+  connector:
+    type: object
+    $ref: /schemas/connector/usb-connector.yaml#

You need unevaluatedProperties:false within connector.

Documentation/devicetree/bindings/usb/mediatek,mt6370-tcpc.yaml line 29

Quoted 2 lines
Documentation/devicetree/bindings/usb/mediatek,mt6370-tcpc.yaml new file +2 -0
+    description:
+      Properties for usb c connector.

Skip description, it's not helpful.

Documentation/devicetree/bindings/usb/mediatek,mt6370-tcpc.yaml line 35

Quoted 6 lines
Documentation/devicetree/bindings/usb/mediatek,mt6370-tcpc.yaml new file +6 -0
+
+additionalProperties: false
+
+required:
+  - compatible
+  - interrupts

Best regards,
Krzysztof

author
#21 lore raw

PATCH 10/14 dt-bindings: power: supply: Add Mediatek MT6370 Charger binding documentation

In reply to ChiaEn Wu

From: ChiaEn Wu <[email protected]>

Add Mediatek MT6370 Charger binding documentation.

---
 .../power/supply/mediatek,mt6370-charger.yaml | 60 +++++++++++++++++++
 1 file changed, 60 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/power/supply/mediatek,mt6370-charger.yaml
Documentation/devicetree/bindings/power/supply/mediatek,mt6370-charger.yaml new file +60 -0
new file mode 100644
index 000000000000..9d5c4487ca9c
@@ -0,0 +1,60 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/power/supply/mediatek,mt6370-charger.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Mediatek MT6370 Battery Charger
+
+maintainers:
+  - ChiaEn Wu <[email protected]>
+
+description: |
+  This module is part of the MT6370 MFD device.
+  Provides Battery Charger, Boost for OTG devices and BC1.2 detection.
+
+properties:
+  compatible:
+    const: mediatek,mt6370-charger
+
+  interrupts:
+    description: |
+      Specify what irqs are needed to be handled by MT6370 Charger driver. IRQ
+      "MT6370_IRQ_CHG_MIVR", "MT6370_IRQ_ATTACH" and "MT6370_IRQ_OVPCTRL_UVP_D"
+      are required.
+    items:
+      - description: BC1.2 done irq for mt6370 charger
+      - description: usb plug in irq for mt6370 charger
+      - description: mivr irq for mt6370 charger
+
+  interrupt-names:
+    items:
+      - const: attach_i
+      - const: uvp_d_evt
+      - const: mivr
+
+  io-channels:
+    description: |
+      Use ADC channel to read vbus, ibus, ibat, etc., info. Ibus ADC channel
+      is required.
+
+  usb-otg-vbus:
+    type: object
+    description: OTG boost regulator.
+    $ref: /schemas/regulator/regulator.yaml#
+
+    properties:
+      enable-gpio:
+        maxItems: 1
+        description: |
+          Specify a valid 'enable' gpio for the regulator and it's optional
+
+required:
+  - compatible
+  - interrupts
+  - interrupt-names
+  - io-channels
+
+additionalProperties: false
+
+...
Signature · 1 line
2.25.1
author
#22 lore raw

PATCH 11/14 dt-bindings: leds: mt6370: Add Mediatek mt6370 indicator documentation

In reply to ChiaEn Wu

From: ChiYuan Huang <[email protected]>

Add Mediatek mt6370 indicator documentation.

---
 .../leds/mediatek,mt6370-indicator.yaml       | 57 +++++++++++++++++++
 1 file changed, 57 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/leds/mediatek,mt6370-indicator.yaml
Documentation/devicetree/bindings/leds/mediatek,mt6370-indicator.yaml new file +57 -0
new file mode 100644
index 000000000000..823be3add097
@@ -0,0 +1,57 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/leds/mediatek,mt6370-indicator.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: LED driver for MT6370 PMIC from MediaTek Integrated.
+
+maintainers:
+  - Alice Chen <[email protected]>
+
+description: |
+  This module is part of the MT6370 MFD device.
+  see Documentation/devicetree/bindings/mfd/mediatek,mt6370.yaml
+  Add MT6370 LED driver include 4-channel RGB LED support Register/PWM/Breath Mode
+
+properties:
+  compatible:
+    const: mediatek,mt6370-indicator
+
+  "#address-cells":
+    const: 1
+
+  "#size-cells":
+    const: 0
+
+patternProperties:
+  "^(multi-)?led@[0-3]$":
+    description: |
+      Properties for a single LED.
+    $ref: common.yaml#
+    type: object
+
+    properties:
+      reg:
+        description: |
+          Index of the LED.
+        enum:
+          - 0 # LED output ISINK1
+          - 1 # LED output ISINK2
+          - 2 # LED output ISINK3
+          - 3 # LED output ISINK4
+
+      mediatek,soft-start:
+        description: |
+          soft start step control, support /0.5ms/1ms/1.5ms/2ms.
+        $ref: /schemas/types.yaml#/definitions/uint32
+        enum: [0, 1, 2, 3]
+
+    unevaluatedProperties: false
+
+required:
+  - compatible
+  - "#address-cells"
+  - "#size-cells"
+
+additionalProperties: false
Signature · 1 line
2.25.1
author
#23 lore raw

PATCH 12/14 dt-bindings: leds: Add Mediatek MT6370 flashlight binding documentation

In reply to ChiaEn Wu

From: Alice Chen <[email protected]>

Add Mediatek MT6370 flashlight binding documentation

---
 .../leds/mediatek,mt6370-flashlight.yaml      | 48 +++++++++++++++++++
 1 file changed, 48 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/leds/mediatek,mt6370-flashlight.yaml
Documentation/devicetree/bindings/leds/mediatek,mt6370-flashlight.yaml new file +48 -0
new file mode 100644
index 000000000000..b1b11bd3d410
@@ -0,0 +1,48 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/leds/leds-mt6370-flashlight.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Flash LED driver for MT6370 PMIC from MediaTek Integrated.
+
+maintainers:
+  - Alice Chen <[email protected]>
+
+description: |
+  This module is part of the MT6370 MFD device.
+  see Documentation/devicetree/bindings/mfd/mt6370.yaml
+  Add MT6370 flash LED driver include 2-channel flash LED support Torch/Strobe Mode.
+
+properties:
+  compatible:
+    const: mediatek,mt6370-flashlight
+
+  "#address-cells":
+    const: 1
+
+  "#size-cells":
+    const: 0
+
+patternProperties:
+  "^led@[0-1]$":
+    type: object
+    $ref: common.yaml#
+    description:
+      Properties for a single flash LED.
+
+    properties:
+      reg:
+        description: Index of the flash LED.
+        enum:
+          - 0 #Address of LED1
+          - 1 #Address of LED2
+
+    unevaluatedProperties: false
+
+required:
+  - compatible
+  - "#address-cells"
+  - "#size-cells"
+
+additionalProperties: false
Signature · 1 line
2.25.1
author
#24 lore raw

PATCH 13/14 dt-bindings: backlight: Add Mediatek MT6370 backlight binding documentation

In reply to ChiaEn Wu

From: ChiYuan Huang <[email protected]>

Add mt6370 backlight binding documentation.

---
 .../backlight/mediatek,mt6370-backlight.yaml  | 110 ++++++++++++++++++
 1 file changed, 110 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/leds/backlight/mediatek,mt6370-backlight.yaml
Documentation/devicetree/bindings/leds/backlight/mediatek,mt6370-backlight.yaml new file +110 -0
new file mode 100644
index 000000000000..81d72ed44be4
@@ -0,0 +1,110 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/leds/backlight/mediatek,mt6370-backlight.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Mediatek MT6370 Backlight
+
+maintainers:
+  - ChiaEn Wu <[email protected]>
+
+description: |
+  MT6370 is a highly-integrated smart power management IC, which includes a
+  single cell Li-Ion/Li-Polymer switching battery charger, a USB Type-C &
+  Power Delivery (PD) controller, dual flash LED current sources, a RGB LED
+  driver, a backlight WLED driver, a display bias driver and a general LDO for
+  portable devices.
+
+  For the LCD backlight, it can provide 4 channel WLED driving capability.
+  Each channel driving current is up to 30mA
+
+allOf:
+  - $ref: common.yaml#
+
+properties:
+  compatible:
+    const: mediatek,mt6370-backlight
+
+  default-brightness:
+    minimum: 0
+    maximum: 2048
+
+  max-brightness:
+    minimum: 0
+    maximum: 2048
+
+  enable-gpios:
+    description: External backlight 'enable' pin
+    maxItems: 1
+
+  mediatek,bled-pwm-enable:
+    description: |
+      Enable external PWM input for backlight dimming
+    type: boolean
+
+  mediatek,bled-pwm-hys-enable:
+    description: |
+      Enable the backlight input-hysteresis for PWM mode
+    type: boolean
+
+  mediatek,bled-pwm-hys-sel:
+    $ref: /schemas/types.yaml#/definitions/uint8
+    enum: [0, 1, 2, 3]
+    description: |
+      Backlight PWM hysteresis input level selection.
+      value mapping:
+        - 0: 1bit
+        - 1: 2bit
+        - 2: 4bit
+        - 3: 6bit
+
+  mediatek,bled-ovp-shutdown:
+    description: |
+      Enable the backlight shutdown when OVP level triggered
+    type: boolean
+
+  mediatek,bled-ovp-level-sel:
+    $ref: /schemas/types.yaml#/definitions/uint8
+    enum: [0, 1, 2, 3]
+    description: |
+      Backlight OVP level selection.
+      value mapping:
+        - 0: 17V
+        - 1: 21V
+        - 2: 25V
+        - 3: 29V
+
+  mediatek,bled-ocp-shutdown:
+    description: |
+      Enable the backlight shutdown when OCP level triggerred.
+    type: boolean
+
+  mediatek,bled-ocp-level-sel:
+    $ref: /schemas/types.yaml#/definitions/uint8
+    enum: [0, 1, 2, 3]
+    description: |
+      Backlight OC level selection.
+      value mapping:
+        - 0: 900mA
+        - 1: 1200mA
+        - 2: 1500mA
+        - 3: 1800mA
+
+  mediatek,bled-channel-use:
+    $ref: /schemas/types.yaml#/definitions/uint8
+    description: |
+      Backlight LED channel to be used.
+      Each bit mapping to:
+        - 0: CH4
+        - 1: CH3
+        - 2: CH2
+        - 3: CH1
+    minimum: 1
+    maximum: 15
+
+required:
+  - compatible
+  - mediatek,bled-channel-use
+
+additionalProperties: false
Signature · 1 line
2.25.1
#25 lore raw

Re: [PATCH 13/14] dt-bindings: backlight: Add Mediatek MT6370 backlight binding documentation

Quoted 23 lines · ChiaEn Wu

From: ChiYuan Huang <[email protected]>

Add mt6370 backlight binding documentation.

---
 .../backlight/mediatek,mt6370-backlight.yaml  | 110 ++++++++++++++++++
 1 file changed, 110 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/leds/backlight/mediatek,mt6370-backlight.yaml
Documentation/devicetree/bindings/leds/backlight/mediatek,mt6370-backlight.yaml new file +7 -0
new file mode 100644
index 000000000000..81d72ed44be4
@@ -0,0 +1,110 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/leds/backlight/mediatek,mt6370-backlight.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Mediatek MT6370 Backlight

Documentation/devicetree/bindings/leds/backlight/mediatek,mt6370-backlight.yaml line 17

Quoted 10 lines
Documentation/devicetree/bindings/leds/backlight/mediatek,mt6370-backlight.yaml new file +10 -0
+
+maintainers:
+  - ChiaEn Wu <[email protected]>
+
+description: |
+  MT6370 is a highly-integrated smart power management IC, which includes a
+  single cell Li-Ion/Li-Polymer switching battery charger, a USB Type-C &
+  Power Delivery (PD) controller, dual flash LED current sources, a RGB LED
+  driver, a backlight WLED driver, a display bias driver and a general LDO for
+  portable devices.

Do not repeat entire device description, but describe only this part. Your other pieces of MFD were doing it correctly, so why here it is different?

Quoted 33 lines
Documentation/devicetree/bindings/leds/backlight/mediatek,mt6370-backlight.yaml new file +33 -0
+
+  For the LCD backlight, it can provide 4 channel WLED driving capability.
+  Each channel driving current is up to 30mA
+
+allOf:
+  - $ref: common.yaml#
+
+properties:
+  compatible:
+    const: mediatek,mt6370-backlight
+
+  default-brightness:
+    minimum: 0
+    maximum: 2048
+
+  max-brightness:
+    minimum: 0
+    maximum: 2048
+
+  enable-gpios:
+    description: External backlight 'enable' pin
+    maxItems: 1
+
+  mediatek,bled-pwm-enable:
+    description: |
+      Enable external PWM input for backlight dimming
+    type: boolean
+
+  mediatek,bled-pwm-hys-enable:
+    description: |
+      Enable the backlight input-hysteresis for PWM mode
+    type: boolean
+

Documentation/devicetree/bindings/leds/backlight/mediatek,mt6370-backlight.yaml line 60

Quoted 10 lines
Documentation/devicetree/bindings/leds/backlight/mediatek,mt6370-backlight.yaml new file +10 -0
+  mediatek,bled-pwm-hys-sel:
+    $ref: /schemas/types.yaml#/definitions/uint8
+    enum: [0, 1, 2, 3]
+    description: |
+      Backlight PWM hysteresis input level selection.
+      value mapping:
+        - 0: 1bit
+        - 1: 2bit
+        - 2: 4bit
+        - 3: 6bit

Please explain what is this input level and what is the meaning of 6bit... In any case you cannot have values mapping, but instead you should use the logical values (so 1, 2, 4, and 6).

If "sel" is shortcut of "selection" please drop it.

Quoted 6 lines
Documentation/devicetree/bindings/leds/backlight/mediatek,mt6370-backlight.yaml new file +6 -0
+
+  mediatek,bled-ovp-shutdown:
+    description: |
+      Enable the backlight shutdown when OVP level triggered
+    type: boolean
+

Documentation/devicetree/bindings/leds/backlight/mediatek,mt6370-backlight.yaml line 76

Quoted 10 lines
Documentation/devicetree/bindings/leds/backlight/mediatek,mt6370-backlight.yaml new file +10 -0
+  mediatek,bled-ovp-level-sel:
+    $ref: /schemas/types.yaml#/definitions/uint8
+    enum: [0, 1, 2, 3]
+    description: |
+      Backlight OVP level selection.
+      value mapping:
+        - 0: 17V
+        - 1: 21V
+        - 2: 25V
+        - 3: 29V

Logical values in microvolts. Name it according to unit suffices and drop any useless parts of property name like "level selection". It is simply - mediatek,bled-ovp-microvolt.

Quoted 6 lines
Documentation/devicetree/bindings/leds/backlight/mediatek,mt6370-backlight.yaml new file +6 -0
+
+  mediatek,bled-ocp-shutdown:
+    description: |
+      Enable the backlight shutdown when OCP level triggerred.
+    type: boolean
+

Documentation/devicetree/bindings/leds/backlight/mediatek,mt6370-backlight.yaml line 92

Quoted 10 lines
Documentation/devicetree/bindings/leds/backlight/mediatek,mt6370-backlight.yaml new file +10 -0
+  mediatek,bled-ocp-level-sel:
+    $ref: /schemas/types.yaml#/definitions/uint8
+    enum: [0, 1, 2, 3]
+    description: |
+      Backlight OC level selection.
+      value mapping:
+        - 0: 900mA
+        - 1: 1200mA
+        - 2: 1500mA
+        - 3: 1800mA

Same comments.

Quoted 7 lines
Documentation/devicetree/bindings/leds/backlight/mediatek,mt6370-backlight.yaml new file +7 -0
+
+  mediatek,bled-channel-use:
+    $ref: /schemas/types.yaml#/definitions/uint8
+    description: |
+      Backlight LED channel to be used.
+      Each bit mapping to:
+        - 0: CH4

Documentation/devicetree/bindings/leds/backlight/mediatek,mt6370-backlight.yaml line 110

Quoted 10 lines
Documentation/devicetree/bindings/leds/backlight/mediatek,mt6370-backlight.yaml new file +10 -0
+        - 1: CH3
+        - 2: CH2
+        - 3: CH1> +    minimum: 1
+    maximum: 15
+
+required:
+  - compatible
+  - mediatek,bled-channel-use
+
+additionalProperties: false

Best regards,
Krzysztof

author
#26 lore raw

PATCH 14/14 dt-bindings: mfd: Add Mediatek MT6370 binding documentation

In reply to ChiaEn Wu

From: ChiYuan Huang <[email protected]>

Add Mediatek MT6370 binding documentation.

---
 .../bindings/mfd/mediatek,mt6370.yaml         | 282 ++++++++++++++++++
 .../dt-bindings/iio/adc/mediatek,mt6370_adc.h |  18 ++
 include/dt-bindings/mfd/mediatek,mt6370.h     |  83 ++++++
 3 files changed, 383 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/mfd/mediatek,mt6370.yaml
 create mode 100644 include/dt-bindings/iio/adc/mediatek,mt6370_adc.h
 create mode 100644 include/dt-bindings/mfd/mediatek,mt6370.h
Documentation/devicetree/bindings/mfd/mediatek,mt6370.yaml new file +282 -0
new file mode 100644
index 000000000000..96a12dce0108
@@ -0,0 +1,282 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/mfd/mediatek,mt6370.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Mediatek MT6370 SubPMIC
+
+maintainers:
+  - ChiYuan Huang <[email protected]>
+
+description: |
+  MT6370 is a highly-integrated smart power management IC, which includes a
+  single cell Li-Ion/Li-Polymer switching battery charger, a USB Type-C &
+  Power Delivery (PD) controller, dual flash LED current sources, a RGB LED
+  driver, a backlight WLED driver, a display bias driver and a general LDO for
+  portable devices.
+
+properties:
+  compatible:
+    const: mediatek,mt6370
+
+  reg:
+    maxItems: 1
+
+  wakeup-source: true
+
+  interrupts:
+    maxItems: 1
+
+  interrupt-controller: true
+
+  '#interrupt-cells':
+    const: 1
+
+  adc:
+    type: object
+    description: |
+      List the compatible configurations of MT6370 ADC.
+
+    properties:
+      compatible:
+        const: mediatek,mt6370-adc
+
+      "#io-channel-cells":
+        const: 1
+
+    required:
+      - compatible
+      - '#io-channel-cells'
+
+  backlight:
+    type: object
+    $ref: /schemas/leds/backlight/mediatek,mt6370-backlight.yaml#
+
+  charger:
+    type: object
+    $ref: /schemas/power/supply/mediatek,mt6370-charger.yaml#
+
+  tcpc:
+    type: object
+    $ref: /schemas/usb/mediatek,mt6370-tcpc.yaml#
+
+  indicator:
+    type: object
+    $ref: /schemas/leds/mediatek,mt6370-indicator.yaml#
+
+  flashlight:
+    type: object
+    $ref: /schemas/leds/mediatek,mt6370-flashlight.yaml#
+
+  regulators:
+    type: object
+    description: |
+      List all supported regulators
+
+    patternProperties:
+      "^(dsvbst|vibldo)$":
+        $ref: /schemas/regulator/regulator.yaml#
+        type: object
+        unevaluatedProperties: false
+
+      "^(dsvpos|dsvneg)$":
+        $ref: /schemas/regulator/regulator.yaml#
+        type: object
+        unevaluatedProperties: false
+
+        properties:
+          enable-gpio:
+            maxItems: 1
+            description: |
+              Specify a valid 'enable' gpio for the regulator and it's optional
+
+required:
+  - compatible
+  - reg
+  - interrupts
+  - interrupt-controller
+  - '#interrupt-cells'
+  - regulators
+  - adc
+  - backlight
+  - indicator
+  - tcpc
+  - charger
+  - flashlight
+
+additionalProperties: false
+
+examples:
+  - |
+    #include <dt-bindings/interrupt-controller/irq.h>
+    #include <dt-bindings/leds/common.h>
+    #include <dt-bindings/mfd/mediatek,mt6370.h>
+    #include <dt-bindings/iio/adc/mediatek,mt6370_adc.h>
+    #include <dt-bindings/usb/pd.h>
+    i2c {
+      #address-cells = <1>;
+      #size-cells = <0>;
+
+      mt6370@34 {
+        compatible = "mediatek,mt6370";
+        reg = <0x34>;
+        wakeup-source;
+        interrupts-extended = <&gpio26 3 IRQ_TYPE_LEVEL_LOW>;
+        interrupt-controller;
+        #interrupt-cells = <1>;
+
+        mt6370_adc: adc {
+          compatible = "mediatek,mt6370-adc";
+          #io-channel-cells = <1>;
+        };
+
+        backlight {
+          compatible = "mediatek,mt6370-backlight";
+          mediatek,bled-channel-use = /bits/ 8 <15>;
+        };
+
+        charger {
+          compatible = "mediatek,mt6370-charger";
+          interrupts = <MT6370_IRQ_ATTACH>, <MT6370_IRQ_OVPCTRL_UVP_D>,
+                       <MT6370_IRQ_CHG_MIVR>;
+          interrupt-names = "attach_i", "uvp_d_evt", "mivr";
+          io-channels = <&mt6370_adc MT6370_CHAN_IBUS>;
+
+          mt6370_otg_vbus: usb-otg-vbus {
+            regulator-compatible = "mt6370,otg-vbus";
+            regulator-name = "usb-otg-vbus";
+            regulator-min-microvolt = <4350000>;
+            regulator-max-microvolt = <5800000>;
+            regulator-min-microamp = <500000>;
+            regulator-max-microamp = <3000000>;
+          };
+        };
+
+        indicator {
+          compatible = "mediatek,mt6370-indicator";
+          #address-cells = <1>;
+          #size-cells = <0>;
+
+          multi-led@0 {
+            reg = <0>;
+            function = LED_FUNCTION_INDICATOR;
+            color = <LED_COLOR_ID_RGB>;
+            led-max-microamp = <24000>;
+            #address-cells = <1>;
+            #size-cells = <0>;
+            mediatek,soft-start = <3>;
+              led@0 {
+                reg = <0>;
+                color = <LED_COLOR_ID_RED>;
+              };
+              led@1 {
+                reg = <1>;
+                color = <LED_COLOR_ID_GREEN>;
+              };
+              led@2 {
+                reg = <2>;
+                color = <LED_COLOR_ID_BLUE>;
+              };
+            };
+          led@3 {
+            reg = <3>;
+            function = LED_FUNCTION_INDICATOR;
+            color = <LED_COLOR_ID_WHITE>;
+            led-max-microamp = <6000>;
+          };
+        };
+
+        flashlight {
+          compatible = "mediatek,mt6370-flashlight";
+          #address-cells = <1>;
+          #size-cells = <0>;
+          led@0 {
+            reg = <0>;
+            led-sources = <0>;
+            function = LED_FUNCTION_FLASH;
+            color = <LED_COLOR_ID_WHITE>;
+            function-enumerator = <1>;
+            led-max-microamp = <200000>;
+            flash-max-microamp = <500000>;
+            flash-max-timeout-us = <1248000>;
+          };
+          led@1 {
+            reg = <1>;
+            led-sources = <1>;
+            function = LED_FUNCTION_FLASH;
+            color = <LED_COLOR_ID_WHITE>;
+            function-enumerator = <2>;
+            led-max-microamp = <200000>;
+            flash-max-microamp = <500000>;
+            flash-max-timeout-us = <1248000>;
+          };
+        };
+
+        tcpc {
+          compatible = "mediatek,mt6370-tcpc";
+          interrupts-extended = <&gpio26 4 IRQ_TYPE_LEVEL_LOW>;
+
+          connector {
+            compatible = "usb-c-connector";
+            label = "USB-C";
+            vbus-supply = <&mt6370_otg_vbus>;
+            data-role = "dual";
+            power-role = "dual";
+            try-power-role = "sink";
+            source-pdos = <PDO_FIXED(5000, 1000, PDO_FIXED_DUAL_ROLE | PDO_FIXED_DATA_SWAP)>;
+            sink-pdos = <PDO_FIXED(5000, 2000, PDO_FIXED_DUAL_ROLE | PDO_FIXED_DATA_SWAP)>;
+            op-sink-microwatt = <10000000>;
+
+            ports {
+              #address-cells = <1>;
+              #size-cells = <0>;
+
+              port@0 {
+                reg = <0>;
+                endpoint {
+                  remote-endpoint = <&usb_hs>;
+                };
+              };
+              port@1 {
+                reg = <1>;
+                endpoint {
+                  remote-endpoint = <&usb_ss>;
+                };
+              };
+              port@2 {
+                reg = <2>;
+                endpoint {
+                  remote-endpoint = <&dp_aux>;
+                };
+              };
+            };
+          };
+        };
+
+        regulators {
+          dsvbst {
+            regulator-name = "mt6370-dsv-vbst";
+            regulator-min-microvolt = <4000000>;
+            regulator-max-microvolt = <6200000>;
+          };
+          dsvpos {
+            regulator-name = "mt6370-dsv-vpos";
+            regulator-min-microvolt = <4000000>;
+            regulator-max-microvolt = <6000000>;
+            regulator-boot-on;
+          };
+          dsvneg {
+            regulator-name = "mt6370-dsv-vneg";
+            regulator-min-microvolt = <4000000>;
+            regulator-max-microvolt = <6000000>;
+            regulator-boot-on;
+          };
+          vibldo {
+            regulator-name = "mt6370-vib-ldo";
+            regulator-min-microvolt = <1600000>;
+            regulator-max-microvolt = <4000000>;
+          };
+        };
+      };
+    };
include/dt-bindings/iio/adc/mediatek,mt6370_adc.h new file +18 -0
new file mode 100644
index 000000000000..18ce2fef8f9e
@@ -0,0 +1,18 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+
+#ifndef __DT_BINDINGS_MEDIATEK_MT6370_ADC_H__
+#define __DT_BINDINGS_MEDIATEK_MT6370_ADC_H__
+
+/* ADC Channel Index */
+#define MT6370_CHAN_VBUSDIV5	0
+#define MT6370_CHAN_VBUSDIV2	1
+#define MT6370_CHAN_VSYS	2
+#define MT6370_CHAN_VBAT	3
+#define MT6370_CHAN_TS_BAT	4
+#define MT6370_CHAN_IBUS	5
+#define MT6370_CHAN_IBAT	6
+#define MT6370_CHAN_CHG_VDDP	7
+#define MT6370_CHAN_TEMP_JC	8
+#define MT6370_CHAN_MAX		9
+
+#endif
include/dt-bindings/mfd/mediatek,mt6370.h new file +83 -0

83 lines not on this page · raw message

Signature · 7 lines
2.25.1


_______________________________________________
Linux-mediatek mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-mediatek
#27 lore raw

Re: [PATCH 14/14] dt-bindings: mfd: Add Mediatek MT6370 binding documentation

Quoted 3 lines · ChiaEn Wu

From: ChiYuan Huang <[email protected]>

Add Mediatek MT6370 binding documentation.

Subject: same as previous patches.

Quoted 46 lines
---
 .../bindings/mfd/mediatek,mt6370.yaml         | 282 ++++++++++++++++++
 .../dt-bindings/iio/adc/mediatek,mt6370_adc.h |  18 ++
 include/dt-bindings/mfd/mediatek,mt6370.h     |  83 ++++++
 3 files changed, 383 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/mfd/mediatek,mt6370.yaml
 create mode 100644 include/dt-bindings/iio/adc/mediatek,mt6370_adc.h
 create mode 100644 include/dt-bindings/mfd/mediatek,mt6370.h
Documentation/devicetree/bindings/mfd/mediatek,mt6370.yaml new file +29 -0
new file mode 100644
index 000000000000..96a12dce0108
@@ -0,0 +1,282 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/mfd/mediatek,mt6370.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Mediatek MT6370 SubPMIC
+
+maintainers:
+  - ChiYuan Huang <[email protected]>
+
+description: |
+  MT6370 is a highly-integrated smart power management IC, which includes a
+  single cell Li-Ion/Li-Polymer switching battery charger, a USB Type-C &
+  Power Delivery (PD) controller, dual flash LED current sources, a RGB LED
+  driver, a backlight WLED driver, a display bias driver and a general LDO for
+  portable devices.
+
+properties:
+  compatible:
+    const: mediatek,mt6370
+
+  reg:
+    maxItems: 1
+
+  wakeup-source: true
+
+  interrupts:
+    maxItems: 1

Documentation/devicetree/bindings/mfd/mediatek,mt6370.yaml line 39

Quoted 10 lines
Documentation/devicetree/bindings/mfd/mediatek,mt6370.yaml new file +10 -0
+
+  interrupt-controller: true
+
+  '#interrupt-cells':
+    const: 1
+
+  adc:
+    type: object
+    description: |
+      List the compatible configurations of MT6370 ADC.

This sentence does not make any sense. The "description" field is to describe, explain the meaning behind given property.

Quoted 26 lines
Documentation/devicetree/bindings/mfd/mediatek,mt6370.yaml new file +26 -0
+
+    properties:
+      compatible:
+        const: mediatek,mt6370-adc
+
+      "#io-channel-cells":
+        const: 1
+
+    required:
+      - compatible
+      - '#io-channel-cells'
+
+  backlight:
+    type: object
+    $ref: /schemas/leds/backlight/mediatek,mt6370-backlight.yaml#
+
+  charger:
+    type: object
+    $ref: /schemas/power/supply/mediatek,mt6370-charger.yaml#
+
+  tcpc:
+    type: object
+    $ref: /schemas/usb/mediatek,mt6370-tcpc.yaml#
+
+  indicator:
+    type: object

Documentation/devicetree/bindings/mfd/mediatek,mt6370.yaml line 75

Quoted 10 lines
Documentation/devicetree/bindings/mfd/mediatek,mt6370.yaml new file +10 -0
+    $ref: /schemas/leds/mediatek,mt6370-indicator.yaml#
+
+  flashlight:
+    type: object
+    $ref: /schemas/leds/mediatek,mt6370-flashlight.yaml#
+
+  regulators:
+    type: object
+    description: |
+      List all supported regulators

Ditto

Quoted 7 lines
Documentation/devicetree/bindings/mfd/mediatek,mt6370.yaml new file +7 -0
+
+    patternProperties:
+      "^(dsvbst|vibldo)$":
+        $ref: /schemas/regulator/regulator.yaml#
+        type: object
+        unevaluatedProperties: false
+

Documentation/devicetree/bindings/mfd/mediatek,mt6370.yaml line 92

Quoted 10 lines
Documentation/devicetree/bindings/mfd/mediatek,mt6370.yaml new file +10 -0
+      "^(dsvpos|dsvneg)$":
+        $ref: /schemas/regulator/regulator.yaml#
+        type: object
+        unevaluatedProperties: false
+
+        properties:
+          enable-gpio:
+            maxItems: 1
+            description: |
+              Specify a valid 'enable' gpio for the regulator and it's optional

Same comment as your patch #10.

Quoted 19 lines
Documentation/devicetree/bindings/mfd/mediatek,mt6370.yaml new file +19 -0
+
+required:
+  - compatible
+  - reg
+  - interrupts
+  - interrupt-controller
+  - '#interrupt-cells'
+  - regulators
+  - adc
+  - backlight
+  - indicator
+  - tcpc
+  - charger
+  - flashlight
+
+additionalProperties: false
+
+examples:
+  - |

Documentation/devicetree/bindings/mfd/mediatek,mt6370.yaml line 121

Quoted 10 lines
Documentation/devicetree/bindings/mfd/mediatek,mt6370.yaml new file +10 -0
+    #include <dt-bindings/interrupt-controller/irq.h>
+    #include <dt-bindings/leds/common.h>
+    #include <dt-bindings/mfd/mediatek,mt6370.h>
+    #include <dt-bindings/iio/adc/mediatek,mt6370_adc.h>
+    #include <dt-bindings/usb/pd.h>
+    i2c {
+      #address-cells = <1>;
+      #size-cells = <0>;
+
+      mt6370@34 {

Generic node name, so "pmic".

Quoted 38 lines
Documentation/devicetree/bindings/mfd/mediatek,mt6370.yaml new file +38 -0
+        compatible = "mediatek,mt6370";
+        reg = <0x34>;
+        wakeup-source;
+        interrupts-extended = <&gpio26 3 IRQ_TYPE_LEVEL_LOW>;
+        interrupt-controller;
+        #interrupt-cells = <1>;
+
+        mt6370_adc: adc {
+          compatible = "mediatek,mt6370-adc";
+          #io-channel-cells = <1>;
+        };
+
+        backlight {
+          compatible = "mediatek,mt6370-backlight";
+          mediatek,bled-channel-use = /bits/ 8 <15>;
+        };
+
+        charger {
+          compatible = "mediatek,mt6370-charger";
+          interrupts = <MT6370_IRQ_ATTACH>, <MT6370_IRQ_OVPCTRL_UVP_D>,
+                       <MT6370_IRQ_CHG_MIVR>;
+          interrupt-names = "attach_i", "uvp_d_evt", "mivr";
+          io-channels = <&mt6370_adc MT6370_CHAN_IBUS>;
+
+          mt6370_otg_vbus: usb-otg-vbus {
+            regulator-compatible = "mt6370,otg-vbus";
+            regulator-name = "usb-otg-vbus";
+            regulator-min-microvolt = <4350000>;
+            regulator-max-microvolt = <5800000>;
+            regulator-min-microamp = <500000>;
+            regulator-max-microamp = <3000000>;
+          };
+        };
+
+        indicator {
+          compatible = "mediatek,mt6370-indicator";
+          #address-cells = <1>;
+          #size-cells = <0>;

Documentation/devicetree/bindings/mfd/mediatek,mt6370.yaml line 169

Quoted 10 lines
Documentation/devicetree/bindings/mfd/mediatek,mt6370.yaml new file +10 -0
+
+          multi-led@0 {
+            reg = <0>;
+            function = LED_FUNCTION_INDICATOR;
+            color = <LED_COLOR_ID_RGB>;
+            led-max-microamp = <24000>;
+            #address-cells = <1>;
+            #size-cells = <0>;
+            mediatek,soft-start = <3>;
+              led@0 {

Messed up indentation.

Quoted 119 lines
Documentation/devicetree/bindings/mfd/mediatek,mt6370.yaml new file +113 -0
+                reg = <0>;
+                color = <LED_COLOR_ID_RED>;
+              };
+              led@1 {
+                reg = <1>;
+                color = <LED_COLOR_ID_GREEN>;
+              };
+              led@2 {
+                reg = <2>;
+                color = <LED_COLOR_ID_BLUE>;
+              };
+            };
+          led@3 {
+            reg = <3>;
+            function = LED_FUNCTION_INDICATOR;
+            color = <LED_COLOR_ID_WHITE>;
+            led-max-microamp = <6000>;
+          };
+        };
+
+        flashlight {
+          compatible = "mediatek,mt6370-flashlight";
+          #address-cells = <1>;
+          #size-cells = <0>;
+          led@0 {
+            reg = <0>;
+            led-sources = <0>;
+            function = LED_FUNCTION_FLASH;
+            color = <LED_COLOR_ID_WHITE>;
+            function-enumerator = <1>;
+            led-max-microamp = <200000>;
+            flash-max-microamp = <500000>;
+            flash-max-timeout-us = <1248000>;
+          };
+          led@1 {
+            reg = <1>;
+            led-sources = <1>;
+            function = LED_FUNCTION_FLASH;
+            color = <LED_COLOR_ID_WHITE>;
+            function-enumerator = <2>;
+            led-max-microamp = <200000>;
+            flash-max-microamp = <500000>;
+            flash-max-timeout-us = <1248000>;
+          };
+        };
+
+        tcpc {
+          compatible = "mediatek,mt6370-tcpc";
+          interrupts-extended = <&gpio26 4 IRQ_TYPE_LEVEL_LOW>;
+
+          connector {
+            compatible = "usb-c-connector";
+            label = "USB-C";
+            vbus-supply = <&mt6370_otg_vbus>;
+            data-role = "dual";
+            power-role = "dual";
+            try-power-role = "sink";
+            source-pdos = <PDO_FIXED(5000, 1000, PDO_FIXED_DUAL_ROLE | PDO_FIXED_DATA_SWAP)>;
+            sink-pdos = <PDO_FIXED(5000, 2000, PDO_FIXED_DUAL_ROLE | PDO_FIXED_DATA_SWAP)>;
+            op-sink-microwatt = <10000000>;
+
+            ports {
+              #address-cells = <1>;
+              #size-cells = <0>;
+
+              port@0 {
+                reg = <0>;
+                endpoint {
+                  remote-endpoint = <&usb_hs>;
+                };
+              };
+              port@1 {
+                reg = <1>;
+                endpoint {
+                  remote-endpoint = <&usb_ss>;
+                };
+              };
+              port@2 {
+                reg = <2>;
+                endpoint {
+                  remote-endpoint = <&dp_aux>;
+                };
+              };
+            };
+          };
+        };
+
+        regulators {
+          dsvbst {
+            regulator-name = "mt6370-dsv-vbst";
+            regulator-min-microvolt = <4000000>;
+            regulator-max-microvolt = <6200000>;
+          };
+          dsvpos {
+            regulator-name = "mt6370-dsv-vpos";
+            regulator-min-microvolt = <4000000>;
+            regulator-max-microvolt = <6000000>;
+            regulator-boot-on;
+          };
+          dsvneg {
+            regulator-name = "mt6370-dsv-vneg";
+            regulator-min-microvolt = <4000000>;
+            regulator-max-microvolt = <6000000>;
+            regulator-boot-on;
+          };
+          vibldo {
+            regulator-name = "mt6370-vib-ldo";
+            regulator-min-microvolt = <1600000>;
+            regulator-max-microvolt = <4000000>;
+          };
+        };
+      };
+    };
include/dt-bindings/iio/adc/mediatek,mt6370_adc.h new file +0 -0
new file mode 100644
index 000000000000..18ce2fef8f9e

include/dt-bindings/iio/adc/mediatek,mt6370_adc.h line 1

Quoted 1 line
include/dt-bindings/iio/adc/mediatek,mt6370_adc.h new file +1 -0
@@ -0,0 +1,18 @@
+/* SPDX-License-Identifier: GPL-2.0 */

Same license as bindings, please.

Quoted 23 lines
include/dt-bindings/iio/adc/mediatek,mt6370_adc.h new file +17 -0
+
+#ifndef __DT_BINDINGS_MEDIATEK_MT6370_ADC_H__
+#define __DT_BINDINGS_MEDIATEK_MT6370_ADC_H__
+
+/* ADC Channel Index */
+#define MT6370_CHAN_VBUSDIV5	0
+#define MT6370_CHAN_VBUSDIV2	1
+#define MT6370_CHAN_VSYS	2
+#define MT6370_CHAN_VBAT	3
+#define MT6370_CHAN_TS_BAT	4
+#define MT6370_CHAN_IBUS	5
+#define MT6370_CHAN_IBAT	6
+#define MT6370_CHAN_CHG_VDDP	7
+#define MT6370_CHAN_TEMP_JC	8
+#define MT6370_CHAN_MAX		9
+
+#endif
include/dt-bindings/mfd/mediatek,mt6370.h new file +0 -0
new file mode 100644
index 000000000000..df641e5d651f

include/dt-bindings/mfd/mediatek,mt6370.h line 1

Quoted 1 line
include/dt-bindings/mfd/mediatek,mt6370.h new file +1 -0
@@ -0,0 +1,83 @@
+/* SPDX-License-Identifier: GPL-2.0 */

Same license as bindings, please.

include/dt-bindings/mfd/mediatek,mt6370.h line 8

Quoted 8 lines
include/dt-bindings/mfd/mediatek,mt6370.h new file +7 -0
+
+#ifndef __DT_BINDINGS_MEDIATEK_MT6370_H__
+#define __DT_BINDINGS_MEDIATEK_MT6370_H__
+
+/* IRQ definitions */
 
+#define MT6370_IRQ_DIRCHGON		0
+#define MT6370_IRQ_CHG_TREG		4

These should be IDs, so numbers incremented by one. Holes are not accepted. There is no point in encoding actual hardware numbers which are directly passed to implementation. Just pass the number, not define. Therefore remove entire file.

include/dt-bindings/mfd/mediatek,mt6370.h line 12

Quoted 4 lines
include/dt-bindings/mfd/mediatek,mt6370.h new file +4 -0
+#define MT6370_IRQ_CHG_AICR		5
+#define MT6370_IRQ_CHG_MIVR		6
+#define MT6370_IRQ_PWR_RDY		7
+#define MT6370_IRQ_FL_CHG_VINOVP	11

Best regards,
Krzysztof