From: Roland Hieber <r.hieber@pengutronix.de>
To: barebox@lists.infradead.org
Cc: Roland Hieber <r.hieber@pengutronix.de>
Subject: [PATCH v2 09/14] ARM: MXS: make power levels configurable in mx2*_power_init
Date: Fri, 10 Aug 2018 18:34:55 +0200 [thread overview]
Message-ID: <20180810163500.12042-10-r.hieber@pengutronix.de> (raw)
In-Reply-To: <20180810163500.12042-1-r.hieber@pengutronix.de>
Depending on the application, board code might want to configure
different power levels and brownout thresholds. They can do so now with
an additional struct mxs_power_ctrls* parameter to mx2*_power_init.
Note that VDDMEM was not set up explicitely in mx28_power_init, but can
now be configured. However, mx28_power_default->vddmem is NULL, so the
old behaviour is still the case when using those default values.
Signed-off-by: Roland Hieber <r.hieber@pengutronix.de>
---
arch/arm/boards/duckbill/lowlevel.c | 2 +-
arch/arm/boards/freescale-mx28-evk/lowlevel.c | 3 +-
arch/arm/boards/imx233-olinuxino/lowlevel.c | 2 +-
arch/arm/boards/karo-tx28/lowlevel.c | 3 +-
arch/arm/mach-mxs/include/mach/init.h | 22 +++++++-
arch/arm/mach-mxs/power-init.c | 55 ++++++++++++++++---
6 files changed, 72 insertions(+), 15 deletions(-)
diff --git a/arch/arm/boards/duckbill/lowlevel.c b/arch/arm/boards/duckbill/lowlevel.c
index 3f8e4ad271..22987a6cdb 100644
--- a/arch/arm/boards/duckbill/lowlevel.c
+++ b/arch/arm/boards/duckbill/lowlevel.c
@@ -51,7 +51,7 @@ static noinline void duckbill_init(void)
pr_debug("initializing power...\n");
- mx28_power_init(POWER_USE_5V);
+ mx28_power_init(POWER_USE_5V, &mx28_power_default);
pr_debug("initializing SDRAM...\n");
diff --git a/arch/arm/boards/freescale-mx28-evk/lowlevel.c b/arch/arm/boards/freescale-mx28-evk/lowlevel.c
index fdaef959a3..22cae1374c 100644
--- a/arch/arm/boards/freescale-mx28-evk/lowlevel.c
+++ b/arch/arm/boards/freescale-mx28-evk/lowlevel.c
@@ -43,7 +43,8 @@ static noinline void freescale_mx28evk_init(void)
pr_debug("initializing power...\n");
- mx28_power_init(POWER_USE_BATTERY_INPUT | POWER_ENABLE_4P2);
+ mx28_power_init(POWER_USE_BATTERY_INPUT | POWER_ENABLE_4P2,
+ &mx28_power_default);
pr_debug("initializing SDRAM...\n");
diff --git a/arch/arm/boards/imx233-olinuxino/lowlevel.c b/arch/arm/boards/imx233-olinuxino/lowlevel.c
index c6cf26b61d..5f36c17e52 100644
--- a/arch/arm/boards/imx233-olinuxino/lowlevel.c
+++ b/arch/arm/boards/imx233-olinuxino/lowlevel.c
@@ -154,7 +154,7 @@ static noinline void imx23_olinuxino_init(void)
pr_debug("initializing power...\n");
- mx23_power_init(POWER_USE_5V);
+ mx23_power_init(POWER_USE_5V, &mx23_power_default);
pr_debug("initializing SDRAM...\n");
diff --git a/arch/arm/boards/karo-tx28/lowlevel.c b/arch/arm/boards/karo-tx28/lowlevel.c
index a9b65167cd..1a93be747d 100644
--- a/arch/arm/boards/karo-tx28/lowlevel.c
+++ b/arch/arm/boards/karo-tx28/lowlevel.c
@@ -43,7 +43,8 @@ static noinline void karo_tx28_init(void)
pr_debug("initializing power...\n");
- mx28_power_init(POWER_USE_BATTERY_INPUT | POWER_ENABLE_4P2);
+ mx28_power_init(POWER_USE_BATTERY_INPUT | POWER_ENABLE_4P2,
+ &mx28_power_default);
pr_debug("initializing SDRAM...\n");
diff --git a/arch/arm/mach-mxs/include/mach/init.h b/arch/arm/mach-mxs/include/mach/init.h
index b62fea9657..281e458d97 100644
--- a/arch/arm/mach-mxs/include/mach/init.h
+++ b/arch/arm/mach-mxs/include/mach/init.h
@@ -28,8 +28,26 @@ enum mxs_power_config {
POWER_ENABLE_4P2 = 0b00000100,
};
-void mx23_power_init(const int config);
-void mx28_power_init(const int config);
+struct mxs_power_ctrl {
+ uint32_t target; /*< target voltage */
+ uint32_t brownout; /*< brownout threshhold */
+};
+struct mxs_power_ctrls {
+ struct mxs_power_ctrl * vdda; /*< if non-null, set values for VDDA */
+ struct mxs_power_ctrl * vddd; /*< if non-null, set values for VDDD */
+ struct mxs_power_ctrl * vddio; /*< if non-null, set values for VDDIO */
+ struct mxs_power_ctrl * vddmem; /*< if non-null, set values for VDDMEM */
+};
+
+extern struct mxs_power_ctrl mxs_vddio_default;
+extern struct mxs_power_ctrl mxs_vddd_default;
+extern struct mxs_power_ctrl mxs_vdda_default;
+extern struct mxs_power_ctrl mx23_vddmem_default;
+extern struct mxs_power_ctrls mx23_power_default;
+extern struct mxs_power_ctrls mx28_power_default;
+
+void mx23_power_init(const int config, struct mxs_power_ctrls *ctrls);
+void mx28_power_init(const int config, struct mxs_power_ctrls *ctrls);
void mxs_power_wait_pswitch(void);
extern const uint32_t mx28_dram_vals_default[190];
diff --git a/arch/arm/mach-mxs/power-init.c b/arch/arm/mach-mxs/power-init.c
index 2984c0c5ff..d4b88a4b2c 100644
--- a/arch/arm/mach-mxs/power-init.c
+++ b/arch/arm/mach-mxs/power-init.c
@@ -1165,6 +1165,17 @@ static void mx23_ungate_power(void)
writel(MX23_POWER_CTRL_CLKGATE, &power_regs->hw_power_ctrl_clr);
}
+struct mxs_power_ctrl mxs_vddd_default = { .target = 1500, .brownout = 1325 };
+struct mxs_power_ctrl mxs_vdda_default = { .target = 1800, .brownout = 1650 };
+struct mxs_power_ctrl mxs_vddio_default = { .target = 3300, .brownout = 3150 };
+struct mxs_power_ctrl mx23_vddmem_default = { .target = 2500, .brownout = 1700 };
+struct mxs_power_ctrls mx23_power_default = {
+ .vdda = &mxs_vdda_default,
+ .vddd = &mxs_vddd_default,
+ .vddio = &mxs_vddio_default,
+ .vddmem = &mx23_vddmem_default,
+};
+
/**
* mx23_power_init() - The power block init main function
*
@@ -1172,8 +1183,9 @@ static void mx23_ungate_power(void)
* proper sequence to start the power block.
*
* @config: see enum mxs_power_config for possible options
+ * @ctrls: a mxs_power_ctrls struct, or use &mx23_power_default for default values
*/
-void mx23_power_init(const int config)
+void mx23_power_init(const int config, struct mxs_power_ctrls *ctrls)
{
struct mxs_power_regs *power_regs =
(struct mxs_power_regs *)IMX_POWER_BASE;
@@ -1210,10 +1222,18 @@ void mx23_power_init(const int config)
mxs_enable_output_rail_protection();
- mxs_power_set_vddx(&mx23_vddio_cfg, 3300, 3150);
- mxs_power_set_vddx(&mxs_vddd_cfg, 1500, 1325);
- mxs_power_set_vddx(&mxs_vddmem_cfg, 2500, 1700);
- mxs_power_set_vddx(&mxs_vdda_cfg, 1800, 1650);
+ if (ctrls->vddio)
+ mxs_power_set_vddx(&mx23_vddio_cfg, ctrls->vddio->target,
+ ctrls->vddio->brownout);
+ if (ctrls->vddd)
+ mxs_power_set_vddx(&mxs_vddd_cfg, ctrls->vddd->target,
+ ctrls->vddd->brownout);
+ if (ctrls->vddmem)
+ mxs_power_set_vddx(&mxs_vddmem_cfg, ctrls->vddmem->target,
+ ctrls->vddmem->brownout);
+ if (ctrls->vdda)
+ mxs_power_set_vddx(&mxs_vdda_cfg, ctrls->vdda->target,
+ ctrls->vdda->brownout);
writel(POWER_CTRL_VDDD_BO_IRQ | POWER_CTRL_VDDA_BO_IRQ |
POWER_CTRL_VDDIO_BO_IRQ | POWER_CTRL_VDD5V_DROOP_IRQ |
@@ -1225,6 +1245,13 @@ void mx23_power_init(const int config)
mxs_early_delay(1000);
}
+struct mxs_power_ctrls mx28_power_default = {
+ .vdda = &mxs_vdda_default,
+ .vddd = &mxs_vddd_default,
+ .vddio = &mxs_vddio_default,
+ .vddmem = NULL,
+};
+
/**
* mx28_power_init() - The power block init main function
*
@@ -1232,8 +1259,9 @@ void mx23_power_init(const int config)
* proper sequence to start the power block.
*
* @config: see enum mxs_power_config for possible options
+ * @ctrls: a mxs_power_ctrls struct, or use &mx28_power_default for default values
*/
-void mx28_power_init(const int config)
+void mx28_power_init(const int config, struct mxs_power_ctrls *ctrls)
{
struct mxs_power_regs *power_regs =
(struct mxs_power_regs *)IMX_POWER_BASE;
@@ -1265,9 +1293,18 @@ void mx28_power_init(const int config)
mxs_enable_output_rail_protection();
- mxs_power_set_vddx(&mx28_vddio_cfg, 3300, 3150);
- mxs_power_set_vddx(&mxs_vddd_cfg, 1500, 1325);
- mxs_power_set_vddx(&mxs_vdda_cfg, 1800, 1650);
+ if (ctrls->vddio)
+ mxs_power_set_vddx(&mx28_vddio_cfg, ctrls->vddio->target,
+ ctrls->vddio->brownout);
+ if (ctrls->vddd)
+ mxs_power_set_vddx(&mxs_vddd_cfg, ctrls->vddd->target,
+ ctrls->vddd->brownout);
+ if (ctrls->vddmem)
+ mxs_power_set_vddx(&mxs_vddmem_cfg, ctrls->vddmem->target,
+ ctrls->vddmem->brownout);
+ if (ctrls->vdda)
+ mxs_power_set_vddx(&mxs_vdda_cfg, ctrls->vdda->target,
+ ctrls->vdda->brownout);
writel(POWER_CTRL_VDDD_BO_IRQ | POWER_CTRL_VDDA_BO_IRQ |
POWER_CTRL_VDDIO_BO_IRQ | POWER_CTRL_VDD5V_DROOP_IRQ |
--
2.18.0
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
next prev parent reply other threads:[~2018-08-10 16:35 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-08-10 16:34 [PATCH v2 00/14] MXS low-level improvements Roland Hieber
2018-08-10 16:34 ` [PATCH v2 01/14] scripts: mxsimage: Allow unencrypted images Roland Hieber
2018-08-10 16:34 ` [PATCH v2 02/14] images: MXS: allow generation of unencrypted bootstreams Roland Hieber
2018-08-10 16:34 ` [PATCH v2 03/14] ARM: MXS: i.MX28: allow setup of low-voltage SDRAM Roland Hieber
2018-08-10 16:34 ` [PATCH v2 04/14] ARM: MXS: allow configuration of EMI clock prescaler Roland Hieber
2018-08-10 16:34 ` [PATCH v2 05/14] ARM: i.MX28: Add memory size detection Roland Hieber
2018-08-10 16:34 ` [PATCH v2 06/14] ARM: i.MX23: " Roland Hieber
2018-08-10 19:14 ` Andrey Smirnov
2018-08-10 16:34 ` [PATCH v2 07/14] ARM: MXS: refactor mx2*_power_init source configuration Roland Hieber
2018-08-10 19:29 ` Andrey Smirnov
2018-08-13 13:04 ` Roland Hieber
2018-08-10 16:34 ` [PATCH v2 08/14] ARM: MXS: allow starting from battery input without 4P2 source enabled Roland Hieber
2018-08-10 16:34 ` Roland Hieber [this message]
2018-08-10 16:34 ` [PATCH v2 10/14] ARM: MXS: fix VDDx brownout setup logic Roland Hieber
2018-08-10 16:34 ` [PATCH v2 11/14] ARM: MXS: make VDDx brownout setup more understandable Roland Hieber
2018-08-10 16:34 ` [PATCH v2 12/14] ARM: MXS: mxs_power_status: use less magic values Roland Hieber
2018-08-10 16:34 ` [PATCH v2 13/14] ARM: MXS: mxs_power_status: align output Roland Hieber
2018-08-10 16:35 ` [PATCH v2 14/14] Documentation: MXS: general update and improvements Roland Hieber
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20180810163500.12042-10-r.hieber@pengutronix.de \
--to=r.hieber@pengutronix.de \
--cc=barebox@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox