lite5200.c 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188
  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/irq.h>
  36. #include <asm/prom.h>
  37. #include <asm/udbg.h>
  38. #include <sysdev/fsl_soc.h>
  39. #include <asm/of_platform.h>
  40. #include <asm/mpc52xx.h>
  41. /* ************************************************************************
  42. *
  43. * Setup the architecture
  44. *
  45. */
  46. static void __init
  47. lite5200_setup_cpu(void)
  48. {
  49. struct mpc52xx_gpio __iomem *gpio;
  50. u32 port_config;
  51. /* Map zones */
  52. gpio = mpc52xx_find_and_map("mpc5200-gpio");
  53. if (!gpio) {
  54. printk(KERN_ERR __FILE__ ": "
  55. "Error while mapping GPIO register for port config. "
  56. "Expect some abnormal behavior\n");
  57. goto error;
  58. }
  59. /* Set port config */
  60. port_config = in_be32(&gpio->port_config);
  61. port_config &= ~0x00800000; /* 48Mhz internal, pin is GPIO */
  62. port_config &= ~0x00007000; /* USB port : Differential mode */
  63. port_config |= 0x00001000; /* USB 1 only */
  64. port_config &= ~0x03000000; /* ATA CS is on csb_4/5 */
  65. port_config |= 0x01000000;
  66. pr_debug("port_config: old:%x new:%x\n",
  67. in_be32(&gpio->port_config), port_config);
  68. out_be32(&gpio->port_config, port_config);
  69. /* Unmap zone */
  70. error:
  71. iounmap(gpio);
  72. }
  73. #ifdef CONFIG_PM
  74. static u32 descr_a;
  75. static void lite5200_suspend_prepare(void __iomem *mbar)
  76. {
  77. u8 pin = 1; /* GPIO_WKUP_1 (GPIO_PSC2_4) */
  78. u8 level = 0; /* wakeup on low level */
  79. mpc52xx_set_wakeup_gpio(pin, level);
  80. /*
  81. * power down usb port
  82. * this needs to be called before of-ohci suspend code
  83. */
  84. descr_a = in_be32(mbar + 0x1048);
  85. out_be32(mbar + 0x1048, (descr_a & ~0x200) | 0x100);
  86. }
  87. static void lite5200_resume_finish(void __iomem *mbar)
  88. {
  89. out_be32(mbar + 0x1048, descr_a);
  90. }
  91. #endif
  92. static void __init lite5200_setup_arch(void)
  93. {
  94. #ifdef CONFIG_PCI
  95. struct device_node *np;
  96. #endif
  97. if (ppc_md.progress)
  98. ppc_md.progress("lite5200_setup_arch()", 0);
  99. /* CPU & Port mux setup */
  100. mpc52xx_setup_cpu(); /* Generic */
  101. lite5200_setup_cpu(); /* Platorm specific */
  102. #ifdef CONFIG_PM
  103. mpc52xx_suspend.board_suspend_prepare = lite5200_suspend_prepare;
  104. mpc52xx_suspend.board_resume_finish = lite5200_resume_finish;
  105. mpc52xx_pm_init();
  106. #endif
  107. #ifdef CONFIG_PCI
  108. np = of_find_node_by_type(NULL, "pci");
  109. if (np) {
  110. mpc52xx_add_bridge(np);
  111. of_node_put(np);
  112. }
  113. #endif
  114. #ifdef CONFIG_BLK_DEV_INITRD
  115. if (initrd_start)
  116. ROOT_DEV = Root_RAM0;
  117. else
  118. #endif
  119. #ifdef CONFIG_ROOT_NFS
  120. ROOT_DEV = Root_NFS;
  121. #else
  122. ROOT_DEV = Root_HDA1;
  123. #endif
  124. }
  125. static void lite5200_show_cpuinfo(struct seq_file *m)
  126. {
  127. struct device_node* np = of_find_all_nodes(NULL);
  128. const char *model = NULL;
  129. if (np)
  130. model = of_get_property(np, "model", NULL);
  131. seq_printf(m, "vendor\t\t: Freescale Semiconductor\n");
  132. seq_printf(m, "machine\t\t: %s\n", model ? model : "unknown");
  133. of_node_put(np);
  134. }
  135. /*
  136. * Called very early, MMU is off, device-tree isn't unflattened
  137. */
  138. static int __init lite5200_probe(void)
  139. {
  140. unsigned long node = of_get_flat_dt_root();
  141. const char *model = of_get_flat_dt_prop(node, "model", NULL);
  142. if (!of_flat_dt_is_compatible(node, "fsl,lite5200") &&
  143. !of_flat_dt_is_compatible(node, "fsl,lite5200b"))
  144. return 0;
  145. pr_debug("%s board found\n", model ? model : "unknown");
  146. return 1;
  147. }
  148. define_machine(lite5200) {
  149. .name = "lite5200",
  150. .probe = lite5200_probe,
  151. .setup_arch = lite5200_setup_arch,
  152. .init = mpc52xx_declare_of_platform_devices,
  153. .init_IRQ = mpc52xx_init_irq,
  154. .get_irq = mpc52xx_get_irq,
  155. .show_cpuinfo = lite5200_show_cpuinfo,
  156. .calibrate_decr = generic_calibrate_decr,
  157. };