diff options
author | Kyungmin Park <kyungmin.park@samsung.com> | 2007-01-15 03:09:14 -0500 |
---|---|---|
committer | Kyungmin Park <kyungmin.park@samsung.com> | 2007-01-17 21:00:31 -0500 |
commit | 738d61f53781a9b677cb472cbd740aa74e7dcd6d (patch) | |
tree | 45b7e7afb765eb497407295bb611fa2327ebf4a1 | |
parent | 9d03280129e84f8cdfd83f84803a4548e3bf697d (diff) |
[MTD] OneNAND: Reduce Double Density Package (DDP) operations
- DDP code clean-up
- Reduce block & bufferram operations in DDP
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
-rw-r--r-- | drivers/mtd/onenand/onenand_base.c | 42 | ||||
-rw-r--r-- | include/linux/mtd/onenand.h | 3 | ||||
-rw-r--r-- | include/linux/mtd/onenand_regs.h | 4 |
3 files changed, 22 insertions, 27 deletions
diff --git a/drivers/mtd/onenand/onenand_base.c b/drivers/mtd/onenand/onenand_base.c index ce1cbdcd355a..d88c7f7fc619 100644 --- a/drivers/mtd/onenand/onenand_base.c +++ b/drivers/mtd/onenand/onenand_base.c | |||
@@ -94,16 +94,9 @@ static void onenand_writew(unsigned short value, void __iomem *addr) | |||
94 | */ | 94 | */ |
95 | static int onenand_block_address(struct onenand_chip *this, int block) | 95 | static int onenand_block_address(struct onenand_chip *this, int block) |
96 | { | 96 | { |
97 | if (this->device_id & ONENAND_DEVICE_IS_DDP) { | 97 | /* Device Flash Core select, NAND Flash Block Address */ |
98 | /* Device Flash Core select, NAND Flash Block Address */ | 98 | if (block & this->density_mask) |
99 | int dfs = 0; | 99 | return ONENAND_DDP_CHIP1 | (block ^ this->density_mask); |
100 | |||
101 | if (block & this->density_mask) | ||
102 | dfs = 1; | ||
103 | |||
104 | return (dfs << ONENAND_DDP_SHIFT) | | ||
105 | (block & (this->density_mask - 1)); | ||
106 | } | ||
107 | 100 | ||
108 | return block; | 101 | return block; |
109 | } | 102 | } |
@@ -118,17 +111,11 @@ static int onenand_block_address(struct onenand_chip *this, int block) | |||
118 | */ | 111 | */ |
119 | static int onenand_bufferram_address(struct onenand_chip *this, int block) | 112 | static int onenand_bufferram_address(struct onenand_chip *this, int block) |
120 | { | 113 | { |
121 | if (this->device_id & ONENAND_DEVICE_IS_DDP) { | 114 | /* Device BufferRAM Select */ |
122 | /* Device BufferRAM Select */ | 115 | if (block & this->density_mask) |
123 | int dbs = 0; | 116 | return ONENAND_DDP_CHIP1; |
124 | |||
125 | if (block & this->density_mask) | ||
126 | dbs = 1; | ||
127 | 117 | ||
128 | return (dbs << ONENAND_DDP_SHIFT); | 118 | return ONENAND_DDP_CHIP0; |
129 | } | ||
130 | |||
131 | return 0; | ||
132 | } | 119 | } |
133 | 120 | ||
134 | /** | 121 | /** |
@@ -757,9 +744,9 @@ static int onenand_read(struct mtd_info *mtd, loff_t from, size_t len, | |||
757 | * Now we issued chip 1 read and pointed chip 1 | 744 | * Now we issued chip 1 read and pointed chip 1 |
758 | * bufferam so we have to point chip 0 bufferam. | 745 | * bufferam so we have to point chip 0 bufferam. |
759 | */ | 746 | */ |
760 | if (this->device_id & ONENAND_DEVICE_IS_DDP && | 747 | if (ONENAND_IS_DDP(this) && |
761 | unlikely(from == (this->chipsize >> 1))) { | 748 | unlikely(from == (this->chipsize >> 1))) { |
762 | this->write_word(0, this->base + ONENAND_REG_START_ADDRESS2); | 749 | this->write_word(ONENAND_DDP_CHIP0, this->base + ONENAND_REG_START_ADDRESS2); |
763 | boundary = 1; | 750 | boundary = 1; |
764 | } else | 751 | } else |
765 | boundary = 0; | 752 | boundary = 0; |
@@ -773,7 +760,7 @@ static int onenand_read(struct mtd_info *mtd, loff_t from, size_t len, | |||
773 | break; | 760 | break; |
774 | /* Set up for next read from bufferRAM */ | 761 | /* Set up for next read from bufferRAM */ |
775 | if (unlikely(boundary)) | 762 | if (unlikely(boundary)) |
776 | this->write_word(0x8000, this->base + ONENAND_REG_START_ADDRESS2); | 763 | this->write_word(ONENAND_DDP_CHIP1, this->base + ONENAND_REG_START_ADDRESS2); |
777 | ONENAND_SET_NEXT_BUFFERRAM(this); | 764 | ONENAND_SET_NEXT_BUFFERRAM(this); |
778 | buf += thislen; | 765 | buf += thislen; |
779 | thislen = min_t(int, mtd->writesize, len - read); | 766 | thislen = min_t(int, mtd->writesize, len - read); |
@@ -1508,7 +1495,7 @@ static int onenand_unlock_all(struct mtd_info *mtd) | |||
1508 | continue; | 1495 | continue; |
1509 | 1496 | ||
1510 | /* Workaround for all block unlock in DDP */ | 1497 | /* Workaround for all block unlock in DDP */ |
1511 | if (this->device_id & ONENAND_DEVICE_IS_DDP) { | 1498 | if (ONENAND_IS_DDP(this)) { |
1512 | /* 1st block on another chip */ | 1499 | /* 1st block on another chip */ |
1513 | loff_t ofs = this->chipsize >> 1; | 1500 | loff_t ofs = this->chipsize >> 1; |
1514 | size_t len = mtd->erasesize; | 1501 | size_t len = mtd->erasesize; |
@@ -1963,7 +1950,10 @@ static int onenand_probe(struct mtd_info *mtd) | |||
1963 | density = dev_id >> ONENAND_DEVICE_DENSITY_SHIFT; | 1950 | density = dev_id >> ONENAND_DEVICE_DENSITY_SHIFT; |
1964 | this->chipsize = (16 << density) << 20; | 1951 | this->chipsize = (16 << density) << 20; |
1965 | /* Set density mask. it is used for DDP */ | 1952 | /* Set density mask. it is used for DDP */ |
1966 | this->density_mask = (1 << (density + 6)); | 1953 | if (ONENAND_IS_DDP(this)) |
1954 | this->density_mask = (1 << (density + 6)); | ||
1955 | else | ||
1956 | this->density_mask = 0; | ||
1967 | 1957 | ||
1968 | /* OneNAND page size & block size */ | 1958 | /* OneNAND page size & block size */ |
1969 | /* The data buffer size is equal to page size */ | 1959 | /* The data buffer size is equal to page size */ |
diff --git a/include/linux/mtd/onenand.h b/include/linux/mtd/onenand.h index f775a7af3890..a99b2944d26b 100644 --- a/include/linux/mtd/onenand.h +++ b/include/linux/mtd/onenand.h | |||
@@ -150,6 +150,9 @@ struct onenand_chip { | |||
150 | #define ONENAND_SET_SYS_CFG1(v, this) \ | 150 | #define ONENAND_SET_SYS_CFG1(v, this) \ |
151 | (this->write_word(v, this->base + ONENAND_REG_SYS_CFG1)) | 151 | (this->write_word(v, this->base + ONENAND_REG_SYS_CFG1)) |
152 | 152 | ||
153 | #define ONENAND_IS_DDP(this) \ | ||
154 | (this->device_id & ONENAND_DEVICE_IS_DDP) | ||
155 | |||
153 | /* Check byte access in OneNAND */ | 156 | /* Check byte access in OneNAND */ |
154 | #define ONENAND_CHECK_BYTE_ACCESS(addr) (addr & 0x1) | 157 | #define ONENAND_CHECK_BYTE_ACCESS(addr) (addr & 0x1) |
155 | 158 | ||
diff --git a/include/linux/mtd/onenand_regs.h b/include/linux/mtd/onenand_regs.h index e31c8f5d4271..5b46cb52d214 100644 --- a/include/linux/mtd/onenand_regs.h +++ b/include/linux/mtd/onenand_regs.h | |||
@@ -80,9 +80,11 @@ | |||
80 | #define ONENAND_VERSION_PROCESS_SHIFT (8) | 80 | #define ONENAND_VERSION_PROCESS_SHIFT (8) |
81 | 81 | ||
82 | /* | 82 | /* |
83 | * Start Address 1 F100h (R/W) | 83 | * Start Address 1 F100h (R/W) & Start Address 2 F101h (R/W) |
84 | */ | 84 | */ |
85 | #define ONENAND_DDP_SHIFT (15) | 85 | #define ONENAND_DDP_SHIFT (15) |
86 | #define ONENAND_DDP_CHIP0 (0) | ||
87 | #define ONENAND_DDP_CHIP1 (1 << ONENAND_DDP_SHIFT) | ||
86 | 88 | ||
87 | /* | 89 | /* |
88 | * Start Address 8 F107h (R/W) | 90 | * Start Address 8 F107h (R/W) |