From patchwork Wed Apr 11 03:41:54 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: xiaolei li X-Patchwork-Id: 10334819 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 4B57C6053C for ; Wed, 11 Apr 2018 03:44:04 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 430A122230 for ; Wed, 11 Apr 2018 03:44:04 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3796728674; Wed, 11 Apr 2018 03:44:04 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, MAILING_LIST_MULTI, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id ACB4F22230 for ; Wed, 11 Apr 2018 03:44:03 +0000 (UTC) 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:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version: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=7AUci7o5VwoixL6NBN0gPODqZy2gL5oxBRsFtXs9Wck=; b=A7MV51uAxYpgqW u5Jr83PiSY3X3+pIcxgtF8jmTngwJolqcpQ+XDEpKqIpVFpWfm/bwNOlB1VkWqw5rqjO0dbxJgVdg d6GzLmQNZxOH3G7eZZWb4mdTfTYs3NjanpgFWELc1o6HyqEN0HZ7R6B3Q7MWld6Xoh9+wtN8D95T8 ZZOvWpAVItxD16C1rVys2UiQYrT6WicSa/f/7pjhWxsr1JMyKr4/P7FoMMJG5IUPA3MMKMHD1uNks 7I0y+ZBh5QgMRyP0W/N9S4Vd/V6NiXvtPvAkFqupGUaFDEDjPu4lcPJjNeWwiDVeasZ3PGjATxy5J nVs5FCgWEIgCaIvla+sw==; 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 1f66fw-0002pZ-SN; Wed, 11 Apr 2018 03:44:00 +0000 Received: from [210.61.82.184] (helo=mailgw02.mediatek.com) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1f66eT-0001v7-SC; Wed, 11 Apr 2018 03:42:33 +0000 X-UUID: 84b0377384834addb503dbea87a6308f-20180411 Received: from mtkexhb01.mediatek.inc [(172.21.101.102)] by mailgw02.mediatek.com (envelope-from ) (mhqrelay.mediatek.com ESMTP with TLS) with ESMTP id 2066783719; Wed, 11 Apr 2018 11:42:14 +0800 Received: from MTKCAS06.mediatek.inc (172.21.101.30) by mtkmbs03n2.mediatek.inc (172.21.101.182) with Microsoft SMTP Server (TLS) id 15.0.1210.3; Wed, 11 Apr 2018 11:42:12 +0800 Received: from mtkslt306.mediatek.inc (10.21.14.136) by MTKCAS06.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1210.3 via Frontend Transport; Wed, 11 Apr 2018 11:42:12 +0800 From: Xiaolei Li To: , Subject: [PATCH 4/8] mtd: rawnand: mtk: Remove max_sector_size from struct mtk_nfc_caps Date: Wed, 11 Apr 2018 11:41:54 +0800 Message-ID: <1523418118-57686-5-git-send-email-xiaolei.li@mediatek.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1523418118-57686-1-git-send-email-xiaolei.li@mediatek.com> References: <1523418118-57686-1-git-send-email-xiaolei.li@mediatek.com> MIME-Version: 1.0 X-MTK: N X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180410_204230_050666_B5F65DE2 X-CRM114-Status: GOOD ( 12.00 ) X-BeenThere: linux-mediatek@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-mediatek@lists.infradead.org, xiaolei.li@mediatek.com, linux-mtd@lists.infradead.org, srv_heupstream@mediatek.com Sender: "Linux-mediatek" Errors-To: linux-mediatek-bounces+patchwork-linux-mediatek=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Remove max_sector_size from struct mtk_nfc_caps, and use sector size array and number of sector size to show sector sizes that controller supports. Signed-off-by: Xiaolei Li --- drivers/mtd/nand/raw/mtk_nand.c | 32 +++++++++++++++++++++++++++----- 1 file changed, 27 insertions(+), 5 deletions(-) diff --git a/drivers/mtd/nand/raw/mtk_nand.c b/drivers/mtd/nand/raw/mtk_nand.c index b05f619..2c244c2 100644 --- a/drivers/mtd/nand/raw/mtk_nand.c +++ b/drivers/mtd/nand/raw/mtk_nand.c @@ -105,10 +105,11 @@ struct mtk_nfc_caps { const u8 *spare_size; u8 num_spare_size; + const int *sector_size; + int num_sector_size; u8 pageformat_spare_shift; u8 nfi_clk_div; u8 max_sector; - u32 max_sector_size; }; struct mtk_nfc_bad_mark_ctl { @@ -177,6 +178,14 @@ struct mtk_nfc { 16, 26, 27, 28 }; +static const int sector_size_max_1k[] = { + 1024, 512 +}; + +static const int sector_size_max_512[] = { + 512 +}; + static inline struct mtk_nfc_nand_chip *to_mtk_nand(struct nand_chip *nand) { return container_of(nand, struct mtk_nfc_nand_chip, nand); @@ -257,6 +266,16 @@ static inline u8 nfi_readb(struct mtk_nfc *nfc, u32 reg) return readb_relaxed(nfc->regs + reg); } +static int mtk_nfc_max_sector_size(struct mtk_nfc *nfc) +{ + int i, sector_size = 0; + + for (i = 0; i < nfc->caps->num_sector_size; i++) + sector_size = max(sector_size, nfc->caps->sector_size[i]); + + return sector_size; +} + static void mtk_nfc_hw_reset(struct mtk_nfc *nfc) { struct device *dev = nfc->dev; @@ -1211,7 +1230,7 @@ static int mtk_nfc_ecc_init(struct device *dev, struct mtd_info *mtd) */ if (nand->ecc.size < 1024) { if (mtd->writesize > 512 && - nfc->caps->max_sector_size > 512) { + mtk_nfc_max_sector_size(nfc) > 512) { nand->ecc.size = 1024; nand->ecc.strength <<= 1; } else { @@ -1400,28 +1419,31 @@ static int mtk_nfc_nand_chips_init(struct device *dev, struct mtk_nfc *nfc) static const struct mtk_nfc_caps mtk_nfc_caps_mt2701 = { .spare_size = spare_size_mt2701, .num_spare_size = 16, + .sector_size = sector_size_max_1k, + .num_sector_size = 2, .pageformat_spare_shift = 4, .nfi_clk_div = 1, .max_sector = 16, - .max_sector_size = 1024, }; static const struct mtk_nfc_caps mtk_nfc_caps_mt2712 = { .spare_size = spare_size_mt2712, .num_spare_size = 19, + .sector_size = sector_size_max_1k, + .num_sector_size = 2, .pageformat_spare_shift = 16, .nfi_clk_div = 2, .max_sector = 16, - .max_sector_size = 1024, }; static const struct mtk_nfc_caps mtk_nfc_caps_mt7622 = { .spare_size = spare_size_mt7622, .num_spare_size = 4, + .sector_size = sector_size_max_512, + .num_sector_size = 1, .pageformat_spare_shift = 4, .nfi_clk_div = 1, .max_sector = 8, - .max_sector_size = 512, }; static const struct of_device_id mtk_nfc_id_table[] = {