[U-Boot] [PATCH v3 0/8] hwconfig and some its users

On Fri, May 01, 2009 at 12:31:54AM +0200, Wolfgang Denk wrote:
Dear Anton,
In message 20090429215000.GA1092@oksana.dev.rtsoft.ru you wrote:
This patch implements simple hwconfig infrastructure: an interface for software knobs to control a hardware.
Thanks a lot.
We support hwconfig options with arguments. For example,
set hwconfig dr_usb,dr_usb_mode:peripheral,dr_usb_phy_type:ulpi
There are three hwconfig options selected:
- dr_usb - enable Dual-Role USB controller;
- dr_usb_mode:peripheral - USB in Function mode;
- dr_usb_phy_type:ulpi - USB should work with ULPI PHYs.
That gives a lot of typing, which in turn results in lots of typing errors, which in this case are probably nasty to debug.
Suggestion: instead of
set hwconfig dr_usb,dr_usb_mode:peripheral,dr_usb_phy_type:ulpi
use:
set hwconfig dr_usb:mode=peripheral,phy_type=ulpi
What do you think?
Sorry for the delay. Done. New patches on the way.
Thanks,

This patch implements simple hwconfig infrastructure: an interface for software knobs to control a hardware.
This is very simple implementation, i.e. it is implemented via `hwconfig' environment variable. Later we could write some "hwconfig <enable|disable|list>" commands, ncurses interface for Award BIOS-like interface, and frame-buffer interface for AMI GUI[1] BIOS-like interface with mouse support[2].
Current implementation details/limitations:
1. Doesn't support options dependencies and mutual exclusion. We can implement this by integrating apt-get[3] into the u-boot. But I didn't bother yet.
2. Since we don't implement hwconfig command, i.e. we're working with the environement directly, there is no way to tell that toggling a particular option will need a reboot to take an effect. So, for now it's advised to always reboot the target after modifying hwconfig variable.
3. We support hwconfig options with arguments. For example,
set hwconfig dr_usb:mode=peripheral,phy_type=ulpi
That means: - dr_usb - enable Dual-Role USB controller; - dr_usb:mode=peripheral - USB in Function mode; - dr_usb:phy_type=ulpi - USB should work with ULPI PHYs;
The purpose of this simple implementation is to define some internal API and then we can continue improving user experience by adding more mature interface, like hwconfig command with bells and whistles. Or not adding, if we feel that current interface fits its needs.
[1] http://en.wikipedia.org/wiki/American_Megatrends [2] Regarding ncurses and GUI with mouse support -- I'm just kidding. [3] The comment regarding apt-get is also a joke, meaning that dependency tracking could be non-trivial. For example, for enabling HW feature X we may need to disable Y, and turn Z into reduced mode (like RMII-only interface for ethernet, no MII).
It's quite trivial to implement simple cases though.
Signed-off-by: Anton Vorontsov avorontsov@ru.mvista.com --- common/Makefile | 1 + common/hwconfig.c | 210 ++++++++++++++++++++++++++++++++++++++++++++++++++++ include/hwconfig.h | 69 +++++++++++++++++ 3 files changed, 280 insertions(+), 0 deletions(-) create mode 100644 common/hwconfig.c create mode 100644 include/hwconfig.h
diff --git a/common/Makefile b/common/Makefile index b9f4ca7..41d6b3d 100644 --- a/common/Makefile +++ b/common/Makefile @@ -150,6 +150,7 @@ COBJS-$(CONFIG_VFD) += cmd_vfd.o # others COBJS-$(CONFIG_DDR_SPD) += ddr_spd.o COBJS-$(CONFIG_CMD_DOC) += docecc.o +COBJS-$(CONFIG_HWCONFIG) += hwconfig.o COBJS-$(CONFIG_CONSOLE_MUX) += iomux.o COBJS-y += flash.o COBJS-$(CONFIG_CMD_KGDB) += kgdb.o diff --git a/common/hwconfig.c b/common/hwconfig.c new file mode 100644 index 0000000..e5c60ba --- /dev/null +++ b/common/hwconfig.c @@ -0,0 +1,210 @@ +/* + * An inteface for configuring a hardware via u-boot environment. + * + * Copyright (c) 2009 MontaVista Software, Inc. + * + * Author: Anton Vorontsov avorontsov@ru.mvista.com + * + * 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. + */ + +#include <config.h> +#include <common.h> +#include <exports.h> +#include <hwconfig.h> +#include <linux/types.h> +#include <linux/string.h> + +static const char *hwconfig_parse(const char *opts, size_t maxlen, + const char *opt, char stopch, char eqch, + size_t *arglen) +{ + size_t optlen = strlen(opt); + char *str; + const char *start = opts; + const char *end; + +next: + str = strstr(opts, opt); + end = str + optlen; + if (end - start > maxlen) + return NULL; + + if (str && (str == opts || str[-1] == stopch) && + (*end == stopch || *end == eqch || *end == '\0')) { + const char *arg_end; + + if (!arglen) + return str; + + if (*end != eqch) + return NULL; + + arg_end = strchr(str, stopch); + if (!arg_end) + *arglen = min(maxlen, strlen(str)) - optlen - 1; + else + *arglen = arg_end - end - 1; + + return end + 1; + } else if (str) { + opts = end; + goto next; + } + return NULL; +} + +const char *cpu_hwconfig __attribute__((weak)); +const char *board_hwconfig __attribute__((weak)); + +static const char *__hwconfig(const char *opt, size_t *arglen) +{ + const char *env_hwconfig = getenv("hwconfig"); + + if (env_hwconfig) + return hwconfig_parse(env_hwconfig, strlen(env_hwconfig), + opt, ';', ':', arglen); + + if (board_hwconfig) + return hwconfig_parse(board_hwconfig, strlen(board_hwconfig), + opt, ';', ':', arglen); + + if (cpu_hwconfig) + return hwconfig_parse(cpu_hwconfig, strlen(cpu_hwconfig), + opt, ';', ':', arglen); + + return NULL; +} + +/* + * hwconfig - query if a particular hwconfig option is specified + * @opt: a string representing an option + * + * This call can be used to find out whether U-Boot should configure + * a particular hardware option. + * + * Returns non-zero value if the hardware option can be used and thus + * should be configured, 0 otherwise. + * + * This function also returns non-zero value if CONFIG_HWCONFIG is + * undefined. + * + * Returning non-zero value without CONFIG_HWCONFIG has its crucial + * purpose: the hwconfig() call should be a "transparent" interface, + * e.g. if a board doesn't need hwconfig facility, then we assume + * that the board file only calls things that are actually used, so + * hwconfig() will always return true result. + */ +int hwconfig(const char *opt) +{ + return !!__hwconfig(opt, NULL); +} + +/* + * hwconfig_arg - get hwconfig option's argument + * @opt: a string representing an option + * @arglen: a pointer to an allocated size_t variable + * + * Unlike hwconfig() function, this function returns a pointer to the + * start of the hwconfig arguments, if option is not found or it has + * no specified arguments, the function returns NULL pointer. + * + * If CONFIG_HWCONFIG is undefined, the function returns "", and + * arglen is set to 0. + */ +const char *hwconfig_arg(const char *opt, size_t *arglen) +{ + return __hwconfig(opt, arglen); +} + +/* + * hwconfig_arg_cmp - compare hwconfig option's argument + * @opt: a string representing an option + * @arg: a string for comparing an option's argument + * + * This call is similar to hwconfig_arg, but instead of returning + * hwconfig argument and its length, it is comparing it to @arg. + * + * Returns non-zero value if @arg matches, 0 otherwise. + * + * If CONFIG_HWCONFIG is undefined, the function returns a non-zero + * value, i.e. the argument matches. + */ +int hwconfig_arg_cmp(const char *opt, const char *arg) +{ + const char *argstr; + size_t arglen; + + argstr = hwconfig_arg(opt, &arglen); + if (!argstr || arglen != strlen(arg)) + return 0; + + return !strncmp(argstr, arg, arglen); +} + +/* + * hwconfig_sub - query if a particular hwconfig sub-option is specified + * @opt: a string representing an option + * @subopt: a string representing a sub-option + * + * This call is similar to hwconfig(), except that it takes additional + * argument @subopt. In this example: + * "dr_usb:mode=peripheral" + * "dr_usb" is an option, "mode" is a sub-option, and "peripheral" is its + * argument. + */ +int hwconfig_sub(const char *opt, const char *subopt) +{ + size_t arglen; + const char *arg; + + arg = __hwconfig(opt, &arglen); + if (!arg) + return 0; + return !!hwconfig_parse(arg, arglen, subopt, ',', '=', NULL); +} + +/* + * hwconfig_subarg - get hwconfig sub-option's argument + * @opt: a string representing an option + * @subopt: a string representing a sub-option + * @subarglen: a pointer to an allocated size_t variable + * + * This call is similar to hwconfig_arg(), except that it takes an additional + * argument @subopt, and so works with sub-options. + */ +const char *hwconfig_subarg(const char *opt, const char *subopt, + size_t *subarglen) +{ + size_t arglen; + const char *arg; + + arg = __hwconfig(opt, &arglen); + if (!arg) + return NULL; + return hwconfig_parse(arg, arglen, subopt, ',', '=', subarglen); +} + +/* + * hwconfig_arg_cmp - compare hwconfig sub-option's argument + * @opt: a string representing an option + * @subopt: a string representing a sub-option + * @subarg: a string for comparing an sub-option's argument + * + * This call is similar to hwconfig_arg_cmp, except that it takes an additional + * argument @subopt, and so works with sub-options. + */ +int hwconfig_subarg_cmp(const char *opt, const char *subopt, const char *subarg) +{ + const char *argstr; + size_t arglen; + + argstr = hwconfig_subarg(opt, subopt, &arglen); + if (!argstr || arglen != strlen(subarg)) + return 0; + + return !strncmp(argstr, subarg, arglen); +} diff --git a/include/hwconfig.h b/include/hwconfig.h new file mode 100644 index 0000000..d517f78 --- /dev/null +++ b/include/hwconfig.h @@ -0,0 +1,69 @@ +/* + * An inteface for configuring a hardware via u-boot environment. + * + * Copyright (c) 2009 MontaVista Software, Inc. + * + * Author: Anton Vorontsov avorontsov@ru.mvista.com + * + * 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. + */ + +#ifndef _HWCONFIG_H +#define _HWCONFIG_H + +#include <linux/types.h> +#include <asm/errno.h> + +#ifdef CONFIG_HWCONFIG + +extern int hwconfig(const char *opt); +extern const char *hwconfig_arg(const char *opt, size_t *arglen); +extern int hwconfig_arg_cmp(const char *opt, const char *arg); +extern int hwconfig_sub(const char *opt, const char *subopt); +extern const char *hwconfig_subarg(const char *opt, const char *subopt, + size_t *subarglen); +extern int hwconfig_subarg_cmp(const char *opt, const char *subopt, + const char *subarg); + +#else + +static inline int hwconfig(const char *opt) +{ + return -ENOSYS; +} + +static inline const char *hwconfig_arg(const char *opt, size_t *arglen) +{ + *arglen = 0; + return ""; +} + +static inline int hwconfig_arg_cmp(const char *opt, const char *arg) +{ + return -ENOSYS; +} + +static inline int hwconfig_sub(const char *opt, const char *subopt) +{ + return -ENOSYS; +} + +static inline const char *hwconfig_subarg(const char *opt, const char *subopt, + size_t *subarglen) +{ + *subarglen = 0; + return ""; +} + +static inline int hwconfig_subarg_cmp(const char *opt, const char *subopt, + const char *subarg) +{ + return -ENOSYS; +} + +#endif /* CONFIG_HWCONFIG */ + +#endif /* _HWCONFIG_H */

Dear Anton Vorontsov,
In message 20090609202527.GA20493@oksana.dev.rtsoft.ru you wrote:
This patch implements simple hwconfig infrastructure: an interface for software knobs to control a hardware.
This is very simple implementation, i.e. it is implemented via `hwconfig' environment variable. Later we could write some "hwconfig <enable|disable|list>" commands, ncurses interface for Award BIOS-like interface, and frame-buffer interface for AMI GUI[1] BIOS-like interface with mouse support[2].
Current implementation details/limitations:
Doesn't support options dependencies and mutual exclusion. We can implement this by integrating apt-get[3] into the u-boot. But I didn't bother yet.
Since we don't implement hwconfig command, i.e. we're working with the environement directly, there is no way to tell that toggling a particular option will need a reboot to take an effect. So, for now it's advised to always reboot the target after modifying hwconfig variable.
We support hwconfig options with arguments. For example,
set hwconfig dr_usb:mode=peripheral,phy_type=ulpi
That means:
- dr_usb - enable Dual-Role USB controller;
- dr_usb:mode=peripheral - USB in Function mode;
- dr_usb:phy_type=ulpi - USB should work with ULPI PHYs;
The purpose of this simple implementation is to define some internal API and then we can continue improving user experience by adding more mature interface, like hwconfig command with bells and whistles. Or not adding, if we feel that current interface fits its needs.
[1] http://en.wikipedia.org/wiki/American_Megatrends [2] Regarding ncurses and GUI with mouse support -- I'm just kidding. [3] The comment regarding apt-get is also a joke, meaning that dependency tracking could be non-trivial. For example, for enabling HW feature X we may need to disable Y, and turn Z into reduced mode (like RMII-only interface for ethernet, no MII).
It's quite trivial to implement simple cases though.
Signed-off-by: Anton Vorontsov avorontsov@ru.mvista.com
common/Makefile | 1 + common/hwconfig.c | 210 ++++++++++++++++++++++++++++++++++++++++++++++++++++ include/hwconfig.h | 69 +++++++++++++++++ 3 files changed, 280 insertions(+), 0 deletions(-) create mode 100644 common/hwconfig.c create mode 100644 include/hwconfig.h
Applied, thanks.
Best regards,
Wolfgang Denk

This patch implements fdt_fixup_esdhc() function that is used to fixup the device tree.
The function adds status = "disabled" propery if esdhc pins muxed away, otherwise it fixups clock-frequency for esdhc nodes.
Signed-off-by: Anton Vorontsov avorontsov@ru.mvista.com --- drivers/mmc/fsl_esdhc.c | 19 +++++++++++++++++++ include/fsl_esdhc.h | 8 ++++++++ 2 files changed, 27 insertions(+), 0 deletions(-)
diff --git a/drivers/mmc/fsl_esdhc.c b/drivers/mmc/fsl_esdhc.c index 0ba45cd..34af32b 100644 --- a/drivers/mmc/fsl_esdhc.c +++ b/drivers/mmc/fsl_esdhc.c @@ -28,11 +28,13 @@ #include <config.h> #include <common.h> #include <command.h> +#include <hwconfig.h> #include <mmc.h> #include <part.h> #include <malloc.h> #include <mmc.h> #include <fsl_esdhc.h> +#include <fdt_support.h> #include <asm/io.h>
@@ -346,3 +348,20 @@ int fsl_esdhc_mmc_init(bd_t *bis) { return esdhc_initialize(bis); } + +void fdt_fixup_esdhc(void *blob, bd_t *bd) +{ + const char *compat = "fsl,esdhc"; + const char *status = "okay"; + + if (!hwconfig("esdhc")) { + status = "disabled"; + goto out; + } + + do_fixup_by_compat_u32(blob, compat, "clock-frequency", + gd->sdhc_clk, 1); +out: + do_fixup_by_compat(blob, compat, "status", status, + strlen(status) + 1, 1); +} diff --git a/include/fsl_esdhc.h b/include/fsl_esdhc.h index 0a5c5d6..89b8304 100644 --- a/include/fsl_esdhc.h +++ b/include/fsl_esdhc.h @@ -26,6 +26,8 @@ #ifndef __FSL_ESDHC_H__ #define __FSL_ESDHC_H__
+#include <asm/errno.h> + /* FSL eSDHC-specific constants */ #define SYSCTL 0x0002e02c #define SYSCTL_INITA 0x08000000 @@ -140,6 +142,12 @@ #define ESDHC_HOSTCAPBLT_DMAS 0x00400000 #define ESDHC_HOSTCAPBLT_HSS 0x00200000
+#ifdef CONFIG_FSL_ESDHC int fsl_esdhc_mmc_init(bd_t *bis); +void fdt_fixup_esdhc(void *blob, bd_t *bd); +#else +static inline int fsl_esdhc_mmc_init(bd_t *bis) { return -ENOSYS; } +static inline void fdt_fixup_esdhc(void *blob, bd_t *bd) {} +#endif /* CONFIG_FSL_ESDHC */
#endif /* __FSL_ESDHC_H__ */

Dear Anton Vorontsov,
In message 20090609202529.GB20493@oksana.dev.rtsoft.ru you wrote:
This patch implements fdt_fixup_esdhc() function that is used to fixup the device tree.
The function adds status = "disabled" propery if esdhc pins muxed away, otherwise it fixups clock-frequency for esdhc nodes.
Signed-off-by: Anton Vorontsov avorontsov@ru.mvista.com
drivers/mmc/fsl_esdhc.c | 19 +++++++++++++++++++ include/fsl_esdhc.h | 8 ++++++++ 2 files changed, 27 insertions(+), 0 deletions(-)
Applied, thanks.
Best regards,
Wolfgang Denk

This patch adds support for eSDHC on MPC837XERDB boards. The WP switch doesn't seem to work on RDB boards though, the WP pin is always asserted (can see the pin state when it's in GPIO mode).
FSL DR USB and FSL eSDHC are mutually exclusive because of pins multiplexing, so user should specify 'esdhc' or 'dr_usb' options in the hwconfig environment variable to choose between the devices.
p.s. Now we're very close to a monitor len limit (196 bytes left using gcc-4.2.0), so also increase the monitor len by one sector (64 KB).
Signed-off-by: Anton Vorontsov avorontsov@ru.mvista.com --- board/freescale/mpc837xerdb/mpc837xerdb.c | 18 ++++++++++++++++++ include/configs/MPC837XERDB.h | 18 +++++++++++++++++- 2 files changed, 35 insertions(+), 1 deletions(-)
diff --git a/board/freescale/mpc837xerdb/mpc837xerdb.c b/board/freescale/mpc837xerdb/mpc837xerdb.c index 318a3dc..2229657 100644 --- a/board/freescale/mpc837xerdb/mpc837xerdb.c +++ b/board/freescale/mpc837xerdb/mpc837xerdb.c @@ -13,12 +13,14 @@ */
#include <common.h> +#include <hwconfig.h> #include <i2c.h> #include <asm/io.h> #include <asm/fsl_serdes.h> #include <fdt_support.h> #include <spd_sdram.h> #include <vsc7385.h> +#include <fsl_esdhc.h>
#if defined(CONFIG_SYS_DRAM_TEST) int @@ -166,6 +168,21 @@ int board_early_init_f(void) return 0; }
+#ifdef CONFIG_FSL_ESDHC +int board_mmc_init(bd_t *bd) +{ + struct immap __iomem *im = (struct immap __iomem *)CONFIG_SYS_IMMR; + + if (!hwconfig("esdhc")) + return 0; + + clrsetbits_be32(&im->sysconf.sicrl, SICRL_USB_B, SICRL_USB_B_SD); + clrsetbits_be32(&im->sysconf.sicrh, SICRH_SPI, SICRH_SPI_SD); + + return fsl_esdhc_mmc_init(bd); +} +#endif + /* * Miscellaneous late-boot configurations * @@ -195,5 +212,6 @@ void ft_board_setup(void *blob, bd_t *bd) #endif ft_cpu_setup(blob, bd); fdt_fixup_dr_usb(blob, bd); + fdt_fixup_esdhc(blob, bd); } #endif /* CONFIG_OF_BOARD_SETUP */ diff --git a/include/configs/MPC837XERDB.h b/include/configs/MPC837XERDB.h index 8d0c93b..d335d76 100644 --- a/include/configs/MPC837XERDB.h +++ b/include/configs/MPC837XERDB.h @@ -34,6 +34,7 @@
#define CONFIG_BOARD_EARLY_INIT_F #define CONFIG_MISC_INIT_R +#define CONFIG_HWCONFIG
/* * On-board devices @@ -228,7 +229,7 @@ #undef CONFIG_SYS_RAMBOOT #endif
-#define CONFIG_SYS_MONITOR_LEN (256 * 1024) /* Reserve 256 kB for Mon */ +#define CONFIG_SYS_MONITOR_LEN (320 * 1024) /* Reserve 320 kB for Mon */ #define CONFIG_SYS_MALLOC_LEN (512 * 1024) /* Reserved for malloc */
/* @@ -342,6 +343,9 @@ #define CONFIG_OF_BOARD_SETUP 1 #define CONFIG_OF_STDOUT_VIA_ALIAS 1
+#define CONFIG_SYS_64BIT_STRTOUL 1 +#define CONFIG_SYS_64BIT_VSPRINTF 1 + /* I2C */ #define CONFIG_HARD_I2C /* I2C with hardware support */ #undef CONFIG_SOFT_I2C /* I2C bit-banged */ @@ -510,6 +514,18 @@
#undef CONFIG_WATCHDOG /* watchdog disabled */
+#define CONFIG_MMC 1 + +#ifdef CONFIG_MMC +#define CONFIG_FSL_ESDHC +#define CONFIG_SYS_FSL_ESDHC_ADDR CONFIG_SYS_MPC83xx_ESDHC_ADDR +#define CONFIG_CMD_MMC +#define CONFIG_GENERIC_MMC +#define CONFIG_CMD_EXT2 +#define CONFIG_CMD_FAT +#define CONFIG_DOS_PARTITION +#endif + /* * Miscellaneous configurable options */

Dear Anton Vorontsov,
In message 20090609202530.GC20493@oksana.dev.rtsoft.ru you wrote:
This patch adds support for eSDHC on MPC837XERDB boards. The WP switch doesn't seem to work on RDB boards though, the WP pin is always asserted (can see the pin state when it's in GPIO mode).
FSL DR USB and FSL eSDHC are mutually exclusive because of pins multiplexing, so user should specify 'esdhc' or 'dr_usb' options in the hwconfig environment variable to choose between the devices.
p.s. Now we're very close to a monitor len limit (196 bytes left using gcc-4.2.0), so also increase the monitor len by one sector (64 KB).
Signed-off-by: Anton Vorontsov avorontsov@ru.mvista.com
board/freescale/mpc837xerdb/mpc837xerdb.c | 18 ++++++++++++++++++ include/configs/MPC837XERDB.h | 18 +++++++++++++++++- 2 files changed, 35 insertions(+), 1 deletions(-)
Applied, thanks.
Best regards,
Wolfgang Denk

fdt_fixup_esdhc() will either disable or enable eSDHC nodes, and also will fixup clock-frequency property.
Plus, since DR USB and eSDHC are mutually exclusive, we should only configure the eSDHC if asked through hwconfig.
Signed-off-by: Anton Vorontsov avorontsov@ru.mvista.com --- board/freescale/mpc837xemds/mpc837xemds.c | 37 ++++++++++++++++++---------- include/configs/MPC837XEMDS.h | 1 + 2 files changed, 25 insertions(+), 13 deletions(-)
diff --git a/board/freescale/mpc837xemds/mpc837xemds.c b/board/freescale/mpc837xemds/mpc837xemds.c index 062d762..5d3cea1 100644 --- a/board/freescale/mpc837xemds/mpc837xemds.c +++ b/board/freescale/mpc837xemds/mpc837xemds.c @@ -11,6 +11,7 @@ */
#include <common.h> +#include <hwconfig.h> #include <i2c.h> #include <asm/io.h> #include <asm/fsl_serdes.h> @@ -18,12 +19,12 @@ #include <tsec.h> #include <libfdt.h> #include <fdt_support.h> +#include <fsl_esdhc.h> #include "pci.h" #include "../common/pq-mds-pib.h"
int board_early_init_f(void) { - struct immap __iomem *im = (struct immap __iomem *)CONFIG_SYS_IMMR; u8 *bcsr = (u8 *)CONFIG_SYS_BCSR;
/* Enable flash write */ @@ -31,18 +32,6 @@ int board_early_init_f(void) /* Clear all of the interrupt of BCSR */ bcsr[0xe] = 0xff;
-#ifdef CONFIG_MMC - /* Set SPI_SD, SER_SD, and IRQ4_WP so that SD signals go through */ - bcsr[0xc] |= 0x4c; - - /* Set proper bits in SICR to allow SD signals through */ - clrsetbits_be32(&im->sysconf.sicrl, SICRL_USB_B, SICRL_USB_B_SD); - - clrsetbits_be32(&im->sysconf.sicrh, (SICRH_GPIO2_E | SICRH_SPI), - (SICRH_GPIO2_E_SD | SICRH_SPI_SD)); - -#endif - #ifdef CONFIG_FSL_SERDES immap_t *immr = (immap_t *)CONFIG_SYS_IMMR; u32 spridr = in_be32(&immr->sysconf.spridr); @@ -72,6 +61,27 @@ int board_early_init_f(void) return 0; }
+#ifdef CONFIG_FSL_ESDHC +int board_mmc_init(bd_t *bd) +{ + struct immap __iomem *im = (struct immap __iomem *)CONFIG_SYS_IMMR; + u8 *bcsr = (u8 *)CONFIG_SYS_BCSR; + + if (!hwconfig("esdhc")) + return 0; + + /* Set SPI_SD, SER_SD, and IRQ4_WP so that SD signals go through */ + bcsr[0xc] |= 0x4c; + + /* Set proper bits in SICR to allow SD signals through */ + clrsetbits_be32(&im->sysconf.sicrl, SICRL_USB_B, SICRL_USB_B_SD); + clrsetbits_be32(&im->sysconf.sicrh, SICRH_GPIO2_E | SICRH_SPI, + SICRH_GPIO2_E_SD | SICRH_SPI_SD); + + return fsl_esdhc_mmc_init(bd); +} +#endif + #if defined(CONFIG_TSEC1) || defined(CONFIG_TSEC2) int board_eth_init(bd_t *bd) { @@ -322,6 +332,7 @@ void ft_board_setup(void *blob, bd_t *bd) ft_cpu_setup(blob, bd); ft_tsec_fixup(blob, bd); fdt_fixup_dr_usb(blob, bd); + fdt_fixup_esdhc(blob, bd); #ifdef CONFIG_PCI ft_pci_setup(blob, bd); if (board_pci_host_broken()) diff --git a/include/configs/MPC837XEMDS.h b/include/configs/MPC837XEMDS.h index a62d805..9413b29 100644 --- a/include/configs/MPC837XEMDS.h +++ b/include/configs/MPC837XEMDS.h @@ -111,6 +111,7 @@
#define CONFIG_BOARD_EARLY_INIT_F /* call board_pre_init */ #define CONFIG_BOARD_EARLY_INIT_R +#define CONFIG_HWCONFIG
/* * IMMR new address

Dear Anton Vorontsov,
In message 20090609202531.GD20493@oksana.dev.rtsoft.ru you wrote:
fdt_fixup_esdhc() will either disable or enable eSDHC nodes, and also will fixup clock-frequency property.
Plus, since DR USB and eSDHC are mutually exclusive, we should only configure the eSDHC if asked through hwconfig.
Signed-off-by: Anton Vorontsov avorontsov@ru.mvista.com
board/freescale/mpc837xemds/mpc837xemds.c | 37 ++++++++++++++++++---------- include/configs/MPC837XEMDS.h | 1 + 2 files changed, 25 insertions(+), 13 deletions(-)
Applied, thanks.
Best regards,
Wolfgang Denk

In subsequent patches we'll use FSL-specific functions in fdt_fixup_dr_usb(), so let's move the routine to a more appropriate place.
So far fsl_dr_usb.c isn't actually an USB driver, but eventually it will turn into one, let's hope. ;-)
Also rename CONFIG_HAS_FSL_DR_USB to CONFIG_USB_FSL_DR to be consistent with other USB drivers.
Signed-off-by: Anton Vorontsov avorontsov@ru.mvista.com --- Makefile | 1 + board/freescale/mpc8315erdb/mpc8315erdb.c | 1 + board/freescale/mpc837xemds/mpc837xemds.c | 1 + board/freescale/mpc837xerdb/mpc837xerdb.c | 1 + common/fdt_support.c | 41 ---------------------- drivers/usb/otg/Makefile | 46 +++++++++++++++++++++++++ drivers/usb/otg/fsl_dr_usb.c | 52 +++++++++++++++++++++++++++++ include/configs/MPC8315ERDB.h | 2 +- include/configs/MPC837XEMDS.h | 2 +- include/configs/MPC837XERDB.h | 2 +- include/fdt_support.h | 6 --- include/fsl_dr_usb.h | 21 +++++++++++ 12 files changed, 126 insertions(+), 50 deletions(-) create mode 100644 drivers/usb/otg/Makefile create mode 100644 drivers/usb/otg/fsl_dr_usb.c create mode 100644 include/fsl_dr_usb.h
diff --git a/Makefile b/Makefile index 24e6410..95a7615 100644 --- a/Makefile +++ b/Makefile @@ -265,6 +265,7 @@ LIBS += drivers/serial/libserial.a LIBS += drivers/twserial/libtws.a LIBS += drivers/usb/gadget/libusb_gadget.a LIBS += drivers/usb/host/libusb_host.a +LIBS += drivers/usb/otg/libusb_otg.a LIBS += drivers/usb/musb/libusb_musb.a LIBS += drivers/video/libvideo.a LIBS += drivers/watchdog/libwatchdog.a diff --git a/board/freescale/mpc8315erdb/mpc8315erdb.c b/board/freescale/mpc8315erdb/mpc8315erdb.c index f80b0ba..9d6896d 100644 --- a/board/freescale/mpc8315erdb/mpc8315erdb.c +++ b/board/freescale/mpc8315erdb/mpc8315erdb.c @@ -30,6 +30,7 @@ #include <pci.h> #include <mpc83xx.h> #include <netdev.h> +#include <fsl_dr_usb.h> #include <asm/io.h>
DECLARE_GLOBAL_DATA_PTR; diff --git a/board/freescale/mpc837xemds/mpc837xemds.c b/board/freescale/mpc837xemds/mpc837xemds.c index 5d3cea1..76b5430 100644 --- a/board/freescale/mpc837xemds/mpc837xemds.c +++ b/board/freescale/mpc837xemds/mpc837xemds.c @@ -20,6 +20,7 @@ #include <libfdt.h> #include <fdt_support.h> #include <fsl_esdhc.h> +#include <fsl_dr_usb.h> #include "pci.h" #include "../common/pq-mds-pib.h"
diff --git a/board/freescale/mpc837xerdb/mpc837xerdb.c b/board/freescale/mpc837xerdb/mpc837xerdb.c index 2229657..e8fa6b6 100644 --- a/board/freescale/mpc837xerdb/mpc837xerdb.c +++ b/board/freescale/mpc837xerdb/mpc837xerdb.c @@ -21,6 +21,7 @@ #include <spd_sdram.h> #include <vsc7385.h> #include <fsl_esdhc.h> +#include <fsl_dr_usb.h>
#if defined(CONFIG_SYS_DRAM_TEST) int diff --git a/common/fdt_support.c b/common/fdt_support.c index b54f886..ec6cff1 100644 --- a/common/fdt_support.c +++ b/common/fdt_support.c @@ -454,47 +454,6 @@ void fdt_fixup_ethernet(void *fdt) } }
-#ifdef CONFIG_HAS_FSL_DR_USB -void fdt_fixup_dr_usb(void *blob, bd_t *bd) -{ - char *mode; - char *type; - const char *compat = "fsl-usb2-dr"; - const char *prop_mode = "dr_mode"; - const char *prop_type = "phy_type"; - int node_offset; - int err; - - mode = getenv("usb_dr_mode"); - type = getenv("usb_phy_type"); - if (!mode && !type) - return; - - node_offset = fdt_node_offset_by_compatible(blob, 0, compat); - if (node_offset < 0) { - printf("WARNING: could not find compatible node %s: %s.\n", - compat, fdt_strerror(node_offset)); - return; - } - - if (mode) { - err = fdt_setprop(blob, node_offset, prop_mode, mode, - strlen(mode) + 1); - if (err < 0) - printf("WARNING: could not set %s for %s: %s.\n", - prop_mode, compat, fdt_strerror(err)); - } - - if (type) { - err = fdt_setprop(blob, node_offset, prop_type, type, - strlen(type) + 1); - if (err < 0) - printf("WARNING: could not set %s for %s: %s.\n", - prop_type, compat, fdt_strerror(err)); - } -} -#endif /* CONFIG_HAS_FSL_DR_USB */ - #if defined(CONFIG_MPC83XX) || defined(CONFIG_MPC85xx) /* * update crypto node properties to a specified revision of the SEC diff --git a/drivers/usb/otg/Makefile b/drivers/usb/otg/Makefile new file mode 100644 index 0000000..34b590f --- /dev/null +++ b/drivers/usb/otg/Makefile @@ -0,0 +1,46 @@ +# +# (C) Copyright 2000-2007 +# Wolfgang Denk, DENX Software Engineering, wd@denx.de. +# +# 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. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, +# MA 02111-1307 USA +# + +include $(TOPDIR)/config.mk + +LIB := $(obj)libusb_otg.a + +COBJS-$(CONFIG_USB_FSL_DR) += fsl_dr_usb.o + +COBJS := $(COBJS-y) +SRCS := $(COBJS:.o=.c) +OBJS := $(addprefix $(obj),$(COBJS)) + +all: $(LIB) + +$(LIB): $(obj).depend $(OBJS) + $(AR) $(ARFLAGS) $@ $(OBJS) + +######################################################################### + +# defines $(obj).depend target +include $(SRCTREE)/rules.mk + +sinclude $(obj).depend + +######################################################################### diff --git a/drivers/usb/otg/fsl_dr_usb.c b/drivers/usb/otg/fsl_dr_usb.c new file mode 100644 index 0000000..af9797f --- /dev/null +++ b/drivers/usb/otg/fsl_dr_usb.c @@ -0,0 +1,52 @@ +/* + * Copyright (c) 2008-2009 MontaVista Software, Inc. + * + * Author: Anton Vorontsov avorontsov@ru.mvista.com + * + * 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. + */ + +#include <common.h> +#include <libfdt.h> + +void fdt_fixup_dr_usb(void *blob, bd_t *bd) +{ + char *mode; + char *type; + const char *compat = "fsl-usb2-dr"; + const char *prop_mode = "dr_mode"; + const char *prop_type = "phy_type"; + int node_offset; + int err; + + mode = getenv("usb_dr_mode"); + type = getenv("usb_phy_type"); + if (!mode && !type) + return; + + node_offset = fdt_node_offset_by_compatible(blob, 0, compat); + if (node_offset < 0) { + printf("WARNING: could not find compatible node %s: %s.\n", + compat, fdt_strerror(node_offset)); + return; + } + + if (mode) { + err = fdt_setprop(blob, node_offset, prop_mode, mode, + strlen(mode) + 1); + if (err < 0) + printf("WARNING: could not set %s for %s: %s.\n", + prop_mode, compat, fdt_strerror(err)); + } + + if (type) { + err = fdt_setprop(blob, node_offset, prop_type, type, + strlen(type) + 1); + if (err < 0) + printf("WARNING: could not set %s for %s: %s.\n", + prop_type, compat, fdt_strerror(err)); + } +} diff --git a/include/configs/MPC8315ERDB.h b/include/configs/MPC8315ERDB.h index 9fa91f4..e3dcf96 100644 --- a/include/configs/MPC8315ERDB.h +++ b/include/configs/MPC8315ERDB.h @@ -344,7 +344,7 @@ #define CONFIG_NET_MULTI 1 #endif
-#define CONFIG_HAS_FSL_DR_USB +#define CONFIG_USB_FSL_DR 1
/* * TSEC diff --git a/include/configs/MPC837XEMDS.h b/include/configs/MPC837XEMDS.h index 9413b29..631468f 100644 --- a/include/configs/MPC837XEMDS.h +++ b/include/configs/MPC837XEMDS.h @@ -385,7 +385,7 @@ extern int board_pci_host_broken(void); #define CONFIG_83XX_GENERIC_PCIE 1 #define CONFIG_PQ_MDS_PIB 1 /* PQ MDS Platform IO Board */
-#define CONFIG_HAS_FSL_DR_USB 1 /* fixup device tree for the DR USB */ +#define CONFIG_USB_FSL_DR 1 /* fixup device tree for the DR USB */
#define CONFIG_NET_MULTI #define CONFIG_PCI_PNP /* do pci plug-and-play */ diff --git a/include/configs/MPC837XERDB.h b/include/configs/MPC837XERDB.h index d335d76..4f15be5 100644 --- a/include/configs/MPC837XERDB.h +++ b/include/configs/MPC837XERDB.h @@ -654,7 +654,7 @@ #define CONFIG_ETH1ADDR 00:04:9f:ef:04:02 #endif
-#define CONFIG_HAS_FSL_DR_USB +#define CONFIG_USB_FSL_DR 1
#define CONFIG_IPADDR 10.0.0.2 #define CONFIG_SERVERIP 10.0.0.1 diff --git a/include/fdt_support.h b/include/fdt_support.h index 6062df9..7ee29ef 100644 --- a/include/fdt_support.h +++ b/include/fdt_support.h @@ -53,12 +53,6 @@ int fdt_find_and_setprop(void *fdt, const char *node, const char *prop, const void *val, int len, int create); void fdt_fixup_qe_firmware(void *fdt);
-#ifdef CONFIG_HAS_FSL_DR_USB -void fdt_fixup_dr_usb(void *blob, bd_t *bd); -#else -static inline void fdt_fixup_dr_usb(void *blob, bd_t *bd) {} -#endif /* CONFIG_HAS_FSL_DR_USB */ - #if defined(CONFIG_MPC85xx) || defined(CONFIG_MPC83XX) void fdt_fixup_crypto_node(void *blob, int sec_rev); #else diff --git a/include/fsl_dr_usb.h b/include/fsl_dr_usb.h new file mode 100644 index 0000000..c14d9ba --- /dev/null +++ b/include/fsl_dr_usb.h @@ -0,0 +1,21 @@ +/* + * Copyright (c) 2008-2009 MontaVista Software, Inc. + * + * Author: Anton Vorontsov avorontsov@ru.mvista.com + * + * 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. + */ + +#ifndef __DR_USB_H +#define __DR_USB_H + +#ifdef CONFIG_USB_FSL_DR +void fdt_fixup_dr_usb(void *blob, bd_t *bd); +#else +static inline void fdt_fixup_dr_usb(void *blob, bd_t *bd) {} +#endif + +#endif /* __DR_USB_H */

Dear Anton Vorontsov,
In message 20090609202532.GE20493@oksana.dev.rtsoft.ru you wrote:
In subsequent patches we'll use FSL-specific functions in fdt_fixup_dr_usb(), so let's move the routine to a more appropriate place.
So far fsl_dr_usb.c isn't actually an USB driver, but eventually it will turn into one, let's hope. ;-)
Also rename CONFIG_HAS_FSL_DR_USB to CONFIG_USB_FSL_DR to be consistent with other USB drivers.
Signed-off-by: Anton Vorontsov avorontsov@ru.mvista.com
Makefile | 1 + board/freescale/mpc8315erdb/mpc8315erdb.c | 1 + board/freescale/mpc837xemds/mpc837xemds.c | 1 + board/freescale/mpc837xerdb/mpc837xerdb.c | 1 + common/fdt_support.c | 41 ---------------------- drivers/usb/otg/Makefile | 46 +++++++++++++++++++++++++ drivers/usb/otg/fsl_dr_usb.c | 52 +++++++++++++++++++++++++++++ include/configs/MPC8315ERDB.h | 2 +- include/configs/MPC837XEMDS.h | 2 +- include/configs/MPC837XERDB.h | 2 +- include/fdt_support.h | 6 --- include/fsl_dr_usb.h | 21 +++++++++++ 12 files changed, 126 insertions(+), 50 deletions(-) create mode 100644 drivers/usb/otg/Makefile create mode 100644 drivers/usb/otg/fsl_dr_usb.c create mode 100644 include/fsl_dr_usb.h
Sorry, this patch doesn't apply:
Applying: fdt_support, usb: Move fdt_fixup_dr_usb routine to drivers/usb/otg error: patch failed: common/fdt_support.c:454 error: common/fdt_support.c: patch does not apply error: patch failed: include/configs/MPC8315ERDB.h:344 error: include/configs/MPC8315ERDB.h: patch does not apply error: patch failed: include/fdt_support.h:53 error: include/fdt_support.h: patch does not apply fatal: sha1 information is lacking or useless (board/freescale/mpc837xemds/mpc837xemds.c). Repository lacks necessary blobs to fall back on 3-way merge. Cannot fall back to three-way merge. Patch failed at 0005.
Please rebase and resubmit.
Best regards,
Wolfgang Denk

Dear Anton Vorontsov,
In message 20090609202532.GE20493@oksana.dev.rtsoft.ru you wrote:
In subsequent patches we'll use FSL-specific functions in fdt_fixup_dr_usb(), so let's move the routine to a more appropriate place.
So far fsl_dr_usb.c isn't actually an USB driver, but eventually it will turn into one, let's hope. ;-)
Also rename CONFIG_HAS_FSL_DR_USB to CONFIG_USB_FSL_DR to be consistent with other USB drivers.
Signed-off-by: Anton Vorontsov avorontsov@ru.mvista.com
Makefile | 1 + board/freescale/mpc8315erdb/mpc8315erdb.c | 1 + board/freescale/mpc837xemds/mpc837xemds.c | 1 + board/freescale/mpc837xerdb/mpc837xerdb.c | 1 + common/fdt_support.c | 41 ---------------------- drivers/usb/otg/Makefile | 46 +++++++++++++++++++++++++ drivers/usb/otg/fsl_dr_usb.c | 52 +++++++++++++++++++++++++++++ include/configs/MPC8315ERDB.h | 2 +- include/configs/MPC837XEMDS.h | 2 +- include/configs/MPC837XERDB.h | 2 +- include/fdt_support.h | 6 --- include/fsl_dr_usb.h | 21 +++++++++++ 12 files changed, 126 insertions(+), 50 deletions(-) create mode 100644 drivers/usb/otg/Makefile create mode 100644 drivers/usb/otg/fsl_dr_usb.c create mode 100644 include/fsl_dr_usb.h
Sorry, doesn't apply:
Applying: fsl_dr_usb: Fixup disabled USB controllers nodes in device tree error: drivers/usb/otg/fsl_dr_usb.c: does not exist in index fatal: sha1 information is lacking or useless (drivers/usb/otg/fsl_dr_usb.c). Repository lacks necessary blobs to fall back on 3-way merge. Cannot fall back to three-way merge. Patch failed at 0006.
Please rebase and resubmit.
Best regards,
Wolfgang Denk

We should add status = "disabled" property when USB controller can't be used (for example when USB pins muxed away to another device).
Also convert whole fdt_fixup_dr_usb() to use more compact routines from fdt_support.h.
Signed-off-by: Anton Vorontsov avorontsov@ru.mvista.com --- cpu/mpc83xx/cpu.c | 4 +++ drivers/usb/otg/fsl_dr_usb.c | 60 ++++++++++++++++++++++++----------------- 2 files changed, 39 insertions(+), 25 deletions(-)
diff --git a/cpu/mpc83xx/cpu.c b/cpu/mpc83xx/cpu.c index 876f5c7..034958c 100644 --- a/cpu/mpc83xx/cpu.c +++ b/cpu/mpc83xx/cpu.c @@ -404,6 +404,10 @@ int cpu_mmc_init(bd_t *bis) #endif }
+#ifdef CONFIG_HWCONFIG +const char *cpu_hwconfig = "dr_usb"; +#endif + #ifdef CONFIG_BOOTCOUNT_LIMIT
#if !defined(CONFIG_MPC8360) diff --git a/drivers/usb/otg/fsl_dr_usb.c b/drivers/usb/otg/fsl_dr_usb.c index af9797f..345efa9 100644 --- a/drivers/usb/otg/fsl_dr_usb.c +++ b/drivers/usb/otg/fsl_dr_usb.c @@ -10,43 +10,53 @@ */
#include <common.h> -#include <libfdt.h> +#include <malloc.h> +#include <hwconfig.h> +#include <fdt_support.h>
void fdt_fixup_dr_usb(void *blob, bd_t *bd) { - char *mode; - char *type; const char *compat = "fsl-usb2-dr"; - const char *prop_mode = "dr_mode"; - const char *prop_type = "phy_type"; - int node_offset; - int err; - - mode = getenv("usb_dr_mode"); - type = getenv("usb_phy_type"); - if (!mode && !type) + const char *mode; + const char *type; + size_t modelen = 0; + size_t typelen = 0; + char *buf; + size_t bufsz; + + if (!hwconfig("dr_usb")) { + const char *reason = "disabled"; + + do_fixup_by_compat(blob, compat, "status", reason, + strlen(reason) + 1, 1); + return; + } + + mode = hwconfig_subarg("dr_usb", "mode", &modelen); + type = hwconfig_subarg("dr_usb", "phy_type", &typelen); + bufsz = max(modelen, typelen); + if (!bufsz) return;
- node_offset = fdt_node_offset_by_compatible(blob, 0, compat); - if (node_offset < 0) { - printf("WARNING: could not find compatible node %s: %s.\n", - compat, fdt_strerror(node_offset)); + buf = malloc(bufsz + 1); + if (!buf) { + printf("%s: unable to allocate memory\n", __func__); return; }
if (mode) { - err = fdt_setprop(blob, node_offset, prop_mode, mode, - strlen(mode) + 1); - if (err < 0) - printf("WARNING: could not set %s for %s: %s.\n", - prop_mode, compat, fdt_strerror(err)); + strcpy(buf, mode); + buf[modelen] = '\0'; + do_fixup_by_compat(blob, compat, "dr_mode", buf, + modelen + 1, 1); }
if (type) { - err = fdt_setprop(blob, node_offset, prop_type, type, - strlen(type) + 1); - if (err < 0) - printf("WARNING: could not set %s for %s: %s.\n", - prop_type, compat, fdt_strerror(err)); + strcpy(buf, type); + buf[typelen] = '\0'; + do_fixup_by_compat(blob, compat, "phy_type", buf, + typelen + 1, 1); } + + free(buf); }

Dear Anton Vorontsov,
In message 20090609202534.GF20493@oksana.dev.rtsoft.ru you wrote:
We should add status = "disabled" property when USB controller can't be used (for example when USB pins muxed away to another device).
Also convert whole fdt_fixup_dr_usb() to use more compact routines from fdt_support.h.
Signed-off-by: Anton Vorontsov avorontsov@ru.mvista.com
cpu/mpc83xx/cpu.c | 4 +++ drivers/usb/otg/fsl_dr_usb.c | 60 ++++++++++++++++++++++++----------------- 2 files changed, 39 insertions(+), 25 deletions(-)
[Oops, please ignore previous reply to wrong patch submission.]
Does not apply:
Applying: fsl_dr_usb: Fixup disabled USB controllers nodes in device tree error: drivers/usb/otg/fsl_dr_usb.c: does not exist in index fatal: sha1 information is lacking or useless (drivers/usb/otg/fsl_dr_usb.c). Repository lacks necessary blobs to fall back on 3-way merge. Cannot fall back to three-way merge. Patch failed at 0006.
Please rebase and resubmit.
Best regards,
Wolfgang Denk

This patch simply converts the board to the hwconfig infrastructure.
Signed-off-by: Anton Vorontsov avorontsov@ru.mvista.com --- board/freescale/mpc8315erdb/mpc8315erdb.c | 14 +++++--------- include/configs/MPC8315ERDB.h | 1 + 2 files changed, 6 insertions(+), 9 deletions(-)
diff --git a/board/freescale/mpc8315erdb/mpc8315erdb.c b/board/freescale/mpc8315erdb/mpc8315erdb.c index 9d6896d..d9cff86 100644 --- a/board/freescale/mpc8315erdb/mpc8315erdb.c +++ b/board/freescale/mpc8315erdb/mpc8315erdb.c @@ -24,6 +24,7 @@ */
#include <common.h> +#include <hwconfig.h> #include <i2c.h> #include <libfdt.h> #include <fdt_support.h> @@ -177,20 +178,15 @@ void pci_init_board(void) #if defined(CONFIG_OF_BOARD_SETUP) void fdt_tsec1_fixup(void *fdt, bd_t *bd) { - char *mpc8315erdb = getenv("mpc8315erdb"); const char disabled[] = "disabled"; const char *path; int ret;
- if (!mpc8315erdb) + if (hwconfig_arg_cmp("board_type", "tsec1")) { return; - - if (!strcmp(mpc8315erdb, "tsec1")) { - return; - } else if (strcmp(mpc8315erdb, "ulpi")) { - printf("WARNING: wrong `mpc8315erdb' environment " - "variable specified: `%s'. Should be `ulpi' " - "or `tsec1'.\n", mpc8315erdb); + } else if (!hwconfig_arg_cmp("board_type", "ulpi")) { + printf("NOTICE: No or unknown board_type hwconfig specified.\n" + " Assuming board with TSEC1.\n"); return; }
diff --git a/include/configs/MPC8315ERDB.h b/include/configs/MPC8315ERDB.h index e3dcf96..6ed3a9f 100644 --- a/include/configs/MPC8315ERDB.h +++ b/include/configs/MPC8315ERDB.h @@ -72,6 +72,7 @@ #define CONFIG_SYS_SICRL 0x00000000 /* 3.3V, no delay */
#define CONFIG_BOARD_EARLY_INIT_F /* call board_pre_init */ +#define CONFIG_HWCONFIG
/* * IMMR new address

Dear Anton Vorontsov,
In message 20090609202536.GG20493@oksana.dev.rtsoft.ru you wrote:
This patch simply converts the board to the hwconfig infrastructure.
Signed-off-by: Anton Vorontsov avorontsov@ru.mvista.com
board/freescale/mpc8315erdb/mpc8315erdb.c | 14 +++++--------- include/configs/MPC8315ERDB.h | 1 + 2 files changed, 6 insertions(+), 9 deletions(-)
Applied, thanks.
Best regards,
Wolfgang Denk

Since we have simple hwconfig interface now, we don't need pci_external_arbiter variable any longer.
Signed-off-by: Anton Vorontsov avorontsov@ru.mvista.com --- board/freescale/mpc837xemds/mpc837xemds.c | 3 +-- 1 files changed, 1 insertions(+), 2 deletions(-)
diff --git a/board/freescale/mpc837xemds/mpc837xemds.c b/board/freescale/mpc837xemds/mpc837xemds.c index 76b5430..4041416 100644 --- a/board/freescale/mpc837xemds/mpc837xemds.c +++ b/board/freescale/mpc837xemds/mpc837xemds.c @@ -293,10 +293,9 @@ int board_pci_host_broken(void) { struct immap __iomem *im = (struct immap __iomem *)CONFIG_SYS_IMMR; const u32 rcw_mask = HRCWH_PCI1_ARBITER_ENABLE | HRCWH_PCI_HOST; - const char *pci_ea = getenv("pci_external_arbiter");
/* It's always OK in case of external arbiter. */ - if (pci_ea && !strcmp(pci_ea, "yes")) + if (hwconfig_subarg_cmp("pci", "arbiter", "external")) return 0;
if ((in_be32(&im->reset.rcwh) & rcw_mask) != rcw_mask)

Dear Anton Vorontsov,
In message 20090609202538.GH20493@oksana.dev.rtsoft.ru you wrote:
Since we have simple hwconfig interface now, we don't need pci_external_arbiter variable any longer.
Signed-off-by: Anton Vorontsov avorontsov@ru.mvista.com
board/freescale/mpc837xemds/mpc837xemds.c | 3 +-- 1 files changed, 1 insertions(+), 2 deletions(-)
Applied, thanks.
Best regards,
Wolfgang Denk

On Wed, 10 Jun 2009 00:23:28 +0400 Anton Vorontsov avorontsov@ru.mvista.com wrote:
On Fri, May 01, 2009 at 12:31:54AM +0200, Wolfgang Denk wrote:
Dear Anton,
In message 20090429215000.GA1092@oksana.dev.rtsoft.ru you wrote:
This patch implements simple hwconfig infrastructure: an interface for software knobs to control a hardware.
Thanks a lot.
We support hwconfig options with arguments. For example,
set hwconfig dr_usb,dr_usb_mode:peripheral,dr_usb_phy_type:ulpi
There are three hwconfig options selected:
- dr_usb - enable Dual-Role USB controller;
- dr_usb_mode:peripheral - USB in Function mode;
- dr_usb_phy_type:ulpi - USB should work with ULPI PHYs.
That gives a lot of typing, which in turn results in lots of typing errors, which in this case are probably nasty to debug.
Suggestion: instead of
set hwconfig dr_usb,dr_usb_mode:peripheral,dr_usb_phy_type:ulpi
use:
set hwconfig dr_usb:mode=peripheral,phy_type=ulpi
What do you think?
Sorry for the delay. Done. New patches on the way.
I had made a similar comment to the original hwconfig posting that appears to have been missed:
http://lists.denx.de/pipermail/u-boot/2009-April/051845.html
the existing syntax is flawed, e.g., what is the separator character going to be when you want to configure something more than dr_usb using the syntax used in this patchseries? And can we adopt a syntax that's more familiar (or recognizable) to our users from the outset?
Kim

On Thu, Jun 11, 2009 at 09:09:56AM -0500, Kim Phillips wrote: [...]
Suggestion: instead of
set hwconfig dr_usb,dr_usb_mode:peripheral,dr_usb_phy_type:ulpi
use:
set hwconfig dr_usb:mode=peripheral,phy_type=ulpi
What do you think?
Sorry for the delay. Done. New patches on the way.
I had made a similar comment to the original hwconfig posting that appears to have been missed:
http://lists.denx.de/pipermail/u-boot/2009-April/051845.html
I didn't miss it. ;-)
the existing syntax is flawed, e.g., what is the separator character going to be when you want to configure something more than dr_usb using the syntax used in this patchseries?
The separator between options is ';', between sub-options is ','.
So that would be 'dr_usb:mode=host,phy_type=ulpi; esdhc".
Which translates to
dr_usb { mode = host; phy_type = ulpi; };
esdhc;
And can we adopt a syntax that's more familiar (or recognizable) to our users from the outset?
Sure, I'm open to suggestions. Originally you proposed this scheme:
set hwconfig "usb=dr; dr_usb_mode=peripheral; dr_usb_phy_type=ulpi"
But Wolfgang proposed options and sub-options to save some typing (notice the repetitive dr_usb), so there should be two assignment symbols and two symbols for separation.
Thanks,

On Thu, 11 Jun 2009 18:39:43 +0400 Anton Vorontsov avorontsov@ru.mvista.com wrote:
On Thu, Jun 11, 2009 at 09:09:56AM -0500, Kim Phillips wrote: [...]
Suggestion: instead of
set hwconfig dr_usb,dr_usb_mode:peripheral,dr_usb_phy_type:ulpi
use:
set hwconfig dr_usb:mode=peripheral,phy_type=ulpi
What do you think?
Sorry for the delay. Done. New patches on the way.
I had made a similar comment to the original hwconfig posting that appears to have been missed:
http://lists.denx.de/pipermail/u-boot/2009-April/051845.html
I didn't miss it. ;-)
this repost didn't make that instantly clear enough to me ;-)
the existing syntax is flawed, e.g., what is the separator character going to be when you want to configure something more than dr_usb using the syntax used in this patchseries?
The separator between options is ';', between sub-options is ','.
So that would be 'dr_usb:mode=host,phy_type=ulpi; esdhc".
Which translates to
dr_usb { mode = host; phy_type = ulpi; };
esdhc;
And can we adopt a syntax that's more familiar (or recognizable) to our users from the outset?
Sure, I'm open to suggestions. Originally you proposed this scheme:
set hwconfig "usb=dr; dr_usb_mode=peripheral; dr_usb_phy_type=ulpi"
But Wolfgang proposed options and sub-options to save some typing (notice the repetitive dr_usb), so there should be two assignment symbols and two symbols for separation.
if you don't want to type, things like this are possible but they have to depend on the order given:
dr_usb.mode = host; .phy_type = ulpi; esdhc;
however when automating/scripting concatenation of them, it's useful to not have to depend on their order:
dr_usb.mode = host; esdhc; dr_usb.phy_type = ulpi;
...so as you can see I've come up with the dot ('.') in order to eliminate the less familiar (and therefore more misleading) colon (':').
What do you think?
Kim
p.s., your representation above is the best, but now it's starting to look like the frontend to a C compiler:
"dr_usb { mode = host; phy_type = ulpi; }; esdhc;"

Dear Kim Phillips,
In message 20090611105533.7aeec1ee.kim.phillips@freescale.com you wrote:
The separator between options is ';', between sub-options is ','.
So that would be 'dr_usb:mode=host,phy_type=ulpi; esdhc".
...and that's still what I like most of the differnet formats discussed so far.
if you don't want to type, things like this are possible but they have to depend on the order given:
It's not only about not typing, it's also about being able to read it easily.
dr_usb.mode = host; .phy_type = ulpi; esdhc;
however when automating/scripting concatenation of them, it's useful to not have to depend on their order:
dr_usb.mode = host; esdhc; dr_usb.phy_type = ulpi;
I see no reason that we need to support such a format. In C, you also cannot mix initializations of fields from different structures :-)
What do you think?
'dr_usb:mode=host,phy_type=ulpi; esdhc" still looks reasonable to me.
Best regards,
Wolfgang Denk

On Thu, 11 Jun 2009 18:03:51 +0200 Wolfgang Denk wd@denx.de wrote:
Dear Kim Phillips,
In message 20090611105533.7aeec1ee.kim.phillips@freescale.com you wrote:
The separator between options is ';', between sub-options is ','.
So that would be 'dr_usb:mode=host,phy_type=ulpi; esdhc".
...and that's still what I like most of the differnet formats discussed so far.
if you don't want to type, things like this are possible but they have to depend on the order given:
It's not only about not typing, it's also about being able to read it easily.
right, which it currently isn't, due to conflicting precedence levels for the different operator characters chosen.
btw, there should be no severe loss of readability here:
dr_usb.mode = host; .phy_type = ulpi; esdhc;
...
however when automating/scripting concatenation of them, it's useful to not have to depend on their order:
dr_usb.mode = host; esdhc; dr_usb.phy_type = ulpi;
I see no reason that we need to support such a format. In C, you also cannot mix initializations of fields from different structures :-)
I view these as regular assignments, not initializations :)
What do you think?
'dr_usb:mode=host,phy_type=ulpi; esdhc" still looks reasonable to me.
the ':', which, in C, would be as though we're specifying a bit-field, and, in English, has higher precedence than ';' which makes it confusing because ';' is used elsewhere with higher precedence than the ':'. I'd almost prefer a space instead, making:
"dr_usb mode=host, phy_type=ulpi; esdhc"
but the dot operator '.' is the best candidate since it accurately represents /member/ access.
just my 2c.
Kim

On Thu, Jun 11, 2009 at 10:55:33AM -0500, Kim Phillips wrote: [...]
if you don't want to type, things like this are possible but they have to depend on the order given:
dr_usb.mode = host; .phy_type = ulpi; esdhc;
however when automating/scripting concatenation of them, it's useful to not have to depend on their order:
dr_usb.mode = host; esdhc; dr_usb.phy_type = ulpi;
...so as you can see I've come up with the dot ('.') in order to eliminate the less familiar (and therefore more misleading) colon (':').
What do you think?
"dr_usb.mode = host; .phy_type = ulpi; esdhc;" <- that isn't obvious that .phy_type is a continuation of dr_usb. :-/
It's kind of more special format then the original...
Kim
p.s., your representation above is the best, but now it's starting to look like the frontend to a C compiler:
"dr_usb { mode = host; phy_type = ulpi; }; esdhc;"
I like it too: http://lists.denx.de/pipermail/u-boot/2009-May/051875.html
Wolfgang replied that we should keep things simple, and if we want something complicated we should use device-tree: http://lists.denx.de/pipermail/u-boot/2009-May/051886.html
Since hwconfig is designed to be *simple* hw configuration interface, I tend to agree with Wolfgang.
Technically we don't need hwconfig, it is only needed to make configuration easier for reference boards that have quite a lot of hw options. Hwconfig can be substituted by
# mw 0x... 0x... # manually modify some bcsrs # mw 0x... 0x... # manually modify pinmux # fdt addr ... # now manually fixup the device tree # fdt set ... ... # fdt mknode ... ...
In a final product you barely need the hwconfig stuff, because product boards only define things they use (and that's why we must keep things working without CONFIG_HWCONFIG).
Thanks,

On Thu, 11 Jun 2009 21:01:23 +0400 Anton Vorontsov avorontsov@ru.mvista.com wrote:
"dr_usb.mode = host; .phy_type = ulpi; esdhc;" <- that isn't obvious that .phy_type is a continuation of dr_usb. :-/
It's kind of more special format then the original...
special, eh? ;)
Wolfgang replied that we should keep things simple, and if we want something complicated we should use device-tree: http://lists.denx.de/pipermail/u-boot/2009-May/051886.html
so until u-boot engulfs the dtc, for the mpc83xx parts:
Acked-by: Kim Phillips kim.phillips@freescale.com
..in case Wolfgang Denk wants to pick up the entire series and put it in his next branch (appropriate enough).
Kim

On Thu, Jun 11, 2009 at 04:53:50PM -0500, Kim Phillips wrote:
On Thu, 11 Jun 2009 21:01:23 +0400 Anton Vorontsov avorontsov@ru.mvista.com wrote:
"dr_usb.mode = host; .phy_type = ulpi; esdhc;" <- that isn't obvious that .phy_type is a continuation of dr_usb. :-/
It's kind of more special format then the original...
special, eh? ;)
Wolfgang replied that we should keep things simple, and if we want something complicated we should use device-tree: http://lists.denx.de/pipermail/u-boot/2009-May/051886.html
so until u-boot engulfs the dtc, for the mpc83xx parts:
Acked-by: Kim Phillips kim.phillips@freescale.com
..in case Wolfgang Denk wants to pick up the entire series and put it in his next branch (appropriate enough).
Hi Kim, Wolfgang,
Any news on this?
Thanks,

On Tue, 7 Jul 2009 16:19:20 +0400 Anton Vorontsov avorontsov@ru.mvista.com wrote:
Wolfgang replied that we should keep things simple, and if we want something complicated we should use device-tree: http://lists.denx.de/pipermail/u-boot/2009-May/051886.html
so until u-boot engulfs the dtc, for the mpc83xx parts:
Acked-by: Kim Phillips kim.phillips@freescale.com
..in case Wolfgang Denk wants to pick up the entire series and put it in his next branch (appropriate enough).
Hi Kim, Wolfgang,
Any news on this?
Wolfgang, if you have no objection, please apply directly.
Thanks,
Kim

Dear Kim Phillips,
In message 20090707173804.acc352f9.kim.phillips@freescale.com you wrote:
Any news on this?
Wolfgang, if you have no objection, please apply directly.
Done.
Best regards,
Wolfgang Denk

On Thu, Jul 16, 2009 at 10:52:13PM +0200, Wolfgang Denk wrote:
Dear Kim Phillips,
In message 20090707173804.acc352f9.kim.phillips@freescale.com you wrote:
Any news on this?
Wolfgang, if you have no objection, please apply directly.
Done.
Thanks a lot, Wolfgang!

On Jul 16, 2009, at 4:06 PM, Anton Vorontsov wrote:
On Thu, Jul 16, 2009 at 10:52:13PM +0200, Wolfgang Denk wrote:
Dear Kim Phillips,
In message 20090707173804.acc352f9.kim.phillips@freescale.com you wrote:
Any news on this?
Wolfgang, if you have no objection, please apply directly.
Done.
Thanks a lot, Wolfgang!
Anton,
Do we need some version of these patches for MPC8536 DS & eSDHC support?
- k
participants (4)
-
Anton Vorontsov
-
Kim Phillips
-
Kumar Gala
-
Wolfgang Denk