From patchwork Tue Apr 17 19:10:59 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ronak Desai X-Patchwork-Id: 899587 X-Patchwork-Delegate: boris.brezillon@free-electrons.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:e::133; helo=bombadil.infradead.org; envelope-from=linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=rockwellcollins.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="eRoAB6QF"; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 40QZcT1xGqz9s1t for ; Wed, 18 Apr 2018 05:11:50 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To: References:List-Owner; bh=heoWTWrZXSrRfdP8CPYbg2yncGOYDJzJUYPlBvoAs1U=; b=eRo AB6QF/BAj2qLBLE/4azLoL28N4OV5HASwB0bQS12rj+PGCdP+v55gcxGL7YuSFJM9Etdqt96UdvhJ +AbjYhn/0CRWBxO5rfSYnlTTOFOVTwdMBMt1JD3udYAEZmPKU8CIBfBOcQAuU2093bKi0r8Ojw8JN UTz/gr67WWzrM/WWdVwUBWyg53tu3c4/U4+TKVVKofKUVRijM9leYczR+mftIbQR7QdoTrLf718Ip 4G6uey3nr8uDfrMomlV50O06mN1MRV9Qt58MVAGjMSmtzKXruTIGaQuTTtPkJdXP1dJTdeN51fh5J E9Alms6Uw64r+FQ1VYJlRDZSjrje9Zg==; 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 1f8W0v-0000rS-C1; Tue, 17 Apr 2018 19:11:37 +0000 Received: from ch3vs03.rockwellcollins.com ([205.175.226.47]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1f8W0r-0000pn-Q1 for linux-mtd@lists.infradead.org; Tue, 17 Apr 2018 19:11:35 +0000 Received: from ofwch3n02.rockwellcollins.com (HELO ciulimr01.rockwellcollins.com) ([205.175.226.14]) by ch3vs03.rockwellcollins.com with ESMTP; 17 Apr 2018 14:11:20 -0500 X-Received: from largo.rockwellcollins.com (unknown [192.168.140.76]) by ciulimr01.rockwellcollins.com (Postfix) with ESMTP id 742C4600F9; Tue, 17 Apr 2018 14:11:20 -0500 (CDT) From: Ronak Desai To: linux-mtd@lists.infradead.org Subject: [PATCH] Added set feature command in FSL IFC nand controller driver for ONFI nand Date: Tue, 17 Apr 2018 14:10:59 -0500 Message-Id: <1523992259-56588-1-git-send-email-ronak.desai@rockwellcollins.com> X-Mailer: git-send-email 1.9.1 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180417_121133_967763_E5EF53DD X-CRM114-Status: GOOD ( 11.27 ) X-Spam-Score: -0.0 (/) X-Spam-Report: SpamAssassin version 3.4.1 on bombadil.infradead.org summary: Content analysis details: (-0.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at http://www.dnswl.org/, no trust [205.175.226.47 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 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: ronak.desai@rockwellcollins.com, prabhakar.kushwaha@nxp.com MIME-Version: 1.0 Sender: "linux-mtd" Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org This patch adds set feature command (EFh) support in Freescale IFC nand controller driver. The SET FEATURES (EFh) command is used to modify the target's default power-on behavior. This command uses one-byte feature address to determine which sub-feature parameters will be modified. Signed-off-by: Ronak Desai --- drivers/mtd/nand/fsl_ifc_nand.c | 51 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) -- 1.7.9.5 diff --git a/drivers/mtd/nand/fsl_ifc_nand.c b/drivers/mtd/nand/fsl_ifc_nand.c index af85c4b..20b97ef 100644 --- a/drivers/mtd/nand/fsl_ifc_nand.c +++ b/drivers/mtd/nand/fsl_ifc_nand.c @@ -613,6 +613,23 @@ static void fsl_ifc_cmdfunc(struct mtd_info *mtd, unsigned int command, fsl_ifc_run_command(mtd); return; + case NAND_CMD_SET_FEATURES: { + ifc_out32((IFC_FIR_OP_CW0 << IFC_NAND_FIR0_OP0_SHIFT) | + (IFC_FIR_OP_UA << IFC_NAND_FIR0_OP1_SHIFT) | + (IFC_FIR_OP_WBCD << IFC_NAND_FIR0_OP2_SHIFT), + &ifc->ifc_nand.nand_fir0); + + ifc_out32((NAND_CMD_SET_FEATURES << IFC_NAND_FCR0_CMD0_SHIFT), + &ifc->ifc_nand.nand_fcr0); + + ifc_out32(column, &ifc->ifc_nand.row3); + + /* Write only 4 bytes from flash buffer */ + ifc_out32(4, &ifc->ifc_nand.nand_fbcr); + fsl_ifc_run_command(mtd); + return; + } + case NAND_CMD_RNDOUT: { __le16 Tccs = 0; chip->onfi_version ? (Tccs = chip->onfi_params.t_ccs) @@ -905,6 +922,39 @@ static void fsl_ifc_sram_init(struct fsl_ifc_mtd *priv) ifc_out32(csor_ext, &ifc_global->csor_cs[cs].csor_ext); } +/** + * fsl_ifc_onfi_set_features- set features for ONFI nand + * @mtd: MTD device structure + * @chip: nand chip info structure + * @addr: feature address. + * @subfeature_param: the subfeature parameters, a four bytes array. + */ +static int fsl_ifc_onfi_set_features(struct mtd_info *mtd, struct nand_chip *chip, + int addr, uint8_t *subfeature_param) +{ + int status; + int i; + +#ifdef CONFIG_SYS_NAND_ONFI_DETECTION + if (!chip->onfi_version || + !(le16_to_cpu(chip->onfi_params.opt_cmd) + & ONFI_OPT_CMD_SET_GET_FEATURES)) + return -EINVAL; +#endif + + /* Want data from start of the buffer */ + set_addr(mtd, 0, 0, 0); + + for (i = 0; i < ONFI_SUBFEATURE_PARAM_LEN; ++i) + chip->write_byte(mtd, subfeature_param[i]); + + chip->cmdfunc(mtd, NAND_CMD_SET_FEATURES, addr, 0); + + status = chip->waitfunc(mtd, chip); + if (status & NAND_STATUS_FAIL) + return -EIO; + return 0; +} static int fsl_ifc_chip_init(struct fsl_ifc_mtd *priv) { struct fsl_ifc_ctrl *ctrl = priv->ctrl; @@ -932,6 +982,7 @@ static int fsl_ifc_chip_init(struct fsl_ifc_mtd *priv) chip->select_chip = fsl_ifc_select_chip; chip->cmdfunc = fsl_ifc_cmdfunc; chip->waitfunc = fsl_ifc_wait; + chip->onfi_set_features = fsl_ifc_onfi_set_features; chip->bbt_td = &bbt_main_descr; chip->bbt_md = &bbt_mirror_descr;