Path: blob/master/arch/powerpc/platforms/embedded6xx/linkstation.c
10818 views
/*1* Board setup routines for the Buffalo Linkstation / Kurobox Platform.2*3* Copyright (C) 2006 G. Liakhovetski ([email protected])4*5* Based on sandpoint.c by Mark A. Greer6*7* This file is licensed under the terms of the GNU General Public License8* version 2. This program is licensed "as is" without any warranty of9* any kind, whether express or implied.10*/1112#include <linux/kernel.h>13#include <linux/initrd.h>14#include <linux/of_platform.h>1516#include <asm/time.h>17#include <asm/prom.h>18#include <asm/mpic.h>19#include <asm/pci-bridge.h>2021#include "mpc10x.h"2223static __initdata struct of_device_id of_bus_ids[] = {24{ .type = "soc", },25{ .compatible = "simple-bus", },26{},27};2829static int __init declare_of_platform_devices(void)30{31of_platform_bus_probe(NULL, of_bus_ids, NULL);32return 0;33}34machine_device_initcall(linkstation, declare_of_platform_devices);3536static int __init linkstation_add_bridge(struct device_node *dev)37{38#ifdef CONFIG_PCI39int len;40struct pci_controller *hose;41const int *bus_range;4243printk("Adding PCI host bridge %s\n", dev->full_name);4445bus_range = of_get_property(dev, "bus-range", &len);46if (bus_range == NULL || len < 2 * sizeof(int))47printk(KERN_WARNING "Can't get bus-range for %s, assume"48" bus 0\n", dev->full_name);4950hose = pcibios_alloc_controller(dev);51if (hose == NULL)52return -ENOMEM;53hose->first_busno = bus_range ? bus_range[0] : 0;54hose->last_busno = bus_range ? bus_range[1] : 0xff;55setup_indirect_pci(hose, 0xfec00000, 0xfee00000, 0);5657/* Interpret the "ranges" property */58/* This also maps the I/O region and sets isa_io/mem_base */59pci_process_bridge_OF_ranges(hose, dev, 1);60#endif61return 0;62}6364static void __init linkstation_setup_arch(void)65{66struct device_node *np;6768/* Lookup PCI host bridges */69for_each_compatible_node(np, "pci", "mpc10x-pci")70linkstation_add_bridge(np);7172printk(KERN_INFO "BUFFALO Network Attached Storage Series\n");73printk(KERN_INFO "(C) 2002-2005 BUFFALO INC.\n");74}7576/*77* Interrupt setup and service. Interrupts on the linkstation come78* from the four PCI slots plus onboard 8241 devices: I2C, DUART.79*/80static void __init linkstation_init_IRQ(void)81{82struct mpic *mpic;83struct device_node *dnp;84const u32 *prop;85int size;86phys_addr_t paddr;8788dnp = of_find_node_by_type(NULL, "open-pic");89if (dnp == NULL)90return;9192prop = of_get_property(dnp, "reg", &size);93paddr = (phys_addr_t)of_translate_address(dnp, prop);9495mpic = mpic_alloc(dnp, paddr, MPIC_PRIMARY | MPIC_WANTS_RESET, 4, 32, " EPIC ");96BUG_ON(mpic == NULL);9798/* PCI IRQs */99mpic_assign_isu(mpic, 0, paddr + 0x10200);100101/* I2C */102mpic_assign_isu(mpic, 1, paddr + 0x11000);103104/* ttyS0, ttyS1 */105mpic_assign_isu(mpic, 2, paddr + 0x11100);106107mpic_init(mpic);108}109110extern void avr_uart_configure(void);111extern void avr_uart_send(const char);112113static void linkstation_restart(char *cmd)114{115local_irq_disable();116117/* Reset system via AVR */118avr_uart_configure();119/* Send reboot command */120avr_uart_send('C');121122for(;;) /* Spin until reset happens */123avr_uart_send('G'); /* "kick" */124}125126static void linkstation_power_off(void)127{128local_irq_disable();129130/* Power down system via AVR */131avr_uart_configure();132/* send shutdown command */133avr_uart_send('E');134135for(;;) /* Spin until power-off happens */136avr_uart_send('G'); /* "kick" */137/* NOTREACHED */138}139140static void linkstation_halt(void)141{142linkstation_power_off();143/* NOTREACHED */144}145146static void linkstation_show_cpuinfo(struct seq_file *m)147{148seq_printf(m, "vendor\t\t: Buffalo Technology\n");149seq_printf(m, "machine\t\t: Linkstation I/Kurobox(HG)\n");150}151152static int __init linkstation_probe(void)153{154unsigned long root;155156root = of_get_flat_dt_root();157158if (!of_flat_dt_is_compatible(root, "linkstation"))159return 0;160return 1;161}162163define_machine(linkstation){164.name = "Buffalo Linkstation",165.probe = linkstation_probe,166.setup_arch = linkstation_setup_arch,167.init_IRQ = linkstation_init_IRQ,168.show_cpuinfo = linkstation_show_cpuinfo,169.get_irq = mpic_get_irq,170.restart = linkstation_restart,171.power_off = linkstation_power_off,172.halt = linkstation_halt,173.calibrate_decr = generic_calibrate_decr,174};175176177