Received: by 2002:a25:31c3:0:0:0:0:0 with SMTP id x186csp5836271ybx; Sun, 10 Nov 2019 22:45:06 -0800 (PST) X-Google-Smtp-Source: APXvYqzNCO23iQuCYC1ovCjiVYvZzfsqc7bnt+1pnEWZ9gqhaD/dK++jmh3s0GgjBUx1G8tmOFQc X-Received: by 2002:a17:906:c2d6:: with SMTP id ch22mr560466ejb.262.1573454706537; Sun, 10 Nov 2019 22:45:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1573454706; cv=none; d=google.com; s=arc-20160816; b=V02MACdCo0ZzaPPU7ph087N2xLi5HjbzpZDHjVstND9FNlyh2MpZiu4LJ7E149iK5F hZYd54xX/SXAuqs9ht+HqEGIyeKVqlkm2ygVFiqpgV/vD70nRbeVgxyrjQ+mSIAveb7p wIa85JQcGZA/uNN9c+st+S7/BA/0OnrqpvDA2Yz/6f/XFSpvy03rHOALmLVP4q5bm9Dt 00WyQXcLRDWGeDf96GtXKz13v7nXgW9Aqq+thqQtMStXGz2u+VqLKcVDLijn0A+mqROd mzAWonfixaKekITTkg2mHHUr/YDQiE06cZT0ZLYfCLAv5ETmibBWeyhC/bdFcidnkrsA 9wWg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=uQ+72HL7Vl3XlAr99k7Pf6jxNFzWncuNt13Tpq3Iehs=; b=bsQFwwKNBBbJGAs/IGjmN3+vkXVVcdqwE3ZbBrxD51HStVBx/eCJytSw2LjWY4yvpQ UG8hzONnxIAvsSzkdQhN/voeu/xtlgZEP5Y9nKc95SPT95PqAE0tFnqpRZeDVIsKe2Qw FHmx4KLa4UgnhfYgpx/Kxof5EEOcRCao4ARFeUkXjMeOtoRmuYKBjLUZjzeM9WojY5dS 1Mcw6jPRA3fxJpedx7WU6C2s/ENK4L48FiUd0y7OKSKO9xe0xUlxWeZ2Ma6Th8nvPqe8 sbgmX1FoNZoXa1dvrhFA7FF+f7xFGPCPl1/ZA+K5sUc2aULMGJKGHGFB34tiyKIzrUBn 5Rug== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c10si10185046eda.284.2019.11.10.22.44.42; Sun, 10 Nov 2019 22:45:06 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726853AbfKKGoO (ORCPT + 99 others); Mon, 11 Nov 2019 01:44:14 -0500 Received: from mail-sz.amlogic.com ([211.162.65.117]:21657 "EHLO mail-sz.amlogic.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726805AbfKKGoN (ORCPT ); Mon, 11 Nov 2019 01:44:13 -0500 Received: from [10.28.39.106] (10.28.39.106) by mail-sz.amlogic.com (10.28.11.5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1591.10; Mon, 11 Nov 2019 14:44:28 +0800 Subject: Re: [PATCH v5 1/3] pinctrl: meson: add a new callback for SoCs fixup To: Neil Armstrong , Linus Walleij , CC: Jerome Brunet , Kevin Hilman , Martin Blumenstingl , Carlo Caione , Rob Herring , Xingyu Chen , Jianxin Pan , Hanjie Lin , Mark Rutland , , , References: <1573203636-7436-1-git-send-email-qianggui.song@amlogic.com> <1573203636-7436-2-git-send-email-qianggui.song@amlogic.com> <54809378-d4b0-2013-eb22-d6570eff2a8c@baylibre.com> From: Qianggui Song Message-ID: Date: Mon, 11 Nov 2019 14:44:28 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.9.1 MIME-Version: 1.0 In-Reply-To: <54809378-d4b0-2013-eb22-d6570eff2a8c@baylibre.com> Content-Type: text/plain; charset="utf-8" Content-Language: en-US Content-Transfer-Encoding: 7bit X-Originating-IP: [10.28.39.106] X-ClientProxiedBy: mail-sz.amlogic.com (10.28.11.5) To mail-sz.amlogic.com (10.28.11.5) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2019/11/8 20:50, Neil Armstrong wrote: > Hi, > > On 08/11/2019 10:00, Qianggui Song wrote: >> In meson_pinctrl_parse_dt, it contains two parts: reg parsing and >> SoC relative fixup for AO. Several fixups in the same code make it hard >> to maintain, so move all fixups to each SoC's callback and make >> meson_pinctrl_parse_dt just do the reg parsing, separate these two >> parts.Overview of all current Meson SoCs fixup is as below: >> >> +------+--------------------------------------+--------------------------+ >> | | | | >> | SoC | EE domain | AO domain | >> +------+--------------------------------------+--------------------------+ >> |m8 | parse regs: | parse regs: | >> |m8b | gpio,mux,pull,pull-enable(skip ds) | gpio,mux,pull(skip ds)| >> |gxl | fixup: | fixup: | >> |gxbb | no | pull-enable = pull; | >> |axg | | | >> +------+--------------------------------------+--------------------------+ >> |g12a | parse regs: | parse regs: | >> |sm1 | gpio,mux,pull,pull-enable,ds | gpio,mux,ds | >> | | fixup: | fixup: | >> | | no | pull = gpio; | >> | | | pull-enable = gpio; | >> +------+--------------------------------------+--------------------------+ >> |a1 or | parse regs: | >> |later | gpio/mux (without ao domain) | >> |SoCs | fixup: | >> | | pull = gpio; pull-enable = gpio; ds = gpio; | >> +------+-----------------------------------------------------------------+ >> Since m8-axg share the same ao fixup, make a common function >> meson8_aobus_parse_dt_extra to do the job. >> >> Signed-off-by: Qianggui Song >> --- >> drivers/pinctrl/meson/pinctrl-meson-axg.c | 1 + >> drivers/pinctrl/meson/pinctrl-meson-g12a.c | 9 +++++++++ >> drivers/pinctrl/meson/pinctrl-meson-gxbb.c | 1 + >> drivers/pinctrl/meson/pinctrl-meson-gxl.c | 1 + >> drivers/pinctrl/meson/pinctrl-meson.c | 25 ++++++++++++++++++------- >> drivers/pinctrl/meson/pinctrl-meson.h | 5 +++++ >> drivers/pinctrl/meson/pinctrl-meson8.c | 1 + >> drivers/pinctrl/meson/pinctrl-meson8b.c | 1 + >> 8 files changed, 37 insertions(+), 7 deletions(-) >> >> diff --git a/drivers/pinctrl/meson/pinctrl-meson-axg.c b/drivers/pinctrl/meson/pinctrl-meson-axg.c >> index ad502eda4afa..072765db93d7 100644 >> --- a/drivers/pinctrl/meson/pinctrl-meson-axg.c >> +++ b/drivers/pinctrl/meson/pinctrl-meson-axg.c >> @@ -1066,6 +1066,7 @@ >> .num_banks = ARRAY_SIZE(meson_axg_aobus_banks), >> .pmx_ops = &meson_axg_pmx_ops, >> .pmx_data = &meson_axg_aobus_pmx_banks_data, >> + .parse_dt = meson8_aobus_parse_dt_extra, >> }; >> >> static const struct of_device_id meson_axg_pinctrl_dt_match[] = { >> diff --git a/drivers/pinctrl/meson/pinctrl-meson-g12a.c b/drivers/pinctrl/meson/pinctrl-meson-g12a.c >> index 582665fd362a..41850e3c0091 100644 >> --- a/drivers/pinctrl/meson/pinctrl-meson-g12a.c >> +++ b/drivers/pinctrl/meson/pinctrl-meson-g12a.c >> @@ -1362,6 +1362,14 @@ >> .num_pmx_banks = ARRAY_SIZE(meson_g12a_aobus_pmx_banks), >> }; >> >> +static int meson_g12a_aobus_parse_dt_extra(struct meson_pinctrl *pc) >> +{ >> + pc->reg_pull = pc->reg_gpio; >> + pc->reg_pullen = pc->reg_gpio; >> + >> + return 0; >> +} >> + >> static struct meson_pinctrl_data meson_g12a_periphs_pinctrl_data = { >> .name = "periphs-banks", >> .pins = meson_g12a_periphs_pins, >> @@ -1388,6 +1396,7 @@ >> .num_banks = ARRAY_SIZE(meson_g12a_aobus_banks), >> .pmx_ops = &meson_axg_pmx_ops, >> .pmx_data = &meson_g12a_aobus_pmx_banks_data, >> + .parse_dt = meson_g12a_aobus_parse_dt_extra, >> }; >> >> static const struct of_device_id meson_g12a_pinctrl_dt_match[] = { >> diff --git a/drivers/pinctrl/meson/pinctrl-meson-gxbb.c b/drivers/pinctrl/meson/pinctrl-meson-gxbb.c >> index 5bfa56f3847e..926b9997159a 100644 >> --- a/drivers/pinctrl/meson/pinctrl-meson-gxbb.c >> +++ b/drivers/pinctrl/meson/pinctrl-meson-gxbb.c >> @@ -851,6 +851,7 @@ >> .num_funcs = ARRAY_SIZE(meson_gxbb_aobus_functions), >> .num_banks = ARRAY_SIZE(meson_gxbb_aobus_banks), >> .pmx_ops = &meson8_pmx_ops, >> + .parse_dt = meson8_aobus_parse_dt_extra, >> }; >> >> static const struct of_device_id meson_gxbb_pinctrl_dt_match[] = { >> diff --git a/drivers/pinctrl/meson/pinctrl-meson-gxl.c b/drivers/pinctrl/meson/pinctrl-meson-gxl.c >> index 72c5373c8dc1..8b1a49f5da43 100644 >> --- a/drivers/pinctrl/meson/pinctrl-meson-gxl.c >> +++ b/drivers/pinctrl/meson/pinctrl-meson-gxl.c >> @@ -820,6 +820,7 @@ >> .num_funcs = ARRAY_SIZE(meson_gxl_aobus_functions), >> .num_banks = ARRAY_SIZE(meson_gxl_aobus_banks), >> .pmx_ops = &meson8_pmx_ops, >> + .parse_dt = meson8_aobus_parse_dt_extra, >> }; >> >> static const struct of_device_id meson_gxl_pinctrl_dt_match[] = { >> diff --git a/drivers/pinctrl/meson/pinctrl-meson.c b/drivers/pinctrl/meson/pinctrl-meson.c >> index 8bba9d053d9f..a812c6d986d9 100644 >> --- a/drivers/pinctrl/meson/pinctrl-meson.c >> +++ b/drivers/pinctrl/meson/pinctrl-meson.c >> @@ -625,7 +625,7 @@ static struct regmap *meson_map_resource(struct meson_pinctrl *pc, >> >> i = of_property_match_string(node, "reg-names", name); >> if (of_address_to_resource(node, i, &res)) >> - return ERR_PTR(-ENOENT); >> + return NULL; >> >> base = devm_ioremap_resource(pc->dev, &res); >> if (IS_ERR(base)) >> @@ -665,26 +665,24 @@ static int meson_pinctrl_parse_dt(struct meson_pinctrl *pc, >> pc->of_node = gpio_np; >> >> pc->reg_mux = meson_map_resource(pc, gpio_np, "mux"); >> - if (IS_ERR(pc->reg_mux)) { >> + if (IS_ERR_OR_NULL(pc->reg_mux)) { >> dev_err(pc->dev, "mux registers not found\n"); >> return PTR_ERR(pc->reg_mux); > > If pc->reg_mux is NULL, it will return "0" here, which is wrong. > > Either keep the return ERR_PTR(-ENOENT); in meson_map_resource, or > return pc->reg_mux ? -ENOENT : PTR_ERR(pc->reg_mux); > Thanks. ERR_PTR(-ENOENT) to NULL make below region easy to handle, I will change to "return pc->reg_mux ? -ENOENT : PTR_ERR(pc->reg_mux);" >> } >> >> pc->reg_gpio = meson_map_resource(pc, gpio_np, "gpio"); >> - if (IS_ERR(pc->reg_gpio)) { >> + if (IS_ERR_OR_NULL(pc->reg_gpio)) { >> dev_err(pc->dev, "gpio registers not found\n"); >> return PTR_ERR(pc->reg_gpio); > > Ditto will do as above. > >> } >> >> pc->reg_pull = meson_map_resource(pc, gpio_np, "pull"); >> - /* Use gpio region if pull one is not present */ >> if (IS_ERR(pc->reg_pull)) >> - pc->reg_pull = pc->reg_gpio; >> + pc->reg_pull = NULL; >> >> pc->reg_pullen = meson_map_resource(pc, gpio_np, "pull-enable"); >> - /* Use pull region if pull-enable one is not present */ >> if (IS_ERR(pc->reg_pullen)) >> - pc->reg_pullen = pc->reg_pull; >> + pc->reg_pullen = NULL; >> >> pc->reg_ds = meson_map_resource(pc, gpio_np, "ds"); >> if (IS_ERR(pc->reg_ds)) { >> @@ -692,6 +690,19 @@ static int meson_pinctrl_parse_dt(struct meson_pinctrl *pc, >> pc->reg_ds = NULL; >> } >> >> + if (pc->data->parse_dt) >> + return pc->data->parse_dt(pc); >> + >> + return 0; >> +} >> + >> +int meson8_aobus_parse_dt_extra(struct meson_pinctrl *pc) >> +{ >> + if (!pc->reg_pull) >> + return -EINVAL; >> + >> + pc->reg_pullen = pc->reg_pull; >> + >> return 0; >> } >> >> diff --git a/drivers/pinctrl/meson/pinctrl-meson.h b/drivers/pinctrl/meson/pinctrl-meson.h >> index c696f3241a36..bfa1d3599333 100644 >> --- a/drivers/pinctrl/meson/pinctrl-meson.h >> +++ b/drivers/pinctrl/meson/pinctrl-meson.h >> @@ -11,6 +11,8 @@ >> #include >> #include >> >> +struct meson_pinctrl; >> + >> /** >> * struct meson_pmx_group - a pinmux group >> * >> @@ -114,6 +116,7 @@ struct meson_pinctrl_data { >> unsigned int num_banks; >> const struct pinmux_ops *pmx_ops; >> void *pmx_data; >> + int (*parse_dt)(struct meson_pinctrl *pc); >> }; >> >> struct meson_pinctrl { >> @@ -171,3 +174,5 @@ int meson_pmx_get_groups(struct pinctrl_dev *pcdev, >> >> /* Common probe function */ >> int meson_pinctrl_probe(struct platform_device *pdev); >> +/* Common ao groups extra dt parse function for SoCs before g12a */ >> +int meson8_aobus_parse_dt_extra(struct meson_pinctrl *pc); >> diff --git a/drivers/pinctrl/meson/pinctrl-meson8.c b/drivers/pinctrl/meson/pinctrl-meson8.c >> index 0b97befa6335..dd17100efdcf 100644 >> --- a/drivers/pinctrl/meson/pinctrl-meson8.c >> +++ b/drivers/pinctrl/meson/pinctrl-meson8.c >> @@ -1103,6 +1103,7 @@ >> .num_funcs = ARRAY_SIZE(meson8_aobus_functions), >> .num_banks = ARRAY_SIZE(meson8_aobus_banks), >> .pmx_ops = &meson8_pmx_ops, >> + .parse_dt = &meson8_aobus_parse_dt_extra, >> }; >> >> static const struct of_device_id meson8_pinctrl_dt_match[] = { >> diff --git a/drivers/pinctrl/meson/pinctrl-meson8b.c b/drivers/pinctrl/meson/pinctrl-meson8b.c >> index a7de388388e6..2d5339edd0b7 100644 >> --- a/drivers/pinctrl/meson/pinctrl-meson8b.c >> +++ b/drivers/pinctrl/meson/pinctrl-meson8b.c >> @@ -962,6 +962,7 @@ >> .num_funcs = ARRAY_SIZE(meson8b_aobus_functions), >> .num_banks = ARRAY_SIZE(meson8b_aobus_banks), >> .pmx_ops = &meson8_pmx_ops, >> + .parse_dt = &meson8_aobus_parse_dt_extra, >> }; >> >> static const struct of_device_id meson8b_pinctrl_dt_match[] = { >> > > . >