All of lore.kernel.org
 help / color / mirror / Atom feed
From: Stefano Babic <sbabic@denx.de>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH V2 09/20] mxc_ocotp: Update driver to support OCOTP controller on i.MX7ULP
Date: Sun, 12 Feb 2017 10:22:11 +0100	[thread overview]
Message-ID: <79793724-7153-5614-1dfe-fb516d67ad2f@denx.de> (raw)
In-Reply-To: <1482833066-29291-10-git-send-email-peng.fan@nxp.com>



On 27/12/2016 11:04, Peng Fan wrote:
> Update the mxc_ocotp driver to support i.MX7ULP.
> The read/write sequence has some changes due to
> PDN and OUT_STATUS registers added and TIME register is
> removed. Also update the bank size and number.
> 
> Add is_mx7ulp macro in sys_proto.h
> 
> Signed-off-by: Peng Fan <peng.fan@nxp.com>
> Signed-off-by: Ye Li <ye.li@nxp.com>
> Cc: Stefano Babic <sbabic@denx.de>
> ---
> 
> V2:
>  Add imx_mx7ulp, and small update.
> 
>  arch/arm/include/asm/imx-common/sys_proto.h |  2 ++
>  drivers/misc/mxc_ocotp.c                    | 52 ++++++++++++++++++++++++++++-
>  2 files changed, 53 insertions(+), 1 deletion(-)
> 
> diff --git a/arch/arm/include/asm/imx-common/sys_proto.h b/arch/arm/include/asm/imx-common/sys_proto.h
> index 539d34b..732b692 100644
> --- a/arch/arm/include/asm/imx-common/sys_proto.h
> +++ b/arch/arm/include/asm/imx-common/sys_proto.h
> @@ -38,6 +38,8 @@
>  #define is_mx6ull() (is_cpu_type(MXC_CPU_MX6ULL))
>  #define is_mx6sll() (is_cpu_type(MXC_CPU_MX6SLL))
>  
> +#define is_mx7ulp() (is_cpu_type(MXC_CPU_MX7ULP))
> +
>  u32 get_nr_cpus(void);
>  u32 get_cpu_rev(void);
>  u32 get_cpu_speed_grade_hz(void);
> diff --git a/drivers/misc/mxc_ocotp.c b/drivers/misc/mxc_ocotp.c
> index 0b1c050..88610d6 100644
> --- a/drivers/misc/mxc_ocotp.c
> +++ b/drivers/misc/mxc_ocotp.c
> @@ -29,6 +29,12 @@
>  #ifdef CONFIG_MX7
>  #define BM_CTRL_ADDR                    0x0000000f
>  #define BM_CTRL_RELOAD                  0x00000400
> +#elif defined(CONFIG_MX7ULP)
> +#define BM_CTRL_ADDR                    0x000000FF
> +#define BM_CTRL_RELOAD                  0x00000400
> +#define BM_OUT_STATUS_DED				0x00000400
> +#define BM_OUT_STATUS_LOCKED			0x00000800
> +#define BM_OUT_STATUS_PROGFAIL			0x00001000
>  #else
>  #define BM_CTRL_ADDR			0x0000007f
>  #endif
> @@ -70,6 +76,9 @@
>  #elif defined CONFIG_MX7
>  #define FUSE_BANK_SIZE	0x40
>  #define FUSE_BANKS	16
> +#elif defined(CONFIG_MX7ULP)
> +#define FUSE_BANK_SIZE	0x80
> +#define FUSE_BANKS	31
>  #else
>  #error "Unsupported architecture\n"
>  #endif
> @@ -98,7 +107,7 @@ u32 fuse_bank_physical(int index)
>  {
>  	u32 phy_index;
>  
> -	if (is_mx6sl()) {
> +	if (is_mx6sl() || is_mx7ulp()) {
>  		phy_index = index;
>  	} else if (is_mx6ul() || is_mx6ull() || is_mx6sll()) {
>  		if ((is_mx6ull() || is_mx6sll()) && index == 8)
> @@ -187,6 +196,10 @@ static int finish_access(struct ocotp_regs *regs, const char *caller)
>  	err = !!(readl(&regs->ctrl) & BM_CTRL_ERROR);
>  	clear_error(regs);
>  
> +#ifdef CONFIG_MX7ULP
> +	/* Need to power down the OTP memory */
> +	writel(1, &regs->pdn);
> +#endif
>  	if (err) {
>  		printf("mxc_ocotp %s(): Access protect error\n", caller);
>  		return -EIO;
> @@ -217,6 +230,13 @@ int fuse_read(u32 bank, u32 word, u32 *val)
>  
>  	*val = readl(&regs->bank[phy_bank].fuse_regs[phy_word << 2]);
>  
> +#ifdef CONFIG_MX7ULP
> +	if (readl(&regs->out_status) & BM_OUT_STATUS_DED) {
> +		writel(BM_OUT_STATUS_DED, &regs->out_status_clr);
> +		printf("mxc_ocotp %s(): fuse read wrong\n", __func__);
> +		return -EIO;
> +	}
> +#endif
>  	return finish_access(regs, __func__);
>  }
>  
> @@ -238,6 +258,12 @@ static void set_timing(struct ocotp_regs *regs)
>  	clrsetbits_le32(&regs->timing, BM_TIMING_FSOURCE | BM_TIMING_PROG,
>  			timing);
>  }
> +#elif defined(CONFIG_MX7ULP)
> +static void set_timing(struct ocotp_regs *regs)
> +{
> +	/* No timing set for MX7ULP */
> +}
> +
>  #else
>  static void set_timing(struct ocotp_regs *regs)
>  {
> @@ -302,6 +328,14 @@ int fuse_sense(u32 bank, u32 word, u32 *val)
>  	*val = readl(&regs->read_fuse_data);
>  #endif
>  
> +#ifdef CONFIG_MX7ULP
> +	if (readl(&regs->out_status) & BM_OUT_STATUS_DED) {
> +		writel(BM_OUT_STATUS_DED, &regs->out_status_clr);
> +		printf("mxc_ocotp %s(): fuse read wrong\n", __func__);
> +		return -EIO;
> +	}
> +#endif
> +
>  	return finish_access(regs, __func__);
>  }
>  
> @@ -355,6 +389,14 @@ int fuse_prog(u32 bank, u32 word, u32 val)
>  #endif
>  	udelay(WRITE_POSTAMBLE_US);
>  
> +#ifdef CONFIG_MX7ULP
> +	if (readl(&regs->out_status) & (BM_OUT_STATUS_PROGFAIL | BM_OUT_STATUS_LOCKED)) {
> +		writel((BM_OUT_STATUS_PROGFAIL | BM_OUT_STATUS_LOCKED), &regs->out_status_clr);
> +		printf("mxc_ocotp %s(): fuse write is failed\n", __func__);
> +		return -EIO;
> +	}
> +#endif
> +
>  	return finish_access(regs, __func__);
>  }
>  
> @@ -374,5 +416,13 @@ int fuse_override(u32 bank, u32 word, u32 val)
>  
>  	writel(val, &regs->bank[phy_bank].fuse_regs[phy_word << 2]);
>  
> +#ifdef CONFIG_MX7ULP
> +	if (readl(&regs->out_status) & (BM_OUT_STATUS_PROGFAIL | BM_OUT_STATUS_LOCKED)) {
> +		writel((BM_OUT_STATUS_PROGFAIL | BM_OUT_STATUS_LOCKED), &regs->out_status_clr);
> +		printf("mxc_ocotp %s(): fuse write is failed\n", __func__);
> +		return -EIO;
> +	}
> +#endif
> +
>  	return finish_access(regs, __func__);
>  }
> 

Reviewed-by : Stefano Babic <sbabic@denx.de>

Best regards,
Stefano Babic

-- 
=====================================================================
DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: sbabic at denx.de
=====================================================================

  reply	other threads:[~2017-02-12  9:22 UTC|newest]

Thread overview: 48+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-12-27 10:04 [U-Boot] [PATCH V2 00/20] imx: add i.MX7ULP support Peng Fan
2016-12-27 10:04 ` [U-Boot] [PATCH V2 01/20] imx: mx7ulp: Add mx7ulp to Kconfig Peng Fan
2017-02-12  8:39   ` Stefano Babic
2016-12-27 10:04 ` [U-Boot] [PATCH V2 02/20] imx: mx7ulp: add registers header file Peng Fan
2017-02-12  8:40   ` Stefano Babic
2016-12-27 10:04 ` [U-Boot] [PATCH V2 03/20] imx: mx7ulp: add iomux driver to support IOMUXC0 and IOMUXC1 Peng Fan
2017-02-12  8:45   ` Stefano Babic
2016-12-27 10:04 ` [U-Boot] [PATCH V2 04/20] imx: mx7ulp: Add clock framework and functions Peng Fan
2017-02-12  9:12   ` Stefano Babic
2016-12-27 10:04 ` [U-Boot] [PATCH V2 05/20] imx: mx7ulp: Add soc level initialization codes " Peng Fan
2017-02-12  9:19   ` Stefano Babic
2017-02-22  6:48     ` Peng Fan
2016-12-27 10:04 ` [U-Boot] [PATCH V2 06/20] imx: mx7ulp: handle all the lpuarts in get_lpuart_clk Peng Fan
2017-02-12  9:20   ` Stefano Babic
2016-12-27 10:04 ` [U-Boot] [PATCH V2 07/20] imx: mx7ulp: Implement the clock functions for i2c driver Peng Fan
2017-02-12  9:20   ` Stefano Babic
2016-12-27 10:04 ` [U-Boot] [PATCH V2 08/20] gpio: Add Rapid GPIO2P driver for i.MX7ULP Peng Fan
2017-02-12  9:21   ` Stefano Babic
2016-12-27 10:04 ` [U-Boot] [PATCH V2 09/20] mxc_ocotp: Update driver to support OCOTP controller on i.MX7ULP Peng Fan
2017-02-12  9:22   ` Stefano Babic [this message]
2016-12-27 10:04 ` [U-Boot] [PATCH V2 10/20] mx7ulp: Add iomux pins header file Peng Fan
2016-12-27 10:04 ` [U-Boot] [PATCH V2 11/20] wdog: Add the watchdog driver for MX7ULP Peng Fan
2017-02-12  9:25   ` Stefano Babic
2017-02-22  6:59     ` Peng Fan
2017-02-22  8:18       ` Stefano Babic
2016-12-27 10:04 ` [U-Boot] [PATCH V2 12/20] pinctrl: Add i.MX7ULP pinctrl driver Peng Fan
2017-01-12  5:07   ` Simon Glass
2017-02-12  9:25   ` Stefano Babic
2016-12-27 10:04 ` [U-Boot] [PATCH V2 13/20] i2c: lpi2c: add lpi2c driver for i.MX7ULP Peng Fan
2016-12-27 10:04 ` [U-Boot] [PATCH V2 14/20] serial: lpuart: restructure lpuart driver Peng Fan
2016-12-29  9:28   ` Bhuvanchandra DV
2017-02-12  9:27   ` Stefano Babic
2016-12-27 10:04 ` [U-Boot] [PATCH V2 15/20] serial: lpuart: add i.MX7ULP support Peng Fan
2016-12-27 10:04 ` [U-Boot] [PATCH V2 16/20] mx7ulp: Add HAB boot support Peng Fan
2017-02-12  9:28   ` Stefano Babic
2016-12-27 10:04 ` [U-Boot] [PATCH V2 17/20] arm: dts: add i.MX7ULP dtsi file Peng Fan
2016-12-27 10:04 ` [U-Boot] [PATCH V2 18/20] mmc: fsl_esdhc: support i.MX7ULP Peng Fan
2016-12-27 22:17   ` Jaehoon Chung
2017-02-12  9:29   ` Stefano Babic
2016-12-27 10:04 ` [U-Boot] [PATCH V2 19/20] imx: imx7ulp: add EVK board support Peng Fan
2016-12-27 10:04 ` [U-Boot] [PATCH V2 20/20] imx: mx7ulp_evk: enable mmc/regulator support Peng Fan
2016-12-27 11:22   ` Fabio Estevam
2016-12-27 12:07     ` Peng Fan
2017-01-03  9:05       ` Peng Fan
2017-01-12  2:23         ` Peng Fan
2017-01-12  2:24           ` Peng Fan
2017-02-08  8:36 ` [U-Boot] [PATCH V2 00/20] imx: add i.MX7ULP support Peng Fan
2017-02-08 12:16   ` Stefano Babic

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=79793724-7153-5614-1dfe-fb516d67ad2f@denx.de \
    --to=sbabic@denx.de \
    --cc=u-boot@lists.denx.de \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.