Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp833484pxb; Fri, 21 Jan 2022 04:31:25 -0800 (PST) X-Google-Smtp-Source: ABdhPJyed909PjrE4rmGIJ2VZr0YlTurhWkItHy8TPsrxnQGNsbjOK73AlPyx+F4FOpv5WYvdZ2V X-Received: by 2002:a17:90a:bd09:: with SMTP id y9mr555195pjr.57.1642768285110; Fri, 21 Jan 2022 04:31:25 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1642768285; cv=pass; d=google.com; s=arc-20160816; b=uZxs85uhuI8TCSVuMEKnG8Y0wu0nu2YHC3CPbp3B7HM0bzW2RgCANltD4k8YvavplQ P8tO3w2HEiiq223WYKuz9AcwM/7uWy1NEDGmj5h4OkmgXgLk7rcOGFz30GG/3QmwjG6v 8/onGGRa8Rnwa3NBN74Kn9Ir79AzOyGKDdGJ+l6OtUcVpkxkG0Yz9WtwDWclLV5aQ6jT eEUeeHYnURBDCnNwRao3PxZbAxlvOLLVuE2olyDJr8LbpLgRrxyzRZdlLFL/efH3vbFw hm8AiW/mNo1jKDilsmDqqtsDu9FJoiYFpUIlsqxQYC/lrYf8Vi7imBRkopFauc+MuXYN HqBA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:content-transfer-encoding :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=v1wzgHxMee1sqsmiL1o13ZkzRDifJobPMhYkv72TIZA=; b=jQQuOf77r8cIU2RWlJqzjZN+XBn95YKl3ZGBYwlsm3brCn8m8Zd1//D5I1k1kUfEwe Ke6W2V3cE/8Ss7iRq0XX06BJZaCZ1fEn6IYZ7gk2bu4zYkbS0piik4okqYYM73gzZJjv JCSIjlm7uDLIssSel7CL5G45nIPWjHDHErlQaNGboZhUmdCHtR6+LT3u8y2qbKa85FKM nOWYfzwjty9Si6FU/YdjVOESjl8XESgk2Js7nG7MFncxhzUiPvx9Fb+mn/bsdFPoOXbG 2hd9u2nJp9TPK7kRJev6WA4IkQkQOPPZKjDff8FV8npmQ26IhV11W/Efrq2k8xP15f8h gqcg== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@seco.com header.s=selector2 header.b=qdUhLX74; arc=pass (i=1 spf=pass spfdomain=seco.com dkim=pass dkdomain=seco.com dmarc=pass fromdomain=seco.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=seco.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id bc7si5384260plb.21.2022.01.21.04.31.12; Fri, 21 Jan 2022 04:31:25 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@seco.com header.s=selector2 header.b=qdUhLX74; arc=pass (i=1 spf=pass spfdomain=seco.com dkim=pass dkdomain=seco.com dmarc=pass fromdomain=seco.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=seco.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1350465AbiASAZD (ORCPT + 99 others); Tue, 18 Jan 2022 19:25:03 -0500 Received: from mail-eopbgr80059.outbound.protection.outlook.com ([40.107.8.59]:23461 "EHLO EUR04-VI1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S244782AbiASAY7 (ORCPT ); Tue, 18 Jan 2022 19:24:59 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=dHqAMhRMpW92YAls31wwEyiFoja8GIP6lHQ18eYlJOkkwGfvIN/5nii+fEGZLhbMmgt144QeDWX/74uG3lZ9czzlQaNn3UiB/Su9xakaFWyYKEZKj/iwy9hcrF1WHWBtIoQdkLKoRa+skj3EUlaubtAkax57Emu0rOqEKpZaovP+mkGb/m7D50wxj3pMGzK7m784xIkSxDIx3T8C+JZBPTrwuFCx4XLjO3SemtI3V+5RNdBLpKw8mL8ij3CJcFHywc+XsHOHeSldu7HoK0TuRtMMW3XncHYmDTI5e7GytuJZ8N85MVvmAjKxi1uZX4pRjdTZqgqcBN5fE71dmGHpXg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=v1wzgHxMee1sqsmiL1o13ZkzRDifJobPMhYkv72TIZA=; b=KHjQELW4DSzV7aFFA4Su7Mxt6ZcmbpMZ7SzDfWNatY7Pa9MdE30trhdBBsqo//fUVwj1/5GoQTJj+gxA363dscqPjaGtdqq6pVSTQ8vm/+JPN3hqW8nN1etP3lrFxxShkXGe9MVAHtvzFK5/UFyAT30kl2gyqPWlKbKdUkeKMZh53k9zsnNSyoVh+3W/4uYAyXStfgmVmDD1DHP0r0vjaV6yubUS26rCm1bKPYr8f/qNwZ/LKhY8PqjJq2zHztsSoQeMEeJ0uV5sX5zMDXvSnxH9ECcaHB/erwwApflM8pe84HbRQXEjEtMnFx7mg695cDAacWrjCeVr/b+OkIe5Gw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=seco.com; dmarc=pass action=none header.from=seco.com; dkim=pass header.d=seco.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=seco.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=v1wzgHxMee1sqsmiL1o13ZkzRDifJobPMhYkv72TIZA=; b=qdUhLX74FEghxeJDjLJ9ZTfHkSMv3zmR6sMwSlb0kvLr5jibqEdv+jXdI6kQoNKIFe91/HMypFN0ntWGwMv2V9dtqfBzJ3ZZUOMpGoJ3HjFa+FylT/Wq4xKR4GnULJqBeAtrYWG4NQq7hL1BqbsxS5eFHyhI5ILs5sZlrFUO8r42tB0BBtJ4XX6MkclssVVnoMbUCG2QNeXfDW82sDf1W+tnGPQsmyO44NDJYNIn0qPN33N0zbZO7X3BYgwlEC51mQ1mHocQNF6suC0PDAFiNLXdjvpWhGYlRurFy1w3YufGeJqI8xV+5KsKFXSCOP1xwUsWlDNiuI4G/JeO+MT+Ng== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=seco.com; Received: from DB7PR03MB4523.eurprd03.prod.outlook.com (2603:10a6:10:19::27) by AM6PR03MB4373.eurprd03.prod.outlook.com (2603:10a6:20b:10::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4888.11; Wed, 19 Jan 2022 00:24:55 +0000 Received: from DB7PR03MB4523.eurprd03.prod.outlook.com ([fe80::d47e:81b0:256:3005]) by DB7PR03MB4523.eurprd03.prod.outlook.com ([fe80::d47e:81b0:256:3005%4]) with mapi id 15.20.4888.014; Wed, 19 Jan 2022 00:24:55 +0000 From: Sean Anderson To: Greg Kroah-Hartman , linux-usb@vger.kernel.org Cc: Felipe Balbi , Thinh Nguyen , Balaji Prakash J , linux-kernel@vger.kernel.org, Robert Hancock , Baruch Siach , Sean Anderson Subject: [PATCH v2 2/7] usb: dwc3: Get clocks individually Date: Tue, 18 Jan 2022 19:24:32 -0500 Message-Id: <20220119002438.106079-3-sean.anderson@seco.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220119002438.106079-1-sean.anderson@seco.com> References: <20220119002438.106079-1-sean.anderson@seco.com> Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: MN2PR01CA0025.prod.exchangelabs.com (2603:10b6:208:10c::38) To DB7PR03MB4523.eurprd03.prod.outlook.com (2603:10a6:10:19::27) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: b139ed45-4227-409f-b3fd-08d9dae21e30 X-MS-TrafficTypeDiagnostic: AM6PR03MB4373:EE_ X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:7219; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: n7Q37EAl3y+BoqVC5YQYAOKm+P3iIxxcZLM5LQ+NvQ9SuyYHkkFus2KA0e2sDVyKRrHZKoDGBbIxxh7fGWetIKvaijbT8lklcANXjqr2G29tnMkyyKGbzNY4F1qW9QNs+J27Zf4PP3gOPl/GnQgYwfVSFUpir3RW8A72bcuBXo4kMleJUNL+2az/FpvYJ1zWrMA3wmcFGjogSopCSj93B8qX8YMaHMW1gxbjqdWsn63Zag5YfD61OOsjHYfJS5hn/VYvE7AtNXwjBvEbewHuiLmLvGEELX0RuJtD3F4TibltYZib6eC2NSV6tpFtrK8InDFI7O6YhvK7QbRPch65SAXngqvMG0tfyWSCfQP0GA6GQ7UOoZpFmrzGMs5i6ySVIUGvKBu13uZKjK6g2xCfw5gaaonAxM3MyOQAAQmZjf7mnhNeVFnkKp+7x9CFWY5+f8xYYxHCQZdiJVvwSVh5+m3i1S63lPBBjPFphDe291std0GIqs4CgdtHnviz0byK0N7Ojw0fEAFAopSRl75ekykK4Eg6tJBLQigkLEQYiyBdMxuMGJQodvTbEzPWlsVonDnKKBVtkREFgMxPbY0AZwd6ABkr4IDQ00TyF2rRyS729PDntBQi3ElMbVvm/Z2VD7Wal164CNCaT2CwSYx2amPgTH810uF52WYZhS8cb2FPPGgDstjUbt5lbT6z0eoZnVYIzrAZHBJ4cK/vgtmCVg== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DB7PR03MB4523.eurprd03.prod.outlook.com;PTR:;CAT:NONE;SFS:(366004)(107886003)(316002)(6666004)(5660300002)(186003)(4326008)(6512007)(44832011)(6486002)(6506007)(38100700002)(2616005)(1076003)(66556008)(38350700002)(52116002)(54906003)(66946007)(8936002)(508600001)(2906002)(83380400001)(36756003)(26005)(8676002)(66476007)(86362001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?JJW//faSsHrt6qOVuMSjlrFF4J8zhb2y/mh2RUSsXy9TEPjh0q+K6cNn4QOh?= =?us-ascii?Q?hENb02O0YMvC4sEV738WDorx3teIcszCGsR1aGHh1wA4iLcn3ciI1Du5xA2N?= =?us-ascii?Q?gqYORNbYsVBGGQPYecgYY8x2o3JC/lDY9UojS6eL5WQ65kg7Z2WC4dpTUjwD?= =?us-ascii?Q?xs1jNDv1f8YcjcjSBO8Gup0NkBcqTgiNCqiMPJxGjWA6BTUKPZfnJakIh4X4?= =?us-ascii?Q?g6Xbo9I2567GiEQTBx5slgbAqybfQQwawdge5zfyzCV7K1YDLmuLY5M06Oml?= =?us-ascii?Q?zDE8ko21GauhC69mTezMiXIPvAV7+cZMH8UV61COva2BbKGYXFVPCMGYhTIZ?= =?us-ascii?Q?fXUJoGd2O5kmYenJRxy3cICpLG6WL+RMEMiQVknrfZe2LfWiati7tzNdk78p?= =?us-ascii?Q?98DNnPIZNNjFKXOHdGGuN59HMJvp2lQlyq4gDTCtMjA+VBq39OqmyKPh6aVH?= =?us-ascii?Q?4qxD1A4lUXgnOgtUzfcOBg53zSx3Cc0mKv1aDYD5iwihwNTQAWx4Gvv8BGiT?= =?us-ascii?Q?58xMBTRrtbc4QnQprn4gHOB6XpkK+HQLXeMsavmrSZgW6gQgbcru7ROQcnoN?= =?us-ascii?Q?gx229hGvyomYzaZWFSWC1g3fVtHA6th2F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lq/nmwoo8jSu38Kc139W0kgdlqBiz7aUq4H484cIqWD5onYQTb?= =?us-ascii?Q?lFeWACrIAUyjAIb9vs5f/vQ+vfZlEBoSrof+DUr9h+lDp9egZpIN7chOk4Jv?= =?us-ascii?Q?+VeJC+q/s7L0uOKKIpm+0rU=3D?= X-OriginatorOrg: seco.com X-MS-Exchange-CrossTenant-Network-Message-Id: b139ed45-4227-409f-b3fd-08d9dae21e30 X-MS-Exchange-CrossTenant-AuthSource: DB7PR03MB4523.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Jan 2022 00:24:55.5326 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: bebe97c3-6438-442e-ade3-ff17aa50e733 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: MspnLRClLlkuMTFjbNf62/tF5tVyCDiOZuLeCGDQ1Nr3CvDrdb9hynncloZQUf60DCXI+v6H/cu1ZyR/roy4gQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR03MB4373 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Instead of grabbing all clocks in bulk, grab them individually. This will allow us to get the frequency or otherwise deal with discrete clocks. This may break some platforms if they use a clock which doesn't use one of the documented names. Signed-off-by: Sean Anderson --- Changes in v2: - Document clock members drivers/usb/dwc3/core.c | 62 +++++++++++++++++++++++++++++++++-------- drivers/usb/dwc3/core.h | 10 ++++--- 2 files changed, 56 insertions(+), 16 deletions(-) diff --git a/drivers/usb/dwc3/core.c b/drivers/usb/dwc3/core.c index f4c09951b517..699ab9abdc47 100644 --- a/drivers/usb/dwc3/core.c +++ b/drivers/usb/dwc3/core.c @@ -745,6 +745,38 @@ static int dwc3_phy_setup(struct dwc3 *dwc) return 0; } +static int dwc3_clk_enable(struct dwc3 *dwc) +{ + int ret; + + ret = clk_prepare_enable(dwc->bus_clk); + if (ret) + return ret; + + ret = clk_prepare_enable(dwc->ref_clk); + if (ret) + goto disable_bus_clk; + + ret = clk_prepare_enable(dwc->susp_clk); + if (ret) + goto disable_ref_clk; + + return 0; + +disable_ref_clk: + clk_disable_unprepare(dwc->ref_clk); +disable_bus_clk: + clk_disable_unprepare(dwc->bus_clk); + return ret; +} + +static void dwc3_clk_disable(struct dwc3 *dwc) +{ + clk_disable_unprepare(dwc->susp_clk); + clk_disable_unprepare(dwc->ref_clk); + clk_disable_unprepare(dwc->bus_clk); +} + static void dwc3_core_exit(struct dwc3 *dwc) { dwc3_event_buffers_cleanup(dwc); @@ -758,7 +790,7 @@ static void dwc3_core_exit(struct dwc3 *dwc) usb_phy_set_suspend(dwc->usb3_phy, 1); phy_power_off(dwc->usb2_generic_phy); phy_power_off(dwc->usb3_generic_phy); - clk_bulk_disable_unprepare(dwc->num_clks, dwc->clks); + dwc3_clk_disable(dwc); reset_control_assert(dwc->reset); } @@ -1605,25 +1637,31 @@ static int dwc3_probe(struct platform_device *pdev) return PTR_ERR(dwc->reset); if (dev->of_node) { - 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 < 0) - dwc->num_clks = 0; - else - dwc->num_clks = ret; + dwc->bus_clk = devm_clk_get_optional(dev, "bus_early"); + if (IS_ERR(dwc->bus_clk)) + return dev_err_probe(dev, PTR_ERR(dwc->bus_clk), + "could not get bus clock\n"); + dwc->ref_clk = devm_clk_get_optional(dev, "ref"); + if (IS_ERR(dwc->ref_clk)) + return dev_err_probe(dev, PTR_ERR(dwc->ref_clk), + "could not get ref clock\n"); + + dwc->susp_clk = devm_clk_get_optional(dev, "suspend"); + if (IS_ERR(dwc->susp_clk)) + return dev_err_probe(dev, PTR_ERR(dwc->susp_clk), + "could not get suspend clock\n"); } ret = reset_control_deassert(dwc->reset); if (ret) return ret; - ret = clk_bulk_prepare_enable(dwc->num_clks, dwc->clks); + ret = dwc3_clk_enable(dwc); if (ret) goto assert_reset; @@ -1711,7 +1749,7 @@ static int dwc3_probe(struct platform_device *pdev) pm_runtime_disable(&pdev->dev); disable_clks: - clk_bulk_disable_unprepare(dwc->num_clks, dwc->clks); + dwc3_clk_disable(dwc); assert_reset: reset_control_assert(dwc->reset); @@ -1755,7 +1793,7 @@ static int dwc3_core_init_for_resume(struct dwc3 *dwc) if (ret) return ret; - ret = clk_bulk_prepare_enable(dwc->num_clks, dwc->clks); + ret = dwc3_clk_enable(dwc); if (ret) goto assert_reset; @@ -1766,7 +1804,7 @@ static int dwc3_core_init_for_resume(struct dwc3 *dwc) return 0; disable_clks: - clk_bulk_disable_unprepare(dwc->num_clks, dwc->clks); + dwc3_clk_disable(dwc); assert_reset: reset_control_assert(dwc->reset); diff --git a/drivers/usb/dwc3/core.h b/drivers/usb/dwc3/core.h index e1cc3f7398fb..45cfa7d9f27a 100644 --- a/drivers/usb/dwc3/core.h +++ b/drivers/usb/dwc3/core.h @@ -978,8 +978,9 @@ struct dwc3_scratchpad_array { * @eps: endpoint array * @gadget: device side representation of the peripheral controller * @gadget_driver: pointer to the gadget driver - * @clks: array of clocks - * @num_clks: number of clocks + * @bus_clk: clock for accessing the registers + * @ref_clk: reference clock + * @susp_clk: clock used when the SS phy is in low power (S3) state * @reset: reset control * @regs: base address for our registers * @regs_size: address space size @@ -1134,8 +1135,9 @@ struct dwc3 { struct usb_gadget *gadget; struct usb_gadget_driver *gadget_driver; - struct clk_bulk_data *clks; - int num_clks; + struct clk *bus_clk; + struct clk *ref_clk; + struct clk *susp_clk; struct reset_control *reset; -- 2.25.1