/** * core.c - DesignWare USB3 DRD Controller Core file * * Copyright (C) 2010-2011 Texas Instruments Incorporated - http://www.ti.com * * Authors: Felipe Balbi <balbi@ti.com>, * Sebastian Andrzej Siewior <bigeasy@linutronix.de> * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 of * the License as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. */#include<linux/version.h>#include<linux/module.h>#include<linux/kernel.h>#include<linux/slab.h>#include<linux/spinlock.h>#include<linux/platform_device.h>#include<linux/pm_runtime.h>#include<linux/interrupt.h>#include<linux/ioport.h>#include<linux/io.h>#include<linux/list.h>#include<linux/delay.h>#include<linux/dma-mapping.h>#include<linux/of.h>#include<linux/acpi.h>#include<linux/pinctrl/consumer.h>#include<linux/usb/ch9.h>#include<linux/usb/gadget.h>#include<linux/usb/of.h>#include<linux/usb/otg.h>#include"core.h"#include"gadget.h"#include"io.h"#include"debug.h"#define DWC3_DEFAULT_AUTOSUSPEND_DELAY 5000 /* ms *//** * dwc3_get_dr_mode - Validates and sets dr_mode * @dwc: pointer to our context structure */staticintdwc3_get_dr_mode(structdwc3*dwc){enumusb_dr_modemode;structdevice*dev=dwc->dev;unsignedinthw_mode;if(dwc->dr_mode==USB_DR_MODE_UNKNOWN)dwc->dr_mode=USB_DR_MODE_OTG;mode=dwc->dr_mode;hw_mode=DWC3_GHWPARAMS0_MODE(dwc->hwparams.hwparams0);switch(hw_mode){caseDWC3_GHWPARAMS0_MODE_GADGET:if(IS_ENABLED(CONFIG_USB_DWC3_HOST)){dev_err(dev,"Controller does not support host mode.\n");return-EINVAL;}mode=USB_DR_MODE_PERIPHERAL;break;caseDWC3_GHWPARAM