18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */ 28c2ecf20Sopenharmony_ci/* 38c2ecf20Sopenharmony_ci * uninorth.h: definitions for using the "UniNorth" host bridge chip 48c2ecf20Sopenharmony_ci * from Apple. This chip is used on "Core99" machines 58c2ecf20Sopenharmony_ci * This also includes U2 used on more recent MacRISC2/3 68c2ecf20Sopenharmony_ci * machines and U3 (G5) 78c2ecf20Sopenharmony_ci * 88c2ecf20Sopenharmony_ci */ 98c2ecf20Sopenharmony_ci#ifdef __KERNEL__ 108c2ecf20Sopenharmony_ci#ifndef __ASM_UNINORTH_H__ 118c2ecf20Sopenharmony_ci#define __ASM_UNINORTH_H__ 128c2ecf20Sopenharmony_ci 138c2ecf20Sopenharmony_ci/* 148c2ecf20Sopenharmony_ci * Uni-N and U3 config space reg. definitions 158c2ecf20Sopenharmony_ci * 168c2ecf20Sopenharmony_ci * (Little endian) 178c2ecf20Sopenharmony_ci */ 188c2ecf20Sopenharmony_ci 198c2ecf20Sopenharmony_ci/* Address ranges selection. This one should work with Bandit too */ 208c2ecf20Sopenharmony_ci/* Not U3 */ 218c2ecf20Sopenharmony_ci#define UNI_N_ADDR_SELECT 0x48 228c2ecf20Sopenharmony_ci#define UNI_N_ADDR_COARSE_MASK 0xffff0000 /* 256Mb regions at *0000000 */ 238c2ecf20Sopenharmony_ci#define UNI_N_ADDR_FINE_MASK 0x0000ffff /* 16Mb regions at f*000000 */ 248c2ecf20Sopenharmony_ci 258c2ecf20Sopenharmony_ci/* AGP registers */ 268c2ecf20Sopenharmony_ci/* Not U3 */ 278c2ecf20Sopenharmony_ci#define UNI_N_CFG_GART_BASE 0x8c 288c2ecf20Sopenharmony_ci#define UNI_N_CFG_AGP_BASE 0x90 298c2ecf20Sopenharmony_ci#define UNI_N_CFG_GART_CTRL 0x94 308c2ecf20Sopenharmony_ci#define UNI_N_CFG_INTERNAL_STATUS 0x98 318c2ecf20Sopenharmony_ci#define UNI_N_CFG_GART_DUMMY_PAGE 0xa4 328c2ecf20Sopenharmony_ci 338c2ecf20Sopenharmony_ci/* UNI_N_CFG_GART_CTRL bits definitions */ 348c2ecf20Sopenharmony_ci#define UNI_N_CFG_GART_INVAL 0x00000001 358c2ecf20Sopenharmony_ci#define UNI_N_CFG_GART_ENABLE 0x00000100 368c2ecf20Sopenharmony_ci#define UNI_N_CFG_GART_2xRESET 0x00010000 378c2ecf20Sopenharmony_ci#define UNI_N_CFG_GART_DISSBADET 0x00020000 388c2ecf20Sopenharmony_ci/* The following seems to only be used only on U3 <j.glisse@gmail.com> */ 398c2ecf20Sopenharmony_ci#define U3_N_CFG_GART_SYNCMODE 0x00040000 408c2ecf20Sopenharmony_ci#define U3_N_CFG_GART_PERFRD 0x00080000 418c2ecf20Sopenharmony_ci#define U3_N_CFG_GART_B2BGNT 0x00200000 428c2ecf20Sopenharmony_ci#define U3_N_CFG_GART_FASTDDR 0x00400000 438c2ecf20Sopenharmony_ci 448c2ecf20Sopenharmony_ci/* My understanding of UniNorth AGP as of UniNorth rev 1.0x, 458c2ecf20Sopenharmony_ci * revision 1.5 (x4 AGP) may need further changes. 468c2ecf20Sopenharmony_ci * 478c2ecf20Sopenharmony_ci * AGP_BASE register contains the base address of the AGP aperture on 488c2ecf20Sopenharmony_ci * the AGP bus. It doesn't seem to be visible to the CPU as of UniNorth 1.x, 498c2ecf20Sopenharmony_ci * even if decoding of this address range is enabled in the address select 508c2ecf20Sopenharmony_ci * register. Apparently, the only supported bases are 256Mb multiples 518c2ecf20Sopenharmony_ci * (high 4 bits of that register). 528c2ecf20Sopenharmony_ci * 538c2ecf20Sopenharmony_ci * GART_BASE register appear to contain the physical address of the GART 548c2ecf20Sopenharmony_ci * in system memory in the high address bits (page aligned), and the 558c2ecf20Sopenharmony_ci * GART size in the low order bits (number of GART pages) 568c2ecf20Sopenharmony_ci * 578c2ecf20Sopenharmony_ci * The GART format itself is one 32bits word per physical memory page. 588c2ecf20Sopenharmony_ci * This word contains, in little-endian format (!!!), the physical address 598c2ecf20Sopenharmony_ci * of the page in the high bits, and what appears to be an "enable" bit 608c2ecf20Sopenharmony_ci * in the LSB bit (0) that must be set to 1 when the entry is valid. 618c2ecf20Sopenharmony_ci * 628c2ecf20Sopenharmony_ci * Obviously, the GART is not cache coherent and so any change to it 638c2ecf20Sopenharmony_ci * must be flushed to memory (or maybe just make the GART space non 648c2ecf20Sopenharmony_ci * cachable). AGP memory itself doesn't seem to be cache coherent neither. 658c2ecf20Sopenharmony_ci * 668c2ecf20Sopenharmony_ci * In order to invalidate the GART (which is probably necessary to inval 678c2ecf20Sopenharmony_ci * the bridge internal TLBs), the following sequence has to be written, 688c2ecf20Sopenharmony_ci * in order, to the GART_CTRL register: 698c2ecf20Sopenharmony_ci * 708c2ecf20Sopenharmony_ci * UNI_N_CFG_GART_ENABLE | UNI_N_CFG_GART_INVAL 718c2ecf20Sopenharmony_ci * UNI_N_CFG_GART_ENABLE 728c2ecf20Sopenharmony_ci * UNI_N_CFG_GART_ENABLE | UNI_N_CFG_GART_2xRESET 738c2ecf20Sopenharmony_ci * UNI_N_CFG_GART_ENABLE 748c2ecf20Sopenharmony_ci * 758c2ecf20Sopenharmony_ci * As far as AGP "features" are concerned, it looks like fast write may 768c2ecf20Sopenharmony_ci * not be supported but this has to be confirmed. 778c2ecf20Sopenharmony_ci * 788c2ecf20Sopenharmony_ci * Turning on AGP seem to require a double invalidate operation, one before 798c2ecf20Sopenharmony_ci * setting the AGP command register, on after. 808c2ecf20Sopenharmony_ci * 818c2ecf20Sopenharmony_ci * Turning off AGP seems to require the following sequence: first wait 828c2ecf20Sopenharmony_ci * for the AGP to be idle by reading the internal status register, then 838c2ecf20Sopenharmony_ci * write in that order to the GART_CTRL register: 848c2ecf20Sopenharmony_ci * 858c2ecf20Sopenharmony_ci * UNI_N_CFG_GART_ENABLE | UNI_N_CFG_GART_INVAL 868c2ecf20Sopenharmony_ci * 0 878c2ecf20Sopenharmony_ci * UNI_N_CFG_GART_2xRESET 888c2ecf20Sopenharmony_ci * 0 898c2ecf20Sopenharmony_ci */ 908c2ecf20Sopenharmony_ci 918c2ecf20Sopenharmony_ci/* 928c2ecf20Sopenharmony_ci * Uni-N memory mapped reg. definitions 938c2ecf20Sopenharmony_ci * 948c2ecf20Sopenharmony_ci * Those registers are Big-Endian !! 958c2ecf20Sopenharmony_ci * 968c2ecf20Sopenharmony_ci * Their meaning come from either Darwin and/or from experiments I made with 978c2ecf20Sopenharmony_ci * the bootrom, I'm not sure about their exact meaning yet 988c2ecf20Sopenharmony_ci * 998c2ecf20Sopenharmony_ci */ 1008c2ecf20Sopenharmony_ci 1018c2ecf20Sopenharmony_ci/* Version of the UniNorth chip */ 1028c2ecf20Sopenharmony_ci#define UNI_N_VERSION 0x0000 /* Known versions: 3,7 and 8 */ 1038c2ecf20Sopenharmony_ci 1048c2ecf20Sopenharmony_ci#define UNI_N_VERSION_107 0x0003 /* 1.0.7 */ 1058c2ecf20Sopenharmony_ci#define UNI_N_VERSION_10A 0x0007 /* 1.0.10 */ 1068c2ecf20Sopenharmony_ci#define UNI_N_VERSION_150 0x0011 /* 1.5 */ 1078c2ecf20Sopenharmony_ci#define UNI_N_VERSION_200 0x0024 /* 2.0 */ 1088c2ecf20Sopenharmony_ci#define UNI_N_VERSION_PANGEA 0x00C0 /* Integrated U1 + K */ 1098c2ecf20Sopenharmony_ci#define UNI_N_VERSION_INTREPID 0x00D2 /* Integrated U2 + K */ 1108c2ecf20Sopenharmony_ci#define UNI_N_VERSION_300 0x0030 /* 3.0 (U3 on G5) */ 1118c2ecf20Sopenharmony_ci 1128c2ecf20Sopenharmony_ci/* This register is used to enable/disable various clocks */ 1138c2ecf20Sopenharmony_ci#define UNI_N_CLOCK_CNTL 0x0020 1148c2ecf20Sopenharmony_ci#define UNI_N_CLOCK_CNTL_PCI 0x00000001 /* PCI2 clock control */ 1158c2ecf20Sopenharmony_ci#define UNI_N_CLOCK_CNTL_GMAC 0x00000002 /* GMAC clock control */ 1168c2ecf20Sopenharmony_ci#define UNI_N_CLOCK_CNTL_FW 0x00000004 /* FireWire clock control */ 1178c2ecf20Sopenharmony_ci#define UNI_N_CLOCK_CNTL_ATA100 0x00000010 /* ATA-100 clock control (U2) */ 1188c2ecf20Sopenharmony_ci 1198c2ecf20Sopenharmony_ci/* Power Management control */ 1208c2ecf20Sopenharmony_ci#define UNI_N_POWER_MGT 0x0030 1218c2ecf20Sopenharmony_ci#define UNI_N_POWER_MGT_NORMAL 0x00 1228c2ecf20Sopenharmony_ci#define UNI_N_POWER_MGT_IDLE2 0x01 1238c2ecf20Sopenharmony_ci#define UNI_N_POWER_MGT_SLEEP 0x02 1248c2ecf20Sopenharmony_ci 1258c2ecf20Sopenharmony_ci/* This register is configured by Darwin depending on the UniN 1268c2ecf20Sopenharmony_ci * revision 1278c2ecf20Sopenharmony_ci */ 1288c2ecf20Sopenharmony_ci#define UNI_N_ARB_CTRL 0x0040 1298c2ecf20Sopenharmony_ci#define UNI_N_ARB_CTRL_QACK_DELAY_SHIFT 15 1308c2ecf20Sopenharmony_ci#define UNI_N_ARB_CTRL_QACK_DELAY_MASK 0x0e1f8000 1318c2ecf20Sopenharmony_ci#define UNI_N_ARB_CTRL_QACK_DELAY 0x30 1328c2ecf20Sopenharmony_ci#define UNI_N_ARB_CTRL_QACK_DELAY105 0x00 1338c2ecf20Sopenharmony_ci 1348c2ecf20Sopenharmony_ci/* This one _might_ return the CPU number of the CPU reading it; 1358c2ecf20Sopenharmony_ci * the bootROM decides whether to boot or to sleep/spinloop depending 1368c2ecf20Sopenharmony_ci * on this register being 0 or not 1378c2ecf20Sopenharmony_ci */ 1388c2ecf20Sopenharmony_ci#define UNI_N_CPU_NUMBER 0x0050 1398c2ecf20Sopenharmony_ci 1408c2ecf20Sopenharmony_ci/* This register appear to be read by the bootROM to decide what 1418c2ecf20Sopenharmony_ci * to do on a non-recoverable reset (powerup or wakeup) 1428c2ecf20Sopenharmony_ci */ 1438c2ecf20Sopenharmony_ci#define UNI_N_HWINIT_STATE 0x0070 1448c2ecf20Sopenharmony_ci#define UNI_N_HWINIT_STATE_SLEEPING 0x01 1458c2ecf20Sopenharmony_ci#define UNI_N_HWINIT_STATE_RUNNING 0x02 1468c2ecf20Sopenharmony_ci/* This last bit appear to be used by the bootROM to know the second 1478c2ecf20Sopenharmony_ci * CPU has started and will enter it's sleep loop with IP=0 1488c2ecf20Sopenharmony_ci */ 1498c2ecf20Sopenharmony_ci#define UNI_N_HWINIT_STATE_CPU1_FLAG 0x10000000 1508c2ecf20Sopenharmony_ci 1518c2ecf20Sopenharmony_ci/* This register controls AACK delay, which is set when 2004 iBook/PowerBook 1528c2ecf20Sopenharmony_ci * is in low speed mode. 1538c2ecf20Sopenharmony_ci */ 1548c2ecf20Sopenharmony_ci#define UNI_N_AACK_DELAY 0x0100 1558c2ecf20Sopenharmony_ci#define UNI_N_AACK_DELAY_ENABLE 0x00000001 1568c2ecf20Sopenharmony_ci 1578c2ecf20Sopenharmony_ci/* Clock status for Intrepid */ 1588c2ecf20Sopenharmony_ci#define UNI_N_CLOCK_STOP_STATUS0 0x0150 1598c2ecf20Sopenharmony_ci#define UNI_N_CLOCK_STOPPED_EXTAGP 0x00200000 1608c2ecf20Sopenharmony_ci#define UNI_N_CLOCK_STOPPED_AGPDEL 0x00100000 1618c2ecf20Sopenharmony_ci#define UNI_N_CLOCK_STOPPED_I2S0_45_49 0x00080000 1628c2ecf20Sopenharmony_ci#define UNI_N_CLOCK_STOPPED_I2S0_18 0x00040000 1638c2ecf20Sopenharmony_ci#define UNI_N_CLOCK_STOPPED_I2S1_45_49 0x00020000 1648c2ecf20Sopenharmony_ci#define UNI_N_CLOCK_STOPPED_I2S1_18 0x00010000 1658c2ecf20Sopenharmony_ci#define UNI_N_CLOCK_STOPPED_TIMER 0x00008000 1668c2ecf20Sopenharmony_ci#define UNI_N_CLOCK_STOPPED_SCC_RTCLK18 0x00004000 1678c2ecf20Sopenharmony_ci#define UNI_N_CLOCK_STOPPED_SCC_RTCLK32 0x00002000 1688c2ecf20Sopenharmony_ci#define UNI_N_CLOCK_STOPPED_SCC_VIA32 0x00001000 1698c2ecf20Sopenharmony_ci#define UNI_N_CLOCK_STOPPED_SCC_SLOT0 0x00000800 1708c2ecf20Sopenharmony_ci#define UNI_N_CLOCK_STOPPED_SCC_SLOT1 0x00000400 1718c2ecf20Sopenharmony_ci#define UNI_N_CLOCK_STOPPED_SCC_SLOT2 0x00000200 1728c2ecf20Sopenharmony_ci#define UNI_N_CLOCK_STOPPED_PCI_FBCLKO 0x00000100 1738c2ecf20Sopenharmony_ci#define UNI_N_CLOCK_STOPPED_VEO0 0x00000080 1748c2ecf20Sopenharmony_ci#define UNI_N_CLOCK_STOPPED_VEO1 0x00000040 1758c2ecf20Sopenharmony_ci#define UNI_N_CLOCK_STOPPED_USB0 0x00000020 1768c2ecf20Sopenharmony_ci#define UNI_N_CLOCK_STOPPED_USB1 0x00000010 1778c2ecf20Sopenharmony_ci#define UNI_N_CLOCK_STOPPED_USB2 0x00000008 1788c2ecf20Sopenharmony_ci#define UNI_N_CLOCK_STOPPED_32 0x00000004 1798c2ecf20Sopenharmony_ci#define UNI_N_CLOCK_STOPPED_45 0x00000002 1808c2ecf20Sopenharmony_ci#define UNI_N_CLOCK_STOPPED_49 0x00000001 1818c2ecf20Sopenharmony_ci 1828c2ecf20Sopenharmony_ci#define UNI_N_CLOCK_STOP_STATUS1 0x0160 1838c2ecf20Sopenharmony_ci#define UNI_N_CLOCK_STOPPED_PLL4REF 0x00080000 1848c2ecf20Sopenharmony_ci#define UNI_N_CLOCK_STOPPED_CPUDEL 0x00040000 1858c2ecf20Sopenharmony_ci#define UNI_N_CLOCK_STOPPED_CPU 0x00020000 1868c2ecf20Sopenharmony_ci#define UNI_N_CLOCK_STOPPED_BUF_REFCKO 0x00010000 1878c2ecf20Sopenharmony_ci#define UNI_N_CLOCK_STOPPED_PCI2 0x00008000 1888c2ecf20Sopenharmony_ci#define UNI_N_CLOCK_STOPPED_FW 0x00004000 1898c2ecf20Sopenharmony_ci#define UNI_N_CLOCK_STOPPED_GB 0x00002000 1908c2ecf20Sopenharmony_ci#define UNI_N_CLOCK_STOPPED_ATA66 0x00001000 1918c2ecf20Sopenharmony_ci#define UNI_N_CLOCK_STOPPED_ATA100 0x00000800 1928c2ecf20Sopenharmony_ci#define UNI_N_CLOCK_STOPPED_MAX 0x00000400 1938c2ecf20Sopenharmony_ci#define UNI_N_CLOCK_STOPPED_PCI1 0x00000200 1948c2ecf20Sopenharmony_ci#define UNI_N_CLOCK_STOPPED_KLPCI 0x00000100 1958c2ecf20Sopenharmony_ci#define UNI_N_CLOCK_STOPPED_USB0PCI 0x00000080 1968c2ecf20Sopenharmony_ci#define UNI_N_CLOCK_STOPPED_USB1PCI 0x00000040 1978c2ecf20Sopenharmony_ci#define UNI_N_CLOCK_STOPPED_USB2PCI 0x00000020 1988c2ecf20Sopenharmony_ci#define UNI_N_CLOCK_STOPPED_7PCI1 0x00000008 1998c2ecf20Sopenharmony_ci#define UNI_N_CLOCK_STOPPED_AGP 0x00000004 2008c2ecf20Sopenharmony_ci#define UNI_N_CLOCK_STOPPED_PCI0 0x00000002 2018c2ecf20Sopenharmony_ci#define UNI_N_CLOCK_STOPPED_18 0x00000001 2028c2ecf20Sopenharmony_ci 2038c2ecf20Sopenharmony_ci/* Intrepid registe to OF do-platform-clockspreading */ 2048c2ecf20Sopenharmony_ci#define UNI_N_CLOCK_SPREADING 0x190 2058c2ecf20Sopenharmony_ci 2068c2ecf20Sopenharmony_ci/* Uninorth 1.5 rev. has additional perf. monitor registers at 0xf00-0xf50 */ 2078c2ecf20Sopenharmony_ci 2088c2ecf20Sopenharmony_ci 2098c2ecf20Sopenharmony_ci/* 2108c2ecf20Sopenharmony_ci * U3 specific registers 2118c2ecf20Sopenharmony_ci */ 2128c2ecf20Sopenharmony_ci 2138c2ecf20Sopenharmony_ci 2148c2ecf20Sopenharmony_ci/* U3 Toggle */ 2158c2ecf20Sopenharmony_ci#define U3_TOGGLE_REG 0x00e0 2168c2ecf20Sopenharmony_ci#define U3_PMC_START_STOP 0x0001 2178c2ecf20Sopenharmony_ci#define U3_MPIC_RESET 0x0002 2188c2ecf20Sopenharmony_ci#define U3_MPIC_OUTPUT_ENABLE 0x0004 2198c2ecf20Sopenharmony_ci 2208c2ecf20Sopenharmony_ci/* U3 API PHY Config 1 */ 2218c2ecf20Sopenharmony_ci#define U3_API_PHY_CONFIG_1 0x23030 2228c2ecf20Sopenharmony_ci 2238c2ecf20Sopenharmony_ci/* U3 HyperTransport registers */ 2248c2ecf20Sopenharmony_ci#define U3_HT_CONFIG_BASE 0x70000 2258c2ecf20Sopenharmony_ci#define U3_HT_LINK_COMMAND 0x100 2268c2ecf20Sopenharmony_ci#define U3_HT_LINK_CONFIG 0x110 2278c2ecf20Sopenharmony_ci#define U3_HT_LINK_FREQ 0x120 2288c2ecf20Sopenharmony_ci 2298c2ecf20Sopenharmony_ci#endif /* __ASM_UNINORTH_H__ */ 2308c2ecf20Sopenharmony_ci#endif /* __KERNEL__ */ 231