Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

usb: dwc3: omap: distinguish between SW and HW modes

The OMAP wrapper allows us to either control internal
OTG signals via SW or HW. Different boards might wish
to use one or the other mode of operation. Let's have
have that information passed via platform_data for now.

After DT conversion is finished for OMAP, we can easily
convert this to a DT attribute.

Signed-off-by: Felipe Balbi <balbi@ti.com>

+69
+22
drivers/usb/dwc3/dwc3-omap.c
··· 42 42 #include <linux/interrupt.h> 43 43 #include <linux/spinlock.h> 44 44 #include <linux/platform_device.h> 45 + #include <linux/platform_data/dwc3-omap.h> 45 46 #include <linux/dma-mapping.h> 46 47 #include <linux/ioport.h> 47 48 #include <linux/io.h> ··· 194 193 195 194 static int __devinit dwc3_omap_probe(struct platform_device *pdev) 196 195 { 196 + struct dwc3_omap_data *pdata = pdev->dev.platform_data; 197 197 struct platform_device *dwc3; 198 198 struct dwc3_omap *omap; 199 199 struct resource *res; ··· 259 257 omap->irq = irq; 260 258 omap->base = base; 261 259 omap->dwc3 = dwc3; 260 + 261 + reg = dwc3_readl(omap->base, USBOTGSS_UTMI_OTG_STATUS); 262 + 263 + if (!pdata) { 264 + dev_dbg(&pdev->dev, "missing platform data\n"); 265 + } else { 266 + switch (pdata->utmi_mode) { 267 + case DWC3_OMAP_UTMI_MODE_SW: 268 + reg |= USBOTGSS_UTMI_OTG_STATUS_SW_MODE; 269 + break; 270 + case DWC3_OMAP_UTMI_MODE_HW: 271 + reg &= ~USBOTGSS_UTMI_OTG_STATUS_SW_MODE; 272 + break; 273 + default: 274 + dev_dbg(&pdev->dev, "UNKNOWN utmi mode %d\n", 275 + pdata->utmi_mode); 276 + } 277 + } 278 + 279 + dwc3_writel(omap->base, USBOTGSS_UTMI_OTG_STATUS, reg); 262 280 263 281 /* check the DMA Status */ 264 282 reg = dwc3_readl(omap->base, USBOTGSS_SYSCONFIG);
+47
include/linux/platform_data/dwc3-omap.h
··· 1 + /** 2 + * dwc3-omap.h - OMAP Specific Glue layer, header. 3 + * 4 + * Copyright (C) 2010-2011 Texas Instruments Incorporated - http://www.ti.com 5 + * All rights reserved. 6 + * 7 + * Author: Felipe Balbi <balbi@ti.com> 8 + * 9 + * Redistribution and use in source and binary forms, with or without 10 + * modification, are permitted provided that the following conditions 11 + * are met: 12 + * 1. Redistributions of source code must retain the above copyright 13 + * notice, this list of conditions, and the following disclaimer, 14 + * without modification. 15 + * 2. Redistributions in binary form must reproduce the above copyright 16 + * notice, this list of conditions and the following disclaimer in the 17 + * documentation and/or other materials provided with the distribution. 18 + * 3. The names of the above-listed copyright holders may not be used 19 + * to endorse or promote products derived from this software without 20 + * specific prior written permission. 21 + * 22 + * ALTERNATIVELY, this software may be distributed under the terms of the 23 + * GNU General Public License ("GPL") version 2, as published by the Free 24 + * Software Foundation. 25 + * 26 + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS 27 + * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 28 + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 29 + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR 30 + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 31 + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 32 + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 33 + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 34 + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 35 + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 36 + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 37 + */ 38 + 39 + enum dwc3_omap_utmi_mode { 40 + DWC3_OMAP_UTMI_MODE_UNKNOWN = 0, 41 + DWC3_OMAP_UTMI_MODE_HW, 42 + DWC3_OMAP_UTMI_MODE_SW, 43 + }; 44 + 45 + struct dwc3_omap_data { 46 + enum dwc3_omap_utmi_mode utmi_mode; 47 + };