From 06920861a77a24d4413dbd32a0798ef73ccd7df5 Mon Sep 17 00:00:00 2001 From: Adam Wujek <adam.wujek@cern.ch> Date: Wed, 8 Jul 2015 18:15:44 +0200 Subject: [PATCH] userspace/wrsw_hal: change assignment of left port's LED From now, turn left LED on when link is up. Depending on the configured function LED will have the following color: --orange for port configured as non-wr --green for slave --yellow for master and other cases (like wrong configuration) Signed-off-by: Adam Wujek <adam.wujek@cern.ch> --- userspace/libwr/i2c_sfp.c | 12 ++++++------ userspace/libwr/include/libwr/sfp_lib.h | 15 +++++++-------- userspace/wrsw_hal/hal_ports.c | 16 +++++++++++++--- 3 files changed, 26 insertions(+), 17 deletions(-) diff --git a/userspace/libwr/i2c_sfp.c b/userspace/libwr/i2c_sfp.c index 314356ee5..43a6f60e8 100644 --- a/userspace/libwr/i2c_sfp.c +++ b/userspace/libwr/i2c_sfp.c @@ -411,13 +411,13 @@ void shw_sfp_gpio_init(void) for (i = 0; i < 18; i++) { shw_sfp_set_led_synced(i, 1); shw_udelay(7000); - shw_sfp_set_led_link(i, 1); + shw_sfp_set_generic(i, 1, SFP_LED_WRMODE_MASTER); shw_udelay(7000); } for (i = 0; i < 18; i++) { shw_sfp_set_led_synced(i, 0); shw_udelay(7000); - shw_sfp_set_led_link(i, 0); + shw_sfp_set_generic(i, 0, SFP_LED_WRMODE_MASTER); shw_udelay(7000); } @@ -457,9 +457,9 @@ void shw_sfp_gpio_set(int num, uint8_t state) else curr &= 0xf0; - if (state & SFP_LED_LINK) + if (state & SFP_LED_WRMODE1) curr |= SFP_LED_LINK_MASK(top); - if (state & SFP_LED_WRMODE) + if (state & SFP_LED_WRMODE2) curr |= SFP_LED_WRMODE_MASK(top); if (state & SFP_LED_SYNCED) curr |= SFP_LED_SYNCED_MASK(top); @@ -500,9 +500,9 @@ uint8_t shw_sfp_gpio_get(int num) i2c_transfer(bus, addr, 0, 1, &curr); if (curr & SFP_LED_LINK_MASK(top)) - out |= SFP_LED_LINK; + out |= SFP_LED_WRMODE1; if (curr & SFP_LED_WRMODE_MASK(top)) - out |= SFP_LED_WRMODE; + out |= SFP_LED_WRMODE2; if (curr & SFP_LED_SYNCED_MASK(top)) out |= SFP_LED_SYNCED; if (curr & SFP_TX_DISABLE_MASK(top)) diff --git a/userspace/libwr/include/libwr/sfp_lib.h b/userspace/libwr/include/libwr/sfp_lib.h index acec44a5d..4ac7881eb 100644 --- a/userspace/libwr/include/libwr/sfp_lib.h +++ b/userspace/libwr/include/libwr/sfp_lib.h @@ -1,17 +1,16 @@ #ifndef __LIBWR_SHW_SFPLIB_H #define __LIBWR_SHW_SFPLIB_H -#define SFP_LED_LINK (1 << 0) -#define SFP_LED_WRMODE (1 << 1) +/* note each led contains green and orange part */ +#define SFP_LED_WRMODE_SLAVE (1) /* green */ +#define SFP_LED_WRMODE_NON_WR (2) /* orange */ +#define SFP_LED_WRMODE_MASTER (3) /* yellow */ +#define SFP_LED_WRMODE_OFF (3) /* to off entire WRMODE LED */ +#define SFP_LED_WRMODE1 (1 << 0) +#define SFP_LED_WRMODE2 (1 << 1) #define SFP_LED_SYNCED (1 << 2) #define SFP_TX_DISABLE (1 << 3) -#define shw_sfp_set_led_link(num, status) \ - shw_sfp_set_generic(num, status, SFP_LED_LINK) - -#define shw_sfp_set_led_wrmode(num, status) \ - shw_sfp_set_generic(num, status, SFP_LED_WRMODE) - #define shw_sfp_set_led_synced(num, status) \ shw_sfp_set_generic(num, status, SFP_LED_SYNCED) diff --git a/userspace/wrsw_hal/hal_ports.c b/userspace/wrsw_hal/hal_ports.c index 825c5406d..3ecff4caa 100644 --- a/userspace/wrsw_hal/hal_ports.c +++ b/userspace/wrsw_hal/hal_ports.c @@ -327,7 +327,8 @@ static int hal_port_link_down(struct hal_port_state * p, int link_up) rts_set_mode(RTS_MODE_GM_FREERUNNING); } - shw_sfp_set_led_link(p->hw_index, 0); + /* turn off link/wrmode LEDs */ + shw_sfp_set_generic(p->hw_index, 0, SFP_LED_WRMODE_OFF); p->state = HAL_PORT_STATE_LINK_DOWN; hal_port_reset_state(p); @@ -380,8 +381,17 @@ static void hal_port_fsm(struct hal_port_state * p) p->tx_cal_pending = 0; p->rx_cal_pending = 0; - - shw_sfp_set_led_link(p->hw_index, 1); + /* set link/wrmode LEDs */ + if (p->mode == HEXP_PORT_MODE_WR_SLAVE) {/* slave */ + shw_sfp_set_generic(p->hw_index, 1, + SFP_LED_WRMODE_SLAVE); + } else if (p->mode == HEXP_PORT_MODE_NON_WR) {/* non-wr */ + shw_sfp_set_generic(p->hw_index, 1, + SFP_LED_WRMODE_NON_WR); + } else { /* master or other */ + shw_sfp_set_generic(p->hw_index, 1, + SFP_LED_WRMODE_MASTER); + } pr_info("%s: link up\n", p->name); p->state = HAL_PORT_STATE_UP; } -- GitLab