From: Johan Jonker <jbx6244@gmail.com>
To: Yifeng Zhao <yifeng.zhao@rock-chips.com>,
miquel.raynal@bootlin.com, richard@nod.at, vigneshr@ti.com,
robh+dt@kernel.org
Cc: devicetree@vger.kernel.org, linux-mtd@lists.infradead.org,
heiko@sntech.de, linux-rockchip@lists.infradead.org
Subject: Re: [PATCH v5 2/7] mtd: rawnand: rockchip: NFC drivers for RK3308, RK3188 and others
Date: Wed, 29 Apr 2020 17:55:56 +0200 [thread overview]
Message-ID: <4dbe907c-a6c2-a163-0cab-234b08336b5c@gmail.com> (raw)
In-Reply-To: <20200426100250.14678-3-yifeng.zhao@rock-chips.com>
Hi Yifeng,
A few more comments below for now (part 2).
On 4/26/20 12:02 PM, Yifeng Zhao wrote:
[..]
> +#define THIS_NAME "rk-nand"
> +static int rk_nfc_nand_chip_init(struct device *dev, struct rk_nfc *nfc,
> + struct device_node *np)
> +{
> + struct rk_nfc_nand_chip *nand;
> + struct nand_chip *chip;
> + struct mtd_info *mtd;
> + int nsels;
> + u32 tmp;
> + int ret;
> + int i;
> +
> + if (!of_get_property(np, "reg", &nsels))
> + return -ENODEV;
> + nsels /= sizeof(u32);
> + if (!nsels || nsels > NFC_MAX_NSELS) {
> + dev_err(dev, "invalid reg property size %d\n", nsels);
> + return -EINVAL;
> + }
> +
> + nand = devm_kzalloc(dev, sizeof(*nand) + nsels * sizeof(u8),
> + GFP_KERNEL);
> + if (!nand)
> + return -ENOMEM;
> +
> + nand->nsels = nsels;
> + for (i = 0; i < nsels; i++) {
> + ret = of_property_read_u32_index(np, "reg", i, &tmp);
> + if (ret) {
> + dev_err(dev, "reg property failure : %d\n", ret);
> + return ret;
> + }
> +
> + if (tmp >= NFC_MAX_NSELS) {
> + dev_err(dev, "invalid CS: %u\n", tmp);
> + return -EINVAL;
> + }
> +
> + if (test_and_set_bit(tmp, &nfc->assigned_cs)) {
> + dev_err(dev, "CS %u already assigned\n", tmp);
> + return -EINVAL;
> + }
> +
> + nand->sels[i] = tmp;
> + }
> +
> + chip = &nand->chip;
> + chip->controller = &nfc->controller;
> +
> + nand_set_flash_node(chip, np);
> + nand_set_controller_data(chip, nfc);
> +
> + chip->options |= NAND_USE_BOUNCE_BUFFER | NAND_NO_SUBPAGE_WRITE;
> + chip->bbt_options = NAND_BBT_USE_FLASH | NAND_BBT_NO_OOB;
> +
> + /* set default mode in case dt entry is missing */
> + chip->ecc.mode = NAND_ECC_HW;
> +
> + mtd = nand_to_mtd(chip);
> + mtd->owner = THIS_MODULE;
> + mtd->dev.parent = dev;
> + mtd->name = THIS_NAME;
The 'mtd->name' shows up somewhere in file tree.
The rk3288 has 2 nfc's. In theory 2 probes and also 2 device names, so I
think that we shouldn't use a fixed define for 'mtd->name'.
Maybe use something like this:
mtd->name = devm_kasprintf(ctrl->dev, GFP_KERNEL, "%s",
dev_name(ctrl->dev));
> + mtd_set_ooblayout(mtd, &rk_nfc_ooblayout_ops);
> + rk_nfc_hw_init(nfc);
> + ret = nand_scan(chip, nsels);
> + if (ret)
> + return ret;
> +
> + if (chip->options & NAND_IS_BOOT_MEDIUM) {
> + ret = of_property_read_u32(np, "rockchip-boot-blks", &tmp);
> + nand->boot_blks = ret ? 0 : tmp;
> +
> + ret = of_property_read_u32(np, "rockchip-boot-ecc-strength",
> + &tmp);
> + nand->boot_ecc = ret ? chip->ecc.strength : tmp;
> + }
> +
> + ret = mtd_device_register(mtd, NULL, 0);
> + if (ret) {
> + dev_err(dev, "mtd parse partition error\n");
> + nand_release(chip);
> + return ret;
> + }
> +
> + list_add_tail(&nand->node, &nfc->chips);
> +
> + return 0;
> +}
[..]
> +static struct platform_driver rk_nfc_driver = {
> + .probe = rk_nfc_probe,
> + .remove = rk_nfc_remove,
> + .driver = {
> + .name = THIS_NAME,
.name = "rockchip-nfc",
.name = "rockchip-nand-controller",
The driver name shows up in the kernel log and is used in combination
with 'greb'.
This name should stay in line with all other rockchip drivers.
rockchip-drm
rockchip-rk3066-hdmi
rockchip-pm-domain
rockchip-u3phy
rockchip-thermal
> + .of_match_table = rk_nfc_id_table,
> + .pm = &rk_nfc_pm_ops,
> + },
> +};
next prev parent reply other threads:[~2020-04-29 15:56 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-04-26 10:02 [PATCH v5 0/7] Add Rockchip NFC drivers for RK3308 and others Yifeng Zhao
2020-04-26 10:02 ` [PATCH v5 1/7] dt-bindings: mtd: Describe Rockchip RK3xxx NAND flash controller Yifeng Zhao
2020-04-28 15:01 ` Rob Herring
2020-04-29 3:56 ` Re: [PATCH v5 1/7] dt-bindings: mtd: Describe Rockchip RK3xxx NAND flash controller【请注意,邮件由robherring2@gmail.com代发】 赵仪峰
2020-04-29 8:53 ` [PATCH v5 1/7] dt-bindings: mtd: Describe Rockchip RK3xxx NAND flash controller Johan Jonker
2020-04-29 9:13 ` Miquel Raynal
2020-04-29 9:28 ` Johan Jonker
2020-04-30 13:02 ` 赵仪峰
2020-05-01 11:47 ` Johan Jonker
2020-04-26 10:02 ` [PATCH v5 2/7] mtd: rawnand: rockchip: NFC drivers for RK3308, RK3188 and others Yifeng Zhao
2020-04-26 15:59 ` Johan Jonker
2020-04-29 11:02 ` Re: [PATCH v5 2/7] mtd: rawnand: rockchip: NFC drivers for RK3308, RK3188 and others【请注意,邮件由linux-rockchip-bounces+yifeng.zhao=rock-chips.com@lists.infradead.org代发】 赵仪峰
2020-04-29 15:55 ` Johan Jonker [this message]
2020-04-29 17:04 ` [PATCH v5 2/7] mtd: rawnand: rockchip: NFC drivers for RK3308, RK3188 and others Miquel Raynal
2020-04-26 10:02 ` [PATCH v5 3/7] MAINTAINERS: add maintainers to rockchip nfc Yifeng Zhao
2020-04-26 13:40 ` Johan Jonker
2020-04-26 10:02 ` [PATCH v5 4/7] arm64: dts: rockchip: Add nfc dts for RK3308 SOC Yifeng Zhao
2020-04-26 10:11 ` [PATCH v5 5/7] arm64: dts: rockchip: Add nfc dts for PX30 SOC Yifeng Zhao
2020-04-26 10:11 ` [PATCH v5 6/7] xarm: dts: rockchip: Add nfc dts for RV1108 SOC Yifeng Zhao
2020-04-26 10:11 ` [PATCH v5 7/7] arm: dts: rockchip: Add nfc dts for RK3066 and RK3188 SOC Yifeng Zhao
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=4dbe907c-a6c2-a163-0cab-234b08336b5c@gmail.com \
--to=jbx6244@gmail.com \
--cc=devicetree@vger.kernel.org \
--cc=heiko@sntech.de \
--cc=linux-mtd@lists.infradead.org \
--cc=linux-rockchip@lists.infradead.org \
--cc=miquel.raynal@bootlin.com \
--cc=richard@nod.at \
--cc=robh+dt@kernel.org \
--cc=vigneshr@ti.com \
--cc=yifeng.zhao@rock-chips.com \
/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;
as well as URLs for NNTP newsgroup(s).