]>
Commit | Line | Data |
---|---|---|
2874c5fd | 1 | // SPDX-License-Identifier: GPL-2.0-or-later |
833e31e7 LY |
2 | /* |
3 | * arch/powerpc/platforms/83xx/mpc837x_mds.c | |
4 | * | |
5 | * Copyright (C) 2007 Freescale Semiconductor, Inc. All rights reserved. | |
6 | * | |
7 | * MPC837x MDS board specific routines | |
833e31e7 LY |
8 | */ |
9 | ||
10 | #include <linux/pci.h> | |
11 | #include <linux/of.h> | |
12 | #include <linux/of_platform.h> | |
13 | ||
14 | #include <asm/time.h> | |
15 | #include <asm/ipic.h> | |
16 | #include <asm/udbg.h> | |
17 | #include <asm/prom.h> | |
76fe1ffc | 18 | #include <sysdev/fsl_pci.h> |
833e31e7 LY |
19 | |
20 | #include "mpc83xx.h" | |
21 | ||
e10241d8 LY |
22 | #define BCSR12_USB_SER_MASK 0x8a |
23 | #define BCSR12_USB_SER_PIN 0x80 | |
24 | #define BCSR12_USB_SER_DEVICE 0x02 | |
e10241d8 LY |
25 | |
26 | static int mpc837xmds_usb_cfg(void) | |
27 | { | |
28 | struct device_node *np; | |
29 | const void *phy_type, *mode; | |
30 | void __iomem *bcsr_regs = NULL; | |
31 | u8 bcsr12; | |
32 | int ret; | |
33 | ||
34 | ret = mpc837x_usb_cfg(); | |
35 | if (ret) | |
36 | return ret; | |
37 | /* Map BCSR area */ | |
d7f46190 | 38 | np = of_find_compatible_node(NULL, NULL, "fsl,mpc837xmds-bcsr"); |
e10241d8 | 39 | if (np) { |
d7f46190 | 40 | bcsr_regs = of_iomap(np, 0); |
e10241d8 LY |
41 | of_node_put(np); |
42 | } | |
43 | if (!bcsr_regs) | |
44 | return -1; | |
45 | ||
46 | np = of_find_node_by_name(NULL, "usb"); | |
fa9fc821 JL |
47 | if (!np) { |
48 | ret = -ENODEV; | |
49 | goto out; | |
50 | } | |
e10241d8 LY |
51 | phy_type = of_get_property(np, "phy_type", NULL); |
52 | if (phy_type && !strcmp(phy_type, "ulpi")) { | |
53 | clrbits8(bcsr_regs + 12, BCSR12_USB_SER_PIN); | |
54 | } else if (phy_type && !strcmp(phy_type, "serial")) { | |
55 | mode = of_get_property(np, "dr_mode", NULL); | |
56 | bcsr12 = in_8(bcsr_regs + 12) & ~BCSR12_USB_SER_MASK; | |
57 | bcsr12 |= BCSR12_USB_SER_PIN; | |
58 | if (mode && !strcmp(mode, "peripheral")) | |
59 | bcsr12 |= BCSR12_USB_SER_DEVICE; | |
60 | out_8(bcsr_regs + 12, bcsr12); | |
61 | } else { | |
62 | printk(KERN_ERR "USB DR: unsupported PHY\n"); | |
63 | } | |
64 | ||
65 | of_node_put(np); | |
fa9fc821 | 66 | out: |
e10241d8 | 67 | iounmap(bcsr_regs); |
fa9fc821 | 68 | return ret; |
e10241d8 LY |
69 | } |
70 | ||
833e31e7 LY |
71 | /* ************************************************************************ |
72 | * | |
73 | * Setup the architecture | |
74 | * | |
75 | */ | |
76 | static void __init mpc837x_mds_setup_arch(void) | |
77 | { | |
fff69fd0 | 78 | mpc83xx_setup_arch(); |
e10241d8 | 79 | mpc837xmds_usb_cfg(); |
833e31e7 LY |
80 | } |
81 | ||
7669d58c | 82 | machine_device_initcall(mpc837x_mds, mpc83xx_declare_of_platform_devices); |
833e31e7 | 83 | |
833e31e7 LY |
84 | /* |
85 | * Called very early, MMU is off, device-tree isn't unflattened | |
86 | */ | |
87 | static int __init mpc837x_mds_probe(void) | |
88 | { | |
56571384 | 89 | return of_machine_is_compatible("fsl,mpc837xmds"); |
833e31e7 LY |
90 | } |
91 | ||
92 | define_machine(mpc837x_mds) { | |
93 | .name = "MPC837x MDS", | |
94 | .probe = mpc837x_mds_probe, | |
95 | .setup_arch = mpc837x_mds_setup_arch, | |
d4fb5ebd | 96 | .init_IRQ = mpc83xx_ipic_init_IRQ, |
833e31e7 LY |
97 | .get_irq = ipic_get_irq, |
98 | .restart = mpc83xx_restart, | |
99 | .time_init = mpc83xx_time_init, | |
100 | .calibrate_decr = generic_calibrate_decr, | |
101 | .progress = udbg_progress, | |
102 | }; |