Received: by 2002:ac0:8c9a:0:0:0:0:0 with SMTP id r26csp590817ima; Fri, 1 Feb 2019 07:54:55 -0800 (PST) X-Google-Smtp-Source: ALg8bN71zT3NRMrAdqgCjEiQAy5Q3buozranRMyd1bGgzCkQRLMgKlgfmaYHcCSL1M3XkCGyN3ST X-Received: by 2002:a17:902:8a8a:: with SMTP id p10mr40605342plo.50.1549036495561; Fri, 01 Feb 2019 07:54:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1549036495; cv=none; d=google.com; s=arc-20160816; b=L5jkUVtLRsvaIVyw3IvRYCUlFU85tuWtRbVMbbTmkeAH46txPtfoNI4POOAbzpsCGz 119KzuoyLbqjR0v6PyY7hpMask8DQIw9DgFOA4BzxEttM4C5aO6FUfGDQHFjSmJ3XDsZ E5z7fjvf5eq2Q1wQuNO30dyqrFjpSTWaAhyV4tC+8Vt4h8TSBi3RY70EoQwxHMcSeO6B tyXUgZ2fJ1y0Xnr3szQUFy7C4Hd+qbeuJj4LSIAlLvnxFuOgxKfsm67Cp0Ea3ZPP2tPQ 7+r7XUCxnJOtJFK8z7d75vBjOTcnth/gGdO/EKTi8xblkfFmYTPac4WgPZRIwOJz4Mwx RWHw== 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=rFKx+XMvKc5zpQG7pXFSVe3Q51z1cEDbb9POCkHg2hg=; b=HllMJrI59C2bDbER2phGIaeMTWF4xW8e/ZZdhUa+FXX8iurCfXP5lXuibEHAqLSBrg HeHxqTcoAp7YJ+tsH9tfXEBn2sLis6EMA3XOUg4BQD5ex1kFEqE7+T0bBLFgAuMj6DYS x05imMUMyHrNse2tf8ulIlDzv9do2JHBV60ymdhf1579kEIAAG9akObxXbJ9k8dpdjQ7 BI1Q7Fe2eKXBBU5aph282X6Kmpo7ydkYt+oano69caSLK3dKSBu1bVtbX+yzbkWNehge mu7gKdn67KGqEZnJKI0XIc+nvSfBt64D+B6C/cNbO5vZFhdZEnT5Cmj7ik5L88XywFqs /ejw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=q+RJeNpI; 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 e21si7104598pgg.571.2019.02.01.07.54.40; Fri, 01 Feb 2019 07:54:55 -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=q+RJeNpI; 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 S1730239AbfBAPxY (ORCPT + 99 others); Fri, 1 Feb 2019 10:53:24 -0500 Received: from mail.kernel.org ([198.145.29.99]:58426 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726972AbfBAPxY (ORCPT ); Fri, 1 Feb 2019 10:53:24 -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 E97A22086C; Fri, 1 Feb 2019 15:53:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1549036403; bh=J05/pA4Tw3IyG/X7lPNXAUT0bLf1MB9DtIwPQW/iEvc=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=q+RJeNpI6tMS+cNBQgXFGRoY9jxzot3W4hbwqRh3gYrEaGNWcltzXn/2GMhxxsHL6 1mAl3kONo1YykXQ7LeHJENSHm3oAMruNv4xQFRBNIUtNFWrwyBMv2rp55cVP6uDD2h jrP7K5tIq1tZljgCPIesJhWZcQqDgM3TF89MRQxM= Date: Fri, 1 Feb 2019 16:53:13 +0100 From: Boris Brezillon To: Masahiro Yamada Cc: Boris Brezillon , Miquel Raynal , linux-mtd , Linux Kernel Mailing List Subject: Re: [Question] setup_data_interface() hook when switching to a different type of NAND chip Message-ID: <20190201165218.22a0ac21@bbrezillon> In-Reply-To: References: 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 Hi Masahiro, On Fri, 1 Feb 2019 19:27:46 +0900 Masahiro Yamada wrote: > Hi. > > > When I was looking into the NAND controller/chips separation, > this question popped up in my mind. > > > Commit 2d472aba15ff169 provides us a more flexibility > about the controller/chips connection. > The connected NAND chips do not need to be homogeneous > any more. > > > My question is about the ->setup_data_interface() hook > when switching between NAND chips with different speed (timing mode). > > > Think about the case below: > > { > compatible = "foo-nand-controller"; > reg = <...>; > #address-cells = <1>; > #size-cells = <0>; > > nand@0 { > reg = <0>; > /* Slow NAND chip */ > } > > nand@1 { > reg = <1>; > /* Fast NAND chip */ > } > > } > > > > In this case, two devices /dev/mtdblock0 and /dev/mtdblock1 > will appear. > > If a user gets access to those two devices in turns, > I think ->setup_data_interface() should be invoked somehow > in order to update the timing registers on the controller side. > > Currently, ->setup_data_interface() is invoked in nand_scan_tail() > and that's it. > > So, both nand@0 and nand@1 are accessed by the timing mode of nand@1 > (assuming nand@0 and nand@1 are initialized in this order) > > > Of course, it depends on the controller. > > If a controller has a register set for every chip select, > the hardware will be able to change the access speed automatically. > > > I think most of controllers just have a single set of timing registers. > So, when switching between different types of chips, > the driver must update the timing registers. > > > If this is a worthwhile usecase, > should it be taken care of by the NAND framework, > or by drivers ? > > > I just thought we could do something in > nand_get_device() / nand_release_device(). > > > If this should be done per driver, > drivers can update registers in select_target or select_chip. > > > Thought? It should be done by the driver in its select_target() handler. Actually, it's already done like that in several drivers (marvell, sunxi, ...). ->setup_data_interface() is not required to apply timings right away. What it should do is convert the NAND timings into controller timings. Of course, if the controller has one set of timing regs per CS, the driver can apply timings right away, but when that's not the case, controller timings should be stored in the private nand data and applied when the chip is selected. Feel free to enhance the ->setup_data_interface() doc if you think it's not clear enough. Regards, Boris