public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Marek Vasut <marex@denx.de>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH 1/2] altera_qspi: add lock unlock ops
Date: Sun, 29 Nov 2015 14:34:52 +0100	[thread overview]
Message-ID: <201511291434.52790.marex@denx.de> (raw)
In-Reply-To: <1448797103-30524-1-git-send-email-thomas@wytron.com.tw>

On Sunday, November 29, 2015 at 12:38:22 PM, Thomas Chou wrote:
> Add lock() and unlock() mtd ops to altera_qspi.
> 
> Signed-off-by: Thomas Chou <thomas@wytron.com.tw>
> ---
>  drivers/mtd/altera_qspi.c | 82
> +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 82
> insertions(+)
> 
> diff --git a/drivers/mtd/altera_qspi.c b/drivers/mtd/altera_qspi.c
> index 50c6e0e..89f04a4 100644
> --- a/drivers/mtd/altera_qspi.c
> +++ b/drivers/mtd/altera_qspi.c
> @@ -46,10 +46,24 @@ struct altera_qspi_platdata {
> 
>  flash_info_t flash_info[CONFIG_SYS_MAX_FLASH_BANKS];	/* FLASH chips 
info
> */
> 
> +static void altera_qspi_get_locked_range(struct mtd_info *mtd, loff_t
> *ofs, +					 uint64_t *len);
> +
>  void flash_print_info(flash_info_t *info)
>  {
> +	struct mtd_info *mtd = info->mtd;
> +	loff_t ofs;
> +	uint64_t len;

u64 please.

> +
>  	printf("Altera QSPI flash  Size: %ld MB in %d Sectors\n",
>  	       info->size >> 20, info->sector_count);
> +	altera_qspi_get_locked_range(mtd, &ofs, &len);
> +	printf("  %08lX +%lX", info->start[0], info->size);
> +	if (len) {
> +		printf(", protected %08lX +%lX",
> +		       info->start[0] + (ulong)ofs, (ulong)len);

Do you really need the typecasts here ? %llx should do it for the len
and dropping the l should do it for ofs I think.

> +	}
> +	putc('\n');
>  }
> 
>  int flash_erase(flash_info_t *info, int s_first, int s_last)
> @@ -171,6 +185,72 @@ static void altera_qspi_sync(struct mtd_info *mtd)
>  {
>  }
> 
> +static void altera_qspi_get_locked_range(struct mtd_info *mtd, loff_t
> *ofs, +					 uint64_t *len)
> +{
> +	struct udevice *dev = mtd->dev;
> +	struct altera_qspi_platdata *pdata = dev_get_platdata(dev);
> +	struct altera_qspi_regs *regs = pdata->regs;
> +	u32 stat = readl(&regs->rd_status);
> +	unsigned pow = ((stat >> 2) & 0x7) | ((stat >> 3) & 0x8);
> +
> +	*ofs = 0;
> +	*len = 0;
> +	if (pow) {
> +		*len = mtd->erasesize << (pow - 1);
> +		if (!(stat & 0x20))
> +			*ofs = mtd->size - *len;

What are all these magic numbers ?

> +	}
> +}
> +
> +static int altera_qspi_lock(struct mtd_info *mtd, loff_t ofs, uint64_t
> len) +{
> +	struct udevice *dev = mtd->dev;
> +	struct altera_qspi_platdata *pdata = dev_get_platdata(dev);
> +	struct altera_qspi_regs *regs = pdata->regs;
> +	u32 sector_start, sector_end;
> +	uint64_t num_sectors;

u64

> +	u32 mem_op;
> +	u32 sr_bp;
> +	u32 sr_tb;

All were just minor nits, thanks!

Best regards,
Marek Vasut

  parent reply	other threads:[~2015-11-29 13:34 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-11-29 11:38 [U-Boot] [PATCH 1/2] altera_qspi: add lock unlock ops Thomas Chou
2015-11-29 11:38 ` [U-Boot] [PATCH 2/2] altera_qspi: fix erase and write error code Thomas Chou
2015-11-29 13:35   ` Marek Vasut
2015-12-01  7:21   ` Chin Liang See
2015-11-29 13:34 ` Marek Vasut [this message]
2015-12-01  7:09 ` [U-Boot] [PATCH 1/2] altera_qspi: add lock unlock ops Chin Liang See
2015-12-01  9:07 ` [U-Boot] [PATCH v2 " Thomas Chou
2015-12-01  9:07   ` [U-Boot] [PATCH v2 2/2] altera_qspi: fix erase and write error code Thomas Chou
2015-12-01 13:24     ` Marek Vasut
2015-12-06  3:33     ` Thomas Chou
2015-12-01 13:23   ` [U-Boot] [PATCH v2 1/2] altera_qspi: add lock unlock ops Marek Vasut
2015-12-06  3:32   ` Thomas Chou

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=201511291434.52790.marex@denx.de \
    --to=marex@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox