Add Mediatek MT6370 PMIC support
Subsystems (11)
v4 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.
In this series of patches, we based on Andy Shevchenko's mfd patch used to adjust the Makefile order.
(https://lore.kernel.org/all/[email protected]/)
Among with this, we took some changes for MT6370 and refined the MT6370 device tree files to comply with DT specifications.
Thank you,
ChiaEn Wu
---
Changes in v4:
- In patch 02/13:
- Add minItems of "io-channel-names"
- Replace text "Mediatek" with "MediaTek"
- In patch 06/13:
- Roll back all "$ref: " to v2 patch style (using "/schemas/...")
- In patch 07/13:
- Replace text "Mediatek" with "MediaTek" in Kconfig
- Replace "first break and then return" with "return directly" in
"mt6370_check_vendor_info()"
- Add module name related description in Kconfig helptext
- Add Copyright in the source code
- Add header file "mt6370.h" for all "#define IRQ"
- Adjust Makefile order of MT6370
- Refine "bank_idx" and "bank_addr" in "mt6375_regmap_read()" / "mt6375_regmap_write()"
- Refine redundant "else if" in "mt6370_regmap_read()"
- In patch 08/13:
- Replace text "Mediatek" with "MediaTek" in Kconfig
- Replace "first ret=regulator_(dis/en)able and then return" with "return directly" in "mt6370_tcpc_set_vbus()"
- Replace header file <linux/of.h> with <linux/mod_devicetable.h>
- Add Copyright in the source code
- Add module name related description in Kconfig helptext
- Remove header file <linux/of.h>
- Refine all probe error by using dev_err_probe()
- In patch 09/13:
- Replace text "Mediatek" with "MediaTek"
- Replace all "first dev_err() and then return" with "return dev_err_probe()"
- Add Copyright in the source code
- Add module name related description in Kconfig
- Add unit suffix of macro "ADC_CONV_POLLING_TIME"
- Add new macro "ADC_CONV_TIME_MS"
- Adjust the position of include file <mediatek,mt6370_adc.h>
- Adjust the postions between <linux/module.h> and <linux/mod_devicetable.h>
- Fix some incorrect characters
- In patch 10/13:
- Replace text "Mediatek" with "MediaTek" in Kconfig and MODULE_DESCRIPTION()
- Replace "mt6370_chg_val_to_reg" and "mt6370_chg_reg_to_val" with
"linear_range" API
- Replace "first break and then return" with "return directly" in all
cases of get/set power_supply_property
- Replace all "first dev_err() and then return" with "return dev_err_probe()"
- Replace all "return IS_ERR(priv->rdev) ? PTR_ERR(priv->rdev) :
0" with
"PTR_ERR_OR_ZERO()"
- Replace "priv->dev->of_node" with "dev_of_node()"
- Add Copyright in the source code
- Add module name related description in Kconfig helptext
- Add proper unit of "MT6370_MIVR_IBUS_TH"
- Add error check in "mt6370_chg_get_status"
- Remove including <mediatek,mt6370_adc.h> header file
- Remove redundant comma of every enum terminator line
- Remove unwanted blank lines
- Remove the useless label (toggle_cfo_exit:)
- Remove using atomic
- Remove using of_match_ptr()
- Fix some incorrect characters
- Fix updating wrong bits when using ena_gpiod of OTG regulator
- Adjust the probe order in probe()
- In patch 11/13:
- Replace text "Mediatek" with "MediaTek" in Kconfig
- Replace text "const" with "constant" in Kconfig
- Add Copyright in the source code
- In patch 12/13:
- Replace text "Mediatek" with "MediaTek" in Kconfig
- Add Copyright in the source code
- In patch 13/13:
- Replace text "Mediatek" with "MediaTek" in Kconfig
- Add Copyright in the source code
- Revise the comment of "PWM HYS STEPS"
Changes in v3:
- Remove ADC ABI file, which is added in v2 Patch 7
- In patch 02/14:
- Add items and remove maxItems of io-channels
- Add io-channel-names and describe each item
- Add "unevaluatedProperties: false" in "usb-otg-vbus-regulator"
- Rename "enable-gpio" to "enable-gpios" in "usb-otg-vbus-regulator"
- In patch 03/14:
- Use leds-class-multicolor.yaml instead of common.yaml.
- Split multi-led and led node.
- Add subdevice "led" in "multi-led".
- In patch 04/14:
- Remove the description of enum.
- In patch 05/14:
- Rename "mediatek,bled-pwm-hys-input-threshold-steps" to "mediatek,bled-pwm-hys-input-th-steps"
- Refine "bled-pwm-hys-input-th-steps", "bled-ovp-microvolt", "bled-ocp-microamp" enum values
- In patch 06/14:
- Use " in entire patchset
- Refine ADC description
- Rename "enable-gpio" to "enable-gpios" in "regualtor"
- In patch 07/14:
- Refine Kconfig help text
- Refine error message of unknown vendor ID in mt6370_check_vendor_info()
- Refine return value handling of mt6370_regmap_read()
- Refine all probe error by using dev_err_probe()
- Refine "bank_idx" and "bank_addr" in mt6370_regmap_read() and mt6370_regmap_write()
- Add "#define VENID*" and drop the comments in mt6370_check_vendor_info()
- Drop "MFD" in MODULE_DESCRIPTION()
- In patch 09/14:
- Refine Kconfig help text
- In patch 10/14:
- Refine Kconfig help text
- Refine all channel value in read_scale()
a. current: uA --> mA
b. voltage: uV --> mV
c. temperature: degrees Celsius --> milli degrees Celsius
- Add "default:" condition of switch statement in read_scale() and read_raw()
- Add error message for reading ADC register failed
- Add the comment for adc_lock
- Add <linux/mod_devicetable.h> header file for struct of_device_id
- Replace "adc" text with "ADC" in all of the error messages
- In patch 12/14:
- Refine the grammer of the Kconfig.
- Change reg mode to the const current mode.
- In patch 14/14:
- Refine bool properties parsing (pwm-enable, ovp-shutdown, ocp-shutdown) in DT parsing function
- Refine u32 and u8 properties parsing (pwm-hys-input-th-steps, ovp-microvolt, ocp-microamp), from using register value to using actual value
- Refine error string of "channle-use" parsing failed
- Refine Kconfig help text
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 (7):
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
leds: mt6370: Add Mediatek MT6370 current sink type LED Indicator
support
ChiaEn Wu (4):
dt-bindings: power: supply: Add Mediatek MT6370 Charger
iio: adc: mt6370: Add Mediatek MT6370 support
power: supply: mt6370: Add Mediatek MT6370 charger driver
video: backlight: mt6370: Add Mediatek MT6370 support
.../leds/backlight/mediatek,mt6370-backlight.yaml | 92 ++ .../bindings/leds/mediatek,mt6370-flashlight.yaml | 41 + .../bindings/leds/mediatek,mt6370-indicator.yaml | 77 ++ .../devicetree/bindings/mfd/mediatek,mt6370.yaml | 280 ++++++ .../power/supply/mediatek,mt6370-charger.yaml | 88 ++ .../bindings/usb/mediatek,mt6370-tcpc.yaml | 36 + drivers/iio/adc/Kconfig | 12 + drivers/iio/adc/Makefile | 1 + drivers/iio/adc/mt6370-adc.c | 274 +++++ drivers/leds/Kconfig | 14 + drivers/leds/Makefile | 1 + drivers/leds/flash/Kconfig | 12 + drivers/leds/flash/Makefile | 1 + drivers/leds/flash/leds-mt6370-flash.c | 662 ++++++++++++ drivers/leds/leds-mt6370.c | 994 ++++++++++++++++++ drivers/mfd/Kconfig | 16 + drivers/mfd/Makefile | 1 + drivers/mfd/mt6370.c | 289 ++++++ drivers/mfd/mt6370.h | 88 ++ drivers/power/supply/Kconfig | 14 + drivers/power/supply/Makefile | 1 + drivers/power/supply/mt6370-charger.c | 1062 ++++++++++++++++++++ drivers/usb/typec/tcpm/Kconfig | 11 + drivers/usb/typec/tcpm/Makefile | 1 + drivers/usb/typec/tcpm/tcpci_mt6370.c | 207 ++++ drivers/video/backlight/Kconfig | 12 + drivers/video/backlight/Makefile | 1 + drivers/video/backlight/mt6370-backlight.c | 352 +++++++ include/dt-bindings/iio/adc/mediatek,mt6370_adc.h | 18 + 29 files changed, 4658 insertions(+) create mode 100644 Documentation/devicetree/bindings/leds/backlight/mediatek,mt6370-backlight.yaml create mode 100644 Documentation/devicetree/bindings/leds/mediatek,mt6370-flashlight.yaml create mode 100644 Documentation/devicetree/bindings/leds/mediatek,mt6370-indicator.yaml create mode 100644 Documentation/devicetree/bindings/mfd/mediatek,mt6370.yaml create mode 100644 Documentation/devicetree/bindings/power/supply/mediatek,mt6370-charger.yaml create mode 100644 Documentation/devicetree/bindings/usb/mediatek,mt6370-tcpc.yaml create mode 100644 drivers/iio/adc/mt6370-adc.c create mode 100644 drivers/leds/flash/leds-mt6370-flash.c create mode 100644 drivers/leds/leds-mt6370.c create mode 100644 drivers/mfd/mt6370.c create mode 100644 drivers/mfd/mt6370.h create mode 100644 drivers/power/supply/mt6370-charger.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.7.4
PATCH v4 1/13 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: MediatTek 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.7.4
PATCH v4 2/13 dt-bindings: power: supply: Add Mediatek MT6370 Charger
In reply to ChiaEn WuFrom: ChiaEn Wu <[email protected]>
Add Mediatek MT6370 Charger binding documentation.
---
v4:
- Add minItems of "io-channel-names"
- Replace text "Mediatek" with "MediaTek"
--- .../power/supply/mediatek,mt6370-charger.yaml | 88 ++++++++++++++++++++++ 1 file changed, 88 insertions(+) create mode 100644 Documentation/devicetree/bindings/power/supply/mediatek,mt6370-charger.yaml
Documentation/devicetree/bindings/power/supply/mediatek,mt6370-charger.yaml new file +88 -0
@@ -0,0 +1,88 @@ +# 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. + minItems: 1 + items: + - description: | + VBUS voltage with lower accuracy (+-75mV) but higher measure + range (1~22V) + - description: | + VBUS voltage with higher accuracy (+-30mV) but lower measure + range (1~9.76V) + - description: the main system input voltage + - description: battery voltage + - description: battery temperature-sense input voltage + - description: IBUS current (required) + - description: battery current + - description: | + regulated output voltage to supply for the PWM low-side gate driver + and the bootstrap capacitor + - description: IC junction temperature + + io-channel-names: + minItems: 1 + items: + - const: vbusdiv5 + - const: vbusdiv2 + - const: vsys + - const: vbat + - const: ts_bat + - const: ibus + - const: ibat + - const: chg_vddp + - const: temp_jc + + usb-otg-vbus-regulator: + type: object + description: OTG boost regulator. + unevaluatedProperties: false + $ref: /schemas/regulator/regulator.yaml# + + properties: + enable-gpios: + maxItems: 1 + +required: + - compatible + - interrupts + - interrupt-names + - io-channels + +additionalProperties: false + +...
Signature · 1 line
2.7.4
PATCH v4 3/13 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.
--- .../bindings/leds/mediatek,mt6370-indicator.yaml | 77 ++++++++++++++++++++++ 1 file changed, 77 insertions(+) create mode 100644 Documentation/devicetree/bindings/leds/mediatek,mt6370-indicator.yaml
Documentation/devicetree/bindings/leds/mediatek,mt6370-indicator.yaml new file +77 -0
@@ -0,0 +1,77 @@ +# 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 + +allOf: + - $ref: leds-class-multicolor.yaml# + +properties: + compatible: + const: mediatek,mt6370-indicator + + "#address-cells": + const: 1 + + "#size-cells": + const: 0 + +patternProperties: + "^multi-led@[0-3]$": + type: object + + properties: + reg: + enum: [0, 1, 2, 3] + + "#address-cells": + const: 1 + + "#size-cells": + const: 0 + + patternProperties: + "^led@[0-2]$": + type: object + $ref: common.yaml# + unevaluatedProperties: false + + required: + - reg + - color + + required: + - reg + - color + - "#address-cells" + - "#size-cells" + + "^led@[0-3]$": + type: object + $ref: common.yaml# + unevaluatedProperties: false + + properties: + reg: + enum: [0, 1, 2, 3] + + required: + - reg + - color + +required: + - compatible + - "#address-cells" + - "#size-cells" + +additionalProperties: false
Signature · 1 line
2.7.4
PATCH v4 4/13 dt-bindings: leds: Add Mediatek MT6370 flashlight
In reply to ChiaEn WuFrom: Alice Chen <[email protected]>
Add Mediatek MT6370 flashlight binding documentation.
--- .../bindings/leds/mediatek,mt6370-flashlight.yaml | 41 ++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 Documentation/devicetree/bindings/leds/mediatek,mt6370-flashlight.yaml
Documentation/devicetree/bindings/leds/mediatek,mt6370-flashlight.yaml new file +41 -0
@@ -0,0 +1,41 @@ +# 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# + unevaluatedProperties: false + + properties: + reg: + enum: [0, 1] + +required: + - compatible + - "#address-cells" + - "#size-cells" + +additionalProperties: false
Signature · 1 line
2.7.4
PATCH v4 5/13 dt-bindings: backlight: Add Mediatek MT6370 backlight
In reply to ChiaEn WuFrom: ChiYuan Huang <[email protected]>
Add mt6370 backlight binding documentation.
--- .../leds/backlight/mediatek,mt6370-backlight.yaml | 92 ++++++++++++++++++++++ 1 file changed, 92 insertions(+) create mode 100644 Documentation/devicetree/bindings/leds/backlight/mediatek,mt6370-backlight.yaml
Documentation/devicetree/bindings/leds/backlight/mediatek,mt6370-backlight.yaml new file +92 -0
@@ -0,0 +1,92 @@ +# 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-th-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 more than 64 steps. + + mediatek,bled-ovp-shutdown: + description: | + Enable the backlight shutdown when OVP level triggered + type: boolean + + mediatek,bled-ovp-microvolt: + enum: [17000000, 21000000, 25000000, 29000000] + description: | + Backlight OVP level selection. + + mediatek,bled-ocp-shutdown: + description: | + Enable the backlight shutdown when OCP level triggerred. + type: boolean + + mediatek,bled-ocp-microamp: + enum: [900000, 1200000, 1500000, 1800000] + description: | + Backlight OC level selection. + + 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.7.4
PATCH v4 6/13 dt-bindings: mfd: Add Mediatek MT6370
In reply to ChiaEn WuFrom: ChiYuan Huang <[email protected]>
Add Mediatek MT6370 binding documentation.
---
v4
- Roll back all "$ref: " to v2 patch style (using
"/schemas/...")
--- .../devicetree/bindings/mfd/mediatek,mt6370.yaml | 280 +++++++++++++++++++++ include/dt-bindings/iio/adc/mediatek,mt6370_adc.h | 18 ++ 2 files changed, 298 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 +280 -0
@@ -0,0 +1,280 @@ +# 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 (lower + accuracy, higher measure range), VBUSDIV2 (higher accuracy, lower + measure range), 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-gpios: + 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.7.4
PATCH v4 7/13 mfd: mt6370: Add Mediatek MT6370 support
In reply to ChiaEn WuFrom: ChiYuan Huang <[email protected]>
Add Mediatek MT6370 MFD support.
---
v4
- Replace text "Mediatek" with "MediaTek" in Kconfig
- Replace "first break and then return" with "return directly" in
"mt6370_check_vendor_info()"
- Add module name related description in Kconfig helptext
- Add Copyright in the source code
- Add header file "mt6370.h" for all "#define IRQ"
- Adjust Makefile order of MT6370
- Refine "bank_idx" and "bank_addr" in "mt6375_regmap_read()" / "mt6375_regmap_write()"
- Refine redundant "else if" in "mt6370_regmap_read()"
--- drivers/mfd/Kconfig | 16 +++ drivers/mfd/Makefile | 1 + drivers/mfd/mt6370.c | 289 +++++++++++++++++++++++++++++++++++++++++++++++++++ drivers/mfd/mt6370.h | 88 ++++++++++++++++ 4 files changed, 394 insertions(+) create mode 100644 drivers/mfd/mt6370.c create mode 100644 drivers/mfd/mt6370.h
drivers/mfd/Kconfig +16 -0
@@ -937,6 +937,22 @@ 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 consists of a single cell battery charger with ADC monitoring, RGB + LEDs, dual channel flashlight, WLED backlight driver, display bias + voltage supply, one general purpose LDO, and the USB Type-C & PD + controller complies with the latest USB Type-C and PD standards. + + This driver can also be built as a module. If so the module + will be called "mt6370.ko". + config MFD_MT6397 tristate "MediaTek MT6397 PMIC Support" select MFD_CORE
drivers/mfd/Makefile +1 -0
@@ -173,6 +173,7 @@ obj-$(CONFIG_MFD_MAX8998) += max8998.o max8998-irq.o obj-$(CONFIG_MFD_MP2629) += mp2629.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
drivers/mfd/mt6370.c new file +289 -0
289 lines not on this page · raw message
drivers/mfd/mt6370.h new file +88 -0
88 lines not on this page · raw message
Signature · 1 line
2.7.4
PATCH v4 8/13 usb: typec: tcpci_mt6370: Add Mediatek MT6370 tcpci driver
In reply to ChiaEn WuFrom: ChiYuan Huang <[email protected]>
Add chip level mt6370 tcpci driver.
---
v4:
- Replace text "Mediatek" with "MediaTek" in Kconfig
- Replace "first ret=regulator_(dis/en)able and then return" with "return directly" in "mt6370_tcpc_set_vbus()"
- Replace header file <linux/of.h> with <linux/mod_devicetable.h>
- Add Copyright in the source code
- Add module name related description in Kconfig helptext
- Remove header file <linux/of.h>
- Refine all probe error by using dev_err_probe()
--- drivers/usb/typec/tcpm/Kconfig | 11 ++ drivers/usb/typec/tcpm/Makefile | 1 + drivers/usb/typec/tcpm/tcpci_mt6370.c | 207 ++++++++++++++++++++++++++++++++++ 3 files changed, 219 insertions(+) create mode 100644 drivers/usb/typec/tcpm/tcpci_mt6370.c
drivers/usb/typec/tcpm/Kconfig +11 -0
@@ -35,6 +35,17 @@ 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. + + This driver can also be built as a module. If so the module + will be called "tcpci_mt6370.ko". + 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 +207 -0
207 lines not on this page · raw message
Signature · 1 line
2.7.4
PATCH v4 9/13 iio: adc: mt6370: Add Mediatek MT6370 support
In reply to ChiaEn WuFrom: ChiaEn Wu <[email protected]>
Add Mediatek MT6370 ADC support.
---
v4:
- Replace text "Mediatek" with "MediaTek"
- Replace all "first dev_err() and then return" with "return dev_err_probe()"
- Add Copyright in the source code
- Add module name related description in Kconfig
- Add unit suffix of macro "ADC_CONV_POLLING_TIME"
- Add new macro "ADC_CONV_TIME_MS"
- Adjust the position of include file <mediatek,mt6370_adc.h>
- Adjust the postions between <linux/module.h> and <linux/mod_devicetable.h>
- Fix some incorrect characters
--- drivers/iio/adc/Kconfig | 12 ++ drivers/iio/adc/Makefile | 1 + drivers/iio/adc/mt6370-adc.c | 274 +++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 287 insertions(+) create mode 100644 drivers/iio/adc/mt6370-adc.c
drivers/iio/adc/Kconfig +12 -0
@@ -737,6 +737,18 @@ 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 yes here to enable MediaTek MT6370 ADC support. + + This ADC driver provides 9 channels for system monitoring (charger + current, voltage, and temperature). + + This driver can also be built as a module. If so the module + will be called "mt6370-adc.ko". + 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 +274 -0
274 lines not on this page · raw message
Signature · 1 line
2.7.4
PATCH v4 10/13 power: supply: mt6370: Add Mediatek MT6370 charger driver
In reply to ChiaEn WuFrom: ChiaEn Wu <[email protected]>
Add Mediatek MT6370 charger driver.
---
v4:
- Replace text "Mediatek" with "MediaTek" in Kconfig and MODULE_DESCRIPTION()
- Replace "mt6370_chg_val_to_reg" and "mt6370_chg_reg_to_val" with
"linear_range" API
- Replace "first break and then return" with "return directly" in all
cases of get/set power_supply_property
- Replace all "first dev_err() and then return" with "return dev_err_probe()"
- Replace all "return IS_ERR(priv->rdev) ? PTR_ERR(priv->rdev) :
0" with
"PTR_ERR_OR_ZERO()"
- Replace "priv->dev->of_node" with "dev_of_node()"
- Add Copyright in the source code
- Add module name related description in Kconfig helptext
- Add proper unit of "MT6370_MIVR_IBUS_TH"
- Add error check in "mt6370_chg_get_status"
- Remove including <mediatek,mt6370_adc.h> header file
- Remove redundant comma of every enum terminator line
- Remove unwanted blank lines
- Remove the useless label (toggle_cfo_exit:)
- Remove using atomic
- Remove using of_match_ptr()
- Fix some incorrect characters
- Fix updating wrong bits when using ena_gpiod of OTG regulator
- Adjust the probe order in probe()
--- drivers/power/supply/Kconfig | 14 + drivers/power/supply/Makefile | 1 + drivers/power/supply/mt6370-charger.c | 1062 +++++++++++++++++++++++++++++++++ 3 files changed, 1077 insertions(+) create mode 100644 drivers/power/supply/mt6370-charger.c
drivers/power/supply/Kconfig +14 -0
@@ -619,6 +619,20 @@ 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. + + This driver can also be built as a module. If so the module + will be called "mt6370-charger.ko". + 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 +1062 -0
1,062 lines not on this page · raw message
Signature · 1 line
2.7.4
PATCH v4 11/13 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.
---
v4:
- Replace text "Mediatek" with "MediaTek" in Kconfig
- Replace text "const" with "constant" in Kconfig
- Add Copyright in the source code
--- drivers/leds/Kconfig | 14 + drivers/leds/Makefile | 1 + drivers/leds/leds-mt6370.c | 994 +++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 1009 insertions(+) create mode 100644 drivers/leds/leds-mt6370.c
drivers/leds/Kconfig +14 -0
@@ -244,6 +244,20 @@ 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 are four channel current-sink LED drivers that + support hardware pattern for constant current, PWM, and breath mode. + Isink4 channel can also be used as a CHG_VIN power good indicator. + + This driver can also be built as a module. If so the module + will be called "leds-mt6370.ko". + 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 +994 -0
994 lines not on this page · raw message
Signature · 1 line
2.7.4
PATCH v4 12/13 leds: flashlight: mt6370: Add Mediatek MT6370 flashlight support
In reply to ChiaEn WuFrom: Alice Chen <[email protected]>
Add Mediatek MT6370 flashlight support.
---
v4:
- Replace text "Mediatek" with "MediaTek" in Kconfig
- Add Copyright in the source code
--- drivers/leds/flash/Kconfig | 12 + drivers/leds/flash/Makefile | 1 + drivers/leds/flash/leds-mt6370-flash.c | 662 +++++++++++++++++++++++++++++++++ 3 files changed, 675 insertions(+) create mode 100644 drivers/leds/flash/leds-mt6370-flash.c
drivers/leds/flash/Kconfig +12 -0
@@ -90,4 +90,16 @@ 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. + + This driver can also be built as a module. If so the module + will be called "leds-mt6370-flash.ko". + 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 +662 -0
662 lines not on this page · raw message
Signature · 1 line
2.7.4
PATCH v4 13/13 video: backlight: mt6370: Add Mediatek MT6370 support
In reply to ChiaEn WuFrom: ChiaEn Wu <[email protected]>
Add Mediatek MT6370 Backlight support.
---
v4:
- Replace text "Mediatek" with "MediaTek" in Kconfig
- Add Copyright in the source code
- Revise the comment of "PWM HYS STEPS"
--- drivers/video/backlight/Kconfig | 12 + drivers/video/backlight/Makefile | 1 + drivers/video/backlight/mt6370-backlight.c | 352 +++++++++++++++++++++++++++++ 3 files changed, 365 insertions(+) create mode 100644 drivers/video/backlight/mt6370-backlight.c
drivers/video/backlight/Kconfig +12 -0
@@ -268,6 +268,18 @@ 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 are 4 channels + inside, and each channel supports up to 30mA of current capability + with 2048 current steps in exponential or linear mapping curves. + + This driver can also be built as a module. If so the module + will be called "mt6370-backlight.ko". + 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 +352 -0
352 lines not on this page · raw message
Signature · 1 line
2.7.4
Greg KH
maintainerRe: [PATCH v4 08/13] usb: typec: tcpci_mt6370: Add Mediatek MT6370 tcpci driver
In reply to ChiaEn WuQuoted 3 lines · ChiaEn Wu
From: ChiYuan Huang <[email protected]>
Add chip level mt6370 tcpci driver.
What does this mean? Please provide more information about the hardware being supported here so we know how to review this.
thanks,
greg k-h
Re: [PATCH v4 02/13] dt-bindings: power: supply: Add Mediatek MT6370 Charger
In reply to ChiaEn WuQuoted 6 lines · ChiaEn Wu
From: ChiaEn Wu <[email protected]>
Add Mediatek MT6370 Charger binding documentation.
Signed-off-by ChiaEn Wu <[email protected]>---
Best regards,
Krzysztof
Re: [PATCH v4 06/13] dt-bindings: mfd: Add Mediatek MT6370
In reply to ChiaEn WuQuoted 10 lines · ChiaEn Wu
From: ChiYuan Huang <[email protected]>
Add Mediatek MT6370 binding documentation.
Signed-off-by ChiYuan Huang <[email protected]>---
v4
- Roll back all "$ref: " to v2 patch style (using
"/schemas/...")
Quoted 7 lines
--- .../devicetree/bindings/mfd/mediatek,mt6370.yaml | 280 +++++++++++++++++++++ include/dt-bindings/iio/adc/mediatek,mt6370_adc.h | 18 ++ 2 files changed, 298 insertions(+) create mode 100644 Documentation/devicetree/bindings/mfd/mediatek,mt6370.yaml create mode 100644 include/dt-bindings/iio/adc/mediatek,mt6370_adc.h
Looks ok. This depends on previous DT bindings patches, so all of them should go through one tree or with some pull requests (but that would be a lot). You should mention it in cover letter to get the acks from subsystem maintainers.
Best regards,
Krzysztof
Re: [PATCH v4 08/13] usb: typec: tcpci_mt6370: Add Mediatek MT6370 tcpci driver
In reply to Greg KHGreg KH <[email protected]> 於 2022年7月4日 週一 下午3:32寫道:
Quoted 8 lines · ChiaEn Wu
Quoted 3 lines
From: ChiYuan Huang <[email protected]>
Add chip level mt6370 tcpci driver.
What does this mean? Please provide more information about the hardware being supported here so we know how to review this.
Dear Greg,
MediaTek 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.
This driver is used for the Type-C & Power Delivery controller in MediaTek MT6370 IC.
If we change the commit message to
"Add MediaTek MT6370 tcpci driver.
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."
does this meet your requirements?
Or “Add tcpci driver for Mediatek MT6370 IC” is enough?
Sincerely,
Alice Chen
Greg KH
maintainerRe: [PATCH v4 08/13] usb: typec: tcpci_mt6370: Add Mediatek MT6370 tcpci driver
Quoted 21 lines · szuni chen
Greg KH <[email protected]> 於 2022年7月4日 週一 下午3:32寫道:
Quoted 8 lines · ChiaEn Wu
Quoted 3 lines
From: ChiYuan Huang <[email protected]>
Add chip level mt6370 tcpci driver.
What does this mean? Please provide more information about the hardware being supported here so we know how to review this.
Dear Greg,
MediaTek 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.
This driver is used for the Type-C & Power Delivery controller in MediaTek MT6370 IC.
Quoted 8 lines
If we change the commit message to
"Add MediaTek MT6370 tcpci driver.
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."does this meet your requirements?
What would you want to see if you were reading a changelog text for an unfamiliar hardware device? More text is always better!
thanks,
greg k-h
Re: [PATCH v4 08/13] usb: typec: tcpci_mt6370: Add Mediatek MT6370 tcpci driver
In reply to ChiaEn WuQuoted 2 lines · ChiaEn Wu
Add chip level mt6370 tcpci driver.
...
Quoted 4 lines
drivers/usb/typec/tcpm/tcpci_mt6370.c new file +4
-0+static const struct reg_sequence mt6370_reg_init[] = { +REG_SEQ (0xA0 ,0x1 ,1000 ), +REG_SEQ (0x81 ,0x38 ,0 ), +REG_SEQ (0x82 ,0x82 ,0 ),
drivers/usb/typec/tcpm/tcpci_mt6370.c line 49
Quoted 10 lines
drivers/usb/typec/tcpm/tcpci_mt6370.c new file +10
-0+REG_SEQ (0xBA ,0xFC ,0 ), +REG_SEQ (0xBB ,0x50 ,0 ), +REG_SEQ (0x9E ,0x8F ,0 ), +REG_SEQ (0xA1 ,0x5 ,0 ), +REG_SEQ (0xA2 ,0x4 ,0 ), +REG_SEQ (0xA3 ,0x4A ,0 ), +REG_SEQ (0xA4 ,0x01 ,0 ), +REG_SEQ (0x95 ,0x01 ,0 ), +REG_SEQ (0x80 ,0x71 ,0 ), +REG_SEQ (0x9B ,0x3A ,1000 )
Keep a comma here in case something would be added later on.
Quoted 1 line
+};
...
drivers/usb/typec/tcpm/tcpci_mt6370.c line 96
Quoted 6 lines
drivers/usb/typec/tcpm/tcpci_mt6370.c new file +6
-0+if (ret && !source) +return regulator_disable (priv->vbus); +else if (!ret && source) +return regulator_enable (priv->vbus); +else +return 0 ;
'else' is redundant in both cases.
...
drivers/usb/typec/tcpm/tcpci_mt6370.c line 118
Quoted 13 lines
drivers/usb/typec/tcpm/tcpci_mt6370.c new file +13
-0+static int mt6370_check_vendor_info (struct mt6370_priv *priv) +{ +struct regmap *regmap = priv->tcpci_data.regmap; +u16 vid; +int ret; + + ret =regmap_raw_read (regmap,TCPC_VENDOR_ID , &vid,sizeof (u16)); +if (ret) +return ret; + +if (vid !=MT6370_VENDOR_ID ) { +dev_err (priv->dev,"Vendor ID not correct 0x%02x\n" , vid); +return -ENODEV ;
return dev_err_probe(...);
Quoted 12 lines
drivers/usb/typec/tcpm/tcpci_mt6370.c new file +12
-0+ } + +return 0 ; +} + +static int mt6370_tcpc_probe (struct platform_device *pdev) +{ +struct mt6370_priv *priv; +int ret; + + priv =devm_kzalloc (&pdev->dev,sizeof (*priv),GFP_KERNEL ); +if (!priv)
drivers/usb/typec/tcpm/tcpci_mt6370.c line 139
Quoted 10 lines
drivers/usb/typec/tcpm/tcpci_mt6370.c new file +9
-0+return -ENOMEM ; + + priv->dev = &pdev->dev; +platform_set_drvdata (pdev, priv); + + priv->tcpci_data.regmap =dev_get_regmap (pdev->dev.parent,NULL ); +if (!priv->tcpci_data.regmap) +return dev_err_probe (&pdev->dev, -ENODEV , +"Failed to init regmap\n" );
You may save some LoCs by introducing a temporary variable
struct device *dev = &pdev->dev;
and here on a single line
return dev_err_probe(dev, ...);
Ditto for the rest.
...
drivers/usb/typec/tcpm/tcpci_mt6370.c line 144
Quoted 5 lines
drivers/usb/typec/tcpm/tcpci_mt6370.c new file +4
-0+ ret =mt6370_check_vendor_info (priv); +if (ret) +return dev_err_probe (&pdev->dev, ret, +"Failed to check vendor info\n" );
This duplicates (with less info given) the message from the callee.
...
Quoted 1 line
+ { .compatible = "mediatek,mt6370-tcpc", },
Inner comma is not needed.
Signature · 2 lines
With Best Regards, Andy Shevchenko
Re: [PATCH v4 07/13] mfd: mt6370: Add Mediatek MT6370 support
In reply to ChiaEn WuQuoted 2 lines · ChiaEn Wu
Add Mediatek MT6370 MFD support.
...
Quoted 1 line
+ This driver can also be built as a module. If so the module
If so,
Quoted 1 line
+ will be called "mt6370.ko".
".ko" part is not needed.
To all your patches in the series where this applies.
...
Quoted 66 lines
drivers/mfd/mt6370.c new file +66
-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 ),
drivers/mfd/mt6370.c line 124
Quoted 10 lines
drivers/mfd/mt6370.c new file +10
-0+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 )
Leave a comma here.
Quoted 1 line
+};
...
drivers/mfd/mt6370.c line 142
Quoted 7 lines
drivers/mfd/mt6370.c new file +7
-0+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" )
Leave a comma here.
drivers/mfd/mt6370.c line 152
Quoted 10 lines
drivers/mfd/mt6370.c new file +10
-0+}; + +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)
Leave a comma here.
Quoted 1 line
+};
Signature · 2 lines
With Best Regards, Andy Shevchenko
Re: [PATCH v4 09/13] iio: adc: mt6370: Add Mediatek MT6370 support
In reply to ChiaEn WuQuoted 4 lines · ChiaEn Wu
From: ChiaEn Wu <[email protected]>
Add Mediatek MT6370 ADC support.
...
Quoted 1 line
+ This driver can also be built as a module. If so the module
If so,
Quoted 1 line
+ will be called "mt6370-adc.ko".
No ".ko" part.
...
Quoted 1 line
+#define
ADC_CONV_TIME_US35000
Since it's actually MS, drop this and use MS * 1000 whenever it's needed.
Quoted 1 line
+#define
ADC_CONV_TIME_MS(ADC_CONV_TIME_US/ 1000)
...
drivers/iio/adc/mt6370-adc.c line 192
Quoted 5 lines
drivers/iio/adc/mt6370-adc.c new file +5
-0+static int mt6370_adc_read_label (struct iio_dev *iio_dev, +struct iio_chan_spec const *chan,char *label) +{ +return snprintf (label,PAGE_SIZE ,"%s\n" , + mt6370_channel_labels[chan->channel]);
sysfs_emit()
Quoted 1 line
+}
...
drivers/iio/adc/mt6370-adc.c line 228
Quoted 6 lines
drivers/iio/adc/mt6370-adc.c new file +6
-0+static int mt6370_adc_probe (struct platform_device *pdev) +{ +int ret; +struct mt6370_adc_data *priv; +struct regmap *regmap; +struct iio_dev *indio_dev;
Per all your patches, use reversed xmas tree ordering ("longest line first" rule).
Also it may be good to have a temporary variable for struct device pointer.
Quoted 1 line
+}
...
Quoted 1 line
+MODULE_DESCRIPTION("MT6370 ADC Drvier");
Driver. Spell check your patches.
Signature · 2 lines
With Best Regards, Andy Shevchenko
Re: [PATCH v4 10/13] power: supply: mt6370: Add Mediatek MT6370 charger driver
In reply to ChiaEn WuQuoted 1 line · ChiaEn Wu
Add Mediatek MT6370 charger driver.
...
Quoted 1 line
+ This driver can also be built as a module. If so the module
If so,
Quoted 1 line
+ will be called "mt6370-charger.ko".
No ".ko" part.
...
Quoted 1 line
+#define
MT6370_MIVR_IBUS_TH_100_MA100000
mA
...
drivers/power/supply/mt6370-charger.c line 192
Quoted 5 lines
drivers/power/supply/mt6370-charger.c new file +4
-0+if (mt6370_chg_fields[fd].range) { +return linear_range_get_value (mt6370_chg_fields[fd].range, + reg_val, val); + }else {
Redundant 'else'.
Quoted 3 lines
drivers/power/supply/mt6370-charger.c new file +3
-0+ *val = reg_val; +return 0 ; + }
...
Quoted 1 line
+ if (fd !=
F_VMIVR)
Why not positive conditional?
drivers/power/supply/mt6370-charger.c line 215
Quoted 6 lines
drivers/power/supply/mt6370-charger.c new file +6
-0+linear_range_get_selector_within (r, val, &val); + else { + ret =linear_range_get_selector_high (r, val, &val, &f); +if (!ret) + val = r->max_sel; + }
Checkpatch didn't complain about the absence of {} ?
...
drivers/power/supply/mt6370-charger.c line 329
Quoted 2 lines
drivers/power/supply/mt6370-charger.c new file +2
-0+ irq_num =platform_get_irq_byname (pdev, irq_name); +if (irq_num >=0 ) {
if (irq_num < 0)
return;
Quoted 5 lines
drivers/power/supply/mt6370-charger.c new file +5
-0+if (en) +enable_irq (irq_num); +else +disable_irq_nosync (irq_num); + }
...
Quoted 1 line
+ /* Check in otg mode or not */
OTG
...
drivers/power/supply/mt6370-charger.c line 586
Quoted 4 lines
drivers/power/supply/mt6370-charger.c new file +4
-0+static int mt6370_chg_set_online (struct mt6370_priv *priv, +const union power_supply_propval *val) +{ +unsigned int pwr_rdy = !!val->intval;
Seems you are using int as boolean, do you need it specifically for something? Otherwise use boolean here.
Quoted 16 lines
drivers/power/supply/mt6370-charger.c new file +16
-0+ +mutex_lock (&priv->attach_lock); +if (pwr_rdy == !!priv->attach) { +dev_err (priv->dev,"pwr_rdy is same(%d)\n" , pwr_rdy); +mutex_unlock (&priv->attach_lock); +return 0 ; + } + + priv->attach = pwr_rdy; +mutex_unlock (&priv->attach_lock); + +if (!queue_work (priv->wq, &priv->bc12_work)) +dev_err (priv->dev,"bc12 work has already queued\n" ); + +return 0 ; +}
Signature · 2 lines
With Best Regards, Andy Shevchenko
Re: [PATCH v4 12/13] leds: flashlight: mt6370: Add Mediatek MT6370 flashlight support
In reply to ChiaEn WuQuoted 1 line · ChiaEn Wu
Add Mediatek MT6370 flashlight support.
...
Quoted 1 line
+ This driver can also be built as a module. If so the module
If so,
Quoted 1 line
+ will be called "leds-mt6370-flash.ko".
No ".ko" part.
...
drivers/leds/flash/leds-mt6370-flash.c line 64
Quoted 11 lines
drivers/leds/flash/leds-mt6370-flash.c new file +11
-0+#define MT6370_ITORCH_MINUA 25000 +#define MT6370_ITORCH_STEPUA 12500 +#define MT6370_ITORCH_MAXUA 400000 +#define MT6370_ITORCH_DOUBLE_MAXUA 800000 +#define MT6370_ISTRB_MINUA 50000 +#define MT6370_ISTRB_STEPUA 12500 +#define MT6370_ISTRB_MAXUA 1500000 +#define MT6370_ISTRB_DOUBLE_MAXUA 3000000 +#define MT6370_STRBTO_MINUS 64000 +#define MT6370_STRBTO_STEPUS 32000 +#define MT6370_STRBTO_MAXUS 2432000
Make units suffix visible, i.e. _US, _uA, etc.
...
drivers/leds/flash/leds-mt6370-flash.c line 125
Quoted 4 lines
drivers/leds/flash/leds-mt6370-flash.c new file +4
-0+if (curr) + val |=MT6370_TORCHEN_MASK ; + +
One blank line is enough.
...
drivers/leds/flash/leds-mt6370-flash.c line 166
Quoted 3 lines
drivers/leds/flash/leds-mt6370-flash.c new file +3
-0+/* +* Due to the current spike when turning on flash, +* let brightness to be kept by framework.
brightness be
the framework
Quoted 3 lines
drivers/leds/flash/leds-mt6370-flash.c new file +3
-0+* This empty function is used to +* prevent led_classdev_flash register ops check failure. +*/
...
drivers/leds/flash/leds-mt6370-flash.c line 199
Quoted 7 lines
drivers/leds/flash/leds-mt6370-flash.c new file +6
-0+ }else { + ret =regmap_update_bits (priv->regmap, +MT6370_REG_FLEDISTRB (led->led_no), +MT6370_ISTROBE_MASK , val); +if (ret) +return ret;
Dup of the below.
Quoted 2 lines
(quoted diff) +2
-0+ } + return ret;
...
drivers/leds/flash/leds-mt6370-flash.c line 250
Quoted 4 lines
drivers/leds/flash/leds-mt6370-flash.c new file +4
-0+/* +* If the flash need to be on, +* config the flash current ramping up to the setting value +* Else, always recover back to the minimum one
Missed periods.
Quoted 1 line
+ */
...
drivers/leds/flash/leds-mt6370-flash.c line 263
Quoted 8 lines
drivers/leds/flash/leds-mt6370-flash.c new file +8
-0+/* +* For the flash turn on/off, HW ramping up/down time is 5ms/500us +* respectively. +*/ +if (!prev && curr) +usleep_range (5000 ,6000 ); +else if (prev && !curr) +udelay (500 );
Comment doesn't explain why this is suddenly a busy loop operation?
Quoted 24 lines
drivers/leds/flash/leds-mt6370-flash.c new file +24
-0+static int mt6370_led_register (struct device *parent,struct mt6370_led *led, +struct led_init_data *init_data) +{ +struct v4l2_flash_config v4l2_config = {0 }; +int ret; + + ret =devm_led_classdev_flash_register_ext (parent, &led->flash, + init_data); +if (ret) { +dev_err (parent,"Couldn't register flash %d\n" , led->led_no); +return ret; + } + +mt6370_init_v4l2_flash_config (led, &v4l2_config); + led->v4l2_flash =v4l2_flash_init (parent, init_data->fwnode, + &led->flash, &v4l2_flash_ops, + &v4l2_config); +if (IS_ERR (led->v4l2_flash)) { +dev_err (parent,"Failed to register %d v4l2 sd\n" , led->led_no); +return PTR_ERR (led->v4l2_flash); + } + +return 0 ; +}
...
drivers/leds/flash/leds-mt6370-flash.c line 540
Quoted 3 lines
drivers/leds/flash/leds-mt6370-flash.c new file +3
-0+ }else + val =clamp_align (val,MT6370_STRBTO_MINUS ,MT6370_STRBTO_MAXUS , +MT6370_STRBTO_STEPUS );
Missed {}
Review
Quoted 2 lines
(quoted diff) +2
-0+ +
One blank line is enough.
Signature · 2 lines
With Best Regards, Andy Shevchenko
Re: [PATCH v4 13/13] video: backlight: mt6370: Add Mediatek MT6370 support
In reply to ChiaEn WuQuoted 4 lines · ChiaEn Wu
From: ChiaEn Wu <[email protected]>
Add Mediatek MT6370 Backlight support.
...
Quoted 1 line
+ This driver can also be built as a module. If so the module
If so,
Quoted 1 line
+ will be called "mt6370-backlight.ko".
No ".ko" part.
...
Quoted 1 line
+#include <
linux/gpio/driver.h>
Can you elaborate on this?
drivers/video/backlight/mt6370-backlight.c line 17
Quoted 6 lines
drivers/video/backlight/mt6370-backlight.c new file +5
-0+#include <linux/kernel.h> +#include <linux/log2.h> +#include <linux/minmax.h> +#include <linux/module.h> +#include <linux/of.h>
Can you elaborate on this?
drivers/video/backlight/mt6370-backlight.c line 19
Quoted 2 lines
drivers/video/backlight/mt6370-backlight.c new file +2
-0+#include <linux/platform_device.h> +#include <linux/regmap.h>
Missed mod_devicetable.h.
...
drivers/video/backlight/mt6370-backlight.c line 78
Quoted 3 lines
drivers/video/backlight/mt6370-backlight.c new file +3
-0+ brightness_val[0 ] = (brightness -1 ) &MT6370_BL_DIM2_MASK ; + brightness_val[1 ] = (brightness -1 ) + >>fls (MT6370_BL_DIM2_MASK );
Bad indentation. One line?
...
Quoted 1 line
+ if (
priv->enable_gpio)
Dup check.
Quoted 1 line
+
gpiod_set_value(priv->enable_gpio, brightness ? 1 : 0);
...
drivers/video/backlight/mt6370-backlight.c line 130
Quoted 2 lines
drivers/video/backlight/mt6370-backlight.c new file +2
-0+ brightness = brightness_val[1 ] <<fls (MT6370_BL_DIM2_MASK ); + brightness += (brightness_val[0 ] &MT6370_BL_DIM2_MASK );
Too many parentheses.
...
drivers/video/backlight/mt6370-backlight.c line 171
Quoted 7 lines
drivers/video/backlight/mt6370-backlight.c new file +7
-0+/* +* prop_val = 1 --> 1 steps --> 0x00 +* prop_val = 2 ~ 4 --> 4 steps --> 0x01 +* prop_val = 5 ~ 16 --> 16 steps --> 0x10 +* prop_val = 17 ~ 64 --> 64 steps --> 0x11 +*/ + prop_val = (ilog2 (roundup_pow_of_two (prop_val)) +1 ) >>1 ;
Isn't something closer to get_order() or fls()?
...
drivers/video/backlight/mt6370-backlight.c line 218
Quoted 2 lines
drivers/video/backlight/mt6370-backlight.c new file +2
-0+ props->max_brightness =min_t (u32, brightness, +MT6370_BL_MAX_BRIGHTNESS );
One line?
...
Quoted 1 line
+ val = 0;
Do you need this here?
Quoted 1 line
+
prop_val= 0;
Useless.
Quoted 13 lines
drivers/video/backlight/mt6370-backlight.c new file +13
-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 or over than upper bound (%d)\n" , + prop_val); +return -EINVAL ; + }
...
drivers/video/backlight/mt6370-backlight.c line 282
Quoted 8 lines
drivers/video/backlight/mt6370-backlight.c new file +8
-0+static int mt6370_bl_probe (struct platform_device *pdev) +{ +struct mt6370_priv *priv; +struct backlight_properties props = { + .type =BACKLIGHT_RAW , + .scale =BACKLIGHT_SCALE_LINEAR , + }; +int ret;
struct device *dev = &pdev->dev;
will save you a few LoCs.
Signature · 2 lines
With Best Regards, Andy Shevchenko
Re: [PATCH v4 12/13] leds: flashlight: mt6370: Add Mediatek MT6370 flashlight support
In reply to Andy ShevchenkoHi Andy,
Thank you for the valuable comment.
Andy Shevchenko <[email protected]> 於 2022年7月5日 週二 清晨5:06寫道:
Quoted 11 lines · ChiaEn Wu
Quoted 2 lines
Add Mediatek MT6370 flashlight support.
...
Quoted 1 line
+ This driver can also be built as a module. If so the module
If so,
Thank you, I'll fix it in the next version.
Quoted 4 lines
Quoted 1 line
+ will be called "leds-mt6370-flash.ko".
No ".ko" part.
Thank you, I'll fix it in the next version.
Quoted 16 lines
...
drivers/leds/flash/leds-mt6370-flash.c line 64
Quoted 11 lines
drivers/leds/flash/leds-mt6370-flash.c new file +11
-0+#define MT6370_ITORCH_MINUA 25000 +#define MT6370_ITORCH_STEPUA 12500 +#define MT6370_ITORCH_MAXUA 400000 +#define MT6370_ITORCH_DOUBLE_MAXUA 800000 +#define MT6370_ISTRB_MINUA 50000 +#define MT6370_ISTRB_STEPUA 12500 +#define MT6370_ISTRB_MAXUA 1500000 +#define MT6370_ISTRB_DOUBLE_MAXUA 3000000 +#define MT6370_STRBTO_MINUS 64000 +#define MT6370_STRBTO_STEPUS 32000 +#define MT6370_STRBTO_MAXUS 2432000Make units suffix visible, i.e.
_US,_uA, etc.
Thank you, I'll fix it in the next version.
Quoted 9 lines
...
drivers/leds/flash/leds-mt6370-flash.c line 125
Quoted 4 lines
drivers/leds/flash/leds-mt6370-flash.c new file +4
-0+if (curr) + val |=MT6370_TORCHEN_MASK ; + +One blank line is enough.
Thank you, I'll fix it in the next version.
Quoted 9 lines
...
drivers/leds/flash/leds-mt6370-flash.c line 166
Quoted 3 lines
drivers/leds/flash/leds-mt6370-flash.c new file +3
-0+/* +* Due to the current spike when turning on flash, +* let brightness to be kept by framework. brightness be
the framework
Thank you, I'll fix it in the next version.
Quoted 4 lines
drivers/leds/flash/leds-mt6370-flash.c line 169
Quoted 3 lines
drivers/leds/flash/leds-mt6370-flash.c new file +3
-0+* This empty function is used to +* prevent led_classdev_flash register ops check failure. +*/
Thank you, I'll fix it in the next version.
Quoted 7 lines
...
Quoted 4 lines
drivers/leds/flash/leds-mt6370-flash.c new file +4
-0+ }else { + ret =regmap_update_bits (priv->regmap, +MT6370_REG_FLEDISTRB (led->led_no), +MT6370_ISTROBE_MASK , val);
Quoted 5 lines
Review
Quoted 2 lines
(quoted diff) +2
-0+ if (ret) + return ret;Dup of the below.
Thank you, I'll fix it in the next version.
Quoted 12 lines
Quoted 2 lines
(quoted diff) +2
-0+ } + return ret;...
drivers/leds/flash/leds-mt6370-flash.c line 250
Quoted 4 lines
drivers/leds/flash/leds-mt6370-flash.c new file +4
-0+/* +* If the flash need to be on, +* config the flash current ramping up to the setting value +* Else, always recover back to the minimum one Missed periods.
Thank you, I'll fix it in the next version.
Quoted 13 lines
Quoted 1 line
+ */
...
drivers/leds/flash/leds-mt6370-flash.c line 263
Quoted 8 lines
drivers/leds/flash/leds-mt6370-flash.c new file +8
-0+/* +* For the flash turn on/off, HW ramping up/down time is 5ms/500us +* respectively. +*/ +if (!prev && curr) +usleep_range (5000 ,6000 ); +else if (prev && !curr) +udelay (500 );
Quoted 2 lines
Comment doesn't explain why this is suddenly a busy loop operation?
For the flash turn on/off, HW ramping up/down waiting time is 5ms/500us, respectively.
The busy loop is for preventing turn on/off in wait time, which will cause unexpected problems.
If I change the comment to
"For the flash turn on/off, HW ramping up/down waiting time is 5ms/500us, respectively.
Need to wait until HW ramping successfully to prevent the unexpected problem.", will this meet your expectation?
Quoted 28 lines
Quoted 25 lines
drivers/leds/flash/leds-mt6370-flash.c new file +24
-0+static int mt6370_led_register (struct device *parent,struct mt6370_led *led, +struct led_init_data *init_data) +{ +struct v4l2_flash_config v4l2_config = {0 }; +int ret; + + ret =devm_led_classdev_flash_register_ext (parent, &led->flash, + init_data); +if (ret) { +dev_err (parent,"Couldn't register flash %d\n" , led->led_no); +return ret; + } + +mt6370_init_v4l2_flash_config (led, &v4l2_config); + led->v4l2_flash =v4l2_flash_init (parent, init_data->fwnode, + &led->flash, &v4l2_flash_ops, + &v4l2_config); +if (IS_ERR (led->v4l2_flash)) { +dev_err (parent,"Failed to register %d v4l2 sd\n" , led->led_no); +return PTR_ERR (led->v4l2_flash); + } + +return 0 ; +}...
Quoted 6 lines
drivers/leds/flash/leds-mt6370-flash.c line 540
Quoted 3 lines
drivers/leds/flash/leds-mt6370-flash.c new file +3
-0+ }else + val =clamp_align (val,MT6370_STRBTO_MINUS ,MT6370_STRBTO_MAXUS , +MT6370_STRBTO_STEPUS );Missed {}
Thank you, I'll fix it in the next version.
Quoted 5 lines
Review
Quoted 2 lines
(quoted diff) +2
-0+ +One blank line is enough.
Thank you, I'll fix it in the next version.
Quoted 1 line
--
Yours Sincerely,
Alice
Re: [PATCH v4 13/13] video: backlight: mt6370: Add Mediatek MT6370 support
In reply to Andy ShevchenkoHi Andy,
Thanks for your reply! I have some questions want to ask you below.
Andy Shevchenko <[email protected]> 於 2022年7月5日 週二 清晨5:14寫道:
Quoted 37 lines · ChiaEn Wu
Quoted 4 lines
From: ChiaEn Wu <[email protected]>
Add Mediatek MT6370 Backlight support.
...
Quoted 1 line
+ This driver can also be built as a module. If so the module
If so,
Quoted 1 line
+ will be called "mt6370-backlight.ko".
No ".ko" part.
...
Quoted 1 line
+#include <
linux/gpio/driver.h>Can you elaborate on this?
drivers/video/backlight/mt6370-backlight.c line 17
Quoted 6 lines
drivers/video/backlight/mt6370-backlight.c new file +5
-0+#include <linux/kernel.h> +#include <linux/log2.h> +#include <linux/minmax.h> +#include <linux/module.h> +#include <linux/of.h> Can you elaborate on this?
drivers/video/backlight/mt6370-backlight.c line 19
Quoted 2 lines
drivers/video/backlight/mt6370-backlight.c new file +2
-0+#include <linux/platform_device.h> +#include <linux/regmap.h> Missed
mod_devicetable.h.
Quoted 7 lines
...
drivers/video/backlight/mt6370-backlight.c line 78
Quoted 3 lines
drivers/video/backlight/mt6370-backlight.c new file +3
-0+ brightness_val[0 ] = (brightness -1 ) &MT6370_BL_DIM2_MASK ; + brightness_val[1 ] = (brightness -1 ) + >>fls (MT6370_BL_DIM2_MASK );Bad indentation. One line?
Well... if indent to one line, it will be over 80 characters(or called columns?) From my understanding, it is not allowed, right??
Quoted 26 lines
...
Quoted 1 line
+ if (
priv->enable_gpio)Dup check.
Quoted 1 line
+
gpiod_set_value(priv->enable_gpio, brightness ? 1 : 0);...
drivers/video/backlight/mt6370-backlight.c line 130
Quoted 2 lines
drivers/video/backlight/mt6370-backlight.c new file +2
-0+ brightness = brightness_val[1 ] <<fls (MT6370_BL_DIM2_MASK ); + brightness += (brightness_val[0 ] &MT6370_BL_DIM2_MASK );Too many parentheses.
...
drivers/video/backlight/mt6370-backlight.c line 171
Quoted 7 lines
drivers/video/backlight/mt6370-backlight.c new file +7
-0+/* +* prop_val = 1 --> 1 steps --> 0x00 +* prop_val = 2 ~ 4 --> 4 steps --> 0x01 +* prop_val = 5 ~ 16 --> 16 steps --> 0x10 +* prop_val = 17 ~ 64 --> 64 steps --> 0x11 +*/ + prop_val = (ilog2 (roundup_pow_of_two (prop_val)) +1 ) >>1 ;
Quoted 1 line
Isn't something closer to
get_order()orfls()?
I will revise it to "(get_order(prop_va * PAGE_SIZE) + 1) / 2" and this change is meet your expectations??
Quoted 7 lines
...
drivers/video/backlight/mt6370-backlight.c line 218
Quoted 2 lines
drivers/video/backlight/mt6370-backlight.c new file +2
-0+ props->max_brightness =min_t (u32, brightness, +MT6370_BL_MAX_BRIGHTNESS );One line?
Ditto, it will be over 80 characters...
Quoted 38 lines
...
Quoted 1 line
+ val = 0;
Do you need this here?
Quoted 1 line
+
prop_val= 0;Useless.
Quoted 13 lines
drivers/video/backlight/mt6370-backlight.c new file +13
-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 or over than upper bound (%d)\n" , + prop_val); +return -EINVAL ; + }...
drivers/video/backlight/mt6370-backlight.c line 282
Quoted 8 lines
drivers/video/backlight/mt6370-backlight.c new file +8
-0+static int mt6370_bl_probe (struct platform_device *pdev) +{ +struct mt6370_priv *priv; +struct backlight_properties props = { + .type =BACKLIGHT_RAW , + .scale =BACKLIGHT_SCALE_LINEAR , + }; +int ret;struct device *dev = &pdev->dev;
Quoted 5 lines
will save you a few LoCs.
--
With Best Regards,
Andy Shevchenko
Best regards,
ChiaEn Wu
Re: [PATCH v4 13/13] video: backlight: mt6370: Add Mediatek MT6370 support
Quoted 2 lines · ChiaEn Wu
Andy Shevchenko <[email protected]> 於 2022年7月5日 週二 清晨5:14寫道:
Quoted 1 line · ChiaEn Wu
Please, remove unneeded context when replying!
...
Quoted 8 lines
Quoted 5 lines
drivers/video/backlight/mt6370-backlight.c line 78
Quoted 3 lines
drivers/video/backlight/mt6370-backlight.c new file +3
-0+ brightness_val[0 ] = (brightness -1 ) &MT6370_BL_DIM2_MASK ; + brightness_val[1 ] = (brightness -1 ) + >>fls (MT6370_BL_DIM2_MASK );Bad indentation. One line?
Well... if indent to one line, it will be over 80 characters(or called columns?) From my understanding, it is not allowed, right??
It's allowed to some extent.Use your common sense. Here it's obviously broken indentation.
...
Quoted 6 lines
Quoted 3 lines
Quoted 1 line
+
prop_val= (ilog2(roundup_pow_of_two(prop_val)) + 1) >> 1;Isn't something closer to
get_order()orfls()?I will revise it to "(
get_order(prop_va * PAGE_SIZE)+ 1) / 2" and this change is meet your expectations??
Nope. Try again. What about fls()?
...
Quoted 6 lines
Quoted 4 lines
drivers/video/backlight/mt6370-backlight.c line 218
Quoted 2 lines
drivers/video/backlight/mt6370-backlight.c new file +2
-0+ props->max_brightness =min_t (u32, brightness, +MT6370_BL_MAX_BRIGHTNESS );One line?
Ditto, it will be over 80 characters...
As per above.
Signature · 2 lines
With Best Regards, Andy Shevchenko
Re: [PATCH v4 13/13] video: backlight: mt6370: Add Mediatek MT6370 support
Quoted 12 lines · Andy Shevchenko
Quoted 2 lines · ChiaEn Wu
Andy Shevchenko <[email protected]> 於 2022年7月5日 週二 清晨5:14寫道:
Quoted 1 line · ChiaEn Wu
Please, remove unneeded context when replying!
...
Quoted 4 lines
Quoted 4 lines
Quoted 3 lines
drivers/video/backlight/mt6370-backlight.c new file +3
-0+ brightness_val[0 ] = (brightness -1 ) &MT6370_BL_DIM2_MASK ; + brightness_val[1 ] = (brightness -1 ) + >>fls (MT6370_BL_DIM2_MASK );
Quoted 7 lines
Quoted 4 lines
Quoted 1 line
Bad indentation. One line?
Well... if indent to one line, it will be over 80 characters(or called columns?) From my understanding, it is not allowed, right??
It's allowed to some extent.Use your common sense. Here it's obviously broken indentation.
Refrain from going crazy though - hard limit is 100 chars.
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 v4 13/13] video: backlight: mt6370: Add Mediatek MT6370 support
In reply to Andy ShevchenkoAndy Shevchenko <[email protected]> 於 2022年7月13日 週三 晚上8:07寫道:
Quoted 23 lines · ChiaEn Wu
Quoted 2 lines
Andy Shevchenko <[email protected]> 於 2022年7月5日 週二 清晨5:14寫道:
Quoted 1 line · ChiaEn Wu
Please, remove unneeded context when replying!
...
Quoted 8 lines
Quoted 5 lines
drivers/video/backlight/mt6370-backlight.c line 78
Quoted 3 lines
drivers/video/backlight/mt6370-backlight.c new file +3
-0+ brightness_val[0 ] = (brightness -1 ) &MT6370_BL_DIM2_MASK ; + brightness_val[1 ] = (brightness -1 ) + >>fls (MT6370_BL_DIM2_MASK );Bad indentation. One line?
Well... if indent to one line, it will be over 80 characters(or called columns?) From my understanding, it is not allowed, right??
It's allowed to some extent.Use your common sense. Here it's obviously broken indentation.
...
Quoted 8 lines
Quoted 6 lines
Quoted 3 lines
Quoted 1 line
+
prop_val= (ilog2(roundup_pow_of_two(prop_val)) + 1) >> 1;Isn't something closer to
get_order()orfls()?I will revise it to "(
get_order(prop_va * PAGE_SIZE)+ 1) / 2" and this change is meet your expectations??Nope. Try again. What about
fls()?
I have tried two methods so far, as follows
-------------------------------------------------------------
/*
* prop_val = 1 --> 1 steps --> b'00 * prop_val = 2 ~ 4 --> 4 steps --> b'01 * prop_val = 5 ~ 16 --> 16 steps --> b'10
* prop_val = 17 ~ 64 --> 64 steps --> b'11
*/
// 1. use fls() and ffs() combinationprop_val = ffs(prop_val) == fls(prop_val) ? fls(prop_val) >> 1 :
(fls(prop_val) + 1) >> 1;
// 2. use one line for-loop, but without fls()
for (i = --prop_val, prop_val = 0; i >> 2 * prop_val != 0; prop_val++);
-------------------------------------------------------------
Do these changes meet your expectations??
Quoted 15 lines
...
Quoted 6 lines
Quoted 4 lines
drivers/video/backlight/mt6370-backlight.c line 218
Quoted 2 lines
drivers/video/backlight/mt6370-backlight.c new file +2
-0+ props->max_brightness =min_t (u32, brightness, +MT6370_BL_MAX_BRIGHTNESS );One line?
Ditto, it will be over 80 characters...
As per above.
--
With Best Regards,
Andy Shevchenko
Re: [PATCH v4 13/13] video: backlight: mt6370: Add Mediatek MT6370 support
Quoted 4 lines · ChiaEn Wu
Andy Shevchenko <[email protected]> 於 2022年7月13日 週三 晚上8:07寫道:
Quoted 3 lines · ChiaEn Wu
Quoted 2 lines
Andy Shevchenko <[email protected]> 於 2022年7月5日 週二 清晨5:14寫道:
Quoted 1 line · ChiaEn Wu
Please, once again, remove unneeded context when replying! ^^^^^^^
...
Quoted 9 lines
Quoted 8 lines
Quoted 6 lines
Quoted 3 lines
Quoted 1 line
+
prop_val= (ilog2(roundup_pow_of_two(prop_val)) + 1) >> 1;Isn't something closer to
get_order()orfls()?I will revise it to "(
get_order(prop_va * PAGE_SIZE)+ 1) / 2" and this change is meet your expectations??Nope. Try again. What about
fls()?
Quoted 8 lines
I have tried two methods so far, as follows
-------------------------------------------------------------
/** prop_val = 1 --> 1 steps --> b'00 * prop_val = 2 ~ 4 --> 4 steps --> b'01 * prop_val = 5 ~ 16 --> 16 steps --> b'10*
prop_val= 17 ~ 64 --> 64 steps --> b'11
*/
So, for 1 --> 0, for 2 --> 1, for 5 --> 2, and for 17 --> 3. Now, consider x - 1:
0 ( 0 ) --> 0 1 (2^0) --> 1 4 (2^2) --> 2
16 (2^4) --> 3
64 (2^6) --> ? (but let's consider that the range has been checked already)
Since we take the lower limit, it means ffs():
y = (ffs(x - 1) + 1) / 2;
Does it work for you?
Quoted 8 lines
// 1. use
fls()andffs()combinationprop_val=ffs(prop_val)==fls(prop_val)?fls(prop_val)>> 1 :
(fls(prop_val)+ 1) >> 1;// 2. use one line for-loop, but without
fls()
for (i = --prop_val,prop_val= 0; i >> 2 *prop_val!= 0; prop_val++);
-------------------------------------------------------------
Do these changes meet your expectations??
No, this is ugly. Yes, I understand that a bit arithmetics is hard...
Signature · 2 lines
With Best Regards, Andy Shevchenko
Re: [PATCH v4 13/13] video: backlight: mt6370: Add Mediatek MT6370 support
Quoted 3 lines · Andy Shevchenko
Quoted 1 line · ChiaEn Wu
Andy Shevchenko <[email protected]> 於 2022年7月13日 週三 晚上8:07寫道:
...
Quoted 14 lines
Quoted 8 lines
I have tried two methods so far, as follows
-------------------------------------------------------------
/** prop_val = 1 --> 1 steps --> b'00 * prop_val = 2 ~ 4 --> 4 steps --> b'01 * prop_val = 5 ~ 16 --> 16 steps --> b'10*
prop_val= 17 ~ 64 --> 64 steps --> b'11
*/So, for 1 --> 0, for 2 --> 1, for 5 --> 2, and for 17 --> 3. Now, consider x - 1:
0 ( 0 ) --> 0 1 (2^0) --> 1 4 (2^2) --> 2
Quoted 8 lines
16 (2^4) --> 3
64 (2^6) --> ? (but let's consider that the range has been checked already)Since we take the lower limit, it means
ffs():y = (ffs(x - 1) + 1) / 2;Does it work for you?
It wouldn't, because we need to use fls() against it actually.
So,
0..1 (-1..0) --> 0 2..4 (1..3) --> 1 5..16 (4..15) --> 2
17..64 (16..63) --> 3
y = x ? ((fls(x - 1) + 1) / 2 : 0;
Signature · 2 lines
With Best Regards, Andy Shevchenko
Re: [PATCH v4 13/13] video: backlight: mt6370: Add Mediatek MT6370 support
In reply to Andy ShevchenkoQuoted 15 lines · Andy Shevchenko
Quoted 8 lines · ChiaEn Wu
I have tried two methods so far, as follows
-------------------------------------------------------------
/** prop_val = 1 --> 1 steps --> b'00 * prop_val = 2 ~ 4 --> 4 steps --> b'01 * prop_val = 5 ~ 16 --> 16 steps --> b'10*
prop_val= 17 ~ 64 --> 64 steps --> b'11
*/So, for 1 --> 0, for 2 --> 1, for 5 --> 2, and for 17 --> 3. Now, consider x - 1:
0 ( 0 ) --> 0 1 (2^0) --> 1 4 (2^2) --> 2
Quoted 8 lines
16 (2^4) --> 3
64 (2^6) --> ? (but let's consider that the range has been checked already)Since we take the lower limit, it means
ffs():y = (ffs(x - 1) + 1) / 2;Does it work for you?
To be honest, for this tiny table, writing code that *doesn't* require intricate deciphering together with a huge comment saying what is does would probably be better:
prop_val = (prop_val <= 1 ? 0 : prop_val <= 4 ? 1 : prop_val <= 16 ? 2 : 3);
This would be "obviously correct" and require no comment.
Daniel.
Re: [PATCH v4 13/13] video: backlight: mt6370: Add Mediatek MT6370 support
Quoted 30 lines · Daniel Thompson
Quoted 15 lines · Andy Shevchenko
Quoted 8 lines · ChiaEn Wu
I have tried two methods so far, as follows
-------------------------------------------------------------
/** prop_val = 1 --> 1 steps --> b'00 * prop_val = 2 ~ 4 --> 4 steps --> b'01 * prop_val = 5 ~ 16 --> 16 steps --> b'10*
prop_val= 17 ~ 64 --> 64 steps --> b'11
*/So, for 1 --> 0, for 2 --> 1, for 5 --> 2, and for 17 --> 3. Now, consider x - 1:
0 ( 0 ) --> 0 1 (2^0) --> 1 4 (2^2) --> 2Quoted 8 lines
16 (2^4) --> 3
64 (2^6) --> ? (but let's consider that the range has been checked already)Since we take the lower limit, it means
ffs():y = (ffs(x - 1) + 1) / 2;Does it work for you?
To be honest, for this tiny table, writing code that *doesn't* require intricate deciphering together with a huge comment saying what is does would probably be better:
Quoted 6 lines
prop_val = (prop_val <= 1 ? 0 : prop_val <= 4 ? 1 : prop_val <= 16 ? 2 : 3);This would be "obviously correct" and require no comment.
Agree. It will also limit checking (and whatever needed for that).
Signature · 2 lines
With Best Regards, Andy Shevchenko
Re: [PATCH v4 13/13] video: backlight: mt6370: Add Mediatek MT6370 support
In reply to Andy ShevchenkoQuoted 4 lines · Andy Shevchenko
Quoted 2 lines · Andy Shevchenko
Quoted 1 line · ChiaEn Wu
Andy Shevchenko <[email protected]> 於 2022年7月13日 週三 晚上8:07寫道:
...
Quoted 21 lines
Quoted 10 lines
Quoted 4 lines
* prop_val = 1 --> 1 steps --> b'00 * prop_val = 2 ~ 4 --> 4 steps --> b'01 * prop_val = 5 ~ 16 --> 16 steps --> b'10*
prop_val= 17 ~ 64 --> 64 steps --> b'11So, for 1 --> 0, for 2 --> 1, for 5 --> 2, and for 17 --> 3. Now, consider x - 1:
0 ( 0 ) --> 0 1 (2^0) --> 1 4 (2^2) --> 2Quoted 8 lines
16 (2^4) --> 3
64 (2^6) --> ? (but let's consider that the range has been checked already)Since we take the lower limit, it means
ffs():y = (ffs(x - 1) + 1) / 2;Does it work for you?
It wouldn't, because we need to use
fls()against it actually.
Quoted 7 lines
So,
0..1 (-1..0) --> 0 2..4 (1..3) --> 1 5..16 (4..15) --> 217..64 (16..63) --> 3
y = x ? ((fls(x - 1) + 1) / 2 : 0;
Okay, I nailed it down, but Daniel is right, it's simpler to have just conditionals.
y = x >=2 ? __fls(x - 1) / 2 + 1 : 0;
--
With Best Regards,
Andy Shevchenko