[U-Boot] [PATCH v4 11/11] dm: i2c: tegra: Convert to driver model
Simon Glass
sjg at chromium.org
Fri Dec 5 15:50:33 CET 2014
Hi Masahiro,
On 5 December 2014 at 06:15, Masahiro Yamada <yamada.m at jp.panasonic.com> wrote:
> Hi Simon,
>
>
>
> On Thu, 4 Dec 2014 21:21:30 -0700
> Simon Glass <sjg at chromium.org> wrote:
>
>> +static const struct dm_i2c_ops tegra_i2c_ops = {
>> + .xfer = tegra_i2c_xfer,
>> + .probe_chip = tegra_i2c_probe_chip,
>> + .set_bus_speed = tegra_i2c_set_bus_speed,
>> +};
>>
>> - for (i = 0; i < TEGRA_I2C_NUM_CONTROLLERS; i++) {
>> - struct i2c_bus *bus = &i2c_controllers[i];
>> +static int tegra_i2c_child_pre_probe(struct udevice *dev)
>> +{
>> + struct dm_i2c_chip *i2c_chip = dev_get_parentdata(dev);
>>
>> - if (bus->inited && bus->is_dvc)
>> - return i;
>> - }
>> + if (dev->of_offset == -1)
>> + return 0;
>> + return i2c_chip_ofdata_to_platdata(gd->fdt_blob, dev->of_offset,
>> + i2c_chip);
>> +}
>
>
> As I said in v3, it is unfortunate that uclass does not support .child_pre_probe.
>
>
> sandbox_i2c.c and tegra-i2c.c have a similar .child_pre_probe.
> I copied tegra_i2c_child_pre_probe() to my i2c driver verbatim.
>
> I guess every driver will do so.
>
>
> Is it a good idea to move .child_pre_probe to uclass_driver?
Sorry I didn't reply on this.
I have been thinking about this for a while. For SPI we have the same
problem and I think I mentioned it in the code somewhere. For the PCI
RFC I have already adjusted the platdata lifecycle a little since I
think it will simplify all buses, and have added a another data
pointer for a different purpose.
For the case you raise the problem as you say is that each driver is
required to provide a certain structure for its children so that its
uclass is happy. On the other hand the driver may want to add
additional information We already have a lot of flexibility so I was
waiting to see how much this would really matter (there is after all a
complexity trade-off).
With PCI I've made some changes and I think I'll end up adding another
pointer. At that point I will also want to change SPI and I2C.
For now, I'd like to leave this alone. It does work and avoids adding
new features at this late stage.
Let's revisit when I come back to PCI.
Regards,
Simon
More information about the U-Boot
mailing list