summaryrefslogtreecommitdiffstats
path: root/drivers/i2c
Commit message (Collapse)AuthorAgeFilesLines
* i.MX: i2c: Fix build error in debug output codeAndrey Smirnov2018-08-131-2/+2
| | | | | | | | | Looks like that particular chunk of the code have not been built in a while and bitrotted. Change function parameters appropriately to avoid breaking the build. Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* i2c-mux-pca954x: fix out-of-bounds write for 64 bit systemsPeter Mamonov2018-05-241-1/+3
| | | | | | | | get_drv_data(..., &data->type) overwrites memory beyond data->type member due to mismatch of sizeof(enum pca_type) and sizeof(void *) on 64 bit systems. Signed-off-by: Peter Mamonov <pmamonov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* i2c: i2c_master_send(): don't leave flags uninitializedAntony Pavlov2018-02-091-0/+1
| | | | | | | | Leaving the flags field unitialized can lead to performing read operation instead of write operation. Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* i2c: read/write_reg: don't assume client->dev to be validUwe Kleine-König2018-01-251-2/+2
| | | | | | | | | | | | | | When using the barebox commands i2c_read or i2c_write the client pointer passed to the respective function isn't completely initialized. This makes dev_dbg(&client->dev, ...); choke as it dereferences client->dev.driver->name with client->dev.driver being a random value. Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* i2c: designware: evaluate i2c-sda-hold-time propertySteffen Trumtrar2018-01-111-0/+40
| | | | | | | | | | Newer designware i2c controllers allow setting the SDA hold time. Evaluate the devicetree property "i2c-sda-hold-time" and set the value accordingly. The code is an adaption of the Linux v4.12 driver. Signed-off-by: Steffen Trumtrar <s.trumtrar@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* i2c: mv64xxx: add timeout waiting for bus readyBastian Stender2017-11-171-5/+15
| | | | | | | | This prevents barebox hanging e.g. in case the i2c clock is accidentally connected to GND. Signed-off-by: Bastian Stender <bst@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* i2c: mv64xxx: fix indentationAntony Pavlov2017-05-231-1/+1
| | | | | | | | | | | | | | | | | | The patch fixes this compiler's warning: drivers/i2c/busses/i2c-mv64xxx.c: In function ‘mv64xxx_i2c_fsm’: drivers/i2c/busses/i2c-mv64xxx.c:303:3: warning: this ‘if’ clause does not guard... [-Wmisleading-indentation] if (drv_data->bytes_left == 1) ^~ drivers/i2c/busses/i2c-mv64xxx.c:305:4: note: ...this statement, but the latter is misleadingly indented as if it is guarded by the ‘if’ udelay(2); ^~~~~~ Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com> Cc: Bastian Stender <bst@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Merge branch 'for-next/mvebu'Sascha Hauer2017-03-131-23/+18
|\
| * i2c: mv64xxx: simplify mv64xxx_i2c_wait_for_completionBastian Stender2017-03-021-21/+8
| | | | | | | | | | | | | | | | | | Two nested while loops are not necessary here, so integrate the read, i2c_fsm and i2c_do_action calls into mv64xxx_i2c_wait_for_completion() and remove the obsolete interrupt remains. Signed-off-by: Bastian Stender <bst@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * i2c: mv64xxx: add software delaysBastian Stender2017-03-021-2/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | As stated in Marvell's Functional Specifications in MV-S107021-U0 Rev. A on page 420 ff. software delays are needed. "SW delay represent a delay of at least 2 internal clock cycles". These delays are hereby implemented. The original kernel driver compensates the needed software delays with the time the interrupts take. Signed-off-by: Bastian Stender <bst@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | i.MX: i2c: fix i2c-fsl for non-OF boardsAlexander Kurz2017-02-141-4/+10
|/ | | | | | | | | | With commit 4ed5b778a56b ("i.MX: i2c: Add Vybrid support") i2c-fsl probe returns -EINVAL for all non-OF boards. Since newer planforms, especially vf610 are restricted OF-only it is safe to assume "fsl,imx21-i2c" if CONFIG_OFDEVICE is not set. Signed-off-by: Alexander Kurz <akurz@blala.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* i2c: i.MX: Enable clockSascha Hauer2017-01-191-0/+1
| | | | | | For architectures which do not enable all clocks during initialization. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Merge branch 'for-next/vybrid'Sascha Hauer2017-01-121-62/+160
|\
| * i.MX: i2c: Add Vybrid supportAndrey Smirnov2017-01-111-28/+122
| | | | | | | | | | Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
| * i.MX: i2c: Use read/write adapter functionsAndrey Smirnov2017-01-111-42/+46
| | | | | | | | | | | | | | | | | | Use read/write adapter functions instead of directly calling to readb/writeb. This is needed to prepare driver code to support Vybrid SoC's variant of this block. Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | Merge branch 'for-next/misc'Sascha Hauer2017-01-111-0/+7
|\ \
| * | i2c-mux-pca954x: Add code to control reset lineAndrey Smirnov2017-01-101-0/+7
| |/ | | | | | | | | | | | | | | | | | | Most recent device tree binding for that mux support specifying a GPIO connected to a reset line of that chip. Add code to handle that binding in order to be able to use the chip on boards that leverage aforementioned functionality. Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | i2c: gpio: use dynamic bus number unconditionallyUwe Kleine-König2016-11-171-1/+1
| | | | | | | | | | | | | | | | While being a bit more random this helps dt setups where the id of a platform device cannot easily be fixed anyhow. Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | i2c: gpio: fix handling of return code of of_get_gpioUwe Kleine-König2016-11-171-7/+9
|/ | | | | | | | | | | | Instead of using gpio_is_valid just check the return code of of_get_gpio for being < 0. This fixes -EPROBE_DEFER handling as now this error code is handed to the caller instead of -ENODEV. If the gpio returned by of_get_gpio is an invalid number this isn't noticed by of_i2c_gpio_probe, but then gpio_request later fails which is good enough. Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* driver: replace dev_request_mem_region with dev_request_mem_resourceSascha Hauer2016-03-077-19/+35
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | dev_request_mem_region doesn't work properly one some SoCs on which PTR_ERR() values clash with valid return values from dev_request_mem_region. Replace them with dev_request_mem_resource where possible. This patch has been generated with the following semantic patch: // <smpl> @@ expression d; expression n; expression io; identifier func; @@ func(...) { +struct resource *iores; <+... -io = dev_request_mem_region(d, n); -if (IS_ERR(io)) { +iores = dev_request_mem_resource(d, n); +if (IS_ERR(iores)) { ... - return PTR_ERR(io); -} + return PTR_ERR(iores); +} +io = IOMEM(iores->start); ...+> } @@ expression d; expression n; expression io; identifier func; @@ func(...) { +struct resource *iores; <+... -io = dev_request_mem_region(d, n); -if (IS_ERR(io)) { +iores = dev_request_mem_resource(d, n); +if (IS_ERR(iores)) - return PTR_ERR(io); -} + return PTR_ERR(iores); +io = IOMEM(iores->start); ...+> } @@ expression d; expression n; expression io; identifier func; @@ func(...) { +struct resource *iores; <+... -io = dev_request_mem_region(d, n); -if (IS_ERR(io)) { - ret = PTR_ERR(io); +iores = dev_request_mem_resource(d, n); +if (IS_ERR(iores)) { + ret = PTR_ERR(iores); ... } +io = IOMEM(iores->start); ...+> } @@ expression d; expression n; expression io; identifier func; @@ func(...) { +struct resource *iores; <+... -io = dev_request_mem_region(d, n); +iores = dev_request_mem_resource(d, n); +if (IS_ERR(iores)) + return PTR_ERR(iores); +io = IOMEM(iores->start); ...+> } @@ identifier func; @@ func(...) { <+... struct resource *iores; -struct resource *iores; ...+> } // </smpl> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* driver: Fix return check of dev_request_mem_regionSascha Hauer2016-02-232-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | dev_request_mem_region returns an ERR_PTR, fix places which check for a NULL pointer instead. This patch has been generated with this semantic patch, written by me and improved by Andrey Smirnov: // <smpl> @@ expression e; expression e1; @@ e = dev_request_mem_region(...); ... -if (!e) - return e1; +if (IS_ERR(e)) + return PTR_ERR(e); @ rule1 @ expression e; @@ e = dev_request_mem_region(...); @@ expression rule1.e; identifier ret, label; constant errno; @@ if (!e) { ... ( - ret = -errno; + ret = PTR_ERR(e); ... goto label; | - return -errno; + return PTR_ERR(e); ) } @depends on rule1@ expression rule1.e; @@ - if (e == NULL) + if (IS_ERR(e)) { ... } // </smpl> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de> Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
* i2c: core: Add client I2C address to devinfoTrent Piepho2015-11-201-0/+9
| | | | | | | | | | Useful bit of information. Example: barebox:/ devinfo dummy0 Bus: i2c Address: 0x52 Signed-off-by: Trent Piepho <tpiepho@kymetacorp.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* i2c: add pca954x bus multiplexer driverAntony Pavlov2015-11-195-1/+272
| | | | | Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* i2c: import multiplexed I2C bus core support from linux kernelAntony Pavlov2015-11-193-0/+156
| | | | | Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* i2c: Create for_each_i2c_adapter()Sascha Hauer2015-11-191-4/+4
| | | | | | This can be used by the i2c_probe command to iterate over i2c adapters. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* i2c-imx: Use xzalloc instead of kzallocAndrey Smirnov2015-11-191-1/+1
| | | | | | | | | 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>
* i2c: Add support for DesignWare controllersAndrey Smirnov2015-11-193-0/+581
| | | | | | | | | | | 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>
* i2c: fsl: Add bus recovery supportSascha Hauer2015-09-171-5/+62
| | | | | | | | 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>
* Merge branch 'for-next/misc'Sascha Hauer2015-09-011-4/+8
|\
| * i2c-imx: Fix memory leak in i2c_fsl_probe()Andrey Smirnov2015-08-191-4/+8
| | | | | | | | | | | | | | | | | | 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>
* | i2c: gpio: add bus recovery supportJan Luebbe2015-08-201-0/+10
| | | | | | | | | | Signed-off-by: Jan Luebbe <jluebbe@debian.org> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | i2c: algo-bit: check if the bus is busyJan Luebbe2015-08-201-0/+32
| | | | | | | | | | | | | | 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>
* | i2c: algo-bit: fix debug codeJan Luebbe2015-08-201-7/+5
| | | | | | | | | | | | | | | | 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>
* | i2c-omap: add bus recovery supportJan Luebbe2015-08-201-3/+81
| | | | | | | | | | | | | | | | 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>
* | i2c-omap: clear ARDY twiceJan Luebbe2015-08-201-0/+4
| | | | | | | | | | | | | | | | 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>
* | i2c: add bus recovery infrastructureJan Luebbe2015-08-201-0/+130
|/ | | | | | | | 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>
* Merge branch 'for-next/ppc'Sascha Hauer2015-08-061-2/+7
|\
| * PPC/MPC5200: re-use the IMX I2C master driver for MPC5200Juergen Borleis2015-08-031-2/+7
| | | | | | | | | | | | | | | | 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>
* | i2c: only register enabled child nodesJan Luebbe2015-07-091-1/+1
|/ | | | | Signed-off-by: Jan Luebbe <jluebbe@debian.org> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* Merge branch 'for-next/misc'Sascha Hauer2015-06-091-1/+1
|\
| * i2c: Use correct format specifierSascha Hauer2015-05-151-1/+1
| | | | | | | | | | | | 'count' is of type u16, not size_t. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
* | i2c: omap: fix i2c bus number outputRobert Schwebel2015-06-031-3/+3
|/ | | | | | | | | | | | | | | | 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>
* Merge branch 'for-next/of-device-id'Sascha Hauer2015-05-064-18/+18
|\
| * of: use 'const void *' for struct of_device_id.dataAntony Pavlov2015-04-304-18/+18
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* | i2c: mv64xxx: continue probe when clock-frequency is missingAntony Pavlov2015-04-171-2/+1
|/ | | | | | | | | | | | | | | | | | | | 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>
* driver: Call remove function only when availableSascha Hauer2015-03-171-1/+2
| | | | | | | | 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>
* i2c: omap: fix fclk_rate for ti,omap4-i2cJan Weitzel2015-01-061-6/+5
| | | | | | | | 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>
* Merge branch 'for-next/tegra'Sascha Hauer2014-11-051-1/+1
|\
| * i2c: tegra: move to fs initcallLucas Stach2014-10-081-1/+1
| | | | | | | | | | | | | | | | 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>
* | i2c: at91: fix invalid length checkLucas Stach2014-10-211-2/+2
|/ | | | | | Signed-off-by: Lucas Stach <dev@lynxeye.de> Acked-by: Bo Shen <voice.shen@atmel.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>