Add Mediatek MT6370 PMIC support
Subsystems (12)
v2 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.
Among with this we took some changes and refined the device tree files to comply with DT specifications.
Thank you,
ChiaEn Wu
---
Changes in v2:
- In patch 01/15:
- Add "unevaluatedProperties: false".
- Delete "DT bindings".
- Refine the description to fit in 80 columns.
- Skip the connector description.
- In patch 02/15:
- Refine items description of interrupt-name
- Rename "usb-otg-vbus" to "usb-otg-vbus-regulator"
- Add constraint properties for ADC
- In patch 03/15:
- Skip not useful description of "^(multi-)?led@[0-3]$" and reg.
- Due to the dependency, remove the mention of mfd document directory.
- Delete Soft-start property. In design aspect, we think soft-restart should always be enabled, our new chip has deleted the related setting register , also, we don’t allow user adjust this parameter in this chip.
- Refine the commit message.
- In patch 04/15:
- Skip not useful description of "^led@[0-1]$" and reg.
- Add apace after '#'.
- Refine the commit message.
- In patch 05/15:
- Remove "binding documentation" in subject title
- Refine description of mt6370 backlight binding document
- Refine properties name(bled-pwm-hys-input-bit, bled-ovp-microvolt, bled-ocp-microamp) and their description
- In patch 06/15:
- Refine ADC and Regulator descriptions
- Refine include header usage in example
- Refine node name to generic node name("pmic@34")
- Refine led example indentation
- Refine license of mediatek,mt6370_adc.h
- Rename the dts example from IRQ define to number.
- Remove mediatek,mt6370.h
- In patch 07/15:
- Add ABI documentation for mt6370 non-standard ADC sysfs interfaces.
- In patch 08/15:
- Add all IRQ define into mt6370.c.
- Refine include header usage
- In patch 09/15:
- No changes.
- In patch 10/15:
- Use 'gpiod_get_from_of_node' to replace 'fwnode_gpiod_get_index'.
- In patch 11/15:
- Refine Kconfig mt6370 help text
- Refine mask&shift to FIELD_PREP()
- Refine mutex lock name ("lock" -> "adc_lock")
- Refine mt6370_adc_read_scale()
- Refine mt6370_adc_read_offset()
- Refine mt6370_channel_labels[] by using enum to index chan spec
- Refine MT6370_ADC_CHAN()
- Refine indio_dev->name
- Remove useless include header files
- In patch 12/15:
- Refine mt6370_chg_otg_rdesc.of_match
("mt6370,otg-vbus" -> "usb-otg-vbus-regulator") to match
DT binding- In patch 13/15:
- Refine Kconfig description.
- Remove include "linux/of.h" and use "linux/mod_devicetable.h".
- Place a comma for the last element of the const unsigned int array.
- Add a comment line for the mutex 'lock'.
- In probe function, use 'dev_err_probe' in some judgement to reduce the LOC.
- Refine include header usage.
BIT/GENMASK -> linux/bits.h
FIELD_GET -> linux/bitfield.h
- In patch 14/15:
- Add blank line.
- Replace container_of() with to_mt6370_led() .
- Refine description of ramping.
- Refine the mt6370_init_common_properties function.
- Refine the probe return.
- In patch 15/15:
- Refine MT6370 help text in Kconfig
- Refine DT Parse function
- Remove useless enum
- Add comment for 6372 backward compatible in bl_update_status() and check_vendor_info()
- Using dev_err_probe(); insteads dev_err()&return; in the probe()
Alice Chen (2):
dt-bindings: leds: Add Mediatek MT6370 flashlight
leds: flashlight: mt6370: Add Mediatek MT6370 flashlight support
ChiYuan Huang (8):
dt-bindings: usb: Add Mediatek MT6370 TCPC
dt-bindings: leds: mt6370: Add Mediatek mt6370 current sink type LED
indicator
dt-bindings: backlight: Add Mediatek MT6370 backlight
dt-bindings: mfd: Add Mediatek MT6370
mfd: mt6370: Add Mediatek MT6370 support
usb: typec: tcpci_mt6370: Add Mediatek MT6370 tcpci driver
regulator: mt6370: Add mt6370 DisplayBias and VibLDO support
leds: mt6370: Add Mediatek MT6370 current sink type LED Indicator
support
ChiaEn Wu (5):
dt-bindings: power: supply: Add Mediatek MT6370 Charger
Documentation: ABI: testing: mt6370: Add ADC sysfs guideline
iio: adc: mt6370: Add Mediatek MT6370 support
power: supply: mt6370: Add Mediatek MT6370 charger driver
video: backlight: mt6370: Add Mediatek MT6370 support
.../ABI/testing/sysfs-bus-iio-adc-mt6370 | 36 + .../backlight/mediatek,mt6370-backlight.yaml | 107 ++ .../leds/mediatek,mt6370-flashlight.yaml | 44 + .../leds/mediatek,mt6370-indicator.yaml | 48 + .../bindings/mfd/mediatek,mt6370.yaml | 279 ++++ .../power/supply/mediatek,mt6370-charger.yaml | 60 + .../bindings/usb/mediatek,mt6370-tcpc.yaml | 36 + drivers/iio/adc/Kconfig | 9 + drivers/iio/adc/Makefile | 1 + drivers/iio/adc/mt6370-adc.c | 262 ++++ 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 | 657 ++++++++++ drivers/leds/leds-mt6370.c | 989 ++++++++++++++ drivers/mfd/Kconfig | 13 + drivers/mfd/Makefile | 1 + drivers/mfd/mt6370.c | 349 +++++ 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 | 388 ++++++ drivers/usb/typec/tcpm/Kconfig | 8 + drivers/usb/typec/tcpm/Makefile | 1 + drivers/usb/typec/tcpm/tcpci_mt6370.c | 212 +++ drivers/video/backlight/Kconfig | 9 + drivers/video/backlight/Makefile | 1 + drivers/video/backlight/mt6370-backlight.c | 339 +++++ .../dt-bindings/iio/adc/mediatek,mt6370_adc.h | 18 + 32 files changed, 5042 insertions(+) create mode 100644 Documentation/ABI/testing/sysfs-bus-iio-adc-mt6370 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
Signature · 1 line
2.25.1
PATCH v2 1/15 dt-bindings: usb: Add Mediatek MT6370 TCPC
From: ChiYuan Huang <[email protected]>
Add Mediatek MT6370 TCPC binding documentation.
--- .../bindings/usb/mediatek,mt6370-tcpc.yaml | 36 +++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 Documentation/devicetree/bindings/usb/mediatek,mt6370-tcpc.yaml
Documentation/devicetree/bindings/usb/mediatek,mt6370-tcpc.yaml new file +36 -0
@@ -0,0 +1,36 @@ +# 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 + +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# + unevaluatedProperties: false + +additionalProperties: false + +required: + - compatible + - interrupts
Signature · 1 line
2.25.1
PATCH v2 2/15 dt-bindings: power: supply: Add Mediatek MT6370 Charger
In reply to ChiaEn WuFrom: 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
@@ -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 + - description: usb plug in irq + - description: mivr irq + + 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. + minItems: 1 + maxItems: 9 + + usb-otg-vbus-regulator: + type: object + description: OTG boost regulator. + $ref: /schemas/regulator/regulator.yaml# + + properties: + enable-gpio: + maxItems: 1 + +required: + - compatible + - interrupts + - interrupt-names + - io-channels + +additionalProperties: false + +...
Signature · 1 line
2.25.1
PATCH v2 3/15 dt-bindings: leds: mt6370: Add Mediatek mt6370 current sink type LED indicator
In reply to ChiaEn WuFrom: ChiYuan Huang <[email protected]>
Add Mediatek mt6370 current sink type LED indicator binding documentation.
--- .../leds/mediatek,mt6370-indicator.yaml | 48 +++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 Documentation/devicetree/bindings/leds/mediatek,mt6370-indicator.yaml
Documentation/devicetree/bindings/leds/mediatek,mt6370-indicator.yaml new file +48 -0
@@ -0,0 +1,48 @@ +# 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. + 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]$": + $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 + + unevaluatedProperties: false + +required: + - compatible + - "#address-cells" + - "#size-cells" + +additionalProperties: false
Signature · 1 line
2.25.1
PATCH v2 4/15 dt-bindings: leds: Add Mediatek MT6370 flashlight
In reply to ChiaEn WuFrom: Alice Chen <[email protected]>
Add Mediatek MT6370 flashlight binding documentation.
--- .../leds/mediatek,mt6370-flashlight.yaml | 44 +++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 Documentation/devicetree/bindings/leds/mediatek,mt6370-flashlight.yaml
Documentation/devicetree/bindings/leds/mediatek,mt6370-flashlight.yaml new file +44 -0
@@ -0,0 +1,44 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/leds/mediatek,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. + 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# + + properties: + reg: + 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
PATCH v2 5/15 dt-bindings: backlight: Add Mediatek MT6370 backlight
In reply to ChiaEn WuFrom: ChiYuan Huang <[email protected]>
Add mt6370 backlight binding documentation.
--- .../backlight/mediatek,mt6370-backlight.yaml | 107 ++++++++++++++++++ 1 file changed, 107 insertions(+) create mode 100644 Documentation/devicetree/bindings/leds/backlight/mediatek,mt6370-backlight.yaml
Documentation/devicetree/bindings/leds/backlight/mediatek,mt6370-backlight.yaml new file +107 -0
@@ -0,0 +1,107 @@ +# 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: | + This module is part of the MT6370 MFD device. + The MT6370 Backlight WLED driver supports up to a 29V output voltage for + 4 channels of 8 series WLEDs. Each channel supports up to 30mA of current + capability with 2048 current steps (11 bits) in exponential or linear + mapping curves. + +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-input-bit: + $ref: /schemas/types.yaml#/definitions/uint8 + enum: [0, 1, 2, 3] + description: | + The selection of the upper and lower bounds threshold of backlight + PWM resolution. If we choose selection 3 (6 bits), the variation of PWM + resolution needs over than 64 steps (2^6). + value mapping: + - 0: 1 + - 1: 2 + - 2: 4 + - 3: 6 + + mediatek,bled-ovp-shutdown: + description: | + Enable the backlight shutdown when OVP level triggered + type: boolean + + mediatek,bled-ovp-microvolt: + enum: [0, 1, 2, 3] + description: | + Backlight OVP level selection. + value mapping: + - 0: 17000000 + - 1: 21000000 + - 2: 25000000 + - 3: 29000000 + + mediatek,bled-ocp-shutdown: + description: | + Enable the backlight shutdown when OCP level triggerred. + type: boolean + + mediatek,bled-ocp-microamp: + enum: [0, 1, 2, 3] + description: | + Backlight OC level selection. + value mapping: + - 0: 900000 + - 1: 1200000 + - 2: 1500000 + - 3: 1800000 + + 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
PATCH v2 6/15 dt-bindings: mfd: Add Mediatek MT6370
In reply to ChiaEn WuFrom: ChiYuan Huang <[email protected]>
Add Mediatek MT6370 binding documentation.
--- .../bindings/mfd/mediatek,mt6370.yaml | 279 ++++++++++++++++++ .../dt-bindings/iio/adc/mediatek,mt6370_adc.h | 18 ++ 2 files changed, 297 insertions(+) create mode 100644 Documentation/devicetree/bindings/mfd/mediatek,mt6370.yaml create mode 100644 include/dt-bindings/iio/adc/mediatek,mt6370_adc.h
Documentation/devicetree/bindings/mfd/mediatek,mt6370.yaml new file +279 -0
@@ -0,0 +1,279 @@ +# 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: | + Provides 9 channels for system monitoring, including vbusdiv5, vbusdiv2, + vbat, vsys, chg_vddp, ts_bat, ibus, ibat, and temp_jc. + + 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, which support the control for DisplayBias + voltages and one general purpose LDO which commonly used to drive the + vibrator. + + 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 + +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/iio/adc/mediatek,mt6370_adc.h> + #include <dt-bindings/usb/pd.h> + i2c { + #address-cells = <1>; + #size-cells = <0>; + + pmic@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 = <48>, <68>, <6>; + interrupt-names = "attach_i", "uvp_d_evt", "mivr"; + io-channels = <&mt6370_adc MT6370_CHAN_IBUS>; + + mt6370_otg_vbus: usb-otg-vbus-regulator { + regulator-name = "mt6370-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>; + 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
@@ -0,0 +1,18 @@ +/* SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause */ + +#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
Signature · 1 line
2.25.1
PATCH v2 7/15 Documentation: ABI: testing: mt6370: Add ADC sysfs guideline
In reply to ChiaEn WuFrom: ChiaEn Wu <[email protected]>
Add ABI documentation for mt6370 non-standard ADC sysfs interfaces.
--- .../ABI/testing/sysfs-bus-iio-adc-mt6370 | 36 +++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 Documentation/ABI/testing/sysfs-bus-iio-adc-mt6370
Documentation/ABI/testing/sysfs-bus-iio-adc-mt6370 new file +36 -0
@@ -0,0 +1,36 @@ +What: /sys/bus/iio/devices/iio:deviceX/in_voltage0_raw +KernelVersion: 5.18 +Contact: [email protected] +Description: + Indicated MT6370 VBUS ADC with lower accuracy(+-75mA) + higher measure range(1~22V) + Calculating with scale returns voltage in uV + +What: /sys/bus/iio/devices/iio:deviceX/in_voltage1_raw +KernelVersion: 5.18 +Contact: [email protected] +Description: + Indicated MT6370 VBUS ADC with higher accuracy(+-30mA) + lower measure range(1~9.76V) + Calculating with scale offset returns voltage in uV + +What: /sys/bus/iio/devices/iio:deviceX/in_voltage4_raw +KernelVersion: 5.18 +Contact: [email protected] +Description: + Indicated MT6370 TS_BAT ADC + Calculating with scale returns voltage in uV + +What: /sys/bus/iio/devices/iio:deviceX/in_voltage7_raw +KernelVersion: 5.18 +Contact: [email protected] +Description: + Indicated MT6370 CHG_VDDP ADC + Calculating with scale returns voltage in mV + +What: /sys/bus/iio/devices/iio:deviceX/in_temp8_raw +KernelVersion: 5.18 +Contact: [email protected] +Description: + Indicated MT6370 IC junction temperature + Calculating with scale and offset returns temperature in degree
Signature · 1 line
2.25.1
PATCH v2 8/15 mfd: mt6370: Add Mediatek MT6370 support
In reply to ChiaEn WuFrom: ChiYuan Huang <[email protected]>
Add Mediatek MT6370 MFD support.
--- drivers/mfd/Kconfig | 13 ++ drivers/mfd/Makefile | 1 + drivers/mfd/mt6370.c | 349 +++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 363 insertions(+) create mode 100644 drivers/mfd/mt6370.c
drivers/mfd/Kconfig +13 -0
@@ -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
@@ -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 +349 -0
349 lines not on this page · raw message
Signature · 1 line
2.25.1
PATCH v2 9/15 usb: typec: tcpci_mt6370: Add Mediatek MT6370 tcpci driver
In reply to ChiaEn WuFrom: 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
@@ -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
@@ -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
PATCH v2 10/15 regulator: mt6370: Add mt6370 DisplayBias and VibLDO support
In reply to ChiaEn WuFrom: ChiYuan Huang <[email protected]>
Add mt6370 DisplayBias and VibLDO support.
--- drivers/regulator/Kconfig | 8 + drivers/regulator/Makefile | 1 + drivers/regulator/mt6370-regulator.c | 388 +++++++++++++++++++++++++++ 3 files changed, 397 insertions(+) create mode 100644 drivers/regulator/mt6370-regulator.c
drivers/regulator/Kconfig +8 -0
@@ -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
@@ -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 +388 -0
388 lines not on this page · raw message
Signature · 1 line
2.25.1
PATCH v2 11/15 iio: adc: mt6370: Add Mediatek MT6370 support
In reply to ChiaEn WuFrom: 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 | 262 +++++++++++++++++++++++++++++++++++ 3 files changed, 272 insertions(+) create mode 100644 drivers/iio/adc/mt6370-adc.c
drivers/iio/adc/Kconfig +9 -0
@@ -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
@@ -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 +262 -0
262 lines not on this page · raw message
Signature · 1 line
2.25.1
PATCH v2 12/15 power: supply: mt6370: Add Mediatek MT6370 charger driver
In reply to ChiaEn WuFrom: 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
@@ -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
@@ -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
PATCH v2 13/15 leds: mt6370: Add Mediatek MT6370 current sink type LED Indicator support
In reply to ChiaEn WuFrom: ChiYuan Huang <[email protected]>
Add Mediatek MT6370 current sink type LED Indicator driver.
--- drivers/leds/Kconfig | 11 + drivers/leds/Makefile | 1 + drivers/leds/leds-mt6370.c | 989 +++++++++++++++++++++++++++++++++++++ 3 files changed, 1001 insertions(+) create mode 100644 drivers/leds/leds-mt6370.c
drivers/leds/Kconfig +11 -0
@@ -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 + Say Y here to enable support for MT6370_RGB LED device. + In MT6370, there're four channel current-sink LED driver that support + hardware pattern for reg, pwm, breath mode. Isink4 channel + can also be used as a CHG_VIN power good indicator. + config LEDS_S3C24XX tristate "LED Support for Samsung S3C24XX GPIO LEDs" depends on LEDS_CLASS
drivers/leds/Makefile +1 -0
@@ -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 +989 -0
989 lines not on this page · raw message
Signature · 1 line
2.25.1
PATCH v2 14/15 leds: flashlight: mt6370: Add Mediatek MT6370 flashlight support
In reply to ChiaEn WuFrom: 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 | 657 +++++++++++++++++++++++++ 3 files changed, 667 insertions(+) create mode 100644 drivers/leds/flash/leds-mt6370-flash.c
drivers/leds/flash/Kconfig +9 -0
@@ -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
@@ -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 +657 -0
657 lines not on this page · raw message
Signature · 1 line
2.25.1
PATCH v2 15/15 video: backlight: mt6370: Add Mediatek MT6370 support
In reply to ChiaEn WuFrom: ChiaEn Wu <[email protected]>
Add Mediatek MT6370 Backlight support.
--- drivers/video/backlight/Kconfig | 9 + drivers/video/backlight/Makefile | 1 + drivers/video/backlight/mt6370-backlight.c | 339 +++++++++++++++++++++ 3 files changed, 349 insertions(+) create mode 100644 drivers/video/backlight/mt6370-backlight.c
drivers/video/backlight/Kconfig +9 -0
@@ -268,6 +268,15 @@ 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 + This enables support for Mediatek MT6370 Backlight driver. + It's commonly used to drive the display WLED. There're 4 channels + inisde, and each channel supports up to 30mA of current capability + with 2048 current steps in exponential or linear mapping curves. + config BACKLIGHT_APPLE tristate "Apple Backlight Driver" depends on X86 && ACPI
drivers/video/backlight/Makefile +1 -0
@@ -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 +339 -0
339 lines not on this page · raw message
Signature · 1 line
2.25.1
Rob Herring
maintainerRe: [PATCH v2 06/15] dt-bindings: mfd: Add Mediatek MT6370
In reply to ChiaEn WuQuoted 4 lines · ChiaEn Wu
From: ChiYuan Huang <[email protected]>
Add Mediatek MT6370 binding documentation.
Quoted 8 lines
Signed-off-by ChiYuan Huang <[email protected]>--- .../bindings/mfd/mediatek,mt6370.yaml | 279 ++++++++++++++++++ .../dt-bindings/iio/adc/mediatek,mt6370_adc.h | 18 ++ 2 files changed, 297 insertions(+) create mode 100644 Documentation/devicetree/bindings/mfd/mediatek,mt6370.yaml create mode 100644 include/dt-bindings/iio/adc/mediatek,mt6370_adc.h
My bot found errors running 'make DT_CHECKER_FLAGS=-m dt_binding_check' on your patch (DT_CHECKER_FLAGS is new in v5.13):
yamllint warnings/errors:
dtschema/dtc warnings/errors:./Documentation/devicetree/bindings/mfd/mediatek,mt6370.yaml: Unable to find schema file matching $id: http://devicetree.org/schemas/leds/backlight/mediatek,mt6370-backlight.yaml
/builds/robherring/linux-dt-review/Documentation/devicetree/bindings/mfd/mediatek,mt6370.example.dtb: pmic@34: backlight: False schema does not allow {'compatible': ['mediatek,mt6370-backlight'], 'mediatek,bled-channel-use': b'\x0f'}
From schema: /builds/robherring/linux-dt-review/Documentation/devicetree/bindings/mfd/mediatek,mt6370.yaml
/builds/robherring/linux-dt-review/Documentation/devicetree/bindings/mfd/mediatek,mt6370.example.dtb: pmic@34: charger: False schema does not allow {'compatible': ['mediatek,mt6370-charger'], 'interrupts': [[48], [68], [6]], 'interrupt-names': ['attach_i', 'uvp_d_evt', 'mivr'], 'io-channels': [[1, 5]], 'usb-otg-vbus-regulator': {'regulator-name': ['mt6370-usb-otg-vbus'], 'regulator-min-microvolt': [[4350000]], 'regulator-max-microvolt': [[5800000]], 'regulator-min-microamp': [[500000]], 'regulator-max-microamp': [[3000000]], 'phandle': [[2]]}}
From schema: /builds/robherring/linux-dt-review/Documentation/devicetree/bindings/mfd/mediatek,mt6370.yaml
/builds/robherring/linux-dt-review/Documentation/devicetree/bindings/mfd/mediatek,mt6370.example.dtb: pmic@34: tcpc: False schema does not allow {'compatible': ['mediatek,mt6370-tcpc'], 'interrupts-extended': [[4294967295, 4, 8]], 'connector': {'compatible': ['usb-c-connector'], 'label': ['USB-C'], 'vbus-supply': [[2]], 'data-role': ['dual'], 'power-role': ['dual'], 'try-power-role': ['sink'], 'source-pdos': [[570527844]], 'sink-pdos': [[570527944]], 'op-sink-microwatt': [[10000000]], 'ports': {'#address-cells': [[1]], '#size-cells': [[0]], 'port@0': {'reg': [[0]], 'endpoint': {'remote-endpoint': [[4294967295]]}}, 'port@1': {'reg': [[1]], 'endpoint': {'remote-endpoint': [[4294967295]]}}, 'port@2': {'reg': [[2]], 'endpoint': {'remote-endpoint': [[4294967295]]}}}}}
From schema: /builds/robherring/linux-dt-review/Documentation/devicetree/bindings/mfd/mediatek,mt6370.yaml
/builds/robherring/linux-dt-review/Documentation/devicetree/bindings/mfd/mediatek,mt6370.example.dtb: pmic@34: indicator: False schema does not allow {'compatible': ['mediatek,mt6370-indicator'], '#address-cells': [[1]], '#size-cells': [[0]], 'multi-led@0': {'reg': [[0]], 'function': ['indicator'], 'color': [[9]], 'led-max-microamp': [[24000]], '#address-cells': [[1]], '#size-cells': [[0]], 'led@0': {'reg': [[0]], 'color': [[1]]}, 'led@1': {'reg': [[1]], 'color': [[2]]}, 'led@2': {'reg': [[2]], 'color': [[3]]}}, 'led@3': {'reg': [[3]], 'function': ['indicator'], 'color': [[0]], 'led-max-microamp': [[6000]]}}
From schema: /builds/robherring/linux-dt-review/Documentation/devicetree/bindings/mfd/mediatek,mt6370.yaml
/builds/robherring/linux-dt-review/Documentation/devicetree/bindings/mfd/mediatek,mt6370.example.dtb: pmic@34: flashlight: False schema does not allow {'compatible': ['mediatek,mt6370-flashlight'], '#address-cells': [[1]], '#size-cells': [[0]], 'led@0': {'reg': [[0]], 'led-sources': [[0]], 'function': ['flash'], 'color': [[0]], 'function-enumerator': [[1]], 'led-max-microamp': [[200000]], 'flash-max-microamp': [[500000]], 'flash-max-timeout-us': [[1248000]]}, 'led@1': {'reg': [[1]], 'led-sources': [[1]], 'function': ['flash'], 'color': [[0]], 'function-enumerator': [[2]], 'led-max-microamp': [[200000]], 'flash-max-microamp': [[500000]], 'flash-max-timeout-us': [[1248000]]}}
From schema: /builds/robherring/linux-dt-review/Documentation/devicetree/bindings/mfd/mediatek,mt6370.yaml
/builds/robherring/linux-dt-review/Documentation/devicetree/bindings/mfd/mediatek,mt6370.example.dtb: backlight: mediatek,bled-channel-use: b'\x0f' is not of type 'object', 'array', 'boolean', 'null'
From schema: /usr/local/lib/python3.10/dist-packages/dtschema/schemas/dt-core.yamlDocumentation/devicetree/bindings/mfd/mediatek,mt6370.example.dtb:0:0: /example-0/i2c/pmic@34/backlight: failed to match any schema with compatible: ['mediatek,mt6370-backlight']Documentation/devicetree/bindings/mfd/mediatek,mt6370.example.dtb:0:0: /example-0/i2c/pmic@34/charger: failed to match any schema with compatible: ['mediatek,mt6370-charger']Documentation/devicetree/bindings/mfd/mediatek,mt6370.example.dtb:0:0: /example-0/i2c/pmic@34/indicator: failed to match any schema with compatible: ['mediatek,mt6370-indicator']Documentation/devicetree/bindings/mfd/mediatek,mt6370.example.dtb:0:0: /example-0/i2c/pmic@34/flashlight: failed to match any schema with compatible: ['mediatek,mt6370-flashlight']Documentation/devicetree/bindings/mfd/mediatek,mt6370.example.dtb:0:0: /example-0/i2c/pmic@34/tcpc: failed to match any schema with compatible: ['mediatek,mt6370-tcpc']
doc reference errors (make refcheckdocs):
See https://patchwork.ozlabs.org/patch/
This check can fail if there are any dependencies. The base for a patch series is generally the most recent rc1.
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 v2 15/15] video: backlight: mt6370: Add Mediatek MT6370 support
In reply to ChiaEn Wudrivers/video/backlight/mt6370-backlight.c line 127
Quoted 2 lines · ChiaEn Wu
drivers/video/backlight/mt6370-backlight.c new file +2
-0+static int mt6370_init_backlight_properties (struct mt6370_priv *priv, +struct backlight_properties *props)
Most of the changes in this version looks good... but it looks the new code in this function has a number of problems. See below...
drivers/video/backlight/mt6370-backlight.c line 137
Quoted 10 lines
drivers/video/backlight/mt6370-backlight.c new file +10
-0+{ +struct device *dev = priv->dev; +u8 prop_val; +u32 brightness; +unsigned int mask, val; +int ret; + +/* Vendor optional properties +* if property not exist, keep value in default. +*/
That's not the right strategy for booleans. Not existing means false (e.g. flags should actively be unset).
drivers/video/backlight/mt6370-backlight.c line 144
Quoted 7 lines
drivers/video/backlight/mt6370-backlight.c new file +7
-0+if (device_property_read_bool (dev,"mediatek,bled-pwm-enable" )) { + ret =regmap_update_bits (priv->regmap,MT6370_REG_BL_PWM , +MT6370_BL_PWM_EN_MASK , +MT6370_BL_PWM_EN_MASK ); +if (ret) +return ret; + }
As above comment... all of the boolean properties are now being read incorrectly.
Quoted 15 lines
drivers/video/backlight/mt6370-backlight.c new file +15
-0+ +if (device_property_read_bool (dev,"mediatek,bled-pwm-hys-enable" )) { + ret =regmap_update_bits (priv->regmap,MT6370_REG_BL_PWM , +MT6370_BL_PWM_HYS_EN_MASK , +MT6370_BL_PWM_HYS_EN_MASK ); +if (ret) +return ret; + } + + ret =device_property_read_u8 (dev,"mediatek,bled-pwm-hys-input-bit" , + &prop_val); +if (!ret) { + val =min_t (u8, prop_val,3 ) + << (ffs (MT6370_BL_PWM_HYS_SEL_MASK ) -1 ); + ret = regmap_update_bits(priv->regmap, MT6370_REG_BL_PWM,
drivers/video/backlight/mt6370-backlight.c line 169
Quoted 10 lines
drivers/video/backlight/mt6370-backlight.c new file +10
-0+ MT6370_BL_PWM_HYS_SEL_MASK, val); +if (ret) +return ret; + } + + ret =device_property_read_u8 (dev,"mediatek,bled-ovp-microvolt" , + &prop_val); +if (!ret) { + val =min_t (u8, prop_val,3 ) + << (ffs (MT6370_BL_OVP_SEL_MASK ) -1 );
This has been renamed but still seems to the using 0, 1, 2, 3 rather than an actual value in microvolts.
Quoted 9 lines
drivers/video/backlight/mt6370-backlight.c new file +9
-0+ ret =regmap_update_bits (priv->regmap,MT6370_REG_BL_BSTCTRL , +MT6370_BL_OVP_SEL_MASK , val); +if (ret) +return ret; + } + +if (device_property_read_bool (dev,"mediatek,bled-ovp-shutdown" )) { + ret = regmap_update_bits(priv->regmap, MT6370_REG_BL_BSTCTRL, + MT6370_BL_OVP_EN_MASK,
drivers/video/backlight/mt6370-backlight.c line 188
Quoted 10 lines
drivers/video/backlight/mt6370-backlight.c new file +10
-0+ MT6370_BL_OVP_EN_MASK); +if (ret) +return ret; + } + + ret =device_property_read_u8 (dev,"mediatek,bled-ocp-microamp" , + &prop_val); +if (!ret) { + val =min_t (u8, prop_val,3 ) + << (ffs (MT6370_BL_OC_SEL_MASK ) -1 );
Likewise, should this be accepting a value in microamps?
Quoted 28 lines
drivers/video/backlight/mt6370-backlight.c new file +28
-0+ ret =regmap_update_bits (priv->regmap,MT6370_REG_BL_BSTCTRL , +MT6370_BL_OC_SEL_MASK , val); +if (ret) +return ret; + } + +if (device_property_read_bool (dev,"mediatek,bled-ocp-shutdown" )) { + ret =regmap_update_bits (priv->regmap,MT6370_REG_BL_BSTCTRL , +MT6370_BL_OC_EN_MASK , +MT6370_BL_OC_EN_MASK ); +if (ret) +return ret; + } + +/* Common properties */ + ret =device_property_read_u32 (dev,"max-brightness" , &brightness); +if (ret) + brightness =MT6370_BL_MAX_BRIGHTNESS ; + + props->max_brightness =min_t (u32, brightness, +MT6370_BL_MAX_BRIGHTNESS ); + + ret =device_property_read_u32 (dev,"default-brightness" , &brightness); +if (ret) + brightness = props->max_brightness; + + props->brightness =min_t (u32, brightness, props->max_brightness); +
drivers/video/backlight/mt6370-backlight.c line 226
Quoted 10 lines
drivers/video/backlight/mt6370-backlight.c new file +10
-0+ + ret =device_property_read_u8 (dev,"mediatek,bled-channel-use" , + &prop_val); +if (ret) { +dev_err (dev,"mediatek,bled-channel-use DT property missing\n" ); +return ret; + } + +if (!prop_val || prop_val >MT6370_BL_MAX_CH ) { +dev_err (dev,"No channel specified (ch_val:%d)\n" , prop_val);
Error string has not been updated to match condition that triggers it.
Review
Quoted 2 lines
(quoted diff) +2
-0+ return -EINVAL; + }
Daniel.
Re: [PATCH v2 08/15] mfd: mt6370: Add Mediatek MT6370 support
In reply to ChiaEn WuQuoted 7 lines · ChiaEn Wu
drivers/mfd/Kconfig +0
-0@@ -937,6 +937,19 @@ config MFD_MT6360 PMIC part includes 2-channel BUCKs and 2-channel LDOs LDO part includes 4-channel LDOs
drivers/mfd/Kconfig config MFD_MT6360 · line 948
Quoted 10 lines
drivers/mfd/Kconfig +9
-0+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
integrates ADC (?)
drivers/mfd/Kconfig config MFD_MT6360 · line 950
Quoted 2 lines
drivers/mfd/Kconfig +2
-0+ LEDs, dual channel flashlight, WLED backlight driver, display bias + voltage supply, one general purpose LDO, and cc logic
CC (?)
What is CC?
drivers/mfd/Kconfig config MFD_MT6360 · line 951
Quoted 1 line
drivers/mfd/Kconfig +1
-0+ controller with USBPD commmunication capable.
capability.
Signature · 6 lines
~Randy _______________________________________________ Linux-mediatek mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-mediatek
Re: [PATCH v2 10/15] regulator: mt6370: Add mt6370 DisplayBias and VibLDO support
In reply to ChiaEn WuQuoted 5 lines · ChiaEn Wu
drivers/regulator/Kconfig +0
-0
drivers/regulator/Kconfig config REGULATOR_MT6360 · line 812
Quoted 9 lines
drivers/regulator/Kconfig +6
-0@@ -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
supports
drivers/regulator/Kconfig config REGULATOR_MT6360 · line 813
Quoted 1 line
drivers/regulator/Kconfig +1
-0+ general purpose LDO which commonly used to drive the vibrator.
which is commonly used to drive the vibrator.
Signature · 1 line
~Randy
Re: [PATCH v2 11/15] iio: adc: mt6370: Add Mediatek MT6370 support
In reply to ChiaEn WuHi,
Quoted 5 lines · ChiaEn Wu
drivers/iio/adc/Kconfig +0
-0
drivers/iio/adc/Kconfig config MEDIATEK_MT6360_ADC · line 746
Quoted 10 lines
drivers/iio/adc/Kconfig +7
-0@@ -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
Please try again on the help text. I can't decode that.
Quoted 1 line
drivers/iio/adc/Kconfig +1
-0+ and tablets and supports a 9 channel general purpose ADC.
Signature · 1 line
~Randy
Re: [PATCH v2 13/15] leds: mt6370: Add Mediatek MT6370 current sink type LED Indicator support
In reply to ChiaEn WuHi--
Quoted 6 lines · ChiaEn Wu
drivers/leds/Kconfig +0
-0@@ -244,6 +244,17 @@ config LEDS_MT6323 This option enables support for on-chip LED drivers found on
drivers/leds/Kconfig config LEDS_MT6323 · line 254
Quoted 10 lines
drivers/leds/Kconfig +8
-0Mediatek 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 + Say Y here to enable support for MT6370_RGB LED device. + In MT6370, there're four channel current-sink LED driver that support
Please spell out "there are" instead of using an unusual contraction. Also:
drivers that support
drivers/leds/Kconfig config LEDS_MT6323 · line 255
Quoted 1 line
drivers/leds/Kconfig +1
-0+ hardware pattern for reg, pwm, breath mode. Isink4 channel
PWM,
What is "reg"?
Quoted 1 line
drivers/leds/Kconfig +1
-0+ can also be used as a CHG_VIN power good indicator.
Signature · 1 line
~Randy
Re: [PATCH v2 15/15] video: backlight: mt6370: Add Mediatek MT6370 support
In reply to ChiaEn WuQuoted 5 lines · ChiaEn Wu
drivers/video/backlight/Kconfig +0
-0
drivers/video/backlight/Kconfig config BACKLIGHT_MAX8925 · line 276
Quoted 9 lines
drivers/video/backlight/Kconfig +6
-0@@ -268,6 +268,15 @@ 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 + This enables support for Mediatek MT6370 Backlight driver. + It's commonly used to drive the display WLED. There're 4 channels
There are 4 channels
drivers/video/backlight/Kconfig config BACKLIGHT_MAX8925 · line 277
Quoted 1 line
drivers/video/backlight/Kconfig +1
-0+ inisde, and each channel supports up to 30mA of current capability
inside,
Quoted 1 line
drivers/video/backlight/Kconfig +1
-0+ with 2048 current steps in exponential or linear mapping curves.
Signature · 1 line
~Randy
Re: [PATCH v2 08/15] mfd: mt6370: Add Mediatek MT6370 support
In reply to ChiaEn WuQuoted 19 lines · ChiaEn Wu
From: ChiYuan Huang <[email protected]>
Add Mediatek MT6370 MFD support.
Signed-off-by ChiYuan Huang <[email protected]>--- drivers/mfd/Kconfig | 13 ++ drivers/mfd/Makefile | 1 + drivers/mfd/mt6370.c | 349 +++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 363 insertions(+) create mode 100644 drivers/mfd/mt6370.cdrivers/mfd/Kconfig +0
-0@@ -937,6 +937,19 @@ config MFD_MT6360 PMIC part includes 2-channel BUCKs and 2-channel LDOs LDO part includes 4-channel LDOs
drivers/mfd/Kconfig config MFD_MT6360 · line 948
Quoted 10 lines
drivers/mfd/Kconfig +9
-0+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
s/integrates/consists of a/
"ADC"
drivers/mfd/Kconfig config MFD_MT6360 · line 951
Quoted 4 lines
drivers/mfd/Kconfig +3
-0+ LEDs, dual channel flashlight, WLED backlight driver, display bias + voltage supply, one general purpose LDO, and cc logic + controller with USBPD commmunication capable.
The last part makes no sense - "and is USBPD"?
Quoted 121 lines
drivers/mfd/Kconfig +0
-0config MFD_MT6397 tristate "MediaTek MT6397 PMIC Support" select MFD_COREdrivers/mfd/Makefile +1
-0@@ -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.odrivers/mfd/mt6370.c new file +100
-0@@ -0,0 +1,349 @@ +// SPDX-License-Identifier: GPL-2.0 + +#include <linux/bits.h> +#include <linux/i2c.h> +#include <linux/interrupt.h> +#include <linux/kernel.h> +#include <linux/mfd/core.h> +#include <linux/module.h> +#include <linux/regmap.h> + +enum { +MT6370_USBC_I2C =0 , +MT6370_PMU_I2C , +MT6370_MAX_I2C +}; + +#define MT6370_REG_DEV_INFO 0x100 +#define MT6370_REG_CHG_IRQ1 0x1C0 +#define MT6370_REG_CHG_MASK1 0x1E0 + +#define MT6370_VENID_MASK GENMASK(7, 4) + +#define MT6370_NUM_IRQREGS 16 +#define MT6370_USBC_I2CADDR 0x4E +#define MT6370_REG_ADDRLEN 2 +#define MT6370_REG_MAXADDR 0x1FF + +/* IRQ definitions */ +#define MT6370_IRQ_DIRCHGON 0 +#define MT6370_IRQ_CHG_TREG 4 +#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 +#define MT6370_IRQ_CHG_VSYSUV 12 +#define MT6370_IRQ_CHG_VSYSOV 13 +#define MT6370_IRQ_CHG_VBATOV 14 +#define MT6370_IRQ_CHG_VINOVPCHG 15 +#define MT6370_IRQ_TS_BAT_COLD 20 +#define MT6370_IRQ_TS_BAT_COOL 21 +#define MT6370_IRQ_TS_BAT_WARM 22 +#define MT6370_IRQ_TS_BAT_HOT 23 +#define MT6370_IRQ_TS_STATC 24 +#define MT6370_IRQ_CHG_FAULT 25 +#define MT6370_IRQ_CHG_STATC 26 +#define MT6370_IRQ_CHG_TMR 27 +#define MT6370_IRQ_CHG_BATABS 28 +#define MT6370_IRQ_CHG_ADPBAD 29 +#define MT6370_IRQ_CHG_RVP 30 +#define MT6370_IRQ_TSHUTDOWN 31 +#define MT6370_IRQ_CHG_IINMEAS 32 +#define MT6370_IRQ_CHG_ICCMEAS 33 +#define MT6370_IRQ_CHGDET_DONE 34 +#define MT6370_IRQ_WDTMR 35 +#define MT6370_IRQ_SSFINISH 36 +#define MT6370_IRQ_CHG_RECHG 37 +#define MT6370_IRQ_CHG_TERM 38 +#define MT6370_IRQ_CHG_IEOC 39 +#define MT6370_IRQ_ADC_DONE 40 +#define MT6370_IRQ_PUMPX_DONE 41 +#define MT6370_IRQ_BST_BATUV 45 +#define MT6370_IRQ_BST_MIDOV 46 +#define MT6370_IRQ_BST_OLP 47 +#define MT6370_IRQ_ATTACH 48 +#define MT6370_IRQ_DETACH 49 +#define MT6370_IRQ_HVDCP_STPDONE 51 +#define MT6370_IRQ_HVDCP_VBUSDET_DONE 52 +#define MT6370_IRQ_HVDCP_DET 53 +#define MT6370_IRQ_CHGDET 54 +#define MT6370_IRQ_DCDT 55 +#define MT6370_IRQ_DIRCHG_VGOK 59 +#define MT6370_IRQ_DIRCHG_WDTMR 60 +#define MT6370_IRQ_DIRCHG_UC 61 +#define MT6370_IRQ_DIRCHG_OC 62 +#define MT6370_IRQ_DIRCHG_OV 63 +#define MT6370_IRQ_OVPCTRL_SWON 67 +#define MT6370_IRQ_OVPCTRL_UVP_D 68 +#define MT6370_IRQ_OVPCTRL_UVP 69 +#define MT6370_IRQ_OVPCTRL_OVP_D 70 +#define MT6370_IRQ_OVPCTRL_OVP 71 +#define MT6370_IRQ_FLED_STRBPIN 72 +#define MT6370_IRQ_FLED_TORPIN 73 +#define MT6370_IRQ_FLED_TX 74 +#define MT6370_IRQ_FLED_LVF 75 +#define MT6370_IRQ_FLED2_SHORT 78 +#define MT6370_IRQ_FLED1_SHORT 79 +#define MT6370_IRQ_FLED2_STRB 80 +#define MT6370_IRQ_FLED1_STRB 81 +#define mT6370_IRQ_FLED2_STRB_TO 82 +#define MT6370_IRQ_FLED1_STRB_TO 83 +#define MT6370_IRQ_FLED2_TOR 84 +#define MT6370_IRQ_FLED1_TOR 85 +#define MT6370_IRQ_OTP 93 +#define MT6370_IRQ_VDDA_OVP 94 +#define MT6370_IRQ_VDDA_UV 95 +#define MT6370_IRQ_LDO_OC 103 +#define MT6370_IRQ_BLED_OCP 118 +#define MT6370_IRQ_BLED_OVP 119 +#define MT6370_IRQ_DSV_VNEG_OCP 123 +#define MT6370_IRQ_DSV_VPOS_OCP 124
drivers/mfd/mt6370.c line 110
Quoted 10 lines
drivers/mfd/mt6370.c new file +10
-0+#define MT6370_IRQ_DSV_BST_OCP 125 +#define MT6370_IRQ_DSV_VNEG_SCP 126 +#define MT6370_IRQ_DSV_VPOS_SCP 127 + +struct mt6370_info { +struct i2c_client *i2c[MT6370_MAX_I2C ]; +struct device *dev; +struct regmap *regmap; +struct regmap_irq_chip_data *irq_data; +};
Can we shove all of the above into a header file?
Quoted 112 lines
drivers/mfd/mt6370.c new file +112
-0+static const struct regmap_irq mt6370_irqs[] = { +REGMAP_IRQ_REG_LINE (MT6370_IRQ_DIRCHGON ,8 ), +REGMAP_IRQ_REG_LINE (MT6370_IRQ_CHG_TREG ,8 ), +REGMAP_IRQ_REG_LINE (MT6370_IRQ_CHG_AICR ,8 ), +REGMAP_IRQ_REG_LINE (MT6370_IRQ_CHG_MIVR ,8 ), +REGMAP_IRQ_REG_LINE (MT6370_IRQ_PWR_RDY ,8 ), +REGMAP_IRQ_REG_LINE (MT6370_IRQ_FL_CHG_VINOVP ,8 ), +REGMAP_IRQ_REG_LINE (MT6370_IRQ_CHG_VSYSUV ,8 ), +REGMAP_IRQ_REG_LINE (MT6370_IRQ_CHG_VSYSOV ,8 ), +REGMAP_IRQ_REG_LINE (MT6370_IRQ_CHG_VBATOV ,8 ), +REGMAP_IRQ_REG_LINE (MT6370_IRQ_CHG_VINOVPCHG ,8 ), +REGMAP_IRQ_REG_LINE (MT6370_IRQ_TS_BAT_COLD ,8 ), +REGMAP_IRQ_REG_LINE (MT6370_IRQ_TS_BAT_COOL ,8 ), +REGMAP_IRQ_REG_LINE (MT6370_IRQ_TS_BAT_WARM ,8 ), +REGMAP_IRQ_REG_LINE (MT6370_IRQ_TS_BAT_HOT ,8 ), +REGMAP_IRQ_REG_LINE (MT6370_IRQ_TS_STATC ,8 ), +REGMAP_IRQ_REG_LINE (MT6370_IRQ_CHG_FAULT ,8 ), +REGMAP_IRQ_REG_LINE (MT6370_IRQ_CHG_STATC ,8 ), +REGMAP_IRQ_REG_LINE (MT6370_IRQ_CHG_TMR ,8 ), +REGMAP_IRQ_REG_LINE (MT6370_IRQ_CHG_BATABS ,8 ), +REGMAP_IRQ_REG_LINE (MT6370_IRQ_CHG_ADPBAD ,8 ), +REGMAP_IRQ_REG_LINE (MT6370_IRQ_CHG_RVP ,8 ), +REGMAP_IRQ_REG_LINE (MT6370_IRQ_TSHUTDOWN ,8 ), +REGMAP_IRQ_REG_LINE (MT6370_IRQ_CHG_IINMEAS ,8 ), +REGMAP_IRQ_REG_LINE (MT6370_IRQ_CHG_ICCMEAS ,8 ), +REGMAP_IRQ_REG_LINE (MT6370_IRQ_CHGDET_DONE ,8 ), +REGMAP_IRQ_REG_LINE (MT6370_IRQ_WDTMR ,8 ), +REGMAP_IRQ_REG_LINE (MT6370_IRQ_SSFINISH ,8 ), +REGMAP_IRQ_REG_LINE (MT6370_IRQ_CHG_RECHG ,8 ), +REGMAP_IRQ_REG_LINE (MT6370_IRQ_CHG_TERM ,8 ), +REGMAP_IRQ_REG_LINE (MT6370_IRQ_CHG_IEOC ,8 ), +REGMAP_IRQ_REG_LINE (MT6370_IRQ_ADC_DONE ,8 ), +REGMAP_IRQ_REG_LINE (MT6370_IRQ_PUMPX_DONE ,8 ), +REGMAP_IRQ_REG_LINE (MT6370_IRQ_BST_BATUV ,8 ), +REGMAP_IRQ_REG_LINE (MT6370_IRQ_BST_MIDOV ,8 ), +REGMAP_IRQ_REG_LINE (MT6370_IRQ_BST_OLP ,8 ), +REGMAP_IRQ_REG_LINE (MT6370_IRQ_ATTACH ,8 ), +REGMAP_IRQ_REG_LINE (MT6370_IRQ_DETACH ,8 ), +REGMAP_IRQ_REG_LINE (MT6370_IRQ_HVDCP_STPDONE ,8 ), +REGMAP_IRQ_REG_LINE (MT6370_IRQ_HVDCP_VBUSDET_DONE ,8 ), +REGMAP_IRQ_REG_LINE (MT6370_IRQ_HVDCP_DET ,8 ), +REGMAP_IRQ_REG_LINE (MT6370_IRQ_CHGDET ,8 ), +REGMAP_IRQ_REG_LINE (MT6370_IRQ_DCDT ,8 ), +REGMAP_IRQ_REG_LINE (MT6370_IRQ_DIRCHG_VGOK ,8 ), +REGMAP_IRQ_REG_LINE (MT6370_IRQ_DIRCHG_WDTMR ,8 ), +REGMAP_IRQ_REG_LINE (MT6370_IRQ_DIRCHG_UC ,8 ), +REGMAP_IRQ_REG_LINE (MT6370_IRQ_DIRCHG_OC ,8 ), +REGMAP_IRQ_REG_LINE (MT6370_IRQ_DIRCHG_OV ,8 ), +REGMAP_IRQ_REG_LINE (MT6370_IRQ_OVPCTRL_SWON ,8 ), +REGMAP_IRQ_REG_LINE (MT6370_IRQ_OVPCTRL_UVP_D ,8 ), +REGMAP_IRQ_REG_LINE (MT6370_IRQ_OVPCTRL_UVP ,8 ), +REGMAP_IRQ_REG_LINE (MT6370_IRQ_OVPCTRL_OVP_D ,8 ), +REGMAP_IRQ_REG_LINE (MT6370_IRQ_OVPCTRL_OVP ,8 ), +REGMAP_IRQ_REG_LINE (MT6370_IRQ_FLED_STRBPIN ,8 ), +REGMAP_IRQ_REG_LINE (MT6370_IRQ_FLED_TORPIN ,8 ), +REGMAP_IRQ_REG_LINE (MT6370_IRQ_FLED_TX ,8 ), +REGMAP_IRQ_REG_LINE (MT6370_IRQ_FLED_LVF ,8 ), +REGMAP_IRQ_REG_LINE (MT6370_IRQ_FLED2_SHORT ,8 ), +REGMAP_IRQ_REG_LINE (MT6370_IRQ_FLED1_SHORT ,8 ), +REGMAP_IRQ_REG_LINE (MT6370_IRQ_FLED2_STRB ,8 ), +REGMAP_IRQ_REG_LINE (MT6370_IRQ_FLED1_STRB ,8 ), +REGMAP_IRQ_REG_LINE (mT6370_IRQ_FLED2_STRB_TO,8 ), +REGMAP_IRQ_REG_LINE (MT6370_IRQ_FLED1_STRB_TO ,8 ), +REGMAP_IRQ_REG_LINE (MT6370_IRQ_FLED2_TOR ,8 ), +REGMAP_IRQ_REG_LINE (MT6370_IRQ_FLED1_TOR ,8 ), +REGMAP_IRQ_REG_LINE (MT6370_IRQ_OTP ,8 ), +REGMAP_IRQ_REG_LINE (MT6370_IRQ_VDDA_OVP ,8 ), +REGMAP_IRQ_REG_LINE (MT6370_IRQ_VDDA_UV ,8 ), +REGMAP_IRQ_REG_LINE (MT6370_IRQ_LDO_OC ,8 ), +REGMAP_IRQ_REG_LINE (MT6370_IRQ_BLED_OCP ,8 ), +REGMAP_IRQ_REG_LINE (MT6370_IRQ_BLED_OVP ,8 ), +REGMAP_IRQ_REG_LINE (MT6370_IRQ_DSV_VNEG_OCP ,8 ), +REGMAP_IRQ_REG_LINE (MT6370_IRQ_DSV_VPOS_OCP ,8 ), +REGMAP_IRQ_REG_LINE (MT6370_IRQ_DSV_BST_OCP ,8 ), +REGMAP_IRQ_REG_LINE (MT6370_IRQ_DSV_VNEG_SCP ,8 ), +REGMAP_IRQ_REG_LINE (MT6370_IRQ_DSV_VPOS_SCP ,8 ) +}; + +static const struct regmap_irq_chip mt6370_irq_chip = { + .name ="mt6370-irqs" , + .status_base =MT6370_REG_CHG_IRQ1 , + .mask_base =MT6370_REG_CHG_MASK1 , + .num_regs =MT6370_NUM_IRQREGS , + .irqs = mt6370_irqs, + .num_irqs =ARRAY_SIZE (mt6370_irqs), +}; + +static const struct resource mt6370_regulator_irqs[] = { +DEFINE_RES_IRQ_NAMED (MT6370_IRQ_DSV_VPOS_SCP ,"db_vpos_scp" ), +DEFINE_RES_IRQ_NAMED (MT6370_IRQ_DSV_VNEG_SCP ,"db_vneg_scp" ), +DEFINE_RES_IRQ_NAMED (MT6370_IRQ_DSV_BST_OCP ,"db_vbst_ocp" ), +DEFINE_RES_IRQ_NAMED (MT6370_IRQ_DSV_VPOS_OCP ,"db_vpos_ocp" ), +DEFINE_RES_IRQ_NAMED (MT6370_IRQ_DSV_VNEG_OCP ,"db_vneg_ocp" ), +DEFINE_RES_IRQ_NAMED (MT6370_IRQ_LDO_OC ,"ldo_oc" ) +}; + +static const struct mfd_cell mt6370_devices[] = { +MFD_CELL_OF ("adc" ,NULL ,NULL ,0 ,0 ,"mediatek,mt6370-adc" ), +MFD_CELL_OF ("charger" ,NULL ,NULL ,0 ,0 ,"mediatek,mt6370-charger" ), +MFD_CELL_OF ("backlight" ,NULL ,NULL ,0 ,0 ,"mediatek,mt6370-backlight" ), +MFD_CELL_OF ("flashlight" ,NULL ,NULL ,0 ,0 ,"mediatek,mt6370-flashlight" ), +MFD_CELL_OF ("indicator" ,NULL ,NULL ,0 ,0 ,"mediatek,mt6370-indicator" ), +MFD_CELL_OF ("tcpc" ,NULL ,NULL ,0 ,0 ,"mediatek,mt6370-tcpc" ), +MFD_CELL_RES ("regulator" , mt6370_regulator_irqs) +}; + +static int mt6370_check_vendor_info (struct mt6370_info *info) +{ +unsigned int devinfo; +int ret; + + ret =regmap_read (info->regmap,MT6370_REG_DEV_INFO , &devinfo);
drivers/mfd/mt6370.c line 233
Quoted 10 lines
drivers/mfd/mt6370.c new file +10
-0+if (ret) +return ret; + +switch (FIELD_GET (MT6370_VENID_MASK , devinfo)) { +case 0x8 :/* RT5081 */ +case 0xA :/* RT5081A */ +case 0xE :/* MT6370 */ +case 0xF :/* MT6371 */ +case 0x9 :/* MT6372P */ +case 0xB :/* MT6372CP */
Please define these and drop the comments.
Quoted 4 lines
drivers/mfd/mt6370.c new file +4
-0+break ; +default : +dev_err (info->dev,"Not invalid value 0x%02x\n" , devinfo); +return -ENODEV ;
drivers/mfd/mt6370.c line 247
Quoted 10 lines
drivers/mfd/mt6370.c new file +10
-0+ } + +return 0 ; +} + +static int mt6370_regmap_read (void *context,const void *reg_buf, +size_t reg_size,void *val_buf,size_t val_size) +{ +struct mt6370_info *info = context; +u8 bank_idx = *(u8 *)reg_buf, bank_addr = *(u8 *)(reg_buf +1 );
Looks a little scruffy. Perhaps allocate the values below.
Quoted 4 lines
drivers/mfd/mt6370.c new file +4
-0+int ret; + + ret =i2c_smbus_read_i2c_block_data (info->i2c[bank_idx], bank_addr, + val_size, val_buf);
drivers/mfd/mt6370.c line 261
Quoted 10 lines
drivers/mfd/mt6370.c new file +10
-0+if (ret != val_size) +return ret; + +return 0 ; +} + +static int mt6370_regmap_write (void *context,const void *data,size_t count) +{ +struct mt6370_info *info = context; +u8 bank_idx = *(u8 *)data, bank_addr = *(u8 *)(data +1 );
As above.
Quoted 25 lines
drivers/mfd/mt6370.c new file +25
-0+int len = count -MT6370_REG_ADDRLEN ; + +return i2c_smbus_write_i2c_block_data (info->i2c[bank_idx], bank_addr, + len, data +MT6370_REG_ADDRLEN ); +} + +static const struct regmap_bus mt6370_regmap_bus = { + .read = mt6370_regmap_read, + .write = mt6370_regmap_write, +}; + +static const struct regmap_config mt6370_regmap_config = { + .reg_bits =16 , + .val_bits =8 , + .reg_format_endian =REGMAP_ENDIAN_BIG , + .max_register =MT6370_REG_MAXADDR , +}; + +static int mt6370_probe (struct i2c_client *i2c) +{ +struct mt6370_info *info; +struct i2c_client *usbc_i2c; +int ret; + + info =devm_kzalloc (&i2c->dev,sizeof (*info),GFP_KERNEL );
drivers/mfd/mt6370.c line 296
Quoted 10 lines
drivers/mfd/mt6370.c new file +10
-0+if (!info) +return -ENOMEM ; + + info->dev = &i2c->dev; + + usbc_i2c =devm_i2c_new_dummy_device (&i2c->dev, i2c->adapter, +MT6370_USBC_I2CADDR ); +if (IS_ERR (usbc_i2c)) { + ret =PTR_ERR (usbc_i2c); +dev_err (&i2c->dev,"Failed to register usbc i2c client %d\n" , ret);
"USB-C I2C"?
Quoted 42 lines
drivers/mfd/mt6370.c new file +42
-0+return ret; + } + +/* Assign I2C client for PMU and TypeC */ + info->i2c[MT6370_PMU_I2C ] = i2c; + info->i2c[MT6370_USBC_I2C ] = usbc_i2c; + + info->regmap =devm_regmap_init (&i2c->dev, &mt6370_regmap_bus, info, + &mt6370_regmap_config); +if (IS_ERR (info->regmap)) { + ret =PTR_ERR (info->regmap); +dev_err (&i2c->dev,"Failed to register regmap (%d)\n" , ret); +return ret; + } + + ret =mt6370_check_vendor_info (info); +if (ret) { +dev_err (&i2c->dev,"Failed to check vendor info (%d)\n" , ret); +return ret; + } + + ret =devm_regmap_add_irq_chip (&i2c->dev, info->regmap, i2c->irq, +IRQF_ONESHOT ,-1 , &mt6370_irq_chip, + &info->irq_data); +if (ret) { +dev_err (&i2c->dev,"Failed to add irq chip (%d)\n" , ret); +return ret; + } + +return devm_mfd_add_devices (&i2c->dev,PLATFORM_DEVID_AUTO , + mt6370_devices,ARRAY_SIZE (mt6370_devices), +NULL ,0 , +regmap_irq_get_domain (info->irq_data)); +} + +static const struct of_device_id mt6370_match_table[] = { + { .compatible ="mediatek,mt6370" , }, + {} +}; +MODULE_DEVICE_TABLE (of, mt6370_match_table); + +static struct i2c_driver mt6370_driver = {
drivers/mfd/mt6370.c line 348
Quoted 10 lines
drivers/mfd/mt6370.c new file +10
-0+ .driver = { + .name = "mt6370", + .of_match_table = mt6370_match_table, + }, + .probe_new = mt6370_probe, +}; +module_i2c_driver (mt6370_driver); + +MODULE_AUTHOR ("ChiYuan Huang <[email protected]>" ); +MODULE_DESCRIPTION ("MT6370 I2C MFD Driver" );
Drop all references to "MFD" please.
Quoted 1 line
drivers/mfd/mt6370.c new file +1
-0+MODULE_LICENSE ("GPL v2" );
Signature · 4 lines
Lee Jones [李琼斯] Principal Technical Lead - Developer Services Linaro.org │ Open source software for Arm SoCs Follow Linaro: Facebook | Twitter | Blog
Re: [PATCH v2 02/15] dt-bindings: power: supply: Add Mediatek MT6370 Charger
In reply to ChiaEn WuQuoted 45 lines · ChiaEn Wu
From: ChiaEn Wu <[email protected]>
Add Mediatek MT6370 Charger binding documentation.
Signed-off-by ChiaEn Wu <[email protected]>--- .../power/supply/mediatek,mt6370-charger.yaml | 60 +++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 Documentation/devicetree/bindings/power/supply/mediatek,mt6370-charger.yamlDocumentation/devicetree/bindings/power/supply/mediatek,mt6370-charger.yaml new file +29
-0@@ -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 + - description: usb plug in irq + - description: mivr irq +
Documentation/devicetree/bindings/power/supply/mediatek,mt6370-charger.yaml line 39
Quoted 10 lines
Documentation/devicetree/bindings/power/supply/mediatek,mt6370-charger.yaml new file +10
-0+ 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.
Add io-channel-names and describe each item - what type of ADC it is expected to be.
Documentation/devicetree/bindings/power/supply/mediatek,mt6370-charger.yaml line 46
Quoted 7 lines
Documentation/devicetree/bindings/power/supply/mediatek,mt6370-charger.yaml new file +7
-0+ minItems: 1 + maxItems: 9 + + usb-otg-vbus-regulator: + type: object + description: OTG boost regulator. + $ref: /schemas/regulator/regulator.yaml#
unevaluatedProperties: false
Documentation/devicetree/bindings/power/supply/mediatek,mt6370-charger.yaml line 49
Quoted 3 lines
Documentation/devicetree/bindings/power/supply/mediatek,mt6370-charger.yaml new file +3
-0+ + properties: + enable-gpio:
"gpios", so:
enable-gpios
Documentation/devicetree/bindings/power/supply/mediatek,mt6370-charger.yaml line 60
Quoted 11 lines
Documentation/devicetree/bindings/power/supply/mediatek,mt6370-charger.yaml new file +11
-0+ maxItems: 1 + +required: + - compatible + - interrupts + - interrupt-names + - io-channels + +additionalProperties: false + +...
Best regards,
Krzysztof
Re: [PATCH v2 01/15] dt-bindings: usb: Add Mediatek MT6370 TCPC
In reply to ChiaEn WuQuoted 5 lines · ChiaEn Wu
From: ChiYuan Huang <[email protected]>
Add Mediatek MT6370 TCPC binding documentation.
Signed-off-by ChiYuan Huang <[email protected]>
Best regards,
Krzysztof
Re: [PATCH v2 03/15] dt-bindings: leds: mt6370: Add Mediatek mt6370 current sink type LED indicator
In reply to ChiaEn WuQuoted 33 lines · ChiaEn Wu
From: ChiYuan Huang <[email protected]>
Add Mediatek mt6370 current sink type LED indicator binding documentation.
Signed-off-by ChiYuan Huang <[email protected]>--- .../leds/mediatek,mt6370-indicator.yaml | 48 +++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 Documentation/devicetree/bindings/leds/mediatek,mt6370-indicator.yamlDocumentation/devicetree/bindings/leds/mediatek,mt6370-indicator.yaml new file +17
-0@@ -0,0 +1,48 @@ +# 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. + Add MT6370 LED driver include 4-channel RGB LED support Register/PWM/Breath Mode + +properties: + compatible:
Documentation/devicetree/bindings/leds/mediatek,mt6370-indicator.yaml line 27
Quoted 10 lines
Documentation/devicetree/bindings/leds/mediatek,mt6370-indicator.yaml new file +10
-0+ const: mediatek,mt6370-indicator + + "#address-cells": + const: 1 + + "#size-cells": + const: 0 + +patternProperties: + "^(multi-)?led@[0-3]$":
If this is multi-led, then you should reference
/schemas/leds/leds-pwm-multicolor.yaml
See other examples using it.
Best regards,
Krzysztof
Re: [PATCH v2 04/15] dt-bindings: leds: Add Mediatek MT6370 flashlight
In reply to ChiaEn WuQuoted 41 lines · ChiaEn Wu
From: Alice Chen <[email protected]>
Add Mediatek MT6370 flashlight binding documentation.
Signed-off-by Alice Chen <[email protected]>--- .../leds/mediatek,mt6370-flashlight.yaml | 44 +++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 Documentation/devicetree/bindings/leds/mediatek,mt6370-flashlight.yamlDocumentation/devicetree/bindings/leds/mediatek,mt6370-flashlight.yaml new file +25
-0@@ -0,0 +1,44 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/leds/mediatek,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. + 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 +
Documentation/devicetree/bindings/leds/mediatek,mt6370-flashlight.yaml line 35
Quoted 10 lines
Documentation/devicetree/bindings/leds/mediatek,mt6370-flashlight.yaml new file +10
-0+patternProperties: + "^led@[0-1]$": + type: object + $ref: common.yaml# + + properties: + reg: + enum: + - 0 # Address of LED1 + - 1 # Address of LED2
Just: enum: [0, 1]
No need for description.
Documentation/devicetree/bindings/leds/mediatek,mt6370-flashlight.yaml line 44
Quoted 9 lines
Documentation/devicetree/bindings/leds/mediatek,mt6370-flashlight.yaml new file +9
-0+ + unevaluatedProperties: false + +required: + - compatible + - "#address-cells" + - "#size-cells" + +additionalProperties: false
Best regards,
Krzysztof
Re: [PATCH v2 05/15] dt-bindings: backlight: Add Mediatek MT6370 backlight
In reply to ChiaEn WuQuoted 65 lines · ChiaEn Wu
From: ChiYuan Huang <[email protected]>
Add mt6370 backlight binding documentation.
Signed-off-by ChiYuan Huang <[email protected]>--- .../backlight/mediatek,mt6370-backlight.yaml | 107 ++++++++++++++++++ 1 file changed, 107 insertions(+) create mode 100644 Documentation/devicetree/bindings/leds/backlight/mediatek,mt6370-backlight.yamlDocumentation/devicetree/bindings/leds/backlight/mediatek,mt6370-backlight.yaml new file +49
-0@@ -0,0 +1,107 @@ +# 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: | + This module is part of the MT6370 MFD device. + The MT6370 Backlight WLED driver supports up to a 29V output voltage for + 4 channels of 8 series WLEDs. Each channel supports up to 30mA of current + capability with 2048 current steps (11 bits) in exponential or linear + mapping curves. + +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-input-bit: + $ref: /schemas/types.yaml#/definitions/uint8
Documentation/devicetree/bindings/leds/backlight/mediatek,mt6370-backlight.yaml line 59
Quoted 10 lines
Documentation/devicetree/bindings/leds/backlight/mediatek,mt6370-backlight.yaml new file +10
-0+ enum: [0, 1, 2, 3] + description: | + The selection of the upper and lower bounds threshold of backlight + PWM resolution. If we choose selection 3 (6 bits), the variation of PWM + resolution needs over than 64 steps (2^6). + value mapping: + - 0: 1 + - 1: 2 + - 2: 4 + - 3: 6
Nope, I said last time:
"In any case you cannot have values mapping"
Please use proper real world value, not some register bits. The property name also needs fixing.
Quoted 5 lines
Documentation/devicetree/bindings/leds/backlight/mediatek,mt6370-backlight.yaml new file +5
-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 74
Quoted 10 lines
Documentation/devicetree/bindings/leds/backlight/mediatek,mt6370-backlight.yaml new file +10
-0+ + mediatek,bled-ovp-microvolt: + enum: [0, 1, 2, 3] + description: | + Backlight OVP level selection. + value mapping: + - 0: 17000000 + - 1: 21000000 + - 2: 25000000 + - 3: 29000000
No. Please test your bindings.
microvolt cannot be 1 mV. It's 21000000, not 1. No value mappings.
Quoted 5 lines
Documentation/devicetree/bindings/leds/backlight/mediatek,mt6370-backlight.yaml new file +5
-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 89
Quoted 10 lines
Documentation/devicetree/bindings/leds/backlight/mediatek,mt6370-backlight.yaml new file +10
-0+ + mediatek,bled-ocp-microamp: + enum: [0, 1, 2, 3] + description: | + Backlight OC level selection. + value mapping: + - 0: 900000 + - 1: 1200000 + - 2: 1500000 + - 3: 1800000
Nope.
Quoted 8 lines
Documentation/devicetree/bindings/leds/backlight/mediatek,mt6370-backlight.yaml new file +8
-0+ + 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
Documentation/devicetree/bindings/leds/backlight/mediatek,mt6370-backlight.yaml line 107
Quoted 10 lines
Documentation/devicetree/bindings/leds/backlight/mediatek,mt6370-backlight.yaml new file +10
-0+ - 2: CH2 + - 3: CH1 + minimum: 1 + maximum: 15 + +required: + - compatible + - mediatek,bled-channel-use + +additionalProperties: false
Best regards,
Krzysztof
Re: [PATCH v2 06/15] dt-bindings: mfd: Add Mediatek MT6370
In reply to ChiaEn WuQuoted 59 lines · ChiaEn Wu
From: ChiYuan Huang <[email protected]>
Add Mediatek MT6370 binding documentation.
Signed-off-by ChiYuan Huang <[email protected]>--- .../bindings/mfd/mediatek,mt6370.yaml | 279 ++++++++++++++++++ .../dt-bindings/iio/adc/mediatek,mt6370_adc.h | 18 ++ 2 files changed, 297 insertions(+) create mode 100644 Documentation/devicetree/bindings/mfd/mediatek,mt6370.yaml create mode 100644 include/dt-bindings/iio/adc/mediatek,mt6370_adc.hDocumentation/devicetree/bindings/mfd/mediatek,mt6370.yaml new file +41
-0@@ -0,0 +1,279 @@ +# 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: | + Provides 9 channels for system monitoring, including vbusdiv5, vbusdiv2, + vbat, vsys, chg_vddp, ts_bat, ibus, ibat, and temp_jc. +
Documentation/devicetree/bindings/mfd/mediatek,mt6370.yaml line 51
Quoted 10 lines
Documentation/devicetree/bindings/mfd/mediatek,mt6370.yaml new file +10
-0+ properties: + compatible: + const: mediatek,mt6370-adc + + "#io-channel-cells": + const: 1 + + required: + - compatible + - '#io-channel-cells'
Decide in your entire patchset whether you use ' or ". Don't mix.
Since you did not test your bindings, I am not reviewing it. First, test them. No need for me to do the job of a automated tool, right?
Best regards,
Krzysztof
Re: [PATCH v2 10/15] regulator: mt6370: Add mt6370 DisplayBias and VibLDO support
In reply to Randy DunlapHi Randy,
Thanks for your helpful comments!
We will refine them in the next patch, thanks!
Randy Dunlap <[email protected]> 於 2022年6月14日 週二 凌晨4:15寫道:
Quoted 21 lines · ChiaEn Wu
Quoted 5 lines
drivers/regulator/Kconfig +0
-0drivers/regulator/Kconfig config REGULATOR_MT6360 · line 812
Quoted 9 lines
drivers/regulator/Kconfig +6
-0@@ -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 onesupports
Quoted 7 lines
drivers/regulator/Kconfig config REGULATOR_MT6360 · line 813
Quoted 1 line
drivers/regulator/Kconfig +1
-0+ general purpose LDO which commonly used to drive the vibrator.which is commonly used to drive the vibrator.
--
~Randy
Best regards,
ChiaEn Wu
Re: [PATCH v2 11/15] iio: adc: mt6370: Add Mediatek MT6370 support
In reply to Randy DunlapHi Randy,
Thanks for your comment!
I apologize for any inconvenience caused when you decoded this help text. I will refine this in the next patch, thanks!
Randy Dunlap <[email protected]> 於 2022年6月14日 週二 凌晨4:17寫道:
Quoted 22 lines
Hi,
Quoted 5 lines · ChiaEn Wu
drivers/iio/adc/Kconfig +0
-0drivers/iio/adc/Kconfig config MEDIATEK_MT6360_ADC · line 746
Quoted 10 lines
drivers/iio/adc/Kconfig +7
-0@@ -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 smartphonesPlease try again on the help text. I can't decode that.
Quoted 4 lines
drivers/iio/adc/Kconfig config MEDIATEK_MT6360_ADC · line 747
Quoted 1 line
drivers/iio/adc/Kconfig +1
-0+ and tablets and supports a 9 channel general purpose ADC.--
~Randy
Best Regards,
ChiaEn Wu
Re: [PATCH v2 15/15] video: backlight: mt6370: Add Mediatek MT6370 support
In reply to Daniel ThompsonHi Daniel,
Thanks for your helpful feedback!
Daniel Thompson <[email protected]> 於 2022年6月14日 週二 凌晨1:08寫道:
Quoted 9 lines · ChiaEn Wu
drivers/video/backlight/mt6370-backlight.c line 127
Quoted 2 lines
drivers/video/backlight/mt6370-backlight.c new file +2
-0+static int mt6370_init_backlight_properties (struct mt6370_priv *priv, +struct backlight_properties *props)Most of the changes in this version looks good... but it looks the new code in this function has a number of problems. See below...
Quoted 14 lines
drivers/video/backlight/mt6370-backlight.c line 137
Quoted 10 lines
drivers/video/backlight/mt6370-backlight.c new file +10
-0+{ +struct device *dev = priv->dev; +u8 prop_val; +u32 brightness; +unsigned int mask, val; +int ret; + +/* Vendor optional properties +* if property not exist, keep value in default. +*/ That's not the right strategy for booleans. Not existing means false (e.g. flags should actively be unset).
I am so sorry for making these mistakes...
I will try to refine them in the right strategy in the next patch!
Quoted 33 lines
drivers/video/backlight/mt6370-backlight.c line 144
Quoted 8 lines
drivers/video/backlight/mt6370-backlight.c new file +7
-0+if (device_property_read_bool (dev,"mediatek,bled-pwm-enable" )) { + ret =regmap_update_bits (priv->regmap,MT6370_REG_BL_PWM , +MT6370_BL_PWM_EN_MASK , +MT6370_BL_PWM_EN_MASK ); +if (ret) +return ret; + }As above comment... all of the boolean properties are now being read incorrectly.
Quoted 20 lines
drivers/video/backlight/mt6370-backlight.c new file +20
-0+ +if (device_property_read_bool (dev,"mediatek,bled-pwm-hys-enable" )) { + ret =regmap_update_bits (priv->regmap,MT6370_REG_BL_PWM , +MT6370_BL_PWM_HYS_EN_MASK , +MT6370_BL_PWM_HYS_EN_MASK ); +if (ret) +return ret; + } + + ret =device_property_read_u8 (dev,"mediatek,bled-pwm-hys-input-bit" , + &prop_val); +if (!ret) { + val =min_t (u8, prop_val,3 ) + << (ffs (MT6370_BL_PWM_HYS_SEL_MASK ) -1 ); + ret =regmap_update_bits (priv->regmap,MT6370_REG_BL_PWM , +MT6370_BL_PWM_HYS_SEL_MASK , val); +if (ret) +return ret; + } +
Quoted 8 lines
drivers/video/backlight/mt6370-backlight.c line 169
Quoted 5 lines
drivers/video/backlight/mt6370-backlight.c new file +5
-0+ ret =device_property_read_u8 (dev,"mediatek,bled-ovp-microvolt" , + &prop_val); +if (!ret) { + val =min_t (u8, prop_val,3 ) + << (ffs (MT6370_BL_OVP_SEL_MASK ) -1 );This has been renamed but still seems to the using 0, 1, 2, 3 rather than an actual value in microvolts.
I’m so sorry for using the not actual value in microvolts and microamps. I will refine these mistakes along with DT in the next patch. Thank you!
Quoted 57 lines
Quoted 11 lines
drivers/video/backlight/mt6370-backlight.c new file +9
-0+ ret =regmap_update_bits (priv->regmap,MT6370_REG_BL_BSTCTRL , +MT6370_BL_OVP_SEL_MASK , val); +if (ret) +return ret; + } + +if (device_property_read_bool (dev,"mediatek,bled-ovp-shutdown" )) { + ret = regmap_update_bits(priv->regmap, MT6370_REG_BL_BSTCTRL, + MT6370_BL_OVP_EN_MASK,drivers/video/backlight/mt6370-backlight.c line 188
Quoted 10 lines
drivers/video/backlight/mt6370-backlight.c new file +10
-0+ MT6370_BL_OVP_EN_MASK); +if (ret) +return ret; + } + + ret =device_property_read_u8 (dev,"mediatek,bled-ocp-microamp" , + &prop_val); +if (!ret) { + val =min_t (u8, prop_val,3 ) + << (ffs (MT6370_BL_OC_SEL_MASK ) -1 );Likewise, should this be accepting a value in microamps?
Quoted 32 lines
drivers/video/backlight/mt6370-backlight.c new file +32
-0+ ret =regmap_update_bits (priv->regmap,MT6370_REG_BL_BSTCTRL , +MT6370_BL_OC_SEL_MASK , val); +if (ret) +return ret; + } + +if (device_property_read_bool (dev,"mediatek,bled-ocp-shutdown" )) { + ret =regmap_update_bits (priv->regmap,MT6370_REG_BL_BSTCTRL , +MT6370_BL_OC_EN_MASK , +MT6370_BL_OC_EN_MASK ); +if (ret) +return ret; + } + +/* Common properties */ + ret =device_property_read_u32 (dev,"max-brightness" , &brightness); +if (ret) + brightness =MT6370_BL_MAX_BRIGHTNESS ; + + props->max_brightness =min_t (u32, brightness, +MT6370_BL_MAX_BRIGHTNESS ); + + ret =device_property_read_u32 (dev,"default-brightness" , &brightness); +if (ret) + brightness = props->max_brightness; + + props->brightness =min_t (u32, brightness, props->max_brightness); + + + ret =device_property_read_u8 (dev,"mediatek,bled-channel-use" , + &prop_val); +if (ret) {
Quoted 9 lines
drivers/video/backlight/mt6370-backlight.c line 226
Quoted 6 lines
drivers/video/backlight/mt6370-backlight.c new file +6
-0+dev_err (dev,"mediatek,bled-channel-use DT property missing\n" ); +return ret; + } + +if (!prop_val || prop_val >MT6370_BL_MAX_CH ) { +dev_err (dev,"No channel specified (ch_val:%d)\n" , prop_val);Error string has not been updated to match condition that triggers it.
I will refine this wrong error string in the next patch, thanks!
Quoted 6 lines
Review
Quoted 3 lines
(quoted diff) +2
-0+ return -EINVAL; + }Daniel.
Best regards,
ChiaEn Wu
Re: [PATCH v2 02/15] dt-bindings: power: supply: Add Mediatek MT6370 Charger
In reply to Krzysztof KozlowskiHi Krzysztof,
Thanks for your helpful comments! I have so some questions want to ask you below.
Krzysztof Kozlowski <[email protected]> 於 2022年6月17日 週五 清晨5:05寫道:
Quoted 52 lines · ChiaEn Wu
Quoted 50 lines
From: ChiaEn Wu <[email protected]>
Add Mediatek MT6370 Charger binding documentation.
Signed-off-by ChiaEn Wu <[email protected]>--- .../power/supply/mediatek,mt6370-charger.yaml | 60 +++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 Documentation/devicetree/bindings/power/supply/mediatek,mt6370-charger.yamlDocumentation/devicetree/bindings/power/supply/mediatek,mt6370-charger.yaml new file +34
-0@@ -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 + - description: usb plug in irq + - description: mivr irq + + interrupt-names: + items: + - const: attach_i + - const: uvp_d_evt + - const: mivr
Quoted 9 lines
Documentation/devicetree/bindings/power/supply/mediatek,mt6370-charger.yaml line 39
Quoted 5 lines
Documentation/devicetree/bindings/power/supply/mediatek,mt6370-charger.yaml new file +5
-0+ + io-channels: + description: | + Use ADC channel to read vbus, ibus, ibat, etc., info. Ibus ADC channel + is required.Add io-channel-names and describe each item - what type of ADC it is expected to be.
I'm afraid I might not be understanding what you mean.
I will try to add some text in "description" and "io-channel-names", like below
----------------------------------
io-channels:
description: |
Use ADC channel to read VBUS, IBUS, IBAT, etc., info. Ibus ADC channel is required. It can be seen ininclude/dt-bindings/iio/adc/mediatek,mt6370_adc.h
minItems: 1
maxItems: 9
io-channel-names:
items:
- const: vbusdiv5
- const: vbusdiv2
- ...
----------------------------------
Did these modifications meet your expectations?
Quoted 9 lines
Documentation/devicetree/bindings/power/supply/mediatek,mt6370-charger.yaml line 46
Quoted 7 lines
Documentation/devicetree/bindings/power/supply/mediatek,mt6370-charger.yaml new file +7
-0+ minItems: 1 + maxItems: 9 + + usb-otg-vbus-regulator: + type: object + description: OTG boost regulator. + $ref: /schemas/regulator/regulator.yaml#unevaluatedProperties: false
I will add this in the next patch.
Quoted 7 lines
Documentation/devicetree/bindings/power/supply/mediatek,mt6370-charger.yaml line 49
Quoted 4 lines
Documentation/devicetree/bindings/power/supply/mediatek,mt6370-charger.yaml new file +3
-0+ + properties: + enable-gpio:"gpios", so:
enable-gpios
If this otg regulator only uses one GPIO Pin, do I still need to change to "gpios"?
If so, I will refine it along with the regulator "enable-gpio" in MFD dt-binding.
Quoted 16 lines
Documentation/devicetree/bindings/power/supply/mediatek,mt6370-charger.yaml line 60
Quoted 12 lines
Documentation/devicetree/bindings/power/supply/mediatek,mt6370-charger.yaml new file +11
-0+ maxItems: 1 + +required: + - compatible + - interrupts + - interrupt-names + - io-channels + +additionalProperties: false + +...Best regards,
Krzysztof
Best regards,
ChiaEn Wu
Re: [PATCH v2 05/15] dt-bindings: backlight: Add Mediatek MT6370 backlight
In reply to Krzysztof KozlowskiHi Krzysztof,
Thanks for your helpful feedback, I have some questions want to confirm with you below.
Krzysztof Kozlowski <[email protected]> 於 2022年6月17日 週五 清晨5:13寫道:
Quoted 81 lines · ChiaEn Wu
Quoted 65 lines
From: ChiYuan Huang <[email protected]>
Add mt6370 backlight binding documentation.
Signed-off-by ChiYuan Huang <[email protected]>--- .../backlight/mediatek,mt6370-backlight.yaml | 107 ++++++++++++++++++ 1 file changed, 107 insertions(+) create mode 100644 Documentation/devicetree/bindings/leds/backlight/mediatek,mt6370-backlight.yamlDocumentation/devicetree/bindings/leds/backlight/mediatek,mt6370-backlight.yaml new file +49
-0@@ -0,0 +1,107 @@ +# 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: | + This module is part of the MT6370 MFD device. + The MT6370 Backlight WLED driver supports up to a 29V output voltage for + 4 channels of 8 series WLEDs. Each channel supports up to 30mA of current + capability with 2048 current steps (11 bits) in exponential or linear + mapping curves. + +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-input-bit: + $ref: /schemas/types.yaml#/definitions/uint8Documentation/devicetree/bindings/leds/backlight/mediatek,mt6370-backlight.yaml line 59
Quoted 10 lines
Documentation/devicetree/bindings/leds/backlight/mediatek,mt6370-backlight.yaml new file +10
-0+ enum: [0, 1, 2, 3] + description: | + The selection of the upper and lower bounds threshold of backlight + PWM resolution. If we choose selection 3 (6 bits), the variation of PWM + resolution needs over than 64 steps (2^6). + value mapping: + - 0: 1 + - 1: 2 + - 2: 4 + - 3: 6Nope, I said last time:
"In any case you cannot have values mapping"
Quoted 2 lines
Please use proper real world value, not some register bits. The property name also needs fixing.
I so apologized for misunderstanding your meaning...
I try to modify it like below.
--------
mediatek,bled-pwm-hys-input-threshold-steps:
$ref: /schemas/types.yaml#/definitions/uint8
enum: [1, 4, 16, 64]
description: |
The selection of the upper and lower bounds threshold of backlight PWM resolution. If we choose selection 64, the variation of PWM resolution needs over 64 steps.
--------
If these changes meet your expectations, I will try to modify "bled-ovp-microvolt" and "bled-ocp-microamp" in the same way. Thank you so much.
Quoted 53 lines
Quoted 6 lines
Documentation/devicetree/bindings/leds/backlight/mediatek,mt6370-backlight.yaml new file +5
-0+ + mediatek,bled-ovp-shutdown: + description: | + Enable the backlight shutdown when OVP level triggered + type: booleanDocumentation/devicetree/bindings/leds/backlight/mediatek,mt6370-backlight.yaml line 74
Quoted 10 lines
Documentation/devicetree/bindings/leds/backlight/mediatek,mt6370-backlight.yaml new file +10
-0+ + mediatek,bled-ovp-microvolt: + enum: [0, 1, 2, 3] + description: | + Backlight OVP level selection. + value mapping: + - 0: 17000000 + - 1: 21000000 + - 2: 25000000 + - 3: 29000000No. Please test your bindings.
microvolt cannot be 1 mV. It's 21000000, not 1. No value mappings.
Quoted 5 lines
Documentation/devicetree/bindings/leds/backlight/mediatek,mt6370-backlight.yaml new file +5
-0+ + mediatek,bled-ocp-shutdown: + description: | + Enable the backlight shutdown when OCP level triggerred. + type: booleanDocumentation/devicetree/bindings/leds/backlight/mediatek,mt6370-backlight.yaml line 89
Quoted 10 lines
Documentation/devicetree/bindings/leds/backlight/mediatek,mt6370-backlight.yaml new file +10
-0+ + mediatek,bled-ocp-microamp: + enum: [0, 1, 2, 3] + description: | + Backlight OC level selection. + value mapping: + - 0: 900000 + - 1: 1200000 + - 2: 1500000 + - 3: 1800000Nope.
Quoted 14 lines
Documentation/devicetree/bindings/leds/backlight/mediatek,mt6370-backlight.yaml new file +14
-0+ + 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:
Quoted 8 lines
Documentation/devicetree/bindings/leds/backlight/mediatek,mt6370-backlight.yaml line 107
Quoted 4 lines
Documentation/devicetree/bindings/leds/backlight/mediatek,mt6370-backlight.yaml new file +4
-0+ - compatible + - mediatek,bled-channel-use + +additionalProperties: falseBest regards,
Krzysztof
Best regards,
ChiaEn Wu
Re: [PATCH v2 06/15] dt-bindings: mfd: Add Mediatek MT6370
In reply to Rob HerringHi Rob,
Rob Herring <[email protected]> 於 2022年6月13日 週一 晚上9:33寫道:
Quoted 31 lines · ChiaEn Wu
Quoted 4 lines
From: ChiYuan Huang <[email protected]>
Add Mediatek MT6370 binding documentation.
Quoted 8 lines
Signed-off-by ChiYuan Huang <[email protected]>--- .../bindings/mfd/mediatek,mt6370.yaml | 279 ++++++++++++++++++ .../dt-bindings/iio/adc/mediatek,mt6370_adc.h | 18 ++ 2 files changed, 297 insertions(+) create mode 100644 Documentation/devicetree/bindings/mfd/mediatek,mt6370.yaml create mode 100644 include/dt-bindings/iio/adc/mediatek,mt6370_adc.hMy bot found errors running 'make DT_CHECKER_FLAGS=-m
dt_binding_check' on your patch (DT_CHECKER_FLAGSis new in v5.13):yamllint warnings/errors:
dtschema/dtc warnings/errors:
./Documentation/devicetree/bindings/mfd/mediatek,mt6370.yaml: Unable to find schema file matching $id: http://devicetree.org/schemas/leds/backlight/mediatek,mt6370-backlight.yaml
/builds/robherring/linux-dt-review/Documentation/devicetree/bindings/mfd/mediatek,mt6370.example.dtb: pmic@34: backlight: False schema does not allow {'compatible': ['mediatek,mt6370-backlight'], 'mediatek,bled-channel-use': b'\x0f'}
From schema: /builds/robherring/linux-dt-review/Documentation/devicetree/bindings/mfd/mediatek,mt6370.yaml
/builds/robherring/linux-dt-review/Documentation/devicetree/bindings/mfd/mediatek,mt6370.example.dtb: pmic@34: charger: False schema does not allow {'compatible': ['mediatek,mt6370-charger'], 'interrupts': [[48], [68], [6]], 'interrupt-names': ['attach_i', 'uvp_d_evt', 'mivr'], 'io-channels': [[1, 5]], 'usb-otg-vbus-regulator': {'regulator-name': ['mt6370-usb-otg-vbus'], 'regulator-min-microvolt': [[4350000]], 'regulator-max-microvolt': [[5800000]], 'regulator-min-microamp': [[500000]], 'regulator-max-microamp': [[3000000]], 'phandle': [[2]]}}
From schema: /builds/robherring/linux-dt-review/Documentation/devicetree/bindings/mfd/mediatek,mt6370.yaml
/builds/robherring/linux-dt-review/Documentation/devicetree/bindings/mfd/mediatek,mt6370.example.dtb: pmic@34: tcpc: False schema does not allow {'compatible': ['mediatek,mt6370-tcpc'], 'interrupts-extended': [[4294967295, 4, 8]], 'connector': {'compatible': ['usb-c-connector'], 'label': ['USB-C'], 'vbus-supply': [[2]], 'data-role': ['dual'], 'power-role': ['dual'], 'try-power-role': ['sink'], 'source-pdos': [[570527844]], 'sink-pdos': [[570527944]], 'op-sink-microwatt': [[10000000]], 'ports': {'#address-cells': [[1]], '#size-cells': [[0]], 'port@0': {'reg': [[0]], 'endpoint': {'remote-endpoint': [[4294967295]]}}, 'port@1': {'reg': [[1]], 'endpoint': {'remote-endpoint': [[4294967295]]}}, 'port@2': {'reg': [[2]], 'endpoint': {'remote-endpoint': [[4294967295]]}}}}}
From schema: /builds/robherring/linux-dt-review/Documentation/devicetree/bindings/mfd/mediatek,mt6370.yaml
/builds/robherring/linux-dt-review/Documentation/devicetree/bindings/mfd/mediatek,mt6370.example.dtb: pmic@34: indicator: False schema does not allow {'compatible': ['mediatek,mt6370-indicator'], '#address-cells': [[1]], '#size-cells': [[0]], 'multi-led@0': {'reg': [[0]], 'function': ['indicator'], 'color': [[9]], 'led-max-microamp': [[24000]], '#address-cells': [[1]], '#size-cells': [[0]], 'led@0': {'reg': [[0]], 'color': [[1]]}, 'led@1': {'reg': [[1]], 'color': [[2]]}, 'led@2': {'reg': [[2]], 'color': [[3]]}}, 'led@3': {'reg': [[3]], 'function': ['indicator'], 'color': [[0]], 'led-max-microamp': [[6000]]}}
From schema: /builds/robherring/linux-dt-review/Documentation/devicetree/bindings/mfd/mediatek,mt6370.yaml
/builds/robherring/linux-dt-review/Documentation/devicetree/bindings/mfd/mediatek,mt6370.example.dtb: pmic@34: flashlight: False schema does not allow {'compatible': ['mediatek,mt6370-flashlight'], '#address-cells': [[1]], '#size-cells': [[0]], 'led@0': {'reg': [[0]], 'led-sources': [[0]], 'function': ['flash'], 'color': [[0]], 'function-enumerator': [[1]], 'led-max-microamp': [[200000]], 'flash-max-microamp': [[500000]], 'flash-max-timeout-us': [[1248000]]}, 'led@1': {'reg': [[1]], 'led-sources': [[1]], 'function': ['flash'], 'color': [[0]], 'function-enumerator': [[2]], 'led-max-microamp': [[200000]], 'flash-max-microamp': [[500000]], 'flash-max-timeout-us': [[1248000]]}}
Quoted 9 lines
From schema: /builds/robherring/linux-dt-review/Documentation/devicetree/bindings/mfd/mediatek,mt6370.yaml
/builds/robherring/linux-dt-review/Documentation/devicetree/bindings/mfd/mediatek,mt6370.example.dtb: backlight: mediatek,bled-channel-use: b'\x0f' is not of type 'object', 'array', 'boolean', 'null'
From schema:/usr/local/lib/python3.10/dist-packages/dtschema/schemas/dt-core.yamlDocumentation/devicetree/bindings/mfd/mediatek,mt6370.example.dtb:0:0: /example-0/i2c/pmic@34/backlight: failed to match any schema with compatible: ['mediatek,mt6370-backlight']Documentation/devicetree/bindings/mfd/mediatek,mt6370.example.dtb:0:0: /example-0/i2c/pmic@34/charger: failed to match any schema with compatible: ['mediatek,mt6370-charger']Documentation/devicetree/bindings/mfd/mediatek,mt6370.example.dtb:0:0: /example-0/i2c/pmic@34/indicator: failed to match any schema with compatible: ['mediatek,mt6370-indicator']Documentation/devicetree/bindings/mfd/mediatek,mt6370.example.dtb:0:0: /example-0/i2c/pmic@34/flashlight: failed to match any schema with compatible: ['mediatek,mt6370-flashlight']Documentation/devicetree/bindings/mfd/mediatek,mt6370.example.dtb:0:0: /example-0/i2c/pmic@34/tcpc: failed to match any schema with compatible: ['mediatek,mt6370-tcpc']
Before we submitted these patches, we had already checked by running this command below,
"make DT_CHECKER_FLAGS=-m dt_binding_check DT_SCHEMA_FILES=Documentation/devicetree/bindings/mfd/mediatek,mt6370.yaml". But we could not find any errors like your error msg after the checking process.
Our mfd dt-binding patch is dependent on "backlight dt-binding", "charger dt-binding", "tcpc dt-binding", "indicator dt-binding" and "flashlight dt-binding" patches.
Would you please apply them before you check mfd dt-binding patch? Thank you so much!
Quoted 7 lines
doc reference errors (make refcheckdocs):
See https://patchwork.ozlabs.org/patch/
This check can fail if there are any dependencies. The base for a patch series is generally the most recent rc1.
Quoted 8 lines
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.
Best regards,
ChiaEn Wu
Re: [PATCH v2 06/15] dt-bindings: mfd: Add Mediatek MT6370
In reply to Krzysztof KozlowskiHi Krzysztof,
Krzysztof Kozlowski <[email protected]> 於 2022年6月17日 週五 清晨5:15寫道:
Quoted 65 lines · ChiaEn Wu
Quoted 63 lines
From: ChiYuan Huang <[email protected]>
Add Mediatek MT6370 binding documentation.
Signed-off-by ChiYuan Huang <[email protected]>--- .../bindings/mfd/mediatek,mt6370.yaml | 279 ++++++++++++++++++ .../dt-bindings/iio/adc/mediatek,mt6370_adc.h | 18 ++ 2 files changed, 297 insertions(+) create mode 100644 Documentation/devicetree/bindings/mfd/mediatek,mt6370.yaml create mode 100644 include/dt-bindings/iio/adc/mediatek,mt6370_adc.hDocumentation/devicetree/bindings/mfd/mediatek,mt6370.yaml new file +45
-0@@ -0,0 +1,279 @@ +# 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: | + Provides 9 channels for system monitoring, including vbusdiv5, vbusdiv2, + vbat, vsys, chg_vddp, ts_bat, ibus, ibat, and temp_jc. + + properties: + compatible: + const: mediatek,mt6370-adc +
Quoted 8 lines
Documentation/devicetree/bindings/mfd/mediatek,mt6370.yaml line 51
Quoted 6 lines
Documentation/devicetree/bindings/mfd/mediatek,mt6370.yaml new file +6
-0+ "#io-channel-cells": + const: 1 + + required: + - compatible + - '#io-channel-cells'Decide in your entire patchset whether you use ' or ". Don't mix.
Thanks for your comments.
We apologize for doing these mistakes...
We will use the same symbol in the entire patchset and check again before the next submission.
Quoted 6 lines
Since you did not test your bindings, I am not reviewing it. First, test them. No need for me to do the job of a automated tool, right?
Best regards,
Krzysztof
Best regards,
ChiaEn Wu
Re: [PATCH v2 08/15] mfd: mt6370: Add Mediatek MT6370 support
In reply to Lee JonesHi Lee,
Thanks for your helpful comments, we have some questions and replies below.
Lee Jones <[email protected]> 於 2022年6月16日 週四 清晨6:49寫道:
Quoted 35 lines · ChiaEn Wu
Quoted 20 lines
From: ChiYuan Huang <[email protected]>
Add Mediatek MT6370 MFD support.
Signed-off-by ChiYuan Huang <[email protected]>--- drivers/mfd/Kconfig | 13 ++ drivers/mfd/Makefile | 1 + drivers/mfd/mt6370.c | 349 +++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 363 insertions(+) create mode 100644 drivers/mfd/mt6370.cdrivers/mfd/Kconfig +0
-0@@ -937,6 +937,19 @@ config MFD_MT6360 PMIC part includes 2-channel BUCKs and 2-channel LDOs LDO part includes 4-channel LDOsdrivers/mfd/Kconfig config MFD_MT6360 · line 948
Quoted 10 lines
drivers/mfd/Kconfig +9
-0+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, RGBs/integrates/consists of a/
Quoted 1 line
"ADC"
We will fine it in the next patch.
Quoted 7 lines
drivers/mfd/Kconfig config MFD_MT6360 · line 951
Quoted 5 lines
drivers/mfd/Kconfig +3
-0+ LEDs, dual channel flashlight, WLED backlight driver, display bias + voltage supply, one general purpose LDO, and cc logic + controller with USBPD commmunication capable.The last part makes no sense - "and is USBPD"?
If we modify this help text to
"one general purpose LDO, and the USB Type-C & PD controller complies with the latest USB Type-C and PD standards",
did these modifications meet your expectations?
Quoted 126 lines
Quoted 126 lines
drivers/mfd/Kconfig +0
-0config MFD_MT6397 tristate "MediaTek MT6397 PMIC Support" select MFD_COREdrivers/mfd/Makefile +1
-0@@ -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.odrivers/mfd/mt6370.c new file +104
-0@@ -0,0 +1,349 @@ +// SPDX-License-Identifier: GPL-2.0 + +#include <linux/bits.h> +#include <linux/i2c.h> +#include <linux/interrupt.h> +#include <linux/kernel.h> +#include <linux/mfd/core.h> +#include <linux/module.h> +#include <linux/regmap.h> + +enum { +MT6370_USBC_I2C =0 , +MT6370_PMU_I2C , +MT6370_MAX_I2C +}; + +#define MT6370_REG_DEV_INFO 0x100 +#define MT6370_REG_CHG_IRQ1 0x1C0 +#define MT6370_REG_CHG_MASK1 0x1E0 + +#define MT6370_VENID_MASK GENMASK(7, 4) + +#define MT6370_NUM_IRQREGS 16 +#define MT6370_USBC_I2CADDR 0x4E +#define MT6370_REG_ADDRLEN 2 +#define MT6370_REG_MAXADDR 0x1FF + +/* IRQ definitions */ +#define MT6370_IRQ_DIRCHGON 0 +#define MT6370_IRQ_CHG_TREG 4 +#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 +#define MT6370_IRQ_CHG_VSYSUV 12 +#define MT6370_IRQ_CHG_VSYSOV 13 +#define MT6370_IRQ_CHG_VBATOV 14 +#define MT6370_IRQ_CHG_VINOVPCHG 15 +#define MT6370_IRQ_TS_BAT_COLD 20 +#define MT6370_IRQ_TS_BAT_COOL 21 +#define MT6370_IRQ_TS_BAT_WARM 22 +#define MT6370_IRQ_TS_BAT_HOT 23 +#define MT6370_IRQ_TS_STATC 24 +#define MT6370_IRQ_CHG_FAULT 25 +#define MT6370_IRQ_CHG_STATC 26 +#define MT6370_IRQ_CHG_TMR 27 +#define MT6370_IRQ_CHG_BATABS 28 +#define MT6370_IRQ_CHG_ADPBAD 29 +#define MT6370_IRQ_CHG_RVP 30 +#define MT6370_IRQ_TSHUTDOWN 31 +#define MT6370_IRQ_CHG_IINMEAS 32 +#define MT6370_IRQ_CHG_ICCMEAS 33 +#define MT6370_IRQ_CHGDET_DONE 34 +#define MT6370_IRQ_WDTMR 35 +#define MT6370_IRQ_SSFINISH 36 +#define MT6370_IRQ_CHG_RECHG 37 +#define MT6370_IRQ_CHG_TERM 38 +#define MT6370_IRQ_CHG_IEOC 39 +#define MT6370_IRQ_ADC_DONE 40 +#define MT6370_IRQ_PUMPX_DONE 41 +#define MT6370_IRQ_BST_BATUV 45 +#define MT6370_IRQ_BST_MIDOV 46 +#define MT6370_IRQ_BST_OLP 47 +#define MT6370_IRQ_ATTACH 48 +#define MT6370_IRQ_DETACH 49 +#define MT6370_IRQ_HVDCP_STPDONE 51 +#define MT6370_IRQ_HVDCP_VBUSDET_DONE 52 +#define MT6370_IRQ_HVDCP_DET 53 +#define MT6370_IRQ_CHGDET 54 +#define MT6370_IRQ_DCDT 55 +#define MT6370_IRQ_DIRCHG_VGOK 59 +#define MT6370_IRQ_DIRCHG_WDTMR 60 +#define MT6370_IRQ_DIRCHG_UC 61 +#define MT6370_IRQ_DIRCHG_OC 62 +#define MT6370_IRQ_DIRCHG_OV 63 +#define MT6370_IRQ_OVPCTRL_SWON 67 +#define MT6370_IRQ_OVPCTRL_UVP_D 68 +#define MT6370_IRQ_OVPCTRL_UVP 69 +#define MT6370_IRQ_OVPCTRL_OVP_D 70 +#define MT6370_IRQ_OVPCTRL_OVP 71 +#define MT6370_IRQ_FLED_STRBPIN 72 +#define MT6370_IRQ_FLED_TORPIN 73 +#define MT6370_IRQ_FLED_TX 74 +#define MT6370_IRQ_FLED_LVF 75 +#define MT6370_IRQ_FLED2_SHORT 78 +#define MT6370_IRQ_FLED1_SHORT 79 +#define MT6370_IRQ_FLED2_STRB 80 +#define MT6370_IRQ_FLED1_STRB 81 +#define mT6370_IRQ_FLED2_STRB_TO 82 +#define MT6370_IRQ_FLED1_STRB_TO 83 +#define MT6370_IRQ_FLED2_TOR 84 +#define MT6370_IRQ_FLED1_TOR 85 +#define MT6370_IRQ_OTP 93 +#define MT6370_IRQ_VDDA_OVP 94 +#define MT6370_IRQ_VDDA_UV 95 +#define MT6370_IRQ_LDO_OC 103 +#define MT6370_IRQ_BLED_OCP 118 +#define MT6370_IRQ_BLED_OVP 119 +#define MT6370_IRQ_DSV_VNEG_OCP 123 +#define MT6370_IRQ_DSV_VPOS_OCP 124 +#define MT6370_IRQ_DSV_BST_OCP 125 +#define MT6370_IRQ_DSV_VNEG_SCP 126 +#define MT6370_IRQ_DSV_VPOS_SCP 127 +
Quoted 8 lines
drivers/mfd/mt6370.c line 110
Quoted 6 lines
drivers/mfd/mt6370.c new file +6
-0+struct mt6370_info { +struct i2c_client *i2c[MT6370_MAX_I2C ]; +struct device *dev; +struct regmap *regmap; +struct regmap_irq_chip_data *irq_data; +};Can we shove all of the above into a header file?
Well... In Patch v1, we put these "#define IRQ" into "include/dt-bindings/mfd/mediatek,mt6370.h".
But the reviewer of DT files hoped us to remove this header file, we put these "#define IRQ" in this .c file.
Shall we leave them here or put them into the header file in "driver/power/supply/mt6370-charger.h"?
Quoted 117 lines
Quoted 117 lines
drivers/mfd/mt6370.c new file +116
-0+static const struct regmap_irq mt6370_irqs[] = { +REGMAP_IRQ_REG_LINE (MT6370_IRQ_DIRCHGON ,8 ), +REGMAP_IRQ_REG_LINE (MT6370_IRQ_CHG_TREG ,8 ), +REGMAP_IRQ_REG_LINE (MT6370_IRQ_CHG_AICR ,8 ), +REGMAP_IRQ_REG_LINE (MT6370_IRQ_CHG_MIVR ,8 ), +REGMAP_IRQ_REG_LINE (MT6370_IRQ_PWR_RDY ,8 ), +REGMAP_IRQ_REG_LINE (MT6370_IRQ_FL_CHG_VINOVP ,8 ), +REGMAP_IRQ_REG_LINE (MT6370_IRQ_CHG_VSYSUV ,8 ), +REGMAP_IRQ_REG_LINE (MT6370_IRQ_CHG_VSYSOV ,8 ), +REGMAP_IRQ_REG_LINE (MT6370_IRQ_CHG_VBATOV ,8 ), +REGMAP_IRQ_REG_LINE (MT6370_IRQ_CHG_VINOVPCHG ,8 ), +REGMAP_IRQ_REG_LINE (MT6370_IRQ_TS_BAT_COLD ,8 ), +REGMAP_IRQ_REG_LINE (MT6370_IRQ_TS_BAT_COOL ,8 ), +REGMAP_IRQ_REG_LINE (MT6370_IRQ_TS_BAT_WARM ,8 ), +REGMAP_IRQ_REG_LINE (MT6370_IRQ_TS_BAT_HOT ,8 ), +REGMAP_IRQ_REG_LINE (MT6370_IRQ_TS_STATC ,8 ), +REGMAP_IRQ_REG_LINE (MT6370_IRQ_CHG_FAULT ,8 ), +REGMAP_IRQ_REG_LINE (MT6370_IRQ_CHG_STATC ,8 ), +REGMAP_IRQ_REG_LINE (MT6370_IRQ_CHG_TMR ,8 ), +REGMAP_IRQ_REG_LINE (MT6370_IRQ_CHG_BATABS ,8 ), +REGMAP_IRQ_REG_LINE (MT6370_IRQ_CHG_ADPBAD ,8 ), +REGMAP_IRQ_REG_LINE (MT6370_IRQ_CHG_RVP ,8 ), +REGMAP_IRQ_REG_LINE (MT6370_IRQ_TSHUTDOWN ,8 ), +REGMAP_IRQ_REG_LINE (MT6370_IRQ_CHG_IINMEAS ,8 ), +REGMAP_IRQ_REG_LINE (MT6370_IRQ_CHG_ICCMEAS ,8 ), +REGMAP_IRQ_REG_LINE (MT6370_IRQ_CHGDET_DONE ,8 ), +REGMAP_IRQ_REG_LINE (MT6370_IRQ_WDTMR ,8 ), +REGMAP_IRQ_REG_LINE (MT6370_IRQ_SSFINISH ,8 ), +REGMAP_IRQ_REG_LINE (MT6370_IRQ_CHG_RECHG ,8 ), +REGMAP_IRQ_REG_LINE (MT6370_IRQ_CHG_TERM ,8 ), +REGMAP_IRQ_REG_LINE (MT6370_IRQ_CHG_IEOC ,8 ), +REGMAP_IRQ_REG_LINE (MT6370_IRQ_ADC_DONE ,8 ), +REGMAP_IRQ_REG_LINE (MT6370_IRQ_PUMPX_DONE ,8 ), +REGMAP_IRQ_REG_LINE (MT6370_IRQ_BST_BATUV ,8 ), +REGMAP_IRQ_REG_LINE (MT6370_IRQ_BST_MIDOV ,8 ), +REGMAP_IRQ_REG_LINE (MT6370_IRQ_BST_OLP ,8 ), +REGMAP_IRQ_REG_LINE (MT6370_IRQ_ATTACH ,8 ), +REGMAP_IRQ_REG_LINE (MT6370_IRQ_DETACH ,8 ), +REGMAP_IRQ_REG_LINE (MT6370_IRQ_HVDCP_STPDONE ,8 ), +REGMAP_IRQ_REG_LINE (MT6370_IRQ_HVDCP_VBUSDET_DONE ,8 ), +REGMAP_IRQ_REG_LINE (MT6370_IRQ_HVDCP_DET ,8 ), +REGMAP_IRQ_REG_LINE (MT6370_IRQ_CHGDET ,8 ), +REGMAP_IRQ_REG_LINE (MT6370_IRQ_DCDT ,8 ), +REGMAP_IRQ_REG_LINE (MT6370_IRQ_DIRCHG_VGOK ,8 ), +REGMAP_IRQ_REG_LINE (MT6370_IRQ_DIRCHG_WDTMR ,8 ), +REGMAP_IRQ_REG_LINE (MT6370_IRQ_DIRCHG_UC ,8 ), +REGMAP_IRQ_REG_LINE (MT6370_IRQ_DIRCHG_OC ,8 ), +REGMAP_IRQ_REG_LINE (MT6370_IRQ_DIRCHG_OV ,8 ), +REGMAP_IRQ_REG_LINE (MT6370_IRQ_OVPCTRL_SWON ,8 ), +REGMAP_IRQ_REG_LINE (MT6370_IRQ_OVPCTRL_UVP_D ,8 ), +REGMAP_IRQ_REG_LINE (MT6370_IRQ_OVPCTRL_UVP ,8 ), +REGMAP_IRQ_REG_LINE (MT6370_IRQ_OVPCTRL_OVP_D ,8 ), +REGMAP_IRQ_REG_LINE (MT6370_IRQ_OVPCTRL_OVP ,8 ), +REGMAP_IRQ_REG_LINE (MT6370_IRQ_FLED_STRBPIN ,8 ), +REGMAP_IRQ_REG_LINE (MT6370_IRQ_FLED_TORPIN ,8 ), +REGMAP_IRQ_REG_LINE (MT6370_IRQ_FLED_TX ,8 ), +REGMAP_IRQ_REG_LINE (MT6370_IRQ_FLED_LVF ,8 ), +REGMAP_IRQ_REG_LINE (MT6370_IRQ_FLED2_SHORT ,8 ), +REGMAP_IRQ_REG_LINE (MT6370_IRQ_FLED1_SHORT ,8 ), +REGMAP_IRQ_REG_LINE (MT6370_IRQ_FLED2_STRB ,8 ), +REGMAP_IRQ_REG_LINE (MT6370_IRQ_FLED1_STRB ,8 ), +REGMAP_IRQ_REG_LINE (mT6370_IRQ_FLED2_STRB_TO,8 ), +REGMAP_IRQ_REG_LINE (MT6370_IRQ_FLED1_STRB_TO ,8 ), +REGMAP_IRQ_REG_LINE (MT6370_IRQ_FLED2_TOR ,8 ), +REGMAP_IRQ_REG_LINE (MT6370_IRQ_FLED1_TOR ,8 ), +REGMAP_IRQ_REG_LINE (MT6370_IRQ_OTP ,8 ), +REGMAP_IRQ_REG_LINE (MT6370_IRQ_VDDA_OVP ,8 ), +REGMAP_IRQ_REG_LINE (MT6370_IRQ_VDDA_UV ,8 ), +REGMAP_IRQ_REG_LINE (MT6370_IRQ_LDO_OC ,8 ), +REGMAP_IRQ_REG_LINE (MT6370_IRQ_BLED_OCP ,8 ), +REGMAP_IRQ_REG_LINE (MT6370_IRQ_BLED_OVP ,8 ), +REGMAP_IRQ_REG_LINE (MT6370_IRQ_DSV_VNEG_OCP ,8 ), +REGMAP_IRQ_REG_LINE (MT6370_IRQ_DSV_VPOS_OCP ,8 ), +REGMAP_IRQ_REG_LINE (MT6370_IRQ_DSV_BST_OCP ,8 ), +REGMAP_IRQ_REG_LINE (MT6370_IRQ_DSV_VNEG_SCP ,8 ), +REGMAP_IRQ_REG_LINE (MT6370_IRQ_DSV_VPOS_SCP ,8 ) +}; + +static const struct regmap_irq_chip mt6370_irq_chip = { + .name ="mt6370-irqs" , + .status_base =MT6370_REG_CHG_IRQ1 , + .mask_base =MT6370_REG_CHG_MASK1 , + .num_regs =MT6370_NUM_IRQREGS , + .irqs = mt6370_irqs, + .num_irqs =ARRAY_SIZE (mt6370_irqs), +}; + +static const struct resource mt6370_regulator_irqs[] = { +DEFINE_RES_IRQ_NAMED (MT6370_IRQ_DSV_VPOS_SCP ,"db_vpos_scp" ), +DEFINE_RES_IRQ_NAMED (MT6370_IRQ_DSV_VNEG_SCP ,"db_vneg_scp" ), +DEFINE_RES_IRQ_NAMED (MT6370_IRQ_DSV_BST_OCP ,"db_vbst_ocp" ), +DEFINE_RES_IRQ_NAMED (MT6370_IRQ_DSV_VPOS_OCP ,"db_vpos_ocp" ), +DEFINE_RES_IRQ_NAMED (MT6370_IRQ_DSV_VNEG_OCP ,"db_vneg_ocp" ), +DEFINE_RES_IRQ_NAMED (MT6370_IRQ_LDO_OC ,"ldo_oc" ) +}; + +static const struct mfd_cell mt6370_devices[] = { +MFD_CELL_OF ("adc" ,NULL ,NULL ,0 ,0 ,"mediatek,mt6370-adc" ), +MFD_CELL_OF ("charger" ,NULL ,NULL ,0 ,0 ,"mediatek,mt6370-charger" ), +MFD_CELL_OF ("backlight" ,NULL ,NULL ,0 ,0 ,"mediatek,mt6370-backlight" ), +MFD_CELL_OF ("flashlight" ,NULL ,NULL ,0 ,0 ,"mediatek,mt6370-flashlight" ), +MFD_CELL_OF ("indicator" ,NULL ,NULL ,0 ,0 ,"mediatek,mt6370-indicator" ), +MFD_CELL_OF ("tcpc" ,NULL ,NULL ,0 ,0 ,"mediatek,mt6370-tcpc" ), +MFD_CELL_RES ("regulator" , mt6370_regulator_irqs) +}; + +static int mt6370_check_vendor_info (struct mt6370_info *info) +{ +unsigned int devinfo; +int ret; + + ret =regmap_read (info->regmap,MT6370_REG_DEV_INFO , &devinfo); +if (ret) +return ret; + +switch (FIELD_GET (MT6370_VENID_MASK , devinfo)) {
Quoted 8 lines
drivers/mfd/mt6370.c line 233
Quoted 6 lines
drivers/mfd/mt6370.c new file +6
-0+case 0x8 :/* RT5081 */ +case 0xA :/* RT5081A */ +case 0xE :/* MT6370 */ +case 0xF :/* MT6371 */ +case 0x9 :/* MT6372P */ +case 0xB :/* MT6372CP */ Please define these and drop the comments.
OK, we will refine them in the next patch! Thanks!
Quoted 18 lines
Quoted 5 lines
drivers/mfd/mt6370.c new file +4
-0+break ; +default : +dev_err (info->dev,"Not invalid value 0x%02x\n" , devinfo); +return -ENODEV ;drivers/mfd/mt6370.c line 247
Quoted 10 lines
drivers/mfd/mt6370.c new file +10
-0+ } + +return 0 ; +} + +static int mt6370_regmap_read (void *context,const void *reg_buf, +size_t reg_size,void *val_buf,size_t val_size) +{ +struct mt6370_info *info = context; +u8 bank_idx = *(u8 *)reg_buf, bank_addr = *(u8 *)(reg_buf +1 );Looks a little scruffy. Perhaps allocate the values below.
Quoted 16 lines
Quoted 4 lines
drivers/mfd/mt6370.c new file +4
-0+int ret; + + ret =i2c_smbus_read_i2c_block_data (info->i2c[bank_idx], bank_addr, + val_size, val_buf);drivers/mfd/mt6370.c line 261
Quoted 10 lines
drivers/mfd/mt6370.c new file +10
-0+if (ret != val_size) +return ret; + +return 0 ; +} + +static int mt6370_regmap_write (void *context,const void *data,size_t count) +{ +struct mt6370_info *info = context; +u8 bank_idx = *(u8 *)data, bank_addr = *(u8 *)(data +1 );As above.
OK, we will try to refine these parts in the next patch.
Quoted 30 lines
Quoted 30 lines
drivers/mfd/mt6370.c new file +29
-0+int len = count -MT6370_REG_ADDRLEN ; + +return i2c_smbus_write_i2c_block_data (info->i2c[bank_idx], bank_addr, + len, data +MT6370_REG_ADDRLEN ); +} + +static const struct regmap_bus mt6370_regmap_bus = { + .read = mt6370_regmap_read, + .write = mt6370_regmap_write, +}; + +static const struct regmap_config mt6370_regmap_config = { + .reg_bits =16 , + .val_bits =8 , + .reg_format_endian =REGMAP_ENDIAN_BIG , + .max_register =MT6370_REG_MAXADDR , +}; + +static int mt6370_probe (struct i2c_client *i2c) +{ +struct mt6370_info *info; +struct i2c_client *usbc_i2c; +int ret; + + info =devm_kzalloc (&i2c->dev,sizeof (*info),GFP_KERNEL ); +if (!info) +return -ENOMEM ; + + info->dev = &i2c->dev;
Quoted 8 lines
drivers/mfd/mt6370.c line 296
Quoted 6 lines
drivers/mfd/mt6370.c new file +6
-0+ + usbc_i2c =devm_i2c_new_dummy_device (&i2c->dev, i2c->adapter, +MT6370_USBC_I2CADDR ); +if (IS_ERR (usbc_i2c)) { + ret =PTR_ERR (usbc_i2c); +dev_err (&i2c->dev,"Failed to register usbc i2c client %d\n" , ret);"USB-C I2C"?
MT6370 have two slave address, one is for the USB PD module and another one is for other modules.
So we use "USB-C I2C" to refer to the USB PD module.
Quoted 47 lines
Quoted 47 lines
drivers/mfd/mt6370.c new file +46
-0+return ret; + } + +/* Assign I2C client for PMU and TypeC */ + info->i2c[MT6370_PMU_I2C ] = i2c; + info->i2c[MT6370_USBC_I2C ] = usbc_i2c; + + info->regmap =devm_regmap_init (&i2c->dev, &mt6370_regmap_bus, info, + &mt6370_regmap_config); +if (IS_ERR (info->regmap)) { + ret =PTR_ERR (info->regmap); +dev_err (&i2c->dev,"Failed to register regmap (%d)\n" , ret); +return ret; + } + + ret =mt6370_check_vendor_info (info); +if (ret) { +dev_err (&i2c->dev,"Failed to check vendor info (%d)\n" , ret); +return ret; + } + + ret =devm_regmap_add_irq_chip (&i2c->dev, info->regmap, i2c->irq, +IRQF_ONESHOT ,-1 , &mt6370_irq_chip, + &info->irq_data); +if (ret) { +dev_err (&i2c->dev,"Failed to add irq chip (%d)\n" , ret); +return ret; + } + +return devm_mfd_add_devices (&i2c->dev,PLATFORM_DEVID_AUTO , + mt6370_devices,ARRAY_SIZE (mt6370_devices), +NULL ,0 , +regmap_irq_get_domain (info->irq_data)); +} + +static const struct of_device_id mt6370_match_table[] = { + { .compatible ="mediatek,mt6370" , }, + {} +}; +MODULE_DEVICE_TABLE (of, mt6370_match_table); + +static struct i2c_driver mt6370_driver = { + .driver = { + .name ="mt6370" , + .of_match_table = mt6370_match_table, + },
Quoted 8 lines
drivers/mfd/mt6370.c line 348
Quoted 6 lines
drivers/mfd/mt6370.c new file +6
-0+ .probe_new = mt6370_probe, +}; +module_i2c_driver (mt6370_driver); + +MODULE_AUTHOR ("ChiYuan Huang <[email protected]>" ); +MODULE_DESCRIPTION ("MT6370 I2C MFD Driver" );Drop all references to "MFD" please.
OK, we will drop them in the next patch. Thank you so much!
Quoted 8 lines
drivers/mfd/mt6370.c line 349
Quoted 2 lines
drivers/mfd/mt6370.c new file +1
-0+MODULE_LICENSE ("GPL v2" );--
Lee Jones [李琼斯]
Principal Technical Lead - Developer ServicesLinaro.org │ Open source software for Arm SoCs Follow Linaro: Facebook | Twitter | Blog
Best regards,
ChiaEn Wu
Rob Herring
maintainerRe: [PATCH v2 06/15] dt-bindings: mfd: Add Mediatek MT6370
In reply to ChiaEn WuQuoted 50 lines · ChiaEn Wu
Hi Rob,
Rob Herring <[email protected]> 於 2022年6月13日 週一 晚上9:33寫道:
Quoted 31 lines · ChiaEn Wu
Quoted 4 lines
From: ChiYuan Huang <[email protected]>
Add Mediatek MT6370 binding documentation.
Quoted 8 lines
Signed-off-by ChiYuan Huang <[email protected]>--- .../bindings/mfd/mediatek,mt6370.yaml | 279 ++++++++++++++++++ .../dt-bindings/iio/adc/mediatek,mt6370_adc.h | 18 ++ 2 files changed, 297 insertions(+) create mode 100644 Documentation/devicetree/bindings/mfd/mediatek,mt6370.yaml create mode 100644 include/dt-bindings/iio/adc/mediatek,mt6370_adc.hMy bot found errors running 'make DT_CHECKER_FLAGS=-m
dt_binding_check' on your patch (DT_CHECKER_FLAGSis new in v5.13):yamllint warnings/errors:
dtschema/dtc warnings/errors:
./Documentation/devicetree/bindings/mfd/mediatek,mt6370.yaml: Unable to find schema file matching $id: http://devicetree.org/schemas/leds/backlight/mediatek,mt6370-backlight.yaml
/builds/robherring/linux-dt-review/Documentation/devicetree/bindings/mfd/mediatek,mt6370.example.dtb: pmic@34: backlight: False schema does not allow {'compatible': ['mediatek,mt6370-backlight'], 'mediatek,bled-channel-use': b'\x0f'}
From schema: /builds/robherring/linux-dt-review/Documentation/devicetree/bindings/mfd/mediatek,mt6370.yaml
/builds/robherring/linux-dt-review/Documentation/devicetree/bindings/mfd/mediatek,mt6370.example.dtb: pmic@34: charger: False schema does not allow {'compatible': ['mediatek,mt6370-charger'], 'interrupts': [[48], [68], [6]], 'interrupt-names': ['attach_i', 'uvp_d_evt', 'mivr'], 'io-channels': [[1, 5]], 'usb-otg-vbus-regulator': {'regulator-name': ['mt6370-usb-otg-vbus'], 'regulator-min-microvolt': [[4350000]], 'regulator-max-microvolt': [[5800000]], 'regulator-min-microamp': [[500000]], 'regulator-max-microamp': [[3000000]], 'phandle': [[2]]}}
From schema: /builds/robherring/linux-dt-review/Documentation/devicetree/bindings/mfd/mediatek,mt6370.yaml
/builds/robherring/linux-dt-review/Documentation/devicetree/bindings/mfd/mediatek,mt6370.example.dtb: pmic@34: tcpc: False schema does not allow {'compatible': ['mediatek,mt6370-tcpc'], 'interrupts-extended': [[4294967295, 4, 8]], 'connector': {'compatible': ['usb-c-connector'], 'label': ['USB-C'], 'vbus-supply': [[2]], 'data-role': ['dual'], 'power-role': ['dual'], 'try-power-role': ['sink'], 'source-pdos': [[570527844]], 'sink-pdos': [[570527944]], 'op-sink-microwatt': [[10000000]], 'ports': {'#address-cells': [[1]], '#size-cells': [[0]], 'port@0': {'reg': [[0]], 'endpoint': {'remote-endpoint': [[4294967295]]}}, 'port@1': {'reg': [[1]], 'endpoint': {'remote-endpoint': [[4294967295]]}}, 'port@2': {'reg': [[2]], 'endpoint': {'remote-endpoint': [[4294967295]]}}}}}
From schema: /builds/robherring/linux-dt-review/Documentation/devicetree/bindings/mfd/mediatek,mt6370.yaml
/builds/robherring/linux-dt-review/Documentation/devicetree/bindings/mfd/mediatek,mt6370.example.dtb: pmic@34: indicator: False schema does not allow {'compatible': ['mediatek,mt6370-indicator'], '#address-cells': [[1]], '#size-cells': [[0]], 'multi-led@0': {'reg': [[0]], 'function': ['indicator'], 'color': [[9]], 'led-max-microamp': [[24000]], '#address-cells': [[1]], '#size-cells': [[0]], 'led@0': {'reg': [[0]], 'color': [[1]]}, 'led@1': {'reg': [[1]], 'color': [[2]]}, 'led@2': {'reg': [[2]], 'color': [[3]]}}, 'led@3': {'reg': [[3]], 'function': ['indicator'], 'color': [[0]], 'led-max-microamp': [[6000]]}}
From schema: /builds/robherring/linux-dt-review/Documentation/devicetree/bindings/mfd/mediatek,mt6370.yaml
/builds/robherring/linux-dt-review/Documentation/devicetree/bindings/mfd/mediatek,mt6370.example.dtb: pmic@34: flashlight: False schema does not allow {'compatible': ['mediatek,mt6370-flashlight'], '#address-cells': [[1]], '#size-cells': [[0]], 'led@0': {'reg': [[0]], 'led-sources': [[0]], 'function': ['flash'], 'color': [[0]], 'function-enumerator': [[1]], 'led-max-microamp': [[200000]], 'flash-max-microamp': [[500000]], 'flash-max-timeout-us': [[1248000]]}, 'led@1': {'reg': [[1]], 'led-sources': [[1]], 'function': ['flash'], 'color': [[0]], 'function-enumerator': [[2]], 'led-max-microamp': [[200000]], 'flash-max-microamp': [[500000]], 'flash-max-timeout-us': [[1248000]]}}Quoted 9 lines
From schema: /builds/robherring/linux-dt-review/Documentation/devicetree/bindings/mfd/mediatek,mt6370.yaml
/builds/robherring/linux-dt-review/Documentation/devicetree/bindings/mfd/mediatek,mt6370.example.dtb: backlight: mediatek,bled-channel-use: b'\x0f' is not of type 'object', 'array', 'boolean', 'null'
From schema:/usr/local/lib/python3.10/dist-packages/dtschema/schemas/dt-core.yamlDocumentation/devicetree/bindings/mfd/mediatek,mt6370.example.dtb:0:0: /example-0/i2c/pmic@34/backlight: failed to match any schema with compatible: ['mediatek,mt6370-backlight']Documentation/devicetree/bindings/mfd/mediatek,mt6370.example.dtb:0:0: /example-0/i2c/pmic@34/charger: failed to match any schema with compatible: ['mediatek,mt6370-charger']Documentation/devicetree/bindings/mfd/mediatek,mt6370.example.dtb:0:0: /example-0/i2c/pmic@34/indicator: failed to match any schema with compatible: ['mediatek,mt6370-indicator']Documentation/devicetree/bindings/mfd/mediatek,mt6370.example.dtb:0:0: /example-0/i2c/pmic@34/flashlight: failed to match any schema with compatible: ['mediatek,mt6370-flashlight']Documentation/devicetree/bindings/mfd/mediatek,mt6370.example.dtb:0:0: /example-0/i2c/pmic@34/tcpc: failed to match any schema with compatible: ['mediatek,mt6370-tcpc']Before we submitted these patches, we had already checked by running this command below,
"make DT_CHECKER_FLAGS=-mdt_binding_checkDT_SCHEMA_FILES=Documentation/devicetree/bindings/mfd/mediatek,mt6370.yaml". But we could not find any errors like your error msg after the checking process.
Quoted 4 lines
Our mfd dt-binding patch is dependent on "backlight dt-binding", "charger dt-binding", "tcpc dt-binding", "indicator dt-binding" and "flashlight dt-binding" patches.
Would you please apply them before you check mfd dt-binding patch?
That is what is done. Not sure what happened here though.
Rob
Re: [PATCH v2 02/15] dt-bindings: power: supply: Add Mediatek MT6370 Charger
In reply to ChiaEn WuQuoted 79 lines · ChiaEn Wu
Hi Krzysztof,
Thanks for your helpful comments! I have so some questions want to ask you below.
Krzysztof Kozlowski <[email protected]> 於 2022年6月17日 週五 清晨5:05寫道:
Quoted 52 lines · ChiaEn Wu
Quoted 50 lines
From: ChiaEn Wu <[email protected]>
Add Mediatek MT6370 Charger binding documentation.
Signed-off-by ChiaEn Wu <[email protected]>--- .../power/supply/mediatek,mt6370-charger.yaml | 60 +++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 Documentation/devicetree/bindings/power/supply/mediatek,mt6370-charger.yamlDocumentation/devicetree/bindings/power/supply/mediatek,mt6370-charger.yaml new file +34
-0@@ -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 + - description: usb plug in irq + - description: mivr irq + + interrupt-names: + items: + - const: attach_i + - const: uvp_d_evt + - const: mivrQuoted 9 lines
Documentation/devicetree/bindings/power/supply/mediatek,mt6370-charger.yaml line 39
Quoted 5 lines
Documentation/devicetree/bindings/power/supply/mediatek,mt6370-charger.yaml new file +5
-0+ + io-channels: + description: | + Use ADC channel to read vbus, ibus, ibat, etc., info. Ibus ADC channel + is required.Add io-channel-names and describe each item - what type of ADC it is expected to be.
I'm afraid I might not be understanding what you mean.
I will try to add some text in "description" and "io-channel-names", like below
----------------------------------
io-channels:
description: |
Use ADC channel to read VBUS, IBUS, IBAT, etc., info. Ibus ADC channel is required. It can be seen ininclude/dt-bindings/iio/adc/mediatek,mt6370_adc.h
minItems: 1
maxItems: 9
Quoted 4 lines
io-channel-names:
items:
- const: vbusdiv5
- const: vbusdiv2
Almost. The best would be something like this:Documentation/devicetree/bindings/power/supply/cpcap-charger.yaml so also "items" with description under "io-channels". You need to skip maxItems in such case (keep minItems).
Quoted 21 lines
- ...
----------------------------------
Did these modifications meet your expectations?Quoted 9 lines
Documentation/devicetree/bindings/power/supply/mediatek,mt6370-charger.yaml line 46
Quoted 7 lines
Documentation/devicetree/bindings/power/supply/mediatek,mt6370-charger.yaml new file +7
-0+ minItems: 1 + maxItems: 9 + + usb-otg-vbus-regulator: + type: object + description: OTG boost regulator. + $ref: /schemas/regulator/regulator.yaml#unevaluatedProperties: false
I will add this in the next patch.
Quoted 5 lines
Quoted 4 lines
Documentation/devicetree/bindings/power/supply/mediatek,mt6370-charger.yaml new file +3
-0+ + properties: + enable-gpio:
Quoted 5 lines
Quoted 2 lines
"gpios", so:
enable-gpiosIf this otg regulator only uses one GPIO Pin, do I still need to change to "gpios"?
Yes, because "gpios" is the preferred suffix. This is requirement for all such properties. enable-gpios are also documented here:Documentation/devicetree/bindings/gpio/gpio-consumer-common.yaml
Quoted 2 lines
If so, I will refine it along with the regulator "enable-gpio" in MFD dt-binding.
Yes, there it should be "enable-gpios" as well.
Best regards,
Krzysztof
Re: [PATCH v2 05/15] dt-bindings: backlight: Add Mediatek MT6370 backlight
In reply to ChiaEn WuQuoted 8 lines · ChiaEn Wu
+ - 3: 6
Quoted 6 lines
Nope, I said last time:
"In any case you cannot have values mapping"Please use proper real world value, not some register bits. The property name also needs fixing.
Quoted 15 lines
I so apologized for misunderstanding your meaning...
I try to modify it like below.
--------
mediatek,bled-pwm-hys-input-threshold-steps:
$ref: /schemas/types.yaml#/definitions/uint8
enum: [1, 4, 16, 64]
description: |
The selection of the upper and lower bounds threshold of backlight PWM resolution. If we choose selection 64, the variation of PWM resolution needs over 64 steps.
--------
If these changes meet your expectations, I will try to modify "bled-ovp-microvolt" and "bled-ocp-microamp" in the same way. Thank you so much.
This looks good. Thank you.
Best regards,
Krzysztof
Jonathan Cameron
maintainerRe: [PATCH v2 07/15] Documentation: ABI: testing: mt6370: Add ADC sysfs guideline
In reply to ChiaEn WuQuoted 16 lines · On Mon, 13 Jun 2022 19:11:38 +0800 ChiaEn Wu <[email protected]> wrote:
From: ChiaEn Wu <[email protected]>
Add ABI documentation for mt6370 non-standard ADC sysfs interfaces.
Signed-off-by ChiaEn Wu <[email protected]>--- .../ABI/testing/sysfs-bus-iio-adc-mt6370 | 36 +++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 Documentation/ABI/testing/sysfs-bus-iio-adc-mt6370Documentation/ABI/testing/sysfs-bus-iio-adc-mt6370 new file +0
-0
Documentation/ABI/testing/sysfs-bus-iio-adc-mt6370 line 1
Quoted 1 line
Documentation/ABI/testing/sysfs-bus-iio-adc-mt6370 new file +1
-0@@ -0,0 +1,36 @@ +What: /sys/bus/iio/devices/iio:deviceX/in_voltage0_raw
Unfortunately the kernel documentation build scripts do no support duplicating standard ABI for particular devices so as to provide more information. Hence you can't have anything in this file.
Documentation/ABI/testing/sysfs-bus-iio-adc-mt6370 line 5
Quoted 4 lines
Documentation/ABI/testing/sysfs-bus-iio-adc-mt6370 new file +4
-0+KernelVersion: 5.18 +Contact: [email protected] +Description: + Indicated MT6370 VBUS ADC with lower accuracy(+-75mA)
Curious though, voltage with a mA accuracy range?
This scale should be presented directly to userspace anyway so no need for this doc.
Documentation/ABI/testing/sysfs-bus-iio-adc-mt6370 line 7
Quoted 2 lines
Documentation/ABI/testing/sysfs-bus-iio-adc-mt6370 new file +2
-0+ higher measure range(1~22V) + Calculating with scale returns voltage in uV
No. All channels return in mV. That's the ABI requirement as in sysfs-bus-iio and we cannot vary if for particular drivers. If we did no generic tooling would work.
Quoted 29 lines
Documentation/ABI/testing/sysfs-bus-iio-adc-mt6370 new file +29
-0+ +What: /sys/bus/iio/devices/iio:deviceX/in_voltage1_raw +KernelVersion: 5.18 +Contact: [email protected] +Description: + Indicated MT6370 VBUS ADC with higher accuracy(+-30mA) + lower measure range(1~9.76V) + Calculating with scale offset returns voltage in uV + +What: /sys/bus/iio/devices/iio:deviceX/in_voltage4_raw +KernelVersion: 5.18 +Contact: [email protected] +Description: + Indicated MT6370 TS_BAT ADC + Calculating with scale returns voltage in uV + +What: /sys/bus/iio/devices/iio:deviceX/in_voltage7_raw +KernelVersion: 5.18 +Contact: [email protected] +Description: + Indicated MT6370 CHG_VDDP ADC + Calculating with scale returns voltage in mV + +What: /sys/bus/iio/devices/iio:deviceX/in_temp8_raw +KernelVersion: 5.18 +Contact: [email protected] +Description: + Indicated MT6370 IC junction temperature + Calculating with scale and offset returns temperature in degree
Jonathan Cameron
maintainerRe: [PATCH v2 08/15] mfd: mt6370: Add Mediatek MT6370 support
In reply to ChiaEn WuQuoted 5 lines · On Mon, 13 Jun 2022 19:11:39 +0800 ChiaEn Wu <[email protected]> wrote:
From: ChiYuan Huang <[email protected]>
Add Mediatek MT6370 MFD support.
Signed-off-by ChiYuan Huang <[email protected]>
Hi.
A few trivial things that probably overlap with other reviewer comments.
Quoted 9 lines
drivers/mfd/mt6370.c new file +9
-0+static int mt6370_check_vendor_info (struct mt6370_info *info) +{ +unsigned int devinfo; +int ret; + + ret =regmap_read (info->regmap,MT6370_REG_DEV_INFO , &devinfo); +if (ret) +return ret; +
drivers/mfd/mt6370.c line 236
Quoted 10 lines
drivers/mfd/mt6370.c new file +10
-0+switch (FIELD_GET (MT6370_VENID_MASK , devinfo)) { +case 0x8 :/* RT5081 */ +case 0xA :/* RT5081A */ +case 0xE :/* MT6370 */ +case 0xF :/* MT6371 */ +case 0x9 :/* MT6372P */ +case 0xB :/* MT6372CP */ +break ; +default : +dev_err (info->dev,"Not invalid value 0x%02x\n" , devinfo);
Double negative... You mean "Invalid value"
though you probably want to say something more specific such as
"Unknown Vendor ID 0x%02x\n")
Quoted 7 lines
drivers/mfd/mt6370.c new file +7
-0+return -ENODEV ; + } + +return 0 ; +} + +static int mt6370_regmap_read(void *context, const void *reg_buf,
drivers/mfd/mt6370.c line 253
Quoted 10 lines
drivers/mfd/mt6370.c new file +10
-0+ size_t reg_size, void *val_buf, size_t val_size) +{ + struct mt6370_info *info = context; +u8 bank_idx = *(u8 *)reg_buf, bank_addr = *(u8 *)(reg_buf +1 ); +int ret; + + ret =i2c_smbus_read_i2c_block_data (info->i2c[bank_idx], bank_addr, + val_size, val_buf); +if (ret != val_size) +return ret;
If it's positive , that is probably not what regmap expects. See handling in here
https://elixir.bootlin.com/linux/latest/source/drivers/base/regmap/regmap-i2c.c#L222
Quoted 13 lines
drivers/mfd/mt6370.c new file +11
-0+ +return 0 ; +} + +static int mt6370_probe (struct i2c_client *i2c) +{ +struct mt6370_info *info; +struct i2c_client *usbc_i2c; +int ret; + + info =devm_kzalloc (&i2c->dev,sizeof (*info),GFP_KERNEL );
drivers/mfd/mt6370.c line 296
Quoted 10 lines
drivers/mfd/mt6370.c new file +10
-0+if (!info) +return -ENOMEM ; + + info->dev = &i2c->dev; + + usbc_i2c =devm_i2c_new_dummy_device (&i2c->dev, i2c->adapter, +MT6370_USBC_I2CADDR ); +if (IS_ERR (usbc_i2c)) { + ret =PTR_ERR (usbc_i2c); +dev_err (&i2c->dev,"Failed to register usbc i2c client %d\n" , ret);
Might as well use
return dev_err_probe(&i2c->dev, PTR_ERR(usb_i2c), "Failed to register USBC I2C client\n");
Whilst the defer handling isn't relevant, it is safe to use throughout probe and tidier in this case at least.
drivers/mfd/mt6370.c line 308
Quoted 12 lines
drivers/mfd/mt6370.c new file +12
-0+return ret; + } + +/* Assign I2C client for PMU and TypeC */ + info->i2c[MT6370_PMU_I2C ] = i2c; + info->i2c[MT6370_USBC_I2C ] = usbc_i2c; + + info->regmap =devm_regmap_init (&i2c->dev, &mt6370_regmap_bus, info, + &mt6370_regmap_config); +if (IS_ERR (info->regmap)) { + ret =PTR_ERR (info->regmap); +dev_err (&i2c->dev,"Failed to register regmap (%d)\n" , ret);
as above dev_err_probe() will tidy this and following cases up for you.
Quoted 22 lines
drivers/mfd/mt6370.c new file +22
-0+return ret; + } + + ret =mt6370_check_vendor_info (info); +if (ret) { +dev_err (&i2c->dev,"Failed to check vendor info (%d)\n" , ret); +return ret; + } + + ret =devm_regmap_add_irq_chip (&i2c->dev, info->regmap, i2c->irq, +IRQF_ONESHOT ,-1 , &mt6370_irq_chip, + &info->irq_data); +if (ret) { +dev_err (&i2c->dev,"Failed to add irq chip (%d)\n" , ret); +return ret; + } + +return devm_mfd_add_devices (&i2c->dev,PLATFORM_DEVID_AUTO , + mt6370_devices,ARRAY_SIZE (mt6370_devices), +NULL ,0 , +regmap_irq_get_domain (info->irq_data)); +}
Jonathan Cameron
maintainerRe: [PATCH v2 11/15] iio: adc: mt6370: Add Mediatek MT6370 support
In reply to ChiaEn WuQuoted 5 lines · On Mon, 13 Jun 2022 19:11:42 +0800 ChiaEn Wu <[email protected]> wrote:
From: ChiaEn Wu <[email protected]>
Add Mediatek MT6370 ADC support.
Signed-off-by ChiaEn Wu <[email protected]>
Hi ChiaEn Wu,
A few comments inline, but mostly looks good to me with the exception of the scales which look far too large.
Thanks,
Jonathan
Quoted 45 lines
--- drivers/iio/adc/Kconfig | 9 ++ drivers/iio/adc/Makefile | 1 + drivers/iio/adc/mt6370-adc.c | 262 +++++++++++++++++++++++++++++++++++ 3 files changed, 272 insertions(+) create mode 100644 drivers/iio/adc/mt6370-adc.cdrivers/iio/adc/Kconfig +9
-0@@ -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_TESTdrivers/iio/adc/Makefile +1
-0@@ -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.odrivers/iio/adc/mt6370-adc.c new file +0
-0
drivers/iio/adc/mt6370-adc.c line 8
Quoted 8 lines
drivers/iio/adc/mt6370-adc.c new file +8
-0@@ -0,0 +1,262 @@ +// SPDX-License-Identifier: GPL-2.0 + +#include <dt-bindings/iio/adc/mediatek,mt6370_adc.h> +#include <linux/bits.h> +#include <linux/bitfield.h> +#include <linux/iio/iio.h> +#include <linux/kernel.h> +#include <linux/module.h>
#include <linux/mod_devicetable.h>
rather than relying on indirect include for
struct of_device_id
We've just removed such an include path from IIO and had to fix up a lot of drivers that falsely assumed that would available.
Quoted 14 lines
drivers/iio/adc/mt6370-adc.c new file +14
-0+#include <linux/mutex.h> +#include <linux/platform_device.h> +#include <linux/regmap.h> + +#define MT6370_REG_CHG_CTRL3 0x113/* AICR */ +#define MT6370_REG_CHG_CTRL7 0x117/* ICHG */ +#define MT6370_REG_CHG_ADC 0x121 +#define MT6370_REG_ADC_DATA_H 0x14C + +#define MT6370_ADC_START_MASK BIT(0) +#define MT6370_ADC_IN_SEL_MASK GENMASK(7, 4) +#define MT6370_AICR_ICHG_MASK GENMASK(7, 2) + +#define MT6370_AICR_400MA 0x6
drivers/iio/adc/mt6370-adc.c line 32
Quoted 10 lines
drivers/iio/adc/mt6370-adc.c new file +10
-0+#define MT6370_ICHG_500MA 0x4 +#define MT6370_ICHG_900MA 0x8 + +#define ADC_CONV_TIME_US 35000 +#define ADC_CONV_POLLING_TIME 1000 + +struct mt6370_adc_data { +struct device *dev; +struct regmap *regmap; +struct mutex adc_lock;
Please document scope of the lock. I think it's to synchronize access to the device state concerned with channel reads, but there should be a comment here to say something about that.
Quoted 17 lines
drivers/iio/adc/mt6370-adc.c new file +17
-0+}; + +static int mt6370_adc_read_channel (struct mt6370_adc_data *priv,int chan, +unsigned long addr,int *val) +{ +__be16 be_val; +unsigned int reg_val; +int ret; + +mutex_lock (&priv->adc_lock); + + reg_val =MT6370_ADC_START_MASK | +FIELD_PREP (MT6370_ADC_IN_SEL_MASK , addr); + ret =regmap_write (priv->regmap,MT6370_REG_CHG_ADC , reg_val); +if (ret) + goto adc_unlock; +
drivers/iio/adc/mt6370-adc.c line 59
Quoted 10 lines
drivers/iio/adc/mt6370-adc.c new file +10
-0+msleep (ADC_CONV_TIME_US /1000 ); + + ret =regmap_read_poll_timeout (priv->regmap, +MT6370_REG_CHG_ADC , reg_val, + !(reg_val &MT6370_ADC_START_MASK ), +ADC_CONV_POLLING_TIME , +ADC_CONV_TIME_US *3 ); +if (ret) { +if (ret == -ETIMEDOUT ) +dev_err (priv->dev,"Failed to wait adc conversion\n" );
Why are any other error here not worth reporting? I'd print a message for all return values.
Quoted 27 lines
drivers/iio/adc/mt6370-adc.c new file +27
-0+ goto adc_unlock; + } + + ret =regmap_raw_read (priv->regmap,MT6370_REG_ADC_DATA_H , + &be_val,sizeof (be_val)); +if (ret) + goto adc_unlock; + + *val =be16_to_cpu (be_val); + ret =IIO_VAL_INT ; + +adc_unlock: +mutex_unlock (&priv->adc_lock); + +return ret; +} + +static int mt6370_adc_read_scale (struct mt6370_adc_data *priv, +int chan,int *val1,int *val2) +{ +unsigned int reg_val; +int ret; + +switch (chan) { +case MT6370_CHAN_VBAT : +case MT6370_CHAN_VSYS : +case MT6370_CHAN_CHG_VDDP :
drivers/iio/adc/mt6370-adc.c line 96
Quoted 10 lines
drivers/iio/adc/mt6370-adc.c new file +10
-0+ *val1 =5 ; +return IIO_VAL_INT ; +case MT6370_CHAN_IBUS : + ret =regmap_read (priv->regmap,MT6370_REG_CHG_CTRL3 , ®_val); +if (ret) +return ret; + + reg_val =FIELD_GET (MT6370_AICR_ICHG_MASK , reg_val); +if (reg_val <MT6370_AICR_400MA ) + *val1 =33500 ;
As (scale * raw) must give a value in milliamps, this seems very large as each ADC reading currently represents 33Amps. That would make an impressive PMIC!)
Same for the various entries below. Note that scale is often
not an integer value (or even as large as 1) Hence the many different precisions of data type that IIO provides and the useful types like IIO_VAL_FRACTIONAL;
Quoted 25 lines
drivers/iio/adc/mt6370-adc.c new file +25
-0+else + *val1 =50000 ; + +return IIO_VAL_INT ; +case MT6370_CHAN_IBAT : + ret =regmap_read (priv->regmap,MT6370_REG_CHG_CTRL7 , ®_val); +if (ret) +return ret; + + reg_val =FIELD_GET (MT6370_AICR_ICHG_MASK , reg_val); +if (reg_val <MT6370_ICHG_500MA ) + *val1 =23750 ; +else if (reg_val >=MT6370_ICHG_500MA && + reg_val <MT6370_ICHG_900MA ) + *val1 =26800 ; +else + *val1 =50000 ; + +return IIO_VAL_INT ; +case MT6370_CHAN_VBUSDIV5 : + *val1 =25000 ; +return IIO_VAL_INT ; +case MT6370_CHAN_VBUSDIV2 : + *val1 =50000 ; +return IIO_VAL_INT ;
drivers/iio/adc/mt6370-adc.c line 131
Quoted 10 lines
drivers/iio/adc/mt6370-adc.c new file +10
-0+case MT6370_CHAN_TS_BAT : + *val1 =25 ; + *val2 =10000 ; +return IIO_VAL_FRACTIONAL ; +case MT6370_CHAN_TEMP_JC : + *val1 =2 ; +return IIO_VAL_INT ; + } + +return -EINVAL ;
As below, I'd prefer this as a default: in the switch statement.
Quoted 2 lines
drivers/iio/adc/mt6370-adc.c new file +2
-0+} +
...
Quoted 8 lines
drivers/iio/adc/mt6370-adc.c new file +8
-0+ +static int mt6370_adc_read_raw (struct iio_dev *iio_dev, +const struct iio_chan_spec *chan, +int *val,int *val2,long mask) +{ +struct mt6370_adc_data *priv =iio_priv (iio_dev); + +switch (mask) {
drivers/iio/adc/mt6370-adc.c line 158
Quoted 10 lines
drivers/iio/adc/mt6370-adc.c new file +10
-0+case IIO_CHAN_INFO_RAW : +return mt6370_adc_read_channel (priv, chan->channel, + chan->address, val); +case IIO_CHAN_INFO_SCALE : +return mt6370_adc_read_scale (priv, chan->channel, val, val2); +case IIO_CHAN_INFO_OFFSET : +return mt6370_adc_read_offset (priv, chan->channel, val); + } + +return -EINVAL ;
Add a default to the switch statement and return -EINVAL in there. That makes it explicit that you are handling all the cases you care about.
Sure, right now it's obvious that is the case, but it might not be so obvious if more code happens to get added here in future.
Quoted 3 lines
drivers/iio/adc/mt6370-adc.c new file +2
-0+} +
Re: [PATCH v2 03/15] dt-bindings: leds: mt6370: Add Mediatek mt6370 current sink type LED indicator
In reply to Krzysztof KozlowskiDear Krzysztof,
Thank you for the valuable command.
Krzysztof Kozlowski <[email protected]> 於 2022年6月17日 週五 清晨5:09寫道:
Quoted 49 lines · ChiaEn Wu
Quoted 33 lines
From: ChiYuan Huang <[email protected]>
Add Mediatek mt6370 current sink type LED indicator binding documentation.
Signed-off-by ChiYuan Huang <[email protected]>--- .../leds/mediatek,mt6370-indicator.yaml | 48 +++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 Documentation/devicetree/bindings/leds/mediatek,mt6370-indicator.yamlDocumentation/devicetree/bindings/leds/mediatek,mt6370-indicator.yaml new file +17
-0@@ -0,0 +1,48 @@ +# 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. + Add MT6370 LED driver include 4-channel RGB LED support Register/PWM/Breath Mode + +properties: + compatible:Documentation/devicetree/bindings/leds/mediatek,mt6370-indicator.yaml line 27
Quoted 10 lines
Documentation/devicetree/bindings/leds/mediatek,mt6370-indicator.yaml new file +10
-0+ const: mediatek,mt6370-indicator + + "#address-cells": + const: 1 + + "#size-cells": + const: 0 + +patternProperties: + "^(multi-)?led@[0-3]$":If this is multi-led, then you should reference
/schemas/leds/leds-pwm-multicolor.yaml
Quoted 1 line
See other examples using it.
In my opinion, leds-pwm-multicolor.yaml is used for external pwm signals, and needs to assign an external pwm property.
But our pwm leds use an internal clock to generate the pwm signal. Is leds-class-multicolor.yaml more appropriate?
Sincerely,
Alice
Quoted 5 lines
Best regards,
Krzysztof
Re: [PATCH v2 07/15] Documentation: ABI: testing: mt6370: Add ADC sysfs guideline
In reply to Jonathan CameronHi Jonathan,
Thanks for your helpful comments, and I have some questions want to ask you below.
Jonathan Cameron <[email protected]> 於 2022年6月18日 週六 晚上11:39寫道:
Quoted 14 lines
Quoted 10 lines · On Mon, 13 Jun 2022 19:11:38 +0800 ChiaEn Wu <[email protected]> wrote:
From: ChiaEn Wu <[email protected]>
Add ABI documentation for mt6370 non-standard ADC sysfs interfaces.
Signed-off-by ChiaEn Wu <[email protected]>--- .../ABI/testing/sysfs-bus-iio-adc-mt6370 | 36 +++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 Documentation/ABI/testing/sysfs-bus-iio-adc-mt6370
Quoted 12 lines
Documentation/ABI/testing/sysfs-bus-iio-adc-mt6370 line 1
Quoted 7 lines
Documentation/ABI/testing/sysfs-bus-iio-adc-mt6370 new file +1
-0@@ -0,0 +1,36 @@ +What: /sys/bus/iio/devices/iio:deviceX/in_voltage0_rawUnfortunately the kernel documentation build scripts do no support duplicating standard ABI for particular devices so as to provide more information. Hence you can't have anything in this file.
I want to confirm with you again,
because my ABI file duplicates with standard sysfs-bus-iio (voltage, current, and temperature channels),
Should I just remove this ABI file and modify the code of mt6370-adc to meet your expectations??
Quoted 6 lines
Documentation/ABI/testing/sysfs-bus-iio-adc-mt6370 line 5
Quoted 5 lines
Documentation/ABI/testing/sysfs-bus-iio-adc-mt6370 new file +4
-0+KernelVersion: 5.18 +Contact: [email protected] +Description: + Indicated MT6370 VBUS ADC with lower accuracy(+-75mA)Curious though, voltage with a mA accuracy range?
Yes, this description is based on the data sheet.
Quoted 9 lines
This scale should be presented directly to userspace anyway so no need for this doc.
Documentation/ABI/testing/sysfs-bus-iio-adc-mt6370 line 7
Quoted 2 lines
Documentation/ABI/testing/sysfs-bus-iio-adc-mt6370 new file +2
-0+ higher measure range(1~22V) + Calculating with scale returns voltage in uVNo. All channels return in mV. That's the ABI requirement as in sysfs-bus-iio and we cannot vary if for particular drivers. If we did no generic tooling would work.
Ok, I got it!
Quoted 22 lines
Quoted 22 lines
Documentation/ABI/testing/sysfs-bus-iio-adc-mt6370 new file +21
-0+ +What: /sys/bus/iio/devices/iio:deviceX/in_voltage1_raw +KernelVersion: 5.18 +Contact: [email protected] +Description: + Indicated MT6370 VBUS ADC with higher accuracy(+-30mA) + lower measure range(1~9.76V) + Calculating with scale offset returns voltage in uV + +What: /sys/bus/iio/devices/iio:deviceX/in_voltage4_raw +KernelVersion: 5.18 +Contact: [email protected] +Description: + Indicated MT6370 TS_BAT ADC + Calculating with scale returns voltage in uV + +What: /sys/bus/iio/devices/iio:deviceX/in_voltage7_raw +KernelVersion: 5.18 +Contact: [email protected] +Description: + Indicated MT6370 CHG_VDDP ADC
Quoted 8 lines
Documentation/ABI/testing/sysfs-bus-iio-adc-mt6370 line 36
Quoted 8 lines
Documentation/ABI/testing/sysfs-bus-iio-adc-mt6370 new file +8
-0+ Calculating with scale returns voltage in mV + +What: /sys/bus/iio/devices/iio:deviceX/in_temp8_raw +KernelVersion: 5.18 +Contact: [email protected] +Description: + Indicated MT6370 IC junction temperature + Calculating with scale and offset returns temperature in degree
Shall I modify the scale of temperature to milli degrees in mt6370-adc.c and remove this item??
Quoted 1 line
Best regards,
ChiaEn Wu
Jonathan Cameron
maintainerRe: [PATCH v2 07/15] Documentation: ABI: testing: mt6370: Add ADC sysfs guideline
Quoted 33 lines · On Mon, 20 Jun 2022 14:00:43 +0800 ChiaEn Wu <[email protected]> wrote:
Hi Jonathan,
Thanks for your helpful comments, and I have some questions want to ask you below.
Jonathan Cameron <[email protected]> 於 2022年6月18日 週六 晚上11:39寫道:
Quoted 14 lines
Quoted 10 lines · On Mon, 13 Jun 2022 19:11:38 +0800 ChiaEn Wu <[email protected]> wrote:
From: ChiaEn Wu <[email protected]>
Add ABI documentation for mt6370 non-standard ADC sysfs interfaces.
Signed-off-by ChiaEn Wu <[email protected]>--- .../ABI/testing/sysfs-bus-iio-adc-mt6370 | 36 +++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 Documentation/ABI/testing/sysfs-bus-iio-adc-mt6370Quoted 12 lines
Documentation/ABI/testing/sysfs-bus-iio-adc-mt6370 line 1
Quoted 7 lines
Documentation/ABI/testing/sysfs-bus-iio-adc-mt6370 new file +1
-0@@ -0,0 +1,36 @@ +What: /sys/bus/iio/devices/iio:deviceX/in_voltage0_rawUnfortunately the kernel documentation build scripts do no support duplicating standard ABI for particular devices so as to provide more information. Hence you can't have anything in this file.
Quoted 5 lines
I want to confirm with you again,
because my ABI file duplicates with standard sysfs-bus-iio (voltage, current, and temperature channels),
Should I just remove this ABI file and modify the code of mt6370-adc to meet your expectations??
yes.
Quoted 9 lines
Quoted 7 lines
Documentation/ABI/testing/sysfs-bus-iio-adc-mt6370 line 5
Quoted 6 lines
Documentation/ABI/testing/sysfs-bus-iio-adc-mt6370 new file +4
-0+KernelVersion: 5.18 +Contact: [email protected] +Description: + Indicated MT6370 VBUS ADC with lower accuracy(+-75mA)Curious though, voltage with a mA accuracy range?
Yes, this description is based on the data sheet.
Weird :)
Quoted 38 lines
Quoted 10 lines
This scale should be presented directly to userspace anyway so no need for this doc.
Documentation/ABI/testing/sysfs-bus-iio-adc-mt6370 line 7
Quoted 2 lines
Documentation/ABI/testing/sysfs-bus-iio-adc-mt6370 new file +2
-0+ higher measure range(1~22V) + Calculating with scale returns voltage in uVNo. All channels return in mV. That's the ABI requirement as in sysfs-bus-iio and we cannot vary if for particular drivers. If we did no generic tooling would work.
Ok, I got it!
Quoted 25 lines
Quoted 25 lines
Documentation/ABI/testing/sysfs-bus-iio-adc-mt6370 new file +24
-0+ +What: /sys/bus/iio/devices/iio:deviceX/in_voltage1_raw +KernelVersion: 5.18 +Contact: [email protected] +Description: + Indicated MT6370 VBUS ADC with higher accuracy(+-30mA) + lower measure range(1~9.76V) + Calculating with scale offset returns voltage in uV + +What: /sys/bus/iio/devices/iio:deviceX/in_voltage4_raw +KernelVersion: 5.18 +Contact: [email protected] +Description: + Indicated MT6370 TS_BAT ADC + Calculating with scale returns voltage in uV + +What: /sys/bus/iio/devices/iio:deviceX/in_voltage7_raw +KernelVersion: 5.18 +Contact: [email protected] +Description: + Indicated MT6370 CHG_VDDP ADC + Calculating with scale returns voltage in mV + +What: /sys/bus/iio/devices/iio:deviceX/in_temp8_raw
Quoted 8 lines
Quoted 5 lines
Documentation/ABI/testing/sysfs-bus-iio-adc-mt6370 line 36
Quoted 5 lines
Documentation/ABI/testing/sysfs-bus-iio-adc-mt6370 new file +5
-0+KernelVersion: 5.18 +Contact: [email protected] +Description: + Indicated MT6370 IC junction temperature + Calculating with scale and offset returns temperature in degreeShall I modify the scale of temperature to milli degrees in
mt6370-adc.cand remove this item??
yes.
Thanks,
Jonathan
Quoted 5 lines
Quoted 2 lines
Best regards,
ChiaEn Wu
Re: [PATCH v2 07/15] Documentation: ABI: testing: mt6370: Add ADC sysfs guideline
Hi Jonathan,
Thanks for your reply!
Jonathan Cameron <[email protected]> 於 2022年6月21日 週二 凌晨2:35寫道:
Quoted 37 lines
Quoted 33 lines · On Mon, 20 Jun 2022 14:00:43 +0800 ChiaEn Wu <[email protected]> wrote:
Hi Jonathan,
Thanks for your helpful comments, and I have some questions want to ask you below.
Jonathan Cameron <[email protected]> 於 2022年6月18日 週六 晚上11:39寫道:
Quoted 26 lines
Quoted 16 lines · On Mon, 13 Jun 2022 19:11:38 +0800 ChiaEn Wu <[email protected]> wrote:
From: ChiaEn Wu <[email protected]>
Add ABI documentation for mt6370 non-standard ADC sysfs interfaces.
Signed-off-by ChiaEn Wu <[email protected]>--- .../ABI/testing/sysfs-bus-iio-adc-mt6370 | 36 +++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 Documentation/ABI/testing/sysfs-bus-iio-adc-mt6370Documentation/ABI/testing/sysfs-bus-iio-adc-mt6370 new file +0
-0Documentation/ABI/testing/sysfs-bus-iio-adc-mt6370 line 1
Quoted 1 line
Documentation/ABI/testing/sysfs-bus-iio-adc-mt6370 new file +1
-0@@ -0,0 +1,36 @@ +What: /sys/bus/iio/devices/iio:deviceX/in_voltage0_rawUnfortunately the kernel documentation build scripts do no support duplicating standard ABI for particular devices so as to provide more information. Hence you can't have anything in this file.
Quoted 7 lines
Quoted 5 lines
I want to confirm with you again,
because my ABI file duplicates with standard sysfs-bus-iio (voltage, current, and temperature channels),
Should I just remove this ABI file and modify the code of mt6370-adc to meet your expectations??yes.
OK! I got it! I will refine the code in the next patch!
Quoted 9 lines
Quoted 9 lines
Quoted 8 lines
Documentation/ABI/testing/sysfs-bus-iio-adc-mt6370 line 5
Quoted 7 lines
Documentation/ABI/testing/sysfs-bus-iio-adc-mt6370 new file +4
-0+KernelVersion: 5.18 +Contact: [email protected] +Description: + Indicated MT6370 VBUS ADC with lower accuracy(+-75mA)Curious though, voltage with a mA accuracy range?
Quoted 3 lines
Quoted 1 line
Yes, this description is based on the data sheet.
Weird :)
First, I want to apologize to you because I rechecked the datasheet and asked the hardware engineer,
the conclusion is I wrote the wrong unit...
The correction is that the accuracy of vbusdiv5 is +-75"mV", not "mA", and another one, vbusdiv2, is +-30mV.
I sincerely apologize for this mistake and for any inconvenience...
Quoted 48 lines
Quoted 39 lines
Quoted 11 lines
This scale should be presented directly to userspace anyway so no need for this doc.
Documentation/ABI/testing/sysfs-bus-iio-adc-mt6370 line 7
Quoted 2 lines
Documentation/ABI/testing/sysfs-bus-iio-adc-mt6370 new file +2
-0+ higher measure range(1~22V) + Calculating with scale returns voltage in uVNo. All channels return in mV. That's the ABI requirement as in sysfs-bus-iio and we cannot vary if for particular drivers. If we did no generic tooling would work.
Ok, I got it!
Quoted 25 lines
Quoted 25 lines
Documentation/ABI/testing/sysfs-bus-iio-adc-mt6370 new file +24
-0+ +What: /sys/bus/iio/devices/iio:deviceX/in_voltage1_raw +KernelVersion: 5.18 +Contact: [email protected] +Description: + Indicated MT6370 VBUS ADC with higher accuracy(+-30mA) + lower measure range(1~9.76V) + Calculating with scale offset returns voltage in uV + +What: /sys/bus/iio/devices/iio:deviceX/in_voltage4_raw +KernelVersion: 5.18 +Contact: [email protected] +Description: + Indicated MT6370 TS_BAT ADC + Calculating with scale returns voltage in uV + +What: /sys/bus/iio/devices/iio:deviceX/in_voltage7_raw +KernelVersion: 5.18 +Contact: [email protected] +Description: + Indicated MT6370 CHG_VDDP ADC + Calculating with scale returns voltage in mV + +What: /sys/bus/iio/devices/iio:deviceX/in_temp8_rawQuoted 8 lines
Quoted 5 lines
Documentation/ABI/testing/sysfs-bus-iio-adc-mt6370 line 36
Quoted 5 lines
Documentation/ABI/testing/sysfs-bus-iio-adc-mt6370 new file +5
-0+KernelVersion: 5.18 +Contact: [email protected] +Description: + Indicated MT6370 IC junction temperature + Calculating with scale and offset returns temperature in degreeShall I modify the scale of temperature to milli degrees in
mt6370-adc.cand remove this item??
Quoted 12 lines
yes.
Thanks,
Jonathan
Quoted 5 lines
Quoted 2 lines
Best regards,
ChiaEn Wu
Best regards,
ChiaEn Wu
Re: [PATCH v2 03/15] dt-bindings: leds: mt6370: Add Mediatek mt6370 current sink type LED indicator
In reply to szuni chenQuoted 54 lines · szuni chen
Dear Krzysztof,
Thank you for the valuable command.
Krzysztof Kozlowski <[email protected]> 於 2022年6月17日 週五 清晨5:09寫道:
Quoted 49 lines · ChiaEn Wu
Quoted 33 lines
From: ChiYuan Huang <[email protected]>
Add Mediatek mt6370 current sink type LED indicator binding documentation.
Signed-off-by ChiYuan Huang <[email protected]>--- .../leds/mediatek,mt6370-indicator.yaml | 48 +++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 Documentation/devicetree/bindings/leds/mediatek,mt6370-indicator.yamlDocumentation/devicetree/bindings/leds/mediatek,mt6370-indicator.yaml new file +17
-0@@ -0,0 +1,48 @@ +# 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. + Add MT6370 LED driver include 4-channel RGB LED support Register/PWM/Breath Mode + +properties: + compatible:Documentation/devicetree/bindings/leds/mediatek,mt6370-indicator.yaml line 27
Quoted 10 lines
Documentation/devicetree/bindings/leds/mediatek,mt6370-indicator.yaml new file +10
-0+ const: mediatek,mt6370-indicator + + "#address-cells": + const: 1 + + "#size-cells": + const: 0 + +patternProperties: + "^(multi-)?led@[0-3]$":If this is multi-led, then you should reference
/schemas/leds/leds-pwm-multicolor.yaml
Quoted 6 lines
Quoted 1 line
See other examples using it.
In my opinion,
leds-pwm-multicolor.yamlis used for external pwm signals, and needs to assign an external pwm property.
But our pwm leds use an internal clock to generate the pwm signal. Isleds-class-multicolor.yamlmore appropriate?
Yeah, I meant the latter but pasted wrong file.
/schemas/leds/leds-class-multicolor.yaml#
Best regards,
Krzysztof
Re: [PATCH v2 08/15] mfd: mt6370: Add Mediatek MT6370 support
In reply to ChiaEn WuQuoted 51 lines · ChiaEn Wu
Hi Lee,
Thanks for your helpful comments, we have some questions and replies below.
Lee Jones <[email protected]> 於 2022年6月16日 週四 清晨6:49寫道:
Quoted 35 lines · ChiaEn Wu
Quoted 20 lines
From: ChiYuan Huang <[email protected]>
Add Mediatek MT6370 MFD support.
Signed-off-by ChiYuan Huang <[email protected]>--- drivers/mfd/Kconfig | 13 ++ drivers/mfd/Makefile | 1 + drivers/mfd/mt6370.c | 349 +++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 363 insertions(+) create mode 100644 drivers/mfd/mt6370.cdrivers/mfd/Kconfig +0
-0@@ -937,6 +937,19 @@ config MFD_MT6360 PMIC part includes 2-channel BUCKs and 2-channel LDOs LDO part includes 4-channel LDOsdrivers/mfd/Kconfig config MFD_MT6360 · line 948
Quoted 10 lines
drivers/mfd/Kconfig +9
-0+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, RGBs/integrates/consists of a/
Quoted 1 line
"ADC"
We will fine it in the next patch.
Quoted 6 lines
Quoted 5 lines
drivers/mfd/Kconfig +3
-0+ LEDs, dual channel flashlight, WLED backlight driver, display bias + voltage supply, one general purpose LDO, and cc logic + controller with USBPD commmunication capable.
Quoted 6 lines
Quoted 1 line
The last part makes no sense - "and is USBPD"?
If we modify this help text to
"one general purpose LDO, and the USB Type-C & PD controller complies with the latest USB Type-C and PD standards",
did these modifications meet your expectations?
"one general purpose LDO and a USB Type-C & PD controller that complies with the latest USB Type-C and PD standards"
Better?
Quoted 134 lines
Quoted 125 lines
Quoted 125 lines
drivers/mfd/Kconfig +0
-0config MFD_MT6397 tristate "MediaTek MT6397 PMIC Support" select MFD_COREdrivers/mfd/Makefile +1
-0@@ -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.odrivers/mfd/mt6370.c new file +104
-0@@ -0,0 +1,349 @@ +// SPDX-License-Identifier: GPL-2.0 + +#include <linux/bits.h> +#include <linux/i2c.h> +#include <linux/interrupt.h> +#include <linux/kernel.h> +#include <linux/mfd/core.h> +#include <linux/module.h> +#include <linux/regmap.h> + +enum { +MT6370_USBC_I2C =0 , +MT6370_PMU_I2C , +MT6370_MAX_I2C +}; + +#define MT6370_REG_DEV_INFO 0x100 +#define MT6370_REG_CHG_IRQ1 0x1C0 +#define MT6370_REG_CHG_MASK1 0x1E0 + +#define MT6370_VENID_MASK GENMASK(7, 4) + +#define MT6370_NUM_IRQREGS 16 +#define MT6370_USBC_I2CADDR 0x4E +#define MT6370_REG_ADDRLEN 2 +#define MT6370_REG_MAXADDR 0x1FF + +/* IRQ definitions */ +#define MT6370_IRQ_DIRCHGON 0 +#define MT6370_IRQ_CHG_TREG 4 +#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 +#define MT6370_IRQ_CHG_VSYSUV 12 +#define MT6370_IRQ_CHG_VSYSOV 13 +#define MT6370_IRQ_CHG_VBATOV 14 +#define MT6370_IRQ_CHG_VINOVPCHG 15 +#define MT6370_IRQ_TS_BAT_COLD 20 +#define MT6370_IRQ_TS_BAT_COOL 21 +#define MT6370_IRQ_TS_BAT_WARM 22 +#define MT6370_IRQ_TS_BAT_HOT 23 +#define MT6370_IRQ_TS_STATC 24 +#define MT6370_IRQ_CHG_FAULT 25 +#define MT6370_IRQ_CHG_STATC 26 +#define MT6370_IRQ_CHG_TMR 27 +#define MT6370_IRQ_CHG_BATABS 28 +#define MT6370_IRQ_CHG_ADPBAD 29 +#define MT6370_IRQ_CHG_RVP 30 +#define MT6370_IRQ_TSHUTDOWN 31 +#define MT6370_IRQ_CHG_IINMEAS 32 +#define MT6370_IRQ_CHG_ICCMEAS 33 +#define MT6370_IRQ_CHGDET_DONE 34 +#define MT6370_IRQ_WDTMR 35 +#define MT6370_IRQ_SSFINISH 36 +#define MT6370_IRQ_CHG_RECHG 37 +#define MT6370_IRQ_CHG_TERM 38 +#define MT6370_IRQ_CHG_IEOC 39 +#define MT6370_IRQ_ADC_DONE 40 +#define MT6370_IRQ_PUMPX_DONE 41 +#define MT6370_IRQ_BST_BATUV 45 +#define MT6370_IRQ_BST_MIDOV 46 +#define MT6370_IRQ_BST_OLP 47 +#define MT6370_IRQ_ATTACH 48 +#define MT6370_IRQ_DETACH 49 +#define MT6370_IRQ_HVDCP_STPDONE 51 +#define MT6370_IRQ_HVDCP_VBUSDET_DONE 52 +#define MT6370_IRQ_HVDCP_DET 53 +#define MT6370_IRQ_CHGDET 54 +#define MT6370_IRQ_DCDT 55 +#define MT6370_IRQ_DIRCHG_VGOK 59 +#define MT6370_IRQ_DIRCHG_WDTMR 60 +#define MT6370_IRQ_DIRCHG_UC 61 +#define MT6370_IRQ_DIRCHG_OC 62 +#define MT6370_IRQ_DIRCHG_OV 63 +#define MT6370_IRQ_OVPCTRL_SWON 67 +#define MT6370_IRQ_OVPCTRL_UVP_D 68 +#define MT6370_IRQ_OVPCTRL_UVP 69 +#define MT6370_IRQ_OVPCTRL_OVP_D 70 +#define MT6370_IRQ_OVPCTRL_OVP 71 +#define MT6370_IRQ_FLED_STRBPIN 72 +#define MT6370_IRQ_FLED_TORPIN 73 +#define MT6370_IRQ_FLED_TX 74 +#define MT6370_IRQ_FLED_LVF 75 +#define MT6370_IRQ_FLED2_SHORT 78 +#define MT6370_IRQ_FLED1_SHORT 79 +#define MT6370_IRQ_FLED2_STRB 80 +#define MT6370_IRQ_FLED1_STRB 81 +#define mT6370_IRQ_FLED2_STRB_TO 82 +#define MT6370_IRQ_FLED1_STRB_TO 83 +#define MT6370_IRQ_FLED2_TOR 84 +#define MT6370_IRQ_FLED1_TOR 85 +#define MT6370_IRQ_OTP 93 +#define MT6370_IRQ_VDDA_OVP 94 +#define MT6370_IRQ_VDDA_UV 95 +#define MT6370_IRQ_LDO_OC 103 +#define MT6370_IRQ_BLED_OCP 118 +#define MT6370_IRQ_BLED_OVP 119 +#define MT6370_IRQ_DSV_VNEG_OCP 123 +#define MT6370_IRQ_DSV_VPOS_OCP 124 +#define MT6370_IRQ_DSV_BST_OCP 125 +#define MT6370_IRQ_DSV_VNEG_SCP 126 +#define MT6370_IRQ_DSV_VPOS_SCP 127 +Quoted 8 lines
drivers/mfd/mt6370.c line 110
Quoted 6 lines
drivers/mfd/mt6370.c new file +6
-0+struct mt6370_info { +struct i2c_client *i2c[MT6370_MAX_I2C ]; +struct device *dev; +struct regmap *regmap; +struct regmap_irq_chip_data *irq_data; +};Can we shove all of the above into a header file?
Quoted 6 lines
Well... In Patch v1, we put these "#define IRQ" into "
include/dt-bindings/mfd/mediatek,mt6370.h".
But the reviewer of DT files hoped us to remove this header file, we put these "#define IRQ" in this .c file.
Shall we leave them here or put them into the header file in "driver/power/supply/mt6370-charger.h"?
Where are they used?
Signature · 4 lines
Lee Jones [李琼斯] Principal Technical Lead - Developer Services Linaro.org │ Open source software for Arm SoCs Follow Linaro: Facebook | Twitter | Blog
Re: [PATCH v2 08/15] mfd: mt6370: Add Mediatek MT6370 support
Hi Lee,
Thanks for your reply!
Lee Jones <[email protected]> 於 2022年6月27日 週一 晚上10:14寫道:
Quoted 61 lines · ChiaEn Wu
Quoted 52 lines
Hi Lee,
Thanks for your helpful comments, we have some questions and replies below.
Lee Jones <[email protected]> 於 2022年6月16日 週四 清晨6:49寫道:
Quoted 35 lines · ChiaEn Wu
Quoted 20 lines
From: ChiYuan Huang <[email protected]>
Add Mediatek MT6370 MFD support.
Signed-off-by ChiYuan Huang <[email protected]>--- drivers/mfd/Kconfig | 13 ++ drivers/mfd/Makefile | 1 + drivers/mfd/mt6370.c | 349 +++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 363 insertions(+) create mode 100644 drivers/mfd/mt6370.cdrivers/mfd/Kconfig +0
-0@@ -937,6 +937,19 @@ config MFD_MT6360 PMIC part includes 2-channel BUCKs and 2-channel LDOs LDO part includes 4-channel LDOsdrivers/mfd/Kconfig config MFD_MT6360 · line 948
Quoted 10 lines
drivers/mfd/Kconfig +9
-0+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, RGBs/integrates/consists of a/
Quoted 1 line
"ADC"
We will fine it in the next patch.
Quoted 6 lines
Quoted 5 lines
drivers/mfd/Kconfig +3
-0+ LEDs, dual channel flashlight, WLED backlight driver, display bias + voltage supply, one general purpose LDO, and cc logic + controller with USBPD commmunication capable.Quoted 6 lines
Quoted 1 line
The last part makes no sense - "and is USBPD"?
If we modify this help text to
"one general purpose LDO, and the USB Type-C & PD controller complies with the latest USB Type-C and PD standards",
did these modifications meet your expectations?
Quoted 4 lines
"one general purpose LDO and a USB Type-C & PD controller that complies with the latest USB Type-C and PD standards"
Better?
Yes, thanks! We will modify it like that in the next patch.
Quoted 135 lines
Quoted 135 lines
Quoted 134 lines
Quoted 122 lines
drivers/mfd/Kconfig +0
-0config MFD_MT6397 tristate "MediaTek MT6397 PMIC Support" select MFD_COREdrivers/mfd/Makefile +1
-0@@ -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.odrivers/mfd/mt6370.c new file +100
-0@@ -0,0 +1,349 @@ +// SPDX-License-Identifier: GPL-2.0 + +#include <linux/bits.h> +#include <linux/i2c.h> +#include <linux/interrupt.h> +#include <linux/kernel.h> +#include <linux/mfd/core.h> +#include <linux/module.h> +#include <linux/regmap.h> + +enum { +MT6370_USBC_I2C =0 , +MT6370_PMU_I2C , +MT6370_MAX_I2C +}; + +#define MT6370_REG_DEV_INFO 0x100 +#define MT6370_REG_CHG_IRQ1 0x1C0 +#define MT6370_REG_CHG_MASK1 0x1E0 + +#define MT6370_VENID_MASK GENMASK(7, 4) + +#define MT6370_NUM_IRQREGS 16 +#define MT6370_USBC_I2CADDR 0x4E +#define MT6370_REG_ADDRLEN 2 +#define MT6370_REG_MAXADDR 0x1FF + +/* IRQ definitions */ +#define MT6370_IRQ_DIRCHGON 0 +#define MT6370_IRQ_CHG_TREG 4 +#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 +#define MT6370_IRQ_CHG_VSYSUV 12 +#define MT6370_IRQ_CHG_VSYSOV 13 +#define MT6370_IRQ_CHG_VBATOV 14 +#define MT6370_IRQ_CHG_VINOVPCHG 15 +#define MT6370_IRQ_TS_BAT_COLD 20 +#define MT6370_IRQ_TS_BAT_COOL 21 +#define MT6370_IRQ_TS_BAT_WARM 22 +#define MT6370_IRQ_TS_BAT_HOT 23 +#define MT6370_IRQ_TS_STATC 24 +#define MT6370_IRQ_CHG_FAULT 25 +#define MT6370_IRQ_CHG_STATC 26 +#define MT6370_IRQ_CHG_TMR 27 +#define MT6370_IRQ_CHG_BATABS 28 +#define MT6370_IRQ_CHG_ADPBAD 29 +#define MT6370_IRQ_CHG_RVP 30 +#define MT6370_IRQ_TSHUTDOWN 31 +#define MT6370_IRQ_CHG_IINMEAS 32 +#define MT6370_IRQ_CHG_ICCMEAS 33 +#define MT6370_IRQ_CHGDET_DONE 34 +#define MT6370_IRQ_WDTMR 35 +#define MT6370_IRQ_SSFINISH 36 +#define MT6370_IRQ_CHG_RECHG 37 +#define MT6370_IRQ_CHG_TERM 38 +#define MT6370_IRQ_CHG_IEOC 39 +#define MT6370_IRQ_ADC_DONE 40 +#define MT6370_IRQ_PUMPX_DONE 41 +#define MT6370_IRQ_BST_BATUV 45 +#define MT6370_IRQ_BST_MIDOV 46 +#define MT6370_IRQ_BST_OLP 47 +#define MT6370_IRQ_ATTACH 48 +#define MT6370_IRQ_DETACH 49 +#define MT6370_IRQ_HVDCP_STPDONE 51 +#define MT6370_IRQ_HVDCP_VBUSDET_DONE 52 +#define MT6370_IRQ_HVDCP_DET 53 +#define MT6370_IRQ_CHGDET 54 +#define MT6370_IRQ_DCDT 55 +#define MT6370_IRQ_DIRCHG_VGOK 59 +#define MT6370_IRQ_DIRCHG_WDTMR 60 +#define MT6370_IRQ_DIRCHG_UC 61 +#define MT6370_IRQ_DIRCHG_OC 62 +#define MT6370_IRQ_DIRCHG_OV 63 +#define MT6370_IRQ_OVPCTRL_SWON 67 +#define MT6370_IRQ_OVPCTRL_UVP_D 68 +#define MT6370_IRQ_OVPCTRL_UVP 69 +#define MT6370_IRQ_OVPCTRL_OVP_D 70 +#define MT6370_IRQ_OVPCTRL_OVP 71 +#define MT6370_IRQ_FLED_STRBPIN 72 +#define MT6370_IRQ_FLED_TORPIN 73 +#define MT6370_IRQ_FLED_TX 74 +#define MT6370_IRQ_FLED_LVF 75 +#define MT6370_IRQ_FLED2_SHORT 78 +#define MT6370_IRQ_FLED1_SHORT 79 +#define MT6370_IRQ_FLED2_STRB 80 +#define MT6370_IRQ_FLED1_STRB 81 +#define mT6370_IRQ_FLED2_STRB_TO 82 +#define MT6370_IRQ_FLED1_STRB_TO 83 +#define MT6370_IRQ_FLED2_TOR 84 +#define MT6370_IRQ_FLED1_TOR 85 +#define MT6370_IRQ_OTP 93 +#define MT6370_IRQ_VDDA_OVP 94 +#define MT6370_IRQ_VDDA_UV 95 +#define MT6370_IRQ_LDO_OC 103 +#define MT6370_IRQ_BLED_OCP 118 +#define MT6370_IRQ_BLED_OVP 119 +#define MT6370_IRQ_DSV_VNEG_OCP 123 +#define MT6370_IRQ_DSV_VPOS_OCP 124drivers/mfd/mt6370.c line 110
Quoted 10 lines
drivers/mfd/mt6370.c new file +10
-0+#define MT6370_IRQ_DSV_BST_OCP 125 +#define MT6370_IRQ_DSV_VNEG_SCP 126 +#define MT6370_IRQ_DSV_VPOS_SCP 127 + +struct mt6370_info { +struct i2c_client *i2c[MT6370_MAX_I2C ]; +struct device *dev; +struct regmap *regmap; +struct regmap_irq_chip_data *irq_data; +};Can we shove all of the above into a header file?
Quoted 8 lines
Quoted 6 lines
Well... In Patch v1, we put these "#define IRQ" into "
include/dt-bindings/mfd/mediatek,mt6370.h".
But the reviewer of DT files hoped us to remove this header file, we put these "#define IRQ" in this .c file.
Shall we leave them here or put them into the header file in "driver/power/supply/mt6370-charger.h"?Where are they used?
Sorry, I wrote the wrong path last time...
What I should say last time was to put them into the header file into "driver/mfd/mt6370.h"
These "#define IRQ" are just used in "driver/mfd/mt6370.c" I’m really sorry for making this mistake...
Quoted 6 lines
--
Lee Jones [李琼斯]
Principal Technical Lead - Developer ServicesLinaro.org │ Open source software for Arm SoCs Follow Linaro: Facebook | Twitter | Blog
Best regards,
ChiaEn Wu
Re: [PATCH v2 08/15] mfd: mt6370: Add Mediatek MT6370 support
[...]
Quoted 21 lines
Quoted 21 lines
Quoted 20 lines
Quoted 5 lines
Quoted 5 lines
drivers/mfd/mt6370.c new file +5
-0+#define MT6370_IRQ_DSV_VPOS_OCP 124 +#define MT6370_IRQ_DSV_BST_OCP 125 +#define MT6370_IRQ_DSV_VNEG_SCP 126 +#define MT6370_IRQ_DSV_VPOS_SCP 127 +Quoted 8 lines
drivers/mfd/mt6370.c line 110
Quoted 6 lines
drivers/mfd/mt6370.c new file +6
-0+struct mt6370_info { +struct i2c_client *i2c[MT6370_MAX_I2C ]; +struct device *dev; +struct regmap *regmap; +struct regmap_irq_chip_data *irq_data; +};Can we shove all of the above into a header file?
Well... In Patch v1, we put these "#define IRQ" into "
include/dt-bindings/mfd/mediatek,mt6370.h".
But the reviewer of DT files hoped us to remove this header file, we put these "#define IRQ" in this .c file.
Shall we leave them here or put them into the header file in "driver/power/supply/mt6370-charger.h"?
Quoted 7 lines
Quoted 1 line
Where are they used?
Sorry, I wrote the wrong path last time...
What I should say last time was to put them into the header file into "driver/mfd/mt6370.h"
These "#define IRQ" are just used in "driver/mfd/mt6370.c" I’m really sorry for making this mistake...
Yes, that would be fine.
Signature · 4 lines
Lee Jones [李琼斯] Principal Technical Lead - Developer Services Linaro.org │ Open source software for Arm SoCs Follow Linaro: Facebook | Twitter | Blog