116216333SThomas Gleixner /* SPDX-License-Identifier: GPL-2.0-or-later */ 293db446aSBoris Brezillon /* 393db446aSBoris Brezillon * Freescale GPMI NAND Flash Driver 493db446aSBoris Brezillon * 593db446aSBoris Brezillon * Copyright 2008-2011 Freescale Semiconductor, Inc. 693db446aSBoris Brezillon * Copyright 2008 Embedded Alley Solutions, Inc. 793db446aSBoris Brezillon */ 893db446aSBoris Brezillon #ifndef __GPMI_NAND_GPMI_REGS_H 993db446aSBoris Brezillon #define __GPMI_NAND_GPMI_REGS_H 1093db446aSBoris Brezillon 1193db446aSBoris Brezillon #define HW_GPMI_CTRL0 0x00000000 1293db446aSBoris Brezillon #define HW_GPMI_CTRL0_SET 0x00000004 1393db446aSBoris Brezillon #define HW_GPMI_CTRL0_CLR 0x00000008 1493db446aSBoris Brezillon #define HW_GPMI_CTRL0_TOG 0x0000000c 1593db446aSBoris Brezillon 1693db446aSBoris Brezillon #define BP_GPMI_CTRL0_COMMAND_MODE 24 1793db446aSBoris Brezillon #define BM_GPMI_CTRL0_COMMAND_MODE (3 << BP_GPMI_CTRL0_COMMAND_MODE) 1893db446aSBoris Brezillon #define BF_GPMI_CTRL0_COMMAND_MODE(v) \ 1993db446aSBoris Brezillon (((v) << BP_GPMI_CTRL0_COMMAND_MODE) & BM_GPMI_CTRL0_COMMAND_MODE) 2093db446aSBoris Brezillon #define BV_GPMI_CTRL0_COMMAND_MODE__WRITE 0x0 2193db446aSBoris Brezillon #define BV_GPMI_CTRL0_COMMAND_MODE__READ 0x1 2293db446aSBoris Brezillon #define BV_GPMI_CTRL0_COMMAND_MODE__READ_AND_COMPARE 0x2 2393db446aSBoris Brezillon #define BV_GPMI_CTRL0_COMMAND_MODE__WAIT_FOR_READY 0x3 2493db446aSBoris Brezillon 2593db446aSBoris Brezillon #define BM_GPMI_CTRL0_WORD_LENGTH (1 << 23) 2693db446aSBoris Brezillon #define BV_GPMI_CTRL0_WORD_LENGTH__16_BIT 0x0 2793db446aSBoris Brezillon #define BV_GPMI_CTRL0_WORD_LENGTH__8_BIT 0x1 2893db446aSBoris Brezillon 2993db446aSBoris Brezillon /* 3093db446aSBoris Brezillon * Difference in LOCK_CS between imx23 and imx28 : 3193db446aSBoris Brezillon * This bit may impact the _POWER_ consumption. So some chips 3293db446aSBoris Brezillon * do not set it. 3393db446aSBoris Brezillon */ 3493db446aSBoris Brezillon #define MX23_BP_GPMI_CTRL0_LOCK_CS 22 3593db446aSBoris Brezillon #define MX28_BP_GPMI_CTRL0_LOCK_CS 27 3693db446aSBoris Brezillon #define LOCK_CS_ENABLE 0x1 3793db446aSBoris Brezillon #define BF_GPMI_CTRL0_LOCK_CS(v, x) 0x0 3893db446aSBoris Brezillon 3993db446aSBoris Brezillon /* Difference in CS between imx23 and imx28 */ 4093db446aSBoris Brezillon #define BP_GPMI_CTRL0_CS 20 4193db446aSBoris Brezillon #define MX23_BM_GPMI_CTRL0_CS (3 << BP_GPMI_CTRL0_CS) 4293db446aSBoris Brezillon #define MX28_BM_GPMI_CTRL0_CS (7 << BP_GPMI_CTRL0_CS) 4393db446aSBoris Brezillon #define BF_GPMI_CTRL0_CS(v, x) (((v) << BP_GPMI_CTRL0_CS) & \ 4493db446aSBoris Brezillon (GPMI_IS_MX23((x)) \ 4593db446aSBoris Brezillon ? MX23_BM_GPMI_CTRL0_CS \ 4693db446aSBoris Brezillon : MX28_BM_GPMI_CTRL0_CS)) 4793db446aSBoris Brezillon 4893db446aSBoris Brezillon #define BP_GPMI_CTRL0_ADDRESS 17 4993db446aSBoris Brezillon #define BM_GPMI_CTRL0_ADDRESS (3 << BP_GPMI_CTRL0_ADDRESS) 5093db446aSBoris Brezillon #define BF_GPMI_CTRL0_ADDRESS(v) \ 5193db446aSBoris Brezillon (((v) << BP_GPMI_CTRL0_ADDRESS) & BM_GPMI_CTRL0_ADDRESS) 5293db446aSBoris Brezillon #define BV_GPMI_CTRL0_ADDRESS__NAND_DATA 0x0 5393db446aSBoris Brezillon #define BV_GPMI_CTRL0_ADDRESS__NAND_CLE 0x1 5493db446aSBoris Brezillon #define BV_GPMI_CTRL0_ADDRESS__NAND_ALE 0x2 5593db446aSBoris Brezillon 5693db446aSBoris Brezillon #define BM_GPMI_CTRL0_ADDRESS_INCREMENT (1 << 16) 5793db446aSBoris Brezillon #define BV_GPMI_CTRL0_ADDRESS_INCREMENT__DISABLED 0x0 5893db446aSBoris Brezillon #define BV_GPMI_CTRL0_ADDRESS_INCREMENT__ENABLED 0x1 5993db446aSBoris Brezillon 6093db446aSBoris Brezillon #define BP_GPMI_CTRL0_XFER_COUNT 0 6193db446aSBoris Brezillon #define BM_GPMI_CTRL0_XFER_COUNT (0xffff << BP_GPMI_CTRL0_XFER_COUNT) 6293db446aSBoris Brezillon #define BF_GPMI_CTRL0_XFER_COUNT(v) \ 6393db446aSBoris Brezillon (((v) << BP_GPMI_CTRL0_XFER_COUNT) & BM_GPMI_CTRL0_XFER_COUNT) 6493db446aSBoris Brezillon 6593db446aSBoris Brezillon #define HW_GPMI_COMPARE 0x00000010 6693db446aSBoris Brezillon 6793db446aSBoris Brezillon #define HW_GPMI_ECCCTRL 0x00000020 6893db446aSBoris Brezillon #define HW_GPMI_ECCCTRL_SET 0x00000024 6993db446aSBoris Brezillon #define HW_GPMI_ECCCTRL_CLR 0x00000028 7093db446aSBoris Brezillon #define HW_GPMI_ECCCTRL_TOG 0x0000002c 7193db446aSBoris Brezillon 7293db446aSBoris Brezillon #define BP_GPMI_ECCCTRL_ECC_CMD 13 7393db446aSBoris Brezillon #define BM_GPMI_ECCCTRL_ECC_CMD (3 << BP_GPMI_ECCCTRL_ECC_CMD) 7493db446aSBoris Brezillon #define BF_GPMI_ECCCTRL_ECC_CMD(v) \ 7593db446aSBoris Brezillon (((v) << BP_GPMI_ECCCTRL_ECC_CMD) & BM_GPMI_ECCCTRL_ECC_CMD) 7693db446aSBoris Brezillon #define BV_GPMI_ECCCTRL_ECC_CMD__BCH_DECODE 0x0 7793db446aSBoris Brezillon #define BV_GPMI_ECCCTRL_ECC_CMD__BCH_ENCODE 0x1 7893db446aSBoris Brezillon 7993db446aSBoris Brezillon #define BM_GPMI_ECCCTRL_ENABLE_ECC (1 << 12) 8093db446aSBoris Brezillon #define BV_GPMI_ECCCTRL_ENABLE_ECC__ENABLE 0x1 8193db446aSBoris Brezillon #define BV_GPMI_ECCCTRL_ENABLE_ECC__DISABLE 0x0 8293db446aSBoris Brezillon 8393db446aSBoris Brezillon #define BP_GPMI_ECCCTRL_BUFFER_MASK 0 8493db446aSBoris Brezillon #define BM_GPMI_ECCCTRL_BUFFER_MASK (0x1ff << BP_GPMI_ECCCTRL_BUFFER_MASK) 8593db446aSBoris Brezillon #define BF_GPMI_ECCCTRL_BUFFER_MASK(v) \ 8693db446aSBoris Brezillon (((v) << BP_GPMI_ECCCTRL_BUFFER_MASK) & BM_GPMI_ECCCTRL_BUFFER_MASK) 8793db446aSBoris Brezillon #define BV_GPMI_ECCCTRL_BUFFER_MASK__BCH_AUXONLY 0x100 8893db446aSBoris Brezillon #define BV_GPMI_ECCCTRL_BUFFER_MASK__BCH_PAGE 0x1FF 8993db446aSBoris Brezillon 9093db446aSBoris Brezillon #define HW_GPMI_ECCCOUNT 0x00000030 9193db446aSBoris Brezillon #define HW_GPMI_PAYLOAD 0x00000040 9293db446aSBoris Brezillon #define HW_GPMI_AUXILIARY 0x00000050 9393db446aSBoris Brezillon #define HW_GPMI_CTRL1 0x00000060 9493db446aSBoris Brezillon #define HW_GPMI_CTRL1_SET 0x00000064 9593db446aSBoris Brezillon #define HW_GPMI_CTRL1_CLR 0x00000068 9693db446aSBoris Brezillon #define HW_GPMI_CTRL1_TOG 0x0000006c 9793db446aSBoris Brezillon 9893db446aSBoris Brezillon #define BP_GPMI_CTRL1_DECOUPLE_CS 24 9993db446aSBoris Brezillon #define BM_GPMI_CTRL1_DECOUPLE_CS (1 << BP_GPMI_CTRL1_DECOUPLE_CS) 10093db446aSBoris Brezillon 10193db446aSBoris Brezillon #define BP_GPMI_CTRL1_WRN_DLY_SEL 22 10293db446aSBoris Brezillon #define BM_GPMI_CTRL1_WRN_DLY_SEL (0x3 << BP_GPMI_CTRL1_WRN_DLY_SEL) 10393db446aSBoris Brezillon #define BF_GPMI_CTRL1_WRN_DLY_SEL(v) \ 10493db446aSBoris Brezillon (((v) << BP_GPMI_CTRL1_WRN_DLY_SEL) & BM_GPMI_CTRL1_WRN_DLY_SEL) 10593db446aSBoris Brezillon #define BV_GPMI_CTRL1_WRN_DLY_SEL_4_TO_8NS 0x0 10693db446aSBoris Brezillon #define BV_GPMI_CTRL1_WRN_DLY_SEL_6_TO_10NS 0x1 10793db446aSBoris Brezillon #define BV_GPMI_CTRL1_WRN_DLY_SEL_7_TO_12NS 0x2 10893db446aSBoris Brezillon #define BV_GPMI_CTRL1_WRN_DLY_SEL_NO_DELAY 0x3 10993db446aSBoris Brezillon 110*46337d15SHan Xu #define BM_GPMI_CTRL1_GANGED_RDYBUSY (1 << 19) 11193db446aSBoris Brezillon #define BM_GPMI_CTRL1_BCH_MODE (1 << 18) 11293db446aSBoris Brezillon 11393db446aSBoris Brezillon #define BP_GPMI_CTRL1_DLL_ENABLE 17 11493db446aSBoris Brezillon #define BM_GPMI_CTRL1_DLL_ENABLE (1 << BP_GPMI_CTRL1_DLL_ENABLE) 11593db446aSBoris Brezillon 11693db446aSBoris Brezillon #define BP_GPMI_CTRL1_HALF_PERIOD 16 11793db446aSBoris Brezillon #define BM_GPMI_CTRL1_HALF_PERIOD (1 << BP_GPMI_CTRL1_HALF_PERIOD) 11893db446aSBoris Brezillon 11993db446aSBoris Brezillon #define BP_GPMI_CTRL1_RDN_DELAY 12 12093db446aSBoris Brezillon #define BM_GPMI_CTRL1_RDN_DELAY (0xf << BP_GPMI_CTRL1_RDN_DELAY) 12193db446aSBoris Brezillon #define BF_GPMI_CTRL1_RDN_DELAY(v) \ 12293db446aSBoris Brezillon (((v) << BP_GPMI_CTRL1_RDN_DELAY) & BM_GPMI_CTRL1_RDN_DELAY) 12393db446aSBoris Brezillon 12493db446aSBoris Brezillon #define BM_GPMI_CTRL1_DEV_RESET (1 << 3) 12593db446aSBoris Brezillon #define BV_GPMI_CTRL1_DEV_RESET__ENABLED 0x0 12693db446aSBoris Brezillon #define BV_GPMI_CTRL1_DEV_RESET__DISABLED 0x1 12793db446aSBoris Brezillon 12893db446aSBoris Brezillon #define BM_GPMI_CTRL1_ATA_IRQRDY_POLARITY (1 << 2) 12993db446aSBoris Brezillon #define BV_GPMI_CTRL1_ATA_IRQRDY_POLARITY__ACTIVELOW 0x0 13093db446aSBoris Brezillon #define BV_GPMI_CTRL1_ATA_IRQRDY_POLARITY__ACTIVEHIGH 0x1 13193db446aSBoris Brezillon 13293db446aSBoris Brezillon #define BM_GPMI_CTRL1_CAMERA_MODE (1 << 1) 13393db446aSBoris Brezillon #define BV_GPMI_CTRL1_GPMI_MODE__NAND 0x0 13493db446aSBoris Brezillon #define BV_GPMI_CTRL1_GPMI_MODE__ATA 0x1 13593db446aSBoris Brezillon 13693db446aSBoris Brezillon #define BM_GPMI_CTRL1_GPMI_MODE (1 << 0) 13793db446aSBoris Brezillon 138b1206122SMiquel Raynal #define BM_GPMI_CTRL1_CLEAR_MASK (BM_GPMI_CTRL1_WRN_DLY_SEL | \ 139b1206122SMiquel Raynal BM_GPMI_CTRL1_DLL_ENABLE | \ 140b1206122SMiquel Raynal BM_GPMI_CTRL1_RDN_DELAY | \ 141b1206122SMiquel Raynal BM_GPMI_CTRL1_HALF_PERIOD) 142b1206122SMiquel Raynal 14393db446aSBoris Brezillon #define HW_GPMI_TIMING0 0x00000070 14493db446aSBoris Brezillon 14593db446aSBoris Brezillon #define BP_GPMI_TIMING0_ADDRESS_SETUP 16 14693db446aSBoris Brezillon #define BM_GPMI_TIMING0_ADDRESS_SETUP (0xff << BP_GPMI_TIMING0_ADDRESS_SETUP) 14793db446aSBoris Brezillon #define BF_GPMI_TIMING0_ADDRESS_SETUP(v) \ 14893db446aSBoris Brezillon (((v) << BP_GPMI_TIMING0_ADDRESS_SETUP) & BM_GPMI_TIMING0_ADDRESS_SETUP) 14993db446aSBoris Brezillon 15093db446aSBoris Brezillon #define BP_GPMI_TIMING0_DATA_HOLD 8 15193db446aSBoris Brezillon #define BM_GPMI_TIMING0_DATA_HOLD (0xff << BP_GPMI_TIMING0_DATA_HOLD) 15293db446aSBoris Brezillon #define BF_GPMI_TIMING0_DATA_HOLD(v) \ 15393db446aSBoris Brezillon (((v) << BP_GPMI_TIMING0_DATA_HOLD) & BM_GPMI_TIMING0_DATA_HOLD) 15493db446aSBoris Brezillon 15593db446aSBoris Brezillon #define BP_GPMI_TIMING0_DATA_SETUP 0 15693db446aSBoris Brezillon #define BM_GPMI_TIMING0_DATA_SETUP (0xff << BP_GPMI_TIMING0_DATA_SETUP) 15793db446aSBoris Brezillon #define BF_GPMI_TIMING0_DATA_SETUP(v) \ 15893db446aSBoris Brezillon (((v) << BP_GPMI_TIMING0_DATA_SETUP) & BM_GPMI_TIMING0_DATA_SETUP) 15993db446aSBoris Brezillon 16093db446aSBoris Brezillon #define HW_GPMI_TIMING1 0x00000080 16193db446aSBoris Brezillon #define BP_GPMI_TIMING1_BUSY_TIMEOUT 16 16293db446aSBoris Brezillon #define BM_GPMI_TIMING1_BUSY_TIMEOUT (0xffff << BP_GPMI_TIMING1_BUSY_TIMEOUT) 16393db446aSBoris Brezillon #define BF_GPMI_TIMING1_BUSY_TIMEOUT(v) \ 16493db446aSBoris Brezillon (((v) << BP_GPMI_TIMING1_BUSY_TIMEOUT) & BM_GPMI_TIMING1_BUSY_TIMEOUT) 16593db446aSBoris Brezillon 16693db446aSBoris Brezillon #define HW_GPMI_TIMING2 0x00000090 16793db446aSBoris Brezillon #define HW_GPMI_DATA 0x000000a0 16893db446aSBoris Brezillon 16993db446aSBoris Brezillon /* MX28 uses this to detect READY. */ 17093db446aSBoris Brezillon #define HW_GPMI_STAT 0x000000b0 17193db446aSBoris Brezillon #define MX28_BP_GPMI_STAT_READY_BUSY 24 17293db446aSBoris Brezillon #define MX28_BM_GPMI_STAT_READY_BUSY (0xff << MX28_BP_GPMI_STAT_READY_BUSY) 17393db446aSBoris Brezillon #define MX28_BF_GPMI_STAT_READY_BUSY(v) \ 17493db446aSBoris Brezillon (((v) << MX28_BP_GPMI_STAT_READY_BUSY) & MX28_BM_GPMI_STAT_READY_BUSY) 17593db446aSBoris Brezillon 17693db446aSBoris Brezillon /* MX23 uses this to detect READY. */ 17793db446aSBoris Brezillon #define HW_GPMI_DEBUG 0x000000c0 17893db446aSBoris Brezillon #define MX23_BP_GPMI_DEBUG_READY0 28 17993db446aSBoris Brezillon #define MX23_BM_GPMI_DEBUG_READY0 (1 << MX23_BP_GPMI_DEBUG_READY0) 18093db446aSBoris Brezillon #endif 181