From patchwork Mon Jun 17 15:13:33 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sebastian Andrzej Siewior X-Patchwork-Id: 2733821 Return-Path: X-Original-To: patchwork-linux-omap@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 6E4509F8E1 for ; Mon, 17 Jun 2013 15:13:49 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id B32CB202EA for ; Mon, 17 Jun 2013 15:13:44 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 61983202DB for ; Mon, 17 Jun 2013 15:13:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751304Ab3FQPNl (ORCPT ); Mon, 17 Jun 2013 11:13:41 -0400 Received: from www.linutronix.de ([62.245.132.108]:39754 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751062Ab3FQPNj (ORCPT ); Mon, 17 Jun 2013 11:13:39 -0400 Received: from localhost ([127.0.0.1] helo=localhost.localdomain) by Galois.linutronix.de with esmtp (Exim 4.72) (envelope-from ) id 1Uob7i-0002vt-08; Mon, 17 Jun 2013 17:13:38 +0200 From: Sebastian Andrzej Siewior To: Felipe Balbi Cc: linux-omap@vger.kernel.org, linux-usb@vger.kernel.org, Sebastian Andrzej Siewior Subject: [PATCH 1/2] musb: musb: dsps: support multiple instances Date: Mon, 17 Jun 2013 17:13:33 +0200 Message-Id: <1371482014-5244-2-git-send-email-bigeasy@linutronix.de> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1371482014-5244-1-git-send-email-bigeasy@linutronix.de> References: <1371482014-5244-1-git-send-email-bigeasy@linutronix.de> X-Linutronix-Spam-Score: -1.0 X-Linutronix-Spam-Level: - X-Linutronix-Spam-Status: No , -1.0 points, 5.0 required, ALL_TRUSTED=-1, SHORTCIRCUIT=-0.0001 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.0 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 If we specify right now more than once instance then we attempt to add the platform device twice. The nop driver does not mind the second add because it checks for it and returns without a word. At removal time a segfault is likely because the first intance clean ups the phy and second, well, goes boom. This patchs adds two dummy device node to the am33xx for the dummy phy which we have now. During probe time, we grab the phy based on the device node if we have one. If not, we use the same hack we used so far. Signed-off-by: Sebastian Andrzej Siewior --- arch/arm/boot/dts/am33xx.dtsi | 8 ++++++++ drivers/usb/musb/musb_dsps.c | 18 +++++++++++++----- include/linux/usb/musb.h | 1 + 3 files changed, 22 insertions(+), 5 deletions(-) diff --git a/arch/arm/boot/dts/am33xx.dtsi b/arch/arm/boot/dts/am33xx.dtsi index 8e1248f..30d0d45 100644 --- a/arch/arm/boot/dts/am33xx.dtsi +++ b/arch/arm/boot/dts/am33xx.dtsi @@ -341,6 +341,14 @@ port1-mode = <3>; power = <250>; ti,hwmods = "usb_otg_hs"; + phys = <&nopphy0 &nopphy1>; + }; + + nopphy0: usbphy@0 { + compatible = "usb-nop-xceiv"; + }; + nopphy1: usbphy@1 { + compatible = "usb-nop-xceiv"; }; mac: ethernet@4a100000 { diff --git a/drivers/usb/musb/musb_dsps.c b/drivers/usb/musb/musb_dsps.c index e1b661d..d9ff390 100644 --- a/drivers/usb/musb/musb_dsps.c +++ b/drivers/usb/musb/musb_dsps.c @@ -415,9 +415,14 @@ static int dsps_musb_init(struct musb *musb) /* mentor core register starts at offset of 0x400 from musb base */ musb->mregs += wrp->musb_core_offset; - /* NOP driver needs change if supporting dual instance */ - usb_nop_xceiv_register(); - musb->xceiv = usb_get_phy(USB_PHY_TYPE_USB2); + if (!glue->dev->of_node) { + /* This hack works only for a single instance. */ + usb_nop_xceiv_register(); + musb->xceiv = usb_get_phy(USB_PHY_TYPE_USB2); + } else { + musb->xceiv = devm_usb_get_phy_by_phandle(glue->dev, "phys", + musb->config->instance); + } if (IS_ERR_OR_NULL(musb->xceiv)) return -EPROBE_DEFER; @@ -449,7 +454,8 @@ static int dsps_musb_init(struct musb *musb) return 0; err0: usb_put_phy(musb->xceiv); - usb_nop_xceiv_unregister(); + if (!glue->dev->of_node) + usb_nop_xceiv_unregister(); return status; } @@ -466,7 +472,8 @@ static int dsps_musb_exit(struct musb *musb) /* NOP driver needs change if supporting dual instance */ usb_put_phy(musb->xceiv); - usb_nop_xceiv_unregister(); + if (!glue->dev->of_node) + usb_nop_xceiv_unregister(); return 0; } @@ -570,6 +577,7 @@ static int dsps_create_musb_pdev(struct dsps_glue *glue, u8 id) of_property_read_u32(np, res_name, (u32 *)&pdata->mode); of_property_read_u32(np, "power", (u32 *)&pdata->power); config->multipoint = of_property_read_bool(np, "multipoint"); + config->instance = id; pdata->config = config; } diff --git a/include/linux/usb/musb.h b/include/linux/usb/musb.h index 053c268..e027705 100644 --- a/include/linux/usb/musb.h +++ b/include/linux/usb/musb.h @@ -83,6 +83,7 @@ struct musb_hdrc_config { u8 vendor_stat __deprecated; /* vendor status reg witdh */ u8 dma_req_chan __deprecated; /* bitmask for required dma channels */ u8 ram_bits; /* ram address size */ + u8 instance; struct musb_hdrc_eps_bits *eps_bits __deprecated; #ifdef CONFIG_BLACKFIN