162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */
262306a36Sopenharmony_ci/*
362306a36Sopenharmony_ci * uninorth.h: definitions for using the "UniNorth" host bridge chip
462306a36Sopenharmony_ci *             from Apple. This chip is used on "Core99" machines
562306a36Sopenharmony_ci *	       This also includes U2 used on more recent MacRISC2/3
662306a36Sopenharmony_ci *             machines and U3 (G5)
762306a36Sopenharmony_ci *
862306a36Sopenharmony_ci */
962306a36Sopenharmony_ci#ifdef __KERNEL__
1062306a36Sopenharmony_ci#ifndef __ASM_UNINORTH_H__
1162306a36Sopenharmony_ci#define __ASM_UNINORTH_H__
1262306a36Sopenharmony_ci
1362306a36Sopenharmony_ci/*
1462306a36Sopenharmony_ci * Uni-N and U3 config space reg. definitions
1562306a36Sopenharmony_ci *
1662306a36Sopenharmony_ci * (Little endian)
1762306a36Sopenharmony_ci */
1862306a36Sopenharmony_ci
1962306a36Sopenharmony_ci/* Address ranges selection. This one should work with Bandit too */
2062306a36Sopenharmony_ci/* Not U3 */
2162306a36Sopenharmony_ci#define UNI_N_ADDR_SELECT		0x48
2262306a36Sopenharmony_ci#define UNI_N_ADDR_COARSE_MASK		0xffff0000	/* 256Mb regions at *0000000 */
2362306a36Sopenharmony_ci#define UNI_N_ADDR_FINE_MASK		0x0000ffff	/*  16Mb regions at f*000000 */
2462306a36Sopenharmony_ci
2562306a36Sopenharmony_ci/* AGP registers */
2662306a36Sopenharmony_ci/* Not U3 */
2762306a36Sopenharmony_ci#define UNI_N_CFG_GART_BASE		0x8c
2862306a36Sopenharmony_ci#define UNI_N_CFG_AGP_BASE		0x90
2962306a36Sopenharmony_ci#define UNI_N_CFG_GART_CTRL		0x94
3062306a36Sopenharmony_ci#define UNI_N_CFG_INTERNAL_STATUS	0x98
3162306a36Sopenharmony_ci#define UNI_N_CFG_GART_DUMMY_PAGE	0xa4
3262306a36Sopenharmony_ci
3362306a36Sopenharmony_ci/* UNI_N_CFG_GART_CTRL bits definitions */
3462306a36Sopenharmony_ci#define UNI_N_CFG_GART_INVAL		0x00000001
3562306a36Sopenharmony_ci#define UNI_N_CFG_GART_ENABLE		0x00000100
3662306a36Sopenharmony_ci#define UNI_N_CFG_GART_2xRESET		0x00010000
3762306a36Sopenharmony_ci#define UNI_N_CFG_GART_DISSBADET	0x00020000
3862306a36Sopenharmony_ci/* The following seems to only be used only on U3 <j.glisse@gmail.com> */
3962306a36Sopenharmony_ci#define U3_N_CFG_GART_SYNCMODE		0x00040000
4062306a36Sopenharmony_ci#define U3_N_CFG_GART_PERFRD		0x00080000
4162306a36Sopenharmony_ci#define U3_N_CFG_GART_B2BGNT		0x00200000
4262306a36Sopenharmony_ci#define U3_N_CFG_GART_FASTDDR		0x00400000
4362306a36Sopenharmony_ci
4462306a36Sopenharmony_ci/* My understanding of UniNorth AGP as of UniNorth rev 1.0x,
4562306a36Sopenharmony_ci * revision 1.5 (x4 AGP) may need further changes.
4662306a36Sopenharmony_ci *
4762306a36Sopenharmony_ci * AGP_BASE register contains the base address of the AGP aperture on
4862306a36Sopenharmony_ci * the AGP bus. It doesn't seem to be visible to the CPU as of UniNorth 1.x,
4962306a36Sopenharmony_ci * even if decoding of this address range is enabled in the address select
5062306a36Sopenharmony_ci * register. Apparently, the only supported bases are 256Mb multiples
5162306a36Sopenharmony_ci * (high 4 bits of that register).
5262306a36Sopenharmony_ci *
5362306a36Sopenharmony_ci * GART_BASE register appear to contain the physical address of the GART
5462306a36Sopenharmony_ci * in system memory in the high address bits (page aligned), and the
5562306a36Sopenharmony_ci * GART size in the low order bits (number of GART pages)
5662306a36Sopenharmony_ci *
5762306a36Sopenharmony_ci * The GART format itself is one 32bits word per physical memory page.
5862306a36Sopenharmony_ci * This word contains, in little-endian format (!!!), the physical address
5962306a36Sopenharmony_ci * of the page in the high bits, and what appears to be an "enable" bit
6062306a36Sopenharmony_ci * in the LSB bit (0) that must be set to 1 when the entry is valid.
6162306a36Sopenharmony_ci *
6262306a36Sopenharmony_ci * Obviously, the GART is not cache coherent and so any change to it
6362306a36Sopenharmony_ci * must be flushed to memory (or maybe just make the GART space non
6462306a36Sopenharmony_ci * cachable). AGP memory itself doesn't seem to be cache coherent neither.
6562306a36Sopenharmony_ci *
6662306a36Sopenharmony_ci * In order to invalidate the GART (which is probably necessary to inval
6762306a36Sopenharmony_ci * the bridge internal TLBs), the following sequence has to be written,
6862306a36Sopenharmony_ci * in order, to the GART_CTRL register:
6962306a36Sopenharmony_ci *
7062306a36Sopenharmony_ci *   UNI_N_CFG_GART_ENABLE | UNI_N_CFG_GART_INVAL
7162306a36Sopenharmony_ci *   UNI_N_CFG_GART_ENABLE
7262306a36Sopenharmony_ci *   UNI_N_CFG_GART_ENABLE | UNI_N_CFG_GART_2xRESET
7362306a36Sopenharmony_ci *   UNI_N_CFG_GART_ENABLE
7462306a36Sopenharmony_ci *
7562306a36Sopenharmony_ci * As far as AGP "features" are concerned, it looks like fast write may
7662306a36Sopenharmony_ci * not be supported but this has to be confirmed.
7762306a36Sopenharmony_ci *
7862306a36Sopenharmony_ci * Turning on AGP seem to require a double invalidate operation, one before
7962306a36Sopenharmony_ci * setting the AGP command register, on after.
8062306a36Sopenharmony_ci *
8162306a36Sopenharmony_ci * Turning off AGP seems to require the following sequence: first wait
8262306a36Sopenharmony_ci * for the AGP to be idle by reading the internal status register, then
8362306a36Sopenharmony_ci * write in that order to the GART_CTRL register:
8462306a36Sopenharmony_ci *
8562306a36Sopenharmony_ci *   UNI_N_CFG_GART_ENABLE | UNI_N_CFG_GART_INVAL
8662306a36Sopenharmony_ci *   0
8762306a36Sopenharmony_ci *   UNI_N_CFG_GART_2xRESET
8862306a36Sopenharmony_ci *   0
8962306a36Sopenharmony_ci */
9062306a36Sopenharmony_ci
9162306a36Sopenharmony_ci/*
9262306a36Sopenharmony_ci * Uni-N memory mapped reg. definitions
9362306a36Sopenharmony_ci *
9462306a36Sopenharmony_ci * Those registers are Big-Endian !!
9562306a36Sopenharmony_ci *
9662306a36Sopenharmony_ci * Their meaning come from either Darwin and/or from experiments I made with
9762306a36Sopenharmony_ci * the bootrom, I'm not sure about their exact meaning yet
9862306a36Sopenharmony_ci *
9962306a36Sopenharmony_ci */
10062306a36Sopenharmony_ci
10162306a36Sopenharmony_ci/* Version of the UniNorth chip */
10262306a36Sopenharmony_ci#define UNI_N_VERSION			0x0000		/* Known versions: 3,7 and 8 */
10362306a36Sopenharmony_ci
10462306a36Sopenharmony_ci#define UNI_N_VERSION_107		0x0003		/* 1.0.7 */
10562306a36Sopenharmony_ci#define UNI_N_VERSION_10A		0x0007		/* 1.0.10 */
10662306a36Sopenharmony_ci#define UNI_N_VERSION_150		0x0011		/* 1.5 */
10762306a36Sopenharmony_ci#define UNI_N_VERSION_200		0x0024		/* 2.0 */
10862306a36Sopenharmony_ci#define UNI_N_VERSION_PANGEA		0x00C0		/* Integrated U1 + K */
10962306a36Sopenharmony_ci#define UNI_N_VERSION_INTREPID		0x00D2		/* Integrated U2 + K */
11062306a36Sopenharmony_ci#define UNI_N_VERSION_300		0x0030		/* 3.0 (U3 on G5) */
11162306a36Sopenharmony_ci
11262306a36Sopenharmony_ci/* This register is used to enable/disable various clocks */
11362306a36Sopenharmony_ci#define UNI_N_CLOCK_CNTL		0x0020
11462306a36Sopenharmony_ci#define UNI_N_CLOCK_CNTL_PCI		0x00000001	/* PCI2 clock control */
11562306a36Sopenharmony_ci#define UNI_N_CLOCK_CNTL_GMAC		0x00000002	/* GMAC clock control */
11662306a36Sopenharmony_ci#define UNI_N_CLOCK_CNTL_FW		0x00000004	/* FireWire clock control */
11762306a36Sopenharmony_ci#define UNI_N_CLOCK_CNTL_ATA100		0x00000010	/* ATA-100 clock control (U2) */
11862306a36Sopenharmony_ci
11962306a36Sopenharmony_ci/* Power Management control */
12062306a36Sopenharmony_ci#define UNI_N_POWER_MGT			0x0030
12162306a36Sopenharmony_ci#define UNI_N_POWER_MGT_NORMAL		0x00
12262306a36Sopenharmony_ci#define UNI_N_POWER_MGT_IDLE2		0x01
12362306a36Sopenharmony_ci#define UNI_N_POWER_MGT_SLEEP		0x02
12462306a36Sopenharmony_ci
12562306a36Sopenharmony_ci/* This register is configured by Darwin depending on the UniN
12662306a36Sopenharmony_ci * revision
12762306a36Sopenharmony_ci */
12862306a36Sopenharmony_ci#define UNI_N_ARB_CTRL			0x0040
12962306a36Sopenharmony_ci#define UNI_N_ARB_CTRL_QACK_DELAY_SHIFT	15
13062306a36Sopenharmony_ci#define UNI_N_ARB_CTRL_QACK_DELAY_MASK	0x0e1f8000
13162306a36Sopenharmony_ci#define UNI_N_ARB_CTRL_QACK_DELAY	0x30
13262306a36Sopenharmony_ci#define UNI_N_ARB_CTRL_QACK_DELAY105	0x00
13362306a36Sopenharmony_ci
13462306a36Sopenharmony_ci/* This one _might_ return the CPU number of the CPU reading it;
13562306a36Sopenharmony_ci * the bootROM decides whether to boot or to sleep/spinloop depending
13662306a36Sopenharmony_ci * on this register being 0 or not
13762306a36Sopenharmony_ci */
13862306a36Sopenharmony_ci#define UNI_N_CPU_NUMBER		0x0050
13962306a36Sopenharmony_ci
14062306a36Sopenharmony_ci/* This register appear to be read by the bootROM to decide what
14162306a36Sopenharmony_ci *  to do on a non-recoverable reset (powerup or wakeup)
14262306a36Sopenharmony_ci */
14362306a36Sopenharmony_ci#define UNI_N_HWINIT_STATE		0x0070
14462306a36Sopenharmony_ci#define UNI_N_HWINIT_STATE_SLEEPING	0x01
14562306a36Sopenharmony_ci#define UNI_N_HWINIT_STATE_RUNNING	0x02
14662306a36Sopenharmony_ci/* This last bit appear to be used by the bootROM to know the second
14762306a36Sopenharmony_ci * CPU has started and will enter it's sleep loop with IP=0
14862306a36Sopenharmony_ci */
14962306a36Sopenharmony_ci#define UNI_N_HWINIT_STATE_CPU1_FLAG	0x10000000
15062306a36Sopenharmony_ci
15162306a36Sopenharmony_ci/* This register controls AACK delay, which is set when 2004 iBook/PowerBook
15262306a36Sopenharmony_ci * is in low speed mode.
15362306a36Sopenharmony_ci */
15462306a36Sopenharmony_ci#define UNI_N_AACK_DELAY		0x0100
15562306a36Sopenharmony_ci#define UNI_N_AACK_DELAY_ENABLE		0x00000001
15662306a36Sopenharmony_ci
15762306a36Sopenharmony_ci/* Clock status for Intrepid */
15862306a36Sopenharmony_ci#define UNI_N_CLOCK_STOP_STATUS0	0x0150
15962306a36Sopenharmony_ci#define UNI_N_CLOCK_STOPPED_EXTAGP	0x00200000
16062306a36Sopenharmony_ci#define UNI_N_CLOCK_STOPPED_AGPDEL	0x00100000
16162306a36Sopenharmony_ci#define UNI_N_CLOCK_STOPPED_I2S0_45_49	0x00080000
16262306a36Sopenharmony_ci#define UNI_N_CLOCK_STOPPED_I2S0_18	0x00040000
16362306a36Sopenharmony_ci#define UNI_N_CLOCK_STOPPED_I2S1_45_49	0x00020000
16462306a36Sopenharmony_ci#define UNI_N_CLOCK_STOPPED_I2S1_18	0x00010000
16562306a36Sopenharmony_ci#define UNI_N_CLOCK_STOPPED_TIMER	0x00008000
16662306a36Sopenharmony_ci#define UNI_N_CLOCK_STOPPED_SCC_RTCLK18	0x00004000
16762306a36Sopenharmony_ci#define UNI_N_CLOCK_STOPPED_SCC_RTCLK32	0x00002000
16862306a36Sopenharmony_ci#define UNI_N_CLOCK_STOPPED_SCC_VIA32	0x00001000
16962306a36Sopenharmony_ci#define UNI_N_CLOCK_STOPPED_SCC_SLOT0	0x00000800
17062306a36Sopenharmony_ci#define UNI_N_CLOCK_STOPPED_SCC_SLOT1	0x00000400
17162306a36Sopenharmony_ci#define UNI_N_CLOCK_STOPPED_SCC_SLOT2	0x00000200
17262306a36Sopenharmony_ci#define UNI_N_CLOCK_STOPPED_PCI_FBCLKO	0x00000100
17362306a36Sopenharmony_ci#define UNI_N_CLOCK_STOPPED_VEO0	0x00000080
17462306a36Sopenharmony_ci#define UNI_N_CLOCK_STOPPED_VEO1	0x00000040
17562306a36Sopenharmony_ci#define UNI_N_CLOCK_STOPPED_USB0	0x00000020
17662306a36Sopenharmony_ci#define UNI_N_CLOCK_STOPPED_USB1	0x00000010
17762306a36Sopenharmony_ci#define UNI_N_CLOCK_STOPPED_USB2	0x00000008
17862306a36Sopenharmony_ci#define UNI_N_CLOCK_STOPPED_32		0x00000004
17962306a36Sopenharmony_ci#define UNI_N_CLOCK_STOPPED_45		0x00000002
18062306a36Sopenharmony_ci#define UNI_N_CLOCK_STOPPED_49		0x00000001
18162306a36Sopenharmony_ci
18262306a36Sopenharmony_ci#define UNI_N_CLOCK_STOP_STATUS1	0x0160
18362306a36Sopenharmony_ci#define UNI_N_CLOCK_STOPPED_PLL4REF	0x00080000
18462306a36Sopenharmony_ci#define UNI_N_CLOCK_STOPPED_CPUDEL	0x00040000
18562306a36Sopenharmony_ci#define UNI_N_CLOCK_STOPPED_CPU		0x00020000
18662306a36Sopenharmony_ci#define UNI_N_CLOCK_STOPPED_BUF_REFCKO	0x00010000
18762306a36Sopenharmony_ci#define UNI_N_CLOCK_STOPPED_PCI2	0x00008000
18862306a36Sopenharmony_ci#define UNI_N_CLOCK_STOPPED_FW		0x00004000
18962306a36Sopenharmony_ci#define UNI_N_CLOCK_STOPPED_GB		0x00002000
19062306a36Sopenharmony_ci#define UNI_N_CLOCK_STOPPED_ATA66	0x00001000
19162306a36Sopenharmony_ci#define UNI_N_CLOCK_STOPPED_ATA100	0x00000800
19262306a36Sopenharmony_ci#define UNI_N_CLOCK_STOPPED_MAX		0x00000400
19362306a36Sopenharmony_ci#define UNI_N_CLOCK_STOPPED_PCI1	0x00000200
19462306a36Sopenharmony_ci#define UNI_N_CLOCK_STOPPED_KLPCI	0x00000100
19562306a36Sopenharmony_ci#define UNI_N_CLOCK_STOPPED_USB0PCI	0x00000080
19662306a36Sopenharmony_ci#define UNI_N_CLOCK_STOPPED_USB1PCI	0x00000040
19762306a36Sopenharmony_ci#define UNI_N_CLOCK_STOPPED_USB2PCI	0x00000020
19862306a36Sopenharmony_ci#define UNI_N_CLOCK_STOPPED_7PCI1	0x00000008
19962306a36Sopenharmony_ci#define UNI_N_CLOCK_STOPPED_AGP		0x00000004
20062306a36Sopenharmony_ci#define UNI_N_CLOCK_STOPPED_PCI0	0x00000002
20162306a36Sopenharmony_ci#define UNI_N_CLOCK_STOPPED_18		0x00000001
20262306a36Sopenharmony_ci
20362306a36Sopenharmony_ci/* Intrepid registe to OF do-platform-clockspreading */
20462306a36Sopenharmony_ci#define UNI_N_CLOCK_SPREADING		0x190
20562306a36Sopenharmony_ci
20662306a36Sopenharmony_ci/* Uninorth 1.5 rev. has additional perf. monitor registers at 0xf00-0xf50 */
20762306a36Sopenharmony_ci
20862306a36Sopenharmony_ci
20962306a36Sopenharmony_ci/*
21062306a36Sopenharmony_ci * U3 specific registers
21162306a36Sopenharmony_ci */
21262306a36Sopenharmony_ci
21362306a36Sopenharmony_ci
21462306a36Sopenharmony_ci/* U3 Toggle */
21562306a36Sopenharmony_ci#define U3_TOGGLE_REG			0x00e0
21662306a36Sopenharmony_ci#define U3_PMC_START_STOP		0x0001
21762306a36Sopenharmony_ci#define U3_MPIC_RESET			0x0002
21862306a36Sopenharmony_ci#define U3_MPIC_OUTPUT_ENABLE		0x0004
21962306a36Sopenharmony_ci
22062306a36Sopenharmony_ci/* U3 API PHY Config 1 */
22162306a36Sopenharmony_ci#define U3_API_PHY_CONFIG_1		0x23030
22262306a36Sopenharmony_ci
22362306a36Sopenharmony_ci/* U3 HyperTransport registers */
22462306a36Sopenharmony_ci#define U3_HT_CONFIG_BASE      		0x70000
22562306a36Sopenharmony_ci#define U3_HT_LINK_COMMAND		0x100
22662306a36Sopenharmony_ci#define U3_HT_LINK_CONFIG		0x110
22762306a36Sopenharmony_ci#define U3_HT_LINK_FREQ			0x120
22862306a36Sopenharmony_ci
22962306a36Sopenharmony_ci#endif /* __ASM_UNINORTH_H__ */
23062306a36Sopenharmony_ci#endif /* __KERNEL__ */
231