21 #include <linux/kernel.h>
22 #include <linux/slab.h>
24 #include <linux/module.h>
34 #define NR_CS553X_CONTROLLERS 4
36 #define MSR_DIVIL_GLD_CAP 0x51400000
37 #define CAP_CS5535 0x2df000ULL
38 #define CAP_CS5536 0x5df500ULL
41 #define MSR_NANDF_DATA 0x5140001b
42 #define MSR_NANDF_CTL 0x5140001c
43 #define MSR_NANDF_RSVD 0x5140001d
46 #define MSR_DIVIL_LBAR_FLSH0 0x51400010
47 #define MSR_DIVIL_LBAR_FLSH1 0x51400011
48 #define MSR_DIVIL_LBAR_FLSH2 0x51400012
49 #define MSR_DIVIL_LBAR_FLSH3 0x51400013
51 #define FLSH_LBAR_EN (1ULL<<32)
52 #define FLSH_NOR_NAND (1ULL<<33)
53 #define FLSH_MEM_IO (1ULL<<34)
58 #define MSR_DIVIL_BALL_OPTS 0x51400015
59 #define PIN_OPT_IDE (1<<0)
62 #define MM_NAND_DATA 0x00
63 #define MM_NAND_CTL 0x800
64 #define MM_NAND_IO 0x801
65 #define MM_NAND_STS 0x810
66 #define MM_NAND_ECC_LSB 0x811
67 #define MM_NAND_ECC_MSB 0x812
68 #define MM_NAND_ECC_COL 0x813
69 #define MM_NAND_LAC 0x814
70 #define MM_NAND_ECC_CTL 0x815
73 #define IO_NAND_DATA 0x00
74 #define IO_NAND_CTL 0x04
75 #define IO_NAND_IO 0x05
76 #define IO_NAND_STS 0x06
77 #define IO_NAND_ECC_CTL 0x08
78 #define IO_NAND_ECC_LSB 0x09
79 #define IO_NAND_ECC_MSB 0x0a
80 #define IO_NAND_ECC_COL 0x0b
81 #define IO_NAND_LAC 0x0c
83 #define CS_NAND_CTL_DIST_EN (1<<4)
84 #define CS_NAND_CTL_RDY_INT_MASK (1<<3)
85 #define CS_NAND_CTL_ALE (1<<2)
86 #define CS_NAND_CTL_CLE (1<<1)
87 #define CS_NAND_CTL_CE (1<<0)
89 #define CS_NAND_STS_FLASH_RDY (1<<3)
90 #define CS_NAND_CTLR_BUSY (1<<2)
91 #define CS_NAND_CMD_COMP (1<<1)
92 #define CS_NAND_DIST_ST (1<<0)
94 #define CS_NAND_ECC_PARITY (1<<2)
95 #define CS_NAND_ECC_CLRECC (1<<1)
96 #define CS_NAND_ECC_ENECC (1<<0)
122 static unsigned char cs553x_read_byte(
struct mtd_info *mtd)
140 static void cs553x_hwcontrol(
struct mtd_info *mtd,
int cmd,
146 unsigned char ctl = (ctrl & ~NAND_CTRL_CHANGE ) ^ 0x01;
150 cs553x_write_byte(mtd, cmd);
153 static int cs553x_device_ready(
struct mtd_info *mtd)
162 static void cs_enable_hwecc(
struct mtd_info *mtd,
int mode)
178 ecc_code[1] = ecc >> 8;
179 ecc_code[0] = ecc >> 16;
180 ecc_code[2] = ecc >> 24;
184 static struct mtd_info *cs553x_mtd[4];
186 static int __init cs553x_init_one(
int cs,
int mmio,
unsigned long adr)
192 printk(
KERN_NOTICE "Probing CS553x NAND controller CS#%d at %sIO 0x%08lx\n", cs, mmio?
"MM":
"P", adr);
208 this = (
struct nand_chip *)(&new_mtd[1]);
215 new_mtd->
priv =
this;
235 this->
ecc.size = 256;
237 this->
ecc.hwctl = cs_enable_hwecc;
238 this->
ecc.calculate = cs_calculate_ecc;
250 this->
ecc.strength = 1;
254 cs553x_mtd[
cs] = new_mtd;
265 static int is_geode(
void)
282 static int __init cs553x_init(
void)
301 printk(
KERN_INFO "CS553x NAND controller: Flash I/O not enabled in MSR_DIVIL_BALL_OPTS.\n");
309 err = cs553x_init_one(i, !!(val &
FLSH_MEM_IO), val & 0xFFFFFFFF);
328 static void __exit cs553x_cleanup(
void)
340 this = cs553x_mtd[
i]->
priv;
346 cs553x_mtd[
i] =
NULL;