Message ID | 20181120120409.12822-2-marek.behun@nic.cz |
---|---|
State | Superseded |
Delegated to: | Stefan Roese |
Headers | show |
Series | [U-Boot,u-boot-marvell,v3,01/10] board: turris_mox: Cosmetic restructurization | expand |
On 20.11.18 13:04, Marek Behún wrote: > When SFP module is connected directly to CPU module we want the SGMII > lane speed at 1.25 Gbps. > > This is a temporary solution till there is a comphy driver in the kernel > capable of changing SGMII speed at runtime. > > Signed-off-by: Marek Behún <marek.behun@nic.cz> Reviewed-by: Stefan Roese <sr@denx.de> Thanks, Stefan > --- > board/CZ.NIC/turris_mox/turris_mox.c | 33 ++++++++++++++++++++++++++++ > 1 file changed, 33 insertions(+) > > diff --git a/board/CZ.NIC/turris_mox/turris_mox.c b/board/CZ.NIC/turris_mox/turris_mox.c > index 415c462493..3c0ab58756 100644 > --- a/board/CZ.NIC/turris_mox/turris_mox.c > +++ b/board/CZ.NIC/turris_mox/turris_mox.c > @@ -8,6 +8,7 @@ > #include <dm.h> > #include <clk.h> > #include <spi.h> > +#include <mvebu/comphy.h> > #include <linux/string.h> > #include <linux/libfdt.h> > #include <fdt_support.h> > @@ -206,6 +207,38 @@ static int mox_get_topology(const u8 **ptopology, int *psize, int *pis_sd) > return 0; > } > > +int comphy_update_map(struct comphy_map *serdes_map, int count) > +{ > + int ret, i, size, sfpindex = -1, swindex = -1; > + const u8 *topology; > + > + ret = mox_get_topology(&topology, &size, NULL); > + if (ret) > + return ret; > + > + for (i = 0; i < size; ++i) { > + if (topology[i] == MOX_MODULE_SFP && sfpindex == -1) > + sfpindex = i; > + else if ((topology[i] == MOX_MODULE_TOPAZ || > + topology[i] == MOX_MODULE_PERIDOT) && > + swindex == -1) > + swindex = i; > + } > + > + if (sfpindex >= 0 && swindex >= 0) { > + if (sfpindex < swindex) > + serdes_map[0].speed = PHY_SPEED_1_25G; > + else > + serdes_map[0].speed = PHY_SPEED_3_125G; > + } else if (sfpindex >= 0) { > + serdes_map[0].speed = PHY_SPEED_1_25G; > + } else if (swindex >= 0) { > + serdes_map[0].speed = PHY_SPEED_3_125G; > + } > + > + return 0; > +} > + > int last_stage_init(void) > { > int ret, i; > Viele Grüße, Stefan
diff --git a/board/CZ.NIC/turris_mox/turris_mox.c b/board/CZ.NIC/turris_mox/turris_mox.c index 415c462493..3c0ab58756 100644 --- a/board/CZ.NIC/turris_mox/turris_mox.c +++ b/board/CZ.NIC/turris_mox/turris_mox.c @@ -8,6 +8,7 @@ #include <dm.h> #include <clk.h> #include <spi.h> +#include <mvebu/comphy.h> #include <linux/string.h> #include <linux/libfdt.h> #include <fdt_support.h> @@ -206,6 +207,38 @@ static int mox_get_topology(const u8 **ptopology, int *psize, int *pis_sd) return 0; } +int comphy_update_map(struct comphy_map *serdes_map, int count) +{ + int ret, i, size, sfpindex = -1, swindex = -1; + const u8 *topology; + + ret = mox_get_topology(&topology, &size, NULL); + if (ret) + return ret; + + for (i = 0; i < size; ++i) { + if (topology[i] == MOX_MODULE_SFP && sfpindex == -1) + sfpindex = i; + else if ((topology[i] == MOX_MODULE_TOPAZ || + topology[i] == MOX_MODULE_PERIDOT) && + swindex == -1) + swindex = i; + } + + if (sfpindex >= 0 && swindex >= 0) { + if (sfpindex < swindex) + serdes_map[0].speed = PHY_SPEED_1_25G; + else + serdes_map[0].speed = PHY_SPEED_3_125G; + } else if (sfpindex >= 0) { + serdes_map[0].speed = PHY_SPEED_1_25G; + } else if (swindex >= 0) { + serdes_map[0].speed = PHY_SPEED_3_125G; + } + + return 0; +} + int last_stage_init(void) { int ret, i;
When SFP module is connected directly to CPU module we want the SGMII lane speed at 1.25 Gbps. This is a temporary solution till there is a comphy driver in the kernel capable of changing SGMII speed at runtime. Signed-off-by: Marek Behún <marek.behun@nic.cz> --- board/CZ.NIC/turris_mox/turris_mox.c | 33 ++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+)