[U-Boot] [PATCH v1 2/3] arm, at91: add Siemens board taurus (based on AT91SAM9G20)

2013-10-21 Thread Heiko Schocher
Signed-off-by: Roger Meier 
Reviewed-by: Heiko Schocher 
Cc: Andreas Bießmann 
---
 board/siemens/taurus/Makefile |  38 
 board/siemens/taurus/taurus.c | 204 ++
 boards.cfg|   2 +
 include/configs/taurus.h  | 163 +
 4 files changed, 407 insertions(+)
 create mode 100644 board/siemens/taurus/Makefile
 create mode 100644 board/siemens/taurus/taurus.c
 create mode 100644 include/configs/taurus.h

diff --git a/board/siemens/taurus/Makefile b/board/siemens/taurus/Makefile
new file mode 100644
index 000..9c288b7
--- /dev/null
+++ b/board/siemens/taurus/Makefile
@@ -0,0 +1,38 @@
+#
+# Makefile for Siemens TAURUS (AT91SAM9G20) based board
+# (C) Copyright 2013 Siemens AG
+#
+# Based on:
+# U-Boot file: board/atmel/at91sam9260ek/Makefile
+#
+# (C) Copyright 2003-2008
+# Wolfgang Denk, DENX Software Engineering, w...@denx.de.
+#
+# (C) Copyright 2008
+# Stelian Pop 
+# Lead Tech Design 
+#
+# SPDX-License-Identifier: GPL-2.0+
+#
+
+include $(TOPDIR)/config.mk
+
+LIB= $(obj)lib$(BOARD).o
+
+COBJS-y+= taurus.o
+
+SRCS   := $(SOBJS:.o=.S) $(COBJS-y:.o=.c)
+OBJS   := $(addprefix $(obj),$(COBJS-y))
+SOBJS  := $(addprefix $(obj),$(SOBJS))
+
+$(LIB):$(obj).depend $(OBJS) $(SOBJS)
+   $(call cmd_link_o_target, $(OBJS) $(SOBJS))
+
+#
+
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
+
+sinclude $(obj).depend
+
+#
diff --git a/board/siemens/taurus/taurus.c b/board/siemens/taurus/taurus.c
new file mode 100644
index 000..debc48e
--- /dev/null
+++ b/board/siemens/taurus/taurus.c
@@ -0,0 +1,204 @@
+/*
+ * Board functions for Siemens TAURUS (AT91SAM9G20) based boards
+ * (C) Copyright Siemens AG
+ *
+ * Based on:
+ * U-Boot file: board/atmel/at91sam9260ek/at91sam9260ek.c
+ *
+ * (C) Copyright 2007-2008
+ * Stelian Pop 
+ * Lead Tech Design 
+ *
+ * SPDX-License-Identifier:GPL-2.0+
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#if defined(CONFIG_RESET_PHY_R) && defined(CONFIG_MACB)
+# include 
+#endif
+#include 
+
+DECLARE_GLOBAL_DATA_PTR;
+
+/* - */
+/*
+ * Miscelaneous platform dependent initialisations
+ */
+
+#ifdef CONFIG_CMD_NAND
+static void taurus_nand_hw_init(void)
+{
+   struct at91_smc *smc = (struct at91_smc *)ATMEL_BASE_SMC;
+   struct at91_matrix *matrix = (struct at91_matrix *)ATMEL_BASE_MATRIX;
+   unsigned long csa;
+
+   /* Assign CS3 to NAND/SmartMedia Interface */
+   csa = readl(&matrix->ebicsa);
+   csa |= AT91_MATRIX_CS3A_SMC_SMARTMEDIA;
+   writel(csa, &matrix->ebicsa);
+
+   /* Configure SMC CS3 for NAND/SmartMedia */
+   writel(AT91_SMC_SETUP_NWE(2) | AT91_SMC_SETUP_NCS_WR(0) |
+  AT91_SMC_SETUP_NRD(2) | AT91_SMC_SETUP_NCS_RD(0),
+  &smc->cs[3].setup);
+   writel(AT91_SMC_PULSE_NWE(4) | AT91_SMC_PULSE_NCS_WR(3) |
+  AT91_SMC_PULSE_NRD(4) | AT91_SMC_PULSE_NCS_RD(3),
+  &smc->cs[3].pulse);
+   writel(AT91_SMC_CYCLE_NWE(7) | AT91_SMC_CYCLE_NRD(7),
+  &smc->cs[3].cycle);
+   writel(AT91_SMC_MODE_RM_NRD | AT91_SMC_MODE_WM_NWE |
+  AT91_SMC_MODE_EXNW_DISABLE |
+  AT91_SMC_MODE_DBW_8 |
+  AT91_SMC_MODE_TDF_CYCLE(3),
+  &smc->cs[3].mode);
+
+   /* Configure RDY/BSY */
+   at91_set_gpio_input(CONFIG_SYS_NAND_READY_PIN, 1);
+
+   /* Enable NandFlash */
+   at91_set_gpio_output(CONFIG_SYS_NAND_ENABLE_PIN, 1);
+}
+#endif
+
+#ifdef CONFIG_MACB
+static void taurus_macb_hw_init(void)
+{
+   struct at91_pmc *pmc = (struct at91_pmc *)ATMEL_BASE_PMC;
+   struct at91_port *pioa = (struct at91_port *)ATMEL_BASE_PIOA;
+   struct at91_rstc *rstc = (struct at91_rstc *)ATMEL_BASE_RSTC;
+   unsigned long erstl;
+
+   /* Enable EMAC clock */
+   writel(1 << ATMEL_ID_EMAC0, &pmc->pcer);
+
+   /*
+* Disable pull-up on:
+*  RXDV (PA17) => PHY normal mode (not Test mode)
+*  ERX0 (PA14) => PHY ADDR0
+*  ERX1 (PA15) => PHY ADDR1
+*  ERX2 (PA25) => PHY ADDR2
+*  ERX3 (PA26) => PHY ADDR3
+*  ECRS (PA28) => PHY ADDR4  => PHYADDR = 0x0
+*
+* PHY has internal pull-down
+*/
+   writel(pin_to_mask(AT91_PIN_PA14) |
+   pin_to_mask(AT91_PIN_PA15) |
+   pin_to_mask(AT91_PIN_PA17) |
+   pin_to_mask(AT91_PIN_PA25) |
+   pin_to_mask(AT91_PIN_PA26) |
+   pin_to_mask(AT91_PIN_PA28),
+   &pioa->pudr);
+
+   /*
+* Need to reset PHY ?-> 200us reset
+* Bug within Atmel CPU (undefined initial states on io-lines)!
+* S

[U-Boot] [PATCH v1 3/3] arm, at91: add siemens corvus board

2013-10-21 Thread Heiko Schocher
Signed-off-by: Boris Schmidt 
Reviewed-by: Heiko Schocher 
Cc: Andreas Bießmann 
---
 board/siemens/corvus/Makefile |  39 +
 board/siemens/corvus/board.c  | 345 ++
 boards.cfg|   1 +
 include/configs/corvus.h  | 185 ++
 4 files changed, 570 insertions(+)
 create mode 100644 board/siemens/corvus/Makefile
 create mode 100644 board/siemens/corvus/board.c
 create mode 100644 include/configs/corvus.h

diff --git a/board/siemens/corvus/Makefile b/board/siemens/corvus/Makefile
new file mode 100644
index 000..88981d8
--- /dev/null
+++ b/board/siemens/corvus/Makefile
@@ -0,0 +1,39 @@
+#
+# Makefile for siemens CORVUS (AT91SAM9G45) based board
+# (C) Copyright 2013 Siemens AG
+#
+# Based on:
+# U-Boot file: board/atmel/at91sam9m10g45ek/Makefile
+#
+# (C) Copyright 2003-2008
+# Wolfgang Denk, DENX Software Engineering, w...@denx.de.
+#
+# (C) Copyright 2008
+# Stelian Pop 
+# Lead Tech Design 
+#
+# SPDX-License-Identifier: GPL-2.0+
+#
+
+
+include $(TOPDIR)/config.mk
+
+LIB= $(obj)lib$(BOARD).o
+
+COBJS-y += board.o
+
+SRCS   := $(SOBJS:.o=.S) $(COBJS-y:.o=.c)
+OBJS   := $(addprefix $(obj),$(COBJS-y))
+SOBJS  := $(addprefix $(obj),$(SOBJS))
+
+$(LIB):$(obj).depend $(OBJS) $(SOBJS)
+   $(call cmd_link_o_target, $(OBJS) $(SOBJS))
+
+#
+
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
+
+sinclude $(obj).depend
+
+#
diff --git a/board/siemens/corvus/board.c b/board/siemens/corvus/board.c
new file mode 100644
index 000..1940da7
--- /dev/null
+++ b/board/siemens/corvus/board.c
@@ -0,0 +1,345 @@
+/*
+ * Board functions for Siemens CORVUS (AT91SAM9G45) based board
+ * (C) Copyright 2013 Siemens AG
+ *
+ * Based on:
+ * U-Boot file: board/atmel/at91sam9m10g45ek/at91sam9m10g45ek.c
+ * (C) Copyright 2007-2008
+ * Stelian Pop 
+ * Lead Tech Design 
+ *
+ * SPDX-License-Identifier:GPL-2.0+
+ */
+
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#if defined(CONFIG_RESET_PHY_R) && defined(CONFIG_MACB)
+#include 
+#endif
+#include 
+
+DECLARE_GLOBAL_DATA_PTR;
+
+/* - */
+/*
+ * Miscelaneous platform dependent initialisations
+ */
+
+#ifdef CONFIG_CMD_NAND
+static void corvus_nand_hw_init(void)
+{
+   struct at91_smc *smc = (struct at91_smc *)ATMEL_BASE_SMC;
+   struct at91_matrix *matrix = (struct at91_matrix *)ATMEL_BASE_MATRIX;
+   struct at91_pmc *pmc = (struct at91_pmc *)ATMEL_BASE_PMC;
+   unsigned long csa;
+
+   /* Enable CS3 */
+   csa = readl(&matrix->ebicsa);
+   csa |= AT91_MATRIX_EBI_CS3A_SMC_SMARTMEDIA;
+   writel(csa, &matrix->ebicsa);
+
+   /* Configure SMC CS3 for NAND/SmartMedia */
+   writel(AT91_SMC_SETUP_NWE(1) | AT91_SMC_SETUP_NCS_WR(0) |
+  AT91_SMC_SETUP_NRD(1) | AT91_SMC_SETUP_NCS_RD(0),
+  &smc->cs[3].setup);
+   writel(AT91_SMC_PULSE_NWE(4) | AT91_SMC_PULSE_NCS_WR(3) |
+  AT91_SMC_PULSE_NRD(3) | AT91_SMC_PULSE_NCS_RD(2),
+  &smc->cs[3].pulse);
+   writel(AT91_SMC_CYCLE_NWE(7) | AT91_SMC_CYCLE_NRD(4),
+  &smc->cs[3].cycle);
+   writel(AT91_SMC_MODE_RM_NRD | AT91_SMC_MODE_WM_NWE |
+  AT91_SMC_MODE_EXNW_DISABLE |
+#ifdef CONFIG_SYS_NAND_DBW_16
+  AT91_SMC_MODE_DBW_16 |
+#else /* CONFIG_SYS_NAND_DBW_8 */
+  AT91_SMC_MODE_DBW_8 |
+#endif
+  AT91_SMC_MODE_TDF_CYCLE(3),
+  &smc->cs[3].mode);
+
+   writel(1 << ATMEL_ID_PIOC, &pmc->pcer);
+
+   /* Configure RDY/BSY */
+   at91_set_gpio_input(CONFIG_SYS_NAND_READY_PIN, 1);
+
+   /* Enable NandFlash */
+   at91_set_gpio_output(CONFIG_SYS_NAND_ENABLE_PIN, 1);
+}
+#endif
+
+#ifdef CONFIG_CMD_USB
+static void at91sam9m10g45ek_usb_hw_init(void)
+{
+   struct at91_pmc *pmc = (struct at91_pmc *)ATMEL_BASE_PMC;
+
+   writel(1 << ATMEL_ID_PIODE, &pmc->pcer);
+
+   at91_set_gpio_output(AT91_PIN_PD1, 0);
+   at91_set_gpio_output(AT91_PIN_PD3, 0);
+}
+#endif
+
+#ifdef CONFIG_MACB
+static void corvus_macb_hw_init(void)
+{
+   struct at91_pmc *pmc = (struct at91_pmc *)ATMEL_BASE_PMC;
+   struct at91_port *pioa = (struct at91_port *)ATMEL_BASE_PIOA;
+   struct at91_rstc *rstc = (struct at91_rstc *)ATMEL_BASE_RSTC;
+   unsigned long erstl;
+
+   /* Enable clock */
+   writel(1 << ATMEL_ID_EMAC, &pmc->pcer);
+
+   /*
+* Disable pull-up on:
+*  RXDV (PA15) => PHY normal mode (not Test mode)
+*  ERX0 (PA12) => PHY ADDR0
+*  ERX1 (PA13) => PHY ADDR1 => PHYADDR = 0x0
+*
+* PHY has internal pull-down
+*/
+   writel(pin_to_mask(AT91_PIN_PA15) |
+  pin_to_mask

[U-Boot] [PATCH v1 0/3] arm, at91: support for the taurus and corvus board

2013-10-21 Thread Heiko Schocher
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

add support for the two AT91SAM9G20 boards from siemens. For the
taurus board, patch 1 from this series add some needed defines. 

Heiko Schocher (2):
  arm, at91: add Siemens board taurus (based on AT91SAM9G20)
  arm, at91: add siemens corvus board

Roger Meier (1):
  at91: add defines for reset type

 arch/arm/include/asm/arch-at91/at91_rstc.h |   7 +
 board/siemens/corvus/Makefile  |  39 
 board/siemens/corvus/board.c   | 345 +
 board/siemens/taurus/Makefile  |  38 
 board/siemens/taurus/taurus.c  | 204 +
 boards.cfg |   3 +
 include/configs/corvus.h   | 185 
 include/configs/taurus.h   | 163 ++
 8 files changed, 984 insertions(+)
 create mode 100644 board/siemens/corvus/Makefile
 create mode 100644 board/siemens/corvus/board.c
 create mode 100644 board/siemens/taurus/Makefile
 create mode 100644 board/siemens/taurus/taurus.c
 create mode 100644 include/configs/corvus.h
 create mode 100644 include/configs/taurus.h

-- 
1.8.3.1

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH v1 1/3] at91: add defines for reset type

2013-10-21 Thread Heiko Schocher
From: Roger Meier 

Signed-off-by: Roger Meier 
Reviewed-by: Heiko Schocher 
Cc: Andreas Bießmann 
---
 arch/arm/include/asm/arch-at91/at91_rstc.h | 7 +++
 1 file changed, 7 insertions(+)

diff --git a/arch/arm/include/asm/arch-at91/at91_rstc.h 
b/arch/arm/include/asm/arch-at91/at91_rstc.h
index 423cf51..a942342 100644
--- a/arch/arm/include/asm/arch-at91/at91_rstc.h
+++ b/arch/arm/include/asm/arch-at91/at91_rstc.h
@@ -38,4 +38,11 @@ typedef struct at91_rstc {
 
 #define AT91_RSTC_SR_NRSTL 0x0001
 
+#define AT91_RSTC_RSTTYP   (7 << 8)/* Reset Type */
+#define AT91_RSTC_RSTTYP_GENERAL   (0 << 8)
+#define AT91_RSTC_RSTTYP_WAKEUP(1 << 8)
+#define AT91_RSTC_RSTTYP_WATCHDOG  (2 << 8)
+#define AT91_RSTC_RSTTYP_SOFTWARE  (3 << 8)
+#define AT91_RSTC_RSTTYP_USER  (4 << 8)
+
 #endif
-- 
1.8.3.1

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [RFC PATCH 1/2] usb: dfu: decrease dfu->r_left along with the transfer

2013-10-21 Thread Marek Vasut
Hi Lukasz,

> Hi Marek,
> 
> > Hi,
> > 
> > > The value of dfu->r_left need decrease along with the transfer
> > > 
> > > Signed-off-by: Bo Shen 
> > 
> > Lucasz/Heiko , can you ACK/NAK this and 2/2 ? Thanks!
> 
> For me it looks like a more difficult problem.
> I've got an impression that patches proposed by Bo would break eMMC.
> 
> Unfortunately I'm now a bit short of time to go deeper to it. Before
> ELCE I shall have got a bit more time.

OK, thanks!

Best regards,
Marek Vasut
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] v2013.10 failed build with jffs2 cmd

2013-10-21 Thread Chris Ruehl

Dear List,

when I tried to build v2013.10 with the Option: CONFIG_CMD_JFFS2
using linao tool-chain 2013.09 (and earlier) I run into the well known problem

 uses VFP register arguments, u-boot does not

the u-boot.map shows this as source of the trouble -

/opt/armhf/gcc-linaro-arm-linux-gnueabihf-4.8-2013.09_linux/bin/../lib/gcc/arm-linux-gnueabihf/4.8.2/libgcc.a(_aeabi_uldivmod.o)
  fs/jffs2/libjffs2.o (__aeabi_uldivmod)
/opt/armhf/gcc-linaro-arm-linux-gnueabihf-4.8-2013.09_linux/bin/../lib/gcc/arm-linux-gnueabihf/4.8.2/libgcc.a(_dvmd_lnx.o)

/opt/armhf/gcc-linaro-arm-linux-gnueabihf-4.8-2013.09_linux/bin/../lib/gcc/arm-linux-gnueabihf/4.8.2/libgcc.a(_udivsi3.o) 
(__aeabi_idiv0)

/opt/armhf/gcc-linaro-arm-linux-gnueabihf-4.8-2013.09_linux/bin/../lib/gcc/arm-linux-gnueabihf/4.8.2/libgcc.a(bpabi.o)

/opt/armhf/gcc-linaro-arm-linux-gnueabihf-4.8-2013.09_linux/bin/../lib/gcc/arm-linux-gnueabihf/4.8.2/libgcc.a(_aeabi_uldivmod.o) 
(__gnu_uldivmod_helper)

/opt/armhf/gcc-linaro-arm-linux-gnueabihf-4.8-2013.09_linux/bin/../lib/gcc/arm-linux-gnueabihf/4.8.2/libgcc.a(_divdi3.o)

/opt/armhf/gcc-linaro-arm-linux-gnueabihf-4.8-2013.09_linux/bin/../lib/gcc/arm-linux-gnueabihf/4.8.2/libgcc.a(bpabi.o) 
(__divdi3)

/opt/armhf/gcc-linaro-arm-linux-gnueabihf-4.8-2013.09_linux/bin/../lib/gcc/arm-linux-gnueabihf/4.8.2/libgcc.a(_udivdi3.o)

/opt/armhf/gcc-linaro-arm-linux-gnueabihf-4.8-2013.09_linux/bin/../lib/gcc/arm-linux-gnueabihf/4.8.2/libgcc.a(bpabi.o) 
(__udivdi3)



any hints to solve this?


Chris

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [RFC PATCH 1/2] usb: dfu: decrease dfu->r_left along with the transfer

2013-10-21 Thread Lukasz Majewski

Hi Marek,

> Hi,
> 
> > The value of dfu->r_left need decrease along with the transfer
> > 
> > Signed-off-by: Bo Shen 
> 
> Lucasz/Heiko , can you ACK/NAK this and 2/2 ? Thanks!

For me it looks like a more difficult problem. 
I've got an impression that patches proposed by Bo would break eMMC.

Unfortunately I'm now a bit short of time to go deeper to it. Before
ELCE I shall have got a bit more time.

> 
> > ---
> >  drivers/dfu/dfu.c |1 +
> >  1 file changed, 1 insertion(+)
> > 
> > diff --git a/drivers/dfu/dfu.c b/drivers/dfu/dfu.c
> > index 56b21c7..65c6984 100644
> > --- a/drivers/dfu/dfu.c
> > +++ b/drivers/dfu/dfu.c
> > @@ -229,6 +229,7 @@ static int dfu_read_buffer_fill(struct
> > dfu_entity *dfu, void *buf, int size) dfu->crc = crc32(dfu->crc,
> > buf, chunk); dfu->i_buf += chunk;
> > dfu->b_left -= chunk;
> > +   dfu->r_left -= chunk;
> > size -= chunk;
> > buf += chunk;
> > readn += chunk;
> 
> Best regards,
> Marek Vasut

Regards,
Lukasz


signature.asc
Description: PGP signature
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [RESEND PATCH] imx: Easy enabling of SION per-pin using MUX_MODE_SION helper macro

2013-10-21 Thread Otavio Salvador
The macro allows easy setting in per-pin, as for example:

,
| imx_iomux_v3_setup_pad(MX6_PAD_NANDF_D1__GPIO_2_1 | MUX_MODE_SION);
`

The IOMUX_CONFIG_SION allows for reading PAD value from PSR register.

The following quote from the datasheet:

,
| ...
| 28.4.2.2 GPIO Write Mode
| The programming sequence for driving output signals should be as follows:
| 1. Configure IOMUX to select GPIO mode (Via IOMUXC), also enable SION if need
| to read loopback pad value through PSR
| 2. Configure GPIO direction register to output (GPIO_GDIR[GDIR] set to 1b).
| 3. Write value to data register (GPIO_DR).
| ...
`

This fixes the gpio_get_value to properly work when a GPIO is set for
output and has no conflicts.

Thanks for Benoît Thébaudeau , Fabio
Estevam  and Eric Bénard
 for helping to properly trace this down.

Signed-off-by: Otavio Salvador 
---
 arch/arm/include/asm/imx-common/iomux-v3.h | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/arch/arm/include/asm/imx-common/iomux-v3.h 
b/arch/arm/include/asm/imx-common/iomux-v3.h
index dc2b3ef..dec11a1 100644
--- a/arch/arm/include/asm/imx-common/iomux-v3.h
+++ b/arch/arm/include/asm/imx-common/iomux-v3.h
@@ -63,6 +63,8 @@ typedef u64 iomux_v3_cfg_t;
 #define MUX_SEL_INPUT_SHIFT59
 #define MUX_SEL_INPUT_MASK ((iomux_v3_cfg_t)0xf << MUX_SEL_INPUT_SHIFT)
 
+#define MUX_MODE_SION  ((iomux_v3_cfg_t)IOMUX_CONFIG_SION << \
+   MUX_MODE_SHIFT)
 #define MUX_PAD_CTRL(x)((iomux_v3_cfg_t)(x) << 
MUX_PAD_CTRL_SHIFT)
 
 #define IOMUX_PAD(pad_ctrl_ofs, mux_ctrl_ofs, mux_mode, sel_input_ofs, \
-- 
1.8.4.rc3

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH 2/4] wandboard: add Future Eletronics 7" WVGA LCD extension board

2013-10-21 Thread Otavio Salvador
This adds support for the 7" WVGA produced by Future Eletronics and
make it dynamically detect if it is connected or not based on the
touchscreen controller.

Signed-off-by: Otavio Salvador 
---
 board/wandboard/wandboard.c | 238 
 include/configs/wandboard.h |  35 ++-
 2 files changed, 251 insertions(+), 22 deletions(-)

diff --git a/board/wandboard/wandboard.c b/board/wandboard/wandboard.c
index 23a78c1..b2a27c0 100644
--- a/board/wandboard/wandboard.c
+++ b/board/wandboard/wandboard.c
@@ -15,6 +15,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -25,6 +26,7 @@
 #include 
 #include 
 #include 
+#include 
 
 DECLARE_GLOBAL_DATA_PTR;
 
@@ -39,6 +41,10 @@ DECLARE_GLOBAL_DATA_PTR;
 #define ENET_PAD_CTRL  (PAD_CTL_PUS_100K_UP |  \
PAD_CTL_SPEED_MED | PAD_CTL_DSE_40ohm | PAD_CTL_HYS)
 
+#define I2C_PAD_CTRL   (PAD_CTL_PUS_100K_UP |  \
+   PAD_CTL_SPEED_MED | PAD_CTL_DSE_40ohm | PAD_CTL_HYS |   \
+   PAD_CTL_ODE | PAD_CTL_SRE_FAST)
+
 #define USDHC1_CD_GPIO IMX_GPIO_NR(1, 2)
 #define USDHC3_CD_GPIO IMX_GPIO_NR(3, 9)
 #define ETH_PHY_RESET  IMX_GPIO_NR(3, 29)
@@ -208,48 +214,236 @@ int board_phy_config(struct phy_device *phydev)
 }
 
 #if defined(CONFIG_VIDEO_IPUV3)
-static struct fb_videomode const hdmi = {
-   .name   = "HDMI",
-   .refresh= 60,
-   .xres   = 1024,
-   .yres   = 768,
-   .pixclock   = 15385,
-   .left_margin= 220,
-   .right_margin   = 40,
-   .upper_margin   = 21,
-   .lower_margin   = 7,
-   .hsync_len  = 60,
-   .vsync_len  = 10,
-   .sync   = FB_SYNC_EXT,
-   .vmode  = FB_VMODE_NONINTERLACED
+struct i2c_pads_info i2c_pad_info = {
+   .scl = {
+   .i2c_mode = MX6_PAD_KEY_COL3__I2C2_SCL
+   | MUX_PAD_CTRL(I2C_PAD_CTRL),
+   .gpio_mode = MX6_PAD_KEY_COL3__GPIO_4_12
+   | MUX_PAD_CTRL(I2C_PAD_CTRL),
+   .gp = IMX_GPIO_NR(4, 12)
+   },
+   .sda = {
+   .i2c_mode = MX6_PAD_KEY_ROW3__I2C2_SDA
+   | MUX_PAD_CTRL(I2C_PAD_CTRL),
+   .gpio_mode = MX6_PAD_KEY_ROW3__GPIO_4_13
+   | MUX_PAD_CTRL(I2C_PAD_CTRL),
+   .gp = IMX_GPIO_NR(4, 13)
+   }
 };
 
-int board_video_skip(void)
-{
-   int ret;
+static iomux_v3_cfg_t const fwadapt_7wvga_pads[] = {
+   MX6_PAD_DI0_DISP_CLK__IPU1_DI0_DISP_CLK,
+   MX6_PAD_DI0_PIN2__IPU1_DI0_PIN2, /* HSync */
+   MX6_PAD_DI0_PIN3__IPU1_DI0_PIN3, /* VSync */
+   MX6_PAD_DI0_PIN4__IPU1_DI0_PIN4
+   | MUX_PAD_CTRL(PAD_CTL_DSE_120ohm), /* Contrast */
+   MX6_PAD_DI0_PIN15__IPU1_DI0_PIN15, /* DISP0_DRDY */
+
+   MX6_PAD_DISP0_DAT0__IPU1_DISP0_DAT_0,
+   MX6_PAD_DISP0_DAT1__IPU1_DISP0_DAT_1,
+   MX6_PAD_DISP0_DAT2__IPU1_DISP0_DAT_2,
+   MX6_PAD_DISP0_DAT3__IPU1_DISP0_DAT_3,
+   MX6_PAD_DISP0_DAT4__IPU1_DISP0_DAT_4,
+   MX6_PAD_DISP0_DAT5__IPU1_DISP0_DAT_5,
+   MX6_PAD_DISP0_DAT6__IPU1_DISP0_DAT_6,
+   MX6_PAD_DISP0_DAT7__IPU1_DISP0_DAT_7,
+   MX6_PAD_DISP0_DAT8__IPU1_DISP0_DAT_8,
+   MX6_PAD_DISP0_DAT9__IPU1_DISP0_DAT_9,
+   MX6_PAD_DISP0_DAT10__IPU1_DISP0_DAT_10,
+   MX6_PAD_DISP0_DAT11__IPU1_DISP0_DAT_11,
+   MX6_PAD_DISP0_DAT12__IPU1_DISP0_DAT_12,
+   MX6_PAD_DISP0_DAT13__IPU1_DISP0_DAT_13,
+   MX6_PAD_DISP0_DAT14__IPU1_DISP0_DAT_14,
+   MX6_PAD_DISP0_DAT15__IPU1_DISP0_DAT_15,
+   MX6_PAD_DISP0_DAT16__IPU1_DISP0_DAT_16,
+   MX6_PAD_DISP0_DAT17__IPU1_DISP0_DAT_17,
+
+   MX6_PAD_SD4_DAT2__GPIO_2_10
+   | MUX_PAD_CTRL(NO_PAD_CTRL), /* DISP0_BKLEN */
+   MX6_PAD_SD4_DAT3__GPIO_2_11
+   | MUX_PAD_CTRL(NO_PAD_CTRL), /* DISP0_VDDEN */
+};
 
-   ret = ipuv3_fb_init(&hdmi, 0, IPU_PIX_FMT_RGB24);
+struct display_info_t {
+   int bus;
+   int addr;
+   int pixfmt;
+   int (*detect)(struct display_info_t const *dev);
+   void(*enable)(struct display_info_t const *dev);
+   struct  fb_videomode mode;
+};
 
-   if (ret)
-   printf("HDMI cannot be configured: %d\n", ret);
+static int detect_hdmi(struct display_info_t const *dev)
+{
+   struct hdmi_regs *hdmi  = (struct hdmi_regs *)HDMI_ARB_BASE_ADDR;
+   return readb(&hdmi->phy_stat0) & HDMI_DVI_STAT;
+}
 
+static void do_enable_hdmi(struct display_info_t const *dev)
+{
imx_enable_hdmi_phy();
+}
 
-   return ret;
+static int detect_i2c(struct display_info_t const *dev)
+{
+   return ((0 == i2c_set_bus_num(dev->bus)) &&
+   (0 == i2c_probe(dev->addr)));
+}
+
+static void enable_fwadapt_7wvga(struct display_info_t const *dev)
+{
+   imx_iomux_v3_setup_multiple_pads(
+   fwadapt_7wvga_pads,
+   ARRAY_SIZE(fwadapt_7wvga_pads));
+
+   gpio_

[U-Boot] [PATCH 3/4] wandboard: Use '0' as bootdelay but interruptable

2013-10-21 Thread Otavio Salvador
The '0' as bootdelay reduces a lot the boot time while we still allow
the boot to be interruptable if need.

Signed-off-by: Otavio Salvador 
---
 include/configs/wandboard.h | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/include/configs/wandboard.h b/include/configs/wandboard.h
index dff515e..bffac9a 100644
--- a/include/configs/wandboard.h
+++ b/include/configs/wandboard.h
@@ -48,7 +48,8 @@
 #define CONFIG_CMD_BMODE
 #define CONFIG_CMD_SETEXPR
 
-#define CONFIG_BOOTDELAY   5
+#define CONFIG_BOOTDELAY   0
+#define CONFIG_ZERO_BOOTDELAY_CHECK
 
 #define CONFIG_SYS_MEMTEST_START   0x1000
 #define CONFIG_SYS_MEMTEST_END (CONFIG_SYS_MEMTEST_START + 500 * SZ_1M)
-- 
1.8.4.rc3

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH 1/4] mx6: Remove PAD_CTL_DSE_120ohm from i.MX6DL's IPU1_DI0_PIN4 pin

2013-10-21 Thread Otavio Salvador
This removes the PAD_CTL_DSE_120ohm as done for i.MX6Q's IPU1_DI0_PIN4
pin definition and makes it aligned with 3.0.35-4.1.0 and 3.12
mainline kernel.

Signed-off-by: Otavio Salvador 
---
 arch/arm/include/asm/arch-mx6/mx6dl_pins.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/arm/include/asm/arch-mx6/mx6dl_pins.h 
b/arch/arm/include/asm/arch-mx6/mx6dl_pins.h
index b5df68a..7373407 100644
--- a/arch/arm/include/asm/arch-mx6/mx6dl_pins.h
+++ b/arch/arm/include/asm/arch-mx6/mx6dl_pins.h
@@ -210,7 +210,7 @@ enum {
MX6_PAD_DI0_PIN3__MMDC_MMDC_DEBUG_3 = IOMUX_PAD(0x03BC, 0x00A8, 6, 
0x, 0, 0),
MX6_PAD_DI0_PIN3__PL301_SIM_MX6DL_PER1_HADDR_10 = IOMUX_PAD(0x03BC, 
0x00A8, 7, 0x, 0, 0),
MX6_PAD_DI0_PIN3__LCDIF_CS  = IOMUX_PAD(0x03BC, 0x00A8, 8, 
0x, 0, 0),
-   MX6_PAD_DI0_PIN4__IPU1_DI0_PIN4 = IOMUX_PAD(0x03C0, 0x00AC, 0, 
0x, 0, PAD_CTL_DSE_120ohm),
+   MX6_PAD_DI0_PIN4__IPU1_DI0_PIN4 = IOMUX_PAD(0x03C0, 0x00AC, 0, 
0x, 0, 0),
MX6_PAD_DI0_PIN4__LCDIF_BUSY= IOMUX_PAD(0x03C0, 0x00AC, 1, 
0x08D8, 1, 0),
MX6_PAD_DI0_PIN4__AUDMUX_AUD6_RXD   = IOMUX_PAD(0x03C0, 0x00AC, 2, 
0x, 0, 0),
MX6_PAD_DI0_PIN4__USDHC1_WP = IOMUX_PAD(0x03C0, 0x00AC, 3, 
0x092C, 0, 0),
-- 
1.8.4.rc3

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH 0/4] Wandboard support for Future Eletronics 7" WVGA LCD extension board

2013-10-21 Thread Otavio Salvador
This patchset adds support for the Future Eletronics 7" WVGA LCD
extension board and implements its auto-detection using i2c to check
for it's touch controller presence.

The IOMUXC change is included here as it makes both SoC type MUX
settings in line to each other and took a while to figure out why it
worked with one and failed with another SoC.


Otavio Salvador (4):
  mx6: Remove PAD_CTL_DSE_120ohm from i.MX6DL's IPU1_DI0_PIN4 pin
  wandboard: add Future Eletronics 7" WVGA LCD extension board
  wandboard: Use '0' as bootdelay but interruptable
  wandboard: Pass 'quiet' bootparam by default

 arch/arm/include/asm/arch-mx6/mx6dl_pins.h |   2 +-
 board/wandboard/wandboard.c| 238 ++---
 include/configs/wandboard.h|  38 -
 3 files changed, 254 insertions(+), 24 deletions(-)

-- 
1.8.4.rc3

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH 4/4] wandboard: Pass 'quiet' bootparam by default

2013-10-21 Thread Otavio Salvador
This reduces the boot time and makes easier to spot important images.

Signed-off-by: Otavio Salvador 
---
 include/configs/wandboard.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/configs/wandboard.h b/include/configs/wandboard.h
index bffac9a..75a456c 100644
--- a/include/configs/wandboard.h
+++ b/include/configs/wandboard.h
@@ -142,7 +142,7 @@
"fi; "  \
"fi\0" \
"mmcargs=setenv bootargs console=${console},${baudrate} " \
-   "root=${mmcroot}; run videoargs\0" \
+   "root=${mmcroot} quiet; run videoargs\0" \
"videoargs=" \
"setenv nextcon 0; " \
"if hdmidet; then " \
-- 
1.8.4.rc3

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [RESEND PATCH 0/3] mx28evk environment rework for NAND support

2013-10-21 Thread Otavio Salvador
This patchset improves the mx28evk default environment so it is easier
to use by users when testing the NAND support.

It provides a set of new environment routines as:

 - update_nand_kernel
 - update_nand_fdt
 - update_nand_filesystem

and allow for easy NAND boot using:

 'run nandboot'

This has been tested using:

 Samsung 4G NAND, part-#: K9LBG08U0D-PCB0


Otavio Salvador (3):
  mx28evk: Use 512k for fdt partition to align it
  mx28evk: Add 'nandboot' environment command
  mx28evk: Extend environment to easy write of NAND system

 include/configs/mx28evk.h | 55 ---
 1 file changed, 52 insertions(+), 3 deletions(-)

-- 
1.8.4.rc3

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [RESEND PATCH 3/3] mx28evk: Extend environment to easy write of NAND system

2013-10-21 Thread Otavio Salvador
This adds following new targets:

 - update_nand_kernel
 - update_nand_fdt
 - update_nand_filesystem

and to avoid confusion, the 'update_nand_full' has been renamed to
'update_nand_firmware_full'.

Signed-off-by: Otavio Salvador 
---
 include/configs/mx28evk.h | 35 ++-
 1 file changed, 34 insertions(+), 1 deletion(-)

diff --git a/include/configs/mx28evk.h b/include/configs/mx28evk.h
index e40df09..5e43226 100644
--- a/include/configs/mx28evk.h
+++ b/include/configs/mx28evk.h
@@ -161,6 +161,7 @@
 
 /* Extra Environment */
 #define CONFIG_EXTRA_ENV_SETTINGS \
+   "ubifs_file=filesystem.ubifs\0" \
"update_nand_full_filename=u-boot.nand\0" \
"update_nand_firmware_filename=u-boot.sb\0" \
"update_nand_firmware_maxsz=0x10\0" \
@@ -171,7 +172,7 @@
"nand info ; " \
"setexpr fcb_sz ${update_nand_stride} * ${update_nand_count};" \
"setexpr update_nand_fcb ${fcb_sz} * ${nand_writesize}\0" \
-   "update_nand_full=" /* Update FCB, DBBT and FW */ \
+   "update_nand_firmware_full=" /* Update FCB, DBBT and FW */ \
"if tftp ${update_nand_full_filename} ; then " \
"run update_nand_get_fcb_size ; " \
"nand scrub -y 0x0 ${filesize} ; " \
@@ -190,6 +191,38 @@
"nand write ${loadaddr} ${fcb_sz} ${filesize} ; " \
"nand write ${loadaddr} ${fw_off} ${filesize} ; " \
"fi\0" \
+   "update_nand_kernel="   /* Update kernel */ \
+   "mtdparts default; " \
+   "nand erase.part kernel; " \
+   "if test ${ip_dyn} = yes; then " \
+   "setenv get_cmd dhcp; " \
+   "else " \
+   "setenv get_cmd tftp; " \
+   "fi; " \
+   "${get_cmd} ${uimage}; " \
+   "nand write ${loadaddr} kernel ${filesize}\0" \
+   "update_nand_fdt="  /* Update fdt */ \
+   "mtdparts default; " \
+   "nand erase.part fdt; " \
+   "if test ${ip_dyn} = yes; then " \
+   "setenv get_cmd dhcp; " \
+   "else " \
+   "setenv get_cmd tftp; " \
+   "fi; " \
+   "${get_cmd} ${fdt_file}; " \
+   "nand write ${loadaddr} fdt ${filesize}\0" \
+   "update_nand_filesystem="   /* Update filesystem */ \
+   "mtdparts default; " \
+   "nand erase.part filesystem; " \
+   "if test ${ip_dyn} = yes; then " \
+   "setenv get_cmd dhcp; " \
+   "else " \
+   "setenv get_cmd tftp; " \
+   "fi; " \
+   "${get_cmd} ${ubifs_file}; " \
+   "ubi part filesystem; " \
+   "ubi create filesystem; " \
+   "ubi write ${loadaddr} filesystem ${filesize}\0" \
"nandargs=setenv bootargs console=${console_mainline},${baudrate} " \
"rootfstype=ubifs ubi.mtd=6 root=ubi0_0 ${mtdparts}\0" \
"nandboot=" /* Boot from NAND */ \
-- 
1.8.4.rc3

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [RESEND PATCH 2/3] mx28evk: Add 'nandboot' environment command

2013-10-21 Thread Otavio Salvador
This reads the kernel, ftd and boot into ubifs filesystem. While on
that, the SD firmware filename definition has been moved next to the
other SD related commands.

Signed-off-by: Otavio Salvador 
---
 include/configs/mx28evk.h | 18 +-
 1 file changed, 17 insertions(+), 1 deletion(-)

diff --git a/include/configs/mx28evk.h b/include/configs/mx28evk.h
index 27b1a41..e40df09 100644
--- a/include/configs/mx28evk.h
+++ b/include/configs/mx28evk.h
@@ -163,7 +163,6 @@
 #define CONFIG_EXTRA_ENV_SETTINGS \
"update_nand_full_filename=u-boot.nand\0" \
"update_nand_firmware_filename=u-boot.sb\0" \
-   "update_sd_firmware_filename=u-boot.sd\0" \
"update_nand_firmware_maxsz=0x10\0" \
"update_nand_stride=0x40\0" /* MX28 datasheet ch. 12.12 */ \
"update_nand_count=0x4\0"   /* MX28 datasheet ch. 12.12 */ \
@@ -191,6 +190,23 @@
"nand write ${loadaddr} ${fcb_sz} ${filesize} ; " \
"nand write ${loadaddr} ${fw_off} ${filesize} ; " \
"fi\0" \
+   "nandargs=setenv bootargs console=${console_mainline},${baudrate} " \
+   "rootfstype=ubifs ubi.mtd=6 root=ubi0_0 ${mtdparts}\0" \
+   "nandboot=" /* Boot from NAND */ \
+   "mtdparts default; " \
+   "run nandargs; " \
+   "nand read ${loadaddr} kernel 0x0040; " \
+   "if test ${boot_fdt} = yes; then " \
+   "nand read ${fdt_addr} fdt 0x0008; " \
+   "bootm ${loadaddr} - ${fdt_addr}; " \
+   "else " \
+   "if test ${boot_fdt} = no; then " \
+   "bootm; " \
+   "else " \
+   "echo \"ERROR: Set boot_fdt to yes or no.\"; " \
+   "fi; " \
+   "fi\0" \
+   "update_sd_firmware_filename=u-boot.sd\0" \
"update_sd_firmware="   /* Update the SD firmware partition */ \
"if mmc rescan ; then " \
"if tftp ${update_sd_firmware_filename} ; then " \
-- 
1.8.4.rc3

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH] mx6sabresd: Add eMMC specific environment to allow U-Boot update

2013-10-21 Thread Otavio Salvador
A new 'update_emmc_firmware' target is added to allow for easy U-Boot
update in the eMMC as it has secury boot partition and this needs
specific handling on how to program the specific partition.

Signed-off-by: Otavio Salvador 
---
 include/configs/mx6sabre_common.h | 23 +++
 include/configs/mx6sabresd.h  |  2 ++
 2 files changed, 25 insertions(+)

diff --git a/include/configs/mx6sabre_common.h 
b/include/configs/mx6sabre_common.h
index bf6113b..a87ec12 100644
--- a/include/configs/mx6sabre_common.h
+++ b/include/configs/mx6sabre_common.h
@@ -78,6 +78,28 @@
 #define CONFIG_LOADADDR0x1200
 #define CONFIG_SYS_TEXT_BASE   0x1780
 
+#ifdef CONFIG_SUPPORT_EMMC_BOOT
+#define EMMC_ENV \
+   "emmcdev=2\0" \
+   "update_emmc_firmware=" \
+   "if test ${ip_dyn} = yes; then " \
+   "setenv get_cmd dhcp; " \
+   "else " \
+   "setenv get_cmd tftp; " \
+   "fi; " \
+   "if ${get_cmd} ${update_sd_firmware_filename}; then " \
+   "if mmc dev ${emmcdev} && " \
+   "mmc open ${emmcdev} 1; then "  \
+   "setexpr fw_sz ${filesize} / 0x200; " \
+   "setexpr fw_sz ${fw_sz} + 1; "  \
+   "mmc write ${loadaddr} 0x2 ${fw_sz}; " \
+   "mmc close ${emmcdev} 1; " \
+   "fi; "  \
+   "fi\0"
+#else
+#define EMMC_DEV ""
+#endif
+
 #define CONFIG_EXTRA_ENV_SETTINGS \
"script=boot.scr\0" \
"uimage=uImage\0" \
@@ -104,6 +126,7 @@
"mmc write ${loadaddr} 0x2 ${fw_sz}; " \
"fi; "  \
"fi\0" \
+   EMMC_ENV  \
"mmcargs=setenv bootargs console=${console},${baudrate} " \
"root=${mmcroot}\0" \
"loadbootscript=" \
diff --git a/include/configs/mx6sabresd.h b/include/configs/mx6sabresd.h
index 3229bc7..7653ecb 100644
--- a/include/configs/mx6sabresd.h
+++ b/include/configs/mx6sabresd.h
@@ -30,6 +30,8 @@
 #define CONFIG_SYS_MMC_ENV_DEV 1   /* SDHC3 */
 #endif
 
+#define CONFIG_SUPPORT_EMMC_BOOT /* eMMC specific */
+
 /* Framebuffer */
 #define CONFIG_VIDEO
 #define CONFIG_VIDEO_IPUV3
-- 
1.8.4.rc3

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [RESEND PATCH 1/3] mx28evk: Use 512k for fdt partition to align it

2013-10-21 Thread Otavio Salvador
Using 512k for fdt partition allow it to be aligned with the other
small partitions and 512k erase block size.

Signed-off-by: Otavio Salvador 
---
 include/configs/mx28evk.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/configs/mx28evk.h b/include/configs/mx28evk.h
index 07f88ca..27b1a41 100644
--- a/include/configs/mx28evk.h
+++ b/include/configs/mx28evk.h
@@ -97,7 +97,7 @@
"512k(environment),"\
"512k(redundant-environment),"  \
"4m(kernel),"   \
-   "128k(fdt),"\
+   "512k(fdt),"\
"8m(ramdisk),"  \
"-(filesystem)"
 #endif
-- 
1.8.4.rc3

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH] kirkwood: ib62x0: use device tree and update config

2013-10-21 Thread Marek Vasut
Dear Luka Perkov,

> Hi Fabio,
> 
> On Sun, Oct 13, 2013 at 11:41:44PM -0300, Fabio Estevam wrote:
> > On Sun, Oct 13, 2013 at 11:38 PM, Luka Perkov  wrote:
> > >  /*
> > > 
> > > - * Machine type
> > > + * Enable device tree support
> > > 
> > >   */
> > > 
> > > -#define CONFIG_MACH_TYPE   MACH_TYPE_NAS6210
> > > +#define CONFIG_OF_LIBFDT
> > 
> > I am not familiar with this platform, but couldn't you also keep
> > CONFIG_MACH_TYPE ?
> > 
> > This way people have the option to load both dt and non-dt kernels.
> 
> Upstream uses only DT. When uboot support was pushed we had non-DT
> kernel patches that were never merged upstream. IMO we should just drop
> CONFIG_MACH_TYPE and use CONFIG_OF_LIBFDT.

You are breaking compatibility here, so you should keep the machine ID .

Best regards,
Marek Vasut
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] Does uboot support HID-I2C

2013-10-21 Thread David Goodenough
It would appear that there is a standard for running keyboards on I2C,
and that Windows 8 and Linux both support it.  But I could not find
any references to uboot support.  Is it supported or planned?

Apparently the standard has been around for about a year (I think
Microsoft originally wrote it), and that now chip support is being
offered to make it easy to deliver (TI just announced the TCA8424
chip).

David

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH v2 01/19] Makefile: prepare for using Kbuild-style Makefile

2013-10-21 Thread Simon Glass
Hi Masahiro,

On Sun, Oct 20, 2013 at 10:56 PM, Masahiro Yamada
 wrote:
> Hello, Simon.
>
>
>> >> Would looking for obj- be better or worse?
>> >
>> > At first I thought of this but I was kind of worried
>> > whether all makefiles should forcibly have obj-y or obj-.
>> >
>> > arch/arm/cpu/armv7/tegra114/
>> > arch/arm/cpu/armv7/tegra30/
>> > directories have no source files but only a Makefile.
>> >
>> > After all, I simply added
>> > obj- :=
>> > line in them, so I think your suggestion will work.
>> >
>> > If you prefer to search obj-, I will consider to change at version 3.
>>
>> No, it doesn't matter, it sounds like what you are doing is just as
>> good, and it is temporary as you say. I wonder how temporary?
>
>
> I posted a new series
> "Third step towards Kbuild: Convert rest of makefiles" (consists of 18 patch 
> files)
> The series deletes the temporary grep switch.
>
> Altough it is Tom who decides when the series should be applied,
> I hope it is not so late.

The merge window only opened recently so it should be fine.

Regards,
Simon


>
>
> Best Regards
> Masahiro Yamada
>
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] fdt performance

2013-10-21 Thread Wolfgang Denk
Dear Michael,

In message  
you wrote:
>
> > > it's possible that these checks could be simply optimised away. The
> >
> > This is not hwat happens.
> 
> Actually, it is my understanding that the "if (p + len < p)" can be
> optimized away.  This exact case is discussed in the LWN article "GCC and
> pointer overflows"[1].

No, this does not apply here.  You miss a key point.  We are not doing
any pointer arithmetics here.  We have:

int offset;
unsigned int len;

and then do:

if (((offset + len) < offset) ...) ...

> Basically, the C standard states that pointer arithmetic should not cause
> overflow, thus allowing the compiler to assume that "p + len" must always
> be greater than "p".

This is totally irrelevant here.  There are no pointers being used
here.

> --001a1133769056575204e93035f1
> Content-Type: text/html; charset=UTF-8
> Content-Transfer-Encoding: quoted-printable

Can you please stop posting HTML?  Thanks!

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: w...@denx.de
The human race is faced with a cruel choice: work  or  daytime  tele-
vision.
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [RFC] ARM: U-boot and 2 GiB of ram with get_ram_size only being long

2013-10-21 Thread Wolfgang Denk
Dear Scott Wood,

In message <1382138723.7979.928.ca...@snotra.buserror.net> you wrote:
>
> And the one 64-bit environment that we're about to have in U-Boot
> (armv8) has discontiguous memory, which is another case where
> get_ram_size() won't work.

get_ram_size() is supposed to be run per memory bank.  If you have
discontiguous memory, then you probably have several memory banks that
can be sized separately?

> BTW, shouldn't get_ram_size restore the original data in the final
> "return (maxsize)" case?  I know, patches welcome. :-)

Yes, get_ram_size() is non-destructive (at least in the no-error
case; otherwise things like PRAM would not work).

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: w...@denx.de
I think there's a world market for about five computers.
 -- attr. Thomas J. Watson (Chairman of the Board, IBM), 1943
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH v5 03/16] sandbox: config: Don't use 64-bit physical memory

2013-10-21 Thread Simon Glass
Sandbox uses an emulated memory map which is quite small. We don't need the
CONFIG_PHYS_64BIT option since we can address memory with a 32-bit offset
into our ram_buf.

Adjust the phys_addr_t and phys_size_t types accordingly.

Signed-off-by: Simon Glass 
---
Changes in v5: None
Changes in v4: None
Changes in v3: None
Changes in v2: None

 arch/sandbox/include/asm/types.h | 4 ++--
 include/configs/sandbox.h| 1 -
 2 files changed, 2 insertions(+), 3 deletions(-)

diff --git a/arch/sandbox/include/asm/types.h b/arch/sandbox/include/asm/types.h
index 88c84ba..6d3eb1f 100644
--- a/arch/sandbox/include/asm/types.h
+++ b/arch/sandbox/include/asm/types.h
@@ -48,8 +48,8 @@ typedef unsigned long long u64;
 #define BITS_PER_LONG  CONFIG_SANDBOX_BITS_PER_LONG
 
 typedef unsigned long dma_addr_t;
-typedef unsigned long phys_addr_t;
-typedef unsigned long phys_size_t;
+typedef u32 phys_addr_t;
+typedef u32 phys_size_t;
 
 #endif /* __KERNEL__ */
 
diff --git a/include/configs/sandbox.h b/include/configs/sandbox.h
index 4027030..d6b6c75 100644
--- a/include/configs/sandbox.h
+++ b/include/configs/sandbox.h
@@ -72,7 +72,6 @@
 #define CONFIG_SYS_LOAD_ADDR   0x
 #define CONFIG_SYS_MEMTEST_START   0x0010
 #define CONFIG_SYS_MEMTEST_END (CONFIG_SYS_MEMTEST_START + 0x1000)
-#define CONFIG_PHYS_64BIT
 #define CONFIG_SYS_FDT_LOAD_ADDR   0x100
 
 /* Size of our emulated memory */
-- 
1.8.4

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH v5 15/16] dm: Enable gpio command to support driver model

2013-10-21 Thread Simon Glass
Now that named GPIO banks are supported, along with a way of obtaining
the status of a GPIO (input or output), we can provide an enhanced
GPIO command for driver model. Where the driver provides its own operation
for obtaining the GPIO state, this is used, otherwise a generic version
is sufficient.

Signed-off-by: Simon Glass 
---
Changes in v5: None
Changes in v4: None
Changes in v3: None
Changes in v2: None

 common/cmd_gpio.c | 127 --
 1 file changed, 114 insertions(+), 13 deletions(-)

diff --git a/common/cmd_gpio.c b/common/cmd_gpio.c
index 47eee89..c6758c1 100644
--- a/common/cmd_gpio.c
+++ b/common/cmd_gpio.c
@@ -8,7 +8,7 @@
 
 #include 
 #include 
-
+#include 
 #include 
 
 #ifndef name_to_gpio
@@ -22,25 +22,115 @@ enum gpio_cmd {
GPIO_TOGGLE,
 };
 
+#if defined(CONFIG_DM_GPIO) && !defined(gpio_status)
+static const char * const gpio_function[] = {
+   "input",
+   "output",
+   "unknown",
+};
+
+static void show_gpio(struct device *dev, const char *bank_name, int offset)
+{
+   struct dm_gpio_ops *ops = gpio_get_ops(dev);
+   char buf[80];
+   int ret;
+
+   *buf = '\0';
+   if (ops->get_state) {
+   ret = ops->get_state(dev, offset, buf, sizeof(buf));
+   if (ret) {
+   puts("");
+   return;
+   }
+   } else {
+   int func =  GPIOF_UNKNOWN;
+   int ret;
+
+   if (ops->get_function) {
+   ret = ops->get_function(dev, offset);
+   if (ret >= 0 && ret < ARRAY_SIZE(gpio_function))
+   func = ret;
+   }
+   sprintf(buf, "%s%u: %8s %d", bank_name, offset,
+   gpio_function[func], ops->get_value(dev, offset));
+   }
+
+   puts(buf);
+   puts("\n");
+}
+
+static int do_gpio_status(const char *gpio_name)
+{
+   struct device *dev;
+   int newline = 0;
+   int ret;
+
+   if (gpio_name && !*gpio_name)
+   gpio_name = NULL;
+   for (ret = uclass_first_device(UCLASS_GPIO, &dev);
+dev;
+ret = uclass_next_device(&dev)) {
+   const char *bank_name;
+   int num_bits;
+
+   bank_name = gpio_get_bank_info(dev, &num_bits);
+
+   if (!gpio_name || !bank_name ||
+   !strncmp(gpio_name, bank_name, strlen(bank_name))) {
+   const char *p = NULL;
+   int offset;
+
+   if (bank_name) {
+   if (newline)
+   putc('\n');
+   printf("Bank %s:\n", bank_name);
+   }
+   newline = 1;
+   if (gpio_name && bank_name) {
+   p = gpio_name + strlen(bank_name);
+   offset = simple_strtoul(p, NULL, 10);
+   show_gpio(dev, bank_name, offset);
+   } else {
+   for (offset = 0; offset < num_bits; offset++)
+   show_gpio(dev, bank_name, offset);
+   }
+   }
+   }
+
+   return ret;
+}
+#endif
+
 static int do_gpio(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 {
-   int gpio;
+   unsigned int gpio;
enum gpio_cmd sub_cmd;
ulong value;
-   const char *str_cmd, *str_gpio;
+   const char *str_cmd, *str_gpio = NULL;
+#ifdef CONFIG_DM_GPIO
+   int ret;
+#endif
 
+   if (argc < 2)
+ show_usage:
+   return CMD_RET_USAGE;
+   str_cmd = argv[1];
+   if (argc > 2)
+   str_gpio = argv[2];
+   if (!strcmp(str_cmd, "status")) {
+   /* Support deprecated gpio_status() */
 #ifdef gpio_status
-   if (argc == 2 && !strcmp(argv[1], "status")) {
gpio_status();
return 0;
-   }
+#elif defined(CONFIG_DM_GPIO)
+   return cmd_process_error(cmdtp, do_gpio_status(str_gpio));
+#else
+   goto show_usage;
 #endif
+   }
 
-   if (argc != 3)
- show_usage:
-   return CMD_RET_USAGE;
-   str_cmd = argv[1];
-   str_gpio = argv[2];
+   if (!str_gpio)
+   goto show_usage;
 
/* parse the behavior */
switch (*str_cmd) {
@@ -51,11 +141,21 @@ static int do_gpio(cmd_tbl_t *cmdtp, int flag, int argc, 
char * const argv[])
default:  goto show_usage;
}
 
+#if defined(CONFIG_DM_GPIO)
+   /*
+* TODO(s...@chromium.org): Convert this code over to use the GPIO
+* uclass interface instead of the numbered GPIO compatibility
+* layer.
+*/
+   ret = gpio_lookup_name(str_gpio, NULL, NULL, &gpio);
+   if (ret)
+   return cmd_process_error(cmd

[U-Boot] [PATCH v5 11/16] dm: Add a 'dm' command for testing

2013-10-21 Thread Simon Glass
This command is not required for driver model operation, but can be useful
for testing. It provides simple dumps of internal data structures.

Signed-off-by: Simon Glass 
Signed-off-by: Marek Vasut 
Signed-off-by: Pavel Herrmann 
Signed-off-by: Viktor Křivák 
Signed-off-by: Tomas Hlavacek 
---
Changes in v5:
- Change to new SPDX license headers

Changes in v4:
- Change 'dm dump' command to 'dm tree'

Changes in v3: None
Changes in v2: None

 include/configs/sandbox.h |   1 +
 test/dm/Makefile  |   1 +
 test/dm/cmd_dm.c  | 133 ++
 3 files changed, 135 insertions(+)
 create mode 100644 test/dm/cmd_dm.c

diff --git a/include/configs/sandbox.h b/include/configs/sandbox.h
index 7c74d57..8f594ac 100644
--- a/include/configs/sandbox.h
+++ b/include/configs/sandbox.h
@@ -19,6 +19,7 @@
 #define CONFIG_BOOTSTAGE
 #define CONFIG_BOOTSTAGE_REPORT
 #define CONFIG_DM
+#define CONFIG_CMD_DM
 #define CONFIG_DM_TEST
 
 /* Number of bits in a C 'long' on this architecture */
diff --git a/test/dm/Makefile b/test/dm/Makefile
index 3302e42..fb7b190 100644
--- a/test/dm/Makefile
+++ b/test/dm/Makefile
@@ -8,6 +8,7 @@ include $(TOPDIR)/config.mk
 
 LIB= $(obj)libtestdm.o
 
+COBJS-$(CONFIG_CMD_DM) += cmd_dm.o
 COBJS-$(CONFIG_DM_TEST) += test-driver.o
 COBJS-$(CONFIG_DM_TEST) += test-fdt.o
 COBJS-$(CONFIG_DM_TEST) += test-main.o
diff --git a/test/dm/cmd_dm.c b/test/dm/cmd_dm.c
new file mode 100644
index 000..a03fe20
--- /dev/null
+++ b/test/dm/cmd_dm.c
@@ -0,0 +1,133 @@
+/*
+ * Copyright (c) 2013 Google, Inc
+ *
+ * (C) Copyright 2012
+ * Marek Vasut 
+ *
+ * SPDX-License-Identifier:GPL-2.0+
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+static int display_succ(struct device *in, char *buf)
+{
+   int len;
+   int ip = 0;
+   char local[16];
+   struct device *pos, *n, *prev = NULL;
+
+   printf("%s- %s @ %08x", buf, in->name, map_to_sysmem(in));
+   if (in->flags & DM_FLAG_ACTIVATED)
+   puts(" - activated");
+   puts("\n");
+
+   if (list_empty(&in->child_head))
+   return 0;
+
+   len = strlen(buf);
+   strncpy(local, buf, sizeof(local));
+   snprintf(local + len, 2, "|");
+   if (len && local[len - 1] == '`')
+   local[len - 1] = ' ';
+
+   list_for_each_entry_safe(pos, n, &in->child_head, sibling_node) {
+   if (ip++)
+   display_succ(prev, local);
+   prev = pos;
+   }
+
+   snprintf(local + len, 2, "`");
+   display_succ(prev, local);
+
+   return 0;
+}
+
+static int dm_dump(struct device *dev)
+{
+   if (!dev)
+   return -EINVAL;
+   return display_succ(dev, "");
+}
+
+static int do_dm_dump_all(cmd_tbl_t *cmdtp, int flag, int argc,
+ char * const argv[])
+{
+   struct device *root;
+
+   root = dm_root();
+   printf("ROOT %08x\n", map_to_sysmem(root));
+   return dm_dump(root);
+}
+
+static int do_dm_dump_uclass(cmd_tbl_t *cmdtp, int flag, int argc,
+char * const argv[])
+{
+   struct uclass *uc;
+   int ret;
+   int id;
+
+   for (id = 0; id < UCLASS_COUNT; id++) {
+   struct device *dev;
+
+   ret = uclass_get(id, &uc);
+   if (ret)
+   continue;
+
+   printf("uclass %d: %s\n", id, uc->uc_drv->name);
+   for (ret = uclass_first_device(id, &dev);
+dev;
+ret = uclass_next_device(&dev)) {
+   printf("  %s @  %08x:\n", dev->name,
+  map_to_sysmem(dev));
+   }
+   puts("\n");
+   }
+
+   return 0;
+}
+
+static int do_dm_test(cmd_tbl_t *cmdtp, int flag, int argc,
+ char * const argv[])
+{
+   return dm_test_main();
+}
+
+static cmd_tbl_t test_commands[] = {
+   U_BOOT_CMD_MKENT(tree, 0, 1, do_dm_dump_all, "", ""),
+   U_BOOT_CMD_MKENT(uclass, 1, 1, do_dm_dump_uclass, "", ""),
+   U_BOOT_CMD_MKENT(test, 1, 1, do_dm_test, "", ""),
+};
+
+static int do_dm(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
+{
+   cmd_tbl_t *test_cmd;
+   int ret;
+
+   if (argc != 2)
+   return CMD_RET_USAGE;
+   test_cmd = find_cmd_tbl(argv[1], test_commands,
+   ARRAY_SIZE(test_commands));
+   argc -= 2;
+   argv += 2;
+   if (!test_cmd || argc > test_cmd->maxargs)
+   return CMD_RET_USAGE;
+
+   ret = test_cmd->cmd(test_cmd, flag, argc, argv);
+
+   return cmd_process_error(test_cmd, ret);
+}
+
+U_BOOT_CMD(
+   dm, 2,  1,  do_dm,
+   "Driver model low level access",
+   "tree Dump driver model tree\n"
+   "dm uclassDump list of instances for each uclass\n"
+   "dm test Run tests"
+);
-- 
1.8.

[U-Boot] [PATCH v5 05/16] Add cmd_process_error() to report and process errors

2013-10-21 Thread Simon Glass
U-Boot now uses errors defined in include/errno.h which are negative
integers. Commands which fail need to report the error and return 1
to indicate failure. Add this functionality in cmd_process_error().

For now this merely reports the error number. It would be possible
also to produce a helpful error message by storing the error strings
in U-Boot.

Signed-off-by: Simon Glass 
---
Changes in v5: None
Changes in v4: None
Changes in v3: None
Changes in v2: None

 common/command.c  | 10 ++
 include/command.h |  9 +
 2 files changed, 19 insertions(+)

diff --git a/common/command.c b/common/command.c
index 625571d..668aa8b 100644
--- a/common/command.c
+++ b/common/command.c
@@ -538,3 +538,13 @@ enum command_ret_t cmd_process(int flag, int argc, char * 
const argv[],
rc = cmd_usage(cmdtp);
return rc;
 }
+
+int cmd_process_error(cmd_tbl_t *cmdtp, int err)
+{
+   if (err) {
+   printf("Command '%s' failed: Error %d\n", cmdtp->name, err);
+   return 1;
+   }
+
+   return 0;
+}
diff --git a/include/command.h b/include/command.h
index f782779..d3f700f 100644
--- a/include/command.h
+++ b/include/command.h
@@ -64,6 +64,15 @@ extern int var_complete(int argc, char * const argv[], char 
last_char, int maxv,
 extern int cmd_auto_complete(const char *const prompt, char *buf, int *np, int 
*colp);
 #endif
 
+/**
+ * cmd_process_error() - report and process a possible error
+ *
+ * @cmdtp: Command which caused the error
+ * @err: Error code (0 if none, -ve for error, like -EIO)
+ * @return 0 if there is not error, 1 (CMD_RET_FAILURE) if an error is found
+ */
+int cmd_process_error(cmd_tbl_t *cmdtp, int err);
+
 /*
  * Monitor Command
  *
-- 
1.8.4

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH v5 09/16] dm: Set up driver model after relocation

2013-10-21 Thread Simon Glass
Make driver model available after relocation, by setting up data structures
and scanning for devices using compiled-in platform_data and (when available)
the device tree.

Signed-off-by: Simon Glass 
---
Changes in v5: None
Changes in v4: None
Changes in v3: None
Changes in v2: None

 common/board_r.c | 33 +
 1 file changed, 33 insertions(+)

diff --git a/common/board_r.c b/common/board_r.c
index 86ca1cb..6d3cd5e 100644
--- a/common/board_r.c
+++ b/common/board_r.c
@@ -18,6 +18,7 @@
 #ifdef CONFIG_HAS_DATAFLASH
 #include 
 #endif
+#include 
 #include 
 #include 
 #if defined(CONFIG_CMD_IDE)
@@ -51,7 +52,9 @@
 #ifdef CONFIG_X86
 #include 
 #endif
+#include 
 #include 
+#include 
 
 DECLARE_GLOBAL_DATA_PTR;
 
@@ -263,6 +266,33 @@ static int initr_malloc(void)
return 0;
 }
 
+#ifdef CONFIG_DM
+static int initr_dm(void)
+{
+   int ret;
+
+   ret = dm_init();
+   if (ret) {
+   debug("dm_init() failed: %d\n", ret);
+   return ret;
+   }
+   ret = dm_scan_platform_data();
+   if (ret) {
+   debug("dm_scan_platform_data() failed: %d\n", ret);
+   return ret;
+   }
+#ifdef CONFIG_OF_CONTROL
+   ret = dm_scan_fdt(gd->fdt_blob);
+   if (ret) {
+   debug("dm_scan_fdt() failed: %d\n", ret);
+   return ret;
+   }
+#endif
+
+   return 0;
+}
+#endif
+
 __weak int power_init_board(void)
 {
return 0;
@@ -761,6 +791,9 @@ init_fnc_t init_sequence_r[] = {
initr_barrier,
initr_malloc,
bootstage_relocate,
+#ifdef CONFIG_DM
+   initr_dm,
+#endif
 #ifdef CONFIG_ARCH_EARLY_INIT_R
arch_early_init_r,
 #endif
-- 
1.8.4

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH v5 0/16] Driver model implementation, tests, demo and GPIO

2013-10-21 Thread Simon Glass

Note: If you are reviewing this code, but don't have a lot of time, please
consider starting with the 'demo' driver (patch 'dm: Add a
demonstration/example driver') since it clearly shows how devices and
uclasses work. Much of this series consists of test code and plumbing, so
is of less interest to driver authors.

This patch adds a driver model implementation. It is taken from
the driver model code developed by:

   Marek Vasut 
   Pavel Herrmann 
   Viktor Křivák 
   Tomas Hlavacek 

Please see doc/driver-model/README.txt for details of how to run this and
what to look for. So far the documentation in doc/driver-model has not
been updated.

You can find a test version of the code used here in branch dm4 at:

   http://git.denx.de/u-boot-x86.git

(Branch dm contains the original implementation)

Changes in v5:
- Change to new SPDX license headers
- Correct >80col line missed last time
- Change to new SPDX license headers
- Fix style nit on for() loop
- Change to new SPDX license headers
- Change to new SPDX license headers
- Change to new SPDX license headers
- Adjust patch to completely remove old driver model documentation

Changes in v4:
- Move common/dm to drivers/core
- device_chld_unbind() continues on error
- Correct 'out.dtb' typo
- Change 'dm dump' command to 'dm tree'
- Remove duplicated .op line

Changes in v3:
- Add new patch to build a device tree file for sandbox
- Updated README.txt to cover changes since version 2
- Tidy up commenting of functions and structures
- Rename per_device_priv_size to per_device_auto_alloc_size, etc.
- Add a flag for tracking whether DM allocates/frees platform_data
- Add function/struct comments to tests
- Fix up demo command help
- Update demo driver to use device tree
- Update GPIO support to use new struct member names
- Tidy up comments/documentation in GPIO module
- Update sandbox GPIO header file comments
- Add new patch to move driver model documentation

Changes in v2:
- Removed pointer return values in favour of integer
- Use driver_bind() in dm_init() instead of writing new code
- Allow driver_bind() to support a NULL parent
- Add dm_warn() to warn about impending doom
- Standardise variable names (e.g. uclass instead of class)
- Remove relocation functions
- Add new header file for lists
- Add new util file to hold utility functions
- Allow a driver to bind to only one uclass
- Remove unneeded arguments to uclass_bind(), uclass_unbind()
- Rename struct device's 'bus' to 'parent'
- Rename data structures to hopefully be clearer
- Put platform_data definitions in their own header file
- Add U_BOOT_DEVICE to declare platform_data
- Add auto-probing feature for platform_data to avoid driver_bind() calls
- Add simple unit test functions
- Add test infrastructure for driver model
- Add integration tests for driver model
- Add device tree support in driver model
- Add automatic allocation of platform_data for FDT
- Add automatic allocation of priv data for devices
- Add automatic allocation of device-specific priv data for uclasses
- Add GPIO uclass and tests
- Add sandbox GPIO driver
- Update gpio command to use driver model
- Add tests for core code
- Add script to run tests
- Add a single include/dm.h to bring in driver model code

Simon Glass (16):
  sandbox: Make map_to_sysmem() use a constant pointer
  sandbox: Correct data sizes and printf() strings in fdtdec.c
  sandbox: config: Don't use 64-bit physical memory
  sandbox: Build a device tree file for sandbox
  Add cmd_process_error() to report and process errors
  dm: Add README for driver model
  dm: Add base driver model support
  sandbox: config: Enable driver model
  dm: Set up driver model after relocation
  dm: Add basic tests
  dm: Add a 'dm' command for testing
  dm: Add a demonstration/example driver
  dm: Add GPIO support and tests
  sandbox: Convert GPIOs to use driver model
  dm: Enable gpio command to support driver model
  dm: Remove old driver model documentation

 Makefile  |   4 +
 arch/sandbox/config.mk|   2 +
 arch/sandbox/include/asm/gpio.h   |  14 +-
 arch/sandbox/include/asm/io.h |   2 +-
 arch/sandbox/include/asm/types.h  |   4 +-
 board/sandbox/dts/sandbox.dts |  20 ++
 board/sandbox/sandbox/sandbox.c   |   7 +-
 common/Makefile   |   1 +
 common/board_r.c  |  33 +++
 common/cmd_demo.c | 102 +++
 common/cmd_gpio.c | 127 -
 common/command.c  |  10 +
 doc/driver-model/README.txt   | 321 ++
 doc/driver-model/UDM-block.txt| 278 ---
 doc/driver-model/UDM-cores.txt| 126 -
 doc/driver-model/UDM-design.txt   | 315 --
 doc/driver-model/UDM-fpga.txt | 115 
 doc/driver-model/UDM-gpio.txt | 106 
 doc/driver-model/UDM-hwmon.txt| 118 -
 doc/driver-model/UDM-keyboard.txt |  47 
 doc/driver-model/UDM-mmc.txt  | 319 --
 

[U-Boot] [PATCH v5 01/16] sandbox: Make map_to_sysmem() use a constant pointer

2013-10-21 Thread Simon Glass
Very often a constant pointer is passed to this function, so we should
declare this, since map_to_sysmem() does not change the pointer.

Signed-off-by: Simon Glass 
---
Changes in v5: None
Changes in v4: None
Changes in v3: None
Changes in v2: None

 arch/sandbox/include/asm/io.h | 2 +-
 include/common.h  | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/sandbox/include/asm/io.h b/arch/sandbox/include/asm/io.h
index 9ac6a5f..7956041 100644
--- a/arch/sandbox/include/asm/io.h
+++ b/arch/sandbox/include/asm/io.h
@@ -38,6 +38,6 @@ static inline void unmap_sysmem(const void *vaddr)
 }
 
 /* Map from a pointer to our RAM buffer */
-phys_addr_t map_to_sysmem(void *ptr);
+phys_addr_t map_to_sysmem(const void *ptr);
 
 #endif
diff --git a/include/common.h b/include/common.h
index 409515f..8ca67f6 100644
--- a/include/common.h
+++ b/include/common.h
@@ -923,7 +923,7 @@ static inline void unmap_sysmem(const void *vaddr)
 {
 }
 
-static inline phys_addr_t map_to_sysmem(void *ptr)
+static inline phys_addr_t map_to_sysmem(const void *ptr)
 {
return (phys_addr_t)(uintptr_t)ptr;
 }
-- 
1.8.4

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH v5 14/16] sandbox: Convert GPIOs to use driver model

2013-10-21 Thread Simon Glass
Convert sandbox over to use driver model GPIOs.

Signed-off-by: Simon Glass 
---
Changes in v5: None
Changes in v4: None
Changes in v3:
- Update sandbox GPIO header file comments

Changes in v2: None

 arch/sandbox/include/asm/gpio.h |  14 +--
 board/sandbox/sandbox/sandbox.c |   7 +-
 drivers/gpio/sandbox.c  | 210 +---
 include/configs/sandbox.h   |   1 +
 4 files changed, 144 insertions(+), 88 deletions(-)

diff --git a/arch/sandbox/include/asm/gpio.h b/arch/sandbox/include/asm/gpio.h
index afb9c78..95b59da 100644
--- a/arch/sandbox/include/asm/gpio.h
+++ b/arch/sandbox/include/asm/gpio.h
@@ -29,7 +29,7 @@
  * @param gp   GPIO number
  * @return -1 on error, 0 if GPIO is low, >0 if high
  */
-int sandbox_gpio_get_value(unsigned gp);
+int sandbox_gpio_get_value(struct device *dev, unsigned int offset);
 
 /**
  * Set the simulated value of a GPIO (used only in sandbox test code)
@@ -38,7 +38,7 @@ int sandbox_gpio_get_value(unsigned gp);
  * @param valuevalue to set (0 for low, non-zero for high)
  * @return -1 on error, 0 if ok
  */
-int sandbox_gpio_set_value(unsigned gp, int value);
+int sandbox_gpio_set_value(struct device *dev, unsigned int offset, int value);
 
 /**
  * Return the simulated direction of a GPIO (used only in sandbox test code)
@@ -46,7 +46,7 @@ int sandbox_gpio_set_value(unsigned gp, int value);
  * @param gp   GPIO number
  * @return -1 on error, 0 if GPIO is input, >0 if output
  */
-int sandbox_gpio_get_direction(unsigned gp);
+int sandbox_gpio_get_direction(struct device *dev, unsigned int offset);
 
 /**
  * Set the simulated direction of a GPIO (used only in sandbox test code)
@@ -55,11 +55,7 @@ int sandbox_gpio_get_direction(unsigned gp);
  * @param output 0 to set as input, 1 to set as output
  * @return -1 on error, 0 if ok
  */
-int sandbox_gpio_set_direction(unsigned gp, int output);
-
-/* Display information about each GPIO */
-void gpio_info(void);
-
-#define gpio_status()  gpio_info()
+int sandbox_gpio_set_direction(struct device *dev, unsigned int offset,
+  int output);
 
 #endif
diff --git a/board/sandbox/sandbox/sandbox.c b/board/sandbox/sandbox/sandbox.c
index f471cb7..ea56065 100644
--- a/board/sandbox/sandbox/sandbox.c
+++ b/board/sandbox/sandbox/sandbox.c
@@ -4,7 +4,7 @@
  */
 
 #include 
-
+#include 
 #include 
 
 /*
@@ -14,6 +14,11 @@
  */
 gd_t *gd;
 
+/* Add a simple GPIO device */
+U_BOOT_DEVICE(gpio_sandbox) = {
+   .name = "gpio_sandbox",
+};
+
 void flush_cache(unsigned long start, unsigned long size)
 {
 }
diff --git a/drivers/gpio/sandbox.c b/drivers/gpio/sandbox.c
index 3c6cfec..1d07403 100644
--- a/drivers/gpio/sandbox.c
+++ b/drivers/gpio/sandbox.c
@@ -4,8 +4,13 @@
  */
 
 #include 
+#include 
+#include 
+#include 
 #include 
 
+DECLARE_GLOBAL_DATA_PTR;
+
 /* Flags for each GPIO */
 #define GPIOF_OUTPUT   (1 << 0)/* Currently set as an output */
 #define GPIOF_HIGH (1 << 1)/* Currently set high */
@@ -16,34 +21,30 @@ struct gpio_state {
u8 flags;   /* flags (GPIOF_...) */
 };
 
-/*
- * State of GPIOs
- * TODO: Put this into sandbox state
- */
-static struct gpio_state state[CONFIG_SANDBOX_GPIO_COUNT];
-
 /* Access routines for GPIO state */
-static u8 *get_gpio_flags(unsigned gp)
+static u8 *get_gpio_flags(struct device *dev, unsigned offset)
 {
-   /* assert()'s could be disabled, so make sure we handle that */
-   assert(gp < ARRAY_SIZE(state));
-   if (gp >= ARRAY_SIZE(state)) {
+   struct gpio_dev_priv *uc_priv = dev->uclass_priv;
+   struct gpio_state *state = dev->priv;
+
+   if (offset >= uc_priv->gpio_count) {
static u8 invalid_flags;
-   printf("sandbox_gpio: error: invalid gpio %u\n", gp);
+   printf("sandbox_gpio: error: invalid gpio %u\n", offset);
return &invalid_flags;
}
 
-   return &state[gp].flags;
+   return &state[offset].flags;
 }
 
-static int get_gpio_flag(unsigned gp, int flag)
+static int get_gpio_flag(struct device *dev, unsigned offset, int flag)
 {
-   return (*get_gpio_flags(gp) & flag) != 0;
+   return (*get_gpio_flags(dev, offset) & flag) != 0;
 }
 
-static int set_gpio_flag(unsigned gp, int flag, int value)
+static int set_gpio_flag(struct device *dev, unsigned offset, int flag,
+int value)
 {
-   u8 *gpio = get_gpio_flags(gp);
+   u8 *gpio = get_gpio_flags(dev, offset);
 
if (value)
*gpio |= flag;
@@ -53,11 +54,12 @@ static int set_gpio_flag(unsigned gp, int flag, int value)
return 0;
 }
 
-static int check_reserved(unsigned gpio, const char *func)
+static int check_reserved(struct device *dev, unsigned offset,
+ const char *func)
 {
-   if (!get_gpio_flag(gpio, GPIOF_RESERVED)) {
-   printf("sandbox_gpio: %s: error: gpio %u not reserved\n",
-   func, gpio);
+   if 

[U-Boot] [PATCH v5 02/16] sandbox: Correct data sizes and printf() strings in fdtdec.c

2013-10-21 Thread Simon Glass
There are a few warnings in this file when building for sandbox. Addresses
coming from the device tree need to be treated as ulong as elsewhere in
U-Boot and we must use map_sysmem() to convert to a pointer when needed.

Signed-off-by: Simon Glass 
---
Changes in v5: None
Changes in v4: None
Changes in v3: None
Changes in v2: None

 lib/fdtdec.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/lib/fdtdec.c b/lib/fdtdec.c
index dc35856..692bcc6 100644
--- a/lib/fdtdec.c
+++ b/lib/fdtdec.c
@@ -84,10 +84,10 @@ fdt_addr_t fdtdec_get_addr_size(const void *blob, int node,
size = (fdt_size_t *)((char *)cell +
sizeof(fdt_addr_t));
*sizep = fdt_size_to_cpu(*size);
-   debug("addr=%p, size=%p\n", (void *)addr,
- (void *)*sizep);
+   debug("addr=%08lx, size=%08x\n",
+ (ulong)addr, *sizep);
} else {
-   debug("%p\n", (void *)addr);
+   debug("%08lx\n", (ulong)addr);
}
return addr;
}
@@ -609,7 +609,7 @@ int fdtdec_decode_region(const void *blob, int node,
if (!cell || (len != sizeof(fdt_addr_t) * 2))
return -1;
 
-   *ptrp = (void *)fdt_addr_to_cpu(*cell);
+   *ptrp = map_sysmem(fdt_addr_to_cpu(*cell), *size);
*size = fdt_size_to_cpu(cell[1]);
debug("%s: size=%zx\n", __func__, *size);
return 0;
-- 
1.8.4

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH v5 10/16] dm: Add basic tests

2013-10-21 Thread Simon Glass
Add some tests of driver model functionality. Coverage includes:

- basic init
- binding of drivers to devices using platform_data
- automatic probing of devices when referenced
- availability of platform data to devices
- lifecycle from bind to probe to remove to unbind
- renumbering within a uclass when devices are probed/removed
- calling driver-defined operations
- deactivation of drivers when removed
- memory leak across creation and destruction of drivers/uclasses
- uclass init/destroy methods
- automatic probe/remove of children/parents when needed

This function is enabled for sandbox, using CONFIG_DM_TEST.

Signed-off-by: Simon Glass 
---
Changes in v5:
- Change to new SPDX license headers
- Fix style nit on for() loop

Changes in v4:
- Correct 'out.dtb' typo

Changes in v3:
- Add function/struct comments to tests

Changes in v2: None

 Makefile  |   1 +
 include/configs/sandbox.h |   1 +
 include/dm/test.h | 167 ++
 include/dm/ut.h   |  95 
 test/dm/Makefile  |  39 
 test/dm/core.c| 544 ++
 test/dm/test-driver.c | 146 +
 test/dm/test-fdt.c| 135 
 test/dm/test-main.c   | 107 +
 test/dm/test-uclass.c | 104 +
 test/dm/test.dts  |  59 +
 test/dm/ut.c  |  33 +++
 12 files changed, 1431 insertions(+)
 create mode 100644 include/dm/test.h
 create mode 100644 include/dm/ut.h
 create mode 100644 test/dm/Makefile
 create mode 100644 test/dm/core.c
 create mode 100644 test/dm/test-driver.c
 create mode 100644 test/dm/test-fdt.c
 create mode 100644 test/dm/test-main.c
 create mode 100644 test/dm/test-uclass.c
 create mode 100644 test/dm/test.dts
 create mode 100644 test/dm/ut.c

diff --git a/Makefile b/Makefile
index 63dd8af..c58aa5a 100644
--- a/Makefile
+++ b/Makefile
@@ -324,6 +324,7 @@ LIBS-y += api/libapi.o
 LIBS-y += post/libpost.o
 LIBS-y += test/libtest.o
 LIBS-$(CONFIG_DM) += drivers/core/libdm.o
+LIBS-y += test/dm/libtestdm.o
 
 ifneq ($(CONFIG_OMAP_COMMON),)
 LIBS-y += $(CPUDIR)/omap-common/libomap-common.o
diff --git a/include/configs/sandbox.h b/include/configs/sandbox.h
index f9c96eb..7c74d57 100644
--- a/include/configs/sandbox.h
+++ b/include/configs/sandbox.h
@@ -19,6 +19,7 @@
 #define CONFIG_BOOTSTAGE
 #define CONFIG_BOOTSTAGE_REPORT
 #define CONFIG_DM
+#define CONFIG_DM_TEST
 
 /* Number of bits in a C 'long' on this architecture */
 #define CONFIG_SANDBOX_BITS_PER_LONG   64
diff --git a/include/dm/test.h b/include/dm/test.h
new file mode 100644
index 000..eeaa2eb
--- /dev/null
+++ b/include/dm/test.h
@@ -0,0 +1,167 @@
+/*
+ * Copyright (c) 2013 Google, Inc.
+ *
+ * SPDX-License-Identifier:GPL-2.0+
+ */
+
+#ifndef __DM_TEST_H
+#define __DM_TEST_H
+
+#include 
+
+/**
+ * struct dm_test_cdata - configuration data for test instance
+ *
+ * @ping_add: Amonut to add each time we get a ping
+ * @base: Base address of this device
+ */
+struct dm_test_pdata {
+   int ping_add;
+   uint32_t base;
+};
+
+/**
+ * struct test_ops - Operations supported by the test device
+ *
+ * @ping: Ping operation
+ * @dev: Device to operate on
+ * @pingval: Value to ping the device with
+ * @pingret: Returns resulting value from driver
+ * @return 0 if OK, -ve on error
+ */
+struct test_ops {
+   int (*ping)(struct device *dev, int pingval, int *pingret);
+};
+
+/* Operations that our test driver supports */
+enum {
+   DM_TEST_OP_BIND = 0,
+   DM_TEST_OP_UNBIND,
+   DM_TEST_OP_PROBE,
+   DM_TEST_OP_REMOVE,
+
+   /* For uclass */
+   DM_TEST_OP_POST_BIND,
+   DM_TEST_OP_PRE_UNBIND,
+   DM_TEST_OP_POST_PROBE,
+   DM_TEST_OP_PRE_REMOVE,
+   DM_TEST_OP_INIT,
+   DM_TEST_OP_DESTROY,
+
+   DM_TEST_OP_COUNT,
+};
+
+/* Test driver types */
+enum {
+   DM_TEST_TYPE_FIRST = 0,
+   DM_TEST_TYPE_SECOND,
+};
+
+/* The number added to the ping total on each probe */
+#define DM_TEST_START_TOTAL5
+
+/**
+ * struct dm_test_priv - private data for the test devices
+ */
+struct dm_test_priv {
+   int ping_total;
+   int op_count[DM_TEST_OP_COUNT];
+};
+
+/**
+ * struct dm_test_perdev_class_priv - private per-device data for test uclass
+ */
+struct dm_test_uclass_perdev_priv {
+   int base_add;
+};
+
+/**
+ * struct dm_test_uclass_priv - private data for test uclass
+ */
+struct dm_test_uclass_priv {
+   int total_add;
+};
+
+/*
+ * Operation counts for the test driver, used to check that each method is
+ * called correctly
+ */
+extern int dm_testdrv_op_count[DM_TEST_OP_COUNT];
+
+extern struct dm_test_state global_test_state;
+
+/*
+ * struct dm_test_state - Entire state of dm test system
+ *
+ * This is often abreviated to dms.
+ *
+ * @root: Root device
+ * @testdev: Test device
+ * @fail_count: Number of tests that failed
+ * @force_fail_alloc: Force all memory allocs to fail
+ * @skip_post_probe: Skip uclass post-p

[U-Boot] [PATCH v5 12/16] dm: Add a demonstration/example driver

2013-10-21 Thread Simon Glass
As an example of how to write a uclass and a driver, provide a demo version
of each, accessible through the 'demo' command.

To use these with driver model, define CONFIG_CMD_DEMO and CONFIG_DM_DEMO.

The two demo drivers are enabled with CONFIG_DM_DEMO_SIMPLE and
CONFIG_DM_DEMO_SHAPE.

Signed-off-by: Simon Glass 
Signed-off-by: Marek Vasut 
Signed-off-by: Pavel Herrmann 
Signed-off-by: Viktor Křivák 
Signed-off-by: Tomas Hlavacek 
---
Changes in v5:
- Change to new SPDX license headers

Changes in v4:
- Remove duplicated .op line

Changes in v3:
- Fix up demo command help
- Update demo driver to use device tree

Changes in v2: None

 Makefile   |   1 +
 common/Makefile|   1 +
 common/cmd_demo.c  | 102 +++
 drivers/demo/Makefile  |  31 +++
 drivers/demo/demo-pdata.c  |  47 
 drivers/demo/demo-shape.c  | 130 +
 drivers/demo/demo-simple.c |  47 
 drivers/demo/demo-uclass.c |  60 +
 include/configs/sandbox.h  |   4 ++
 include/dm-demo.h  |  36 +
 10 files changed, 459 insertions(+)
 create mode 100644 common/cmd_demo.c
 create mode 100644 drivers/demo/Makefile
 create mode 100644 drivers/demo/demo-pdata.c
 create mode 100644 drivers/demo/demo-shape.c
 create mode 100644 drivers/demo/demo-simple.c
 create mode 100644 drivers/demo/demo-uclass.c
 create mode 100644 include/dm-demo.h

diff --git a/Makefile b/Makefile
index c58aa5a..c78afa0 100644
--- a/Makefile
+++ b/Makefile
@@ -325,6 +325,7 @@ LIBS-y += post/libpost.o
 LIBS-y += test/libtest.o
 LIBS-$(CONFIG_DM) += drivers/core/libdm.o
 LIBS-y += test/dm/libtestdm.o
+LIBS-$(CONFIG_DM_DEMO) += drivers/demo/libdemo.o
 
 ifneq ($(CONFIG_OMAP_COMMON),)
 LIBS-y += $(CPUDIR)/omap-common/libomap-common.o
diff --git a/common/Makefile b/common/Makefile
index 288690b..dbaa407 100644
--- a/common/Makefile
+++ b/common/Makefile
@@ -67,6 +67,7 @@ COBJS-$(CONFIG_CMD_CONSOLE) += cmd_console.o
 COBJS-$(CONFIG_CMD_CPLBINFO) += cmd_cplbinfo.o
 COBJS-$(CONFIG_DATAFLASH_MMC_SELECT) += cmd_dataflash_mmc_mux.o
 COBJS-$(CONFIG_CMD_DATE) += cmd_date.o
+COBJS-$(CONFIG_CMD_DEMO) += cmd_demo.o
 COBJS-$(CONFIG_CMD_SOUND) += cmd_sound.o
 ifdef CONFIG_4xx
 COBJS-$(CONFIG_CMD_SETGETDCR) += cmd_dcr.o
diff --git a/common/cmd_demo.c b/common/cmd_demo.c
new file mode 100644
index 000..c0747d0
--- /dev/null
+++ b/common/cmd_demo.c
@@ -0,0 +1,102 @@
+/*
+ * Copyright (c) 2013 Google, Inc
+ *
+ * (C) Copyright 2012
+ * Pavel Herrmann 
+ *
+ * SPDX-License-Identifier:GPL-2.0+
+ */
+
+#include 
+#include 
+#include 
+
+struct device *demo_dev;
+
+static int do_demo_hello(cmd_tbl_t *cmdtp, int flag, int argc,
+char * const argv[])
+{
+   int ch = 0;
+
+   if (argc)
+   ch = *argv[0];
+
+   return demo_hello(demo_dev, ch);
+}
+
+static int do_demo_status(cmd_tbl_t *cmdtp, int flag, int argc,
+ char * const argv[])
+{
+   int status;
+   int ret;
+
+   ret = demo_status(demo_dev, &status);
+   if (ret)
+   return ret;
+
+   printf("Status: %d\n", status);
+
+   return 0;
+}
+
+int do_demo_list(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
+{
+   struct device *dev;
+   int i, ret;
+
+   puts("Demo uclass entries:\n");
+
+   for (i = 0, ret = uclass_first_device(UCLASS_DEMO, &dev);
+dev;
+ret = uclass_next_device(&dev)) {
+   printf("entry %d - instance %08x, ops %08x, platform_data 
%08x\n",
+  i++, map_to_sysmem(dev),
+  map_to_sysmem(dev->driver->ops),
+  map_to_sysmem(dev->platform_data));
+   }
+
+   return cmd_process_error(cmdtp, ret);
+}
+
+static cmd_tbl_t demo_commands[] = {
+   U_BOOT_CMD_MKENT(list, 0, 1, do_demo_list, "", ""),
+   U_BOOT_CMD_MKENT(hello, 2, 1, do_demo_hello, "", ""),
+   U_BOOT_CMD_MKENT(status, 1, 1, do_demo_status, "", ""),
+};
+
+static int do_demo(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
+{
+   cmd_tbl_t *demo_cmd;
+   int devnum = 0;
+   int ret;
+
+   if (argc < 2)
+   return CMD_RET_USAGE;
+   demo_cmd = find_cmd_tbl(argv[1], demo_commands,
+   ARRAY_SIZE(demo_commands));
+   argc -= 2;
+   argv += 2;
+   if (!demo_cmd || argc > demo_cmd->maxargs)
+   return CMD_RET_USAGE;
+
+   if (argc) {
+   devnum = simple_strtoul(argv[0], NULL, 10);
+   ret = uclass_get_device(UCLASS_DEMO, devnum, &demo_dev);
+   if (ret)
+   return cmd_process_error(cmdtp, ret);
+   argc--;
+   argv++;
+   }
+
+   ret = demo_cmd->cmd(demo_cmd, flag, argc, argv);
+
+   return cmd_process_error(demo_cmd, ret);
+}
+
+U_BOOT_CMD(
+   demo,   4,  1, 

[U-Boot] [PATCH v5 13/16] dm: Add GPIO support and tests

2013-10-21 Thread Simon Glass
Add driver model support for GPIOs. Since existing GPIO drivers do not use
driver model, this feature must be enabled by CONFIG_DM_GPIO. After all
GPO drivers are converted over we can perhaps remove this config.

Tests are provided for the sandbox implementation, and are a sufficient
sanity check for basic operation.

The GPIO uclass understands the concept of named banks of GPIOs, with each
GPIO device providing a single bank. Within each bank the GPIOs are numbered
using an offset from 0 to n-1. For example a bank named 'b' with 20
offsets will provide GPIOs named b0 to b19.

Anonymous GPIO banks are also supported, and are just numbered without any
prefix.

Each time a GPIO driver is added to the uclass, the GPIOs are renumbered
accordinging, so there is always a global GPIO numbering order.

Signed-off-by: Simon Glass 
Signed-off-by: Marek Vasut 
Signed-off-by: Pavel Herrmann 
Signed-off-by: Viktor Křivák 
Signed-off-by: Tomas Hlavacek 
---
Changes in v5:
- Change to new SPDX license headers

Changes in v4: None
Changes in v3:
- Update GPIO support to use new struct member names
- Tidy up comments/documentation in GPIO module

Changes in v2: None

 drivers/gpio/Makefile  |   2 +
 drivers/gpio/gpio-uclass.c | 266 +
 include/asm-generic/gpio.h | 104 ++
 test/dm/gpio.c | 111 +++
 4 files changed, 483 insertions(+)
 create mode 100644 drivers/gpio/gpio-uclass.c
 create mode 100644 test/dm/gpio.c

diff --git a/drivers/gpio/Makefile b/drivers/gpio/Makefile
index 71ddb00..46f2c5d 100644
--- a/drivers/gpio/Makefile
+++ b/drivers/gpio/Makefile
@@ -9,6 +9,8 @@ include $(TOPDIR)/config.mk
 
 LIB:= $(obj)libgpio.o
 
+COBJS-$(CONFIG_DM_GPIO)+= gpio-uclass.o
+
 COBJS-$(CONFIG_AT91_GPIO)  += at91_gpio.o
 COBJS-$(CONFIG_INTEL_ICH6_GPIO)+= intel_ich6_gpio.o
 COBJS-$(CONFIG_KIRKWOOD_GPIO)  += kw_gpio.o
diff --git a/drivers/gpio/gpio-uclass.c b/drivers/gpio/gpio-uclass.c
new file mode 100644
index 000..56bfd11
--- /dev/null
+++ b/drivers/gpio/gpio-uclass.c
@@ -0,0 +1,266 @@
+/*
+ * Copyright (c) 2013 Google, Inc
+ *
+ * SPDX-License-Identifier:GPL-2.0+
+ */
+
+#include 
+#include 
+#include 
+#include 
+
+/**
+ * gpio_to_device() - Convert global GPIO number to device, number
+ * gpio:   The numeric representation of the GPIO
+ *
+ * Convert the GPIO number to an entry in the list of GPIOs
+ * or GPIO blocks registered with the GPIO controller. Returns
+ * entry on success, NULL on error.
+ */
+static int gpio_to_device(unsigned int gpio, struct device **devp,
+ unsigned int *offset)
+{
+   struct gpio_dev_priv *uc_priv;
+   struct device *dev;
+   int ret;
+
+   for (ret = uclass_first_device(UCLASS_GPIO, &dev);
+dev;
+ret = uclass_next_device(&dev)) {
+   uc_priv = dev->uclass_priv;
+   if (gpio >= uc_priv->gpio_base &&
+   gpio < uc_priv->gpio_base + uc_priv->gpio_count) {
+   *devp = dev;
+   *offset = gpio - uc_priv->gpio_base;
+   return 0;
+   }
+   }
+
+   /* No such GPIO */
+   return ret ? ret : -EINVAL;
+}
+
+int gpio_lookup_name(const char *name, struct device **devp,
+unsigned int *offsetp, unsigned int *gpiop)
+{
+   struct gpio_dev_priv *uc_priv;
+   struct device *dev;
+   int ret;
+
+   if (devp)
+   *devp = NULL;
+   for (ret = uclass_first_device(UCLASS_GPIO, &dev);
+dev;
+ret = uclass_next_device(&dev)) {
+   ulong offset;
+   int len;
+
+   uc_priv = dev->uclass_priv;
+   len = uc_priv->bank_name ? strlen(uc_priv->bank_name) : 0;
+
+   if (!strncmp(name, uc_priv->bank_name, len)) {
+   if (strict_strtoul(name + len, 10, &offset))
+   continue;
+   if (devp)
+   *devp = dev;
+   if (offsetp)
+   *offsetp = offset;
+   if (gpiop)
+   *gpiop = uc_priv->gpio_base + offset;
+   return 0;
+   }
+   }
+
+   return ret ? ret : -EINVAL;
+}
+
+/**
+ * gpio_request() - [COMPAT] Request GPIO
+ * gpio:   GPIO number
+ * label:  Name for the requested GPIO
+ *
+ * This function implements the API that's compatible with current
+ * GPIO API used in U-Boot. The request is forwarded to particular
+ * GPIO driver. Returns 0 on success, negative value on error.
+ */
+int gpio_request(unsigned gpio, const char *label)
+{
+   unsigned int offset;
+   struct device *dev;
+   int ret;
+
+   ret = gpio_to_device(gpio, &dev, &offset);
+   if (ret)
+   return ret;
+
+   if (!gpio_get_ops(dev)->request)

[U-Boot] [PATCH v5 04/16] sandbox: Build a device tree file for sandbox

2013-10-21 Thread Simon Glass
Add support for building a device tree for sandbox's CONFIG_OF_HOSTFILE
option to make it easier to use device tree with sandbox.

This adjusts the Makefile to build a u-boot.dtb file which can be passed
to sandbox U-Boot with:

   ./u-boot -d u-boot.dtb

Signed-off-by: Simon Glass 
---
Changes in v5: None
Changes in v4: None
Changes in v3:
- Add new patch to build a device tree file for sandbox

Changes in v2: None

 Makefile  |  1 +
 arch/sandbox/config.mk|  2 ++
 board/sandbox/dts/sandbox.dts | 20 
 include/configs/sandbox.h |  1 +
 4 files changed, 24 insertions(+)
 create mode 100644 board/sandbox/dts/sandbox.dts

diff --git a/Makefile b/Makefile
index dc04179..d6af971 100644
--- a/Makefile
+++ b/Makefile
@@ -402,6 +402,7 @@ ALL-$(CONFIG_SPL) += $(obj)spl/u-boot-spl.bin
 ALL-$(CONFIG_SPL_FRAMEWORK) += $(obj)u-boot.img
 ALL-$(CONFIG_TPL) += $(obj)tpl/u-boot-tpl.bin
 ALL-$(CONFIG_OF_SEPARATE) += $(obj)u-boot.dtb $(obj)u-boot-dtb.bin
+ALL-$(CONFIG_OF_HOSTFILE) += $(obj)u-boot.dtb
 ifneq ($(CONFIG_SPL_TARGET),)
 ALL-$(CONFIG_SPL) += $(obj)$(subst ",,$(CONFIG_SPL_TARGET))
 endif
diff --git a/arch/sandbox/config.mk b/arch/sandbox/config.mk
index 6142dd4..60b7262 100644
--- a/arch/sandbox/config.mk
+++ b/arch/sandbox/config.mk
@@ -7,3 +7,5 @@ PLATFORM_LIBS += -lrt
 
 # Support generic board on sandbox
 __HAVE_ARCH_GENERIC_BOARD := y
+
+CONFIG_ARCH_DEVICE_TREE := sandbox
diff --git a/board/sandbox/dts/sandbox.dts b/board/sandbox/dts/sandbox.dts
new file mode 100644
index 000..96a4438
--- /dev/null
+++ b/board/sandbox/dts/sandbox.dts
@@ -0,0 +1,20 @@
+/dts-v1/;
+
+/ {
+   triangle {
+   compatible = "demo-shape";
+   colour = "cyan";
+   sides = <3>;
+   character = <83>;
+   };
+   square {
+   compatible = "demo-shape";
+   colour = "blue";
+   sides = <4>;
+   };
+   hexagon {
+   compatible = "demo-simple";
+   colour = "white";
+   sides = <6>;
+   };
+};
diff --git a/include/configs/sandbox.h b/include/configs/sandbox.h
index d6b6c75..9fedde7 100644
--- a/include/configs/sandbox.h
+++ b/include/configs/sandbox.h
@@ -30,6 +30,7 @@
 #define CONFIG_FIT_SIGNATURE
 #define CONFIG_RSA
 #define CONFIG_CMD_FDT
+#define CONFIG_DEFAULT_DEVICE_TREE sandbox
 
 #define CONFIG_FS_FAT
 #define CONFIG_FS_EXT4
-- 
1.8.4

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH v5 06/16] dm: Add README for driver model

2013-10-21 Thread Simon Glass
This adds a README to help with understanding of this series.

Signed-off-by: Simon Glass 
---
Changes in v5: None
Changes in v4: None
Changes in v3:
- Updated README.txt to cover changes since version 2

Changes in v2:
- Removed pointer return values in favour of integer
- Use driver_bind() in dm_init() instead of writing new code
- Allow driver_bind() to support a NULL parent
- Add dm_warn() to warn about impending doom
- Standardise variable names (e.g. uclass instead of class)
- Remove relocation functions
- Add new header file for lists
- Add new util file to hold utility functions
- Allow a driver to bind to only one uclass
- Remove unneeded arguments to uclass_bind(), uclass_unbind()
- Rename struct device's 'bus' to 'parent'
- Rename data structures to hopefully be clearer
- Put platform_data definitions in their own header file
- Add U_BOOT_DEVICE to declare platform_data
- Add auto-probing feature for platform_data to avoid driver_bind() calls
- Add simple unit test functions
- Add test infrastructure for driver model
- Add integration tests for driver model
- Add device tree support in driver model
- Add automatic allocation of platform_data for FDT
- Add automatic allocation of priv data for devices
- Add automatic allocation of device-specific priv data for uclasses
- Add GPIO uclass and tests
- Add sandbox GPIO driver
- Update gpio command to use driver model
- Add tests for core code
- Add script to run tests
- Add a single include/dm.h to bring in driver model code

 doc/driver-model/README.txt | 321 
 1 file changed, 321 insertions(+)
 create mode 100644 doc/driver-model/README.txt

diff --git a/doc/driver-model/README.txt b/doc/driver-model/README.txt
new file mode 100644
index 000..64cb114
--- /dev/null
+++ b/doc/driver-model/README.txt
@@ -0,0 +1,321 @@
+Driver Model
+
+
+This README contains high-level information about driver model, a unified
+way of declaring and accessing drivers in U-Boot. The original work was done
+by:
+
+   Marek Vasut 
+   Pavel Herrmann 
+   Viktor Křivák 
+   Tomas Hlavacek 
+
+This has been both simplified and extended into the current implementation
+by:
+
+   Simon Glass 
+
+
+Terminology
+---
+
+Uclass - a group of device which operate in the same way. A uclass provides
+   a way of accessing invidual devices within the group, but always
+   using the same interface. For example a GPIO uclass provides
+   operations for get/set value. An I2C uclass may have 10 I2C ports,
+   4 with one driver, and 6 with another.
+
+Driver - some code which talks to a peripheral and presents a higher-level
+   interface to it.
+
+Device - an instance of a driver, tied to a particular port or peripheral.
+
+
+How to try it
+-
+
+Build U-Boot sandbox and run it:
+
+   make sandbox_config
+   make
+   ./u-boot
+
+   (type 'reset' to exit U-Boot)
+
+
+There is a uclass called 'demo'. This uclass handles
+saying hello, and reporting its status. There are two drivers in this
+uclass:
+
+   - simple: Just prints a message for hello, doesn't implement status
+   - shape: Prints shapes and reports number of characters printed as status
+
+The demo class is pretty simple, but not trivial. The intention is that it
+can be used for testing, so it will implement all driver model features and
+provide 100% code coverage of them. It does have multiple drivers, it
+handles parameter data and platform_data (data which tells the driver how
+to operate on a particular platform) and it uses private driver data.
+
+To try it, see the example session below:
+
+=>demo hello 1
+Hello '@' from 07981110: red 4
+=>demo status 2
+Status: 0
+=>demo hello 2
+g
+r@
+e@@
+e@@@
+n
+g@
+=>demo status 2
+Status: 21
+=>demo hello 4 ^
+  y^^^
+ e^
+l^^^
+l^^^
+ o^
+  w^^^
+=>demo status 4
+Status: 36
+=>
+
+
+Running the tests
+-
+
+The intent with driver model is that the core portion has 100% test coverage
+in sandbox, and every uclass has its own test. As a move towards this, tests
+are provided in test/dm. To run them, try:
+
+   ./test/dm/test-dm.sh
+
+
+What is going on?
+-
+
+Let's start at the top. The demo command is in common/cmd_demo.c. It does
+the usual command procesing and then:
+
+   struct device *demo_dev;
+
+   ret = uclass_get_device(UCLASS_DEMO, &demo_dev);
+
+UCLASS_DEMO means the class of devices which implement 'demo'. Other
+classes might be MMC, or GPIO, hashing or serial. The idea is that the
+devices in the class all share a particular way of working. The class
+presents a unified view of all these devices to U-Boot.
+
+This function looks up the device for the demo uclass. Given a device
+number we can find the device because all devices have registered with
+the UCLASS_DEMO uclass.
+
+Having found the device, we activate it with:
+
+   ret = driver_activate(demo_dev);
+
+This is because all devices are inactive un

[U-Boot] [PATCH v5 08/16] sandbox: config: Enable driver model

2013-10-21 Thread Simon Glass
Use driver model in sandbox to permit running of driver model unit test.

Signed-off-by: Simon Glass 
---
Changes in v5: None
Changes in v4: None
Changes in v3: None
Changes in v2: None

 include/configs/sandbox.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/include/configs/sandbox.h b/include/configs/sandbox.h
index 9fedde7..f9c96eb 100644
--- a/include/configs/sandbox.h
+++ b/include/configs/sandbox.h
@@ -18,6 +18,7 @@
 
 #define CONFIG_BOOTSTAGE
 #define CONFIG_BOOTSTAGE_REPORT
+#define CONFIG_DM
 
 /* Number of bits in a C 'long' on this architecture */
 #define CONFIG_SANDBOX_BITS_PER_LONG   64
-- 
1.8.4

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH] powerpc/83xx: Define USB1 and USB2 base addr for MPC834x

2013-10-21 Thread York Sun
Kim,

I can take this in if you ack it.

York


On 10/19/2013 07:03 AM, Ramneek Mehresh wrote:
> Define base addresse for both MPH(USB1) and DR(USB2) controllers
> for MPC834x socs
> 
> Signed-off-by: Ramneek Mehresh 
> ---
>  arch/powerpc/include/asm/immap_83xx.h | 5 +
>  1 file changed, 5 insertions(+)
> 
> diff --git a/arch/powerpc/include/asm/immap_83xx.h 
> b/arch/powerpc/include/asm/immap_83xx.h
> index 3c86ff6..289f7ca 100644
> --- a/arch/powerpc/include/asm/immap_83xx.h
> +++ b/arch/powerpc/include/asm/immap_83xx.h
> @@ -763,6 +763,7 @@ typedef struct immap {
>   u8  res7[0xC];
>  } immap_t;
>  
> +#ifndef  CONFIG_MPC834x
>  #ifdef CONFIG_HAS_FSL_MPH_USB
>  #define CONFIG_SYS_MPC83xx_USB1_OFFSET  0x22000  /* use the MPH 
> controller */
>  #define CONFIG_SYS_MPC83xx_USB2_OFFSET   0
> @@ -770,6 +771,10 @@ typedef struct immap {
>  #define CONFIG_SYS_MPC83xx_USB1_OFFSET   0
>  #define CONFIG_SYS_MPC83xx_USB2_OFFSET  0x23000  /* use the DR 
> controller */
>  #endif
> +#else
> +#define CONFIG_SYS_MPC83xx_USB1_OFFSET   0x22000
> +#define CONFIG_SYS_MPC83xx_USB2_OFFSET  0x23000
> +#endif
>  
>  #elif defined(CONFIG_MPC8313)
>  typedef struct immap {
> 


___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH v3] ARM: tegra: Add the Tamonten™ NG Evaluation Carrier board

2013-10-21 Thread Alban Bedel
Add support for the new Tamonten™ NG platform from Avionic Design.
Currently only I2C, MMC, USB and ethernet have been tested.

Signed-off-by: Alban Bedel 
---
 .../common/pinmux-config-tamonten-ng.h | 385 +
 board/avionic-design/common/tamonten-ng.c  | 110 ++
 board/avionic-design/dts/tegra30-tamonten.dtsi |  74 
 board/avionic-design/dts/tegra30-tec-ng.dts|   8 +
 board/avionic-design/tec-ng/Makefile   |  32 ++
 boards.cfg |   1 +
 include/configs/tec-ng.h   |  84 +
 7 files changed, 694 insertions(+)
 create mode 100644 board/avionic-design/common/pinmux-config-tamonten-ng.h
 create mode 100644 board/avionic-design/common/tamonten-ng.c
 create mode 100644 board/avionic-design/dts/tegra30-tamonten.dtsi
 create mode 100644 board/avionic-design/dts/tegra30-tec-ng.dts
 create mode 100644 board/avionic-design/tec-ng/Makefile
 create mode 100644 include/configs/tec-ng.h

diff --git a/board/avionic-design/common/pinmux-config-tamonten-ng.h 
b/board/avionic-design/common/pinmux-config-tamonten-ng.h
new file mode 100644
index 000..39df731
--- /dev/null
+++ b/board/avionic-design/common/pinmux-config-tamonten-ng.h
@@ -0,0 +1,385 @@
+/*
+ * (C) Copyright 2013
+ * Avionic Design GmbH 
+ *
+ * SPDX-License-Identifier:GPL-2.0+
+ */
+
+#ifndef _PINMUX_CONFIG_TAMONTEN_NG_H_
+#define _PINMUX_CONFIG_TAMONTEN_NG_H_
+
+#define DEFAULT_PINMUX(_pingroup, _mux, _pull, _tri, _io)  \
+   {   \
+   .pingroup   = PINGRP_##_pingroup,   \
+   .func   = PMUX_FUNC_##_mux, \
+   .pull   = PMUX_PULL_##_pull,\
+   .tristate   = PMUX_TRI_##_tri,  \
+   .io = PMUX_PIN_##_io,   \
+   .lock   = PMUX_PIN_LOCK_DEFAULT,\
+   .od = PMUX_PIN_OD_DEFAULT,  \
+   .ioreset= PMUX_PIN_IO_RESET_DEFAULT,\
+   }
+
+#define I2C_PINMUX(_pingroup, _mux, _pull, _tri, _io, _lock, _od) \
+   {   \
+   .pingroup   = PINGRP_##_pingroup,   \
+   .func   = PMUX_FUNC_##_mux, \
+   .pull   = PMUX_PULL_##_pull,\
+   .tristate   = PMUX_TRI_##_tri,  \
+   .io = PMUX_PIN_##_io,   \
+   .lock   = PMUX_PIN_LOCK_##_lock,\
+   .od = PMUX_PIN_OD_##_od,\
+   .ioreset= PMUX_PIN_IO_RESET_DEFAULT,\
+   }
+
+#define LV_PINMUX(_pingroup, _mux, _pull, _tri, _io, _lock, _ioreset) \
+   {   \
+   .pingroup   = PINGRP_##_pingroup,   \
+   .func   = PMUX_FUNC_##_mux, \
+   .pull   = PMUX_PULL_##_pull,\
+   .tristate   = PMUX_TRI_##_tri,  \
+   .io = PMUX_PIN_##_io,   \
+   .lock   = PMUX_PIN_LOCK_##_lock,\
+   .od = PMUX_PIN_OD_DEFAULT,  \
+   .ioreset= PMUX_PIN_IO_RESET_##_ioreset  \
+   }
+
+#define DEFAULT_PADCFG(_padgrp, _slwf, _slwr, _drvup, _drvdn, _lpmd, _schmt, 
_hsm) \
+   {   \
+   .padgrp = PDRIVE_PINGROUP_##_padgrp,\
+   .slwf   = _slwf,\
+   .slwr   = _slwr,\
+   .drvup  = _drvup,   \
+   .drvdn  = _drvdn,   \
+   .lpmd   = PGRP_LPMD_##_lpmd,\
+   .schmt  = PGRP_SCHMT_##_schmt,  \
+   .hsm= PGRP_HSM_##_hsm,  \
+   }
+
+static struct pingroup_config tamonten_ng_pinmux_common[] = {
+   /* SDMMC1 pinmux */
+   DEFAULT_PINMUX(SDMMC1_CLK,  SDMMC1, NORMAL, NORMAL, INPUT),
+   DEFAULT_PINMUX(SDMMC1_CMD,  SDMMC1, UP, NORMAL, INPUT),
+   DEFAULT_PINMUX(SDMMC1_DAT0, SDMMC1, UP, NORMAL, INPUT),
+   DEFAULT_PINMUX(SDMMC1_DAT1, SDMMC1, UP, NORMAL, INPUT),
+   DEFAULT_PINMUX(SDMMC1_DAT2, SDMMC1, UP, NORMAL, INPUT),
+   DEFAULT_PINMUX(SDMMC1_DAT3, SDMMC1, UP, NORMAL, INPUT),
+
+   /* SDMMC3 pinmux */
+   DEFAULT_PINMUX(SDMMC3_CLK,  SDMMC3, NORMAL, NORMAL, INPUT),
+   DEFAULT_PINMUX(SDMMC3_CMD,  SDMMC3, UP, NORMAL, INPUT),
+   DEFAULT_PINMUX(SDMMC3_DAT0, SDMMC3, UP, NORMAL, INPUT),
+   DEFAULT_PINMUX(SDMMC3_DAT1, SDMMC3, UP, NORMAL, INPUT),
+   

[U-Boot] Setting board revision and serial with device tree

2013-10-21 Thread Lars Poeschel
Hello!

I want to set the board serial number and revision for linux /proc/cpuinfo . 
On an arm board it seems arch/arm/lib/bootm.c function boot_prep_linux() is 
responsible. On a non fdt booting board I can enable CONFIG_REVISION_TAG and 
CONFIG_SERIAL_TAG in the board config and implement get_board_rev() and 
get_board_serial() in the board files. The information is then passed to the 
linux kernel using ATAGS structure. This does not work, if the board boots 
with device tree.
How can a similar thing be done with device tree booting arm board ? I don't 
find information about this. Can somebody please point me to some documentation 
or relevant locations in code, where this is done ?

Thanks a lot,
Lars
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH 3/3] MAKEALL: fix boards_by_field function

2013-10-21 Thread Masahiro Yamada
Hello Albert.

> 
> The way the code is written now, board_by_field() has to do the job of 
> board_by_cpu() and has to know the CPU field has colon-separated
> subfields. What should be done is, board_by_field should not even worry
> about colons at all, and it is board_by_cpu() which should know about
> CPU dubfields and treat them properly.
> 
> Is this clearer?
> 

I posted v2.

Best Regards
Masahiro Yamada

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH 3/3] sh: ecovec: Update to new I2C framework

2013-10-21 Thread Nobuhiro Iwamatsu
Hi,

Thanks for your review

2013/10/17 Heiko Schocher :
> Hello Nobuhiro,
>
> Am 17.10.2013 09:18, schrieb Nobuhiro Iwamatsu:
>
>> Ecovec uses sh_i2c driver. sh_i2c driver updated to new I2C framwork.
>> This updates ecovec to this change.
>>
>> Signed-off-by: Nobuhiro Iwamatsu
>> ---
>>   board/renesas/ecovec/ecovec.c |  4 ++--
>>   include/configs/ecovec.h  | 15 +++
>>   2 files changed, 9 insertions(+), 10 deletions(-)
>
>
> Could you sqash this patch into http://patchwork.ozlabs.org/patch/284106
> so we get no problems with "git bisect".

OK , I will bisect and re-send.

>
> Beside of that only one comment:
>
>> diff --git a/board/renesas/ecovec/ecovec.c b/board/renesas/ecovec/ecovec.c
>> index e2d365a..4289d2d 100644
>> --- a/board/renesas/ecovec/ecovec.c
>> +++ b/board/renesas/ecovec/ecovec.c
>> @@ -57,8 +57,8 @@ int board_late_init(void)
>>
>> outl(inl(MSTPCR2)&  ~0x1000, MSTPCR2);
>>
>>
>> -   i2c_init(CONFIG_SYS_I2C_SPEED, CONFIG_SYS_I2C_SLAVE);
>> -   i2c_set_bus_num(CONFIG_SYS_I2C_MODULE); /* Use I2C 1 */
>> +   i2c_init(CONFIG_SYS_I2C_SH_SPEED1, CONFIG_SYS_I2C_SLAVE);
>> +   i2c_set_bus_num(1); /* Use I2C 1 */
>
>
> same comment as for your patch for the kzm9g board, remove i2c_init()
> call, as it is no longer necessary, thanks!
>

I see. I will remove i2c_init().

> bye,
> Heiko

Best regards,
  Nobuhiro

-- 
Nobuhiro Iwamatsu
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH 2/3] arm: kzm9g: Update to new I2C framework

2013-10-21 Thread Nobuhiro Iwamatsu
Hi,

Thanks for  your review.

2013/10/17 Heiko Schocher :
> Hello Nobuhiro,
>
> Am 17.10.2013 09:18, schrieb Nobuhiro Iwamatsu:
>
>> Kzm9g uses sh_i2c driver. sh_i2c driver updated to new I2C framwork.
>> This updates kzm9g to this change.
>>
>> Signed-off-by: Nobuhiro Iwamatsu
>>
>> ---
>>   board/kmc/kzm9g/kzm9g.c |  2 +-
>>   include/configs/kzm9g.h | 31 ---
>>   2 files changed, 17 insertions(+), 16 deletions(-)
>
>
> Could you sqash this patch into http://patchwork.ozlabs.org/patch/284106
> so we get no problems with "git bisect".

OK, I will squash this patch and re-send.

>
> Beside of that only one comment:
>
>
>> diff --git a/board/kmc/kzm9g/kzm9g.c b/board/kmc/kzm9g/kzm9g.c
>> index b669ffe..0ec5e8e 100644
>> --- a/board/kmc/kzm9g/kzm9g.c
>> +++ b/board/kmc/kzm9g/kzm9g.c
>> @@ -289,7 +289,7 @@ void adjust_core_voltage(void)
>>   {
>> u8 data;
>>
>> -   i2c_init(CONFIG_SYS_I2C_SPEED, CONFIG_SYS_I2C_SLAVE);
>> +   i2c_init(CONFIG_SYS_I2C_SH_SPEED0, CONFIG_SYS_I2C_SLAVE);
>
>
> You no longer need to call i2c_init, as this does i2c_set_bus_num()
> for you. Please remove this and test, thanks!

I see. I will update this patch.

>
> bye,
> Heiko

Best regards,
  Nobuhiro

-- 
Nobuhiro Iwamatsu
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] Can a standalone application send data via Ethernet in U-Boot?

2013-10-21 Thread rvijay435
Dear Wolfgang, 

> it would be nice if you would disclose your real name... 
Vijay Kishore.

Thanks for your reply. So, now I will start modifying the registers related
to Ethernet and try to send the data over Ethernet.



--
View this message in context: 
http://u-boot.10912.n7.nabble.com/Can-a-standalone-application-send-data-via-Ethernet-in-U-Boot-tp165775p165937.html
Sent from the U-Boot mailing list archive at Nabble.com.
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH] powerpc/c29xpcie: reverse CPLD register bit

2013-10-21 Thread Po Liu
The CPLD registers MSB is powerpc's LSB, and LSB is powerpc's MSB.
It is not convinient for understand. Reverse the value when read
write to the CPLD registers.

Signed-off-by: Po Liu 
---
This patch after
http://patchwork.ozlabs.org/patch/278079/
[U-Boot,v2] powerpc/c29xpcie: add DDR ECC on off config setting

 board/freescale/c29xpcie/c29xpcie.c |  3 +-
 board/freescale/c29xpcie/cpld.c | 94 +
 board/freescale/c29xpcie/cpld.h | 21 +++--
 board/freescale/c29xpcie/ddr.c  |  4 +-
 4 files changed, 83 insertions(+), 39 deletions(-)

diff --git a/board/freescale/c29xpcie/c29xpcie.c 
b/board/freescale/c29xpcie/c29xpcie.c
index 48c4b30..e22c774 100644
--- a/board/freescale/c29xpcie/c29xpcie.c
+++ b/board/freescale/c29xpcie/c29xpcie.c
@@ -28,10 +28,9 @@ DECLARE_GLOBAL_DATA_PTR;
 int checkboard(void)
 {
struct cpu_type *cpu = gd->arch.cpu;
-   struct cpld_data *cpld_data = (void *)(CONFIG_SYS_CPLD_BASE);
 
printf("Board: %sPCIe, ", cpu->name);
-   printf("CPLD Ver: 0x%02x\n", in_8(&cpld_data->cpldver));
+   printf("CPLD Ver: %x.%x\n", CPLD_READ(hwver), CPLD_READ(cpldver));
 
return 0;
 }
diff --git a/board/freescale/c29xpcie/cpld.c b/board/freescale/c29xpcie/cpld.c
index 5cbccff..beaba63 100644
--- a/board/freescale/c29xpcie/cpld.c
+++ b/board/freescale/c29xpcie/cpld.c
@@ -20,31 +20,63 @@
 #include 
 
 #include "cpld.h"
+
+static u8 rev_bit(u8 val)
+{
+   u8 rev_val;
+   int i;
+
+   rev_val = val & 1;
+   for (i = 1; i <= 7; i++) {
+   val >>= 1;
+   rev_val <<= 1;
+   rev_val |= val & 1;
+   }
+
+   return rev_val;
+}
+
+static u8 __cpld_read(unsigned int reg)
+{
+   void *p = (void *)CONFIG_SYS_CPLD_BASE;
+
+   return rev_bit(in_8(p + reg));
+}
+
+u8 cpld_read(unsigned int reg) __attribute__((weak, alias("__cpld_read")));
+
+static void __cpld_write(unsigned int reg, u8 value)
+{
+   void *p = (void *)CONFIG_SYS_CPLD_BASE;
+
+   out_8(p + reg, rev_bit(value));
+}
+
+void cpld_write(unsigned int reg, u8 value)
+   __attribute__((weak, alias("__cpld_write")));
+
 /**
  * Set the boot bank to the alternate bank
  */
-void cpld_set_altbank(u8 banksel)
+void __cpld_set_altbank(u8 banksel)
 {
-   struct cpld_data *cpld_data = (void *)(CONFIG_SYS_CPLD_BASE);
-   u8 reg11;
-
-   reg11 = in_8(&cpld_data->flhcsr);
+   u8 reg11 = CPLD_READ(flhcsr);
 
switch (banksel) {
case 1:
-   out_8(&cpld_data->flhcsr, (reg11 & CPLD_BANKSEL_MASK)
+   CPLD_WRITE(flhcsr, (reg11 & CPLD_BANKSEL_MASK)
| CPLD_BANKSEL_EN | CPLD_SELECT_BANK1);
break;
case 2:
-   out_8(&cpld_data->flhcsr, (reg11 & CPLD_BANKSEL_MASK)
+   CPLD_WRITE(flhcsr, (reg11 & CPLD_BANKSEL_MASK)
| CPLD_BANKSEL_EN | CPLD_SELECT_BANK2);
break;
case 3:
-   out_8(&cpld_data->flhcsr, (reg11 & CPLD_BANKSEL_MASK)
+   CPLD_WRITE(flhcsr, (reg11 & CPLD_BANKSEL_MASK)
| CPLD_BANKSEL_EN | CPLD_SELECT_BANK3);
break;
case 4:
-   out_8(&cpld_data->flhcsr, (reg11 & CPLD_BANKSEL_MASK)
+   CPLD_WRITE(flhcsr, (reg11 & CPLD_BANKSEL_MASK)
| CPLD_BANKSEL_EN | CPLD_SELECT_BANK4);
break;
default:
@@ -56,35 +88,39 @@ void cpld_set_altbank(u8 banksel)
do_reset(NULL, 0, 0, NULL);
 }
 
+void cpld_set_altbank(u8 banksel)
+   __attribute__((weak, alias("__cpld_set_altbank")));
+
 /**
  * Set the boot bank to the default bank
  */
-void cpld_set_defbank(void)
+void __cpld_set_defbank(void)
 {
-   cpld_set_altbank(4);
+   __cpld_set_altbank(4);
 }
 
+void cpld_set_defbank(void)
+   __attribute__((weak, alias("__cpld_set_defbank")));
+
 #ifdef DEBUG
 static void cpld_dump_regs(void)
 {
-   struct cpld_data *cpld_data = (void *)(CONFIG_SYS_CPLD_BASE);
-
-   printf("chipid1 = 0x%02x\n", in_8(&cpld_data->chipid1));
-   printf("chipid2 = 0x%02x\n", in_8(&cpld_data->chipid2));
-   printf("hwver   = 0x%02x\n", in_8(&cpld_data->hwver));
-   printf("cpldver = 0x%02x\n", in_8(&cpld_data->cpldver));
-   printf("rstcon  = 0x%02x\n", in_8(&cpld_data->rstcon));
-   printf("flhcsr  = 0x%02x\n", in_8(&cpld_data->flhcsr));
-   printf("wdcsr   = 0x%02x\n", in_8(&cpld_data->wdcsr));
-   printf("wdkick  = 0x%02x\n", in_8(&cpld_data->wdkick));
-   printf("fancsr  = 0x%02x\n", in_8(&cpld_data->fancsr));
-   printf("ledcsr  = 0x%02x\n", in_8(&cpld_data->ledcsr));
-   printf("misc= 0x%02x\n", in_8(&cpld_data->misccsr));
-   printf("bootor  = 0x%02x\n", in_8(&cpld_data->bootor));
-   printf("bootcfg1= 0x%02x\n", in_8(&cpld_data->bootcfg1));
-   printf("bootcfg2  

Re: [U-Boot] [PATCH] fsl_esdhc: Add Auto command 12 interrupt bit detecting

2013-10-21 Thread Zhang Haijun

Hi, Babic

Thanks.

This patch is test on PPC.


Regards,
Haijun


于 2013/10/21 17:19, Stefano Babic 写道:

Hi,

On 21/10/2013 10:23, Zhang Haijun wrote:

Hi, all

Who can give some comments?

I put Antonius in CC, he's the MMC custodian.


The driver is for both PPC and i.MX. On which platform do you test these
changes ?

Best regards,
Stefano Babic



于 2013/10/12 17:50, Haijun Zhang 写道:

When Auto-CMD12 is used, the corresponding interrupt and error bit
should be enabled and set to reflect auto cmd 12 error.
Also add other command error detecting, like command index error,
CRC error etc. Without this command error bit set system will hang
due to the while loop.

Signed-off-by: Haijun Zhang 
---
  drivers/mmc/fsl_esdhc.c | 10 +-
  include/fsl_esdhc.h |  3 ++-
  2 files changed, 7 insertions(+), 6 deletions(-)

diff --git a/drivers/mmc/fsl_esdhc.c b/drivers/mmc/fsl_esdhc.c
index dc1d002..5aa592b 100644
--- a/drivers/mmc/fsl_esdhc.c
+++ b/drivers/mmc/fsl_esdhc.c
@@ -342,13 +342,13 @@ esdhc_send_cmd(struct mmc *mmc, struct mmc_cmd *cmd, 
struct mmc_data *data)
  #endif
  
  	/* Wait for the command to complete */

-   while (!(esdhc_read32(®s->irqstat) & (IRQSTAT_CC | IRQSTAT_CTOE)))
+   while (!(esdhc_read32(®s->irqstat) & (IRQSTAT_CC | CMD_ERR)))
;
  
  	irqstat = esdhc_read32(®s->irqstat);
  
  	/* Reset CMD and DATA portions on error */

-   if (irqstat & (CMD_ERR | IRQSTAT_CTOE)) {
+   if (irqstat & CMD_ERR) {
esdhc_write32(®s->sysctl, esdhc_read32(®s->sysctl) |
  SYSCTL_RSTC);
while (esdhc_read32(®s->sysctl) & SYSCTL_RSTC)
@@ -363,12 +363,12 @@ esdhc_send_cmd(struct mmc *mmc, struct mmc_cmd *cmd, 
struct mmc_data *data)
}
}
  
-	if (irqstat & CMD_ERR)

-   return COMM_ERR;
-
if (irqstat & IRQSTAT_CTOE)
return TIMEOUT;
  
+	if (irqstat & CMD_ERR)

+   return COMM_ERR;
+
/* Workaround for ESDHC errata ENGcm03648 */
if (!data && (cmd->resp_type & MMC_RSP_BUSY)) {
int timeout = 2500;
diff --git a/include/fsl_esdhc.h b/include/fsl_esdhc.h
index 67d6057..37dbe27 100644
--- a/include/fsl_esdhc.h
+++ b/include/fsl_esdhc.h
@@ -62,7 +62,8 @@
  #define IRQSTAT_TC(0x0002)
  #define IRQSTAT_CC(0x0001)
  
-#define CMD_ERR		(IRQSTAT_CIE | IRQSTAT_CEBE | IRQSTAT_CCE)

+#define CMD_ERR(IRQSTAT_CIE | IRQSTAT_CEBE | IRQSTAT_CCE | \
+   IRQSTAT_CTOE | IRQSTAT_AC12E)
  #define DATA_ERR  (IRQSTAT_DEBE | IRQSTAT_DCE | IRQSTAT_DTOE | \
IRQSTAT_DMAE)
  #define DATA_COMPLETE (IRQSTAT_TC | IRQSTAT_DINT)




--
Thanks & Regards
Haijun.


___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH] fsl_esdhc: Add Auto command 12 interrupt bit detecting

2013-10-21 Thread Stefano Babic
Hi,

On 21/10/2013 10:23, Zhang Haijun wrote:
> Hi, all
> 
> Who can give some comments?

I put Antonius in CC, he's the MMC custodian.


The driver is for both PPC and i.MX. On which platform do you test these
changes ?

Best regards,
Stefano Babic

> 
> 
> 于 2013/10/12 17:50, Haijun Zhang 写道:
>> When Auto-CMD12 is used, the corresponding interrupt and error bit
>> should be enabled and set to reflect auto cmd 12 error.
>> Also add other command error detecting, like command index error,
>> CRC error etc. Without this command error bit set system will hang
>> due to the while loop.
>>
>> Signed-off-by: Haijun Zhang 
>> ---
>>  drivers/mmc/fsl_esdhc.c | 10 +-
>>  include/fsl_esdhc.h |  3 ++-
>>  2 files changed, 7 insertions(+), 6 deletions(-)
>>
>> diff --git a/drivers/mmc/fsl_esdhc.c b/drivers/mmc/fsl_esdhc.c
>> index dc1d002..5aa592b 100644
>> --- a/drivers/mmc/fsl_esdhc.c
>> +++ b/drivers/mmc/fsl_esdhc.c
>> @@ -342,13 +342,13 @@ esdhc_send_cmd(struct mmc *mmc, struct mmc_cmd *cmd, 
>> struct mmc_data *data)
>>  #endif
>>  
>>  /* Wait for the command to complete */
>> -while (!(esdhc_read32(®s->irqstat) & (IRQSTAT_CC | IRQSTAT_CTOE)))
>> +while (!(esdhc_read32(®s->irqstat) & (IRQSTAT_CC | CMD_ERR)))
>>  ;
>>  
>>  irqstat = esdhc_read32(®s->irqstat);
>>  
>>  /* Reset CMD and DATA portions on error */
>> -if (irqstat & (CMD_ERR | IRQSTAT_CTOE)) {
>> +if (irqstat & CMD_ERR) {
>>  esdhc_write32(®s->sysctl, esdhc_read32(®s->sysctl) |
>>SYSCTL_RSTC);
>>  while (esdhc_read32(®s->sysctl) & SYSCTL_RSTC)
>> @@ -363,12 +363,12 @@ esdhc_send_cmd(struct mmc *mmc, struct mmc_cmd *cmd, 
>> struct mmc_data *data)
>>  }
>>  }
>>  
>> -if (irqstat & CMD_ERR)
>> -return COMM_ERR;
>> -
>>  if (irqstat & IRQSTAT_CTOE)
>>  return TIMEOUT;
>>  
>> +if (irqstat & CMD_ERR)
>> +return COMM_ERR;
>> +
>>  /* Workaround for ESDHC errata ENGcm03648 */
>>  if (!data && (cmd->resp_type & MMC_RSP_BUSY)) {
>>  int timeout = 2500;
>> diff --git a/include/fsl_esdhc.h b/include/fsl_esdhc.h
>> index 67d6057..37dbe27 100644
>> --- a/include/fsl_esdhc.h
>> +++ b/include/fsl_esdhc.h
>> @@ -62,7 +62,8 @@
>>  #define IRQSTAT_TC  (0x0002)
>>  #define IRQSTAT_CC  (0x0001)
>>  
>> -#define CMD_ERR (IRQSTAT_CIE | IRQSTAT_CEBE | IRQSTAT_CCE)
>> +#define CMD_ERR (IRQSTAT_CIE | IRQSTAT_CEBE | IRQSTAT_CCE | \
>> +IRQSTAT_CTOE | IRQSTAT_AC12E)
>>  #define DATA_ERR(IRQSTAT_DEBE | IRQSTAT_DCE | IRQSTAT_DTOE | \
>>  IRQSTAT_DMAE)
>>  #define DATA_COMPLETE   (IRQSTAT_TC | IRQSTAT_DINT)
> 


-- 
=
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: sba...@denx.de
=
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH] fsl_esdhc: Add Auto command 12 interrupt bit detecting

2013-10-21 Thread Zhang Haijun
Hi, all

Who can give some comments?


于 2013/10/12 17:50, Haijun Zhang 写道:
> When Auto-CMD12 is used, the corresponding interrupt and error bit
> should be enabled and set to reflect auto cmd 12 error.
> Also add other command error detecting, like command index error,
> CRC error etc. Without this command error bit set system will hang
> due to the while loop.
>
> Signed-off-by: Haijun Zhang 
> ---
>  drivers/mmc/fsl_esdhc.c | 10 +-
>  include/fsl_esdhc.h |  3 ++-
>  2 files changed, 7 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/mmc/fsl_esdhc.c b/drivers/mmc/fsl_esdhc.c
> index dc1d002..5aa592b 100644
> --- a/drivers/mmc/fsl_esdhc.c
> +++ b/drivers/mmc/fsl_esdhc.c
> @@ -342,13 +342,13 @@ esdhc_send_cmd(struct mmc *mmc, struct mmc_cmd *cmd, 
> struct mmc_data *data)
>  #endif
>  
>   /* Wait for the command to complete */
> - while (!(esdhc_read32(®s->irqstat) & (IRQSTAT_CC | IRQSTAT_CTOE)))
> + while (!(esdhc_read32(®s->irqstat) & (IRQSTAT_CC | CMD_ERR)))
>   ;
>  
>   irqstat = esdhc_read32(®s->irqstat);
>  
>   /* Reset CMD and DATA portions on error */
> - if (irqstat & (CMD_ERR | IRQSTAT_CTOE)) {
> + if (irqstat & CMD_ERR) {
>   esdhc_write32(®s->sysctl, esdhc_read32(®s->sysctl) |
> SYSCTL_RSTC);
>   while (esdhc_read32(®s->sysctl) & SYSCTL_RSTC)
> @@ -363,12 +363,12 @@ esdhc_send_cmd(struct mmc *mmc, struct mmc_cmd *cmd, 
> struct mmc_data *data)
>   }
>   }
>  
> - if (irqstat & CMD_ERR)
> - return COMM_ERR;
> -
>   if (irqstat & IRQSTAT_CTOE)
>   return TIMEOUT;
>  
> + if (irqstat & CMD_ERR)
> + return COMM_ERR;
> +
>   /* Workaround for ESDHC errata ENGcm03648 */
>   if (!data && (cmd->resp_type & MMC_RSP_BUSY)) {
>   int timeout = 2500;
> diff --git a/include/fsl_esdhc.h b/include/fsl_esdhc.h
> index 67d6057..37dbe27 100644
> --- a/include/fsl_esdhc.h
> +++ b/include/fsl_esdhc.h
> @@ -62,7 +62,8 @@
>  #define IRQSTAT_TC   (0x0002)
>  #define IRQSTAT_CC   (0x0001)
>  
> -#define CMD_ERR  (IRQSTAT_CIE | IRQSTAT_CEBE | IRQSTAT_CCE)
> +#define CMD_ERR  (IRQSTAT_CIE | IRQSTAT_CEBE | IRQSTAT_CCE | \
> + IRQSTAT_CTOE | IRQSTAT_AC12E)
>  #define DATA_ERR (IRQSTAT_DEBE | IRQSTAT_DCE | IRQSTAT_DTOE | \
>   IRQSTAT_DMAE)
>  #define DATA_COMPLETE(IRQSTAT_TC | IRQSTAT_DINT)

-- 
Thanks & Regards
Haijun.


___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] Pull request: u-boot-sh/master

2013-10-21 Thread Albert ARIBAUD
Hi Nobuhiro,

On Sat, 19 Oct 2013 06:14:10 +0900, Nobuhiro Iwamatsu
 wrote:

> Hi, Tom.
> 
> I already send patches of ARM board of rmoble with patch of serial_sh.
>   http://lists.denx.de/pipermail/u-boot/2013-September/163796.html
>   http://lists.denx.de/pipermail/u-boot/2013-September/163795.html
> 
> I think that Albert takes these in his repository about the board of ARM.
> I I should have written on the pull-request about this.

I think I commented the series, and particularly, I suggested that the
patches be ordered so that ARM boards wouldn't break.

As for applying, I'm fine with mainline applying it through the sh
repo once fixed; I'll ack the ARM patches in the series so that Tom
knows I'm ok with it.

> Best regards,
>   Nobuhiro

Amicalement,
-- 
Albert.
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH 2/2] arm: atmel: get rid of too many ifdeffery

2013-10-21 Thread Bo Shen
Get rid of too many ifdeffery in usb ohci driver

Add following two configuration for USB clock selecting
- CONFIG_USB_ATMEL_CLK_SEL_PLLB: using PLLB as usb ohci input clock
- CONFIG_USB_ATMEL_CLK_SEL_UPLL: using UPLL as usb ohci input clock

Signed-off-by: Bo Shen 

---
 drivers/usb/host/ohci-at91.c|   14 --
 include/configs/afeb9260.h  |1 +
 include/configs/at91rm9200ek.h  |1 +
 include/configs/at91sam9260ek.h |1 +
 include/configs/at91sam9261ek.h |1 +
 include/configs/at91sam9263ek.h |1 +
 include/configs/at91sam9n12ek.h |1 +
 include/configs/at91sam9x5ek.h  |3 ++-
 include/configs/cpu9260.h   |1 +
 include/configs/cpuat91.h   |1 +
 include/configs/eb_cpux9k2.h|1 +
 include/configs/ethernut5.h |1 +
 include/configs/meesc.h |1 +
 include/configs/otc570.h|1 +
 include/configs/pm9261.h|1 +
 include/configs/pm9263.h|1 +
 include/configs/pm9g45.h|1 +
 include/configs/sama5d3xek.h|1 +
 include/configs/sbc35_a9g20.h   |1 +
 include/configs/snapper9260.h   |1 +
 include/configs/stamp9g20.h |1 +
 include/configs/top9000.h   |1 +
 include/configs/vl_ma2sc.h  |1 +
 23 files changed, 27 insertions(+), 11 deletions(-)

diff --git a/drivers/usb/host/ohci-at91.c b/drivers/usb/host/ohci-at91.c
index 05d6ff2..c24505e 100644
--- a/drivers/usb/host/ohci-at91.c
+++ b/drivers/usb/host/ohci-at91.c
@@ -18,9 +18,7 @@ int usb_cpu_init(void)
 {
at91_pmc_t *pmc = (at91_pmc_t *)ATMEL_BASE_PMC;
 
-#if defined(CONFIG_AT91CAP9) || defined(CONFIG_AT91SAM9260) || \
-defined(CONFIG_AT91SAM9263) || defined(CONFIG_AT91SAM9G20) || \
-   defined(CONFIG_AT91SAM9261) || defined(CONFIG_AT91SAM9N12)
+#ifdef CONFIG_USB_ATMEL_CLK_SEL_PLLB
/* Enable PLLB */
writel(get_pllb_init(), &pmc->pllbr);
while ((readl(&pmc->sr) & AT91_PMC_LOCKB) != AT91_PMC_LOCKB)
@@ -28,8 +26,7 @@ int usb_cpu_init(void)
 #ifdef CONFIG_AT91SAM9N12
writel(AT91_PMC_USBS_USB_PLLB | AT91_PMC_USB_DIV_2, &pmc->usb);
 #endif
-#elif defined(CONFIG_AT91SAM9G45) || defined(CONFIG_AT91SAM9M10G45) || \
-   defined(CONFIG_AT91SAM9X5) || defined(CONFIG_SAMA5D3)
+#elif defined(CONFIG_USB_ATMEL_CLK_SEL_UPLL)
/* Enable UPLL */
writel(readl(&pmc->uckr) | AT91_PMC_UPLLEN | AT91_PMC_BIASEN,
&pmc->uckr);
@@ -73,9 +70,7 @@ int usb_cpu_stop(void)
writel(ATMEL_PMC_UHP, &pmc->scdr);
 #endif
 
-#if defined(CONFIG_AT91CAP9) || defined(CONFIG_AT91SAM9260) || \
-   defined(CONFIG_AT91SAM9263) || defined(CONFIG_AT91SAM9G20) || \
-   defined(CONFIG_AT91SAM9N12)
+#ifdef CONFIG_USB_ATMEL_CLK_SEL_PLLB
 #ifdef CONFIG_AT91SAM9N12
writel(0, &pmc->usb);
 #endif
@@ -83,8 +78,7 @@ int usb_cpu_stop(void)
writel(0, &pmc->pllbr);
while ((readl(&pmc->sr) & AT91_PMC_LOCKB) != 0)
;
-#elif defined(CONFIG_AT91SAM9G45) || defined(CONFIG_AT91SAM9M10G45) || \
-   defined(CONFIG_AT91SAM9X5) || defined(CONFIG_SAMA5D3)
+#elif defined(CONFIG_USB_ATMEL_CLK_SEL_UPLL)
/* Disable UPLL */
writel(readl(&pmc->uckr) & (~AT91_PMC_UPLLEN), &pmc->uckr);
while ((readl(&pmc->sr) & AT91_PMC_LOCKU) == AT91_PMC_LOCKU)
diff --git a/include/configs/afeb9260.h b/include/configs/afeb9260.h
index be2f207..d99d671 100644
--- a/include/configs/afeb9260.h
+++ b/include/configs/afeb9260.h
@@ -112,6 +112,7 @@
 
 /* USB */
 #define CONFIG_USB_ATMEL
+#define CONFIG_USB_ATMEL_CLK_SEL_PLLB
 #define CONFIG_USB_OHCI_NEW
 #define CONFIG_DOS_PARTITION
 #define CONFIG_SYS_USB_OHCI_CPU_INIT
diff --git a/include/configs/at91rm9200ek.h b/include/configs/at91rm9200ek.h
index e158b0d..27e32e2 100644
--- a/include/configs/at91rm9200ek.h
+++ b/include/configs/at91rm9200ek.h
@@ -154,6 +154,7 @@
  * USB Config
  */
 #define CONFIG_USB_ATMEL   1
+#define CONFIG_USB_ATMEL_CLK_SEL_PLLB
 #define CONFIG_USB_OHCI_NEW1
 #define CONFIG_USB_KEYBOARD1
 #define CONFIG_USB_STORAGE 1
diff --git a/include/configs/at91sam9260ek.h b/include/configs/at91sam9260ek.h
index d7fd6b0..248d6ee 100644
--- a/include/configs/at91sam9260ek.h
+++ b/include/configs/at91sam9260ek.h
@@ -185,6 +185,7 @@
 
 /* USB */
 #define CONFIG_USB_ATMEL
+#define CONFIG_USB_ATMEL_CLK_SEL_PLLB
 #define CONFIG_USB_OHCI_NEW1
 #define CONFIG_SYS_USB_OHCI_CPU_INIT   1
 #define CONFIG_SYS_USB_OHCI_REGS_BASE  0x0050  /* 
AT91SAM9260_UHP_BASE */
diff --git a/include/configs/at91sam9261ek.h b/include/configs/at91sam9261ek.h
index af56604..819ae72 100644
--- a/include/configs/at91sam9261ek.h
+++ b/include/configs/at91sam9261ek.h
@@ -146,6 +146,7 @@
 
 /* USB */
 #define CONFIG_USB_ATMEL
+#define CONFIG_USB_ATMEL_CLK_SEL_PLLB
 #define CONFIG_USB_OHCI_NEW
 #define CONFIG_DOS_PARTITION
 #define CONFIG_SYS_USB_OHCI_CPU_INIT
diff --git a/include/configs/at91sam9263ek.h b/inc

[U-Boot] [PATCH 1/2] arm: atmel: at91sam9n12ek: add usb host support

2013-10-21 Thread Bo Shen
Add usb host support for at91sam9n12ek board.

Signed-off-by: Bo Shen 
---
 arch/arm/include/asm/arch-at91/at91_pmc.h |2 ++
 board/atmel/at91sam9n12ek/at91sam9n12ek.c |   11 +++
 drivers/usb/host/ohci-at91.c  |   11 +--
 include/configs/at91sam9n12ek.h   |   12 
 4 files changed, 34 insertions(+), 2 deletions(-)

diff --git a/arch/arm/include/asm/arch-at91/at91_pmc.h 
b/arch/arm/include/asm/arch-at91/at91_pmc.h
index 003920c..7b36f74 100644
--- a/arch/arm/include/asm/arch-at91/at91_pmc.h
+++ b/arch/arm/include/asm/arch-at91/at91_pmc.h
@@ -233,6 +233,8 @@ typedef struct at91_pmc {
 #endif
 #defineAT91_PMC_USBS_USB_PLLA  (0x0)   /* USB 
Clock Input is PLLA */
 #defineAT91_PMC_USBS_USB_UPLL  (0x1)   /* USB 
Clock Input is UPLL */
+#defineAT91_PMC_USBS_USB_PLLB  (0x1)   /* USB 
Clock Input is PLLB, AT91SAM9N12 only */
+#defineAT91_PMC_USB_DIV_2  (0x1 <<  8) /* USB 
Clock divided by 2 */
 #defineAT91_PMC_USBDIV_8   (0x7 <<  8) /* USB 
Clock divided by 8 */
 #defineAT91_PMC_USBDIV_10  (0x9 <<  8) /* USB 
Clock divided by 10 */
 
diff --git a/board/atmel/at91sam9n12ek/at91sam9n12ek.c 
b/board/atmel/at91sam9n12ek/at91sam9n12ek.c
index 2ec32eb..9adc992 100644
--- a/board/atmel/at91sam9n12ek/at91sam9n12ek.c
+++ b/board/atmel/at91sam9n12ek/at91sam9n12ek.c
@@ -199,6 +199,13 @@ void at91sam9n12ek_ks8851_hw_init(void)
 }
 #endif
 
+#ifdef CONFIG_USB_ATMEL
+void at91sam9n12ek_usb_hw_init(void)
+{
+   at91_set_pio_output(AT91_PIO_PORTB, 7, 0);
+}
+#endif
+
 int board_early_init_f(void)
 {
/* Enable clocks for all PIOs */
@@ -230,6 +237,10 @@ int board_init(void)
at91sam9n12ek_ks8851_hw_init();
 #endif
 
+#ifdef CONFIG_USB_ATMEL
+   at91sam9n12ek_usb_hw_init();
+#endif
+
return 0;
 }
 
diff --git a/drivers/usb/host/ohci-at91.c b/drivers/usb/host/ohci-at91.c
index 9e90d59..05d6ff2 100644
--- a/drivers/usb/host/ohci-at91.c
+++ b/drivers/usb/host/ohci-at91.c
@@ -20,11 +20,14 @@ int usb_cpu_init(void)
 
 #if defined(CONFIG_AT91CAP9) || defined(CONFIG_AT91SAM9260) || \
 defined(CONFIG_AT91SAM9263) || defined(CONFIG_AT91SAM9G20) || \
-defined(CONFIG_AT91SAM9261)
+   defined(CONFIG_AT91SAM9261) || defined(CONFIG_AT91SAM9N12)
/* Enable PLLB */
writel(get_pllb_init(), &pmc->pllbr);
while ((readl(&pmc->sr) & AT91_PMC_LOCKB) != AT91_PMC_LOCKB)
;
+#ifdef CONFIG_AT91SAM9N12
+   writel(AT91_PMC_USBS_USB_PLLB | AT91_PMC_USB_DIV_2, &pmc->usb);
+#endif
 #elif defined(CONFIG_AT91SAM9G45) || defined(CONFIG_AT91SAM9M10G45) || \
defined(CONFIG_AT91SAM9X5) || defined(CONFIG_SAMA5D3)
/* Enable UPLL */
@@ -71,7 +74,11 @@ int usb_cpu_stop(void)
 #endif
 
 #if defined(CONFIG_AT91CAP9) || defined(CONFIG_AT91SAM9260) || \
-defined(CONFIG_AT91SAM9263) || defined(CONFIG_AT91SAM9G20)
+   defined(CONFIG_AT91SAM9263) || defined(CONFIG_AT91SAM9G20) || \
+   defined(CONFIG_AT91SAM9N12)
+#ifdef CONFIG_AT91SAM9N12
+   writel(0, &pmc->usb);
+#endif
/* Disable PLLB */
writel(0, &pmc->pllbr);
while ((readl(&pmc->sr) & AT91_PMC_LOCKB) != 0)
diff --git a/include/configs/at91sam9n12ek.h b/include/configs/at91sam9n12ek.h
index 28a7925..cc79f8b 100644
--- a/include/configs/at91sam9n12ek.h
+++ b/include/configs/at91sam9n12ek.h
@@ -83,6 +83,7 @@
 #define CONFIG_CMD_SF
 #define CONFIG_CMD_MMC
 #define CONFIG_CMD_FAT
+#define CONFIG_CMD_USB
 
 #define CONFIG_NR_DRAM_BANKS   1
 #define CONFIG_SYS_SDRAM_BASE  0x2000
@@ -163,6 +164,17 @@
 #define CONFIG_SYS_MEMTEST_START   CONFIG_SYS_SDRAM_BASE
 #define CONFIG_SYS_MEMTEST_END 0x26e0
 
+/* USB host */
+#ifdef CONFIG_CMD_USB
+#define CONFIG_USB_ATMEL
+#define CONFIG_USB_OHCI_NEW
+#define CONFIG_SYS_USB_OHCI_CPU_INIT
+#define CONFIG_SYS_USB_OHCI_REGS_BASE  ATMEL_BASE_OHCI
+#define CONFIG_SYS_USB_OHCI_SLOT_NAME  "at91sam9n12"
+#define CONFIG_SYS_USB_OHCI_MAX_ROOT_PORTS 1
+#define CONFIG_USB_STORAGE
+#endif
+
 #ifdef CONFIG_SYS_USE_SPIFLASH
 
 /* bootstrap + u-boot + env + linux in dataflash on CS0 */
-- 
1.7.9.5

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot