Commit Graph

425 Commits

Author SHA1 Message Date
Boris Brezillon ef964b0175 UPSTREAM: mtd: Don't stop MTD partition creation when it fails on one device
MTD partition creation code is a bit tricky. It tries to figure out
when things have changed (either MTD dev list or mtdparts/mtdids vars)
and when that happens it first deletes all the partitions that had been
previously created and then creates the new ones based on the new
mtdparts/mtdids values.
But before deleting the old partitions, it ensures that none of the
currently registered parts are being used and bails out when that's
not the case. So, we end up in a situation where, if at least one MTD
dev has one of its partitions used by someone (UBI for instance), the
partitions update logic no longer works for other devs.

Rework the code to relax the logic and allow updates of MTD parts on
devices that are not being used (we still refuse to updates parts on
devices who have at least one of their partitions used by someone).

Fixes: 5db66b3aee6f ("cmd: mtd: add 'mtd' command")
Change-Id: I789ff4aef0fa6e25a85e48ef7a98cfcead4b81bb
Signed-off-by: Boris Brezillon <boris.brezillon@bootlin.com>
Tested-by: Heiko Schocher <hs@denx.de>
Signed-off-by: Jon Lin <jon.lin@rock-chips.com>
(cherry picked from commit 4a5594fa20d0fa6479f477d2bd67967aca201c2f)
2019-07-05 19:33:47 +08:00
Boris Brezillon 002d1762d9 UPSTREAM: mtd: Delete partitions attached to the device when a device is deleted
If we don't do that, partitions might still be exposed while the
underlying device is gone.

Fixes: 2a74930da57f ("mtd: mtdpart: implement proper partition handling")
Change-Id: Ibf4a89f2caab24e6fdfb9c2dbd42fc4114b4bbe6
Signed-off-by: Boris Brezillon <boris.brezillon@bootlin.com>
Tested-by: Heiko Schocher <hs@denx.de>
Signed-off-by: Jon Lin <jon.lin@rock-chips.com>
(cherry picked from commit a02820fca90ce9ccf243b3fce59c04dabd5671a8)
2019-07-05 19:33:47 +08:00
Boris Brezillon 90108c6c51 UPSTREAM: mtd: Add a function to report when the MTD dev list has been updated
We need to parse mtdparts/mtids again everytime a device has been
added/removed from the MTD list, but there's currently no way to know
when such an update has been done.

Add an ->updated field to the idr struct that we set to true every time
a device is added/removed and expose a function returning the value
of this field and resetting it to false.

Change-Id: If7edb8fde01051087b43eb16683aca6b991daace
Signed-off-by: Boris Brezillon <boris.brezillon@bootlin.com>
Tested-by: Heiko Schocher <hs@denx.de>
Signed-off-by: Jon Lin <jon.lin@rock-chips.com>
(cherry picked from commit 4c47fd0b6bce62162e11b8a22e2eaf0d8f6673b1)
2019-07-05 19:33:46 +08:00
Stefan Roese 6eb4b036a3 UPSTREAM: mtd: nand: spi: Add Gigadevice SPI NAND support
This patch adds support for Gigadevices SPI NAND device to the new SPI
NAND infrastructure in U-Boot. Currently only the 128MiB GD5F1GQ4UC
device is supported.

Change-Id: I9939a71a038b27bb7250dec0617a0d11e18f03dd
Signed-off-by: Stefan Roese <sr@denx.de>
Cc: Miquel Raynal <miquel.raynal@bootlin.com>
Cc: Boris Brezillon <boris.brezillon@bootlin.com>
Cc: Jagan Teki <jagan@openedev.com>
Reviewed-by: Miquel Raynal <miquel.raynal@bootlin.com>
Acked-by: Jagan Teki <jagan@openedev.com>
Signed-off-by: Jon Lin <jon.lin@rock-chips.com>
(cherry picked from commit 9e5c2a755a6ca5f3931de548f43101d0d18ac003)
2019-07-05 19:33:44 +08:00
Miquel Raynal c7314be430 UPSTREAM: mtd: mtdpart: implement proper partition handling
Instead of collecting partitions in a flat list, create a hierarchy
within the mtd_info structure: use a partitions list to keep track of
the partitions of an MTD device (which might be itself a partition of
another MTD device), a pointer to the parent device (NULL when the MTD
device is the root one, not a partition).

By also saving directly in mtd_info the offset of the partition, we
can get rid of the mtd_part structure.

Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Reviewed-by: Stefan Roese <sr@denx.de>
Reviewed-by: Boris Brezillon <boris.brezillon@bootlin.com>
Change-Id: I87c81be7b75c7d71db5dce2fb4b0cfb1ec1a0fe2
Signed-off-by: Jon Lin <jon.lin@rock-chips.com>
(cherry picked from commit 2a74930da57f6fbe3c24509f1d481f435acd2356)
2019-07-05 19:33:44 +08:00
Miquel Raynal 504668197e UPSTREAM: mtd: uboot: search for an equivalent MTD name with the mtdids
Using an MTD device (resp. partition) name in mtdparts is simple and
straightforward. However, for a long time already, another name was
given in mtdparts to indicate a device (resp. partition) so the
"mtdids" environment variable was created to do the match.

Let's create a function that, from an MTD device (resp. partition)
name, search for the equivalent name in the "mtdparts" environment
variable thanks to the "mtdids" string.

Change-Id: I0fbf73baa9623bb933dd268d7a88dd2746a30d6d
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Reviewed-by: Stefan Roese <sr@denx.de>
Reviewed-by: Boris Brezillon <boris.brezillon@bootlin.com>
Signed-off-by: Jon Lin <jon.lin@rock-chips.com>
(cherry picked from commit ff4afa8a981e22eef670c7c857cb87983346cc2c)
2019-07-05 19:33:44 +08:00
Miquel Raynal 3de98b82f9 UPSTREAM: mtd: mtdpart: add a generic mtdparts-like parser
The current parser is very specific to U-Boot mtdparts implementation.
It does not use MTD structures like mtd_info and mtd_partition. Copy
and adapt the current parser in drivers/mtd/mtd-uclass.c (to not break
the current use of mtdparts.c itself) and write some kind of a wrapper
around the current implementation to allow other commands to benefit
from this parsing in a user-friendly way.

This new function will allocate an mtd_partition array for each
successful call. This array must be freed after use by the caller.
The given 'mtdparts' buffer pointer will be moved forward to the next
MTD device (if any, it will point towards a '\0' character otherwise).

Change-Id: If785967e93395e883636695c669a52c60d2a043d
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Acked-by: Jagan Teki <jagan@openedev.com>
Reviewed-by: Stefan Roese <sr@denx.de>
Reviewed-by: Boris Brezillon <boris.brezillon@bootlin.com>
Signed-off-by: Jon Lin <jon.lin@rock-chips.com>
(cherry picked from commit 21cc1fb5af06e468c74ae601bac719d306523f9c)
2019-07-05 19:33:44 +08:00
Boris Brezillon 80c0c832a1 UPSTREAM: mtd: spinand: Add initial support for the MX35LF1GE4AB chip
Add minimal support for the MX35LF1GE4AB SPI NAND chip.

Change-Id: Ifb036b16f09086f5cda092c30bb850d1f91668a4
Signed-off-by: Boris Brezillon <boris.brezillon@bootlin.com>
Acked-by: Jagan Teki <jagan@openedev.com>
Signed-off-by: Jon Lin <jon.lin@rock-chips.com>
(cherry picked from commit 6f041ccabb03bea16c2f21f3254dc9c1cb38425c)
2019-07-05 19:33:44 +08:00
Frieder Schrempf b98ac5e2ee UPSTREAM: mtd: spinand: Add initial support for Winbond W25M02GV
Add support for the W25M02GV chip.

Change-Id: Iad3e56fb79484fe8bd809c74f033ca1cc270c68b
Signed-off-by: Frieder Schrempf <frieder.schrempf@exceet.de>
Signed-off-by: Boris Brezillon <boris.brezillon@bootlin.com>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Acked-by: Jagan Teki <jagan@openedev.com>
Signed-off-by: Jon Lin <jon.lin@rock-chips.com>
(cherry picked from commit 3181c0a622d35bd8e6d4407458e7204d4df5a8c1)
2019-07-05 19:33:44 +08:00
Peter Pan ed13557fe1 UPSTREAM: mtd: spinand: Add initial support for Micron MT29F2G01ABAGD
Add a basic driver for Micron SPI NANDs. Only one device is supported
right now, but the driver will be extended to support more devices
afterwards.

Change-Id: I00be31e80599565e8bd3c01e17177c6594f5b98b
Signed-off-by: Peter Pan <peterpandong@micron.com>
Signed-off-by: Boris Brezillon <boris.brezillon@bootlin.com>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Acked-by: Jagan Teki <jagan@openedev.com>
Signed-off-by: Jon Lin <jon.lin@rock-chips.com>
(cherry picked from commit 883d8778ae177172c0a53c018faa39e61f30dea3)
2019-07-05 19:33:44 +08:00
Peter Pan 749af7cd07 UPSTREAM: mtd: nand: Add core infrastructure to support SPI NANDs
Add a SPI NAND framework based on the generic NAND framework and the
spi-mem infrastructure.

In its current state, this framework supports the following features:

- single/dual/quad IO modes
- on-die ECC

Change-Id: Ifdb3001b7570e0e034f7125c4b66053462f2aed2
Signed-off-by: Peter Pan <peterpandong@micron.com>
Signed-off-by: Boris Brezillon <boris.brezillon@bootlin.com>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Acked-by: Jagan Teki <jagan@openedev.com>
Signed-off-by: Jon Lin <jon.lin@rock-chips.com>
(cherry picked from commit 0a6d6bae03864938f073cc114992c40f2338a155)
2019-07-05 19:33:44 +08:00
Boris Brezillon ed99f7731a UPSTREAM: mtd: nand: Add core infrastructure to deal with NAND devices
Add an intermediate layer to abstract NAND device interface so that
some logic can be shared between SPI NANDs, parallel/raw NANDs,
OneNANDs, ...

Change-Id: I0c2b2e3ddae912756a35aac2741dd1ce8a243b35
Signed-off-by: Boris Brezillon <boris.brezillon@bootlin.com>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Acked-by: Jagan Teki <jagan@openedev.com>
Signed-off-by: Jon Lin <jon.lin@rock-chips.com>
(cherry picked from commit b95db8d33a1e920801816e47ffc5c6f18acce024)
2019-07-05 19:33:44 +08:00
Miquel Raynal ac199d1339 UPSTREAM: mtd: move definitions to enlarge their range
Some helpers might be useful in a future 'mtd' U-Boot command to parse
MTD device list.

Change-Id: I127b2a919e781c749271caa8d2186a69edb70982
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Signed-off-by: Jon Lin <jon.lin@rock-chips.com>
(cherry picked from commit d02f1d36ec6fe6bfadd77fa71b1df228010ddaa8)
2019-07-05 19:33:44 +08:00
Ezequiel Garcia 86db6a459f UPSTREAM: mtd: Uninline mtd_write_oob and move it to mtdcore.c
There's no reason for having mtd_write_oob inlined in mtd.h header.
Move it to mtdcore.c where it belongs.

Change-Id: I1e06b151912689171ff9c66f95cba13f256d27a1
Signed-off-by: Ezequiel Garcia <ezequiel@vanguardiasur.com.ar>
Acked-by: Boris Brezillon <boris.brezillon@free-electrons.com>
Signed-off-by: Jacek Anaszewski <j.anaszewski@samsung.com>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Signed-off-by: Jon Lin <jon.lin@rock-chips.com>
(cherry picked from commit 5f50d82d8918b711717b4bbd96c6f348eb6e2a2c)
2019-07-05 19:33:44 +08:00
Jörg Krause 46c3d471e4 UPSTREAM: mtd: nand: export nand_get_flash_type function
`nand_get_flash_type()` allows identification of supported NAND flashs.
The function is useful in SPL (like mxs_nand_spl.c) to lookup for a NAND
flash (which does not support ONFi) instead of using nand_simple.c and
hard-coding all required NAND parameters.

Change-Id: I469c18019d13e8e7f5105ece92c581047e751924
Signed-off-by: Jörg Krause <joerg.krause@embedded.rocks>
Signed-off-by: Jon Lin <jon.lin@rock-chips.com>
(cherry picked from commit da37d096820e15b2bcdb0243da2dc01707c650f2)
2019-07-05 19:33:39 +08:00
Alexey Brodkin 28386b6dc6 UPSTREAM: lib: Add hexdump
Often during debugging session it's very interesting to see
what data we were dealing with. For example what we write or read
to/from memory or peripherals.

This change introduces functions that allow to dump binary
data with one simple function invocation like:
------------------->8----------------
print_hex_dump_bytes("", DUMP_PREFIX_OFFSET, buf, len);
------------------->8----------------

which gives us the following:
------------------->8----------------
00000000: f2 b7 c9 88 62 61 75 64 72 61 74 65 3d 31 31 35  ....baudrate=115
00000010: 32 30 30 00 62 6f 6f 74 61 72 67 73 3d 63 6f 6e  200.bootargs=con
00000020: 73 6f 6c 65 3d 74 74 79 53 33 2c 31 31 35 32 30  sole=ttyS3,11520
00000030: 30 6e 38 00 62 6f 6f 74 64 65 6c 61 79 3d 33 00  0n8.bootdelay=3.
00000040: 62 6f 6f 74 66 69 6c 65 3d 75 49 6d 61 67 65 00  bootfile=uImage.
00000050: 66 64 74 63 6f 6e 74 72 6f 6c 61 64 64 72 3d 39  fdtcontroladdr=9
00000060: 66 66 62 31 62 61 30 00 6c 6f 61 64 61 64 64 72  ffb1ba0.loadaddr
00000070: 3d 30 78 38 32 30 30 30 30 30 30 00 73 74 64 65  =0x82000000.stde
00000080: 72 72 3d 73 65 72 69 61 6c 30 40 65 30 30 32 32  rr=serial0@e0022
00000090: 30 30 30 00 73 74 64 69 6e 3d 73 65 72 69 61 6c  000.stdin=serial
000000a0: 30 40 65 30 30 32 32 30 30 30 00 73 74 64 6f 75  0@e0022000.stdou
000000b0: 74 3d 73 65 72 69 61 6c 30 40 65 30 30 32 32 30  t=serial0@e00220
000000c0: 30 30 00 00 00 00 00 00 00 00 00 00 00 00 00 00  00..............
...
------------------->8----------------

Source of hexdump.c was copied from Linux kernel v4.7-rc2.

Signed-off-by: Alexey Brodkin <abrodkin@synopsys.com>
Cc: Anatolij Gustschin <agust@denx.de>
Cc: Mario Six <mario.six@gdsys.cc>
Cc: Simon Glass <sjg@chromium.org>
Cc: Tom Rini <trini@konsulko.com>
Cc: Stefan Roese <sr@denx.de>

Change-Id: I038b41f51d45d1b853da499578bf8ef384a63730
Signed-off-by: Jon Lin <jon.lin@rock-chips.com>
(cherry picked from commit f8c987f8f127f867d96ca74bcd1fcb11d8265b67)
2019-07-05 19:33:39 +08:00
Masahiro Yamada f1ba13f8e2 UPSTREAM: libfdt: move headers to <linux/libfdt.h> and <linux/libfdt_env.h>
Thomas reported U-Boot failed to build host tools if libfdt-devel
package is installed because tools include libfdt headers from
/usr/include/ instead of using internal ones.

This commit moves the header code:
  include/libfdt.h         -> include/linux/libfdt.h
  include/libfdt_env.h     -> include/linux/libfdt_env.h

and replaces include directives:
  #include <libfdt.h>      -> #include <linux/libfdt.h>
  #include <libfdt_env.h>  -> #include <linux/libfdt_env.h>

Change-Id: I68fd5734d6460c169fa5ee2893c57cb5d73340b6
Reported-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Signed-off-by: Jon Lin <jon.lin@rock-chips.com>
(cherry picked from commit b08c8c4870831c9315dcae237772238e80035bd5)
2019-07-05 19:33:35 +08:00
Masahiro Yamada 331c237568 UPSTREAM: mtd: nand: Rename nand.h into rawnand.h
This header was renamed to rawnand.h in Linux.

The following is the corresponding commit in Linux.

  commit d4092d76a4a4e57b65910899948a83cc8646c5a5
  Author: Boris Brezillon <boris.brezillon@free-electrons.com>
  Date:   Fri Aug 4 17:29:10 2017 +0200

      mtd: nand: Rename nand.h into rawnand.h

      We are planning to share more code between different NAND based
      devices (SPI NAND, OneNAND and raw NANDs), but before doing that
      we need to move the existing include/linux/mtd/nand.h file into
      include/linux/mtd/rawnand.h so we can later create a nand.h header
      containing all common structure and function prototypes.

Change-Id: Ia387c26297c268a449e3451c7adfabcd6417b278
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Signed-off-by: Jon Lin <jon.lin@rock-chips.com>
(cherry picked from commit 6ae3900a86b52429bf7a73ad832f0ad02acc2282)
2019-07-05 19:21:04 +08:00
Masahiro Yamada b48ce1006a UPSTREAM: mtd: nand: introduce NAND_ROW_ADDR_3 flag
Several drivers check ->chipsize to see if the third row address cycle
is needed.  Instead of embedding magic sizes such as 32MB, 128MB in
drivers, introduce a new flag NAND_ROW_ADDR_3 for clean-up.  Since
nand_scan_ident() knows well about the device, it can handle this
properly.  The flag is set if the row address bit width is greater
than 16.

Delete comments such as "One more address cycle for ..." because
intention is now clear enough from the code.

Change-Id: I46c6ce88e75faf27564297bcd8f69f34407feff7
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Acked-by: Wenyou Yang <wenyou.yang@microchip.com>
Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com>
[Linux commit: 14157f861437ebe2d624b0a845b91bbdf8ca9a2d]
Signed-off-by: Jon Lin <jon.lin@rock-chips.com>
(cherry picked from commit e6001371d1603f00a98af9e6dd73abdbbffd2784)
2019-07-05 19:21:04 +08:00
Masahiro Yamada 2416d1a307 UPSTREAM: mtd: nand: add generic helpers to check, match, maximize ECC settings
Driver are responsible for setting up ECC parameters correctly.
Those include:
  - Check if ECC parameters specified (usually by DT) are valid
  - Meet the chip's ECC requirement
  - Maximize ECC strength if NAND_ECC_MAXIMIZE flag is set

The logic can be generalized by factoring out common code.

This commit adds 3 helpers to the NAND framework:
nand_check_ecc_caps - Check if preset step_size and strength are valid
nand_match_ecc_req - Match the chip's requirement
nand_maximize_ecc - Maximize the ECC strength

To use the helpers above, a driver needs to provide:
  - Data array of supported ECC step size and strength
  - A hook that calculates ECC bytes from the combination of
    step_size and strength.

By using those helpers, code duplication among drivers will be
reduced.

Change-Id: I74551caae9c08de925327b8550221e5c75d123c2
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com>
[Linux commit: 2c8f8afa7f92acb07641bf95b940d384ed1d0294]
Signed-off-by: Jon Lin <jon.lin@rock-chips.com>
(cherry picked from commit 470c29d1c28d23bdd86456bc431b8f26f8727903)
2019-07-05 19:21:04 +08:00
Boris Brezillon 61083dd4cd UPSTREAM: mtd: nand: Pass the CS line to ->setup_data_interface()
Some NAND controllers can assign different NAND timings to different
CS lines. Pass the CS line information to ->setup_data_interface() so
that the NAND controller driver knows which CS line is concerned by
the setup_data_interface() request.

Change-Id: I752cbd4374e56b0370bdbfa3ecb207f6ec1f5145
Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com>
[Linux commit: 104e442a67cfba4d0cc982384761befb917fb6a1]
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Signed-off-by: Jon Lin <jon.lin@rock-chips.com>
(cherry picked from commit 52cde35b9645e60a0c8e4040136476c4f9804110)
2019-07-05 19:21:04 +08:00
Masahiro Yamada 206756d491 UPSTREAM: mtd: nand: allow drivers to request minimum alignment for passed buffer
In some cases, nand_do_{read,write}_ops is passed with unaligned
ops->datbuf.  Drivers using DMA will be unhappy about unaligned
buffer.

The new struct member, buf_align, represents the minimum alignment
the driver require for the buffer.  If the buffer passed from the
upper MTD layer does not have enough alignment, nand_do_*_ops will
use bufpoi.

Change-Id: I83feb4e3fe7d612b3fc2ec46008f540834f2c185
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com>
[Linux commit: 477544c62a84d3bacd9f90ba75ffc16c04d78071]
Signed-off-by: Jon Lin <jon.lin@rock-chips.com>
(cherry picked from commit 436fb2b84dc24853298f1768c596f7ee02d582d7)
2019-07-05 19:21:04 +08:00
Boris Brezillon 7939380356 UPSTREAM: mtd: nand: Drop the ->errstat() hook
The ->errstat() hook is no longer implemented NAND controller drivers.
Get rid of it before someone starts abusing it.

Change-Id: I6920981bf0c7c0fad9b017f83a3a075ad898d9be
Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com>
[Linux commit: 7d135bcced20be2b50128432c5426a7278ec4f6d]
[masahiro: modify davinci_nand.c for U-Boot]
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Signed-off-by: Jon Lin <jon.lin@rock-chips.com>
(cherry picked from commit 94b50a8aae1a6e1514cb39ecb2d2aec0824582f6)
2019-07-05 19:21:04 +08:00
Boris Brezillon 271c54fdad UPSTREAM: mtd: nand: Drop unused cached programming support
Cached programming is always skipped, so drop the associated code until
we decide to really support it.

Change-Id: Ife766710fad3e88ccc2e156aeb7f46924c44fd2d
Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com>
[Linux commit: 0b4773fd1649e0d418275557723a7ef54f769dc9]
[masahiro: modify davinci_nand.c for U-Boot]
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Signed-off-by: Jon Lin <jon.lin@rock-chips.com>
(cherry picked from commit 4d75596e6d27315a05253d85e870d28cda972d45)
2019-07-05 19:21:04 +08:00
Boris Brezillon c44c4cceac UPSTREAM: mtd: add mtd_ooblayout_xxx() helper functions
In order to make the ecclayout definition completely dynamic we need to
rework the way the OOB layout are defined and iterated.

Create a few mtd_ooblayout_xxx() helpers to ease OOB bytes manipulation
and hide ecclayout internals to their users.

Change-Id: I6248b25d56d8ac9074bfb8e76140a78f0803a433
Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com>
[Linux commit: 75eb2cec251fda33c9bb716ecc372819abb9278a]
[masahiro:
 cherry-pick more code from adbbc3bc827eb1f43a932d783f09ba55c8ec8379]
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Signed-off-by: Jon Lin <jon.lin@rock-chips.com>
(cherry picked from commit 13f3b04f61aa6a0ec61bf01bb404f21c10b48bd0)
2019-07-05 19:21:04 +08:00
Marc Gonzalez 5f649222ed UPSTREAM: mtd: nand: Support controllers with custom page
If your controller already sends the required NAND commands when
reading or writing a page, then the framework is not supposed to
send READ0 and SEQIN/PAGEPROG respectively.

Change-Id: I55b5e5f4fbe1f417b60794c234ffdb48c7900d70
Signed-off-by: Marc Gonzalez <marc_gonzalez@sigmadesigns.com>
Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com>
[Linux commit: 3371d663bb4579f1b2003a92162edd6d90edd089]
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Signed-off-by: Jon Lin <jon.lin@rock-chips.com>
(cherry picked from commit 1fb87de83dd6e76307e110100f265deb2d8d8163)
2019-07-05 19:21:04 +08:00
Boris Brezillon c47e7cbb07 UPSTREAM: mtd: nand: Add a few more timings to nand_sdr_timings
Add the tR_max, tBERS_max, tPROG_max and tCCS_min timings to the
nand_sdr_timings struct.
Assign default/safe values for the statically defined timings, and
extract them from the ONFI parameter table if the NAND is ONFI
compliant.

Change-Id: Id5d29cfbab072d3500f23a997e63b1ba6e5b64ff
Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com>
Tested-by: Marc Gonzalez <marc_gonzalez@sigmadesigns.com>
[Linux commit: 204e7ecd47e26cc12d9e8e8a7e7a2eeb9573f0ba
 Fixup commit: 6d29231000bbe0fb9e4893a9c68151ffdd3b5469]
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Signed-off-by: Jon Lin <jon.lin@rock-chips.com>
(cherry picked from commit 6f84b26b53afa207092a8906fa08f4c78d65afb6)
2019-07-05 19:21:04 +08:00
Boris Brezillon 36efa0ccf7 UPSTREAM: mtd: nand: Fix data interface configuration logic
When changing from one data interface setting to another, one has to
ensure a specific sequence which is described in the ONFI spec.

One of these constraints is that the CE line has go high after a reset
before a command can be sent with the new data interface setting, which
is not guaranteed by the current implementation.

Rework the nand_reset() function and all the call sites to make sure the
CE line is asserted and released when required.

Also make sure to actually apply the new data interface setting on the
first die.

Change-Id: I5c8bd5b3342823510771c9fbb9fa637208cce037
Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com>
Fixes: d8e725dd8311 ("mtd: nand: automate NAND timings selection")
Reviewed-by: Sascha Hauer <s.hauer@pengutronix.de>
Tested-by: Marc Gonzalez <marc_gonzalez@sigmadesigns.com>
[Linux commit: 73f907fd5fa56b0066d199bdd7126bbd04f6cd7b]
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Signed-off-by: Jon Lin <jon.lin@rock-chips.com>
(cherry picked from commit 3d841b3214565640ada80baa0f73885cddd216be)
2019-07-05 19:20:53 +08:00
Boris Brezillon 38657f6e0f UPSTREAM: mtd: nand: automate NAND timings selection
The NAND framework provides several helpers to query timing modes supported
by a NAND chip, but this implies that all NAND controller drivers have
to implement the same timings selection dance. Also currently NAND
devices can be resetted at arbitrary places which also resets the timing
for ONFI chips to timing mode 0.

Provide a common logic to select the best timings based on ONFI or
->onfi_timing_mode_default information. Hook this into nand_reset()
to make sure the new timing is applied each time during a reset.

NAND controller willing to support timings adjustment should just
implement the ->setup_data_interface() method.

Change-Id: I9a70d62e3e7144d348ee98bb15cc70f2d229eb65
Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
[Linux commit: d8e725dd831186a3595036b2b1df9f68cbc6efa3]
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Signed-off-by: Jon Lin <jon.lin@rock-chips.com>
(cherry picked from commit 27c4792cd233ba68fa15aaa885d0f53db7b5728a)
2019-07-05 19:20:53 +08:00
Sascha Hauer 0f9f2da379 UPSTREAM: mtd: nand: Expose data interface for ONFI mode 0
The nand layer will need ONFI mode 0 to use it as timing mode
before and right after reset.

Change-Id: If79882c9ae5256c817f331157bf108148b214b39
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com>
[Linux commit: 6e1f9708dbf3c50a8da93c1952a01a7a2acb5e66]
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Signed-off-by: Jon Lin <jon.lin@rock-chips.com>
(cherry picked from commit b893e83330662393ff40d4dc8cb2733599beb26a)
2019-07-05 19:20:53 +08:00
Sascha Hauer e56ea81c67 UPSTREAM: mtd: nand: convert ONFI mode into data interface
struct nand_data_interface is the designated type to pass to
the NAND drivers to configure the timing. To simplify further
patches convert the onfi_sdr_timings array from type struct
nand_sdr_timings nand_data_interface.

Change-Id: I9c9422bf02986844e3f6b57381ca62ed9c5a66b7
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com>
[Linux commit: b1dd3ca203fccd111926c3f6ac59bf903ec62b05]
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Signed-off-by: Jon Lin <jon.lin@rock-chips.com>
(cherry picked from commit 46deff57da190fee1a902ecfbf951cd4cfe8494e)
2019-07-05 19:20:53 +08:00
Sascha Hauer 2b17534304 UPSTREAM: mtd: nand: Create a NAND reset function
When NAND devices are resetted some initialization may have to be done,
like for example they have to be configured for the timing mode that
shall be used. To get a common place where this initialization can be
implemented create a nand_reset() function. This currently only issues
a NAND_CMD_RESET to the NAND device. The places issuing this command
manually are replaced with a call to nand_reset().

Change-Id: Id5e060d521d5f7835e928633515e6f4a02ba72fa
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com>
[Linux commit: 2f94abfe35b210e7711af9202a3dcfc9e779219a]
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Signed-off-by: Jon Lin <jon.lin@rock-chips.com>
(cherry picked from commit 1728eb577dc1de459196ca45068f3feced77a198)
2019-07-05 19:20:53 +08:00
Boris Brezillon 5e8564cf41 UPSTREAM: mtd: nand: Add an option to maximize the ECC strength
The generic NAND DT bindings allows one to tweak the ECC strength and
step size to their need. It can be used to lower the ECC strength to
match a bootloader/firmware config, but might also be used to get a better
reliability.

In the latter case, the user might want to use the maximum ECC strength
without having to explicitly calculate the exact value (this value not
only depends on the OOB size, but also on the NAND controller, and can
be tricky to extract).

Add a generic 'nand-ecc-maximize' DT property and the associated
NAND_ECC_MAXIMIZE flag, to let ECC controller drivers select the best
ECC strength and step-size on their own.

Change-Id: I9303c1f99c9abc0656cf25825bb2d70b40aaf00d
Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com>
Acked-by: Rob Herring <robh@kernel.org>
[Linux commit: ba78ee00e1ff84de9b3ad33edbd3ec599099ee82]
[masahiro: of_property_read_bool -> fdt_getprop for U-Boot]
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Signed-off-by: Jon Lin <jon.lin@rock-chips.com>
(cherry picked from commit 19d30ded88fb8b89c8426e6d95ded19ba900f314)
2019-07-05 19:20:53 +08:00
Shixiang Zheng ffa55e1823 video/drm: add panel node parameters for screen rotate
Change-Id: I83112f8a05bd301327d7d1ca21eda97594d95823
Signed-off-by: Shixiang Zheng <shixiang.zheng@rock-chips.com>
2019-06-11 09:30:25 +08:00
Wyon Bi cfb50d9acf media: Add MEDIA_BUS_FMT_RGB666_1X7X3_JEIDA media bus code definitions
This patch adds a new RGB media bus formats that describe
18-bit samples transferred over an LVDS bus with three
differential data pairs, serialized into 7 time slots,
using standard JEIDA data ordering.

Change-Id: I54b674aa8b067452007de076010dbd6a3c7f4a52
Signed-off-by: Wyon Bi <bivvy.bi@rock-chips.com>
2019-02-20 09:14:12 +08:00
Joseph Chen d0df954bf3 arm: lib: add arm32/64 stacktrace support
This patch supports dump arm32/64 stacktrace as the format of raw
address info. The U-Boot symbol table is not available now, please
use ./scripts/stacktrace.sh script to parse stacktrace info with command:

    ./scripts/stacktrace.sh <file>       // stacktrace info file

Example on RK3399:
    Call trace:
     PC:   [< 00258a7c >]  dwc3_gadget_uboot_handle_interrupt+0xa0/0x5bc
     LR:   [< 002052f8 >]  usb_gadget_handle_interrupts+0x10/0x1c

    Stack:
           [< 00258a7c >]  dwc3_gadget_uboot_handle_interrupt+0xa0/0x5bc
           [< 0025bd6c >]  sleep_thread.isra.20+0xb0/0x114
           [< 0025cf58 >]  fsg_main_thread+0x2c8/0x1814
           [< 0020db58 >]  do_rkusb+0x250/0x338
           [< 00226a00 >]  cmd_process+0xac/0xe0
           [< 00212df4 >]  run_list_real+0x6fc/0x72c
           [< 00212f94 >]  parse_stream_outer+0x170/0x67c
           [< 002126e0 >]  parse_string_outer+0xdc/0xf4
           [< 00212bb0 >]  run_list_real+0x4b8/0x72c
           [< 00212f94 >]  parse_stream_outer+0x170/0x67c
           [< 00212698 >]  parse_string_outer+0x94/0xf4
           [< 00225f30 >]  run_command_list+0x38/0x90
           [< 00202d08 >]  rockchip_dnl_mode_check+0x4c/0xd4
           [< 00202db0 >]  setup_boot_mode+0x20/0xf0
           [< 00203010 >]  board_late_init+0x10/0x40
           [< 0027071c >]  initcall_run_list+0x44/0x80
           [< 00213d68 >]  board_init_r+0x20/0x24

The "dump_stack()" is available to trigger stacktrace.

Change-Id: Ib1423269dd255fa4a34231489cd3b7e6ddd22540
Signed-off-by: Joseph Chen <chenjh@rock-chips.com>
2019-02-13 09:04:23 +08:00
Masahiro Yamada 0e00a84cde UPSTREAM: libfdt: move headers to <linux/libfdt.h> and <linux/libfdt_env.h>
Thomas reported U-Boot failed to build host tools if libfdt-devel
package is installed because tools include libfdt headers from
/usr/include/ instead of using internal ones.

This commit moves the header code:
  include/libfdt.h         -> include/linux/libfdt.h
  include/libfdt_env.h     -> include/linux/libfdt_env.h

and replaces include directives:
  #include <libfdt.h>      -> #include <linux/libfdt.h>
  #include <libfdt_env.h>  -> #include <linux/libfdt_env.h>

Change-Id: I6c0f7e50e8b571106627f25ddac008a62bd2994e
Reported-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Signed-off-by: Kever Yang <kever.yang@rock-chips.com>
2018-12-24 17:20:37 +08:00
William Wu 3e4afe6b7c usb: phy: rockchip: support vbus detect for rk3288
This patch implements USB vbus detect API for rk3288,
it can be used for user to determine whether enter
download mode or not.

Change-Id: Ic493b40b56cd149ec19f57ce914d70d288c54ca9
Signed-off-by: William Wu <william.wu@rock-chips.com>
2018-12-18 17:30:47 +08:00
Joseph Chen 2c6a058b7e rockchip: implement board_lmb_reserve()
Using last bi_dram[...] to initialize "bootm_low" and "bootm_mapsize".
This makes lmb_alloc_base() always alloc from tail of sdram.
If we don't assign it, bi_dram[0] is used by default and it may cause
lmb_alloc_base() fail when bi_dram[0] range is small.

Change-Id: I13c2c2d6135e26e647dcfde4c173d896c800fea5
Signed-off-by: Joseph Chen <chenjh@rock-chips.com>
2018-11-13 14:07:56 +08:00
William Wu 26dd3474b3 usb: gadget: add SuperSpeed support to the Gadget Framework
This patch implements the Binary Device Object Store (BOS)
Descriptor for SuperSpeed. It also add SuperSpeed Endpoint
Descriptors for fastboot and rockusb gadget.

Change-Id: I7d858e1b5117d403919f5fdacb40072a5fad336f
Signed-off-by: William Wu <william.wu@rock-chips.com>
2018-10-16 15:22:02 +08:00
Algea Cao 8e2bab3fc5 drm: Transplant dw-hdmi code from rkdevelop
1.Updating edid parse method.
2.New hdmi i2c control method.
3.Adding mode filter.
4.Adding color select method.
5.Support hdmi 2.0.
6.Adding baseparameter reading.
7.Support HDCP 1.4.

Tested in rk3399/rk3229/rk3128h/rk3328.

Change-Id: I2b3b1fb0079e97ba4b737781356e920548d6ad75
Signed-off-by: Algea Cao <algea.cao@rock-chips.com>
2018-08-15 10:10:19 +08:00
Frank Wang 57ab23a62c rockchip: boot_mode: add usb-vbus detect support
Checked the usb-vbus status after the download key had been pressed in
case of there was no usb-cable plugged in PC.

Change-Id: Iece797be68f0f3094f3137e4c90a53000fb9ffe2
Signed-off-by: Frank Wang <frank.wang@rock-chips.com>
2018-02-28 14:36:58 +08:00
Masahiro Yamada 1b48bbdd20 UPSTREAM: bitops: collect BIT macros to include/linux/bitops.h
Same macros are defined in various places.  Collect them into
include/linux/bitops.h like Linux.

Change-Id: I81d12e8c8151c6eb29499d2b5cd61ed782500492
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Signed-off-by: Kever Yang <kever.yang@rock-chips.com>
(cherry picked from commit ed3986ca30972c94f0076f88c948406ce030a05c)
2018-01-17 15:27:28 +08:00
Masahiro Yamada 5d099091a8 UPSTREAM: lib: libfdt: wrap scripts/dtc/libfdt/* where possible
lib/libfdt/ and scripts/dtc/libfdt have the same copies for the
followings 6 files:
  fdt.c fdt_addresses.c fdt_empty_tree.c fdt_overlay.c fdt_strerr.c
  fdt_sw.c

Make them a wrapper of scripts/dtc/libfdt/*.  This is exactly what
Linux does to sync libfdt.  In order to make is possible, import
<linux/libfdt.h> and <linux/libfdt_env.h> from Linux 4.14-rc5.

Unfortunately, U-Boot locally modified the following 3 files:
  fdt_ro.c fdt_wip.c fdt_rw.c

The fdt_region.c is U-Boot own file.

I did not touch them in order to avoid unpredictable impact.

Change-Id: I154855ba51291bf56775714c0066247431d66244
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Signed-off-by: Kever Yang <kever.yang@rock-chips.com>
(cherry picked from commit 50a327ded68b7e675389ad284ea3f8c62e683bda)
2018-01-17 15:27:28 +08:00
Masahiro Yamada d8b625e660 UPSTREAM: linux/types.h: add typedef of uintptr_t
Add this typedef in the same place as in Linux.  This is necessary
to refactor libfdt inclusion.

U-Boot also defines it in include/compiler.h.  Of course it should
not do that, but I do not want to open a can of worms.

Change-Id: I9dfb66591cf520ed4e68168521b114af086fd860
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Signed-off-by: Kever Yang <kever.yang@rock-chips.com>
(cherry picked from commit 1c4b453ad2a62d0243ae5fd6657f2d6b7eb7332d)
2018-01-17 15:27:28 +08:00
Marek Behún 4794b31f85 UPSTREAM: linux/time.h: Remove dead code
Since
  rem = ((long) *tim_p) % SECSPERDAY;
the second while cycle
  while (rem >= SECSPERDAY)
is dead.

Change-Id: I7cb339650cc87f5ab892702adec7f4c147aff77d
Reported-by: Coverity (CID: 167334)
Signed-off-by: Marek Behun <marek.behun@nic.cz>
Signed-off-by: Kever Yang <kever.yang@rock-chips.com>
(cherry picked from commit 502af618ec3d60f3c8b9914e3484f112fb295b6e)
2018-01-17 15:27:28 +08:00
Jean-Jacques Hiblot df70772d8a UPSTREAM: lzo: add a function to check the validity of the header
Change-Id: I8835606db327dc958e90ce717ae4fe85439b46e3
Signed-off-by: Jean-Jacques Hiblot <jjhiblot@ti.com>
Reviewed-by: Tom Rini <trini@konsulko.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
Signed-off-by: Kever Yang <kever.yang@rock-chips.com>
(cherry picked from commit d753f942ec12e6b5b2db73698aa6c55588053d3a)
2018-01-17 15:27:28 +08:00
Masahiro Yamada 263b1d7d68 UPSTREAM: linux/kernel.h: import DIV_ROUND_{DOWN, UP}_ULL from Linux
These macros are useful to avoid link error on 32-bit systems.

Change-Id: Id451c874a2a89e3ebff352e4c90d2d4d0613b9bc
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Signed-off-by: Kever Yang <kever.yang@rock-chips.com>
(cherry picked from commit 84570a0c111ac50372d51271eadc13ff5cbb1a54)
2018-01-17 15:27:28 +08:00
Masahiro Yamada d4496ef3da UPSTREAM: linux/bitfield.h: import <linux/bitfield.h> from Linux 4.13
Copied from Linux 4.13.

Commit log of 3e9b3112ec74 of Linux explains well why this header
is useful.

Change-Id: I6d565317c573e01eb5df2af5a24982db049e8e08
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Signed-off-by: Kever Yang <kever.yang@rock-chips.com>
(cherry picked from commit 6990e91f0971b877cd636e646f93587b1afbb284)
2018-01-17 15:27:28 +08:00
Masahiro Yamada 8f1ef3f536 UPSTREAM: dm: define dev_*() log functions in DM header
Many drivers had started to use dev_err, dev_info, etc. for log
functions.  Currently, we are relying on <linux/compat.h>, but I
guess the best home is <dm/device.h>, taking into account that
Linux defines them in <linux/device.h>.

For now, I am leaving the ones in <linux/compat.h> because lots of
Linux-originated code uses dev_*(), but the first argument is not
struct udevice, so we need to ignore the bogus argument.  More
efforts are needed to iron out the issues.

Change-Id: I18f67bd63ac22d8b69bdf8e0558600c58e8703d2
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
Signed-off-by: Kever Yang <kever.yang@rock-chips.com>
(cherry picked from commit c898cba41e94fa87c57d71911fb812cd34c7a91e)
2018-01-17 15:27:28 +08:00