1*4882a593Smuzhiyun /* SPDX-License-Identifier: GPL-2.0 */ 2*4882a593Smuzhiyun /* 3*4882a593Smuzhiyun * uninorth.h: definitions for using the "UniNorth" host bridge chip 4*4882a593Smuzhiyun * from Apple. This chip is used on "Core99" machines 5*4882a593Smuzhiyun * This also includes U2 used on more recent MacRISC2/3 6*4882a593Smuzhiyun * machines and U3 (G5) 7*4882a593Smuzhiyun * 8*4882a593Smuzhiyun */ 9*4882a593Smuzhiyun #ifdef __KERNEL__ 10*4882a593Smuzhiyun #ifndef __ASM_UNINORTH_H__ 11*4882a593Smuzhiyun #define __ASM_UNINORTH_H__ 12*4882a593Smuzhiyun 13*4882a593Smuzhiyun /* 14*4882a593Smuzhiyun * Uni-N and U3 config space reg. definitions 15*4882a593Smuzhiyun * 16*4882a593Smuzhiyun * (Little endian) 17*4882a593Smuzhiyun */ 18*4882a593Smuzhiyun 19*4882a593Smuzhiyun /* Address ranges selection. This one should work with Bandit too */ 20*4882a593Smuzhiyun /* Not U3 */ 21*4882a593Smuzhiyun #define UNI_N_ADDR_SELECT 0x48 22*4882a593Smuzhiyun #define UNI_N_ADDR_COARSE_MASK 0xffff0000 /* 256Mb regions at *0000000 */ 23*4882a593Smuzhiyun #define UNI_N_ADDR_FINE_MASK 0x0000ffff /* 16Mb regions at f*000000 */ 24*4882a593Smuzhiyun 25*4882a593Smuzhiyun /* AGP registers */ 26*4882a593Smuzhiyun /* Not U3 */ 27*4882a593Smuzhiyun #define UNI_N_CFG_GART_BASE 0x8c 28*4882a593Smuzhiyun #define UNI_N_CFG_AGP_BASE 0x90 29*4882a593Smuzhiyun #define UNI_N_CFG_GART_CTRL 0x94 30*4882a593Smuzhiyun #define UNI_N_CFG_INTERNAL_STATUS 0x98 31*4882a593Smuzhiyun #define UNI_N_CFG_GART_DUMMY_PAGE 0xa4 32*4882a593Smuzhiyun 33*4882a593Smuzhiyun /* UNI_N_CFG_GART_CTRL bits definitions */ 34*4882a593Smuzhiyun #define UNI_N_CFG_GART_INVAL 0x00000001 35*4882a593Smuzhiyun #define UNI_N_CFG_GART_ENABLE 0x00000100 36*4882a593Smuzhiyun #define UNI_N_CFG_GART_2xRESET 0x00010000 37*4882a593Smuzhiyun #define UNI_N_CFG_GART_DISSBADET 0x00020000 38*4882a593Smuzhiyun /* The following seems to only be used only on U3 <j.glisse@gmail.com> */ 39*4882a593Smuzhiyun #define U3_N_CFG_GART_SYNCMODE 0x00040000 40*4882a593Smuzhiyun #define U3_N_CFG_GART_PERFRD 0x00080000 41*4882a593Smuzhiyun #define U3_N_CFG_GART_B2BGNT 0x00200000 42*4882a593Smuzhiyun #define U3_N_CFG_GART_FASTDDR 0x00400000 43*4882a593Smuzhiyun 44*4882a593Smuzhiyun /* My understanding of UniNorth AGP as of UniNorth rev 1.0x, 45*4882a593Smuzhiyun * revision 1.5 (x4 AGP) may need further changes. 46*4882a593Smuzhiyun * 47*4882a593Smuzhiyun * AGP_BASE register contains the base address of the AGP aperture on 48*4882a593Smuzhiyun * the AGP bus. It doesn't seem to be visible to the CPU as of UniNorth 1.x, 49*4882a593Smuzhiyun * even if decoding of this address range is enabled in the address select 50*4882a593Smuzhiyun * register. Apparently, the only supported bases are 256Mb multiples 51*4882a593Smuzhiyun * (high 4 bits of that register). 52*4882a593Smuzhiyun * 53*4882a593Smuzhiyun * GART_BASE register appear to contain the physical address of the GART 54*4882a593Smuzhiyun * in system memory in the high address bits (page aligned), and the 55*4882a593Smuzhiyun * GART size in the low order bits (number of GART pages) 56*4882a593Smuzhiyun * 57*4882a593Smuzhiyun * The GART format itself is one 32bits word per physical memory page. 58*4882a593Smuzhiyun * This word contains, in little-endian format (!!!), the physical address 59*4882a593Smuzhiyun * of the page in the high bits, and what appears to be an "enable" bit 60*4882a593Smuzhiyun * in the LSB bit (0) that must be set to 1 when the entry is valid. 61*4882a593Smuzhiyun * 62*4882a593Smuzhiyun * Obviously, the GART is not cache coherent and so any change to it 63*4882a593Smuzhiyun * must be flushed to memory (or maybe just make the GART space non 64*4882a593Smuzhiyun * cachable). AGP memory itself doesn't seem to be cache coherent neither. 65*4882a593Smuzhiyun * 66*4882a593Smuzhiyun * In order to invalidate the GART (which is probably necessary to inval 67*4882a593Smuzhiyun * the bridge internal TLBs), the following sequence has to be written, 68*4882a593Smuzhiyun * in order, to the GART_CTRL register: 69*4882a593Smuzhiyun * 70*4882a593Smuzhiyun * UNI_N_CFG_GART_ENABLE | UNI_N_CFG_GART_INVAL 71*4882a593Smuzhiyun * UNI_N_CFG_GART_ENABLE 72*4882a593Smuzhiyun * UNI_N_CFG_GART_ENABLE | UNI_N_CFG_GART_2xRESET 73*4882a593Smuzhiyun * UNI_N_CFG_GART_ENABLE 74*4882a593Smuzhiyun * 75*4882a593Smuzhiyun * As far as AGP "features" are concerned, it looks like fast write may 76*4882a593Smuzhiyun * not be supported but this has to be confirmed. 77*4882a593Smuzhiyun * 78*4882a593Smuzhiyun * Turning on AGP seem to require a double invalidate operation, one before 79*4882a593Smuzhiyun * setting the AGP command register, on after. 80*4882a593Smuzhiyun * 81*4882a593Smuzhiyun * Turning off AGP seems to require the following sequence: first wait 82*4882a593Smuzhiyun * for the AGP to be idle by reading the internal status register, then 83*4882a593Smuzhiyun * write in that order to the GART_CTRL register: 84*4882a593Smuzhiyun * 85*4882a593Smuzhiyun * UNI_N_CFG_GART_ENABLE | UNI_N_CFG_GART_INVAL 86*4882a593Smuzhiyun * 0 87*4882a593Smuzhiyun * UNI_N_CFG_GART_2xRESET 88*4882a593Smuzhiyun * 0 89*4882a593Smuzhiyun */ 90*4882a593Smuzhiyun 91*4882a593Smuzhiyun /* 92*4882a593Smuzhiyun * Uni-N memory mapped reg. definitions 93*4882a593Smuzhiyun * 94*4882a593Smuzhiyun * Those registers are Big-Endian !! 95*4882a593Smuzhiyun * 96*4882a593Smuzhiyun * Their meaning come from either Darwin and/or from experiments I made with 97*4882a593Smuzhiyun * the bootrom, I'm not sure about their exact meaning yet 98*4882a593Smuzhiyun * 99*4882a593Smuzhiyun */ 100*4882a593Smuzhiyun 101*4882a593Smuzhiyun /* Version of the UniNorth chip */ 102*4882a593Smuzhiyun #define UNI_N_VERSION 0x0000 /* Known versions: 3,7 and 8 */ 103*4882a593Smuzhiyun 104*4882a593Smuzhiyun #define UNI_N_VERSION_107 0x0003 /* 1.0.7 */ 105*4882a593Smuzhiyun #define UNI_N_VERSION_10A 0x0007 /* 1.0.10 */ 106*4882a593Smuzhiyun #define UNI_N_VERSION_150 0x0011 /* 1.5 */ 107*4882a593Smuzhiyun #define UNI_N_VERSION_200 0x0024 /* 2.0 */ 108*4882a593Smuzhiyun #define UNI_N_VERSION_PANGEA 0x00C0 /* Integrated U1 + K */ 109*4882a593Smuzhiyun #define UNI_N_VERSION_INTREPID 0x00D2 /* Integrated U2 + K */ 110*4882a593Smuzhiyun #define UNI_N_VERSION_300 0x0030 /* 3.0 (U3 on G5) */ 111*4882a593Smuzhiyun 112*4882a593Smuzhiyun /* This register is used to enable/disable various clocks */ 113*4882a593Smuzhiyun #define UNI_N_CLOCK_CNTL 0x0020 114*4882a593Smuzhiyun #define UNI_N_CLOCK_CNTL_PCI 0x00000001 /* PCI2 clock control */ 115*4882a593Smuzhiyun #define UNI_N_CLOCK_CNTL_GMAC 0x00000002 /* GMAC clock control */ 116*4882a593Smuzhiyun #define UNI_N_CLOCK_CNTL_FW 0x00000004 /* FireWire clock control */ 117*4882a593Smuzhiyun #define UNI_N_CLOCK_CNTL_ATA100 0x00000010 /* ATA-100 clock control (U2) */ 118*4882a593Smuzhiyun 119*4882a593Smuzhiyun /* Power Management control */ 120*4882a593Smuzhiyun #define UNI_N_POWER_MGT 0x0030 121*4882a593Smuzhiyun #define UNI_N_POWER_MGT_NORMAL 0x00 122*4882a593Smuzhiyun #define UNI_N_POWER_MGT_IDLE2 0x01 123*4882a593Smuzhiyun #define UNI_N_POWER_MGT_SLEEP 0x02 124*4882a593Smuzhiyun 125*4882a593Smuzhiyun /* This register is configured by Darwin depending on the UniN 126*4882a593Smuzhiyun * revision 127*4882a593Smuzhiyun */ 128*4882a593Smuzhiyun #define UNI_N_ARB_CTRL 0x0040 129*4882a593Smuzhiyun #define UNI_N_ARB_CTRL_QACK_DELAY_SHIFT 15 130*4882a593Smuzhiyun #define UNI_N_ARB_CTRL_QACK_DELAY_MASK 0x0e1f8000 131*4882a593Smuzhiyun #define UNI_N_ARB_CTRL_QACK_DELAY 0x30 132*4882a593Smuzhiyun #define UNI_N_ARB_CTRL_QACK_DELAY105 0x00 133*4882a593Smuzhiyun 134*4882a593Smuzhiyun /* This one _might_ return the CPU number of the CPU reading it; 135*4882a593Smuzhiyun * the bootROM decides whether to boot or to sleep/spinloop depending 136*4882a593Smuzhiyun * on this register being 0 or not 137*4882a593Smuzhiyun */ 138*4882a593Smuzhiyun #define UNI_N_CPU_NUMBER 0x0050 139*4882a593Smuzhiyun 140*4882a593Smuzhiyun /* This register appear to be read by the bootROM to decide what 141*4882a593Smuzhiyun * to do on a non-recoverable reset (powerup or wakeup) 142*4882a593Smuzhiyun */ 143*4882a593Smuzhiyun #define UNI_N_HWINIT_STATE 0x0070 144*4882a593Smuzhiyun #define UNI_N_HWINIT_STATE_SLEEPING 0x01 145*4882a593Smuzhiyun #define UNI_N_HWINIT_STATE_RUNNING 0x02 146*4882a593Smuzhiyun /* This last bit appear to be used by the bootROM to know the second 147*4882a593Smuzhiyun * CPU has started and will enter it's sleep loop with IP=0 148*4882a593Smuzhiyun */ 149*4882a593Smuzhiyun #define UNI_N_HWINIT_STATE_CPU1_FLAG 0x10000000 150*4882a593Smuzhiyun 151*4882a593Smuzhiyun /* This register controls AACK delay, which is set when 2004 iBook/PowerBook 152*4882a593Smuzhiyun * is in low speed mode. 153*4882a593Smuzhiyun */ 154*4882a593Smuzhiyun #define UNI_N_AACK_DELAY 0x0100 155*4882a593Smuzhiyun #define UNI_N_AACK_DELAY_ENABLE 0x00000001 156*4882a593Smuzhiyun 157*4882a593Smuzhiyun /* Clock status for Intrepid */ 158*4882a593Smuzhiyun #define UNI_N_CLOCK_STOP_STATUS0 0x0150 159*4882a593Smuzhiyun #define UNI_N_CLOCK_STOPPED_EXTAGP 0x00200000 160*4882a593Smuzhiyun #define UNI_N_CLOCK_STOPPED_AGPDEL 0x00100000 161*4882a593Smuzhiyun #define UNI_N_CLOCK_STOPPED_I2S0_45_49 0x00080000 162*4882a593Smuzhiyun #define UNI_N_CLOCK_STOPPED_I2S0_18 0x00040000 163*4882a593Smuzhiyun #define UNI_N_CLOCK_STOPPED_I2S1_45_49 0x00020000 164*4882a593Smuzhiyun #define UNI_N_CLOCK_STOPPED_I2S1_18 0x00010000 165*4882a593Smuzhiyun #define UNI_N_CLOCK_STOPPED_TIMER 0x00008000 166*4882a593Smuzhiyun #define UNI_N_CLOCK_STOPPED_SCC_RTCLK18 0x00004000 167*4882a593Smuzhiyun #define UNI_N_CLOCK_STOPPED_SCC_RTCLK32 0x00002000 168*4882a593Smuzhiyun #define UNI_N_CLOCK_STOPPED_SCC_VIA32 0x00001000 169*4882a593Smuzhiyun #define UNI_N_CLOCK_STOPPED_SCC_SLOT0 0x00000800 170*4882a593Smuzhiyun #define UNI_N_CLOCK_STOPPED_SCC_SLOT1 0x00000400 171*4882a593Smuzhiyun #define UNI_N_CLOCK_STOPPED_SCC_SLOT2 0x00000200 172*4882a593Smuzhiyun #define UNI_N_CLOCK_STOPPED_PCI_FBCLKO 0x00000100 173*4882a593Smuzhiyun #define UNI_N_CLOCK_STOPPED_VEO0 0x00000080 174*4882a593Smuzhiyun #define UNI_N_CLOCK_STOPPED_VEO1 0x00000040 175*4882a593Smuzhiyun #define UNI_N_CLOCK_STOPPED_USB0 0x00000020 176*4882a593Smuzhiyun #define UNI_N_CLOCK_STOPPED_USB1 0x00000010 177*4882a593Smuzhiyun #define UNI_N_CLOCK_STOPPED_USB2 0x00000008 178*4882a593Smuzhiyun #define UNI_N_CLOCK_STOPPED_32 0x00000004 179*4882a593Smuzhiyun #define UNI_N_CLOCK_STOPPED_45 0x00000002 180*4882a593Smuzhiyun #define UNI_N_CLOCK_STOPPED_49 0x00000001 181*4882a593Smuzhiyun 182*4882a593Smuzhiyun #define UNI_N_CLOCK_STOP_STATUS1 0x0160 183*4882a593Smuzhiyun #define UNI_N_CLOCK_STOPPED_PLL4REF 0x00080000 184*4882a593Smuzhiyun #define UNI_N_CLOCK_STOPPED_CPUDEL 0x00040000 185*4882a593Smuzhiyun #define UNI_N_CLOCK_STOPPED_CPU 0x00020000 186*4882a593Smuzhiyun #define UNI_N_CLOCK_STOPPED_BUF_REFCKO 0x00010000 187*4882a593Smuzhiyun #define UNI_N_CLOCK_STOPPED_PCI2 0x00008000 188*4882a593Smuzhiyun #define UNI_N_CLOCK_STOPPED_FW 0x00004000 189*4882a593Smuzhiyun #define UNI_N_CLOCK_STOPPED_GB 0x00002000 190*4882a593Smuzhiyun #define UNI_N_CLOCK_STOPPED_ATA66 0x00001000 191*4882a593Smuzhiyun #define UNI_N_CLOCK_STOPPED_ATA100 0x00000800 192*4882a593Smuzhiyun #define UNI_N_CLOCK_STOPPED_MAX 0x00000400 193*4882a593Smuzhiyun #define UNI_N_CLOCK_STOPPED_PCI1 0x00000200 194*4882a593Smuzhiyun #define UNI_N_CLOCK_STOPPED_KLPCI 0x00000100 195*4882a593Smuzhiyun #define UNI_N_CLOCK_STOPPED_USB0PCI 0x00000080 196*4882a593Smuzhiyun #define UNI_N_CLOCK_STOPPED_USB1PCI 0x00000040 197*4882a593Smuzhiyun #define UNI_N_CLOCK_STOPPED_USB2PCI 0x00000020 198*4882a593Smuzhiyun #define UNI_N_CLOCK_STOPPED_7PCI1 0x00000008 199*4882a593Smuzhiyun #define UNI_N_CLOCK_STOPPED_AGP 0x00000004 200*4882a593Smuzhiyun #define UNI_N_CLOCK_STOPPED_PCI0 0x00000002 201*4882a593Smuzhiyun #define UNI_N_CLOCK_STOPPED_18 0x00000001 202*4882a593Smuzhiyun 203*4882a593Smuzhiyun /* Intrepid registe to OF do-platform-clockspreading */ 204*4882a593Smuzhiyun #define UNI_N_CLOCK_SPREADING 0x190 205*4882a593Smuzhiyun 206*4882a593Smuzhiyun /* Uninorth 1.5 rev. has additional perf. monitor registers at 0xf00-0xf50 */ 207*4882a593Smuzhiyun 208*4882a593Smuzhiyun 209*4882a593Smuzhiyun /* 210*4882a593Smuzhiyun * U3 specific registers 211*4882a593Smuzhiyun */ 212*4882a593Smuzhiyun 213*4882a593Smuzhiyun 214*4882a593Smuzhiyun /* U3 Toggle */ 215*4882a593Smuzhiyun #define U3_TOGGLE_REG 0x00e0 216*4882a593Smuzhiyun #define U3_PMC_START_STOP 0x0001 217*4882a593Smuzhiyun #define U3_MPIC_RESET 0x0002 218*4882a593Smuzhiyun #define U3_MPIC_OUTPUT_ENABLE 0x0004 219*4882a593Smuzhiyun 220*4882a593Smuzhiyun /* U3 API PHY Config 1 */ 221*4882a593Smuzhiyun #define U3_API_PHY_CONFIG_1 0x23030 222*4882a593Smuzhiyun 223*4882a593Smuzhiyun /* U3 HyperTransport registers */ 224*4882a593Smuzhiyun #define U3_HT_CONFIG_BASE 0x70000 225*4882a593Smuzhiyun #define U3_HT_LINK_COMMAND 0x100 226*4882a593Smuzhiyun #define U3_HT_LINK_CONFIG 0x110 227*4882a593Smuzhiyun #define U3_HT_LINK_FREQ 0x120 228*4882a593Smuzhiyun 229*4882a593Smuzhiyun #endif /* __ASM_UNINORTH_H__ */ 230*4882a593Smuzhiyun #endif /* __KERNEL__ */ 231