Path: blob/master/arch/powerpc/platforms/embedded6xx/linkstation.c
26489 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>15#include <linux/seq_file.h>1617#include <asm/time.h>18#include <asm/mpic.h>19#include <asm/pci-bridge.h>2021#include "mpc10x.h"2223static const struct of_device_id of_bus_ids[] __initconst = {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 %pOF\n", dev);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 %pOF, assume"48" bus 0\n", dev);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{66printk(KERN_INFO "BUFFALO Network Attached Storage Series\n");67printk(KERN_INFO "(C) 2002-2005 BUFFALO INC.\n");68}6970static void __init linkstation_setup_pci(void)71{72struct device_node *np;7374/* Lookup PCI host bridges */75for_each_compatible_node(np, "pci", "mpc10x-pci")76linkstation_add_bridge(np);77}7879/*80* Interrupt setup and service. Interrupts on the linkstation come81* from the four PCI slots plus onboard 8241 devices: I2C, DUART.82*/83static void __init linkstation_init_IRQ(void)84{85struct mpic *mpic;8687mpic = mpic_alloc(NULL, 0, 0, 4, 0, " EPIC ");88BUG_ON(mpic == NULL);8990/* PCI IRQs */91mpic_assign_isu(mpic, 0, mpic->paddr + 0x10200);9293/* I2C */94mpic_assign_isu(mpic, 1, mpic->paddr + 0x11000);9596/* ttyS0, ttyS1 */97mpic_assign_isu(mpic, 2, mpic->paddr + 0x11100);9899mpic_init(mpic);100}101102static void __noreturn linkstation_restart(char *cmd)103{104local_irq_disable();105106/* Reset system via AVR */107avr_uart_configure();108/* Send reboot command */109avr_uart_send('C');110111for(;;) /* Spin until reset happens */112avr_uart_send('G'); /* "kick" */113}114115static void __noreturn linkstation_power_off(void)116{117local_irq_disable();118119/* Power down system via AVR */120avr_uart_configure();121/* send shutdown command */122avr_uart_send('E');123124for(;;) /* Spin until power-off happens */125avr_uart_send('G'); /* "kick" */126/* NOTREACHED */127}128129static void __noreturn linkstation_halt(void)130{131linkstation_power_off();132/* NOTREACHED */133}134135static void linkstation_show_cpuinfo(struct seq_file *m)136{137seq_printf(m, "vendor\t\t: Buffalo Technology\n");138seq_printf(m, "machine\t\t: Linkstation I/Kurobox(HG)\n");139}140141static int __init linkstation_probe(void)142{143pm_power_off = linkstation_power_off;144145return 1;146}147148define_machine(linkstation){149.name = "Buffalo Linkstation",150.compatible = "linkstation",151.probe = linkstation_probe,152.setup_arch = linkstation_setup_arch,153.discover_phbs = linkstation_setup_pci,154.init_IRQ = linkstation_init_IRQ,155.show_cpuinfo = linkstation_show_cpuinfo,156.get_irq = mpic_get_irq,157.restart = linkstation_restart,158.halt = linkstation_halt,159};160161162