mpc86xads_setup.c 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  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. };
  61. static void __init init_ioports(void)
  62. {
  63. int i;
  64. for (i = 0; i < ARRAY_SIZE(mpc866ads_pins); i++) {
  65. struct cpm_pin *pin = &mpc866ads_pins[i];
  66. cpm1_set_pin(pin->port, pin->pin, pin->flags);
  67. }
  68. cpm1_clk_setup(CPM_CLK_SMC1, CPM_BRG1, CPM_CLK_RTX);
  69. cpm1_clk_setup(CPM_CLK_SMC2, CPM_BRG2, CPM_CLK_RTX);
  70. cpm1_clk_setup(CPM_CLK_SCC1, CPM_CLK1, CPM_CLK_TX);
  71. cpm1_clk_setup(CPM_CLK_SCC1, CPM_CLK2, CPM_CLK_RX);
  72. /* Set FEC1 and FEC2 to MII mode */
  73. clrbits32(&mpc8xx_immr->im_cpm.cp_cptr, 0x00000180);
  74. }
  75. static void __init mpc86xads_setup_arch(void)
  76. {
  77. struct device_node *np;
  78. u32 __iomem *bcsr_io;
  79. cpm_reset();
  80. init_ioports();
  81. np = of_find_compatible_node(NULL, NULL, "fsl,mpc866ads-bcsr");
  82. if (!np) {
  83. printk(KERN_CRIT "Could not find fsl,mpc866ads-bcsr node\n");
  84. return;
  85. }
  86. bcsr_io = of_iomap(np, 0);
  87. of_node_put(np);
  88. if (bcsr_io == NULL) {
  89. printk(KERN_CRIT "Could not remap BCSR\n");
  90. return;
  91. }
  92. clrbits32(bcsr_io, BCSR1_RS232EN_1 | BCSR1_RS232EN_2 | BCSR1_ETHEN);
  93. iounmap(bcsr_io);
  94. }
  95. static int __init mpc86xads_probe(void)
  96. {
  97. unsigned long root = of_get_flat_dt_root();
  98. return of_flat_dt_is_compatible(root, "fsl,mpc866ads");
  99. }
  100. static struct of_device_id __initdata of_bus_ids[] = {
  101. { .name = "soc", },
  102. { .name = "cpm", },
  103. { .name = "localbus", },
  104. {},
  105. };
  106. static int __init declare_of_platform_devices(void)
  107. {
  108. of_platform_bus_probe(NULL, of_bus_ids, NULL);
  109. return 0;
  110. }
  111. machine_device_initcall(mpc86x_ads, declare_of_platform_devices);
  112. define_machine(mpc86x_ads) {
  113. .name = "MPC86x ADS",
  114. .probe = mpc86xads_probe,
  115. .setup_arch = mpc86xads_setup_arch,
  116. .init_IRQ = mpc8xx_pics_init,
  117. .get_irq = mpc8xx_get_irq,
  118. .restart = mpc8xx_restart,
  119. .calibrate_decr = mpc8xx_calibrate_decr,
  120. .set_rtc_time = mpc8xx_set_rtc_time,
  121. .get_rtc_time = mpc8xx_get_rtc_time,
  122. .progress = udbg_progress,
  123. };