18c2ecf20Sopenharmony_ci// SPDX-License-Identifier: GPL-2.0-only 28c2ecf20Sopenharmony_ci/* 38c2ecf20Sopenharmony_ci * AXS101/AXS103 Software Development Platform 48c2ecf20Sopenharmony_ci * 58c2ecf20Sopenharmony_ci * Copyright (C) 2013-15 Synopsys, Inc. (www.synopsys.com) 68c2ecf20Sopenharmony_ci */ 78c2ecf20Sopenharmony_ci 88c2ecf20Sopenharmony_ci#include <linux/of_fdt.h> 98c2ecf20Sopenharmony_ci#include <linux/of_platform.h> 108c2ecf20Sopenharmony_ci#include <linux/libfdt.h> 118c2ecf20Sopenharmony_ci 128c2ecf20Sopenharmony_ci#include <asm/asm-offsets.h> 138c2ecf20Sopenharmony_ci#include <asm/io.h> 148c2ecf20Sopenharmony_ci#include <asm/mach_desc.h> 158c2ecf20Sopenharmony_ci#include <soc/arc/mcip.h> 168c2ecf20Sopenharmony_ci 178c2ecf20Sopenharmony_ci#define AXS_MB_CGU 0xE0010000 188c2ecf20Sopenharmony_ci#define AXS_MB_CREG 0xE0011000 198c2ecf20Sopenharmony_ci 208c2ecf20Sopenharmony_ci#define CREG_MB_IRQ_MUX (AXS_MB_CREG + 0x214) 218c2ecf20Sopenharmony_ci#define CREG_MB_SW_RESET (AXS_MB_CREG + 0x220) 228c2ecf20Sopenharmony_ci#define CREG_MB_VER (AXS_MB_CREG + 0x230) 238c2ecf20Sopenharmony_ci#define CREG_MB_CONFIG (AXS_MB_CREG + 0x234) 248c2ecf20Sopenharmony_ci 258c2ecf20Sopenharmony_ci#define AXC001_CREG 0xF0001000 268c2ecf20Sopenharmony_ci#define AXC001_GPIO_INTC 0xF0003000 278c2ecf20Sopenharmony_ci 288c2ecf20Sopenharmony_cistatic void __init axs10x_enable_gpio_intc_wire(void) 298c2ecf20Sopenharmony_ci{ 308c2ecf20Sopenharmony_ci /* 318c2ecf20Sopenharmony_ci * Peripherals on CPU Card and Mother Board are wired to cpu intc via 328c2ecf20Sopenharmony_ci * intermediate DW APB GPIO blocks (mainly for debouncing) 338c2ecf20Sopenharmony_ci * 348c2ecf20Sopenharmony_ci * --------------------- 358c2ecf20Sopenharmony_ci * | snps,arc700-intc | 368c2ecf20Sopenharmony_ci * --------------------- 378c2ecf20Sopenharmony_ci * | #7 | #15 388c2ecf20Sopenharmony_ci * ------------------- ------------------- 398c2ecf20Sopenharmony_ci * | snps,dw-apb-gpio | | snps,dw-apb-gpio | 408c2ecf20Sopenharmony_ci * ------------------- ------------------- 418c2ecf20Sopenharmony_ci * | #12 | 428c2ecf20Sopenharmony_ci * | [ Debug UART on cpu card ] 438c2ecf20Sopenharmony_ci * | 448c2ecf20Sopenharmony_ci * ------------------------ 458c2ecf20Sopenharmony_ci * | snps,dw-apb-intc (MB)| 468c2ecf20Sopenharmony_ci * ------------------------ 478c2ecf20Sopenharmony_ci * | | | | 488c2ecf20Sopenharmony_ci * [eth] [uart] [... other perip on Main Board] 498c2ecf20Sopenharmony_ci * 508c2ecf20Sopenharmony_ci * Current implementation of "irq-dw-apb-ictl" driver doesn't work well 518c2ecf20Sopenharmony_ci * with stacked INTCs. In particular problem happens if its master INTC 528c2ecf20Sopenharmony_ci * not yet instantiated. See discussion here - 538c2ecf20Sopenharmony_ci * https://lkml.org/lkml/2015/3/4/755 548c2ecf20Sopenharmony_ci * 558c2ecf20Sopenharmony_ci * So setup the first gpio block as a passive pass thru and hide it from 568c2ecf20Sopenharmony_ci * DT hardware topology - connect MB intc directly to cpu intc 578c2ecf20Sopenharmony_ci * The GPIO "wire" needs to be init nevertheless (here) 588c2ecf20Sopenharmony_ci * 598c2ecf20Sopenharmony_ci * One side adv is that peripheral interrupt handling avoids one nested 608c2ecf20Sopenharmony_ci * intc ISR hop 618c2ecf20Sopenharmony_ci */ 628c2ecf20Sopenharmony_ci#define GPIO_INTEN (AXC001_GPIO_INTC + 0x30) 638c2ecf20Sopenharmony_ci#define GPIO_INTMASK (AXC001_GPIO_INTC + 0x34) 648c2ecf20Sopenharmony_ci#define GPIO_INTTYPE_LEVEL (AXC001_GPIO_INTC + 0x38) 658c2ecf20Sopenharmony_ci#define GPIO_INT_POLARITY (AXC001_GPIO_INTC + 0x3c) 668c2ecf20Sopenharmony_ci#define MB_TO_GPIO_IRQ 12 678c2ecf20Sopenharmony_ci 688c2ecf20Sopenharmony_ci iowrite32(~(1 << MB_TO_GPIO_IRQ), (void __iomem *) GPIO_INTMASK); 698c2ecf20Sopenharmony_ci iowrite32(0, (void __iomem *) GPIO_INTTYPE_LEVEL); 708c2ecf20Sopenharmony_ci iowrite32(~0, (void __iomem *) GPIO_INT_POLARITY); 718c2ecf20Sopenharmony_ci iowrite32(1 << MB_TO_GPIO_IRQ, (void __iomem *) GPIO_INTEN); 728c2ecf20Sopenharmony_ci} 738c2ecf20Sopenharmony_ci 748c2ecf20Sopenharmony_cistatic void __init axs10x_print_board_ver(unsigned int creg, const char *str) 758c2ecf20Sopenharmony_ci{ 768c2ecf20Sopenharmony_ci union ver { 778c2ecf20Sopenharmony_ci struct { 788c2ecf20Sopenharmony_ci#ifdef CONFIG_CPU_BIG_ENDIAN 798c2ecf20Sopenharmony_ci unsigned int pad:11, y:12, m:4, d:5; 808c2ecf20Sopenharmony_ci#else 818c2ecf20Sopenharmony_ci unsigned int d:5, m:4, y:12, pad:11; 828c2ecf20Sopenharmony_ci#endif 838c2ecf20Sopenharmony_ci }; 848c2ecf20Sopenharmony_ci unsigned int val; 858c2ecf20Sopenharmony_ci } board; 868c2ecf20Sopenharmony_ci 878c2ecf20Sopenharmony_ci board.val = ioread32((void __iomem *)creg); 888c2ecf20Sopenharmony_ci pr_info("AXS: %s FPGA Date: %u-%u-%u\n", str, board.d, board.m, 898c2ecf20Sopenharmony_ci board.y); 908c2ecf20Sopenharmony_ci} 918c2ecf20Sopenharmony_ci 928c2ecf20Sopenharmony_cistatic void __init axs10x_early_init(void) 938c2ecf20Sopenharmony_ci{ 948c2ecf20Sopenharmony_ci int mb_rev; 958c2ecf20Sopenharmony_ci char mb[32]; 968c2ecf20Sopenharmony_ci 978c2ecf20Sopenharmony_ci /* Determine motherboard version */ 988c2ecf20Sopenharmony_ci if (ioread32((void __iomem *) CREG_MB_CONFIG) & (1 << 28)) 998c2ecf20Sopenharmony_ci mb_rev = 3; /* HT-3 (rev3.0) */ 1008c2ecf20Sopenharmony_ci else 1018c2ecf20Sopenharmony_ci mb_rev = 2; /* HT-2 (rev2.0) */ 1028c2ecf20Sopenharmony_ci 1038c2ecf20Sopenharmony_ci axs10x_enable_gpio_intc_wire(); 1048c2ecf20Sopenharmony_ci 1058c2ecf20Sopenharmony_ci scnprintf(mb, 32, "MainBoard v%d", mb_rev); 1068c2ecf20Sopenharmony_ci axs10x_print_board_ver(CREG_MB_VER, mb); 1078c2ecf20Sopenharmony_ci} 1088c2ecf20Sopenharmony_ci 1098c2ecf20Sopenharmony_ci#ifdef CONFIG_AXS101 1108c2ecf20Sopenharmony_ci 1118c2ecf20Sopenharmony_ci#define CREG_CPU_ADDR_770 (AXC001_CREG + 0x20) 1128c2ecf20Sopenharmony_ci#define CREG_CPU_ADDR_TUNN (AXC001_CREG + 0x60) 1138c2ecf20Sopenharmony_ci#define CREG_CPU_ADDR_770_UPD (AXC001_CREG + 0x34) 1148c2ecf20Sopenharmony_ci#define CREG_CPU_ADDR_TUNN_UPD (AXC001_CREG + 0x74) 1158c2ecf20Sopenharmony_ci 1168c2ecf20Sopenharmony_ci#define CREG_CPU_ARC770_IRQ_MUX (AXC001_CREG + 0x114) 1178c2ecf20Sopenharmony_ci#define CREG_CPU_GPIO_UART_MUX (AXC001_CREG + 0x120) 1188c2ecf20Sopenharmony_ci 1198c2ecf20Sopenharmony_ci/* 1208c2ecf20Sopenharmony_ci * Set up System Memory Map for ARC cpu / peripherals controllers 1218c2ecf20Sopenharmony_ci * 1228c2ecf20Sopenharmony_ci * Each AXI master has a 4GB memory map specified as 16 apertures of 256MB, each 1238c2ecf20Sopenharmony_ci * of which maps to a corresponding 256MB aperture in Target slave memory map. 1248c2ecf20Sopenharmony_ci * 1258c2ecf20Sopenharmony_ci * e.g. ARC cpu AXI Master's aperture 8 (0x8000_0000) is mapped to aperture 0 1268c2ecf20Sopenharmony_ci * (0x0000_0000) of DDR Port 0 (slave #1) 1278c2ecf20Sopenharmony_ci * 1288c2ecf20Sopenharmony_ci * Access from cpu to MB controllers such as GMAC is setup using AXI Tunnel: 1298c2ecf20Sopenharmony_ci * which has master/slaves on both ends. 1308c2ecf20Sopenharmony_ci * e.g. aperture 14 (0xE000_0000) of ARC cpu is mapped to aperture 14 1318c2ecf20Sopenharmony_ci * (0xE000_0000) of CPU Card AXI Tunnel slave (slave #3) which is mapped to 1328c2ecf20Sopenharmony_ci * MB AXI Tunnel Master, which also has a mem map setup 1338c2ecf20Sopenharmony_ci * 1348c2ecf20Sopenharmony_ci * In the reverse direction, MB AXI Masters (e.g. GMAC) mem map is setup 1358c2ecf20Sopenharmony_ci * to map to MB AXI Tunnel slave which connects to CPU Card AXI Tunnel Master 1368c2ecf20Sopenharmony_ci */ 1378c2ecf20Sopenharmony_cistruct aperture { 1388c2ecf20Sopenharmony_ci unsigned int slave_sel:4, slave_off:4, pad:24; 1398c2ecf20Sopenharmony_ci}; 1408c2ecf20Sopenharmony_ci 1418c2ecf20Sopenharmony_ci/* CPU Card target slaves */ 1428c2ecf20Sopenharmony_ci#define AXC001_SLV_NONE 0 1438c2ecf20Sopenharmony_ci#define AXC001_SLV_DDR_PORT0 1 1448c2ecf20Sopenharmony_ci#define AXC001_SLV_SRAM 2 1458c2ecf20Sopenharmony_ci#define AXC001_SLV_AXI_TUNNEL 3 1468c2ecf20Sopenharmony_ci#define AXC001_SLV_AXI2APB 6 1478c2ecf20Sopenharmony_ci#define AXC001_SLV_DDR_PORT1 7 1488c2ecf20Sopenharmony_ci 1498c2ecf20Sopenharmony_ci/* MB AXI Target slaves */ 1508c2ecf20Sopenharmony_ci#define AXS_MB_SLV_NONE 0 1518c2ecf20Sopenharmony_ci#define AXS_MB_SLV_AXI_TUNNEL_CPU 1 1528c2ecf20Sopenharmony_ci#define AXS_MB_SLV_AXI_TUNNEL_HAPS 2 1538c2ecf20Sopenharmony_ci#define AXS_MB_SLV_SRAM 3 1548c2ecf20Sopenharmony_ci#define AXS_MB_SLV_CONTROL 4 1558c2ecf20Sopenharmony_ci 1568c2ecf20Sopenharmony_ci/* MB AXI masters */ 1578c2ecf20Sopenharmony_ci#define AXS_MB_MST_TUNNEL_CPU 0 1588c2ecf20Sopenharmony_ci#define AXS_MB_MST_USB_OHCI 10 1598c2ecf20Sopenharmony_ci 1608c2ecf20Sopenharmony_ci/* 1618c2ecf20Sopenharmony_ci * memmap for ARC core on CPU Card 1628c2ecf20Sopenharmony_ci */ 1638c2ecf20Sopenharmony_cistatic const struct aperture axc001_memmap[16] = { 1648c2ecf20Sopenharmony_ci {AXC001_SLV_AXI_TUNNEL, 0x0}, 1658c2ecf20Sopenharmony_ci {AXC001_SLV_AXI_TUNNEL, 0x1}, 1668c2ecf20Sopenharmony_ci {AXC001_SLV_SRAM, 0x0}, /* 0x2000_0000: Local SRAM */ 1678c2ecf20Sopenharmony_ci {AXC001_SLV_NONE, 0x0}, 1688c2ecf20Sopenharmony_ci {AXC001_SLV_NONE, 0x0}, 1698c2ecf20Sopenharmony_ci {AXC001_SLV_NONE, 0x0}, 1708c2ecf20Sopenharmony_ci {AXC001_SLV_NONE, 0x0}, 1718c2ecf20Sopenharmony_ci {AXC001_SLV_NONE, 0x0}, 1728c2ecf20Sopenharmony_ci {AXC001_SLV_DDR_PORT0, 0x0}, /* 0x8000_0000: DDR 0..256M */ 1738c2ecf20Sopenharmony_ci {AXC001_SLV_DDR_PORT0, 0x1}, /* 0x9000_0000: DDR 256..512M */ 1748c2ecf20Sopenharmony_ci {AXC001_SLV_DDR_PORT0, 0x2}, 1758c2ecf20Sopenharmony_ci {AXC001_SLV_DDR_PORT0, 0x3}, 1768c2ecf20Sopenharmony_ci {AXC001_SLV_NONE, 0x0}, 1778c2ecf20Sopenharmony_ci {AXC001_SLV_AXI_TUNNEL, 0xD}, 1788c2ecf20Sopenharmony_ci {AXC001_SLV_AXI_TUNNEL, 0xE}, /* MB: CREG, CGU... */ 1798c2ecf20Sopenharmony_ci {AXC001_SLV_AXI2APB, 0x0}, /* CPU Card local CREG, CGU... */ 1808c2ecf20Sopenharmony_ci}; 1818c2ecf20Sopenharmony_ci 1828c2ecf20Sopenharmony_ci/* 1838c2ecf20Sopenharmony_ci * memmap for CPU Card AXI Tunnel Master (for access by MB controllers) 1848c2ecf20Sopenharmony_ci * GMAC (MB) -> MB AXI Tunnel slave -> CPU Card AXI Tunnel Master -> DDR 1858c2ecf20Sopenharmony_ci */ 1868c2ecf20Sopenharmony_cistatic const struct aperture axc001_axi_tunnel_memmap[16] = { 1878c2ecf20Sopenharmony_ci {AXC001_SLV_AXI_TUNNEL, 0x0}, 1888c2ecf20Sopenharmony_ci {AXC001_SLV_AXI_TUNNEL, 0x1}, 1898c2ecf20Sopenharmony_ci {AXC001_SLV_SRAM, 0x0}, 1908c2ecf20Sopenharmony_ci {AXC001_SLV_NONE, 0x0}, 1918c2ecf20Sopenharmony_ci {AXC001_SLV_NONE, 0x0}, 1928c2ecf20Sopenharmony_ci {AXC001_SLV_NONE, 0x0}, 1938c2ecf20Sopenharmony_ci {AXC001_SLV_NONE, 0x0}, 1948c2ecf20Sopenharmony_ci {AXC001_SLV_NONE, 0x0}, 1958c2ecf20Sopenharmony_ci {AXC001_SLV_DDR_PORT1, 0x0}, 1968c2ecf20Sopenharmony_ci {AXC001_SLV_DDR_PORT1, 0x1}, 1978c2ecf20Sopenharmony_ci {AXC001_SLV_DDR_PORT1, 0x2}, 1988c2ecf20Sopenharmony_ci {AXC001_SLV_DDR_PORT1, 0x3}, 1998c2ecf20Sopenharmony_ci {AXC001_SLV_NONE, 0x0}, 2008c2ecf20Sopenharmony_ci {AXC001_SLV_AXI_TUNNEL, 0xD}, 2018c2ecf20Sopenharmony_ci {AXC001_SLV_AXI_TUNNEL, 0xE}, 2028c2ecf20Sopenharmony_ci {AXC001_SLV_AXI2APB, 0x0}, 2038c2ecf20Sopenharmony_ci}; 2048c2ecf20Sopenharmony_ci 2058c2ecf20Sopenharmony_ci/* 2068c2ecf20Sopenharmony_ci * memmap for MB AXI Masters 2078c2ecf20Sopenharmony_ci * Same mem map for all perip controllers as well as MB AXI Tunnel Master 2088c2ecf20Sopenharmony_ci */ 2098c2ecf20Sopenharmony_cistatic const struct aperture axs_mb_memmap[16] = { 2108c2ecf20Sopenharmony_ci {AXS_MB_SLV_SRAM, 0x0}, 2118c2ecf20Sopenharmony_ci {AXS_MB_SLV_SRAM, 0x0}, 2128c2ecf20Sopenharmony_ci {AXS_MB_SLV_NONE, 0x0}, 2138c2ecf20Sopenharmony_ci {AXS_MB_SLV_NONE, 0x0}, 2148c2ecf20Sopenharmony_ci {AXS_MB_SLV_NONE, 0x0}, 2158c2ecf20Sopenharmony_ci {AXS_MB_SLV_NONE, 0x0}, 2168c2ecf20Sopenharmony_ci {AXS_MB_SLV_NONE, 0x0}, 2178c2ecf20Sopenharmony_ci {AXS_MB_SLV_NONE, 0x0}, 2188c2ecf20Sopenharmony_ci {AXS_MB_SLV_AXI_TUNNEL_CPU, 0x8}, /* DDR on CPU Card */ 2198c2ecf20Sopenharmony_ci {AXS_MB_SLV_AXI_TUNNEL_CPU, 0x9}, /* DDR on CPU Card */ 2208c2ecf20Sopenharmony_ci {AXS_MB_SLV_AXI_TUNNEL_CPU, 0xA}, 2218c2ecf20Sopenharmony_ci {AXS_MB_SLV_AXI_TUNNEL_CPU, 0xB}, 2228c2ecf20Sopenharmony_ci {AXS_MB_SLV_NONE, 0x0}, 2238c2ecf20Sopenharmony_ci {AXS_MB_SLV_AXI_TUNNEL_HAPS, 0xD}, 2248c2ecf20Sopenharmony_ci {AXS_MB_SLV_CONTROL, 0x0}, /* MB Local CREG, CGU... */ 2258c2ecf20Sopenharmony_ci {AXS_MB_SLV_AXI_TUNNEL_CPU, 0xF}, 2268c2ecf20Sopenharmony_ci}; 2278c2ecf20Sopenharmony_ci 2288c2ecf20Sopenharmony_cistatic noinline void __init 2298c2ecf20Sopenharmony_ciaxs101_set_memmap(void __iomem *base, const struct aperture map[16]) 2308c2ecf20Sopenharmony_ci{ 2318c2ecf20Sopenharmony_ci unsigned int slave_select, slave_offset; 2328c2ecf20Sopenharmony_ci int i; 2338c2ecf20Sopenharmony_ci 2348c2ecf20Sopenharmony_ci slave_select = slave_offset = 0; 2358c2ecf20Sopenharmony_ci for (i = 0; i < 8; i++) { 2368c2ecf20Sopenharmony_ci slave_select |= map[i].slave_sel << (i << 2); 2378c2ecf20Sopenharmony_ci slave_offset |= map[i].slave_off << (i << 2); 2388c2ecf20Sopenharmony_ci } 2398c2ecf20Sopenharmony_ci 2408c2ecf20Sopenharmony_ci iowrite32(slave_select, base + 0x0); /* SLV0 */ 2418c2ecf20Sopenharmony_ci iowrite32(slave_offset, base + 0x8); /* OFFSET0 */ 2428c2ecf20Sopenharmony_ci 2438c2ecf20Sopenharmony_ci slave_select = slave_offset = 0; 2448c2ecf20Sopenharmony_ci for (i = 0; i < 8; i++) { 2458c2ecf20Sopenharmony_ci slave_select |= map[i+8].slave_sel << (i << 2); 2468c2ecf20Sopenharmony_ci slave_offset |= map[i+8].slave_off << (i << 2); 2478c2ecf20Sopenharmony_ci } 2488c2ecf20Sopenharmony_ci 2498c2ecf20Sopenharmony_ci iowrite32(slave_select, base + 0x4); /* SLV1 */ 2508c2ecf20Sopenharmony_ci iowrite32(slave_offset, base + 0xC); /* OFFSET1 */ 2518c2ecf20Sopenharmony_ci} 2528c2ecf20Sopenharmony_ci 2538c2ecf20Sopenharmony_cistatic void __init axs101_early_init(void) 2548c2ecf20Sopenharmony_ci{ 2558c2ecf20Sopenharmony_ci int i; 2568c2ecf20Sopenharmony_ci 2578c2ecf20Sopenharmony_ci /* ARC 770D memory view */ 2588c2ecf20Sopenharmony_ci axs101_set_memmap((void __iomem *) CREG_CPU_ADDR_770, axc001_memmap); 2598c2ecf20Sopenharmony_ci iowrite32(1, (void __iomem *) CREG_CPU_ADDR_770_UPD); 2608c2ecf20Sopenharmony_ci 2618c2ecf20Sopenharmony_ci /* AXI tunnel memory map (incoming traffic from MB into CPU Card */ 2628c2ecf20Sopenharmony_ci axs101_set_memmap((void __iomem *) CREG_CPU_ADDR_TUNN, 2638c2ecf20Sopenharmony_ci axc001_axi_tunnel_memmap); 2648c2ecf20Sopenharmony_ci iowrite32(1, (void __iomem *) CREG_CPU_ADDR_TUNN_UPD); 2658c2ecf20Sopenharmony_ci 2668c2ecf20Sopenharmony_ci /* MB peripherals memory map */ 2678c2ecf20Sopenharmony_ci for (i = AXS_MB_MST_TUNNEL_CPU; i <= AXS_MB_MST_USB_OHCI; i++) 2688c2ecf20Sopenharmony_ci axs101_set_memmap((void __iomem *) AXS_MB_CREG + (i << 4), 2698c2ecf20Sopenharmony_ci axs_mb_memmap); 2708c2ecf20Sopenharmony_ci 2718c2ecf20Sopenharmony_ci iowrite32(0x3ff, (void __iomem *) AXS_MB_CREG + 0x100); /* Update */ 2728c2ecf20Sopenharmony_ci 2738c2ecf20Sopenharmony_ci /* GPIO pins 18 and 19 are used as UART rx and tx, respectively. */ 2748c2ecf20Sopenharmony_ci iowrite32(0x01, (void __iomem *) CREG_CPU_GPIO_UART_MUX); 2758c2ecf20Sopenharmony_ci 2768c2ecf20Sopenharmony_ci /* Set up the MB interrupt system: mux interrupts to GPIO7) */ 2778c2ecf20Sopenharmony_ci iowrite32(0x01, (void __iomem *) CREG_MB_IRQ_MUX); 2788c2ecf20Sopenharmony_ci 2798c2ecf20Sopenharmony_ci /* reset ethernet and ULPI interfaces */ 2808c2ecf20Sopenharmony_ci iowrite32(0x18, (void __iomem *) CREG_MB_SW_RESET); 2818c2ecf20Sopenharmony_ci 2828c2ecf20Sopenharmony_ci /* map GPIO 14:10 to ARC 9:5 (IRQ mux change for MB v2 onwards) */ 2838c2ecf20Sopenharmony_ci iowrite32(0x52, (void __iomem *) CREG_CPU_ARC770_IRQ_MUX); 2848c2ecf20Sopenharmony_ci 2858c2ecf20Sopenharmony_ci axs10x_early_init(); 2868c2ecf20Sopenharmony_ci} 2878c2ecf20Sopenharmony_ci 2888c2ecf20Sopenharmony_ci#endif /* CONFIG_AXS101 */ 2898c2ecf20Sopenharmony_ci 2908c2ecf20Sopenharmony_ci#ifdef CONFIG_AXS103 2918c2ecf20Sopenharmony_ci 2928c2ecf20Sopenharmony_ci#define AXC003_CREG 0xF0001000 2938c2ecf20Sopenharmony_ci#define AXC003_MST_AXI_TUNNEL 0 2948c2ecf20Sopenharmony_ci#define AXC003_MST_HS38 1 2958c2ecf20Sopenharmony_ci 2968c2ecf20Sopenharmony_ci#define CREG_CPU_AXI_M0_IRQ_MUX (AXC003_CREG + 0x440) 2978c2ecf20Sopenharmony_ci#define CREG_CPU_GPIO_UART_MUX (AXC003_CREG + 0x480) 2988c2ecf20Sopenharmony_ci#define CREG_CPU_TUN_IO_CTRL (AXC003_CREG + 0x494) 2998c2ecf20Sopenharmony_ci 3008c2ecf20Sopenharmony_ci 3018c2ecf20Sopenharmony_cistatic void __init axs103_early_init(void) 3028c2ecf20Sopenharmony_ci{ 3038c2ecf20Sopenharmony_ci#ifdef CONFIG_ARC_MCIP 3048c2ecf20Sopenharmony_ci /* 3058c2ecf20Sopenharmony_ci * AXS103 configurations for SMP/QUAD configurations share device tree 3068c2ecf20Sopenharmony_ci * which defaults to 100 MHz. However recent failures of Quad config 3078c2ecf20Sopenharmony_ci * revealed P&R timing violations so clamp it down to safe 50 MHz 3088c2ecf20Sopenharmony_ci * Instead of duplicating defconfig/DT for SMP/QUAD, add a small hack 3098c2ecf20Sopenharmony_ci * of fudging the freq in DT 3108c2ecf20Sopenharmony_ci */ 3118c2ecf20Sopenharmony_ci#define AXS103_QUAD_CORE_CPU_FREQ_HZ 50000000 3128c2ecf20Sopenharmony_ci 3138c2ecf20Sopenharmony_ci unsigned int num_cores = (read_aux_reg(ARC_REG_MCIP_BCR) >> 16) & 0x3F; 3148c2ecf20Sopenharmony_ci if (num_cores > 2) { 3158c2ecf20Sopenharmony_ci u32 freq; 3168c2ecf20Sopenharmony_ci int off = fdt_path_offset(initial_boot_params, "/cpu_card/core_clk"); 3178c2ecf20Sopenharmony_ci const struct fdt_property *prop; 3188c2ecf20Sopenharmony_ci 3198c2ecf20Sopenharmony_ci prop = fdt_get_property(initial_boot_params, off, 3208c2ecf20Sopenharmony_ci "assigned-clock-rates", NULL); 3218c2ecf20Sopenharmony_ci freq = be32_to_cpu(*(u32 *)(prop->data)); 3228c2ecf20Sopenharmony_ci 3238c2ecf20Sopenharmony_ci /* Patching .dtb in-place with new core clock value */ 3248c2ecf20Sopenharmony_ci if (freq != AXS103_QUAD_CORE_CPU_FREQ_HZ) { 3258c2ecf20Sopenharmony_ci freq = cpu_to_be32(AXS103_QUAD_CORE_CPU_FREQ_HZ); 3268c2ecf20Sopenharmony_ci fdt_setprop_inplace(initial_boot_params, off, 3278c2ecf20Sopenharmony_ci "assigned-clock-rates", &freq, sizeof(freq)); 3288c2ecf20Sopenharmony_ci } 3298c2ecf20Sopenharmony_ci } 3308c2ecf20Sopenharmony_ci#endif 3318c2ecf20Sopenharmony_ci 3328c2ecf20Sopenharmony_ci /* Memory maps already config in pre-bootloader */ 3338c2ecf20Sopenharmony_ci 3348c2ecf20Sopenharmony_ci /* set GPIO mux to UART */ 3358c2ecf20Sopenharmony_ci iowrite32(0x01, (void __iomem *) CREG_CPU_GPIO_UART_MUX); 3368c2ecf20Sopenharmony_ci 3378c2ecf20Sopenharmony_ci iowrite32((0x00100000U | 0x000C0000U | 0x00003322U), 3388c2ecf20Sopenharmony_ci (void __iomem *) CREG_CPU_TUN_IO_CTRL); 3398c2ecf20Sopenharmony_ci 3408c2ecf20Sopenharmony_ci /* Set up the AXS_MB interrupt system.*/ 3418c2ecf20Sopenharmony_ci iowrite32(12, (void __iomem *) (CREG_CPU_AXI_M0_IRQ_MUX 3428c2ecf20Sopenharmony_ci + (AXC003_MST_HS38 << 2))); 3438c2ecf20Sopenharmony_ci 3448c2ecf20Sopenharmony_ci /* connect ICTL - Main Board with GPIO line */ 3458c2ecf20Sopenharmony_ci iowrite32(0x01, (void __iomem *) CREG_MB_IRQ_MUX); 3468c2ecf20Sopenharmony_ci 3478c2ecf20Sopenharmony_ci axs10x_print_board_ver(AXC003_CREG + 4088, "AXC003 CPU Card"); 3488c2ecf20Sopenharmony_ci 3498c2ecf20Sopenharmony_ci axs10x_early_init(); 3508c2ecf20Sopenharmony_ci} 3518c2ecf20Sopenharmony_ci#endif 3528c2ecf20Sopenharmony_ci 3538c2ecf20Sopenharmony_ci#ifdef CONFIG_AXS101 3548c2ecf20Sopenharmony_ci 3558c2ecf20Sopenharmony_cistatic const char *axs101_compat[] __initconst = { 3568c2ecf20Sopenharmony_ci "snps,axs101", 3578c2ecf20Sopenharmony_ci NULL, 3588c2ecf20Sopenharmony_ci}; 3598c2ecf20Sopenharmony_ci 3608c2ecf20Sopenharmony_ciMACHINE_START(AXS101, "axs101") 3618c2ecf20Sopenharmony_ci .dt_compat = axs101_compat, 3628c2ecf20Sopenharmony_ci .init_early = axs101_early_init, 3638c2ecf20Sopenharmony_ciMACHINE_END 3648c2ecf20Sopenharmony_ci 3658c2ecf20Sopenharmony_ci#endif /* CONFIG_AXS101 */ 3668c2ecf20Sopenharmony_ci 3678c2ecf20Sopenharmony_ci#ifdef CONFIG_AXS103 3688c2ecf20Sopenharmony_ci 3698c2ecf20Sopenharmony_cistatic const char *axs103_compat[] __initconst = { 3708c2ecf20Sopenharmony_ci "snps,axs103", 3718c2ecf20Sopenharmony_ci NULL, 3728c2ecf20Sopenharmony_ci}; 3738c2ecf20Sopenharmony_ci 3748c2ecf20Sopenharmony_ciMACHINE_START(AXS103, "axs103") 3758c2ecf20Sopenharmony_ci .dt_compat = axs103_compat, 3768c2ecf20Sopenharmony_ci .init_early = axs103_early_init, 3778c2ecf20Sopenharmony_ciMACHINE_END 3788c2ecf20Sopenharmony_ci 3798c2ecf20Sopenharmony_ci/* 3808c2ecf20Sopenharmony_ci * For the VDK OS-kit, to get the offset to pid and command fields 3818c2ecf20Sopenharmony_ci */ 3828c2ecf20Sopenharmony_cichar coware_swa_pid_offset[TASK_PID]; 3838c2ecf20Sopenharmony_cichar coware_swa_comm_offset[TASK_COMM]; 3848c2ecf20Sopenharmony_ci 3858c2ecf20Sopenharmony_ci#endif /* CONFIG_AXS103 */ 386