[U-Boot] [PATCH] i2c: mux: Allow muxes to work as children of i2c bus without i2c-parent

Michal Simek michal.simek at xilinx.com
Tue Jan 3 10:22:27 CET 2017


On 2.1.2017 20:20, Moritz Fischer wrote:
> Hi Michal,
> 
> On Mon, Jan 2, 2017 at 6:24 AM, Michal Simek <michal.simek at xilinx.com> wrote:
>> On 29.12.2016 23:50, Moritz Fischer wrote:
>>> For mux check if the parent is already a device of UCLASS_I2C and if yes
>>> just use that. Otherwise see if someone specified an i2c-parent phandle.
>>> This mimics the behavior found in the Kernel, as it removes the
>>> requirement to explicitly specify a i2c-parent phandle.
>>>
>>> Signed-off-by: Moritz Fischer <moritz.fischer at ettus.com>
>>> Cc: Heiko Schocher <hs at denx.de>
>>> Cc: Bin Meng <bmeng.cn at gmail.com>
>>> Cc: Simon Glass <sjg at chromium.org>
>>> Cc: Michal Simek <michal.simek at xilinx.com>
>>> Cc: u-boot at lists.denx.de
>>> ---
>>>  drivers/i2c/muxes/i2c-mux-uclass.c | 9 +++++++++
>>>  1 file changed, 9 insertions(+)
>>>
>>> diff --git a/drivers/i2c/muxes/i2c-mux-uclass.c b/drivers/i2c/muxes/i2c-mux-uclass.c
>>> index 7a698b6..e01b773 100644
>>> --- a/drivers/i2c/muxes/i2c-mux-uclass.c
>>> +++ b/drivers/i2c/muxes/i2c-mux-uclass.c
>>> @@ -86,6 +86,15 @@ static int i2c_mux_post_probe(struct udevice *mux)
>>>       debug("%s: %s\n", __func__, mux->name);
>>>       priv->selected = -1;
>>>
>>> +     /* if parent is of i2c uclass already, we'll take that, otherwise
>>> +      * look if we find an i2c-parent phandle */
>>
>> Incorrect comment style.
> 
> Yeah, wasn't flagged by checkpatch .... will fix.
>>
>>> +     if (UCLASS_I2C == device_get_uclass_id(mux->parent)) {
>>> +             priv->i2c_bus = dev_get_parent(mux);
>>> +             debug("%s: bus=%p/%s\n", __func__, priv->i2c_bus,
>>> +                   priv->i2c_bus->name);
>>> +             return 0;
>>> +     }
>>> +
>>>       ret = uclass_get_device_by_phandle(UCLASS_I2C, mux, "i2c-parent",
>>>                                          &priv->i2c_bus);
>>>       if (ret)
>>>
>>
>> The part of this will be good to also handle
>> req_seq for mux busses. But at least this should solved part of the
>> problems.
> 
> I'm not sure I understand this comment.

AFAIK using i2c muxes requires two changes in DTS file.
First change is this to setup i2c-parent in DTS file which is something
what Linux doesn't need.
The next change is that you have to extend i2c aliases to point to i2c
mux sub busses which is the second thing what Linux doesn't need.
I expect that this change you have in your dts file.

I think that if you detect mux with 8 ports you can simply use unique
busid to be able to address them.

Thanks,
Michal



More information about the U-Boot mailing list