Commit Graph

1123 Commits

Author SHA1 Message Date
Jagan Teki
bfcdc3956d sf: Read back and check once macronix quad bit set
One macronix quad bit set using SR, it's good to
read back and check the written bit and also if
it's already been set check for the bit and return.

Cc: Vignesh R <vigneshr@ti.com>
Cc: Simon Glass <sjg@chromium.org>
Cc: Bin Meng <bmeng.cn@gmail.com>
Tested-by: Mugunthan V N <mugunthanvnm@ti.com>
Signed-off-by: Jagan Teki <jteki@openedev.com>
2016-01-13 18:47:26 +05:30
Jagan Teki
ffecb0fc84 sf: Read back and check once spansion quad bit set
One spansion quad bit set using CR, it's good to
read back and check the written bit and also if
it's already been set check for the bit and return.

Cc: Vignesh R <vigneshr@ti.com>
Cc: Simon Glass <sjg@chromium.org>
Cc: Bin Meng <bmeng.cn@gmail.com>
Cc: Michal Simek <michal.simek@xilinx.com>
Cc: Siva Durga Prasad Paladugu <sivadur@xilinx.com>
Tested-by: Mugunthan V N <mugunthanvnm@ti.com>
Signed-off-by: Jagan Teki <jteki@openedev.com>
2016-01-13 18:47:26 +05:30
Jagan Teki
c56ae7519f sf: Fix quad bit set for micron devices
Setting up quad bit for micron devices need to do the
same way as other flash devices like spansion, winbond
etc does using enhanced volatile config register so this
patch adds this support instead of printing "QEB is volatile"

Cc: Simon Glass <sjg@chromium.org>
Cc: Bin Meng <bmeng.cn@gmail.com>
Cc: Peter Pan <peterpandong@micron.com>
Cc: Fabio Estevam <fabio.estevam@freescale.com>
Cc: Michal Simek <michal.simek@xilinx.com>
Cc: Siva Durga Prasad Paladugu <sivadur@xilinx.com>
Signed-off-by: Jagan Teki <jteki@openedev.com>
2016-01-13 18:47:26 +05:30
Jagan Teki
eb020f69e0 sf: Use BIT macro
Used BIT macro like 1 << nr as BIT(nr) where nr is 0...n

Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
Signed-off-by: Jagan Teki <jteki@openedev.com>
2016-01-13 18:47:26 +05:30
Jagan Teki
7bc679fb14 sf: Minor cleanup
- Tab space
- Place all read commands at one place.
- Re-arrange write commands.

Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
Signed-off-by: Jagan Teki <jteki@openedev.com>
2016-01-13 18:47:26 +05:30
Jagan Teki
11c579bc9c sf: Remove spi_flash_remove
Use direct call to device_remove instead of exctra
spi_flash_remove defination.

Reviewed-by: Simon Glass <sjg@chromium.org>
Signed-off-by: Jagan Teki <jteki@openedev.com>
2016-01-13 18:47:26 +05:30
Jagan Teki
6f3096585b sf: Rename bank_end to bar_end in read_bar
bar_end gives more meaningfull compared to bank_end and
spi_flash_write_bar uses bar_end so replaced bank_end with
bar_end in spi_flash_read_bar

Signed-off-by: Jagan Teki <jteki@openedev.com>
2016-01-13 18:47:26 +05:30
Jagan Teki
9275929c24 sf: Rename spi_flash_set_* functions
Since quad_mode functions are local to spi flash core,
rename them to a meaningful and readable names.

Signed-off-by: Jagan Teki <jteki@openedev.com>
2016-01-13 18:47:25 +05:30
Jagan Teki
d25dd94298 sf: Move spi_read_cmds_array locally
Since spi_read_cmds_array is used locally in
spi_flash_scan, so move array to locally used
function instead of defining global array.

Tested-by: Jagan Teki <jteki@openedev.com>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
Signed-off-by: Jagan Teki <jteki@openedev.com>
2016-01-13 18:47:25 +05:30
Jagan Teki
cdf3393814 spi: Rename SPI_TX_BP|QPP to SPI_TX_BYTE|QUAD
Since SPI_TX_* are spi_slave{} members so use spi protocol
notation instead spi flash programming, like

SPI_TX_BP  => SPI_TX_BYTE
SPI_TX_QPP => SPI_TX_QUAD

Cc: Simon Glass <sjg@chromium.org>
Tested-by: Jagan Teki <jteki@openedev.com>
Tested-by: Bin Meng <bmeng.cn@gmail.com>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
Signed-off-by: Jagan Teki <jteki@openedev.com>
2016-01-13 18:47:25 +05:30
Jagan Teki
095a41d3c2 spi: Use mode instead of op_mode_tx
Used mode member from spi_slave{} instead of op_mode_tx.

Cc: Simon Glass <sjg@chromium.org>
Tested-by: Jagan Teki <jteki@openedev.com>
Tested-by: Bin Meng <bmeng.cn@gmail.com>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
Signed-off-by: Jagan Teki <jteki@openedev.com>
2016-01-13 18:47:25 +05:30
Jagan Teki
e228d6deb1 sf: Get spi locally from spi_flash
For better code readabilty, get the spi pointer from
spi_flash{} locally and use it instead of direct
dereferring spi pinter as flash->spi->*

Tested-by: Jagan Teki <jteki@openedev.com>
Tested-by: Bin Meng <bmeng.cn@gmail.com>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
Signed-off-by: Jagan Teki <jteki@openedev.com>
2016-01-13 18:47:25 +05:30
Tom Rini
67ecb84ccb Merge branch 'master' of git://git.denx.de/u-boot-spi 2016-01-07 12:41:57 -05:00
Fabio Estevam
5092158359 spi: spi_flash: Fix the arguments of stm_is_locked_sr()
stm_is_locked_sr() takes the status register (SR) value as the last
parameter, not the second.

Based on a patch from Brian Norris for the linux kernel:
http://git.infradead.org/linux-mtd.git/commit/a32d5b726ff8cf32bf491522b0ac8ae2545a063e

Signed-off-by: Fabio Estevam <fabio.estevam@nxp.com>
Reviewed-by: Jagan Teki <jteki@openedev.com>
2016-01-07 20:29:33 +05:30
Ladislav Michl
6a4595600b UBI: Fix compile error when CONFIG_UBI_SILENCE_MSG defined
drivers/mtd/ubi/io.c:1354:3: error: 'dump_len' undeclared (first use in
this function)
   dump_len = max_t(int, 128, len - i);

Signed-off-by: Ladislav Michl <ladis@linux-mips.org>
2016-01-04 09:11:10 +01:00
Thomas Chou
8e8106dcd5 altera_qspi: allow ctrl-c to abort the erase ops
Allow ctrl-c to abort the erase ops.

Signed-off-by: Thomas Chou <thomas@wytron.com.tw>
2015-12-28 09:32:43 +08:00
Thomas Chou
d579d38f3f altera_qspi: show erase progress
Show sector erase progress with dot and comma.

Signed-off-by: Thomas Chou <thomas@wytron.com.tw>
2015-12-28 09:32:43 +08:00
Thomas Chou
f81a673ec4 altera_qspi: skip erase if the sector is blank
Skip erase if the sector is blank. The sector erase is slow, and
may take 0.7 sec typically or up to 3 sec worst-case.

Signed-off-by: Thomas Chou <thomas@wytron.com.tw>
2015-12-28 09:32:43 +08:00
Thomas Chou
a1b1d7eceb altera_qspi: set fail_addr for erase ops
If the erase fails, fail_addr might indicate exactly which block
failed. If fail_addr = MTD_FAIL_ADDR_UNKNOWN, the failure was not
at the device level or was not specific to any particular block.

Signed-off-by: Thomas Chou <thomas@wytron.com.tw>
2015-12-28 09:32:43 +08:00
Thomas Chou
9e957aa4ce altera_qspi: call callback even if the erase failed
Erase is an asynchronous operation.  Device drivers are supposed
to call instr->callback() whenever the operation completes, even
if it completes with a failure.

Signed-off-by: Thomas Chou <thomas@wytron.com.tw>
2015-12-28 09:32:43 +08:00
Thomas Chou
1c0e84ca82 altera_qspi: initialize instr.mtd in flash_erase
Initialize instr.mtd in flash_erase(). This fixes the system
hang issue when CONFIG_MTD_PARTITIONS is selected.

Signed-off-by: Thomas Chou <thomas@wytron.com.tw>
Acked-by: Marek Vasut <marex@denx.de>
2015-12-19 09:51:19 +08:00
Jagan Teki
cba65a77c4 sf: Rename sf_ops.c to spi-flash.c
Since all spi-flash core operations are moved into
sf_ops.c then it's better to renamed as spi-flash.c

Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
Signed-off-by: Jagan Teki <jteki@openedev.com>
2015-12-11 22:12:24 +05:30
Jagan Teki
339fd6dca5 sf: Use static for file-scope functions
Used static for file-scope functions in sf_probe.c

Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
Signed-off-by: Jagan Teki <jteki@openedev.com>
2015-12-11 22:12:24 +05:30
Jagan Teki
bfdb07eb4b sf: sf_probe: Remove spi_slave pointer argument
Since spi_slave is a spi pointer in spi_flash{} then assign
spi_slave{} pointer to flash->spi and remove spi_slave
pointer argument to
- spi_flash_probe_slave
- spi_flash_scan

Tested-by: Jagan Teki <jteki@openedev.com>
Tested-by: Bin Meng <bmeng.cn@gmail.com>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
Signed-off-by: Jagan Teki <jteki@openedev.com>
2015-12-11 22:12:24 +05:30
Jagan Teki
b6a2c436e0 sf: ops: Fix missing break on spansion read_bar
For assigning read_bar commands in spansion case, break
is missing this patch add that break.

Reviewed-by: Simon Glass <sjg@chromium.org>
Signed-off-by: Jagan Teki <jteki@openedev.com>
2015-12-11 22:12:24 +05:30
Jagan Teki
aae00f8bab sf: Remove unneeded SST_BP and SST_WP
SST parts added on sf_params.c supports both SST_WR which consits
of both BP and WP and there is a spi controller ich which supports
only BP so the relevent _write hook set based on "slave->op_mode_tx"
hence there is no respective change required from flash side hance
removed these.

Tested-by: Bin Meng <bmeng.cn@gmail.com>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
Signed-off-by: Jagan Teki <jteki@openedev.com>
2015-12-11 22:12:24 +05:30
Jagan Teki
615879ac1a sf: Remove unneeded header includes
Removed unneeded header includes in sf_ops and sf_probe

Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
Signed-off-by: Jagan Teki <jteki@openedev.com>
2015-12-11 22:12:24 +05:30
Jagan Teki
6f9d670d8e sf: Flash power up read-only based on idcode0
Using macro's for flash power up read-only access code
leads wrong behaviour hence use idcode0 for runtime
detection, hence the flash which require this functionality
gets detected at runtime.

Tested-by: Jagan Teki <jteki@openedev.com>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
Signed-off-by: Jagan Teki <jteki@openedev.com>
2015-12-11 22:12:24 +05:30
Jagan Teki
cb37518516 sf: Use simple name for register access functions
Most of the register access function are static,
so used simple name to represent each.

Tested-by: Jagan Teki <jteki@openedev.com>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
Signed-off-by: Jagan Teki <jteki@openedev.com>
2015-12-11 22:12:23 +05:30
Jagan Teki
fc335d63b0 sf: Fix Makefile
This patch removes unneeded ifdef and fixed accordingly.

Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
Signed-off-by: Jagan Teki <jteki@openedev.com>
2015-12-11 22:12:23 +05:30
Jagan Teki
6fa40e796c sf: Use static for file-scope functions
Use static for file-scope functions and removed
them from header files.

Tested-by: Jagan Teki <jteki@openedev.com>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
Signed-off-by: Jagan Teki <jteki@openedev.com>
2015-12-11 22:12:23 +05:30
Jagan Teki
0edae52f08 sf: probe: Code cleanup
- Move bar read code below the bar write hance both
  at once place, hence it easy for #ifdef macro only
  once and readable.
- Move read_cmd_array at top

Tested-by: Jagan Teki <jteki@openedev.com>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
Signed-off-by: Jagan Teki <jteki@openedev.com>
2015-12-11 22:12:23 +05:30
Jagan Teki
1e90d9fd31 sf: Move read_id code to sf_ops
read_id code is related to spi_flash stuff
hence moved to sf_ops.

Tested-by: Jagan Teki <jteki@openedev.com>
Tested-by: Bin Meng <bmeng.cn@gmail.com>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
Signed-off-by: Jagan Teki <jteki@openedev.com>
2015-12-11 22:12:23 +05:30
Jagan Teki
3847c0c180 sf: Move spi_flash_scan code to sf_ops
Intension is that sf_ops should deals all spi_flash
related stuff and sf_probe (which should renamed future)
should be an interface layer for spi_flash versus spi drivers.

sf_ops => spi_flash interface
sf_probe => interface layer vs spi_flash(sf_probe) to spi drivers

Tested-by: Jagan Teki <jteki@openedev.com>
Tested-by: Bin Meng <bmeng.cn@gmail.com>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
Signed-off-by: Jagan Teki <jteki@openedev.com>
2015-12-11 22:12:23 +05:30
Jagan Teki
3a1adb621b sf: spi_flash_validate_params => spi_flash_scan
Rename spi_flash_validate_params to spi_flash_scan
as this code not only deals with params setup but
also configure all spi_flash attributes.

And also moved all flash related code into
spi_flash_scan for future functionality addition.

Tested-by: Jagan Teki <jteki@openedev.com>
Tested-by: Bin Meng <bmeng.cn@gmail.com>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
Signed-off-by: Jagan Teki <jteki@openedev.com>
2015-12-11 22:12:23 +05:30
Tom Rini
25ef4bea59 Merge git://git.denx.de/u-boot-nios 2015-12-06 21:53:18 -05:00
Thomas Chou
f118fe5cf9 altera_qspi: fix erase and write error code
Fix erase and write error code, which should be "protected".

From the "Embedded Peripherals IP User Guide" of Altera,

The "Illegal write" flag indicates that a write instruction is
targeting a protected sector on the flash memory. This bit is
set to indicate that the IP has cancelled a write instruction.

The "Illegal erase" flag indicates that an erase instruction has
been set to a protected sector on the flash memory. This bit is
set to indicate that the IP has cancelled the erase instruction.

Signed-off-by: Thomas Chou <thomas@wytron.com.tw>
Acked-by: Chin Liang See <clsee@altera.com>
Reviewed-by: Marek Vasut <marex@denx.de>
2015-12-06 11:31:29 +08:00
Thomas Chou
421f306f2c altera_qspi: add lock unlock ops
Add lock() and unlock() mtd ops to altera_qspi.

Signed-off-by: Thomas Chou <thomas@wytron.com.tw>
Acked-by: Chin Liang See <clsee@altera.com>
Reviewed-by: Marek Vasut <marex@denx.de>
2015-12-06 11:31:25 +08:00
Vagrant Cascadian
1b25e586cb Fix typo: firstly -> first.
Signed-off-by: Vagrant Cascadian <vagrant@debian.org>
Acked-by: Marek Vasut <marex@denx.de>
2015-12-05 18:22:23 -05:00
Simon Glass
24b852a7a2 Move console definitions into a new console.h file
The console includes a global variable and several functions that are only
used by a small subset of U-Boot files. Before adding more functions, move
the definitions into their own header file.

Signed-off-by: Simon Glass <sjg@chromium.org>
2015-11-19 20:27:50 -07:00
Tom Rini
9ef671c9d4 Merge branch 'master' of git://git.denx.de/u-boot-spi 2015-11-19 13:27:26 -05:00
Michal Simek
2588f2ddfd dm: sf: Add support for all targets which requires MANUAL_RELOC
It is follow up patch based on
"dm: Add support for all targets which requires MANUAL_RELOC"
(sha1: 484fdf5ba0)
to update function pointers for DM.

Using post_bind is not ideal but it is one on current option what can be
used. Variable reloc_done has to be used do not call relocation after
every bind. Maybe new core functions should be introduced for this case.

Signed-off-by: Michal Simek <michal.simek@xilinx.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
2015-11-19 13:10:32 +01:00
Nikita Kiryanov
36afd45136 spl: change return values of spl_*_load_image()
Make spl_*_load_image() functions return a value instead of
hanging if a problem is encountered. This enables main spl code
to make the decision whether to hang or not, thus preparing
it to support alternative boot devices.

Some boot devices (namely nand and spi) do not hang on error.
Instead, they return normally and SPL proceeds to boot the
contents of the load address. This is considered a bug and
is rectified by hanging on error for these devices as well.

Signed-off-by: Nikita Kiryanov <nikita@compulab.co.il>
Cc: Igor Grinberg <grinberg@compulab.co.il>
Cc: Tom Rini <trini@konsulko.com>
Cc: Simon Glass <sjg@chromium.org>
Cc: Ian Campbell <ijc@hellion.org.uk>
Cc: Hans De Goede <hdegoede@redhat.com>
Cc: Albert Aribaud <albert.u.boot@aribaud.net>
Cc: Jagan Teki <jteki@openedev.com>
Reviewed-by: Tom Rini <trini@konsulko.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
2015-11-18 14:50:02 -05:00
Thomas Chou
8ed38fa50c altera_qspi: change ioremap to map_physmem
Change ioremap() to map_physmem(), as it is more used in u-boot.

Signed-off-by: Thomas Chou <thomas@wytron.com.tw>
Reviewed-by: Marek Vasut <marex@denx.de>
2015-11-18 21:18:30 +08:00
Bin Meng
3e56ecec43 sf: Correct flash->flags for SST flash
flash->flags for SST flash should be updated for both DM and non-DM
flash drivers.

Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
Reviewed-by: Jagan Teki <jteki@openedev.com>
2015-11-18 12:52:05 +05:30
Fabio Estevam
a668a164ff spi: sf_ops: Check the return value from spi_flash_cmd_read_status()
We should check the return value from spi_flash_cmd_read_status() and
propagate it in the case of error.

This fixes a defect caught by Coverity.

Reported-by: Tom Rini <trini@konsulko.com>
Signed-off-by: Fabio Estevam <fabio.estevam@freescale.com>
Reviewed-by: Jagan Teki <jteki@openedev.com>
2015-11-18 00:55:29 +05:30
Fabio Estevam
5168721e58 sf: Add lock ops for SST SPI NOR flash
SST SPI NOR flash has the same locking programming bits
as ST Micro - added support for it.

Signed-off-by: Fabio Estevam <fabio.estevam@freescale.com>
[Minor change on commit message]
Signed-off-by: Jagan Teki <jteki@openedev.com>
Reviewed-by: Jagan Teki <jteki@openedev.com>
2015-11-18 00:26:26 +05:30
Jagan Teki
7693fb3756 sf: Remove eeprom_m95xxx test driver
The relevent boards which used this driver got zapped
in previous release and the driver is never used in the
code and also it doesn't use/do any spi-flash operations.

Commit details for relevent removed boards:
"ARM: at91: remove non-generic boards"
(sha1: f6b42c1403)

Cc: Tom Rini <trini@konsulko.com>
Cc: Albin Tonnerre <albin.tonnerre@free-electrons.com>
Signed-off-by: Jagan Teki <jteki@openedev.com>
2015-11-18 00:01:07 +05:30
Bin Meng
439fcb9b4f sf: Fix NULL pointer exception for flashes without lock methods
commit c3c016c "sf: Add SPI NOR protection mechanism" introduced
flash_lock()/flash_unlock()/flash_is_locked() methods for SPI flash,
but not every flash driver supplies these. We should test these
methods against NULL before actually calling them.

Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
Reviewed-by: Fabio Estevam <fabio.estevam@freescale.com>
Reviewed-by: Jagan Teki <jteki@openedev.com>
2015-11-13 09:47:22 -05:00
Maxime Ripard
10b6971215 mtd: uboot: Add meaningful error message
The current error message in get_part if CONFIG_MTDPARTS is disabled is
"offset is not a number" which is confusing and doesn't help at all.

Change that for something that might give a hint on what's going on.

Signed-off-by: Maxime Ripard <maxime.ripard@free-electrons.com>
Reviewed-by: Tom Rini <trini@konsulko.com>
2015-11-12 13:17:28 -05:00