canyonlands.c 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. /*
  2. * This contain platform specific code for APM PPC460EX based Canyonlands
  3. * board.
  4. *
  5. * Copyright (c) 2010, Applied Micro Circuits Corporation
  6. * Author: Rupjyoti Sarmah <rsarmah@apm.com>
  7. *
  8. * This program is free software; you can redistribute it and/or
  9. * modify it under the terms of the GNU General Public License as
  10. * published by the Free Software Foundation; either version 2 of
  11. * the License, or (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program; if not, write to the Free Software
  20. * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  21. * MA 02111-1307 USA
  22. *
  23. */
  24. #include <linux/kernel.h>
  25. #include <linux/init.h>
  26. #include <asm/pci-bridge.h>
  27. #include <asm/ppc4xx.h>
  28. #include <asm/udbg.h>
  29. #include <asm/uic.h>
  30. #include <linux/of_platform.h>
  31. #include <linux/delay.h>
  32. #include "44x.h"
  33. #define BCSR_USB_EN 0x11
  34. static const struct of_device_id ppc460ex_of_bus[] __initconst = {
  35. { .compatible = "ibm,plb4", },
  36. { .compatible = "ibm,opb", },
  37. { .compatible = "ibm,ebc", },
  38. { .compatible = "simple-bus", },
  39. {},
  40. };
  41. static int __init ppc460ex_device_probe(void)
  42. {
  43. of_platform_bus_probe(NULL, ppc460ex_of_bus, NULL);
  44. return 0;
  45. }
  46. machine_device_initcall(canyonlands, ppc460ex_device_probe);
  47. /* Using this code only for the Canyonlands board. */
  48. static int __init ppc460ex_probe(void)
  49. {
  50. if (of_machine_is_compatible("amcc,canyonlands")) {
  51. pci_set_flags(PCI_REASSIGN_ALL_RSRC);
  52. return 1;
  53. }
  54. return 0;
  55. }
  56. /* USB PHY fixup code on Canyonlands kit. */
  57. static int __init ppc460ex_canyonlands_fixup(void)
  58. {
  59. u8 __iomem *bcsr ;
  60. void __iomem *vaddr;
  61. struct device_node *np;
  62. int ret = 0;
  63. np = of_find_compatible_node(NULL, NULL, "amcc,ppc460ex-bcsr");
  64. if (!np) {
  65. printk(KERN_ERR "failed did not find amcc, ppc460ex bcsr node\n");
  66. return -ENODEV;
  67. }
  68. bcsr = of_iomap(np, 0);
  69. of_node_put(np);
  70. if (!bcsr) {
  71. printk(KERN_CRIT "Could not remap bcsr\n");
  72. ret = -ENODEV;
  73. goto err_bcsr;
  74. }
  75. np = of_find_compatible_node(NULL, NULL, "ibm,ppc4xx-gpio");
  76. if (!np) {
  77. printk(KERN_ERR "failed did not find ibm,ppc4xx-gpio node\n");
  78. return -ENODEV;
  79. }
  80. vaddr = of_iomap(np, 0);
  81. of_node_put(np);
  82. if (!vaddr) {
  83. printk(KERN_CRIT "Could not get gpio node address\n");
  84. ret = -ENODEV;
  85. goto err_gpio;
  86. }
  87. /* Disable USB, through the BCSR7 bits */
  88. setbits8(&bcsr[7], BCSR_USB_EN);
  89. /* Wait for a while after reset */
  90. msleep(100);
  91. /* Enable USB here */
  92. clrbits8(&bcsr[7], BCSR_USB_EN);
  93. /*
  94. * Configure multiplexed gpio16 and gpio19 as alternate1 output
  95. * source after USB reset. In this configuration gpio16 will be
  96. * USB2HStop and gpio19 will be USB2DStop. For more details refer to
  97. * table 34-7 of PPC460EX user manual.
  98. */
  99. setbits32((vaddr + GPIO0_OSRH), 0x42000000);
  100. setbits32((vaddr + GPIO0_TSRH), 0x42000000);
  101. err_gpio:
  102. iounmap(vaddr);
  103. err_bcsr:
  104. iounmap(bcsr);
  105. return ret;
  106. }
  107. machine_device_initcall(canyonlands, ppc460ex_canyonlands_fixup);
  108. define_machine(canyonlands) {
  109. .name = "Canyonlands",
  110. .probe = ppc460ex_probe,
  111. .progress = udbg_progress,
  112. .init_IRQ = uic_init_tree,
  113. .get_irq = uic_get_irq,
  114. .restart = ppc4xx_reset_system,
  115. .calibrate_decr = generic_calibrate_decr,
  116. };