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
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  3)  * linux/arch/arm/mach-footbridge/cats-pci.c
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  4)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  5)  * PCI bios-type initialisation for PCI machines
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  6)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  7)  * Bits taken from various places.
^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/irq.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) #include <asm/mach/pci.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) #include <asm/mach-types.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) /* cats host-specific stuff */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) static int irqmap_cats[] = { IRQ_PCI, IRQ_IN0, IRQ_IN1, IRQ_IN3 };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) static u8 cats_no_swizzle(struct pci_dev *dev, u8 *pin)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) static int cats_map_irq(const struct pci_dev *dev, u8 slot, u8 pin)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) 	if (dev->irq >= 255)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) 		return -1;	/* not a valid interrupt. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) 	if (dev->irq >= 128)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) 		return dev->irq & 0x1f;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) 	if (dev->irq >= 1 && dev->irq <= 4)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) 		return irqmap_cats[dev->irq - 1];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) 	if (dev->irq != 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) 		printk("PCI: device %02x:%02x has unknown irq line %x\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) 		       dev->bus->number, dev->devfn, dev->irq);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) 	return -1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44)  * why not the standard PCI swizzle?  does this prevent 4-port tulip
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45)  * cards being used (ie, pci-pci bridge based cards)?
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) static struct hw_pci cats_pci __initdata = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) 	.swizzle		= cats_no_swizzle,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) 	.map_irq		= cats_map_irq,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) 	.nr_controllers		= 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) 	.ops			= &dc21285_ops,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) 	.setup			= dc21285_setup,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) 	.preinit		= dc21285_preinit,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) 	.postinit		= dc21285_postinit,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) static int __init cats_pci_init(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) 	if (machine_is_cats())
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) 		pci_common_init(&cats_pci);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) subsys_initcall(cats_pci_init);