public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [U-Boot] [PATCH 0/8] ARM Nomadik: video and keypad for nhk8815 (and RFC inside)
@ 2009-10-09 11:16 Alessandro Rubini
  2009-10-09 11:16 ` [U-Boot] [PATCH 1/8] video: add amba-clcd prime-cell Alessandro Rubini
                   ` (7 more replies)
  0 siblings, 8 replies; 17+ messages in thread
From: Alessandro Rubini @ 2009-10-09 11:16 UTC (permalink / raw)
  To: u-boot

This adds support for display and keypad on the Nomadik evaluation kit.

I tried to split the changes as best as I can.  First the amba-lcd
is added as a generic driver, although it receives pre-computed register
values, as it misses the code to assemble register bits from higher-level
parameters.  I think it acceptable for a boot loader, although it could
be better.

Then, I add the "STMicro Port Extender 2401" as a separete driver.
It's an i2c-driven port extender found on the evaluation kit; I coded it
in order for other boards to use the code if needed.

common/lcd.c is a ifdef hell, and I had a hard time adding 32bpp
support.  Howerver, it was not something I could submit, because it
was even worse with ifdef than now, so I turned to 16bpp. 16bpp wasn't
working either, so I tried to fix it.  This is definitely suboptimal,
and I need help in making it right. Fortunately only the mimc200 uses
16bpp so any issues should be easy to fix. The mimc200 uses CONFIG_ATMEL_LCD,
actually, so it falls on different ifdefs than me.

May I tell that I'd better remove ATMEL_LCD from common/lcd.c and push
specifics in a separate file?  Is that task worth endorsing? I think
once atmel is out of the way, the other specific clases (pxa and
little ore) should be easy, so lcd.c can finally be made more
maintainable.  Will we do that?

BTW: I know the name "make 16bpp work" is not suitable for upstream, but
since I expect at least a V2 series to be needed, I'd better avoid
renaming it at this point. Similarly, there are no comments within each
patch, I'll split this explanation in proper places for V2.

Alessandro Rubini (8):
  video: add amba-clcd prime-cell
  include/nomadik.h: add physical address for cldc
  drivers/misc: add stmpe2401 port extender and keypad controller
  nhk8815.h: define we need stmpe
  lcd: make 16bpp work
  nhk8815: added keypad
  nhk8815: start lower in RAM, so the 800x480 frame buffer fits
  nhk8815: added lcd support

 board/st/nhk8815/Makefile  |    6 +-
 board/st/nhk8815/config.mk |    7 +-
 board/st/nhk8815/keypad.c  |  100 +++++++++++++++++++++++++
 board/st/nhk8815/lcd.c     |   89 ++++++++++++++++++++++
 board/st/nhk8815/nhk8815.c |    9 ++
 common/lcd.c               |   26 +++++--
 drivers/misc/Makefile      |    1 +
 drivers/misc/stmpe2401.c   |  176 ++++++++++++++++++++++++++++++++++++++++++++
 drivers/video/Makefile     |    1 +
 drivers/video/amba.c       |   86 +++++++++++++++++++++
 include/amba_clcd.h        |   85 +++++++++++++++++++++
 include/configs/nhk8815.h  |   20 +++++-
 include/nomadik.h          |    1 +
 include/stmpe2401.h        |   66 ++++++++++++++++
 14 files changed, 660 insertions(+), 13 deletions(-)
 create mode 100644 board/st/nhk8815/keypad.c
 create mode 100644 board/st/nhk8815/lcd.c
 create mode 100644 drivers/misc/stmpe2401.c
 create mode 100644 drivers/video/amba.c
 create mode 100644 include/amba_clcd.h
 create mode 100644 include/stmpe2401.h

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

* [U-Boot] [PATCH 1/8] video: add amba-clcd prime-cell
  2009-10-09 11:16 [U-Boot] [PATCH 0/8] ARM Nomadik: video and keypad for nhk8815 (and RFC inside) Alessandro Rubini
@ 2009-10-09 11:16 ` Alessandro Rubini
  2009-11-22 22:40   ` Wolfgang Denk
  2009-10-09 11:17 ` [U-Boot] [PATCH 2/8] include/nomadik.h: add physical address for cldc Alessandro Rubini
                   ` (6 subsequent siblings)
  7 siblings, 1 reply; 17+ messages in thread
From: Alessandro Rubini @ 2009-10-09 11:16 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>
---
 drivers/video/Makefile |    1 +
 drivers/video/amba.c   |   86 ++++++++++++++++++++++++++++++++++++++++++++++++
 include/amba_clcd.h    |   85 +++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 172 insertions(+), 0 deletions(-)
 create mode 100644 drivers/video/amba.c
 create mode 100644 include/amba_clcd.h

diff --git a/drivers/video/Makefile b/drivers/video/Makefile
index bb6b5a0..a5e339a 100644
--- a/drivers/video/Makefile
+++ b/drivers/video/Makefile
@@ -29,6 +29,7 @@ COBJS-$(CONFIG_ATI_RADEON_FB) += ati_radeon_fb.o
 COBJS-$(CONFIG_ATMEL_LCD) += atmel_lcdfb.o
 COBJS-$(CONFIG_CFB_CONSOLE) += cfb_console.o
 COBJS-$(CONFIG_S6E63D6) += s6e63d6.o
+COBJS-$(CONFIG_VIDEO_AMBA) += amba.o
 COBJS-$(CONFIG_VIDEO_CT69000) += ct69000.o
 COBJS-$(CONFIG_VIDEO_MB862xx) += mb862xx.o
 COBJS-$(CONFIG_VIDEO_MX3) += mx3fb.o
diff --git a/drivers/video/amba.c b/drivers/video/amba.c
new file mode 100644
index 0000000..ebb9aca
--- /dev/null
+++ b/drivers/video/amba.c
@@ -0,0 +1,86 @@
+/*
+ * Driver for AMBA PrimeCell CLCD
+ *
+ * Copyright (C) 2009 Alessandro Rubini
+ *
+ * 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 <asm/io.h>
+#include <lcd.h>
+#include <amba_clcd.h>
+
+/* These variables are required by lcd.c -- although it sets them by itself */
+int lcd_line_length;
+int lcd_color_fg;
+int lcd_color_bg;
+void *lcd_base;
+void *lcd_console_address;
+short console_col;
+short console_row;
+
+/*
+ * To use this driver you need to provide the following in board files:
+ *	a panel_info definition
+ *	an lcd_enable function (can't define a weak default with current code)
+ */
+
+/* There is nothing to do with color registers, we use true color */
+void lcd_setcolreg(ushort regno, ushort red, ushort green, ushort blue)
+{
+	printf("%s:%s - %i %i %i %i\n", __FILE__, __func__,
+	       regno, red, green, blue);
+	return;
+}
+
+/* Low level initialization of the logic cell: depends on panel_info */
+void lcd_ctrl_init(void *lcdbase)
+{
+	struct clcd_regs *regval;
+	void *regs;
+	u32 cntl;
+
+	printf("%s:%s\n", __FILE__, __func__);
+
+	regval = panel_info.priv;
+	regs = (void *)NOMADIK_CLCDC_BASE;
+	cntl = regval->cntl & ~CNTL_LCDEN;
+	printf("%s:%s -- t0 %x t1 %x \n", __FILE__, __func__,
+	       regval->tim0, regval->tim1);
+
+	/* Lazily, just copy the registers over: first control with no ena */
+	writel(cntl, regs + CLCD_CNTL);
+	writel(regval->tim0, regs + CLCD_TIM0);
+	writel(regval->tim1, regs + CLCD_TIM1);
+	writel(regval->tim2, regs + CLCD_TIM2);
+	writel(regval->tim3, regs + CLCD_TIM3);
+	writel((u32)lcdbase, regs + CLCD_UBAS);
+	/* finally, enable */
+	writel(cntl | CNTL_LCDEN, regs + CLCD_CNTL);
+}
+
+/* This is trivial, and copied from atmel_lcdfb.c */
+ulong calc_fbsize(void)
+{
+	printf("%s:%s\n", __FILE__, __func__);
+	return ((panel_info.vl_col * panel_info.vl_row *
+		NBITS(panel_info.vl_bpix)) / 8) + PAGE_SIZE;
+
+}
diff --git a/include/amba_clcd.h b/include/amba_clcd.h
new file mode 100644
index 0000000..f72062b
--- /dev/null
+++ b/include/amba_clcd.h
@@ -0,0 +1,85 @@
+/*
+ * Register definitions for the AMBA CLCD logic cell.
+ *
+ * derived from David A Rusling:
+ *     linux/include/asm-arm/hardware/amba_clcd.h -- Integrator LCD panel.
+ *
+ * Copyright (C) 2001 ARM Limited
+ *
+ * This file is subject to the terms and conditions of the GNU General Public
+ * License.  See the file COPYING in the main directory of this archive
+ * for more details.
+ */
+
+/*
+ * CLCD Controller Internal Register addresses
+ */
+#define CLCD_TIM0		0x00000000
+#define CLCD_TIM1 		0x00000004
+#define CLCD_TIM2 		0x00000008
+#define CLCD_TIM3 		0x0000000c
+#define CLCD_UBAS 		0x00000010
+#define CLCD_LBAS 		0x00000014
+
+#if !defined(CONFIG_ARCH_VERSATILE) && !defined(CONFIG_ARCH_REALVIEW)
+#define CLCD_IENB 		0x00000018
+#define CLCD_CNTL 		0x0000001c
+#else
+/*
+ * Someone rearranged these two registers on the Versatile
+ * platform...
+ */
+#define CLCD_IENB 		0x0000001c
+#define CLCD_CNTL 		0x00000018
+#endif
+
+#define CLCD_STAT 		0x00000020
+#define CLCD_INTR 		0x00000024
+#define CLCD_UCUR 		0x00000028
+#define CLCD_LCUR 		0x0000002C
+#define CLCD_PALL 		0x00000200
+#define CLCD_PALETTE		0x00000200
+
+#define TIM2_CLKSEL		(1 << 5)
+#define TIM2_IVS		(1 << 11)
+#define TIM2_IHS		(1 << 12)
+#define TIM2_IPC		(1 << 13)
+#define TIM2_IOE		(1 << 14)
+#define TIM2_BCD		(1 << 26)
+
+#define CNTL_LCDEN		(1 << 0)
+#define CNTL_LCDBPP1		(0 << 1)
+#define CNTL_LCDBPP2		(1 << 1)
+#define CNTL_LCDBPP4		(2 << 1)
+#define CNTL_LCDBPP8		(3 << 1)
+#define CNTL_LCDBPP16		(4 << 1)
+#define CNTL_LCDBPP16_565	(6 << 1)
+#define CNTL_LCDBPP24		(5 << 1)
+#define CNTL_LCDBW		(1 << 4)
+#define CNTL_LCDTFT		(1 << 5)
+#define CNTL_LCDMONO8		(1 << 6)
+#define CNTL_LCDDUAL		(1 << 7)
+#define CNTL_BGR		(1 << 8)
+#define CNTL_BEBO		(1 << 9)
+#define CNTL_BEPO		(1 << 10)
+#define CNTL_LCDPWR		(1 << 11)
+#define CNTL_LCDVCOMP(x)	((x) << 12)
+#define CNTL_LDMAFIFOTIME	(1 << 15)
+#define CNTL_WATERMARK		(1 << 16)
+
+/* raw information */
+struct clcd_regs {
+	u32			tim0;
+	u32			tim1;
+	u32			tim2;
+	u32			tim3;
+	u32			cntl;
+	unsigned long		pixclock;
+};
+
+/* split up information -- yet to be used */
+struct clcd_params {
+	int left_margin, right_margin, upper_margin, lower_margin;
+	int hsync_len, vsync_len;
+	int sync, vmode;
+};
-- 
1.6.0.2

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

* [U-Boot] [PATCH 2/8] include/nomadik.h: add physical address for cldc
  2009-10-09 11:16 [U-Boot] [PATCH 0/8] ARM Nomadik: video and keypad for nhk8815 (and RFC inside) Alessandro Rubini
  2009-10-09 11:16 ` [U-Boot] [PATCH 1/8] video: add amba-clcd prime-cell Alessandro Rubini
@ 2009-10-09 11:17 ` Alessandro Rubini
  2009-10-09 11:17 ` [U-Boot] [PATCH 3/8] drivers/misc: add stmpe2401 port extender and keypad controller Alessandro Rubini
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 17+ messages in thread
From: Alessandro Rubini @ 2009-10-09 11:17 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/nomadik.h |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/include/nomadik.h b/include/nomadik.h
index d9405fd..ea65b2d 100644
--- a/include/nomadik.h
+++ b/include/nomadik.h
@@ -4,6 +4,7 @@
 #define __NOMADIK_H__
 
 /* Base addresses of our peripherals */
+#define NOMADIK_CLCDC_BASE	0x10120000	/* CLCD Controller */
 #define NOMADIK_SRC_BASE	0x101E0000	/* System and Reset Cnt */
 #define NOMADIK_PMU_BASE	0x101E9000	/* Power Management Unit */
 #define NOMADIK_MPMC_BASE	0x10110000	/* SDRAM Controller */
-- 
1.6.0.2

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

* [U-Boot] [PATCH 3/8] drivers/misc: add stmpe2401 port extender and keypad controller
  2009-10-09 11:16 [U-Boot] [PATCH 0/8] ARM Nomadik: video and keypad for nhk8815 (and RFC inside) Alessandro Rubini
  2009-10-09 11:16 ` [U-Boot] [PATCH 1/8] video: add amba-clcd prime-cell Alessandro Rubini
  2009-10-09 11:17 ` [U-Boot] [PATCH 2/8] include/nomadik.h: add physical address for cldc Alessandro Rubini
@ 2009-10-09 11:17 ` Alessandro Rubini
  2009-11-22 22:47   ` Wolfgang Denk
  2009-10-09 11:17 ` [U-Boot] [PATCH 4/8] nhk8815.h: define we need stmpe Alessandro Rubini
                   ` (4 subsequent siblings)
  7 siblings, 1 reply; 17+ messages in thread
From: Alessandro Rubini @ 2009-10-09 11:17 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>
---
 drivers/misc/Makefile    |    1 +
 drivers/misc/stmpe2401.c |  176 ++++++++++++++++++++++++++++++++++++++++++++++
 include/stmpe2401.h      |   66 +++++++++++++++++
 3 files changed, 243 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..9bab1b4
--- /dev/null
+++ b/drivers/misc/stmpe2401.c
@@ -0,0 +1,176 @@
+/*
+ * 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..fe7691e
--- /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] 17+ messages in thread

* [U-Boot] [PATCH 4/8] nhk8815.h: define we need stmpe
  2009-10-09 11:16 [U-Boot] [PATCH 0/8] ARM Nomadik: video and keypad for nhk8815 (and RFC inside) Alessandro Rubini
                   ` (2 preceding siblings ...)
  2009-10-09 11:17 ` [U-Boot] [PATCH 3/8] drivers/misc: add stmpe2401 port extender and keypad controller Alessandro Rubini
@ 2009-10-09 11:17 ` Alessandro Rubini
  2009-10-09 11:17 ` [U-Boot] [PATCH 5/8] lcd: make 16bpp work Alessandro Rubini
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 17+ messages in thread
From: Alessandro Rubini @ 2009-10-09 11:17 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 a00c2fb..e1be45b 100644
--- a/include/configs/nhk8815.h
+++ b/include/configs/nhk8815.h
@@ -110,7 +110,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
@@ -126,6 +126,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] 17+ messages in thread

* [U-Boot] [PATCH 5/8] lcd: make 16bpp work
  2009-10-09 11:16 [U-Boot] [PATCH 0/8] ARM Nomadik: video and keypad for nhk8815 (and RFC inside) Alessandro Rubini
                   ` (3 preceding siblings ...)
  2009-10-09 11:17 ` [U-Boot] [PATCH 4/8] nhk8815.h: define we need stmpe Alessandro Rubini
@ 2009-10-09 11:17 ` Alessandro Rubini
  2009-11-22 22:43   ` Wolfgang Denk
  2009-10-09 11:17 ` [U-Boot] [PATCH 6/8] nhk8815: added keypad Alessandro Rubini
                   ` (2 subsequent siblings)
  7 siblings, 1 reply; 17+ messages in thread
From: Alessandro Rubini @ 2009-10-09 11:17 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>
---
 common/lcd.c |   26 ++++++++++++++++++++------
 1 files changed, 20 insertions(+), 6 deletions(-)

diff --git a/common/lcd.c b/common/lcd.c
index 4e31618..d05c025 100644
--- a/common/lcd.c
+++ b/common/lcd.c
@@ -63,7 +63,7 @@
 /************************************************************************/
 #ifdef CONFIG_LCD_LOGO
 # include <bmp_logo.h>		/* Get logo data, width and height	*/
-# if (CONSOLE_COLOR_WHITE >= BMP_LOGO_OFFSET)
+# if (CONSOLE_COLOR_WHITE >= BMP_LOGO_OFFSET) && (LCD_BPP != LCD_COLOR16)
 #  error Default Color Map overlaps with Logo Color Map
 # endif
 #endif
@@ -244,10 +244,12 @@ static void lcd_drawchars (ushort x, ushort y, uchar *str, int count)
 				bits <<= 1;
 			}
 #elif LCD_BPP == LCD_COLOR16
-			for (c=0; c<16; ++c) {
-				*d++ = (bits & 0x80) ?
-						lcd_color_fg : lcd_color_bg;
-				bits <<= 1;
+			{
+				u16 *d = (u16 *)dest;
+				for (c=0; c<8; ++c) {
+					*d++ = (bits & 0x80) ? 0xffff : 0;
+					bits <<= 1;
+				}
 			}
 #endif
 		}
@@ -529,6 +531,13 @@ void bitmap_plot (int x, int y)
 		cmap = (ushort *)&(cp->lcd_cmap[BMP_LOGO_OFFSET*sizeof(ushort)]);
 #elif defined(CONFIG_ATMEL_LCD)
 		cmap = (uint *) (panel_info.mmio + ATMEL_LCDC_LUT(0));
+#else
+		/*
+		 * default case: generic system with no cmap (most likely 16bpp)
+		 * We set cmap to the source palette, so no change is done.
+		 * This avoids even more ifdef in the next stanza
+		 */
+		cmap = bmp_logo_palette;
 #endif
 
 		WATCHDOG_RESET();
@@ -567,10 +576,15 @@ void bitmap_plot (int x, int y)
 		}
 	}
 	else { /* true color mode */
+		u16 col16;
 		fb16 = (ushort *)(lcd_base + y * lcd_line_length + x);
 		for (i=0; i<BMP_LOGO_HEIGHT; ++i) {
 			for (j=0; j<BMP_LOGO_WIDTH; j++) {
-				fb16[j] = bmp_logo_palette[(bmap[j])];
+				col16 = bmp_logo_palette[(bmap[j]-16)];
+				fb16[j] =
+					((col16 & 0x000F) << 1) |
+					((col16 & 0x00F0) << 3) |
+					((col16 & 0x0F00) << 4);
 				}
 			bmap += BMP_LOGO_WIDTH;
 			fb16 += panel_info.vl_col;
-- 
1.6.0.2

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

* [U-Boot] [PATCH 6/8] nhk8815: added keypad
  2009-10-09 11:16 [U-Boot] [PATCH 0/8] ARM Nomadik: video and keypad for nhk8815 (and RFC inside) Alessandro Rubini
                   ` (4 preceding siblings ...)
  2009-10-09 11:17 ` [U-Boot] [PATCH 5/8] lcd: make 16bpp work Alessandro Rubini
@ 2009-10-09 11:17 ` Alessandro Rubini
  2009-11-22 22:49   ` Wolfgang Denk
  2009-10-09 11:17 ` [U-Boot] [PATCH 7/8] nhk8815: start lower in RAM, so the 800x480 frame buffer fits Alessandro Rubini
  2009-10-09 11:18 ` [U-Boot] [PATCH 8/8] nhk8815: added lcd support Alessandro Rubini
  7 siblings, 1 reply; 17+ messages in thread
From: Alessandro Rubini @ 2009-10-09 11:17 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>
---
 board/st/nhk8815/Makefile  |    5 ++-
 board/st/nhk8815/keypad.c  |  100 ++++++++++++++++++++++++++++++++++++++++++++
 board/st/nhk8815/nhk8815.c |    5 ++
 include/configs/nhk8815.h  |    3 +
 4 files changed, 112 insertions(+), 1 deletions(-)
 create mode 100644 board/st/nhk8815/keypad.c

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..1753cd1
--- /dev/null
+++ b/board/st/nhk8815/keypad.c
@@ -0,0 +1,100 @@
+/*
+ * 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;
+
+	printf("%s:%s\n", __FILE__, __func__);
+
+	/* 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.c b/board/st/nhk8815/nhk8815.c
index eadce40..efeb0d2 100644
--- a/board/st/nhk8815/nhk8815.c
+++ b/board/st/nhk8815/nhk8815.c
@@ -106,9 +106,14 @@ int board_eth_init(bd_t *bis)
 }
 #endif
 
+extern int nhk8815_keypad_init(void);		/* ./keypad.c */
+
 /* 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 e1be45b..f9dbd7a 100644
--- a/include/configs/nhk8815.h
+++ b/include/configs/nhk8815.h
@@ -131,6 +131,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] 17+ messages in thread

* [U-Boot] [PATCH 7/8] nhk8815: start lower in RAM, so the 800x480 frame buffer fits
  2009-10-09 11:16 [U-Boot] [PATCH 0/8] ARM Nomadik: video and keypad for nhk8815 (and RFC inside) Alessandro Rubini
                   ` (5 preceding siblings ...)
  2009-10-09 11:17 ` [U-Boot] [PATCH 6/8] nhk8815: added keypad Alessandro Rubini
@ 2009-10-09 11:17 ` Alessandro Rubini
  2009-11-22 22:51   ` Wolfgang Denk
  2009-10-09 11:18 ` [U-Boot] [PATCH 8/8] nhk8815: added lcd support Alessandro Rubini
  7 siblings, 1 reply; 17+ messages in thread
From: Alessandro Rubini @ 2009-10-09 11:17 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>
---
 board/st/nhk8815/config.mk |    7 ++-----
 1 files changed, 2 insertions(+), 5 deletions(-)

diff --git a/board/st/nhk8815/config.mk b/board/st/nhk8815/config.mk
index 590393b..faf1d53 100644
--- a/board/st/nhk8815/config.mk
+++ b/board/st/nhk8815/config.mk
@@ -18,9 +18,6 @@
 # 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
+# A display of 800x480x4 takes almost 2MB, so we must be lower than that.
+TEXT_BASE = 0x03c00000
-- 
1.6.0.2

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

* [U-Boot] [PATCH 8/8] nhk8815: added lcd support
  2009-10-09 11:16 [U-Boot] [PATCH 0/8] ARM Nomadik: video and keypad for nhk8815 (and RFC inside) Alessandro Rubini
                   ` (6 preceding siblings ...)
  2009-10-09 11:17 ` [U-Boot] [PATCH 7/8] nhk8815: start lower in RAM, so the 800x480 frame buffer fits Alessandro Rubini
@ 2009-10-09 11:18 ` Alessandro Rubini
  2009-11-22 22:53   ` Wolfgang Denk
  7 siblings, 1 reply; 17+ messages in thread
From: Alessandro Rubini @ 2009-10-09 11:18 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>
---
 board/st/nhk8815/Makefile  |    1 +
 board/st/nhk8815/lcd.c     |   89 ++++++++++++++++++++++++++++++++++++++++++++
 board/st/nhk8815/nhk8815.c |    4 ++
 include/configs/nhk8815.h  |   10 +++++
 4 files changed, 104 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..0f59b2b
--- /dev/null
+++ b/board/st/nhk8815/lcd.c
@@ -0,0 +1,89 @@
+/*
+ * 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_regs nhk8815_clcd_regs = {
+	.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_regs,
+};
+
+/* Don't turn on (too early), but configure data lines and remove reset */
+void lcd_enable(void)
+{
+	printf("%s:%s\n", __FILE__, __func__);
+	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)
+{
+	printf("%s:%s\n", __FILE__, __func__);
+	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.c b/board/st/nhk8815/nhk8815.c
index efeb0d2..ded7681 100644
--- a/board/st/nhk8815/nhk8815.c
+++ b/board/st/nhk8815/nhk8815.c
@@ -107,6 +107,7 @@ int board_eth_init(bd_t *bis)
 #endif
 
 extern int nhk8815_keypad_init(void);		/* ./keypad.c */
+extern int nhk8815_backlight_on(void);		/* in ./lcd.c */
 
 /* Initialization callback, from lib_arm/board.c */
 int board_late_init(void)
@@ -114,6 +115,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 f9dbd7a..ad098d9 100644
--- a/include/configs/nhk8815.h
+++ b/include/configs/nhk8815.h
@@ -134,6 +134,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] 17+ messages in thread

* [U-Boot] [PATCH 1/8] video: add amba-clcd prime-cell
  2009-10-09 11:16 ` [U-Boot] [PATCH 1/8] video: add amba-clcd prime-cell Alessandro Rubini
@ 2009-11-22 22:40   ` Wolfgang Denk
  0 siblings, 0 replies; 17+ messages in thread
From: Wolfgang Denk @ 2009-11-22 22:40 UTC (permalink / raw)
  To: u-boot

Dear Anatolij,

In message <a8b2fcf3420377ff5349893f18d69df46780d250.1255086085.git.rubini@ unipv.it> Alessandro Rubini wrote:
> From: Alessandro Rubini <rubini@unipv.it>
> 
> Signed-off-by: Alessandro Rubini <rubini@unipv.it>
> Acked-by: Andrea Gallo <andrea.gallo@stericsson.com>
> ---
>  drivers/video/Makefile |    1 +
>  drivers/video/amba.c   |   86 ++++++++++++++++++++++++++++++++++++++++++++++++
>  include/amba_clcd.h    |   85 +++++++++++++++++++++++++++++++++++++++++++++++
>  3 files changed, 172 insertions(+), 0 deletions(-)
>  create mode 100644 drivers/video/amba.c
>  create mode 100644 include/amba_clcd.h

Could you please check the status of this patch? Thanks.


Alessandro, can you please try to fix your mailer so it does not
insert spaces / new lines into the message ID's, as this seems to
prevent gmane from archiving these postings?

Best regards,

Wolfgang Denk

-- 
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
I haven't lost my mind -- it's backed up on tape somewhere.

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

* [U-Boot] [PATCH 5/8] lcd: make 16bpp work
  2009-10-09 11:17 ` [U-Boot] [PATCH 5/8] lcd: make 16bpp work Alessandro Rubini
@ 2009-11-22 22:43   ` Wolfgang Denk
  0 siblings, 0 replies; 17+ messages in thread
From: Wolfgang Denk @ 2009-11-22 22:43 UTC (permalink / raw)
  To: u-boot

Dear Alessandro Rubini,

In message <5d6b28b1993d090ee26fa192c1784739eb12db3f.1255086085.git.rubini@ unipv.it> you wrote:
> From: Alessandro Rubini <rubini@unipv.it>
> 
> Signed-off-by: Alessandro Rubini <rubini@unipv.it>
> Acked-by: Andrea Gallo <andrea.gallo@stericsson.com>
> ---
>  common/lcd.c |   26 ++++++++++++++++++++------
>  1 files changed, 20 insertions(+), 6 deletions(-)
> 
> diff --git a/common/lcd.c b/common/lcd.c
> index 4e31618..d05c025 100644
> --- a/common/lcd.c
> +++ b/common/lcd.c
> @@ -63,7 +63,7 @@
>  /************************************************************************/
>  #ifdef CONFIG_LCD_LOGO
>  # include <bmp_logo.h>		/* Get logo data, width and height	*/
> -# if (CONSOLE_COLOR_WHITE >= BMP_LOGO_OFFSET)
> +# if (CONSOLE_COLOR_WHITE >= BMP_LOGO_OFFSET) && (LCD_BPP != LCD_COLOR16)
>  #  error Default Color Map overlaps with Logo Color Map
>  # endif
>  #endif
> @@ -244,10 +244,12 @@ static void lcd_drawchars (ushort x, ushort y, uchar *str, int count)
>  				bits <<= 1;
>  			}
>  #elif LCD_BPP == LCD_COLOR16
> -			for (c=0; c<16; ++c) {
> -				*d++ = (bits & 0x80) ?
> -						lcd_color_fg : lcd_color_bg;
> -				bits <<= 1;
> +			{
> +				u16 *d = (u16 *)dest;

Please do not declare variables in the middle of the code; move
declaration to start of function and avoid the {...} block.


Anatolij, will you pick up this (cleaned up) patch, then?

Best regards,

Wolfgang Denk

-- 
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
You got to learn three things. What's  real,  what's  not  real,  and
what's the difference."           - Terry Pratchett, _Witches Abroad_

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

* [U-Boot] [PATCH 3/8] drivers/misc: add stmpe2401 port extender and keypad controller
  2009-10-09 11:17 ` [U-Boot] [PATCH 3/8] drivers/misc: add stmpe2401 port extender and keypad controller Alessandro Rubini
@ 2009-11-22 22:47   ` Wolfgang Denk
  0 siblings, 0 replies; 17+ messages in thread
From: Wolfgang Denk @ 2009-11-22 22:47 UTC (permalink / raw)
  To: u-boot

Dear Alessandro Rubini,

In message <ed1819daf7e13ba4ae675c5ba4c96bb97350ea94.1255086085.git.rubini@ unipv.it> you wrote:
> From: Alessandro Rubini <rubini@unipv.it>
> 
> Signed-off-by: Alessandro Rubini <rubini@unipv.it>
> Acked-by: Andrea Gallo <andrea.gallo@stericsson.com>
...
> +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;

Please split:

	if (ret < 0)
		return ret;

Please fix globally in whole patch set.

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

ditto in cases like here.

Please check if you want to run the whole code through lindent or
similar.

> +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);

Another of the countless cases of inacceptable indentation.

...
> diff --git a/include/stmpe2401.h b/include/stmpe2401.h
> new file mode 100644
> index 0000000..fe7691e
> --- /dev/null
> +++ b/include/stmpe2401.h
...
> +#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 */

Looks as if you want to turn this into a C struct?

> +/* 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

Please make this a C struct.


Best regards,

Wolfgang Denk

-- 
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
What is wanted is not the will to believe,  but the will to find out,
which is the exact opposite.
		        -- Bertrand Russell, "Skeptical Essays", 1928

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

* [U-Boot] [PATCH 6/8] nhk8815: added keypad
  2009-10-09 11:17 ` [U-Boot] [PATCH 6/8] nhk8815: added keypad Alessandro Rubini
@ 2009-11-22 22:49   ` Wolfgang Denk
  2009-11-22 22:57     ` Alessandro Rubini
  0 siblings, 1 reply; 17+ messages in thread
From: Wolfgang Denk @ 2009-11-22 22:49 UTC (permalink / raw)
  To: u-boot

Dear Alessandro Rubini,

In message <5a9bb8fb15cdb47d2ccd77af62f759ed493de944.1255086085.git.rubini@ unipv.it> you wrote:
> From: Alessandro Rubini <rubini@unipv.it>
> 
> Signed-off-by: Alessandro Rubini <rubini@unipv.it>
> Acked-by: Andrea Gallo <andrea.gallo@stericsson.com>

Please see previous comments about coding style.

Additionally:

> +int nhk8815_keypad_init(void)
> +{
> +        struct stdio_dev dev;

Indentation by TAB only, please.

> +	printf("%s:%s\n", __FILE__, __func__);

Guess this should be debug() instead?



Best regards,

Wolfgang Denk

-- 
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
As long as we're going to reinvent the wheel again, we might as  well
try making it round this time.                        - Mike Dennison

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

* [U-Boot] [PATCH 7/8] nhk8815: start lower in RAM, so the 800x480 frame buffer fits
  2009-10-09 11:17 ` [U-Boot] [PATCH 7/8] nhk8815: start lower in RAM, so the 800x480 frame buffer fits Alessandro Rubini
@ 2009-11-22 22:51   ` Wolfgang Denk
  0 siblings, 0 replies; 17+ messages in thread
From: Wolfgang Denk @ 2009-11-22 22:51 UTC (permalink / raw)
  To: u-boot

Dear Alessandro Rubini,

In message <13e66c1b362688fc77332fc0c9519567214ca6a2.1255086085.git.rubini@ unipv.it> you wrote:
> From: Alessandro Rubini <rubini@unipv.it>
...
> -TEXT_BASE = 0x03F80000
> +# A display of 800x480x4 takes almost 2MB, so we must be lower than that.

x4 ? 4bpp or what? 

I cannot parse this. And even at 32bpp (= 4 byte per pixel) this gives
only 1.5 MiB ?


Best regards,

Wolfgang Denk

-- 
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
Applying computer technology is simply finding the  right  wrench  to
pound in the correct screw.

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

* [U-Boot] [PATCH 8/8] nhk8815: added lcd support
  2009-10-09 11:18 ` [U-Boot] [PATCH 8/8] nhk8815: added lcd support Alessandro Rubini
@ 2009-11-22 22:53   ` Wolfgang Denk
  2009-11-25 15:23     ` Alessandro Rubini
  0 siblings, 1 reply; 17+ messages in thread
From: Wolfgang Denk @ 2009-11-22 22:53 UTC (permalink / raw)
  To: u-boot

Dear Alessandro Rubini,

In message <109a8c9f77c98641a8a02c4346cd2c7d2cc6794f.1255086085.git.rubini@ unipv.it> you wrote:
> From: Alessandro Rubini <rubini@unipv.it>
...
> +void lcd_enable(void)
> +{
> +	printf("%s:%s\n", __FILE__, __func__);
> +	int i;

Please no declarations in the middle of code.

And probably this should be debug() instead of printf() ?

> +int nhk8815_backlight_on(void)
> +{
> +	printf("%s:%s\n", __FILE__, __func__);
> +	int i;

Ditto, 2x.

> diff --git a/board/st/nhk8815/nhk8815.c b/board/st/nhk8815/nhk8815.c
> index efeb0d2..ded7681 100644
> --- a/board/st/nhk8815/nhk8815.c
> +++ b/board/st/nhk8815/nhk8815.c
> @@ -107,6 +107,7 @@ int board_eth_init(bd_t *bis)
>  #endif
>  
>  extern int nhk8815_keypad_init(void);		/* ./keypad.c */
> +extern int nhk8815_backlight_on(void);		/* in ./lcd.c */

Please move prototype decl;arations to some header file.


Best regards,

Wolfgang Denk

-- 
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
"There's only one kind of woman ..." "Or man, for  that  matter.  You
either believe in yourself or you don't."
	-- Kirk and Harry Mudd, "Mudd's Women", stardate 1330.1

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

* [U-Boot] [PATCH 6/8] nhk8815: added keypad
  2009-11-22 22:49   ` Wolfgang Denk
@ 2009-11-22 22:57     ` Alessandro Rubini
  0 siblings, 0 replies; 17+ messages in thread
From: Alessandro Rubini @ 2009-11-22 22:57 UTC (permalink / raw)
  To: u-boot

Hello Wolfgang.

Thanks for looking at my patch-set.

>> +	printf("%s:%s\n", __FILE__, __func__);
> 
> Guess this should be debug() instead?

Actually, this was meant to be removed in final code.  As explained in
the 0/8 message, this patch set was mainly and RFC, as some of the
stuff looked questionable to me. So I chose to post my current status
to get some comments on the approach, not on the details which I know
were just work in progress, though working on real hardware.

So, unless there are serious issues, I'll clean up my current
tree, add comments to each patch and repost as V2.

thanks
/alessandro

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

* [U-Boot] [PATCH 8/8] nhk8815: added lcd support
  2009-11-22 22:53   ` Wolfgang Denk
@ 2009-11-25 15:23     ` Alessandro Rubini
  0 siblings, 0 replies; 17+ messages in thread
From: Alessandro Rubini @ 2009-11-25 15:23 UTC (permalink / raw)
  To: u-boot

I'm almost done with the requested changes on this patch set, will post
V2 this evening after re-running ./makeall as needed.

I've a question, though:

>> +extern int nhk8815_backlight_on(void);		/* in ./lcd.c */
> 
> Please move prototype decl;arations to some header file.

Unfortunately, there is no suitable file. It's just that I split
code related to different drivers in different files, for better
housekeeping.  These two are called nhk8815-something as they are
board-specific anyways.

Should I create a local header file in this same board directory, with
just the two prototypes? Or "ifndef __ASSEMBLY__ in the board config
file is better?  I'd better ask first to avoid a V3 just for this
detail.

Thanks
/alessandro

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

end of thread, other threads:[~2009-11-25 15:23 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-10-09 11:16 [U-Boot] [PATCH 0/8] ARM Nomadik: video and keypad for nhk8815 (and RFC inside) Alessandro Rubini
2009-10-09 11:16 ` [U-Boot] [PATCH 1/8] video: add amba-clcd prime-cell Alessandro Rubini
2009-11-22 22:40   ` Wolfgang Denk
2009-10-09 11:17 ` [U-Boot] [PATCH 2/8] include/nomadik.h: add physical address for cldc Alessandro Rubini
2009-10-09 11:17 ` [U-Boot] [PATCH 3/8] drivers/misc: add stmpe2401 port extender and keypad controller Alessandro Rubini
2009-11-22 22:47   ` Wolfgang Denk
2009-10-09 11:17 ` [U-Boot] [PATCH 4/8] nhk8815.h: define we need stmpe Alessandro Rubini
2009-10-09 11:17 ` [U-Boot] [PATCH 5/8] lcd: make 16bpp work Alessandro Rubini
2009-11-22 22:43   ` Wolfgang Denk
2009-10-09 11:17 ` [U-Boot] [PATCH 6/8] nhk8815: added keypad Alessandro Rubini
2009-11-22 22:49   ` Wolfgang Denk
2009-11-22 22:57     ` Alessandro Rubini
2009-10-09 11:17 ` [U-Boot] [PATCH 7/8] nhk8815: start lower in RAM, so the 800x480 frame buffer fits Alessandro Rubini
2009-11-22 22:51   ` Wolfgang Denk
2009-10-09 11:18 ` [U-Boot] [PATCH 8/8] nhk8815: added lcd support Alessandro Rubini
2009-11-22 22:53   ` Wolfgang Denk
2009-11-25 15:23     ` Alessandro Rubini

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