From patchwork Fri Jun 23 20:30:21 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Varshini Rajendran X-Patchwork-Id: 112266 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp6029654vqr; Fri, 23 Jun 2023 13:42:48 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ68ZuPnp+QpdBilIhB4RYV/nXd4tT5VbgGKI8fiPodfIKbCMVevl96/6aCE88H583uuMIEK X-Received: by 2002:a05:6a20:1614:b0:116:fd37:c924 with SMTP id l20-20020a056a20161400b00116fd37c924mr27157585pzj.5.1687552967756; Fri, 23 Jun 2023 13:42:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687552967; cv=none; d=google.com; s=arc-20160816; b=d2X95luLuT9AGIt3Eth/n7sPJQ66u4r0tlpOx/z+Kk7QLk+qIoHIBhBpQIHZe7/M0l cRRQDYcM6iG2Efq5Vy92WljJem0TTbLaW3pXWfK/PesBYjAndAWxnOsoWWaUMD3/+xR9 l3qq6YU+wjix5G0IssXD/5NzmqwCxc4AZYJfydmL/1Cl+yQPZ2nYJV/vCCDCVIKcsv2v X5jVTnlBfQX2a/bB2Sdfa1O0pCn41G12gOftp3JledhZqwt8fMVllt9YlkEaZmD0x+Eb duFFlcl2FrY4/uXwbnrzVN2Hq7lniK3Kr9+zC8ToGwk3IDDmBTwdMPKtoffKA2sX84xP Hz1g== 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=uKwwsHtQZbeI92VOl5+0qVz0vPFpjMd6jyw2UsGfaOE=; fh=gvF0Lmh3we7l1N050eW0NXEfX6fwK1w/g3y1gvYPqdE=; b=iSroapeunr8IXOFpyQsm7E8oFzf/yD/9gDBku0NvvkhkGsznIdI/vsNjOjQ7XEsBuM z4b+SWYJCo9uffTEpLnftFOjI1mJGgQ/TUqMcVwZFI1VyslujhH7i412kEh6W88GjD2b IUfDNYEVlXRqBf+NTS4eOYMc/l9ZAA/+1s7XCASeJgpkxO59ISBh3yMJw1OtDJfO+flf KyMdpuQyimPJqb9P1t6bLjPZjz1JkuQH9SO5O+JapPf30ueDYT9MaOYpctkeb53Jf2t5 miSfRcRzXBhzFmngbtdTj2kfG4sGChqKqIn7FDdNFcryininU0mLofWxrUBXxMCvsTQj yJlg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@microchip.com header.s=mchp header.b=m2lq5uWp; 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: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id l69-20020a638848000000b0054f9f9c744fsi181358pgd.639.2023.06.23.13.42.33; Fri, 23 Jun 2023 13:42:47 -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=m2lq5uWp; 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 S232193AbjFWUhp (ORCPT + 99 others); Fri, 23 Jun 2023 16:37:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54464 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232062AbjFWUhd (ORCPT ); Fri, 23 Jun 2023 16:37:33 -0400 Received: from esa.microchip.iphmx.com (esa.microchip.iphmx.com [68.232.154.123]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E144A2965; Fri, 23 Jun 2023 13:37:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1687552623; x=1719088623; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=+NDzjzg+Ni//gNmFZKyOgL7uxanPfC14OsbzNCq8wzw=; b=m2lq5uWpNEOk41B54sKg/a6G8/YVRgwTL7fwyUga75Zx7jb0zYFDCSB0 IXN8qWHHa3KuybazFbu4CvsIvUUXCJRQ7sHrXz64qCjklHwhawph53Kyi HTQaHG2kcIRLtke1aU1/Ck9E5VUvs8zrjpcuNSJy+9MxWAj3v17J5+1HM HtSPQCKI83I7DQR2IA5U8yNtGZ3uWiZlw7OduA8gXePFLLdcLvYrVCC9l g6uDyaifygWZyv9LkmwMng6Bj1IUOr+p1T1eKX5sa5K7WLYBMDrlBG1Hh Si3yzfrXdCBJuNvzu9G0vsI7SZ6RVdW2oYSGtKgxPlxmxxsTqDAuxjklG Q==; X-IronPort-AV: E=Sophos;i="6.01,153,1684825200"; d="scan'208";a="158362094" X-Amp-Result: SKIPPED(no attachment in message) Received: from unknown (HELO email.microchip.com) ([170.129.1.10]) by esa6.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 23 Jun 2023 13:36:26 -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.21; Fri, 23 Jun 2023 13:36:21 -0700 Received: from che-lt-i67070.amer.actel.com (10.10.115.15) by chn-vm-ex04.mchp-main.com (10.10.85.152) with Microsoft SMTP Server id 15.1.2507.21 via Frontend Transport; Fri, 23 Jun 2023 13:35:53 -0700 From: Varshini Rajendran To: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , CC: , , , , , , Subject: [PATCH v2 10/45] clk: at91: sama7g5: move mux table macros to header file Date: Sat, 24 Jun 2023 02:00:21 +0530 Message-ID: <20230623203056.689705-11-varshini.rajendran@microchip.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230623203056.689705-1-varshini.rajendran@microchip.com> References: <20230623203056.689705-1-varshini.rajendran@microchip.com> MIME-Version: 1.0 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_NONE,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1769527540843712275?= X-GMAIL-MSGID: =?utf-8?q?1769527540843712275?= Move the mux table init and fill macro function definitions from the sama7g5 pmc driver to the pmc.h header file since they will be used by other SoC's pmc drivers as well like sam9x7. Signed-off-by: Varshini Rajendran --- drivers/clk/at91/pmc.h | 16 ++++++++++++++++ drivers/clk/at91/sama7g5.c | 35 ++++++++++------------------------- 2 files changed, 26 insertions(+), 25 deletions(-) diff --git a/drivers/clk/at91/pmc.h b/drivers/clk/at91/pmc.h index 1dd01f30bdee..f3c23ff0da02 100644 --- a/drivers/clk/at91/pmc.h +++ b/drivers/clk/at91/pmc.h @@ -121,6 +121,22 @@ struct at91_clk_pms { #define ndck(a, s) (a[s - 1].id + 1) #define nck(a) (a[ARRAY_SIZE(a) - 1].id + 1) + +#define PMC_INIT_TABLE(_table, _count) \ + do { \ + u8 _i; \ + for (_i = 0; _i < (_count); _i++) \ + (_table)[_i] = _i; \ + } while (0) + +#define PMC_FILL_TABLE(_to, _from, _count) \ + do { \ + u8 _i; \ + for (_i = 0; _i < (_count); _i++) { \ + (_to)[_i] = (_from)[_i]; \ + } \ + } while (0) + struct pmc_data *pmc_data_allocate(unsigned int ncore, unsigned int nsystem, unsigned int nperiph, unsigned int ngck, unsigned int npck); diff --git a/drivers/clk/at91/sama7g5.c b/drivers/clk/at91/sama7g5.c index 468a3c5449b5..75011df708cc 100644 --- a/drivers/clk/at91/sama7g5.c +++ b/drivers/clk/at91/sama7g5.c @@ -16,21 +16,6 @@ #include "pmc.h" -#define SAMA7G5_INIT_TABLE(_table, _count) \ - do { \ - u8 _i; \ - for (_i = 0; _i < (_count); _i++) \ - (_table)[_i] = _i; \ - } while (0) - -#define SAMA7G5_FILL_TABLE(_to, _from, _count) \ - do { \ - u8 _i; \ - for (_i = 0; _i < (_count); _i++) { \ - (_to)[_i] = (_from)[_i]; \ - } \ - } while (0) - static DEFINE_SPINLOCK(pmc_pll_lock); static DEFINE_SPINLOCK(pmc_mck0_lock); static DEFINE_SPINLOCK(pmc_mckX_lock); @@ -1022,11 +1007,11 @@ static void __init sama7g5_pmc_setup(struct device_node *np) if (!mux_table) goto err_free; - SAMA7G5_INIT_TABLE(mux_table, 3); - SAMA7G5_FILL_TABLE(&mux_table[3], sama7g5_mckx[i].ep_mux_table, - sama7g5_mckx[i].ep_count); - SAMA7G5_FILL_TABLE(&parent_names[3], sama7g5_mckx[i].ep, - sama7g5_mckx[i].ep_count); + PMC_INIT_TABLE(mux_table, 3); + PMC_FILL_TABLE(&mux_table[3], sama7g5_mckx[i].ep_mux_table, + sama7g5_mckx[i].ep_count); + PMC_FILL_TABLE(&parent_names[3], sama7g5_mckx[i].ep, + sama7g5_mckx[i].ep_count); hw = at91_clk_sama7g5_register_master(regmap, sama7g5_mckx[i].n, num_parents, parent_names, mux_table, @@ -1109,11 +1094,11 @@ static void __init sama7g5_pmc_setup(struct device_node *np) if (!mux_table) goto err_free; - SAMA7G5_INIT_TABLE(mux_table, 3); - SAMA7G5_FILL_TABLE(&mux_table[3], sama7g5_gck[i].pp_mux_table, - sama7g5_gck[i].pp_count); - SAMA7G5_FILL_TABLE(&parent_names[3], sama7g5_gck[i].pp, - sama7g5_gck[i].pp_count); + PMC_INIT_TABLE(mux_table, 3); + PMC_FILL_TABLE(&mux_table[3], sama7g5_gck[i].pp_mux_table, + sama7g5_gck[i].pp_count); + PMC_FILL_TABLE(&parent_names[3], sama7g5_gck[i].pp, + sama7g5_gck[i].pp_count); hw = at91_clk_register_generated(regmap, &pmc_pcr_lock, &sama7g5_pcr_layout,