Skip to contentSkip to conversation

palm treo 680 smartphone board support

PATCH Superseded Mike Dunn 5 participants 23 messages Apr 7, 2013 – Apr 9, 2013

Subsystems (7)

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore

Mike Dunn

author
#0 lore raw

cover palm treo 680 smartphone board support

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
Signature · 1 line
1.7.8.6
author
#1 lore raw

PATCH 1/8 pxa_lcd: add the ACX544AKN lcd device

This adds the definitions required to support the LCD device on the Palm Treo 680.

---
 drivers/video/pxa_lcd.c |   32 ++++++++++++++++++++++++++++++++
 1 files changed, 32 insertions(+), 0 deletions(-)
drivers/video/pxa_lcd.c +32 -0
index b40ec36..d5fbe7b 100644
@@ -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	0x04700007 /* 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
Signature · 1 line
1.7.8.6
author
#2 lore raw

PATCH 2/8 pxa_lcd: make lcd_enable() a weak pointer

In reply to 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.

---
 drivers/video/pxa_lcd.c |    6 +++++-
 1 files changed, 5 insertions(+), 1 deletions(-)
drivers/video/pxa_lcd.c +5 -1
index d5fbe7b..fd848ef 100644
@@ -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						*/
 /************************************************************************/
Signature · 1 line
1.7.8.6
#3 lore raw

PATCH 2/8 pxa_lcd: make lcd_enable() a weak pointer

drivers/video/pxa_lcd.c void lcd_initcolregs (void) · line 418

Quoted 2 lines · Mike Dunn
drivers/video/pxa_lcd.c +2 -0
+void lcd_enable(void)
+       __attribute__((weak, alias("__lcd_enable")));

What about declaring it as:

__weak void lcd_enable(void)

author
#4 lore raw

PATCH 2/8 pxa_lcd: make lcd_enable() a weak pointer

Quoted 10 lines · Fabio Estevam

drivers/video/pxa_lcd.c void lcd_initcolregs (void) · line 418

Quoted 2 lines · Mike Dunn
drivers/video/pxa_lcd.c +2 -0
+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

author
#5 lore raw

PATCH 3/8 pxa_lcd: allow L_BIAS line to be unused

In reply to 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.

---

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(-)
drivers/video/pxa_lcd.c +16 -2
index fd848ef..29f62e9 100644
@@ -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) & 0xf0000000) | 0x02aaaaaa, GAFR2_L);
+#else
 		writel((readl(GAFR2_L) & 0xf0000000) | 0x0aaaaaaa, GAFR2_L);
+#endif
 	}
 	else
 	{
Signature · 1 line
1.7.8.6
#6 lore raw

PATCH 3/8 pxa_lcd: allow L_BIAS line to be unused

Dear Mike Dunn,

Quoted 11 lines

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.

The other option would be to pull the GPIO setup from the driver. That'd be the best.

Best regards,
Marek Vasut

author
#7 lore raw

PATCH 3/8 pxa_lcd: allow L_BIAS line to be unused

Quoted 12 lines · Marek Vasut

Dear Mike Dunn,

Quoted 10 lines

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.

Quoted 4 lines
Quoted 1 line

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

author
#8 lore raw

PATCH 4/8 pxa27x_udc: remove call to unimplemented set_GPIO_mode()

In reply to 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.

---
 arch/arm/include/asm/arch-pxa/hardware.h |   11 -----------
 drivers/usb/gadget/pxa27x_udc.c          |    4 +++-
 2 files changed, 3 insertions(+), 12 deletions(-)
arch/arm/include/asm/arch-pxa/hardware.h +0 -11
index 44b800f..2397bce 100644
@@ -77,17 +77,6 @@
 #define GPIO_FALLING_EDGE	1
 #define GPIO_RISING_EDGE	2
 #define GPIO_BOTH_EDGES		3
-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
 
drivers/usb/gadget/pxa27x_udc.c +3 -1
index 4c00081..71cc0f2 100644
@@ -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 */
Signature · 1 line
1.7.8.6
author
#9 lore raw

PATCH 5/8 arm: bootm: call udc_disable() before booting linux

In reply to 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.

---

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(-)
arch/arm/include/asm/bootm.h +1 -0
index db2ff94..68189cc 100644
@@ -21,6 +21,7 @@
 
 #ifdef CONFIG_USB_DEVICE
 extern void udc_disconnect(void);
+extern void udc_disable(void);
 #endif
 
 #endif
arch/arm/lib/bootm.c +1 -0
index f3b30c5..6daa7bf 100644
@@ -105,6 +105,7 @@ static void announce_and_cleanup(void)
 
 #ifdef CONFIG_USB_DEVICE
 	udc_disconnect();
+	udc_disable();
 #endif
 	cleanup_before_linux();
 }
Signature · 1 line
1.7.8.6
#10 lore raw

PATCH 5/8 arm: bootm: call udc_disable() before booting linux

Dear Mike Dunn,

Quoted 10 lines

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.

---

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

Fix the linux one too though please.

Best regards,
Marek Vasut

author
#11 lore raw

PATCH 6/8 lib: import bitrev library from linux kernel

In reply to 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.

---
 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
include/linux/bitrev.h new file +16 -0
new file mode 100644
index 0000000..7ffe03f
@@ -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 */
lib/Makefile +1 -0
index 1bfd3ee..b4aaae9 100644
@@ -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
lib/bitrev.c new file +56 -0

56 lines not on this page · raw message

Signature · 1 line
1.7.8.6
#12 lore raw

PATCH 6/8 lib: import bitrev library from linux kernel

Dear Mike Dunn,

Quoted 24 lines

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.

---
 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
include/linux/bitrev.h new file +4 -0
new file mode 100644
index 0000000..7ffe03f
@@ -0,0 +1,16 @@
+#ifndef _LINUX_BITREV_H
+#define _LINUX_BITREV_H
+
+#include <linux/types.h>

include/linux/bitrev.h line 14

Quoted 10 lines
include/linux/bitrev.h new file +10 -0
+
+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?

[...]

author
#13 lore raw

PATCH 6/8 lib: import bitrev library from linux kernel

Quoted 30 lines · Marek Vasut

Dear Mike Dunn,

Quoted 28 lines

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.

---
 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
include/linux/bitrev.h new file +8 -0
new file mode 100644
index 0000000..7ffe03f
@@ -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)
Quoted 8 lines

include/linux/bitrev.h line 14

Quoted 6 lines
include/linux/bitrev.h new file +6 -0
+{
+	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

#14 lore raw

PATCH 6/8 lib: import bitrev library from linux kernel

In reply to Mike Dunn

Dear Mike Dunn,

Quoted 1 line · In message <[email protected]> you wrote:

This patch adds the bitrev library from the linux kernel. This is a simple

-------------------------------------^^^^^^^^^^^^^^^^^^^^^^

Please read bullet # 4 at
http://www.denx.de/wiki/view/U-Boot/Patches#Attributing_Code_Copyrights_Sign
and provide exact reference.

Best regards,

Wolfgang Denk

Signature · 4 lines
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
I have a very small mind and must live with it.    -- Edsger Dijkstra
author
#15 lore raw

PATCH 7/8 mtd: nand: add driver for diskonchip g4 nand flash

In reply to 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.

---
 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
drivers/mtd/nand/Makefile +2 -0
index c77c0c4..1bcf43c 100644
@@ -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
 
drivers/mtd/nand/docg4.c new file +1053 -0

1,053 lines not on this page · raw message

drivers/mtd/nand/docg4_spl.c new file +234 -0

234 lines not on this page · raw message

include/linux/mtd/docg4.h new file +126 -0

126 lines not on this page · raw message

Signature · 1 line
1.7.8.6
#16 lore raw

PATCH 7/8 mtd: nand: add driver for diskonchip g4 nand flash

Dear Mike Dunn,

Quoted 15 lines

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.

Quoted 1 line

Try #ifdef U_BOOT instead of #if 0, no?

Best regards,
Marek Vasut

author
#17 lore raw

PATCH 7/8 mtd: nand: add driver for diskonchip g4 nand flash

On 04/07/2013 11:25 PM, Marek Vasut wrote:
[..]

Quoted 1 line

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

#18 lore raw

PATCH 7/8 mtd: nand: add driver for diskonchip g4 nand flash

Dear Mike Dunn,

Quoted 19 lines · Marek Vasut

[..]

Quoted 1 line

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)) {

		...
Quoted 1 line

#endif

Hrm, I always thought we had some __UBOOT__ defined, but apparently not :-(

Best regards,
Marek Vasut

#19 lore raw

PATCH 7/8 mtd: nand: add driver for diskonchip g4 nand flash

In reply to Marek Vasut
Quoted 21 lines · Marek Vasut

Dear Mike Dunn,

Quoted 1 line

This patch adds a driver for the diskonchip G4 nand flash device.

It is

Quoted 3 lines

based on the driver from the linux kernel.

This also includes a separate SPL driver. A separate SPL driver is

used

Quoted 2 lines

because the device operates in a different mode (reliable mode) when loading a boot image, and also because the storage format of the

boot

Quoted 1 line

image is different from normal data (pages are stored

redundantly). The

Quoted 1 line

SPL driver basically mimics how a typical IPL reads data from the

device.

Quoted 1 line

The special operating mode and storage format are used to

compensate for

Quoted 1 line

the fact that the IPL does not contain the BCH ecc decoding

algorithm (due

Quoted 2 lines

to size constraints). Although the u-boot SPL *could* use ecc, it operates like an IPL for the sake of simplicity and uniformity,

Quoted 8 lines

since the

Quoted 1 line

IPL and SPL share the task of loading the u-boot image. As a side

benefit,

Quoted 3 lines

the SPL driver is very small.

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.

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

-Scott

author
#20 lore raw

PATCH 7/8 mtd: nand: add driver for diskonchip g4 nand flash

Quoted 20 lines · Scott Wood
Quoted 19 lines · Marek Vasut

Dear Mike Dunn,

Quoted 16 lines

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.

Quoted 7 lines
Quoted 1 line

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.

Quoted 2 lines

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

author
#21 lore raw

PATCH 8/8 board support for palm treo 680

In reply to 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.

---
 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
CREDITS +4 -0
index 7c1458f..3b657e9 100644
@@ -124,6 +124,10 @@ N: James F. Dougherty
 E: jfd at GigabitNetworks.COM
 D: Port to the MOUSSE board
 
+N: Mike Dunn
+E: mikedunn at newsguy.com
+D: Palmtreo680 board, docg4 nand flash driver
+
 N: Dave Ellis
 E: DGE at sixnetio.com
 D: EEPROM Speedup, SXNI855T port
MAINTAINERS +3 -0
index 1614b91..db62af1 100644
@@ -650,6 +650,9 @@ Wolfgang Denk <[email protected]>
 	imx27lite	i.MX27
 	qong		i.MX31
 
+Mike Dunn <[email protected]>
+	palmtreo680	pxa270
+
 Kristoffer Ericson <[email protected]>
 
 	jornada	SA1110
board/palmtreo680/Makefile new file +47 -0

47 lines not on this page · raw message

board/palmtreo680/flash_u-boot.c new file +170 -0

170 lines not on this page · raw message

board/palmtreo680/palmtreo680.c new file +184 -0

184 lines not on this page · raw message

board/palmtreo680/palmtreo680_spl.lds new file +69 -0

69 lines not on this page · raw message

boards.cfg +1 -0
index 5fc70be..72a9440 100644
@@ -331,6 +331,7 @@ h2200                        arm         pxa
 lubbock                      arm         pxa
 palmld                       arm         pxa
 palmtc                       arm         pxa
+palmtreo680                  arm         pxa
 polaris                      arm         pxa         trizepsiv           -              -           trizepsiv:POLARIS
 pxa255_idp                   arm         pxa
 trizepsiv                    arm         pxa
doc/README.palmtreo680 new file +570 -0

570 lines not on this page · raw message

include/configs/palmtreo680.h new file +307 -0

307 lines not on this page · raw message

Signature · 1 line
1.7.8.6
#22 lore raw

PATCH 8/8 board support for palm treo 680

Dear Mike Dunn,

Quoted 22 lines

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

Quoted 5 lines

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.

I dunno about the userland too, it might go into tools/ and be unified to all DoCG4 devices. And also make sure to use #define[space] isntead of #define[tab] in the config file.