From 3be2270718aa7fdab48e3585a23a4436075fc039 Mon Sep 17 00:00:00 2001 From: Antony Pavlov Date: Tue, 11 Oct 2016 12:06:11 +0300 Subject: [PATCH 01/13] sandbox: drop unused header files Signed-off-by: Antony Pavlov Signed-off-by: Sascha Hauer --- arch/sandbox/include/asm/processor.h | 25 ------------------------- arch/sandbox/include/asm/ptrace.h | 1 - 2 files changed, 26 deletions(-) delete mode 100644 arch/sandbox/include/asm/processor.h delete mode 100644 arch/sandbox/include/asm/ptrace.h diff --git a/arch/sandbox/include/asm/processor.h b/arch/sandbox/include/asm/processor.h deleted file mode 100644 index 075ec74da..000000000 --- a/arch/sandbox/include/asm/processor.h +++ /dev/null @@ -1,25 +0,0 @@ -/* - * (C) Copyright 2002 - * Daniel Engström, Omicron Ceti AB, daniel@omicron.se - * - * See file CREDITS for list of people who contributed to this - * project. - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of - * the License, or (at your option) any later version. - * - * 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. - * - */ - -#ifndef __ASM_PROCESSOR_H_ -#define __ASM_PROCESSOR_H_ 1 -/* Currently this header is unused in the i386 port - * but some generic files #include - * so this file is a placeholder. */ -#endif diff --git a/arch/sandbox/include/asm/ptrace.h b/arch/sandbox/include/asm/ptrace.h deleted file mode 100644 index 2997587d8..000000000 --- a/arch/sandbox/include/asm/ptrace.h +++ /dev/null @@ -1 +0,0 @@ -/* dummy */ From 655b16187dd9e273112ebb4ba0ea40b255f2e4aa Mon Sep 17 00:00:00 2001 From: Yegor Yefremov Date: Wed, 12 Oct 2016 07:52:22 +0200 Subject: [PATCH 02/13] ubi: fix spelling Signed-off-by: Yegor Yefremov Signed-off-by: Sascha Hauer --- drivers/mtd/ubi/build.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/mtd/ubi/build.c b/drivers/mtd/ubi/build.c index 617c63e5a..16e5a2c91 100644 --- a/drivers/mtd/ubi/build.c +++ b/drivers/mtd/ubi/build.c @@ -492,13 +492,13 @@ static int autoresize(struct ubi_device *ubi, int vol_id) * @vid_hdr_offset: VID header offset * @max_beb_per1024: maximum expected number of bad PEB per 1024 PEBs * - * This function attaches MTD device @mtd_dev to UBI and assign @ubi_num number + * This function attaches MTD device @mtd_dev to UBI and assigns @ubi_num number * to the newly created UBI device, unless @ubi_num is %UBI_DEV_NUM_AUTO, in * which case this function finds a vacant device number and assigns it * automatically. Returns the new UBI device number in case of success and a * negative error code in case of failure. * - * Note, the invocations of this function has to be serialized by the + * Note, the invocation of this function has to be serialized by the * @ubi_devices_mutex. */ int ubi_attach_mtd_dev(struct mtd_info *mtd, int ubi_num, @@ -697,7 +697,7 @@ out_free: * UBI device is busy and cannot be destroyed, and %-EINVAL if it does not * exist. * - * Note, the invocations of this function has to be serialized by the + * Note, the invocation of this function has to be serialized by the * @ubi_devices_mutex. */ int ubi_detach_mtd_dev(int ubi_num, int anyway) From 9c4e30e4458d9d4ae3d4cc9c7b70ced27b43814a Mon Sep 17 00:00:00 2001 From: Antony Pavlov Date: Mon, 17 Oct 2016 14:57:58 +0300 Subject: [PATCH 03/13] of: fix typos Signed-off-by: Antony Pavlov Signed-off-by: Sascha Hauer --- drivers/of/base.c | 2 +- drivers/of/fdt.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/of/base.c b/drivers/of/base.c index 1e6c33dbf..767d4e1e3 100644 --- a/drivers/of/base.c +++ b/drivers/of/base.c @@ -1631,7 +1631,7 @@ struct device_node *of_get_next_available_child(const struct device_node *node, EXPORT_SYMBOL(of_get_next_available_child); /** - * of_get_next_child - Iterate a node childs + * of_get_next_child - Iterate a node children * @node: parent node * @prev: previous child of the parent node, or NULL to get first * diff --git a/drivers/of/fdt.c b/drivers/of/fdt.c index b2253aa7a..614e136de 100644 --- a/drivers/of/fdt.c +++ b/drivers/of/fdt.c @@ -525,7 +525,7 @@ void of_clean_reserve_map(void) * fdt_add_reserve_map - Add reserve map entries to a devicetree binary * @__fdt: The devicetree blob * - * This adds the reservemap entries previously colllected in + * This adds the reservemap entries previously collected in * of_add_reserve_entry() to a devicetree binary blob. This also * adds the devicetree itself to the reserved list, so after calling * this function the tree should not be relocated anymore. From 57aac5f1ff63b4997d3dc665c4c05f5470a1e681 Mon Sep 17 00:00:00 2001 From: Sascha Hauer Date: Tue, 18 Oct 2016 14:34:02 +0200 Subject: [PATCH 04/13] linux/list.h: Add missing include linux/list.h needs linux/kernel.h for container_of(). Add it. Signed-off-by: Sascha Hauer --- include/linux/list.h | 1 + 1 file changed, 1 insertion(+) diff --git a/include/linux/list.h b/include/linux/list.h index bc63ece95..af5edc9a7 100644 --- a/include/linux/list.h +++ b/include/linux/list.h @@ -2,6 +2,7 @@ #define _LINUX_LIST_H #include /* for NULL */ +#include /* * Simple doubly linked list implementation. From eca7871bced78837154ad52c42864ba3c87a9904 Mon Sep 17 00:00:00 2001 From: Sascha Hauer Date: Tue, 18 Oct 2016 14:36:49 +0200 Subject: [PATCH 05/13] complete: Add completion for nv and globalvar commands The 'nv' command is often used to create a nv variable for an existing global variable, so add a command completion function for this. Signed-off-by: Sascha Hauer --- commands/global.c | 2 ++ commands/nv.c | 2 ++ common/globalvar.c | 28 ++++++++++++++++++++++++++++ include/globalvar.h | 2 ++ 4 files changed, 34 insertions(+) diff --git a/commands/global.c b/commands/global.c index d21b82951..fc687169a 100644 --- a/commands/global.c +++ b/commands/global.c @@ -22,6 +22,7 @@ #include #include #include +#include static int do_global(int argc, char *argv[]) { @@ -77,4 +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_END diff --git a/commands/nv.c b/commands/nv.c index a1fb095a1..37cdb9664 100644 --- a/commands/nv.c +++ b/commands/nv.c @@ -22,6 +22,7 @@ #include #include #include +#include static int do_nv(int argc, char *argv[]) { @@ -90,4 +91,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_END diff --git a/common/globalvar.c b/common/globalvar.c index fb69db973..e75cac96d 100644 --- a/common/globalvar.c +++ b/common/globalvar.c @@ -626,3 +626,31 @@ static void nv_exit(void) nvvar_save(); } predevshutdown_exitcall(nv_exit); + +static int nv_global_param_complete(struct device_d *dev, struct string_list *sl, + char *instr, int eval) +{ + struct param_d *param; + int len; + + len = strlen(instr); + + list_for_each_entry(param, &dev->parameters, list) { + if (strncmp(instr, param->name, len)) + continue; + + string_list_add_asprintf(sl, "%s%c", + param->name, + eval ? ' ' : '='); + } + + return 0; +} + +int nv_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 2a5d8a1a1..ecd9f1d18 100644 --- a/include/globalvar.h +++ b/include/globalvar.h @@ -4,6 +4,7 @@ #include #include #include +#include extern struct device_d global_device; @@ -123,5 +124,6 @@ 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); #endif /* __GLOBALVAR_H */ From 0e1b3c4a15f75ec8a10fc205981707ef00cbd132 Mon Sep 17 00:00:00 2001 From: Antony Pavlov Date: Wed, 19 Oct 2016 11:44:37 +0300 Subject: [PATCH 06/13] sandbox: eliminate sdl_init() Signed-off-by: Antony Pavlov Signed-off-by: Sascha Hauer --- arch/sandbox/mach-sandbox/include/mach/linux.h | 1 - arch/sandbox/os/sdl.c | 7 +------ 2 files changed, 1 insertion(+), 7 deletions(-) diff --git a/arch/sandbox/mach-sandbox/include/mach/linux.h b/arch/sandbox/mach-sandbox/include/mach/linux.h index 1e53f69ad..1f11ed449 100644 --- a/arch/sandbox/mach-sandbox/include/mach/linux.h +++ b/arch/sandbox/mach-sandbox/include/mach/linux.h @@ -30,7 +30,6 @@ struct linux_console_data { extern int sdl_xres; extern int sdl_yres; -int sdl_init(void); void sdl_close(void); int sdl_open(int xres, int yres, int bpp, void* buf); void sdl_stop_timer(void); diff --git a/arch/sandbox/os/sdl.c b/arch/sandbox/os/sdl.c index ec538e9af..9a35279eb 100644 --- a/arch/sandbox/os/sdl.c +++ b/arch/sandbox/os/sdl.c @@ -23,11 +23,6 @@ static SDL_Surface *real_screen; static void *buffer = NULL; pthread_t th; -int sdl_init(void) -{ - return SDL_Init(SDL_INIT_VIDEO | SDL_INIT_NOPARACHUTE); -} - static void sdl_copy_buffer(SDL_Surface *screen) { if (SDL_MUSTLOCK(screen)) { @@ -84,7 +79,7 @@ int sdl_open(int xres, int yres, int bpp, void* buf) { int flags = SDL_HWSURFACE | SDL_ASYNCBLIT | SDL_HWACCEL; - if (sdl_init() < 0) { + if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_NOPARACHUTE) < 0) { printf("Could not initialize SDL: %s.\n", SDL_GetError()); return -1; } From 02ede48e67b96b947b26f13804a5f05c36a124c8 Mon Sep 17 00:00:00 2001 From: Sascha Hauer Date: Fri, 14 Oct 2016 11:42:00 +0200 Subject: [PATCH 07/13] gen-dtb-s: Put compressed dtb in different section MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit For builtin dtbs all compiled dtbs matching section .dtb.rodata.* are collected in a single section. Since every dtb is compiled as uncompressed and also as compressed binary each dtb ends up twice in the section. Let's put the compressed variants in .dtbz.rodata.* sections rather than .dtb.rodata.*.z so they end up in the binary only once. Signed-off-by: Sascha Hauer Tested-by: Daniel Krüger --- scripts/gen-dtb-s | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/gen-dtb-s b/scripts/gen-dtb-s index 40c60855e..4215461ed 100755 --- a/scripts/gen-dtb-s +++ b/scripts/gen-dtb-s @@ -58,7 +58,7 @@ fi compressed=$(stat $dtb.lzo -c "%s") uncompressed=$(stat $dtb -c "%s") -echo ".section .dtb.rodata.${name}.z,\"a\"" +echo ".section .dtbz.rodata.${name},\"a\"" echo ".balign STRUCT_ALIGNMENT" echo ".global __dtb_z_${name}_start" echo "__dtb_z_${name}_start:" From 86b716c06ae2e6fde05c881e9e7c597211f32afa Mon Sep 17 00:00:00 2001 From: Lucas Stach Date: Tue, 1 Nov 2016 09:57:42 +0100 Subject: [PATCH 08/13] net: e1000: set edev parent pointer This way the ethernet device will show up at the correct point in the device hierarchy. Signed-off-by: Lucas Stach Signed-off-by: Sascha Hauer --- drivers/net/e1000/main.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/net/e1000/main.c b/drivers/net/e1000/main.c index 77bcd179a..6f9dddaf2 100644 --- a/drivers/net/e1000/main.c +++ b/drivers/net/e1000/main.c @@ -3600,6 +3600,7 @@ static int e1000_probe(struct pci_dev *pdev, const struct pci_device_id *id) e1000_get_ethaddr(edev, edev->ethaddr); /* Set up the function pointers and register the device */ + edev->parent = &pdev->dev; edev->init = e1000_init; edev->recv = e1000_poll; edev->send = e1000_transmit; From a3390e16ed1cc99cf076cca722bf638f72486752 Mon Sep 17 00:00:00 2001 From: Alexander Kurz Date: Fri, 4 Nov 2016 10:19:06 +0100 Subject: [PATCH 09/13] mfd: mc13892: more descriptive charger register defines Make access to the mc13892 charger parameter voltage, current and max power dissipation readable in terms of millivolts, milliamps and milliwatts. Signed-off-by: Alexander Kurz Signed-off-by: Sascha Hauer --- arch/arm/boards/efika-mx-smartbook/board.c | 4 +-- include/mfd/mc13892.h | 40 +++++++++++++++++----- 2 files changed, 32 insertions(+), 12 deletions(-) diff --git a/arch/arm/boards/efika-mx-smartbook/board.c b/arch/arm/boards/efika-mx-smartbook/board.c index d7c11dc2f..d7c5681db 100644 --- a/arch/arm/boards/efika-mx-smartbook/board.c +++ b/arch/arm/boards/efika-mx-smartbook/board.c @@ -74,9 +74,7 @@ static void efikamx_power_init(struct mc13xxx *mc) /* Externally powered */ mc13xxx_reg_read(mc, MC13892_REG_CHARGE, &val); - val |= MC13782_CHARGE_ICHRG0 | MC13782_CHARGE_ICHRG1 | - MC13782_CHARGE_ICHRG2 | MC13782_CHARGE_ICHRG3 | - MC13782_CHARGE_CHGAUTOB; + val |= MC13782_CHARGE_ICHRG_FULL | MC13782_CHARGE_CHGAUTOB; mc13xxx_reg_write(mc, MC13892_REG_CHARGE, val); /* power up the system first */ diff --git a/include/mfd/mc13892.h b/include/mfd/mc13892.h index c92a46244..8b522391b 100644 --- a/include/mfd/mc13892.h +++ b/include/mfd/mc13892.h @@ -29,21 +29,43 @@ /* REG_CHARGE */ -#define MC13782_CHARGE_VCHRG0 (1 << 0) -#define MC13782_CHARGE_VCHRG1 (1 << 1) -#define MC13782_CHARGE_VCHRG2 (1 << 2) -#define MC13782_CHARGE_ICHRG0 (1 << 3) -#define MC13782_CHARGE_ICHRG1 (1 << 4) -#define MC13782_CHARGE_ICHRG2 (1 << 5) -#define MC13782_CHARGE_ICHRG3 (1 << 6) +#define MC13782_CHARGE_VCHRG_3800 (0 << 0) +#define MC13782_CHARGE_VCHRG_4100 (1 << 0) +#define MC13782_CHARGE_VCHRG_4150 (2 << 0) +#define MC13782_CHARGE_VCHRG_4200 (3 << 0) +#define MC13782_CHARGE_VCHRG_4250 (4 << 0) +#define MC13782_CHARGE_VCHRG_4300 (5 << 0) +#define MC13782_CHARGE_VCHRG_4375 (6 << 0) +#define MC13782_CHARGE_VCHRG_4450 (7 << 0) +#define MC13782_CHARGE_VCHRG_MASK (7 << 0) +#define MC13782_CHARGE_ICHRG_0 (0 << 3) +#define MC13782_CHARGE_ICHRG_80 (1 << 3) +#define MC13782_CHARGE_ICHRG_240 (2 << 3) +#define MC13782_CHARGE_ICHRG_320 (3 << 3) +#define MC13782_CHARGE_ICHRG_400 (4 << 3) +#define MC13782_CHARGE_ICHRG_480 (5 << 3) +#define MC13782_CHARGE_ICHRG_560 (6 << 3) +#define MC13782_CHARGE_ICHRG_640 (7 << 3) +#define MC13782_CHARGE_ICHRG_720 (8 << 3) +#define MC13782_CHARGE_ICHRG_800 (9 << 3) +#define MC13782_CHARGE_ICHRG_880 (10 << 3) +#define MC13782_CHARGE_ICHRG_960 (11 << 3) +#define MC13782_CHARGE_ICHRG_1040 (12 << 3) +#define MC13782_CHARGE_ICHRG_1200 (13 << 3) +#define MC13782_CHARGE_ICHRG_1600 (14 << 3) +#define MC13782_CHARGE_ICHRG_FULL (15 << 3) +#define MC13782_CHARGE_ICHRG_MASK (15 << 3) #define MC13782_CHARGE_TREN (1 << 7) #define MC13782_CHARGE_ACKLPB (1 << 8) #define MC13782_CHARGE_THCHKB (1 << 9) #define MC13782_CHARGE_FETOVRD (1 << 10) #define MC13782_CHARGE_FETCTRL (1 << 11) #define MC13782_CHARGE_RVRSMODE (1 << 13) -#define MC13782_CHARGE_PLIM0 (1 << 15) -#define MC13782_CHARGE_PLIM1 (1 << 16) +#define MC13782_CHARGE_PLIM_600 (0 << 15) +#define MC13782_CHARGE_PLIM_800 (1 << 15) +#define MC13782_CHARGE_PLIM_1000 (2 << 15) +#define MC13782_CHARGE_PLIM_1200 (3 << 15) +#define MC13782_CHARGE_PLIM_MASK (3 << 15) #define MC13782_CHARGE_PLIMDIS (1 << 17) #define MC13782_CHARGE_CHRGLEDEN (1 << 18) #define MC13782_CHARGE_CHGTMRRST (1 << 19) From e6876cde693ebffd87ae270197e7bf60a94edcaa Mon Sep 17 00:00:00 2001 From: Antony Pavlov Date: Mon, 7 Nov 2016 12:04:25 +0300 Subject: [PATCH 10/13] command.h: drop unused Struct_Section attribute Signed-off-by: Antony Pavlov Signed-off-by: Sascha Hauer --- include/command.h | 2 -- 1 file changed, 2 deletions(-) diff --git a/include/command.h b/include/command.h index 2e7278099..43ee454f2 100644 --- a/include/command.h +++ b/include/command.h @@ -89,8 +89,6 @@ int run_command(const char *cmd); #endif /* __ASSEMBLY__ */ -#define Struct_Section __attribute__ ((unused,section (".barebox_cmd"))) - #define BAREBOX_CMD_START(_name) \ extern const struct command __barebox_cmd_##_name; \ const struct command __barebox_cmd_##_name \ From 7649dc9ec971d0988c9bf1e9d9c004fa284d81b5 Mon Sep 17 00:00:00 2001 From: Stefan Lengfeld Date: Mon, 7 Nov 2016 16:10:56 +0100 Subject: [PATCH 11/13] commands: spi: fix chip select validation The chip selects are numbered 0..(max chip selects - 1). Chip select with number is invalid. Fix the check for that. Using the out of bound chip select may hang your board. Signed-off-by: Stefan Lengfeld Signed-off-by: Sascha Hauer --- commands/spi.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/commands/spi.c b/commands/spi.c index 21db9ae23..6603b34b6 100644 --- a/commands/spi.c +++ b/commands/spi.c @@ -68,8 +68,8 @@ static int do_spi(int argc, char *argv[]) return -ENODEV; } - if (spi.chip_select > spi.master->num_chipselect) { - printf("spi chip select (%d)> master num chipselect (%d)\n", + if (spi.chip_select >= spi.master->num_chipselect) { + printf("spi chip select (%d) >= master num chipselect (%d)\n", spi.chip_select, spi.master->num_chipselect); return -EINVAL; } From 9549b10a7ec8a20ccc0177d7b5c5f03c902793c5 Mon Sep 17 00:00:00 2001 From: Sascha Hauer Date: Mon, 7 Nov 2016 14:26:47 +0100 Subject: [PATCH 12/13] net: phy: micrel: Do not overwrite reserved bits ksz8021_config_init() unconditionally sets the KSZPHY_OMSO_RMII_OVERRIDE bit. This is since the initial micrel phy commit, so it's not reproducible where this comes from and why this is done. Neither U-Boot nor the kernel ever touch this bit and so should we. Also, instead of doing a write only operation, read/modify/write the bit we actually want to change. This fixes operation on a KSZ8081MLX which is a MII only phy. KSZPHY_OMSO_RMII_OVERRIDE is reserved here and must be written to 0. KSZPHY_OMSO_MII_OVERRIDE is default 1 and must be written as 1. Signed-off-by: Sascha Hauer --- drivers/net/phy/micrel.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/net/phy/micrel.c b/drivers/net/phy/micrel.c index 9a30cb7e9..0ca359b0b 100644 --- a/drivers/net/phy/micrel.c +++ b/drivers/net/phy/micrel.c @@ -72,8 +72,12 @@ static int kszphy_config_init(struct phy_device *phydev) static int ksz8021_config_init(struct phy_device *phydev) { - const u16 val = KSZPHY_OMSO_B_CAST_OFF | KSZPHY_OMSO_RMII_OVERRIDE; + u16 val; + + val = phy_read(phydev, MII_KSZPHY_OMSO); + val |= KSZPHY_OMSO_B_CAST_OFF; phy_write(phydev, MII_KSZPHY_OMSO, val); + return 0; } From ee69c588417972185a1a2d72aa553410493791c2 Mon Sep 17 00:00:00 2001 From: Sascha Hauer Date: Tue, 8 Nov 2016 18:33:09 +0100 Subject: [PATCH 13/13] clk: add clock command completion This adds tab completion for the clk_* commands. Signed-off-by: Sascha Hauer --- commands/clk.c | 5 +++++ drivers/clk/clk.c | 22 ++++++++++++++++++++++ include/linux/clk.h | 4 ++++ 3 files changed, 31 insertions(+) diff --git a/commands/clk.c b/commands/clk.c index f862c45b2..47159dddd 100644 --- a/commands/clk.c +++ b/commands/clk.c @@ -25,6 +25,7 @@ BAREBOX_CMD_START(clk_enable) BAREBOX_CMD_DESC("enable a clock") BAREBOX_CMD_OPTS("CLK") BAREBOX_CMD_GROUP(CMD_GRP_HWMANIP) + BAREBOX_CMD_COMPLETE(clk_name_complete) BAREBOX_CMD_END static int do_clk_disable(int argc, char *argv[]) @@ -48,6 +49,7 @@ BAREBOX_CMD_START(clk_disable) BAREBOX_CMD_DESC("disable a clock") BAREBOX_CMD_OPTS("CLK") BAREBOX_CMD_GROUP(CMD_GRP_HWMANIP) + BAREBOX_CMD_COMPLETE(clk_name_complete) BAREBOX_CMD_END static int do_clk_set_rate(int argc, char *argv[]) @@ -77,6 +79,7 @@ BAREBOX_CMD_START(clk_set_rate) BAREBOX_CMD_OPTS("CLK HZ") BAREBOX_CMD_GROUP(CMD_GRP_HWMANIP) BAREBOX_CMD_HELP(cmd_clk_set_rate_help) + BAREBOX_CMD_COMPLETE(clk_name_complete) BAREBOX_CMD_END static int do_clk_get_rate(int argc, char *argv[]) @@ -130,6 +133,7 @@ BAREBOX_CMD_START(clk_get_rate) BAREBOX_CMD_OPTS("[-s VARNAME] CLK") BAREBOX_CMD_GROUP(CMD_GRP_HWMANIP) BAREBOX_CMD_HELP(cmd_clk_get_rate_help) + BAREBOX_CMD_COMPLETE(clk_name_complete) BAREBOX_CMD_END static int do_clk_dump(int argc, char *argv[]) @@ -187,4 +191,5 @@ BAREBOX_CMD_START(clk_set_parent) BAREBOX_CMD_DESC("set parent of a clock") BAREBOX_CMD_OPTS("CLK PARENT") BAREBOX_CMD_GROUP(CMD_GRP_HWMANIP) + BAREBOX_CMD_COMPLETE(clk_name_complete) BAREBOX_CMD_END diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c index 630a84d58..15e424db1 100644 --- a/drivers/clk/clk.c +++ b/drivers/clk/clk.c @@ -17,6 +17,8 @@ #include #include #include +#include +#include #include #include @@ -508,3 +510,23 @@ void clk_dump(int verbose) dump_one(c, verbose, 0); } } + +int clk_name_complete(struct string_list *sl, char *instr) +{ + struct clk *c; + int len; + + if (!instr) + instr = ""; + + len = strlen(instr); + + list_for_each_entry(c, &clks, list) { + if (strncmp(instr, c->name, len)) + continue; + + string_list_add_asprintf(sl, "%s ", c->name); + } + + return COMPLETE_CONTINUE; +} diff --git a/include/linux/clk.h b/include/linux/clk.h index 7a0ee110e..8cb9731f1 100644 --- a/include/linux/clk.h +++ b/include/linux/clk.h @@ -362,4 +362,8 @@ static inline int of_clk_init(struct device_node *root, } #endif +struct string_list; + +int clk_name_complete(struct string_list *sl, char *instr); + #endif