From patchwork Thu Dec 12 01:42:30 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Stultz X-Patchwork-Id: 181377 Delivered-To: patches@linaro.org Received: by 2002:a92:3001:0:0:0:0:0 with SMTP id x1csp280401ile; Wed, 11 Dec 2019 17:42:42 -0800 (PST) X-Received: by 2002:a17:902:9a49:: with SMTP id x9mr6595149plv.331.1576114962000; Wed, 11 Dec 2019 17:42:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1576114961; cv=none; d=google.com; s=arc-20160816; b=gDztEpQGdWmf1D4dwcEmUEk4dfFUqkdXIBilSn1G6eRiyF73LqFg19pW2ChKFdPdXC /zOoUGlkaXz1+32sn2BNZ4lx4VKqrn94FiJP6c6slNYaZtzsqZ6K7bN0TPamLjTX+xiR 6SBYw8i6RzaCSP85UCDUAlARx4OXEgj8rMQcZcMegDcS2fvbI9c8O4yhv4zYSDXkQC++ IAw8OAvo9UuKTW5b7Qb4IjX78tZUspJf3Rva0q+ISUWro6V7UB4Zh6wj7H2szKFUVU0y ljw6ZUfqA0CR5cO2+1UVwR+ceGDc+q2pc6xD3JLYTeZ2Xg2JW66QTqmSgTBYokvykBdI TlcA== 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=G6kjJoovlC6cVfetXCubnmxNfzySZyzH70fmpOskqm8=; b=ajTRqGqYXdW+uM88N+PqTCNdvrikDJQQ/dLhoG9s68t+JPiCww++FbFMQOAoaTF+Cp 5oVCuP++N2P7r0pe9xYOcsG0l0fZZf7km6oYEAEufF3f8QxqaYXuwNZLUSf9GHbcuJrV D0KJXMNpcm/uWfMd89Z5rvnDn3zvq4hkahD2EsCBTBp3tLss5Gq3qEMaCcfHUBzhPcXS rP6QkBnvOusFmN366Ydv3H1OPEhgryuuo9z5omVVXpeeXOs0li9gwRHs2mzp3tHCwQ1z GsMYhKAVszs4TqLNn2cUrEQJcQs74bEC33rUEOtMkrUJG7Cejb2Zlq8xiN5NtJtu/fhb oS8w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=cGOZzqU1; 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 e190sor4968288pfe.32.2019.12.11.17.42.41 for (Google Transport Security); Wed, 11 Dec 2019 17:42:41 -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=cGOZzqU1; 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=G6kjJoovlC6cVfetXCubnmxNfzySZyzH70fmpOskqm8=; b=cGOZzqU13JOBPam+xdKigkTIGiAjbtkPvBYtjMIcRGUuLi4JiP7MUinvcn6DCHl3if FfTvBb4dk8U5AMVmF2CjA3dX++wBfx3pTTGhYpwAXjF+gVP7q2lyOJ71aGuUEDGgLDk+ TMnP3JbWjTdAvowKhz6F66lifrsJQu8cJUerpX+PE5lpkYRjgLc7ZYnOaB5FZFDeXZLZ 4XTD82pAK9BsC4PJHfrpswrG46E7SuRpdj1/clKJtXJ/dD0FqdjFwSmynLis5GtK1lV7 /4QvRxBrdkNP0ceSSZ49Ot9qJNQWbR+IUoA7OE66lecnIgheFt5rQQ4O7VaQtW+J/H3+ w9Gw== 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=G6kjJoovlC6cVfetXCubnmxNfzySZyzH70fmpOskqm8=; b=Iw82u+SE1ljWIzONknlKib5FQFEODRHUX1SxqmyApVZoYUAsxDwlw5KbWnRW0MWsBr YZcUyhu/R7lWghotUlibPGR/Yeu4MAi0O1tlFEPx8NnORznPjRollQvmKlS9gULEIiyN kGAzPi2MxZtHSgo+aKriWf3HoUEjNA9hxInPNmYrKERYmi3Grm7dtfpZmJNKm076IqTG sTrCN74tqQ6ICkEnXEbk24Zn/YGsEqCpACnCrR4FR3NBxVVjfsQSWwPbLSOcx19BCtgA kzLHvcGnbdEzFjJCtncFGXTJgcriYTXv3OmoVkTOn+8FfA87Ybmr04FyOZ2CDn4NW0EV Xhdw== X-Gm-Message-State: APjAAAXImB4psE60RZ8oP844/Mb0NFLP62N6lBh/kBrjSviCUIvdViZZ GKDY1UCbU+m/PuCA+MQJDdrJCQ+C X-Google-Smtp-Source: APXvYqwpqM70vNZbKae/RwdZ2CYgbgIkvtbmpvMV4ONBua+4aE8gJ9REa97neloI95Wm/o50zRSkzw== X-Received: by 2002:a62:1a97:: with SMTP id a145mr7398556pfa.244.1576114961674; Wed, 11 Dec 2019 17:42:41 -0800 (PST) Return-Path: Received: from localhost.localdomain ([2601:1c2:680:1319:692:26ff:feda:3a81]) by smtp.gmail.com with ESMTPSA id p16sm4217996pgi.50.2019.12.11.17.42.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Dec 2019 17:42:41 -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 v7 5/8] usb: dwc3: Rework clock initialization to be more flexible Date: Thu, 12 Dec 2019 01:42:30 +0000 Message-Id: <20191212014233.32799-6-john.stultz@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191212014233.32799-1-john.stultz@linaro.org> References: <20191212014233.32799-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 f561c6c9e8a9..c6316d4b7593 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 @@ -1438,11 +1432,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); @@ -1478,17 +1467,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);