From patchwork Fri May 13 22:25:17 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tony Lindgren X-Patchwork-Id: 9093951 Return-Path: X-Original-To: patchwork-linux-omap@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 0CEB3BF29F for ; Fri, 13 May 2016 22:25:26 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 1E9172020F for ; Fri, 13 May 2016 22:25:25 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 360B720172 for ; Fri, 13 May 2016 22:25:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753833AbcEMWZW (ORCPT ); Fri, 13 May 2016 18:25:22 -0400 Received: from muru.com ([72.249.23.125]:54343 "EHLO muru.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753348AbcEMWZW (ORCPT ); Fri, 13 May 2016 18:25:22 -0400 Received: from atomide.com (localhost [127.0.0.1]) by muru.com (Postfix) with ESMTPS id DAB548225; Fri, 13 May 2016 22:27:05 +0000 (UTC) Date: Fri, 13 May 2016 15:25:17 -0700 From: Tony Lindgren To: Bin Liu , Felipe Balbi , Kishon Vijay Abraham I , Ivaylo Dimitrov , Sergei Shtylyov , linux-usb@vger.kernel.org, linux-omap@vger.kernel.org Subject: Re: [PATCH 10/15] usb: musb: Don't set d+ high before enable for 2430 glue layer Message-ID: <20160513222517.GG5995@atomide.com> References: <1463014396-4095-1-git-send-email-tony@atomide.com> <1463014396-4095-11-git-send-email-tony@atomide.com> <20160513210334.GC1665@uda0271908> <20160513211739.GE5995@atomide.com> <20160513212252.GA1659@uda0271908> <20160513213900.GF5995@atomide.com> <20160513220232.GA2478@uda0271908> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20160513220232.GA2478@uda0271908> User-Agent: Mutt/1.5.24 (2015-08-30) Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org X-Spam-Status: No, score=-8.3 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP * Bin Liu [160513 15:04]: > > But what would be in musb_default_set_mode()? Currently only am35x, > da8xx, dsps, and omap2430 glues implement _set_mode(), but they don't > have any in common. Only omap2430 sets session bit in _set_mode(), no > one else does so. Well how about the following if no glue specific configuration of the ID pin is possible? Tony 8< ----------------------- --- To unsubscribe from this list: send the line "unsubscribe linux-omap" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html --- a/drivers/usb/musb/musb_core.c +++ b/drivers/usb/musb/musb_core.c @@ -416,6 +416,26 @@ void musb_write_fifo(struct musb_hw_ep *hw_ep, u16 len, const u8 *src) return hw_ep->musb->io.write_fifo(hw_ep, len, src); } +static int musb_try_set_mode(struct musb *musb, u8 mode) +{ + if (musb->ops->set_mode) + return musb->ops->set_mode(musb, mode); + + if (mode == MUSB_HOST) { + u8 devctl; + + devctl = musb_readb(musb->mregs, MUSB_DEVCTL); + devctl |= MUSB_DEVCTL_SESSION; + musb_writeb(musb->mregs, MUSB_DEVCTL, devctl); + } else { + dev_warn(musb->controller, + "platform specific set_mode not implemnted: %i\n", + mode); + } + + return 0; +} + /*-------------------------------------------------------------------------*/ /* for high speed test mode; see USB 2.0 spec 7.1.20 */ @@ -1723,11 +1743,11 @@ musb_mode_store(struct device *dev, struct device_attribute *attr, spin_lock_irqsave(&musb->lock, flags); if (sysfs_streq(buf, "host")) - status = musb_platform_set_mode(musb, MUSB_HOST); + status = musb_try_set_mode(musb, MUSB_HOST); else if (sysfs_streq(buf, "peripheral")) - status = musb_platform_set_mode(musb, MUSB_PERIPHERAL); + status = musb_try_set_mode(musb, MUSB_PERIPHERAL); else if (sysfs_streq(buf, "otg")) - status = musb_platform_set_mode(musb, MUSB_OTG); + status = musb_try_set_mode(musb, MUSB_OTG); else status = -EINVAL; spin_unlock_irqrestore(&musb->lock, flags); @@ -2185,13 +2205,13 @@ musb_init_controller(struct device *dev, int nIrq, void __iomem *ctrl) status = musb_host_setup(musb, plat->power); if (status < 0) goto fail3; - status = musb_platform_set_mode(musb, MUSB_HOST); + status = musb_try_set_mode(musb, MUSB_HOST); break; case MUSB_PORT_MODE_GADGET: status = musb_gadget_setup(musb); if (status < 0) goto fail3; - status = musb_platform_set_mode(musb, MUSB_PERIPHERAL); + status = musb_try_set_mode(musb, MUSB_PERIPHERAL); break; case MUSB_PORT_MODE_DUAL_ROLE: status = musb_host_setup(musb, plat->power); @@ -2202,7 +2222,7 @@ musb_init_controller(struct device *dev, int nIrq, void __iomem *ctrl) musb_host_cleanup(musb); goto fail3; } - status = musb_platform_set_mode(musb, MUSB_OTG); + status = musb_try_set_mode(musb, MUSB_OTG); break; default: dev_err(dev, "unsupported port mode %d\n", musb->port_mode); --- a/drivers/usb/musb/musb_core.h +++ b/drivers/usb/musb/musb_core.h @@ -556,14 +556,6 @@ static inline void musb_platform_disable(struct musb *musb) musb->ops->disable(musb); } -static inline int musb_platform_set_mode(struct musb *musb, u8 mode) -{ - if (!musb->ops->set_mode) - return 0; - - return musb->ops->set_mode(musb, mode); -} - static inline void musb_platform_try_idle(struct musb *musb, unsigned long timeout) {