xref: /linux/arch/powerpc/sysdev/grackle.c (revision 06d07429858317ded2db7986113a9e0129cd599b)
12874c5fdSThomas Gleixner // SPDX-License-Identifier: GPL-2.0-or-later
2830825d6SPaul Mackerras /*
3830825d6SPaul Mackerras  * Functions for setting up and using a MPC106 northbridge
4830825d6SPaul Mackerras  * Extracted from arch/powerpc/platforms/powermac/pci.c.
5830825d6SPaul Mackerras  *
6830825d6SPaul Mackerras  * Copyright (C) 2003 Benjamin Herrenschmuidt (benh@kernel.crashing.org)
7830825d6SPaul Mackerras  * Copyright (C) 1997 Paul Mackerras (paulus@samba.org)
8830825d6SPaul Mackerras  */
9830825d6SPaul Mackerras #include <linux/kernel.h>
10830825d6SPaul Mackerras #include <linux/pci.h>
11830825d6SPaul Mackerras #include <linux/init.h>
12*e6f6390aSChristophe Leroy #include <linux/of.h>
13830825d6SPaul Mackerras 
14830825d6SPaul Mackerras #include <asm/io.h>
15830825d6SPaul Mackerras #include <asm/pci-bridge.h>
16830825d6SPaul Mackerras #include <asm/grackle.h>
17830825d6SPaul Mackerras 
18830825d6SPaul Mackerras #define GRACKLE_CFA(b, d, o)	(0x80 | ((b) << 8) | ((d) << 16) \
19830825d6SPaul Mackerras 				 | (((o) & ~3) << 24))
20830825d6SPaul Mackerras 
21830825d6SPaul Mackerras #define GRACKLE_PICR1_LOOPSNOOP		0x00000010
22830825d6SPaul Mackerras 
grackle_set_loop_snoop(struct pci_controller * bp,int enable)23830825d6SPaul Mackerras static inline void grackle_set_loop_snoop(struct pci_controller *bp, int enable)
24830825d6SPaul Mackerras {
25830825d6SPaul Mackerras 	unsigned int val;
26830825d6SPaul Mackerras 
27830825d6SPaul Mackerras 	out_be32(bp->cfg_addr, GRACKLE_CFA(0, 0, 0xa8));
28830825d6SPaul Mackerras 	val = in_le32(bp->cfg_data);
29830825d6SPaul Mackerras 	val = enable? (val | GRACKLE_PICR1_LOOPSNOOP) :
30830825d6SPaul Mackerras 		(val & ~GRACKLE_PICR1_LOOPSNOOP);
31830825d6SPaul Mackerras 	out_be32(bp->cfg_addr, GRACKLE_CFA(0, 0, 0xa8));
32830825d6SPaul Mackerras 	out_le32(bp->cfg_data, val);
33830825d6SPaul Mackerras 	(void)in_le32(bp->cfg_data);
34830825d6SPaul Mackerras }
35830825d6SPaul Mackerras 
setup_grackle(struct pci_controller * hose)36830825d6SPaul Mackerras void __init setup_grackle(struct pci_controller *hose)
37830825d6SPaul Mackerras {
382e56ff20SKumar Gala 	setup_indirect_pci(hose, 0xfec00000, 0xfee00000, 0);
3971a157e8SGrant Likely 	if (of_machine_is_compatible("PowerMac1,1"))
400e47ff1cSRob Herring 		pci_add_flags(PCI_REASSIGN_ALL_BUS);
4171a157e8SGrant Likely 	if (of_machine_is_compatible("AAPL,PowerBook1998"))
42830825d6SPaul Mackerras 		grackle_set_loop_snoop(hose, 1);
43830825d6SPaul Mackerras }
44