From: Sascha Hauer <s.hauer@pengutronix.de>
To: Jan Luebbe <jluebbe@debian.org>
Cc: barebox@lists.infradead.org
Subject: Re: [PATCH v2] davinci_nand: add support for the NAND controller
Date: Fri, 31 Jul 2015 10:17:46 +0200 [thread overview]
Message-ID: <20150731081746.GT18700@pengutronix.de> (raw)
In-Reply-To: <1438270321-945-1-git-send-email-jluebbe@debian.org>
On Thu, Jul 30, 2015 at 05:32:01PM +0200, Jan Luebbe wrote:
> This driver is based on the Linux driver (v4.0).
>
> Signed-off-by: Jan Luebbe <jluebbe@debian.org>
> ---
> Changes from v1:
> - Fix style problems reported by checkpatch (reported by Antony Pavlov).
>
> + *nand_davinci_get_pdata(struct device_d *dev)
> +{
> + struct davinci_nand_pdata *pdata;
> + const char *mode;
> + u32 prop;
> +
> + pdata = kzalloc(sizeof(struct davinci_nand_pdata),
> + GFP_KERNEL);
> + if (!pdata)
> + return ERR_PTR(-ENOMEM);
> + if (!of_property_read_u32(dev->device_node,
> + "ti,davinci-chipselect", &prop))
> + pdata->chipsel = prop;
> + else
> + return ERR_PTR(-EINVAL);
> +
> + if (!of_property_read_u32(dev->device_node,
> + "ti,davinci-mask-ale", &prop))
> + pdata->mask_ale = prop;
> + if (!of_property_read_u32(dev->device_node,
> + "ti,davinci-mask-cle", &prop))
> + pdata->mask_cle = prop;
> + if (!of_property_read_u32(dev->device_node,
> + "ti,davinci-mask-chipsel", &prop))
> + pdata->mask_chipsel = prop;
> + if (!of_property_read_string(dev->device_node,
> + "nand-ecc-mode", &mode) ||
> + !of_property_read_string(dev->device_node,
> + "ti,davinci-ecc-mode", &mode)) {
We have of_get_nand_ecc_mode(). How about adding an optional propname
argument to it and using it here?
> + if (!strncmp("none", mode, 4))
> + pdata->ecc_mode = NAND_ECC_NONE;
> + if (!strncmp("soft", mode, 4))
> + pdata->ecc_mode = NAND_ECC_SOFT;
> + if (!strncmp("hw", mode, 2))
> + pdata->ecc_mode = NAND_ECC_HW;
> + }
> + if (!of_property_read_u32(dev->device_node,
> + "ti,davinci-ecc-bits", &prop))
> + pdata->ecc_bits = prop;
> +
> + prop = of_get_nand_bus_width(dev->device_node);
> + if (0 < prop || !of_property_read_u32(dev->device_node,
> + "ti,davinci-nand-buswidth", &prop))
> + if (prop == 16)
> + pdata->options |= NAND_BUSWIDTH_16;
> + if (of_property_read_bool(dev->device_node,
> + "nand-on-flash-bbt") ||
of_get_nand_on_flash_bbt()?
> + of_property_read_bool(dev->device_node,
> + "ti,davinci-nand-use-bbt"))
> + pdata->bbt_options = NAND_BBT_USE_FLASH;
> +
> + if (of_device_is_compatible(dev->device_node,
> + "ti,keystone-nand")) {
> + pdata->options |= NAND_NO_SUBPAGE_WRITE;
> + }
> + return pdata;
> +}
> +
> +static int nand_davinci_probe(struct device_d *dev)
> +{
> + struct davinci_nand_pdata *pdata;
> + struct davinci_nand_info *info;
> + int ret;
> + uint32_t val;
> + nand_ecc_modes_t ecc_mode;
> +
> + pdata = nand_davinci_get_pdata(dev);
Could you strip the pdata leftovers a bit more? Since this driver is
device tree only it's a bit odd that all data is first parsed into a
separately allocated struct davinci_nand_pdata * from where it is
then moved to it's final destination in struct davinci_nand_info.
--
Pengutronix e.K. | |
Industrial Linux Solutions | http://www.pengutronix.de/ |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
prev parent reply other threads:[~2015-07-31 8:18 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-07-30 15:32 Jan Luebbe
2015-07-31 8:17 ` Sascha Hauer [this message]
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=20150731081746.GT18700@pengutronix.de \
--to=s.hauer@pengutronix.de \
--cc=barebox@lists.infradead.org \
--cc=jluebbe@debian.org \
/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