mbox series

[v10,0/9] support ROHM BD70528 PMIC

Message ID cover.1550148989.git.matti.vaittinen@fi.rohmeurope.com
Headers show
Series support ROHM BD70528 PMIC | expand

Message

Matti Vaittinen Feb. 14, 2019, 1:02 p.m. UTC
Patch series introducing support for ROHM BD70528 PMIC

ROHM BD70528 is a programmable Power Management IC for battery
powered 'ultra low power' systems like the pre-announced NXP
i.MX7 ULP. This patch series introduces support for the PMIC. Please
note that this driver only supports HW setup where PMIC is connected
to I2C on A7 core. The other scenario is to use M4 as a power manager
and connect pmic to M4. On such setups the A7 can only access pmic
via M4 core using RPMSG virtio. Such setup depends on RPMSG
implementation on M4 core and is currently not supported by this
patch series.

RTC block of the bd70528 can support 'wake' irq which wakes PMIC
from standby state. Wake irq's can be armed to wake up system up
to 24 hours from arming. bd70528 can also generate alarm interrupts
which can be armed to occur years after triggering. The RTC driver
does always arm both the waker and alarm irqs and does not utilize
longer period of alarm interrupts. All the RTC timers are limited
to occur within the next 24 hours. Any suggestions on more elegant
timer support are welcome =)

GPIO portion of bd70528 driver adds I/O support for driving GPIO
pins or reading the state. The interrupt functionality is provided
by regmap-irq. Current GPIO driver is not aware of whether the pin(s)
are used for I/O or interrupts and it is up-to driver user to
ensure there is no misconfiguration or "double use".

The power-supply patch included in series is only poorly tested as I
lack of hardware with real battery connected. Reset and ADC are not
supported by this series.

Changelog v10:
- Exported locking functions for RTC lock and as a result dropped hid
  the struct bd70528 from sub-devices who no longer needed it.
- removed linux/gpio.h header from GPIO driver.

Changelog v9: Changes suggested by Lee Jones
- MFD, DT-binding, RTC and WDT changed
- DT-bindings: Spelling fixes
- RTC and WDT: Use exported function instead of function pointer for WDT
  arming/disarming
- MFD: Export WDT arming/disarming function instead of providing a
  pointer to it.
- Various styling fixes.

Changelog v8:
- regulators(*), wdt, gpio, rtc, mfd(*) and dt-bindings unchanged.
  (*)Patches 1-3 squashed to not break bisecting.

- removed unnecessary newline from clk
- fixed possible use of uninitialized 'reg' from power-supply.
  Found by 0-day tests and reported by Dan Carpenter.

Changelog v7:
Only patch 2 changed.
- Avoid out-of-array-bounds access at regulator probe if unsupported
  chip type is passed to bd718x7 regulator driver.

Changelog v6:
Only patch 10 changed.
- styling fixes pointed by Gunter Roeck
- dropped RFC tag

Changelog v5 (RFC):
Only patch 7 changed.
- Explained why lock is not needed at GPIO value getting
- removed ampersands from function pointer assignments.

Changelog v4 (RFC):
patches 1,2,3,4,5,10 are unchanged from v3
DT-binding fixes suggested by Rob Herring:
- drop interrupt-parent
- drop clock-frequency
- change pmic node name to a generic one
RTC:
- enable RTC block's irqs before registering rtc
GPIO fixes after initial testing:
- fix getting GPIO value when direction is output
POWER:
- Add ASCII art intended to clarify the charger HW state machine

Changelog v3 (RFC):
patches 1,2,3,4,5,6,7,8 and 10 are unchanged from v2
RTC fixups suggested by Guenter Roeck:
- create bd70528_set_time_locked function in order to simplify
  error handling and to make mutex lock/unlock path more obvious
- don't ignore errors on bd70528_set_time_locked
- simplify bd70528_read_alarm enabled condition setting
- add __packed to structs where members are mapped to HW registers
- remove unnecessary brackets from enable condition in set_wake
RTC: fixups suggested by Alessandro Belloni
- don't use deprecated devm_rtc_device_register
- add alarm_irq_enable callback
- add range_min and range_max
WDT:
- add regmap and mutex pointers to WDT data so that they can be accessed
  without dereferencing the parent data
- remove parent data pointer from WDT data
- embed struct watchdog_device into WDT data in order to avoid double
  allocation.
GPIO:
- remove unused header as pointed by Linus Walleij
POWER:
- do not copy the whole MFD data (especially the mutex to avoid
  all possibilities of accidentally using the copy of a mutex)

Changelog v2 (RFC): Mainly feedback from Guenter Roeck:
- patches 1, 2, 3, 4, 5, 9 are unchanged.
- mfd: own mutex for each bd70528 instance - embed in struct bd70528
- watchdog: do not copy parent device data
- watchdog: fix deadlock caused by double locked mutex
- watchdog: set initial timeouts and WDT parent information
- watchdog: remove unnecessary ping function from ops
- watchdog: and the comment regarding it
- watchdog: allocate watchdog struct in order to allow multiple WDG
  instances
- rtc: bd70528 fix the order of mutex unlock and re-enabling RTC based
  timers
- rtc: fix the irq mask register address
- power: fix the irq mask register address
- regulator/regmap-irq: Drop the patches 1, 8 and 9 from original series
  as those were already applied by Mark 

Patch 1:
	split the bd718x7.h to generic and chip specific portions.
	(breaks compilation without patch 2 and 3)
	- adapt bd718x7.h changes to bd718x7 regulator driver
	- adapt bd718x7.h changes to bd718x7 clk driver
Patch 2:
	add MFD core support for bd70528
Patch 3:
	support bd70528 clk using bd718x7 clk driver
Patch 4:
	document DT bindings for BD70528
Patch 5:
	support BD70528 GPIO block
Patch 6:
	support BD70528 RTC
Patch 7:
	support BD70528 battery charger
Patch 8:
	support BD70528 watchdog
Patch 9:
	drop struct bd70528 from regulator

This patch series is based on Mark's regulator/for-next branch

---

Matti Vaittinen (9):
  mfd: regulator: clk: split rohm-bd718x7.h
  mfd: bd70528: Support ROHM bd70528 PMIC - core
  clk: bd718x7: Support ROHM BD70528 clk block
  devicetree: bindings: Document first ROHM BD70528 bindings
  gpio: Initial support for ROHM bd70528 GPIO block
  rtc: bd70528: Initial support for ROHM bd70528 RTC
  power: supply: Initial support for ROHM BD70528 PMIC charger block
  watchdog: bd70528: Initial support for ROHM BD70528 watchdog block
  regulator: bd70528: drop struct bd70528

 .../devicetree/bindings/mfd/rohm,bd70528-pmic.txt  | 102 +++
 drivers/clk/Kconfig                                |   6 +-
 drivers/clk/clk-bd718x7.c                          |  24 +-
 drivers/gpio/Kconfig                               |  11 +
 drivers/gpio/Makefile                              |   1 +
 drivers/gpio/gpio-bd70528.c                        | 231 +++++++
 drivers/mfd/Kconfig                                |  17 +
 drivers/mfd/Makefile                               |   1 +
 drivers/mfd/rohm-bd70528.c                         | 438 ++++++++++++
 drivers/mfd/rohm-bd718x7.c                         |  23 +-
 drivers/power/supply/Kconfig                       |   9 +
 drivers/power/supply/Makefile                      |   1 +
 drivers/power/supply/bd70528-charger.c             | 745 +++++++++++++++++++++
 drivers/regulator/bd70528-regulator.c              |   4 +-
 drivers/regulator/bd718x7-regulator.c              |  24 +-
 drivers/rtc/Kconfig                                |   8 +
 drivers/rtc/Makefile                               |   1 +
 drivers/rtc/rtc-bd70528.c                          | 500 ++++++++++++++
 drivers/watchdog/Kconfig                           |  12 +
 drivers/watchdog/Makefile                          |   1 +
 drivers/watchdog/bd70528_wdt.c                     | 187 ++++++
 include/linux/mfd/rohm-bd70528.h                   | 383 +++++++++++
 include/linux/mfd/rohm-bd718x7.h                   |  22 +-
 include/linux/mfd/rohm-generic.h                   |  20 +
 24 files changed, 2723 insertions(+), 48 deletions(-)
 create mode 100644 Documentation/devicetree/bindings/mfd/rohm,bd70528-pmic.txt
 create mode 100644 drivers/gpio/gpio-bd70528.c
 create mode 100644 drivers/mfd/rohm-bd70528.c
 create mode 100644 drivers/power/supply/bd70528-charger.c
 create mode 100644 drivers/rtc/rtc-bd70528.c
 create mode 100644 drivers/watchdog/bd70528_wdt.c
 create mode 100644 include/linux/mfd/rohm-bd70528.h
 create mode 100644 include/linux/mfd/rohm-generic.h

Comments

Matti Vaittinen Feb. 28, 2019, 7:04 a.m. UTC | #1
Hello Lee and Mark,

On Thu, Feb 14, 2019 at 03:02:37PM +0200, Matti Vaittinen wrote:
> Patch series introducing support for ROHM BD70528 PMIC
> 
> ROHM BD70528 is a programmable Power Management IC for battery
> powered 'ultra low power' systems like the pre-announced NXP
> i.MX7 ULP. This patch series introduces support for the PMIC. Please
> note that this driver only supports HW setup where PMIC is connected
> to I2C on A7 core. The other scenario is to use M4 as a power manager
> and connect pmic to M4. On such setups the A7 can only access pmic
> via M4 core using RPMSG virtio. Such setup depends on RPMSG
> implementation on M4 core and is currently not supported by this
> patch series.
> 

I was wondering if there is anything that could be done to allow the MFD
part of this series to end up in upstream without having to wait the
regmap-irq changes
(https://git.kernel.org/pub/scm/linux/kernel/git/broonie/regmap.git/commit/?h=topic/irq)
 to be merged from Linus' tree to MFD tree? If I see it correctly, the
regmap-irq (main-irq-reg support) changes are not targeted to linux 5.1.
To me it looks like getting them to MFD via Linus' tree will take a while.

The MFD part depends on the regmap-irq changes and I think that most
other subsystems want to have the MFD changes in before taking rest of
the driver in their trees. So it will be a while untill all the changes
are in. It would really be nice to have the drive in-tree sooner - hence
I ask if theres a way. (I don't want to push, just ask if it is possible :])

Best Regards
	Matti Vaittinen
Lee Jones Feb. 28, 2019, 8:10 a.m. UTC | #2
On Thu, 28 Feb 2019, Matti Vaittinen wrote:

> Hello Lee and Mark,
> 
> On Thu, Feb 14, 2019 at 03:02:37PM +0200, Matti Vaittinen wrote:
> > Patch series introducing support for ROHM BD70528 PMIC
> > 
> > ROHM BD70528 is a programmable Power Management IC for battery
> > powered 'ultra low power' systems like the pre-announced NXP
> > i.MX7 ULP. This patch series introduces support for the PMIC. Please
> > note that this driver only supports HW setup where PMIC is connected
> > to I2C on A7 core. The other scenario is to use M4 as a power manager
> > and connect pmic to M4. On such setups the A7 can only access pmic
> > via M4 core using RPMSG virtio. Such setup depends on RPMSG
> > implementation on M4 core and is currently not supported by this
> > patch series.
> > 
> 
> I was wondering if there is anything that could be done to allow the MFD
> part of this series to end up in upstream without having to wait the
> regmap-irq changes
> (https://git.kernel.org/pub/scm/linux/kernel/git/broonie/regmap.git/commit/?h=topic/irq)
>  to be merged from Linus' tree to MFD tree? If I see it correctly, the
> regmap-irq (main-irq-reg support) changes are not targeted to linux 5.1.
> To me it looks like getting them to MFD via Linus' tree will take a while.
> 
> The MFD part depends on the regmap-irq changes and I think that most
> other subsystems want to have the MFD changes in before taking rest of
> the driver in their trees. So it will be a while untill all the changes
> are in. It would really be nice to have the drive in-tree sooner - hence
> I ask if theres a way. (I don't want to push, just ask if it is possible :])

It's possible, so long as there aren't any build-time dependencies
between the subsystems.  Immediate acceptance however isn't possible
due to the impending merge-window which opens in 3 days.
Matti Vaittinen Feb. 28, 2019, 8:22 a.m. UTC | #3
Hello Lee, Mark,

On Thu, Feb 28, 2019 at 08:10:55AM +0000, Lee Jones wrote:
> On Thu, 28 Feb 2019, Matti Vaittinen wrote:
> 
> > Hello Lee and Mark,
> > 
> > On Thu, Feb 14, 2019 at 03:02:37PM +0200, Matti Vaittinen wrote:
> > > Patch series introducing support for ROHM BD70528 PMIC
> > > 
> > I was wondering if there is anything that could be done to allow the MFD
> > part of this series to end up in upstream without having to wait the
> > regmap-irq changes
> > (https://git.kernel.org/pub/scm/linux/kernel/git/broonie/regmap.git/commit/?h=topic/irq)
> >  to be merged from Linus' tree to MFD tree? If I see it correctly, the
> > regmap-irq (main-irq-reg support) changes are not targeted to linux 5.1.
> > To me it looks like getting them to MFD via Linus' tree will take a while.
> > 
> > The MFD part depends on the regmap-irq changes and I think that most
> > other subsystems want to have the MFD changes in before taking rest of
> > the driver in their trees. So it will be a while untill all the changes
> > are in. It would really be nice to have the drive in-tree sooner - hence
> > I ask if theres a way. (I don't want to push, just ask if it is possible :])
> 
> It's possible, so long as there aren't any build-time dependencies
> between the subsystems.  Immediate acceptance however isn't possible
> due to the impending merge-window which opens in 3 days.

Thanks for reply Lee. So merge-window is opening - meaning the 5.1 is
being baked now(?) 

Anyays to make it clear - there is build time dependency between MFD and
regmap-irq changes. MFD part won't compile without the changes in regmap
tree. And theres no new Kconfig to depend on or other compile time
checks. So REGMAP changes are required for this MFD portion to compile.

So my question actually is if the MFD portion must wait untill REGMAP
goes to Linus tree (at 5.2(?))- and then get merged to MFD tree later -
or if the regmap-irq changes can go to MFD via some other route (sorry -
I don't really know how you guys do maintain the trees - I really lack
of the insight/skills on that area :])

Rest of the subsystems (regulator, clk, watchdog, gpio) do all depend on
MFD - but they should have 'depends on' KConfig to MFD meaning they
won't be built without MFD.

Br,
	Matti Vaittinen
Mark Brown Feb. 28, 2019, 11:40 a.m. UTC | #4
On Thu, Feb 28, 2019 at 09:04:50AM +0200, Matti Vaittinen wrote:
> On Thu, Feb 14, 2019 at 03:02:37PM +0200, Matti Vaittinen wrote:

>> Patch series introducing support for ROHM BD70528 PMIC
> 
> I was wondering if there is anything that could be done to allow the MFD
> part of this series to end up in upstream without having to wait the
> regmap-irq changes
> (https://git.kernel.org/pub/scm/linux/kernel/git/broonie/regmap.git/commit/?h=topic/irq)
>  to be merged from Linus' tree to MFD tree? If I see it correctly, the
> regmap-irq (main-irq-reg support) changes are not targeted to linux 5.1.
> To me it looks like getting them to MFD via Linus' tree will take a while.

They're targeted for v5.1 and I sent a pull request to Lee for that
branch IIRC.
Matti Vaittinen March 6, 2019, 10:38 a.m. UTC | #5
On Thu, Feb 28, 2019 at 11:40:26AM +0000, Mark Brown wrote:
> On Thu, Feb 28, 2019 at 09:04:50AM +0200, Matti Vaittinen wrote:
> > On Thu, Feb 14, 2019 at 03:02:37PM +0200, Matti Vaittinen wrote:
> 
> >> Patch series introducing support for ROHM BD70528 PMIC
> > 
> > I was wondering if there is anything that could be done to allow the MFD
> > part of this series to end up in upstream without having to wait the
> > regmap-irq changes
> > (https://git.kernel.org/pub/scm/linux/kernel/git/broonie/regmap.git/commit/?h=topic/irq)
> >  to be merged from Linus' tree to MFD tree? If I see it correctly, the
> > regmap-irq (main-irq-reg support) changes are not targeted to linux 5.1.
> > To me it looks like getting them to MFD via Linus' tree will take a while.
> 
> They're targeted for v5.1 and I sent a pull request to Lee for that
> branch IIRC.
Thanks Mark. I think I have misunderstood how you deliver changes to 5.1
- or then I have done some other mistake. I thought these changes were
  not going to 5.1 as I did not see them in your for-5.1 branch. But I
probably did some error there. Thanks for explaining this :)

Br,
	Matti Vaittinen
Matti Vaittinen March 25, 2019, 7:36 a.m. UTC | #6
Hello again Lee & all,

On Thu, Feb 28, 2019 at 10:22:48AM +0200, Matti Vaittinen wrote:
> On Thu, Feb 28, 2019 at 08:10:55AM +0000, Lee Jones wrote:
> > On Thu, 28 Feb 2019, Matti Vaittinen wrote:
> > 
> > > Hello Lee and Mark,
> > > 
> > > On Thu, Feb 14, 2019 at 03:02:37PM +0200, Matti Vaittinen wrote:
> > > > Patch series introducing support for ROHM BD70528 PMIC

//snip

> > > 
> > > The MFD part depends on the regmap-irq changes and I think that most
> > > other subsystems want to have the MFD changes in before taking rest of
> > > the driver in their trees. So it will be a while untill all the changes
> > > are in. It would really be nice to have the drive in-tree sooner - hence
> > > I ask if theres a way. (I don't want to push, just ask if it is possible :])
> > 
> > It's possible, so long as there aren't any build-time dependencies
> > between the subsystems.  Immediate acceptance however isn't possible
> > due to the impending merge-window which opens in 3 days.
> 
> Thanks for reply Lee. So merge-window is opening - meaning the 5.1 is
> being baked now(?) 
> 
> Anyays to make it clear - there is build time dependency between MFD and
> regmap-irq changes. MFD part won't compile without the changes in regmap
> tree. And theres no new Kconfig to depend on or other compile time
> checks. So REGMAP changes are required for this MFD portion to compile.

//snip

> Rest of the subsystems (regulator, clk, watchdog, gpio) do all depend on
> MFD - but they should have 'depends on' KConfig to MFD meaning they
> won't be built without MFD.

I see the 5.1-rc1 and 5.1-rc2 are out. Those contain the regmap-irq
changes the BD70528 MFD driver depends on. Would you like me to rebase
the series to some other tree (which tree/branch? I don't see updated
for-mfd-next branch in kernel.org yet) and resend it? Original patch
series was created on top of the regulator tree.

Br,
	Matti Vaittinen
Lee Jones March 25, 2019, 8:02 a.m. UTC | #7
On Mon, 25 Mar 2019, Matti Vaittinen wrote:

> Hello again Lee & all,
> 
> On Thu, Feb 28, 2019 at 10:22:48AM +0200, Matti Vaittinen wrote:
> > On Thu, Feb 28, 2019 at 08:10:55AM +0000, Lee Jones wrote:
> > > On Thu, 28 Feb 2019, Matti Vaittinen wrote:
> > > 
> > > > Hello Lee and Mark,
> > > > 
> > > > On Thu, Feb 14, 2019 at 03:02:37PM +0200, Matti Vaittinen wrote:
> > > > > Patch series introducing support for ROHM BD70528 PMIC
> 
> //snip
> 
> > > > 
> > > > The MFD part depends on the regmap-irq changes and I think that most
> > > > other subsystems want to have the MFD changes in before taking rest of
> > > > the driver in their trees. So it will be a while untill all the changes
> > > > are in. It would really be nice to have the drive in-tree sooner - hence
> > > > I ask if theres a way. (I don't want to push, just ask if it is possible :])
> > > 
> > > It's possible, so long as there aren't any build-time dependencies
> > > between the subsystems.  Immediate acceptance however isn't possible
> > > due to the impending merge-window which opens in 3 days.
> > 
> > Thanks for reply Lee. So merge-window is opening - meaning the 5.1 is
> > being baked now(?) 
> > 
> > Anyays to make it clear - there is build time dependency between MFD and
> > regmap-irq changes. MFD part won't compile without the changes in regmap
> > tree. And theres no new Kconfig to depend on or other compile time
> > checks. So REGMAP changes are required for this MFD portion to compile.
> 
> //snip
> 
> > Rest of the subsystems (regulator, clk, watchdog, gpio) do all depend on
> > MFD - but they should have 'depends on' KConfig to MFD meaning they
> > won't be built without MFD.
> 
> I see the 5.1-rc1 and 5.1-rc2 are out. Those contain the regmap-irq
> changes the BD70528 MFD driver depends on. Would you like me to rebase
> the series to some other tree (which tree/branch? I don't see updated
> for-mfd-next branch in kernel.org yet) and resend it? Original patch
> series was created on top of the regulator tree.

If you could rebase and resend, that would be great.

You should (very nearly) always base on an upstream tag, so v5.1-rc2
would be best in this case.
Matti Vaittinen March 25, 2019, 8:20 a.m. UTC | #8
On Mon, Mar 25, 2019 at 08:02:06AM +0000, Lee Jones wrote:
> On Mon, 25 Mar 2019, Matti Vaittinen wrote:
> 
> > Hello again Lee & all,
> > 
> > On Thu, Feb 28, 2019 at 10:22:48AM +0200, Matti Vaittinen wrote:
> > > On Thu, Feb 28, 2019 at 08:10:55AM +0000, Lee Jones wrote:
> > > > On Thu, 28 Feb 2019, Matti Vaittinen wrote:
> > > > 
> > > > > Hello Lee and Mark,
> > > > > 
> > > > > On Thu, Feb 14, 2019 at 03:02:37PM +0200, Matti Vaittinen wrote:
> > > > > > Patch series introducing support for ROHM BD70528 PMIC
> > 
> > I see the 5.1-rc1 and 5.1-rc2 are out. Those contain the regmap-irq
> > changes the BD70528 MFD driver depends on. Would you like me to rebase
> > the series to some other tree (which tree/branch? I don't see updated
> > for-mfd-next branch in kernel.org yet) and resend it? Original patch
> > series was created on top of the regulator tree.
> 
> If you could rebase and resend, that would be great.
> 
> You should (very nearly) always base on an upstream tag, so v5.1-rc2
> would be best in this case.

So always use tag from "kernel/git/torvalds/linux.git" tree? Thanks for
this guidance :) I'll try getting this rebased and resent today or
tomorrow.

Br,
	Matti Vaittinen

> 
> -- 
> Lee Jones [李琼斯]
> Linaro Services Technical Lead
> Linaro.org │ Open source software for ARM SoCs
> Follow Linaro: Facebook | Twitter | Blog