canyonlands.c (96916090f488986a4ebb8e9ffa6a3b50881d5ccd) canyonlands.c (8960f7ff508064de1896d8539911411179b8433c)
1/*
1/*
2 * Canyonlands board specific routines
2 * This contain platform specific code for APM PPC460EX based Canyonlands
3 * board.
3 *
4 *
4 * Copyright 2008 DENX Software Engineering, Stefan Roese <sr@denx.de>
5 * Copyright (c) 2010, Applied Micro Circuits Corporation
6 * Author: Rupjyoti Sarmah <rsarmah@apm.com>
5 *
7 *
6 * Based on the Katmai code by
7 * Benjamin Herrenschmidt <benh@kernel.crashing.org>
8 * Copyright 2007 IBM Corp.
9 * Josh Boyer <jwboyer@linux.vnet.ibm.com>
10 * Copyright 2007 IBM Corporation
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.
11 *
12 *
12 * This program is free software; you can redistribute it and/or modify it
13 * under the terms of the GNU General Public License as published by the
14 * Free Software Foundation; either version 2 of the License, or (at your
15 * option) any later version.
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 *
16 */
23 */
24#include <linux/kernel.h>
17#include <linux/init.h>
25#include <linux/init.h>
18#include <linux/of_platform.h>
19
20#include <asm/machdep.h>
21#include <asm/prom.h>
22#include <asm/udbg.h>
23#include <asm/time.h>
24#include <asm/uic.h>
25#include <asm/pci-bridge.h>
26#include <asm/ppc4xx.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"
27
33
28static __initdata struct of_device_id canyonlands_of_bus[] = {
34#define BCSR_USB_EN 0x11
35
36static __initdata struct of_device_id ppc460ex_of_bus[] = {
29 { .compatible = "ibm,plb4", },
30 { .compatible = "ibm,opb", },
31 { .compatible = "ibm,ebc", },
37 { .compatible = "ibm,plb4", },
38 { .compatible = "ibm,opb", },
39 { .compatible = "ibm,ebc", },
40 { .compatible = "simple-bus", },
32 {},
33};
34
41 {},
42};
43
35static int __init canyonlands_device_probe(void)
44static int __init ppc460ex_device_probe(void)
36{
45{
37 of_platform_bus_probe(NULL, canyonlands_of_bus, NULL);
46 of_platform_bus_probe(NULL, ppc460ex_of_bus, NULL);
38
39 return 0;
40}
47
48 return 0;
49}
41machine_device_initcall(canyonlands, canyonlands_device_probe);
50machine_device_initcall(canyonlands, ppc460ex_device_probe);
42
51
43static int __init canyonlands_probe(void)
52/* Using this code only for the Canyonlands board. */
53
54static int __init ppc460ex_probe(void)
44{
45 unsigned long root = of_get_flat_dt_root();
55{
56 unsigned long root = of_get_flat_dt_root();
57 if (of_flat_dt_is_compatible(root, "amcc,canyonlands")) {
58 ppc_pci_set_flags(PPC_PCI_REASSIGN_ALL_RSRC);
59 return 1;
60 }
61 return 0;
62}
46
63
47 if (!of_flat_dt_is_compatible(root, "amcc,canyonlands"))
48 return 0;
64/* USB PHY fixup code on Canyonlands kit. */
49
65
50 ppc_pci_flags = PPC_PCI_REASSIGN_ALL_RSRC;
66static int __init ppc460ex_canyonlands_fixup(void)
67{
68 u8 __iomem *bcsr ;
69 void __iomem *vaddr;
70 struct device_node *np;
71 int ret = 0;
51
72
52 return 1;
53}
73 np = of_find_compatible_node(NULL, NULL, "amcc,ppc460ex-bcsr");
74 if (!np) {
75 printk(KERN_ERR "failed did not find amcc, ppc460ex bcsr node\n");
76 return -ENODEV;
77 }
54
78
79 bcsr = of_iomap(np, 0);
80 of_node_put(np);
81
82 if (!bcsr) {
83 printk(KERN_CRIT "Could not remap bcsr\n");
84 ret = -ENODEV;
85 goto err_bcsr;
86 }
87
88 np = of_find_compatible_node(NULL, NULL, "ibm,ppc4xx-gpio");
89 if (!np) {
90 printk(KERN_ERR "failed did not find ibm,ppc4xx-gpio node\n");
91 return -ENODEV;
92 }
93
94 vaddr = of_iomap(np, 0);
95 of_node_put(np);
96
97 if (!vaddr) {
98 printk(KERN_CRIT "Could not get gpio node address\n");
99 ret = -ENODEV;
100 goto err_gpio;
101 }
102 /* Disable USB, through the BCSR7 bits */
103 setbits8(&bcsr[7], BCSR_USB_EN);
104
105 /* Wait for a while after reset */
106 msleep(100);
107
108 /* Enable USB here */
109 clrbits8(&bcsr[7], BCSR_USB_EN);
110
111 /*
112 * Configure multiplexed gpio16 and gpio19 as alternate1 output
113 * source after USB reset. In this configuration gpio16 will be
114 * USB2HStop and gpio19 will be USB2DStop. For more details refer to
115 * table 34-7 of PPC460EX user manual.
116 */
117 setbits32((vaddr + GPIO0_OSRH), 0x42000000);
118 setbits32((vaddr + GPIO0_TSRH), 0x42000000);
119err_gpio:
120 iounmap(vaddr);
121err_bcsr:
122 iounmap(bcsr);
123 return ret;
124}
125machine_device_initcall(canyonlands, ppc460ex_canyonlands_fixup);
55define_machine(canyonlands) {
126define_machine(canyonlands) {
56 .name = "Canyonlands",
57 .probe = canyonlands_probe,
58 .progress = udbg_progress,
59 .init_IRQ = uic_init_tree,
60 .get_irq = uic_get_irq,
61 .restart = ppc4xx_reset_system,
62 .calibrate_decr = generic_calibrate_decr,
127 .name = "Canyonlands",
128 .probe = ppc460ex_probe,
129 .progress = udbg_progress,
130 .init_IRQ = uic_init_tree,
131 .get_irq = uic_get_irq,
132 .restart = ppc4xx_reset_system,
133 .calibrate_decr = generic_calibrate_decr,
63};
134};