From patchwork Tue Apr 23 15:03:10 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lee Jones X-Patchwork-Id: 16360 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ye0-f198.google.com (mail-ye0-f198.google.com [209.85.213.198]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id C92702391B for ; Tue, 23 Apr 2013 15:04:45 +0000 (UTC) Received: by mail-ye0-f198.google.com with SMTP id m5sf332330yen.5 for ; Tue, 23 Apr 2013 08:03:57 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-received:mime-version:x-beenthere:x-received:received-spf :x-received:x-forwarded-to:x-forwarded-for:delivered-to:x-received :received-spf:x-received:from:to:cc:subject:date:message-id:x-mailer :in-reply-to:references:x-gm-message-state:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :x-google-group-id:list-post:list-help:list-archive:list-unsubscribe; bh=sGbr00FQHuwGhmH/hEfsKkVJsAcnjCeCHZN5bTz5zhQ=; b=MjsbRuMvcKxYgDLDlk4pUH3YvB+zDzkJLKrAewc4vXheAc08OLjJXMGT+8vAP/mrHv E4wdAQ49blt4doCEqNeHs9goQgbOpNdk2AIx8m6XNSXiuoScJZxXFIUTHazv8rE+rx4J XGPO+ZmvKYyhfeDJwkqVKN1VplvbKt6rg0UW4ixZow0hpYVsns6F6PaSbSnsJoChKblf 2vh7tMqAVArMTSj+Wgs5JuscuH18DwhIdyRa12sXfeJTR3IBAji8hWZASbZuwfhcQazI ZJmEu69JZT4XiaBF2/17Dmgqo66dptPjJbS9LurNUIoyjYWEqDcnTgGkM0CUvELvjnOa z92Q== X-Received: by 10.224.75.137 with SMTP id y9mr131920qaj.3.1366729436890; Tue, 23 Apr 2013 08:03:56 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.71.202 with SMTP id x10ls348840qeu.56.gmail; Tue, 23 Apr 2013 08:03:56 -0700 (PDT) X-Received: by 10.52.89.48 with SMTP id bl16mr19222228vdb.120.1366729436705; Tue, 23 Apr 2013 08:03:56 -0700 (PDT) Received: from mail-vc0-f169.google.com (mail-vc0-f169.google.com [209.85.220.169]) by mx.google.com with ESMTPS id gr7si3005304vdc.142.2013.04.23.08.03.56 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 23 Apr 2013 08:03:56 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.220.169 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.220.169; Received: by mail-vc0-f169.google.com with SMTP id gd11so737283vcb.0 for ; Tue, 23 Apr 2013 08:03:56 -0700 (PDT) X-Received: by 10.52.166.103 with SMTP id zf7mr19395684vdb.94.1366729436574; Tue, 23 Apr 2013 08:03:56 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.58.127.98 with SMTP id nf2csp129530veb; Tue, 23 Apr 2013 08:03:54 -0700 (PDT) X-Received: by 10.194.82.34 with SMTP id f2mr3912045wjy.25.1366729428232; Tue, 23 Apr 2013 08:03:48 -0700 (PDT) Received: from mail-wi0-x236.google.com (mail-wi0-x236.google.com [2a00:1450:400c:c05::236]) by mx.google.com with ESMTPS id p17si6374863wie.23.2013.04.23.08.03.47 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 23 Apr 2013 08:03:48 -0700 (PDT) Received-SPF: neutral (google.com: 2a00:1450:400c:c05::236 is neither permitted nor denied by best guess record for domain of lee.jones@linaro.org) client-ip=2a00:1450:400c:c05::236; Received: by mail-wi0-f182.google.com with SMTP id m6so898906wiv.9 for ; Tue, 23 Apr 2013 08:03:47 -0700 (PDT) X-Received: by 10.180.105.195 with SMTP id go3mr42854652wib.2.1366729427820; Tue, 23 Apr 2013 08:03:47 -0700 (PDT) Received: from localhost.localdomain (cpc34-aztw25-2-0-cust250.18-1.cable.virginmedia.com. [86.16.136.251]) by mx.google.com with ESMTPS id q20sm16491081wiv.7.2013.04.23.08.03.46 (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 23 Apr 2013 08:03:46 -0700 (PDT) From: Lee Jones To: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Cc: arnd@arndb.de, linus.walleij@stericsson.com, mian.yousaf.kaukab@stericsson.com, Lee Jones , Felipe Balbi , linux-usb@vger.kernel.org Subject: [PATCH 06/10] usb: musb: ux500: add device tree probing support Date: Tue, 23 Apr 2013 16:03:10 +0100 Message-Id: <1366729394-11406-7-git-send-email-lee.jones@linaro.org> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1366729394-11406-1-git-send-email-lee.jones@linaro.org> References: <1366729394-11406-1-git-send-email-lee.jones@linaro.org> X-Gm-Message-State: ALoCoQnTQ/NxoPoLUwWrWUfD/4e434kIGa2qWFL9RenLkIUwQtt2VjKErNrp40nvoycaZ3lhVN/H X-Original-Sender: lee.jones@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.220.169 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Precedence: list Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org List-ID: X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , This patch will allow ux500-musb to be probed and configured solely from configuration found in Device Tree. Cc: Felipe Balbi Cc: linux-usb@vger.kernel.org Signed-off-by: Lee Jones --- .../devicetree/bindings/usb/ux500-usb.txt | 49 +++++++++++++++++++ drivers/usb/musb/ux500.c | 51 ++++++++++++++++++++ 2 files changed, 100 insertions(+) create mode 100644 Documentation/devicetree/bindings/usb/ux500-usb.txt diff --git a/Documentation/devicetree/bindings/usb/ux500-usb.txt b/Documentation/devicetree/bindings/usb/ux500-usb.txt new file mode 100644 index 0000000..2844cbc --- /dev/null +++ b/Documentation/devicetree/bindings/usb/ux500-usb.txt @@ -0,0 +1,49 @@ +Ux500 MUSB + +Required properties: + - compatible : Should be "stericsson,db8500-musb" + - reg : Offset and length of registers + - interrupts : Interrupt; mode, number and trigger + - mode : One of; "host", "otg", or "peripheral" + +Optional properties: + - dmas : A list of dma channels; + dma-controller, event-line, fixed-channel, flags + - dma-names : An ordered list of channel names affiliated to the above + +Example: + +usb_per5@a03e0000 { + compatible = "stericsson,db8500-musb", "mentor,musb"; + reg = <0xa03e0000 0x10000>; + interrupts = <0 23 0x4>; + interrupt-names = "mc"; + + mode = "otg"; + + dmas = <&dma 38 0 0x2>, /* Logical - DevToMem */ + <&dma 38 0 0x0>, /* Logical - MemToDev */ + <&dma 37 0 0x2>, /* Logical - DevToMem */ + <&dma 37 0 0x0>, /* Logical - MemToDev */ + <&dma 36 0 0x2>, /* Logical - DevToMem */ + <&dma 36 0 0x0>, /* Logical - MemToDev */ + <&dma 19 0 0x2>, /* Logical - DevToMem */ + <&dma 19 0 0x0>, /* Logical - MemToDev */ + <&dma 18 0 0x2>, /* Logical - DevToMem */ + <&dma 18 0 0x0>, /* Logical - MemToDev */ + <&dma 17 0 0x2>, /* Logical - DevToMem */ + <&dma 17 0 0x0>, /* Logical - MemToDev */ + <&dma 16 0 0x2>, /* Logical - DevToMem */ + <&dma 16 0 0x0>, /* Logical - MemToDev */ + <&dma 39 0 0x2>, /* Logical - DevToMem */ + <&dma 39 0 0x0>; /* Logical - MemToDev */ + + dma-names = "iep_1_9", "oep_1_9", + "iep_2_10", "oep_2_10", + "iep_3_11", "oep_3_11", + "iep_4_12", "oep_4_12", + "iep_5_13", "oep_5_13", + "iep_6_14", "oep_6_14", + "iep_7_15", "oep_7_15", + "iep_8", "oep_8"; +}; diff --git a/drivers/usb/musb/ux500.c b/drivers/usb/musb/ux500.c index 7ddb132..6418624 100644 --- a/drivers/usb/musb/ux500.c +++ b/drivers/usb/musb/ux500.c @@ -25,6 +25,7 @@ #include #include #include +#include #include #include "musb_core.h" @@ -88,14 +89,57 @@ static const struct musb_platform_ops ux500_ops = { .exit = ux500_musb_exit, }; +static struct musb_hdrc_platform_data * +ux500_of_probe(struct platform_device *pdev, struct device_node *np) +{ + struct musb_hdrc_platform_data *pdata; + const char *mode; + int strlen; + + pdata = devm_kzalloc(&pdev->dev, sizeof(*pdata), GFP_KERNEL); + if (!pdata) + return NULL; + + mode = of_get_property(np, "mode", &strlen); + if (!mode) { + dev_err(&pdev->dev, "No 'mode' property found\n"); + return NULL; + } + + if (strlen > 0) { + if (!strcmp(mode, "host")) + pdata->mode = MUSB_HOST; + if (!strcmp(mode, "otg")) + pdata->mode = MUSB_OTG; + if (!strcmp(mode, "peripheral")) + pdata->mode = MUSB_PERIPHERAL; + } + + return pdata; +} + static int ux500_probe(struct platform_device *pdev) { struct musb_hdrc_platform_data *pdata = pdev->dev.platform_data; + struct device_node *np = pdev->dev.of_node; struct platform_device *musb; struct ux500_glue *glue; struct clk *clk; int ret = -ENOMEM; + if (!pdata) { + if (np) { + pdata = ux500_of_probe(pdev, np); + if (!pdata) + goto err0; + + pdev->dev.platform_data = pdata; + } else { + dev_err(&pdev->dev, "no pdata or device tree found\n"); + goto err0; + } + } + glue = kzalloc(sizeof(*glue), GFP_KERNEL); if (!glue) { dev_err(&pdev->dev, "failed to allocate glue context\n"); @@ -124,6 +168,7 @@ static int ux500_probe(struct platform_device *pdev) musb->dev.parent = &pdev->dev; musb->dev.dma_mask = &pdev->dev.coherent_dma_mask; musb->dev.coherent_dma_mask = pdev->dev.coherent_dma_mask; + musb->dev.of_node = pdev->dev.of_node; glue->dev = &pdev->dev; glue->musb = musb; @@ -222,12 +267,18 @@ static const struct dev_pm_ops ux500_pm_ops = { #define DEV_PM_OPS NULL #endif +static const struct of_device_id ux500_match[] = { + { .compatible = "stericsson,db8500-musb", }, + {} +}; + static struct platform_driver ux500_driver = { .probe = ux500_probe, .remove = ux500_remove, .driver = { .name = "musb-ux500", .pm = DEV_PM_OPS, + .of_match_table = ux500_match, }, };