9
0
Fork 0
Commit Graph

63 Commits

Author SHA1 Message Date
Sascha Hauer 3e503822c7 use loff_t for file offsets
This is a first step for 64bit file support: Make the file sizes/offsets
64bit.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2012-06-30 16:53:24 +02:00
Sascha Hauer 51885a7d73 Change byte order detection mechanism to kernel style
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>
2012-06-28 13:49:16 +02:00
Johannes Stezenbach 9c865c1669 m25p80: progressbar tweak
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>
2012-06-07 19:31:33 +02:00
Johannes Stezenbach 2c25d3ec4b m25p80: allow erase to be interrupted
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>
2012-06-07 19:31:33 +02:00
Johannes Stezenbach 011702664f m25p80: prevent endless loop in erase
"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>
2012-06-07 19:31:33 +02:00
Krzysztof Halasa 254b183339 NOR flash: reduce size of cfiword_t if not using 64-bit bus.
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>
2012-05-13 11:03:26 +02:00
Sascha Hauer 7eebd3b4c6 cfi flash: Fix alignment problem
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>
2012-04-05 10:58:02 +02:00
Sascha Hauer 14bc0e9f83 cfi flash: Fix loop count calculation
'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>
2012-04-05 10:58:02 +02:00
Sascha Hauer 8145c67ff8 remove unused Kconfig variable HAS_CFI
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2011-12-07 13:04:54 +01:00
Michael Grzeschik a2b6da5e66 m25p80: set the correct erasesize when we use OPCODE_BE_4K
Signed-off-by: Michael Grzeschik <m.grzeschik@pengutronix.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2011-11-25 12:41:18 +01:00
Sascha Hauer 2024fa56ff cfi flash: fix flash_make_cmd for big endian access
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>
2011-09-23 16:32:48 +02:00
Sascha Hauer 0b07a67b6f cfi flash: use cpu native accessors
So that the driver can work on big endian systems again

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2011-09-23 16:32:48 +02:00
Sascha Hauer 3ee7877a48 introduce io.h
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>
2011-09-22 19:03:05 +02:00
Teresa Gámez 943b27107c cfi_flash: support of u32 cmd
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>
2011-08-26 09:33:37 +02:00
Franck Jullien e705ccd130 nor: Add SPI flash driver
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>
2011-08-24 18:44:31 +02:00
Jean-Christophe PLAGNIOL-VILLARD 13da42d6d7 cfi_flash: convert missing map_base
Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
2011-07-30 02:05:26 +08:00
Sascha Hauer 8262d20dae cfi: convert to struct resource
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>
2011-07-19 00:12:53 +08:00
Sascha Hauer 2f0109b1bb Merge branch 'master' into next 2011-01-17 09:43:40 +01:00
Krzysztof Halasa 04e89d094a CFI NOR flash: fix write timeout units.
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>
2011-01-17 08:26:06 +01:00
Krzysztof Halasa c5baa0edc4 Fix error handling with malloc, memalign etc. Introduce xmemalign().
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>
2011-01-07 10:21:22 +01:00
Krzysztof Halasa 72e94e7373 Fix NOR CFI flash driver to work on big endian systems.
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>
2010-12-21 09:02:40 +01:00
Krzysztof Halasa d66ae58cd8 Cosmetic fixes, including format attributes for printf() and friends.
Signed-off-by: Krzysztof Hałasa <khc@pm.waw.pl>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2010-12-21 09:02:40 +01:00
Krzysztof Halasa e2bf1aec90 Flash CFI: removed unused 'size' variable.
Signed-off-by: Krzysztof Hałasa <khc@pm.waw.pl>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2010-12-21 09:02:40 +01:00
Sascha Hauer f4b1ebd2fd cfi flash driver: check for ctrl-c during erase
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2010-12-20 09:28:21 +01:00
Jean-Christophe PLAGNIOL-VILLARD 615076e1fc cfi_flash_amd: 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.

based on U-Boot

Signed-off-by: Haavard Skinnemoen <hskinnemoen@atmel.com>
Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
2010-12-03 01:53:14 +08:00
Jean-Christophe PLAGNIOL-VILLARD 9985498695 cfi_flash: introduce flash cmdset fixup
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>
2010-12-03 01:53:14 +08:00
Jean-Christophe PLAGNIOL-VILLARD 0df2a8d263 cfi_flash: move reset command assigment to specific chipset init function
Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
2010-12-03 01:53:14 +08:00
Jean-Christophe PLAGNIOL-VILLARD 04191aa0fc 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.

based on U-Boot

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
2010-12-03 01:53:13 +08:00
Jean-Christophe PLAGNIOL-VILLARD fec9928dc7 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.

based on U-Boot

Signed-off-by: Haavard Skinnemoen <hskinnemoen@atmel.com>
Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
2010-12-03 01:53:13 +08:00
Jean-Christophe PLAGNIOL-VILLARD 6bc05afea5 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.

based on U-Boot

Signed-off-by: Haavard Skinnemoen <hskinnemoen@atmel.com>
Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
2010-12-03 01:53:13 +08:00
Jean-Christophe PLAGNIOL-VILLARD 8b41ca208e cfi_flash: update manufacturer id flash support
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>
2010-12-03 01:53:12 +08:00
Jean-Christophe PLAGNIOL-VILLARD ce35b3c09a cfi_flash: synchronize command offsets with Linux CFI driver
Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
2010-12-03 01:53:12 +08:00
Jean-Christophe PLAGNIOL-VILLARD 64e70cd050 cfi_flash: use amd and standard reset flash command at probing
as we do not known which flash we have yet

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
2010-12-03 01:53:12 +08:00
Jean-Christophe PLAGNIOL-VILLARD ae416f6270 cfi_flash: move flash_read_uchar from inline to noinline
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>
2010-12-03 01:53:12 +08:00
Jean-Christophe PLAGNIOL-VILLARD 7c487f3730 cfi_flash: add Atmel real protect flash support
based on U-Boot

Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
2010-12-03 01:53:12 +08:00
Jean-Christophe PLAGNIOL-VILLARD 322b9af875 cfi_flash: move intel real protect flash support to cfi_flash_intel.c
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>
2010-12-03 01:53:12 +08:00
Sascha Hauer 8196b9e2cc cfi_flash: Add mtd partition support for UBI
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2010-07-05 15:07:09 +02:00
Sascha Hauer b6b76c4ee2 cfi_flash: Do not print debug info while erasing
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2010-07-05 13:00:02 +02:00
Sascha Hauer 497445d51e cfi_flash: Do not typedef struct flash_info
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2010-07-05 13:00:02 +02:00
Sascha Hauer 6d1d9e8d8b Merge branch 'next' 2010-07-03 10:26:21 +02:00
Wolfram Sang a0e68122e6 nor: don't use sector for ERASE_START
Similar to ac2d4d71ba, 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>
2010-06-29 08:28:14 +02:00
Sascha Hauer b99e2c4ac6 cfi flash driver: Use generic progression bar function
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2010-06-28 10:43:55 +02:00
Uwe Kleine-König 7a0a29ca36 cfi_flash: use flash_write_word instead of reimplementing it again
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>
2010-05-03 15:01:28 +02:00
Wolfram Sang ac2d4d71ba nor: Don't use the sector for the unlock sequence
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>
2010-05-03 15:01:28 +02:00
Sascha Hauer e6b8bdc0c5 cfi_flash: move include/cfi_flash.c next to driver
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>
2010-02-08 14:37:50 +01:00
Sascha Hauer 582da05383 cfi_flash: remove old driver and switch to new one
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2010-02-08 14:37:49 +01:00
Sascha Hauer 8b82899341 cfi_flash_new: make code more readable, return is not a function
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2010-02-08 14:37:49 +01:00
Sascha Hauer 089066237d cfi_flash_new: generate flash erase dots in common function
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2010-02-08 14:37:49 +01:00
Sascha Hauer 146ba46d41 cfi_flash_new: Safe indention level by bailing out earlier in error case
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2010-02-08 14:37:49 +01:00
Sascha Hauer 4e459d98ef cfi_flash_new: Fix Intel chips
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>
2010-02-08 14:37:49 +01:00