Received: by 2002:a05:6358:45e:b0:b5:b6eb:e1f9 with SMTP id 30csp4196146rwe; Tue, 30 Aug 2022 06:18:27 -0700 (PDT) X-Google-Smtp-Source: AA6agR4vFVirCcadPk2g6n+B2psaqQkGLSt/fSXQvqMsTHenSfQbSZGOROtl3sD0LGm7yjDpAjHq X-Received: by 2002:a17:907:6e94:b0:741:8c76:2ed8 with SMTP id sh20-20020a1709076e9400b007418c762ed8mr6946891ejc.731.1661865507220; Tue, 30 Aug 2022 06:18:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661865507; cv=none; d=google.com; s=arc-20160816; b=h0LRfLtc2JYsTgp0ijgBxbEnhMrX+/DAq/EUWJVxlwbQpKV/pFPnZXMvAFCXpAdWQL NLuli8eK7aaNtaodueBClizLGkjapxfdvYmtjOuaQzGAlisAhW0PTkiXM+NRZERAfC4+ 11RFxwqZUFInmX15EYzUL9ri86hxkLvf9MEG2yhD/N+DqYvCMdELerJM92ffeydI7Mlf X7YtJunKKrz2+d0ZXw38OGEl80ABjElcSd4pV/Uf6UB0MOIG8XGOfu6iL1ZFeHBBJ/Qs XFvum47GwNbZVmiWh12DNvbvInoe4PN5oINKU/pbXCSrypSzwUwVBWfHVlsXtkUzr4d8 8JRw== 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=fEmKYLSbrouN7v5Z7XiN7S2ewD/VfY5i6BkVjyuHN88=; b=Ciqech35L7Ruq8MfWDgj6FLOZSdyXRSgXeX8uKCEW2CTzNZL/169rWJpX9DnkVl18x tNCDWk1eMaTj/kVR8amo8OWkXupq+NN2Z9PS9cLx35qutMo8xDvYV9rrA6bG81bFnapT nqVT/fkaZiSzd6Eton+hfluXV6J9DBZZtuzySzth/jvA28zKKbEtEcH9gbJQzz/0JegP bH+EBjpFrUSizU3xZe6d4TlHrWFjjQMG12H8o2vjryK5AnXWMz75T25dbcQWKqUpwG4s G99vN7enwX9PdRplhMGLMpsZoaGXx3ZaiG3wlJIv5UEwsIHk0rIizHkTN4TlXKN/OlA9 O5Gw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@microchip.com header.s=mchp header.b=pumPAMY2; 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 c16-20020a05640227d000b0043c436a8d48si10561267ede.582.2022.08.30.06.18.01; Tue, 30 Aug 2022 06:18:27 -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=pumPAMY2; 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 S230259AbiH3My2 (ORCPT + 99 others); Tue, 30 Aug 2022 08:54:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48550 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230050AbiH3Mx7 (ORCPT ); Tue, 30 Aug 2022 08:53:59 -0400 Received: from esa.microchip.iphmx.com (esa.microchip.iphmx.com [68.232.153.233]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 383C015C362; Tue, 30 Aug 2022 05:53:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1661864032; x=1693400032; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=+j0Bj+aApY6wS6WgiTdHHq/9KOIAMlKvPqoSyxcaJfM=; b=pumPAMY2yABL7ComwhXzRJImuL5gy3APsZJQ/aUn9IiAwNIAlxPCuJTA EFYa7IhfDcfBtaqFKlnoNPj1AinAP+d5Gl/Eyz1udQ3FUJl8PjzXNQi6h J44hblSzGpXRx1X+eJqDzBf0XKAl6CTADEKY1y0/zAgmHE6vUdRnpNy7x tEIy+HMoSdncFMNTog90et9XyYQVqxxicnMxxnLo3wmzZgmJIZpXNEFRr gZCWs55n9YkcznM1sRMLu632nA3gyaRdkkwjMTbLO8tNVLgyuBrb7kshr uYn5xG2vxAzJancpKTUcJsF4/DydXUpP6GpG4ZnXclCOc/H0wYhomN4Ul w==; X-IronPort-AV: E=Sophos;i="5.93,275,1654585200"; d="scan'208";a="188645833" Received: from unknown (HELO email.microchip.com) ([170.129.1.10]) by esa1.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 30 Aug 2022 05:53:52 -0700 Received: from chn-vm-ex04.mchp-main.com (10.10.85.152) by chn-vm-ex01.mchp-main.com (10.10.85.143) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.12; Tue, 30 Aug 2022 05:53:50 -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; Tue, 30 Aug 2022 05:53:47 -0700 From: Conor Dooley To: Michael Turquette , Stephen Boyd , Rob Herring , Krzysztof Kozlowski , Palmer Dabbelt , Conor Dooley , Daire McNamara CC: Paul Walmsley , Albert Ou , Claudiu Beznea , , , , Subject: [PATCH v4 12/13] clk: microchip: mpfs: convert periph_clk to clk_gate Date: Tue, 30 Aug 2022 13:52:49 +0100 Message-ID: <20220830125249.2373416-12-conor.dooley@microchip.com> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220830125110.2372514-1-conor.dooley@microchip.com> References: <20220830125110.2372514-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 88a200e88e54..fa46176eb9ca 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