Merge git://git.infradead.org/mtd-2.6

* git://git.infradead.org/mtd-2.6: (59 commits)
mtd: mtdpart: disallow reading OOB past the end of the partition
mtd: pxa3xx_nand: NULL dereference in pxa3xx_nand_probe
UBI: use mtd->writebufsize to set minimal I/O unit size
mtd: initialize writebufsize in the MTD object of a partition
mtd: onenand: add mtd->writebufsize initialization
mtd: nand: add mtd->writebufsize initialization
mtd: cfi: add writebufsize initialization
mtd: add writebufsize field to mtd_info struct
mtd: OneNAND: OMAP2/3: prevent regulator sleeping while OneNAND is in use
mtd: OneNAND: add enable / disable methods to onenand_chip
mtd: m25p80: Fix JEDEC ID for AT26DF321
mtd: txx9ndfmc: limit transfer bytes to 512 (ECC provides 6 bytes max)
mtd: cfi_cmdset_0002: add support for Samsung K8D3x16UxC NOR chips
mtd: cfi_cmdset_0002: add support for Samsung K8D6x16UxM NOR chips
mtd: nand: ams-delta: drop omap_read/write, use ioremap
mtd: m25p80: add debugging trace in sst_write
mtd: nand: ams-delta: select for built-in by default
mtd: OneNAND: lighten scary initial bad block messages
mtd: OneNAND: OMAP2/3: add support for command line partitioning
mtd: nand: rearrange ONFI revision checking, add ONFI 2.3
...

Fix up trivial conflict in drivers/mtd/Kconfig as per DavidW.

+595 -351
+17
arch/arm/mach-omap1/board-ams-delta.c
··· 179 179 { OMAP_TAG_LCD, &ams_delta_lcd_config }, 180 180 }; 181 181 182 + static struct resource ams_delta_nand_resources[] = { 183 + [0] = { 184 + .start = OMAP1_MPUIO_BASE, 185 + .end = OMAP1_MPUIO_BASE + 186 + OMAP_MPUIO_IO_CNTL + sizeof(u32) - 1, 187 + .flags = IORESOURCE_MEM, 188 + }, 189 + }; 190 + 191 + static struct platform_device ams_delta_nand_device = { 192 + .name = "ams-delta-nand", 193 + .id = -1, 194 + .num_resources = ARRAY_SIZE(ams_delta_nand_resources), 195 + .resource = ams_delta_nand_resources, 196 + }; 197 + 182 198 static struct resource ams_delta_kp_resources[] = { 183 199 [0] = { 184 200 .start = INT_KEYBOARD, ··· 281 265 }; 282 266 283 267 static struct platform_device *ams_delta_devices[] __initdata = { 268 + &ams_delta_nand_device, 284 269 &ams_delta_kp_device, 285 270 &ams_delta_lcd_device, 286 271 &ams_delta_led_device,
+1
arch/arm/plat-omap/include/plat/onenand.h
··· 23 23 int (*onenand_setup)(void __iomem *, int freq); 24 24 int dma_channel; 25 25 u8 flags; 26 + u8 regulator_can_sleep; 26 27 }; 27 28 28 29 #define ONENAND_MAX_PARTITIONS 8
+11 -8
drivers/mtd/Kconfig
··· 53 53 devices. Partitioning on NFTL 'devices' is a different - that's the 54 54 'normal' form of partitioning used on a block device. 55 55 56 + if MTD_PARTITIONS 57 + 56 58 config MTD_REDBOOT_PARTS 57 59 tristate "RedBoot partition table parsing" 58 - depends on MTD_PARTITIONS 59 60 ---help--- 60 61 RedBoot is a ROM monitor and bootloader which deals with multiple 61 62 'images' in flash devices by putting a table one of the erase ··· 73 72 SA1100 map driver (CONFIG_MTD_SA1100) has an option for this, for 74 73 example. 75 74 75 + if MTD_REDBOOT_PARTS 76 + 76 77 config MTD_REDBOOT_DIRECTORY_BLOCK 77 78 int "Location of RedBoot partition table" 78 - depends on MTD_REDBOOT_PARTS 79 79 default "-1" 80 80 ---help--- 81 81 This option is the Linux counterpart to the ··· 93 91 94 92 config MTD_REDBOOT_PARTS_UNALLOCATED 95 93 bool "Include unallocated flash regions" 96 - depends on MTD_REDBOOT_PARTS 97 94 help 98 95 If you need to register each unallocated flash region as a MTD 99 96 'partition', enable this option. 100 97 101 98 config MTD_REDBOOT_PARTS_READONLY 102 99 bool "Force read-only for RedBoot system images" 103 - depends on MTD_REDBOOT_PARTS 104 100 help 105 101 If you need to force read-only for 'RedBoot', 'RedBoot Config' and 106 102 'FIS directory' images, enable this option. 103 + 104 + endif # MTD_REDBOOT_PARTS 107 105 108 106 config MTD_CMDLINE_PARTS 109 107 bool "Command line partition table parsing" ··· 144 142 145 143 config MTD_AFS_PARTS 146 144 tristate "ARM Firmware Suite partition parsing" 147 - depends on ARM && MTD_PARTITIONS 145 + depends on ARM 148 146 ---help--- 149 147 The ARM Firmware Suite allows the user to divide flash devices into 150 148 multiple 'images'. Each such image has a header containing its name ··· 160 158 example. 161 159 162 160 config MTD_OF_PARTS 163 - tristate "Flash partition map based on OF description" 164 - depends on OF && MTD_PARTITIONS 161 + def_bool y 162 + depends on OF 165 163 help 166 164 This provides a partition parsing function which derives 167 165 the partition map from the children of the flash node, ··· 169 167 170 168 config MTD_AR7_PARTS 171 169 tristate "TI AR7 partitioning support" 172 - depends on MTD_PARTITIONS 173 170 ---help--- 174 171 TI AR7 partitioning support 172 + 173 + endif # MTD_PARTITIONS 175 174 176 175 comment "User Modules And Translation Layers" 177 176
+1 -1
drivers/mtd/Makefile
··· 6 6 obj-$(CONFIG_MTD) += mtd.o 7 7 mtd-y := mtdcore.o mtdsuper.o 8 8 mtd-$(CONFIG_MTD_PARTITIONS) += mtdpart.o 9 + mtd-$(CONFIG_MTD_OF_PARTS) += ofpart.o 9 10 10 11 obj-$(CONFIG_MTD_CONCAT) += mtdconcat.o 11 12 obj-$(CONFIG_MTD_REDBOOT_PARTS) += redboot.o 12 13 obj-$(CONFIG_MTD_CMDLINE_PARTS) += cmdlinepart.o 13 14 obj-$(CONFIG_MTD_AFS_PARTS) += afs.o 14 15 obj-$(CONFIG_MTD_AR7_PARTS) += ar7part.o 15 - obj-$(CONFIG_MTD_OF_PARTS) += ofpart.o 16 16 17 17 # 'Users' - code which presents functionality to userspace. 18 18 obj-$(CONFIG_MTD_CHAR) += mtdchar.o
+28 -27
drivers/mtd/chips/cfi_cmdset_0001.c
··· 162 162 #endif 163 163 164 164 /* Atmel chips don't use the same PRI format as Intel chips */ 165 - static void fixup_convert_atmel_pri(struct mtd_info *mtd, void *param) 165 + static void fixup_convert_atmel_pri(struct mtd_info *mtd) 166 166 { 167 167 struct map_info *map = mtd->priv; 168 168 struct cfi_private *cfi = map->fldrv_priv; ··· 202 202 cfi->cfiq->BufWriteTimeoutMax = 0; 203 203 } 204 204 205 - static void fixup_at49bv640dx_lock(struct mtd_info *mtd, void *param) 205 + static void fixup_at49bv640dx_lock(struct mtd_info *mtd) 206 206 { 207 207 struct map_info *map = mtd->priv; 208 208 struct cfi_private *cfi = map->fldrv_priv; ··· 214 214 215 215 #ifdef CMDSET0001_DISABLE_ERASE_SUSPEND_ON_WRITE 216 216 /* Some Intel Strata Flash prior to FPO revision C has bugs in this area */ 217 - static void fixup_intel_strataflash(struct mtd_info *mtd, void* param) 217 + static void fixup_intel_strataflash(struct mtd_info *mtd) 218 218 { 219 219 struct map_info *map = mtd->priv; 220 220 struct cfi_private *cfi = map->fldrv_priv; ··· 227 227 #endif 228 228 229 229 #ifdef CMDSET0001_DISABLE_WRITE_SUSPEND 230 - static void fixup_no_write_suspend(struct mtd_info *mtd, void* param) 230 + static void fixup_no_write_suspend(struct mtd_info *mtd) 231 231 { 232 232 struct map_info *map = mtd->priv; 233 233 struct cfi_private *cfi = map->fldrv_priv; ··· 240 240 } 241 241 #endif 242 242 243 - static void fixup_st_m28w320ct(struct mtd_info *mtd, void* param) 243 + static void fixup_st_m28w320ct(struct mtd_info *mtd) 244 244 { 245 245 struct map_info *map = mtd->priv; 246 246 struct cfi_private *cfi = map->fldrv_priv; ··· 249 249 cfi->cfiq->BufWriteTimeoutMax = 0; /* Not supported */ 250 250 } 251 251 252 - static void fixup_st_m28w320cb(struct mtd_info *mtd, void* param) 252 + static void fixup_st_m28w320cb(struct mtd_info *mtd) 253 253 { 254 254 struct map_info *map = mtd->priv; 255 255 struct cfi_private *cfi = map->fldrv_priv; ··· 259 259 (cfi->cfiq->EraseRegionInfo[1] & 0xffff0000) | 0x3e; 260 260 }; 261 261 262 - static void fixup_use_point(struct mtd_info *mtd, void *param) 262 + static void fixup_use_point(struct mtd_info *mtd) 263 263 { 264 264 struct map_info *map = mtd->priv; 265 265 if (!mtd->point && map_is_linear(map)) { ··· 268 268 } 269 269 } 270 270 271 - static void fixup_use_write_buffers(struct mtd_info *mtd, void *param) 271 + static void fixup_use_write_buffers(struct mtd_info *mtd) 272 272 { 273 273 struct map_info *map = mtd->priv; 274 274 struct cfi_private *cfi = map->fldrv_priv; ··· 282 282 /* 283 283 * Some chips power-up with all sectors locked by default. 284 284 */ 285 - static void fixup_unlock_powerup_lock(struct mtd_info *mtd, void *param) 285 + static void fixup_unlock_powerup_lock(struct mtd_info *mtd) 286 286 { 287 287 struct map_info *map = mtd->priv; 288 288 struct cfi_private *cfi = map->fldrv_priv; ··· 295 295 } 296 296 297 297 static struct cfi_fixup cfi_fixup_table[] = { 298 - { CFI_MFR_ATMEL, CFI_ID_ANY, fixup_convert_atmel_pri, NULL }, 299 - { CFI_MFR_ATMEL, AT49BV640D, fixup_at49bv640dx_lock, NULL }, 300 - { CFI_MFR_ATMEL, AT49BV640DT, fixup_at49bv640dx_lock, NULL }, 298 + { CFI_MFR_ATMEL, CFI_ID_ANY, fixup_convert_atmel_pri }, 299 + { CFI_MFR_ATMEL, AT49BV640D, fixup_at49bv640dx_lock }, 300 + { CFI_MFR_ATMEL, AT49BV640DT, fixup_at49bv640dx_lock }, 301 301 #ifdef CMDSET0001_DISABLE_ERASE_SUSPEND_ON_WRITE 302 - { CFI_MFR_ANY, CFI_ID_ANY, fixup_intel_strataflash, NULL }, 302 + { CFI_MFR_ANY, CFI_ID_ANY, fixup_intel_strataflash }, 303 303 #endif 304 304 #ifdef CMDSET0001_DISABLE_WRITE_SUSPEND 305 - { CFI_MFR_ANY, CFI_ID_ANY, fixup_no_write_suspend, NULL }, 305 + { CFI_MFR_ANY, CFI_ID_ANY, fixup_no_write_suspend }, 306 306 #endif 307 307 #if !FORCE_WORD_WRITE 308 - { CFI_MFR_ANY, CFI_ID_ANY, fixup_use_write_buffers, NULL }, 308 + { CFI_MFR_ANY, CFI_ID_ANY, fixup_use_write_buffers }, 309 309 #endif 310 - { CFI_MFR_ST, 0x00ba, /* M28W320CT */ fixup_st_m28w320ct, NULL }, 311 - { CFI_MFR_ST, 0x00bb, /* M28W320CB */ fixup_st_m28w320cb, NULL }, 312 - { CFI_MFR_INTEL, CFI_ID_ANY, fixup_unlock_powerup_lock, NULL, }, 313 - { 0, 0, NULL, NULL } 310 + { CFI_MFR_ST, 0x00ba, /* M28W320CT */ fixup_st_m28w320ct }, 311 + { CFI_MFR_ST, 0x00bb, /* M28W320CB */ fixup_st_m28w320cb }, 312 + { CFI_MFR_INTEL, CFI_ID_ANY, fixup_unlock_powerup_lock }, 313 + { 0, 0, NULL } 314 314 }; 315 315 316 316 static struct cfi_fixup jedec_fixup_table[] = { 317 - { CFI_MFR_INTEL, I82802AB, fixup_use_fwh_lock, NULL, }, 318 - { CFI_MFR_INTEL, I82802AC, fixup_use_fwh_lock, NULL, }, 319 - { CFI_MFR_ST, M50LPW080, fixup_use_fwh_lock, NULL, }, 320 - { CFI_MFR_ST, M50FLW080A, fixup_use_fwh_lock, NULL, }, 321 - { CFI_MFR_ST, M50FLW080B, fixup_use_fwh_lock, NULL, }, 322 - { 0, 0, NULL, NULL } 317 + { CFI_MFR_INTEL, I82802AB, fixup_use_fwh_lock }, 318 + { CFI_MFR_INTEL, I82802AC, fixup_use_fwh_lock }, 319 + { CFI_MFR_ST, M50LPW080, fixup_use_fwh_lock }, 320 + { CFI_MFR_ST, M50FLW080A, fixup_use_fwh_lock }, 321 + { CFI_MFR_ST, M50FLW080B, fixup_use_fwh_lock }, 322 + { 0, 0, NULL } 323 323 }; 324 324 static struct cfi_fixup fixup_table[] = { 325 325 /* The CFI vendor ids and the JEDEC vendor IDs appear ··· 327 327 * well. This table is to pick all cases where 328 328 * we know that is the case. 329 329 */ 330 - { CFI_MFR_ANY, CFI_ID_ANY, fixup_use_point, NULL }, 331 - { 0, 0, NULL, NULL } 330 + { CFI_MFR_ANY, CFI_ID_ANY, fixup_use_point }, 331 + { 0, 0, NULL } 332 332 }; 333 333 334 334 static void cfi_fixup_major_minor(struct cfi_private *cfi, ··· 455 455 mtd->flags = MTD_CAP_NORFLASH; 456 456 mtd->name = map->name; 457 457 mtd->writesize = 1; 458 + mtd->writebufsize = 1 << cfi->cfiq->MaxBufWriteSize; 458 459 459 460 mtd->reboot_notifier.notifier_call = cfi_intelext_reboot; 460 461
+66 -50
drivers/mtd/chips/cfi_cmdset_0002.c
··· 134 134 135 135 #ifdef AMD_BOOTLOC_BUG 136 136 /* Wheee. Bring me the head of someone at AMD. */ 137 - static void fixup_amd_bootblock(struct mtd_info *mtd, void* param) 137 + static void fixup_amd_bootblock(struct mtd_info *mtd) 138 138 { 139 139 struct map_info *map = mtd->priv; 140 140 struct cfi_private *cfi = map->fldrv_priv; ··· 186 186 } 187 187 #endif 188 188 189 - static void fixup_use_write_buffers(struct mtd_info *mtd, void *param) 189 + static void fixup_use_write_buffers(struct mtd_info *mtd) 190 190 { 191 191 struct map_info *map = mtd->priv; 192 192 struct cfi_private *cfi = map->fldrv_priv; ··· 197 197 } 198 198 199 199 /* Atmel chips don't use the same PRI format as AMD chips */ 200 - static void fixup_convert_atmel_pri(struct mtd_info *mtd, void *param) 200 + static void fixup_convert_atmel_pri(struct mtd_info *mtd) 201 201 { 202 202 struct map_info *map = mtd->priv; 203 203 struct cfi_private *cfi = map->fldrv_priv; ··· 228 228 cfi->cfiq->BufWriteTimeoutMax = 0; 229 229 } 230 230 231 - static void fixup_use_secsi(struct mtd_info *mtd, void *param) 231 + static void fixup_use_secsi(struct mtd_info *mtd) 232 232 { 233 233 /* Setup for chips with a secsi area */ 234 234 mtd->read_user_prot_reg = cfi_amdstd_secsi_read; 235 235 mtd->read_fact_prot_reg = cfi_amdstd_secsi_read; 236 236 } 237 237 238 - static void fixup_use_erase_chip(struct mtd_info *mtd, void *param) 238 + static void fixup_use_erase_chip(struct mtd_info *mtd) 239 239 { 240 240 struct map_info *map = mtd->priv; 241 241 struct cfi_private *cfi = map->fldrv_priv; ··· 250 250 * Some Atmel chips (e.g. the AT49BV6416) power-up with all sectors 251 251 * locked by default. 252 252 */ 253 - static void fixup_use_atmel_lock(struct mtd_info *mtd, void *param) 253 + static void fixup_use_atmel_lock(struct mtd_info *mtd) 254 254 { 255 255 mtd->lock = cfi_atmel_lock; 256 256 mtd->unlock = cfi_atmel_unlock; ··· 271 271 cfi->cfiq->NumEraseRegions = 1; 272 272 } 273 273 274 - static void fixup_sst39vf(struct mtd_info *mtd, void *param) 274 + static void fixup_sst39vf(struct mtd_info *mtd) 275 275 { 276 276 struct map_info *map = mtd->priv; 277 277 struct cfi_private *cfi = map->fldrv_priv; ··· 282 282 cfi->addr_unlock2 = 0x2AAA; 283 283 } 284 284 285 - static void fixup_sst39vf_rev_b(struct mtd_info *mtd, void *param) 285 + static void fixup_sst39vf_rev_b(struct mtd_info *mtd) 286 286 { 287 287 struct map_info *map = mtd->priv; 288 288 struct cfi_private *cfi = map->fldrv_priv; ··· 295 295 cfi->sector_erase_cmd = CMD(0x50); 296 296 } 297 297 298 - static void fixup_sst38vf640x_sectorsize(struct mtd_info *mtd, void *param) 298 + static void fixup_sst38vf640x_sectorsize(struct mtd_info *mtd) 299 299 { 300 300 struct map_info *map = mtd->priv; 301 301 struct cfi_private *cfi = map->fldrv_priv; 302 302 303 - fixup_sst39vf_rev_b(mtd, param); 303 + fixup_sst39vf_rev_b(mtd); 304 304 305 305 /* 306 306 * CFI reports 1024 sectors (0x03ff+1) of 64KBytes (0x0100*256) where ··· 310 310 pr_warning("%s: Bad 38VF640x CFI data; adjusting sector size from 64 to 8KiB\n", mtd->name); 311 311 } 312 312 313 - static void fixup_s29gl064n_sectors(struct mtd_info *mtd, void *param) 313 + static void fixup_s29gl064n_sectors(struct mtd_info *mtd) 314 314 { 315 315 struct map_info *map = mtd->priv; 316 316 struct cfi_private *cfi = map->fldrv_priv; ··· 321 321 } 322 322 } 323 323 324 - static void fixup_s29gl032n_sectors(struct mtd_info *mtd, void *param) 324 + static void fixup_s29gl032n_sectors(struct mtd_info *mtd) 325 325 { 326 326 struct map_info *map = mtd->priv; 327 327 struct cfi_private *cfi = map->fldrv_priv; ··· 334 334 335 335 /* Used to fix CFI-Tables of chips without Extended Query Tables */ 336 336 static struct cfi_fixup cfi_nopri_fixup_table[] = { 337 - { CFI_MFR_SST, 0x234A, fixup_sst39vf, NULL, }, /* SST39VF1602 */ 338 - { CFI_MFR_SST, 0x234B, fixup_sst39vf, NULL, }, /* SST39VF1601 */ 339 - { CFI_MFR_SST, 0x235A, fixup_sst39vf, NULL, }, /* SST39VF3202 */ 340 - { CFI_MFR_SST, 0x235B, fixup_sst39vf, NULL, }, /* SST39VF3201 */ 341 - { CFI_MFR_SST, 0x235C, fixup_sst39vf_rev_b, NULL, }, /* SST39VF3202B */ 342 - { CFI_MFR_SST, 0x235D, fixup_sst39vf_rev_b, NULL, }, /* SST39VF3201B */ 343 - { CFI_MFR_SST, 0x236C, fixup_sst39vf_rev_b, NULL, }, /* SST39VF6402B */ 344 - { CFI_MFR_SST, 0x236D, fixup_sst39vf_rev_b, NULL, }, /* SST39VF6401B */ 345 - { 0, 0, NULL, NULL } 337 + { CFI_MFR_SST, 0x234a, fixup_sst39vf }, /* SST39VF1602 */ 338 + { CFI_MFR_SST, 0x234b, fixup_sst39vf }, /* SST39VF1601 */ 339 + { CFI_MFR_SST, 0x235a, fixup_sst39vf }, /* SST39VF3202 */ 340 + { CFI_MFR_SST, 0x235b, fixup_sst39vf }, /* SST39VF3201 */ 341 + { CFI_MFR_SST, 0x235c, fixup_sst39vf_rev_b }, /* SST39VF3202B */ 342 + { CFI_MFR_SST, 0x235d, fixup_sst39vf_rev_b }, /* SST39VF3201B */ 343 + { CFI_MFR_SST, 0x236c, fixup_sst39vf_rev_b }, /* SST39VF6402B */ 344 + { CFI_MFR_SST, 0x236d, fixup_sst39vf_rev_b }, /* SST39VF6401B */ 345 + { 0, 0, NULL } 346 346 }; 347 347 348 348 static struct cfi_fixup cfi_fixup_table[] = { 349 - { CFI_MFR_ATMEL, CFI_ID_ANY, fixup_convert_atmel_pri, NULL }, 349 + { CFI_MFR_ATMEL, CFI_ID_ANY, fixup_convert_atmel_pri }, 350 350 #ifdef AMD_BOOTLOC_BUG 351 - { CFI_MFR_AMD, CFI_ID_ANY, fixup_amd_bootblock, NULL }, 352 - { CFI_MFR_MACRONIX, CFI_ID_ANY, fixup_amd_bootblock, NULL }, 351 + { CFI_MFR_AMD, CFI_ID_ANY, fixup_amd_bootblock }, 352 + { CFI_MFR_MACRONIX, CFI_ID_ANY, fixup_amd_bootblock }, 353 353 #endif 354 - { CFI_MFR_AMD, 0x0050, fixup_use_secsi, NULL, }, 355 - { CFI_MFR_AMD, 0x0053, fixup_use_secsi, NULL, }, 356 - { CFI_MFR_AMD, 0x0055, fixup_use_secsi, NULL, }, 357 - { CFI_MFR_AMD, 0x0056, fixup_use_secsi, NULL, }, 358 - { CFI_MFR_AMD, 0x005C, fixup_use_secsi, NULL, }, 359 - { CFI_MFR_AMD, 0x005F, fixup_use_secsi, NULL, }, 360 - { CFI_MFR_AMD, 0x0c01, fixup_s29gl064n_sectors, NULL, }, 361 - { CFI_MFR_AMD, 0x1301, fixup_s29gl064n_sectors, NULL, }, 362 - { CFI_MFR_AMD, 0x1a00, fixup_s29gl032n_sectors, NULL, }, 363 - { CFI_MFR_AMD, 0x1a01, fixup_s29gl032n_sectors, NULL, }, 364 - { CFI_MFR_SST, 0x536A, fixup_sst38vf640x_sectorsize, NULL, }, /* SST38VF6402 */ 365 - { CFI_MFR_SST, 0x536B, fixup_sst38vf640x_sectorsize, NULL, }, /* SST38VF6401 */ 366 - { CFI_MFR_SST, 0x536C, fixup_sst38vf640x_sectorsize, NULL, }, /* SST38VF6404 */ 367 - { CFI_MFR_SST, 0x536D, fixup_sst38vf640x_sectorsize, NULL, }, /* SST38VF6403 */ 354 + { CFI_MFR_AMD, 0x0050, fixup_use_secsi }, 355 + { CFI_MFR_AMD, 0x0053, fixup_use_secsi }, 356 + { CFI_MFR_AMD, 0x0055, fixup_use_secsi }, 357 + { CFI_MFR_AMD, 0x0056, fixup_use_secsi }, 358 + { CFI_MFR_AMD, 0x005C, fixup_use_secsi }, 359 + { CFI_MFR_AMD, 0x005F, fixup_use_secsi }, 360 + { CFI_MFR_AMD, 0x0c01, fixup_s29gl064n_sectors }, 361 + { CFI_MFR_AMD, 0x1301, fixup_s29gl064n_sectors }, 362 + { CFI_MFR_AMD, 0x1a00, fixup_s29gl032n_sectors }, 363 + { CFI_MFR_AMD, 0x1a01, fixup_s29gl032n_sectors }, 364 + { CFI_MFR_SST, 0x536a, fixup_sst38vf640x_sectorsize }, /* SST38VF6402 */ 365 + { CFI_MFR_SST, 0x536b, fixup_sst38vf640x_sectorsize }, /* SST38VF6401 */ 366 + { CFI_MFR_SST, 0x536c, fixup_sst38vf640x_sectorsize }, /* SST38VF6404 */ 367 + { CFI_MFR_SST, 0x536d, fixup_sst38vf640x_sectorsize }, /* SST38VF6403 */ 368 368 #if !FORCE_WORD_WRITE 369 - { CFI_MFR_ANY, CFI_ID_ANY, fixup_use_write_buffers, NULL, }, 369 + { CFI_MFR_ANY, CFI_ID_ANY, fixup_use_write_buffers }, 370 370 #endif 371 - { 0, 0, NULL, NULL } 371 + { 0, 0, NULL } 372 372 }; 373 373 static struct cfi_fixup jedec_fixup_table[] = { 374 - { CFI_MFR_SST, SST49LF004B, fixup_use_fwh_lock, NULL, }, 375 - { CFI_MFR_SST, SST49LF040B, fixup_use_fwh_lock, NULL, }, 376 - { CFI_MFR_SST, SST49LF008A, fixup_use_fwh_lock, NULL, }, 377 - { 0, 0, NULL, NULL } 374 + { CFI_MFR_SST, SST49LF004B, fixup_use_fwh_lock }, 375 + { CFI_MFR_SST, SST49LF040B, fixup_use_fwh_lock }, 376 + { CFI_MFR_SST, SST49LF008A, fixup_use_fwh_lock }, 377 + { 0, 0, NULL } 378 378 }; 379 379 380 380 static struct cfi_fixup fixup_table[] = { ··· 383 383 * well. This table is to pick all cases where 384 384 * we know that is the case. 385 385 */ 386 - { CFI_MFR_ANY, CFI_ID_ANY, fixup_use_erase_chip, NULL }, 387 - { CFI_MFR_ATMEL, AT49BV6416, fixup_use_atmel_lock, NULL }, 388 - { 0, 0, NULL, NULL } 386 + { CFI_MFR_ANY, CFI_ID_ANY, fixup_use_erase_chip }, 387 + { CFI_MFR_ATMEL, AT49BV6416, fixup_use_atmel_lock }, 388 + { 0, 0, NULL } 389 389 }; 390 390 391 391 392 392 static void cfi_fixup_major_minor(struct cfi_private *cfi, 393 393 struct cfi_pri_amdstd *extp) 394 394 { 395 - if (cfi->mfr == CFI_MFR_SAMSUNG && cfi->id == 0x257e && 396 - extp->MajorVersion == '0') 397 - extp->MajorVersion = '1'; 395 + if (cfi->mfr == CFI_MFR_SAMSUNG) { 396 + if ((extp->MajorVersion == '0' && extp->MinorVersion == '0') || 397 + (extp->MajorVersion == '3' && extp->MinorVersion == '3')) { 398 + /* 399 + * Samsung K8P2815UQB and K8D6x16UxM chips 400 + * report major=0 / minor=0. 401 + * K8D3x16UxC chips report major=3 / minor=3. 402 + */ 403 + printk(KERN_NOTICE " Fixing Samsung's Amd/Fujitsu" 404 + " Extended Query version to 1.%c\n", 405 + extp->MinorVersion); 406 + extp->MajorVersion = '1'; 407 + } 408 + } 409 + 398 410 /* 399 411 * SST 38VF640x chips report major=0xFF / minor=0xFF. 400 412 */ ··· 440 428 mtd->flags = MTD_CAP_NORFLASH; 441 429 mtd->name = map->name; 442 430 mtd->writesize = 1; 431 + mtd->writebufsize = 1 << cfi->cfiq->MaxBufWriteSize; 432 + 433 + DEBUG(MTD_DEBUG_LEVEL3, "MTD %s(): write buffer size %d\n", 434 + __func__, mtd->writebufsize); 443 435 444 436 mtd->reboot_notifier.notifier_call = cfi_amdstd_reboot; 445 437
+1
drivers/mtd/chips/cfi_cmdset_0020.c
··· 238 238 mtd->resume = cfi_staa_resume; 239 239 mtd->flags = MTD_CAP_NORFLASH & ~MTD_BIT_WRITEABLE; 240 240 mtd->writesize = 8; /* FIXME: Should be 0 for STMicro flashes w/out ECC */ 241 + mtd->writebufsize = 1 << cfi->cfiq->MaxBufWriteSize; 241 242 map->fldrv = &cfi_staa_chipdrv; 242 243 __module_get(THIS_MODULE); 243 244 mtd->name = map->name;
+1 -1
drivers/mtd/chips/cfi_util.c
··· 156 156 for (f=fixups; f->fixup; f++) { 157 157 if (((f->mfr == CFI_MFR_ANY) || (f->mfr == cfi->mfr)) && 158 158 ((f->id == CFI_ID_ANY) || (f->id == cfi->id))) { 159 - f->fixup(mtd, f->param); 159 + f->fixup(mtd); 160 160 } 161 161 } 162 162 }
+1 -1
drivers/mtd/chips/fwh_lock.h
··· 98 98 return ret; 99 99 } 100 100 101 - static void fixup_use_fwh_lock(struct mtd_info *mtd, void *param) 101 + static void fixup_use_fwh_lock(struct mtd_info *mtd) 102 102 { 103 103 printk(KERN_NOTICE "using fwh lock/unlock method\n"); 104 104 /* Setup for the chips with the fwh lock method */
+35 -4
drivers/mtd/devices/m25p80.c
··· 51 51 #define OPCODE_WRDI 0x04 /* Write disable */ 52 52 #define OPCODE_AAI_WP 0xad /* Auto address increment word program */ 53 53 54 + /* Used for Macronix flashes only. */ 55 + #define OPCODE_EN4B 0xb7 /* Enter 4-byte mode */ 56 + #define OPCODE_EX4B 0xe9 /* Exit 4-byte mode */ 57 + 54 58 /* Status Register bits. */ 55 59 #define SR_WIP 1 /* Write in progress */ 56 60 #define SR_WEL 2 /* Write enable latch */ ··· 66 62 67 63 /* Define max times to check status register before we give up. */ 68 64 #define MAX_READY_WAIT_JIFFIES (40 * HZ) /* M25P16 specs 40s max chip erase */ 69 - #define MAX_CMD_SIZE 4 65 + #define MAX_CMD_SIZE 5 70 66 71 67 #ifdef CONFIG_M25PXX_USE_FAST_READ 72 68 #define OPCODE_READ OPCODE_FAST_READ ··· 156 152 } 157 153 158 154 /* 155 + * Enable/disable 4-byte addressing mode. 156 + */ 157 + static inline int set_4byte(struct m25p *flash, int enable) 158 + { 159 + u8 code = enable ? OPCODE_EN4B : OPCODE_EX4B; 160 + 161 + return spi_write_then_read(flash->spi, &code, 1, NULL, 0); 162 + } 163 + 164 + /* 159 165 * Service routine to read status register until ready, or timeout occurs. 160 166 * Returns non-zero if error. 161 167 */ ··· 221 207 cmd[1] = addr >> (flash->addr_width * 8 - 8); 222 208 cmd[2] = addr >> (flash->addr_width * 8 - 16); 223 209 cmd[3] = addr >> (flash->addr_width * 8 - 24); 210 + cmd[4] = addr >> (flash->addr_width * 8 - 32); 224 211 } 225 212 226 213 static int m25p_cmdsz(struct m25p *flash) ··· 497 482 size_t actual; 498 483 int cmd_sz, ret; 499 484 485 + DEBUG(MTD_DEBUG_LEVEL2, "%s: %s %s 0x%08x, len %zd\n", 486 + dev_name(&flash->spi->dev), __func__, "to", 487 + (u32)to, len); 488 + 500 489 *retlen = 0; 501 490 502 491 /* sanity checks */ ··· 626 607 .sector_size = (_sector_size), \ 627 608 .n_sectors = (_n_sectors), \ 628 609 .page_size = 256, \ 629 - .addr_width = 3, \ 630 610 .flags = (_flags), \ 631 611 }) 632 612 ··· 653 635 { "at26f004", INFO(0x1f0400, 0, 64 * 1024, 8, SECT_4K) }, 654 636 { "at26df081a", INFO(0x1f4501, 0, 64 * 1024, 16, SECT_4K) }, 655 637 { "at26df161a", INFO(0x1f4601, 0, 64 * 1024, 32, SECT_4K) }, 656 - { "at26df321", INFO(0x1f4701, 0, 64 * 1024, 64, SECT_4K) }, 638 + { "at26df321", INFO(0x1f4700, 0, 64 * 1024, 64, SECT_4K) }, 657 639 658 640 /* EON -- en25pxx */ 659 641 { "en25p32", INFO(0x1c2016, 0, 64 * 1024, 64, 0) }, ··· 671 653 { "mx25l6405d", INFO(0xc22017, 0, 64 * 1024, 128, 0) }, 672 654 { "mx25l12805d", INFO(0xc22018, 0, 64 * 1024, 256, 0) }, 673 655 { "mx25l12855e", INFO(0xc22618, 0, 64 * 1024, 256, 0) }, 656 + { "mx25l25635e", INFO(0xc22019, 0, 64 * 1024, 512, 0) }, 657 + { "mx25l25655e", INFO(0xc22619, 0, 64 * 1024, 512, 0) }, 674 658 675 659 /* Spansion -- single (large) sector size only, at least 676 660 * for the chips listed here (without boot sectors). ··· 784 764 return &m25p_ids[tmp]; 785 765 } 786 766 } 767 + dev_err(&spi->dev, "unrecognized JEDEC id %06x\n", jedec); 787 768 return ERR_PTR(-ENODEV); 788 769 } 789 770 ··· 904 883 905 884 flash->mtd.dev.parent = &spi->dev; 906 885 flash->page_size = info->page_size; 907 - flash->addr_width = info->addr_width; 886 + 887 + if (info->addr_width) 888 + flash->addr_width = info->addr_width; 889 + else { 890 + /* enable 4-byte addressing if the device exceeds 16MiB */ 891 + if (flash->mtd.size > 0x1000000) { 892 + flash->addr_width = 4; 893 + set_4byte(flash, 1); 894 + } else 895 + flash->addr_width = 3; 896 + } 908 897 909 898 dev_info(&spi->dev, "%s (%lld Kbytes)\n", id->name, 910 899 (long long)flash->mtd.size >> 10);
+2 -2
drivers/mtd/devices/sst25l.c
··· 335 335 return ret; 336 336 } 337 337 338 - static struct flash_info *__init sst25l_match_device(struct spi_device *spi) 338 + static struct flash_info *__devinit sst25l_match_device(struct spi_device *spi) 339 339 { 340 340 struct flash_info *flash_info = NULL; 341 341 struct spi_message m; ··· 375 375 return flash_info; 376 376 } 377 377 378 - static int __init sst25l_probe(struct spi_device *spi) 378 + static int __devinit sst25l_probe(struct spi_device *spi) 379 379 { 380 380 struct flash_info *flash_info; 381 381 struct sst25l_flash *flash;
+2 -5
drivers/mtd/maps/amd76xrom.c
··· 149 149 if (request_resource(&iomem_resource, &window->rsrc)) { 150 150 window->rsrc.parent = NULL; 151 151 printk(KERN_ERR MOD_NAME 152 - " %s(): Unable to register resource" 153 - " 0x%.16llx-0x%.16llx - kernel bug?\n", 154 - __func__, 155 - (unsigned long long)window->rsrc.start, 156 - (unsigned long long)window->rsrc.end); 152 + " %s(): Unable to register resource %pR - kernel bug?\n", 153 + __func__, &window->rsrc); 157 154 } 158 155 159 156
+5
drivers/mtd/maps/bcm963xx-flash.c
··· 196 196 bcm963xx_mtd_info = do_map_probe("cfi_probe", &bcm963xx_map); 197 197 if (!bcm963xx_mtd_info) { 198 198 dev_err(&pdev->dev, "failed to probe using CFI\n"); 199 + bcm963xx_mtd_info = do_map_probe("jedec_probe", &bcm963xx_map); 200 + if (bcm963xx_mtd_info) 201 + goto probe_ok; 202 + dev_err(&pdev->dev, "failed to probe using JEDEC\n"); 199 203 err = -EIO; 200 204 goto err_probe; 201 205 } 202 206 207 + probe_ok: 203 208 bcm963xx_mtd_info->owner = THIS_MODULE; 204 209 205 210 /* This is mutually exclusive */
+2 -5
drivers/mtd/maps/ck804xrom.c
··· 178 178 if (request_resource(&iomem_resource, &window->rsrc)) { 179 179 window->rsrc.parent = NULL; 180 180 printk(KERN_ERR MOD_NAME 181 - " %s(): Unable to register resource" 182 - " 0x%.016llx-0x%.016llx - kernel bug?\n", 183 - __func__, 184 - (unsigned long long)window->rsrc.start, 185 - (unsigned long long)window->rsrc.end); 181 + " %s(): Unable to register resource %pR - kernel bug?\n", 182 + __func__, &window->rsrc); 186 183 } 187 184 188 185
+3 -6
drivers/mtd/maps/esb2rom.c
··· 242 242 window->rsrc.flags = IORESOURCE_MEM | IORESOURCE_BUSY; 243 243 if (request_resource(&iomem_resource, &window->rsrc)) { 244 244 window->rsrc.parent = NULL; 245 - printk(KERN_DEBUG MOD_NAME 246 - ": %s(): Unable to register resource" 247 - " 0x%.08llx-0x%.08llx - kernel bug?\n", 248 - __func__, 249 - (unsigned long long)window->rsrc.start, 250 - (unsigned long long)window->rsrc.end); 245 + printk(KERN_DEBUG MOD_NAME ": " 246 + "%s(): Unable to register resource %pR - kernel bug?\n", 247 + __func__, &window->rsrc); 251 248 } 252 249 253 250 /* Map the firmware hub into my address space. */
+3 -6
drivers/mtd/maps/ichxrom.c
··· 175 175 window->rsrc.flags = IORESOURCE_MEM | IORESOURCE_BUSY; 176 176 if (request_resource(&iomem_resource, &window->rsrc)) { 177 177 window->rsrc.parent = NULL; 178 - printk(KERN_DEBUG MOD_NAME 179 - ": %s(): Unable to register resource" 180 - " 0x%.16llx-0x%.16llx - kernel bug?\n", 181 - __func__, 182 - (unsigned long long)window->rsrc.start, 183 - (unsigned long long)window->rsrc.end); 178 + printk(KERN_DEBUG MOD_NAME ": " 179 + "%s(): Unable to register resource %pR - kernel bug?\n", 180 + __func__, &window->rsrc); 184 181 } 185 182 186 183 /* Map the firmware hub into my address space. */
+1 -3
drivers/mtd/maps/physmap_of.c
··· 274 274 continue; 275 275 } 276 276 277 - dev_dbg(&dev->dev, "of_flash device: %.8llx-%.8llx\n", 278 - (unsigned long long)res.start, 279 - (unsigned long long)res.end); 277 + dev_dbg(&dev->dev, "of_flash device: %pR\n", &res); 280 278 281 279 err = -EBUSY; 282 280 res_size = resource_size(&res);
+2 -3
drivers/mtd/maps/scx200_docflash.c
··· 166 166 outl(pmr, scx200_cb_base + SCx200_PMR); 167 167 } 168 168 169 - printk(KERN_INFO NAME ": DOCCS mapped at 0x%llx-0x%llx, width %d\n", 170 - (unsigned long long)docmem.start, 171 - (unsigned long long)docmem.end, width); 169 + printk(KERN_INFO NAME ": DOCCS mapped at %pR, width %d\n", 170 + &docmem, width); 172 171 173 172 scx200_docflash_map.size = size; 174 173 if (width == 8)
+1 -1
drivers/mtd/maps/tqm8xxl.c
··· 139 139 goto error_mem; 140 140 } 141 141 142 - map_banks[idx]->name = (char *)kmalloc(16, GFP_KERNEL); 142 + map_banks[idx]->name = kmalloc(16, GFP_KERNEL); 143 143 144 144 if (!map_banks[idx]->name) { 145 145 ret = -ENOMEM;
+5 -5
drivers/mtd/mtdchar.c
··· 522 522 if (!capable(CAP_SYS_ADMIN)) 523 523 return -EPERM; 524 524 525 - /* Only master mtd device must be used to control partitions */ 526 - if (!mtd_is_master(mtd)) 527 - return -EINVAL; 528 - 529 525 if (copy_from_user(&a, arg, sizeof(struct blkpg_ioctl_arg))) 530 526 return -EFAULT; 531 527 ··· 530 534 531 535 switch (a.op) { 532 536 case BLKPG_ADD_PARTITION: 537 + 538 + /* Only master mtd device must be used to add partitions */ 539 + if (mtd_is_partition(mtd)) 540 + return -EINVAL; 533 541 534 542 return mtd_add_partition(mtd, p.devname, p.start, p.length); 535 543 ··· 601 601 } 602 602 603 603 case MEMGETINFO: 604 + memset(&info, 0, sizeof(info)); 604 605 info.type = mtd->type; 605 606 info.flags = mtd->flags; 606 607 info.size = mtd->size; ··· 610 609 info.oobsize = mtd->oobsize; 611 610 /* The below fields are obsolete */ 612 611 info.ecctype = -1; 613 - info.eccsize = 0; 614 612 if (copy_to_user(argp, &info, sizeof(struct mtd_info_user))) 615 613 return -EFAULT; 616 614 break;
+1
drivers/mtd/mtdconcat.c
··· 776 776 concat->mtd.size = subdev[0]->size; 777 777 concat->mtd.erasesize = subdev[0]->erasesize; 778 778 concat->mtd.writesize = subdev[0]->writesize; 779 + concat->mtd.writebufsize = subdev[0]->writebufsize; 779 780 concat->mtd.subpage_sft = subdev[0]->subpage_sft; 780 781 concat->mtd.oobsize = subdev[0]->oobsize; 781 782 concat->mtd.oobavail = subdev[0]->oobavail;
+2 -1
drivers/mtd/mtdoops.c
··· 401 401 printk(KERN_WARNING "mtdoops: could not unregister kmsg_dumper\n"); 402 402 403 403 cxt->mtd = NULL; 404 - flush_scheduled_work(); 404 + flush_work_sync(&cxt->work_erase); 405 + flush_work_sync(&cxt->work_write); 405 406 } 406 407 407 408
+24 -6
drivers/mtd/mtdpart.c
··· 120 120 return -EINVAL; 121 121 if (ops->datbuf && from + ops->len > mtd->size) 122 122 return -EINVAL; 123 - res = part->master->read_oob(part->master, from + part->offset, ops); 124 123 124 + /* 125 + * If OOB is also requested, make sure that we do not read past the end 126 + * of this partition. 127 + */ 128 + if (ops->oobbuf) { 129 + size_t len, pages; 130 + 131 + if (ops->mode == MTD_OOB_AUTO) 132 + len = mtd->oobavail; 133 + else 134 + len = mtd->oobsize; 135 + pages = mtd_div_by_ws(mtd->size, mtd); 136 + pages -= mtd_div_by_ws(from, mtd); 137 + if (ops->ooboffs + ops->ooblen > pages * len) 138 + return -EINVAL; 139 + } 140 + 141 + res = part->master->read_oob(part->master, from + part->offset, ops); 125 142 if (unlikely(res)) { 126 143 if (res == -EUCLEAN) 127 144 mtd->ecc_stats.corrected++; ··· 401 384 slave->mtd.flags = master->flags & ~part->mask_flags; 402 385 slave->mtd.size = part->size; 403 386 slave->mtd.writesize = master->writesize; 387 + slave->mtd.writebufsize = master->writebufsize; 404 388 slave->mtd.oobsize = master->oobsize; 405 389 slave->mtd.oobavail = master->oobavail; 406 390 slave->mtd.subpage_sft = master->subpage_sft; ··· 738 720 } 739 721 EXPORT_SYMBOL_GPL(parse_mtd_partitions); 740 722 741 - int mtd_is_master(struct mtd_info *mtd) 723 + int mtd_is_partition(struct mtd_info *mtd) 742 724 { 743 725 struct mtd_part *part; 744 - int nopart = 0; 726 + int ispart = 0; 745 727 746 728 mutex_lock(&mtd_partitions_mutex); 747 729 list_for_each_entry(part, &mtd_partitions, list) 748 730 if (&part->mtd == mtd) { 749 - nopart = 1; 731 + ispart = 1; 750 732 break; 751 733 } 752 734 mutex_unlock(&mtd_partitions_mutex); 753 735 754 - return nopart; 736 + return ispart; 755 737 } 756 - EXPORT_SYMBOL_GPL(mtd_is_master); 738 + EXPORT_SYMBOL_GPL(mtd_is_partition);
+1
drivers/mtd/nand/Kconfig
··· 96 96 config MTD_NAND_AMS_DELTA 97 97 tristate "NAND Flash device on Amstrad E3" 98 98 depends on MACH_AMS_DELTA 99 + default y 99 100 help 100 101 Support for NAND flash on Amstrad E3 (Delta). 101 102
+69 -11
drivers/mtd/nand/ams-delta.c
··· 4 4 * Copyright (C) 2006 Jonathan McDowell <noodles@earth.li> 5 5 * 6 6 * Derived from drivers/mtd/toto.c 7 + * Converted to platform driver by Janusz Krzysztofik <jkrzyszt@tis.icnet.pl> 8 + * Partially stolen from drivers/mtd/nand/plat_nand.c 7 9 * 8 10 * This program is free software; you can redistribute it and/or modify 9 11 * it under the terms of the GNU General Public License version 2 as ··· 64 62 static void ams_delta_write_byte(struct mtd_info *mtd, u_char byte) 65 63 { 66 64 struct nand_chip *this = mtd->priv; 65 + void __iomem *io_base = this->priv; 67 66 68 - omap_writew(0, (OMAP1_MPUIO_BASE + OMAP_MPUIO_IO_CNTL)); 69 - omap_writew(byte, this->IO_ADDR_W); 67 + writew(0, io_base + OMAP_MPUIO_IO_CNTL); 68 + writew(byte, this->IO_ADDR_W); 70 69 ams_delta_latch2_write(AMS_DELTA_LATCH2_NAND_NWE, 0); 71 70 ndelay(40); 72 71 ams_delta_latch2_write(AMS_DELTA_LATCH2_NAND_NWE, ··· 78 75 { 79 76 u_char res; 80 77 struct nand_chip *this = mtd->priv; 78 + void __iomem *io_base = this->priv; 81 79 82 80 ams_delta_latch2_write(AMS_DELTA_LATCH2_NAND_NRE, 0); 83 81 ndelay(40); 84 - omap_writew(~0, (OMAP1_MPUIO_BASE + OMAP_MPUIO_IO_CNTL)); 85 - res = omap_readw(this->IO_ADDR_R); 82 + writew(~0, io_base + OMAP_MPUIO_IO_CNTL); 83 + res = readw(this->IO_ADDR_R); 86 84 ams_delta_latch2_write(AMS_DELTA_LATCH2_NAND_NRE, 87 85 AMS_DELTA_LATCH2_NAND_NRE); 88 86 ··· 155 151 /* 156 152 * Main initialization routine 157 153 */ 158 - static int __init ams_delta_init(void) 154 + static int __devinit ams_delta_init(struct platform_device *pdev) 159 155 { 160 156 struct nand_chip *this; 157 + struct resource *res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 158 + void __iomem *io_base; 161 159 int err = 0; 160 + 161 + if (!res) 162 + return -ENXIO; 162 163 163 164 /* Allocate memory for MTD device structure and private data */ 164 165 ams_delta_mtd = kmalloc(sizeof(struct mtd_info) + ··· 186 177 /* Link the private data with the MTD structure */ 187 178 ams_delta_mtd->priv = this; 188 179 180 + if (!request_mem_region(res->start, resource_size(res), 181 + dev_name(&pdev->dev))) { 182 + dev_err(&pdev->dev, "request_mem_region failed\n"); 183 + err = -EBUSY; 184 + goto out_free; 185 + } 186 + 187 + io_base = ioremap(res->start, resource_size(res)); 188 + if (io_base == NULL) { 189 + dev_err(&pdev->dev, "ioremap failed\n"); 190 + err = -EIO; 191 + goto out_release_io; 192 + } 193 + 194 + this->priv = io_base; 195 + 189 196 /* Set address of NAND IO lines */ 190 - this->IO_ADDR_R = (OMAP1_MPUIO_BASE + OMAP_MPUIO_INPUT_LATCH); 191 - this->IO_ADDR_W = (OMAP1_MPUIO_BASE + OMAP_MPUIO_OUTPUT); 197 + this->IO_ADDR_R = io_base + OMAP_MPUIO_INPUT_LATCH; 198 + this->IO_ADDR_W = io_base + OMAP_MPUIO_OUTPUT; 192 199 this->read_byte = ams_delta_read_byte; 193 200 this->write_buf = ams_delta_write_buf; 194 201 this->read_buf = ams_delta_read_buf; ··· 219 194 /* 25 us command delay time */ 220 195 this->chip_delay = 30; 221 196 this->ecc.mode = NAND_ECC_SOFT; 197 + 198 + platform_set_drvdata(pdev, io_base); 222 199 223 200 /* Set chip enabled, but */ 224 201 ams_delta_latch2_write(NAND_MASK, AMS_DELTA_LATCH2_NAND_NRE | ··· 241 214 goto out; 242 215 243 216 out_mtd: 217 + platform_set_drvdata(pdev, NULL); 218 + iounmap(io_base); 219 + out_release_io: 220 + release_mem_region(res->start, resource_size(res)); 221 + out_free: 244 222 kfree(ams_delta_mtd); 245 223 out: 246 224 return err; 247 225 } 248 226 249 - module_init(ams_delta_init); 250 - 251 227 /* 252 228 * Clean up routine 253 229 */ 254 - static void __exit ams_delta_cleanup(void) 230 + static int __devexit ams_delta_cleanup(struct platform_device *pdev) 255 231 { 232 + void __iomem *io_base = platform_get_drvdata(pdev); 233 + struct resource *res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 234 + 256 235 /* Release resources, unregister device */ 257 236 nand_release(ams_delta_mtd); 258 237 238 + iounmap(io_base); 239 + release_mem_region(res->start, resource_size(res)); 240 + 259 241 /* Free the MTD device structure */ 260 242 kfree(ams_delta_mtd); 243 + 244 + return 0; 261 245 } 262 - module_exit(ams_delta_cleanup); 246 + 247 + static struct platform_driver ams_delta_nand_driver = { 248 + .probe = ams_delta_init, 249 + .remove = __devexit_p(ams_delta_cleanup), 250 + .driver = { 251 + .name = "ams-delta-nand", 252 + .owner = THIS_MODULE, 253 + }, 254 + }; 255 + 256 + static int __init ams_delta_nand_init(void) 257 + { 258 + return platform_driver_register(&ams_delta_nand_driver); 259 + } 260 + module_init(ams_delta_nand_init); 261 + 262 + static void __exit ams_delta_nand_exit(void) 263 + { 264 + platform_driver_unregister(&ams_delta_nand_driver); 265 + } 266 + module_exit(ams_delta_nand_exit); 263 267 264 268 MODULE_LICENSE("GPL"); 265 269 MODULE_AUTHOR("Jonathan McDowell <noodles@earth.li>");
+2
drivers/mtd/nand/fsl_elbc_nand.c
··· 388 388 "page_addr: 0x%x, column: 0x%x.\n", 389 389 page_addr, column); 390 390 391 + elbc_fcm_ctrl->column = column; 392 + elbc_fcm_ctrl->oob = 0; 391 393 elbc_fcm_ctrl->use_mdr = 1; 392 394 393 395 fcr = (NAND_CMD_STATUS << FCR_CMD1_SHIFT) |
+68 -21
drivers/mtd/nand/fsmc_nand.c
··· 31 31 #include <linux/io.h> 32 32 #include <linux/slab.h> 33 33 #include <linux/mtd/fsmc.h> 34 + #include <linux/amba/bus.h> 34 35 #include <mtd/mtd-abi.h> 35 36 36 37 static struct nand_ecclayout fsmc_ecc1_layout = { ··· 120 119 } 121 120 }; 122 121 122 + 123 + #ifdef CONFIG_MTD_PARTITIONS 123 124 /* 124 125 * Default partition tables to be used if the partition information not 125 - * provided through platform data 126 - */ 127 - #define PARTITION(n, off, sz) {.name = n, .offset = off, .size = sz} 128 - 129 - /* 126 + * provided through platform data. 127 + * 130 128 * Default partition layout for small page(= 512 bytes) devices 131 129 * Size for "Root file system" is updated in driver based on actual device size 132 130 */ 133 131 static struct mtd_partition partition_info_16KB_blk[] = { 134 - PARTITION("X-loader", 0, 4 * 0x4000), 135 - PARTITION("U-Boot", 0x10000, 20 * 0x4000), 136 - PARTITION("Kernel", 0x60000, 256 * 0x4000), 137 - PARTITION("Root File System", 0x460000, 0), 132 + { 133 + .name = "X-loader", 134 + .offset = 0, 135 + .size = 4*0x4000, 136 + }, 137 + { 138 + .name = "U-Boot", 139 + .offset = 0x10000, 140 + .size = 20*0x4000, 141 + }, 142 + { 143 + .name = "Kernel", 144 + .offset = 0x60000, 145 + .size = 256*0x4000, 146 + }, 147 + { 148 + .name = "Root File System", 149 + .offset = 0x460000, 150 + .size = 0, 151 + }, 138 152 }; 139 153 140 154 /* ··· 157 141 * Size for "Root file system" is updated in driver based on actual device size 158 142 */ 159 143 static struct mtd_partition partition_info_128KB_blk[] = { 160 - PARTITION("X-loader", 0, 4 * 0x20000), 161 - PARTITION("U-Boot", 0x80000, 12 * 0x20000), 162 - PARTITION("Kernel", 0x200000, 48 * 0x20000), 163 - PARTITION("Root File System", 0x800000, 0), 144 + { 145 + .name = "X-loader", 146 + .offset = 0, 147 + .size = 4*0x20000, 148 + }, 149 + { 150 + .name = "U-Boot", 151 + .offset = 0x80000, 152 + .size = 12*0x20000, 153 + }, 154 + { 155 + .name = "Kernel", 156 + .offset = 0x200000, 157 + .size = 48*0x20000, 158 + }, 159 + { 160 + .name = "Root File System", 161 + .offset = 0x800000, 162 + .size = 0, 163 + }, 164 164 }; 165 165 166 166 #ifdef CONFIG_MTD_CMDLINE_PARTS 167 167 const char *part_probes[] = { "cmdlinepart", NULL }; 168 168 #endif 169 + #endif 169 170 170 171 /** 171 - * struct fsmc_nand_data - atructure for FSMC NAND device state 172 + * struct fsmc_nand_data - structure for FSMC NAND device state 172 173 * 174 + * @pid: Part ID on the AMBA PrimeCell format 173 175 * @mtd: MTD info for a NAND flash. 174 176 * @nand: Chip related info for a NAND flash. 175 177 * @partitions: Partition info for a NAND Flash. ··· 203 169 * @regs_va: FSMC regs base address. 204 170 */ 205 171 struct fsmc_nand_data { 172 + u32 pid; 206 173 struct mtd_info mtd; 207 174 struct nand_chip nand; 208 175 struct mtd_partition *partitions; ··· 543 508 struct nand_chip *nand; 544 509 struct fsmc_regs *regs; 545 510 struct resource *res; 546 - int nr_parts, ret = 0; 511 + int ret = 0; 512 + u32 pid; 513 + int i; 547 514 548 515 if (!pdata) { 549 516 dev_err(&pdev->dev, "platform data is NULL\n"); ··· 635 598 if (ret) 636 599 goto err_probe1; 637 600 601 + /* 602 + * This device ID is actually a common AMBA ID as used on the 603 + * AMBA PrimeCell bus. However it is not a PrimeCell. 604 + */ 605 + for (pid = 0, i = 0; i < 4; i++) 606 + pid |= (readl(host->regs_va + resource_size(res) - 0x20 + 4 * i) & 255) << (i * 8); 607 + host->pid = pid; 608 + dev_info(&pdev->dev, "FSMC device partno %03x, manufacturer %02x, " 609 + "revision %02x, config %02x\n", 610 + AMBA_PART_BITS(pid), AMBA_MANF_BITS(pid), 611 + AMBA_REV_BITS(pid), AMBA_CONFIG_BITS(pid)); 612 + 638 613 host->bank = pdata->bank; 639 614 host->select_chip = pdata->select_bank; 640 615 regs = host->regs_va; ··· 674 625 675 626 fsmc_nand_setup(regs, host->bank, nand->options & NAND_BUSWIDTH_16); 676 627 677 - if (get_fsmc_version(host->regs_va) == FSMC_VER8) { 628 + if (AMBA_REV_BITS(host->pid) >= 8) { 678 629 nand->ecc.read_page = fsmc_read_page_hwecc; 679 630 nand->ecc.calculate = fsmc_read_hwecc_ecc4; 680 631 nand->ecc.correct = fsmc_correct_data; ··· 694 645 goto err_probe; 695 646 } 696 647 697 - if (get_fsmc_version(host->regs_va) == FSMC_VER8) { 648 + if (AMBA_REV_BITS(host->pid) >= 8) { 698 649 if (host->mtd.writesize == 512) { 699 650 nand->ecc.layout = &fsmc_ecc4_sp_layout; 700 651 host->ecc_place = &fsmc_ecc4_sp_place; ··· 725 676 * Check if partition info passed via command line 726 677 */ 727 678 host->mtd.name = "nand"; 728 - nr_parts = parse_mtd_partitions(&host->mtd, part_probes, 679 + host->nr_partitions = parse_mtd_partitions(&host->mtd, part_probes, 729 680 &host->partitions, 0); 730 - if (nr_parts > 0) { 731 - host->nr_partitions = nr_parts; 732 - } else { 681 + if (host->nr_partitions <= 0) { 733 682 #endif 734 683 /* 735 684 * Check if partition info passed via command line
+1 -56
drivers/mtd/nand/jz4740_nand.c
··· 251 251 return 0; 252 252 } 253 253 254 - 255 - /* Copy paste of nand_read_page_hwecc_oob_first except for different eccpos 256 - * handling. The ecc area is for 4k chips 72 bytes long and thus does not fit 257 - * into the eccpos array. */ 258 - static int jz_nand_read_page_hwecc_oob_first(struct mtd_info *mtd, 259 - struct nand_chip *chip, uint8_t *buf, int page) 260 - { 261 - int i, eccsize = chip->ecc.size; 262 - int eccbytes = chip->ecc.bytes; 263 - int eccsteps = chip->ecc.steps; 264 - uint8_t *p = buf; 265 - unsigned int ecc_offset = chip->page_shift; 266 - 267 - /* Read the OOB area first */ 268 - chip->cmdfunc(mtd, NAND_CMD_READOOB, 0, page); 269 - chip->read_buf(mtd, chip->oob_poi, mtd->oobsize); 270 - chip->cmdfunc(mtd, NAND_CMD_READ0, 0, page); 271 - 272 - for (i = ecc_offset; eccsteps; eccsteps--, i += eccbytes, p += eccsize) { 273 - int stat; 274 - 275 - chip->ecc.hwctl(mtd, NAND_ECC_READ); 276 - chip->read_buf(mtd, p, eccsize); 277 - 278 - stat = chip->ecc.correct(mtd, p, &chip->oob_poi[i], NULL); 279 - if (stat < 0) 280 - mtd->ecc_stats.failed++; 281 - else 282 - mtd->ecc_stats.corrected += stat; 283 - } 284 - return 0; 285 - } 286 - 287 - /* Copy-and-paste of nand_write_page_hwecc with different eccpos handling. */ 288 - static void jz_nand_write_page_hwecc(struct mtd_info *mtd, 289 - struct nand_chip *chip, const uint8_t *buf) 290 - { 291 - int i, eccsize = chip->ecc.size; 292 - int eccbytes = chip->ecc.bytes; 293 - int eccsteps = chip->ecc.steps; 294 - const uint8_t *p = buf; 295 - unsigned int ecc_offset = chip->page_shift; 296 - 297 - for (i = ecc_offset; eccsteps; eccsteps--, i += eccbytes, p += eccsize) { 298 - chip->ecc.hwctl(mtd, NAND_ECC_WRITE); 299 - chip->write_buf(mtd, p, eccsize); 300 - chip->ecc.calculate(mtd, p, &chip->oob_poi[i]); 301 - } 302 - 303 - chip->write_buf(mtd, chip->oob_poi, mtd->oobsize); 304 - } 305 - 306 254 #ifdef CONFIG_MTD_CMDLINE_PARTS 307 255 static const char *part_probes[] = {"cmdline", NULL}; 308 256 #endif ··· 340 392 chip->ecc.mode = NAND_ECC_HW_OOB_FIRST; 341 393 chip->ecc.size = 512; 342 394 chip->ecc.bytes = 9; 343 - 344 - chip->ecc.read_page = jz_nand_read_page_hwecc_oob_first; 345 - chip->ecc.write_page = jz_nand_write_page_hwecc; 346 395 347 396 if (pdata) 348 397 chip->ecc.layout = pdata->ecc_layout; ··· 434 489 return 0; 435 490 } 436 491 437 - struct platform_driver jz_nand_driver = { 492 + static struct platform_driver jz_nand_driver = { 438 493 .probe = jz_nand_probe, 439 494 .remove = __devexit_p(jz_nand_remove), 440 495 .driver = {
+1 -1
drivers/mtd/nand/mxc_nand.c
··· 1009 1009 struct mxc_nand_platform_data *pdata = pdev->dev.platform_data; 1010 1010 struct mxc_nand_host *host; 1011 1011 struct resource *res; 1012 - int err = 0, nr_parts = 0; 1012 + int err = 0, __maybe_unused nr_parts = 0; 1013 1013 struct nand_ecclayout *oob_smallpage, *oob_largepage; 1014 1014 1015 1015 /* Allocate memory for MTD device structure and private data */
+15 -10
drivers/mtd/nand/nand_base.c
··· 2865 2865 2866 2866 /* check version */ 2867 2867 val = le16_to_cpu(p->revision); 2868 - if (val == 1 || val > (1 << 4)) { 2869 - printk(KERN_INFO "%s: unsupported ONFI version: %d\n", 2870 - __func__, val); 2871 - return 0; 2872 - } 2873 - 2874 - if (val & (1 << 4)) 2868 + if (val & (1 << 5)) 2869 + chip->onfi_version = 23; 2870 + else if (val & (1 << 4)) 2875 2871 chip->onfi_version = 22; 2876 2872 else if (val & (1 << 3)) 2877 2873 chip->onfi_version = 21; 2878 2874 else if (val & (1 << 2)) 2879 2875 chip->onfi_version = 20; 2880 - else 2876 + else if (val & (1 << 1)) 2881 2877 chip->onfi_version = 10; 2878 + else 2879 + chip->onfi_version = 0; 2880 + 2881 + if (!chip->onfi_version) { 2882 + printk(KERN_INFO "%s: unsupported ONFI version: %d\n", 2883 + __func__, val); 2884 + return 0; 2885 + } 2882 2886 2883 2887 sanitize_string(p->manufacturer, sizeof(p->manufacturer)); 2884 2888 sanitize_string(p->model, sizeof(p->model)); ··· 2891 2887 mtd->writesize = le32_to_cpu(p->byte_per_page); 2892 2888 mtd->erasesize = le32_to_cpu(p->pages_per_block) * mtd->writesize; 2893 2889 mtd->oobsize = le16_to_cpu(p->spare_bytes_per_page); 2894 - chip->chipsize = le32_to_cpu(p->blocks_per_lun) * mtd->erasesize; 2890 + chip->chipsize = (uint64_t)le32_to_cpu(p->blocks_per_lun) * mtd->erasesize; 2895 2891 busw = 0; 2896 2892 if (le16_to_cpu(p->features) & 1) 2897 2893 busw = NAND_BUSWIDTH_16; ··· 3161 3157 printk(KERN_INFO "NAND device: Manufacturer ID:" 3162 3158 " 0x%02x, Chip ID: 0x%02x (%s %s)\n", *maf_id, *dev_id, 3163 3159 nand_manuf_ids[maf_idx].name, 3164 - chip->onfi_version ? type->name : chip->onfi_params.model); 3160 + chip->onfi_version ? chip->onfi_params.model : type->name); 3165 3161 3166 3162 return type; 3167 3163 } ··· 3439 3435 mtd->resume = nand_resume; 3440 3436 mtd->block_isbad = nand_block_isbad; 3441 3437 mtd->block_markbad = nand_block_markbad; 3438 + mtd->writebufsize = mtd->writesize; 3442 3439 3443 3440 /* propagate ecc.layout to mtd_info */ 3444 3441 mtd->ecclayout = chip->ecc.layout;
+2 -1
drivers/mtd/nand/nand_bbt.c
··· 1092 1092 1093 1093 /** 1094 1094 * verify_bbt_descr - verify the bad block description 1095 - * @bd: the table to verify 1095 + * @mtd: MTD device structure 1096 + * @bd: the table to verify 1096 1097 * 1097 1098 * This functions performs a few sanity checks on the bad block description 1098 1099 * table.
+19 -20
drivers/mtd/nand/nandsim.c
··· 210 210 #define STATE_CMD_READ0 0x00000001 /* read data from the beginning of page */ 211 211 #define STATE_CMD_READ1 0x00000002 /* read data from the second half of page */ 212 212 #define STATE_CMD_READSTART 0x00000003 /* read data second command (large page devices) */ 213 - #define STATE_CMD_PAGEPROG 0x00000004 /* start page programm */ 213 + #define STATE_CMD_PAGEPROG 0x00000004 /* start page program */ 214 214 #define STATE_CMD_READOOB 0x00000005 /* read OOB area */ 215 215 #define STATE_CMD_ERASE1 0x00000006 /* sector erase first command */ 216 216 #define STATE_CMD_STATUS 0x00000007 /* read status */ 217 217 #define STATE_CMD_STATUS_M 0x00000008 /* read multi-plane status (isn't implemented) */ 218 - #define STATE_CMD_SEQIN 0x00000009 /* sequential data imput */ 218 + #define STATE_CMD_SEQIN 0x00000009 /* sequential data input */ 219 219 #define STATE_CMD_READID 0x0000000A /* read ID */ 220 220 #define STATE_CMD_ERASE2 0x0000000B /* sector erase second command */ 221 221 #define STATE_CMD_RESET 0x0000000C /* reset */ ··· 230 230 #define STATE_ADDR_ZERO 0x00000040 /* one byte zero address was accepted */ 231 231 #define STATE_ADDR_MASK 0x00000070 /* address states mask */ 232 232 233 - /* Durind data input/output the simulator is in these states */ 233 + /* During data input/output the simulator is in these states */ 234 234 #define STATE_DATAIN 0x00000100 /* waiting for data input */ 235 235 #define STATE_DATAIN_MASK 0x00000100 /* data input states mask */ 236 236 ··· 248 248 249 249 /* Simulator's actions bit masks */ 250 250 #define ACTION_CPY 0x00100000 /* copy page/OOB to the internal buffer */ 251 - #define ACTION_PRGPAGE 0x00200000 /* programm the internal buffer to flash */ 251 + #define ACTION_PRGPAGE 0x00200000 /* program the internal buffer to flash */ 252 252 #define ACTION_SECERASE 0x00300000 /* erase sector */ 253 253 #define ACTION_ZEROOFF 0x00400000 /* don't add any offset to address */ 254 254 #define ACTION_HALFOFF 0x00500000 /* add to address half of page */ ··· 263 263 #define OPT_PAGE512 0x00000002 /* 512-byte page chips */ 264 264 #define OPT_PAGE2048 0x00000008 /* 2048-byte page chips */ 265 265 #define OPT_SMARTMEDIA 0x00000010 /* SmartMedia technology chips */ 266 - #define OPT_AUTOINCR 0x00000020 /* page number auto inctimentation is possible */ 266 + #define OPT_AUTOINCR 0x00000020 /* page number auto incrementation is possible */ 267 267 #define OPT_PAGE512_8BIT 0x00000040 /* 512-byte page chips with 8-bit bus width */ 268 268 #define OPT_PAGE4096 0x00000080 /* 4096-byte page chips */ 269 269 #define OPT_LARGEPAGE (OPT_PAGE2048 | OPT_PAGE4096) /* 2048 & 4096-byte page chips */ 270 270 #define OPT_SMALLPAGE (OPT_PAGE256 | OPT_PAGE512) /* 256 and 512-byte page chips */ 271 271 272 - /* Remove action bits ftom state */ 272 + /* Remove action bits from state */ 273 273 #define NS_STATE(x) ((x) & ~ACTION_MASK) 274 274 275 275 /* 276 276 * Maximum previous states which need to be saved. Currently saving is 277 - * only needed for page programm operation with preceeded read command 277 + * only needed for page program operation with preceded read command 278 278 * (which is only valid for 512-byte pages). 279 279 */ 280 280 #define NS_MAX_PREVSTATES 1 ··· 380 380 /* Read OOB */ 381 381 {OPT_SMALLPAGE, {STATE_CMD_READOOB | ACTION_OOBOFF, STATE_ADDR_PAGE | ACTION_CPY, 382 382 STATE_DATAOUT, STATE_READY}}, 383 - /* Programm page starting from the beginning */ 383 + /* Program page starting from the beginning */ 384 384 {OPT_ANY, {STATE_CMD_SEQIN, STATE_ADDR_PAGE, STATE_DATAIN, 385 385 STATE_CMD_PAGEPROG | ACTION_PRGPAGE, STATE_READY}}, 386 - /* Programm page starting from the beginning */ 386 + /* Program page starting from the beginning */ 387 387 {OPT_SMALLPAGE, {STATE_CMD_READ0, STATE_CMD_SEQIN | ACTION_ZEROOFF, STATE_ADDR_PAGE, 388 388 STATE_DATAIN, STATE_CMD_PAGEPROG | ACTION_PRGPAGE, STATE_READY}}, 389 - /* Programm page starting from the second half */ 389 + /* Program page starting from the second half */ 390 390 {OPT_PAGE512, {STATE_CMD_READ1, STATE_CMD_SEQIN | ACTION_HALFOFF, STATE_ADDR_PAGE, 391 391 STATE_DATAIN, STATE_CMD_PAGEPROG | ACTION_PRGPAGE, STATE_READY}}, 392 - /* Programm OOB */ 392 + /* Program OOB */ 393 393 {OPT_SMALLPAGE, {STATE_CMD_READOOB, STATE_CMD_SEQIN | ACTION_OOBOFF, STATE_ADDR_PAGE, 394 394 STATE_DATAIN, STATE_CMD_PAGEPROG | ACTION_PRGPAGE, STATE_READY}}, 395 395 /* Erase sector */ ··· 470 470 err = -EINVAL; 471 471 goto err_close; 472 472 } 473 - ns->pages_written = vmalloc(ns->geom.pgnum); 473 + ns->pages_written = vzalloc(ns->geom.pgnum); 474 474 if (!ns->pages_written) { 475 475 NS_ERR("alloc_device: unable to allocate pages written array\n"); 476 476 err = -ENOMEM; ··· 483 483 goto err_free; 484 484 } 485 485 ns->cfile = cfile; 486 - memset(ns->pages_written, 0, ns->geom.pgnum); 487 486 return 0; 488 487 } 489 488 ··· 1170 1171 * of supported operations. 1171 1172 * 1172 1173 * Operation can be unknown because of the following. 1173 - * 1. New command was accepted and this is the firs call to find the 1174 + * 1. New command was accepted and this is the first call to find the 1174 1175 * correspondent states chain. In this case ns->npstates = 0; 1175 - * 2. There is several operations which begin with the same command(s) 1176 + * 2. There are several operations which begin with the same command(s) 1176 1177 * (for example program from the second half and read from the 1177 1178 * second half operations both begin with the READ1 command). In this 1178 1179 * case the ns->pstates[] array contains previous states. ··· 1185 1186 * ns->ops, ns->state, ns->nxstate are initialized, ns->npstate is 1186 1187 * zeroed). 1187 1188 * 1188 - * If there are several maches, the current state is pushed to the 1189 + * If there are several matches, the current state is pushed to the 1189 1190 * ns->pstates. 1190 1191 * 1191 1192 * The operation can be unknown only while commands are input to the chip. ··· 1194 1195 * operation is searched using the following pattern: 1195 1196 * ns->pstates[0], ... ns->pstates[ns->npstates], <address input> 1196 1197 * 1197 - * It is supposed that this pattern must either match one operation on 1198 + * It is supposed that this pattern must either match one operation or 1198 1199 * none. There can't be ambiguity in that case. 1199 1200 * 1200 - * If no matches found, the functions does the following: 1201 + * If no matches found, the function does the following: 1201 1202 * 1. if there are saved states present, try to ignore them and search 1202 1203 * again only using the last command. If nothing was found, switch 1203 1204 * to the STATE_READY state. ··· 1667 1668 1668 1669 case ACTION_PRGPAGE: 1669 1670 /* 1670 - * Programm page - move internal buffer data to the page. 1671 + * Program page - move internal buffer data to the page. 1671 1672 */ 1672 1673 1673 1674 if (ns->lines.wp) { ··· 1932 1933 NS_DBG("read_byte: all bytes were read\n"); 1933 1934 1934 1935 /* 1935 - * The OPT_AUTOINCR allows to read next conseqitive pages without 1936 + * The OPT_AUTOINCR allows to read next consecutive pages without 1936 1937 * new read operation cycle. 1937 1938 */ 1938 1939 if ((ns->options & OPT_AUTOINCR) && NS_STATE(ns->state) == STATE_DATAOUT) {
+1 -1
drivers/mtd/nand/pasemi_nand.c
··· 107 107 if (pasemi_nand_mtd) 108 108 return -ENODEV; 109 109 110 - pr_debug("pasemi_nand at %llx-%llx\n", res.start, res.end); 110 + pr_debug("pasemi_nand at %pR\n", &res); 111 111 112 112 /* Allocate memory for MTD device structure and private data */ 113 113 pasemi_nand_mtd = kzalloc(sizeof(struct mtd_info) +
+1 -1
drivers/mtd/nand/pxa3xx_nand.c
··· 885 885 /* set info fields needed to __readid */ 886 886 info->read_id_bytes = (info->page_size == 2048) ? 4 : 2; 887 887 info->reg_ndcr = ndcr; 888 + info->cmdset = &default_cmdset; 888 889 889 890 if (__readid(info, &id)) 890 891 return -ENODEV; ··· 916 915 917 916 info->ndtr0cs0 = nand_readl(info, NDTR0CS0); 918 917 info->ndtr1cs0 = nand_readl(info, NDTR1CS0); 919 - info->cmdset = &default_cmdset; 920 918 921 919 return 0; 922 920 }
+3 -2
drivers/mtd/nand/txx9ndfmc.c
··· 277 277 ret = nand_scan_ident(mtd, 1, NULL); 278 278 if (!ret) { 279 279 if (mtd->writesize >= 512) { 280 - chip->ecc.size = mtd->writesize; 281 - chip->ecc.bytes = 3 * (mtd->writesize / 256); 280 + /* Hardware ECC 6 byte ECC per 512 Byte data */ 281 + chip->ecc.size = 512; 282 + chip->ecc.bytes = 6; 282 283 } 283 284 ret = nand_scan_tail(mtd); 284 285 }
+61 -19
drivers/mtd/onenand/omap2.c
··· 35 35 #include <linux/dma-mapping.h> 36 36 #include <linux/io.h> 37 37 #include <linux/slab.h> 38 + #include <linux/regulator/consumer.h> 38 39 39 40 #include <asm/mach/flash.h> 40 41 #include <plat/gpmc.h> ··· 64 63 int dma_channel; 65 64 int freq; 66 65 int (*setup)(void __iomem *base, int freq); 66 + struct regulator *regulator; 67 67 }; 68 + 69 + #ifdef CONFIG_MTD_PARTITIONS 70 + static const char *part_probes[] = { "cmdlinepart", NULL, }; 71 + #endif 68 72 69 73 static void omap2_onenand_dma_cb(int lch, u16 ch_status, void *data) 70 74 { ··· 114 108 static int omap2_onenand_wait(struct mtd_info *mtd, int state) 115 109 { 116 110 struct omap2_onenand *c = container_of(mtd, struct omap2_onenand, mtd); 111 + struct onenand_chip *this = mtd->priv; 117 112 unsigned int intr = 0; 118 - unsigned int ctrl; 113 + unsigned int ctrl, ctrl_mask; 119 114 unsigned long timeout; 120 115 u32 syscfg; 121 116 ··· 187 180 if (result == 0) { 188 181 /* Timeout after 20ms */ 189 182 ctrl = read_reg(c, ONENAND_REG_CTRL_STATUS); 190 - if (ctrl & ONENAND_CTRL_ONGO) { 183 + if (ctrl & ONENAND_CTRL_ONGO && 184 + !this->ongoing) { 191 185 /* 192 186 * The operation seems to be still going 193 187 * so give it some more time. ··· 277 269 return -EIO; 278 270 } 279 271 280 - if (ctrl & 0xFE9F) 272 + ctrl_mask = 0xFE9F; 273 + if (this->ongoing) 274 + ctrl_mask &= ~0x8000; 275 + 276 + if (ctrl & ctrl_mask) 281 277 wait_warn("unexpected controller status", state, ctrl, intr); 282 278 283 279 return 0; ··· 603 591 memset((__force void *)c->onenand.base, 0, ONENAND_BUFRAM_SIZE); 604 592 } 605 593 594 + static int omap2_onenand_enable(struct mtd_info *mtd) 595 + { 596 + int ret; 597 + struct omap2_onenand *c = container_of(mtd, struct omap2_onenand, mtd); 598 + 599 + ret = regulator_enable(c->regulator); 600 + if (ret != 0) 601 + dev_err(&c->pdev->dev, "cant enable regulator\n"); 602 + 603 + return ret; 604 + } 605 + 606 + static int omap2_onenand_disable(struct mtd_info *mtd) 607 + { 608 + int ret; 609 + struct omap2_onenand *c = container_of(mtd, struct omap2_onenand, mtd); 610 + 611 + ret = regulator_disable(c->regulator); 612 + if (ret != 0) 613 + dev_err(&c->pdev->dev, "cant disable regulator\n"); 614 + 615 + return ret; 616 + } 617 + 606 618 static int __devinit omap2_onenand_probe(struct platform_device *pdev) 607 619 { 608 620 struct omap_onenand_platform_data *pdata; ··· 741 705 } 742 706 } 743 707 708 + if (pdata->regulator_can_sleep) { 709 + c->regulator = regulator_get(&pdev->dev, "vonenand"); 710 + if (IS_ERR(c->regulator)) { 711 + dev_err(&pdev->dev, "Failed to get regulator\n"); 712 + goto err_release_dma; 713 + } 714 + c->onenand.enable = omap2_onenand_enable; 715 + c->onenand.disable = omap2_onenand_disable; 716 + } 717 + 744 718 if ((r = onenand_scan(&c->mtd, 1)) < 0) 745 - goto err_release_dma; 719 + goto err_release_regulator; 746 720 747 721 switch ((c->onenand.version_id >> 4) & 0xf) { 748 722 case 0: ··· 773 727 } 774 728 775 729 #ifdef CONFIG_MTD_PARTITIONS 776 - if (pdata->parts != NULL) 777 - r = add_mtd_partitions(&c->mtd, pdata->parts, 778 - pdata->nr_parts); 730 + r = parse_mtd_partitions(&c->mtd, part_probes, &c->parts, 0); 731 + if (r > 0) 732 + r = add_mtd_partitions(&c->mtd, c->parts, r); 733 + else if (pdata->parts != NULL) 734 + r = add_mtd_partitions(&c->mtd, pdata->parts, pdata->nr_parts); 779 735 else 780 736 #endif 781 737 r = add_mtd_device(&c->mtd); 782 - if (r < 0) 738 + if (r) 783 739 goto err_release_onenand; 784 740 785 741 platform_set_drvdata(pdev, c); ··· 790 742 791 743 err_release_onenand: 792 744 onenand_release(&c->mtd); 745 + err_release_regulator: 746 + regulator_put(c->regulator); 793 747 err_release_dma: 794 748 if (c->dma_channel != -1) 795 749 omap_free_dma(c->dma_channel); ··· 807 757 err_free_cs: 808 758 gpmc_cs_free(c->gpmc_cs); 809 759 err_kfree: 760 + kfree(c->parts); 810 761 kfree(c); 811 762 812 763 return r; ··· 817 766 { 818 767 struct omap2_onenand *c = dev_get_drvdata(&pdev->dev); 819 768 820 - BUG_ON(c == NULL); 821 - 822 - #ifdef CONFIG_MTD_PARTITIONS 823 - if (c->parts) 824 - del_mtd_partitions(&c->mtd); 825 - else 826 - del_mtd_device(&c->mtd); 827 - #else 828 - del_mtd_device(&c->mtd); 829 - #endif 830 - 831 769 onenand_release(&c->mtd); 770 + regulator_put(c->regulator); 832 771 if (c->dma_channel != -1) 833 772 omap_free_dma(c->dma_channel); 834 773 omap2_onenand_shutdown(pdev); ··· 830 789 iounmap(c->onenand.base); 831 790 release_mem_region(c->phys_base, ONENAND_IO_SIZE); 832 791 gpmc_cs_free(c->gpmc_cs); 792 + kfree(c->parts); 833 793 kfree(c); 834 794 835 795 return 0;
+54 -27
drivers/mtd/onenand/onenand_base.c
··· 400 400 value = onenand_bufferram_address(this, block); 401 401 this->write_word(value, this->base + ONENAND_REG_START_ADDRESS2); 402 402 403 - if (ONENAND_IS_MLC(this) || ONENAND_IS_2PLANE(this) || 404 - ONENAND_IS_4KB_PAGE(this)) 403 + if (ONENAND_IS_2PLANE(this) || ONENAND_IS_4KB_PAGE(this)) 405 404 /* It is always BufferRAM0 */ 406 405 ONENAND_SET_BUFFERRAM0(this); 407 406 else ··· 429 430 case FLEXONENAND_CMD_RECOVER_LSB: 430 431 case ONENAND_CMD_READ: 431 432 case ONENAND_CMD_READOOB: 432 - if (ONENAND_IS_MLC(this) || ONENAND_IS_4KB_PAGE(this)) 433 + if (ONENAND_IS_4KB_PAGE(this)) 433 434 /* It is always BufferRAM0 */ 434 435 dataram = ONENAND_SET_BUFFERRAM0(this); 435 436 else ··· 948 949 if (this->state == FL_READY) { 949 950 this->state = new_state; 950 951 spin_unlock(&this->chip_lock); 952 + if (new_state != FL_PM_SUSPENDED && this->enable) 953 + this->enable(mtd); 951 954 break; 952 955 } 953 956 if (new_state == FL_PM_SUSPENDED) { ··· 976 975 { 977 976 struct onenand_chip *this = mtd->priv; 978 977 978 + if (this->state != FL_PM_SUSPENDED && this->disable) 979 + this->disable(mtd); 979 980 /* Release the chip */ 980 981 spin_lock(&this->chip_lock); 981 982 this->state = FL_READY; ··· 1356 1353 1357 1354 stats = mtd->ecc_stats; 1358 1355 1359 - readcmd = ONENAND_IS_MLC(this) ? ONENAND_CMD_READ : ONENAND_CMD_READOOB; 1356 + readcmd = ONENAND_IS_4KB_PAGE(this) ? ONENAND_CMD_READ : ONENAND_CMD_READOOB; 1360 1357 1361 1358 while (read < len) { 1362 1359 cond_resched(); ··· 1432 1429 int ret; 1433 1430 1434 1431 onenand_get_device(mtd, FL_READING); 1435 - ret = ONENAND_IS_MLC(this) || ONENAND_IS_4KB_PAGE(this) ? 1432 + ret = ONENAND_IS_4KB_PAGE(this) ? 1436 1433 onenand_mlc_read_ops_nolock(mtd, from, &ops) : 1437 1434 onenand_read_ops_nolock(mtd, from, &ops); 1438 1435 onenand_release_device(mtd); ··· 1467 1464 1468 1465 onenand_get_device(mtd, FL_READING); 1469 1466 if (ops->datbuf) 1470 - ret = ONENAND_IS_MLC(this) || ONENAND_IS_4KB_PAGE(this) ? 1467 + ret = ONENAND_IS_4KB_PAGE(this) ? 1471 1468 onenand_mlc_read_ops_nolock(mtd, from, ops) : 1472 1469 onenand_read_ops_nolock(mtd, from, ops); 1473 1470 else ··· 1488 1485 { 1489 1486 struct onenand_chip *this = mtd->priv; 1490 1487 unsigned long timeout; 1491 - unsigned int interrupt; 1492 - unsigned int ctrl; 1488 + unsigned int interrupt, ctrl, ecc, addr1, addr8; 1493 1489 1494 1490 /* The 20 msec is enough */ 1495 1491 timeout = jiffies + msecs_to_jiffies(20); ··· 1500 1498 /* To get correct interrupt status in timeout case */ 1501 1499 interrupt = this->read_word(this->base + ONENAND_REG_INTERRUPT); 1502 1500 ctrl = this->read_word(this->base + ONENAND_REG_CTRL_STATUS); 1501 + addr1 = this->read_word(this->base + ONENAND_REG_START_ADDRESS1); 1502 + addr8 = this->read_word(this->base + ONENAND_REG_START_ADDRESS8); 1503 1503 1504 1504 if (interrupt & ONENAND_INT_READ) { 1505 - int ecc = onenand_read_ecc(this); 1505 + ecc = onenand_read_ecc(this); 1506 1506 if (ecc & ONENAND_ECC_2BIT_ALL) { 1507 - printk(KERN_WARNING "%s: ecc error = 0x%04x, " 1508 - "controller error 0x%04x\n", 1509 - __func__, ecc, ctrl); 1507 + printk(KERN_DEBUG "%s: ecc 0x%04x ctrl 0x%04x " 1508 + "intr 0x%04x addr1 %#x addr8 %#x\n", 1509 + __func__, ecc, ctrl, interrupt, addr1, addr8); 1510 1510 return ONENAND_BBT_READ_ECC_ERROR; 1511 1511 } 1512 1512 } else { 1513 - printk(KERN_ERR "%s: read timeout! ctrl=0x%04x intr=0x%04x\n", 1514 - __func__, ctrl, interrupt); 1513 + printk(KERN_ERR "%s: read timeout! ctrl 0x%04x " 1514 + "intr 0x%04x addr1 %#x addr8 %#x\n", 1515 + __func__, ctrl, interrupt, addr1, addr8); 1515 1516 return ONENAND_BBT_READ_FATAL_ERROR; 1516 1517 } 1517 1518 1518 1519 /* Initial bad block case: 0x2400 or 0x0400 */ 1519 1520 if (ctrl & ONENAND_CTRL_ERROR) { 1520 - printk(KERN_DEBUG "%s: controller error = 0x%04x\n", 1521 - __func__, ctrl); 1521 + printk(KERN_DEBUG "%s: ctrl 0x%04x intr 0x%04x addr1 %#x " 1522 + "addr8 %#x\n", __func__, ctrl, interrupt, addr1, addr8); 1522 1523 return ONENAND_BBT_READ_ERROR; 1523 1524 } 1524 1525 ··· 1563 1558 1564 1559 column = from & (mtd->oobsize - 1); 1565 1560 1566 - readcmd = ONENAND_IS_MLC(this) ? ONENAND_CMD_READ : ONENAND_CMD_READOOB; 1561 + readcmd = ONENAND_IS_4KB_PAGE(this) ? ONENAND_CMD_READ : ONENAND_CMD_READOOB; 1567 1562 1568 1563 while (read < len) { 1569 1564 cond_resched(); ··· 1617 1612 u_char *oob_buf = this->oob_buf; 1618 1613 int status, i, readcmd; 1619 1614 1620 - readcmd = ONENAND_IS_MLC(this) ? ONENAND_CMD_READ : ONENAND_CMD_READOOB; 1615 + readcmd = ONENAND_IS_4KB_PAGE(this) ? ONENAND_CMD_READ : ONENAND_CMD_READOOB; 1621 1616 1622 1617 this->command(mtd, readcmd, to, mtd->oobsize); 1623 1618 onenand_update_bufferram(mtd, to, 0); ··· 1850 1845 const u_char *buf = ops->datbuf; 1851 1846 const u_char *oob = ops->oobbuf; 1852 1847 u_char *oobbuf; 1853 - int ret = 0; 1848 + int ret = 0, cmd; 1854 1849 1855 1850 DEBUG(MTD_DEBUG_LEVEL3, "%s: to = 0x%08x, len = %i\n", 1856 1851 __func__, (unsigned int) to, (int) len); ··· 1959 1954 ONENAND_SET_NEXT_BUFFERRAM(this); 1960 1955 } 1961 1956 1962 - this->command(mtd, ONENAND_CMD_PROG, to, mtd->writesize); 1957 + this->ongoing = 0; 1958 + cmd = ONENAND_CMD_PROG; 1959 + 1960 + /* Exclude 1st OTP and OTP blocks for cache program feature */ 1961 + if (ONENAND_IS_CACHE_PROGRAM(this) && 1962 + likely(onenand_block(this, to) != 0) && 1963 + ONENAND_IS_4KB_PAGE(this) && 1964 + ((written + thislen) < len)) { 1965 + cmd = ONENAND_CMD_2X_CACHE_PROG; 1966 + this->ongoing = 1; 1967 + } 1968 + 1969 + this->command(mtd, cmd, to, mtd->writesize); 1963 1970 1964 1971 /* 1965 1972 * 2 PLANE, MLC, and Flex-OneNAND wait here ··· 2084 2067 2085 2068 oobbuf = this->oob_buf; 2086 2069 2087 - oobcmd = ONENAND_IS_MLC(this) ? ONENAND_CMD_PROG : ONENAND_CMD_PROGOOB; 2070 + oobcmd = ONENAND_IS_4KB_PAGE(this) ? ONENAND_CMD_PROG : ONENAND_CMD_PROGOOB; 2088 2071 2089 2072 /* Loop until all data write */ 2090 2073 while (written < len) { ··· 2103 2086 memcpy(oobbuf + column, buf, thislen); 2104 2087 this->write_bufferram(mtd, ONENAND_SPARERAM, oobbuf, 0, mtd->oobsize); 2105 2088 2106 - if (ONENAND_IS_MLC(this) || ONENAND_IS_4KB_PAGE(this)) { 2089 + if (ONENAND_IS_4KB_PAGE(this)) { 2107 2090 /* Set main area of DataRAM to 0xff*/ 2108 2091 memset(this->page_buf, 0xff, mtd->writesize); 2109 2092 this->write_bufferram(mtd, ONENAND_DATARAM, ··· 2498 2481 /* Grab the lock and see if the device is available */ 2499 2482 onenand_get_device(mtd, FL_ERASING); 2500 2483 2501 - if (region || instr->len < MB_ERASE_MIN_BLK_COUNT * block_size) { 2484 + if (ONENAND_IS_4KB_PAGE(this) || region || 2485 + instr->len < MB_ERASE_MIN_BLK_COUNT * block_size) { 2502 2486 /* region is set for Flex-OneNAND (no mb erase) */ 2503 2487 ret = onenand_block_by_block_erase(mtd, instr, 2504 2488 region, block_size); ··· 3047 3029 this->command(mtd, ONENAND_CMD_OTP_ACCESS, 0, 0); 3048 3030 this->wait(mtd, FL_OTPING); 3049 3031 3050 - ret = ONENAND_IS_MLC(this) || ONENAND_IS_4KB_PAGE(this) ? 3032 + ret = ONENAND_IS_4KB_PAGE(this) ? 3051 3033 onenand_mlc_read_ops_nolock(mtd, from, &ops) : 3052 3034 onenand_read_ops_nolock(mtd, from, &ops); 3053 3035 ··· 3395 3377 case ONENAND_DEVICE_DENSITY_4Gb: 3396 3378 if (ONENAND_IS_DDP(this)) 3397 3379 this->options |= ONENAND_HAS_2PLANE; 3398 - else if (numbufs == 1) 3380 + else if (numbufs == 1) { 3399 3381 this->options |= ONENAND_HAS_4KB_PAGE; 3382 + this->options |= ONENAND_HAS_CACHE_PROGRAM; 3383 + } 3400 3384 3401 3385 case ONENAND_DEVICE_DENSITY_2Gb: 3402 3386 /* 2Gb DDP does not have 2 plane */ ··· 3419 3399 break; 3420 3400 } 3421 3401 3422 - if (ONENAND_IS_MLC(this) || ONENAND_IS_4KB_PAGE(this)) 3402 + /* The MLC has 4KiB pagesize. */ 3403 + if (ONENAND_IS_MLC(this)) 3404 + this->options |= ONENAND_HAS_4KB_PAGE; 3405 + 3406 + if (ONENAND_IS_4KB_PAGE(this)) 3423 3407 this->options &= ~ONENAND_HAS_2PLANE; 3424 3408 3425 3409 if (FLEXONENAND(this)) { ··· 3439 3415 printk(KERN_DEBUG "Chip has 2 plane\n"); 3440 3416 if (this->options & ONENAND_HAS_4KB_PAGE) 3441 3417 printk(KERN_DEBUG "Chip has 4KiB pagesize\n"); 3418 + if (this->options & ONENAND_HAS_CACHE_PROGRAM) 3419 + printk(KERN_DEBUG "Chip has cache program feature\n"); 3442 3420 } 3443 3421 3444 3422 /** ··· 3857 3831 /* The data buffer size is equal to page size */ 3858 3832 mtd->writesize = this->read_word(this->base + ONENAND_REG_DATA_BUFFER_SIZE); 3859 3833 /* We use the full BufferRAM */ 3860 - if (ONENAND_IS_MLC(this) || ONENAND_IS_4KB_PAGE(this)) 3834 + if (ONENAND_IS_4KB_PAGE(this)) 3861 3835 mtd->writesize <<= 1; 3862 3836 3863 3837 mtd->oobsize = mtd->writesize >> 5; ··· 4080 4054 mtd->block_isbad = onenand_block_isbad; 4081 4055 mtd->block_markbad = onenand_block_markbad; 4082 4056 mtd->owner = THIS_MODULE; 4057 + mtd->writebufsize = mtd->writesize; 4083 4058 4084 4059 /* Unlock whole block */ 4085 4060 this->unlock_all(mtd);
+6 -4
drivers/mtd/onenand/onenand_bbt.c
··· 91 91 for (j = 0; j < len; j++) { 92 92 /* No need to read pages fully, 93 93 * just read required OOB bytes */ 94 - ret = onenand_bbt_read_oob(mtd, from + j * mtd->writesize + bd->offs, &ops); 94 + ret = onenand_bbt_read_oob(mtd, 95 + from + j * this->writesize + bd->offs, &ops); 95 96 96 97 /* If it is a initial bad block, just ignore it */ 97 98 if (ret == ONENAND_BBT_READ_FATAL_ERROR) 98 99 return -EIO; 99 100 100 - if (ret || check_short_pattern(&buf[j * scanlen], scanlen, mtd->writesize, bd)) { 101 + if (ret || check_short_pattern(&buf[j * scanlen], 102 + scanlen, this->writesize, bd)) { 101 103 bbm->bbt[i >> 3] |= 0x03 << (i & 0x6); 102 - printk(KERN_WARNING "Bad eraseblock %d at 0x%08x\n", 103 - i >> 1, (unsigned int) from); 104 + printk(KERN_INFO "OneNAND eraseblock %d is an " 105 + "initial bad block\n", i >> 1); 104 106 mtd->ecc_stats.badblocks++; 105 107 break; 106 108 }
+5 -2
drivers/mtd/onenand/samsung.c
··· 651 651 void __iomem *p; 652 652 void *buf = (void *) buffer; 653 653 dma_addr_t dma_src, dma_dst; 654 - int err, page_dma = 0; 654 + int err, ofs, page_dma = 0; 655 655 struct device *dev = &onenand->pdev->dev; 656 656 657 657 p = this->base + area; ··· 677 677 if (!page) 678 678 goto normal; 679 679 680 + /* Page offset */ 681 + ofs = ((size_t) buf & ~PAGE_MASK); 680 682 page_dma = 1; 683 + 681 684 /* DMA routine */ 682 685 dma_src = onenand->phys_base + (p - this->base); 683 - dma_dst = dma_map_page(dev, page, 0, count, DMA_FROM_DEVICE); 686 + dma_dst = dma_map_page(dev, page, ofs, count, DMA_FROM_DEVICE); 684 687 } else { 685 688 /* DMA routine */ 686 689 dma_src = onenand->phys_base + (p - this->base);
+27 -1
drivers/mtd/ubi/build.c
··· 672 672 ubi->nor_flash = 1; 673 673 } 674 674 675 - ubi->min_io_size = ubi->mtd->writesize; 675 + /* 676 + * Set UBI min. I/O size (@ubi->min_io_size). We use @mtd->writebufsize 677 + * for these purposes, not @mtd->writesize. At the moment this does not 678 + * matter for NAND, because currently @mtd->writebufsize is equivalent to 679 + * @mtd->writesize for all NANDs. However, some CFI NOR flashes may 680 + * have @mtd->writebufsize which is multiple of @mtd->writesize. 681 + * 682 + * The reason we use @mtd->writebufsize for @ubi->min_io_size is that 683 + * UBI and UBIFS recovery algorithms rely on the fact that if there was 684 + * an unclean power cut, then we can find offset of the last corrupted 685 + * node, align the offset to @ubi->min_io_size, read the rest of the 686 + * eraseblock starting from this offset, and check whether there are 687 + * only 0xFF bytes. If yes, then we are probably dealing with a 688 + * corruption caused by a power cut, if not, then this is probably some 689 + * severe corruption. 690 + * 691 + * Thus, we have to use the maximum write unit size of the flash, which 692 + * is @mtd->writebufsize, because @mtd->writesize is the minimum write 693 + * size, not the maximum. 694 + */ 695 + if (ubi->mtd->type == MTD_NANDFLASH) 696 + ubi_assert(ubi->mtd->writebufsize == ubi->mtd->writesize); 697 + else if (ubi->mtd->type == MTD_NORFLASH) 698 + ubi_assert(ubi->mtd->writebufsize % ubi->mtd->writesize == 0); 699 + 700 + ubi->min_io_size = ubi->mtd->writebufsize; 701 + 676 702 ubi->hdrs_min_io_size = ubi->mtd->writesize >> ubi->mtd->subpage_sft; 677 703 678 704 /*
+2 -4
drivers/mtd/ubi/vtbl.c
··· 425 425 426 426 /* Read both LEB 0 and LEB 1 into memory */ 427 427 ubi_rb_for_each_entry(rb, seb, &sv->root, u.rb) { 428 - leb[seb->lnum] = vmalloc(ubi->vtbl_size); 428 + leb[seb->lnum] = vzalloc(ubi->vtbl_size); 429 429 if (!leb[seb->lnum]) { 430 430 err = -ENOMEM; 431 431 goto out_free; 432 432 } 433 - memset(leb[seb->lnum], 0, ubi->vtbl_size); 434 433 435 434 err = ubi_io_read_data(ubi, leb[seb->lnum], seb->pnum, 0, 436 435 ubi->vtbl_size); ··· 515 516 int i; 516 517 struct ubi_vtbl_record *vtbl; 517 518 518 - vtbl = vmalloc(ubi->vtbl_size); 519 + vtbl = vzalloc(ubi->vtbl_size); 519 520 if (!vtbl) 520 521 return ERR_PTR(-ENOMEM); 521 - memset(vtbl, 0, ubi->vtbl_size); 522 522 523 523 for (i = 0; i < ubi->vtbl_slots; i++) 524 524 memcpy(&vtbl[i], &empty_vtbl_record, UBI_VTBL_RECORD_SIZE);
+2 -3
fs/jffs2/build.c
··· 336 336 size = sizeof(struct jffs2_eraseblock) * c->nr_blocks; 337 337 #ifndef __ECOS 338 338 if (jffs2_blocks_use_vmalloc(c)) 339 - c->blocks = vmalloc(size); 339 + c->blocks = vzalloc(size); 340 340 else 341 341 #endif 342 - c->blocks = kmalloc(size, GFP_KERNEL); 342 + c->blocks = kzalloc(size, GFP_KERNEL); 343 343 if (!c->blocks) 344 344 return -ENOMEM; 345 345 346 - memset(c->blocks, 0, size); 347 346 for (i=0; i<c->nr_blocks; i++) { 348 347 INIT_LIST_HEAD(&c->blocks[i].list); 349 348 c->blocks[i].offset = i * c->sector_size;
+1 -1
fs/jffs2/jffs2_fs_sb.h
··· 144 144 void *os_priv; 145 145 }; 146 146 147 - #endif /* _JFFS2_FB_SB */ 147 + #endif /* _JFFS2_FS_SB */
+6 -6
fs/jffs2/xattr.c
··· 151 151 JFFS2_ERROR("node CRC failed at %#08x, read=%#08x, calc=%#08x\n", 152 152 offset, je32_to_cpu(rx.hdr_crc), crc); 153 153 xd->flags |= JFFS2_XFLAGS_INVALID; 154 - return EIO; 154 + return -EIO; 155 155 } 156 156 totlen = PAD(sizeof(rx) + rx.name_len + 1 + je16_to_cpu(rx.value_len)); 157 157 if (je16_to_cpu(rx.magic) != JFFS2_MAGIC_BITMASK ··· 167 167 je32_to_cpu(rx.xid), xd->xid, 168 168 je32_to_cpu(rx.version), xd->version); 169 169 xd->flags |= JFFS2_XFLAGS_INVALID; 170 - return EIO; 170 + return -EIO; 171 171 } 172 172 xd->xprefix = rx.xprefix; 173 173 xd->name_len = rx.name_len; ··· 230 230 ref_offset(xd->node), xd->data_crc, crc); 231 231 kfree(data); 232 232 xd->flags |= JFFS2_XFLAGS_INVALID; 233 - return EIO; 233 + return -EIO; 234 234 } 235 235 236 236 xd->flags |= JFFS2_XFLAGS_HOT; ··· 268 268 if (xd->xname) 269 269 return 0; 270 270 if (xd->flags & JFFS2_XFLAGS_INVALID) 271 - return EIO; 271 + return -EIO; 272 272 if (unlikely(is_xattr_datum_unchecked(c, xd))) 273 273 rc = do_verify_xattr_datum(c, xd); 274 274 if (!rc) ··· 460 460 if (crc != je32_to_cpu(rr.node_crc)) { 461 461 JFFS2_ERROR("node CRC failed at %#08x, read=%#08x, calc=%#08x\n", 462 462 offset, je32_to_cpu(rr.node_crc), crc); 463 - return EIO; 463 + return -EIO; 464 464 } 465 465 if (je16_to_cpu(rr.magic) != JFFS2_MAGIC_BITMASK 466 466 || je16_to_cpu(rr.nodetype) != JFFS2_NODETYPE_XREF ··· 470 470 offset, je16_to_cpu(rr.magic), JFFS2_MAGIC_BITMASK, 471 471 je16_to_cpu(rr.nodetype), JFFS2_NODETYPE_XREF, 472 472 je32_to_cpu(rr.totlen), PAD(sizeof(rr))); 473 - return EIO; 473 + return -EIO; 474 474 } 475 475 ref->ino = je32_to_cpu(rr.ino); 476 476 ref->xid = je32_to_cpu(rr.xid);
+1 -2
include/linux/mtd/cfi.h
··· 527 527 struct cfi_fixup { 528 528 uint16_t mfr; 529 529 uint16_t id; 530 - void (*fixup)(struct mtd_info *mtd, void* param); 531 - void* param; 530 + void (*fixup)(struct mtd_info *mtd); 532 531 }; 533 532 534 533 #define CFI_MFR_ANY 0xFFFF
+4 -22
include/linux/mtd/fsmc.h
··· 16 16 #ifndef __MTD_FSMC_H 17 17 #define __MTD_FSMC_H 18 18 19 + #include <linux/io.h> 19 20 #include <linux/platform_device.h> 20 21 #include <linux/mtd/physmap.h> 21 22 #include <linux/types.h> ··· 28 27 29 28 /* 30 29 * The placement of the Command Latch Enable (CLE) and 31 - * Address Latch Enable (ALE) is twised around in the 30 + * Address Latch Enable (ALE) is twisted around in the 32 31 * SPEAR310 implementation. 33 32 */ 34 33 #if defined(CONFIG_MACH_SPEAR310) ··· 63 62 64 63 /* ctrl_tim register definitions */ 65 64 66 - struct fsms_nand_bank_regs { 65 + struct fsmc_nand_bank_regs { 67 66 uint32_t pc; 68 67 uint32_t sts; 69 68 uint32_t comm; ··· 79 78 struct fsmc_regs { 80 79 struct fsmc_nor_bank_regs nor_bank_regs[FSMC_MAX_NOR_BANKS]; 81 80 uint8_t reserved_1[0x40 - 0x20]; 82 - struct fsms_nand_bank_regs bank_regs[FSMC_MAX_NAND_BANKS]; 81 + struct fsmc_nand_bank_regs bank_regs[FSMC_MAX_NAND_BANKS]; 83 82 uint8_t reserved_2[0xfe0 - 0xc0]; 84 83 uint32_t peripid0; /* 0xfe0 */ 85 84 uint32_t peripid1; /* 0xfe4 */ ··· 114 113 #define FSMC_TWAIT_6 (6 << 8) 115 114 #define FSMC_THOLD_4 (4 << 16) 116 115 #define FSMC_THIZ_1 (1 << 24) 117 - 118 - /* peripid2 register definitions */ 119 - #define FSMC_REVISION_MSK (0xf) 120 - #define FSMC_REVISION_SHFT (0x4) 121 - 122 - #define FSMC_VER1 1 123 - #define FSMC_VER2 2 124 - #define FSMC_VER3 3 125 - #define FSMC_VER4 4 126 - #define FSMC_VER5 5 127 - #define FSMC_VER6 6 128 - #define FSMC_VER7 7 129 - #define FSMC_VER8 8 130 - 131 - static inline uint32_t get_fsmc_version(struct fsmc_regs *regs) 132 - { 133 - return (readl(&regs->peripid2) >> FSMC_REVISION_SHFT) & 134 - FSMC_REVISION_MSK; 135 - } 136 116 137 117 /* 138 118 * There are 13 bytes of ecc for every 512 byte block in FSMC version 8
+11
include/linux/mtd/mtd.h
··· 144 144 */ 145 145 uint32_t writesize; 146 146 147 + /* 148 + * Size of the write buffer used by the MTD. MTD devices having a write 149 + * buffer can write multiple writesize chunks at a time. E.g. while 150 + * writing 4 * writesize bytes to a device with 2 * writesize bytes 151 + * buffer the MTD driver can (but doesn't have to) do 2 writesize 152 + * operations, but not 4. Currently, all NANDs have writebufsize 153 + * equivalent to writesize (NAND page size). Some NOR flashes do have 154 + * writebufsize greater than writesize. 155 + */ 156 + uint32_t writebufsize; 157 + 147 158 uint32_t oobsize; // Amount of OOB data per block (e.g. 16) 148 159 uint32_t oobavail; // Available OOB bytes per block 149 160
+2
include/linux/mtd/nand.h
··· 448 448 * See the defines for further explanation. 449 449 * @badblockpos: [INTERN] position of the bad block marker in the oob 450 450 * area. 451 + * @badblockbits: [INTERN] number of bits to left-shift the bad block 452 + * number 451 453 * @cellinfo: [INTERN] MLC/multichip data from chip ident 452 454 * @numchips: [INTERN] number of physical chips 453 455 * @chipsize: [INTERN] the size of one chip for multichip arrays
+14
include/linux/mtd/onenand.h
··· 118 118 int (*chip_probe)(struct mtd_info *mtd); 119 119 int (*block_markbad)(struct mtd_info *mtd, loff_t ofs); 120 120 int (*scan_bbt)(struct mtd_info *mtd); 121 + int (*enable)(struct mtd_info *mtd); 122 + int (*disable)(struct mtd_info *mtd); 121 123 122 124 struct completion complete; 123 125 int irq; ··· 139 137 void *bbm; 140 138 141 139 void *priv; 140 + 141 + /* 142 + * Shows that the current operation is composed 143 + * of sequence of commands. For example, cache program. 144 + * Such command status OnGo bit is checked at the end of 145 + * sequence. 146 + */ 147 + unsigned int ongoing; 142 148 }; 143 149 144 150 /* ··· 181 171 #define ONENAND_IS_2PLANE(this) (0) 182 172 #endif 183 173 174 + #define ONENAND_IS_CACHE_PROGRAM(this) \ 175 + (this->options & ONENAND_HAS_CACHE_PROGRAM) 176 + 184 177 /* Check byte access in OneNAND */ 185 178 #define ONENAND_CHECK_BYTE_ACCESS(addr) (addr & 0x1) 186 179 ··· 194 181 #define ONENAND_HAS_UNLOCK_ALL (0x0002) 195 182 #define ONENAND_HAS_2PLANE (0x0004) 196 183 #define ONENAND_HAS_4KB_PAGE (0x0008) 184 + #define ONENAND_HAS_CACHE_PROGRAM (0x0010) 197 185 #define ONENAND_SKIP_UNLOCK_CHECK (0x0100) 198 186 #define ONENAND_PAGEBUF_ALLOC (0x1000) 199 187 #define ONENAND_OOBBUF_ALLOC (0x2000)
+1 -1
include/linux/mtd/partitions.h
··· 89 89 static inline int mtd_has_cmdlinepart(void) { return 0; } 90 90 #endif 91 91 92 - int mtd_is_master(struct mtd_info *mtd); 92 + int mtd_is_partition(struct mtd_info *mtd); 93 93 int mtd_add_partition(struct mtd_info *master, char *name, 94 94 long long offset, long long length); 95 95 int mtd_del_partition(struct mtd_info *master, int partno);