* [RFC] i2c: sh_mobile: WIP! Fix clock calculation for newer SoCs
@ 2014-05-01 11:59 Wolfram Sang
[not found] ` <1398945555-12928-1-git-send-email-wsa-z923LK4zBo2bacvFa/9K2g@public.gmane.org>
0 siblings, 1 reply; 3+ messages in thread
From: Wolfram Sang @ 2014-05-01 11:59 UTC (permalink / raw)
To: linux-i2c-u79uwXL29TY76Z2rM5mHXA
Cc: Wolfram Sang, linux-sh-u79uwXL29TY76Z2rM5mHXA, Magnus Damm,
Geert Uytterhoeven, Wolfram Sang
From: Wolfram Sang <wsa+renesas-jBu1N2QxHDJrcw3mvpCnnVaTQe2KTcn/@public.gmane.org>
Newer SoCs have so fast input clocks that the ICCL/H registers only
count every second clock to have a meaningful 9-bit range. The driver
was already prepared for that happening, but didn't use it so far.
This patch still needs some improvements, but already shows what I am
aiming for.
Signed-off-by: Wolfram Sang <wsa+renesas-jBu1N2QxHDJrcw3mvpCnnVaTQe2KTcn/@public.gmane.org>
---
drivers/i2c/busses/i2c-sh_mobile.c | 32 +++++++++++++++++++++-----------
1 file changed, 21 insertions(+), 11 deletions(-)
diff --git a/drivers/i2c/busses/i2c-sh_mobile.c b/drivers/i2c/busses/i2c-sh_mobile.c
index ddc9970fd724..d399b9a355b6 100644
--- a/drivers/i2c/busses/i2c-sh_mobile.c
+++ b/drivers/i2c/busses/i2c-sh_mobile.c
@@ -32,6 +32,7 @@
#include <linux/clk.h>
#include <linux/io.h>
#include <linux/slab.h>
+#include <linux/of_device.h>
#include <linux/i2c/i2c-sh_mobile.h>
/* Transmit operation: */
@@ -611,6 +612,14 @@ static struct i2c_algorithm sh_mobile_i2c_algorithm = {
.master_xfer = sh_mobile_i2c_xfer,
};
+static const struct of_device_id sh_mobile_i2c_dt_ids[] = {
+ { .compatible = "renesas,rmobile-iic", .data = (void *)1 },
+ { .compatible = "renesas,iic-r8a7790", .data = (void *)2 },
+ { .compatible = "renesas,iic-r8a7791", .data = (void *)2 },
+ {},
+};
+MODULE_DEVICE_TABLE(of, sh_mobile_i2c_dt_ids);
+
static int sh_mobile_i2c_hook_irqs(struct platform_device *dev)
{
struct resource *res;
@@ -668,11 +677,18 @@ static int sh_mobile_i2c_probe(struct platform_device *dev)
ret = of_property_read_u32(dev->dev.of_node, "clock-frequency", &bus_speed);
pd->bus_speed = ret ? STANDARD_MODE : bus_speed;
- if (pdata && pdata->bus_speed)
- pd->bus_speed = pdata->bus_speed;
- pd->clks_per_count = 1;
- if (pdata && pdata->clks_per_count)
- pd->clks_per_count = pdata->clks_per_count;
+ if (dev->dev.of_node) {
+ const struct of_device_id *match;
+
+ match = of_match_device(sh_mobile_i2c_dt_ids, &dev->dev);
+ pd->clks_per_count = match->data;
+ } else {
+ if (pdata && pdata->bus_speed)
+ pd->bus_speed = pdata->bus_speed;
+ pd->clks_per_count = 1;
+ if (pdata && pdata->clks_per_count)
+ pd->clks_per_count = pdata->clks_per_count;
+ }
/* The IIC blocks on SH-Mobile ARM processors
* come with two new bits in ICIC.
@@ -750,12 +766,6 @@ static const struct dev_pm_ops sh_mobile_i2c_dev_pm_ops = {
.runtime_resume = sh_mobile_i2c_runtime_nop,
};
-static const struct of_device_id sh_mobile_i2c_dt_ids[] = {
- { .compatible = "renesas,rmobile-iic", },
- {},
-};
-MODULE_DEVICE_TABLE(of, sh_mobile_i2c_dt_ids);
-
static struct platform_driver sh_mobile_i2c_driver = {
.driver = {
.name = "i2c-sh_mobile",
--
1.9.2
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [RFC] i2c: sh_mobile: WIP! Fix clock calculation for newer SoCs
[not found] ` <1398945555-12928-1-git-send-email-wsa-z923LK4zBo2bacvFa/9K2g@public.gmane.org>
@ 2014-05-01 13:26 ` Geert Uytterhoeven
2014-05-01 16:50 ` Wolfram Sang
0 siblings, 1 reply; 3+ messages in thread
From: Geert Uytterhoeven @ 2014-05-01 13:26 UTC (permalink / raw)
To: Wolfram Sang; +Cc: Linux I2C, Linux-sh list, Magnus Damm, Wolfram Sang
Hi Wolfram,
On Thu, May 1, 2014 at 1:59 PM, Wolfram Sang <wsa-z923LK4zBo2bacvFa/9K2g@public.gmane.org> wrote:
> +static const struct of_device_id sh_mobile_i2c_dt_ids[] = {
> + { .compatible = "renesas,rmobile-iic", .data = (void *)1 },
> + { .compatible = "renesas,iic-r8a7790", .data = (void *)2 },
> + { .compatible = "renesas,iic-r8a7791", .data = (void *)2 },
> + {},
> +};
> +MODULE_DEVICE_TABLE(of, sh_mobile_i2c_dt_ids);
> + const struct of_device_id *match;
> +
> + match = of_match_device(sh_mobile_i2c_dt_ids, &dev->dev);
> + pd->clks_per_count = match->data;
Missing cast "(int)match->data"?
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert-Td1EMuHUCqxL1ZNQvxDV9g@public.gmane.org
In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [RFC] i2c: sh_mobile: WIP! Fix clock calculation for newer SoCs
2014-05-01 13:26 ` Geert Uytterhoeven
@ 2014-05-01 16:50 ` Wolfram Sang
0 siblings, 0 replies; 3+ messages in thread
From: Wolfram Sang @ 2014-05-01 16:50 UTC (permalink / raw)
To: Geert Uytterhoeven; +Cc: Linux I2C, Linux-sh list, Magnus Damm, Wolfram Sang
[-- Attachment #1: Type: text/plain, Size: 886 bytes --]
On Thu, May 01, 2014 at 03:26:15PM +0200, Geert Uytterhoeven wrote:
> Hi Wolfram,
>
> On Thu, May 1, 2014 at 1:59 PM, Wolfram Sang <wsa-z923LK4zBo2bacvFa/9K2g@public.gmane.org> wrote:
> > +static const struct of_device_id sh_mobile_i2c_dt_ids[] = {
> > + { .compatible = "renesas,rmobile-iic", .data = (void *)1 },
> > + { .compatible = "renesas,iic-r8a7790", .data = (void *)2 },
> > + { .compatible = "renesas,iic-r8a7791", .data = (void *)2 },
> > + {},
> > +};
> > +MODULE_DEVICE_TABLE(of, sh_mobile_i2c_dt_ids);
>
> > + const struct of_device_id *match;
> > +
> > + match = of_match_device(sh_mobile_i2c_dt_ids, &dev->dev);
> > + pd->clks_per_count = match->data;
>
> Missing cast "(int)match->data"?
"This patch still needs some improvements, but already shows what I am
aiming for." :)
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2014-05-01 16:50 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-05-01 11:59 [RFC] i2c: sh_mobile: WIP! Fix clock calculation for newer SoCs Wolfram Sang
[not found] ` <1398945555-12928-1-git-send-email-wsa-z923LK4zBo2bacvFa/9K2g@public.gmane.org>
2014-05-01 13:26 ` Geert Uytterhoeven
2014-05-01 16:50 ` Wolfram Sang
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).