From patchwork Thu Nov 28 05:09:58 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Stultz X-Patchwork-Id: 180371 Delivered-To: patches@linaro.org Received: by 2002:a92:38d5:0:0:0:0:0 with SMTP id g82csp7062970ilf; Wed, 27 Nov 2019 21:10:10 -0800 (PST) X-Received: by 2002:a17:902:142:: with SMTP id 60mr8135925plb.38.1574917810108; Wed, 27 Nov 2019 21:10:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1574917810; cv=none; d=google.com; s=arc-20160816; b=VyHbmpgK9Z7aRNAdSKKpK4tvWVo/4ecr8637TQF6FjrlbLMwjF0nulZe3NgGBmty6b 9TdLULUh44GDSwlTJn1rc/ns9pXRX2fvHUkybV8/gJChBkFW7ofATki/O7OHtjidIilN YMSI6xo+LcHw5knAsMQbEaGymi55LLZrlcONk8STic30qTHDF1TAmW8pY+SAXU9VmxdH eTKLybmi7IgBTyWjv0YlKyx+ywdWOTrMLwPD+No4/aoZ1FhBR0PqLSEPzItUgRAp6CeA YFq6YVNGLkqS3/c1E7T1DMqlVbnplTdp8e7/gZdJwsDFuYkBq8VvvXDLkCU+RPlZJJCH xKrA== 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=BvSTajJ0/txDo3oQ9anR2MLYElhTmMiqKohTpjPUH4Y=; b=uojU0BJ+g/SFtLT4AgcoExP5bjnUf8MSr8kCRJf5vr9YVQzP+LMBK+x/n+k7WlBZ9t tI9cP1sVrpi8wWg8xf/kZ548HhD8Zf3pFxC/OCS/SxePNooOQ5HIGW4tqdGpRWlEAaBC JDSHWS6NwyKjcSFVy1/QBxrbQRmhURs27sVhtaxhB3IolV/hKtaNi987CG6jEo/MyW4W A6hCgO2zRObNIILzZozNoF/zgDIYK3ywVrxerUGcsC7FshAp5YlAdYcjYBS4F+l6rb4e wFIgUC6ipvYbZAGjnKjC/8U1eZzeOyIBl6J8oi7Jjm2ninTxgdbzRXs684UyFRdLt/h1 7IiQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=hEcBgdZf; 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 z13sor3711520pfa.42.2019.11.27.21.10.10 for (Google Transport Security); Wed, 27 Nov 2019 21:10:10 -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=hEcBgdZf; 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=BvSTajJ0/txDo3oQ9anR2MLYElhTmMiqKohTpjPUH4Y=; b=hEcBgdZf62B5VBmMPEBMROUIXTik/BmhILgVyVtvBnFUL+wplH8lMAizJ0o0t3/ng/ iKfkb0yh4LkTNwbo9TqW1UBDse7OefhHp8STTYmoQFwejSusy11WfaIqzr0xEq29Aovr SZXB0JEgIUGPzDtNjE816xl2J45Cm2GSK5ykeQgEZkH5nGJijSLPBkdL4qnvjle75Giy W+JaJPW95XhtAntBeGnN2+nKIFtQCjTVptuFfZTjIdT3FltrfPmPadJ8D9pLtk1nAkXU hWfXB3h/Mjf1HyqlidX7XwaVp3uY5B2UiNZSduoUE4Yc4j9x6jM4LtnvD45MvbkJr0B4 l9Vw== 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=BvSTajJ0/txDo3oQ9anR2MLYElhTmMiqKohTpjPUH4Y=; b=n473A5BRIBSFhmHqV0f/pX2Qgxro7K0enX7DApPH8Obdfos3i/pCWqttN2+y4qHZIF ZpvI0LbAnit5+8ejCUcfjj6PebcnO/7+dyqGt63U85ftrAqe07qCzmAjAWJyXBn0n4Gk hLQw6bjDe/2viGhKjzKBLNjFY6RagYa5JTYb4gdd0kUcP/Fi58QZh2h1cmp5Hb2OiRAK reZzSzlIDAvRLSi5AKNWMq6qHQRz5It9mikvcg0jqPrf42jASCqjFezp28iJyeYVozAj lbV6Ae+dprj0fy6wBC31iCf2vcK1yzOVDRSY7ZZf7y7oT+tnAW+J62IF3HqFERmYyDCg y3aQ== X-Gm-Message-State: APjAAAUw4XxUwFk2JOU7auwx3GUqON/E/7ttORFKGWSkOKji+l4AONCo IggPNbuit5LqqtiCV0rwkLt6mteo X-Google-Smtp-Source: APXvYqyql6x+1lm7cxFqUepsOsRjBk9AfB5o3/t6r/N0vThhH09XFvGWl/xVmQ8NaYF3vh/pvqejmQ== X-Received: by 2002:a62:5e04:: with SMTP id s4mr52193789pfb.63.1574917809693; Wed, 27 Nov 2019 21:10:09 -0800 (PST) Return-Path: Received: from localhost.localdomain ([2601:1c2:680:1319:692:26ff:feda:3a81]) by smtp.gmail.com with ESMTPSA id j20sm17799838pff.182.2019.11.27.21.10.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Nov 2019 21:10:09 -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 , Jack Pham , linux-usb@vger.kernel.org, devicetree@vger.kernel.org Subject: [PATCH v6 5/8] usb: dwc3: Rework clock initialization to be more flexible Date: Thu, 28 Nov 2019 05:09:58 +0000 Message-Id: <20191128051001.18995-6-john.stultz@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191128051001.18995-1-john.stultz@linaro.org> References: <20191128051001.18995-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: Jack Pham Cc: linux-usb@vger.kernel.org Cc: devicetree@vger.kernel.org Suggested-by: Rob Herring Signed-off-by: John Stultz Change-Id: I3319bec8253edc131d772ca66dc9335435b06424 --- 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);