From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752603AbcEIWsH (ORCPT ); Mon, 9 May 2016 18:48:07 -0400 Received: from vern.gendns.com ([206.190.152.46]:36253 "EHLO vern.gendns.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751360AbcEIWsE (ORCPT ); Mon, 9 May 2016 18:48:04 -0400 Subject: Re: [PATCH v4 3/7] phy: Add set_mode callback To: Bin Liu , petr@barix.com, sergei.shtylyov@cogentembedded.com, khilman@kernel.org, nsekhar@ti.com, Rob Herring , Pawel Moll , Mark Rutland , Ian Campbell , Kumar Gala , Kishon Vijay Abraham I , Greg Kroah-Hartman , Alan Stern , Lee Jones , devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org References: <1460658919-4965-1-git-send-email-david@lechnology.com> <1460658919-4965-4-git-send-email-david@lechnology.com> <20160504181030.GA4327@uda0271908> <572A3D74.3080907@lechnology.com> <20160504183903.GB27414@uda0271908> From: David Lechner Message-ID: <5731139F.4020602@lechnology.com> Date: Mon, 9 May 2016 17:47:59 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.6.0 MIME-Version: 1.0 In-Reply-To: <20160504183903.GB27414@uda0271908> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - vern.gendns.com X-AntiAbuse: Original Domain - vger.kernel.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - lechnology.com X-Get-Message-Sender-Via: vern.gendns.com: authenticated_id: davidmain+lechnology.com/only user confirmed/virtual account not confirmed X-Authenticated-Sender: vern.gendns.com: davidmain@lechnology.com X-Source: X-Source-Args: X-Source-Dir: Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 05/04/2016 01:39 PM, Bin Liu wrote: > On Wed, May 04, 2016 at 01:20:36PM -0500, David Lechner wrote: >> This is something I actually plan on using because the device I am >> using (LEGO MINDSTORMS EV3) is not wired for OTG, so the callback is >> needed to override the ID and VBUS signals when switching between >> host and peripheral mode. > > Have you already tested this? I never tried changing mode via sysfs, but > by quickly reviewing the code, I am wondering how it works. the core > only calls ops->set_mode() but nothing else. To really switch the mode, > the driver has to talk to the root hub, and manipulate the SESSION > bit... > I have tested this now and it works. It works because by setting the mode, we are overriding the VBUS and ID signals, which in turn triggers interrupts. I have tested switching to both peripheral mode and host mode via sysfs. Host mode has some issues if you are using a self-powered device, but that is a bug in the da8xx glue layer and shouldn't hold up this patch series. Aside from that, it works exactly as expected.