Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756985AbbLHQgQ (ORCPT ); Tue, 8 Dec 2015 11:36:16 -0500 Received: from mailapp01.imgtec.com ([195.59.15.196]:33956 "EHLO mailapp01.imgtec.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750942AbbLHQgP (ORCPT ); Tue, 8 Dec 2015 11:36:15 -0500 Subject: Re: [PATCH v9 2/3] mtd: nand: jz4780: driver for NAND devices on JZ4780 SoCs To: Boris Brezillon References: <1449144142-24004-1-git-send-email-harvey.hunt@imgtec.com> <1449144142-24004-3-git-send-email-harvey.hunt@imgtec.com> <20151208151436.11ce72f4@bbrezillon> <5666FF6B.5090309@imgtec.com> <20151208172641.4e1f935a@bbrezillon> CC: , Zubair Lutfullah Kakakhel , , Alex Smith , Brian Norris , "David Woodhouse" From: Harvey Hunt Message-ID: <566706FC.9020606@imgtec.com> Date: Tue, 8 Dec 2015 16:36:12 +0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.4.0 MIME-Version: 1.0 In-Reply-To: <20151208172641.4e1f935a@bbrezillon> Content-Type: text/plain; charset="windows-1252"; format=flowed Content-Transfer-Encoding: 7bit X-Originating-IP: [192.168.154.22] Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2092 Lines: 70 On 08/12/15 16:26, Boris Brezillon wrote: > On Tue, 8 Dec 2015 16:03:55 +0000 > Harvey Hunt wrote: > >>> >>> static void jz4780_nand_cmd_ctrl(struct mtd_info *mtd, int cmd, >>> unsigned int ctrl) >>> { >>> struct jz4780_nand_chip *nand = to_jz4780_nand_chip(mtd); >>> struct jz4780_nand_controller *nfc = to_jz4780_nand_controller(nand->chip.controller); >>> struct jz4780_nand_cs *cs; >>> >>> if (WARN_ON(nfc->selected < 0)) >>> return; >>> >>> cs = &nfc->cs[nfc->selected]; >>> >>> if (ctrl & NAND_CTRL_CHANGE) { >>> if (cmd != NAND_CMD_NONE) { >>> if (ctrl & NAND_ALE) >>> writeb(cmd, cs->base + OFFSET_ADDR); >>> else if (ctrl & NAND_CLE) >>> writeb(cmd, cs->base + OFFSET_CMD); >>> } >>> >>> jz4780_nemc_assert(nfc->dev, cs->bank, ctrl & NAND_NCE); >>> } >>> } >>> >> >> Okay, I understand your point now. I would also have to implement the >> read/write functions to replace the defaults, correct? If so, it feels >> strange to add functions to reimplement the default ones. >> > > Actually it should be something like this, because NAND_CTRL_CHANGE is > cleared after the first address cycle. > > static void jz4780_nand_cmd_ctrl(struct mtd_info *mtd, int cmd, > unsigned int ctrl) > { > struct jz4780_nand_chip *nand = to_jz4780_nand_chip(mtd); > struct jz4780_nand_controller *nfc = to_jz4780_nand_controller(nand->chip.controller); > struct jz4780_nand_cs *cs; > > if (WARN_ON(nfc->selected < 0)) > return; > > cs = &nfc->cs[nfc->selected]; > > jz4780_nemc_assert(nfc->dev, cs->bank, ctrl & NAND_NCE); > > if (cmd == NAND_CMD_NONE) > return; > > if (ctrl & NAND_ALE) > writeb(cmd, cs->base + OFFSET_ADDR); > else if (ctrl & NAND_CLE) > writeb(cmd, cs->base + OFFSET_CMD); > } > Thanks for the example code, I'll try it out for the next version. -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/