Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: GPL-2.0-or-later
0002 /*
0003  * This contain platform specific code for APM PPC460EX based Canyonlands
0004  * board.
0005  *
0006  * Copyright (c) 2010, Applied Micro Circuits Corporation
0007  * Author: Rupjyoti Sarmah <rsarmah@apm.com>
0008  */
0009 #include <linux/kernel.h>
0010 #include <linux/init.h>
0011 #include <asm/pci-bridge.h>
0012 #include <asm/ppc4xx.h>
0013 #include <asm/udbg.h>
0014 #include <asm/uic.h>
0015 #include <linux/of_address.h>
0016 #include <linux/of_platform.h>
0017 #include <linux/delay.h>
0018 #include "44x.h"
0019 
0020 #define BCSR_USB_EN 0x11
0021 
0022 static const struct of_device_id ppc460ex_of_bus[] __initconst = {
0023     { .compatible = "ibm,plb4", },
0024     { .compatible = "ibm,opb", },
0025     { .compatible = "ibm,ebc", },
0026     { .compatible = "simple-bus", },
0027     {},
0028 };
0029 
0030 static int __init ppc460ex_device_probe(void)
0031 {
0032     of_platform_bus_probe(NULL, ppc460ex_of_bus, NULL);
0033 
0034     return 0;
0035 }
0036 machine_device_initcall(canyonlands, ppc460ex_device_probe);
0037 
0038 /* Using this code only for the Canyonlands board.  */
0039 
0040 static int __init ppc460ex_probe(void)
0041 {
0042     if (of_machine_is_compatible("amcc,canyonlands")) {
0043         pci_set_flags(PCI_REASSIGN_ALL_RSRC);
0044         return 1;
0045     }
0046     return 0;
0047 }
0048 
0049 /* USB PHY fixup code on Canyonlands kit. */
0050 
0051 static int __init ppc460ex_canyonlands_fixup(void)
0052 {
0053     u8 __iomem *bcsr ;
0054     void __iomem *vaddr;
0055     struct device_node *np;
0056     int ret = 0;
0057 
0058     np = of_find_compatible_node(NULL, NULL, "amcc,ppc460ex-bcsr");
0059     if (!np) {
0060         printk(KERN_ERR "failed did not find amcc, ppc460ex bcsr node\n");
0061         return -ENODEV;
0062     }
0063 
0064     bcsr = of_iomap(np, 0);
0065     of_node_put(np);
0066 
0067     if (!bcsr) {
0068         printk(KERN_CRIT "Could not remap bcsr\n");
0069         ret = -ENODEV;
0070         goto err_bcsr;
0071     }
0072 
0073     np = of_find_compatible_node(NULL, NULL, "ibm,ppc4xx-gpio");
0074     if (!np) {
0075         printk(KERN_ERR "failed did not find ibm,ppc4xx-gpio node\n");
0076         return -ENODEV;
0077     }
0078 
0079     vaddr = of_iomap(np, 0);
0080     of_node_put(np);
0081 
0082     if (!vaddr) {
0083         printk(KERN_CRIT "Could not get gpio node address\n");
0084         ret = -ENODEV;
0085         goto err_gpio;
0086     }
0087     /* Disable USB, through the BCSR7 bits */
0088     setbits8(&bcsr[7], BCSR_USB_EN);
0089 
0090     /* Wait for a while after reset */
0091     msleep(100);
0092 
0093     /* Enable USB here */
0094     clrbits8(&bcsr[7], BCSR_USB_EN);
0095 
0096     /*
0097      * Configure multiplexed gpio16 and gpio19 as alternate1 output
0098      * source after USB reset. In this configuration gpio16 will be
0099      * USB2HStop and gpio19 will be USB2DStop. For more details refer to
0100      * table 34-7 of PPC460EX user manual.
0101      */
0102     setbits32((vaddr + GPIO0_OSRH), 0x42000000);
0103     setbits32((vaddr + GPIO0_TSRH), 0x42000000);
0104 err_gpio:
0105     iounmap(vaddr);
0106 err_bcsr:
0107     iounmap(bcsr);
0108     return ret;
0109 }
0110 machine_device_initcall(canyonlands, ppc460ex_canyonlands_fixup);
0111 define_machine(canyonlands) {
0112     .name = "Canyonlands",
0113     .probe = ppc460ex_probe,
0114     .progress = udbg_progress,
0115     .init_IRQ = uic_init_tree,
0116     .get_irq = uic_get_irq,
0117     .restart = ppc4xx_reset_system,
0118     .calibrate_decr = generic_calibrate_decr,
0119 };