]> git.proxmox.com Git - mirror_ubuntu-hirsute-kernel.git/blame - arch/powerpc/platforms/44x/canyonlands.c
treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 156
[mirror_ubuntu-hirsute-kernel.git] / arch / powerpc / platforms / 44x / canyonlands.c
CommitLineData
1a59d1b8 1// SPDX-License-Identifier: GPL-2.0-or-later
8960f7ff
RS
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>
8960f7ff
RS
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
19#define BCSR_USB_EN 0x11
20
ce6d73c9 21static const struct of_device_id ppc460ex_of_bus[] __initconst = {
8960f7ff
RS
22 { .compatible = "ibm,plb4", },
23 { .compatible = "ibm,opb", },
24 { .compatible = "ibm,ebc", },
25 { .compatible = "simple-bus", },
26 {},
27};
28
29static int __init ppc460ex_device_probe(void)
30{
31 of_platform_bus_probe(NULL, ppc460ex_of_bus, NULL);
32
33 return 0;
34}
35machine_device_initcall(canyonlands, ppc460ex_device_probe);
36
37/* Using this code only for the Canyonlands board. */
38
39static int __init ppc460ex_probe(void)
40{
56571384 41 if (of_machine_is_compatible("amcc,canyonlands")) {
0e47ff1c 42 pci_set_flags(PCI_REASSIGN_ALL_RSRC);
8960f7ff 43 return 1;
56571384 44 }
8960f7ff
RS
45 return 0;
46}
47
48/* USB PHY fixup code on Canyonlands kit. */
49
50static int __init ppc460ex_canyonlands_fixup(void)
51{
52 u8 __iomem *bcsr ;
53 void __iomem *vaddr;
54 struct device_node *np;
55 int ret = 0;
56
57 np = of_find_compatible_node(NULL, NULL, "amcc,ppc460ex-bcsr");
58 if (!np) {
59 printk(KERN_ERR "failed did not find amcc, ppc460ex bcsr node\n");
60 return -ENODEV;
61 }
62
63 bcsr = of_iomap(np, 0);
64 of_node_put(np);
65
66 if (!bcsr) {
67 printk(KERN_CRIT "Could not remap bcsr\n");
68 ret = -ENODEV;
69 goto err_bcsr;
70 }
71
72 np = of_find_compatible_node(NULL, NULL, "ibm,ppc4xx-gpio");
73 if (!np) {
74 printk(KERN_ERR "failed did not find ibm,ppc4xx-gpio node\n");
75 return -ENODEV;
76 }
77
78 vaddr = of_iomap(np, 0);
79 of_node_put(np);
80
81 if (!vaddr) {
82 printk(KERN_CRIT "Could not get gpio node address\n");
83 ret = -ENODEV;
84 goto err_gpio;
85 }
86 /* Disable USB, through the BCSR7 bits */
87 setbits8(&bcsr[7], BCSR_USB_EN);
88
89 /* Wait for a while after reset */
90 msleep(100);
91
92 /* Enable USB here */
93 clrbits8(&bcsr[7], BCSR_USB_EN);
94
95 /*
96 * Configure multiplexed gpio16 and gpio19 as alternate1 output
97 * source after USB reset. In this configuration gpio16 will be
98 * USB2HStop and gpio19 will be USB2DStop. For more details refer to
99 * table 34-7 of PPC460EX user manual.
100 */
101 setbits32((vaddr + GPIO0_OSRH), 0x42000000);
102 setbits32((vaddr + GPIO0_TSRH), 0x42000000);
103err_gpio:
104 iounmap(vaddr);
105err_bcsr:
106 iounmap(bcsr);
107 return ret;
108}
109machine_device_initcall(canyonlands, ppc460ex_canyonlands_fixup);
110define_machine(canyonlands) {
111 .name = "Canyonlands",
112 .probe = ppc460ex_probe,
113 .progress = udbg_progress,
114 .init_IRQ = uic_init_tree,
115 .get_irq = uic_get_irq,
116 .restart = ppc4xx_reset_system,
117 .calibrate_decr = generic_calibrate_decr,
118};