Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: GPL-2.0-or-later
0002 /*
0003  * Functions for setting up and using a MPC106 northbridge
0004  * Extracted from arch/powerpc/platforms/powermac/pci.c.
0005  *
0006  * Copyright (C) 2003 Benjamin Herrenschmuidt (benh@kernel.crashing.org)
0007  * Copyright (C) 1997 Paul Mackerras (paulus@samba.org)
0008  */
0009 #include <linux/kernel.h>
0010 #include <linux/pci.h>
0011 #include <linux/init.h>
0012 #include <linux/of.h>
0013 
0014 #include <asm/io.h>
0015 #include <asm/pci-bridge.h>
0016 #include <asm/grackle.h>
0017 
0018 #define GRACKLE_CFA(b, d, o)    (0x80 | ((b) << 8) | ((d) << 16) \
0019                  | (((o) & ~3) << 24))
0020 
0021 #define GRACKLE_PICR1_STG       0x00000040
0022 #define GRACKLE_PICR1_LOOPSNOOP     0x00000010
0023 
0024 /* N.B. this is called before bridges is initialized, so we can't
0025    use grackle_pcibios_{read,write}_config_dword. */
0026 static inline void grackle_set_stg(struct pci_controller* bp, int enable)
0027 {
0028     unsigned int val;
0029 
0030     out_be32(bp->cfg_addr, GRACKLE_CFA(0, 0, 0xa8));
0031     val = in_le32(bp->cfg_data);
0032     val = enable? (val | GRACKLE_PICR1_STG) :
0033         (val & ~GRACKLE_PICR1_STG);
0034     out_be32(bp->cfg_addr, GRACKLE_CFA(0, 0, 0xa8));
0035     out_le32(bp->cfg_data, val);
0036     (void)in_le32(bp->cfg_data);
0037 }
0038 
0039 static inline void grackle_set_loop_snoop(struct pci_controller *bp, int enable)
0040 {
0041     unsigned int val;
0042 
0043     out_be32(bp->cfg_addr, GRACKLE_CFA(0, 0, 0xa8));
0044     val = in_le32(bp->cfg_data);
0045     val = enable? (val | GRACKLE_PICR1_LOOPSNOOP) :
0046         (val & ~GRACKLE_PICR1_LOOPSNOOP);
0047     out_be32(bp->cfg_addr, GRACKLE_CFA(0, 0, 0xa8));
0048     out_le32(bp->cfg_data, val);
0049     (void)in_le32(bp->cfg_data);
0050 }
0051 
0052 void __init setup_grackle(struct pci_controller *hose)
0053 {
0054     setup_indirect_pci(hose, 0xfec00000, 0xfee00000, 0);
0055     if (of_machine_is_compatible("PowerMac1,1"))
0056         pci_add_flags(PCI_REASSIGN_ALL_BUS);
0057     if (of_machine_is_compatible("AAPL,PowerBook1998"))
0058         grackle_set_loop_snoop(hose, 1);
0059 #if 0   /* Disabled for now, HW problems ??? */
0060     grackle_set_stg(hose, 1);
0061 #endif
0062 }