From patchwork Thu Oct 27 09:34:06 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexandre Bailon X-Patchwork-Id: 79640 Delivered-To: patch@linaro.org Received: by 10.140.97.247 with SMTP id m110csp550371qge; Thu, 27 Oct 2016 03:54:47 -0700 (PDT) X-Received: by 10.99.132.194 with SMTP id k185mr11018105pgd.171.1477565687809; Thu, 27 Oct 2016 03:54:47 -0700 (PDT) Return-Path: Received: from bombadil.infradead.org (bombadil.infradead.org. [2001:1868:205::9]) by mx.google.com with ESMTPS id u126si7259787pfb.69.2016.10.27.03.54.47 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 27 Oct 2016 03:54:47 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org designates 2001:1868:205::9 as permitted sender) client-ip=2001:1868:205::9; 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-arm-kernel-bounces+patch=linaro.org@lists.infradead.org designates 2001:1868:205::9 as permitted sender) smtp.mailfrom=linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.85_2 #1 (Red Hat Linux)) id 1bziJU-0001A2-Nm; Thu, 27 Oct 2016 10:53:36 +0000 Received: from mail-wm0-x234.google.com ([2a00:1450:400c:c09::234]) by bombadil.infradead.org with esmtps (Exim 4.85_2 #1 (Red Hat Linux)) id 1bziJ4-0000ez-1J for linux-arm-kernel@lists.infradead.org; Thu, 27 Oct 2016 10:53:13 +0000 Received: by mail-wm0-x234.google.com with SMTP id n67so29781091wme.1 for ; Thu, 27 Oct 2016 03:52:49 -0700 (PDT) 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=Pfk1XI/fX2Sj9vcyj1FkCZfIz+mtEebepduTp6rtLNo=; b=c/8sMK+EuHf8do4pcx4VD6qB6e/g9z2hQ3cBilSaikOdW6IEc5aLuz2SGuPpaSkXHg HkCNcZBnUb2ztUfVKSFwOK+RMf6bsT2r2LWTN4/XTq3F/9uIoYxHKS9RRMJy423jJvU2 7TAdZRI3s2NOa25pcqebbrw/WU40J4KGfHKSkkFAJxQ2j2rZQ/GwRoOB8AT8jDg0xDsu AfUJSAvoF59UUg0zpv4uvIeytXqAqWM+0Pe+ySZdt/iqyl/TnSmeR0X4HYZlGNxZ8A4w nleY05CRQRhqj0tsU0lXoAaubMtFMpnz2cySK0ZMUHdkIgEY398IwntnyYSqyfb96dfS r9XQ== 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=Pfk1XI/fX2Sj9vcyj1FkCZfIz+mtEebepduTp6rtLNo=; b=Eo+weQOEmHWUzN9y/RNiz0ArV0pOP4/+K6wtwRzfVdPRFb4iGFRHikhur/45AycCRS IPbj6JR2VnKZoGrxLduBeXn9VmkcOHVe7OCWpxt9HanzAj6SQx3cmY/MWxzBlcaIDPvp MO2Ayp3FjhCvZvr8BeQ1q9hY+y994iIMyiEdiEnTk+Gh3HUsWmytIHFa8lKTorhIVOm9 sdFgMV8LGQBqCHySGlEpXvLR0M3kJAWvyIH8vq+O3O3ui4ATHVGvVzsn/bWWbtxZwG4b h5Klw7e40dY3lVsfsGrSVaiy+QiklVsZ1Zoo7yOxF98VCWkdruZkAdn3D8PtSMNld32T SZNg== X-Gm-Message-State: ABUngvfIY8PAe+8LDPFa4vLQAd4QjudVCPqWeW4PrBKA/+3B4sn8TbD/+g1J38QPDlnXN/T6 X-Received: by 10.195.9.199 with SMTP id du7mr1708975wjd.40.1477560863226; Thu, 27 Oct 2016 02:34:23 -0700 (PDT) Received: from localhost.localdomain ([90.63.244.31]) by smtp.gmail.com with ESMTPSA id im3sm7412558wjb.13.2016.10.27.02.34.22 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 27 Oct 2016 02:34:22 -0700 (PDT) From: Alexandre Bailon To: khilman@baylibre.com, robh+dt@kernel.org, b-liu@ti.com Subject: [PATCH v3 3/4] usb: musb: da8xx: Add DT support for the DA8xx driver Date: Thu, 27 Oct 2016 11:34:06 +0200 Message-Id: <1477560847-8929-4-git-send-email-abailon@baylibre.com> X-Mailer: git-send-email 2.7.3 In-Reply-To: <1477560847-8929-1-git-send-email-abailon@baylibre.com> References: <1477560847-8929-1-git-send-email-abailon@baylibre.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20161027_035310_341322_2012E3F1 X-CRM114-Status: GOOD ( 14.92 ) X-Spam-Score: -1.9 (-) X-Spam-Report: SpamAssassin version 3.4.0 on bombadil.infradead.org summary: Content analysis details: (-1.9 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [2a00:1450:400c:c09:0:0:0:234 listed in] [list.dnswl.org] 0.7 SPF_SOFTFAIL SPF: sender does not match SPF record (softfail) -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: devicetree@vger.kernel.org, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, Petr Kulhavy , Alexandre Bailon , linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patch=linaro.org@lists.infradead.org From: Petr Kulhavy This adds DT support for TI DA8xx/OMAP-L1x/AM17xx/AM18xx MUSB driver Signed-off-by: Petr Kulhavy Signed-off-by: Alexandre Bailon Tested-by: David Lechner --- drivers/usb/musb/da8xx.c | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) -- 2.7.3 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel diff --git a/drivers/usb/musb/da8xx.c b/drivers/usb/musb/da8xx.c index 210b7e4..51ae3b6 100644 --- a/drivers/usb/musb/da8xx.c +++ b/drivers/usb/musb/da8xx.c @@ -6,6 +6,9 @@ * Based on the DaVinci "glue layer" code. * Copyright (C) 2005-2006 by Texas Instruments * + * DT support + * Copyright (c) 2016 Petr Kulhavy + * * This file is part of the Inventra Controller Driver for Linux. * * The Inventra Controller Driver for Linux is free software; you @@ -433,6 +436,21 @@ static int da8xx_musb_exit(struct musb *musb) return 0; } +static inline u8 get_vbus_power(struct device *dev) +{ + struct regulator *vbus_supply; + int current_uA; + + vbus_supply = regulator_get_optional(dev, "vbus"); + if (IS_ERR(vbus_supply)) + return 255; + current_uA = regulator_get_current_limit(vbus_supply); + regulator_put(vbus_supply); + if (current_uA <= 0 || current_uA > 510000) + return 255; + return current_uA / 1000 / 2; +} + static const struct musb_platform_ops da8xx_ops = { .quirks = MUSB_DMA_CPPI | MUSB_INDEXED_EP, .init = da8xx_musb_init, @@ -458,6 +476,12 @@ static const struct platform_device_info da8xx_dev_info = { .dma_mask = DMA_BIT_MASK(32), }; +static const struct musb_hdrc_config da8xx_config = { + .ram_bits = 10, + .num_eps = 5, + .multipoint = 1, +}; + static int da8xx_probe(struct platform_device *pdev) { struct resource musb_resources[2]; @@ -465,6 +489,7 @@ static int da8xx_probe(struct platform_device *pdev) struct da8xx_glue *glue; struct platform_device_info pinfo; struct clk *clk; + struct device_node *np = pdev->dev.of_node; int ret; glue = devm_kzalloc(&pdev->dev, sizeof(*glue), GFP_KERNEL); @@ -486,6 +511,16 @@ static int da8xx_probe(struct platform_device *pdev) glue->dev = &pdev->dev; glue->clk = clk; + if (IS_ENABLED(CONFIG_OF) && np) { + pdata = devm_kzalloc(&pdev->dev, sizeof(*pdata), GFP_KERNEL); + if (!pdata) + return -ENOMEM; + + pdata->config = &da8xx_config; + pdata->mode = musb_get_mode(&pdev->dev); + pdata->power = get_vbus_power(&pdev->dev); + } + pdata->platform_ops = &da8xx_ops; glue->usb_phy = usb_phy_generic_register(); @@ -536,11 +571,22 @@ static int da8xx_remove(struct platform_device *pdev) return 0; } +#ifdef CONFIG_OF +static const struct of_device_id da8xx_id_table[] = { + { + .compatible = "ti,da830-musb", + }, + {}, +}; +MODULE_DEVICE_TABLE(of, da8xx_id_table); +#endif + static struct platform_driver da8xx_driver = { .probe = da8xx_probe, .remove = da8xx_remove, .driver = { .name = "musb-da8xx", + .of_match_table = of_match_ptr(da8xx_id_table), }, };