Re: [PATCH v5 5/7] ARM: davinci: i2c: add OF support
From: Sekhar Nori <hidden>
Date: 2012-07-16 16:16:17
Also in:
linux-arm-kernel, linux-i2c
On 7/14/2012 9:45 AM, Heiko Schocher wrote:
Hello Sekhar, On 13.07.2012 15:57, Sekhar Nori wrote:quoted
Hi Heiko, On 5/30/2012 3:49 PM, Heiko Schocher wrote:quoted
add of support for the davinci i2c driver. Signed-off-by: Heiko Schocher<redacted> Cc: davinci-linux-open-source-VycZQUHpC/PFrsHnngEfi1aTQe2KTcn/@public.gmane.org Cc: linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org Cc: devicetree-discuss-uLR06cmDAlY/bJ5BZ2RsiQ@public.gmane.org Cc: linux-i2c-u79uwXL29TY76Z2rM5mHXA@public.gmane.org Cc: Ben Dooks<redacted> Cc: Wolfram Sang<redacted> Cc: Grant Likely<grant.likely-s3s/WqlpOiPyB63q8FvJNQ@public.gmane.org> Cc: Sekhar Nori<redacted> Cc: Wolfgang Denk<redacted> Cc: Sylwester Nawrocki<redacted>[...]
[...]
quoted
quoted
diff --git a/drivers/i2c/busses/i2c-davinci.cb/drivers/i2c/busses/i2c-davinci.c index a76d85f..4e7a966 100644--- a/drivers/i2c/busses/i2c-davinci.c +++ b/drivers/i2c/busses/i2c-davinci.c
[...]
quoted
quoted
static int davinci_i2c_probe(struct platform_device *pdev) { struct davinci_i2c_dev *dev;@@ -676,6 +695,25 @@ static int davinci_i2c_probe(structplatform_device *pdev) dev->irq = irq->start; platform_set_drvdata(pdev, dev); + if ((dev->dev->platform_data == NULL)&& + (pdev->dev.of_node)) { + u32 prop; + + dev->pdata = devm_kzalloc(&pdev->dev, + sizeof(struct davinci_i2c_platform_data), GFP_KERNEL); + if (!dev->pdata) { + r = -ENOMEM; + goto err_free_mem; + } + memcpy(dev->pdata,&davinci_i2c_platform_data_default, + sizeof(struct davinci_i2c_platform_data)); + if (!of_property_read_u32(pdev->dev.of_node, "clock-frequency", + &prop)) + dev->pdata->bus_freq = prop / 1000; + if (!of_property_read_u32(pdev->dev.of_node, "bus-delay", + &prop)) + dev->pdata->bus_delay = prop;You are leaving out two other platform data members (the gpio pins corresponding to data and clock) from DT data. We should be able to get that information from DT too, right?Yes, but I had not ported the GPIO driver to OF ...
Okay. Understood. They can added once GPIO has been ported too and this part is tested.
quoted
So, I took this patch and tried to see if pdata maintenance can be simplified and came with the diff below. Can you have a look and see if this makes sense? I tested this using i2cdetect both with and without DT.Tested your patch on the enbw_cmc board with a LM75 on the enbw_cmc board, works fine. Can I post a "v6" of my patch, merged with your patch below and your Signed-off?
Yes, please do. You can post it as in independent patch (not as part of a series) since the patch does not have any dependencies. Thanks, Sekhar