p1023_rds.c 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  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 "smp.h"
  32. #include <sysdev/fsl_soc.h>
  33. #include <sysdev/fsl_pci.h>
  34. #include "mpc85xx.h"
  35. /* ************************************************************************
  36. *
  37. * Setup the architecture
  38. *
  39. */
  40. static void __init mpc85xx_rds_setup_arch(void)
  41. {
  42. struct device_node *np;
  43. if (ppc_md.progress)
  44. ppc_md.progress("p1023_rds_setup_arch()", 0);
  45. /* Map BCSR area */
  46. np = of_find_node_by_name(NULL, "bcsr");
  47. if (np != NULL) {
  48. static u8 __iomem *bcsr_regs;
  49. bcsr_regs = of_iomap(np, 0);
  50. of_node_put(np);
  51. if (!bcsr_regs) {
  52. printk(KERN_ERR
  53. "BCSR: Failed to map bcsr register space\n");
  54. return;
  55. } else {
  56. #define BCSR15_I2C_BUS0_SEG_CLR 0x07
  57. #define BCSR15_I2C_BUS0_SEG2 0x02
  58. /*
  59. * Note: Accessing exclusively i2c devices.
  60. *
  61. * The i2c controller selects initially ID EEPROM in the u-boot;
  62. * but if menu configuration selects RTC support in the kernel,
  63. * the i2c controller switches to select RTC chip in the kernel.
  64. */
  65. #ifdef CONFIG_RTC_CLASS
  66. /* Enable RTC chip on the segment #2 of i2c */
  67. clrbits8(&bcsr_regs[15], BCSR15_I2C_BUS0_SEG_CLR);
  68. setbits8(&bcsr_regs[15], BCSR15_I2C_BUS0_SEG2);
  69. #endif
  70. iounmap(bcsr_regs);
  71. }
  72. }
  73. #ifdef CONFIG_PCI
  74. for_each_compatible_node(np, "pci", "fsl,p1023-pcie")
  75. fsl_add_bridge(np, 0);
  76. #endif
  77. mpc85xx_smp_init();
  78. }
  79. machine_device_initcall(p1023_rds, mpc85xx_common_publish_devices);
  80. static void __init mpc85xx_rds_pic_init(void)
  81. {
  82. struct mpic *mpic = mpic_alloc(NULL, 0,
  83. MPIC_WANTS_RESET | MPIC_BIG_ENDIAN |
  84. MPIC_BROKEN_FRR_NIRQS | MPIC_SINGLE_DEST_CPU,
  85. 0, 256, " OpenPIC ");
  86. BUG_ON(mpic == NULL);
  87. mpic_init(mpic);
  88. }
  89. static int __init p1023_rds_probe(void)
  90. {
  91. unsigned long root = of_get_flat_dt_root();
  92. return of_flat_dt_is_compatible(root, "fsl,P1023RDS");
  93. }
  94. define_machine(p1023_rds) {
  95. .name = "P1023 RDS",
  96. .probe = p1023_rds_probe,
  97. .setup_arch = mpc85xx_rds_setup_arch,
  98. .init_IRQ = mpc85xx_rds_pic_init,
  99. .get_irq = mpic_get_irq,
  100. .restart = fsl_rstcr_restart,
  101. .calibrate_decr = generic_calibrate_decr,
  102. .progress = udbg_progress,
  103. #ifdef CONFIG_PCI
  104. .pcibios_fixup_bus = fsl_pcibios_fixup_bus,
  105. #endif
  106. };