From patchwork Mon Oct 28 21:59:15 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Stultz X-Patchwork-Id: 177973 Delivered-To: patches@linaro.org Received: by 2002:a92:409a:0:0:0:0:0 with SMTP id d26csp3978356ill; Mon, 28 Oct 2019 14:59:30 -0700 (PDT) X-Received: by 2002:a65:554e:: with SMTP id t14mr21059775pgr.370.1572299969886; Mon, 28 Oct 2019 14:59:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1572299969; cv=none; d=google.com; s=arc-20160816; b=Fes8OnSF4vz37IAkmkdVOn5GX34yGs56fmlMiV2cQSQv/SFOMWxTvAyicjYwmMgJ+k d8/82sidrRSZ0P3C/i3K2O5yhL2ZGy12ay4vt6fBeckv51frlkKrHoNeCm4Lt9ErrGNl YvkgQHMovGGW+JXiI2j6HKaOMX5G+Bnx4XNASxjIiB7+OHeJ66x9uWLqIdAUxbABPVwc nHfAP8EeO53oMZjl+ymJs91iIi0GUcauFZca6ZK1UumoN0zaDU6yzz+pVFs/5+5uIWPt M94LHE/Ap4sL2ipCL0CafQ2tbZR6vql2tXrhDziUs3slyJm0+5/i7AyFrcqUHjSAsPzk J8gQ== 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=Sf5eKNCSIBpNdFo6pBKVICUJYVHElXUrV/RD8eO146c=; b=dUPKJmVU90UxzIWWkyHEj2HClLjsGPMuhts0clpcLlScEP+zqadeO4r9UJ3znH2Lzv gOc6ESTTdpWx8kgA6NBuFO3EiGKX0h6/BagM+WJxvtmw/aBr0L85QD9Ag55/2FI5TXmz FFHcasLWdliGZLH2JDNclsD9yVaT2g1UcVMaVCcAI+73UIHGSnwFlkXtp2pkvCPR6oFj OIfX/Zg7JAf9/7ztbgFdCPyPApSwGvFXpAUs3ff/UED0Umn4/NxIBMuX688u/51QjdXL JF1V9fW2l5Q/oKBNnp1lDRgknu0vKO2IbuDoc/BHXjbBgqRfrrwtVnZG/jfSA2n/OwSY LWmA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=lMEc5oJe; 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 r75sor13113432pfr.42.2019.10.28.14.59.29 for (Google Transport Security); Mon, 28 Oct 2019 14:59:29 -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=lMEc5oJe; 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=Sf5eKNCSIBpNdFo6pBKVICUJYVHElXUrV/RD8eO146c=; b=lMEc5oJeuYWUcVxXpphSMAIRavQ29nAcI5d2oKIF5KsDKcFZnIO8Rcwx8rlC2A8Zf/ CF5EjelirIgQYnWaDQFgrG7r+Oh+liDGWYseTgIuogkTucMwvA9ZsP/LheVHE/zFsbcS MpnCEZ0dr7M6+w8sAnEgZXE/TPEx6kssrdjMLA9cAPy4zvF/Q7Z084sRASR5cfwrE156 Dq2WaWlxclZJyvBepM8NvQKGSkQV4UrmPKJjFOsfHATm/IoZihLaQwjrWyKTuHXgICUq DI5KCli3WtY+muIL2MpvQmZSAfF1FcdKcY0GT06yRWMhwtT4FmfKoizuKQyE3WTTIj8a t4yw== 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=Sf5eKNCSIBpNdFo6pBKVICUJYVHElXUrV/RD8eO146c=; b=TOoPltBlOdJ40vwdhhO7zIgXap51OTP33N0V6zX75TQnmjK9Rl9c2Dgxq6t5sqeaRg vilQ0bldmeFazQZwTcoUfPQLmmBXBwJKCV2XXca3SfiKkxW1WBfOoA+1XpLuKUOa/kqw FsQuRinHOnj/BfPLX/WD6ARsuofVgB8zxoGBiNNXKts1oZ9rcY3f18uExjtbFOLo5Ff8 NB9lFtxf8ObkMARD8Q8K1fEtGUQa7yEGxvrnBtwZUslAyyDpsJM6PCqHzzOzEEie3HQg R5JS7zxhRHKd8HIYUcMHcr/oO+Lb5RmX4sgURQMrtNoE+gKhNJS8+foFbX8fbMFCg7xk vQ1Q== X-Gm-Message-State: APjAAAWFRXjSQ/mifSoiq6zjU0+u9QiLxnPHY81HTBz4CCVGqC81mtwj fu+7G78qRb4SJkt57xApnzmqHLjd X-Google-Smtp-Source: APXvYqzV4dIrv4WayXRoBFG9n15lx1cNIer3M6DVGTDjqIPPzgjtWxEe21YsXYhKjId/Zy5mg6XkmQ== X-Received: by 2002:a62:5c07:: with SMTP id q7mr22638078pfb.159.1572299969484; Mon, 28 Oct 2019 14:59:29 -0700 (PDT) Return-Path: Received: from localhost.localdomain (c-67-170-172-113.hsd1.or.comcast.net. [67.170.172.113]) by smtp.gmail.com with ESMTPSA id f12sm10880612pfn.152.2019.10.28.14.59.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 28 Oct 2019 14:59:28 -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: [PATCH v4 5/9] usb: dwc3: Rework clock initialization to be more flexible Date: Mon, 28 Oct 2019 21:59:15 +0000 Message-Id: <20191028215919.83697-6-john.stultz@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191028215919.83697-1-john.stultz@linaro.org> References: <20191028215919.83697-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);