mbox series

[v3,0/2] Add mmc driver for Sunplus SP7021 SOC

Message ID cover.1644398657.git.tonyhuang.sunplus@gmail.com
Headers show
Series Add mmc driver for Sunplus SP7021 SOC | expand

Message

Tony Huang Feb. 9, 2022, 10:41 a.m. UTC
This is a patch series for mmc driver for Sunplus SP7021 SOC.

Sunplus SP7021 is an ARM Cortex A7 (4 cores) based SoC. It integrates
many peripherals (ex: UART, I2C, SPI, SDIO, eMMC, USB, SD card and
etc.) into a single chip. It is designed for industrial control.

Refer to:
https://sunplus-tibbo.atlassian.net/wiki/spaces/doc/overview
https://tibbo.com/store/plus1.html

Tony Huang (2):
  dt-binding: mmc: Add mmc yaml file for Sunplus SP7021
  mmc: Add mmc driver for Sunplus SP7021

 .../devicetree/bindings/mmc/sunplus-mmc.yaml       |   76 +
 MAINTAINERS                                        |    7 +
 drivers/mmc/host/Kconfig                           |    9 +
 drivers/mmc/host/Makefile                          |    1 +
 drivers/mmc/host/sunplus_mmc.c                     | 2168 ++++++++++++++++++++
 5 files changed, 2261 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/mmc/sunplus-mmc.yaml
 create mode 100644 drivers/mmc/host/sunplus_mmc.c

Comments

Rob Herring Feb. 9, 2022, 7:07 p.m. UTC | #1
On Wed, Feb 09, 2022 at 06:41:06PM +0800, Tony Huang wrote:
> Add mmc yaml file for Sunplus SP7021
> 
> Signed-off-by: Tony Huang <tonyhuang.sunplus@gmail.com>
> ---
> Changes in v3:
>  - combine sdcard and eMMC into one driver.
> 
>  .../devicetree/bindings/mmc/sunplus-mmc.yaml       | 76 ++++++++++++++++++++++
>  MAINTAINERS                                        |  6 ++
>  2 files changed, 82 insertions(+)
>  create mode 100644 Documentation/devicetree/bindings/mmc/sunplus-mmc.yaml
> 
> diff --git a/Documentation/devicetree/bindings/mmc/sunplus-mmc.yaml b/Documentation/devicetree/bindings/mmc/sunplus-mmc.yaml
> new file mode 100644
> index 0000000..8f44d13
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/mmc/sunplus-mmc.yaml
> @@ -0,0 +1,76 @@
> +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
> +# Copyright (C) Sunplus Ltd. Co. 2021
> +%YAML 1.2
> +---
> +$id: http://devicetree.org/schemas/mmc/sunplus-mmc.yaml#
> +$schema: http://devicetree.org/meta-schemas/core.yaml#
> +
> +title: sunplus MMC controller
> +
> +allOf:
> +  - $ref: "mmc-controller.yaml"
> +
> +maintainers:
> +  - Tony Huang <tonyhuang.sunplus@gmail.com>
> +  - Li-hao Kuo <lhjeff911@gmail.com>
> +
> +properties:
> +  compatible:
> +    enum:
> +      - sunplus,sp7021-emmc
> +      - sunplus,sp7021-sdhci

Why are these still different? Looking at the driver, it seems the 
settings are the same for both. And for clock speeds, we have properties 
to control them as they can be board specific.

> +
> +  reg:
> +    maxItems: 1
> +
> +  interrupts:
> +    maxItems: 1
> +
> +  clocks:
> +    minItems: 1
> +
> +  resets:
> +    maxItems: 1
> +
> +  max-frequency: true
> +
> +required:
> +  - compatible
> +  - reg
> +  - interrupts
> +  - clocks
> +  - resets
> +
> +unevaluatedProperties: false
> +
> +examples:
> +  - |
> +    #include <dt-bindings/interrupt-controller/irq.h>
> +    #include <dt-bindings/interrupt-controller/arm-gic.h>
> +    mmc0: mmc@9c003b00 {
> +        compatible = "sunplus,sp7021-emmc";
> +        reg = <0x9c003b00 0x180>;
> +        interrupts = <20 IRQ_TYPE_LEVEL_HIGH>;
> +        clocks = <&clkc 0x4e>;
> +        resets = <&rstc 0x3e>;
> +        bus-width = <8>;
> +        max-frequency = <52000000>;
> +        non-removable;
> +        disable-wp;
> +        cap-mmc-highspeed;
> +        mmc-ddr-3_3v;
> +        no-sdio;
> +        no-sd;
> +    };
> +
> +    mmc1: mmc@9c003e80 {
> +       compatible = "sunplus,sp7021-sdhci";
> +       reg = <0x9c003e80 0x280>;
> +       interrupts = <21 IRQ_TYPE_LEVEL_HIGH>;
> +       clocks = <&clkc 0x4f>;
> +       resets = <&rstc 0x3f>;
> +       pinctrl-names = "default";
> +       pinctrl-0 = <&mmc1_mux &mmc1_mux_cd>;
> +       max-frequency = <52000000>;
> +    };
> +...
> diff --git a/MAINTAINERS b/MAINTAINERS
> index fb18ce7..cb46a55 100644
> --- a/MAINTAINERS
> +++ b/MAINTAINERS
> @@ -18242,6 +18242,12 @@ L:	netdev@vger.kernel.org
>  S:	Maintained
>  F:	drivers/net/ethernet/dlink/sundance.c
>  
> +SUNPLUS MMC DRIVER
> +M:	Tony Huang <tonyhuang.sunplus@gmail.com>
> +M:	Li-hao Kuo <lhjeff911@gmail.com>
> +S:	Maintained
> +F:	Documentation/devicetree/bindings/mmc/sunplu-mmc.yaml
> +
>  SUPERH
>  M:	Yoshinori Sato <ysato@users.sourceforge.jp>
>  M:	Rich Felker <dalias@libc.org>
> -- 
> 2.7.4
> 
>
Tony Huang 黃懷厚 Feb. 10, 2022, 8:56 a.m. UTC | #2
Dear Robh:

> Subject: Re: [PATCH v3 1/2] dt-binding: mmc: Add mmc yaml file for Sunplus
> SP7021
> 
> On Wed, Feb 09, 2022 at 06:41:06PM +0800, Tony Huang wrote:
> > Add mmc yaml file for Sunplus SP7021
> >
> > Signed-off-by: Tony Huang <tonyhuang.sunplus@gmail.com>
> > ---
> > Changes in v3:
> >  - combine sdcard and eMMC into one driver.
> >
> >  .../devicetree/bindings/mmc/sunplus-mmc.yaml       | 76
> ++++++++++++++++++++++
> >  MAINTAINERS                                        |  6 ++
> >  2 files changed, 82 insertions(+)
> >  create mode 100644
> > Documentation/devicetree/bindings/mmc/sunplus-mmc.yaml
> >
> > diff --git a/Documentation/devicetree/bindings/mmc/sunplus-mmc.yaml
> > b/Documentation/devicetree/bindings/mmc/sunplus-mmc.yaml
> > new file mode 100644
> > index 0000000..8f44d13
> > --- /dev/null
> > +++ b/Documentation/devicetree/bindings/mmc/sunplus-mmc.yaml
> > @@ -0,0 +1,76 @@
> > +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) # Copyright
> > +(C) Sunplus Ltd. Co. 2021 %YAML 1.2
> > +---
> > +$id: http://devicetree.org/schemas/mmc/sunplus-mmc.yaml#
> > +$schema: http://devicetree.org/meta-schemas/core.yaml#
> > +
> > +title: sunplus MMC controller
> > +
> > +allOf:
> > +  - $ref: "mmc-controller.yaml"
> > +
> > +maintainers:
> > +  - Tony Huang <tonyhuang.sunplus@gmail.com>
> > +  - Li-hao Kuo <lhjeff911@gmail.com>
> > +
> > +properties:
> > +  compatible:
> > +    enum:
> > +      - sunplus,sp7021-emmc
> > +      - sunplus,sp7021-sdhci
> 
> Why are these still different? Looking at the driver, it seems the settings are
> the same for both. And for clock speeds, we have properties to control them as
> they can be board specific.
> 

The register base address of emmc and sd card are different.
eMMC and sdcard are individual hardware settings

> > +
> > +  reg:
> > +    maxItems: 1
> > +
> > +  interrupts:
> > +    maxItems: 1
> > +
> > +  clocks:
> > +    minItems: 1
> > +
> > +  resets:
> > +    maxItems: 1
> > +
> > +  max-frequency: true
> > +
> > +required:
> > +  - compatible
> > +  - reg
> > +  - interrupts
> > +  - clocks
> > +  - resets
> > +
> > +unevaluatedProperties: false
> > +
> > +examples:
> > +  - |
> > +    #include <dt-bindings/interrupt-controller/irq.h>
> > +    #include <dt-bindings/interrupt-controller/arm-gic.h>
> > +    mmc0: mmc@9c003b00 {
> > +        compatible = "sunplus,sp7021-emmc";
> > +        reg = <0x9c003b00 0x180>;
> > +        interrupts = <20 IRQ_TYPE_LEVEL_HIGH>;
> > +        clocks = <&clkc 0x4e>;
> > +        resets = <&rstc 0x3e>;
> > +        bus-width = <8>;
> > +        max-frequency = <52000000>;
> > +        non-removable;
> > +        disable-wp;
> > +        cap-mmc-highspeed;
> > +        mmc-ddr-3_3v;
> > +        no-sdio;
> > +        no-sd;
> > +    };
> > +
> > +    mmc1: mmc@9c003e80 {
> > +       compatible = "sunplus,sp7021-sdhci";
> > +       reg = <0x9c003e80 0x280>;
> > +       interrupts = <21 IRQ_TYPE_LEVEL_HIGH>;
> > +       clocks = <&clkc 0x4f>;
> > +       resets = <&rstc 0x3f>;
> > +       pinctrl-names = "default";
> > +       pinctrl-0 = <&mmc1_mux &mmc1_mux_cd>;
> > +       max-frequency = <52000000>;
> > +    };
> > +...
> > diff --git a/MAINTAINERS b/MAINTAINERS index fb18ce7..cb46a55 100644
> > --- a/MAINTAINERS
> > +++ b/MAINTAINERS
> > @@ -18242,6 +18242,12 @@ L:	netdev@vger.kernel.org
> >  S:	Maintained
> >  F:	drivers/net/ethernet/dlink/sundance.c
> >
> > +SUNPLUS MMC DRIVER
> > +M:	Tony Huang <tonyhuang.sunplus@gmail.com>
> > +M:	Li-hao Kuo <lhjeff911@gmail.com>
> > +S:	Maintained
> > +F:	Documentation/devicetree/bindings/mmc/sunplu-mmc.yaml
> > +
> >  SUPERH
> >  M:	Yoshinori Sato <ysato@users.sourceforge.jp>
> >  M:	Rich Felker <dalias@libc.org>
> > --
> > 2.7.4
> >
> >
Ulf Hansson Feb. 11, 2022, 12:52 p.m. UTC | #3
On Thu, 10 Feb 2022 at 09:56, Tony Huang 黃懷厚 <tony.huang@sunplus.com> wrote:
>
> Dear Robh:
>
> > Subject: Re: [PATCH v3 1/2] dt-binding: mmc: Add mmc yaml file for Sunplus
> > SP7021
> >
> > On Wed, Feb 09, 2022 at 06:41:06PM +0800, Tony Huang wrote:
> > > Add mmc yaml file for Sunplus SP7021
> > >
> > > Signed-off-by: Tony Huang <tonyhuang.sunplus@gmail.com>
> > > ---
> > > Changes in v3:
> > >  - combine sdcard and eMMC into one driver.
> > >
> > >  .../devicetree/bindings/mmc/sunplus-mmc.yaml       | 76
> > ++++++++++++++++++++++
> > >  MAINTAINERS                                        |  6 ++
> > >  2 files changed, 82 insertions(+)
> > >  create mode 100644
> > > Documentation/devicetree/bindings/mmc/sunplus-mmc.yaml
> > >
> > > diff --git a/Documentation/devicetree/bindings/mmc/sunplus-mmc.yaml
> > > b/Documentation/devicetree/bindings/mmc/sunplus-mmc.yaml
> > > new file mode 100644
> > > index 0000000..8f44d13
> > > --- /dev/null
> > > +++ b/Documentation/devicetree/bindings/mmc/sunplus-mmc.yaml
> > > @@ -0,0 +1,76 @@
> > > +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) # Copyright
> > > +(C) Sunplus Ltd. Co. 2021 %YAML 1.2
> > > +---
> > > +$id: http://devicetree.org/schemas/mmc/sunplus-mmc.yaml#
> > > +$schema: http://devicetree.org/meta-schemas/core.yaml#
> > > +
> > > +title: sunplus MMC controller
> > > +
> > > +allOf:
> > > +  - $ref: "mmc-controller.yaml"
> > > +
> > > +maintainers:
> > > +  - Tony Huang <tonyhuang.sunplus@gmail.com>
> > > +  - Li-hao Kuo <lhjeff911@gmail.com>
> > > +
> > > +properties:
> > > +  compatible:
> > > +    enum:
> > > +      - sunplus,sp7021-emmc
> > > +      - sunplus,sp7021-sdhci
> >
> > Why are these still different? Looking at the driver, it seems the settings are
> > the same for both. And for clock speeds, we have properties to control them as
> > they can be board specific.
> >
>
> The register base address of emmc and sd card are different.
> eMMC and sdcard are individual hardware settings

When I looked at the previous version of the driver(s) that was
posted, I got the impression that you have some registers in the
controller that are specific for eMMC, SD or SDIO.

So, depending on how the controller is going to be used (for eMMC, SD
or SDIO) it's needs to be configured differently. Right?

If I got this right, I think you can instead use the existing common
DT properties, "no-sd", "no-sdio", "no-mmc" to explain how each
controller is configured.

Does this make sense to you?

Kind regards
Uffe
Tony Huang 黃懷厚 Feb. 14, 2022, 2:02 a.m. UTC | #4
Dear Uffe:

> Subject: Re: [PATCH v3 1/2] dt-binding: mmc: Add mmc yaml file for Sunplus
> SP7021
> 
> On Thu, 10 Feb 2022 at 09:56, Tony Huang 黃懷厚
> <tony.huang@sunplus.com> wrote:
> >
> > Dear Robh:
> >
> > > Subject: Re: [PATCH v3 1/2] dt-binding: mmc: Add mmc yaml file for
> > > Sunplus
> > > SP7021
> > >
> > > On Wed, Feb 09, 2022 at 06:41:06PM +0800, Tony Huang wrote:
> > > > Add mmc yaml file for Sunplus SP7021
> > > >
> > > > Signed-off-by: Tony Huang <tonyhuang.sunplus@gmail.com>
> > > > ---
> > > > Changes in v3:
> > > >  - combine sdcard and eMMC into one driver.
> > > >
> > > >  .../devicetree/bindings/mmc/sunplus-mmc.yaml       | 76
> > > ++++++++++++++++++++++
> > > >  MAINTAINERS                                        |  6 ++
> > > >  2 files changed, 82 insertions(+)  create mode 100644
> > > > Documentation/devicetree/bindings/mmc/sunplus-mmc.yaml
> > > >
> > > > diff --git
> > > > a/Documentation/devicetree/bindings/mmc/sunplus-mmc.yaml
> > > > b/Documentation/devicetree/bindings/mmc/sunplus-mmc.yaml
> > > > new file mode 100644
> > > > index 0000000..8f44d13
> > > > --- /dev/null
> > > > +++ b/Documentation/devicetree/bindings/mmc/sunplus-mmc.yaml
> > > > @@ -0,0 +1,76 @@
> > > > +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) #
> > > > +Copyright
> > > > +(C) Sunplus Ltd. Co. 2021 %YAML 1.2
> > > > +---
> > > > +$id: http://devicetree.org/schemas/mmc/sunplus-mmc.yaml#
> > > > +$schema: http://devicetree.org/meta-schemas/core.yaml#
> > > > +
> > > > +title: sunplus MMC controller
> > > > +
> > > > +allOf:
> > > > +  - $ref: "mmc-controller.yaml"
> > > > +
> > > > +maintainers:
> > > > +  - Tony Huang <tonyhuang.sunplus@gmail.com>
> > > > +  - Li-hao Kuo <lhjeff911@gmail.com>
> > > > +
> > > > +properties:
> > > > +  compatible:
> > > > +    enum:
> > > > +      - sunplus,sp7021-emmc
> > > > +      - sunplus,sp7021-sdhci
> > >
> > > Why are these still different? Looking at the driver, it seems the
> > > settings are the same for both. And for clock speeds, we have
> > > properties to control them as they can be board specific.
> > >
> >
> > The register base address of emmc and sd card are different.
> > eMMC and sdcard are individual hardware settings
> 
> When I looked at the previous version of the driver(s) that was posted, I got the
> impression that you have some registers in the controller that are specific for
> eMMC, SD or SDIO.
> 
> So, depending on how the controller is going to be used (for eMMC, SD or SDIO)
> it's needs to be configured differently. Right?
> 
> If I got this right, I think you can instead use the existing common DT
> properties, "no-sd", "no-sdio", "no-mmc" to explain how each controller is
> configured.
> 

OK, I will use DT> properties, "no-sd", "no-sdio", "no-mmc"  to explain how 
each controller is configured.
Thanks