lite5200.c 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198
  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. #ifdef CONFIG_PM
  75. static u32 descr_a;
  76. static void lite5200_suspend_prepare(void __iomem *mbar)
  77. {
  78. u8 pin = 1; /* GPIO_WKUP_1 (GPIO_PSC2_4) */
  79. u8 level = 0; /* wakeup on low level */
  80. mpc52xx_set_wakeup_gpio(pin, level);
  81. /*
  82. * power down usb port
  83. * this needs to be called before of-ohci suspend code
  84. */
  85. descr_a = in_be32(mbar + 0x1048);
  86. out_be32(mbar + 0x1048, (descr_a & ~0x200) | 0x100);
  87. }
  88. static void lite5200_resume_finish(void __iomem *mbar)
  89. {
  90. out_be32(mbar + 0x1048, descr_a);
  91. }
  92. #endif
  93. static void __init lite5200_setup_arch(void)
  94. {
  95. struct device_node *np;
  96. if (ppc_md.progress)
  97. ppc_md.progress("lite5200_setup_arch()", 0);
  98. np = of_find_node_by_type(NULL, "cpu");
  99. if (np) {
  100. const unsigned int *fp =
  101. of_get_property(np, "clock-frequency", NULL);
  102. if (fp != 0)
  103. loops_per_jiffy = *fp / HZ;
  104. else
  105. loops_per_jiffy = 50000000 / HZ;
  106. of_node_put(np);
  107. }
  108. /* CPU & Port mux setup */
  109. mpc52xx_setup_cpu(); /* Generic */
  110. lite5200_setup_cpu(); /* Platorm specific */
  111. #ifdef CONFIG_PM
  112. mpc52xx_suspend.board_suspend_prepare = lite5200_suspend_prepare;
  113. mpc52xx_suspend.board_resume_finish = lite5200_resume_finish;
  114. mpc52xx_pm_init();
  115. #endif
  116. #ifdef CONFIG_PCI
  117. np = of_find_node_by_type(NULL, "pci");
  118. if (np) {
  119. mpc52xx_add_bridge(np);
  120. of_node_put(np);
  121. }
  122. #endif
  123. #ifdef CONFIG_BLK_DEV_INITRD
  124. if (initrd_start)
  125. ROOT_DEV = Root_RAM0;
  126. else
  127. #endif
  128. #ifdef CONFIG_ROOT_NFS
  129. ROOT_DEV = Root_NFS;
  130. #else
  131. ROOT_DEV = Root_HDA1;
  132. #endif
  133. }
  134. void lite5200_show_cpuinfo(struct seq_file *m)
  135. {
  136. struct device_node* np = of_find_all_nodes(NULL);
  137. const char *model = NULL;
  138. if (np)
  139. model = of_get_property(np, "model", NULL);
  140. seq_printf(m, "vendor\t\t: Freescale Semiconductor\n");
  141. seq_printf(m, "machine\t\t: %s\n", model ? model : "unknown");
  142. of_node_put(np);
  143. }
  144. /*
  145. * Called very early, MMU is off, device-tree isn't unflattened
  146. */
  147. static int __init lite5200_probe(void)
  148. {
  149. unsigned long node = of_get_flat_dt_root();
  150. const char *model = of_get_flat_dt_prop(node, "model", NULL);
  151. if (!of_flat_dt_is_compatible(node, "fsl,lite5200") &&
  152. !of_flat_dt_is_compatible(node, "fsl,lite5200b"))
  153. return 0;
  154. pr_debug("%s board found\n", model ? model : "unknown");
  155. return 1;
  156. }
  157. define_machine(lite5200) {
  158. .name = "lite5200",
  159. .probe = lite5200_probe,
  160. .setup_arch = lite5200_setup_arch,
  161. .init = mpc52xx_declare_of_platform_devices,
  162. .init_IRQ = mpc52xx_init_irq,
  163. .get_irq = mpc52xx_get_irq,
  164. .show_cpuinfo = lite5200_show_cpuinfo,
  165. .calibrate_decr = generic_calibrate_decr,
  166. };