From: Mugunthan V N <mugunthanvnm@ti.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH 03/14] drivers: i2c: uclass: parse dt parameters only when CONFIG_OF_CONTROL is enable
Date: Fri, 22 Jul 2016 13:05:50 +0530 [thread overview]
Message-ID: <8807f75e-6f8e-b47c-daa5-ddc795a54c21@ti.com> (raw)
In-Reply-To: <CAPnjgZ1Brk_GsrHSLnYwt59LT3tqYg2xfu9T=qejbu3se1QPNw@mail.gmail.com>
On Friday 22 July 2016 08:51 AM, Simon Glass wrote:
> Hi Mugunthan,
>
> On 18 July 2016 at 03:40, Mugunthan V N <mugunthanvnm@ti.com> wrote:
>> parse dt parameter of i2c devices only when CONFIG_OF_CONTROL
>> is enabled.
>>
>> Signed-off-by: Mugunthan V N <mugunthanvnm@ti.com>
>> ---
>> drivers/i2c/i2c-uclass.c | 14 ++++++++++++++
>> 1 file changed, 14 insertions(+)
>
> Reviewed-by: Simon Glass <sjg@chromium.org>
>
> Please see below.
>
>>
>> diff --git a/drivers/i2c/i2c-uclass.c b/drivers/i2c/i2c-uclass.c
>> index 50b99ea..20b30ff 100644
>> --- a/drivers/i2c/i2c-uclass.c
>> +++ b/drivers/i2c/i2c-uclass.c
>> @@ -467,6 +467,7 @@ int i2c_deblock(struct udevice *bus)
>> return ops->deblock(bus);
>> }
>>
>> +#if CONFIG_IS_ENABLED(OF_CONTROL)
>> int i2c_chip_ofdata_to_platdata(const void *blob, int node,
>> struct dm_i2c_chip *chip)
>> {
>> @@ -482,31 +483,44 @@ int i2c_chip_ofdata_to_platdata(const void *blob, int node,
>>
>> return 0;
>> }
>> +#endif
>>
>> static int i2c_post_probe(struct udevice *dev)
>> {
>> +#if CONFIG_IS_ENABLED(OF_CONTROL)
>> struct dm_i2c_bus *i2c = dev_get_uclass_priv(dev);
>>
>> i2c->speed_hz = fdtdec_get_int(gd->fdt_blob, dev->of_offset,
>> "clock-frequency", 100000);
>
> The above should be moved into i2c_chip_ofdata_to_platdata(), which
> will only be called if there is a device tree.
This cannot be moved to i2c_chip_ofdata_to_platdata() as it is called
from post_bind where uclass_priv will not be allocated. uclass_priv will
be allocated in device probe.
Regards
Mugunthan V N
>
>>
>> return dm_i2c_set_bus_speed(dev, i2c->speed_hz);
>
> I'm not sure about this one. In principle there should be a value
> i2c->speed_hz even if OF_CONTROL is not used. But I suppose it's OK to
> retain this #ifdef.
>
>> +#else
>> + return 0;
>> +#endif
>> }
>>
>> static int i2c_post_bind(struct udevice *dev)
>> {
>> +#if CONFIG_IS_ENABLED(OF_CONTROL)
>> /* Scan the bus for devices */
>> return dm_scan_fdt_node(dev, gd->fdt_blob, dev->of_offset, false);
>> +#else
>> + return 0;
>> +#endif
>> }
>>
>> static int i2c_child_post_bind(struct udevice *dev)
>> {
>> +#if CONFIG_IS_ENABLED(OF_CONTROL)
>> struct dm_i2c_chip *plat = dev_get_parent_platdata(dev);
>>
>> if (dev->of_offset == -1)
>> return 0;
>>
>> return i2c_chip_ofdata_to_platdata(gd->fdt_blob, dev->of_offset, plat);
>> +#else
>> + return 0;
>> +#endif
>> }
>>
>> UCLASS_DRIVER(i2c) = {
>> --
>> 2.9.1.200.gb1ec08f
>>
>
> Regards,
> Simon
>
next prev parent reply other threads:[~2016-07-22 7:35 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-07-18 9:40 [U-Boot] [PATCH 00/14] DM conversion of omap i2c driver Mugunthan V N
2016-07-18 9:40 ` [U-Boot] [PATCH 01/14] omap4: i2c: correct register offset for sync register Mugunthan V N
2016-07-18 14:27 ` Tom Rini
2016-07-18 9:40 ` [U-Boot] [PATCH 02/14] omap5/dra7: " Mugunthan V N
2016-07-18 14:27 ` Tom Rini
2016-07-18 9:40 ` [U-Boot] [PATCH 03/14] drivers: i2c: uclass: parse dt parameters only when CONFIG_OF_CONTROL is enable Mugunthan V N
2016-07-22 3:21 ` Simon Glass
2016-07-22 7:35 ` Mugunthan V N [this message]
2016-07-22 14:16 ` Simon Glass
2016-07-25 14:35 ` Mugunthan V N
2016-08-01 1:01 ` Simon Glass
2016-07-18 9:40 ` [U-Boot] [PATCH 04/14] ti_armv7_common: i2c: do not define DM_I2C for spl Mugunthan V N
2016-07-18 14:27 ` Tom Rini
2016-07-18 9:41 ` [U-Boot] [PATCH 05/14] drivers: i2c: omap24xx_i2c: prepare driver for DM conversion Mugunthan V N
2016-07-20 14:19 ` Simon Glass
2016-07-18 9:41 ` [U-Boot] [PATCH 06/14] drivers: i2c: omap24xx_i2c: adopt omap_i2c driver to driver model Mugunthan V N
2016-07-20 14:19 ` Simon Glass
2016-07-18 9:41 ` [U-Boot] [PATCH 07/14] defconfig: am335x_boneblack_vboot: enable i2c " Mugunthan V N
2016-07-18 14:27 ` Tom Rini
2016-07-18 9:41 ` [U-Boot] [PATCH 08/14] defconfig: am335x_evm: " Mugunthan V N
2016-07-18 14:27 ` Tom Rini
2016-07-18 9:41 ` [U-Boot] [PATCH 09/14] defconfig: am43xx_evm: " Mugunthan V N
2016-07-18 14:27 ` Tom Rini
2016-07-18 9:41 ` [U-Boot] [PATCH 10/14] defconfig: am43xx_hs_evm: " Mugunthan V N
2016-07-18 14:27 ` Tom Rini
2016-07-18 9:41 ` [U-Boot] [PATCH 11/14] defconfig: dra7xx_evm: " Mugunthan V N
2016-07-18 14:27 ` Tom Rini
2016-07-18 9:41 ` [U-Boot] [PATCH 12/14] defconfig: dra7xx_hs_evm: " Mugunthan V N
2016-07-18 14:28 ` Tom Rini
2016-07-18 9:41 ` [U-Boot] [PATCH 13/14] defconfig: am57xx_evm: " Mugunthan V N
2016-07-18 14:28 ` Tom Rini
2016-07-18 9:41 ` [U-Boot] [PATCH 14/14] defconfig: am57xx_hs_evm: " Mugunthan V N
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=8807f75e-6f8e-b47c-daa5-ddc795a54c21@ti.com \
--to=mugunthanvnm@ti.com \
--cc=u-boot@lists.denx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox