9
0
Fork 0
Commit Graph

4266 Commits

Author SHA1 Message Date
Sascha Hauer f4714e5f6a Merge branch 'for-next/video' 2016-09-13 14:56:07 +02:00
Sascha Hauer 074a8fdc92 Merge branch 'for-next/socfpga' 2016-09-13 14:56:06 +02:00
Sascha Hauer 0e1892b2e9 Merge branch 'for-next/rockchip' 2016-09-13 14:56:05 +02:00
Sascha Hauer dd534571bd Merge branch 'for-next/misc' 2016-09-13 14:56:05 +02:00
Sascha Hauer b2c398f440 Merge branch 'for-next/imx' 2016-09-13 14:56:04 +02:00
Alexander Kurz 25be41232b ARM: i.MX drivers: enable i.MX50 where already supported
The i.MX50 SOC includes one ESDHCv3, three ESDHCv2, one cspi and
two ecspi instances which are supported by existing drivers.

Signed-off-by: Alexander Kurz <akurz@blala.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-09-12 08:23:09 +02:00
Michael Olbrich faf2ec64e7 mci: mmci: Fix read FIFO handling
According to the Linux kernel and the qemu code, the MMCIFIFOCNT contains
the remaining number of words to read, excluding those that are already in
the FIFO. So the current number of bytes in the FIFO is
host_remain - (readl(base + MMCIFIFOCNT) << 2).

Also writing to MMCIDATACTRL will reset the read counter. As a result,
MCI_DATABLOCKEND is never set and read_bytes() waits forever.

With this change, SD-Card support on qemu vexpress works correctly.

Signed-off-by: Michael Olbrich <m.olbrich@pengutronix.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-09-05 08:53:24 +02:00
Sascha Hauer b5952e8304 usb: i.MX chipidea: Enable VBUS regulator when needed
We should enable VBUS only in host mode, not unconditionally
during probe(). Fix that.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-09-05 08:52:56 +02:00
Philipp Zabel 6ed5b755ba video/edid: Fix edid_to_display_timings error path
edid_to_display_timings is called in drivers/video/imx-ipu-v3/imx-hdmi.c,
drivers/video/simple-panel.c, and drivers/video/edid.c with the struct
display_timings *timings parameter pointing to an embedded struct
display_timings inside a struct fb_info. The timings pointer is not to
be freed in the error path.

Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-09-05 08:27:02 +02:00
Sascha Hauer b82ae64e47 usb: chipidea i.MX: Do not return unnecessary error
We only allow to setup the host/peripheral role once, when it's already
set then we return -EBUSY.
Return 0 instead when we set the same role again and only return -EBUSY
when we actually try to change the role.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-08-29 17:37:41 +02:00
Sascha Hauer ac20c4f03b video: backlight: fix the value of 'brightness_max'
Fixes: 87c6a88 video/backlight-pwm: fix the value of 'brightness_max'.

brightness_max should really contain the number of brightness steps, so
the number of elements in the brightness array.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-08-29 17:36:36 +02:00
Wadim Egorov 62c8ce6c42 mci: dw_mmc: Add RK3288 compatible string
The SDHC used in the RK2928 and RK3288 are compatible with each other.
Add a compatible string for RK3288's SDHC.

Signed-off-by: Wadim Egorov <w.egorov@phytec.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-08-26 07:28:31 +02:00
Wadim Egorov 70abe9e13f clk: Add RK3288 clock driver
Add clk driver for RK3288 SoC. This driver comes from the Linux kernel.
Based on kernel v4.4

Signed-off-by: Wadim Egorov <w.egorov@phytec.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-08-26 07:28:31 +02:00
Wadim Egorov 413a35395a clocksource: Add rk3288 timer driver
This driver comes from the u-boot (v2016.01).

Signed-off-by: Wadim Egorov <w.egorov@phytec.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-08-26 07:28:31 +02:00
Andrey Gusakov 46e30c9ac0 video: tc358767: add eDP video encoder driver
This patch adds support for the Toshiba TC358767 eDP bridge,
connected via DPI.

Signed-off-by: Andrey Gusakov <andrey.gusakov@cogentembedded.com>
Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-08-25 08:28:40 +02:00
Philipp Zabel da03ce9c18 video: add VPL ioctl to get bus format
The i.MX specific DI_MODE VPL ioctl already allows to query the encoder
input bus format. This patch also allows non-i.MX specific encoder drivers
to report their input bus format.

Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-08-25 08:28:40 +02:00
Philipp Zabel 1be6d321ef video: switch to media bus formats
V4L2 pixel formats are supposed to describe video frames in memory. To
describe the pixel format on the hardware bus between display interface
and encoders, use media bus formats, which are more expressive.

This allows to get rid of the custom GBR24 and LVDS666 fourccs.

Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-08-25 08:28:40 +02:00
Antony Pavlov d97eeac4e2 net: phy: of_phy_register_fixed_link(): drop redundant initialization
The phy_device_create() function makes all necessary phydev initialization
so we can drop phydev->pause and phydev->link initialization in
the of_phy_register_fixed_link() function.

Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-08-22 07:46:52 +02:00
Sascha Hauer a2b88410ea mtd: nand-imx: Optimize timing for i.MX25
So far we relied on the clock rate as configured by reset default or
board code. Also we did not touch the symmetric mode bit. Use
the ONFI provided timing parameters to configure the clock rate for
the Nand controller. Also symmetric mode (EDO mode) when needed.
This is done for v2 controllers (i.MX25/35) only, other controllers
need other setup code.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-08-18 16:17:04 +02:00
Sascha Hauer 5a9a69155c mtd: nand-imx: split preset_v1_v2 into two functions
preset_v1_v2() still needs to distinguish between v1 and v2 and
the shared code is not very big. Since we need another v2 only
addtion in the next patch split the function into a v1 and a v2
specific function.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-08-18 16:17:03 +02:00
Sascha Hauer cae9515d05 mtd: nand: add ONFI timing mode to nand_timings converter
Ported from Linux commit 974647e:
| Add a converter to retrieve NAND timings from an ONFI NAND timing mode.
| At the moment, only SDR NAND timings are supported.
|
| Signed-off-by: Boris BREZILLON <boris.brezillon@free-electrons.com>
| Signed-off-by: Brian Norris <computersforpeace@gmail.com>

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-08-18 16:16:27 +02:00
Alexander Kurz d3c3e40355 mfd mc13xxx: add MC13892_REVISION_2_4
An MC13892CJ having REV[4:0]=0x14 can be found in the kindle-d01100.
Add the revision to the list to support this device.

Signed-off-by: Alexander Kurz <akurz@blala.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-08-18 09:15:28 +02:00
Enrico Jorns 5679e3296f clk: socfpga: add divider registers to the main pll outputs
This patch is based on kernel patch 0691bb1b5a1865b3bbc9b7ce6e26eff546abb1cf
by Dinh Nguyen <dinguyen@altera.com>.

The C0(mpu_clk), C1(main_clk), and C2(dbg_base_clk) outputs from the main
PLL go through a pre-divider before coming into the system. These registers
were hidden for the CycloneV platform, but are now used for the ArriaV
platform.

This patch updates the clock driver to read the div-reg property for the
socfpga-periph-clk clocks.

Note: The registers used for the div-reg property are not documented but
set by the preloader.

Signed-off-by: Enrico Jorns <ejo@pengutronix.de>
Signed-off-by: Steffen Trumtrar <s.trumtrar@pengutronix.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-08-18 08:19:45 +02:00
Sascha Hauer 20eabbf251 Merge branch 'for-next/video-backlight' 2016-08-03 08:08:23 +02:00
Sascha Hauer 984f9c9925 Merge branch 'for-next/syscon' 2016-08-03 08:08:23 +02:00
Sascha Hauer 7a51da5ff1 Merge branch 'for-next/net' 2016-08-03 08:08:23 +02:00
Sascha Hauer b927df0329 Merge branch 'for-next/misc' 2016-08-03 08:08:23 +02:00
Sascha Hauer 14e04d019b Merge branch 'for-next/imx' 2016-08-03 08:08:23 +02:00
Sascha Hauer 94e7bdcd9a Merge branch 'for-next/boot' 2016-08-03 08:08:22 +02:00
Alexander Kurz 28a0baffb9 ARM i.MX31: add SPI support
The i.MX31 SPI interface was refered by freescale as spi_ver_0_4 in one
of their older vendor extended linux releases. spi_ver_0_4 differs only
in minor aspects to spi_ver_0_7 (i.MX35) which is already supported by
barebox.
Regarding barebox, the differences boil down to the location and length
of the CHIP SELECT and BIT COUNT/BURST LENGTH elements of CONREG. The
spi_ver_0_4 variant is limited to single word bursts with a maximum of
32 bits_per_word.

Add support for the i.MX31 SPI interface to the barebox spi_ver_0_7
implementation.

Signed-off-by: Alexander Kurz <akurz@blala.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-08-03 07:30:41 +02:00
Alexander Kurz d8a7c4580b mc13xxx: make driver-provided SPI frequency overridable
The preset SPI frequency for mc13xxx PMIC introduced with patch 6e18b3a48e
("mc13xxx: Define maximum SPI clock frequency global to driver") is not
desirable or working on all boards. Provide a possibility to override
the default SPI max_speed_hz from board code.

Signed-off-by: Alexander Kurz <akurz@blala.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-08-03 07:30:40 +02:00
Alexander Kurz 741642a862 mtd: spi-nor: add new variants
Read access tested on W25Q20BW and MX25U4035.

Signed-off-by: Alexander Kurz <akurz@blala.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-08-03 07:28:58 +02:00
Sascha Hauer 4d85cb974a include: Move bulk of boot.h to bootm.h
The majority of the stuff currently in include/boot.h is about bootm
code implemented common/bootm.c. To be more consistent move it to a
new file include/bootm.h.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-07-26 08:31:31 +02:00
Sascha Hauer 370e90bac9 nand: mrvl: use ERR_CAST() for returning error pointers
ERR_CAST exists to return error pointers as error pointers without
casting them explicitly to the correct pointer type.

Also this Fixes:
In function 'alloc_nand_resource':
warning: return makes pointer from integer without a cast

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-07-25 10:26:50 +02:00
Andrey Smirnov 6f239e487c mfd: syscon: Use IOMEM instead of explicit cast
Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-07-19 06:49:50 +02:00
Andrey Smirnov a3eae6db13 mfd: syscon: Don't check xzalloc return for NULL
Xzalloc never returns NULL, so this check does not bring any value.

Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-07-19 06:49:50 +02:00
Andrey Smirnov b313346b1a mfd: syscon: Decouple syscon interface from platform devices
Follow Linux Kernel change introduced in
bdb0066df96e74a4002125467ebe459feff1ebef and avoid device/driver model
for DT-based platforms. See the original kernel commit for the rationale.

Also make syscon_base_lookup_by_pdevname() behave the same way as its
kernel counterpart in the case whern "property" argument is NULL.

Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-07-19 06:49:50 +02:00
Andrey Smirnov 2ccd60013d mfd: syscon: Don't call request_iomem_region()
On platforms that mix dedicated IP block register space with
miscellaneous registers it is necessary to share register window between
syscon and dedicated IP block driver. Calling request_iomem_region()
implies exclusive ownership of the region, which, in the case above
could not happen.

This change also makes this driver's behaviour to that of its Linux
kernel counterpart.

Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-07-19 06:49:20 +02:00
Andrey Smirnov 26384d071d Revert "syscon: Decrease driver registration priority"
Fixing the i.MX6 specific issue this way breaks things on CLPS711x
target. Better fix for the problem is to follow this patch.

This reverts commit c203958f3b.

Reported-by: Alexander Shiyan <shc_work@mail.ru>
Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-07-19 06:49:20 +02:00
iw3gtf@arcor.de 832f9fec6a video/backlight-pwm: properly handle the case of an empty 'brightness-levels' in the device tree.
In case of an empty 'brightness-levels' array in the device tree or
a non empty one but containing only zeros the value of
'pwm_backlight->scale' would remain 0 possibly causing a division by zero
in the function compute_duty_cycle().

To fix it we check the computed value in case we actually have a 'brightness-levels'
array in the device tree otherwise we implicitly assume a simple array
of the form { 0, 1, 2, ..., 100 } and set the scale to 100.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-07-15 08:07:14 +02:00
iw3gtf@arcor.de ca497ce66d video/backlight-pwm: code readability improvement.
We use the local variable 'length' instead of the lengthy
'pwm_backlight->backlight.brightness_max' within pwm_backlight_parse_dt().

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-07-15 08:07:14 +02:00
iw3gtf@arcor.de 87c6a88f2a video/backlight-pwm: fix the value of 'brightness_max'.
The field pwm_backlight->backlight.brightness_max should be the maximum
allowed brightness value for the backlight, not the max index of the
array 'pwm_backlight->levels[]'.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-07-15 08:07:14 +02:00
iw3gtf@arcor.de c27b1a93ce video/backlight-pwm: fixed a loop index going out of range.
In the function pwm_backlight_parse_dt() the last iteration of the for
loop accessed memory past the end of the array 'pwm_backlight->levels[]'
because of a wrong test ( '<=' instead of '<').

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-07-15 08:07:14 +02:00
Andrey Smirnov 1f3b611979 imx_thermal: Remove leftover debug output
Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-07-15 08:00:36 +02:00
Sascha Hauer ffc5fe0723 net: usb: use minimum timeout when polling for new packets
When no new packets have arrived we want to return to the caller
as soon as possible to give other network controllers the chance
to receive packets. With the current USB bulk message timeout of
one second other network controllers do not work properly whenever
the USB network controller is active.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-07-14 22:18:45 +02:00
Sascha Hauer 7be6d29724 Revert "mci: imx-esdhc: Remove excess function"
This reverts commit 8a6896971d.

With this patch it's no longer possible to call detect on the
physical device which is necessary for example to make environment
on MMC work. Unlike the commit message for 8a6896971d claims
mci_detect_card() is not called from mci_register().

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-07-14 14:37:51 +02:00
Sascha Hauer ca95c2bab9 Merge branch 'for-next/video' 2016-07-11 07:58:34 +02:00
Sascha Hauer 50543054eb Merge branch 'for-next/ubi' 2016-07-11 07:58:34 +02:00
Sascha Hauer e77acea709 Merge branch 'for-next/state' 2016-07-11 07:58:34 +02:00
Sascha Hauer bb73cb9427 Merge branch 'for-next/mtd' 2016-07-11 07:58:33 +02:00
Sascha Hauer f64075972b Merge branch 'for-next/misc' 2016-07-11 07:58:33 +02:00
Sascha Hauer e54183d6d4 Merge branch 'for-next/mips' 2016-07-11 07:58:33 +02:00
Sascha Hauer e2da792a52 Merge branch 'for-next/imx' 2016-07-11 07:58:33 +02:00
Uwe Kleine-König 034c16f54e mtd: nand: imx-bbm: use raw reading when checking for factory BBM
This is necessary to prevent the imx_nand_bbm command to bail out
on ECC errors which leaves the device without BBT.

Also simplify buffer management: Use on-stack buffer instead of malloc.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-07-11 07:48:42 +02:00
Markus Pargmann c999b507da state: Refactor state framework
The state framework grew organically over the time. Unfortunately the
architecture and abstractions disappeared during this period.

This patch refactors the framework to recreate the abstractions. The
main focus was the backend with its storage. The main use-case was to
offer better NAND support with less erase cycles and interchangeable
data formats (dtb,raw).

The general architecture now has a backend which consists of a data
format and storage. The storage consists of multiple storage buckets
each holding exactly one copy of the state data. A data format describes
a data serialization for the state framework. This can be either dtb or
raw. A storage bucket is a storage location which is used to store any
data. There is a (new) circular type which writes changes behind the
last written data and therefore reduces the number of erases. The other
type is a direct bucket which writes directly to a storage offset for
all non-erase storage.

Furthermore this patch splits up all classes into different files in a
subdirectory.

This is currently all in one patch as I can't see a good way to split
the changes up without having a non-working state framework in between.

The following diagram shows the new architecture roughly:

           .----------.
           |  state   |
           '----------'
                 |
                 |
                 v
  .----------------------------.
  |       state_backend        |
  |----------------------------|
  | + state_load(*state);      |
  | + state_save(*state);      |
  | + state_backend_init(...); |
  |                            |
  |                            |
  '----------------------------'
    |            |                   The format describes
    |            |                   how the state data
    |            '------------->     is serialized
    |   .--------------------------------------------.
    |   |      state_backend_format <INTERFACE>      |
    |   |--------------------------------------------|
    |   | + verify(*format, magic, *buf, len);       |
    |   | + pack(*format, *state, **buf, len);       |
    |   | + unpack(*format, *state, *buf, len);      |
    |   | + get_packed_len(*format, *state);         |
    |   | + free(*format);                           |
    |   '--------------------------------------------'
    |              ^                      ^
    |              *                      *
    |              *                      *
    |   .--------------------. .--------------------.
    |   | backend_format_dtb | | backend_format_raw |
    |   '--------------------' '--------------------'
    |
    |
    |
    v
.----------------------------------------------------------.
|                  state_backend_storage                   |
|----------------------------------------------------------|
| + init(...);                                             |
| + free(*storage);                                        |
| + read(*storage, *format, magic, **buf, *len, len_hint); |
| + write(*storage, *buf, len);                            |
| + restore_consistency(*storage, *buf, len);              |
'----------------------------------------------------------'
                              |
     The backend storage is responsible to manage multiple
     data copies and distribute them onto several buckets.
     Read data is verified against the given format to
     ensure that the read data is correct.
                              |
                              |
                              |
                              |
                              |
                              v
        .------------------------------------------.
        | state_backend_storage_bucket <INTERFACE> |
        |------------------------------------------|
        | + init(*bucket);                         |
        | + write(*bucket, *buf, len);             |
        | + read(*bucket, **buf, len_hint);        |
        | + free(*bucket);                         |
        '------------------------------------------'
                      ^     ^      ^
                     *      *       *
                    *       *        *
 A storage bucket represents*exactly one data copy at one
 data location. A circular b*cket writes any new data to
 the end of the bucket (for *educed erases on NAND). A
 direct bucket directly writ*s at one location.
               *            *             *
              *             *              *
             *              *               *
 .-----------------------.  *  .-------------------------.
 | backend_bucket_direct |  *  | backend_bucket_circular |
 '-----------------------'  *  '-------------------------'
             ^              *               ^
             |              *               |
             |              *               |
             |              *               |
             |  .-----------------------.   |
             '--| backend_bucket_cached |---'
                '-----------------------'
             A backend_bucket_cached is a transparent
             bucket that directly uses another bucket
             as backend device and caches all accesses.

Signed-off-by: Markus Pargmann <mpa@pengutronix.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-07-08 08:59:31 +02:00
Lucas Stach 5455354846 clk: fix misleading indenting
Signed-off-by: Lucas Stach <dev@lynxeye.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-07-07 09:36:49 +02:00
Lucas Stach 81a54afd22 USB: gadget: composite: avoid possible NULL ptr dereference
Check if g is valid before trying to dereference it.

Signed-off-by: Lucas Stach <dev@lynxeye.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-07-07 09:35:53 +02:00
Antony Pavlov adce981d24 of: base: import of_get_cpu_node() from linux-v4.7-rc2
Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-07-07 09:29:54 +02:00
Sascha Hauer 04f3cde151 usb: ehci: honour timeout value
usb_control_msg() and usb_bulk_msg() have a timeout parameter. Honour
this in the ehci driver instead of using a default timeout.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-07-06 11:15:39 +02:00
Alexander Shiyan e5c6340f42 net: smc911x: Add parsing devicetree options
This patch adds parsing basic devicetree options for the smc911x driver:
reg-io-width, reg-shift and smsc,force-(in/ex)ternal-phy, which makes
driver usable for most DTS-based boards.

Signed-off-by: Alexander Shiyan <shc_work@mail.ru>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-07-05 09:02:41 +02:00
Sascha Hauer 992794d0d4 eeprom: at24: Use xasprintf for small allocation
The code for error checking shouldn't be bigger than the allocated
string.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-07-05 09:02:40 +02:00
Sascha Hauer 3b393a43af net: dm9k: Fix buswidth setting for platform data probe
priv->buswidth expects IORESOURCE_MEM_* macros which are not
identical to the integer byte bus width, so calling
dm9000_setup_buswidth() for the platform_data case is wrong.

fixes: d818f02 net: dm9k: add device tree support

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Reported by: 张忠山 <zzs213@126.com>
2016-07-05 09:02:40 +02:00
Uwe Kleine-König c4fa1cb0f6 mtd: nand: simplify nand_block_checkbad
if (A) {
		if (!B)
			return C;
		return D;
	}

	return C;

can be simplified to:

	if (A && B)
		return D;

	return C;

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-07-05 09:02:40 +02:00
Alexander Shiyan c672fda23a input: Compile keymap only if necessary
Signed-off-by: Alexander Shiyan <shc_work@mail.ru>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-07-05 09:02:37 +02:00
Andrey Smirnov aa750244ee video/edid: Move int_sqrt() out
Move int_sqrt() out of drivers/video/edid.c so that it is availible to
other parts of Barebox.

Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-06-30 08:33:53 +02:00
Sascha Hauer a7f955fc98 eeprom: at24: fix discarding const qualifier
fixes:
at24.c:434:10: warning: assignment discards 'const' qualifier from pointer
target type

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-06-28 07:43:35 +02:00
Teresa Remmet c087e0804f mtd: UBI: Add support for updating static volumes
Added support to update UBI static volumes in barebox.
This is mainly realized with adding the ioctl UBI_IOCVOLUP.

Signed-off-by: Teresa Remmet <t.remmet@phytec.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-06-28 07:31:37 +02:00
Sascha Hauer 94d8236556 mtd: ubi: actually do work in wear leveling code
The actual work in the wear leveling code is done in a separate thread.
Since we do not have threading so far we did not do any of the queued
work. Change this by calling the worker function synchronously.

With this barebox now can write a fastmap on a freshly ubiformated
device.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-06-28 07:30:04 +02:00
Teresa Remmet 8b765bebb6 mtd: ubi: Fix endless loop when moving PEB
When moving a PEB the leb_write_trylock() function is called.
As the function never returns 0 UBI will end up in an endless
loop.

Noticed the issue when fastmap has been enabled and data is beeing copied
several times to a UBI volume. When UBI tries to move the anchor PEB,
the issue comes up.

The leb_write_trylock() is now equal to the leb_write_lock().
But kept it for easier maintaince in future when syncing with
kernel.

Signed-off-by: Teresa Remmet <t.remmet@phytec.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-06-28 07:30:00 +02:00
Sascha Hauer 1ebb663db9 net: dm9k: Fix buswidth setting for platform data probe
priv->buswidth expects IORESOURCE_MEM_* macros which are not
identical to the integer byte bus width, so calling
dm9000_setup_buswidth() for the platform_data case is wrong.

fixes: d818f02 net: dm9k: add device tree support

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Reported by: 张忠山 <zzs213@126.com>
2016-06-28 07:27:08 +02:00
Alexander Shiyan d479f15f24 spi: imx: Remove the use of property "fsl, spi-num-chipselects"
The "fsl,spi-num-chipselects" property will be marked obsolete soon.
This patch updates the driver to be ready to such changes.

Signed-off-by: Alexander Shiyan <shc_work@mail.ru>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-06-27 08:45:49 +02:00
Sascha Hauer 1daa3bc8dc mtd: nand_mxs: Setup timing
So far we relied on the default timing values which are rather slow.
This patch adds the timing setup functions from the kernel. Tested
on i.MX6 with a AMD/Spansion S34ML08G2 and a Micron MT29F32G08ABAAAWP.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-06-24 11:44:26 +02:00
Sascha Hauer 6a175cb3ff mtd: nand: Set ONFI function hooks earlier
Make the ONFI function hooks available after nand_scan_ident() but
before nand_scan_tail(). Based on the kernel commit:
4204ccc mtd: set ONFI nand's default hooks in nand_set_defaults()

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-06-24 11:44:26 +02:00
Lucas Stach 8ef4478c37 mtd: fix mtdraw_erase stub signature
Commit 81737c1d43 (mtd: Fix erasing of devices >4GiB) changed the
prototype of the erase function, but fogot to fix up the stub function
used when no MTD write support is built in.

Signed-off-by: Lucas Stach <l.stach@pengutronix.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-06-24 08:23:33 +02:00
Lucas Stach ed9e5ff965 aiodev: imx_thermal: depend on MACH_IMX6
This driver uses private includes from the imx6 architecture.

Signed-off-by: Lucas Stach <l.stach@pengutronix.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-06-23 08:15:10 +02:00
Lucas Stach f569157cbf aiodev: imx_thermal: remove empty include
This file doesn't hold any content any more, so there is no
need to include it.

Signed-off-by: Lucas Stach <l.stach@pengutronix.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-06-23 08:15:10 +02:00
Sascha Hauer 13ef2b2490 mtd: nand: gpmi: Use subpage reads only on suitable NAND chips
On some NAND chips the driver uses a ECC size that is not dividable by
the number of chunks per page which means a single chunk cannot be read.
Disable the subpage feature for these NANDs. This is quite unfortunate
since the subpage feature really speeds up scanning NAND chips.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-06-22 08:45:45 +02:00
Alexander Shiyan 8a6896971d mci: imx-esdhc: Remove excess function
Function detect() is defined in the MCI core and mci_detect_card() is
already called form mci_register(). Remove excess fuction.

Signed-off-by: Alexander Shiyan <shc_work@mail.ru>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-06-20 08:32:36 +02:00
Alexander Shiyan f296a48612 mci: core: Do not fail if vmmc regulator fail
The vmmc regulator can be an usupported device for barebox,
the specific MFD regulator type, for example. Just lets think is all ok.

Signed-off-by: Alexander Shiyan <shc_work@mail.ru>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-06-20 08:32:36 +02:00
Alexander Shiyan 5cf7d7014a mci: imx: Add devicetree options parsing by MCI core.
Signed-off-by: Alexander Shiyan <shc_work@mail.ru>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-06-20 08:32:36 +02:00
Alexander Shiyan 9088481cc7 mci: imx: Use mci_register() return value for driver probe.
Signed-off-by: Alexander Shiyan <shc_work@mail.ru>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-06-20 08:32:36 +02:00
Antony Pavlov addb6f7394 net: phy: make locally used of_phy_register_fixed_link() static
The patch fixes this compiler's warning:

    drivers/net/phy/phy.c:303:20: warning: no previous prototype for
    ‘of_phy_register_fixed_link’ [-Wmissing-prototypes]

Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-06-16 15:48:42 +02:00
Sascha Hauer d059216c48 Merge branch 'for-next/ubi' 2016-06-14 09:13:41 +02:00
Sascha Hauer db17be7f34 Merge branch 'for-next/mtd' 2016-06-14 09:13:41 +02:00
Sascha Hauer 6bfb591cc1 Merge branch 'for-next/misc' 2016-06-14 09:13:41 +02:00
Sascha Hauer 336dcea5a1 Merge branch 'for-next/mips' 2016-06-14 09:13:41 +02:00
Sascha Hauer 0fcd7fdbb9 Merge branch 'for-next/imx' 2016-06-14 09:13:40 +02:00
Sascha Hauer f0a3a956b8 Merge branch 'for-next/e1000' 2016-06-14 09:13:40 +02:00
Sascha Hauer 5f987cd3f7 Merge branch 'for-next/aiodev' 2016-06-14 09:13:26 +02:00
Antony Pavlov f1772f4798 MIPS: ath79: dts: sync spi stuff with linux v4.7-rc2
Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-06-14 08:39:55 +02:00
Antony Pavlov 5253099564 MIPS: ath79: dts: sync clk stuff with linux v4.7-rc2
Please see these linux kernel ath79 commits:

    commit 1e6a3492e7bb12aa8ee26050ff6829c39ebaa152
    Author: Antony Pavlov <antonynpavlov@gmail.com>
    Date:   Thu Mar 17 06:34:17 2016 +0300

        MIPS: dts: qca: introduce AR9331 devicetree

    commit 5ae5c452e3361612cd8182eb8bdfecf0ebf42288
    Author: Antony Pavlov <antonynpavlov@gmail.com>
    Date:   Thu Mar 17 06:34:18 2016 +0300

        MIPS: ath79: update devicetree clock support for AR9331

Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-06-14 08:39:55 +02:00
Antony Pavlov 9f4e3730bd clk: ar933x: fix copyright header
Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-06-14 08:39:55 +02:00
grodriguez a945a51b76 Fix genphy_restart_aneg() for Micrel's ksz9031.
Commit da89ee8f2e ("Center FLP timing at 16ms") breaks
genphy_restart_aneg() for Micrel's ksz9031. According to the
datasheet, the ksz9031 requires a wait of 1ms after clearing
the PDOWN bit and before read/write access to any PHY registers.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-06-14 08:32:15 +02:00
Trent Piepho edb96cf3d7 mci: Fix version numbers again
The SD and eMMC version numbers are a pain to print and sort, since
they are inconsistent in if a two digit minor version shdoulde be
treated as a single number or as minor and micro version numbers.

This allows version 1.10 and 4.5 and 4.41, where 41 is less than 5.

Signed-off-by: Trent Piepho <tpiepho@kymetacorp.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-06-07 08:06:43 +02:00
Andrey Smirnov 4ff3269a70 e1000: Expose i210's external flash as MTD
Add code needed to access SPI-NOR flash attached to i210 as a regular
MTD device.

Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-06-03 09:14:14 +02:00
Andrey Smirnov a74b97f009 e1000: Expose i210's iNVM as a cdev
Add code needed to expose iNVM memory on the chip as a cdev. The
driver also registers a dummy "invm" device that exposes "locked"
property which is used to implement iNMV line locking feature.

Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-06-03 09:14:14 +02:00
Andrey Smirnov 91d3dd2fd8 e1000: Add a "poll register" function
Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-06-03 09:14:14 +02:00
Andrey Smirnov 72f02e6c0b e1000: Add EEPROM access locking for i210
As per datasheet (section 4.6 p. 147) accessing EEPROM on i210
requires software to hold a corresponding lock bit in SW_FW_SYNC
register.

Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-06-03 09:14:14 +02:00
Andrey Smirnov 741cdaf506 e1000: Properly release SW_FW_SYNC semaphore bits
As described in the datasheet Software/Firmware synchronisation bits
are expected to be released by the software after it is done using
it. Add a porper subroutine to do that instead of relying on the
Firmware clearing those bits due to timeout.

Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-06-03 09:14:14 +02:00
Andrey Smirnov 2bac167769 e1000: Refactor Flash/EEPROM reading code
Refactor Flash/EEPROM reading code to use vtable with pointers to
small, specialized functions based on the flash class instead of big
monolithic funtions whose behaviour is driven by a number of flags and
variables.

Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-06-03 09:14:14 +02:00
Andrey Smirnov 580ad4021c e1000: Remove unnecessary intialization
We always call e1000_init_eeprom_params() as a part of probing, so
there's no need check if it needs to be called in e1000_read_eeprom().

Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-06-03 09:14:14 +02:00
Andrey Smirnov 224174354f e1000: Fix a bug in e1000_probe()
There are several reasons why that code in e1000_probe had to be
changed:

 - It reads from chip variant specific register (present only on
   i210) in a chip variant agnostic codepath

 - It makes no sense to check for FLUPD bit to make a decision weither
   to validate EEPROM or not since its function per datasheet is:

   " ... Flash Update.

     Writing 1b to this bit causes the content of the internal 4 KB
     shadow RAM to be written into one of the first two 4 KB sectors
     of the Flash device (Sector 0 or Sector 1). The bit is
     self-cleared immediately... "

   and it is only through sheer serendipity the defined value for
   bitmask for FLUPD is equivalent to bitmask for FLASH_DETECTED bit
   which is the bit we actually care about and need to test against
   (FLUPD for i210 has a different bitmask)

Fix those problems by replacing the i210 specific check inside of
e1000_validate_eeprom_checksum() with a chip agnostic one and using
correct bitmask.

Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-06-03 09:14:14 +02:00
Andrey Smirnov e1e4976931 e1000: Consolidate Microwire EEPROM init code
All of the chips that bitbang Microwire to access EEPROM appear to be
configured in the same way, so move common code into a separate
function and make use of it.

Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-06-03 09:14:14 +02:00
Andrey Smirnov 81f2d33a83 e1000: Consolidate SPI EEPROM init code
All of the chips that bitbang SPI to access EEPROM appear to be
configured in the same way, so move common code into a separate
function and make use of it.

Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-06-03 09:14:14 +02:00
Andrey Smirnov 8ba2db7646 e1000: Simplify EEPROM init for e1000_igb
That chip specifies read access uising EERD via use_eerd, which means
that none of the more "advanced" EEPROM parameters will be used for
reads, so remove them.

Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-06-03 09:14:14 +02:00
Andrey Smirnov 7f7833ec83 e1000: Simplify EEPROM init for e1000_80003es2lan
That chip specifies read access uising EERD via use_eerd, which means
that none of the more "advanced" EEPROM parameters will be used for
reads, so remove them.

Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-06-03 09:14:14 +02:00
Andrey Smirnov b141814765 e1000: Remove 'page_size'
Remove 'page_size' from 'struct e1000_eeprom_info' since it is not
used anywhere in the code.

Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-06-03 09:14:14 +02:00
Andrey Smirnov 920fc71094 e1000: Remove 'use_eewr' parameter
Remove 'use_eewr' from 'struct e1000_eeprom_info' since it is not used
anywhere in the code.

Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-06-03 09:14:14 +02:00
Andrey Smirnov ff6a64d42f e1000: Consolidate register offset fixups
Consolidate all code taking care on CSR offset differences for i210
chips into a single place in the driver and integrate that funcionality
into e1000_{read,write}_reg functions. This way we can get rid of all
those

    if (hw->mac_type == e1000_igb) {
       ....
    } else {
       ....
    }

snippets sprinkled all across the driver code.

Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-06-03 09:14:14 +02:00
Andrey Smirnov 7477a1500a e1000: Remove unneeded i210 specific register code
Despite having EEC(EECD) and EERD at "non-standard" offsets i210
aliases those registers to be accesible via regular addresses so none
of the code removed by this commit is really necessary.

Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-06-03 09:14:14 +02:00
Andrey Smirnov 3d68327587 e1000: Do not read same register twice
EEPROM_INIT_CONTROL2_REG is already read once before entering this
switch statement, so there's not much use in reading its value for the
second time.

Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-06-03 09:14:14 +02:00
Andrey Smirnov 2ea081c242 e1000: Remove unnecessary variable
There doesn't seem to be any point for having 'nv_packet' variable and
it looks like a leftover from driving porting. Remove it and use
'txpacket' instead

Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-06-03 09:14:14 +02:00
Andrey Smirnov a199e7b221 e1000: Fix a bug in e1000_detect_gig_phy
It seems there's stray exclamation mark character in
e1000_detect_gig_phy which renders the whole if statement useless
since it converts 'phy_type' into a boolean and comparing that to 0xFF
would always result in false (which GCC 5.1 is now able to detect and
warn about). This commit fixes that.

Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-06-03 09:14:14 +02:00
Andrey Smirnov 940bd8bb25 e1000: Convert E1000_*_REG macros to functions
E1000_*_REG don't bring any value by being macros and implicit appending
of "E1000_" prefix to the constant name only makes thing harder to grep
or understand. Replace those macros with functions.

Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-06-03 09:14:14 +02:00
Andrey Smirnov ae4915ff38 e1000: Include <net.h> in e1000.h
That header(e1000.h) uses a number of definitions from net.h, so for it
to be self-contained it needs to include that file. This change also
allows remove includes of net.h from other files.

Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-06-03 09:14:14 +02:00
Andrey Smirnov fcfd488cec e1000: Split driver into multiple files
The driver has a number of not very tightly coupled subsystems and at
4K+ lines e1000.c is getting rather hard to wrangle, so let's move
EEPROM handling code (very self contained susbsystem) into a separate
file and put all of the driver into a dedicated subdirectory.

Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-06-03 09:14:14 +02:00
Uwe Kleine-König 17f77702e5 eeprom: at24: make device name setup more robust
With two eeproms that have a different compatible string (in my case
"at,24c64" and "at,24c32") dev->id is 0 for both which results in a
failure to bind the device that is probed later.

So pick a name more intelligently: If there is an alias defined in the
device tree, use this one, otherwise pick a free index.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-05-31 08:57:46 +02:00
Uwe Kleine-König 3982f4ad8a eeprom: at24: check return value of devfs_create and fix error path
if devfs_create failed because "eeprom0" already exists
of_parse_partitions must not be called, otherwise the already existing
eeprom gets assigned partitions that don't belog there.

Also free dummy clients in the error path and the write protect gpio
only if it is actually valid.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-05-31 08:57:46 +02:00
Uwe Kleine-König a20a3cb4cd eeprom: at25: check return value of devfs_create
Also only emit the message that the device was probed when it
actually was.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-05-31 08:57:46 +02:00
Alexander Shiyan 3f374304ad pinctrl: iomux-v3: Cleaning SION patch before applying
Signed-off-by: Alexander Shiyan <shc_work@mail.ru>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-05-31 08:23:45 +02:00
Alexander Shiyan fd5f9fc3ab MCI: imx-esdhc: Allow to use 1-bit bus width in board files
Signed-off-by: Alexander Shiyan <shc_work@mail.ru>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-05-31 08:23:45 +02:00
Trent Piepho 24fcf5fcee rtc: ds1307: Add support for configuring external clock pin
The DS1307 has a square wave output pin, which can be used to output a
clock signal from the DS1307.  Additionally, the DS1308 supports
configuring this pin as an input from an external clock source to
which it should sync itself.

Add support with OF device tree properties to configure these
settings.  Supported features are using the clock pin as an output, an
input, the rate of the pin, and if it should be enabled on battery
backup power.

The driver does not check that the selected features are supported by
the clock chip being used.  It is the designer's responsibility to
create a valid device tree node; the bootloader does not attempt to be
a device tree validator.

Signed-off-by: Trent Piepho <tpiepho@kymetacorp.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-05-30 07:12:19 +02:00
Teresa Remmet 31edb3f16d mtd: UBI: Remove ubi_free_fastmap
Freeing the fastmap is now done by ubi_fastmap_close() from kernel.
No need to keep the barebox own fastmap free function.

Signed-off-by: Teresa Remmet <t.remmet@phytec.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-05-27 12:30:27 +02:00
Richard Weinberger 58eb46f7cb ubi: Fix out of bounds write in volume update code
ubi_start_leb_change() allocates too few bytes.
ubi_more_leb_change_data() will write up to req->upd_bytes +
ubi->min_io_size bytes.

Cc: stable@vger.kernel.org
Signed-off-by: Richard Weinberger <richard@nod.at>
Reviewed-by: Boris Brezillon <boris.brezillon@free-electrons.com>
Signed-off-by: Teresa Remmet <t.remmet@phytec.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-05-27 12:30:27 +02:00
Sebastian Siewior 7027011106 mtd: ubi: wl: avoid erasing a PEB which is empty
wear_leveling_worker() currently unconditionally puts a PEB on erase in
the error case even it just been taken from the free_list and never
used.
In case the PEB was never used it can be put back on the free list
saving a precious erase cycle.

v1…v2:
	- to_leb_clean -> dst_leb_clean
	- use the nested option for ensure_wear_leveling()
	- do_sync_erase() can't go -ENOMEM so we can just go into
	  RO-mode now.

Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Signed-off-by: Richard Weinberger <richard@nod.at>
Signed-off-by: Teresa Remmet <t.remmet@phytec.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-05-27 12:30:27 +02:00
Sebastian Siewior c5576d8a3a mtd: ubi: don't leak e if schedule_erase() fails
If __erase_worker() fails to erase the EB and schedule_erase() fails as
well to do anything about it then we go RO. But that is not a reason to
leak the e argument here. Therefore clean up e.

Cc: <stable@vger.kernel.org>
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Signed-off-by: Richard Weinberger <richard@nod.at>
Signed-off-by: Teresa Remmet <t.remmet@phytec.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-05-27 12:30:27 +02:00
Sebastian Siewior 6c5c4a4171 mtd: ubi: fixup error correction in do_sync_erase()
Since fastmap we gained do_sync_erase(). This function can return an error
and its error handling isn't obvious. First the memory allocation for
struct ubi_work can fail and as such struct ubi_wl_entry is leaked.
However if the memory allocation succeeds then the tail function takes
care of the struct ubi_wl_entry. A free here could result in a double
free.
To make the error handling simpler, I split the tail function into one
piece which does the work and another which frees the struct ubi_work
which is passed as argument. As result do_sync_erase() can keep the
struct on stack and we get rid of one error source.

Cc: <stable@vger.kernel.org>
Fixes: 8199b901a ("UBI: Add fastmap support to the WL sub-system")
Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Signed-off-by: Richard Weinberger <richard@nod.at>

Conflicts:
	drivers/mtd/ubi/wl.c

Fixed conflicts.

Signed-off-by: Teresa Remmet <t.remmet@phytec.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-05-27 12:30:27 +02:00
Brian Norris 2dace81b53 UBI: fix use of "VID" vs. "EC" in header self-check
Looks like a typo, using UBI_EC_HDR_SIZE_CRC (note the "EC") to compute
the CRC for the VID header.

This shouldn't cause any functional change, as both structures are 64
bytes. Verified with:

	BUILD_BUG_ON(UBI_VID_HDR_SIZE_CRC != UBI_EC_HDR_SIZE_CRC);

Reported here:
http://lists.infradead.org/pipermail/linux-mtd/2013-September/048570.html

Reported by: Bill Pringlemeir <bpringlemeir@gmail.com>
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
Signed-off-by: Richard Weinberger <richard@nod.at>
Signed-off-by: Teresa Remmet <t.remmet@phytec.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-05-27 12:30:27 +02:00
Ezequiel García 6cf1f78230 UBI: Fastmap: Fix PEB array type
The PEB array is an array of __be32, so let's fix the
scan_pool() prototype accordingly.

Signed-off-by: Ezequiel Garcia <ezequiel@vanguardiasur.com.ar>
Signed-off-by: Richard Weinberger <richard@nod.at>

Conflicts:
	drivers/mtd/ubi/fastmap.c

Fixed minor conflict.

Signed-off-by: Teresa Remmet <t.remmet@phytec.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-05-27 12:30:27 +02:00
Richard Weinberger 2926770741 UBI: Fix debug message
We have to use j instead of i. i is the volume id
and not the block.

Reported-by: Alexander.Block@continental-corporation.com
Signed-off-by: Richard Weinberger <richard@nod.at>
Acked-by: Brian Norris <computersforpeace@gmail.com>
Signed-off-by: Teresa Remmet <t.remmet@phytec.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-05-27 12:30:27 +02:00
Richard Weinberger 3ff2991446 UBI: Fix typo in comment
While we are here fix a s/beween/between typo.

Signed-off-by: Richard Weinberger <richard@nod.at>
Acked-by: Brian Norris <computersforpeace@gmail.com>
Signed-off-by: Teresa Remmet <t.remmet@phytec.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-05-27 12:30:27 +02:00
Richard Weinberger da0647f244 UBI: Fastmap: Simplify expression
There is no need to compute pnum again.

Signed-off-by: Richard Weinberger <richard@nod.at>
Acked-by: Brian Norris <computersforpeace@gmail.com>
Signed-off-by: Teresa Remmet <t.remmet@phytec.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-05-27 12:30:27 +02:00
shengyong 14cd478b83 UBI: return ENOSPC if no enough space available
UBI: attaching mtd1 to ubi0
UBI: scanning is finished
UBI error: init_volumes: not enough PEBs, required 706, available 686
UBI error: ubi_wl_init: no enough physical eraseblocks (-20, need 1)
UBI error: ubi_attach_mtd_dev: failed to attach mtd1, error -12 <= NOT ENOMEM
UBI error: ubi_init: cannot attach mtd1

If available PEBs are not enough when initializing volumes, return -ENOSPC
directly. If available PEBs are not enough when initializing WL, return
-ENOSPC instead of -ENOMEM.

Cc: stable@vger.kernel.org
Signed-off-by: Sheng Yong <shengyong1@huawei.com>
Signed-off-by: Richard Weinberger <richard@nod.at>
Reviewed-by: David Gstir <david@sigma-star.at>
Signed-off-by: Teresa Remmet <t.remmet@phytec.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-05-27 12:30:27 +02:00
Richard Weinberger 2258208ae2 UBI: Validate data_size
Make sure that data_size is less than LEB size.
Otherwise a handcrafted UBI image is able to trigger
an out of bounds memory access in ubi_compare_lebs().

Cc: stable@vger.kernel.org
Signed-off-by: Richard Weinberger <richard@nod.at>
Reviewed-by: David Gstir <david@sigma-star.at>
Signed-off-by: Teresa Remmet <t.remmet@phytec.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-05-27 12:30:27 +02:00
shengyong 35fd94ee95 UBI: Remove unnecessary `\'
Signed-off-by: Sheng Yong <shengyong1@huawei.com>
Signed-off-by: Richard Weinberger <richard@nod.at>
Signed-off-by: Teresa Remmet <t.remmet@phytec.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-05-27 12:30:27 +02:00
shengyong 1a61f0591d UBI: add a helper function for updatting on-flash layout volumes
Signed-off-by: Sheng Yong <shengyong1@huawei.com>
Signed-off-by: Richard Weinberger <richard@nod.at>
Signed-off-by: Teresa Remmet <t.remmet@phytec.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-05-27 12:30:27 +02:00
shengyong 794d45b116 UBI: Fastmap: Do not add vol if it already exists
During fastmap attaching, check if a volume already exists when adding
the volume to volume tree. NOTE that the issue cannot happen, only if
the on-flash fastmap data is modified.

Signed-off-by: Sheng Yong <shengyong1@huawei.com>
Signed-off-by: Richard Weinberger <richard@nod.at>
Signed-off-by: Teresa Remmet <t.remmet@phytec.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-05-27 12:30:27 +02:00
shengyong 78ae01bf2b UBI: Init vol->reserved_pebs by assignment
`vol' is a newly allocated value by kzalloc. Initialize it by assignment
instead of `+='.

Signed-off-by: Sheng Yong <shengyong1@huawei.com>
Signed-off-by: Richard Weinberger <richard@nod.at>
Signed-off-by: Teresa Remmet <t.remmet@phytec.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-05-27 12:30:27 +02:00
shengyong c59fb39da3 UBI: Fastmap: Rename variables to make them meaningful
s/fmpl1/fmpl
s/fmpl2/fmpl_wl

Add "WL" to the error message when wrong WL pool magic number is detected.

Signed-off-by: Sheng Yong <shengyong1@huawei.com>
Signed-off-by: Richard Weinberger <richard@nod.at>

Conflicts:
	drivers/mtd/ubi/fastmap.c

Fixed minor conflict.

Signed-off-by: Teresa Remmet <t.remmet@phytec.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-05-27 12:30:27 +02:00
shengyong 7780097495 UBI: Fastmap: Remove unnecessary `\'
Signed-off-by: Sheng Yong <shengyong1@huawei.com>
Signed-off-by: Richard Weinberger <richard@nod.at>
Signed-off-by: Teresa Remmet <t.remmet@phytec.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-05-27 12:30:27 +02:00
shengyong 2b0f3ccda3 UBI: Fastmap: Use max() to get the larger value
Signed-off-by: Sheng Yong <shengyong1@huawei.com>
Signed-off-by: Richard Weinberger <richard@nod.at>
Signed-off-by: Teresa Remmet <t.remmet@phytec.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-05-27 12:30:27 +02:00
Richard Weinberger 787b429414 UBI: Fastmap: Fall back to scanning mode after ECC error
If we encounter an uncorrectable ECC error while scanning for the fastmap
UBI must not fail hard. Instead fall back to scanning mode.

Reported-by: Alexander Block <Alexander.Block@continental-corporation.com>
Signed-off-by: Richard Weinberger <richard@nod.at>

Conflicts:
	drivers/mtd/ubi/attach.c

Fixed minor conflict.

Signed-off-by: Teresa Remmet <t.remmet@phytec.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-05-27 12:30:27 +02:00
Richard Weinberger 0aaf425c29 UBI: Fastmap: Remove is_fm_block()
This function was added to fastmap in a very early stage
to have paranoid assertions.
With the current fastmap implementation this assert will never
trigger as fastmap PEBs are not seen by the WL sub-system.
Remove it to save us some CPU cycles.

Signed-off-by: Richard Weinberger <richard@nod.at>

Conflicts:
	drivers/mtd/ubi/fastmap-wl.c

Fixed minor conflict.

Signed-off-by: Teresa Remmet <t.remmet@phytec.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-05-27 12:30:27 +02:00
Richard Weinberger 2fb14ff615 UBI: Fastmap: Introduce may_reserve_for_fm()
...and kill another #ifdef.

Signed-off-by: Richard Weinberger <richard@nod.at>
Signed-off-by: Teresa Remmet <t.remmet@phytec.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-05-27 12:30:27 +02:00
Richard Weinberger eb21c4f4a7 UBI: Fastmap: Introduce ubi_fastmap_init()
...and kill another #ifdef in wl.c. :-)

Signed-off-by: Richard Weinberger <richard@nod.at>
Signed-off-by: Teresa Remmet <t.remmet@phytec.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-05-27 12:30:27 +02:00
Richard Weinberger 88a5d0bf5a UBI: Fastmap: Wire up WL accessor functions
Use the new WL accessor functions in fastmap.

Signed-off-by: Richard Weinberger <richard@nod.at>
Signed-off-by: Teresa Remmet <t.remmet@phytec.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-05-27 12:30:27 +02:00
Richard Weinberger c1bb58207b UBI: Add accessor functions for WL data structures
Fastmap need access to various WL data structures as
fastmap tightly depends on WL.
To make the access less invasive add accessor functions.

Signed-off-by: Richard Weinberger <richard@nod.at>

Conflicts:
	drivers/mtd/ubi/ubi.h

Fixed minor conflict.

Signed-off-by: Teresa Remmet <t.remmet@phytec.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-05-27 12:30:27 +02:00
Richard Weinberger 55f49caf31 UBI: Move fastmap specific functions out of wl.c
Fastmap is tightly connected to the WL sub-system, many fastmap-specific
functionslive in wl.c.
To get rid of most #ifdefs in wl.c move this functions into a new file
and include it into wl.c

Signed-off-by: Richard Weinberger <richard@nod.at>

Conflicts:
	drivers/mtd/ubi/wl.c

Reworked this for barebox.

Signed-off-by: Teresa Remmet <t.remmet@phytec.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-05-27 12:30:27 +02:00
Richard Weinberger 384accb944 UBI: Fix stale pointers in ubi->lookuptbl
In some error paths the WL sub-system gives up on a PEB
and frees it's ubi_wl_entry struct but does not set
the entry in ubi->lookuptbl to NULL.
Fastmap can stumble over such a stale pointer as it uses
ubi->lookuptbl to find all PEBs.

Fix this by introducing a new helper function which free()s
a WL entry and removes the reference from the lookup table.

Signed-off-by: Richard Weinberger <richard@nod.at>

Conflicts:
	drivers/mtd/ubi/wl.c

Fixed minor conflict.

Signed-off-by: Teresa Remmet <t.remmet@phytec.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-05-27 12:30:27 +02:00
Richard Weinberger 69dab3930d UBI: Fastmap: Rework fastmap error paths
If UBI is unable to write the fastmap to the device
we have make sure that upon next attach UBI will fall
back to scanning mode.
In case we cannot ensure that they only thing we can do
is falling back to read-only mode.

The current error handling code is not powercut proof.
It could happen that a powercut while invalidating would
lead to a state where an too old fastmap could be used upon
attach.
This patch addresses the issue by writing a fake fastmap
super block to a fresh PEB instead of reerasing the existing one.
The fake fastmap super block will UBI case to do a full scan.

Signed-off-by: Richard Weinberger <richard@nod.at>
Signed-off-by: Teresa Remmet <t.remmet@phytec.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-05-27 12:30:27 +02:00
Richard Weinberger 12be3f0f5b UBI: Fastmap: Prepare for variable sized fastmaps
The current code assumes that each fastmap has the same amount of PEBs.
So far this is true but will change soon.

Signed-off-by: Richard Weinberger <richard@nod.at>

Conflicts:
	drivers/mtd/ubi/fastmap.c

Fixed minor conflict.

Signed-off-by: Teresa Remmet <t.remmet@phytec.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-05-27 12:30:27 +02:00
Richard Weinberger 631cecf7ef UBI: Fastmap: Set used_ebs only for static volumes
If we set it for dynamic ones we might confuse various self checks.

Signed-off-by: Richard Weinberger <richard@nod.at>
Signed-off-by: Teresa Remmet <t.remmet@phytec.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-05-27 12:30:27 +02:00
Richard Weinberger d33e1f3cd4 UBI: Fastmap: Fix leb_count unbalance
If a LEB is unmapped we have to decrement leb_count as well.

Signed-off-by: Richard Weinberger <richard@nod.at>

Conflicts:
	drivers/mtd/ubi/fastmap.c

Fixed minor conflict.

Signed-off-by: Teresa Remmet <t.remmet@phytec.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-05-27 12:30:27 +02:00
Richard Weinberger cd9332ddf4 UBI: Fastmap: Make WL pool size 50% of user pool size
Don't use a fixed size for the WL pool.
Make it instead 50% of the user pool.
We don't make it 100% as it is not as heavily used as the user pool.

Signed-off-by: Richard Weinberger <richard@nod.at>
Signed-off-by: Teresa Remmet <t.remmet@phytec.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-05-27 12:30:27 +02:00
Richard Weinberger b98122916a UBI: Fastmap: Switch to ro mode if invalidate_fastmap() fails
We have to switch to ro mode to guarantee that upon next UBI attach
all data is consistent.

Signed-off-by: Richard Weinberger <richard@nod.at>
Signed-off-by: Teresa Remmet <t.remmet@phytec.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-05-27 12:30:27 +02:00
Richard Weinberger 75abea1602 UBI: Fastmap: Remove eba_orphans logic
This logic is in vain as we treat protected PEBs also as used, so this
case must not happen.
If a PEB is found which is in the EBA table but not known as used
has to be issued as fatal error.

Signed-off-by: Richard Weinberger <richard@nod.at>

Conflicts:
	drivers/mtd/ubi/fastmap.c

Fixed conflicts.

Signed-off-by: Teresa Remmet <t.remmet@phytec.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-05-27 12:30:27 +02:00
Richard Weinberger b1a13edc0a UBI: Fastmap: Remove bogus ubi_assert()
It is legal to have PEBs left in the used list.
This can happen if UBI copies a PEB and a powercut happens
between writing a new fastmap and adding this PEB into the EBA table.
In this case the old PEB will be used.

Signed-off-by: Richard Weinberger <richard@nod.at>
Signed-off-by: Teresa Remmet <t.remmet@phytec.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-05-27 12:30:27 +02:00
Richard Weinberger 0e76193e89 UBI: Fastmap: Fix race in ubi_eba_atomic_leb_change()
This function a) requests a new PEB, b) writes data to it,
c) returns the old PEB and d) registers the new PEB in the EBA table.

For the non-fastmap case this works perfectly fine and is powercut safe.
Is fastmap enabled this can lead to issues.
If a new fastmap is written between a) and c) the freshly requested PEB
is no longer in a pool and will not be scanned upon attaching.
If now a powercut happens between c) and d) the freshly requested PEB
will not be scanned and the old one got already scheduled for erase.
After attaching the EBA table will point to a erased PEB.

Fix this issue by swapping steps c) and d).

Signed-off-by: Richard Weinberger <richard@nod.at>

Conflicts:
	drivers/mtd/ubi/eba.c

Fixed minor conflict.

Signed-off-by: Teresa Remmet <t.remmet@phytec.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-05-27 12:30:27 +02:00
Richard Weinberger c91309eba2 UBI: Fastmap: Fix fastmap usage in ubi_volume_notify()
There is no need to switch to ro mode if ubi_update_fastmap() fails.
Also get rid of the ifdef.

Signed-off-by: Richard Weinberger <richard@nod.at>
Reviewed-by: Tanya Brokhman <tlinder@codeaurora.org>

Conflicts:
	drivers/mtd/ubi/build.c

Fixed minor conflict.

Signed-off-by: Teresa Remmet <t.remmet@phytec.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-05-27 12:30:27 +02:00
Richard Weinberger 70b129870a UBI: Fastmap: Wrap fastmap specific function in a ifdef
...such that we can implement NOP variants of some functions.
This will help to reduce fastmap specific ifdefs in other c files.

Signed-off-by: Richard Weinberger <richard@nod.at>
Reviewed-by: Tanya Brokhman <tlinder@codeaurora.org>

Conflicts:
	drivers/mtd/ubi/ubi.h

Fixed minor conflict.

Signed-off-by: Teresa Remmet <t.remmet@phytec.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-05-27 12:30:27 +02:00
Richard Weinberger e8957c2033 UBI: Fastmap: Notify user in case of an ubi_update_fastmap() failure
If ubi_update_fastmap() fails notify the user.
This is not a hard error as ubi_update_fastmap() makes sure that upon failure
the current on-flash fastmap will no be used upon next UBI attach.

Signed-off-by: Richard Weinberger <richard@nod.at>

Conflicts:
	drivers/mtd/ubi/wl.c

Fixed minor conflict.

Signed-off-by: Teresa Remmet <t.remmet@phytec.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-05-27 12:30:27 +02:00
Richard Weinberger bb1a98cc18 UBI: Fastmap: Fix memory leaks while closing the WL sub-system
Add a ubi_fastmap_close() to free all resources used by fastmap
at WL shutdown.

Signed-off-by: Richard Weinberger <richard@nod.at>
Tested-by: Guido Martínez <guido@vanguardiasur.com.ar>
Reviewed-by: Guido Martínez <guido@vanguardiasur.com.ar>
Signed-off-by: Teresa Remmet <t.remmet@phytec.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-05-27 12:30:27 +02:00
Richard Weinberger 0e0ab6669a UBI: Fastmap: Don't allocate new ubi_wl_entry objects
There is no need to allocate new ones every time, we can reuse
the existing ones.
This makes the code cleaner and more easy to follow.

Signed-off-by: Richard Weinberger <richard@nod.at>
Reviewed-by: Tanya Brokhman <tlinder@codeaurora.org>
Reviewed-by: Guido Martínez <guido@vanguardiasur.com.ar>

Conflicts:
	drivers/mtd/ubi/fastmap.c

Fixed minor conflict.

Signed-off-by: Teresa Remmet <t.remmet@phytec.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-05-27 12:30:27 +02:00
Richard Weinberger c1f0db3a00 UBI: Fastmap: Make ubi_refill_pools() fair
Currently ubi_refill_pools() first fills the first and then
the second one.
If only very few free PEBs are available the second pool can get
zero PEBs.
Change ubi_refill_pools() to distribute free PEBs fair between
all pools.

Signed-off-by: Richard Weinberger <richard@nod.at>
Reviewed-by: Guido Martínez <guido@vanguardiasur.com.ar>

Conflicts:
	drivers/mtd/ubi/wl.c

Fixed minor conflict.

Signed-off-by: Teresa Remmet <t.remmet@phytec.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-05-27 12:30:27 +02:00
Richard Weinberger 41917ec0db UBI: Split __wl_get_peb()
Make it two functions, wl_get_wle() and wl_get_peb().
wl_get_peb() works exactly like __wl_get_peb() but wl_get_wle()
does not call produce_free_peb().
While refilling the fastmap user pool we cannot release ubi->wl_lock
as produce_free_peb() does.
Hence the fastmap logic uses now wl_get_wle().

Signed-off-by: Richard Weinberger <richard@nod.at>

Conflicts:
	drivers/mtd/ubi/wl.c

Fixed minor conflict.

Signed-off-by: Teresa Remmet <t.remmet@phytec.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-05-27 12:30:27 +02:00
Brian Norris b6dae61226 UBI: align comment for readability
The kerneldoc for @vid_hdr_aloffset continues onto a second line, but
this is not obvious, because the second line isn't indented, and it
begins with '@'.

Signed-off-by: Brian Norris <computersforpeace@gmail.com>
Signed-off-by: Richard Weinberger <richard@nod.at>
Signed-off-by: Teresa Remmet <t.remmet@phytec.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-05-27 12:30:27 +02:00
Brian Norris b55281c930 UBI: initialize LEB number variable
In some of the 'out_not_moved' error paths, lnum may be used
uninitialized. Don't ignore the warning; let's fix it.

This uninitialized variable doesn't have much visible effect in the end,
since we just schedule the PEB for erasure, and its LEB number doesn't
really matter (it just gets printed in debug messages). But let's get it
straight anyway.

Coverity CID #113449

Cc: stable <stable@vger.kernel.org>
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
Signed-off-by: Richard Weinberger <richard@nod.at>
Signed-off-by: Teresa Remmet <t.remmet@phytec.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-05-27 12:30:27 +02:00
Brian Norris 29f82f85c8 UBI: fix out of bounds write
If aeb->len >= vol->reserved_pebs, we should not be writing aeb into the
PEB->LEB mapping.

Caught by Coverity, CID #711212.

Cc: stable <stable@vger.kernel.org>
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
Signed-off-by: Richard Weinberger <richard@nod.at>
Signed-off-by: Teresa Remmet <t.remmet@phytec.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-05-27 12:30:27 +02:00
Brian Norris 2021c973ea UBI: account for bitflips in both the VID header and data
We are completely discarding the earlier value of 'bitflips', which
could reflect a bitflip found in ubi_io_read_vid_hdr(). Let's use the
bitwise OR of header and data 'bitflip' statuses instead.

Coverity CID #1226856

Cc: stable <stable@vger.kernel.org>
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
Signed-off-by: Richard Weinberger <richard@nod.at>
Signed-off-by: Teresa Remmet <t.remmet@phytec.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-05-27 12:30:27 +02:00
Brian Norris cea375ee5d UBI: fix missing brace control flow
commit 0e707ae79ba3 ("UBI: do propagate positive error codes up") seems
to have produced an unintended change in the control flow here.

Completely untested, but it looks obvious.

Caught by Coverity, which didn't like the indentation. CID 1271184.

Signed-off-by: Brian Norris <computersforpeace@gmail.com>
Cc: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Richard Weinberger <richard@nod.at>
Signed-off-by: Teresa Remmet <t.remmet@phytec.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-05-27 12:30:27 +02:00
Richard Weinberger 4ee1297e15 UBI: Fastmap: Care about the protection queue
Fastmap can miss a PEB if it is in the protection queue
and not jet in the used tree.
Treat every protected PEB as used.

Signed-off-by: Richard Weinberger <richard@nod.at>
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
Signed-off-by: Teresa Remmet <t.remmet@phytec.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-05-27 12:30:27 +02:00
Artem Bityutskiy 38d958af9b UBI: do propagate positive error codes up
UBI uses positive function return codes internally, and should not propagate
them up, except in the place this path fixes. Here is the original bug report
from Dan Carpenter:

The problem is really in ubi_eba_read_leb().

drivers/mtd/ubi/eba.c
   412                  err = ubi_io_read_vid_hdr(ubi, pnum, vid_hdr, 1);
   413                  if (err && err != UBI_IO_BITFLIPS) {
   414                          if (err > 0) {
   415                                  /*
   416                                   * The header is either absent or corrupted.
   417                                   * The former case means there is a bug -
   418                                   * switch to read-only mode just in case.
   419                                   * The latter case means a real corruption - we
   420                                   * may try to recover data. FIXME: but this is
   421                                   * not implemented.
   422                                   */
   423                                  if (err == UBI_IO_BAD_HDR_EBADMSG ||
   424                                      err == UBI_IO_BAD_HDR) {
   425                                          ubi_warn("corrupted VID header at PEB %d, LEB %d:%d",
   426                                                   pnum, vol_id, lnum);
   427                                          err = -EBADMSG;
   428                                  } else
   429                                          ubi_ro_mode(ubi);

On this path we return UBI_IO_FF and UBI_IO_FF_BITFLIPS and it
eventually gets passed to ERR_PTR().  We probably dereference the bad
pointer and oops.  At that point we've gone read only so it was already
a bad situation...

   430                          }
   431                          goto out_free;
   432                  } else if (err == UBI_IO_BITFLIPS)
   433                          scrub = 1;
   434

Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
Signed-off-by: Teresa Remmet <t.remmet@phytec.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-05-27 12:30:27 +02:00
Artem Bityutskiy a2c9d53236 UBI: clean-up printing helpers
Let's prefix UBI messages with 'ubiX' instead of 'UBI-X' - this is more
consistent with the way we name UBI devices.

Also, commit "32608703 UBI: Extend UBI layer debug/messaging capabilities"
added the function name print to 'ubi_msg()' - lets revert this change, since
these messages are supposed to be just informative messages, and not debugging
messages.

Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>

Conflicts:
	drivers/mtd/ubi/ubi.h

Fixed minor conflict.

Signed-off-by: Teresa Remmet <t.remmet@phytec.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-05-27 12:30:27 +02:00
Tanya Brokhman 33f0c785ec UBI: extend UBI layer debug/messaging capabilities - cosmetics
Some cosmetic fixes to the patch "UBI: Extend UBI layer debug/messaging
capabilities".

Signed-off-by: Tanya Brokhman <tlinder@codeaurora.org>
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>

Conflicts:
	drivers/mtd/ubi/build.c
	drivers/mtd/ubi/cdev.c
	drivers/mtd/ubi/io.c
	drivers/mtd/ubi/wl.c

Reworked it for barebox.

Signed-off-by: Teresa Remmet <t.remmet@phytec.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-05-27 12:30:27 +02:00
Richard Weinberger cd40364588 UBI: Fix invalid vfree()
The logic of vfree()'ing vol->upd_buf is tied to vol->updating.
In ubi_start_update() vol->updating is set long before vmalloc()'ing
vol->upd_buf. If we encounter a write failure in ubi_start_update()
before vmalloc() the UBI device release function will try to vfree()
vol->upd_buf because vol->updating is set.
Fix this by allocating vol->upd_buf directly after setting vol->updating.

Fixes:
[   31.559338] UBI warning: vol_cdev_release: update of volume 2 not finished, volume is damaged
[   31.559340] ------------[ cut here ]------------
[   31.559343] WARNING: CPU: 1 PID: 2747 at mm/vmalloc.c:1446 __vunmap+0xe3/0x110()
[   31.559344] Trying to vfree() nonexistent vm area (ffffc90001f2b000)
[   31.559345] Modules linked in:
[   31.565620]  0000000000000bba ffff88002a0cbdb0 ffffffff818f0497 ffff88003b9ba148
[   31.566347]  ffff88002a0cbde0 ffffffff8156f515 ffff88003b9ba148 0000000000000bba
[   31.567073]  0000000000000000 0000000000000000 ffff88002a0cbe88 ffffffff8156c10a
[   31.567793] Call Trace:
[   31.568034]  [<ffffffff818f0497>] dump_stack+0x4e/0x7a
[   31.568510]  [<ffffffff8156f515>] ubi_io_write_vid_hdr+0x155/0x160
[   31.569084]  [<ffffffff8156c10a>] ubi_eba_write_leb+0x23a/0x870
[   31.569628]  [<ffffffff81569b36>] vol_cdev_write+0x226/0x380
[   31.570155]  [<ffffffff81179265>] vfs_write+0xb5/0x1f0
[   31.570627]  [<ffffffff81179f8a>] SyS_pwrite64+0x6a/0xa0
[   31.571123]  [<ffffffff818fde12>] system_call_fastpath+0x16/0x1b

Cc: <stable@vger.kernel.org>
Signed-off-by: Richard Weinberger <richard@nod.at>
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
Signed-off-by: Teresa Remmet <t.remmet@phytec.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-05-27 12:30:27 +02:00
Richard Weinberger 7ab29ccfa8 UBI: Fix double free after do_sync_erase()
If the erase worker is unable to erase a PEB it will
free the ubi_wl_entry itself.
The failing ubi_wl_entry must not free()'d again after
do_sync_erase() returns.

Cc: <stable@vger.kernel.org>
Signed-off-by: Richard Weinberger <richard@nod.at>
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>

Conflicts:
	drivers/mtd/ubi/wl.c

Fixed small conflict.

Signed-off-by: Teresa Remmet <t.remmet@phytec.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-05-27 12:30:27 +02:00
Richard Weinberger 3032649d43 UBI: vtbl: Use ubi_eba_atomic_leb_change()
This is more a cosmetic change than a fix.
By using ubi_eba_atomic_leb_change()
we can guarantee that the first VTBL record is always
correct and we don't really need the second one anymore.
But we have to keep the second one to not break anything.

Artem: add a comment

Signed-off-by: Richard Weinberger <richard@nod.at>
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
Signed-off-by: Teresa Remmet <t.remmet@phytec.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-05-27 12:30:27 +02:00
Tanya Brokhman 379c86f1af UBI: Extend UBI layer debug/messaging capabilities
If there is more then one UBI device mounted, there is no way to
distinguish between messages from different UBI devices.
Add device number to all ubi layer message types.

The R/O block driver messages were replaced by pr_* since
ubi_device structure is not used by it.

Amended a bit by Artem.

Signed-off-by: Tanya Brokhman <tlinder@codeaurora.org>
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>

Conflicts:
	drivers/mtd/ubi/block.c
	drivers/mtd/ubi/build.c
	drivers/mtd/ubi/cdev.c
	drivers/mtd/ubi/debug.c
	drivers/mtd/ubi/fastmap.c
	drivers/mtd/ubi/io.c
	drivers/mtd/ubi/ubi.h
	drivers/mtd/ubi/vmt.c
	drivers/mtd/ubi/wl.c

Reworked it for barebox.

Signed-off-by: Teresa Remmet <t.remmet@phytec.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-05-27 12:30:27 +02:00
Richard Weinberger fbc46098ba UBI: Fastmap: Calc fastmap size correctly
We need to add fm_sb too.

Signed-off-by: Richard Weinberger <richard@nod.at>
Reviewed-by: Tanya Brokhman <tlinder@codeaurora.org>
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
Signed-off-by: Teresa Remmet <t.remmet@phytec.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-05-27 12:30:27 +02:00
Richard Weinberger fd87416901 UBI: Fix trivial typo in __schedule_ubi_work
s/of/if/

Signed-off-by: Richard Weinberger <richard@nod.at>
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
Signed-off-by: Teresa Remmet <t.remmet@phytec.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-05-27 12:30:27 +02:00
Richard Weinberger 50b3e86258 UBI: wl: Rename cancel flag to shutdown
It confused me more than once that the cancel flag of the
work function does not indicate the cancellation of a single work.
In fact it indicates the WL sub-system shutdown and therefore
worker functions have to free their wl_entries too.
That's why you cannot cancel a single work, you can only shutdown
all works.

Signed-off-by: Richard Weinberger <richard@nod.at>
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
Signed-off-by: Teresa Remmet <t.remmet@phytec.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-05-27 12:30:27 +02:00
Richard Weinberger ed50f88648 UBI: ubi_eba_read_leb: Remove in vain variable assignment
There is no need to set err, it will be overwritten in any case
later at:
        if (scrub)
                err = ubi_wl_scrub_peb(ubi, pnum);

Signed-off-by: Richard Weinberger <richard@nod.at>
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
Signed-off-by: Teresa Remmet <t.remmet@phytec.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-05-27 12:30:27 +02:00
Richard Weinberger efdbc27a0f UBI: Improve comment on work_sem
Make clear what work_sem really does.

Suggested-by: Artem Bityutskiy <dedekind1@gmail.com>
Signed-off-by: Richard Weinberger <richard@nod.at>
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
Signed-off-by: Teresa Remmet <t.remmet@phytec.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-05-27 12:30:27 +02:00
Richard Genoud b743e8c57a UBI: add missing kmem_cache_free() in process_pool_aeb error path
I ran into this error after a ubiupdatevol, because I forgot to backport
e9110361a9a4 UBI: fix the volumes tree sorting criteria.

UBI error: process_pool_aeb: orphaned volume in fastmap pool
UBI error: ubi_scan_fastmap: Attach by fastmap failed, doing a full scan!
kmem_cache_destroy ubi_ainf_peb_slab: Slab cache still has objects
CPU: 0 PID: 1 Comm: swapper Not tainted 3.14.18-00053-gf05cac8dbf85 #1
[<c000d298>] (unwind_backtrace) from [<c000baa8>] (show_stack+0x10/0x14)
[<c000baa8>] (show_stack) from [<c01b7a68>] (destroy_ai+0x230/0x244)
[<c01b7a68>] (destroy_ai) from [<c01b8fd4>] (ubi_attach+0x98/0x1ec)
[<c01b8fd4>] (ubi_attach) from [<c01ade90>] (ubi_attach_mtd_dev+0x2b8/0x868)
[<c01ade90>] (ubi_attach_mtd_dev) from [<c038b510>] (ubi_init+0x1dc/0x2ac)
[<c038b510>] (ubi_init) from [<c0008860>] (do_one_initcall+0x94/0x140)
[<c0008860>] (do_one_initcall) from [<c037aadc>] (kernel_init_freeable+0xe8/0x1b0)
[<c037aadc>] (kernel_init_freeable) from [<c02730ac>] (kernel_init+0x8/0xe4)
[<c02730ac>] (kernel_init) from [<c00093f0>] (ret_from_fork+0x14/0x24)
UBI: scanning is finished

Freeing the cache in the error path fixes the Slab error.

Tested on at91sam9g35 (3.14.18+fastmap backports)

Signed-off-by: Richard Genoud <richard.genoud@gmail.com>
Cc: stable <stable@vger.kernel.org> # 3.10+

Use kfree instead of kmem_cache_free() for barebox.

Signed-off-by: Teresa Remmet <t.remmet@phytec.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-05-27 12:30:27 +02:00
Sascha Hauer 5376121774 of: Add missing include
drivers/of/device.c has the implementation for of_match_device(), so
also include the header which has the prototype.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-05-24 12:51:53 +02:00
Sascha Hauer 57a648aabb of: base: Match simple-mfd devices
Some simple-buses are now considered to be simple-mfd devices. Match
them aswell.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-05-23 12:21:03 +02:00
Trent Piepho a2f8644d71 rtc: ds1307: Add ds1308 to driver's ID list
As far as the driver is concerned, it's the same as a 1338.  It's too
bad the i2c drivers can't make use of OF compatible properties with a
list of compatible devices.

Signed-off-by: Trent Piepho <tpiepho@kymetacorp.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-05-23 08:29:46 +02:00
Alexander Shiyan b2b000699b ATA: platform_ide: Fix resource allocation
Fixes: 3bd69ad driver: replace dev_request_mem_region with
dev_request_mem_resource

The driver trying to use memory resource, then IO resource.
The ALT register is optional.

Signed-off-by: Alexander Shiyan <shc_work@mail.ru>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-05-23 08:23:54 +02:00
Sascha Hauer f7c9c149e5 aiodev: Add basic LM75 temperature driver
Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-05-18 07:48:13 +02:00
Andrey Smirnov ccebda1d4c aiodev: Add TEMPMON driver
Port TEMPMON driver from U-Boot

Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-05-18 07:48:09 +02:00
Andrey Smirnov c203958f3b syscon: Decrease driver registration priority
A number of devices on i.MX6 list "syscon" as second compatibility
string, among them, most importantly, is "iomuxv3" pinmux driver, which
gets probed at "postcore_initcall". Probing this driver at
"core_initcall" results in "syscon" driver usurping pinmux device and
preventing "iomuxv3" driver from loading and correctly initializing
pinmux of the system (which in turn results in a lot of sadness).

Moving this driver to be initialized at "device_initcall" time resolves
the issue.

Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-05-18 07:47:51 +02:00
Sascha Hauer 914480a542 drivers: Introduce AIODEV subsystem
AIODEV/Aiodevice is a analog I/O framework that can be thought of as a
simplified hybrid between 'hwmon' and 'IIO' subsystems of Linux kernel

This commit is very heavily based on 'iodevice' framework proposal
written by Sascha Hauer.

Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-05-18 07:47:46 +02:00
Teresa Remmet adfc28f904 net: phy: micrel: KSZ9081/KSZ8091: Disable broadcast mode
KSZ9081 only supports two phy ids 0x0 and 0x3. 0x0 is also
used as broadcast address. Disable broadcast, so that id 0x0
can be used as unique address on a shared bus.

Signed-off-by: Teresa Remmet <t.remmet@phytec.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-05-13 12:06:33 +02:00
Sascha Hauer ece204a8ac usb: fastboot: Fix oem exec support
Fixes: b1374a6 usb: fastboot: drop CONFIG_COMMAND_SUPPORT dependency

The correct config option to depend on is CONFIG_COMMAND_SUPPORT,
not CONFIG_COMMAND.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-05-10 10:29:50 +02:00
Sascha Hauer 51061a9884 mtd: nand: nand_mxs: Add subpage read support
subpage read support can significantly speed up scanning UBI volumes, so
add support for it. This is inspired by the corresponding Kernel commit.
Unlike in the kernel we add subpage read support for i.MX28 aswell.
Testing it on i.MX28 revealed no problems.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-05-10 08:24:27 +02:00
Sascha Hauer ec21c89112 mtd: nand: Pass page argument to read_subpage hook
Similar to what the kernel does in e004debda (mtd: nand: add "page" argument for
read_subpage hook).

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-05-10 08:18:39 +02:00
Sascha Hauer 7ba65d2417 mtd: nand: nand_mxs: Factor out BCH setup function
The BCH setup has to be changed during runtime with the following
patches, so factor out a function for it.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-05-10 08:18:00 +02:00
Sascha Hauer 06f5a7c9ad Merge branch 'for-next/ubiformat' 2016-05-09 08:50:02 +02:00
Sascha Hauer 5c83ce6091 Merge branch 'for-next/pci' 2016-05-09 08:49:50 +02:00
Sascha Hauer fd2f990204 Merge branch 'for-next/mtd' 2016-05-09 08:49:43 +02:00
Sascha Hauer 4cb8e17aa3 Merge branch 'for-next/misc' 2016-05-09 08:49:43 +02:00
Sascha Hauer 854df603da Merge branch 'for-next/include-pdata' 2016-05-09 08:49:42 +02:00
Sascha Hauer 55aca0a48c Merge branch 'for-next/include-cleanup' 2016-05-09 08:49:42 +02:00
Sascha Hauer 21981dbe6c Merge branch 'for-next/imx' 2016-05-09 08:49:42 +02:00
Sascha Hauer 23debc6fd9 Merge branch 'for-next/arm' 2016-05-09 08:49:42 +02:00
Stefan Christ b66a106f34 mci: imx-esdhc: implement reset quirks for i.MX6 DualLite/Solo
First of all the reset values of MMC interfaces are differently between
Quad and DualLite/Solo SoM.

                Register VEND_SPEC2(0xC8)
    Quad:       0x0
    DualLite:   0x00000006
    default:    0x00000006    (from i.MX6 Reference Manual)

Furthermore the ROM Code of Quad and DualLite uses the MMC interfaces
differently when it loads the bootloader from that device:

                Register DLL_CTRL(0x60)  Bit 25 FBCLK_SEL (0x48)
    Quad:       0x0                      0
    DualLite:   0x01000021               1

Since the linux kernel and barebox driver doesn't reset all registers,
the MMC interface is in an inconsistent state, which leads to boot
failures for some eMMC devices on the i.MX6 DualLite SoM. The errors
look like:

    mmcblk3: error -110 sending stop command, original cmd response 0x900, card status 0x400900
    mmcblk3: error -84 transferring data, sector 24578, nr 2, cmd response 0x900, card status 0x0
    mmcblk3: retrying using single block read
    mmcblk3: error -84 transferring data, sector 24578, nr 2, cmd response 0x900, card status 0x0
    blk_update_request: I/O error, dev mmcblk3, sector 24578

It's sufficient to reset register DLL_CTRL and bit FBCLK_SEL. Register
VEND_SPEC2 has no effect.

Signed-off-by: Stefan Christ <s.christ@phytec.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-05-09 08:38:59 +02:00
Sascha Hauer 79fdb84a6b net: phy: Add fixed link support
Some network devices, especially when connected to a switch, are
connected via a fixed link. This patch adds support for a fixed phy
configured through device tree.
TODO: Add support for the "speed" and "full-duplex" properties.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Tested-by: Wjatscheslaw Stoljarski <wjatscheslaw.stoljarski@kiwigrid.com>
2016-05-09 08:30:28 +02:00
Andrey Smirnov d34b5ffc7f PCI: imx6: Add DT bindings to configure PHY Tx driver settings
The settings in GPR8 are dependent upon the particular layout of the
hardware platform.  As such, they should be configurable via the device
tree.

Look up PHY Tx driver settings from the device tree.  Fall back to the
original hard-coded values if they are not specified in the device tree.

[Andrey Smirnov: port to Barebox codebase]

Signed-off-by: Justin Waters <justin.waters@timesys.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
Acked-by: Lucas Stach <l.stach@pengutronix.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-05-03 09:15:39 +02:00
Andrey Smirnov a9fe885685 PCI: imx6: Remove broken Gen2 workaround
Remove the remnants of the workaround for erratum ERR005184 which was never
completely implemented.  The checks alone don't carry any value as we don't
act properly on the result.

A workaround should be added to the lane speed change in establish_link
later.

[Andrey Smirnov: port to Barebox codebase]

Signed-off-by: Lucas Stach <l.stach@pengutronix.de>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-05-03 09:15:39 +02:00
Andrey Smirnov 003f55844d PCI: imx6: Move PHY reset into imx6_pcie_establish_link()
This adds the PHY reset into a common error path of
imx6_pcie_establish_link(), deduplicating some of the debug prints.  Also
reduce the severity of the "no-link" message in the one place where it is
expected to be hit when no peripheral is attached.

[Andrey Smirnov: port to Barebox codebase]

Signed-off-by: Lucas Stach <l.stach@pengutronix.de>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-05-03 09:15:39 +02:00
Andrey Smirnov 469950f3db ATA: Implement a hook for 'devinfo'
Implement simple adapter function to serve as a hook for 'devinfo'
command.

Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-04-28 16:43:14 +02:00
Boris Brezillon 08d0d519ec of: fix of_tree_for_each_node_from() macro
of_tree_for_each_node_from() is supposed to iterate over all DT nodes
after the one pointed by the from parameter, but with the current
of_next_node() implementation we cannot access the root node.

Patch of_next_node() to point to root_node when from is NULL.

Doing that also simplifies users of of_tree_for_each_node_from() which
were duplicating the logic to point to the root_node when from is NULL.

Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-04-28 16:43:14 +02:00
Sascha Hauer b61d301cf6 state: Fix Kconfig dependencies
State support does not need OF_BAREBOX_DRIVERS and never did, so drop
the dependency there. It's the state driver which needs of_find_path(),
since this symbol now is always enabled when OF is enabled, we don't
have to add the dependency to the state driver, but instead can depend
on OFDEVICE. We could depend on OF instead, but compiling the state
driver without OFDEVICE makes no sense.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-04-28 16:43:14 +02:00
Sascha Hauer 5e94c658e4 drivers/of: Always compile of_path.c with OF support
of_find_path() is a OF specific library function, so always
compile it when OF support is enabled.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-04-28 16:43:14 +02:00
Andrey Smirnov 005cd22b30 sata-imx: Fix a typo
It looks like comma operator was accidentaly used instead of regular
semicolon. Fix this to avoid confusing future readers of the code.

Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-04-28 16:40:14 +02:00
Andrey Smirnov 69919d895a PCI: imx6: Move imx6_pcie_reset_phy() near other PHY handling functions
Move imx6_pcie_reset_phy() near the other PHY related functions in the
file.  This is a cosmetic change, but also allows to do the following
changes without introducing needless forward declarations.

[Andrey Smirnov: port to Barebox codebase]

Signed-off-by: Lucas Stach <l.stach@pengutronix.de>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-04-28 07:44:28 +02:00
Fabio Estevam 7ed3258eab PCI: imx6: Simplify a trivial if-return sequence
Simplify a trivial if-return sequence by combining it with a preceding
function call.

The semantic patch that makes this change is available in
scripts/coccinelle/misc/simple_return.cocci.

Signed-off-by: Fabio Estevam <fabio.estevam@freescale.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Acked-by: Lucas Stach <l.stach@pengutronix.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-04-28 07:44:21 +02:00
Andrey Smirnov ea13b82ae3 PCI: imx6: Rename imx6_pcie_start_link() to imx6_pcie_establish_link()
Rename imx6_pcie_start_link() to imx6_pcie_establish_link() to follow the
convention of other DesignWare-based host drivers.  No functional change.

[Andrey Smirnov: port to BB codebase]
Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Acked-by: Pratyush Anand <pratyush.anand@gmail.com>
Acked-by: Lucas Stach <l.stach@pengutronix.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-04-28 07:44:15 +02:00
Andrey Smirnov 015ec0a528 PCI: imx6: Add proper i.MX6+ reset sequence
I.MX6+ version of the silicon exposed PCIe core's reset signal as a bit
in one of the control registers. As a result using old, pre-i.MX6+,
reset sequence on i.MX6+ leads to Barebox hanging during startup. Using
exposed reset bit instead solves the problem.

This commit is based on portions of commit

c34068d48273e24d392d9a49a38be807954420ed

in http://git.freescale.com/git/cgit.cgi/imx/linux-2.6-imx.git

Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
Acked-by: Lucas Stach <l.stach@pengutronix.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-04-28 07:44:10 +02:00
Andrey Smirnov bd55401e97 OF: Port of_match_device() and of_device_get_match_data()
Port of_match_device() and of_device_get_match_data() from Linux kernel
code.

Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
Acked-by: Lucas Stach <l.stach@pengutronix.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-04-28 07:44:04 +02:00
Andrey Smirnov 9aa9049cfd PCI: imx6: Simplify imx6_pcie_remove()
Instead of manualy flipping the bits call imx6_pcie_assert_core_reset()
to give the code, executing after BB, a clean slate. This also makes the
function match similar code in Linux kernel driver.

Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
Acked-by: Lucas Stach <l.stach@pengutronix.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-04-28 07:43:49 +02:00
Uwe Kleine-König 63ae16da82 serial_auart: make dt aware
This allows to instantiate devices from an oftree and so allows
to select the console using /chosen/stdout-path.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-04-27 15:39:37 +02:00
Sascha Hauer b1374a6d97 usb: fastboot: drop CONFIG_COMMAND_SUPPORT dependency
fastboot can run without command support. In this case we cannot
execute oem commands.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-04-26 09:24:53 +02:00
Sascha Hauer 8228f9e1fd usb: fastboot: Use C API for ubiformat
This makes it possible to compile the fastboot gadget without
command support. While at it bail out when ubiformat is not
compiled in.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-04-26 09:10:02 +02:00
Sascha Hauer 1454a0e2cd of: preserve /memreserve/ entries
Some dts files for the Kernel specify a reserved memory area using the
/memreserve/ dtc directive. These entries get lost during
unflattening/flattening the device tree and are never passed to the
Kernel.

This patch fixes this behaviour. This is done by copying the entries
into a /memreserve node in the unflattened tree and moving them back
during flattening the tree. The entries added by barebox dynamically
are appended to the static entries from the original dtb.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-04-25 11:55:46 +02:00
Du Huanpeng fe03b34fbe whole tree: remove trailing whitespaces
Signed-off-by: Du Huanpeng <u74147@gmail.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-04-21 15:17:52 +02:00
Sascha Hauer cb8cf33ce8 fix erasing/protecting flashes with unspecified size
fixes: 81737c1 mtd: Fix erasing of devices >4GiB

Several places erased a complete flash partition passing ~0 as count to
erase(). With the above commit count to erase was changed from an unsigned
type to a signed type, so the (count > f->size - offset) check in
erase() no longer triggers and the ~0 count is no longer adjusted to the whole
device size. Among other things this results in saveenv failures on NOR
flashes.
This patch fixes this by introducing an explicit macro for erasing the
whole device which is tested for in erase(). All other negative values
are rejected.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Reported-by: Giorgio <giorgio.nicole@arcor.de>
2016-04-19 08:26:51 +02:00
Sascha Hauer 01f8f60cf0 stdio: rename getc to getchar
The function we have implemented as getc has the semantics of the
standard function getchar, so rename it accorgingly.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-04-15 12:21:46 +02:00
Sascha Hauer 947fb5adf8 string: Fix (v)asprintf prototypes
Our asprintf and vasprintf have different prototypes than the glibc
functions. This causes trouble when we want to share barebox code
with userspace code. Change the prototypes for (v)asprintf to match
the glibc prototypes. Since the current (v)asprintf are convenient
to use change the existing functions to b(v)asprintf.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-04-15 12:21:45 +02:00
Sascha Hauer db33f32842 include: move crc specific stuff to crc.h
We have a crc.h, so move our crc function prototypes there to further
cleanup common.h.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-04-15 12:21:44 +02:00
Sascha Hauer ea5aeb986c include: move run_command prototype to command.h
run_command fits much better into command.h, move it there.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-04-15 12:21:44 +02:00
Sascha Hauer dd8244a422 include: Move ide platform_data to include/platform_data
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-04-15 08:44:42 +02:00
Sascha Hauer a45ab7100c include: Move smc911x eth platform_data to include/platform_data
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-04-15 08:44:42 +02:00
Sascha Hauer 044058fe90 include: Move dm9000 eth platform_data to include/platform_data
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-04-15 08:44:42 +02:00
Sascha Hauer 041155f11c include: Move ns16550 serial platform_data to include/platform_data
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-04-15 08:44:42 +02:00
Sascha Hauer 51b03f4844 include: Move fec eth platform_data to include/platform_data
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-04-15 08:44:41 +02:00
Sascha Hauer 4fc192f6be include: Move davinci emac platform_data to include/platform_data
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-04-15 08:44:41 +02:00
Sascha Hauer 423204c619 include: Move designware eth platform_data to include/platform_data
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-04-15 08:44:41 +02:00
Sascha Hauer a1c43792a5 include: Move smc91111 eth platform_data to include/platform_data
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-04-15 08:44:41 +02:00
Sascha Hauer 472e36c752 include: Move ep93xx eth platform_data to include/platform_data
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-04-15 08:44:41 +02:00
Uwe Kleine-König d5034e62bc mci: mxs: add support for dt aliases to name devices
While changing there, reformat the comment and use ; instead of , after
the previous call.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-04-12 08:17:23 +02:00
Teresa Remmet 074f5cb186 mtd: nand: omap_gpmc: Fix bitflips in empty page
When using BCH8 decoding, bitflips in an empty page are
not checked. This can cause issues if UBI/UBIFS are used.
Extend the omap_correct_bch() function to check for them.

Code is based on linux mainline mtd/nand/omap2.c driver.

Signed-off-by: Teresa Remmet <t.remmet@phytec.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-04-12 08:16:03 +02:00
Teresa Remmet d316cda736 mtd: nand: omap_gpmc: Remove BCH4 support
This has no users and seems to be untested. Removed it.

Signed-off-by: Teresa Remmet <t.remmet@phytec.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-04-12 08:16:03 +02:00
Uwe Kleine-König bbf7a49bfd pinctrl: mxs: add raw value from device tree to debug output
Not sure this is of general interest, but it helped me matching pin
configs from a static table to device tree entries.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
2016-04-12 08:06:56 +02:00
Sascha Hauer 45ad47a301 Merge branch 'for-next/ubifs' 2016-04-08 13:37:28 +02:00
Sascha Hauer 5a43795272 Merge branch 'for-next/ubiformat' 2016-04-08 13:37:28 +02:00
Sascha Hauer 11b2257f4b Merge branch 'for-next/rtc' 2016-04-08 13:37:28 +02:00
Sascha Hauer 660fc0ad87 Merge branch 'for-next/mtd-imx-nand' 2016-04-08 13:37:28 +02:00
Sascha Hauer fd50a8d758 Merge branch 'for-next/imx-bbu-nand-fcb' 2016-04-08 13:37:28 +02:00
Sascha Hauer 0d3f88a6db Merge branch 'for-next/imx' 2016-04-08 13:37:28 +02:00