Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1681422 > unrolled thread
| Started by | Chris Packham <chris.packham@alliedtelesis.co.nz> |
|---|---|
| First post | 2017-07-05 12:20 +0200 |
| Last post | 2017-07-05 22:50 +0200 |
| Articles | 7 — 3 participants |
Back to article view | Back to linux.kernel
[PATCH v2 0/4] i2c: pca-platform: additional improvements Chris Packham <chris.packham@alliedtelesis.co.nz> - 2017-07-05 12:20 +0200
[PATCH v2 3/4] i2c: pca-platform: use device_property_read_u32 Chris Packham <chris.packham@alliedtelesis.co.nz> - 2017-07-05 12:20 +0200
[PATCH v2 1/4] sh: sh7785lcr: add GPIO lookup table for i2c controller reset Chris Packham <chris.packham@alliedtelesis.co.nz> - 2017-07-05 12:20 +0200
[PATCH v2 4/4] i2c: pca-platform: drop gpio from platform data Chris Packham <chris.packham@alliedtelesis.co.nz> - 2017-07-05 12:20 +0200
[PATCH v2 2/4] i2c: pca-platform: unconditionally use devm_gpiod_get_optional Chris Packham <chris.packham@alliedtelesis.co.nz> - 2017-07-05 12:20 +0200
Re: [PATCH v2 0/4] i2c: pca-platform: additional improvements Andy Shevchenko <andy.shevchenko@gmail.com> - 2017-07-05 13:50 +0200
Re: [PATCH v2 0/4] i2c: pca-platform: additional improvements Chris Packham <Chris.Packham@alliedtelesis.co.nz> - 2017-07-05 22:50 +0200
| From | Chris Packham <chris.packham@alliedtelesis.co.nz> |
|---|---|
| Date | 2017-07-05 12:20 +0200 |
| Subject | [PATCH v2 0/4] i2c: pca-platform: additional improvements |
| Message-ID | <tZPzz-4Wj-1@gated-at.bofh.it> |
This series addresses some of the points identified by Andy. The series is based on top of i2c/for-next. 2 of the patches from v1 have already been applied so I've dropped them from this version. I have compile tested patch 1/1 but I don't have access to sh hardware to actually test the changes on. Chris Packham (4): sh: sh7785lcr: add GPIO lookup table for i2c controller reset i2c: pca-platform: unconditionally use devm_gpiod_get_optional i2c: pca-platform: use device_property_read_u32 i2c: pca-platform: drop gpio from platform data arch/blackfin/mach-bf561/boards/acvilon.c | 1 - arch/sh/boards/board-sh7785lcr.c | 11 +++++++++- drivers/i2c/busses/i2c-pca-platform.c | 34 +++++++++---------------------- include/linux/i2c-pca-platform.h | 3 --- 4 files changed, 20 insertions(+), 29 deletions(-) -- 2.13.0
[toc] | [next] | [standalone]
| From | Chris Packham <chris.packham@alliedtelesis.co.nz> |
|---|---|
| Date | 2017-07-05 12:20 +0200 |
| Subject | [PATCH v2 3/4] i2c: pca-platform: use device_property_read_u32 |
| Message-ID | <tZPzA-4Wj-27@gated-at.bofh.it> |
| In reply to | #1681422 |
Use device_property_read_u32 instead of of_property_read_u32_index to
lookup the "clock-frequency" property.
Signed-off-by: Chris Packham <chris.packham@alliedtelesis.co.nz>
---
Changes in v2:
- move call to device_property_read_u32 to above platform_data usage.
This allows the device property/device tree to go first and
platform_data (if present) can override things. Eventually when all
the platforms using this driver are converted to either use device
properties or a device tree then the platform_data can simply be
deleted.
drivers/i2c/busses/i2c-pca-platform.c | 13 ++++++-------
1 file changed, 6 insertions(+), 7 deletions(-)
diff --git a/drivers/i2c/busses/i2c-pca-platform.c b/drivers/i2c/busses/i2c-pca-platform.c
index b90193d09d4b..bc2707ffd409 100644
--- a/drivers/i2c/busses/i2c-pca-platform.c
+++ b/drivers/i2c/busses/i2c-pca-platform.c
@@ -177,16 +177,15 @@ static int i2c_pca_pf_probe(struct platform_device *pdev)
if (IS_ERR(i2c->gpio))
return PTR_ERR(i2c->gpio);
+ i2c->adap.timeout = HZ;
+ ret = device_property_read_u32(&pdev->dev, "clock-frequency",
+ &i2c->algo_data.i2c_clock);
+ if (ret)
+ i2c->algo_data.i2c_clock = 59000;
+
if (platform_data) {
i2c->adap.timeout = platform_data->timeout;
i2c->algo_data.i2c_clock = platform_data->i2c_clock_speed;
- } else if (np) {
- i2c->adap.timeout = HZ;
- of_property_read_u32_index(np, "clock-frequency", 0,
- &i2c->algo_data.i2c_clock);
- } else {
- i2c->adap.timeout = HZ;
- i2c->algo_data.i2c_clock = 59000;
}
i2c->algo_data.data = i2c;
--
2.13.0
[toc] | [prev] | [next] | [standalone]
| From | Chris Packham <chris.packham@alliedtelesis.co.nz> |
|---|---|
| Date | 2017-07-05 12:20 +0200 |
| Subject | [PATCH v2 1/4] sh: sh7785lcr: add GPIO lookup table for i2c controller reset |
| Message-ID | <tZPzA-4Wj-11@gated-at.bofh.it> |
| In reply to | #1681422 |
Define the GPIO connected to the PCA9564 using a GPIO lookup table. This
will allow the i2c-pca-platform driver to use the device managed APIs to
lookup the gpio instead of using platform_data.
Signed-off-by: Chris Packham <chris.packham@alliedtelesis.co.nz>
---
Changes in v2:
- use correct API (gpio_add_lookup_table) and compile test.
arch/sh/boards/board-sh7785lcr.c | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/arch/sh/boards/board-sh7785lcr.c b/arch/sh/boards/board-sh7785lcr.c
index 2c4771ee84cd..caec1ebffb09 100644
--- a/arch/sh/boards/board-sh7785lcr.c
+++ b/arch/sh/boards/board-sh7785lcr.c
@@ -25,6 +25,7 @@
#include <linux/io.h>
#include <linux/clk.h>
#include <linux/errno.h>
+#include <linux/gpio/machine.h>
#include <mach/sh7785lcr.h>
#include <cpu/sh7785.h>
#include <asm/heartbeat.h>
@@ -243,6 +244,14 @@ static struct resource i2c_resources[] = {
},
};
+static struct gpiod_lookup_table i2c_gpio_table = {
+ .dev_id = "i2c.0",
+ .table = {
+ GPIO_LOOKUP("pfc-sh7757", 0, "reset-gpios", GPIO_ACTIVE_LOW),
+ { },
+ },
+};
+
static struct i2c_pca9564_pf_platform_data i2c_platform_data = {
.gpio = 0,
.i2c_clock_speed = I2C_PCA_CON_330kHz,
@@ -283,6 +292,7 @@ static int __init sh7785lcr_devices_setup(void)
i2c_device.num_resources = ARRAY_SIZE(i2c_proto_resources);
}
+ gpiod_add_lookup_table(&i2c_gpio_table);
return platform_add_devices(sh7785lcr_devices,
ARRAY_SIZE(sh7785lcr_devices));
}
--
2.13.0
[toc] | [prev] | [next] | [standalone]
| From | Chris Packham <chris.packham@alliedtelesis.co.nz> |
|---|---|
| Date | 2017-07-05 12:20 +0200 |
| Subject | [PATCH v2 4/4] i2c: pca-platform: drop gpio from platform data |
| Message-ID | <tZPzA-4Wj-23@gated-at.bofh.it> |
| In reply to | #1681422 |
Now that the i2c-pca-plaform driver is using the device managed API for
gpios there is no need for the reset gpio to be specified via
i2c_pca9564_pf_platform_data.
Signed-off-by: Chris Packham <chris.packham@alliedtelesis.co.nz>
---
arch/blackfin/mach-bf561/boards/acvilon.c | 1 -
arch/sh/boards/board-sh7785lcr.c | 1 -
include/linux/i2c-pca-platform.h | 3 ---
3 files changed, 5 deletions(-)
diff --git a/arch/blackfin/mach-bf561/boards/acvilon.c b/arch/blackfin/mach-bf561/boards/acvilon.c
index 37f8f25a1347..192404318a36 100644
--- a/arch/blackfin/mach-bf561/boards/acvilon.c
+++ b/arch/blackfin/mach-bf561/boards/acvilon.c
@@ -112,7 +112,6 @@ static struct resource bfin_i2c_pca_resources[] = {
};
struct i2c_pca9564_pf_platform_data pca9564_platform_data = {
- .gpio = -1,
.i2c_clock_speed = 330000,
.timeout = HZ,
};
diff --git a/arch/sh/boards/board-sh7785lcr.c b/arch/sh/boards/board-sh7785lcr.c
index caec1ebffb09..d7d232dea33e 100644
--- a/arch/sh/boards/board-sh7785lcr.c
+++ b/arch/sh/boards/board-sh7785lcr.c
@@ -253,7 +253,6 @@ static struct gpiod_lookup_table i2c_gpio_table = {
};
static struct i2c_pca9564_pf_platform_data i2c_platform_data = {
- .gpio = 0,
.i2c_clock_speed = I2C_PCA_CON_330kHz,
.timeout = HZ,
};
diff --git a/include/linux/i2c-pca-platform.h b/include/linux/i2c-pca-platform.h
index aba33759dec4..6331eaef9352 100644
--- a/include/linux/i2c-pca-platform.h
+++ b/include/linux/i2c-pca-platform.h
@@ -2,9 +2,6 @@
#define I2C_PCA9564_PLATFORM_H
struct i2c_pca9564_pf_platform_data {
- int gpio; /* pin to reset chip. driver will work when
- * not supplied (negative value), but it
- * cannot exit some error conditions then */
int i2c_clock_speed; /* values are defined in linux/i2c-algo-pca.h */
int timeout; /* timeout in jiffies */
};
--
2.13.0
[toc] | [prev] | [next] | [standalone]
| From | Chris Packham <chris.packham@alliedtelesis.co.nz> |
|---|---|
| Date | 2017-07-05 12:20 +0200 |
| Subject | [PATCH v2 2/4] i2c: pca-platform: unconditionally use devm_gpiod_get_optional |
| Message-ID | <tZPzA-4Wj-25@gated-at.bofh.it> |
| In reply to | #1681422 |
Allow for the reset-gpios property to be defined in the device tree
or via a GPIO lookup table.
Signed-off-by: Chris Packham <chris.packham@alliedtelesis.co.nz>
---
Changes in v2:
- move call up above platform_data usage
drivers/i2c/busses/i2c-pca-platform.c | 21 ++++-----------------
1 file changed, 4 insertions(+), 17 deletions(-)
diff --git a/drivers/i2c/busses/i2c-pca-platform.c b/drivers/i2c/busses/i2c-pca-platform.c
index 853a2abedb05..b90193d09d4b 100644
--- a/drivers/i2c/busses/i2c-pca-platform.c
+++ b/drivers/i2c/busses/i2c-pca-platform.c
@@ -173,33 +173,20 @@ static int i2c_pca_pf_probe(struct platform_device *pdev)
i2c->adap.dev.parent = &pdev->dev;
i2c->adap.dev.of_node = np;
+ i2c->gpio = devm_gpiod_get_optional(&pdev->dev, "reset-gpios", GPIOD_OUT_LOW);
+ if (IS_ERR(i2c->gpio))
+ return PTR_ERR(i2c->gpio);
+
if (platform_data) {
i2c->adap.timeout = platform_data->timeout;
i2c->algo_data.i2c_clock = platform_data->i2c_clock_speed;
- if (gpio_is_valid(platform_data->gpio)) {
- ret = devm_gpio_request_one(&pdev->dev,
- platform_data->gpio,
- GPIOF_ACTIVE_LOW,
- i2c->adap.name);
- if (ret == 0) {
- i2c->gpio = gpio_to_desc(platform_data->gpio);
- gpiod_direction_output(i2c->gpio, 0);
- } else {
- dev_warn(&pdev->dev, "Registering gpio failed!\n");
- i2c->gpio = NULL;
- }
- }
} else if (np) {
i2c->adap.timeout = HZ;
- i2c->gpio = devm_gpiod_get_optional(&pdev->dev, "reset-gpios", GPIOD_OUT_LOW);
- if (IS_ERR(i2c->gpio))
- return PTR_ERR(i2c->gpio);
of_property_read_u32_index(np, "clock-frequency", 0,
&i2c->algo_data.i2c_clock);
} else {
i2c->adap.timeout = HZ;
i2c->algo_data.i2c_clock = 59000;
- i2c->gpio = NULL;
}
i2c->algo_data.data = i2c;
--
2.13.0
[toc] | [prev] | [next] | [standalone]
| From | Andy Shevchenko <andy.shevchenko@gmail.com> |
|---|---|
| Date | 2017-07-05 13:50 +0200 |
| Message-ID | <tZQYG-5GJ-9@gated-at.bofh.it> |
| In reply to | #1681422 |
On Wed, Jul 5, 2017 at 1:13 PM, Chris Packham <chris.packham@alliedtelesis.co.nz> wrote: > This series addresses some of the points identified by Andy. The series is > based on top of i2c/for-next. 2 of the patches from v1 have already been > applied so I've dropped them from this version. > > I have compile tested patch 1/1 but I don't have access to sh hardware > to actually test the changes on. Entire series looks good to me: Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com> Further improvement is to get timeout value via device properties API and get rid of legacy platform data completely. This can be done in further series. > > Chris Packham (4): > sh: sh7785lcr: add GPIO lookup table for i2c controller reset > i2c: pca-platform: unconditionally use devm_gpiod_get_optional > i2c: pca-platform: use device_property_read_u32 > i2c: pca-platform: drop gpio from platform data > > arch/blackfin/mach-bf561/boards/acvilon.c | 1 - > arch/sh/boards/board-sh7785lcr.c | 11 +++++++++- > drivers/i2c/busses/i2c-pca-platform.c | 34 +++++++++---------------------- > include/linux/i2c-pca-platform.h | 3 --- > 4 files changed, 20 insertions(+), 29 deletions(-) > > -- > 2.13.0 > -- With Best Regards, Andy Shevchenko
[toc] | [prev] | [next] | [standalone]
| From | Chris Packham <Chris.Packham@alliedtelesis.co.nz> |
|---|---|
| Date | 2017-07-05 22:50 +0200 |
| Message-ID | <tZZpg-2RM-17@gated-at.bofh.it> |
| In reply to | #1681479 |
On 05/07/17 23:49, Andy Shevchenko wrote: > On Wed, Jul 5, 2017 at 1:13 PM, Chris Packham > <chris.packham@alliedtelesis.co.nz> wrote: >> This series addresses some of the points identified by Andy. The series is >> based on top of i2c/for-next. 2 of the patches from v1 have already been >> applied so I've dropped them from this version. >> >> I have compile tested patch 1/1 but I don't have access to sh hardware >> to actually test the changes on. > > > Entire series looks good to me: > Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com> > > Further improvement is to get timeout value via device properties API > and get rid of legacy platform data completely. This can be done in > further series. Actually the timeout can probably go now. The two in-tree platforms that set it via platform_data set it to HZ which is (now) the default. > >> >> Chris Packham (4): >> sh: sh7785lcr: add GPIO lookup table for i2c controller reset >> i2c: pca-platform: unconditionally use devm_gpiod_get_optional >> i2c: pca-platform: use device_property_read_u32 >> i2c: pca-platform: drop gpio from platform data >> >> arch/blackfin/mach-bf561/boards/acvilon.c | 1 - >> arch/sh/boards/board-sh7785lcr.c | 11 +++++++++- >> drivers/i2c/busses/i2c-pca-platform.c | 34 +++++++++---------------------- >> include/linux/i2c-pca-platform.h | 3 --- >> 4 files changed, 20 insertions(+), 29 deletions(-) >> >> -- >> 2.13.0 >> > > >
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web