From patchwork Wed Oct 16 03:33:34 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Stultz X-Patchwork-Id: 176413 Delivered-To: patches@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp6783684ill; Tue, 15 Oct 2019 20:33:51 -0700 (PDT) X-Received: by 2002:a65:67c8:: with SMTP id b8mr29676810pgs.121.1571196831508; Tue, 15 Oct 2019 20:33:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571196831; cv=none; d=google.com; s=arc-20160816; b=U2LGcyzJdnFExAc+MMmkn5VgI94FLs/wOBnZuC6WYR7TqhdcZlDhhL6qEU5dEXNf6L /6Hl6vbn/JZpI8KrbUa0LLxHmuAsbbK8lhfUVXNRiYDV2jCo7pS1ibFHu2KlMLwYupRn xP8DPPaIWtTUq/f7aGGdSFvo6+sswPPSco8QAYQE+bfHsZNHmzqox0c34xGFk+EMuY2m h2WiCzHpgOLJRnjDuwOYjPiLXxiGofNxt/5NUeHAGt6uWDqJmo5bM47mGG8RGZtcdSLr qYvgDaDgb0HhqaSl31erCtTAjjME/gqz66onsNjlBZOtCD46ShqXxj9lmaUdJicu9Jh/ HC7w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=mmGMZQlCR6mgA59oWS1f2Nk927cLgLJYDtngM3i0DmQ=; b=gQDJ5PVPf2PAV78qtKMjvVJA8vzDJ2aiShgooct8uvFKkCp93+CJYwMFfRVqeGXStS Ys43wz5dKrjC9W8S3ag8Ai5sdKlq/8pw2eYnrAp7RpeUCGWnUykL7IbBhACBAuyTtfNq 3DAmDiskxfXbDtW+LKvFjgFyejLUy8G+fklr8UCc62kga1seAmjFKyLiFa9DoMwLvktO 3vDJORtvUO35DhduQSUPrHupnCNGsUnifhx7VLbraWSaZrUzz022QKoCrcGnH/xPcSrK aZuIlwenCCoUnDk7e1V2VDW5MsK7PSdrKLO7ApjHT3FAHEIFQKSTMB8p4y7zzr1EHika qsFQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="uLkbH/AL"; spf=pass (google.com: domain of john.stultz@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=john.stultz@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id i12sor25889978pfk.45.2019.10.15.20.33.51 for (Google Transport Security); Tue, 15 Oct 2019 20:33:51 -0700 (PDT) Received-SPF: pass (google.com: domain of john.stultz@linaro.org designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="uLkbH/AL"; spf=pass (google.com: domain of john.stultz@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=john.stultz@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=mmGMZQlCR6mgA59oWS1f2Nk927cLgLJYDtngM3i0DmQ=; b=uLkbH/AL8pOg7wAkq783Kv7Wli+S4S1fkwXvQK1hsdZz8RMDlTmkhaDVpBDw/mkoO4 zBTWunDgn6kC1ewqFmgahk4sa4DL54pMRwCKWKiTye44tvTXsqTp6tTiQkBUQj9ZE7WX GFlecPGJ8qg9BS/QnlLtz2ltiSGv/DD9h60Nk3yaik8zidbbaF1cr9PvCiBb3MgexH43 QqgoYOBBbb1zOJvedENxG6asKQFB/TzSZAY/z04OpFQSmYX6mevmQD1DMHMmEQbMZkNW uW8J/Od3UKmRiRZSjx5lUM8HYObGLRFjd7aVMByq0wV3Rc+Qi/ZvxrF44OpKP2tjyR0R 0vhw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=mmGMZQlCR6mgA59oWS1f2Nk927cLgLJYDtngM3i0DmQ=; b=JsfE48STNSmq1TumDSnay0xgOo97mX2VkhPlF2zxRBwr+JPH8CVNaJ5vw1x3EbM17b E01tSAHZU4amQQncFdpg/t7X4VoO3A+fnbUh6c52fHdDaKxrN9MYOJH0O+4IX369ieWP okNGd5o5FRboKllwFEAH+kY3g7A3+44PvXP94wdITeQ3rlH2d9XuvD1MZhnE34g5Bf1o 1I3rk8917CXiWnC3UsxB6BW4z0d8ZzCtw/nPvb1oZ9dUEw8iJTagg6H14Kdi41B98hTN 3kGMPRQpMM9NnNcGr/zI4m2F79ZbDHX2V/Fi/C7lc0ox4Ht0u0BdxifEf0cw0d7PiUnB v7Gg== X-Gm-Message-State: APjAAAWIJoD+cEMCfGyYYKGM8D3Q8B9dXn1Tdp++ZgX4MAcTVFFZCsKi yAm5v3sPY1UdegFa9DZCcMD2eyRr X-Google-Smtp-Source: APXvYqws+YMGIIyJ9Z71j/JJfgVn5iU2tJXSMhO0gdaPFucclq53zCDhmjLlxCTNhG2oSTVllo97hA== X-Received: by 2002:a62:e206:: with SMTP id a6mr42231705pfi.64.1571196830986; Tue, 15 Oct 2019 20:33:50 -0700 (PDT) Return-Path: Received: from localhost.localdomain ([2601:1c2:680:1319:692:26ff:feda:3a81]) by smtp.gmail.com with ESMTPSA id l23sm748356pjy.12.2019.10.15.20.33.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 15 Oct 2019 20:33:50 -0700 (PDT) From: John Stultz To: lkml Cc: John Stultz , Greg Kroah-Hartman , Rob Herring , Mark Rutland , ShuFan Lee , Heikki Krogerus , Suzuki K Poulose , Chunfeng Yun , Yu Chen , Felipe Balbi , Hans de Goede , Andy Shevchenko , Jun Li , Valentin Schneider , Jack Pham , linux-usb@vger.kernel.org, devicetree@vger.kernel.org Subject: [RFC][PATCH v3 05/11] usb: dwc3: Rework clock initialization to be more flexible Date: Wed, 16 Oct 2019 03:33:34 +0000 Message-Id: <20191016033340.1288-6-john.stultz@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191016033340.1288-1-john.stultz@linaro.org> References: <20191016033340.1288-1-john.stultz@linaro.org> The dwc3 core binding specifies three clocks: ref, bus_early, and suspend which are all controlled in the driver together. However some variants of the hardware my not have all three clks So this patch reworks the reading of the clks from the dts to use devm_clk_bulk_get_all() will will fetch all the clocks specified in the dts together. This patch was reccomended by Rob Herring as an alternative to creating multiple bindings for each variant of hardware when the only unique bits were clocks and resets. Cc: Greg Kroah-Hartman Cc: Rob Herring Cc: Mark Rutland CC: ShuFan Lee Cc: Heikki Krogerus Cc: Suzuki K Poulose Cc: Chunfeng Yun Cc: Yu Chen Cc: Felipe Balbi Cc: Hans de Goede Cc: Andy Shevchenko Cc: Jun Li Cc: Valentin Schneider Cc: Jack Pham Cc: linux-usb@vger.kernel.org Cc: devicetree@vger.kernel.org Suggested-by: Rob Herring Signed-off-by: John Stultz --- v3: Rework dwc3 core rather then adding another dwc-of-simple binding. --- drivers/usb/dwc3/core.c | 20 +++++--------------- 1 file changed, 5 insertions(+), 15 deletions(-) -- 2.17.1 diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c index a039e35ec7ad..4d4f1836b62c 100644 --- a/drivers/usb/dwc3/core.c +++ b/drivers/usb/dwc3/core.c @@ -305,12 +305,6 @@ static int dwc3_core_soft_reset(struct dwc3 *dwc) return 0; } -static const struct clk_bulk_data dwc3_core_clks[] = { - { .id = "ref" }, - { .id = "bus_early" }, - { .id = "suspend" }, -}; - /* * dwc3_frame_length_adjustment - Adjusts frame length if required * @dwc3: Pointer to our controller context structure @@ -1418,11 +1412,6 @@ static int dwc3_probe(struct platform_device *pdev) if (!dwc) return -ENOMEM; - dwc->clks = devm_kmemdup(dev, dwc3_core_clks, sizeof(dwc3_core_clks), - GFP_KERNEL); - if (!dwc->clks) - return -ENOMEM; - dwc->dev = dev; res = platform_get_resource(pdev, IORESOURCE_MEM, 0); @@ -1458,17 +1447,18 @@ static int dwc3_probe(struct platform_device *pdev) return PTR_ERR(dwc->reset); if (dev->of_node) { - dwc->num_clks = ARRAY_SIZE(dwc3_core_clks); - - ret = devm_clk_bulk_get(dev, dwc->num_clks, dwc->clks); + ret = devm_clk_bulk_get_all(dev, &dwc->clks); if (ret == -EPROBE_DEFER) return ret; /* * Clocks are optional, but new DT platforms should support all * clocks as required by the DT-binding. */ - if (ret) + if (ret < 0) dwc->num_clks = 0; + else + dwc->num_clks = ret; + } ret = reset_control_deassert(dwc->reset);