All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 0/6] ARM: LPC32xx: Patch set with further fixes for LPC32xx
@ 2012-02-25 15:35 Roland Stigge
  2012-02-25 15:35 ` [PATCH v2 1/6] ARM: LPC32xx: Fix irq on GPI_28 Roland Stigge
                   ` (6 more replies)
  0 siblings, 7 replies; 13+ messages in thread
From: Roland Stigge @ 2012-02-25 15:35 UTC (permalink / raw)
  To: linux-arm-kernel

This is another bundle of patches for LPC32xx, fixing bugs and completing
support for drivers using the LPC32xx base port.

It synchronizes changes from lpclinux.com to the mainline kernel and applies
cleanly to 3.3-rc4.

Signed-off-by: Roland Stigge <stigge@antcom.de>

---

Roland Stigge (6):
  ARM: LPC32xx: Fix irq on GPI_28
  ARM: LPC32xx: Fix missing and bad LPC32XX macros
  ARM: LPC32xx: Fix interrupt controller init
  ARM: LPC32xx: irq.c: Clear latched event
  ARM: LPC32xx: serial.c: HW bug workaround
  ARM: LPC32xx: serial.c: Fixed loop limit

 arch/arm/mach-lpc32xx/include/mach/irqs.h     |    2 -
 arch/arm/mach-lpc32xx/include/mach/platform.h |   51 +++++++++++++-------------
 arch/arm/mach-lpc32xx/irq.c                   |   25 ++++++++++--
 arch/arm/mach-lpc32xx/pm.c                    |    2 -
 arch/arm/mach-lpc32xx/serial.c                |   20 +++++++++-
 arch/arm/mach-lpc32xx/timer.c                 |   46 +++++++++++------------
 6 files changed, 91 insertions(+), 55 deletions(-)

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

* [PATCH v2 1/6] ARM: LPC32xx: Fix irq on GPI_28
  2012-02-25 15:35 [PATCH v2 0/6] ARM: LPC32xx: Patch set with further fixes for LPC32xx Roland Stigge
@ 2012-02-25 15:35 ` Roland Stigge
  2012-02-25 15:35 ` [PATCH v2 2/6] ARM: LPC32xx: Fix missing and bad LPC32XX macros Roland Stigge
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 13+ messages in thread
From: Roland Stigge @ 2012-02-25 15:35 UTC (permalink / raw)
  To: linux-arm-kernel

The GPI_28 IRQ was not registered properly. The registration of
IRQ_LPC32XX_GPI_28 was added and the (wrong) IRQ_LPC32XX_GPI_11 at
LPC32XX_SIC1_IRQ(4) was replaced by IRQ_LPC32XX_GPI_28 (see manual of
LPC32xx / interrupt controller).

Signed-off-by: Roland Stigge <stigge@antcom.de>

---
 arch/arm/mach-lpc32xx/include/mach/irqs.h |    2 +-
 arch/arm/mach-lpc32xx/irq.c               |    4 ++++
 2 files changed, 5 insertions(+), 1 deletion(-)

--- linux-2.6.orig/arch/arm/mach-lpc32xx/include/mach/irqs.h
+++ linux-2.6/arch/arm/mach-lpc32xx/include/mach/irqs.h
@@ -61,7 +61,7 @@
  */
 #define IRQ_LPC32XX_JTAG_COMM_TX	LPC32XX_SIC1_IRQ(1)
 #define IRQ_LPC32XX_JTAG_COMM_RX	LPC32XX_SIC1_IRQ(2)
-#define IRQ_LPC32XX_GPI_11		LPC32XX_SIC1_IRQ(4)
+#define IRQ_LPC32XX_GPI_28		LPC32XX_SIC1_IRQ(4)
 #define IRQ_LPC32XX_TS_P		LPC32XX_SIC1_IRQ(6)
 #define IRQ_LPC32XX_TS_IRQ		LPC32XX_SIC1_IRQ(7)
 #define IRQ_LPC32XX_TS_AUX		LPC32XX_SIC1_IRQ(8)
--- linux-2.6.orig/arch/arm/mach-lpc32xx/irq.c
+++ linux-2.6/arch/arm/mach-lpc32xx/irq.c
@@ -118,6 +118,10 @@ static const struct lpc32xx_event_info l
 		.event_group = &lpc32xx_event_pin_regs,
 		.mask = LPC32XX_CLKPWR_EXTSRC_GPI_06_BIT,
 	},
+	[IRQ_LPC32XX_GPI_28] = {
+		.event_group = &lpc32xx_event_pin_regs,
+		.mask = LPC32XX_CLKPWR_EXTSRC_GPI_28_BIT,
+	},
 	[IRQ_LPC32XX_GPIO_00] = {
 		.event_group = &lpc32xx_event_int_regs,
 		.mask = LPC32XX_CLKPWR_INTSRC_GPIO_00_BIT,

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

* [PATCH v2 2/6] ARM: LPC32xx: Fix missing and bad LPC32XX macros
  2012-02-25 15:35 [PATCH v2 0/6] ARM: LPC32xx: Patch set with further fixes for LPC32xx Roland Stigge
  2012-02-25 15:35 ` [PATCH v2 1/6] ARM: LPC32xx: Fix irq on GPI_28 Roland Stigge
@ 2012-02-25 15:35 ` Roland Stigge
  2012-02-25 15:35 ` [PATCH v2 3/6] ARM: LPC32xx: Fix interrupt controller init Roland Stigge
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 13+ messages in thread
From: Roland Stigge @ 2012-02-25 15:35 UTC (permalink / raw)
  To: linux-arm-kernel

Some of the LPC32XX_* macros were typed ("LCP32XX_*"), which is fixed by this
patch. (Besides another LCP doc typo.)

Further, the LPC32XX_GPIO_P2_MUX_SET/CLR/STATE macros were missing.

Signed-off-by: Roland Stigge <stigge@antcom.de>

---
 arch/arm/mach-lpc32xx/include/mach/platform.h |   51 +++++++++++++-------------
 arch/arm/mach-lpc32xx/pm.c                    |    2 -
 arch/arm/mach-lpc32xx/timer.c                 |   46 +++++++++++------------
 3 files changed, 51 insertions(+), 48 deletions(-)

--- linux-2.6.orig/arch/arm/mach-lpc32xx/include/mach/platform.h
+++ linux-2.6/arch/arm/mach-lpc32xx/include/mach/platform.h
@@ -591,42 +591,42 @@
 /*
  * Timer/counter register offsets
  */
-#define LCP32XX_TIMER_IR(x)			io_p2v((x) + 0x00)
-#define LCP32XX_TIMER_TCR(x)			io_p2v((x) + 0x04)
-#define LCP32XX_TIMER_TC(x)			io_p2v((x) + 0x08)
-#define LCP32XX_TIMER_PR(x)			io_p2v((x) + 0x0C)
-#define LCP32XX_TIMER_PC(x)			io_p2v((x) + 0x10)
-#define LCP32XX_TIMER_MCR(x)			io_p2v((x) + 0x14)
-#define LCP32XX_TIMER_MR0(x)			io_p2v((x) + 0x18)
-#define LCP32XX_TIMER_MR1(x)			io_p2v((x) + 0x1C)
-#define LCP32XX_TIMER_MR2(x)			io_p2v((x) + 0x20)
-#define LCP32XX_TIMER_MR3(x)			io_p2v((x) + 0x24)
-#define LCP32XX_TIMER_CCR(x)			io_p2v((x) + 0x28)
-#define LCP32XX_TIMER_CR0(x)			io_p2v((x) + 0x2C)
-#define LCP32XX_TIMER_CR1(x)			io_p2v((x) + 0x30)
-#define LCP32XX_TIMER_CR2(x)			io_p2v((x) + 0x34)
-#define LCP32XX_TIMER_CR3(x)			io_p2v((x) + 0x38)
-#define LCP32XX_TIMER_EMR(x)			io_p2v((x) + 0x3C)
-#define LCP32XX_TIMER_CTCR(x)			io_p2v((x) + 0x70)
+#define LPC32XX_TIMER_IR(x)			io_p2v((x) + 0x00)
+#define LPC32XX_TIMER_TCR(x)			io_p2v((x) + 0x04)
+#define LPC32XX_TIMER_TC(x)			io_p2v((x) + 0x08)
+#define LPC32XX_TIMER_PR(x)			io_p2v((x) + 0x0C)
+#define LPC32XX_TIMER_PC(x)			io_p2v((x) + 0x10)
+#define LPC32XX_TIMER_MCR(x)			io_p2v((x) + 0x14)
+#define LPC32XX_TIMER_MR0(x)			io_p2v((x) + 0x18)
+#define LPC32XX_TIMER_MR1(x)			io_p2v((x) + 0x1C)
+#define LPC32XX_TIMER_MR2(x)			io_p2v((x) + 0x20)
+#define LPC32XX_TIMER_MR3(x)			io_p2v((x) + 0x24)
+#define LPC32XX_TIMER_CCR(x)			io_p2v((x) + 0x28)
+#define LPC32XX_TIMER_CR0(x)			io_p2v((x) + 0x2C)
+#define LPC32XX_TIMER_CR1(x)			io_p2v((x) + 0x30)
+#define LPC32XX_TIMER_CR2(x)			io_p2v((x) + 0x34)
+#define LPC32XX_TIMER_CR3(x)			io_p2v((x) + 0x38)
+#define LPC32XX_TIMER_EMR(x)			io_p2v((x) + 0x3C)
+#define LPC32XX_TIMER_CTCR(x)			io_p2v((x) + 0x70)
 
 /*
  * ir register definitions
  */
-#define LCP32XX_TIMER_CNTR_MTCH_BIT(n)		(1 << ((n) & 0x3))
-#define LCP32XX_TIMER_CNTR_CAPT_BIT(n)		(1 << (4 + ((n) & 0x3)))
+#define LPC32XX_TIMER_CNTR_MTCH_BIT(n)		(1 << ((n) & 0x3))
+#define LPC32XX_TIMER_CNTR_CAPT_BIT(n)		(1 << (4 + ((n) & 0x3)))
 
 /*
  * tcr register definitions
  */
-#define LCP32XX_TIMER_CNTR_TCR_EN		0x1
-#define LCP32XX_TIMER_CNTR_TCR_RESET		0x2
+#define LPC32XX_TIMER_CNTR_TCR_EN		0x1
+#define LPC32XX_TIMER_CNTR_TCR_RESET		0x2
 
 /*
  * mcr register definitions
  */
-#define LCP32XX_TIMER_CNTR_MCR_MTCH(n)		(0x1 << ((n) * 3))
-#define LCP32XX_TIMER_CNTR_MCR_RESET(n)		(0x1 << (((n) * 3) + 1))
-#define LCP32XX_TIMER_CNTR_MCR_STOP(n)		(0x1 << (((n) * 3) + 2))
+#define LPC32XX_TIMER_CNTR_MCR_MTCH(n)		(0x1 << ((n) * 3))
+#define LPC32XX_TIMER_CNTR_MCR_RESET(n)		(0x1 << (((n) * 3) + 1))
+#define LPC32XX_TIMER_CNTR_MCR_STOP(n)		(0x1 << (((n) * 3) + 2))
 
 /*
  * Standard UART register offsets
@@ -690,5 +690,8 @@
 #define LPC32XX_GPIO_P1_MUX_SET			_GPREG(0x130)
 #define LPC32XX_GPIO_P1_MUX_CLR			_GPREG(0x134)
 #define LPC32XX_GPIO_P1_MUX_STATE		_GPREG(0x138)
+#define LPC32XX_GPIO_P2_MUX_SET			_GPREG(0x028)
+#define LPC32XX_GPIO_P2_MUX_CLR			_GPREG(0x02C)
+#define LPC32XX_GPIO_P2_MUX_STATE		_GPREG(0x030)
 
 #endif
--- linux-2.6.orig/arch/arm/mach-lpc32xx/pm.c
+++ linux-2.6/arch/arm/mach-lpc32xx/pm.c
@@ -13,7 +13,7 @@
 /*
  * LPC32XX CPU and system power management
  *
- * The LCP32XX has three CPU modes for controlling system power: run,
+ * The LPC32XX has three CPU modes for controlling system power: run,
  * direct-run, and halt modes. When switching between halt and run modes,
  * the CPU transistions through direct-run mode. For Linux, direct-run
  * mode is not used in normal operation. Halt mode is used when the
--- linux-2.6.orig/arch/arm/mach-lpc32xx/timer.c
+++ linux-2.6/arch/arm/mach-lpc32xx/timer.c
@@ -34,11 +34,11 @@
 static int lpc32xx_clkevt_next_event(unsigned long delta,
     struct clock_event_device *dev)
 {
-	__raw_writel(LCP32XX_TIMER_CNTR_TCR_RESET,
-		LCP32XX_TIMER_TCR(LPC32XX_TIMER0_BASE));
-	__raw_writel(delta, LCP32XX_TIMER_PR(LPC32XX_TIMER0_BASE));
-	__raw_writel(LCP32XX_TIMER_CNTR_TCR_EN,
-		LCP32XX_TIMER_TCR(LPC32XX_TIMER0_BASE));
+	__raw_writel(LPC32XX_TIMER_CNTR_TCR_RESET,
+		LPC32XX_TIMER_TCR(LPC32XX_TIMER0_BASE));
+	__raw_writel(delta, LPC32XX_TIMER_PR(LPC32XX_TIMER0_BASE));
+	__raw_writel(LPC32XX_TIMER_CNTR_TCR_EN,
+		LPC32XX_TIMER_TCR(LPC32XX_TIMER0_BASE));
 
 	return 0;
 }
@@ -58,7 +58,7 @@ static void lpc32xx_clkevt_mode(enum clo
 		 * disable the timer to wait for the first call to
 		 * set_next_event().
 		 */
-		__raw_writel(0, LCP32XX_TIMER_TCR(LPC32XX_TIMER0_BASE));
+		__raw_writel(0, LPC32XX_TIMER_TCR(LPC32XX_TIMER0_BASE));
 		break;
 
 	case CLOCK_EVT_MODE_UNUSED:
@@ -81,8 +81,8 @@ static irqreturn_t lpc32xx_timer_interru
 	struct clock_event_device *evt = &lpc32xx_clkevt;
 
 	/* Clear match */
-	__raw_writel(LCP32XX_TIMER_CNTR_MTCH_BIT(0),
-		LCP32XX_TIMER_IR(LPC32XX_TIMER0_BASE));
+	__raw_writel(LPC32XX_TIMER_CNTR_MTCH_BIT(0),
+		LPC32XX_TIMER_IR(LPC32XX_TIMER0_BASE));
 
 	evt->event_handler(evt);
 
@@ -128,14 +128,14 @@ static void __init lpc32xx_timer_init(vo
 	clkrate = clkrate / clk_get_pclk_div();
 
 	/* Initial timer setup */
-	__raw_writel(0, LCP32XX_TIMER_TCR(LPC32XX_TIMER0_BASE));
-	__raw_writel(LCP32XX_TIMER_CNTR_MTCH_BIT(0),
-		LCP32XX_TIMER_IR(LPC32XX_TIMER0_BASE));
-	__raw_writel(1, LCP32XX_TIMER_MR0(LPC32XX_TIMER0_BASE));
-	__raw_writel(LCP32XX_TIMER_CNTR_MCR_MTCH(0) |
-		LCP32XX_TIMER_CNTR_MCR_STOP(0) |
-		LCP32XX_TIMER_CNTR_MCR_RESET(0),
-		LCP32XX_TIMER_MCR(LPC32XX_TIMER0_BASE));
+	__raw_writel(0, LPC32XX_TIMER_TCR(LPC32XX_TIMER0_BASE));
+	__raw_writel(LPC32XX_TIMER_CNTR_MTCH_BIT(0),
+		LPC32XX_TIMER_IR(LPC32XX_TIMER0_BASE));
+	__raw_writel(1, LPC32XX_TIMER_MR0(LPC32XX_TIMER0_BASE));
+	__raw_writel(LPC32XX_TIMER_CNTR_MCR_MTCH(0) |
+		LPC32XX_TIMER_CNTR_MCR_STOP(0) |
+		LPC32XX_TIMER_CNTR_MCR_RESET(0),
+		LPC32XX_TIMER_MCR(LPC32XX_TIMER0_BASE));
 
 	/* Setup tick interrupt */
 	setup_irq(IRQ_LPC32XX_TIMER0, &lpc32xx_timer_irq);
@@ -151,14 +151,14 @@ static void __init lpc32xx_timer_init(vo
 	clockevents_register_device(&lpc32xx_clkevt);
 
 	/* Use timer1 as clock source. */
-	__raw_writel(LCP32XX_TIMER_CNTR_TCR_RESET,
-		LCP32XX_TIMER_TCR(LPC32XX_TIMER1_BASE));
-	__raw_writel(0, LCP32XX_TIMER_PR(LPC32XX_TIMER1_BASE));
-	__raw_writel(0, LCP32XX_TIMER_MCR(LPC32XX_TIMER1_BASE));
-	__raw_writel(LCP32XX_TIMER_CNTR_TCR_EN,
-		LCP32XX_TIMER_TCR(LPC32XX_TIMER1_BASE));
+	__raw_writel(LPC32XX_TIMER_CNTR_TCR_RESET,
+		LPC32XX_TIMER_TCR(LPC32XX_TIMER1_BASE));
+	__raw_writel(0, LPC32XX_TIMER_PR(LPC32XX_TIMER1_BASE));
+	__raw_writel(0, LPC32XX_TIMER_MCR(LPC32XX_TIMER1_BASE));
+	__raw_writel(LPC32XX_TIMER_CNTR_TCR_EN,
+		LPC32XX_TIMER_TCR(LPC32XX_TIMER1_BASE));
 
-	clocksource_mmio_init(LCP32XX_TIMER_TC(LPC32XX_TIMER1_BASE),
+	clocksource_mmio_init(LPC32XX_TIMER_TC(LPC32XX_TIMER1_BASE),
 		"lpc32xx_clksrc", clkrate, 300, 32, clocksource_mmio_readl_up);
 }
 

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

* [PATCH v2 3/6] ARM: LPC32xx: Fix interrupt controller init
  2012-02-25 15:35 [PATCH v2 0/6] ARM: LPC32xx: Patch set with further fixes for LPC32xx Roland Stigge
  2012-02-25 15:35 ` [PATCH v2 1/6] ARM: LPC32xx: Fix irq on GPI_28 Roland Stigge
  2012-02-25 15:35 ` [PATCH v2 2/6] ARM: LPC32xx: Fix missing and bad LPC32XX macros Roland Stigge
@ 2012-02-25 15:35 ` Roland Stigge
  2012-02-25 15:35 ` [PATCH v2 4/6] ARM: LPC32xx: irq.c: Clear latched event Roland Stigge
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 13+ messages in thread
From: Roland Stigge @ 2012-02-25 15:35 UTC (permalink / raw)
  To: linux-arm-kernel

This patch fixes the initialization of the interrupt controller of the LPC32xx
by correctly setting up SIC1 and SIC2 instead of (wrongly) using the same value
as for the Main Interrupt Controller (MIC).

Signed-off-by: Roland Stigge <stigge@antcom.de>

---
 arch/arm/mach-lpc32xx/irq.c |   10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

--- linux-2.6.orig/arch/arm/mach-lpc32xx/irq.c
+++ linux-2.6/arch/arm/mach-lpc32xx/irq.c
@@ -384,13 +384,15 @@ void __init lpc32xx_init_irq(void)
 
 	/* Setup SIC1 */
 	__raw_writel(0, LPC32XX_INTC_MASK(LPC32XX_SIC1_BASE));
-	__raw_writel(MIC_APR_DEFAULT, LPC32XX_INTC_POLAR(LPC32XX_SIC1_BASE));
-	__raw_writel(MIC_ATR_DEFAULT, LPC32XX_INTC_ACT_TYPE(LPC32XX_SIC1_BASE));
+	__raw_writel(SIC1_APR_DEFAULT, LPC32XX_INTC_POLAR(LPC32XX_SIC1_BASE));
+	__raw_writel(SIC1_ATR_DEFAULT,
+				LPC32XX_INTC_ACT_TYPE(LPC32XX_SIC1_BASE));
 
 	/* Setup SIC2 */
 	__raw_writel(0, LPC32XX_INTC_MASK(LPC32XX_SIC2_BASE));
-	__raw_writel(MIC_APR_DEFAULT, LPC32XX_INTC_POLAR(LPC32XX_SIC2_BASE));
-	__raw_writel(MIC_ATR_DEFAULT, LPC32XX_INTC_ACT_TYPE(LPC32XX_SIC2_BASE));
+	__raw_writel(SIC2_APR_DEFAULT, LPC32XX_INTC_POLAR(LPC32XX_SIC2_BASE));
+	__raw_writel(SIC2_ATR_DEFAULT,
+				LPC32XX_INTC_ACT_TYPE(LPC32XX_SIC2_BASE));
 
 	/* Configure supported IRQ's */
 	for (i = 0; i < NR_IRQS; i++) {

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

* [PATCH v2 4/6] ARM: LPC32xx: irq.c: Clear latched event
  2012-02-25 15:35 [PATCH v2 0/6] ARM: LPC32xx: Patch set with further fixes for LPC32xx Roland Stigge
                   ` (2 preceding siblings ...)
  2012-02-25 15:35 ` [PATCH v2 3/6] ARM: LPC32xx: Fix interrupt controller init Roland Stigge
@ 2012-02-25 15:35 ` Roland Stigge
  2012-02-25 15:35 ` [PATCH v2 5/6] ARM: LPC32xx: serial.c: HW bug workaround Roland Stigge
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 13+ messages in thread
From: Roland Stigge @ 2012-02-25 15:35 UTC (permalink / raw)
  To: linux-arm-kernel

This patch fixes the wakeup disable function by clearing latched events.

Signed-off-by: Roland Stigge <stigge@antcom.de>

---
 arch/arm/mach-lpc32xx/irq.c |   11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

--- linux-2.6.orig/arch/arm/mach-lpc32xx/irq.c
+++ linux-2.6/arch/arm/mach-lpc32xx/irq.c
@@ -309,9 +309,18 @@ static int lpc32xx_irq_wake(struct irq_d
 
 		if (state)
 			eventreg |= lpc32xx_events[d->irq].mask;
-		else
+		else {
 			eventreg &= ~lpc32xx_events[d->irq].mask;
 
+			/*
+			 * When disabling the wakeup, clear the latched
+			 * event
+			 */
+			__raw_writel(lpc32xx_events[d->irq].mask,
+				lpc32xx_events[d->irq].
+				event_group->rawstat_reg);
+		}
+
 		__raw_writel(eventreg,
 			lpc32xx_events[d->irq].event_group->enab_reg);
 

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

* [PATCH v2 5/6] ARM: LPC32xx: serial.c: HW bug workaround
  2012-02-25 15:35 [PATCH v2 0/6] ARM: LPC32xx: Patch set with further fixes for LPC32xx Roland Stigge
                   ` (3 preceding siblings ...)
  2012-02-25 15:35 ` [PATCH v2 4/6] ARM: LPC32xx: irq.c: Clear latched event Roland Stigge
@ 2012-02-25 15:35 ` Roland Stigge
  2012-02-27 14:14   ` Wolfram Sang
  2012-02-25 15:35 ` [PATCH v2 6/6] ARM: LPC32xx: serial.c: Fixed loop limit Roland Stigge
  2012-02-27 19:16 ` [PATCH v2 0/6] ARM: LPC32xx: Patch set with further fixes for LPC32xx Kevin Wells
  6 siblings, 1 reply; 13+ messages in thread
From: Roland Stigge @ 2012-02-25 15:35 UTC (permalink / raw)
  To: linux-arm-kernel

This patch fixes a HW bug by flushing RX FIFOs of the UARTs on init.

Signed-off-by: Roland Stigge <stigge@antcom.de>

---
 arch/arm/mach-lpc32xx/serial.c |   18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

--- linux-2.6.orig/arch/arm/mach-lpc32xx/serial.c
+++ linux-2.6/arch/arm/mach-lpc32xx/serial.c
@@ -88,6 +88,7 @@ struct uartinit {
 	char *uart_ck_name;
 	u32 ck_mode_mask;
 	void __iomem *pdiv_clk_reg;
+	resource_size_t mapbase;
 };
 
 static struct uartinit uartinit_data[] __initdata = {
@@ -97,6 +98,7 @@ static struct uartinit uartinit_data[] _
 		.ck_mode_mask =
 			LPC32XX_UART_CLKMODE_LOAD(LPC32XX_UART_CLKMODE_ON, 5),
 		.pdiv_clk_reg = LPC32XX_CLKPWR_UART5_CLK_CTRL,
+		.mapbase = LPC32XX_UART5_BASE,
 	},
 #endif
 #ifdef CONFIG_ARCH_LPC32XX_UART3_SELECT
@@ -105,6 +107,7 @@ static struct uartinit uartinit_data[] _
 		.ck_mode_mask =
 			LPC32XX_UART_CLKMODE_LOAD(LPC32XX_UART_CLKMODE_ON, 3),
 		.pdiv_clk_reg = LPC32XX_CLKPWR_UART3_CLK_CTRL,
+		.mapbase = LPC32XX_UART3_BASE,
 	},
 #endif
 #ifdef CONFIG_ARCH_LPC32XX_UART4_SELECT
@@ -113,6 +116,7 @@ static struct uartinit uartinit_data[] _
 		.ck_mode_mask =
 			LPC32XX_UART_CLKMODE_LOAD(LPC32XX_UART_CLKMODE_ON, 4),
 		.pdiv_clk_reg = LPC32XX_CLKPWR_UART4_CLK_CTRL,
+		.mapbase = LPC32XX_UART4_BASE,
 	},
 #endif
 #ifdef CONFIG_ARCH_LPC32XX_UART6_SELECT
@@ -121,6 +125,7 @@ static struct uartinit uartinit_data[] _
 		.ck_mode_mask =
 			LPC32XX_UART_CLKMODE_LOAD(LPC32XX_UART_CLKMODE_ON, 6),
 		.pdiv_clk_reg = LPC32XX_CLKPWR_UART6_CLK_CTRL,
+		.mapbase = LPC32XX_UART6_BASE,
 	},
 #endif
 };
@@ -165,6 +170,19 @@ void __init lpc32xx_serial_init(void)
 
 		/* pre-UART clock divider set to 1 */
 		__raw_writel(0x0101, uartinit_data[i].pdiv_clk_reg);
+
+		/*
+		 * Force a flush of the RX FIFOs to work around a
+		 * HW bug
+		 */
+		puart = uartinit_data[i].mapbase;
+		__raw_writel(0xC1, LPC32XX_UART_IIR_FCR(puart));
+		__raw_writel(0x00, LPC32XX_UART_DLL_FIFO(puart));
+		j = LPC32XX_SUART_FIFO_SIZE;
+		while (j--)
+			tmp = __raw_readl(
+				LPC32XX_UART_DLL_FIFO(puart));
+		__raw_writel(0, LPC32XX_UART_IIR_FCR(puart));
 	}
 
 	/* This needs to be done after all UART clocks are setup */

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

* [PATCH v2 6/6] ARM: LPC32xx: serial.c: Fixed loop limit
  2012-02-25 15:35 [PATCH v2 0/6] ARM: LPC32xx: Patch set with further fixes for LPC32xx Roland Stigge
                   ` (4 preceding siblings ...)
  2012-02-25 15:35 ` [PATCH v2 5/6] ARM: LPC32xx: serial.c: HW bug workaround Roland Stigge
@ 2012-02-25 15:35 ` Roland Stigge
  2012-02-27 19:16 ` [PATCH v2 0/6] ARM: LPC32xx: Patch set with further fixes for LPC32xx Kevin Wells
  6 siblings, 0 replies; 13+ messages in thread
From: Roland Stigge @ 2012-02-25 15:35 UTC (permalink / raw)
  To: linux-arm-kernel

This patch fixes a wrong loop limit on UART init.

Signed-off-by: Roland Stigge <stigge@antcom.de>

---
 arch/arm/mach-lpc32xx/serial.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

--- linux-2.6.orig/arch/arm/mach-lpc32xx/serial.c
+++ linux-2.6/arch/arm/mach-lpc32xx/serial.c
@@ -187,7 +187,7 @@ void __init lpc32xx_serial_init(void)
 
 	/* This needs to be done after all UART clocks are setup */
 	__raw_writel(clkmodes, LPC32XX_UARTCTL_CLKMODE);
-	for (i = 0; i < ARRAY_SIZE(uartinit_data) - 1; i++) {
+	for (i = 0; i < ARRAY_SIZE(uartinit_data); i++) {
 		/* Force a flush of the RX FIFOs to work around a HW bug */
 		puart = serial_std_platform_data[i].mapbase;
 		__raw_writel(0xC1, LPC32XX_UART_IIR_FCR(puart));

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

* [PATCH v2 5/6] ARM: LPC32xx: serial.c: HW bug workaround
  2012-02-25 15:35 ` [PATCH v2 5/6] ARM: LPC32xx: serial.c: HW bug workaround Roland Stigge
@ 2012-02-27 14:14   ` Wolfram Sang
  2012-02-27 15:37     ` Roland Stigge
  0 siblings, 1 reply; 13+ messages in thread
From: Wolfram Sang @ 2012-02-27 14:14 UTC (permalink / raw)
  To: linux-arm-kernel

On Sat, Feb 25, 2012 at 04:35:17PM +0100, Roland Stigge wrote:
> This patch fixes a HW bug by flushing RX FIFOs of the UARTs on init.
> 
> Signed-off-by: Roland Stigge <stigge@antcom.de>

If you have a reference (errata ID or similar) it would be nice to have
it in the comment and description.

-- 
Pengutronix e.K.                           | Wolfram Sang                |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20120227/2da1299c/attachment.sig>

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

* [PATCH v2 5/6] ARM: LPC32xx: serial.c: HW bug workaround
  2012-02-27 14:14   ` Wolfram Sang
@ 2012-02-27 15:37     ` Roland Stigge
  2012-02-27 15:48       ` Wolfram Sang
  2012-02-27 19:02       ` Kevin Wells
  0 siblings, 2 replies; 13+ messages in thread
From: Roland Stigge @ 2012-02-27 15:37 UTC (permalink / raw)
  To: linux-arm-kernel

Hi Kevin,

On 02/27/2012 03:14 PM, Wolfram Sang wrote:
> If you have a reference (errata ID or similar) it would be nice to
> have it in the comment and description.

Can you please help out with this one?

In the LPC32xx errata, there is a note about a similar HS UART issue,
but this one here (Standard UART) must be a different one (or it's a
bug and the fix is actually targeted at HS UART).

I actually just ported this code from lpclinux.com and assumed that
NXP knows best about LPC HW bugs. ;-)

Thanks in advance,

Roland

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

* [PATCH v2 5/6] ARM: LPC32xx: serial.c: HW bug workaround
  2012-02-27 15:37     ` Roland Stigge
@ 2012-02-27 15:48       ` Wolfram Sang
  2012-02-27 19:02       ` Kevin Wells
  1 sibling, 0 replies; 13+ messages in thread
From: Wolfram Sang @ 2012-02-27 15:48 UTC (permalink / raw)
  To: linux-arm-kernel


> I actually just ported this code from lpclinux.com and assumed that
> NXP knows best about LPC HW bugs. ;-)

Okay, if there is no errata ID, then that's also fine. Mentioning that
the fix comes from the official NXP-tree might be worth adding to the
comment, nonetheless. It feels much better if the hardware vendor
somehow confirms a hardware bug (be it just with code as in this case)
IMO.

-- 
Pengutronix e.K.                           | Wolfram Sang                |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20120227/c4c86a0f/attachment.sig>

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

* [PATCH v2 5/6] ARM: LPC32xx: serial.c: HW bug workaround
  2012-02-27 15:37     ` Roland Stigge
  2012-02-27 15:48       ` Wolfram Sang
@ 2012-02-27 19:02       ` Kevin Wells
  2012-02-27 21:59         ` Roland Stigge
  1 sibling, 1 reply; 13+ messages in thread
From: Kevin Wells @ 2012-02-27 19:02 UTC (permalink / raw)
  To: linux-arm-kernel


>> If you have a reference (errata ID or similar) it would be nice to
>> have it in the comment and description.
>
>Can you please help out with this one?
>
>In the LPC32xx errata, there is a note about a similar HS UART issue,
>but this one here (Standard UART) must be a different one (or it's a
>bug and the fix is actually targeted at HS UART).
>
>I actually just ported this code from lpclinux.com and assumed that
>NXP knows best about LPC HW bugs. ;-)

There isn't any errata related to this, but something strange was
happening with the serial ports (only in Linux) if I didn't do this.
I stumbled across a 'bug' comment in the pnx4008 port related to
serial, tried the same fix, and the problem went away, so I
(incorrectly) keyed in the errata wording.

Here's the original comment from the ARM pnx4008 port (serial.c):
  48         /* Send a NULL to fix the UART HW bug */
  49         __raw_writel(0x00, UART5_BASE_VA);
  50         __raw_writel(0x00, UART3_BASE_VA);

The HSUART errata is not related to this.

>Thanks in advance,
>
>Roland

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

* [PATCH v2 0/6] ARM: LPC32xx: Patch set with further fixes for LPC32xx
  2012-02-25 15:35 [PATCH v2 0/6] ARM: LPC32xx: Patch set with further fixes for LPC32xx Roland Stigge
                   ` (5 preceding siblings ...)
  2012-02-25 15:35 ` [PATCH v2 6/6] ARM: LPC32xx: serial.c: Fixed loop limit Roland Stigge
@ 2012-02-27 19:16 ` Kevin Wells
  6 siblings, 0 replies; 13+ messages in thread
From: Kevin Wells @ 2012-02-27 19:16 UTC (permalink / raw)
  To: linux-arm-kernel

>This is another bundle of patches for LPC32xx, fixing bugs and completing
>support for drivers using the LPC32xx base port.
>
>It synchronizes changes from lpclinux.com to the mainline kernel and applies
>cleanly to 3.3-rc4.
>
>Signed-off-by: Roland Stigge <stigge@antcom.de>

Acked-by: Kevin Wells <Kevin.wells@nxp.com>

>---
>
>Roland Stigge (6):
>  ARM: LPC32xx: Fix irq on GPI_28
>  ARM: LPC32xx: Fix missing and bad LPC32XX macros
>  ARM: LPC32xx: Fix interrupt controller init
>  ARM: LPC32xx: irq.c: Clear latched event
>  ARM: LPC32xx: serial.c: HW bug workaround
>  ARM: LPC32xx: serial.c: Fixed loop limit
>
> arch/arm/mach-lpc32xx/include/mach/irqs.h     |    2 -
> arch/arm/mach-lpc32xx/include/mach/platform.h |   51 +++++++++++++-------------
> arch/arm/mach-lpc32xx/irq.c                   |   25 ++++++++++--
> arch/arm/mach-lpc32xx/pm.c                    |    2 -
> arch/arm/mach-lpc32xx/serial.c                |   20 +++++++++-
> arch/arm/mach-lpc32xx/timer.c                 |   46 +++++++++++------------
> 6 files changed, 91 insertions(+), 55 deletions(-)

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

* [PATCH v2 5/6] ARM: LPC32xx: serial.c: HW bug workaround
  2012-02-27 19:02       ` Kevin Wells
@ 2012-02-27 21:59         ` Roland Stigge
  0 siblings, 0 replies; 13+ messages in thread
From: Roland Stigge @ 2012-02-27 21:59 UTC (permalink / raw)
  To: linux-arm-kernel

Hi!

On 27/02/12 20:02, Kevin Wells wrote:
> There isn't any errata related to this, but something strange was
> happening with the serial ports (only in Linux) if I didn't do this.
> I stumbled across a 'bug' comment in the pnx4008 port related to
> serial, tried the same fix, and the problem went away, so I
> (incorrectly) keyed in the errata wording.
> 
> Here's the original comment from the ARM pnx4008 port (serial.c):
>   48         /* Send a NULL to fix the UART HW bug */
>   49         __raw_writel(0x00, UART5_BASE_VA);
>   50         __raw_writel(0x00, UART3_BASE_VA);

Hard to trace since pnx4008's serial.c contains it since the beginning
in 2006.

OTOH, you added a bit more than this to lpc32xx' serial.c.

Anyway, I guess that PNX4008's and LPC3200's standard UARTs share some
ideas, NXP internally. ;-)

Roland

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

end of thread, other threads:[~2012-02-27 21:59 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-02-25 15:35 [PATCH v2 0/6] ARM: LPC32xx: Patch set with further fixes for LPC32xx Roland Stigge
2012-02-25 15:35 ` [PATCH v2 1/6] ARM: LPC32xx: Fix irq on GPI_28 Roland Stigge
2012-02-25 15:35 ` [PATCH v2 2/6] ARM: LPC32xx: Fix missing and bad LPC32XX macros Roland Stigge
2012-02-25 15:35 ` [PATCH v2 3/6] ARM: LPC32xx: Fix interrupt controller init Roland Stigge
2012-02-25 15:35 ` [PATCH v2 4/6] ARM: LPC32xx: irq.c: Clear latched event Roland Stigge
2012-02-25 15:35 ` [PATCH v2 5/6] ARM: LPC32xx: serial.c: HW bug workaround Roland Stigge
2012-02-27 14:14   ` Wolfram Sang
2012-02-27 15:37     ` Roland Stigge
2012-02-27 15:48       ` Wolfram Sang
2012-02-27 19:02       ` Kevin Wells
2012-02-27 21:59         ` Roland Stigge
2012-02-25 15:35 ` [PATCH v2 6/6] ARM: LPC32xx: serial.c: Fixed loop limit Roland Stigge
2012-02-27 19:16 ` [PATCH v2 0/6] ARM: LPC32xx: Patch set with further fixes for LPC32xx Kevin Wells

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.