/arch/powerpc/platforms/44x/canyonlands.c

http://github.com/mirrors/linux · C · 118 lines · 82 code · 17 blank · 19 comment · 5 complexity · 1e1f8065ca772d073ac601e3fdee73b7 MD5 · raw file

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