mbox series

[00/11] add support for sam9x60 nand controller

Message ID 20190213085930.31578-1-tudor.ambarus@microchip.com
Headers show
Series add support for sam9x60 nand controller | expand

Message

Tudor Ambarus Feb. 13, 2019, 8:59 a.m. UTC
From: Tudor Ambarus <tudor.ambarus@microchip.com>

The sam9x60 board defines the CCFG_EBICSA register under SFR,
and not as a MATRIX register, as previous boards do.
NAND Flash I/Os are connected to D16–D23, thus
SFR_CCFG_EBICSA.NFD0_ON_D16 is set to 1.

Tested using mtd-utils.

- patches [1, 7] add support for the sam9x60 nand controller. I would
  suggest to get them through linux-mtd tree, if all agree.
- patch 8 can be taken by Alexandre
- patch 9 - SPDX change, can be taken by Lee
- patch 10 - SPDX change, can be taken by Alexandre
- patch 11 - SPDX change, should go through linux-mtd

dt compatible string for "microchip,sam9x60-sfr" has already been
submited at https://patchwork.kernel.org/patch/10799831/

Tudor Ambarus (11):
  ARM: at91: add sam9x60 SFR definitions
  memory: atmel-ebi: add generic name for ebi regmap
  dt-bindings: memory: atmel-ebi: add sam9x60 compatible
  memory: atmel-ebi: add sam9x60 EBI support
  mtd: rawnand: atmel: add generic name for EBICSA regmap
  dt-bindings: mtd: atmel-nand: add sam9x60 compatible
  mtd: rawnand: atmel: add sam9x60 nand controller support
  memory: atmel-ebi: move NUM_CS definition inside atmel-ebi
  mfd: syscon: atmel: switch to SPDX license identifiers
  memory: atmel-ebi: switch to SPDX license identifiers
  mtd: rawnand: atmel: switch to SPDX license identifiers

 .../bindings/memory-controllers/atmel,ebi.txt      |   1 +
 .../devicetree/bindings/mtd/atmel-nand.txt         |   1 +
 drivers/memory/atmel-ebi.c                         |  48 ++++++---
 drivers/mtd/nand/raw/atmel/nand-controller.c       | 117 ++++++++++++++++-----
 drivers/mtd/nand/raw/atmel/pmecc.c                 |   5 +-
 drivers/mtd/nand/raw/atmel/pmecc.h                 |   6 +-
 include/linux/mfd/syscon/atmel-matrix.h            |   7 +-
 include/linux/mfd/syscon/atmel-mc.h                |   6 +-
 include/linux/mfd/syscon/atmel-smc.h               |   5 +-
 include/linux/mfd/syscon/atmel-st.h                |   6 +-
 include/soc/at91/atmel-sfr.h                       |  34 ++++--
 11 files changed, 161 insertions(+), 75 deletions(-)

Comments

Alexandre Belloni Feb. 13, 2019, 10:52 a.m. UTC | #1
On 13/02/2019 08:59:44+0000, Tudor.Ambarus@microchip.com wrote:
> From: Tudor Ambarus <tudor.ambarus@microchip.com>
> 
> Keep generic names, as there are no conflicts with previous
> SFR definitions.
> 
> While touching bits, update AT91_OHCIICR_USB_SUSPEND to use
> GENMASK, replace unused AT91_OHCIICR_SUSPEND_A/B/C with a more
> generic macro, align values on tab-width.
> 
> Signed-off-by: Tudor Ambarus <tudor.ambarus@microchip.com>
Acked-by: Alexandre Belloni <alexandre.belloni@bootlin.com>

> ---
>  include/soc/at91/atmel-sfr.h | 34 +++++++++++++++++++++++++++-------
>  1 file changed, 27 insertions(+), 7 deletions(-)
> 
> diff --git a/include/soc/at91/atmel-sfr.h b/include/soc/at91/atmel-sfr.h
> index 482337af06b8..532fd784e86c 100644
> --- a/include/soc/at91/atmel-sfr.h
> +++ b/include/soc/at91/atmel-sfr.h
> @@ -14,21 +14,41 @@
>  #define _LINUX_MFD_SYSCON_ATMEL_SFR_H
>  
>  #define AT91_SFR_DDRCFG		0x04	/* DDR Configuration Register */
> +#define AT91_SFR_CCFG_EBICSA	0x04	/* EBI Chip Select Register */
>  /* 0x08 ~ 0x0c: Reserved */
>  #define AT91_SFR_OHCIICR	0x10	/* OHCI INT Configuration Register */
>  #define AT91_SFR_OHCIISR	0x14	/* OHCI INT Status Register */
>  #define AT91_SFR_UTMICKTRIM	0x30	/* UTMI Clock Trimming Register */
> +#define AT91_SFR_UTMISWAP	0x3c	/* UTMI DP/DM Pin Swapping Register */
> +#define AT91_SFR_LS		0x7c	/* Light Sleep Register */
>  #define AT91_SFR_I2SCLKSEL	0x90	/* I2SC Register */
> +#define AT91_SFR_WPMR		0xe4	/* Write Protection Mode Register */
>  
>  /* Field definitions */
> -#define AT91_OHCIICR_SUSPEND_A	BIT(8)
> -#define AT91_OHCIICR_SUSPEND_B	BIT(9)
> -#define AT91_OHCIICR_SUSPEND_C	BIT(10)
> +#define AT91_SFR_CCFG_EBI_CSA(cs, val)		((val) << (cs))
> +#define AT91_SFR_CCFG_EBI_DBPUC			BIT(8)
> +#define AT91_SFR_CCFG_EBI_DBPDC			BIT(9)
> +#define AT91_SFR_CCFG_EBI_DRIVE			BIT(17)
> +#define AT91_SFR_CCFG_NFD0_ON_D16		BIT(24)
> +#define AT91_SFR_CCFG_DDR_MP_EN			BIT(25)
>  
> -#define AT91_OHCIICR_USB_SUSPEND	(AT91_OHCIICR_SUSPEND_A | \
> -					 AT91_OHCIICR_SUSPEND_B | \
> -					 AT91_OHCIICR_SUSPEND_C)
> +#define AT91_SFR_OHCIICR_RES(x)			BIT(x)
> +#define AT91_SFR_OHCIICR_ARIE			BIT(4)
> +#define AT91_SFR_OHCIICR_APPSTART		BIT(5)
> +#define AT91_SFR_OHCIICR_USB_SUSP(x)		BIT(8 + (x))
> +#define AT91_SFR_OHCIICR_UDPPUDIS		BIT(23)
> +#define AT91_OHCIICR_USB_SUSPEND		GENMASK(10, 8)
>  
> -#define AT91_UTMICKTRIM_FREQ	GENMASK(1, 0)
> +#define AT91_SFR_OHCIISR_RIS(x)			BIT(x)
> +
> +#define AT91_UTMICKTRIM_FREQ			GENMASK(1, 0)
> +
> +#define AT91_SFR_UTMISWAP_PORT(x)		BIT(x)
> +
> +#define AT91_SFR_LS_VALUE(x)			BIT(x)
> +#define AT91_SFR_LS_MEM_POWER_GATING_ULP1_EN	BIT(16)
> +
> +#define AT91_SFR_WPMR_WPEN			BIT(0)
> +#define AT91_SFR_WPMR_WPKEY_MASK		GENMASK(31, 8)
>  
>  #endif /* _LINUX_MFD_SYSCON_ATMEL_SFR_H */
> -- 
> 2.9.5
>
Alexandre Belloni Feb. 13, 2019, 10:53 a.m. UTC | #2
On 13/02/2019 08:59:48+0000, Tudor.Ambarus@microchip.com wrote:
> From: Tudor Ambarus <tudor.ambarus@microchip.com>
> 
> The sam9x60 board defines the CCFG_EBICSA register under SFR,
> and not as a MATRIX register, as previous boards do. Add a
> more generic name for the EBI regmap as a prerequisite for
> sam9x60 ebi support.
> 
> Signed-off-by: Tudor Ambarus <tudor.ambarus@microchip.com>
Acked-by: Alexandre Belloni <alexandre.belloni@bootlin.com>

> ---
>  drivers/memory/atmel-ebi.c | 23 ++++++++++++++++-------
>  1 file changed, 16 insertions(+), 7 deletions(-)
> 
> diff --git a/drivers/memory/atmel-ebi.c b/drivers/memory/atmel-ebi.c
> index c3748b414c27..b45914cfa212 100644
> --- a/drivers/memory/atmel-ebi.c
> +++ b/drivers/memory/atmel-ebi.c
> @@ -36,6 +36,7 @@ struct atmel_ebi_dev {
>  struct atmel_ebi_caps {
>  	unsigned int available_cs;
>  	unsigned int ebi_csa_offs;
> +	const char *regmap_name;
>  	void (*get_config)(struct atmel_ebi_dev *ebid,
>  			   struct atmel_ebi_dev_config *conf);
>  	int (*xlate_config)(struct atmel_ebi_dev *ebid,
> @@ -47,7 +48,7 @@ struct atmel_ebi_caps {
>  
>  struct atmel_ebi {
>  	struct clk *clk;
> -	struct regmap *matrix;
> +	struct regmap *regmap;
>  	struct  {
>  		struct regmap *regmap;
>  		struct clk *clk;
> @@ -357,7 +358,7 @@ static int atmel_ebi_dev_setup(struct atmel_ebi *ebi, struct device_node *np,
>  		 * one "atmel,smc-" property is present.
>  		 */
>  		if (ebi->caps->ebi_csa_offs && apply)
> -			regmap_update_bits(ebi->matrix,
> +			regmap_update_bits(ebi->regmap,
>  					   ebi->caps->ebi_csa_offs,
>  					   BIT(cs), 0);
>  
> @@ -372,6 +373,7 @@ static int atmel_ebi_dev_setup(struct atmel_ebi *ebi, struct device_node *np,
>  static const struct atmel_ebi_caps at91sam9260_ebi_caps = {
>  	.available_cs = 0xff,
>  	.ebi_csa_offs = AT91SAM9260_MATRIX_EBICSA,
> +	.regmap_name = "atmel,matrix",
>  	.get_config = at91sam9_ebi_get_config,
>  	.xlate_config = atmel_ebi_xslate_smc_config,
>  	.apply_config = at91sam9_ebi_apply_config,
> @@ -380,6 +382,7 @@ static const struct atmel_ebi_caps at91sam9260_ebi_caps = {
>  static const struct atmel_ebi_caps at91sam9261_ebi_caps = {
>  	.available_cs = 0xff,
>  	.ebi_csa_offs = AT91SAM9261_MATRIX_EBICSA,
> +	.regmap_name = "atmel,matrix",
>  	.get_config = at91sam9_ebi_get_config,
>  	.xlate_config = atmel_ebi_xslate_smc_config,
>  	.apply_config = at91sam9_ebi_apply_config,
> @@ -388,6 +391,7 @@ static const struct atmel_ebi_caps at91sam9261_ebi_caps = {
>  static const struct atmel_ebi_caps at91sam9263_ebi0_caps = {
>  	.available_cs = 0x3f,
>  	.ebi_csa_offs = AT91SAM9263_MATRIX_EBI0CSA,
> +	.regmap_name = "atmel,matrix",
>  	.get_config = at91sam9_ebi_get_config,
>  	.xlate_config = atmel_ebi_xslate_smc_config,
>  	.apply_config = at91sam9_ebi_apply_config,
> @@ -396,6 +400,7 @@ static const struct atmel_ebi_caps at91sam9263_ebi0_caps = {
>  static const struct atmel_ebi_caps at91sam9263_ebi1_caps = {
>  	.available_cs = 0x7,
>  	.ebi_csa_offs = AT91SAM9263_MATRIX_EBI1CSA,
> +	.regmap_name = "atmel,matrix",
>  	.get_config = at91sam9_ebi_get_config,
>  	.xlate_config = atmel_ebi_xslate_smc_config,
>  	.apply_config = at91sam9_ebi_apply_config,
> @@ -404,6 +409,7 @@ static const struct atmel_ebi_caps at91sam9263_ebi1_caps = {
>  static const struct atmel_ebi_caps at91sam9rl_ebi_caps = {
>  	.available_cs = 0x3f,
>  	.ebi_csa_offs = AT91SAM9RL_MATRIX_EBICSA,
> +	.regmap_name = "atmel,matrix",
>  	.get_config = at91sam9_ebi_get_config,
>  	.xlate_config = atmel_ebi_xslate_smc_config,
>  	.apply_config = at91sam9_ebi_apply_config,
> @@ -412,6 +418,7 @@ static const struct atmel_ebi_caps at91sam9rl_ebi_caps = {
>  static const struct atmel_ebi_caps at91sam9g45_ebi_caps = {
>  	.available_cs = 0x3f,
>  	.ebi_csa_offs = AT91SAM9G45_MATRIX_EBICSA,
> +	.regmap_name = "atmel,matrix",
>  	.get_config = at91sam9_ebi_get_config,
>  	.xlate_config = atmel_ebi_xslate_smc_config,
>  	.apply_config = at91sam9_ebi_apply_config,
> @@ -420,6 +427,7 @@ static const struct atmel_ebi_caps at91sam9g45_ebi_caps = {
>  static const struct atmel_ebi_caps at91sam9x5_ebi_caps = {
>  	.available_cs = 0x3f,
>  	.ebi_csa_offs = AT91SAM9X5_MATRIX_EBICSA,
> +	.regmap_name = "atmel,matrix",
>  	.get_config = at91sam9_ebi_get_config,
>  	.xlate_config = atmel_ebi_xslate_smc_config,
>  	.apply_config = at91sam9_ebi_apply_config,
> @@ -543,13 +551,14 @@ static int atmel_ebi_probe(struct platform_device *pdev)
>  
>  	/*
>  	 * The sama5d3 does not provide an EBICSA register and thus does need
> -	 * to access the matrix registers.
> +	 * to access it.
>  	 */
>  	if (ebi->caps->ebi_csa_offs) {
> -		ebi->matrix =
> -			syscon_regmap_lookup_by_phandle(np, "atmel,matrix");
> -		if (IS_ERR(ebi->matrix))
> -			return PTR_ERR(ebi->matrix);
> +		ebi->regmap =
> +			syscon_regmap_lookup_by_phandle(np,
> +							ebi->caps->regmap_name);
> +		if (IS_ERR(ebi->regmap))
> +			return PTR_ERR(ebi->regmap);
>  	}
>  
>  	ret = of_property_read_u32(np, "#address-cells", &val);
> -- 
> 2.9.5
>
Alexandre Belloni Feb. 13, 2019, 10:54 a.m. UTC | #3
On 13/02/2019 08:59:55+0000, Tudor.Ambarus@microchip.com wrote:
> From: Tudor Ambarus <tudor.ambarus@microchip.com>
> 
> The sam9x60 board defines the CCFG_EBICSA register under SFR,
> and not as a MATRIX register, as previous boards do.
> 
> Signed-off-by: Tudor Ambarus <tudor.ambarus@microchip.com>
Acked-by: Alexandre Belloni <alexandre.belloni@bootlin.com>

> ---
>  drivers/memory/atmel-ebi.c | 14 ++++++++++++++
>  1 file changed, 14 insertions(+)
> 
> diff --git a/drivers/memory/atmel-ebi.c b/drivers/memory/atmel-ebi.c
> index b45914cfa212..0322df9dc249 100644
> --- a/drivers/memory/atmel-ebi.c
> +++ b/drivers/memory/atmel-ebi.c
> @@ -17,6 +17,7 @@
>  #include <linux/init.h>
>  #include <linux/of_device.h>
>  #include <linux/regmap.h>
> +#include <soc/at91/atmel-sfr.h>
>  
>  struct atmel_ebi_dev_config {
>  	int cs;
> @@ -440,6 +441,15 @@ static const struct atmel_ebi_caps sama5d3_ebi_caps = {
>  	.apply_config = sama5_ebi_apply_config,
>  };
>  
> +static const struct atmel_ebi_caps sam9x60_ebi_caps = {
> +	.available_cs = 0x3f,
> +	.ebi_csa_offs = AT91_SFR_CCFG_EBICSA,
> +	.regmap_name = "microchip,sfr",
> +	.get_config = at91sam9_ebi_get_config,
> +	.xlate_config = atmel_ebi_xslate_smc_config,
> +	.apply_config = at91sam9_ebi_apply_config,
> +};
> +
>  static const struct of_device_id atmel_ebi_id_table[] = {
>  	{
>  		.compatible = "atmel,at91sam9260-ebi",
> @@ -473,6 +483,10 @@ static const struct of_device_id atmel_ebi_id_table[] = {
>  		.compatible = "atmel,sama5d3-ebi",
>  		.data = &sama5d3_ebi_caps,
>  	},
> +	{
> +		.compatible = "microchip,sam9x60-ebi",
> +		.data = &sam9x60_ebi_caps,
> +	},
>  	{ /* sentinel */ }
>  };
>  
> -- 
> 2.9.5
>
Miquel Raynal April 1, 2019, 3:24 p.m. UTC | #4
Hi Tudor,

<Tudor.Ambarus@microchip.com> wrote on Wed, 13 Feb 2019 08:59:41 +0000:

> From: Tudor Ambarus <tudor.ambarus@microchip.com>
> 
> The sam9x60 board defines the CCFG_EBICSA register under SFR,
> and not as a MATRIX register, as previous boards do.
> NAND Flash I/Os are connected to D16–D23, thus
> SFR_CCFG_EBICSA.NFD0_ON_D16 is set to 1.
> 
> Tested using mtd-utils.
> 
> - patches [1, 7] add support for the sam9x60 nand controller. I would
>   suggest to get them through linux-mtd tree, if all agree.
> - patch 8 can be taken by Alexandre
> - patch 9 - SPDX change, can be taken by Lee
> - patch 10 - SPDX change, can be taken by Alexandre
> - patch 11 - SPDX change, should go through linux-mtd
> 
> dt compatible string for "microchip,sam9x60-sfr" has already been
> submited at https://patchwork.kernel.org/patch/10799831/
> 
> Tudor Ambarus (11):
>   ARM: at91: add sam9x60 SFR definitions
>   memory: atmel-ebi: add generic name for ebi regmap
>   dt-bindings: memory: atmel-ebi: add sam9x60 compatible
>   memory: atmel-ebi: add sam9x60 EBI support
>   mtd: rawnand: atmel: add generic name for EBICSA regmap
>   dt-bindings: mtd: atmel-nand: add sam9x60 compatible
>   mtd: rawnand: atmel: add sam9x60 nand controller support
>   memory: atmel-ebi: move NUM_CS definition inside atmel-ebi
>   mfd: syscon: atmel: switch to SPDX license identifiers
>   memory: atmel-ebi: switch to SPDX license identifiers
>   mtd: rawnand: atmel: switch to SPDX license identifiers
> 
>  .../bindings/memory-controllers/atmel,ebi.txt      |   1 +
>  .../devicetree/bindings/mtd/atmel-nand.txt         |   1 +
>  drivers/memory/atmel-ebi.c                         |  48 ++++++---
>  drivers/mtd/nand/raw/atmel/nand-controller.c       | 117 ++++++++++++++++-----
>  drivers/mtd/nand/raw/atmel/pmecc.c                 |   5 +-
>  drivers/mtd/nand/raw/atmel/pmecc.h                 |   6 +-
>  include/linux/mfd/syscon/atmel-matrix.h            |   7 +-
>  include/linux/mfd/syscon/atmel-mc.h                |   6 +-
>  include/linux/mfd/syscon/atmel-smc.h               |   5 +-
>  include/linux/mfd/syscon/atmel-st.h                |   6 +-
>  include/soc/at91/atmel-sfr.h                       |  34 ++++--
>  11 files changed, 161 insertions(+), 75 deletions(-)
> 


Patches 1-7 & 11 applied to
git://git.kernel.org/pub/scm/linux/kernel/git/mtd/linux.git on nand/next.


Thanks,
Miquèl
Lee Jones April 3, 2019, 10:08 a.m. UTC | #5
On Wed, 13 Feb 2019, Tudor.Ambarus@microchip.com wrote:

> From: Tudor Ambarus <tudor.ambarus@microchip.com>
> 
> Adopt the SPDX license identifiers to ease license compliance
> management.
> 
> Signed-off-by: Tudor Ambarus <tudor.ambarus@microchip.com>
> ---
>  include/linux/mfd/syscon/atmel-matrix.h | 6 +-----
>  include/linux/mfd/syscon/atmel-mc.h     | 6 +-----
>  include/linux/mfd/syscon/atmel-smc.h    | 5 +----
>  include/linux/mfd/syscon/atmel-st.h     | 6 +-----
>  4 files changed, 4 insertions(+), 19 deletions(-)

Applied, thanks.