From patchwork Mon Nov 7 13:05:07 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexandre Bailon X-Patchwork-Id: 81088 Delivered-To: patch@linaro.org Received: by 10.140.97.165 with SMTP id m34csp1007946qge; Mon, 7 Nov 2016 05:19:24 -0800 (PST) X-Received: by 10.98.20.131 with SMTP id 125mr13528135pfu.51.1478524764806; Mon, 07 Nov 2016 05:19:24 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s25si31301267pge.307.2016.11.07.05.19.24; Mon, 07 Nov 2016 05:19:24 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-usb-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@baylibre-com.20150623.gappssmtp.com; spf=pass (google.com: best guess record for domain of linux-usb-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-usb-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932378AbcKGNRT (ORCPT + 4 others); Mon, 7 Nov 2016 08:17:19 -0500 Received: from mail-wm0-f50.google.com ([74.125.82.50]:38702 "EHLO mail-wm0-f50.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932287AbcKGNFf (ORCPT ); Mon, 7 Nov 2016 08:05:35 -0500 Received: by mail-wm0-f50.google.com with SMTP id f82so117256008wmf.1 for ; Mon, 07 Nov 2016 05:05:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=zRVY/bAILpiPyZiWeEcQ0WDi5iwd6asIwItm/4GhlQ8=; b=gOiFBiB0bVYE/v5zKeN/YF6fgemB1cFgYDR3mj4CveftppVmGcpA8qKYBTgst7Pcn3 AbU/z/4g1o1NQvi3YEFXpSsfEvNI1fwocMTYShjtWYwroeqQqrjDtLvLWOdcpCJvv1B7 4mT+lh5sDmZENsk9kZHIShTAIId0qWfca28UToXDBfmpi5ek76pfUBiZAHZUXrcCyaNZ nvBPyrxzfUMWPwpM9hdYEdlK/ewKi3u5tGCVdtxb3VUnJ/JzwTMHGOPTiygB0lOSOzIa mMb2mdRMGNV6n8K8eyOZXu1HYiuBxpI9QRuXOQbHB0kKDch6OMTqeYKfRP2/esFBDtKp afeQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=zRVY/bAILpiPyZiWeEcQ0WDi5iwd6asIwItm/4GhlQ8=; b=iYwU/QPAtKzJE4Q2wPPUFHMbCy6ZaR1h50uxRGutnKq5mX37rYp9+kMf/E3awJTNJD DtrUu0dNy1VCgZRYS3NmOHDp2bidMqsCUcbpjEbFJKdy65rDy4VX5MXRJsBKxE4K+BAS wKudeSCPa02jGOf6h5kv0WgSe6cro29MzOiGm9O5ei/i0Smju0XhyDIZdbmz/DpvjGyk NHEl0hozVsuRUhA4BKG7SzKqEeFFJCb5qtJbz4NEX8I+CV1fSII/nTSQXKLUA1/iCTQS G180xRYgZruc+IMYeWleP4Obtw4BQd//hZE4NFbq4Ez3zGJE0EtAVsIRCbTXWFDv0Wel aHuA== X-Gm-Message-State: ABUngvdIDYTzue40UTo6e504qrMph9a1J/8CEJWCqeO8bbeaOy2wno4qmUgxuAIvGArmh1Xz X-Received: by 10.28.12.80 with SMTP id 77mr9552324wmm.106.1478523933367; Mon, 07 Nov 2016 05:05:33 -0800 (PST) Received: from localhost.localdomain ([90.63.244.31]) by smtp.gmail.com with ESMTPSA id y2sm30933952wjx.20.2016.11.07.05.05.32 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 07 Nov 2016 05:05:32 -0800 (PST) From: Alexandre Bailon To: david@lechnology.com, b-liu@ti.com, balbi@kernel.org Cc: kishon@ti.com, khilman@baylibre.com, linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org, nsekhar@ti.com, Alexandre Bailon Subject: [PATCH v5 3/4] usb: musb: Add a new argument to musb_platform_set_mode() Date: Mon, 7 Nov 2016 14:05:07 +0100 Message-Id: <1478523908-4383-4-git-send-email-abailon@baylibre.com> X-Mailer: git-send-email 2.7.3 In-Reply-To: <1478523908-4383-1-git-send-email-abailon@baylibre.com> References: <1478523908-4383-1-git-send-email-abailon@baylibre.com> Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org During the init, the driver will use musb_platform_set_mode() to configure the controller mode and the PHY mode. The PHY of DA8xx has some issues when the PHY is forced in host or device, so we want to keep it in OTG mode unless the user request a specific mode by using the sysfs. Add the init argument to musb_platform_set_mode() in order to let the callback change its behavior if it is called during the init. Signed-off-by: Alexandre Bailon --- drivers/usb/musb/am35x.c | 2 +- drivers/usb/musb/blackfin.c | 2 +- drivers/usb/musb/da8xx.c | 2 +- drivers/usb/musb/davinci.c | 2 +- drivers/usb/musb/musb_core.c | 12 ++++++------ drivers/usb/musb/musb_core.h | 6 +++--- drivers/usb/musb/musb_dsps.c | 2 +- drivers/usb/musb/sunxi.c | 2 +- drivers/usb/musb/tusb6010.c | 2 +- 9 files changed, 16 insertions(+), 16 deletions(-) -- 2.7.3 -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/usb/musb/am35x.c b/drivers/usb/musb/am35x.c index 50ca805..7136888 100644 --- a/drivers/usb/musb/am35x.c +++ b/drivers/usb/musb/am35x.c @@ -332,7 +332,7 @@ static irqreturn_t am35x_musb_interrupt(int irq, void *hci) return ret; } -static int am35x_musb_set_mode(struct musb *musb, u8 musb_mode) +static int am35x_musb_set_mode(struct musb *musb, u8 musb_mode, bool init) { struct device *dev = musb->controller; struct musb_hdrc_platform_data *plat = dev_get_platdata(dev); diff --git a/drivers/usb/musb/blackfin.c b/drivers/usb/musb/blackfin.c index 310238c..544e98f 100644 --- a/drivers/usb/musb/blackfin.c +++ b/drivers/usb/musb/blackfin.c @@ -356,7 +356,7 @@ static int bfin_musb_vbus_status(struct musb *musb) return 0; } -static int bfin_musb_set_mode(struct musb *musb, u8 musb_mode) +static int bfin_musb_set_mode(struct musb *musb, u8 musb_mode, bool init) { return -EIO; } diff --git a/drivers/usb/musb/da8xx.c b/drivers/usb/musb/da8xx.c index 6749aa1..ac0c2f7 100644 --- a/drivers/usb/musb/da8xx.c +++ b/drivers/usb/musb/da8xx.c @@ -335,7 +335,7 @@ static irqreturn_t da8xx_musb_interrupt(int irq, void *hci) return ret; } -static int da8xx_musb_set_mode(struct musb *musb, u8 musb_mode) +static int da8xx_musb_set_mode(struct musb *musb, u8 musb_mode, bool init) { struct da8xx_glue *glue = dev_get_drvdata(musb->controller->parent); enum phy_mode phy_mode; diff --git a/drivers/usb/musb/davinci.c b/drivers/usb/musb/davinci.c index cee61a5..d12b902 100644 --- a/drivers/usb/musb/davinci.c +++ b/drivers/usb/musb/davinci.c @@ -369,7 +369,7 @@ static irqreturn_t davinci_musb_interrupt(int irq, void *__hci) return retval; } -static int davinci_musb_set_mode(struct musb *musb, u8 mode) +static int davinci_musb_set_mode(struct musb *musb, u8 mode, bool init) { /* EVM can't do this (right?) */ return -EIO; diff --git a/drivers/usb/musb/musb_core.c b/drivers/usb/musb/musb_core.c index 27dadc0..4a8d394 100644 --- a/drivers/usb/musb/musb_core.c +++ b/drivers/usb/musb/musb_core.c @@ -1730,11 +1730,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_platform_set_mode(musb, MUSB_HOST, false); else if (sysfs_streq(buf, "peripheral")) - status = musb_platform_set_mode(musb, MUSB_PERIPHERAL); + status = musb_platform_set_mode(musb, MUSB_PERIPHERAL, false); else if (sysfs_streq(buf, "otg")) - status = musb_platform_set_mode(musb, MUSB_OTG); + status = musb_platform_set_mode(musb, MUSB_OTG, false); else status = -EINVAL; spin_unlock_irqrestore(&musb->lock, flags); @@ -2261,13 +2261,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_platform_set_mode(musb, MUSB_HOST, true); 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_platform_set_mode(musb, MUSB_PERIPHERAL, true); break; case MUSB_PORT_MODE_DUAL_ROLE: status = musb_host_setup(musb, plat->power); @@ -2278,7 +2278,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_platform_set_mode(musb, MUSB_OTG, true); break; default: dev_err(dev, "unsupported port mode %d\n", musb->port_mode); diff --git a/drivers/usb/musb/musb_core.h b/drivers/usb/musb/musb_core.h index 2cb88a49..1bfc8fa 100644 --- a/drivers/usb/musb/musb_core.h +++ b/drivers/usb/musb/musb_core.h @@ -203,7 +203,7 @@ struct musb_platform_ops { struct dma_controller * (*dma_init) (struct musb *musb, void __iomem *base); void (*dma_exit)(struct dma_controller *c); - int (*set_mode)(struct musb *musb, u8 mode); + int (*set_mode)(struct musb *musb, u8 mode, bool init); void (*try_idle)(struct musb *musb, unsigned long timeout); int (*recover)(struct musb *musb); @@ -558,12 +558,12 @@ 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) +static inline int musb_platform_set_mode(struct musb *musb, u8 mode, bool init) { if (!musb->ops->set_mode) return 0; - return musb->ops->set_mode(musb, mode); + return musb->ops->set_mode(musb, mode, init); } static inline void musb_platform_try_idle(struct musb *musb, diff --git a/drivers/usb/musb/musb_dsps.c b/drivers/usb/musb/musb_dsps.c index 0f17d21..a889679 100644 --- a/drivers/usb/musb/musb_dsps.c +++ b/drivers/usb/musb/musb_dsps.c @@ -462,7 +462,7 @@ static int dsps_musb_exit(struct musb *musb) return 0; } -static int dsps_musb_set_mode(struct musb *musb, u8 mode) +static int dsps_musb_set_mode(struct musb *musb, u8 mode, bool init) { struct device *dev = musb->controller; struct dsps_glue *glue = dev_get_drvdata(dev->parent); diff --git a/drivers/usb/musb/sunxi.c b/drivers/usb/musb/sunxi.c index 1408245..04bf763 100644 --- a/drivers/usb/musb/sunxi.c +++ b/drivers/usb/musb/sunxi.c @@ -346,7 +346,7 @@ static void sunxi_musb_dma_controller_destroy(struct dma_controller *c) { } -static int sunxi_musb_set_mode(struct musb *musb, u8 mode) +static int sunxi_musb_set_mode(struct musb *musb, u8 mode, bool init) { struct sunxi_glue *glue = dev_get_drvdata(musb->controller->parent); enum phy_mode new_mode; diff --git a/drivers/usb/musb/tusb6010.c b/drivers/usb/musb/tusb6010.c index df7c9f4..8a74587 100644 --- a/drivers/usb/musb/tusb6010.c +++ b/drivers/usb/musb/tusb6010.c @@ -628,7 +628,7 @@ static void tusb_musb_set_vbus(struct musb *musb, int is_on) * Note that if a mini-A cable is plugged in the ID line will stay down as * the weak ID pull-up is not able to pull the ID up. */ -static int tusb_musb_set_mode(struct musb *musb, u8 musb_mode) +static int tusb_musb_set_mode(struct musb *musb, u8 musb_mode, bool init) { void __iomem *tbase = musb->ctrl_base; u32 otg_stat, phy_otg_ctrl, phy_otg_ena, dev_conf;