powerpc/512x: fix clk_get() return value
[linux-2.6/linux-acpi-2.6/ibm-acpi-2.6.git] / arch / powerpc / platforms / 83xx / mpc837x_mds.c
blobf9751c8905be5db684a25555975a60b3b574d881
1 /*
2 * arch/powerpc/platforms/83xx/mpc837x_mds.c
4 * Copyright (C) 2007 Freescale Semiconductor, Inc. All rights reserved.
6 * MPC837x MDS board specific routines
8 * This program is free software; you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License as published by the
10 * Free Software Foundation; either version 2 of the License, or (at your
11 * option) any later version.
14 #include <linux/pci.h>
15 #include <linux/of.h>
16 #include <linux/of_platform.h>
18 #include <asm/time.h>
19 #include <asm/ipic.h>
20 #include <asm/udbg.h>
21 #include <asm/prom.h>
22 #include <sysdev/fsl_pci.h>
24 #include "mpc83xx.h"
26 #define BCSR12_USB_SER_MASK 0x8a
27 #define BCSR12_USB_SER_PIN 0x80
28 #define BCSR12_USB_SER_DEVICE 0x02
30 static int mpc837xmds_usb_cfg(void)
32 struct device_node *np;
33 const void *phy_type, *mode;
34 void __iomem *bcsr_regs = NULL;
35 u8 bcsr12;
36 int ret;
38 ret = mpc837x_usb_cfg();
39 if (ret)
40 return ret;
41 /* Map BCSR area */
42 np = of_find_compatible_node(NULL, NULL, "fsl,mpc837xmds-bcsr");
43 if (np) {
44 bcsr_regs = of_iomap(np, 0);
45 of_node_put(np);
47 if (!bcsr_regs)
48 return -1;
50 np = of_find_node_by_name(NULL, "usb");
51 if (!np)
52 return -ENODEV;
53 phy_type = of_get_property(np, "phy_type", NULL);
54 if (phy_type && !strcmp(phy_type, "ulpi")) {
55 clrbits8(bcsr_regs + 12, BCSR12_USB_SER_PIN);
56 } else if (phy_type && !strcmp(phy_type, "serial")) {
57 mode = of_get_property(np, "dr_mode", NULL);
58 bcsr12 = in_8(bcsr_regs + 12) & ~BCSR12_USB_SER_MASK;
59 bcsr12 |= BCSR12_USB_SER_PIN;
60 if (mode && !strcmp(mode, "peripheral"))
61 bcsr12 |= BCSR12_USB_SER_DEVICE;
62 out_8(bcsr_regs + 12, bcsr12);
63 } else {
64 printk(KERN_ERR "USB DR: unsupported PHY\n");
67 of_node_put(np);
68 iounmap(bcsr_regs);
69 return 0;
72 /* ************************************************************************
74 * Setup the architecture
77 static void __init mpc837x_mds_setup_arch(void)
79 #ifdef CONFIG_PCI
80 struct device_node *np;
81 #endif
83 if (ppc_md.progress)
84 ppc_md.progress("mpc837x_mds_setup_arch()", 0);
86 #ifdef CONFIG_PCI
87 for_each_compatible_node(np, "pci", "fsl,mpc8349-pci")
88 mpc83xx_add_bridge(np);
89 for_each_compatible_node(np, "pci", "fsl,mpc8314-pcie")
90 mpc83xx_add_bridge(np);
91 #endif
92 mpc837xmds_usb_cfg();
95 static struct of_device_id mpc837x_ids[] = {
96 { .type = "soc", },
97 { .compatible = "soc", },
98 { .compatible = "simple-bus", },
99 { .compatible = "gianfar", },
103 static int __init mpc837x_declare_of_platform_devices(void)
105 /* Publish platform_device */
106 of_platform_bus_probe(NULL, mpc837x_ids, NULL);
108 return 0;
110 machine_device_initcall(mpc837x_mds, mpc837x_declare_of_platform_devices);
112 static void __init mpc837x_mds_init_IRQ(void)
114 struct device_node *np;
116 np = of_find_compatible_node(NULL, NULL, "fsl,ipic");
117 if (!np)
118 return;
120 ipic_init(np, 0);
122 /* Initialize the default interrupt mapping priorities,
123 * in case the boot rom changed something on us.
125 ipic_set_default_priority();
129 * Called very early, MMU is off, device-tree isn't unflattened
131 static int __init mpc837x_mds_probe(void)
133 unsigned long root = of_get_flat_dt_root();
135 return of_flat_dt_is_compatible(root, "fsl,mpc837xmds");
138 define_machine(mpc837x_mds) {
139 .name = "MPC837x MDS",
140 .probe = mpc837x_mds_probe,
141 .setup_arch = mpc837x_mds_setup_arch,
142 .init_IRQ = mpc837x_mds_init_IRQ,
143 .get_irq = ipic_get_irq,
144 .restart = mpc83xx_restart,
145 .time_init = mpc83xx_time_init,
146 .calibrate_decr = generic_calibrate_decr,
147 .progress = udbg_progress,