lite5200.c 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  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. lite52xx_setup_cpu(void)
  49. {
  50. struct mpc52xx_gpio __iomem *gpio;
  51. u32 port_config;
  52. /* Map zones */
  53. gpio = mpc52xx_find_and_map("mpc52xx-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 lite52xx_setup_arch(void)
  75. {
  76. struct device_node *np;
  77. if (ppc_md.progress)
  78. ppc_md.progress("lite52xx_setup_arch()", 0);
  79. np = of_find_node_by_type(NULL, "cpu");
  80. if (np) {
  81. unsigned int *fp =
  82. (int *)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. lite52xx_setup_cpu(); /* Platorm specific */
  92. #ifdef CONFIG_PCI
  93. np = of_find_node_by_type(np, "pci");
  94. if (np)
  95. mpc52xx_add_bridge(np);
  96. #endif
  97. #ifdef CONFIG_BLK_DEV_INITRD
  98. if (initrd_start)
  99. ROOT_DEV = Root_RAM0;
  100. else
  101. #endif
  102. #ifdef CONFIG_ROOT_NFS
  103. ROOT_DEV = Root_NFS;
  104. #else
  105. ROOT_DEV = Root_HDA1;
  106. #endif
  107. }
  108. void lite52xx_show_cpuinfo(struct seq_file *m)
  109. {
  110. struct device_node* np = of_find_all_nodes(NULL);
  111. const char *model = NULL;
  112. if (np)
  113. model = get_property(np, "model", NULL);
  114. seq_printf(m, "vendor\t\t: Freescale Semiconductor\n");
  115. seq_printf(m, "machine\t\t: %s\n", model ? model : "unknown");
  116. of_node_put(np);
  117. }
  118. /*
  119. * Called very early, MMU is off, device-tree isn't unflattened
  120. */
  121. static int __init lite52xx_probe(void)
  122. {
  123. unsigned long node = of_get_flat_dt_root();
  124. const char *model = of_get_flat_dt_prop(node, "model", NULL);
  125. if (!of_flat_dt_is_compatible(node, "lite52xx"))
  126. return 0;
  127. pr_debug("%s board w/ mpc52xx found\n", model ? model : "unknown");
  128. return 1;
  129. }
  130. define_machine(lite52xx) {
  131. .name = "lite52xx",
  132. .probe = lite52xx_probe,
  133. .setup_arch = lite52xx_setup_arch,
  134. .init = mpc52xx_declare_of_platform_devices,
  135. .init_IRQ = mpc52xx_init_irq,
  136. .get_irq = mpc52xx_get_irq,
  137. .show_cpuinfo = lite52xx_show_cpuinfo,
  138. .calibrate_decr = generic_calibrate_decr,
  139. };