public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: <bogus@does.not.exist.com>
To: u-boot@lists.denx.de
Subject: No subject
Date: Mon, 05 Dec 2011 12:53:56 -0000	[thread overview]
Message-ID: <mailman.17.1327100151.16640.u-boot@lists.denx.de> (raw)

not just check for that and error (not silently continue) if it's
anything else?

> +}
> +
> +/**
> + * Page read/write function
> + *
> + * @param mtd		mtd info structure
> + * @param chip		nand chip info structure
> + * @param buf		data buffer
> + * @param page		page number
> + * @param with_ecc	1 to enable ECC, 0 to disable ECC
> + * @param is_writing	0 for read, 1 for write
> + * @return	0 when successfully completed
> + *		-EIO when command timeout
> + */
> +static int nand_rw_page(struct mtd_info *mtd, struct nand_chip *chip,
> +	uint8_t *buf, int page, int with_ecc, int is_writing)
> +{
> +	u32 reg_val;
> +	int tag_size;
> +	struct nand_oobfree *free = chip->ecc.layout->oobfree;
> +	/* 128 is larger than the value that our HW can support. */
> +	u32 tag_buf[128];
> +	char *tag_ptr;
> +	struct nand_info *info;
> +	struct fdt_nand *config;
> +
> +	if (((int) buf) & 0x03) {

s/int/uintptr_t/ (or unsigned long)

> +		printf("buf 0x%X has to be 4-byte aligned\n", (u32) buf);

%p

> +	set_bus_width_page_size(&info->config, &reg_val);

You need to set up the bus width and page size on every page transfer?
Why not figure out the value to write in the register at init time (thus
making it a good place to reject unsupported configurations)?

> +	/* Set ECC selection, configure ECC settings */
> +	if (with_ecc) {
> +		tag_size = config->tag_bytes + config->tag_ecc_bytes;
> +		reg_val |= (CFG_SKIP_SPARE_SEL_4
> +			| CFG_SKIP_SPARE_ENABLE
> +			| CFG_HW_ECC_CORRECTION_ENABLE
> +			| CFG_ECC_EN_TAG_DISABLE
> +			| CFG_HW_ECC_SEL_RS
> +			| CFG_HW_ECC_ENABLE
> +			| CFG_TVAL4
> +			| (tag_size - 1));
> +
> +		if (!is_writing) {
> +			tag_size += config->skipped_spare_bytes;
> +			invalidate_dcache_range((unsigned long) tag_ptr,
> +				((unsigned long) tag_ptr) + tag_size);
> +		} else
> +			flush_dcache_range((unsigned long) tag_ptr,
> +				((unsigned long) tag_ptr) + tag_size);
> +	} else {
> +		tag_size = mtd->oobsize;
> +		reg_val |= (CFG_SKIP_SPARE_DISABLE
> +			| CFG_HW_ECC_CORRECTION_DISABLE
> +			| CFG_ECC_EN_TAG_DISABLE
> +			| CFG_HW_ECC_DISABLE
> +			| (tag_size - 1));
> +		if (!is_writing) {
> +			invalidate_dcache_range((unsigned long) chip->oob_poi,
> +				((unsigned long) chip->oob_poi) + tag_size);
> +		} else {
> +			flush_dcache_range((unsigned long) chip->oob_poi,
> +				((unsigned long) chip->oob_poi) + tag_size);
> +		}
> +	}
> +	writel(reg_val, &info->reg->config);
> +
> +	if (!is_writing) {
> +		invalidate_dcache_range((unsigned long) buf,
> +			((unsigned long) buf) +
> +			(1 << chip->page_shift));
> +	} else {
> +		flush_dcache_range((unsigned long) buf,
> +			((unsigned long) buf) +
> +			(1 << chip->page_shift));
> +	}

Please factor out all this cache stuff into a dma prepare function that
takes start, length, and is_writing.  Is it even really needed to
invalidate rather than flush in the read case?  It doesn't look like
these buffers are even going to be cacheline-aligned...

> +int fdt_decode_nand(const void *blob, int node, struct fdt_nand *config)
> +{
> +	int err;
> +
> +	config->reg = (struct nand_ctlr *)fdtdec_get_addr(blob, node, "reg");
> +	config->enabled = fdtdec_get_is_enabled(blob, node);
> +	config->width = fdtdec_get_int(blob, node, "width", 8);
> +	err = fdtdec_decode_gpio(blob, node, "wp-gpios", &config->wp_gpio);
> +	if (err)
> +		return err;
> +	err = fdtdec_get_int_array(blob, node, "nvidia,timing",
> +			config->timing, FDT_NAND_TIMING_COUNT);
> +	if (err < 0)
> +		return err;
> +
> +	/* Now look up the controller and decode that */
> +	node = fdt_next_node(blob, node, NULL);
> +	if (node < 0)
> +		return node;
> +
> +	config->page_data_bytes = fdtdec_get_int(blob, node,
> +						"page-data-bytes", -1);
> +	config->tag_ecc_bytes = fdtdec_get_int(blob, node,
> +						"tag-ecc-bytes", -1);
> +	config->tag_bytes = fdtdec_get_int(blob, node, "tag-bytes", -1);
> +	config->data_ecc_bytes = fdtdec_get_int(blob, node,
> +						"data-ecc-bytes", -1);
> +	config->skipped_spare_bytes = fdtdec_get_int(blob, node,
> +						"skipped-spare-bytes", -1);
> +	config->page_spare_bytes = fdtdec_get_int(blob, node,
> +						"page-spare-bytes", -1);

Has this binding been accepted into Linux's documentation or another
canonical source?

Usually vendor prefixes are asked for on such properties (similar to
"nvidia,timing").

> +/* Oh dear I suspect no one will like these Bit values? */

Indeed.

> +enum {
> +	Bit0 = 1 << 0,
> +	Bit1 = 1 << 1,
> +	Bit2 = 1 << 2,

Please just open code this in the functional definitions.

> +enum {
> +	CMD_TRANS_SIZE_BYTES1 = 0,
> +	CMD_TRANS_SIZE_BYTES2,
> +	CMD_TRANS_SIZE_BYTES3,
> +	CMD_TRANS_SIZE_BYTES4,
> +	CMD_TRANS_SIZE_BYTES5,
> +	CMD_TRANS_SIZE_BYTES6,
> +	CMD_TRANS_SIZE_BYTES7,
> +	CMD_TRANS_SIZE_BYTES8,
> +	CMD_TRANS_SIZE_BYTES_PAGE_SIZE_SEL
> +};

Why not just use the number of bytes directly, minus one?

-Scott

             reply	other threads:[~2011-12-05 12:53 UTC|newest]

Thread overview: 398+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-12-05 12:53 bogus [this message]
  -- strict thread matches above, loose matches on Subject: below --
2020-11-25 10:16 No subject Manuel Reis
2020-05-08  9:43 Patrick Wildt
2014-06-27  8:01 bogus
2014-06-27  8:01 bogus
2014-06-27  8:01 bogus
2014-06-27  8:01 bogus
2014-05-30  7:51 bogus
2014-05-30  7:51 bogus
2014-05-30  7:51 bogus
2014-03-03  8:42 bogus
2014-03-03  8:42 bogus
2014-03-03  8:42 bogus
2014-03-03  8:42 bogus
2014-03-03  8:42 bogus
2014-03-03  8:42 bogus
2014-03-03  8:42 bogus
2014-03-03  8:42 bogus
2014-03-03  8:42 bogus
2014-03-03  8:42 bogus
2014-03-03  8:42 bogus
2013-12-16 11:38 bogus
2013-12-16 11:38 bogus
2013-12-16 11:38 bogus
2013-12-16 11:38 bogus
2013-12-16 11:38 bogus
2013-12-16 11:38 bogus
2013-12-16 11:38 bogus
2013-12-16 11:38 bogus
2013-10-15 19:54 bogus
2013-10-15 19:54 bogus
2013-10-15 19:54 bogus
2013-10-15 19:54 bogus
2013-10-15 19:54 bogus
2013-10-15 19:54 bogus
2013-10-15 19:54 bogus
2013-10-15 19:54 bogus
2013-10-15 19:54 bogus
2013-10-15 19:54 bogus
2013-10-15 19:54 bogus
2013-10-15 19:54 bogus
2013-08-18  1:03 bogus
2013-08-18  1:03 bogus
2013-08-18  1:03 bogus
2013-08-18  1:03 bogus
2013-08-18  1:03 bogus
2013-08-18  1:03 bogus
2013-08-18  1:03 bogus
2013-08-18  1:03 bogus
2013-08-18  1:03 bogus
2013-08-18  1:03 bogus
2013-08-18  1:03 bogus
2013-08-18  1:03 bogus
2013-08-18  1:03 bogus
2013-08-18  1:03 bogus
2013-04-09 14:12 bogus
2013-04-09 14:12 bogus
2013-04-09 14:12 bogus
2013-04-09 14:12 bogus
2013-04-09 14:12 bogus
2013-04-09 14:12 bogus
2013-04-09 14:12 bogus
2013-04-09 14:12 bogus
2013-04-09 14:12 bogus
2013-04-09 14:12 bogus
2013-04-09 14:12 bogus
2013-04-09 14:12 bogus
2013-04-09 14:12 bogus
2013-04-09 14:12 bogus
2013-04-09 14:12 bogus
2013-04-09 14:12 bogus
2013-04-09 14:12 bogus
2012-10-11  5:38 bogus
2012-10-11  5:38 bogus
2012-10-11  5:38 bogus
2012-10-11  5:38 bogus
2012-10-11  5:38 bogus
2012-10-11  5:38 bogus
2012-10-11  5:38 bogus
2012-10-11  5:38 bogus
2012-10-11  5:38 bogus
2012-10-11  5:38 bogus
2012-10-11  5:38 bogus
2012-10-11  5:38 bogus
2012-10-11  5:38 bogus
2012-10-11  5:38 bogus
2012-10-11  5:38 bogus
2012-10-11  5:38 bogus
2012-10-11  5:38 bogus
2012-10-11  5:38 bogus
2012-10-11  5:38 bogus
2012-10-11  5:38 bogus
2012-10-11  5:38 bogus
2012-10-11  5:38 bogus
2012-10-11  5:38 bogus
2012-10-11  5:38 bogus
2012-10-11  5:38 bogus
2012-10-11  5:38 bogus
2012-10-11  5:38 bogus
2012-10-11  5:38 bogus
2012-10-11  5:38 bogus
2012-10-11  5:38 bogus
2012-10-11  5:38 bogus
2012-10-11  5:38 bogus
2011-12-05 12:53 bogus
2011-12-05 12:53 bogus
2011-12-05 12:53 bogus
2011-12-05 12:53 bogus
2011-12-05 12:53 bogus
2011-12-05 12:53 bogus
2011-12-05 12:53 bogus
2011-12-05 12:53 bogus
2011-12-05 12:53 bogus
2011-12-05 12:53 bogus
2011-12-05 12:53 bogus
2011-12-05 12:53 bogus
2011-12-05 12:53 bogus
2011-12-05 12:53 bogus
2011-12-05 12:53 bogus
2011-12-05 12:53 bogus
2011-12-05 12:53 bogus
2011-12-05 12:53 bogus
2011-12-05 12:53 bogus
2011-12-05 12:53 bogus
2011-12-05 12:53 bogus
2011-12-05 12:53 bogus
2011-12-05 12:53 bogus
2011-12-05 12:53 bogus
2011-12-05 12:53 bogus
2011-12-05 12:53 bogus
2011-12-05 12:53 bogus
2011-12-05 12:53 bogus
2011-12-05 12:53 bogus
2011-12-05 12:53 bogus
2011-12-05 12:53 bogus
2011-12-05 12:53 bogus
2011-12-05 12:53 bogus
2011-12-05 12:53 bogus
2011-12-05 12:53 bogus
2011-12-05 12:53 bogus
2011-12-05 12:53 bogus
2011-12-05 12:53 bogus
2011-12-05 12:53 bogus
2011-12-05 12:53 bogus
2011-12-05 12:53 bogus
2011-12-05 12:53 bogus
2011-12-05 12:53 bogus
2011-12-05 12:53 bogus
2011-12-05 12:53 bogus
2011-12-05 12:53 bogus
2011-12-05 12:53 bogus
2011-11-17 20:02 bogus
2011-11-17 20:02 bogus
2011-11-17 20:02 bogus
2011-11-17 20:02 bogus
2011-11-17 20:02 bogus
2009-01-23 10:48 bogus
2009-01-23 10:48 bogus
2009-01-23 10:48 bogus
2009-01-23 10:48 bogus
2009-01-23 10:48 bogus
2009-01-23 10:48 bogus
2009-01-23 10:48 bogus
2009-01-23 10:48 bogus
2009-01-23 10:48 bogus
2009-01-23 10:48 bogus
2009-01-23 10:48 bogus
2009-01-23 10:48 bogus
2009-01-23 10:48 bogus
2009-01-23 10:48 bogus
2009-01-23 10:48 bogus
2009-01-23 10:48 bogus
2009-01-23 10:48 bogus
2009-01-23 10:48 bogus
2009-01-23 10:48 bogus
2009-01-23 10:48 bogus
2009-01-23 10:48 bogus
2009-01-23 10:48 bogus
2009-01-23 10:48 bogus
2009-01-23 10:48 bogus
2009-01-23 10:48 bogus
2009-01-23 10:48 bogus
2009-01-23 10:48 bogus
2009-01-23 10:48 bogus
2009-01-23 10:48 bogus
2009-01-23 10:48 bogus
2009-01-23 10:48 bogus
2009-01-23 10:48 bogus
2009-01-23 10:48 bogus
2009-01-23 10:48 bogus
2009-01-23 10:48 bogus
2009-01-23 10:48 bogus
2009-01-23 10:48 bogus
2009-01-23 10:48 bogus
2009-01-23 10:48 bogus
2009-01-23 10:48 bogus
2009-01-23 10:48 bogus
2009-01-23 10:48 bogus
2009-01-23 10:48 bogus
2009-01-23 10:48 bogus
2009-01-23 10:48 bogus
2009-01-23 10:48 bogus
2009-01-23 10:48 bogus
2009-01-23 10:48 bogus
2009-01-23 10:48 bogus
2009-01-23 10:48 bogus
2009-01-23 10:48 bogus
2009-01-23 10:48 bogus
2009-01-23 10:48 bogus
2009-01-23 10:48 bogus
2009-01-23 10:48 bogus
2009-01-23 10:48 bogus
2009-01-23 10:48 bogus
2009-01-23 10:48 bogus
2009-01-23 10:48 bogus
2009-01-23 10:48 bogus
2009-01-23 10:48 bogus
2009-01-23 10:48 bogus
2009-01-23 10:48 bogus
2009-01-23 10:48 bogus
2009-01-23 10:48 bogus
2009-01-23 10:48 bogus
2009-01-23 10:48 bogus
2009-01-23 10:48 bogus
2009-01-23 10:48 bogus
2009-01-23 10:48 bogus
2009-01-23 10:48 bogus
2009-01-23 10:48 bogus
2009-01-23 10:48 bogus
2009-01-23 10:48 bogus
2009-01-23 10:48 bogus
2009-01-23 10:48 bogus
2009-01-23 10:48 bogus
2009-01-23 10:48 bogus
2009-01-23 10:48 bogus
2009-01-23 10:48 bogus
2009-01-23 10:48 bogus
2009-01-23 10:48 bogus
2009-01-23 10:48 bogus
2009-01-23 10:48 bogus
2009-01-23 10:48 bogus
2009-01-23 10:48 bogus
2009-01-23 10:48 bogus
2009-01-23 10:48 bogus
2009-01-23 10:48 bogus
2009-01-23 10:48 bogus
2009-01-23 10:48 bogus
2009-01-23 10:48 bogus
2009-01-23 10:48 bogus
2009-01-23 10:48 bogus
2009-01-23 10:48 bogus
2009-01-23 10:48 bogus
2009-01-23 10:48 bogus
2009-01-23 10:48 bogus
2009-01-23 10:48 bogus
2009-01-23 10:48 bogus
2009-01-23 10:48 bogus
2009-01-23 10:48 bogus
2009-01-23 10:48 bogus
2009-01-23 10:48 bogus
2009-01-23 10:48 bogus
2009-01-23 10:48 bogus
2009-01-23 10:48 bogus
2009-01-23 10:48 bogus
2009-01-23 10:48 bogus
2009-01-23 10:48 bogus
2009-01-23 10:48 bogus
2009-01-23 10:48 bogus
2009-01-23 10:48 bogus
2009-01-23 10:48 bogus
2009-01-23 10:48 bogus
2009-01-23 10:48 bogus
2009-01-23 10:48 bogus
2009-01-23 10:48 bogus
2009-01-23 10:48 bogus
2009-01-23 10:48 bogus
2009-01-23 10:48 bogus
2009-01-23 10:48 bogus
2009-01-23 10:48 bogus
2009-01-23 10:48 bogus
2009-01-23 10:48 bogus
2009-01-23 10:48 bogus
2009-01-23 10:48 bogus
2009-01-23 10:48 bogus
2009-01-23 10:48 bogus
2009-01-23 10:48 bogus
2009-01-23 10:48 bogus
2009-01-23 10:48 bogus
2009-01-23 10:48 bogus
2009-01-23 10:48 bogus
2009-01-23 10:48 bogus
2009-01-23 10:48 bogus
2009-01-23 10:48 bogus
2009-01-23 10:48 bogus
2009-01-23 10:48 bogus
2009-01-23 10:48 bogus
2009-01-23 10:48 bogus
2009-01-23 10:48 bogus
2009-01-23 10:48 bogus
2009-01-23 10:48 bogus
2009-01-23 10:48 bogus
2009-01-23 10:48 bogus
2009-01-23 10:48 bogus
2009-01-23 10:48 bogus
2009-01-23 10:48 bogus
2009-01-23 10:48 bogus
2009-01-23 10:48 bogus
2009-01-23 10:48 bogus
2009-01-23 10:48 bogus
2009-01-23 10:48 bogus
2008-08-19 20:18 bogus
2008-08-19 20:18 bogus
2008-08-19 20:18 bogus
2008-08-19 20:18 bogus
2008-08-19 20:18 bogus
2008-08-19 20:18 bogus
2008-08-19 20:18 bogus
2008-08-19 20:18 bogus
2008-08-19 20:18 bogus
2008-08-19 20:18 bogus
2008-08-19 20:18 bogus
2008-08-19 20:18 bogus
2008-08-19 20:18 bogus
2008-08-19 20:18 bogus
2008-08-19 20:18 bogus
2008-08-19 20:18 bogus
2008-08-19 20:18 bogus
2008-08-19 20:18 bogus
2008-08-19 20:18 bogus
2008-08-19 20:18 bogus
2008-08-19 20:18 bogus
2008-08-19 20:18 bogus
2008-08-19 20:18 bogus
2008-08-19 20:18 bogus
2008-08-19 20:18 bogus
2008-08-19 20:18 bogus
2008-08-19 20:18 bogus
2008-08-19 20:18 bogus
2008-08-19 20:18 bogus
2008-08-19 20:18 bogus
2008-08-19 20:18 bogus
2008-08-19 20:18 bogus
2008-08-19 20:18 bogus
2008-08-19 20:18 bogus
2008-08-19 20:18 bogus
2008-08-19 20:18 bogus
2008-08-19 20:18 bogus
2008-08-19 20:18 bogus
2008-08-19 20:18 bogus
2008-08-19 20:18 bogus
2008-08-19 20:18 bogus
2008-08-19 20:18 bogus
2008-08-19 20:18 bogus
2008-08-19 20:18 bogus
2008-08-19 20:18 bogus
2008-08-19 20:18 bogus
2008-08-19 20:18 bogus
2008-08-19 20:18 bogus
2008-08-19 20:18 bogus
2008-08-19 20:18 bogus
2008-08-19 20:18 bogus
2008-08-19 20:18 bogus
2008-08-19 20:18 bogus
2008-08-19 20:18 bogus
2008-08-19 20:18 bogus
2008-08-19 20:18 bogus
2008-08-19 20:18 bogus
2008-08-19 20:18 bogus
2008-08-19 20:18 bogus
2008-08-19 20:18 bogus
2008-08-19 20:18 bogus
2008-08-19 20:18 bogus
2008-08-19 20:18 bogus
2008-08-19 20:18 bogus
2008-08-19 20:18 bogus
2008-08-19 20:18 bogus
2008-08-19 20:18 bogus
2008-07-29  0:03 bogus
2008-07-29  0:03 bogus
2008-07-29  0:03 bogus
2008-07-29  0:03 bogus
2008-07-29  0:03 bogus
2008-07-29  0:03 bogus
2008-07-29  0:03 bogus
2008-07-29  0:03 bogus
2008-07-29  0:03 bogus
2008-07-29  0:03 bogus
2008-07-29  0:03 bogus
2008-07-29  0:03 bogus
2008-07-29  0:03 bogus
2008-07-29  0:03 bogus
2008-07-29  0:03 bogus
2008-07-29  0:03 bogus
2008-07-29  0:03 bogus
2008-07-29  0:03 bogus
2008-07-29  0:03 bogus
2008-07-29  0:03 bogus
2008-07-29  0:03 bogus

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=mailman.17.1327100151.16640.u-boot@lists.denx.de \
    --to=bogus@does.not.exist.com \
    --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