Commit 9433cd1109ae61b2676ed4832ae75da79ec9083d

Authored by Marek Behún
Committed by Stefan Roese
1 parent 296c64ea41

arm: mvebu: turris_mox: Change SERDES map depending on module topology

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>
Signed-off-by: Stefan Roese <sr@denx.de>

Showing 1 changed file with 33 additions and 0 deletions Side-by-side Diff

board/CZ.NIC/turris_mox/turris_mox.c
... ... @@ -8,6 +8,7 @@
8 8 #include <dm.h>
9 9 #include <clk.h>
10 10 #include <spi.h>
  11 +#include <mvebu/comphy.h>
11 12 #include <linux/string.h>
12 13 #include <linux/libfdt.h>
13 14 #include <fdt_support.h>
... ... @@ -202,6 +203,38 @@
202 203 *psize = size;
203 204 if (pis_sd)
204 205 *pis_sd = is_sd;
  206 +
  207 + return 0;
  208 +}
  209 +
  210 +int comphy_update_map(struct comphy_map *serdes_map, int count)
  211 +{
  212 + int ret, i, size, sfpindex = -1, swindex = -1;
  213 + const u8 *topology;
  214 +
  215 + ret = mox_get_topology(&topology, &size, NULL);
  216 + if (ret)
  217 + return ret;
  218 +
  219 + for (i = 0; i < size; ++i) {
  220 + if (topology[i] == MOX_MODULE_SFP && sfpindex == -1)
  221 + sfpindex = i;
  222 + else if ((topology[i] == MOX_MODULE_TOPAZ ||
  223 + topology[i] == MOX_MODULE_PERIDOT) &&
  224 + swindex == -1)
  225 + swindex = i;
  226 + }
  227 +
  228 + if (sfpindex >= 0 && swindex >= 0) {
  229 + if (sfpindex < swindex)
  230 + serdes_map[0].speed = PHY_SPEED_1_25G;
  231 + else
  232 + serdes_map[0].speed = PHY_SPEED_3_125G;
  233 + } else if (sfpindex >= 0) {
  234 + serdes_map[0].speed = PHY_SPEED_1_25G;
  235 + } else if (swindex >= 0) {
  236 + serdes_map[0].speed = PHY_SPEED_3_125G;
  237 + }
205 238  
206 239 return 0;
207 240 }