power: supply: mt6360_charger: add MT6360 charger support
Subsystems (5)
v6 cover power: supply: mt6360_charger: add MT6360 charger support
This patch series add MT6360 Charger support contains driver and binding document
Gene Chen (3)
lib: add linear range get selector within
dt-bindings: power: Add bindings document for Charger support on MT6360 PMIC
power: supply: mt6360_charger: add MT6360 charger support
Documentation/devicetree/bindings/power/supply/mt6360_charger.yaml | 48 drivers/power/supply/Kconfig | 11 drivers/power/supply/Makefile | 1 drivers/power/supply/mt6360_charger.c | 867 ++++++++++ include/linux/linear_range.h | 2 lib/linear_ranges.c | 31 6 files changed, 960 insertions(+)
changelogs between v1 & v2
- Add binding property with unit and custom name prefix
- Remove extcon device, redundant brackets and interrupts
- Fix power supply prop "charger type"
changelogs between v2 & v3
- Add register selector to value mapping
changelogs between v3 & v4
- move pdata vinovp to mt6360_chg_info
- remove unuse sysfs attribute
- refactor debug log and warning
- add power supply prop input voltage limit
changelogs between v4 & v5
- add linear range selector mapping
- use linear range to map charger setting
changelogs between v5 & v6
- use REGULATOR_LINEAR_RANGE
- use devm_work_autocancel
- fix Kconfig description
PATCH RESEND v6 1/3 lib: add linear range get selector within
From: Gene Chen <[email protected]>
Add linear range get selector within for choose closest selector between minimum and maximum selector.
--- include/linux/linear_range.h | 2 ++ lib/linear_ranges.c | 31 +++++++++++++++++++++++++++++++ 2 files changed, 33 insertions(+)
include/linux/linear_range.h +2 -0
@@ -41,6 +41,8 @@ int linear_range_get_selector_low(const struct linear_range *r,int linear_range_get_selector_high (const struct linear_range *r,unsigned int val,unsigned int *selector,bool *found); +void linear_range_get_selector_within (const struct linear_range *r, +unsigned int val,unsigned int *selector);int linear_range_get_selector_low_array (const struct linear_range *r,int ranges,unsigned int val,unsigned int *selector,bool *found);
lib/linear_ranges.c +31 -0
@@ -241,5 +241,36 @@ int linear_range_get_selector_high(const struct linear_range *r, }EXPORT_SYMBOL_GPL (linear_range_get_selector_high); +/** +* linear_range_get_selector_within - return linear range selector for value +* @r: pointer to linear range where selector is looked from +* @val: value for which the selector is searched +* @selector: address where found selector value is updated +* +* Return selector for which range value is closest match for given +* input value. Value is matching if it is equal or lower than given +* value. But return maximum selector if given value is higher than +* maximum value. +*/ +void linear_range_get_selector_within (const struct linear_range *r, +unsigned int val,unsigned int *selector) +{ +if (r->min > val) { + *selector = r->min_sel; +return ; + } + +if (linear_range_get_max_value (r) < val) { + *selector = r->max_sel; +return ; + } + +if (r->step ==0 ) + *selector = r->min_sel; +else + *selector = (val - r->min) / r->step + r->min_sel; +} +EXPORT_SYMBOL_GPL (linear_range_get_selector_within); +MODULE_DESCRIPTION ("linear-ranges helper" );MODULE_LICENSE ("GPL" );
Signature · 1 line
2.25.1
PATCH RESEND v6 2/3 dt-bindings: power: Add bindings document for Charger support on MT6360 PMIC
In reply to Gene ChenFrom: Gene Chen <[email protected]>
Add bindings document for Charger support on MT6360 PMIC
--- .../bindings/power/supply/mt6360_charger.yaml | 48 +++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 Documentation/devicetree/bindings/power/supply/mt6360_charger.yaml
Documentation/devicetree/bindings/power/supply/mt6360_charger.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/power/supply/mt6360_charger.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Battery charger driver for MT6360 PMIC from MediaTek Integrated. + +maintainers: + - Gene Chen <[email protected]> + +description: | + This module is part of the MT6360 MFD device. + Provides Battery Charger, Boost for OTG devices and BC1.2 detection. + +properties: + compatible: + const: mediatek,mt6360-chg + + richtek,vinovp-microvolt: + description: Maximum CHGIN regulation voltage in uV. + enum: [ 5500000, 6500000, 11000000, 14500000 ] + + + usb-otg-vbus-regulator: + type: object + description: OTG boost regulator. + $ref: /schemas/regulator/regulator.yaml# + +required: + - compatible + +additionalProperties: false + +examples: + - | + mt6360_charger: charger { + compatible = "mediatek,mt6360-chg"; + richtek,vinovp-microvolt = <14500000>; + + otg_vbus_regulator: usb-otg-vbus-regulator { + regulator-compatible = "usb-otg-vbus"; + regulator-name = "usb-otg-vbus"; + regulator-min-microvolt = <4425000>; + regulator-max-microvolt = <5825000>; + }; + }; +...
Signature · 1 line
2.25.1
PATCH RESEND v6 3/3 power: supply: mt6360_charger: add MT6360 charger support
In reply to Gene ChenFrom: Gene Chen <[email protected]>
Add basic support for the battery charger for MT6360 PMIC
--- drivers/power/supply/Kconfig | 11 + drivers/power/supply/Makefile | 1 + drivers/power/supply/mt6360_charger.c | 867 ++++++++++++++++++++++++++ 3 files changed, 879 insertions(+) create mode 100644 drivers/power/supply/mt6360_charger.c
drivers/power/supply/Kconfig +11 -0
@@ -577,6 +577,17 @@ config CHARGER_MP2629 Battery charger. This driver provides Battery charger power management functions on the systems. +config CHARGER_MT6360 + tristate "Mediatek MT6360 Charger Driver" + depends on MFD_MT6360 + depends on REGULATOR + select LINEAR_RANGES + help + Say Y here to enable MT6360 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
@@ -78,6 +78,7 @@ obj-$(CONFIG_CHARGER_MAX77693) += max77693_charger.o obj-$(CONFIG_CHARGER_MAX8997) += max8997_charger.o obj-$(CONFIG_CHARGER_MAX8998) += max8998_charger.o obj-$(CONFIG_CHARGER_MP2629) += mp2629_charger.o +obj-$(CONFIG_CHARGER_MT6360) += mt6360_charger.o obj-$(CONFIG_CHARGER_QCOM_SMBB) += qcom_smbb.o obj-$(CONFIG_CHARGER_BQ2415X) += bq2415x_charger.o obj-$(CONFIG_CHARGER_BQ24190) += bq24190_charger.o
drivers/power/supply/mt6360_charger.c new file +867 -0
867 lines not on this page · raw message
Signature · 1 line
2.25.1
Hi,
Quoted 2 lines · Gene Chen
This patch series add MT6360 Charger support contains driver and binding document
Thanks, queued.
-- Sebastian
Quoted 37 lines
Gene Chen (3)
lib: add linear range get selector within
dt-bindings: power: Add bindings document for Charger support on MT6360 PMIC
power: supply:mt6360_charger: add MT6360 charger supportDocumentation/devicetree/bindings/power/supply/mt6360_charger.yaml | 48 drivers/power/supply/Kconfig | 11 drivers/power/supply/Makefile | 1 drivers/power/supply/mt6360_charger.c | 867 ++++++++++ include/linux/linear_range.h | 2 lib/linear_ranges.c | 31 6 files changed, 960 insertions(+)changelogs between v1 & v2
- Add binding property with unit and custom name prefix
- Remove extcon device, redundant brackets and interrupts
- Fix power supply prop "charger type"changelogs between v2 & v3
- Add register selector to value mappingchangelogs between v3 & v4
- move pdata vinovp tomt6360_chg_info
- remove unuse sysfs attribute
- refactor debug log and warning
- add power supply prop input voltage limitchangelogs between v4 & v5
- add linear range selector mapping
- use linear range to map charger settingchangelogs between v5 & v6
- useREGULATOR_LINEAR_RANGE
- usedevm_work_autocancel
- fixKconfigdescription
Mark Brown
maintainerQuoted 5 lines · Sebastian Reichel
Quoted 2 lines · Gene Chen
This patch series add MT6360 Charger support contains driver and binding document
Thanks, queued.
We're still waiting for review from Matti on the linear ranges bit - normally that goes through the regulator tree, do you have a tag to pull in case of merge conflicts?
Hi Mark,
Quoted 10 lines · Mark Brown
Quoted 5 lines · Sebastian Reichel
Quoted 2 lines · Gene Chen
This patch series add MT6360 Charger support contains driver and binding document
Thanks, queued.
We're still waiting for review from Matti on the linear ranges bit - normally that goes through the regulator tree, do you have a tag to pull in case of merge conflicts?
He actually already provided his Rb in v5, Gene did not carry it over properly (I added it) and the patch looks simple enough, that Linus will know what to do in case of a conflict. But if you insist I can unroll my tree and create a topic branch for this.
-- Sebastian
Mark Brown
maintainerQuoted 10 lines · Sebastian Reichel
Quoted 3 lines · Mark Brown
We're still waiting for review from Matti on the linear ranges bit - normally that goes through the regulator tree, do you have a tag to pull in case of merge conflicts?
He actually already provided his Rb in v5, Gene did not carry it over properly (I added it) and the patch looks simple enough, that Linus will know what to do in case of a conflict. But if you insist I can unroll my tree and create a topic branch for this.
It would be better, the issues I'm worrying about are more general refactorings or whatever that create actual dependencies rather than just trivial add/add type issues - it can make doing some kinds of work really painful if things go via a different tree.
Hi,
Quoted 12 lines · Mark Brown
Quoted 10 lines · Sebastian Reichel
Quoted 3 lines · Mark Brown
We're still waiting for review from Matti on the linear ranges bit - normally that goes through the regulator tree, do you have a tag to pull in case of merge conflicts?
He actually already provided his Rb in v5, Gene did not carry it over properly (I added it) and the patch looks simple enough, that Linus will know what to do in case of a conflict. But if you insist I can unroll my tree and create a topic branch for this.
Quoted 4 lines
It would be better, the issues I'm worrying about are more general refactorings or whatever that create actual dependencies rather than just trivial add/add type issues - it can make doing some kinds of work really painful if things go via a different tree.
There you go:
-- Sebastian
The following changes since commit e73f0f0ee7541171d89f2e2491130c7771ba58d3:
Linux 5.14-rc1 (2021-07-11 15:07:40 -0700)
are available in the Git repository at:
ssh://[email protected]/pub/scm/linux/kernel/git/sre/linux-power-supply.git tags/ib-mt6360-for-5.15-signed
for you to fetch changes up to 0402e8ebb8b869e375e8af7243044df21b5ff378:
power: supply: mt6360_charger: add MT6360 charger support (2021-08-13 18:37:49 +0200)
----------------------------------------------------------------
Immutable branch between regulator and power-supply for for 5.15
This immutable branch introduces the MT6360 charger driver, which requires a new linear range helper.
----------------------------------------------------------------
Gene Chen (3):
lib: add linear range get selector within
dt-bindings: power: Add bindings document for Charger support on MT6360 PMIC
power: supply: mt6360_charger: add MT6360 charger support
.../bindings/power/supply/mt6360_charger.yaml | 48 ++ drivers/power/supply/Kconfig | 11 + drivers/power/supply/Makefile | 1 + drivers/power/supply/mt6360_charger.c | 867 +++++++++++++++++++++ include/linux/linear_range.h | 2 + lib/linear_ranges.c | 31 + 6 files changed, 960 insertions(+) create mode 100644 Documentation/devicetree/bindings/power/supply/mt6360_charger.yaml create mode 100644 drivers/power/supply/mt6360_charger.c
_______________________________________________
Linux-mediatek mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-mediatek
Mark Brown
maintainerQuoted 8 lines · Sebastian Reichel
Quoted 4 lines · Mark Brown
It would be better, the issues I'm worrying about are more general refactorings or whatever that create actual dependencies rather than just trivial add/add type issues - it can make doing some kinds of work really painful if things go via a different tree.
There you go:
Thanks!
Quoted 12 lines · Sebastian Reichel
Hi,
Quoted 9 lines · Mark Brown
Quoted 8 lines · Sebastian Reichel
Quoted 5 lines · Mark Brown
We're still waiting for review from Matti on the linear ranges bit -
normally that goes through the regulator tree, do you have a tag to pull
in case of merge conflicts?He actually already provided his Rb in v5, Gene did not carry it over properly (I added it)
Thanks guys! I do _really_ appreciate you taking care of merging the changes :)
Best Regards
--Matti