Path: blob/master/arch/powerpc/platforms/85xx/ksi8560.c
10820 views
/*1* Board setup routines for the Emerson KSI85602*3* Author: Alexandr Smirnov <[email protected]>4*5* Based on mpc85xx_ads.c maintained by Kumar Gala6*7* 2008 (c) MontaVista, Software, Inc. This file is licensed under8* the terms of the GNU General Public License version 2. This program9* is licensed "as is" without any warranty of any kind, whether express10* or implied.11*12*/1314#include <linux/stddef.h>15#include <linux/kernel.h>16#include <linux/pci.h>17#include <linux/kdev_t.h>18#include <linux/delay.h>19#include <linux/seq_file.h>20#include <linux/of_platform.h>2122#include <asm/system.h>23#include <asm/time.h>24#include <asm/machdep.h>25#include <asm/pci-bridge.h>26#include <asm/mpic.h>27#include <mm/mmu_decl.h>28#include <asm/udbg.h>29#include <asm/prom.h>3031#include <sysdev/fsl_soc.h>32#include <sysdev/fsl_pci.h>3334#include <asm/cpm2.h>35#include <sysdev/cpm2_pic.h>363738#define KSI8560_CPLD_HVR 0x04 /* Hardware Version Register */39#define KSI8560_CPLD_PVR 0x08 /* PLD Version Register */40#define KSI8560_CPLD_RCR1 0x30 /* Reset Command Register 1 */4142#define KSI8560_CPLD_RCR1_CPUHR 0x80 /* CPU Hard Reset */4344static void __iomem *cpld_base = NULL;4546static void machine_restart(char *cmd)47{48if (cpld_base)49out_8(cpld_base + KSI8560_CPLD_RCR1, KSI8560_CPLD_RCR1_CPUHR);50else51printk(KERN_ERR "Can't find CPLD base, hang forever\n");5253for (;;);54}5556static void cpm2_cascade(unsigned int irq, struct irq_desc *desc)57{58struct irq_chip *chip = irq_desc_get_chip(desc);59int cascade_irq;6061while ((cascade_irq = cpm2_get_irq()) >= 0)62generic_handle_irq(cascade_irq);6364chip->irq_eoi(&desc->irq_data);65}6667static void __init ksi8560_pic_init(void)68{69struct mpic *mpic;70struct resource r;71struct device_node *np;72#ifdef CONFIG_CPM273int irq;74#endif7576np = of_find_node_by_type(NULL, "open-pic");7778if (np == NULL) {79printk(KERN_ERR "Could not find open-pic node\n");80return;81}8283if (of_address_to_resource(np, 0, &r)) {84printk(KERN_ERR "Could not map mpic register space\n");85of_node_put(np);86return;87}8889mpic = mpic_alloc(np, r.start,90MPIC_PRIMARY | MPIC_WANTS_RESET | MPIC_BIG_ENDIAN,910, 256, " OpenPIC ");92BUG_ON(mpic == NULL);93of_node_put(np);9495mpic_init(mpic);9697#ifdef CONFIG_CPM298/* Setup CPM2 PIC */99np = of_find_compatible_node(NULL, NULL, "fsl,cpm2-pic");100if (np == NULL) {101printk(KERN_ERR "PIC init: can not find fsl,cpm2-pic node\n");102return;103}104irq = irq_of_parse_and_map(np, 0);105106cpm2_pic_init(np);107of_node_put(np);108irq_set_chained_handler(irq, cpm2_cascade);109#endif110}111112#ifdef CONFIG_CPM2113/*114* Setup I/O ports115*/116struct cpm_pin {117int port, pin, flags;118};119120static struct cpm_pin __initdata ksi8560_pins[] = {121/* SCC1 */122{3, 29, CPM_PIN_OUTPUT | CPM_PIN_PRIMARY},123{3, 30, CPM_PIN_OUTPUT | CPM_PIN_SECONDARY},124{3, 31, CPM_PIN_INPUT | CPM_PIN_PRIMARY},125126/* SCC2 */127{3, 26, CPM_PIN_OUTPUT | CPM_PIN_PRIMARY},128{3, 27, CPM_PIN_OUTPUT | CPM_PIN_PRIMARY},129{3, 28, CPM_PIN_INPUT | CPM_PIN_PRIMARY},130131/* FCC1 */132{0, 14, CPM_PIN_INPUT | CPM_PIN_PRIMARY},133{0, 15, CPM_PIN_INPUT | CPM_PIN_PRIMARY},134{0, 16, CPM_PIN_INPUT | CPM_PIN_PRIMARY},135{0, 17, CPM_PIN_INPUT | CPM_PIN_PRIMARY},136{0, 18, CPM_PIN_OUTPUT | CPM_PIN_PRIMARY},137{0, 19, CPM_PIN_OUTPUT | CPM_PIN_PRIMARY},138{0, 20, CPM_PIN_OUTPUT | CPM_PIN_PRIMARY},139{0, 21, CPM_PIN_OUTPUT | CPM_PIN_PRIMARY},140{0, 26, CPM_PIN_INPUT | CPM_PIN_SECONDARY},141{0, 27, CPM_PIN_INPUT | CPM_PIN_SECONDARY},142{0, 28, CPM_PIN_OUTPUT | CPM_PIN_SECONDARY},143{0, 29, CPM_PIN_OUTPUT | CPM_PIN_SECONDARY},144{0, 30, CPM_PIN_INPUT | CPM_PIN_SECONDARY},145{0, 31, CPM_PIN_INPUT | CPM_PIN_SECONDARY},146{2, 23, CPM_PIN_INPUT | CPM_PIN_PRIMARY}, /* CLK9 */147{2, 22, CPM_PIN_INPUT | CPM_PIN_PRIMARY}, /* CLK10 */148149};150151static void __init init_ioports(void)152{153int i;154155for (i = 0; i < ARRAY_SIZE(ksi8560_pins); i++) {156struct cpm_pin *pin = &ksi8560_pins[i];157cpm2_set_pin(pin->port, pin->pin, pin->flags);158}159160cpm2_clk_setup(CPM_CLK_SCC1, CPM_BRG1, CPM_CLK_RX);161cpm2_clk_setup(CPM_CLK_SCC1, CPM_BRG1, CPM_CLK_TX);162cpm2_clk_setup(CPM_CLK_SCC2, CPM_BRG2, CPM_CLK_RX);163cpm2_clk_setup(CPM_CLK_SCC2, CPM_BRG2, CPM_CLK_TX);164cpm2_clk_setup(CPM_CLK_FCC1, CPM_CLK9, CPM_CLK_RX);165cpm2_clk_setup(CPM_CLK_FCC1, CPM_CLK10, CPM_CLK_TX);166}167#endif168169/*170* Setup the architecture171*/172static void __init ksi8560_setup_arch(void)173{174struct device_node *cpld;175176cpld = of_find_compatible_node(NULL, NULL, "emerson,KSI8560-cpld");177if (cpld)178cpld_base = of_iomap(cpld, 0);179else180printk(KERN_ERR "Can't find CPLD in device tree\n");181182if (ppc_md.progress)183ppc_md.progress("ksi8560_setup_arch()", 0);184185#ifdef CONFIG_CPM2186cpm2_reset();187init_ioports();188#endif189}190191static void ksi8560_show_cpuinfo(struct seq_file *m)192{193uint pvid, svid, phid1;194195pvid = mfspr(SPRN_PVR);196svid = mfspr(SPRN_SVR);197198seq_printf(m, "Vendor\t\t: Emerson Network Power\n");199seq_printf(m, "Board\t\t: KSI8560\n");200201if (cpld_base) {202seq_printf(m, "Hardware rev\t: %d\n",203in_8(cpld_base + KSI8560_CPLD_HVR));204seq_printf(m, "CPLD rev\t: %d\n",205in_8(cpld_base + KSI8560_CPLD_PVR));206} else207seq_printf(m, "Unknown Hardware and CPLD revs\n");208209seq_printf(m, "PVR\t\t: 0x%x\n", pvid);210seq_printf(m, "SVR\t\t: 0x%x\n", svid);211212/* Display cpu Pll setting */213phid1 = mfspr(SPRN_HID1);214seq_printf(m, "PLL setting\t: 0x%x\n", ((phid1 >> 24) & 0x3f));215}216217static struct of_device_id __initdata of_bus_ids[] = {218{ .type = "soc", },219{ .type = "simple-bus", },220{ .name = "cpm", },221{ .name = "localbus", },222{ .compatible = "gianfar", },223{},224};225226static int __init declare_of_platform_devices(void)227{228of_platform_bus_probe(NULL, of_bus_ids, NULL);229230return 0;231}232machine_device_initcall(ksi8560, declare_of_platform_devices);233234/*235* Called very early, device-tree isn't unflattened236*/237static int __init ksi8560_probe(void)238{239unsigned long root = of_get_flat_dt_root();240241return of_flat_dt_is_compatible(root, "emerson,KSI8560");242}243244define_machine(ksi8560) {245.name = "KSI8560",246.probe = ksi8560_probe,247.setup_arch = ksi8560_setup_arch,248.init_IRQ = ksi8560_pic_init,249.show_cpuinfo = ksi8560_show_cpuinfo,250.get_irq = mpic_get_irq,251.restart = machine_restart,252.calibrate_decr = generic_calibrate_decr,253};254255256