diff options
author | Sascha Hauer <s.hauer@pengutronix.de> | 2018-01-05 12:08:20 +0100 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2018-01-05 12:08:20 +0100 |
commit | 052d1c9e0756db2b02da98c97a6c50d26b8c28ce (patch) | |
tree | cd9c072425c9e333e4be744d47aab96fed2cd430 | |
parent | e2d5e447e6b5035f9e78a29037d15f7fd9606918 (diff) | |
parent | 7518e1c47765bb66ee854acb97bd285e9320df36 (diff) | |
download | barebox-052d1c9e0756db2b02da98c97a6c50d26b8c28ce.tar.gz barebox-052d1c9e0756db2b02da98c97a6c50d26b8c28ce.tar.xz |
Merge branch 'for-next/misc'
-rw-r--r-- | Documentation/devicetree/bindings/mtd/m25p80.rst | 2 | ||||
-rw-r--r-- | Documentation/user/state.rst | 46 | ||||
-rw-r--r-- | commands/global.c | 2 | ||||
-rw-r--r-- | commands/nv.c | 2 | ||||
-rw-r--r-- | common/globalvar.c | 45 | ||||
-rw-r--r-- | drivers/clk/vexpress/clk-sp810.c | 20 | ||||
-rw-r--r-- | drivers/mtd/spi-nor/spi-nor.c | 4 | ||||
-rw-r--r-- | include/globalvar.h | 3 | ||||
-rw-r--r-- | lib/readline_simple.c | 2 |
9 files changed, 101 insertions, 25 deletions
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 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 #### 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 77b89c1791..1471d849ec 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); @@ -460,6 +467,9 @@ int globalvar_add_simple_string(const char *name, char **value) globalvar_nv_sync(name); + if (!*value) + *value = xstrdup(""); + return 0; } @@ -643,10 +653,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/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); } 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) }, 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 */ 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); |