From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.0 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id ADC4CC169C4 for ; Sun, 3 Feb 2019 13:57:17 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 7C47F2084A for ; Sun, 3 Feb 2019 13:57:17 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="kt5psNYM"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=crapouillou.net header.i=@crapouillou.net header.b="gz0f46/P" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 7C47F2084A Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=crapouillou.net Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-mtd-bounces+linux-mtd=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender:Content-Type: Content-Transfer-Encoding:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-Id:To: Subject:From:Date:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=aBUzuL6hDr1pF87EwubhG2m8RdVL+mr9ph/WSvWIcPc=; b=kt5psNYMvh4kd+al7V88UrlPS dhJI2GZl7y7IVyXWTu5EpDtD68Kv0nmoLsFfR0U6DVEwDEHCnfuQDITWT/Ga+vL2/9E69rnS5i8A6 M4Akx78c/9Qc4sVroymyzCBCtKuk31wjWVjkNhe8n+XYZ+ETWeOkqlUc0cMwN5KgQQpOwE9WulUHX 36L3Davum387AUHzpmL3jH78mrri+20id0PQFkiCACZP/40FbRGivVDEQH8+OHSkjp9cItLVU3Ntz jEwnFj5OyE5TJaaah7/GsQtNB1Sv7BmtjcqlttLWCBs2vhJoZDvAqsTxiA/rfcChls3gvcIbtEzxS IjEOliF1w==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gqIGo-0004Am-Ks; Sun, 03 Feb 2019 13:57:14 +0000 Received: from outils.crapouillou.net ([89.234.176.41] helo=crapouillou.net) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gqIGl-00049M-CG for linux-mtd@lists.infradead.org; Sun, 03 Feb 2019 13:57:13 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=crapouillou.net; s=mail; t=1549202228; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=JhIxqtYBUymNwnoVtMBVkJEhdQaXjb8TBlyTpJXq6QE=; b=gz0f46/P4qWJkl2gZa8c+ftr7SWafPUt5fIglBjz9jNaLGD1+hEciqs3+QTsuMfDLIgLmI Mh3j4xQvIm8QzRganOe/w+AEbVyjAufI5g5qqJJgLrpLHggWSj/F16ZeCZlubMZ6k1NUHx onJm2Bwn9rc/bw2JDtvh2clCVlwOVUg= Date: Sun, 03 Feb 2019 10:56:53 -0300 From: Paul Cercueil Subject: Re: [PATCH v2 4/9] mtd: rawnand: jz4780: Add support for the JZ4740 To: Boris Brezillon Message-Id: <1549202213.1950.1@crapouillou.net> In-Reply-To: <20190203083151.4fc29c5b@bbrezillon> References: <20190202231926.2444-1-paul@crapouillou.net> <20190202231926.2444-5-paul@crapouillou.net> <20190203083151.4fc29c5b@bbrezillon> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190203_055711_851203_9ACDC0F2 X-CRM114-Status: GOOD ( 21.14 ) X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Mark Rutland , devicetree@vger.kernel.org, Mathieu Malaterre , Richard Weinberger , linux-kernel@vger.kernel.org, Marek Vasut , Rob Herring , linux-mtd@lists.infradead.org, Harvey Hunt , Miquel Raynal , Brian Norris , David Woodhouse Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="iso-8859-1"; Format="flowed" Sender: "linux-mtd" Errors-To: linux-mtd-bounces+linux-mtd=archiver.kernel.org@lists.infradead.org Le dim. 3 f=E9vr. 2019 =E0 4:31, Boris Brezillon = a =E9crit : > On Sat, 2 Feb 2019 20:19:21 -0300 > Paul Cercueil wrote: > = >> Add support for probing the jz4780-nand driver on the JZ4740 SoC = >> from >> Ingenic. >> = >> Signed-off-by: Paul Cercueil >> --- >> = >> Changes: >> = >> v2: - Add support for the JZ4740 and not the JZ4725B: they behave = >> the >> same, and JZ4740 is fully upstream while JZ4725B is not. The >> JZ4725B devicetree will then simply use the = >> "ingenic,jz4740-nand" >> compatible string. >> - Fix the number of bytes for the ECC when the ECC strength is = >> 4. >> This is needed for the JZ4740, which uses Reed-Solomon = >> instead of >> BCH. >> = >> drivers/mtd/nand/raw/ingenic/jz4780_nand.c | 48 = >> +++++++++++++++++----- > = > If we're going to make the driver compatible with jz4740 and jz4725b > maybe we should rename the source files jz47xx_{nand,bch}.{c,h}. I don't know about that. Adding support for new hardware isn't a good = reason to rename the driver, or so I've been told around here, as you then make = it harder to review the git history of the driver. >> 1 file changed, 37 insertions(+), 11 deletions(-) >> = >> diff --git a/drivers/mtd/nand/raw/ingenic/jz4780_nand.c = >> b/drivers/mtd/nand/raw/ingenic/jz4780_nand.c >> index 7f55358b860f..c0855fef7735 100644 >> --- a/drivers/mtd/nand/raw/ingenic/jz4780_nand.c >> +++ b/drivers/mtd/nand/raw/ingenic/jz4780_nand.c >> @@ -13,6 +13,7 @@ >> #include >> #include >> #include >> +#include >> #include >> #include >> #include >> @@ -26,13 +27,15 @@ >> = >> #define DRV_NAME "jz4780-nand" >> = >> -#define OFFSET_DATA 0x00000000 >> -#define OFFSET_CMD 0x00400000 >> -#define OFFSET_ADDR 0x00800000 >> - >> /* Command delay when there is no R/B pin. */ >> #define RB_DELAY_US 100 >> = >> +struct jz_soc_info { >> + unsigned long data_offset; >> + unsigned long addr_offset; >> + unsigned long cmd_offset; >> +}; >> + >> struct jz4780_nand_cs { >> unsigned int bank; >> void __iomem *base; >> @@ -40,6 +43,7 @@ struct jz4780_nand_cs { >> = >> struct jz4780_nand_controller { >> struct device *dev; >> + const struct jz_soc_info *soc_info; >> struct jz4780_bch *bch; >> struct nand_controller controller; >> unsigned int num_banks; >> @@ -101,9 +105,9 @@ static void jz4780_nand_cmd_ctrl(struct = >> nand_chip *chip, int cmd, >> return; >> = >> if (ctrl & NAND_ALE) >> - writeb(cmd, cs->base + OFFSET_ADDR); >> + writeb(cmd, cs->base + nfc->soc_info->addr_offset); >> else if (ctrl & NAND_CLE) >> - writeb(cmd, cs->base + OFFSET_CMD); >> + writeb(cmd, cs->base + nfc->soc_info->cmd_offset); >> } >> = >> static int jz4780_nand_dev_ready(struct nand_chip *chip) >> @@ -161,8 +165,13 @@ static int jz4780_nand_attach_chip(struct = >> nand_chip *chip) >> struct jz4780_nand_controller *nfc =3D = >> to_jz4780_nand_controller(chip->controller); >> int eccbytes; >> = >> - chip->ecc.bytes =3D fls((1 + 8) * chip->ecc.size) * >> - (chip->ecc.strength / 8); >> + if (chip->ecc.strength =3D=3D 4) { >> + /* JZ4740 uses 9 bytes of ECC to correct maximum 4 errors */ >> + chip->ecc.bytes =3D 9; >> + } else { >> + chip->ecc.bytes =3D fls((1 + 8) * chip->ecc.size) * >> + (chip->ecc.strength / 8); >> + } >> = >> switch (chip->ecc.mode) { >> case NAND_ECC_HW: >> @@ -272,8 +281,8 @@ static int jz4780_nand_init_chip(struct = >> platform_device *pdev, >> return -ENOMEM; >> mtd->dev.parent =3D dev; >> = >> - chip->legacy.IO_ADDR_R =3D cs->base + OFFSET_DATA; >> - chip->legacy.IO_ADDR_W =3D cs->base + OFFSET_DATA; >> + chip->legacy.IO_ADDR_R =3D cs->base + nfc->soc_info->data_offset; >> + chip->legacy.IO_ADDR_W =3D cs->base + nfc->soc_info->data_offset; >> chip->legacy.chip_delay =3D RB_DELAY_US; >> chip->options =3D NAND_NO_SUBPAGE_WRITE; >> chip->legacy.select_chip =3D jz4780_nand_select_chip; >> @@ -353,6 +362,10 @@ static int jz4780_nand_probe(struct = >> platform_device *pdev) >> if (!nfc) >> return -ENOMEM; >> = >> + nfc->soc_info =3D device_get_match_data(dev); >> + if (!nfc->soc_info) >> + return -EINVAL; >> + >> /* >> * Check for BCH HW before we call nand_scan_ident, to prevent us = >> from >> * having to call it again if the BCH driver returns = >> -EPROBE_DEFER. >> @@ -390,8 +403,21 @@ static int jz4780_nand_remove(struct = >> platform_device *pdev) >> return 0; >> } >> = >> +static const struct jz_soc_info jz4740_soc_info =3D { >> + .data_offset =3D 0x00000000, >> + .cmd_offset =3D 0x00008000, >> + .addr_offset =3D 0x00010000, >> +}; >> + >> +static const struct jz_soc_info jz4780_soc_info =3D { >> + .data_offset =3D 0x00000000, >> + .cmd_offset =3D 0x00400000, >> + .addr_offset =3D 0x00800000, >> +}; >> + >> static const struct of_device_id jz4780_nand_dt_match[] =3D { >> - { .compatible =3D "ingenic,jz4780-nand" }, >> + { .compatible =3D "ingenic,jz4740-nand", .data =3D &jz4740_soc_info }, >> + { .compatible =3D "ingenic,jz4780-nand", .data =3D &jz4780_soc_info = >> }, >> {}, >> }; >> MODULE_DEVICE_TABLE(of, jz4780_nand_dt_match); > = ______________________________________________________ Linux MTD discussion mailing list http://lists.infradead.org/mailman/listinfo/linux-mtd/