Path: blob/master/arch/powerpc/platforms/amigaone/setup.c
10819 views
/*1* AmigaOne platform setup2*3* Copyright 2008 Gerhard Pircher ([email protected])4*5* Based on original amigaone_setup.c source code6* Copyright 2003 by Hans-Joerg Frieden and Thomas Frieden7*8* This program is free software; you can redistribute it and/or modify it9* under the terms of the GNU General Public License as published by the10* Free Software Foundation; either version 2 of the License, or (at your11* option) any later version.12*/1314#include <linux/kernel.h>15#include <linux/of.h>16#include <linux/of_address.h>17#include <linux/seq_file.h>18#include <generated/utsrelease.h>1920#include <asm/machdep.h>21#include <asm/cputable.h>22#include <asm/pci-bridge.h>23#include <asm/i8259.h>24#include <asm/time.h>25#include <asm/udbg.h>2627extern void __flush_disable_L1(void);2829void amigaone_show_cpuinfo(struct seq_file *m)30{31seq_printf(m, "vendor\t\t: Eyetech Ltd.\n");32}3334static int __init amigaone_add_bridge(struct device_node *dev)35{36const u32 *cfg_addr, *cfg_data;37int len;38const int *bus_range;39struct pci_controller *hose;4041printk(KERN_INFO "Adding PCI host bridge %s\n", dev->full_name);4243cfg_addr = of_get_address(dev, 0, NULL, NULL);44cfg_data = of_get_address(dev, 1, NULL, NULL);45if ((cfg_addr == NULL) || (cfg_data == NULL))46return -ENODEV;4748bus_range = of_get_property(dev, "bus-range", &len);49if ((bus_range == NULL) || (len < 2 * sizeof(int)))50printk(KERN_WARNING "Can't get bus-range for %s, assume"51" bus 0\n", dev->full_name);5253hose = pcibios_alloc_controller(dev);54if (hose == NULL)55return -ENOMEM;5657hose->first_busno = bus_range ? bus_range[0] : 0;58hose->last_busno = bus_range ? bus_range[1] : 0xff;5960setup_indirect_pci(hose, cfg_addr[0], cfg_data[0], 0);6162/* Interpret the "ranges" property */63/* This also maps the I/O region and sets isa_io/mem_base */64pci_process_bridge_OF_ranges(hose, dev, 1);6566return 0;67}6869void __init amigaone_setup_arch(void)70{71struct device_node *np;72int phb = -ENODEV;7374/* Lookup PCI host bridges. */75for_each_compatible_node(np, "pci", "mai-logic,articia-s")76phb = amigaone_add_bridge(np);7778BUG_ON(phb != 0);7980if (ppc_md.progress)81ppc_md.progress("Linux/PPC "UTS_RELEASE"\n", 0);82}8384void __init amigaone_init_IRQ(void)85{86struct device_node *pic, *np = NULL;87const unsigned long *prop = NULL;88unsigned long int_ack = 0;8990/* Search for ISA interrupt controller. */91pic = of_find_compatible_node(NULL, "interrupt-controller",92"pnpPNP,000");93BUG_ON(pic == NULL);9495/* Look for interrupt acknowledge address in the PCI root node. */96np = of_find_compatible_node(NULL, "pci", "mai-logic,articia-s");97if (np) {98prop = of_get_property(np, "8259-interrupt-acknowledge", NULL);99if (prop)100int_ack = prop[0];101of_node_put(np);102}103104if (int_ack == 0)105printk(KERN_WARNING "Cannot find PCI interrupt acknowledge"106" address, polling\n");107108i8259_init(pic, int_ack);109ppc_md.get_irq = i8259_irq;110irq_set_default_host(i8259_get_host());111}112113static int __init request_isa_regions(void)114{115request_region(0x00, 0x20, "dma1");116request_region(0x40, 0x20, "timer");117request_region(0x80, 0x10, "dma page reg");118request_region(0xc0, 0x20, "dma2");119120return 0;121}122machine_device_initcall(amigaone, request_isa_regions);123124void amigaone_restart(char *cmd)125{126local_irq_disable();127128/* Flush and disable caches. */129__flush_disable_L1();130131/* Set SRR0 to the reset vector and turn on MSR_IP. */132mtspr(SPRN_SRR0, 0xfff00100);133mtspr(SPRN_SRR1, MSR_IP);134135/* Do an rfi to jump back to firmware. */136__asm__ __volatile__("rfi" : : : "memory");137138/* Not reached. */139while (1);140}141142static int __init amigaone_probe(void)143{144unsigned long root = of_get_flat_dt_root();145146if (of_flat_dt_is_compatible(root, "eyetech,amigaone")) {147/*148* Coherent memory access cause complete system lockup! Thus149* disable this CPU feature, even if the CPU needs it.150*/151cur_cpu_spec->cpu_features &= ~CPU_FTR_NEED_COHERENT;152153ISA_DMA_THRESHOLD = 0x00ffffff;154DMA_MODE_READ = 0x44;155DMA_MODE_WRITE = 0x48;156157return 1;158}159160return 0;161}162163define_machine(amigaone) {164.name = "AmigaOne",165.probe = amigaone_probe,166.setup_arch = amigaone_setup_arch,167.show_cpuinfo = amigaone_show_cpuinfo,168.init_IRQ = amigaone_init_IRQ,169.restart = amigaone_restart,170.calibrate_decr = generic_calibrate_decr,171.progress = udbg_progress,172};173174175