xref: /openbmc/linux/arch/powerpc/platforms/embedded6xx/storcenter.c (revision 1ac731c529cd4d6adbce134754b51ff7d822b145)
13490cba5SJon Loeliger /*
23490cba5SJon Loeliger  * Board setup routines for the storcenter
33490cba5SJon Loeliger  *
43490cba5SJon Loeliger  * Copyright 2007 (C) Oyvind Repvik (nail@nslu2-linux.org)
53490cba5SJon Loeliger  * Copyright 2007 Andy Wilcox, Jon Loeliger
63490cba5SJon Loeliger  *
73490cba5SJon Loeliger  * Based on linkstation.c by G. Liakhovetski
83490cba5SJon Loeliger  *
93490cba5SJon Loeliger  * This file is licensed under the terms of the GNU General Public License
103490cba5SJon Loeliger  * version 2.  This program is licensed "as is" without any warranty of
113490cba5SJon Loeliger  * any kind, whether express or implied.
123490cba5SJon Loeliger  */
133490cba5SJon Loeliger 
143490cba5SJon Loeliger #include <linux/kernel.h>
153490cba5SJon Loeliger #include <linux/pci.h>
163490cba5SJon Loeliger #include <linux/initrd.h>
173490cba5SJon Loeliger #include <linux/of_platform.h>
183490cba5SJon Loeliger 
193490cba5SJon Loeliger #include <asm/time.h>
203490cba5SJon Loeliger #include <asm/mpic.h>
213490cba5SJon Loeliger #include <asm/pci-bridge.h>
223490cba5SJon Loeliger 
233490cba5SJon Loeliger #include "mpc10x.h"
243490cba5SJon Loeliger 
253490cba5SJon Loeliger 
26ce6d73c9SUwe Kleine-König static const struct of_device_id storcenter_of_bus[] __initconst = {
273490cba5SJon Loeliger 	{ .name = "soc", },
283490cba5SJon Loeliger 	{},
293490cba5SJon Loeliger };
303490cba5SJon Loeliger 
storcenter_device_probe(void)313490cba5SJon Loeliger static int __init storcenter_device_probe(void)
323490cba5SJon Loeliger {
333490cba5SJon Loeliger 	of_platform_bus_probe(NULL, storcenter_of_bus, NULL);
343490cba5SJon Loeliger 	return 0;
353490cba5SJon Loeliger }
363490cba5SJon Loeliger machine_device_initcall(storcenter, storcenter_device_probe);
373490cba5SJon Loeliger 
383490cba5SJon Loeliger 
storcenter_add_bridge(struct device_node * dev)393490cba5SJon Loeliger static int __init storcenter_add_bridge(struct device_node *dev)
403490cba5SJon Loeliger {
413490cba5SJon Loeliger #ifdef CONFIG_PCI
423490cba5SJon Loeliger 	int len;
433490cba5SJon Loeliger 	struct pci_controller *hose;
443490cba5SJon Loeliger 	const int *bus_range;
453490cba5SJon Loeliger 
46b7c670d6SRob Herring 	printk("Adding PCI host bridge %pOF\n", dev);
473490cba5SJon Loeliger 
483490cba5SJon Loeliger 	hose = pcibios_alloc_controller(dev);
493490cba5SJon Loeliger 	if (hose == NULL)
503490cba5SJon Loeliger 		return -ENOMEM;
513490cba5SJon Loeliger 
523490cba5SJon Loeliger 	bus_range = of_get_property(dev, "bus-range", &len);
533490cba5SJon Loeliger 	hose->first_busno = bus_range ? bus_range[0] : 0;
543490cba5SJon Loeliger 	hose->last_busno = bus_range ? bus_range[1] : 0xff;
553490cba5SJon Loeliger 
563490cba5SJon Loeliger 	setup_indirect_pci(hose, MPC10X_MAPB_CNFG_ADDR, MPC10X_MAPB_CNFG_DATA, 0);
573490cba5SJon Loeliger 
583490cba5SJon Loeliger 	/* Interpret the "ranges" property */
593490cba5SJon Loeliger 	/* This also maps the I/O region and sets isa_io/mem_base */
603490cba5SJon Loeliger 	pci_process_bridge_OF_ranges(hose, dev, 1);
613490cba5SJon Loeliger #endif
623490cba5SJon Loeliger 
633490cba5SJon Loeliger 	return 0;
643490cba5SJon Loeliger }
653490cba5SJon Loeliger 
storcenter_setup_arch(void)663490cba5SJon Loeliger static void __init storcenter_setup_arch(void)
673490cba5SJon Loeliger {
68d20a864fSOliver O'Halloran 	printk(KERN_INFO "IOMEGA StorCenter\n");
69d20a864fSOliver O'Halloran }
70d20a864fSOliver O'Halloran 
storcenter_setup_pci(void)71d20a864fSOliver O'Halloran static void __init storcenter_setup_pci(void)
72d20a864fSOliver O'Halloran {
733490cba5SJon Loeliger 	struct device_node *np;
743490cba5SJon Loeliger 
753490cba5SJon Loeliger 	/* Lookup PCI host bridges */
763490cba5SJon Loeliger 	for_each_compatible_node(np, "pci", "mpc10x-pci")
773490cba5SJon Loeliger 		storcenter_add_bridge(np);
783490cba5SJon Loeliger }
793490cba5SJon Loeliger 
803490cba5SJon Loeliger /*
81fb914ebfSVitaliy Ivanov  * Interrupt setup and service.  Interrupts on the turbostation come
823490cba5SJon Loeliger  * from the four PCI slots plus onboard 8241 devices: I2C, DUART.
833490cba5SJon Loeliger  */
storcenter_init_IRQ(void)843490cba5SJon Loeliger static void __init storcenter_init_IRQ(void)
853490cba5SJon Loeliger {
863490cba5SJon Loeliger 	struct mpic *mpic;
873490cba5SJon Loeliger 
88e55d7f73SKyle Moffett 	mpic = mpic_alloc(NULL, 0, 0, 16, 0, " OpenPIC  ");
893490cba5SJon Loeliger 	BUG_ON(mpic == NULL);
903490cba5SJon Loeliger 
913490cba5SJon Loeliger 	/*
920367aad1SJon Loeliger 	 * 16 Serial Interrupts followed by 16 Internal Interrupts.
930367aad1SJon Loeliger 	 * I2C is the second internal, so it is at 17, 0x11020.
943490cba5SJon Loeliger 	 */
95e7a98675SKyle Moffett 	mpic_assign_isu(mpic, 0, mpic->paddr + 0x10200);
96e7a98675SKyle Moffett 	mpic_assign_isu(mpic, 1, mpic->paddr + 0x11000);
973490cba5SJon Loeliger 
983490cba5SJon Loeliger 	mpic_init(mpic);
993490cba5SJon Loeliger }
1003490cba5SJon Loeliger 
storcenter_restart(char * cmd)10195ec77c0SDaniel Axtens static void __noreturn storcenter_restart(char *cmd)
1023490cba5SJon Loeliger {
1033490cba5SJon Loeliger 	local_irq_disable();
1043490cba5SJon Loeliger 
1053490cba5SJon Loeliger 	/* Set exception prefix high - to the firmware */
106e53281bcSChristophe Leroy 	mtmsr(mfmsr() | MSR_IP);
107e53281bcSChristophe Leroy 	isync();
1083490cba5SJon Loeliger 
1093490cba5SJon Loeliger 	/* Wait for reset to happen */
1103490cba5SJon Loeliger 	for (;;) ;
1113490cba5SJon Loeliger }
1123490cba5SJon Loeliger 
define_machine(storcenter)1133490cba5SJon Loeliger define_machine(storcenter){
1143490cba5SJon Loeliger 	.name 			= "IOMEGA StorCenter",
115*1c96fcdeSChristophe Leroy 	.compatible		= "iomega,storcenter",
1163490cba5SJon Loeliger 	.setup_arch 		= storcenter_setup_arch,
117d20a864fSOliver O'Halloran 	.discover_phbs 		= storcenter_setup_pci,
1183490cba5SJon Loeliger 	.init_IRQ 		= storcenter_init_IRQ,
1193490cba5SJon Loeliger 	.get_irq 		= mpic_get_irq,
1203490cba5SJon Loeliger 	.restart 		= storcenter_restart,
1213490cba5SJon Loeliger };
122