* [PATCH 1/4] regulator: pfuze: remove unsued define @ 2020-01-27 15:50 Michael Grzeschik 2020-01-27 15:50 ` [PATCH 2/4] regulator: pfuze: add support to other architectures Michael Grzeschik ` (2 more replies) 0 siblings, 3 replies; 8+ messages in thread From: Michael Grzeschik @ 2020-01-27 15:50 UTC (permalink / raw) To: barebox Signed-off-by: Michael Grzeschik <m.grzeschik@pengutronix.de> --- drivers/regulator/pfuze.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/drivers/regulator/pfuze.c b/drivers/regulator/pfuze.c index 1950ffb04c..55f7eb5d4c 100644 --- a/drivers/regulator/pfuze.c +++ b/drivers/regulator/pfuze.c @@ -31,8 +31,6 @@ #define DRIVERNAME "pfuze" -#define MC13XXX_NUMREGS 0x3f - #define PFUZE100_SW1ABMODE 0x23 #define PFUZE100_SW1CMODE 0x31 #define PFUZE100_SW2MODE 0x38 -- 2.25.0 _______________________________________________ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox ^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH 2/4] regulator: pfuze: add support to other architectures 2020-01-27 15:50 [PATCH 1/4] regulator: pfuze: remove unsued define Michael Grzeschik @ 2020-01-27 15:50 ` Michael Grzeschik 2020-01-28 8:45 ` Sascha Hauer 2020-01-27 15:50 ` [PATCH 3/4] regulator: pfuze: add include regmap.h so struct regmap is known Michael Grzeschik 2020-01-27 15:50 ` [PATCH 4/4] ARM: phyCORE-i.MX8M SOM: add pmic initialisation for power good Michael Grzeschik 2 siblings, 1 reply; 8+ messages in thread From: Michael Grzeschik @ 2020-01-27 15:50 UTC (permalink / raw) To: barebox Currently the pfuze driver is build dependent to ARCH_IMX6. To make it possible to work with ARCH_IMX8 we move the imx6_poweroff call to an own poweroff handler. Signed-off-by: Michael Grzeschik <m.grzeschik@pengutronix.de> --- arch/arm/mach-imx/imx6.c | 8 ++++++++ drivers/regulator/Kconfig | 2 +- drivers/regulator/pfuze.c | 2 -- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/arch/arm/mach-imx/imx6.c b/arch/arm/mach-imx/imx6.c index 41e0066add..8f1638c1ea 100644 --- a/arch/arm/mach-imx/imx6.c +++ b/arch/arm/mach-imx/imx6.c @@ -401,3 +401,11 @@ void __noreturn imx6_pm_stby_poweroff(void) while(1); } + +static int imx6_init(void) +{ + poweroff_handler_register_fn(imx6_pm_stby_poweroff); + + return 0; +} +coredevice_initcall(imx6_init); diff --git a/drivers/regulator/Kconfig b/drivers/regulator/Kconfig index 28bd69a2a5..f47a115da2 100644 --- a/drivers/regulator/Kconfig +++ b/drivers/regulator/Kconfig @@ -19,7 +19,7 @@ config REGULATOR_BCM283X config REGULATOR_PFUZE bool "Freescale PFUZE100/200/3000 regulator driver" depends on I2C - depends on ARCH_IMX6 + depends on ARCH_IMX6 || ARCH_IMX8MQ config REGULATOR_STPMIC1 tristate "STMicroelectronics STPMIC1 PMIC Regulators" diff --git a/drivers/regulator/pfuze.c b/drivers/regulator/pfuze.c index 55f7eb5d4c..91aaec0e7e 100644 --- a/drivers/regulator/pfuze.c +++ b/drivers/regulator/pfuze.c @@ -142,8 +142,6 @@ static void pfuze_power_off_prepare(struct poweroff_handler *handler) regmap_write_bits(pfuze_dev->map, PFUZE100_VGEN6VOL, PFUZE100_VGENxLPWR | PFUZE100_VGENxSTBY, PFUZE100_VGENxSTBY); - - imx6_pm_stby_poweroff(); } static struct regmap_bus regmap_pfuze_i2c_bus = { -- 2.25.0 _______________________________________________ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 2/4] regulator: pfuze: add support to other architectures 2020-01-27 15:50 ` [PATCH 2/4] regulator: pfuze: add support to other architectures Michael Grzeschik @ 2020-01-28 8:45 ` Sascha Hauer 2020-01-29 22:19 ` Michael Grzeschik 0 siblings, 1 reply; 8+ messages in thread From: Sascha Hauer @ 2020-01-28 8:45 UTC (permalink / raw) To: Michael Grzeschik; +Cc: barebox Hi Michael, On Mon, Jan 27, 2020 at 04:50:11PM +0100, Michael Grzeschik wrote: > Currently the pfuze driver is build dependent to ARCH_IMX6. To make it > possible to work with ARCH_IMX8 we move the imx6_poweroff call to an own > poweroff handler. > > Signed-off-by: Michael Grzeschik <m.grzeschik@pengutronix.de> > --- > arch/arm/mach-imx/imx6.c | 8 ++++++++ > drivers/regulator/Kconfig | 2 +- > drivers/regulator/pfuze.c | 2 -- > 3 files changed, 9 insertions(+), 3 deletions(-) > > diff --git a/arch/arm/mach-imx/imx6.c b/arch/arm/mach-imx/imx6.c > index 41e0066add..8f1638c1ea 100644 > --- a/arch/arm/mach-imx/imx6.c > +++ b/arch/arm/mach-imx/imx6.c > @@ -401,3 +401,11 @@ void __noreturn imx6_pm_stby_poweroff(void) > > while(1); > } > + > +static int imx6_init(void) > +{ > + poweroff_handler_register_fn(imx6_pm_stby_poweroff); > + > + return 0; > +} imx6_pm_stby_poweroff() only works when a pfuze is present and is configured correctly. Calling this on every i.MX board is not nice. What you can do is to call pfuze_register_init_callback() from here. You'll have to add a static inline wrapper for this in case pfuze support is not compiled in. I wonder how this compiles as my version of this file already has a function named imx6_init(). Using this is preferred btw as it's already made sure that it will run only on i.MX6. > +coredevice_initcall(imx6_init); Note that this doesn't necessarily means that we are running an i.MX6. It could be whatever else is compiled in. Sascha -- Pengutronix e.K. | | Steuerwalder Str. 21 | http://www.pengutronix.de/ | 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 | _______________________________________________ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 2/4] regulator: pfuze: add support to other architectures 2020-01-28 8:45 ` Sascha Hauer @ 2020-01-29 22:19 ` Michael Grzeschik 2020-01-30 7:57 ` Sascha Hauer 0 siblings, 1 reply; 8+ messages in thread From: Michael Grzeschik @ 2020-01-29 22:19 UTC (permalink / raw) To: Sascha Hauer; +Cc: barebox [-- Attachment #1.1: Type: text/plain, Size: 2497 bytes --] Hi Sascha, On Tue, Jan 28, 2020 at 09:45:50AM +0100, Sascha Hauer wrote: > Hi Michael, > > On Mon, Jan 27, 2020 at 04:50:11PM +0100, Michael Grzeschik wrote: > > Currently the pfuze driver is build dependent to ARCH_IMX6. To make it > > possible to work with ARCH_IMX8 we move the imx6_poweroff call to an own > > poweroff handler. > > > > Signed-off-by: Michael Grzeschik <m.grzeschik@pengutronix.de> > > --- > > arch/arm/mach-imx/imx6.c | 8 ++++++++ > > drivers/regulator/Kconfig | 2 +- > > drivers/regulator/pfuze.c | 2 -- > > 3 files changed, 9 insertions(+), 3 deletions(-) > > > > diff --git a/arch/arm/mach-imx/imx6.c b/arch/arm/mach-imx/imx6.c > > index 41e0066add..8f1638c1ea 100644 > > --- a/arch/arm/mach-imx/imx6.c > > +++ b/arch/arm/mach-imx/imx6.c > > @@ -401,3 +401,11 @@ void __noreturn imx6_pm_stby_poweroff(void) > > > > while(1); > > } > > + > > +static int imx6_init(void) > > +{ > > + poweroff_handler_register_fn(imx6_pm_stby_poweroff); > > + > > + return 0; > > +} > > imx6_pm_stby_poweroff() only works when a pfuze is present and is > configured correctly. Calling this on every i.MX board is not nice. Right > What you can do is to call pfuze_register_init_callback() from here. > You'll have to add a static inline wrapper for this in case pfuze > support is not compiled in. So you mean, call pfuze_register_init_callback to register a callback function which then itself registers the poweroff_handler as above? I think that could work, but then the init_callback is already used for every imx6. The callback would also be overwritten by users in board code trying to preconfigure the pfuze into a sane state, right? > I wonder how this compiles as my version of this file already has a > function named imx6_init(). Using this is preferred btw as it's already > made sure that it will run only on i.MX6. Duh, it wont. I tried it with imx6 disabled. > > +coredevice_initcall(imx6_init); > > Note that this doesn't necessarily means that we are running an i.MX6. > It could be whatever else is compiled in. Yes, therefor the callback approach is to be prefered. Michael -- Pengutronix e.K. | | Steuerwalder Str. 21 | http://www.pengutronix.de/ | 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 | [-- Attachment #1.2: signature.asc --] [-- Type: application/pgp-signature, Size: 833 bytes --] [-- Attachment #2: Type: text/plain, Size: 149 bytes --] _______________________________________________ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 2/4] regulator: pfuze: add support to other architectures 2020-01-29 22:19 ` Michael Grzeschik @ 2020-01-30 7:57 ` Sascha Hauer 0 siblings, 0 replies; 8+ messages in thread From: Sascha Hauer @ 2020-01-30 7:57 UTC (permalink / raw) To: Michael Grzeschik; +Cc: barebox On Wed, Jan 29, 2020 at 11:19:20PM +0100, Michael Grzeschik wrote: > Hi Sascha, > > On Tue, Jan 28, 2020 at 09:45:50AM +0100, Sascha Hauer wrote: > > Hi Michael, > > > > On Mon, Jan 27, 2020 at 04:50:11PM +0100, Michael Grzeschik wrote: > > > Currently the pfuze driver is build dependent to ARCH_IMX6. To make it > > > possible to work with ARCH_IMX8 we move the imx6_poweroff call to an own > > > poweroff handler. > > > > > > Signed-off-by: Michael Grzeschik <m.grzeschik@pengutronix.de> > > > --- > > > arch/arm/mach-imx/imx6.c | 8 ++++++++ > > > drivers/regulator/Kconfig | 2 +- > > > drivers/regulator/pfuze.c | 2 -- > > > 3 files changed, 9 insertions(+), 3 deletions(-) > > > > > > diff --git a/arch/arm/mach-imx/imx6.c b/arch/arm/mach-imx/imx6.c > > > index 41e0066add..8f1638c1ea 100644 > > > --- a/arch/arm/mach-imx/imx6.c > > > +++ b/arch/arm/mach-imx/imx6.c > > > @@ -401,3 +401,11 @@ void __noreturn imx6_pm_stby_poweroff(void) > > > > > > while(1); > > > } > > > + > > > +static int imx6_init(void) > > > +{ > > > + poweroff_handler_register_fn(imx6_pm_stby_poweroff); > > > + > > > + return 0; > > > +} > > > > imx6_pm_stby_poweroff() only works when a pfuze is present and is > > configured correctly. Calling this on every i.MX board is not nice. > > Right > > > What you can do is to call pfuze_register_init_callback() from here. > > You'll have to add a static inline wrapper for this in case pfuze > > support is not compiled in. > > So you mean, call pfuze_register_init_callback to register a callback > function which then itself registers the poweroff_handler as above? > > I think that could work, but then the init_callback is already used for > every imx6. The callback would also be overwritten by users in board > code trying to preconfigure the pfuze into a sane state, right? Yes. Board code would then have to call imx6_pm_stby_poweroff() additionally to its own fixups. Sascha -- Pengutronix e.K. | | Steuerwalder Str. 21 | http://www.pengutronix.de/ | 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 | _______________________________________________ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox ^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH 3/4] regulator: pfuze: add include regmap.h so struct regmap is known 2020-01-27 15:50 [PATCH 1/4] regulator: pfuze: remove unsued define Michael Grzeschik 2020-01-27 15:50 ` [PATCH 2/4] regulator: pfuze: add support to other architectures Michael Grzeschik @ 2020-01-27 15:50 ` Michael Grzeschik 2020-01-27 15:50 ` [PATCH 4/4] ARM: phyCORE-i.MX8M SOM: add pmic initialisation for power good Michael Grzeschik 2 siblings, 0 replies; 8+ messages in thread From: Michael Grzeschik @ 2020-01-27 15:50 UTC (permalink / raw) To: barebox Without this the user of the function will get a compile warning about the undeclared struct regmap. Signed-off-by: Michael Grzeschik <m.grzeschik@pengutronix.de> --- include/mfd/pfuze.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/include/mfd/pfuze.h b/include/mfd/pfuze.h index 6045ceec0a..5427b21005 100644 --- a/include/mfd/pfuze.h +++ b/include/mfd/pfuze.h @@ -1,6 +1,8 @@ #ifndef __INCLUDE_PFUZE_H #define __INCLUDE_PFUZE_H +#include <regmap.h> + int pfuze_register_init_callback(void(*callback)(struct regmap *map)); #endif /* __INCLUDE_PFUZE_H */ -- 2.25.0 _______________________________________________ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox ^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH 4/4] ARM: phyCORE-i.MX8M SOM: add pmic initialisation for power good 2020-01-27 15:50 [PATCH 1/4] regulator: pfuze: remove unsued define Michael Grzeschik 2020-01-27 15:50 ` [PATCH 2/4] regulator: pfuze: add support to other architectures Michael Grzeschik 2020-01-27 15:50 ` [PATCH 3/4] regulator: pfuze: add include regmap.h so struct regmap is known Michael Grzeschik @ 2020-01-27 15:50 ` Michael Grzeschik 2020-01-28 8:48 ` Sascha Hauer 2 siblings, 1 reply; 8+ messages in thread From: Michael Grzeschik @ 2020-01-27 15:50 UTC (permalink / raw) To: barebox This patch is adding the same PMIC handling as the u-boot spl does for this Board. It ensures sane defaults. Signed-off-by: Michael Grzeschik <m.grzeschik@pengutronix.de> --- arch/arm/boards/phytec-som-imx8mq/board.c | 38 +++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/arch/arm/boards/phytec-som-imx8mq/board.c b/arch/arm/boards/phytec-som-imx8mq/board.c index 4fd098c5f6..7df53a7cfb 100644 --- a/arch/arm/boards/phytec-som-imx8mq/board.c +++ b/arch/arm/boards/phytec-som-imx8mq/board.c @@ -10,9 +10,45 @@ #include <init.h> #include <linux/sizes.h> #include <mach/bbu.h> +#include <mfd/pfuze.h> #include <envfs.h> +#define PFUZE100_DEVICEID 0x0 +#define PFUZE100_REVID 0x3 + +#define PFUZE100_SW1ABMODE 0x23 +#define PFUZE100_SW2MODE 0x38 +#define PFUZE100_SW1CMODE 0x31 +#define PFUZE100_SW3AVOL 0x3c + +#define APS_PFM 0xc + +static void imx8mq_setup_pmic_voltages(struct regmap *map) +{ + int offset = PFUZE100_SW1CMODE; + int switch_num = 6; + int val, i; + + regmap_read(map, PFUZE100_SW3AVOL, &val); + + /* ensure the correct VDD_DRAM_0V9 output voltage */ + regmap_write_bits(map, PFUZE100_SW3AVOL, 0x3f, 0x18); + + /* pfuze200 */ + regmap_read(map, PFUZE100_DEVICEID, &val); + if (val & 0xf) { + offset = PFUZE100_SW2MODE; + switch_num = 4; + } + + /* set all switches APS in normal and PFM mode in standby */ + regmap_write(map, PFUZE100_SW1ABMODE, APS_PFM); + + for (i = 0; i < switch_num - 1; i++) + regmap_write(map, offset + i * 7, APS_PFM); +} + static int physom_imx8mq_devices_init(void) { int flag_emmc = 0; @@ -23,6 +59,8 @@ static int physom_imx8mq_devices_init(void) barebox_set_hostname("phycore-imx8mq"); + pfuze_register_init_callback(imx8mq_setup_pmic_voltages); + switch (bootsource_get_instance()) { case 0: flag_emmc = BBU_HANDLER_FLAG_DEFAULT; -- 2.25.0 _______________________________________________ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox ^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 4/4] ARM: phyCORE-i.MX8M SOM: add pmic initialisation for power good 2020-01-27 15:50 ` [PATCH 4/4] ARM: phyCORE-i.MX8M SOM: add pmic initialisation for power good Michael Grzeschik @ 2020-01-28 8:48 ` Sascha Hauer 0 siblings, 0 replies; 8+ messages in thread From: Sascha Hauer @ 2020-01-28 8:48 UTC (permalink / raw) To: Michael Grzeschik; +Cc: barebox On Mon, Jan 27, 2020 at 04:50:13PM +0100, Michael Grzeschik wrote: > This patch is adding the same PMIC handling as the u-boot spl does for > this Board. It ensures sane defaults. > > Signed-off-by: Michael Grzeschik <m.grzeschik@pengutronix.de> > --- > arch/arm/boards/phytec-som-imx8mq/board.c | 38 +++++++++++++++++++++++ > 1 file changed, 38 insertions(+) > > diff --git a/arch/arm/boards/phytec-som-imx8mq/board.c b/arch/arm/boards/phytec-som-imx8mq/board.c > index 4fd098c5f6..7df53a7cfb 100644 > --- a/arch/arm/boards/phytec-som-imx8mq/board.c > +++ b/arch/arm/boards/phytec-som-imx8mq/board.c > @@ -10,9 +10,45 @@ > #include <init.h> > #include <linux/sizes.h> > #include <mach/bbu.h> > +#include <mfd/pfuze.h> > > #include <envfs.h> > > +#define PFUZE100_DEVICEID 0x0 > +#define PFUZE100_REVID 0x3 > + > +#define PFUZE100_SW1ABMODE 0x23 > +#define PFUZE100_SW2MODE 0x38 > +#define PFUZE100_SW1CMODE 0x31 > +#define PFUZE100_SW3AVOL 0x3c > + > +#define APS_PFM 0xc > + > +static void imx8mq_setup_pmic_voltages(struct regmap *map) > +{ > + int offset = PFUZE100_SW1CMODE; > + int switch_num = 6; > + int val, i; > + > + regmap_read(map, PFUZE100_SW3AVOL, &val); > + > + /* ensure the correct VDD_DRAM_0V9 output voltage */ > + regmap_write_bits(map, PFUZE100_SW3AVOL, 0x3f, 0x18); > + > + /* pfuze200 */ > + regmap_read(map, PFUZE100_DEVICEID, &val); > + if (val & 0xf) { > + offset = PFUZE100_SW2MODE; > + switch_num = 4; > + } > + > + /* set all switches APS in normal and PFM mode in standby */ > + regmap_write(map, PFUZE100_SW1ABMODE, APS_PFM); > + > + for (i = 0; i < switch_num - 1; i++) > + regmap_write(map, offset + i * 7, APS_PFM); > +} > + > static int physom_imx8mq_devices_init(void) > { > int flag_emmc = 0; > @@ -23,6 +59,8 @@ static int physom_imx8mq_devices_init(void) > > barebox_set_hostname("phycore-imx8mq"); > > + pfuze_register_init_callback(imx8mq_setup_pmic_voltages); Yes, providing a static inline wrapper function for this is a good idea. Sascha -- Pengutronix e.K. | | Steuerwalder Str. 21 | http://www.pengutronix.de/ | 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 | _______________________________________________ barebox mailing list barebox@lists.infradead.org http://lists.infradead.org/mailman/listinfo/barebox ^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2020-01-30 7:57 UTC | newest] Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2020-01-27 15:50 [PATCH 1/4] regulator: pfuze: remove unsued define Michael Grzeschik 2020-01-27 15:50 ` [PATCH 2/4] regulator: pfuze: add support to other architectures Michael Grzeschik 2020-01-28 8:45 ` Sascha Hauer 2020-01-29 22:19 ` Michael Grzeschik 2020-01-30 7:57 ` Sascha Hauer 2020-01-27 15:50 ` [PATCH 3/4] regulator: pfuze: add include regmap.h so struct regmap is known Michael Grzeschik 2020-01-27 15:50 ` [PATCH 4/4] ARM: phyCORE-i.MX8M SOM: add pmic initialisation for power good Michael Grzeschik 2020-01-28 8:48 ` Sascha Hauer
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox