Re: [PATCH 07/10] dt-bindings: phy: add DT binding for Microsemi Ocelot SerDes muxing

From: Alexandre Belloni
Date: Tue Aug 14 2018 - 09:28:37 EST


On 13/08/2018 16:37:48-0600, Rob Herring wrote:
> > I'm fine with a define for the second value (which is basically the enum
> > serdes_type I've defined at the beginning of the serdes driver) but I
> > don't see the point of defining the index of the SerDes. What would it
> > look like?
> >
> > enum serdes_type {
> > SERDES1G = 1,
> > SERDES6G = 6,
> > }
> >
> > #define SERDES1G_0 0
> > #define SERDES1G_1 1
> > #define SERDES1G_2 2
> > #define SERDES6G_0 0
> > #define SERDES6G_1 1
> >
> > Then, e.g.:
> >
> > &port5 {
> > phys = <&serdes 5 SERDES1G SERDES1G_0>
> > };
> >
> > If you want a define for the pair (serdes_type, serdes_index), I don't
> > see how I could re-use it on the driver side but it makes more sense on the
> > DeviceTree side:
> >
> > #define SERDES1G_0 1 0
> > #define SERDES1G_1 1 1
> > #define SERDES1G_2 1 2
> > #define SERDES6G_0 6 0
> > #define SERDES6G_1 6 1
>
> I prefer #defines which are a single number. Otherwise if you read a dts
> file when #phy-cells is 3, it will look like an error in that you have
> what looks like 2 cells.
>

Maybe we should not have the type in DT and simply have an index. The
driver will now what the serdes type is anyway and the defines would be:

#define SERDES1G_0 0
#define SERDES1G_1 1
#define SERDES1G_2 2
#define SERDES6G_0 3
#define SERDES6G_1 4

The main drawback is that this requires one include file per soc.

--
Alexandre Belloni, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com