From c121c5063c0674fad6811f0b0d86ec3bc6eecbbd Mon Sep 17 00:00:00 2001 From: Vineet Gupta Date: Fri, 18 Jan 2013 15:12:20 +0530 Subject: ARC: Boot #1: low-level, setup_arch(), /proc/cpuinfo, mem init Signed-off-by: Vineet Gupta Acked-by: Arnd Bergmann --- arch/arc/plat-arcfpga/platform.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 arch/arc/plat-arcfpga/platform.c (limited to 'arch/arc/plat-arcfpga/platform.c') diff --git a/arch/arc/plat-arcfpga/platform.c b/arch/arc/plat-arcfpga/platform.c new file mode 100644 index 000000000000..7b5dcab5becb --- /dev/null +++ b/arch/arc/plat-arcfpga/platform.c @@ -0,0 +1,29 @@ +/* + * ARC FPGA Platform support code + * + * Copyright (C) 2012 Synopsys, Inc. (www.synopsys.com) + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + */ + +#include +#include +#include + +/* + * Early Platform Initialization called from setup_arch() + */ +void __init arc_platform_early_init(void) +{ + pr_info("[plat-arcfpga]: registering early dev resources\n"); +} + +int __init fpga_plat_init(void) +{ + pr_info("[plat-arcfpga]: registering device resources\n"); + + return 0; +} +arch_initcall(fpga_plat_init); -- cgit v1.2.3 From ee36d1722112f33725ec1a7fc02f6c46e630fd27 Mon Sep 17 00:00:00 2001 From: Vineet Gupta Date: Fri, 18 Jan 2013 15:12:20 +0530 Subject: ARC: [plat-arcfpga] Static platform device for CONFIG_SERIAL_ARC N.B. This is old style of hardcoding platform device specific info in code and it's instantiation thererof using platform_add_devices(). Subsequent patches replace this with DeviceTree based runtime probe. This patch has been retained just as an example of "don't-do-this" for newer kernel ports. Signed-off-by: Vineet Gupta Cc: Arnd Bergmann --- arch/arc/plat-arcfpga/platform.c | 108 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 108 insertions(+) (limited to 'arch/arc/plat-arcfpga/platform.c') diff --git a/arch/arc/plat-arcfpga/platform.c b/arch/arc/plat-arcfpga/platform.c index 7b5dcab5becb..5388b31e2ead 100644 --- a/arch/arc/plat-arcfpga/platform.c +++ b/arch/arc/plat-arcfpga/platform.c @@ -10,7 +10,102 @@ #include #include +#include #include +#include +#include +#include +#include +#include + +/*----------------------- Platform Devices -----------------------------*/ + +#if defined(CONFIG_SERIAL_ARC) || defined(CONFIG_SERIAL_ARC_MODULE) + +static unsigned long arc_uart_info[] = { + CONFIG_ARC_SERIAL_BAUD, /* uart->baud */ + -1, /* uart->port.uartclk */ + -1, /* uart->is_emulated (runtime @running_on_hw) */ + 0 +}; + +#define ARC_UART_DEV(n) \ + \ +static struct resource arc_uart##n##_res[] = { \ + { \ + .start = UART##n##_BASE, \ + .end = UART##n##_BASE + 0xFF, \ + .flags = IORESOURCE_MEM, \ + }, \ + { \ + .start = UART##n##_IRQ, \ + .end = UART##n##_IRQ, \ + .flags = IORESOURCE_IRQ, \ + }, \ +}; \ + \ +static struct platform_device arc_uart##n##_dev = { \ + .name = "arc-uart", \ + .id = n, \ + .num_resources = ARRAY_SIZE(arc_uart##n##_res), \ + .resource = arc_uart##n##_res, \ + .dev = { \ + .platform_data = &arc_uart_info, \ + }, \ +} + +ARC_UART_DEV(0); +#if CONFIG_SERIAL_ARC_NR_PORTS > 1 +ARC_UART_DEV(1); +#endif + +static struct platform_device *fpga_early_devs[] __initdata = { +#if defined(CONFIG_SERIAL_ARC_CONSOLE) + &arc_uart0_dev, +#endif +}; + +static void arc_fpga_serial_init(void) +{ + arc_uart_info[1] = arc_get_core_freq(); + + /* To let driver workaround ISS bug: baudh Reg can't be set to 0 */ + arc_uart_info[2] = !running_on_hw; + + early_platform_add_devices(fpga_early_devs, + ARRAY_SIZE(fpga_early_devs)); + + /* + * ARC console driver registers itself as an early platform driver + * of class "earlyprintk". + * Install it here, followed by probe of devices. + * The installation here doesn't require earlyprintk in command line + * To do so however, replace the lines below with + * parse_early_param(); + * early_platform_driver_probe("earlyprintk", 1, 1); + * ^^ + */ + early_platform_driver_register_all("earlyprintk"); + early_platform_driver_probe("earlyprintk", 1, 0); + + /* + * This is to make sure that arc uart would be preferred console + * despite one/more of following: + * -command line lacked "console=ttyARC0" or + * -CONFIG_VT_CONSOLE was enabled (for no reason whatsoever) + * Note that this needs to be done after above early console is reg, + * otherwise the early console never gets a chance to run. + */ + add_preferred_console("ttyARC", 0, "115200"); +} + +#else + +static void arc_fpga_serial_init(void) +{ +} + +#endif /* CONFIG_SERIAL_ARC */ /* * Early Platform Initialization called from setup_arch() @@ -18,12 +113,25 @@ void __init arc_platform_early_init(void) { pr_info("[plat-arcfpga]: registering early dev resources\n"); + + arc_fpga_serial_init(); } +static struct platform_device *fpga_devs[] __initdata = { +#if defined(CONFIG_SERIAL_ARC) || defined(CONFIG_SERIAL_ARC_MODULE) + &arc_uart0_dev, +#if CONFIG_SERIAL_ARC_NR_PORTS > 1 + &arc_uart1_dev, +#endif +#endif +}; + int __init fpga_plat_init(void) { pr_info("[plat-arcfpga]: registering device resources\n"); + platform_add_devices(fpga_devs, ARRAY_SIZE(fpga_devs)); + return 0; } arch_initcall(fpga_plat_init); -- cgit v1.2.3 From abe11ddea1d759f9995a9a4636c28c9b40856ca8 Mon Sep 17 00:00:00 2001 From: Vineet Gupta Date: Fri, 18 Jan 2013 15:12:21 +0530 Subject: ARC: [plat-arcfpga]: Enabling DeviceTree for Angel4 board * arc-uart platform device now populated dynamically, using of_platform_populate() - applies to any other device whatsoever. * uart in turn requires incore arc-intc to be also present in DT * A irq-domain needs to be instantiated for IRQ requests by DT probed device (e.g. arc-uart) TODO: switch over to linear irq domain once all devs have been transitioned to DT Signed-off-by: Vineet Gupta Cc: Grant Likely Cc: Arnd Bergmann --- arch/arc/plat-arcfpga/platform.c | 97 +++++++++++++++++++--------------------- 1 file changed, 46 insertions(+), 51 deletions(-) (limited to 'arch/arc/plat-arcfpga/platform.c') diff --git a/arch/arc/plat-arcfpga/platform.c b/arch/arc/plat-arcfpga/platform.c index 5388b31e2ead..33bcac8bd6b8 100644 --- a/arch/arc/plat-arcfpga/platform.c +++ b/arch/arc/plat-arcfpga/platform.c @@ -13,6 +13,7 @@ #include #include #include +#include #include #include #include @@ -20,58 +21,56 @@ /*----------------------- Platform Devices -----------------------------*/ -#if defined(CONFIG_SERIAL_ARC) || defined(CONFIG_SERIAL_ARC_MODULE) - static unsigned long arc_uart_info[] = { - CONFIG_ARC_SERIAL_BAUD, /* uart->baud */ - -1, /* uart->port.uartclk */ - -1, /* uart->is_emulated (runtime @running_on_hw) */ + 0, /* uart->is_emulated (runtime @running_on_hw) */ + 0, /* uart->port.uartclk */ + 0, /* uart->baud */ 0 }; -#define ARC_UART_DEV(n) \ - \ -static struct resource arc_uart##n##_res[] = { \ - { \ - .start = UART##n##_BASE, \ - .end = UART##n##_BASE + 0xFF, \ - .flags = IORESOURCE_MEM, \ - }, \ - { \ - .start = UART##n##_IRQ, \ - .end = UART##n##_IRQ, \ - .flags = IORESOURCE_IRQ, \ - }, \ -}; \ - \ -static struct platform_device arc_uart##n##_dev = { \ - .name = "arc-uart", \ - .id = n, \ - .num_resources = ARRAY_SIZE(arc_uart##n##_res), \ - .resource = arc_uart##n##_res, \ - .dev = { \ - .platform_data = &arc_uart_info, \ - }, \ -} +#if defined(CONFIG_SERIAL_ARC_CONSOLE) +/* + * static platform data - but only for early serial + * TBD: derive this from a special DT node + */ +static struct resource arc_uart0_res[] = { + { + .start = UART0_BASE, + .end = UART0_BASE + 0xFF, + .flags = IORESOURCE_MEM, + }, + { + .start = UART0_IRQ, + .end = UART0_IRQ, + .flags = IORESOURCE_IRQ, + }, +}; -ARC_UART_DEV(0); -#if CONFIG_SERIAL_ARC_NR_PORTS > 1 -ARC_UART_DEV(1); -#endif +static struct platform_device arc_uart0_dev = { + .name = "arc-uart", + .id = 0, + .num_resources = ARRAY_SIZE(arc_uart0_res), + .resource = arc_uart0_res, + .dev = { + .platform_data = &arc_uart_info, + }, +}; static struct platform_device *fpga_early_devs[] __initdata = { -#if defined(CONFIG_SERIAL_ARC_CONSOLE) &arc_uart0_dev, -#endif }; +#endif static void arc_fpga_serial_init(void) { + /* To let driver workaround ISS bug: baudh Reg can't be set to 0 */ + arc_uart_info[0] = !running_on_hw; + arc_uart_info[1] = arc_get_core_freq(); - /* To let driver workaround ISS bug: baudh Reg can't be set to 0 */ - arc_uart_info[2] = !running_on_hw; + arc_uart_info[2] = CONFIG_ARC_SERIAL_BAUD; +#if defined(CONFIG_SERIAL_ARC_CONSOLE) early_platform_add_devices(fpga_early_devs, ARRAY_SIZE(fpga_early_devs)); @@ -97,16 +96,9 @@ static void arc_fpga_serial_init(void) * otherwise the early console never gets a chance to run. */ add_preferred_console("ttyARC", 0, "115200"); +#endif } -#else - -static void arc_fpga_serial_init(void) -{ -} - -#endif /* CONFIG_SERIAL_ARC */ - /* * Early Platform Initialization called from setup_arch() */ @@ -117,20 +109,23 @@ void __init arc_platform_early_init(void) arc_fpga_serial_init(); } -static struct platform_device *fpga_devs[] __initdata = { +static struct of_dev_auxdata plat_auxdata_lookup[] __initdata = { #if defined(CONFIG_SERIAL_ARC) || defined(CONFIG_SERIAL_ARC_MODULE) - &arc_uart0_dev, -#if CONFIG_SERIAL_ARC_NR_PORTS > 1 - &arc_uart1_dev, -#endif + OF_DEV_AUXDATA("snps,arc-uart", UART0_BASE, "arc-uart", arc_uart_info), #endif + {} }; int __init fpga_plat_init(void) { pr_info("[plat-arcfpga]: registering device resources\n"); - platform_add_devices(fpga_devs, ARRAY_SIZE(fpga_devs)); + /* + * Traverses flattened DeviceTree - registering platform devices + * complete with their resources + */ + of_platform_populate(NULL, of_default_bus_match_table, + plat_auxdata_lookup, NULL); return 0; } -- cgit v1.2.3 From 7fadc1e8fe89698caac213ff6d631b811fc7b393 Mon Sep 17 00:00:00 2001 From: Vineet Gupta Date: Fri, 18 Jan 2013 15:12:24 +0530 Subject: ARC: [plat-arfpga] BVCI Latency Unit setup Signed-off-by: Vineet Gupta --- arch/arc/plat-arcfpga/platform.c | 56 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) (limited to 'arch/arc/plat-arcfpga/platform.c') diff --git a/arch/arc/plat-arcfpga/platform.c b/arch/arc/plat-arcfpga/platform.c index 33bcac8bd6b8..b7f63e3f3cae 100644 --- a/arch/arc/plat-arcfpga/platform.c +++ b/arch/arc/plat-arcfpga/platform.c @@ -12,6 +12,7 @@ #include #include #include +#include #include #include #include @@ -19,6 +20,59 @@ #include #include +/*-----------------------BVCI Latency Unit -----------------------------*/ + +#ifdef CONFIG_ARC_HAS_BVCI_LAT_UNIT + +int lat_cycles = CONFIG_BVCI_LAT_CYCLES; + +/* BVCI Bus Profiler: Latency Unit */ +static void __init setup_bvci_lat_unit(void) +{ +#define MAX_BVCI_UNITS 12 + + unsigned int i; + unsigned int *base = (unsigned int *)BVCI_LAT_UNIT_BASE; + const unsigned long units_req = CONFIG_BVCI_LAT_UNITS; + const unsigned int REG_UNIT = 21; + const unsigned int REG_VAL = 22; + + /* + * There are multiple Latency Units corresponding to the many + * interfaces of the system bus arbiter (both CPU side as well as + * the peripheral side). + * + * Unit 0 - System Arb and Mem Controller - adds latency to all + * memory trasactions + * Unit 1 - I$ and System Bus + * Unit 2 - D$ and System Bus + * .. + * Unit 12 - IDE Disk controller and System Bus + * + * The programmers model requires writing to lat_unit reg first + * and then the latency value (cycles) to lat_value reg + */ + + if (CONFIG_BVCI_LAT_UNITS == 0) { + writel(0, base + REG_UNIT); + writel(lat_cycles, base + REG_VAL); + pr_info("BVCI Latency for all Memory Transactions %d cycles\n", + lat_cycles); + } else { + for_each_set_bit(i, &units_req, MAX_BVCI_UNITS) { + writel(i + 1, base + REG_UNIT); /* loop is 0 based */ + writel(lat_cycles, base + REG_VAL); + pr_info("BVCI Latency for Unit[%d] = %d cycles\n", + (i + 1), lat_cycles); + } + } +} +#else +static void __init setup_bvci_lat_unit(void) +{ +} +#endif + /*----------------------- Platform Devices -----------------------------*/ static unsigned long arc_uart_info[] = { @@ -106,6 +160,8 @@ void __init arc_platform_early_init(void) { pr_info("[plat-arcfpga]: registering early dev resources\n"); + setup_bvci_lat_unit(); + arc_fpga_serial_init(); } -- cgit v1.2.3 From 877768c84d6ca8f7dedafff0e44615a12e82f8f4 Mon Sep 17 00:00:00 2001 From: Vineet Gupta Date: Wed, 23 Jan 2013 16:32:48 +0530 Subject: ARC: [Review] Multi-platform image #3: switch to board callback -platform API is retired and instead callbacks are used Signed-off-by: Vineet Gupta Cc: Arnd Bergmann Acked-by: Arnd Bergmann --- arch/arc/plat-arcfpga/platform.c | 50 +++++++++++++++++++++++++++++++++------- 1 file changed, 42 insertions(+), 8 deletions(-) (limited to 'arch/arc/plat-arcfpga/platform.c') diff --git a/arch/arc/plat-arcfpga/platform.c b/arch/arc/plat-arcfpga/platform.c index b7f63e3f3cae..ac85d6927334 100644 --- a/arch/arc/plat-arcfpga/platform.c +++ b/arch/arc/plat-arcfpga/platform.c @@ -18,7 +18,9 @@ #include #include #include +#include #include +#include /*-----------------------BVCI Latency Unit -----------------------------*/ @@ -153,10 +155,7 @@ static void arc_fpga_serial_init(void) #endif } -/* - * Early Platform Initialization called from setup_arch() - */ -void __init arc_platform_early_init(void) +static void __init plat_fpga_early_init(void) { pr_info("[plat-arcfpga]: registering early dev resources\n"); @@ -172,7 +171,7 @@ static struct of_dev_auxdata plat_auxdata_lookup[] __initdata = { {} }; -int __init fpga_plat_init(void) +static void __init plat_fpga_populate_dev(void) { pr_info("[plat-arcfpga]: registering device resources\n"); @@ -182,7 +181,42 @@ int __init fpga_plat_init(void) */ of_platform_populate(NULL, of_default_bus_match_table, plat_auxdata_lookup, NULL); - - return 0; } -arch_initcall(fpga_plat_init); + +/*----------------------- Machine Descriptions ------------------------------ + * + * Machine description is simply a set of platform/board specific callbacks + * This is not directly related to DeviceTree based dynamic device creation, + * however as part of early device tree scan, we also select the right + * callback set, by matching the DT compatible name. + */ + +static const char *aa4_compat[] __initdata = { + "snps,arc-angel4", + NULL, +}; + +MACHINE_START(ANGEL4, "angel4") + .dt_compat = aa4_compat, + .init_early = plat_fpga_early_init, + .init_machine = plat_fpga_populate_dev, + .init_irq = plat_fpga_init_IRQ, +#ifdef CONFIG_SMP + .init_smp = iss_model_init_smp, +#endif +MACHINE_END + +static const char *ml509_compat[] __initdata = { + "snps,arc-ml509", + NULL, +}; + +MACHINE_START(ML509, "ml509") + .dt_compat = ml509_compat, + .init_early = plat_fpga_early_init, + .init_machine = plat_fpga_populate_dev, + .init_irq = plat_fpga_init_IRQ, +#ifdef CONFIG_SMP + .init_smp = iss_model_init_smp, +#endif +MACHINE_END -- cgit v1.2.3 From e97ff121ae61ba80e41b2cc3bd6dfe9886d22505 Mon Sep 17 00:00:00 2001 From: Vineet Gupta Date: Fri, 18 Jan 2013 15:12:26 +0530 Subject: ARC: [Review] Multi-platform image #4: Isolate platform headers -Top level ARC makefile removes -I for platform headers -asm/irq.h no longer includes plat/irq.h -platform makefile adds -I for it's specfic platform headers -platform code to directly include it's plat/irq.h -Linker script needed plat/memmap.h for CCM info, already in .config Signed-off-by: Vineet Gupta Cc: Arnd Bergmann Acked-by: Arnd Bergmann --- arch/arc/plat-arcfpga/platform.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'arch/arc/plat-arcfpga/platform.c') diff --git a/arch/arc/plat-arcfpga/platform.c b/arch/arc/plat-arcfpga/platform.c index ac85d6927334..4024f10a39ca 100644 --- a/arch/arc/plat-arcfpga/platform.c +++ b/arch/arc/plat-arcfpga/platform.c @@ -16,11 +16,11 @@ #include #include #include -#include #include #include #include #include +#include /*-----------------------BVCI Latency Unit -----------------------------*/ -- cgit v1.2.3 From b830cde5a486d1157105fe928dfa0ddcb9f1b840 Mon Sep 17 00:00:00 2001 From: Vineet Gupta Date: Fri, 18 Jan 2013 15:12:26 +0530 Subject: ARC: [Review] Multi-platform image #8: platform registers SMP callbacks Platforms export their SMP callbacks by populating arc_smp_ops. The population itself needs to be done pretty early, from init_early callback. Signed-off-by: Vineet Gupta Cc: Arnd Bergmann --- arch/arc/plat-arcfpga/platform.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'arch/arc/plat-arcfpga/platform.c') diff --git a/arch/arc/plat-arcfpga/platform.c b/arch/arc/plat-arcfpga/platform.c index 4024f10a39ca..4e20a1a5104d 100644 --- a/arch/arc/plat-arcfpga/platform.c +++ b/arch/arc/plat-arcfpga/platform.c @@ -162,6 +162,10 @@ static void __init plat_fpga_early_init(void) setup_bvci_lat_unit(); arc_fpga_serial_init(); + +#ifdef CONFIG_SMP + iss_model_init_early_smp(); +#endif } static struct of_dev_auxdata plat_auxdata_lookup[] __initdata = { -- cgit v1.2.3