mpc837x_mds.c 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  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. #include <linux/pci.h>
  14. #include <linux/of.h>
  15. #include <linux/of_platform.h>
  16. #include <asm/time.h>
  17. #include <asm/ipic.h>
  18. #include <asm/udbg.h>
  19. #include <asm/prom.h>
  20. #include <sysdev/fsl_pci.h>
  21. #include "mpc83xx.h"
  22. #define BCSR12_USB_SER_MASK 0x8a
  23. #define BCSR12_USB_SER_PIN 0x80
  24. #define BCSR12_USB_SER_DEVICE 0x02
  25. static int mpc837xmds_usb_cfg(void)
  26. {
  27. struct device_node *np;
  28. const void *phy_type, *mode;
  29. void __iomem *bcsr_regs = NULL;
  30. u8 bcsr12;
  31. int ret;
  32. ret = mpc837x_usb_cfg();
  33. if (ret)
  34. return ret;
  35. /* Map BCSR area */
  36. np = of_find_compatible_node(NULL, NULL, "fsl,mpc837xmds-bcsr");
  37. if (np) {
  38. bcsr_regs = of_iomap(np, 0);
  39. of_node_put(np);
  40. }
  41. if (!bcsr_regs)
  42. return -1;
  43. np = of_find_node_by_name(NULL, "usb");
  44. if (!np) {
  45. ret = -ENODEV;
  46. goto out;
  47. }
  48. phy_type = of_get_property(np, "phy_type", NULL);
  49. if (phy_type && !strcmp(phy_type, "ulpi")) {
  50. clrbits8(bcsr_regs + 12, BCSR12_USB_SER_PIN);
  51. } else if (phy_type && !strcmp(phy_type, "serial")) {
  52. mode = of_get_property(np, "dr_mode", NULL);
  53. bcsr12 = in_8(bcsr_regs + 12) & ~BCSR12_USB_SER_MASK;
  54. bcsr12 |= BCSR12_USB_SER_PIN;
  55. if (mode && !strcmp(mode, "peripheral"))
  56. bcsr12 |= BCSR12_USB_SER_DEVICE;
  57. out_8(bcsr_regs + 12, bcsr12);
  58. } else {
  59. printk(KERN_ERR "USB DR: unsupported PHY\n");
  60. }
  61. of_node_put(np);
  62. out:
  63. iounmap(bcsr_regs);
  64. return ret;
  65. }
  66. /* ************************************************************************
  67. *
  68. * Setup the architecture
  69. *
  70. */
  71. static void __init mpc837x_mds_setup_arch(void)
  72. {
  73. if (ppc_md.progress)
  74. ppc_md.progress("mpc837x_mds_setup_arch()", 0);
  75. mpc83xx_setup_pci();
  76. mpc837xmds_usb_cfg();
  77. }
  78. machine_device_initcall(mpc837x_mds, mpc83xx_declare_of_platform_devices);
  79. /*
  80. * Called very early, MMU is off, device-tree isn't unflattened
  81. */
  82. static int __init mpc837x_mds_probe(void)
  83. {
  84. unsigned long root = of_get_flat_dt_root();
  85. return of_flat_dt_is_compatible(root, "fsl,mpc837xmds");
  86. }
  87. define_machine(mpc837x_mds) {
  88. .name = "MPC837x MDS",
  89. .probe = mpc837x_mds_probe,
  90. .setup_arch = mpc837x_mds_setup_arch,
  91. .init_IRQ = mpc83xx_ipic_init_IRQ,
  92. .get_irq = ipic_get_irq,
  93. .restart = mpc83xx_restart,
  94. .time_init = mpc83xx_time_init,
  95. .calibrate_decr = generic_calibrate_decr,
  96. .progress = udbg_progress,
  97. };