Skip to contentSkip to conversation

OMAP3630: UART4 startup (+ new bugfix!)

RFC PATCH New Sergio Aguirre 1 participant 7 messages Feb 27, 2010

Subsystems (5)
lore
Share & tools
lore
#0 lore raw

v3 cover OMAP3630: UART4 startup (+ new bugfix!)

Hi,

This is the v3 of the RFC for UART4 addition for 3630 chips.

Changes with respect to v2 [1]:
- Merged patches for control bits.
- Fix umproper check during globals setting. cpu_is_omap3630 was invalid at that point. (now 3630 boards are bootable gain!)
- Fix hardcode to use PER domain on UART3 only.

Indirect dependencies:
- Tested with Thomas Weber's patch [2].

Thanks for Paul Walmsley and Tony Lindgreen for their initial comments.

Detailed patchlist summary:

Sergio Aguirre (6):
OMAP3: serial: Check for zero-based physical addr omap2/3/4: serial: Remove condition for getting uart4_phys
ARM: OMAP3630: PRCM: Add UART4 control bits
OMAP clock: Add uart4_ick/fck definitions for 3630
OMAP3: PRCM: Consider UART4 for 3630 chip in prcm_setup_regs
omap3: serial: Fix uart4 handling for 3630

 arch/arm/mach-omap2/clock3xxx_data.c  |   22 +++++++++++++++++++++
 arch/arm/mach-omap2/cm-regbits-34xx.h |    2 +
 arch/arm/mach-omap2/pm34xx.c          |    8 +++++-
 arch/arm/mach-omap2/prcm-common.h     |    4 +++
 arch/arm/mach-omap2/serial.c          |   34 +++++++++++++++++++-------------
 5 files changed, 54 insertions(+), 16 deletions(-)

[1] http://marc.info/?l=linux-omap&m=126719959007695&w=2
[2] http://marc.info/?l=linux-kernel&m=126709078514087&w=2

#1 lore raw

RFC PATCH v3 1/6 OMAP3: serial: Check for zero-based physical addr

This is for protecting a wrong mapping attempt of a zero-based physical address.

The result is that, no serial port will be attempted to be mapped.

Also add an additional protection for NULL clocks before attempting to enable them (if above condition applies)

---
 arch/arm/mach-omap2/serial.c |   10 ++++++++++
 1 files changed, 10 insertions(+), 0 deletions(-)
arch/arm/mach-omap2/serial.c +10 -0
index b79bc89..128bfae 100644
@@ -659,6 +659,12 @@ void __init omap_serial_early_init(void)
 		struct device *dev = &pdev->dev;
 		struct plat_serial8250_port *p = dev->platform_data;
 
+		/* Don't map zero-based physical address */
+		if (p->mapbase == 0) {
+			printk(KERN_WARNING "omap serial: No physical address"
+			       " for uart#%d, so skipping early_init...\n", i);
+			continue;
+		}
 		/*
 		 * Module 4KB + L4 interconnect 4KB
 		 * Static mapping, never released
@@ -722,6 +728,10 @@ void __init omap_serial_init_port(int port)
 	pdev = &uart->pdev;
 	dev = &pdev->dev;
 
+	/* Don't proceed if there's no clocks available */
+	if (!uart->ick || !uart->fck)
+		return;
+
 	omap_uart_enable_clocks(uart);
 
 	omap_uart_reset(uart);
Signature · 1 line
1.6.3.3
#2 lore raw

RFC PATCH v3 2/6 omap2/3/4: serial: Remove condition for getting uart4_phys

In reply to Sergio Aguirre

This check is invalid, since we haven't filled the omap_revision var at this point.

---
 arch/arm/mach-omap2/serial.c |   14 +-------------
 1 files changed, 1 insertions(+), 13 deletions(-)
arch/arm/mach-omap2/serial.c +1 -13
index 128bfae..605422e 100644
@@ -115,7 +115,6 @@ static struct plat_serial8250_port serial_platform_data2[] = {
 	}
 };
 
-#if defined(CONFIG_ARCH_OMAP3) || defined(CONFIG_ARCH_OMAP4)
 static struct plat_serial8250_port serial_platform_data3[] = {
 	{
 		.irq		= 70,
@@ -128,23 +127,12 @@ static struct plat_serial8250_port serial_platform_data3[] = {
 	}
 };
 
-static inline void omap2_set_globals_uart4(struct omap_globals *omap2_globals)
-{
-	serial_platform_data3[0].mapbase = omap2_globals->uart4_phys;
-}
-#else
-static inline void omap2_set_globals_uart4(struct omap_globals *omap2_globals)
-{
-}
-#endif
-
 void __init omap2_set_globals_uart(struct omap_globals *omap2_globals)
 {
 	serial_platform_data0[0].mapbase = omap2_globals->uart1_phys;
 	serial_platform_data1[0].mapbase = omap2_globals->uart2_phys;
 	serial_platform_data2[0].mapbase = omap2_globals->uart3_phys;
-	if (cpu_is_omap3630() || cpu_is_omap44xx())
-		omap2_set_globals_uart4(omap2_globals);
+	serial_platform_data3[0].mapbase = omap2_globals->uart4_phys;
 }
 
 static inline unsigned int __serial_read_reg(struct uart_port *up,
Signature · 1 line
1.6.3.3
#3 lore raw

RFC PATCH v3 3/6 ARM: OMAP3630: PRCM: Add UART4 control bits

In reply to Sergio Aguirre

This bits are exclusive of omap 36xx family of chips.

---
 arch/arm/mach-omap2/cm-regbits-34xx.h |    2 ++
 arch/arm/mach-omap2/prcm-common.h     |    4 ++++
 2 files changed, 6 insertions(+), 0 deletions(-)
arch/arm/mach-omap2/cm-regbits-34xx.h +2 -0
index a3a3ca0..834b671 100644
@@ -649,6 +649,8 @@
 #define OMAP3430_ST_MCBSP2_MASK				(1 << 0)
 
 /* CM_AUTOIDLE_PER */
+#define OMAP3630_AUTO_UART4				(1 << 18)
+#define OMAP3630_AUTO_UART4_SHIFT			18
 #define OMAP3430_AUTO_GPIO6				(1 << 17)
 #define OMAP3430_AUTO_GPIO6_SHIFT			17
 #define OMAP3430_AUTO_GPIO5				(1 << 16)
arch/arm/mach-omap2/prcm-common.h +4 -0
index 90f603d..c4e7bcb 100644
@@ -390,6 +390,8 @@
 #define OMAP3430_EN_MPU_SHIFT				1
 
 /* CM_FCLKEN_PER, CM_ICLKEN_PER, PM_WKEN_PER shared bits */
+#define OMAP3630_EN_UART4				(1 << 18)
+#define OMAP3630_EN_UART4_SHIFT				18
 #define OMAP3430_EN_GPIO6				(1 << 17)
 #define OMAP3430_EN_GPIO6_SHIFT				17
 #define OMAP3430_EN_GPIO5				(1 << 16)
@@ -430,6 +432,8 @@
 #define OMAP3430_EN_MCBSP2_SHIFT			0
 
 /* CM_IDLEST_PER, PM_WKST_PER shared bits */
+#define OMAP3630_ST_UART4_SHIFT				18
+#define OMAP3630_ST_UART4_MASK				(1 << 18)
 #define OMAP3430_ST_GPIO6_SHIFT				17
 #define OMAP3430_ST_GPIO6_MASK				(1 << 17)
 #define OMAP3430_ST_GPIO5_SHIFT				16
Signature · 1 line
1.6.3.3
#4 lore raw

RFC PATCH v3 4/6 OMAP clock: Add uart4_ick/fck definitions for 3630

In reply to Sergio Aguirre

This is only valid for omap 36xx family of chips.

---
 arch/arm/mach-omap2/clock3xxx_data.c |   22 ++++++++++++++++++++++
 1 files changed, 22 insertions(+), 0 deletions(-)
arch/arm/mach-omap2/clock3xxx_data.c +22 -0
index d5153b6..e8afaa6 100644
@@ -2541,6 +2541,16 @@ static struct clk uart3_fck = {
 	.recalc		= &followparent_recalc,
 };
 
+static struct clk uart4_fck = {
+	.name		= "uart4_fck",
+	.ops		= &clkops_omap2_dflt_wait,
+	.parent		= &per_48m_fck,
+	.enable_reg	= OMAP_CM_REGADDR(OMAP3430_PER_MOD, CM_FCLKEN),
+	.enable_bit	= OMAP3630_EN_UART4_SHIFT,
+	.clkdm_name	= "per_clkdm",
+	.recalc		= &followparent_recalc,
+};
+
 static struct clk gpt2_fck = {
 	.name		= "gpt2_fck",
 	.ops		= &clkops_omap2_dflt_wait,
@@ -2791,6 +2801,16 @@ static struct clk uart3_ick = {
 	.recalc		= &followparent_recalc,
 };
 
+static struct clk uart4_ick = {
+	.name		= "uart4_ick",
+	.ops		= &clkops_omap2_dflt_wait,
+	.parent		= &per_l4_ick,
+	.enable_reg	= OMAP_CM_REGADDR(OMAP3430_PER_MOD, CM_ICLKEN),
+	.enable_bit	= OMAP3630_EN_UART4_SHIFT,
+	.clkdm_name	= "per_clkdm",
+	.recalc		= &followparent_recalc,
+};
+
 static struct clk gpt9_ick = {
 	.name		= "gpt9_ick",
 	.ops		= &clkops_omap2_dflt_wait,
@@ -3420,6 +3440,7 @@ static struct omap_clk omap3xxx_clks[] = {
 	CLK(NULL,	"per_96m_fck",	&per_96m_fck,	CK_3XXX),
 	CLK(NULL,	"per_48m_fck",	&per_48m_fck,	CK_3XXX),
 	CLK(NULL,	"uart3_fck",	&uart3_fck,	CK_3XXX),
+	CLK(NULL,	"uart4_fck",	&uart4_fck,	CK_36XX),
 	CLK(NULL,	"gpt2_fck",	&gpt2_fck,	CK_3XXX),
 	CLK(NULL,	"gpt3_fck",	&gpt3_fck,	CK_3XXX),
 	CLK(NULL,	"gpt4_fck",	&gpt4_fck,	CK_3XXX),
@@ -3443,6 +3464,7 @@ static struct omap_clk omap3xxx_clks[] = {
 	CLK(NULL,	"gpio2_ick",	&gpio2_ick,	CK_3XXX),
 	CLK(NULL,	"wdt3_ick",	&wdt3_ick,	CK_3XXX),
 	CLK(NULL,	"uart3_ick",	&uart3_ick,	CK_3XXX),
+	CLK(NULL,	"uart4_ick",	&uart4_ick,	CK_36XX),
 	CLK(NULL,	"gpt9_ick",	&gpt9_ick,	CK_3XXX),
 	CLK(NULL,	"gpt8_ick",	&gpt8_ick,	CK_3XXX),
 	CLK(NULL,	"gpt7_ick",	&gpt7_ick,	CK_3XXX),
Signature · 1 line
1.6.3.3
#5 lore raw

RFC PATCH v3 5/6 OMAP3: PRCM: Consider UART4 for 3630 chip in prcm_setup_regs

In reply to Sergio Aguirre
---
 arch/arm/mach-omap2/pm34xx.c |    8 ++++++--
 1 files changed, 6 insertions(+), 2 deletions(-)
arch/arm/mach-omap2/pm34xx.c +6 -2
index fee2efb..81082f2 100644
@@ -734,6 +734,9 @@ static void __init omap3_d2d_idle(void)
 
 static void __init prcm_setup_regs(void)
 {
+	u32 omap3630_auto_uart4 = cpu_is_omap3630() ? OMAP3630_AUTO_UART4 : 0;
+	u32 omap3630_en_uart4 = cpu_is_omap3630() ? OMAP3630_EN_UART4 : 0;
+
 	/* XXX Reset all wkdeps. This should be done when initializing
 	 * powerdomains */
 	prm_write_mod_reg(0, OMAP3430_IVA2_MOD, PM_WKDEP);
@@ -820,6 +823,7 @@ static void __init prcm_setup_regs(void)
 		CM_AUTOIDLE);
 
 	cm_write_mod_reg(
+		omap3630_auto_uart4 |
 		OMAP3430_AUTO_GPIO6 |
 		OMAP3430_AUTO_GPIO5 |
 		OMAP3430_AUTO_GPIO4 |
@@ -899,14 +903,14 @@ static void __init prcm_setup_regs(void)
 			  OMAP3430_EN_GPIO4 | OMAP3430_EN_GPIO5 |
 			  OMAP3430_EN_GPIO6 | OMAP3430_EN_UART3 |
 			  OMAP3430_EN_MCBSP2 | OMAP3430_EN_MCBSP3 |
-			  OMAP3430_EN_MCBSP4,
+			  OMAP3430_EN_MCBSP4 | omap3630_en_uart4,
 			  OMAP3430_PER_MOD, PM_WKEN);
 	/* and allow them to wake up MPU */
 	prm_write_mod_reg(OMAP3430_GRPSEL_GPIO2 | OMAP3430_EN_GPIO3 |
 			  OMAP3430_GRPSEL_GPIO4 | OMAP3430_EN_GPIO5 |
 			  OMAP3430_GRPSEL_GPIO6 | OMAP3430_EN_UART3 |
 			  OMAP3430_EN_MCBSP2 | OMAP3430_EN_MCBSP3 |
-			  OMAP3430_EN_MCBSP4,
+			  OMAP3430_EN_MCBSP4 | omap3630_en_uart4,
 			  OMAP3430_PER_MOD, OMAP3430_PM_MPUGRPSEL);
 
 	/* Don't attach IVA interrupts */
Signature · 1 line
1.6.3.3
#6 lore raw

RFC PATCH v3 6/6 omap3: serial: Fix uart4 handling for 3630

In reply to Sergio Aguirre

This patch makes the following:
- Adds missing wakeup padding register handling.
- Fixes a hardcode to use PER module ONLY on UART3.
- Corrects IRQ number to 80 for 3630 case.

---
 arch/arm/mach-omap2/serial.c |   10 +++++++++-
 1 files changed, 9 insertions(+), 1 deletions(-)
arch/arm/mach-omap2/serial.c +9 -1
index 605422e..d7cea8a 100644
@@ -444,7 +444,7 @@ static void omap_uart_idle_init(struct omap_uart_state *uart)
 	omap_uart_smart_idle_enable(uart, 0);
 
 	if (cpu_is_omap34xx()) {
-		u32 mod = (uart->num == 2) ? OMAP3430_PER_MOD : CORE_MOD;
+		u32 mod = (uart->num > 1) ? OMAP3430_PER_MOD : CORE_MOD;
 		u32 wk_mask = 0;
 		u32 padconf = 0;
 
@@ -463,6 +463,10 @@ static void omap_uart_idle_init(struct omap_uart_state *uart)
 			wk_mask = OMAP3430_ST_UART3_MASK;
 			padconf = 0x19e;
 			break;
+		case 3:
+			wk_mask = OMAP3630_ST_UART4_MASK;
+			padconf = 0x0d2;
+			break;
 		}
 		uart->wk_mask = wk_mask;
 		uart->padconf = padconf;
@@ -689,6 +693,10 @@ void __init omap_serial_early_init(void)
 
 		if (cpu_is_omap44xx())
 			p->irq += 32;
+
+		/* IRQ for UART4 in omap3630 is 80 */
+		if (cpu_is_omap3630() && (i == 3))
+			p->irq = 80;
 	}
 }
 
Signature · 1 line
1.6.3.3