From patchwork Wed Nov 16 10:52:25 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexandre Bailon X-Patchwork-Id: 82480 Delivered-To: patch@linaro.org Received: by 10.140.97.165 with SMTP id m34csp82820qge; Wed, 16 Nov 2016 02:52:51 -0800 (PST) X-Received: by 10.99.125.77 with SMTP id m13mr6977834pgn.58.1479293571914; Wed, 16 Nov 2016 02:52:51 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n22si31304160pfi.246.2016.11.16.02.52.51; Wed, 16 Nov 2016 02:52:51 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of devicetree-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 devicetree-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=devicetree-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S938789AbcKPKwn (ORCPT + 7 others); Wed, 16 Nov 2016 05:52:43 -0500 Received: from mail-wm0-f48.google.com ([74.125.82.48]:35178 "EHLO mail-wm0-f48.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755327AbcKPKwi (ORCPT ); Wed, 16 Nov 2016 05:52:38 -0500 Received: by mail-wm0-f48.google.com with SMTP id a197so230889775wmd.0 for ; Wed, 16 Nov 2016 02:52:38 -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=0APbmsKA3i48TdX5m9L3d0MFyCuWKXXz/OopgV1r+G8=; b=hzaGjyFWDO1dE6LmvIWBfjHGIBNX9Lg+MnS+pcjMEAe67x4dOgmtmOrdjOh0brR0+V nw9TK8kxqVTpU/FgQbIhGKA+trJr0cqi9U5pdriGljl3en62IcYs+Asx12ZjYxkMMpIq eCQIVqvrGoH84hN1aPWX3DIVqQVh/dxBaGrqbk+T01fajFKTwdfb//SEdeiqeUXDZBn6 9ZtVDyFvm7+92Un9d9lEzlyzCkNsnfrfbFF3LkyfXc5Nd16fjeA0lvehTFNf2Tdkh4GW flSFuzespeS9exgaf+5UswmFADaGPmMyPsUCgQClpBrqtfB/j+CwDMkIePjpTxx3qQvc rqmg== 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=0APbmsKA3i48TdX5m9L3d0MFyCuWKXXz/OopgV1r+G8=; b=YCU1bSlUg7+9K/L54kLLSUGSxAt2tCNVL8H4usfCsekOK58+/tBW7HrK1V3JWy0zPM fYxthJAFEjnFOc5oyot2QT1TAsDDzabV4cgMpqE7OM0/FZetjpV3p/kViAv/MFs36UJj yogUzLaMwt2fe685+3doIcA42hJbAf6Ayvo5QI+hUNAfQ59Dt9iHfGeT2BkzLb4/lROX mxnJrf1i0f3dgD4KB7LBnOx4ttvKsJWzvRotvwEdrb1RboyomQ62NrEuMZfN2MNQHyNj GXxA+R+V4DxPEFcbepGJaEGwQCIEOnTBYjXNvLyLOZb8rHLzJW3FBHGCM/YWd1ulgyUZ reDw== X-Gm-Message-State: ABUngveP97ooY/QCgEaMOrPisTvfxdQkanX17svK9d+DudtQ6jdD5mAm5SujDTi4nz24cFG4 X-Received: by 10.28.126.11 with SMTP id z11mr9881415wmc.87.1479293557423; Wed, 16 Nov 2016 02:52:37 -0800 (PST) Received: from localhost.localdomain ([90.63.244.31]) by smtp.gmail.com with ESMTPSA id m9sm9444479wma.0.2016.11.16.02.52.36 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 16 Nov 2016 02:52:37 -0800 (PST) From: Alexandre Bailon To: khilman@baylibre.com, robh+dt@kernel.org, b-liu@ti.com Cc: linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, nsekhar@ti.com, Petr Kulhavy , Alexandre Bailon Subject: [PATCH v5 3/3] usb: musb: da8xx: Add DT support for the DA8xx driver Date: Wed, 16 Nov 2016 11:52:25 +0100 Message-Id: <1479293545-7516-4-git-send-email-abailon@baylibre.com> X-Mailer: git-send-email 2.7.3 In-Reply-To: <1479293545-7516-1-git-send-email-abailon@baylibre.com> References: <1479293545-7516-1-git-send-email-abailon@baylibre.com> Sender: devicetree-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.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 -- To unsubscribe from this list: send the line "unsubscribe devicetree" 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/da8xx.c b/drivers/usb/musb/da8xx.c index 2440f88..f205a03 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); @@ -487,6 +512,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(); @@ -537,11 +572,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), }, };