Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

powerpc/64: Remove maple platform

The maple platform was added in 2004 [1], to support the "Maple" 970FX
evaluation board.

It was later used for IBM JS20/JS21 machines, as well as the Bimini
machine, aka "Yellow Dog Powerstation".

Sadly all those machines have passed into memory, and there's been no
evidence for years that anyone is still using any of them.

Remove the platform and related code. It can always be reinstated if
there's interest.

Note that this has no impact on support for 970FX based Power Macs.

[1]: https://git.kernel.org/pub/scm/linux/kernel/git/mpe/linux-fullhistory.git/commit/?id=f0d068d65c5e555ffcfbc189de32598f6f00770c

Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://patch.msgid.link/20241013102957.548291-1-mpe@ellerman.id.au

+8 -1488
+2 -2
Documentation/arch/powerpc/booting.rst
··· 93 93 should: 94 94 95 95 a) add your platform support as a _boolean_ option in 96 - arch/powerpc/Kconfig, following the example of PPC_PSERIES, 97 - PPC_PMAC and PPC_MAPLE. The latter is probably a good 96 + arch/powerpc/Kconfig, following the example of PPC_PSERIES 97 + and PPC_PMAC. The latter is probably a good 98 98 example of a board support to start from. 99 99 100 100 b) create your main platform file as
-6
arch/powerpc/Kconfig.debug
··· 223 223 help 224 224 Select this to enable early debugging via the RTAS console. 225 225 226 - config PPC_EARLY_DEBUG_MAPLE 227 - bool "Maple real mode" 228 - depends on PPC_MAPLE 229 - help 230 - Select this to enable early debugging for Maple. 231 - 232 226 config PPC_EARLY_DEBUG_PAS_REALMODE 233 227 bool "PA Semi real mode" 234 228 depends on PPC_PASEMI
-1
arch/powerpc/boot/.gitignore
··· 30 30 zImage.epapr 31 31 zImage.holly 32 32 zImage.*lds 33 - zImage.maple 34 33 zImage.miboot 35 34 zImage.pmac 36 35 zImage.pseries
+1 -2
arch/powerpc/boot/Makefile
··· 276 276 277 277 image-$(CONFIG_PPC_PSERIES) += zImage.pseries 278 278 image-$(CONFIG_PPC_POWERNV) += zImage.pseries 279 - image-$(CONFIG_PPC_MAPLE) += zImage.maple 280 279 image-$(CONFIG_PPC_IBM_CELL_BLADE) += zImage.pseries 281 280 image-$(CONFIG_PPC_PS3) += dtbImage.ps3 282 281 image-$(CONFIG_PPC_CHRP) += zImage.chrp ··· 443 444 clean-files += $(image-) $(initrd-) cuImage.* dtbImage.* treeImage.* \ 444 445 zImage zImage.initrd zImage.chrp zImage.coff zImage.holly \ 445 446 zImage.miboot zImage.pmac zImage.pseries \ 446 - zImage.maple simpleImage.* otheros.bld 447 + simpleImage.* otheros.bld 447 448 448 449 # clean up files cached by wrapper 449 450 clean-kernel-base := vmlinux.strip vmlinux.bin
+1 -6
arch/powerpc/boot/wrapper
··· 271 271 fi 272 272 make_space=n 273 273 ;; 274 - maple) 275 - platformo="$object/of.o $object/epapr.o" 276 - link_address='0x400000' 277 - make_space=n 278 - ;; 279 274 pmac|chrp) 280 275 platformo="$object/of.o $object/epapr.o" 281 276 make_space=n ··· 512 517 513 518 # post-processing needed for some platforms 514 519 case "$platform" in 515 - pseries|chrp|maple) 520 + pseries|chrp) 516 521 $objbin/addnote "$ofile" 517 522 ;; 518 523 coff)
-111
arch/powerpc/configs/maple_defconfig
··· 1 - CONFIG_PPC64=y 2 - CONFIG_SMP=y 3 - CONFIG_NR_CPUS=4 4 - CONFIG_SYSVIPC=y 5 - CONFIG_POSIX_MQUEUE=y 6 - CONFIG_NO_HZ=y 7 - CONFIG_HIGH_RES_TIMERS=y 8 - CONFIG_IKCONFIG=y 9 - CONFIG_IKCONFIG_PROC=y 10 - # CONFIG_COMPAT_BRK is not set 11 - CONFIG_PROFILING=y 12 - CONFIG_KPROBES=y 13 - CONFIG_MODULES=y 14 - CONFIG_MODULE_UNLOAD=y 15 - CONFIG_MODVERSIONS=y 16 - CONFIG_MODULE_SRCVERSION_ALL=y 17 - # CONFIG_BLK_DEV_BSG is not set 18 - CONFIG_PARTITION_ADVANCED=y 19 - CONFIG_MAC_PARTITION=y 20 - # CONFIG_PPC_POWERNV is not set 21 - # CONFIG_PPC_PSERIES is not set 22 - # CONFIG_PPC_PMAC is not set 23 - CONFIG_PPC_MAPLE=y 24 - CONFIG_UDBG_RTAS_CONSOLE=y 25 - CONFIG_GEN_RTC=y 26 - CONFIG_KEXEC=y 27 - CONFIG_IRQ_ALL_CPUS=y 28 - CONFIG_PPC_4K_PAGES=y 29 - CONFIG_PCI_MSI=y 30 - CONFIG_NET=y 31 - CONFIG_PACKET=y 32 - CONFIG_UNIX=y 33 - CONFIG_XFRM_USER=m 34 - CONFIG_INET=y 35 - CONFIG_IP_MULTICAST=y 36 - CONFIG_IP_PNP=y 37 - CONFIG_IP_PNP_DHCP=y 38 - # CONFIG_IPV6 is not set 39 - CONFIG_BLK_DEV_RAM=y 40 - CONFIG_BLK_DEV_RAM_SIZE=8192 41 - # CONFIG_SCSI_PROC_FS is not set 42 - CONFIG_BLK_DEV_SD=y 43 - CONFIG_BLK_DEV_SR=y 44 - CONFIG_CHR_DEV_SG=y 45 - CONFIG_SCSI_IPR=y 46 - CONFIG_ATA=y 47 - CONFIG_PATA_AMD=y 48 - CONFIG_ATA_GENERIC=y 49 - CONFIG_NETDEVICES=y 50 - CONFIG_AMD8111_ETH=y 51 - CONFIG_TIGON3=y 52 - CONFIG_E1000=y 53 - CONFIG_USB_PEGASUS=y 54 - # CONFIG_INPUT_KEYBOARD is not set 55 - # CONFIG_INPUT_MOUSE is not set 56 - # CONFIG_SERIO is not set 57 - CONFIG_SERIAL_8250=y 58 - CONFIG_SERIAL_8250_CONSOLE=y 59 - CONFIG_HVC_RTAS=y 60 - # CONFIG_HW_RANDOM is not set 61 - CONFIG_I2C=y 62 - CONFIG_I2C_CHARDEV=y 63 - CONFIG_I2C_AMD8111=y 64 - # CONFIG_VGA_CONSOLE is not set 65 - CONFIG_HID_GYRATION=y 66 - CONFIG_HID_PANTHERLORD=y 67 - CONFIG_HID_PETALYNX=y 68 - CONFIG_HID_SAMSUNG=y 69 - CONFIG_HID_SUNPLUS=y 70 - CONFIG_USB=y 71 - CONFIG_USB_MON=y 72 - CONFIG_USB_EHCI_HCD=y 73 - CONFIG_USB_EHCI_ROOT_HUB_TT=y 74 - # CONFIG_USB_EHCI_HCD_PPC_OF is not set 75 - CONFIG_USB_OHCI_HCD=y 76 - CONFIG_USB_UHCI_HCD=y 77 - CONFIG_USB_SERIAL=y 78 - CONFIG_USB_SERIAL_GENERIC=y 79 - CONFIG_USB_SERIAL_CYPRESS_M8=m 80 - CONFIG_USB_SERIAL_GARMIN=m 81 - CONFIG_USB_SERIAL_IPW=m 82 - CONFIG_USB_SERIAL_KEYSPAN=y 83 - CONFIG_USB_SERIAL_TI=m 84 - CONFIG_EXT2_FS=y 85 - CONFIG_EXT4_FS=y 86 - CONFIG_FS_DAX=y 87 - CONFIG_MSDOS_FS=y 88 - CONFIG_VFAT_FS=y 89 - CONFIG_PROC_KCORE=y 90 - CONFIG_TMPFS=y 91 - CONFIG_HUGETLBFS=y 92 - CONFIG_CRAMFS=y 93 - CONFIG_NFS_FS=y 94 - CONFIG_NFS_V3_ACL=y 95 - CONFIG_NFS_V4=y 96 - CONFIG_ROOT_NFS=y 97 - CONFIG_NLS_DEFAULT="utf-8" 98 - CONFIG_NLS_UTF8=y 99 - CONFIG_CRC_CCITT=y 100 - CONFIG_CRC_T10DIF=y 101 - CONFIG_MAGIC_SYSRQ=y 102 - CONFIG_DEBUG_KERNEL=y 103 - CONFIG_DEBUG_STACK_USAGE=y 104 - CONFIG_DEBUG_STACKOVERFLOW=y 105 - CONFIG_XMON=y 106 - CONFIG_XMON_DEFAULT=y 107 - CONFIG_BOOTX_TEXT=y 108 - CONFIG_CRYPTO_ECB=m 109 - CONFIG_CRYPTO_PCBC=m 110 - # CONFIG_CRYPTO_HW is not set 111 - CONFIG_PRINTK_TIME=y
-1
arch/powerpc/configs/ppc64_defconfig
··· 44 44 CONFIG_IBMEBUS=y 45 45 CONFIG_PAPR_SCM=m 46 46 CONFIG_PPC_SVM=y 47 - CONFIG_PPC_MAPLE=y 48 47 CONFIG_PPC_PASEMI=y 49 48 CONFIG_PPC_PASEMI_IOMMU=y 50 49 CONFIG_PPC_PS3=y
-1
arch/powerpc/include/asm/udbg.h
··· 38 38 void __init udbg_init_debug_lpar(void); 39 39 void __init udbg_init_debug_lpar_hvsi(void); 40 40 void __init udbg_init_pmac_realmode(void); 41 - void __init udbg_init_maple_realmode(void); 42 41 void __init udbg_init_pas_realmode(void); 43 42 void __init udbg_init_rtas_panel(void); 44 43 void __init udbg_init_rtas_console(void);
+4 -4
arch/powerpc/kernel/misc_64.S
··· 74 74 blr 75 75 #endif /* CONFIG_PPC_EARLY_DEBUG_BOOTX */ 76 76 77 - #if defined(CONFIG_PPC_PMAC) || defined(CONFIG_PPC_MAPLE) 77 + #ifdef CONFIG_PPC_PMAC 78 78 79 79 /* 80 80 * Do an IO access in real mode ··· 137 137 sync 138 138 isync 139 139 blr 140 - #endif /* defined(CONFIG_PPC_PMAC) || defined(CONFIG_PPC_MAPLE) */ 140 + #endif // CONFIG_PPC_PMAC 141 141 142 142 #ifdef CONFIG_PPC_PASEMI 143 143 ··· 174 174 #endif /* CONFIG_PPC_PASEMI */ 175 175 176 176 177 - #if defined(CONFIG_CPU_FREQ_PMAC64) || defined(CONFIG_CPU_FREQ_MAPLE) 177 + #ifdef CONFIG_CPU_FREQ_PMAC64 178 178 /* 179 179 * SCOM access functions for 970 (FX only for now) 180 180 * ··· 243 243 /* restore interrupts */ 244 244 mtmsrd r5,1 245 245 blr 246 - #endif /* CONFIG_CPU_FREQ_PMAC64 || CONFIG_CPU_FREQ_MAPLE */ 246 + #endif // CONFIG_CPU_FREQ_PMAC64 247 247 248 248 /* kexec_wait(phys_cpu) 249 249 *
-86
arch/powerpc/kernel/prom_init.c
··· 2792 2792 dt_struct_start, dt_struct_end); 2793 2793 } 2794 2794 2795 - #ifdef CONFIG_PPC_MAPLE 2796 - /* PIBS Version 1.05.0000 04/26/2005 has an incorrect /ht/isa/ranges property. 2797 - * The values are bad, and it doesn't even have the right number of cells. */ 2798 - static void __init fixup_device_tree_maple(void) 2799 - { 2800 - phandle isa; 2801 - u32 rloc = 0x01002000; /* IO space; PCI device = 4 */ 2802 - u32 isa_ranges[6]; 2803 - char *name; 2804 - 2805 - name = "/ht@0/isa@4"; 2806 - isa = call_prom("finddevice", 1, 1, ADDR(name)); 2807 - if (!PHANDLE_VALID(isa)) { 2808 - name = "/ht@0/isa@6"; 2809 - isa = call_prom("finddevice", 1, 1, ADDR(name)); 2810 - rloc = 0x01003000; /* IO space; PCI device = 6 */ 2811 - } 2812 - if (!PHANDLE_VALID(isa)) 2813 - return; 2814 - 2815 - if (prom_getproplen(isa, "ranges") != 12) 2816 - return; 2817 - if (prom_getprop(isa, "ranges", isa_ranges, sizeof(isa_ranges)) 2818 - == PROM_ERROR) 2819 - return; 2820 - 2821 - if (isa_ranges[0] != 0x1 || 2822 - isa_ranges[1] != 0xf4000000 || 2823 - isa_ranges[2] != 0x00010000) 2824 - return; 2825 - 2826 - prom_printf("Fixing up bogus ISA range on Maple/Apache...\n"); 2827 - 2828 - isa_ranges[0] = 0x1; 2829 - isa_ranges[1] = 0x0; 2830 - isa_ranges[2] = rloc; 2831 - isa_ranges[3] = 0x0; 2832 - isa_ranges[4] = 0x0; 2833 - isa_ranges[5] = 0x00010000; 2834 - prom_setprop(isa, name, "ranges", 2835 - isa_ranges, sizeof(isa_ranges)); 2836 - } 2837 - 2838 - #define CPC925_MC_START 0xf8000000 2839 - #define CPC925_MC_LENGTH 0x1000000 2840 - /* The values for memory-controller don't have right number of cells */ 2841 - static void __init fixup_device_tree_maple_memory_controller(void) 2842 - { 2843 - phandle mc; 2844 - u32 mc_reg[4]; 2845 - char *name = "/hostbridge@f8000000"; 2846 - u32 ac, sc; 2847 - 2848 - mc = call_prom("finddevice", 1, 1, ADDR(name)); 2849 - if (!PHANDLE_VALID(mc)) 2850 - return; 2851 - 2852 - if (prom_getproplen(mc, "reg") != 8) 2853 - return; 2854 - 2855 - prom_getprop(prom.root, "#address-cells", &ac, sizeof(ac)); 2856 - prom_getprop(prom.root, "#size-cells", &sc, sizeof(sc)); 2857 - if ((ac != 2) || (sc != 2)) 2858 - return; 2859 - 2860 - if (prom_getprop(mc, "reg", mc_reg, sizeof(mc_reg)) == PROM_ERROR) 2861 - return; 2862 - 2863 - if (mc_reg[0] != CPC925_MC_START || mc_reg[1] != CPC925_MC_LENGTH) 2864 - return; 2865 - 2866 - prom_printf("Fixing up bogus hostbridge on Maple...\n"); 2867 - 2868 - mc_reg[0] = 0x0; 2869 - mc_reg[1] = CPC925_MC_START; 2870 - mc_reg[2] = 0x0; 2871 - mc_reg[3] = CPC925_MC_LENGTH; 2872 - prom_setprop(mc, name, "reg", mc_reg, sizeof(mc_reg)); 2873 - } 2874 - #else 2875 - #define fixup_device_tree_maple() 2876 - #define fixup_device_tree_maple_memory_controller() 2877 - #endif 2878 - 2879 2795 #ifdef CONFIG_PPC_CHRP 2880 2796 /* 2881 2797 * Pegasos and BriQ lacks the "ranges" property in the isa node ··· 3109 3193 3110 3194 static void __init fixup_device_tree(void) 3111 3195 { 3112 - fixup_device_tree_maple(); 3113 - fixup_device_tree_maple_memory_controller(); 3114 3196 fixup_device_tree_chrp(); 3115 3197 fixup_device_tree_pmac(); 3116 3198 fixup_device_tree_efika();
-3
arch/powerpc/kernel/udbg.c
··· 39 39 #elif defined(CONFIG_PPC_EARLY_DEBUG_RTAS_CONSOLE) 40 40 /* RTAS console debug */ 41 41 udbg_init_rtas_console(); 42 - #elif defined(CONFIG_PPC_EARLY_DEBUG_MAPLE) 43 - /* Maple real mode debug */ 44 - udbg_init_maple_realmode(); 45 42 #elif defined(CONFIG_PPC_EARLY_DEBUG_PAS_REALMODE) 46 43 udbg_init_pas_realmode(); 47 44 #elif defined(CONFIG_PPC_EARLY_DEBUG_BOOTX)
-23
arch/powerpc/kernel/udbg_16550.c
··· 205 205 udbg_use_uart(); 206 206 } 207 207 208 - #ifdef CONFIG_PPC_MAPLE 209 - 210 - #define UDBG_UART_MAPLE_ADDR ((void __iomem *)0xf40003f8) 211 - 212 - static u8 udbg_uart_in_maple(unsigned int reg) 213 - { 214 - return real_readb(UDBG_UART_MAPLE_ADDR + reg); 215 - } 216 - 217 - static void udbg_uart_out_maple(unsigned int reg, u8 val) 218 - { 219 - real_writeb(val, UDBG_UART_MAPLE_ADDR + reg); 220 - } 221 - 222 - void __init udbg_init_maple_realmode(void) 223 - { 224 - udbg_uart_in = udbg_uart_in_maple; 225 - udbg_uart_out = udbg_uart_out_maple; 226 - udbg_use_uart(); 227 - } 228 - 229 - #endif /* CONFIG_PPC_MAPLE */ 230 - 231 208 #ifdef CONFIG_PPC_PASEMI 232 209 233 210 #define UDBG_UART_PAS_ADDR ((void __iomem *)0xfcff03f8UL)
-1
arch/powerpc/platforms/Kconfig
··· 7 7 source "arch/powerpc/platforms/512x/Kconfig" 8 8 source "arch/powerpc/platforms/52xx/Kconfig" 9 9 source "arch/powerpc/platforms/powermac/Kconfig" 10 - source "arch/powerpc/platforms/maple/Kconfig" 11 10 source "arch/powerpc/platforms/pasemi/Kconfig" 12 11 source "arch/powerpc/platforms/ps3/Kconfig" 13 12 source "arch/powerpc/platforms/cell/Kconfig"
-1
arch/powerpc/platforms/Makefile
··· 14 14 obj-$(CONFIG_PPC_86xx) += 86xx/ 15 15 obj-$(CONFIG_PPC_POWERNV) += powernv/ 16 16 obj-$(CONFIG_PPC_PSERIES) += pseries/ 17 - obj-$(CONFIG_PPC_MAPLE) += maple/ 18 17 obj-$(CONFIG_PPC_PASEMI) += pasemi/ 19 18 obj-$(CONFIG_PPC_CELL) += cell/ 20 19 obj-$(CONFIG_PPC_PS3) += ps3/
-19
arch/powerpc/platforms/maple/Kconfig
··· 1 - # SPDX-License-Identifier: GPL-2.0 2 - config PPC_MAPLE 3 - depends on PPC64 && PPC_BOOK3S && CPU_BIG_ENDIAN 4 - bool "Maple 970FX Evaluation Board" 5 - select FORCE_PCI 6 - select MPIC 7 - select U3_DART 8 - select MPIC_U3_HT_IRQS 9 - select GENERIC_TBSYNC 10 - select PPC_UDBG_16550 11 - select PPC_970_NAP 12 - select PPC_64S_HASH_MMU 13 - select PPC_HASH_MMU_NATIVE 14 - select PPC_RTAS 15 - select MMIO_NVRAM 16 - select ATA_NONSTANDARD if ATA 17 - help 18 - This option enables support for the Maple 970FX Evaluation Board. 19 - For more information, refer to <http://www.970eval.com>
-2
arch/powerpc/platforms/maple/Makefile
··· 1 - # SPDX-License-Identifier: GPL-2.0-only 2 - obj-y += setup.o pci.o time.o
-14
arch/powerpc/platforms/maple/maple.h
··· 1 - /* SPDX-License-Identifier: GPL-2.0 */ 2 - /* 3 - * Declarations for maple-specific code. 4 - * 5 - * Maple is the name of a PPC970 evaluation board. 6 - */ 7 - extern int maple_set_rtc_time(struct rtc_time *tm); 8 - extern void maple_get_rtc_time(struct rtc_time *tm); 9 - extern time64_t maple_get_boot_time(void); 10 - extern void maple_pci_init(void); 11 - extern void maple_pci_irq_fixup(struct pci_dev *dev); 12 - extern int maple_pci_get_legacy_ide_irq(struct pci_dev *dev, int channel); 13 - 14 - extern struct pci_controller_ops maple_pci_controller_ops;
-672
arch/powerpc/platforms/maple/pci.c
··· 1 - // SPDX-License-Identifier: GPL-2.0-or-later 2 - /* 3 - * Copyright (C) 2004 Benjamin Herrenschmuidt (benh@kernel.crashing.org), 4 - * IBM Corp. 5 - */ 6 - 7 - #undef DEBUG 8 - 9 - #include <linux/kernel.h> 10 - #include <linux/pci.h> 11 - #include <linux/delay.h> 12 - #include <linux/string.h> 13 - #include <linux/init.h> 14 - #include <linux/irq.h> 15 - #include <linux/of_irq.h> 16 - 17 - #include <asm/sections.h> 18 - #include <asm/io.h> 19 - #include <asm/pci-bridge.h> 20 - #include <asm/machdep.h> 21 - #include <asm/iommu.h> 22 - #include <asm/ppc-pci.h> 23 - #include <asm/isa-bridge.h> 24 - 25 - #include "maple.h" 26 - 27 - #ifdef DEBUG 28 - #define DBG(x...) printk(x) 29 - #else 30 - #define DBG(x...) 31 - #endif 32 - 33 - static struct pci_controller *u3_agp, *u3_ht, *u4_pcie; 34 - 35 - static int __init fixup_one_level_bus_range(struct device_node *node, int higher) 36 - { 37 - for (; node; node = node->sibling) { 38 - const int *bus_range; 39 - const unsigned int *class_code; 40 - int len; 41 - 42 - /* For PCI<->PCI bridges or CardBus bridges, we go down */ 43 - class_code = of_get_property(node, "class-code", NULL); 44 - if (!class_code || ((*class_code >> 8) != PCI_CLASS_BRIDGE_PCI && 45 - (*class_code >> 8) != PCI_CLASS_BRIDGE_CARDBUS)) 46 - continue; 47 - bus_range = of_get_property(node, "bus-range", &len); 48 - if (bus_range != NULL && len > 2 * sizeof(int)) { 49 - if (bus_range[1] > higher) 50 - higher = bus_range[1]; 51 - } 52 - higher = fixup_one_level_bus_range(node->child, higher); 53 - } 54 - return higher; 55 - } 56 - 57 - /* This routine fixes the "bus-range" property of all bridges in the 58 - * system since they tend to have their "last" member wrong on macs 59 - * 60 - * Note that the bus numbers manipulated here are OF bus numbers, they 61 - * are not Linux bus numbers. 62 - */ 63 - static void __init fixup_bus_range(struct device_node *bridge) 64 - { 65 - int *bus_range; 66 - struct property *prop; 67 - int len; 68 - 69 - /* Lookup the "bus-range" property for the hose */ 70 - prop = of_find_property(bridge, "bus-range", &len); 71 - if (prop == NULL || prop->value == NULL || len < 2 * sizeof(int)) { 72 - printk(KERN_WARNING "Can't get bus-range for %pOF\n", 73 - bridge); 74 - return; 75 - } 76 - bus_range = prop->value; 77 - bus_range[1] = fixup_one_level_bus_range(bridge->child, bus_range[1]); 78 - } 79 - 80 - 81 - static unsigned long u3_agp_cfa0(u8 devfn, u8 off) 82 - { 83 - return (1 << (unsigned long)PCI_SLOT(devfn)) | 84 - ((unsigned long)PCI_FUNC(devfn) << 8) | 85 - ((unsigned long)off & 0xFCUL); 86 - } 87 - 88 - static unsigned long u3_agp_cfa1(u8 bus, u8 devfn, u8 off) 89 - { 90 - return ((unsigned long)bus << 16) | 91 - ((unsigned long)devfn << 8) | 92 - ((unsigned long)off & 0xFCUL) | 93 - 1UL; 94 - } 95 - 96 - static volatile void __iomem *u3_agp_cfg_access(struct pci_controller* hose, 97 - u8 bus, u8 dev_fn, u8 offset) 98 - { 99 - unsigned int caddr; 100 - 101 - if (bus == hose->first_busno) { 102 - if (dev_fn < (11 << 3)) 103 - return NULL; 104 - caddr = u3_agp_cfa0(dev_fn, offset); 105 - } else 106 - caddr = u3_agp_cfa1(bus, dev_fn, offset); 107 - 108 - /* Uninorth will return garbage if we don't read back the value ! */ 109 - do { 110 - out_le32(hose->cfg_addr, caddr); 111 - } while (in_le32(hose->cfg_addr) != caddr); 112 - 113 - offset &= 0x07; 114 - return hose->cfg_data + offset; 115 - } 116 - 117 - static int u3_agp_read_config(struct pci_bus *bus, unsigned int devfn, 118 - int offset, int len, u32 *val) 119 - { 120 - struct pci_controller *hose; 121 - volatile void __iomem *addr; 122 - 123 - hose = pci_bus_to_host(bus); 124 - if (hose == NULL) 125 - return PCIBIOS_DEVICE_NOT_FOUND; 126 - 127 - addr = u3_agp_cfg_access(hose, bus->number, devfn, offset); 128 - if (!addr) 129 - return PCIBIOS_DEVICE_NOT_FOUND; 130 - /* 131 - * Note: the caller has already checked that offset is 132 - * suitably aligned and that len is 1, 2 or 4. 133 - */ 134 - switch (len) { 135 - case 1: 136 - *val = in_8(addr); 137 - break; 138 - case 2: 139 - *val = in_le16(addr); 140 - break; 141 - default: 142 - *val = in_le32(addr); 143 - break; 144 - } 145 - return PCIBIOS_SUCCESSFUL; 146 - } 147 - 148 - static int u3_agp_write_config(struct pci_bus *bus, unsigned int devfn, 149 - int offset, int len, u32 val) 150 - { 151 - struct pci_controller *hose; 152 - volatile void __iomem *addr; 153 - 154 - hose = pci_bus_to_host(bus); 155 - if (hose == NULL) 156 - return PCIBIOS_DEVICE_NOT_FOUND; 157 - 158 - addr = u3_agp_cfg_access(hose, bus->number, devfn, offset); 159 - if (!addr) 160 - return PCIBIOS_DEVICE_NOT_FOUND; 161 - /* 162 - * Note: the caller has already checked that offset is 163 - * suitably aligned and that len is 1, 2 or 4. 164 - */ 165 - switch (len) { 166 - case 1: 167 - out_8(addr, val); 168 - break; 169 - case 2: 170 - out_le16(addr, val); 171 - break; 172 - default: 173 - out_le32(addr, val); 174 - break; 175 - } 176 - return PCIBIOS_SUCCESSFUL; 177 - } 178 - 179 - static struct pci_ops u3_agp_pci_ops = 180 - { 181 - .read = u3_agp_read_config, 182 - .write = u3_agp_write_config, 183 - }; 184 - 185 - static unsigned long u3_ht_cfa0(u8 devfn, u8 off) 186 - { 187 - return (devfn << 8) | off; 188 - } 189 - 190 - static unsigned long u3_ht_cfa1(u8 bus, u8 devfn, u8 off) 191 - { 192 - return u3_ht_cfa0(devfn, off) + (bus << 16) + 0x01000000UL; 193 - } 194 - 195 - static volatile void __iomem *u3_ht_cfg_access(struct pci_controller* hose, 196 - u8 bus, u8 devfn, u8 offset) 197 - { 198 - if (bus == hose->first_busno) { 199 - if (PCI_SLOT(devfn) == 0) 200 - return NULL; 201 - return hose->cfg_data + u3_ht_cfa0(devfn, offset); 202 - } else 203 - return hose->cfg_data + u3_ht_cfa1(bus, devfn, offset); 204 - } 205 - 206 - static int u3_ht_root_read_config(struct pci_controller *hose, u8 offset, 207 - int len, u32 *val) 208 - { 209 - volatile void __iomem *addr; 210 - 211 - addr = hose->cfg_addr; 212 - addr += ((offset & ~3) << 2) + (4 - len - (offset & 3)); 213 - 214 - switch (len) { 215 - case 1: 216 - *val = in_8(addr); 217 - break; 218 - case 2: 219 - *val = in_be16(addr); 220 - break; 221 - default: 222 - *val = in_be32(addr); 223 - break; 224 - } 225 - 226 - return PCIBIOS_SUCCESSFUL; 227 - } 228 - 229 - static int u3_ht_root_write_config(struct pci_controller *hose, u8 offset, 230 - int len, u32 val) 231 - { 232 - volatile void __iomem *addr; 233 - 234 - addr = hose->cfg_addr + ((offset & ~3) << 2) + (4 - len - (offset & 3)); 235 - 236 - if (offset >= PCI_BASE_ADDRESS_0 && offset < PCI_CAPABILITY_LIST) 237 - return PCIBIOS_SUCCESSFUL; 238 - 239 - switch (len) { 240 - case 1: 241 - out_8(addr, val); 242 - break; 243 - case 2: 244 - out_be16(addr, val); 245 - break; 246 - default: 247 - out_be32(addr, val); 248 - break; 249 - } 250 - 251 - return PCIBIOS_SUCCESSFUL; 252 - } 253 - 254 - static int u3_ht_read_config(struct pci_bus *bus, unsigned int devfn, 255 - int offset, int len, u32 *val) 256 - { 257 - struct pci_controller *hose; 258 - volatile void __iomem *addr; 259 - 260 - hose = pci_bus_to_host(bus); 261 - if (hose == NULL) 262 - return PCIBIOS_DEVICE_NOT_FOUND; 263 - 264 - if (bus->number == hose->first_busno && devfn == PCI_DEVFN(0, 0)) 265 - return u3_ht_root_read_config(hose, offset, len, val); 266 - 267 - if (offset > 0xff) 268 - return PCIBIOS_BAD_REGISTER_NUMBER; 269 - 270 - addr = u3_ht_cfg_access(hose, bus->number, devfn, offset); 271 - if (!addr) 272 - return PCIBIOS_DEVICE_NOT_FOUND; 273 - 274 - /* 275 - * Note: the caller has already checked that offset is 276 - * suitably aligned and that len is 1, 2 or 4. 277 - */ 278 - switch (len) { 279 - case 1: 280 - *val = in_8(addr); 281 - break; 282 - case 2: 283 - *val = in_le16(addr); 284 - break; 285 - default: 286 - *val = in_le32(addr); 287 - break; 288 - } 289 - return PCIBIOS_SUCCESSFUL; 290 - } 291 - 292 - static int u3_ht_write_config(struct pci_bus *bus, unsigned int devfn, 293 - int offset, int len, u32 val) 294 - { 295 - struct pci_controller *hose; 296 - volatile void __iomem *addr; 297 - 298 - hose = pci_bus_to_host(bus); 299 - if (hose == NULL) 300 - return PCIBIOS_DEVICE_NOT_FOUND; 301 - 302 - if (bus->number == hose->first_busno && devfn == PCI_DEVFN(0, 0)) 303 - return u3_ht_root_write_config(hose, offset, len, val); 304 - 305 - if (offset > 0xff) 306 - return PCIBIOS_BAD_REGISTER_NUMBER; 307 - 308 - addr = u3_ht_cfg_access(hose, bus->number, devfn, offset); 309 - if (!addr) 310 - return PCIBIOS_DEVICE_NOT_FOUND; 311 - /* 312 - * Note: the caller has already checked that offset is 313 - * suitably aligned and that len is 1, 2 or 4. 314 - */ 315 - switch (len) { 316 - case 1: 317 - out_8(addr, val); 318 - break; 319 - case 2: 320 - out_le16(addr, val); 321 - break; 322 - default: 323 - out_le32(addr, val); 324 - break; 325 - } 326 - return PCIBIOS_SUCCESSFUL; 327 - } 328 - 329 - static struct pci_ops u3_ht_pci_ops = 330 - { 331 - .read = u3_ht_read_config, 332 - .write = u3_ht_write_config, 333 - }; 334 - 335 - static unsigned int u4_pcie_cfa0(unsigned int devfn, unsigned int off) 336 - { 337 - return (1 << PCI_SLOT(devfn)) | 338 - (PCI_FUNC(devfn) << 8) | 339 - ((off >> 8) << 28) | 340 - (off & 0xfcu); 341 - } 342 - 343 - static unsigned int u4_pcie_cfa1(unsigned int bus, unsigned int devfn, 344 - unsigned int off) 345 - { 346 - return (bus << 16) | 347 - (devfn << 8) | 348 - ((off >> 8) << 28) | 349 - (off & 0xfcu) | 1u; 350 - } 351 - 352 - static volatile void __iomem *u4_pcie_cfg_access(struct pci_controller* hose, 353 - u8 bus, u8 dev_fn, int offset) 354 - { 355 - unsigned int caddr; 356 - 357 - if (bus == hose->first_busno) 358 - caddr = u4_pcie_cfa0(dev_fn, offset); 359 - else 360 - caddr = u4_pcie_cfa1(bus, dev_fn, offset); 361 - 362 - /* Uninorth will return garbage if we don't read back the value ! */ 363 - do { 364 - out_le32(hose->cfg_addr, caddr); 365 - } while (in_le32(hose->cfg_addr) != caddr); 366 - 367 - offset &= 0x03; 368 - return hose->cfg_data + offset; 369 - } 370 - 371 - static int u4_pcie_read_config(struct pci_bus *bus, unsigned int devfn, 372 - int offset, int len, u32 *val) 373 - { 374 - struct pci_controller *hose; 375 - volatile void __iomem *addr; 376 - 377 - hose = pci_bus_to_host(bus); 378 - if (hose == NULL) 379 - return PCIBIOS_DEVICE_NOT_FOUND; 380 - if (offset >= 0x1000) 381 - return PCIBIOS_BAD_REGISTER_NUMBER; 382 - addr = u4_pcie_cfg_access(hose, bus->number, devfn, offset); 383 - if (!addr) 384 - return PCIBIOS_DEVICE_NOT_FOUND; 385 - /* 386 - * Note: the caller has already checked that offset is 387 - * suitably aligned and that len is 1, 2 or 4. 388 - */ 389 - switch (len) { 390 - case 1: 391 - *val = in_8(addr); 392 - break; 393 - case 2: 394 - *val = in_le16(addr); 395 - break; 396 - default: 397 - *val = in_le32(addr); 398 - break; 399 - } 400 - return PCIBIOS_SUCCESSFUL; 401 - } 402 - static int u4_pcie_write_config(struct pci_bus *bus, unsigned int devfn, 403 - int offset, int len, u32 val) 404 - { 405 - struct pci_controller *hose; 406 - volatile void __iomem *addr; 407 - 408 - hose = pci_bus_to_host(bus); 409 - if (hose == NULL) 410 - return PCIBIOS_DEVICE_NOT_FOUND; 411 - if (offset >= 0x1000) 412 - return PCIBIOS_BAD_REGISTER_NUMBER; 413 - addr = u4_pcie_cfg_access(hose, bus->number, devfn, offset); 414 - if (!addr) 415 - return PCIBIOS_DEVICE_NOT_FOUND; 416 - /* 417 - * Note: the caller has already checked that offset is 418 - * suitably aligned and that len is 1, 2 or 4. 419 - */ 420 - switch (len) { 421 - case 1: 422 - out_8(addr, val); 423 - break; 424 - case 2: 425 - out_le16(addr, val); 426 - break; 427 - default: 428 - out_le32(addr, val); 429 - break; 430 - } 431 - return PCIBIOS_SUCCESSFUL; 432 - } 433 - 434 - static struct pci_ops u4_pcie_pci_ops = 435 - { 436 - .read = u4_pcie_read_config, 437 - .write = u4_pcie_write_config, 438 - }; 439 - 440 - static void __init setup_u3_agp(struct pci_controller* hose) 441 - { 442 - /* On G5, we move AGP up to high bus number so we don't need 443 - * to reassign bus numbers for HT. If we ever have P2P bridges 444 - * on AGP, we'll have to move pci_assign_all_buses to the 445 - * pci_controller structure so we enable it for AGP and not for 446 - * HT childs. 447 - * We hard code the address because of the different size of 448 - * the reg address cell, we shall fix that by killing struct 449 - * reg_property and using some accessor functions instead 450 - */ 451 - hose->first_busno = 0xf0; 452 - hose->last_busno = 0xff; 453 - hose->ops = &u3_agp_pci_ops; 454 - hose->cfg_addr = ioremap(0xf0000000 + 0x800000, 0x1000); 455 - hose->cfg_data = ioremap(0xf0000000 + 0xc00000, 0x1000); 456 - 457 - u3_agp = hose; 458 - } 459 - 460 - static void __init setup_u4_pcie(struct pci_controller* hose) 461 - { 462 - /* We currently only implement the "non-atomic" config space, to 463 - * be optimised later. 464 - */ 465 - hose->ops = &u4_pcie_pci_ops; 466 - hose->cfg_addr = ioremap(0xf0000000 + 0x800000, 0x1000); 467 - hose->cfg_data = ioremap(0xf0000000 + 0xc00000, 0x1000); 468 - 469 - u4_pcie = hose; 470 - } 471 - 472 - static void __init setup_u3_ht(struct pci_controller* hose) 473 - { 474 - hose->ops = &u3_ht_pci_ops; 475 - 476 - /* We hard code the address because of the different size of 477 - * the reg address cell, we shall fix that by killing struct 478 - * reg_property and using some accessor functions instead 479 - */ 480 - hose->cfg_data = ioremap(0xf2000000, 0x02000000); 481 - hose->cfg_addr = ioremap(0xf8070000, 0x1000); 482 - 483 - hose->first_busno = 0; 484 - hose->last_busno = 0xef; 485 - 486 - u3_ht = hose; 487 - } 488 - 489 - static int __init maple_add_bridge(struct device_node *dev) 490 - { 491 - int len; 492 - struct pci_controller *hose; 493 - char* disp_name; 494 - const int *bus_range; 495 - int primary = 1; 496 - 497 - DBG("Adding PCI host bridge %pOF\n", dev); 498 - 499 - bus_range = of_get_property(dev, "bus-range", &len); 500 - if (bus_range == NULL || len < 2 * sizeof(int)) { 501 - printk(KERN_WARNING "Can't get bus-range for %pOF, assume bus 0\n", 502 - dev); 503 - } 504 - 505 - hose = pcibios_alloc_controller(dev); 506 - if (hose == NULL) 507 - return -ENOMEM; 508 - hose->first_busno = bus_range ? bus_range[0] : 0; 509 - hose->last_busno = bus_range ? bus_range[1] : 0xff; 510 - hose->controller_ops = maple_pci_controller_ops; 511 - 512 - disp_name = NULL; 513 - if (of_device_is_compatible(dev, "u3-agp")) { 514 - setup_u3_agp(hose); 515 - disp_name = "U3-AGP"; 516 - primary = 0; 517 - } else if (of_device_is_compatible(dev, "u3-ht")) { 518 - setup_u3_ht(hose); 519 - disp_name = "U3-HT"; 520 - primary = 1; 521 - } else if (of_device_is_compatible(dev, "u4-pcie")) { 522 - setup_u4_pcie(hose); 523 - disp_name = "U4-PCIE"; 524 - primary = 0; 525 - } 526 - printk(KERN_INFO "Found %s PCI host bridge. Firmware bus number: %d->%d\n", 527 - disp_name, hose->first_busno, hose->last_busno); 528 - 529 - /* Interpret the "ranges" property */ 530 - /* This also maps the I/O region and sets isa_io/mem_base */ 531 - pci_process_bridge_OF_ranges(hose, dev, primary); 532 - 533 - /* Fixup "bus-range" OF property */ 534 - fixup_bus_range(dev); 535 - 536 - /* Check for legacy IOs */ 537 - isa_bridge_find_early(hose); 538 - 539 - /* create pci_dn's for DT nodes under this PHB */ 540 - pci_devs_phb_init_dynamic(hose); 541 - 542 - return 0; 543 - } 544 - 545 - 546 - void maple_pci_irq_fixup(struct pci_dev *dev) 547 - { 548 - DBG(" -> maple_pci_irq_fixup\n"); 549 - 550 - /* Fixup IRQ for PCIe host */ 551 - if (u4_pcie != NULL && dev->bus->number == 0 && 552 - pci_bus_to_host(dev->bus) == u4_pcie) { 553 - printk(KERN_DEBUG "Fixup U4 PCIe IRQ\n"); 554 - dev->irq = irq_create_mapping(NULL, 1); 555 - if (dev->irq) 556 - irq_set_irq_type(dev->irq, IRQ_TYPE_LEVEL_LOW); 557 - } 558 - 559 - /* Hide AMD8111 IDE interrupt when in legacy mode so 560 - * the driver calls pci_get_legacy_ide_irq() 561 - */ 562 - if (dev->vendor == PCI_VENDOR_ID_AMD && 563 - dev->device == PCI_DEVICE_ID_AMD_8111_IDE && 564 - (dev->class & 5) != 5) { 565 - dev->irq = 0; 566 - } 567 - 568 - DBG(" <- maple_pci_irq_fixup\n"); 569 - } 570 - 571 - static int maple_pci_root_bridge_prepare(struct pci_host_bridge *bridge) 572 - { 573 - struct pci_controller *hose = pci_bus_to_host(bridge->bus); 574 - struct device_node *np, *child; 575 - 576 - if (hose != u3_agp) 577 - return 0; 578 - 579 - /* Fixup the PCI<->OF mapping for U3 AGP due to bus renumbering. We 580 - * assume there is no P2P bridge on the AGP bus, which should be a 581 - * safe assumptions hopefully. 582 - */ 583 - np = hose->dn; 584 - PCI_DN(np)->busno = 0xf0; 585 - for_each_child_of_node(np, child) 586 - PCI_DN(child)->busno = 0xf0; 587 - 588 - return 0; 589 - } 590 - 591 - void __init maple_pci_init(void) 592 - { 593 - struct device_node *np, *root; 594 - struct device_node *ht = NULL; 595 - 596 - /* Probe root PCI hosts, that is on U3 the AGP host and the 597 - * HyperTransport host. That one is actually "kept" around 598 - * and actually added last as its resource management relies 599 - * on the AGP resources to have been setup first 600 - */ 601 - root = of_find_node_by_path("/"); 602 - if (root == NULL) { 603 - printk(KERN_CRIT "maple_find_bridges: can't find root of device tree\n"); 604 - return; 605 - } 606 - for_each_child_of_node(root, np) { 607 - if (!of_node_is_type(np, "pci") && !of_node_is_type(np, "ht")) 608 - continue; 609 - if ((of_device_is_compatible(np, "u4-pcie") || 610 - of_device_is_compatible(np, "u3-agp")) && 611 - maple_add_bridge(np) == 0) 612 - of_node_get(np); 613 - 614 - if (of_device_is_compatible(np, "u3-ht")) { 615 - of_node_get(np); 616 - ht = np; 617 - } 618 - } 619 - of_node_put(root); 620 - 621 - /* Now setup the HyperTransport host if we found any 622 - */ 623 - if (ht && maple_add_bridge(ht) != 0) 624 - of_node_put(ht); 625 - 626 - ppc_md.pcibios_root_bridge_prepare = maple_pci_root_bridge_prepare; 627 - 628 - /* Tell pci.c to not change any resource allocations. */ 629 - pci_add_flags(PCI_PROBE_ONLY); 630 - } 631 - 632 - int maple_pci_get_legacy_ide_irq(struct pci_dev *pdev, int channel) 633 - { 634 - struct device_node *np; 635 - unsigned int defirq = channel ? 15 : 14; 636 - unsigned int irq; 637 - 638 - if (pdev->vendor != PCI_VENDOR_ID_AMD || 639 - pdev->device != PCI_DEVICE_ID_AMD_8111_IDE) 640 - return defirq; 641 - 642 - np = pci_device_to_OF_node(pdev); 643 - if (np == NULL) { 644 - printk("Failed to locate OF node for IDE %s\n", 645 - pci_name(pdev)); 646 - return defirq; 647 - } 648 - irq = irq_of_parse_and_map(np, channel & 0x1); 649 - if (!irq) { 650 - printk("Failed to map onboard IDE interrupt for channel %d\n", 651 - channel); 652 - return defirq; 653 - } 654 - return irq; 655 - } 656 - 657 - static void quirk_ipr_msi(struct pci_dev *dev) 658 - { 659 - /* Something prevents MSIs from the IPR from working on Bimini, 660 - * and the driver has no smarts to recover. So disable MSI 661 - * on it for now. */ 662 - 663 - if (machine_is(maple)) { 664 - dev->no_msi = 1; 665 - dev_info(&dev->dev, "Quirk disabled MSI\n"); 666 - } 667 - } 668 - DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_IBM, PCI_DEVICE_ID_IBM_OBSIDIAN, 669 - quirk_ipr_msi); 670 - 671 - struct pci_controller_ops maple_pci_controller_ops = { 672 - };
-363
arch/powerpc/platforms/maple/setup.c
··· 1 - // SPDX-License-Identifier: GPL-2.0-or-later 2 - /* 3 - * Maple (970 eval board) setup code 4 - * 5 - * (c) Copyright 2004 Benjamin Herrenschmidt (benh@kernel.crashing.org), 6 - * IBM Corp. 7 - */ 8 - 9 - #undef DEBUG 10 - 11 - #include <linux/init.h> 12 - #include <linux/errno.h> 13 - #include <linux/sched.h> 14 - #include <linux/kernel.h> 15 - #include <linux/export.h> 16 - #include <linux/mm.h> 17 - #include <linux/stddef.h> 18 - #include <linux/unistd.h> 19 - #include <linux/ptrace.h> 20 - #include <linux/user.h> 21 - #include <linux/tty.h> 22 - #include <linux/string.h> 23 - #include <linux/delay.h> 24 - #include <linux/ioport.h> 25 - #include <linux/major.h> 26 - #include <linux/initrd.h> 27 - #include <linux/vt_kern.h> 28 - #include <linux/console.h> 29 - #include <linux/pci.h> 30 - #include <linux/adb.h> 31 - #include <linux/cuda.h> 32 - #include <linux/pmu.h> 33 - #include <linux/irq.h> 34 - #include <linux/seq_file.h> 35 - #include <linux/root_dev.h> 36 - #include <linux/serial.h> 37 - #include <linux/smp.h> 38 - #include <linux/bitops.h> 39 - #include <linux/of.h> 40 - #include <linux/of_address.h> 41 - #include <linux/platform_device.h> 42 - #include <linux/memblock.h> 43 - 44 - #include <asm/processor.h> 45 - #include <asm/sections.h> 46 - #include <asm/io.h> 47 - #include <asm/pci-bridge.h> 48 - #include <asm/iommu.h> 49 - #include <asm/machdep.h> 50 - #include <asm/dma.h> 51 - #include <asm/cputable.h> 52 - #include <asm/time.h> 53 - #include <asm/mpic.h> 54 - #include <asm/rtas.h> 55 - #include <asm/udbg.h> 56 - #include <asm/nvram.h> 57 - 58 - #include "maple.h" 59 - 60 - #ifdef DEBUG 61 - #define DBG(fmt...) udbg_printf(fmt) 62 - #else 63 - #define DBG(fmt...) 64 - #endif 65 - 66 - static unsigned long maple_find_nvram_base(void) 67 - { 68 - struct device_node *rtcs; 69 - unsigned long result = 0; 70 - 71 - /* find NVRAM device */ 72 - rtcs = of_find_compatible_node(NULL, "nvram", "AMD8111"); 73 - if (rtcs) { 74 - struct resource r; 75 - if (of_address_to_resource(rtcs, 0, &r)) { 76 - printk(KERN_EMERG "Maple: Unable to translate NVRAM" 77 - " address\n"); 78 - goto bail; 79 - } 80 - if (!(r.flags & IORESOURCE_IO)) { 81 - printk(KERN_EMERG "Maple: NVRAM address isn't PIO!\n"); 82 - goto bail; 83 - } 84 - result = r.start; 85 - } else 86 - printk(KERN_EMERG "Maple: Unable to find NVRAM\n"); 87 - bail: 88 - of_node_put(rtcs); 89 - return result; 90 - } 91 - 92 - static void __noreturn maple_restart(char *cmd) 93 - { 94 - unsigned int maple_nvram_base; 95 - const unsigned int *maple_nvram_offset, *maple_nvram_command; 96 - struct device_node *sp; 97 - 98 - maple_nvram_base = maple_find_nvram_base(); 99 - if (maple_nvram_base == 0) 100 - goto fail; 101 - 102 - /* find service processor device */ 103 - sp = of_find_node_by_name(NULL, "service-processor"); 104 - if (!sp) { 105 - printk(KERN_EMERG "Maple: Unable to find Service Processor\n"); 106 - goto fail; 107 - } 108 - maple_nvram_offset = of_get_property(sp, "restart-addr", NULL); 109 - maple_nvram_command = of_get_property(sp, "restart-value", NULL); 110 - of_node_put(sp); 111 - 112 - /* send command */ 113 - outb_p(*maple_nvram_command, maple_nvram_base + *maple_nvram_offset); 114 - for (;;) ; 115 - fail: 116 - printk(KERN_EMERG "Maple: Manual Restart Required\n"); 117 - for (;;) ; 118 - } 119 - 120 - static void __noreturn maple_power_off(void) 121 - { 122 - unsigned int maple_nvram_base; 123 - const unsigned int *maple_nvram_offset, *maple_nvram_command; 124 - struct device_node *sp; 125 - 126 - maple_nvram_base = maple_find_nvram_base(); 127 - if (maple_nvram_base == 0) 128 - goto fail; 129 - 130 - /* find service processor device */ 131 - sp = of_find_node_by_name(NULL, "service-processor"); 132 - if (!sp) { 133 - printk(KERN_EMERG "Maple: Unable to find Service Processor\n"); 134 - goto fail; 135 - } 136 - maple_nvram_offset = of_get_property(sp, "power-off-addr", NULL); 137 - maple_nvram_command = of_get_property(sp, "power-off-value", NULL); 138 - of_node_put(sp); 139 - 140 - /* send command */ 141 - outb_p(*maple_nvram_command, maple_nvram_base + *maple_nvram_offset); 142 - for (;;) ; 143 - fail: 144 - printk(KERN_EMERG "Maple: Manual Power-Down Required\n"); 145 - for (;;) ; 146 - } 147 - 148 - static void __noreturn maple_halt(void) 149 - { 150 - maple_power_off(); 151 - } 152 - 153 - #ifdef CONFIG_SMP 154 - static struct smp_ops_t maple_smp_ops = { 155 - .probe = smp_mpic_probe, 156 - .message_pass = smp_mpic_message_pass, 157 - .kick_cpu = smp_generic_kick_cpu, 158 - .setup_cpu = smp_mpic_setup_cpu, 159 - .give_timebase = smp_generic_give_timebase, 160 - .take_timebase = smp_generic_take_timebase, 161 - }; 162 - #endif /* CONFIG_SMP */ 163 - 164 - static void __init maple_use_rtas_reboot_and_halt_if_present(void) 165 - { 166 - if (rtas_function_implemented(RTAS_FN_SYSTEM_REBOOT) && 167 - rtas_function_implemented(RTAS_FN_POWER_OFF)) { 168 - ppc_md.restart = rtas_restart; 169 - pm_power_off = rtas_power_off; 170 - ppc_md.halt = rtas_halt; 171 - } 172 - } 173 - 174 - static void __init maple_setup_arch(void) 175 - { 176 - /* init to some ~sane value until calibrate_delay() runs */ 177 - loops_per_jiffy = 50000000; 178 - 179 - /* Setup SMP callback */ 180 - #ifdef CONFIG_SMP 181 - smp_ops = &maple_smp_ops; 182 - #endif 183 - maple_use_rtas_reboot_and_halt_if_present(); 184 - 185 - printk(KERN_DEBUG "Using native/NAP idle loop\n"); 186 - 187 - mmio_nvram_init(); 188 - } 189 - 190 - /* 191 - * This is almost identical to pSeries and CHRP. We need to make that 192 - * code generic at one point, with appropriate bits in the device-tree to 193 - * identify the presence of an HT APIC 194 - */ 195 - static void __init maple_init_IRQ(void) 196 - { 197 - struct device_node *root, *np, *mpic_node = NULL; 198 - const unsigned int *opprop; 199 - unsigned long openpic_addr = 0; 200 - int naddr, n, i, opplen, has_isus = 0; 201 - struct mpic *mpic; 202 - unsigned int flags = 0; 203 - 204 - /* Locate MPIC in the device-tree. Note that there is a bug 205 - * in Maple device-tree where the type of the controller is 206 - * open-pic and not interrupt-controller 207 - */ 208 - 209 - for_each_node_by_type(np, "interrupt-controller") 210 - if (of_device_is_compatible(np, "open-pic")) { 211 - mpic_node = np; 212 - break; 213 - } 214 - if (mpic_node == NULL) 215 - for_each_node_by_type(np, "open-pic") { 216 - mpic_node = np; 217 - break; 218 - } 219 - if (mpic_node == NULL) { 220 - printk(KERN_ERR 221 - "Failed to locate the MPIC interrupt controller\n"); 222 - return; 223 - } 224 - 225 - /* Find address list in /platform-open-pic */ 226 - root = of_find_node_by_path("/"); 227 - naddr = of_n_addr_cells(root); 228 - opprop = of_get_property(root, "platform-open-pic", &opplen); 229 - if (opprop) { 230 - openpic_addr = of_read_number(opprop, naddr); 231 - has_isus = (opplen > naddr); 232 - printk(KERN_DEBUG "OpenPIC addr: %lx, has ISUs: %d\n", 233 - openpic_addr, has_isus); 234 - } 235 - 236 - BUG_ON(openpic_addr == 0); 237 - 238 - /* Check for a big endian MPIC */ 239 - if (of_property_read_bool(np, "big-endian")) 240 - flags |= MPIC_BIG_ENDIAN; 241 - 242 - /* XXX Maple specific bits */ 243 - flags |= MPIC_U3_HT_IRQS; 244 - /* All U3/U4 are big-endian, older SLOF firmware doesn't encode this */ 245 - flags |= MPIC_BIG_ENDIAN; 246 - 247 - /* Setup the openpic driver. More device-tree junks, we hard code no 248 - * ISUs for now. I'll have to revisit some stuffs with the folks doing 249 - * the firmware for those 250 - */ 251 - mpic = mpic_alloc(mpic_node, openpic_addr, flags, 252 - /*has_isus ? 16 :*/ 0, 0, " MPIC "); 253 - BUG_ON(mpic == NULL); 254 - 255 - /* Add ISUs */ 256 - opplen /= sizeof(u32); 257 - for (n = 0, i = naddr; i < opplen; i += naddr, n++) { 258 - unsigned long isuaddr = of_read_number(opprop + i, naddr); 259 - mpic_assign_isu(mpic, n, isuaddr); 260 - } 261 - 262 - /* All ISUs are setup, complete initialization */ 263 - mpic_init(mpic); 264 - ppc_md.get_irq = mpic_get_irq; 265 - of_node_put(mpic_node); 266 - of_node_put(root); 267 - } 268 - 269 - static void __init maple_progress(char *s, unsigned short hex) 270 - { 271 - printk("*** %04x : %s\n", hex, s ? s : ""); 272 - } 273 - 274 - 275 - /* 276 - * Called very early, MMU is off, device-tree isn't unflattened 277 - */ 278 - static int __init maple_probe(void) 279 - { 280 - if (!of_machine_is_compatible("Momentum,Maple") && 281 - !of_machine_is_compatible("Momentum,Apache")) 282 - return 0; 283 - 284 - pm_power_off = maple_power_off; 285 - 286 - iommu_init_early_dart(&maple_pci_controller_ops); 287 - 288 - return 1; 289 - } 290 - 291 - #ifdef CONFIG_EDAC 292 - /* 293 - * Register a platform device for CPC925 memory controller on 294 - * all boards with U3H (CPC925) bridge. 295 - */ 296 - static int __init maple_cpc925_edac_setup(void) 297 - { 298 - struct platform_device *pdev; 299 - struct device_node *np = NULL; 300 - struct resource r; 301 - int ret; 302 - volatile void __iomem *mem; 303 - u32 rev; 304 - 305 - np = of_find_node_by_type(NULL, "memory-controller"); 306 - if (!np) { 307 - printk(KERN_ERR "%s: Unable to find memory-controller node\n", 308 - __func__); 309 - return -ENODEV; 310 - } 311 - 312 - ret = of_address_to_resource(np, 0, &r); 313 - of_node_put(np); 314 - 315 - if (ret < 0) { 316 - printk(KERN_ERR "%s: Unable to get memory-controller reg\n", 317 - __func__); 318 - return -ENODEV; 319 - } 320 - 321 - mem = ioremap(r.start, resource_size(&r)); 322 - if (!mem) { 323 - printk(KERN_ERR "%s: Unable to map memory-controller memory\n", 324 - __func__); 325 - return -ENOMEM; 326 - } 327 - 328 - rev = __raw_readl(mem); 329 - iounmap(mem); 330 - 331 - if (rev < 0x34 || rev > 0x3f) { /* U3H */ 332 - printk(KERN_ERR "%s: Non-CPC925(U3H) bridge revision: %02x\n", 333 - __func__, rev); 334 - return 0; 335 - } 336 - 337 - pdev = platform_device_register_simple("cpc925_edac", 0, &r, 1); 338 - if (IS_ERR(pdev)) 339 - return PTR_ERR(pdev); 340 - 341 - printk(KERN_INFO "%s: CPC925 platform device created\n", __func__); 342 - 343 - return 0; 344 - } 345 - machine_device_initcall(maple, maple_cpc925_edac_setup); 346 - #endif 347 - 348 - define_machine(maple) { 349 - .name = "Maple", 350 - .probe = maple_probe, 351 - .setup_arch = maple_setup_arch, 352 - .discover_phbs = maple_pci_init, 353 - .init_IRQ = maple_init_IRQ, 354 - .pci_irq_fixup = maple_pci_irq_fixup, 355 - .pci_get_legacy_ide_irq = maple_pci_get_legacy_ide_irq, 356 - .restart = maple_restart, 357 - .halt = maple_halt, 358 - .get_boot_time = maple_get_boot_time, 359 - .set_rtc_time = maple_set_rtc_time, 360 - .get_rtc_time = maple_get_rtc_time, 361 - .progress = maple_progress, 362 - .power_save = power4_idle, 363 - };
-170
arch/powerpc/platforms/maple/time.c
··· 1 - // SPDX-License-Identifier: GPL-2.0-or-later 2 - /* 3 - * (c) Copyright 2004 Benjamin Herrenschmidt (benh@kernel.crashing.org), 4 - * IBM Corp. 5 - */ 6 - 7 - #undef DEBUG 8 - 9 - #include <linux/errno.h> 10 - #include <linux/sched.h> 11 - #include <linux/kernel.h> 12 - #include <linux/param.h> 13 - #include <linux/string.h> 14 - #include <linux/mm.h> 15 - #include <linux/init.h> 16 - #include <linux/time.h> 17 - #include <linux/adb.h> 18 - #include <linux/pmu.h> 19 - #include <linux/interrupt.h> 20 - #include <linux/mc146818rtc.h> 21 - #include <linux/bcd.h> 22 - #include <linux/of_address.h> 23 - 24 - #include <asm/sections.h> 25 - #include <asm/io.h> 26 - #include <asm/machdep.h> 27 - #include <asm/time.h> 28 - 29 - #include "maple.h" 30 - 31 - #ifdef DEBUG 32 - #define DBG(x...) printk(x) 33 - #else 34 - #define DBG(x...) 35 - #endif 36 - 37 - static int maple_rtc_addr; 38 - 39 - static int maple_clock_read(int addr) 40 - { 41 - outb_p(addr, maple_rtc_addr); 42 - return inb_p(maple_rtc_addr+1); 43 - } 44 - 45 - static void maple_clock_write(unsigned long val, int addr) 46 - { 47 - outb_p(addr, maple_rtc_addr); 48 - outb_p(val, maple_rtc_addr+1); 49 - } 50 - 51 - void maple_get_rtc_time(struct rtc_time *tm) 52 - { 53 - do { 54 - tm->tm_sec = maple_clock_read(RTC_SECONDS); 55 - tm->tm_min = maple_clock_read(RTC_MINUTES); 56 - tm->tm_hour = maple_clock_read(RTC_HOURS); 57 - tm->tm_mday = maple_clock_read(RTC_DAY_OF_MONTH); 58 - tm->tm_mon = maple_clock_read(RTC_MONTH); 59 - tm->tm_year = maple_clock_read(RTC_YEAR); 60 - } while (tm->tm_sec != maple_clock_read(RTC_SECONDS)); 61 - 62 - if (!(maple_clock_read(RTC_CONTROL) & RTC_DM_BINARY) 63 - || RTC_ALWAYS_BCD) { 64 - tm->tm_sec = bcd2bin(tm->tm_sec); 65 - tm->tm_min = bcd2bin(tm->tm_min); 66 - tm->tm_hour = bcd2bin(tm->tm_hour); 67 - tm->tm_mday = bcd2bin(tm->tm_mday); 68 - tm->tm_mon = bcd2bin(tm->tm_mon); 69 - tm->tm_year = bcd2bin(tm->tm_year); 70 - } 71 - if ((tm->tm_year + 1900) < 1970) 72 - tm->tm_year += 100; 73 - 74 - tm->tm_wday = -1; 75 - } 76 - 77 - int maple_set_rtc_time(struct rtc_time *tm) 78 - { 79 - unsigned char save_control, save_freq_select; 80 - int sec, min, hour, mon, mday, year; 81 - 82 - spin_lock(&rtc_lock); 83 - 84 - save_control = maple_clock_read(RTC_CONTROL); /* tell the clock it's being set */ 85 - 86 - maple_clock_write((save_control|RTC_SET), RTC_CONTROL); 87 - 88 - save_freq_select = maple_clock_read(RTC_FREQ_SELECT); /* stop and reset prescaler */ 89 - 90 - maple_clock_write((save_freq_select|RTC_DIV_RESET2), RTC_FREQ_SELECT); 91 - 92 - sec = tm->tm_sec; 93 - min = tm->tm_min; 94 - hour = tm->tm_hour; 95 - mon = tm->tm_mon; 96 - mday = tm->tm_mday; 97 - year = tm->tm_year; 98 - 99 - if (!(save_control & RTC_DM_BINARY) || RTC_ALWAYS_BCD) { 100 - sec = bin2bcd(sec); 101 - min = bin2bcd(min); 102 - hour = bin2bcd(hour); 103 - mon = bin2bcd(mon); 104 - mday = bin2bcd(mday); 105 - year = bin2bcd(year); 106 - } 107 - maple_clock_write(sec, RTC_SECONDS); 108 - maple_clock_write(min, RTC_MINUTES); 109 - maple_clock_write(hour, RTC_HOURS); 110 - maple_clock_write(mon, RTC_MONTH); 111 - maple_clock_write(mday, RTC_DAY_OF_MONTH); 112 - maple_clock_write(year, RTC_YEAR); 113 - 114 - /* The following flags have to be released exactly in this order, 115 - * otherwise the DS12887 (popular MC146818A clone with integrated 116 - * battery and quartz) will not reset the oscillator and will not 117 - * update precisely 500 ms later. You won't find this mentioned in 118 - * the Dallas Semiconductor data sheets, but who believes data 119 - * sheets anyway ... -- Markus Kuhn 120 - */ 121 - maple_clock_write(save_control, RTC_CONTROL); 122 - maple_clock_write(save_freq_select, RTC_FREQ_SELECT); 123 - 124 - spin_unlock(&rtc_lock); 125 - 126 - return 0; 127 - } 128 - 129 - static struct resource rtc_iores = { 130 - .name = "rtc", 131 - .flags = IORESOURCE_IO | IORESOURCE_BUSY, 132 - }; 133 - 134 - time64_t __init maple_get_boot_time(void) 135 - { 136 - struct rtc_time tm; 137 - struct device_node *rtcs; 138 - 139 - rtcs = of_find_compatible_node(NULL, "rtc", "pnpPNP,b00"); 140 - if (rtcs) { 141 - struct resource r; 142 - if (of_address_to_resource(rtcs, 0, &r)) { 143 - printk(KERN_EMERG "Maple: Unable to translate RTC" 144 - " address\n"); 145 - goto bail; 146 - } 147 - if (!(r.flags & IORESOURCE_IO)) { 148 - printk(KERN_EMERG "Maple: RTC address isn't PIO!\n"); 149 - goto bail; 150 - } 151 - maple_rtc_addr = r.start; 152 - printk(KERN_INFO "Maple: Found RTC at IO 0x%x\n", 153 - maple_rtc_addr); 154 - } 155 - bail: 156 - of_node_put(rtcs); 157 - if (maple_rtc_addr == 0) { 158 - maple_rtc_addr = RTC_PORT(0); /* legacy address */ 159 - printk(KERN_INFO "Maple: No device node for RTC, assuming " 160 - "legacy address (0x%x)\n", maple_rtc_addr); 161 - } 162 - 163 - rtc_iores.start = maple_rtc_addr; 164 - rtc_iores.end = maple_rtc_addr + 7; 165 - request_resource(&ioport_resource, &rtc_iores); 166 - 167 - maple_get_rtc_time(&tm); 168 - return rtc_tm_to_time64(&tm); 169 - } 170 -