ARM: CSR: Adding CSR SiRFprimaII board support
Subsystems (3)
PATCH 1/1 ARM: CSR: Adding CSR SiRFprimaII board support
From: Binghua Duan <[email protected]>
SiRFprimaII is the latest generation application processor from CSR?s Multifunction SoC product family. Designed around an ARM cortex A9 core, high-speed memory bus, advanced 3D accelerator and full-HD multi-format video decoder, SiRFprimaII is able to meet the needs of complicated applications for modern multifunction devices that require heavy concurrent applications and fluid user experience. Integrated with GPS baseband, analog and PMU, this new platform is designed to provide a cost effective solution for Automotive and Consumer markets.
This patch adds the basic support for this SoC and EVB board based on device tree. It is following the ZYNQ of Grant Likely in some degree.
--- arch/arm/Kconfig | 13 + arch/arm/Makefile | 1 + arch/arm/boot/dts/prima2-cb.dts | 44 +++ arch/arm/mach-prima2/Makefile | 1 + arch/arm/mach-prima2/Makefile.boot | 3 + arch/arm/mach-prima2/board_dt.c | 28 ++ arch/arm/mach-prima2/clock.c | 474 +++++++++++++++++++++++ arch/arm/mach-prima2/common.c | 81 ++++ arch/arm/mach-prima2/common.h | 23 ++ arch/arm/mach-prima2/include/mach/clkdev.h | 15 + arch/arm/mach-prima2/include/mach/debug-macro.S | 29 ++ arch/arm/mach-prima2/include/mach/entry-macro.S | 28 ++ arch/arm/mach-prima2/include/mach/hardware.h | 15 + arch/arm/mach-prima2/include/mach/io.h | 17 + arch/arm/mach-prima2/include/mach/irqs.h | 17 + arch/arm/mach-prima2/include/mach/isa-dma.h | 14 + arch/arm/mach-prima2/include/mach/map.h | 49 +++ arch/arm/mach-prima2/include/mach/memory.h | 21 + arch/arm/mach-prima2/include/mach/system.h | 27 ++ arch/arm/mach-prima2/include/mach/timex.h | 14 + arch/arm/mach-prima2/include/mach/uart.h | 18 + arch/arm/mach-prima2/include/mach/uncompress.h | 42 ++ arch/arm/mach-prima2/include/mach/vmalloc.h | 14 + arch/arm/mach-prima2/irq.c | 81 ++++ arch/arm/mach-prima2/timer.c | 181 +++++++++ arch/arm/mm/Kconfig | 2 +- 26 files changed, 1251 insertions(+), 1 deletions(-) create mode 100644 arch/arm/boot/dts/prima2-cb.dts create mode 100644 arch/arm/mach-prima2/Makefile create mode 100644 arch/arm/mach-prima2/Makefile.boot create mode 100644 arch/arm/mach-prima2/board_dt.c create mode 100644 arch/arm/mach-prima2/clock.c create mode 100644 arch/arm/mach-prima2/common.c create mode 100644 arch/arm/mach-prima2/common.h create mode 100644 arch/arm/mach-prima2/include/mach/clkdev.h create mode 100644 arch/arm/mach-prima2/include/mach/debug-macro.S create mode 100644 arch/arm/mach-prima2/include/mach/entry-macro.S create mode 100644 arch/arm/mach-prima2/include/mach/hardware.h create mode 100644 arch/arm/mach-prima2/include/mach/io.h create mode 100644 arch/arm/mach-prima2/include/mach/irqs.h create mode 100644 arch/arm/mach-prima2/include/mach/isa-dma.h create mode 100644 arch/arm/mach-prima2/include/mach/map.h create mode 100644 arch/arm/mach-prima2/include/mach/memory.h create mode 100644 arch/arm/mach-prima2/include/mach/system.h create mode 100644 arch/arm/mach-prima2/include/mach/timex.h create mode 100644 arch/arm/mach-prima2/include/mach/uart.h create mode 100644 arch/arm/mach-prima2/include/mach/uncompress.h create mode 100644 arch/arm/mach-prima2/include/mach/vmalloc.h create mode 100644 arch/arm/mach-prima2/irq.c create mode 100644 arch/arm/mach-prima2/timer.c
arch/arm/Kconfig +13 -0
@@ -879,6 +879,19 @@ config ARCH_VT8500 select HAVE_PWM help Support for VIA/WonderMedia VT8500/WM85xx System-on-Chip. + +config ARCH_PRIMA2 + bool "CSR SiRFSoC PRIMA2 ARM Cortex A9 Platform" + select CPU_V7 + select GENERIC_TIME + select GENERIC_CLOCKEVENTS + select CLKDEV_LOOKUP + select USE_OF + select ISA_DMA_API + select ZONE_DMA + help + Support for CSR SiRFSoC ARM Cortex A9 Platform + endchoice #
arch/arm/Makefile +1 -0
@@ -191,6 +191,7 @@ machine-$(CONFIG_ARCH_VEXPRESS) := vexpress machine-$(CONFIG_ARCH_VT8500) := vt8500 machine-$(CONFIG_ARCH_W90X900) := w90x900 machine-$(CONFIG_ARCH_NUC93X) := nuc93x +machine-$(CONFIG_ARCH_PRIMA2) := prima2 machine-$(CONFIG_FOOTBRIDGE) := footbridge machine-$(CONFIG_MACH_SPEAR300) := spear3xx machine-$(CONFIG_MACH_SPEAR310) := spear3xx
arch/arm/boot/dts/prima2-cb.dts new file +44 -0
44 lines not on this page · raw message
arch/arm/mach-prima2/Makefile new file +1 -0
@@ -0,0 +1 @@ +obj-y := timer.o irq.o clock.o common.o board_dt.o
arch/arm/mach-prima2/Makefile.boot new file +3 -0
@@ -0,0 +1,3 @@ +zreladdr-y := 0x00008000 +params_phys-y := 0x00000100 +initrd_phys-y := 0x00800000
arch/arm/mach-prima2/board_dt.c new file +28 -0
@@ -0,0 +1,28 @@ +/* +* This file contains code for boards with device tree support. +* +* Copyright (c) 2011 Cambridge Silicon Radio Limited, a CSR plc group company. +* +* Licensed under GPLv2 or later. +*/ + +#include <linux/of.h> +#include <asm/mach/arch.h> +#include <asm/mach-types.h> +#include <mach/hardware.h> +#include "common.h" + +static const char *prima2cb_dt_match[]__initdata = { +"sirf,prima2-cb" , +NULL +}; + +MACHINE_START (PRIMA2_EVB ,"prima2cb" ) + .boot_params = SIRFSOC_SDRAM_PA + 0x100, + .init_early = sirfsoc_init_clk, + .map_io = sirfsoc_map_io, + .init_irq = sirfsoc_init_irq, + .timer = &sirfsoc_timer, + .init_machine = sirfsoc_mach_init, + .dt_compat = prima2cb_dt_match, +MACHINE_END
arch/arm/mach-prima2/clock.c new file +474 -0
474 lines not on this page · raw message
arch/arm/mach-prima2/common.c new file +81 -0
81 lines not on this page · raw message
arch/arm/mach-prima2/common.h new file +23 -0
@@ -0,0 +1,23 @@ +/* +* This file contains common function prototypes to avoid externs in the c files. +* +* Copyright (c) 2011 Cambridge Silicon Radio Limited, a CSR plc group company. +* +* Licensed under GPLv2 or later. +*/ + +#ifndef __MACH_PRIMA2_COMMON_H__ +#define __MACH_PRIMA2_COMMON_H__ + +#include <linux/init.h> +#include <asm/mach/time.h> + +extern struct sys_timer sirfsoc_timer; + +extern void __init sirfsoc_init_io (void ); +extern void __init sirfsoc_map_io (void ); +extern void __init sirfsoc_mach_init (void ); +extern void sirfsoc_init_irq (void ); +extern void __init sirfsoc_init_clk (void ); + +#endif
arch/arm/mach-prima2/include/mach/clkdev.h new file +15 -0
@@ -0,0 +1,15 @@ +/* +* arch/arm/mach-prima2/include/mach/clkdev.h +* +* Copyright (c) 2011 Cambridge Silicon Radio Limited, a CSR plc group company. +* +* Licensed under GPLv2 or later. +*/ + +#ifndef __MACH_CLKDEV_H +#define __MACH_CLKDEV_H + +#define __clk_get (clk) ({ 1; }) +#define __clk_put (clk) do { } while (0) + +#endif
arch/arm/mach-prima2/include/mach/debug-macro.S new file +29 -0
@@ -0,0 +1,29 @@ +/* + * arch/arm/mach-prima2/include/mach/debug-macro.S + * + * Copyright (c) 2011 Cambridge Silicon Radio Limited, a CSR plc group company. + * + * Licensed under GPLv2 or later. + */ + +#include <mach/hardware.h> +#include <mach/uart.h> + + .macro addruart, rp, rv + ldr \rp, =SIRFSOC_UART1_PA_BASE @ physical + ldr \rv, =SIRFSOC_UART1_VA_BASE @ virtual + .endm + + .macro senduart,rd,rx + str \rd, [\rx, #SIRFSOC_UART_TXFIFO_DATA] + .endm + + .macro busyuart,rd,rx + .endm + + .macro waituart,rd,rx +1001: ldr \rd, [\rx, #SIRFSOC_UART_TXFIFO_STATUS] + tst \rd, #SIRFSOC_UART1_TXFIFO_EMPTY + beq 1001b + .endm +
arch/arm/mach-prima2/include/mach/entry-macro.S new file +28 -0
@@ -0,0 +1,28 @@ +/* + * arch/arm/mach-prima2/include/mach/entry-macro.S + * + * Copyright (c) 2011 Cambridge Silicon Radio Limited, a CSR plc group company. + * + * Licensed under GPLv2 or later. + */ + +#include <mach/hardware.h> + +#define SIRFSOC_INT_ID 0x38 + + .macro get_irqnr_and_base, irqnr, irqstat, base, tmp + ldr \base, =SIRFSOC_INTR_VA_BASE + ldr \irqnr, [\base, #SIRFSOC_INT_ID] @ Get the highest priority irq + cmp \irqnr, #0x40 @ the irq num can't be larger than 0x3f + movges \irqnr, #0 + .endm + + .macro disable_fiq + .endm + + .macro get_irqnr_preamble, base, tmp + .endm + + .macro arch_ret_to_user, tmp1, tmp2 + .endm +
arch/arm/mach-prima2/include/mach/hardware.h new file +15 -0
@@ -0,0 +1,15 @@ +/* +* arch/arm/mach-prima2/include/mach/hardware.h +* +* Copyright (c) 2011 Cambridge Silicon Radio Limited, a CSR plc group company. +* +* Licensed under GPLv2 or later. +*/ + +#ifndef __MACH_HARDWARE_H__ +#define __MACH_HARDWARE_H__ + +#include <asm/sizes.h> +#include <mach/map.h> + +#endif
arch/arm/mach-prima2/include/mach/io.h new file +17 -0
@@ -0,0 +1,17 @@ +/* +* arch/arm/mach-prima2/include/mach/io.h +* +* Copyright (c) 2011 Cambridge Silicon Radio Limited, a CSR plc group company. +* +* Licensed under GPLv2 or later. +*/ + +#ifndef __MACH_PRIMA2_IO_H +#define __MACH_PRIMA2_IO_H + +#define IO_SPACE_LIMIT 0xffffffff + +#define __mem_pci (x) (x) +#define __io (a) ((void __iomem *)(a)) + +#endif
arch/arm/mach-prima2/include/mach/irqs.h new file +17 -0
@@ -0,0 +1,17 @@ +/* +* arch/arm/mach-prima2/include/mach/irqs.h +* +* Copyright (c) 2011 Cambridge Silicon Radio Limited, a CSR plc group company. +* +* Licensed under GPLv2 or later. +*/ + +#ifndef __ASM_ARCH_IRQS_H +#define __ASM_ARCH_IRQS_H + +#define SIRFSOC_INTENAL_IRQ_START 0 +#define SIRFSOC_INTENAL_IRQ_END 59 + +#define NR_IRQS 220 + +#endif
arch/arm/mach-prima2/include/mach/isa-dma.h new file +14 -0
@@ -0,0 +1,14 @@ +/* +* arch/arm/mach-prima2/include/mach/io.h +* +* Copyright (c) 2011 Cambridge Silicon Radio Limited, a CSR plc group company. +* +* Licensed under GPLv2 or later. +*/ + +#ifndef __MACH_PRIMA2_ISADMA_H +#define __MACH_PRIMA2_ISADMA_H + +#define MAX_DMA_CHANNELS 32 + +#endif
arch/arm/mach-prima2/include/mach/map.h new file +49 -0
49 lines not on this page · raw message
arch/arm/mach-prima2/include/mach/memory.h new file +21 -0
@@ -0,0 +1,21 @@ +/* +* arch/arm/mach-prima2/include/mach/memory.h +* +* Copyright (c) 2010 ? 2011 Cambridge Silicon Radio Limited, a CSR plc group company. +* +* Licensed under GPLv2 or later. +*/ + +#ifndef __ASM_ARCH_MEMORY_H +#define __ASM_ARCH_MEMORY_H + +#define PLAT_PHYS_OFFSET UL(0x00000000) + +/* +* Restrict DMA-able region to workaround silicon limitation. +* The limitation restricts buffers available for DMA to SD/MMC +* hardware to be below 256MB +*/ +#define ARM_DMA_ZONE_SIZE (SZ_256M) + +#endif
arch/arm/mach-prima2/include/mach/system.h new file +27 -0
@@ -0,0 +1,27 @@ +/* +* arch/arm/mach-prima2/include/mach/system.h +* +* Copyright (c) 2011 Cambridge Silicon Radio Limited, a CSR plc group company. +* +* Licensed under GPLv2 or later. +*/ + +#ifndef __MACH_SYSTEM_H__ +#define __MACH_SYSTEM_H__ + +#include <linux/bitops.h> +#include <mach/hardware.h> + +#define SIRFSOC_SYS_RST_BIT BIT(31) + +static inline void arch_idle (void ) +{ +cpu_do_idle (); +} + +static inline void arch_reset (char mode,const char *cmd) +{ +writel (SIRFSOC_SYS_RST_BIT ,SIRFSOC_RSTC_VA_BASE ); +} + +#endif
arch/arm/mach-prima2/include/mach/timex.h new file +14 -0
@@ -0,0 +1,14 @@ +/* +* arch/arm/mach-prima2/include/mach/timex.h +* +* Copyright (c) 2011 Cambridge Silicon Radio Limited, a CSR plc group company. +* +* Licensed under GPLv2 or later. +*/ + +#ifndef __MACH_TIMEX_H__ +#define __MACH_TIMEX_H__ + +#define CLOCK_TICK_RATE (100 * HZ) + +#endif
arch/arm/mach-prima2/include/mach/uart.h new file +18 -0
@@ -0,0 +1,18 @@ +/* +* arch/arm/mach-prima2/include/mach/uart.h +* +* Copyright (c) 2011 Cambridge Silicon Radio Limited, a CSR plc group company. +* +* Licensed under GPLv2 or later. +*/ + +#ifndef __MACH_PRIMA2_SIRFSOC_UART_H +#define __MACH_PRIMA2_SIRFSOC_UART_H + +#define SIRFSOC_UART_TXFIFO_STATUS 0x0114 +#define SIRFSOC_UART_TXFIFO_DATA 0x0118 + +#define SIRFSOC_UART1_TXFIFO_FULL (1 << 5) +#define SIRFSOC_UART1_TXFIFO_EMPTY (1 << 6) + +#endif
arch/arm/mach-prima2/include/mach/uncompress.h new file +42 -0
42 lines not on this page · raw message
arch/arm/mach-prima2/include/mach/vmalloc.h new file +14 -0
@@ -0,0 +1,14 @@ +/* +* arch/arm/ach-prima2/include/mach/vmalloc.h +* +* Copyright (c) 2010 ? 2011 Cambridge Silicon Radio Limited, a CSR plc group company. +* +* Licensed under GPLv2 or later. +*/ + +#ifndef __MACH_VMALLOC_H +#define __MACH_VMALLOC_H + +#define VMALLOC_END 0xFEC00000 + +#endif
arch/arm/mach-prima2/irq.c new file +81 -0
81 lines not on this page · raw message
arch/arm/mach-prima2/timer.c new file +181 -0
181 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_PRIMA2 default y select OUTER_CACHE select OUTER_CACHE_SYNC
Signature · 6 lines
1.7.1 Member of the CSR plc group of companies. CSR plc registered in England and Wales, registered number 4187346, registered office Churchill House, Cambridge Business Park, Cowley Road, Cambridge, CB4 0WZ, United Kingdom More information can be found at www.csr.com. Follow CSR on Twitter at http://twitter.com/CSR_PLC and read our [email protected]/blog
PATCH 1/1 ARM: CSR: Adding CSR SiRFprimaII board support
Quoted 11 lines · Barry Song
From: Binghua Duan <[email protected]>
SiRFprimaII is the latest generation application processor from CSR?s Multifunction SoC product family. Designed around an ARM cortex A9 core, high-speed memory bus, advanced 3D accelerator and full-HD multi-format video decoder, SiRFprimaII is able to meet the needs of complicated applications for modern multifunction devices that require heavy concurrent applications and fluid user experience. Integrated with GPS baseband, analog and PMU, this new platform is designed to provide a cost effective solution for Automotive and Consumer markets.
Quoted 2 lines
This patch adds the basic support for this SoC and EVB board based on device tree. It is following the ZYNQ of Grant Likely in some degree.
Hi Binghua and Barry,
Your platform looks pretty good already, it's good to see that you are progressing so well with the conversion to device tree.
Quoted 39 lines
arch/arm/boot/dts/prima2-cb.dts new file +33
-0@@ -0,0 +1,44 @@ +/dts-v1/; +/ { + model = "SIRF Prima2 EVB"; + compatible = "sirf,prima2-cb", "sirf,prima2"; + #address-cells = <1>; + #size-cells = <1>; + interrupt-parent = <&intc>; + + memory { + reg = <0x00000000 0x20000000>; + }; + + chosen { + bootargs = "mem=512M real_root=/dev/mmcblk0p2 console=ttyS1 earlyprintk"; + linux,stdout-path = &uart1; + }; + + amba { + compatible = "simple-bus"; + #address-cells = <1>; + #size-cells = <1>; + ranges; + + intc: interrupt-controller at 0x80020000 { + interrupt-controller; + compatible = "arm,sirfsoc"; + reg = <0x80020000 0x1000>; + #interrupt-cells = <1>; + }; + + uart0: uart at 0xb0050000 { + compatible = "sirf,uart"; + reg = <0xb0050000 0x1000>;
arch/arm/boot/dts/prima2-cb.dts line 43
Quoted 10 lines
arch/arm/boot/dts/prima2-cb.dts new file +10
-0+ interrupts = <17>; + }; + + uart1: uart at 0xb0060000 { + compatible = "sirf,uart"; + reg = <0xb0060000 0x1000>; + interrupts = <18>; + }; + }; +};
The "compatible" properties should really be more specific than this. You can list multiple alternatives in there, but please always have one that identifies the exact version of each of the macros uniquely.
Please also model the device hierarchy as close as possible to the high-level block diagrams in the data sheet. I would e.g. expect this to have multiple AMBA buses, one at 0x80000000 and one at 0xb0000000, so just define them separately with a ranges property describing the location of the bus in the address space, and put the child devices at relative addresses to that.
I would also recommend listing all devices in the device tree here, even if the drivers are not yet ported.
Regarding the interrupt and timer drivers, there has been some discussion about moving them to drivers/irq and drivers/clocksource, respectively.
arch/arm/mach-prima2/clock.c
Quoted 5 lines
arch/arm/mach-prima2/clock.c new file +0
-0
I can't really comment on the clock support. A lot has changed here recently, so I hope someone else can comment.
Quoted 50 lines
arch/arm/mach-prima2/clock.c new file +49
-0+#define IOTABLE_ENTRY (region) {\ + .virtual = SIRFSOC_##region##_VA_BASE, \ + .pfn = __phys_to_pfn(SIRFSOC_##region##_PA_BASE),\ + .length = SIRFSOC_##region##_SIZE, \ + .type = MT_DEVICE, \ +} + +static struct map_desc sirfsoc_iodesc[]__initdata = { +IOTABLE_ENTRY (INTR ), +IOTABLE_ENTRY (UART1 ), +IOTABLE_ENTRY (TIMER ), +IOTABLE_ENTRY (CLOCK ), +#ifdef CONFIG_CACHE_L2X0 +IOTABLE_ENTRY (L2CC ), +#endif +}; + +void __init sirfsoc_map_io (void ) +{ +iotable_init (sirfsoc_iodesc,ARRAY_SIZE (sirfsoc_iodesc)); +} + +#define L2X0_ADDR_FILTERING_START 0xC00 +#define L2X0_ADDR_FILTERING_END 0xC04 + +static int __init sirfsoc_init (void ) +{ +#ifdef CONFIG_CACHE_L2X0 +if (!(readl_relaxed (SIRFSOC_L2CC_VA_BASE +L2X0_CTRL ) &1 )) { +/* +* set the physical memory windows L2 cache will cover +*/ +writel_relaxed (PHYS_OFFSET +1024 *1024 *1024 , +SIRFSOC_L2CC_VA_BASE +L2X0_ADDR_FILTERING_END ); +writel_relaxed (PHYS_OFFSET |0x1 , +SIRFSOC_L2CC_VA_BASE +L2X0_ADDR_FILTERING_START ); + +writel_relaxed (0 , +SIRFSOC_L2CC_VA_BASE +L2X0_TAG_LATENCY_CTRL ); +writel_relaxed (0 , +SIRFSOC_L2CC_VA_BASE +L2X0_DATA_LATENCY_CTRL ); + } +l2x0_init ((void __iomem *)SIRFSOC_L2CC_VA_BASE ,0x00040000 , +0x00000000 ); +#endif + +return 0 ; +} +arch_initcall (sirfsoc_init);
arch/arm/mach-prima2/clock.c
Quoted 10 lines
arch/arm/mach-prima2/clock.c new file +9
-0+#ifndef __MACH_PRIMA2_IO_H +#define __MACH_PRIMA2_IO_H + +#define IO_SPACE_LIMIT 0xffffffff + +#define __mem_pci (x) (x) +#define __io (a) ((void __iomem *)(a)) + +#endif
This is broken for PCI I/O space windows. The same issue keeps coming up with every new platform, and I wish we could simply not have to define these.
Do you have any PCI or PCMCIA devices?
arch/arm/mach-prima2/include/mach/isa-dma.h line 14
Quoted 8 lines
arch/arm/mach-prima2/include/mach/isa-dma.h +7
-0+ +#ifndef __MACH_PRIMA2_ISADMA_H +#define __MACH_PRIMA2_ISADMA_H + +#define MAX_DMA_CHANNELS 32 + +#endif
Would it make sense to convert the DMA support on your platform to the more modern dmaengine API? The old ISA DMA API is showing its age, and will cause trouble when you want to support different DMA controllers in a single kernel.
Quoted 32 lines
arch/arm/mach-prima2/include/mach/map.h new file +27
-0+ +#define SIRFSOC_VA (x) (VMALLOC_END + ((x) & 0x00FFF000)) + +/* INTR */ +#define SIRFSOC_INTR_PA_BASE 0x80020000 +#define SIRFSOC_INTR_VA_BASE SIRFSOC_VA(0x002000) +#define SIRFSOC_INTR_SIZE SZ_4K + +/* L2 CACHE */ +#define SIRFSOC_L2CC_PA_BASE 0x80040000 +#define SIRFSOC_L2CC_VA_BASE SIRFSOC_VA(0x004000) +#define SIRFSOC_L2CC_SIZE SZ_4K + +/* CLOCK */ +#define SIRFSOC_CLOCK_PA_BASE 0x88000000 +#define SIRFSOC_CLOCK_VA_BASE SIRFSOC_VA(0x005000) +#define SIRFSOC_CLOCK_SIZE SZ_4K + +/* RESET CONTROLLER */ +#define SIRFSOC_RSTC_PA_BASE 0x88010000 +#define SIRFSOC_RSTC_VA_BASE SIRFSOC_VA(0x006000) +#define SIRFSOC_RSTC_SIZE SZ_4K + +/* OS TIMER */ +#define SIRFSOC_TIMER_PA_BASE 0xb0020000 +#define SIRFSOC_TIMER_VA_BASE SIRFSOC_VA(0x00c000) +#define SIRFSOC_TIMER_SIZE SZ_4K
arch/arm/mach-prima2/include/mach/map.h line 49
Quoted 10 lines
arch/arm/mach-prima2/include/mach/map.h new file +10
-0+ +/* UART-1: used as serial debug port */ +#define SIRFSOC_UART1_PA_BASE 0xb0060000 +#define SIRFSOC_UART1_VA_BASE SIRFSOC_VA(0x060000) +#define SIRFSOC_UART1_SIZE SZ_4K + +/* RAM BASE*/ +#define SIRFSOC_SDRAM_PA 0x00000000 + +#endif
I think these should all be converted into device tree properties if possible. Anything that can be initialized late enough should just do an ioremap at the time when you first need to access the registers.
For the L2 cache, Rob already posted a binding, so best work with him on that one.
arch/arm/mach-prima2/include/mach/map.h
Quoted 7 lines
arch/arm/mach-prima2/include/mach/map.h new file +7
-0+/* +* Restrict DMA-able region to workaround silicon limitation. +* The limitation restricts buffers available for DMA to SD/MMC +* hardware to be below 256MB +*/ +#define ARM_DMA_ZONE_SIZE (SZ_256M) +
This is very unfortunate, but I guess there is no real way to avoid doing this, right?
arch/arm/mach-prima2/include/mach/map.h
Quoted 8 lines
arch/arm/mach-prima2/include/mach/map.h new file +8
-0+static void sirfsoc_irq_mask (struct irq_data *d) +{ +unsigned long mask; + + mask =__raw_readl (SIRFSOC_INTR_VA_BASE +SIRFSOC_INT_RISC_MASK0 + (d->irq /32 ) *4 ) & + ~(1 << ( d->irq %32 )); +__raw_writel (mask,SIRFSOC_INTR_VA_BASE +SIRFSOC_INT_RISC_MASK0 + (d->irq /32 ) *4 ); +}
Better use readl_relaxed here than __raw_readl.
arch/arm/mach-prima2/include/mach/map.h
Quoted 9 lines
arch/arm/mach-prima2/include/mach/map.h new file +9
-0+/* timer0 interrupt handler */ +static irqreturn_t sirfsoc_timer_interrupt (int irq,void *dev_id) +{ +struct clock_event_device *ce = dev_id; + +WARN_ON (!(__raw_readl (SIRFSOC_TIMER_VA_BASE +SIRFSOC_TIMER_STATUS ) &BIT (0 ))); + +/* clear timer0 interrupt */ +__raw_writel (BIT (0 ),SIRFSOC_TIMER_VA_BASE +SIRFSOC_TIMER_STATUS );
Here, too.
Arnd
PATCH 1/1 ARM: CSR: Adding CSR SiRFprimaII board support
In reply to Barry SongSome comments inline, nothing really serious...
arch/arm/Kconfig config ARCH_VT8500 · line 890
Quoted 8 lines · Barry Song
arch/arm/Kconfig +8
-0+config ARCH_PRIMA2 + bool "CSR SiRFSoC PRIMA2 ARM Cortex A9 Platform" + select CPU_V7 + select GENERIC_TIME + select GENERIC_CLOCKEVENTS + select CLKDEV_LOOKUP + select USE_OF + select ISA_DMA_API
Do you really provide the old ISA DMA API? Unless you're intending to use existing ISA drivers with their ISA DMA, you shouldn't define this.
arch/arm/Makefile machine-$(CONFIG_ARCH_VEXPRESS) := vexpress · line 194
Quoted 9 lines
arch/arm/Makefile +1
-0@@ -191,6 +191,7 @@ machine-$(CONFIG_ARCH_VEXPRESS) := vexpress machine-$(CONFIG_ARCH_VT8500) := vt8500 machine-$(CONFIG_ARCH_W90X900) := w90x900 machine-$(CONFIG_ARCH_NUC93X) := nuc93x +machine-$(CONFIG_ARCH_PRIMA2) := prima2
The comment at the start of this list says:
# Machine directory name. This list is sorted alphanumerically
# by CONFIG_* macro name.
and I thank the NUC93x people for also missing it. Please ignore the NUC93x entry and place yours appropriately.
Quoted 14 lines
arch/arm/boot/dts/prima2-cb.dts new file +8
-0@@ -0,0 +1,44 @@ +/dts-v1/; +/ { + model = "SIRF Prima2 EVB"; + compatible = "sirf,prima2-cb", "sirf,prima2"; + #address-cells = <1>; + #size-cells = <1>; + interrupt-parent = <&intc>; +
arch/arm/boot/dts/prima2-cb.dts line 18
Quoted 10 lines
arch/arm/boot/dts/prima2-cb.dts new file +10
-0+ memory { + reg = <0x00000000 0x20000000>; + }; + + chosen { + bootargs = "mem=512M real_root=/dev/mmcblk0p2 console=ttyS1 earlyprintk"; + linux,stdout-path = &uart1; + }; + + amba {
You declare that you have an AMBA bus, does it have primcells on it? Should you be selecting ARM_AMBA in your kconfig?
Quoted 10 lines
arch/arm/mach-prima2/include/mach/entry-macro.S new file +4
-0@@ -0,0 +1,28 @@ +/* + * arch/arm/mach-prima2/include/mach/entry-macro.S + * + * Copyright (c) 2011 Cambridge Silicon Radio Limited, a CSR plc group company.
arch/arm/mach-prima2/include/mach/entry-macro.S line 14
Quoted 10 lines
arch/arm/mach-prima2/include/mach/entry-macro.S new file +10
-0+ * + * Licensed under GPLv2 or later. + */ + +#include <mach/hardware.h> + +#define SIRFSOC_INT_ID 0x38 + + .macro get_irqnr_and_base, irqnr, irqstat, base, tmp + ldr \base, =SIRFSOC_INTR_VA_BASE
Consider using get_irqnr_preamble to load the base address only once per IRQ exception.
Quoted 10 lines
arch/arm/mach-prima2/include/mach/isa-dma.h new file +4
-0@@ -0,0 +1,14 @@ +/* +* arch/arm/mach-prima2/include/mach/io.h +* +* Copyright (c) 2011 Cambridge Silicon Radio Limited, a CSR plc group company.
arch/arm/mach-prima2/include/mach/isa-dma.h line 14
Quoted 10 lines
arch/arm/mach-prima2/include/mach/isa-dma.h new file +10
-0+* +* Licensed under GPLv2 or later. +*/ + +#ifndef __MACH_PRIMA2_ISADMA_H +#define __MACH_PRIMA2_ISADMA_H + +#define MAX_DMA_CHANNELS 32 + +#endif
You don't need this if you don't define ISA_DMA_API.
Quoted 12 lines
arch/arm/mach-prima2/include/mach/uncompress.h new file +6
-0@@ -0,0 +1,42 @@ +/* +* arch/arm/mach-prima2/include/mach/uncompress.h +* +* Copyright (c) 2011 Cambridge Silicon Radio Limited, a CSR plc group company. +* +* Licensed under GPLv2 or later.
arch/arm/mach-prima2/include/mach/uncompress.h line 16
Quoted 10 lines
arch/arm/mach-prima2/include/mach/uncompress.h new file +10
-0+*/ + +#ifndef __ASM_ARCH_UNCOMPRESS_H +#define __ASM_ARCH_UNCOMPRESS_H + +#include <linux/bitops.h> +#include <linux/io.h> +#include <asm/processor.h> +#include <mach/hardware.h> +#include <mach/uart.h>
If you include all that, then you're in for problems with the decompressor. The decompressor is a _really_ limited environment, and most stuff from linux/ or platfform stuff will not be available.
Quoted 6 lines
arch/arm/mach-prima2/irq.c new file +0
-0@@ -0,0 +1,81 @@
...
Quoted 41 lines
arch/arm/mach-prima2/irq.c new file +41
-0+#define SIRFSOC_INT_PENDING0 0x0000 +#define SIRFSOC_INT_PENDING1 0x0004 +#define SIRFSOC_INT_IRQ_PENDING0 0x0008 +#define SIRFSOC_INT_IRQ_PENDING1 0x000C +#define SIRFSOC_INT_FIQ_PENDING0 0x0010 +#define SIRFSOC_INT_FIQ_PENDING1 0x0014 +#define SIRFSOC_INT_RISC_MASK0 0x0018 +#define SIRFSOC_INT_RISC_MASK1 0x001C +#define SIRFSOC_INT_RISC_LEVEL0 0x0020 +#define SIRFSOC_INT_RISC_LEVEL1 0x0024 + +static void sirfsoc_irq_ack (struct irq_data *d) +{ +} + +static void sirfsoc_irq_mask (struct irq_data *d) +{ +unsigned long mask; + + mask =__raw_readl (SIRFSOC_INTR_VA_BASE +SIRFSOC_INT_RISC_MASK0 + (d->irq /32 ) *4 ) & + ~(1 << ( d->irq %32 )); +__raw_writel (mask,SIRFSOC_INTR_VA_BASE +SIRFSOC_INT_RISC_MASK0 + (d->irq /32 ) *4 ); +} + +static void sirfsoc_irq_unmask (struct irq_data *d) +{ +unsigned long mask; + + mask =__raw_readl (SIRFSOC_INTR_VA_BASE +SIRFSOC_INT_RISC_MASK0 + (d->irq /32 ) *4 ) | + (1 << ( d->irq %32 )); +__raw_writel (mask,SIRFSOC_INTR_VA_BASE +SIRFSOC_INT_RISC_MASK0 + (d->irq /32 ) *4 ); +} + +int sirfsoc_irq_settype (struct irq_data *d,unsigned int type) +{ +/* +* Interrupt handler doesnt support setting trigger type +*/ +if (type ==IRQ_TYPE_NONE ) +return 0 ; +
arch/arm/mach-prima2/irq.c line 65
Quoted 10 lines
arch/arm/mach-prima2/irq.c new file +10
-0+return -EINVAL ; +} + +static struct irq_chip sirfsoc_irq_chip = { + .name ="SiRF SoC" , + .irq_ack = sirfsoc_irq_ack, + .irq_mask = sirfsoc_irq_mask, + .irq_unmask = sirfsoc_irq_unmask, + .irq_set_type = sirfsoc_irq_settype, +};
Can you use the recently introduced generic irqchips stuff for this?
Quoted 6 lines
arch/arm/mach-prima2/timer.c new file +0
-0@@ -0,0 +1,181 @@
...
arch/arm/mach-prima2/timer.c line 155
Quoted 6 lines
arch/arm/mach-prima2/timer.c new file +6
-0+/* initialize the kernel jiffy timer source */ +static void __init sirfsoc_timer_init (void ) +{ +unsigned long rate; +/* timer's input clock is io clock */ +struct clk *clk =clk_get (NULL ,"io" );
Rather than going down this broken path of specifying clock names as connection IDs, it would be better to obtain it by function:
struct clk *clk = clk_get_sys("timer", NULL);Experience shows that people think that naming the clock signals themselves and passing strings around to drivers is easier. After a few years they find that what they thought was easy, is actually inflexible and has become a huge problem which they need to rework. (Samsung folk are currently going through this pain.)
So please, don't fall into the trap of "lets give each clock signal a name and look up only by clock name". Use the device names as the primary matching and don't allow yourself to get into the trap of passing clock names around.
arch/arm/mach-prima2/timer.c line 157
Quoted 2 lines
arch/arm/mach-prima2/timer.c new file +2
-0+ +BUG_ON (IS_ERR_OR_NULL (clk));
BUG_ON(IS_ERR(clk));
If clk_get() may return NULL, then clk_get_rate() should be able to eat that value without choking.
arch/arm/mach-prima2/timer.c line 160
Quoted 3 lines
arch/arm/mach-prima2/timer.c new file +3
-0+ + rate =clk_get_rate (clk); +clk_put (clk);
It's much preferable not to clk_put() a clock which you're going to continue using.
arch/arm/mach-prima2/timer.c line 171
Quoted 11 lines
arch/arm/mach-prima2/timer.c new file +11
-0+ +BUG_ON (rate <CLOCK_TICK_RATE ); +BUG_ON (rate %CLOCK_TICK_RATE ); + +__raw_writel (rate /CLOCK_TICK_RATE /2 -1 ,SIRFSOC_TIMER_VA_BASE +SIRFSOC_TIMER_DIV ); +__raw_writel (0 ,SIRFSOC_TIMER_VA_BASE +SIRFSOC_TIMER_COUNTER_LO ); +__raw_writel (0 ,SIRFSOC_TIMER_VA_BASE +SIRFSOC_TIMER_COUNTER_HI ); +__raw_writel (BIT (0 ),SIRFSOC_TIMER_VA_BASE +SIRFSOC_TIMER_STATUS ); + +if (clocksource_register_hz (&sirfsoc_clocksource,CLOCK_TICK_RATE )) +BUG ();
Confused. CLOCK_TICK_RATE is defined to be 100 * HZ, so 10kHz. Do your timers really tick at 10kHz? That seems needlessly slow for a 64-bit counter. Also consider BUG_ON()
arch/arm/mach-prima2/timer.c line 174
Quoted 3 lines
arch/arm/mach-prima2/timer.c new file +3
-0+ +if (setup_irq (sirfsoc_timer_irq.irq, &sirfsoc_timer_irq)) +BUG ();
BUG_ON() here too.
PATCH 1/1 ARM: CSR: Adding CSR SiRFprimaII board support
2011/6/22 Russell King - ARM Linux <[email protected]>:
Quoted 99 lines
Some comments inline, nothing really serious...
Quoted 8 lines · Barry Song
+config
ARCH_PRIMA2
+ ? ? bool "CSR SiRFSoC PRIMA2 ARM Cortex A9 Platform"
+ ? ? selectCPU_V7
+ ? ? selectGENERIC_TIME
+ ? ? selectGENERIC_CLOCKEVENTS
+ ? ? selectCLKDEV_LOOKUP
+ ? ? selectUSE_OF
+ ? ? selectISA_DMA_APIDo you really provide the old ISA DMA API? ?Unless you're intending to use existing ISA drivers with their ISA DMA, you shouldn't define this.
Quoted 9 lines
arch/arm/Makefile +0
-0@@ -191,6 +191,7 @@ machine-$(CONFIG_ARCH_VEXPRESS) ? ? ? ? ? := vexpress?machine-$(CONFIG_ARCH_VT8500) ? ? ? ? ? ? ? ?:= vt8500 ?machine-$(CONFIG_ARCH_W90X900) ? ? ? ? ? ? ? := w90x900 ?machine-$(CONFIG_ARCH_NUC93X) ? ? ? ? ? ? ? ?:= nuc93x +machine-$(CONFIG_ARCH_PRIMA2) ? ? ? ? ? ? ? ?:= prima2
The comment at the start of this list says:
# Machine directory name. ?This list is sorted alphanumerically
# by CONFIG_* macro name.and I thank the NUC93x people for also missing it. ?Please ignore the NUC93x entry and place yours appropriately.
Quoted 14 lines
arch/arm/boot/dts/prima2-cb.dts new file +8
-0@@ -0,0 +1,44 @@ +/dts-v1/; +/ { + ? ? ? ?model = "SIRF Prima2 EVB"; + ? ? ? ?compatible = "sirf,prima2-cb", "sirf,prima2"; + ? ? #address-cells = <1>; + ? ? #size-cells = <1>; + ? ? interrupt-parent = <&intc>; +arch/arm/boot/dts/prima2-cb.dts line 18
Quoted 10 lines
arch/arm/boot/dts/prima2-cb.dts new file +10
-0+ ? ? ? ?memory { + ? ? ? ? ? ? ? ?reg = <0x00000000 0x20000000>; + ? ? ? ?}; + + ? ? chosen { + ? ? ? ? ? ? bootargs = "mem=512M real_root=/dev/mmcblk0p2 console=ttyS1 earlyprintk"; + ? ? ? ? ? ? linux,stdout-path = &uart1; + ? ? }; + + ? ? amba {You declare that you have an AMBA bus, does it have primcells on it? Should you be selecting
ARM_AMBAin your kconfig?Quoted 10 lines
arch/arm/mach-prima2/include/mach/entry-macro.S new file +4
-0@@ -0,0 +1,28 @@ +/* + * arch/arm/mach-prima2/include/mach/entry-macro.S + * + * Copyright (c) 2011 Cambridge Silicon Radio Limited, a CSR plc group company.arch/arm/mach-prima2/include/mach/entry-macro.S line 14
Quoted 10 lines
arch/arm/mach-prima2/include/mach/entry-macro.S new file +10
-0+ * + * Licensed under GPLv2 or later. + */ + +#include <mach/hardware.h> + +#define SIRFSOC_INT_ID 0x38 + + ? ? .macro ?get_irqnr_and_base, irqnr, irqstat, base, tmp + ? ? ? ?ldr \base, =SIRFSOC_INTR_VA_BASEConsider using
get_irqnr_preambleto load the base address only once per IRQ exception.Quoted 14 lines
arch/arm/mach-prima2/include/mach/isa-dma.h new file +8
-0@@ -0,0 +1,14 @@ +/* +* arch/arm/mach-prima2/include/mach/io.h +* +* Copyright (c) 2011 Cambridge Silicon Radio Limited, a CSR plc group company. +* +* Licensed under GPLv2 or later. +*/ +
Quoted 8 lines
arch/arm/mach-prima2/include/mach/isa-dma.h line 14
Quoted 6 lines
arch/arm/mach-prima2/include/mach/isa-dma.h new file +6
-0+#ifndef __MACH_PRIMA2_ISADMA_H +#define __MACH_PRIMA2_ISADMA_H + +#define MAX_DMA_CHANNELS 32 + +#endif You don't need this if you don't define
ISA_DMA_API.
i don't need ISA_DMA at all. i was totally wrong for this. actually i only need a DMA zone due to DMA address can't
be larger than 256MB for prima2 SD controller. So "#define ARM_DMA_ZONE_SIZE SZ_256M" is enough for me.
Quoted 19 lines
Quoted 19 lines
arch/arm/mach-prima2/include/mach/uncompress.h new file +12
-0@@ -0,0 +1,42 @@ +/* +* arch/arm/mach-prima2/include/mach/uncompress.h +* +* Copyright (c) 2011 Cambridge Silicon Radio Limited, a CSR plc group company. +* +* Licensed under GPLv2 or later. +*/ + +#ifndef __ASM_ARCH_UNCOMPRESS_H +#define __ASM_ARCH_UNCOMPRESS_H + +#include <linux/bitops.h>
Quoted 8 lines
arch/arm/mach-prima2/include/mach/uncompress.h
Quoted 4 lines
arch/arm/mach-prima2/include/mach/uncompress.h new file +4
-0+#include <linux/io.h> +#include <asm/processor.h> +#include <mach/hardware.h> +#includeIf you include all that, then you're in for problems with the decompressor. The decompressor is a _really_ limited environment, and most stuff from linux/ or platfform stuff will not be available.
<mach/uart.h>, io.h, mach/map.h with memory mapping are needed here. others are redundant here.
Quoted 53 lines
Quoted 7 lines
arch/arm/mach-prima2/irq.c new file +0
-0@@ -0,0 +1,81 @@...
Quoted 45 lines
arch/arm/mach-prima2/irq.c new file +45
-0+#define SIRFSOC_INT_PENDING0 ? ? ? ? ? ?0x0000 +#define SIRFSOC_INT_PENDING1 ? ? ? ? ? ?0x0004 +#define SIRFSOC_INT_IRQ_PENDING0 ? ? ? ?0x0008 +#define SIRFSOC_INT_IRQ_PENDING1 ? ? ? ?0x000C +#define SIRFSOC_INT_FIQ_PENDING0 ? ? ? ?0x0010 +#define SIRFSOC_INT_FIQ_PENDING1 ? ? ? ?0x0014 +#define SIRFSOC_INT_RISC_MASK0 ? ? ? ? ?0x0018 +#define SIRFSOC_INT_RISC_MASK1 ? ? ? ? ?0x001C +#define SIRFSOC_INT_RISC_LEVEL0 ? ? ? ? 0x0020 +#define SIRFSOC_INT_RISC_LEVEL1 ? ? ? ? 0x0024 + +static void sirfsoc_irq_ack (struct irq_data *d) +{ +} + +static void sirfsoc_irq_mask (struct irq_data *d) +{ + ? ? unsigned long mask; + + ? ? mask = __raw_readl(SIRFSOC_INTR_VA_BASE + SIRFSOC_INT_RISC_MASK0 + (d->irq / 32) * 4) & + ? ? ? ? ? ? ~(1 << ( d->irq % 32)); + ? ? __raw_writel(mask, SIRFSOC_INTR_VA_BASE + SIRFSOC_INT_RISC_MASK0 + (d->irq / 32) * 4); +} + +static void sirfsoc_irq_unmask (struct irq_data *d) +{ + ? ? unsigned long mask; + + ? ? mask = __raw_readl(SIRFSOC_INTR_VA_BASE + SIRFSOC_INT_RISC_MASK0 + (d->irq / 32) * 4) | + ? ? ? ? ? ? (1 << ( d->irq % 32)); + ? ? __raw_writel(mask, SIRFSOC_INTR_VA_BASE + SIRFSOC_INT_RISC_MASK0 + (d->irq / 32) * 4); +} + +int sirfsoc_irq_settype (struct irq_data *d,unsigned int type) +{ + ? ? /* + ? ? ?* Interrupt handler doesnt support setting trigger type + ? ? ?*/ + ? ? if (type == IRQ_TYPE_NONE) + ? ? ? ? ? ? return 0; + + ? ? return -EINVAL; +} + +static struct irq_chip sirfsoc_irq_chip = {
Quoted 8 lines
Quoted 6 lines
+ ? ? .name = "SiRF SoC",
+ ? ? .irq_ack =sirfsoc_irq_ack,
+ ? ? .irq_mask =sirfsoc_irq_mask,
+ ? ? .irq_unmask =sirfsoc_irq_unmask,
+ ? ? .irq_set_type =sirfsoc_irq_settype,
+};Can you use the recently introduced generic irqchips stuff for this?
agree, then i select GENERIC_IRQ_CHIP.
Quoted 8 lines
Quoted 7 lines
arch/arm/mach-prima2/timer.c new file +0
-0@@ -0,0 +1,181 @@...
Quoted 10 lines
arch/arm/mach-prima2/timer.c
Quoted 6 lines
arch/arm/mach-prima2/timer.c new file +6
-0+/* initialize the kernel jiffy timer source */ +static void __init sirfsoc_timer_init (void ) +{ + ? ? unsigned long rate; + ? ? /* timer's input clock is io clock */ + ? ? struct clk *clk = clk_get(NULL, "io");Rather than going down this broken path of specifying clock names as connection IDs, it would be better to obtain it by function:
? ? ? ?struct clk *clk =clk_get_sys("timer", NULL);
agree. it makes the codes clearer a lot for sys level clock which doesn't bind with a device.
Quoted 11 lines
Experience shows that people think that naming the clock signals themselves and passing strings around to drivers is easier. ?After a few years they find that what they thought was easy, is actually inflexible and has become a huge problem which they need to rework. ?(Samsung folk are currently going through this pain.)
So please, don't fall into the trap of "lets give each clock signal a name and look up only by clock name". ?Use the device names as the primary matching and don't allow yourself to get into the trap of passing clock names around.
agree. to avoid device name issues, the current clock.c only include system timers like pll, cystal and bus level. i didn't place device level clocks like uart/lcd/gps/gpu/mmc and so on yet.
then all of them should be changed to use dev_id but not con_id. then we get them by clk_get_sys().
so the problem still need to be solved since device names coming from DT is not that much "stable" as statically registered devices. the name from DT isn't the same
as what board support code currently uses for statically registered platform_devices.
Grant has two threads for this:
1. of: add clock providers to provide clk mapping in DT
http://www.mail-archive.com/devicetree-discuss at lists.ozlabs.org/msg03016.html
2. " If Linux needs specific devices to have specific names, then it can pass in a lookup table that matches DT nodes to device names, which is considerably simpler and it leaves the platform setup code in control over how devices get instantiated."
both seems not ready yet?
Quoted 8 lines
Quoted 3 lines
+
+ ? ? BUG_ON(IS_ERR_OR_NULL(clk));? ? ? ?BUG_ON(IS_ERR(clk));
If
clk_get()may return NULL, thenclk_get_rate()should be able to eat that value without choking.
agree. clk_get() has no chance to return NULL.
Quoted 7 lines
Quoted 4 lines
+
+ ? ? rate =clk_get_rate(clk);
+ ? ?clk_put(clk);It's much preferable not to
clk_put()a clock which you're going to continue using.
agree.
Quoted 16 lines
arch/arm/mach-prima2/timer.c
Quoted 12 lines
arch/arm/mach-prima2/timer.c new file +11
-0+ + ? ? BUG_ON(rate < CLOCK_TICK_RATE); + ? ? BUG_ON(rate % CLOCK_TICK_RATE); + + ? ? __raw_writel(rate / CLOCK_TICK_RATE / 2 - 1, SIRFSOC_TIMER_VA_BASE + SIRFSOC_TIMER_DIV); + ? ? __raw_writel(0, SIRFSOC_TIMER_VA_BASE + SIRFSOC_TIMER_COUNTER_LO); + ? ? __raw_writel(0, SIRFSOC_TIMER_VA_BASE + SIRFSOC_TIMER_COUNTER_HI); + ? ? __raw_writel(BIT(0), SIRFSOC_TIMER_VA_BASE + SIRFSOC_TIMER_STATUS); + + ? ? if (clocksource_register_hz(&sirfsoc_clocksource, CLOCK_TICK_RATE)) + ? ? ? ? ? ? BUG();Confused. ?CLOCK_TICK_RATE is defined to be 100 * HZ, so 10kHz. ?Do your timers really tick at 10kHz? ?That seems needlessly slow for a 64-bit counter. ?Also consider
BUG_ON()
sorry for typo. it's my misoperation by copy/paste the file from another file. it actually is "#define CLOCK_TICK_RATE 1000000"
Quoted 6 lines
Quoted 4 lines
+
+ ? ? if (setup_irq(sirfsoc_timer_irq.irq, &sirfsoc_timer_irq))
+ ? ? ? ? ? ?BUG();
BUG_ON()here too.
Agree.
Quoted 6 lines
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel at lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
PATCH 1/1 ARM: CSR: Adding CSR SiRFprimaII board support
In reply to Arnd Bergmann2011/6/21 Arnd Bergmann <[email protected]>:
Quoted 12 lines · Barry Song
Quoted 11 lines
From: Binghua Duan <[email protected]>
SiRFprimaII is the latest generation application processor from CSR?s Multifunction SoC product family. Designed around an ARM cortex A9 core, high-speed memory bus, advanced 3D accelerator and full-HD multi-format video decoder, SiRFprimaII is able to meet the needs of complicated applications for modern multifunction devices that require heavy concurrent applications and fluid user experience. Integrated with GPS baseband, analog and PMU, this new platform is designed to provide a cost effective solution for Automotive and Consumer markets.
Quoted 7 lines
Quoted 2 lines
This patch adds the basic support for this SoC and EVB board based on device tree. It is following the ZYNQ of Grant Likely in some degree.
Hi Binghua and Barry,
Your platform looks pretty good already, it's good to see that you are progressing so well with the conversion to device tree.
really really thank you very much for your helping to track the threads of CSR platform from the beginning.
you guide us in the right direction.
Quoted 46 lines
Quoted 46 lines
arch/arm/boot/dts/prima2-cb.dts new file +39
-0@@ -0,0 +1,44 @@ +/dts-v1/; +/ { + ? ? ? ?model = "SIRF Prima2 EVB"; + ? ? ? ?compatible = "sirf,prima2-cb", "sirf,prima2"; + ? ? #address-cells = <1>; + ? ? #size-cells = <1>; + ? ? interrupt-parent = <&intc>; + + ? ? ? ?memory { + ? ? ? ? ? ? ? ?reg = <0x00000000 0x20000000>; + ? ? ? ?}; + + ? ? chosen { + ? ? ? ? ? ? bootargs = "mem=512M real_root=/dev/mmcblk0p2 console=ttyS1 earlyprintk"; + ? ? ? ? ? ? linux,stdout-path = &uart1; + ? ? }; + + ? ? amba { + ? ? ? ? ? ? compatible = "simple-bus"; + ? ? ? ? ? ? #address-cells = <1>; + ? ? ? ? ? ? #size-cells = <1>; + ? ? ? ? ? ? ranges; + + ? ? ? ? ? ? intc: interrupt-controller at 0x80020000 { + ? ? ? ? ? ? ? ? ? ? ? ? interrupt-controller; + ? ? ? ? ? ? ? ? ? ? ? ? compatible = "arm,sirfsoc"; + ? ? ? ? ? ? ? ? ? ? ? ? reg = <0x80020000 0x1000>; + ? ? ? ? ? ? ? ? ? ? ? ? #interrupt-cells = <1>; + ? ? ? ? ? ? }; + + ? ? ? ? ? ? uart0: uart at 0xb0050000 { + ? ? ? ? ? ? ? ? ? ? ? ? ? ?compatible = "sirf,uart"; + ? ? ? ? ? ? ? ? ? ? ? ? ? ?reg = <0xb0050000 0x1000>; + ? ? ? ? ? ? ? ? ? ? ? ? ? ?interrupts = <17>; + ? ? ? ? ? ? }; + + ? ? ? ? ? ? uart1: uart at 0xb0060000 { + ? ? ? ? ? ? ? ? ? ? ? ? ? ?compatible = "sirf,uart"; + ? ? ? ? ? ? ? ? ? ? ? ? ? ?reg = <0xb0060000 0x1000>;
Quoted 8 lines
arch/arm/boot/dts/prima2-cb.dts line 43
Quoted 4 lines
arch/arm/boot/dts/prima2-cb.dts new file +4
-0+ ? ? ? ? ? ? ? ? ? ? ? ? ? ?interrupts = <18>; + ? ? ? ? ? ? }; + ? ? }; +};The "compatible" properties should really be more specific than this. You can list multiple alternatives in there, but please always have one that identifies the exact version of each of the macros uniquely.
i guess you mean compatible = "sirf,uart", "sirf,prima2-uart", "sirf,altas6-uart" ?
Quoted 9 lines
Please also model the device hierarchy as close as possible to the high-level block diagrams in the data sheet. I would e.g. expect this to have multiple AMBA buses, one at
0x80000000and one at0xb0000000, so just define them separately with a ranges property describing the location of the bus in the address space, and put the child devices at relative addresses to that.I would also recommend listing all devices in the device tree here, even if the drivers are not yet ported.
agree. i am working with IC guys on this.
Quoted 3 lines
Regarding the interrupt and timer drivers, there has been some discussion about moving them to
drivers/irqanddrivers/clocksource, respectively.
i will keep an eye on them.
Quoted 61 lines
arch/arm/mach-prima2/clock.c
Quoted 6 lines
arch/arm/mach-prima2/clock.c new file +0
-0I can't really comment on the clock support. A lot has changed here recently, so I hope someone else can comment.
Quoted 49 lines
arch/arm/mach-prima2/clock.c new file +49
-0+#define IOTABLE_ENTRY (region) {\ + ? ? .virtual ? ? ? ?= SIRFSOC_##region##_VA_BASE, \ + ? ? .pfn ? ? ? ? ? ?= __phys_to_pfn(SIRFSOC_##region##_PA_BASE),\ + ? ? .length ? ? ? ? = SIRFSOC_##region##_SIZE, \ + ? ? .type ? ? ? ? ? = MT_DEVICE, \ +} + +static struct map_desc sirfsoc_iodesc[]__initdata = { + ? ? ? ?IOTABLE_ENTRY(INTR), + ? ? ? ?IOTABLE_ENTRY(UART1), + ? ? ? ?IOTABLE_ENTRY(TIMER), + ? ? ? ?IOTABLE_ENTRY(CLOCK), +#ifdef CONFIG_CACHE_L2X0 + ? ? IOTABLE_ENTRY(L2CC), +#endif +}; + +void __init sirfsoc_map_io (void ) +{ + ? ? iotable_init(sirfsoc_iodesc, ARRAY_SIZE(sirfsoc_iodesc)); +} + +#define L2X0_ADDR_FILTERING_START ? ? ? 0xC00 +#define L2X0_ADDR_FILTERING_END ? ? ? ? 0xC04 + +static int __init sirfsoc_init (void ) +{ +#ifdef CONFIG_CACHE_L2X0 + ? ? if (!(readl_relaxed(SIRFSOC_L2CC_VA_BASE + L2X0_CTRL) & 1)) { + ? ? ? ? ? ? /* + ? ? ? ? ? ? ?* set the physical memory windows L2 cache will cover + ? ? ? ? ? ? ?*/ + ? ? ? ? ? ? writel_relaxed(PHYS_OFFSET + 1024 * 1024 * 1024, + ? ? ? ? ? ? ? ? ? ? SIRFSOC_L2CC_VA_BASE + L2X0_ADDR_FILTERING_END); + ? ? ? ? ? ? writel_relaxed(PHYS_OFFSET | 0x1, + ? ? ? ? ? ? ? ? ? ? SIRFSOC_L2CC_VA_BASE + L2X0_ADDR_FILTERING_START); + + ? ? ? ? ? ? writel_relaxed(0, + ? ? ? ? ? ? ? ? ? ? SIRFSOC_L2CC_VA_BASE + L2X0_TAG_LATENCY_CTRL); + ? ? ? ? ? ? writel_relaxed(0, + ? ? ? ? ? ? ? ? ? ? SIRFSOC_L2CC_VA_BASE + L2X0_DATA_LATENCY_CTRL); + ? ? } + ? ? l2x0_init((void __iomem *)SIRFSOC_L2CC_VA_BASE, 0x00040000, + ? ? ? ? ? ? 0x00000000); +#endif + + ? ? return 0; +} +arch_initcall (sirfsoc_init);
Quoted 13 lines
arch/arm/mach-prima2/clock.c
Quoted 9 lines
arch/arm/mach-prima2/clock.c new file +9
-0+#ifndef __MACH_PRIMA2_IO_H +#define __MACH_PRIMA2_IO_H + +#define IO_SPACE_LIMIT 0xffffffff + +#define __mem_pci (x) ? (x) +#define __io (a) ? ? ? ?((void __iomem *)(a)) + +#endif This is broken for PCI I/O space windows. The same issue keeps coming up with every new platform, and I wish we could simply not have to define these.
agree.
Quoted 2 lines
Do you have any PCI or PCMCIA devices?
we do have an internal PCI bridge. but it seems it is completely transparent to users and softwares just like we have no PCI bridge at all.
anyway, i need the final confirmation from IC guys.
Most platforms without PCI define io.h by giving a simple comment "We don't actually have real ISA nor PCI buses, but there is so many drivers out there that might just work if we fake them...".
Quoted 14 lines
arch/arm/mach-prima2/include/mach/isa-dma.h line 14
Quoted 9 lines
arch/arm/mach-prima2/include/mach/isa-dma.h +7
-0+ +#ifndef __MACH_PRIMA2_ISADMA_H +#define __MACH_PRIMA2_ISADMA_H + +#define MAX_DMA_CHANNELS 32 + +#endif Would it make sense to convert the DMA support on your platform to the more modern dmaengine API? The old ISA DMA API is showing its age, and will cause trouble when you want to support different DMA controllers in a single kernel.
sorry for my fault of selecting ISA_DMA . we don't need that at all.
Quoted 39 lines
Quoted 39 lines
arch/arm/mach-prima2/include/mach/map.h new file +33
-0+ +#define SIRFSOC_VA (x) ? ? ? ? ? ? ? ? ? ? ? ?(VMALLOC_END + ((x) & 0x00FFF000)) + +/* INTR */ +#define SIRFSOC_INTR_PA_BASE ? ? ? ? 0x80020000 +#define SIRFSOC_INTR_VA_BASE ? ? ? ? SIRFSOC_VA(0x002000) +#define SIRFSOC_INTR_SIZE ? ? ? ? ? ?SZ_4K + +/* L2 CACHE */ +#define SIRFSOC_L2CC_PA_BASE ? ? ? ? 0x80040000 +#define SIRFSOC_L2CC_VA_BASE ? ? ? ? SIRFSOC_VA(0x004000) +#define SIRFSOC_L2CC_SIZE ? ? ? ? ? ?SZ_4K + +/* CLOCK */ +#define SIRFSOC_CLOCK_PA_BASE ? ? ? ? ? ? ? ?0x88000000 +#define SIRFSOC_CLOCK_VA_BASE ? ? ? ? ? ? ? ?SIRFSOC_VA(0x005000) +#define SIRFSOC_CLOCK_SIZE ? ? ? ? ? SZ_4K + +/* RESET CONTROLLER */ +#define SIRFSOC_RSTC_PA_BASE ? ? ? ? 0x88010000 +#define SIRFSOC_RSTC_VA_BASE ? ? ? ? SIRFSOC_VA(0x006000) +#define SIRFSOC_RSTC_SIZE ? ? ? ? ? ?SZ_4K + +/* OS TIMER */ +#define SIRFSOC_TIMER_PA_BASE ? ? ? ? ? ? ? ?0xb0020000 +#define SIRFSOC_TIMER_VA_BASE ? ? ? ? ? ? ? ?SIRFSOC_VA(0x00c000) +#define SIRFSOC_TIMER_SIZE ? ? ? ? ? SZ_4K + +/* UART-1: used as serial debug port */ +#define SIRFSOC_UART1_PA_BASE ? ? ? ? ? ? ? ?0xb0060000 +#define SIRFSOC_UART1_VA_BASE ? ? ? ? ? ? ? ?SIRFSOC_VA(0x060000) +#define SIRFSOC_UART1_SIZE ? ? ? ? ? SZ_4K +
Quoted 8 lines
arch/arm/mach-prima2/include/mach/map.h line 49
Quoted 4 lines
arch/arm/mach-prima2/include/mach/map.h new file +4
-0+/* RAM BASE*/ +#define SIRFSOC_SDRAM_PA ? ? ? ? ? ? 0x00000000 + +#endif I think these should all be converted into device tree properties if possible. Anything that can be initialized late enough should just do an ioremap at the time when you first need to access the registers.
i totally agree with your opinion. but i guess SIRFSOC_UART1_PA_BASE/SIRFSOC_UART1_VA_BASE is necessary here since they are mapped very early for DEBUG_LL.
i do find some patches about probing L2 cache and some other things by DT. i can provide them by DT and don't map them until we access them. but it seems a static io table is pretty simple for some low level hardwares.
Another issue is that .init_early(fot this case, it is sirfsoc_init_clk) is called earlier than kernel mm init and later than .map_io(for this case, it is sirfsoc_map_io), the early static mapping makes .init_early can access mapped virtual memory too.
Quoted 3 lines
For the L2 cache, Rob already posted a binding, so best work with him on that one.
agree
Quoted 11 lines
arch/arm/mach-prima2/include/mach/map.h
Quoted 8 lines
arch/arm/mach-prima2/include/mach/map.h new file +7
-0+/* +* Restrict DMA-able region to workaround silicon limitation. +* The limitation restricts buffers available for DMA to SD/MMC +* hardware to be below 256MB +*/ +#define ARM_DMA_ZONE_SIZE ? ?(SZ_256M) +This is very unfortunate, but I guess there is no real way to avoid doing this, right?
a hardware issue limits DMA address must be less than 256MB for SD controller. to make sure SD controller get DMA buffer below 256MB, we need that DMA zone.
But guess the size of the zone doesn't matter at all, it even can be 1MB, 2MB or any value less than 256MB. Anyway, we only need a DMA buffer for SD.
if we reserve an area for SD DMA buffer, it seems ugly too?
Quoted 11 lines
arch/arm/mach-prima2/include/mach/map.h
Quoted 9 lines
arch/arm/mach-prima2/include/mach/map.h new file +8
-0+static void sirfsoc_irq_mask (struct irq_data *d) +{ + ? ? unsigned long mask; + + ? ? mask = __raw_readl(SIRFSOC_INTR_VA_BASE + SIRFSOC_INT_RISC_MASK0 + (d->irq / 32) * 4) & + ? ? ? ? ? ? ~(1 << ( d->irq % 32)); + ? ? __raw_writel(mask, SIRFSOC_INTR_VA_BASE + SIRFSOC_INT_RISC_MASK0 + (d->irq / 32) * 4); +}Better use
readl_relaxedhere than__raw_readl.
Agree
Quoted 13 lines
arch/arm/mach-prima2/include/mach/map.h
Quoted 11 lines
arch/arm/mach-prima2/include/mach/map.h new file +9
-0+/* timer0 interrupt handler */ +static irqreturn_t sirfsoc_timer_interrupt (int irq,void *dev_id) +{ + ? ? struct clock_event_device *ce = dev_id; + + ? ? WARN_ON(!(__raw_readl(SIRFSOC_TIMER_VA_BASE + SIRFSOC_TIMER_STATUS) & BIT(0))); + + ? ? /* clear timer0 interrupt */ + ? ? __raw_writel(BIT(0), SIRFSOC_TIMER_VA_BASE + SIRFSOC_TIMER_STATUS);Here, too.
Agree.
Quoted 8 lines
? ? ? ?Arnd
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel at lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
PATCH 1/1 ARM: CSR: Adding CSR SiRFprimaII board support
Quoted 7 lines · Barry Song
Quoted 4 lines
The "compatible" properties should really be more specific than this. You can list multiple alternatives in there, but please always have one that identifies the exact version of each of the macros uniquely.
i guess you mean compatible = "sirf,uart", "sirf,prima2-uart", "sirf,altas6-uart" ?
It depends on how specific prima2 and atlas6 really are. Are these specific pieces of silicon, or are they each a family of similar chips? Is one a superset of the other?
If your device tree describes a board with a prima2 SoC on it, and all prima2 chips are identical, then ("sirf,uart", "sirf,prima2-uart") is fine. If prima2 is itself a family of chips, you should add a third entry like "sirf,prima2-1234-uart" where 1234 is the model number of that chip.
My understanding is that prima2 and atlas6 are two separate chips, so you should not list them both in one device tree.
If your hardware design team has an official nomenclature for different versions of the uart macro, you can also add that. E.g. if prima1 and atlas5 use version 3.1 of the uart, while prima2 and atlas6 use version 3.2, you can list that version too. A driver can then match on the uart version and doesn't have to know about the soc it's used in. This depends on how your hardware design team works.
Also, if you buy hardware macros from other companies, it's useful to list those in the compatible property as well, to let the same driver automatically work across SoCs from multiple vendors that have licensed the same core, like you do for the ARM l2 cache controller.
Quoted 6 lines
Quoted 1 line
Do you have any PCI or PCMCIA devices?
we do have an internal PCI bridge. but it seems it is completely transparent to users and softwares just like we have no PCI bridge at all.
anyway, i need the final confirmation from IC guys.
I don't completely understand. If you have actual PCI devices with a proper configuration space in the system, I would strongly suggest that you export the PCI host bridge instead of the individual devices and let the PCI probing code take care of that.
Using hardware probing mechanisms is normally preferred, because it means you don't have to list every device in the device tree.
Quoted 3 lines
Most platforms without PCI define
io.hby giving a simple comment "We don't actually have real ISA nor PCI buses, but there is so many drivers out there that might just work if we fake them...".
It's on my list to look into.
Quoted 44 lines
Quoted 35 lines
Quoted 35 lines
arch/arm/mach-prima2/include/mach/map.h new file +33
-0+ +#define SIRFSOC_VA (x) (VMALLOC_END + ((x) & 0x00FFF000)) + +/* INTR */ +#define SIRFSOC_INTR_PA_BASE 0x80020000 +#define SIRFSOC_INTR_VA_BASE SIRFSOC_VA(0x002000) +#define SIRFSOC_INTR_SIZE SZ_4K + +/* L2 CACHE */ +#define SIRFSOC_L2CC_PA_BASE 0x80040000 +#define SIRFSOC_L2CC_VA_BASE SIRFSOC_VA(0x004000) +#define SIRFSOC_L2CC_SIZE SZ_4K + +/* CLOCK */ +#define SIRFSOC_CLOCK_PA_BASE 0x88000000 +#define SIRFSOC_CLOCK_VA_BASE SIRFSOC_VA(0x005000) +#define SIRFSOC_CLOCK_SIZE SZ_4K + +/* RESET CONTROLLER */ +#define SIRFSOC_RSTC_PA_BASE 0x88010000 +#define SIRFSOC_RSTC_VA_BASE SIRFSOC_VA(0x006000) +#define SIRFSOC_RSTC_SIZE SZ_4K + +/* OS TIMER */ +#define SIRFSOC_TIMER_PA_BASE 0xb0020000 +#define SIRFSOC_TIMER_VA_BASE SIRFSOC_VA(0x00c000) +#define SIRFSOC_TIMER_SIZE SZ_4K + +/* UART-1: used as serial debug port */ +#define SIRFSOC_UART1_PA_BASE 0xb0060000 +#define SIRFSOC_UART1_VA_BASE SIRFSOC_VA(0x060000) +#define SIRFSOC_UART1_SIZE SZ_4K +Quoted 8 lines
arch/arm/mach-prima2/include/mach/map.h line 49
Quoted 4 lines
arch/arm/mach-prima2/include/mach/map.h new file +4
-0+/* RAM BASE*/ +#define SIRFSOC_SDRAM_PA 0x00000000 + +#endif I think these should all be converted into device tree properties if possible. Anything that can be initialized late enough should just do an ioremap at the time when you first need to access the registers.
Quoted 3 lines
i totally agree with your opinion. but i guess SIRFSOC_UART1_PA_BASE/SIRFSOC_UART1_VA_BASE is necessary here since they are mapped very early for
DEBUG_LL.
Please make that code optional and dependent on CONFIG_DEBUG_LL then.
I would also recommend splitting out all code related to DEBUG_LL into one separate patch so we can look at the base code independent of that.
I believe we already have a problem with DEBUG_LL as soon as we get to multi-platform kernels.
Quoted 4 lines
Another issue is that .init_early(fot this case, it is
sirfsoc_init_clk) is called earlier than kernel mm init and later than .map_io(for this case, it issirfsoc_map_io), the early static mapping makes .init_early can access mapped virtual memory too.
But does sirfsoc_init_clk have to be called from init_early, or can you do it a bit later?
Quoted 11 lines
Quoted 10 lines
arch/arm/mach-prima2/include/mach/map.h
Quoted 7 lines
arch/arm/mach-prima2/include/mach/map.h new file +7
-0+/* +* Restrict DMA-able region to workaround silicon limitation. +* The limitation restricts buffers available for DMA to SD/MMC +* hardware to be below 256MB +*/ +#define ARM_DMA_ZONE_SIZE (SZ_256M) +This is very unfortunate, but I guess there is no real way to avoid doing this, right?
Quoted 7 lines
a hardware issue limits DMA address must be less than 256MB for SD controller. to make sure SD controller get DMA buffer below 256MB, we need that DMA zone.
But guess the size of the zone doesn't matter at all, it even can be 1MB, 2MB or any value less than 256MB. Anyway, we only need a DMA buffer for SD.
if we reserve an area for SD DMA buffer, it seems ugly too?
Probably yes, it would also make the I/O slower because then you have to alway do bounce-buffering, while now you only have to do it when the user buffer is above 256 MB.
You should definitely make sure that the SD device has the correct dma_mask set, which is required for correctness, while the right ARM_DMA_ZONE_SIZE is more a question of performance. When we get to multi-platform kernels, we can then just set the minimum of the configured platforms.
Arnd
PATCH 1/1 ARM: CSR: Adding CSR SiRFprimaII board support
In reply to Barry SongQuoted 14 lines · Barry Song
so the problem still need to be solved since device names coming from DT is not that much "stable" as statically registered devices. the name from DT isn't the same
as what board support code currently uses for statically registeredplatform_devices.Grant has two threads for this:
1. of: add clock providers to provide clk mapping in DT
http://www.mail-archive.com/devicetree-discuss at lists.ozlabs.org/msg03016.html
2. " If Linux needs specific devices to have specific names, then it can pass in a lookup table that matches DT nodes to device names, which is considerably simpler and it leaves the platform setup code in control over how devices get instantiated."
Quoted 1 line
both seems not ready yet?
I'm planning to merge the auxdata patch (thread 2 above) into linux-next in a couple of days. When I push out that branch, it can be merged into the subarch tree before picking up the sirfprimall support patch (assuming it gets picked up for v3.1)
g.
PATCH 1/1 ARM: CSR: Adding CSR SiRFprimaII board support
In reply to Arnd Bergmann2011/6/22 Arnd Bergmann <[email protected]>:
Quoted 6 lines · Barry Song
Quoted 5 lines
Quoted 4 lines
The "compatible" properties should really be more specific than this. You can list multiple alternatives in there, but please always have one that identifies the exact version of each of the macros uniquely.
Quoted 6 lines
Quoted 2 lines
i guess you mean compatible = ?"sirf,uart", "sirf,prima2-uart", "sirf,altas6-uart" ?
It depends on how specific prima2 and atlas6 really are. Are these specific pieces of silicon, or are they each a family of similar chips? Is one a superset of the other?
they are two different chips sharing many same IP cores. uart should be one.
Comparing with PrimaII, the updated IP of Atlas6 include usb controller, cortexA9, ECC, and new IP include graphics.
Quoted 5 lines
If your device tree describes a board with a prima2 SoC on it, and all prima2 chips are identical, then ("sirf,uart", "sirf,prima2-uart") is fine. If prima2 is itself a family of chips, you should add a third entry like "sirf,prima2-1234-uart" where 1234 is the model number of that chip.
i guess we can use ("sirf,uart", "sirf,prima2-uart", "sirf,prima2-1500-uart") for the moment.
Quoted 23 lines
My understanding is that prima2 and atlas6 are two separate chips, so you should not list them both in one device tree.
If your hardware design team has an official nomenclature for different versions of the uart macro, you can also add that. E.g. if prima1 and atlas5 use version 3.1 of the uart, while prima2 and atlas6 use version 3.2, you can list that version too. A driver can then match on the uart version and doesn't have to know about the soc it's used in. This depends on how your hardware design team works.
Also, if you buy hardware macros from other companies, it's useful to list those in the compatible property as well, to let the same driver automatically work across SoCs from multiple vendors that have licensed the same core, like you do for the ARM l2 cache controller.
Quoted 6 lines
Quoted 1 line
Do you have any PCI or PCMCIA devices?
we do have an internal PCI bridge. but it seems it is completely transparent to users and softwares just like we have no PCI bridge at all.
anyway, i need the final confirmation from IC guys.
Quoted 7 lines
I don't completely understand. If you have actual PCI devices with a proper configuration space in the system, I would strongly suggest that you export the PCI host bridge instead of the individual devices and let the PCI probing code take care of that.
Using hardware probing mechanisms is normally preferred, because it means you don't have to list every device in the device tree.
Due to history reasons, SD controller is using ip core with pci interface. and its configuration is hard-coded in IC directly. and PrimaII doesn't support external pci devices too. PCI configuration and signals of SD are invisible to users and software at all. to software, we can't see anything related with pci from SD. when we are accessing sd controller, it looks like we are just accessing normal memory bus.
The DMA limitation of 256MB is also due to the design of internal PCI bridge. the bridge only can cover below 256MB.
Quoted 6 lines
Quoted 4 lines
Most platforms without PCI define
io.hby giving a simple comment "We don't actually have real ISA nor PCI buses, but there is so many drivers out there that might just work if we fake them...".It's on my list to look into.
Great.
Quoted 49 lines
Quoted 45 lines
Quoted 36 lines
Quoted 36 lines
arch/arm/mach-prima2/include/mach/map.h new file +33
-0+ +#define SIRFSOC_VA (x) ? ? ? ? ? ? ? ? ? ? ? ?(VMALLOC_END + ((x) & 0x00FFF000)) + +/* INTR */ +#define SIRFSOC_INTR_PA_BASE ? ? ? ? 0x80020000 +#define SIRFSOC_INTR_VA_BASE ? ? ? ? SIRFSOC_VA(0x002000) +#define SIRFSOC_INTR_SIZE ? ? ? ? ? ?SZ_4K + +/* L2 CACHE */ +#define SIRFSOC_L2CC_PA_BASE ? ? ? ? 0x80040000 +#define SIRFSOC_L2CC_VA_BASE ? ? ? ? SIRFSOC_VA(0x004000) +#define SIRFSOC_L2CC_SIZE ? ? ? ? ? ?SZ_4K + +/* CLOCK */ +#define SIRFSOC_CLOCK_PA_BASE ? ? ? ? ? ? ? ?0x88000000 +#define SIRFSOC_CLOCK_VA_BASE ? ? ? ? ? ? ? ?SIRFSOC_VA(0x005000) +#define SIRFSOC_CLOCK_SIZE ? ? ? ? ? SZ_4K + +/* RESET CONTROLLER */ +#define SIRFSOC_RSTC_PA_BASE ? ? ? ? 0x88010000 +#define SIRFSOC_RSTC_VA_BASE ? ? ? ? SIRFSOC_VA(0x006000) +#define SIRFSOC_RSTC_SIZE ? ? ? ? ? ?SZ_4K + +/* OS TIMER */ +#define SIRFSOC_TIMER_PA_BASE ? ? ? ? ? ? ? ?0xb0020000 +#define SIRFSOC_TIMER_VA_BASE ? ? ? ? ? ? ? ?SIRFSOC_VA(0x00c000) +#define SIRFSOC_TIMER_SIZE ? ? ? ? ? SZ_4K + +/* UART-1: used as serial debug port */ +#define SIRFSOC_UART1_PA_BASE ? ? ? ? ? ? ? ?0xb0060000 +#define SIRFSOC_UART1_VA_BASE ? ? ? ? ? ? ? ?SIRFSOC_VA(0x060000) +#define SIRFSOC_UART1_SIZE ? ? ? ? ? SZ_4K +Quoted 8 lines
arch/arm/mach-prima2/include/mach/map.h line 49
Quoted 4 lines
arch/arm/mach-prima2/include/mach/map.h new file +4
-0+/* RAM BASE*/ +#define SIRFSOC_SDRAM_PA ? ? ? ? ? ? 0x00000000 + +#endif I think these should all be converted into device tree properties if possible. Anything that can be initialized late enough should just do an ioremap at the time when you first need to access the registers.
Quoted 3 lines
i totally agree with your opinion. but i guess SIRFSOC_UART1_PA_BASE/SIRFSOC_UART1_VA_BASE is necessary here since they are mapped very early for
DEBUG_LL.
Quoted 5 lines
Please make that code optional and dependent on
CONFIG_DEBUG_LLthen.I would also recommend splitting out all code related to
DEBUG_LLinto one separate patch so we can look at the base code independent of that.
uart for DEBUG_LL require mapping twice. one in head.S, the other one in .map_io for static mapping.
i can let the static mapping as the seperate patch.
Quoted 11 lines
I believe we already have a problem with
DEBUG_LLas soon as we get to multi-platform kernels.Quoted 4 lines
Another issue is that .init_early(fot this case, it is
sirfsoc_init_clk) ?is called earlier than kernel mm init and later than .map_io(for this case, it issirfsoc_map_io), ?the early static mapping makes .init_early can access mapped virtual memory too.But does
sirfsoc_init_clkhave to be called frominit_early, or can you do it a bit later?
The sequence is
temp mapping of DEBUG uart in head.S -> kernel paging_init() -> static mapping of .map_io(build new mapping for uart) -> .init_early(prepare clock which .timer will access for this case) -> kernel mm init -> .timer -> arch_initcall
between mm init and .timer, there are irq/prio_tree init, both seem not the right place to prepare clock. if i can move clock init behind mm init, ioremap should be ok. Then make codes ugly.
For other cases, some boards maybe use init_early to prepare some other things. and they maybe access virtual memory too.
Quoted 24 lines
Quoted 12 lines
Quoted 11 lines
arch/arm/mach-prima2/include/mach/map.h
Quoted 8 lines
arch/arm/mach-prima2/include/mach/map.h new file +7
-0+/* +* Restrict DMA-able region to workaround silicon limitation. +* The limitation restricts buffers available for DMA to SD/MMC +* hardware to be below 256MB +*/ +#define ARM_DMA_ZONE_SIZE ? ?(SZ_256M) +This is very unfortunate, but I guess there is no real way to avoid doing this, right?
Quoted 7 lines
a hardware issue limits DMA address must be less than 256MB for SD controller. to make sure SD controller get DMA buffer below 256MB, we need that DMA zone.
But guess the size of the zone doesn't matter at all, it even can be 1MB, 2MB or any value less than 256MB. Anyway, we only need a DMA buffer for SD.
if we reserve an area for SD DMA buffer, it seems ugly too?Probably yes, it would also make the I/O slower because then you have to alway do bounce-buffering, while now you only have to do it when the user buffer is above 256 MB.
Quoted 5 lines
You should definitely make sure that the SD device has the correct
dma_maskset, which is required for correctness, while the rightARM_DMA_ZONE_SIZEis more a question of performance. When we get to multi-platform kernels, we can then just set the minimum of the configured platforms.
yes. we should have right dma masking to 256MB. Anyway, DMA bouncing is required since data buffers are from filesystem, and they might be above 256MB.
I guess we can define the zone size to 1MB for SiRFPrimaII, then result in less chance to cross normal and dma zone?
Quoted 3 lines
? ? ? ?Arnd
PATCH 1/1 ARM: CSR: Adding CSR SiRFprimaII board support
Quoted 9 lines · On Thursday 23 June 2011 09:42:01 Barry Song wrote:
2011/6/22 Arnd Bergmann <[email protected]>:
Quoted 5 lines · Barry Song
If your device tree describes a board with a prima2 SoC on it, and all prima2 chips are identical, then ("sirf,uart", "sirf,prima2-uart") is fine. If prima2 is itself a family of chips, you should add a third entry like "sirf,prima2-1234-uart" where 1234 is the model number of that chip.
i guess we can use ("sirf,uart", "sirf,prima2-uart", "sirf,prima2-1500-uart") for the moment.
Ok.
Quoted 17 lines
Quoted 8 lines
I don't completely understand. If you have actual PCI devices with a proper configuration space in the system, I would strongly suggest that you export the PCI host bridge instead of the individual devices and let the PCI probing code take care of that.
Using hardware probing mechanisms is normally preferred, because it means you don't have to list every device in the device tree.
Due to history reasons, SD controller is using ip core with pci interface. and its configuration is hard-coded in IC directly. and PrimaII doesn't support external pci devices too. PCI configuration and signals of SD are invisible to users and software at all. to software, we can't see anything related with pci from SD. when we are accessing sd controller, it looks like we are just accessing normal memory bus.
Quoted 2 lines
The DMA limitation of 256MB is also due to the design of internal PCI bridge. the bridge only can cover below 256MB.
Ok. As a feedback to the hardware designers, maybe you can tell them that we would very much appreciate being able to probe devices by looking at hardware registers instead of having to hardcode device locations for every single board. PCI config space is a well-established way to do that, so if you already use PCI components it would be nice to make them visible and compliant.
Obviously, it would also be really nice to not have to worry about arbitrary restrictions in DMA addresses.
Quoted 13 lines
Quoted 10 lines
I believe we already have a problem with
DEBUG_LLas soon as we get to multi-platform kernels.Quoted 4 lines
Another issue is that .init_early(fot this case, it is
sirfsoc_init_clk) is called earlier than kernel mm init and later than .map_io(for this case, it issirfsoc_map_io), the early static mapping makes .init_early can access mapped virtual memory too.But does
sirfsoc_init_clkhave to be called frominit_early, or can you do it a bit later?The sequence is
Quoted 8 lines
temp mapping of DEBUG uart in
head.S-> kernelpaging_init()-> static mapping of .map_io(build new mapping for uart) -> .init_early(prepare clock which .timer will access for this case) -> kernel mm init -> .timer ->arch_initcallbetween mm init and .timer, there are irq/prio_tree init, both seem not the right place to prepare clock. if i can move clock init behind mm init, ioremap should be ok. Then make codes ugly.
Ok, I see.
I wonder if this is getting better with the common clk handling.
Quoted 10 lines
Quoted 9 lines
Probably yes, it would also make the I/O slower because then you have to alway do bounce-buffering, while now you only have to do it when the user buffer is above 256 MB.
You should definitely make sure that the SD device has the correct
dma_maskset, which is required for correctness, while the rightARM_DMA_ZONE_SIZEis more a question of performance. When we get to multi-platform kernels, we can then just set the minimum of the configured platforms.
Quoted 3 lines
yes. we should have right dma masking to 256MB. Anyway, DMA bouncing is required since data buffers are from filesystem, and they might be above 256MB.
Bouncing will only be performed for pages that are actually over the limit, see __blk_queue_bounce(). If a system doesn't have over 256 MB, there will be no bouncing at all.
Quoted 2 lines
I guess we can define the zone size to 1MB for SiRFPrimaII, then result in less chance to cross normal and dma zone?
I don't see how that would help. Just leave it at 256 MB to give the allocator the most room.
Arnd
PATCH 1/1 ARM: CSR: Adding CSR SiRFprimaII board support
In reply to Russell King - ARM Linux2011/6/22 Russell King - ARM Linux <[email protected]>:
Quoted 52 lines
Some comments inline, nothing really serious...
Quoted 8 lines · Barry Song
+config
ARCH_PRIMA2
+ ? ? bool "CSR SiRFSoC PRIMA2 ARM Cortex A9 Platform"
+ ? ? selectCPU_V7
+ ? ? selectGENERIC_TIME
+ ? ? selectGENERIC_CLOCKEVENTS
+ ? ? selectCLKDEV_LOOKUP
+ ? ? selectUSE_OF
+ ? ? selectISA_DMA_APIDo you really provide the old ISA DMA API? ?Unless you're intending to use existing ISA drivers with their ISA DMA, you shouldn't define this.
Quoted 9 lines
arch/arm/Makefile +0
-0@@ -191,6 +191,7 @@ machine-$(CONFIG_ARCH_VEXPRESS) ? ? ? ? ? := vexpress?machine-$(CONFIG_ARCH_VT8500) ? ? ? ? ? ? ? ?:= vt8500 ?machine-$(CONFIG_ARCH_W90X900) ? ? ? ? ? ? ? := w90x900 ?machine-$(CONFIG_ARCH_NUC93X) ? ? ? ? ? ? ? ?:= nuc93x +machine-$(CONFIG_ARCH_PRIMA2) ? ? ? ? ? ? ? ?:= prima2
The comment at the start of this list says:
# Machine directory name. ?This list is sorted alphanumerically
# by CONFIG_* macro name.and I thank the NUC93x people for also missing it. ?Please ignore the NUC93x entry and place yours appropriately.
Quoted 19 lines
arch/arm/boot/dts/prima2-cb.dts new file +13
-0@@ -0,0 +1,44 @@ +/dts-v1/; +/ { + ? ? ? ?model = "SIRF Prima2 EVB"; + ? ? ? ?compatible = "sirf,prima2-cb", "sirf,prima2"; + ? ? #address-cells = <1>; + ? ? #size-cells = <1>; + ? ? interrupt-parent = <&intc>; + + ? ? ? ?memory { + ? ? ? ? ? ? ? ?reg = <0x00000000 0x20000000>; + ? ? ? ?}; + + ? ? chosen {
Quoted 8 lines
arch/arm/boot/dts/prima2-cb.dts line 18
Quoted 5 lines
arch/arm/boot/dts/prima2-cb.dts new file +5
-0+ ? ? ? ? ? ? bootargs = "mem=512M real_root=/dev/mmcblk0p2 console=ttyS1 earlyprintk"; + ? ? ? ? ? ? linux,stdout-path = &uart1; + ? ? }; + + ? ? amba {You declare that you have an AMBA bus, does it have primcells on it? Should you be selecting
ARM_AMBAin your kconfig?
Russell,
the chip has no primecells on it. And it seems we don't need ARM_AMBA. PrimaII uses AXI protocol, but has no AMBA IP controller. and many IP are self-defined. Nothing in the chip really has AMBA periph id. its layout is like
AXI(0-0x3FFFFFFF)
memory
AXI(0x40000000-0xC0000000)
CPUIF(sirf-iobus)
INTC
MEMC
LCD
VPP
GRAPHIC
MULTIMEDIA
GPS
UART
...
hard-coded PCI bridge
SD/MMC
rtc-iobrg
RTC
Quoted 207 lines
Quoted 11 lines
arch/arm/mach-prima2/include/mach/entry-macro.S new file +4
-0@@ -0,0 +1,28 @@ +/* + * arch/arm/mach-prima2/include/mach/entry-macro.S + * + * Copyright (c) 2011 Cambridge Silicon Radio Limited, a CSR plc group company.arch/arm/mach-prima2/include/mach/entry-macro.S line 14
Quoted 10 lines
arch/arm/mach-prima2/include/mach/entry-macro.S new file +10
-0+ * + * Licensed under GPLv2 or later. + */ + +#include <mach/hardware.h> + +#define SIRFSOC_INT_ID 0x38 + + ? ? .macro ?get_irqnr_and_base, irqnr, irqstat, base, tmp + ? ? ? ?ldr \base, =SIRFSOC_INTR_VA_BASEConsider using
get_irqnr_preambleto load the base address only once per IRQ exception.Quoted 10 lines
arch/arm/mach-prima2/include/mach/isa-dma.h new file +4
-0@@ -0,0 +1,14 @@ +/* +* arch/arm/mach-prima2/include/mach/io.h +* +* Copyright (c) 2011 Cambridge Silicon Radio Limited, a CSR plc group company. arch/arm/mach-prima2/include/mach/isa-dma.h line 14
Quoted 10 lines
arch/arm/mach-prima2/include/mach/isa-dma.h new file +10
-0+* +* Licensed under GPLv2 or later. +*/ + +#ifndef __MACH_PRIMA2_ISADMA_H +#define __MACH_PRIMA2_ISADMA_H + +#define MAX_DMA_CHANNELS 32 + +#endif You don't need this if you don't define
ISA_DMA_API.Quoted 12 lines
arch/arm/mach-prima2/include/mach/uncompress.h new file +6
-0@@ -0,0 +1,42 @@ +/* +* arch/arm/mach-prima2/include/mach/uncompress.h +* +* Copyright (c) 2011 Cambridge Silicon Radio Limited, a CSR plc group company. +* +* Licensed under GPLv2 or later. arch/arm/mach-prima2/include/mach/uncompress.h line 16
Quoted 10 lines
arch/arm/mach-prima2/include/mach/uncompress.h new file +10
-0+*/ + +#ifndef __ASM_ARCH_UNCOMPRESS_H +#define __ASM_ARCH_UNCOMPRESS_H + +#include <linux/bitops.h> +#include <linux/io.h> +#include <asm/processor.h> +#include <mach/hardware.h> +#include <mach/uart.h> If you include all that, then you're in for problems with the decompressor. The decompressor is a _really_ limited environment, and most stuff from linux/ or platfform stuff will not be available.
Quoted 6 lines
arch/arm/mach-prima2/irq.c new file +0
-0@@ -0,0 +1,81 @@...
Quoted 41 lines
arch/arm/mach-prima2/irq.c new file +41
-0+#define SIRFSOC_INT_PENDING0 ? ? ? ? ? ?0x0000 +#define SIRFSOC_INT_PENDING1 ? ? ? ? ? ?0x0004 +#define SIRFSOC_INT_IRQ_PENDING0 ? ? ? ?0x0008 +#define SIRFSOC_INT_IRQ_PENDING1 ? ? ? ?0x000C +#define SIRFSOC_INT_FIQ_PENDING0 ? ? ? ?0x0010 +#define SIRFSOC_INT_FIQ_PENDING1 ? ? ? ?0x0014 +#define SIRFSOC_INT_RISC_MASK0 ? ? ? ? ?0x0018 +#define SIRFSOC_INT_RISC_MASK1 ? ? ? ? ?0x001C +#define SIRFSOC_INT_RISC_LEVEL0 ? ? ? ? 0x0020 +#define SIRFSOC_INT_RISC_LEVEL1 ? ? ? ? 0x0024 + +static void sirfsoc_irq_ack (struct irq_data *d) +{ +} + +static void sirfsoc_irq_mask (struct irq_data *d) +{ + ? ? unsigned long mask; + + ? ? mask = __raw_readl(SIRFSOC_INTR_VA_BASE + SIRFSOC_INT_RISC_MASK0 + (d->irq / 32) * 4) & + ? ? ? ? ? ? ~(1 << ( d->irq % 32)); + ? ? __raw_writel(mask, SIRFSOC_INTR_VA_BASE + SIRFSOC_INT_RISC_MASK0 + (d->irq / 32) * 4); +} + +static void sirfsoc_irq_unmask (struct irq_data *d) +{ + ? ? unsigned long mask; + + ? ? mask = __raw_readl(SIRFSOC_INTR_VA_BASE + SIRFSOC_INT_RISC_MASK0 + (d->irq / 32) * 4) | + ? ? ? ? ? ? (1 << ( d->irq % 32)); + ? ? __raw_writel(mask, SIRFSOC_INTR_VA_BASE + SIRFSOC_INT_RISC_MASK0 + (d->irq / 32) * 4); +} + +int sirfsoc_irq_settype (struct irq_data *d,unsigned int type) +{ + ? ? /* + ? ? ?* Interrupt handler doesnt support setting trigger type + ? ? ?*/ + ? ? if (type == IRQ_TYPE_NONE) + ? ? ? ? ? ? return 0; +arch/arm/mach-prima2/irq.c
Quoted 10 lines
arch/arm/mach-prima2/irq.c new file +10
-0+ ? ? return -EINVAL; +} + +static struct irq_chip sirfsoc_irq_chip = { + ? ? .name = "SiRF SoC", + ? ? .irq_ack = sirfsoc_irq_ack, + ? ? .irq_mask = sirfsoc_irq_mask, + ? ? .irq_unmask = sirfsoc_irq_unmask, + ? ? .irq_set_type = sirfsoc_irq_settype, +};Can you use the recently introduced generic irqchips stuff for this?
Quoted 6 lines
arch/arm/mach-prima2/timer.c new file +0
-0@@ -0,0 +1,181 @@...
arch/arm/mach-prima2/timer.c
Quoted 6 lines
arch/arm/mach-prima2/timer.c new file +6
-0+/* initialize the kernel jiffy timer source */ +static void __init sirfsoc_timer_init (void ) +{ + ? ? unsigned long rate; + ? ? /* timer's input clock is io clock */ + ? ? struct clk *clk = clk_get(NULL, "io");Rather than going down this broken path of specifying clock names as connection IDs, it would be better to obtain it by function:
? ? ? ?struct clk *clk =clk_get_sys("timer", NULL);Experience shows that people think that naming the clock signals themselves and passing strings around to drivers is easier. ?After a few years they find that what they thought was easy, is actually inflexible and has become a huge problem which they need to rework. ?(Samsung folk are currently going through this pain.)
So please, don't fall into the trap of "lets give each clock signal a name and look up only by clock name". ?Use the device names as the primary matching and don't allow yourself to get into the trap of passing clock names around.
Quoted 2 lines
+
+ ? ? BUG_ON(IS_ERR_OR_NULL(clk));? ? ? ?BUG_ON(IS_ERR(clk));
If
clk_get()may return NULL, thenclk_get_rate()should be able to eat that value without choking.Quoted 3 lines
+
+ ? ? rate =clk_get_rate(clk);
+ ? ?clk_put(clk);It's much preferable not to
clk_put()a clock which you're going to continue using.arch/arm/mach-prima2/timer.c
Quoted 11 lines
arch/arm/mach-prima2/timer.c new file +11
-0+ + ? ? BUG_ON(rate < CLOCK_TICK_RATE); + ? ? BUG_ON(rate % CLOCK_TICK_RATE); + + ? ? __raw_writel(rate / CLOCK_TICK_RATE / 2 - 1, SIRFSOC_TIMER_VA_BASE + SIRFSOC_TIMER_DIV); + ? ? __raw_writel(0, SIRFSOC_TIMER_VA_BASE + SIRFSOC_TIMER_COUNTER_LO); + ? ? __raw_writel(0, SIRFSOC_TIMER_VA_BASE + SIRFSOC_TIMER_COUNTER_HI); + ? ? __raw_writel(BIT(0), SIRFSOC_TIMER_VA_BASE + SIRFSOC_TIMER_STATUS); + + ? ? if (clocksource_register_hz(&sirfsoc_clocksource, CLOCK_TICK_RATE)) + ? ? ? ? ? ? BUG();Confused. ?CLOCK_TICK_RATE is defined to be 100 * HZ, so 10kHz. ?Do your timers really tick at 10kHz? ?That seems needlessly slow for a 64-bit counter. ?Also consider
BUG_ON()Quoted 3 lines
+
+ ? ? if (setup_irq(sirfsoc_timer_irq.irq, &sirfsoc_timer_irq))
+ ? ? ? ? ? ?BUG();
BUG_ON()here too._______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel at lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel