Path: blob/master/arch/powerpc/platforms/83xx/km83xx.c
10819 views
/*1* Copyright 2008-2011 DENX Software Engineering GmbH2* Author: Heiko Schocher <[email protected]>3*4* Description:5* Keymile KMETER1 board specific routines.6*7* This program is free software; you can redistribute it and/or modify it8* under the terms of the GNU General Public License as published by the9* Free Software Foundation; either version 2 of the License, or (at your10* option) any later version.11*/1213#include <linux/stddef.h>14#include <linux/kernel.h>15#include <linux/init.h>16#include <linux/errno.h>17#include <linux/reboot.h>18#include <linux/pci.h>19#include <linux/kdev_t.h>20#include <linux/major.h>21#include <linux/console.h>22#include <linux/delay.h>23#include <linux/seq_file.h>24#include <linux/root_dev.h>25#include <linux/initrd.h>26#include <linux/of_platform.h>27#include <linux/of_device.h>2829#include <asm/system.h>30#include <asm/atomic.h>31#include <asm/time.h>32#include <asm/io.h>33#include <asm/machdep.h>34#include <asm/ipic.h>35#include <asm/irq.h>36#include <asm/prom.h>37#include <asm/udbg.h>38#include <sysdev/fsl_soc.h>39#include <sysdev/fsl_pci.h>40#include <asm/qe.h>41#include <asm/qe_ic.h>4243#include "mpc83xx.h"4445#define SVR_REV(svr) (((svr) >> 0) & 0xFFFF) /* Revision field */46/* ************************************************************************47*48* Setup the architecture49*50*/51static void __init mpc83xx_km_setup_arch(void)52{53struct device_node *np;5455if (ppc_md.progress)56ppc_md.progress("kmpbec83xx_setup_arch()", 0);5758#ifdef CONFIG_PCI59for_each_compatible_node(np, "pci", "fsl,mpc8349-pci")60mpc83xx_add_bridge(np);61#endif6263#ifdef CONFIG_QUICC_ENGINE64qe_reset();6566np = of_find_node_by_name(NULL, "par_io");67if (np != NULL) {68par_io_init(np);69of_node_put(np);7071for_each_node_by_name(np, "spi")72par_io_of_config(np);7374for (np = NULL; (np = of_find_node_by_name(np, "ucc")) != NULL;)75par_io_of_config(np);76}7778np = of_find_compatible_node(NULL, "network", "ucc_geth");79if (np != NULL) {80uint svid;8182/* handle mpc8360ea rev.2.1 erratum 2: RGMII Timing */83svid = mfspr(SPRN_SVR);84if (SVR_REV(svid) == 0x0021) {85struct device_node *np_par;86struct resource res;87void __iomem *base;88int ret;8990np_par = of_find_node_by_name(NULL, "par_io");91if (np_par == NULL) {92printk(KERN_WARNING "%s couldn;t find par_io node\n",93__func__);94return;95}96/* Map Parallel I/O ports registers */97ret = of_address_to_resource(np_par, 0, &res);98if (ret) {99printk(KERN_WARNING "%s couldn;t map par_io registers\n",100__func__);101return;102}103base = ioremap(res.start, res.end - res.start + 1);104105/*106* IMMR + 0x14A8[4:5] = 11 (clk delay for UCC 2)107* IMMR + 0x14A8[18:19] = 11 (clk delay for UCC 1)108*/109setbits32((base + 0xa8), 0x0c003000);110111/*112* IMMR + 0x14AC[20:27] = 10101010113* (data delay for both UCC's)114*/115clrsetbits_be32((base + 0xac), 0xff0, 0xaa0);116iounmap(base);117of_node_put(np_par);118}119of_node_put(np);120}121#endif /* CONFIG_QUICC_ENGINE */122}123124static struct of_device_id kmpbec83xx_ids[] = {125{ .type = "soc", },126{ .compatible = "soc", },127{ .compatible = "simple-bus", },128{ .type = "qe", },129{ .compatible = "fsl,qe", },130{},131};132133static int __init kmeter_declare_of_platform_devices(void)134{135/* Publish the QE devices */136of_platform_bus_probe(NULL, kmpbec83xx_ids, NULL);137138return 0;139}140machine_device_initcall(mpc83xx_km, kmeter_declare_of_platform_devices);141142static void __init mpc83xx_km_init_IRQ(void)143{144struct device_node *np;145146np = of_find_compatible_node(NULL, NULL, "fsl,pq2pro-pic");147if (!np) {148np = of_find_node_by_type(NULL, "ipic");149if (!np)150return;151}152153ipic_init(np, 0);154155/* Initialize the default interrupt mapping priorities,156* in case the boot rom changed something on us.157*/158ipic_set_default_priority();159of_node_put(np);160161#ifdef CONFIG_QUICC_ENGINE162np = of_find_compatible_node(NULL, NULL, "fsl,qe-ic");163if (!np) {164np = of_find_node_by_type(NULL, "qeic");165if (!np)166return;167}168qe_ic_init(np, 0, qe_ic_cascade_low_ipic, qe_ic_cascade_high_ipic);169of_node_put(np);170#endif /* CONFIG_QUICC_ENGINE */171}172173/* list of the supported boards */174static char *board[] __initdata = {175"Keymile,KMETER1",176"Keymile,kmpbec8321",177NULL178};179180/*181* Called very early, MMU is off, device-tree isn't unflattened182*/183static int __init mpc83xx_km_probe(void)184{185unsigned long node = of_get_flat_dt_root();186int i = 0;187188while (board[i]) {189if (of_flat_dt_is_compatible(node, board[i]))190break;191i++;192}193return (board[i] != NULL);194}195196define_machine(mpc83xx_km) {197.name = "mpc83xx-km-platform",198.probe = mpc83xx_km_probe,199.setup_arch = mpc83xx_km_setup_arch,200.init_IRQ = mpc83xx_km_init_IRQ,201.get_irq = ipic_get_irq,202.restart = mpc83xx_restart,203.time_init = mpc83xx_time_init,204.calibrate_decr = generic_calibrate_decr,205.progress = udbg_progress,206};207208209