xref: /linux/arch/powerpc/sysdev/grackle.c (revision 2e56ff206b7c6c28b847ccdbe46ad69b3263ac32)
1830825d6SPaul Mackerras /*
2830825d6SPaul Mackerras  * Functions for setting up and using a MPC106 northbridge
3830825d6SPaul Mackerras  * Extracted from arch/powerpc/platforms/powermac/pci.c.
4830825d6SPaul Mackerras  *
5830825d6SPaul Mackerras  * Copyright (C) 2003 Benjamin Herrenschmuidt (benh@kernel.crashing.org)
6830825d6SPaul Mackerras  * Copyright (C) 1997 Paul Mackerras (paulus@samba.org)
7830825d6SPaul Mackerras  *
8830825d6SPaul Mackerras  * This program is free software; you can redistribute it and/or
9830825d6SPaul Mackerras  * modify it under the terms of the GNU General Public License
10830825d6SPaul Mackerras  * as published by the Free Software Foundation; either version
11830825d6SPaul Mackerras  * 2 of the License, or (at your option) any later version.
12830825d6SPaul Mackerras  */
13830825d6SPaul Mackerras #include <linux/kernel.h>
14830825d6SPaul Mackerras #include <linux/pci.h>
15830825d6SPaul Mackerras #include <linux/init.h>
16830825d6SPaul Mackerras 
17830825d6SPaul Mackerras #include <asm/io.h>
18830825d6SPaul Mackerras #include <asm/prom.h>
19830825d6SPaul Mackerras #include <asm/pci-bridge.h>
20830825d6SPaul Mackerras #include <asm/grackle.h>
21830825d6SPaul Mackerras 
22830825d6SPaul Mackerras #define GRACKLE_CFA(b, d, o)	(0x80 | ((b) << 8) | ((d) << 16) \
23830825d6SPaul Mackerras 				 | (((o) & ~3) << 24))
24830825d6SPaul Mackerras 
25830825d6SPaul Mackerras #define GRACKLE_PICR1_STG		0x00000040
26830825d6SPaul Mackerras #define GRACKLE_PICR1_LOOPSNOOP		0x00000010
27830825d6SPaul Mackerras 
28830825d6SPaul Mackerras /* N.B. this is called before bridges is initialized, so we can't
29830825d6SPaul Mackerras    use grackle_pcibios_{read,write}_config_dword. */
30830825d6SPaul Mackerras static inline void grackle_set_stg(struct pci_controller* bp, int enable)
31830825d6SPaul Mackerras {
32830825d6SPaul Mackerras 	unsigned int val;
33830825d6SPaul Mackerras 
34830825d6SPaul Mackerras 	out_be32(bp->cfg_addr, GRACKLE_CFA(0, 0, 0xa8));
35830825d6SPaul Mackerras 	val = in_le32(bp->cfg_data);
36830825d6SPaul Mackerras 	val = enable? (val | GRACKLE_PICR1_STG) :
37830825d6SPaul Mackerras 		(val & ~GRACKLE_PICR1_STG);
38830825d6SPaul Mackerras 	out_be32(bp->cfg_addr, GRACKLE_CFA(0, 0, 0xa8));
39830825d6SPaul Mackerras 	out_le32(bp->cfg_data, val);
40830825d6SPaul Mackerras 	(void)in_le32(bp->cfg_data);
41830825d6SPaul Mackerras }
42830825d6SPaul Mackerras 
43830825d6SPaul Mackerras static inline void grackle_set_loop_snoop(struct pci_controller *bp, int enable)
44830825d6SPaul Mackerras {
45830825d6SPaul Mackerras 	unsigned int val;
46830825d6SPaul Mackerras 
47830825d6SPaul Mackerras 	out_be32(bp->cfg_addr, GRACKLE_CFA(0, 0, 0xa8));
48830825d6SPaul Mackerras 	val = in_le32(bp->cfg_data);
49830825d6SPaul Mackerras 	val = enable? (val | GRACKLE_PICR1_LOOPSNOOP) :
50830825d6SPaul Mackerras 		(val & ~GRACKLE_PICR1_LOOPSNOOP);
51830825d6SPaul Mackerras 	out_be32(bp->cfg_addr, GRACKLE_CFA(0, 0, 0xa8));
52830825d6SPaul Mackerras 	out_le32(bp->cfg_data, val);
53830825d6SPaul Mackerras 	(void)in_le32(bp->cfg_data);
54830825d6SPaul Mackerras }
55830825d6SPaul Mackerras 
56830825d6SPaul Mackerras void __init setup_grackle(struct pci_controller *hose)
57830825d6SPaul Mackerras {
58*2e56ff20SKumar Gala 	setup_indirect_pci(hose, 0xfec00000, 0xfee00000, 0);
59a1fdf694SPavel Roskin 	if (machine_is_compatible("PowerMac1,1"))
60a1fdf694SPavel Roskin 		pci_assign_all_buses = 1;
61830825d6SPaul Mackerras 	if (machine_is_compatible("AAPL,PowerBook1998"))
62830825d6SPaul Mackerras 		grackle_set_loop_snoop(hose, 1);
63830825d6SPaul Mackerras #if 0	/* Disabled for now, HW problems ??? */
64830825d6SPaul Mackerras 	grackle_set_stg(hose, 1);
65830825d6SPaul Mackerras #endif
66830825d6SPaul Mackerras }
67