Received: by 2002:ac0:aed5:0:0:0:0:0 with SMTP id t21csp2886163imb; Mon, 4 Mar 2019 17:16:51 -0800 (PST) X-Google-Smtp-Source: APXvYqyB8nJWMNkomC7ikuNfCVDolDujLyONhTMEDnOfx6lN7h1B+vbfaoBy9MFk09KSQ5xFPwwN X-Received: by 2002:a63:8743:: with SMTP id i64mr21121163pge.69.1551748611326; Mon, 04 Mar 2019 17:16:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1551748611; cv=none; d=google.com; s=arc-20160816; b=kFfZDnKA/mZe6jRIkq3wjnfLLmUVHH+awcf0OE3jJE7V7+LPxzmLHkFRqt32FDrh6X 3hkRlR8w87uGwPcnhfBRdSH4XhLCp9xlLEVeM9aWwtK6/A0NoRSBMF0TAHKRD/RIvM5R swBZGPstvHZ9MoesNJugAkXWZV0skmlbMwDw0AnEwlRLU2h/2/AhN2JbBLHWqYKfATpR QRx4/kfvT2OQNmbrKrQxWhiIoRLq+mrW6XTXvpbHE883x9LJ814MAwM8woPosANs45El B4MWwiqIQ/5HspCdE/Wx+bgFLNWt7ET5twDywMbBWIhDuEnmI/dy4BASSNEXQX7Tm7au 6+AA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=IEvP4g5lJTM3OFPEtoC3ByvwIpbcDNQCJQYv4o25Tks=; b=hBUjxVD4E4pwz/15Q2DCq/TvrwyWJEEOd5Hu3aLY9Tu3mgNqKDhQGA21EHkNaFxcEz 34HUu1u+g4g3hU/55eKMETwr8+KYYBErEC4x9KM822Nf9NVaHpA/HCiB6MhU6NFnS7MH /JaDE9M02QtHH0if+HOpFfAm96lmWY6Ow1xdbqiPkIk6UXkOJvXX4ZO2vrUboiHr7MfE 3mfTppL0WpruU6gFQLi7Bac4kw8mdu7HKV6Jt0WGfHNd8mNLi9xeO/rONYBNOmqxOfMT Nz44hi2XxT8TWPo5crThSQwW1oSrKTqham44+VefFOYcVK9lX1ocxRiwAd+ffPVsYVEO +bKg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=JyPwVPHG; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g3si7084935pld.325.2019.03.04.17.16.35; Mon, 04 Mar 2019 17:16:51 -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; dkim=pass header.i=@kernel.org header.s=default header.b=JyPwVPHG; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726889AbfCEBQL (ORCPT + 99 others); Mon, 4 Mar 2019 20:16:11 -0500 Received: from mail.kernel.org ([198.145.29.99]:54238 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726066AbfCEBQL (ORCPT ); Mon, 4 Mar 2019 20:16:11 -0500 Received: from mail-wr1-f47.google.com (mail-wr1-f47.google.com [209.85.221.47]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 1319820830; Tue, 5 Mar 2019 01:16:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1551748569; bh=511KmFJ6iE8xlIN/eeEImKZSeX9y1CjSr5j4vWH3Mq4=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=JyPwVPHGfDfOvCkrx/jb5u0JfMHaDu0ERHqyW97DAvq3dGpSdw3uAcm+kBj3t8sgD quE7K5dWkic5vcc1J8ARLEQLGmn34Bvdpe/Vp1wnp8Gdw9N33k35rfJu5KVSp5yBA6 mlDkXjwFyuQuyrLYDi49Srkf8CQg20c8x6x0kCOQ= Received: by mail-wr1-f47.google.com with SMTP id n2so7582692wrw.8; Mon, 04 Mar 2019 17:16:09 -0800 (PST) X-Gm-Message-State: APjAAAUXMehAy3WTLLogyIGQ7NF+L/msq3iseflkr9SmHRaxnJACVpYc 1AeOie6992JQyyEcbf1Zs6ZoOEBOcM170pdWK24= X-Received: by 2002:a5d:5410:: with SMTP id g16mr14027408wrv.214.1551748567450; Mon, 04 Mar 2019 17:16:07 -0800 (PST) MIME-Version: 1.0 References: <20190303015341.986-1-zhiyong.tao@mediatek.com> <20190303015341.986-2-zhiyong.tao@mediatek.com> In-Reply-To: <20190303015341.986-2-zhiyong.tao@mediatek.com> From: Sean Wang Date: Mon, 4 Mar 2019 17:15:55 -0800 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH] pinctrl: add drive for I2C related pins on MT8183 To: Zhiyong Tao Cc: Rob Herring , Linus Walleij , Mark Rutland , Matthias Brugger , srv_heupstream , Liguo Zhang , =?UTF-8?B?RWRkaWUgSHVhbmcgKOm7g+aZuuWCkSk=?= , =?UTF-8?B?SG9uZ2t1biBDYW8gKOabuea0quWdpCk=?= , Biao Huang , Hongzhou Yang , =?UTF-8?B?Q2h1YW5qaWEgTGl1ICjmn7PkvKDlmIkp?= , =?UTF-8?B?RXJpbiBMbyAo576F6ZuF6b2hKQ==?= , =?UTF-8?B?U2VhbiBXYW5nICjnjovlv5fkupgp?= , devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, linux-gpio@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, Mar 2, 2019 at 5:53 PM Zhiyong Tao wrote: > > This patch provides the advanced drive for I2C used pins on MT8183. > The detail strength specification description of the I2C pin is as follows. > When E1=0/E0=0, the strength is 0.125mA. > When E1=0/E0=1, the strength is 0.25mA. > When E1=1/E0=0, the strength is 0.5mA. > When E1=1/E0=1, the strength is 1mA. Three things are needed to be added The first is we need to add more words in the git message about what relationship between the specific driving setup and existing generic driving setup. The second is stating why we need to add extra vendor driving property in the patch is, instead of using the generic driving property. The third is we need to add the dt-binding document prior to the change. > > Signed-off-by: Zhiyong Tao > --- > drivers/pinctrl/mediatek/pinctrl-mt8183.c | 50 ++++++++++++++++++++++++ > drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.c | 45 +++++++++++++++++++++ > drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.h | 13 ++++++ > drivers/pinctrl/mediatek/pinctrl-paris.c | 20 ++++++++++ > 4 files changed, 128 insertions(+) > > diff --git a/drivers/pinctrl/mediatek/pinctrl-mt8183.c b/drivers/pinctrl/mediatek/pinctrl-mt8183.c > index 6262fd3678ea..f034574fc593 100644 > --- a/drivers/pinctrl/mediatek/pinctrl-mt8183.c > +++ b/drivers/pinctrl/mediatek/pinctrl-mt8183.c > @@ -472,6 +472,51 @@ static const struct mtk_pin_field_calc mt8183_pin_r1_range[] = { > PIN_FIELD_BASE(133, 133, 8, 0x0D0, 0x10, 13, 1), > }; > > +static const struct mtk_pin_field_calc mt8183_pin_e1e0en_range[] = { > + PIN_FIELD_BASE(48, 48, 3, 0x0F0, 0x10, 20, 1), > + PIN_FIELD_BASE(49, 49, 3, 0x0F0, 0x10, 15, 1), > + PIN_FIELD_BASE(50, 50, 4, 0x0F0, 0x10, 12, 1), > + PIN_FIELD_BASE(51, 51, 4, 0x0F0, 0x10, 7, 1), > + PIN_FIELD_BASE(81, 81, 5, 0x0F0, 0x10, 12, 1), > + PIN_FIELD_BASE(82, 82, 5, 0x0F0, 0x10, 9, 1), > + PIN_FIELD_BASE(83, 83, 5, 0x0F0, 0x10, 19, 1), > + PIN_FIELD_BASE(84, 84, 5, 0x0F0, 0x10, 22, 1), > + PIN_FIELD_BASE(103, 103, 6, 0x0F0, 0x10, 24, 1), > + PIN_FIELD_BASE(104, 104, 6, 0x0F0, 0x10, 14, 1), > + PIN_FIELD_BASE(105, 105, 6, 0x0F0, 0x10, 27, 1), > + PIN_FIELD_BASE(106, 106, 6, 0x0F0, 0x10, 17, 1), > +}; > + > +static const struct mtk_pin_field_calc mt8183_pin_e0_range[] = { > + PIN_FIELD_BASE(48, 48, 3, 0x0F0, 0x10, 21, 1), > + PIN_FIELD_BASE(49, 49, 3, 0x0F0, 0x10, 16, 1), > + PIN_FIELD_BASE(50, 50, 4, 0x0F0, 0x10, 13, 1), > + PIN_FIELD_BASE(51, 51, 4, 0x0F0, 0x10, 8, 1), > + PIN_FIELD_BASE(81, 81, 5, 0x0F0, 0x10, 13, 1), > + PIN_FIELD_BASE(82, 82, 5, 0x0F0, 0x10, 10, 1), > + PIN_FIELD_BASE(83, 83, 5, 0x0F0, 0x10, 20, 1), > + PIN_FIELD_BASE(84, 84, 5, 0x0F0, 0x10, 23, 1), > + PIN_FIELD_BASE(103, 103, 6, 0x0F0, 0x10, 25, 1), > + PIN_FIELD_BASE(104, 104, 6, 0x0F0, 0x10, 15, 1), > + PIN_FIELD_BASE(105, 105, 6, 0x0F0, 0x10, 28, 1), > + PIN_FIELD_BASE(106, 106, 6, 0x0F0, 0x10, 18, 1), > +}; > + > +static const struct mtk_pin_field_calc mt8183_pin_e1_range[] = { > + PIN_FIELD_BASE(48, 48, 3, 0x0F0, 0x10, 22, 1), > + PIN_FIELD_BASE(49, 49, 3, 0x0F0, 0x10, 17, 1), > + PIN_FIELD_BASE(50, 50, 4, 0x0F0, 0x10, 14, 1), > + PIN_FIELD_BASE(51, 51, 4, 0x0F0, 0x10, 9, 1), > + PIN_FIELD_BASE(81, 81, 5, 0x0F0, 0x10, 14, 1), > + PIN_FIELD_BASE(82, 82, 5, 0x0F0, 0x10, 11, 1), > + PIN_FIELD_BASE(83, 83, 5, 0x0F0, 0x10, 21, 1), > + PIN_FIELD_BASE(84, 84, 5, 0x0F0, 0x10, 24, 1), > + PIN_FIELD_BASE(103, 103, 6, 0x0F0, 0x10, 26, 1), > + PIN_FIELD_BASE(104, 104, 6, 0x0F0, 0x10, 16, 1), > + PIN_FIELD_BASE(105, 105, 6, 0x0F0, 0x10, 29, 1), > + PIN_FIELD_BASE(106, 106, 6, 0x0F0, 0x10, 19, 1), > +}; > + > static const struct mtk_pin_reg_calc mt8183_reg_cals[PINCTRL_PIN_REG_MAX] = { > [PINCTRL_PIN_REG_MODE] = MTK_RANGE(mt8183_pin_mode_range), > [PINCTRL_PIN_REG_DIR] = MTK_RANGE(mt8183_pin_dir_range), > @@ -485,6 +530,9 @@ static const struct mtk_pin_reg_calc mt8183_reg_cals[PINCTRL_PIN_REG_MAX] = { > [PINCTRL_PIN_REG_PUPD] = MTK_RANGE(mt8183_pin_pupd_range), > [PINCTRL_PIN_REG_R0] = MTK_RANGE(mt8183_pin_r0_range), > [PINCTRL_PIN_REG_R1] = MTK_RANGE(mt8183_pin_r1_range), > + [PINCTRL_PIN_REG_DRV_EN_DIS] = MTK_RANGE(mt8183_pin_e1e0en_range), > + [PINCTRL_PIN_REG_DRV_E0] = MTK_RANGE(mt8183_pin_e0_range), > + [PINCTRL_PIN_REG_DRV_E1] = MTK_RANGE(mt8183_pin_e1_range), > }; > > static const char * const mt8183_pinctrl_register_base_names[] = { > @@ -517,6 +565,8 @@ static const struct mtk_pin_soc mt8183_data = { > .drive_get = mtk_pinconf_drive_get_rev1, > .adv_pull_get = mtk_pinconf_adv_pull_get, > .adv_pull_set = mtk_pinconf_adv_pull_set, > + .adv_drive_get = mtk_pinconf_adv_drive_get, > + .adv_drive_set = mtk_pinconf_adv_drive_set, > }; > > static const struct of_device_id mt8183_pinctrl_of_match[] = { > diff --git a/drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.c b/drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.c > index 4a9e0d4c2bbc..da024279ec59 100644 > --- a/drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.c > +++ b/drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.c > @@ -668,3 +668,48 @@ int mtk_pinconf_adv_pull_get(struct mtk_pinctrl *hw, > > return 0; > } > + > +int mtk_pinconf_adv_drive_set(struct mtk_pinctrl *hw, > + const struct mtk_pin_desc *desc, bool enable, > + u32 arg) > +{ > + int err; > + > + err = mtk_hw_set_value(hw, desc, PINCTRL_PIN_REG_DRV_E0, arg & 1); > + if (err) > + return 0; return err; > + > + err = mtk_hw_set_value(hw, desc, PINCTRL_PIN_REG_DRV_E1, > + !!(arg & 2)); > + if (err) > + return 0; return err; > + > + arg = enable ? 1 : 0; > + > + err = mtk_hw_set_value(hw, desc, PINCTRL_PIN_REG_DRV_EN_DIS, arg); > + it looks like it is redundant operation to set e0 and e1 when we want to disable the advanced driving. > + return err; > +} > + > +int mtk_pinconf_adv_drive_get(struct mtk_pinctrl *hw, > + const struct mtk_pin_desc *desc, u32 *val) > +{ > + u32 en, e0, e1; > + int err; > + > + err = mtk_hw_get_value(hw, desc, PINCTRL_PIN_REG_DRV_EN_DIS, &en); > + if (err) > + return err; > + > + err = mtk_hw_get_value(hw, desc, PINCTRL_PIN_REG_DRV_E0, &e0); > + if (err) > + return err; > + > + err = mtk_hw_get_value(hw, desc, PINCTRL_PIN_REG_DRV_E1, &e1); > + if (err) > + return err; > + > + *val = (e0 | e1 << 1 | en << 2) & 0x7; > + > + return 0; > +} > diff --git a/drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.h b/drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.h > index 6d24522739d9..795a3b10d54e 100644 > --- a/drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.h > +++ b/drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.h > @@ -63,6 +63,9 @@ enum { > PINCTRL_PIN_REG_IES, > PINCTRL_PIN_REG_PULLEN, > PINCTRL_PIN_REG_PULLSEL, > + PINCTRL_PIN_REG_DRV_EN_DIS, > + PINCTRL_PIN_REG_DRV_E0, > + PINCTRL_PIN_REG_DRV_E1, > PINCTRL_PIN_REG_MAX, > }; > > @@ -224,6 +227,11 @@ struct mtk_pin_soc { > int (*adv_pull_get)(struct mtk_pinctrl *hw, > const struct mtk_pin_desc *desc, bool pullup, > u32 *val); > + int (*adv_drive_set)(struct mtk_pinctrl *hw, > + const struct mtk_pin_desc *desc, bool enable, > + u32 arg); > + int (*adv_drive_get)(struct mtk_pinctrl *hw, > + const struct mtk_pin_desc *desc, u32 *val); > > /* Specific driver data */ > void *driver_data; > @@ -287,5 +295,10 @@ int mtk_pinconf_adv_pull_set(struct mtk_pinctrl *hw, > int mtk_pinconf_adv_pull_get(struct mtk_pinctrl *hw, > const struct mtk_pin_desc *desc, bool pullup, > u32 *val); > +int mtk_pinconf_adv_drive_set(struct mtk_pinctrl *hw, > + const struct mtk_pin_desc *desc, bool enable, > + u32 arg); > +int mtk_pinconf_adv_drive_get(struct mtk_pinctrl *hw, > + const struct mtk_pin_desc *desc, u32 *val); > > #endif /* __PINCTRL_MTK_COMMON_V2_H */ > diff --git a/drivers/pinctrl/mediatek/pinctrl-paris.c b/drivers/pinctrl/mediatek/pinctrl-paris.c > index b59e10852bfb..8c473d48cd5f 100644 > --- a/drivers/pinctrl/mediatek/pinctrl-paris.c > +++ b/drivers/pinctrl/mediatek/pinctrl-paris.c > @@ -20,12 +20,16 @@ > #define MTK_PIN_CONFIG_RDSEL (PIN_CONFIG_END + 2) > #define MTK_PIN_CONFIG_PU_ADV (PIN_CONFIG_END + 3) > #define MTK_PIN_CONFIG_PD_ADV (PIN_CONFIG_END + 4) > +#define MTK_PIN_CONFIG_DRV_EN_ADV (PIN_CONFIG_END + 5) > +#define MTK_PIN_CONFIG_DRV_DIS_ADV (PIN_CONFIG_END + 6) > > static const struct pinconf_generic_params mtk_custom_bindings[] = { > {"mediatek,tdsel", MTK_PIN_CONFIG_TDSEL, 0}, > {"mediatek,rdsel", MTK_PIN_CONFIG_RDSEL, 0}, > {"mediatek,pull-up-adv", MTK_PIN_CONFIG_PU_ADV, 1}, > {"mediatek,pull-down-adv", MTK_PIN_CONFIG_PD_ADV, 1}, > + {"mediatek,drive-enable-adv", MTK_PIN_CONFIG_DRV_EN_ADV, 2}, > + {"mediatek,drive-disable-adv", MTK_PIN_CONFIG_DRV_DIS_ADV, 2}, adding a "mediatek,drive-strength-adv" is enough as the generic driving strength property doing. > }; > > #ifdef CONFIG_DEBUG_FS > @@ -34,6 +38,8 @@ static const struct pin_config_item mtk_conf_items[] = { > PCONFDUMP(MTK_PIN_CONFIG_RDSEL, "rdsel", NULL, true), > PCONFDUMP(MTK_PIN_CONFIG_PU_ADV, "pu-adv", NULL, true), > PCONFDUMP(MTK_PIN_CONFIG_PD_ADV, "pd-adv", NULL, true), > + PCONFDUMP(MTK_PIN_CONFIG_DRV_EN_ADV, "drive-enable-adv", NULL, true), > + PCONFDUMP(MTK_PIN_CONFIG_DRV_DIS_ADV, "drive-disable-adv", NULL, true), > }; > #endif > > @@ -311,6 +317,20 @@ static int mtk_pinconf_set(struct pinctrl_dev *pctldev, unsigned int pin, > return -ENOTSUPP; > } > break; > + case MTK_PIN_CONFIG_DRV_EN_ADV: > + case MTK_PIN_CONFIG_DRV_DIS_ADV: > + if (hw->soc->adv_drive_set) { > + bool enable; > + > + enable = param == MTK_PIN_CONFIG_DRV_EN_ADV; > + err = hw->soc->adv_drive_set(hw, desc, enable, > + arg); > + if (err) > + return err; > + } else { > + return -ENOTSUPP; > + } > + break; > default: > err = -ENOTSUPP; > } > -- > 2.12.5 >