Path: blob/master/arch/powerpc/platforms/83xx/mpc837x_mds.c
10818 views
/*1* arch/powerpc/platforms/83xx/mpc837x_mds.c2*3* Copyright (C) 2007 Freescale Semiconductor, Inc. All rights reserved.4*5* MPC837x MDS board specific routines6*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/pci.h>14#include <linux/of.h>15#include <linux/of_platform.h>1617#include <asm/time.h>18#include <asm/ipic.h>19#include <asm/udbg.h>20#include <asm/prom.h>21#include <sysdev/fsl_pci.h>2223#include "mpc83xx.h"2425#define BCSR12_USB_SER_MASK 0x8a26#define BCSR12_USB_SER_PIN 0x8027#define BCSR12_USB_SER_DEVICE 0x022829static int mpc837xmds_usb_cfg(void)30{31struct device_node *np;32const void *phy_type, *mode;33void __iomem *bcsr_regs = NULL;34u8 bcsr12;35int ret;3637ret = mpc837x_usb_cfg();38if (ret)39return ret;40/* Map BCSR area */41np = of_find_compatible_node(NULL, NULL, "fsl,mpc837xmds-bcsr");42if (np) {43bcsr_regs = of_iomap(np, 0);44of_node_put(np);45}46if (!bcsr_regs)47return -1;4849np = of_find_node_by_name(NULL, "usb");50if (!np) {51ret = -ENODEV;52goto out;53}54phy_type = of_get_property(np, "phy_type", NULL);55if (phy_type && !strcmp(phy_type, "ulpi")) {56clrbits8(bcsr_regs + 12, BCSR12_USB_SER_PIN);57} else if (phy_type && !strcmp(phy_type, "serial")) {58mode = of_get_property(np, "dr_mode", NULL);59bcsr12 = in_8(bcsr_regs + 12) & ~BCSR12_USB_SER_MASK;60bcsr12 |= BCSR12_USB_SER_PIN;61if (mode && !strcmp(mode, "peripheral"))62bcsr12 |= BCSR12_USB_SER_DEVICE;63out_8(bcsr_regs + 12, bcsr12);64} else {65printk(KERN_ERR "USB DR: unsupported PHY\n");66}6768of_node_put(np);69out:70iounmap(bcsr_regs);71return ret;72}7374/* ************************************************************************75*76* Setup the architecture77*78*/79static void __init mpc837x_mds_setup_arch(void)80{81#ifdef CONFIG_PCI82struct device_node *np;83#endif8485if (ppc_md.progress)86ppc_md.progress("mpc837x_mds_setup_arch()", 0);8788#ifdef CONFIG_PCI89for_each_compatible_node(np, "pci", "fsl,mpc8349-pci")90mpc83xx_add_bridge(np);91for_each_compatible_node(np, "pci", "fsl,mpc8314-pcie")92mpc83xx_add_bridge(np);93#endif94mpc837xmds_usb_cfg();95}9697static struct of_device_id mpc837x_ids[] = {98{ .type = "soc", },99{ .compatible = "soc", },100{ .compatible = "simple-bus", },101{ .compatible = "gianfar", },102{},103};104105static int __init mpc837x_declare_of_platform_devices(void)106{107/* Publish platform_device */108of_platform_bus_probe(NULL, mpc837x_ids, NULL);109110return 0;111}112machine_device_initcall(mpc837x_mds, mpc837x_declare_of_platform_devices);113114static void __init mpc837x_mds_init_IRQ(void)115{116struct device_node *np;117118np = of_find_compatible_node(NULL, NULL, "fsl,ipic");119if (!np)120return;121122ipic_init(np, 0);123124/* Initialize the default interrupt mapping priorities,125* in case the boot rom changed something on us.126*/127ipic_set_default_priority();128}129130/*131* Called very early, MMU is off, device-tree isn't unflattened132*/133static int __init mpc837x_mds_probe(void)134{135unsigned long root = of_get_flat_dt_root();136137return of_flat_dt_is_compatible(root, "fsl,mpc837xmds");138}139140define_machine(mpc837x_mds) {141.name = "MPC837x MDS",142.probe = mpc837x_mds_probe,143.setup_arch = mpc837x_mds_setup_arch,144.init_IRQ = mpc837x_mds_init_IRQ,145.get_irq = ipic_get_irq,146.restart = mpc83xx_restart,147.time_init = mpc83xx_time_init,148.calibrate_decr = generic_calibrate_decr,149.progress = udbg_progress,150};151152153