mpc837x_mds.c (2410B)
1// SPDX-License-Identifier: GPL-2.0-or-later 2/* 3 * arch/powerpc/platforms/83xx/mpc837x_mds.c 4 * 5 * Copyright (C) 2007 Freescale Semiconductor, Inc. All rights reserved. 6 * 7 * MPC837x MDS board specific routines 8 */ 9 10#include <linux/pci.h> 11#include <linux/of.h> 12#include <linux/of_address.h> 13#include <linux/of_platform.h> 14 15#include <asm/time.h> 16#include <asm/ipic.h> 17#include <asm/udbg.h> 18#include <sysdev/fsl_pci.h> 19 20#include "mpc83xx.h" 21 22#define BCSR12_USB_SER_MASK 0x8a 23#define BCSR12_USB_SER_PIN 0x80 24#define BCSR12_USB_SER_DEVICE 0x02 25 26static int __init mpc837xmds_usb_cfg(void) 27{ 28 struct device_node *np; 29 const void *phy_type, *mode; 30 void __iomem *bcsr_regs = NULL; 31 u8 bcsr12; 32 int ret; 33 34 ret = mpc837x_usb_cfg(); 35 if (ret) 36 return ret; 37 /* Map BCSR area */ 38 np = of_find_compatible_node(NULL, NULL, "fsl,mpc837xmds-bcsr"); 39 if (np) { 40 bcsr_regs = of_iomap(np, 0); 41 of_node_put(np); 42 } 43 if (!bcsr_regs) 44 return -1; 45 46 np = of_find_node_by_name(NULL, "usb"); 47 if (!np) { 48 ret = -ENODEV; 49 goto out; 50 } 51 phy_type = of_get_property(np, "phy_type", NULL); 52 if (phy_type && !strcmp(phy_type, "ulpi")) { 53 clrbits8(bcsr_regs + 12, BCSR12_USB_SER_PIN); 54 } else if (phy_type && !strcmp(phy_type, "serial")) { 55 mode = of_get_property(np, "dr_mode", NULL); 56 bcsr12 = in_8(bcsr_regs + 12) & ~BCSR12_USB_SER_MASK; 57 bcsr12 |= BCSR12_USB_SER_PIN; 58 if (mode && !strcmp(mode, "peripheral")) 59 bcsr12 |= BCSR12_USB_SER_DEVICE; 60 out_8(bcsr_regs + 12, bcsr12); 61 } else { 62 printk(KERN_ERR "USB DR: unsupported PHY\n"); 63 } 64 65 of_node_put(np); 66out: 67 iounmap(bcsr_regs); 68 return ret; 69} 70 71/* ************************************************************************ 72 * 73 * Setup the architecture 74 * 75 */ 76static void __init mpc837x_mds_setup_arch(void) 77{ 78 mpc83xx_setup_arch(); 79 mpc837xmds_usb_cfg(); 80} 81 82machine_device_initcall(mpc837x_mds, mpc83xx_declare_of_platform_devices); 83 84/* 85 * Called very early, MMU is off, device-tree isn't unflattened 86 */ 87static int __init mpc837x_mds_probe(void) 88{ 89 return of_machine_is_compatible("fsl,mpc837xmds"); 90} 91 92define_machine(mpc837x_mds) { 93 .name = "MPC837x MDS", 94 .probe = mpc837x_mds_probe, 95 .setup_arch = mpc837x_mds_setup_arch, 96 .discover_phbs = mpc83xx_setup_pci, 97 .init_IRQ = mpc83xx_ipic_init_IRQ, 98 .get_irq = ipic_get_irq, 99 .restart = mpc83xx_restart, 100 .time_init = mpc83xx_time_init, 101 .calibrate_decr = generic_calibrate_decr, 102 .progress = udbg_progress, 103};