Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: GPL-2.0-or-later
0002 /*
0003  * AmigaOne platform setup
0004  *
0005  * Copyright 2008 Gerhard Pircher (gerhard_pircher@gmx.net)
0006  *
0007  *   Based on original amigaone_setup.c source code
0008  * Copyright 2003 by Hans-Joerg Frieden and Thomas Frieden
0009  */
0010 
0011 #include <linux/irqdomain.h>
0012 #include <linux/kernel.h>
0013 #include <linux/of.h>
0014 #include <linux/of_address.h>
0015 #include <linux/seq_file.h>
0016 #include <generated/utsrelease.h>
0017 
0018 #include <asm/machdep.h>
0019 #include <asm/cputable.h>
0020 #include <asm/pci-bridge.h>
0021 #include <asm/i8259.h>
0022 #include <asm/time.h>
0023 #include <asm/udbg.h>
0024 #include <asm/dma.h>
0025 
0026 extern void __flush_disable_L1(void);
0027 
0028 void amigaone_show_cpuinfo(struct seq_file *m)
0029 {
0030     seq_printf(m, "vendor\t\t: Eyetech Ltd.\n");
0031 }
0032 
0033 static int __init amigaone_add_bridge(struct device_node *dev)
0034 {
0035     const u32 *cfg_addr, *cfg_data;
0036     int len;
0037     const int *bus_range;
0038     struct pci_controller *hose;
0039 
0040     printk(KERN_INFO "Adding PCI host bridge %pOF\n", dev);
0041 
0042     cfg_addr = of_get_address(dev, 0, NULL, NULL);
0043     cfg_data = of_get_address(dev, 1, NULL, NULL);
0044     if ((cfg_addr == NULL) || (cfg_data == NULL))
0045         return -ENODEV;
0046 
0047     bus_range = of_get_property(dev, "bus-range", &len);
0048     if ((bus_range == NULL) || (len < 2 * sizeof(int)))
0049         printk(KERN_WARNING "Can't get bus-range for %pOF, assume"
0050                " bus 0\n", dev);
0051 
0052     hose = pcibios_alloc_controller(dev);
0053     if (hose == NULL)
0054         return -ENOMEM;
0055 
0056     hose->first_busno = bus_range ? bus_range[0] : 0;
0057     hose->last_busno = bus_range ? bus_range[1] : 0xff;
0058 
0059     setup_indirect_pci(hose, cfg_addr[0], cfg_data[0], 0);
0060 
0061     /* Interpret the "ranges" property */
0062     /* This also maps the I/O region and sets isa_io/mem_base */
0063     pci_process_bridge_OF_ranges(hose, dev, 1);
0064 
0065     return 0;
0066 }
0067 
0068 void __init amigaone_setup_arch(void)
0069 {
0070     if (ppc_md.progress)
0071         ppc_md.progress("Linux/PPC "UTS_RELEASE"\n", 0);
0072 }
0073 
0074 static void __init amigaone_discover_phbs(void)
0075 {
0076     struct device_node *np;
0077     int phb = -ENODEV;
0078 
0079     /* Lookup PCI host bridges. */
0080     for_each_compatible_node(np, "pci", "mai-logic,articia-s")
0081         phb = amigaone_add_bridge(np);
0082 
0083     BUG_ON(phb != 0);
0084 }
0085 
0086 void __init amigaone_init_IRQ(void)
0087 {
0088     struct device_node *pic, *np = NULL;
0089     const unsigned long *prop = NULL;
0090     unsigned long int_ack = 0;
0091 
0092     /* Search for ISA interrupt controller. */
0093     pic = of_find_compatible_node(NULL, "interrupt-controller",
0094                                   "pnpPNP,000");
0095     BUG_ON(pic == NULL);
0096 
0097     /* Look for interrupt acknowledge address in the PCI root node. */
0098     np = of_find_compatible_node(NULL, "pci", "mai-logic,articia-s");
0099     if (np) {
0100         prop = of_get_property(np, "8259-interrupt-acknowledge", NULL);
0101         if (prop)
0102             int_ack = prop[0];
0103         of_node_put(np);
0104     }
0105 
0106     if (int_ack == 0)
0107         printk(KERN_WARNING "Cannot find PCI interrupt acknowledge"
0108                " address, polling\n");
0109 
0110     i8259_init(pic, int_ack);
0111     ppc_md.get_irq = i8259_irq;
0112     irq_set_default_host(i8259_get_host());
0113 }
0114 
0115 static int __init request_isa_regions(void)
0116 {
0117     request_region(0x00, 0x20, "dma1");
0118     request_region(0x40, 0x20, "timer");
0119     request_region(0x80, 0x10, "dma page reg");
0120     request_region(0xc0, 0x20, "dma2");
0121 
0122     return 0;
0123 }
0124 machine_device_initcall(amigaone, request_isa_regions);
0125 
0126 void __noreturn amigaone_restart(char *cmd)
0127 {
0128     local_irq_disable();
0129 
0130     /* Flush and disable caches. */
0131     __flush_disable_L1();
0132 
0133         /* Set SRR0 to the reset vector and turn on MSR_IP. */
0134     mtspr(SPRN_SRR0, 0xfff00100);
0135     mtspr(SPRN_SRR1, MSR_IP);
0136 
0137     /* Do an rfi to jump back to firmware. */
0138     __asm__ __volatile__("rfi" : : : "memory");
0139 
0140     /* Not reached. */
0141     while (1);
0142 }
0143 
0144 static int __init amigaone_probe(void)
0145 {
0146     if (of_machine_is_compatible("eyetech,amigaone")) {
0147         /*
0148          * Coherent memory access cause complete system lockup! Thus
0149          * disable this CPU feature, even if the CPU needs it.
0150          */
0151         cur_cpu_spec->cpu_features &= ~CPU_FTR_NEED_COHERENT;
0152 
0153         DMA_MODE_READ = 0x44;
0154         DMA_MODE_WRITE = 0x48;
0155 
0156         return 1;
0157     }
0158 
0159     return 0;
0160 }
0161 
0162 define_machine(amigaone) {
0163     .name           = "AmigaOne",
0164     .probe          = amigaone_probe,
0165     .setup_arch     = amigaone_setup_arch,
0166     .discover_phbs      = amigaone_discover_phbs,
0167     .show_cpuinfo       = amigaone_show_cpuinfo,
0168     .init_IRQ       = amigaone_init_IRQ,
0169     .restart        = amigaone_restart,
0170     .calibrate_decr     = generic_calibrate_decr,
0171     .progress       = udbg_progress,
0172 };