From patchwork Tue Feb 25 17:53:03 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Stultz X-Patchwork-Id: 183873 Delivered-To: patches@linaro.org Received: by 2002:a92:1f12:0:0:0:0:0 with SMTP id i18csp2041605ile; Tue, 25 Feb 2020 09:54:05 -0800 (PST) X-Received: by 2002:a63:ed14:: with SMTP id d20mr58324018pgi.267.1582653245063; Tue, 25 Feb 2020 09:54:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1582653245; cv=none; d=google.com; s=arc-20160816; b=Um7zbKBP2r1DjGL6xsEW772ow2ZY9z+rv/XGKcJkA8I6qpJiDGWgKXtPn+qnV2KLNR 7U2OidAk43dhjFjnhxGFGASdBXpC2Y9P9Wytfu83PAdVWple5nyt1K3MjYxU8W9WktP9 cwZdqFtcqHSnBf0ZBFVwUEzyIZRmf4pdOidfv6aqNljFo+DWOSLM37C48aSdwz3rqzFJ zkoLc9nGGiwXZ8OSwzBH5Dt6PyuF5oWRpf6RzKBicCpwboW9+ZzOcSfP4V1I+nlz+R/o 79XHQCKQDhLTgxJCIbJEET83Usm4TgPbOfA1qiwpPeJ6ip0evaeBFE2ciCacYrcLf59Q NpCQ== 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=CpmywWyp6aExqYXO2nsoyNHZG6T/FiFmGDy6H1VmZYo=; b=yeetVMMPRlWSDaoFGX0k2pQ5n3PWn5u0qvgvsRzjO133JwzGHq8kUwZNhYhVhOt2A3 z0FqbuwWSWcOWjI6Qpq8UZhRW9Q7GCCBZawd/2EHIFj4BZtmcKL/Zxj4IeN8tS6mCxIc kENhE269lX57h4F1Ok1xcEQ/V/cfhxQmCrIfQ5fxoxkfNAteFTHOFQOlccU2ucRaKN69 NIJSROOYFxrHI8/cSY9oEiwCZWqksOm5WST+diZ9azmmXbb4RNIGRQSNi81wx2SxduJH sH4M4ZqKSIB+blnRn0AvzvUsAJkOtAAqZn1DlC0sJbUbSNqgcdySdV/Pt1/u51ZtNP4P 6YjQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ASuZESBs; 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 l129sor2277544pgl.67.2020.02.25.09.54.04 for (Google Transport Security); Tue, 25 Feb 2020 09:54:05 -0800 (PST) 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=ASuZESBs; 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=CpmywWyp6aExqYXO2nsoyNHZG6T/FiFmGDy6H1VmZYo=; b=ASuZESBsToschmHjBbgEc3jfR3shNL1vpcT7qJeCfsurb2NjTft4SutlPuhnOOJwpv w0YXal/pHV67j2wlcIfNz8ABT7AzFinBpm71SU6eHSOmUaw2rOn4Oele9Nx4ekt5GQ+P VwPPurcKjc99Z1vChtyxA5w2NbZkayU8asApDjoLX416t0GGg3AR6Teub6jG0AjwsXxP lsGccjBqajtNtNTqwyuVBO0mLXkidobN/csXNNDzhYC9LxjFana27NKfoAGwFKPzOsb0 66/ycCvpXGQ26/Ou5JNA41pfnmjA3kQnBbJ/QqDVvP8xBOPFiUS/jF5tm3IL6bD0RgPc G1Ig== 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=CpmywWyp6aExqYXO2nsoyNHZG6T/FiFmGDy6H1VmZYo=; b=s8uhhyPTjb7QfwiSzJGscwVzEsXkqo0mSjrahNz2b9vL2RknIgpUb67zt7t3O/NM0B bsJjDU71tMHT/x6moxekM0PJnfRuQi9e0ls3JcPMhB7Mf7x7g5rG6efFd6cQIlr0Bhn3 sKKO18gztCS3xuUXR9+eV0hxiXh+kr5fkuykZxtECLgPeWdKbDmAlZihKaaoiYn+b1PL I1GtSIPfJHk2FJnSaDMA4AtukapgdqsXT5cb4mALTmwXD+NC77HD5FA1AKLvSje44ptb BMVmMuOGjKRPl4mmOFstgEbUOz1Ykxu+9KUFn2CfcA1yma6jxbOIOpj/FED1s2yJMqXU W77w== X-Gm-Message-State: APjAAAU1VARK+rpgmAYRJl/BVM/tY96Trfnp2/p8aGESibmafme6KTtL yAbfv+BqFcKo7wA2ml57YwaInST3 X-Google-Smtp-Source: APXvYqwpHKqD+EUq28KEJF7IXzIP1hpR7FRD9XctnUIftrS+HfPh4WaCyCgkjKFUI/d1YZOsWn0oKA== X-Received: by 2002:a63:7e1a:: with SMTP id z26mr5483897pgc.226.1582653244705; Tue, 25 Feb 2020 09:54:04 -0800 (PST) Return-Path: Received: from localhost.localdomain ([2601:1c2:680:1319:692:26ff:feda:3a81]) by smtp.gmail.com with ESMTPSA id v8sm18013291pgt.52.2020.02.25.09.53.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 25 Feb 2020 09:54:04 -0800 (PST) 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 , Guillaume Gardet , Jack Pham , linux-usb@vger.kernel.org, devicetree@vger.kernel.org Subject: [PATCH v8 5/6] usb: dwc3: Rework clock initialization to be more flexible Date: Tue, 25 Feb 2020 17:53:03 +0000 Message-Id: <20200225175304.36406-6-john.stultz@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200225175304.36406-1-john.stultz@linaro.org> References: <20200225175304.36406-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, or some may have more. Usually this was handled by using the dwc3-of-simple glue driver, but that resulted in a proliferation of bindings for for every variant, when the only difference was the clocks and resets lists. 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 recommended by Rob Herring as an alternative to creating multiple bindings for each variant of hardware. 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: Guillaume Gardet 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. v6: Re-introduce this patch, on Rob's suggestion --- 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 1d85c42b9c67..ba21af5c1204 100644 --- a/drivers/usb/dwc3/core.c +++ b/drivers/usb/dwc3/core.c @@ -289,12 +289,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 @@ -1441,11 +1435,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); @@ -1481,17 +1470,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);