Commit | Line | Data |
---|---|---|
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> | |
76fe1ffc | 22 | #include <sysdev/fsl_pci.h> |
833e31e7 LY |
23 | |
24 | #include "mpc83xx.h" | |
25 | ||
e10241d8 LY |
26 | #define BCSR12_USB_SER_MASK 0x8a |
27 | #define BCSR12_USB_SER_PIN 0x80 | |
28 | #define BCSR12_USB_SER_DEVICE 0x02 | |
29 | extern int mpc837x_usb_cfg(void); | |
30 | ||
31 | static int mpc837xmds_usb_cfg(void) | |
32 | { | |
33 | struct device_node *np; | |
34 | const void *phy_type, *mode; | |
35 | void __iomem *bcsr_regs = NULL; | |
36 | u8 bcsr12; | |
37 | int ret; | |
38 | ||
39 | ret = mpc837x_usb_cfg(); | |
40 | if (ret) | |
41 | return ret; | |
42 | /* Map BCSR area */ | |
d7f46190 | 43 | np = of_find_compatible_node(NULL, NULL, "fsl,mpc837xmds-bcsr"); |
e10241d8 | 44 | if (np) { |
d7f46190 | 45 | bcsr_regs = of_iomap(np, 0); |
e10241d8 LY |
46 | of_node_put(np); |
47 | } | |
48 | if (!bcsr_regs) | |
49 | return -1; | |
50 | ||
51 | np = of_find_node_by_name(NULL, "usb"); | |
52 | if (!np) | |
53 | return -ENODEV; | |
54 | phy_type = of_get_property(np, "phy_type", NULL); | |
55 | if (phy_type && !strcmp(phy_type, "ulpi")) { | |
56 | clrbits8(bcsr_regs + 12, BCSR12_USB_SER_PIN); | |
57 | } else if (phy_type && !strcmp(phy_type, "serial")) { | |
58 | mode = of_get_property(np, "dr_mode", NULL); | |
59 | bcsr12 = in_8(bcsr_regs + 12) & ~BCSR12_USB_SER_MASK; | |
60 | bcsr12 |= BCSR12_USB_SER_PIN; | |
61 | if (mode && !strcmp(mode, "peripheral")) | |
62 | bcsr12 |= BCSR12_USB_SER_DEVICE; | |
63 | out_8(bcsr_regs + 12, bcsr12); | |
64 | } else { | |
65 | printk(KERN_ERR "USB DR: unsupported PHY\n"); | |
66 | } | |
67 | ||
68 | of_node_put(np); | |
69 | iounmap(bcsr_regs); | |
70 | return 0; | |
71 | } | |
72 | ||
833e31e7 LY |
73 | /* ************************************************************************ |
74 | * | |
75 | * Setup the architecture | |
76 | * | |
77 | */ | |
78 | static void __init mpc837x_mds_setup_arch(void) | |
79 | { | |
80 | #ifdef CONFIG_PCI | |
81 | struct device_node *np; | |
82 | #endif | |
83 | ||
84 | if (ppc_md.progress) | |
85 | ppc_md.progress("mpc837x_mds_setup_arch()", 0); | |
86 | ||
87 | #ifdef CONFIG_PCI | |
62666828 AV |
88 | for_each_compatible_node(np, "pci", "fsl,mpc8349-pci") { |
89 | if (!of_device_is_available(np)) { | |
90 | pr_warning("%s: disabled by the firmware.\n", | |
91 | np->full_name); | |
92 | continue; | |
93 | } | |
833e31e7 | 94 | mpc83xx_add_bridge(np); |
62666828 | 95 | } |
833e31e7 | 96 | #endif |
e10241d8 | 97 | mpc837xmds_usb_cfg(); |
833e31e7 LY |
98 | } |
99 | ||
100 | static struct of_device_id mpc837x_ids[] = { | |
101 | { .type = "soc", }, | |
102 | { .compatible = "soc", }, | |
d7f46190 | 103 | { .compatible = "simple-bus", }, |
833e31e7 LY |
104 | {}, |
105 | }; | |
106 | ||
107 | static int __init mpc837x_declare_of_platform_devices(void) | |
108 | { | |
833e31e7 LY |
109 | /* Publish of_device */ |
110 | of_platform_bus_probe(NULL, mpc837x_ids, NULL); | |
111 | ||
112 | return 0; | |
113 | } | |
6392f184 | 114 | machine_device_initcall(mpc837x_mds, mpc837x_declare_of_platform_devices); |
833e31e7 LY |
115 | |
116 | static void __init mpc837x_mds_init_IRQ(void) | |
117 | { | |
118 | struct device_node *np; | |
119 | ||
120 | np = of_find_compatible_node(NULL, NULL, "fsl,ipic"); | |
121 | if (!np) | |
122 | return; | |
123 | ||
124 | ipic_init(np, 0); | |
125 | ||
126 | /* Initialize the default interrupt mapping priorities, | |
127 | * in case the boot rom changed something on us. | |
128 | */ | |
129 | ipic_set_default_priority(); | |
130 | } | |
131 | ||
132 | /* | |
133 | * Called very early, MMU is off, device-tree isn't unflattened | |
134 | */ | |
135 | static int __init mpc837x_mds_probe(void) | |
136 | { | |
137 | unsigned long root = of_get_flat_dt_root(); | |
138 | ||
139 | return of_flat_dt_is_compatible(root, "fsl,mpc837xmds"); | |
140 | } | |
141 | ||
142 | define_machine(mpc837x_mds) { | |
143 | .name = "MPC837x MDS", | |
144 | .probe = mpc837x_mds_probe, | |
145 | .setup_arch = mpc837x_mds_setup_arch, | |
146 | .init_IRQ = mpc837x_mds_init_IRQ, | |
147 | .get_irq = ipic_get_irq, | |
148 | .restart = mpc83xx_restart, | |
149 | .time_init = mpc83xx_time_init, | |
150 | .calibrate_decr = generic_calibrate_decr, | |
151 | .progress = udbg_progress, | |
152 | }; |