Commit Graph

368 Commits

Author SHA1 Message Date
Wolfgang Grandegger 672ed2aee9 Enable multi chip support in the NAND layer
This patch adds support for NAND_MAX_CHIPS to the MTD NAND layer.
Multi-chips devices are displayed as shown:

  Device 0: 2x NAND 512MiB 3,3V 8-bit, sector size 128 KiB

Signed-off-by: Wolfgang Grandegger <wg@grandegger.com>
Signed-off-by: Scott Wood <scottwood@freescale.com>
2009-03-23 15:53:37 -05:00
Eric Schumann 3a3baf3ee6 Make flash protection work, when the environment is in EEPROM
On the pcm030 the environment is located in the onboard EEPROM. But we want
to handle flash sector protection in a safe manner. So we must read the
unlock environment variable from EEPROM instead from flash.

This patch is required as long the evironment is saved into the EEPROM.

Stefan: Additional change as suggested by Wolfgang, use bigger char array
(instead of 4).

Signed-off-by: Eric Schumann <E.Schumann@phytec.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Acked-by: Wolfgang Denk <wd@denx.de>
Signed-off-by: Stefan Roese <sr@denx.de>
2009-03-23 09:50:45 +01:00
Jean-Christophe PLAGNIOL-VILLARD 74c076d6c3 at91sam9/at91cap: move nand drivers to drivers/mtd/nand
Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
2009-03-22 13:22:24 +01:00
Richard Retanubun 7a88601a34 CFI: geometry reversal for STMicro M29W320DT
Follow up to the flash_fixup_stm to fix geometry reversal
on STMicro M29W320ET flash chip. The M29W320DT has 4 erase region.

Signed-off-by: Richard Retanubun <RichardRetanubun@RuggedCom.com>
Signed-off-by: Stefan Roese <sr@denx.de>
2009-03-19 15:00:32 +01:00
Jean-Christophe PLAGNIOL-VILLARD 0176c03a24 nomadik/nand: fix 'ecc512' discards qualifiers from pointer target type
Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
2009-02-22 17:56:50 +01:00
Alessandro Rubini 0d8c6eab24 Nand driver for Nomadik SoC
This driver implements the ECC algorithm described in
the CPU data sheet and uses the OOB layout chosen in
already-released development systems (shipped with a custom-made
u-boot 1.3.1).

Signed-off-by: Alessandro Rubini <rubini@unipv.it>
Acked-by: Andrea Gallo <andrea.gallo@stnwireless.com>
2009-02-22 13:40:28 +01:00
Heiko Schocher 4f975678de cfi: make flash_get_info() non static
If on your board is more than one flash, you must know
the size of every single flash, for example, for updating
the DTS before booting Linux. So make this function
flash_get_info() extern, and you can have all info
about your flashes.

Signed-off-by: Heiko Schocher <hs@denx.de>
Signed-off-by: Stefan Roese <sr@denx.de>
2009-02-11 17:01:17 +01:00
Wolfgang Denk f8306cb94f Merge branch 'master' of ssh://gemini/home/wd/git/u-boot/master 2009-02-07 23:51:52 +01:00
Wolfgang Denk 64ace0d1e5 Merge branch 'master' of git://git.denx.de/u-boot-nand-flash 2009-02-07 23:37:10 +01:00
Peter Tyser 8da601280a NAND: Add timeout for reset command
Without the timeout present an infinite loop can occur if the
NAND device is broken or not present.

Signed-off-by: Peter Tyser <ptyser@xes-inc.com>
Signed-off-by: Scott Wood <scottwood@freescale.com>
2009-02-06 17:29:38 -06:00
Peter Tyser 10dc6a9bef NAND: Silence warning when CONFIG_SYS_NAND_QUIET_TEST
Commit cfa460adfd removed support
for disabling the "No NAND device found!!!" warning when
CONFIG_SYS_NAND_QUIET_TEST was defined.  This re-adds support
for silencing the warning.

Signed-off-by: Peter Tyser <ptyser@xes-inc.com>
Signed-off-by: Scott Wood <scottwood@freescale.com>
2009-02-06 17:29:29 -06:00
Valeriy Glushkov ad09ab2e3a NAND: Fixed invalid pointers to static relocated chip names
Dear Wolfgang,

You are right, the patch was ugly.
The new one seems to be better.

Signed-off-by: Valeriy Glushkov <gvv@lstec.com>
Signed-off-by: Scott Wood <scottwood@freescale.com>
2009-02-06 17:28:31 -06:00
Stefan Roese e1fb6d0d52 cfi_flash: Fix typo in cfi_flash.c
Patch "flash/cfi_flash: Use virtual sector start address, not phys"
introduced a small typo and compilation warning for systems with CFI
legacy support (e.g. hcu4). This patch fixes it.

Signed-off-by: Stefan Roese <sr@denx.de>
2009-02-05 11:44:52 +01:00
Stefan Roese 28745db969 jedec_flash: Only use manufacturer defines from common flash.h
This patch removes the double defined manufacturer defines from
jedec_flash.c. Since the common defines in flash.h are 32bit
we now need the (16) cast. This patch also removes the compilation
warning (e.g. seen on hcu5):

./MAKEALL hcu5
Configuring for hcu5 board...
jedec_flash.c:219: warning: large integer implicitly truncated to unsigned type

Signed-off-by: Stefan Roese <sr@denx.de>
2009-02-05 11:27:58 +01:00
Stefan Roese ec21d5cfcb cfi_flash: Silence compilation warning
Patch "flash/cfi_flash: Use virtual sector start address, not phys"
introduced a small compilation warning. This patch fixes it.

Signed-off-by: Stefan Roese <sr@denx.de>
2009-02-05 11:25:57 +01:00
Becky Bruce 09ce9921a7 flash/cfi_flash: Use virtual sector start address, not phys
include/flash.h was commented to say that the address in
flash_info->start was a physical address.  However, from u-boot's
point of view, and looking at most flash code, it makes more
sense for this to be a virtual address.  So I corrected the
comment to indicate that this was a virtual address.

The only flash driver that was actually treating the address
as physical was the mtd/cfi_flash driver.  However, this code
was using it inconsistently as it actually directly dereferenced
the "start" element, while it used map_physmem to get a
virtual address in other places.  I changed this driver so
that the code which initializes the info->start field calls
map_physmem to get a virtual address, eliminating the need for
further map_physmem calls.  The code is now consistent.

The *only* place a physical address should be used is when defining the
flash banks list that is used to initialize the flash_info struct,
usually found in the board config file.

Signed-off-by: Becky Bruce <beckyb@kernel.crashing.org>
Signed-off-by: Stefan Roese <sr@denx.de>
2009-02-05 11:20:05 +01:00
Wolfgang Denk 657f2062d8 Fix compiler warning
(shows up only when DEBUG is enabled)

Signed-off-by: Wolfgang Denk <wd@denx.de>
2009-02-04 12:09:20 +01:00
Mike Frysinger be9d8c780e Blackfin: add driver for on-chip NAND controller
This is a port of the Linux Blackfin on-chip NFC driver to U-Boot.

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
2009-02-02 12:27:07 -05:00
Wolfgang Denk 6c6e042ab3 Merge branch 'master' of git://git.denx.de/u-boot-arm 2009-02-01 21:38:07 +01:00
Richard Retanubun e8eac43718 CFI: Add geometry reversal for STMicro M29W320ET
Added flash_fixup_stm to fix geometry reversal on STMicro M29W320ET flash chip.

Modeled after flash_fixup_amd, this patch handles the geometry reversal
or erase sectors that exist for ST Micro (now Numonyx) M29W320ET flash.
Since I cannot test all STM's chips, the detection is implemented as
narrow as possible for now.

Signed-off-by: Richard Retanubun <RichardRetanubun@RuggedCom.com>
Signed-off-by: Stefan Roese <sr@denx.de>
2009-01-26 10:59:48 +01:00
Jens Gehrlein 0f8e851e89 CFI: increase performance of function find_sector()
Tested on TQM5200S-BD with Samsung K8P2815UQB

Signed-off-by: Jens Gehrlein <sew_s@tqs.de>
Signed-off-by: Stefan Roese <sr@denx.de>
2009-01-26 10:50:13 +01:00
Jens Gehrlein a7292871a7 CFI: avoid redundant function call in single word programming mode
The function find_sector() doesn't need to be called twice in
the case of AMD command set.
Tested on TQM5200S-BD with Samsung K8P2815UQB.

Signed-off-by: Jens Gehrlein <sew_s@tqs.de>
Signed-off-by: Stefan Roese <sr@denx.de>
2009-01-26 10:49:59 +01:00
Dirk Behme 12201a1354 OMAP3: Add NAND support
Add NAND support.

Signed-off-by: Nishanth Menon <nm@ti.com>
Signed-off-by: Syed Mohammed Khasim <khasim@ti.com>
Signed-off-by: Dirk Behme <dirk.behme@googlemail.com>
2009-01-24 17:51:21 +01:00
Brad Bozarth 68f8718df2 spi flash: fix crash due to spi flash miscommunication
Higher spi flash layers expect to be given back a pointer that was
malloced so that it can free the result, but the lower layers return
a pointer that is in the middle of the malloced memory. Reorder the
members of the lower spi structures so that things work out.

Signed-off-by: Brad Bozarth <bflinux@yumbrad.com>
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Acked-by: Haavard Skinnemoen <haavard.skinnemoen@atmel.com>
2009-01-24 01:57:40 +01:00
Niklaus Giger 94f9279f7b Added legacy flash ST Micro M29W040B 2009-01-24 01:22:22 +01:00
Mike Frysinger d4bade8d77 nand: fixup printf modifiers to match types used
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Signed-off-by: Scott Wood <scottwood@freescale.com>
2009-01-23 10:32:52 -06:00
Wolfgang Grandegger 6c869637fe NAND: rename NAND_MAX_CHIPS to CONFIG_SYS_NAND_MAX_CHIPS
This patch renames NAND_MAX_CHIPS to CONFIG_SYS_NAND_MAX_CHIPS and
changes the default from 8 to 1 for the legacy and the new MTD
NAND layer. This allows to remove all NAND_MAX_CHIPS definitions
in the board config files because none of the boards use multi
chip support (NAND_MAX_CHIPS > 1) so far. The bamboo and the DU440
define

 #define NAND_MAX_CHIPS          CONFIG_SYS_MAX_NAND_DEVICE

but that's bogus and did not work anyhow.

Signed-off-by: Wolfgang Grandegger <wg@grandegger.com>
Signed-off-by: Scott Wood <scottwood@freescale.com>
2009-01-23 10:32:51 -06:00
Nishanth Menon 50657c2732 NAND: Enable nand lock, unlock feature
Enable nand lock, unlock and status of lock feature.
Not every device and platform requires this, hence,
it is under define for CONFIG_CMD_NAND_LOCK_UNLOCK

Nand unlock and status operate on block boundary instead
of page boundary. Details in:
http://www.micron.com/products/partdetail?part=MT29C2G24MAKLAJG-6%20IT

Intial solution provided by Vikram Pandita <vikram.pandita@ti.com>
Includes preliminary suggestions from Scott Wood

Signed-off-by: Nishanth Menon <nm@ti.com>
Signed-off-by: Scott Wood <scottwood@freescale.com>
2009-01-23 10:32:49 -06:00
Mike Frysinger 69fb8be4fc NAND: move board_nand_init to nand.h
Rather than putting the function prototype for board_nand_init() in the one
place where it gets called, put it into nand.h so that every place that also
defines it gets the prototype.  Otherwise, errors can go silently unnoticed
such as using the wrong return value (void rather than int) when defining
the function.

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Signed-off-by: Scott Wood <scottwood@freescale.com>
2009-01-23 10:32:49 -06:00
Stefan Roese 1ae3986204 OneNAND: Additional sync with 2.6.27
- Add subpage write support
- Add onenand_oob_64/32 ecclayout

This has been missing and without it UBI has some incompatibilies issues
with the current (>= 2.6.27) Linux kernel version. vid_hdr_offset is
placed differently (2048 instead of 512) without this fix.

Signed-off-by: Stefan Roese <sr@denx.de>
Signed-off-by: Scott Wood <scottwood@freescale.com>
2009-01-23 10:32:48 -06:00
Kyungmin Park 1714f51a20 Add markbad function
Add missing markbad function
If not, it's hang when it entered the mtd->mark_bad().

Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
2009-01-23 10:32:47 -06:00
Stefan Roese 8cf11f3aa7 OneNAND: Save version_id in onenand_chip struct
The version (ver_id) was not stored in the onenand_chip structure and
because of this the continuous locking scheme could be enabled on some
chips.

Signed-off-by: Stefan Roese <sr@denx.de>
2009-01-23 10:32:46 -06:00
Stefan Roese 4fca3310d6 OneNAND: Fix compiler warnings
Signed-off-by: Stefan Roese <sr@denx.de>
2009-01-23 10:32:45 -06:00
Kyungmin Park ef0921d6b0 Sync with 2.6.27
Sync with OneNAND kernel codes

Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
2009-01-23 10:32:44 -06:00
Wolfgang Denk f85cd46918 Merge branch 'master' of git://git.denx.de/u-boot-mpc85xx 2008-12-30 23:30:47 +01:00
Kumar Gala 9d94aff699 NAND FSL elbc: Use virt_to_phys to determine which bank is in use
The current code that determines which bank/chipselect is used for a
given NAND instance only worked for 32-bit addresses and assumed
a 1:1 mapping.  This breaks in 36-bit physical configs.

The proper way to handle this is to use the virt_to_phys() and
BR_PHYS_ADDR() routinues to match the 34-bit lbc bus address
with the the virtual address the NAND code uses.

Signed-off-by: Kumar Gala <galak@kernel.crashing.org>
Acked-by: Scott Wood <scottwood@freescale.com>
2008-12-19 18:20:08 -06:00
Scott Wood ff49ea8977 NAND: Mark the BBT as scanned prior to calling scan_bbt.
Otherwise, recursion can occur if scan_bbt does not find a bad block
table, and tries to write one, and the attempt to erase the BBT area
causes a bad block check.

Signed-off-by: Scott Wood <scottwood@freescale.com>
2008-12-16 14:40:34 -06:00
Wolfgang Denk 455ae7e87f Coding style cleanup, update CHANGELOG.
Signed-off-by: Wolfgang Denk <wd@denx.de>
2008-12-16 01:02:17 +01:00
Mike Frysinger 84bc72d90c spi/stmicro: fix debug() display of cmd
The stmicro_wait_ready() func tries to show the actual opcode that was sent
to the device, but instead it displays the array pointer.  Fix it to pull
out the opcode from the start of the array.

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
2008-12-16 00:48:18 +01:00
Stefan Roese 8173293516 UBI: Return -ENOMEM upon failing malloc
Return with correct error code (-ENOMEM) from ubi_attach_mtd_dev() upon
failing malloc().

Signed-off-by: Stefan Roese <sr@denx.de>
2008-12-10 12:55:23 +01:00
Stefan Roese 2ee951ba2a UBI: Enable re-initializing of the "ubi part" command
With this patch now, the user can call "ubi part" multiple times to
re-connect the UBI device to another MTD partition.

Signed-off-by: Stefan Roese <sr@denx.de>
2008-12-09 10:07:36 +01:00
Stefan Roese 9def12cae3 MTD: Fix problem based on non-working relocation (list head mtd_partitions)
Don't use LIST_HEAD() but initialize the struct via INIT_LIST_HEAD() upon
first call of add_mtd_partitions(). Otherwise this won't work on platforms
where the relocation is broken (like MIPS or PPC).

Signed-off-by: Stefan Roese <sr@denx.de>
2008-12-09 10:07:23 +01:00
Ilko Iliev bd876772ee mtd/dataflash.c: fix a problem with the last partition
This patch fix the problem that only the [NB_DATAFLASH_AREA - 1] dataflash
partition can be defined to use the area to the end of dataflash size.
Now it is possible to have only one dataflash partition from 0 to the end
of of dataflash size.

Signed-off-by: Ilko Iliev <iliev@ronetix.at>
2008-12-02 21:53:24 +01:00
Ilko Iliev 03f797793b fix some coding style violations.
This patch fix some coding style violations.

Signed-off-by: Ilko Iliev <iliev@ronetix.at>
2008-12-02 21:53:22 +01:00
Scott Wood 2077e348c2 NAND: Fix misplaced return statement in nand_{read,write}_skip_bad().
This caused the operation to be needlessly repeated if there were
no bad blocks and no errors.

Signed-off-by: Valeriy Glushkov <gvv@lstec.com>
Signed-off-by: Scott Wood <scottwood@freescale.com>
2008-11-25 10:47:02 -06:00
Wolfgang Denk f9b354faa0 Merge branch 'master' of git://git.denx.de/u-boot-ubi 2008-11-25 11:40:57 +01:00
Piotr Ziecik e6a7edbc17 mtd: Remove a printf() from add_mtd_device().
Remove a printf() from add_mtd_device(), which produces spurious output.

Signed-off-by: Piotr Ziecik <kosmo@semihalf.com>
Signed-off-by: Stefan Roese <sr@denx.de>
2008-11-24 11:29:53 +01:00
Piotr Ziecik 91809ed51d cfi-mtd: Add cfi-mtd driver.
Add cfi-mtd driver, which exports CFI flash to MTD layer.
This allows CFI flash devices to be used from MTD layer.

Building of the new driver is controlled by CONFIG_FLASH_CFI_MTD
option. Initialization is done by calling cfi_mtd_init() from
flash_init().

Signed-off-by: Piotr Ziecik <kosmo@semihalf.com>
Signed-off-by: Stefan Roese <sr@denx.de>
2008-11-24 11:05:25 +01:00
Piotr Ziecik 6ea808efdf cfi_flash: Add interface for flash verbosity control
Add interface for flash verbosity control. It allows
to disable output from low-level flash API. It is useful
when calling these low-level functions from context other
than flash commands (for example the MTD/CFI interface
implmentation).

Signed-off-by: Piotr Ziecik <kosmo@semihalf.com>
Signed-off-by: Stefan Roese <sr@denx.de>
2008-11-24 10:55:36 +01:00
Piotr Ziecik ebc9784ce6 cfi_flash: Export flash_sector_size() function.
Export flash_sector_size() function from drivers/mtd/cfi_flash.c,
so that it can be used in the upcoming cfi-mtd driver.

Signed-off-by: Piotr Ziecik <kosmo@semihalf.com>
Signed-off-by: Stefan Roese <sr@denx.de>
2008-11-24 10:55:35 +01:00
Stefan Roese 45aa5a7f4d cfi_flash: Make all flash access functions weak
This patch defines all flash access functions as weak so that
they can be overridden by board specific versions.

This will be used by the upcoming VCTH board support where the NOR
FLASH unfortunately can't be accessed memory-mapped. Special
accessor functions are needed here.

To enable this weak functions you need to define
CONFIG_CFI_FLASH_USE_WEAK_ACCESSORS in your board config header.
Otherwise the "old" default functions will be used resulting
in smaller code.

Signed-off-by: Stefan Roese <sr@denx.de>
Acked-by: Haavard Skinnemoen <haavard.skinnemoen@atmel.com>
2008-11-24 10:55:35 +01:00
Kyungmin Park c91a719daa UBI: Add basic UBI support to U-Boot (Part 5/8)
This patch adds basic UBI (Unsorted Block Image) support to U-Boot.
It's based on the Linux UBI version and basically has a "OS"
translation wrapper that defines most Linux specific calls
(spin_lock() etc.) into no-ops. Some source code parts have been
uncommented by "#ifdef UBI_LINUX". This makes it easier to compare
this version with the Linux version and simplifies future UBI
ports/bug-fixes from the Linux version.

Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
Signed-off-by: Stefan Roese <sr@denx.de>
2008-11-19 20:34:39 +01:00
Kyungmin Park f412fefa07 UBI: Add basic UBI support to U-Boot (Part 4/8)
This patch adds basic UBI (Unsorted Block Image) support to U-Boot.
It's based on the Linux UBI version and basically has a "OS"
translation wrapper that defines most Linux specific calls
(spin_lock() etc.) into no-ops. Some source code parts have been
uncommented by "#ifdef UBI_LINUX". This makes it easier to compare
this version with the Linux version and simplifies future UBI
ports/bug-fixes from the Linux version.

Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
Signed-off-by: Stefan Roese <sr@denx.de>
2008-11-19 20:34:39 +01:00
Kyungmin Park 2d262c4853 UBI: Add basic UBI support to U-Boot (Part 3/8)
This patch adds basic UBI (Unsorted Block Image) support to U-Boot.
It's based on the Linux UBI version and basically has a "OS"
translation wrapper that defines most Linux specific calls
(spin_lock() etc.) into no-ops. Some source code parts have been
uncommented by "#ifdef UBI_LINUX". This makes it easier to compare
this version with the Linux version and simplifies future UBI
ports/bug-fixes from the Linux version.

Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
Signed-off-by: Stefan Roese <sr@denx.de>
2008-11-19 20:34:39 +01:00
Kyungmin Park 961df83361 UBI: Add basic UBI support to U-Boot (Part 2/8)
This patch adds basic UBI (Unsorted Block Image) support to U-Boot.
It's based on the Linux UBI version and basically has a "OS"
translation wrapper that defines most Linux specific calls
(spin_lock() etc.) into no-ops. Some source code parts have been
uncommented by "#ifdef UBI_LINUX". This makes it easier to compare
this version with the Linux version and simplifies future UBI
ports/bug-fixes from the Linux version.

Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
Signed-off-by: Stefan Roese <sr@denx.de>
2008-11-19 20:34:39 +01:00
Kyungmin Park f399d4a281 UBI: Add basic UBI support to U-Boot (Part 1/8)
This patch adds basic UBI (Unsorted Block Image) support to U-Boot.
It's based on the Linux UBI version and basically has a "OS"
translation wrapper that defines most Linux specific calls
(spin_lock() etc.) into no-ops. Some source code parts have been
uncommented by "#ifdef UBI_LINUX". This makes it easier to compare
this version with the Linux version and simplifies future UBI
ports/bug-fixes from the Linux version.

Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
Signed-off-by: Stefan Roese <sr@denx.de>
2008-11-19 20:34:39 +01:00
Kyungmin Park e29c22f5ab MTD: Add MTD paritioning infrastructure
This MTD part infrastructure will be used by the upcoming
UBI support.

Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
Signed-off-by: Stefan Roese <sr@denx.de>
2008-11-19 20:34:39 +01:00
Wolfgang Denk 9abda6ba73 CFI Driver: Fix "flash not ready" problem
This patch fixes a problem on systems where the NOR flash is attached
to a 64 bit bus.  The toggle bit detection in flash_toggle() is based
on the assumption that the same flash address is read twice without
any other interjacent flash accesses.  However, on 32 bit systems the
function flash_read64() [as currently implemented] does not perform
an atomic 64 bit read - instead, this is broken down into two 32 bit
read accesses on addresses "addr" and "addr + 4".  So instead of
reading a 64 bit value twice from "addr", we see a sequence of 4 32
bit reads from "addr", "addr + 4", "addr", and "addr + 4".  The
consequence is that flash_toggle() fails to work.

This patch implements a simple, but somewhat ugly solution, as it
avoids the use of flash_read64() in this critical place (by breaking
it down manually into 32 bit read operations) instead of rewriting
flash_read64() such to perform atomic 64 bit reads as one could
expect.  However, such a rewrite would require the use of floating
point load operations, which becomes pretty complex:

	save MSR;
	set Floating Point Enable bit in MSR;
	use "lfd" instruction to perform atomic 64 bit read;
	use "stfd" to store value to temporary variable on stack;
	load u64 value from temporary variable;
	restore saved MSR;
	return u64 value;

The benefit-cost ratio of such an implementation was considered too
bad to actually attempt this, especially as we can expect that such
an implementation would not only have a bigger memory footprint but
also cause a performance degradation.

Signed-off-by: Wolfgang Denk <wd@denx.de>
Signed-off-by: Stefan Roese <sr@denx.de>
2008-10-31 11:32:53 +01:00
Scott Wood bd78bc6b2a NAND: Properly create JFFS2 cleanmarkers.
As reported by Ilko Iliev <iliev@ronetix.at>, the "nand erase clean"
command is currently broken, and among other things causes all blocks
to be marked bad.

This implements it properly using MTD_OOB_AUTO, along with some
indentation fixes.

Signed-off-by: Scott Wood <scottwood@freescale.com>
2008-10-29 14:20:26 -05:00
Scott Wood f7fe57c098 NAND fsl elbc: Set FMR[ECCM] based on page size.
Hardware expects ECCM 0 for small page and ECCM 1 for large page
when booting from NAND, so use those defaults.

Signed-off-by: Scott Wood <scottwood@freescale.com>
2008-10-29 13:42:41 -05:00
Haiying Wang 4e190b03aa Make Freescale local bus registers available for both 83xx and 85xx.
- Rename lbus83xx_t to fsl_lbus_t and move it to asm/fsl_lbc.h so that it
  can be shared by both 83xx and 85xx
- Remove lbus83xx_t and replace it with fsl_lbus_t in all 83xx boards
  files which use lbus83xx_t.
- Move FMR, FIR, FCR, FPAR, LTESR from mpc83xx.h to asm/fsl_lbc.h so that
  85xx can share them.

Signed-off-by: Jason Jin <Jason.Jin@freescale.com>
Signed-off-by: Haiying Wang <Haiying.Wang@freescale.com>
Signed-off-by: Scott Wood <scottwood@freescale.com>
2008-10-29 11:12:53 -05:00
Karl Beldan 33efde5eca NAND: Reset chip on power-up
Some chips require a RESET after power-up (e.g. Micron MT29FxGxxxxx).
The first command sent is NAND_CMD_READID.
Issue a NAND_CMD_RESET in nand_scan_ident before reading the device id.
Tested with an MT29F4G08AAC.

Signed-off-by: Karl Beldan <karl.beldan@gmail.com>
Signed-off-by: Scott Wood <scottwood@freescale.com>
2008-10-29 10:42:17 -05:00
Scott Wood c45912d8ab NAND: sync with 2.6.27
This brings the core NAND code up to date with the Linux kernel.

Since there were several drivers in Linux as of the last update that are
not in u-boot, I'm not bringing over new drivers that have been added
since in the absence of an interested party.

I did not update OneNAND since it was recently synced by Kyungmin Park,
and I'm not sure exactly what the common ancestor is.

Signed-off-by: Scott Wood <scottwood@freescale.com>
2008-10-29 10:42:16 -05:00
Jean-Christophe PLAGNIOL-VILLARD 6d0f6bcf33 rename CFG_ macros to CONFIG_SYS
Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
2008-10-18 21:54:03 +02:00
Jason Jin fecb5ade3b Fix the NAND size overflow issue.
When the total size of all NAND devices exceeds 4 GiB, the size  will
overflow. This patch tries to fix this.

Note that we still have a problem when a single NAND device is bigger
than 4 GiB: then the overflow would actually happen earlier, i. e.
when storing the size in nand_info[].size, as nand_info[].size is an
"u_int32_t".

Signed-off-by: Jason Jin <Jason.jin@freescale.com>
Signed-off-by: Wolfgang Denk <wd@denx.de>
2008-10-14 13:27:16 +02:00
Ed Swarthout 0d01f66d23 CFI: cfi_flash write fix for AMD legacy
The flash_unlock_seq requires a sector for AMD_LEGACY.
Fix a retcode check typeo.

Signed-off-by: Ed Swarthout <Ed.Swarthout@freescale.com>
Signed-off-by: Stefan Roese <sr@denx.de>
2008-10-13 13:51:21 +02:00
Mike Frysinger 2215987e10 cfi_flash: do not reset flash when probe fails
The CFI flash driver starts at flash_init() which calls down into
flash_get_size().  This starts by calling flash_detect_cfi().  If said
function fails, flash_get_size() finishes by attempting to reset the
flash.  Unfortunately, it does this with an info->portwidth set to 0x10
which filters down into flash_make_cmd() and that happily smashes the
stack by sticking info->portwidth bytes into a cfiword_t variable that
lives on the stack.  On a 64bit system you probably won't notice, but
killing the last 8 bytes on a 32bit system usually leads to a corrupt
return address.  Which is what happens on a Blackfin system.

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Signed-off-by: Stefan Roese <sr@denx.de>
2008-10-02 10:30:32 +02:00
Wolfgang Denk 508eb85db7 Merge branch 'master' of git://git.denx.de/u-boot-nand-flash 2008-09-13 01:45:56 +02:00
Anton Vorontsov 0008b6d968 fsl_elbc_nand: ecclayout cleanups
This patch deletes oobavail assignments, they're calculated by the nand
core code in nand_scan_tail, plus current oobavail values are wrong for
the LP NANDs.

Signed-off-by: Anton Vorontsov <avorontsov@ru.mvista.com>
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
Signed-off-by: Scott Wood <scottwood@freescale.com>
2008-09-12 14:58:33 -05:00
Anton Vorontsov 8f42bf1c39 fsl_elbc_nand: implement support for flash-based BBT
This patch implements support for flash-based BBT for chips working
through ELBC NAND controller, so that NAND core will not have to re-scan
for bad blocks on every boot.

Because ELBC controller may provide HW-generated ECCs we should adjust
bbt pattern and bbt version positions in the OOB free area.

Signed-off-by: Anton Vorontsov <avorontsov@ru.mvista.com>
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
Signed-off-by: Scott Wood <scottwood@freescale.com>
2008-09-12 14:57:20 -05:00
Anton Vorontsov 97ae023648 fsl_elbc_nand: fix OOB workability for large page NAND chips
For large page chips, nand_bbt is looking into OOB area, and checking
for "0xff 0xff" pattern at OOB offset 0. That is, two bytes should be
reserved for bbt means.

But ELBC driver is specifying ecclayout so that oobfree area starts at
offset 1, so only one byte left for the bbt purposes.

This causes problems with any OOB users, namely JFFS2: after first mount
JFFS2 will fill all OOBs with "erased marker", so OOBs will contain:

  OOB Data: ff 19 85 20 03 00 ff ff ff 00 00 08 ff ff ff ff
  OOB Data: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
  OOB Data: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff
  OOB Data: ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff

And on the next boot, NAND core will rescan for bad blocks, then will
see "0xff 0x19" pattern, and will mark all blocks as bad ones.

To fix the issue we should implement our own bad block pattern: just one
byte at OOB start. Though, this will work only for x8 chips. For x16
chips two bytes must be checked. Since ELBC driver does not support x16
NANDs (yet), we're safe for now.

Signed-off-by: Anton Vorontsov <avorontsov@ru.mvista.com>
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
Signed-off-by: Scott Wood <scottwood@freescale.com>
2008-09-12 14:56:03 -05:00
Jean-Christophe PLAGNIOL-VILLARD 0e8d158664 rename CFG_ENV macros to CONFIG_ENV
Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
2008-09-10 22:48:06 +02:00
Jean-Christophe PLAGNIOL-VILLARD 5a1aceb068 rename CFG_ENV_IS_IN_FLASH in CONFIG_ENV_IS_IN_FLASH
Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
2008-09-10 22:48:04 +02:00
Wolfgang Denk f6808c48a5 Merge branch 'master' of git://git.denx.de/u-boot-mpc85xx 2008-09-10 11:07:35 +02:00
Andrew Klossner 5251469943 Fix printf errors under -DDEBUG
Fix printf format-string/arg mismatches under -DDEBUG.

These warnings occur with DEBUG defined for a platform using
cpu/mpc85xx.  Users of other architectures can unearth similar
problems by adding the line "CFLAGS += -DDEBUG=1" in config.mk right
after "CFLAGS += $(call cc-option,-fno-stack-protector)".

Signed-off-by: Andrew Klossner <andrew@cesa.opbu.xerox.com>
Signed-off-by: Andy Fleming <afleming@freescale.com>
2008-09-09 17:02:41 -05:00
TsiChung Liew 7b7a869a8b mtd: SPI Flash: Support the STMicro Flash
Add MTD SPI Flash support for M25P16, M25P20, M25P32,
M25P40, M25P64, M25P80, M25P128.

Signed-off-by: Jason McMullan <mcmullan@netapp.com>
Signed-off-by: TsiChung Liew <Tsi-Chung.Liew@freescale.com>
2008-09-09 11:57:29 -06:00
Graeme Russ 3ef96ded38 Update i386 code (sc520_cdp)
Attempt to bring i386 / sc520 inline with master

Signed-off-by: Graeme Russ <graeme.russ@gmail.com>
2008-09-09 11:48:53 +02:00
Guennadi Liakhovetski e0056b3410 NAND: add NAND driver for S3C64XX
Based on the original S3C64XX NAND driver by Samsung for U-Boot 1.1.6.

Signed-off-by: Guennadi Liakhovetski <lg@denx.de>
2008-08-31 00:39:47 +02:00
Wolfgang Denk a49d10cf02 Minor coding style cleanup, updte CHANGELOG
Signed-off-by: Wolfgang Denk <wd@denx.de>
2008-08-25 23:45:41 +02:00
Kyungmin Park bfd7f38614 Fix OneNAND read_oob/write_oob functions compatability
Also sync with kernel OneNAND codes

Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
Signed-off-by: Scott Wood <scottwood@freescale.com>
2008-08-21 13:50:20 -05:00
Nick Spence 9e8e63cce6 CFI: Add CFI_CMDSET_INTEL_EXTENDED to fix flash_real_protect()
This patch fixes a missing vendor code in the flash_real_protect() function.

Signed-off-by: Nick Spence <nick.spence@freescale.com>
Signed-off-by: Stefan Roese <sr@denx.de>
2008-08-20 14:24:08 +02:00
TsiChung Liew 4e00acded2 CFI: Fix AMD Legacy sector protect
New implement sector lock and unlock or softlock commands
do not exist in AMD legacy flash. Thus, causing issue
when erasing AMD legacy flash (such as lv040)

Signed-off-by: TsiChung Liew <Tsi-Chung.Liew@freescale.com>
Signed-off-by: Stefan Roese <sr@denx.de>
2008-08-20 14:21:46 +02:00
Wolfgang Denk 855efd04e4 Merge branch 'master' of git://git.denx.de/u-boot-cfi-flash 2008-08-14 14:56:40 +02:00
Wolfgang Denk 4b0708093e Coding Style cleanup, update CHANGELOG
Signed-off-by: Wolfgang Denk <wd@denx.de>
2008-08-14 14:41:06 +02:00
Wolfgang Denk 28ac671910 Merge branch 'master' of git://git.denx.de/u-boot-nand-flash 2008-08-14 11:26:22 +02:00
Stefan Roese becbbc7b2a Merge branch 'master' of /home/stefan/git/u-boot/u-boot into next 2008-08-14 08:25:13 +02:00
Kyungmin Park d438d50848 Fix OneNAND build break
Since page size field is changed from oobblock to writesize. But OneNAND is not updated.
- fix bufferram management at erase operation
This patch includes the NAND/OneNAND state filed too.

Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
Signed-off-by: Scott Wood <scottwood@freescale.com>
2008-08-13 11:00:19 -05:00
Jean-Christophe PLAGNIOL-VILLARD 9483df6408 drivers/mtd/nand_legacy: Move conditional compilation to Makefile
Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
2008-08-13 01:40:43 +02:00
Jean-Christophe PLAGNIOL-VILLARD cc4a0ceeac drivers/mtd/nand: Move conditional compilation to Makefile
rename CFG_NAND_LEGACY to CONFIG_NAND_LEGACY

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
2008-08-13 01:40:43 +02:00
Jean-Christophe PLAGNIOL-VILLARD 4fb09b8192 drivers/mtd/onenand: Move conditional compilation to Makefile
Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
2008-08-13 01:40:42 +02:00
Jean-Christophe PLAGNIOL-VILLARD 00b1883a4c drivers/mtd: Move conditional compilation to Makefile
rename CFG_FLASH_CFI_DRIVER to CONFIG_FLASH_CFI_DRIVER

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
2008-08-13 01:40:42 +02:00
Fathi BOUDRA 195ccfc599 OneNAND: Fill in MTD function pointers for OneNAND.
onenand_print_device_info():
 - Now returns a string to be placed in mtd->name,
   rather than calling printf.
 - Remove verbose parameter as it becomes useless.

Signed-off-by: Fathi Boudra <fabo@debian.org>
Signed-off-by: Scott Wood <scottwood@freescale.com>
2008-08-12 11:31:32 -05:00
Marcel Ziswiler eafcabd15f NAND: chip->state does not always get set.
Fixes an issue with chip->state not always being set causing troubles.

Signed-off-by: Marcel Ziswiler <marcel@ziswiler.com>
Signed-off-by: Scott Wood <scottwood@freescale.com>
2008-08-12 11:31:29 -05:00
Ilya Yanok 13f0fd94e3 NAND: Scan bad blocks lazily.
Rather than scanning on boot, scan upon the first attempt to check the
badness of a block.  This speeds up boot when not using NAND, and reduces
the likelihood of needing to reflash via JTAG if NAND becomes
nonfunctional.

Signed-off-by: Ilya Yanok <yanok@emcraft.com>
Signed-off-by: Scott Wood <scottwood@freescale.com>
2008-08-12 11:31:28 -05:00
Scott Wood dfbf617ff0 NAND read/write fix
Implement block-skipping read/write, based on a patch from
Morten Ebbell Hestens <morten.hestnes@tandberg.com>.

Signed-off-by: Morten Ebbell Hestnes <morten.hestnes@tandberg.com>
Signed-off-by: Scott Wood <scottwood@freescale.com>
2008-08-12 11:31:28 -05:00
Anton Vorontsov e1c3dbada3 nand: fsl_upm: convert to updated MTD NAND infrastructure
Signed-off-by: Anton Vorontsov <avorontsov@ru.mvista.com>
Signed-off-by: Scott Wood <scottwood@freescale.com>
2008-08-12 11:31:27 -05:00
Scott Wood 300253306a fsl_elbc_nand: Hard-code the FBAR/FPAR split.
The hardware has separate registers for block and page-within-block,
but the division between the two has no apparent relation to the
actual erase block size of the NAND chip.

Signed-off-by: Scott Wood <scottwood@freescale.com>
2008-08-12 11:31:26 -05:00
Anton Vorontsov 9c814b0a71 fsl_elbc_nand: workaround for hangs during nand write
Using current driver elbc sometimes hangs during nand write. Reading back
last byte helps though (thanks to Scott Wood for the idea).

Signed-off-by: Anton Vorontsov <avorontsov@ru.mvista.com>
Signed-off-by: Scott Wood <scottwood@freescale.com>
2008-08-12 11:31:26 -05:00
Scott Wood 9fd020d6b4 Freescale eLBC FCM NAND driver
This is a driver for the Flash Control Machine of the enhanched Local Bus
Controller found on some Freescale chips (such as the mpc8313 and the
mpc8379).

Signed-off-by: Scott Wood <scottwood@freescale.com>
2008-08-12 11:31:25 -05:00
Scott Wood 41ef8c716e Don't panic if a controller driver does ecc its own way.
Some hardware, such as the enhanced local bus controller used on some
mpc83xx chips, does ecc transparently when reading and writing data, rather
than providing a generic calculate/correct mechanism that can be exported to
the nand subsystem.

The subsystem should not BUG() when calculate, correct, or hwctl are
missing, if the methods that call them have been overridden.

Signed-off-by: Scott Wood <scottwood@freescale.com>
2008-08-12 11:31:25 -05:00
Stefan Roese e52b34d40a NAND: Make NAND driver less verbose per default
This patch turns off printing of bad blocks per default upon bootup.
This can always be shown via the "nand bad" command later.

Signed-off-by: Stefan Roese <sr@denx.de>
2008-08-12 11:31:24 -05:00
Stefan Roese 1207226452 NAND: Change nand_wait_ready() to not call nand_wait()
This patch changes nand_wait_ready() to not just call nand_wait(),
since this will send a new command to the NAND chip. We just want to
wait for the chip to become ready here.

Signed-off-by: Stefan Roese <sr@denx.de>
2008-08-12 11:31:22 -05:00
William Juul 5e1dae5c3d Fixing coding style issues
- Fixing leading white spaces
 - Fixing indentation where 4 spaces are used instead of tab
 - Removing C++ comments (//), wherever I introduced them

Signed-off-by: William Juul <william.juul@tandberg.com>
Signed-off-by: Scott Wood <scottwood@freescale.com>
2008-08-12 11:31:17 -05:00
William Juul 4cbb651b29 Remove white space at end.
Signed-off-by: William Juul <william.juul@tandberg.com>
Signed-off-by: Scott Wood <scottwood@freescale.com>
2008-08-12 11:31:16 -05:00
William Juul cfa460adfd Update MTD to that of Linux 2.6.22.1
A lot changed in the Linux MTD code, since it was last ported from
Linux to U-Boot. This patch takes U-Boot NAND support to the level
of Linux 2.6.22.1 and will enable support for very large NAND devices
(4KB pages) and ease the compatibility between U-Boot and Linux
filesystems.

This patch is tested on two custom boards with PPC and ARM
processors running YAFFS in U-Boot and Linux using gcc-4.1.2
cross compilers.

MAKEALL ppc/arm has some issues:
 * DOC/OneNand/nand_spl is not building (I have not tried porting
   these parts, and since I do not have any HW and I am not familiar
   with this code/HW I think its best left to someone else.)

Except for the issues mentioned above, I have ported all drivers
necessary to run MAKEALL ppc/arm without errors and warnings. Many
drivers were trivial to port, but some were not so trivial. The
following drivers must be examined carefully and maybe rewritten to
some degree:
 cpu/ppc4xx/ndfc.c
 cpu/arm926ejs/davinci/nand.c
 board/delta/nand.c
 board/zylonite/nand.c

Signed-off-by: William Juul <william.juul@tandberg.com>
Signed-off-by: Stig Olsen <stig.olsen@tandberg.com>
Signed-off-by: Scott Wood <scottwood@freescale.com>
2008-08-12 11:31:15 -05:00
Steve Sakoman 4d57b0fb29 OneNAND: Remove unused parameters to onenand_verify_page
The block and page parameters of onenand_verify_page() are not used. This causes a compiler error when CONFIG_MTD_ONENAND_VERIFY_WRITE is enabled.

Signed-off-by: Steve Sakoman <steve@sakoman.com>
Signed-off-by: Dirk Behme <dirk.behme@gmail.com>
2008-08-11 15:07:46 -05:00
Wolfgang Denk dedec4cfc8 Merge branch 'master' of git://git.denx.de/u-boot-at91 2008-08-10 01:04:50 +02:00
Sergey Lapin f77d92a3f5 DataFlash: AT45DB021 fix and AT45DB081 support
Fix for page size of AT45DB021. Also adding bigger AT45DB081
which comes with some newer boards.

Signed-off-by: Sergey Lapin <slapin@ossfans.org>
2008-08-09 00:15:06 +02:00
Wolfgang Denk 2a112b234d CFI: allow for dynamically determined flash sizes and addresses
The CFI driver allowed only for static initializers in the
CFG_FLASH_BANKS_LIST definition, i. e. it did not allow to map
several flash banks contiguously if the bank sizes were not known in
advance, which kind of violates U-Boot's design philosophy.

(will be used for example by the TQM8xxL boards)

Signed-off-by: Wolfgang Denk <wd@denx.de>
2008-08-08 16:39:54 +02:00
Rafael Campos bc9019e197 cfi-flash: Added support to flash_real_protect for Atmel flash devices
Some of the flash memories produced by ATMEL start in read-only mode.
We need to unprotect it. This patch allows the AT49BV6416 to work with
cfi_flash memories. Tested in the at91rm9200ek board.

Signed-off-by: Rafael Campos Las Heras <rafael.campos@hanscan.com>
Signed-off-by: Stefan Roese <sr@denx.de>
2008-08-06 14:22:41 +02:00
Guennadi Liakhovetski 7949839e58 cfi-flash: Add definition for the AM29LV800BB AMD NOR-flash
Signed-off-by: Guennadi Liakhovetski <lg@denx.de>
Signed-off-by: Stefan Roese <sr@denx.de>
2008-08-06 14:19:06 +02:00
Haavard Skinnemoen a229d291f3 spi flash: Fix printf() format warnings
Signed-off-by: Haavard Skinnemoen <haavard.skinnemoen@atmel.com>
2008-07-23 16:15:01 +02:00
Sebastian Siewior 340ccb260f cfi_flash: fix flash on BE machines with CFG_WRITE_SWAPPED_DATA
This got broken by commits 93c56f212c
 [cfi_flash: support of long cmd in U-boot.]

That command needs to be in little endian format on BE machines
with CFG_WRITE_SWAPPED_DATA. Without this patch, the command 0xf0
gets saved on stack as 0x00 00 00 f0 and 0x00 gets written into
the cmdbuf in case portwidth = chipwidth = 8bit.

Cc: Alexey Korolev <akorolev@infradead.org>
Cc: Vasiliy Leonenko <vasiliy.leonenko@mail.ru>
Signed-off-by: Sebastian Siewior <bigeasy@linutronix.de>
2008-07-17 11:42:35 +02:00
Sebastian Siewior 7288f972fc cfi_flash: make the command u32 only
This got changed by commit 93c56f212c
[cfi_flash: support of long cmd in U-boot.]

Long is the wrong type because it will behave differently on 64bit
machines in a way that is probably not expected. u32 should be
enough.

Cc: Alexey Korolev <akorolev@infradead.org>
Cc: Vasiliy Leonenko <vasiliy.leonenko@mail.ru>
Signed-off-by: Sebastian Siewior <bigeasy@linutronix.de>
2008-07-15 21:42:04 +02:00
Jean-Christophe PLAGNIOL-VILLARD 0a5676befb Fix some more printf() format issues.
Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
2008-07-13 16:55:00 +02:00
Sergey Lapin c6457e3b8b DataFlash AT45DB021 support
Some boards based on AT91SAM926X-EK use smaller DF chips to keep
bootstrap, u-boot and its environment, using NAND or other external
storage for kernel and rootfs. This patch adds support for
small 1024x263 chip.

Signed-off-by: Sergey Lapin <slapin@ossfans.org>
2008-07-10 22:50:28 +02:00
Stefan Roese e870690bdc MTD/NAND: Fix printf format warning in nand code
This patch fixes NAND related printf format warning. Those warnings are
now visible since patch dc4b0b38d4
[Fix printf errors.] by Andrew Klossner has been applied. Thanks, this is
really helpful.

Signed-off-by: Stefan Roese <sr@denx.de>
2008-07-10 10:46:13 +02:00
Wolfgang Denk 40234535ee Merge branch 'master' of git://www.denx.de/git/u-boot-nand-flash 2008-07-10 00:59:04 +02:00
Scott Wood 3167c5386e NAND: Rename DEBUG to MTDDEBUG to avoid namespace pollution.
This is particularly problematic now that non-NAND-specific code is
including <nand.h>, and thus all debugging code is being compiled
regardless of whether it was requested, as reported by Scott McNutt
<smcnutt@psyent.com>.

Signed-off-by: Scott Wood <scottwood@freescale.com>
2008-07-09 17:24:47 -05:00
Stefan Roese 0192d7d56e jedec_flash: Fix AM29DL800BB device ID
As pointed out by Jerry Hicks, this patch corrects the device ID of
the Spansion AM29DL800BB NOR device. Verified against latest Spansion
datasheet (rev C4 from Dezember 2006).

Signed-off-by: Stefan Roese <sr@denx.de>
2008-07-08 12:57:14 +02:00
Stefan Roese fb8c061ea0 cfi-flash: Fix problem in flash_toggle(), busy was not detected reliably
This patch simplifies flash_toggle() (AMD commandset), which is used to
detect if a FLASH device is still busy with erase/program operations. On
800MHz Canyonlands/Glacier boards (460EX/GT) the current implementation
did not detect the busy state reliably, resulting in non erased sectors
etc. This patch now simplifies this function by "just" comparing the
complete data-word instead of ANDing it with the command-word (0x40)
before the compatison. It is done the same way in the Linux implementation
chip_ready() in cfi_cmdset_0002.c.

Signed-off-by: Stefan Roese <sr@denx.de>
2008-06-19 15:08:17 +02:00
Wolfgang Denk 1859e42fbf Merge branch 'master' of git://www.denx.de/git/u-boot-cfi-flash 2008-06-11 22:24:46 +02:00
Sergei Poselenov 248ae5cfc8 NAND: Added support for 128-bit OOB, adapted
Signed-off-by: Sergei Poselenov <sposelenov@emcraft.com>
2008-06-11 00:30:22 -05:00
Wolfgang Grandegger a75a57ef6e NAND FSL UPM: driver re-write using the hwcontrol callback
This is a re-write of the NAND FSL UPM driver using the more universal
hwcontrol callback (instead of the cmdfunc callback). Here is a brief
list of furher modifications:

- For the time being, the UPM setup writing the UPM array has been
  removed from the driver and must now be done by the board specific
  code.

- The bus width definition in "struct fsl_upm_nand" is now in bits to
  comply with the corresponding Linux driver and 8, 16 and 32 bit
  accesses are supported.

- chip->dev_read is only set if fun->dev_ready != NULL, which is
  required for boards not connecting the R/B pin.

- A few issue have been fixed with MxMR bit manipulation like in the
  corresponding Linux driver.

Note: I think the "io_addr" field of "struct fsl_upm" could be removed
      as well, because the address is already determined by
      "nand->IO_ADDR_[RW]", but I'm not 100% sure.

This patch has been tested on a TQM8548 modules with the NAND chip
Micron MT29F8G08FABWP.

This patch is based on the following patches posted to this list a few
minutes ago:

  PPC: add accessor macros to clear and set bits in one shot
  83xx/85xx/86xx: add more MxMR local bus definitions

Signed-off-by: Wolfgang Grandegger <wg@grandegger.com>
Acked-by: Anton Vorontsov <avorontsov@ru.mvista.com>
2008-06-10 18:22:26 -05:00
Vasiliy Leoenenko 9c048b5234 cfi_flash: enable M18 flash chips family support.
Added new command set ID. Buffered write command processing is changed
in order to support M18 flash chips family.

Signed-off-by: Alexey Korolev <akorolev@infradead.org>
Signed-off-by: Vasiliy Leonenko <vasiliy.leonenko@mail.ru>
2008-06-03 21:02:34 +02:00
Vasiliy Leoenenko 93c56f212c cfi_flash: support of long cmd in U-boot.
Some NOR flash chips needs support of commands with length grether than max
value size of uchar. For example all M18 family chips use 0x1ff command in
buffered write mode as value of program loops count.

Signed-off-by: Alexey Korolev <akorolev@infradead.org>
Signed-off-by: Vasiliy Leonenko <vasiliy.leonenko@mail.ru>
2008-06-03 21:01:55 +02:00
Haavard Skinnemoen d25ce7d24c SPI Flash subsystem
This adds a new SPI flash subsystem.

Currently, only AT45 DataFlash in non-power-of-two mode is supported,
but some preliminary support for other flash types is in place as
well.

Signed-off-by: Haavard Skinnemoen <haavard.skinnemoen@atmel.com>
2008-06-03 20:31:34 +02:00
Kumar Gala f979690ee3 Fix warnings from gcc-4.3.0 build on a ppc host
* The cfi_flash.c memset fix actual allows the board to boot so there is
  a bit more going on here than just resolving warnings associated with
  uninitialized variables.

* include/asm/bitops.h:302: warning: '__swab32p' is static but used in
  inline function 'ext2_find_next_zero_bit' which is not static

Signed-off-by: Kumar Gala <galak@kernel.crashing.org>
2008-06-03 19:52:52 +02:00
Dirk Behme 9723bbb46a nand: Correct NAND erase percentage output
For NAND erase sizes smaller than one NAND erase block, erase
percentage output becomes grater than 100% e.g.

-- cut --
  > nand info
Device 0: NAND 64MiB 1,8V 8-bit, sector size 16 KiB
  > nand erase 0x100000 0x2000
NAND erase: device 0 offset 0x100000, size 0x2000
Erasing at 0x100000 -- 200% complete.
OK
  >
-- cut --

Correct this and give user a warning that more is erased than specified:

-- cut --
  > nand erase 0x100000 0x2000
NAND erase: device 0 offset 0x100000, size 0x2000
Warning: Erase size 0x00002000 smaller than one erase block 0x00004000
           Erasing 0x00004000 instead
Erasing at 0x100000 -- 100% complete.
OK
  >
-- cut --

Signed-off-by: Dirk Behme <dirk.behme@gmail.com>
2008-05-28 11:06:27 -05:00
Wolfgang Denk 53677ef18e Big white-space cleanup.
This commit gets rid of a huge amount of silly white-space issues.
Especially, all sequences of SPACEs followed by TAB characters get
removed (unless they appear in print statements).

Also remove all embedded "vim:" and "vi:" statements which hide
indentation problems.

Signed-off-by: Wolfgang Denk <wd@denx.de>
2008-05-21 00:14:08 +02:00
Wolfgang Denk d2c6fbec43 onenand: rename 16 bit memory copy into memcpy_16() to avoid conflicts
Onenand needs a version of memcpy() which performs 16 bit accesses
only; make sure the name does not conflict with the standard
function.

Signed-off-by: Wolfgang Denk <wd@denx.de>
2008-05-01 21:30:16 +02:00
Matthias Fuchs c63ad6325a cfi-flash: Add CFG_FLASH_AUTOPROTECT_LIST
This patch adds a configurable flash auto protection list that can be used
to make U-Boot protect flash regions in flash_init().

The idea has been discussed on the u-boot mailing list starting
on Nov 18th, 2007.

Even this patch brings a new feature it is used as a bugfix for 4xx
platforms where flash_init() does not completely protect the
monitor's flash range in all situations.

U-Boot protects the flash range from CFG_MONITOR_BASE to
(CFG_MONITOR_BASE + monitor_flash_len  - 1) by default. This does not
include the reset vector at 0xfffffffc.

Example:
#define CFG_FLASH_AUTOPROTECT_LIST {{0xfff80000, 0x80000}}

This config option will auto protect the last 512k of flash that
contains the bootloader on board like APC405 and PMC405.

Signed-off-by: Matthias Fuchs <matthias.fuchs@esd-electronics.com>
2008-04-25 15:52:14 +02:00
Troy Kisky 84c01d3a05 PATCH - Fix oob data copied into supplied buffer
This patch correctly sets the oobavail variable
and fixes a bug where the oob data was not valid when
there where multiple groups in oobfree.

First segment fixes a typo
Second segment fixes a bug where oob data may be copied incorrectly.
Third segment adds an error message when exiting due to write protect.
Forth segment fixes a bug where oobavail may be set incorrectly.

Signed-off-by: Troy Kisky <troy.kisky@boundarydevices.com>
2008-04-21 08:43:46 +02:00
Ulf Samuelsson c3a60cb3bd Clean up dataflash partitioning
This patch removes the board dependent parts from
"drivers/mtd/dataflash.c".
Each board relying on this, will have the appropriate
code in a new file, "partition.c" in the board directory.
board Makefiles updated to use the file.

The dataflash partitions are aligned on sector/page boundaries.

The CONFIG_NEW_DF_PARTITION was used to create named partitions
This is now the default operation, and the CONFIG variable is removed.

Signed-off-by: Ulf Samuelsson <ulf@atmel.com>
2008-04-18 00:24:05 -07:00
Mike Frysinger e25cb8d3f4 Remove conflicting NAND ID
There are two NAND entries with ID 0xDC and this obviously causes problems.
In the kernel, they punted the first entry, so we should do the same.

See this upstream e-mail for more info:
http://lists.infradead.org/pipermail/linux-mtd/2007-July/018795.html

Signed-off-by: Michael Hennerich <michael.hennerich@analog.com>
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
2008-04-17 14:56:56 -07:00
Kyungmin Park 77e475cc0e Fix OneNAND read
It should access with 16-bit instead of 8-bit

Now it uses the generic memcpy with 8-bit access. It means it reads wrong data from OneNAND.

Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
2008-04-13 23:11:16 -07:00
Guennadi Liakhovetski 96ef831f71 cfi_flash: Support buffered writes on non-standard Spansion NOR flash
Some NOR flash chip from Spansion, for example, the s29ws-n MirrorBit
series require different addresses for buffered write commands. Define a
configuration option to support buffered writes on those chips. A more
elegant solution would be to automatically detect those chips by parsing
their CFI records, but that would require introduction of a fixup table
into the cfi_flash driver.

Signed-off-by: Guennadi Liakhovetski <lg@denx.de>
2008-04-12 08:59:09 +02:00
Wolfgang Denk a1b215e2a2 Merge branch 'master' of git://www.denx.de/git/u-boot-at91 2008-04-08 00:16:36 +02:00
Jean-Christophe PLAGNIOL-VILLARD b5873f1732 dataflash: Move CONFIG_HAS_DATAFLASH to Makefile
Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
2008-04-01 07:30:51 +02:00
Stelian Pop 5604e2178c Cleanup DataFlash partition handling
DataFlash partition information has become a mess. This patch
defines a single partition scheme for Atmel DataFlashes. This partition
scheme will be used by all AT91CAP9 and AT91SAM9 boards.

Signed-off-by: Stelian Pop <stelian@popies.net>
2008-04-01 01:43:59 +02:00
Daniel Hellstrom 97bf85d784 MTD/CFI: flash_read64 is defined a weak function (for SPARC)
SPARC has implemented __raw_readq, it reads 64-bit from any 32-bit address.
SPARC CPUs implement flash_read64 which calls __raw_readq.

For current SPARC architectures (LEON2 and LEON3) each read from the
FLASH must lead to a cache miss. This is because FLASH can not be set
non-cacheable since program code resides there, and alternatively disabling
cache is poor from performance view, or doing a cache flush between each
read is even poorer.

Forcing a cache miss on a SPARC is done by a special instruction "lda" -
load alternative space, the alternative space number (ASI) is processor
implementation spcific and can be found by including <asm/processor.h>.

Signed-off-by: Daniel Hellstrom <daniel@gaisler.com>
2008-03-29 06:51:04 +01:00
Tor Krill 90447ecbba MTD/CFI: Add support for 16bit legacy AMD flash
Add entry for 512Kx16 AMD flash to jedec_table.
Read out 16bit device id if chipwidth is 16bit.
Fixed coding style after Stefans feedback

Signed-off-by: Tor Krill <tor@excito.com>
2008-03-28 11:44:23 +01:00
Kyungmin Park 1bb707c39a Add Flex-OneNAND booting support
Flex-OneNAND is a monolithic integrated circuit with a NAND Flash array
using a NOR Flash interface. This on-chip integration enables system designers
to reduce external system logic and use high-density NAND Flash
in applications that would otherwise have to use more NOR components.

Flex-OneNAND enables users to configure to partition it into SLC and MLC areas
in more flexible way. While MLC area of Flex-OneNAND can be used to store data
that require low reliability and high density, SLC area of Flex-OneNAND
to store data that need high reliability and high performance. Flex-OneNAND
can let users take advantage of storing these two different types of data
into one chip, which is making Flex-OneNAND more cost- and space-effective.

Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
2008-03-26 00:05:32 +01:00
Stefan Roese f0105727d1 CFI: Small cleanup for FLASH_SHOW_PROGRESS
With this patch we don't need that many #ifdef's in the code. It moves
the subtraction into the macro and defines a NOP-macro when
CONFIG_FLASH_SHOW_PROGRESS is not defined.

Signed-off-by: Stefan Roese <sr@denx.de>
Acked-by: Gerald Van Baren <vanbaren@cideas.com>
2008-03-19 13:41:25 +01:00
Jerry Van Baren 9a042e9ca5 Flash programming progress countdown.
Signed-off-by: Gerald Van Baren <vanbaren@cideas.com>
2008-03-19 13:41:25 +01:00
Michael Schwingen 1ba639da56 CFI: Do not use uninitialized cmd_reset
Do not use uninitialized cmd_reset; issue both AMD and Intel reset
commands instead

From a short test, it looks like AMD-style flash roms treat *any* unknown
command write as a reset, at least when in CFI Query mode, so issuing the
Intel reset command to AMD-style flashs seems safe (from the small sample I
have), plus the 3-cycle magic sequence should kick the state machine into
the right state even without a reset command. Since the AMD-style flashs
require the unlock sequence for real operation, I chose to try the AMD reset
command first, so that Intel flashs do no see an invalid command prior to
the CFI query.

I have tested the patch on AM29LV320-style flashs from Fujitsu and Macronix,
plus Intel StrataFlash.

Signed-off-by: Michael Schwingen <michael@schwingen.org>
Signed-off-by: Stefan Roese <sr@denx.de>
2008-02-21 17:12:19 +01:00
Stelian Pop 20b197c6f2 AT91CAP9 support : build integration
Signed-off-by: Stelian Pop <stelian@popies.net>
2008-02-14 09:37:57 +00:00
Stelian Pop d49fe4bed5 Improve DataFlash CS definition.
Use a structure instead of the error prone unnamed array to
define the possible dataflash banks.

Signed-off-by: Stelian Pop <stelian@popies.net>
2008-02-14 09:37:56 +00:00
Kumar Gala 3cfb0c51b2 Remove duplicate defines for ARRAY_SIZE
Signed-off-by: Kumar Gala <galak@kernel.crashing.org>
2008-02-14 00:43:02 +01:00
Stelian Pop c77ce474b1 Fix incorrect address test in AT91F_DataflashSelect().
Signed-off-by: Stelian Pop <stelian@popies.net>
2008-02-14 00:37:23 +01:00
Anton Vorontsov cd9d23053d nand: FSL UPM NAND driver
Signed-off-by: Anton Vorontsov <avorontsov@ru.mvista.com>
2008-01-16 14:14:40 +01:00
Kyungmin Park 6cb2239ae7 OneNAND: Separate U-Boot dependent code from OneNAND
OneNAND: Separate U-Boot dependent code from OneNAND

Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
2008-01-16 14:10:15 +01:00
Michael Schwingen 8225d1e3ac CFI: Fix CONFIG_FLASH_CFI_LEGACY compilation
Signed-off-by: Michael Schwingen <michael@schwingen.org>
Acked-by: Stefan Roese <sr@denx.de>
2008-01-13 15:07:26 +01:00
Marcel Ziswiler 7817cb2083 fix comments with new drivers organization
Signed-off-by: Marcel Ziswiler <marcel@ziswiler.com>
2008-01-09 21:48:49 +01:00
Stefan Roese ce37422d00 cfi_flash: Fix bug in flash_isset() to use correct 32bit function
This bug was detected on the LWMON5 target which has 2 Intel 16bit wide
flash chips connected to a 32bit wide port.

Signed-off-by: Stefan Roese <sr@denx.de>
2008-01-02 16:07:01 +01:00
Stefan Roese 0dc80e2759 cfi_flash: Add missing check for erased dest to flash_write_cfibuffer()
The check for an sufficiently erased destination was missing in the
buffered write function of the cfi flash driver (when
CFG_FLASH_USE_BUFFER_WRITE is defined). This patch adds this check to that
writing to such a region will fail with the currect error message.

Signed-off-by: Stefan Roese <sr@denx.de>
2007-12-27 07:50:54 +01:00
Haavard Skinnemoen 467bcee11f cfi_flash: Add manufacturer-specific fixups
Run fixups based on the JEDEC manufacturer ID independent of the
command set ID.

This changes current behaviour: Previously, geometry reversal for AMD
chips were done based on the command set ID, while they are now done
based on the JEDEC manufacturer and device ID.

Also add fixup for top-boot Atmel chips. A fixup is needed for
AT49BV6416(T) too, but since u-boot currently only reads the low byte
of the device ID, there's no way to tell it apart from AT49BV642D,
which should not have this fixup. Since AT49BV642D support is
necessary to get ATNGW100 board support into mainline, I've commented
out the fixup for now.

Signed-off-by: Haavard Skinnemoen <hskinnemoen@atmel.com>
2007-12-17 15:48:38 +01:00
Haavard Skinnemoen 0ddf06ddf6 cfi_flash: Add cmdset-specific init functions
Move things like reading JEDEC IDs and fixing up geometry reversal
into separate functions. The geometry reversal fixup is now performed
by altering the qry structure directly, which makes the sector init
code slightly cleaner.

Signed-off-by: Haavard Skinnemoen <hskinnemoen@atmel.com>
2007-12-17 15:48:31 +01:00
Haavard Skinnemoen e23741f4a6 cfi_flash: Read whole QRY structure in one go
Read out the whole CFI Standard Query structure after successful cfi
identification. This allows subsequent code to access this information
directly without having to go through flash_read_uchar() and friends.

Signed-off-by: Haavard Skinnemoen <hskinnemoen@atmel.com>
2007-12-17 15:48:25 +01:00
Haavard Skinnemoen 12d30aa797 cfi_flash: Use map_physmem() and unmap_physmem()
Use map_physmem() and unmap_physmem() to convert from physical to
virtual addresses. This gives the arch a chance to provide an uncached
mapping for flash accesses.

Signed-off-by: Haavard Skinnemoen <hskinnemoen@atmel.com>
2007-12-13 13:15:22 +01:00
Haavard Skinnemoen cdbaefb5f5 cfi_flash: Introduce read and write accessors
Introduce flash_read{8,16,32,64) and flash_write{8,16,32,64} and use
them to access the flash memory. This makes it clearer when the flash
is actually being accessed; merely dereferencing a volatile pointer
looks just like any other kind of access.

Signed-off-by: Haavard Skinnemoen <hskinnemoen@atmel.com>
2007-12-13 13:15:11 +01:00
Haavard Skinnemoen be60a9021c cfi_flash: Reorder functions and eliminate extra prototypes
Reorder the functions in cfi_flash.c so that each function only uses
functions that have been defined before it. This allows the static
prototype declarations near the top to be eliminated and might allow
gcc to do a better job inlining functions.

Signed-off-by: Haavard Skinnemoen <hskinnemoen@atmel.com>
2007-12-13 13:14:55 +01:00
Haavard Skinnemoen 3055793bcb cfi_flash: Make some needlessly global functions static
Make functions not declared in any header file static.

Signed-off-by: Haavard Skinnemoen <hskinnemoen@atmel.com>
2007-12-13 13:12:46 +01:00
Haavard Skinnemoen 7e5b9b4715 cfi_flash: Break long lines
This patch tries to keep all lines in the cfi_flash driver below 80
columns. There are a few lines left which don't fit this requirement
because I couldn't find any trivial way to break them (i.e. it would
take some restructuring, which I intend to do in a later patch.)

Signed-off-by: Haavard Skinnemoen <hskinnemoen@atmel.com>
2007-12-13 13:11:45 +01:00
Bartlomiej Sieka 42026c9cb3 CFI: synchronize command offsets with Linux CFI driver
Fixes non-working CFI Flash on the Inka4x0 board.

Signed-off-by: Bartlomiej Sieka <tur@semihalf.com>
2007-12-13 12:00:37 +01:00
Stefan Roese 9692c2734a CFI: Coding style cleanup
Signed-off-by: Stefan Roese <sr@denx.de>
2007-12-08 08:25:09 +01:00
Michael Schwingen 81b20ccc2d CFI: support JEDEC flash roms in CFI-flash framework
The following patch adds support for non-CFI flash ROMS, by hooking into the
CFI flash code and using most of its code, as recently discussed here in the
thread "Mixing CFI and non-CFI flashs".

Signed-off-by: Michael Schwingen <michael@schwingen.org>
Signed-off-by: Stefan Roese <sr@denx.de>
2007-12-08 08:16:50 +01:00
Jean-Christophe PLAGNIOL-VILLARD 59829cc189 drivers/mtd : move mtd drivers to drivers/mtd
Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
2007-11-25 23:28:52 +01:00