1*830825d6SPaul Mackerras /* 2*830825d6SPaul Mackerras * Functions for setting up and using a MPC106 northbridge 3*830825d6SPaul Mackerras * Extracted from arch/powerpc/platforms/powermac/pci.c. 4*830825d6SPaul Mackerras * 5*830825d6SPaul Mackerras * Copyright (C) 2003 Benjamin Herrenschmuidt (benh@kernel.crashing.org) 6*830825d6SPaul Mackerras * Copyright (C) 1997 Paul Mackerras (paulus@samba.org) 7*830825d6SPaul Mackerras * 8*830825d6SPaul Mackerras * This program is free software; you can redistribute it and/or 9*830825d6SPaul Mackerras * modify it under the terms of the GNU General Public License 10*830825d6SPaul Mackerras * as published by the Free Software Foundation; either version 11*830825d6SPaul Mackerras * 2 of the License, or (at your option) any later version. 12*830825d6SPaul Mackerras */ 13*830825d6SPaul Mackerras #include <linux/kernel.h> 14*830825d6SPaul Mackerras #include <linux/pci.h> 15*830825d6SPaul Mackerras #include <linux/init.h> 16*830825d6SPaul Mackerras 17*830825d6SPaul Mackerras #include <asm/io.h> 18*830825d6SPaul Mackerras #include <asm/prom.h> 19*830825d6SPaul Mackerras #include <asm/pci-bridge.h> 20*830825d6SPaul Mackerras #include <asm/grackle.h> 21*830825d6SPaul Mackerras 22*830825d6SPaul Mackerras #define GRACKLE_CFA(b, d, o) (0x80 | ((b) << 8) | ((d) << 16) \ 23*830825d6SPaul Mackerras | (((o) & ~3) << 24)) 24*830825d6SPaul Mackerras 25*830825d6SPaul Mackerras #define GRACKLE_PICR1_STG 0x00000040 26*830825d6SPaul Mackerras #define GRACKLE_PICR1_LOOPSNOOP 0x00000010 27*830825d6SPaul Mackerras 28*830825d6SPaul Mackerras /* N.B. this is called before bridges is initialized, so we can't 29*830825d6SPaul Mackerras use grackle_pcibios_{read,write}_config_dword. */ 30*830825d6SPaul Mackerras static inline void grackle_set_stg(struct pci_controller* bp, int enable) 31*830825d6SPaul Mackerras { 32*830825d6SPaul Mackerras unsigned int val; 33*830825d6SPaul Mackerras 34*830825d6SPaul Mackerras out_be32(bp->cfg_addr, GRACKLE_CFA(0, 0, 0xa8)); 35*830825d6SPaul Mackerras val = in_le32(bp->cfg_data); 36*830825d6SPaul Mackerras val = enable? (val | GRACKLE_PICR1_STG) : 37*830825d6SPaul Mackerras (val & ~GRACKLE_PICR1_STG); 38*830825d6SPaul Mackerras out_be32(bp->cfg_addr, GRACKLE_CFA(0, 0, 0xa8)); 39*830825d6SPaul Mackerras out_le32(bp->cfg_data, val); 40*830825d6SPaul Mackerras (void)in_le32(bp->cfg_data); 41*830825d6SPaul Mackerras } 42*830825d6SPaul Mackerras 43*830825d6SPaul Mackerras static inline void grackle_set_loop_snoop(struct pci_controller *bp, int enable) 44*830825d6SPaul Mackerras { 45*830825d6SPaul Mackerras unsigned int val; 46*830825d6SPaul Mackerras 47*830825d6SPaul Mackerras out_be32(bp->cfg_addr, GRACKLE_CFA(0, 0, 0xa8)); 48*830825d6SPaul Mackerras val = in_le32(bp->cfg_data); 49*830825d6SPaul Mackerras val = enable? (val | GRACKLE_PICR1_LOOPSNOOP) : 50*830825d6SPaul Mackerras (val & ~GRACKLE_PICR1_LOOPSNOOP); 51*830825d6SPaul Mackerras out_be32(bp->cfg_addr, GRACKLE_CFA(0, 0, 0xa8)); 52*830825d6SPaul Mackerras out_le32(bp->cfg_data, val); 53*830825d6SPaul Mackerras (void)in_le32(bp->cfg_data); 54*830825d6SPaul Mackerras } 55*830825d6SPaul Mackerras 56*830825d6SPaul Mackerras void __init setup_grackle(struct pci_controller *hose) 57*830825d6SPaul Mackerras { 58*830825d6SPaul Mackerras setup_indirect_pci(hose, 0xfec00000, 0xfee00000); 59*830825d6SPaul Mackerras if (machine_is_compatible("AAPL,PowerBook1998")) 60*830825d6SPaul Mackerras grackle_set_loop_snoop(hose, 1); 61*830825d6SPaul Mackerras #if 0 /* Disabled for now, HW problems ??? */ 62*830825d6SPaul Mackerras grackle_set_stg(hose, 1); 63*830825d6SPaul Mackerras #endif 64*830825d6SPaul Mackerras } 65