summaryrefslogtreecommitdiffstats
path: root/drivers/nor
Commit message (Collapse)AuthorAgeFilesLines
* use loff_t for file offsetsSascha Hauer2012-06-302-10/+14
| | | | | | | This is a first step for 64bit file support: Make the file sizes/offsets 64bit. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Change byte order detection mechanism to kernel styleSascha Hauer2012-06-281-4/+6
| | | | | | | | | | | | | | | The Linux Kernel defines only one of __LITTLE_ENDIAN and __BIG_ENDIAN. Endianess can then be tested with #ifdef __xx_ENDIAN. Userspace always defined both __LITTLE_ENDIAN and __BIG_ENDIAN and byteorder can then be tested with #if __BYTE_ORDER == __xx_ENDIAN. As we tend to use a lot of Kernel code in barebox we switch to use the kernel way of determing the byte order. As this always causes a lot of confusion add a check to include/common.h to make sure only one of __LITTLE_ENDIAN and __BIG_ENDIAN is defined. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* m25p80: progressbar tweakJohannes Stezenbach2012-06-071-2/+2
| | | | | | | | Show progressbar even when erasing just a single sector, otherwise it looks as if erase didn't do anything. Signed-off-by: Johannes Stezenbach <js@sig21.net> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* m25p80: allow erase to be interruptedJohannes Stezenbach2012-06-071-0/+2
| | | | | | | Check for Ctrl-C before erasing each sector. Signed-off-by: Johannes Stezenbach <js@sig21.net> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* m25p80: prevent endless loop in eraseJohannes Stezenbach2012-06-071-0/+2
| | | | | | | | | "erase /dev/myflash0 0+1" erased the whole flash, similar for other value of count if you guessed the erae block size wrong. Signed-off-by: Johannes Stezenbach <js@sig21.net> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* NOR flash: reduce size of cfiword_t if not using 64-bit bus.Krzysztof Halasa2012-05-131-0/+10
| | | | | | | This is done to reduce the binary size a bit. Signed-off-by: Krzysztof Hałasa <khc@pm.waw.pl> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* cfi flash: Fix alignment problemSascha Hauer2012-04-051-5/+13
| | | | | | | | | | | | | | | | | | | | | | | | | The intel cfi buffer write has a problem with writing when the alignment of the buffer in memory is smaller than the flash bus width. This patch fixes a alignment problem which may show during this scenario: - 32 or 64 attached NOR flash - flashing an image directly from network to the nor flash The involved network driver is "smc9111.c". The data that comes from the network stack and should be written into the flash isn't 32 bit aligned (at least with this network driver). This is probably due to the 48 bit wide ethernet addresses. However the "cfi_flash.c" driver doesn't handle this situation, and accesses the not-aligned address with a 32 bit pointer. This patch fixes the problem by reducing the access width if an aligment problem between source and destination is found. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* cfi flash: Fix loop count calculationSascha Hauer2012-04-051-1/+1
| | | | | | | | 'reduce the number of loops by the width of the port' means a simple len / width. Do not try to be clever by shifting and doing it wrong. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* remove unused Kconfig variable HAS_CFISascha Hauer2011-12-071-3/+0
| | | | Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* m25p80: set the correct erasesize when we use OPCODE_BE_4KMichael Grzeschik2011-11-251-2/+4
| | | | | Signed-off-by: Michael Grzeschik <m.grzeschik@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* cfi flash: fix flash_make_cmd for big endian accessSascha Hauer2011-09-231-19/+5
| | | | | | | | | | | | | | This is broken on big endian systems since: 943b271 cfi_flash: support of u32 cmd I looked over it and I *think* that the function was correct for both big and little endian systems before this patch. To support u32 cmd we only have to change the data type of the command from u8 to u32. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de> Cc: Teresa Gámez <t.gamez@phytec.de>
* cfi flash: use cpu native accessorsSascha Hauer2011-09-231-6/+6
| | | | | | So that the driver can work on big endian systems again Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* introduce io.hSascha Hauer2011-09-222-2/+2
| | | | | | | To allow for some generic io accessors introduce io.h and use this instead of asm/io.h throughout the tree. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* cfi_flash: support of u32 cmdTeresa Gámez2011-08-264-18/+38
| | | | | | | | | | | | Some NOR flash chips have commands with length greater than the maximum value size of uchar. Based on an U-Boot Patch by Vasiliy Leoenenko <vasiliy.leonenko@mail.ru> Only tested with little endian on an intel cfi_flash. Signed-off-by: Teresa Gámez <t.gamez@phytec.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* nor: Add SPI flash driverFranck Jullien2011-08-244-5/+945
| | | | | | | | | This patch adds the m25p80 driver. It has been ported from Linux. MTD code has been removed. It has been tested with a m25p40 chip and the Altera SPI master driver. Signed-off-by: Franck Jullien <franck.jullien@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* cfi_flash: convert missing map_baseJean-Christophe PLAGNIOL-VILLARD2011-07-301-1/+1
| | | | Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
* cfi: convert to struct resourceSascha Hauer2011-07-191-19/+17
| | | | | | | This is the non invasive approach. All this type casting shows this driver should be really cleaned up (or retired) Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Merge branch 'master' into nextSascha Hauer2011-01-171-10/+8
|\
| * CFI NOR flash: fix write timeout units.Krzysztof Halasa2011-01-171-10/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Write timeouts are expressed in microseconds. Milliseconds are 1000 times longer than microseconds, not 1000 times shorter. Before (Intel 28F128J3D75): CFI conformant FLASH (16 x 16) Size: 16 MB in 128 Sectors Intel Extended command set, Manufacturer ID: 0x89, Device ID: 0x18 Erase timeout: 4096 ms, write timeout: 256000 ms Buffer write timeout: 1024000 ms, buffer size: 32 bytes After: ... Erase timeout: 4096 ms, write timeout: 256 us Buffer write timeout: 1024 us, buffer size: 32 bytes Signed-off-by: Krzysztof Hałasa <khc@pm.waw.pl> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | Fix error handling with malloc, memalign etc. Introduce xmemalign().Krzysztof Halasa2011-01-071-3/+3
|/ | | | | | | | | | | | | | The idea is to panic() when there is no memory available for normal operation. Exception: code which can consume arbitrary amount of RAM (example: files allocated in ramfs) must report error instead of panic(). This patch also fixes code which didn't check for NULL from malloc() etc. Usage: malloc(), memalign() return NULL when out of RAM. xmalloc(), xmemalign() always return non-NULL or panic(). Signed-off-by: Krzysztof Hałasa <khc@pm.waw.pl> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Fix NOR CFI flash driver to work on big endian systems.Krzysztof Halasa2010-12-212-90/+62
| | | | | | | | | | | Fix NOR CFI flash driver to work on big endian systems. Basically this transforms the u8/u16/u32/u64 union into a single u64 value. Not tested on LE platform. Apply with caution. Signed-off-by: Krzysztof Hałasa <khc@pm.waw.pl> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Cosmetic fixes, including format attributes for printf() and friends.Krzysztof Halasa2010-12-211-4/+4
| | | | | Signed-off-by: Krzysztof Hałasa <khc@pm.waw.pl> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Flash CFI: removed unused 'size' variable.Krzysztof Halasa2010-12-211-2/+1
| | | | | Signed-off-by: Krzysztof Hałasa <khc@pm.waw.pl> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* cfi flash driver: check for ctrl-c during eraseSascha Hauer2010-12-201-0/+5
| | | | Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* cfi_flash_amd: Add manufacturer-specific fixupsJean-Christophe PLAGNIOL-VILLARD2010-12-031-1/+38
| | | | | | | | | | | | | | | | 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. based on U-Boot Signed-off-by: Haavard Skinnemoen <hskinnemoen@atmel.com> Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
* cfi_flash: introduce flash cmdset fixupJean-Christophe PLAGNIOL-VILLARD2010-12-034-39/+52
| | | | | | | | | | | | Move fixing up like 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. based on U-Boot Signed-off-by: Haavard Skinnemoen <hskinnemoen@atmel.com> Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
* cfi_flash: move reset command assigment to specific chipset init functionJean-Christophe PLAGNIOL-VILLARD2010-12-033-6/+6
| | | | Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
* cfi_flash: do not reset flash when probe failsJean-Christophe PLAGNIOL-VILLARD2010-12-031-1/+1
| | | | | | | | | | | | | | | | | 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. based on U-Boot Signed-off-by: Mike Frysinger <vapier@gentoo.org> Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
* cfi_flash: Read whole QRY structure in one goJean-Christophe PLAGNIOL-VILLARD2010-12-032-85/+97
| | | | | | | | | | | 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. based on U-Boot Signed-off-by: Haavard Skinnemoen <hskinnemoen@atmel.com> Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
* cfi_flash: Introduce read and write accessorsJean-Christophe PLAGNIOL-VILLARD2010-12-034-79/+130
| | | | | | | | | | | | 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. based on U-Boot Signed-off-by: Haavard Skinnemoen <hskinnemoen@atmel.com> Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
* cfi_flash: update manufacturer id flash supportJean-Christophe PLAGNIOL-VILLARD2010-12-034-4/+25
| | | | | | | | several first banks can contain 0x7f instead of actual ID support as done in linux Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
* cfi_flash: synchronize command offsets with Linux CFI driverJean-Christophe PLAGNIOL-VILLARD2010-12-032-11/+28
| | | | Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
* cfi_flash: use amd and standard reset flash command at probingJean-Christophe PLAGNIOL-VILLARD2010-12-031-1/+2
| | | | | | as we do not known which flash we have yet Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
* cfi_flash: move flash_read_uchar from inline to noinlineJean-Christophe PLAGNIOL-VILLARD2010-12-032-14/+16
| | | | | | | | it will reduce the binary size of 28 bytes and fix some issue observerd during the porting of the at91rm9200ek when reading the device_id and manufacturor_id Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
* cfi_flash: add Atmel real protect flash supportJean-Christophe PLAGNIOL-VILLARD2010-12-032-0/+21
| | | | | | based on U-Boot Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
* cfi_flash: move intel real protect flash support to cfi_flash_intel.cJean-Christophe PLAGNIOL-VILLARD2010-12-034-6/+24
| | | | | | let an empty function for amd as we will add later atmel real protect flash Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
* cfi_flash: Add mtd partition support for UBISascha Hauer2010-07-052-4/+98
| | | | Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* cfi_flash: Do not print debug info while erasingSascha Hauer2010-07-051-1/+1
| | | | Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* cfi_flash: Do not typedef struct flash_infoSascha Hauer2010-07-054-60/+60
| | | | Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Merge branch 'next'Sascha Hauer2010-07-031-1/+4
|\
| * cfi flash driver: Use generic progression bar functionSascha Hauer2010-06-281-1/+4
| | | | | | | | Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | nor: don't use sector for ERASE_STARTWolfram Sang2010-06-291-2/+1
|/ | | | | | | | | | | | | | Similar to ac2d4d71ba493fd638ae0bf1a530a51c76d3c53d, copy the behaviour from Linux which does: cfi_send_gen_cmd(0x80, cfi->addr_unlock1, chip->start, map, cfi, cfi->device_type, NULL); Notice the third parameter which is simply chip->start. Needed for some SST-flashes. Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Signed-off-by: Wolfram Sang <w.sang@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* cfi_flash: use flash_write_word instead of reimplementing it againUwe Kleine-König2010-05-031-18/+1
| | | | | | | | | While at it remove some unused code and an unbalanced enable_interrupts(). Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Signed-off-by: Wolfram Sang <w.sang@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* nor: Don't use the sector for the unlock sequenceWolfram Sang2010-05-031-8/+8
| | | | | | | | | | | | | | | Copy the behaviour from Linux which does: cfi_send_gen_cmd(0xAA, cfi->addr_unlock1, chip->start, map, cfi, cfi->device_type, NULL); ... (Notice the third parameter which is simply chip->start). Solves erase problems with SST flashes. Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Signed-off-by: Wolfram Sang <w.sang@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* cfi_flash: move include/cfi_flash.c next to driverSascha Hauer2010-02-084-3/+657
| | | | | | | | This file has no useful things for others than the driver, so move it next to the driver and remove the corresponding include from other files. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* cfi_flash: remove old driver and switch to new oneSascha Hauer2010-02-086-2046/+515
| | | | Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* cfi_flash_new: make code more readable, return is not a functionSascha Hauer2010-02-081-4/+5
| | | | Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* cfi_flash_new: generate flash erase dots in common functionSascha Hauer2010-02-083-16/+3
| | | | Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* cfi_flash_new: Safe indention level by bailing out earlier in error caseSascha Hauer2010-02-081-21/+24
| | | | Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* cfi_flash_new: Fix Intel chipsSascha Hauer2010-02-081-39/+3
| | | | | | | There was some mixup when to to a full status check and when to do a status check only. Fix this. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>