Received: by 2002:a05:6358:4e97:b0:b3:742d:4702 with SMTP id ce23csp1393315rwb; Fri, 19 Aug 2022 02:57:34 -0700 (PDT) X-Google-Smtp-Source: AA6agR4JsnIdnZPe+CROM7QV5T8WKLBUBPfbQz+IMEheR98isW/ICKpm+K4IObWLmGl6MqRwvTo1 X-Received: by 2002:a17:90b:3ec9:b0:1f5:7e38:1fd1 with SMTP id rm9-20020a17090b3ec900b001f57e381fd1mr13023304pjb.101.1660903054485; Fri, 19 Aug 2022 02:57:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1660903054; cv=none; d=google.com; s=arc-20160816; b=BWvIDu3kI8Bsyrv8gj/rIrsM9tNa0Dsxw88qMJ1dhA8z9mF+QCMEPrHxsbavEdQxcL L5O0v7I+uh1r0+cGEyhqCOCfAsPt89ek2bqWX0GLaFc4GxKanIjFog9kGPB+iDSQAhkv 5T0KtzhGyugWBW4i/Ikgm46gSkLOePmC8OQmXdqCTh3sAyhiYVNComo+mgY8zSExEMyU ++nCiozHO6t9SuF2QwKBQ06GM/Ux/cjn6I6vr/t+9MsvBPMGHzP6r7JlZhjFVf211mK8 BRWParMLI9Er6Rzu17AJXzD5xk+63MNC1hQoDIupaGtZi7EktgQuYk2sxpAfG3JIAonV 0hnw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=rGom6CPWejVdJuwH7OGZ2D+NnZazCOx6cY1qeCHWzmM=; b=X15zlVOWAPq0mI8aqZuYCt8wXugk1k2B61tzxnq5erxMHzZyqVDOO42JSa0P1GfTVO lYbMHuFf1f/K3lUkFB56+Dw6MP6xukwYsx9JQBRkWo1gMtdK+5YZ9XgQBW//AHkMkZJV 3ZS4KDcfBoImpuYVpNVtmwj2xWNby7t41XCuOaFP/WmBC7P8h5dJgFuoN0AfEj6GhhSF pJi/dVZ+7C91xELhzLiiHbKDPKLoSX3NaHGZK3v7EbD/waMCD+JxCnd+9LB9fs/JshxY lHR4DRYCykqPMrGmHZzUgqWVHXj68mejYqS3mDbBvqLVFS0rpdmn9SLdqtyK+5NLhBAL 1j5Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@microchip.com header.s=mchp header.b=ARIlkXj0; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=microchip.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 4-20020a631644000000b00429ead9bda6si3497782pgw.86.2022.08.19.02.57.23; Fri, 19 Aug 2022 02:57:34 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@microchip.com header.s=mchp header.b=ARIlkXj0; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=microchip.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1348278AbiHSJ4R (ORCPT + 99 others); Fri, 19 Aug 2022 05:56:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56756 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1348254AbiHSJzb (ORCPT ); Fri, 19 Aug 2022 05:55:31 -0400 Received: from esa.microchip.iphmx.com (esa.microchip.iphmx.com [68.232.154.123]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 88596F4CA4; Fri, 19 Aug 2022 02:55:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1660902912; x=1692438912; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=sgjU7S3Jp8TY5e/zoYxCXMLoM+CHD6Vu7ShuGPypjH8=; b=ARIlkXj0Q6VXpeODCzI88O118yxHuMbx2HdP8LvkRB+q/4mnfaA/+0on LVhGt47uzQrVLKNUxGPMo4L5n4DKa+Cx9/CuJqf16714p9yWrWjRU7IJG uXppSrrO83PwNY3fo0yiUYKzl291fIeD6eYvnch7gQa9ineCkAzc41Wj7 Uw+i7FM0sZjoKkZvx2R//OMVPMKdwDUeF/e+zHMPdNTPp5h8XFQPulKGs 1xEbum1fC4UB0wtD92atA6uE+dQb84l/SlA4N4iRsDvH4BBgsG8M5Ptlz T6df6WSAb2ECTsZTWWT7qD84SnweViWPJCSnbjDnZXaTH+40Rmlz1fqhI w==; X-IronPort-AV: E=Sophos;i="5.93,247,1654585200"; d="scan'208";a="170010405" Received: from unknown (HELO email.microchip.com) ([170.129.1.10]) by esa4.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 19 Aug 2022 02:55:11 -0700 Received: from chn-vm-ex04.mchp-main.com (10.10.85.152) by chn-vm-ex04.mchp-main.com (10.10.85.152) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.12; Fri, 19 Aug 2022 02:55:07 -0700 Received: from wendy.microchip.com (10.10.115.15) by chn-vm-ex04.mchp-main.com (10.10.85.152) with Microsoft SMTP Server id 15.1.2507.12 via Frontend Transport; Fri, 19 Aug 2022 02:55:04 -0700 From: Conor Dooley To: Michael Turquette , Stephen Boyd , Rob Herring , Krzysztof Kozlowski , Palmer Dabbelt , Conor Dooley , Philipp Zabel , Daire McNamara CC: Paul Walmsley , Albert Ou , , , , Subject: [PATCH v3 12/13] clk: microchip: mpfs: convert periph_clk to clk_gate Date: Fri, 19 Aug 2022 10:53:20 +0100 Message-ID: <20220819095320.40006-13-conor.dooley@microchip.com> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220819095320.40006-1-conor.dooley@microchip.com> References: <20220819095320.40006-1-conor.dooley@microchip.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_PASS,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org With the reset code moved to the recently added reset controller, there is no need for custom ops any longer. Remove the custom ops and the custom struct by converting to a clk_gate. Reviewed-by: Daire McNamara Signed-off-by: Conor Dooley --- drivers/clk/microchip/clk-mpfs.c | 72 +++----------------------------- 1 file changed, 6 insertions(+), 66 deletions(-) diff --git a/drivers/clk/microchip/clk-mpfs.c b/drivers/clk/microchip/clk-mpfs.c index 8af532f03d24..35a67d2b7845 100644 --- a/drivers/clk/microchip/clk-mpfs.c +++ b/drivers/clk/microchip/clk-mpfs.c @@ -58,19 +58,11 @@ struct mpfs_cfg_hw_clock { u32 reg_offset; }; -struct mpfs_periph_clock { - void __iomem *reg; - u8 shift; -}; - struct mpfs_periph_hw_clock { - struct mpfs_periph_clock periph; - struct clk_hw hw; + struct clk_gate periph; unsigned int id; }; -#define to_mpfs_periph_clk(_hw) container_of(_hw, struct mpfs_periph_hw_clock, hw) - /* * mpfs_clk_lock prevents anything else from writing to the * mpfs clk block while a software locked register is being written. @@ -273,64 +265,12 @@ static int mpfs_clk_register_cfgs(struct device *dev, struct mpfs_cfg_hw_clock * * peripheral clocks - devices connected to axi or ahb buses. */ -static int mpfs_periph_clk_enable(struct clk_hw *hw) -{ - struct mpfs_periph_hw_clock *periph_hw = to_mpfs_periph_clk(hw); - struct mpfs_periph_clock *periph = &periph_hw->periph; - u32 reg, val; - unsigned long flags; - - spin_lock_irqsave(&mpfs_clk_lock, flags); - - reg = readl_relaxed(periph->reg); - val = reg | (1u << periph->shift); - writel_relaxed(val, periph->reg); - - spin_unlock_irqrestore(&mpfs_clk_lock, flags); - - return 0; -} - -static void mpfs_periph_clk_disable(struct clk_hw *hw) -{ - struct mpfs_periph_hw_clock *periph_hw = to_mpfs_periph_clk(hw); - struct mpfs_periph_clock *periph = &periph_hw->periph; - u32 reg, val; - unsigned long flags; - - spin_lock_irqsave(&mpfs_clk_lock, flags); - - reg = readl_relaxed(periph->reg); - val = reg & ~(1u << periph->shift); - writel_relaxed(val, periph->reg); - - spin_unlock_irqrestore(&mpfs_clk_lock, flags); -} - -static int mpfs_periph_clk_is_enabled(struct clk_hw *hw) -{ - struct mpfs_periph_hw_clock *periph_hw = to_mpfs_periph_clk(hw); - struct mpfs_periph_clock *periph = &periph_hw->periph; - u32 reg; - - reg = readl_relaxed(periph->reg); - if (reg & (1u << periph->shift)) - return 1; - - return 0; -} - -static const struct clk_ops mpfs_periph_clk_ops = { - .enable = mpfs_periph_clk_enable, - .disable = mpfs_periph_clk_disable, - .is_enabled = mpfs_periph_clk_is_enabled, -}; - #define CLK_PERIPH(_id, _name, _parent, _shift, _flags) { \ .id = _id, \ - .periph.shift = _shift, \ - .hw.init = CLK_HW_INIT_HW(_name, _parent, &mpfs_periph_clk_ops, \ + .periph.bit_idx = _shift, \ + .periph.hw.init = CLK_HW_INIT_HW(_name, _parent, &clk_gate_ops, \ _flags), \ + .periph.lock = &mpfs_clk_lock, \ } #define PARENT_CLK(PARENT) (&mpfs_cfg_clks[CLK_##PARENT].cfg.hw) @@ -390,13 +330,13 @@ static int mpfs_clk_register_periphs(struct device *dev, struct mpfs_periph_hw_c struct mpfs_periph_hw_clock *periph_hw = &periph_hws[i]; periph_hw->periph.reg = data->base + REG_SUBBLK_CLOCK_CR; - ret = devm_clk_hw_register(dev, &periph_hw->hw); + ret = devm_clk_hw_register(dev, &periph_hw->periph.hw); if (ret) return dev_err_probe(dev, ret, "failed to register clock id: %d\n", periph_hw->id); id = periph_hws[i].id; - data->hw_data.hws[id] = &periph_hw->hw; + data->hw_data.hws[id] = &periph_hw->periph.hw; } return 0; -- 2.36.1