/* * MTK NAND Flash controller driver. * Copyright (C) 2016 MediaTek Inc. * Authors: Xiaolei Li <xiaolei.li@mediatek.com> * Jorge Ramirez-Ortiz <jorge.ramirez-ortiz@linaro.org> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. */#include<linux/platform_device.h>#include<linux/dma-mapping.h>#include<linux/interrupt.h>#include<linux/delay.h>#include<linux/clk.h>#include<linux/mtd/nand.h>#include<linux/mtd/mtd.h>#include<linux/module.h>#include<linux/iopoll.h>#include<linux/of.h>#include"mtk_ecc.h"/* NAND controller register definition */#define NFI_CNFG (0x00)#define CNFG_AHB BIT(0)#define CNFG_READ_EN BIT(1)#define CNFG_DMA_BURST_EN BIT(2)#define CNFG_BYTE_RW BIT(6)#define CNFG_HW_ECC_EN BIT(8)#define CNFG_AUTO_FMT_EN BIT(9)#define CNFG_OP_CUST (6 << 12)#define NFI_PAGEFMT (0x04)#define PAGEFMT_FDM_ECC_SHIFT (12)#define PAGEFMT_FDM_SHIFT (8)#define PAGEFMT_SPARE_16 (0)#define PAGEFMT_SPARE_26 (1)#define PAGEFMT_SPARE_27 (2)#define PAGEFMT_SPARE_28 (3)#define PAGEFMT_SPARE_32 (4)#define PAGEFMT_SPARE_36 (5)#define PAGEFMT_SPARE_40 (6)#define PAGEFMT_SPARE_44 (7)#define PAGEFMT_SPARE_48 (8)#define PAGEFMT_SPARE_49 (9)#define PAGEFMT_SPARE_50 (0xa)#define PAGEFMT_SPARE_51 (0xb)#define PAGEFMT_SPARE_52 (0xc)#define PAGEFMT_SPARE_62 (0xd)