Path: blob/master/arch/powerpc/platforms/cell/celleb_scc_uhc.c
10818 views
/*1* SCC (Super Companion Chip) UHC setup2*3* (C) Copyright 2006-2007 TOSHIBA CORPORATION4*5* This program is free software; you can redistribute it and/or modify6* it under the terms of the GNU General Public License as published by7* the Free Software Foundation; either version 2 of the License, or8* (at your option) any later version.9*10* This program is distributed in the hope that it will be useful,11* but WITHOUT ANY WARRANTY; without even the implied warranty of12* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the13* GNU General Public License for more details.14*15* You should have received a copy of the GNU General Public License along16* with this program; if not, write to the Free Software Foundation, Inc.,17* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.18*/1920#include <linux/kernel.h>21#include <linux/pci.h>2223#include <asm/delay.h>24#include <asm/io.h>25#include <asm/machdep.h>2627#include "celleb_scc.h"2829#define UHC_RESET_WAIT_MAX 100003031static inline int uhc_clkctrl_ready(u32 val)32{33const u32 mask = SCC_UHC_USBCEN | SCC_UHC_USBCEN;34return((val & mask) == mask);35}3637/*38* UHC(usb host controller) enable function.39* affect to both of OHCI and EHCI core module.40*/41static void enable_scc_uhc(struct pci_dev *dev)42{43void __iomem *uhc_base;44u32 __iomem *uhc_clkctrl;45u32 __iomem *uhc_ecmode;46u32 val = 0;47int i;4849if (!machine_is(celleb_beat) &&50!machine_is(celleb_native))51return;5253uhc_base = ioremap(pci_resource_start(dev, 0),54pci_resource_len(dev, 0));55if (!uhc_base) {56printk(KERN_ERR "failed to map UHC register base.\n");57return;58}59uhc_clkctrl = uhc_base + SCC_UHC_CKRCTRL;60uhc_ecmode = uhc_base + SCC_UHC_ECMODE;6162/* setup for normal mode */63val |= SCC_UHC_F48MCKLEN;64out_be32(uhc_clkctrl, val);65val |= SCC_UHC_PHY_SUSPEND_SEL;66out_be32(uhc_clkctrl, val);67udelay(10);68val |= SCC_UHC_PHYEN;69out_be32(uhc_clkctrl, val);70udelay(50);7172/* disable reset */73val |= SCC_UHC_HCLKEN;74out_be32(uhc_clkctrl, val);75val |= (SCC_UHC_USBCEN | SCC_UHC_USBEN);76out_be32(uhc_clkctrl, val);77i = 0;78while (!uhc_clkctrl_ready(in_be32(uhc_clkctrl))) {79udelay(10);80if (i++ > UHC_RESET_WAIT_MAX) {81printk(KERN_ERR "Failed to disable UHC reset %x\n",82in_be32(uhc_clkctrl));83break;84}85}8687/* Endian Conversion Mode for Master ALL area */88out_be32(uhc_ecmode, SCC_UHC_ECMODE_BY_BYTE);8990iounmap(uhc_base);91}9293DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_TOSHIBA_2,94PCI_DEVICE_ID_TOSHIBA_SCC_USB, enable_scc_uhc);959697