0001
0002
0003
0004
0005
0006
0007
0008
0009
0010 #include <linux/pci.h>
0011 #include <linux/of.h>
0012 #include <linux/of_address.h>
0013 #include <linux/of_platform.h>
0014
0015 #include <asm/time.h>
0016 #include <asm/ipic.h>
0017 #include <asm/udbg.h>
0018 #include <sysdev/fsl_pci.h>
0019
0020 #include "mpc83xx.h"
0021
0022 #define BCSR12_USB_SER_MASK 0x8a
0023 #define BCSR12_USB_SER_PIN 0x80
0024 #define BCSR12_USB_SER_DEVICE 0x02
0025
0026 static int __init mpc837xmds_usb_cfg(void)
0027 {
0028 struct device_node *np;
0029 const void *phy_type, *mode;
0030 void __iomem *bcsr_regs = NULL;
0031 u8 bcsr12;
0032 int ret;
0033
0034 ret = mpc837x_usb_cfg();
0035 if (ret)
0036 return ret;
0037
0038 np = of_find_compatible_node(NULL, NULL, "fsl,mpc837xmds-bcsr");
0039 if (np) {
0040 bcsr_regs = of_iomap(np, 0);
0041 of_node_put(np);
0042 }
0043 if (!bcsr_regs)
0044 return -1;
0045
0046 np = of_find_node_by_name(NULL, "usb");
0047 if (!np) {
0048 ret = -ENODEV;
0049 goto out;
0050 }
0051 phy_type = of_get_property(np, "phy_type", NULL);
0052 if (phy_type && !strcmp(phy_type, "ulpi")) {
0053 clrbits8(bcsr_regs + 12, BCSR12_USB_SER_PIN);
0054 } else if (phy_type && !strcmp(phy_type, "serial")) {
0055 mode = of_get_property(np, "dr_mode", NULL);
0056 bcsr12 = in_8(bcsr_regs + 12) & ~BCSR12_USB_SER_MASK;
0057 bcsr12 |= BCSR12_USB_SER_PIN;
0058 if (mode && !strcmp(mode, "peripheral"))
0059 bcsr12 |= BCSR12_USB_SER_DEVICE;
0060 out_8(bcsr_regs + 12, bcsr12);
0061 } else {
0062 printk(KERN_ERR "USB DR: unsupported PHY\n");
0063 }
0064
0065 of_node_put(np);
0066 out:
0067 iounmap(bcsr_regs);
0068 return ret;
0069 }
0070
0071
0072
0073
0074
0075
0076 static void __init mpc837x_mds_setup_arch(void)
0077 {
0078 mpc83xx_setup_arch();
0079 mpc837xmds_usb_cfg();
0080 }
0081
0082 machine_device_initcall(mpc837x_mds, mpc83xx_declare_of_platform_devices);
0083
0084
0085
0086
0087 static int __init mpc837x_mds_probe(void)
0088 {
0089 return of_machine_is_compatible("fsl,mpc837xmds");
0090 }
0091
0092 define_machine(mpc837x_mds) {
0093 .name = "MPC837x MDS",
0094 .probe = mpc837x_mds_probe,
0095 .setup_arch = mpc837x_mds_setup_arch,
0096 .discover_phbs = mpc83xx_setup_pci,
0097 .init_IRQ = mpc83xx_ipic_init_IRQ,
0098 .get_irq = ipic_get_irq,
0099 .restart = mpc83xx_restart,
0100 .time_init = mpc83xx_time_init,
0101 .calibrate_decr = generic_calibrate_decr,
0102 .progress = udbg_progress,
0103 };