Path: blob/master/arch/powerpc/platforms/83xx/mpc836x_mds.c
10819 views
/*1* Copyright (C) Freescale Semicondutor, Inc. 2006. All rights reserved.2*3* Author: Li Yang <[email protected]>4* Yin Olivia <[email protected]>5*6* Description:7* MPC8360E MDS board specific routines.8*9* Changelog:10* Jun 21, 2006 Initial version11*12* This program is free software; you can redistribute it and/or modify it13* under the terms of the GNU General Public License as published by the14* Free Software Foundation; either version 2 of the License, or (at your15* option) any later version.16*/1718#include <linux/stddef.h>19#include <linux/kernel.h>20#include <linux/compiler.h>21#include <linux/init.h>22#include <linux/errno.h>23#include <linux/reboot.h>24#include <linux/pci.h>25#include <linux/kdev_t.h>26#include <linux/major.h>27#include <linux/console.h>28#include <linux/delay.h>29#include <linux/seq_file.h>30#include <linux/root_dev.h>31#include <linux/initrd.h>32#include <linux/of_platform.h>33#include <linux/of_device.h>3435#include <asm/system.h>36#include <asm/atomic.h>37#include <asm/time.h>38#include <asm/io.h>39#include <asm/machdep.h>40#include <asm/ipic.h>41#include <asm/irq.h>42#include <asm/prom.h>43#include <asm/udbg.h>44#include <sysdev/fsl_soc.h>45#include <sysdev/fsl_pci.h>46#include <sysdev/simple_gpio.h>47#include <asm/qe.h>48#include <asm/qe_ic.h>4950#include "mpc83xx.h"5152#undef DEBUG53#ifdef DEBUG54#define DBG(fmt...) udbg_printf(fmt)55#else56#define DBG(fmt...)57#endif5859/* ************************************************************************60*61* Setup the architecture62*63*/64static void __init mpc836x_mds_setup_arch(void)65{66struct device_node *np;67u8 __iomem *bcsr_regs = NULL;6869if (ppc_md.progress)70ppc_md.progress("mpc836x_mds_setup_arch()", 0);7172/* Map BCSR area */73np = of_find_node_by_name(NULL, "bcsr");74if (np) {75struct resource res;7677of_address_to_resource(np, 0, &res);78bcsr_regs = ioremap(res.start, res.end - res.start +1);79of_node_put(np);80}8182#ifdef CONFIG_PCI83for_each_compatible_node(np, "pci", "fsl,mpc8349-pci")84mpc83xx_add_bridge(np);85#endif8687#ifdef CONFIG_QUICC_ENGINE88qe_reset();8990if ((np = of_find_node_by_name(NULL, "par_io")) != NULL) {91par_io_init(np);92of_node_put(np);9394for (np = NULL; (np = of_find_node_by_name(np, "ucc")) != NULL;)95par_io_of_config(np);96#ifdef CONFIG_QE_USB97/* Must fixup Par IO before QE GPIO chips are registered. */98par_io_config_pin(1, 2, 1, 0, 3, 0); /* USBOE */99par_io_config_pin(1, 3, 1, 0, 3, 0); /* USBTP */100par_io_config_pin(1, 8, 1, 0, 1, 0); /* USBTN */101par_io_config_pin(1, 10, 2, 0, 3, 0); /* USBRXD */102par_io_config_pin(1, 9, 2, 1, 3, 0); /* USBRP */103par_io_config_pin(1, 11, 2, 1, 3, 0); /* USBRN */104par_io_config_pin(2, 20, 2, 0, 1, 0); /* CLK21 */105#endif /* CONFIG_QE_USB */106}107108if ((np = of_find_compatible_node(NULL, "network", "ucc_geth"))109!= NULL){110uint svid;111112/* Reset the Ethernet PHY */113#define BCSR9_GETHRST 0x20114clrbits8(&bcsr_regs[9], BCSR9_GETHRST);115udelay(1000);116setbits8(&bcsr_regs[9], BCSR9_GETHRST);117118/* handle mpc8360ea rev.2.1 erratum 2: RGMII Timing */119svid = mfspr(SPRN_SVR);120if (svid == 0x80480021) {121void __iomem *immap;122123immap = ioremap(get_immrbase() + 0x14a8, 8);124125/*126* IMMR + 0x14A8[4:5] = 11 (clk delay for UCC 2)127* IMMR + 0x14A8[18:19] = 11 (clk delay for UCC 1)128*/129setbits32(immap, 0x0c003000);130131/*132* IMMR + 0x14AC[20:27] = 10101010133* (data delay for both UCC's)134*/135clrsetbits_be32(immap + 4, 0xff0, 0xaa0);136137iounmap(immap);138}139140iounmap(bcsr_regs);141of_node_put(np);142}143#endif /* CONFIG_QUICC_ENGINE */144}145146static struct of_device_id mpc836x_ids[] = {147{ .type = "soc", },148{ .compatible = "soc", },149{ .compatible = "simple-bus", },150{ .type = "qe", },151{ .compatible = "fsl,qe", },152{},153};154155static int __init mpc836x_declare_of_platform_devices(void)156{157/* Publish the QE devices */158of_platform_bus_probe(NULL, mpc836x_ids, NULL);159160return 0;161}162machine_device_initcall(mpc836x_mds, mpc836x_declare_of_platform_devices);163164#ifdef CONFIG_QE_USB165static int __init mpc836x_usb_cfg(void)166{167u8 __iomem *bcsr;168struct device_node *np;169const char *mode;170int ret = 0;171172np = of_find_compatible_node(NULL, NULL, "fsl,mpc8360mds-bcsr");173if (!np)174return -ENODEV;175176bcsr = of_iomap(np, 0);177of_node_put(np);178if (!bcsr)179return -ENOMEM;180181np = of_find_compatible_node(NULL, NULL, "fsl,mpc8323-qe-usb");182if (!np) {183ret = -ENODEV;184goto err;185}186187#define BCSR8_TSEC1M_MASK (0x3 << 6)188#define BCSR8_TSEC1M_RGMII (0x0 << 6)189#define BCSR8_TSEC2M_MASK (0x3 << 4)190#define BCSR8_TSEC2M_RGMII (0x0 << 4)191/*192* Default is GMII (2), but we should set it to RGMII (0) if we use193* USB (Eth PHY is in RGMII mode anyway).194*/195clrsetbits_8(&bcsr[8], BCSR8_TSEC1M_MASK | BCSR8_TSEC2M_MASK,196BCSR8_TSEC1M_RGMII | BCSR8_TSEC2M_RGMII);197198#define BCSR13_USBMASK 0x0f199#define BCSR13_nUSBEN 0x08 /* 1 - Disable, 0 - Enable */200#define BCSR13_USBSPEED 0x04 /* 1 - Full, 0 - Low */201#define BCSR13_USBMODE 0x02 /* 1 - Host, 0 - Function */202#define BCSR13_nUSBVCC 0x01 /* 1 - gets VBUS, 0 - supplies VBUS */203204clrsetbits_8(&bcsr[13], BCSR13_USBMASK, BCSR13_USBSPEED);205206mode = of_get_property(np, "mode", NULL);207if (mode && !strcmp(mode, "peripheral")) {208setbits8(&bcsr[13], BCSR13_nUSBVCC);209qe_usb_clock_set(QE_CLK21, 48000000);210} else {211setbits8(&bcsr[13], BCSR13_USBMODE);212/*213* The BCSR GPIOs are used to control power and214* speed of the USB transceiver. This is needed for215* the USB Host only.216*/217simple_gpiochip_init("fsl,mpc8360mds-bcsr-gpio");218}219220of_node_put(np);221err:222iounmap(bcsr);223return ret;224}225machine_arch_initcall(mpc836x_mds, mpc836x_usb_cfg);226#endif /* CONFIG_QE_USB */227228static void __init mpc836x_mds_init_IRQ(void)229{230struct device_node *np;231232np = of_find_node_by_type(NULL, "ipic");233if (!np)234return;235236ipic_init(np, 0);237238/* Initialize the default interrupt mapping priorities,239* in case the boot rom changed something on us.240*/241ipic_set_default_priority();242of_node_put(np);243244#ifdef CONFIG_QUICC_ENGINE245np = of_find_compatible_node(NULL, NULL, "fsl,qe-ic");246if (!np) {247np = of_find_node_by_type(NULL, "qeic");248if (!np)249return;250}251qe_ic_init(np, 0, qe_ic_cascade_low_ipic, qe_ic_cascade_high_ipic);252of_node_put(np);253#endif /* CONFIG_QUICC_ENGINE */254}255256/*257* Called very early, MMU is off, device-tree isn't unflattened258*/259static int __init mpc836x_mds_probe(void)260{261unsigned long root = of_get_flat_dt_root();262263return of_flat_dt_is_compatible(root, "MPC836xMDS");264}265266define_machine(mpc836x_mds) {267.name = "MPC836x MDS",268.probe = mpc836x_mds_probe,269.setup_arch = mpc836x_mds_setup_arch,270.init_IRQ = mpc836x_mds_init_IRQ,271.get_irq = ipic_get_irq,272.restart = mpc83xx_restart,273.time_init = mpc83xx_time_init,274.calibrate_decr = generic_calibrate_decr,275.progress = udbg_progress,276};277278279