2010-05-13 22:57:33 +08:00
|
|
|
/*
|
|
|
|
* NAND Flash Controller Device Driver
|
|
|
|
* Copyright (c) 2009 - 2010, Intel Corporation and its suppliers.
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify it
|
|
|
|
* under the terms and conditions of the GNU General Public License,
|
|
|
|
* version 2, as published by the Free Software Foundation.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope 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.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License along with
|
|
|
|
* this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2014-08-29 19:00:51 +08:00
|
|
|
#ifndef __DENALI_H__
|
|
|
|
#define __DENALI_H__
|
|
|
|
|
2017-03-30 14:45:52 +08:00
|
|
|
#include <linux/bitops.h>
|
2010-07-22 01:32:26 +08:00
|
|
|
#include <linux/mtd/nand.h>
|
2010-05-13 22:57:33 +08:00
|
|
|
|
|
|
|
#define DEVICE_RESET 0x0
|
2017-06-06 07:21:41 +08:00
|
|
|
#define DEVICE_RESET__BANK(bank) BIT(bank)
|
2010-05-13 22:57:33 +08:00
|
|
|
|
|
|
|
#define TRANSFER_SPARE_REG 0x10
|
2017-06-06 07:21:41 +08:00
|
|
|
#define TRANSFER_SPARE_REG__FLAG BIT(0)
|
2010-05-13 22:57:33 +08:00
|
|
|
|
|
|
|
#define LOAD_WAIT_CNT 0x20
|
2017-06-06 07:21:41 +08:00
|
|
|
#define LOAD_WAIT_CNT__VALUE GENMASK(15, 0)
|
2010-05-13 22:57:33 +08:00
|
|
|
|
|
|
|
#define PROGRAM_WAIT_CNT 0x30
|
2017-06-06 07:21:41 +08:00
|
|
|
#define PROGRAM_WAIT_CNT__VALUE GENMASK(15, 0)
|
2010-05-13 22:57:33 +08:00
|
|
|
|
|
|
|
#define ERASE_WAIT_CNT 0x40
|
2017-06-06 07:21:41 +08:00
|
|
|
#define ERASE_WAIT_CNT__VALUE GENMASK(15, 0)
|
2010-05-13 22:57:33 +08:00
|
|
|
|
|
|
|
#define INT_MON_CYCCNT 0x50
|
2017-06-06 07:21:41 +08:00
|
|
|
#define INT_MON_CYCCNT__VALUE GENMASK(15, 0)
|
2010-05-13 22:57:33 +08:00
|
|
|
|
|
|
|
#define RB_PIN_ENABLED 0x60
|
2017-06-06 07:21:41 +08:00
|
|
|
#define RB_PIN_ENABLED__BANK(bank) BIT(bank)
|
2010-05-13 22:57:33 +08:00
|
|
|
|
|
|
|
#define MULTIPLANE_OPERATION 0x70
|
2017-06-06 07:21:41 +08:00
|
|
|
#define MULTIPLANE_OPERATION__FLAG BIT(0)
|
2010-05-13 22:57:33 +08:00
|
|
|
|
|
|
|
#define MULTIPLANE_READ_ENABLE 0x80
|
2017-06-06 07:21:41 +08:00
|
|
|
#define MULTIPLANE_READ_ENABLE__FLAG BIT(0)
|
2010-05-13 22:57:33 +08:00
|
|
|
|
|
|
|
#define COPYBACK_DISABLE 0x90
|
2017-06-06 07:21:41 +08:00
|
|
|
#define COPYBACK_DISABLE__FLAG BIT(0)
|
2010-05-13 22:57:33 +08:00
|
|
|
|
|
|
|
#define CACHE_WRITE_ENABLE 0xa0
|
2017-06-06 07:21:41 +08:00
|
|
|
#define CACHE_WRITE_ENABLE__FLAG BIT(0)
|
2010-05-13 22:57:33 +08:00
|
|
|
|
|
|
|
#define CACHE_READ_ENABLE 0xb0
|
2017-06-06 07:21:41 +08:00
|
|
|
#define CACHE_READ_ENABLE__FLAG BIT(0)
|
2010-05-13 22:57:33 +08:00
|
|
|
|
|
|
|
#define PREFETCH_MODE 0xc0
|
2017-06-06 07:21:41 +08:00
|
|
|
#define PREFETCH_MODE__PREFETCH_EN BIT(0)
|
|
|
|
#define PREFETCH_MODE__PREFETCH_BURST_LENGTH GENMASK(15, 4)
|
2010-05-13 22:57:33 +08:00
|
|
|
|
|
|
|
#define CHIP_ENABLE_DONT_CARE 0xd0
|
2017-06-06 07:21:41 +08:00
|
|
|
#define CHIP_EN_DONT_CARE__FLAG BIT(0)
|
2010-05-13 22:57:33 +08:00
|
|
|
|
|
|
|
#define ECC_ENABLE 0xe0
|
2017-06-06 07:21:41 +08:00
|
|
|
#define ECC_ENABLE__FLAG BIT(0)
|
2010-05-13 22:57:33 +08:00
|
|
|
|
|
|
|
#define GLOBAL_INT_ENABLE 0xf0
|
2017-06-06 07:21:41 +08:00
|
|
|
#define GLOBAL_INT_EN_FLAG BIT(0)
|
2010-05-13 22:57:33 +08:00
|
|
|
|
mtd: nand: denali: handle timing parameters by setup_data_interface()
Handling timing parameters in a driver's own way should be avoided
because it duplicates efforts of drivers/mtd/nand/nand_timings.c
Besides, this driver hard-codes Intel specific parameters such as
CLK_X=5, CLK_MULTI=4. Taking a certain device (Samsung K9WAG08U1A)
into account by get_samsung_nand_para() is weird as well.
Now, the core framework provides .setup_data_interface() hook, which
handles timing parameters in a generic manner.
While I am working on this, I found even more issues in the current
code, so fixed the following as well:
- In recent IP versions, WE_2_RE and TWHR2 share the same register.
Likewise for ADDR_2_DATA and TCWAW, CS_SETUP_CNT and TWB. When
updating one, the other must be masked. Otherwise, the other will
be set to 0, then timing settings will be broken.
- The recent IP release expanded the ADDR_2_DATA to 7-bit wide.
This register is related to tADL. As commit 74a332e78e8f ("mtd:
nand: timings: Fix tADL_min for ONFI 4.0 chips") addressed, the
ONFi 4.0 increased the minimum of tADL to 400 nsec. This may not
fit in the 6-bit ADDR_2_DATA in older versions. Check the IP
revision and handle this correctly, otherwise the register value
would wrap around.
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com>
2017-06-13 21:45:37 +08:00
|
|
|
#define TWHR2_AND_WE_2_RE 0x100
|
|
|
|
#define TWHR2_AND_WE_2_RE__WE_2_RE GENMASK(5, 0)
|
|
|
|
#define TWHR2_AND_WE_2_RE__TWHR2 GENMASK(13, 8)
|
2010-05-13 22:57:33 +08:00
|
|
|
|
mtd: nand: denali: handle timing parameters by setup_data_interface()
Handling timing parameters in a driver's own way should be avoided
because it duplicates efforts of drivers/mtd/nand/nand_timings.c
Besides, this driver hard-codes Intel specific parameters such as
CLK_X=5, CLK_MULTI=4. Taking a certain device (Samsung K9WAG08U1A)
into account by get_samsung_nand_para() is weird as well.
Now, the core framework provides .setup_data_interface() hook, which
handles timing parameters in a generic manner.
While I am working on this, I found even more issues in the current
code, so fixed the following as well:
- In recent IP versions, WE_2_RE and TWHR2 share the same register.
Likewise for ADDR_2_DATA and TCWAW, CS_SETUP_CNT and TWB. When
updating one, the other must be masked. Otherwise, the other will
be set to 0, then timing settings will be broken.
- The recent IP release expanded the ADDR_2_DATA to 7-bit wide.
This register is related to tADL. As commit 74a332e78e8f ("mtd:
nand: timings: Fix tADL_min for ONFI 4.0 chips") addressed, the
ONFi 4.0 increased the minimum of tADL to 400 nsec. This may not
fit in the 6-bit ADDR_2_DATA in older versions. Check the IP
revision and handle this correctly, otherwise the register value
would wrap around.
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com>
2017-06-13 21:45:37 +08:00
|
|
|
#define TCWAW_AND_ADDR_2_DATA 0x110
|
|
|
|
/* The width of ADDR_2_DATA is 6 bit for old IP, 7 bit for new IP */
|
|
|
|
#define TCWAW_AND_ADDR_2_DATA__ADDR_2_DATA GENMASK(6, 0)
|
|
|
|
#define TCWAW_AND_ADDR_2_DATA__TCWAW GENMASK(13, 8)
|
2010-05-13 22:57:33 +08:00
|
|
|
|
|
|
|
#define RE_2_WE 0x120
|
2017-06-06 07:21:41 +08:00
|
|
|
#define RE_2_WE__VALUE GENMASK(5, 0)
|
2010-05-13 22:57:33 +08:00
|
|
|
|
2010-07-22 01:32:26 +08:00
|
|
|
#define ACC_CLKS 0x130
|
2017-06-06 07:21:41 +08:00
|
|
|
#define ACC_CLKS__VALUE GENMASK(3, 0)
|
2010-05-13 22:57:33 +08:00
|
|
|
|
|
|
|
#define NUMBER_OF_PLANES 0x140
|
2017-06-06 07:21:41 +08:00
|
|
|
#define NUMBER_OF_PLANES__VALUE GENMASK(2, 0)
|
2010-05-13 22:57:33 +08:00
|
|
|
|
|
|
|
#define PAGES_PER_BLOCK 0x150
|
2017-06-06 07:21:41 +08:00
|
|
|
#define PAGES_PER_BLOCK__VALUE GENMASK(15, 0)
|
2010-05-13 22:57:33 +08:00
|
|
|
|
|
|
|
#define DEVICE_WIDTH 0x160
|
2017-06-06 07:21:41 +08:00
|
|
|
#define DEVICE_WIDTH__VALUE GENMASK(1, 0)
|
2010-05-13 22:57:33 +08:00
|
|
|
|
|
|
|
#define DEVICE_MAIN_AREA_SIZE 0x170
|
2017-06-06 07:21:41 +08:00
|
|
|
#define DEVICE_MAIN_AREA_SIZE__VALUE GENMASK(15, 0)
|
2010-05-13 22:57:33 +08:00
|
|
|
|
|
|
|
#define DEVICE_SPARE_AREA_SIZE 0x180
|
2017-06-06 07:21:41 +08:00
|
|
|
#define DEVICE_SPARE_AREA_SIZE__VALUE GENMASK(15, 0)
|
2010-05-13 22:57:33 +08:00
|
|
|
|
|
|
|
#define TWO_ROW_ADDR_CYCLES 0x190
|
2017-06-06 07:21:41 +08:00
|
|
|
#define TWO_ROW_ADDR_CYCLES__FLAG BIT(0)
|
2010-05-13 22:57:33 +08:00
|
|
|
|
|
|
|
#define MULTIPLANE_ADDR_RESTRICT 0x1a0
|
2017-06-06 07:21:41 +08:00
|
|
|
#define MULTIPLANE_ADDR_RESTRICT__FLAG BIT(0)
|
2010-05-13 22:57:33 +08:00
|
|
|
|
|
|
|
#define ECC_CORRECTION 0x1b0
|
2017-06-06 07:21:41 +08:00
|
|
|
#define ECC_CORRECTION__VALUE GENMASK(4, 0)
|
2010-05-13 22:57:33 +08:00
|
|
|
|
|
|
|
#define READ_MODE 0x1c0
|
2017-06-06 07:21:41 +08:00
|
|
|
#define READ_MODE__VALUE GENMASK(3, 0)
|
2010-05-13 22:57:33 +08:00
|
|
|
|
|
|
|
#define WRITE_MODE 0x1d0
|
2017-06-06 07:21:41 +08:00
|
|
|
#define WRITE_MODE__VALUE GENMASK(3, 0)
|
2010-05-13 22:57:33 +08:00
|
|
|
|
|
|
|
#define COPYBACK_MODE 0x1e0
|
2017-06-06 07:21:41 +08:00
|
|
|
#define COPYBACK_MODE__VALUE GENMASK(3, 0)
|
2010-05-13 22:57:33 +08:00
|
|
|
|
|
|
|
#define RDWR_EN_LO_CNT 0x1f0
|
2017-06-06 07:21:41 +08:00
|
|
|
#define RDWR_EN_LO_CNT__VALUE GENMASK(4, 0)
|
2010-05-13 22:57:33 +08:00
|
|
|
|
|
|
|
#define RDWR_EN_HI_CNT 0x200
|
2017-06-06 07:21:41 +08:00
|
|
|
#define RDWR_EN_HI_CNT__VALUE GENMASK(4, 0)
|
2010-05-13 22:57:33 +08:00
|
|
|
|
|
|
|
#define MAX_RD_DELAY 0x210
|
2017-06-06 07:21:41 +08:00
|
|
|
#define MAX_RD_DELAY__VALUE GENMASK(3, 0)
|
2010-05-13 22:57:33 +08:00
|
|
|
|
|
|
|
#define CS_SETUP_CNT 0x220
|
2017-06-06 07:21:41 +08:00
|
|
|
#define CS_SETUP_CNT__VALUE GENMASK(4, 0)
|
mtd: nand: denali: handle timing parameters by setup_data_interface()
Handling timing parameters in a driver's own way should be avoided
because it duplicates efforts of drivers/mtd/nand/nand_timings.c
Besides, this driver hard-codes Intel specific parameters such as
CLK_X=5, CLK_MULTI=4. Taking a certain device (Samsung K9WAG08U1A)
into account by get_samsung_nand_para() is weird as well.
Now, the core framework provides .setup_data_interface() hook, which
handles timing parameters in a generic manner.
While I am working on this, I found even more issues in the current
code, so fixed the following as well:
- In recent IP versions, WE_2_RE and TWHR2 share the same register.
Likewise for ADDR_2_DATA and TCWAW, CS_SETUP_CNT and TWB. When
updating one, the other must be masked. Otherwise, the other will
be set to 0, then timing settings will be broken.
- The recent IP release expanded the ADDR_2_DATA to 7-bit wide.
This register is related to tADL. As commit 74a332e78e8f ("mtd:
nand: timings: Fix tADL_min for ONFI 4.0 chips") addressed, the
ONFi 4.0 increased the minimum of tADL to 400 nsec. This may not
fit in the 6-bit ADDR_2_DATA in older versions. Check the IP
revision and handle this correctly, otherwise the register value
would wrap around.
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com>
2017-06-13 21:45:37 +08:00
|
|
|
#define CS_SETUP_CNT__TWB GENMASK(17, 12)
|
2010-05-13 22:57:33 +08:00
|
|
|
|
|
|
|
#define SPARE_AREA_SKIP_BYTES 0x230
|
2017-06-06 07:21:41 +08:00
|
|
|
#define SPARE_AREA_SKIP_BYTES__VALUE GENMASK(5, 0)
|
2010-05-13 22:57:33 +08:00
|
|
|
|
|
|
|
#define SPARE_AREA_MARKER 0x240
|
2017-06-06 07:21:41 +08:00
|
|
|
#define SPARE_AREA_MARKER__VALUE GENMASK(15, 0)
|
2010-05-13 22:57:33 +08:00
|
|
|
|
|
|
|
#define DEVICES_CONNECTED 0x250
|
2017-06-06 07:21:41 +08:00
|
|
|
#define DEVICES_CONNECTED__VALUE GENMASK(2, 0)
|
2010-05-13 22:57:33 +08:00
|
|
|
|
2010-07-22 01:32:26 +08:00
|
|
|
#define DIE_MASK 0x260
|
2017-06-06 07:21:41 +08:00
|
|
|
#define DIE_MASK__VALUE GENMASK(7, 0)
|
2010-05-13 22:57:33 +08:00
|
|
|
|
|
|
|
#define FIRST_BLOCK_OF_NEXT_PLANE 0x270
|
2017-06-06 07:21:41 +08:00
|
|
|
#define FIRST_BLOCK_OF_NEXT_PLANE__VALUE GENMASK(15, 0)
|
2010-05-13 22:57:33 +08:00
|
|
|
|
|
|
|
#define WRITE_PROTECT 0x280
|
2017-06-06 07:21:41 +08:00
|
|
|
#define WRITE_PROTECT__FLAG BIT(0)
|
2010-05-13 22:57:33 +08:00
|
|
|
|
|
|
|
#define RE_2_RE 0x290
|
2017-06-06 07:21:41 +08:00
|
|
|
#define RE_2_RE__VALUE GENMASK(5, 0)
|
2010-05-13 22:57:33 +08:00
|
|
|
|
2010-07-22 01:32:26 +08:00
|
|
|
#define MANUFACTURER_ID 0x300
|
2017-06-06 07:21:41 +08:00
|
|
|
#define MANUFACTURER_ID__VALUE GENMASK(7, 0)
|
2010-05-13 22:57:33 +08:00
|
|
|
|
|
|
|
#define DEVICE_ID 0x310
|
2017-06-06 07:21:41 +08:00
|
|
|
#define DEVICE_ID__VALUE GENMASK(7, 0)
|
2010-05-13 22:57:33 +08:00
|
|
|
|
|
|
|
#define DEVICE_PARAM_0 0x320
|
2017-06-06 07:21:41 +08:00
|
|
|
#define DEVICE_PARAM_0__VALUE GENMASK(7, 0)
|
2010-05-13 22:57:33 +08:00
|
|
|
|
|
|
|
#define DEVICE_PARAM_1 0x330
|
2017-06-06 07:21:41 +08:00
|
|
|
#define DEVICE_PARAM_1__VALUE GENMASK(7, 0)
|
2010-05-13 22:57:33 +08:00
|
|
|
|
|
|
|
#define DEVICE_PARAM_2 0x340
|
2017-06-06 07:21:41 +08:00
|
|
|
#define DEVICE_PARAM_2__VALUE GENMASK(7, 0)
|
2010-05-13 22:57:33 +08:00
|
|
|
|
|
|
|
#define LOGICAL_PAGE_DATA_SIZE 0x350
|
2017-06-06 07:21:41 +08:00
|
|
|
#define LOGICAL_PAGE_DATA_SIZE__VALUE GENMASK(15, 0)
|
2010-05-13 22:57:33 +08:00
|
|
|
|
|
|
|
#define LOGICAL_PAGE_SPARE_SIZE 0x360
|
2017-06-06 07:21:41 +08:00
|
|
|
#define LOGICAL_PAGE_SPARE_SIZE__VALUE GENMASK(15, 0)
|
2010-05-13 22:57:33 +08:00
|
|
|
|
2010-07-22 01:32:26 +08:00
|
|
|
#define REVISION 0x370
|
2017-06-06 07:21:41 +08:00
|
|
|
#define REVISION__VALUE GENMASK(15, 0)
|
2010-05-13 22:57:33 +08:00
|
|
|
|
|
|
|
#define ONFI_DEVICE_FEATURES 0x380
|
2017-06-06 07:21:41 +08:00
|
|
|
#define ONFI_DEVICE_FEATURES__VALUE GENMASK(5, 0)
|
2010-05-13 22:57:33 +08:00
|
|
|
|
2010-07-22 01:32:26 +08:00
|
|
|
#define ONFI_OPTIONAL_COMMANDS 0x390
|
2017-06-06 07:21:41 +08:00
|
|
|
#define ONFI_OPTIONAL_COMMANDS__VALUE GENMASK(5, 0)
|
2010-05-13 22:57:33 +08:00
|
|
|
|
|
|
|
#define ONFI_TIMING_MODE 0x3a0
|
2017-06-06 07:21:41 +08:00
|
|
|
#define ONFI_TIMING_MODE__VALUE GENMASK(5, 0)
|
2010-05-13 22:57:33 +08:00
|
|
|
|
|
|
|
#define ONFI_PGM_CACHE_TIMING_MODE 0x3b0
|
2017-06-06 07:21:41 +08:00
|
|
|
#define ONFI_PGM_CACHE_TIMING_MODE__VALUE GENMASK(5, 0)
|
2010-05-13 22:57:33 +08:00
|
|
|
|
|
|
|
#define ONFI_DEVICE_NO_OF_LUNS 0x3c0
|
2017-06-06 07:21:41 +08:00
|
|
|
#define ONFI_DEVICE_NO_OF_LUNS__NO_OF_LUNS GENMASK(7, 0)
|
|
|
|
#define ONFI_DEVICE_NO_OF_LUNS__ONFI_DEVICE BIT(8)
|
2010-05-13 22:57:33 +08:00
|
|
|
|
|
|
|
#define ONFI_DEVICE_NO_OF_BLOCKS_PER_LUN_L 0x3d0
|
2017-06-06 07:21:41 +08:00
|
|
|
#define ONFI_DEVICE_NO_OF_BLOCKS_PER_LUN_L__VALUE GENMASK(15, 0)
|
2010-05-13 22:57:33 +08:00
|
|
|
|
|
|
|
#define ONFI_DEVICE_NO_OF_BLOCKS_PER_LUN_U 0x3e0
|
2017-06-06 07:21:41 +08:00
|
|
|
#define ONFI_DEVICE_NO_OF_BLOCKS_PER_LUN_U__VALUE GENMASK(15, 0)
|
|
|
|
|
|
|
|
#define FEATURES 0x3f0
|
|
|
|
#define FEATURES__N_BANKS GENMASK(1, 0)
|
|
|
|
#define FEATURES__ECC_MAX_ERR GENMASK(5, 2)
|
|
|
|
#define FEATURES__DMA BIT(6)
|
|
|
|
#define FEATURES__CMD_DMA BIT(7)
|
|
|
|
#define FEATURES__PARTITION BIT(8)
|
|
|
|
#define FEATURES__XDMA_SIDEBAND BIT(9)
|
|
|
|
#define FEATURES__GPREG BIT(10)
|
|
|
|
#define FEATURES__INDEX_ADDR BIT(11)
|
2010-05-13 22:57:33 +08:00
|
|
|
|
|
|
|
#define TRANSFER_MODE 0x400
|
2017-06-06 07:21:41 +08:00
|
|
|
#define TRANSFER_MODE__VALUE GENMASK(1, 0)
|
2010-05-13 22:57:33 +08:00
|
|
|
|
2017-06-06 07:21:41 +08:00
|
|
|
#define INTR_STATUS(bank) (0x410 + (bank) * 0x50)
|
|
|
|
#define INTR_EN(bank) (0x420 + (bank) * 0x50)
|
2017-03-30 14:45:52 +08:00
|
|
|
/* bit[1:0] is used differently depending on IP version */
|
2017-06-06 07:21:41 +08:00
|
|
|
#define INTR__ECC_UNCOR_ERR BIT(0) /* new IP */
|
|
|
|
#define INTR__ECC_TRANSACTION_DONE BIT(0) /* old IP */
|
|
|
|
#define INTR__ECC_ERR BIT(1) /* old IP */
|
|
|
|
#define INTR__DMA_CMD_COMP BIT(2)
|
|
|
|
#define INTR__TIME_OUT BIT(3)
|
|
|
|
#define INTR__PROGRAM_FAIL BIT(4)
|
|
|
|
#define INTR__ERASE_FAIL BIT(5)
|
|
|
|
#define INTR__LOAD_COMP BIT(6)
|
|
|
|
#define INTR__PROGRAM_COMP BIT(7)
|
|
|
|
#define INTR__ERASE_COMP BIT(8)
|
|
|
|
#define INTR__PIPE_CPYBCK_CMD_COMP BIT(9)
|
|
|
|
#define INTR__LOCKED_BLK BIT(10)
|
|
|
|
#define INTR__UNSUP_CMD BIT(11)
|
|
|
|
#define INTR__INT_ACT BIT(12)
|
|
|
|
#define INTR__RST_COMP BIT(13)
|
|
|
|
#define INTR__PIPE_CMD_ERR BIT(14)
|
|
|
|
#define INTR__PAGE_XFER_INC BIT(15)
|
|
|
|
|
|
|
|
#define PAGE_CNT(bank) (0x430 + (bank) * 0x50)
|
|
|
|
#define ERR_PAGE_ADDR(bank) (0x440 + (bank) * 0x50)
|
|
|
|
#define ERR_BLOCK_ADDR(bank) (0x450 + (bank) * 0x50)
|
2010-05-13 22:57:33 +08:00
|
|
|
|
|
|
|
#define ECC_THRESHOLD 0x600
|
2017-06-06 07:21:41 +08:00
|
|
|
#define ECC_THRESHOLD__VALUE GENMASK(9, 0)
|
2010-05-13 22:57:33 +08:00
|
|
|
|
2010-07-22 01:32:26 +08:00
|
|
|
#define ECC_ERROR_BLOCK_ADDRESS 0x610
|
2017-06-06 07:21:41 +08:00
|
|
|
#define ECC_ERROR_BLOCK_ADDRESS__VALUE GENMASK(15, 0)
|
2010-05-13 22:57:33 +08:00
|
|
|
|
|
|
|
#define ECC_ERROR_PAGE_ADDRESS 0x620
|
2017-06-06 07:21:41 +08:00
|
|
|
#define ECC_ERROR_PAGE_ADDRESS__VALUE GENMASK(11, 0)
|
|
|
|
#define ECC_ERROR_PAGE_ADDRESS__BANK GENMASK(15, 12)
|
2010-05-13 22:57:33 +08:00
|
|
|
|
|
|
|
#define ECC_ERROR_ADDRESS 0x630
|
2017-06-06 07:21:41 +08:00
|
|
|
#define ECC_ERROR_ADDRESS__OFFSET GENMASK(11, 0)
|
|
|
|
#define ECC_ERROR_ADDRESS__SECTOR_NR GENMASK(15, 12)
|
2010-05-13 22:57:33 +08:00
|
|
|
|
|
|
|
#define ERR_CORRECTION_INFO 0x640
|
2017-06-06 07:21:41 +08:00
|
|
|
#define ERR_CORRECTION_INFO__BYTEMASK GENMASK(7, 0)
|
|
|
|
#define ERR_CORRECTION_INFO__DEVICE_NR GENMASK(11, 8)
|
|
|
|
#define ERR_CORRECTION_INFO__ERROR_TYPE BIT(14)
|
|
|
|
#define ERR_CORRECTION_INFO__LAST_ERR_INFO BIT(15)
|
2010-05-13 22:57:33 +08:00
|
|
|
|
2017-03-30 14:45:52 +08:00
|
|
|
#define ECC_COR_INFO(bank) (0x650 + (bank) / 2 * 0x10)
|
|
|
|
#define ECC_COR_INFO__SHIFT(bank) ((bank) % 2 * 8)
|
2017-06-06 07:21:41 +08:00
|
|
|
#define ECC_COR_INFO__MAX_ERRORS GENMASK(6, 0)
|
|
|
|
#define ECC_COR_INFO__UNCOR_ERR BIT(7)
|
2017-03-30 14:45:52 +08:00
|
|
|
|
mtd: nand: denali: avoid hard-coding ECC step, strength, bytes
This driver was originally written for the Intel MRST platform with
several platform-specific parameters hard-coded.
Currently, the ECC settings are hard-coded as follows:
#define ECC_SECTOR_SIZE 512
#define ECC_8BITS 14
#define ECC_15BITS 26
Therefore, the driver can only support two cases.
- ecc.size = 512, ecc.strength = 8 --> ecc.bytes = 14
- ecc.size = 512, ecc.strength = 15 --> ecc.bytes = 26
However, these are actually customizable parameters, for example,
UniPhier platform supports the following:
- ecc.size = 1024, ecc.strength = 8 --> ecc.bytes = 14
- ecc.size = 1024, ecc.strength = 16 --> ecc.bytes = 28
- ecc.size = 1024, ecc.strength = 24 --> ecc.bytes = 42
So, we need to handle the ECC parameters in a more generic manner.
Fortunately, the Denali User's Guide explains how to calculate the
ecc.bytes. The formula is:
ecc.bytes = 2 * CEIL(13 * ecc.strength / 16) (for ecc.size = 512)
ecc.bytes = 2 * CEIL(14 * ecc.strength / 16) (for ecc.size = 1024)
For DT platforms, it would be reasonable to allow DT to specify ECC
strength by either "nand-ecc-strength" or "nand-ecc-maximize". If
none of them is specified, the driver will try to meet the chip's ECC
requirement.
For PCI platforms, the max ECC strength is used to keep the original
behavior.
Newer versions of this IP need ecc.size and ecc.steps explicitly
set up via the following registers:
CFG_DATA_BLOCK_SIZE (0x6b0)
CFG_LAST_DATA_BLOCK_SIZE (0x6c0)
CFG_NUM_DATA_BLOCKS (0x6d0)
For older IP versions, write accesses to these registers are just
ignored.
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Acked-by: Rob Herring <robh@kernel.org>
Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com>
2017-06-07 19:52:12 +08:00
|
|
|
#define CFG_DATA_BLOCK_SIZE 0x6b0
|
|
|
|
|
|
|
|
#define CFG_LAST_DATA_BLOCK_SIZE 0x6c0
|
|
|
|
|
|
|
|
#define CFG_NUM_DATA_BLOCKS 0x6d0
|
|
|
|
|
|
|
|
#define CFG_META_DATA_SIZE 0x6e0
|
|
|
|
|
2010-05-13 22:57:33 +08:00
|
|
|
#define DMA_ENABLE 0x700
|
2017-06-06 07:21:41 +08:00
|
|
|
#define DMA_ENABLE__FLAG BIT(0)
|
2010-05-13 22:57:33 +08:00
|
|
|
|
|
|
|
#define IGNORE_ECC_DONE 0x710
|
2017-06-06 07:21:41 +08:00
|
|
|
#define IGNORE_ECC_DONE__FLAG BIT(0)
|
2010-05-13 22:57:33 +08:00
|
|
|
|
|
|
|
#define DMA_INTR 0x720
|
2017-03-23 04:07:06 +08:00
|
|
|
#define DMA_INTR_EN 0x730
|
2017-06-06 07:21:41 +08:00
|
|
|
#define DMA_INTR__TARGET_ERROR BIT(0)
|
|
|
|
#define DMA_INTR__DESC_COMP_CHANNEL0 BIT(1)
|
|
|
|
#define DMA_INTR__DESC_COMP_CHANNEL1 BIT(2)
|
|
|
|
#define DMA_INTR__DESC_COMP_CHANNEL2 BIT(3)
|
|
|
|
#define DMA_INTR__DESC_COMP_CHANNEL3 BIT(4)
|
|
|
|
#define DMA_INTR__MEMCOPY_DESC_COMP BIT(5)
|
2010-05-13 22:57:33 +08:00
|
|
|
|
|
|
|
#define TARGET_ERR_ADDR_LO 0x740
|
2017-06-06 07:21:41 +08:00
|
|
|
#define TARGET_ERR_ADDR_LO__VALUE GENMASK(15, 0)
|
2010-05-13 22:57:33 +08:00
|
|
|
|
|
|
|
#define TARGET_ERR_ADDR_HI 0x750
|
2017-06-06 07:21:41 +08:00
|
|
|
#define TARGET_ERR_ADDR_HI__VALUE GENMASK(15, 0)
|
2010-05-13 22:57:33 +08:00
|
|
|
|
|
|
|
#define CHNL_ACTIVE 0x760
|
2017-06-06 07:21:41 +08:00
|
|
|
#define CHNL_ACTIVE__CHANNEL0 BIT(0)
|
|
|
|
#define CHNL_ACTIVE__CHANNEL1 BIT(1)
|
|
|
|
#define CHNL_ACTIVE__CHANNEL2 BIT(2)
|
|
|
|
#define CHNL_ACTIVE__CHANNEL3 BIT(3)
|
2010-05-13 22:57:33 +08:00
|
|
|
|
|
|
|
#define MODE_00 0x00000000
|
|
|
|
#define MODE_01 0x04000000
|
|
|
|
#define MODE_10 0x08000000
|
|
|
|
#define MODE_11 0x0C000000
|
|
|
|
|
|
|
|
struct denali_nand_info {
|
|
|
|
struct nand_chip nand;
|
mtd: nand: denali: handle timing parameters by setup_data_interface()
Handling timing parameters in a driver's own way should be avoided
because it duplicates efforts of drivers/mtd/nand/nand_timings.c
Besides, this driver hard-codes Intel specific parameters such as
CLK_X=5, CLK_MULTI=4. Taking a certain device (Samsung K9WAG08U1A)
into account by get_samsung_nand_para() is weird as well.
Now, the core framework provides .setup_data_interface() hook, which
handles timing parameters in a generic manner.
While I am working on this, I found even more issues in the current
code, so fixed the following as well:
- In recent IP versions, WE_2_RE and TWHR2 share the same register.
Likewise for ADDR_2_DATA and TCWAW, CS_SETUP_CNT and TWB. When
updating one, the other must be masked. Otherwise, the other will
be set to 0, then timing settings will be broken.
- The recent IP release expanded the ADDR_2_DATA to 7-bit wide.
This register is related to tADL. As commit 74a332e78e8f ("mtd:
nand: timings: Fix tADL_min for ONFI 4.0 chips") addressed, the
ONFi 4.0 increased the minimum of tADL to 400 nsec. This may not
fit in the 6-bit ADDR_2_DATA in older versions. Check the IP
revision and handle this correctly, otherwise the register value
would wrap around.
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com>
2017-06-13 21:45:37 +08:00
|
|
|
unsigned long clk_x_rate; /* bus interface clock rate */
|
2010-05-13 22:57:33 +08:00
|
|
|
int flash_bank; /* currently selected chip */
|
2011-05-06 22:28:55 +08:00
|
|
|
struct device *dev;
|
2017-03-23 04:07:05 +08:00
|
|
|
void __iomem *flash_reg; /* Register Interface */
|
|
|
|
void __iomem *flash_mem; /* Host Data/Command Interface */
|
2010-05-13 22:57:33 +08:00
|
|
|
|
|
|
|
/* elements used by ISR */
|
|
|
|
struct completion complete;
|
|
|
|
spinlock_t irq_lock;
|
2017-06-13 21:45:38 +08:00
|
|
|
uint32_t irq_mask;
|
2010-05-13 22:57:33 +08:00
|
|
|
uint32_t irq_status;
|
2012-09-28 00:58:05 +08:00
|
|
|
int irq;
|
2010-08-06 18:48:21 +08:00
|
|
|
|
2017-06-13 21:45:43 +08:00
|
|
|
void *buf;
|
|
|
|
dma_addr_t dma_addr;
|
2017-06-13 21:45:45 +08:00
|
|
|
int dma_avail;
|
2017-03-23 04:07:08 +08:00
|
|
|
int devnum; /* represent how many nands connected */
|
|
|
|
int bbtskipbytes;
|
|
|
|
int max_banks;
|
2017-03-30 14:45:57 +08:00
|
|
|
unsigned int revision;
|
2017-03-23 04:07:07 +08:00
|
|
|
unsigned int caps;
|
mtd: nand: denali: avoid hard-coding ECC step, strength, bytes
This driver was originally written for the Intel MRST platform with
several platform-specific parameters hard-coded.
Currently, the ECC settings are hard-coded as follows:
#define ECC_SECTOR_SIZE 512
#define ECC_8BITS 14
#define ECC_15BITS 26
Therefore, the driver can only support two cases.
- ecc.size = 512, ecc.strength = 8 --> ecc.bytes = 14
- ecc.size = 512, ecc.strength = 15 --> ecc.bytes = 26
However, these are actually customizable parameters, for example,
UniPhier platform supports the following:
- ecc.size = 1024, ecc.strength = 8 --> ecc.bytes = 14
- ecc.size = 1024, ecc.strength = 16 --> ecc.bytes = 28
- ecc.size = 1024, ecc.strength = 24 --> ecc.bytes = 42
So, we need to handle the ECC parameters in a more generic manner.
Fortunately, the Denali User's Guide explains how to calculate the
ecc.bytes. The formula is:
ecc.bytes = 2 * CEIL(13 * ecc.strength / 16) (for ecc.size = 512)
ecc.bytes = 2 * CEIL(14 * ecc.strength / 16) (for ecc.size = 1024)
For DT platforms, it would be reasonable to allow DT to specify ECC
strength by either "nand-ecc-strength" or "nand-ecc-maximize". If
none of them is specified, the driver will try to meet the chip's ECC
requirement.
For PCI platforms, the max ECC strength is used to keep the original
behavior.
Newer versions of this IP need ecc.size and ecc.steps explicitly
set up via the following registers:
CFG_DATA_BLOCK_SIZE (0x6b0)
CFG_LAST_DATA_BLOCK_SIZE (0x6c0)
CFG_NUM_DATA_BLOCKS (0x6d0)
For older IP versions, write accesses to these registers are just
ignored.
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Acked-by: Rob Herring <robh@kernel.org>
Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com>
2017-06-07 19:52:12 +08:00
|
|
|
const struct nand_ecc_caps *ecc_caps;
|
2010-05-13 22:57:33 +08:00
|
|
|
};
|
|
|
|
|
2017-03-30 14:45:52 +08:00
|
|
|
#define DENALI_CAP_HW_ECC_FIXUP BIT(0)
|
2017-03-30 14:45:54 +08:00
|
|
|
#define DENALI_CAP_DMA_64BIT BIT(1)
|
2017-03-30 14:45:52 +08:00
|
|
|
|
mtd: nand: denali: avoid hard-coding ECC step, strength, bytes
This driver was originally written for the Intel MRST platform with
several platform-specific parameters hard-coded.
Currently, the ECC settings are hard-coded as follows:
#define ECC_SECTOR_SIZE 512
#define ECC_8BITS 14
#define ECC_15BITS 26
Therefore, the driver can only support two cases.
- ecc.size = 512, ecc.strength = 8 --> ecc.bytes = 14
- ecc.size = 512, ecc.strength = 15 --> ecc.bytes = 26
However, these are actually customizable parameters, for example,
UniPhier platform supports the following:
- ecc.size = 1024, ecc.strength = 8 --> ecc.bytes = 14
- ecc.size = 1024, ecc.strength = 16 --> ecc.bytes = 28
- ecc.size = 1024, ecc.strength = 24 --> ecc.bytes = 42
So, we need to handle the ECC parameters in a more generic manner.
Fortunately, the Denali User's Guide explains how to calculate the
ecc.bytes. The formula is:
ecc.bytes = 2 * CEIL(13 * ecc.strength / 16) (for ecc.size = 512)
ecc.bytes = 2 * CEIL(14 * ecc.strength / 16) (for ecc.size = 1024)
For DT platforms, it would be reasonable to allow DT to specify ECC
strength by either "nand-ecc-strength" or "nand-ecc-maximize". If
none of them is specified, the driver will try to meet the chip's ECC
requirement.
For PCI platforms, the max ECC strength is used to keep the original
behavior.
Newer versions of this IP need ecc.size and ecc.steps explicitly
set up via the following registers:
CFG_DATA_BLOCK_SIZE (0x6b0)
CFG_LAST_DATA_BLOCK_SIZE (0x6c0)
CFG_NUM_DATA_BLOCKS (0x6d0)
For older IP versions, write accesses to these registers are just
ignored.
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Acked-by: Rob Herring <robh@kernel.org>
Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com>
2017-06-07 19:52:12 +08:00
|
|
|
int denali_calc_ecc_bytes(int step_size, int strength);
|
2012-09-28 00:58:05 +08:00
|
|
|
extern int denali_init(struct denali_nand_info *denali);
|
|
|
|
extern void denali_remove(struct denali_nand_info *denali);
|
|
|
|
|
2014-08-29 19:00:51 +08:00
|
|
|
#endif /* __DENALI_H__ */
|