Re: [PATCH v2 2/7] dt-bindings: i3c: svc: add compatible string i3c: silvaco,i3c-target-v1

From: Frank Li
Date: Wed Jan 17 2024 - 11:20:04 EST


On Wed, Jan 17, 2024 at 07:50:16AM +0100, Krzysztof Kozlowski wrote:
> On 16/01/2024 23:25, Frank Li wrote:
> > On Tue, Jan 16, 2024 at 10:01:42PM +0100, Krzysztof Kozlowski wrote:
> >> On 16/01/2024 21:56, Krzysztof Kozlowski wrote:
> >>> On 16/01/2024 21:44, Frank Li wrote:
> >>>> On Tue, Jan 16, 2024 at 09:30:24PM +0100, Krzysztof Kozlowski wrote:
> >>>>> On 16/01/2024 20:13, Frank Li wrote:
> >>>>>> On Tue, Jan 16, 2024 at 06:23:09PM +0000, Conor Dooley wrote:
> >>>>>>> On Tue, Jan 16, 2024 at 12:35:44PM -0500, Frank Li wrote:
> >>>>>>>> On Tue, Jan 16, 2024 at 09:48:08AM +0000, Conor Dooley wrote:
> >>>>>>>>> On Tue, Jan 16, 2024 at 10:33:48AM +0100, Krzysztof Kozlowski wrote:
> >>>>>>>>>> On 16/01/2024 10:30, Conor Dooley wrote:
> >>>>>>>>>>> On Tue, Jan 16, 2024 at 08:24:20AM +0100, Krzysztof Kozlowski wrote:
> >>>>>>>>>>>> On 16/01/2024 03:29, Frank Li wrote:
> >>>>>>>>>>>>>>> Patches were accepted after discussion, what you ponit to. So I
> >>>>>>>>>>>>>>> think everyone agree on the name 'silvaco,i3c-master-v1'.
> >>>>>>>>>>>>>>> I plan send next version to fix auto build error. Any additional
> >>>>>>>>>>>>>>> comments about this?
> >>>>>>>>>>>>>>
> >>>>>>>>>>>>>> I still do not see how did you address Rob's comment and his point is
> >>>>>>>>>>>>>> valid. You just did not reply to it.
> >>>>>>>>>>>>>
> >>>>>>>>>>>>> See https://lore.kernel.org/imx/ZXCiaKfMYYShoiXK@lizhi-Precision-Tower-5810/
> >>>>>>>>>>>>
> >>>>>>>>>>>> First of all, that's not the answer to Rob's email, but some other
> >>>>>>>>>>>> thread which is 99% ignored by Rob (unless he has filters for
> >>>>>>>>>>>> "@Rob"...). Therefore no, it does not count as valid answer.
> >>>>>>>>>>>>
> >>>>>>>>>>>> Second, explanation does not make sense. There is no argument granting
> >>>>>>>>>>>> you exception from SoC specific compatibles.
> >>>>>>>>>>>
> >>>>>>>>>>> The patch could have been applied two months ago had Frank done as
> >>>>>>>>>>> was requested (multiple times). I don't understand the resistance
> >>>>>>>>>>> towards doing so given the process has taken way way longer as a result.
> >>>>>>>>>>
> >>>>>>>>>> I think that Rob's comment was just skipped and original master binding
> >>>>>>>>>> was merged without addressing it. I don't want to repeat the same
> >>>>>>>>>> process for the "target". Indeed I could point this earlier... if I only
> >>>>>>>>>> knew that Rob pointed out that issue.
> >>>>>>>>>
> >>>>>>>>> Oh I think I got confused here. The context for this mail led me to
> >>>>>>>>> think that this was still trying to push the i3c-master-v1 stuff through
> >>>>>>>>> and I was commenting on my frustration with the resistance to applying
> >>>>>>>>> the feedback received. I didn't realise that this was for another
> >>>>>>>>> patch adding a target.
> >>>>>>>>>
> >>>>>>>>> I think you already said it, but NAK to adding any more compatibles here
> >>>>>>>>> until the soc-specific compatible that was asked for for the imx93 is
> >>>>>>>>> added.
> >>>>>>>>
> >>>>>>>> Is it okay for 'silvaco,i3c-target-imx93'?
> >>>>>
> >>>>> No, because imx93 is product of NXP, not Silvaco.
> >>>>>
> >>>>> You need regular SoC-block compatibles, just like we have for all other
> >>>>> snps, dwc and cdns.
> >>>>
> >>>> "nxp,imx93-svc-i3c-target" ?
> >>>
> >>> Could be, now please point me to patch adding such code to DTS. I would
> >>> like to see the real use case for it.
> >>
> >> Probably I was not clear enough, so let's be more precise: I think you
> >> might have troubles pointing to such code, because it just does not
> >> exist. It is a bit contradicting to single hardware description, because
> >> you want to describe one hardware in two different ways, with two
> >> different compatibles.
> >>
> >> Your commit msg is here empty - it says what patch is does, which is
> >> obvious. Tells nothing about the hardware being described here, which
> >> does not help this discussion. This would need solving as well, but main
> >> point stays - don't add new compatibles for the same hardware, at least
> >> not without valid reason/explanation.
> >
> > I can improve commt msg. It was similar PCI case (There are two work mode:
> > root complex and endpoint). So there are two kind compatible string for it.
> >
> > If you think it is good for using two compatible string for two work mode
> > of the same hardware.
>
> Not really, because compatible describes hardware and it is the same
> hardware here. We do not have two different compatibles for GPIOs being
> input or output. Or two different compatibles for serial engines (ones
> providing UART, SPI or I2C).

GPIO and UART is simple. Actuall SPI and I2C have two mode, slave and
master. Many SPI/I2C is dual mode controller. Just seldom use slave mode
at linux side. So you just see master mode SPI/I2C controller in dt-binding
and dts file. So few people upstream slave part to linux kernel community.
They have the exact same problems if support slave mode.

PCI is typical example:
EP mode: Documentation/devicetree/bindings/pci/qcom,pcie-ep.yaml
RC mode: Documentation/devicetree/bindings/pci/qcom,pcie.yaml

Which is the same hardware for two difference compatible string.
>
> >
> > I can write git commit message like:
> >
> > dt-bindings: i3c: svc: add compatible string nxp,imx93-svc-i3c-target
> >
> > silvaco i3c controller is dual mode controller, which can work as master
> > and target mode. All clock, reg, irq are the same for both mode. Add
> > compatible string "nxp,imx93-svc-i3c-target" to let silivaco i3c
> > controller work as target mode.
> >
> > Of course, alternate method to added a property "mode" to distingiush
> > master and target mode. but old "silvaco,i3c-master-v1" will actually work
> > as dual mode support. Driver structure will become complex.
>
> Please send full DTS of user for this, which works for 100%, so we can
> see how it differs from controller mode. If your code snippet from other
> thread is correct, then it would suggest "mode" property or lack of
> children. Maybe lack of children is not enough, if user-space could
> control I3C bus.

According to current implment, only need change imx93.dtsi's @i3c1's
compatible string to "silvaco,i3c-target-v1". I attached imx93 dts node for
your reference.

i3c1: i3c-master@44330000 {
compatible = "silvaco,i3c-master-v1";
^^^^ only need change here!

reg = <0x44330000 0x10000>;
interrupts = <GIC_SPI 12 IRQ_TYPE_LEVEL_HIGH>;
#address-cells = <3>;
#size-cells = <0>;
clocks = <&clk IMX93_CLK_BUS_AON>,
<&clk IMX93_CLK_I3C1_GATE>,
<&clk IMX93_CLK_I3C1_SLOW>;
clock-names = "pclk", "fast_clk", "slow_clk";
dmas = <&edma1 6 0 1>, <&edma1 5 0 0>;
dma-names = "rx", "tx";
status = "disabled";
};

For master mode:
Unlike i2c. Genenally I3C can auto probe children node like USB can auto
detect attached devices. So I3C master can work without children nodes.
Such as auto load i3c sensor driver according to i3c standard vendor id and
production id.

For target mode: using configfs to controller I3C.

mkdir /sys/kernel/config/i3c_target/functions/tty/t
echo 0x011b > /sys/kernel/config/i3c_target/functions/tty/t/vendor_id
echo 0x1000 > /sys/kernel/config/i3c_target/functions/tty/t/part_id
echo 0x6 > /sys/kernel/config/i3c_target/functions/tty/t/bcr

ln -s /sys/kernel/config/i3c_target/functions/tty/t /sys/kernel/config/i3c_target/controllers/44330000.i3c-master/

Then you echo test >/dev/ttySI3C0.

Unlike USB, user can switch host and gadget mode dymatically. Suppose I3C
only work on one of master or slave mode only, which is static.

Although it is one hardware, I think it is exculsive multi function device.

Summary: basice two option to distingiush controller and target mode.
1. by "compatible" string
2. by "mode"

I think 1 is relatively simple and easy to understand.

>
> Best regards,
> Krzysztof
>