Re: [U-Boot] compiled failed when turned off gcc optimazition

2013-07-02 Thread Mike Dunn
On 07/01/2013 12:51 PM, Wolfgang Denk wrote:
 Dear Mike Dunn,
 
 In message 51d1c455.9010...@newsguy.com you wrote:

 But there's a good motivation for wanting to turn off optimization.
 
 I disagree here.  If you are hunting down a problem, you want to be as
 close at the original code as possible.  Disabling optimization is
 such a dramatic change to the generated code that you actually debug a
 different program.


I guess it depends on what problem being debugged...  I think your point is
valid for things like tracking down race conditions or misbehaving hardware.
But for more mundane problems like logical errors in the code, optimizations get
in the way.  It would be nice to be able to experiment with optimizations off.
Just knowing that a particular problem still exists when unoptimized code is run
will provide some clues.


 
 Single-stepping with a debugger at the C source level is almost useless.  
 I've
 since gotten better at single-stepping at the assembly level while using the
 mixed c and assembly view of gdb.
 
 Hm... Did you read up the documentation, say [1], and try out these
 recommendations?
 
 [1] http://www.denx.de/wiki/view/DULG/DebuggingTricks


No, but I will.  Many thanks!
Mike

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


Re: [U-Boot] compiled failed when turned off gcc optimazition

2013-07-01 Thread Mike Dunn
On 07/01/2013 04:37 AM, Wolfgang Denk wrote:
 Dear tiger...@viatech.com.cn,
 
 please do not top post / full quote.
 
 In message fe7aded5c2218b4786c09cd97dc4c49f940...@exchbj02.viatech.com.bj 
 you wrote:

 During debug u-boot with JTAG tools, maybe turning off optimizations was 
 recommended.
 
 Many people recommend many things. Even strange or non-working or
 incorrect or dangerous ones.


A while back I tried this for the Linux kernel, with similiar results.  I just
let it go without investigating further, guessing that maybe some tricks with
compiler directives were incompatible with turning off optimization.

But there's a good motivation for wanting to turn off optimization.
Single-stepping with a debugger at the C source level is almost useless.  I've
since gotten better at single-stepping at the assembly level while using the
mixed c and assembly view of gdb.

Mike

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


[U-Boot] [PATCH] mtd/nand: docg4: fix compiler warnings

2013-06-26 Thread Mike Dunn
Newer gcc versions warn about unused variables.  This patch corrects a few of
those warnings that popped up in a build for the palmtreo680 board.

Signed-off-by: Mike Dunn miked...@newsguy.com
---

 drivers/mtd/nand/docg4_spl.c | 15 +++
 1 file changed, 7 insertions(+), 8 deletions(-)

diff --git a/drivers/mtd/nand/docg4_spl.c b/drivers/mtd/nand/docg4_spl.c
index 95e856c..734cbeb 100644
--- a/drivers/mtd/nand/docg4_spl.c
+++ b/drivers/mtd/nand/docg4_spl.c
@@ -113,7 +113,6 @@ static int docg4_load_block_reliable(uint32_t flash_offset, 
void *dest_addr)
int g4_index = 0;
uint16_t flash_status;
uint16_t *buf;
-   uint16_t discard, magic_high, magic_low;
 
/* flash_offset must be aligned to the start of a block */
if (flash_offset  0x3)
@@ -154,9 +153,9 @@ static int docg4_load_block_reliable(uint32_t flash_offset, 
void *dest_addr)
 * The IPL on the palmtreo680 requires that this contain a 32 bit magic
 * number, or the load aborts.  We'll ignore it.
 */
-   discard = readw(docptr + 0x103c); /* hw quirk; 1st read discarded */
-   magic_low = readw(docptr + 0x103c);
-   magic_high = readw(docptr + DOCG4_MYSTERY_REG);
+   readw(docptr + 0x103c); /* hw quirk; 1st read discarded */
+   readw(docptr + 0x103c); /* lower 16 bits of magic number */
+   readw(docptr + DOCG4_MYSTERY_REG); /* upper 16 bits of magic number */
writew(0, docptr + DOC_DATAEND);
write_nop(docptr);
write_nop(docptr);
@@ -183,15 +182,15 @@ static int docg4_load_block_reliable(uint32_t 
flash_offset, void *dest_addr)
write_nop(docptr);
 
/* read the 512 bytes of page data, 2 bytes at a time */
-   discard = readw(docptr + 0x103c);
+   readw(docptr + 0x103c); /* hw quirk */
for (i = 0; i  256; i++)
*buf++ = readw(docptr + 0x103c);
 
/* read oob, but discard it */
for (i = 0; i  7; i++)
-   discard = readw(docptr + 0x103c);
-   discard = readw(docptr + DOCG4_OOB_6_7);
-   discard = readw(docptr + DOCG4_OOB_6_7);
+   readw(docptr + 0x103c);
+   readw(docptr + DOCG4_OOB_6_7);
+   readw(docptr + DOCG4_OOB_6_7);
 
writew(0, docptr + DOC_DATAEND);
write_nop(docptr);
-- 
1.8.1.5

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


[U-Boot] [PATCH] usb: pxa27x_udc: fix compiler warnings

2013-06-26 Thread Mike Dunn
Newer gcc versions warn about unused variables.  This patch corrects a few of
those warnings that popped up in a build for the palmtreo680 board.

Signed-off-by: Mike Dunn miked...@newsguy.com
---
 drivers/usb/gadget/pxa27x_udc.c | 14 +-
 1 file changed, 5 insertions(+), 9 deletions(-)

diff --git a/drivers/usb/gadget/pxa27x_udc.c b/drivers/usb/gadget/pxa27x_udc.c
index 71cc0f2..598923d 100644
--- a/drivers/usb/gadget/pxa27x_udc.c
+++ b/drivers/usb/gadget/pxa27x_udc.c
@@ -151,7 +151,7 @@ static int udc_read_urb(struct usb_endpoint_instance 
*endpoint)
struct urb *urb = endpoint-rcv_urb;
int ep_num = endpoint-endpoint_address  USB_ENDPOINT_NUMBER_MASK;
u32 *data32 = (u32 *) urb-buffer;
-   unsigned int i, n, is_short ;
+   unsigned int i, n;
 
usbdbg(read urb on ep %d, ep_num);
 #if defined(USBDDBG)  defined(USBDPARANOIA)
@@ -165,9 +165,8 @@ static int udc_read_urb(struct usb_endpoint_instance 
*endpoint)
n = readl(UDCBCN(ep_num))  0x3ff;
else /* zlp */
n = 0;
-   is_short = n != endpoint-rcv_packetSize;
 
-   usbdbg(n %d%s, n, is_short ? -s : );
+   usbdbg(n %d%s, n, n != endpoint-rcv_packetSize ? -s : );
for (i = 0; i  n; i += 4)
data32[urb-actual_length / 4 + i / 4] = readl(UDCDN(ep_num));
 
@@ -402,16 +401,13 @@ static void udc_handle_ep(struct usb_endpoint_instance 
*endpoint)
 
 static void udc_state_changed(void)
 {
-   int config, interface, alternate;
 
writel(readl(UDCCR) | UDCCR_SMAC, UDCCR);
 
-   config = (readl(UDCCR)  UDCCR_ACN)  UDCCR_ACN_S;
-   interface = (readl(UDCCR)  UDCCR_AIN)  UDCCR_AIN_S;
-   alternate = (readl(UDCCR)  UDCCR_AAISN)  UDCCR_AAISN_S;
-
usbdbg(New UDC settings are: conf %d - inter %d - alter %d,
-   config, interface, alternate);
+  (readl(UDCCR)  UDCCR_ACN)  UDCCR_ACN_S,
+  (readl(UDCCR)  UDCCR_AIN)  UDCCR_AIN_S,
+  (readl(UDCCR)  UDCCR_AAISN)  UDCCR_AAISN_S);
 
usbd_device_event_irq(udc_device, DEVICE_CONFIGURED, 0);
writel(UDCISR1_IRCC, UDCISR1);
-- 
1.8.1.5

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


[U-Boot] [PATCH] pxa: fix compiler warnings about unused variables

2013-06-24 Thread Mike Dunn
Newer gcc versions warn about unused variables.  This patch corrects a few of
those warnings that popped up in a pxa build.

Signed-off-by: Mike Dunn miked...@newsguy.com
---
 drivers/mtd/nand/docg4_spl.c| 15 +++
 drivers/usb/gadget/pxa27x_udc.c | 14 +-
 2 files changed, 12 insertions(+), 17 deletions(-)

diff --git a/drivers/mtd/nand/docg4_spl.c b/drivers/mtd/nand/docg4_spl.c
index 95e856c..734cbeb 100644
--- a/drivers/mtd/nand/docg4_spl.c
+++ b/drivers/mtd/nand/docg4_spl.c
@@ -113,7 +113,6 @@ static int docg4_load_block_reliable(uint32_t flash_offset, 
void *dest_addr)
int g4_index = 0;
uint16_t flash_status;
uint16_t *buf;
-   uint16_t discard, magic_high, magic_low;
 
/* flash_offset must be aligned to the start of a block */
if (flash_offset  0x3)
@@ -154,9 +153,9 @@ static int docg4_load_block_reliable(uint32_t flash_offset, 
void *dest_addr)
 * The IPL on the palmtreo680 requires that this contain a 32 bit magic
 * number, or the load aborts.  We'll ignore it.
 */
-   discard = readw(docptr + 0x103c); /* hw quirk; 1st read discarded */
-   magic_low = readw(docptr + 0x103c);
-   magic_high = readw(docptr + DOCG4_MYSTERY_REG);
+   readw(docptr + 0x103c); /* hw quirk; 1st read discarded */
+   readw(docptr + 0x103c); /* lower 16 bits of magic number */
+   readw(docptr + DOCG4_MYSTERY_REG); /* upper 16 bits of magic number */
writew(0, docptr + DOC_DATAEND);
write_nop(docptr);
write_nop(docptr);
@@ -183,15 +182,15 @@ static int docg4_load_block_reliable(uint32_t 
flash_offset, void *dest_addr)
write_nop(docptr);
 
/* read the 512 bytes of page data, 2 bytes at a time */
-   discard = readw(docptr + 0x103c);
+   readw(docptr + 0x103c); /* hw quirk */
for (i = 0; i  256; i++)
*buf++ = readw(docptr + 0x103c);
 
/* read oob, but discard it */
for (i = 0; i  7; i++)
-   discard = readw(docptr + 0x103c);
-   discard = readw(docptr + DOCG4_OOB_6_7);
-   discard = readw(docptr + DOCG4_OOB_6_7);
+   readw(docptr + 0x103c);
+   readw(docptr + DOCG4_OOB_6_7);
+   readw(docptr + DOCG4_OOB_6_7);
 
writew(0, docptr + DOC_DATAEND);
write_nop(docptr);
diff --git a/drivers/usb/gadget/pxa27x_udc.c b/drivers/usb/gadget/pxa27x_udc.c
index 71cc0f2..598923d 100644
--- a/drivers/usb/gadget/pxa27x_udc.c
+++ b/drivers/usb/gadget/pxa27x_udc.c
@@ -151,7 +151,7 @@ static int udc_read_urb(struct usb_endpoint_instance 
*endpoint)
struct urb *urb = endpoint-rcv_urb;
int ep_num = endpoint-endpoint_address  USB_ENDPOINT_NUMBER_MASK;
u32 *data32 = (u32 *) urb-buffer;
-   unsigned int i, n, is_short ;
+   unsigned int i, n;
 
usbdbg(read urb on ep %d, ep_num);
 #if defined(USBDDBG)  defined(USBDPARANOIA)
@@ -165,9 +165,8 @@ static int udc_read_urb(struct usb_endpoint_instance 
*endpoint)
n = readl(UDCBCN(ep_num))  0x3ff;
else /* zlp */
n = 0;
-   is_short = n != endpoint-rcv_packetSize;
 
-   usbdbg(n %d%s, n, is_short ? -s : );
+   usbdbg(n %d%s, n, n != endpoint-rcv_packetSize ? -s : );
for (i = 0; i  n; i += 4)
data32[urb-actual_length / 4 + i / 4] = readl(UDCDN(ep_num));
 
@@ -402,16 +401,13 @@ static void udc_handle_ep(struct usb_endpoint_instance 
*endpoint)
 
 static void udc_state_changed(void)
 {
-   int config, interface, alternate;
 
writel(readl(UDCCR) | UDCCR_SMAC, UDCCR);
 
-   config = (readl(UDCCR)  UDCCR_ACN)  UDCCR_ACN_S;
-   interface = (readl(UDCCR)  UDCCR_AIN)  UDCCR_AIN_S;
-   alternate = (readl(UDCCR)  UDCCR_AAISN)  UDCCR_AAISN_S;
-
usbdbg(New UDC settings are: conf %d - inter %d - alter %d,
-   config, interface, alternate);
+  (readl(UDCCR)  UDCCR_ACN)  UDCCR_ACN_S,
+  (readl(UDCCR)  UDCCR_AIN)  UDCCR_AIN_S,
+  (readl(UDCCR)  UDCCR_AAISN)  UDCCR_AAISN_S);
 
usbd_device_event_irq(udc_device, DEVICE_CONFIGURED, 0);
writel(UDCISR1_IRCC, UDCISR1);
-- 
1.8.1.5

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


Re: [U-Boot] [PULL] u-boot-pxa/master

2013-06-23 Thread Mike Dunn
On 06/23/2013 03:13 AM, Albert ARIBAUD wrote:
 Hi Marek,
 
 FYI, I am using the ARM cross-toolchain available in my Ubuntu 13.04.

 For some reason, I feel the linaro ones were always stuffed with 
 experimental 
 and semi-broken stuff :-(
 
 Maybe they were; all I can say is, the Ubuntu/Linaro toolchain never
 failed me in any way.


I build my toolchain using the crossdev script, which is a gentoo package.  I've
been doing this for years without any problems, except that occasionally
building requires some trial-and-error because of incompatibilities between
gcc/binutils/glibc.  But other than that, I am able to choose the version of
each tool.

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


Re: [U-Boot] [PULL] u-boot-pxa/master

2013-06-22 Thread Mike Dunn
On 06/22/2013 09:57 AM, Albert ARIBAUD wrote:
 Hi Marek,
 
 On Sat, 22 Jun 2013 15:26:21 +0200, Marek Vasut ma...@denx.de wrote:
 
 The following changes since commit fbf87b1823dd5ebc2a384711ea2c677543019ece:

   arm: optimize relocate_code routine (2013-06-21 23:05:50 +0200)

 are available in the git repository at:

   git://git.denx.de/u-boot-pxa.git master

 for you to fetch changes up to 9dc8fef2583f23ca6a99c6f5e709a8b80018364f:

   pxa: fix memory coherency problem after relocation (2013-06-22 15:25:28 
 +0200)

 
 Mike Dunn (5):
   pxa: add support for palmtreo680 board
   pxa: palmtreo680 flash programming utility
   pxa: turn icache off in cpu_init_crit()
   pxa: use -mcpu=xscale compiler option
   pxa: fix memory coherency problem after relocation

  CREDITS  |4 +
  MAINTAINERS  |3 +
  arch/arm/cpu/pxa/config.mk   |2 +-
  arch/arm/cpu/pxa/start.S |3 +-
  arch/arm/lib/relocate.S  |9 +++
  board/palmtreo680/Makefile   |   34 +
  board/palmtreo680/README |  581 
 ++
  board/palmtreo680/palmtreo680.c  |  148 +++
  boards.cfg   |1 +
  include/configs/palmtreo680.h|  286 
 
  tools/palmtreo680/flash_u-boot.c |  177 
 ++
  11 files changed, 1245 insertions(+), 3 deletions(-)
  create mode 100644 board/palmtreo680/Makefile
  create mode 100644 board/palmtreo680/README
  create mode 100644 board/palmtreo680/palmtreo680.c
  create mode 100644 include/configs/palmtreo680.h
  create mode 100644 tools/palmtreo680/flash_u-boot.c
 
 gcc version 4.7.3 (Ubuntu/Linaro 4.7.3-1ubuntu1)
 
 fails with warnings for palmtreo680:


I don't get these warnings, despite the u-boot makefiles passing -Wall to gcc.
I'm using gcc version 4.5.4...  I guess maybe I need to update gcc because later
versions are stricter?  I'll go ahead and do that, and if this produces the
warnings, I'll submit patches that eliminates them.  Sorry.

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


[U-Boot] [PATCH 2/2] pxa: fix memory coherency problem after relocation

2013-06-21 Thread Mike Dunn
On the xscale, the icache must be invalidated and the write buffers drained
after writing code over the data bus, even if the caches are disabled.  Tested
on the pxa270.

Signed-off-by: Mike Dunn miked...@newsguy.com
---
 arch/arm/lib/relocate.S |9 +
 1 files changed, 9 insertions(+), 0 deletions(-)

diff --git a/arch/arm/lib/relocate.S b/arch/arm/lib/relocate.S
index 4446da9..eedf314 100644
--- a/arch/arm/lib/relocate.S
+++ b/arch/arm/lib/relocate.S
@@ -92,6 +92,15 @@ fixnext:
 
 relocate_done:
 
+#ifdef __XSCALE__
+   /*
+* On xscale, icache must be invalidated and write buffers drained,
+* even with cache disabled - 4.2.7 of xscale core developer's manual
+*/
+   mcr p15, 0, r0, c7, c7, 0   /* invalidate icache */
+   mcr p15, 0, r0, c7, c10, 4  /* drain write buffer */
+#endif
+
/* ARMv4- don't know bx lr but the assembler fails to see that */
 
 #ifdef __ARM_ARCH_4__
-- 
1.7.8.6

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


[U-Boot] [PATCH 0/2] pxa: fix memory coherency problem after relocation

2013-06-21 Thread Mike Dunn
These patches fix a memory coherency problem that sometimes occurs on xscale
after code relocation.  The first patch changes the options passed to the
compiler so that the __XSCALE__ macro is defined.  This is used in the second
patch to limit the change to xscale cores, where the necessary cache operations
are performed before jumping to the relocated code.

Whether other cores need a similiar operation after code relocation remains an
open question.

Thanks Albert.

Mike Dunn (2):
  pxa: use -mcpu=xscale compiler option
  pxa: fix memory coherency problem after relocation

 arch/arm/cpu/pxa/config.mk |2 +-
 arch/arm/lib/relocate.S|9 +
 2 files changed, 10 insertions(+), 1 deletions(-)

-- 
1.7.8.6

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


[U-Boot] [PATCH 1/2] pxa: use -mcpu=xscale compiler option

2013-06-21 Thread Mike Dunn
Pass '-mcpu=xscale' to the compiler instead of march and mtune.  This will cause
gcc to define the __XSCALE__ macro.

Signed-off-by: Mike Dunn miked...@newsguy.com
---
 arch/arm/cpu/pxa/config.mk |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/arch/arm/cpu/pxa/config.mk b/arch/arm/cpu/pxa/config.mk
index 0bbe295..ea55859 100644
--- a/arch/arm/cpu/pxa/config.mk
+++ b/arch/arm/cpu/pxa/config.mk
@@ -24,7 +24,7 @@
 
 PLATFORM_RELFLAGS += -fno-common -ffixed-r8 -msoft-float
 
-PLATFORM_CPPFLAGS += -march=armv5te -mtune=xscale
+PLATFORM_CPPFLAGS += -mcpu=xscale
 # =
 #
 # Supply options according to compiler version
-- 
1.7.8.6

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


Re: [U-Boot] [PATCH] arm: fix memory coherency problem after relocation

2013-06-20 Thread Mike Dunn
On 06/20/2013 06:56 AM, Marek Vasut wrote:
 Dear Mike Dunn,
 
 On the xscale, the icache must be invalidated and the write buffers drained
 after writing code over the data bus, even if the caches are disabled. 
 After rebasing with the main git repository, u-boot began crashing in odd
 places on my pxa270 board (palmtreo680) after the code relocation routine
 ran.  This patch fixes it.  Cache coherency problems are often
 hit-and-miss (ha ha), and this latent problem didn't rear its ugly head
 until now.  Tested on the pxa270.

 Signed-off-by: Mike Dunn miked...@newsguy.com
 ---

 I realize that __ARM_ARCH_5TE__ does not necessarily mean xscale.
 
 We should introduce some CONFIG_PXA I guess.


I think CONFIG_XSCALE is more correct, because if I'm not mistaken more recent
Marvell processors continue to use the 'pxa' nomenclature in their name but do
not contain xscale cores.

I'll take a stab at a patch if you like.  Maybe something like this macro in
arch/arm/include/asm/arch-pxa/hardware.h

/*
 * Define CONFIG_CPU_MONAHANS in case some CPU of the PXA3xx family is selected.
 * PXA300/310/320 all have distinct register mappings in some cases, that's why
 * the exact CPU has to be selected. CONFIG_CPU_MONAHANS is a helper for common
 * drivers and compatibility glue with old source then.
 */
#ifndef CONFIG_CPU_MONAHANS
#if defined(CONFIG_CPU_PXA300) || \
defined(CONFIG_CPU_PXA310) || \
defined(CONFIG_CPU_PXA320)
#define CONFIG_CPU_MONAHANS
#endif
#endif

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


Re: [U-Boot] [PATCH] mtd: nand/docg4: fix driver after Linux resync

2013-06-18 Thread Mike Dunn
On 06/17/2013 03:29 PM, Scott Wood wrote:
 On 06/17/2013 12:44:55 PM, Mike Dunn wrote:
 Commit dfe64e2c89731a3f9950d7acd8681b68df2bae03:

 mtd: resync with Linux-3.7.1

 broke the docg4 driver.  Specifically:
  - some of the prototypes of the ecc methods changed
  - the NAND_NO_AUTOINCR flag was removed
  - the ecc.strength element was added.

 This patch fixes these.  Tested on the docg4 on my palmtre680 board.
 
 Applied to u-boot-nand-flash.
 
 Is board support for palmtre680 coming, so the driver will get routine
 build-testing?


Yes.  I've already submitted patches for palmtreo680 board support, but was
remiss in shepherding it to mainline.  Will be resubmitting soon.

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


[U-Boot] [PATCH v6 1/2] pxa: add support for palmtreo680 board

2013-06-18 Thread Mike Dunn
This patch adds support for the Palm Treo 680 smartphone.  A quick overview of
u-boot implementation on the treo 680...

The treo 680 has a Diskonchip G4 nand flash chip.  This device has a 2k region
that maps to the system bus at the reset vector in a NOR-like fashion so that it
can be used as the boot device.  The phone is shipped with this 2k region
configured as write-protected (can't be modified) and programmed with an initial
program loader (IPL).  At power-up, this IPL loads the contents of two flash
blocks to SDRAM and jumps to it.  The capacity of the two blocks is not large
enough to hold all of u-boot, so a u-boot SPL is used.  To conserve flash space,
these two blocks and the necessary number of subsequent blocks are programmed
with a concatenated spl + u-boot image.  That way, the IPL will also load a
portion of u-boot proper, and when the spl runs, it relocates the portion of
u-boot that the IPL has already loaded, and then resumes loading the remaining
part of u-boot before jumping to it.

The default_environment is used (CONFIG_ENV_IS_NOWHERE) because I didn't think
that having a writable environment was worth the cost of a flash block, although
adding it would be straightforward.  I abuse the CONFIG_EXTRA_ENV_SETTINGS
option to specify the usbtty for the console (CONFIG_SYS_CONSOLE_IS_IN_ENV).

Support for the LCD is included, but currently it is only useful for displaying
the u-boot splash screen.  But if u-boot is built without the usbtty console, it
does display the auto-boot progress nicely.

Signed-off-by: Mike Dunn miked...@newsguy.com
---
Changelog:
  v6: mv doc/README.palmtreo680 board/palmtreo680/README
  v5: do not use a custom linker script for spl build
  v4:
- use CONFIG_MACH_TYPE instead of MACH_TYPE_TREO680 to initialize
  bi_arch_number
- use offset from CONFIG_SYS_DRAM_BASE to initialize bi_boot_params,
  instead of hard-coding an absolute address
- use shift operator to set one bit when initializing gpio register
- remove memcpy() definition from spl build; use
  CONFIG_SPL_LIBGENERIC_SUPPORT to properly build and link with
  u-boot's memcpy()
- config file cleanup: remove erroneous comments, unneeded numerical
  definitions
- edited README.palmtreo680 a bit
  v3: flash_u-boot utility split into separate patch
  v2:
- tabs removed in #defines in palmtreo680.h
- utility for programming u-boot to flash moved to tools/palmtreo680

 CREDITS |4 +
 MAINTAINERS |3 +
 board/palmtreo680/Makefile  |   34 +++
 board/palmtreo680/README|  581 +++
 board/palmtreo680/palmtreo680.c |  148 ++
 boards.cfg  |1 +
 include/configs/palmtreo680.h   |  286 +++
 7 files changed, 1057 insertions(+), 0 deletions(-)
 create mode 100644 board/palmtreo680/Makefile
 create mode 100644 board/palmtreo680/README
 create mode 100644 board/palmtreo680/palmtreo680.c
 create mode 100644 include/configs/palmtreo680.h

diff --git a/CREDITS b/CREDITS
index 7c1458f..3b657e9 100644
--- a/CREDITS
+++ b/CREDITS
@@ -124,6 +124,10 @@ N: James F. Dougherty
 E: j...@gigabitnetworks.com
 D: Port to the MOUSSE board
 
+N: Mike Dunn
+E: miked...@newsguy.com
+D: Palmtreo680 board, docg4 nand flash driver
+
 N: Dave Ellis
 E: d...@sixnetio.com
 D: EEPROM Speedup, SXNI855T port
diff --git a/MAINTAINERS b/MAINTAINERS
index 7820375..9abff0a 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -651,6 +651,9 @@ Wolfgang Denk w...@denx.de
imx27lite   i.MX27
qongi.MX31
 
+Mike Dunn miked...@newsguy.com
+   palmtreo680 pxa270
+
 Kristoffer Ericson kristoffer.eric...@gmail.com
 
jornada SA1110
diff --git a/board/palmtreo680/Makefile b/board/palmtreo680/Makefile
new file mode 100644
index 000..34ffb99
--- /dev/null
+++ b/board/palmtreo680/Makefile
@@ -0,0 +1,34 @@
+#
+# Palm Treo680 Support
+#
+# Copyright (C) 2013 Mike Dunn miked...@newsguy.com
+#
+# This file is released under the terms of GPL v2 and any later version.
+# See the file COPYING in the root directory of the source tree for details.
+
+include $(TOPDIR)/config.mk
+
+LIB= $(obj)lib$(BOARD).o
+
+COBJS  := palmtreo680.o
+
+SRCS   := $(COBJS:.o=.c)
+OBJS   := $(addprefix $(obj),$(COBJS))
+
+$(LIB):$(obj).depend $(OBJS)
+   $(call cmd_link_o_target, $(OBJS))
+
+clean:
+   rm -f $(OBJS)
+
+distclean: clean
+   rm -f $(LIB) core *.bak $(obj).depend
+
+#
+
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
+
+sinclude $(obj).depend
+
+#
diff --git a/board/palmtreo680/README b/board/palmtreo680/README
new file mode 100644
index 000..159f1f6
--- /dev/null
+++ b/board/palmtreo680/README
@@ -0,0 +1,581 @@
+
+README for the Palm Treo 680.
+
+Copyright (C

[U-Boot] [PATCH v6 0/2] pxa: add support for palmtreo680 board

2013-06-18 Thread Mike Dunn
These two patches add support for the Palm Treo 680 phone.  The second patch
provides a userspace utility that is needed to program u-boot to the docg4 nand
flash in the manner required by the phone's IPL.

Marek, I thought that these patches were in your tree when you issued the PR a
few weeks ago, but I must have been mistaken.  Sorry.

I would have labeled these patches RESEND, but since I submitted v5 I learned
that README files now go into the board/ directory, so I made that change and
called it v6.  Each patch contains its full changelog.

Thanks!

Mike Dunn (2):
  pxa: add support for palmtreo680 board
  pxa: palmtreo680 flash programming utility

 CREDITS  |4 +
 MAINTAINERS  |3 +
 board/palmtreo680/Makefile   |   34 +++
 board/palmtreo680/README |  581 ++
 board/palmtreo680/palmtreo680.c  |  148 ++
 boards.cfg   |1 +
 include/configs/palmtreo680.h|  286 +++
 tools/palmtreo680/flash_u-boot.c |  177 
 8 files changed, 1234 insertions(+), 0 deletions(-)
 create mode 100644 board/palmtreo680/Makefile
 create mode 100644 board/palmtreo680/README
 create mode 100644 board/palmtreo680/palmtreo680.c
 create mode 100644 include/configs/palmtreo680.h
 create mode 100644 tools/palmtreo680/flash_u-boot.c

-- 
1.7.8.6

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


[U-Boot] [PATCH v6 2/2] pxa: palmtreo680 flash programming utility

2013-06-18 Thread Mike Dunn
This adds a userspace linux utility that writes the u-boot image to an mtd
partition on the docg4 nand flash.

A special utility is required to do this because u-boot is partially loaded by
an initial program loader (IPL) that is permanently programmed to the boot
region of the flash.  This IPL expects the image to be written in a unique
format. The characteristics of this format can be summarized as follows:
  - Flash blocks to be loaded must have a magic number in the oob bytes of the
first page of the block.
  - Each page must be written redundantly in the subsequent page.
  - The integrated flash controller's reliable mode is used, requiring that
alternate 2k regions (4 pages) are skipped when writing.
For these reasons, a u-boot image can not be written using nandwrite from
mtd-utils.

Signed-off-by: Mike Dunn miked...@newsguy.com
---
Changelog:
  v6: no change
  v5: on error, return a sensible errno.h code
  v4:
- use return instead of exit
- use calloc() instead of malloc()
- remove call to read() from within while loop test 
  v3: new patch; split off from patch 7 in v2 of patchset

 tools/palmtreo680/flash_u-boot.c |  177 ++
 1 files changed, 177 insertions(+), 0 deletions(-)
 create mode 100644 tools/palmtreo680/flash_u-boot.c

diff --git a/tools/palmtreo680/flash_u-boot.c b/tools/palmtreo680/flash_u-boot.c
new file mode 100644
index 000..3d8296f
--- /dev/null
+++ b/tools/palmtreo680/flash_u-boot.c
@@ -0,0 +1,177 @@
+/*
+ * Copyright (C) 2013 Mike Dunn miked...@newsguy.com
+ *
+ * This file is released under the terms of GPL v2 and any later version.
+ * See the file COPYING in the root directory of the source tree for details.
+ *
+ *
+ * This is a userspace Linux utility that, when run on the Treo 680, will
+ * program u-boot to flash.  The docg4 driver *must* be loaded with the
+ * reliable_mode and ignore_badblocks parameters enabled:
+ *
+ *modprobe docg4 ignore_badblocks=1 reliable_mode=1
+ *
+ * This utility writes the concatenated spl + u-boot image to the start of the
+ * mtd device in the format expected by the IPL/SPL.  The image file and mtd
+ * device node are passed to the utility as arguments.  The blocks must have
+ * been erased beforehand.
+ *
+ * When you compile this, note that it links to libmtd from mtd-utils, so 
ensure
+ * that your include and lib paths include this.
+ */
+
+#include stdio.h
+#include stdlib.h
+#include sys/stat.h
+#include fcntl.h
+#include string.h
+#include sys/types.h
+#include unistd.h
+#include errno.h
+#include mtd/mtd-user.h
+#include libmtd.h
+
+#define RELIABLE_BLOCKSIZE  0x1 /* block capacity in reliable mode */
+#define STANDARD_BLOCKSIZE  0x4 /* block capacity in normal mode */
+#define PAGESIZE 512
+#define PAGES_PER_BLOCK 512
+#define OOBSIZE 7  /* available to user (16 total) */
+
+uint8_t ff_oob[OOBSIZE] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
+
+/* this is the magic number the IPL looks for (ASCII BIPO) */
+uint8_t page0_oob[OOBSIZE] = {'B', 'I', 'P', 'O', 0xff, 0xff, 0xff};
+
+int main(int argc, char * const argv[])
+{
+   int devfd, datafd, num_blocks, block;
+   off_t file_size;
+   libmtd_t mtd_desc;
+   struct mtd_dev_info devinfo;
+   uint8_t *blockbuf;
+   char response[8];
+
+   if (argc != 3) {
+   printf(usage: %s image file mtd dev node\n, argv[0]);
+   return -EINVAL;
+   }
+
+   mtd_desc = libmtd_open();
+   if (mtd_desc == NULL) {
+   int errsv = errno;
+   fprintf(stderr, can't initialize libmtd\n);
+   return -errsv;
+   }
+
+   /* open the spl image file and mtd device */
+   datafd = open(argv[1], O_RDONLY);
+   if (datafd == -1) {
+   int errsv = errno;
+   perror(argv[1]);
+   return -errsv;
+   }
+   devfd = open(argv[2], O_WRONLY);
+   if (devfd == -1) {
+   int errsv = errno;
+   perror(argv[2]);
+   return -errsv;
+   }
+   if (mtd_get_dev_info(mtd_desc, argv[2], devinfo)  0) {
+   int errsv = errno;
+   perror(argv[2]);
+   return -errsv;
+   }
+
+   /* determine the number of blocks needed by the image */
+   file_size = lseek(datafd, 0, SEEK_END);
+   if (file_size == (off_t)-1) {
+   int errsv = errno;
+   perror(lseek);
+   return -errsv;
+   }
+   num_blocks = (file_size + RELIABLE_BLOCKSIZE - 1) / RELIABLE_BLOCKSIZE;
+   file_size = lseek(datafd, 0, SEEK_SET);
+   if (file_size == (off_t)-1) {
+   int errsv = errno;
+   perror(lseek);
+   return -errsv;
+   }
+   printf(The mtd partition contains %d blocks\n, devinfo.eb_cnt);
+   printf(U-boot will occupy %d blocks\n, num_blocks);
+   if (num_blocks  devinfo.eb_cnt) {
+   fprintf(stderr

[U-Boot] [PATCH] mtd: nand/docg4: fix driver after Linux resync

2013-06-17 Thread Mike Dunn
Commit dfe64e2c89731a3f9950d7acd8681b68df2bae03:

mtd: resync with Linux-3.7.1

broke the docg4 driver.  Specifically:
 - some of the prototypes of the ecc methods changed
 - the NAND_NO_AUTOINCR flag was removed
 - the ecc.strength element was added.

This patch fixes these.  Tested on the docg4 on my palmtre680 board.

Signed-off-by: Mike Dunn miked...@newsguy.com
---
 drivers/mtd/nand/docg4.c |   26 ++
 1 files changed, 14 insertions(+), 12 deletions(-)

diff --git a/drivers/mtd/nand/docg4.c b/drivers/mtd/nand/docg4.c
index 7dd9953..09f01c8 100644
--- a/drivers/mtd/nand/docg4.c
+++ b/drivers/mtd/nand/docg4.c
@@ -487,7 +487,7 @@ static void docg4_read_buf(struct mtd_info *mtd, uint8_t 
*buf, int len)
 }
 
 static int docg4_read_oob(struct mtd_info *mtd, struct nand_chip *nand,
- int page, int sndcmd)
+ int page)
 {
struct docg4_priv *doc = nand-priv;
void __iomem *docptr = CONFIG_SYS_NAND_BASE;
@@ -577,7 +577,7 @@ static void docg4_write_buf16(struct mtd_info *mtd, const 
uint8_t *buf, int len)
writew(p[i], nand-IO_ADDR_W);
 }
 
-static void write_page(struct mtd_info *mtd, struct nand_chip *nand,
+static int write_page(struct mtd_info *mtd, struct nand_chip *nand,
   const uint8_t *buf, int use_ecc)
 {
void __iomem *docptr = CONFIG_SYS_NAND_BASE;
@@ -626,16 +626,18 @@ static void write_page(struct mtd_info *mtd, struct 
nand_chip *nand,
write_nop(docptr);
writew(0, docptr + DOC_DATAEND);
write_nop(docptr);
+
+   return 0;
 }
 
-static void docg4_write_page_raw(struct mtd_info *mtd, struct nand_chip *nand,
-const uint8_t *buf)
+static int docg4_write_page_raw(struct mtd_info *mtd, struct nand_chip *nand,
+const uint8_t *buf, int oob_required)
 {
return write_page(mtd, nand, buf, 0);
 }
 
-static void docg4_write_page(struct mtd_info *mtd, struct nand_chip *nand,
-const uint8_t *buf)
+static int docg4_write_page(struct mtd_info *mtd, struct nand_chip *nand,
+const uint8_t *buf, int oob_required)
 {
return write_page(mtd, nand, buf, 1);
 }
@@ -706,13 +708,13 @@ static int read_page(struct mtd_info *mtd, struct 
nand_chip *nand,
 
 
 static int docg4_read_page_raw(struct mtd_info *mtd, struct nand_chip *nand,
-  uint8_t *buf, int page)
+  uint8_t *buf, int oob_required, int page)
 {
return read_page(mtd, nand, buf, page, 0);
 }
 
 static int docg4_read_page(struct mtd_info *mtd, struct nand_chip *nand,
-  uint8_t *buf, int page)
+  uint8_t *buf, int oob_required, int page)
 {
return read_page(mtd, nand, buf, page, 1);
 }
@@ -779,7 +781,7 @@ static int read_factory_bbt(struct mtd_info *mtd)
return -ENOMEM;
 
read_page_prologue(CONFIG_SYS_NAND_BASE, g4_addr);
-   status = docg4_read_page(mtd, nand, buf, DOCG4_FACTORY_BBT_PAGE);
+   status = docg4_read_page(mtd, nand, buf, 0, DOCG4_FACTORY_BBT_PAGE);
if (status)
goto exit;
 
@@ -858,7 +860,7 @@ static int docg4_block_markbad(struct mtd_info *mtd, loff_t 
ofs)
 
/* write first page of block */
write_page_prologue(CONFIG_SYS_NAND_BASE, g4_addr);
-   docg4_write_page(mtd, nand, buf);
+   docg4_write_page(mtd, nand, buf, 1);
ret = pageprog(mtd);
if (!ret)
mtd-ecc_stats.badblocks++;
@@ -959,8 +961,8 @@ int docg4_nand_init(struct mtd_info *mtd, struct nand_chip 
*nand, int devnum)
nand-ecc.size = DOCG4_PAGE_SIZE;
nand-ecc.prepad = 8;
nand-ecc.bytes = 8;
-   nand-options =
-   NAND_BUSWIDTH_16 | NAND_NO_SUBPAGE_WRITE | NAND_NO_AUTOINCR;
+   nand-ecc.strength = DOCG4_T;
+   nand-options = NAND_BUSWIDTH_16 | NAND_NO_SUBPAGE_WRITE;
nand-controller = nand-hwcontrol;
 
/* methods */
-- 
1.7.8.6

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


[U-Boot] [PATCH] pxa: turn icache off in cpu_init_crit()

2013-06-17 Thread Mike Dunn
The comment in the low-level initialization function cpu_init_crit() says that
the caches are being disabled, but (oddly) the icache is actually turned on.
This is probably not a good idea prior to relocating code, so this patch turns
it off.  Tested on the pxa270.

Signed-off-by: Mike Dunn miked...@newsguy.com
---

Because the current code seems quite deliberate in setting the icache bit, I
looked for evidence of an errata on the pxa25x whereby the logic of this bit is
inverted, but couldn't find any.

 arch/arm/cpu/pxa/start.S |3 +--
 1 files changed, 1 insertions(+), 2 deletions(-)

diff --git a/arch/arm/cpu/pxa/start.S b/arch/arm/cpu/pxa/start.S
index 2e3f65e..b1deb72 100644
--- a/arch/arm/cpu/pxa/start.S
+++ b/arch/arm/cpu/pxa/start.S
@@ -208,10 +208,9 @@ cpu_init_crit:
 * disable MMU stuff and caches
 */
mrc p15, 0, r0, c1, c0, 0
-   bic r0, r0, #0x2300 @ clear bits 13, 9:8 (--V- --RS)
+   bic r0, r0, #0x3300 @ clear bits 13:12, 9:8 (--VI --RS)
bic r0, r0, #0x0087 @ clear bits 7, 2:0 (B--- -CAM)
orr r0, r0, #0x0002 @ set bit 2 (A) Align
-   orr r0, r0, #0x1000 @ set bit 12 (I) I-Cache
mcr p15, 0, r0, c1, c0, 0
 
mov pc, lr  /* back to my caller */
-- 
1.7.8.6

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


[U-Boot] [PATCH] arm: fix memory coherency problem after relocation

2013-06-17 Thread Mike Dunn
On the xscale, the icache must be invalidated and the write buffers drained
after writing code over the data bus, even if the caches are disabled.  After
rebasing with the main git repository, u-boot began crashing in odd places on my
pxa270 board (palmtreo680) after the code relocation routine ran.  This patch
fixes it.  Cache coherency problems are often hit-and-miss (ha ha), and this
latent problem didn't rear its ugly head until now.  Tested on the pxa270.

Signed-off-by: Mike Dunn miked...@newsguy.com
---

I realize that __ARM_ARCH_5TE__ does not necessarily mean xscale.  But how else
to test for pxa2xx/ixp in an assembly file?  I wouldn't expect any ill effects
on a non-xscale v5te because these CP15 operations are defined the same way in
the ARM Architecture Reference Manual for v5 cores, but unfortunately I only
have a pxa270 xscale to test on.

I experienced this same problem a couple years ago when I was getting OpenOCD
working on the xscale.  Often software breakpoints (replacing an instruction
with the 'bkpt' instruction) would fail unless this operation was performed
after replacing the instruction, even with caches off.  The following two
paragraphs are cut from section 4.2.7 of the xscale core developer's manual...

If the instruction cache is not enabled, or code is being written to a
non-cacheable region, software must still invalidate the instruction cache
before using the newly-written code. This precaution ensures that state
associated with the new code is not buffered elsewhere in the processor, such as
the fetch buffers or the BTB.

Naturally, when writing code as data, care must be taken to force it completely
out of the processor into external memory before attempting to execute it. If
writing into a non-cacheable region, flushing the write buffers is sufficient
precaution (see Section 7.2.8 for a description of this

 arch/arm/lib/relocate.S |   10 ++
 1 files changed, 10 insertions(+), 0 deletions(-)

diff --git a/arch/arm/lib/relocate.S b/arch/arm/lib/relocate.S
index 4446da9..e2febed 100644
--- a/arch/arm/lib/relocate.S
+++ b/arch/arm/lib/relocate.S
@@ -92,6 +92,16 @@ fixnext:
 
 relocate_done:
 
+#ifdef __ARM_ARCH_5TE__
+   /*
+* On xscale, icache must be invalidated and write buffers drained,
+* even with cache disabled - 4.2.7 of xscale core developer's manual
+*/
+   mov r0, #0  /* arm reference manual: data SBZ */
+   mcr p15, 0, r0, c7, c7, 0   /* invalidate icache */
+   mcr p15, 0, r0, c7, c10, 4  /* drain write buffer */
+#endif
+
/* ARMv4- don't know bx lr but the assembler fails to see that */
 
 #ifdef __ARM_ARCH_4__
-- 
1.7.8.6

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


Re: [U-Boot] [PATCH] arm: pxa: PXA270 D-Cache as ram

2013-05-23 Thread Mike Dunn
On 05/21/2013 02:38 PM, Marek Vasut wrote:
 Dear Sergey Yanovich,
 
 Dear Marek Vasut,

 On Tue, 2013-05-21 at 22:07 +0200, Marek Vasut wrote:
 The OneNAND has 1kbyte limit on code it will directly address when
 booting from it, you can't even make generate the MMU table there.

 Do you mean there is no space left inside that 1K for
 lock_cache_for_stack()?
 
 How would you do that ? You need MMU enabled to lock lines IIRC.
 
 I have plans to dig deeper into this after I complete the current
 project. Faster boot is always a good thing. Thanks for explaining in
 details.

 Sure, yet I think I just piled work onto you ;-)

 It's OK. I have plans to do this anyway.
 
 CCing Mike Dunn, you two should coordinate.


Thanks Marek.  Was following this on the ML.  Will take a look when I get a 
chance.
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH v5] palmtreo680: add utility that writes u-boot to flash

2013-04-20 Thread Mike Dunn
On 04/20/2013 03:25 AM, Marek Vasut wrote:
 Dear Mike Dunn,

[...]

 
 I fixed the calloc() semantics and applied, thanks. Please repost whatever is 
 still missing in u-boot-pxa/master and I'll then roll pullRQ for mainline.

Thanks Marek.  Now I see your point regarding calloc() semantics.  Only

arm: bootm: call udc_disable() before booting linux

is not in your tree; I think you were worried about testing on musb boards.
I'll repost, but no reason to take a risk; I hope to get a patch for the Linux
udc driver upstream soon.

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


[U-Boot] [PATCH RESEND] arm: bootm: call udc_disable() before booting linux

2013-04-20 Thread Mike Dunn
On the pxa270, if the udc device is not disabled before jumping to linux, the
device fails to initialize in linux because it was left in a running state, and
the linux driver assumes that it is in a disabled state.

Signed-off-by: Mike Dunn miked...@newsguy.com
---
Arguably, this is a bug in the linux driver, but it seemed pretty simple and
benign to just disable it in u-boot.  I'll also send a patch to upstream kernel
to fix its udc driver.

 arch/arm/include/asm/bootm.h |1 +
 arch/arm/lib/bootm.c |1 +
 2 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/arch/arm/include/asm/bootm.h b/arch/arm/include/asm/bootm.h
index db2ff94..68189cc 100644
--- a/arch/arm/include/asm/bootm.h
+++ b/arch/arm/include/asm/bootm.h
@@ -21,6 +21,7 @@
 
 #ifdef CONFIG_USB_DEVICE
 extern void udc_disconnect(void);
+extern void udc_disable(void);
 #endif
 
 #endif
diff --git a/arch/arm/lib/bootm.c b/arch/arm/lib/bootm.c
index f3b30c5..6daa7bf 100644
--- a/arch/arm/lib/bootm.c
+++ b/arch/arm/lib/bootm.c
@@ -105,6 +105,7 @@ static void announce_and_cleanup(void)
 
 #ifdef CONFIG_USB_DEVICE
udc_disconnect();
+   udc_disable();
 #endif
cleanup_before_linux();
 }
-- 
1.7.8.6

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


Re: [U-Boot] [PATCH v5] palmtreo680: add utility that writes u-boot to flash

2013-04-20 Thread Mike Dunn
On 04/20/2013 03:25 AM, Marek Vasut wrote:
 Dear Mike Dunn,
 
 
 I fixed the calloc() semantics and applied, thanks. Please repost whatever is 
 still missing in u-boot-pxa/master and I'll then roll pullRQ for mainline.


Oops, the board support patch is not in your tree either.  Will repost.

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


Re: [U-Boot] [PATCH v5] palmtreo680: add utility that writes u-boot to flash

2013-04-20 Thread Mike Dunn
On 04/20/2013 11:01 AM, Marek Vasut wrote:
 Dear Mike Dunn,
 
 On 04/20/2013 03:25 AM, Marek Vasut wrote:
 Dear Mike Dunn,


 I fixed the calloc() semantics and applied, thanks. Please repost
 whatever is still missing in u-boot-pxa/master and I'll then roll pullRQ
 for mainline.

 Oops, the board support patch is not in your tree either.  Will repost.
 
 Did I not ramble about it? Check that first please, I'm not sure now ;-)
 


Yes, we went back-and-forth about it, and the latest version was v4.  But I need
to rework it because the spl build now fails due to a recent change to
arch/arm/cpu/pxa/start.S in commit 7086e91b0e9930139e703c8f9f857b52baf2bef4

  arm: relocate_code(): Use __image_copy_end for end of relocation

I was using my own linker script for the spl, which does not define the
__image_copy_end symbol that is now referenced in start.S.  I don't exactly
remember why I felt the need to avoid using the script in
arch/arm/cpu/u-boot-spl.lds, except that I didn't like all the sections created
by the --ffunction-sections and --fdata-sections compiler flags and wanted them
combined with a '*' wildcard.  But I removed my linker script and the
CONFIG_SPL_LDSCRIPT line from my config file and it is testing fine.  So I will
have to post a v5 of the patch.

Thanks again Marek,
Mike
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH v5] add support for the palm treo 680 board

2013-04-20 Thread Mike Dunn
A quick overview of u-boot implementation on the treo 680...

The treo 680 has a Diskonchip G4 nand flash chip.  This device has a 2k region
that maps to the system bus at the reset vector in a NOR-like fashion so that it
can be used as the boot device.  The phone is shipped with this 2k region
configured as write-protected (can't be modified) and programmed with an initial
program loader (IPL).  At power-up, this IPL loads the contents of two flash
blocks to SDRAM and jumps to it.  The capacity of the two blocks is not large
enough to hold all of u-boot, so a u-boot SPL is used.  To conserve flash space,
these two blocks and the necessary number of subsequent blocks are programmed
with a concatenated spl + u-boot image.  That way, the IPL will also load a
portion of u-boot proper, and when the spl runs, it relocates the portion of
u-boot that the IPL has already loaded, and then resumes loading the remaining
part of u-boot before jumping to it.

The default_environment is used (CONFIG_ENV_IS_NOWHERE) because I didn't think
that having a writable environment was worth the cost of a flash block, although
adding it would be straightforward.  I abuse the CONFIG_EXTRA_ENV_SETTINGS
option to specify the usbtty for the console (CONFIG_SYS_CONSOLE_IS_IN_ENV).

Support for the LCD is included, but currently it is only useful for displaying
the u-boot splash screen.  But if u-boot is built without the usbtty console, it
does display the auto-boot progress nicely.

Signed-off-by: Mike Dunn miked...@newsguy.com
---
Changelog:
  v5: do not use a custom linker script for spl build
  v4:
- use CONFIG_MACH_TYPE instead of MACH_TYPE_TREO680 to initialize
  bi_arch_number
- use offset from CONFIG_SYS_DRAM_BASE to initialize bi_boot_params,
  instead of hard-coding an absolute address
- use shift operator to set one bit when initializing gpio register
- remove memcpy() definition from spl build; use
  CONFIG_SPL_LIBGENERIC_SUPPORT to properly build and link with
  u-boot's memcpy()
- config file cleanup: remove erroneous comments, unneeded numerical
  definitions
- edited README.palmtreo680 a bit
  v3: flash_u-boot utility split into separate patch
  v2:
- tabs removed in #defines in palmtreo680.h
- utility for programming u-boot to flash moved to tools/palmtreo680

 CREDITS |4 +
 MAINTAINERS |3 +
 board/palmtreo680/Makefile  |   34 +++
 board/palmtreo680/palmtreo680.c |  154 +++
 boards.cfg  |1 +
 doc/README.palmtreo680  |  581 +++
 include/configs/palmtreo680.h   |  286 +++
 7 files changed, 1063 insertions(+), 0 deletions(-)
 create mode 100644 board/palmtreo680/Makefile
 create mode 100644 board/palmtreo680/palmtreo680.c
 create mode 100644 doc/README.palmtreo680
 create mode 100644 include/configs/palmtreo680.h

diff --git a/CREDITS b/CREDITS
index 7c1458f..3b657e9 100644
--- a/CREDITS
+++ b/CREDITS
@@ -124,6 +124,10 @@ N: James F. Dougherty
 E: j...@gigabitnetworks.com
 D: Port to the MOUSSE board
 
+N: Mike Dunn
+E: miked...@newsguy.com
+D: Palmtreo680 board, docg4 nand flash driver
+
 N: Dave Ellis
 E: d...@sixnetio.com
 D: EEPROM Speedup, SXNI855T port
diff --git a/MAINTAINERS b/MAINTAINERS
index 643a5ac..ff3724d 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -650,6 +650,9 @@ Wolfgang Denk w...@denx.de
imx27lite   i.MX27
qongi.MX31
 
+Mike Dunn miked...@newsguy.com
+   palmtreo680 pxa270
+
 Kristoffer Ericson kristoffer.eric...@gmail.com
 
jornada SA1110
diff --git a/board/palmtreo680/Makefile b/board/palmtreo680/Makefile
new file mode 100644
index 000..34ffb99
--- /dev/null
+++ b/board/palmtreo680/Makefile
@@ -0,0 +1,34 @@
+#
+# Palm Treo680 Support
+#
+# Copyright (C) 2013 Mike Dunn miked...@newsguy.com
+#
+# This file is released under the terms of GPL v2 and any later version.
+# See the file COPYING in the root directory of the source tree for details.
+
+include $(TOPDIR)/config.mk
+
+LIB= $(obj)lib$(BOARD).o
+
+COBJS  := palmtreo680.o
+
+SRCS   := $(COBJS:.o=.c)
+OBJS   := $(addprefix $(obj),$(COBJS))
+
+$(LIB):$(obj).depend $(OBJS)
+   $(call cmd_link_o_target, $(OBJS))
+
+clean:
+   rm -f $(OBJS)
+
+distclean: clean
+   rm -f $(LIB) core *.bak $(obj).depend
+
+#
+
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
+
+sinclude $(obj).depend
+
+#
diff --git a/board/palmtreo680/palmtreo680.c b/board/palmtreo680/palmtreo680.c
new file mode 100644
index 000..d721657
--- /dev/null
+++ b/board/palmtreo680/palmtreo680.c
@@ -0,0 +1,154 @@
+/*
+ * Palm Treo 680 Support
+ *
+ * Copyright (C) 2013 Mike Dunn miked...@newsguy.com
+ *
+ * This file is released under the terms of GPL v2

[U-Boot] [PATCH v5] palmtreo680: add utility that writes u-boot to flash

2013-04-19 Thread Mike Dunn
This adds a userspace linux utility that writes the u-boot image to an mtd
partition on the docg4 nand flash.

A special utility is required to do this because u-boot is partially loaded by
an initial program loader (IPL) that is permanently programmed to the boot
region of the flash.  This IPL expects the image to be written in a unique
format. The characteristics of this format can be summarized as follows:
  - Flash blocks to be loaded must have a magic number in the oob bytes of the
first page of the block.
  - Each page must be written redundantly in the subsequent page.
  - The integrated flash controller's reliable mode is used, requiring that
alternate 2k regions (4 pages) are skipped when writing.
For these reasons, a u-boot image can not be written using nandwrite from
mtd-utils.

Signed-off-by: Mike Dunn miked...@newsguy.com
---
Changelog:
  v5: on error, return sensible code from errno.h
  v4:
- use return instead of exit
- use calloc() instead of malloc()
- remove call to read() from within while loop test 
  v3: new patch; split off from patch 7 in v2 of patchset

 tools/palmtreo680/flash_u-boot.c |  177 ++
 1 files changed, 177 insertions(+), 0 deletions(-)
 create mode 100644 tools/palmtreo680/flash_u-boot.c

diff --git a/tools/palmtreo680/flash_u-boot.c b/tools/palmtreo680/flash_u-boot.c
new file mode 100644
index 000..3d8296f
--- /dev/null
+++ b/tools/palmtreo680/flash_u-boot.c
@@ -0,0 +1,177 @@
+/*
+ * Copyright (C) 2013 Mike Dunn miked...@newsguy.com
+ *
+ * This file is released under the terms of GPL v2 and any later version.
+ * See the file COPYING in the root directory of the source tree for details.
+ *
+ *
+ * This is a userspace Linux utility that, when run on the Treo 680, will
+ * program u-boot to flash.  The docg4 driver *must* be loaded with the
+ * reliable_mode and ignore_badblocks parameters enabled:
+ *
+ *modprobe docg4 ignore_badblocks=1 reliable_mode=1
+ *
+ * This utility writes the concatenated spl + u-boot image to the start of the
+ * mtd device in the format expected by the IPL/SPL.  The image file and mtd
+ * device node are passed to the utility as arguments.  The blocks must have
+ * been erased beforehand.
+ *
+ * When you compile this, note that it links to libmtd from mtd-utils, so 
ensure
+ * that your include and lib paths include this.
+ */
+
+#include stdio.h
+#include stdlib.h
+#include sys/stat.h
+#include fcntl.h
+#include string.h
+#include sys/types.h
+#include unistd.h
+#include errno.h
+#include mtd/mtd-user.h
+#include libmtd.h
+
+#define RELIABLE_BLOCKSIZE  0x1 /* block capacity in reliable mode */
+#define STANDARD_BLOCKSIZE  0x4 /* block capacity in normal mode */
+#define PAGESIZE 512
+#define PAGES_PER_BLOCK 512
+#define OOBSIZE 7  /* available to user (16 total) */
+
+uint8_t ff_oob[OOBSIZE] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
+
+/* this is the magic number the IPL looks for (ASCII BIPO) */
+uint8_t page0_oob[OOBSIZE] = {'B', 'I', 'P', 'O', 0xff, 0xff, 0xff};
+
+int main(int argc, char * const argv[])
+{
+   int devfd, datafd, num_blocks, block;
+   off_t file_size;
+   libmtd_t mtd_desc;
+   struct mtd_dev_info devinfo;
+   uint8_t *blockbuf;
+   char response[8];
+
+   if (argc != 3) {
+   printf(usage: %s image file mtd dev node\n, argv[0]);
+   return -EINVAL;
+   }
+
+   mtd_desc = libmtd_open();
+   if (mtd_desc == NULL) {
+   int errsv = errno;
+   fprintf(stderr, can't initialize libmtd\n);
+   return -errsv;
+   }
+
+   /* open the spl image file and mtd device */
+   datafd = open(argv[1], O_RDONLY);
+   if (datafd == -1) {
+   int errsv = errno;
+   perror(argv[1]);
+   return -errsv;
+   }
+   devfd = open(argv[2], O_WRONLY);
+   if (devfd == -1) {
+   int errsv = errno;
+   perror(argv[2]);
+   return -errsv;
+   }
+   if (mtd_get_dev_info(mtd_desc, argv[2], devinfo)  0) {
+   int errsv = errno;
+   perror(argv[2]);
+   return -errsv;
+   }
+
+   /* determine the number of blocks needed by the image */
+   file_size = lseek(datafd, 0, SEEK_END);
+   if (file_size == (off_t)-1) {
+   int errsv = errno;
+   perror(lseek);
+   return -errsv;
+   }
+   num_blocks = (file_size + RELIABLE_BLOCKSIZE - 1) / RELIABLE_BLOCKSIZE;
+   file_size = lseek(datafd, 0, SEEK_SET);
+   if (file_size == (off_t)-1) {
+   int errsv = errno;
+   perror(lseek);
+   return -errsv;
+   }
+   printf(The mtd partition contains %d blocks\n, devinfo.eb_cnt);
+   printf(U-boot will occupy %d blocks\n, num_blocks);
+   if (num_blocks  devinfo.eb_cnt) {
+   fprintf(stderr, Insufficient blocks

Re: [U-Boot] [PATCH v4] palmtreo680: add utility that writes u-boot to flash

2013-04-18 Thread Mike Dunn
On 04/18/2013 06:54 AM, Marek Vasut wrote:
 Dear Mike Dunn,
 
 [...]
 
 +if (argc != 3) {
 +printf(usage: %s image file mtd dev node\n, argv[0]);
 
 btw is this /dev/mtdX or /dev/mtdblockX ?


/dev/mtdx  You must have defined a partition that starts at the offset at which
you are placing the u-boot image, and of course is big enough to hold the image.


 
 +return -1;
 
 errno.h didn't work? Like ... return -EINVAL or such ?


'return -EINVAL' works, sure.  Are you suggesting that the utility should return
an intelligent error code at all failure exit points?  Like if the call to
calloc() fails, it should return -ENOMEM?  I could do that if you prefer.  I
didn't worry about it because I always print the reason for the failure to
stderr, usually by way of perror().  Sorry, I guess I didn't understand your
initial suggestion.


 
 [...]
 
 +blockbuf = calloc(RELIABLE_BLOCKSIZE, 1);
 
 calloc() semantics are misunderstood by so many :-(


calloc(RELIABLE_BLOCKSIZE, sizeof(char)) ?


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


[U-Boot] [PATCH v4] add support for the palm treo 680 board

2013-04-16 Thread Mike Dunn
A quick overview of u-boot implementation on the treo 680...

The treo 680 has a Diskonchip G4 nand flash chip.  This device has a 2k region
that maps to the system bus at the reset vector in a NOR-like fashion so that it
can be used as the boot device.  The phone is shipped with this 2k region
configured as write-protected (can't be modified) and programmed with an initial
program loader (IPL).  At power-up, this IPL loads the contents of two flash
blocks to SDRAM and jumps to it.  The capacity of the two blocks is not large
enough to hold all of u-boot, so a u-boot SPL is used.  To conserve flash space,
these two blocks and the necessary number of subsequent blocks are programmed
with a concatenated spl + u-boot image.  That way, the IPL will also load a
portion of u-boot proper, and when the spl runs, it relocates the portion of
u-boot that the IPL has already loaded, and then resumes loading the remaining
part of u-boot before jumping to it.

The default_environment is used (CONFIG_ENV_IS_NOWHERE) because I didn't think
that having a writable environment was worth the cost of a flash block, although
adding it would be straightforward.  I abuse the CONFIG_EXTRA_ENV_SETTINGS
option to specify the usbtty for the console (CONFIG_SYS_CONSOLE_IS_IN_ENV).

Support for the LCD is included, but currently it is only useful for displaying
the u-boot splash screen.  But if u-boot is built without the usbtty console, it
does display the auto-boot progress nicely.

Signed-off-by: Mike Dunn miked...@newsguy.com
---
Changelog:
  v4:
- use CONFIG_MACH_TYPE instead of MACH_TYPE_TREO680 to initialize
  bi_arch_number
- use offset from CONFIG_SYS_DRAM_BASE to initialize bi_boot_params,
  instead of hard-coding an absolute address
- use shift operator to set one bit when initializing gpio register
- remove memcpy() definition from spl build; use
  CONFIG_SPL_LIBGENERIC_SUPPORT to properly build and link with
  u-boot's memcpy()
- config file cleanup: remove erroneous comments, unneeded numerical
  definitions
- edited README.palmtreo680 a bit
  v3: flash_u-boot utility split into separate patch
  v2:
- tabs removed in #defines in palmtreo680.h
- utility for programming u-boot to flash moved to tools/palmtreo680

 CREDITS   |4 +
 MAINTAINERS   |3 +
 board/palmtreo680/Makefile|   34 ++
 board/palmtreo680/palmtreo680.c   |  154 +
 board/palmtreo680/palmtreo680_spl.lds |   51 +++
 boards.cfg|1 +
 doc/README.palmtreo680|  581 +
 include/configs/palmtreo680.h |  287 
 8 files changed, 1115 insertions(+), 0 deletions(-)
 create mode 100644 board/palmtreo680/Makefile
 create mode 100644 board/palmtreo680/palmtreo680.c
 create mode 100644 board/palmtreo680/palmtreo680_spl.lds
 create mode 100644 doc/README.palmtreo680
 create mode 100644 include/configs/palmtreo680.h

diff --git a/CREDITS b/CREDITS
index 7c1458f..3b657e9 100644
--- a/CREDITS
+++ b/CREDITS
@@ -124,6 +124,10 @@ N: James F. Dougherty
 E: j...@gigabitnetworks.com
 D: Port to the MOUSSE board
 
+N: Mike Dunn
+E: miked...@newsguy.com
+D: Palmtreo680 board, docg4 nand flash driver
+
 N: Dave Ellis
 E: d...@sixnetio.com
 D: EEPROM Speedup, SXNI855T port
diff --git a/MAINTAINERS b/MAINTAINERS
index 1614b91..db62af1 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -650,6 +650,9 @@ Wolfgang Denk w...@denx.de
imx27lite   i.MX27
qongi.MX31
 
+Mike Dunn miked...@newsguy.com
+   palmtreo680 pxa270
+
 Kristoffer Ericson kristoffer.eric...@gmail.com
 
jornada SA1110
diff --git a/board/palmtreo680/Makefile b/board/palmtreo680/Makefile
new file mode 100644
index 000..34ffb99
--- /dev/null
+++ b/board/palmtreo680/Makefile
@@ -0,0 +1,34 @@
+#
+# Palm Treo680 Support
+#
+# Copyright (C) 2013 Mike Dunn miked...@newsguy.com
+#
+# This file is released under the terms of GPL v2 and any later version.
+# See the file COPYING in the root directory of the source tree for details.
+
+include $(TOPDIR)/config.mk
+
+LIB= $(obj)lib$(BOARD).o
+
+COBJS  := palmtreo680.o
+
+SRCS   := $(COBJS:.o=.c)
+OBJS   := $(addprefix $(obj),$(COBJS))
+
+$(LIB):$(obj).depend $(OBJS)
+   $(call cmd_link_o_target, $(OBJS))
+
+clean:
+   rm -f $(OBJS)
+
+distclean: clean
+   rm -f $(LIB) core *.bak $(obj).depend
+
+#
+
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
+
+sinclude $(obj).depend
+
+#
diff --git a/board/palmtreo680/palmtreo680.c b/board/palmtreo680/palmtreo680.c
new file mode 100644
index 000..d721657
--- /dev/null
+++ b/board/palmtreo680/palmtreo680.c
@@ -0,0 +1,154 @@
+/*
+ * Palm Treo 680 Support
+ *
+ * Copyright (C) 2013 Mike

Re: [U-Boot] [PATCH v3 8/8] palmtreo680: add utility that writes u-boot to flash

2013-04-16 Thread Mike Dunn
Thanks again Marek.  A question below...


On 04/14/2013 10:38 AM, Marek Vasut wrote:


[...]


 +
 +if (argc != 3) {
 +printf(usage: %s image file mtd dev node\n, argv[0]);
 +exit(-1);
 
 Use proper errno and return as you're returning from main() anyway.


Agreed regarding 'return'.  But should I be concerned with setting or preserving
errno before all 'return -1' lines?  Is it normal practice for a common utility
to set errno?  errno will have to be saved in many places, since perror() itself
can change it.  This will add many more lines of code.


[...]


 +
 +blockbuf = malloc(RELIABLE_BLOCKSIZE);
 
 Do you not want to use some calloc() here to make sure the blockbuf is 
 zeroed?


Not necessary here; the buffer is always filled or the utility exits with error.
 But will change to calloc() anyway.

[...]


 +
 +/* read data for one block from file */
 +while (len != 0  (read_ret = read(datafd, buf, len)) != 0) {
 
 Uh, this really might be a candidate for IOCCC, split this please ...


Well, OK, but... I normally don't embed calls in tests, but I do it here because
the read is performed at the start of each loop iteration, and I thought this
made it clearer and more concise.  Basically it means loop while there's still
more data to write, and read() does not return EOF.

Actually, read() should never return EOF, because earlier I check the file
length, so if I'm going to do the sanity check anyway, maybe it should be 
separate.

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


[U-Boot] [PATCH v4] palmtreo680: add utility that writes u-boot to flash

2013-04-16 Thread Mike Dunn
This adds a userspace linux utility that writes the u-boot image to an mtd
partition on the docg4 nand flash.

A special utility is required to do this because u-boot is partially loaded by
an initial program loader (IPL) that is permanently programmed to the boot
region of the flash.  This IPL expects the image to be written in a unique
format. The characteristics of this format can be summarized as follows:
  - Flash blocks to be loaded must have a magic number in the oob bytes of the
first page of the block.
  - Each page must be written redundantly in the subsequent page.
  - The integrated flash controller's reliable mode is used, requiring that
alternate 2k regions (4 pages) are skipped when writing.
For these reasons, a u-boot image can not be written using nandwrite from
mtd-utils.

Signed-off-by: Mike Dunn miked...@newsguy.com
---
Changelog:
  v4:
- use return instead of exit
- use calloc() instead of malloc()
- remove call to read() from within while loop test 
  v3: new patch; split off from patch 7 in v2 of patchset

I was wrong, Marek... the read() will return EOF while writing the last block,
unless the size of the image is such that it fills the last block.  Otherwise,
the last block is only partially written, and stops at EOF.  This is fine.

 tools/palmtreo680/flash_u-boot.c |  168 ++
 1 files changed, 168 insertions(+), 0 deletions(-)
 create mode 100644 tools/palmtreo680/flash_u-boot.c

diff --git a/tools/palmtreo680/flash_u-boot.c b/tools/palmtreo680/flash_u-boot.c
new file mode 100644
index 000..8f8dadf
--- /dev/null
+++ b/tools/palmtreo680/flash_u-boot.c
@@ -0,0 +1,168 @@
+/*
+ * Copyright (C) 2013 Mike Dunn miked...@newsguy.com
+ *
+ * This file is released under the terms of GPL v2 and any later version.
+ * See the file COPYING in the root directory of the source tree for details.
+ *
+ *
+ * This is a userspace Linux utility that, when run on the Treo 680, will
+ * program u-boot to flash.  The docg4 driver *must* be loaded with the
+ * reliable_mode and ignore_badblocks parameters enabled:
+ *
+ *modprobe docg4 ignore_badblocks=1 reliable_mode=1
+ *
+ * This utility writes the concatenated spl + u-boot image to the start of the
+ * mtd device in the format expected by the IPL/SPL.  The image file and mtd
+ * device node are passed to the utility as arguments.  The blocks must have
+ * been erased beforehand.
+ *
+ * When you compile this, note that it links to libmtd from mtd-utils, so 
ensure
+ * that your include and lib paths include this.
+ */
+
+#include stdio.h
+#include stdlib.h
+#include sys/stat.h
+#include fcntl.h
+#include string.h
+#include sys/types.h
+#include unistd.h
+#include errno.h
+#include mtd/mtd-user.h
+#include libmtd.h
+
+#define RELIABLE_BLOCKSIZE  0x1 /* block capacity in reliable mode */
+#define STANDARD_BLOCKSIZE  0x4 /* block capacity in normal mode */
+#define PAGESIZE 512
+#define PAGES_PER_BLOCK 512
+#define OOBSIZE 7  /* available to user (16 total) */
+
+uint8_t ff_oob[OOBSIZE] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
+
+/* this is the magic number the IPL looks for (ASCII BIPO) */
+uint8_t page0_oob[OOBSIZE] = {'B', 'I', 'P', 'O', 0xff, 0xff, 0xff};
+
+int main(int argc, char * const argv[])
+{
+   int devfd, datafd, num_blocks, block;
+   off_t file_size;
+   libmtd_t mtd_desc;
+   struct mtd_dev_info devinfo;
+   uint8_t *blockbuf;
+   char response[8];
+
+   if (argc != 3) {
+   printf(usage: %s image file mtd dev node\n, argv[0]);
+   return -1;
+   }
+
+   mtd_desc = libmtd_open();
+   if (mtd_desc == NULL) {
+   fprintf(stderr, can't initialize libmtd\n);
+   return -1;
+   }
+
+   /* open the spl image file and mtd device */
+   datafd = open(argv[1], O_RDONLY);
+   if (datafd == -1) {
+   perror(argv[1]);
+   return -1;
+   }
+   devfd = open(argv[2], O_WRONLY);
+   if (devfd == -1) {
+   perror(argv[2]);
+   return -1;
+   }
+   if (mtd_get_dev_info(mtd_desc, argv[2], devinfo)  0) {
+   fprintf(stderr, mtd_get_dev_info failed\n);
+   return -1;
+   }
+
+   /* determine the number of blocks needed by the image */
+   file_size = lseek(datafd, 0, SEEK_END);
+   if (file_size == (off_t)-1) {
+   perror(lseek);
+   return -1;
+   }
+   num_blocks = (file_size + RELIABLE_BLOCKSIZE - 1) / RELIABLE_BLOCKSIZE;
+   file_size = lseek(datafd, 0, SEEK_SET);
+   if (file_size == (off_t)-1) {
+   perror(lseek);
+   return -1;
+   }
+   printf(The mtd partition contains %d blocks\n, devinfo.eb_cnt);
+   printf(U-boot will occupy %d blocks\n, num_blocks);
+   if (num_blocks  devinfo.eb_cnt) {
+   fprintf(stderr, Insufficient blocks on partition\n

Re: [U-Boot] [PATCH v3 7/8] add support for palm treo 680 board

2013-04-15 Thread Mike Dunn
On 04/14/2013 10:34 AM, Marek Vasut wrote:
 Dear Mike Dunn,
 
 [...]
 
 +int board_init(void)
 +{
 +/* We have RAM, disable cache */
 +dcache_disable();
 +icache_disable();
 +
 +gd-bd-bi_arch_number = MACH_TYPE_TREO680;
 
 This is not needed, just define CONFIG_MACH_TYPE in treo680.h


Oops, yes, I see.


 
 +gd-bd-bi_boot_params = 0xa100;
 
 Is this not CONFIG_SYS_DRAM_BASE + 0x100 ? I think it is.


Correct.

[...]


 +
 +#ifdef CONFIG_MMC
 +int board_mmc_init(bd_t *bis)
 +{
 +writel(0x0400, GPSR(42)); /* power on */
 
 Can you not use your bitlibrary for this stuff? Or maybe at least use (1  
 n) 
 here to make it more readable.


Well, bitrev reverses the bits; not really applicable here.  But you're right, a
shift would be better for clarity.


 
 But seriously, do you not want to (in the longer run) implement proper GPIO 
 driver for PXA? That'd help a lot. Also, do you not want to volunteer to fix 
 PXA? I think it's a bit rotting all around ;-)


Sure, I'd be open to that.


 
 +return pxa_mmc_register(0);
 +}
 +#endif
 +
 +void board_nand_init(void)
 +{
 +/* we have one 128M diskonchip G4  */
 +
 +struct mtd_info *mtd = nand_info[0];
 +struct nand_chip *nand = docg4_nand_chip;
 +if (docg4_nand_init(mtd, nand, 0))
 +hang();
 +}
 +
 +#ifdef CONFIG_SPL_BUILD
 +void *memcpy(void *dest, const void *src, size_t count)
 +{
 
 CONFIG_SPL_LIBCOMMON_SUPPORT shall give you memcpy.


This does not appear to be the case.  Unless I'm mistaken, memcpy() will be in
either lib/libgeneric.o (lib/string.c) or arch/arm/lib/libarm.o
(arch/arm/lib/memcpy.S) - depending on CONFIG_USE_ARCH_MEMCPY - but in neither
case will it be in common/libcommon.o.


 
 [...]
 
 +void nand_boot(void)
 +{
 [...]
 
 Will the common/spl/ NAND loading code not cut it here? I guess it won't 
 since 
 PXA is FUBAR when it comes to any kind of SPL loading. Do you not want to fix 
 that? I'd be really grateful if you did ;-)


Well, palmtreo680 is a special case because its nand_boot() resumes loading
u-boot where the IPL left off.  IOW, the IPL has already loaded a portion of
u-boot, whereas a generic nand_boot() will want to load the entire image.

I'd be willing to help with pxa spl code, but that might be difficult without
hardware to test on, no?


 
 [...]
 
 btw. you dont really need to #define CONFIG_PXA27X to value 1 in your 
 config, 
 just remove those useless trailing 1s .


Ah yes.  And I'm finding some other clean-ups in the config file.

Thanks again Marek,
Mike
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


Re: [U-Boot] [PATCH v3 7/8] add support for palm treo 680 board

2013-04-15 Thread Mike Dunn
On 04/15/2013 11:33 AM, Marek Vasut wrote:
 Dear Mike Dunn,
 
 [...]
 
 +#ifdef CONFIG_SPL_BUILD
 +void *memcpy(void *dest, const void *src, size_t count)
 +{

 CONFIG_SPL_LIBCOMMON_SUPPORT shall give you memcpy.

 This does not appear to be the case.  Unless I'm mistaken, memcpy() will be
 in either lib/libgeneric.o (lib/string.c) or arch/arm/lib/libarm.o
 (arch/arm/lib/memcpy.S) - depending on CONFIG_USE_ARCH_MEMCPY - but in
 neither case will it be in common/libcommon.o.
 
 CONFIG_SPL_LIBGENERIC_SUPPORT then ;-)


smacks forehead

Does preclude use of CONFIG_USE_ARCH_MEMCPY though.

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


Re: [U-Boot] [PATCH v2 0/7] palm treo 680 smartphone board support

2013-04-14 Thread Mike Dunn
On 04/14/2013 10:44 AM, Marek Vasut wrote:
 Hi Mike,
 
 Hi,

 This patchset adds support for the Palm Treo 680 smartphone.  I had to make
 some minor tweaks to u-boot to get things working.  Most of these changes
 are small, and most only touch the pxa arch.

 Thanks for looking.
 
 I pushed what I considered ok to u-boot-pxa/master, please start your reworks 
 on 
 top of that.


Will do.  Thanks a lot for your time and effort in reviewing!

I forgot to add 'v3' to the subject line of patch 5/8 in the last set I sent:

[PATCH 5/8] lib: import bitrev library from the linux kernel

Don't know if that will cause problems or not.  The contents of the patch are
unchanged from v2, but the description added the HEAD commit from the kernel I
took the code from, as we discussed.

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


Re: [U-Boot] [PATCH v2 5/7] lib: import bitrev library from the linux kernel

2013-04-12 Thread Mike Dunn
On 04/11/2013 12:19 PM, Marek Vasut wrote:
 Dear Mike Dunn,
 
 This patch adds the bitrev library from the linux kernel.  This is a simple
 algorithm that uses an 8 bit look-up table to reverse the bits in data
 types of 8, 16, or 32 bit widths.  The docg4 nand flash driver uses it.

 [port from linux kernel 2.6.20 commit
 a5cfc1ec58a07074dacb6aa8c79eff864c966d12]
 
 Why did you port it from such an ancient kernel? Newer version is not an 
 option?


Maybe I misunderstood and gave the wrong information (probably, now that I think
about it).  I took it fom the latest kernel, but reported the commit that added
it to the kernel.

In this case, it's a simple algorithm and only a couple trivial changes were
made since it was first added to the kernel, so the error is probably
inconsequential, but I'll resubmit, reporting the HEAD of the kernel I took it
from if you like.

BTW, I did the same for the docg4 driver, but I did the u-boot port a while ago,
so in that case it's correct, at least practically.  Since I did the port, the
kernel docg4 driver had some enhancements (reliable mode) that still need to be
brought into u-boot.

Thanks Marek,
Mike

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


Re: [U-Boot] [PATCH v2 7/7] add support for palm treo 680 board

2013-04-12 Thread Mike Dunn
On 04/11/2013 12:20 PM, Marek Vasut wrote:
 Dear Mike Dunn,
 
 A quick overview of u-boot implementation on the treo 680...

 The treo 680 has a Diskonchip G4 nand flash chip.  This device has a 2k
 region that maps to the system bus at the reset vector in a NOR-like
 fashion so that it can be used as the boot device.  The phone is shipped
 with this 2k region configured as write-protected (can't be modified) and
 programmed with an initial program loader (IPL).  At power-up, this IPL
 loads the contents of two flash blocks to SDRAM and jumps to it.  The
 capacity of the two blocks is not large enough to hold all of u-boot, so a
 u-boot SPL is used.  To conserve flash space, these two blocks and the
 necessary number of subsequent blocks are programmed with a concatenated
 spl + u-boot image.  That way, the IPL will also load a portion of u-boot
 proper, and when the spl runs, it relocates the portion of u-boot that the
 IPL has already loaded, and then resumes loading the remaining part of
 u-boot before jumping to it.

 The default_environment is used (CONFIG_ENV_IS_NOWHERE) because I didn't
 think that having a writable environment was worth the cost of a flash
 block, although adding it would be straightforward.  I abuse the
 CONFIG_EXTRA_ENV_SETTINGS option to specify the usbtty for the console
 (CONFIG_SYS_CONSOLE_IS_IN_ENV).

 Support for the LCD is included, but currently it is only useful for
 displaying the u-boot splash screen.  But if u-boot is built without the
 usbtty console, it does display the auto-boot progress nicely.

 Signed-off-by: Mike Dunn miked...@newsguy.com
 
 I think the tool shall really go as a separate patch. Besides, can the tool 
 not 
 be implemented as a part of u-boot's mkimage infrastructure?


OK, I can make the flash_u-boot utility (which writes u-boot to the flash boot
blocks) a separate patch.

As for making it part of mkimage...  I didn't really consider that because based
on my (limited) knowledge, I figured they are unrelated.  As I understand it,
mkimage creates an OS image file that u-boot can parse and load.  flash_u-boot
is a utility that performs the task of writing u-boot itself to flash.

I figured that mine was a special case, since u-boot must be written in a
special format (redundant pages) and in a special manner (alternate 4k regions
skipped), with the flash device in a special mode, and so it can not be done in
the normal manner; e.g., 'nandwrite' from mtd-utils, or its u-boot 'nand write'
equivalent, even if you first ran the u-boot image through a separate utility
that simply converted the format of the image.

Hope that makes sense.  Any insight appreciated.  I'll take a look at what's in
the tools directory.

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


Re: [U-Boot] [PATCH v2 6/7] mtd: nand: add driver for diskonchip g4 nand flash

2013-04-12 Thread Mike Dunn
On 04/11/2013 02:00 PM, Scott Wood wrote:
 On 04/10/2013 07:45:27 PM, Mike Dunn wrote:
 This patch adds a driver for the diskonchip G4 nand flash device.  It is 
 based
 on the driver from the linux kernel.

 This also includes a separate SPL driver.  A separate SPL driver is used 
 because
 the device operates in a different mode (reliable mode) when loading a boot
 image, and also because the storage format of the boot image is different 
 from
 normal data (pages are stored redundantly).  The SPL driver basically mimics 
 how
 a typical IPL reads data from the device.  The special operating mode and
 storage format are used to compensate for the fact that the IPL does not 
 contain
 the BCH ecc decoding algorithm (due to size constraints).  Although the 
 u-boot
 SPL *could* use ecc, it operates like an IPL for the sake of simplicity and
 uniformity, since the IPL and SPL share the task of loading the u-boot image.
 As a side benefit, the SPL driver is very small.

 [port from linux kernel 3.4 commit 570469f3bde7f71cc1ece07a18d54a05b6a8775d]

 Signed-off-by: Mike Dunn miked...@newsguy.com
 ---
  drivers/mtd/nand/Makefile|2 +
  drivers/mtd/nand/docg4.c | 1035 
 ++
  drivers/mtd/nand/docg4_spl.c |  222 +
  include/linux/mtd/docg4.h|  134 ++
  4 files changed, 1393 insertions(+), 0 deletions(-)
  create mode 100644 drivers/mtd/nand/docg4.c
  create mode 100644 drivers/mtd/nand/docg4_spl.c
  create mode 100644 include/linux/mtd/docg4.h
 [snip]
 +#ifdef DEBUG_DOCG4
 +#define dbg(format, arg...) printf(DEBUG:  format, ##arg)
 +#else
 +#define dbg(format, arg...) do {} while (0)
 +#endif
 
 Maybe use MTDDEBUG?


Ok.  Alternatively, I wouldn't mind pulling them out entirely.  It's been
behaving quite nicely, and amyway, in the past I used a JTAG emultor rather than
the printfs.


 
 Otherwise:
 Acked-by: Scott Wood scottw...@freescale.com


Many thanks Scott,
Mike
___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] [PATCH v3 1/8] pxa_lcd: add the ACX544AKN lcd device

2013-04-12 Thread Mike Dunn
This adds the definitions required to support the LCD device on the Palm Treo
680.

Signed-off-by: Mike Dunn miked...@newsguy.com
---
Changelog:
v3: no change
v2: no change

 drivers/video/pxa_lcd.c |   32 
 1 files changed, 32 insertions(+), 0 deletions(-)

diff --git a/drivers/video/pxa_lcd.c b/drivers/video/pxa_lcd.c
index b40ec36..d5fbe7b 100644
--- a/drivers/video/pxa_lcd.c
+++ b/drivers/video/pxa_lcd.c
@@ -248,6 +248,38 @@ vidinfo_t panel_info = {
 };
 #endif /* CONFIG_ACX517AKN */
 
+#ifdef CONFIG_ACX544AKN
+
+# define LCD_BPP   LCD_COLOR16
+
+/* you have to set lccr0 and lccr3 (including pcd) */
+# define REG_LCCR0 0x003008f9
+# define REG_LCCR3 0x0477 /* 16bpp */
+
+vidinfo_t panel_info = {
+   .vl_col = 320,
+   .vl_row = 320,
+   .vl_width   = 320,
+   .vl_height  = 320,
+   .vl_clkp= CONFIG_SYS_LOW,
+   .vl_oep = CONFIG_SYS_LOW,
+   .vl_hsp = CONFIG_SYS_LOW,
+   .vl_vsp = CONFIG_SYS_LOW,
+   .vl_dp  = CONFIG_SYS_LOW,
+   .vl_bpix= LCD_BPP,
+   .vl_lbw = 0,
+   .vl_splt= 0,
+   .vl_clor= 1,
+   .vl_tft = 1,
+   .vl_hpw = 0x05,
+   .vl_blw = 0x13,
+   .vl_elw = 0x08,
+   .vl_vpw = 0x02,
+   .vl_bfw = 0x07,
+   .vl_efw = 0x05,
+};
+#endif /* CONFIG_ACX544AKN */
+
 /*--*/
 
 #ifdef CONFIG_LQ038J7DH53
-- 
1.7.8.6

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


[U-Boot] [PATCH v3 0/8] palm treo 680 smartphone board support

2013-04-12 Thread Mike Dunn
This patchset adds support for the Palm Treo 680 smartphone.  I had to make some
minor tweaks to u-boot to get things working.  Most of these changes are small,
and most only touch the pxa arch.

Thanks for looking.

Changelog:
v3:
  - changed commit message for patch that adds bitrev library to specify the
HEAD commit of the linux kernel that the library was taken from, not only
the commit that added it to the kernel
  - in docg4 driver patch, replaced dbg macro with MTDDEBUG
  - put flash_u-boot utility in a separate patch

v2:
  - tabs removed in #defines in palmtreo680.h
  - use '__weak' macro in pxa_lcd
  - remove externs from function prototypes in bitrev.h
  - remove commented-out code from docg4.c
  - the CONFIG_SYS_LCD_PXA_NO_L_BIAS patch was removed; the same result
is accomplished by re-configuring the L_BIAS gpio in the board-specific
lcd_enable(), which runs after the driver initialization
  - userland utility for programming u-boot to flash moved to tools/palmtreo680
  - commit message for patches that add bitrev library and docg4 driver contain
the commit and linux version for when the code was added to linux

Mike Dunn (8):
  pxa_lcd: add the ACX544AKN lcd device
  pxa_lcd: make lcd_enable() a weak pointer
  pxa27x_udc: remove call to unimplemented set_GPIO_mode()
  arm: bootm: call udc_disable() before booting linux
  lib: import bitrev library from the linux kernel
  mtd: nand: add driver for diskonchip g4 nand flash
  add support for palm treo 680 board
  palmtreo680: add utility that writes u-boot to flash

 CREDITS  |4 +
 MAINTAINERS  |3 +
 arch/arm/include/asm/arch-pxa/hardware.h |   11 -
 arch/arm/include/asm/bootm.h |1 +
 arch/arm/lib/bootm.c |1 +
 board/palmtreo680/Makefile   |   34 +
 board/palmtreo680/palmtreo680.c  |  179 ++
 board/palmtreo680/palmtreo680_spl.lds|   51 ++
 boards.cfg   |1 +
 doc/README.palmtreo680   |  570 +
 drivers/mtd/nand/Makefile|2 +
 drivers/mtd/nand/docg4.c | 1028 ++
 drivers/mtd/nand/docg4_spl.c |  222 +++
 drivers/usb/gadget/pxa27x_udc.c  |4 +-
 drivers/video/pxa_lcd.c  |   34 +-
 include/configs/palmtreo680.h|  295 +
 include/linux/bitrev.h   |   23 +
 include/linux/mtd/docg4.h|  134 
 lib/Makefile |1 +
 lib/bitrev.c |   59 ++
 tools/palmtreo680/flash_u-boot.c |  167 +
 21 files changed, 2811 insertions(+), 13 deletions(-)
 create mode 100644 board/palmtreo680/Makefile
 create mode 100644 board/palmtreo680/palmtreo680.c
 create mode 100644 board/palmtreo680/palmtreo680_spl.lds
 create mode 100644 doc/README.palmtreo680
 create mode 100644 drivers/mtd/nand/docg4.c
 create mode 100644 drivers/mtd/nand/docg4_spl.c
 create mode 100644 include/configs/palmtreo680.h
 create mode 100644 include/linux/bitrev.h
 create mode 100644 include/linux/mtd/docg4.h
 create mode 100644 lib/bitrev.c
 create mode 100644 tools/palmtreo680/flash_u-boot.c

-- 
1.7.8.6

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


[U-Boot] [PATCH v3 3/8] pxa27x_udc: remove call to unimplemented set_GPIO_mode()

2013-04-12 Thread Mike Dunn
If CONFIG_USB_DEV_PULLUP_GPIO is defined, a link error occurs because the
set_GPIO_mode() helper function is not implemented.  This function doesn't do
much except make the code a little more readable, so I just manually coded its
equivalent and removed the prototype from the header file.  It is invoked no
where else in the code.

While I was at it, I noticed that two other function prototypes in the same
header file are also neither implemented nor invoked anywhere, so I removed them
as well.

Signed-off-by: Mike Dunn miked...@newsguy.com
---
Changelog:
  v3: no change
  v2: no change

 arch/arm/include/asm/arch-pxa/hardware.h |   11 ---
 drivers/usb/gadget/pxa27x_udc.c  |4 +++-
 2 files changed, 3 insertions(+), 12 deletions(-)

diff --git a/arch/arm/include/asm/arch-pxa/hardware.h 
b/arch/arm/include/asm/arch-pxa/hardware.h
index 44b800f..2397bce 100644
--- a/arch/arm/include/asm/arch-pxa/hardware.h
+++ b/arch/arm/include/asm/arch-pxa/hardware.h
@@ -77,17 +77,6 @@
 #define GPIO_FALLING_EDGE  1
 #define GPIO_RISING_EDGE   2
 #define GPIO_BOTH_EDGES3
-extern void set_GPIO_IRQ_edge( int gpio_nr, int edge_mask );
-
-/*
- * Handy routine to set GPIO alternate functions
- */
-extern void set_GPIO_mode( int gpio_mode );
-
-/*
- * return current lclk frequency in units of 10kHz
- */
-extern unsigned int get_lclk_frequency_10khz(void);
 
 #endif
 
diff --git a/drivers/usb/gadget/pxa27x_udc.c b/drivers/usb/gadget/pxa27x_udc.c
index 4c00081..71cc0f2 100644
--- a/drivers/usb/gadget/pxa27x_udc.c
+++ b/drivers/usb/gadget/pxa27x_udc.c
@@ -610,7 +610,9 @@ void udc_connect(void)
 
 #ifdef CONFIG_USB_DEV_PULLUP_GPIO
/* Turn on the USB connection by enabling the pullup resistor */
-   set_GPIO_mode(CONFIG_USB_DEV_PULLUP_GPIO | GPIO_OUT);
+   writel(readl(GPDR(CONFIG_USB_DEV_PULLUP_GPIO))
+| GPIO_bit(CONFIG_USB_DEV_PULLUP_GPIO),
+  GPDR(CONFIG_USB_DEV_PULLUP_GPIO));
writel(GPIO_bit(CONFIG_USB_DEV_PULLUP_GPIO), 
GPSR(CONFIG_USB_DEV_PULLUP_GPIO));
 #else
/* Host port 2 transceiver D+ pull up enable */
-- 
1.7.8.6

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


[U-Boot] [PATCH v3 2/8] pxa_lcd: make lcd_enable() a weak pointer

2013-04-12 Thread Mike Dunn
Make lcd_init() a weak pointer so that boards can overload it if necessary.  The
palmtreo680 board needs to wiggle some gpios and configure the pwm controller in
order to get the lcd and its backlight working.

Signed-off-by: Mike Dunn miked...@newsguy.com
---
Changelog:
v3: no change

v2:
  - use __weak macro instead of explicit compiler directive

 drivers/video/pxa_lcd.c |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/video/pxa_lcd.c b/drivers/video/pxa_lcd.c
index d5fbe7b..5e4c685 100644
--- a/drivers/video/pxa_lcd.c
+++ b/drivers/video/pxa_lcd.c
@@ -410,7 +410,7 @@ void lcd_initcolregs (void)
 #endif /* LCD_MONOCHROME */
 
 /*--*/
-void lcd_enable (void)
+__weak void lcd_enable(void)
 {
 }
 
-- 
1.7.8.6

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


[U-Boot] [PATCH 5/8] lib: import bitrev library from the linux kernel

2013-04-12 Thread Mike Dunn
This patch adds the bitrev library from the linux kernel.  This is a simple
algorithm that uses an 8 bit look-up table to reverse the bits in data types of
8, 16, or 32 bit widths.  The docg4 nand flash driver uses it.

[port from linux kernel v3.9 commit 7ee32a6d30d1c8a3b7a07a6269da8f0a08662927]
[originally added: v2.6.20 by commit a5cfc1ec58a07074dacb6aa8c79eff864c966d12]

Signed-off-by: Mike Dunn miked...@newsguy.com
---
Changelog:
  v3: no change
  v2: remove 'extern' from function prototypes in bitrev.h

 include/linux/bitrev.h |   23 ++
 lib/Makefile   |1 +
 lib/bitrev.c   |   59 
 3 files changed, 83 insertions(+), 0 deletions(-)
 create mode 100644 include/linux/bitrev.h
 create mode 100644 lib/bitrev.c

diff --git a/include/linux/bitrev.h b/include/linux/bitrev.h
new file mode 100644
index 000..a61d956
--- /dev/null
+++ b/include/linux/bitrev.h
@@ -0,0 +1,23 @@
+/*
+ * This file is released under the terms of GPL v2 and any later version.
+ * See the file COPYING in the root directory of the source tree for details.
+ *
+ * Based on bitrev from the Linux kernel, by Akinobu Mita
+ */
+
+#ifndef _LINUX_BITREV_H
+#define _LINUX_BITREV_H
+
+#include linux/types.h
+
+extern u8 const byte_rev_table[256];
+
+static inline u8 bitrev8(u8 byte)
+{
+   return byte_rev_table[byte];
+}
+
+u16 bitrev16(u16 in);
+u32 bitrev32(u32 in);
+
+#endif /* _LINUX_BITREV_H */
diff --git a/lib/Makefile b/lib/Makefile
index 1bfd3ee..b4aaae9 100644
--- a/lib/Makefile
+++ b/lib/Makefile
@@ -55,6 +55,7 @@ COBJS-$(CONFIG_SHA1) += sha1.o
 COBJS-$(CONFIG_SHA256) += sha256.o
 COBJS-y+= strmhz.o
 COBJS-$(CONFIG_RBTREE) += rbtree.o
+COBJS-$(CONFIG_BITREVERSE) += bitrev.o
 endif
 
 ifdef CONFIG_SPL_BUILD
diff --git a/lib/bitrev.c b/lib/bitrev.c
new file mode 100644
index 000..160021a
--- /dev/null
+++ b/lib/bitrev.c
@@ -0,0 +1,59 @@
+/*
+ * This file is released under the terms of GPL v2 and any later version.
+ * See the file COPYING in the root directory of the source tree for details.
+ *
+ * Based on bitrev from the Linux kernel, by Akinobu Mita
+ */
+
+
+#include linux/types.h
+#include linux/bitrev.h
+
+const u8 byte_rev_table[256] = {
+   0x00, 0x80, 0x40, 0xc0, 0x20, 0xa0, 0x60, 0xe0,
+   0x10, 0x90, 0x50, 0xd0, 0x30, 0xb0, 0x70, 0xf0,
+   0x08, 0x88, 0x48, 0xc8, 0x28, 0xa8, 0x68, 0xe8,
+   0x18, 0x98, 0x58, 0xd8, 0x38, 0xb8, 0x78, 0xf8,
+   0x04, 0x84, 0x44, 0xc4, 0x24, 0xa4, 0x64, 0xe4,
+   0x14, 0x94, 0x54, 0xd4, 0x34, 0xb4, 0x74, 0xf4,
+   0x0c, 0x8c, 0x4c, 0xcc, 0x2c, 0xac, 0x6c, 0xec,
+   0x1c, 0x9c, 0x5c, 0xdc, 0x3c, 0xbc, 0x7c, 0xfc,
+   0x02, 0x82, 0x42, 0xc2, 0x22, 0xa2, 0x62, 0xe2,
+   0x12, 0x92, 0x52, 0xd2, 0x32, 0xb2, 0x72, 0xf2,
+   0x0a, 0x8a, 0x4a, 0xca, 0x2a, 0xaa, 0x6a, 0xea,
+   0x1a, 0x9a, 0x5a, 0xda, 0x3a, 0xba, 0x7a, 0xfa,
+   0x06, 0x86, 0x46, 0xc6, 0x26, 0xa6, 0x66, 0xe6,
+   0x16, 0x96, 0x56, 0xd6, 0x36, 0xb6, 0x76, 0xf6,
+   0x0e, 0x8e, 0x4e, 0xce, 0x2e, 0xae, 0x6e, 0xee,
+   0x1e, 0x9e, 0x5e, 0xde, 0x3e, 0xbe, 0x7e, 0xfe,
+   0x01, 0x81, 0x41, 0xc1, 0x21, 0xa1, 0x61, 0xe1,
+   0x11, 0x91, 0x51, 0xd1, 0x31, 0xb1, 0x71, 0xf1,
+   0x09, 0x89, 0x49, 0xc9, 0x29, 0xa9, 0x69, 0xe9,
+   0x19, 0x99, 0x59, 0xd9, 0x39, 0xb9, 0x79, 0xf9,
+   0x05, 0x85, 0x45, 0xc5, 0x25, 0xa5, 0x65, 0xe5,
+   0x15, 0x95, 0x55, 0xd5, 0x35, 0xb5, 0x75, 0xf5,
+   0x0d, 0x8d, 0x4d, 0xcd, 0x2d, 0xad, 0x6d, 0xed,
+   0x1d, 0x9d, 0x5d, 0xdd, 0x3d, 0xbd, 0x7d, 0xfd,
+   0x03, 0x83, 0x43, 0xc3, 0x23, 0xa3, 0x63, 0xe3,
+   0x13, 0x93, 0x53, 0xd3, 0x33, 0xb3, 0x73, 0xf3,
+   0x0b, 0x8b, 0x4b, 0xcb, 0x2b, 0xab, 0x6b, 0xeb,
+   0x1b, 0x9b, 0x5b, 0xdb, 0x3b, 0xbb, 0x7b, 0xfb,
+   0x07, 0x87, 0x47, 0xc7, 0x27, 0xa7, 0x67, 0xe7,
+   0x17, 0x97, 0x57, 0xd7, 0x37, 0xb7, 0x77, 0xf7,
+   0x0f, 0x8f, 0x4f, 0xcf, 0x2f, 0xaf, 0x6f, 0xef,
+   0x1f, 0x9f, 0x5f, 0xdf, 0x3f, 0xbf, 0x7f, 0xff,
+};
+
+u16 bitrev16(u16 x)
+{
+   return (bitrev8(x  0xff)  8) | bitrev8(x  8);
+}
+
+/**
+ * bitrev32 - reverse the order of bits in a u32 value
+ * @x: value to be bit-reversed
+ */
+u32 bitrev32(u32 x)
+{
+   return (bitrev16(x  0x)  16) | bitrev16(x  16);
+}
-- 
1.7.8.6

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


[U-Boot] [PATCH v3 4/8] arm: bootm: call udc_disable() before booting linux

2013-04-12 Thread Mike Dunn
On the pxa270, if the udc device is not disabled before jumping to linux, the
device fails to initialize in linux because it was left in a running state, and
the linux driver assumes that it is in a disabled state.

Signed-off-by: Mike Dunn miked...@newsguy.com
---
Changelog:
  v3: no change
  v2: no change

Arguably, this is a bug in the linux driver, but it seemed pretty simple and
benign to just disable it in u-boot.  I'll also send a patch to upstream kernel
to fix its driver.

 arch/arm/include/asm/bootm.h |1 +
 arch/arm/lib/bootm.c |1 +
 2 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/arch/arm/include/asm/bootm.h b/arch/arm/include/asm/bootm.h
index db2ff94..68189cc 100644
--- a/arch/arm/include/asm/bootm.h
+++ b/arch/arm/include/asm/bootm.h
@@ -21,6 +21,7 @@
 
 #ifdef CONFIG_USB_DEVICE
 extern void udc_disconnect(void);
+extern void udc_disable(void);
 #endif
 
 #endif
diff --git a/arch/arm/lib/bootm.c b/arch/arm/lib/bootm.c
index f3b30c5..6daa7bf 100644
--- a/arch/arm/lib/bootm.c
+++ b/arch/arm/lib/bootm.c
@@ -105,6 +105,7 @@ static void announce_and_cleanup(void)
 
 #ifdef CONFIG_USB_DEVICE
udc_disconnect();
+   udc_disable();
 #endif
cleanup_before_linux();
 }
-- 
1.7.8.6

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


[U-Boot] [PATCH v3 8/8] palmtreo680: add utility that writes u-boot to flash

2013-04-12 Thread Mike Dunn
This adds a userspace linux utility that writes the u-boot image to an mtd
partition on the docg4 nand flash.

A special utility is required to do this because u-boot is partially loaded by
an initial program loader (IPL) that is permanently programmed to the boot
region of the flash.  This IPL expects the image to be written in a unique
format. The characteristics of this format can be summarized as follows:
  - Flash blocks to be loaded must have a magic number in the oob bytes of the
first page of the block.
  - Each page must be written redundantly in the subsequent page.
  - The integrated flash controller's reliable mode is used, requiring that
alternate 2k regions (4 pages) are skipped when writing.
For these reasons, a u-boot image can not be written using nandwrite from
mtd-utils.

Signed-off-by: Mike Dunn miked...@newsguy.com
---
Changelog:
  v3: new patch; split off from patch 7 in v2 of patchset

 tools/palmtreo680/flash_u-boot.c |  167 ++
 1 files changed, 167 insertions(+), 0 deletions(-)
 create mode 100644 tools/palmtreo680/flash_u-boot.c

diff --git a/tools/palmtreo680/flash_u-boot.c b/tools/palmtreo680/flash_u-boot.c
new file mode 100644
index 000..97b336f
--- /dev/null
+++ b/tools/palmtreo680/flash_u-boot.c
@@ -0,0 +1,167 @@
+/*
+ * Copyright (C) 2013 Mike Dunn miked...@newsguy.com
+ *
+ * This file is released under the terms of GPL v2 and any later version.
+ * See the file COPYING in the root directory of the source tree for details.
+ *
+ *
+ * This is a userspace Linux utility that, when run on the Treo 680, will
+ * program u-boot to flash.  The docg4 driver *must* be loaded with the
+ * reliable_mode and ignore_badblocks parameters enabled:
+ *
+ *modprobe docg4 ignore_badblocks=1 reliable_mode=1
+ *
+ * This utility writes the concatenated spl + u-boot image to the start of the
+ * mtd device in the format expected by the IPL/SPL.  The image file and mtd
+ * device node are passed to the utility as arguments.  The blocks must have
+ * been erased beforehand.
+ *
+ * When you compile this, note that it links to libmtd from mtd-utils, so 
ensure
+ * that your include and lib paths include this.
+ */
+
+#include stdio.h
+#include stdlib.h
+#include sys/stat.h
+#include fcntl.h
+#include string.h
+#include sys/types.h
+#include unistd.h
+#include errno.h
+#include mtd/mtd-user.h
+#include libmtd.h
+
+#define RELIABLE_BLOCKSIZE  0x1 /* block capacity in reliable mode */
+#define STANDARD_BLOCKSIZE  0x4 /* block capacity in normal mode */
+#define PAGESIZE 512
+#define PAGES_PER_BLOCK 512
+#define OOBSIZE 7  /* available to user (16 total) */
+
+uint8_t ff_oob[OOBSIZE] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
+
+/* this is the magic number the IPL looks for (ASCII BIPO) */
+uint8_t page0_oob[OOBSIZE] = {'B', 'I', 'P', 'O', 0xff, 0xff, 0xff};
+
+int main(int argc, char * const argv[])
+{
+   int devfd, datafd, num_blocks, block;
+   off_t file_size;
+   libmtd_t mtd_desc;
+   struct mtd_dev_info devinfo;
+   uint8_t *blockbuf;
+   char response[8];
+
+   if (argc != 3) {
+   printf(usage: %s image file mtd dev node\n, argv[0]);
+   exit(-1);
+   }
+
+   mtd_desc = libmtd_open();
+   if (mtd_desc == NULL) {
+   fprintf(stderr, can't initialize libmtd\n);
+   exit(-1);
+   }
+
+   /* open the spl image file and mtd device */
+   datafd = open(argv[1], O_RDONLY);
+   if (datafd == -1) {
+   perror(argv[1]);
+   exit(-1);
+   }
+   devfd = open(argv[2], O_WRONLY);
+   if (devfd == -1) {
+   perror(argv[2]);
+   exit(-1);
+   }
+   if (mtd_get_dev_info(mtd_desc, argv[2], devinfo)  0) {
+   fprintf(stderr, mtd_get_dev_info failed\n);
+   exit(-1);
+   }
+
+   /* determine the number of blocks needed by the image */
+   file_size = lseek(datafd, 0, SEEK_END);
+   if (file_size == (off_t)-1) {
+   perror(lseek);
+   exit(-1);
+   }
+   num_blocks = (file_size + RELIABLE_BLOCKSIZE - 1) / RELIABLE_BLOCKSIZE;
+   file_size = lseek(datafd, 0, SEEK_SET);
+   if (file_size == (off_t)-1) {
+   perror(lseek);
+   exit(-1);
+   }
+   printf(The mtd partition contains %d blocks\n, devinfo.eb_cnt);
+   printf(U-boot will occupy %d blocks\n, num_blocks);
+   if (num_blocks  devinfo.eb_cnt) {
+   fprintf(stderr, Insufficient blocks on partition\n);
+   exit(-1);
+   }
+
+   printf(IMPORTANT: These blocks must be in an erased state!\n);
+   printf(Do you want to proceed?\n);
+   scanf(%s, response);
+   if ((response[0] != 'y')  (response[0] != 'Y')) {
+   printf(Exiting\n);
+   close(devfd);
+   close(datafd);
+   exit(-1

[U-Boot] [PATCH v3 6/8] mtd: nand: add driver for diskonchip g4 nand flash

2013-04-12 Thread Mike Dunn
This patch adds a driver for the diskonchip G4 nand flash device.  It is based
on the driver from the linux kernel.

This also includes a separate SPL driver.  A separate SPL driver is used because
the device operates in a different mode (reliable mode) when loading a boot
image, and also because the storage format of the boot image is different from
normal data (pages are stored redundantly).  The SPL driver basically mimics how
a typical IPL reads data from the device.  The special operating mode and
storage format are used to compensate for the fact that the IPL does not contain
the BCH ecc decoding algorithm (due to size constraints).  Although the u-boot
SPL *could* use ecc, it operates like an IPL for the sake of simplicity and
uniformity, since the IPL and SPL share the task of loading the u-boot image.
As a side benefit, the SPL driver is very small.

[port from linux kernel 3.4 commit 570469f3bde7f71cc1ece07a18d54a05b6a8775d]

Signed-off-by: Mike Dunn miked...@newsguy.com
---
Changelog:
  v3: replace dbg macro with MTDDEBUG
  v2: remove commented-out code

 drivers/mtd/nand/Makefile|2 +
 drivers/mtd/nand/docg4.c | 1028 ++
 drivers/mtd/nand/docg4_spl.c |  222 +
 include/linux/mtd/docg4.h|  134 ++
 4 files changed, 1386 insertions(+), 0 deletions(-)
 create mode 100644 drivers/mtd/nand/docg4.c
 create mode 100644 drivers/mtd/nand/docg4_spl.c
 create mode 100644 include/linux/mtd/docg4.h

diff --git a/drivers/mtd/nand/Makefile b/drivers/mtd/nand/Makefile
index c77c0c4..1bcf43c 100644
--- a/drivers/mtd/nand/Makefile
+++ b/drivers/mtd/nand/Makefile
@@ -34,6 +34,7 @@ NORMAL_DRIVERS=y
 endif
 
 COBJS-$(CONFIG_SPL_NAND_AM33XX_BCH) += am335x_spl_bch.o
+COBJS-$(CONFIG_SPL_NAND_DOCG4) += docg4_spl.o
 COBJS-$(CONFIG_SPL_NAND_SIMPLE) += nand_spl_simple.o
 COBJS-$(CONFIG_SPL_NAND_LOAD) += nand_spl_load.o
 COBJS-$(CONFIG_SPL_NAND_ECC) += nand_ecc.o
@@ -78,6 +79,7 @@ COBJS-$(CONFIG_NAND_SPEAR) += spr_nand.o
 COBJS-$(CONFIG_TEGRA_NAND) += tegra_nand.o
 COBJS-$(CONFIG_NAND_OMAP_GPMC) += omap_gpmc.o
 COBJS-$(CONFIG_NAND_PLAT) += nand_plat.o
+COBJS-$(CONFIG_NAND_DOCG4) += docg4.o
 
 else  # minimal SPL drivers
 
diff --git a/drivers/mtd/nand/docg4.c b/drivers/mtd/nand/docg4.c
new file mode 100644
index 000..7dd9953
--- /dev/null
+++ b/drivers/mtd/nand/docg4.c
@@ -0,0 +1,1028 @@
+/*
+ * drivers/mtd/nand/docg4.c
+ *
+ * Copyright (C) 2013 Mike Dunn miked...@newsguy.com
+ *
+ * This file is released under the terms of GPL v2 and any later version.
+ * See the file COPYING in the root directory of the source tree for details.
+ *
+ * mtd nand driver for M-Systems DiskOnChip G4
+ *
+ * Tested on the Palm Treo 680.  The G4 is also present on Toshiba Portege, 
Asus
+ * P526, some HTC smartphones (Wizard, Prophet, ...), O2 XDA Zinc, maybe 
others.
+ * Should work on these as well.  Let me know!
+ *
+ * TODO:
+ *
+ *  Mechanism for management of password-protected areas
+ *
+ *  Hamming ecc when reading oob only
+ *
+ *  According to the M-Sys documentation, this device is also available in a
+ *  dual-die configuration having a 256MB capacity, but no mechanism for
+ *  detecting this variant is documented.  Currently this driver assumes 128MB
+ *  capacity.
+ *
+ *  Support for multiple cascaded devices (floors).  Not sure which gadgets
+ *  contain multiple G4s in a cascaded configuration, if any.
+ *
+ */
+
+
+#include common.h
+#include asm/arch/hardware.h
+#include asm/io.h
+#include asm/bitops.h
+#include asm/errno.h
+#include malloc.h
+#include nand.h
+#include linux/bch.h
+#include linux/bitrev.h
+#include linux/mtd/docg4.h
+
+/*
+ * The device has a nop register which M-Sys claims is for the purpose of
+ * inserting precise delays.  But beware; at least some operations fail if the
+ * nop writes are replaced with a generic delay!
+ */
+static inline void write_nop(void __iomem *docptr)
+{
+   writew(0, docptr + DOC_NOP);
+}
+
+
+static int poll_status(void __iomem *docptr)
+{
+   /*
+* Busy-wait for the FLASHREADY bit to be set in the FLASHCONTROL
+* register.  Operations known to take a long time (e.g., block erase)
+* should sleep for a while before calling this.
+*/
+
+   uint8_t flash_status;
+
+   /* hardware quirk requires reading twice initially */
+   flash_status = readb(docptr + DOC_FLASHCONTROL);
+
+   do {
+   flash_status = readb(docptr + DOC_FLASHCONTROL);
+   } while (!(flash_status  DOC_CTRL_FLASHREADY));
+
+   return 0;
+}
+
+static void write_addr(void __iomem *docptr, uint32_t docg4_addr)
+{
+   /* write the four address bytes packed in docg4_addr to the device */
+
+   writeb(docg4_addr  0xff, docptr + DOC_FLASHADDRESS);
+   docg4_addr = 8;
+   writeb(docg4_addr  0xff, docptr + DOC_FLASHADDRESS);
+   docg4_addr = 8;
+   writeb(docg4_addr  0xff, docptr + DOC_FLASHADDRESS);
+   docg4_addr = 8;
+   writeb(docg4_addr  0xff

[U-Boot] [PATCH v3 7/8] add support for palm treo 680 board

2013-04-12 Thread Mike Dunn
A quick overview of u-boot implementation on the treo 680...

The treo 680 has a Diskonchip G4 nand flash chip.  This device has a 2k region
that maps to the system bus at the reset vector in a NOR-like fashion so that it
can be used as the boot device.  The phone is shipped with this 2k region
configured as write-protected (can't be modified) and programmed with an initial
program loader (IPL).  At power-up, this IPL loads the contents of two flash
blocks to SDRAM and jumps to it.  The capacity of the two blocks is not large
enough to hold all of u-boot, so a u-boot SPL is used.  To conserve flash space,
these two blocks and the necessary number of subsequent blocks are programmed
with a concatenated spl + u-boot image.  That way, the IPL will also load a
portion of u-boot proper, and when the spl runs, it relocates the portion of
u-boot that the IPL has already loaded, and then resumes loading the remaining
part of u-boot before jumping to it.

The default_environment is used (CONFIG_ENV_IS_NOWHERE) because I didn't think
that having a writable environment was worth the cost of a flash block, although
adding it would be straightforward.  I abuse the CONFIG_EXTRA_ENV_SETTINGS
option to specify the usbtty for the console (CONFIG_SYS_CONSOLE_IS_IN_ENV).

Support for the LCD is included, but currently it is only useful for displaying
the u-boot splash screen.  But if u-boot is built without the usbtty console, it
does display the auto-boot progress nicely.

Signed-off-by: Mike Dunn miked...@newsguy.com
---
Changelog:
  v3: flash_u-boot utility split into separate patch
  v2:
- tabs removed in #defines in palmtreo680.h
- utility for programming u-boot to flash moved to tools/palmtreo680

 CREDITS   |4 +
 MAINTAINERS   |3 +
 board/palmtreo680/Makefile|   34 ++
 board/palmtreo680/palmtreo680.c   |  179 +++
 board/palmtreo680/palmtreo680_spl.lds |   51 +++
 boards.cfg|1 +
 doc/README.palmtreo680|  570 +
 include/configs/palmtreo680.h |  295 +
 8 files changed, 1137 insertions(+), 0 deletions(-)
 create mode 100644 board/palmtreo680/Makefile
 create mode 100644 board/palmtreo680/palmtreo680.c
 create mode 100644 board/palmtreo680/palmtreo680_spl.lds
 create mode 100644 doc/README.palmtreo680
 create mode 100644 include/configs/palmtreo680.h

diff --git a/CREDITS b/CREDITS
index 7c1458f..3b657e9 100644
--- a/CREDITS
+++ b/CREDITS
@@ -124,6 +124,10 @@ N: James F. Dougherty
 E: j...@gigabitnetworks.com
 D: Port to the MOUSSE board
 
+N: Mike Dunn
+E: miked...@newsguy.com
+D: Palmtreo680 board, docg4 nand flash driver
+
 N: Dave Ellis
 E: d...@sixnetio.com
 D: EEPROM Speedup, SXNI855T port
diff --git a/MAINTAINERS b/MAINTAINERS
index 1614b91..db62af1 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -650,6 +650,9 @@ Wolfgang Denk w...@denx.de
imx27lite   i.MX27
qongi.MX31
 
+Mike Dunn miked...@newsguy.com
+   palmtreo680 pxa270
+
 Kristoffer Ericson kristoffer.eric...@gmail.com
 
jornada SA1110
diff --git a/board/palmtreo680/Makefile b/board/palmtreo680/Makefile
new file mode 100644
index 000..34ffb99
--- /dev/null
+++ b/board/palmtreo680/Makefile
@@ -0,0 +1,34 @@
+#
+# Palm Treo680 Support
+#
+# Copyright (C) 2013 Mike Dunn miked...@newsguy.com
+#
+# This file is released under the terms of GPL v2 and any later version.
+# See the file COPYING in the root directory of the source tree for details.
+
+include $(TOPDIR)/config.mk
+
+LIB= $(obj)lib$(BOARD).o
+
+COBJS  := palmtreo680.o
+
+SRCS   := $(COBJS:.o=.c)
+OBJS   := $(addprefix $(obj),$(COBJS))
+
+$(LIB):$(obj).depend $(OBJS)
+   $(call cmd_link_o_target, $(OBJS))
+
+clean:
+   rm -f $(OBJS)
+
+distclean: clean
+   rm -f $(LIB) core *.bak $(obj).depend
+
+#
+
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
+
+sinclude $(obj).depend
+
+#
diff --git a/board/palmtreo680/palmtreo680.c b/board/palmtreo680/palmtreo680.c
new file mode 100644
index 000..c23c570
--- /dev/null
+++ b/board/palmtreo680/palmtreo680.c
@@ -0,0 +1,179 @@
+/*
+ * Palm Treo 680 Support
+ *
+ * Copyright (C) 2013 Mike Dunn miked...@newsguy.com
+ *
+ * This file is released under the terms of GPL v2 and any later version.
+ * See the file COPYING in the root directory of the source tree for details.
+ *
+ */
+
+#include common.h
+#include command.h
+#include serial.h
+#include nand.h
+#include malloc.h
+#include asm/arch/pxa-regs.h
+#include asm/arch-pxa/pxa.h
+#include asm/arch-pxa/regs-mmc.h
+#include asm/io.h
+#include asm/global_data.h
+#include u-boot/crc.h
+#include linux/mtd/docg4.h
+
+DECLARE_GLOBAL_DATA_PTR;
+
+static struct nand_chip docg4_nand_chip;
+
+int

Re: [U-Boot] [PATCH v2 8/8] ARM: Present a menu of bootable options on boot

2013-04-11 Thread Mike Dunn
On 04/10/2013 06:43 PM, Rob Herring wrote:
 On Wed, Apr 10, 2013 at 8:12 AM, Suriyan Ramasami suriya...@gmail.com wrote:
 Initialize usb and ide.
 Scan through the usb for storage and boot capable partitions.
 Scan through the ide interface for boot capable partitions.
 Present such bootable options to the user to choose to boot from
 If the user does not choose any choose the default option
 the default option is the option chosen by the user the last time
 If no such default option exists, boot from the first possible
 bootable option.
 
 This all sounds very generic but...
 

 Signed-off-by: Suriyan Ramasami suriya...@gmail.com
 ---
 Changes in v2:
 - Coding style changes

  board/Seagate/goflexhome/goflexhomemenu.c |  415 
 +
 
 but this is not a generic location. This feature would interest me and
 probably Stephen as well.


I was thinking along these lines as well for the treo 680.  Suriyan, perhaps we
can collaborate, with the guidance of the maintainers here.

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


[U-Boot] [PATCH v2 0/7] palm treo 680 smartphone board support

2013-04-10 Thread Mike Dunn
Hi,

This patchset adds support for the Palm Treo 680 smartphone.  I had to make some
minor tweaks to u-boot to get things working.  Most of these changes are small,
and most only touch the pxa arch.

Thanks for looking.

Changelog:
v2:
  - tabs removed in #defines in palmtreo680.h
  - use '__weak' macro in pxa_lcd
  - remove externs from function prototypes in bitrev.h
  - remove commented-out code from docg4.c
  - the CONFIG_SYS_LCD_PXA_NO_L_BIAS patch was removed; the same result
is accomplished by re-configuring the L_BIAS gpio in the board-specific
lcd_enable(), which runs after the driver initialization
  - userland utility for programming u-boot to flash moved to tools/palmtreo680
  - commit message for patches that add bitrev library and docg4 driver contain
the commit and linux version for when the code was added to linux

Mike Dunn (7):
  pxa_lcd: add the ACX544AKN lcd device
  pxa_lcd: make lcd_enable() a weak pointer
  pxa27x_udc: remove call to unimplemented set_GPIO_mode()
  arm: bootm: call udc_disable()before booting linux
  lib: import bitrev library from the linux kernel
  mtd: nand: add driver for diskonchip g4 nand flash
  add support for palm treo 680 board

 CREDITS  |4 +
 MAINTAINERS  |3 +
 arch/arm/include/asm/arch-pxa/hardware.h |   11 -
 arch/arm/include/asm/bootm.h |1 +
 arch/arm/lib/bootm.c |1 +
 board/palmtreo680/Makefile   |   34 +
 board/palmtreo680/palmtreo680.c  |  179 +
 board/palmtreo680/palmtreo680_spl.lds|   51 ++
 boards.cfg   |1 +
 doc/README.palmtreo680   |  570 
 drivers/mtd/nand/Makefile|2 +
 drivers/mtd/nand/docg4.c | 1034 ++
 drivers/mtd/nand/docg4_spl.c |  221 +++
 drivers/usb/gadget/pxa27x_udc.c  |4 +-
 drivers/video/pxa_lcd.c  |   34 +-
 include/configs/palmtreo680.h|  296 +
 include/linux/bitrev.h   |   23 +
 include/linux/mtd/docg4.h|  134 
 lib/Makefile |1 +
 lib/bitrev.c |   59 ++
 tools/palmtreo680/flash_u-boot.c |  177 +
 21 files changed, 2827 insertions(+), 13 deletions(-)
 create mode 100644 board/palmtreo680/Makefile
 create mode 100644 board/palmtreo680/palmtreo680.c
 create mode 100644 board/palmtreo680/palmtreo680_spl.lds
 create mode 100644 doc/README.palmtreo680
 create mode 100644 drivers/mtd/nand/docg4.c
 create mode 100644 drivers/mtd/nand/docg4_spl.c
 create mode 100644 include/configs/palmtreo680.h
 create mode 100644 include/linux/bitrev.h
 create mode 100644 include/linux/mtd/docg4.h
 create mode 100644 lib/bitrev.c
 create mode 100644 tools/palmtreo680/flash_u-boot.c

-- 
1.7.8.6

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


[U-Boot] [PATCH v2 1/7] pxa_lcd: add the ACX544AKN lcd device

2013-04-10 Thread Mike Dunn
This adds the definitions required to support the LCD device on the Palm Treo
680.

Signed-off-by: Mike Dunn miked...@newsguy.com
---
 drivers/video/pxa_lcd.c |   32 
 1 files changed, 32 insertions(+), 0 deletions(-)

diff --git a/drivers/video/pxa_lcd.c b/drivers/video/pxa_lcd.c
index b40ec36..d5fbe7b 100644
--- a/drivers/video/pxa_lcd.c
+++ b/drivers/video/pxa_lcd.c
@@ -248,6 +248,38 @@ vidinfo_t panel_info = {
 };
 #endif /* CONFIG_ACX517AKN */
 
+#ifdef CONFIG_ACX544AKN
+
+# define LCD_BPP   LCD_COLOR16
+
+/* you have to set lccr0 and lccr3 (including pcd) */
+# define REG_LCCR0 0x003008f9
+# define REG_LCCR3 0x0477 /* 16bpp */
+
+vidinfo_t panel_info = {
+   .vl_col = 320,
+   .vl_row = 320,
+   .vl_width   = 320,
+   .vl_height  = 320,
+   .vl_clkp= CONFIG_SYS_LOW,
+   .vl_oep = CONFIG_SYS_LOW,
+   .vl_hsp = CONFIG_SYS_LOW,
+   .vl_vsp = CONFIG_SYS_LOW,
+   .vl_dp  = CONFIG_SYS_LOW,
+   .vl_bpix= LCD_BPP,
+   .vl_lbw = 0,
+   .vl_splt= 0,
+   .vl_clor= 1,
+   .vl_tft = 1,
+   .vl_hpw = 0x05,
+   .vl_blw = 0x13,
+   .vl_elw = 0x08,
+   .vl_vpw = 0x02,
+   .vl_bfw = 0x07,
+   .vl_efw = 0x05,
+};
+#endif /* CONFIG_ACX544AKN */
+
 /*--*/
 
 #ifdef CONFIG_LQ038J7DH53
-- 
1.7.8.6

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


[U-Boot] [PATCH v2 2/7] pxa_lcd: make lcd_enable() a weak pointer

2013-04-10 Thread Mike Dunn
Make lcd_init() a weak pointer so that boards can overload it if necessary.  The
palmtreo680 board needs to wiggle some gpios and configure the pwm controller in
order to get the lcd and its backlight working.

Signed-off-by: Mike Dunn miked...@newsguy.com
---
 drivers/video/pxa_lcd.c |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/video/pxa_lcd.c b/drivers/video/pxa_lcd.c
index d5fbe7b..5e4c685 100644
--- a/drivers/video/pxa_lcd.c
+++ b/drivers/video/pxa_lcd.c
@@ -410,7 +410,7 @@ void lcd_initcolregs (void)
 #endif /* LCD_MONOCHROME */
 
 /*--*/
-void lcd_enable (void)
+__weak void lcd_enable(void)
 {
 }
 
-- 
1.7.8.6

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


[U-Boot] [PATCH v2 3/7] pxa27x_udc: remove call to unimplemented set_GPIO_mode()

2013-04-10 Thread Mike Dunn
If CONFIG_USB_DEV_PULLUP_GPIO is defined, a link error occurs because the
set_GPIO_mode() helper function is not implemented.  This function doesn't do
much except make the code a little more readable, so I just manually coded its
equivalent and removed the prototype from the header file.  It is invoked no
where else in the code.

While I was at it, I noticed that two other function prototypes in the same
header file are also neither implemented nor invoked anywhere, so I removed them
as well.

Signed-off-by: Mike Dunn miked...@newsguy.com
---
 arch/arm/include/asm/arch-pxa/hardware.h |   11 ---
 drivers/usb/gadget/pxa27x_udc.c  |4 +++-
 2 files changed, 3 insertions(+), 12 deletions(-)

diff --git a/arch/arm/include/asm/arch-pxa/hardware.h 
b/arch/arm/include/asm/arch-pxa/hardware.h
index 44b800f..2397bce 100644
--- a/arch/arm/include/asm/arch-pxa/hardware.h
+++ b/arch/arm/include/asm/arch-pxa/hardware.h
@@ -77,17 +77,6 @@
 #define GPIO_FALLING_EDGE  1
 #define GPIO_RISING_EDGE   2
 #define GPIO_BOTH_EDGES3
-extern void set_GPIO_IRQ_edge( int gpio_nr, int edge_mask );
-
-/*
- * Handy routine to set GPIO alternate functions
- */
-extern void set_GPIO_mode( int gpio_mode );
-
-/*
- * return current lclk frequency in units of 10kHz
- */
-extern unsigned int get_lclk_frequency_10khz(void);
 
 #endif
 
diff --git a/drivers/usb/gadget/pxa27x_udc.c b/drivers/usb/gadget/pxa27x_udc.c
index 4c00081..71cc0f2 100644
--- a/drivers/usb/gadget/pxa27x_udc.c
+++ b/drivers/usb/gadget/pxa27x_udc.c
@@ -610,7 +610,9 @@ void udc_connect(void)
 
 #ifdef CONFIG_USB_DEV_PULLUP_GPIO
/* Turn on the USB connection by enabling the pullup resistor */
-   set_GPIO_mode(CONFIG_USB_DEV_PULLUP_GPIO | GPIO_OUT);
+   writel(readl(GPDR(CONFIG_USB_DEV_PULLUP_GPIO))
+| GPIO_bit(CONFIG_USB_DEV_PULLUP_GPIO),
+  GPDR(CONFIG_USB_DEV_PULLUP_GPIO));
writel(GPIO_bit(CONFIG_USB_DEV_PULLUP_GPIO), 
GPSR(CONFIG_USB_DEV_PULLUP_GPIO));
 #else
/* Host port 2 transceiver D+ pull up enable */
-- 
1.7.8.6

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


[U-Boot] [PATCH v2 4/7] arm: bootm: call udc_disable()before booting linux

2013-04-10 Thread Mike Dunn
On the pxa270, if the udc device is not disabled before jumping to linux, the
device fails to initialize in linux because it was left in a running state, and
the linux driver assumes that it is in a disabled state.

Signed-off-by: Mike Dunn miked...@newsguy.com
---

Arguably, this is a bug in the linux driver, but it seemed pretty simple and
benign to just disable it in u-boot.  I'll also send a patch to upstream kernel
to fix its driver.

 arch/arm/include/asm/bootm.h |1 +
 arch/arm/lib/bootm.c |1 +
 2 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/arch/arm/include/asm/bootm.h b/arch/arm/include/asm/bootm.h
index db2ff94..68189cc 100644
--- a/arch/arm/include/asm/bootm.h
+++ b/arch/arm/include/asm/bootm.h
@@ -21,6 +21,7 @@
 
 #ifdef CONFIG_USB_DEVICE
 extern void udc_disconnect(void);
+extern void udc_disable(void);
 #endif
 
 #endif
diff --git a/arch/arm/lib/bootm.c b/arch/arm/lib/bootm.c
index f3b30c5..6daa7bf 100644
--- a/arch/arm/lib/bootm.c
+++ b/arch/arm/lib/bootm.c
@@ -105,6 +105,7 @@ static void announce_and_cleanup(void)
 
 #ifdef CONFIG_USB_DEVICE
udc_disconnect();
+   udc_disable();
 #endif
cleanup_before_linux();
 }
-- 
1.7.8.6

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


[U-Boot] [PATCH v2 5/7] lib: import bitrev library from the linux kernel

2013-04-10 Thread Mike Dunn
This patch adds the bitrev library from the linux kernel.  This is a simple
algorithm that uses an 8 bit look-up table to reverse the bits in data types of
8, 16, or 32 bit widths.  The docg4 nand flash driver uses it.

[port from linux kernel 2.6.20 commit a5cfc1ec58a07074dacb6aa8c79eff864c966d12]

Signed-off-by: Mike Dunn miked...@newsguy.com
---
 include/linux/bitrev.h |   23 ++
 lib/Makefile   |1 +
 lib/bitrev.c   |   59 
 3 files changed, 83 insertions(+), 0 deletions(-)
 create mode 100644 include/linux/bitrev.h
 create mode 100644 lib/bitrev.c

diff --git a/include/linux/bitrev.h b/include/linux/bitrev.h
new file mode 100644
index 000..a61d956
--- /dev/null
+++ b/include/linux/bitrev.h
@@ -0,0 +1,23 @@
+/*
+ * This file is released under the terms of GPL v2 and any later version.
+ * See the file COPYING in the root directory of the source tree for details.
+ *
+ * Based on bitrev from the Linux kernel, by Akinobu Mita
+ */
+
+#ifndef _LINUX_BITREV_H
+#define _LINUX_BITREV_H
+
+#include linux/types.h
+
+extern u8 const byte_rev_table[256];
+
+static inline u8 bitrev8(u8 byte)
+{
+   return byte_rev_table[byte];
+}
+
+u16 bitrev16(u16 in);
+u32 bitrev32(u32 in);
+
+#endif /* _LINUX_BITREV_H */
diff --git a/lib/Makefile b/lib/Makefile
index 1bfd3ee..b4aaae9 100644
--- a/lib/Makefile
+++ b/lib/Makefile
@@ -55,6 +55,7 @@ COBJS-$(CONFIG_SHA1) += sha1.o
 COBJS-$(CONFIG_SHA256) += sha256.o
 COBJS-y+= strmhz.o
 COBJS-$(CONFIG_RBTREE) += rbtree.o
+COBJS-$(CONFIG_BITREVERSE) += bitrev.o
 endif
 
 ifdef CONFIG_SPL_BUILD
diff --git a/lib/bitrev.c b/lib/bitrev.c
new file mode 100644
index 000..160021a
--- /dev/null
+++ b/lib/bitrev.c
@@ -0,0 +1,59 @@
+/*
+ * This file is released under the terms of GPL v2 and any later version.
+ * See the file COPYING in the root directory of the source tree for details.
+ *
+ * Based on bitrev from the Linux kernel, by Akinobu Mita
+ */
+
+
+#include linux/types.h
+#include linux/bitrev.h
+
+const u8 byte_rev_table[256] = {
+   0x00, 0x80, 0x40, 0xc0, 0x20, 0xa0, 0x60, 0xe0,
+   0x10, 0x90, 0x50, 0xd0, 0x30, 0xb0, 0x70, 0xf0,
+   0x08, 0x88, 0x48, 0xc8, 0x28, 0xa8, 0x68, 0xe8,
+   0x18, 0x98, 0x58, 0xd8, 0x38, 0xb8, 0x78, 0xf8,
+   0x04, 0x84, 0x44, 0xc4, 0x24, 0xa4, 0x64, 0xe4,
+   0x14, 0x94, 0x54, 0xd4, 0x34, 0xb4, 0x74, 0xf4,
+   0x0c, 0x8c, 0x4c, 0xcc, 0x2c, 0xac, 0x6c, 0xec,
+   0x1c, 0x9c, 0x5c, 0xdc, 0x3c, 0xbc, 0x7c, 0xfc,
+   0x02, 0x82, 0x42, 0xc2, 0x22, 0xa2, 0x62, 0xe2,
+   0x12, 0x92, 0x52, 0xd2, 0x32, 0xb2, 0x72, 0xf2,
+   0x0a, 0x8a, 0x4a, 0xca, 0x2a, 0xaa, 0x6a, 0xea,
+   0x1a, 0x9a, 0x5a, 0xda, 0x3a, 0xba, 0x7a, 0xfa,
+   0x06, 0x86, 0x46, 0xc6, 0x26, 0xa6, 0x66, 0xe6,
+   0x16, 0x96, 0x56, 0xd6, 0x36, 0xb6, 0x76, 0xf6,
+   0x0e, 0x8e, 0x4e, 0xce, 0x2e, 0xae, 0x6e, 0xee,
+   0x1e, 0x9e, 0x5e, 0xde, 0x3e, 0xbe, 0x7e, 0xfe,
+   0x01, 0x81, 0x41, 0xc1, 0x21, 0xa1, 0x61, 0xe1,
+   0x11, 0x91, 0x51, 0xd1, 0x31, 0xb1, 0x71, 0xf1,
+   0x09, 0x89, 0x49, 0xc9, 0x29, 0xa9, 0x69, 0xe9,
+   0x19, 0x99, 0x59, 0xd9, 0x39, 0xb9, 0x79, 0xf9,
+   0x05, 0x85, 0x45, 0xc5, 0x25, 0xa5, 0x65, 0xe5,
+   0x15, 0x95, 0x55, 0xd5, 0x35, 0xb5, 0x75, 0xf5,
+   0x0d, 0x8d, 0x4d, 0xcd, 0x2d, 0xad, 0x6d, 0xed,
+   0x1d, 0x9d, 0x5d, 0xdd, 0x3d, 0xbd, 0x7d, 0xfd,
+   0x03, 0x83, 0x43, 0xc3, 0x23, 0xa3, 0x63, 0xe3,
+   0x13, 0x93, 0x53, 0xd3, 0x33, 0xb3, 0x73, 0xf3,
+   0x0b, 0x8b, 0x4b, 0xcb, 0x2b, 0xab, 0x6b, 0xeb,
+   0x1b, 0x9b, 0x5b, 0xdb, 0x3b, 0xbb, 0x7b, 0xfb,
+   0x07, 0x87, 0x47, 0xc7, 0x27, 0xa7, 0x67, 0xe7,
+   0x17, 0x97, 0x57, 0xd7, 0x37, 0xb7, 0x77, 0xf7,
+   0x0f, 0x8f, 0x4f, 0xcf, 0x2f, 0xaf, 0x6f, 0xef,
+   0x1f, 0x9f, 0x5f, 0xdf, 0x3f, 0xbf, 0x7f, 0xff,
+};
+
+u16 bitrev16(u16 x)
+{
+   return (bitrev8(x  0xff)  8) | bitrev8(x  8);
+}
+
+/**
+ * bitrev32 - reverse the order of bits in a u32 value
+ * @x: value to be bit-reversed
+ */
+u32 bitrev32(u32 x)
+{
+   return (bitrev16(x  0x)  16) | bitrev16(x  16);
+}
-- 
1.7.8.6

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


[U-Boot] [PATCH v2 6/7] mtd: nand: add driver for diskonchip g4 nand flash

2013-04-10 Thread Mike Dunn
This patch adds a driver for the diskonchip G4 nand flash device.  It is based
on the driver from the linux kernel.

This also includes a separate SPL driver.  A separate SPL driver is used because
the device operates in a different mode (reliable mode) when loading a boot
image, and also because the storage format of the boot image is different from
normal data (pages are stored redundantly).  The SPL driver basically mimics how
a typical IPL reads data from the device.  The special operating mode and
storage format are used to compensate for the fact that the IPL does not contain
the BCH ecc decoding algorithm (due to size constraints).  Although the u-boot
SPL *could* use ecc, it operates like an IPL for the sake of simplicity and
uniformity, since the IPL and SPL share the task of loading the u-boot image.
As a side benefit, the SPL driver is very small.

[port from linux kernel 3.4 commit 570469f3bde7f71cc1ece07a18d54a05b6a8775d]

Signed-off-by: Mike Dunn miked...@newsguy.com
---
 drivers/mtd/nand/Makefile|2 +
 drivers/mtd/nand/docg4.c | 1035 ++
 drivers/mtd/nand/docg4_spl.c |  222 +
 include/linux/mtd/docg4.h|  134 ++
 4 files changed, 1393 insertions(+), 0 deletions(-)
 create mode 100644 drivers/mtd/nand/docg4.c
 create mode 100644 drivers/mtd/nand/docg4_spl.c
 create mode 100644 include/linux/mtd/docg4.h

diff --git a/drivers/mtd/nand/Makefile b/drivers/mtd/nand/Makefile
index c77c0c4..1bcf43c 100644
--- a/drivers/mtd/nand/Makefile
+++ b/drivers/mtd/nand/Makefile
@@ -34,6 +34,7 @@ NORMAL_DRIVERS=y
 endif
 
 COBJS-$(CONFIG_SPL_NAND_AM33XX_BCH) += am335x_spl_bch.o
+COBJS-$(CONFIG_SPL_NAND_DOCG4) += docg4_spl.o
 COBJS-$(CONFIG_SPL_NAND_SIMPLE) += nand_spl_simple.o
 COBJS-$(CONFIG_SPL_NAND_LOAD) += nand_spl_load.o
 COBJS-$(CONFIG_SPL_NAND_ECC) += nand_ecc.o
@@ -78,6 +79,7 @@ COBJS-$(CONFIG_NAND_SPEAR) += spr_nand.o
 COBJS-$(CONFIG_TEGRA_NAND) += tegra_nand.o
 COBJS-$(CONFIG_NAND_OMAP_GPMC) += omap_gpmc.o
 COBJS-$(CONFIG_NAND_PLAT) += nand_plat.o
+COBJS-$(CONFIG_NAND_DOCG4) += docg4.o
 
 else  # minimal SPL drivers
 
diff --git a/drivers/mtd/nand/docg4.c b/drivers/mtd/nand/docg4.c
new file mode 100644
index 000..c5c4ee0
--- /dev/null
+++ b/drivers/mtd/nand/docg4.c
@@ -0,0 +1,1035 @@
+/*
+ * drivers/mtd/nand/docg4.c
+ *
+ * Copyright (C) 2013 Mike Dunn miked...@newsguy.com
+ *
+ * This file is released under the terms of GPL v2 and any later version.
+ * See the file COPYING in the root directory of the source tree for details.
+ *
+ * mtd nand driver for M-Systems DiskOnChip G4
+ *
+ * Tested on the Palm Treo 680.  The G4 is also present on Toshiba Portege, 
Asus
+ * P526, some HTC smartphones (Wizard, Prophet, ...), O2 XDA Zinc, maybe 
others.
+ * Should work on these as well.  Let me know!
+ *
+ * TODO:
+ *
+ *  Mechanism for management of password-protected areas
+ *
+ *  Hamming ecc when reading oob only
+ *
+ *  According to the M-Sys documentation, this device is also available in a
+ *  dual-die configuration having a 256MB capacity, but no mechanism for
+ *  detecting this variant is documented.  Currently this driver assumes 128MB
+ *  capacity.
+ *
+ *  Support for multiple cascaded devices (floors).  Not sure which gadgets
+ *  contain multiple G4s in a cascaded configuration, if any.
+ *
+ */
+
+
+#include common.h
+#include asm/arch/hardware.h
+#include asm/io.h
+#include asm/bitops.h
+#include asm/errno.h
+#include malloc.h
+#include nand.h
+#include linux/bch.h
+#include linux/bitrev.h
+#include linux/mtd/docg4.h
+
+/*
+ * The device has a nop register which M-Sys claims is for the purpose of
+ * inserting precise delays.  But beware; at least some operations fail if the
+ * nop writes are replaced with a generic delay!
+ */
+static inline void write_nop(void __iomem *docptr)
+{
+   writew(0, docptr + DOC_NOP);
+}
+
+
+static int poll_status(void __iomem *docptr)
+{
+   /*
+* Busy-wait for the FLASHREADY bit to be set in the FLASHCONTROL
+* register.  Operations known to take a long time (e.g., block erase)
+* should sleep for a while before calling this.
+*/
+
+   uint8_t flash_status;
+
+   /* hardware quirk requires reading twice initially */
+   flash_status = readb(docptr + DOC_FLASHCONTROL);
+
+   do {
+   flash_status = readb(docptr + DOC_FLASHCONTROL);
+   } while (!(flash_status  DOC_CTRL_FLASHREADY));
+
+   return 0;
+}
+
+static void write_addr(void __iomem *docptr, uint32_t docg4_addr)
+{
+   /* write the four address bytes packed in docg4_addr to the device */
+
+   writeb(docg4_addr  0xff, docptr + DOC_FLASHADDRESS);
+   docg4_addr = 8;
+   writeb(docg4_addr  0xff, docptr + DOC_FLASHADDRESS);
+   docg4_addr = 8;
+   writeb(docg4_addr  0xff, docptr + DOC_FLASHADDRESS);
+   docg4_addr = 8;
+   writeb(docg4_addr  0xff, docptr + DOC_FLASHADDRESS);
+}
+
+
+#ifdef DEBUG_DOCG4
+#define dbg(format, arg

[U-Boot] [PATCH v2 7/7] add support for palm treo 680 board

2013-04-10 Thread Mike Dunn
A quick overview of u-boot implementation on the treo 680...

The treo 680 has a Diskonchip G4 nand flash chip.  This device has a 2k region
that maps to the system bus at the reset vector in a NOR-like fashion so that it
can be used as the boot device.  The phone is shipped with this 2k region
configured as write-protected (can't be modified) and programmed with an initial
program loader (IPL).  At power-up, this IPL loads the contents of two flash
blocks to SDRAM and jumps to it.  The capacity of the two blocks is not large
enough to hold all of u-boot, so a u-boot SPL is used.  To conserve flash space,
these two blocks and the necessary number of subsequent blocks are programmed
with a concatenated spl + u-boot image.  That way, the IPL will also load a
portion of u-boot proper, and when the spl runs, it relocates the portion of
u-boot that the IPL has already loaded, and then resumes loading the remaining
part of u-boot before jumping to it.

The default_environment is used (CONFIG_ENV_IS_NOWHERE) because I didn't think
that having a writable environment was worth the cost of a flash block, although
adding it would be straightforward.  I abuse the CONFIG_EXTRA_ENV_SETTINGS
option to specify the usbtty for the console (CONFIG_SYS_CONSOLE_IS_IN_ENV).

Support for the LCD is included, but currently it is only useful for displaying
the u-boot splash screen.  But if u-boot is built without the usbtty console, it
does display the auto-boot progress nicely.

Signed-off-by: Mike Dunn miked...@newsguy.com
---
 CREDITS   |4 +
 MAINTAINERS   |3 +
 board/palmtreo680/Makefile|   34 ++
 board/palmtreo680/palmtreo680.c   |  179 +++
 board/palmtreo680/palmtreo680_spl.lds |   51 +++
 boards.cfg|1 +
 doc/README.palmtreo680|  570 +
 include/configs/palmtreo680.h |  295 +
 tools/palmtreo680/flash_u-boot.c  |  177 ++
 9 files changed, 1314 insertions(+), 0 deletions(-)
 create mode 100644 board/palmtreo680/Makefile
 create mode 100644 board/palmtreo680/palmtreo680.c
 create mode 100644 board/palmtreo680/palmtreo680_spl.lds
 create mode 100644 doc/README.palmtreo680
 create mode 100644 include/configs/palmtreo680.h
 create mode 100644 tools/palmtreo680/flash_u-boot.c

diff --git a/CREDITS b/CREDITS
index 7c1458f..3b657e9 100644
--- a/CREDITS
+++ b/CREDITS
@@ -124,6 +124,10 @@ N: James F. Dougherty
 E: j...@gigabitnetworks.com
 D: Port to the MOUSSE board
 
+N: Mike Dunn
+E: miked...@newsguy.com
+D: Palmtreo680 board, docg4 nand flash driver
+
 N: Dave Ellis
 E: d...@sixnetio.com
 D: EEPROM Speedup, SXNI855T port
diff --git a/MAINTAINERS b/MAINTAINERS
index 1614b91..db62af1 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -650,6 +650,9 @@ Wolfgang Denk w...@denx.de
imx27lite   i.MX27
qongi.MX31
 
+Mike Dunn miked...@newsguy.com
+   palmtreo680 pxa270
+
 Kristoffer Ericson kristoffer.eric...@gmail.com
 
jornada SA1110
diff --git a/board/palmtreo680/Makefile b/board/palmtreo680/Makefile
new file mode 100644
index 000..34ffb99
--- /dev/null
+++ b/board/palmtreo680/Makefile
@@ -0,0 +1,34 @@
+#
+# Palm Treo680 Support
+#
+# Copyright (C) 2013 Mike Dunn miked...@newsguy.com
+#
+# This file is released under the terms of GPL v2 and any later version.
+# See the file COPYING in the root directory of the source tree for details.
+
+include $(TOPDIR)/config.mk
+
+LIB= $(obj)lib$(BOARD).o
+
+COBJS  := palmtreo680.o
+
+SRCS   := $(COBJS:.o=.c)
+OBJS   := $(addprefix $(obj),$(COBJS))
+
+$(LIB):$(obj).depend $(OBJS)
+   $(call cmd_link_o_target, $(OBJS))
+
+clean:
+   rm -f $(OBJS)
+
+distclean: clean
+   rm -f $(LIB) core *.bak $(obj).depend
+
+#
+
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
+
+sinclude $(obj).depend
+
+#
diff --git a/board/palmtreo680/palmtreo680.c b/board/palmtreo680/palmtreo680.c
new file mode 100644
index 000..c23c570
--- /dev/null
+++ b/board/palmtreo680/palmtreo680.c
@@ -0,0 +1,179 @@
+/*
+ * Palm Treo 680 Support
+ *
+ * Copyright (C) 2013 Mike Dunn miked...@newsguy.com
+ *
+ * This file is released under the terms of GPL v2 and any later version.
+ * See the file COPYING in the root directory of the source tree for details.
+ *
+ */
+
+#include common.h
+#include command.h
+#include serial.h
+#include nand.h
+#include malloc.h
+#include asm/arch/pxa-regs.h
+#include asm/arch-pxa/pxa.h
+#include asm/arch-pxa/regs-mmc.h
+#include asm/io.h
+#include asm/global_data.h
+#include u-boot/crc.h
+#include linux/mtd/docg4.h
+
+DECLARE_GLOBAL_DATA_PTR;
+
+static struct nand_chip docg4_nand_chip;
+
+int board_init(void)
+{
+   /* We have RAM, disable cache */
+   dcache_disable

Re: [U-Boot] [PATCH 7/8] mtd: nand: add driver for diskonchip g4 nand flash

2013-04-09 Thread Mike Dunn
On 04/08/2013 05:59 PM, Scott Wood wrote:
 On 04/08/2013 01:25:01 AM, Marek Vasut wrote:
 Dear Mike Dunn,

  This patch adds a driver for the diskonchip G4 nand flash device.  It is
  based on the driver from the linux kernel.
 
  This also includes a separate SPL driver.  A separate SPL driver is used
  because the device operates in a different mode (reliable mode) when
  loading a boot image, and also because the storage format of the boot
  image is different from normal data (pages are stored redundantly).  The
  SPL driver basically mimics how a typical IPL reads data from the device.
  The special operating mode and storage format are used to compensate for
  the fact that the IPL does not contain the BCH ecc decoding algorithm (due
  to size constraints).  Although the u-boot SPL *could* use ecc, it
  operates like an IPL for the sake of simplicity and uniformity, since the
  IPL and SPL share the task of loading the u-boot image. As a side benefit,
  the SPL driver is very small.
 
  Signed-off-by: Mike Dunn miked...@newsguy.com

 Try #ifdef U_BOOT instead of #if 0, no?
 
 Just remove the code that would be hidden by #if 0.  Besides making the U-Boot
 code easier to read, we *want* to get a conflict marker if we try to merge in 
 a
 new upstream version, and those lines were changed in Linux.  This would give 
 us
 an opportunity to see if similar changes are needed to the U-Boot version of 
 the
 code.


OK.


 
 Another option would be to introduce for_each_set_bit in U-Boot.


This was my first inclination, but it looked like a lot of work across multiple
architectures, so I let it go.

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


Re: [U-Boot] [PATCH 3/8] pxa_lcd: allow L_BIAS line to be unused

2013-04-09 Thread Mike Dunn
On 04/07/2013 10:28 PM, Marek Vasut wrote:
 Dear Mike Dunn,
 
 This patch adds a config option CONFIG_SYS_LCD_PXA_NO_L_BIAS, which causes
 the lcd controller initialization code to leave as an ordinary gpio the
 line that is typically configured as the lcd L_BIAS alternate function
 (this is the gpio 77 line).

 For some reason (I don't have a datasheet), the lcd device on the
 palmtreo680 board does not use the L_BIAS line.  PalmOS does not configure
 the gpio 77 line for the L_BIAS alternate function, and if it is
 configured as such, the lcd does not work.

 Signed-off-by: Mike Dunn miked...@newsguy.com
 
 The other option would be to pull the GPIO setup from the driver. That'd be 
 the 
 best.


Well, there's a lot of shared code in pxafb_setup_gpio() that handles pin
configuration for all possible interface widths.

But after looking at this problem some more, I realized that the board-specific
lcd_enable() is called after the pxa driver's initialization, so the board code
can undo the L_BIAS pin configuration.  Not elegant, but better than the ugly
#ifdefs.

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


Re: [U-Boot] [PATCH 6/8] lib: import bitrev library from linux kernel

2013-04-08 Thread Mike Dunn
On 04/07/2013 11:23 PM, Marek Vasut wrote:
 Dear Mike Dunn,
 
 This patch adds the bitrev library from the linux kernel.  This is a simple
 algorithm that uses an 8 bit look-up table to reverse the bits in data
 types of 8, 16, or 32 bit widths.  The docg4 nand flash driver uses it.

 Signed-off-by: Mike Dunn miked...@newsguy.com
 ---
  include/linux/bitrev.h |   16 +
  lib/Makefile   |1 +
  lib/bitrev.c   |   56
  3 files changed, 73
 insertions(+), 0 deletions(-)
  create mode 100644 include/linux/bitrev.h
  create mode 100644 lib/bitrev.c

 diff --git a/include/linux/bitrev.h b/include/linux/bitrev.h
 new file mode 100644
 index 000..7ffe03f
 --- /dev/null
 +++ b/include/linux/bitrev.h
 @@ -0,0 +1,16 @@
 +#ifndef _LINUX_BITREV_H
 +#define _LINUX_BITREV_H
 +
 +#include linux/types.h
 +
 +extern u8 const byte_rev_table[256];
 +
 +static inline u8 bitrev8(u8 byte)
 +{
 +return byte_rev_table[byte];
 +}
 +
 +extern u16 bitrev16(u16 in);
 +extern u32 bitrev32(u32 in);
 
 Do we really need to expose the array and use so many externs here?



Yeah, I don't know why the function prototypes were given the 'extern'
specifier.  This is how it is in the kernel.  They aren't necessary.

As for the table... if the bitrev8() function is moved to bitrev.c, the table
need not be extern.  But if I'm not mistaken, bitrev8() is in the header so that
it can be inlined by the compiler.  So for the sake of performance I think the
extern is appropriate for the table.

Thanks Marek,
Mike

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


Re: [U-Boot] [PATCH 7/8] mtd: nand: add driver for diskonchip g4 nand flash

2013-04-08 Thread Mike Dunn
On 04/07/2013 11:25 PM, Marek Vasut wrote:
[..]
 Try #ifdef U_BOOT instead of #if 0, no?


Marek, can you clarify?  Do you mean something like...

#define U_BOOT
...
#ifndef U_BOOT  /* Currently u-boot does not have for_each_set_bit */
unsigned long bits = ~buf[i];
for_each_set_bit(bitnum, bits, 8) {
...
#else
uint8_t mask;
for(bitnum = 0, mask = 0x80; bitnum  8; bitnum++, mask = 1) {
if (!(buf[i]  mask)) {

...
#endif

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


Re: [U-Boot] [PATCH 2/8] pxa_lcd: make lcd_enable() a weak pointer

2013-04-08 Thread Mike Dunn
On 04/07/2013 12:08 PM, Fabio Estevam wrote:
 On Sun, Apr 7, 2013 at 1:40 PM, Mike Dunn miked...@newsguy.com wrote:
 
 +void lcd_enable(void)
 +   __attribute__((weak, alias(__lcd_enable)));
 
 What about declaring it as:
 
 __weak void lcd_enable(void)
 
 



Yes, that works.  And very to-the-point :)  Thanks.

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


[U-Boot] [PATCH 0/8] palm treo 680 smartphone board support

2013-04-07 Thread Mike Dunn
Hi,

This patchset adds support for the Palm Treo 680 smartphone.  Sorry for the
large number of patches; hope this isn't too bold for a first contribution to
u-boot.  I had to make some minor tweaks to u-boot to get things working.  Most
of these changes are small, and most only touch the pxa arch.  Of course I'd be
happy to rework any patches as necessary.

I'd like to add more features... For one thing, the treo really needs support
for the pxa keypad.  But this patchset is large enough already, and it's
perfectly useful on the treo, as long as you don't mind using usbtty for the
console.

Thanks for looking.

Mike


Mike Dunn (8):
  pxa_lcd: add the ACX544AKN lcd device
  pxa_lcd: make lcd_enable() a weak pointer
  pxa_lcd: allow L_BIAS line to be unused
  pxa27x_udc: remove call to unimplemented set_GPIO_mode()
  arm: bootm: call udc_disable() before booting linux
  lib: import bitrev library from linux kernel
  mtd: nand: add driver for diskonchip g4 nand flash
  board support for palm treo 680

 CREDITS  |4 +
 MAINTAINERS  |3 +
 arch/arm/include/asm/arch-pxa/hardware.h |   11 -
 arch/arm/include/asm/bootm.h |1 +
 arch/arm/lib/bootm.c |1 +
 board/palmtreo680/Makefile   |   47 ++
 board/palmtreo680/flash_u-boot.c |  170 +
 board/palmtreo680/palmtreo680.c  |  184 ++
 board/palmtreo680/palmtreo680_spl.lds|   69 ++
 boards.cfg   |1 +
 doc/README.palmtreo680   |  570 
 drivers/mtd/nand/Makefile|2 +
 drivers/mtd/nand/docg4.c | 1053 ++
 drivers/mtd/nand/docg4_spl.c |  234 +++
 drivers/usb/gadget/pxa27x_udc.c  |4 +-
 drivers/video/pxa_lcd.c  |   56 ++-
 include/configs/palmtreo680.h|  307 +
 include/linux/bitrev.h   |   16 +
 include/linux/mtd/docg4.h|  126 
 lib/Makefile |1 +
 lib/bitrev.c |   56 ++
 21 files changed, 2901 insertions(+), 15 deletions(-)
 create mode 100644 board/palmtreo680/Makefile
 create mode 100644 board/palmtreo680/flash_u-boot.c
 create mode 100644 board/palmtreo680/palmtreo680.c
 create mode 100644 board/palmtreo680/palmtreo680_spl.lds
 create mode 100644 doc/README.palmtreo680
 create mode 100644 drivers/mtd/nand/docg4.c
 create mode 100644 drivers/mtd/nand/docg4_spl.c
 create mode 100644 include/configs/palmtreo680.h
 create mode 100644 include/linux/bitrev.h
 create mode 100644 include/linux/mtd/docg4.h
 create mode 100644 lib/bitrev.c

-- 
1.7.8.6

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


[U-Boot] [PATCH 2/8] pxa_lcd: make lcd_enable() a weak pointer

2013-04-07 Thread Mike Dunn
Make lcd_init() a weak pointer aliased to the current (and currently empty)
lcd_init(), so that boards can overload it if necessary.  The palmtreo680 board
needs to wiggle some gpios and configure the pwm controller in order to get the
lcd and its backlight working.

Signed-off-by: Mike Dunn miked...@newsguy.com
---
 drivers/video/pxa_lcd.c |6 +-
 1 files changed, 5 insertions(+), 1 deletions(-)

diff --git a/drivers/video/pxa_lcd.c b/drivers/video/pxa_lcd.c
index d5fbe7b..fd848ef 100644
--- a/drivers/video/pxa_lcd.c
+++ b/drivers/video/pxa_lcd.c
@@ -410,10 +410,14 @@ void lcd_initcolregs (void)
 #endif /* LCD_MONOCHROME */
 
 /*--*/
-void lcd_enable (void)
+void __lcd_enable(void)
 {
 }
 
+void lcd_enable(void)
+   __attribute__((weak, alias(__lcd_enable)));
+
+
 //
 /* ** PXA255 specific routines */
 //
-- 
1.7.8.6

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


[U-Boot] [PATCH 5/8] arm: bootm: call udc_disable() before booting linux

2013-04-07 Thread Mike Dunn
On the pxa270 (at least), if the udc device is not disabled before jumping to
linux, the device fails to initialize in linux because it was left in a running
state, and the linux driver assumes that it is in a disabled state.

Signed-off-by: Mike Dunn miked...@newsguy.com
---

Arguably, this is a bug in the linux driver, but it seemed pretty simple and
benign to just disable it in u-boot.

 arch/arm/include/asm/bootm.h |1 +
 arch/arm/lib/bootm.c |1 +
 2 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/arch/arm/include/asm/bootm.h b/arch/arm/include/asm/bootm.h
index db2ff94..68189cc 100644
--- a/arch/arm/include/asm/bootm.h
+++ b/arch/arm/include/asm/bootm.h
@@ -21,6 +21,7 @@
 
 #ifdef CONFIG_USB_DEVICE
 extern void udc_disconnect(void);
+extern void udc_disable(void);
 #endif
 
 #endif
diff --git a/arch/arm/lib/bootm.c b/arch/arm/lib/bootm.c
index f3b30c5..6daa7bf 100644
--- a/arch/arm/lib/bootm.c
+++ b/arch/arm/lib/bootm.c
@@ -105,6 +105,7 @@ static void announce_and_cleanup(void)
 
 #ifdef CONFIG_USB_DEVICE
udc_disconnect();
+   udc_disable();
 #endif
cleanup_before_linux();
 }
-- 
1.7.8.6

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


[U-Boot] [PATCH 1/8] pxa_lcd: add the ACX544AKN lcd device

2013-04-07 Thread Mike Dunn
This adds the definitions required to support the LCD device on the Palm Treo
680.

Signed-off-by: Mike Dunn miked...@newsguy.com
---
 drivers/video/pxa_lcd.c |   32 
 1 files changed, 32 insertions(+), 0 deletions(-)

diff --git a/drivers/video/pxa_lcd.c b/drivers/video/pxa_lcd.c
index b40ec36..d5fbe7b 100644
--- a/drivers/video/pxa_lcd.c
+++ b/drivers/video/pxa_lcd.c
@@ -248,6 +248,38 @@ vidinfo_t panel_info = {
 };
 #endif /* CONFIG_ACX517AKN */
 
+#ifdef CONFIG_ACX544AKN
+
+# define LCD_BPP   LCD_COLOR16
+
+/* you have to set lccr0 and lccr3 (including pcd) */
+# define REG_LCCR0 0x003008f9
+# define REG_LCCR3 0x0477 /* 16bpp */
+
+vidinfo_t panel_info = {
+   .vl_col = 320,
+   .vl_row = 320,
+   .vl_width   = 320,
+   .vl_height  = 320,
+   .vl_clkp= CONFIG_SYS_LOW,
+   .vl_oep = CONFIG_SYS_LOW,
+   .vl_hsp = CONFIG_SYS_LOW,
+   .vl_vsp = CONFIG_SYS_LOW,
+   .vl_dp  = CONFIG_SYS_LOW,
+   .vl_bpix= LCD_BPP,
+   .vl_lbw = 0,
+   .vl_splt= 0,
+   .vl_clor= 1,
+   .vl_tft = 1,
+   .vl_hpw = 0x05,
+   .vl_blw = 0x13,
+   .vl_elw = 0x08,
+   .vl_vpw = 0x02,
+   .vl_bfw = 0x07,
+   .vl_efw = 0x05,
+};
+#endif /* CONFIG_ACX544AKN */
+
 /*--*/
 
 #ifdef CONFIG_LQ038J7DH53
-- 
1.7.8.6

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


[U-Boot] [PATCH 3/8] pxa_lcd: allow L_BIAS line to be unused

2013-04-07 Thread Mike Dunn
This patch adds a config option CONFIG_SYS_LCD_PXA_NO_L_BIAS, which causes the
lcd controller initialization code to leave as an ordinary gpio the line that is
typically configured as the lcd L_BIAS alternate function (this is the gpio 77
line).

For some reason (I don't have a datasheet), the lcd device on the palmtreo680
board does not use the L_BIAS line.  PalmOS does not configure the gpio 77 line
for the L_BIAS alternate function, and if it is configured as such, the lcd does
not work.

Signed-off-by: Mike Dunn miked...@newsguy.com
---

This is a little ugly, I know, but I didn't want to try and get too fancy.

 drivers/video/pxa_lcd.c |   18 --
 1 files changed, 16 insertions(+), 2 deletions(-)

diff --git a/drivers/video/pxa_lcd.c b/drivers/video/pxa_lcd.c
index fd848ef..29f62e9 100644
--- a/drivers/video/pxa_lcd.c
+++ b/drivers/video/pxa_lcd.c
@@ -478,8 +478,13 @@ static void pxafb_setup_gpio (vidinfo_t *vid)
 
/* bits 74-77 */
writel(readl(GPDR2) | (0xf  10), GPDR2);
+#ifdef CONFIG_SYS_LCD_PXA_NO_L_BIAS
+   writel((readl(GAFR2_L)  ~(0xff  20)) | (0x2a  20),
+  GAFR2_L);
+#else
writel((readl(GAFR2_L)  ~(0xff  20)) | (0xaa  20),
-   GAFR2_L);
+  GAFR2_L);
+#endif
}
 
/* 8 bit interface */
@@ -497,8 +502,13 @@ static void pxafb_setup_gpio (vidinfo_t *vid)
 
/* bits 74-77 */
writel(readl(GPDR2) | (0xf  10), GPDR2);
+#ifdef CONFIG_SYS_LCD_PXA_NO_L_BIAS
+   writel((readl(GAFR2_L)  ~(0xff  20)) | (0x2a  20),
+  GAFR2_L);
+#else
writel((readl(GAFR2_L)  ~(0xff  20)) | (0xaa  20),
-   GAFR2_L);
+  GAFR2_L);
+#endif
}
 
/* 16 bit interface */
@@ -511,7 +521,11 @@ static void pxafb_setup_gpio (vidinfo_t *vid)
 
writel((readl(GAFR1_U)  ~(0xfff  20)) | (0xaaa  20),
GAFR1_U);
+#ifdef CONFIG_SYS_LCD_PXA_NO_L_BIAS
+   writel((readl(GAFR2_L)  0xf000) | 0x02aa, GAFR2_L);
+#else
writel((readl(GAFR2_L)  0xf000) | 0x0aaa, GAFR2_L);
+#endif
}
else
{
-- 
1.7.8.6

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


[U-Boot] [PATCH 4/8] pxa27x_udc: remove call to unimplemented set_GPIO_mode()

2013-04-07 Thread Mike Dunn
If CONFIG_USB_DEV_PULLUP_GPIO is defined, a link error occurs because the
set_GPIO_mode() helper function is not implemented.  This function doesn't do
much except make the code a little more readable, so I just manually coded its
equivalent and removed the prototype from the header file.  It is invoked no
where else in the code.

While I was at it, I noticed that two other function prototypes in the same
header file are also neither implemented nor invoked anywhere, so I removed them
as well.

Signed-off-by: Mike Dunn miked...@newsguy.com
---
 arch/arm/include/asm/arch-pxa/hardware.h |   11 ---
 drivers/usb/gadget/pxa27x_udc.c  |4 +++-
 2 files changed, 3 insertions(+), 12 deletions(-)

diff --git a/arch/arm/include/asm/arch-pxa/hardware.h 
b/arch/arm/include/asm/arch-pxa/hardware.h
index 44b800f..2397bce 100644
--- a/arch/arm/include/asm/arch-pxa/hardware.h
+++ b/arch/arm/include/asm/arch-pxa/hardware.h
@@ -77,17 +77,6 @@
 #define GPIO_FALLING_EDGE  1
 #define GPIO_RISING_EDGE   2
 #define GPIO_BOTH_EDGES3
-extern void set_GPIO_IRQ_edge( int gpio_nr, int edge_mask );
-
-/*
- * Handy routine to set GPIO alternate functions
- */
-extern void set_GPIO_mode( int gpio_mode );
-
-/*
- * return current lclk frequency in units of 10kHz
- */
-extern unsigned int get_lclk_frequency_10khz(void);
 
 #endif
 
diff --git a/drivers/usb/gadget/pxa27x_udc.c b/drivers/usb/gadget/pxa27x_udc.c
index 4c00081..71cc0f2 100644
--- a/drivers/usb/gadget/pxa27x_udc.c
+++ b/drivers/usb/gadget/pxa27x_udc.c
@@ -610,7 +610,9 @@ void udc_connect(void)
 
 #ifdef CONFIG_USB_DEV_PULLUP_GPIO
/* Turn on the USB connection by enabling the pullup resistor */
-   set_GPIO_mode(CONFIG_USB_DEV_PULLUP_GPIO | GPIO_OUT);
+   writel(readl(GPDR(CONFIG_USB_DEV_PULLUP_GPIO))
+| GPIO_bit(CONFIG_USB_DEV_PULLUP_GPIO),
+  GPDR(CONFIG_USB_DEV_PULLUP_GPIO));
writel(GPIO_bit(CONFIG_USB_DEV_PULLUP_GPIO), 
GPSR(CONFIG_USB_DEV_PULLUP_GPIO));
 #else
/* Host port 2 transceiver D+ pull up enable */
-- 
1.7.8.6

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


[U-Boot] [PATCH 6/8] lib: import bitrev library from linux kernel

2013-04-07 Thread Mike Dunn
This patch adds the bitrev library from the linux kernel.  This is a simple
algorithm that uses an 8 bit look-up table to reverse the bits in data types of
8, 16, or 32 bit widths.  The docg4 nand flash driver uses it.

Signed-off-by: Mike Dunn miked...@newsguy.com
---
 include/linux/bitrev.h |   16 +
 lib/Makefile   |1 +
 lib/bitrev.c   |   56 
 3 files changed, 73 insertions(+), 0 deletions(-)
 create mode 100644 include/linux/bitrev.h
 create mode 100644 lib/bitrev.c

diff --git a/include/linux/bitrev.h b/include/linux/bitrev.h
new file mode 100644
index 000..7ffe03f
--- /dev/null
+++ b/include/linux/bitrev.h
@@ -0,0 +1,16 @@
+#ifndef _LINUX_BITREV_H
+#define _LINUX_BITREV_H
+
+#include linux/types.h
+
+extern u8 const byte_rev_table[256];
+
+static inline u8 bitrev8(u8 byte)
+{
+   return byte_rev_table[byte];
+}
+
+extern u16 bitrev16(u16 in);
+extern u32 bitrev32(u32 in);
+
+#endif /* _LINUX_BITREV_H */
diff --git a/lib/Makefile b/lib/Makefile
index 1bfd3ee..b4aaae9 100644
--- a/lib/Makefile
+++ b/lib/Makefile
@@ -55,6 +55,7 @@ COBJS-$(CONFIG_SHA1) += sha1.o
 COBJS-$(CONFIG_SHA256) += sha256.o
 COBJS-y+= strmhz.o
 COBJS-$(CONFIG_RBTREE) += rbtree.o
+COBJS-$(CONFIG_BITREVERSE) += bitrev.o
 endif
 
 ifdef CONFIG_SPL_BUILD
diff --git a/lib/bitrev.c b/lib/bitrev.c
new file mode 100644
index 000..3448e3f
--- /dev/null
+++ b/lib/bitrev.c
@@ -0,0 +1,56 @@
+/*
+ * Based on bitrev from the Linux kernel, by Akinobu Mita
+ */
+
+
+#include linux/types.h
+#include linux/bitrev.h
+
+const u8 byte_rev_table[256] = {
+   0x00, 0x80, 0x40, 0xc0, 0x20, 0xa0, 0x60, 0xe0,
+   0x10, 0x90, 0x50, 0xd0, 0x30, 0xb0, 0x70, 0xf0,
+   0x08, 0x88, 0x48, 0xc8, 0x28, 0xa8, 0x68, 0xe8,
+   0x18, 0x98, 0x58, 0xd8, 0x38, 0xb8, 0x78, 0xf8,
+   0x04, 0x84, 0x44, 0xc4, 0x24, 0xa4, 0x64, 0xe4,
+   0x14, 0x94, 0x54, 0xd4, 0x34, 0xb4, 0x74, 0xf4,
+   0x0c, 0x8c, 0x4c, 0xcc, 0x2c, 0xac, 0x6c, 0xec,
+   0x1c, 0x9c, 0x5c, 0xdc, 0x3c, 0xbc, 0x7c, 0xfc,
+   0x02, 0x82, 0x42, 0xc2, 0x22, 0xa2, 0x62, 0xe2,
+   0x12, 0x92, 0x52, 0xd2, 0x32, 0xb2, 0x72, 0xf2,
+   0x0a, 0x8a, 0x4a, 0xca, 0x2a, 0xaa, 0x6a, 0xea,
+   0x1a, 0x9a, 0x5a, 0xda, 0x3a, 0xba, 0x7a, 0xfa,
+   0x06, 0x86, 0x46, 0xc6, 0x26, 0xa6, 0x66, 0xe6,
+   0x16, 0x96, 0x56, 0xd6, 0x36, 0xb6, 0x76, 0xf6,
+   0x0e, 0x8e, 0x4e, 0xce, 0x2e, 0xae, 0x6e, 0xee,
+   0x1e, 0x9e, 0x5e, 0xde, 0x3e, 0xbe, 0x7e, 0xfe,
+   0x01, 0x81, 0x41, 0xc1, 0x21, 0xa1, 0x61, 0xe1,
+   0x11, 0x91, 0x51, 0xd1, 0x31, 0xb1, 0x71, 0xf1,
+   0x09, 0x89, 0x49, 0xc9, 0x29, 0xa9, 0x69, 0xe9,
+   0x19, 0x99, 0x59, 0xd9, 0x39, 0xb9, 0x79, 0xf9,
+   0x05, 0x85, 0x45, 0xc5, 0x25, 0xa5, 0x65, 0xe5,
+   0x15, 0x95, 0x55, 0xd5, 0x35, 0xb5, 0x75, 0xf5,
+   0x0d, 0x8d, 0x4d, 0xcd, 0x2d, 0xad, 0x6d, 0xed,
+   0x1d, 0x9d, 0x5d, 0xdd, 0x3d, 0xbd, 0x7d, 0xfd,
+   0x03, 0x83, 0x43, 0xc3, 0x23, 0xa3, 0x63, 0xe3,
+   0x13, 0x93, 0x53, 0xd3, 0x33, 0xb3, 0x73, 0xf3,
+   0x0b, 0x8b, 0x4b, 0xcb, 0x2b, 0xab, 0x6b, 0xeb,
+   0x1b, 0x9b, 0x5b, 0xdb, 0x3b, 0xbb, 0x7b, 0xfb,
+   0x07, 0x87, 0x47, 0xc7, 0x27, 0xa7, 0x67, 0xe7,
+   0x17, 0x97, 0x57, 0xd7, 0x37, 0xb7, 0x77, 0xf7,
+   0x0f, 0x8f, 0x4f, 0xcf, 0x2f, 0xaf, 0x6f, 0xef,
+   0x1f, 0x9f, 0x5f, 0xdf, 0x3f, 0xbf, 0x7f, 0xff,
+};
+
+u16 bitrev16(u16 x)
+{
+   return (bitrev8(x  0xff)  8) | bitrev8(x  8);
+}
+
+/**
+ * bitrev32 - reverse the order of bits in a u32 value
+ * @x: value to be bit-reversed
+ */
+u32 bitrev32(u32 x)
+{
+   return (bitrev16(x  0x)  16) | bitrev16(x  16);
+}
-- 
1.7.8.6

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


[U-Boot] [PATCH 8/8] board support for palm treo 680

2013-04-07 Thread Mike Dunn
A quick overview of u-boot implementation on the treo 680...

The treo 680 has a Diskonchip G4 nand flash chip.  This device has a 2k region
that maps to the system bus at the reset vector in a NOR-like fashion so that it
can be used as the boot device.  The phone is shipped with this 2k region
configured as write-protected (can't be modified) and programmed with an initial
program loader (IPL).  At power-up, this IPL loads the contents of two flash
blocks to SDRAM and jumps to it.  The capacity of the two blocks is not large
enough to hold all of u-boot, so a u-boot SPL is used.  To conserve flash space,
these two blocks and the necessary number of subsequent blocks are programmed
with a concatenated spl + u-boot image.  That way, the IPL will also load a
portion of u-boot proper, and when the spl runs, it relocates the portion of
u-boot that the IPL has already loaded, and then resumes loading the remaining
part of u-boot before jumping to it.

The default_environment is used (CONFIG_ENV_IS_NOWHERE) because I didn't think
that having a writable environment was worth the cost of a flash block, although
adding it would be straightforward.  I abuse the CONFIG_EXTRA_ENV_SETTINGS
option to specify the usbtty for the console (CONFIG_SYS_CONSOLE_IS_IN_ENV).

Support for the LCD is included, but currently it is only useful for displaying
the u-boot splash screen.  But if u-boot is built without the usbtty console, it
does display the auto-boot progress nicely.

Signed-off-by: Mike Dunn miked...@newsguy.com
---
 CREDITS   |4 +
 MAINTAINERS   |3 +
 board/palmtreo680/Makefile|   47 +++
 board/palmtreo680/flash_u-boot.c  |  170 ++
 board/palmtreo680/palmtreo680.c   |  184 +++
 board/palmtreo680/palmtreo680_spl.lds |   69 
 boards.cfg|1 +
 doc/README.palmtreo680|  570 +
 include/configs/palmtreo680.h |  307 ++
 9 files changed, 1355 insertions(+), 0 deletions(-)
 create mode 100644 board/palmtreo680/Makefile
 create mode 100644 board/palmtreo680/flash_u-boot.c
 create mode 100644 board/palmtreo680/palmtreo680.c
 create mode 100644 board/palmtreo680/palmtreo680_spl.lds
 create mode 100644 doc/README.palmtreo680
 create mode 100644 include/configs/palmtreo680.h

diff --git a/CREDITS b/CREDITS
index 7c1458f..3b657e9 100644
--- a/CREDITS
+++ b/CREDITS
@@ -124,6 +124,10 @@ N: James F. Dougherty
 E: j...@gigabitnetworks.com
 D: Port to the MOUSSE board
 
+N: Mike Dunn
+E: miked...@newsguy.com
+D: Palmtreo680 board, docg4 nand flash driver
+
 N: Dave Ellis
 E: d...@sixnetio.com
 D: EEPROM Speedup, SXNI855T port
diff --git a/MAINTAINERS b/MAINTAINERS
index 1614b91..db62af1 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -650,6 +650,9 @@ Wolfgang Denk w...@denx.de
imx27lite   i.MX27
qongi.MX31
 
+Mike Dunn miked...@newsguy.com
+   palmtreo680 pxa270
+
 Kristoffer Ericson kristoffer.eric...@gmail.com
 
jornada SA1110
diff --git a/board/palmtreo680/Makefile b/board/palmtreo680/Makefile
new file mode 100644
index 000..e729e6a
--- /dev/null
+++ b/board/palmtreo680/Makefile
@@ -0,0 +1,47 @@
+#
+# Palm Treo680 Support
+#
+# Copyright (C) 2013 Mike Dunn miked...@newsguy.com
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License as
+# published by the Free Software Foundation; either version 2 of
+# the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+# MA 02111-1307 USA
+#
+
+include $(TOPDIR)/config.mk
+
+LIB= $(obj)lib$(BOARD).o
+
+COBJS  := palmtreo680.o
+
+SRCS   := $(COBJS:.o=.c)
+OBJS   := $(addprefix $(obj),$(COBJS))
+
+$(LIB):$(obj).depend $(OBJS)
+   $(call cmd_link_o_target, $(OBJS))
+
+clean:
+   rm -f $(OBJS)
+
+distclean: clean
+   rm -f $(LIB) core *.bak $(obj).depend
+
+#
+
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
+
+sinclude $(obj).depend
+
+#
diff --git a/board/palmtreo680/flash_u-boot.c b/board/palmtreo680/flash_u-boot.c
new file mode 100644
index 000..ee4213e
--- /dev/null
+++ b/board/palmtreo680/flash_u-boot.c
@@ -0,0 +1,170 @@
+/*
+ * This file is not part of u-boot.  It is a userspace Linux utility that, when
+ * run on the Treo 680, will program u-boot to flash

[U-Boot] [PATCH 7/8] mtd: nand: add driver for diskonchip g4 nand flash

2013-04-07 Thread Mike Dunn
This patch adds a driver for the diskonchip G4 nand flash device.  It is based
on the driver from the linux kernel.

This also includes a separate SPL driver.  A separate SPL driver is used because
the device operates in a different mode (reliable mode) when loading a boot
image, and also because the storage format of the boot image is different from
normal data (pages are stored redundantly).  The SPL driver basically mimics how
a typical IPL reads data from the device.  The special operating mode and
storage format are used to compensate for the fact that the IPL does not contain
the BCH ecc decoding algorithm (due to size constraints).  Although the u-boot
SPL *could* use ecc, it operates like an IPL for the sake of simplicity and
uniformity, since the IPL and SPL share the task of loading the u-boot image.
As a side benefit, the SPL driver is very small.

Signed-off-by: Mike Dunn miked...@newsguy.com
---
 drivers/mtd/nand/Makefile|2 +
 drivers/mtd/nand/docg4.c | 1053 ++
 drivers/mtd/nand/docg4_spl.c |  234 ++
 include/linux/mtd/docg4.h|  126 +
 4 files changed, 1415 insertions(+), 0 deletions(-)
 create mode 100644 drivers/mtd/nand/docg4.c
 create mode 100644 drivers/mtd/nand/docg4_spl.c
 create mode 100644 include/linux/mtd/docg4.h

diff --git a/drivers/mtd/nand/Makefile b/drivers/mtd/nand/Makefile
index c77c0c4..1bcf43c 100644
--- a/drivers/mtd/nand/Makefile
+++ b/drivers/mtd/nand/Makefile
@@ -34,6 +34,7 @@ NORMAL_DRIVERS=y
 endif
 
 COBJS-$(CONFIG_SPL_NAND_AM33XX_BCH) += am335x_spl_bch.o
+COBJS-$(CONFIG_SPL_NAND_DOCG4) += docg4_spl.o
 COBJS-$(CONFIG_SPL_NAND_SIMPLE) += nand_spl_simple.o
 COBJS-$(CONFIG_SPL_NAND_LOAD) += nand_spl_load.o
 COBJS-$(CONFIG_SPL_NAND_ECC) += nand_ecc.o
@@ -78,6 +79,7 @@ COBJS-$(CONFIG_NAND_SPEAR) += spr_nand.o
 COBJS-$(CONFIG_TEGRA_NAND) += tegra_nand.o
 COBJS-$(CONFIG_NAND_OMAP_GPMC) += omap_gpmc.o
 COBJS-$(CONFIG_NAND_PLAT) += nand_plat.o
+COBJS-$(CONFIG_NAND_DOCG4) += docg4.o
 
 else  # minimal SPL drivers
 
diff --git a/drivers/mtd/nand/docg4.c b/drivers/mtd/nand/docg4.c
new file mode 100644
index 000..988aa16
--- /dev/null
+++ b/drivers/mtd/nand/docg4.c
@@ -0,0 +1,1053 @@
+/*
+ * drivers/mtd/nand/docg4.c
+ *
+ *  Copyright (C) 2013 Mike Dunn miked...@newsguy.com
+ *
+ * mtd nand driver for M-Systems DiskOnChip G4
+ *
+ * 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.
+ *
+ * Tested on the Palm Treo 680.  The G4 is also present on Toshiba Portege, 
Asus
+ * P526, some HTC smartphones (Wizard, Prophet, ...), O2 XDA Zinc, maybe 
others.
+ * Should work on these as well.  Let me know!
+ *
+ * TODO:
+ *
+ *  Mechanism for management of password-protected areas
+ *
+ *  Hamming ecc when reading oob only
+ *
+ *  According to the M-Sys documentation, this device is also available in a
+ *  dual-die configuration having a 256MB capacity, but no mechanism for
+ *  detecting this variant is documented.  Currently this driver assumes 128MB
+ *  capacity.
+ *
+ *  Support for multiple cascaded devices (floors).  Not sure which gadgets
+ *  contain multiple G4s in a cascaded configuration, if any.
+ *
+ */
+
+
+#include common.h
+#include asm/arch/hardware.h
+#include asm/io.h
+#include asm/bitops.h
+#include asm/errno.h
+#include malloc.h
+#include nand.h
+#include linux/bch.h
+#include linux/bitrev.h
+#include linux/mtd/docg4.h
+
+/*
+ * The device has a nop register which M-Sys claims is for the purpose of
+ * inserting precise delays.  But beware; at least some operations fail if the
+ * nop writes are replaced with a generic delay!
+ */
+static inline void write_nop(void __iomem *docptr)
+{
+   writew(0, docptr + DOC_NOP);
+}
+
+
+static int poll_status(void __iomem *docptr)
+{
+   /*
+* Busy-wait for the FLASHREADY bit to be set in the FLASHCONTROL
+* register.  Operations known to take a long time (e.g., block erase)
+* should sleep for a while before calling this.
+*/
+
+   uint8_t flash_status;
+
+   /* hardware quirk requires reading twice initially */
+   flash_status = readb(docptr + DOC_FLASHCONTROL);
+
+   do {
+   flash_status = readb(docptr + DOC_FLASHCONTROL);
+   } while (!(flash_status  DOC_CTRL_FLASHREADY));
+
+   return 0;
+}
+
+static void write_addr(void __iomem *docptr, uint32_t docg4_addr)
+{
+   /* write the four address bytes packed in docg4_addr to the device */
+
+   writeb(docg4_addr  0xff, docptr + DOC_FLASHADDRESS);
+   docg4_addr = 8;
+   writeb(docg4_addr  0xff, docptr + DOC_FLASHADDRESS);
+   docg4_addr = 8;
+   writeb(docg4_addr  0xff, docptr + DOC_FLASHADDRESS);
+   docg4_addr = 8;
+   writeb(docg4_addr  0xff, docptr + DOC_FLASHADDRESS);
+}
+
+
+#ifdef DEBUG_DOCG4