public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [U-Boot] [PATCH 0/7] Nomadik: lcd and other stuff
@ 2010-04-15 11:11 Alessandro Rubini
  2010-04-15 11:11 ` [U-Boot] [PATCH 1/7] nhk8815: change the order of initialization Alessandro Rubini
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: Alessandro Rubini @ 2010-04-15 11:11 UTC (permalink / raw)
  To: u-boot

From: Alessandro Rubini <rubini@unipv.it>

This patch set is the one from December, with one addition in
documentation (last patch in the series).  It is rebased to current
master, although there was no dependency on the massive renames
besides the "fix timer" patch which meanwhile got upstream.

Alessandro Rubini (7):
  nhk8815: change the order of initialization
  drivers/misc: add stmpe2401 port extender and keypad controller
  nhk8815.h: define we need stmpe
  nhk8815: added keypad
  nhk8815: start lower in RAM, so the 800x480 frame buffer fits
  nhk8815: added lcd support
  nhk8815: documented how to replace u-boot on flash

 board/st/nhk8815/Makefile          |    6 +-
 board/st/nhk8815/config.mk         |    8 +-
 board/st/nhk8815/keypad.c          |   99 +++++++++++++++++++
 board/st/nhk8815/lcd.c             |   88 +++++++++++++++++
 board/st/nhk8815/nhk8815-devices.h |    8 ++
 board/st/nhk8815/nhk8815.c         |   38 +++++--
 doc/README.nhk8815                 |   20 ++++
 drivers/misc/Makefile              |    1 +
 drivers/misc/stmpe2401.c           |  191 ++++++++++++++++++++++++++++++++++++
 include/configs/nhk8815.h          |   20 ++++-
 include/stmpe2401.h                |   66 ++++++++++++
 11 files changed, 528 insertions(+), 17 deletions(-)
 create mode 100644 board/st/nhk8815/keypad.c
 create mode 100644 board/st/nhk8815/lcd.c
 create mode 100644 board/st/nhk8815/nhk8815-devices.h
 create mode 100644 drivers/misc/stmpe2401.c
 create mode 100644 include/stmpe2401.h

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

* [U-Boot] [PATCH 1/7] nhk8815: change the order of initialization
  2010-04-15 11:11 [U-Boot] [PATCH 0/7] Nomadik: lcd and other stuff Alessandro Rubini
@ 2010-04-15 11:11 ` Alessandro Rubini
  2010-04-15 11:12 ` [U-Boot] [PATCH 2/7] drivers/misc: add stmpe2401 port extender and keypad controller Alessandro Rubini
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: Alessandro Rubini @ 2010-04-15 11:11 UTC (permalink / raw)
  To: u-boot

From: Alessandro Rubini <rubini@unipv.it>

Some inizialization was in board_late_init(), but to satisfy drivers
added in the next patches must be performed in normal board_init.
This patch leaves board_late_init() empty, but later patches fill it.

Signed-off-by: Alessandro Rubini <rubini@unipv.it>
Acked-by: Andrea Gallo <andrea.gallo@stericsson.com>
---

 board/st/nhk8815/nhk8815.c |   31 +++++++++++++++++++++----------
 1 files changed, 21 insertions(+), 10 deletions(-)

diff --git a/board/st/nhk8815/nhk8815.c b/board/st/nhk8815/nhk8815.c
index faef810..eadce40 100644
--- a/board/st/nhk8815/nhk8815.c
+++ b/board/st/nhk8815/nhk8815.c
@@ -60,22 +60,26 @@ int board_init(void)
 	writel(0x02100551, NOMADIK_FSMC_BASE + 0x04); /* FSMC_BTR0 */
 
 	icache_enable();
-	return 0;
-}
 
-int board_late_init(void)
-{
+	/*
+	 * Configure I2C pins, as we will use I2C in a later commit
+	 */
+
 	/* Set the two I2C gpio lines to be gpio high */
 	nmk_gpio_set(__SCL, 1);	nmk_gpio_set(__SDA, 1);
 	nmk_gpio_dir(__SCL, 1);	nmk_gpio_dir(__SDA, 1);
 	nmk_gpio_af(__SCL, GPIO_GPIO); nmk_gpio_af(__SDA, GPIO_GPIO);
 
-	/* Reset the I2C port expander, on GPIO77 */
-	nmk_gpio_af(77, GPIO_GPIO);
-	nmk_gpio_dir(77, 1);
-	nmk_gpio_set(77, 0);
-	udelay(10);
-	nmk_gpio_set(77, 1);
+	/* Put the two I2C port expanders out of reset, on GPIO77 and 79 */
+	{
+		int n[2]={77, 79};
+		int i;
+		for (i = 0; i < ARRAY_SIZE(n); i++) {
+			nmk_gpio_af(n[i], GPIO_GPIO);
+			nmk_gpio_dir(n[i], 1);
+			nmk_gpio_set(n[i], 1);
+		}
+	}
 
 	return 0;
 }
@@ -101,3 +105,10 @@ int board_eth_init(bd_t *bis)
 	return rc;
 }
 #endif
+
+/* Initialization callback, from lib_arm/board.c */
+int board_late_init(void)
+{
+	return 0;
+}
+
-- 
1.6.0.2

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

* [U-Boot] [PATCH 2/7] drivers/misc: add stmpe2401 port extender and keypad controller
  2010-04-15 11:11 [U-Boot] [PATCH 0/7] Nomadik: lcd and other stuff Alessandro Rubini
  2010-04-15 11:11 ` [U-Boot] [PATCH 1/7] nhk8815: change the order of initialization Alessandro Rubini
@ 2010-04-15 11:12 ` Alessandro Rubini
  2010-04-15 11:12 ` [U-Boot] [PATCH 3/7] nhk8815.h: define we need stmpe Alessandro Rubini
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: Alessandro Rubini @ 2010-04-15 11:12 UTC (permalink / raw)
  To: u-boot

From: Alessandro Rubini <rubini@unipv.it>

This driver is an i2c device acting as a port extender. Since
the keypad can be configured to act on specific row and column lines,
the specific setup is passed by the board file.  This is used by
the Nomadik nhk8815, through a later patch in this series.

Signed-off-by: Alessandro Rubini <rubini@unipv.it>
Acked-by: Andrea Gallo <andrea.gallo@stericsson.com>
---
 drivers/misc/Makefile    |    1 +
 drivers/misc/stmpe2401.c |  191 ++++++++++++++++++++++++++++++++++++++++++++++
 include/stmpe2401.h      |   66 ++++++++++++++++
 3 files changed, 258 insertions(+), 0 deletions(-)
 create mode 100644 drivers/misc/stmpe2401.c
 create mode 100644 include/stmpe2401.h

diff --git a/drivers/misc/Makefile b/drivers/misc/Makefile
index f6df60f..76c009a 100644
--- a/drivers/misc/Makefile
+++ b/drivers/misc/Makefile
@@ -30,6 +30,7 @@ COBJS-$(CONFIG_DS4510)  += ds4510.o
 COBJS-$(CONFIG_FSL_LAW) += fsl_law.o
 COBJS-$(CONFIG_NS87308) += ns87308.o
 COBJS-$(CONFIG_STATUS_LED) += status_led.o
+COBJS-$(CONFIG_STMPE2401) += stmpe2401.o
 COBJS-$(CONFIG_TWL4030_LED) += twl4030_led.o
 
 COBJS	:= $(COBJS-y)
diff --git a/drivers/misc/stmpe2401.c b/drivers/misc/stmpe2401.c
new file mode 100644
index 0000000..f347d07
--- /dev/null
+++ b/drivers/misc/stmpe2401.c
@@ -0,0 +1,191 @@
+/*
+ * board/st/nhk8815/egpio.c: extended gpio as found on nhk8815 board
+ *
+ * Copyright 2009 Alessandro Rubini <rubini@unipv.it>
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ */
+#include <common.h>
+#include <i2c.h>
+#include <stmpe2401.h>
+
+/*
+ * First, an interface to set and read registers, used in this file as well
+ */
+int pe_getreg(int addr, int reg)
+{
+	unsigned char val8 = reg;
+	int ret;
+
+	ret = i2c_read(addr, reg, 1 /* len */, &val8, 1);
+	if (ret < 0)
+		return ret;
+	return val8;
+}
+
+int pe_setreg(int addr, int reg, int val)
+{
+	unsigned char val8 = val;
+
+	return i2c_write(addr, reg, 1, &val8, 1);
+}
+
+/*
+ * Generic higher-level GPIO interface
+ */
+int pe_gpio_af(int addr, int pin, int af)
+{
+	int regval;
+
+	regval = pe_getreg(addr, PE_GPIO_AFR(pin));
+	if (regval < 0)
+		return regval;
+	regval &= ~PE_GPIO_AF_MASK(pin);
+	regval |= af << PE_GPIO_AF_SHIFT(pin);
+	return pe_setreg(addr, PE_GPIO_AFR(pin), regval);
+}
+
+int pe_gpio_dir(int addr, int pin, int dir)
+{
+	int regval;
+
+	/* 0 == input, 1 == output */
+	regval = pe_getreg(addr, PE_GPIO_GPDR(pin));
+	if (regval < 0)
+		return regval;
+	regval &= ~PE_GPIO_MASK(pin);
+	if (dir)
+		regval |= PE_GPIO_MASK(pin);
+	return pe_setreg(addr, PE_GPIO_GPDR(pin), regval);
+}
+
+int pe_gpio_pud(int addr, int pin, int pu, int pd)
+{
+	int regval, mask = PE_GPIO_MASK(pin);
+
+	/* change pullup */
+	regval = pe_getreg(addr, PE_GPIO_GPPUR(pin));
+	if (regval < 0)
+		return regval;
+	if (pu)
+		regval |= mask;
+	else
+		regval &= ~mask;
+	regval = pe_setreg(addr, PE_GPIO_GPPUR(pin), regval);
+	if (regval < 0)
+		return regval;
+
+	/* change pulldown */
+	regval = pe_getreg(addr, PE_GPIO_GPPDR(pin));
+	if (regval < 0)
+		return regval;
+	if (pu)
+		regval |= mask;
+	else
+		regval &= ~mask;
+	regval = pe_setreg(addr, PE_GPIO_GPPDR(pin), regval);
+	if (regval < 0)
+		return regval;
+
+	return 0;
+}
+
+int pe_gpio_set(int addr, int pin, int val)
+{
+	int reg;
+
+	if (val)
+		reg = PE_GPIO_GPSR(pin);
+	else
+		reg = PE_GPIO_GPCR(pin);
+
+	return pe_setreg(addr, reg, PE_GPIO_MASK(pin));
+}
+
+int pe_gpio_get(int addr, int pin)
+{
+	int regval;
+
+	regval = pe_getreg(addr, PE_GPIO_GPMR(pin));
+	if (regval < 0)
+		return regval;
+	return (regval & PE_GPIO_MASK(pin)) ? 1 : 0;
+}
+
+/*
+ * Generic higher-level keypad interface: we have 12 rows out, 8 columns in
+ */
+int pe_kpc_init(int addr, int rowmask, int colmask, int debounce_ms)
+{
+	int i;
+	/* note that gpio15 is missing in the rows, so use tables */
+	static unsigned char row_to_gpio[12] = {
+		8, 9, 10, 11,   12, 13, 14, 16,   17, 18, 19, 20};
+	static unsigned char col_to_gpio[8] = {
+		0, 1, 2, 3,   4, 5, 6, 7};
+
+	/* First, configure pins for alternate functions (and pullup) */
+	for (i = 0; i < ARRAY_SIZE(row_to_gpio); i++) {
+		if (rowmask & (1 << i)) {
+			pe_gpio_dir(addr, row_to_gpio[i], 1 /* out */);
+			pe_gpio_af(addr, row_to_gpio[i], PE_GPIO_AF_AF1);
+			pe_gpio_pud(addr, row_to_gpio[i], 0, 0);
+		}
+	}
+	for (i = 0; i < ARRAY_SIZE(col_to_gpio); i++) {
+		if (colmask & (1 << i)) {
+			pe_gpio_dir(addr, col_to_gpio[i], 0 /* in */);
+			pe_gpio_af(addr, col_to_gpio[i], PE_GPIO_AF_AF1);
+			pe_gpio_pud(addr, col_to_gpio[i], 1, 0);
+		}
+	}
+
+	/* Set configuration for kpc: no support for dedicated keys */
+	pe_setreg(addr, PE_KPC_COL, colmask);
+	pe_setreg(addr, PE_KPC_ROW_MSB, 0xc0 | (rowmask >> 8));
+	pe_setreg(addr, PE_KPC_ROW_LSB, rowmask & 0xff);
+	pe_setreg(addr, PE_KPC_CTRL_MSB, 0x30 /* scan count is 3 */);
+	pe_setreg(addr, PE_KPC_CTRL_LSB, debounce_ms << 1);
+
+	/* Configure interrupt controller */
+	pe_setreg(addr, PE_ICR_LSB, 0x1); /* level, active low */
+	pe_setreg(addr, PE_IER_LSB, 0x2); /* bit1: keypad */
+
+	/* Start scanning */
+	pe_setreg(addr, PE_KPC_CTRL_LSB, (debounce_ms << 1) | 1);
+	return 0;
+}
+
+int pe_kpc_getkey(int addr, int *row, int *col)
+{
+	int key0, key1;
+
+	/* ack irq: bit 1 is keypad */
+	pe_setreg(addr, PE_ISR_LSB, 0x2);
+	/* get data -- one key only@a time: ignore key1*/
+	key0 = pe_getreg(addr, PE_KPC_DATA0);
+	key1 = pe_getreg(addr, PE_KPC_DATA1);
+	if (key0 & 0x80) /* release: return error */
+		return -1;
+	if ((key0 & 0x78) == 0x78) /* no key reported */
+		return -1;
+	*row = ((key0 & 0x78) >> 3);
+	*col = key0 & 0x07;
+	return 0;
+}
diff --git a/include/stmpe2401.h b/include/stmpe2401.h
new file mode 100644
index 0000000..3f513df
--- /dev/null
+++ b/include/stmpe2401.h
@@ -0,0 +1,66 @@
+/*
+ * Defines and rototypes for port extender STMPE2401. Use "PE_" as short prefix.
+ */
+
+#ifndef __STMPE2401_H
+#define __STMPE2401_H
+
+/*
+ * registers for the EGPIO blocks: we have groups of three registers,
+ * starting from MSB, so use negative offsets from LSB.
+ */
+#define PE_GPIO_OFFSET(gpio)  (- (gpio) / 8)
+#define PE_GPIO_MASK(gpio) (1 << ((gpio) & 7))
+
+#define PE_GPIO_GPMR(gpio)	(0xa4 + PE_GPIO_OFFSET(gpio)) /* monitor */
+#define PE_GPIO_GPCR(gpio)	(0x88 + PE_GPIO_OFFSET(gpio)) /* clear */
+#define PE_GPIO_GPSR(gpio)	(0x85 + PE_GPIO_OFFSET(gpio)) /* set */
+#define PE_GPIO_GPDR(gpio)	(0x8b + PE_GPIO_OFFSET(gpio)) /* direction */
+#define PE_GPIO_GPPUR(gpio)	(0x97 + PE_GPIO_OFFSET(gpio)) /* pull-up */
+#define PE_GPIO_GPPDR(gpio)	(0x9a + PE_GPIO_OFFSET(gpio)) /* pull-down */
+
+/* for alternate function, we have two bits per gpio, so 6 registers */
+#define PE_GPIO_AF_OFFSET(gpio)	(- (gpio) / 4)
+#define PE_GPIO_AF_SHIFT(gpio)	(2 * ((gpio) & 3))
+#define PE_GPIO_AF_MASK(gpio)	(3 << PE_GPIO_AF_SHIFT(gpio))
+#define PE_GPIO_AFR(gpio)	(0xa0 + PE_GPIO_AF_OFFSET(gpio))
+
+enum egpio_af {
+	PE_GPIO_AF_GPIO = 0,
+	PE_GPIO_AF_AF1,
+	PE_GPIO_AF_AF2,
+	PE_GPIO_AF_AF3
+};
+
+/* keypad controller registers */
+#define PE_KPC_COL		0x60
+#define PE_KPC_ROW_MSB		0x61
+#define PE_KPC_ROW_LSB		0x62
+#define PE_KPC_CTRL_MSB		0x63
+#define PE_KPC_CTRL_LSB		0x64
+#define PE_KPC_DATA0		0x68
+#define PE_KPC_DATA1		0x69
+#define PE_KPC_DATA2		0x6a
+
+/* interrupt controller registers (not all of them: we only need the LSB) */
+#define PE_ICR_LSB		0x11 /* control reg */
+#define PE_IER_LSB		0x13 /* enable reg */
+#define PE_ISR_LSB		0x15 /* status reg */
+
+/*
+ * prototypes of public functions
+ */
+extern int pe_getreg(int addr, int reg);
+extern int pe_setreg(int addr, int reg, int val);
+
+extern int pe_gpio_af(int addr, int gpio, int af);
+extern int pe_gpio_dir(int addr, int gpio, int dir);
+extern int pe_gpio_pud(int addr, int gpio, int pu, int pd);
+extern int pe_gpio_set(int addr, int gpio, int val);
+extern int pe_gpio_get(int addr, int gpio);
+
+/* here, rowmask is bits 0..11 for outputs, colmask is bits 0..7, for inputs */
+extern int pe_kpc_init(int addr, int rowmask, int colmask, int debounce_ms);
+extern int pe_kpc_getkey(int addr, int *row, int *col);
+
+#endif /* __STMPE2401_H */
-- 
1.6.0.2

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

* [U-Boot] [PATCH 3/7] nhk8815.h: define we need stmpe
  2010-04-15 11:11 [U-Boot] [PATCH 0/7] Nomadik: lcd and other stuff Alessandro Rubini
  2010-04-15 11:11 ` [U-Boot] [PATCH 1/7] nhk8815: change the order of initialization Alessandro Rubini
  2010-04-15 11:12 ` [U-Boot] [PATCH 2/7] drivers/misc: add stmpe2401 port extender and keypad controller Alessandro Rubini
@ 2010-04-15 11:12 ` Alessandro Rubini
  2010-04-15 11:12 ` [U-Boot] [PATCH 4/7] nhk8815: added keypad Alessandro Rubini
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: Alessandro Rubini @ 2010-04-15 11:12 UTC (permalink / raw)
  To: u-boot

From: Alessandro Rubini <rubini@unipv.it>


Signed-off-by: Alessandro Rubini <rubini@unipv.it>
Acked-by: Andrea Gallo <andrea.gallo@stericsson.com>
---
 include/configs/nhk8815.h |    7 ++++++-
 1 files changed, 6 insertions(+), 1 deletions(-)

diff --git a/include/configs/nhk8815.h b/include/configs/nhk8815.h
index 2b640dc..fcb1b20 100644
--- a/include/configs/nhk8815.h
+++ b/include/configs/nhk8815.h
@@ -109,7 +109,7 @@
 #define CONFIG_PL01x_PORTS	{ (void *)CFG_SERIAL0, (void *)CFG_SERIAL1 }
 #define CONFIG_PL011_CLOCK	48000000
 
-/* i2c, for the port extenders (uses gpio.c in board directory) */
+/* i2c, for the stmpe2401 port extenders (uses gpio.c in board directory) */
 #ifndef __ASSEMBLY__
 #include <asm/arch/gpio.h>
 #define CONFIG_CMD_I2C
@@ -125,6 +125,11 @@
 #define I2C_DELAY     (udelay(2))
 #endif /* __ASSEMBLY__ */
 
+/* Activate port extenders and define their i2c address */
+#define CONFIG_STMPE2401
+#define STMPE0  0x43
+#define STMPE1  0x44
+
 /* Ethernet */
 #define PCI_MEMORY_VADDR	0xe8000000
 #define PCI_IO_VADDR		0xee000000
-- 
1.6.0.2

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

* [U-Boot] [PATCH 4/7] nhk8815: added keypad
  2010-04-15 11:11 [U-Boot] [PATCH 0/7] Nomadik: lcd and other stuff Alessandro Rubini
                   ` (2 preceding siblings ...)
  2010-04-15 11:12 ` [U-Boot] [PATCH 3/7] nhk8815.h: define we need stmpe Alessandro Rubini
@ 2010-04-15 11:12 ` Alessandro Rubini
  2010-04-15 11:12 ` [U-Boot] [PATCH 5/7] nhk8815: start lower in RAM, so the 800x480 frame buffer fits Alessandro Rubini
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: Alessandro Rubini @ 2010-04-15 11:12 UTC (permalink / raw)
  To: u-boot

From: Alessandro Rubini <rubini@unipv.it>

This patch adds keypad support for the nhk8815 board, based on the
stmpe2401 driver. The keypad hosts 16 keys, so each of them sends a
string instead of a single key.  The provided keymap is only an
example and must be customized according to the use case.

Signed-off-by: Alessandro Rubini <rubini@unipv.it>
Acked-by: Andrea Gallo <andrea.gallo@stericsson.com>
---
 board/st/nhk8815/Makefile          |    5 ++-
 board/st/nhk8815/keypad.c          |   99 ++++++++++++++++++++++++++++++++++++
 board/st/nhk8815/nhk8815-devices.h |    7 +++
 board/st/nhk8815/nhk8815.c         |    4 ++
 include/configs/nhk8815.h          |    3 +
 5 files changed, 117 insertions(+), 1 deletions(-)
 create mode 100644 board/st/nhk8815/keypad.c
 create mode 100644 board/st/nhk8815/nhk8815-devices.h

diff --git a/board/st/nhk8815/Makefile b/board/st/nhk8815/Makefile
index b37fe53..1bb1d2c 100644
--- a/board/st/nhk8815/Makefile
+++ b/board/st/nhk8815/Makefile
@@ -29,7 +29,10 @@ include $(TOPDIR)/config.mk
 
 LIB	= $(obj)lib$(BOARD).a
 
-COBJS	:= nhk8815.o
+COBJS-y	:= nhk8815.o
+COBJS-$(CONFIG_NHK8815_KEYPAD) += keypad.o
+
+COBJS	:= $(COBJS-y)
 SOBJS	:= platform.o
 
 SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
diff --git a/board/st/nhk8815/keypad.c b/board/st/nhk8815/keypad.c
new file mode 100644
index 0000000..4bbcce6
--- /dev/null
+++ b/board/st/nhk8815/keypad.c
@@ -0,0 +1,99 @@
+/*
+ * board/st/nhk8815/keypad.c: keypad on nhk8815 board, based on STMPE2401
+ *
+ * Copyright 2009 Alessandro Rubini <rubini@unipv.it>
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ */
+#include <common.h>
+#include <stdio_dev.h>
+#include <i2c.h>
+#include <stmpe2401.h>
+
+/*
+ * Keymap for our 4x4 matrix: since we have just
+ * a few keys, use a string for each of the keys.
+ */
+static char *keymap[4][4] = {
+	{"", "back", "ffw", "left"},
+	{"", "tvout", "playpause", "right"},
+	{"vol-", "lock", "rew", "up"},
+	{"vol+", "start", "ok", "down"}
+};
+
+/* this keeps track of the string being returned */
+static char *nextchar = "";
+
+/* This getc can return failure, not permitted in the caller */
+static int __nhk8815_getc(void)
+{
+	int row, col, res;
+
+	res = pe_kpc_getkey(STMPE0, &row, &col);
+	if (res < 0)
+		return res; /* invalid */
+	nextchar = keymap[row][col];
+	return 0;
+}
+
+/* This is low level: may not report a valid key (a release, for example) */
+static int __nhk8815_tstc(void)
+{
+	/* the interrupt is active low */
+	int gpio = nmk_gpio_get(76);
+	return !gpio;
+}
+
+/* This is the one that is being called, it reads the pending string */
+static int nhk8815_tstc(void)
+{
+	if (*nextchar) /* there's already data */
+		return 1;
+	if (!__nhk8815_tstc()) /* no new data? */
+		return 0;
+	__nhk8815_getc(); /* get (or not) new data */
+	return (nextchar[0] != '\0');
+}
+
+/* So this is only called when there is data in the currenct string */
+static int nhk8815_getc(void)
+{
+	return *(nextchar++);
+}
+
+/* called from late init */
+int nhk8815_keypad_init(void)
+{
+	struct stdio_dev dev;
+
+	/* The keypad is on EXP0, columns 0..3, rows 0..3 */
+	pe_kpc_init(STMPE0, 0x0f, 0x0f, 30 /* ms */);
+
+	/* Keypad interrupt: GPIO76 */
+	nmk_gpio_af(76, GPIO_GPIO);
+	nmk_gpio_dir(76, 0);
+
+	memset (&dev, 0, sizeof (dev));
+	dev.flags = DEV_FLAGS_INPUT;
+	dev.getc = nhk8815_getc;
+	dev.tstc = nhk8815_tstc;
+	strcpy(dev.name, "keypad");
+	stdio_register(&dev);
+	return 0;
+}
diff --git a/board/st/nhk8815/nhk8815-devices.h b/board/st/nhk8815/nhk8815-devices.h
new file mode 100644
index 0000000..78252ed
--- /dev/null
+++ b/board/st/nhk8815/nhk8815-devices.h
@@ -0,0 +1,7 @@
+#ifndef __NHK8815_DEVICES__
+#define __NHK8815_DEVICES__
+
+/* Prototypes for functions exported by device files in this directory */
+extern int nhk8815_keypad_init(void);          /* ./keypad.c */
+
+#endif /* __NHK8815_DEVICES__ */
diff --git a/board/st/nhk8815/nhk8815.c b/board/st/nhk8815/nhk8815.c
index eadce40..fbabd15 100644
--- a/board/st/nhk8815/nhk8815.c
+++ b/board/st/nhk8815/nhk8815.c
@@ -29,6 +29,7 @@
 #include <netdev.h>
 #include <asm/io.h>
 #include <asm/arch/gpio.h>
+#include "nhk8815-devices.h"
 
 DECLARE_GLOBAL_DATA_PTR;
 
@@ -109,6 +110,9 @@ int board_eth_init(bd_t *bis)
 /* Initialization callback, from lib_arm/board.c */
 int board_late_init(void)
 {
+#ifdef CONFIG_NHK8815_KEYPAD
+	nhk8815_keypad_init();
+#endif
 	return 0;
 }
 
diff --git a/include/configs/nhk8815.h b/include/configs/nhk8815.h
index fcb1b20..5eb3cbc 100644
--- a/include/configs/nhk8815.h
+++ b/include/configs/nhk8815.h
@@ -130,6 +130,9 @@
 #define STMPE0  0x43
 #define STMPE1  0x44
 
+/* Keypad using stmpe2401 */
+#define CONFIG_NHK8815_KEYPAD
+
 /* Ethernet */
 #define PCI_MEMORY_VADDR	0xe8000000
 #define PCI_IO_VADDR		0xee000000
-- 
1.6.0.2

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

* [U-Boot] [PATCH 5/7] nhk8815: start lower in RAM, so the 800x480 frame buffer fits
  2010-04-15 11:11 [U-Boot] [PATCH 0/7] Nomadik: lcd and other stuff Alessandro Rubini
                   ` (3 preceding siblings ...)
  2010-04-15 11:12 ` [U-Boot] [PATCH 4/7] nhk8815: added keypad Alessandro Rubini
@ 2010-04-15 11:12 ` Alessandro Rubini
  2010-04-15 11:12 ` [U-Boot] [PATCH 6/7] nhk8815: added lcd support Alessandro Rubini
  2010-04-15 11:12 ` [U-Boot] [PATCH 7/7] nhk8815: documented how to replace u-boot on flash Alessandro Rubini
  6 siblings, 0 replies; 8+ messages in thread
From: Alessandro Rubini @ 2010-04-15 11:12 UTC (permalink / raw)
  To: u-boot

From: Alessandro Rubini <rubini@unipv.it>

This simply moves u-boot to a lower address, as the frame buffer
is allocated after u-boot itself in memory.

Signed-off-by: Alessandro Rubini <rubini@unipv.it>
Acked-by: Andrea Gallo <andrea.gallo@stericsson.com>
---
 board/st/nhk8815/config.mk |    8 +++-----
 1 files changed, 3 insertions(+), 5 deletions(-)

diff --git a/board/st/nhk8815/config.mk b/board/st/nhk8815/config.mk
index 590393b..6e5e358 100644
--- a/board/st/nhk8815/config.mk
+++ b/board/st/nhk8815/config.mk
@@ -18,9 +18,7 @@
 # along with this program; if not, write to the Free Software
 # Foundation, Inc., 59 Temple Place, Suite 330, Boston,
 # MA 02111-1307 USA
-#
-#
-# image should be loaded at 0x01000000
-#
 
-TEXT_BASE = 0x03F80000
+# Start 4MB before the end, as the frame buffer is allocate after
+# u-boot. 800x480 @ 32bpp takes 1.5MB alone, so let's play safe.
+TEXT_BASE = 0x03c00000
-- 
1.6.0.2

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

* [U-Boot] [PATCH 6/7] nhk8815: added lcd support
  2010-04-15 11:11 [U-Boot] [PATCH 0/7] Nomadik: lcd and other stuff Alessandro Rubini
                   ` (4 preceding siblings ...)
  2010-04-15 11:12 ` [U-Boot] [PATCH 5/7] nhk8815: start lower in RAM, so the 800x480 frame buffer fits Alessandro Rubini
@ 2010-04-15 11:12 ` Alessandro Rubini
  2010-04-15 11:12 ` [U-Boot] [PATCH 7/7] nhk8815: documented how to replace u-boot on flash Alessandro Rubini
  6 siblings, 0 replies; 8+ messages in thread
From: Alessandro Rubini @ 2010-04-15 11:12 UTC (permalink / raw)
  To: u-boot

From: Alessandro Rubini <rubini@unipv.it>

This adds lcd support for the board. It includes defines for 32-bit
parameter as well, although support for LCD_COLOR32 is not yet in
u-boot. This uses the stmpe2401 to turn on display backlight.

Signed-off-by: Alessandro Rubini <rubini@unipv.it>
Acked-by: Andrea Gallo <andrea.gallo@stericsson.com>
---
 board/st/nhk8815/Makefile          |    1 +
 board/st/nhk8815/lcd.c             |   88 ++++++++++++++++++++++++++++++++++++
 board/st/nhk8815/nhk8815-devices.h |    1 +
 board/st/nhk8815/nhk8815.c         |    3 +
 include/configs/nhk8815.h          |   10 ++++
 5 files changed, 103 insertions(+), 0 deletions(-)
 create mode 100644 board/st/nhk8815/lcd.c

diff --git a/board/st/nhk8815/Makefile b/board/st/nhk8815/Makefile
index 1bb1d2c..7155f12 100644
--- a/board/st/nhk8815/Makefile
+++ b/board/st/nhk8815/Makefile
@@ -31,6 +31,7 @@ LIB	= $(obj)lib$(BOARD).a
 
 COBJS-y	:= nhk8815.o
 COBJS-$(CONFIG_NHK8815_KEYPAD) += keypad.o
+COBJS-$(CONFIG_LCD) += lcd.o
 
 COBJS	:= $(COBJS-y)
 SOBJS	:= platform.o
diff --git a/board/st/nhk8815/lcd.c b/board/st/nhk8815/lcd.c
new file mode 100644
index 0000000..d3acb48
--- /dev/null
+++ b/board/st/nhk8815/lcd.c
@@ -0,0 +1,88 @@
+/*
+ * board/st/nhk8815/lcd.c: use amba clcd and STMPE2401 for backlight/reset
+ *
+ * Copyright 2009 Alessandro Rubini <rubini@unipv.it>
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ */
+#include <common.h>
+#include <lcd.h>
+#include <amba_clcd.h>
+#include <stmpe2401.h>
+
+/* Two configurations are supported: 32bpp and 16bpp */
+#if LCD_BPP == LCD_COLOR32
+#  define			CLCD_CNTL_VAL		0x0019182b
+#  define			CLCD_BPIX_VAL		5 /* 1<<5 = 32 */
+#elif LCD_BPP == LCD_COLOR16
+#  define			CLCD_CNTL_VAL		0x001d1829
+#  define			CLCD_BPIX_VAL		4 /* 1<<4 = 16 */
+#else
+#  error "Invalid LCD_BPP in config file"
+#endif
+
+/* Horribly, these are precomputed registers */
+struct clcd_config nhk8815_clcd_config = {
+	.address =	(struct clcd_registers *)NOMADIK_CLCDC_BASE,
+	.tim0 =		0xd52600c4,	/* horizontal timings */
+	.tim1 =		0x220a01df,	/* vertical timings */
+	.tim2 =		0x031f1821,	/* clock and signal polarity */
+	.tim3 =		0,		/* not used */
+	.cntl =		CLCD_CNTL_VAL,	/* control, pixel size etc */
+	.pixclock =	18*1000*1000,	/* 18 MHz */
+};
+
+/* This is the panel_info for generic boards. Too little info, actually */
+vidinfo_t panel_info = {
+	.vl_col =	800,
+	.vl_row =	480,
+	.vl_bpix =	CLCD_BPIX_VAL,
+	.priv =		&nhk8815_clcd_config,
+};
+
+/* Don't turn on (too early), but configure data lines and remove reset */
+void lcd_enable(void)
+{
+	int i;
+
+	/* Turn the alternate functions as needed */
+	for (i = 32; i <= 39; i++)
+		nmk_gpio_af(i, GPIO_ALT_B);
+
+	/* EXP1_GPIO_5 = output high -- remove reset from display */
+	pe_gpio_af(STMPE1, 5, PE_GPIO_AF_GPIO);
+	pe_gpio_dir(STMPE1, 5, 1);
+	pe_gpio_set(STMPE1, 5, 1);
+}
+
+/* Called from late_init: we turn on the backlight through port expander */
+int nhk8815_backlight_on(void)
+{
+	int i;
+
+	/* Turn the alternate functions as needed */
+	for (i = 32; i <= 39; i++)
+		nmk_gpio_af(i, GPIO_ALT_B);
+
+	/* EXP0_GPIO_21 = output high -- backlight */
+	pe_gpio_af(STMPE0, 21, PE_GPIO_AF_GPIO);
+	pe_gpio_dir(STMPE0, 21, 1);
+	pe_gpio_set(STMPE0, 21, 1);
+	return 0;
+}
diff --git a/board/st/nhk8815/nhk8815-devices.h b/board/st/nhk8815/nhk8815-devices.h
index 78252ed..aec5825 100644
--- a/board/st/nhk8815/nhk8815-devices.h
+++ b/board/st/nhk8815/nhk8815-devices.h
@@ -3,5 +3,6 @@
 
 /* Prototypes for functions exported by device files in this directory */
 extern int nhk8815_keypad_init(void);          /* ./keypad.c */
+extern int nhk8815_backlight_on(void);		/* in ./lcd.c */
 
 #endif /* __NHK8815_DEVICES__ */
diff --git a/board/st/nhk8815/nhk8815.c b/board/st/nhk8815/nhk8815.c
index fbabd15..fedb3c0 100644
--- a/board/st/nhk8815/nhk8815.c
+++ b/board/st/nhk8815/nhk8815.c
@@ -113,6 +113,9 @@ int board_late_init(void)
 #ifdef CONFIG_NHK8815_KEYPAD
 	nhk8815_keypad_init();
 #endif
+#ifdef CONFIG_LCD
+	nhk8815_backlight_on();
+#endif
 	return 0;
 }
 
diff --git a/include/configs/nhk8815.h b/include/configs/nhk8815.h
index 5eb3cbc..bbeea91 100644
--- a/include/configs/nhk8815.h
+++ b/include/configs/nhk8815.h
@@ -133,6 +133,16 @@
 /* Keypad using stmpe2401 */
 #define CONFIG_NHK8815_KEYPAD
 
+/* Display support */
+#define CONFIG_LCD
+#define CONFIG_LCD_LOGO
+#define CONFIG_LCD_INFO_BELOW_LOGO
+#define CONFIG_SYS_WHITE_ON_BLACK
+#define LCD_BPP				LCD_COLOR16
+#define CONFIG_VIDEO_AMBA
+#define CONFIG_SYS_CONSOLE_IS_IN_ENV	1
+#define CONFIG_CONSOLE_MUX
+
 /* Ethernet */
 #define PCI_MEMORY_VADDR	0xe8000000
 #define PCI_IO_VADDR		0xee000000
-- 
1.6.0.2

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

* [U-Boot] [PATCH 7/7] nhk8815: documented how to replace u-boot on flash
  2010-04-15 11:11 [U-Boot] [PATCH 0/7] Nomadik: lcd and other stuff Alessandro Rubini
                   ` (5 preceding siblings ...)
  2010-04-15 11:12 ` [U-Boot] [PATCH 6/7] nhk8815: added lcd support Alessandro Rubini
@ 2010-04-15 11:12 ` Alessandro Rubini
  6 siblings, 0 replies; 8+ messages in thread
From: Alessandro Rubini @ 2010-04-15 11:12 UTC (permalink / raw)
  To: u-boot

From: Alessandro Rubini <rubini@unipv.it>


Signed-off-by: Alessandro Rubini <rubini@unipv.it>
Acked-by: Andrea Gallo <andrea.gallo@stericsson.com>
---
 doc/README.nhk8815 |   20 ++++++++++++++++++++
 1 files changed, 20 insertions(+), 0 deletions(-)

diff --git a/doc/README.nhk8815 b/doc/README.nhk8815
index 9008e39..365d7e1 100644
--- a/doc/README.nhk8815
+++ b/doc/README.nhk8815
@@ -26,6 +26,26 @@ where it was loaded from, the configurations differ in where the filesystem
 is looked for by default.
 
 
+** How to replace U-Boot with your own
+
+Due to the "secure" boot described above, The U-Boot binary isn't
+expected to live at the beginning of the NAND flash but rather at
+0x80800 (offset 2kB within /dev/mtd).
+
+To replace it with your own binary you should either use the serial
+flasher the vendor distributes (there is a version running on
+GNU/Linux too) or with the following commands from U-Boot.
+These commands read 256kB from the are that will be /dev/mtd2 and
+overwrite U-Boot at offset 2kB:
+
+    nand read  100000 80000 40000
+    bootp      100800 u-boot-nhl8815.bin
+    nand erase  80000 40000
+    nand write 100000 80000 40000
+
+
+** Further documentation
+
 On www.st.com/nomadik and on www.stnwireless.com there are documents,
 summary data and white papers on Nomadik. The full datasheet for
 STn8815 is not currently available on line but under specific request
-- 
1.6.0.2

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

end of thread, other threads:[~2010-04-15 11:12 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-04-15 11:11 [U-Boot] [PATCH 0/7] Nomadik: lcd and other stuff Alessandro Rubini
2010-04-15 11:11 ` [U-Boot] [PATCH 1/7] nhk8815: change the order of initialization Alessandro Rubini
2010-04-15 11:12 ` [U-Boot] [PATCH 2/7] drivers/misc: add stmpe2401 port extender and keypad controller Alessandro Rubini
2010-04-15 11:12 ` [U-Boot] [PATCH 3/7] nhk8815.h: define we need stmpe Alessandro Rubini
2010-04-15 11:12 ` [U-Boot] [PATCH 4/7] nhk8815: added keypad Alessandro Rubini
2010-04-15 11:12 ` [U-Boot] [PATCH 5/7] nhk8815: start lower in RAM, so the 800x480 frame buffer fits Alessandro Rubini
2010-04-15 11:12 ` [U-Boot] [PATCH 6/7] nhk8815: added lcd support Alessandro Rubini
2010-04-15 11:12 ` [U-Boot] [PATCH 7/7] nhk8815: documented how to replace u-boot on flash Alessandro Rubini

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox