From patchwork Wed Mar 11 17:21:08 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Stultz X-Patchwork-Id: 184408 Delivered-To: patches@linaro.org Received: by 2002:a92:1f12:0:0:0:0:0 with SMTP id i18csp869943ile; Wed, 11 Mar 2020 10:21:27 -0700 (PDT) X-Received: by 2002:a17:902:bd43:: with SMTP id b3mr3758044plx.230.1583947286887; Wed, 11 Mar 2020 10:21:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1583947286; cv=none; d=google.com; s=arc-20160816; b=mOAmun9dps+qUhqsd4K8FSGk0asPvl2sCL9BX2X5pDyfxuuPC53TAlQPAOPIpUfgjY bxifBO4bdK/bEKuqXkU+v3CO6KMsl7aY7qukQ+m3I//aFfCdYULJsLE7DzRnhwkVFrxR +FI7hR5225J20f2g6xEyhqgQaiod1N73yIX5je7qXvgRLMK/x35UoDeEQkOfJ1FZCZ8p RdE6CrxFHqjvSsQ6FVaGtB3HZi0F/UxaZ9Dp68Ql6HJgtnu+jZcaetcZ0w/ahiSv8Tpi Rqea3yICDXd9o66ETw0WGXM1pSrB/YTOUg0HlntjUk5ra1pfV8d4zz6xIS27oCltg7QT TmNQ== 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=d0VmCpn0hie8Rgz5aK5B5dbk1bxLmDFjqdtVuUpCRl5GwM5nQKatxUR6aJTaDHaSQv iRs/jT/njVCeSiLF/LoChWllOpz5L5cQ/wI/PikNtJ4e9nj+LzGyuoXAVvAMdYPaFkhK ZQZWmqooDNjMfsIA9SmjZXRhlTAIZnzxkGcxZOaE5Jri0S/tBwDTn6+s6jVKWCC5E8cG KPJ0yEqPkMurIpyHGqBL/CjwvIucnYbS5xQcf9PkbVvqisiMD5S3p/8qbsLxCRmrqk4q UgE0YCQH/8RUQHsb3vYoprRPvc+bmkHXUdYJjcnFMOverD5jA4qQC1mJw4fuQ5izzy0z JNtQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=znQttMIz; 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 x7sor2845656pfb.40.2020.03.11.10.21.26 for (Google Transport Security); Wed, 11 Mar 2020 10:21:26 -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=znQttMIz; 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=znQttMIzLhlauM/O9plxveT/fNrNaEDEifiJ5H0Am0jZ8/lTIHyXlHg0yknkHJiADu 9kR8VtlZGdEdod+7vB5Oxm0Z8GKCvxdCT9LqcNp7XKTJYI+DkdgngFyvvW9OLgEJQx8Q IK9rG8mgyRvlrAM53TgYZxF8UCtZzrdzrfR2hy2tOzQ/s5RF0TJyZHYO0s19r1C5tav4 QwMI+KfyoMaztfRLMF4mzN/jvm1SxRcxJQBY2ap3p48leqUmNYqOMlYyOwu4PiOvcMeW YIm2SeipEb3FeP/t33f8fg9qDGH/t/Ms5OMgia3XPUBPIugzSIvdpzidGf5zAyPaZsXV Xhlw== 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=lOzNFza3UG0Te/viS+Ntrxv0gD2VcfCJBw5Fu0o54FDdqVRt4mXFYMAKNZRoCQcTfH Pb93rgZFXb5dPxWlKoyzhwBMszvBzLotnz238KtxLHM/tyY7jJJL8vU4myBvmJqh/qm7 Qyqq7SLUN+I0iD2Uvu9LaV+ECWOGDwmM49upsrKkJQb0wCHpNtudTM3U0CEtahNpFs0E obV4m6+Q630xKpYIvGqb55okq6IJjLqhUb5rurYtf8dX+WJZth+fHG+SGVrm5VN2I5SS gH3phDNGlgFNoHmJrFRdkyuIn6xJ51qLu6YQblLlXqTlYeAFq4Qeo/fQrR/3YbFmDwbI oTVA== X-Gm-Message-State: ANhLgQ1R8yjxus1dMu3eVEL3f7tyPoYxbgbdCUAKR7oTH+RYiRo5rmlM RcPl83+9Pmsgf28hW61Nk0DL75JX X-Google-Smtp-Source: ADFU+vuRBKnrKmXU0JZNUQ5/lnkIEqkKhvu5m1kBFMbNPnH6c1//Ozyk0auxbkjc1uDgkvgSp6FZyw== X-Received: by 2002:a17:902:a58a:: with SMTP id az10mr4002764plb.20.1583947286400; Wed, 11 Mar 2020 10:21:26 -0700 (PDT) Return-Path: Received: from localhost.localdomain ([2601:1c2:680:1319:692:26ff:feda:3a81]) by smtp.gmail.com with ESMTPSA id b24sm14914053pfi.52.2020.03.11.10.21.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Mar 2020 10:21:25 -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 , Guillaume Gardet , Jack Pham , linux-usb@vger.kernel.org, devicetree@vger.kernel.org Subject: [RESEND][PATCH v8 5/6] usb: dwc3: Rework clock initialization to be more flexible Date: Wed, 11 Mar 2020 17:21:08 +0000 Message-Id: <20200311172109.45134-6-john.stultz@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200311172109.45134-1-john.stultz@linaro.org> References: <20200311172109.45134-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);