vexpress: detect the mapping based on the amba devices
Subsystems (6)
cover vexpress: detect the mapping based on the amba devices
HI,
so we can run on a9 on the non legacy hw
The following changes since commit 2d91386102612773074832d55e2ef11702fbb432:
arm: add vexpress board support (2013-02-12 05:53:04 +0800)
are available in the git repository at:
git://git.jcrosoft.org/barebox.git delivery/vexpress
for you to fetch changes up to 92b8828ad6b2b01248bd84888b8bbf920df85c31:
vexpress: detect the board periph mapping and detecting the sp804 mapping (2013-02-12 05:53:04 +0800)
----------------------------------------------------------------
Jean-Christophe PLAGNIOL-VILLARD (3):
amba: introduce amba_device_get_pid/cid
sp804: introduce amba_is_arm_sp804 to detect if the sp804 is present at the address
vexpress: detect the board periph mapping and detecting the sp804 mapping
arch/arm/boards/vexpress/init.c | 35 +++++++++++++++++++---------------- arch/arm/boards/vexpress/lowlevel.c | 4 +++- arch/arm/mach-vexpress/devices.c | 4 ++-- arch/arm/mach-vexpress/include/mach/devices.h | 6 +++--- arch/arm/mach-vexpress/v2m.c | 2 +- drivers/amba/bus.c | 10 +++------- drivers/clocksource/amba-sp804.c | 6 +++--- include/linux/amba/bus.h | 28 ++++++++++++++++++++++++++++ include/linux/amba/sp804.h | 30 ++++++++++++++++++++++++++++++ 9 files changed, 92 insertions(+), 33 deletions(-) create mode 100644 include/linux/amba/sp804.h
Best Regards,
J.
_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
PATCH 1/3 amba: introduce amba_device_get_pid/cid
so we can use it on vexpress to detect the hardware mapping
--- drivers/amba/bus.c | 10 +++------- include/linux/amba/bus.h | 28 ++++++++++++++++++++++++++++ 2 files changed, 31 insertions(+), 7 deletions(-)
drivers/amba/bus.c +3 -7
@@ -104,7 +104,7 @@ int amba_device_add(struct amba_device *dev) {u32 size;void __iomem *tmp; -int i, ret; +int ret;struct resource *res =NULL ; dev->dev.bus = &amba_bustype;
@@ -135,12 +135,8 @@ int amba_device_add(struct amba_device *dev)* Read pid and cid based on size of resource * they are located at end of region */ -for (pid =0 , i =0 ; i <4 ; i++) - pid |= (readl (tmp + size -0x20 +4 * i) &255 ) << - (i *8 ); -for (cid =0 , i =0 ; i <4 ; i++) - cid |= (readl (tmp + size -0x10 +4 * i) &255 ) << - (i *8 ); + pid =amba_device_get_pid (tmp, size); + cid =amba_device_get_cid (tmp, size);if (cid ==AMBA_CID ) dev->periphid = pid;
include/linux/amba/bus.h +28 -0
@@ -150,4 +150,32 @@ struct amba_device name##_device = { \ .periphid = id, \ } +#include <io.h> +/* +* Read pid and cid based on size of resource +* they are located at end of region +*/ +static inline u32 amba_device_get_pid (void *base,u32 size) +{ +int i; +u32 pid; + +for (pid =0 , i =0 ; i <4 ; i++) + pid |= (readl (base + size -0x20 +4 * i) &255 ) << + (i *8 ); + +return pid; +} + +static inline u32 amba_device_get_cid (void *base,u32 size) +{ +int i; +u32 cid; + +for (cid =0 , i =0 ; i <4 ; i++) + cid |= (readl (base + size -0x10 +4 * i) &255 ) << + (i *8 ); + +return cid; +}#endif
Signature · 7 lines
1.7.10.4 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
PATCH 2/3 sp804: introduce amba_is_arm_sp804 to detect if the sp804 is present at the address
--- drivers/clocksource/amba-sp804.c | 6 +++--- include/linux/amba/sp804.h | 30 ++++++++++++++++++++++++++++++ 2 files changed, 33 insertions(+), 3 deletions(-) create mode 100644 include/linux/amba/sp804.h
drivers/clocksource/amba-sp804.c +3 -3
@@ -9,7 +9,7 @@#include <io.h> #include <driver.h> #include <errno.h> -#include <linux/amba/bus.h> +#include <linux/amba/sp804.h> #include <linux/clk.h> #include <linux/err.h>
@@ -73,8 +73,8 @@ static int sp804_probe(struct amba_device *dev, const struct amba_id *id)static struct amba_id sp804_ids[] = { { - .id =0x00141804 , - .mask =0x00ffffff , + .id =AMBA_ARM_SP804_ID , + .mask =AMBA_ARM_SP804_ID_MASK , }, {0 ,0 }, };
include/linux/amba/sp804.h new file +30 -0
@@ -0,0 +1,30 @@ +/* +* Copyright (C) 2013 Jean-Christophe PLAGNIOL-VILLARD <[email protected]> +* +* GPLv2 only +*/ + +#ifndef __AMBA_SP804_H__ +#define __AMBA_SP804_H__ + +#include <linux/amba/bus.h> +#include <sizes.h> + +#define AMBA_ARM_SP804_ID 0x00141804 +#define AMBA_ARM_SP804_ID_MASK 0x00ffffff + +static inline bool amba_is_arm_sp804 (void __iomem *base) +{ +u32 pid, cid; +u32 size =SZ_4K ; + + cid =amba_device_get_cid (base, size); + +if (cid !=AMBA_CID ) +return false; + + pid =amba_device_get_pid (base, size); + +return (pid &AMBA_ARM_SP804_ID_MASK ) ==AMBA_ARM_SP804_ID ; +} +#endif /* __AMBA_SP804_H__ */
Signature · 7 lines
1.7.10.4 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
PATCH 3/3 vexpress: detect the board periph mapping and detecting the sp804 mapping
In reply to Jean-Christophe PLAGNIOL-VILLARDat 0x10011000 for a9 legacy otherwise at 0x1c110000
as the new board also support Cortex-A9
so this is working
qemu/arm-softmmu/qemu-system-arm -M vexpress-a15 -m 1024 -smp 1 -kernel build/vexpress/barebox -pflash build/vexpress/flash -nographic -cpu cortex-a9
--- arch/arm/boards/vexpress/init.c | 35 ++++++++++++++----------- arch/arm/boards/vexpress/lowlevel.c | 4 ++- arch/arm/mach-vexpress/devices.c | 4 +-- arch/arm/mach-vexpress/include/mach/devices.h | 6 ++--- arch/arm/mach-vexpress/v2m.c | 2 +- 5 files changed, 28 insertions(+), 23 deletions(-)
arch/arm/boards/vexpress/init.c +19 -16
@@ -15,6 +15,7 @@#include <sizes.h> #include <io.h> #include <globalvar.h> +#include <linux/amba/sp804.h> struct vexpress_init {void (*core_init)(void );
@@ -57,12 +58,12 @@ struct vexpress_init vexpress_init_ax = { .devices_init = vexpress_ax_devices_init, }; -static void vexpress_a9_mem_init (void ) +static void vexpress_a9_legacy_mem_init (void ) { -vexpress_a9_add_ddram (SZ_512M ,SZ_512M ); +vexpress_a9_legacy_add_ddram (SZ_512M ,SZ_512M ); } -static void vexpress_a9_devices_init (void ) +static void vexpress_a9_legacy_devices_init (void ) {add_cfi_flash_device (0 ,0x40000000 ,SZ_64M ,0 );add_cfi_flash_device (1 ,0x44000000 ,SZ_64M ,0 );
@@ -73,20 +74,20 @@ static void vexpress_a9_devices_init(void)armlinux_set_bootparams ((void *)(0x60000100 )); } -static void vexpress_a9_console_init (void ) +static void vexpress_a9_legacy_console_init (void ) { -vexpress_a9_register_uart (0 ); -vexpress_a9_register_uart (1 ); -vexpress_a9_register_uart (2 ); -vexpress_a9_register_uart (3 ); +vexpress_a9_legacy_register_uart (0 ); +vexpress_a9_legacy_register_uart (1 ); +vexpress_a9_legacy_register_uart (2 ); +vexpress_a9_legacy_register_uart (3 ); } -struct vexpress_init vexpress_init_a9 = { - .core_init = vexpress_a9_init, - .mem_init = vexpress_a9_mem_init, - .console_init = vexpress_a9_console_init, - .devices_init = vexpress_a9_devices_init, - .hostname ="vexpress-a9" , +struct vexpress_init vexpress_init_a9_legacy = { + .core_init = vexpress_a9_legacy_init, + .mem_init = vexpress_a9_legacy_mem_init, + .console_init = vexpress_a9_legacy_console_init, + .devices_init = vexpress_a9_legacy_devices_init, + .hostname ="vexpress-a9-legacy" , };static int vexpress_mem_init (void )
@@ -123,14 +124,16 @@ console_initcall(vexpress_console_init);static int vexpress_core_init (void ) { -if (cpu_is_cortex_a9 ()) { - v2m_init = &vexpress_init_a9; +if (amba_is_arm_sp804 (IOMEM (0x10011000 ))) { + v2m_init = &vexpress_init_a9_legacy; }else { v2m_init = &vexpress_init_ax;if (cpu_is_cortex_a5 ()) v2m_init->hostname ="vexpress-a5" ;else if (cpu_is_cortex_a7 ()) v2m_init->hostname ="vexpress-a7" ; +else if (cpu_is_cortex_a9 ()) + v2m_init->hostname ="vexpress-a9" ;else if (cpu_is_cortex_a15 ()) v2m_init->hostname ="vexpress-a15" ; }
arch/arm/boards/vexpress/lowlevel.c +3 -1
@@ -9,11 +9,13 @@#include <asm/barebox-arm-head.h> #include <asm/barebox-arm.h> #include <asm/system_info.h> +#include <linux/amba/sp804.h> void __naked reset (void ) {common_reset (); -if (cpu_is_cortex_a9 ()) + +if (amba_is_arm_sp804 (IOMEM (0x10011000 )))barebox_arm_entry (0x60000000 ,SZ_512M ,0 );else barebox_arm_entry (0x80000000 ,SZ_512M ,0 );
arch/arm/mach-vexpress/devices.c +2 -2
@@ -12,7 +12,7 @@#include <mach/devices.h> -void vexpress_a9_add_ddram (u32 ddr0_size,u32 ddr1_size) +void vexpress_a9_legacy_add_ddram (u32 ddr0_size,u32 ddr1_size) {arm_add_mem_device ("ram0" ,0x60000000 , ddr0_size);
@@ -21,7 +21,7 @@ void vexpress_a9_add_ddram(u32 ddr0_size, u32 ddr1_size) } -void vexpress_a9_register_uart (unsigned id) +void vexpress_a9_legacy_register_uart (unsigned id) {resource_size_t start;
arch/arm/mach-vexpress/include/mach/devices.h +3 -3
@@ -7,13 +7,13 @@#ifndef __ASM_ARCH_DEVICES_H__#define __ASM_ARCH_DEVICES_H__ -void vexpress_a9_add_ddram (u32 ddr0_size,u32 ddr1_size); +void vexpress_a9_legacy_add_ddram (u32 ddr0_size,u32 ddr1_size);void vexpress_add_ddram (u32 size); -void vexpress_a9_register_uart (unsigned id); +void vexpress_a9_legacy_register_uart (unsigned id);void vexpress_register_uart (unsigned id); -void vexpress_a9_init (void ); +void vexpress_a9_legacy_init (void );void vexpress_init (void );extern void *v2m_wdt_base;
arch/arm/mach-vexpress/v2m.c +1 -1
@@ -64,7 +64,7 @@ static void __init v2m_sp804_init(void __iomem *base)amba_apb_device_add (NULL ,"sp804" ,DEVICE_ID_SINGLE , (resource_size_t )base,4096 ,NULL ,0 ); } -void vexpress_a9_init (void ) +void vexpress_a9_legacy_init (void ) { v2m_wdt_base =IOMEM (0x1000f000 ); v2m_sysreg_base =IOMEM (0x10001000 );
Signature · 7 lines
1.7.10.4 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox