mpc837x_mds.c 3.5 KB

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