ARM: Basic Xilinx Support
Subsystems (5)
cover ARM: Basic Xilinx Support
Hi Russell,
Just for giggles, here is the Xilinx board support series reworked a bit to depend entirely on CONFIG_OF and not use any static device registrations other than what is needed to bootstrap the system, and adds as little code as possible in terms of new infrastructure. All told, the 4th patch adds less than 950 lines of code to the kernel, which is pretty darn good for a whole new subarch.
The zynq platform is a pretty ideal test case for this since the goal has been from day one to depend on CONFIG_OF. The previous series only used static device registrations because device tree on arm isn't yet in mainline. Plus, xilinx is already quite comfortable with how to use the device tree since their other two architectures (powerpc and microblaze) have depended on device tree for years now.
I'd like to get your thoughts on the reuse of plat-versatile for the struct clk implementation. I'm certainly not excited about creating yet another implementation, and versatile seems to be ideal to reuse.
The previous version of this board support has already been in linux-next for quite a while now. If you do decide to pick up device tree support for 2.6.40, then it would pretty low risk thing to queue up this board support also.
The 2nd and 3rd patches aren't actually part of the board support, but I included them here because they're needed to get the patch to apply. The whole series is based on top of both the irq_domain series I posted last week and the latest arm device tree support series.
g.
---
Grant Likely (4):
arm/dt: Add dt machine definition
of/address: Add of_find_matching_node_by_address helper dt/irq: add of_irq_domain_add_simple() helper
ARM: Xilinx: Adding Xilinx board support
Documentation/devicetree/bindings/arm/xilinx.txt | 7 + arch/arm/Kconfig | 14 + arch/arm/Makefile | 2 arch/arm/boot/dts/zynq-ep107.dts | 52 ++++ arch/arm/include/asm/mach/arch.h | 9 + arch/arm/mach-zynq/Makefile | 6 arch/arm/mach-zynq/Makefile.boot | 3 arch/arm/mach-zynq/board_dt.c | 36 +++ arch/arm/mach-zynq/common.c | 112 ++++++++ arch/arm/mach-zynq/common.h | 29 ++ arch/arm/mach-zynq/include/mach/clkdev.h | 32 ++ arch/arm/mach-zynq/include/mach/debug-macro.S | 36 +++ arch/arm/mach-zynq/include/mach/entry-macro.S | 30 ++ arch/arm/mach-zynq/include/mach/hardware.h | 18 + arch/arm/mach-zynq/include/mach/io.h | 33 ++ arch/arm/mach-zynq/include/mach/irqs.h | 21 ++ arch/arm/mach-zynq/include/mach/memory.h | 22 ++ arch/arm/mach-zynq/include/mach/system.h | 28 ++ arch/arm/mach-zynq/include/mach/timex.h | 23 ++ arch/arm/mach-zynq/include/mach/uart.h | 25 ++ arch/arm/mach-zynq/include/mach/uncompress.h | 51 ++++ arch/arm/mach-zynq/include/mach/vmalloc.h | 20 + arch/arm/mach-zynq/include/mach/zynq_soc.h | 48 ++++ arch/arm/mach-zynq/timer.c | 298 ++++++++++++++++++++++ arch/arm/mm/Kconfig | 2 drivers/of/address.c | 18 + drivers/of/irq.c | 44 +++ include/linux/of_address.h | 4 include/linux/of_irq.h | 2 29 files changed, 1024 insertions(+), 1 deletions(-) create mode 100644 Documentation/devicetree/bindings/arm/xilinx.txt create mode 100644 arch/arm/boot/dts/zynq-ep107.dts create mode 100644 arch/arm/mach-zynq/Makefile create mode 100644 arch/arm/mach-zynq/Makefile.boot create mode 100644 arch/arm/mach-zynq/board_dt.c create mode 100644 arch/arm/mach-zynq/common.c create mode 100644 arch/arm/mach-zynq/common.h create mode 100644 arch/arm/mach-zynq/include/mach/clkdev.h create mode 100644 arch/arm/mach-zynq/include/mach/debug-macro.S create mode 100644 arch/arm/mach-zynq/include/mach/entry-macro.S create mode 100644 arch/arm/mach-zynq/include/mach/hardware.h create mode 100644 arch/arm/mach-zynq/include/mach/io.h create mode 100644 arch/arm/mach-zynq/include/mach/irqs.h create mode 100644 arch/arm/mach-zynq/include/mach/memory.h create mode 100644 arch/arm/mach-zynq/include/mach/system.h create mode 100644 arch/arm/mach-zynq/include/mach/timex.h create mode 100644 arch/arm/mach-zynq/include/mach/uart.h create mode 100644 arch/arm/mach-zynq/include/mach/uncompress.h create mode 100644 arch/arm/mach-zynq/include/mach/vmalloc.h create mode 100644 arch/arm/mach-zynq/include/mach/zynq_soc.h create mode 100644 arch/arm/mach-zynq/timer.c
Signature · 1 line
Signature
RFC PATCH 1/4 arm/dt: Add dt machine definition
This patch adds a DT_MACHINE_START macro to use instead of MACHINE_START when creating a machine_desc that supports using the device tree.
--- arch/arm/include/asm/mach/arch.h | 9 +++++++++ 1 files changed, 9 insertions(+), 0 deletions(-)
arch/arm/include/asm/mach/arch.h +9 -0
@@ -70,4 +70,13 @@ static const struct machine_desc __mach_desc_##_type \#define MACHINE_END \ }; +#define MACH_TYPE_DT 0xffffffff + +#define DT_MACHINE_START (_name, _namestr) \ +static const struct machine_desc __mach_desc_##_name \ + __used \ + __attribute__((__section__(".arch.info.init"))) = { \ + .nr = MACH_TYPE_DT, \ + .name = _namestr, +#endif
RFC PATCH 2/4 of/address: Add of_find_matching_node_by_address helper
In reply to Grant Likelyof_find_matching_node_by_address() can be used to find a device tree node for a device at a specific address.
--- drivers/of/address.c | 18 ++++++++++++++++++ include/linux/of_address.h | 4 ++++ 2 files changed, 22 insertions(+), 0 deletions(-)
drivers/of/address.c +18 -0
@@ -591,6 +591,24 @@ int of_address_to_resource(struct device_node *dev, int index, }EXPORT_SYMBOL_GPL (of_address_to_resource); +struct device_node *of_find_matching_node_by_address (struct device_node *from, +const struct of_device_id *matches, +u64 base_address) +{ +struct device_node *dn =of_find_matching_node (from, matches); +struct resource res; + +while (dn) { +if (of_address_to_resource (dn,0 , &res)) +continue ; +if (res.start == base_address) +return dn; + dn =of_find_matching_node (dn, matches); + } + +return NULL ; +} +/** * of_iomap - Maps the memory mapped IO for a given device_node
include/linux/of_address.h +4 -0
@@ -7,6 +7,10 @@ extern int of_address_count(struct device_node *np);extern u64 of_translate_address (struct device_node *np,const __be32 *addr);extern int of_address_to_resource (struct device_node *dev,int index,struct resource *r); +extern struct device_node *of_find_matching_node_by_address ( +struct device_node *from, +const struct of_device_id *matches, +u64 base_address);extern void __iomem *of_iomap (struct device_node *device,int index);/* Extract an address from a device, returns the region size and
RFC PATCH 3/4 dt/irq: add of_irq_domain_add_simple() helper
In reply to Grant Likelyof_irq_domain_add_simple() is an easy way to generate an irq translation domain for simple irq controllers. It assumes a flat 1:1 mapping from hardware irq number to an offset of the first linux irq number assigned to the controller
--- drivers/of/irq.c | 44 ++++++++++++++++++++++++++++++++++++++++++++ include/linux/of_irq.h | 2 ++ 2 files changed, 46 insertions(+), 0 deletions(-)
drivers/of/irq.c +44 -0
@@ -24,6 +24,7 @@#include <linux/of.h> #include <linux/of_irq.h> #include <linux/string.h> +#include <linux/slab.h> /* For archs that don't support NO_IRQ (such as x86), provide a dummy value */ #ifndef NO_IRQ
@@ -147,6 +148,49 @@ unsigned int irq_create_of_mapping(struct device_node *controller, }EXPORT_SYMBOL_GPL (irq_create_of_mapping); +/* +* A simple irq domain implementation that 1:1 translates hwirqs to an offset +* from the irq_start value +*/ +struct of_irq_domain_simple { +struct of_irq_domain domain; +int irq_start; +int irq_size; +}; + +static unsigned int of_irq_domain_simple_map (struct of_irq_domain *domain, +struct device_node *controller, +const u32 *intspec,u32 intsize) +{ +struct of_irq_domain_simple *ds; + + ds = container_of(domain, struct of_irq_domain_simple, domain); +if (intspec[0 ] >= ds->irq_size) +return NO_IRQ ; +return ds->irq_start + intspec[0 ]; +} + +/** +* of_irq_domain_create_simple() - Set up a 'simple' translation range +*/ +void of_irq_domain_add_simple (struct device_node *controller, +int irq_start,int irq_size) +{ +struct of_irq_domain_simple *sd; + + sd =kzalloc (sizeof (*sd),GFP_KERNEL ); +if (!sd) { +WARN_ON (1 ); +return ; + } + + sd->irq_start = irq_start; + sd->irq_size = irq_size; + sd->domain.controller =of_node_get (controller); + sd->domain.map = of_irq_domain_simple_map; +of_irq_domain_add (&sd->domain); +} +/** * irq_of_parse_and_map - Parse and map an interrupt into linux virq space * @device: Device node of the device whose interrupt is to be mapped
include/linux/of_irq.h +2 -0
@@ -63,6 +63,8 @@ struct of_irq_domain {extern void of_irq_domain_add (struct of_irq_domain *domain);extern void of_irq_set_default_domain (struct of_irq_domain *host);extern struct of_irq_domain *of_irq_domain_find (struct device_node *controller); +extern void of_irq_domain_add_simple (struct device_node *controller, +int irq_start,int irq_size);/* * Workarounds only applied to 32bit powermac machines
RFC PATCH 4/4 ARM: Xilinx: Adding Xilinx board support
In reply to Grant LikelyThe 1st board support is minimal to get a system up and running on the Xilinx platform.
This platform reuses the clock implementation from plat-versatile, and it depends entirely on CONFIG_OF support. There is only one board support file which obtains all device information from a device tree dtb file which is passed to the kernel at boot time.
--- Documentation/devicetree/bindings/arm/xilinx.txt | 7 + arch/arm/Kconfig | 14 + arch/arm/Makefile | 2 arch/arm/boot/dts/zynq-ep107.dts | 52 ++++ arch/arm/mach-zynq/Makefile | 6 arch/arm/mach-zynq/Makefile.boot | 3 arch/arm/mach-zynq/board_dt.c | 36 +++ arch/arm/mach-zynq/common.c | 112 ++++++++ arch/arm/mach-zynq/common.h | 29 ++ arch/arm/mach-zynq/include/mach/clkdev.h | 32 ++ arch/arm/mach-zynq/include/mach/debug-macro.S | 36 +++ arch/arm/mach-zynq/include/mach/entry-macro.S | 30 ++ arch/arm/mach-zynq/include/mach/hardware.h | 18 + arch/arm/mach-zynq/include/mach/io.h | 33 ++ arch/arm/mach-zynq/include/mach/irqs.h | 21 ++ arch/arm/mach-zynq/include/mach/memory.h | 22 ++ arch/arm/mach-zynq/include/mach/system.h | 28 ++ arch/arm/mach-zynq/include/mach/timex.h | 23 ++ arch/arm/mach-zynq/include/mach/uart.h | 25 ++ arch/arm/mach-zynq/include/mach/uncompress.h | 51 ++++ arch/arm/mach-zynq/include/mach/vmalloc.h | 20 + arch/arm/mach-zynq/include/mach/zynq_soc.h | 48 ++++ arch/arm/mach-zynq/timer.c | 298 ++++++++++++++++++++++ arch/arm/mm/Kconfig | 2 24 files changed, 947 insertions(+), 1 deletions(-) create mode 100644 Documentation/devicetree/bindings/arm/xilinx.txt create mode 100644 arch/arm/boot/dts/zynq-ep107.dts create mode 100644 arch/arm/mach-zynq/Makefile create mode 100644 arch/arm/mach-zynq/Makefile.boot create mode 100644 arch/arm/mach-zynq/board_dt.c create mode 100644 arch/arm/mach-zynq/common.c create mode 100644 arch/arm/mach-zynq/common.h create mode 100644 arch/arm/mach-zynq/include/mach/clkdev.h create mode 100644 arch/arm/mach-zynq/include/mach/debug-macro.S create mode 100644 arch/arm/mach-zynq/include/mach/entry-macro.S create mode 100644 arch/arm/mach-zynq/include/mach/hardware.h create mode 100644 arch/arm/mach-zynq/include/mach/io.h create mode 100644 arch/arm/mach-zynq/include/mach/irqs.h create mode 100644 arch/arm/mach-zynq/include/mach/memory.h create mode 100644 arch/arm/mach-zynq/include/mach/system.h create mode 100644 arch/arm/mach-zynq/include/mach/timex.h create mode 100644 arch/arm/mach-zynq/include/mach/uart.h create mode 100644 arch/arm/mach-zynq/include/mach/uncompress.h create mode 100644 arch/arm/mach-zynq/include/mach/vmalloc.h create mode 100644 arch/arm/mach-zynq/include/mach/zynq_soc.h create mode 100644 arch/arm/mach-zynq/timer.c
Documentation/devicetree/bindings/arm/xilinx.txt new file +7 -0
@@ -0,0 +1,7 @@ +Xilinx Zynq EP107 Emulation Platform board + +This board is an emulation platform for the Zynq product which is +based on an ARM Cortex A9 processor. + +Required root node properties: + - compatible = "xlnx,zynq-ep107";
arch/arm/Kconfig +14 -0
@@ -889,6 +889,20 @@ config ARCH_VT8500 select HAVE_PWM help Support for VIA/WonderMedia VT8500/WM85xx System-on-Chip. + +config ARCH_ZYNQ + bool "Xilinx Zynq ARM Cortex A9 Platform" + select CPU_V7 + select GENERIC_TIME + select GENERIC_CLOCKEVENTS + select CLKDEV_LOOKUP + select ARM_GIC + select ARM_AMBA + select ICST + select USE_OF + help + Support for Xilinx Zynq ARM Cortex A9 Platform + endchoice #
arch/arm/Makefile +2 -0
@@ -201,6 +201,7 @@ machine-$(CONFIG_MACH_SPEAR300) := spear3xx machine-$(CONFIG_MACH_SPEAR310) := spear3xx machine-$(CONFIG_MACH_SPEAR320) := spear3xx machine-$(CONFIG_MACH_SPEAR600) := spear6xx +machine-$(CONFIG_ARCH_ZYNQ) := zynq # Platform directory name. This list is sorted alphanumerically # by CONFIG_* macro name.
@@ -209,6 +210,7 @@ plat-$(CONFIG_ARCH_OMAP) := omap plat-$(CONFIG_ARCH_S3C64XX) := samsung plat-$(CONFIG_ARCH_STMP3XXX) := stmp3xxx plat-$(CONFIG_ARCH_TCC_926) := tcc +plat-$(CONFIG_ARCH_ZYNQ) := versatile plat-$(CONFIG_PLAT_IOP) := iop plat-$(CONFIG_PLAT_NOMADIK) := nomadik plat-$(CONFIG_PLAT_ORION) := orion
arch/arm/boot/dts/zynq-ep107.dts new file +52 -0
52 lines not on this page · raw message
arch/arm/mach-zynq/Makefile new file +6 -0
@@ -0,0 +1,6 @@ +# +# Makefile for the linux kernel. +# + +# Common support +obj-y := common.o timer.o board_dt.o
arch/arm/mach-zynq/Makefile.boot new file +3 -0
@@ -0,0 +1,3 @@ + zreladdr-y := 0x00008000 +params_phys-y := 0x00000100 +initrd_phys-y := 0x00800000
arch/arm/mach-zynq/board_dt.c new file +36 -0
@@ -0,0 +1,36 @@ +/* +* This file contains code for boards with device tree support. +* +* Copyright (C) 2011 Xilinx +* +* based on arch/arm/mach-realview/core.c +* +* Copyright (C) 1999 - 2003 ARM Limited +* Copyright (C) 2000 Deep Blue Solutions Ltd +* +* This software is licensed under the terms of the GNU General Public +* License version 2, as published by the Free Software Foundation, and +* may be copied, distributed, and modified under those terms. +* +* 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. +*/ + +#include <linux/of.h> +#include <asm/mach/arch.h> +#include "common.h" + +static const char *xilinx_dt_match[] = { +"xlnx,zynq-ep107" , +NULL +}; + +DT_MACHINE_START (XILINX_EP107 ,"Xilinx Zynq Platform" ) + .map_io = xilinx_map_io, + .init_irq = xilinx_irq_init, + .init_machine = xilinx_init_machine, + .timer = &xttcpss_sys_timer, + .dt_compat = xilinx_dt_match, +MACHINE_END
arch/arm/mach-zynq/common.c new file +112 -0
112 lines not on this page · raw message
arch/arm/mach-zynq/common.h new file +29 -0
@@ -0,0 +1,29 @@ +/* +* This file contains common function prototypes to avoid externs +* in the c files. +* +* Copyright (C) 2011 Xilinx +* +* This software is licensed under the terms of the GNU General Public +* License version 2, as published by the Free Software Foundation, and +* may be copied, distributed, and modified under those terms. +* +* 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. +*/ + +#ifndef __MACH_ZYNQ_COMMON_H__ +#define __MACH_ZYNQ_COMMON_H__ + +#include <linux/init.h> +#include <asm/mach/time.h> + +extern void xilinx_init_machine (void ); +extern void xilinx_irq_init (void ); +extern void xilinx_map_io (void ); + +extern struct sys_timer xttcpss_sys_timer; + +#endif
arch/arm/mach-zynq/include/mach/clkdev.h new file +32 -0
@@ -0,0 +1,32 @@ +/* +* arch/arm/mach-zynq/include/mach/clkdev.h +* +* Copyright (C) 2011 Xilinx, Inc. +* +* This software is licensed under the terms of the GNU General Public +* License version 2, as published by the Free Software Foundation, and +* may be copied, distributed, and modified under those terms. +* +* 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. +* +*/ + +#ifndef __MACH_CLKDEV_H__ +#define __MACH_CLKDEV_H__ + +#include <plat/clock.h> + +struct clk { +unsigned long rate; +const struct clk_ops *ops; +const struct icst_params *params; +void __iomem *vcoreg; +}; + +#define __clk_get (clk) ({ 1; }) +#define __clk_put (clk) do { } while (0) + +#endif
arch/arm/mach-zynq/include/mach/debug-macro.S new file +36 -0
@@ -0,0 +1,36 @@ +/* arch/arm/mach-zynq/include/mach/debug-macro.S + * + * Debugging macro include header + * + * Copyright (C) 2011 Xilinx + * + * This software is licensed under the terms of the GNU General Public + * License version 2, as published by the Free Software Foundation, and + * may be copied, distributed, and modified under those terms. + * + * 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. + */ + +#include <mach/zynq_soc.h> +#include <mach/uart.h> + + .macro addruart, rp, rv + ldr \rp, =LL_UART_PADDR @ physical + ldr \rv, =LL_UART_VADDR @ virtual + .endm + + .macro senduart,rd,rx + str \rd, [\rx, #UART_FIFO_OFFSET] @ TXDATA + .endm + + .macro waituart,rd,rx + .endm + + .macro busyuart,rd,rx +1002: ldr \rd, [\rx, #UART_SR_OFFSET] @ get status register + tst \rd, #UART_SR_TXFULL @ + bne 1002b @ wait if FIFO is full + .endm
arch/arm/mach-zynq/include/mach/entry-macro.S new file +30 -0
@@ -0,0 +1,30 @@ +/* + * arch/arm/mach-zynq/include/mach/entry-macro.S + * + * Low-level IRQ helper macros + * + * Copyright (C) 2011 Xilinx + * + * based on arch/plat-mxc/include/mach/entry-macro.S + * + * Copyright (C) 2007 Lennert Buytenhek <[email protected]> + * Copyright 2004-2007 Freescale Semiconductor, Inc. All Rights Reserved. + * + * This software is licensed under the terms of the GNU General Public + * License version 2, as published by the Free Software Foundation, and + * may be copied, distributed, and modified under those terms. + * + * 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. + */ + +#include <mach/hardware.h> +#include <asm/hardware/entry-macro-gic.S> + + .macro disable_fiq + .endm + + .macro arch_ret_to_user, tmp1, tmp2 + .endm
arch/arm/mach-zynq/include/mach/hardware.h new file +18 -0
@@ -0,0 +1,18 @@ +/* arch/arm/mach-zynq/include/mach/hardware.h +* +* Copyright (C) 2011 Xilinx +* +* This software is licensed under the terms of the GNU General Public +* License version 2, as published by the Free Software Foundation, and +* may be copied, distributed, and modified under those terms. +* +* 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. +*/ + +#ifndef __MACH_HARDWARE_H__ +#define __MACH_HARDWARE_H__ + +#endif
arch/arm/mach-zynq/include/mach/io.h new file +33 -0
@@ -0,0 +1,33 @@ +/* arch/arm/mach-zynq/include/mach/io.h +* +* Copyright (C) 2011 Xilinx +* +* This software is licensed under the terms of the GNU General Public +* License version 2, as published by the Free Software Foundation, and +* may be copied, distributed, and modified under those terms. +* +* 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. +*/ + +#ifndef __MACH_IO_H__ +#define __MACH_IO_H__ + +/* Allow IO space to be anywhere in the memory */ + +#define IO_SPACE_LIMIT 0xffff + +/* IO address mapping macros, nothing special at this time but required */ + +#ifdef __ASSEMBLER__ +#define IOMEM (x) (x) +#else +#define IOMEM (x) ((void __force __iomem *)(x)) +#endif + +#define __io (a) __typesafe_io(a) +#define __mem_pci (a) (a) + +#endif
arch/arm/mach-zynq/include/mach/irqs.h new file +21 -0
@@ -0,0 +1,21 @@ +/* arch/arm/mach-zynq/include/mach/irqs.h +* +* Copyright (C) 2011 Xilinx +* +* This software is licensed under the terms of the GNU General Public +* License version 2, as published by the Free Software Foundation, and +* may be copied, distributed, and modified under those terms. +* +* 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. +*/ + +#ifndef __MACH_IRQS_H +#define __MACH_IRQS_H + +#define ARCH_NR_GPIOS 118 +#define NR_IRQS (128 + ARCH_NR_GPIOS) + +#endif
arch/arm/mach-zynq/include/mach/memory.h new file +22 -0
@@ -0,0 +1,22 @@ +/* arch/arm/mach-zynq/include/mach/memory.h +* +* Copyright (C) 2011 Xilinx +* +* This software is licensed under the terms of the GNU General Public +* License version 2, as published by the Free Software Foundation, and +* may be copied, distributed, and modified under those terms. +* +* 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. +*/ + +#ifndef __MACH_MEMORY_H__ +#define __MACH_MEMORY_H__ + +#include <asm/sizes.h> + +#define PLAT_PHYS_OFFSET UL(0x0) + +#endif
arch/arm/mach-zynq/include/mach/system.h new file +28 -0
@@ -0,0 +1,28 @@ +/* arch/arm/mach-zynq/include/mach/system.h +* +* Copyright (C) 2011 Xilinx +* +* This software is licensed under the terms of the GNU General Public +* License version 2, as published by the Free Software Foundation, and +* may be copied, distributed, and modified under those terms. +* +* 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. +*/ + +#ifndef __MACH_SYSTEM_H__ +#define __MACH_SYSTEM_H__ + +static inline void arch_idle (void ) +{ +cpu_do_idle (); +} + +static inline void arch_reset (char mode,const char *cmd) +{ +/* Add architecture specific reset processing here */ +} + +#endif
arch/arm/mach-zynq/include/mach/timex.h new file +23 -0
@@ -0,0 +1,23 @@ +/* arch/arm/mach-zynq/include/mach/timex.h +* +* Copyright (C) 2011 Xilinx +* +* This software is licensed under the terms of the GNU General Public +* License version 2, as published by the Free Software Foundation, and +* may be copied, distributed, and modified under those terms. +* +* 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. +*/ + +#ifndef __MACH_TIMEX_H__ +#define __MACH_TIMEX_H__ + +/* the following is needed for the system to build but will be removed +in the future, the value is not important but won't hurt +*/ +#define CLOCK_TICK_RATE (100 * HZ) + +#endif
arch/arm/mach-zynq/include/mach/uart.h new file +25 -0
@@ -0,0 +1,25 @@ +/* arch/arm/mach-zynq/include/mach/uart.h +* +* Copyright (C) 2011 Xilinx +* +* This software is licensed under the terms of the GNU General Public +* License version 2, as published by the Free Software Foundation, and +* may be copied, distributed, and modified under those terms. +* +* 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. +*/ + +#ifndef __MACH_UART_H__ +#define __MACH_UART_H__ + +#define UART_CR_OFFSET 0x00/* Control Register [8:0] */ +#define UART_SR_OFFSET 0x2C/* Channel Status [11:0] */ +#define UART_FIFO_OFFSET 0x30/* FIFO [15:0] or [7:0] */ + +#define UART_SR_TXFULL 0x00000010/* TX FIFO full */ +#define UART_SR_TXEMPTY 0x00000008/* TX FIFO empty */ + +#endif
arch/arm/mach-zynq/include/mach/uncompress.h new file +51 -0
51 lines not on this page · raw message
arch/arm/mach-zynq/include/mach/vmalloc.h new file +20 -0
@@ -0,0 +1,20 @@ +/* arch/arm/mach-zynq/include/mach/vmalloc.h +* +* Copyright (C) 2011 Xilinx +* +* This software is licensed under the terms of the GNU General Public +* License version 2, as published by the Free Software Foundation, and +* may be copied, distributed, and modified under those terms. +* +* 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. +*/ + +#ifndef __MACH_VMALLOC_H__ +#define __MACH_VMALLOC_H__ + +#define VMALLOC_END 0xE0000000UL + +#endif
arch/arm/mach-zynq/include/mach/zynq_soc.h new file +48 -0
48 lines not on this page · raw message
arch/arm/mach-zynq/timer.c new file +298 -0
298 lines not on this page · raw message
arch/arm/mm/Kconfig +1 -1
@@ -821,7 +821,7 @@ config CACHE_L2X0 depends on REALVIEW_EB_ARM11MP || MACH_REALVIEW_PB11MP || MACH_REALVIEW_PB1176 || \ REALVIEW_EB_A9MP || SOC_IMX35 || SOC_IMX31 || MACH_REALVIEW_PBX || \ ARCH_NOMADIK || ARCH_OMAP4 || ARCH_EXYNOS4 || ARCH_TEGRA || \ - ARCH_U8500 || ARCH_VEXPRESS_CA9X4 || ARCH_SHMOBILE + ARCH_U8500 || ARCH_VEXPRESS_CA9X4 || ARCH_SHMOBILE || ARCH_ZYNQ default y select OUTER_CACHE select OUTER_CACHE_SYNC
Re: [RFC PATCH 4/4] ARM: Xilinx: Adding Xilinx board support
Quoted 337 lines · Grant Likely
The 1st board support is minimal to get a system up and running on the Xilinx platform.
This platform reuses the clock implementation from plat-versatile, and it depends entirely on
CONFIG_OFsupport. There is only one board support file which obtains all device information from a device tree dtb file which is passed to the kernel at boot time.Signed-off-by John Linn <[email protected]>Signed-off-by Grant Likely <[email protected]>--- Documentation/devicetree/bindings/arm/xilinx.txt | 7 + arch/arm/Kconfig | 14 + arch/arm/Makefile | 2 arch/arm/boot/dts/zynq-ep107.dts | 52 ++++ arch/arm/mach-zynq/Makefile | 6 arch/arm/mach-zynq/Makefile.boot | 3 arch/arm/mach-zynq/board_dt.c | 36 +++ arch/arm/mach-zynq/common.c | 112 ++++++++ arch/arm/mach-zynq/common.h | 29 ++ arch/arm/mach-zynq/include/mach/clkdev.h | 32 ++ arch/arm/mach-zynq/include/mach/debug-macro.S | 36 +++ arch/arm/mach-zynq/include/mach/entry-macro.S | 30 ++ arch/arm/mach-zynq/include/mach/hardware.h | 18 + arch/arm/mach-zynq/include/mach/io.h | 33 ++ arch/arm/mach-zynq/include/mach/irqs.h | 21 ++ arch/arm/mach-zynq/include/mach/memory.h | 22 ++ arch/arm/mach-zynq/include/mach/system.h | 28 ++ arch/arm/mach-zynq/include/mach/timex.h | 23 ++ arch/arm/mach-zynq/include/mach/uart.h | 25 ++ arch/arm/mach-zynq/include/mach/uncompress.h | 51 ++++ arch/arm/mach-zynq/include/mach/vmalloc.h | 20 + arch/arm/mach-zynq/include/mach/zynq_soc.h | 48 ++++ arch/arm/mach-zynq/timer.c | 298 ++++++++++++++++++++++ arch/arm/mm/Kconfig | 2 24 files changed, 947 insertions(+), 1 deletions(-) create mode 100644 Documentation/devicetree/bindings/arm/xilinx.txt create mode 100644 arch/arm/boot/dts/zynq-ep107.dts create mode 100644 arch/arm/mach-zynq/Makefile create mode 100644 arch/arm/mach-zynq/Makefile.boot create mode 100644 arch/arm/mach-zynq/board_dt.c create mode 100644 arch/arm/mach-zynq/common.c create mode 100644 arch/arm/mach-zynq/common.h create mode 100644 arch/arm/mach-zynq/include/mach/clkdev.h create mode 100644 arch/arm/mach-zynq/include/mach/debug-macro.S create mode 100644 arch/arm/mach-zynq/include/mach/entry-macro.S create mode 100644 arch/arm/mach-zynq/include/mach/hardware.h create mode 100644 arch/arm/mach-zynq/include/mach/io.h create mode 100644 arch/arm/mach-zynq/include/mach/irqs.h create mode 100644 arch/arm/mach-zynq/include/mach/memory.h create mode 100644 arch/arm/mach-zynq/include/mach/system.h create mode 100644 arch/arm/mach-zynq/include/mach/timex.h create mode 100644 arch/arm/mach-zynq/include/mach/uart.h create mode 100644 arch/arm/mach-zynq/include/mach/uncompress.h create mode 100644 arch/arm/mach-zynq/include/mach/vmalloc.h create mode 100644 arch/arm/mach-zynq/include/mach/zynq_soc.h create mode 100644 arch/arm/mach-zynq/timer.cDocumentation/devicetree/bindings/arm/xilinx.txt new file +7
-0@@ -0,0 +1,7 @@ +Xilinx Zynq EP107 Emulation Platform board + +This board is an emulation platform for the Zynq product which is +based on an ARM Cortex A9 processor. + +Required root node properties: + - compatible = "xlnx,zynq-ep107";arch/arm/Kconfig +14
-0@@ -889,6 +889,20 @@ config ARCH_VT8500 select HAVE_PWM help Support for VIA/WonderMedia VT8500/WM85xx System-on-Chip. + +config ARCH_ZYNQ + bool "Xilinx Zynq ARM Cortex A9 Platform" + select CPU_V7 + select GENERIC_TIME + select GENERIC_CLOCKEVENTS + select CLKDEV_LOOKUP + select ARM_GIC + select ARM_AMBA + select ICST + select USE_OF + help + Support for Xilinx Zynq ARM Cortex A9 Platform + endchoice #arch/arm/Makefile +2
-0@@ -201,6 +201,7 @@ machine-$(CONFIG_MACH_SPEAR300) := spear3xx machine-$(CONFIG_MACH_SPEAR310) := spear3xx machine-$(CONFIG_MACH_SPEAR320) := spear3xx machine-$(CONFIG_MACH_SPEAR600) := spear6xx +machine-$(CONFIG_ARCH_ZYNQ) := zynq # Platform directory name. This list is sorted alphanumerically # by CONFIG_* macro name.@@ -209,6 +210,7 @@ plat-$(CONFIG_ARCH_OMAP) := omap plat-$(CONFIG_ARCH_S3C64XX) := samsung plat-$(CONFIG_ARCH_STMP3XXX) := stmp3xxx plat-$(CONFIG_ARCH_TCC_926) := tcc +plat-$(CONFIG_ARCH_ZYNQ) := versatile plat-$(CONFIG_PLAT_IOP) := iop plat-$(CONFIG_PLAT_NOMADIK) := nomadik plat-$(CONFIG_PLAT_ORION) := orionarch/arm/boot/dts/zynq-ep107.dts new file +52
-0@@ -0,0 +1,52 @@ +/* + * Copyright (C) 2011 Xilinx + * + * This software is licensed under the terms of the GNU General Public + * License version 2, as published by the Free Software Foundation, and + * may be copied, distributed, and modified under those terms. + * + * 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. + */ + +/dts-v1/; +/ { + model = "Xilinx Zynq EP107"; + compatible = "xlnx,zynq-ep107"; + #address-cells = <1>; + #size-cells = <1>; + interrupt-parent = <&intc>; + + memory { + device_type = "memory"; + reg = <0x0 0x10000000>; + }; + + chosen { + bootargs = "console=ttyPS0,9600 root=/dev/ram rw initrd=0x800000,8M earlyprintk"; + linux,stdout-path = &uart0; + }; + + amba { + compatible = "simple-bus"; + #address-cells = <1>; + #size-cells = <1>; + ranges; + + intc: interrupt-controller at f8f01000 { + interrupt-controller; + compatible = "arm,gic"; + reg = <0xF8F01000 0x1000>; + #interrupt-cells = <2>; + }; + + uart0: uart at e0000000 { + compatible = "xlnx,xuartps"; + reg = <0xE0000000 0x1000>; + interrupts = <59 0>; + clock = <50000000>; + }; + }; +};arch/arm/mach-zynq/Makefile new file +6
-0@@ -0,0 +1,6 @@ +# +# Makefile for the linux kernel. +# + +# Common support +obj-y := common.o timer.o board_dt.oarch/arm/mach-zynq/Makefile.boot new file +3
-0@@ -0,0 +1,3 @@ + zreladdr-y := 0x00008000 +params_phys-y := 0x00000100 +initrd_phys-y := 0x00800000arch/arm/mach-zynq/board_dt.c new file +36
-0@@ -0,0 +1,36 @@ +/* +* This file contains code for boards with device tree support. +* +* Copyright (C) 2011 Xilinx +* +* based on arch/arm/mach-realview/core.c +* +* Copyright (C) 1999 - 2003 ARM Limited +* Copyright (C) 2000 Deep Blue Solutions Ltd +* +* This software is licensed under the terms of the GNU General Public +* License version 2, as published by the Free Software Foundation, and +* may be copied, distributed, and modified under those terms. +* +* 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. +*/ + +#include <linux/of.h> +#include <asm/mach/arch.h> +#include "common.h" + +static const char *xilinx_dt_match[] = { +"xlnx,zynq-ep107" , +NULL +}; + +DT_MACHINE_START (XILINX_EP107 ,"Xilinx Zynq Platform" ) + .map_io = xilinx_map_io, + .init_irq = xilinx_irq_init, + .init_machine = xilinx_init_machine, + .timer = &xttcpss_sys_timer, + .dt_compat = xilinx_dt_match, +MACHINE_END arch/arm/mach-zynq/common.c new file +94
-0@@ -0,0 +1,112 @@ +/* +* This file contains common code that is intended to be used across +* boards so that it's not replicated. +* +* Copyright (C) 2011 Xilinx +* +* This software is licensed under the terms of the GNU General Public +* License version 2, as published by the Free Software Foundation, and +* may be copied, distributed, and modified under those terms. +* +* 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. +*/ + +#include <linux/init.h> +#include <linux/kernel.h> +#include <linux/cpumask.h> +#include <linux/platform_device.h> +#include <linux/clk.h> +#include <linux/of_irq.h> +#include <linux/of_platform.h> + +#include <asm/mach/map.h> +#include <asm/page.h> +#include <asm/hardware/gic.h> +#include <asm/hardware/cache-l2x0.h> + +#include <mach/zynq_soc.h> +#include <mach/clkdev.h> +#include "common.h" + +static struct of_device_id zynq_of_bus_ids[]__initdata = { + { .compatible ="simple-bus" , }, + {} +}; + +static struct of_device_id gic_match[] = { + { .compatible ="arm,gic" , }, + {} +}; + +/** +* xilinx_init_machine() - System specific initialization, intended to be +* called from board specific initialization. +*/ +void __init xilinx_init_machine (void ) +{ +struct device_node *node =of_find_matching_node (NULL , gic_match); + +if (node) +of_irq_domain_add_simple (node,0 ,NR_IRQS ); + +#ifdef CONFIG_CACHE_L2X0 +/* +* 64KB way size, 8-way associativity, parity disabled +*/ +l2x0_init (PL310_L2CC_BASE ,0x02060000 ,0xF0F0FFFF ); +#endif + +of_platform_bus_probe (NULL , zynq_of_bus_ids,NULL ); +} + +/** +* xilinx_irq_init() - Interrupt controller initialization for the GIC. +*/ +void __init xilinx_irq_init (void ) +{ +gic_init (0 ,29 ,SCU_GIC_DIST_BASE ,SCU_GIC_CPU_BASE ); +} + +/* The minimum devices needed to be mapped before the VM system is up and +* running include the GIC, UART and Timer Counter. +*/ + +static struct map_desc io_desc[]__initdata = { + { + .virtual =TTC0_VIRT , + .pfn =__phys_to_pfn (TTC0_PHYS ), + .length =SZ_4K , + .type =MT_DEVICE , + }, { + .virtual =SCU_PERIPH_VIRT , + .pfn =__phys_to_pfn (SCU_PERIPH_PHYS ), + .length =SZ_8K , + .type =MT_DEVICE , + }, { + .virtual =PL310_L2CC_VIRT , + .pfn =__phys_to_pfn (PL310_L2CC_PHYS ), + .length =SZ_4K , + .type =MT_DEVICE , + }, +
arch/arm/mach-zynq/common.c line 104
Quoted 10 lines
arch/arm/mach-zynq/common.c new file +10
-0+#ifdef CONFIG_DEBUG_LL + { + .virtual = UART0_VIRT, + .pfn = __phys_to_pfn(UART0_PHYS), + .length = SZ_4K, + .type = MT_DEVICE, + }, +#endif + +};
look below
Quoted 468 lines
arch/arm/mach-zynq/common.c new file +8
-0+ +/** +* xilinx_map_io() - Create memory mappings needed for early I/O. +*/ +void __init xilinx_map_io (void ) +{ +iotable_init (io_desc,ARRAY_SIZE (io_desc)); +}arch/arm/mach-zynq/common.h new file +29
-0@@ -0,0 +1,29 @@ +/* +* This file contains common function prototypes to avoid externs +* in the c files. +* +* Copyright (C) 2011 Xilinx +* +* This software is licensed under the terms of the GNU General Public +* License version 2, as published by the Free Software Foundation, and +* may be copied, distributed, and modified under those terms. +* +* 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. +*/ + +#ifndef __MACH_ZYNQ_COMMON_H__ +#define __MACH_ZYNQ_COMMON_H__ + +#include <linux/init.h> +#include <asm/mach/time.h> + +extern void xilinx_init_machine (void ); +extern void xilinx_irq_init (void ); +extern void xilinx_map_io (void ); + +extern struct sys_timer xttcpss_sys_timer; + +#endif arch/arm/mach-zynq/include/mach/clkdev.h new file +32
-0@@ -0,0 +1,32 @@ +/* +* arch/arm/mach-zynq/include/mach/clkdev.h +* +* Copyright (C) 2011 Xilinx, Inc. +* +* This software is licensed under the terms of the GNU General Public +* License version 2, as published by the Free Software Foundation, and +* may be copied, distributed, and modified under those terms. +* +* 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. +* +*/ + +#ifndef __MACH_CLKDEV_H__ +#define __MACH_CLKDEV_H__ + +#include <plat/clock.h> + +struct clk { +unsigned long rate; +const struct clk_ops *ops; +const struct icst_params *params; +void __iomem *vcoreg; +}; + +#define __clk_get (clk) ({ 1; }) +#define __clk_put (clk) do { } while (0) + +#endif arch/arm/mach-zynq/include/mach/debug-macro.S new file +36
-0@@ -0,0 +1,36 @@ +/* arch/arm/mach-zynq/include/mach/debug-macro.S + * + * Debugging macro include header + * + * Copyright (C) 2011 Xilinx + * + * This software is licensed under the terms of the GNU General Public + * License version 2, as published by the Free Software Foundation, and + * may be copied, distributed, and modified under those terms. + * + * 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. + */ + +#include <mach/zynq_soc.h> +#include <mach/uart.h> + + .macro addruart, rp, rv + ldr \rp, =LL_UART_PADDR @ physical + ldr \rv, =LL_UART_VADDR @ virtual + .endm + + .macro senduart,rd,rx + str \rd, [\rx, #UART_FIFO_OFFSET] @ TXDATA + .endm + + .macro waituart,rd,rx + .endm + + .macro busyuart,rd,rx +1002: ldr \rd, [\rx, #UART_SR_OFFSET] @ get status register + tst \rd, #UART_SR_TXFULL @ + bne 1002b @ wait if FIFO is full + .endmarch/arm/mach-zynq/include/mach/entry-macro.S new file +30
-0@@ -0,0 +1,30 @@ +/* + * arch/arm/mach-zynq/include/mach/entry-macro.S + * + * Low-level IRQ helper macros + * + * Copyright (C) 2011 Xilinx + * + * based on arch/plat-mxc/include/mach/entry-macro.S + * + * Copyright (C) 2007 Lennert Buytenhek <[email protected]> + * Copyright 2004-2007 Freescale Semiconductor, Inc. All Rights Reserved. + * + * This software is licensed under the terms of the GNU General Public + * License version 2, as published by the Free Software Foundation, and + * may be copied, distributed, and modified under those terms. + * + * 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. + */ + +#include <mach/hardware.h> +#include <asm/hardware/entry-macro-gic.S> + + .macro disable_fiq + .endm + + .macro arch_ret_to_user, tmp1, tmp2 + .endmarch/arm/mach-zynq/include/mach/hardware.h new file +18
-0@@ -0,0 +1,18 @@ +/* arch/arm/mach-zynq/include/mach/hardware.h +* +* Copyright (C) 2011 Xilinx +* +* This software is licensed under the terms of the GNU General Public +* License version 2, as published by the Free Software Foundation, and +* may be copied, distributed, and modified under those terms. +* +* 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. +*/ + +#ifndef __MACH_HARDWARE_H__ +#define __MACH_HARDWARE_H__ + +#endif arch/arm/mach-zynq/include/mach/io.h new file +33
-0@@ -0,0 +1,33 @@ +/* arch/arm/mach-zynq/include/mach/io.h +* +* Copyright (C) 2011 Xilinx +* +* This software is licensed under the terms of the GNU General Public +* License version 2, as published by the Free Software Foundation, and +* may be copied, distributed, and modified under those terms. +* +* 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. +*/ + +#ifndef __MACH_IO_H__ +#define __MACH_IO_H__ + +/* Allow IO space to be anywhere in the memory */ + +#define IO_SPACE_LIMIT 0xffff + +/* IO address mapping macros, nothing special at this time but required */ + +#ifdef __ASSEMBLER__ +#define IOMEM (x) (x) +#else +#define IOMEM (x) ((void __force __iomem *)(x)) +#endif + +#define __io (a) __typesafe_io(a) +#define __mem_pci (a) (a) + +#endif arch/arm/mach-zynq/include/mach/irqs.h new file +21
-0@@ -0,0 +1,21 @@ +/* arch/arm/mach-zynq/include/mach/irqs.h +* +* Copyright (C) 2011 Xilinx +* +* This software is licensed under the terms of the GNU General Public +* License version 2, as published by the Free Software Foundation, and +* may be copied, distributed, and modified under those terms. +* +* 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. +*/ + +#ifndef __MACH_IRQS_H +#define __MACH_IRQS_H + +#define ARCH_NR_GPIOS 118 +#define NR_IRQS (128 + ARCH_NR_GPIOS) + +#endif arch/arm/mach-zynq/include/mach/memory.h new file +22
-0@@ -0,0 +1,22 @@ +/* arch/arm/mach-zynq/include/mach/memory.h +* +* Copyright (C) 2011 Xilinx +* +* This software is licensed under the terms of the GNU General Public +* License version 2, as published by the Free Software Foundation, and +* may be copied, distributed, and modified under those terms. +* +* 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. +*/ + +#ifndef __MACH_MEMORY_H__ +#define __MACH_MEMORY_H__ + +#include <asm/sizes.h> + +#define PLAT_PHYS_OFFSET UL(0x0) + +#endif arch/arm/mach-zynq/include/mach/system.h new file +28
-0@@ -0,0 +1,28 @@ +/* arch/arm/mach-zynq/include/mach/system.h +* +* Copyright (C) 2011 Xilinx +* +* This software is licensed under the terms of the GNU General Public +* License version 2, as published by the Free Software Foundation, and +* may be copied, distributed, and modified under those terms. +* +* 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. +*/ + +#ifndef __MACH_SYSTEM_H__ +#define __MACH_SYSTEM_H__ + +static inline void arch_idle (void ) +{ +cpu_do_idle (); +} + +static inline void arch_reset (char mode,const char *cmd) +{ +/* Add architecture specific reset processing here */ +} + +#endif arch/arm/mach-zynq/include/mach/timex.h new file +23
-0@@ -0,0 +1,23 @@ +/* arch/arm/mach-zynq/include/mach/timex.h +* +* Copyright (C) 2011 Xilinx +* +* This software is licensed under the terms of the GNU General Public +* License version 2, as published by the Free Software Foundation, and +* may be copied, distributed, and modified under those terms. +* +* 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. +*/ + +#ifndef __MACH_TIMEX_H__ +#define __MACH_TIMEX_H__ + +/* the following is needed for the system to build but will be removed +in the future, the value is not important but won't hurt +*/ +#define CLOCK_TICK_RATE (100 * HZ) + +#endif arch/arm/mach-zynq/include/mach/uart.h new file +25
-0@@ -0,0 +1,25 @@ +/* arch/arm/mach-zynq/include/mach/uart.h +* +* Copyright (C) 2011 Xilinx +* +* This software is licensed under the terms of the GNU General Public +* License version 2, as published by the Free Software Foundation, and +* may be copied, distributed, and modified under those terms. +* +* 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. +*/ + +#ifndef __MACH_UART_H__ +#define __MACH_UART_H__ + +#define UART_CR_OFFSET 0x00/* Control Register [8:0] */ +#define UART_SR_OFFSET 0x2C/* Channel Status [11:0] */ +#define UART_FIFO_OFFSET 0x30/* FIFO [15:0] or [7:0] */ + +#define UART_SR_TXFULL 0x00000010/* TX FIFO full */ +#define UART_SR_TXEMPTY 0x00000008/* TX FIFO empty */ + +#endif arch/arm/mach-zynq/include/mach/uncompress.h new file +51
-0@@ -0,0 +1,51 @@ +/* arch/arm/mach-zynq/include/mach/uncompress.h +* +* Copyright (C) 2011 Xilinx +* +* This software is licensed under the terms of the GNU General Public +* License version 2, as published by the Free Software Foundation, and +* may be copied, distributed, and modified under those terms. +* +* 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. +*/ + +#ifndef __MACH_UNCOMPRESS_H__ +#define __MACH_UNCOMPRESS_H__ + +#include <linux/io.h> +#include <asm/processor.h> +#include <mach/zynq_soc.h> +#include <mach/uart.h> + +void arch_decomp_setup (void ) +{ +} + +static inline void flush (void ) +{ +/* +* Wait while the FIFO is not empty +*/ +while (!(__raw_readl (IOMEM (LL_UART_PADDR +UART_SR_OFFSET )) & +UART_SR_TXEMPTY )) +cpu_relax (); +} + +#define arch_decomp_wdog () + +static void putc (char ch) +{ +/* +* Wait for room in the FIFO, then write the char into the FIFO +*/ +while (__raw_readl (IOMEM (LL_UART_PADDR +UART_SR_OFFSET )) & +UART_SR_TXFULL ) +cpu_relax (); + +__raw_writel (ch,IOMEM (LL_UART_PADDR +UART_FIFO_OFFSET )); +} + +#endif arch/arm/mach-zynq/include/mach/vmalloc.h new file +20
-0@@ -0,0 +1,20 @@ +/* arch/arm/mach-zynq/include/mach/vmalloc.h +* +* Copyright (C) 2011 Xilinx +* +* This software is licensed under the terms of the GNU General Public +* License version 2, as published by the Free Software Foundation, and +* may be copied, distributed, and modified under those terms. +* +* 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. +*/ + +#ifndef __MACH_VMALLOC_H__ +#define __MACH_VMALLOC_H__ + +#define VMALLOC_END 0xE0000000UL + +#endif arch/arm/mach-zynq/include/mach/zynq_soc.h new file +8
-0@@ -0,0 +1,48 @@ +/* arch/arm/mach-zynq/include/mach/zynq_soc.h +* +* Copyright (C) 2011 Xilinx +* +* This software is licensed under the terms of the GNU General Public +* License version 2, as published by the Free Software Foundation, and +* may be copied, distributed, and modified under those terms. +*
arch/arm/mach-zynq/include/mach/zynq_soc.h line 18
Quoted 10 lines
arch/arm/mach-zynq/include/mach/zynq_soc.h new file +10
-0+* 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. +*/ + +#ifndef __MACH_XILINX_SOC_H__ +#define __MACH_XILINX_SOC_H__ + +#define PERIPHERAL_CLOCK_RATE 2500000
I think this should be moved to DTS too.
arch/arm/mach-zynq/include/mach/zynq_soc.h line 23
Quoted 5 lines
arch/arm/mach-zynq/include/mach/zynq_soc.h new file +5
-0+ +/* For now, all mappings are flat (physical = virtual) +*/ +#define UART0_PHYS 0xE0000000 +#define UART0_VIRT UART0_PHYS
I am not quite sure if is depend entirely on DTS. Why is here physical uart address? I don't know how you handle DT in arm but seems to me that the whole io_desc structure should go away too.
Michal
Signature · 4 lines
Michal Simek, Ing. (M.Eng) w: www.monstr.eu p: +42-0-721842854 Maintainer of Linux kernel 2.6 Microblaze Linux - http://www.monstr.eu/fdt/ Microblaze U-BOOT custodian
Re: [RFC PATCH 4/4] ARM: Xilinx: Adding Xilinx board support
In reply to Grant LikelyQuoted 7 lines · On Monday 02 May 2011 07:08:00 Grant Likely wrote:
The 1st board support is minimal to get a system up and running on the Xilinx platform.
This platform reuses the clock implementation from plat-versatile, and it depends entirely on
CONFIG_OFsupport. There is only one board support file which obtains all device information from a device tree dtb file which is passed to the kernel at boot time.
Very cool stuff!
arch/arm/boot/dts/zynq-ep107.dts line 36
Quoted 6 lines
arch/arm/boot/dts/zynq-ep107.dts new file +6
-0+ + amba { + compatible = "simple-bus"; + #address-cells = <1>; + #size-cells = <1>; + ranges;
Shouldn't we have a way to identify amba buses by the compatible property as well, rather than only declaring it simple-bus?
We might be able to do some more automatic probing in the amba code in cases where the architected registers are actually filled with meaningful data there.
Is the empty ranges property technically correct? Excuse my poor knowledge of amba, but I would have assumed that only a range of addresses is actually put on the bus, while others (e.g. RAM) are not visible on AMBA.
Quoted 25 lines
arch/arm/mach-zynq/common.c new file +25
-0+static struct of_device_id zynq_of_bus_ids[]__initdata = { + { .compatible ="simple-bus" , }, + {} +}; + +static struct of_device_id gic_match[] = { + { .compatible ="arm,gic" , }, + {} +}; + +/** +* xilinx_init_machine() - System specific initialization, intended to be +* called from board specific initialization. +*/ +void __init xilinx_init_machine (void ) +{ +struct device_node *node =of_find_matching_node (NULL , gic_match); + +if (node) +of_irq_domain_add_simple (node,0 ,NR_IRQS ); + +#ifdef CONFIG_CACHE_L2X0 +/* +* 64KB way size, 8-way associativity, parity disabled +*/
arch/arm/mach-zynq/common.c line 71
Quoted 10 lines
arch/arm/mach-zynq/common.c new file +10
-0+l2x0_init (PL310_L2CC_BASE ,0x02060000 ,0xF0F0FFFF ); +#endif + +/** +* xilinx_irq_init() - Interrupt controller initialization for the GIC. +*/ +void __init xilinx_irq_init (void ) +{ +gic_init (0 ,29 ,SCU_GIC_DIST_BASE ,SCU_GIC_CPU_BASE ); +}
I think we can do better than this, there is still more hardcoded stuff in here than I think should be. I understand that you tried to minimize the size of the patch set for obvious reasons, but none of this seems too board specific to put into common code in one way or another.
Of course we can not fix all of this at once, but maybe we can have an explanation for each hardcoded setting on why it is still needed and what would have to be done to make it go away.
Quoted 11 lines
arch/arm/mach-zynq/common.c new file +11
-0+/* The minimum devices needed to be mapped before the VM system is up and +* running include the GIC, UART and Timer Counter. +*/ + +static struct map_desc io_desc[]__initdata = { + { + .virtual =TTC0_VIRT , + .pfn =__phys_to_pfn (TTC0_PHYS ), + .length =SZ_4K , + .type =MT_DEVICE , + }, {
arch/arm/mach-zynq/common.c line 93
Quoted 10 lines
arch/arm/mach-zynq/common.c new file +10
-0+ .virtual = SCU_PERIPH_VIRT, + .pfn = __phys_to_pfn(SCU_PERIPH_PHYS), + .length = SZ_8K, + .type = MT_DEVICE, + }, { + .virtual = PL310_L2CC_VIRT, + .pfn = __phys_to_pfn(PL310_L2CC_PHYS), + .length = SZ_4K, + .type = MT_DEVICE, + },
I especially dislike the idea of having to set up iotables, these seem completely counterintuitive when we probe the devices from the device tree.
AFAICT, all of init_irq, time_init and init_machine are called way after mm_init, so you should have ioremap available by the time you need to access these virtual memory ranges.
I can understand why you'd want to special-case PCI I/O space windows and early serial port access, but I think we should handle them differently and give them fixed machine independent virtual addresses.
arch/arm/mach-zynq/include/mach/vmalloc.h
Quoted 12 lines
arch/arm/mach-zynq/include/mach/io.h new file +0
-0arch/arm/mach-zynq/include/mach/irqs.h new file +0
-0arch/arm/mach-zynq/include/mach/memory.h new file +0
-0arch/arm/mach-zynq/include/mach/system.h new file +0
-0arch/arm/mach-zynq/include/mach/timex.h new file +0
-0arch/arm/mach-zynq/include/mach/vmalloc.h new file +0
-0
These are all either completely generic versions that could be reused on a number of other machines, or they could be turned into such files.
For the global inlude/asm-generic files, we have just added a mechanism to share that kind of file across multiple architectures using some Makefile magic. Should we perhaps do something similar here to avoid having to create more of the same files?
arch/arm/mach-zynq/include/mach/uncompress.h
Quoted 4 lines
arch/arm/mach-zynq/include/mach/uart.h new file +0
-0arch/arm/mach-zynq/include/mach/uncompress.h new file +0
-0
For these, it obviously won't work.
arch/arm/mach-zynq/timer.c
Quoted 5 lines
arch/arm/mach-zynq/timer.c new file +0
-0
In the light of the recent discussions of drivers moving out of platforms into common Linux code, do we expect this to also happen to timers any time soon?
Arnd
Re: [RFC PATCH 4/4] ARM: Xilinx: Adding Xilinx board support
Quoted 21 lines · Arnd Bergmann
Quoted 7 lines · On Monday 02 May 2011 07:08:00 Grant Likely wrote:
The 1st board support is minimal to get a system up and running on the Xilinx platform.
This platform reuses the clock implementation from plat-versatile, and it depends entirely on
CONFIG_OFsupport. There is only one board support file which obtains all device information from a device tree dtb file which is passed to the kernel at boot time.Very cool stuff!
arch/arm/boot/dts/zynq-ep107.dts line 36
Quoted 6 lines
arch/arm/boot/dts/zynq-ep107.dts new file +6
-0+ + amba { + compatible = "simple-bus"; + #address-cells =<1>; + #size-cells =<1>; + ranges;Shouldn't we have a way to identify amba buses by the compatible property as well, rather than only declaring it simple-bus?
Quoted 4 lines
We might be able to do some more automatic probing in the amba code in cases where the architected registers are actually filled with meaningful data there.
Typically, I don't think anything but ARM's Primecell peripherals have registers for probing. The GIC and PL310 don't have them.
However, this is what was used for an early version of the versatile dts:
compatible = "arm,amba-bus";
Quoted 46 lines
Is the empty ranges property technically correct? Excuse my poor knowledge of amba, but I would have assumed that only a range of addresses is actually put on the bus, while others (e.g. RAM) are not visible on AMBA.
Quoted 25 lines
arch/arm/mach-zynq/common.c new file +25
-0+static struct of_device_id zynq_of_bus_ids[]__initdata = { + { .compatible ="simple-bus" , }, + {} +}; + +static struct of_device_id gic_match[] = { + { .compatible ="arm,gic" , }, + {} +}; + +/** +* xilinx_init_machine() - System specific initialization, intended to be +* called from board specific initialization. +*/ +void __init xilinx_init_machine (void ) +{ +struct device_node *node =of_find_matching_node (NULL , gic_match); + +if (node) +of_irq_domain_add_simple (node,0 ,NR_IRQS ); + +#ifdef CONFIG_CACHE_L2X0 +/* +* 64KB way size, 8-way associativity, parity disabled +*/ arch/arm/mach-zynq/common.c line 71
Quoted 10 lines
arch/arm/mach-zynq/common.c new file +10
-0+l2x0_init (PL310_L2CC_BASE ,0x02060000 ,0xF0F0FFFF ); +#endif + +/** +* xilinx_irq_init() - Interrupt controller initialization for the GIC. +*/ +void __init xilinx_irq_init (void ) +{ +gic_init (0 ,29 ,SCU_GIC_DIST_BASE ,SCU_GIC_CPU_BASE ); +}I think we can do better than this, there is still more hardcoded stuff in here than I think should be. I understand that you tried to minimize the size of the patch set for obvious reasons, but none of this seems too board specific to put into common code in one way or another.
Quoted 3 lines
Of course we can not fix all of this at once, but maybe we can have an explanation for each hardcoded setting on why it is still needed and what would have to be done to make it go away.
The SCU base address is probe-able:
/* Get SCU base */
asm("mrc p15, 4, %0, c15, c0, 0" : "=r" (base));However, this is specific to the A9 and not an SCU feature.
Quoted 27 lines
Quoted 12 lines
arch/arm/mach-zynq/common.c new file +11
-0+/* The minimum devices needed to be mapped before the VM system is up and +* running include the GIC, UART and Timer Counter. +*/ + +static struct map_desc io_desc[]__initdata = { + { + .virtual =TTC0_VIRT , + .pfn =__phys_to_pfn (TTC0_PHYS ), + .length =SZ_4K , + .type =MT_DEVICE , + }, {arch/arm/mach-zynq/common.c line 93
Quoted 10 lines
arch/arm/mach-zynq/common.c new file +10
-0+ .virtual = SCU_PERIPH_VIRT, + .pfn = __phys_to_pfn(SCU_PERIPH_PHYS), + .length = SZ_8K, + .type = MT_DEVICE, + }, { + .virtual = PL310_L2CC_VIRT, + .pfn = __phys_to_pfn(PL310_L2CC_PHYS), + .length = SZ_4K, + .type = MT_DEVICE, + },I especially dislike the idea of having to set up iotables, these seem completely counterintuitive when we probe the devices from the device tree.
Quoted 4 lines
AFAICT, all of
init_irq,time_initandinit_machineare called way aftermm_init, so you should have ioremap available by the time you need to access these virtual memory ranges.
The SCU is accessed before ioremap is up. The only reason it is accessed early is to determine the number of cores present.
The L2 can certainly be ioremapped and probed via DT. How about something like this:
l2cc {
compatible = "arm,pl310-l2";
reg = <0xfff12000 0x1000>;
aux-value = <0>;
aux-mask = <0xffffffff>;
};Rob
Re: [RFC PATCH 4/4] ARM: Xilinx: Adding Xilinx board support
Quoted 2 lines · Rob Herring
The SCU is accessed before ioremap is up. The only reason it is accessed early is to determine the number of cores present.
The number of cores should definitely be available in the device tree, normally by looking at the root interrupt controller.
Quoted 9 lines
The L2 can certainly be ioremapped and probed via DT. How about something like this:
l2cc { compatible = "arm,pl310-l2"; reg = <0xfff12000 0x1000>; aux-value = <0>; aux-mask = <0xffffffff>; };
sounds good to me.
Arnd