18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */ 28c2ecf20Sopenharmony_ci/* 38c2ecf20Sopenharmony_ci*Copyright (C) 2004 Konrad Eisele (eiselekd@web.de,konrad@gaisler.com), Gaisler Research 48c2ecf20Sopenharmony_ci*Copyright (C) 2004 Stefan Holst (mail@s-holst.de), Uni-Stuttgart 58c2ecf20Sopenharmony_ci*Copyright (C) 2009 Daniel Hellstrom (daniel@gaisler.com),Konrad Eisele (konrad@gaisler.com) Aeroflex Gaisler AB 68c2ecf20Sopenharmony_ci*/ 78c2ecf20Sopenharmony_ci 88c2ecf20Sopenharmony_ci#ifndef LEON_AMBA_H_INCLUDE 98c2ecf20Sopenharmony_ci#define LEON_AMBA_H_INCLUDE 108c2ecf20Sopenharmony_ci 118c2ecf20Sopenharmony_ci#ifndef __ASSEMBLY__ 128c2ecf20Sopenharmony_ci 138c2ecf20Sopenharmony_cistruct amba_prom_registers { 148c2ecf20Sopenharmony_ci unsigned int phys_addr; /* The physical address of this register */ 158c2ecf20Sopenharmony_ci unsigned int reg_size; /* How many bytes does this register take up? */ 168c2ecf20Sopenharmony_ci}; 178c2ecf20Sopenharmony_ci 188c2ecf20Sopenharmony_ci#endif 198c2ecf20Sopenharmony_ci 208c2ecf20Sopenharmony_ci/* 218c2ecf20Sopenharmony_ci * The following defines the bits in the LEON UART Status Registers. 228c2ecf20Sopenharmony_ci */ 238c2ecf20Sopenharmony_ci 248c2ecf20Sopenharmony_ci#define LEON_REG_UART_STATUS_DR 0x00000001 /* Data Ready */ 258c2ecf20Sopenharmony_ci#define LEON_REG_UART_STATUS_TSE 0x00000002 /* TX Send Register Empty */ 268c2ecf20Sopenharmony_ci#define LEON_REG_UART_STATUS_THE 0x00000004 /* TX Hold Register Empty */ 278c2ecf20Sopenharmony_ci#define LEON_REG_UART_STATUS_BR 0x00000008 /* Break Error */ 288c2ecf20Sopenharmony_ci#define LEON_REG_UART_STATUS_OE 0x00000010 /* RX Overrun Error */ 298c2ecf20Sopenharmony_ci#define LEON_REG_UART_STATUS_PE 0x00000020 /* RX Parity Error */ 308c2ecf20Sopenharmony_ci#define LEON_REG_UART_STATUS_FE 0x00000040 /* RX Framing Error */ 318c2ecf20Sopenharmony_ci#define LEON_REG_UART_STATUS_ERR 0x00000078 /* Error Mask */ 328c2ecf20Sopenharmony_ci 338c2ecf20Sopenharmony_ci/* 348c2ecf20Sopenharmony_ci * The following defines the bits in the LEON UART Ctrl Registers. 358c2ecf20Sopenharmony_ci */ 368c2ecf20Sopenharmony_ci 378c2ecf20Sopenharmony_ci#define LEON_REG_UART_CTRL_RE 0x00000001 /* Receiver enable */ 388c2ecf20Sopenharmony_ci#define LEON_REG_UART_CTRL_TE 0x00000002 /* Transmitter enable */ 398c2ecf20Sopenharmony_ci#define LEON_REG_UART_CTRL_RI 0x00000004 /* Receiver interrupt enable */ 408c2ecf20Sopenharmony_ci#define LEON_REG_UART_CTRL_TI 0x00000008 /* Transmitter irq */ 418c2ecf20Sopenharmony_ci#define LEON_REG_UART_CTRL_PS 0x00000010 /* Parity select */ 428c2ecf20Sopenharmony_ci#define LEON_REG_UART_CTRL_PE 0x00000020 /* Parity enable */ 438c2ecf20Sopenharmony_ci#define LEON_REG_UART_CTRL_FL 0x00000040 /* Flow control enable */ 448c2ecf20Sopenharmony_ci#define LEON_REG_UART_CTRL_LB 0x00000080 /* Loop Back enable */ 458c2ecf20Sopenharmony_ci 468c2ecf20Sopenharmony_ci#define LEON3_GPTIMER_EN 1 478c2ecf20Sopenharmony_ci#define LEON3_GPTIMER_RL 2 488c2ecf20Sopenharmony_ci#define LEON3_GPTIMER_LD 4 498c2ecf20Sopenharmony_ci#define LEON3_GPTIMER_IRQEN 8 508c2ecf20Sopenharmony_ci#define LEON3_GPTIMER_SEPIRQ 8 518c2ecf20Sopenharmony_ci#define LEON3_GPTIMER_TIMERS 0x7 528c2ecf20Sopenharmony_ci 538c2ecf20Sopenharmony_ci#define LEON23_REG_TIMER_CONTROL_EN 0x00000001 /* 1 = enable counting */ 548c2ecf20Sopenharmony_ci/* 0 = hold scalar and counter */ 558c2ecf20Sopenharmony_ci#define LEON23_REG_TIMER_CONTROL_RL 0x00000002 /* 1 = reload at 0 */ 568c2ecf20Sopenharmony_ci /* 0 = stop at 0 */ 578c2ecf20Sopenharmony_ci#define LEON23_REG_TIMER_CONTROL_LD 0x00000004 /* 1 = load counter */ 588c2ecf20Sopenharmony_ci /* 0 = no function */ 598c2ecf20Sopenharmony_ci#define LEON23_REG_TIMER_CONTROL_IQ 0x00000008 /* 1 = irq enable */ 608c2ecf20Sopenharmony_ci /* 0 = no function */ 618c2ecf20Sopenharmony_ci 628c2ecf20Sopenharmony_ci/* 638c2ecf20Sopenharmony_ci * The following defines the bits in the LEON PS/2 Status Registers. 648c2ecf20Sopenharmony_ci */ 658c2ecf20Sopenharmony_ci 668c2ecf20Sopenharmony_ci#define LEON_REG_PS2_STATUS_DR 0x00000001 /* Data Ready */ 678c2ecf20Sopenharmony_ci#define LEON_REG_PS2_STATUS_PE 0x00000002 /* Parity error */ 688c2ecf20Sopenharmony_ci#define LEON_REG_PS2_STATUS_FE 0x00000004 /* Framing error */ 698c2ecf20Sopenharmony_ci#define LEON_REG_PS2_STATUS_KI 0x00000008 /* Keyboard inhibit */ 708c2ecf20Sopenharmony_ci#define LEON_REG_PS2_STATUS_RF 0x00000010 /* RX buffer full */ 718c2ecf20Sopenharmony_ci#define LEON_REG_PS2_STATUS_TF 0x00000020 /* TX buffer full */ 728c2ecf20Sopenharmony_ci 738c2ecf20Sopenharmony_ci/* 748c2ecf20Sopenharmony_ci * The following defines the bits in the LEON PS/2 Ctrl Registers. 758c2ecf20Sopenharmony_ci */ 768c2ecf20Sopenharmony_ci 778c2ecf20Sopenharmony_ci#define LEON_REG_PS2_CTRL_RE 0x00000001 /* Receiver enable */ 788c2ecf20Sopenharmony_ci#define LEON_REG_PS2_CTRL_TE 0x00000002 /* Transmitter enable */ 798c2ecf20Sopenharmony_ci#define LEON_REG_PS2_CTRL_RI 0x00000004 /* Keyboard receive irq */ 808c2ecf20Sopenharmony_ci#define LEON_REG_PS2_CTRL_TI 0x00000008 /* Keyboard transmit irq */ 818c2ecf20Sopenharmony_ci 828c2ecf20Sopenharmony_ci#define LEON3_IRQMPSTATUS_CPUNR 28 838c2ecf20Sopenharmony_ci#define LEON3_IRQMPSTATUS_BROADCAST 27 848c2ecf20Sopenharmony_ci 858c2ecf20Sopenharmony_ci#define GPTIMER_CONFIG_IRQNT(a) (((a) >> 3) & 0x1f) 868c2ecf20Sopenharmony_ci#define GPTIMER_CONFIG_ISSEP(a) ((a) & (1 << 8)) 878c2ecf20Sopenharmony_ci#define GPTIMER_CONFIG_NTIMERS(a) ((a) & (0x7)) 888c2ecf20Sopenharmony_ci#define LEON3_GPTIMER_CTRL_PENDING 0x10 898c2ecf20Sopenharmony_ci#define LEON3_GPTIMER_CONFIG_NRTIMERS(c) ((c)->config & 0x7) 908c2ecf20Sopenharmony_ci#define LEON3_GPTIMER_CTRL_ISPENDING(r) (((r)&LEON3_GPTIMER_CTRL_PENDING) ? 1 : 0) 918c2ecf20Sopenharmony_ci 928c2ecf20Sopenharmony_ci#ifndef __ASSEMBLY__ 938c2ecf20Sopenharmony_ci 948c2ecf20Sopenharmony_cistruct leon3_irqctrl_regs_map { 958c2ecf20Sopenharmony_ci u32 ilevel; 968c2ecf20Sopenharmony_ci u32 ipend; 978c2ecf20Sopenharmony_ci u32 iforce; 988c2ecf20Sopenharmony_ci u32 iclear; 998c2ecf20Sopenharmony_ci u32 mpstatus; 1008c2ecf20Sopenharmony_ci u32 mpbroadcast; 1018c2ecf20Sopenharmony_ci u32 notused02; 1028c2ecf20Sopenharmony_ci u32 notused03; 1038c2ecf20Sopenharmony_ci u32 ampctrl; 1048c2ecf20Sopenharmony_ci u32 icsel[2]; 1058c2ecf20Sopenharmony_ci u32 notused13; 1068c2ecf20Sopenharmony_ci u32 notused20; 1078c2ecf20Sopenharmony_ci u32 notused21; 1088c2ecf20Sopenharmony_ci u32 notused22; 1098c2ecf20Sopenharmony_ci u32 notused23; 1108c2ecf20Sopenharmony_ci u32 mask[16]; 1118c2ecf20Sopenharmony_ci u32 force[16]; 1128c2ecf20Sopenharmony_ci /* Extended IRQ registers */ 1138c2ecf20Sopenharmony_ci u32 intid[16]; /* 0xc0 */ 1148c2ecf20Sopenharmony_ci u32 unused[(0x1000-0x100)/4]; 1158c2ecf20Sopenharmony_ci}; 1168c2ecf20Sopenharmony_ci 1178c2ecf20Sopenharmony_cistruct leon3_apbuart_regs_map { 1188c2ecf20Sopenharmony_ci u32 data; 1198c2ecf20Sopenharmony_ci u32 status; 1208c2ecf20Sopenharmony_ci u32 ctrl; 1218c2ecf20Sopenharmony_ci u32 scaler; 1228c2ecf20Sopenharmony_ci}; 1238c2ecf20Sopenharmony_ci 1248c2ecf20Sopenharmony_cistruct leon3_gptimerelem_regs_map { 1258c2ecf20Sopenharmony_ci u32 val; 1268c2ecf20Sopenharmony_ci u32 rld; 1278c2ecf20Sopenharmony_ci u32 ctrl; 1288c2ecf20Sopenharmony_ci u32 unused; 1298c2ecf20Sopenharmony_ci}; 1308c2ecf20Sopenharmony_ci 1318c2ecf20Sopenharmony_cistruct leon3_gptimer_regs_map { 1328c2ecf20Sopenharmony_ci u32 scalar; 1338c2ecf20Sopenharmony_ci u32 scalar_reload; 1348c2ecf20Sopenharmony_ci u32 config; 1358c2ecf20Sopenharmony_ci u32 unused; 1368c2ecf20Sopenharmony_ci struct leon3_gptimerelem_regs_map e[8]; 1378c2ecf20Sopenharmony_ci}; 1388c2ecf20Sopenharmony_ci 1398c2ecf20Sopenharmony_ci/* 1408c2ecf20Sopenharmony_ci * Types and structure used for AMBA Plug & Play bus scanning 1418c2ecf20Sopenharmony_ci */ 1428c2ecf20Sopenharmony_ci 1438c2ecf20Sopenharmony_ci#define AMBA_MAXAPB_DEVS 64 1448c2ecf20Sopenharmony_ci#define AMBA_MAXAPB_DEVS_PERBUS 16 1458c2ecf20Sopenharmony_ci 1468c2ecf20Sopenharmony_cistruct amba_device_table { 1478c2ecf20Sopenharmony_ci int devnr; /* number of devices on AHB or APB bus */ 1488c2ecf20Sopenharmony_ci unsigned int *addr[16]; /* addresses to the devices configuration tables */ 1498c2ecf20Sopenharmony_ci unsigned int allocbits[1]; /* 0=unallocated, 1=allocated driver */ 1508c2ecf20Sopenharmony_ci}; 1518c2ecf20Sopenharmony_ci 1528c2ecf20Sopenharmony_cistruct amba_apbslv_device_table { 1538c2ecf20Sopenharmony_ci int devnr; /* number of devices on AHB or APB bus */ 1548c2ecf20Sopenharmony_ci unsigned int *addr[AMBA_MAXAPB_DEVS]; /* addresses to the devices configuration tables */ 1558c2ecf20Sopenharmony_ci unsigned int apbmst[AMBA_MAXAPB_DEVS]; /* apb master if a entry is a apb slave */ 1568c2ecf20Sopenharmony_ci unsigned int apbmstidx[AMBA_MAXAPB_DEVS]; /* apb master idx if a entry is a apb slave */ 1578c2ecf20Sopenharmony_ci unsigned int allocbits[4]; /* 0=unallocated, 1=allocated driver */ 1588c2ecf20Sopenharmony_ci}; 1598c2ecf20Sopenharmony_ci 1608c2ecf20Sopenharmony_cistruct amba_confarea_type { 1618c2ecf20Sopenharmony_ci struct amba_confarea_type *next;/* next bus in chain */ 1628c2ecf20Sopenharmony_ci struct amba_device_table ahbmst; 1638c2ecf20Sopenharmony_ci struct amba_device_table ahbslv; 1648c2ecf20Sopenharmony_ci struct amba_apbslv_device_table apbslv; 1658c2ecf20Sopenharmony_ci unsigned int apbmst; 1668c2ecf20Sopenharmony_ci}; 1678c2ecf20Sopenharmony_ci 1688c2ecf20Sopenharmony_ci/* collect apb slaves */ 1698c2ecf20Sopenharmony_cistruct amba_apb_device { 1708c2ecf20Sopenharmony_ci unsigned int start, irq, bus_id; 1718c2ecf20Sopenharmony_ci struct amba_confarea_type *bus; 1728c2ecf20Sopenharmony_ci}; 1738c2ecf20Sopenharmony_ci 1748c2ecf20Sopenharmony_ci/* collect ahb slaves */ 1758c2ecf20Sopenharmony_cistruct amba_ahb_device { 1768c2ecf20Sopenharmony_ci unsigned int start[4], irq, bus_id; 1778c2ecf20Sopenharmony_ci struct amba_confarea_type *bus; 1788c2ecf20Sopenharmony_ci}; 1798c2ecf20Sopenharmony_ci 1808c2ecf20Sopenharmony_cistruct device_node; 1818c2ecf20Sopenharmony_civoid _amba_init(struct device_node *dp, struct device_node ***nextp); 1828c2ecf20Sopenharmony_ci 1838c2ecf20Sopenharmony_ciextern unsigned long amba_system_id; 1848c2ecf20Sopenharmony_ciextern struct leon3_irqctrl_regs_map *leon3_irqctrl_regs; 1858c2ecf20Sopenharmony_ciextern struct leon3_gptimer_regs_map *leon3_gptimer_regs; 1868c2ecf20Sopenharmony_ciextern struct amba_apb_device leon_percpu_timer_dev[16]; 1878c2ecf20Sopenharmony_ciextern int leondebug_irq_disable; 1888c2ecf20Sopenharmony_ciextern int leon_debug_irqout; 1898c2ecf20Sopenharmony_ciextern unsigned long leon3_gptimer_irq; 1908c2ecf20Sopenharmony_ciextern unsigned int sparc_leon_eirq; 1918c2ecf20Sopenharmony_ci 1928c2ecf20Sopenharmony_ci#endif /* __ASSEMBLY__ */ 1938c2ecf20Sopenharmony_ci 1948c2ecf20Sopenharmony_ci#define LEON3_IO_AREA 0xfff00000 1958c2ecf20Sopenharmony_ci#define LEON3_CONF_AREA 0xff000 1968c2ecf20Sopenharmony_ci#define LEON3_AHB_SLAVE_CONF_AREA (1 << 11) 1978c2ecf20Sopenharmony_ci 1988c2ecf20Sopenharmony_ci#define LEON3_AHB_CONF_WORDS 8 1998c2ecf20Sopenharmony_ci#define LEON3_APB_CONF_WORDS 2 2008c2ecf20Sopenharmony_ci#define LEON3_AHB_MASTERS 16 2018c2ecf20Sopenharmony_ci#define LEON3_AHB_SLAVES 16 2028c2ecf20Sopenharmony_ci#define LEON3_APB_SLAVES 16 2038c2ecf20Sopenharmony_ci#define LEON3_APBUARTS 8 2048c2ecf20Sopenharmony_ci 2058c2ecf20Sopenharmony_ci/* Vendor codes */ 2068c2ecf20Sopenharmony_ci#define VENDOR_GAISLER 1 2078c2ecf20Sopenharmony_ci#define VENDOR_PENDER 2 2088c2ecf20Sopenharmony_ci#define VENDOR_ESA 4 2098c2ecf20Sopenharmony_ci#define VENDOR_OPENCORES 8 2108c2ecf20Sopenharmony_ci 2118c2ecf20Sopenharmony_ci/* Gaisler Research device id's */ 2128c2ecf20Sopenharmony_ci#define GAISLER_LEON3 0x003 2138c2ecf20Sopenharmony_ci#define GAISLER_LEON3DSU 0x004 2148c2ecf20Sopenharmony_ci#define GAISLER_ETHAHB 0x005 2158c2ecf20Sopenharmony_ci#define GAISLER_APBMST 0x006 2168c2ecf20Sopenharmony_ci#define GAISLER_AHBUART 0x007 2178c2ecf20Sopenharmony_ci#define GAISLER_SRCTRL 0x008 2188c2ecf20Sopenharmony_ci#define GAISLER_SDCTRL 0x009 2198c2ecf20Sopenharmony_ci#define GAISLER_APBUART 0x00C 2208c2ecf20Sopenharmony_ci#define GAISLER_IRQMP 0x00D 2218c2ecf20Sopenharmony_ci#define GAISLER_AHBRAM 0x00E 2228c2ecf20Sopenharmony_ci#define GAISLER_GPTIMER 0x011 2238c2ecf20Sopenharmony_ci#define GAISLER_PCITRG 0x012 2248c2ecf20Sopenharmony_ci#define GAISLER_PCISBRG 0x013 2258c2ecf20Sopenharmony_ci#define GAISLER_PCIFBRG 0x014 2268c2ecf20Sopenharmony_ci#define GAISLER_PCITRACE 0x015 2278c2ecf20Sopenharmony_ci#define GAISLER_PCIDMA 0x016 2288c2ecf20Sopenharmony_ci#define GAISLER_AHBTRACE 0x017 2298c2ecf20Sopenharmony_ci#define GAISLER_ETHDSU 0x018 2308c2ecf20Sopenharmony_ci#define GAISLER_PIOPORT 0x01A 2318c2ecf20Sopenharmony_ci#define GAISLER_GRGPIO 0x01A 2328c2ecf20Sopenharmony_ci#define GAISLER_AHBJTAG 0x01c 2338c2ecf20Sopenharmony_ci#define GAISLER_ETHMAC 0x01D 2348c2ecf20Sopenharmony_ci#define GAISLER_AHB2AHB 0x020 2358c2ecf20Sopenharmony_ci#define GAISLER_USBDC 0x021 2368c2ecf20Sopenharmony_ci#define GAISLER_ATACTRL 0x024 2378c2ecf20Sopenharmony_ci#define GAISLER_DDRSPA 0x025 2388c2ecf20Sopenharmony_ci#define GAISLER_USBEHC 0x026 2398c2ecf20Sopenharmony_ci#define GAISLER_USBUHC 0x027 2408c2ecf20Sopenharmony_ci#define GAISLER_I2CMST 0x028 2418c2ecf20Sopenharmony_ci#define GAISLER_SPICTRL 0x02D 2428c2ecf20Sopenharmony_ci#define GAISLER_DDR2SPA 0x02E 2438c2ecf20Sopenharmony_ci#define GAISLER_SPIMCTRL 0x045 2448c2ecf20Sopenharmony_ci#define GAISLER_LEON4 0x048 2458c2ecf20Sopenharmony_ci#define GAISLER_LEON4DSU 0x049 2468c2ecf20Sopenharmony_ci#define GAISLER_AHBSTAT 0x052 2478c2ecf20Sopenharmony_ci#define GAISLER_FTMCTRL 0x054 2488c2ecf20Sopenharmony_ci#define GAISLER_KBD 0x060 2498c2ecf20Sopenharmony_ci#define GAISLER_VGA 0x061 2508c2ecf20Sopenharmony_ci#define GAISLER_SVGA 0x063 2518c2ecf20Sopenharmony_ci#define GAISLER_GRSYSMON 0x066 2528c2ecf20Sopenharmony_ci#define GAISLER_GRACECTRL 0x067 2538c2ecf20Sopenharmony_ci 2548c2ecf20Sopenharmony_ci#define GAISLER_L2TIME 0xffd /* internal device: leon2 timer */ 2558c2ecf20Sopenharmony_ci#define GAISLER_L2C 0xffe /* internal device: leon2compat */ 2568c2ecf20Sopenharmony_ci#define GAISLER_PLUGPLAY 0xfff /* internal device: plug & play configarea */ 2578c2ecf20Sopenharmony_ci 2588c2ecf20Sopenharmony_ci/* Chip IDs */ 2598c2ecf20Sopenharmony_ci#define AEROFLEX_UT699 0x0699 2608c2ecf20Sopenharmony_ci#define LEON4_NEXTREME1 0x0102 2618c2ecf20Sopenharmony_ci#define GAISLER_GR712RC 0x0712 2628c2ecf20Sopenharmony_ci 2638c2ecf20Sopenharmony_ci#define amba_vendor(x) (((x) >> 24) & 0xff) 2648c2ecf20Sopenharmony_ci 2658c2ecf20Sopenharmony_ci#define amba_device(x) (((x) >> 12) & 0xfff) 2668c2ecf20Sopenharmony_ci 2678c2ecf20Sopenharmony_ci#endif 268