linux-rockchip.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: Heiko Stuebner <heiko@sntech.de>
To: David Wu <david.wu@rock-chips.com>
Cc: linus.walleij@linaro.org, huangtao@rock-chips.com,
	linux-rockchip@lists.infradead.org, linux-gpio@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH v1 1/2] pinctrl: rockchip:Add input schmitt support
Date: Thu, 23 Feb 2017 17:51:41 +0100	[thread overview]
Message-ID: <48027259.fqOrTqXNdI@phil> (raw)
In-Reply-To: <1487068541-14120-2-git-send-email-david.wu@rock-chips.com>

Hi David,

Am Dienstag, 14. Februar 2017, 18:35:40 CET schrieb David Wu:
> From: "david.wu" <david.wu@rock-chips.com>
> 
> To prevent external noise crosstalk, some pins need to
> enable input schmitt, like i2c pins, 32k-input pin and so on.
> 
> Signed-off-by: david.wu <david.wu@rock-chips.com>
> ---
>  drivers/pinctrl/pinctrl-rockchip.c | 69
> ++++++++++++++++++++++++++++++++++++++ 1 file changed, 69 insertions(+)
> 
> diff --git a/drivers/pinctrl/pinctrl-rockchip.c
> b/drivers/pinctrl/pinctrl-rockchip.c index a20ce9f..6a071b1 100644
> --- a/drivers/pinctrl/pinctrl-rockchip.c
> +++ b/drivers/pinctrl/pinctrl-rockchip.c
> @@ -308,6 +308,9 @@ struct rockchip_pin_ctrl {
>  				    int *reg, u8 *bit);
>  	void	(*iomux_recalc)(u8 bank_num, int pin, int *reg,
>  				u8 *bit, int *mask);
> +	void	(*schmitt_calc_reg)(struct rockchip_pin_bank *bank,
> +				    int pin_num, struct regmap **regmap,
> +				    int *reg, u8 *bit);
>  };
> 
>  struct rockchip_pin_config {
> @@ -1355,6 +1358,53 @@ static int rockchip_set_pull(struct rockchip_pin_bank
> *bank, return ret;
>  }
> 
> +static int rockchip_get_schmitt(struct rockchip_pin_bank *bank, int
> pin_num) +{
> +	struct rockchip_pinctrl *info = bank->drvdata;
> +	struct rockchip_pin_ctrl *ctrl = info->ctrl;
> +	struct regmap *regmap;
> +	int reg, ret;
> +	u8 bit;
> +	u32 data;
> +
> +	ctrl->schmitt_calc_reg(bank, pin_num, &regmap, &reg, &bit);

we might want to have and check an actual return value here.
On things like the rk3288 only some special pins have these schmitt triggers 
it seems, so we might want to abort if something tries to access an 
unsupported one.

> +
> +	ret = regmap_read(regmap, reg, &data);
> +	if (ret)
> +		return ret;
> +
> +	data >>= bit;
> +	return data & 0x1;

The mask seems to also be variable, for example on the rk3399 there seem to be 
multiple "levels" for at least gpio2. So your calc-callback might want to also 
set the right mask.

Otherwise looks good.


Heiko


  reply	other threads:[~2017-02-23 16:51 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-02-14 10:35 [PATCH v1 0/2] Add pinctrl input schmitt support David Wu
     [not found] ` <1487068541-14120-1-git-send-email-david.wu-TNX95d0MmH7DzftRWevZcw@public.gmane.org>
2017-02-14 10:35   ` [PATCH v1 1/2] pinctrl: rockchip:Add " David Wu
2017-02-23 16:51     ` Heiko Stuebner [this message]
2017-02-28 11:12       ` David.Wu
2017-02-14 10:35 ` [PATCH v1 2/2] pinctrl: rockchip: Add input schmitt support for rk3328 David Wu
2017-02-23 16:53   ` Heiko Stuebner
2017-02-22 15:04 ` [PATCH v1 0/2] Add pinctrl input schmitt support Linus Walleij

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=48027259.fqOrTqXNdI@phil \
    --to=heiko@sntech.de \
    --cc=david.wu@rock-chips.com \
    --cc=huangtao@rock-chips.com \
    --cc=linus.walleij@linaro.org \
    --cc=linux-gpio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-rockchip@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).