mbox series

[v11,0/4] Mediatek pinctrl patch on mt8195

Message ID 20210830003603.31864-1-zhiyong.tao@mediatek.com
Headers show
Series Mediatek pinctrl patch on mt8195 | expand

Message

Zhiyong Tao Aug. 30, 2021, 12:35 a.m. UTC
This series includes 4 patches:
1.add rsel define.
2.change pull up/down description
3.add pm_ops.
4.add rsel setting.

Changes in patch v11:
1)add pm_ops fucntion support
2)change pull up/down description
3)add resistance value feature support.

Changes in patch v10:
1)fix PARENTHESIS_ALIGNMENT of mtk_pinconf_bias_set_rsel
2)fix LONG_LINE warning in 615 in pinctrl-paris.c.

Changes in patch v9:
1)fix "mtk_pinconf_bias_set_rsel" build warning.

Changes in patch v8:
1)add rsel define patch
2)avoid  CamelCase
3)add pinctrl rsel setting patch which is another resistance selection
  solution for I2C on MT8195.

Changes in patch v7:
1)add version in patch and fix spelling mistakes.

Changes in patch v6:
1)add "pintcrl: mediatek" as prefix.

Changes in patch v5:
1)document and driver patch are apploed.
2)change '-EOPNOTSUPP' to '-ENOTSUPP'

Changes in patch v4:
1)fix pinctrl-mt8195.yaml warning error.
2)remove pinctrl device node patch which is based on "mt8195.dtsi".

Changes in patch v3:
1)change '^pins' to '-pins$'.
2)change 'state_0_node_a' to 'gpio_pin' which is defined in dts.
3)change 'state_0_node_b' to 'i2c0_pin' which is defined in dts.
4)reorder this series patches. change pinctrl file and binding document
together in one patch.

There are no changes in v1 & v2.

Zhiyong Tao (4):
dt-bindings: pinctrl: mt8195: add rsel define
  dt-bindings: pinctrl: mt8195: change pull up/down description
  pinctrl: mediatek: mt8195: Add pm_ops
  pinctrl: mediatek: add rsel setting on MT8195

 .../bindings/pinctrl/pinctrl-mt8195.yaml      |  32 +++-
 drivers/pinctrl/mediatek/pinctrl-mt8195.c     | 134 +++++++++++++
 .../pinctrl/mediatek/pinctrl-mtk-common-v2.c  | 181 ++++++++++++++++--
 .../pinctrl/mediatek/pinctrl-mtk-common-v2.h  |  35 +++-
 drivers/pinctrl/mediatek/pinctrl-paris.c      |  24 ++-
 drivers/pinctrl/mediatek/pinctrl-paris.h      |   2 +-
 include/dt-bindings/pinctrl/mt65xx.h          |   9 +
 7 files changed, 387 insertions(+), 30 deletions(-)

--
2.18.0

Comments

Rob Herring (Arm) Aug. 31, 2021, 10:09 p.m. UTC | #1
On Mon, 30 Aug 2021 08:36:00 +0800, Zhiyong Tao wrote:
> This patch adds rsel define for mt8195.

> 

> Signed-off-by: Zhiyong Tao <zhiyong.tao@mediatek.com>

> ---

>  include/dt-bindings/pinctrl/mt65xx.h | 9 +++++++++

>  1 file changed, 9 insertions(+)

> 


Acked-by: Rob Herring <robh@kernel.org>
Rob Herring (Arm) Aug. 31, 2021, 10:13 p.m. UTC | #2
On Mon, Aug 30, 2021 at 08:36:01AM +0800, Zhiyong Tao wrote:
> Change pull up/down description

Every commit is a 'change'. Your commit msg should explain 'why', not 
what the diff is.

> 
> Signed-off-by: Zhiyong Tao <zhiyong.tao@mediatek.com>
> ---
>  .../bindings/pinctrl/pinctrl-mt8195.yaml      | 32 +++++++++++++++++--
>  1 file changed, 29 insertions(+), 3 deletions(-)
> 
> diff --git a/Documentation/devicetree/bindings/pinctrl/pinctrl-mt8195.yaml b/Documentation/devicetree/bindings/pinctrl/pinctrl-mt8195.yaml
> index 2f12ec59eee5..a341ed9f0095 100644
> --- a/Documentation/devicetree/bindings/pinctrl/pinctrl-mt8195.yaml
> +++ b/Documentation/devicetree/bindings/pinctrl/pinctrl-mt8195.yaml
> @@ -85,9 +85,35 @@ patternProperties:
>            2/4/6/8/10/12/14/16mA in mt8195.
>          enum: [0, 1, 2, 3, 4, 5, 6, 7]
>  
> -      bias-pull-down: true
> -
> -      bias-pull-up: true
> +      bias-pull-down:
> +        description: |
> +          For pull down type is normal, it don't need add RSEL & R1R0 define
> +          and resistance value.
> +          For pull down type is PUPD/R0/R1 type, it can add R1R0 define to
> +          set different resistance. It can support "MTK_PUPD_SET_R1R0_00" &
> +          "MTK_PUPD_SET_R1R0_01" & "MTK_PUPD_SET_R1R0_10" & "MTK_PUPD_SET_R1R0_11"
> +          define in mt8195.
> +          For pull down type is RSEL, it can add RSEL define & resistance value(ohm)
> +          to set different resistance. It can support "MTK_PULL_SET_RSEL_000" &
> +          "MTK_PULL_SET_RSEL_001" & "MTK_PULL_SET_RSEL_010" & "MTK_PULL_SET_RSEL_011" &
> +          "MTK_PULL_SET_RSEL_100" & "MTK_PULL_SET_RSEL_101" & "MTK_PULL_SET_RSEL_110" &
> +          "MTK_PULL_SET_RSEL_111" define in mt8195. It can also support resistance value(ohm)
> +          "75000" & "5000" in mt8195.

Sounds like constraints on the values. Please write a schema.

> +
> +      bias-pull-up:
> +        description: |
> +          For pull up type is normal, it don't need add RSEL & R1R0 define
> +          and resistance value.
> +          For pull up type is PUPD/R0/R1 type, it can add R1R0 define to
> +          set different resistance. It can support "MTK_PUPD_SET_R1R0_00" &
> +          "MTK_PUPD_SET_R1R0_01" & "MTK_PUPD_SET_R1R0_10" & "MTK_PUPD_SET_R1R0_11"
> +          define in mt8195.
> +          For pull up type is RSEL, it can add RSEL define & resistance value(ohm)
> +          to set different resistance. It can support "MTK_PULL_SET_RSEL_000" &
> +          "MTK_PULL_SET_RSEL_001" & "MTK_PULL_SET_RSEL_010" & "MTK_PULL_SET_RSEL_011" &
> +          "MTK_PULL_SET_RSEL_100" & "MTK_PULL_SET_RSEL_101" & "MTK_PULL_SET_RSEL_110" &
> +          "MTK_PULL_SET_RSEL_111" define in mt8195. It can also support resistance value(ohm)
> +          "1000" & "1500" & "2000" & "3000" & "4000" & "5000" & "10000" & "75000" in mt8195.
>  
>        bias-disable: true
>  
> -- 
> 2.18.0
> 
>
Chen-Yu Tsai Sept. 1, 2021, 4:35 a.m. UTC | #3
On Mon, Aug 30, 2021 at 8:36 AM Zhiyong Tao <zhiyong.tao@mediatek.com> wrote:
>

> This patch adds rsel define for mt8195.

>

> Signed-off-by: Zhiyong Tao <zhiyong.tao@mediatek.com>

> ---

>  include/dt-bindings/pinctrl/mt65xx.h | 9 +++++++++

>  1 file changed, 9 insertions(+)

>

> diff --git a/include/dt-bindings/pinctrl/mt65xx.h b/include/dt-bindings/pinctrl/mt65xx.h

> index 7e16e58fe1f7..f5934abcd1bd 100644

> --- a/include/dt-bindings/pinctrl/mt65xx.h

> +++ b/include/dt-bindings/pinctrl/mt65xx.h

> @@ -16,6 +16,15 @@

>  #define MTK_PUPD_SET_R1R0_10 102

>  #define MTK_PUPD_SET_R1R0_11 103

>

> +#define MTK_PULL_SET_RSEL_000  200

> +#define MTK_PULL_SET_RSEL_001  201

> +#define MTK_PULL_SET_RSEL_010  202

> +#define MTK_PULL_SET_RSEL_011  203

> +#define MTK_PULL_SET_RSEL_100  204

> +#define MTK_PULL_SET_RSEL_101  205

> +#define MTK_PULL_SET_RSEL_110  206

> +#define MTK_PULL_SET_RSEL_111  207


Could you keep the spacing between constants tighter, or have no spacing
at all? Like having MTK_PULL_SET_RSEL_000 defined as 104 and so on. This
would reduce the chance of new macro values colliding with actual resistor
values set in the datasheets, plus a contiguous space would be easy to
rule as macros.

ChenYu

>  #define MTK_DRIVE_2mA  2

>  #define MTK_DRIVE_4mA  4

>  #define MTK_DRIVE_6mA  6

> --

> 2.18.0

> _______________________________________________

> Linux-mediatek mailing list

> Linux-mediatek@lists.infradead.org

> http://lists.infradead.org/mailman/listinfo/linux-mediatek
Chen-Yu Tsai Sept. 2, 2021, 3:35 a.m. UTC | #4
On Thu, Sep 2, 2021 at 10:54 AM zhiyong.tao <zhiyong.tao@mediatek.com> wrote:
>

> On Wed, 2021-09-01 at 12:35 +0800, Chen-Yu Tsai wrote:

> > On Mon, Aug 30, 2021 at 8:36 AM Zhiyong Tao <zhiyong.tao@mediatek.com> wrote:

> > >

> > > This patch adds rsel define for mt8195.

> > >

> > > Signed-off-by: Zhiyong Tao <zhiyong.tao@mediatek.com>

> > > ---

> > >  include/dt-bindings/pinctrl/mt65xx.h | 9 +++++++++

> > >  1 file changed, 9 insertions(+)

> > >

> > > diff --git a/include/dt-bindings/pinctrl/mt65xx.h b/include/dt-bindings/pinctrl/mt65xx.h

> > > index 7e16e58fe1f7..f5934abcd1bd 100644

> > > --- a/include/dt-bindings/pinctrl/mt65xx.h

> > > +++ b/include/dt-bindings/pinctrl/mt65xx.h

> > > @@ -16,6 +16,15 @@

> > >  #define MTK_PUPD_SET_R1R0_10 102

> > >  #define MTK_PUPD_SET_R1R0_11 103

> > >

> > > +#define MTK_PULL_SET_RSEL_000  200

> > > +#define MTK_PULL_SET_RSEL_001  201

> > > +#define MTK_PULL_SET_RSEL_010  202

> > > +#define MTK_PULL_SET_RSEL_011  203

> > > +#define MTK_PULL_SET_RSEL_100  204

> > > +#define MTK_PULL_SET_RSEL_101  205

> > > +#define MTK_PULL_SET_RSEL_110  206

> > > +#define MTK_PULL_SET_RSEL_111  207

> >

> > Could you keep the spacing between constants tighter, or have no spacing

> > at all? Like having MTK_PULL_SET_RSEL_000 defined as 104 and so on. This

> > would reduce the chance of new macro values colliding with actual resistor

> > values set in the datasheets, plus a contiguous space would be easy to

> > rule as macros.

> >

> > ChenYu

>

> Hi chenyu,

> By the current solution, it won't be mixed used by MTK_PULL_SET_RSEL_XXX

> and real  resistor value.

> If user use MTK_PULL_SET_RSEL_XXX, They don't care the define which

> means how much resistor value.


What I meant was that by keeping the value space tight, we avoid the
situation where in some new chip, one of the RSEL resistors happens to
be 200 or 300 ohms. 100 is already taken, so there's nothing we can
do if new designs actually do have 100 ohm settings.

> We think that we don't contiguous macro space for different register.

> It may increase code complexity to make having MTK_PULL_SET_RSEL_000

> defined as 104.


Can you elaborate? It is a simple range check and offset handling. Are
you concerned that a new design would have R2R1R0 and you would like
the macros to be contiguous?

BTW I don't quite get why decimal base values (100, 200, etc.) were
chosen. One would think that binary bases are easier to handle in code.


ChenYu

> Thanks.

>

> >

> > >  #define MTK_DRIVE_2mA  2

> > >  #define MTK_DRIVE_4mA  4

> > >  #define MTK_DRIVE_6mA  6

> > > --

> > > 2.18.0

> > > _______________________________________________

> > > Linux-mediatek mailing list

> > > Linux-mediatek@lists.infradead.org

> > > http://lists.infradead.org/mailman/listinfo/linux-mediatek

>
Chen-Yu Tsai Sept. 6, 2021, 8:20 a.m. UTC | #5
On Sat, Sep 4, 2021 at 4:40 PM zhiyong.tao <zhiyong.tao@mediatek.com> wrote:
>
> On Thu, 2021-09-02 at 11:35 +0800, Chen-Yu Tsai wrote:
> > On Thu, Sep 2, 2021 at 10:54 AM zhiyong.tao <zhiyong.tao@mediatek.com
> > > wrote:
> > >
> > > On Wed, 2021-09-01 at 12:35 +0800, Chen-Yu Tsai wrote:
> > > > On Mon, Aug 30, 2021 at 8:36 AM Zhiyong Tao <
> > > > zhiyong.tao@mediatek.com> wrote:
> > > > >
> > > > > This patch adds rsel define for mt8195.
> > > > >
> > > > > Signed-off-by: Zhiyong Tao <zhiyong.tao@mediatek.com>
> > > > > ---
> > > > >  include/dt-bindings/pinctrl/mt65xx.h | 9 +++++++++
> > > > >  1 file changed, 9 insertions(+)
> > > > >
> > > > > diff --git a/include/dt-bindings/pinctrl/mt65xx.h b/include/dt-
> > > > > bindings/pinctrl/mt65xx.h
> > > > > index 7e16e58fe1f7..f5934abcd1bd 100644
> > > > > --- a/include/dt-bindings/pinctrl/mt65xx.h
> > > > > +++ b/include/dt-bindings/pinctrl/mt65xx.h
> > > > > @@ -16,6 +16,15 @@
> > > > >  #define MTK_PUPD_SET_R1R0_10 102
> > > > >  #define MTK_PUPD_SET_R1R0_11 103
> > > > >
> > > > > +#define MTK_PULL_SET_RSEL_000  200
> > > > > +#define MTK_PULL_SET_RSEL_001  201
> > > > > +#define MTK_PULL_SET_RSEL_010  202
> > > > > +#define MTK_PULL_SET_RSEL_011  203
> > > > > +#define MTK_PULL_SET_RSEL_100  204
> > > > > +#define MTK_PULL_SET_RSEL_101  205
> > > > > +#define MTK_PULL_SET_RSEL_110  206
> > > > > +#define MTK_PULL_SET_RSEL_111  207
> > > >
> > > > Could you keep the spacing between constants tighter, or have no
> > > > spacing
> > > > at all? Like having MTK_PULL_SET_RSEL_000 defined as 104 and so
> > > > on. This
> > > > would reduce the chance of new macro values colliding with actual
> > > > resistor
> > > > values set in the datasheets, plus a contiguous space would be
> > > > easy to
> > > > rule as macros.
> > > >
> > > > ChenYu
> > >
> > > Hi chenyu,
> > > By the current solution, it won't be mixed used by
> > > MTK_PULL_SET_RSEL_XXX
> > > and real  resistor value.
> > > If user use MTK_PULL_SET_RSEL_XXX, They don't care the define which
> > > means how much resistor value.
> >
> > What I meant was that by keeping the value space tight, we avoid the
> > situation where in some new chip, one of the RSEL resistors happens
> > to
> > be 200 or 300 ohms. 100 is already taken, so there's nothing we can
> > do if new designs actually do have 100 ohm settings.
> >
> > > We think that we don't contiguous macro space for different
> > > register.
> > > It may increase code complexity to make having
> > > MTK_PULL_SET_RSEL_000
> > > defined as 104.
> >
> > Can you elaborate? It is a simple range check and offset handling.
> > Are
> > you concerned that a new design would have R2R1R0 and you would like
> > the macros to be contiguous?
> >
> > BTW I don't quite get why decimal base values (100, 200, etc.) were
> > chosen. One would think that binary bases are easier to handle in
> > code.
> >
> >
> > ChenYu
> >
>
> Yes,we concerned that a new design would have R2R1R0 and we would like
> the macros to be contiguous in the feature. we reserve it.

I see. That makes sense. Do you expect to see R3 or even R4 in the future?
Or put another way, do you expect to see resistor values of 150 or 200
supported?

Maybe we could reserve 200 and start from 201 for the RSEL macros?

Some planning needs to be done here to avoid value clashes.

> We think that decimal and binary base values are the same for the
> feature.

With decimal numbers you end up wasting a bit more space, since the
hardware is always using binary values. I just found it odd, that's
all.

ChenYu

> > > Thanks.
> > >
> > > >
> > > > >  #define MTK_DRIVE_2mA  2
> > > > >  #define MTK_DRIVE_4mA  4
> > > > >  #define MTK_DRIVE_6mA  6
> > > > > --
> > > > > 2.18.0
> > > > > _______________________________________________
> > > > > Linux-mediatek mailing list
> > > > > Linux-mediatek@lists.infradead.org
> > > > > http://lists.infradead.org/mailman/listinfo/linux-mediatek
Chen-Yu Tsai Sept. 15, 2021, 3:25 a.m. UTC | #6
On Tue, Sep 14, 2021 at 8:27 PM zhiyong.tao <zhiyong.tao@mediatek.com> wrote:
>
> On Mon, 2021-09-06 at 16:20 +0800, Chen-Yu Tsai wrote:
> > On Sat, Sep 4, 2021 at 4:40 PM zhiyong.tao <zhiyong.tao@mediatek.com>
> > wrote:
> > >
> > > On Thu, 2021-09-02 at 11:35 +0800, Chen-Yu Tsai wrote:
> > > > On Thu, Sep 2, 2021 at 10:54 AM zhiyong.tao <
> > > > zhiyong.tao@mediatek.com
> > > > > wrote:
> > > > >
> > > > > On Wed, 2021-09-01 at 12:35 +0800, Chen-Yu Tsai wrote:
> > > > > > On Mon, Aug 30, 2021 at 8:36 AM Zhiyong Tao <
> > > > > > zhiyong.tao@mediatek.com> wrote:
> > > > > > >
> > > > > > > This patch adds rsel define for mt8195.
> > > > > > >
> > > > > > > Signed-off-by: Zhiyong Tao <zhiyong.tao@mediatek.com>
> > > > > > > ---
> > > > > > >  include/dt-bindings/pinctrl/mt65xx.h | 9 +++++++++
> > > > > > >  1 file changed, 9 insertions(+)
> > > > > > >
> > > > > > > diff --git a/include/dt-bindings/pinctrl/mt65xx.h
> > > > > > > b/include/dt-
> > > > > > > bindings/pinctrl/mt65xx.h
> > > > > > > index 7e16e58fe1f7..f5934abcd1bd 100644
> > > > > > > --- a/include/dt-bindings/pinctrl/mt65xx.h
> > > > > > > +++ b/include/dt-bindings/pinctrl/mt65xx.h
> > > > > > > @@ -16,6 +16,15 @@
> > > > > > >  #define MTK_PUPD_SET_R1R0_10 102
> > > > > > >  #define MTK_PUPD_SET_R1R0_11 103
> > > > > > >
> > > > > > > +#define MTK_PULL_SET_RSEL_000  200
> > > > > > > +#define MTK_PULL_SET_RSEL_001  201
> > > > > > > +#define MTK_PULL_SET_RSEL_010  202
> > > > > > > +#define MTK_PULL_SET_RSEL_011  203
> > > > > > > +#define MTK_PULL_SET_RSEL_100  204
> > > > > > > +#define MTK_PULL_SET_RSEL_101  205
> > > > > > > +#define MTK_PULL_SET_RSEL_110  206
> > > > > > > +#define MTK_PULL_SET_RSEL_111  207
> > > > > >
> > > > > > Could you keep the spacing between constants tighter, or have
> > > > > > no
> > > > > > spacing
> > > > > > at all? Like having MTK_PULL_SET_RSEL_000 defined as 104 and
> > > > > > so
> > > > > > on. This
> > > > > > would reduce the chance of new macro values colliding with
> > > > > > actual
> > > > > > resistor
> > > > > > values set in the datasheets, plus a contiguous space would
> > > > > > be
> > > > > > easy to
> > > > > > rule as macros.
> > > > > >
> > > > > > ChenYu
> > > > >
> > > > > Hi chenyu,
> > > > > By the current solution, it won't be mixed used by
> > > > > MTK_PULL_SET_RSEL_XXX
> > > > > and real  resistor value.
> > > > > If user use MTK_PULL_SET_RSEL_XXX, They don't care the define
> > > > > which
> > > > > means how much resistor value.
> > > >
> > > > What I meant was that by keeping the value space tight, we avoid
> > > > the
> > > > situation where in some new chip, one of the RSEL resistors
> > > > happens
> > > > to
> > > > be 200 or 300 ohms. 100 is already taken, so there's nothing we
> > > > can
> > > > do if new designs actually do have 100 ohm settings.
> > > >
> > > > > We think that we don't contiguous macro space for different
> > > > > register.
> > > > > It may increase code complexity to make having
> > > > > MTK_PULL_SET_RSEL_000
> > > > > defined as 104.
> > > >
> > > > Can you elaborate? It is a simple range check and offset
> > > > handling.
> > > > Are
> > > > you concerned that a new design would have R2R1R0 and you would
> > > > like
> > > > the macros to be contiguous?
> > > >
> > > > BTW I don't quite get why decimal base values (100, 200, etc.)
> > > > were
> > > > chosen. One would think that binary bases are easier to handle in
> > > > code.
> > > >
> > > >
> > > > ChenYu
> > > >
> > >
> > > Yes,we concerned that a new design would have R2R1R0 and we would
> > > like
> > > the macros to be contiguous in the feature. we reserve it.
> >
> > I see. That makes sense. Do you expect to see R3 or even R4 in the
> > future?
> > Or put another way, do you expect to see resistor values of 150 or
> > 200
> > supported?
> >
> > Maybe we could reserve 200 and start from 201 for the RSEL macros?
> >
> > Some planning needs to be done here to avoid value clashes.
> >
> > > We think that decimal and binary base values are the same for the
> > > feature.
> >
> > With decimal numbers you end up wasting a bit more space, since the
> > hardware is always using binary values. I just found it odd, that's
> > all.
> >
> > ChenYu
> >
> > > > > Thanks.
>
> Hi ChenYu,
>
> In the next version, we provide a solution which we discussed internal
> to avoid value clashes.
>
> The solution:
> 1. We will keep the define "MTK_PULL_SET_RSEL_000 200". It won't
> change.
>
> 2. We will add a property in pio dtsi node, for example,
> the property name is "rsel_resistance_in_si_unit".
> We will add a flag "rsel_si_unit" in pinctrl device.
> in probe function, we will identify the property name
> "rsel_resistance_in_si_unit" to set the flag "rsel_si_unit" value.
> So it can void value clashes.

I suppose a "mediatek," prefix should be added. And to future proof
things this should probably apply to all bias-up/down values, so
"mediatek,bias-resistance-in-si-units"?

And the description should include something like that:

  Past usage of bias-up/down values included magic numbers to specify
  different hardware configurations based on register values. This
  property specifies that all values used for bias-up/down for this
  controller shall be in SI units.

And this proposal is still subject to maintainer (not me) review.


> 3.We will provide the define "MTK_PULL_SET_RSEL_000 200" and si unit
> two solution. users can support which solution by add property
> "rsel_resistance_in_si_unit" in dts node or not.

Thanks. I think this solution does provide a clear separation of the
two value spaces.

ChenYu

> > > > >
> > > > > >
> > > > > > >  #define MTK_DRIVE_2mA  2
> > > > > > >  #define MTK_DRIVE_4mA  4
> > > > > > >  #define MTK_DRIVE_6mA  6
> > > > > > > --
> > > > > > > 2.18.0
> > > > > > > _______________________________________________
> > > > > > > Linux-mediatek mailing list
> > > > > > > Linux-mediatek@lists.infradead.org
> > > > > > > http://lists.infradead.org/mailman/listinfo/linux-mediatek
Light Hsieh (謝明燈) Sept. 15, 2021, 5:01 a.m. UTC | #7
For backward compatible to previous usage and many customers of mediatek, MTK would not change previous usage of bias-pull-up and bias-pull-down setting usage.

The si unit usage will only apply to rsel only.

Please sto  give comments on changing mediatek's previous usage.

Light

-----Original Message-----
From: Chen-Yu Tsai [mailto:wenst@chromium.org] 

Sent: Wednesday, September 15, 2021 11:25 AM
To: Zhiyong Tao (陶志勇)
Cc: Rob Herring; Linus Walleij; Mark Rutland; Matthias Brugger; Sean Wang; srv_heupstream; Hui Liu (刘辉); Eddie Huang (黃智傑); Light Hsieh (謝明燈); Biao Huang (黄彪); Hongzhou Yang; Sean Wang; Seiya Wang (王迺君); Devicetree List; LKML; moderated list:ARM/FREESCALE IMX / MXC ARM ARCHITECTURE; moderated list:ARM/Mediatek SoC support; open list:GPIO SUBSYSTEM
Subject: Re: [PATCH v11 1/4] dt-bindings: pinctrl: mt8195: add rsel define

On Tue, Sep 14, 2021 at 8:27 PM zhiyong.tao <zhiyong.tao@mediatek.com> wrote:
>

> On Mon, 2021-09-06 at 16:20 +0800, Chen-Yu Tsai wrote:

> > On Sat, Sep 4, 2021 at 4:40 PM zhiyong.tao 

> > <zhiyong.tao@mediatek.com>

> > wrote:

> > >

> > > On Thu, 2021-09-02 at 11:35 +0800, Chen-Yu Tsai wrote:

> > > > On Thu, Sep 2, 2021 at 10:54 AM zhiyong.tao < 

> > > > zhiyong.tao@mediatek.com

> > > > > wrote:

> > > > >

> > > > > On Wed, 2021-09-01 at 12:35 +0800, Chen-Yu Tsai wrote:

> > > > > > On Mon, Aug 30, 2021 at 8:36 AM Zhiyong Tao < 

> > > > > > zhiyong.tao@mediatek.com> wrote:

> > > > > > >

> > > > > > > This patch adds rsel define for mt8195.

> > > > > > >

> > > > > > > Signed-off-by: Zhiyong Tao <zhiyong.tao@mediatek.com>

> > > > > > > ---

> > > > > > >  include/dt-bindings/pinctrl/mt65xx.h | 9 +++++++++

> > > > > > >  1 file changed, 9 insertions(+)

> > > > > > >

> > > > > > > diff --git a/include/dt-bindings/pinctrl/mt65xx.h

> > > > > > > b/include/dt-

> > > > > > > bindings/pinctrl/mt65xx.h

> > > > > > > index 7e16e58fe1f7..f5934abcd1bd 100644

> > > > > > > --- a/include/dt-bindings/pinctrl/mt65xx.h

> > > > > > > +++ b/include/dt-bindings/pinctrl/mt65xx.h

> > > > > > > @@ -16,6 +16,15 @@

> > > > > > >  #define MTK_PUPD_SET_R1R0_10 102  #define 

> > > > > > > MTK_PUPD_SET_R1R0_11 103

> > > > > > >

> > > > > > > +#define MTK_PULL_SET_RSEL_000  200 #define 

> > > > > > > +MTK_PULL_SET_RSEL_001  201 #define MTK_PULL_SET_RSEL_010  

> > > > > > > +202 #define MTK_PULL_SET_RSEL_011  203 #define 

> > > > > > > +MTK_PULL_SET_RSEL_100  204 #define MTK_PULL_SET_RSEL_101  

> > > > > > > +205 #define MTK_PULL_SET_RSEL_110  206 #define 

> > > > > > > +MTK_PULL_SET_RSEL_111  207

> > > > > >

> > > > > > Could you keep the spacing between constants tighter, or 

> > > > > > have no spacing at all? Like having MTK_PULL_SET_RSEL_000 

> > > > > > defined as 104 and so on. This would reduce the chance of 

> > > > > > new macro values colliding with actual resistor values set 

> > > > > > in the datasheets, plus a contiguous space would be easy to 

> > > > > > rule as macros.

> > > > > >

> > > > > > ChenYu

> > > > >

> > > > > Hi chenyu,

> > > > > By the current solution, it won't be mixed used by 

> > > > > MTK_PULL_SET_RSEL_XXX and real  resistor value.

> > > > > If user use MTK_PULL_SET_RSEL_XXX, They don't care the define 

> > > > > which means how much resistor value.

> > > >

> > > > What I meant was that by keeping the value space tight, we avoid 

> > > > the situation where in some new chip, one of the RSEL resistors 

> > > > happens to be 200 or 300 ohms. 100 is already taken, so there's 

> > > > nothing we can do if new designs actually do have 100 ohm 

> > > > settings.

> > > >

> > > > > We think that we don't contiguous macro space for different 

> > > > > register.

> > > > > It may increase code complexity to make having

> > > > > MTK_PULL_SET_RSEL_000

> > > > > defined as 104.

> > > >

> > > > Can you elaborate? It is a simple range check and offset 

> > > > handling.

> > > > Are

> > > > you concerned that a new design would have R2R1R0 and you would 

> > > > like the macros to be contiguous?

> > > >

> > > > BTW I don't quite get why decimal base values (100, 200, etc.) 

> > > > were chosen. One would think that binary bases are easier to 

> > > > handle in code.

> > > >

> > > >

> > > > ChenYu

> > > >

> > >

> > > Yes,we concerned that a new design would have R2R1R0 and we would 

> > > like the macros to be contiguous in the feature. we reserve it.

> >

> > I see. That makes sense. Do you expect to see R3 or even R4 in the 

> > future?

> > Or put another way, do you expect to see resistor values of 150 or

> > 200

> > supported?

> >

> > Maybe we could reserve 200 and start from 201 for the RSEL macros?

> >

> > Some planning needs to be done here to avoid value clashes.

> >

> > > We think that decimal and binary base values are the same for the 

> > > feature.

> >

> > With decimal numbers you end up wasting a bit more space, since the 

> > hardware is always using binary values. I just found it odd, that's 

> > all.

> >

> > ChenYu

> >

> > > > > Thanks.

>

> Hi ChenYu,

>

> In the next version, we provide a solution which we discussed internal 

> to avoid value clashes.

>

> The solution:

> 1. We will keep the define "MTK_PULL_SET_RSEL_000 200". It won't 

> change.

>

> 2. We will add a property in pio dtsi node, for example, the property 

> name is "rsel_resistance_in_si_unit".

> We will add a flag "rsel_si_unit" in pinctrl device.

> in probe function, we will identify the property name 

> "rsel_resistance_in_si_unit" to set the flag "rsel_si_unit" value.

> So it can void value clashes.


I suppose a "mediatek," prefix should be added. And to future proof things this should probably apply to all bias-up/down values, so "mediatek,bias-resistance-in-si-units"?

And the description should include something like that:

  Past usage of bias-up/down values included magic numbers to specify
  different hardware configurations based on register values. This
  property specifies that all values used for bias-up/down for this
  controller shall be in SI units.

And this proposal is still subject to maintainer (not me) review.


> 3.We will provide the define "MTK_PULL_SET_RSEL_000 200" and si unit 

> two solution. users can support which solution by add property 

> "rsel_resistance_in_si_unit" in dts node or not.


Thanks. I think this solution does provide a clear separation of the two value spaces.

ChenYu

> > > > >

> > > > > >

> > > > > > >  #define MTK_DRIVE_2mA  2

> > > > > > >  #define MTK_DRIVE_4mA  4

> > > > > > >  #define MTK_DRIVE_6mA  6

> > > > > > > --

> > > > > > > 2.18.0

> > > > > > > _______________________________________________

> > > > > > > Linux-mediatek mailing list 

> > > > > > > Linux-mediatek@lists.infradead.org

> > > > > > > https://urldefense.com/v3/__http://lists.infradead.org/mailman/listinfo/linux-mediatek__;!!CTRNKA9wMg0ARbw!zfqxZT9WYP_G3T1jav-FwDuN6JMr70ldR-lKVmyhZjYDkIBoyCz1FKT-RGI7cVhOQn4$