From patchwork Mon Aug 14 06:03:09 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Raag Jadav X-Patchwork-Id: 135183 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b824:0:b0:3f2:4152:657d with SMTP id z4csp2580046vqi; Mon, 14 Aug 2023 00:38:15 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGb2mtOdAo8b8k8o87Yz7wuh0Gh885Jlpxf1ioO3/ev5CQ+pFpdOn9LmkiKDive/hrVElo7 X-Received: by 2002:a17:902:c1c4:b0:1bb:9bc8:d22d with SMTP id c4-20020a170902c1c400b001bb9bc8d22dmr7319665plc.16.1691998694869; Mon, 14 Aug 2023 00:38:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691998694; cv=none; d=google.com; s=arc-20160816; b=LSBi1dLN8wkOgz6XbM3Mcv6eTFH5KJ/ydQjgVKuKwwo4CsMqd0aWHECORWR/pOtNhN 8d5ioywKiKdC71vI05EPlphronxp3CsJJCWOt4qONMvreQRd3pLmQKLoiBGCMjCkr5Vs rVH4BGTthc7VnwiNoX4tJwQnroSo+ylatNJ9wKtvrHP+tqPkgIZdqk1aim0cQ7gpYn/C mqN02Lvlw5crqX89EuIBEmad+T8AbrHFIMKWZYeDGoKuHzJPCXh2O7zyvsUUcmmIPuhP 6uFdxRCFo0SUQJtLBcoAsyOF/ainDAlUm4GwVkcjs8nNfJfE3NOwBq7AuoYGiOZWS74o GlWw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from:dkim-signature; bh=Kp1gLdyLO7DHFqgZP6bmo7uuERyjbJuBaLEDr4YGKD8=; fh=ITb4zGKkWO3T0WmJnSV0Z0twUZ/f73yiIOUT0grFSAs=; b=BaSuRoSYFIlQmxm1zky6FLmjP5Ncyj3AYPaM6ConbMo6xFanekLA9SEAvpV0DKwylQ TdQZTsfcioV4KS79/TGpsCLubliSNuBUMpE6kuJa7KaYsCWWqQ3mZDq+7mSD1g5UzfJD nq9MCAsgeZk9hsf8Gh5iVw8S1U7ReFIhWBNRziD3SSYwVhwluuxFl7qteOXuik/EM8er JXE/9qFyn4q9y1CDcb9goYf4T5HcH8ilrS78O15xjhbLBw2En0RDbWgdm1r0fjonIp9R R5dVnheYqwSX4Jh3pE+Na59i1NF4lhmtoV+y+KtNCo66qFPZOtqnMkMNpDJ/YKjAme1/ ZcSA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=k4SiMj6l; 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=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id f10-20020a170902ce8a00b001bd9d6e8319si7997687plg.145.2023.08.14.00.38.02; Mon, 14 Aug 2023 00:38:14 -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=@intel.com header.s=Intel header.b=k4SiMj6l; 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=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233501AbjHNGEU (ORCPT + 99 others); Mon, 14 Aug 2023 02:04:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41842 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233294AbjHNGEK (ORCPT ); Mon, 14 Aug 2023 02:04:10 -0400 Received: from mgamail.intel.com (mgamail.intel.com [192.55.52.115]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E678E129; Sun, 13 Aug 2023 23:04:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1691993049; x=1723529049; h=from:to:cc:subject:date:message-id:in-reply-to: references; bh=WcdGtChIm1EcfRxknsGqjMYwaa75wWP0SVoFIOs0nSI=; b=k4SiMj6lkVCqQoowyNLmbVjWTuN2TO2DmWY6CUETYfJDERqMsqKYnsJm aw6AXg1ng5W0f5ts6dIHWjWdW9eN1LNsZW8t7mzAck2qgumJ/wbgR1Jy8 OjAFpbSF6YbQXQvdIHx6r+nOlDxbAtzRztK30B83c2H8R4dpXYYESjKS6 YqiKxhBF4ctjSk9yL2VbmPqWrpapRYS9Xo25PMwqsVemovuYNBPT0BvEg eSYsKTD5zJkwdIDCK5B7kWjn+G+3Hqx2wRt/HQMGQadIKsVmHZkLtwbUU TMfi7Jb0xwUYZEpVhZiSN0yWIvDHlDC5p0uhuPXxRO+KHxI6rCqmDFd2F Q==; X-IronPort-AV: E=McAfee;i="6600,9927,10801"; a="371970755" X-IronPort-AV: E=Sophos;i="6.01,171,1684825200"; d="scan'208";a="371970755" Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Aug 2023 23:04:08 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10801"; a="798702943" X-IronPort-AV: E=Sophos;i="6.01,171,1684825200"; d="scan'208";a="798702943" Received: from inlubt0316.iind.intel.com ([10.191.20.213]) by fmsmga008.fm.intel.com with ESMTP; 13 Aug 2023 23:04:05 -0700 From: Raag Jadav To: linus.walleij@linaro.org, mika.westerberg@linux.intel.com, andriy.shevchenko@linux.intel.com Cc: linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, mallikarjunappa.sangannavar@intel.com, pandith.n@intel.com, Raag Jadav Subject: [PATCH v1 2/4] pinctrl: baytrail: reuse common functions from pinctrl-intel Date: Mon, 14 Aug 2023 11:33:09 +0530 Message-Id: <20230814060311.15945-3-raag.jadav@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20230814060311.15945-1-raag.jadav@intel.com> References: <20230814060311.15945-1-raag.jadav@intel.com> 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_NONE,SPF_NONE 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: INBOX X-GMAIL-THRID: 1774189222981439648 X-GMAIL-MSGID: 1774189222981439648 Reuse common functions from pinctrl-intel driver. Signed-off-by: Raag Jadav --- drivers/pinctrl/intel/pinctrl-baytrail.c | 90 +++--------------------- 1 file changed, 11 insertions(+), 79 deletions(-) diff --git a/drivers/pinctrl/intel/pinctrl-baytrail.c b/drivers/pinctrl/intel/pinctrl-baytrail.c index 02ab5fd7cbd5..85f1aea2ca89 100644 --- a/drivers/pinctrl/intel/pinctrl-baytrail.c +++ b/drivers/pinctrl/intel/pinctrl-baytrail.c @@ -13,6 +13,7 @@ #include #include #include +#include #include #include #include @@ -551,25 +552,10 @@ static const struct intel_pinctrl_soc_data *byt_soc_data[] = { static DEFINE_RAW_SPINLOCK(byt_lock); -static struct intel_community *byt_get_community(struct intel_pinctrl *vg, - unsigned int pin) -{ - struct intel_community *comm; - int i; - - for (i = 0; i < vg->ncommunities; i++) { - comm = vg->communities + i; - if (pin < comm->pin_base + comm->npins && pin >= comm->pin_base) - return comm; - } - - return NULL; -} - static void __iomem *byt_gpio_reg(struct intel_pinctrl *vg, unsigned int offset, int reg) { - struct intel_community *comm = byt_get_community(vg, offset); + struct intel_community *comm = intel_get_community(vg, offset); u32 reg_offset; if (!comm) @@ -591,68 +577,12 @@ static void __iomem *byt_gpio_reg(struct intel_pinctrl *vg, unsigned int offset, return comm->pad_regs + reg_offset + reg; } -static int byt_get_groups_count(struct pinctrl_dev *pctldev) -{ - struct intel_pinctrl *vg = pinctrl_dev_get_drvdata(pctldev); - - return vg->soc->ngroups; -} - -static const char *byt_get_group_name(struct pinctrl_dev *pctldev, - unsigned int selector) -{ - struct intel_pinctrl *vg = pinctrl_dev_get_drvdata(pctldev); - - return vg->soc->groups[selector].grp.name; -} - -static int byt_get_group_pins(struct pinctrl_dev *pctldev, - unsigned int selector, - const unsigned int **pins, - unsigned int *num_pins) -{ - struct intel_pinctrl *vg = pinctrl_dev_get_drvdata(pctldev); - - *pins = vg->soc->groups[selector].grp.pins; - *num_pins = vg->soc->groups[selector].grp.npins; - - return 0; -} - static const struct pinctrl_ops byt_pinctrl_ops = { - .get_groups_count = byt_get_groups_count, - .get_group_name = byt_get_group_name, - .get_group_pins = byt_get_group_pins, + .get_groups_count = intel_get_groups_count, + .get_group_name = intel_get_group_name, + .get_group_pins = intel_get_group_pins, }; -static int byt_get_functions_count(struct pinctrl_dev *pctldev) -{ - struct intel_pinctrl *vg = pinctrl_dev_get_drvdata(pctldev); - - return vg->soc->nfunctions; -} - -static const char *byt_get_function_name(struct pinctrl_dev *pctldev, - unsigned int selector) -{ - struct intel_pinctrl *vg = pinctrl_dev_get_drvdata(pctldev); - - return vg->soc->functions[selector].func.name; -} - -static int byt_get_function_groups(struct pinctrl_dev *pctldev, - unsigned int selector, - const char * const **groups, - unsigned int *ngroups) -{ - struct intel_pinctrl *vg = pinctrl_dev_get_drvdata(pctldev); - - *groups = vg->soc->functions[selector].func.groups; - *ngroups = vg->soc->functions[selector].func.ngroups; - - return 0; -} - static void byt_set_group_simple_mux(struct intel_pinctrl *vg, const struct intel_pingroup group, unsigned int func) @@ -851,9 +781,9 @@ static int byt_gpio_set_direction(struct pinctrl_dev *pctl_dev, } static const struct pinmux_ops byt_pinmux_ops = { - .get_functions_count = byt_get_functions_count, - .get_function_name = byt_get_function_name, - .get_function_groups = byt_get_function_groups, + .get_functions_count = intel_get_functions_count, + .get_function_name = intel_get_function_name, + .get_function_groups = intel_get_function_groups, .set_mux = byt_set_mux, .gpio_request_enable = byt_gpio_request_enable, .gpio_disable_free = byt_gpio_disable_free, @@ -1261,7 +1191,7 @@ static void byt_gpio_dbg_show(struct seq_file *s, struct gpio_chip *chip) val = readl(val_reg); raw_spin_unlock_irqrestore(&byt_lock, flags); - comm = byt_get_community(vg, pin); + comm = intel_get_community(vg, pin); if (!comm) { seq_printf(s, "Pin %i: can't retrieve community\n", pin); continue; @@ -1848,3 +1778,5 @@ static int __init byt_gpio_init(void) return platform_driver_register(&byt_gpio_driver); } subsys_initcall(byt_gpio_init); + +MODULE_IMPORT_NS(PINCTRL_INTEL);