]> git.proxmox.com Git - mirror_ubuntu-eoan-kernel.git/blame - arch/powerpc/platforms/83xx/mpc837x_mds.c
[POWERPC] 83xx: Fix wrong USB phy type in mpc837xmds dts
[mirror_ubuntu-eoan-kernel.git] / arch / powerpc / platforms / 83xx / mpc837x_mds.c
CommitLineData
833e31e7
LY
1/*
2 * arch/powerpc/platforms/83xx/mpc837x_mds.c
3 *
4 * Copyright (C) 2007 Freescale Semiconductor, Inc. All rights reserved.
5 *
6 * MPC837x MDS board specific routines
7 *
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.
12 */
13
14#include <linux/pci.h>
15#include <linux/of.h>
16#include <linux/of_platform.h>
17
18#include <asm/time.h>
19#include <asm/ipic.h>
20#include <asm/udbg.h>
21#include <asm/prom.h>
22
23#include "mpc83xx.h"
24
e10241d8
LY
25#define BCSR12_USB_SER_MASK 0x8a
26#define BCSR12_USB_SER_PIN 0x80
27#define BCSR12_USB_SER_DEVICE 0x02
28extern int mpc837x_usb_cfg(void);
29
30static int mpc837xmds_usb_cfg(void)
31{
32 struct device_node *np;
33 const void *phy_type, *mode;
34 void __iomem *bcsr_regs = NULL;
35 u8 bcsr12;
36 int ret;
37
38 ret = mpc837x_usb_cfg();
39 if (ret)
40 return ret;
41 /* Map BCSR area */
42 np = of_find_node_by_name(NULL, "bcsr");
43 if (np) {
44 struct resource res;
45
46 of_address_to_resource(np, 0, &res);
47 bcsr_regs = ioremap(res.start, res.end - res.start + 1);
48 of_node_put(np);
49 }
50 if (!bcsr_regs)
51 return -1;
52
53 np = of_find_node_by_name(NULL, "usb");
54 if (!np)
55 return -ENODEV;
56 phy_type = of_get_property(np, "phy_type", NULL);
57 if (phy_type && !strcmp(phy_type, "ulpi")) {
58 clrbits8(bcsr_regs + 12, BCSR12_USB_SER_PIN);
59 } else if (phy_type && !strcmp(phy_type, "serial")) {
60 mode = of_get_property(np, "dr_mode", NULL);
61 bcsr12 = in_8(bcsr_regs + 12) & ~BCSR12_USB_SER_MASK;
62 bcsr12 |= BCSR12_USB_SER_PIN;
63 if (mode && !strcmp(mode, "peripheral"))
64 bcsr12 |= BCSR12_USB_SER_DEVICE;
65 out_8(bcsr_regs + 12, bcsr12);
66 } else {
67 printk(KERN_ERR "USB DR: unsupported PHY\n");
68 }
69
70 of_node_put(np);
71 iounmap(bcsr_regs);
72 return 0;
73}
74
833e31e7
LY
75/* ************************************************************************
76 *
77 * Setup the architecture
78 *
79 */
80static void __init mpc837x_mds_setup_arch(void)
81{
82#ifdef CONFIG_PCI
83 struct device_node *np;
84#endif
85
86 if (ppc_md.progress)
87 ppc_md.progress("mpc837x_mds_setup_arch()", 0);
88
89#ifdef CONFIG_PCI
90 for_each_compatible_node(np, "pci", "fsl,mpc8349-pci")
91 mpc83xx_add_bridge(np);
92#endif
e10241d8 93 mpc837xmds_usb_cfg();
833e31e7
LY
94}
95
96static struct of_device_id mpc837x_ids[] = {
97 { .type = "soc", },
98 { .compatible = "soc", },
99 {},
100};
101
102static int __init mpc837x_declare_of_platform_devices(void)
103{
833e31e7
LY
104 /* Publish of_device */
105 of_platform_bus_probe(NULL, mpc837x_ids, NULL);
106
107 return 0;
108}
6392f184 109machine_device_initcall(mpc837x_mds, mpc837x_declare_of_platform_devices);
833e31e7
LY
110
111static void __init mpc837x_mds_init_IRQ(void)
112{
113 struct device_node *np;
114
115 np = of_find_compatible_node(NULL, NULL, "fsl,ipic");
116 if (!np)
117 return;
118
119 ipic_init(np, 0);
120
121 /* Initialize the default interrupt mapping priorities,
122 * in case the boot rom changed something on us.
123 */
124 ipic_set_default_priority();
125}
126
127/*
128 * Called very early, MMU is off, device-tree isn't unflattened
129 */
130static int __init mpc837x_mds_probe(void)
131{
132 unsigned long root = of_get_flat_dt_root();
133
134 return of_flat_dt_is_compatible(root, "fsl,mpc837xmds");
135}
136
137define_machine(mpc837x_mds) {
138 .name = "MPC837x MDS",
139 .probe = mpc837x_mds_probe,
140 .setup_arch = mpc837x_mds_setup_arch,
141 .init_IRQ = mpc837x_mds_init_IRQ,
142 .get_irq = ipic_get_irq,
143 .restart = mpc83xx_restart,
144 .time_init = mpc83xx_time_init,
145 .calibrate_decr = generic_calibrate_decr,
146 .progress = udbg_progress,
147};