From ff312be32a68e51df173b913aa257f60220a3eda Mon Sep 17 00:00:00 2001 From: Lucas Stach Date: Thu, 16 Nov 2017 22:19:46 +0100 Subject: clk: sp810: hardwire parent to 1MHz clock This works around a limitation in our handling of the vexpress config bus. For now just hardcode the clock parent to the 1MHz clock, which is the default as emulated by QEMU and also the setting the Linux kernel will configure later. This fixes the vexpress clocksource running at a wrong rate leading to bogus delays and sleep times. Signed-off-by: Lucas Stach Signed-off-by: Sascha Hauer --- drivers/clk/vexpress/clk-sp810.c | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/drivers/clk/vexpress/clk-sp810.c b/drivers/clk/vexpress/clk-sp810.c index af72c74024..959661e19e 100644 --- a/drivers/clk/vexpress/clk-sp810.c +++ b/drivers/clk/vexpress/clk-sp810.c @@ -44,10 +44,7 @@ struct clk_sp810 { static int clk_sp810_timerclken_get_parent(struct clk *hw) { - struct clk_sp810_timerclken *timerclken = to_clk_sp810_timerclken(hw); - u32 val = readl(timerclken->sp810->base + SCCTRL); - - return !!(val & (1 << SCCTRL_TIMERENnSEL_SHIFT(timerclken->channel))); + return 1; } static int clk_sp810_timerclken_set_parent(struct clk *hw, u8 index) @@ -59,6 +56,9 @@ static int clk_sp810_timerclken_set_parent(struct clk *hw, u8 index) if (WARN_ON(index > 1)) return -EINVAL; + if (index == 0) + return -EINVAL; + val = readl(sp810->base + SCCTRL); val &= ~(1 << shift); val |= index << shift; @@ -92,7 +92,6 @@ static void clk_sp810_of_setup(struct device_node *node) char name[12]; static int instance; int i; - bool deprecated; if (!sp810) return; @@ -106,8 +105,6 @@ static void clk_sp810_of_setup(struct device_node *node) sp810->node = node; sp810->base = of_iomap(node, 0); - deprecated = !of_find_property(node, "assigned-clock-parents", NULL); - for (i = 0; i < ARRAY_SIZE(sp810->timerclken); i++) { snprintf(name, sizeof(name), "sp810_%d_%d", instance, i); @@ -119,13 +116,10 @@ static void clk_sp810_of_setup(struct device_node *node) sp810->timerclken[i].hw.ops = &clk_sp810_timerclken_ops; /* - * If DT isn't setting the parent, force it to be - * the 1 MHz clock without going through the framework. - * We do this before clk_register() so that it can determine - * the parent and setup the tree properly. + * Always set parent to 1MHz clock to match QEMU emulation + * and satisfy requirements on real HW. */ - if (deprecated) - clk_sp810_timerclken_set_parent(&sp810->timerclken[i].hw, 1); + clk_sp810_timerclken_set_parent(&sp810->timerclken[i].hw, 1); clk_register(&sp810->timerclken[i].hw); } -- cgit v1.2.3 From 30caa3917de8ecfd45f6b12aa4ffe00966f2e250 Mon Sep 17 00:00:00 2001 From: Gaël PORTAY Date: Thu, 16 Nov 2017 23:58:14 -0500 Subject: readline_simple: use len instead of CONFIG_CBSIZE MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit It is safier to use the length given in parameter instead of using the preprocessor CONFIG_CBSIZE value. Signed-off-by: Gaël PORTAY Signed-off-by: Sascha Hauer --- lib/readline_simple.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/readline_simple.c b/lib/readline_simple.c index 80e075bc5c..fcdbca41a9 100644 --- a/lib/readline_simple.c +++ b/lib/readline_simple.c @@ -100,7 +100,7 @@ int readline (const char *prompt, char *line, int len) /* * Must be a normal character then */ - if (n < CONFIG_CBSIZE-2) { + if (n < len-2) { if (c == '\t') { /* expand TABs */ puts (tab_seq+(col&07)); col += 8 - (col&07); -- cgit v1.2.3 From 1c2c4246a9914bfdf234c6c636abcd27d9d3975c Mon Sep 17 00:00:00 2001 From: Sascha Hauer Date: Thu, 23 Nov 2017 12:02:59 +0100 Subject: globalvar: When a globalvar is created with a NULL value, use empty string As a convenience for users of globalvar_add_simple_string() create an empty value for the variable when passed a NULL pointer as value. Signed-off-by: Sascha Hauer --- common/globalvar.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/common/globalvar.c b/common/globalvar.c index ee756e5140..1db6bd9a41 100644 --- a/common/globalvar.c +++ b/common/globalvar.c @@ -459,6 +459,9 @@ int globalvar_add_simple_string(const char *name, char **value) globalvar_nv_sync(name); + if (!*value) + *value = xstrdup(""); + return 0; } -- cgit v1.2.3 From 834527a5f9bfa378647f1602a41742a01b5a1b18 Mon Sep 17 00:00:00 2001 From: Sascha Hauer Date: Thu, 23 Nov 2017 11:59:46 +0100 Subject: nv: add device parameter overwrites to completion list nv variables in the form dev..* can be used to make device parameters persistent. Add these to the completion list to make setting these variables more convenient. Signed-off-by: Sascha Hauer --- commands/global.c | 2 +- commands/nv.c | 2 +- common/globalvar.c | 33 +++++++++++++++++++++++++++++++-- include/globalvar.h | 3 ++- 4 files changed, 35 insertions(+), 5 deletions(-) diff --git a/commands/global.c b/commands/global.c index fc687169a7..c66bf6e539 100644 --- a/commands/global.c +++ b/commands/global.c @@ -78,5 +78,5 @@ BAREBOX_CMD_START(global) BAREBOX_CMD_OPTS("[-r] VAR[=VALUE] ...") BAREBOX_CMD_GROUP(CMD_GRP_ENV) BAREBOX_CMD_HELP(cmd_global_help) - BAREBOX_CMD_COMPLETE(nv_global_complete) + BAREBOX_CMD_COMPLETE(global_complete) BAREBOX_CMD_END diff --git a/commands/nv.c b/commands/nv.c index 51b855ee4b..01c25a108f 100644 --- a/commands/nv.c +++ b/commands/nv.c @@ -104,5 +104,5 @@ BAREBOX_CMD_START(nv) BAREBOX_CMD_OPTS("[-r] VAR[=VALUE] ...") BAREBOX_CMD_GROUP(CMD_GRP_ENV) BAREBOX_CMD_HELP(cmd_nv_help) - BAREBOX_CMD_COMPLETE(nv_global_complete) + BAREBOX_CMD_COMPLETE(nv_complete) BAREBOX_CMD_END diff --git a/common/globalvar.c b/common/globalvar.c index 1db6bd9a41..29d158e3fb 100644 --- a/common/globalvar.c +++ b/common/globalvar.c @@ -645,10 +645,39 @@ static int nv_global_param_complete(struct device_d *dev, struct string_list *sl return 0; } -int nv_global_complete(struct string_list *sl, char *instr) +int nv_complete(struct string_list *sl, char *instr) +{ + struct device_d *dev; + struct param_d *param; + char *str; + int len; + + nv_global_param_complete(&global_device, sl, instr, 0); + + len = strlen(instr); + + if (strncmp(instr, "dev.", min_t(int, len, 4))) + return 0; + + for_each_device(dev) { + if (dev == &global_device || dev == &nv_device) + continue; + + list_for_each_entry(param, &dev->parameters, list) { + str = basprintf("dev.%s.%s=", dev_name(dev), param->name); + if (strncmp(instr, str, len)) + free(str); + else + string_list_add(sl, str); + } + } + + return 0; +} + +int global_complete(struct string_list *sl, char *instr) { nv_global_param_complete(&global_device, sl, instr, 0); - nv_global_param_complete(&nv_device, sl, instr, 0); return 0; } diff --git a/include/globalvar.h b/include/globalvar.h index df43f1fe66..67391e2042 100644 --- a/include/globalvar.h +++ b/include/globalvar.h @@ -117,6 +117,7 @@ static inline void dev_param_init_from_nv(struct device_d *dev, const char *name void nv_var_set_clean(void); int nvvar_save(void); -int nv_global_complete(struct string_list *sl, char *instr); +int nv_complete(struct string_list *sl, char *instr); +int global_complete(struct string_list *sl, char *instr); #endif /* __GLOBALVAR_H */ -- cgit v1.2.3 From d49bdc8316bcb39630330307c601d7885e9f3560 Mon Sep 17 00:00:00 2001 From: Sascha Hauer Date: Fri, 24 Nov 2017 08:22:13 +0100 Subject: nvvar: Initialze from underlying device parameter When a nvvar is added with a NULL parameter then it's initialized with the value of the underlying global variable. Do this aswell when the nvvar is a device parameter. Signed-off-by: Sascha Hauer --- common/globalvar.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/common/globalvar.c b/common/globalvar.c index 29d158e3fb..9e98f633ef 100644 --- a/common/globalvar.c +++ b/common/globalvar.c @@ -199,6 +199,8 @@ static int nv_param_set(struct device_d *dev, struct param_d *p, const char *val static int __nvvar_add(const char *name, const char *value) { struct param_d *p; + struct device_d *dev = NULL; + const char *pname; int ret; if (!IS_ENABLED(CONFIG_NVVAR)) @@ -220,7 +222,12 @@ static int __nvvar_add(const char *name, const char *value) if (value) return nv_set(&nv_device, p, value); - value = dev_get_param(&global_device, name); + ret = nvvar_device_dispatch(name, &dev, &pname); + if (ret > 0) + value = dev_get_param(dev, pname); + else + value = dev_get_param(&global_device, name); + if (value) { free(p->value); p->value = xstrdup(value); -- cgit v1.2.3 From 35b1c10084a1c0e64080c9d6868d73b19e5dce74 Mon Sep 17 00:00:00 2001 From: Ulrich Ölmann Date: Fri, 24 Nov 2017 09:50:37 +0100 Subject: Documentation: devicetree: m25p80: fix referenced filename MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Linux changed the filename in commit 8947e396a829 ("Documentation: dt: mtd: replace "nor-jedec" binding with "jedec, spi-nor"") and barebox imported this change in commit 8ed978b79062 ("dts: update to v4.1-rc4"). Signed-off-by: Ulrich Ölmann Signed-off-by: Sascha Hauer --- Documentation/devicetree/bindings/mtd/m25p80.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Documentation/devicetree/bindings/mtd/m25p80.rst b/Documentation/devicetree/bindings/mtd/m25p80.rst index d7c8914ec5..09e8b8eff6 100644 --- a/Documentation/devicetree/bindings/mtd/m25p80.rst +++ b/Documentation/devicetree/bindings/mtd/m25p80.rst @@ -1,7 +1,7 @@ MTD SPI driver for ST M25Pxx (and similar) serial flash chips ============================================================= -Additionally to the Linux bindings in ``dts/Bindings/mtd/m25p80.txt`` +Additionally to the Linux bindings in ``dts/Bindings/mtd/jedec,spi-nor.txt`` the barebox driver has the following optional properties: - use-large-blocks : Use large blocks rather than the 4K blocks some devices -- cgit v1.2.3 From ab8a0debc6c42ef1f8fa57e5bdf7096a0a4b8f52 Mon Sep 17 00:00:00 2001 From: Ulrich Ölmann Date: Fri, 24 Nov 2017 15:42:51 +0100 Subject: mtd: spi-nor: mx25l3205d/mx25l6405d: append SECT_4K MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This is a port of Linux kernel commit | commit 0501f2e5ff28a02295e42fc9e7164a20ef4c30d5 | Author: Andreas Fenkart | Date: Thu Nov 5 10:04:23 2015 +0100 | | mtd: spi-nor: mx25l3205d/mx25l6405d: append SECT_4K | | according datasheet both chips can erase 4kByte sectors individually | | Signed-off-by: Andreas Fenkart | Signed-off-by: Brian Norris Signed-off-by: Ulrich Ölmann Signed-off-by: Sascha Hauer --- drivers/mtd/spi-nor/spi-nor.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/mtd/spi-nor/spi-nor.c b/drivers/mtd/spi-nor/spi-nor.c index fb13cd1269..5cf650c0e2 100644 --- a/drivers/mtd/spi-nor/spi-nor.c +++ b/drivers/mtd/spi-nor/spi-nor.c @@ -524,9 +524,9 @@ static const struct spi_device_id spi_nor_ids[] = { { "mx25l4005a", INFO(0xc22013, 0, 64 * 1024, 8, SECT_4K) }, { "mx25l8005", INFO(0xc22014, 0, 64 * 1024, 16, 0) }, { "mx25l1606e", INFO(0xc22015, 0, 64 * 1024, 32, SECT_4K) }, - { "mx25l3205d", INFO(0xc22016, 0, 64 * 1024, 64, 0) }, + { "mx25l3205d", INFO(0xc22016, 0, 64 * 1024, 64, SECT_4K) }, { "mx25l3255e", INFO(0xc29e16, 0, 64 * 1024, 64, SECT_4K) }, - { "mx25l6405d", INFO(0xc22017, 0, 64 * 1024, 128, 0) }, + { "mx25l6405d", INFO(0xc22017, 0, 64 * 1024, 128, SECT_4K) }, { "mx25u2033e", INFO(0xc22532, 0, 64 * 1024, 4, SECT_4K) }, { "mx25u4035", INFO(0xc22533, 0, 64 * 1024, 8, SECT_4K) }, { "mx25u8035", INFO(0xc22534, 0, 64 * 1024, 16, SECT_4K) }, -- cgit v1.2.3 From 7518e1c47765bb66ee854acb97bd285e9320df36 Mon Sep 17 00:00:00 2001 From: Sascha Hauer Date: Mon, 11 Dec 2017 15:49:00 +0100 Subject: Documentation: state: mention SD/eMMC devices The state framework also has support for SD/eMMC devices, so mention them in the documentation. Signed-off-by: Sascha Hauer --- Documentation/user/state.rst | 46 ++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 44 insertions(+), 2 deletions(-) diff --git a/Documentation/user/state.rst b/Documentation/user/state.rst index 7d6c5770d5..d17f39befb 100644 --- a/Documentation/user/state.rst +++ b/Documentation/user/state.rst @@ -39,8 +39,8 @@ Backends (e.g. Supported Memory Types) Some non-volatile memory is need for storing a *state* variable set: -- all kinds of NOR flash memories -- all kinds of NAND flash memories +- Disk like devices: SD, (e)MMC, ATA +- all kinds of NAND and NOR flash memories (mtd) - MRAM - EEPROM - all kind of SRAMs (backup battery assumed) @@ -531,6 +531,48 @@ content, its backend-type and *state* variable layout. }; }; +SD/eMMC and ATA +############### + +The following devicetree node entry defines some kind of SD/eMMC memory and +a partition at a specific offset inside it to be used as the backend for the +*state* variable set. Note that currently there is no support for on-disk +partition tables. Instead, a ofpart partition description must be used. You +have to make sure that this partition does not conflict with any other partition +in the partition table. + +.. code-block:: text + + backend_state_sd: part@100000 { + label = "state"; + reg = <0x100000 0x20000>; + }; + +With this 'backend' definition its possible to define the *state* variable set +content, its backend-type and *state* variable layout. + +.. code-block:: text + + aliases { + state = &state_sd; + }; + + state_sd: state_memory { + #address-cells = <1>; + #size-cells = <1>; + compatible = "barebox,state"; + magic = <0xab67421f>; + backend-type = "raw"; + backend = <&backend_state_sd>; + backend-stridesize = <0x40>; + + variable { + reg = <0x0 0x1>; + type ="uint8"; + default = <0x1>; + }; + }; + SRAM #### -- cgit v1.2.3