All of lore.kernel.org
 help / color / mirror / Atom feed
* [U-Boot] [PATCH 0/8] hwconfig and some its users (was: Re: [PATCH 2/6] Add FSL "Can use" framework)
@ 2009-04-29 21:48 Anton Vorontsov
  2009-04-29 21:50 ` [U-Boot] [PATCH 1/8] Add simple hwconfig infrastructure Anton Vorontsov
                   ` (7 more replies)
  0 siblings, 8 replies; 17+ messages in thread
From: Anton Vorontsov @ 2009-04-29 21:48 UTC (permalink / raw)
  To: u-boot

On Thu, Feb 19, 2009 at 08:56:50PM +0100, Wolfgang Denk wrote:
> Dear Anton Vorontsov,
> 
> In message <20090219154545.GB26618@oksana.dev.rtsoft.ru> you wrote:
> > So far it's used for specifying whether we want to use FSL DR USB or
> > FSL eSDHC devices on MPC837X processors.
> > 
> > There are two more candidates for future use:
> > 1. USB ULPI PHY vs. TSEC1 on MPC8315E-RDB boards;
> > 2. Marvell vs. Vitesse PHYs on MPC8313E-RDB boards.
> 
> If you know that might need to be extended, than better plan for it
> right from the beginning.

OK. Done.

> > diff --git a/board/freescale/common/fsl_can_use.c b/board/freescale/common/fsl_can_use.c
> > new file mode 100644
> > index 0000000..17cc20f
> > --- /dev/null
> > +++ b/board/freescale/common/fsl_can_use.c
> 
> That's a very strange name for a function, IMHO. I would expect that
> it has something to do with using a CAN controller...
> 
> > +int __fsl_can_use_dr_usb(void)
> 
> If you plan to make this extendable, please use a more generic name.
> For example: fsl_hwconfig() [note that leading __ is reserved].
> 
> > +	const char *usb_or_esdhc = getenv("usb_or_esdhc");
> 
> Please make it extendable, use a more generic name for one (and only
> one) environment variable. It makes littel sense to pollyte the
> envrionment with N additional variables. For example, call it
> "hwconfig". Allow that this variable holds a list of config settings,
> separated for example by comma or colon or ...
> 
> > +	if (!usb_or_esdhc || !strcmp(usb_or_esdhc, "usb"))
> > +		return 1;
> > +
> > +	if (!strcmp(usb_or_esdhc, "esdhc"))
> > +		return 0;
> 
> This doesn't scale as well. Use a table of known strings and (static
> inline) function pointers - this is much easier to extend when new
> options need to get added.
> 
> 
> Once we've reached this point, we might even lean back and think which
> part of this is FSL specific. None, tight? So make this a generic
> feature and look around which other code can be replaced by it.
> 
> We can probably define both the content of option name / handler
> function pointer table and the respective handler functions in a board
> specific file - eventually even the board config file.
> 
> That would make for a flexible solution.

Here it is, patches on the way. It's very simple. Just an
environment variable, but it should be enough to do what
we need currently. I should write some documentation
though.

Thanks?

-- 
Anton Vorontsov
email: cbouatmailru at gmail.com
irc://irc.freenode.net/bd2

^ permalink raw reply	[flat|nested] 17+ messages in thread

* [U-Boot] [PATCH 1/8] Add simple hwconfig infrastructure
  2009-04-29 21:48 [U-Boot] [PATCH 0/8] hwconfig and some its users (was: Re: [PATCH 2/6] Add FSL "Can use" framework) Anton Vorontsov
@ 2009-04-29 21:50 ` Anton Vorontsov
  2009-04-29 21:59   ` Anton Vorontsov
                     ` (3 more replies)
  2009-04-29 21:50 ` [U-Boot] [PATCH 2/8] fsl_esdhc: Add device tree fixups Anton Vorontsov
                   ` (6 subsequent siblings)
  7 siblings, 4 replies; 17+ messages in thread
From: Anton Vorontsov @ 2009-04-29 21:50 UTC (permalink / raw)
  To: u-boot

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,dr_usb_mode:peripheral,dr_usb_phy_type:ulpi

   There are three hwconfig options selected:
   1. dr_usb - enable Dual-Role USB controller;
   2. dr_usb_mode:peripheral - USB in Function mode;
   3. 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  |  134 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 include/hwconfig.h |   46 ++++++++++++++++++
 3 files changed, 181 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..c9a6712
--- /dev/null
+++ b/common/hwconfig.c
@@ -0,0 +1,134 @@
+/*
+ * 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 <exports.h>
+#include <hwconfig.h>
+#include <linux/types.h>
+#include <linux/string.h>
+
+static const char *hwconfig_parse(const char *opts, const char *opt,
+				  size_t *arglen)
+{
+	size_t optlen = strlen(opt);
+	char *str = strstr(opts, opt);
+	const char *end = str + optlen;
+
+	if (str && (str == opts || str[-1] == ',' ) &&
+			(*end == ',' || *end == ':' || *end == '\0')) {
+		const char *arg_end;
+
+		if (!arglen)
+			return str;
+
+		if (*end != ':')
+			return NULL;
+
+		arg_end = strchr(str, ',');
+		if (!arg_end)
+			*arglen = strlen(str) - optlen - 1;
+		else
+			*arglen = arg_end - end - 1;
+
+		return end + 1;
+	}
+	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, opt, arglen);
+
+	if (board_hwconfig)
+		return hwconfig_parse(board_hwconfig, opt, arglen);
+
+	if (cpu_hwconfig)
+		return hwconfig_parse(cpu_hwconfig, opt, arglen);
+
+	return NULL;
+}
+
+/*
+ * hwconfig - query if a particular hardware option should be used
+ * @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 - query if a particular hardware option should be used
+ * @opt:	a string representing an option
+ * @arglen:	a pointer to an allocated size_t variable
+ *
+ * This call can be used to find out whether U-Boot should configure
+ * a particular hardware option.
+ *
+ * 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's arguments
+ * @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 1 if @arg matches, 0 otherwise.
+ *
+ * If CONFIG_HWCONFIG is undefined, the function returns 1, 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)
+		return 0;
+
+	return !strncmp(argstr, arg, arglen + 1);
+}
diff --git a/include/hwconfig.h b/include/hwconfig.h
new file mode 100644
index 0000000..704086a
--- /dev/null
+++ b/include/hwconfig.h
@@ -0,0 +1,46 @@
+/*
+ * 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);
+
+#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 0;
+}
+
+#endif /* CONFIG_HWCONFIG */
+
+#endif /* _HWCONFIG_H */
-- 
1.6.2.2

^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [U-Boot] [PATCH 2/8] fsl_esdhc: Add device tree fixups
  2009-04-29 21:48 [U-Boot] [PATCH 0/8] hwconfig and some its users (was: Re: [PATCH 2/6] Add FSL "Can use" framework) Anton Vorontsov
  2009-04-29 21:50 ` [U-Boot] [PATCH 1/8] Add simple hwconfig infrastructure Anton Vorontsov
@ 2009-04-29 21:50 ` Anton Vorontsov
  2009-04-29 21:50 ` [U-Boot] [PATCH 3/8] mpc83xx: MPC837XERDB: Add support for FSL eSDHC Anton Vorontsov
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 17+ messages in thread
From: Anton Vorontsov @ 2009-04-29 21:50 UTC (permalink / raw)
  To: u-boot

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 |   22 ++++++++++++++++++++++
 include/fsl_esdhc.h     |    8 ++++++++
 2 files changed, 30 insertions(+), 0 deletions(-)

diff --git a/drivers/mmc/fsl_esdhc.c b/drivers/mmc/fsl_esdhc.c
index 0ba45cd..3929634 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,23 @@ int fsl_esdhc_mmc_init(bd_t *bis)
 {
 	return esdhc_initialize(bis);
 }
+
+#ifdef CONFIG_MPC85xx
+#define ESDHC_COMPATIBLE "fsl,mpc8536-esdhc"
+#else
+#define ESDHC_COMPATIBLE "fsl,mpc8379-esdhc"
+#endif
+
+void fdt_fixup_esdhc(void *blob, bd_t *bd)
+{
+	if (!hwconfig("esdhc")) {
+		const char *reason = "disabled";
+
+		do_fixup_by_compat(blob, ESDHC_COMPATIBLE, "status", reason,
+				   strlen(reason) + 1, 1);
+		return;
+	}
+
+	do_fixup_by_compat_u32(blob, ESDHC_COMPATIBLE, "clock-frequency",
+			       gd->sdhc_clk, 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__ */
-- 
1.6.2.2

^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [U-Boot] [PATCH 3/8] mpc83xx: MPC837XERDB: Add support for FSL eSDHC
  2009-04-29 21:48 [U-Boot] [PATCH 0/8] hwconfig and some its users (was: Re: [PATCH 2/6] Add FSL "Can use" framework) Anton Vorontsov
  2009-04-29 21:50 ` [U-Boot] [PATCH 1/8] Add simple hwconfig infrastructure Anton Vorontsov
  2009-04-29 21:50 ` [U-Boot] [PATCH 2/8] fsl_esdhc: Add device tree fixups Anton Vorontsov
@ 2009-04-29 21:50 ` Anton Vorontsov
  2009-04-29 21:50 ` [U-Boot] [PATCH 4/8] mpc83xx: MPC837XEMDS: Fixup eSDHC nodes in device tree Anton Vorontsov
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 17+ messages in thread
From: Anton Vorontsov @ 2009-04-29 21:50 UTC (permalink / raw)
  To: u-boot

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
  */
-- 
1.6.2.2

^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [U-Boot] [PATCH 4/8] mpc83xx: MPC837XEMDS: Fixup eSDHC nodes in device tree
  2009-04-29 21:48 [U-Boot] [PATCH 0/8] hwconfig and some its users (was: Re: [PATCH 2/6] Add FSL "Can use" framework) Anton Vorontsov
                   ` (2 preceding siblings ...)
  2009-04-29 21:50 ` [U-Boot] [PATCH 3/8] mpc83xx: MPC837XERDB: Add support for FSL eSDHC Anton Vorontsov
@ 2009-04-29 21:50 ` Anton Vorontsov
  2009-04-29 21:50 ` [U-Boot] [PATCH 5/8] fdt_support, usb: Move fdt_fixup_dr_usb routine to drivers/usb/otg Anton Vorontsov
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 17+ messages in thread
From: Anton Vorontsov @ 2009-04-29 21:50 UTC (permalink / raw)
  To: u-boot

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
-- 
1.6.2.2

^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [U-Boot] [PATCH 5/8] fdt_support, usb: Move fdt_fixup_dr_usb routine to drivers/usb/otg
  2009-04-29 21:48 [U-Boot] [PATCH 0/8] hwconfig and some its users (was: Re: [PATCH 2/6] Add FSL "Can use" framework) Anton Vorontsov
                   ` (3 preceding siblings ...)
  2009-04-29 21:50 ` [U-Boot] [PATCH 4/8] mpc83xx: MPC837XEMDS: Fixup eSDHC nodes in device tree Anton Vorontsov
@ 2009-04-29 21:50 ` Anton Vorontsov
  2009-04-29 21:50 ` [U-Boot] [PATCH 6/8] fsl_dr_usb: Fixup disabled USB controllers nodes in device tree Anton Vorontsov
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 17+ messages in thread
From: Anton Vorontsov @ 2009-04-29 21:50 UTC (permalink / raw)
  To: u-boot

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 c52894c..fe3a323 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 at 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 */
-- 
1.6.2.2

^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [U-Boot] [PATCH 6/8] fsl_dr_usb: Fixup disabled USB controllers nodes in device tree
  2009-04-29 21:48 [U-Boot] [PATCH 0/8] hwconfig and some its users (was: Re: [PATCH 2/6] Add FSL "Can use" framework) Anton Vorontsov
                   ` (4 preceding siblings ...)
  2009-04-29 21:50 ` [U-Boot] [PATCH 5/8] fdt_support, usb: Move fdt_fixup_dr_usb routine to drivers/usb/otg Anton Vorontsov
@ 2009-04-29 21:50 ` Anton Vorontsov
  2009-04-29 21:50 ` [U-Boot] [PATCH 7/8] mpc83xx: MPC8315ERDB: Use hwconfig for board type selection Anton Vorontsov
  2009-04-29 21:50 ` [U-Boot] [PATCH 8/8] mpc83xx: MPC837xEMDS: Use hwconfig instead of pci_external_arbiter variable Anton Vorontsov
  7 siblings, 0 replies; 17+ messages in thread
From: Anton Vorontsov @ 2009-04-29 21:50 UTC (permalink / raw)
  To: u-boot

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..97584f8 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_arg("dr_usb_mode", &modelen);
+	type = hwconfig_arg("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);
 }
-- 
1.6.2.2

^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [U-Boot] [PATCH 7/8] mpc83xx: MPC8315ERDB: Use hwconfig for board type selection
  2009-04-29 21:48 [U-Boot] [PATCH 0/8] hwconfig and some its users (was: Re: [PATCH 2/6] Add FSL "Can use" framework) Anton Vorontsov
                   ` (5 preceding siblings ...)
  2009-04-29 21:50 ` [U-Boot] [PATCH 6/8] fsl_dr_usb: Fixup disabled USB controllers nodes in device tree Anton Vorontsov
@ 2009-04-29 21:50 ` Anton Vorontsov
  2009-04-29 21:50 ` [U-Boot] [PATCH 8/8] mpc83xx: MPC837xEMDS: Use hwconfig instead of pci_external_arbiter variable Anton Vorontsov
  7 siblings, 0 replies; 17+ messages in thread
From: Anton Vorontsov @ 2009-04-29 21:50 UTC (permalink / raw)
  To: u-boot

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
-- 
1.6.2.2

^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [U-Boot] [PATCH 8/8] mpc83xx: MPC837xEMDS: Use hwconfig instead of pci_external_arbiter variable
  2009-04-29 21:48 [U-Boot] [PATCH 0/8] hwconfig and some its users (was: Re: [PATCH 2/6] Add FSL "Can use" framework) Anton Vorontsov
                   ` (6 preceding siblings ...)
  2009-04-29 21:50 ` [U-Boot] [PATCH 7/8] mpc83xx: MPC8315ERDB: Use hwconfig for board type selection Anton Vorontsov
@ 2009-04-29 21:50 ` Anton Vorontsov
  7 siblings, 0 replies; 17+ messages in thread
From: Anton Vorontsov @ 2009-04-29 21:50 UTC (permalink / raw)
  To: u-boot

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..a9ffc70 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_arg_cmp("pci_arbiter", "external"))
 		return 0;
 
 	if ((in_be32(&im->reset.rcwh) & rcw_mask) != rcw_mask)
-- 
1.6.2.2

^ permalink raw reply related	[flat|nested] 17+ messages in thread

* [U-Boot] [PATCH 1/8] Add simple hwconfig infrastructure
  2009-04-29 21:50 ` [U-Boot] [PATCH 1/8] Add simple hwconfig infrastructure Anton Vorontsov
@ 2009-04-29 21:59   ` Anton Vorontsov
  2009-04-30 20:00   ` Kim Phillips
                     ` (2 subsequent siblings)
  3 siblings, 0 replies; 17+ messages in thread
From: Anton Vorontsov @ 2009-04-29 21:59 UTC (permalink / raw)
  To: u-boot

On Thu, Apr 30, 2009 at 01:50:00AM +0400, Anton Vorontsov wrote:
[..]
> +/*

Just noticed that I missed kerneldoc starting comment.
It should be /**, will fix.

-- 
Anton Vorontsov
email: cbouatmailru at gmail.com
irc://irc.freenode.net/bd2

^ permalink raw reply	[flat|nested] 17+ messages in thread

* [U-Boot] [PATCH 1/8] Add simple hwconfig infrastructure
  2009-04-29 21:50 ` [U-Boot] [PATCH 1/8] Add simple hwconfig infrastructure Anton Vorontsov
  2009-04-29 21:59   ` Anton Vorontsov
@ 2009-04-30 20:00   ` Kim Phillips
  2009-04-30 20:22     ` Anton Vorontsov
  2009-04-30 22:31   ` Wolfgang Denk
  2009-06-02 20:51   ` Andy Fleming
  3 siblings, 1 reply; 17+ messages in thread
From: Kim Phillips @ 2009-04-30 20:00 UTC (permalink / raw)
  To: u-boot

On Thu, 30 Apr 2009 01:50:00 +0400
Anton Vorontsov <avorontsov@ru.mvista.com> 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:
> 
> 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,dr_usb_mode:peripheral,dr_usb_phy_type:ulpi

so a newbie displays his board's environment and sees the above line
for the first time.  It's not clear whether they will interpret the
above as how you would have them:

>    There are three hwconfig options selected:
>    1. dr_usb - enable Dual-Role USB controller;
>    2. dr_usb_mode:peripheral - USB in Function mode;
>    3. dr_usb_phy_type:ulpi - USB should work with ULPI PHYs.

or as something starting along the lines of "dr_usb and/or dr_usb_mode
acquire the 'peripheral' setting,..." and then realize
"peripheral,dr_usb_phy_type" doesn't make much sense, and have to
revert to applying different 'weights' to the comma (,) and colon (:)
token separator characters (to a native English speaker, a colon has
a higher separation weight than the comma).

May I suggest something more clearer on the outset, such as:

set hwconfig "dr_usb=enable; dr_usb_mode=peripheral; dr_usb_phy_type=ulpi"

or

set hwconfig "usb=dr; dr_usb_mode=peripheral; dr_usb_phy_type=ulpi"

> 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.

phew, you had me for a second there :).

Kim

^ permalink raw reply	[flat|nested] 17+ messages in thread

* [U-Boot] [PATCH 1/8] Add simple hwconfig infrastructure
  2009-04-30 20:00   ` Kim Phillips
@ 2009-04-30 20:22     ` Anton Vorontsov
  0 siblings, 0 replies; 17+ messages in thread
From: Anton Vorontsov @ 2009-04-30 20:22 UTC (permalink / raw)
  To: u-boot

On Thu, Apr 30, 2009 at 03:00:50PM -0500, Kim Phillips wrote:
> On Thu, 30 Apr 2009 01:50:00 +0400
> Anton Vorontsov <avorontsov@ru.mvista.com> 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:
> > 
> > 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,dr_usb_mode:peripheral,dr_usb_phy_type:ulpi
> 
> so a newbie displays his board's environment and sees the above line
> for the first time.  It's not clear whether they will interpret the
> above as how you would have them:
> 
> >    There are three hwconfig options selected:
> >    1. dr_usb - enable Dual-Role USB controller;
> >    2. dr_usb_mode:peripheral - USB in Function mode;
> >    3. dr_usb_phy_type:ulpi - USB should work with ULPI PHYs.
> 
> or as something starting along the lines of "dr_usb and/or dr_usb_mode
> acquire the 'peripheral' setting,..." and then realize
> "peripheral,dr_usb_phy_type" doesn't make much sense, and have to
> revert to applying different 'weights' to the comma (,) and colon (:)
> token separator characters (to a native English speaker, a colon has
> a higher separation weight than the comma).
> 
> May I suggest something more clearer on the outset, such as:
> 
> set hwconfig "dr_usb=enable; dr_usb_mode=peripheral; dr_usb_phy_type=ulpi"
> 
> or
> 
> set hwconfig "usb=dr; dr_usb_mode=peripheral; dr_usb_phy_type=ulpi"

Yes, much more readable. Will implement.


Thanks!

-- 
Anton Vorontsov
email: cbouatmailru at gmail.com
irc://irc.freenode.net/bd2

^ permalink raw reply	[flat|nested] 17+ messages in thread

* [U-Boot] [PATCH 1/8] Add simple hwconfig infrastructure
  2009-04-29 21:50 ` [U-Boot] [PATCH 1/8] Add simple hwconfig infrastructure Anton Vorontsov
  2009-04-29 21:59   ` Anton Vorontsov
  2009-04-30 20:00   ` Kim Phillips
@ 2009-04-30 22:31   ` Wolfgang Denk
  2009-04-30 23:12     ` Anton Vorontsov
  2009-06-02 20:51   ` Andy Fleming
  3 siblings, 1 reply; 17+ messages in thread
From: Wolfgang Denk @ 2009-04-30 22:31 UTC (permalink / raw)
  To: u-boot

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.

> 3. 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:
>    1. dr_usb - enable Dual-Role USB controller;
>    2. dr_usb_mode:peripheral - USB in Function mode;
>    3. 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?


Best regards,

Wolfgang Denk

-- 
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
Copy from one, it's plagiarism; copy from two, it's research.

^ permalink raw reply	[flat|nested] 17+ messages in thread

* [U-Boot] [PATCH 1/8] Add simple hwconfig infrastructure
  2009-04-30 22:31   ` Wolfgang Denk
@ 2009-04-30 23:12     ` Anton Vorontsov
  2009-05-01  7:33       ` Wolfgang Denk
  0 siblings, 1 reply; 17+ messages in thread
From: Anton Vorontsov @ 2009-04-30 23:12 UTC (permalink / raw)
  To: u-boot

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.
> 
> > 3. 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:
> >    1. dr_usb - enable Dual-Role USB controller;
> >    2. dr_usb_mode:peripheral - USB in Function mode;
> >    3. 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?

At first sight this looks great. But where should we stop?
I mean, technically that is

dr_usb {
	mode = peripheral;
	phy_type = ulpi;
};

I wonder if we want multi-level nesting capability, i.e.

dr_usb {
	mode = peripheral;
	phy {
		type = ulpi;
		clock = 48;
	};
};

We'd type it this way:

=> set hwconfig "
> dr_usb {
> mode = peripheral;
> phy {
> type = ulpi;
> speed = 48;
> }
> }
> "

:-)

Or we can stop at one nesting level capability, just as you
describe. Your suggestion is quite easy to implement, but
full fledged parser is needed for the most generic case.


Thanks,

-- 
Anton Vorontsov
email: cbouatmailru at gmail.com
irc://irc.freenode.net/bd2

^ permalink raw reply	[flat|nested] 17+ messages in thread

* [U-Boot] [PATCH 1/8] Add simple hwconfig infrastructure
  2009-04-30 23:12     ` Anton Vorontsov
@ 2009-05-01  7:33       ` Wolfgang Denk
  0 siblings, 0 replies; 17+ messages in thread
From: Wolfgang Denk @ 2009-05-01  7:33 UTC (permalink / raw)
  To: u-boot

Dear Anton,

In message <20090430231220.GA17546@oksana.dev.rtsoft.ru> you 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?
> 
> At first sight this looks great. But where should we stop?

at a semicolon :-) i. e. something like this:

	set hwconfig dr_usb:mode=peripheral,phy_type=ulpi;next_option:on;other_option:off

> I wonder if we want multi-level nesting capability, i.e.
> 
> dr_usb {
> 	mode = peripheral;
> 	phy {
> 		type = ulpi;
> 		clock = 48;
> 	};
> };

I don't think we should go that far.

> Or we can stop at one nesting level capability, just as you
> describe. Your suggestion is quite easy to implement, but
> full fledged parser is needed for the most generic case.

I think this should remain what it was introduced as: a *simple*
hwconfig infrastructure.

If you need more capabilities, then we should just use existing code:
use a device tree. OK, then you have to provide the information in a
separate flash sector instead of the environment, but in the long run
this is the way to go anyway - if you do it right you will need just
a single copy of the device tree for both U-Boot and Linux.


So if you need something small and *simple* now, then use hwconfig,
but without all theoretically possible bells and whistles; if you need
the full-blown thing, trhen use a device tree.

Best regards,

Wolfgang Denk

-- 
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
"I've seen it. It's rubbish."          - Marvin the Paranoid Android

^ permalink raw reply	[flat|nested] 17+ messages in thread

* [U-Boot] [PATCH 1/8] Add simple hwconfig infrastructure
  2009-04-29 21:50 ` [U-Boot] [PATCH 1/8] Add simple hwconfig infrastructure Anton Vorontsov
                     ` (2 preceding siblings ...)
  2009-04-30 22:31   ` Wolfgang Denk
@ 2009-06-02 20:51   ` Andy Fleming
  2009-06-02 22:11     ` Anton Vorontsov
  3 siblings, 1 reply; 17+ messages in thread
From: Andy Fleming @ 2009-06-02 20:51 UTC (permalink / raw)
  To: u-boot

On Wed, Apr 29, 2009 at 4:50 PM, Anton Vorontsov
<avorontsov@ru.mvista.com>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].



...Any updates on this?  It looks like your eSDHC patches rely on it, so I
can't apply any of these 8 patches until this one passes.  :)

Andy

^ permalink raw reply	[flat|nested] 17+ messages in thread

* [U-Boot] [PATCH 1/8] Add simple hwconfig infrastructure
  2009-06-02 20:51   ` Andy Fleming
@ 2009-06-02 22:11     ` Anton Vorontsov
  0 siblings, 0 replies; 17+ messages in thread
From: Anton Vorontsov @ 2009-06-02 22:11 UTC (permalink / raw)
  To: u-boot

On Tue, Jun 02, 2009 at 03:51:29PM -0500, Andy Fleming wrote:
> On Wed, Apr 29, 2009 at 4:50 PM, Anton Vorontsov
> <avorontsov@ru.mvista.com>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].
> 
> 
> ...Any updates on this?  It looks like your eSDHC patches rely on it, so I
> can't apply any of these 8 patches until this one passes.  :)

Yeah... I've been on a vacation, and then got some internal
MV work to do, but now I'm slowly but surely catching up on
the pending community work, so I will post updated patches
soon.

Thanks,

-- 
Anton Vorontsov
email: cbouatmailru at gmail.com
irc://irc.freenode.net/bd2

^ permalink raw reply	[flat|nested] 17+ messages in thread

end of thread, other threads:[~2009-06-02 22:11 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-04-29 21:48 [U-Boot] [PATCH 0/8] hwconfig and some its users (was: Re: [PATCH 2/6] Add FSL "Can use" framework) Anton Vorontsov
2009-04-29 21:50 ` [U-Boot] [PATCH 1/8] Add simple hwconfig infrastructure Anton Vorontsov
2009-04-29 21:59   ` Anton Vorontsov
2009-04-30 20:00   ` Kim Phillips
2009-04-30 20:22     ` Anton Vorontsov
2009-04-30 22:31   ` Wolfgang Denk
2009-04-30 23:12     ` Anton Vorontsov
2009-05-01  7:33       ` Wolfgang Denk
2009-06-02 20:51   ` Andy Fleming
2009-06-02 22:11     ` Anton Vorontsov
2009-04-29 21:50 ` [U-Boot] [PATCH 2/8] fsl_esdhc: Add device tree fixups Anton Vorontsov
2009-04-29 21:50 ` [U-Boot] [PATCH 3/8] mpc83xx: MPC837XERDB: Add support for FSL eSDHC Anton Vorontsov
2009-04-29 21:50 ` [U-Boot] [PATCH 4/8] mpc83xx: MPC837XEMDS: Fixup eSDHC nodes in device tree Anton Vorontsov
2009-04-29 21:50 ` [U-Boot] [PATCH 5/8] fdt_support, usb: Move fdt_fixup_dr_usb routine to drivers/usb/otg Anton Vorontsov
2009-04-29 21:50 ` [U-Boot] [PATCH 6/8] fsl_dr_usb: Fixup disabled USB controllers nodes in device tree Anton Vorontsov
2009-04-29 21:50 ` [U-Boot] [PATCH 7/8] mpc83xx: MPC8315ERDB: Use hwconfig for board type selection Anton Vorontsov
2009-04-29 21:50 ` [U-Boot] [PATCH 8/8] mpc83xx: MPC837xEMDS: Use hwconfig instead of pci_external_arbiter variable Anton Vorontsov

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.