canyonlands.c 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. // SPDX-License-Identifier: GPL-2.0-or-later
  2. /*
  3. * This contain platform specific code for APM PPC460EX based Canyonlands
  4. * board.
  5. *
  6. * Copyright (c) 2010, Applied Micro Circuits Corporation
  7. * Author: Rupjyoti Sarmah <[email protected]>
  8. */
  9. #include <linux/kernel.h>
  10. #include <linux/init.h>
  11. #include <asm/pci-bridge.h>
  12. #include <asm/ppc4xx.h>
  13. #include <asm/udbg.h>
  14. #include <asm/uic.h>
  15. #include <linux/of_address.h>
  16. #include <linux/of_platform.h>
  17. #include <linux/delay.h>
  18. #include "44x.h"
  19. #define BCSR_USB_EN 0x11
  20. static const struct of_device_id ppc460ex_of_bus[] __initconst = {
  21. { .compatible = "ibm,plb4", },
  22. { .compatible = "ibm,opb", },
  23. { .compatible = "ibm,ebc", },
  24. { .compatible = "simple-bus", },
  25. {},
  26. };
  27. static int __init ppc460ex_device_probe(void)
  28. {
  29. of_platform_bus_probe(NULL, ppc460ex_of_bus, NULL);
  30. return 0;
  31. }
  32. machine_device_initcall(canyonlands, ppc460ex_device_probe);
  33. /* Using this code only for the Canyonlands board. */
  34. static int __init ppc460ex_probe(void)
  35. {
  36. if (of_machine_is_compatible("amcc,canyonlands")) {
  37. pci_set_flags(PCI_REASSIGN_ALL_RSRC);
  38. return 1;
  39. }
  40. return 0;
  41. }
  42. /* USB PHY fixup code on Canyonlands kit. */
  43. static int __init ppc460ex_canyonlands_fixup(void)
  44. {
  45. u8 __iomem *bcsr ;
  46. void __iomem *vaddr;
  47. struct device_node *np;
  48. int ret = 0;
  49. np = of_find_compatible_node(NULL, NULL, "amcc,ppc460ex-bcsr");
  50. if (!np) {
  51. printk(KERN_ERR "failed did not find amcc, ppc460ex bcsr node\n");
  52. return -ENODEV;
  53. }
  54. bcsr = of_iomap(np, 0);
  55. of_node_put(np);
  56. if (!bcsr) {
  57. printk(KERN_CRIT "Could not remap bcsr\n");
  58. ret = -ENODEV;
  59. goto err_bcsr;
  60. }
  61. np = of_find_compatible_node(NULL, NULL, "ibm,ppc4xx-gpio");
  62. if (!np) {
  63. printk(KERN_ERR "failed did not find ibm,ppc4xx-gpio node\n");
  64. return -ENODEV;
  65. }
  66. vaddr = of_iomap(np, 0);
  67. of_node_put(np);
  68. if (!vaddr) {
  69. printk(KERN_CRIT "Could not get gpio node address\n");
  70. ret = -ENODEV;
  71. goto err_gpio;
  72. }
  73. /* Disable USB, through the BCSR7 bits */
  74. setbits8(&bcsr[7], BCSR_USB_EN);
  75. /* Wait for a while after reset */
  76. msleep(100);
  77. /* Enable USB here */
  78. clrbits8(&bcsr[7], BCSR_USB_EN);
  79. /*
  80. * Configure multiplexed gpio16 and gpio19 as alternate1 output
  81. * source after USB reset. In this configuration gpio16 will be
  82. * USB2HStop and gpio19 will be USB2DStop. For more details refer to
  83. * table 34-7 of PPC460EX user manual.
  84. */
  85. setbits32((vaddr + GPIO0_OSRH), 0x42000000);
  86. setbits32((vaddr + GPIO0_TSRH), 0x42000000);
  87. err_gpio:
  88. iounmap(vaddr);
  89. err_bcsr:
  90. iounmap(bcsr);
  91. return ret;
  92. }
  93. machine_device_initcall(canyonlands, ppc460ex_canyonlands_fixup);
  94. define_machine(canyonlands) {
  95. .name = "Canyonlands",
  96. .probe = ppc460ex_probe,
  97. .progress = udbg_progress,
  98. .init_IRQ = uic_init_tree,
  99. .get_irq = uic_get_irq,
  100. .restart = ppc4xx_reset_system,
  101. .calibrate_decr = generic_calibrate_decr,
  102. };