mpc86xads_setup.c 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. /*arch/powerpc/platforms/8xx/mpc86xads_setup.c
  2. *
  3. * Platform setup for the Freescale mpc86xads board
  4. *
  5. * Vitaly Bordug <vbordug@ru.mvista.com>
  6. *
  7. * Copyright 2005 MontaVista Software Inc.
  8. *
  9. * Heavily modified by Scott Wood <scottwood@freescale.com>
  10. * Copyright 2007 Freescale Semiconductor, Inc.
  11. *
  12. * This file is licensed under the terms of the GNU General Public License
  13. * version 2. This program is licensed "as is" without any warranty of any
  14. * kind, whether express or implied.
  15. */
  16. #include <linux/init.h>
  17. #include <linux/of_platform.h>
  18. #include <asm/io.h>
  19. #include <asm/machdep.h>
  20. #include <asm/system.h>
  21. #include <asm/time.h>
  22. #include <asm/8xx_immap.h>
  23. #include <asm/cpm1.h>
  24. #include <asm/fs_pd.h>
  25. #include <asm/udbg.h>
  26. #include "mpc86xads.h"
  27. #include "mpc8xx.h"
  28. struct cpm_pin {
  29. int port, pin, flags;
  30. };
  31. static struct cpm_pin mpc866ads_pins[] = {
  32. /* SMC1 */
  33. {CPM_PORTB, 24, CPM_PIN_INPUT}, /* RX */
  34. {CPM_PORTB, 25, CPM_PIN_INPUT | CPM_PIN_SECONDARY}, /* TX */
  35. /* SMC2 */
  36. {CPM_PORTB, 21, CPM_PIN_INPUT}, /* RX */
  37. {CPM_PORTB, 20, CPM_PIN_INPUT | CPM_PIN_SECONDARY}, /* TX */
  38. /* SCC1 */
  39. {CPM_PORTA, 6, CPM_PIN_INPUT}, /* CLK1 */
  40. {CPM_PORTA, 7, CPM_PIN_INPUT}, /* CLK2 */
  41. {CPM_PORTA, 14, CPM_PIN_INPUT}, /* TX */
  42. {CPM_PORTA, 15, CPM_PIN_INPUT}, /* RX */
  43. {CPM_PORTB, 19, CPM_PIN_INPUT | CPM_PIN_SECONDARY}, /* TENA */
  44. {CPM_PORTC, 10, CPM_PIN_INPUT | CPM_PIN_SECONDARY | CPM_PIN_GPIO}, /* RENA */
  45. {CPM_PORTC, 11, CPM_PIN_INPUT | CPM_PIN_SECONDARY | CPM_PIN_GPIO}, /* CLSN */
  46. /* MII */
  47. {CPM_PORTD, 3, CPM_PIN_OUTPUT},
  48. {CPM_PORTD, 4, CPM_PIN_OUTPUT},
  49. {CPM_PORTD, 5, CPM_PIN_OUTPUT},
  50. {CPM_PORTD, 6, CPM_PIN_OUTPUT},
  51. {CPM_PORTD, 7, CPM_PIN_OUTPUT},
  52. {CPM_PORTD, 8, CPM_PIN_OUTPUT},
  53. {CPM_PORTD, 9, CPM_PIN_OUTPUT},
  54. {CPM_PORTD, 10, CPM_PIN_OUTPUT},
  55. {CPM_PORTD, 11, CPM_PIN_OUTPUT},
  56. {CPM_PORTD, 12, CPM_PIN_OUTPUT},
  57. {CPM_PORTD, 13, CPM_PIN_OUTPUT},
  58. {CPM_PORTD, 14, CPM_PIN_OUTPUT},
  59. {CPM_PORTD, 15, CPM_PIN_OUTPUT},
  60. /* I2C */
  61. {CPM_PORTB, 26, CPM_PIN_INPUT | CPM_PIN_OPENDRAIN},
  62. {CPM_PORTB, 27, CPM_PIN_INPUT | CPM_PIN_OPENDRAIN},
  63. };
  64. static void __init init_ioports(void)
  65. {
  66. int i;
  67. for (i = 0; i < ARRAY_SIZE(mpc866ads_pins); i++) {
  68. struct cpm_pin *pin = &mpc866ads_pins[i];
  69. cpm1_set_pin(pin->port, pin->pin, pin->flags);
  70. }
  71. cpm1_clk_setup(CPM_CLK_SMC1, CPM_BRG1, CPM_CLK_RTX);
  72. cpm1_clk_setup(CPM_CLK_SMC2, CPM_BRG2, CPM_CLK_RTX);
  73. cpm1_clk_setup(CPM_CLK_SCC1, CPM_CLK1, CPM_CLK_TX);
  74. cpm1_clk_setup(CPM_CLK_SCC1, CPM_CLK2, CPM_CLK_RX);
  75. /* Set FEC1 and FEC2 to MII mode */
  76. clrbits32(&mpc8xx_immr->im_cpm.cp_cptr, 0x00000180);
  77. }
  78. static void __init mpc86xads_setup_arch(void)
  79. {
  80. struct device_node *np;
  81. u32 __iomem *bcsr_io;
  82. cpm_reset();
  83. init_ioports();
  84. np = of_find_compatible_node(NULL, NULL, "fsl,mpc866ads-bcsr");
  85. if (!np) {
  86. printk(KERN_CRIT "Could not find fsl,mpc866ads-bcsr node\n");
  87. return;
  88. }
  89. bcsr_io = of_iomap(np, 0);
  90. of_node_put(np);
  91. if (bcsr_io == NULL) {
  92. printk(KERN_CRIT "Could not remap BCSR\n");
  93. return;
  94. }
  95. clrbits32(bcsr_io, BCSR1_RS232EN_1 | BCSR1_RS232EN_2 | BCSR1_ETHEN);
  96. iounmap(bcsr_io);
  97. }
  98. static int __init mpc86xads_probe(void)
  99. {
  100. unsigned long root = of_get_flat_dt_root();
  101. return of_flat_dt_is_compatible(root, "fsl,mpc866ads");
  102. }
  103. static struct of_device_id __initdata of_bus_ids[] = {
  104. { .name = "soc", },
  105. { .name = "cpm", },
  106. { .name = "localbus", },
  107. {},
  108. };
  109. static int __init declare_of_platform_devices(void)
  110. {
  111. of_platform_bus_probe(NULL, of_bus_ids, NULL);
  112. return 0;
  113. }
  114. machine_device_initcall(mpc86x_ads, declare_of_platform_devices);
  115. define_machine(mpc86x_ads) {
  116. .name = "MPC86x ADS",
  117. .probe = mpc86xads_probe,
  118. .setup_arch = mpc86xads_setup_arch,
  119. .init_IRQ = mpc8xx_pics_init,
  120. .get_irq = mpc8xx_get_irq,
  121. .restart = mpc8xx_restart,
  122. .calibrate_decr = mpc8xx_calibrate_decr,
  123. .set_rtc_time = mpc8xx_set_rtc_time,
  124. .get_rtc_time = mpc8xx_get_rtc_time,
  125. .progress = udbg_progress,
  126. };