mbox series

[v4,0/5] Add RK816 PMIC support

Message ID 20240416161237.2500037-1-knaerzche@gmail.com
Headers show
Series Add RK816 PMIC support | expand

Message

Alex Bee April 16, 2024, 4:12 p.m. UTC
This series aims to add support for Rockchip RK816 PMIC series. As per
datasheet it's targeted for RK3126/RK3128 (RK816-1), RK1108 (RK816-2) and
PX3-SE (RK816-3) but might be used for other SoCs as well. The MFD consists
of an integrated RTC, a GPIO controller, two 32k clock outputs, a power
key, 3 buck- and 6 ldo regulators, 3 regulator-switches, and charger with
integrated fuel gauge. Charger and fuel gauge are not part of this series.
Two of the switches (otg/boost) are part of the binding, but not of
the driver. They must only ever be enabled if no battery charging is
happening, but it will be enabled automatically if a battery is attached
and an external power source is connected. Thus that needs some
incorporation of a yet to be added charger driver.
Integration in the existing rk8xx-infrastructure was pretty straightforward
and only needed very little tweaking. In order to not further bloat the
driver(s) too much with additional `#define`s I tried to re-use existing
ones wherever possible.

The patches are loosely based on the vendor's implementation, verified
against the datasheet and tested/measured on a RK3126 board.

I'd like to gently ping pinctrl and regulator maintainers: please have a
look at this series. I've now added Sebastian Reichel to the recipients, as
he recently added RK806 support and re-worked parts of the rk8xx drivers.

changes since v1:
  - integrated Krzysztof's feedback for the bindings and the resulting
    driver changes
  - fixed a sparse warning 

link to v1:
https://lore.kernel.org/lkml/20240321143911.90210-2-knaerzche@gmail.com/

changes since v2:
  - integrated Krzysztof's feedback to v2 of the bindings and the resulting
    driver changes

link to v2:
https://lore.kernel.org/lkml/20240323085852.116756-1-knaerzche@gmail.com/

changes since v3:
  - integrated Krzysztof's feedback to the bindings of v3 
  - integrated Lee's feedback to the mfd part of v3 

link to v3:
https://lore.kernel.org/lkml/20240323132757.141861-2-knaerzche@gmail.com/

Please see individual patches for details about the changes.

Alex Bee (5):
  dt-bindings: mfd: Add rk816 binding
  mfd: rk8xx: Add RK816 support
  pinctrl: rk805: Add rk816 pinctrl support
  regulator: rk808: Support apply_bit for
    rk808_set_suspend_voltage_range
  regulator: rk808: Add RK816 support

 .../bindings/mfd/rockchip,rk816.yaml          | 274 ++++++++++++++++++
 drivers/mfd/Kconfig                           |   4 +-
 drivers/mfd/rk8xx-core.c                      | 104 +++++++
 drivers/mfd/rk8xx-i2c.c                       |  45 ++-
 drivers/pinctrl/pinctrl-rk805.c               |  69 +++++
 drivers/regulator/rk808-regulator.c           | 218 +++++++++++++-
 include/linux/mfd/rk808.h                     | 144 +++++++++
 7 files changed, 851 insertions(+), 7 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/mfd/rockchip,rk816.yaml

Comments

Linus Walleij April 17, 2024, 8:57 a.m. UTC | #1
On Tue, Apr 16, 2024 at 6:12 PM Alex Bee <knaerzche@gmail.com> wrote:

> This adds support for RK816 to the exising rk805 pinctrl driver
>
> It has a single pin which can be configured as input from a thermistor (for
> instance in an attached battery) or as a gpio.
>
> Signed-off-by: Alex Bee <knaerzche@gmail.com>

Looks good to me, is this patch something I can just merge
once the maintainers have reviewed it?

Yours,
Linus Walleij
Alex Bee April 18, 2024, 5:48 p.m. UTC | #2
Hi Linus

Am 17.04.24 um 10:57 schrieb Linus Walleij:
> On Tue, Apr 16, 2024 at 6:12 PM Alex Bee <knaerzche@gmail.com> wrote:
>
>> This adds support for RK816 to the exising rk805 pinctrl driver
>>
>> It has a single pin which can be configured as input from a thermistor (for
>> instance in an attached battery) or as a gpio.
>>
>> Signed-off-by: Alex Bee <knaerzche@gmail.com>
> Looks good to me, is this patch something I can just merge
> once the maintainers have reviewed it?
This patch depends on the mfd patch as it includes some definitions which
are used here. Same is true for the regulator patch. So I guess this whole
series has to go via the mfd tree and it would be probably the best if the
other subsystem maintainers could ack/review the other patches.

Regards,
Alex

>
> Yours,
> Linus Walleij
Linus Walleij April 19, 2024, 1:31 p.m. UTC | #3
On Tue, Apr 16, 2024 at 6:12 PM Alex Bee <knaerzche@gmail.com> wrote:

> This adds support for RK816 to the exising rk805 pinctrl driver
>
> It has a single pin which can be configured as input from a thermistor (for
> instance in an attached battery) or as a gpio.
>
> Signed-off-by: Alex Bee <knaerzche@gmail.com>

Reviewed-by: Linus Walleij <linus.walleij@linaro.org>

Lee: pls apply with the rest to the MFD subsystem when you
are happy with the patches.

Yours,
Linus Walleij
Mark Brown April 23, 2024, 5:21 a.m. UTC | #4
On Tue, Apr 16, 2024 at 06:12:36PM +0200, Alex Bee wrote:
> rk808_set_suspend_voltage_range currently does not account the existence of
> apply_bit/apply_reg.
> 
> This adds support for those in same way it is done in
> regulator_set_voltage_sel_regmap and is required for the upcoming RK816
> support

Acked-by: Mark Brown <broonie@kernel.org>
Mark Brown April 23, 2024, 5:21 a.m. UTC | #5
On Tue, Apr 16, 2024 at 06:12:37PM +0200, Alex Bee wrote:
> Add support for rk816 to the existing rk808 regulator driver.
> 
> The infrastructure of the driver can be re-used as is. A peculiarity for
> this version is, that BUCK1/BUCK2 have a (common) bit which needs to
> toggled after a voltage change to confirm the change. Regulator regmap
> takes care of that by defining a apply_bit and apply_reg for those
> regulators.

Reviewed-by: Mark Brown <broonie@kernel.org>
Alex Bee May 3, 2024, 8:01 a.m. UTC | #6
Hi Lee,

it looks like all patches except the MFD ones have been reviewed/acked by
now. I hope I integrated your feedback to v3 [0] in a way you were
expecting. Also I was hoping this whole series could be go though the MFD
tree, since all the none-MFD patches depend on the changes mfd-header.

Please let me know if there is anything left for me to do.

Thanks,

Alex

[0] 
https://lore.kernel.org/lkml/20240323132757.141861-2-knaerzche@gmail.com/T/#m1bb23196c192289f898aebc64ccf62edb9ef5b5a

Am 16.04.24 um 18:12 schrieb Alex Bee:
> This series aims to add support for Rockchip RK816 PMIC series. As per
> datasheet it's targeted for RK3126/RK3128 (RK816-1), RK1108 (RK816-2) and
> PX3-SE (RK816-3) but might be used for other SoCs as well. The MFD consists
> of an integrated RTC, a GPIO controller, two 32k clock outputs, a power
> key, 3 buck- and 6 ldo regulators, 3 regulator-switches, and charger with
> integrated fuel gauge. Charger and fuel gauge are not part of this series.
> Two of the switches (otg/boost) are part of the binding, but not of
> the driver. They must only ever be enabled if no battery charging is
> happening, but it will be enabled automatically if a battery is attached
> and an external power source is connected. Thus that needs some
> incorporation of a yet to be added charger driver.
> Integration in the existing rk8xx-infrastructure was pretty straightforward
> and only needed very little tweaking. In order to not further bloat the
> driver(s) too much with additional `#define`s I tried to re-use existing
> ones wherever possible.
>
> The patches are loosely based on the vendor's implementation, verified
> against the datasheet and tested/measured on a RK3126 board.
>
> I'd like to gently ping pinctrl and regulator maintainers: please have a
> look at this series. I've now added Sebastian Reichel to the recipients, as
> he recently added RK806 support and re-worked parts of the rk8xx drivers.
>
> changes since v1:
>    - integrated Krzysztof's feedback for the bindings and the resulting
>      driver changes
>    - fixed a sparse warning
>
> link to v1:
> https://lore.kernel.org/lkml/20240321143911.90210-2-knaerzche@gmail.com/
>
> changes since v2:
>    - integrated Krzysztof's feedback to v2 of the bindings and the resulting
>      driver changes
>
> link to v2:
> https://lore.kernel.org/lkml/20240323085852.116756-1-knaerzche@gmail.com/
>
> changes since v3:
>    - integrated Krzysztof's feedback to the bindings of v3
>    - integrated Lee's feedback to the mfd part of v3
>
> link to v3:
> https://lore.kernel.org/lkml/20240323132757.141861-2-knaerzche@gmail.com/
>
> Please see individual patches for details about the changes.
>
> Alex Bee (5):--
>    dt-bindings: mfd: Add rk816 binding
>    mfd: rk8xx: Add RK816 support
>    pinctrl: rk805: Add rk816 pinctrl support
>    regulator: rk808: Support apply_bit for
>      rk808_set_suspend_voltage_range
>    regulator: rk808: Add RK816 support
>
>   .../bindings/mfd/rockchip,rk816.yaml          | 274 ++++++++++++++++++
>   drivers/mfd/Kconfig                           |   4 +-
>   drivers/mfd/rk8xx-core.c                      | 104 +++++++
>   drivers/mfd/rk8xx-i2c.c                       |  45 ++-
>   drivers/pinctrl/pinctrl-rk805.c               |  69 +++++
>   drivers/regulator/rk808-regulator.c           | 218 +++++++++++++-
>   include/linux/mfd/rk808.h                     | 144 +++++++++
>   7 files changed, 851 insertions(+), 7 deletions(-)
>   create mode 100644 Documentation/devicetree/bindings/mfd/rockchip,rk816.yaml
>
Lee Jones May 3, 2024, 8:11 a.m. UTC | #7
On Fri, 03 May 2024, Alex Bee wrote:

> Hi Lee,
> 
> it looks like all patches except the MFD ones have been reviewed/acked by
> now. I hope I integrated your feedback to v3 [0] in a way you were
> expecting. Also I was hoping this whole series could be go though the MFD
> tree, since all the none-MFD patches depend on the changes mfd-header.
> 
> Please let me know if there is anything left for me to do.

I have the patch open 'right now', please bear with me.
Lee Jones May 3, 2024, 8:17 a.m. UTC | #8
On Tue, 16 Apr 2024 18:12:32 +0200, Alex Bee wrote:
> This series aims to add support for Rockchip RK816 PMIC series. As per
> datasheet it's targeted for RK3126/RK3128 (RK816-1), RK1108 (RK816-2) and
> PX3-SE (RK816-3) but might be used for other SoCs as well. The MFD consists
> of an integrated RTC, a GPIO controller, two 32k clock outputs, a power
> key, 3 buck- and 6 ldo regulators, 3 regulator-switches, and charger with
> integrated fuel gauge. Charger and fuel gauge are not part of this series.
> Two of the switches (otg/boost) are part of the binding, but not of
> the driver. They must only ever be enabled if no battery charging is
> happening, but it will be enabled automatically if a battery is attached
> and an external power source is connected. Thus that needs some
> incorporation of a yet to be added charger driver.
> Integration in the existing rk8xx-infrastructure was pretty straightforward
> and only needed very little tweaking. In order to not further bloat the
> driver(s) too much with additional `#define`s I tried to re-use existing
> ones wherever possible.
> 
> [...]

Applied, thanks!

[1/5] dt-bindings: mfd: Add rk816 binding
      commit: 06dfb41b1cf8d64327e5c4391e165f466506c4f0
[2/5] mfd: rk8xx: Add RK816 support
      commit: e9006f81faf8e438ea83626db578610e49f31576
[3/5] pinctrl: rk805: Add rk816 pinctrl support
      commit: 1bd97d64b5f0c01d03ecc9473ccfcf180dbbf54a
[4/5] regulator: rk808: Support apply_bit for rk808_set_suspend_voltage_range
      commit: 9f4e899c286b5127e2443d50e37ee2112efbfa2c
[5/5] regulator: rk808: Add RK816 support
      commit: 5eb068da74a0b443fb99a89d9e5062691649c470

--
Lee Jones [李琼斯]
Lee Jones May 3, 2024, 8:18 a.m. UTC | #9
On Fri, 03 May 2024, Lee Jones wrote:

> On Tue, 16 Apr 2024 18:12:32 +0200, Alex Bee wrote:
> > This series aims to add support for Rockchip RK816 PMIC series. As per
> > datasheet it's targeted for RK3126/RK3128 (RK816-1), RK1108 (RK816-2) and
> > PX3-SE (RK816-3) but might be used for other SoCs as well. The MFD consists
> > of an integrated RTC, a GPIO controller, two 32k clock outputs, a power
> > key, 3 buck- and 6 ldo regulators, 3 regulator-switches, and charger with
> > integrated fuel gauge. Charger and fuel gauge are not part of this series.
> > Two of the switches (otg/boost) are part of the binding, but not of
> > the driver. They must only ever be enabled if no battery charging is
> > happening, but it will be enabled automatically if a battery is attached
> > and an external power source is connected. Thus that needs some
> > incorporation of a yet to be added charger driver.
> > Integration in the existing rk8xx-infrastructure was pretty straightforward
> > and only needed very little tweaking. In order to not further bloat the
> > driver(s) too much with additional `#define`s I tried to re-use existing
> > ones wherever possible.
> > 
> > [...]
> 
> Applied, thanks!
> 
> [1/5] dt-bindings: mfd: Add rk816 binding
>       commit: 06dfb41b1cf8d64327e5c4391e165f466506c4f0
> [2/5] mfd: rk8xx: Add RK816 support
>       commit: e9006f81faf8e438ea83626db578610e49f31576
> [3/5] pinctrl: rk805: Add rk816 pinctrl support
>       commit: 1bd97d64b5f0c01d03ecc9473ccfcf180dbbf54a
> [4/5] regulator: rk808: Support apply_bit for rk808_set_suspend_voltage_range
>       commit: 9f4e899c286b5127e2443d50e37ee2112efbfa2c
> [5/5] regulator: rk808: Add RK816 support
>       commit: 5eb068da74a0b443fb99a89d9e5062691649c470

Submitted for build testing.

If successful, I'll follow-up with a PR.
Alex Bee May 3, 2024, 8:29 a.m. UTC | #10
Am 03.05.24 um 10:18 schrieb Lee Jones:
> On Fri, 03 May 2024, Lee Jones wrote:
>
>> On Tue, 16 Apr 2024 18:12:32 +0200, Alex Bee wrote:
>>> This series aims to add support for Rockchip RK816 PMIC series. As per
>>> datasheet it's targeted for RK3126/RK3128 (RK816-1), RK1108 (RK816-2) and
>>> PX3-SE (RK816-3) but might be used for other SoCs as well. The MFD consists
>>> of an integrated RTC, a GPIO controller, two 32k clock outputs, a power
>>> key, 3 buck- and 6 ldo regulators, 3 regulator-switches, and charger with
>>> integrated fuel gauge. Charger and fuel gauge are not part of this series.
>>> Two of the switches (otg/boost) are part of the binding, but not of
>>> the driver. They must only ever be enabled if no battery charging is
>>> happening, but it will be enabled automatically if a battery is attached
>>> and an external power source is connected. Thus that needs some
>>> incorporation of a yet to be added charger driver.
>>> Integration in the existing rk8xx-infrastructure was pretty straightforward
>>> and only needed very little tweaking. In order to not further bloat the
>>> driver(s) too much with additional `#define`s I tried to re-use existing
>>> ones wherever possible.
>>>
>>> [...]
>> Applied, thanks!
>>
>> [1/5] dt-bindings: mfd: Add rk816 binding
>>        commit: 06dfb41b1cf8d64327e5c4391e165f466506c4f0
>> [2/5] mfd: rk8xx: Add RK816 support
>>        commit: e9006f81faf8e438ea83626db578610e49f31576
>> [3/5] pinctrl: rk805: Add rk816 pinctrl support
>>        commit: 1bd97d64b5f0c01d03ecc9473ccfcf180dbbf54a
>> [4/5] regulator: rk808: Support apply_bit for rk808_set_suspend_voltage_range
>>        commit: 9f4e899c286b5127e2443d50e37ee2112efbfa2c
>> [5/5] regulator: rk808: Add RK816 support
>>        commit: 5eb068da74a0b443fb99a89d9e5062691649c470
> Submitted for build testing.
>
> If successful, I'll follow-up with a PR.

Great, thanks a lot.

Alex