From patchwork Mon Jun 5 23:21:58 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 103099 Delivered-To: patch@linaro.org Received: by 10.182.29.35 with SMTP id g3csp1008215obh; Mon, 5 Jun 2017 16:24:39 -0700 (PDT) X-Received: by 10.84.236.6 with SMTP id q6mr18339651plk.146.1496705079269; Mon, 05 Jun 2017 16:24:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1496705079; cv=none; d=google.com; s=arc-20160816; b=OpISN9srEgthhJn4UyonQDdXXPcjeJDxpgRMv4/UU8VVy6BruDjSQlHa8gtyzBieNJ bZY+atQA2FmZ89sKTUB8WlHbvqHflCRgqskihEg/cKW6DbfWkpFmMwRVzJOJjmhU3oyB AqiVdb4Jm3ZZGCUMJnxl3tbhpPLEPBoWw5EMmp2cYL3y8/oUxRrm68zBOzfvjAUtyzY6 mh5QdCgVLwfxz8ZH8cfWUlt4QguDJ7mtLvcXsHmJ7tsOSALybY1ILf4m5TMzXRoU7e7a EQ8Gkym1KUdfnKf6CfiNRy/m58tk9hnGTPnVXdOlctTXIBwJwqIY4CWtgJCu+lmbWUS+ +ThQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:sender:content-transfer-encoding:mime-version:cc :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:references:in-reply-to:message-id:date:subject :to:from:dkim-signature:dkim-filter:dkim-signature:dkim-signature :arc-authentication-results; bh=4jUXlVuJTRhVKD6G5Ch/ja7RKNUmEt9isLAClaE7wlo=; b=sW71X2XUsqNWTZSY7XKEhg8/9x0MVA7rjYbdUvBH+OL2LW3D9Idu+N05Rag0WNbOW/ rEMRPcPLcFZQCb6b2IO/nVtxL4ChiwrhnjSB4eSTfgMelR618gvvWlvhMH+eHy3RRBnR 1qRVGT0sQXQOsypp+wuAsSL/bx4G7S0evCFxAq+MEKAOnfXj6xDKUmtT0+ZwK8GvmkPT A2wimiAffOUMoHYjEckzZQQRn/7MwTLiz2FHjkzxLbeVNbBNQbUYekuGha8zvRa+eP7E eG5Nb9Mur/BwsZXwT61r7PlqoXBNV3xgKPVV5Qa6iiREhxPjLowbgOueRM9OgbqqbfOI A7WA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@lists.infradead.org; dkim=neutral (body hash did not verify) header.i=@infradead.org; dkim=neutral (body hash did not verify) header.i=@nifty.com; spf=pass (google.com: best guess record for domain of linux-mtd-bounces+patch=linaro.org@lists.infradead.org designates 65.50.211.133 as permitted sender) smtp.mailfrom=linux-mtd-bounces+patch=linaro.org@lists.infradead.org Return-Path: Received: from bombadil.infradead.org (bombadil.infradead.org. [65.50.211.133]) by mx.google.com with ESMTPS id 1si8473665plw.319.2017.06.05.16.24.39 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 05 Jun 2017 16:24:39 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-mtd-bounces+patch=linaro.org@lists.infradead.org designates 65.50.211.133 as permitted sender) client-ip=65.50.211.133; Authentication-Results: mx.google.com; dkim=pass header.i=@lists.infradead.org; dkim=neutral (body hash did not verify) header.i=@infradead.org; dkim=neutral (body hash did not verify) header.i=@nifty.com; spf=pass (google.com: best guess record for domain of linux-mtd-bounces+patch=linaro.org@lists.infradead.org designates 65.50.211.133 as permitted sender) smtp.mailfrom=linux-mtd-bounces+patch=linaro.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-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To: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:List-Owner; bh=4jUXlVuJTRhVKD6G5Ch/ja7RKNUmEt9isLAClaE7wlo=; b=hUwxDRUtg2dCVhnaVJQxhW+B2G yh12sbLQmPYBOT8Ga70lC9ajUPZeMIow7nc/aLVELfnJq8zVzCoHTSH1gK9lOssTEdZxF22RoNiKn YWja8wJhvhW2pmL+u6vX5sq2FUIcbrefX93OOU+GZAQ7MKuofGKR3VB9FtPm2RFxTv91UKeE+UcCX bNQhb/d9GHOZIoc+95Xa/pjtdLOf1jXh3dYhi/szWgVMNJAQFsrQ9eyBbXFqgtZ9KSYsg7wtgXQCB lcv9eYVRdYr4JBsm7TqmLO0GbhbB7wjK1suq91kM3RZUwS8GHXhvI0W50/6xFVBzTMQKFGDdGrTk6 8WbMWumg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1dI1MG-0000Pa-33; Mon, 05 Jun 2017 23:24:24 +0000 Received: from casper.infradead.org ([2001:770:15f::2]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1dI1ME-0000Nl-Qj for linux-mtd@bombadil.infradead.org; Mon, 05 Jun 2017 23:24:23 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=References:In-Reply-To:Message-Id:Date: Subject:Cc:To:From:Sender:Reply-To:MIME-Version:Content-Type: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=KhTn6sQsADa/IN2lbjaGDCxn+B1TPkDhBduOA+q/3vY=; b=hynFEuI4hvV3DUEwyu/TxSLdm 6e1Ar2KGgnPLe+m5HIfVIYMx5JkZrlkGh/s+cH++aZVYnKgJ3jKDlwNzQoGRaVy55S+N/JzX+hRkX w4zsMCQIFYIZiS84AW6cwjD9tB0KLqG/FYfQKIuONocc4Svdo0lHwpqGP6VnnWdgkv2jeDTFFxZWN 44sVFlicnhbtM0tdKrZc1Ea/OzcactK3z7wXvFjDBMJUfeDydQ0M3Nzdnu6nOwiucgdU6DPdIOH5y ObfxtQJSnOxaHXWh9S2ZFiD8or6lAyfWjUgEOx/IUlVG+xbMvKAsXSQ3k6Fx6QLtXrorC/OmhbYOl lm8SUUWng==; Received: from conuserg-10.nifty.com ([210.131.2.77]) by casper.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1dI1M6-0003vU-Mz for linux-mtd@lists.infradead.org; Mon, 05 Jun 2017 23:24:21 +0000 Received: from grover.sesame (FL1-118-110-19-204.osk.mesh.ad.jp [118.110.19.204]) (authenticated) by conuserg-10.nifty.com with ESMTP id v55NMD5t004412; Tue, 6 Jun 2017 08:22:49 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-10.nifty.com v55NMD5t004412 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1496704970; bh=KhTn6sQsADa/IN2lbjaGDCxn+B1TPkDhBduOA+q/3vY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Cao0F8j24vqNBtbz10IWz5iTJY0IY+J7Wz0VwS3Pl4zBDss/4udwUELbuhE9aQXQY wsajlNlDqZTd5fxZhB8QYjyVeZQPwyD/FENJm4Y8+lAdEtfXLi5MsVyLtIu7Z3ziYJ +6bnCGGIaLSQSWJBMzA0ddGZuowZVcjlmO985qpj8aqYys3KFrhHEt8H0nVGf5Dq4S cNanDvgJi/3Gsld01Ca+H6KlmANhgoF0+7radtLGKpky73zlatVnRKi/7UQm6yZpkP 4BryeHyUPvSwErr5hj6Irx6/kM27ogyjnRyk7GFiLj16TyW3QL5WBTBU05N55NZVMm DEMvaziORrL/w== X-Nifty-SrcIP: [118.110.19.204] From: Masahiro Yamada To: linux-mtd@lists.infradead.org Subject: [PATCH v4 19/23] mtd: nand: denali: use flag instead of register macro for direction Date: Tue, 6 Jun 2017 08:21:58 +0900 Message-Id: <1496704922-12261-20-git-send-email-yamada.masahiro@socionext.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1496704922-12261-1-git-send-email-yamada.masahiro@socionext.com> References: <1496704922-12261-1-git-send-email-yamada.masahiro@socionext.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170606_002415_770871_5EE5B9DD X-CRM114-Status: GOOD ( 19.73 ) X-Spam-Score: -1.2 (-) X-Spam-Report: SpamAssassin version 3.4.1 on casper.infradead.org summary: Content analysis details: (-1.2 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- 0.7 SPF_SOFTFAIL SPF: sender does not match SPF record (softfail) -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 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: Boris Brezillon , Richard Weinberger , Dinh Nguyen , Masahiro Yamada , Artem Bityutskiy , Cyrille Pitchen , linux-kernel@vger.kernel.org, Marek Vasut , Masami Hiramatsu , Chuanxiao Dong , Jassi Brar , Brian Norris , Enrico Jorns , David Woodhouse , Graham Moore MIME-Version: 1.0 Sender: "linux-mtd" Errors-To: linux-mtd-bounces+patch=linaro.org@lists.infradead.org It is not a good idea to re-use macros that represent a specific register bit field for the transfer direction. It is true that bit 8 indicates the direction for the MAP10 pipeline operation and the data DMA operation, but this is not valid across the IP. Use a simple flag (write: 1, read: 0) for the direction. Signed-off-by: Masahiro Yamada --- Changes in v4: None Changes in v3: None Changes in v2: - Newly added drivers/mtd/nand/denali.c | 36 +++++++++++++++++------------------- 1 file changed, 17 insertions(+), 19 deletions(-) -- 2.7.4 ______________________________________________________ Linux MTD discussion mailing list http://lists.infradead.org/mailman/listinfo/linux-mtd/ diff --git a/drivers/mtd/nand/denali.c b/drivers/mtd/nand/denali.c index 755825d..d156d95 100644 --- a/drivers/mtd/nand/denali.c +++ b/drivers/mtd/nand/denali.c @@ -53,9 +53,6 @@ static inline struct denali_nand_info *mtd_to_denali(struct mtd_info *mtd) #define MAIN_ACCESS 0x42 #define MAIN_SPARE_ACCESS 0x43 -#define DENALI_READ 0 -#define DENALI_WRITE 0x100 - #define DENALI_NR_BANKS 4 /* @@ -284,7 +281,7 @@ static int denali_dev_ready(struct mtd_info *mtd) */ static int denali_send_pipeline_cmd(struct denali_nand_info *denali, int page, bool ecc_en, bool transfer_spare, - int access_type, int op) + int access_type, int write) { int status = PASS; uint32_t addr, cmd; @@ -295,17 +292,17 @@ static int denali_send_pipeline_cmd(struct denali_nand_info *denali, int page, addr = BANK(denali->flash_bank) | page; - if (op == DENALI_WRITE && access_type != SPARE_ACCESS) { + if (write && access_type != SPARE_ACCESS) { cmd = MODE_01 | addr; iowrite32(cmd, denali->flash_mem); - } else if (op == DENALI_WRITE && access_type == SPARE_ACCESS) { + } else if (write && access_type == SPARE_ACCESS) { /* read spare area */ cmd = MODE_10 | addr; index_addr(denali, cmd, access_type); cmd = MODE_01 | addr; iowrite32(cmd, denali->flash_mem); - } else if (op == DENALI_READ) { + } else { /* setup page read request for access type */ cmd = MODE_10 | addr; index_addr(denali, cmd, access_type); @@ -367,7 +364,7 @@ static int write_oob_data(struct mtd_info *mtd, uint8_t *buf, int page) int status = 0; if (denali_send_pipeline_cmd(denali, page, false, false, SPARE_ACCESS, - DENALI_WRITE) == PASS) { + 1) == PASS) { write_data_to_flash_mem(denali, buf, mtd->oobsize); /* wait for operation to complete */ @@ -392,7 +389,7 @@ static void read_oob_data(struct mtd_info *mtd, uint8_t *buf, int page) uint32_t irq_status, addr, cmd; if (denali_send_pipeline_cmd(denali, page, false, true, SPARE_ACCESS, - DENALI_READ) == PASS) { + 0) == PASS) { read_data_from_flash_mem(denali, buf, mtd->oobsize); /* @@ -578,7 +575,7 @@ static void denali_enable_dma(struct denali_nand_info *denali, bool en) } static void denali_setup_dma64(struct denali_nand_info *denali, - dma_addr_t dma_addr, int page, int op) + dma_addr_t dma_addr, int page, int write) { uint32_t mode; const int page_count = 1; @@ -591,7 +588,8 @@ static void denali_setup_dma64(struct denali_nand_info *denali, * 1. setup transfer type, interrupt when complete, * burst len = 64 bytes, the number of pages */ - index_addr(denali, mode, 0x01002000 | (64 << 16) | op | page_count); + index_addr(denali, mode, + 0x01002000 | (64 << 16) | (write << 8) | page_count); /* 2. set memory low address */ index_addr(denali, mode, dma_addr); @@ -601,7 +599,7 @@ static void denali_setup_dma64(struct denali_nand_info *denali, } static void denali_setup_dma32(struct denali_nand_info *denali, - dma_addr_t dma_addr, int page, int op) + dma_addr_t dma_addr, int page, int write) { uint32_t mode; const int page_count = 1; @@ -611,7 +609,7 @@ static void denali_setup_dma32(struct denali_nand_info *denali, /* DMA is a four step process */ /* 1. setup transfer type and # of pages */ - index_addr(denali, mode | page, 0x2000 | op | page_count); + index_addr(denali, mode | page, 0x2000 | (write << 8) | page_count); /* 2. set memory high address bits 23:8 */ index_addr(denali, mode | ((dma_addr >> 16) << 8), 0x2200); @@ -624,12 +622,12 @@ static void denali_setup_dma32(struct denali_nand_info *denali, } static void denali_setup_dma(struct denali_nand_info *denali, - dma_addr_t dma_addr, int page, int op) + dma_addr_t dma_addr, int page, int write) { if (denali->caps & DENALI_CAP_DMA_64BIT) - denali_setup_dma64(denali, dma_addr, page, op); + denali_setup_dma64(denali, dma_addr, page, write); else - denali_setup_dma32(denali, dma_addr, page, op); + denali_setup_dma32(denali, dma_addr, page, write); } /* @@ -668,7 +666,7 @@ static int write_page(struct mtd_info *mtd, struct nand_chip *chip, denali_reset_irq(denali); denali_enable_dma(denali, true); - denali_setup_dma(denali, addr, page, DENALI_WRITE); + denali_setup_dma(denali, addr, page, 1); /* wait for operation to complete */ irq_status = denali_wait_for_irq(denali, irq_mask); @@ -750,7 +748,7 @@ static int denali_read_page(struct mtd_info *mtd, struct nand_chip *chip, dma_sync_single_for_device(denali->dev, addr, size, DMA_FROM_DEVICE); denali_reset_irq(denali); - denali_setup_dma(denali, addr, page, DENALI_READ); + denali_setup_dma(denali, addr, page, 0); /* wait for operation to complete */ irq_status = denali_wait_for_irq(denali, irq_mask); @@ -793,7 +791,7 @@ static int denali_read_page_raw(struct mtd_info *mtd, struct nand_chip *chip, dma_sync_single_for_device(denali->dev, addr, size, DMA_FROM_DEVICE); denali_reset_irq(denali); - denali_setup_dma(denali, addr, page, DENALI_READ); + denali_setup_dma(denali, addr, page, 0); /* wait for operation to complete */ irq_status = denali_wait_for_irq(denali, irq_mask);