From patchwork Wed Nov 28 01:16:01 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ming Lei X-Patchwork-Id: 1813471 Return-Path: X-Original-To: patchwork-linux-omap@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork1.kernel.org (Postfix) with ESMTP id 526723FC54 for ; Wed, 28 Nov 2012 01:16:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754189Ab2K1BQF (ORCPT ); Tue, 27 Nov 2012 20:16:05 -0500 Received: from mail-ea0-f174.google.com ([209.85.215.174]:39035 "EHLO mail-ea0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753213Ab2K1BQD (ORCPT ); Tue, 27 Nov 2012 20:16:03 -0500 Received: by mail-ea0-f174.google.com with SMTP id e13so5075485eaa.19 for ; Tue, 27 Nov 2012 17:16:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=hO+vl4g5oKlsIdCFKhA8ojwqdGU7mfhGkFoTdgwypA4=; b=Cb2fBNyd2X26mZ4HiSX87SC7emU9DtTNPd/MalryTO2RJRur3Jbwe79SJP+VsKAqbR fcHXQBxhQG2QmYDrBkpKdSX0pcP7iWlMecbEWX+kiHpSwww1LWCfXts7+Fixs5Z2lDtP 41GP2sQ3ZNdp8Y73gdYdo3ipnKI3mLSj8rR7UVxZ/Hr8OYpGfL/7eWZwVystAHYZXkF1 G64iWC/DQHqmgG7aK/s6zE5fYnjS2XOZJGbePeitudITH+G5n0ZkIAvEwWpNUalzdL0W c9gajz0K8qDVIjX0GVMtUDpdTGOGaHWfXPm6P+gSJywO+ZQki8gUopPxpUbFb5XqsNVd cFXw== MIME-Version: 1.0 Received: by 10.14.213.7 with SMTP id z7mr63444214eeo.39.1354065361297; Tue, 27 Nov 2012 17:16:01 -0800 (PST) Received: by 10.14.94.193 with HTTP; Tue, 27 Nov 2012 17:16:01 -0800 (PST) In-Reply-To: References: <50B4FE7D.9030505@linaro.org> Date: Wed, 28 Nov 2012 09:16:01 +0800 Message-ID: Subject: Re: [RFC PATCH 1/5] drivers : introduce device_path api From: Ming Lei To: Andy Green Cc: Alan Stern , Felipe Balbi , Greg KH , linux-omap@vger.kernel.org, keshava_mgowda@ti.com, USB list , rogerq@ti.com Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org On Wed, Nov 28, 2012 at 7:06 AM, Ming Lei wrote: >>> Also from my intuition, power domain should be involved in the problem, >>> because these hard-wired and self-powered USB devices should have >>> its own power domains, and the ehci-omap driver may enable/disable >>> these power domains before adding the bus. >> >> >> I don't know enough to have an opinion, but the arrangement on Panda is >> literally a linear regulator is being controlled by a gpio, which fits into >> struct regulator model. What else would a power domain for that buy us? > > One problem is that you are addressing to, another is that we may extend > Tianyu's per port power off/on mechanism into non-acpi world. > > Considered that our discussion has been extended to general case instead > of pandaboard only, there might be several bus devices which have different > power control method, which should be the idea of power domain. > > I have a draft idea and let me describe it by a pseudo_patch, see below: Sorry, looks sending it too quick, the below pseudo_patch may be more readable about the idea. + /*-------------------------------------------------------------------------*/ /* Thanks, diff --git a/drivers/usb/host/ehci-omap.c b/drivers/usb/host/ehci-omap.c index ac17a7c..c187a11 100644 --- a/drivers/usb/host/ehci-omap.c +++ b/drivers/usb/host/ehci-omap.c @@ -184,6 +184,7 @@ static int ehci_hcd_omap_probe(struct platform_device *pdev) int irq; int i; char supply[7]; + struct port_power_domain *ppd; if (usb_disabled()) return -ENODEV; @@ -220,6 +221,17 @@ static int ehci_hcd_omap_probe(struct platform_device *pdev) goto err_io; } + /* + * register usb per port power domain and enable power on + * this port, to which only hardwired and self-powered device + * attached. And the platform code should provide the + * port power domain list to the usb host controller driver. + */ + list_for_each_entry(ppd, &pdata->port_power_domain, list) { + usb_register_port_pm_domain(&hcd->self, ppd); + usb_enable_port_pm_domain(&hcd->self, ppd); + } + hcd->rsrc_start = res->start; hcd->rsrc_len = resource_size(res); hcd->regs = regs; @@ -289,6 +301,12 @@ static int ehci_hcd_omap_remove(struct platform_device *pdev) struct device *dev = &pdev->dev; struct usb_hcd *hcd = dev_get_drvdata(dev); struct ehci_hcd_omap_platform_data *pdata = dev->platform_data; + struct port_power_domain *ppd; + + list_for_each_entry(ppd, &pdata->port_power_domain, list) { + usb_disable_port_pm_domain(&hcd->self, ppd); + usb_unregister_port_pm_domain(&hcd->self, ppd); + } usb_remove_hcd(hcd); disable_put_regulator(dev->platform_data); diff --git a/include/linux/platform_data/usb-omap.h b/include/linux/platform_data/usb-omap.h index 8570bcf..30516c9 100644 --- a/include/linux/platform_data/usb-omap.h +++ b/include/linux/platform_data/usb-omap.h @@ -47,6 +47,8 @@ struct ehci_hcd_omap_platform_data { int reset_gpio_port[OMAP3_HS_USB_PORTS]; struct regulator *regulator[OMAP3_HS_USB_PORTS]; unsigned phy_reset:1; + + struct list_head port_power_domain; }; struct ohci_hcd_omap_platform_data { diff --git a/include/linux/usb/hcd.h b/include/linux/usb/hcd.h index 608050b..6b86d01 100644 --- a/include/linux/usb/hcd.h +++ b/include/linux/usb/hcd.h @@ -448,6 +448,39 @@ extern void usb_disconnect(struct usb_device **); extern int usb_get_configuration(struct usb_device *dev); extern void usb_destroy_configuration(struct usb_device *dev); +/* + * Only used for describing power domain which provide power to + * hardwired self-powered devices + */ +struct port_power_domain { + struct list_head list; + struct usb_bus *bus; + + /* + * physical port path, and the power domain of 'port_power' provides + * power on the device attatched to the last non-zero port(Pn-1) of + * the n-1 tier hub, the first number(P1) is the root hub port in + * the path, and the second number(P2) is the port number on the + * second tier hub, ..., until the last number Pn which is zero always. + */ + char port_path[32]; /* P1-P2-..Pn-1-Pn */ + + /* + * struct power_domain should be generic power thing, and should be + * defined in device power core, maybe it can reuse some kind of + * current power domain structure. + * + * Many ports can share one same power domain, so make the below field + * as pointer. + */ + struct power_domain *port_power; +}; + +extern int usb_register_port_pm_domain(struct usb_bus *bus, struct port_power_domain *ppd); +extern int usb_unregister_port_pm_domain(struct usb_bus *bus, struct port_power_domain *ppd); +extern int usb_enable_port_pm_domain(struct usb_bus *bus, struct port_power_domain *ppd); +extern int usb_disable_port_pm_domain(struct usb_bus *bus, struct port_power_domain *ppd);