Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752554AbcJJXS2 (ORCPT ); Mon, 10 Oct 2016 19:18:28 -0400 Received: from vern.gendns.com ([206.190.152.46]:42853 "EHLO vern.gendns.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752209AbcJJXS1 (ORCPT ); Mon, 10 Oct 2016 19:18:27 -0400 Subject: Re: [PATCH/RFT 07/12] USB: ohci-da8xx: Request gpios and handle interrupt in the driver To: ahaslam@baylibre.com, gregkh@linuxfoundation.org, robh+dt@kernel.org, nsekhar@ti.com, stern@rowland.harvard.edu, khilman@baylibre.com, sshtylyov@ru.mvista.com References: <1475858577-10366-1-git-send-email-ahaslam@baylibre.com> <1475858577-10366-8-git-send-email-ahaslam@baylibre.com> Cc: linux-usb@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org From: David Lechner Message-ID: <22f1532a-b651-3330-b2ce-9a64a35c85af@lechnology.com> Date: Mon, 10 Oct 2016 18:18:46 -0500 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.3.0 MIME-Version: 1.0 In-Reply-To: <1475858577-10366-8-git-send-email-ahaslam@baylibre.com> 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 Content-Length: 2158 Lines: 46 On 10/07/2016 11:42 AM, ahaslam@baylibre.com wrote: > From: Axel Haslam > > Currently requesting the vbus and overcurrent gpio is handled on > the board specific file. But this does not play well moving to > device tree. > > In preparation to migrate to a device tree boot, handle requesting > gpios and overcurrent interrupt on the usb driver itself, thus avoiding > callbacks to arch/mach* > Instead of using gpios, it seems like it would be better to use a regulator here. I don't know of any real-life cases, but who is to say someone will not design a board that uses a regulator controlled by I2C instead of gpios or something like that. Then, boards that don't have gpios can just use a fixed regulator (or you can make the regulator optional). Using a regulator would also allow users to decide how to respond to overcurrent events (by supplying their own regulator driver) instead of the behavior being dictated by the ohci driver. In my particular area of interest (LEGO MINDSTORMS EV3), the 5V (hardware) regulator for VBUS does use gpios, but the 5V is also shared with the LEGO input and output ports. So what I would ultimately like to be able to do is have userspace notified of an overcurrent event and let userspace decided when to turn the vbus back on. For example, someone might plug something into one of the LEGO input or output ports that causes a short circuit. I would like to display a notification to the user and wait for them to correct the problem and then press a button to turn the power back on. This will require some modifications to the regulator subsystem though. I actually started work on this a while back, but haven't had the time to pursue it any farther. Here are my WIP patches in case there is any interest: * https://github.com/dlech/ev3dev-kernel/commit/541a42b3b8ed639e95bbc835df3292f80190c789 * https://github.com/dlech/ev3dev-kernel/commit/2ba99b1ad6a06c944dd33a073f54044e71b75ae6 * https://github.com/dlech/ev3dev-kernel/commit/cdb03caa50e64931d4f2836c648739aa4385ed3b * https://github.com/dlech/ev3dev-kernel/commit/9d6b50cde34b51309c74d97c26b1430c7ff6aa0f