mgcoge.c 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. /*
  2. * Keymile mgcoge support
  3. * Copyright 2008 DENX Software Engineering GmbH
  4. * Author: Heiko Schocher <hs@denx.de>
  5. *
  6. * based on code from:
  7. * Copyright 2007 Freescale Semiconductor, Inc.
  8. * Author: Scott Wood <scottwood@freescale.com>
  9. *
  10. * This program is free software; you can redistribute it and/or modify it
  11. * under the terms of the GNU General Public License as published by the
  12. * Free Software Foundation; either version 2 of the License, or (at your
  13. * option) any later version.
  14. */
  15. #include <linux/init.h>
  16. #include <linux/interrupt.h>
  17. #include <linux/fsl_devices.h>
  18. #include <linux/of_platform.h>
  19. #include <asm/io.h>
  20. #include <asm/cpm2.h>
  21. #include <asm/udbg.h>
  22. #include <asm/machdep.h>
  23. #include <asm/time.h>
  24. #include <asm/mpc8260.h>
  25. #include <asm/prom.h>
  26. #include <sysdev/fsl_soc.h>
  27. #include <sysdev/cpm2_pic.h>
  28. #include "pq2.h"
  29. static void __init mgcoge_pic_init(void)
  30. {
  31. struct device_node *np = of_find_compatible_node(NULL, NULL, "fsl,pq2-pic");
  32. if (!np) {
  33. printk(KERN_ERR "PIC init: can not find cpm-pic node\n");
  34. return;
  35. }
  36. cpm2_pic_init(np);
  37. of_node_put(np);
  38. }
  39. struct cpm_pin {
  40. int port, pin, flags;
  41. };
  42. static __initdata struct cpm_pin mgcoge_pins[] = {
  43. /* SMC2 */
  44. {1, 8, CPM_PIN_INPUT | CPM_PIN_PRIMARY},
  45. {1, 9, CPM_PIN_OUTPUT | CPM_PIN_PRIMARY},
  46. /* SCC4 */
  47. {3, 25, CPM_PIN_INPUT | CPM_PIN_PRIMARY},
  48. {3, 24, CPM_PIN_INPUT | CPM_PIN_PRIMARY},
  49. {3, 9, CPM_PIN_INPUT | CPM_PIN_PRIMARY},
  50. {3, 8, CPM_PIN_INPUT | CPM_PIN_PRIMARY},
  51. {4, 22, CPM_PIN_INPUT | CPM_PIN_PRIMARY},
  52. {4, 21, CPM_PIN_OUTPUT | CPM_PIN_PRIMARY},
  53. };
  54. static void __init init_ioports(void)
  55. {
  56. int i;
  57. for (i = 0; i < ARRAY_SIZE(mgcoge_pins); i++) {
  58. const struct cpm_pin *pin = &mgcoge_pins[i];
  59. cpm2_set_pin(pin->port - 1, pin->pin, pin->flags);
  60. }
  61. cpm2_smc_clk_setup(CPM_CLK_SMC2, CPM_BRG8);
  62. cpm2_clk_setup(CPM_CLK_SCC4, CPM_CLK7, CPM_CLK_RX);
  63. cpm2_clk_setup(CPM_CLK_SCC4, CPM_CLK8, CPM_CLK_TX);
  64. }
  65. static void __init mgcoge_setup_arch(void)
  66. {
  67. if (ppc_md.progress)
  68. ppc_md.progress("mgcoge_setup_arch()", 0);
  69. cpm2_reset();
  70. /* When this is set, snooping CPM DMA from RAM causes
  71. * machine checks. See erratum SIU18.
  72. */
  73. clrbits32(&cpm2_immr->im_siu_conf.siu_82xx.sc_bcr, MPC82XX_BCR_PLDP);
  74. init_ioports();
  75. if (ppc_md.progress)
  76. ppc_md.progress("mgcoge_setup_arch(), finish", 0);
  77. }
  78. static __initdata struct of_device_id of_bus_ids[] = {
  79. { .compatible = "simple-bus", },
  80. {},
  81. };
  82. static int __init declare_of_platform_devices(void)
  83. {
  84. of_platform_bus_probe(NULL, of_bus_ids, NULL);
  85. return 0;
  86. }
  87. machine_device_initcall(mgcoge, declare_of_platform_devices);
  88. /*
  89. * Called very early, device-tree isn't unflattened
  90. */
  91. static int __init mgcoge_probe(void)
  92. {
  93. unsigned long root = of_get_flat_dt_root();
  94. return of_flat_dt_is_compatible(root, "keymile,mgcoge");
  95. }
  96. define_machine(mgcoge)
  97. {
  98. .name = "Keymile MGCOGE",
  99. .probe = mgcoge_probe,
  100. .setup_arch = mgcoge_setup_arch,
  101. .init_IRQ = mgcoge_pic_init,
  102. .get_irq = cpm2_get_irq,
  103. .calibrate_decr = generic_calibrate_decr,
  104. .restart = pq2_restart,
  105. .progress = udbg_progress,
  106. };