mpc834x_mds.c 4.5 KB

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