p1023_rds.c 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  1. /*
  2. * Copyright 2010-2011 Freescale Semiconductor, Inc.
  3. *
  4. * Author: Roy Zang <tie-fei.zang@freescale.com>
  5. *
  6. * Description:
  7. * P1023 RDS Board Setup
  8. *
  9. * This program is free software; you can redistribute it and/or modify it
  10. * under the terms of the GNU General Public License as published by the
  11. * Free Software Foundation; either version 2 of the License, or (at your
  12. * option) any later version.
  13. */
  14. #include <linux/kernel.h>
  15. #include <linux/init.h>
  16. #include <linux/errno.h>
  17. #include <linux/pci.h>
  18. #include <linux/delay.h>
  19. #include <linux/module.h>
  20. #include <linux/fsl_devices.h>
  21. #include <linux/of_platform.h>
  22. #include <linux/of_device.h>
  23. #include <asm/system.h>
  24. #include <asm/time.h>
  25. #include <asm/machdep.h>
  26. #include <asm/pci-bridge.h>
  27. #include <mm/mmu_decl.h>
  28. #include <asm/prom.h>
  29. #include <asm/udbg.h>
  30. #include <asm/mpic.h>
  31. #include <sysdev/fsl_soc.h>
  32. #include <sysdev/fsl_pci.h>
  33. /* ************************************************************************
  34. *
  35. * Setup the architecture
  36. *
  37. */
  38. #ifdef CONFIG_SMP
  39. void __init mpc85xx_smp_init(void);
  40. #endif
  41. static void __init mpc85xx_rds_setup_arch(void)
  42. {
  43. struct device_node *np;
  44. if (ppc_md.progress)
  45. ppc_md.progress("p1023_rds_setup_arch()", 0);
  46. /* Map BCSR area */
  47. np = of_find_node_by_name(NULL, "bcsr");
  48. if (np != NULL) {
  49. static u8 __iomem *bcsr_regs;
  50. bcsr_regs = of_iomap(np, 0);
  51. of_node_put(np);
  52. if (!bcsr_regs) {
  53. printk(KERN_ERR
  54. "BCSR: Failed to map bcsr register space\n");
  55. return;
  56. } else {
  57. #define BCSR15_I2C_BUS0_SEG_CLR 0x07
  58. #define BCSR15_I2C_BUS0_SEG2 0x02
  59. /*
  60. * Note: Accessing exclusively i2c devices.
  61. *
  62. * The i2c controller selects initially ID EEPROM in the u-boot;
  63. * but if menu configuration selects RTC support in the kernel,
  64. * the i2c controller switches to select RTC chip in the kernel.
  65. */
  66. #ifdef CONFIG_RTC_CLASS
  67. /* Enable RTC chip on the segment #2 of i2c */
  68. clrbits8(&bcsr_regs[15], BCSR15_I2C_BUS0_SEG_CLR);
  69. setbits8(&bcsr_regs[15], BCSR15_I2C_BUS0_SEG2);
  70. #endif
  71. iounmap(bcsr_regs);
  72. }
  73. }
  74. #ifdef CONFIG_PCI
  75. for_each_compatible_node(np, "pci", "fsl,p1023-pcie")
  76. fsl_add_bridge(np, 0);
  77. #endif
  78. #ifdef CONFIG_SMP
  79. mpc85xx_smp_init();
  80. #endif
  81. }
  82. static struct of_device_id p1023_ids[] = {
  83. { .type = "soc", },
  84. { .compatible = "soc", },
  85. { .compatible = "simple-bus", },
  86. {},
  87. };
  88. static int __init p1023_publish_devices(void)
  89. {
  90. of_platform_bus_probe(NULL, p1023_ids, NULL);
  91. return 0;
  92. }
  93. machine_device_initcall(p1023_rds, p1023_publish_devices);
  94. static void __init mpc85xx_rds_pic_init(void)
  95. {
  96. struct mpic *mpic;
  97. struct resource r;
  98. struct device_node *np = NULL;
  99. np = of_find_node_by_type(NULL, "open-pic");
  100. if (!np) {
  101. printk(KERN_ERR "Could not find open-pic node\n");
  102. return;
  103. }
  104. if (of_address_to_resource(np, 0, &r)) {
  105. printk(KERN_ERR "Failed to map mpic register space\n");
  106. of_node_put(np);
  107. return;
  108. }
  109. mpic = mpic_alloc(np, r.start,
  110. MPIC_PRIMARY | MPIC_WANTS_RESET | MPIC_BIG_ENDIAN |
  111. MPIC_BROKEN_FRR_NIRQS | MPIC_SINGLE_DEST_CPU,
  112. 0, 256, " OpenPIC ");
  113. BUG_ON(mpic == NULL);
  114. of_node_put(np);
  115. mpic_init(mpic);
  116. }
  117. static int __init p1023_rds_probe(void)
  118. {
  119. unsigned long root = of_get_flat_dt_root();
  120. return of_flat_dt_is_compatible(root, "fsl,P1023RDS");
  121. }
  122. define_machine(p1023_rds) {
  123. .name = "P1023 RDS",
  124. .probe = p1023_rds_probe,
  125. .setup_arch = mpc85xx_rds_setup_arch,
  126. .init_IRQ = mpc85xx_rds_pic_init,
  127. .get_irq = mpic_get_irq,
  128. .restart = fsl_rstcr_restart,
  129. .calibrate_decr = generic_calibrate_decr,
  130. .progress = udbg_progress,
  131. #ifdef CONFIG_PCI
  132. .pcibios_fixup_bus = fsl_pcibios_fixup_bus,
  133. #endif
  134. };