blob: 6cd02b2e26ee2d2d811c972579b8c661eba5fa2b [file] [log] [blame]
Tom Rini10e47792018-05-06 17:58:06 -04001/* SPDX-License-Identifier: GPL-2.0+ */
Chin Liang See03534df2014-09-12 00:42:17 -05002/*
3 * Copyright (C) 2013-2014 Altera Corporation <www.altera.com>
4 * Copyright (C) 2009-2010, Intel Corporation and its suppliers.
Chin Liang See03534df2014-09-12 00:42:17 -05005 */
6
Scott Wood3ea94ed2015-06-26 19:03:26 -05007#ifndef __DENALI_H__
8#define __DENALI_H__
9
Masahiro Yamada8b0c16f2017-11-22 02:38:32 +090010#include <linux/bitops.h>
Masahiro Yamada2b7a8732017-11-30 13:45:24 +090011#include <linux/mtd/rawnand.h>
Masahiro Yamada8b0c16f2017-11-22 02:38:32 +090012#include <linux/types.h>
Chin Liang See03534df2014-09-12 00:42:17 -050013
14#define DEVICE_RESET 0x0
Masahiro Yamada8b0c16f2017-11-22 02:38:32 +090015#define DEVICE_RESET__BANK(bank) BIT(bank)
Chin Liang See03534df2014-09-12 00:42:17 -050016
17#define TRANSFER_SPARE_REG 0x10
Masahiro Yamada8b0c16f2017-11-22 02:38:32 +090018#define TRANSFER_SPARE_REG__FLAG BIT(0)
Chin Liang See03534df2014-09-12 00:42:17 -050019
20#define LOAD_WAIT_CNT 0x20
Masahiro Yamada8b0c16f2017-11-22 02:38:32 +090021#define LOAD_WAIT_CNT__VALUE GENMASK(15, 0)
Chin Liang See03534df2014-09-12 00:42:17 -050022
23#define PROGRAM_WAIT_CNT 0x30
Masahiro Yamada8b0c16f2017-11-22 02:38:32 +090024#define PROGRAM_WAIT_CNT__VALUE GENMASK(15, 0)
Chin Liang See03534df2014-09-12 00:42:17 -050025
26#define ERASE_WAIT_CNT 0x40
Masahiro Yamada8b0c16f2017-11-22 02:38:32 +090027#define ERASE_WAIT_CNT__VALUE GENMASK(15, 0)
Chin Liang See03534df2014-09-12 00:42:17 -050028
29#define INT_MON_CYCCNT 0x50
Masahiro Yamada8b0c16f2017-11-22 02:38:32 +090030#define INT_MON_CYCCNT__VALUE GENMASK(15, 0)
Chin Liang See03534df2014-09-12 00:42:17 -050031
32#define RB_PIN_ENABLED 0x60
Masahiro Yamada8b0c16f2017-11-22 02:38:32 +090033#define RB_PIN_ENABLED__BANK(bank) BIT(bank)
Chin Liang See03534df2014-09-12 00:42:17 -050034
35#define MULTIPLANE_OPERATION 0x70
Masahiro Yamada8b0c16f2017-11-22 02:38:32 +090036#define MULTIPLANE_OPERATION__FLAG BIT(0)
Chin Liang See03534df2014-09-12 00:42:17 -050037
38#define MULTIPLANE_READ_ENABLE 0x80
Masahiro Yamada8b0c16f2017-11-22 02:38:32 +090039#define MULTIPLANE_READ_ENABLE__FLAG BIT(0)
Chin Liang See03534df2014-09-12 00:42:17 -050040
41#define COPYBACK_DISABLE 0x90
Masahiro Yamada8b0c16f2017-11-22 02:38:32 +090042#define COPYBACK_DISABLE__FLAG BIT(0)
Chin Liang See03534df2014-09-12 00:42:17 -050043
44#define CACHE_WRITE_ENABLE 0xa0
Masahiro Yamada8b0c16f2017-11-22 02:38:32 +090045#define CACHE_WRITE_ENABLE__FLAG BIT(0)
Chin Liang See03534df2014-09-12 00:42:17 -050046
47#define CACHE_READ_ENABLE 0xb0
Masahiro Yamada8b0c16f2017-11-22 02:38:32 +090048#define CACHE_READ_ENABLE__FLAG BIT(0)
Chin Liang See03534df2014-09-12 00:42:17 -050049
50#define PREFETCH_MODE 0xc0
Masahiro Yamada8b0c16f2017-11-22 02:38:32 +090051#define PREFETCH_MODE__PREFETCH_EN BIT(0)
52#define PREFETCH_MODE__PREFETCH_BURST_LENGTH GENMASK(15, 4)
Chin Liang See03534df2014-09-12 00:42:17 -050053
54#define CHIP_ENABLE_DONT_CARE 0xd0
Masahiro Yamada8b0c16f2017-11-22 02:38:32 +090055#define CHIP_EN_DONT_CARE__FLAG BIT(0)
Chin Liang See03534df2014-09-12 00:42:17 -050056
57#define ECC_ENABLE 0xe0
Masahiro Yamada8b0c16f2017-11-22 02:38:32 +090058#define ECC_ENABLE__FLAG BIT(0)
Chin Liang See03534df2014-09-12 00:42:17 -050059
60#define GLOBAL_INT_ENABLE 0xf0
Masahiro Yamada8b0c16f2017-11-22 02:38:32 +090061#define GLOBAL_INT_EN_FLAG BIT(0)
Chin Liang See03534df2014-09-12 00:42:17 -050062
Masahiro Yamada8b0c16f2017-11-22 02:38:32 +090063#define TWHR2_AND_WE_2_RE 0x100
64#define TWHR2_AND_WE_2_RE__WE_2_RE GENMASK(5, 0)
65#define TWHR2_AND_WE_2_RE__TWHR2 GENMASK(13, 8)
Chin Liang See03534df2014-09-12 00:42:17 -050066
Masahiro Yamada8b0c16f2017-11-22 02:38:32 +090067#define TCWAW_AND_ADDR_2_DATA 0x110
68/* The width of ADDR_2_DATA is 6 bit for old IP, 7 bit for new IP */
69#define TCWAW_AND_ADDR_2_DATA__ADDR_2_DATA GENMASK(6, 0)
70#define TCWAW_AND_ADDR_2_DATA__TCWAW GENMASK(13, 8)
Chin Liang See03534df2014-09-12 00:42:17 -050071
72#define RE_2_WE 0x120
Masahiro Yamada8b0c16f2017-11-22 02:38:32 +090073#define RE_2_WE__VALUE GENMASK(5, 0)
Chin Liang See03534df2014-09-12 00:42:17 -050074
75#define ACC_CLKS 0x130
Masahiro Yamada8b0c16f2017-11-22 02:38:32 +090076#define ACC_CLKS__VALUE GENMASK(3, 0)
Chin Liang See03534df2014-09-12 00:42:17 -050077
78#define NUMBER_OF_PLANES 0x140
Masahiro Yamada8b0c16f2017-11-22 02:38:32 +090079#define NUMBER_OF_PLANES__VALUE GENMASK(2, 0)
Chin Liang See03534df2014-09-12 00:42:17 -050080
81#define PAGES_PER_BLOCK 0x150
Masahiro Yamada8b0c16f2017-11-22 02:38:32 +090082#define PAGES_PER_BLOCK__VALUE GENMASK(15, 0)
Chin Liang See03534df2014-09-12 00:42:17 -050083
84#define DEVICE_WIDTH 0x160
Masahiro Yamada8b0c16f2017-11-22 02:38:32 +090085#define DEVICE_WIDTH__VALUE GENMASK(1, 0)
Chin Liang See03534df2014-09-12 00:42:17 -050086
87#define DEVICE_MAIN_AREA_SIZE 0x170
Masahiro Yamada8b0c16f2017-11-22 02:38:32 +090088#define DEVICE_MAIN_AREA_SIZE__VALUE GENMASK(15, 0)
Chin Liang See03534df2014-09-12 00:42:17 -050089
90#define DEVICE_SPARE_AREA_SIZE 0x180
Masahiro Yamada8b0c16f2017-11-22 02:38:32 +090091#define DEVICE_SPARE_AREA_SIZE__VALUE GENMASK(15, 0)
Chin Liang See03534df2014-09-12 00:42:17 -050092
93#define TWO_ROW_ADDR_CYCLES 0x190
Masahiro Yamada8b0c16f2017-11-22 02:38:32 +090094#define TWO_ROW_ADDR_CYCLES__FLAG BIT(0)
Chin Liang See03534df2014-09-12 00:42:17 -050095
96#define MULTIPLANE_ADDR_RESTRICT 0x1a0
Masahiro Yamada8b0c16f2017-11-22 02:38:32 +090097#define MULTIPLANE_ADDR_RESTRICT__FLAG BIT(0)
Chin Liang See03534df2014-09-12 00:42:17 -050098
99#define ECC_CORRECTION 0x1b0
Masahiro Yamada8b0c16f2017-11-22 02:38:32 +0900100#define ECC_CORRECTION__VALUE GENMASK(4, 0)
101#define ECC_CORRECTION__ERASE_THRESHOLD GENMASK(31, 16)
Chin Liang See03534df2014-09-12 00:42:17 -0500102
103#define READ_MODE 0x1c0
Masahiro Yamada8b0c16f2017-11-22 02:38:32 +0900104#define READ_MODE__VALUE GENMASK(3, 0)
Chin Liang See03534df2014-09-12 00:42:17 -0500105
106#define WRITE_MODE 0x1d0
Masahiro Yamada8b0c16f2017-11-22 02:38:32 +0900107#define WRITE_MODE__VALUE GENMASK(3, 0)
Chin Liang See03534df2014-09-12 00:42:17 -0500108
109#define COPYBACK_MODE 0x1e0
Masahiro Yamada8b0c16f2017-11-22 02:38:32 +0900110#define COPYBACK_MODE__VALUE GENMASK(3, 0)
Chin Liang See03534df2014-09-12 00:42:17 -0500111
112#define RDWR_EN_LO_CNT 0x1f0
Masahiro Yamada8b0c16f2017-11-22 02:38:32 +0900113#define RDWR_EN_LO_CNT__VALUE GENMASK(4, 0)
Chin Liang See03534df2014-09-12 00:42:17 -0500114
115#define RDWR_EN_HI_CNT 0x200
Masahiro Yamada8b0c16f2017-11-22 02:38:32 +0900116#define RDWR_EN_HI_CNT__VALUE GENMASK(4, 0)
Chin Liang See03534df2014-09-12 00:42:17 -0500117
118#define MAX_RD_DELAY 0x210
Masahiro Yamada8b0c16f2017-11-22 02:38:32 +0900119#define MAX_RD_DELAY__VALUE GENMASK(3, 0)
Chin Liang See03534df2014-09-12 00:42:17 -0500120
121#define CS_SETUP_CNT 0x220
Masahiro Yamada8b0c16f2017-11-22 02:38:32 +0900122#define CS_SETUP_CNT__VALUE GENMASK(4, 0)
123#define CS_SETUP_CNT__TWB GENMASK(17, 12)
Chin Liang See03534df2014-09-12 00:42:17 -0500124
125#define SPARE_AREA_SKIP_BYTES 0x230
Masahiro Yamada8b0c16f2017-11-22 02:38:32 +0900126#define SPARE_AREA_SKIP_BYTES__VALUE GENMASK(5, 0)
Chin Liang See03534df2014-09-12 00:42:17 -0500127
128#define SPARE_AREA_MARKER 0x240
Masahiro Yamada8b0c16f2017-11-22 02:38:32 +0900129#define SPARE_AREA_MARKER__VALUE GENMASK(15, 0)
Chin Liang See03534df2014-09-12 00:42:17 -0500130
131#define DEVICES_CONNECTED 0x250
Masahiro Yamada8b0c16f2017-11-22 02:38:32 +0900132#define DEVICES_CONNECTED__VALUE GENMASK(2, 0)
Chin Liang See03534df2014-09-12 00:42:17 -0500133
134#define DIE_MASK 0x260
Masahiro Yamada8b0c16f2017-11-22 02:38:32 +0900135#define DIE_MASK__VALUE GENMASK(7, 0)
Chin Liang See03534df2014-09-12 00:42:17 -0500136
137#define FIRST_BLOCK_OF_NEXT_PLANE 0x270
Masahiro Yamada8b0c16f2017-11-22 02:38:32 +0900138#define FIRST_BLOCK_OF_NEXT_PLANE__VALUE GENMASK(15, 0)
Chin Liang See03534df2014-09-12 00:42:17 -0500139
140#define WRITE_PROTECT 0x280
Masahiro Yamada8b0c16f2017-11-22 02:38:32 +0900141#define WRITE_PROTECT__FLAG BIT(0)
Chin Liang See03534df2014-09-12 00:42:17 -0500142
143#define RE_2_RE 0x290
Masahiro Yamada8b0c16f2017-11-22 02:38:32 +0900144#define RE_2_RE__VALUE GENMASK(5, 0)
Chin Liang See03534df2014-09-12 00:42:17 -0500145
146#define MANUFACTURER_ID 0x300
Masahiro Yamada8b0c16f2017-11-22 02:38:32 +0900147#define MANUFACTURER_ID__VALUE GENMASK(7, 0)
Chin Liang See03534df2014-09-12 00:42:17 -0500148
149#define DEVICE_ID 0x310
Masahiro Yamada8b0c16f2017-11-22 02:38:32 +0900150#define DEVICE_ID__VALUE GENMASK(7, 0)
Chin Liang See03534df2014-09-12 00:42:17 -0500151
152#define DEVICE_PARAM_0 0x320
Masahiro Yamada8b0c16f2017-11-22 02:38:32 +0900153#define DEVICE_PARAM_0__VALUE GENMASK(7, 0)
Chin Liang See03534df2014-09-12 00:42:17 -0500154
155#define DEVICE_PARAM_1 0x330
Masahiro Yamada8b0c16f2017-11-22 02:38:32 +0900156#define DEVICE_PARAM_1__VALUE GENMASK(7, 0)
Chin Liang See03534df2014-09-12 00:42:17 -0500157
158#define DEVICE_PARAM_2 0x340
Masahiro Yamada8b0c16f2017-11-22 02:38:32 +0900159#define DEVICE_PARAM_2__VALUE GENMASK(7, 0)
Chin Liang See03534df2014-09-12 00:42:17 -0500160
161#define LOGICAL_PAGE_DATA_SIZE 0x350
Masahiro Yamada8b0c16f2017-11-22 02:38:32 +0900162#define LOGICAL_PAGE_DATA_SIZE__VALUE GENMASK(15, 0)
Chin Liang See03534df2014-09-12 00:42:17 -0500163
164#define LOGICAL_PAGE_SPARE_SIZE 0x360
Masahiro Yamada8b0c16f2017-11-22 02:38:32 +0900165#define LOGICAL_PAGE_SPARE_SIZE__VALUE GENMASK(15, 0)
Chin Liang See03534df2014-09-12 00:42:17 -0500166
167#define REVISION 0x370
Masahiro Yamada8b0c16f2017-11-22 02:38:32 +0900168#define REVISION__VALUE GENMASK(15, 0)
Chin Liang See03534df2014-09-12 00:42:17 -0500169
170#define ONFI_DEVICE_FEATURES 0x380
Masahiro Yamada8b0c16f2017-11-22 02:38:32 +0900171#define ONFI_DEVICE_FEATURES__VALUE GENMASK(5, 0)
Chin Liang See03534df2014-09-12 00:42:17 -0500172
173#define ONFI_OPTIONAL_COMMANDS 0x390
Masahiro Yamada8b0c16f2017-11-22 02:38:32 +0900174#define ONFI_OPTIONAL_COMMANDS__VALUE GENMASK(5, 0)
Chin Liang See03534df2014-09-12 00:42:17 -0500175
176#define ONFI_TIMING_MODE 0x3a0
Masahiro Yamada8b0c16f2017-11-22 02:38:32 +0900177#define ONFI_TIMING_MODE__VALUE GENMASK(5, 0)
Chin Liang See03534df2014-09-12 00:42:17 -0500178
179#define ONFI_PGM_CACHE_TIMING_MODE 0x3b0
Masahiro Yamada8b0c16f2017-11-22 02:38:32 +0900180#define ONFI_PGM_CACHE_TIMING_MODE__VALUE GENMASK(5, 0)
Chin Liang See03534df2014-09-12 00:42:17 -0500181
182#define ONFI_DEVICE_NO_OF_LUNS 0x3c0
Masahiro Yamada8b0c16f2017-11-22 02:38:32 +0900183#define ONFI_DEVICE_NO_OF_LUNS__NO_OF_LUNS GENMASK(7, 0)
184#define ONFI_DEVICE_NO_OF_LUNS__ONFI_DEVICE BIT(8)
Chin Liang See03534df2014-09-12 00:42:17 -0500185
186#define ONFI_DEVICE_NO_OF_BLOCKS_PER_LUN_L 0x3d0
Masahiro Yamada8b0c16f2017-11-22 02:38:32 +0900187#define ONFI_DEVICE_NO_OF_BLOCKS_PER_LUN_L__VALUE GENMASK(15, 0)
Chin Liang See03534df2014-09-12 00:42:17 -0500188
189#define ONFI_DEVICE_NO_OF_BLOCKS_PER_LUN_U 0x3e0
Masahiro Yamada8b0c16f2017-11-22 02:38:32 +0900190#define ONFI_DEVICE_NO_OF_BLOCKS_PER_LUN_U__VALUE GENMASK(15, 0)
Chin Liang See03534df2014-09-12 00:42:17 -0500191
Masahiro Yamada8b0c16f2017-11-22 02:38:32 +0900192#define FEATURES 0x3f0
193#define FEATURES__N_BANKS GENMASK(1, 0)
194#define FEATURES__ECC_MAX_ERR GENMASK(5, 2)
195#define FEATURES__DMA BIT(6)
196#define FEATURES__CMD_DMA BIT(7)
197#define FEATURES__PARTITION BIT(8)
198#define FEATURES__XDMA_SIDEBAND BIT(9)
199#define FEATURES__GPREG BIT(10)
200#define FEATURES__INDEX_ADDR BIT(11)
Chin Liang See03534df2014-09-12 00:42:17 -0500201
202#define TRANSFER_MODE 0x400
Masahiro Yamada8b0c16f2017-11-22 02:38:32 +0900203#define TRANSFER_MODE__VALUE GENMASK(1, 0)
Chin Liang See03534df2014-09-12 00:42:17 -0500204
Masahiro Yamada8b0c16f2017-11-22 02:38:32 +0900205#define INTR_STATUS(bank) (0x410 + (bank) * 0x50)
206#define INTR_EN(bank) (0x420 + (bank) * 0x50)
207/* bit[1:0] is used differently depending on IP version */
208#define INTR__ECC_UNCOR_ERR BIT(0) /* new IP */
209#define INTR__ECC_TRANSACTION_DONE BIT(0) /* old IP */
210#define INTR__ECC_ERR BIT(1) /* old IP */
211#define INTR__DMA_CMD_COMP BIT(2)
212#define INTR__TIME_OUT BIT(3)
213#define INTR__PROGRAM_FAIL BIT(4)
214#define INTR__ERASE_FAIL BIT(5)
215#define INTR__LOAD_COMP BIT(6)
216#define INTR__PROGRAM_COMP BIT(7)
217#define INTR__ERASE_COMP BIT(8)
218#define INTR__PIPE_CPYBCK_CMD_COMP BIT(9)
219#define INTR__LOCKED_BLK BIT(10)
220#define INTR__UNSUP_CMD BIT(11)
221#define INTR__INT_ACT BIT(12)
222#define INTR__RST_COMP BIT(13)
223#define INTR__PIPE_CMD_ERR BIT(14)
224#define INTR__PAGE_XFER_INC BIT(15)
225#define INTR__ERASED_PAGE BIT(16)
Chin Liang See03534df2014-09-12 00:42:17 -0500226
Masahiro Yamada8b0c16f2017-11-22 02:38:32 +0900227#define PAGE_CNT(bank) (0x430 + (bank) * 0x50)
228#define ERR_PAGE_ADDR(bank) (0x440 + (bank) * 0x50)
229#define ERR_BLOCK_ADDR(bank) (0x450 + (bank) * 0x50)
Chin Liang See03534df2014-09-12 00:42:17 -0500230
231#define ECC_THRESHOLD 0x600
Masahiro Yamada8b0c16f2017-11-22 02:38:32 +0900232#define ECC_THRESHOLD__VALUE GENMASK(9, 0)
Chin Liang See03534df2014-09-12 00:42:17 -0500233
234#define ECC_ERROR_BLOCK_ADDRESS 0x610
Masahiro Yamada8b0c16f2017-11-22 02:38:32 +0900235#define ECC_ERROR_BLOCK_ADDRESS__VALUE GENMASK(15, 0)
Chin Liang See03534df2014-09-12 00:42:17 -0500236
237#define ECC_ERROR_PAGE_ADDRESS 0x620
Masahiro Yamada8b0c16f2017-11-22 02:38:32 +0900238#define ECC_ERROR_PAGE_ADDRESS__VALUE GENMASK(11, 0)
239#define ECC_ERROR_PAGE_ADDRESS__BANK GENMASK(15, 12)
Chin Liang See03534df2014-09-12 00:42:17 -0500240
241#define ECC_ERROR_ADDRESS 0x630
Masahiro Yamada8b0c16f2017-11-22 02:38:32 +0900242#define ECC_ERROR_ADDRESS__OFFSET GENMASK(11, 0)
243#define ECC_ERROR_ADDRESS__SECTOR GENMASK(15, 12)
Chin Liang See03534df2014-09-12 00:42:17 -0500244
245#define ERR_CORRECTION_INFO 0x640
Masahiro Yamada8b0c16f2017-11-22 02:38:32 +0900246#define ERR_CORRECTION_INFO__BYTE GENMASK(7, 0)
247#define ERR_CORRECTION_INFO__DEVICE GENMASK(11, 8)
248#define ERR_CORRECTION_INFO__UNCOR BIT(14)
249#define ERR_CORRECTION_INFO__LAST_ERR BIT(15)
250
251#define ECC_COR_INFO(bank) (0x650 + (bank) / 2 * 0x10)
252#define ECC_COR_INFO__SHIFT(bank) ((bank) % 2 * 8)
253#define ECC_COR_INFO__MAX_ERRORS GENMASK(6, 0)
254#define ECC_COR_INFO__UNCOR_ERR BIT(7)
255
256#define CFG_DATA_BLOCK_SIZE 0x6b0
257
258#define CFG_LAST_DATA_BLOCK_SIZE 0x6c0
259
260#define CFG_NUM_DATA_BLOCKS 0x6d0
261
262#define CFG_META_DATA_SIZE 0x6e0
Chin Liang See03534df2014-09-12 00:42:17 -0500263
264#define DMA_ENABLE 0x700
Masahiro Yamada8b0c16f2017-11-22 02:38:32 +0900265#define DMA_ENABLE__FLAG BIT(0)
Chin Liang See03534df2014-09-12 00:42:17 -0500266
267#define IGNORE_ECC_DONE 0x710
Masahiro Yamada8b0c16f2017-11-22 02:38:32 +0900268#define IGNORE_ECC_DONE__FLAG BIT(0)
Chin Liang See03534df2014-09-12 00:42:17 -0500269
270#define DMA_INTR 0x720
Chin Liang See03534df2014-09-12 00:42:17 -0500271#define DMA_INTR_EN 0x730
Masahiro Yamada8b0c16f2017-11-22 02:38:32 +0900272#define DMA_INTR__TARGET_ERROR BIT(0)
273#define DMA_INTR__DESC_COMP_CHANNEL0 BIT(1)
274#define DMA_INTR__DESC_COMP_CHANNEL1 BIT(2)
275#define DMA_INTR__DESC_COMP_CHANNEL2 BIT(3)
276#define DMA_INTR__DESC_COMP_CHANNEL3 BIT(4)
277#define DMA_INTR__MEMCOPY_DESC_COMP BIT(5)
Chin Liang See03534df2014-09-12 00:42:17 -0500278
279#define TARGET_ERR_ADDR_LO 0x740
Masahiro Yamada8b0c16f2017-11-22 02:38:32 +0900280#define TARGET_ERR_ADDR_LO__VALUE GENMASK(15, 0)
Chin Liang See03534df2014-09-12 00:42:17 -0500281
282#define TARGET_ERR_ADDR_HI 0x750
Masahiro Yamada8b0c16f2017-11-22 02:38:32 +0900283#define TARGET_ERR_ADDR_HI__VALUE GENMASK(15, 0)
Chin Liang See03534df2014-09-12 00:42:17 -0500284
285#define CHNL_ACTIVE 0x760
Masahiro Yamada8b0c16f2017-11-22 02:38:32 +0900286#define CHNL_ACTIVE__CHANNEL0 BIT(0)
287#define CHNL_ACTIVE__CHANNEL1 BIT(1)
288#define CHNL_ACTIVE__CHANNEL2 BIT(2)
289#define CHNL_ACTIVE__CHANNEL3 BIT(3)
Chin Liang See03534df2014-09-12 00:42:17 -0500290
Masahiro Yamada8b0c16f2017-11-22 02:38:32 +0900291struct udevice;
Chin Liang See03534df2014-09-12 00:42:17 -0500292
293struct denali_nand_info {
Masahiro Yamadada0763d2014-11-13 20:31:50 +0900294 struct nand_chip nand;
Masahiro Yamada2d1fbc82018-12-19 20:03:18 +0900295 unsigned long clk_rate; /* core clock rate */
Masahiro Yamadab1c72732017-10-14 02:21:18 +0900296 unsigned long clk_x_rate; /* bus interface clock rate */
Masahiro Yamada8b0c16f2017-11-22 02:38:32 +0900297 int active_bank; /* currently selected bank */
298 struct udevice *dev;
Chin Liang See03534df2014-09-12 00:42:17 -0500299 uint32_t page;
Masahiro Yamada8b0c16f2017-11-22 02:38:32 +0900300 void __iomem *reg; /* Register Interface */
301 void __iomem *host; /* Host Data/Command Interface */
302 u32 irq_mask; /* interrupts we are waiting for */
303 u32 irq_status; /* interrupts that have happened */
Chin Liang See03534df2014-09-12 00:42:17 -0500304 int irq;
Masahiro Yamada8b0c16f2017-11-22 02:38:32 +0900305 void *buf; /* for syndrome layout conversion */
306 dma_addr_t dma_addr;
307 int dma_avail; /* can support DMA? */
308 int devs_per_cs; /* devices connected in parallel */
309 int oob_skip_bytes; /* number of bytes reserved for BBM */
310 int max_banks;
311 unsigned int revision; /* IP revision */
312 unsigned int caps; /* IP capability (or quirk) */
313 const struct nand_ecc_caps *ecc_caps;
314 u32 (*host_read)(struct denali_nand_info *denali, u32 addr);
315 void (*host_write)(struct denali_nand_info *denali, u32 addr, u32 data);
316 void (*setup_dma)(struct denali_nand_info *denali, dma_addr_t dma_addr,
317 int page, int write);
Chin Liang See03534df2014-09-12 00:42:17 -0500318};
319
Masahiro Yamada54fde8e2017-09-15 21:43:19 +0900320#define DENALI_CAP_HW_ECC_FIXUP BIT(0)
321#define DENALI_CAP_DMA_64BIT BIT(1)
322
Masahiro Yamada8b0c16f2017-11-22 02:38:32 +0900323int denali_calc_ecc_bytes(int step_size, int strength);
Ley Foon Tand3de3f22020-07-10 14:58:15 +0800324int denali_wait_reset_complete(struct denali_nand_info *denali);
Masahiro Yamada9c5a5dd2017-08-26 01:12:31 +0900325int denali_init(struct denali_nand_info *denali);
326
Scott Wood3ea94ed2015-06-26 19:03:26 -0500327#endif /* __DENALI_H__ */