mpc834x_mds.c 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195
  1. /*
  2. * arch/powerpc/platforms/83xx/mpc834x_mds.c
  3. *
  4. * MPC834x MDS board specific routines
  5. *
  6. * Maintainer: Kumar Gala <galak@kernel.crashing.org>
  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/stddef.h>
  14. #include <linux/kernel.h>
  15. #include <linux/init.h>
  16. #include <linux/errno.h>
  17. #include <linux/reboot.h>
  18. #include <linux/pci.h>
  19. #include <linux/kdev_t.h>
  20. #include <linux/major.h>
  21. #include <linux/console.h>
  22. #include <linux/delay.h>
  23. #include <linux/seq_file.h>
  24. #include <linux/root_dev.h>
  25. #include <asm/system.h>
  26. #include <asm/atomic.h>
  27. #include <asm/time.h>
  28. #include <asm/io.h>
  29. #include <asm/machdep.h>
  30. #include <asm/ipic.h>
  31. #include <asm/bootinfo.h>
  32. #include <asm/irq.h>
  33. #include <asm/prom.h>
  34. #include <asm/udbg.h>
  35. #include <sysdev/fsl_soc.h>
  36. #include "mpc83xx.h"
  37. #define BCSR5_INT_USB 0x02
  38. /* Note: This is only for PB, not for PB+PIB
  39. * On PB only port0 is connected using ULPI */
  40. static int mpc834x_usb_cfg(void)
  41. {
  42. unsigned long sccr, sicrl;
  43. void __iomem *immap;
  44. void __iomem *bcsr_regs = NULL;
  45. u8 bcsr5;
  46. struct device_node *np = NULL;
  47. int port0_is_dr = 0;
  48. if ((np = of_find_compatible_node(NULL, "usb", "fsl-usb2-dr")) != NULL)
  49. port0_is_dr = 1;
  50. if ((np = of_find_compatible_node(NULL, "usb", "fsl-usb2-mph")) != NULL){
  51. if (port0_is_dr) {
  52. printk(KERN_WARNING
  53. "There is only one USB port on PB board! \n");
  54. return -1;
  55. } else if (!port0_is_dr)
  56. /* No usb port enabled */
  57. return -1;
  58. }
  59. immap = ioremap(get_immrbase(), 0x1000);
  60. if (!immap)
  61. return -1;
  62. /* Configure clock */
  63. sccr = in_be32(immap + MPC83XX_SCCR_OFFS);
  64. if (port0_is_dr)
  65. sccr |= MPC83XX_SCCR_USB_DRCM_11; /* 1:3 */
  66. else
  67. sccr |= MPC83XX_SCCR_USB_MPHCM_11; /* 1:3 */
  68. out_be32(immap + MPC83XX_SCCR_OFFS, sccr);
  69. /* Configure Pin */
  70. sicrl = in_be32(immap + MPC83XX_SICRL_OFFS);
  71. /* set port0 only */
  72. if (port0_is_dr)
  73. sicrl |= MPC83XX_SICRL_USB0;
  74. else
  75. sicrl &= ~(MPC83XX_SICRL_USB0);
  76. out_be32(immap + MPC83XX_SICRL_OFFS, sicrl);
  77. iounmap(immap);
  78. /* Map BCSR area */
  79. np = of_find_node_by_name(NULL, "bcsr");
  80. if (np != 0) {
  81. struct resource res;
  82. of_address_to_resource(np, 0, &res);
  83. bcsr_regs = ioremap(res.start, res.end - res.start + 1);
  84. of_node_put(np);
  85. }
  86. if (!bcsr_regs)
  87. return -1;
  88. /*
  89. * if Processor Board is plugged into PIB board,
  90. * force to use the PHY on Processor Board
  91. */
  92. bcsr5 = in_8(bcsr_regs + 5);
  93. if (!(bcsr5 & BCSR5_INT_USB))
  94. out_8(bcsr_regs + 5, (bcsr5 | BCSR5_INT_USB));
  95. iounmap(bcsr_regs);
  96. return 0;
  97. }
  98. /* ************************************************************************
  99. *
  100. * Setup the architecture
  101. *
  102. */
  103. static void __init mpc834x_mds_setup_arch(void)
  104. {
  105. #ifdef CONFIG_PCI
  106. struct device_node *np;
  107. #endif
  108. if (ppc_md.progress)
  109. ppc_md.progress("mpc834x_mds_setup_arch()", 0);
  110. #ifdef CONFIG_PCI
  111. for (np = NULL; (np = of_find_node_by_type(np, "pci")) != NULL;)
  112. mpc83xx_add_bridge(np);
  113. ppc_md.pci_exclude_device = mpc83xx_exclude_device;
  114. #endif
  115. mpc834x_usb_cfg();
  116. }
  117. static void __init mpc834x_mds_init_IRQ(void)
  118. {
  119. struct device_node *np;
  120. np = of_find_node_by_type(NULL, "ipic");
  121. if (!np)
  122. return;
  123. ipic_init(np, 0);
  124. /* Initialize the default interrupt mapping priorities,
  125. * in case the boot rom changed something on us.
  126. */
  127. ipic_set_default_priority();
  128. }
  129. #if defined(CONFIG_I2C_MPC) && defined(CONFIG_SENSORS_DS1374)
  130. extern ulong ds1374_get_rtc_time(void);
  131. extern int ds1374_set_rtc_time(ulong);
  132. static int __init mpc834x_rtc_hookup(void)
  133. {
  134. struct timespec tv;
  135. if (!machine_is(mpc834x_mds))
  136. return 0;
  137. ppc_md.get_rtc_time = ds1374_get_rtc_time;
  138. ppc_md.set_rtc_time = ds1374_set_rtc_time;
  139. tv.tv_nsec = 0;
  140. tv.tv_sec = (ppc_md.get_rtc_time) ();
  141. do_settimeofday(&tv);
  142. return 0;
  143. }
  144. late_initcall(mpc834x_rtc_hookup);
  145. #endif
  146. /*
  147. * Called very early, MMU is off, device-tree isn't unflattened
  148. */
  149. static int __init mpc834x_mds_probe(void)
  150. {
  151. unsigned long root = of_get_flat_dt_root();
  152. return of_flat_dt_is_compatible(root, "MPC834xMDS");
  153. }
  154. define_machine(mpc834x_mds) {
  155. .name = "MPC834x MDS",
  156. .probe = mpc834x_mds_probe,
  157. .setup_arch = mpc834x_mds_setup_arch,
  158. .init_IRQ = mpc834x_mds_init_IRQ,
  159. .get_irq = ipic_get_irq,
  160. .restart = mpc83xx_restart,
  161. .time_init = mpc83xx_time_init,
  162. .calibrate_decr = generic_calibrate_decr,
  163. .progress = udbg_progress,
  164. };