Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  1) // SPDX-License-Identifier: GPL-2.0-or-later
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  3)  * Functions for setting up and using a MPC106 northbridge
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  4)  * Extracted from arch/powerpc/platforms/powermac/pci.c.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  5)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  6)  * Copyright (C) 2003 Benjamin Herrenschmuidt (benh@kernel.crashing.org)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  7)  * Copyright (C) 1997 Paul Mackerras (paulus@samba.org)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  8)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  9) #include <linux/kernel.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) #include <linux/pci.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) #include <linux/init.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) #include <asm/io.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) #include <asm/prom.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) #include <asm/pci-bridge.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) #include <asm/grackle.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) #define GRACKLE_CFA(b, d, o)	(0x80 | ((b) << 8) | ((d) << 16) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) 				 | (((o) & ~3) << 24))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) #define GRACKLE_PICR1_STG		0x00000040
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) #define GRACKLE_PICR1_LOOPSNOOP		0x00000010
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) /* N.B. this is called before bridges is initialized, so we can't
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25)    use grackle_pcibios_{read,write}_config_dword. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) static inline void grackle_set_stg(struct pci_controller* bp, int enable)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) 	unsigned int val;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) 	out_be32(bp->cfg_addr, GRACKLE_CFA(0, 0, 0xa8));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) 	val = in_le32(bp->cfg_data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) 	val = enable? (val | GRACKLE_PICR1_STG) :
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) 		(val & ~GRACKLE_PICR1_STG);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) 	out_be32(bp->cfg_addr, GRACKLE_CFA(0, 0, 0xa8));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) 	out_le32(bp->cfg_data, val);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) 	(void)in_le32(bp->cfg_data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) static inline void grackle_set_loop_snoop(struct pci_controller *bp, int enable)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) 	unsigned int val;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) 	out_be32(bp->cfg_addr, GRACKLE_CFA(0, 0, 0xa8));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) 	val = in_le32(bp->cfg_data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) 	val = enable? (val | GRACKLE_PICR1_LOOPSNOOP) :
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) 		(val & ~GRACKLE_PICR1_LOOPSNOOP);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) 	out_be32(bp->cfg_addr, GRACKLE_CFA(0, 0, 0xa8));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) 	out_le32(bp->cfg_data, val);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) 	(void)in_le32(bp->cfg_data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) void __init setup_grackle(struct pci_controller *hose)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) 	setup_indirect_pci(hose, 0xfec00000, 0xfee00000, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) 	if (of_machine_is_compatible("PowerMac1,1"))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) 		pci_add_flags(PCI_REASSIGN_ALL_BUS);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) 	if (of_machine_is_compatible("AAPL,PowerBook1998"))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) 		grackle_set_loop_snoop(hose, 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) #if 0	/* Disabled for now, HW problems ??? */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) 	grackle_set_stg(hose, 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) }