* [PATCH 0/2] arm: mvebu: Remove comphy_update_map()
@ 2022-01-18 9:33 Pali Rohár
2022-01-18 9:33 ` [PATCH 1/2] arm: mvebu: turris_mox: Convert comphy_update_map() to board_fix_fdt() Pali Rohár
` (2 more replies)
0 siblings, 3 replies; 6+ messages in thread
From: Pali Rohár @ 2022-01-18 9:33 UTC (permalink / raw)
To: Stefan Roese, Marek Behún; +Cc: u-boot
Convert Turris MOX's comphy_update_map() to board_fix_fdt() and then
remove it.
Pali Rohár (2):
arm: mvebu: turris_mox: Convert comphy_update_map() to board_fix_fdt()
phy: marvell: Remove unused function comphy_update_map()
board/CZ.NIC/turris_mox/turris_mox.c | 48 +++++++++-------------------
drivers/phy/marvell/comphy_core.c | 9 ------
drivers/phy/marvell/comphy_core.h | 9 ++++++
include/mvebu/comphy.h | 11 -------
4 files changed, 24 insertions(+), 53 deletions(-)
--
2.20.1
^ permalink raw reply [flat|nested] 6+ messages in thread* [PATCH 1/2] arm: mvebu: turris_mox: Convert comphy_update_map() to board_fix_fdt() 2022-01-18 9:33 [PATCH 0/2] arm: mvebu: Remove comphy_update_map() Pali Rohár @ 2022-01-18 9:33 ` Pali Rohár 2022-01-18 11:17 ` Stefan Roese 2022-01-18 9:33 ` [PATCH 2/2] phy: marvell: Remove unused function comphy_update_map() Pali Rohár 2022-01-20 16:22 ` [PATCH 0/2] arm: mvebu: Remove comphy_update_map() Stefan Roese 2 siblings, 1 reply; 6+ messages in thread From: Pali Rohár @ 2022-01-18 9:33 UTC (permalink / raw) To: Stefan Roese, Marek Behún; +Cc: u-boot Code in board_fix_fdt() already detects connected MOX modules so there is no need to have custom comphy_update_map() function for setting serdes speeds. This change sets phy-mode for MOX SFP module (when present) to sgmii. Comphy driver then sets sgmii serdes speed for this module to 1.25G. Signed-off-by: Pali Rohár <pali@kernel.org> --- board/CZ.NIC/turris_mox/turris_mox.c | 48 +++++++++------------------- 1 file changed, 15 insertions(+), 33 deletions(-) diff --git a/board/CZ.NIC/turris_mox/turris_mox.c b/board/CZ.NIC/turris_mox/turris_mox.c index 3eb5cb425606..f0c5aa6a520b 100644 --- a/board/CZ.NIC/turris_mox/turris_mox.c +++ b/board/CZ.NIC/turris_mox/turris_mox.c @@ -21,7 +21,6 @@ #include <linux/libfdt.h> #include <linux/string.h> #include <miiphy.h> -#include <mvebu/comphy.h> #include <spi.h> #include "mox_sp.h" @@ -49,6 +48,7 @@ int board_fix_fdt(void *blob) enum fdt_status status_pcie, status_eth1; u8 topology[MAX_MOX_MODULES]; int i, size, ret; + bool eth1_sgmii; /* * SPI driver is not loaded in driver model yet, but we have to find out @@ -69,6 +69,7 @@ int board_fix_fdt(void *blob) status_pcie = FDT_STATUS_DISABLED; status_eth1 = FDT_STATUS_DISABLED; + eth1_sgmii = false; for (i = 0; i < MAX_MOX_MODULES; ++i) { writel(0x0, ARMADA_37XX_SPI_DOUT); @@ -82,6 +83,10 @@ int board_fix_fdt(void *blob) topology[i] &= 0xf; + if (topology[i] == MOX_MODULE_SFP && + status_pcie == FDT_STATUS_DISABLED) + eth1_sgmii = true; + if (topology[i] == MOX_MODULE_SFP || topology[i] == MOX_MODULE_TOPAZ || topology[i] == MOX_MODULE_PERIDOT) @@ -98,6 +103,15 @@ int board_fix_fdt(void *blob) printf("Cannot set status for eth1 in U-Boot's device tree: %s!\n", fdt_strerror(ret)); + if (eth1_sgmii) { + ret = fdt_path_offset(blob, "ethernet1"); + if (ret >= 0) + ret = fdt_setprop_string(blob, ret, "phy-mode", "sgmii"); + if (ret < 0) + printf("Cannot set phy-mode for eth1 to sgmii in U-Boot device tree: %s!\n", + fdt_strerror(ret)); + } + if (size > 1 && (topology[1] == MOX_MODULE_PCI || topology[1] == MOX_MODULE_USB3 || topology[1] == MOX_MODULE_PASSPCI)) @@ -199,38 +213,6 @@ 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 = COMPHY_SPEED_1_25G; - else - serdes_map[0].speed = COMPHY_SPEED_3_125G; - } else if (sfpindex >= 0) { - serdes_map[0].speed = COMPHY_SPEED_1_25G; - } else if (swindex >= 0) { - serdes_map[0].speed = COMPHY_SPEED_3_125G; - } - - return 0; -} - #define SW_SMI_CMD_R(d, r) (0x9800 | (((d) & 0x1f) << 5) | ((r) & 0x1f)) #define SW_SMI_CMD_W(d, r) (0x9400 | (((d) & 0x1f) << 5) | ((r) & 0x1f)) -- 2.20.1 ^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH 1/2] arm: mvebu: turris_mox: Convert comphy_update_map() to board_fix_fdt() 2022-01-18 9:33 ` [PATCH 1/2] arm: mvebu: turris_mox: Convert comphy_update_map() to board_fix_fdt() Pali Rohár @ 2022-01-18 11:17 ` Stefan Roese 0 siblings, 0 replies; 6+ messages in thread From: Stefan Roese @ 2022-01-18 11:17 UTC (permalink / raw) To: Pali Rohár, Marek Behún; +Cc: u-boot On 1/18/22 10:33, Pali Rohár wrote: > Code in board_fix_fdt() already detects connected MOX modules so there is > no need to have custom comphy_update_map() function for setting serdes > speeds. > > This change sets phy-mode for MOX SFP module (when present) to sgmii. > Comphy driver then sets sgmii serdes speed for this module to 1.25G. > > Signed-off-by: Pali Rohár <pali@kernel.org> Reviewed-by: Stefan Roese <sr@denx.de> Thanks, Stefan > --- > board/CZ.NIC/turris_mox/turris_mox.c | 48 +++++++++------------------- > 1 file changed, 15 insertions(+), 33 deletions(-) > > diff --git a/board/CZ.NIC/turris_mox/turris_mox.c b/board/CZ.NIC/turris_mox/turris_mox.c > index 3eb5cb425606..f0c5aa6a520b 100644 > --- a/board/CZ.NIC/turris_mox/turris_mox.c > +++ b/board/CZ.NIC/turris_mox/turris_mox.c > @@ -21,7 +21,6 @@ > #include <linux/libfdt.h> > #include <linux/string.h> > #include <miiphy.h> > -#include <mvebu/comphy.h> > #include <spi.h> > > #include "mox_sp.h" > @@ -49,6 +48,7 @@ int board_fix_fdt(void *blob) > enum fdt_status status_pcie, status_eth1; > u8 topology[MAX_MOX_MODULES]; > int i, size, ret; > + bool eth1_sgmii; > > /* > * SPI driver is not loaded in driver model yet, but we have to find out > @@ -69,6 +69,7 @@ int board_fix_fdt(void *blob) > > status_pcie = FDT_STATUS_DISABLED; > status_eth1 = FDT_STATUS_DISABLED; > + eth1_sgmii = false; > > for (i = 0; i < MAX_MOX_MODULES; ++i) { > writel(0x0, ARMADA_37XX_SPI_DOUT); > @@ -82,6 +83,10 @@ int board_fix_fdt(void *blob) > > topology[i] &= 0xf; > > + if (topology[i] == MOX_MODULE_SFP && > + status_pcie == FDT_STATUS_DISABLED) > + eth1_sgmii = true; > + > if (topology[i] == MOX_MODULE_SFP || > topology[i] == MOX_MODULE_TOPAZ || > topology[i] == MOX_MODULE_PERIDOT) > @@ -98,6 +103,15 @@ int board_fix_fdt(void *blob) > printf("Cannot set status for eth1 in U-Boot's device tree: %s!\n", > fdt_strerror(ret)); > > + if (eth1_sgmii) { > + ret = fdt_path_offset(blob, "ethernet1"); > + if (ret >= 0) > + ret = fdt_setprop_string(blob, ret, "phy-mode", "sgmii"); > + if (ret < 0) > + printf("Cannot set phy-mode for eth1 to sgmii in U-Boot device tree: %s!\n", > + fdt_strerror(ret)); > + } > + > if (size > 1 && (topology[1] == MOX_MODULE_PCI || > topology[1] == MOX_MODULE_USB3 || > topology[1] == MOX_MODULE_PASSPCI)) > @@ -199,38 +213,6 @@ 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 = COMPHY_SPEED_1_25G; > - else > - serdes_map[0].speed = COMPHY_SPEED_3_125G; > - } else if (sfpindex >= 0) { > - serdes_map[0].speed = COMPHY_SPEED_1_25G; > - } else if (swindex >= 0) { > - serdes_map[0].speed = COMPHY_SPEED_3_125G; > - } > - > - return 0; > -} > - > #define SW_SMI_CMD_R(d, r) (0x9800 | (((d) & 0x1f) << 5) | ((r) & 0x1f)) > #define SW_SMI_CMD_W(d, r) (0x9400 | (((d) & 0x1f) << 5) | ((r) & 0x1f)) > > Viele Grüße, Stefan Roese -- DENX Software Engineering GmbH, Managing Director: Wolfgang Denk HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-51 Fax: (+49)-8142-66989-80 Email: sr@denx.de ^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH 2/2] phy: marvell: Remove unused function comphy_update_map() 2022-01-18 9:33 [PATCH 0/2] arm: mvebu: Remove comphy_update_map() Pali Rohár 2022-01-18 9:33 ` [PATCH 1/2] arm: mvebu: turris_mox: Convert comphy_update_map() to board_fix_fdt() Pali Rohár @ 2022-01-18 9:33 ` Pali Rohár 2022-01-18 11:18 ` Stefan Roese 2022-01-20 16:22 ` [PATCH 0/2] arm: mvebu: Remove comphy_update_map() Stefan Roese 2 siblings, 1 reply; 6+ messages in thread From: Pali Rohár @ 2022-01-18 9:33 UTC (permalink / raw) To: Stefan Roese, Marek Behún; +Cc: u-boot This weak function is not used anymore, so completely remove it. Private struct comphy_map is not used by any board code anymore, so move it into private driver header file comphy_core.h. Signed-off-by: Pali Rohár <pali@kernel.org> --- drivers/phy/marvell/comphy_core.c | 9 --------- drivers/phy/marvell/comphy_core.h | 9 +++++++++ include/mvebu/comphy.h | 11 ----------- 3 files changed, 9 insertions(+), 20 deletions(-) diff --git a/drivers/phy/marvell/comphy_core.c b/drivers/phy/marvell/comphy_core.c index 233a973035b3..5bb994fe42a5 100644 --- a/drivers/phy/marvell/comphy_core.c +++ b/drivers/phy/marvell/comphy_core.c @@ -79,11 +79,6 @@ int comphy_rx_training(struct udevice *dev, u32 lane) return 0; } -__weak int comphy_update_map(struct comphy_map *serdes_map, int count) -{ - return 0; -} - static int comphy_probe(struct udevice *dev) { int node = dev_of_offset(dev); @@ -126,10 +121,6 @@ static int comphy_probe(struct udevice *dev) if (res < 0) return res; - res = comphy_update_map(chip_cfg->comphy_map_data, chip_cfg->comphy_lanes_count); - if (res < 0) - return res; - /* Save CP index for MultiCP devices (A8K) */ chip_cfg->cp_index = current_idx++; /* PHY power UP sequence */ diff --git a/drivers/phy/marvell/comphy_core.h b/drivers/phy/marvell/comphy_core.h index d573776c05ae..f3d049393876 100644 --- a/drivers/phy/marvell/comphy_core.h +++ b/drivers/phy/marvell/comphy_core.h @@ -8,6 +8,7 @@ #include <fdtdec.h> #include <mvebu/comphy.h> +#include <dt-bindings/comphy/comphy_data.h> #if defined(DEBUG) #define debug_enter() printf("----> Enter %s\n", __func__); @@ -20,6 +21,14 @@ #define MAX_LANE_OPTIONS 10 #define MAX_UTMI_PHY_COUNT 6 +struct comphy_map { + u32 type; + u32 speed; + u32 invert; + bool clk_src; + bool end_point; +}; + struct comphy_mux_options { u32 type; u32 mux_value; diff --git a/include/mvebu/comphy.h b/include/mvebu/comphy.h index 4d1b70393b20..14431576e66e 100644 --- a/include/mvebu/comphy.h +++ b/include/mvebu/comphy.h @@ -6,17 +6,6 @@ #ifndef _MVEBU_COMPHY_H_ #define _MVEBU_COMPHY_H_ -#include <dt-bindings/comphy/comphy_data.h> - -struct comphy_map { - u32 type; - u32 speed; - u32 invert; - bool clk_src; - bool end_point; -}; - int comphy_rx_training(struct udevice *dev, u32 lane); -int comphy_update_map(struct comphy_map *serdes_map, int count); #endif /* _MVEBU_COMPHY_H_ */ -- 2.20.1 ^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH 2/2] phy: marvell: Remove unused function comphy_update_map() 2022-01-18 9:33 ` [PATCH 2/2] phy: marvell: Remove unused function comphy_update_map() Pali Rohár @ 2022-01-18 11:18 ` Stefan Roese 0 siblings, 0 replies; 6+ messages in thread From: Stefan Roese @ 2022-01-18 11:18 UTC (permalink / raw) To: Pali Rohár, Marek Behún; +Cc: u-boot On 1/18/22 10:33, Pali Rohár wrote: > This weak function is not used anymore, so completely remove it. > > Private struct comphy_map is not used by any board code anymore, so move it > into private driver header file comphy_core.h. > > Signed-off-by: Pali Rohár <pali@kernel.org> Reviewed-by: Stefan Roese <sr@denx.de> Thanks, Stefan > --- > drivers/phy/marvell/comphy_core.c | 9 --------- > drivers/phy/marvell/comphy_core.h | 9 +++++++++ > include/mvebu/comphy.h | 11 ----------- > 3 files changed, 9 insertions(+), 20 deletions(-) > > diff --git a/drivers/phy/marvell/comphy_core.c b/drivers/phy/marvell/comphy_core.c > index 233a973035b3..5bb994fe42a5 100644 > --- a/drivers/phy/marvell/comphy_core.c > +++ b/drivers/phy/marvell/comphy_core.c > @@ -79,11 +79,6 @@ int comphy_rx_training(struct udevice *dev, u32 lane) > return 0; > } > > -__weak int comphy_update_map(struct comphy_map *serdes_map, int count) > -{ > - return 0; > -} > - > static int comphy_probe(struct udevice *dev) > { > int node = dev_of_offset(dev); > @@ -126,10 +121,6 @@ static int comphy_probe(struct udevice *dev) > if (res < 0) > return res; > > - res = comphy_update_map(chip_cfg->comphy_map_data, chip_cfg->comphy_lanes_count); > - if (res < 0) > - return res; > - > /* Save CP index for MultiCP devices (A8K) */ > chip_cfg->cp_index = current_idx++; > /* PHY power UP sequence */ > diff --git a/drivers/phy/marvell/comphy_core.h b/drivers/phy/marvell/comphy_core.h > index d573776c05ae..f3d049393876 100644 > --- a/drivers/phy/marvell/comphy_core.h > +++ b/drivers/phy/marvell/comphy_core.h > @@ -8,6 +8,7 @@ > > #include <fdtdec.h> > #include <mvebu/comphy.h> > +#include <dt-bindings/comphy/comphy_data.h> > > #if defined(DEBUG) > #define debug_enter() printf("----> Enter %s\n", __func__); > @@ -20,6 +21,14 @@ > #define MAX_LANE_OPTIONS 10 > #define MAX_UTMI_PHY_COUNT 6 > > +struct comphy_map { > + u32 type; > + u32 speed; > + u32 invert; > + bool clk_src; > + bool end_point; > +}; > + > struct comphy_mux_options { > u32 type; > u32 mux_value; > diff --git a/include/mvebu/comphy.h b/include/mvebu/comphy.h > index 4d1b70393b20..14431576e66e 100644 > --- a/include/mvebu/comphy.h > +++ b/include/mvebu/comphy.h > @@ -6,17 +6,6 @@ > #ifndef _MVEBU_COMPHY_H_ > #define _MVEBU_COMPHY_H_ > > -#include <dt-bindings/comphy/comphy_data.h> > - > -struct comphy_map { > - u32 type; > - u32 speed; > - u32 invert; > - bool clk_src; > - bool end_point; > -}; > - > int comphy_rx_training(struct udevice *dev, u32 lane); > -int comphy_update_map(struct comphy_map *serdes_map, int count); > > #endif /* _MVEBU_COMPHY_H_ */ > Viele Grüße, Stefan Roese -- DENX Software Engineering GmbH, Managing Director: Wolfgang Denk HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-51 Fax: (+49)-8142-66989-80 Email: sr@denx.de ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 0/2] arm: mvebu: Remove comphy_update_map() 2022-01-18 9:33 [PATCH 0/2] arm: mvebu: Remove comphy_update_map() Pali Rohár 2022-01-18 9:33 ` [PATCH 1/2] arm: mvebu: turris_mox: Convert comphy_update_map() to board_fix_fdt() Pali Rohár 2022-01-18 9:33 ` [PATCH 2/2] phy: marvell: Remove unused function comphy_update_map() Pali Rohár @ 2022-01-20 16:22 ` Stefan Roese 2 siblings, 0 replies; 6+ messages in thread From: Stefan Roese @ 2022-01-20 16:22 UTC (permalink / raw) To: Pali Rohár, Marek Behún; +Cc: u-boot On 1/18/22 10:33, Pali Rohár wrote: > Convert Turris MOX's comphy_update_map() to board_fix_fdt() and then > remove it. > > Pali Rohár (2): > arm: mvebu: turris_mox: Convert comphy_update_map() to board_fix_fdt() > phy: marvell: Remove unused function comphy_update_map() > > board/CZ.NIC/turris_mox/turris_mox.c | 48 +++++++++------------------- > drivers/phy/marvell/comphy_core.c | 9 ------ > drivers/phy/marvell/comphy_core.h | 9 ++++++ > include/mvebu/comphy.h | 11 ------- > 4 files changed, 24 insertions(+), 53 deletions(-) > Applied to u-boot-marvell/master Thanks, Stefan ^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2022-01-20 16:22 UTC | newest] Thread overview: 6+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2022-01-18 9:33 [PATCH 0/2] arm: mvebu: Remove comphy_update_map() Pali Rohár 2022-01-18 9:33 ` [PATCH 1/2] arm: mvebu: turris_mox: Convert comphy_update_map() to board_fix_fdt() Pali Rohár 2022-01-18 11:17 ` Stefan Roese 2022-01-18 9:33 ` [PATCH 2/2] phy: marvell: Remove unused function comphy_update_map() Pali Rohár 2022-01-18 11:18 ` Stefan Roese 2022-01-20 16:22 ` [PATCH 0/2] arm: mvebu: Remove comphy_update_map() Stefan Roese
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox