Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp2873222imu; Fri, 18 Jan 2019 00:28:57 -0800 (PST) X-Google-Smtp-Source: ALg8bN7dQBr1PVtVn6PD+9Gdgv0gdlGT9GZMPuQEUGZHiTmYDfNsNVzxb7r0QQhcPbesmkN9xTl8 X-Received: by 2002:a63:6103:: with SMTP id v3mr16223920pgb.75.1547800136986; Fri, 18 Jan 2019 00:28:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547800136; cv=none; d=google.com; s=arc-20160816; b=eIso/O2Xvpx6NIjDazy6iOj4++bC3u0CH6kj3XqoRotcsYclwV+JSfR3yDhTX2jNVk B+7q3Lu5RFNqoajRnw2/ZOCuQL2RHjFJjY7E/0z2Ao0/8Yj8JkAUGq53w4vd+CFKe4AM aOkvTJD8dxWO8kqYZU0fanrVcsVhNmbj0RrwloWXhQJX4FNBchohz+rK8TIsS14wN6UI IV7W/Wfpti6mG3ULIcLXuDAIcPonsp8ThAla9qgTYTiD3YbZ9kd0asmZlRCgOcVdu/Ji QxyvUpqVKI0+W5cR+w1wK3hwuZY5/1amGwyGobBNJ1eUj6vlUuSNNcVNrKxXOvgVP+TN KeTw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=qwL1vxJEbum+Rf6howu1VSq2H6SMgqY1BY+LdZ21wJU=; b=zE3kuBmp5oduecavocONe1B8z0PmfHUPZ7Xeu/26EjeC7JQ00KR/KeZC5tzhVGTj9E jVxl1eaUN8nAkX4rgHNHIj2me5BkMTIweLoAxFlrOfk7KXPt7zDlmm2c0fH66VvZUoA+ VID5CXQor2Ns6rMKR6JuPeYjcLgiL0VrAIuOxd9MPGC3YS6oCJ2AhtAVlWvnfnUYPmb0 16+jnvSkfL/Md90JG6xUdzXWJbK2CZZJz5Gb7GWSv52MrmtDpI4IKD3sYoumvh0YfNR+ LNpsD7ymDRjg1xtci2HnTQmNJqzAd3wf5QNsgCmzqlgZuADTm0VGWkFM/48EqT5KvOpa Hv5w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Fuu1sJ8e; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i5si3909253pfo.189.2019.01.18.00.28.41; Fri, 18 Jan 2019 00:28:56 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Fuu1sJ8e; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727709AbfARI1L (ORCPT + 99 others); Fri, 18 Jan 2019 03:27:11 -0500 Received: from mail.kernel.org ([198.145.29.99]:45396 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726309AbfARI1L (ORCPT ); Fri, 18 Jan 2019 03:27:11 -0500 Received: from bbrezillon (91-160-177-164.subs.proxad.net [91.160.177.164]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id A6B1C2087E; Fri, 18 Jan 2019 08:27:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1547800029; bh=YcQaC4KFmcrUUhdlDPZXzh5YuwmNVmg5BMnMczBl5ns=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=Fuu1sJ8eIHlNHmopJlyGNumnHw7m4UopHbCkGFwaUvh0ES6tL3UVCQVn1lUEUJULS DdQAUtyfyl2xb2DebxkQEXN4H5YmT1Sfb6JKKTpRQDeojIQXolqSk7xOHf5xg37g91 WNgPuBvXf4Ewd1ZXKrHlhtr+R7sVll3ClUM6l+Bw= Date: Fri, 18 Jan 2019 09:26:57 +0100 From: Boris Brezillon To: Paul Cercueil Cc: David Woodhouse , Brian Norris , Marek Vasut , Richard Weinberger , Rob Herring , Mark Rutland , Ralf Baechle , Paul Burton , James Hogan , Miquel Raynal , Harvey Hunt , linux-mtd@lists.infradead.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mips@vger.kernel.org Subject: Re: [PATCH 4/8] mtd: rawnand: jz4780: Add support for the JZ4725B Message-ID: <20190118092657.0293b819@bbrezillon> In-Reply-To: <20190118010634.27399-4-paul@crapouillou.net> References: <20190118010634.27399-1-paul@crapouillou.net> <20190118010634.27399-4-paul@crapouillou.net> X-Mailer: Claws Mail 3.16.0 (GTK+ 2.24.32; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 17 Jan 2019 22:06:30 -0300 Paul Cercueil wrote: > Add support for probing the jz4780-nand driver on the JZ4725B SoC from > Ingenic. > > Signed-off-by: Paul Cercueil Reviewed-by: Boris Brezillon BTW, if you have some time, maybe you could convert this driver to ->exec_op() ;-). > --- > drivers/mtd/nand/raw/jz4780_nand.c | 39 +++++++++++++++++++++++++++++--------- > 1 file changed, 30 insertions(+), 9 deletions(-) > > diff --git a/drivers/mtd/nand/raw/jz4780_nand.c b/drivers/mtd/nand/raw/jz4780_nand.c > index 7f55358b860f..cf24bf12884f 100644 > --- a/drivers/mtd/nand/raw/jz4780_nand.c > +++ b/drivers/mtd/nand/raw/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) > @@ -272,8 +276,8 @@ static int jz4780_nand_init_chip(struct platform_device *pdev, > return -ENOMEM; > mtd->dev.parent = dev; > > - chip->legacy.IO_ADDR_R = cs->base + OFFSET_DATA; > - chip->legacy.IO_ADDR_W = cs->base + OFFSET_DATA; > + chip->legacy.IO_ADDR_R = cs->base + nfc->soc_info->data_offset; > + chip->legacy.IO_ADDR_W = cs->base + nfc->soc_info->data_offset; > chip->legacy.chip_delay = RB_DELAY_US; > chip->options = NAND_NO_SUBPAGE_WRITE; > chip->legacy.select_chip = jz4780_nand_select_chip; > @@ -353,6 +357,10 @@ static int jz4780_nand_probe(struct platform_device *pdev) > if (!nfc) > return -ENOMEM; > > + nfc->soc_info = 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 +398,21 @@ static int jz4780_nand_remove(struct platform_device *pdev) > return 0; > } > > +static const struct jz_soc_info jz4725b_soc_info = { > + .data_offset = 0x00000000, > + .cmd_offset = 0x00008000, > + .addr_offset = 0x00010000, > +}; > + > +static const struct jz_soc_info jz4780_soc_info = { > + .data_offset = 0x00000000, > + .cmd_offset = 0x00400000, > + .addr_offset = 0x00800000, > +}; > + > static const struct of_device_id jz4780_nand_dt_match[] = { > - { .compatible = "ingenic,jz4780-nand" }, > + { .compatible = "ingenic,jz4725b-nand", .data = &jz4725b_soc_info }, > + { .compatible = "ingenic,jz4780-nand", .data = &jz4780_soc_info }, > {}, > }; > MODULE_DEVICE_TABLE(of, jz4780_nand_dt_match);