* [PATCH 00/13] MXS/MX28 low-level improvements
@ 2018-07-25 13:36 Roland Hieber
2018-07-25 13:36 ` [PATCH 01/13] scripts: mxsimage: Allow unencrypted images Roland Hieber
` (12 more replies)
0 siblings, 13 replies; 18+ messages in thread
From: Roland Hieber @ 2018-07-25 13:36 UTC (permalink / raw)
To: barebox; +Cc: Roland Hieber
While porting barebox onto a new old MX28 board, I had to extend the
low-level code to set up SDRAM and PMIC. Most of those changes are
probably also applicable to MX23 boards since the code paths are the
same, and are only wrapped in mx28_*/mx23_*-specific wrapper functions.
(Also, if anyone wants to port these changes back to U-Boot, feel free
to do so, it's the same code ☺)
Roland Hieber (12):
images: MXS: allow generation of unencrypted bootstreams
ARM: MXS: i.MX28: allow setup of low-voltage SDRAM
ARM: MXS: allow configuration of EMI clock dividers
ARM: MXS: i.MX28: add autodetection of memory banks
ARM: MXS: refactor mx2*_power_init source configuration
ARM: MXS: allow starting from battery input without 4P2 source enabled
ARM: MXS: make power levels configurable in mx2*_power_init
ARM: MXS: fix VDDx brownout setup logic
ARM: MXS: make VDDx brownout setup more understandable
ARM: MXS: mxs_power_status: use less magic values
ARM: MXS: mxs_power_status: align output
Documentation: MXS: general update and improvements
Sascha Hauer (1):
scripts: mxsimage: Allow unencrypted images
Documentation/boards/mxs.rst | 97 ++++++-----
arch/arm/boards/duckbill/lowlevel.c | 7 +-
arch/arm/boards/freescale-mx28-evk/lowlevel.c | 8 +-
arch/arm/boards/imx233-olinuxino/lowlevel.c | 2 +-
arch/arm/boards/karo-tx28/lowlevel.c | 8 +-
arch/arm/mach-mxs/Makefile | 2 +-
arch/arm/mach-mxs/include/mach/init.h | 49 +++++-
arch/arm/mach-mxs/mem-imx28.c | 39 +++++
arch/arm/mach-mxs/mem-init.c | 23 ++-
arch/arm/mach-mxs/power-init.c | 162 +++++++++++-------
images/Makefile.mxs | 8 +
scripts/mxsimage.c | 53 +++---
12 files changed, 301 insertions(+), 157 deletions(-)
create mode 100644 arch/arm/mach-mxs/mem-imx28.c
--
2.18.0
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 18+ messages in thread
* [PATCH 01/13] scripts: mxsimage: Allow unencrypted images
2018-07-25 13:36 [PATCH 00/13] MXS/MX28 low-level improvements Roland Hieber
@ 2018-07-25 13:36 ` Roland Hieber
2018-07-25 13:36 ` [PATCH 02/13] images: MXS: allow generation of unencrypted bootstreams Roland Hieber
` (11 subsequent siblings)
12 siblings, 0 replies; 18+ messages in thread
From: Roland Hieber @ 2018-07-25 13:36 UTC (permalink / raw)
To: barebox; +Cc: Roland Hieber
From: Sascha Hauer <s.hauer@pengutronix.de>
Normally MXS SoCs only allow to boot images which have been
encrypted with a zero key. If the ENABLE_UNENCTRYPTED_BOOT fuse
is blown then the SoC also allows to boot unencrypted images.
Add an option to the mxsimage tool to generate such images.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Signed-off-by: Roland Hieber <r.hieber@pengutronix.de>
---
Notes:
submitted by Sascha in https://www.mail-archive.com/barebox@lists.infradead.org/msg26936.html,
but not applied yet.
Typo in subject fixed by me.
scripts/mxsimage.c | 53 +++++++++++++++++++++++++++++-----------------
1 file changed, 33 insertions(+), 20 deletions(-)
diff --git a/scripts/mxsimage.c b/scripts/mxsimage.c
index 5c2c3079de..8a63d76939 100644
--- a/scripts/mxsimage.c
+++ b/scripts/mxsimage.c
@@ -337,6 +337,7 @@ struct sb_image_ctx {
/* Image configuration */
unsigned int verbose_boot:1;
unsigned int silent_dump:1;
+ unsigned int encrypted:1;
const char *input_filename;
const char *output_filename;
const char *cfg_filename;
@@ -484,6 +485,12 @@ static int sb_aes_crypt(struct sb_image_ctx *ictx, uint8_t *in_data,
int ret, outlen;
uint8_t *outbuf;
+ if (!ictx->encrypted) {
+ if (out_data && in_data != out_data)
+ memcpy(out_data, in_data, in_len);
+ return 0;
+ }
+
outbuf = malloc(in_len);
if (!outbuf)
return -ENOMEM;
@@ -645,7 +652,8 @@ static int sb_encrypt_image(struct sb_image_ctx *ictx)
* Key dictionary.
*/
sb_aes_reinit(ictx, 1);
- sb_encrypt_key_dictionary_key(ictx);
+ if (ictx->encrypted)
+ sb_encrypt_key_dictionary_key(ictx);
/*
* Section tags.
@@ -1609,10 +1617,10 @@ static int sb_prefill_image_header(struct sb_image_ctx *ictx)
hdr->timestamp_us = sb_get_timestamp() * 1000000;
/* FIXME -- add proper config option */
- hdr->flags = ictx->verbose_boot ? SB_IMAGE_FLAG_VERBOSE : 0,
+ hdr->flags = ictx->verbose_boot ? SB_IMAGE_FLAG_VERBOSE : 0;
/* FIXME -- We support only default key */
- hdr->key_count = 1;
+ hdr->key_count = ictx->encrypted ? 1 : 0;
return 0;
}
@@ -2450,7 +2458,7 @@ static int sb_build_image(struct sb_image_ctx *ictx)
/* Calculate image size. */
uint32_t size = sizeof(*sb_header) +
ictx->sect_count * sizeof(struct sb_sections_header) +
- sizeof(*sb_dict_key) + sizeof(ictx->digest);
+ sizeof(*sb_dict_key) * sb_header->key_count + sizeof(ictx->digest);
sctx = ictx->sect_head;
while (sctx) {
@@ -2473,8 +2481,10 @@ static int sb_build_image(struct sb_image_ctx *ictx)
sctx = sctx->sect;
};
- memcpy(iptr, sb_dict_key, sizeof(*sb_dict_key));
- iptr += sizeof(*sb_dict_key);
+ if (ictx->encrypted) {
+ memcpy(iptr, sb_dict_key, sizeof(*sb_dict_key));
+ iptr += sizeof(*sb_dict_key);
+ }
sctx = ictx->sect_head;
while (sctx) {
@@ -2516,27 +2526,20 @@ static int sb_build_image(struct sb_image_ctx *ictx)
return 0;
}
-static int mxsimage_generate(const char *configfile, const char *imagefile)
+static int mxsimage_generate(struct sb_image_ctx *ctx)
{
int ret;
- struct sb_image_ctx ctx;
-
- memset(&ctx, 0, sizeof(ctx));
- ctx.cfg_filename = configfile;
- ctx.output_filename = imagefile;
- ctx.verbose_boot = 1;
-
- ret = sb_build_tree_from_cfg(&ctx);
+ ret = sb_build_tree_from_cfg(ctx);
if (ret)
goto fail;
- ret = sb_encrypt_image(&ctx);
+ ret = sb_encrypt_image(ctx);
if (!ret)
- ret = sb_build_image(&ctx);
+ ret = sb_build_image(ctx);
fail:
- sb_free_image(&ctx);
+ sb_free_image(ctx);
return ret;
}
@@ -2546,8 +2549,12 @@ int main(int argc, char *argv[])
int ret;
int opt;
char *configfile = NULL, *outfile = NULL, *verify = NULL;
+ struct sb_image_ctx ctx = {
+ .encrypted = 1,
+ .verbose_boot = 1,
+ };
- while ((opt = getopt(argc, argv, "p:b:c:o:v:")) != -1) {
+ while ((opt = getopt(argc, argv, "p:b:c:o:v:u")) != -1) {
switch (opt) {
case 'p':
prepfile = optarg;
@@ -2564,6 +2571,9 @@ int main(int argc, char *argv[])
case 'v':
verify = optarg;
break;
+ case 'u':
+ ctx.encrypted = 0;
+ break;
default:
exit(1);
}
@@ -2587,7 +2597,10 @@ int main(int argc, char *argv[])
exit(1);
}
- ret = mxsimage_generate(configfile, outfile);
+ ctx.cfg_filename = configfile;
+ ctx.output_filename = outfile;
+
+ ret = mxsimage_generate(&ctx);
if (ret)
exit(1);
--
2.18.0
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 18+ messages in thread
* [PATCH 02/13] images: MXS: allow generation of unencrypted bootstreams
2018-07-25 13:36 [PATCH 00/13] MXS/MX28 low-level improvements Roland Hieber
2018-07-25 13:36 ` [PATCH 01/13] scripts: mxsimage: Allow unencrypted images Roland Hieber
@ 2018-07-25 13:36 ` Roland Hieber
2018-07-25 13:36 ` [PATCH 03/13] ARM: MXS: i.MX28: allow setup of low-voltage SDRAM Roland Hieber
` (10 subsequent siblings)
12 siblings, 0 replies; 18+ messages in thread
From: Roland Hieber @ 2018-07-25 13:36 UTC (permalink / raw)
To: barebox; +Cc: Roland Hieber
mxsimage can now build unencrypted images with -u, so make use of it in
the Makefile. To keep the existing rules simple, name the generated
images *.mxsbsu instead of *.mxsbs.
Signed-off-by: Roland Hieber <r.hieber@pengutronix.de>
---
images/Makefile.mxs | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/images/Makefile.mxs b/images/Makefile.mxs
index 93d43b3529..aab883202a 100644
--- a/images/Makefile.mxs
+++ b/images/Makefile.mxs
@@ -10,6 +10,14 @@ quiet_cmd_mxs_bootstream = MXS-BOOTSTREAM $@
$(obj)/%.mxsbs: $(obj)/%.pblx $(obj)/prep_%.pblb FORCE
$(call if_changed,mxs_bootstream)
+# %.mxsbsu - convert into unencrypted MXS BootStream image
+# ----------------------------------------------------------------
+quiet_cmd_mxs_bootstream_u = MXS-BOOTSTREAM-U $@
+ cmd_mxs_bootstream_u = $(objtree)/scripts/mxsimage -u -c $(CFG_$(@F)) -b $< -o $@ -p $(word 2,$^)
+
+$(obj)/%.mxsbsu: $(obj)/%.pblx $(obj)/prep_%.pblb FORCE
+ $(call if_changed,mxs_bootstream_u)
+
# %.mxssd - convert into MXS SD card image
# ----------------------------------------------------------------
quiet_cmd_mxs_sd = MXS-SD $@
--
2.18.0
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 18+ messages in thread
* [PATCH 03/13] ARM: MXS: i.MX28: allow setup of low-voltage SDRAM
2018-07-25 13:36 [PATCH 00/13] MXS/MX28 low-level improvements Roland Hieber
2018-07-25 13:36 ` [PATCH 01/13] scripts: mxsimage: Allow unencrypted images Roland Hieber
2018-07-25 13:36 ` [PATCH 02/13] images: MXS: allow generation of unencrypted bootstreams Roland Hieber
@ 2018-07-25 13:36 ` Roland Hieber
2018-07-25 13:36 ` [PATCH 04/13] ARM: MXS: allow configuration of EMI clock dividers Roland Hieber
` (9 subsequent siblings)
12 siblings, 0 replies; 18+ messages in thread
From: Roland Hieber @ 2018-07-25 13:36 UTC (permalink / raw)
To: barebox; +Cc: Roland Hieber
The PINCTRL_*_DDR_MODE_* defines are now needed in global scope, so move
them to the respective include header.
Signed-off-by: Roland Hieber <r.hieber@pengutronix.de>
---
arch/arm/boards/duckbill/lowlevel.c | 3 ++-
arch/arm/boards/freescale-mx28-evk/lowlevel.c | 3 ++-
arch/arm/boards/karo-tx28/lowlevel.c | 3 ++-
arch/arm/mach-mxs/include/mach/init.h | 7 ++++++-
arch/arm/mach-mxs/mem-init.c | 9 +++------
5 files changed, 15 insertions(+), 10 deletions(-)
diff --git a/arch/arm/boards/duckbill/lowlevel.c b/arch/arm/boards/duckbill/lowlevel.c
index 2922e40f2a..3adda68d77 100644
--- a/arch/arm/boards/duckbill/lowlevel.c
+++ b/arch/arm/boards/duckbill/lowlevel.c
@@ -55,7 +55,8 @@ static noinline void duckbill_init(void)
pr_debug("initializing SDRAM...\n");
- mx28_mem_init(mx28_dram_vals_default);
+ mx28_mem_init(PINCTRL_EMI_DS_CTRL_DDR_MODE_DDR2,
+ mx28_dram_vals_default);
pr_debug("DONE\n");
}
diff --git a/arch/arm/boards/freescale-mx28-evk/lowlevel.c b/arch/arm/boards/freescale-mx28-evk/lowlevel.c
index 4d45a03ba2..9df60210e6 100644
--- a/arch/arm/boards/freescale-mx28-evk/lowlevel.c
+++ b/arch/arm/boards/freescale-mx28-evk/lowlevel.c
@@ -47,7 +47,8 @@ static noinline void freescale_mx28evk_init(void)
pr_debug("initializing SDRAM...\n");
- mx28_mem_init(mx28_dram_vals_default);
+ mx28_mem_init(PINCTRL_EMI_DS_CTRL_DDR_MODE_DDR2,
+ mx28_dram_vals_default);
pr_debug("DONE\n");
}
diff --git a/arch/arm/boards/karo-tx28/lowlevel.c b/arch/arm/boards/karo-tx28/lowlevel.c
index d072637de7..99f8a562cc 100644
--- a/arch/arm/boards/karo-tx28/lowlevel.c
+++ b/arch/arm/boards/karo-tx28/lowlevel.c
@@ -47,7 +47,8 @@ static noinline void karo_tx28_init(void)
pr_debug("initializing SDRAM...\n");
- mx28_mem_init(mx28_dram_vals_default);
+ mx28_mem_init(PINCTRL_EMI_DS_CTRL_DDR_MODE_DDR2,
+ mx28_dram_vals_default);
pr_debug("DONE\n");
}
diff --git a/arch/arm/mach-mxs/include/mach/init.h b/arch/arm/mach-mxs/include/mach/init.h
index 6526d303a1..7021981d41 100644
--- a/arch/arm/mach-mxs/include/mach/init.h
+++ b/arch/arm/mach-mxs/include/mach/init.h
@@ -21,8 +21,13 @@ void mxs_power_wait_pswitch(void);
extern const uint32_t mx28_dram_vals_default[190];
extern uint32_t mx23_dram_vals[];
+#define PINCTRL_EMI_DS_CTRL_DDR_MODE_LPDDR1 (0b00 << 16)
+#define PINCTRL_EMI_DS_CTRL_DDR_MODE_LVDDR2 (0b10 << 16)
+#define PINCTRL_EMI_DS_CTRL_DDR_MODE_DDR2 (0b11 << 16)
+
void mx23_mem_init(void);
-void mx28_mem_init(const uint32_t dram_vals[190]);
+void mx28_mem_init(const int emi_ds_ctrl_ddr_mode,
+ const uint32_t dram_vals[190]);
void mxs_mem_setup_cpu_and_hbus(void);
void mxs_mem_setup_vdda(void);
void mxs_mem_init_clock(unsigned char divider);
diff --git a/arch/arm/mach-mxs/mem-init.c b/arch/arm/mach-mxs/mem-init.c
index ac8bfee18e..7bc6be00b4 100644
--- a/arch/arm/mach-mxs/mem-init.c
+++ b/arch/arm/mach-mxs/mem-init.c
@@ -318,18 +318,15 @@ void mx23_mem_init(void)
mxs_mem_setup_cpu_and_hbus();
}
-#define PINCTRL_EMI_DS_CTRL_DDR_MODE_DDR2 (0x3 << 16)
-
-void mx28_mem_init(const uint32_t dram_vals[190])
+void mx28_mem_init(const int emi_ds_ctrl_ddr_mode, const uint32_t dram_vals[190])
{
mxs_early_delay(11000);
/* Fractional divider for ref_emi is 21 ; 480 * 18 / 21 = 411MHz */
mxs_mem_init_clock(21);
- /* Set DDR2 mode */
- writel(PINCTRL_EMI_DS_CTRL_DDR_MODE_DDR2,
- IMX_IOMUXC_BASE + 0x1b80);
+ /* Set DDR mode */
+ writel(emi_ds_ctrl_ddr_mode, IMX_IOMUXC_BASE + 0x1b80);
/*
* Configure the DRAM registers
--
2.18.0
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 18+ messages in thread
* [PATCH 04/13] ARM: MXS: allow configuration of EMI clock dividers
2018-07-25 13:36 [PATCH 00/13] MXS/MX28 low-level improvements Roland Hieber
` (2 preceding siblings ...)
2018-07-25 13:36 ` [PATCH 03/13] ARM: MXS: i.MX28: allow setup of low-voltage SDRAM Roland Hieber
@ 2018-07-25 13:36 ` Roland Hieber
2018-08-08 6:41 ` Sascha Hauer
2018-07-25 13:36 ` [PATCH 05/13] ARM: MXS: i.MX28: add autodetection of memory banks Roland Hieber
` (8 subsequent siblings)
12 siblings, 1 reply; 18+ messages in thread
From: Roland Hieber @ 2018-07-25 13:36 UTC (permalink / raw)
To: barebox; +Cc: Roland Hieber
For now, the clock dividers are only accessible from mx28_mem_init, and
the old prescaler of 2 is hardcoded in mx23_mem_init. I'm not sure
if it makes sense to change it at all.
Signed-off-by: Roland Hieber <r.hieber@pengutronix.de>
---
arch/arm/boards/duckbill/lowlevel.c | 2 ++
arch/arm/boards/freescale-mx28-evk/lowlevel.c | 2 ++
arch/arm/boards/karo-tx28/lowlevel.c | 2 ++
arch/arm/mach-mxs/include/mach/init.h | 6 +++---
arch/arm/mach-mxs/mem-init.c | 16 ++++++++--------
5 files changed, 17 insertions(+), 11 deletions(-)
diff --git a/arch/arm/boards/duckbill/lowlevel.c b/arch/arm/boards/duckbill/lowlevel.c
index 3adda68d77..393d4e1e12 100644
--- a/arch/arm/boards/duckbill/lowlevel.c
+++ b/arch/arm/boards/duckbill/lowlevel.c
@@ -56,6 +56,8 @@ static noinline void duckbill_init(void)
pr_debug("initializing SDRAM...\n");
mx28_mem_init(PINCTRL_EMI_DS_CTRL_DDR_MODE_DDR2,
+ /* EMI_CLK of 480 / 2 * (18/21) = 205.7 MHz */
+ 2, 21,
mx28_dram_vals_default);
pr_debug("DONE\n");
diff --git a/arch/arm/boards/freescale-mx28-evk/lowlevel.c b/arch/arm/boards/freescale-mx28-evk/lowlevel.c
index 9df60210e6..196efe0346 100644
--- a/arch/arm/boards/freescale-mx28-evk/lowlevel.c
+++ b/arch/arm/boards/freescale-mx28-evk/lowlevel.c
@@ -48,6 +48,8 @@ static noinline void freescale_mx28evk_init(void)
pr_debug("initializing SDRAM...\n");
mx28_mem_init(PINCTRL_EMI_DS_CTRL_DDR_MODE_DDR2,
+ /* EMI_CLK of 480 / 2 * (18/21) = 205.7 MHz */
+ 2, 21,
mx28_dram_vals_default);
pr_debug("DONE\n");
diff --git a/arch/arm/boards/karo-tx28/lowlevel.c b/arch/arm/boards/karo-tx28/lowlevel.c
index 99f8a562cc..c01c760109 100644
--- a/arch/arm/boards/karo-tx28/lowlevel.c
+++ b/arch/arm/boards/karo-tx28/lowlevel.c
@@ -48,6 +48,8 @@ static noinline void karo_tx28_init(void)
pr_debug("initializing SDRAM...\n");
mx28_mem_init(PINCTRL_EMI_DS_CTRL_DDR_MODE_DDR2,
+ /* EMI_CLK of 480 / 2 * (18/21) = 205.7 MHz */
+ 2, 21,
mx28_dram_vals_default);
pr_debug("DONE\n");
diff --git a/arch/arm/mach-mxs/include/mach/init.h b/arch/arm/mach-mxs/include/mach/init.h
index 7021981d41..4b826363f1 100644
--- a/arch/arm/mach-mxs/include/mach/init.h
+++ b/arch/arm/mach-mxs/include/mach/init.h
@@ -26,11 +26,11 @@ extern uint32_t mx23_dram_vals[];
#define PINCTRL_EMI_DS_CTRL_DDR_MODE_DDR2 (0b11 << 16)
void mx23_mem_init(void);
-void mx28_mem_init(const int emi_ds_ctrl_ddr_mode,
- const uint32_t dram_vals[190]);
+void mx28_mem_init(const int emi_ds_ctrl_ddr_mode, const uint8_t clk_emi_div,
+ const uint8_t clk_emi_frac_div, const uint32_t dram_vals[190]);
void mxs_mem_setup_cpu_and_hbus(void);
void mxs_mem_setup_vdda(void);
-void mxs_mem_init_clock(unsigned char divider);
+void mxs_mem_init_clock(const uint8_t clk_emi_div, const uint8_t clk_emi_frac);
void mxs_lradc_init(void);
void mxs_lradc_enable_batt_measurement(void);
diff --git a/arch/arm/mach-mxs/mem-init.c b/arch/arm/mach-mxs/mem-init.c
index 7bc6be00b4..585c3173f5 100644
--- a/arch/arm/mach-mxs/mem-init.c
+++ b/arch/arm/mach-mxs/mem-init.c
@@ -192,7 +192,7 @@ static void mx23_initialize_dram_values(void)
writel((1 << 24), IMX_SDRAMC_BASE + (4 * 8));
}
-void mxs_mem_init_clock(unsigned char divider)
+void mxs_mem_init_clock(const uint8_t clk_emi_div, const uint8_t clk_emi_frac)
{
struct mxs_clkctrl_regs *clkctrl_regs =
(struct mxs_clkctrl_regs *)IMX_CCM_BASE;
@@ -202,7 +202,7 @@ void mxs_mem_init_clock(unsigned char divider)
&clkctrl_regs->hw_clkctrl_frac0_set[CLKCTRL_FRAC0_EMI]);
/* Set fractional divider for ref_emi */
- writeb(CLKCTRL_FRAC_CLKGATE | (divider & CLKCTRL_FRAC_FRAC_MASK),
+ writeb(CLKCTRL_FRAC_CLKGATE | (clk_emi_frac & CLKCTRL_FRAC_FRAC_MASK),
&clkctrl_regs->hw_clkctrl_frac0[CLKCTRL_FRAC0_EMI]);
/* Ungate EMI clock */
@@ -211,8 +211,8 @@ void mxs_mem_init_clock(unsigned char divider)
mxs_early_delay(11000);
- /* Set EMI clock divider for EMI clock to 411 / 2 = 205MHz */
- writel((2 << CLKCTRL_EMI_DIV_EMI_OFFSET) |
+ /* Set EMI clock divider for EMI clock */
+ writel(((clk_emi_div & CLKCTRL_EMI_DIV_EMI_MASK) << CLKCTRL_EMI_DIV_EMI_OFFSET) |
(1 << CLKCTRL_EMI_DIV_XTAL_OFFSET),
&clkctrl_regs->hw_clkctrl_emi);
@@ -274,7 +274,7 @@ void mx23_mem_init(void)
mxs_early_delay(11000);
/* Fractional divider for ref_emi is 33 ; 480 * 18 / 33 = 266MHz */
- mxs_mem_init_clock(33);
+ mxs_mem_init_clock(2, 33);
/*
* Reset/ungate the EMI block. This is essential, otherwise the system
@@ -318,12 +318,12 @@ void mx23_mem_init(void)
mxs_mem_setup_cpu_and_hbus();
}
-void mx28_mem_init(const int emi_ds_ctrl_ddr_mode, const uint32_t dram_vals[190])
+void mx28_mem_init(const int emi_ds_ctrl_ddr_mode, const uint8_t clk_emi_div,
+ const uint8_t clk_emi_frac_div, const uint32_t dram_vals[190])
{
mxs_early_delay(11000);
- /* Fractional divider for ref_emi is 21 ; 480 * 18 / 21 = 411MHz */
- mxs_mem_init_clock(21);
+ mxs_mem_init_clock(clk_emi_div, clk_emi_frac_div);
/* Set DDR mode */
writel(emi_ds_ctrl_ddr_mode, IMX_IOMUXC_BASE + 0x1b80);
--
2.18.0
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 18+ messages in thread
* [PATCH 05/13] ARM: MXS: i.MX28: add autodetection of memory banks
2018-07-25 13:36 [PATCH 00/13] MXS/MX28 low-level improvements Roland Hieber
` (3 preceding siblings ...)
2018-07-25 13:36 ` [PATCH 04/13] ARM: MXS: allow configuration of EMI clock dividers Roland Hieber
@ 2018-07-25 13:36 ` Roland Hieber
2018-07-27 8:28 ` Roland Hieber
2018-07-31 10:07 ` Roland Hieber
2018-07-25 13:36 ` [PATCH 06/13] ARM: MXS: refactor mx2*_power_init source configuration Roland Hieber
` (7 subsequent siblings)
12 siblings, 2 replies; 18+ messages in thread
From: Roland Hieber @ 2018-07-25 13:36 UTC (permalink / raw)
To: barebox; +Cc: Roland Hieber
If the prebootloader has set up the EMI controller correctly, we can
autodetect the size of available RAM by looking at the respective
configuration registers.
Signed-off-by: Roland Hieber <r.hieber@pengutronix.de>
---
arch/arm/mach-mxs/Makefile | 2 +-
arch/arm/mach-mxs/mem-imx28.c | 39 +++++++++++++++++++++++++++++++++++
2 files changed, 40 insertions(+), 1 deletion(-)
create mode 100644 arch/arm/mach-mxs/mem-imx28.c
diff --git a/arch/arm/mach-mxs/Makefile b/arch/arm/mach-mxs/Makefile
index e3843368c2..0761f909a1 100644
--- a/arch/arm/mach-mxs/Makefile
+++ b/arch/arm/mach-mxs/Makefile
@@ -1,7 +1,7 @@
obj-y += imx.o iomux-imx.o power.o
pbl-y += iomux-imx.o
obj-$(CONFIG_ARCH_IMX23) += clocksource-imx23.o usb-imx23.o soc-imx23.o
-obj-$(CONFIG_ARCH_IMX28) += clocksource-imx28.o usb-imx28.o soc-imx28.o
+obj-$(CONFIG_ARCH_IMX28) += clocksource-imx28.o usb-imx28.o soc-imx28.o mem-imx28.o
obj-$(CONFIG_MXS_OCOTP) += ocotp.o
obj-$(CONFIG_MXS_CMD_BCB) += bcb.o
pbl-y += power-init.o mem-init.o lradc-init.o
diff --git a/arch/arm/mach-mxs/mem-imx28.c b/arch/arm/mach-mxs/mem-imx28.c
new file mode 100644
index 0000000000..e827e0906f
--- /dev/null
+++ b/arch/arm/mach-mxs/mem-imx28.c
@@ -0,0 +1,39 @@
+/*
+ * Copyright (C) 2018 Pengutronix, Roland Hieber <r.hieber@pengutronix.de>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * version 2, as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ */
+
+#include <init.h>
+#include <asm/memory.h>
+#include <mach/imx28-regs.h>
+#include <printk.h>
+
+static int mx28_add_mem(void)
+{
+ if (!of_machine_is_compatible("fsl,imx28"))
+ return 0;
+
+ int * sdramc = (int *)IMX_SDRAMC_BASE;
+
+ uint8_t columns = 12 - ((sdramc[29] >> 16) & 0b111);
+ uint8_t rows = 15 - ((sdramc[29] >> 8) & 0b111);
+ uint8_t banks = ((sdramc[31] >> 16) & 0b1) ? 8 : 4;
+ uint8_t width = sizeof (unsigned short);
+
+ uint32_t size = (1 << columns) * (1 << rows) * banks * width;
+ pr_info("i.MX28: detected %d cols, %d rows, %d banks = %d MiB of RAM\n",
+ columns, rows, banks, size / 1024 / 1024);
+
+ arm_add_mem_device("ram0", IMX_MEMORY_BASE, size);
+
+ return 0;
+}
+mem_initcall(mx28_add_mem);
--
2.18.0
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 18+ messages in thread
* [PATCH 06/13] ARM: MXS: refactor mx2*_power_init source configuration
2018-07-25 13:36 [PATCH 00/13] MXS/MX28 low-level improvements Roland Hieber
` (4 preceding siblings ...)
2018-07-25 13:36 ` [PATCH 05/13] ARM: MXS: i.MX28: add autodetection of memory banks Roland Hieber
@ 2018-07-25 13:36 ` Roland Hieber
2018-07-25 13:36 ` [PATCH 07/13] ARM: MXS: allow starting from battery input without 4P2 source enabled Roland Hieber
` (6 subsequent siblings)
12 siblings, 0 replies; 18+ messages in thread
From: Roland Hieber @ 2018-07-25 13:36 UTC (permalink / raw)
To: barebox; +Cc: Roland Hieber
Having three ints as parameter suggests that we can use up to 2^3
power configurations for the system, but when we look at the code, the
power setup is packaged in if {...} else if {...} else if {...} blocks,
so setting more than one parameter to 1 is useless here.
Refactor the parameters into an enum to get rid of that suggestion.
Signed-off-by: Roland Hieber <r.hieber@pengutronix.de>
---
arch/arm/boards/duckbill/lowlevel.c | 2 +-
arch/arm/boards/freescale-mx28-evk/lowlevel.c | 2 +-
arch/arm/boards/imx233-olinuxino/lowlevel.c | 2 +-
arch/arm/boards/karo-tx28/lowlevel.c | 2 +-
arch/arm/mach-mxs/include/mach/init.h | 20 ++++++--
arch/arm/mach-mxs/power-init.c | 49 +++++++------------
6 files changed, 37 insertions(+), 40 deletions(-)
diff --git a/arch/arm/boards/duckbill/lowlevel.c b/arch/arm/boards/duckbill/lowlevel.c
index 393d4e1e12..ebda3aa047 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(0, 0, 1);
+ mx28_power_init(POWER_USE_5V);
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 196efe0346..64e3752bce 100644
--- a/arch/arm/boards/freescale-mx28-evk/lowlevel.c
+++ b/arch/arm/boards/freescale-mx28-evk/lowlevel.c
@@ -43,7 +43,7 @@ static noinline void freescale_mx28evk_init(void)
pr_debug("initializing power...\n");
- mx28_power_init(0, 1, 0);
+ mx28_power_init(POWER_USE_BATTERY_INPUT);
pr_debug("initializing SDRAM...\n");
diff --git a/arch/arm/boards/imx233-olinuxino/lowlevel.c b/arch/arm/boards/imx233-olinuxino/lowlevel.c
index 63a65230b0..7a3cea006e 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(0, 0, 1);
+ mx23_power_init(POWER_USE_5V);
pr_debug("initializing SDRAM...\n");
diff --git a/arch/arm/boards/karo-tx28/lowlevel.c b/arch/arm/boards/karo-tx28/lowlevel.c
index c01c760109..6ee4235b79 100644
--- a/arch/arm/boards/karo-tx28/lowlevel.c
+++ b/arch/arm/boards/karo-tx28/lowlevel.c
@@ -43,7 +43,7 @@ static noinline void karo_tx28_init(void)
pr_debug("initializing power...\n");
- mx28_power_init(0, 1, 0);
+ mx28_power_init(POWER_USE_BATTERY_INPUT);
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 4b826363f1..5ca7a72042 100644
--- a/arch/arm/mach-mxs/include/mach/init.h
+++ b/arch/arm/mach-mxs/include/mach/init.h
@@ -12,10 +12,22 @@
void mxs_early_delay(int delay);
-void mx23_power_init(int __has_battery, int __use_battery_input,
- int __use_5v_input);
-void mx28_power_init(int __has_battery, int __use_battery_input,
- int __use_5v_input);
+/**
+ * Power configuration of the system:
+ * - POWER_USE_5V: use 5V input as power supply
+ * - POWER_USE_BATTERY: use battery input when the system is supplied by a battery
+ * - POWER_USE_BATTERY_INPUT: use battery input when the system is supplied by
+ * a DC source (instead of a real battery) on the battery input
+ */
+enum mxs_power_config {
+ POWER_USE_5V = 0b00000000,
+ POWER_USE_BATTERY = 0b00000001,
+ POWER_USE_BATTERY_INPUT = 0b00000010,
+ __POWER_USE_MASK = 0b00000011,
+};
+
+void mx23_power_init(const int config);
+void mx28_power_init(const int config);
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 595b51c5ba..a07ff9d676 100644
--- a/arch/arm/mach-mxs/power-init.c
+++ b/arch/arm/mach-mxs/power-init.c
@@ -24,21 +24,7 @@
#include <mach/regs-rtc.h>
#include <mach/regs-lradc.h>
-/*
- * has_battery - true when this board has a battery.
- */
-static int has_battery;
-
-/*
- * use_battery_input - true when this board is supplied from the
- * battery input, but has a DC source instead of a real battery
- */
-static int use_battery_input;
-
-/*
- * use_5v_input - true when this board can use the 5V input
- */
-static int use_5v_input;
+static int power_config;
static void mxs_power_status(void)
{
@@ -514,7 +500,8 @@ static void mxs_power_enable_4p2(void)
POWER_5VCTRL_HEADROOM_ADJ_MASK,
0x4 << POWER_5VCTRL_HEADROOM_ADJ_OFFSET);
- if (has_battery || use_battery_input)
+ if ((power_config & __POWER_USE_MASK) == POWER_USE_BATTERY ||
+ (power_config & __POWER_USE_MASK) == POWER_USE_BATTERY_INPUT)
dropout_ctrl = POWER_DCDC4P2_DROPOUT_CTRL_SRC_SEL;
else
dropout_ctrl = POWER_DCDC4P2_DROPOUT_CTRL_SRC_4P2;
@@ -1182,16 +1169,15 @@ static void mx23_ungate_power(void)
*
* This function calls all the power block initialization functions in
* proper sequence to start the power block.
+ *
+ * @config: see enum mxs_power_config for possible options
*/
-void mx23_power_init(int __has_battery, int __use_battery_input,
- int __use_5v_input)
+void mx23_power_init(const int config)
{
struct mxs_power_regs *power_regs =
(struct mxs_power_regs *)IMX_POWER_BASE;
- has_battery = __has_battery;
- use_battery_input = __use_battery_input;
- use_5v_input = __use_5v_input;
+ power_config = config;
mx23_ungate_power();
@@ -1204,11 +1190,11 @@ void mx23_power_init(int __has_battery, int __use_battery_input,
mxs_src_power_init();
- if (has_battery)
+ if ((power_config & __POWER_USE_MASK) == POWER_USE_BATTERY)
mxs_power_configure_power_source();
- else if (use_battery_input)
+ else if ((power_config & __POWER_USE_MASK) == POWER_USE_BATTERY_INPUT)
mxs_enable_battery_input();
- else if (use_5v_input)
+ else if ((power_config & __POWER_USE_MASK) == POWER_USE_5V)
mxs_boot_valid_5v();
mxs_power_clock2pll();
@@ -1243,16 +1229,15 @@ void mx23_power_init(int __has_battery, int __use_battery_input,
*
* This function calls all the power block initialization functions in
* proper sequence to start the power block.
+ *
+ * @config: see enum mxs_power_config for possible options
*/
-void mx28_power_init(int __has_battery, int __use_battery_input,
- int __use_5v_input)
+void mx28_power_init(const int config)
{
struct mxs_power_regs *power_regs =
(struct mxs_power_regs *)IMX_POWER_BASE;
- has_battery = __has_battery;
- use_battery_input = __use_battery_input;
- use_5v_input = __use_5v_input;
+ power_config = config;
mxs_power_status();
mxs_power_clock2xtal();
@@ -1264,11 +1249,11 @@ void mx28_power_init(int __has_battery, int __use_battery_input,
mxs_src_power_init();
- if (has_battery)
+ if ((power_config & __POWER_USE_MASK) == POWER_USE_BATTERY)
mxs_power_configure_power_source();
- else if (use_battery_input)
+ else if ((power_config & __POWER_USE_MASK) == POWER_USE_BATTERY_INPUT)
mxs_enable_battery_input();
- else if (use_5v_input)
+ else if ((power_config & __POWER_USE_MASK) == POWER_USE_5V)
mxs_boot_valid_5v();
mxs_power_clock2pll();
--
2.18.0
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 18+ messages in thread
* [PATCH 07/13] ARM: MXS: allow starting from battery input without 4P2 source enabled
2018-07-25 13:36 [PATCH 00/13] MXS/MX28 low-level improvements Roland Hieber
` (5 preceding siblings ...)
2018-07-25 13:36 ` [PATCH 06/13] ARM: MXS: refactor mx2*_power_init source configuration Roland Hieber
@ 2018-07-25 13:36 ` Roland Hieber
2018-07-25 13:36 ` [PATCH 08/13] ARM: MXS: make power levels configurable in mx2*_power_init Roland Hieber
` (5 subsequent siblings)
12 siblings, 0 replies; 18+ messages in thread
From: Roland Hieber @ 2018-07-25 13:36 UTC (permalink / raw)
To: barebox; +Cc: Roland Hieber
Some boards don't need the 4.2V power source at all, so allow them to
keep it disabled for efficiency reasons.
For backwards compatibility, don't disable the 4P2 power source on the
existing boards which are supplied from battery input.
The POWER_USE_5V code path however always enables it up as it is needed
to supply the DC-DC converter.
Signed-off-by: Roland Hieber <r.hieber@pengutronix.de>
---
arch/arm/boards/freescale-mx28-evk/lowlevel.c | 2 +-
arch/arm/boards/karo-tx28/lowlevel.c | 2 +-
arch/arm/mach-mxs/include/mach/init.h | 2 ++
arch/arm/mach-mxs/power-init.c | 3 ++-
4 files changed, 6 insertions(+), 3 deletions(-)
diff --git a/arch/arm/boards/freescale-mx28-evk/lowlevel.c b/arch/arm/boards/freescale-mx28-evk/lowlevel.c
index 64e3752bce..e5ae36a715 100644
--- a/arch/arm/boards/freescale-mx28-evk/lowlevel.c
+++ b/arch/arm/boards/freescale-mx28-evk/lowlevel.c
@@ -43,7 +43,7 @@ static noinline void freescale_mx28evk_init(void)
pr_debug("initializing power...\n");
- mx28_power_init(POWER_USE_BATTERY_INPUT);
+ mx28_power_init(POWER_USE_BATTERY_INPUT | POWER_ENABLE_4P2);
pr_debug("initializing SDRAM...\n");
diff --git a/arch/arm/boards/karo-tx28/lowlevel.c b/arch/arm/boards/karo-tx28/lowlevel.c
index 6ee4235b79..9e22f002da 100644
--- a/arch/arm/boards/karo-tx28/lowlevel.c
+++ b/arch/arm/boards/karo-tx28/lowlevel.c
@@ -43,7 +43,7 @@ static noinline void karo_tx28_init(void)
pr_debug("initializing power...\n");
- mx28_power_init(POWER_USE_BATTERY_INPUT);
+ mx28_power_init(POWER_USE_BATTERY_INPUT | POWER_ENABLE_4P2);
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 5ca7a72042..f2e19408d3 100644
--- a/arch/arm/mach-mxs/include/mach/init.h
+++ b/arch/arm/mach-mxs/include/mach/init.h
@@ -18,12 +18,14 @@ void mxs_early_delay(int delay);
* - POWER_USE_BATTERY: use battery input when the system is supplied by a battery
* - POWER_USE_BATTERY_INPUT: use battery input when the system is supplied by
* a DC source (instead of a real battery) on the battery input
+ * - POWER_ENABLE_4P2: power up the 4P2 regulator (implied for POWER_USE_5V)
*/
enum mxs_power_config {
POWER_USE_5V = 0b00000000,
POWER_USE_BATTERY = 0b00000001,
POWER_USE_BATTERY_INPUT = 0b00000010,
__POWER_USE_MASK = 0b00000011,
+ POWER_ENABLE_4P2 = 0b00000100,
};
void mx23_power_init(const int config);
diff --git a/arch/arm/mach-mxs/power-init.c b/arch/arm/mach-mxs/power-init.c
index a07ff9d676..2984c0c5ff 100644
--- a/arch/arm/mach-mxs/power-init.c
+++ b/arch/arm/mach-mxs/power-init.c
@@ -717,7 +717,8 @@ static void mxs_enable_battery_input(void)
POWER_5VCTRL_CHARGE_4P2_ILIMIT_MASK,
0x8 << POWER_5VCTRL_CHARGE_4P2_ILIMIT_OFFSET);
- mxs_power_enable_4p2();
+ if (power_config & POWER_ENABLE_4P2)
+ mxs_power_enable_4p2();
}
/**
--
2.18.0
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 18+ messages in thread
* [PATCH 08/13] ARM: MXS: make power levels configurable in mx2*_power_init
2018-07-25 13:36 [PATCH 00/13] MXS/MX28 low-level improvements Roland Hieber
` (6 preceding siblings ...)
2018-07-25 13:36 ` [PATCH 07/13] ARM: MXS: allow starting from battery input without 4P2 source enabled Roland Hieber
@ 2018-07-25 13:36 ` Roland Hieber
2018-07-25 13:36 ` [PATCH 09/13] ARM: MXS: fix VDDx brownout setup logic Roland Hieber
` (4 subsequent siblings)
12 siblings, 0 replies; 18+ messages in thread
From: Roland Hieber @ 2018-07-25 13:36 UTC (permalink / raw)
To: barebox; +Cc: Roland Hieber
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 ebda3aa047..cc9335dbaf 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 e5ae36a715..ae36671028 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 7a3cea006e..baed338185 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 9e22f002da..cfc9248dea 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 f2e19408d3..66f7f31e35 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
^ permalink raw reply [flat|nested] 18+ messages in thread
* [PATCH 09/13] ARM: MXS: fix VDDx brownout setup logic
2018-07-25 13:36 [PATCH 00/13] MXS/MX28 low-level improvements Roland Hieber
` (7 preceding siblings ...)
2018-07-25 13:36 ` [PATCH 08/13] ARM: MXS: make power levels configurable in mx2*_power_init Roland Hieber
@ 2018-07-25 13:36 ` Roland Hieber
2018-07-25 13:36 ` [PATCH 10/13] ARM: MXS: make VDDx brownout setup more understandable Roland Hieber
` (3 subsequent siblings)
12 siblings, 0 replies; 18+ messages in thread
From: Roland Hieber @ 2018-07-25 13:36 UTC (permalink / raw)
To: barebox; +Cc: Roland Hieber
The cfg->bo_irq and cfg->bo_enirq (i.e. VDDx_BO_IRQ and ENIRQ_VDDx_BO)
flags are part of POWER_CTRL, so setting those flag in cfg->reg (i.e.
POWER_VDDxCTRL) makes no sense. Fortunately, those bits are reserved in
ENIRQ_VDDx_BO, so writing them did no harm, but also doesn't work as
intended.
Signed-off-by: Roland Hieber <r.hieber@pengutronix.de>
---
arch/arm/mach-mxs/power-init.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/arch/arm/mach-mxs/power-init.c b/arch/arm/mach-mxs/power-init.c
index d4b88a4b2c..db597ef65c 100644
--- a/arch/arm/mach-mxs/power-init.c
+++ b/arch/arm/mach-mxs/power-init.c
@@ -1083,8 +1083,8 @@ static void mxs_power_set_vddx(const struct mxs_vddx_cfg *cfg,
if (adjust_up && cfg->bo_irq) {
if (powered_by_linreg) {
- bo_int = readl(cfg->reg);
- clrbits_le32(cfg->reg, cfg->bo_enirq);
+ bo_int = readl(&power_regs->hw_power_ctrl);
+ writel(cfg->bo_enirq, &power_regs->hw_power_ctrl_clr);
}
setbits_le32(cfg->reg, cfg->bo_offset_mask);
}
@@ -1126,7 +1126,7 @@ static void mxs_power_set_vddx(const struct mxs_vddx_cfg *cfg,
if (adjust_up && powered_by_linreg) {
writel(cfg->bo_irq, &power_regs->hw_power_ctrl_clr);
if (bo_int & cfg->bo_enirq)
- setbits_le32(cfg->reg, cfg->bo_enirq);
+ writel(cfg->bo_enirq, &power_regs->hw_power_ctrl_set);
}
clrsetbits_le32(cfg->reg, cfg->bo_offset_mask,
--
2.18.0
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 18+ messages in thread
* [PATCH 10/13] ARM: MXS: make VDDx brownout setup more understandable
2018-07-25 13:36 [PATCH 00/13] MXS/MX28 low-level improvements Roland Hieber
` (8 preceding siblings ...)
2018-07-25 13:36 ` [PATCH 09/13] ARM: MXS: fix VDDx brownout setup logic Roland Hieber
@ 2018-07-25 13:36 ` Roland Hieber
2018-07-25 13:36 ` [PATCH 11/13] ARM: MXS: mxs_power_status: use less magic values Roland Hieber
` (2 subsequent siblings)
12 siblings, 0 replies; 18+ messages in thread
From: Roland Hieber @ 2018-07-25 13:36 UTC (permalink / raw)
To: barebox; +Cc: Roland Hieber
Rename bo_int to prev_bo_enirq to make its purpose clearer, and throw in
a few comments for easier understanding.
Signed-off-by: Roland Hieber <r.hieber@pengutronix.de>
---
arch/arm/mach-mxs/power-init.c | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
diff --git a/arch/arm/mach-mxs/power-init.c b/arch/arm/mach-mxs/power-init.c
index db597ef65c..060bd9115b 100644
--- a/arch/arm/mach-mxs/power-init.c
+++ b/arch/arm/mach-mxs/power-init.c
@@ -1066,7 +1066,7 @@ static void mxs_power_set_vddx(const struct mxs_vddx_cfg *cfg,
{
struct mxs_power_regs *power_regs =
(struct mxs_power_regs *)IMX_POWER_BASE;
- uint32_t cur_target, diff, bo_int = 0;
+ uint32_t cur_target, diff, prev_bo_enirq = 0;
uint32_t powered_by_linreg = 0;
int adjust_up, tmp;
@@ -1082,8 +1082,10 @@ static void mxs_power_set_vddx(const struct mxs_vddx_cfg *cfg,
powered_by_linreg = cfg->powered_by_linreg();
if (adjust_up && cfg->bo_irq) {
+ /* temporarily disable brownout to prevent it from taking
+ effect prematurely during the adjustment */
if (powered_by_linreg) {
- bo_int = readl(&power_regs->hw_power_ctrl);
+ prev_bo_enirq = readl(&power_regs->hw_power_ctrl) & cfg->bo_enirq;
writel(cfg->bo_enirq, &power_regs->hw_power_ctrl_clr);
}
setbits_le32(cfg->reg, cfg->bo_offset_mask);
@@ -1124,8 +1126,10 @@ static void mxs_power_set_vddx(const struct mxs_vddx_cfg *cfg,
if (cfg->bo_irq) {
if (adjust_up && powered_by_linreg) {
+ /* clear brownout IRQ flag in case it fired */
writel(cfg->bo_irq, &power_regs->hw_power_ctrl_clr);
- if (bo_int & cfg->bo_enirq)
+ if (prev_bo_enirq)
+ /* re-enable brownout IRQ after adjustment has finished */
writel(cfg->bo_enirq, &power_regs->hw_power_ctrl_set);
}
--
2.18.0
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 18+ messages in thread
* [PATCH 11/13] ARM: MXS: mxs_power_status: use less magic values
2018-07-25 13:36 [PATCH 00/13] MXS/MX28 low-level improvements Roland Hieber
` (9 preceding siblings ...)
2018-07-25 13:36 ` [PATCH 10/13] ARM: MXS: make VDDx brownout setup more understandable Roland Hieber
@ 2018-07-25 13:36 ` Roland Hieber
2018-07-25 13:36 ` [PATCH 12/13] ARM: MXS: mxs_power_status: align output Roland Hieber
2018-07-25 13:36 ` [PATCH 13/13] Documentation: MXS: general update and improvements Roland Hieber
12 siblings, 0 replies; 18+ messages in thread
From: Roland Hieber @ 2018-07-25 13:36 UTC (permalink / raw)
To: barebox; +Cc: Roland Hieber
... and in that process fix the erroneous usage of VDDA values when
printing the stats for POWER_VDDDCTRL_DISABLE_FET and all of the
*LINREG_OFFSET bitfields.
Signed-off-by: Roland Hieber <r.hieber@pengutronix.de>
---
arch/arm/mach-mxs/power-init.c | 37 ++++++++++++++++++----------------
1 file changed, 20 insertions(+), 17 deletions(-)
diff --git a/arch/arm/mach-mxs/power-init.c b/arch/arm/mach-mxs/power-init.c
index 060bd9115b..3ec17dad19 100644
--- a/arch/arm/mach-mxs/power-init.c
+++ b/arch/arm/mach-mxs/power-init.c
@@ -37,27 +37,30 @@ static void mxs_power_status(void)
uint32_t vddd = readl(&power_regs->hw_power_vdddctrl);
uint32_t vddmem = readl(&power_regs->hw_power_vddmemctrl);
+#define __REG_BITS(value, fieldname) (((value) & fieldname##_MASK) >> fieldname##_OFFSET)
+
printf("vddio: %dmV (BO -%dmV), Linreg enabled, Linreg offset: %d, FET %sabled\n",
- (vddio & 0x1f) * 50 + 2800,
- ((vddio >> 8) & 0x7) * 50,
- linregofs[((vdda >> 12) & 0x3)],
- (vddio & (1 << 16)) ? "dis" : "en");
+ __REG_BITS(vddio, POWER_VDDIOCTRL_TRG) * 50 + 2800,
+ __REG_BITS(vddio, POWER_VDDIOCTRL_BO_OFFSET) * 50,
+ linregofs[__REG_BITS(vddio, POWER_VDDIOCTRL_LINREG_OFFSET)],
+ (vddio & POWER_VDDIOCTRL_DISABLE_FET) ? "dis" : "en");
printf("vdda: %dmV (BO -%dmV), Linreg %sabled, Linreg offset: %d, FET %sabled\n",
- (vdda & 0x1f) * 25 + 1500,
- ((vdda >> 8) & 0x7) * 25,
- (vdda & (1 << 17)) ? "en" : "dis",
- linregofs[((vdda >> 12) & 0x3)],
- (vdda & (1 << 16)) ? "dis" : "en");
+ __REG_BITS(vdda, POWER_VDDACTRL_TRG) * 25 + 1500,
+ __REG_BITS(vdda, POWER_VDDACTRL_BO_OFFSET) * 25,
+ (vdda & POWER_VDDACTRL_ENABLE_LINREG) ? "en" : "dis",
+ linregofs[__REG_BITS(vdda, POWER_VDDACTRL_LINREG_OFFSET)],
+ (vdda & POWER_VDDACTRL_DISABLE_FET) ? "dis" : "en");
printf("vddd: %dmV (BO -%dmV), Linreg %sabled, Linreg offset: %d, FET %sabled\n",
- (vddd & 0x1f) * 25 + 800,
- ((vddd >> 8) & 0x7) * 25,
- (vddd & (1 << 21)) ? "en" : "dis",
- linregofs[((vdda >> 16) & 0x3)],
- (vdda & (1 << 20)) ? "dis" : "en");
+ __REG_BITS(vddd, POWER_VDDDCTRL_TRG) * 25 + 800,
+ __REG_BITS(vddd, POWER_VDDDCTRL_BO_OFFSET) * 25,
+ (vddd & POWER_VDDDCTRL_ENABLE_LINREG) ? "en" : "dis",
+ linregofs[__REG_BITS(vddd, POWER_VDDDCTRL_LINREG_OFFSET)],
+ (vddd & POWER_VDDDCTRL_DISABLE_FET) ? "dis" : "en");
printf("vddmem: %dmV (BO -%dmV), Linreg %sabled\n",
- (vddmem & 0x1f) * 25 + 1100,
- ((vddmem >> 5) & 0x7) * 25,
- (vddmem & (1 << 8)) ? "en" : "dis");
+ __REG_BITS(vddmem, POWER_VDDMEMCTRL_TRG) * 25 + 1100,
+ /* Note: this area is reserved on i.MX23, yielding 0: */
+ __REG_BITS(vddmem, MX28_POWER_VDDMEMCTRL_BO_OFFSET) * 25,
+ (vddmem & POWER_VDDMEMCTRL_ENABLE_LINREG) ? "en" : "dis");
}
/*
--
2.18.0
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 18+ messages in thread
* [PATCH 12/13] ARM: MXS: mxs_power_status: align output
2018-07-25 13:36 [PATCH 00/13] MXS/MX28 low-level improvements Roland Hieber
` (10 preceding siblings ...)
2018-07-25 13:36 ` [PATCH 11/13] ARM: MXS: mxs_power_status: use less magic values Roland Hieber
@ 2018-07-25 13:36 ` Roland Hieber
2018-07-25 13:36 ` [PATCH 13/13] Documentation: MXS: general update and improvements Roland Hieber
12 siblings, 0 replies; 18+ messages in thread
From: Roland Hieber @ 2018-07-25 13:36 UTC (permalink / raw)
To: barebox; +Cc: Roland Hieber
Exemplary previous behaviour:
vddio: 3100mV (BO -200mV), Linreg enabled, Linreg offset: -1, FET enabled
vdda: 1800mV (BO -175mV), Linreg disabled, Linreg offset: -1, FET enabled
vddd: 1200mV (BO -175mV), Linreg enabled, Linreg offset: -1, FET disabled
vddmem: 1500mV (BO -25mV), Linreg disabled
After this patch this looks much cleaner:
vddio: 3100mV (BO -200mV), Linreg enabled, Linreg offset: -1, FET enabled
vdda: 1800mV (BO -175mV), Linreg disabled, Linreg offset: -1, FET enabled
vddd: 1200mV (BO -175mV), Linreg enabled, Linreg offset: -1, FET disabled
vddmem: 1500mV (BO - 25mV), Linreg disabled
Signed-off-by: Roland Hieber <r.hieber@pengutronix.de>
---
arch/arm/mach-mxs/power-init.c | 20 ++++++++++----------
1 file changed, 10 insertions(+), 10 deletions(-)
diff --git a/arch/arm/mach-mxs/power-init.c b/arch/arm/mach-mxs/power-init.c
index 3ec17dad19..796d3ae259 100644
--- a/arch/arm/mach-mxs/power-init.c
+++ b/arch/arm/mach-mxs/power-init.c
@@ -39,28 +39,28 @@ static void mxs_power_status(void)
#define __REG_BITS(value, fieldname) (((value) & fieldname##_MASK) >> fieldname##_OFFSET)
- printf("vddio: %dmV (BO -%dmV), Linreg enabled, Linreg offset: %d, FET %sabled\n",
+ printf("vddio: %4dmV (BO -%3dmV), Linreg enabled, Linreg offset: %1d, FET %sabled\n",
__REG_BITS(vddio, POWER_VDDIOCTRL_TRG) * 50 + 2800,
__REG_BITS(vddio, POWER_VDDIOCTRL_BO_OFFSET) * 50,
linregofs[__REG_BITS(vddio, POWER_VDDIOCTRL_LINREG_OFFSET)],
- (vddio & POWER_VDDIOCTRL_DISABLE_FET) ? "dis" : "en");
- printf("vdda: %dmV (BO -%dmV), Linreg %sabled, Linreg offset: %d, FET %sabled\n",
+ (vddio & POWER_VDDIOCTRL_DISABLE_FET) ? "dis" : " en");
+ printf("vdda: %4dmV (BO -%3dmV), Linreg %sabled, Linreg offset: %1d, FET %sabled\n",
__REG_BITS(vdda, POWER_VDDACTRL_TRG) * 25 + 1500,
__REG_BITS(vdda, POWER_VDDACTRL_BO_OFFSET) * 25,
- (vdda & POWER_VDDACTRL_ENABLE_LINREG) ? "en" : "dis",
+ (vdda & POWER_VDDACTRL_ENABLE_LINREG) ? " en" : "dis",
linregofs[__REG_BITS(vdda, POWER_VDDACTRL_LINREG_OFFSET)],
- (vdda & POWER_VDDACTRL_DISABLE_FET) ? "dis" : "en");
- printf("vddd: %dmV (BO -%dmV), Linreg %sabled, Linreg offset: %d, FET %sabled\n",
+ (vdda & POWER_VDDACTRL_DISABLE_FET) ? "dis" : " en");
+ printf("vddd: %4dmV (BO -%3dmV), Linreg %sabled, Linreg offset: %1d, FET %sabled\n",
__REG_BITS(vddd, POWER_VDDDCTRL_TRG) * 25 + 800,
__REG_BITS(vddd, POWER_VDDDCTRL_BO_OFFSET) * 25,
- (vddd & POWER_VDDDCTRL_ENABLE_LINREG) ? "en" : "dis",
+ (vddd & POWER_VDDDCTRL_ENABLE_LINREG) ? " en" : "dis",
linregofs[__REG_BITS(vddd, POWER_VDDDCTRL_LINREG_OFFSET)],
- (vddd & POWER_VDDDCTRL_DISABLE_FET) ? "dis" : "en");
- printf("vddmem: %dmV (BO -%dmV), Linreg %sabled\n",
+ (vddd & POWER_VDDDCTRL_DISABLE_FET) ? "dis" : " en");
+ printf("vddmem: %4dmV (BO -%3dmV), Linreg %sabled\n",
__REG_BITS(vddmem, POWER_VDDMEMCTRL_TRG) * 25 + 1100,
/* Note: this area is reserved on i.MX23, yielding 0: */
__REG_BITS(vddmem, MX28_POWER_VDDMEMCTRL_BO_OFFSET) * 25,
- (vddmem & POWER_VDDMEMCTRL_ENABLE_LINREG) ? "en" : "dis");
+ (vddmem & POWER_VDDMEMCTRL_ENABLE_LINREG) ? " en" : "dis");
}
/*
--
2.18.0
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 18+ messages in thread
* [PATCH 13/13] Documentation: MXS: general update and improvements
2018-07-25 13:36 [PATCH 00/13] MXS/MX28 low-level improvements Roland Hieber
` (11 preceding siblings ...)
2018-07-25 13:36 ` [PATCH 12/13] ARM: MXS: mxs_power_status: align output Roland Hieber
@ 2018-07-25 13:36 ` Roland Hieber
12 siblings, 0 replies; 18+ messages in thread
From: Roland Hieber @ 2018-07-25 13:36 UTC (permalink / raw)
To: barebox; +Cc: Roland Hieber
Go more into detail about the relationship of the prepare stage and the
bootloader image, and about the generated images. Also don't use
mxs-usb-loader anymore since it has been removed.
Fixes: 3ca576cc4a4236a2556ab17 "scripts: imx/mxs remove mxs-usb-loader"
Signed-off-by: Roland Hieber <r.hieber@pengutronix.de>
---
Documentation/boards/mxs.rst | 97 ++++++++++++++++++++----------------
1 file changed, 53 insertions(+), 44 deletions(-)
diff --git a/Documentation/boards/mxs.rst b/Documentation/boards/mxs.rst
index feb024227a..739f9c40fb 100644
--- a/Documentation/boards/mxs.rst
+++ b/Documentation/boards/mxs.rst
@@ -3,71 +3,83 @@ Freescale MXS
Freescale i.MXs or MXS are a SoC family which consists of the i.MX23
and the i.MX28. These are quite different from the regular i.MX SoCs
-and thus are represented by their own architecture in both the Kernel
-and barebox.
+and thus are represented by their own architecture in both the kernel
+and in barebox.
Bootlets
--------
-Traditionally These SoCs need the Freescale bootlets source and the
-elf2sb2 binary to build a bootable image out of the barebox binary.
-Since the bootlets are board specific and the source code is only
-hardly customisable each vendor usually has his own slightly different
+Traditionally these SoCs need the Freescale bootlets source and the
+*elf2sb2* binary to set up the PMIC and SDRAM, and to build a bootable
+image out of the barebox binary.
+Since the bootlets are board-specific and the source code is only
+hardly customisable, each vendor usually has their own slightly different
version of the bootlets. Booting with the Freescale bootlets is not
-described here, refer to the bootlet sourcecode or your vendors
+described here, refer to the bootlet source code or your vendor's
documentation instead.
-U-Boot and barebox have a port of the bootlets integrated into their
-source. The barebox bootlet code is derived from the U-Boot bootlet
-code written by Marek Vasut.
+Barebox has a port of the bootlets integrated into its source, which is
+derived from the U-Boot bootlet code written by Marek Vasut.
-Currently only the Karo TX28 is supported by the barebox bootlets,
-but we recommend that this approach should be followed for new boards
-and existing boards should be ported over.
+All MXS boards in the barebox tree have been ported to use barebox bootlets and
+image generation, and we recommend this approach for new boards too.
Booting Freescale i.MXs
-----------------------
The Freescale MXS SoCs have a multi staged boot process which needs
different images composed out of different binaries. The ROM executes
-a so called bootstream which contains multiple executables. The first
-one is executed in SRAM and the purpose of this binary is to setup
-the internal PMIC and the SDRAM. The second image is usually the
-bootloader itself. In case of barebox the bootstream is composed
-out of the self extracting barebox image (pblx) and the prepare
-stage for setting up the SDRAM.
+a so called *bootstream* which can contain multiple executables.
+
+The first executable (the prepare stage) is only a small binary executed in
+SRAM, which has a limited size of 128 KB. Its purpose is to setup the internal
+PMIC and the SDRAM, and then jump back to the MXS ROM code, which then maps the
+second executable (the full bootloader) into SDRAM and executes it.
+In case of barebox, the bootstream (``*-bootstream.img``) is composed of the
+self extracting barebox image (``*.pblx``) and the prepare stage
+(``prep_*.pblb``). The file name of those images reflects the name of the
+respective entry points.
The bootstream image itself is useful for USB boot, but for booting from
SD cards or NAND a BCB header has to be prepended to the image. In case
-of SD boot the image has the .mxssd file extension in barebox.
+of SD boot the image is named ``*-sd.img``.
+
+Bootstream images can be unencrypted or encrypted. Depending on the OCOTP fuses
+of your chip, you might need the one or the other to boot the board.
-Since the bootstream images are encrypted they are not suitable for
-2nd stage execution. For this purpose the 2nd stage images are generated.
+Since some of the bootstream images are encrypted, they are not suitable for
+2nd stage execution. For this purpose a 2nd stage image with the name
+``*-2nd.img`` is generated.
Booting from USB
----------------
-barebox has the mxs-usb-loader tool (derived from the sbloader tool from
-the rockbox project). If the board is connected to the PC and started in
-USB Boot mode it should show up in lsusb::
+If enabled in *menuconfig* → *System Type*, barebox builds the *imx-usb-loader*
+tool (derived from the *sbloader* tool from the rockbox project), which can
+load images onto MXS SoCs over USB. (Refer to the documentation of your board
+how to get it into USB boot mode.)
+
+If the board is connected to the PC and started in USB boot mode, it should
+show up in lsusb::
Bus 001 Device 098: ID 15a2:004f Freescale Semiconductor, Inc. i.MX28 SystemOnChip in RecoveryMode
-The bootstream images can be directly booted with::
+The bootstream images can then directly be booted with::
- ./scripts/mxs-usb-loader 0 images/barebox-karo-tx28-bootstream.img
+ ./scripts/imx-usb-loader images/barebox-karo-tx28-bootstream.img
-You might require appropriate udev rules or sudo to gain the rights to
+You might require appropriate udev rules or *sudo* to gain the rights to
access the USB device.
Booting from SD cards
---------------------
-The SD images are suitable for booting from SD cards. SD cards need a special
-partitioning which can be created with the following fdisk sequence (using
-/dev/sdg as example)::
+The SD images are suitable for booting from SD cards. The MXS SoCs require a
+special partition of type 0x53 (OnTrack DM6 Aux) which contains the BCB header.
+The partitioning can be created with the following fdisk sequence (using
+*/dev/sdg* as an example for the SD card)::
- fdisk /dev/sdg
+ $ fdisk /dev/sdg
Welcome to fdisk (util-linux 2.25.1).
Changes will remain in memory only, until you decide to write them.
@@ -93,24 +105,21 @@ partitioning which can be created with the following fdisk sequence (using
Hex code (type L to list all codes): 53
Changed type of partition 'Linux' to 'OnTrack DM6 Aux3'.
- Command (m for help):
-
Command (m for help): w
-After writing the new partition table the image can be written directly to
-the partition::
+After writing the new partition table, the image can be written directly to
+the first partition::
cat images/barebox-karo-tx28-sd.img > /dev/sdg1
-** NOTE **
+.. note::
-The MXS SoCs require a special partition of type 0x53 (OnTrack DM6 Aux)
-which contains the BCB header. For some unknown reason the BCB header is
-inside a partition, but contains the sector number of the raw device from
-which the rest of the image is read. With standard settings booting from
-SD card only works if the partition containing the bootloader starts at
-sector 2048 (the standard for fdisk). See the -p parameter to the mxsboot
-tool which changes this sector number in the image.
+ For some unknown reason the BCB header is
+ inside a partition, but contains the sector number of the raw device from
+ which the rest of the image is read. With standard settings, booting from
+ SD card only works if the partition containing the bootloader starts at
+ sector 2048 (the standard for fdisk). See the *-p* parameter to the
+ ``scripts/mxsboot`` tool to change this sector number in the image.
Booting second stage
--------------------
--
2.18.0
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 18+ messages in thread
* Re: [PATCH 05/13] ARM: MXS: i.MX28: add autodetection of memory banks
2018-07-25 13:36 ` [PATCH 05/13] ARM: MXS: i.MX28: add autodetection of memory banks Roland Hieber
@ 2018-07-27 8:28 ` Roland Hieber
2018-07-31 10:07 ` Roland Hieber
1 sibling, 0 replies; 18+ messages in thread
From: Roland Hieber @ 2018-07-27 8:28 UTC (permalink / raw)
To: barebox
On Wed, Jul 25, 2018 at 03:36:10PM +0200, Roland Hieber wrote:
> If the prebootloader has set up the EMI controller correctly, we can
> autodetect the size of available RAM by looking at the respective
> configuration registers.
>
> Signed-off-by: Roland Hieber <r.hieber@pengutronix.de>
> ---
> arch/arm/mach-mxs/Makefile | 2 +-
> arch/arm/mach-mxs/mem-imx28.c | 39 +++++++++++++++++++++++++++++++++++
> 2 files changed, 40 insertions(+), 1 deletion(-)
> create mode 100644 arch/arm/mach-mxs/mem-imx28.c
>
> diff --git a/arch/arm/mach-mxs/Makefile b/arch/arm/mach-mxs/Makefile
> index e3843368c2..0761f909a1 100644
> --- a/arch/arm/mach-mxs/Makefile
> +++ b/arch/arm/mach-mxs/Makefile
> @@ -1,7 +1,7 @@
> obj-y += imx.o iomux-imx.o power.o
> pbl-y += iomux-imx.o
> obj-$(CONFIG_ARCH_IMX23) += clocksource-imx23.o usb-imx23.o soc-imx23.o
> -obj-$(CONFIG_ARCH_IMX28) += clocksource-imx28.o usb-imx28.o soc-imx28.o
> +obj-$(CONFIG_ARCH_IMX28) += clocksource-imx28.o usb-imx28.o soc-imx28.o mem-imx28.o
> obj-$(CONFIG_MXS_OCOTP) += ocotp.o
> obj-$(CONFIG_MXS_CMD_BCB) += bcb.o
> pbl-y += power-init.o mem-init.o lradc-init.o
> diff --git a/arch/arm/mach-mxs/mem-imx28.c b/arch/arm/mach-mxs/mem-imx28.c
> new file mode 100644
> index 0000000000..e827e0906f
> --- /dev/null
> +++ b/arch/arm/mach-mxs/mem-imx28.c
> @@ -0,0 +1,39 @@
> +/*
> + * Copyright (C) 2018 Pengutronix, Roland Hieber <r.hieber@pengutronix.de>
> + *
> + * This program is free software; you can redistribute it and/or
> + * modify it under the terms of the GNU General Public License
> + * version 2, as published by the Free Software Foundation.
> + *
> + * This program is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
> + * GNU General Public License for more details.
> + */
> +
> +#include <init.h>
> +#include <asm/memory.h>
> +#include <mach/imx28-regs.h>
> +#include <printk.h>
Mhm, there are some includes missing. Will fix in v2.
- Roland
> +
> +static int mx28_add_mem(void)
> +{
> + if (!of_machine_is_compatible("fsl,imx28"))
> + return 0;
> +
> + int * sdramc = (int *)IMX_SDRAMC_BASE;
> +
> + uint8_t columns = 12 - ((sdramc[29] >> 16) & 0b111);
> + uint8_t rows = 15 - ((sdramc[29] >> 8) & 0b111);
> + uint8_t banks = ((sdramc[31] >> 16) & 0b1) ? 8 : 4;
> + uint8_t width = sizeof (unsigned short);
> +
> + uint32_t size = (1 << columns) * (1 << rows) * banks * width;
> + pr_info("i.MX28: detected %d cols, %d rows, %d banks = %d MiB of RAM\n",
> + columns, rows, banks, size / 1024 / 1024);
> +
> + arm_add_mem_device("ram0", IMX_MEMORY_BASE, size);
> +
> + return 0;
> +}
> +mem_initcall(mx28_add_mem);
> --
> 2.18.0
>
>
> _______________________________________________
> barebox mailing list
> barebox@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/barebox
>
--
Roland Hieber | r.hieber@pengutronix.de |
Pengutronix e.K. | https://www.pengutronix.de/ |
Peiner Str. 6-8, 31137 Hildesheim | Phone: +49-5121-206917-5086 |
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] 18+ messages in thread
* Re: [PATCH 05/13] ARM: MXS: i.MX28: add autodetection of memory banks
2018-07-25 13:36 ` [PATCH 05/13] ARM: MXS: i.MX28: add autodetection of memory banks Roland Hieber
2018-07-27 8:28 ` Roland Hieber
@ 2018-07-31 10:07 ` Roland Hieber
2018-08-08 6:40 ` Sascha Hauer
1 sibling, 1 reply; 18+ messages in thread
From: Roland Hieber @ 2018-07-31 10:07 UTC (permalink / raw)
To: Sascha Hauer; +Cc: barebox
Sascha,
while looking for something different, I noticed the following patches
in one of your personal branches:
b2f6eeb Sascha Hauer ● ARM: i.MX28: Add memory size detection
eb607ae Sascha Hauer ● ARM: i.MX23: Add memory size detection
They look much cleaner than my patch, so if you consent, I'll include
them in the v2 series instead of this one.
- Roland
On Wed, Jul 25, 2018 at 03:36:10PM +0200, Roland Hieber wrote:
> If the prebootloader has set up the EMI controller correctly, we can
> autodetect the size of available RAM by looking at the respective
> configuration registers.
>
> Signed-off-by: Roland Hieber <r.hieber@pengutronix.de>
> ---
> arch/arm/mach-mxs/Makefile | 2 +-
> arch/arm/mach-mxs/mem-imx28.c | 39 +++++++++++++++++++++++++++++++++++
> 2 files changed, 40 insertions(+), 1 deletion(-)
> create mode 100644 arch/arm/mach-mxs/mem-imx28.c
>
> diff --git a/arch/arm/mach-mxs/Makefile b/arch/arm/mach-mxs/Makefile
> index e3843368c2..0761f909a1 100644
> --- a/arch/arm/mach-mxs/Makefile
> +++ b/arch/arm/mach-mxs/Makefile
> @@ -1,7 +1,7 @@
> obj-y += imx.o iomux-imx.o power.o
> pbl-y += iomux-imx.o
> obj-$(CONFIG_ARCH_IMX23) += clocksource-imx23.o usb-imx23.o soc-imx23.o
> -obj-$(CONFIG_ARCH_IMX28) += clocksource-imx28.o usb-imx28.o soc-imx28.o
> +obj-$(CONFIG_ARCH_IMX28) += clocksource-imx28.o usb-imx28.o soc-imx28.o mem-imx28.o
> obj-$(CONFIG_MXS_OCOTP) += ocotp.o
> obj-$(CONFIG_MXS_CMD_BCB) += bcb.o
> pbl-y += power-init.o mem-init.o lradc-init.o
> diff --git a/arch/arm/mach-mxs/mem-imx28.c b/arch/arm/mach-mxs/mem-imx28.c
> new file mode 100644
> index 0000000000..e827e0906f
> --- /dev/null
> +++ b/arch/arm/mach-mxs/mem-imx28.c
> @@ -0,0 +1,39 @@
> +/*
> + * Copyright (C) 2018 Pengutronix, Roland Hieber <r.hieber@pengutronix.de>
> + *
> + * This program is free software; you can redistribute it and/or
> + * modify it under the terms of the GNU General Public License
> + * version 2, as published by the Free Software Foundation.
> + *
> + * This program is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
> + * GNU General Public License for more details.
> + */
> +
> +#include <init.h>
> +#include <asm/memory.h>
> +#include <mach/imx28-regs.h>
> +#include <printk.h>
> +
> +static int mx28_add_mem(void)
> +{
> + if (!of_machine_is_compatible("fsl,imx28"))
> + return 0;
> +
> + int * sdramc = (int *)IMX_SDRAMC_BASE;
> +
> + uint8_t columns = 12 - ((sdramc[29] >> 16) & 0b111);
> + uint8_t rows = 15 - ((sdramc[29] >> 8) & 0b111);
> + uint8_t banks = ((sdramc[31] >> 16) & 0b1) ? 8 : 4;
> + uint8_t width = sizeof (unsigned short);
> +
> + uint32_t size = (1 << columns) * (1 << rows) * banks * width;
> + pr_info("i.MX28: detected %d cols, %d rows, %d banks = %d MiB of RAM\n",
> + columns, rows, banks, size / 1024 / 1024);
> +
> + arm_add_mem_device("ram0", IMX_MEMORY_BASE, size);
> +
> + return 0;
> +}
> +mem_initcall(mx28_add_mem);
> --
> 2.18.0
>
>
> _______________________________________________
> barebox mailing list
> barebox@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/barebox
>
--
Roland Hieber | r.hieber@pengutronix.de |
Pengutronix e.K. | https://www.pengutronix.de/ |
Peiner Str. 6-8, 31137 Hildesheim | Phone: +49-5121-206917-5086 |
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] 18+ messages in thread
* Re: [PATCH 05/13] ARM: MXS: i.MX28: add autodetection of memory banks
2018-07-31 10:07 ` Roland Hieber
@ 2018-08-08 6:40 ` Sascha Hauer
0 siblings, 0 replies; 18+ messages in thread
From: Sascha Hauer @ 2018-08-08 6:40 UTC (permalink / raw)
To: Roland Hieber; +Cc: barebox
On Tue, Jul 31, 2018 at 12:07:16PM +0200, Roland Hieber wrote:
> Sascha,
>
> while looking for something different, I noticed the following patches
> in one of your personal branches:
>
> b2f6eeb Sascha Hauer ● ARM: i.MX28: Add memory size detection
> eb607ae Sascha Hauer ● ARM: i.MX23: Add memory size detection
>
> They look much cleaner than my patch, so if you consent, I'll include
> them in the v2 series instead of this one.
Yes, please do so.
Sascha
--
Pengutronix e.K. | |
Industrial Linux Solutions | http://www.pengutronix.de/ |
Peiner Str. 6-8, 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] 18+ messages in thread
* Re: [PATCH 04/13] ARM: MXS: allow configuration of EMI clock dividers
2018-07-25 13:36 ` [PATCH 04/13] ARM: MXS: allow configuration of EMI clock dividers Roland Hieber
@ 2018-08-08 6:41 ` Sascha Hauer
0 siblings, 0 replies; 18+ messages in thread
From: Sascha Hauer @ 2018-08-08 6:41 UTC (permalink / raw)
To: Roland Hieber; +Cc: barebox
On Wed, Jul 25, 2018 at 03:36:09PM +0200, Roland Hieber wrote:
> For now, the clock dividers are only accessible from mx28_mem_init, and
> the old prescaler of 2 is hardcoded in mx23_mem_init. I'm not sure
> if it makes sense to change it at all.
>
> Signed-off-by: Roland Hieber <r.hieber@pengutronix.de>
> ---
> arch/arm/boards/duckbill/lowlevel.c | 2 ++
> arch/arm/boards/freescale-mx28-evk/lowlevel.c | 2 ++
> arch/arm/boards/karo-tx28/lowlevel.c | 2 ++
> arch/arm/mach-mxs/include/mach/init.h | 6 +++---
> arch/arm/mach-mxs/mem-init.c | 16 ++++++++--------
> 5 files changed, 17 insertions(+), 11 deletions(-)
>
> diff --git a/arch/arm/boards/duckbill/lowlevel.c b/arch/arm/boards/duckbill/lowlevel.c
> index 3adda68d77..393d4e1e12 100644
> --- a/arch/arm/boards/duckbill/lowlevel.c
> +++ b/arch/arm/boards/duckbill/lowlevel.c
> @@ -56,6 +56,8 @@ static noinline void duckbill_init(void)
> pr_debug("initializing SDRAM...\n");
>
> mx28_mem_init(PINCTRL_EMI_DS_CTRL_DDR_MODE_DDR2,
> + /* EMI_CLK of 480 / 2 * (18/21) = 205.7 MHz */
> + 2, 21,
> mx28_dram_vals_default);
Instead of adding more parameters to mx28_mem_init() I slighty prefer to
require the boards to call mxs_mem_init_clock() directly instead and
remove it from mx28_mem_init().
Sascha
--
Pengutronix e.K. | |
Industrial Linux Solutions | http://www.pengutronix.de/ |
Peiner Str. 6-8, 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] 18+ messages in thread
end of thread, other threads:[~2018-08-08 6:42 UTC | newest]
Thread overview: 18+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-07-25 13:36 [PATCH 00/13] MXS/MX28 low-level improvements Roland Hieber
2018-07-25 13:36 ` [PATCH 01/13] scripts: mxsimage: Allow unencrypted images Roland Hieber
2018-07-25 13:36 ` [PATCH 02/13] images: MXS: allow generation of unencrypted bootstreams Roland Hieber
2018-07-25 13:36 ` [PATCH 03/13] ARM: MXS: i.MX28: allow setup of low-voltage SDRAM Roland Hieber
2018-07-25 13:36 ` [PATCH 04/13] ARM: MXS: allow configuration of EMI clock dividers Roland Hieber
2018-08-08 6:41 ` Sascha Hauer
2018-07-25 13:36 ` [PATCH 05/13] ARM: MXS: i.MX28: add autodetection of memory banks Roland Hieber
2018-07-27 8:28 ` Roland Hieber
2018-07-31 10:07 ` Roland Hieber
2018-08-08 6:40 ` Sascha Hauer
2018-07-25 13:36 ` [PATCH 06/13] ARM: MXS: refactor mx2*_power_init source configuration Roland Hieber
2018-07-25 13:36 ` [PATCH 07/13] ARM: MXS: allow starting from battery input without 4P2 source enabled Roland Hieber
2018-07-25 13:36 ` [PATCH 08/13] ARM: MXS: make power levels configurable in mx2*_power_init Roland Hieber
2018-07-25 13:36 ` [PATCH 09/13] ARM: MXS: fix VDDx brownout setup logic Roland Hieber
2018-07-25 13:36 ` [PATCH 10/13] ARM: MXS: make VDDx brownout setup more understandable Roland Hieber
2018-07-25 13:36 ` [PATCH 11/13] ARM: MXS: mxs_power_status: use less magic values Roland Hieber
2018-07-25 13:36 ` [PATCH 12/13] ARM: MXS: mxs_power_status: align output Roland Hieber
2018-07-25 13:36 ` [PATCH 13/13] Documentation: MXS: general update and improvements Roland Hieber
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox