Skip to contentSkip to conversation

snowball: Add support for ux500 based snowball board

PATCH Superseded mathieu.poirier at linaro.org 1 participant 4 messages Jun 19, 2012

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

PATCH v2 1/11 snowball: Add support for ux500 based snowball board

From: "Mathieu J. Poirier" <[email protected]>

---
Changes for v2:
- White space cleanup.
- Cleaned #defines.
- Removal of unnecessary defines.

---
 arch/arm/include/asm/arch-u8500/db8500_gpio.h   |   42 ++
 arch/arm/include/asm/arch-u8500/db8500_pincfg.h |  172 ++++++
 board/st-ericsson/snowball/Makefile             |   51 ++
 board/st-ericsson/snowball/db8500_pins.h        |  745 +++++++++++++++++++++++
 board/st-ericsson/snowball/snowball.c           |  185 ++++++
 boards.cfg                                      |    1 +
 drivers/gpio/Makefile                           |    1 +
 drivers/gpio/db8500_gpio.c                      |  225 +++++++
 drivers/serial/serial_pl01x.c                   |    2 +
 include/configs/snowball.h                      |  258 ++++++++
 10 files changed, 1682 insertions(+), 0 deletions(-)
 create mode 100644 arch/arm/include/asm/arch-u8500/db8500_gpio.h
 create mode 100644 arch/arm/include/asm/arch-u8500/db8500_pincfg.h
 create mode 100644 board/st-ericsson/snowball/Makefile
 create mode 100644 board/st-ericsson/snowball/db8500_pins.h
 create mode 100644 board/st-ericsson/snowball/snowball.c
 create mode 100644 drivers/gpio/db8500_gpio.c
 create mode 100644 include/configs/snowball.h
arch/arm/include/asm/arch-u8500/db8500_gpio.h new file +42 -0
new file mode 100644
index 0000000..7c85a89
@@ -0,0 +1,42 @@
+/*
+ * Structures and registers for GPIO access in the Nomadik SoC
+ *
+ * Code ported from Nomadik GPIO driver in ST-Ericsson Linux kernel code.
+ * The purpose is that GPIO config found in kernel should work by simply
+ * copy-paste it to U-boot.
+ *
+ * Ported to U-boot by:
+ * Copyright (C) 2010 Joakim Axelsson <joakim.axelsson AT stericsson.com>
+ * Copyright (C) 2008 STMicroelectronics
+ *     Author: Prafulla WADASKAR <[email protected]>
+ * Copyright (C) 2009 Alessandro Rubini <[email protected]>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#ifndef __DB8500_GPIO_H__
+#define __DB8500_GPIO_H__
+
+/* Alternate functions: function C is set in hw by setting both A and B */
+enum db8500_gpio_alt {
+	DB8500_GPIO_ALT_GPIO = 0,
+	DB8500_GPIO_ALT_A = 1,
+	DB8500_GPIO_ALT_B = 2,
+	DB8500_GPIO_ALT_C = (DB8500_GPIO_ALT_A | DB8500_GPIO_ALT_B)
+};
+
+enum db8500_gpio_pull {
+	DB8500_GPIO_PULL_NONE,
+	DB8500_GPIO_PULL_UP,
+	DB8500_GPIO_PULL_DOWN
+};
+
+void db8500_gpio_set_pull(unsigned gpio, enum db8500_gpio_pull pull);
+void db8500_gpio_make_input(unsigned gpio);
+int db8500_gpio_get_input(unsigned gpio);
+void db8500_gpio_make_output(unsigned gpio, int val);
+void db8500_gpio_set_output(unsigned gpio, int val);
+
+#endif /* __DB8500_GPIO_H__ */
arch/arm/include/asm/arch-u8500/db8500_pincfg.h new file +172 -0

172 lines not on this page · raw message

board/st-ericsson/snowball/Makefile new file +51 -0

51 lines not on this page · raw message

board/st-ericsson/snowball/db8500_pins.h new file +745 -0

745 lines not on this page · raw message

board/st-ericsson/snowball/snowball.c new file +185 -0

185 lines not on this page · raw message

boards.cfg +1 -0
index 9ef903a..db5cb0a 100644
@@ -232,6 +232,7 @@ harmony                      arm         armv7       harmony             nvidia
 seaboard                     arm         armv7       seaboard            nvidia         tegra2
 ventana                      arm         armv7       ventana             nvidia         tegra2
 u8500_href                   arm         armv7       u8500               st-ericsson    u8500
+snowball		     arm	 armv7	     snowball		 st-ericsson	u8500
 actux1_4_16                  arm         ixp         actux1              -              -           actux1:FLASH2X2
 actux1_4_32                  arm         ixp         actux1              -              -           actux1:FLASH2X2,RAM_32MB
 actux1_8_16                  arm         ixp         actux1              -              -           actux1:FLASH1X8
drivers/gpio/Makefile +1 -0
index fb3b09a..36a0ff3 100644
@@ -39,6 +39,7 @@ COBJS-$(CONFIG_TEGRA2_GPIO)	+= tegra2_gpio.o
 COBJS-$(CONFIG_DA8XX_GPIO)	+= da8xx_gpio.o
 COBJS-$(CONFIG_ALTERA_PIO)	+= altera_pio.o
 COBJS-$(CONFIG_MPC83XX_GPIO)	+= mpc83xx_gpio.o
+COBJS-$(CONFIG_DB8500_GPIO)	+= db8500_gpio.o
 
 COBJS	:= $(COBJS-y)
 SRCS 	:= $(COBJS:.o=.c)
drivers/gpio/db8500_gpio.c new file +225 -0

225 lines not on this page · raw message

drivers/serial/serial_pl01x.c +2 -0
index ed581ae..d4c5137 100644
@@ -156,6 +156,8 @@ int serial_init (void)
 			writel(lcr, &regs->fr);
 
 		writel(lcr, &regs->pl011_rlcr);
+		/* lcrh needs to be set again for change to be effective */
+		writel(lcr, &regs->pl011_lcrh);
 	}
 #endif
 	/* Finally, enable the UART */
include/configs/snowball.h new file +258 -0

258 lines not on this page · raw message

Signature · 1 line
1.7.5.4
#1 lore raw

PATCH v2 3/11 snowball: Adding architecture dependent initialisation

From: "Mathieu J. Poirier" <[email protected]>

Enabling timers and clocks in PRCMU and cleaning up mailbox.

---
Changes for v2:
- Cleaned #defines in snowball.h

---
 arch/arm/cpu/armv7/u8500/Makefile       |    2 +-
 arch/arm/cpu/armv7/u8500/cpu.c          |   41 +++++++++++++++++++++++++++++++
 arch/arm/cpu/armv7/u8500/prcmu.c        |   30 ++++++++++++++++++++++
 arch/arm/include/asm/arch-u8500/prcmu.h |   24 ++++++++++++++----
 board/st-ericsson/u8500/u8500_href.c    |    2 +-
 include/configs/snowball.h              |    1 +
 6 files changed, 93 insertions(+), 7 deletions(-)
 create mode 100644 arch/arm/cpu/armv7/u8500/cpu.c
arch/arm/cpu/armv7/u8500/Makefile +1 -1
index 77accde..ce8af96 100644
@@ -25,7 +25,7 @@ include $(TOPDIR)/config.mk
 
 LIB	= $(obj)lib$(SOC).o
 
-COBJS	= timer.o clock.o prcmu.o
+COBJS	= timer.o clock.o prcmu.o cpu.o
 SOBJS	= lowlevel.o
 
 SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
arch/arm/cpu/armv7/u8500/cpu.c new file +41 -0

41 lines not on this page · raw message

arch/arm/cpu/armv7/u8500/prcmu.c +30 -0
index 119ead3..6187dcc 100644
@@ -40,6 +40,8 @@
 #define PRCM_MBOX_CPU_SET (U8500_PRCMU_BASE + 0x100)
 #define PRCM_MBOX_CPU_CLR (U8500_PRCMU_BASE + 0x104)
 
+#define I2C_MBOX_BIT    (1 << 5)
+
 static int prcmu_is_ready(void)
 {
 	int ready = readb(PRCM_XP70_CUR_PWR_STATE) == AP_EXECUTE;
@@ -162,3 +164,31 @@ int prcmu_i2c_write(u8 reg, u16 slave, u8 reg_data)
 		return -1;
 	}
 }
+
+void u8500_prcmu_enable(u32 *reg)
+{
+	writel(readl(reg) | (1 << 8), reg);
+}
+
+void db8500_prcmu_init(void)
+{
+	/* Enable timers */
+	writel(1 << 17, PRCM_TCR);
+
+	u8500_prcmu_enable((u32 *)PRCM_PER1CLK_MGT_REG);
+	u8500_prcmu_enable((u32 *)PRCM_PER2CLK_MGT_REG);
+	u8500_prcmu_enable((u32 *)PRCM_PER3CLK_MGT_REG);
+	/* PER4CLK does not exist */
+	u8500_prcmu_enable((u32 *)PRCM_PER5CLK_MGT_REG);
+	u8500_prcmu_enable((u32 *)PRCM_PER6CLK_MGT_REG);
+	/* Only exists in ED but is always ok to write to */
+	u8500_prcmu_enable((u32 *)PRCM_PER7CLK_MGT_REG);
+
+	u8500_prcmu_enable((u32 *)PRCM_UARTCLK_MGT_REG);
+	u8500_prcmu_enable((u32 *)PRCM_I2CCLK_MGT_REG);
+
+	u8500_prcmu_enable((u32 *)PRCM_SDMMCCLK_MGT_REG);
+
+	/* Clean up the mailbox interrupts after pre-u-boot code. */
+	writel(I2C_MBOX_BIT, PRCM_ARM_IT1_CLEAR);
+}
arch/arm/include/asm/arch-u8500/prcmu.h +19 -5
index 0836983..1fd4d2a 100644
@@ -27,12 +27,23 @@
 #define I2C_RD_OK	2
 #define I2CWRITE	0
 
-#define _PRCMU_TCDM_BASE    U8500_PRCMU_TCDM_BASE
-#define PRCM_XP70_CUR_PWR_STATE (_PRCMU_TCDM_BASE + 0xFFC)      /* 4 BYTES */
-
-#define PRCM_REQ_MB5        (_PRCMU_TCDM_BASE + 0xE44)    /* 4 bytes  */
-#define PRCM_ACK_MB5        (_PRCMU_TCDM_BASE + 0xDF4)    /* 4 bytes */
+#define PRCMU_BASE			U8500_PRCMU_BASE
+#define PRCM_UARTCLK_MGT_REG		(PRCMU_BASE + 0x018)
+#define PRCM_MSPCLK_MGT_REG		(PRCMU_BASE + 0x01C)
+#define PRCM_I2CCLK_MGT_REG		(PRCMU_BASE + 0x020)
+#define PRCM_SDMMCCLK_MGT_REG		(PRCMU_BASE + 0x024)
+#define PRCM_PER1CLK_MGT_REG		(PRCMU_BASE + 0x02C)
+#define PRCM_PER2CLK_MGT_REG		(PRCMU_BASE + 0x030)
+#define PRCM_PER3CLK_MGT_REG		(PRCMU_BASE + 0x034)
+#define PRCM_PER5CLK_MGT_REG		(PRCMU_BASE + 0x038)
+#define PRCM_PER6CLK_MGT_REG		(PRCMU_BASE + 0x03C)
+#define PRCM_PER7CLK_MGT_REG		(PRCMU_BASE + 0x040)
 
+#define PRCM_ARM_IT1_CLEAR		(PRCMU_BASE + 0x48C)
+#define PRCM_TCR			(PRCMU_BASE + 0x1C8)
+#define PRCM_REQ_MB5			(PRCMU_BASE + 0xE44)
+#define PRCM_ACK_MB5			(PRCMU_BASE + 0xDF4)
+#define PRCM_XP70_CUR_PWR_STATE		(PRCMU_BASE + 0xFFC)
 /* Mailbox 5 Requests */
 #define PRCM_REQ_MB5_I2COPTYPE_REG	(PRCM_REQ_MB5 + 0x0)
 #define PRCM_REQ_MB5_BIT_FIELDS		(PRCM_REQ_MB5 + 0x1)
@@ -52,4 +63,7 @@
 extern int prcmu_i2c_read(u8 reg, u16 slave);
 extern int prcmu_i2c_write(u8 reg, u16 slave, u8 reg_data);
 
+void u8500_prcmu_enable(u32 *reg);
+void db8500_prcmu_init(void);
+
 #endif /* __MACH_PRCMU_FW_V1_H */
board/st-ericsson/u8500/u8500_href.c +1 -1
index 6e3fc87..fe72684 100644
@@ -26,8 +26,8 @@
 #include <asm/arch/gpio.h>
 #include <asm/arch/hardware.h>
 #include <asm/arch/sys_proto.h>
-#ifdef CONFIG_MMC
 #include <asm/arch/prcmu.h>
+#ifdef CONFIG_MMC
 #include "../../../drivers/mmc/arm_pl180_mmci.h"
 #endif
 
include/configs/snowball.h +1 -0
index 148d6ee..15cb78b 100644
@@ -31,6 +31,7 @@
 #define CONFIG_SNOWBALL
 #define CONFIG_SYS_ICACHE_OFF
 #define CONFIG_SYS_DCACHE_OFF
+#define CONFIG_ARCH_CPU_INIT
 
 /*
  * High Level Configuration Options
Signature · 1 line
1.7.5.4
#2 lore raw

PATCH v2 6/11 snowball: applying power to LAN and GBF controllers

In reply to mathieu.poirier at linaro.org

From: "Mathieu J. Poirier" <[email protected]>

LAN and GBF need to be powered explicitely, doing so with interface to AB8500 companion chip.

---
Changes for v2:
- Cleaned #defines in snowball.h

---
 arch/arm/include/asm/arch-u8500/hardware.h |   11 +++-
 arch/arm/include/asm/arch-u8500/prcmu.h    |    7 ++-
 board/st-ericsson/snowball/snowball.c      |   87 ++++++++++++++++++++++++++++
 include/configs/snowball.h                 |    1 +
 4 files changed, 103 insertions(+), 3 deletions(-)
arch/arm/include/asm/arch-u8500/hardware.h +10 -1
index 9208880..8044ac3 100644
@@ -62,7 +62,7 @@
 
 /* Per4 */
 #define U8500_PRCMU_BASE	(U8500_PER4_BASE + 0x07000)
-#define U8500_PRCMU_TCDM_BASE   (U8500_PER4_BASE + 0x06800)
+#define U8500_PRCMU_TCDM_BASE   (U8500_PER4_BASE + 0x68000)
 
 /* Per3 */
 #define U8500_UART2_BASE	(U8500_PER3_BASE + 0x7000)
@@ -80,4 +80,13 @@
 #define U8500_BOOTROM_BASE      0x9001f000
 #define U8500_BOOTROM_ASIC_ID_OFFSET    0x0ff4
 
+/* AB8500 specifics */
+#define AB8500_MISC		0x0010
+#define AB8500_GPIO_SEL2_REG	0x1001
+#define AB8500_GPIO_DIR2_REG	0x1011
+#define AB8500_GPIO_DIR4_REG	0x1013
+#define AB8500_GPIO_SEL4_REG	0x1003
+#define AB8500_GPIO_OUT2_REG	0x1021
+#define AB8500_GPIO_OUT4_REG	0x1023
+
 #endif /* __ASM_ARCH_HARDWARE_H */
arch/arm/include/asm/arch-u8500/prcmu.h +5 -2
index 9862eb3..e9dcc93 100644
@@ -64,8 +64,11 @@
 
 #define REQ_MB5			5
 
-extern int prcmu_i2c_read(u8 reg, u16 slave);
-extern int prcmu_i2c_write(u8 reg, u16 slave, u8 reg_data);
+#define ab8500_read	prcmu_i2c_read
+#define ab8500_write	prcmu_i2c_write
+
+int prcmu_i2c_read(u8 reg, u16 slave);
+int prcmu_i2c_write(u8 reg, u16 slave, u8 reg_data);
 
 void u8500_prcmu_enable(u32 *reg);
 void db8500_prcmu_init(void);
board/st-ericsson/snowball/snowball.c +87 -0

96 lines not on this page · raw message

include/configs/snowball.h +1 -0
index 15cb78b..a818b48 100644
@@ -32,6 +32,7 @@
 #define CONFIG_SYS_ICACHE_OFF
 #define CONFIG_SYS_DCACHE_OFF
 #define CONFIG_ARCH_CPU_INIT
+#define CONFIG_BOARD_LATE_INIT
 
 /*
  * High Level Configuration Options
Signature · 1 line
1.7.5.4
#3 lore raw

PATCH v2 10/11 armv7: Adding cpu specific cache managmenent

In reply to mathieu.poirier at linaro.org

From: "Mathieu J. Poirier" <[email protected]>

Some CPU (i.e u8500) need more cache management before launching the Linux kernel.

---
Changes for v2:
- Moved from __attribute__(...) to __weak.

---
 arch/arm/cpu/armv7/cpu.c |    8 ++++++++
 1 files changed, 8 insertions(+), 0 deletions(-)
arch/arm/cpu/armv7/cpu.c +8 -0
index c6fa8ef..cc46328 100644
@@ -36,6 +36,7 @@
 #include <asm/system.h>
 #include <asm/cache.h>
 #include <asm/armv7.h>
+#include <linux/compiler.h>
 
 void save_boot_params_default(u32 r0, u32 r1, u32 r2, u32 r3)
 {
@@ -44,6 +45,8 @@ void save_boot_params_default(u32 r0, u32 r1, u32 r2, u32 r3)
 void save_boot_params(u32 r0, u32 r1, u32 r2, u32 r3)
 	__attribute__((weak, alias("save_boot_params_default")));
 
+void __weak cpu_cache_management(void){}
+
 int cleanup_before_linux(void)
 {
 	/*
@@ -81,5 +84,10 @@ int cleanup_before_linux(void)
 	 */
 	invalidate_dcache_all();
 
+	/*
+	 * Some CPU need more cache attention before starting the kernel.
+	 */
+	cpu_cache_management();
+
 	return 0;
 }
Signature · 1 line
1.7.5.4