| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389 | /* * usb-host.c - OMAP USB Host * * This file will contain the board specific details for the * Synopsys EHCI/OHCI host controller on OMAP3430 and onwards * * Copyright (C) 2007-2011 Texas Instruments * Author: Vikram Pandita <vikram.pandita@ti.com> * Author: Keshava Munegowda <keshava_mgowda@ti.com> * * Generalization by: * Felipe Balbi <balbi@ti.com> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. */#include <linux/types.h>#include <linux/errno.h>#include <linux/delay.h>#include <linux/platform_device.h>#include <linux/slab.h>#include <linux/dma-mapping.h>#include <asm/io.h>#include "soc.h"#include "omap_device.h"#include "mux.h"#include "usb.h"#ifdef CONFIG_MFD_OMAP_USB_HOST#define OMAP_USBHS_DEVICE	"usbhs_omap"#define OMAP_USBTLL_DEVICE	"usbhs_tll"#define	USBHS_UHH_HWMODNAME	"usb_host_hs"#define USBHS_TLL_HWMODNAME	"usb_tll_hs"static struct usbhs_omap_platform_data		usbhs_data;static struct usbtll_omap_platform_data		usbtll_data;static struct ehci_hcd_omap_platform_data	ehci_data;static struct ohci_hcd_omap_platform_data	ohci_data;static struct omap_device_pm_latency omap_uhhtll_latency[] = {	  {		.deactivate_func = omap_device_idle_hwmods,		.activate_func	 = omap_device_enable_hwmods,		.flags = OMAP_DEVICE_LATENCY_AUTO_ADJUST,	  },};/* MUX settings for EHCI pins *//* * setup_ehci_io_mux - initialize IO pad mux for USBHOST */static void __init setup_ehci_io_mux(const enum usbhs_omap_port_mode *port_mode){	switch (port_mode[0]) {	case OMAP_EHCI_PORT_MODE_PHY:		omap_mux_init_signal("hsusb1_stp", OMAP_PIN_OUTPUT);		omap_mux_init_signal("hsusb1_clk", OMAP_PIN_OUTPUT);		omap_mux_init_signal("hsusb1_dir", OMAP_PIN_INPUT_PULLDOWN);		omap_mux_init_signal("hsusb1_nxt", OMAP_PIN_INPUT_PULLDOWN);		omap_mux_init_signal("hsusb1_data0", OMAP_PIN_INPUT_PULLDOWN);		omap_mux_init_signal("hsusb1_data1", OMAP_PIN_INPUT_PULLDOWN);		omap_mux_init_signal("hsusb1_data2", OMAP_PIN_INPUT_PULLDOWN);		omap_mux_init_signal("hsusb1_data3", OMAP_PIN_INPUT_PULLDOWN);		omap_mux_init_signal("hsusb1_data4", OMAP_PIN_INPUT_PULLDOWN);		omap_mux_init_signal("hsusb1_data5", OMAP_PIN_INPUT_PULLDOWN);		omap_mux_init_signal("hsusb1_data6", OMAP_PIN_INPUT_PULLDOWN);		omap_mux_init_signal("hsusb1_data7", OMAP_PIN_INPUT_PULLDOWN);		break;	case OMAP_EHCI_PORT_MODE_TLL:		omap_mux_init_signal("hsusb1_tll_stp",			OMAP_PIN_INPUT_PULLUP);		omap_mux_init_signal("hsusb1_tll_clk",			OMAP_PIN_INPUT_PULLDOWN);		omap_mux_init_signal("hsusb1_tll_dir",			OMAP_PIN_INPUT_PULLDOWN);		omap_mux_init_signal("hsusb1_tll_nxt",			OMAP_PIN_INPUT_PULLDOWN);		omap_mux_init_signal("hsusb1_tll_data0",			OMAP_PIN_INPUT_PULLDOWN);		omap_mux_init_signal("hsusb1_tll_data1",			OMAP_PIN_INPUT_PULLDOWN);		omap_mux_init_signal("hsusb1_tll_data2",			OMAP_PIN_INPUT_PULLDOWN);		omap_mux_init_signal("hsusb1_tll_data3",			OMAP_PIN_INPUT_PULLDOWN);		omap_mux_init_signal("hsusb1_tll_data4",			OMAP_PIN_INPUT_PULLDOWN);		omap_mux_init_signal("hsusb1_tll_data5",			OMAP_PIN_INPUT_PULLDOWN);		omap_mux_init_signal("hsusb1_tll_data6",			OMAP_PIN_INPUT_PULLDOWN);		omap_mux_init_signal("hsusb1_tll_data7",			OMAP_PIN_INPUT_PULLDOWN);		break;	case OMAP_USBHS_PORT_MODE_UNUSED:		/* FALLTHROUGH */	default:		break;	}	switch (port_mode[1]) {	case OMAP_EHCI_PORT_MODE_PHY:		omap_mux_init_signal("hsusb2_stp", OMAP_PIN_OUTPUT);		omap_mux_init_signal("hsusb2_clk", OMAP_PIN_OUTPUT);		omap_mux_init_signal("hsusb2_dir", OMAP_PIN_INPUT_PULLDOWN);		omap_mux_init_signal("hsusb2_nxt", OMAP_PIN_INPUT_PULLDOWN);		omap_mux_init_signal("hsusb2_data0",			OMAP_PIN_INPUT_PULLDOWN);		omap_mux_init_signal("hsusb2_data1",			OMAP_PIN_INPUT_PULLDOWN);		omap_mux_init_signal("hsusb2_data2",			OMAP_PIN_INPUT_PULLDOWN);		omap_mux_init_signal("hsusb2_data3",			OMAP_PIN_INPUT_PULLDOWN);		omap_mux_init_signal("hsusb2_data4",			OMAP_PIN_INPUT_PULLDOWN);		omap_mux_init_signal("hsusb2_data5",			OMAP_PIN_INPUT_PULLDOWN);		omap_mux_init_signal("hsusb2_data6",			OMAP_PIN_INPUT_PULLDOWN);		omap_mux_init_signal("hsusb2_data7",			OMAP_PIN_INPUT_PULLDOWN);		break;	case OMAP_EHCI_PORT_MODE_TLL:		omap_mux_init_signal("hsusb2_tll_stp",			OMAP_PIN_INPUT_PULLUP);		omap_mux_init_signal("hsusb2_tll_clk",			OMAP_PIN_INPUT_PULLDOWN);		omap_mux_init_signal("hsusb2_tll_dir",			OMAP_PIN_INPUT_PULLDOWN);		omap_mux_init_signal("hsusb2_tll_nxt",			OMAP_PIN_INPUT_PULLDOWN);		omap_mux_init_signal("hsusb2_tll_data0",			OMAP_PIN_INPUT_PULLDOWN);		omap_mux_init_signal("hsusb2_tll_data1",			OMAP_PIN_INPUT_PULLDOWN);		omap_mux_init_signal("hsusb2_tll_data2",			OMAP_PIN_INPUT_PULLDOWN);		omap_mux_init_signal("hsusb2_tll_data3",			OMAP_PIN_INPUT_PULLDOWN);		omap_mux_init_signal("hsusb2_tll_data4",			OMAP_PIN_INPUT_PULLDOWN);		omap_mux_init_signal("hsusb2_tll_data5",			OMAP_PIN_INPUT_PULLDOWN);		omap_mux_init_signal("hsusb2_tll_data6",			OMAP_PIN_INPUT_PULLDOWN);		omap_mux_init_signal("hsusb2_tll_data7",			OMAP_PIN_INPUT_PULLDOWN);		break;	case OMAP_USBHS_PORT_MODE_UNUSED:		/* FALLTHROUGH */	default:		break;	}	switch (port_mode[2]) {	case OMAP_EHCI_PORT_MODE_PHY:		printk(KERN_WARNING "Port3 can't be used in PHY mode\n");		break;	case OMAP_EHCI_PORT_MODE_TLL:		omap_mux_init_signal("hsusb3_tll_stp",			OMAP_PIN_INPUT_PULLUP);		omap_mux_init_signal("hsusb3_tll_clk",			OMAP_PIN_INPUT_PULLDOWN);		omap_mux_init_signal("hsusb3_tll_dir",			OMAP_PIN_INPUT_PULLDOWN);		omap_mux_init_signal("hsusb3_tll_nxt",			OMAP_PIN_INPUT_PULLDOWN);		omap_mux_init_signal("hsusb3_tll_data0",			OMAP_PIN_INPUT_PULLDOWN);		omap_mux_init_signal("hsusb3_tll_data1",			OMAP_PIN_INPUT_PULLDOWN);		omap_mux_init_signal("hsusb3_tll_data2",			OMAP_PIN_INPUT_PULLDOWN);		omap_mux_init_signal("hsusb3_tll_data3",			OMAP_PIN_INPUT_PULLDOWN);		omap_mux_init_signal("hsusb3_tll_data4",			OMAP_PIN_INPUT_PULLDOWN);		omap_mux_init_signal("hsusb3_tll_data5",			OMAP_PIN_INPUT_PULLDOWN);		omap_mux_init_signal("hsusb3_tll_data6",			OMAP_PIN_INPUT_PULLDOWN);		omap_mux_init_signal("hsusb3_tll_data7",			OMAP_PIN_INPUT_PULLDOWN);		break;	case OMAP_USBHS_PORT_MODE_UNUSED:		/* FALLTHROUGH */	default:		break;	}	return;}staticvoid __init setup_4430ehci_io_mux(const enum usbhs_omap_port_mode *port_mode){	switch (port_mode[0]) {	case OMAP_EHCI_PORT_MODE_PHY:		omap_mux_init_signal("usbb1_ulpiphy_stp",			OMAP_PIN_OUTPUT);		omap_mux_init_signal("usbb1_ulpiphy_clk",			OMAP_PIN_INPUT_PULLDOWN);		omap_mux_init_signal("usbb1_ulpiphy_dir",			OMAP_PIN_INPUT_PULLDOWN);		omap_mux_init_signal("usbb1_ulpiphy_nxt",			OMAP_PIN_INPUT_PULLDOWN);		omap_mux_init_signal("usbb1_ulpiphy_dat0",			OMAP_PIN_INPUT_PULLDOWN);		omap_mux_init_signal("usbb1_ulpiphy_dat1",			OMAP_PIN_INPUT_PULLDOWN);		omap_mux_init_signal("usbb1_ulpiphy_dat2",			OMAP_PIN_INPUT_PULLDOWN);		omap_mux_init_signal("usbb1_ulpiphy_dat3",			OMAP_PIN_INPUT_PULLDOWN);		omap_mux_init_signal("usbb1_ulpiphy_dat4",			OMAP_PIN_INPUT_PULLDOWN);		omap_mux_init_signal("usbb1_ulpiphy_dat5",			OMAP_PIN_INPUT_PULLDOWN);		omap_mux_init_signal("usbb1_ulpiphy_dat6",			OMAP_PIN_INPUT_PULLDOWN);		omap_mux_init_signal("usbb1_ulpiphy_dat7",			OMAP_PIN_INPUT_PULLDOWN);			break;	case OMAP_EHCI_PORT_MODE_TLL:		omap_mux_init_signal("usbb1_ulpitll_stp",			OMAP_PIN_INPUT_PULLUP);		omap_mux_init_signal("usbb1_ulpitll_clk",			OMAP_PIN_INPUT_PULLDOWN);		omap_mux_init_signal("usbb1_ulpitll_dir",			OMAP_PIN_INPUT_PULLDOWN);		omap_mux_init_signal("usbb1_ulpitll_nxt",			OMAP_PIN_INPUT_PULLDOWN);		omap_mux_init_signal("usbb1_ulpitll_dat0",			OMAP_PIN_INPUT_PULLDOWN);		omap_mux_init_signal("usbb1_ulpitll_dat1",			OMAP_PIN_INPUT_PULLDOWN);		omap_mux_init_signal("usbb1_ulpitll_dat2",			OMAP_PIN_INPUT_PULLDOWN);		omap_mux_init_signal("usbb1_ulpitll_dat3",			OMAP_PIN_INPUT_PULLDOWN);		omap_mux_init_signal("usbb1_ulpitll_dat4",			OMAP_PIN_INPUT_PULLDOWN);		omap_mux_init_signal("usbb1_ulpitll_dat5",			OMAP_PIN_INPUT_PULLDOWN);		omap_mux_init_signal("usbb1_ulpitll_dat6",			OMAP_PIN_INPUT_PULLDOWN);		omap_mux_init_signal("usbb1_ulpitll_dat7",			OMAP_PIN_INPUT_PULLDOWN);			break;	case OMAP_USBHS_PORT_MODE_UNUSED:	default:			break;	}	switch (port_mode[1]) {	case OMAP_EHCI_PORT_MODE_PHY:		omap_mux_init_signal("usbb2_ulpiphy_stp",			OMAP_PIN_OUTPUT);		omap_mux_init_signal("usbb2_ulpiphy_clk",			OMAP_PIN_INPUT_PULLDOWN);		omap_mux_init_signal("usbb2_ulpiphy_dir",			OMAP_PIN_INPUT_PULLDOWN);		omap_mux_init_signal("usbb2_ulpiphy_nxt",			OMAP_PIN_INPUT_PULLDOWN);		omap_mux_init_signal("usbb2_ulpiphy_dat0",			OMAP_PIN_INPUT_PULLDOWN);		omap_mux_init_signal("usbb2_ulpiphy_dat1",			OMAP_PIN_INPUT_PULLDOWN);		omap_mux_init_signal("usbb2_ulpiphy_dat2",			OMAP_PIN_INPUT_PULLDOWN);		omap_mux_init_signal("usbb2_ulpiphy_dat3",			OMAP_PIN_INPUT_PULLDOWN);		omap_mux_init_signal("usbb2_ulpiphy_dat4",			OMAP_PIN_INPUT_PULLDOWN);		omap_mux_init_signal("usbb2_ulpiphy_dat5",			OMAP_PIN_INPUT_PULLDOWN);		omap_mux_init_signal("usbb2_ulpiphy_dat6",			OMAP_PIN_INPUT_PULLDOWN);		omap_mux_init_signal("usbb2_ulpiphy_dat7",			OMAP_PIN_INPUT_PULLDOWN);			break;	case OMAP_EHCI_PORT_MODE_TLL:		omap_mux_init_signal("usbb2_ulpitll_stp",			OMAP_PIN_INPUT_PULLUP);		omap_mux_init_signal("usbb2_ulpitll_clk",			OMAP_PIN_INPUT_PULLDOWN);		omap_mux_init_signal("usbb2_ulpitll_dir",			OMAP_PIN_INPUT_PULLDOWN);		omap_mux_init_signal("usbb2_ulpitll_nxt",			OMAP_PIN_INPUT_PULLDOWN);		omap_mux_init_signal("usbb2_ulpitll_dat0",			OMAP_PIN_INPUT_PULLDOWN);		omap_mux_init_signal("usbb2_ulpitll_dat1",			OMAP_PIN_INPUT_PULLDOWN);		omap_mux_init_signal("usbb2_ulpitll_dat2",			OMAP_PIN_INPUT_PULLDOWN);		omap_mux_init_signal("usbb2_ulpitll_dat3",			OMAP_PIN_INPUT_PULLDOWN);		omap_mux_init_signal("usbb2_ulpitll_dat4",			OMAP_PIN_INPUT_PULLDOWN);		omap_mux_init_signal("usbb2_ulpitll_dat5",			OMAP_PIN_INPUT_PULLDOWN);		omap_mux_init_signal("usbb2_ulpitll_dat6",			OMAP_PIN_INPUT_PULLDOWN);		omap_mux_init_signal("usbb2_ulpitll_dat7",			OMAP_PIN_INPUT_PULLDOWN);			break;	case OMAP_USBHS_PORT_MODE_UNUSED:	default:			break;	}}static void __init setup_ohci_io_mux(const enum usbhs_omap_port_mode *port_mode){	switch (port_mode[0]) {	case OMAP_OHCI_PORT_MODE_PHY_6PIN_DATSE0:	case OMAP_OHCI_PORT_MODE_PHY_6PIN_DPDM:	case OMAP_OHCI_PORT_MODE_TLL_6PIN_DATSE0:	case OMAP_OHCI_PORT_MODE_TLL_6PIN_DPDM:		omap_mux_init_signal("mm1_rxdp",			OMAP_PIN_INPUT_PULLDOWN);		omap_mux_init_signal("mm1_rxdm",			OMAP_PIN_INPUT_PULLDOWN);		/* FALLTHROUGH */	case OMAP_OHCI_PORT_MODE_PHY_4PIN_DPDM:	case OMAP_OHCI_PORT_MODE_TLL_4PIN_DPDM:		omap_mux_init_signal("mm1_rxrcv",			OMAP_PIN_INPUT_PULLDOWN);		/* FALLTHROUGH */	case OMAP_OHCI_PORT_MODE_PHY_3PIN_DATSE0:	case OMAP_OHCI_PORT_MODE_TLL_3PIN_DATSE0:		omap_mux_init_signal("mm1_txen_n", OMAP_PIN_OUTPUT);		/* FALLTHROUGH */	case OMAP_OHCI_PORT_MODE_TLL_2PIN_DATSE0:	case OMAP_OHCI_PORT_MODE_TLL_2PIN_DPDM:		omap_mux_init_signal("mm1_txse0",			OMAP_PIN_INPUT_PULLDOWN);		omap_mux_init_signal("mm1_txdat",			OMAP_PIN_INPUT_PULLDOWN);		break;	case OMAP_USBHS_PORT_MODE_UNUSED:		/* FALLTHROUGH */	default:		break;	}	switch (port_mode[1]) {	case OMAP_OHCI_PORT_MODE_PHY_6PIN_DATSE0:	case OMAP_OHCI_PORT_MODE_PHY_6PIN_DPDM:	case OMAP_OHCI_PORT_MODE_TLL_6PIN_DATSE0:	case OMAP_OHCI_PORT_MODE_TLL_6PIN_DPDM:		omap_mux_init_signal("mm2_rxdp",			OMAP_PIN_INPUT_PULLDOWN);		omap_mux_init_signal("mm2_rxdm",			OMAP_PIN_INPUT_PULLDOWN);		/* FALLTHROUGH */	case OMAP_OHCI_PORT_MODE_PHY_4PIN_DPDM:	case OMAP_OHCI_PORT_MODE_TLL_4PIN_DPDM:		omap_mux_init_signal("mm2_rxrcv",			OMAP_PIN_INPUT_PULLDOWN);		/* FALLTHROUGH */	case OMAP_OHCI_PORT_MODE_PHY_3PIN_DATSE0:	case OMAP_OHCI_PORT_MODE_TLL_3PIN_DATSE0:		omap_mux_init_signal("mm2_txen_n", OMAP_PIN_OUTPUT);		/* FALLTHROUGH */	case OMAP_OHCI_PORT_MODE_TLL_2PIN_DATSE0:	case OMAP_OHCI_PORT_MODE_TLL_2PIN_DPDM:		omap_mux_init_signal("mm2_txse0",			OMAP_PIN_INPUT_PULLDOWN);		omap_mux_init_signal("mm2_txdat",			OMAP_PIN_INPUT_PULLDOWN);		break;	case OMAP_USBHS_PORT_MODE_UNUSED:		/* FALLTHROUGH */	default:		break;	}	switch (port_mode[2]) {	case OMAP_OHCI_PORT_MODE_PHY_6PIN_DATSE0:	case OMAP_OHCI_PORT_MODE_PHY_6PIN_DPDM:	case OMAP_OHCI_PORT_MODE_TLL_6PIN_DATSE0:	case OMAP_OHCI_PORT_MODE_TLL_6PIN_DPDM:		omap_mux_init_signal("mm3_rxdp",			OMAP_PIN_INPUT_PULLDOWN);
 |