* [PATCH v6 00/10 RESEND] Add RT5033 charger device driver
[not found] <cover.1684182964.git.jahau.ref@rocketmail.com>
@ 2023-05-15 20:57 ` Jakob Hauser
2023-05-15 20:57 ` [PATCH v6 01/10 RESEND] mfd: rt5033: Drop rt5033-battery sub-device Jakob Hauser
` (12 more replies)
0 siblings, 13 replies; 27+ messages in thread
From: Jakob Hauser @ 2023-05-15 20:57 UTC (permalink / raw)
To: Sebastian Reichel, Lee Jones, Liam Girdwood, Mark Brown,
Rob Herring, Krzysztof Kozlowski
Cc: Beomho Seo, Chanwoo Choi, Stephan Gerhold, Raymond Hackley,
Pavel Machek, Axel Lin, ChiYuan Huang, Linus Walleij,
Henrik Grimler, Christophe Jaillet, linux-pm, devicetree,
linux-kernel, phone-devel, ~postmarketos/upstreaming,
Jakob Hauser
This patchset adds the charger driver "rt5033-charger". It is part of the
multifunction device rt5033. The patchset is based on an older version by
Beomho Seo of March 2015. For more information on the history and setup of
the patchset see the cover sheet of version v1, there is a link further down
below the changelog.
RESEND: Sorry for spamming. The first try of sending v6 got interrupted and
was split into two threads on the lore list. Therefore sending it again.
Changes in v6:
- Patch 5: In function rt5033_charger_probe() after
calling rt5033_charger_dt_init() replaced the return value from "-ENODEV"
to "PTR_ERR(charger->chg)", as suggested by Christophe.
- Patch 9: Changed the patch from adding "power-supplies: true" to replacing
"additionalProperties: false" by "unevaluatedProperties: false", as
suggested by Krzysztof.
v1: https://lore.kernel.org/linux-pm/cover.1677620677.git.jahau@rocketmail.com/T/#t
v2: https://lore.kernel.org/linux-pm/cover.1681646904.git.jahau@rocketmail.com/T/#t
v3: https://lore.kernel.org/linux-pm/cover.1682636929.git.jahau@rocketmail.com/T/#t
v4: https://lore.kernel.org/linux-pm/20230506155435.3005-1-jahau@rocketmail.com/T/#t
v5: https://lore.kernel.org/linux-pm/20230514123130.41172-1-jahau@rocketmail.com/T/#t
The result of the patchset v6 can be seen at:
https://github.com/Jakko3/linux/blob/rt5033-charger_v6/drivers/power/supply/rt5033_charger.c
Jakob Hauser (9):
mfd: rt5033: Fix chip revision readout
mfd: rt5033: Fix STAT_MASK, HZ_MASK and AICR defines
mfd: rt5033: Apply preparatory changes before adding rt5033-charger
driver
power: supply: rt5033_charger: Add RT5033 charger device driver
power: supply: rt5033_charger: Add cable detection and USB OTG supply
power: supply: rt5033_battery: Move struct rt5033_battery to battery
driver
power: supply: rt5033_battery: Adopt status property from charger
dt-bindings: power: supply: rt5033-battery: Apply
unevaluatedProperties
dt-bindings: Add rt5033 mfd, regulator and charger
Stephan Gerhold (1):
mfd: rt5033: Drop rt5033-battery sub-device
.../bindings/mfd/richtek,rt5033.yaml | 138 ++++
.../power/supply/richtek,rt5033-battery.yaml | 2 +-
.../power/supply/richtek,rt5033-charger.yaml | 65 ++
drivers/mfd/rt5033.c | 8 +-
drivers/power/supply/Kconfig | 8 +
drivers/power/supply/Makefile | 1 +
drivers/power/supply/rt5033_battery.c | 38 +-
drivers/power/supply/rt5033_charger.c | 744 ++++++++++++++++++
include/linux/mfd/rt5033-private.h | 64 +-
include/linux/mfd/rt5033.h | 24 -
10 files changed, 1034 insertions(+), 58 deletions(-)
create mode 100644 Documentation/devicetree/bindings/mfd/richtek,rt5033.yaml
create mode 100644 Documentation/devicetree/bindings/power/supply/richtek,rt5033-charger.yaml
create mode 100644 drivers/power/supply/rt5033_charger.c
--
2.39.2
^ permalink raw reply [flat|nested] 27+ messages in thread
* [PATCH v6 01/10 RESEND] mfd: rt5033: Drop rt5033-battery sub-device
2023-05-15 20:57 ` [PATCH v6 00/10 RESEND] Add RT5033 charger device driver Jakob Hauser
@ 2023-05-15 20:57 ` Jakob Hauser
2023-05-15 20:57 ` [PATCH v6 02/10 RESEND] mfd: rt5033: Fix chip revision readout Jakob Hauser
` (11 subsequent siblings)
12 siblings, 0 replies; 27+ messages in thread
From: Jakob Hauser @ 2023-05-15 20:57 UTC (permalink / raw)
To: Sebastian Reichel, Lee Jones, Liam Girdwood, Mark Brown,
Rob Herring, Krzysztof Kozlowski
Cc: Beomho Seo, Chanwoo Choi, Stephan Gerhold, Raymond Hackley,
Pavel Machek, Axel Lin, ChiYuan Huang, Linus Walleij,
Henrik Grimler, Christophe Jaillet, linux-pm, devicetree,
linux-kernel, phone-devel, ~postmarketos/upstreaming, Lee Jones,
Jakob Hauser
From: Stephan Gerhold <stephan@gerhold.net>
The fuel gauge in the RT5033 PMIC (rt5033-battery) has its own I2C bus
and interrupt lines. Therefore, it is not part of the MFD device
and needs to be specified separately in the device tree.
Cc: Beomho Seo <beomho.seo@samsung.com>
Cc: Chanwoo Choi <cw00.choi@samsung.com>
Fixes: 0b271258544b ("mfd: rt5033: Add Richtek RT5033 driver core.")
Signed-off-by: Stephan Gerhold <stephan@gerhold.net>
Acked-by: Lee Jones <lee.jones@linaro.org>
Signed-off-by: Jakob Hauser <jahau@rocketmail.com>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
---
drivers/mfd/rt5033.c | 3 ---
1 file changed, 3 deletions(-)
diff --git a/drivers/mfd/rt5033.c b/drivers/mfd/rt5033.c
index a5e520fe50a1..8029d444b794 100644
--- a/drivers/mfd/rt5033.c
+++ b/drivers/mfd/rt5033.c
@@ -40,9 +40,6 @@ static const struct mfd_cell rt5033_devs[] = {
{
.name = "rt5033-charger",
.of_compatible = "richtek,rt5033-charger",
- }, {
- .name = "rt5033-battery",
- .of_compatible = "richtek,rt5033-battery",
}, {
.name = "rt5033-led",
.of_compatible = "richtek,rt5033-led",
--
2.39.2
^ permalink raw reply related [flat|nested] 27+ messages in thread
* [PATCH v6 02/10 RESEND] mfd: rt5033: Fix chip revision readout
2023-05-15 20:57 ` [PATCH v6 00/10 RESEND] Add RT5033 charger device driver Jakob Hauser
2023-05-15 20:57 ` [PATCH v6 01/10 RESEND] mfd: rt5033: Drop rt5033-battery sub-device Jakob Hauser
@ 2023-05-15 20:57 ` Jakob Hauser
2023-05-15 20:57 ` [PATCH v6 03/10 RESEND] mfd: rt5033: Fix STAT_MASK, HZ_MASK and AICR defines Jakob Hauser
` (10 subsequent siblings)
12 siblings, 0 replies; 27+ messages in thread
From: Jakob Hauser @ 2023-05-15 20:57 UTC (permalink / raw)
To: Sebastian Reichel, Lee Jones, Liam Girdwood, Mark Brown,
Rob Herring, Krzysztof Kozlowski
Cc: Beomho Seo, Chanwoo Choi, Stephan Gerhold, Raymond Hackley,
Pavel Machek, Axel Lin, ChiYuan Huang, Linus Walleij,
Henrik Grimler, Christophe Jaillet, linux-pm, devicetree,
linux-kernel, phone-devel, ~postmarketos/upstreaming,
Jakob Hauser
After reading the data from the DEVICE_ID register, mask 0x0f needs to be
applied to extract the revision of the chip [1].
The other part of the DEVICE_ID register, mask 0xf0, is a vendor identification
code. That's how it is set up at similar products of Richtek, e.g. RT9455 [2]
page 21 top.
[1] https://github.com/msm8916-mainline/linux-downstream/blob/GT-I9195I/drivers/mfd/rt5033_core.c#L484
[2] https://www.richtek.com/assets/product_file/RT9455/DS9455-00.pdf
Signed-off-by: Jakob Hauser <jahau@rocketmail.com>
---
drivers/mfd/rt5033.c | 5 +++--
include/linux/mfd/rt5033-private.h | 4 ++++
2 files changed, 7 insertions(+), 2 deletions(-)
diff --git a/drivers/mfd/rt5033.c b/drivers/mfd/rt5033.c
index 8029d444b794..3eee4242ee02 100644
--- a/drivers/mfd/rt5033.c
+++ b/drivers/mfd/rt5033.c
@@ -55,7 +55,7 @@ static const struct regmap_config rt5033_regmap_config = {
static int rt5033_i2c_probe(struct i2c_client *i2c)
{
struct rt5033_dev *rt5033;
- unsigned int dev_id;
+ unsigned int dev_id, chip_rev;
int ret;
rt5033 = devm_kzalloc(&i2c->dev, sizeof(*rt5033), GFP_KERNEL);
@@ -78,7 +78,8 @@ static int rt5033_i2c_probe(struct i2c_client *i2c)
dev_err(&i2c->dev, "Device not found\n");
return -ENODEV;
}
- dev_info(&i2c->dev, "Device found Device ID: %04x\n", dev_id);
+ chip_rev = dev_id & RT5033_CHIP_REV_MASK;
+ dev_info(&i2c->dev, "Device found (rev. %d)\n", chip_rev);
ret = regmap_add_irq_chip(rt5033->regmap, rt5033->irq,
IRQF_TRIGGER_FALLING | IRQF_ONESHOT,
diff --git a/include/linux/mfd/rt5033-private.h b/include/linux/mfd/rt5033-private.h
index 6bb432f6a96c..b035a67cec73 100644
--- a/include/linux/mfd/rt5033-private.h
+++ b/include/linux/mfd/rt5033-private.h
@@ -71,6 +71,10 @@ enum rt5033_reg {
/* RT5033 CHGCTRL2 register */
#define RT5033_CHGCTRL2_CV_MASK 0xfc
+/* RT5033 DEVICE_ID register */
+#define RT5033_VENDOR_ID_MASK 0xf0
+#define RT5033_CHIP_REV_MASK 0x0f
+
/* RT5033 CHGCTRL3 register */
#define RT5033_CHGCTRL3_CFO_EN_MASK 0x40
#define RT5033_CHGCTRL3_TIMER_MASK 0x38
--
2.39.2
^ permalink raw reply related [flat|nested] 27+ messages in thread
* [PATCH v6 03/10 RESEND] mfd: rt5033: Fix STAT_MASK, HZ_MASK and AICR defines
2023-05-15 20:57 ` [PATCH v6 00/10 RESEND] Add RT5033 charger device driver Jakob Hauser
2023-05-15 20:57 ` [PATCH v6 01/10 RESEND] mfd: rt5033: Drop rt5033-battery sub-device Jakob Hauser
2023-05-15 20:57 ` [PATCH v6 02/10 RESEND] mfd: rt5033: Fix chip revision readout Jakob Hauser
@ 2023-05-15 20:57 ` Jakob Hauser
2023-05-15 20:57 ` [PATCH v6 04/10 RESEND] mfd: rt5033: Apply preparatory changes before adding rt5033-charger driver Jakob Hauser
` (9 subsequent siblings)
12 siblings, 0 replies; 27+ messages in thread
From: Jakob Hauser @ 2023-05-15 20:57 UTC (permalink / raw)
To: Sebastian Reichel, Lee Jones, Liam Girdwood, Mark Brown,
Rob Herring, Krzysztof Kozlowski
Cc: Beomho Seo, Chanwoo Choi, Stephan Gerhold, Raymond Hackley,
Pavel Machek, Axel Lin, ChiYuan Huang, Linus Walleij,
Henrik Grimler, Christophe Jaillet, linux-pm, devicetree,
linux-kernel, phone-devel, ~postmarketos/upstreaming,
Jakob Hauser
The charger state mask RT5033_CHG_STAT_MASK should be 0x30 [1][2].
The high impedance mask RT5033_RT_HZ_MASK is actually value 0x02 [3] and is
assosiated to the RT5033 CHGCTRL1 register [4]. Accordingly also change
RT5033_CHARGER_HZ_ENABLE to 0x02 to avoid the need of a bit shift upon
application.
For input current limiting AICR mode, the define for the 1000 mA step was
missing [5]. Additionally add the define for DISABLE option. Concerning the
mask, remove RT5033_AICR_MODE_MASK because there is already
RT5033_CHGCTRL1_IAICR_MASK further up. They are redundant and the upper one
makes more sense to have the masks of a register colleted there as an
overview.
[1] https://github.com/msm8916-mainline/linux-downstream/blob/GT-I9195I/drivers/battery/rt5033_charger.c#L669-L682
[2] https://github.com/torvalds/linux/blob/v6.0/include/linux/mfd/rt5033-private.h#L59-L62
[3] https://github.com/msm8916-mainline/linux-downstream/blob/GT-I9195I/include/linux/battery/charger/rt5033_charger.h#L44
[4] https://github.com/msm8916-mainline/linux-downstream/blob/GT-I9195I/drivers/battery/rt5033_charger.c#L223
[5] https://github.com/msm8916-mainline/linux-downstream/blob/GT-I9195I/drivers/battery/rt5033_charger.c#L278
Signed-off-by: Jakob Hauser <jahau@rocketmail.com>
Acked-for-MFD-by: Lee Jones <lee@kernel.org>
---
include/linux/mfd/rt5033-private.h | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/include/linux/mfd/rt5033-private.h b/include/linux/mfd/rt5033-private.h
index b035a67cec73..b6773ebf4e6b 100644
--- a/include/linux/mfd/rt5033-private.h
+++ b/include/linux/mfd/rt5033-private.h
@@ -55,7 +55,7 @@ enum rt5033_reg {
};
/* RT5033 Charger state register */
-#define RT5033_CHG_STAT_MASK 0x20
+#define RT5033_CHG_STAT_MASK 0x30
#define RT5033_CHG_STAT_DISCHARGING 0x00
#define RT5033_CHG_STAT_FULL 0x10
#define RT5033_CHG_STAT_CHARGING 0x20
@@ -67,6 +67,7 @@ enum rt5033_reg {
/* RT5033 CHGCTRL1 register */
#define RT5033_CHGCTRL1_IAICR_MASK 0xe0
#define RT5033_CHGCTRL1_MODE_MASK 0x01
+#define RT5033_CHGCTRL1_HZ_MASK 0x02
/* RT5033 CHGCTRL2 register */
#define RT5033_CHGCTRL2_CV_MASK 0xfc
@@ -92,7 +93,6 @@ enum rt5033_reg {
/* RT5033 RT CTRL1 register */
#define RT5033_RT_CTRL1_UUG_MASK 0x02
-#define RT5033_RT_HZ_MASK 0x01
/* RT5033 control register */
#define RT5033_CTRL_FCCM_BUCK_MASK BIT(0)
@@ -119,13 +119,14 @@ enum rt5033_reg {
* register), AICR mode limits the input current. For example, the AIRC 100
* mode limits the input current to 100 mA.
*/
+#define RT5033_AICR_DISABLE 0x00
#define RT5033_AICR_100_MODE 0x20
#define RT5033_AICR_500_MODE 0x40
#define RT5033_AICR_700_MODE 0x60
#define RT5033_AICR_900_MODE 0x80
+#define RT5033_AICR_1000_MODE 0xa0
#define RT5033_AICR_1500_MODE 0xc0
#define RT5033_AICR_2000_MODE 0xe0
-#define RT5033_AICR_MODE_MASK 0xe0
/* RT5033 use internal timer need to set time */
#define RT5033_FAST_CHARGE_TIMER4 0x00
@@ -195,7 +196,7 @@ enum rt5033_reg {
/* RT5033 charger high impedance mode */
#define RT5033_CHARGER_HZ_DISABLE 0x00
-#define RT5033_CHARGER_HZ_ENABLE 0x01
+#define RT5033_CHARGER_HZ_ENABLE 0x02
/* RT5033 regulator BUCK output voltage uV */
#define RT5033_REGULATOR_BUCK_VOLTAGE_MIN 1000000U
--
2.39.2
^ permalink raw reply related [flat|nested] 27+ messages in thread
* [PATCH v6 04/10 RESEND] mfd: rt5033: Apply preparatory changes before adding rt5033-charger driver
2023-05-15 20:57 ` [PATCH v6 00/10 RESEND] Add RT5033 charger device driver Jakob Hauser
` (2 preceding siblings ...)
2023-05-15 20:57 ` [PATCH v6 03/10 RESEND] mfd: rt5033: Fix STAT_MASK, HZ_MASK and AICR defines Jakob Hauser
@ 2023-05-15 20:57 ` Jakob Hauser
2023-05-25 10:44 ` Lee Jones
2023-05-15 20:57 ` [PATCH v6 05/10 RESEND] power: supply: rt5033_charger: Add RT5033 charger device driver Jakob Hauser
` (8 subsequent siblings)
12 siblings, 1 reply; 27+ messages in thread
From: Jakob Hauser @ 2023-05-15 20:57 UTC (permalink / raw)
To: Sebastian Reichel, Lee Jones, Liam Girdwood, Mark Brown,
Rob Herring, Krzysztof Kozlowski
Cc: Beomho Seo, Chanwoo Choi, Stephan Gerhold, Raymond Hackley,
Pavel Machek, Axel Lin, ChiYuan Huang, Linus Walleij,
Henrik Grimler, Christophe Jaillet, linux-pm, devicetree,
linux-kernel, phone-devel, ~postmarketos/upstreaming,
Jakob Hauser
Order the register blocks to have the masks in descending manner.
Add new defines for constant voltage shift (RT5033_CHGCTRL2_CV_SHIFT),
MIVR mask (RT5033_CHGCTRL4_MIVR_MASK), pre-charge current shift
(RT5033_CHGCTRL4_IPREC_SHIFT), internal timer disable
(RT5033_INT_TIMER_DISABLE), termination disable (RT5033_TE_DISABLE),
CFO disable (RT5033_CFO_DISABLE), UUG disable (RT5033_CHARGER_UUG_DISABLE).
The fast charge timer type needs to be written on mask 0x38
(RT5033_CHGCTRL3_TIMER_MASK). To avoid a bit shift on application, change the
values of the timer types to fit the mask. Added the timout duration as a
comment. And the timer between TIMER8 and TIMER12 is most likely TIMER10, see
e.g. RT5036 [1] page 28 bottom.
Add value options for MIVR (Minimum Input Voltage Regulation).
Move RT5033_TE_ENABLE_MASK to the block "RT5033 CHGCTRL1 register", in order
to have the masks of the register collected there. To fit the naming scheme,
rename it to RT5033_CHGCTRL1_TE_EN_MASK.
Move RT5033_CHG_MAX_CURRENT to the block "RT5033 charger fast-charge current".
Add new defines RT5033_CV_MAX_VOLTAGE and RT5033_CHG_MAX_PRE_CURRENT to the
blocks "RT5033 charger constant charge voltage" and "RT5033 charger pre-charge
current limits".
In include/linux/mfd/rt5033.h, turn power_supply "psy" into a pointer in order
to use it in devm_power_supply_register().
[1] https://media.digikey.com/pdf/Data%20Sheets/Richtek%20PDF/RT5036%20%20Preliminary.pdf
Signed-off-by: Jakob Hauser <jahau@rocketmail.com>
---
include/linux/mfd/rt5033-private.h | 53 ++++++++++++++++++++----------
include/linux/mfd/rt5033.h | 2 +-
2 files changed, 36 insertions(+), 19 deletions(-)
diff --git a/include/linux/mfd/rt5033-private.h b/include/linux/mfd/rt5033-private.h
index b6773ebf4e6b..0221f806d139 100644
--- a/include/linux/mfd/rt5033-private.h
+++ b/include/linux/mfd/rt5033-private.h
@@ -55,22 +55,24 @@ enum rt5033_reg {
};
/* RT5033 Charger state register */
+#define RT5033_CHG_STAT_TYPE_MASK 0x60
+#define RT5033_CHG_STAT_TYPE_PRE 0x20
+#define RT5033_CHG_STAT_TYPE_FAST 0x60
#define RT5033_CHG_STAT_MASK 0x30
#define RT5033_CHG_STAT_DISCHARGING 0x00
#define RT5033_CHG_STAT_FULL 0x10
#define RT5033_CHG_STAT_CHARGING 0x20
#define RT5033_CHG_STAT_NOT_CHARGING 0x30
-#define RT5033_CHG_STAT_TYPE_MASK 0x60
-#define RT5033_CHG_STAT_TYPE_PRE 0x20
-#define RT5033_CHG_STAT_TYPE_FAST 0x60
/* RT5033 CHGCTRL1 register */
#define RT5033_CHGCTRL1_IAICR_MASK 0xe0
-#define RT5033_CHGCTRL1_MODE_MASK 0x01
+#define RT5033_CHGCTRL1_TE_EN_MASK 0x08
#define RT5033_CHGCTRL1_HZ_MASK 0x02
+#define RT5033_CHGCTRL1_MODE_MASK 0x01
/* RT5033 CHGCTRL2 register */
#define RT5033_CHGCTRL2_CV_MASK 0xfc
+#define RT5033_CHGCTRL2_CV_SHIFT 0x02
/* RT5033 DEVICE_ID register */
#define RT5033_VENDOR_ID_MASK 0xf0
@@ -82,14 +84,15 @@ enum rt5033_reg {
#define RT5033_CHGCTRL3_TIMER_EN_MASK 0x01
/* RT5033 CHGCTRL4 register */
-#define RT5033_CHGCTRL4_EOC_MASK 0x07
+#define RT5033_CHGCTRL4_MIVR_MASK 0xe0
#define RT5033_CHGCTRL4_IPREC_MASK 0x18
+#define RT5033_CHGCTRL4_IPREC_SHIFT 0x03
+#define RT5033_CHGCTRL4_EOC_MASK 0x07
/* RT5033 CHGCTRL5 register */
-#define RT5033_CHGCTRL5_VPREC_MASK 0x0f
#define RT5033_CHGCTRL5_ICHG_MASK 0xf0
#define RT5033_CHGCTRL5_ICHG_SHIFT 0x04
-#define RT5033_CHG_MAX_CURRENT 0x0d
+#define RT5033_CHGCTRL5_VPREC_MASK 0x0f
/* RT5033 RT CTRL1 register */
#define RT5033_RT_CTRL1_UUG_MASK 0x02
@@ -128,20 +131,28 @@ enum rt5033_reg {
#define RT5033_AICR_1500_MODE 0xc0
#define RT5033_AICR_2000_MODE 0xe0
-/* RT5033 use internal timer need to set time */
-#define RT5033_FAST_CHARGE_TIMER4 0x00
-#define RT5033_FAST_CHARGE_TIMER6 0x01
-#define RT5033_FAST_CHARGE_TIMER8 0x02
-#define RT5033_FAST_CHARGE_TIMER9 0x03
-#define RT5033_FAST_CHARGE_TIMER12 0x04
-#define RT5033_FAST_CHARGE_TIMER14 0x05
-#define RT5033_FAST_CHARGE_TIMER16 0x06
+/* RT5033 charger minimum input voltage regulation */
+#define RT5033_CHARGER_MIVR_DISABLE 0x00
+#define RT5033_CHARGER_MIVR_4200MV 0x20
+#define RT5033_CHARGER_MIVR_4300MV 0x40
+#define RT5033_CHARGER_MIVR_4400MV 0x60
+#define RT5033_CHARGER_MIVR_4500MV 0x80
+#define RT5033_CHARGER_MIVR_4600MV 0xa0
+#define RT5033_CHARGER_MIVR_4700MV 0xc0
+#define RT5033_CHARGER_MIVR_4800MV 0xe0
+/* RT5033 use internal timer need to set time */
+#define RT5033_FAST_CHARGE_TIMER4 0x00 /* 4 hrs */
+#define RT5033_FAST_CHARGE_TIMER6 0x08 /* 6 hrs */
+#define RT5033_FAST_CHARGE_TIMER8 0x10 /* 8 hrs */
+#define RT5033_FAST_CHARGE_TIMER10 0x18 /* 10 hrs */
+#define RT5033_FAST_CHARGE_TIMER12 0x20 /* 12 hrs */
+#define RT5033_FAST_CHARGE_TIMER14 0x28 /* 14 hrs */
+#define RT5033_FAST_CHARGE_TIMER16 0x30 /* 16 hrs */
+
+#define RT5033_INT_TIMER_DISABLE 0x00
#define RT5033_INT_TIMER_ENABLE 0x01
-/* RT5033 charger termination enable mask */
-#define RT5033_TE_ENABLE_MASK 0x08
-
/*
* RT5033 charger opa mode. RT5033 has two opa modes for OTG: charger mode
* and boost mode.
@@ -150,25 +161,30 @@ enum rt5033_reg {
#define RT5033_BOOST_MODE 0x01
/* RT5033 charger termination enable */
+#define RT5033_TE_DISABLE 0x00
#define RT5033_TE_ENABLE 0x08
/* RT5033 charger CFO enable */
+#define RT5033_CFO_DISABLE 0x00
#define RT5033_CFO_ENABLE 0x40
/* RT5033 charger constant charge voltage (as in CHGCTRL2 register), uV */
#define RT5033_CHARGER_CONST_VOLTAGE_LIMIT_MIN 3650000U
#define RT5033_CHARGER_CONST_VOLTAGE_STEP_NUM 25000U
#define RT5033_CHARGER_CONST_VOLTAGE_LIMIT_MAX 4400000U
+#define RT5033_CV_MAX_VOLTAGE 0x1e
/* RT5033 charger pre-charge current limits (as in CHGCTRL4 register), uA */
#define RT5033_CHARGER_PRE_CURRENT_LIMIT_MIN 350000U
#define RT5033_CHARGER_PRE_CURRENT_STEP_NUM 100000U
#define RT5033_CHARGER_PRE_CURRENT_LIMIT_MAX 650000U
+#define RT5033_CHG_MAX_PRE_CURRENT 0x03
/* RT5033 charger fast-charge current (as in CHGCTRL5 register), uA */
#define RT5033_CHARGER_FAST_CURRENT_MIN 700000U
#define RT5033_CHARGER_FAST_CURRENT_STEP_NUM 100000U
#define RT5033_CHARGER_FAST_CURRENT_MAX 2000000U
+#define RT5033_CHG_MAX_CURRENT 0x0d
/*
* RT5033 charger const-charge end of charger current (
@@ -192,6 +208,7 @@ enum rt5033_reg {
* RT5033 charger UUG. It enables MOS auto control by H/W charger
* circuit.
*/
+#define RT5033_CHARGER_UUG_DISABLE 0x00
#define RT5033_CHARGER_UUG_ENABLE 0x02
/* RT5033 charger high impedance mode */
diff --git a/include/linux/mfd/rt5033.h b/include/linux/mfd/rt5033.h
index 8f306ac15a27..e99e2ab0c1c1 100644
--- a/include/linux/mfd/rt5033.h
+++ b/include/linux/mfd/rt5033.h
@@ -51,7 +51,7 @@ struct rt5033_charger_data {
struct rt5033_charger {
struct device *dev;
struct rt5033_dev *rt5033;
- struct power_supply psy;
+ struct power_supply *psy;
struct rt5033_charger_data *chg;
};
--
2.39.2
^ permalink raw reply related [flat|nested] 27+ messages in thread
* [PATCH v6 05/10 RESEND] power: supply: rt5033_charger: Add RT5033 charger device driver
2023-05-15 20:57 ` [PATCH v6 00/10 RESEND] Add RT5033 charger device driver Jakob Hauser
` (3 preceding siblings ...)
2023-05-15 20:57 ` [PATCH v6 04/10 RESEND] mfd: rt5033: Apply preparatory changes before adding rt5033-charger driver Jakob Hauser
@ 2023-05-15 20:57 ` Jakob Hauser
2023-05-15 20:57 ` [PATCH v6 06/10 RESEND] power: supply: rt5033_charger: Add cable detection and USB OTG supply Jakob Hauser
` (7 subsequent siblings)
12 siblings, 0 replies; 27+ messages in thread
From: Jakob Hauser @ 2023-05-15 20:57 UTC (permalink / raw)
To: Sebastian Reichel, Lee Jones, Liam Girdwood, Mark Brown,
Rob Herring, Krzysztof Kozlowski
Cc: Beomho Seo, Chanwoo Choi, Stephan Gerhold, Raymond Hackley,
Pavel Machek, Axel Lin, ChiYuan Huang, Linus Walleij,
Henrik Grimler, Christophe Jaillet, linux-pm, devicetree,
linux-kernel, phone-devel, ~postmarketos/upstreaming,
Jakob Hauser, Sebastian Reichel
This patch adds device driver of Richtek RT5033 PMIC. The driver supports
switching charger. rt5033 charger provides three charging modes. The charging
modes are pre-charge mode, fast charge mode and constant voltage mode. They
vary in charge rate, the charge parameters can be controlled by i2c interface.
Cc: Beomho Seo <beomho.seo@samsung.com>
Cc: Chanwoo Choi <cw00.choi@samsung.com>
Tested-by: Raymond Hackley <raymondhackley@protonmail.com>
Signed-off-by: Jakob Hauser <jahau@rocketmail.com>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Acked-by: Sebastian Reichel <sebastian.reichel@collabora.com>
---
drivers/power/supply/Kconfig | 8 +
drivers/power/supply/Makefile | 1 +
drivers/power/supply/rt5033_charger.c | 472 ++++++++++++++++++++++++++
include/linux/mfd/rt5033.h | 16 -
4 files changed, 481 insertions(+), 16 deletions(-)
create mode 100644 drivers/power/supply/rt5033_charger.c
diff --git a/drivers/power/supply/Kconfig b/drivers/power/supply/Kconfig
index c78be9f322e6..ea11797670ca 100644
--- a/drivers/power/supply/Kconfig
+++ b/drivers/power/supply/Kconfig
@@ -766,6 +766,14 @@ config BATTERY_RT5033
The fuelgauge calculates and determines the battery state of charge
according to battery open circuit voltage.
+config CHARGER_RT5033
+ tristate "RT5033 battery charger support"
+ depends on MFD_RT5033
+ help
+ This adds support for battery charger in Richtek RT5033 PMIC.
+ The device supports pre-charge mode, fast charge mode and
+ constant voltage mode.
+
config CHARGER_RT9455
tristate "Richtek RT9455 battery charger driver"
depends on I2C
diff --git a/drivers/power/supply/Makefile b/drivers/power/supply/Makefile
index 4adbfba02d05..dfc624bbcf1d 100644
--- a/drivers/power/supply/Makefile
+++ b/drivers/power/supply/Makefile
@@ -54,6 +54,7 @@ obj-$(CONFIG_BATTERY_MAX17040) += max17040_battery.o
obj-$(CONFIG_BATTERY_MAX17042) += max17042_battery.o
obj-$(CONFIG_BATTERY_MAX1721X) += max1721x_battery.o
obj-$(CONFIG_BATTERY_RT5033) += rt5033_battery.o
+obj-$(CONFIG_CHARGER_RT5033) += rt5033_charger.o
obj-$(CONFIG_CHARGER_RT9455) += rt9455_charger.o
obj-$(CONFIG_CHARGER_RT9467) += rt9467-charger.o
obj-$(CONFIG_CHARGER_RT9471) += rt9471.o
diff --git a/drivers/power/supply/rt5033_charger.c b/drivers/power/supply/rt5033_charger.c
new file mode 100644
index 000000000000..5218dfbf5e1b
--- /dev/null
+++ b/drivers/power/supply/rt5033_charger.c
@@ -0,0 +1,472 @@
+// SPDX-License-Identifier: GPL-2.0-only
+/*
+ * Battery charger driver for RT5033
+ *
+ * Copyright (C) 2014 Samsung Electronics, Co., Ltd.
+ * Author: Beomho Seo <beomho.seo@samsung.com>
+ */
+
+#include <linux/module.h>
+#include <linux/of_device.h>
+#include <linux/platform_device.h>
+#include <linux/power_supply.h>
+#include <linux/regmap.h>
+#include <linux/mfd/rt5033-private.h>
+
+struct rt5033_charger_data {
+ unsigned int pre_uamp;
+ unsigned int pre_uvolt;
+ unsigned int const_uvolt;
+ unsigned int eoc_uamp;
+ unsigned int fast_uamp;
+};
+
+struct rt5033_charger {
+ struct device *dev;
+ struct regmap *regmap;
+ struct power_supply *psy;
+ struct rt5033_charger_data *chg;
+};
+
+static int rt5033_get_charger_state(struct rt5033_charger *charger)
+{
+ struct regmap *regmap = charger->regmap;
+ unsigned int reg_data;
+ int state;
+
+ if (!regmap)
+ return POWER_SUPPLY_STATUS_UNKNOWN;
+
+ regmap_read(regmap, RT5033_REG_CHG_STAT, ®_data);
+
+ switch (reg_data & RT5033_CHG_STAT_MASK) {
+ case RT5033_CHG_STAT_DISCHARGING:
+ state = POWER_SUPPLY_STATUS_DISCHARGING;
+ break;
+ case RT5033_CHG_STAT_CHARGING:
+ state = POWER_SUPPLY_STATUS_CHARGING;
+ break;
+ case RT5033_CHG_STAT_FULL:
+ state = POWER_SUPPLY_STATUS_FULL;
+ break;
+ case RT5033_CHG_STAT_NOT_CHARGING:
+ state = POWER_SUPPLY_STATUS_NOT_CHARGING;
+ break;
+ default:
+ state = POWER_SUPPLY_STATUS_UNKNOWN;
+ }
+
+ return state;
+}
+
+static int rt5033_get_charger_type(struct rt5033_charger *charger)
+{
+ struct regmap *regmap = charger->regmap;
+ unsigned int reg_data;
+ int state;
+
+ regmap_read(regmap, RT5033_REG_CHG_STAT, ®_data);
+
+ switch (reg_data & RT5033_CHG_STAT_TYPE_MASK) {
+ case RT5033_CHG_STAT_TYPE_FAST:
+ state = POWER_SUPPLY_CHARGE_TYPE_FAST;
+ break;
+ case RT5033_CHG_STAT_TYPE_PRE:
+ state = POWER_SUPPLY_CHARGE_TYPE_TRICKLE;
+ break;
+ default:
+ state = POWER_SUPPLY_CHARGE_TYPE_NONE;
+ }
+
+ return state;
+}
+
+static int rt5033_get_charger_current_limit(struct rt5033_charger *charger)
+{
+ struct regmap *regmap = charger->regmap;
+ unsigned int state, reg_data, data;
+
+ regmap_read(regmap, RT5033_REG_CHG_CTRL5, ®_data);
+
+ state = (reg_data & RT5033_CHGCTRL5_ICHG_MASK)
+ >> RT5033_CHGCTRL5_ICHG_SHIFT;
+
+ data = RT5033_CHARGER_FAST_CURRENT_MIN +
+ RT5033_CHARGER_FAST_CURRENT_STEP_NUM * state;
+
+ return data;
+}
+
+static int rt5033_get_charger_const_voltage(struct rt5033_charger *charger)
+{
+ struct regmap *regmap = charger->regmap;
+ unsigned int state, reg_data, data;
+
+ regmap_read(regmap, RT5033_REG_CHG_CTRL2, ®_data);
+
+ state = (reg_data & RT5033_CHGCTRL2_CV_MASK)
+ >> RT5033_CHGCTRL2_CV_SHIFT;
+
+ data = RT5033_CHARGER_CONST_VOLTAGE_LIMIT_MIN +
+ RT5033_CHARGER_CONST_VOLTAGE_STEP_NUM * state;
+
+ return data;
+}
+
+static inline int rt5033_init_const_charge(struct rt5033_charger *charger)
+{
+ struct rt5033_charger_data *chg = charger->chg;
+ int ret;
+ unsigned int val;
+ u8 reg_data;
+
+ /* Set constant voltage mode */
+ if (chg->const_uvolt < RT5033_CHARGER_CONST_VOLTAGE_LIMIT_MIN ||
+ chg->const_uvolt > RT5033_CHARGER_CONST_VOLTAGE_LIMIT_MAX) {
+ dev_err(charger->dev,
+ "Value 'constant-charge-voltage-max-microvolt' out of range\n");
+ return -EINVAL;
+ }
+
+ if (chg->const_uvolt == RT5033_CHARGER_CONST_VOLTAGE_LIMIT_MIN)
+ reg_data = 0x00;
+ else if (chg->const_uvolt == RT5033_CHARGER_CONST_VOLTAGE_LIMIT_MAX)
+ reg_data = RT5033_CV_MAX_VOLTAGE;
+ else {
+ val = chg->const_uvolt;
+ val -= RT5033_CHARGER_CONST_VOLTAGE_LIMIT_MIN;
+ val /= RT5033_CHARGER_CONST_VOLTAGE_STEP_NUM;
+ reg_data = val;
+ }
+
+ ret = regmap_update_bits(charger->regmap, RT5033_REG_CHG_CTRL2,
+ RT5033_CHGCTRL2_CV_MASK,
+ reg_data << RT5033_CHGCTRL2_CV_SHIFT);
+ if (ret) {
+ dev_err(charger->dev, "Failed regmap update\n");
+ return -EINVAL;
+ }
+
+ /* Set end of charge current */
+ if (chg->eoc_uamp < RT5033_CHARGER_EOC_MIN ||
+ chg->eoc_uamp > RT5033_CHARGER_EOC_MAX) {
+ dev_err(charger->dev,
+ "Value 'charge-term-current-microamp' out of range\n");
+ return -EINVAL;
+ }
+
+ if (chg->eoc_uamp == RT5033_CHARGER_EOC_MIN)
+ reg_data = 0x01;
+ else if (chg->eoc_uamp == RT5033_CHARGER_EOC_MAX)
+ reg_data = 0x07;
+ else {
+ val = chg->eoc_uamp;
+ if (val < RT5033_CHARGER_EOC_REF) {
+ val -= RT5033_CHARGER_EOC_MIN;
+ val /= RT5033_CHARGER_EOC_STEP_NUM1;
+ reg_data = 0x01 + val;
+ } else if (val > RT5033_CHARGER_EOC_REF) {
+ val -= RT5033_CHARGER_EOC_REF;
+ val /= RT5033_CHARGER_EOC_STEP_NUM2;
+ reg_data = 0x04 + val;
+ } else {
+ reg_data = 0x04;
+ }
+ }
+
+ ret = regmap_update_bits(charger->regmap, RT5033_REG_CHG_CTRL4,
+ RT5033_CHGCTRL4_EOC_MASK, reg_data);
+ if (ret) {
+ dev_err(charger->dev, "Failed regmap update\n");
+ return -EINVAL;
+ }
+
+ return 0;
+}
+
+static inline int rt5033_init_fast_charge(struct rt5033_charger *charger)
+{
+ struct rt5033_charger_data *chg = charger->chg;
+ int ret;
+ unsigned int val;
+ u8 reg_data;
+
+ /* Set limit input current */
+ ret = regmap_update_bits(charger->regmap, RT5033_REG_CHG_CTRL1,
+ RT5033_CHGCTRL1_IAICR_MASK, RT5033_AICR_2000_MODE);
+ if (ret) {
+ dev_err(charger->dev, "Failed regmap update\n");
+ return -EINVAL;
+ }
+
+ /* Set fast-charge mode charging current */
+ if (chg->fast_uamp < RT5033_CHARGER_FAST_CURRENT_MIN ||
+ chg->fast_uamp > RT5033_CHARGER_FAST_CURRENT_MAX) {
+ dev_err(charger->dev,
+ "Value 'constant-charge-current-max-microamp' out of range\n");
+ return -EINVAL;
+ }
+
+ if (chg->fast_uamp == RT5033_CHARGER_FAST_CURRENT_MIN)
+ reg_data = 0x00;
+ else if (chg->fast_uamp == RT5033_CHARGER_FAST_CURRENT_MAX)
+ reg_data = RT5033_CHG_MAX_CURRENT;
+ else {
+ val = chg->fast_uamp;
+ val -= RT5033_CHARGER_FAST_CURRENT_MIN;
+ val /= RT5033_CHARGER_FAST_CURRENT_STEP_NUM;
+ reg_data = val;
+ }
+
+ ret = regmap_update_bits(charger->regmap, RT5033_REG_CHG_CTRL5,
+ RT5033_CHGCTRL5_ICHG_MASK,
+ reg_data << RT5033_CHGCTRL5_ICHG_SHIFT);
+ if (ret) {
+ dev_err(charger->dev, "Failed regmap update\n");
+ return -EINVAL;
+ }
+
+ return 0;
+}
+
+static inline int rt5033_init_pre_charge(struct rt5033_charger *charger)
+{
+ struct rt5033_charger_data *chg = charger->chg;
+ int ret;
+ unsigned int val;
+ u8 reg_data;
+
+ /* Set pre-charge threshold voltage */
+ if (chg->pre_uvolt < RT5033_CHARGER_PRE_THRESHOLD_LIMIT_MIN ||
+ chg->pre_uvolt > RT5033_CHARGER_PRE_THRESHOLD_LIMIT_MAX) {
+ dev_err(charger->dev,
+ "Value 'precharge-upper-limit-microvolt' out of range\n");
+ return -EINVAL;
+ }
+
+ if (chg->pre_uvolt == RT5033_CHARGER_PRE_THRESHOLD_LIMIT_MIN)
+ reg_data = 0x00;
+ else if (chg->pre_uvolt == RT5033_CHARGER_PRE_THRESHOLD_LIMIT_MAX)
+ reg_data = 0x0f;
+ else {
+ val = chg->pre_uvolt;
+ val -= RT5033_CHARGER_PRE_THRESHOLD_LIMIT_MIN;
+ val /= RT5033_CHARGER_PRE_THRESHOLD_STEP_NUM;
+ reg_data = val;
+ }
+
+ ret = regmap_update_bits(charger->regmap, RT5033_REG_CHG_CTRL5,
+ RT5033_CHGCTRL5_VPREC_MASK, reg_data);
+ if (ret) {
+ dev_err(charger->dev, "Failed regmap update\n");
+ return -EINVAL;
+ }
+
+ /* Set pre-charge mode charging current */
+ if (chg->pre_uamp < RT5033_CHARGER_PRE_CURRENT_LIMIT_MIN ||
+ chg->pre_uamp > RT5033_CHARGER_PRE_CURRENT_LIMIT_MAX) {
+ dev_err(charger->dev,
+ "Value 'precharge-current-microamp' out of range\n");
+ return -EINVAL;
+ }
+
+ if (chg->pre_uamp == RT5033_CHARGER_PRE_CURRENT_LIMIT_MIN)
+ reg_data = 0x00;
+ else if (chg->pre_uamp == RT5033_CHARGER_PRE_CURRENT_LIMIT_MAX)
+ reg_data = RT5033_CHG_MAX_PRE_CURRENT;
+ else {
+ val = chg->pre_uamp;
+ val -= RT5033_CHARGER_PRE_CURRENT_LIMIT_MIN;
+ val /= RT5033_CHARGER_PRE_CURRENT_STEP_NUM;
+ reg_data = val;
+ }
+
+ ret = regmap_update_bits(charger->regmap, RT5033_REG_CHG_CTRL4,
+ RT5033_CHGCTRL4_IPREC_MASK,
+ reg_data << RT5033_CHGCTRL4_IPREC_SHIFT);
+ if (ret) {
+ dev_err(charger->dev, "Failed regmap update\n");
+ return -EINVAL;
+ }
+
+ return 0;
+}
+
+static int rt5033_charger_reg_init(struct rt5033_charger *charger)
+{
+ int ret = 0;
+
+ /* Enable charging termination */
+ ret = regmap_update_bits(charger->regmap, RT5033_REG_CHG_CTRL1,
+ RT5033_CHGCTRL1_TE_EN_MASK, RT5033_TE_ENABLE);
+ if (ret) {
+ dev_err(charger->dev, "Failed to enable charging termination.\n");
+ return -EINVAL;
+ }
+
+ /*
+ * Disable minimum input voltage regulation (MIVR), this improves
+ * the charging performance.
+ */
+ ret = regmap_update_bits(charger->regmap, RT5033_REG_CHG_CTRL4,
+ RT5033_CHGCTRL4_MIVR_MASK, RT5033_CHARGER_MIVR_DISABLE);
+ if (ret) {
+ dev_err(charger->dev, "Failed to disable MIVR.\n");
+ return -EINVAL;
+ }
+
+ ret = rt5033_init_pre_charge(charger);
+ if (ret)
+ return ret;
+
+ ret = rt5033_init_fast_charge(charger);
+ if (ret)
+ return ret;
+
+ ret = rt5033_init_const_charge(charger);
+ if (ret)
+ return ret;
+
+ return 0;
+}
+
+static enum power_supply_property rt5033_charger_props[] = {
+ POWER_SUPPLY_PROP_STATUS,
+ POWER_SUPPLY_PROP_CHARGE_TYPE,
+ POWER_SUPPLY_PROP_CURRENT_MAX,
+ POWER_SUPPLY_PROP_CONSTANT_CHARGE_VOLTAGE,
+ POWER_SUPPLY_PROP_MODEL_NAME,
+ POWER_SUPPLY_PROP_MANUFACTURER,
+ POWER_SUPPLY_PROP_ONLINE,
+};
+
+static int rt5033_charger_get_property(struct power_supply *psy,
+ enum power_supply_property psp,
+ union power_supply_propval *val)
+{
+ struct rt5033_charger *charger = power_supply_get_drvdata(psy);
+
+ switch (psp) {
+ case POWER_SUPPLY_PROP_STATUS:
+ val->intval = rt5033_get_charger_state(charger);
+ break;
+ case POWER_SUPPLY_PROP_CHARGE_TYPE:
+ val->intval = rt5033_get_charger_type(charger);
+ break;
+ case POWER_SUPPLY_PROP_CURRENT_MAX:
+ val->intval = rt5033_get_charger_current_limit(charger);
+ break;
+ case POWER_SUPPLY_PROP_CONSTANT_CHARGE_VOLTAGE:
+ val->intval = rt5033_get_charger_const_voltage(charger);
+ break;
+ case POWER_SUPPLY_PROP_MODEL_NAME:
+ val->strval = RT5033_CHARGER_MODEL;
+ break;
+ case POWER_SUPPLY_PROP_MANUFACTURER:
+ val->strval = RT5033_MANUFACTURER;
+ break;
+ case POWER_SUPPLY_PROP_ONLINE:
+ val->intval = (rt5033_get_charger_state(charger) ==
+ POWER_SUPPLY_STATUS_CHARGING);
+ break;
+ default:
+ return -EINVAL;
+ }
+
+ return 0;
+}
+
+static struct rt5033_charger_data *rt5033_charger_dt_init(
+ struct rt5033_charger *charger)
+{
+ struct rt5033_charger_data *chg;
+ struct power_supply_battery_info *info;
+ int ret;
+
+ chg = devm_kzalloc(charger->dev, sizeof(*chg), GFP_KERNEL);
+ if (!chg)
+ return ERR_PTR(-ENOMEM);
+
+ ret = power_supply_get_battery_info(charger->psy, &info);
+ if (ret)
+ return ERR_PTR(dev_err_probe(charger->dev, -EINVAL,
+ "missing battery info\n"));
+
+ /* Assign data. Validity will be checked in the init functions. */
+ chg->pre_uamp = info->precharge_current_ua;
+ chg->fast_uamp = info->constant_charge_current_max_ua;
+ chg->eoc_uamp = info->charge_term_current_ua;
+ chg->pre_uvolt = info->precharge_voltage_max_uv;
+ chg->const_uvolt = info->constant_charge_voltage_max_uv;
+
+ return chg;
+}
+
+static const struct power_supply_desc rt5033_charger_desc = {
+ .name = "rt5033-charger",
+ .type = POWER_SUPPLY_TYPE_USB,
+ .properties = rt5033_charger_props,
+ .num_properties = ARRAY_SIZE(rt5033_charger_props),
+ .get_property = rt5033_charger_get_property,
+};
+
+static int rt5033_charger_probe(struct platform_device *pdev)
+{
+ struct rt5033_charger *charger;
+ struct power_supply_config psy_cfg = {};
+ int ret;
+
+ charger = devm_kzalloc(&pdev->dev, sizeof(*charger), GFP_KERNEL);
+ if (!charger)
+ return -ENOMEM;
+
+ platform_set_drvdata(pdev, charger);
+ charger->dev = &pdev->dev;
+ charger->regmap = dev_get_regmap(pdev->dev.parent, NULL);
+
+ psy_cfg.of_node = pdev->dev.of_node;
+ psy_cfg.drv_data = charger;
+
+ charger->psy = devm_power_supply_register(&pdev->dev,
+ &rt5033_charger_desc,
+ &psy_cfg);
+ if (IS_ERR(charger->psy))
+ return dev_err_probe(&pdev->dev, PTR_ERR(charger->psy),
+ "Failed to register power supply\n");
+
+ charger->chg = rt5033_charger_dt_init(charger);
+ if (IS_ERR_OR_NULL(charger->chg))
+ return PTR_ERR(charger->chg);
+
+ ret = rt5033_charger_reg_init(charger);
+ if (ret)
+ return ret;
+
+ return 0;
+}
+
+static const struct platform_device_id rt5033_charger_id[] = {
+ { "rt5033-charger", },
+ { }
+};
+MODULE_DEVICE_TABLE(platform, rt5033_charger_id);
+
+static const struct of_device_id rt5033_charger_of_match[] = {
+ { .compatible = "richtek,rt5033-charger", },
+ { }
+};
+MODULE_DEVICE_TABLE(of, rt5033_charger_of_match);
+
+static struct platform_driver rt5033_charger_driver = {
+ .driver = {
+ .name = "rt5033-charger",
+ .of_match_table = rt5033_charger_of_match,
+ },
+ .probe = rt5033_charger_probe,
+ .id_table = rt5033_charger_id,
+};
+module_platform_driver(rt5033_charger_driver);
+
+MODULE_DESCRIPTION("Richtek RT5033 charger driver");
+MODULE_AUTHOR("Beomho Seo <beomho.seo@samsung.com>");
+MODULE_LICENSE("GPL v2");
diff --git a/include/linux/mfd/rt5033.h b/include/linux/mfd/rt5033.h
index e99e2ab0c1c1..3992fb2ef0a8 100644
--- a/include/linux/mfd/rt5033.h
+++ b/include/linux/mfd/rt5033.h
@@ -39,20 +39,4 @@ struct rt5033_battery {
struct power_supply *psy;
};
-/* RT5033 charger platform data */
-struct rt5033_charger_data {
- unsigned int pre_uamp;
- unsigned int pre_uvolt;
- unsigned int const_uvolt;
- unsigned int eoc_uamp;
- unsigned int fast_uamp;
-};
-
-struct rt5033_charger {
- struct device *dev;
- struct rt5033_dev *rt5033;
- struct power_supply *psy;
- struct rt5033_charger_data *chg;
-};
-
#endif /* __RT5033_H__ */
--
2.39.2
^ permalink raw reply related [flat|nested] 27+ messages in thread
* [PATCH v6 06/10 RESEND] power: supply: rt5033_charger: Add cable detection and USB OTG supply
2023-05-15 20:57 ` [PATCH v6 00/10 RESEND] Add RT5033 charger device driver Jakob Hauser
` (4 preceding siblings ...)
2023-05-15 20:57 ` [PATCH v6 05/10 RESEND] power: supply: rt5033_charger: Add RT5033 charger device driver Jakob Hauser
@ 2023-05-15 20:57 ` Jakob Hauser
2023-08-17 9:38 ` (subset) " Lee Jones
2023-05-15 20:57 ` [PATCH v6 07/10 RESEND] power: supply: rt5033_battery: Move struct rt5033_battery to battery driver Jakob Hauser
` (6 subsequent siblings)
12 siblings, 1 reply; 27+ messages in thread
From: Jakob Hauser @ 2023-05-15 20:57 UTC (permalink / raw)
To: Sebastian Reichel, Lee Jones, Liam Girdwood, Mark Brown,
Rob Herring, Krzysztof Kozlowski
Cc: Beomho Seo, Chanwoo Choi, Stephan Gerhold, Raymond Hackley,
Pavel Machek, Axel Lin, ChiYuan Huang, Linus Walleij,
Henrik Grimler, Christophe Jaillet, linux-pm, devicetree,
linux-kernel, phone-devel, ~postmarketos/upstreaming,
Jakob Hauser, Sebastian Reichel
Implement cable detection by extcon and handle the driver according to the
connector type.
There are basically three types of action: "set_charging", "set_otg" and
"set_disconnect".
A forth helper function to "unset_otg" was added because this is used in both
"set_charging" and "set_disconnect". In the first case it covers the rather
rare event that someone changes from OTG to charging without disconnect. In
the second case, when disconnecting, the values are set back to the ones from
initialization to return into a defined state.
Additionally, there is "set_mivr". When connecting to e.g. a laptop/PC, the
minimum input voltage regulation (MIVR) shall prevent a voltage drop if the
cable or the supply is weak. The MIVR value is set to 4600MV, same as in the
Android driver [1]. When disconnecting, MIVR is set back to DISABLED.
In the function rt5033_get_charger_state(): When in OTG mode, the chip
reports status "charging". Change this to "discharging" because there is
no charging going on in OTG mode [2].
[1] https://github.com/msm8916-mainline/linux-downstream/blob/GT-I9195I/drivers/battery/rt5033_charger.c#L499
[2] https://github.com/msm8916-mainline/linux-downstream/blob/GT-I9195I/drivers/battery/rt5033_charger.c#L686-L687
Tested-by: Raymond Hackley <raymondhackley@protonmail.com>
Signed-off-by: Jakob Hauser <jahau@rocketmail.com>
Acked-by: Sebastian Reichel <sebastian.reichel@collabora.com>
---
drivers/power/supply/rt5033_charger.c | 276 +++++++++++++++++++++++++-
1 file changed, 274 insertions(+), 2 deletions(-)
diff --git a/drivers/power/supply/rt5033_charger.c b/drivers/power/supply/rt5033_charger.c
index 5218dfbf5e1b..e0303ca5a8db 100644
--- a/drivers/power/supply/rt5033_charger.c
+++ b/drivers/power/supply/rt5033_charger.c
@@ -6,7 +6,10 @@
* Author: Beomho Seo <beomho.seo@samsung.com>
*/
+#include <linux/devm-helpers.h>
+#include <linux/extcon.h>
#include <linux/module.h>
+#include <linux/mutex.h>
#include <linux/of_device.h>
#include <linux/platform_device.h>
#include <linux/power_supply.h>
@@ -26,6 +29,14 @@ struct rt5033_charger {
struct regmap *regmap;
struct power_supply *psy;
struct rt5033_charger_data *chg;
+ struct extcon_dev *edev;
+ struct notifier_block extcon_nb;
+ struct work_struct extcon_work;
+ struct mutex lock;
+ bool online;
+ bool otg;
+ bool mivr_enabled;
+ u8 cv_regval;
};
static int rt5033_get_charger_state(struct rt5033_charger *charger)
@@ -56,6 +67,10 @@ static int rt5033_get_charger_state(struct rt5033_charger *charger)
state = POWER_SUPPLY_STATUS_UNKNOWN;
}
+ /* For OTG mode, RT5033 would still report "charging" */
+ if (charger->otg)
+ state = POWER_SUPPLY_STATUS_DISCHARGING;
+
return state;
}
@@ -147,6 +162,9 @@ static inline int rt5033_init_const_charge(struct rt5033_charger *charger)
return -EINVAL;
}
+ /* Store that value for later usage */
+ charger->cv_regval = reg_data;
+
/* Set end of charge current */
if (chg->eoc_uamp < RT5033_CHARGER_EOC_MIN ||
chg->eoc_uamp > RT5033_CHARGER_EOC_MAX) {
@@ -330,6 +348,152 @@ static int rt5033_charger_reg_init(struct rt5033_charger *charger)
return 0;
}
+static int rt5033_charger_set_otg(struct rt5033_charger *charger)
+{
+ int ret;
+
+ mutex_lock(&charger->lock);
+
+ /* Set OTG boost v_out to 5 volts */
+ ret = regmap_update_bits(charger->regmap, RT5033_REG_CHG_CTRL2,
+ RT5033_CHGCTRL2_CV_MASK,
+ 0x37 << RT5033_CHGCTRL2_CV_SHIFT);
+ if (ret) {
+ dev_err(charger->dev, "Failed set OTG boost v_out\n");
+ return -EINVAL;
+ }
+
+ /* Set operation mode to OTG */
+ ret = regmap_update_bits(charger->regmap, RT5033_REG_CHG_CTRL1,
+ RT5033_CHGCTRL1_MODE_MASK, RT5033_BOOST_MODE);
+ if (ret) {
+ dev_err(charger->dev, "Failed to update OTG mode.\n");
+ return -EINVAL;
+ }
+
+ /* In case someone switched from charging to OTG directly */
+ if (charger->online)
+ charger->online = false;
+
+ charger->otg = true;
+
+ mutex_unlock(&charger->lock);
+
+ return 0;
+}
+
+static int rt5033_charger_unset_otg(struct rt5033_charger *charger)
+{
+ int ret;
+ u8 data;
+
+ /* Restore constant voltage for charging */
+ data = charger->cv_regval;
+ ret = regmap_update_bits(charger->regmap, RT5033_REG_CHG_CTRL2,
+ RT5033_CHGCTRL2_CV_MASK,
+ data << RT5033_CHGCTRL2_CV_SHIFT);
+ if (ret) {
+ dev_err(charger->dev, "Failed to restore constant voltage\n");
+ return -EINVAL;
+ }
+
+ /* Set operation mode to charging */
+ ret = regmap_update_bits(charger->regmap, RT5033_REG_CHG_CTRL1,
+ RT5033_CHGCTRL1_MODE_MASK, RT5033_CHARGER_MODE);
+ if (ret) {
+ dev_err(charger->dev, "Failed to update charger mode.\n");
+ return -EINVAL;
+ }
+
+ charger->otg = false;
+
+ return 0;
+}
+
+static int rt5033_charger_set_charging(struct rt5033_charger *charger)
+{
+ int ret;
+
+ mutex_lock(&charger->lock);
+
+ /* In case someone switched from OTG to charging directly */
+ if (charger->otg) {
+ ret = rt5033_charger_unset_otg(charger);
+ if (ret)
+ return -EINVAL;
+ }
+
+ charger->online = true;
+
+ mutex_unlock(&charger->lock);
+
+ return 0;
+}
+
+static int rt5033_charger_set_mivr(struct rt5033_charger *charger)
+{
+ int ret;
+
+ mutex_lock(&charger->lock);
+
+ /*
+ * When connected via USB connector type SDP (Standard Downstream Port),
+ * the minimum input voltage regulation (MIVR) should be enabled. It
+ * prevents an input voltage drop due to insufficient current provided
+ * by the adapter or USB input. As a downside, it may reduces the
+ * charging current and thus slows the charging.
+ */
+ ret = regmap_update_bits(charger->regmap, RT5033_REG_CHG_CTRL4,
+ RT5033_CHGCTRL4_MIVR_MASK, RT5033_CHARGER_MIVR_4600MV);
+ if (ret) {
+ dev_err(charger->dev, "Failed to set MIVR level.\n");
+ return -EINVAL;
+ }
+
+ charger->mivr_enabled = true;
+
+ mutex_unlock(&charger->lock);
+
+ /* Beyond this, do the same steps like setting charging */
+ rt5033_charger_set_charging(charger);
+
+ return 0;
+}
+
+static int rt5033_charger_set_disconnect(struct rt5033_charger *charger)
+{
+ int ret;
+
+ mutex_lock(&charger->lock);
+
+ /* Disable MIVR if enabled */
+ if (charger->mivr_enabled) {
+ ret = regmap_update_bits(charger->regmap,
+ RT5033_REG_CHG_CTRL4,
+ RT5033_CHGCTRL4_MIVR_MASK,
+ RT5033_CHARGER_MIVR_DISABLE);
+ if (ret) {
+ dev_err(charger->dev, "Failed to disable MIVR.\n");
+ return -EINVAL;
+ }
+
+ charger->mivr_enabled = false;
+ }
+
+ if (charger->otg) {
+ ret = rt5033_charger_unset_otg(charger);
+ if (ret)
+ return -EINVAL;
+ }
+
+ if (charger->online)
+ charger->online = false;
+
+ mutex_unlock(&charger->lock);
+
+ return 0;
+}
+
static enum power_supply_property rt5033_charger_props[] = {
POWER_SUPPLY_PROP_STATUS,
POWER_SUPPLY_PROP_CHARGE_TYPE,
@@ -366,8 +530,7 @@ static int rt5033_charger_get_property(struct power_supply *psy,
val->strval = RT5033_MANUFACTURER;
break;
case POWER_SUPPLY_PROP_ONLINE:
- val->intval = (rt5033_get_charger_state(charger) ==
- POWER_SUPPLY_STATUS_CHARGING);
+ val->intval = charger->online;
break;
default:
return -EINVAL;
@@ -402,6 +565,86 @@ static struct rt5033_charger_data *rt5033_charger_dt_init(
return chg;
}
+static void rt5033_charger_extcon_work(struct work_struct *work)
+{
+ struct rt5033_charger *charger =
+ container_of(work, struct rt5033_charger, extcon_work);
+ struct extcon_dev *edev = charger->edev;
+ int connector, state;
+ int ret;
+
+ for (connector = EXTCON_USB_HOST; connector <= EXTCON_CHG_USB_PD;
+ connector++) {
+ state = extcon_get_state(edev, connector);
+ if (state == 1)
+ break;
+ }
+
+ /*
+ * Adding a delay between extcon notification and extcon action. This
+ * makes extcon action execution more reliable. Without the delay the
+ * execution sometimes fails, possibly because the chip is busy or not
+ * ready.
+ */
+ msleep(100);
+
+ switch (connector) {
+ case EXTCON_CHG_USB_SDP:
+ ret = rt5033_charger_set_mivr(charger);
+ if (ret) {
+ dev_err(charger->dev, "failed to set USB mode\n");
+ break;
+ }
+ dev_info(charger->dev, "USB mode. connector type: %d\n",
+ connector);
+ break;
+ case EXTCON_CHG_USB_DCP:
+ case EXTCON_CHG_USB_CDP:
+ case EXTCON_CHG_USB_ACA:
+ case EXTCON_CHG_USB_FAST:
+ case EXTCON_CHG_USB_SLOW:
+ case EXTCON_CHG_WPT:
+ case EXTCON_CHG_USB_PD:
+ ret = rt5033_charger_set_charging(charger);
+ if (ret) {
+ dev_err(charger->dev, "failed to set charging\n");
+ break;
+ }
+ dev_info(charger->dev, "charging. connector type: %d\n",
+ connector);
+ break;
+ case EXTCON_USB_HOST:
+ ret = rt5033_charger_set_otg(charger);
+ if (ret) {
+ dev_err(charger->dev, "failed to set OTG\n");
+ break;
+ }
+ dev_info(charger->dev, "OTG enabled\n");
+ break;
+ default:
+ ret = rt5033_charger_set_disconnect(charger);
+ if (ret) {
+ dev_err(charger->dev, "failed to set disconnect\n");
+ break;
+ }
+ dev_info(charger->dev, "disconnected\n");
+ break;
+ }
+
+ power_supply_changed(charger->psy);
+}
+
+static int rt5033_charger_extcon_notifier(struct notifier_block *nb,
+ unsigned long event, void *param)
+{
+ struct rt5033_charger *charger =
+ container_of(nb, struct rt5033_charger, extcon_nb);
+
+ schedule_work(&charger->extcon_work);
+
+ return NOTIFY_OK;
+}
+
static const struct power_supply_desc rt5033_charger_desc = {
.name = "rt5033-charger",
.type = POWER_SUPPLY_TYPE_USB,
@@ -414,6 +657,7 @@ static int rt5033_charger_probe(struct platform_device *pdev)
{
struct rt5033_charger *charger;
struct power_supply_config psy_cfg = {};
+ struct device_node *np_conn, *np_edev;
int ret;
charger = devm_kzalloc(&pdev->dev, sizeof(*charger), GFP_KERNEL);
@@ -423,6 +667,7 @@ static int rt5033_charger_probe(struct platform_device *pdev)
platform_set_drvdata(pdev, charger);
charger->dev = &pdev->dev;
charger->regmap = dev_get_regmap(pdev->dev.parent, NULL);
+ mutex_init(&charger->lock);
psy_cfg.of_node = pdev->dev.of_node;
psy_cfg.drv_data = charger;
@@ -442,6 +687,33 @@ static int rt5033_charger_probe(struct platform_device *pdev)
if (ret)
return ret;
+ /*
+ * Extcon support is not vital for the charger to work. If no extcon
+ * is available, just emit a warning and leave the probe function.
+ */
+ np_conn = of_parse_phandle(pdev->dev.of_node, "richtek,usb-connector", 0);
+ np_edev = of_get_parent(np_conn);
+ charger->edev = extcon_find_edev_by_node(np_edev);
+ if (IS_ERR(charger->edev)) {
+ dev_warn(&pdev->dev, "no extcon device found in device-tree\n");
+ goto out;
+ }
+
+ ret = devm_work_autocancel(&pdev->dev, &charger->extcon_work,
+ rt5033_charger_extcon_work);
+ if (ret) {
+ dev_err(&pdev->dev, "failed to initialize extcon work\n");
+ return ret;
+ }
+
+ charger->extcon_nb.notifier_call = rt5033_charger_extcon_notifier;
+ ret = devm_extcon_register_notifier_all(&pdev->dev, charger->edev,
+ &charger->extcon_nb);
+ if (ret) {
+ dev_err(&pdev->dev, "failed to register extcon notifier\n");
+ return ret;
+ }
+out:
return 0;
}
--
2.39.2
^ permalink raw reply related [flat|nested] 27+ messages in thread
* [PATCH v6 07/10 RESEND] power: supply: rt5033_battery: Move struct rt5033_battery to battery driver
2023-05-15 20:57 ` [PATCH v6 00/10 RESEND] Add RT5033 charger device driver Jakob Hauser
` (5 preceding siblings ...)
2023-05-15 20:57 ` [PATCH v6 06/10 RESEND] power: supply: rt5033_charger: Add cable detection and USB OTG supply Jakob Hauser
@ 2023-05-15 20:57 ` Jakob Hauser
2023-05-15 20:57 ` [PATCH v6 08/10 RESEND] power: supply: rt5033_battery: Adopt status property from charger Jakob Hauser
` (5 subsequent siblings)
12 siblings, 0 replies; 27+ messages in thread
From: Jakob Hauser @ 2023-05-15 20:57 UTC (permalink / raw)
To: Sebastian Reichel, Lee Jones, Liam Girdwood, Mark Brown,
Rob Herring, Krzysztof Kozlowski
Cc: Beomho Seo, Chanwoo Choi, Stephan Gerhold, Raymond Hackley,
Pavel Machek, Axel Lin, ChiYuan Huang, Linus Walleij,
Henrik Grimler, Christophe Jaillet, linux-pm, devicetree,
linux-kernel, phone-devel, ~postmarketos/upstreaming,
Jakob Hauser, Sebastian Reichel
Move struct rt5033_battery from the mfd header into the battery driver because
it's not used by others.
Within struct rt5033_battery, remove the line "struct rt5033_dev *rt5033;"
because it doesn't get used.
In rt5033.h, remove #include <linux/power_supply.h>, it's not necessary
anymore.
In rt5033_battery.c, remove #include <linux/mfd/rt5033.h>, it's not necessary
anymore either. Instead add #include <linux/regmap.h> and
Signed-off-by: Jakob Hauser <jahau@rocketmail.com>
Acked-by: Sebastian Reichel <sebastian.reichel@collabora.com>
---
drivers/power/supply/rt5033_battery.c | 9 ++++++++-
include/linux/mfd/rt5033.h | 8 --------
2 files changed, 8 insertions(+), 9 deletions(-)
diff --git a/drivers/power/supply/rt5033_battery.c b/drivers/power/supply/rt5033_battery.c
index 5c04cf305219..91e1efd81f69 100644
--- a/drivers/power/supply/rt5033_battery.c
+++ b/drivers/power/supply/rt5033_battery.c
@@ -6,11 +6,18 @@
* Author: Beomho Seo <beomho.seo@samsung.com>
*/
+#include <linux/i2c.h>
#include <linux/module.h>
#include <linux/platform_device.h>
#include <linux/power_supply.h>
+#include <linux/regmap.h>
#include <linux/mfd/rt5033-private.h>
-#include <linux/mfd/rt5033.h>
+
+struct rt5033_battery {
+ struct i2c_client *client;
+ struct regmap *regmap;
+ struct power_supply *psy;
+};
static int rt5033_battery_get_capacity(struct i2c_client *client)
{
diff --git a/include/linux/mfd/rt5033.h b/include/linux/mfd/rt5033.h
index 3992fb2ef0a8..bb3d18945d21 100644
--- a/include/linux/mfd/rt5033.h
+++ b/include/linux/mfd/rt5033.h
@@ -12,7 +12,6 @@
#include <linux/regulator/consumer.h>
#include <linux/i2c.h>
#include <linux/regmap.h>
-#include <linux/power_supply.h>
/* RT5033 regulator IDs */
enum rt5033_regulators {
@@ -32,11 +31,4 @@ struct rt5033_dev {
bool wakeup;
};
-struct rt5033_battery {
- struct i2c_client *client;
- struct rt5033_dev *rt5033;
- struct regmap *regmap;
- struct power_supply *psy;
-};
-
#endif /* __RT5033_H__ */
--
2.39.2
^ permalink raw reply related [flat|nested] 27+ messages in thread
* [PATCH v6 08/10 RESEND] power: supply: rt5033_battery: Adopt status property from charger
2023-05-15 20:57 ` [PATCH v6 00/10 RESEND] Add RT5033 charger device driver Jakob Hauser
` (6 preceding siblings ...)
2023-05-15 20:57 ` [PATCH v6 07/10 RESEND] power: supply: rt5033_battery: Move struct rt5033_battery to battery driver Jakob Hauser
@ 2023-05-15 20:57 ` Jakob Hauser
2023-05-15 20:57 ` [PATCH v6 09/10 RESEND] dt-bindings: power: supply: rt5033-battery: Apply unevaluatedProperties Jakob Hauser
` (4 subsequent siblings)
12 siblings, 0 replies; 27+ messages in thread
From: Jakob Hauser @ 2023-05-15 20:57 UTC (permalink / raw)
To: Sebastian Reichel, Lee Jones, Liam Girdwood, Mark Brown,
Rob Herring, Krzysztof Kozlowski
Cc: Beomho Seo, Chanwoo Choi, Stephan Gerhold, Raymond Hackley,
Pavel Machek, Axel Lin, ChiYuan Huang, Linus Walleij,
Henrik Grimler, Christophe Jaillet, linux-pm, devicetree,
linux-kernel, phone-devel, ~postmarketos/upstreaming,
Jakob Hauser, Sebastian Reichel
The rt5033-battery fuelgauge can't get a status by itself. The rt5033-charger
can, let's get this value.
To get the charger as a "supplier" from the devicetree, the "of_node" needs
to be initiated.
Additionally, in the probe function replace dev_err() with dev_err_probe(),
this will avoid printing an error for -EPROBE_DEFER when the battery driver
probes before the charger driver.
Signed-off-by: Jakob Hauser <jahau@rocketmail.com>
Acked-by: Sebastian Reichel <sebastian.reichel@collabora.com>
---
drivers/power/supply/rt5033_battery.c | 29 +++++++++++++++++++++------
1 file changed, 23 insertions(+), 6 deletions(-)
diff --git a/drivers/power/supply/rt5033_battery.c b/drivers/power/supply/rt5033_battery.c
index 91e1efd81f69..94d2dea7ef5e 100644
--- a/drivers/power/supply/rt5033_battery.c
+++ b/drivers/power/supply/rt5033_battery.c
@@ -19,6 +19,21 @@ struct rt5033_battery {
struct power_supply *psy;
};
+static int rt5033_battery_get_status(struct i2c_client *client)
+{
+ struct rt5033_battery *battery = i2c_get_clientdata(client);
+ union power_supply_propval val;
+ int ret;
+
+ ret = power_supply_get_property_from_supplier(battery->psy,
+ POWER_SUPPLY_PROP_STATUS,
+ &val);
+ if (ret)
+ val.intval = POWER_SUPPLY_STATUS_UNKNOWN;
+
+ return val.intval;
+}
+
static int rt5033_battery_get_capacity(struct i2c_client *client)
{
struct rt5033_battery *battery = i2c_get_clientdata(client);
@@ -91,6 +106,9 @@ static int rt5033_battery_get_property(struct power_supply *psy,
case POWER_SUPPLY_PROP_CAPACITY:
val->intval = rt5033_battery_get_capacity(battery->client);
break;
+ case POWER_SUPPLY_PROP_STATUS:
+ val->intval = rt5033_battery_get_status(battery->client);
+ break;
default:
return -EINVAL;
}
@@ -103,6 +121,7 @@ static enum power_supply_property rt5033_battery_props[] = {
POWER_SUPPLY_PROP_VOLTAGE_OCV,
POWER_SUPPLY_PROP_PRESENT,
POWER_SUPPLY_PROP_CAPACITY,
+ POWER_SUPPLY_PROP_STATUS,
};
static const struct regmap_config rt5033_battery_regmap_config = {
@@ -124,7 +143,6 @@ static int rt5033_battery_probe(struct i2c_client *client)
struct i2c_adapter *adapter = client->adapter;
struct power_supply_config psy_cfg = {};
struct rt5033_battery *battery;
- u32 ret;
if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE))
return -EIO;
@@ -142,15 +160,14 @@ static int rt5033_battery_probe(struct i2c_client *client)
}
i2c_set_clientdata(client, battery);
+ psy_cfg.of_node = client->dev.of_node;
psy_cfg.drv_data = battery;
battery->psy = power_supply_register(&client->dev,
&rt5033_battery_desc, &psy_cfg);
- if (IS_ERR(battery->psy)) {
- dev_err(&client->dev, "Failed to register power supply\n");
- ret = PTR_ERR(battery->psy);
- return ret;
- }
+ if (IS_ERR(battery->psy))
+ return dev_err_probe(&client->dev, PTR_ERR(battery->psy),
+ "Failed to register power supply\n");
return 0;
}
--
2.39.2
^ permalink raw reply related [flat|nested] 27+ messages in thread
* [PATCH v6 09/10 RESEND] dt-bindings: power: supply: rt5033-battery: Apply unevaluatedProperties
2023-05-15 20:57 ` [PATCH v6 00/10 RESEND] Add RT5033 charger device driver Jakob Hauser
` (7 preceding siblings ...)
2023-05-15 20:57 ` [PATCH v6 08/10 RESEND] power: supply: rt5033_battery: Adopt status property from charger Jakob Hauser
@ 2023-05-15 20:57 ` Jakob Hauser
2023-05-15 21:30 ` Sebastian Reichel
2023-05-16 21:28 ` Conor Dooley
2023-05-15 20:57 ` [PATCH v6 10/10 RESEND] dt-bindings: Add rt5033 mfd, regulator and charger Jakob Hauser
` (3 subsequent siblings)
12 siblings, 2 replies; 27+ messages in thread
From: Jakob Hauser @ 2023-05-15 20:57 UTC (permalink / raw)
To: Sebastian Reichel, Lee Jones, Liam Girdwood, Mark Brown,
Rob Herring, Krzysztof Kozlowski
Cc: Beomho Seo, Chanwoo Choi, Stephan Gerhold, Raymond Hackley,
Pavel Machek, Axel Lin, ChiYuan Huang, Linus Walleij,
Henrik Grimler, Christophe Jaillet, linux-pm, devicetree,
linux-kernel, phone-devel, ~postmarketos/upstreaming,
Jakob Hauser
Additionally to the already available ref "power-supply.yaml", replace
"additionalProperties: false" by "unevaluatedProperties: false". Otherwise,
when referencing rt5033-battery in an example, message "'power-supplies' does
not match any of the regexes: 'pinctrl-[0-9]+'" will be returned.
Signed-off-by: Jakob Hauser <jahau@rocketmail.com>
---
.../bindings/power/supply/richtek,rt5033-battery.yaml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/Documentation/devicetree/bindings/power/supply/richtek,rt5033-battery.yaml b/Documentation/devicetree/bindings/power/supply/richtek,rt5033-battery.yaml
index 756c16d1727d..b5d8888d03d2 100644
--- a/Documentation/devicetree/bindings/power/supply/richtek,rt5033-battery.yaml
+++ b/Documentation/devicetree/bindings/power/supply/richtek,rt5033-battery.yaml
@@ -26,7 +26,7 @@ required:
- compatible
- reg
-additionalProperties: false
+unevaluatedProperties: false
examples:
- |
--
2.39.2
^ permalink raw reply related [flat|nested] 27+ messages in thread
* [PATCH v6 10/10 RESEND] dt-bindings: Add rt5033 mfd, regulator and charger
2023-05-15 20:57 ` [PATCH v6 00/10 RESEND] Add RT5033 charger device driver Jakob Hauser
` (8 preceding siblings ...)
2023-05-15 20:57 ` [PATCH v6 09/10 RESEND] dt-bindings: power: supply: rt5033-battery: Apply unevaluatedProperties Jakob Hauser
@ 2023-05-15 20:57 ` Jakob Hauser
[not found] ` <a308cd6f-0f72-6a12-aa34-ce06290ce0bb@rocketmail.com>
` (2 subsequent siblings)
12 siblings, 0 replies; 27+ messages in thread
From: Jakob Hauser @ 2023-05-15 20:57 UTC (permalink / raw)
To: Sebastian Reichel, Lee Jones, Liam Girdwood, Mark Brown,
Rob Herring, Krzysztof Kozlowski
Cc: Beomho Seo, Chanwoo Choi, Stephan Gerhold, Raymond Hackley,
Pavel Machek, Axel Lin, ChiYuan Huang, Linus Walleij,
Henrik Grimler, Christophe Jaillet, linux-pm, devicetree,
linux-kernel, phone-devel, ~postmarketos/upstreaming,
Jakob Hauser, Krzysztof Kozlowski
Add device tree binding documentation for rt5033 multifunction device, voltage
regulator and battery charger.
Cc: Beomho Seo <beomho.seo@samsung.com>
Cc: Chanwoo Choi <cw00.choi@samsung.com>
Signed-off-by: Jakob Hauser <jahau@rocketmail.com>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
---
.../bindings/mfd/richtek,rt5033.yaml | 138 ++++++++++++++++++
.../power/supply/richtek,rt5033-charger.yaml | 65 +++++++++
2 files changed, 203 insertions(+)
create mode 100644 Documentation/devicetree/bindings/mfd/richtek,rt5033.yaml
create mode 100644 Documentation/devicetree/bindings/power/supply/richtek,rt5033-charger.yaml
diff --git a/Documentation/devicetree/bindings/mfd/richtek,rt5033.yaml b/Documentation/devicetree/bindings/mfd/richtek,rt5033.yaml
new file mode 100644
index 000000000000..386b1a50158a
--- /dev/null
+++ b/Documentation/devicetree/bindings/mfd/richtek,rt5033.yaml
@@ -0,0 +1,138 @@
+# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/mfd/richtek,rt5033.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Richtek RT5033 Power Management Integrated Circuit
+
+maintainers:
+ - Jakob Hauser <jahau@rocketmail.com>
+
+description:
+ RT5033 is a multifunction device which includes battery charger, fuel gauge,
+ flash LED current source, LDO and synchronous Buck converter for portable
+ applications. It is interfaced to host controller using I2C interface. The
+ battery fuel gauge uses a separate I2C bus.
+
+properties:
+ compatible:
+ const: richtek,rt5033
+
+ reg:
+ maxItems: 1
+
+ interrupts:
+ maxItems: 1
+
+ regulators:
+ description:
+ The regulators of RT5033 have to be instantiated under a sub-node named
+ "regulators". For SAFE_LDO voltage there is only one value of 4.9 V. LDO
+ voltage ranges from 1.2 V to 3.0 V in 0.1 V steps. BUCK voltage ranges
+ from 1.0 V to 3.0 V in 0.1 V steps.
+ type: object
+ patternProperties:
+ "^(SAFE_LDO|LDO|BUCK)$":
+ type: object
+ $ref: /schemas/regulator/regulator.yaml#
+ unevaluatedProperties: false
+ additionalProperties: false
+
+ charger:
+ type: object
+ $ref: /schemas/power/supply/richtek,rt5033-charger.yaml#
+
+required:
+ - compatible
+ - reg
+ - interrupts
+
+additionalProperties: false
+
+examples:
+ - |
+ #include <dt-bindings/interrupt-controller/irq.h>
+
+ battery: battery {
+ compatible = "simple-battery";
+ precharge-current-microamp = <450000>;
+ constant-charge-current-max-microamp = <1000000>;
+ charge-term-current-microamp = <150000>;
+ precharge-upper-limit-microvolt = <3500000>;
+ constant-charge-voltage-max-microvolt = <4350000>;
+ };
+
+ extcon {
+ usb_con: connector {
+ compatible = "usb-b-connector";
+ label = "micro-USB";
+ type = "micro";
+ };
+ };
+
+ i2c {
+ #address-cells = <1>;
+ #size-cells = <0>;
+
+ i2c@0 {
+ #address-cells = <1>;
+ #size-cells = <0>;
+ reg = <0>;
+
+ fuel-gauge@35 {
+ compatible = "richtek,rt5033-battery";
+ reg = <0x35>;
+
+ interrupt-parent = <&msmgpio>;
+ interrupts = <121 IRQ_TYPE_EDGE_FALLING>;
+
+ pinctrl-names = "default";
+ pinctrl-0 = <&fg_alert_default>;
+
+ power-supplies = <&rt5033_charger>;
+ };
+ };
+
+ i2c@1 {
+ #address-cells = <1>;
+ #size-cells = <0>;
+ reg = <1>;
+
+ pmic@34 {
+ compatible = "richtek,rt5033";
+ reg = <0x34>;
+
+ interrupt-parent = <&msmgpio>;
+ interrupts = <62 IRQ_TYPE_EDGE_FALLING>;
+
+ pinctrl-names = "default";
+ pinctrl-0 = <&pmic_int_default>;
+
+ regulators {
+ safe_ldo_reg: SAFE_LDO {
+ regulator-name = "SAFE_LDO";
+ regulator-min-microvolt = <4900000>;
+ regulator-max-microvolt = <4900000>;
+ regulator-always-on;
+ };
+ ldo_reg: LDO {
+ regulator-name = "LDO";
+ regulator-min-microvolt = <2800000>;
+ regulator-max-microvolt = <2800000>;
+ };
+ buck_reg: BUCK {
+ regulator-name = "BUCK";
+ regulator-min-microvolt = <1200000>;
+ regulator-max-microvolt = <1200000>;
+ };
+ };
+
+ rt5033_charger: charger {
+ compatible = "richtek,rt5033-charger";
+ monitored-battery = <&battery>;
+ richtek,usb-connector = <&usb_con>;
+ };
+ };
+ };
+ };
diff --git a/Documentation/devicetree/bindings/power/supply/richtek,rt5033-charger.yaml b/Documentation/devicetree/bindings/power/supply/richtek,rt5033-charger.yaml
new file mode 100644
index 000000000000..5b3edd79a523
--- /dev/null
+++ b/Documentation/devicetree/bindings/power/supply/richtek,rt5033-charger.yaml
@@ -0,0 +1,65 @@
+# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/power/supply/richtek,rt5033-charger.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Richtek RT5033 PMIC Battery Charger
+
+maintainers:
+ - Jakob Hauser <jahau@rocketmail.com>
+
+description:
+ The battery charger of the multifunction device RT5033 has to be instantiated
+ under sub-node named "charger" using the following format.
+
+properties:
+ compatible:
+ const: richtek,rt5033-charger
+
+ monitored-battery:
+ $ref: /schemas/types.yaml#/definitions/phandle
+ description: |
+ Phandle to the monitored battery according to battery.yaml. The battery
+ node needs to contain five parameters.
+
+ precharge-current-microamp:
+ Current of pre-charge mode. The pre-charge current levels are 350 mA
+ to 650 mA programmed by I2C per 100 mA.
+
+ constant-charge-current-max-microamp:
+ Current of fast-charge mode. The fast-charge current levels are 700 mA
+ to 2000 mA programmed by I2C per 100 mA.
+
+ charge-term-current-microamp:
+ This property is end of charge current. Its level ranges from 150 mA
+ to 600 mA. Between 150 mA and 300 mA in 50 mA steps, between 300 mA and
+ 600 mA in 100 mA steps.
+
+ precharge-upper-limit-microvolt:
+ Voltage of pre-charge mode. If the battery voltage is below the pre-charge
+ threshold voltage, the charger is in pre-charge mode with pre-charge
+ current. Its levels are 2.3 V to 3.8 V programmed by I2C per 0.1 V.
+
+ constant-charge-voltage-max-microvolt:
+ Battery regulation voltage of constant voltage mode. This voltage levels
+ from 3.65 V to 4.4 V by I2C per 0.025 V.
+
+ richtek,usb-connector:
+ $ref: /schemas/types.yaml#/definitions/phandle
+ description:
+ Phandle to a USB connector according to usb-connector.yaml. The connector
+ should be a child of the extcon device.
+
+required:
+ - monitored-battery
+
+additionalProperties: false
+
+examples:
+ - |
+ charger {
+ compatible = "richtek,rt5033-charger";
+ monitored-battery = <&battery>;
+ richtek,usb-connector = <&usb_con>;
+ };
--
2.39.2
^ permalink raw reply related [flat|nested] 27+ messages in thread
* Re: [PATCH v6 09/10 RESEND] dt-bindings: power: supply: rt5033-battery: Apply unevaluatedProperties
2023-05-15 20:57 ` [PATCH v6 09/10 RESEND] dt-bindings: power: supply: rt5033-battery: Apply unevaluatedProperties Jakob Hauser
@ 2023-05-15 21:30 ` Sebastian Reichel
2023-05-16 21:28 ` Conor Dooley
1 sibling, 0 replies; 27+ messages in thread
From: Sebastian Reichel @ 2023-05-15 21:30 UTC (permalink / raw)
To: Jakob Hauser
Cc: Lee Jones, Liam Girdwood, Mark Brown, Rob Herring,
Krzysztof Kozlowski, Beomho Seo, Chanwoo Choi, Stephan Gerhold,
Raymond Hackley, Pavel Machek, Axel Lin, ChiYuan Huang,
Linus Walleij, Henrik Grimler, Christophe Jaillet, linux-pm,
devicetree, linux-kernel, phone-devel, ~postmarketos/upstreaming
[-- Attachment #1: Type: text/plain, Size: 1211 bytes --]
Hi,
On Mon, May 15, 2023 at 10:57:18PM +0200, Jakob Hauser wrote:
> Additionally to the already available ref "power-supply.yaml", replace
> "additionalProperties: false" by "unevaluatedProperties: false". Otherwise,
> when referencing rt5033-battery in an example, message "'power-supplies' does
> not match any of the regexes: 'pinctrl-[0-9]+'" will be returned.
>
> Signed-off-by: Jakob Hauser <jahau@rocketmail.com>
Acked-by: Sebastian Reichel <sebastian.reichel@collabora.com>
-- Sebastian
> ---
> .../bindings/power/supply/richtek,rt5033-battery.yaml | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/Documentation/devicetree/bindings/power/supply/richtek,rt5033-battery.yaml b/Documentation/devicetree/bindings/power/supply/richtek,rt5033-battery.yaml
> index 756c16d1727d..b5d8888d03d2 100644
> --- a/Documentation/devicetree/bindings/power/supply/richtek,rt5033-battery.yaml
> +++ b/Documentation/devicetree/bindings/power/supply/richtek,rt5033-battery.yaml
> @@ -26,7 +26,7 @@ required:
> - compatible
> - reg
>
> -additionalProperties: false
> +unevaluatedProperties: false
>
> examples:
> - |
> --
> 2.39.2
>
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: [PATCH v6 09/10 RESEND] dt-bindings: power: supply: rt5033-battery: Apply unevaluatedProperties
2023-05-15 20:57 ` [PATCH v6 09/10 RESEND] dt-bindings: power: supply: rt5033-battery: Apply unevaluatedProperties Jakob Hauser
2023-05-15 21:30 ` Sebastian Reichel
@ 2023-05-16 21:28 ` Conor Dooley
1 sibling, 0 replies; 27+ messages in thread
From: Conor Dooley @ 2023-05-16 21:28 UTC (permalink / raw)
To: Jakob Hauser
Cc: Sebastian Reichel, Lee Jones, Liam Girdwood, Mark Brown,
Rob Herring, Krzysztof Kozlowski, Beomho Seo, Chanwoo Choi,
Stephan Gerhold, Raymond Hackley, Pavel Machek, Axel Lin,
ChiYuan Huang, Linus Walleij, Henrik Grimler, Christophe Jaillet,
linux-pm, devicetree, linux-kernel, phone-devel,
~postmarketos/upstreaming
[-- Attachment #1: Type: text/plain, Size: 498 bytes --]
On Mon, May 15, 2023 at 10:57:18PM +0200, Jakob Hauser wrote:
> Additionally to the already available ref "power-supply.yaml", replace
> "additionalProperties: false" by "unevaluatedProperties: false". Otherwise,
> when referencing rt5033-battery in an example, message "'power-supplies' does
> not match any of the regexes: 'pinctrl-[0-9]+'" will be returned.
>
> Signed-off-by: Jakob Hauser <jahau@rocketmail.com>
Acked-by: Conor Dooley <conor.dooley@microchip.com>
Thanks,
Conor.
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]
^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: [PATCH v6 04/10 RESEND] mfd: rt5033: Apply preparatory changes before adding rt5033-charger driver
2023-05-15 20:57 ` [PATCH v6 04/10 RESEND] mfd: rt5033: Apply preparatory changes before adding rt5033-charger driver Jakob Hauser
@ 2023-05-25 10:44 ` Lee Jones
2023-05-25 17:16 ` Jakob Hauser
0 siblings, 1 reply; 27+ messages in thread
From: Lee Jones @ 2023-05-25 10:44 UTC (permalink / raw)
To: Jakob Hauser
Cc: Sebastian Reichel, Liam Girdwood, Mark Brown, Rob Herring,
Krzysztof Kozlowski, Beomho Seo, Chanwoo Choi, Stephan Gerhold,
Raymond Hackley, Pavel Machek, Axel Lin, ChiYuan Huang,
Linus Walleij, Henrik Grimler, Christophe Jaillet, linux-pm,
devicetree, linux-kernel, phone-devel, ~postmarketos/upstreaming
On Mon, 15 May 2023, Jakob Hauser wrote:
> Order the register blocks to have the masks in descending manner.
>
> Add new defines for constant voltage shift (RT5033_CHGCTRL2_CV_SHIFT),
> MIVR mask (RT5033_CHGCTRL4_MIVR_MASK), pre-charge current shift
> (RT5033_CHGCTRL4_IPREC_SHIFT), internal timer disable
> (RT5033_INT_TIMER_DISABLE), termination disable (RT5033_TE_DISABLE),
> CFO disable (RT5033_CFO_DISABLE), UUG disable (RT5033_CHARGER_UUG_DISABLE).
>
> The fast charge timer type needs to be written on mask 0x38
> (RT5033_CHGCTRL3_TIMER_MASK). To avoid a bit shift on application, change the
> values of the timer types to fit the mask. Added the timout duration as a
> comment. And the timer between TIMER8 and TIMER12 is most likely TIMER10, see
> e.g. RT5036 [1] page 28 bottom.
>
> Add value options for MIVR (Minimum Input Voltage Regulation).
>
> Move RT5033_TE_ENABLE_MASK to the block "RT5033 CHGCTRL1 register", in order
> to have the masks of the register collected there. To fit the naming scheme,
> rename it to RT5033_CHGCTRL1_TE_EN_MASK.
>
> Move RT5033_CHG_MAX_CURRENT to the block "RT5033 charger fast-charge current".
>
> Add new defines RT5033_CV_MAX_VOLTAGE and RT5033_CHG_MAX_PRE_CURRENT to the
> blocks "RT5033 charger constant charge voltage" and "RT5033 charger pre-charge
> current limits".
>
> In include/linux/mfd/rt5033.h, turn power_supply "psy" into a pointer in order
> to use it in devm_power_supply_register().
>
> [1] https://media.digikey.com/pdf/Data%20Sheets/Richtek%20PDF/RT5036%20%20Preliminary.pdf
>
> Signed-off-by: Jakob Hauser <jahau@rocketmail.com>
> ---
> include/linux/mfd/rt5033-private.h | 53 ++++++++++++++++++++----------
> include/linux/mfd/rt5033.h | 2 +-
> 2 files changed, 36 insertions(+), 19 deletions(-)
>
> diff --git a/include/linux/mfd/rt5033-private.h b/include/linux/mfd/rt5033-private.h
> index b6773ebf4e6b..0221f806d139 100644
> --- a/include/linux/mfd/rt5033-private.h
> +++ b/include/linux/mfd/rt5033-private.h
> @@ -55,22 +55,24 @@ enum rt5033_reg {
> };
>
> /* RT5033 Charger state register */
> +#define RT5033_CHG_STAT_TYPE_MASK 0x60
> +#define RT5033_CHG_STAT_TYPE_PRE 0x20
> +#define RT5033_CHG_STAT_TYPE_FAST 0x60
> #define RT5033_CHG_STAT_MASK 0x30
> #define RT5033_CHG_STAT_DISCHARGING 0x00
> #define RT5033_CHG_STAT_FULL 0x10
> #define RT5033_CHG_STAT_CHARGING 0x20
> #define RT5033_CHG_STAT_NOT_CHARGING 0x30
> -#define RT5033_CHG_STAT_TYPE_MASK 0x60
> -#define RT5033_CHG_STAT_TYPE_PRE 0x20
> -#define RT5033_CHG_STAT_TYPE_FAST 0x60
>
> /* RT5033 CHGCTRL1 register */
> #define RT5033_CHGCTRL1_IAICR_MASK 0xe0
> -#define RT5033_CHGCTRL1_MODE_MASK 0x01
> +#define RT5033_CHGCTRL1_TE_EN_MASK 0x08
> #define RT5033_CHGCTRL1_HZ_MASK 0x02
> +#define RT5033_CHGCTRL1_MODE_MASK 0x01
>
> /* RT5033 CHGCTRL2 register */
> #define RT5033_CHGCTRL2_CV_MASK 0xfc
> +#define RT5033_CHGCTRL2_CV_SHIFT 0x02
>
> /* RT5033 DEVICE_ID register */
> #define RT5033_VENDOR_ID_MASK 0xf0
> @@ -82,14 +84,15 @@ enum rt5033_reg {
> #define RT5033_CHGCTRL3_TIMER_EN_MASK 0x01
>
> /* RT5033 CHGCTRL4 register */
> -#define RT5033_CHGCTRL4_EOC_MASK 0x07
> +#define RT5033_CHGCTRL4_MIVR_MASK 0xe0
> #define RT5033_CHGCTRL4_IPREC_MASK 0x18
> +#define RT5033_CHGCTRL4_IPREC_SHIFT 0x03
> +#define RT5033_CHGCTRL4_EOC_MASK 0x07
>
> /* RT5033 CHGCTRL5 register */
> -#define RT5033_CHGCTRL5_VPREC_MASK 0x0f
> #define RT5033_CHGCTRL5_ICHG_MASK 0xf0
> #define RT5033_CHGCTRL5_ICHG_SHIFT 0x04
> -#define RT5033_CHG_MAX_CURRENT 0x0d
> +#define RT5033_CHGCTRL5_VPREC_MASK 0x0f
>
> /* RT5033 RT CTRL1 register */
> #define RT5033_RT_CTRL1_UUG_MASK 0x02
> @@ -128,20 +131,28 @@ enum rt5033_reg {
> #define RT5033_AICR_1500_MODE 0xc0
> #define RT5033_AICR_2000_MODE 0xe0
>
> -/* RT5033 use internal timer need to set time */
> -#define RT5033_FAST_CHARGE_TIMER4 0x00
> -#define RT5033_FAST_CHARGE_TIMER6 0x01
> -#define RT5033_FAST_CHARGE_TIMER8 0x02
> -#define RT5033_FAST_CHARGE_TIMER9 0x03
> -#define RT5033_FAST_CHARGE_TIMER12 0x04
> -#define RT5033_FAST_CHARGE_TIMER14 0x05
> -#define RT5033_FAST_CHARGE_TIMER16 0x06
> +/* RT5033 charger minimum input voltage regulation */
> +#define RT5033_CHARGER_MIVR_DISABLE 0x00
> +#define RT5033_CHARGER_MIVR_4200MV 0x20
> +#define RT5033_CHARGER_MIVR_4300MV 0x40
> +#define RT5033_CHARGER_MIVR_4400MV 0x60
> +#define RT5033_CHARGER_MIVR_4500MV 0x80
> +#define RT5033_CHARGER_MIVR_4600MV 0xa0
> +#define RT5033_CHARGER_MIVR_4700MV 0xc0
> +#define RT5033_CHARGER_MIVR_4800MV 0xe0
>
> +/* RT5033 use internal timer need to set time */
> +#define RT5033_FAST_CHARGE_TIMER4 0x00 /* 4 hrs */
> +#define RT5033_FAST_CHARGE_TIMER6 0x08 /* 6 hrs */
> +#define RT5033_FAST_CHARGE_TIMER8 0x10 /* 8 hrs */
> +#define RT5033_FAST_CHARGE_TIMER10 0x18 /* 10 hrs */
> +#define RT5033_FAST_CHARGE_TIMER12 0x20 /* 12 hrs */
> +#define RT5033_FAST_CHARGE_TIMER14 0x28 /* 14 hrs */
> +#define RT5033_FAST_CHARGE_TIMER16 0x30 /* 16 hrs */
> +
> +#define RT5033_INT_TIMER_DISABLE 0x00
> #define RT5033_INT_TIMER_ENABLE 0x01
>
> -/* RT5033 charger termination enable mask */
> -#define RT5033_TE_ENABLE_MASK 0x08
> -
> /*
> * RT5033 charger opa mode. RT5033 has two opa modes for OTG: charger mode
> * and boost mode.
> @@ -150,25 +161,30 @@ enum rt5033_reg {
> #define RT5033_BOOST_MODE 0x01
>
> /* RT5033 charger termination enable */
> +#define RT5033_TE_DISABLE 0x00
> #define RT5033_TE_ENABLE 0x08
>
> /* RT5033 charger CFO enable */
> +#define RT5033_CFO_DISABLE 0x00
> #define RT5033_CFO_ENABLE 0x40
>
> /* RT5033 charger constant charge voltage (as in CHGCTRL2 register), uV */
> #define RT5033_CHARGER_CONST_VOLTAGE_LIMIT_MIN 3650000U
> #define RT5033_CHARGER_CONST_VOLTAGE_STEP_NUM 25000U
> #define RT5033_CHARGER_CONST_VOLTAGE_LIMIT_MAX 4400000U
> +#define RT5033_CV_MAX_VOLTAGE 0x1e
>
> /* RT5033 charger pre-charge current limits (as in CHGCTRL4 register), uA */
> #define RT5033_CHARGER_PRE_CURRENT_LIMIT_MIN 350000U
> #define RT5033_CHARGER_PRE_CURRENT_STEP_NUM 100000U
> #define RT5033_CHARGER_PRE_CURRENT_LIMIT_MAX 650000U
> +#define RT5033_CHG_MAX_PRE_CURRENT 0x03
>
> /* RT5033 charger fast-charge current (as in CHGCTRL5 register), uA */
> #define RT5033_CHARGER_FAST_CURRENT_MIN 700000U
> #define RT5033_CHARGER_FAST_CURRENT_STEP_NUM 100000U
> #define RT5033_CHARGER_FAST_CURRENT_MAX 2000000U
> +#define RT5033_CHG_MAX_CURRENT 0x0d
>
> /*
> * RT5033 charger const-charge end of charger current (
> @@ -192,6 +208,7 @@ enum rt5033_reg {
> * RT5033 charger UUG. It enables MOS auto control by H/W charger
> * circuit.
> */
> +#define RT5033_CHARGER_UUG_DISABLE 0x00
> #define RT5033_CHARGER_UUG_ENABLE 0x02
>
> /* RT5033 charger high impedance mode */
> diff --git a/include/linux/mfd/rt5033.h b/include/linux/mfd/rt5033.h
> index 8f306ac15a27..e99e2ab0c1c1 100644
> --- a/include/linux/mfd/rt5033.h
> +++ b/include/linux/mfd/rt5033.h
> @@ -51,7 +51,7 @@ struct rt5033_charger_data {
> struct rt5033_charger {
> struct device *dev;
> struct rt5033_dev *rt5033;
> - struct power_supply psy;
> + struct power_supply *psy;
Is this current unused?
> struct rt5033_charger_data *chg;
> };
>
> --
> 2.39.2
>
--
Lee Jones [李琼斯]
^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: [PATCH v6 04/10 RESEND] mfd: rt5033: Apply preparatory changes before adding rt5033-charger driver
2023-05-25 10:44 ` Lee Jones
@ 2023-05-25 17:16 ` Jakob Hauser
0 siblings, 0 replies; 27+ messages in thread
From: Jakob Hauser @ 2023-05-25 17:16 UTC (permalink / raw)
To: Lee Jones
Cc: Sebastian Reichel, Liam Girdwood, Mark Brown, Rob Herring,
Krzysztof Kozlowski, Beomho Seo, Chanwoo Choi, Stephan Gerhold,
Raymond Hackley, Pavel Machek, Axel Lin, ChiYuan Huang,
Linus Walleij, Henrik Grimler, Christophe Jaillet, linux-pm,
devicetree, linux-kernel, phone-devel, ~postmarketos/upstreaming
Hi Lee,
On 25.05.23 12:44, Lee Jones wrote:
> On Mon, 15 May 2023, Jakob Hauser wrote:
...
>> diff --git a/include/linux/mfd/rt5033.h b/include/linux/mfd/rt5033.h
>> index 8f306ac15a27..e99e2ab0c1c1 100644
>> --- a/include/linux/mfd/rt5033.h
>> +++ b/include/linux/mfd/rt5033.h
>> @@ -51,7 +51,7 @@ struct rt5033_charger_data {
>> struct rt5033_charger {
>> struct device *dev;
>> struct rt5033_dev *rt5033;
>> - struct power_supply psy;
>> + struct power_supply *psy;
>
> Is this current unused?
Currently this is not in use. The rt5033 charger driver gets introduced
by this pachset.
The struct rt5033_charger was added in Dec 2014 with the mfd driver [1]
but the charger driver didn't make it [2] and further effort to
implement it phased out [3].
[1] https://lore.kernel.org/lkml/20141209140102.GZ3951@x1
[2] https://lore.kernel.org/lkml/20150122183037.GA24898@earth.universe
[3]
https://lore.kernel.org/lkml/1425864191-4121-1-git-send-email-beomho.seo@samsung.com/T/#t
>> struct rt5033_charger_data *chg;
>> };
>>
Kind regards,
Jakob
^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: [PATCH v6 00/10 RESEND] Add RT5033 charger device driver
[not found] ` <a308cd6f-0f72-6a12-aa34-ce06290ce0bb@rocketmail.com>
@ 2023-06-01 14:00 ` Lee Jones
0 siblings, 0 replies; 27+ messages in thread
From: Lee Jones @ 2023-06-01 14:00 UTC (permalink / raw)
To: Jakob Hauser
Cc: Sebastian Reichel, Rob Herring, Krzysztof Kozlowski, Conor Dooley,
Liam Girdwood, Mark Brown, Beomho Seo, Chanwoo Choi,
Stephan Gerhold, Raymond Hackley, Pavel Machek, Axel Lin,
ChiYuan Huang, Linus Walleij, Henrik Grimler, Christophe Jaillet,
linux-pm, devicetree, linux-kernel, phone-devel,
~postmarketos/upstreaming
On Wed, 31 May 2023, Jakob Hauser wrote:
> Dear all,
>
> On 15.05.23 22:57, Jakob Hauser wrote:
> > This patchset adds the charger driver "rt5033-charger". It is part of the
> > multifunction device rt5033. The patchset is based on an older version by
> > Beomho Seo of March 2015. For more information on the history and setup of
> > the patchset see the cover sheet of version v1, there is a link further down
> > below the changelog.
> >
> > RESEND: Sorry for spamming. The first try of sending v6 got interrupted and
> > was split into two threads on the lore list. Therefore sending it again.
> >
> > Changes in v6:
> > - Patch 5: In function rt5033_charger_probe() after
> > calling rt5033_charger_dt_init() replaced the return value from "-ENODEV"
> > to "PTR_ERR(charger->chg)", as suggested by Christophe.
> > - Patch 9: Changed the patch from adding "power-supplies: true" to replacing
> > "additionalProperties: false" by "unevaluatedProperties: false", as
> > suggested by Krzysztof.
> >
> > v1: https://lore.kernel.org/linux-pm/cover.1677620677.git.jahau@rocketmail.com/T/#t
> > v2: https://lore.kernel.org/linux-pm/cover.1681646904.git.jahau@rocketmail.com/T/#t
> > v3: https://lore.kernel.org/linux-pm/cover.1682636929.git.jahau@rocketmail.com/T/#t
> > v4: https://lore.kernel.org/linux-pm/20230506155435.3005-1-jahau@rocketmail.com/T/#t
> > v5: https://lore.kernel.org/linux-pm/20230514123130.41172-1-jahau@rocketmail.com/T/#t
> >
> > The result of the patchset v6 can be seen at:
> > https://github.com/Jakko3/linux/blob/rt5033-charger_v6/drivers/power/supply/rt5033_charger.c
>
> What's missing on this patchset? I'm not familiar with the procedures. If
> all patches need ack's, then the ones for mfd (patches 2 & 4) and for
> dt-bindings (patch 10) are missing.
You're waiting on me. I will apply all of the patches and submit a PR.
You're in the queue - please stand-by.
> Link to the current patchset v6:
> - on lore: https://lore.kernel.org/linux-pm/cover.1684182964.git.jahau@rocketmail.com/T/#t
> - on patchwork: https://patchwork.kernel.org/project/linux-pm/list/?series=747771&state=%2A&archive=both
>
> > Jakob Hauser (9):
> > mfd: rt5033: Fix chip revision readout
> > mfd: rt5033: Fix STAT_MASK, HZ_MASK and AICR defines
> > mfd: rt5033: Apply preparatory changes before adding rt5033-charger
> > driver
> > power: supply: rt5033_charger: Add RT5033 charger device driver
> > power: supply: rt5033_charger: Add cable detection and USB OTG supply
> > power: supply: rt5033_battery: Move struct rt5033_battery to battery
> > driver
> > power: supply: rt5033_battery: Adopt status property from charger
> > dt-bindings: power: supply: rt5033-battery: Apply
> > unevaluatedProperties
> > dt-bindings: Add rt5033 mfd, regulator and charger
> >
> > Stephan Gerhold (1):
> > mfd: rt5033: Drop rt5033-battery sub-device
> >
> > .../bindings/mfd/richtek,rt5033.yaml | 138 ++++
> > .../power/supply/richtek,rt5033-battery.yaml | 2 +-
> > .../power/supply/richtek,rt5033-charger.yaml | 65 ++
> > drivers/mfd/rt5033.c | 8 +-
> > drivers/power/supply/Kconfig | 8 +
> > drivers/power/supply/Makefile | 1 +
> > drivers/power/supply/rt5033_battery.c | 38 +-
> > drivers/power/supply/rt5033_charger.c | 744 ++++++++++++++++++
> > include/linux/mfd/rt5033-private.h | 64 +-
> > include/linux/mfd/rt5033.h | 24 -
> > 10 files changed, 1034 insertions(+), 58 deletions(-)
> > create mode 100644 Documentation/devicetree/bindings/mfd/richtek,rt5033.yaml
> > create mode 100644 Documentation/devicetree/bindings/power/supply/richtek,rt5033-charger.yaml
> > create mode 100644 drivers/power/supply/rt5033_charger.c
>
> Kind regards,
> Jakob
--
Lee Jones [李琼斯]
^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: [PATCH v6 00/10 RESEND] Add RT5033 charger device driver
2023-05-15 20:57 ` [PATCH v6 00/10 RESEND] Add RT5033 charger device driver Jakob Hauser
` (10 preceding siblings ...)
[not found] ` <a308cd6f-0f72-6a12-aa34-ce06290ce0bb@rocketmail.com>
@ 2023-06-08 17:19 ` Lee Jones
2023-06-09 6:47 ` [GIT PULL] Immutable branch between MFD and Power due for the v6.5 merge window Lee Jones
12 siblings, 0 replies; 27+ messages in thread
From: Lee Jones @ 2023-06-08 17:19 UTC (permalink / raw)
To: Jakob Hauser
Cc: Sebastian Reichel, Liam Girdwood, Mark Brown, Rob Herring,
Krzysztof Kozlowski, Beomho Seo, Chanwoo Choi, Stephan Gerhold,
Raymond Hackley, Pavel Machek, Axel Lin, ChiYuan Huang,
Linus Walleij, Henrik Grimler, Christophe Jaillet, linux-pm,
devicetree, linux-kernel, phone-devel, ~postmarketos/upstreaming
On Mon, 15 May 2023, Jakob Hauser wrote:
> This patchset adds the charger driver "rt5033-charger". It is part of the
> multifunction device rt5033. The patchset is based on an older version by
> Beomho Seo of March 2015. For more information on the history and setup of
> the patchset see the cover sheet of version v1, there is a link further down
> below the changelog.
>
> RESEND: Sorry for spamming. The first try of sending v6 got interrupted and
> was split into two threads on the lore list. Therefore sending it again.
>
> Changes in v6:
> - Patch 5: In function rt5033_charger_probe() after
> calling rt5033_charger_dt_init() replaced the return value from "-ENODEV"
> to "PTR_ERR(charger->chg)", as suggested by Christophe.
> - Patch 9: Changed the patch from adding "power-supplies: true" to replacing
> "additionalProperties: false" by "unevaluatedProperties: false", as
> suggested by Krzysztof.
>
> v1: https://lore.kernel.org/linux-pm/cover.1677620677.git.jahau@rocketmail.com/T/#t
> v2: https://lore.kernel.org/linux-pm/cover.1681646904.git.jahau@rocketmail.com/T/#t
> v3: https://lore.kernel.org/linux-pm/cover.1682636929.git.jahau@rocketmail.com/T/#t
> v4: https://lore.kernel.org/linux-pm/20230506155435.3005-1-jahau@rocketmail.com/T/#t
> v5: https://lore.kernel.org/linux-pm/20230514123130.41172-1-jahau@rocketmail.com/T/#t
>
> The result of the patchset v6 can be seen at:
> https://github.com/Jakko3/linux/blob/rt5033-charger_v6/drivers/power/supply/rt5033_charger.c
>
> Jakob Hauser (9):
> mfd: rt5033: Fix chip revision readout
> mfd: rt5033: Fix STAT_MASK, HZ_MASK and AICR defines
> mfd: rt5033: Apply preparatory changes before adding rt5033-charger
> driver
> power: supply: rt5033_charger: Add RT5033 charger device driver
> power: supply: rt5033_charger: Add cable detection and USB OTG supply
> power: supply: rt5033_battery: Move struct rt5033_battery to battery
> driver
> power: supply: rt5033_battery: Adopt status property from charger
> dt-bindings: power: supply: rt5033-battery: Apply
> unevaluatedProperties
> dt-bindings: Add rt5033 mfd, regulator and charger
>
> Stephan Gerhold (1):
> mfd: rt5033: Drop rt5033-battery sub-device
>
> .../bindings/mfd/richtek,rt5033.yaml | 138 ++++
> .../power/supply/richtek,rt5033-battery.yaml | 2 +-
> .../power/supply/richtek,rt5033-charger.yaml | 65 ++
> drivers/mfd/rt5033.c | 8 +-
> drivers/power/supply/Kconfig | 8 +
> drivers/power/supply/Makefile | 1 +
> drivers/power/supply/rt5033_battery.c | 38 +-
> drivers/power/supply/rt5033_charger.c | 744 ++++++++++++++++++
> include/linux/mfd/rt5033-private.h | 64 +-
> include/linux/mfd/rt5033.h | 24 -
> 10 files changed, 1034 insertions(+), 58 deletions(-)
> create mode 100644 Documentation/devicetree/bindings/mfd/richtek,rt5033.yaml
> create mode 100644 Documentation/devicetree/bindings/power/supply/richtek,rt5033-charger.yaml
> create mode 100644 drivers/power/supply/rt5033_charger.c
All applied. Sent for build testing.
I'll follow-up with a PR soon.
--
Lee Jones [李琼斯]
^ permalink raw reply [flat|nested] 27+ messages in thread
* [GIT PULL] Immutable branch between MFD and Power due for the v6.5 merge window
2023-05-15 20:57 ` [PATCH v6 00/10 RESEND] Add RT5033 charger device driver Jakob Hauser
` (11 preceding siblings ...)
2023-06-08 17:19 ` Lee Jones
@ 2023-06-09 6:47 ` Lee Jones
2023-06-16 20:02 ` Jakob Hauser
12 siblings, 1 reply; 27+ messages in thread
From: Lee Jones @ 2023-06-09 6:47 UTC (permalink / raw)
To: Jakob Hauser
Cc: Sebastian Reichel, Liam Girdwood, Mark Brown, Rob Herring,
Krzysztof Kozlowski, Beomho Seo, Chanwoo Choi, Stephan Gerhold,
Raymond Hackley, Pavel Machek, Axel Lin, ChiYuan Huang,
Linus Walleij, Henrik Grimler, Christophe Jaillet, linux-pm,
devicetree, linux-kernel, phone-devel, ~postmarketos/upstreaming
Enjoy!
The following changes since commit ac9a78681b921877518763ba0e89202254349d1b:
Linux 6.4-rc1 (2023-05-07 13:34:35 -0700)
are available in the Git repository at:
git://git.kernel.org/pub/scm/linux/kernel/git/lee/mfd.git ib-mfd-power-v6.5
for you to fetch changes up to b54185c1e3b02c91e4a190ac5c346ea7bfb0de93:
dt-bindings: Add rt5033 MFD, Regulator and Charger (2023-06-08 18:18:13 +0100)
----------------------------------------------------------------
Immutable branch between MFD and Power due for the v6.5 merge window
----------------------------------------------------------------
Jakob Hauser (8):
mfd: rt5033: Fix chip revision readout
mfd: rt5033: Fix STAT_MASK, HZ_MASK and AICR defines
mfd: rt5033: Apply preparatory changes before adding rt5033-charger driver
power: supply: rt5033_charger: Add RT5033 charger device driver
power: supply: rt5033_battery: Move struct rt5033_battery to battery driver
power: supply: rt5033_battery: Adopt status property from charger
dt-bindings: power: supply: rt5033-battery: Apply unevaluatedProperties
dt-bindings: Add rt5033 MFD, Regulator and Charger
Stephan Gerhold (1):
mfd: rt5033: Drop rt5033-battery sub-device
.../devicetree/bindings/mfd/richtek,rt5033.yaml | 138 ++++++
.../power/supply/richtek,rt5033-battery.yaml | 2 +-
.../power/supply/richtek,rt5033-charger.yaml | 65 +++
drivers/mfd/rt5033.c | 8 +-
drivers/power/supply/Kconfig | 8 +
drivers/power/supply/Makefile | 1 +
drivers/power/supply/rt5033_battery.c | 38 +-
drivers/power/supply/rt5033_charger.c | 472 +++++++++++++++++++++
include/linux/mfd/rt5033-private.h | 64 ++-
include/linux/mfd/rt5033.h | 24 --
10 files changed, 762 insertions(+), 58 deletions(-)
create mode 100644 Documentation/devicetree/bindings/mfd/richtek,rt5033.yaml
create mode 100644 Documentation/devicetree/bindings/power/supply/richtek,rt5033-charger.yaml
create mode 100644 drivers/power/supply/rt5033_charger.c
--
Lee Jones [李琼斯]
^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: [GIT PULL] Immutable branch between MFD and Power due for the v6.5 merge window
2023-06-09 6:47 ` [GIT PULL] Immutable branch between MFD and Power due for the v6.5 merge window Lee Jones
@ 2023-06-16 20:02 ` Jakob Hauser
2023-06-19 10:35 ` Lee Jones
0 siblings, 1 reply; 27+ messages in thread
From: Jakob Hauser @ 2023-06-16 20:02 UTC (permalink / raw)
To: Lee Jones
Cc: Sebastian Reichel, Liam Girdwood, Mark Brown, Rob Herring,
Krzysztof Kozlowski, Beomho Seo, Chanwoo Choi, Stephan Gerhold,
Raymond Hackley, Pavel Machek, Axel Lin, ChiYuan Huang,
Linus Walleij, Henrik Grimler, Christophe Jaillet, linux-pm,
devicetree, linux-kernel, phone-devel, ~postmarketos/upstreaming
Hi Lee,
On 09.06.23 08:47, Lee Jones wrote:
> Enjoy!
>
> The following changes since commit ac9a78681b921877518763ba0e89202254349d1b:
>
> Linux 6.4-rc1 (2023-05-07 13:34:35 -0700)
>
> are available in the Git repository at:
>
> git://git.kernel.org/pub/scm/linux/kernel/git/lee/mfd.git ib-mfd-power-v6.5
>
> for you to fetch changes up to b54185c1e3b02c91e4a190ac5c346ea7bfb0de93:
>
> dt-bindings: Add rt5033 MFD, Regulator and Charger (2023-06-08 18:18:13 +0100)
>
> ----------------------------------------------------------------
> Immutable branch between MFD and Power due for the v6.5 merge window
>
> ----------------------------------------------------------------
> Jakob Hauser (8):
> mfd: rt5033: Fix chip revision readout
> mfd: rt5033: Fix STAT_MASK, HZ_MASK and AICR defines
> mfd: rt5033: Apply preparatory changes before adding rt5033-charger driver
> power: supply: rt5033_charger: Add RT5033 charger device driver
> power: supply: rt5033_battery: Move struct rt5033_battery to battery driver
> power: supply: rt5033_battery: Adopt status property from charger
> dt-bindings: power: supply: rt5033-battery: Apply unevaluatedProperties
> dt-bindings: Add rt5033 MFD, Regulator and Charger
>
> Stephan Gerhold (1):
> mfd: rt5033: Drop rt5033-battery sub-device
>
> .../devicetree/bindings/mfd/richtek,rt5033.yaml | 138 ++++++
> .../power/supply/richtek,rt5033-battery.yaml | 2 +-
> .../power/supply/richtek,rt5033-charger.yaml | 65 +++
> drivers/mfd/rt5033.c | 8 +-
> drivers/power/supply/Kconfig | 8 +
> drivers/power/supply/Makefile | 1 +
> drivers/power/supply/rt5033_battery.c | 38 +-
> drivers/power/supply/rt5033_charger.c | 472 +++++++++++++++++++++
> include/linux/mfd/rt5033-private.h | 64 ++-
> include/linux/mfd/rt5033.h | 24 --
> 10 files changed, 762 insertions(+), 58 deletions(-)
> create mode 100644 Documentation/devicetree/bindings/mfd/richtek,rt5033.yaml
> create mode 100644 Documentation/devicetree/bindings/power/supply/richtek,rt5033-charger.yaml
> create mode 100644 drivers/power/supply/rt5033_charger.c
>
I just realized that there is one patch missing in the immutable branch
"ib-mfd-power-v6.5" [1]. Unfortunately I haven't noticed earlier. The
immutable branch holds 9 patches, the patchset has 10 patches [2]. The
missing patch is No. 6 "power: supply: rt5033_charger: Add cable
detection and USB OTG supply".
As this patch No. 6 affects only the file
drivers/power/supply/rt5033_charger.c and is the last patch on that
file, it's no problem to add this patch on top of the other patches.
Could you submit another pull request for the v6.5 merge window to add
this patch?
[1]
https://git.kernel.org/pub/scm/linux/kernel/git/lee/mfd.git/log/?h=ib-mfd-power-6.5
[2]
https://lore.kernel.org/linux-pm/cover.1684182964.git.jahau@rocketmail.com/T/#t
Kind regards,
Jakob
^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: [GIT PULL] Immutable branch between MFD and Power due for the v6.5 merge window
2023-06-16 20:02 ` Jakob Hauser
@ 2023-06-19 10:35 ` Lee Jones
2023-07-30 17:58 ` Jakob Hauser
0 siblings, 1 reply; 27+ messages in thread
From: Lee Jones @ 2023-06-19 10:35 UTC (permalink / raw)
To: Jakob Hauser
Cc: Sebastian Reichel, Liam Girdwood, Mark Brown, Rob Herring,
Krzysztof Kozlowski, Beomho Seo, Chanwoo Choi, Stephan Gerhold,
Raymond Hackley, Pavel Machek, Axel Lin, ChiYuan Huang,
Linus Walleij, Henrik Grimler, Christophe Jaillet, linux-pm,
devicetree, linux-kernel, phone-devel, ~postmarketos/upstreaming
Sebastian,
On Fri, 16 Jun 2023, Jakob Hauser wrote:
> On 09.06.23 08:47, Lee Jones wrote:
> > Enjoy!
> >
> > The following changes since commit ac9a78681b921877518763ba0e89202254349d1b:
> >
> > Linux 6.4-rc1 (2023-05-07 13:34:35 -0700)
> >
> > are available in the Git repository at:
> >
> > git://git.kernel.org/pub/scm/linux/kernel/git/lee/mfd.git ib-mfd-power-v6.5
> >
> > for you to fetch changes up to b54185c1e3b02c91e4a190ac5c346ea7bfb0de93:
> >
> > dt-bindings: Add rt5033 MFD, Regulator and Charger (2023-06-08 18:18:13 +0100)
> >
> > ----------------------------------------------------------------
> > Immutable branch between MFD and Power due for the v6.5 merge window
> >
> > ----------------------------------------------------------------
> > Jakob Hauser (8):
> > mfd: rt5033: Fix chip revision readout
> > mfd: rt5033: Fix STAT_MASK, HZ_MASK and AICR defines
> > mfd: rt5033: Apply preparatory changes before adding rt5033-charger driver
> > power: supply: rt5033_charger: Add RT5033 charger device driver
> > power: supply: rt5033_battery: Move struct rt5033_battery to battery driver
> > power: supply: rt5033_battery: Adopt status property from charger
> > dt-bindings: power: supply: rt5033-battery: Apply unevaluatedProperties
> > dt-bindings: Add rt5033 MFD, Regulator and Charger
> >
> > Stephan Gerhold (1):
> > mfd: rt5033: Drop rt5033-battery sub-device
> >
> > .../devicetree/bindings/mfd/richtek,rt5033.yaml | 138 ++++++
> > .../power/supply/richtek,rt5033-battery.yaml | 2 +-
> > .../power/supply/richtek,rt5033-charger.yaml | 65 +++
> > drivers/mfd/rt5033.c | 8 +-
> > drivers/power/supply/Kconfig | 8 +
> > drivers/power/supply/Makefile | 1 +
> > drivers/power/supply/rt5033_battery.c | 38 +-
> > drivers/power/supply/rt5033_charger.c | 472 +++++++++++++++++++++
> > include/linux/mfd/rt5033-private.h | 64 ++-
> > include/linux/mfd/rt5033.h | 24 --
> > 10 files changed, 762 insertions(+), 58 deletions(-)
> > create mode 100644 Documentation/devicetree/bindings/mfd/richtek,rt5033.yaml
> > create mode 100644 Documentation/devicetree/bindings/power/supply/richtek,rt5033-charger.yaml
> > create mode 100644 drivers/power/supply/rt5033_charger.c
> >
>
> I just realized that there is one patch missing in the immutable branch
> "ib-mfd-power-v6.5" [1]. Unfortunately I haven't noticed earlier. The
> immutable branch holds 9 patches, the patchset has 10 patches [2]. The
> missing patch is No. 6 "power: supply: rt5033_charger: Add cable detection
> and USB OTG supply".
Did you take this pull-request?
If so, would you like to apply the missing patch or would you like me to
take it via MFD (without a subsequent PR)?
> As this patch No. 6 affects only the file
> drivers/power/supply/rt5033_charger.c and is the last patch on that file,
> it's no problem to add this patch on top of the other patches.
>
> Could you submit another pull request for the v6.5 merge window to add this
> patch?
>
> [1] https://git.kernel.org/pub/scm/linux/kernel/git/lee/mfd.git/log/?h=ib-mfd-power-6.5
> [2] https://lore.kernel.org/linux-pm/cover.1684182964.git.jahau@rocketmail.com/T/#t
--
Lee Jones [李琼斯]
^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: [GIT PULL] Immutable branch between MFD and Power due for the v6.5 merge window
2023-06-19 10:35 ` Lee Jones
@ 2023-07-30 17:58 ` Jakob Hauser
0 siblings, 0 replies; 27+ messages in thread
From: Jakob Hauser @ 2023-07-30 17:58 UTC (permalink / raw)
To: Sebastian Reichel
Cc: Lee Jones, Liam Girdwood, Mark Brown, Rob Herring,
Krzysztof Kozlowski, Beomho Seo, Chanwoo Choi, Stephan Gerhold,
Raymond Hackley, Pavel Machek, Axel Lin, ChiYuan Huang,
Linus Walleij, Henrik Grimler, Christophe Jaillet, linux-pm,
devicetree, linux-kernel, phone-devel, ~postmarketos/upstreaming
Hi Sebastian,
The patch 6 "power: supply: rt5033_charger: Add cable detection and USB
OTG supply" of the series v6 RESEND of rt5033-charger is still missing.
On 19.06.23 12:35, Lee Jones wrote:
> Sebastian,
>
> On Fri, 16 Jun 2023, Jakob Hauser wrote:
...
>> I just realized that there is one patch missing in the immutable branch
>> "ib-mfd-power-v6.5" [1]. Unfortunately I haven't noticed earlier. The
>> immutable branch holds 9 patches, the patchset has 10 patches [2]. The
>> missing patch is No. 6 "power: supply: rt5033_charger: Add cable detection
>> and USB OTG supply".
>
> Did you take this pull-request?
>
> If so, would you like to apply the missing patch or would you like me to
> take it via MFD (without a subsequent PR)?
>
>> As this patch No. 6 affects only the file
>> drivers/power/supply/rt5033_charger.c and is the last patch on that file,
>> it's no problem to add this patch on top of the other patches.
>>
>> Could you submit another pull request for the v6.5 merge window to add this
>> patch?
>>
>> [1] https://git.kernel.org/pub/scm/linux/kernel/git/lee/mfd.git/log/?h=ib-mfd-power-6.5
>> [2] https://lore.kernel.org/linux-pm/cover.1684182964.git.jahau@rocketmail.com/T/#t
...
The lore link of the series v6 RESEND is above [2]. The patchwork link
to v6 RESEND is:
https://patchwork.kernel.org/project/linux-pm/list/?series=747771&state=%2A&archive=both
Additionally, there were two follow-up clean-up patches. There were no
review comments so far. Lore and patchwork links are:
https://lore.kernel.org/linux-pm/cover.1686948074.git.jahau@rocketmail.com/T/#t
https://patchwork.kernel.org/project/linux-pm/list/?series=758018&state=%2A&archive=both
Could you apply those three patches? (1x patch 6 of v6 RESEND series +
2x clean-up patches.)
I've just noticed that a new patch by Rob was added to rt5033-charger.
Can you rebase the other three patches by your own or do you want me to
rebase and resend them?
https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/commit/drivers/power/supply/rt5033_charger.c?id=2ce8284c31156c432df60d4497ec68cca04e128f
Kind regards,
Jakob
^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: (subset) [PATCH v6 06/10 RESEND] power: supply: rt5033_charger: Add cable detection and USB OTG supply
2023-05-15 20:57 ` [PATCH v6 06/10 RESEND] power: supply: rt5033_charger: Add cable detection and USB OTG supply Jakob Hauser
@ 2023-08-17 9:38 ` Lee Jones
2023-08-22 7:07 ` Lee Jones
0 siblings, 1 reply; 27+ messages in thread
From: Lee Jones @ 2023-08-17 9:38 UTC (permalink / raw)
To: Sebastian Reichel, Lee Jones, Liam Girdwood, Mark Brown,
Rob Herring, Krzysztof Kozlowski, Jakob Hauser
Cc: Beomho Seo, Chanwoo Choi, Stephan Gerhold, Raymond Hackley,
Pavel Machek, Axel Lin, ChiYuan Huang, Linus Walleij,
Henrik Grimler, Christophe Jaillet, linux-pm, devicetree,
linux-kernel, phone-devel, ~postmarketos/upstreaming,
Sebastian Reichel
On Mon, 15 May 2023 22:57:15 +0200, Jakob Hauser wrote:
> Implement cable detection by extcon and handle the driver according to the
> connector type.
>
> There are basically three types of action: "set_charging", "set_otg" and
> "set_disconnect".
>
> A forth helper function to "unset_otg" was added because this is used in both
> "set_charging" and "set_disconnect". In the first case it covers the rather
> rare event that someone changes from OTG to charging without disconnect. In
> the second case, when disconnecting, the values are set back to the ones from
> initialization to return into a defined state.
>
> [...]
Applied, thanks!
[06/10] power: supply: rt5033_charger: Add cable detection and USB OTG supply
commit: c1af6bcc8583b0a1083338cd26c2090d0bcb0810
--
Lee Jones [李琼斯]
^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: (subset) [PATCH v6 06/10 RESEND] power: supply: rt5033_charger: Add cable detection and USB OTG supply
2023-08-17 9:38 ` (subset) " Lee Jones
@ 2023-08-22 7:07 ` Lee Jones
2023-08-22 21:29 ` Sebastian Reichel
0 siblings, 1 reply; 27+ messages in thread
From: Lee Jones @ 2023-08-22 7:07 UTC (permalink / raw)
To: Sebastian Reichel, Liam Girdwood, Mark Brown, Rob Herring,
Krzysztof Kozlowski, Jakob Hauser
Cc: Beomho Seo, Chanwoo Choi, Stephan Gerhold, Raymond Hackley,
Pavel Machek, Axel Lin, ChiYuan Huang, Linus Walleij,
Henrik Grimler, Christophe Jaillet, linux-pm, devicetree,
linux-kernel, phone-devel, ~postmarketos/upstreaming,
Sebastian Reichel
On Thu, 17 Aug 2023, Lee Jones wrote:
> On Mon, 15 May 2023 22:57:15 +0200, Jakob Hauser wrote:
> > Implement cable detection by extcon and handle the driver according to the
> > connector type.
> >
> > There are basically three types of action: "set_charging", "set_otg" and
> > "set_disconnect".
> >
> > A forth helper function to "unset_otg" was added because this is used in both
> > "set_charging" and "set_disconnect". In the first case it covers the rather
> > rare event that someone changes from OTG to charging without disconnect. In
> > the second case, when disconnecting, the values are set back to the ones from
> > initialization to return into a defined state.
> >
> > [...]
>
> Applied, thanks!
>
> [06/10] power: supply: rt5033_charger: Add cable detection and USB OTG supply
> commit: c1af6bcc8583b0a1083338cd26c2090d0bcb0810
Multiple fixes now follow this patch, so I am unapplying it.
Sebastian, would you mind collecting it up please?
--
Lee Jones [李琼斯]
^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: (subset) [PATCH v6 06/10 RESEND] power: supply: rt5033_charger: Add cable detection and USB OTG supply
2023-08-22 7:07 ` Lee Jones
@ 2023-08-22 21:29 ` Sebastian Reichel
2023-09-03 12:43 ` Jakob Hauser
0 siblings, 1 reply; 27+ messages in thread
From: Sebastian Reichel @ 2023-08-22 21:29 UTC (permalink / raw)
To: Lee Jones
Cc: Liam Girdwood, Mark Brown, Rob Herring, Krzysztof Kozlowski,
Jakob Hauser, Beomho Seo, Chanwoo Choi, Stephan Gerhold,
Raymond Hackley, Pavel Machek, Axel Lin, ChiYuan Huang,
Linus Walleij, Henrik Grimler, Christophe Jaillet, linux-pm,
devicetree, linux-kernel, phone-devel, ~postmarketos/upstreaming
[-- Attachment #1: Type: text/plain, Size: 1676 bytes --]
Hi,
On Tue, Aug 22, 2023 at 08:07:37AM +0100, Lee Jones wrote:
> On Thu, 17 Aug 2023, Lee Jones wrote:
>
> > On Mon, 15 May 2023 22:57:15 +0200, Jakob Hauser wrote:
> > > Implement cable detection by extcon and handle the driver according to the
> > > connector type.
> > >
> > > There are basically three types of action: "set_charging", "set_otg" and
> > > "set_disconnect".
> > >
> > > A forth helper function to "unset_otg" was added because this is used in both
> > > "set_charging" and "set_disconnect". In the first case it covers the rather
> > > rare event that someone changes from OTG to charging without disconnect. In
> > > the second case, when disconnecting, the values are set back to the ones from
> > > initialization to return into a defined state.
> > >
> > > [...]
> >
> > Applied, thanks!
> >
> > [06/10] power: supply: rt5033_charger: Add cable detection and USB OTG supply
> > commit: c1af6bcc8583b0a1083338cd26c2090d0bcb0810
>
> Multiple fixes now follow this patch, so I am unapplying it.
>
> Sebastian, would you mind collecting it up please?
I'm leaving for a two week hiking trip (with basically no internet
access) in some hours. My planed return date is basically when Linus
is expected to tag 6.6-rc1, so I will not queue any more patches and
send my pull request early (within the next few hours).
I planned to catch up with the power-supply backlog last week during
Chaos Communication Camp, but it was too hot to do any sensible
review. Now I expect to process the power-supply backlog in the
week after the merge window.
Greetings and sorry for the inconvenience,
-- Sebastian
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: (subset) [PATCH v6 06/10 RESEND] power: supply: rt5033_charger: Add cable detection and USB OTG supply
2023-08-22 21:29 ` Sebastian Reichel
@ 2023-09-03 12:43 ` Jakob Hauser
2023-09-04 14:27 ` Lee Jones
0 siblings, 1 reply; 27+ messages in thread
From: Jakob Hauser @ 2023-09-03 12:43 UTC (permalink / raw)
To: Sebastian Reichel
Cc: Lee Jones, Liam Girdwood, Mark Brown, Rob Herring,
Krzysztof Kozlowski, Beomho Seo, Chanwoo Choi, Stephan Gerhold,
Raymond Hackley, Pavel Machek, Axel Lin, ChiYuan Huang,
Linus Walleij, Henrik Grimler, Christophe Jaillet,
Stephen Rothwell, Randy Dunlap, Yang Yingliang, linux-pm,
devicetree, linux-kernel, phone-devel, ~postmarketos/upstreaming
Hi Sebastian,
On 22.08.23 23:29, Sebastian Reichel wrote:
> Hi,
>
> On Tue, Aug 22, 2023 at 08:07:37AM +0100, Lee Jones wrote:
>> On Thu, 17 Aug 2023, Lee Jones wrote:
>>
>>> On Mon, 15 May 2023 22:57:15 +0200, Jakob Hauser wrote:
>>>> Implement cable detection by extcon and handle the driver according to the
>>>> connector type.
>>>>
>>>> There are basically three types of action: "set_charging", "set_otg" and
>>>> "set_disconnect".
>>>>
>>>> A forth helper function to "unset_otg" was added because this is used in both
>>>> "set_charging" and "set_disconnect". In the first case it covers the rather
>>>> rare event that someone changes from OTG to charging without disconnect. In
>>>> the second case, when disconnecting, the values are set back to the ones from
>>>> initialization to return into a defined state.
>>>>
>>>> [...]
>>>
>>> Applied, thanks!
>>>
>>> [06/10] power: supply: rt5033_charger: Add cable detection and USB OTG supply
>>> commit: c1af6bcc8583b0a1083338cd26c2090d0bcb0810
>>
>> Multiple fixes now follow this patch, so I am unapplying it.
>>
>> Sebastian, would you mind collecting it up please?
>
> I'm leaving for a two week hiking trip (with basically no internet
> access) in some hours. My planed return date is basically when Linus
> is expected to tag 6.6-rc1, so I will not queue any more patches and
> send my pull request early (within the next few hours).
>
> I planned to catch up with the power-supply backlog last week during
> Chaos Communication Camp, but it was too hot to do any sensible
> review. Now I expect to process the power-supply backlog in the
> week after the merge window.
The patch 6 of the rt5033-charger series v6 gathered some issues. For
all of them a solution was provided. Thanks to everyone involved!
However, I don't know what's the best way to put them together.
- As the patch 6 was forgotten to apply with the others of the
patchset, in the meantime another small patch by Rob sneaked in. The
patch 6 needs to be rebased on Rob's patch. It affects the includes.
Would be nice to order them alphabetically after rebase.
- After patch 6 was added on top of Rob's patch in linux-next, there
was a build failure. This is because "linux/of.h" now explicitly
needs to be added to the rt5033-charger driver. Stephen Rothwell
provided a fix. I'm not sure on the order: Maybe that needs to be
added before adding patch 6 to avoid the build failure when the
kernel test bot checks each commit separately.
https://lore.kernel.org/linux-next/20230821125741.3a2474d7@canb.auug.org.au/T/#u
- Beyond that, the kernel test bot also complained about undefined
reference related to extcon. I didn't understand why this happens
because the driver has "linux/extcon.h" included. Randy was attentive
and provided a fix. Here again I'm not sure about the order, I guess
this should be added before adding patch 6 to avoid build failures if
each commit is tested separately.
Kernel test bot complaints:
x86_64 clang
https://lore.kernel.org/oe-kbuild-all/202308220324.LsI8q3ML-lkp@intel.com/T/#u
x86_64 gcc
https://lore.kernel.org/oe-kbuild-all/202308240723.O2rW0InU-lkp@intel.com/T/#u
arm gcc
https://lore.kernel.org/oe-kbuild-all/202308250617.ue4uQxWa-lkp@intel.com/T/#u
Fix by Randy:
https://lore.kernel.org/linux-pm/20230828224201.26823-1-rdunlap@infradead.org/T/#u
- Yang noticed that the mutex_unlock() is not handled correctly in
some error path and provided a fix:
https://lore.kernel.org/linux-pm/20230822030207.644738-1-yangyingliang@huawei.com/T/#u
- There are two clean-up patches by me. They need to be rebased to the
patches mentioned above but there shouldn't be conflicts with them.
https://lore.kernel.org/linux-pm/cover.1686948074.git.jahau@rocketmail.com/T/#u
Please also note that the commit hash in the linked fixes above refers
to linux-next, where the patch 6 had been applied. As the patch was
dropped later on, I don't know what this means for the commit hashes in
the fixes.
What's the best way to proceed? Can you put these patches together? Or
do you want me something to do?
Kind regards,
Jakob
^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: (subset) [PATCH v6 06/10 RESEND] power: supply: rt5033_charger: Add cable detection and USB OTG supply
2023-09-03 12:43 ` Jakob Hauser
@ 2023-09-04 14:27 ` Lee Jones
2023-09-14 15:33 ` Sebastian Reichel
0 siblings, 1 reply; 27+ messages in thread
From: Lee Jones @ 2023-09-04 14:27 UTC (permalink / raw)
To: Jakob Hauser
Cc: Sebastian Reichel, Liam Girdwood, Mark Brown, Rob Herring,
Krzysztof Kozlowski, Beomho Seo, Chanwoo Choi, Stephan Gerhold,
Raymond Hackley, Pavel Machek, Axel Lin, ChiYuan Huang,
Linus Walleij, Henrik Grimler, Christophe Jaillet,
Stephen Rothwell, Randy Dunlap, Yang Yingliang, linux-pm,
devicetree, linux-kernel, phone-devel, ~postmarketos/upstreaming
On Sun, 03 Sep 2023, Jakob Hauser wrote:
> Hi Sebastian,
>
> On 22.08.23 23:29, Sebastian Reichel wrote:
> > Hi,
> >
> > On Tue, Aug 22, 2023 at 08:07:37AM +0100, Lee Jones wrote:
> > > On Thu, 17 Aug 2023, Lee Jones wrote:
> > >
> > > > On Mon, 15 May 2023 22:57:15 +0200, Jakob Hauser wrote:
> > > > > Implement cable detection by extcon and handle the driver according to the
> > > > > connector type.
> > > > >
> > > > > There are basically three types of action: "set_charging", "set_otg" and
> > > > > "set_disconnect".
> > > > >
> > > > > A forth helper function to "unset_otg" was added because this is used in both
> > > > > "set_charging" and "set_disconnect". In the first case it covers the rather
> > > > > rare event that someone changes from OTG to charging without disconnect. In
> > > > > the second case, when disconnecting, the values are set back to the ones from
> > > > > initialization to return into a defined state.
> > > > >
> > > > > [...]
> > > >
> > > > Applied, thanks!
> > > >
> > > > [06/10] power: supply: rt5033_charger: Add cable detection and USB OTG supply
> > > > commit: c1af6bcc8583b0a1083338cd26c2090d0bcb0810
> > >
> > > Multiple fixes now follow this patch, so I am unapplying it.
> > >
> > > Sebastian, would you mind collecting it up please?
> >
> > I'm leaving for a two week hiking trip (with basically no internet
> > access) in some hours. My planed return date is basically when Linus
> > is expected to tag 6.6-rc1, so I will not queue any more patches and
> > send my pull request early (within the next few hours).
> >
> > I planned to catch up with the power-supply backlog last week during
> > Chaos Communication Camp, but it was too hot to do any sensible
> > review. Now I expect to process the power-supply backlog in the
> > week after the merge window.
>
> The patch 6 of the rt5033-charger series v6 gathered some issues. For all of
> them a solution was provided. Thanks to everyone involved! However, I don't
> know what's the best way to put them together.
>
> - As the patch 6 was forgotten to apply with the others of the
> patchset, in the meantime another small patch by Rob sneaked in. The
> patch 6 needs to be rebased on Rob's patch. It affects the includes.
> Would be nice to order them alphabetically after rebase.
>
> - After patch 6 was added on top of Rob's patch in linux-next, there
> was a build failure. This is because "linux/of.h" now explicitly
> needs to be added to the rt5033-charger driver. Stephen Rothwell
> provided a fix. I'm not sure on the order: Maybe that needs to be
> added before adding patch 6 to avoid the build failure when the
> kernel test bot checks each commit separately.
>
> https://lore.kernel.org/linux-next/20230821125741.3a2474d7@canb.auug.org.au/T/#u
>
> - Beyond that, the kernel test bot also complained about undefined
> reference related to extcon. I didn't understand why this happens
> because the driver has "linux/extcon.h" included. Randy was attentive
> and provided a fix. Here again I'm not sure about the order, I guess
> this should be added before adding patch 6 to avoid build failures if
> each commit is tested separately.
> Kernel test bot complaints:
> x86_64 clang https://lore.kernel.org/oe-kbuild-all/202308220324.LsI8q3ML-lkp@intel.com/T/#u
> x86_64 gcc https://lore.kernel.org/oe-kbuild-all/202308240723.O2rW0InU-lkp@intel.com/T/#u
> arm gcc https://lore.kernel.org/oe-kbuild-all/202308250617.ue4uQxWa-lkp@intel.com/T/#u
> Fix by Randy:
>
> https://lore.kernel.org/linux-pm/20230828224201.26823-1-rdunlap@infradead.org/T/#u
>
> - Yang noticed that the mutex_unlock() is not handled correctly in
> some error path and provided a fix:
>
> https://lore.kernel.org/linux-pm/20230822030207.644738-1-yangyingliang@huawei.com/T/#u
>
> - There are two clean-up patches by me. They need to be rebased to the
> patches mentioned above but there shouldn't be conflicts with them.
>
> https://lore.kernel.org/linux-pm/cover.1686948074.git.jahau@rocketmail.com/T/#u
>
> Please also note that the commit hash in the linked fixes above refers to
> linux-next, where the patch 6 had been applied. As the patch was dropped
> later on, I don't know what this means for the commit hashes in the fixes.
>
> What's the best way to proceed? Can you put these patches together? Or do
> you want me something to do?
You need to do this yourself.
Rebase all of the fixes on top of v6.6-rc1 (which will be released in a
little under a week). Ensure that each patch builds as it's applied so
as not to harm bisecability. If you have to squash them to prevent
built-breakages, then so be it, but don't forget to credit the
contributors. Once complete, post as a set and we'll take it from
there.
--
Lee Jones [李琼斯]
^ permalink raw reply [flat|nested] 27+ messages in thread
* Re: (subset) [PATCH v6 06/10 RESEND] power: supply: rt5033_charger: Add cable detection and USB OTG supply
2023-09-04 14:27 ` Lee Jones
@ 2023-09-14 15:33 ` Sebastian Reichel
0 siblings, 0 replies; 27+ messages in thread
From: Sebastian Reichel @ 2023-09-14 15:33 UTC (permalink / raw)
To: Jakob Hauser; +Cc: linux-pm
[-- Attachment #1: Type: text/plain, Size: 5224 bytes --]
Hi Jakob,
On Mon, Sep 04, 2023 at 03:27:17PM +0100, Lee Jones wrote:
> On Sun, 03 Sep 2023, Jakob Hauser wrote:
> > Hi Sebastian,
> > On 22.08.23 23:29, Sebastian Reichel wrote:
> > > On Tue, Aug 22, 2023 at 08:07:37AM +0100, Lee Jones wrote:
> > > > On Thu, 17 Aug 2023, Lee Jones wrote:
> > > >
> > > > > On Mon, 15 May 2023 22:57:15 +0200, Jakob Hauser wrote:
> > > > > > Implement cable detection by extcon and handle the driver according to the
> > > > > > connector type.
> > > > > >
> > > > > > There are basically three types of action: "set_charging", "set_otg" and
> > > > > > "set_disconnect".
> > > > > >
> > > > > > A forth helper function to "unset_otg" was added because this is used in both
> > > > > > "set_charging" and "set_disconnect". In the first case it covers the rather
> > > > > > rare event that someone changes from OTG to charging without disconnect. In
> > > > > > the second case, when disconnecting, the values are set back to the ones from
> > > > > > initialization to return into a defined state.
> > > > > >
> > > > > > [...]
> > > > >
> > > > > Applied, thanks!
> > > > >
> > > > > [06/10] power: supply: rt5033_charger: Add cable detection and USB OTG supply
> > > > > commit: c1af6bcc8583b0a1083338cd26c2090d0bcb0810
> > > >
> > > > Multiple fixes now follow this patch, so I am unapplying it.
> > > >
> > > > Sebastian, would you mind collecting it up please?
> > >
> > > I'm leaving for a two week hiking trip (with basically no internet
> > > access) in some hours. My planed return date is basically when Linus
> > > is expected to tag 6.6-rc1, so I will not queue any more patches and
> > > send my pull request early (within the next few hours).
> > >
> > > I planned to catch up with the power-supply backlog last week during
> > > Chaos Communication Camp, but it was too hot to do any sensible
> > > review. Now I expect to process the power-supply backlog in the
> > > week after the merge window.
> >
> > The patch 6 of the rt5033-charger series v6 gathered some issues. For all of
> > them a solution was provided. Thanks to everyone involved! However, I don't
> > know what's the best way to put them together.
> >
> > - As the patch 6 was forgotten to apply with the others of the
> > patchset, in the meantime another small patch by Rob sneaked in. The
> > patch 6 needs to be rebased on Rob's patch. It affects the includes.
> > Would be nice to order them alphabetically after rebase.
> >
> > - After patch 6 was added on top of Rob's patch in linux-next, there
> > was a build failure. This is because "linux/of.h" now explicitly
> > needs to be added to the rt5033-charger driver. Stephen Rothwell
> > provided a fix. I'm not sure on the order: Maybe that needs to be
> > added before adding patch 6 to avoid the build failure when the
> > kernel test bot checks each commit separately.
> >
> > https://lore.kernel.org/linux-next/20230821125741.3a2474d7@canb.auug.org.au/T/#u
> >
> > - Beyond that, the kernel test bot also complained about undefined
> > reference related to extcon. I didn't understand why this happens
> > because the driver has "linux/extcon.h" included. Randy was attentive
> > and provided a fix. Here again I'm not sure about the order, I guess
> > this should be added before adding patch 6 to avoid build failures if
> > each commit is tested separately.
> > Kernel test bot complaints:
> > x86_64 clang https://lore.kernel.org/oe-kbuild-all/202308220324.LsI8q3ML-lkp@intel.com/T/#u
> > x86_64 gcc https://lore.kernel.org/oe-kbuild-all/202308240723.O2rW0InU-lkp@intel.com/T/#u
> > arm gcc https://lore.kernel.org/oe-kbuild-all/202308250617.ue4uQxWa-lkp@intel.com/T/#u
> > Fix by Randy:
> >
> > https://lore.kernel.org/linux-pm/20230828224201.26823-1-rdunlap@infradead.org/T/#u
> >
> > - Yang noticed that the mutex_unlock() is not handled correctly in
> > some error path and provided a fix:
> >
> > https://lore.kernel.org/linux-pm/20230822030207.644738-1-yangyingliang@huawei.com/T/#u
> >
> > - There are two clean-up patches by me. They need to be rebased to the
> > patches mentioned above but there shouldn't be conflicts with them.
> >
> > https://lore.kernel.org/linux-pm/cover.1686948074.git.jahau@rocketmail.com/T/#u
> >
> > Please also note that the commit hash in the linked fixes above refers to
> > linux-next, where the patch 6 had been applied. As the patch was dropped
> > later on, I don't know what this means for the commit hashes in the fixes.
> >
> > What's the best way to proceed? Can you put these patches together? Or do
> > you want me something to do?
>
> You need to do this yourself.
>
> Rebase all of the fixes on top of v6.6-rc1 (which will be released in a
> little under a week). Ensure that each patch builds as it's applied so
> as not to harm bisecability. If you have to squash them to prevent
> built-breakages, then so be it, but don't forget to credit the
> contributors. Once complete, post as a set and we'll take it from
> there.
Fully agreed. I expect to see a new series with the missing bits.
-- Sebastian
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply [flat|nested] 27+ messages in thread
end of thread, other threads:[~2023-09-14 15:34 UTC | newest]
Thread overview: 27+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <cover.1684182964.git.jahau.ref@rocketmail.com>
2023-05-15 20:57 ` [PATCH v6 00/10 RESEND] Add RT5033 charger device driver Jakob Hauser
2023-05-15 20:57 ` [PATCH v6 01/10 RESEND] mfd: rt5033: Drop rt5033-battery sub-device Jakob Hauser
2023-05-15 20:57 ` [PATCH v6 02/10 RESEND] mfd: rt5033: Fix chip revision readout Jakob Hauser
2023-05-15 20:57 ` [PATCH v6 03/10 RESEND] mfd: rt5033: Fix STAT_MASK, HZ_MASK and AICR defines Jakob Hauser
2023-05-15 20:57 ` [PATCH v6 04/10 RESEND] mfd: rt5033: Apply preparatory changes before adding rt5033-charger driver Jakob Hauser
2023-05-25 10:44 ` Lee Jones
2023-05-25 17:16 ` Jakob Hauser
2023-05-15 20:57 ` [PATCH v6 05/10 RESEND] power: supply: rt5033_charger: Add RT5033 charger device driver Jakob Hauser
2023-05-15 20:57 ` [PATCH v6 06/10 RESEND] power: supply: rt5033_charger: Add cable detection and USB OTG supply Jakob Hauser
2023-08-17 9:38 ` (subset) " Lee Jones
2023-08-22 7:07 ` Lee Jones
2023-08-22 21:29 ` Sebastian Reichel
2023-09-03 12:43 ` Jakob Hauser
2023-09-04 14:27 ` Lee Jones
2023-09-14 15:33 ` Sebastian Reichel
2023-05-15 20:57 ` [PATCH v6 07/10 RESEND] power: supply: rt5033_battery: Move struct rt5033_battery to battery driver Jakob Hauser
2023-05-15 20:57 ` [PATCH v6 08/10 RESEND] power: supply: rt5033_battery: Adopt status property from charger Jakob Hauser
2023-05-15 20:57 ` [PATCH v6 09/10 RESEND] dt-bindings: power: supply: rt5033-battery: Apply unevaluatedProperties Jakob Hauser
2023-05-15 21:30 ` Sebastian Reichel
2023-05-16 21:28 ` Conor Dooley
2023-05-15 20:57 ` [PATCH v6 10/10 RESEND] dt-bindings: Add rt5033 mfd, regulator and charger Jakob Hauser
[not found] ` <a308cd6f-0f72-6a12-aa34-ce06290ce0bb@rocketmail.com>
2023-06-01 14:00 ` [PATCH v6 00/10 RESEND] Add RT5033 charger device driver Lee Jones
2023-06-08 17:19 ` Lee Jones
2023-06-09 6:47 ` [GIT PULL] Immutable branch between MFD and Power due for the v6.5 merge window Lee Jones
2023-06-16 20:02 ` Jakob Hauser
2023-06-19 10:35 ` Lee Jones
2023-07-30 17:58 ` Jakob Hauser
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).