Re: [U-Boot] [PATCH v2] mmc: Split device init to decouple OCR-polling delay

2012-11-30 Thread Jaehoon Chung
Hi,

This concept is very good.
But I have one question. I think need to call mmc_init() one more, right?
how did you save the boot time(200ms)?

On 11/29/2012 10:21 AM, Simon Glass wrote:
> From: Che-Liang Chiou 
> 
> Most of time that MMC driver spends on initializing a device is polling
> OCR (operation conditions register).  To decouple this polling loop,
> device init is split into two parts: The first part fires the OCR query
> command, and the second part polls the result.  So the caller is now no
> longer bound to the OCR-polling delay; he may fire the query, go
> somewhere and then come back later for the result.
> 
> To use this, call mmc_set_preinit() on any device which needs this.
> 
> This can save significant amounts of time on boot (e.g. 200ms) by
> hiding the MMC init time behind other init.
snip..
> +int mmc_init(struct mmc *mmc)
> +{
> + int err = IN_PROGRESS;
> + unsigned start = get_timer(0);
> +
> + if (mmc->has_init)
> + return 0;
> + if (!mmc->init_in_progress)
> + err = mmc_start_init(mmc);
It need not to return? if err is IN_PROGRESS, next condition is immediately run.
Then i think we didn't save the time before adjust this patch.
> +
> + if (!err || err == IN_PROGRESS)
> + err = mmc_complete_init(mmc);
> + debug("%s: %d, time %lu\n", __func__, err, get_timer(start));
>   return err;
>  }
>  
> @@ -1315,6 +1368,25 @@ int get_mmc_num(void)
>   return cur_dev_num;
>  }
>  
> +void mmc_set_preinit(struct mmc *mmc, int preinit)
> +{
> + mmc->preinit = preinit;
> +}
> +
> +static void do_preinit(void)
> +{
> + struct mmc *m;
> + struct list_head *entry;
> +
> + list_for_each(entry, &mmc_devices) {
> + m = list_entry(entry, struct mmc, link);
> +
> + if (m->preinit)
> + mmc_start_init(m);
> + }
> +}
> +
> +
>  int mmc_initialize(bd_t *bis)
>  {
>   INIT_LIST_HEAD (&mmc_devices);
> @@ -1325,5 +1397,6 @@ int mmc_initialize(bd_t *bis)
>  
>   print_mmc_devices(',');
>  
> + do_preinit();
>   return 0;
>  }
> diff --git a/include/mmc.h b/include/mmc.h
> index a13e2bd..445d714 100644
> --- a/include/mmc.h
> +++ b/include/mmc.h
> @@ -62,6 +62,7 @@
>  #define UNUSABLE_ERR -17 /* Unusable Card */
>  #define COMM_ERR -18 /* Communications Error */
>  #define TIMEOUT  -19
> +#define IN_PROGRESS  -20 /* operation is in progress */
>  
>  #define MMC_CMD_GO_IDLE_STATE0
>  #define MMC_CMD_SEND_OP_COND 1
> @@ -260,6 +261,10 @@ struct mmc {
>   int (*init)(struct mmc *mmc);
>   int (*getcd)(struct mmc *mmc);
>   uint b_max;
> + char op_cond_pending;   /* 1 if we are waiting on an op_cond command */
> + char init_in_progress;  /* 1 if we have done mmc_start_init() */
> + char preinit;   /* start init as early as possible */
> + uint op_cond_response;  /* the response byte from the last op_cond */
>  };
>  
>  int mmc_register(struct mmc *mmc);
> @@ -276,6 +281,31 @@ int mmc_switch_part(int dev_num, unsigned int part_num);
>  int mmc_getcd(struct mmc *mmc);
>  void spl_mmc_load(void) __noreturn;
>  
> +/**
> + * Start device initialization and return immediately; it does not block on
> + * polling OCR (operation condition register) status.  Then you should call
> + * mmc_init, which would block on polling OCR status and complete the device
> + * initializatin.
> + *
> + * @param mmcPointer to a MMC device struct
> + * @return 0 on success, IN_PROGRESS on waiting for OCR status, <0 on error.
> + */
> +int mmc_start_init(struct mmc *mmc);
> +
> +/**
> + * Set preinit flag of mmc device.
> + *
> + * This will cause the device to be pre-inited during mmc_initialize(),
> + * which may save boot time if the device is not accessed until later.
> + * Some eMMC devices take 200-300ms to init, but unfortunately they
> + * must be sent a series of commands to even get them to start preparing
> + * for operation.
> + *
> + * @param mmcPointer to a MMC device struct
> + * @param preinitpreinit flag value
> + */
> +void mmc_set_preinit(struct mmc *mmc, int preinit);
> +
>  #ifdef CONFIG_GENERIC_MMC
>  #define mmc_host_is_spi(mmc) ((mmc)->host_caps & MMC_MODE_SPI)
>  struct mmc *mmc_spi_init(uint bus, uint cs, uint speed, uint mode);
> 

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


Re: [U-Boot] Reg Bootstrapping on x86-64 for tizen

2012-11-30 Thread manohar . betham

Hi,
I did following steps to compile u-boot on x86-64.
 

U-boot Build procedure 
The following command sequence is used to build the u-boot for the particular 
board. 
->To remove ALL files made by by make,configure
 
make distclean 
 
To configure the x86 32 bit based board for the target we have taken the 
coreboot

 
make coreboot-x86_config
 
To build the coreboot-x86 run the below command
 
make all
 
->if the following error [-Werror=unused-but-set-variable]
ext4fs.c: In function ‘ext4fs_write_file’:
ext4fs.c:933:6: error: variable ‘delayed_skipfirst’ set but not used 
[-Werror=unused-but-set-variable]
cc1: all warnings being treated as errors
make[1]: *** [ext4fs.o] Error 1
make[1]: Leaving directory 
`/home/manoharb/Kernel_Tizen/intel_tizen/latest/u-boot/fs/ext4'
make: *** [fs/ext4/libext4fs.o] Error 2 
 
“__maybe_unused” in front of variable declaration
 
 
vim fs/ext4/ext4fs.c +122
 
for example __maybe_unused int delayed_skipfirst = 0;
 
 
2)if the error comes from the “/usr/bin/ld.bfd.real: cannot find -lgcc ”
 
sudo apt-get install ia32-libs 
export LIBRARY_PATH=/usr/lib/x86_64-linux-gnu 
 
As of now i required the procedure to build Tizen kernel on my x86-64 bit 
machine.
 
Please help me to build it or send me the procedure.
 
Thank you!
Best Regards,
Manohar


-Original Message-
From: "Simon Glass" 
Sent: Thursday, November 29, 2012 1:25am
To: manohar.bet...@smartplayin.com
Cc: "Graeme Russ" , "Marek Vasut" , 
u-boot@lists.denx.de
Subject: Re: Reg Bootstrapping on x86-64 for tizen



Hi,

On Tue, Nov 27, 2012 at 3:22 AM,   wrote:
> Dear All,
>
>
>
> I am Manohar ,have compiled the u-boot on x86 64 bit machine using
> coreboot-x86.
>
>
>
> Please help me / send me the procedure of bootstrapping steps of it for
> Tizen kernel.

Do you have coreboot working correctly on the platform? There is not a
lot of upstream support for creating a coreboot rom with U-Boot in it
yet.

Please can you point me to the toolchain you used, command line, etc.
I would be interested in replicating your build as I cannot build on a
x86_64 toolchain at present.

Regards,
Simon

>
>
>
> Thank you!
>
> Best Regards,
>
> Manohar
>
> 8790215215___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCHv2 2/4] at91sam9x5: enable USB support for 9x5ek board.

2012-11-30 Thread Richard Genoud
2012/11/29 Bo Shen :
Hi !
> As port C doesn't support EHCI, so, I think we should deal with this
> carefully.
> ---<8---
> #if OHCI
> #else EHCI
> #endif
> --->8---
> I think this will be better.

yes, you're right, I'll change that
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCHv3 0/4] enable USB on sam9x5ek boards

2012-11-30 Thread richard . genoud
From: Richard Genoud 

This small patchset is based on current master ( 
178d0cc1a4c73c3341afbeb2a93b172de8c96bd1 )
It enables usb on at91sam9x5ek boards.
Tested on at91sam9x5ek with a sam9g35 CPU (+ usb key and mouse)

By default the 3 USB 1.1 ports (A, B and C) are enabled.
If CONFIG_USB_EHCI is defined, the 2 USB 2.0 ports (A and B) will be enabled.

changes from v2:
* VBUS on port C is now only enabled when OHCI is selected
* ATMEL_BASE_OHCI is used instead of hard coded value
* uneeded undef CONFIG_USB_EHCI is removed

changes from v1:
* VBUS for usb port A is enabled
* EHCI configuration is now present
* number of OHCI ports corrected (3 instead of 2)

Richard Genoud (4):
  usb documentation: fix typo
  at91sam9x5: enable USB support for 9x5ek board.
  at91sam9x5ek: regroup FAT/DOS features
  at91sam9x5ek: add USB configuration

 arch/arm/cpu/arm926ejs/at91/at91sam9x5_devices.c |   13 ++
 arch/arm/include/asm/arch-at91/at91sam9x5.h  |2 +
 board/atmel/at91sam9x5ek/at91sam9x5ek.c  |3 ++
 doc/README.usb   |2 +-
 drivers/usb/host/ohci-at91.c |6 +++-
 include/configs/at91sam9x5ek.h   |   29 +-
 6 files changed, 51 insertions(+), 4 deletions(-)

-- 
1.7.2.5

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


[U-Boot] [PATCHv3 3/4] at91sam9x5ek: regroup FAT/DOS features

2012-11-30 Thread richard . genoud
From: Richard Genoud 

Signed-off-by: Richard Genoud 
---
 include/configs/at91sam9x5ek.h |6 +-
 1 files changed, 5 insertions(+), 1 deletions(-)

diff --git a/include/configs/at91sam9x5ek.h b/include/configs/at91sam9x5ek.h
index 71f765b..5e5f9c1 100644
--- a/include/configs/at91sam9x5ek.h
+++ b/include/configs/at91sam9x5ek.h
@@ -90,6 +90,7 @@
 #define CONFIG_CMD_NAND
 #define CONFIG_CMD_SF
 #define CONFIG_CMD_MMC
+#define CONFIG_CMD_FAT
 
 /* SDRAM */
 #define CONFIG_NR_DRAM_BANKS   1
@@ -142,9 +143,12 @@
 /* MMC */
 #ifdef CONFIG_CMD_MMC
 #define CONFIG_MMC
-#define CONFIG_CMD_FAT
 #define CONFIG_GENERIC_MMC
 #define CONFIG_GENERIC_ATMEL_MCI
+#endif
+
+/* FAT */
+#ifdef CONFIG_CMD_FAT
 #define CONFIG_DOS_PARTITION
 #endif
 
-- 
1.7.2.5

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


[U-Boot] [PATCHv3 2/4] at91sam9x5: enable USB support for 9x5ek board.

2012-11-30 Thread richard . genoud
From: Richard Genoud 

Signed-off-by: Richard Genoud 
---
 arch/arm/cpu/arm926ejs/at91/at91sam9x5_devices.c |   13 +
 arch/arm/include/asm/arch-at91/at91sam9x5.h  |2 ++
 board/atmel/at91sam9x5ek/at91sam9x5ek.c  |3 +++
 drivers/usb/host/ohci-at91.c |6 --
 4 files changed, 22 insertions(+), 2 deletions(-)

diff --git a/arch/arm/cpu/arm926ejs/at91/at91sam9x5_devices.c 
b/arch/arm/cpu/arm926ejs/at91/at91sam9x5_devices.c
index 9348552..0448c0b 100644
--- a/arch/arm/cpu/arm926ejs/at91/at91sam9x5_devices.c
+++ b/arch/arm/cpu/arm926ejs/at91/at91sam9x5_devices.c
@@ -193,6 +193,19 @@ void at91_spi1_hw_init(unsigned long cs_mask)
 }
 #endif
 
+#if defined(CONFIG_USB_OHCI_NEW) || defined(CONFIG_USB_EHCI)
+void at91_uhp_hw_init(void)
+{
+   /* Enable VBus on UHP ports */
+   at91_set_pio_output(AT91_PIO_PORTD, 18, 0); /* port A */
+   at91_set_pio_output(AT91_PIO_PORTD, 19, 0); /* port B */
+#if defined(CONFIG_USB_OHCI_NEW)
+   /* port C is OHCI only */
+   at91_set_pio_output(AT91_PIO_PORTD, 20, 0); /* port C */
+#endif
+}
+#endif
+
 #ifdef CONFIG_MACB
 void at91_macb_hw_init(void)
 {
diff --git a/arch/arm/include/asm/arch-at91/at91sam9x5.h 
b/arch/arm/include/asm/arch-at91/at91sam9x5.h
index 0e728c9..de0f1b1 100644
--- a/arch/arm/include/asm/arch-at91/at91sam9x5.h
+++ b/arch/arm/include/asm/arch-at91/at91sam9x5.h
@@ -154,6 +154,8 @@
 #define ATMEL_PIO_PORTS 4
 #define CPU_HAS_PIO3
 #define PIO_SCDR_DIV(0x3fff <<  0)  /* Slow Clock Divider Mask */
+#define ATMEL_PMC_UHP  AT91SAM926x_PMC_UHP
+#define ATMEL_ID_UHP   ATMEL_ID_UHPHS
 
 /*
  * at91sam9x5 specific prototypes
diff --git a/board/atmel/at91sam9x5ek/at91sam9x5ek.c 
b/board/atmel/at91sam9x5ek/at91sam9x5ek.c
index edb0886..8773e6f 100644
--- a/board/atmel/at91sam9x5ek/at91sam9x5ek.c
+++ b/board/atmel/at91sam9x5ek/at91sam9x5ek.c
@@ -295,6 +295,9 @@ int board_init(void)
at91_macb_hw_init();
 #endif
 
+#if defined(CONFIG_USB_OHCI_NEW) || defined(CONFIG_USB_EHCI)
+   at91_uhp_hw_init();
+#endif
 #ifdef CONFIG_LCD
at91sam9x5ek_lcd_hw_init();
 #endif
diff --git a/drivers/usb/host/ohci-at91.c b/drivers/usb/host/ohci-at91.c
index 9532dd9..efd711d 100644
--- a/drivers/usb/host/ohci-at91.c
+++ b/drivers/usb/host/ohci-at91.c
@@ -41,7 +41,8 @@ int usb_cpu_init(void)
writel(get_pllb_init(), &pmc->pllbr);
while ((readl(&pmc->sr) & AT91_PMC_LOCKB) != AT91_PMC_LOCKB)
;
-#elif defined(CONFIG_AT91SAM9G45) || defined(CONFIG_AT91SAM9M10G45)
+#elif defined(CONFIG_AT91SAM9G45) || defined(CONFIG_AT91SAM9M10G45) || \
+   defined(CONFIG_AT91SAM9X5)
/* Enable UPLL */
writel(readl(&pmc->uckr) | AT91_PMC_UPLLEN | AT91_PMC_BIASEN,
&pmc->uckr);
@@ -81,7 +82,8 @@ int usb_cpu_stop(void)
writel(0, &pmc->pllbr);
while ((readl(&pmc->sr) & AT91_PMC_LOCKB) != 0)
;
-#elif defined(CONFIG_AT91SAM9G45) || defined(CONFIG_AT91SAM9M10G45)
+#elif defined(CONFIG_AT91SAM9G45) || defined(CONFIG_AT91SAM9M10G45) || \
+   defined(CONFIG_AT91SAM9X5)
/* Disable UPLL */
writel(readl(&pmc->uckr) & (~AT91_PMC_UPLLEN), &pmc->uckr);
while ((readl(&pmc->sr) & AT91_PMC_LOCKU) == AT91_PMC_LOCKU)
-- 
1.7.2.5

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


[U-Boot] [PATCHv3 4/4] at91sam9x5ek: add USB configuration

2012-11-30 Thread richard . genoud
From: Richard Genoud 

Signed-off-by: Richard Genoud 
---
 include/configs/at91sam9x5ek.h |   23 +++
 1 files changed, 23 insertions(+), 0 deletions(-)

diff --git a/include/configs/at91sam9x5ek.h b/include/configs/at91sam9x5ek.h
index 5e5f9c1..915714f 100644
--- a/include/configs/at91sam9x5ek.h
+++ b/include/configs/at91sam9x5ek.h
@@ -91,6 +91,13 @@
 #define CONFIG_CMD_SF
 #define CONFIG_CMD_MMC
 #define CONFIG_CMD_FAT
+#define CONFIG_CMD_USB
+
+/*
+ * define CONFIG_USB_EHCI to enable USB Hi-Speed (aka 2.0)
+ * NB: in this case, USB 1.1 devices won't be recognized.
+ */
+
 
 /* SDRAM */
 #define CONFIG_NR_DRAM_BANKS   1
@@ -158,6 +165,22 @@
 #define CONFIG_NET_RETRY_COUNT 20
 #define CONFIG_MACB_SEARCH_PHY
 
+/* USB */
+#ifdef CONFIG_CMD_USB
+#ifdef CONFIG_USB_EHCI
+#define CONFIG_USB_EHCI_ATMEL
+#define CONFIG_SYS_USB_EHCI_MAX_ROOT_PORTS 2
+#else
+#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  "at91sam9x5"
+#define CONFIG_SYS_USB_OHCI_MAX_ROOT_PORTS 3
+#endif
+#define CONFIG_USB_ATMEL
+#define CONFIG_USB_STORAGE
+#endif
+
 #define CONFIG_SYS_LOAD_ADDR   0x2200  /* load address */
 
 #define CONFIG_SYS_MEMTEST_START   CONFIG_SYS_SDRAM_BASE
-- 
1.7.2.5

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


[U-Boot] [PATCHv3 1/4] usb documentation: fix typo

2012-11-30 Thread richard . genoud
From: Richard Genoud 

Signed-off-by: Richard Genoud 
---
 doc/README.usb |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/doc/README.usb b/doc/README.usb
index ef1d6ba..b4c3ef5 100644
--- a/doc/README.usb
+++ b/doc/README.usb
@@ -63,7 +63,7 @@ Common USB Commands:
 Storage USB Commands:
 - usb scan:scans the USB for storage devices.The USB must be
running for this command (usb start)
-- usb device [dev]: show or set current USB staorage device
+- usb device [dev]: show or set current USB storage device
 - usb part [dev]:   print partition table of one or all USB storage
devices
 - usb read addr blk# cnt:
-- 
1.7.2.5

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


Re: [U-Boot] [PATCHv3 2/4] at91sam9x5: enable USB support for 9x5ek board.

2012-11-30 Thread Bo Shen

On 11/30/2012 17:18, richard.gen...@gmail.com wrote:

From: Richard Genoud 

Signed-off-by: Richard Genoud 


Acked-by: Bo Shen 
---
  arch/arm/cpu/arm926ejs/at91/at91sam9x5_devices.c |   13 +
  arch/arm/include/asm/arch-at91/at91sam9x5.h  |2 ++
  board/atmel/at91sam9x5ek/at91sam9x5ek.c  |3 +++
  drivers/usb/host/ohci-at91.c |6 --
  4 files changed, 22 insertions(+), 2 deletions(-)

diff --git a/arch/arm/cpu/arm926ejs/at91/at91sam9x5_devices.c 
b/arch/arm/cpu/arm926ejs/at91/at91sam9x5_devices.c
index 9348552..0448c0b 100644
--- a/arch/arm/cpu/arm926ejs/at91/at91sam9x5_devices.c
+++ b/arch/arm/cpu/arm926ejs/at91/at91sam9x5_devices.c
@@ -193,6 +193,19 @@ void at91_spi1_hw_init(unsigned long cs_mask)
  }
  #endif

+#if defined(CONFIG_USB_OHCI_NEW) || defined(CONFIG_USB_EHCI)
+void at91_uhp_hw_init(void)
+{
+   /* Enable VBus on UHP ports */
+   at91_set_pio_output(AT91_PIO_PORTD, 18, 0); /* port A */
+   at91_set_pio_output(AT91_PIO_PORTD, 19, 0); /* port B */
+#if defined(CONFIG_USB_OHCI_NEW)
+   /* port C is OHCI only */
+   at91_set_pio_output(AT91_PIO_PORTD, 20, 0); /* port C */
+#endif
+}
+#endif
+
  #ifdef CONFIG_MACB
  void at91_macb_hw_init(void)
  {
diff --git a/arch/arm/include/asm/arch-at91/at91sam9x5.h 
b/arch/arm/include/asm/arch-at91/at91sam9x5.h
index 0e728c9..de0f1b1 100644
--- a/arch/arm/include/asm/arch-at91/at91sam9x5.h
+++ b/arch/arm/include/asm/arch-at91/at91sam9x5.h
@@ -154,6 +154,8 @@
  #define ATMEL_PIO_PORTS 4
  #define CPU_HAS_PIO3
  #define PIO_SCDR_DIV(0x3fff <<  0)  /* Slow Clock Divider Mask */
+#define ATMEL_PMC_UHP  AT91SAM926x_PMC_UHP
+#define ATMEL_ID_UHP   ATMEL_ID_UHPHS

  /*
   * at91sam9x5 specific prototypes
diff --git a/board/atmel/at91sam9x5ek/at91sam9x5ek.c 
b/board/atmel/at91sam9x5ek/at91sam9x5ek.c
index edb0886..8773e6f 100644
--- a/board/atmel/at91sam9x5ek/at91sam9x5ek.c
+++ b/board/atmel/at91sam9x5ek/at91sam9x5ek.c
@@ -295,6 +295,9 @@ int board_init(void)
at91_macb_hw_init();
  #endif

+#if defined(CONFIG_USB_OHCI_NEW) || defined(CONFIG_USB_EHCI)
+   at91_uhp_hw_init();
+#endif
  #ifdef CONFIG_LCD
at91sam9x5ek_lcd_hw_init();
  #endif
diff --git a/drivers/usb/host/ohci-at91.c b/drivers/usb/host/ohci-at91.c
index 9532dd9..efd711d 100644
--- a/drivers/usb/host/ohci-at91.c
+++ b/drivers/usb/host/ohci-at91.c
@@ -41,7 +41,8 @@ int usb_cpu_init(void)
writel(get_pllb_init(), &pmc->pllbr);
while ((readl(&pmc->sr) & AT91_PMC_LOCKB) != AT91_PMC_LOCKB)
;
-#elif defined(CONFIG_AT91SAM9G45) || defined(CONFIG_AT91SAM9M10G45)
+#elif defined(CONFIG_AT91SAM9G45) || defined(CONFIG_AT91SAM9M10G45) || \
+   defined(CONFIG_AT91SAM9X5)
/* Enable UPLL */
writel(readl(&pmc->uckr) | AT91_PMC_UPLLEN | AT91_PMC_BIASEN,
&pmc->uckr);
@@ -81,7 +82,8 @@ int usb_cpu_stop(void)
writel(0, &pmc->pllbr);
while ((readl(&pmc->sr) & AT91_PMC_LOCKB) != 0)
;
-#elif defined(CONFIG_AT91SAM9G45) || defined(CONFIG_AT91SAM9M10G45)
+#elif defined(CONFIG_AT91SAM9G45) || defined(CONFIG_AT91SAM9M10G45) || \
+   defined(CONFIG_AT91SAM9X5)
/* Disable UPLL */
writel(readl(&pmc->uckr) & (~AT91_PMC_UPLLEN), &pmc->uckr);
while ((readl(&pmc->sr) & AT91_PMC_LOCKU) == AT91_PMC_LOCKU)



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


Re: [U-Boot] [PATCHv3 3/4] at91sam9x5ek: regroup FAT/DOS features

2012-11-30 Thread Bo Shen

On 11/30/2012 17:18, richard.gen...@gmail.com wrote:

From: Richard Genoud 

Signed-off-by: Richard Genoud 


Acked-by: Bo Shen 
---
  include/configs/at91sam9x5ek.h |6 +-
  1 files changed, 5 insertions(+), 1 deletions(-)

diff --git a/include/configs/at91sam9x5ek.h b/include/configs/at91sam9x5ek.h
index 71f765b..5e5f9c1 100644
--- a/include/configs/at91sam9x5ek.h
+++ b/include/configs/at91sam9x5ek.h
@@ -90,6 +90,7 @@
  #define CONFIG_CMD_NAND
  #define CONFIG_CMD_SF
  #define CONFIG_CMD_MMC
+#define CONFIG_CMD_FAT

  /* SDRAM */
  #define CONFIG_NR_DRAM_BANKS  1
@@ -142,9 +143,12 @@
  /* MMC */
  #ifdef CONFIG_CMD_MMC
  #define CONFIG_MMC
-#define CONFIG_CMD_FAT
  #define CONFIG_GENERIC_MMC
  #define CONFIG_GENERIC_ATMEL_MCI
+#endif
+
+/* FAT */
+#ifdef CONFIG_CMD_FAT
  #define CONFIG_DOS_PARTITION
  #endif




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


Re: [U-Boot] [PATCHv3 4/4] at91sam9x5ek: add USB configuration

2012-11-30 Thread Bo Shen

On 11/30/2012 17:18, richard.gen...@gmail.com wrote:

From: Richard Genoud 

Signed-off-by: Richard Genoud 


Acked-by: Bo Shen 
---
  include/configs/at91sam9x5ek.h |   23 +++
  1 files changed, 23 insertions(+), 0 deletions(-)

diff --git a/include/configs/at91sam9x5ek.h b/include/configs/at91sam9x5ek.h
index 5e5f9c1..915714f 100644
--- a/include/configs/at91sam9x5ek.h
+++ b/include/configs/at91sam9x5ek.h
@@ -91,6 +91,13 @@
  #define CONFIG_CMD_SF
  #define CONFIG_CMD_MMC
  #define CONFIG_CMD_FAT
+#define CONFIG_CMD_USB
+
+/*
+ * define CONFIG_USB_EHCI to enable USB Hi-Speed (aka 2.0)
+ * NB: in this case, USB 1.1 devices won't be recognized.
+ */
+

  /* SDRAM */
  #define CONFIG_NR_DRAM_BANKS  1
@@ -158,6 +165,22 @@
  #define CONFIG_NET_RETRY_COUNT20
  #define CONFIG_MACB_SEARCH_PHY

+/* USB */
+#ifdef CONFIG_CMD_USB
+#ifdef CONFIG_USB_EHCI
+#define CONFIG_USB_EHCI_ATMEL
+#define CONFIG_SYS_USB_EHCI_MAX_ROOT_PORTS 2
+#else
+#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  "at91sam9x5"
+#define CONFIG_SYS_USB_OHCI_MAX_ROOT_PORTS 3
+#endif
+#define CONFIG_USB_ATMEL
+#define CONFIG_USB_STORAGE
+#endif
+
  #define CONFIG_SYS_LOAD_ADDR  0x2200  /* load address */

  #define CONFIG_SYS_MEMTEST_START  CONFIG_SYS_SDRAM_BASE



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


Re: [U-Boot] [PATCH 00/46] Enhance spear support

2012-11-30 Thread Armando Visconti

On 11/21/2012 10:24 AM, Wolfgang Denk wrote:

Dear Vipin,

In message<50a0d0eb.4080...@st.com>  you wrote:


The ssh key is as below


THnaks a lot.  The repository should be ready for your use now.  Sorry
it took so long.

Please feel free to contact me directly if there should be any
problems.



Wolfgang, Vipin,

Not sure what are next steps for this patchset.
Is someone going to review it, or part of it?

Or is Vipin expected to do something on the repository
assigned to him (maybe he already did)?

Thx for clarifying it...

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


Re: [U-Boot] [PATCH 00/46] Enhance spear support

2012-11-30 Thread Wolfgang Denk
Dear Armando Visconti,

In message <50b89534.6040...@st.com> you wrote:
>
> Not sure what are next steps for this patchset.
> Is someone going to review it, or part of it?
> 
> Or is Vipin expected to do something on the repository
> assigned to him (maybe he already did)?

Vipin volunteered as custodian, so the next step should be that he
performs a final review, applies the patches to his repo, and sends a
pullr equest to Albert.

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 philosophy exam was a piece of cake  -  which  was  a  bit  of  a
surprise, actually, because I was expecting some questions on a sheet
of paper.
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH] mxs: Silence elftosb

2012-11-30 Thread Marek Vasut
The elftosb tool is now called with -d switch, which produces debug
output to the stdout. The debug output is completely useless for
regular operation, so silence it.

Signed-off-by: Marek Vasut 
Cc: Stefano Babic 
Cc: Fabio Estevam 
---
 Makefile |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/Makefile b/Makefile
index 2bff7e7..e9504c6 100644
--- a/Makefile
+++ b/Makefile
@@ -498,7 +498,7 @@ $(obj)u-boot.ais:   $(obj)spl/u-boot-spl.bin 
$(obj)u-boot.img
 ELFTOSB_TARGET-$(CONFIG_MX28) = imx28
 
 $(obj)u-boot.sb:   $(obj)u-boot.bin $(obj)spl/u-boot-spl.bin
-   elftosb -zdf $(ELFTOSB_TARGET-y) -c 
$(TOPDIR)/$(CPUDIR)/$(SOC)/u-boot-$(ELFTOSB_TARGET-y).bd \
+   elftosb -zf $(ELFTOSB_TARGET-y) -c 
$(TOPDIR)/$(CPUDIR)/$(SOC)/u-boot-$(ELFTOSB_TARGET-y).bd \
-o $(obj)u-boot.sb
 
 $(obj)u-boot.mx28.sd:  $(obj)u-boot.sb
-- 
1.7.10.4

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


[U-Boot] [PATCH] mxs: i2c: Implement algorithm to set up arbitrary i2c speed

2012-11-30 Thread Marek Vasut
This algorithm computes the values of TIMING{0,1,2} registers for the
MX28 I2C block. This algorithm was derived by using a scope, but the
result seems correct.

The resulting values programmed into the registers do not correlate
with the contents of the datasheet. When using the values from the
datasheet, the I2C clock were completely wrong.

Signed-off-by: Marek Vasut 
Cc: Stefano Babic 
Cc: Heiko Schocher 
Cc: Fabio Estevam 
---
 drivers/i2c/mxs_i2c.c |   73 ++---
 1 file changed, 21 insertions(+), 52 deletions(-)

NOTE: Heiko, please apply it onto your u-boot-i2c tree, it's dependent on the
patches that are already there.

diff --git a/drivers/i2c/mxs_i2c.c b/drivers/i2c/mxs_i2c.c
index 006fb91..7b3eec5 100644
--- a/drivers/i2c/mxs_i2c.c
+++ b/drivers/i2c/mxs_i2c.c
@@ -28,6 +28,7 @@
 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -40,6 +41,7 @@ void mxs_i2c_reset(void)
 {
struct mxs_i2c_regs *i2c_regs = (struct mxs_i2c_regs *)MXS_I2C0_BASE;
int ret;
+   int speed = i2c_get_bus_speed();
 
ret = mxs_reset_block(&i2c_regs->hw_i2c_ctrl0_reg);
if (ret) {
@@ -53,6 +55,8 @@ void mxs_i2c_reset(void)
&i2c_regs->hw_i2c_ctrl1_clr);
 
writel(I2C_QUEUECTRL_PIO_QUEUE_MODE, &i2c_regs->hw_i2c_queuectrl_set);
+
+   i2c_set_bus_speed(speed);
 }
 
 void mxs_i2c_setup_read(uint8_t chip, int len)
@@ -210,62 +214,28 @@ int i2c_probe(uchar chip)
return ret;
 }
 
-static struct mxs_i2c_speed_table {
-   uint32_tspeed;
-   uint32_ttiming0;
-   uint32_ttiming1;
-} mxs_i2c_tbl[] = {
-   {
-   10,
-   (0x0078 << I2C_TIMING0_HIGH_COUNT_OFFSET) |
-   (0x0030 << I2C_TIMING0_RCV_COUNT_OFFSET),
-   (0x0080 << I2C_TIMING1_LOW_COUNT_OFFSET) |
-   (0x0030 << I2C_TIMING1_XMIT_COUNT_OFFSET)
-   },
-   {
-   40,
-   (0x000f << I2C_TIMING0_HIGH_COUNT_OFFSET) |
-   (0x0007 << I2C_TIMING0_RCV_COUNT_OFFSET),
-   (0x001f << I2C_TIMING1_LOW_COUNT_OFFSET) |
-   (0x000f << I2C_TIMING1_XMIT_COUNT_OFFSET),
-   }
-};
-
-static struct mxs_i2c_speed_table *mxs_i2c_speed_to_cfg(uint32_t speed)
-{
-   int i;
-   for (i = 0; i < ARRAY_SIZE(mxs_i2c_tbl); i++)
-   if (mxs_i2c_tbl[i].speed == speed)
-   return &mxs_i2c_tbl[i];
-   return NULL;
-}
-
-static uint32_t mxs_i2c_cfg_to_speed(uint32_t timing0, uint32_t timing1)
-{
-   int i;
-   for (i = 0; i < ARRAY_SIZE(mxs_i2c_tbl); i++) {
-   if (mxs_i2c_tbl[i].timing0 != timing0)
-   continue;
-   if (mxs_i2c_tbl[i].timing1 != timing1)
-   continue;
-   return mxs_i2c_tbl[i].speed;
-   }
-
-   return 0;
-}
-
 int i2c_set_bus_speed(unsigned int speed)
 {
struct mxs_i2c_regs *i2c_regs = (struct mxs_i2c_regs *)MXS_I2C0_BASE;
-   struct mxs_i2c_speed_table *spd = mxs_i2c_speed_to_cfg(speed);
 
-   if (!spd) {
-   printf("MXS I2C: Invalid speed selected (%d Hz)\n", speed);
+   uint32_t base = ((2400 / speed) - 38) / 2;
+   uint16_t high_count = base + 3;
+   uint16_t low_count = base - 3;
+   uint16_t rcv_count = (high_count * 3) / 4;
+   uint16_t xmit_count = low_count / 4;
+
+   if (speed > 54) {
+   printf("MXS I2C: Speed too high (%d Hz)\n", speed);
+   return -EINVAL;
+   }
+
+   if (speed < 12000) {
+   printf("MXS I2C: Speed too low (%d Hz)\n", speed);
return -EINVAL;
}
 
-   writel(spd->timing0, &i2c_regs->hw_i2c_timing0);
-   writel(spd->timing1, &i2c_regs->hw_i2c_timing1);
+   writel((high_count << 16) | rcv_count, &i2c_regs->hw_i2c_timing0);
+   writel((low_count << 16) | xmit_count, &i2c_regs->hw_i2c_timing1);
 
writel((0x0030 << I2C_TIMING2_BUS_FREE_OFFSET) |
(0x0030 << I2C_TIMING2_LEADIN_COUNT_OFFSET),
@@ -277,12 +247,11 @@ int i2c_set_bus_speed(unsigned int speed)
 unsigned int i2c_get_bus_speed(void)
 {
struct mxs_i2c_regs *i2c_regs = (struct mxs_i2c_regs *)MXS_I2C0_BASE;
-   uint32_t timing0, timing1;
+   uint32_t timing0;
 
timing0 = readl(&i2c_regs->hw_i2c_timing0);
-   timing1 = readl(&i2c_regs->hw_i2c_timing1);
 
-   return mxs_i2c_cfg_to_speed(timing0, timing1);
+   return 2400 / timing0 >> 16) - 3) * 2) + 38);
 }
 
 void i2c_init(int speed, int slaveadd)
-- 
1.7.10.4

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


Re: [U-Boot] [PATCH 00/46] Enhance spear support

2012-11-30 Thread Armando Visconti

On 11/30/2012 01:34 PM, Wolfgang Denk wrote:

Dear Armando Visconti,

In message<50b89534.6040...@st.com>  you wrote:


Not sure what are next steps for this patchset.
Is someone going to review it, or part of it?

Or is Vipin expected to do something on the repository
assigned to him (maybe he already did)?


Vipin volunteered as custodian, so the next step should be that he
performs a final review, applies the patches to his repo, and sends a
pullr equest to Albert.



Clear.

Ciao,
Arm

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


Re: [U-Boot] [PATCH] mxs: i2c: Implement algorithm to set up arbitrary i2c speed

2012-11-30 Thread Wolfgang Denk
Dear Marek Vasut,

In message <1354280910-17539-1-git-send-email-ma...@denx.de> you wrote:
> This algorithm computes the values of TIMING{0,1,2} registers for the
> MX28 I2C block. This algorithm was derived by using a scope, but the
> result seems correct.

Thanks!  I like that!

...
> + uint32_t base = ((2400 / speed) - 38) / 2;
...
> + return 2400 / timing0 >> 16) - 3) * 2) + 38);

But we should get rid of this magic constant.  On other i.MX systems
that would probably be MXC_HCLK ?

For iMX28, we have CONFIG_PL011_CLOCK in the board config files
instead.

Hm... grepping the source tree for 2400 I get the feeling that
this really needs some cleanup

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
Vulcans worship peace above all.
-- McCoy, "Return to Tomorrow", stardate 4768.3
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH] mxs: i2c: Implement algorithm to set up arbitrary i2c speed

2012-11-30 Thread Marek Vasut
Dear Wolfgang Denk,

> Dear Marek Vasut,
> 
> In message <1354280910-17539-1-git-send-email-ma...@denx.de> you wrote:
> > This algorithm computes the values of TIMING{0,1,2} registers for the
> > MX28 I2C block. This algorithm was derived by using a scope, but the
> > result seems correct.
> 
> Thanks!  I like that!
> 
> ...
> 
> > +   uint32_t base = ((2400 / speed) - 38) / 2;
> 
> ...
> 
> > +   return 2400 / timing0 >> 16) - 3) * 2) + 38);
> 
> But we should get rid of this magic constant.  On other i.MX systems
> that would probably be MXC_HCLK ?

It's APBX clock ... you are so right ... I rolled the patch out too fast.
[...]

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


[U-Boot] [PATCH 1/2] mxs: Implement common function to setup VDDx

2012-11-30 Thread Marek Vasut
Implement common function to setup the VDDIO, VDDD and VDDA voltage.
Right now, there are two almost identical functions to setup VDDIO
and VDDD, which is prone to breakage. Pull out the differences into
constant structure and pass them as an argument to the common function.

Moreover, the function has almost identical loops for setting higher
and lower VDDx voltage. Merge these two loops.

Signed-off-by: Marek Vasut 
Cc: Stefano Babic 
Cc: Fabio Estevam 
---
 arch/arm/cpu/arm926ejs/mxs/spl_power_init.c |  253 +--
 1 file changed, 83 insertions(+), 170 deletions(-)

diff --git a/arch/arm/cpu/arm926ejs/mxs/spl_power_init.c 
b/arch/arm/cpu/arm926ejs/mxs/spl_power_init.c
index 4b917bd..0d80158 100644
--- a/arch/arm/cpu/arm926ejs/mxs/spl_power_init.c
+++ b/arch/arm/cpu/arm926ejs/mxs/spl_power_init.c
@@ -766,198 +766,112 @@ int mxs_get_vddd_power_source_off(void)
return 0;
 }
 
-void mxs_power_set_vddio(uint32_t new_target, uint32_t new_brownout)
+struct mxs_vddx_cfg {
+   uint32_t*reg;
+   uint8_t step_mV;
+   uint16_tlowest_mV;
+   int (*powered_by_linreg)(void);
+   uint32_ttrg_mask;
+   uint32_tbo_irq;
+   uint32_tbo_enirq;
+   uint32_tbo_offset_mask;
+   uint32_tbo_offset_offset;
+};
+
+const struct mxs_vddx_cfg mxs_vddio_cfg = {
+   .reg= &(((struct mxs_power_regs *)MXS_POWER_BASE)->
+   hw_power_vddioctrl),
+   .step_mV= 50,
+   .lowest_mV  = 2800,
+   .powered_by_linreg  = mxs_get_vddio_power_source_off,
+   .trg_mask   = POWER_VDDIOCTRL_TRG_MASK,
+   .bo_irq = POWER_CTRL_VDDIO_BO_IRQ,
+   .bo_enirq   = POWER_CTRL_ENIRQ_VDDIO_BO,
+   .bo_offset_mask = POWER_VDDIOCTRL_BO_OFFSET_MASK,
+   .bo_offset_offset   = POWER_VDDIOCTRL_BO_OFFSET_OFFSET,
+};
+
+const struct mxs_vddx_cfg mxs_vddd_cfg = {
+   .reg= &(((struct mxs_power_regs *)MXS_POWER_BASE)->
+   hw_power_vdddctrl),
+   .step_mV= 25,
+   .lowest_mV  = 800,
+   .powered_by_linreg  = mxs_get_vddd_power_source_off,
+   .trg_mask   = POWER_VDDDCTRL_TRG_MASK,
+   .bo_irq = POWER_CTRL_VDDD_BO_IRQ,
+   .bo_enirq   = POWER_CTRL_ENIRQ_VDDD_BO,
+   .bo_offset_mask = POWER_VDDDCTRL_BO_OFFSET_MASK,
+   .bo_offset_offset   = POWER_VDDDCTRL_BO_OFFSET_OFFSET,
+};
+
+static void mxs_power_set_vddx(const struct mxs_vddx_cfg *cfg,
+   uint32_t new_target, uint32_t new_brownout)
 {
struct mxs_power_regs *power_regs =
(struct mxs_power_regs *)MXS_POWER_BASE;
uint32_t cur_target, diff, bo_int = 0;
uint32_t powered_by_linreg = 0;
+   int adjust_up, tmp;
 
-   new_brownout = (new_target - new_brownout + 25) / 50;
+   new_brownout = DIV_ROUND(new_target - new_brownout, cfg->step_mV);
 
-   cur_target = readl(&power_regs->hw_power_vddioctrl);
-   cur_target &= POWER_VDDIOCTRL_TRG_MASK;
-   cur_target *= 50;   /* 50 mV step*/
-   cur_target += 2800; /* 2800 mV lowest */
+   cur_target = readl(cfg->reg);
+   cur_target &= cfg->trg_mask;
+   cur_target *= cfg->step_mV;
+   cur_target += cfg->lowest_mV;
 
-   powered_by_linreg = mxs_get_vddio_power_source_off();
-   if (new_target > cur_target) {
+   adjust_up = new_target > cur_target;
+   powered_by_linreg = cfg->powered_by_linreg();
 
+   if (adjust_up) {
if (powered_by_linreg) {
-   bo_int = readl(&power_regs->hw_power_vddioctrl);
-   clrbits_le32(&power_regs->hw_power_vddioctrl,
-   POWER_CTRL_ENIRQ_VDDIO_BO);
+   bo_int = readl(cfg->reg);
+   clrbits_le32(cfg->reg, cfg->bo_enirq);
}
+   setbits_le32(cfg->reg, cfg->bo_offset_mask);
+   }
 
-   setbits_le32(&power_regs->hw_power_vddioctrl,
-   POWER_VDDIOCTRL_BO_OFFSET_MASK);
-   do {
-   if (new_target - cur_target > 100)
+   do {
+   if (abs(new_target - cur_target) > 100) {
+   if (adjust_up)
diff = cur_target + 100;
else
-   diff = new_target;
-
-   diff -= 2800;
-   diff /= 50;
-
-   clrsetbits_le32(&power_regs->hw_power_vddioctrl,
-   POWER_VDDIOCTRL_TRG_MASK, diff);
-
-   if (powered_by_linreg ||
- 

[U-Boot] [PATCH 2/2] mxs: Properly setup VDDD in power supply setup code

2012-11-30 Thread Marek Vasut
The memory setup code adjusted the VDDD voltage. Remove this adjustment
and configure the VDDD voltage correctly in the power supply setup code.

Signed-off-by: Marek Vasut 
Cc: Stefano Babic 
Cc: Fabio Estevam 
---
 arch/arm/cpu/arm926ejs/mxs/spl_mem_init.c   |   13 -
 arch/arm/cpu/arm926ejs/mxs/spl_power_init.c |2 +-
 2 files changed, 1 insertion(+), 14 deletions(-)

diff --git a/arch/arm/cpu/arm926ejs/mxs/spl_mem_init.c 
b/arch/arm/cpu/arm926ejs/mxs/spl_mem_init.c
index e693145..8904e24 100644
--- a/arch/arm/cpu/arm926ejs/mxs/spl_mem_init.c
+++ b/arch/arm/cpu/arm926ejs/mxs/spl_mem_init.c
@@ -171,17 +171,6 @@ void mxs_mem_setup_vdda(void)
&power_regs->hw_power_vddactrl);
 }
 
-void mxs_mem_setup_vddd(void)
-{
-   struct mxs_power_regs *power_regs =
-   (struct mxs_power_regs *)MXS_POWER_BASE;
-
-   writel((0x1c << POWER_VDDDCTRL_TRG_OFFSET) |
-   (0x7 << POWER_VDDDCTRL_BO_OFFSET_OFFSET) |
-   POWER_VDDDCTRL_LINREG_OFFSET_1STEPS_BELOW,
-   &power_regs->hw_power_vdddctrl);
-}
-
 uint32_t mxs_mem_get_size(void)
 {
uint32_t sz, da;
@@ -241,8 +230,6 @@ void mxs_mem_init(void)
while (!(readl(MXS_DRAM_BASE + 0xe8) & (1 << 20)))
;
 
-   mxs_mem_setup_vddd();
-
early_delay(1);
 
mxs_mem_setup_cpu_and_hbus();
diff --git a/arch/arm/cpu/arm926ejs/mxs/spl_power_init.c 
b/arch/arm/cpu/arm926ejs/mxs/spl_power_init.c
index 0d80158..2bc6ad1 100644
--- a/arch/arm/cpu/arm926ejs/mxs/spl_power_init.c
+++ b/arch/arm/cpu/arm926ejs/mxs/spl_power_init.c
@@ -897,7 +897,7 @@ void mxs_power_init(void)
mxs_enable_output_rail_protection();
 
mxs_power_set_vddx(&mxs_vddio_cfg, 3300, 3150);
-   mxs_power_set_vddx(&mxs_vddd_cfg, 1350, 1200);
+   mxs_power_set_vddx(&mxs_vddd_cfg, 1500, 1000);
 
writel(POWER_CTRL_VDDD_BO_IRQ | POWER_CTRL_VDDA_BO_IRQ |
POWER_CTRL_VDDIO_BO_IRQ | POWER_CTRL_VDD5V_DROOP_IRQ |
-- 
1.7.10.4

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


[U-Boot] [PATCH v2] mxs: i2c: Implement algorithm to set up arbitrary i2c speed

2012-11-30 Thread Marek Vasut
This algorithm computes the values of TIMING{0,1,2} registers for the
MX28 I2C block. This algorithm was derived by using a scope, but the
result seems correct.

The resulting values programmed into the registers do not correlate
with the contents in datasheet. When using the values from the datasheet,
the I2C clock were completely wrong.

Signed-off-by: Marek Vasut 
Cc: Stefano Babic 
Cc: Fabio Estevam 
Cc: Wolfgang Denk 
---
 arch/arm/cpu/arm926ejs/mxs/clock.c|2 +
 arch/arm/include/asm/arch-mxs/clock.h |1 +
 drivers/i2c/mxs_i2c.c |   75 ++---
 3 files changed, 26 insertions(+), 52 deletions(-)

v2: Properly implement XTAL clock retrieval. The i2c clock are derived from the
24MHz XTAL clock.

diff --git a/arch/arm/cpu/arm926ejs/mxs/clock.c 
b/arch/arm/cpu/arm926ejs/mxs/clock.c
index bfea6ab..4ff19c3 100644
--- a/arch/arm/cpu/arm926ejs/mxs/clock.c
+++ b/arch/arm/cpu/arm926ejs/mxs/clock.c
@@ -333,6 +333,8 @@ uint32_t mxc_get_clock(enum mxc_clock clk)
return mx28_get_sspclk(MXC_SSPCLK2);
case MXC_SSP3_CLK:
return mx28_get_sspclk(MXC_SSPCLK3);
+   case MXC_XTAL_CLK:
+   return XTAL_FREQ_KHZ * 1000;
}
 
return 0;
diff --git a/arch/arm/include/asm/arch-mxs/clock.h 
b/arch/arm/include/asm/arch-mxs/clock.h
index 1700fe3..3d39ef2 100644
--- a/arch/arm/include/asm/arch-mxs/clock.h
+++ b/arch/arm/include/asm/arch-mxs/clock.h
@@ -35,6 +35,7 @@ enum mxc_clock {
MXC_SSP1_CLK,
MXC_SSP2_CLK,
MXC_SSP3_CLK,
+   MXC_XTAL_CLK,
 };
 
 enum mxs_ioclock {
diff --git a/drivers/i2c/mxs_i2c.c b/drivers/i2c/mxs_i2c.c
index 006fb91..b040535 100644
--- a/drivers/i2c/mxs_i2c.c
+++ b/drivers/i2c/mxs_i2c.c
@@ -28,6 +28,7 @@
 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -40,6 +41,7 @@ void mxs_i2c_reset(void)
 {
struct mxs_i2c_regs *i2c_regs = (struct mxs_i2c_regs *)MXS_I2C0_BASE;
int ret;
+   int speed = i2c_get_bus_speed();
 
ret = mxs_reset_block(&i2c_regs->hw_i2c_ctrl0_reg);
if (ret) {
@@ -53,6 +55,8 @@ void mxs_i2c_reset(void)
&i2c_regs->hw_i2c_ctrl1_clr);
 
writel(I2C_QUEUECTRL_PIO_QUEUE_MODE, &i2c_regs->hw_i2c_queuectrl_set);
+
+   i2c_set_bus_speed(speed);
 }
 
 void mxs_i2c_setup_read(uint8_t chip, int len)
@@ -210,62 +214,29 @@ int i2c_probe(uchar chip)
return ret;
 }
 
-static struct mxs_i2c_speed_table {
-   uint32_tspeed;
-   uint32_ttiming0;
-   uint32_ttiming1;
-} mxs_i2c_tbl[] = {
-   {
-   10,
-   (0x0078 << I2C_TIMING0_HIGH_COUNT_OFFSET) |
-   (0x0030 << I2C_TIMING0_RCV_COUNT_OFFSET),
-   (0x0080 << I2C_TIMING1_LOW_COUNT_OFFSET) |
-   (0x0030 << I2C_TIMING1_XMIT_COUNT_OFFSET)
-   },
-   {
-   40,
-   (0x000f << I2C_TIMING0_HIGH_COUNT_OFFSET) |
-   (0x0007 << I2C_TIMING0_RCV_COUNT_OFFSET),
-   (0x001f << I2C_TIMING1_LOW_COUNT_OFFSET) |
-   (0x000f << I2C_TIMING1_XMIT_COUNT_OFFSET),
-   }
-};
-
-static struct mxs_i2c_speed_table *mxs_i2c_speed_to_cfg(uint32_t speed)
-{
-   int i;
-   for (i = 0; i < ARRAY_SIZE(mxs_i2c_tbl); i++)
-   if (mxs_i2c_tbl[i].speed == speed)
-   return &mxs_i2c_tbl[i];
-   return NULL;
-}
-
-static uint32_t mxs_i2c_cfg_to_speed(uint32_t timing0, uint32_t timing1)
-{
-   int i;
-   for (i = 0; i < ARRAY_SIZE(mxs_i2c_tbl); i++) {
-   if (mxs_i2c_tbl[i].timing0 != timing0)
-   continue;
-   if (mxs_i2c_tbl[i].timing1 != timing1)
-   continue;
-   return mxs_i2c_tbl[i].speed;
-   }
-
-   return 0;
-}
-
 int i2c_set_bus_speed(unsigned int speed)
 {
struct mxs_i2c_regs *i2c_regs = (struct mxs_i2c_regs *)MXS_I2C0_BASE;
-   struct mxs_i2c_speed_table *spd = mxs_i2c_speed_to_cfg(speed);
 
-   if (!spd) {
-   printf("MXS I2C: Invalid speed selected (%d Hz)\n", speed);
+   uint32_t clk = mxc_get_clock(MXC_XTAL_CLK);
+   uint32_t base = ((clk / speed) - 38) / 2;
+   uint16_t high_count = base + 3;
+   uint16_t low_count = base - 3;
+   uint16_t rcv_count = (high_count * 3) / 4;
+   uint16_t xmit_count = low_count / 4;
+
+   if (speed > 54) {
+   printf("MXS I2C: Speed too high (%d Hz)\n", speed);
+   return -EINVAL;
+   }
+
+   if (speed < 12000) {
+   printf("MXS I2C: Speed too low (%d Hz)\n", speed);
return -EINVAL;
}
 
-   writel(spd->timing0, &i2c_regs->hw_i2c_timing0);
-   writel(spd->timing1, &i2c_regs->hw_i2c_timing1);
+   writel((high_count << 16) | rcv_count, &i2c_regs->hw_i2c_timing0);
+   writel((low_count << 16) | xmit_count, &i2c_regs->hw_i2c_timing1);
 
writel((0x0030 << I2C_TIMING2_

[U-Boot] [PATCH v3 03/12] x86: video: Add coreboot framebuffer support

2012-11-30 Thread Simon Glass
From: Stefan Reinauer 

Add a basic driver for the coreboot framebuffer.

Signed-off-by: Stefan Reinauer 
Signed-off-by: Simon Glass 
---
Changes in v3:
- Update to avoid using gd which is now a #define

Changes in v2: None

 drivers/video/Makefile  |1 +
 drivers/video/coreboot_fb.c |  101 +++
 2 files changed, 102 insertions(+), 0 deletions(-)
 create mode 100644 drivers/video/coreboot_fb.c

diff --git a/drivers/video/Makefile b/drivers/video/Makefile
index ebb6da8..cc3022a 100644
--- a/drivers/video/Makefile
+++ b/drivers/video/Makefile
@@ -39,6 +39,7 @@ COBJS-$(CONFIG_S6E8AX0) += s6e8ax0.o
 COBJS-$(CONFIG_S6E63D6) += s6e63d6.o
 COBJS-$(CONFIG_SED156X) += sed156x.o
 COBJS-$(CONFIG_VIDEO_AMBA) += amba.o
+COBJS-$(CONFIG_VIDEO_COREBOOT) += coreboot_fb.o
 COBJS-$(CONFIG_VIDEO_CT69000) += ct69000.o videomodes.o
 COBJS-$(CONFIG_VIDEO_DA8XX) += da8xx-fb.o videomodes.o
 COBJS-$(CONFIG_VIDEO_MB862xx) += mb862xx.o videomodes.o
diff --git a/drivers/video/coreboot_fb.c b/drivers/video/coreboot_fb.c
new file mode 100644
index 000..d93bd89
--- /dev/null
+++ b/drivers/video/coreboot_fb.c
@@ -0,0 +1,101 @@
+/*
+ * coreboot Framebuffer driver.
+ *
+ * Copyright (C) 2011 The Chromium OS authors
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include "videomodes.h"
+
+/*
+ * The Graphic Device
+ */
+GraphicDevice ctfb;
+
+static int parse_coreboot_table_fb(GraphicDevice *gdev)
+{
+   struct cb_framebuffer *fb = lib_sysinfo.framebuffer;
+
+   /* If there is no framebuffer structure, bail out and keep
+* running on the serial console.
+*/
+   if (!fb)
+   return 0;
+
+   gdev->winSizeX = fb->x_resolution;
+   gdev->winSizeY = fb->y_resolution;
+
+   gdev->plnSizeX = fb->x_resolution;
+   gdev->plnSizeY = fb->y_resolution;
+
+   gdev->gdfBytesPP = fb->bits_per_pixel / 8;
+
+   switch (fb->bits_per_pixel) {
+   case 24:
+   gdev->gdfIndex = GDF_32BIT_X888RGB;
+   break;
+   case 16:
+   gdev->gdfIndex = GDF_16BIT_565RGB;
+   break;
+   default:
+   gdev->gdfIndex = GDF__8BIT_INDEX;
+   break;
+   }
+
+   gdev->isaBase = CONFIG_SYS_ISA_IO_BASE_ADDRESS;
+   gdev->pciBase = (unsigned int)fb->physical_address;
+
+   gdev->frameAdrs = (unsigned int)fb->physical_address;
+   gdev->memSize = fb->bytes_per_line * fb->y_resolution;
+
+   gdev->vprBase = (unsigned int)fb->physical_address;
+   gdev->cprBase = (unsigned int)fb->physical_address;
+
+   return 1;
+}
+
+void *video_hw_init(void)
+{
+   GraphicDevice *gdev = &ctfb;
+   int bits_per_pixel;
+
+   printf("Video: ");
+
+   if (!parse_coreboot_table_fb(gdev)) {
+   printf("No video mode configured in coreboot!\n");
+   return NULL;
+   }
+
+   bits_per_pixel = gdev->gdfBytesPP * 8;
+
+   /* fill in Graphic device struct */
+   sprintf(gdev->modeIdent, "%dx%dx%d", gdev->winSizeX, gdev->winSizeY,
+bits_per_pixel);
+   printf("%s\n", gdev->modeIdent);
+
+   memset((void *)gdev->pciBase, 0,
+   gdev->winSizeX * gdev->winSizeY * gdev->gdfBytesPP);
+
+   return (void *)gdev;
+}
-- 
1.7.7.3

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


[U-Boot] [PATCH 0/9] USB: Gadget & DFU related fixes (v3)

2012-11-30 Thread Pantelis Antoniou
Third take of USB + DFU updates.

Pantelis Antoniou (9):
  usb: Fix bug when both DFU & ETHER are defined
  g_dnl: Issue connect/disconnect as appropriate
  g_dnl: Properly terminate string list.
  dfu: Only perform DFU board_usb_init() for TRATS
  dfu: Fix crash when wrong number of arguments given
  dfu: Send correct DFU response from composite_setup
  dfu: Properly zero out timeout value
  dfu: Add a partition type target
  dfu: Support larger than memory transfers.

 common/cmd_dfu.c|   5 +-
 drivers/dfu/dfu.c   | 244 
 drivers/dfu/dfu_mmc.c   | 109 
 drivers/usb/gadget/Makefile |   8 +-
 drivers/usb/gadget/composite.c  |  27 
 drivers/usb/gadget/ep0.c|   1 +
 drivers/usb/gadget/f_dfu.c  |   9 +-
 drivers/usb/gadget/g_dnl.c  |  12 +-
 include/configs/am335x_evm.h|   1 +
 include/configs/am3517_evm.h|   1 +
 include/configs/h2200.h |   1 +
 include/configs/omap3_beagle.h  |   1 +
 include/configs/s5p_goni.h  |   1 +
 include/configs/s5pc210_universal.h |   1 +
 include/configs/trats.h |   1 +
 include/dfu.h   |  21 +++-
 16 files changed, 356 insertions(+), 87 deletions(-)

-- 
1.7.12

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


[U-Boot] [PATCH 2/9] g_dnl: Issue connect/disconnect as appropriate

2012-11-30 Thread Pantelis Antoniou
Call usb_gadget_connect/usb_gadget_disconnect in g_dnl_bind/g_dnl_unbind.

Signed-off-by: Pantelis Antoniou 
---
 drivers/usb/gadget/g_dnl.c | 11 ++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/gadget/g_dnl.c b/drivers/usb/gadget/g_dnl.c
index 7d87050..25da733 100644
--- a/drivers/usb/gadget/g_dnl.c
+++ b/drivers/usb/gadget/g_dnl.c
@@ -83,7 +83,12 @@ static struct usb_gadget_strings *g_dnl_composite_strings[] 
= {
 
 static int g_dnl_unbind(struct usb_composite_dev *cdev)
 {
-   debug("%s\n", __func__);
+   struct usb_gadget *gadget = cdev->gadget;
+
+   debug("%s: calling usb_gadget_disconnect for "
+   "controller '%s'\n", shortname, gadget->name);
+   usb_gadget_disconnect(gadget);
+
return 0;
 }
 
@@ -153,6 +158,10 @@ static int g_dnl_bind(struct usb_composite_dev *cdev)
device_desc.bcdDevice = __constant_cpu_to_le16(0x);
}
 
+   debug("%s: calling usb_gadget_connect for "
+   "controller '%s'\n", shortname, gadget->name);
+   usb_gadget_connect(gadget);
+
return 0;
 
  error:
-- 
1.7.12

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


[U-Boot] [PATCH 3/9] g_dnl: Properly terminate string list.

2012-11-30 Thread Pantelis Antoniou
Well, not terminating the list causes very interesting crashes.
As in changing the vendor & product ID crashes. Fun.

Signed-off-by: Pantelis Antoniou 
---
 drivers/usb/gadget/g_dnl.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/usb/gadget/g_dnl.c b/drivers/usb/gadget/g_dnl.c
index 25da733..a5a4c1f 100644
--- a/drivers/usb/gadget/g_dnl.c
+++ b/drivers/usb/gadget/g_dnl.c
@@ -69,6 +69,7 @@ static struct usb_device_descriptor device_desc = {
 static struct usb_string g_dnl_string_defs[] = {
{ 0, manufacturer, },
{ 1, product, },
+   {  }/* end of list */
 };
 
 static struct usb_gadget_strings g_dnl_string_tab = {
-- 
1.7.12

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


[U-Boot] [PATCH 1/9] usb: Fix bug when both DFU & ETHER are defined

2012-11-30 Thread Pantelis Antoniou
When both CONFIG_USB_GADGET & CONFIG_USB_ETHER are defined
the makefile links objects twice.

The cleanest way to fix is to use a new define, CONFIG_USB_UTIL
which must be defined when either CONFIG_USB_ETHER or
CONFIG_USB_GADGET are defined.

All affected boards have been modified as well.

Signed-off-by: Pantelis Antoniou 
---
 drivers/usb/gadget/Makefile | 8 ++--
 include/configs/am335x_evm.h| 1 +
 include/configs/am3517_evm.h| 1 +
 include/configs/h2200.h | 1 +
 include/configs/omap3_beagle.h  | 1 +
 include/configs/s5p_goni.h  | 1 +
 include/configs/s5pc210_universal.h | 1 +
 include/configs/trats.h | 1 +
 8 files changed, 13 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/gadget/Makefile b/drivers/usb/gadget/Makefile
index 040eaba..167f24f 100644
--- a/drivers/usb/gadget/Makefile
+++ b/drivers/usb/gadget/Makefile
@@ -25,15 +25,19 @@ include $(TOPDIR)/config.mk
 
 LIB:= $(obj)libusb_gadget.o
 
+# required for both USB_GADGET & USB_ETHER
+ifdef CONFIG_USB_UTIL
+COBJS-y += epautoconf.o config.o usbstring.o
+endif
+
 # new USB gadget layer dependencies
 ifdef CONFIG_USB_GADGET
-COBJS-y += epautoconf.o config.o usbstring.o
 COBJS-$(CONFIG_USB_GADGET_S3C_UDC_OTG) += s3c_udc_otg.o
 COBJS-$(CONFIG_USBDOWNLOAD_GADGET) += g_dnl.o
 COBJS-$(CONFIG_DFU_FUNCTION) += f_dfu.o
 endif
 ifdef CONFIG_USB_ETHER
-COBJS-y += ether.o epautoconf.o config.o usbstring.o
+COBJS-y += ether.o
 COBJS-$(CONFIG_USB_ETH_RNDIS) += rndis.o
 COBJS-$(CONFIG_MV_UDC) += mv_udc.o
 COBJS-$(CONFIG_CPU_PXA25X) += pxa25x_udc.o
diff --git a/include/configs/am335x_evm.h b/include/configs/am335x_evm.h
index ab9549b..ee19e54 100644
--- a/include/configs/am335x_evm.h
+++ b/include/configs/am335x_evm.h
@@ -278,6 +278,7 @@
 
 #ifdef CONFIG_MUSB_GADGET
 #define CONFIG_USB_ETHER
+#define CONFIG_USB_UTIL
 #define CONFIG_USB_ETH_RNDIS
 #endif /* CONFIG_MUSB_GADGET */
 
diff --git a/include/configs/am3517_evm.h b/include/configs/am3517_evm.h
index ba15325..3aedff3 100644
--- a/include/configs/am3517_evm.h
+++ b/include/configs/am3517_evm.h
@@ -123,6 +123,7 @@
 #ifdef CONFIG_MUSB_GADGET
 #define CONFIG_USB_GADGET_DUALSPEED
 #define CONFIG_USB_ETHER
+#define CONFIG_USB_UTIL
 #define CONFIG_USB_ETH_RNDIS
 #endif /* CONFIG_MUSB_GADGET */
 
diff --git a/include/configs/h2200.h b/include/configs/h2200.h
index 516a26e..fc27bf0 100644
--- a/include/configs/h2200.h
+++ b/include/configs/h2200.h
@@ -170,6 +170,7 @@
 
 #define CONFIG_USB_GADGET_PXA2XX
 #define CONFIG_USB_ETHER
+#define CONFIG_USB_UTIL
 #define CONFIG_USB_ETH_SUBSET
 
 #define CONFIG_USBNET_DEV_ADDR "de:ad:be:ef:00:01"
diff --git a/include/configs/omap3_beagle.h b/include/configs/omap3_beagle.h
index 12d65f2..04fbb5d 100644
--- a/include/configs/omap3_beagle.h
+++ b/include/configs/omap3_beagle.h
@@ -123,6 +123,7 @@
 #define CONFIG_USB_GADGET_DUALSPEED
 #define CONFIG_TWL4030_USB 1
 #define CONFIG_USB_ETHER
+#define CONFIG_USB_UTIL
 #define CONFIG_USB_ETHER_RNDIS
 
 /* USB EHCI */
diff --git a/include/configs/s5p_goni.h b/include/configs/s5p_goni.h
index 56e8347..1e180ade 100644
--- a/include/configs/s5p_goni.h
+++ b/include/configs/s5p_goni.h
@@ -231,6 +231,7 @@
 #define CONFIG_I2C_MULTI_BUS
 #define CONFIG_SYS_MAX_I2C_BUS 7
 #define CONFIG_USB_GADGET
+#define CONFIG_USB_UTIL
 #define CONFIG_USB_GADGET_S3C_UDC_OTG
 #define CONFIG_USB_GADGET_DUALSPEED
 
diff --git a/include/configs/s5pc210_universal.h 
b/include/configs/s5pc210_universal.h
index 894f38b..07ab884 100644
--- a/include/configs/s5pc210_universal.h
+++ b/include/configs/s5pc210_universal.h
@@ -258,6 +258,7 @@
 #define CONFIG_POWER_MAX8998
 
 #define CONFIG_USB_GADGET
+#define CONFIG_USB_UTIL
 #define CONFIG_USB_GADGET_S3C_UDC_OTG
 #define CONFIG_USB_GADGET_DUALSPEED
 
diff --git a/include/configs/trats.h b/include/configs/trats.h
index 355029e..7c2c875 100644
--- a/include/configs/trats.h
+++ b/include/configs/trats.h
@@ -245,6 +245,7 @@
 #define CONFIG_POWER_BATTERY
 #define CONFIG_POWER_BATTERY_TRATS
 #define CONFIG_USB_GADGET
+#define CONFIG_USB_UTIL
 #define CONFIG_USB_GADGET_S3C_UDC_OTG
 #define CONFIG_USB_GADGET_DUALSPEED
 #define CONFIG_USB_GADGET_VBUS_DRAW2
-- 
1.7.12

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


[U-Boot] [PATCH 4/9] dfu: Only perform DFU board_usb_init() for TRATS

2012-11-30 Thread Pantelis Antoniou
USB initialization shouldn't happen for all the boards.

Signed-off-by: Pantelis Antoniou 
---
 common/cmd_dfu.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/common/cmd_dfu.c b/common/cmd_dfu.c
index 01d6b3a..327c738 100644
--- a/common/cmd_dfu.c
+++ b/common/cmd_dfu.c
@@ -55,7 +55,10 @@ static int do_dfu(cmd_tbl_t *cmdtp, int flag, int argc, char 
* const argv[])
goto done;
}
 
+#ifdef CONFIG_TRATS
board_usb_init();
+#endif
+
g_dnl_register(s);
while (1) {
if (ctrlc())
-- 
1.7.12

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


[U-Boot] [PATCH 6/9] dfu: Send correct DFU response from composite_setup

2012-11-30 Thread Pantelis Antoniou
DFU is a bit peculiar. It needs to hook to composite setup and
return it's function descriptor.

So when get-descriptor request comes with a type of DFU_DT_FUNC
we iterate over the configs, and functions, and when we find
the DFU function we call the setup method which is prepared
to return the appropriate function descriptor.

Signed-off-by: Pantelis Antoniou 
---
 drivers/usb/gadget/composite.c | 27 +++
 drivers/usb/gadget/ep0.c   |  1 +
 drivers/usb/gadget/f_dfu.c |  6 --
 3 files changed, 32 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/gadget/composite.c b/drivers/usb/gadget/composite.c
index ebb5131..6496436 100644
--- a/drivers/usb/gadget/composite.c
+++ b/drivers/usb/gadget/composite.c
@@ -773,6 +773,33 @@ composite_setup(struct usb_gadget *gadget, const struct 
usb_ctrlrequest *ctrl)
if (value >= 0)
value = min(w_length, (u16) value);
break;
+
+#ifdef CONFIG_DFU_FUNCTION
+   /* DFU is mighty weird */
+   case DFU_DT_FUNC:
+   w_value &= 0xff;
+   list_for_each_entry(c, &cdev->configs, list) {
+   if (w_value != 0) {
+   w_value--;
+   continue;
+   }
+
+   list_for_each_entry(f, &c->functions, list) {
+
+   /* DFU function only */
+   if (strcmp(f->name, "dfu") != 0)
+   continue;
+
+   value = f->setup(f, ctrl);
+   goto dfu_func_done;
+   }
+   }
+dfu_func_done:
+   if (value >= 0)
+   value = min(w_length, (u16) value);
+   break;
+#endif
+
default:
goto unknown;
}
diff --git a/drivers/usb/gadget/ep0.c b/drivers/usb/gadget/ep0.c
index aa8f916..971d846 100644
--- a/drivers/usb/gadget/ep0.c
+++ b/drivers/usb/gadget/ep0.c
@@ -221,6 +221,7 @@ static int ep0_get_descriptor (struct usb_device_instance 
*device,
break;
 
case USB_DESCRIPTOR_TYPE_CONFIGURATION:
+   case USB_DESCRIPTOR_TYPE_OTHER_SPEED_CONFIGURATION:
{
struct usb_configuration_descriptor
*configuration_descriptor;
diff --git a/drivers/usb/gadget/f_dfu.c b/drivers/usb/gadget/f_dfu.c
index 10547e3..6494f5e 100644
--- a/drivers/usb/gadget/f_dfu.c
+++ b/drivers/usb/gadget/f_dfu.c
@@ -534,8 +534,10 @@ dfu_handle(struct usb_function *f, const struct 
usb_ctrlrequest *ctrl)
value = min(len, (u16) sizeof(dfu_func));
memcpy(req->buf, &dfu_func, value);
}
-   } else /* DFU specific request */
-   value = dfu_state[f_dfu->dfu_state] (f_dfu, ctrl, gadget, req);
+   return value;
+   }
+
+   value = dfu_state[f_dfu->dfu_state] (f_dfu, ctrl, gadget, req);
 
if (value >= 0) {
req->length = value;
-- 
1.7.12

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


[U-Boot] [PATCH 5/9] dfu: Fix crash when wrong number of arguments given

2012-11-30 Thread Pantelis Antoniou
Fix obvious crash when not enough arguments are given to the dfu
command.

Signed-off-by: Pantelis Antoniou 
---
 common/cmd_dfu.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/common/cmd_dfu.c b/common/cmd_dfu.c
index 327c738..83ef324 100644
--- a/common/cmd_dfu.c
+++ b/common/cmd_dfu.c
@@ -50,7 +50,7 @@ static int do_dfu(cmd_tbl_t *cmdtp, int flag, int argc, char 
* const argv[])
if (ret)
return CMD_RET_FAILURE;
 
-   if (strcmp(argv[3], "list") == 0) {
+   if (argc > 3 && strcmp(argv[3], "list") == 0) {
dfu_show_entities();
goto done;
}
-- 
1.7.12

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


[U-Boot] [PATCH 7/9] dfu: Properly zero out timeout value

2012-11-30 Thread Pantelis Antoniou
Zero out timeout value; letting it filled with undefined values
ends up with the dfu host hanging.

Signed-off-by: Pantelis Antoniou 
---
 drivers/usb/gadget/f_dfu.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/usb/gadget/f_dfu.c b/drivers/usb/gadget/f_dfu.c
index 6494f5e..c15585c 100644
--- a/drivers/usb/gadget/f_dfu.c
+++ b/drivers/usb/gadget/f_dfu.c
@@ -164,6 +164,9 @@ static void handle_getstatus(struct usb_request *req)
 
/* send status response */
dstat->bStatus = f_dfu->dfu_status;
+   dstat->bwPollTimeout[0] = 0;
+   dstat->bwPollTimeout[1] = 0;
+   dstat->bwPollTimeout[2] = 0;
dstat->bState = f_dfu->dfu_state;
dstat->iString = 0;
 }
-- 
1.7.12

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


[U-Boot] [PATCH 8/9] dfu: Add a partition type target

2012-11-30 Thread Pantelis Antoniou
Dealing with raw block numbers with the dfu is very annoying.
Introduce a partition method.

Signed-off-by: Pantelis Antoniou 
---
 drivers/dfu/dfu_mmc.c | 31 +++
 1 file changed, 31 insertions(+)

diff --git a/drivers/dfu/dfu_mmc.c b/drivers/dfu/dfu_mmc.c
index 5d504df..083d745 100644
--- a/drivers/dfu/dfu_mmc.c
+++ b/drivers/dfu/dfu_mmc.c
@@ -21,6 +21,7 @@
 
 #include 
 #include 
+#include 
 #include 
 
 enum dfu_mmc_op {
@@ -153,6 +154,10 @@ int dfu_read_medium_mmc(struct dfu_entity *dfu, void *buf, 
long *len)
 
 int dfu_fill_entity_mmc(struct dfu_entity *dfu, char *s)
 {
+   int dev, part;
+   struct mmc *mmc;
+   block_dev_desc_t *blk_dev;
+   disk_partition_t partinfo;
char *st;
 
dfu->dev_type = DFU_DEV_MMC;
@@ -166,8 +171,34 @@ int dfu_fill_entity_mmc(struct dfu_entity *dfu, char *s)
dfu->layout = DFU_FS_FAT;
} else if (!strcmp(st, "ext4")) {
dfu->layout = DFU_FS_EXT4;
+   } else if (!strcmp(st, "part")) {
+
+   dfu->layout = DFU_RAW_ADDR;
+
+   dev = simple_strtoul(s, &s, 10);
+   s++;
+   part = simple_strtoul(s, &s, 10);
+
+   mmc = find_mmc_device(dev);
+   if (mmc == NULL || mmc_init(mmc)) {
+   printf("%s: could not find mmc device #%d!\n", 
__func__, dev);
+   return -ENODEV;
+   }
+
+   blk_dev = &mmc->block_dev;
+   if (get_partition_info(blk_dev, part, &partinfo) != 0) {
+   printf("%s: could not find partition #%d on mmc device 
#%d!\n",
+   __func__, part, dev);
+   return -ENODEV;
+   }
+
+   dfu->data.mmc.lba_start = partinfo.start;
+   dfu->data.mmc.lba_size = partinfo.size;
+   dfu->data.mmc.lba_blk_size = partinfo.blksz;
+
} else {
printf("%s: Memory layout (%s) not supported!\n", __func__, st);
+   return -ENODEV;
}
 
if (dfu->layout == DFU_FS_EXT4 || dfu->layout == DFU_FS_FAT) {
-- 
1.7.12

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


[U-Boot] [PATCH 9/9] dfu: Support larger than memory transfers.

2012-11-30 Thread Pantelis Antoniou
We didn't support upload/download larger than available memory.
This is pretty bad when you have to update your root filesystem for
example.

This patch removes the limitation (and the crashes when you transfered
any file larger than 4MB).
On top of that reduces the huge dfu buffer from 4MB to just 64K, which
was over the top.

The sequence number is a 16 bit counter; make sure we
handle rollover correctly. This fixes the wrong transfers for
large (> 256MB) images.

Also utilize a variable to handle initialization, so that we
don't rely on just the counter sent by the host.

Signed-off-by: Pantelis Antoniou 
---
 drivers/dfu/dfu.c | 244 +++---
 drivers/dfu/dfu_mmc.c |  82 +++--
 include/dfu.h |  21 -
 3 files changed, 264 insertions(+), 83 deletions(-)

diff --git a/drivers/dfu/dfu.c b/drivers/dfu/dfu.c
index e8477fb..fb9b417 100644
--- a/drivers/dfu/dfu.c
+++ b/drivers/dfu/dfu.c
@@ -44,90 +44,228 @@ static int dfu_find_alt_num(const char *s)
 static unsigned char __aligned(CONFIG_SYS_CACHELINE_SIZE)
 dfu_buf[DFU_DATA_BUF_SIZE];
 
+static int dfu_write_buffer_flush(struct dfu_entity *dfu)
+{
+   long w_size;
+   int ret;
+
+   /* flush size? */
+   w_size = dfu->i_buf - dfu->i_buf_start;
+   if (w_size == 0)
+   return 0;
+
+   /* update CRC32 */
+   dfu->crc = crc32(dfu->crc, dfu->i_buf_start, w_size);
+
+   ret = dfu->write_medium(dfu, dfu->offset, dfu->i_buf_start, &w_size);
+   if (ret)
+   debug("%s: Write error!\n", __func__);
+
+   /* point back */
+   dfu->i_buf = dfu->i_buf_start;
+
+   /* update offset */
+   dfu->offset += w_size;
+
+   puts("#");
+
+   return ret;
+}
+
 int dfu_write(struct dfu_entity *dfu, void *buf, int size, int blk_seq_num)
 {
-   static unsigned char *i_buf;
-   static int i_blk_seq_num;
-   long w_size = 0;
int ret = 0;
+   int tret;
+
+   debug("%s: name: %s buf: 0x%p size: 0x%x p_num: 0x%x "
+   "offset: 0x%llx bufoffset: 0x%x\n",
+  __func__, dfu->name, buf, size, blk_seq_num, dfu->offset,
+  dfu->i_buf - dfu->i_buf_start);
+
+   if (!dfu->inited) {
+   /* initial state */
+   dfu->crc = 0;
+   dfu->offset = 0;
+   dfu->i_blk_seq_num = 0;
+   dfu->i_buf_start = dfu_buf;
+   dfu->i_buf_end = dfu_buf + sizeof(dfu_buf);
+   dfu->i_buf = dfu->i_buf_start;
+
+   dfu->inited = 1;
+   }
 
-   debug("%s: name: %s buf: 0x%p size: 0x%x p_num: 0x%x i_buf: 0x%p\n",
-  __func__, dfu->name, buf, size, blk_seq_num, i_buf);
+   if (dfu->i_blk_seq_num != blk_seq_num) {
+   printf("%s: Wrong sequence number! [%d] [%d]\n",
+  __func__, dfu->i_blk_seq_num, blk_seq_num);
+   return -1;
+   }
 
-   if (blk_seq_num == 0) {
-   i_buf = dfu_buf;
-   i_blk_seq_num = 0;
+   /* DFU 1.1 standard says:
+* The wBlockNum field is a block sequence number. It increments each
+* time a block is transferred, wrapping to zero from 65,535. It is used
+* to provide useful context to the DFU loader in the device."
+*
+* This means that it's a 16 bit counter that roll-overs at
+* 0x -> 0x. By having a typical 4K transfer block
+* we roll-over at exactly 256MB. Not very fun to debug.
+*
+* Handling rollover, and having an inited variable,
+* makes things work.
+*/
+
+   /* handle rollover */
+   dfu->i_blk_seq_num = (dfu->i_blk_seq_num + 1) & 0x;
+
+   /* flush buffer if overflow */
+   if ((dfu->i_buf + size) > dfu->i_buf_end) {
+   tret = dfu_write_buffer_flush(dfu);
+   if (ret == 0)
+   ret = tret;
}
 
-   if (i_blk_seq_num++ != blk_seq_num) {
-   printf("%s: Wrong sequence number! [%d] [%d]\n",
-  __func__, i_blk_seq_num, blk_seq_num);
+   /* we should be in buffer now (if not then size too large) */
+   if ((dfu->i_buf + size) > dfu->i_buf_end) {
+   printf("%s: Wrong size! [%d] [%d] - %d\n",
+  __func__, dfu->i_blk_seq_num, blk_seq_num, size);
return -1;
}
 
-   memcpy(i_buf, buf, size);
-   i_buf += size;
+   memcpy(dfu->i_buf, buf, size);
+   dfu->i_buf += size;
 
+   /* if end or if buffer full flush */
+   if (size == 0 || (dfu->i_buf + size) > dfu->i_buf_end) {
+   tret = dfu_write_buffer_flush(dfu);
+   if (ret == 0)
+   ret = tret;
+   }
+
+   /* end? */
if (size == 0) {
-   /* Integrity check (if needed) */
-   debug("%s: %s %d [B] CRC32: 0x%x\n", __func__, dfu->name,

Re: [U-Boot] [PATCH 4/9] dfu: Only perform DFU board_usb_init() for TRATS

2012-11-30 Thread Lukasz Majewski
Hi Pantelis,


One request:

Please stick to following guidelines:
http://www.denx.de/wiki/U-Boot/Patches


> USB initialization shouldn't happen for all the boards.
> 
> Signed-off-by: Pantelis Antoniou 
> ---
>  common/cmd_dfu.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/common/cmd_dfu.c b/common/cmd_dfu.c
> index 01d6b3a..327c738 100644
> --- a/common/cmd_dfu.c
> +++ b/common/cmd_dfu.c
> @@ -55,7 +55,10 @@ static int do_dfu(cmd_tbl_t *cmdtp, int flag, int
> argc, char * const argv[]) goto done;
>   }
>  
> +#ifdef CONFIG_TRATS
>   board_usb_init();
> +#endif
> +

This is under discussion with Tom.

>   g_dnl_register(s);
>   while (1) {
>   if (ctrlc())



-- 
Best regards,

Lukasz Majewski

Samsung Poland R&D Center | Linux Platform Group
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH] mxs: Staticize SPL functions

2012-11-30 Thread Marek Vasut
The MXS SPL didn't mark local functions "static". Fix it. This also makes the
SPL smaller by roughly 300 bytes.

Signed-off-by: Marek Vasut 
Cc: Stefano Babic 
Cc: Fabio Estevam 
---
 arch/arm/cpu/arm926ejs/mxs/spl_boot.c   |4 +-
 arch/arm/cpu/arm926ejs/mxs/spl_mem_init.c   |8 ++--
 arch/arm/cpu/arm926ejs/mxs/spl_power_init.c |   56 +--
 3 files changed, 34 insertions(+), 34 deletions(-)

diff --git a/arch/arm/cpu/arm926ejs/mxs/spl_boot.c 
b/arch/arm/cpu/arm926ejs/mxs/spl_boot.c
index 864ce9f..c38fd39 100644
--- a/arch/arm/cpu/arm926ejs/mxs/spl_boot.c
+++ b/arch/arm/cpu/arm926ejs/mxs/spl_boot.c
@@ -50,7 +50,7 @@ void early_delay(int delay)
 }
 
 #defineMUX_CONFIG_BOOTMODE_PAD (MXS_PAD_3V3 | MXS_PAD_4MA | 
MXS_PAD_NOPULL)
-const iomux_cfg_t iomux_boot[] = {
+static const iomux_cfg_t iomux_boot[] = {
MX28_PAD_LCD_D00__GPIO_1_0 | MUX_CONFIG_BOOTMODE_PAD,
MX28_PAD_LCD_D01__GPIO_1_1 | MUX_CONFIG_BOOTMODE_PAD,
MX28_PAD_LCD_D02__GPIO_1_2 | MUX_CONFIG_BOOTMODE_PAD,
@@ -59,7 +59,7 @@ const iomux_cfg_t iomux_boot[] = {
MX28_PAD_LCD_D05__GPIO_1_5 | MUX_CONFIG_BOOTMODE_PAD,
 };
 
-uint8_t mxs_get_bootmode_index(void)
+static uint8_t mxs_get_bootmode_index(void)
 {
uint8_t bootmode = 0;
int i;
diff --git a/arch/arm/cpu/arm926ejs/mxs/spl_mem_init.c 
b/arch/arm/cpu/arm926ejs/mxs/spl_mem_init.c
index 8904e24..8c7f34a 100644
--- a/arch/arm/cpu/arm926ejs/mxs/spl_mem_init.c
+++ b/arch/arm/cpu/arm926ejs/mxs/spl_mem_init.c
@@ -87,7 +87,7 @@ void __mxs_adjust_memory_params(uint32_t *dram_vals)
 void mxs_adjust_memory_params(uint32_t *dram_vals)
__attribute__((weak, alias("__mxs_adjust_memory_params")));
 
-void init_mx28_200mhz_ddr2(void)
+static void init_mx28_200mhz_ddr2(void)
 {
int i;
 
@@ -97,7 +97,7 @@ void init_mx28_200mhz_ddr2(void)
writel(mx28_dram_vals[i], MXS_DRAM_BASE + (4 * i));
 }
 
-void mxs_mem_init_clock(void)
+static void mxs_mem_init_clock(void)
 {
struct mxs_clkctrl_regs *clkctrl_regs =
(struct mxs_clkctrl_regs *)MXS_CLKCTRL_BASE;
@@ -128,7 +128,7 @@ void mxs_mem_init_clock(void)
early_delay(1);
 }
 
-void mxs_mem_setup_cpu_and_hbus(void)
+static void mxs_mem_setup_cpu_and_hbus(void)
 {
struct mxs_clkctrl_regs *clkctrl_regs =
(struct mxs_clkctrl_regs *)MXS_CLKCTRL_BASE;
@@ -160,7 +160,7 @@ void mxs_mem_setup_cpu_and_hbus(void)
early_delay(15000);
 }
 
-void mxs_mem_setup_vdda(void)
+static void mxs_mem_setup_vdda(void)
 {
struct mxs_power_regs *power_regs =
(struct mxs_power_regs *)MXS_POWER_BASE;
diff --git a/arch/arm/cpu/arm926ejs/mxs/spl_power_init.c 
b/arch/arm/cpu/arm926ejs/mxs/spl_power_init.c
index 2bc6ad1..be44c22 100644
--- a/arch/arm/cpu/arm926ejs/mxs/spl_power_init.c
+++ b/arch/arm/cpu/arm926ejs/mxs/spl_power_init.c
@@ -30,7 +30,7 @@
 
 #include "mxs_init.h"
 
-void mxs_power_clock2xtal(void)
+static void mxs_power_clock2xtal(void)
 {
struct mxs_clkctrl_regs *clkctrl_regs =
(struct mxs_clkctrl_regs *)MXS_CLKCTRL_BASE;
@@ -40,7 +40,7 @@ void mxs_power_clock2xtal(void)
&clkctrl_regs->hw_clkctrl_clkseq_set);
 }
 
-void mxs_power_clock2pll(void)
+static void mxs_power_clock2pll(void)
 {
struct mxs_clkctrl_regs *clkctrl_regs =
(struct mxs_clkctrl_regs *)MXS_CLKCTRL_BASE;
@@ -52,7 +52,7 @@ void mxs_power_clock2pll(void)
CLKCTRL_CLKSEQ_BYPASS_CPU);
 }
 
-void mxs_power_clear_auto_restart(void)
+static void mxs_power_clear_auto_restart(void)
 {
struct mxs_rtc_regs *rtc_regs =
(struct mxs_rtc_regs *)MXS_RTC_BASE;
@@ -85,7 +85,7 @@ void mxs_power_clear_auto_restart(void)
;
 }
 
-void mxs_power_set_linreg(void)
+static void mxs_power_set_linreg(void)
 {
struct mxs_power_regs *power_regs =
(struct mxs_power_regs *)MXS_POWER_BASE;
@@ -104,7 +104,7 @@ void mxs_power_set_linreg(void)
POWER_VDDIOCTRL_LINREG_OFFSET_1STEPS_BELOW);
 }
 
-int mxs_get_batt_volt(void)
+static int mxs_get_batt_volt(void)
 {
struct mxs_power_regs *power_regs =
(struct mxs_power_regs *)MXS_POWER_BASE;
@@ -115,12 +115,12 @@ int mxs_get_batt_volt(void)
return volt;
 }
 
-int mxs_is_batt_ready(void)
+static int mxs_is_batt_ready(void)
 {
return (mxs_get_batt_volt() >= 3600);
 }
 
-int mxs_is_batt_good(void)
+static int mxs_is_batt_good(void)
 {
struct mxs_power_regs *power_regs =
(struct mxs_power_regs *)MXS_POWER_BASE;
@@ -160,7 +160,7 @@ int mxs_is_batt_good(void)
return 0;
 }
 
-void mxs_power_setup_5v_detect(void)
+static void mxs_power_setup_5v_detect(void)
 {
struct mxs_power_regs *power_regs =
(struct mxs_power_regs *)MXS_POWER_BASE;
@@ -172,7 +172,7 @@ void mxs_power_setup_5v_detect(void)
POWER_5VCTRL_PWRUP_VBUS_CMPS);
 }
 
-void m

Re: [U-Boot] [PATCH 5/9] dfu: Fix crash when wrong number of arguments given

2012-11-30 Thread Lukasz Majewski
Hi Pantelis,

> Fix obvious crash when not enough arguments are given to the dfu
> command.
> 
> Signed-off-by: Pantelis Antoniou 
> ---
>  common/cmd_dfu.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/common/cmd_dfu.c b/common/cmd_dfu.c
> index 327c738..83ef324 100644
> --- a/common/cmd_dfu.c
> +++ b/common/cmd_dfu.c
> @@ -50,7 +50,7 @@ static int do_dfu(cmd_tbl_t *cmdtp, int flag, int
> argc, char * const argv[]) if (ret)
>   return CMD_RET_FAILURE;
>  
> - if (strcmp(argv[3], "list") == 0) {
> + if (argc > 3 && strcmp(argv[3], "list") == 0) {
>   dfu_show_entities();
>   goto done;
>   }

Why do you don't include changelog for your patches?

This is already v3, and I had comment to this patch in v2.
Unfortunately with no feedback from your side.

-- 
Best regards,

Lukasz Majewski

Samsung Poland R&D Center | Linux Platform Group
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH v3 0/9] USB: Gadget & DFU related fixes

2012-11-30 Thread Pantelis Antoniou
Third take of USB + DFU updates.

Changelog for the pendants:

changes from v2:
* Handle large transfers properly take #2
* Different method of avoid double linking of 
  usb gadget & usb ether.

changes from v1:
* Properly terminate terminate string list.
* Handle large transfers properly take #1

Pantelis Antoniou (9):
  usb: Fix bug when both DFU & ETHER are defined
  g_dnl: Issue connect/disconnect as appropriate
  g_dnl: Properly terminate string list.
  dfu: Only perform DFU board_usb_init() for TRATS
  dfu: Fix crash when wrong number of arguments given
  dfu: Send correct DFU response from composite_setup
  dfu: Properly zero out timeout value
  dfu: Add a partition type target
  dfu: Support larger than memory transfers.

 common/cmd_dfu.c|   5 +-
 drivers/dfu/dfu.c   | 244 
 drivers/dfu/dfu_mmc.c   | 109 
 drivers/usb/gadget/Makefile |   8 +-
 drivers/usb/gadget/composite.c  |  27 
 drivers/usb/gadget/ep0.c|   1 +
 drivers/usb/gadget/f_dfu.c  |   9 +-
 drivers/usb/gadget/g_dnl.c  |  12 +-
 include/configs/am335x_evm.h|   1 +
 include/configs/am3517_evm.h|   1 +
 include/configs/h2200.h |   1 +
 include/configs/omap3_beagle.h  |   1 +
 include/configs/s5p_goni.h  |   1 +
 include/configs/s5pc210_universal.h |   1 +
 include/configs/trats.h |   1 +
 include/dfu.h   |  21 +++-
 16 files changed, 356 insertions(+), 87 deletions(-)

-- 
1.7.12

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


[U-Boot] [PATCH v3 2/9] g_dnl: Issue connect/disconnect as appropriate

2012-11-30 Thread Pantelis Antoniou
Call usb_gadget_connect/usb_gadget_disconnect in g_dnl_bind/g_dnl_unbind.

Signed-off-by: Pantelis Antoniou 
---
 drivers/usb/gadget/g_dnl.c | 11 ++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/gadget/g_dnl.c b/drivers/usb/gadget/g_dnl.c
index 7d87050..25da733 100644
--- a/drivers/usb/gadget/g_dnl.c
+++ b/drivers/usb/gadget/g_dnl.c
@@ -83,7 +83,12 @@ static struct usb_gadget_strings *g_dnl_composite_strings[] 
= {
 
 static int g_dnl_unbind(struct usb_composite_dev *cdev)
 {
-   debug("%s\n", __func__);
+   struct usb_gadget *gadget = cdev->gadget;
+
+   debug("%s: calling usb_gadget_disconnect for "
+   "controller '%s'\n", shortname, gadget->name);
+   usb_gadget_disconnect(gadget);
+
return 0;
 }
 
@@ -153,6 +158,10 @@ static int g_dnl_bind(struct usb_composite_dev *cdev)
device_desc.bcdDevice = __constant_cpu_to_le16(0x);
}
 
+   debug("%s: calling usb_gadget_connect for "
+   "controller '%s'\n", shortname, gadget->name);
+   usb_gadget_connect(gadget);
+
return 0;
 
  error:
-- 
1.7.12

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


[U-Boot] [PATCH v3 1/9] usb: Fix bug when both DFU & ETHER are defined

2012-11-30 Thread Pantelis Antoniou
When both CONFIG_USB_GADGET & CONFIG_USB_ETHER are defined
the makefile links objects twice.

The cleanest way to fix is to use a new define, CONFIG_USB_UTIL
which must be defined when either CONFIG_USB_ETHER or
CONFIG_USB_GADGET are defined.

All affected boards have been modified as well.

Signed-off-by: Pantelis Antoniou 
---
 drivers/usb/gadget/Makefile | 8 ++--
 include/configs/am335x_evm.h| 1 +
 include/configs/am3517_evm.h| 1 +
 include/configs/h2200.h | 1 +
 include/configs/omap3_beagle.h  | 1 +
 include/configs/s5p_goni.h  | 1 +
 include/configs/s5pc210_universal.h | 1 +
 include/configs/trats.h | 1 +
 8 files changed, 13 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/gadget/Makefile b/drivers/usb/gadget/Makefile
index 040eaba..167f24f 100644
--- a/drivers/usb/gadget/Makefile
+++ b/drivers/usb/gadget/Makefile
@@ -25,15 +25,19 @@ include $(TOPDIR)/config.mk
 
 LIB:= $(obj)libusb_gadget.o
 
+# required for both USB_GADGET & USB_ETHER
+ifdef CONFIG_USB_UTIL
+COBJS-y += epautoconf.o config.o usbstring.o
+endif
+
 # new USB gadget layer dependencies
 ifdef CONFIG_USB_GADGET
-COBJS-y += epautoconf.o config.o usbstring.o
 COBJS-$(CONFIG_USB_GADGET_S3C_UDC_OTG) += s3c_udc_otg.o
 COBJS-$(CONFIG_USBDOWNLOAD_GADGET) += g_dnl.o
 COBJS-$(CONFIG_DFU_FUNCTION) += f_dfu.o
 endif
 ifdef CONFIG_USB_ETHER
-COBJS-y += ether.o epautoconf.o config.o usbstring.o
+COBJS-y += ether.o
 COBJS-$(CONFIG_USB_ETH_RNDIS) += rndis.o
 COBJS-$(CONFIG_MV_UDC) += mv_udc.o
 COBJS-$(CONFIG_CPU_PXA25X) += pxa25x_udc.o
diff --git a/include/configs/am335x_evm.h b/include/configs/am335x_evm.h
index ab9549b..ee19e54 100644
--- a/include/configs/am335x_evm.h
+++ b/include/configs/am335x_evm.h
@@ -278,6 +278,7 @@
 
 #ifdef CONFIG_MUSB_GADGET
 #define CONFIG_USB_ETHER
+#define CONFIG_USB_UTIL
 #define CONFIG_USB_ETH_RNDIS
 #endif /* CONFIG_MUSB_GADGET */
 
diff --git a/include/configs/am3517_evm.h b/include/configs/am3517_evm.h
index ba15325..3aedff3 100644
--- a/include/configs/am3517_evm.h
+++ b/include/configs/am3517_evm.h
@@ -123,6 +123,7 @@
 #ifdef CONFIG_MUSB_GADGET
 #define CONFIG_USB_GADGET_DUALSPEED
 #define CONFIG_USB_ETHER
+#define CONFIG_USB_UTIL
 #define CONFIG_USB_ETH_RNDIS
 #endif /* CONFIG_MUSB_GADGET */
 
diff --git a/include/configs/h2200.h b/include/configs/h2200.h
index 516a26e..fc27bf0 100644
--- a/include/configs/h2200.h
+++ b/include/configs/h2200.h
@@ -170,6 +170,7 @@
 
 #define CONFIG_USB_GADGET_PXA2XX
 #define CONFIG_USB_ETHER
+#define CONFIG_USB_UTIL
 #define CONFIG_USB_ETH_SUBSET
 
 #define CONFIG_USBNET_DEV_ADDR "de:ad:be:ef:00:01"
diff --git a/include/configs/omap3_beagle.h b/include/configs/omap3_beagle.h
index 12d65f2..04fbb5d 100644
--- a/include/configs/omap3_beagle.h
+++ b/include/configs/omap3_beagle.h
@@ -123,6 +123,7 @@
 #define CONFIG_USB_GADGET_DUALSPEED
 #define CONFIG_TWL4030_USB 1
 #define CONFIG_USB_ETHER
+#define CONFIG_USB_UTIL
 #define CONFIG_USB_ETHER_RNDIS
 
 /* USB EHCI */
diff --git a/include/configs/s5p_goni.h b/include/configs/s5p_goni.h
index 56e8347..1e180ade 100644
--- a/include/configs/s5p_goni.h
+++ b/include/configs/s5p_goni.h
@@ -231,6 +231,7 @@
 #define CONFIG_I2C_MULTI_BUS
 #define CONFIG_SYS_MAX_I2C_BUS 7
 #define CONFIG_USB_GADGET
+#define CONFIG_USB_UTIL
 #define CONFIG_USB_GADGET_S3C_UDC_OTG
 #define CONFIG_USB_GADGET_DUALSPEED
 
diff --git a/include/configs/s5pc210_universal.h 
b/include/configs/s5pc210_universal.h
index 894f38b..07ab884 100644
--- a/include/configs/s5pc210_universal.h
+++ b/include/configs/s5pc210_universal.h
@@ -258,6 +258,7 @@
 #define CONFIG_POWER_MAX8998
 
 #define CONFIG_USB_GADGET
+#define CONFIG_USB_UTIL
 #define CONFIG_USB_GADGET_S3C_UDC_OTG
 #define CONFIG_USB_GADGET_DUALSPEED
 
diff --git a/include/configs/trats.h b/include/configs/trats.h
index 355029e..7c2c875 100644
--- a/include/configs/trats.h
+++ b/include/configs/trats.h
@@ -245,6 +245,7 @@
 #define CONFIG_POWER_BATTERY
 #define CONFIG_POWER_BATTERY_TRATS
 #define CONFIG_USB_GADGET
+#define CONFIG_USB_UTIL
 #define CONFIG_USB_GADGET_S3C_UDC_OTG
 #define CONFIG_USB_GADGET_DUALSPEED
 #define CONFIG_USB_GADGET_VBUS_DRAW2
-- 
1.7.12

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


[U-Boot] [PATCH v3 3/9] g_dnl: Properly terminate string list.

2012-11-30 Thread Pantelis Antoniou
Well, not terminating the list causes very interesting crashes.
As in changing the vendor & product ID crashes. Fun.

Signed-off-by: Pantelis Antoniou 
---
 drivers/usb/gadget/g_dnl.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/usb/gadget/g_dnl.c b/drivers/usb/gadget/g_dnl.c
index 25da733..a5a4c1f 100644
--- a/drivers/usb/gadget/g_dnl.c
+++ b/drivers/usb/gadget/g_dnl.c
@@ -69,6 +69,7 @@ static struct usb_device_descriptor device_desc = {
 static struct usb_string g_dnl_string_defs[] = {
{ 0, manufacturer, },
{ 1, product, },
+   {  }/* end of list */
 };
 
 static struct usb_gadget_strings g_dnl_string_tab = {
-- 
1.7.12

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


[U-Boot] [PATCH v3 4/9] dfu: Only perform DFU board_usb_init() for TRATS

2012-11-30 Thread Pantelis Antoniou
USB initialization shouldn't happen for all the boards.

Signed-off-by: Pantelis Antoniou 
---
 common/cmd_dfu.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/common/cmd_dfu.c b/common/cmd_dfu.c
index 01d6b3a..327c738 100644
--- a/common/cmd_dfu.c
+++ b/common/cmd_dfu.c
@@ -55,7 +55,10 @@ static int do_dfu(cmd_tbl_t *cmdtp, int flag, int argc, char 
* const argv[])
goto done;
}
 
+#ifdef CONFIG_TRATS
board_usb_init();
+#endif
+
g_dnl_register(s);
while (1) {
if (ctrlc())
-- 
1.7.12

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


[U-Boot] [PATCH v3 6/9] dfu: Send correct DFU response from composite_setup

2012-11-30 Thread Pantelis Antoniou
DFU is a bit peculiar. It needs to hook to composite setup and
return it's function descriptor.

So when get-descriptor request comes with a type of DFU_DT_FUNC
we iterate over the configs, and functions, and when we find
the DFU function we call the setup method which is prepared
to return the appropriate function descriptor.

Signed-off-by: Pantelis Antoniou 
---
 drivers/usb/gadget/composite.c | 27 +++
 drivers/usb/gadget/ep0.c   |  1 +
 drivers/usb/gadget/f_dfu.c |  6 --
 3 files changed, 32 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/gadget/composite.c b/drivers/usb/gadget/composite.c
index ebb5131..6496436 100644
--- a/drivers/usb/gadget/composite.c
+++ b/drivers/usb/gadget/composite.c
@@ -773,6 +773,33 @@ composite_setup(struct usb_gadget *gadget, const struct 
usb_ctrlrequest *ctrl)
if (value >= 0)
value = min(w_length, (u16) value);
break;
+
+#ifdef CONFIG_DFU_FUNCTION
+   /* DFU is mighty weird */
+   case DFU_DT_FUNC:
+   w_value &= 0xff;
+   list_for_each_entry(c, &cdev->configs, list) {
+   if (w_value != 0) {
+   w_value--;
+   continue;
+   }
+
+   list_for_each_entry(f, &c->functions, list) {
+
+   /* DFU function only */
+   if (strcmp(f->name, "dfu") != 0)
+   continue;
+
+   value = f->setup(f, ctrl);
+   goto dfu_func_done;
+   }
+   }
+dfu_func_done:
+   if (value >= 0)
+   value = min(w_length, (u16) value);
+   break;
+#endif
+
default:
goto unknown;
}
diff --git a/drivers/usb/gadget/ep0.c b/drivers/usb/gadget/ep0.c
index aa8f916..971d846 100644
--- a/drivers/usb/gadget/ep0.c
+++ b/drivers/usb/gadget/ep0.c
@@ -221,6 +221,7 @@ static int ep0_get_descriptor (struct usb_device_instance 
*device,
break;
 
case USB_DESCRIPTOR_TYPE_CONFIGURATION:
+   case USB_DESCRIPTOR_TYPE_OTHER_SPEED_CONFIGURATION:
{
struct usb_configuration_descriptor
*configuration_descriptor;
diff --git a/drivers/usb/gadget/f_dfu.c b/drivers/usb/gadget/f_dfu.c
index 10547e3..6494f5e 100644
--- a/drivers/usb/gadget/f_dfu.c
+++ b/drivers/usb/gadget/f_dfu.c
@@ -534,8 +534,10 @@ dfu_handle(struct usb_function *f, const struct 
usb_ctrlrequest *ctrl)
value = min(len, (u16) sizeof(dfu_func));
memcpy(req->buf, &dfu_func, value);
}
-   } else /* DFU specific request */
-   value = dfu_state[f_dfu->dfu_state] (f_dfu, ctrl, gadget, req);
+   return value;
+   }
+
+   value = dfu_state[f_dfu->dfu_state] (f_dfu, ctrl, gadget, req);
 
if (value >= 0) {
req->length = value;
-- 
1.7.12

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


[U-Boot] [PATCH v3 5/9] dfu: Fix crash when wrong number of arguments given

2012-11-30 Thread Pantelis Antoniou
Fix obvious crash when not enough arguments are given to the dfu
command.

Signed-off-by: Pantelis Antoniou 
---
 common/cmd_dfu.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/common/cmd_dfu.c b/common/cmd_dfu.c
index 327c738..83ef324 100644
--- a/common/cmd_dfu.c
+++ b/common/cmd_dfu.c
@@ -50,7 +50,7 @@ static int do_dfu(cmd_tbl_t *cmdtp, int flag, int argc, char 
* const argv[])
if (ret)
return CMD_RET_FAILURE;
 
-   if (strcmp(argv[3], "list") == 0) {
+   if (argc > 3 && strcmp(argv[3], "list") == 0) {
dfu_show_entities();
goto done;
}
-- 
1.7.12

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


[U-Boot] [PATCH v3 8/9] dfu: Add a partition type target

2012-11-30 Thread Pantelis Antoniou
Dealing with raw block numbers with the dfu is very annoying.
Introduce a partition method.

Signed-off-by: Pantelis Antoniou 
---
 drivers/dfu/dfu_mmc.c | 31 +++
 1 file changed, 31 insertions(+)

diff --git a/drivers/dfu/dfu_mmc.c b/drivers/dfu/dfu_mmc.c
index 5d504df..083d745 100644
--- a/drivers/dfu/dfu_mmc.c
+++ b/drivers/dfu/dfu_mmc.c
@@ -21,6 +21,7 @@
 
 #include 
 #include 
+#include 
 #include 
 
 enum dfu_mmc_op {
@@ -153,6 +154,10 @@ int dfu_read_medium_mmc(struct dfu_entity *dfu, void *buf, 
long *len)
 
 int dfu_fill_entity_mmc(struct dfu_entity *dfu, char *s)
 {
+   int dev, part;
+   struct mmc *mmc;
+   block_dev_desc_t *blk_dev;
+   disk_partition_t partinfo;
char *st;
 
dfu->dev_type = DFU_DEV_MMC;
@@ -166,8 +171,34 @@ int dfu_fill_entity_mmc(struct dfu_entity *dfu, char *s)
dfu->layout = DFU_FS_FAT;
} else if (!strcmp(st, "ext4")) {
dfu->layout = DFU_FS_EXT4;
+   } else if (!strcmp(st, "part")) {
+
+   dfu->layout = DFU_RAW_ADDR;
+
+   dev = simple_strtoul(s, &s, 10);
+   s++;
+   part = simple_strtoul(s, &s, 10);
+
+   mmc = find_mmc_device(dev);
+   if (mmc == NULL || mmc_init(mmc)) {
+   printf("%s: could not find mmc device #%d!\n", 
__func__, dev);
+   return -ENODEV;
+   }
+
+   blk_dev = &mmc->block_dev;
+   if (get_partition_info(blk_dev, part, &partinfo) != 0) {
+   printf("%s: could not find partition #%d on mmc device 
#%d!\n",
+   __func__, part, dev);
+   return -ENODEV;
+   }
+
+   dfu->data.mmc.lba_start = partinfo.start;
+   dfu->data.mmc.lba_size = partinfo.size;
+   dfu->data.mmc.lba_blk_size = partinfo.blksz;
+
} else {
printf("%s: Memory layout (%s) not supported!\n", __func__, st);
+   return -ENODEV;
}
 
if (dfu->layout == DFU_FS_EXT4 || dfu->layout == DFU_FS_FAT) {
-- 
1.7.12

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


[U-Boot] [PATCH v3 7/9] dfu: Properly zero out timeout value

2012-11-30 Thread Pantelis Antoniou
Zero out timeout value; letting it filled with undefined values
ends up with the dfu host hanging.

Signed-off-by: Pantelis Antoniou 
---
 drivers/usb/gadget/f_dfu.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/usb/gadget/f_dfu.c b/drivers/usb/gadget/f_dfu.c
index 6494f5e..c15585c 100644
--- a/drivers/usb/gadget/f_dfu.c
+++ b/drivers/usb/gadget/f_dfu.c
@@ -164,6 +164,9 @@ static void handle_getstatus(struct usb_request *req)
 
/* send status response */
dstat->bStatus = f_dfu->dfu_status;
+   dstat->bwPollTimeout[0] = 0;
+   dstat->bwPollTimeout[1] = 0;
+   dstat->bwPollTimeout[2] = 0;
dstat->bState = f_dfu->dfu_state;
dstat->iString = 0;
 }
-- 
1.7.12

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


[U-Boot] [PATCH v3 9/9] dfu: Support larger than memory transfers.

2012-11-30 Thread Pantelis Antoniou
We didn't support upload/download larger than available memory.
This is pretty bad when you have to update your root filesystem for
example.

This patch removes the limitation (and the crashes when you transfered
any file larger than 4MB).
On top of that reduces the huge dfu buffer from 4MB to just 64K, which
was over the top.

The sequence number is a 16 bit counter; make sure we
handle rollover correctly. This fixes the wrong transfers for
large (> 256MB) images.

Also utilize a variable to handle initialization, so that we
don't rely on just the counter sent by the host.

Signed-off-by: Pantelis Antoniou 
---
 drivers/dfu/dfu.c | 244 +++---
 drivers/dfu/dfu_mmc.c |  82 +++--
 include/dfu.h |  21 -
 3 files changed, 264 insertions(+), 83 deletions(-)

diff --git a/drivers/dfu/dfu.c b/drivers/dfu/dfu.c
index e8477fb..fb9b417 100644
--- a/drivers/dfu/dfu.c
+++ b/drivers/dfu/dfu.c
@@ -44,90 +44,228 @@ static int dfu_find_alt_num(const char *s)
 static unsigned char __aligned(CONFIG_SYS_CACHELINE_SIZE)
 dfu_buf[DFU_DATA_BUF_SIZE];
 
+static int dfu_write_buffer_flush(struct dfu_entity *dfu)
+{
+   long w_size;
+   int ret;
+
+   /* flush size? */
+   w_size = dfu->i_buf - dfu->i_buf_start;
+   if (w_size == 0)
+   return 0;
+
+   /* update CRC32 */
+   dfu->crc = crc32(dfu->crc, dfu->i_buf_start, w_size);
+
+   ret = dfu->write_medium(dfu, dfu->offset, dfu->i_buf_start, &w_size);
+   if (ret)
+   debug("%s: Write error!\n", __func__);
+
+   /* point back */
+   dfu->i_buf = dfu->i_buf_start;
+
+   /* update offset */
+   dfu->offset += w_size;
+
+   puts("#");
+
+   return ret;
+}
+
 int dfu_write(struct dfu_entity *dfu, void *buf, int size, int blk_seq_num)
 {
-   static unsigned char *i_buf;
-   static int i_blk_seq_num;
-   long w_size = 0;
int ret = 0;
+   int tret;
+
+   debug("%s: name: %s buf: 0x%p size: 0x%x p_num: 0x%x "
+   "offset: 0x%llx bufoffset: 0x%x\n",
+  __func__, dfu->name, buf, size, blk_seq_num, dfu->offset,
+  dfu->i_buf - dfu->i_buf_start);
+
+   if (!dfu->inited) {
+   /* initial state */
+   dfu->crc = 0;
+   dfu->offset = 0;
+   dfu->i_blk_seq_num = 0;
+   dfu->i_buf_start = dfu_buf;
+   dfu->i_buf_end = dfu_buf + sizeof(dfu_buf);
+   dfu->i_buf = dfu->i_buf_start;
+
+   dfu->inited = 1;
+   }
 
-   debug("%s: name: %s buf: 0x%p size: 0x%x p_num: 0x%x i_buf: 0x%p\n",
-  __func__, dfu->name, buf, size, blk_seq_num, i_buf);
+   if (dfu->i_blk_seq_num != blk_seq_num) {
+   printf("%s: Wrong sequence number! [%d] [%d]\n",
+  __func__, dfu->i_blk_seq_num, blk_seq_num);
+   return -1;
+   }
 
-   if (blk_seq_num == 0) {
-   i_buf = dfu_buf;
-   i_blk_seq_num = 0;
+   /* DFU 1.1 standard says:
+* The wBlockNum field is a block sequence number. It increments each
+* time a block is transferred, wrapping to zero from 65,535. It is used
+* to provide useful context to the DFU loader in the device."
+*
+* This means that it's a 16 bit counter that roll-overs at
+* 0x -> 0x. By having a typical 4K transfer block
+* we roll-over at exactly 256MB. Not very fun to debug.
+*
+* Handling rollover, and having an inited variable,
+* makes things work.
+*/
+
+   /* handle rollover */
+   dfu->i_blk_seq_num = (dfu->i_blk_seq_num + 1) & 0x;
+
+   /* flush buffer if overflow */
+   if ((dfu->i_buf + size) > dfu->i_buf_end) {
+   tret = dfu_write_buffer_flush(dfu);
+   if (ret == 0)
+   ret = tret;
}
 
-   if (i_blk_seq_num++ != blk_seq_num) {
-   printf("%s: Wrong sequence number! [%d] [%d]\n",
-  __func__, i_blk_seq_num, blk_seq_num);
+   /* we should be in buffer now (if not then size too large) */
+   if ((dfu->i_buf + size) > dfu->i_buf_end) {
+   printf("%s: Wrong size! [%d] [%d] - %d\n",
+  __func__, dfu->i_blk_seq_num, blk_seq_num, size);
return -1;
}
 
-   memcpy(i_buf, buf, size);
-   i_buf += size;
+   memcpy(dfu->i_buf, buf, size);
+   dfu->i_buf += size;
 
+   /* if end or if buffer full flush */
+   if (size == 0 || (dfu->i_buf + size) > dfu->i_buf_end) {
+   tret = dfu_write_buffer_flush(dfu);
+   if (ret == 0)
+   ret = tret;
+   }
+
+   /* end? */
if (size == 0) {
-   /* Integrity check (if needed) */
-   debug("%s: %s %d [B] CRC32: 0x%x\n", __func__, dfu->name,

Re: [U-Boot] [PATCH] mxs: Silence elftosb

2012-11-30 Thread Otavio Salvador
On Fri, Nov 30, 2012 at 11:04 AM, Marek Vasut  wrote:

> The elftosb tool is now called with -d switch, which produces debug
> output to the stdout. The debug output is completely useless for
> regular operation, so silence it.
>
> Signed-off-by: Marek Vasut 
> Cc: Stefano Babic 
> Cc: Fabio Estevam 
>

Acked-by: Otavio Salvador 

-- 
Otavio Salvador O.S. Systems
E-mail: ota...@ossystems.com.br  http://www.ossystems.com.br
Mobile: +55 53 9981-7854  http://projetos.ossystems.com.br
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH 1/2] mxs: Implement common function to setup VDDx

2012-11-30 Thread Otavio Salvador
On Fri, Nov 30, 2012 at 1:22 PM, Marek Vasut  wrote:

> Implement common function to setup the VDDIO, VDDD and VDDA voltage.
> Right now, there are two almost identical functions to setup VDDIO
> and VDDD, which is prone to breakage. Pull out the differences into
> constant structure and pass them as an argument to the common function.
>
> Moreover, the function has almost identical loops for setting higher
> and lower VDDx voltage. Merge these two loops.
>
> Signed-off-by: Marek Vasut 
> Cc: Stefano Babic 
> Cc: Fabio Estevam 
>

I like the code cleanup but I am curious if you have taken a look  if the
mx23 one is compatible.

-- 
Otavio Salvador O.S. Systems
E-mail: ota...@ossystems.com.br  http://www.ossystems.com.br
Mobile: +55 53 9981-7854  http://projetos.ossystems.com.br
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH 1/2] mxs: Implement common function to setup VDDx

2012-11-30 Thread Marek Vasut
Dear Otavio Salvador,

> On Fri, Nov 30, 2012 at 1:22 PM, Marek Vasut  wrote:
> > Implement common function to setup the VDDIO, VDDD and VDDA voltage.
> > Right now, there are two almost identical functions to setup VDDIO
> > and VDDD, which is prone to breakage. Pull out the differences into
> > constant structure and pass them as an argument to the common function.
> > 
> > Moreover, the function has almost identical loops for setting higher
> > and lower VDDx voltage. Merge these two loops.
> > 
> > Signed-off-by: Marek Vasut 
> > Cc: Stefano Babic 
> > Cc: Fabio Estevam 
> 
> I like the code cleanup but I am curious if you have taken a look  if the
> mx23 one is compatible.

MX23 is unsupported in the mainline u-boot.

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


Re: [U-Boot] [PATCH 1/2] mxs: Implement common function to setup VDDx

2012-11-30 Thread Otavio Salvador
On Fri, Nov 30, 2012 at 4:35 PM, Marek Vasut  wrote:

> Dear Otavio Salvador,
>
> > On Fri, Nov 30, 2012 at 1:22 PM, Marek Vasut  wrote:
> > > Implement common function to setup the VDDIO, VDDD and VDDA voltage.
> > > Right now, there are two almost identical functions to setup VDDIO
> > > and VDDD, which is prone to breakage. Pull out the differences into
> > > constant structure and pass them as an argument to the common function.
> > >
> > > Moreover, the function has almost identical loops for setting higher
> > > and lower VDDx voltage. Merge these two loops.
> > >
> > > Signed-off-by: Marek Vasut 
> > > Cc: Stefano Babic 
> > > Cc: Fabio Estevam 
> >
> > I like the code cleanup but I am curious if you have taken a look  if the
> > mx23 one is compatible.
>
> MX23 is unsupported in the mainline u-boot.
>

I see ...

-- 
Otavio Salvador O.S. Systems
E-mail: ota...@ossystems.com.br  http://www.ossystems.com.br
Mobile: +55 53 9981-7854  http://projetos.ossystems.com.br
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH v4 1/2] arm: move C runtime setup code in crt0.S

2012-11-30 Thread Simon Glass
Hi Albert,

On Wed, Nov 28, 2012 at 2:34 PM, Albert ARIBAUD
 wrote:
> Hi Simon,
>
> On Wed, 28 Nov 2012 13:18:57 -0800, Simon Glass 
> wrote:
>
>> Hi Albert,
>>
>> On Tue, Nov 27, 2012 at 4:43 AM, Albert ARIBAUD
>>  wrote:
>> > Move all the C runtime setup code from every start.S
>> > in arch/arm into arch/arm/lib/crt0.S. This covers
>> > the code sequence from setting up the initial stack
>> > to calling into board_init_r().
>> >
>> > Also, rewrite the C runtime setup and make functions
>> > board_init_*() and relocate_code() behave according to
>> > normal C semantics (no jumping across the C stack any
>> > more, etc).
>> >
>> > Some SPL targets had to be touched because they use
>> > start.S explicitly or for some reason; the relevant
>> > maintainers and custodians are cc:ed.
>> >
>> > Signed-off-by: Albert ARIBAUD 
>>
>> I tested this on Seaboard (Tegra 20).
>>
>> Tested-by: Simon Glass 
>>
>> I tried to test it on a snow (exynos5250) but couldn't really sync up
>> with our tree, so gave up. I am not completely sure about how the
>> CONFIG_SPL_BUILD stuff fits together in start.S and I got a build
>> error I wasn't sure how to correct (arch/arm/cpu/armv7/start.S:179:
>> undefined reference to `relocate_done')
>
> Thansk Simon.
>
> In file arch/arm/cpu/armv7/start.S, line 179 uses relocate_done and
> line 228 provides it, and there is no preprocessor conditional
> in-between, so I fail to see how you could get this error.
>
> Is your tree (and branch) available so that I can try and see the issue
> for myself? Either it'll uncover a problem in my patch series, or it'll
> help you merge it (or both).

OK I will try a bit harder and come back to you. Sorry I can't do that
immediately but will be soon...

Regards,
Simon

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


[U-Boot] [PATCH v2 02/10] arm: Keep track of the tlb size as well as its location

2012-11-30 Thread Simon Glass
From: Gabe Black 

It may be necessary to know where the TLB area ends as well as where it
starts. This allows board code to complete a secure memory erase without
destroying the page tables.

Signed-off-by: Gabe Black 
Signed-off-by: Simon Glass 
---
Changes in v2: None

 arch/arm/include/asm/global_data.h |1 +
 arch/arm/lib/board.c   |5 +++--
 2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/arch/arm/include/asm/global_data.h 
b/arch/arm/include/asm/global_data.h
index 2b9af93..41a26ed 100644
--- a/arch/arm/include/asm/global_data.h
+++ b/arch/arm/include/asm/global_data.h
@@ -73,6 +73,7 @@ typedef   struct  global_data {
unsigned long   reloc_off;
 #if !(defined(CONFIG_SYS_ICACHE_OFF) && defined(CONFIG_SYS_DCACHE_OFF))
unsigned long   tlb_addr;
+   unsigned long   tlb_size;
 #endif
const void  *fdt_blob;  /* Our device tree, NULL if none */
void**jt;   /* jump table */
diff --git a/arch/arm/lib/board.c b/arch/arm/lib/board.c
index 22a4d9c..e03fc6d 100644
--- a/arch/arm/lib/board.c
+++ b/arch/arm/lib/board.c
@@ -353,13 +353,14 @@ void board_init_f(ulong bootflag)
 
 #if !(defined(CONFIG_SYS_ICACHE_OFF) && defined(CONFIG_SYS_DCACHE_OFF))
/* reserve TLB table */
-   addr -= (4096 * 4);
+   gd->tlb_size = 4096 * 4;
+   addr -= gd->tlb_size;
 
/* round down to next 64 kB limit */
addr &= ~(0x1 - 1);
 
gd->tlb_addr = addr;
-   debug("TLB table at: %08lx\n", addr);
+   debug("TLB table from %08lx to %08lx\n", addr, addr + gd->tlb_size);
 #endif
 
/* round down to next 4 kB limit */
-- 
1.7.7.3

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


[U-Boot] [PATCH v2 06/10] arm: Add CONFIG_DISPLAY_BOARDINFO_LATE to display board info on LCD

2012-11-30 Thread Simon Glass
This option displays board info after stdio is running, so that it will
appear on the LCD. If it is displayed earlier, the board info will appear
on the serial console but not on the LCD.

Here follows a blow-by-blow description.

1a. Without CONFIG_DISPLAY_BOARDINFO_LATE, on serial:

U-Boot 2011.12-02550-g037e1c5-dirty (Nov 15 2012 - 14:29:42) for SMDK5250

CPU:   S5PC520 @ 1700MHz

Board: Google Snow, rev 0
I2C:   ready
DRAM:  2 GiB Elpida DDR3 @ 800MHz
MMC:   S5P MSHC0: 0, S5P MSHC1: 1
SF: Detected W25Q32 with page size 4 KiB, total 4 MiB
*** Warning - bad CRC, using default environment

In:mkbp-keyb
Out:   lcd
Err:   lcd
Net:   No ethernet found.
Hit any key to stop autoboot:  0
SMDK5250 #

1b. Without CONFIG_DISPLAY_BOARDINFO_LATE, on LCD (note machine info
is missing):

In:mkbp-keyb
Out:   lcd
Err:   lcd
Net:   No ethernet found.
Hit any key to stop autoboot:  0
SMDK5250 #

2a. With CONFIG_DISPLAY_BOARDINFO_LATE, on serial:

U-Boot 2011.12-02550-g037e1c5 (Nov 15 2012 - 14:27:40) for SMDK5250

CPU:   S5PC520 @ 1700MHz
I2C:   ready
DRAM:  2 GiB Elpida DDR3 @ 800MHz
MMC:   S5P MSHC0: 0, S5P MSHC1: 1
SF: Detected W25Q32 with page size 4 KiB, total 4 MiB
*** Warning - bad CRC, using default environment

Model: Google Snow
In:mkbp-keyb
Out:   lcd
Err:   lcd
Net:   No ethernet found.
Hit any key to stop autoboot:  0
SMDK5250 #

2b. With CONFIG_DISPLAY_BOARDINFO_LATE, on LCD (note machine info is present):

Model: Google Snow
In:mkbp-keyb
Out:   lcd
Err:   lcd
Net:   No ethernet found.
Hit any key to stop autoboot:  0
SMDK5250 #

Since the LCD is all that a typical user sees, it is useful to display
the model there.

We may be able to rearrange things some other way one day, but at
present this seems like a convenient way of getting the required
behaviour.

Signed-off-by: Simon Glass 

---
Changes in v2:
- Update commit message to provide a detailed description

 README   |5 +
 arch/arm/lib/board.c |   19 +++
 2 files changed, 24 insertions(+), 0 deletions(-)

diff --git a/README b/README
index d8bd784..36853e5 100644
--- a/README
+++ b/README
@@ -3356,6 +3356,11 @@ use the "saveenv" command to store a valid environment.
when U-Boot starts up. The board function checkboard() is called
to do this.
 
+- CONFIG_DISPLAY_BOARDINFO_LATE
+   Similar to the previous option, but display this information
+   later, once stdio is running and output goes to the LCD, if
+   present.
+
 Low Level (hardware related) configuration options:
 ---
 
diff --git a/arch/arm/lib/board.c b/arch/arm/lib/board.c
index 7d1927e..1d563bb 100644
--- a/arch/arm/lib/board.c
+++ b/arch/arm/lib/board.c
@@ -498,6 +498,16 @@ static int should_load_env(void)
 #endif
 }
 
+#if defined(CONFIG_DISPLAY_BOARDINFO_LATE) && defined(CONFIG_OF_CONTROL)
+static void display_fdt_model(const void *blob)
+{
+   const char *model;
+
+   model = (char *)fdt_getprop(blob, 0, "model", NULL);
+   printf("Model: %s\n", model ? model : "");
+}
+#endif
+
 /
  *
  * This is the next part if the initialization sequence: we are now
@@ -625,6 +635,15 @@ void board_init_r(gd_t *id, ulong dest_addr)
 
console_init_r();   /* fully init console as a device */
 
+#ifdef CONFIG_DISPLAY_BOARDINFO_LATE
+# ifdef CONFIG_OF_CONTROL
+   /* Put this here so it appears on the LCD, now it is ready */
+   display_fdt_model(gd->fdt_blob);
+# else
+   checkboard();
+# endif
+#endif
+
 #if defined(CONFIG_ARCH_MISC_INIT)
/* miscellaneous arch dependent initialisations */
arch_misc_init();
-- 
1.7.7.3

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


[U-Boot] [PATCH v2 03/10] arm: Move fdt check earlier so that board_early_init_f() can use it

2012-11-30 Thread Simon Glass
We want to use the fdt inside board_early_init_f(), so check for its
presence earlier in the pre-reloc init sequence.

So far ARM and microblaze are the only only ones that use
CONFIG_OF_CONTROL. Microblaze does not have the same init loop, and in
particular does not have the board_early_init_f() call. So a patch for
microblaze would have no meaning.

Signed-off-by: Simon Glass 
---
Changes in v2:
- Update commit message with more detail

 arch/arm/lib/board.c |7 +++
 1 files changed, 3 insertions(+), 4 deletions(-)

diff --git a/arch/arm/lib/board.c b/arch/arm/lib/board.c
index e03fc6d..262a3ca 100644
--- a/arch/arm/lib/board.c
+++ b/arch/arm/lib/board.c
@@ -233,13 +233,12 @@ int power_init_board(void)
 
 init_fnc_t *init_sequence[] = {
arch_cpu_init,  /* basic arch cpu dependent setup */
-
-#if defined(CONFIG_BOARD_EARLY_INIT_F)
-   board_early_init_f,
-#endif
 #ifdef CONFIG_OF_CONTROL
fdtdec_check_fdt,
 #endif
+#if defined(CONFIG_BOARD_EARLY_INIT_F)
+   board_early_init_f,
+#endif
timer_init, /* initialize timer */
 #ifdef CONFIG_BOARD_POSTCLK_INIT
board_postclk_init,
-- 
1.7.7.3

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


[U-Boot] [PATCH v2 01/10] arm: move flush_dcache_all() to just before disable cache

2012-11-30 Thread Simon Glass
From: Arun Mankuzhi 

In Cortex-A15 architecture, when we run cache invalidate
the cache clean operation executes automatically.
So if there are any dirty cache lines before disabling the L2 cache
these will be synchronized with the main memory when
invalidate_dcache_all() runs in the last part of U-boot

The two functions after flush_dcache_all is using the stack. So this
data will be on the cache. After disable when invalidate is called the
data will be flushed from cache to memory. This corrupts the stack in
invalida_dcache_all. So this change is required to avoid the u-boot
hang.

So flush has to be done just before clearing CR_C bit

Signed-off-by: Arun Mankuzhi 
Signed-off-by: Simon Glass 
---
Changes in v2: None

 arch/arm/lib/cache-cp15.c |5 -
 1 files changed, 4 insertions(+), 1 deletions(-)

diff --git a/arch/arm/lib/cache-cp15.c b/arch/arm/lib/cache-cp15.c
index 939de10..06119c8 100644
--- a/arch/arm/lib/cache-cp15.c
+++ b/arch/arm/lib/cache-cp15.c
@@ -124,8 +124,11 @@ static void cache_disable(uint32_t cache_bit)
return;
/* if disabling data cache, disable mmu too */
cache_bit |= CR_M;
-   flush_dcache_all();
}
+   reg = get_cr();
+   cp_delay();
+   if (cache_bit == (CR_C | CR_M))
+   flush_dcache_all();
set_cr(reg & ~cache_bit);
 }
 #endif
-- 
1.7.7.3

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


[U-Boot] [PATCH v2 05/10] Document the CONFIG_DISPLAY_BOARDINFO option

2012-11-30 Thread Simon Glass
Add a short note about this in the README.

Signed-off-by: Simon Glass 
---
Changes in v2:
- Split out CONFIG_DISPLAY_BOARDINFO README change into separate commit

 README |5 +
 1 files changed, 5 insertions(+), 0 deletions(-)

diff --git a/README b/README
index d26ce5b..d8bd784 100644
--- a/README
+++ b/README
@@ -3351,6 +3351,11 @@ use the "saveenv" command to store a valid environment.
space for already greatly restricted images, including but not
limited to NAND_SPL configurations.
 
+- CONFIG_DISPLAY_BOARDINFO
+   Display information about the board that U-Boot is running on
+   when U-Boot starts up. The board function checkboard() is called
+   to do this.
+
 Low Level (hardware related) configuration options:
 ---
 
-- 
1.7.7.3

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


[U-Boot] [PATCH v2 07/10] Add option to display customised memory information

2012-11-30 Thread Simon Glass
Some boards want to report more than just memory size. For example, it
might be useful to display the memory type (DDR2, DDR3) or manufacturer.

Add a weak function to support this requirement, accessed through a new
'meminfo' command.

Any example of the DRAM: output is below, just for illustration:

SMDK5250 # meminfo
DRAM:  2 GiB Elpida DDR3 @ 800MHz

Signed-off-by: Simon Glass 
---
Changes in v2:
- Rewrite customised memory info patch to use a command

 README   |1 +
 common/cmd_mem.c |   27 +++
 include/common.h |9 +
 include/config_cmd_all.h |1 +
 4 files changed, 38 insertions(+), 0 deletions(-)

diff --git a/README b/README
index 36853e5..200edf8 100644
--- a/README
+++ b/README
@@ -840,6 +840,7 @@ The following options need to be configured:
CONFIG_CMD_LOADS  loads
CONFIG_CMD_MD5SUM print md5 message digest
  (requires CONFIG_CMD_MEMORY and 
CONFIG_MD5)
+   CONFIG_CMD_MEMINFO  * Display detailed memory information
CONFIG_CMD_MEMORY md, mm, nm, mw, cp, cmp, crc, base,
  loop, loopw, mtest
CONFIG_CMD_MISC   Misc functions like sleep etc
diff --git a/common/cmd_mem.c b/common/cmd_mem.c
index 4d64cff..0f3ffc8 100644
--- a/common/cmd_mem.c
+++ b/common/cmd_mem.c
@@ -33,6 +33,9 @@
 #include 
 #endif
 #include 
+#include 
+
+DECLARE_GLOBAL_DATA_PTR;
 
 static int mod_mem(cmd_tbl_t *, int, int, int, char * const []);
 
@@ -1203,6 +1206,22 @@ U_BOOT_CMD(
 
 #endif
 
+#ifdef CONFIG_CMD_MEMINFO
+__weak void board_show_dram(ulong size)
+{
+   puts("DRAM:  ");
+   print_size(size, "\n");
+}
+
+static int do_mem_info(cmd_tbl_t *cmdtp, int flag, int argc,
+  char * const argv[])
+{
+   board_show_dram(gd->ram_size);
+
+   return 0;
+}
+#endif
+
 U_BOOT_CMD(
base,   2,  1,  do_mem_base,
"print or set address offset",
@@ -1243,3 +1262,11 @@ U_BOOT_CMD(
"[.b, .w, .l] address value delay(ms)"
 );
 #endif /* CONFIG_MX_CYCLIC */
+
+#ifdef CONFIG_CMD_MEMINFO
+U_BOOT_CMD(
+   meminfo,3,  1,  do_mem_info,
+   "display memory information",
+   ""
+);
+#endif
diff --git a/include/common.h b/include/common.h
index 5e3c5ee..a1ab4f0 100644
--- a/include/common.h
+++ b/include/common.h
@@ -311,6 +311,15 @@ int mac_read_from_eeprom(void);
 extern u8 _binary_dt_dtb_start[];  /* embedded device tree blob */
 int set_cpu_clk_info(void);
 
+/**
+ * Show the DRAM size in a board-specific way
+ *
+ * This is used by boards to display DRAM information in their own way.
+ *
+ * @param size Size of DRAM (which should be displayed along with other info)
+ */
+void board_show_dram(ulong size);
+
 /* common/flash.c */
 void flash_perror (int);
 
diff --git a/include/config_cmd_all.h b/include/config_cmd_all.h
index f434cd0..eadc8b7 100644
--- a/include/config_cmd_all.h
+++ b/include/config_cmd_all.h
@@ -53,6 +53,7 @@
 #define CONFIG_CMD_LICENSE /* console license display  */
 #define CONFIG_CMD_LOADB   /* loadb*/
 #define CONFIG_CMD_LOADS   /* loads*/
+#define CONFIG_CMD_MEMINFO /* meminfo  */
 #define CONFIG_CMD_MEMORY  /* md mm nm mw cp cmp crc base loop mtest */
 #define CONFIG_CMD_MFSL/* FSL support for Microblaze   */
 #define CONFIG_CMD_MII /* MII support  */
-- 
1.7.7.3

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


[U-Boot] [PATCH v2 08/10] arm: Make interrupts.o and reset.o in libarm also appear in SPL

2012-11-30 Thread Simon Glass
From: Tom Wai-Hong Tam 

SPL u-boot may call do_reset() which depends on interrupts.o and reset.o.
So make them also appear in SPL.

Signed-off-by: Tom Wai-Hong Tam 
Signed-off-by: Simon Glass 
---
Changes in v2: None

 arch/arm/lib/Makefile |5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/arch/arm/lib/Makefile b/arch/arm/lib/Makefile
index 3422ac1..2fbdc07 100644
--- a/arch/arm/lib/Makefile
+++ b/arch/arm/lib/Makefile
@@ -40,14 +40,15 @@ ifndef CONFIG_SPL_BUILD
 COBJS-y+= board.o
 COBJS-y+= bootm.o
 COBJS-$(CONFIG_SYS_L2_PL310) += cache-pl310.o
-COBJS-y+= interrupts.o
-COBJS-y+= reset.o
 SOBJS-$(CONFIG_USE_ARCH_MEMSET) += memset.o
 SOBJS-$(CONFIG_USE_ARCH_MEMCPY) += memcpy.o
 else
 COBJS-$(CONFIG_SPL_FRAMEWORK) += spl.o
 endif
 
+COBJS-y+= interrupts.o
+COBJS-y+= reset.o
+
 COBJS-y+= cache.o
 COBJS-y+= cache-cp15.o
 
-- 
1.7.7.3

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


[U-Boot] [PATCH v2 09/10] arm: Move bootstage record for board_init_f() to after arch_cpu_init()

2012-11-30 Thread Simon Glass
The timer may be inited in arch_cpu_init() so it is not safe to make a
bootstage mark before this is called. Arrange the code to fix this.

Note: The question was raised as to why we don't keep all archs in sync.
PowerPC doesn't have specific bootstage markers at present (although it
does use boot progress). I hope that the generic board series will solve
this problem in general, but in the meantime this is a real problem, and
only in ARM.

We now get a correct time for board_init_f:

Timer summary in microseconds:
   MarkElapsed  Stage
  0  0  reset
100,000100,000  spl_start
848,530748,530  board_init_f
907,301 58,771  board_init_r
910,478  3,177  board_init

Signed-off-by: Simon Glass 
---
Changes in v2:
- Rebase to master
- Update commit message

 arch/arm/lib/board.c |   11 +--
 1 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/arch/arm/lib/board.c b/arch/arm/lib/board.c
index 1d563bb..0410dae 100644
--- a/arch/arm/lib/board.c
+++ b/arch/arm/lib/board.c
@@ -232,8 +232,17 @@ int __power_init_board(void)
 int power_init_board(void)
__attribute__((weak, alias("__power_init_board")));
 
+   /* Record the board_init_f() bootstage (after arch_cpu_init()) */
+static int mark_bootstage(void)
+{
+   bootstage_mark_name(BOOTSTAGE_ID_START_UBOOT_F, "board_init_f");
+
+   return 0;
+}
+
 init_fnc_t *init_sequence[] = {
arch_cpu_init,  /* basic arch cpu dependent setup */
+   mark_bootstage,
 #ifdef CONFIG_OF_CONTROL
fdtdec_check_fdt,
 #endif
@@ -277,8 +286,6 @@ void board_init_f(ulong bootflag)
void *new_fdt = NULL;
size_t fdt_size = 0;
 
-   bootstage_mark_name(BOOTSTAGE_ID_START_UBOOT_F, "board_init_f");
-
/* Pointer is writable since we allocated a register for it */
gd = (gd_t *) ((CONFIG_SYS_INIT_SP_ADDR) & ~0x07);
/* compiler optimization barrier needed for GCC >= 3.4 */
-- 
1.7.7.3

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


[U-Boot] [PATCH v2 10/10] arm: Tabify code for MMC initialization

2012-11-30 Thread Simon Glass
From: Taylor Hutt 

The two modified lines were indented with spaces.
They are now indented with tabs.

Signed-off-by: Taylor Hutt 
Signed-off-by: Simon Glass 
---
Changes in v2: None

 arch/arm/lib/board.c |4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/arm/lib/board.c b/arch/arm/lib/board.c
index 0410dae..6f58d6c 100644
--- a/arch/arm/lib/board.c
+++ b/arch/arm/lib/board.c
@@ -612,8 +612,8 @@ void board_init_r(gd_t *id, ulong dest_addr)
 #endif
 
 #ifdef CONFIG_GENERIC_MMC
-   puts("MMC:   ");
-   mmc_initialize(gd->bd);
+   puts("MMC:   ");
+   mmc_initialize(gd->bd);
 #endif
 
 #ifdef CONFIG_HAS_DATAFLASH
-- 
1.7.7.3

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


[U-Boot] [PATCH v2 04/10] arm: Add CONFIG_DELAY_ENVIRONMENT to delay environment loading

2012-11-30 Thread Simon Glass
This option delays loading of the environment until later, so that only the
default environment will be available to U-Boot.

This can address the security risk of untrusted data being used during boot.

Any time you load untrusted data you expose yourself to a bug in the
code. The attacker gets to choose the data so can sometimes carefully
craft it to exploit a bug. We try to avoid touching user-controlled
data during a verified boot unless strictly necessary. Since the
default environment is good enough in this case (or you would just
change it), this gets around the problem by just not loading the
environment.

When CONFIG_DELAY_ENVIRONMENT is defined, it is convenient to have a
run-time way of enabling loading of the environment. Add this to the
fdt as /config/delay-environment.

Note: This patch depends on http://patchwork.ozlabs.org/patch/194342/

Signed-off-by: Doug Anderson 
Signed-off-by: Simon Glass 
---
Changes in v2:
- Update commit message to provide more detail

 README   |9 +
 arch/arm/lib/board.c |   29 +++--
 2 files changed, 36 insertions(+), 2 deletions(-)

diff --git a/README b/README
index b9a3685..d26ce5b 100644
--- a/README
+++ b/README
@@ -2329,6 +2329,15 @@ CBFS (Coreboot Filesystem) support
run-time determined information about the hardware to the
environment.  These will be named board_name, board_rev.
 
+   CONFIG_DELAY_ENVIRONMENT
+
+   Normally the environment is loaded when the board is
+   intialised so that it is available to U-Boot. This inhibits
+   that so that the environment is not available until
+   explicitly loaded later by U-Boot code. With CONFIG_OF_CONTROL
+   this is instead controlled by the value of
+   /config/load-environment.
+
 - DataFlash Support:
CONFIG_HAS_DATAFLASH
 
diff --git a/arch/arm/lib/board.c b/arch/arm/lib/board.c
index 262a3ca..7d1927e 100644
--- a/arch/arm/lib/board.c
+++ b/arch/arm/lib/board.c
@@ -40,6 +40,7 @@
 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -476,7 +477,28 @@ static char *failed = "*** failed ***\n";
 #endif
 
 /*
- 
+ * Tell if it's OK to load the environment early in boot.
+ *
+ * If CONFIG_OF_CONFIG is defined, we'll check with the FDT to see
+ * if this is OK (defaulting to saying it's not OK).
+ *
+ * NOTE: Loading the environment early can be a bad idea if security is
+ *   important, since no verification is done on the environment.
+ *
+ * @return 0 if environment should not be loaded, !=0 if it is ok to load
+ */
+static int should_load_env(void)
+{
+#ifdef CONFIG_OF_CONTROL
+   return fdtdec_get_config_int(gd->fdt_blob, "load-environment", 0);
+#elif defined CONFIG_DELAY_ENVIRONMENT
+   return 0;
+#else
+   return 1;
+#endif
+}
+
+/
  *
  * This is the next part if the initialization sequence: we are now
  * running from RAM and have a "normal" C environment, i. e. global
@@ -583,7 +605,10 @@ void board_init_r(gd_t *id, ulong dest_addr)
 #endif
 
/* initialize environment */
-   env_relocate();
+   if (should_load_env())
+   env_relocate();
+   else
+   set_default_env(NULL);
 
 #if defined(CONFIG_CMD_PCI) || defined(CONFIG_PCI)
arm_pci_init();
-- 
1.7.7.3

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


Re: [U-Boot] [PATCH v2] mmc: Split device init to decouple OCR-polling delay

2012-11-30 Thread Simon Glass
Hi,

On Thu, Nov 29, 2012 at 7:20 AM, Jae hoon Chung  wrote:
> Hi Simon,
>
> Is it saved the 200ms? Could you tell me your environment?
> I will check this patch..and share the result.

The environment is snow (Samsung ARM Chromebook). The time save only
comes from not waiting for the MMC init. So:

1. Kick off MMC init
2. Go off and do something else for 200ms
3. Come back and MMC init should complete immediately

Regards,
Simon

>
> Best Regards,
> Jaehoon Chung
>
> 2012/11/29 Simon Glass :
>> From: Che-Liang Chiou 
>>
>> Most of time that MMC driver spends on initializing a device is polling
>> OCR (operation conditions register).  To decouple this polling loop,
>> device init is split into two parts: The first part fires the OCR query
>> command, and the second part polls the result.  So the caller is now no
>> longer bound to the OCR-polling delay; he may fire the query, go
>> somewhere and then come back later for the result.
>>
>> To use this, call mmc_set_preinit() on any device which needs this.
>>
>> This can save significant amounts of time on boot (e.g. 200ms) by
>> hiding the MMC init time behind other init.
>>
>> Signed-off-by: Che-Liang Chiou 
>> Signed-off-by: Simon Glass 
>> ---
>> Changes in v2:
>> - Rebase to master
>>
>>  drivers/mmc/mmc.c |  137 
>> 
>>  include/mmc.h |   30 
>>  2 files changed, 135 insertions(+), 32 deletions(-)
>>
>> diff --git a/drivers/mmc/mmc.c b/drivers/mmc/mmc.c
>> index 72e8ce6..09695e8 100644
>> --- a/drivers/mmc/mmc.c
>> +++ b/drivers/mmc/mmc.c
>> @@ -503,48 +503,70 @@ static int sd_send_op_cond(struct mmc *mmc)
>> return 0;
>>  }
>>
>> -static int mmc_send_op_cond(struct mmc *mmc)
>> +/* We pass in the cmd since otherwise the init seems to fail */
>> +static int mmc_send_op_cond_iter(struct mmc *mmc, struct mmc_cmd *cmd,
>> +   int use_arg)
>>  {
>> -   int timeout = 1;
>> -   struct mmc_cmd cmd;
>> int err;
>>
>> +   cmd->cmdidx = MMC_CMD_SEND_OP_COND;
>> +   cmd->resp_type = MMC_RSP_R3;
>> +   cmd->cmdarg = 0;
>> +   if (use_arg && !mmc_host_is_spi(mmc)) {
>> +   cmd->cmdarg =
>> +   (mmc->voltages &
>> +   (mmc->op_cond_response & OCR_VOLTAGE_MASK)) |
>> +   (mmc->op_cond_response & OCR_ACCESS_MODE);
>> +
>> +   if (mmc->host_caps & MMC_MODE_HC)
>> +   cmd->cmdarg |= OCR_HCS;
>> +   }
>> +   err = mmc_send_cmd(mmc, cmd, NULL);
>> +   if (err)
>> +   return err;
>> +   mmc->op_cond_response = cmd->response[0];
>> +   return 0;
>> +}
>> +
>> +int mmc_send_op_cond(struct mmc *mmc)
>> +{
>> +   struct mmc_cmd cmd;
>> +   int err, i;
>> +
>> /* Some cards seem to need this */
>> mmc_go_idle(mmc);
>>
>> /* Asking to the card its capabilities */
>> -   cmd.cmdidx = MMC_CMD_SEND_OP_COND;
>> -   cmd.resp_type = MMC_RSP_R3;
>> -   cmd.cmdarg = 0;
>> -
>> -   err = mmc_send_cmd(mmc, &cmd, NULL);
>> +   mmc->op_cond_pending = 1;
>> +   for (i = 0; i < 2; i++) {
>> +   err = mmc_send_op_cond_iter(mmc, &cmd, i != 0);
>> +   if (err)
>> +   return err;
>>
>> -   if (err)
>> -   return err;
>> +   /* exit if not busy (flag seems to be inverted) */
>> +   if (mmc->op_cond_response & OCR_BUSY)
>> +   return 0;
>> +   }
>> +   return IN_PROGRESS;
>> +}
>>
>> -   udelay(1000);
>> +int mmc_complete_op_cond(struct mmc *mmc)
>> +{
>> +   struct mmc_cmd cmd;
>> +   int timeout = 1000;
>> +   uint start;
>> +   int err;
>>
>> +   mmc->op_cond_pending = 0;
>> +   start = get_timer(0);
>> do {
>> -   cmd.cmdidx = MMC_CMD_SEND_OP_COND;
>> -   cmd.resp_type = MMC_RSP_R3;
>> -   cmd.cmdarg = (mmc_host_is_spi(mmc) ? 0 :
>> -   (mmc->voltages &
>> -   (cmd.response[0] & OCR_VOLTAGE_MASK)) |
>> -   (cmd.response[0] & OCR_ACCESS_MODE));
>> -
>> -   if (mmc->host_caps & MMC_MODE_HC)
>> -   cmd.cmdarg |= OCR_HCS;
>> -
>> -   err = mmc_send_cmd(mmc, &cmd, NULL);
>> -
>> +   err = mmc_send_op_cond_iter(mmc, &cmd, 1);
>> if (err)
>> return err;
>> -
>> -   udelay(1000);
>> -   } while (!(cmd.response[0] & OCR_BUSY) && timeout--);
>> -
>> -   if (timeout <= 0)
>> -   return UNUSABLE_ERR;
>> +   if (get_timer(start) > timeout)
>> +   return UNUSABLE_ERR;
>> +   udelay(100);
>> +   } while (!(mmc->op_cond_response & OCR_BUSY));
>>
>> if (mmc_host_is_spi(mmc)) { /* read OCR for spi */
>> cmd.cmdidx = MMC_CMD_SPI_READ_OCR;
>> @@

Re: [U-Boot] [PATCH v2] mmc: Split device init to decouple OCR-polling delay

2012-11-30 Thread Simon Glass
Hi Jaehoon,

On Fri, Nov 30, 2012 at 12:25 AM, Jaehoon Chung  wrote:
> Hi,
>
> This concept is very good.
> But I have one question. I think need to call mmc_init() one more, right?
> how did you save the boot time(200ms)?
>
> On 11/29/2012 10:21 AM, Simon Glass wrote:
>> From: Che-Liang Chiou 
>>
>> Most of time that MMC driver spends on initializing a device is polling
>> OCR (operation conditions register).  To decouple this polling loop,
>> device init is split into two parts: The first part fires the OCR query
>> command, and the second part polls the result.  So the caller is now no
>> longer bound to the OCR-polling delay; he may fire the query, go
>> somewhere and then come back later for the result.
>>
>> To use this, call mmc_set_preinit() on any device which needs this.
>>
>> This can save significant amounts of time on boot (e.g. 200ms) by
>> hiding the MMC init time behind other init.
> snip..
>> +int mmc_init(struct mmc *mmc)
>> +{
>> + int err = IN_PROGRESS;
>> + unsigned start = get_timer(0);
>> +
>> + if (mmc->has_init)
>> + return 0;
>> + if (!mmc->init_in_progress)
>> + err = mmc_start_init(mmc);
> It need not to return? if err is IN_PROGRESS, next condition is immediately 
> run.
> Then i think we didn't save the time before adjust this patch.

It's a little confusing, but the way it works is that mmc_preinit()
calls mmc_start_init() early in boot. Then when mmc_init() finally
gets called (later) it finishes off the init. We still need mmc_init()
to actually fully complete the init. If it were to return before
completing the init then we would be unable to use the MMC.

>> +
>> + if (!err || err == IN_PROGRESS)
>> + err = mmc_complete_init(mmc);
>> + debug("%s: %d, time %lu\n", __func__, err, get_timer(start));
>>   return err;
>>  }

[snip]

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


Re: [U-Boot] U-Boot for MIPS AR7161

2012-11-30 Thread Dmytro
Hi Allan Drassal,

Frankly, I'm not in practice faced ar71xx processors in labs, but I
can give details on experience with the ar724x CPUs.

First we need to determine are fully is support in ar71xx.cfg file for
your device.
You need connect to the JTAG and switch the device in halt mode. Next
read the following registers using OpenOCD:
mdw 0xb800 0x10
mdw 0xb805
mdw 0xb8050008
mdw 0xb805000c

On the second device with a working firmware, do the same thing, only
in u-boot (it's as though after the initialization of the CPU):
md 0xb800 0x10
md 0xb805 0x1
md 0xb8050008 0x1
md 0xb805000c 0x1

What is it for?
Before initializing the processor - PLL records are in resetting state
These values are described in the files ar71xx.cfg or ar724x.cfg in
parentheses. Then based on these (reset) values are any operation
with PLL. I.e. We do not just give to known command to processor - We
read from the processor value and produce a binary operation on it
according to the rules described in the source lowlevel_init (if you
take the PLL). The same thing with the any initialization process.

Need will explain how to work with ar71xx.cfg configuration file.
Event "reset-halt-post" thegas telnet command "reset halt"
but this command directly related to the physical nSRST. I.e. During
the execution of commands "reset halt" - nSRTS goes to logic "1" at
the same time, this processor receives commands switch to "halt". In
my experience on ar724x CPUs - is no longer used nSRTS and has been
replaced on RST so "reset halt" does not work in my case and the
difficulty I had was that it was necessary to make sure that the
processor is switched to the correct mode, and it was settings needed
register (make sure you can read the "mdw 0xb805 "after the event
is triggered and you will once again transferred CPU in halt mode.).
As a last resort you can do "ar71xx.cpu invoke-event
reset-halt-post "(if not work "reset halt" as it should) for example
in the instructions:
http://www.google.com/translate_c?langpair=ru|en&u=http://wiki.openwrt.org/ru/toh/tp-link/tl-mr3420/debrick%2525using%2525jtag

The next step will be a check memory:
You need to load the image in the memory at 0xa001
load_image iamge.bin 0xa001
(Address window of DRAM memory at the platform AP96, PB42, etc. - 0xa001)
and most importantly, it immediately check and compare with the
original in HEX mode
mdw 0xa001 0x10
mdw 0xa001 0x10
(check 2 times)
This is due to the fact that If the specified is not correct timings
for the memory then the first read memory may even be quite normal,
but when we re-reading data, the data may already be offset (and
eventually, the data starts, as if to float). Usually corrects this
problem by selecting values in the less side DQS0, DQS1 line.

Bootloader 8Muboot_RAM_version.bin course is not suitable for your
purpose, you need to compile the bootloader for your platform and your
address space (0xa001). So far the only thing I can say about it -
I'm trying to solve this problem and will soon let you know the
results.

P.S.
As variants, there are plenty of opportunities to find the right boot
for your processor, for example there is a recovery function for
COMPEX devices:
http://www.cpx.cz/dls/JTAG% 20SW_CONFIG_INSTR/How% 20to% 20JTAG% 20to%
20Compex% 20Loader.pdf
(Instruction)
http://www.cpx.cz/dls/JTAG% 20SW_CONFIG_INSTR/upbios.tst
(needed file for flash via tftp (without UART))
https://dev.openwrt.org/attachment/ticket/8393/init-ar7130-32m.mac
(config for OCD Commande - can easily be changed to OpenOCD)
http://www.cpx.cz/dls/JTAG% 20SW_CONFIG_INSTR/wp543.rar
(bootloader for ar7130)
http://www.cpx.cz/dls/wpe72_WPE72NX_MMJ5N26E/wp72_loader_jtag.zip
(as bonus this for ar724x - not tested with me)

Regards, Dmytro

2012/11/29, Drassal, Allan :
> Dear Dmytro and others,
>
> Sorry, I didn't post the output in the previous post, just the commands.
> I am going to post the full output below, along with the details of the
> ar71xx.cfg file, and output from openocd also.
> The config file originally came from an AR724x processor as well, so it
> might not be correct for an AR71xx.
> I would appreciate assistance in identifying the mistakes and correcting
> them if you don't mind please.
> Please share with myself and others if you can.
>
> The code that I am attempting to run in the processor, again for the AR724x,
> is 8Muboot_RAM_version.bin
> It can be found easily on the internet with a google search.  If you have
> the expertise to identify what can be changed to make this compatile with
> the AR71xx, please do.
> This code partially runs because upon execution, it turns on an LED on the
> board.  However, it gives no UART output that I can see.
>
> I am still interested in porting U-Boot to this processor as well, and I
> have found bits and pieces of previous work done, but nothing that I can
> identify as compelte.
> MIPS does not seem to be in the main line for U-Boot, but I might be
> mistaken, correc

[U-Boot] [PATCH 1/1] mtd/cfi: add support for SST 4KB sector granularity

2012-11-30 Thread Angelo Dureghello
Add support for SST 4KB sector granularity.

Many recent SST flashes, i.e. SST39VF3201B and similar of this family 
are declared CFI-conformant from SST. They support CFI query, but implement 
2 different sector sizes in the same memory: a 64KB sector (they call it 
"block", std AMD erase cmd=0x30), and a 4KB sector (they call it "sector", 
erase cmd=0x50). Also, CFI query on these chips, reading from address 0x2dh 
of cfi query struct, detects a number of secotrs for the 4KB granularity
(flinfo shows it). 

For all other aspects, they are CFI compliant, so, as Linux do, i think 
it's a good idea to handle these chips in the CFI driver, with a fixup
to allow 4KB granularity, as should be expected, instead of 64KB.

Signed-off-by: Angelo Dureghello 
Cc: Stefan Rose 
---
 drivers/mtd/cfi_flash.c |   25 -
 include/flash.h |1 +
 2 files changed, 25 insertions(+), 1 deletion(-)

diff --git a/drivers/mtd/cfi_flash.c b/drivers/mtd/cfi_flash.c
index b2dfc53..b46f1ca 100644
--- a/drivers/mtd/cfi_flash.c
+++ b/drivers/mtd/cfi_flash.c
@@ -1128,7 +1128,7 @@ int flash_erase (flash_info_t * info, int s_first, int 
s_last)
AMD_CMD_ERASE_START);
flash_unlock_seq (info, sect);
flash_write_cmd (info, sect, 0,
-AMD_CMD_ERASE_SECTOR);
+info->cmd_erase_sector);
break;
 #ifdef CONFIG_FLASH_CFI_LEGACY
case CFI_CMDSET_AMD_LEGACY:
@@ -1733,6 +1733,7 @@ static void cmdset_amd_read_jedec_ids(flash_info_t *info)
 static int cmdset_amd_init(flash_info_t *info, struct cfi_qry *qry)
 {
info->cmd_reset = AMD_CMD_RESET;
+   info->cmd_erase_sector = AMD_CMD_ERASE_SECTOR;
 
cmdset_amd_read_jedec_ids(info);
flash_write_cmd(info, 0, info->cfi_offset, FLASH_CMD_CFI);
@@ -2003,6 +2004,25 @@ static void flash_fixup_stm(flash_info_t *info, struct 
cfi_qry *qry)
}
 }
 
+static void flash_fixup_sst(flash_info_t *info, struct cfi_qry *qry)
+{
+   /*
+* SST, for many recent nor parallel flashes, says they are
+* CFI-conformant. This is not true, since qry struct. 
+* reports a std. AMD command set (0x0002), while SST allows to
+* erase two different sector sizes for the same memory.
+* 64KB sector (SST call it block)  needs 0x30 to be erased.
+* 4KB  sector (SST call it sector) needs 0x50 to be erased.
+* Since CFI query detect the 4KB number of sectors, users expects 
+* a sector granularity of 4KB, and it is here set.
+*/ 
+   if (info->device_id == 0x5D23 || /* SST39VF3201B */
+   info->device_id == 0x5C23) { /* SST39VF3202B */
+   /* set sector granularity to 4KB */ 
+   info->cmd_erase_sector=0x50;
+   }
+}
+
 /*
  * The following code cannot be run from FLASH!
  *
@@ -2081,6 +2101,9 @@ ulong flash_get_size (phys_addr_t base, int banknum)
case 0x0020:
flash_fixup_stm(info, &qry);
break;
+   case 0x00bf: /* SST */
+   flash_fixup_sst(info, &qry);
+   break;
}
 
debug ("manufacturer is %d\n", info->vendor);
diff --git a/include/flash.h b/include/flash.h
index a04ce90..0ba2d33 100644
--- a/include/flash.h
+++ b/include/flash.h
@@ -44,6 +44,7 @@ typedef struct {
ulong   buffer_write_tout;  /* maximum buffer write timeout 
*/
ushort  vendor; /* the primary vendor id
*/
ushort  cmd_reset;  /* vendor specific reset command
*/
+   uchar   cmd_erase_sector;   /* vendor specific erase sect. command  
*/
ushort  interface;  /* used for x8/x16 adjustments  
*/
ushort  legacy_unlock;  /* support Intel legacy (un)locking 
*/
ushort  manufacturer_id;/* manufacturer id  
*/
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH 3/4] patman: Add the concept of multiple projects

2012-11-30 Thread Doug Anderson
There are cases that we want to support different settings (or maybe
even different aliases) for different projects.  Add support for this
by:
* Adding detection for two big projects: U-Boot and Linux.
* Adding default settings for Linux (U-Boot is already good with the
  standard patman defaults).
* Extend the new "settings" feature in .patman to specify per-project
  settings.

Signed-off-by: Doug Anderson 
---
 tools/patman/README  |   13 
 tools/patman/patman.py   |9 +++-
 tools/patman/project.py  |   43 +
 tools/patman/settings.py |  147 +-
 4 files changed, 208 insertions(+), 4 deletions(-)
 create mode 100644 tools/patman/project.py

diff --git a/tools/patman/README b/tools/patman/README
index 6ca5b5b..d294f3d 100644
--- a/tools/patman/README
+++ b/tools/patman/README
@@ -114,6 +114,19 @@ verbose: True
 <<<
 
 
+If you want to adjust settings (or aliases) that affect just a single
+project you can add a section that looks like [project_settings] or
+[project_alias].  If you want to use tags for your linux work, you could
+do:
+
+>>>
+
+[linux_settings]
+process_tags: True
+
+<<<
+
+
 How to run it
 =
 
diff --git a/tools/patman/patman.py b/tools/patman/patman.py
index b327c67..54a252e 100755
--- a/tools/patman/patman.py
+++ b/tools/patman/patman.py
@@ -34,6 +34,7 @@ import checkpatch
 import command
 import gitutil
 import patchstream
+import project
 import settings
 import terminal
 import test
@@ -59,6 +60,9 @@ parser.add_option('--cc-cmd', dest='cc_cmd', type='string', 
action='store',
default=None, help='Output cc list for patch file (used by git)')
 parser.add_option('--no-tags', action='store_false', dest='process_tags',
   default=True, help="Don't process subject tags as aliaes")
+parser.add_option('--project', default=project.DetectProject(),
+  help="Project name; affects default option values and "
+  "aliases [default: %default]")
 
 parser.usage = """patman [options]
 
@@ -66,7 +70,10 @@ Create patches from commits in a branch, check them and 
email them as
 specified by tags you place in the commits. Use -n to """
 
 
-settings.Setup(parser, '')
+# Parse options twice: first to get the project and second to handle
+# defaults properly (which depends on project).
+(options, args) = parser.parse_args()
+settings.Setup(parser, options.project, '')
 (options, args) = parser.parse_args()
 
 # Run our meagre tests
diff --git a/tools/patman/project.py b/tools/patman/project.py
new file mode 100644
index 000..4f7b2b3
--- /dev/null
+++ b/tools/patman/project.py
@@ -0,0 +1,43 @@
+# Copyright (c) 2012 The Chromium OS Authors.
+#
+# See file CREDITS for list of people who contributed to this
+# project.
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License as
+# published by the Free Software Foundation; either version 2 of
+# the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+# MA 02111-1307 USA
+#
+
+import os.path
+
+import gitutil
+
+def DetectProject():
+"""Autodetect the name of the current project.
+
+This looks for signature files/directories that are unlikely to exist 
except
+in the given project.
+
+Returns:
+The name of the project, like "linux" or "u-boot".  Returns "unknown"
+if we can't detect the project.
+"""
+top_level = gitutil.GetTopLevel()
+
+if os.path.exists(os.path.join(top_level, "include", "u-boot")):
+return "u-boot"
+elif os.path.exists(os.path.join(top_level, "kernel")):
+return "linux"
+
+return "unknown"
diff --git a/tools/patman/settings.py b/tools/patman/settings.py
index 5208f7d..084d1b8 100644
--- a/tools/patman/settings.py
+++ b/tools/patman/settings.py
@@ -26,6 +26,140 @@ import re
 import command
 import gitutil
 
+"""Default settings per-project.
+
+These are used by _ProjectConfigParser.  Settings names should match
+the "dest" of the option parser from patman.py.
+"""
+_default_settings = {
+"u-boot": {},
+"linux": {
+"process_tags": "False",
+}
+}
+
+class _ProjectConfigParser(ConfigParser.SafeConfigParser):
+"""ConfigParser that handles projects.
+
+There are two main goals of this class:
+- Load project-specific default settings.
+- Merge general default settings/aliases with project-specific ones.
+
+# Sample config used for tests below...
+>>> import StringIO
+>>> sample_config = '''
+.

[U-Boot] [PATCH 2/2] patman: Add all CC addresses to the cover letter

2012-11-30 Thread Doug Anderson
If we're sending a cover letter make sure to CC everyone that we're
CCing on each of the individual patches.

Signed-off-by: Doug Anderson 
---
 tools/patman/patman.py |2 +-
 tools/patman/series.py |   12 +++-
 2 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/tools/patman/patman.py b/tools/patman/patman.py
index de8314a..4181d80 100755
--- a/tools/patman/patman.py
+++ b/tools/patman/patman.py
@@ -140,7 +140,7 @@ else:
 options.count + options.start):
 ok = False
 
-cc_file = series.MakeCcFile(options.process_tags)
+cc_file = series.MakeCcFile(options.process_tags, cover_fname)
 
 # Email the patches out (giving the user time to check / cancel)
 cmd = ''
diff --git a/tools/patman/series.py b/tools/patman/series.py
index ad8288d..083af0f 100644
--- a/tools/patman/series.py
+++ b/tools/patman/series.py
@@ -19,6 +19,7 @@
 # MA 02111-1307 USA
 #
 
+import itertools
 import os
 
 import gitutil
@@ -138,6 +139,9 @@ class Series(dict):
 print 'Prefix:\t ', self.get('prefix')
 if self.cover:
 print 'Cover: %d lines' % len(self.cover)
+all_ccs = itertools.chain(*self._generated_cc.values())
+for email in set(all_ccs):
+print '  Cc: ',email
 if cmd:
 print 'Git command: %s' % cmd
 
@@ -201,27 +205,33 @@ class Series(dict):
 str = 'Change log exists, but no version is set'
 print col.Color(col.RED, str)
 
-def MakeCcFile(self, process_tags):
+def MakeCcFile(self, process_tags, cover_fname):
 """Make a cc file for us to use for per-commit Cc automation
 
 Also stores in self._generated_cc to make ShowActions() faster.
 
 Args:
 process_tags: Process tags as if they were aliases
+cover_fname: If non-None the name of the cover letter.
 Return:
 Filename of temp file created
 """
 # Look for commit tags (of the form 'xxx:' at the start of the subject)
 fname = '/tmp/patman.%d' % os.getpid()
 fd = open(fname, 'w')
+all_ccs = []
 for commit in self.commits:
 list = []
 if process_tags:
 list += gitutil.BuildEmailList(commit.tags)
 list += gitutil.BuildEmailList(commit.cc_list)
+all_ccs += list
 print >>fd, commit.patch, ', '.join(list)
 self._generated_cc[commit.patch] = list
 
+if cover_fname:
+print >>fd, cover_fname, ', '.join(set(all_ccs))
+
 fd.close()
 return fname
 
-- 
1.7.7.3

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


[U-Boot] [PATCH 1/4] patman: Add a call to get_maintainer.pl if it exists

2012-11-30 Thread Doug Anderson
For Linux the best way to figure out where to send a patch is with the
"get_maintainer.pl" script.  Add support for calling it from patman.
Support is added unconditionally for "scripts/get_maintainer.pl" in
case it is helpful for any other projects.

Signed-off-by: Doug Anderson 
---
 tools/patman/README|   11 ++-
 tools/patman/get_maintainer.py |   63 
 tools/patman/series.py |2 +
 3 files changed, 74 insertions(+), 2 deletions(-)
 create mode 100644 tools/patman/get_maintainer.py

diff --git a/tools/patman/README b/tools/patman/README
index dc3957c..903d02f 100644
--- a/tools/patman/README
+++ b/tools/patman/README
@@ -43,6 +43,9 @@ Series-to: fred.bl...@napier.co.nz
 
 in one of your commits, the series will be sent there.
 
+In Linux this will also call get_maintainer.pl on each of your
+patches automatically.
+
 
 How to use this tool
 
@@ -65,8 +68,12 @@ will get a consistent result each time.
 How to configure it
 ===
 
-For most cases patman will locate and use the file 'doc/git-mailrc' in
-your U-Boot directory. This contains most of the aliases you will need.
+For most cases of using patman for U-Boot developement patman will
+locate and use the file 'doc/git-mailrc' in your U-Boot directory.
+This contains most of the aliases you will need.
+
+For Linux the 'scripts/get_maintainer.pl' handles figuring out where
+to send patches pretty well.
 
 During the first run patman creates a config file for you by taking the default
 user name and email address from the global .gitconfig file.
diff --git a/tools/patman/get_maintainer.py b/tools/patman/get_maintainer.py
new file mode 100644
index 000..cb11373
--- /dev/null
+++ b/tools/patman/get_maintainer.py
@@ -0,0 +1,63 @@
+# Copyright (c) 2012 The Chromium OS Authors.
+#
+# See file CREDITS for list of people who contributed to this
+# project.
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License as
+# published by the Free Software Foundation; either version 2 of
+# the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+# MA 02111-1307 USA
+#
+
+import command
+import gitutil
+import os
+
+def FindGetMaintainer():
+"""Look for the get_maintainer.pl script.
+
+Returns:
+If the script is found we'll return a path to it; else None.
+"""
+try_list = [
+os.path.join(gitutil.GetTopLevel(), 'scripts'),
+]
+# Look in the list
+for path in try_list:
+fname = os.path.join(path, 'get_maintainer.pl')
+if os.path.isfile(fname):
+return fname
+
+return None
+
+def GetMaintainer(fname, verbose=False):
+"""Run get_maintainer.pl on a file if we find it.
+
+We look for get_maintainer.pl in the 'scripts' directory at the top of
+git.  If we find it we'll run it.  If we don't find get_maintainer.pl
+then we fail silently.
+
+Args:
+fname: Path to the patch file to run get_maintainer.pl on.
+
+Returns:
+A list of email addresses to CC to.
+"""
+get_maintainer = FindGetMaintainer()
+if not get_maintainer:
+if verbose:
+print "WARNING: Couldn't find get_maintainer.pl"
+return []
+
+stdout = command.Output(get_maintainer, '--norolestats', fname)
+return stdout.splitlines()
diff --git a/tools/patman/series.py b/tools/patman/series.py
index 083af0f..6c5c570 100644
--- a/tools/patman/series.py
+++ b/tools/patman/series.py
@@ -22,6 +22,7 @@
 import itertools
 import os
 
+import get_maintainer
 import gitutil
 import terminal
 
@@ -225,6 +226,7 @@ class Series(dict):
 if process_tags:
 list += gitutil.BuildEmailList(commit.tags)
 list += gitutil.BuildEmailList(commit.cc_list)
+list += get_maintainer.GetMaintainer(commit.patch)
 all_ccs += list
 print >>fd, commit.patch, ', '.join(list)
 self._generated_cc[commit.patch] = list
-- 
1.7.7.3

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


[U-Boot] [PATCH 2/4] patman: Add support for settings in .patman

2012-11-30 Thread Doug Anderson
This patch adds support for a [settings] section in the .patman file.
In this section you can add settings that will affect the default
values for command-line options.

Support is added in a generic way such that any setting can be updated
by just referring to the "dest" of the option that is passed to the
option parser.  At the moment options that would make sense to put in
settings are "ignore_errors", "process_tags", and "verbose".  You
could override them like:

 [settings]
 ignore_errors: True
 process_tags: False
 verbose: True

The settings functionality is also used in a future change which adds
support for per-project settings.

Signed-off-by: Doug Anderson 
---
 tools/patman/README  |   16 
 tools/patman/gitutil.py  |2 --
 tools/patman/patman.py   |3 +++
 tools/patman/settings.py |   39 +++
 4 files changed, 54 insertions(+), 6 deletions(-)

diff --git a/tools/patman/README b/tools/patman/README
index 903d02f..6ca5b5b 100644
--- a/tools/patman/README
+++ b/tools/patman/README
@@ -98,6 +98,22 @@ The checkpatch.pl in the U-Boot tools/ subdirectory will be 
located and
 used. Failing that you can put it into your path or ~/bin/checkpatch.pl
 
 
+If you want to change the defaults for patman's command-line arguments,
+you can add a [settings] section to your .patman file.  This can be used
+for any command line option by referring to the "dest" for the option in
+patman.py.  For reference, the useful ones (at the moment) shown below
+(all with the non-default setting):
+
+>>>
+
+[settings]
+ignore_errors: True
+process_tags: False
+verbose: True
+
+<<<
+
+
 How to run it
 =
 
diff --git a/tools/patman/gitutil.py b/tools/patman/gitutil.py
index 72d37a0..e7753cf 100644
--- a/tools/patman/gitutil.py
+++ b/tools/patman/gitutil.py
@@ -377,8 +377,6 @@ def GetDefaultUserEmail():
 
 def Setup():
 """Set up git utils, by reading the alias files."""
-settings.Setup('')
-
 # Check for a git alias file also
 alias_fname = GetAliasFile()
 if alias_fname:
diff --git a/tools/patman/patman.py b/tools/patman/patman.py
index 4181d80..b327c67 100755
--- a/tools/patman/patman.py
+++ b/tools/patman/patman.py
@@ -34,6 +34,7 @@ import checkpatch
 import command
 import gitutil
 import patchstream
+import settings
 import terminal
 import test
 
@@ -64,6 +65,8 @@ parser.usage = """patman [options]
 Create patches from commits in a branch, check them and email them as
 specified by tags you place in the commits. Use -n to """
 
+
+settings.Setup(parser, '')
 (options, args) = parser.parse_args()
 
 # Run our meagre tests
diff --git a/tools/patman/settings.py b/tools/patman/settings.py
index 4dda17b..5208f7d 100644
--- a/tools/patman/settings.py
+++ b/tools/patman/settings.py
@@ -88,13 +88,43 @@ def CreatePatmanConfigFile(config_fname):
 print >>f, "[alias]\nme: %s <%s>" % (name, email)
 f.close();
 
-def Setup(config_fname=''):
+def _UpdateDefaults(parser, config):
+"""Update the given OptionParser defaults based on config.
+
+We'll walk through all of the settings from the parser
+For each setting we'll look for a default in the option parser.
+If it's found we'll update the option parser default.
+
+The idea here is that the .patman file should be able to update
+defaults but that command line flags should still have the final
+say.
+
+Args:
+parser: An instance of an OptionParser whose defaults will be
+updated.
+config: An instance of SafeConfigParser that we will query
+for settings.
+"""
+defaults = parser.get_default_values()
+for name, val in config.items('settings'):
+if hasattr(defaults, name):
+default_val = getattr(defaults, name)
+if isinstance(default_val, bool):
+val = config.getboolean('settings', name)
+elif isinstance(default_val, int):
+val = config.getint('settings', name)
+parser.set_default(name, val)
+else:
+print "WARNING: Unknown setting %s" % name
+
+def Setup(parser, config_fname=''):
 """Set up the settings module by reading config files.
 
 Args:
+parser: The parser to update
 config_fname:   Config filename to read ('' for default)
 """
-settings = ConfigParser.SafeConfigParser()
+config = ConfigParser.SafeConfigParser()
 if config_fname == '':
 config_fname = '%s/.patman' % os.getenv('HOME')
 
@@ -102,11 +132,12 @@ def Setup(config_fname=''):
 print "No config file found ~/.patman\nCreating one...\n"
 CreatePatmanConfigFile(config_fname)
 
-settings.read(config_fname)
+config.read(config_fname)
 
-for name, value in settings.items('alias'):
+for name, value in config.items('alias'):
 alias[name] = value.split(',')
 
+_UpdateDefaults(parser, config)
 
 # These are the aliases we understand, indexed by alia

[U-Boot] [PATCH 4/4] patman: Add settings to the list of modules to doctest

2012-11-30 Thread Doug Anderson
The settings modules now has doctests, so run them.

Signed-off-by: Doug Anderson 
---
 tools/patman/patman.py |5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/tools/patman/patman.py b/tools/patman/patman.py
index 54a252e..6825de4 100755
--- a/tools/patman/patman.py
+++ b/tools/patman/patman.py
@@ -85,8 +85,9 @@ if options.test:
 result = unittest.TestResult()
 suite.run(result)
 
-suite = doctest.DocTestSuite('gitutil')
-suite.run(result)
+for module in ['gitutil', 'settings']:
+suite = doctest.DocTestSuite(module)
+suite.run(result)
 
 # TODO: Surely we can just 'print' result?
 print result
-- 
1.7.7.3

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


[U-Boot] [PATCH 1/2] patman: Cache the CC list from MakeCcFile() for use in ShowActions()

2012-11-30 Thread Doug Anderson
Currently we go through and generate the CC list for patches twice.
This gets slow when (in a future CL) we add a call to
get_maintainer.pl on Linux.  Instead of doing things twice, just cache
the CC list when it is first generated.

Signed-off-by: Doug Anderson 
---
 tools/patman/patman.py |6 --
 tools/patman/series.py |   13 +
 2 files changed, 13 insertions(+), 6 deletions(-)

diff --git a/tools/patman/patman.py b/tools/patman/patman.py
index cfe06d0..de8314a 100755
--- a/tools/patman/patman.py
+++ b/tools/patman/patman.py
@@ -140,14 +140,16 @@ else:
 options.count + options.start):
 ok = False
 
+cc_file = series.MakeCcFile(options.process_tags)
+
 # Email the patches out (giving the user time to check / cancel)
 cmd = ''
 if ok or options.ignore_errors:
-cc_file = series.MakeCcFile(options.process_tags)
 cmd = gitutil.EmailPatches(series, cover_fname, args,
 options.dry_run, cc_file)
-os.remove(cc_file)
 
 # For a dry run, just show our actions as a sanity check
 if options.dry_run:
 series.ShowActions(args, cmd, options.process_tags)
+
+os.remove(cc_file)
diff --git a/tools/patman/series.py b/tools/patman/series.py
index d2971f4..ad8288d 100644
--- a/tools/patman/series.py
+++ b/tools/patman/series.py
@@ -46,6 +46,11 @@ class Series(dict):
 self.notes = []
 self.changes = {}
 
+# Written in MakeCcFile()
+#  key: name of patch file
+#  value: list of email addresses
+self._generated_cc = {}
+
 # These make us more like a dictionary
 def __setattr__(self, name, value):
 self[name] = value
@@ -109,10 +114,7 @@ class Series(dict):
 for upto in range(len(args)):
 commit = self.commits[upto]
 print col.Color(col.GREEN, '   %s' % args[upto])
-cc_list = []
-if process_tags:
-cc_list += gitutil.BuildEmailList(commit.tags)
-cc_list += gitutil.BuildEmailList(commit.cc_list)
+cc_list = list(self._generated_cc[commit.patch])
 
 # Skip items in To list
 if 'to' in self:
@@ -202,6 +204,8 @@ class Series(dict):
 def MakeCcFile(self, process_tags):
 """Make a cc file for us to use for per-commit Cc automation
 
+Also stores in self._generated_cc to make ShowActions() faster.
+
 Args:
 process_tags: Process tags as if they were aliases
 Return:
@@ -216,6 +220,7 @@ class Series(dict):
 list += gitutil.BuildEmailList(commit.tags)
 list += gitutil.BuildEmailList(commit.cc_list)
 print >>fd, commit.patch, ', '.join(list)
+self._generated_cc[commit.patch] = list
 
 fd.close()
 return fname
-- 
1.7.7.3

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


Re: [U-Boot] [PATCH v2 04/10] arm: Add CONFIG_DELAY_ENVIRONMENT to delay environment loading

2012-11-30 Thread Doug Anderson
On Fri, Nov 30, 2012 at 3:01 PM, Simon Glass  wrote:
> This option delays loading of the environment until later, so that only the
> default environment will be available to U-Boot.
>
> This can address the security risk of untrusted data being used during boot.
>
> Any time you load untrusted data you expose yourself to a bug in the
> code. The attacker gets to choose the data so can sometimes carefully
> craft it to exploit a bug. We try to avoid touching user-controlled
> data during a verified boot unless strictly necessary. Since the
> default environment is good enough in this case (or you would just
> change it), this gets around the problem by just not loading the
> environment.
>
> When CONFIG_DELAY_ENVIRONMENT is defined, it is convenient to have a
> run-time way of enabling loading of the environment. Add this to the
> fdt as /config/delay-environment.
>
> Note: This patch depends on http://patchwork.ozlabs.org/patch/194342/
>
> Signed-off-by: Doug Anderson 
> Signed-off-by: Simon Glass 
> ---
> Changes in v2:
> - Update commit message to provide more detail
>
>  README   |9 +
>  arch/arm/lib/board.c |   29 +++--
>  2 files changed, 36 insertions(+), 2 deletions(-)
>
> diff --git a/README b/README
> index b9a3685..d26ce5b 100644
> --- a/README
> +++ b/README
> @@ -2329,6 +2329,15 @@ CBFS (Coreboot Filesystem) support
> run-time determined information about the hardware to the
> environment.  These will be named board_name, board_rev.
>
> +   CONFIG_DELAY_ENVIRONMENT
> +
> +   Normally the environment is loaded when the board is
> +   intialised so that it is available to U-Boot. This inhibits
> +   that so that the environment is not available until
> +   explicitly loaded later by U-Boot code. With CONFIG_OF_CONTROL
> +   this is instead controlled by the value of
> +   /config/load-environment.
> +
>  - DataFlash Support:
> CONFIG_HAS_DATAFLASH
>
> diff --git a/arch/arm/lib/board.c b/arch/arm/lib/board.c
> index 262a3ca..7d1927e 100644
> --- a/arch/arm/lib/board.c
> +++ b/arch/arm/lib/board.c
> @@ -40,6 +40,7 @@
>
>  #include 
>  #include 
> +#include 
>  #include 
>  #include 
>  #include 
> @@ -476,7 +477,28 @@ static char *failed = "*** failed ***\n";
>  #endif
>
>  /*
> - 
> + * Tell if it's OK to load the environment early in boot.
> + *
> + * If CONFIG_OF_CONFIG is defined, we'll check with the FDT to see
> + * if this is OK (defaulting to saying it's not OK).
> + *
> + * NOTE: Loading the environment early can be a bad idea if security is
> + *   important, since no verification is done on the environment.
> + *
> + * @return 0 if environment should not be loaded, !=0 if it is ok to load
> + */
> +static int should_load_env(void)
> +{
> +#ifdef CONFIG_OF_CONTROL
> +   return fdtdec_get_config_int(gd->fdt_blob, "load-environment", 0);
> +#elif defined CONFIG_DELAY_ENVIRONMENT
> +   return 0;
> +#else
> +   return 1;
> +#endif
> +}
> +
> +/
>   *
>   * This is the next part if the initialization sequence: we are now
>   * running from RAM and have a "normal" C environment, i. e. global
> @@ -583,7 +605,10 @@ void board_init_r(gd_t *id, ulong dest_addr)
>  #endif
>
> /* initialize environment */
> -   env_relocate();
> +   if (should_load_env())
> +   env_relocate();
> +   else
> +   set_default_env(NULL);
>
>  #if defined(CONFIG_CMD_PCI) || defined(CONFIG_PCI)
> arm_pci_init();
> --
> 1.7.7.3
>

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


Re: [U-Boot] [PATCH v2] mxs: i2c: Implement algorithm to set up arbitrary i2c speed

2012-11-30 Thread Heiko Schocher

Hello Marek,

On 30.11.2012 16:28, Marek Vasut wrote:

This algorithm computes the values of TIMING{0,1,2} registers for the
MX28 I2C block. This algorithm was derived by using a scope, but the
result seems correct.

The resulting values programmed into the registers do not correlate
with the contents in datasheet. When using the values from the datasheet,
the I2C clock were completely wrong.

Signed-off-by: Marek Vasut
Cc: Stefano Babic
Cc: Fabio Estevam
Cc: Wolfgang Denk
---
  arch/arm/cpu/arm926ejs/mxs/clock.c|2 +
  arch/arm/include/asm/arch-mxs/clock.h |1 +
  drivers/i2c/mxs_i2c.c |   75 ++---
  3 files changed, 26 insertions(+), 52 deletions(-)

v2: Properly implement XTAL clock retrieval. The i2c clock are derived from the
 24MHz XTAL clock.


[...]

diff --git a/drivers/i2c/mxs_i2c.c b/drivers/i2c/mxs_i2c.c
index 006fb91..b040535 100644
--- a/drivers/i2c/mxs_i2c.c
+++ b/drivers/i2c/mxs_i2c.c
@@ -28,6 +28,7 @@

  #include
  #include
+#include
  #include
  #include
  #include
@@ -40,6 +41,7 @@ void mxs_i2c_reset(void)
  {
struct mxs_i2c_regs *i2c_regs = (struct mxs_i2c_regs *)MXS_I2C0_BASE;
int ret;
+   int speed = i2c_get_bus_speed();

ret = mxs_reset_block(&i2c_regs->hw_i2c_ctrl0_reg);
if (ret) {
@@ -53,6 +55,8 @@ void mxs_i2c_reset(void)
&i2c_regs->hw_i2c_ctrl1_clr);

writel(I2C_QUEUECTRL_PIO_QUEUE_MODE,&i2c_regs->hw_i2c_queuectrl_set);
+
+   i2c_set_bus_speed(speed);
  }


This change is not described in the patch description, please fix.


  void mxs_i2c_setup_read(uint8_t chip, int len)
@@ -210,62 +214,29 @@ int i2c_probe(uchar chip)
return ret;
  }

-static struct mxs_i2c_speed_table {

[...]

  int i2c_set_bus_speed(unsigned int speed)
  {
struct mxs_i2c_regs *i2c_regs = (struct mxs_i2c_regs *)MXS_I2C0_BASE;
-   struct mxs_i2c_speed_table *spd = mxs_i2c_speed_to_cfg(speed);

-   if (!spd) {
-   printf("MXS I2C: Invalid speed selected (%d Hz)\n", speed);
+   uint32_t clk = mxc_get_clock(MXC_XTAL_CLK);
+   uint32_t base = ((clk / speed) - 38) / 2;
+   uint16_t high_count = base + 3;
+   uint16_t low_count = base - 3;
+   uint16_t rcv_count = (high_count * 3) / 4;
+   uint16_t xmit_count = low_count / 4;


a lot of magic constants ...


+
+   if (speed>  54) {
+   printf("MXS I2C: Speed too high (%d Hz)\n", speed);
+   return -EINVAL;
+   }
+
+   if (speed<  12000) {
+   printf("MXS I2C: Speed too low (%d Hz)\n", speed);
return -EINVAL;
}

-   writel(spd->timing0,&i2c_regs->hw_i2c_timing0);
-   writel(spd->timing1,&i2c_regs->hw_i2c_timing1);
+   writel((high_count<<  16) | rcv_count,&i2c_regs->hw_i2c_timing0);
+   writel((low_count<<  16) | xmit_count,&i2c_regs->hw_i2c_timing1);

 ^^
 spaces



writel((0x0030<<  I2C_TIMING2_BUS_FREE_OFFSET) |
(0x0030<<  I2C_TIMING2_LEADIN_COUNT_OFFSET),
@@ -277,12 +248,12 @@ int i2c_set_bus_speed(unsigned int speed)
  unsigned int i2c_get_bus_speed(void)
  {
struct mxs_i2c_regs *i2c_regs = (struct mxs_i2c_regs *)MXS_I2C0_BASE;
-   uint32_t timing0, timing1;
+   uint32_t clk = mxc_get_clock(MXC_XTAL_CLK);
+   uint32_t timing0;

timing0 = readl(&i2c_regs->hw_i2c_timing0);
-   timing1 = readl(&i2c_regs->hw_i2c_timing1);

-   return mxs_i2c_cfg_to_speed(timing0, timing1);
+   return clk / timing0>>  16) - 3) * 2) + 38);

^
spaces

... and here a lot of magic constants too ... as this is a result of
measuring ... we should at least note here, that we have this values
from a scope session and the values in the manual seem to be not
correct ...

Hmm... I am a little confused ... you write the i2c_regs->hw_i2c_timing{0,1,2}
registers in i2c_set_bus_speed() but you return in i2c_get_bus_speed()
just results from reading the i2c_regs->hw_i2c_timing0 register only
and do some funny calculations ... is this correct?


  }

  void i2c_init(int speed, int slaveadd)


Thanks!

bye,
Heiko
--
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH v2] mxs: i2c: Implement algorithm to set up arbitrary i2c speed

2012-11-30 Thread Marek Vasut
Dear Heiko Schocher,

> Hello Marek,
[...]
> > diff --git a/drivers/i2c/mxs_i2c.c b/drivers/i2c/mxs_i2c.c
> > index 006fb91..b040535 100644
> > --- a/drivers/i2c/mxs_i2c.c
> > +++ b/drivers/i2c/mxs_i2c.c
> > @@ -28,6 +28,7 @@
> > 
> >   #include
> >   #include
> > 
> > +#include
> > 
> >   #include
> >   #include
> >   #include
> > 
> > @@ -40,6 +41,7 @@ void mxs_i2c_reset(void)
> > 
> >   {
> >   
> > struct mxs_i2c_regs *i2c_regs = (struct mxs_i2c_regs *)MXS_I2C0_BASE;
> > int ret;
> > 
> > +   int speed = i2c_get_bus_speed();
> > 
> > ret = mxs_reset_block(&i2c_regs->hw_i2c_ctrl0_reg);
> > if (ret) {
> > 
> > @@ -53,6 +55,8 @@ void mxs_i2c_reset(void)
> > 
> > &i2c_regs->hw_i2c_ctrl1_clr);
> > 
> > writel(I2C_QUEUECTRL_PIO_QUEUE_MODE,&i2c_regs->hw_i2c_queuectrl_set);
> > 
> > +
> > +   i2c_set_bus_speed(speed);
> > 
> >   }
> 
> This change is not described in the patch description, please fix.

I suspect I'll move this to a separate patch.

> >   void mxs_i2c_setup_read(uint8_t chip, int len)
> > 
> > @@ -210,62 +214,29 @@ int i2c_probe(uchar chip)
> > 
> > return ret;
> >   
> >   }
> > 
> > -static struct mxs_i2c_speed_table {
> 
> [...]
> 
> >   int i2c_set_bus_speed(unsigned int speed)
> >   {
> >   
> > struct mxs_i2c_regs *i2c_regs = (struct mxs_i2c_regs *)MXS_I2C0_BASE;
> > 
> > -   struct mxs_i2c_speed_table *spd = mxs_i2c_speed_to_cfg(speed);
> > 
> > -   if (!spd) {
> > -   printf("MXS I2C: Invalid speed selected (%d Hz)\n", speed);
> > +   uint32_t clk = mxc_get_clock(MXC_XTAL_CLK);
> > +   uint32_t base = ((clk / speed) - 38) / 2;
> > +   uint16_t high_count = base + 3;
> > +   uint16_t low_count = base - 3;
> > +   uint16_t rcv_count = (high_count * 3) / 4;
> > +   uint16_t xmit_count = low_count / 4;
> 
> a lot of magic constants ...

True ... and they have no other meaning than to align stuff on the scope ;-)

> > +
> > +   if (speed>  54) {
> > +   printf("MXS I2C: Speed too high (%d Hz)\n", speed);
> > +   return -EINVAL;
> > +   }
> > +
> > +   if (speed<  12000) {
> > +   printf("MXS I2C: Speed too low (%d Hz)\n", speed);
> > 
> > return -EINVAL;
> > 
> > }
> > 
> > -   writel(spd->timing0,&i2c_regs->hw_i2c_timing0);
> > -   writel(spd->timing1,&i2c_regs->hw_i2c_timing1);
> > +   writel((high_count<<  16) | rcv_count,&i2c_regs->hw_i2c_timing0);
> > +   writel((low_count<<  16) | xmit_count,&i2c_regs->hw_i2c_timing1);
> 
>   ^^
>   spaces

Could this be your mailer's issue?

[...]

> ... and here a lot of magic constants too ... as this is a result of
> measuring ... we should at least note here, that we have this values
> from a scope session and the values in the manual seem to be not
> correct ...

True.

> Hmm... I am a little confused ... you write the
> i2c_regs->hw_i2c_timing{0,1,2} registers in i2c_set_bus_speed() but you
> return in i2c_get_bus_speed() just results from reading the
> i2c_regs->hw_i2c_timing0 register only and do some funny calculations ...
> is this correct?

Yes, the speed is configured upon boot anyway, so the timing0 register contains 
result of previous call to i2c_set_bus_speed(). And if it doesn't, we can't 
properly determine the speed anyway :(

> >   }
> >   
> >   void i2c_init(int speed, int slaveadd)
> 
> Thanks!
> 
> bye,
> Heiko
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] U-Boot for MIPS AR7161

2012-11-30 Thread Drassal, Allan
Hi Dmytro,

Thanks for your detailed response.  I corrected some details in the ar71xx.cfg 
file and am posting them below this message.
With this, I am convinced that my JTAG interface is working and the DRAM 
controller is getting setup correctly.
Now, I am just needing some code to load into the processor.
I would like to port U-Boot over to this platform, but it is a little above my 
experience level at the moment.
Perhaps it has already been done and I am not looking in the right place.
This platform is technically based on AP96 I believe though.

I connected up the two devices today and did these checks, these are the 
results...
However, the response from the two devices is slightly different...
You can see the results below...

I needed to do a "reset init" before the file would load successfully...
I assume the DRAM controller is initialized at this point and not if I just 
open up openOCD.
if I just did a straight "halt" without a "reset init", then the PC is different

On the non-functioning device I am assuming it begins to execute code at 
0xbfc00380, but runs into something it can't execute and either loops or 
freezes there.

> reset
JTAG tap: ar71xx.cpu tap/device found: 0x0001 (mfg: 0x000, part: 0x, 
ver: 0x0)
> halt
target state: halted
target halted in MIPS32 mode due to debug-request, pc: 0xbfc00380


results from broken device
> halt
target state: halted
target halted in MIPS32 mode due to debug-request, pc: 0xbfc00380
> mdw 0xb800 0x10
0xb800: 77bc8cd0 81d106a8 0133 0002  2000 00ff 
0081 
0xb820: 0081 0081 0081     
 
> mdw 0xb805
0xb805: 001040a3 
> mdw 0xb8050008
0xb8050008:  
> mdw 0xb805000c
0xb805000c:  

results from working device
ar7100> md 0xb800 0x10  
b800: 77b8884e 812cd6a8 0033 w..N.,.3   
b810:  44a6 00ff 0007..D.   
b820: 0007 0007 0007    
b830:       
ar7100> md 0xb805 0x1   
b805: c0140180  
ar7100> md 0xb8050008 0x1   
b8050008:   
ar7100> md 0xb805000c 0x1   
b805000c:   
ar7100> 

results of loading a file and checking the read memory is the same
> reset init
JTAG tap: ar71xx.cpu tap/device found: 0x0001 (mfg: 0x000, part: 0x, 
ver: 0x0)
target state: halted
target halted in MIPS32 mode due to debug-request, pc: 0xbfc0
> load_image mtd0.bin 0xa001
327680 bytes written at address 0xa001
downloaded 327680 bytes in 3.917356s (81.688 KiB/s)
> mdw 0xa001 0x10
0xa001: 10ff  10fd  1dbb  1db9 
 
0xa0010020: 1db7  1db5  1db3  1db1 
 
> mdw 0xa001 0x10
0xa001: 10ff  10fd  1dbb  1db9 
 
0xa0010020: 1db7  1db5  1db3  1db1 
 
> mdw 0xa001 0x10
0xa001: 10ff  10fd  1dbb  1db9 
 
0xa0010020: 1db7  1db5  1db3  1db1 
 



ar71xx.cfg:
# Atheros AR71xx MIPS 24Kc SoC.
# tested on PB44 refererence board
 
adapter_nsrst_delay 100
jtag_ntrst_delay 100
 
reset_config trst_and_srst
 
set CHIPNAME ar71xx
 
jtag newtap $CHIPNAME cpu -irlen 5 -ircapture 0x1 -irmask 0x1f -expected-id 1
 
set TARGETNAME $CHIPNAME.cpu
target create $TARGETNAME mips_m4k -endian big -chain-position $TARGETNAME
 
$TARGETNAME configure -event reset-halt-post {
#setup PLL to lowest common denominator 300/300/150 setting
mww 0xb805 0x000f40a3   ;# reset val + CPU:3 DDR:3 AHB:0
mww 0xb805 0x800f40a3   ;# send to PLL
 
#next command will reset for PLL changes to take effect
mww 0xb8050008 3;# set reset_switch and clock_switch 
(resets SoC)
}
 
$TARGETNAME configure -event reset-init {
#complete pll initialization
mww 0xb805 0x800f0080   ;# set sw_update bit
mww 0xb8050008 0;# clear reset_switch bit
mww 0xb805 0x800f00e8   ;# clr pwrdwn & bypass
mww 0xb8050008 1;# set clock_switch bit
sleep 1 ;# wait for lock
 
# Setup DDR config and flash mapping
mww 0xb800 0xefbc8cd0   ;# DDR cfg cdl val (rst: 0x5bfc8d0)
mww 0xb804 0x8e7156a2   

[U-Boot] [PATCH 1/2] mxs: i2c: Restore speed setting after block reset

2012-11-30 Thread Marek Vasut
The I2C block reset configures the I2C bus speed to strange value.
Read the I2C speed from the block before reseting the block and
restore it afterwards, so the I2C operates correctly. This issue
can be replicated by doing unsuccessful I2C transfer, after such
transfer finishes, the I2C block clock speed is misconfigured.

Signed-off-by: Marek Vasut 
Cc: Heiko Schocher 
Cc: Fabio Estevam 
---
 drivers/i2c/mxs_i2c.c |3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/i2c/mxs_i2c.c b/drivers/i2c/mxs_i2c.c
index 006fb91..73a6659 100644
--- a/drivers/i2c/mxs_i2c.c
+++ b/drivers/i2c/mxs_i2c.c
@@ -40,6 +40,7 @@ void mxs_i2c_reset(void)
 {
struct mxs_i2c_regs *i2c_regs = (struct mxs_i2c_regs *)MXS_I2C0_BASE;
int ret;
+   int speed = i2c_get_bus_speed();
 
ret = mxs_reset_block(&i2c_regs->hw_i2c_ctrl0_reg);
if (ret) {
@@ -53,6 +54,8 @@ void mxs_i2c_reset(void)
&i2c_regs->hw_i2c_ctrl1_clr);
 
writel(I2C_QUEUECTRL_PIO_QUEUE_MODE, &i2c_regs->hw_i2c_queuectrl_set);
+
+   i2c_set_bus_speed(speed);
 }
 
 void mxs_i2c_setup_read(uint8_t chip, int len)
-- 
1.7.10.4

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


[U-Boot] [PATCH 2/2 V3] mxs: i2c: Implement algorithm to set up arbitrary i2c speed

2012-11-30 Thread Marek Vasut
This algorithm computes the values of TIMING{0,1,2} registers for the
MX28 I2C block. This algorithm was derived by using a scope, but the
result seems correct.

The resulting values programmed into the registers do not correlate
with the contents in datasheet. When using the values from the datasheet,
the I2C clock were completely wrong.

Signed-off-by: Marek Vasut 
Cc: Stefano Babic 
Cc: Fabio Estevam 
Cc: Wolfgang Denk 
---
 arch/arm/cpu/arm926ejs/mxs/clock.c|2 +
 arch/arm/include/asm/arch-mxs/clock.h |1 +
 drivers/i2c/mxs_i2c.c |   87 +
 3 files changed, 37 insertions(+), 53 deletions(-)

V2: Properly implement XTAL clock retrieval. The i2c clock are derived from the
24MHz XTAL clock.

V3: Split away reset speed fix
Add comment about the funny algorithm

diff --git a/arch/arm/cpu/arm926ejs/mxs/clock.c 
b/arch/arm/cpu/arm926ejs/mxs/clock.c
index bfea6ab..4ff19c3 100644
--- a/arch/arm/cpu/arm926ejs/mxs/clock.c
+++ b/arch/arm/cpu/arm926ejs/mxs/clock.c
@@ -333,6 +333,8 @@ uint32_t mxc_get_clock(enum mxc_clock clk)
return mx28_get_sspclk(MXC_SSPCLK2);
case MXC_SSP3_CLK:
return mx28_get_sspclk(MXC_SSPCLK3);
+   case MXC_XTAL_CLK:
+   return XTAL_FREQ_KHZ * 1000;
}
 
return 0;
diff --git a/arch/arm/include/asm/arch-mxs/clock.h 
b/arch/arm/include/asm/arch-mxs/clock.h
index 1700fe3..3d39ef2 100644
--- a/arch/arm/include/asm/arch-mxs/clock.h
+++ b/arch/arm/include/asm/arch-mxs/clock.h
@@ -35,6 +35,7 @@ enum mxc_clock {
MXC_SSP1_CLK,
MXC_SSP2_CLK,
MXC_SSP3_CLK,
+   MXC_XTAL_CLK,
 };
 
 enum mxs_ioclock {
diff --git a/drivers/i2c/mxs_i2c.c b/drivers/i2c/mxs_i2c.c
index 73a6659..b907f7b 100644
--- a/drivers/i2c/mxs_i2c.c
+++ b/drivers/i2c/mxs_i2c.c
@@ -28,6 +28,7 @@
 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -213,62 +214,39 @@ int i2c_probe(uchar chip)
return ret;
 }
 
-static struct mxs_i2c_speed_table {
-   uint32_tspeed;
-   uint32_ttiming0;
-   uint32_ttiming1;
-} mxs_i2c_tbl[] = {
-   {
-   10,
-   (0x0078 << I2C_TIMING0_HIGH_COUNT_OFFSET) |
-   (0x0030 << I2C_TIMING0_RCV_COUNT_OFFSET),
-   (0x0080 << I2C_TIMING1_LOW_COUNT_OFFSET) |
-   (0x0030 << I2C_TIMING1_XMIT_COUNT_OFFSET)
-   },
-   {
-   40,
-   (0x000f << I2C_TIMING0_HIGH_COUNT_OFFSET) |
-   (0x0007 << I2C_TIMING0_RCV_COUNT_OFFSET),
-   (0x001f << I2C_TIMING1_LOW_COUNT_OFFSET) |
-   (0x000f << I2C_TIMING1_XMIT_COUNT_OFFSET),
-   }
-};
-
-static struct mxs_i2c_speed_table *mxs_i2c_speed_to_cfg(uint32_t speed)
-{
-   int i;
-   for (i = 0; i < ARRAY_SIZE(mxs_i2c_tbl); i++)
-   if (mxs_i2c_tbl[i].speed == speed)
-   return &mxs_i2c_tbl[i];
-   return NULL;
-}
-
-static uint32_t mxs_i2c_cfg_to_speed(uint32_t timing0, uint32_t timing1)
-{
-   int i;
-   for (i = 0; i < ARRAY_SIZE(mxs_i2c_tbl); i++) {
-   if (mxs_i2c_tbl[i].timing0 != timing0)
-   continue;
-   if (mxs_i2c_tbl[i].timing1 != timing1)
-   continue;
-   return mxs_i2c_tbl[i].speed;
-   }
-
-   return 0;
-}
-
 int i2c_set_bus_speed(unsigned int speed)
 {
struct mxs_i2c_regs *i2c_regs = (struct mxs_i2c_regs *)MXS_I2C0_BASE;
-   struct mxs_i2c_speed_table *spd = mxs_i2c_speed_to_cfg(speed);
+   /*
+* The timing derivation algorithm. There is no documentation for this
+* algorithm available, it was derived by using the scope and fiddling
+* with constants until the result observed on the scope was good enough
+* for 20kHz, 50kHz, 100kHz, 200kHz, 300kHz and 400kHz. It should be
+* possible to assume the algorithm works for other frequencies as well.
+*
+* Note it was necessary to cap the frequency on both ends as it's not
+* possible to configure completely arbitrary frequency for the I2C bus
+* clock.
+*/
+   uint32_t clk = mxc_get_clock(MXC_XTAL_CLK);
+   uint32_t base = ((clk / speed) - 38) / 2;
+   uint16_t high_count = base + 3;
+   uint16_t low_count = base - 3;
+   uint16_t rcv_count = (high_count * 3) / 4;
+   uint16_t xmit_count = low_count / 4;
+
+   if (speed > 54) {
+   printf("MXS I2C: Speed too high (%d Hz)\n", speed);
+   return -EINVAL;
+   }
 
-   if (!spd) {
-   printf("MXS I2C: Invalid speed selected (%d Hz)\n", speed);
+   if (speed < 12000) {
+   printf("MXS I2C: Speed too low (%d Hz)\n", speed);
return -EINVAL;
}
 
-   writel(spd->timing0, &i2c_regs->hw_i2c_timing0);
-   writel(spd->timing1, &i2c_regs->hw_i2c_timing1);
+   writel((high_count << 16

Re: [U-Boot] [PATCHv3 1/4] usb documentation: fix typo

2012-11-30 Thread Marek Vasut
Dear richard.gen...@gmail.com,

> From: Richard Genoud 
> 
> Signed-off-by: Richard Genoud 

Applied this patch, thanks. Next time please Cc me, that way you have better 
chance I'll notice the patch right away ;-)

> ---
>  doc/README.usb |2 +-
>  1 files changed, 1 insertions(+), 1 deletions(-)
> 
> diff --git a/doc/README.usb b/doc/README.usb
> index ef1d6ba..b4c3ef5 100644
> --- a/doc/README.usb
> +++ b/doc/README.usb
> @@ -63,7 +63,7 @@ Common USB Commands:
>  Storage USB Commands:
>  - usb scan:  scans the USB for storage devices.The USB must be
>   running for this command (usb start)
> -- usb device [dev]: show or set current USB staorage device
> +- usb device [dev]: show or set current USB storage device
>  - usb part [dev]:   print partition table of one or all USB storage
>   devices
>  - usb read addr blk# cnt:

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


Re: [U-Boot] [PATCH v3 1/9] usb: Fix bug when both DFU & ETHER are defined

2012-11-30 Thread Marek Vasut
Dear Pantelis Antoniou,

> When both CONFIG_USB_GADGET & CONFIG_USB_ETHER are defined
> the makefile links objects twice.
> 
> The cleanest way to fix is to use a new define, CONFIG_USB_UTIL
> which must be defined when either CONFIG_USB_ETHER or
> CONFIG_USB_GADGET are defined.
> 
> All affected boards have been modified as well.
> 
> Signed-off-by: Pantelis Antoniou 

Quick google [1]

http://old.nabble.com/if-defined%28a%29-||-defined%28b%29-td26806006.html

This won't work?

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


Re: [U-Boot] [PATCH v3 4/9] dfu: Only perform DFU board_usb_init() for TRATS

2012-11-30 Thread Marek Vasut
Dear Pantelis Antoniou,

> USB initialization shouldn't happen for all the boards.
> 
> Signed-off-by: Pantelis Antoniou 
> ---
>  common/cmd_dfu.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/common/cmd_dfu.c b/common/cmd_dfu.c
> index 01d6b3a..327c738 100644
> --- a/common/cmd_dfu.c
> +++ b/common/cmd_dfu.c
> @@ -55,7 +55,10 @@ static int do_dfu(cmd_tbl_t *cmdtp, int flag, int argc,
> char * const argv[]) goto done;
>   }
> 
> +#ifdef CONFIG_TRATS
>   board_usb_init();
> +#endif
> +

Can this "board_usb_init()" _please_ be renamed?

>   g_dnl_register(s);
>   while (1) {
>   if (ctrlc())

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


Re: [U-Boot] [PATCH v3 0/9] USB: Gadget & DFU related fixes

2012-11-30 Thread Marek Vasut
Dear Pantelis Antoniou,

> Third take of USB + DFU updates.
> 
> Changelog for the pendants:
> 
> changes from v2:
> * Handle large transfers properly take #2
> * Different method of avoid double linking of
>   usb gadget & usb ether.
> 
> changes from v1:
> * Properly terminate terminate string list.
> * Handle large transfers properly take #1
[...]

I applied all but 1/9, that needs proper fixing.

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


Re: [U-Boot] U-Boot for MIPS AR7161

2012-11-30 Thread Drassal, Allan
I think I made a little more progress...
Using the following commands I can get output from the UART...
  # set GPIO 9 & 10 as UART
  mww 0xb804 0x400
  mww 0xb8040028 0x100

  mww 0xb8020004 0x0
  mww 0xb802000c 0x83
  mww 0xb802 0x51
  mww 0xb8020004 0x0
  mww 0xb802000c 0x3
  mww 0xb8020008 0xc1

  mww 0xb802 0x54
  mww 0xb802 0x45
  mww 0xb802 0x53
  mww 0xb802 0x54
  mww 0xb802 0x0D
  mww 0xb802 0x0A

After executing the first two commands, then running the loader program I can 
get UART output, but it is all garbled.
It is like I have not selected the correct BAUD, but I have tried all speeds.
Possibly there is a mismatch in the internal clock calibration and the way the 
loader is calculating UART speeds.
Is this the PLL configuration that I should be looking at?

From: u-boot-boun...@lists.denx.de [u-boot-boun...@lists.denx.de] on behalf of 
Drassal, Allan [dra...@wsu.edu]
Sent: Friday, November 30, 2012 20:14
To: Dmytro
Cc: Luka Perkov; U-Boot Mailing List
Subject: Re: [U-Boot] U-Boot for MIPS AR7161

Hi Dmytro,

Thanks for your detailed response.  I corrected some details in the ar71xx.cfg 
file and am posting them below this message.
With this, I am convinced that my JTAG interface is working and the DRAM 
controller is getting setup correctly.
Now, I am just needing some code to load into the processor.
I would like to port U-Boot over to this platform, but it is a little above my 
experience level at the moment.
Perhaps it has already been done and I am not looking in the right place.
This platform is technically based on AP96 I believe though.

I connected up the two devices today and did these checks, these are the 
results...
However, the response from the two devices is slightly different...
You can see the results below...

I needed to do a "reset init" before the file would load successfully...
I assume the DRAM controller is initialized at this point and not if I just 
open up openOCD.
if I just did a straight "halt" without a "reset init", then the PC is different

On the non-functioning device I am assuming it begins to execute code at 
0xbfc00380, but runs into something it can't execute and either loops or 
freezes there.

> reset
JTAG tap: ar71xx.cpu tap/device found: 0x0001 (mfg: 0x000, part: 0x, 
ver: 0x0)
> halt
target state: halted
target halted in MIPS32 mode due to debug-request, pc: 0xbfc00380


results from broken device
> halt
target state: halted
target halted in MIPS32 mode due to debug-request, pc: 0xbfc00380
> mdw 0xb800 0x10
0xb800: 77bc8cd0 81d106a8 0133 0002  2000 00ff 
0081
0xb820: 0081 0081 0081     

> mdw 0xb805
0xb805: 001040a3
> mdw 0xb8050008
0xb8050008: 
> mdw 0xb805000c
0xb805000c: 

results from working device
ar7100> md 0xb800 0x10
b800: 77b8884e 812cd6a8 0033 w..N.,.3
b810:  44a6 00ff 0007..D.
b820: 0007 0007 0007 
b830:    
ar7100> md 0xb805 0x1
b805: c0140180
ar7100> md 0xb8050008 0x1
b8050008: 
ar7100> md 0xb805000c 0x1
b805000c: 
ar7100>

results of loading a file and checking the read memory is the same
> reset init
JTAG tap: ar71xx.cpu tap/device found: 0x0001 (mfg: 0x000, part: 0x, 
ver: 0x0)
target state: halted
target halted in MIPS32 mode due to debug-request, pc: 0xbfc0
> load_image mtd0.bin 0xa001
327680 bytes written at address 0xa001
downloaded 327680 bytes in 3.917356s (81.688 KiB/s)
> mdw 0xa001 0x10
0xa001: 10ff  10fd  1dbb  1db9 

0xa0010020: 1db7  1db5  1db3  1db1 

> mdw 0xa001 0x10
0xa001: 10ff  10fd  1dbb  1db9 

0xa0010020: 1db7  1db5  1db3  1db1 

> mdw 0xa001 0x10
0xa001: 10ff  10fd  1dbb  1db9 

0xa0010020: 1db7  1db5  1db3  1db1 




ar71xx.cfg:
# Atheros AR71xx MIPS 24Kc SoC.
# tested on PB44 refererence board

adapter_nsrst_delay 100
jtag_ntrst_delay 100

reset_config trst_and_srst

set CHIPNAME ar71xx

jtag newtap $CHIPNAME cpu -irlen 5 -ircapture 0x1 -irmask 0x1f -expected-id 1

set TARGETNAME $CHIPNAME.cpu
target create $TARGETNAME mips_m4k -endian big -chain-position $TARGETNAME

$TARGETNAME configure -event reset-halt-post {
#setup PLL to lowest common denominator 300/300/150 setting
mww 0xb805 0x000f40a3   ;# reset val + CPU:3 DDR:3 AHB:0
mww 0xb805 0x800f40a3   ;# send to PLL

#next command will reset for PLL changes to take effect