Skip to contentSkip to conversation

arm: socfpga: Add initial support for Altera's SOCFPGA HW

RFC PATCH Superseded dinguyen at altera.com 4 participants 5 messages Jul 18, 2012 – Oct 15, 2012

Subsystems (6)

v4 of 5 Superseded Latest is v5 →

lore
Share & tools
lore
#0 lore raw

v4 cover arm: socfpga: Add initial support for Altera's SOCFPGA HW

From: Dinh Nguyen <[email protected]>

This patch add minimal support for Altera's SOCFPGA hardward.

Changes since v3:
- Condensed to 1 patch per Pavel Machek
- Added only root clocks(fixed-rate) definitions in drivers/clk/socfpga
- Update dtsi file per Thomas Petazzoni's recommendation
- Add extern sys_timer dw_apb_timer declaration in include/linux/dw_apb_timer.h

Changes since v2:
- Make use of COMMON_CLK - socfpga folder under drivers/clk
- Add maintainer entry for drivrs/clk/socfpga
- Incorporated changes suggestd by Thomas Petazzoni, Arnd Bergmann, and Rob Herring
- Added Reviewed-by: Rob Herring <[email protected]>

Changes since v1:
- Incorporate changes suggested by Pavel Machek, Thommas Petazzoni, Arnd Bergmann, and Rob Herring
- Reduce the patch to a make as much use of DTS as possible

Dinh Nguyen (1):
ARM: socfpga: initial support for Altera's SOCFPGA platform

Signature · 1 line
1.7.9.5
#1 lore raw

RFC PATCH v4 1/1 ARM: socfpga: initial support for Altera's SOCFPGA platform

From: Dinh Nguyen <[email protected]>

Adding core definitions for Altera's SOCFPGA ARM platform. Mininum support for Altera's SOCFPGA Cyclone 5 hardware.

---
 MAINTAINERS                                      |   10 ++
 arch/arm/Kconfig                                 |   19 +++
 arch/arm/Makefile                                |    1 +
 arch/arm/boot/dts/socfpga.dtsi                   |  147 ++++++++++++++++++++++
 arch/arm/boot/dts/socfpga_cyclone5.dts           |   34 +++++
 arch/arm/configs/socfpga_defconfig               |   83 ++++++++++++
 arch/arm/mach-socfpga/Makefile                   |    5 +
 arch/arm/mach-socfpga/Makefile.boot              |    1 +
 arch/arm/mach-socfpga/common.h                   |   23 ++++
 arch/arm/mach-socfpga/include/mach/debug-macro.S |   16 +++
 arch/arm/mach-socfpga/include/mach/timex.h       |   19 +++
 arch/arm/mach-socfpga/include/mach/uncompress.h  |    9 ++
 arch/arm/mach-socfpga/socfpga.c                  |   62 +++++++++
 drivers/clk/Makefile                             |    1 +
 drivers/clk/socfpga/Makefile                     |    1 +
 drivers/clk/socfpga/clk.c                        |   51 ++++++++
 include/linux/dw_apb_timer.h                     |    1 +
 17 files changed, 483 insertions(+)
 create mode 100644 arch/arm/boot/dts/socfpga.dtsi
 create mode 100644 arch/arm/boot/dts/socfpga_cyclone5.dts
 create mode 100644 arch/arm/configs/socfpga_defconfig
 create mode 100644 arch/arm/mach-socfpga/Makefile
 create mode 100644 arch/arm/mach-socfpga/Makefile.boot
 create mode 100644 arch/arm/mach-socfpga/common.h
 create mode 100644 arch/arm/mach-socfpga/include/mach/debug-macro.S
 create mode 100644 arch/arm/mach-socfpga/include/mach/timex.h
 create mode 100644 arch/arm/mach-socfpga/include/mach/uncompress.h
 create mode 100644 arch/arm/mach-socfpga/socfpga.c
 create mode 100644 drivers/clk/socfpga/Makefile
 create mode 100644 drivers/clk/socfpga/clk.c
MAINTAINERS +10 -0
index 1b71f6c..0239cdb 100644
@@ -1103,6 +1103,16 @@ S:	Supported
 F:	arch/arm/mach-shmobile/
 F:	drivers/sh/
 
+ARM/SOCFPGA ARCHITECTURE
+M:	Dinh Nguyen <[email protected]>
+S:	Maintained
+F:	arch/arm/mach-socfpga/
+
+ARM/SOCFPGA CLOCK FRAMEWORK SUPPORT
+M:	Dinh Nguyen <[email protected]>
+S:	Maintained
+F:	drivers/clk/socfpga/
+
 ARM/TECHNOLOGIC SYSTEMS TS7250 MACHINE SUPPORT
 M:	Lennert Buytenhek <[email protected]>
 L:	linux-arm-kernel at lists.infradead.org (moderated for non-subscribers)
arch/arm/Kconfig +19 -0
index 57eb6ef..b9f5fc9 100644
@@ -250,6 +250,25 @@ choice
 	prompt "ARM system type"
 	default ARCH_VERSATILE
 
+config ARCH_SOCFPGA
+	bool "Altera SOCFPGA family"
+	select ARCH_WANT_OPTIONAL_GPIOLIB
+	select ARM_AMBA
+	select ARM_GIC
+	select CACHE_L2X0
+	select CLKDEV_LOOKUP
+	select COMMON_CLK
+	select CPU_V7
+	select DW_APB_TIMER
+	select DW_APB_TIMER_OF
+	select GENERIC_CLOCKEVENTS
+	select GPIO_PL061 if GPIOLIB
+	select HAVE_ARM_SCU
+	select SPARSE_IRQ
+	select USE_OF
+	help
+	  This enables support for Altera SOCFPGA Cyclone V platform
+
 config ARCH_INTEGRATOR
 	bool "ARM Ltd. Integrator family"
 	select ARM_AMBA
arch/arm/Makefile +1 -0
index 0298b00..1fe5702 100644
@@ -193,6 +193,7 @@ machine-$(CONFIG_MACH_SPEAR310)		:= spear3xx
 machine-$(CONFIG_MACH_SPEAR320)		:= spear3xx
 machine-$(CONFIG_MACH_SPEAR600)		:= spear6xx
 machine-$(CONFIG_ARCH_ZYNQ)		:= zynq
+machine-$(CONFIG_ARCH_SOCFPGA) 	:= socfpga
 
 # Platform directory name.  This list is sorted alphanumerically
 # by CONFIG_* macro name.
arch/arm/boot/dts/socfpga.dtsi new file +147 -0

147 lines not on this page · raw message

arch/arm/boot/dts/socfpga_cyclone5.dts new file +34 -0
new file mode 100644
index 0000000..ab7e4a9
@@ -0,0 +1,34 @@
+/*
+ *  Copyright (C) 2012 Altera Corporation <www.altera.com>
+ *
+ * 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, see <http://www.gnu.org/licenses/>.
+ */
+
+/dts-v1/;
+/include/ "socfpga.dtsi"
+
+/ {
+	model = "Altera SOCFPGA Cyclone V";
+	compatible = "altr,socfpga-cyclone5";
+
+	chosen {
+		bootargs = "console=ttyS0,57600";
+	};
+
+	memory {
+		name = "memory";
+		device_type = "memory";
+		reg = <0x0 0x10000000>; /* 256MB */
+	};
+};
arch/arm/configs/socfpga_defconfig new file +83 -0

83 lines not on this page · raw message

arch/arm/mach-socfpga/Makefile new file +5 -0
new file mode 100644
index 0000000..4fb9324
@@ -0,0 +1,5 @@
+#
+# Makefile for the linux kernel.
+#
+
+obj-y					:= socfpga.o
arch/arm/mach-socfpga/Makefile.boot new file +1 -0
new file mode 100644
index 0000000..dae9661
@@ -0,0 +1 @@
+zreladdr-y	:= 0x00008000
arch/arm/mach-socfpga/common.h new file +23 -0
new file mode 100644
index 0000000..d35997d
@@ -0,0 +1,23 @@
+/*
+ *  Copyright (C) 2012 Altera Corporation <www.altera.com>
+ *
+ * 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, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef __MACH_SOCFPGA_COMMON_H
+#define __MACH_SOCFPGA_COMMON_H
+
+extern void socfpga_init_clocks(void);
+
+#endif
arch/arm/mach-socfpga/include/mach/debug-macro.S new file +16 -0
new file mode 100644
index 0000000..d6f26d2
@@ -0,0 +1,16 @@
+/*
+ *  Copyright (C) 1994-1999 Russell King
+ *  Moved from linux/arch/arm/kernel/debug.S by Ben Dooks
+ *
+ * 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.
+ */
+
+		.macro	addruart, rp, rv, tmp
+		mov	\rp, #DEBUG_LL_UART_OFFSET
+		orr	\rp, \rp, #0x00c00000
+		orr	\rv, \rp, #0xfe000000	@ virtual base
+		orr	\rp, \rp, #0xff000000	@ physical base
+		.endm
+
arch/arm/mach-socfpga/include/mach/timex.h new file +19 -0
new file mode 100644
index 0000000..43df435
@@ -0,0 +1,19 @@
+/*
+ *  Copyright (C) 2003 ARM Limited
+ *
+ * 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
+ */
+
+#define CLOCK_TICK_RATE		(50000000 / 16)
arch/arm/mach-socfpga/include/mach/uncompress.h new file +9 -0
new file mode 100644
index 0000000..bbe20e6
@@ -0,0 +1,9 @@
+#ifndef __MACH_UNCOMPRESS_H
+#define __MACH_UNCOMPRESS_H
+
+#define putc(c)
+#define flush()
+#define arch_decomp_setup()
+#define arch_decomp_wdog()
+
+#endif
arch/arm/mach-socfpga/socfpga.c new file +62 -0

62 lines not on this page · raw message

drivers/clk/Makefile +1 -0
index b9a5158..96014e8 100644
@@ -4,4 +4,5 @@ obj-$(CONFIG_COMMON_CLK)	+= clk.o clk-fixed-rate.o clk-gate.o \
 				   clk-mux.o clk-divider.o clk-fixed-factor.o
 # SoCs specific
 obj-$(CONFIG_ARCH_MXS)		+= mxs/
+obj-$(CONFIG_ARCH_SOCFPGA)	+= socfpga/
 obj-$(CONFIG_PLAT_SPEAR)	+= spear/
drivers/clk/socfpga/Makefile new file +1 -0
new file mode 100644
index 0000000..0303c0b
@@ -0,0 +1 @@
+obj-y += clk.o
drivers/clk/socfpga/clk.c new file +51 -0

51 lines not on this page · raw message

include/linux/dw_apb_timer.h +1 -0
index 07261d5..1148575 100644
@@ -53,4 +53,5 @@ void dw_apb_clocksource_start(struct dw_apb_clocksource *dw_cs);
 cycle_t dw_apb_clocksource_read(struct dw_apb_clocksource *dw_cs);
 void dw_apb_clocksource_unregister(struct dw_apb_clocksource *dw_cs);
 
+extern struct sys_timer dw_apb_timer;
 #endif /* __DW_APB_TIMER_H__ */
Signature · 1 line
1.7.9.5
#2 lore raw

RFC PATCH v4 1/1 ARM: socfpga: initial support for Altera's SOCFPGA platform

arch/arm/mach-socfpga/common.h line 7

Quoted 10 lines · dinguyen at altera.com
arch/arm/mach-socfpga/common.h new file +7 -0
@@ -0,0 +1,23 @@
+
+#ifndef __MACH_SOCFPGA_COMMON_H
+#define __MACH_SOCFPGA_COMMON_H
+
+extern void socfpga_init_clocks(void);
+
+#endif

You still have this header file which should not be there.

Everything else looks good now.

Arnd

#3 lore raw

RFC 1/1 Get early_printk() to work on socfpga board

In reply to dinguyen at altera.com

Add ioremap, so that early_printk() works. Add common 8250.S so that code is not duplicated with picoxcell.

arch/arm/include/debug/8250.S new file +27 -0
new file mode 100644
index 0000000..8db01ee
@@ -0,0 +1,27 @@
+/*
+ * Copyright (c) 2011 Picochip Ltd., Jamie Iles
+ *
+ * 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.
+ *
+ * Derived from arch/arm/mach-davinci/include/mach/debug-macro.S to use 32-bit
+ * accesses to the 8250.
+ */
+
+#include <linux/serial_reg.h>
+
+		.macro	senduart,rd,rx
+		str	\rd, [\rx, #UART_TX << UART_SHIFT]
+		.endm
+
+		.macro	busyuart,rd,rx
+1002:		ldr	\rd, [\rx, #UART_LSR << UART_SHIFT]
+		and	\rd, \rd, #UART_LSR_TEMT | UART_LSR_THRE
+		teq	\rd, #UART_LSR_TEMT | UART_LSR_THRE
+		bne	1002b
+		.endm
+
+		/* The UART's don't have any flow control IO's wired up. */
+		.macro	waituart,rd,rx
+		.endm
arch/arm/include/debug/picoxcell.S +1 -17
index 7419deb..86d05e9 100644
@@ -5,10 +5,7 @@
  * it under the terms of the GNU General Public License version 2 as
  * published by the Free Software Foundation.
  *
- * Derived from arch/arm/mach-davinci/include/mach/debug-macro.S to use 32-bit
- * accesses to the 8250.
  */
-#include <linux/serial_reg.h>
 
 #define UART_SHIFT 2
 #define PICOXCELL_UART1_BASE		0x80230000
@@ -19,17 +16,4 @@
 		ldr	\rp, =PICOXCELL_UART1_BASE
 		.endm
 
-		.macro	senduart,rd,rx
-		str	\rd, [\rx, #UART_TX << UART_SHIFT]
-		.endm
-
-		.macro	busyuart,rd,rx
-1002:		ldr	\rd, [\rx, #UART_LSR << UART_SHIFT]
-		and	\rd, \rd, #UART_LSR_TEMT | UART_LSR_THRE
-		teq	\rd, #UART_LSR_TEMT | UART_LSR_THRE
-		bne	1002b
-		.endm
-
-		/* The UART's don't have any flow control IO's wired up. */
-		.macro	waituart,rd,rx
-		.endm
+#include "8250.S"
arch/arm/include/debug/socfpga.S +5 -0
index d6f26d2..2e1dec8 100644
@@ -7,6 +7,9 @@
  * published by the Free Software Foundation.
  */
 
+#define UART_SHIFT 2
+#define DEBUG_LL_UART_OFFSET	0x00002000
+
 		.macro	addruart, rp, rv, tmp
 		mov	\rp, #DEBUG_LL_UART_OFFSET
 		orr	\rp, \rp, #0x00c00000
@@ -14,3 +17,5 @@
 		orr	\rp, \rp, #0xff000000	@ physical base
 		.endm
 
+#include "8250.S"
+
arch/arm/mach-socfpga/socfpga.c +9 -0
index 17d0ec9..962e01e 100644
@@ -36,6 +36,13 @@ static struct map_desc scu_io_desc __initdata = {
 	.type		= MT_DEVICE,
 };
 
+static struct map_desc uart_io_desc __initdata = {
+	.virtual	= 0xfec02000,
+	.pfn		= __phys_to_pfn(0xffc02000),
+	.length		= SZ_8K,
+	.type		= MT_DEVICE,
+};
+
 static void __init socfpga_map_io(void)
 {
 	unsigned long base;
@@ -45,6 +52,8 @@ static void __init socfpga_map_io(void)
 
 	scu_io_desc.pfn = __phys_to_pfn(base);
 	iotable_init(&scu_io_desc, 1);
+	iotable_init(&uart_io_desc, 1);
+	early_printk("Early printk initialized\n");
 }
 
 const static struct of_device_id irq_match[] = {
Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
Acked-by on v1 1/1
#4 lore raw

[RFC] Get early_printk() to work on socfpga board

Hi Pavel,

Quoted 11 lines · Pavel Machek

Add ioremap, so that early_printk() works. Add common 8250.S so that code is not duplicated with picoxcell.

arch/arm/include/debug/8250.S new file +0 -0
new file mode 100644
index 0000000..8db01ee

arch/arm/include/debug/8250.S line 10

Quoted 10 lines
arch/arm/include/debug/8250.S new file +10 -0
@@ -0,0 +1,27 @@
+/*
+ * Copyright (c) 2011 Picochip Ltd., Jamie Iles
+ *
+ * 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.
+ *
+ * Derived from arch/arm/mach-davinci/include/mach/debug-macro.S to use 32-bit
+ * accesses to the 8250.
+ */

The APB on picoxcell only supports 32-bit accesses so we have to use 32-bit accesses for that platform, but others may need 8-bit accesses, so naming this 8250_32.S may be more appropriate?

I did try making 8/32 bit accesses acompile-time configuration and sharing with other platforms before but it looked a bit messy.

Otherwise:

Jamie