Driver's private data structure is allocated with kzalloc without any
code to check for kzalloc's possible failure. Fix that by replaceing
kzalloc with xzalloc.
Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Add a driver for DesignWare I2C controller IP block found on several
SoCs including Altera SoC products
Tested using Terrasic SoCKit board and GPIO expander board with I2C
EEPROM on it
Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Useful for recovering busses. This needs additional device tree properties
describing the sda/scl gpios. The corresponding linux patch with the binding
description is currently under review.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
If we have a timeout while waiting, try to recover.
Signed-off-by: Jan Luebbe <jluebbe@debian.org>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Replace jiffies from kernel code with get_time_ns. The flags variable
used in the readbytes debug output does not exist.
Signed-off-by: Jan Luebbe <jluebbe@debian.org>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
This is based on commit 9dcb0e7b999db6c420c70fd32497a979a044fcdf from
the kernel with some additional fixes.
Signed-off-by: Jan Luebbe <jluebbe@debian.org>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
This implements the fix from the kernel commit
4cdbf7d346e7461c3b93a26707c852e2c9db3753.
Signed-off-by: Jan Luebbe <jluebbe@debian.org>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
This is based on the code introduced to the kernel in
5f9296ba21b3c395e53dd84e7ff9578f97f24295.
Signed-off-by: Jan Luebbe <jluebbe@debian.org>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
All points of failure in the code of i2c_fsl_probe() happen after the
allocation of i2c_fsl, so all of them have to perform necessary
cleanup setups in case of failure.
Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
This IP core is shared between many FSL SoCs. The MPC5200 provides this
core as well.
Signed-off-by: Juergen Borleis <jbe@pengutronix.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
When probing from devicetree, the output for several i2c host
controllers prints out a bus number of -1:
i2c-omap 44e0b000.i2c: bus -1 rev0.11 at 400 kHz
i2c-omap 4802a000.i2c: bus -1 rev0.11 at 400 kHz
i2c-omap 4819c000.i2c: bus -1 rev0.11 at 400 kHz
The call to i2c_add_numbered_adapter() in probe finds out the next free
bus number, so we move the output to a location where the number is
already determined.
Signed-off-by: Robert Schwebel <r.schwebel@pengutronix.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Since 2011 barebox' of_device_id struct uses unsigned long type for data field:
struct of_device_id {
char *compatible;
unsigned long data;
};
Almost always struct of_device_id.data field are used as pointer
and need 'unsigned long' casting.
E.g. see 'git grep -A 4 of_device_id drivers/' output:
drivers/ata/sata-imx.c:static __maybe_unused struct of_device_id imx_sata_dt_ids[] = {
drivers/ata/sata-imx.c- {
drivers/ata/sata-imx.c- .compatible = "fsl,imx6q-ahci",
drivers/ata/sata-imx.c- .data = (unsigned long)&data_imx6,
drivers/ata/sata-imx.c- }, {
Here is of_device_id struct in linux kernel v4.0:
struct of_device_id {
char name[32];
char type[32];
char compatible[128];
const void *data;
};
Changing of_device_id.data type to 'const void *data' will increase
barebox' linux kernel compatibility and decrease number of 'unsigned
long' casts.
Part of the patch was done using the 'coccinelle' tool with the
following semantic patch:
@rule1@
identifier dev;
identifier type;
identifier func;
@@
func(...) {
<...
- dev_get_drvdata(dev, (unsigned long *)&type)
+ dev_get_drvdata(dev, (const void **)&type)
...>
}
@rule2@
identifier dev;
identifier type;
identifier func;
identifier data;
@@
func(...) {
<...
- dev_get_drvdata(dev, (unsigned long *)&type->data)
+ dev_get_drvdata(dev, (const void **)&type->data)
...>
}
Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Based on this linux kernel commit:
commit 0ce4bc1dbdd911ae1763e2d4ff36bd1b214a59f7
Author: Chen-Yu Tsai <wens@csie.org>
Date: Mon Sep 1 22:28:13 2014 +0800
i2c: mv64xxx: continue probe when clock-frequency is missing
The "clock-frequency" DT property is listed as optional, However,
the current code stores the return value of of_property_read_u32 in
the return code of mv64xxx_of_config, but then forgets to clear it
after setting the default value of "clock-frequency". It is then
passed out to the main probe function, resulting in a probe failure
when "clock-frequency" is missing.
Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
The bus implementations currently call the drivers remove
hook unconditionally, but this hook is seldomly populated. Only call
it when it's actually populated.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
The compatible "ti,omap4-i2c" don't help to get fclk_rate. So set it acording to
cpu compatible: "ti,am33xx" and "ti,omap4"
Signed-off-by: Jan Weitzel <j.weitzel@phytec.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
i2c is needed to enable voltage rails that are later
needed by other drivers.
Signed-off-by: Lucas Stach <l.stach@pengutronix.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Looking at the linux kernel the clock-frequency property of
the device tree is used to set the bus speed and not the
fclk_rate. Adapted this to be compliant with linux kernel.
Signed-off-by: Teresa Gámez <t.gamez@phytec.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
As the i2c-at91 driver won't work in the interrupt mode,
so need to poll the interrupts.
Signed-off-by: Bo Shen <voice.shen@atmel.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
This driver is also used for Allwinner SoCs I2C controllers.
Ported from linux-3.15.
The most notable barebox driver version changes:
* drop platform device stuff;
* drop "allwinner,sun*" stuff;
* drop message offloading support;
* add reg-io-width devicetree parameter to use driver
with byte-oriented controller versions.
Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com>
Acked-by: Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com>
On Armada XP:
Tested-by: Sebastian Hesselbarth <sebastian.hesselbarth@gmail.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
This patch imports i2c_smbus_{read,write}* functions from linux-3.15.
Here is a quote from linux.git/Documentation/i2c/smbus-protocol:
If you write a driver for some I2C device, please try to use the SMBus
commands if at all possible (if the device uses only that subset of the
I2C protocol). This makes it possible to use the device driver on both
SMBus adapters and I2C adapters (the SMBus command set is automatically
translated to I2C on I2C adapters, but plain I2C commands can not be
handled at all on most pure SMBus adapters).
So having i2c_smbus_{read,write}* functions in barebox makes
porting of linux i2c client drivers much easier as many drivers rely on
these smbus functions.
Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>