lite5200.c 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  1. /*
  2. * Freescale Lite5200 board support
  3. *
  4. * Written by: Grant Likely <grant.likely@secretlab.ca>
  5. *
  6. * Copyright (C) Secret Lab Technologies Ltd. 2006. All rights reserved.
  7. * Copyright (C) Freescale Semicondutor, Inc. 2006. All rights reserved.
  8. *
  9. * Description:
  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. #undef DEBUG
  16. #include <linux/stddef.h>
  17. #include <linux/kernel.h>
  18. #include <linux/init.h>
  19. #include <linux/errno.h>
  20. #include <linux/reboot.h>
  21. #include <linux/pci.h>
  22. #include <linux/kdev_t.h>
  23. #include <linux/major.h>
  24. #include <linux/console.h>
  25. #include <linux/delay.h>
  26. #include <linux/seq_file.h>
  27. #include <linux/root_dev.h>
  28. #include <linux/initrd.h>
  29. #include <asm/system.h>
  30. #include <asm/atomic.h>
  31. #include <asm/time.h>
  32. #include <asm/io.h>
  33. #include <asm/machdep.h>
  34. #include <asm/ipic.h>
  35. #include <asm/bootinfo.h>
  36. #include <asm/irq.h>
  37. #include <asm/prom.h>
  38. #include <asm/udbg.h>
  39. #include <sysdev/fsl_soc.h>
  40. #include <asm/of_platform.h>
  41. #include <asm/mpc52xx.h>
  42. /* ************************************************************************
  43. *
  44. * Setup the architecture
  45. *
  46. */
  47. static void __init
  48. lite5200_setup_cpu(void)
  49. {
  50. struct mpc52xx_gpio __iomem *gpio;
  51. u32 port_config;
  52. /* Map zones */
  53. gpio = mpc52xx_find_and_map("mpc5200-gpio");
  54. if (!gpio) {
  55. printk(KERN_ERR __FILE__ ": "
  56. "Error while mapping GPIO register for port config. "
  57. "Expect some abnormal behavior\n");
  58. goto error;
  59. }
  60. /* Set port config */
  61. port_config = in_be32(&gpio->port_config);
  62. port_config &= ~0x00800000; /* 48Mhz internal, pin is GPIO */
  63. port_config &= ~0x00007000; /* USB port : Differential mode */
  64. port_config |= 0x00001000; /* USB 1 only */
  65. port_config &= ~0x03000000; /* ATA CS is on csb_4/5 */
  66. port_config |= 0x01000000;
  67. pr_debug("port_config: old:%x new:%x\n",
  68. in_be32(&gpio->port_config), port_config);
  69. out_be32(&gpio->port_config, port_config);
  70. /* Unmap zone */
  71. error:
  72. iounmap(gpio);
  73. }
  74. static void __init lite5200_setup_arch(void)
  75. {
  76. struct device_node *np;
  77. if (ppc_md.progress)
  78. ppc_md.progress("lite5200_setup_arch()", 0);
  79. np = of_find_node_by_type(NULL, "cpu");
  80. if (np) {
  81. const unsigned int *fp =
  82. of_get_property(np, "clock-frequency", NULL);
  83. if (fp != 0)
  84. loops_per_jiffy = *fp / HZ;
  85. else
  86. loops_per_jiffy = 50000000 / HZ;
  87. of_node_put(np);
  88. }
  89. /* CPU & Port mux setup */
  90. mpc52xx_setup_cpu(); /* Generic */
  91. lite5200_setup_cpu(); /* Platorm specific */
  92. #ifdef CONFIG_PCI
  93. np = of_find_node_by_type(NULL, "pci");
  94. if (np) {
  95. mpc52xx_add_bridge(np);
  96. of_node_put(np);
  97. }
  98. #endif
  99. #ifdef CONFIG_BLK_DEV_INITRD
  100. if (initrd_start)
  101. ROOT_DEV = Root_RAM0;
  102. else
  103. #endif
  104. #ifdef CONFIG_ROOT_NFS
  105. ROOT_DEV = Root_NFS;
  106. #else
  107. ROOT_DEV = Root_HDA1;
  108. #endif
  109. }
  110. void lite5200_show_cpuinfo(struct seq_file *m)
  111. {
  112. struct device_node* np = of_find_all_nodes(NULL);
  113. const char *model = NULL;
  114. if (np)
  115. model = of_get_property(np, "model", NULL);
  116. seq_printf(m, "vendor\t\t: Freescale Semiconductor\n");
  117. seq_printf(m, "machine\t\t: %s\n", model ? model : "unknown");
  118. of_node_put(np);
  119. }
  120. /*
  121. * Called very early, MMU is off, device-tree isn't unflattened
  122. */
  123. static int __init lite5200_probe(void)
  124. {
  125. unsigned long node = of_get_flat_dt_root();
  126. const char *model = of_get_flat_dt_prop(node, "model", NULL);
  127. if (!of_flat_dt_is_compatible(node, "fsl,lite5200") &&
  128. !of_flat_dt_is_compatible(node, "fsl,lite5200b"))
  129. return 0;
  130. pr_debug("%s board found\n", model ? model : "unknown");
  131. return 1;
  132. }
  133. define_machine(lite5200) {
  134. .name = "lite5200",
  135. .probe = lite5200_probe,
  136. .setup_arch = lite5200_setup_arch,
  137. .init = mpc52xx_declare_of_platform_devices,
  138. .init_IRQ = mpc52xx_init_irq,
  139. .get_irq = mpc52xx_get_irq,
  140. .show_cpuinfo = lite5200_show_cpuinfo,
  141. .calibrate_decr = generic_calibrate_decr,
  142. };