Index: src/sys/arch/shark/shark/sequoia.c =================================================================== RCS file: /cvsroot/src/sys/arch/shark/shark/sequoia.c,v retrieving revision 1.18 diff -u -r1.18 sequoia.c --- src/sys/arch/shark/shark/sequoia.c 29 Nov 2025 22:08:06 -0000 1.18 +++ src/sys/arch/shark/shark/sequoia.c 18 Jun 2026 14:59:39 -0000 @@ -109,13 +109,6 @@ #define LED_DEBUG_GREEN_BIT FOMPCR_M_PCON8 -/* define biled colors */ -#define LED_BILED_NONE 0 -#define LED_BILED_GREEN 1 -#define LED_BILED_YELLOW 2 -#define LED_BILED_RED 3 - - #define LED_TIMEOUT hz / 20 /* 20 times a second */ #define LED_NET_ACTIVE (1000000/hz) * LED_TIMEOUT /* delay in us for net activity */ @@ -131,6 +124,7 @@ static struct timeval ledLastActive; /* last time we get net activity */ static int ledColor; /* present color of led */ +static int debugColor; /* present color of debug led */ static int ledBlockCount; /* reference count of block calls */ int sequoia_index_cache = -1; /* set to silly value so that we dont cache on init */ @@ -144,7 +138,6 @@ ** FUNCTIONAL PROTOTYPES ** */ -static void ledSetBiled(int color); static void ledTimeout(void *arg); /* @@ -195,6 +188,8 @@ CLR(seqReg,LED_DEBUG_GREEN_BIT); sequoiaWrite(PMC_FOMPCR_REG, seqReg); + ledColor = LED_BILED_RED; + debugColor = LED_DEBUG_STATE_1; /* ** @@ -264,6 +259,7 @@ /* setup the biled info */ ledColor = LED_BILED_GREEN; + ledSetBiled(ledColor); ledLastActive.tv_usec = 0; ledLastActive.tv_sec = 0; ledBlockCount = 0; @@ -530,13 +526,13 @@ /* check if we are blocked */ if(ledBlockCount) { - if(ledColor == LED_BILED_YELLOW) + if(ledColor & LED_BILED_YELLOW) { - ledSetBiled(LED_BILED_NONE); + ledSetBiled(LED_BILED_YELLOW_OFF); } else { - ledSetBiled(LED_BILED_YELLOW); + ledSetBiled(LED_BILED_YELLOW_ON); } } @@ -544,22 +540,22 @@ /* check if we have network activity */ else if (timeSpan < LED_NET_ACTIVE) { - if(ledColor == LED_BILED_GREEN) + if(ledColor & LED_BILED_GREEN) { - ledSetBiled(LED_BILED_NONE); + ledSetBiled(LED_BILED_GREEN_OFF); } else { - ledSetBiled(LED_BILED_GREEN); + ledSetBiled(LED_BILED_GREEN_ON); } } /* normal operating mode */ else { - if(ledColor != LED_BILED_GREEN) + if(!(ledColor & LED_BILED_GREEN)) { - ledSetBiled(LED_BILED_GREEN); + ledSetBiled(LED_BILED_GREEN_ON); } } @@ -569,13 +565,12 @@ } -static void ledSetBiled(int color) +void ledSetBiled(int color) { u_int16_t seqReg; sequoiaLock(); - ledColor = color; sequoiaRead (PMC_FOMPCR_REG, &seqReg); switch(color) @@ -583,21 +578,45 @@ case LED_BILED_NONE: SET(seqReg,LED_BILED_YELLOW_BIT); SET(seqReg,LED_BILED_GREEN_BIT); + ledColor = color; break; case LED_BILED_YELLOW: CLR(seqReg,LED_BILED_YELLOW_BIT); SET(seqReg,LED_BILED_GREEN_BIT); + ledColor = color; break; case LED_BILED_GREEN: SET(seqReg,LED_BILED_YELLOW_BIT); CLR(seqReg,LED_BILED_GREEN_BIT); + ledColor = color; break; case LED_BILED_RED: CLR(seqReg,LED_BILED_YELLOW_BIT); CLR(seqReg,LED_BILED_GREEN_BIT); + ledColor = color; + break; + + case LED_BILED_YELLOW_ON: + CLR(seqReg,LED_BILED_YELLOW_BIT); + ledColor |= LED_BILED_YELLOW; + break; + + case LED_BILED_YELLOW_OFF: + SET(seqReg,LED_BILED_YELLOW_BIT); + ledColor &= ~LED_BILED_YELLOW; + break; + + case LED_BILED_GREEN_ON: + CLR(seqReg,LED_BILED_GREEN_BIT); + ledColor |= LED_BILED_GREEN; + break; + + case LED_BILED_GREEN_OFF: + SET(seqReg,LED_BILED_GREEN_BIT); + ledColor &= ~LED_BILED_GREEN; break; default: @@ -609,6 +628,11 @@ sequoiaUnlock(); } +int ledGetBiled(void) +{ + return ledColor; +} + int hwGetRev(void) { @@ -686,37 +710,45 @@ case LED_DEBUG_STATE_0: CLR(seqReg,LED_DEBUG_YELLOW_BIT); CLR(seqReg,LED_DEBUG_GREEN_BIT); + debugColor = LED_DEBUG_STATE_0; break; case LED_DEBUG_STATE_1: SET(seqReg,LED_DEBUG_YELLOW_BIT); CLR(seqReg,LED_DEBUG_GREEN_BIT); + debugColor = LED_DEBUG_STATE_1; break; case LED_DEBUG_STATE_2: CLR(seqReg,LED_DEBUG_YELLOW_BIT); SET(seqReg,LED_DEBUG_GREEN_BIT); + debugColor = LED_DEBUG_STATE_2; break; case LED_DEBUG_STATE_3: SET(seqReg,LED_DEBUG_YELLOW_BIT); SET(seqReg,LED_DEBUG_GREEN_BIT); + debugColor = LED_DEBUG_STATE_3; break; case LED_DEBUG_YELLOW_ON: SET(seqReg,LED_DEBUG_YELLOW_BIT); + debugColor |= LED_DEBUG_STATE_1; break; case LED_DEBUG_YELLOW_OFF: CLR(seqReg,LED_DEBUG_YELLOW_BIT); + debugColor &= ~LED_DEBUG_STATE_1; break; case LED_DEBUG_GREEN_ON: SET(seqReg,LED_DEBUG_GREEN_BIT); + debugColor |= LED_DEBUG_STATE_2; break; case LED_DEBUG_GREEN_OFF: CLR(seqReg,LED_DEBUG_GREEN_BIT); + debugColor &= ~LED_DEBUG_STATE_2; break; default: @@ -728,6 +760,11 @@ sequoiaUnlock(); } +int ledGetDebug(void) +{ + return debugColor; +} + int testPin=0; void scrToggleTestPin (void) @@ -794,6 +831,11 @@ config_found(self, &noba, sequoia_cfprint, CFARGS(.iattr = "sequoia")); + /* attach the LED's */ + strlcpy(noba.oba_ofname, "dec,dnard-led", sizeof(noba.oba_ofname)); + config_found(self, &noba, sequoia_cfprint, + CFARGS(.iattr = "sequoia")); + /* attach the ofisa instance at the same OFW node */ config_found(self, aux, ofisaprint, CFARGS(.iattr = "ofisa_subclass")); Index: src/sys/arch/shark/shark/sequoia.h =================================================================== RCS file: /cvsroot/src/sys/arch/shark/shark/sequoia.h,v retrieving revision 1.6 diff -u -r1.6 sequoia.h --- src/sys/arch/shark/shark/sequoia.h 5 Dec 2021 07:21:59 -0000 1.6 +++ src/sys/arch/shark/shark/sequoia.h 18 Jun 2026 14:59:40 -0000 @@ -5111,8 +5111,23 @@ #define LED_DEBUG_GREEN_OFF 6 #define LED_DEBUG_GREEN_ON 7 +/* define biled colors */ +#define LED_BILED_NONE 0 +#define LED_BILED_GREEN 1 +#define LED_BILED_YELLOW 2 +#define LED_BILED_RED 3 /* Green + Yellow */ +#define LED_BILED_GREEN_OFF 4 +#define LED_BILED_GREEN_ON 5 + +#define LED_BILED_YELLOW_OFF 6 +#define LED_BILED_YELLOW_ON 7 + + +void ledSetBiled(int color); void ledSetDebug(int command); +int ledGetBiled(void); +int ledGetDebug(void); #endif /* _LOCORE */ #endif /* __LANGUAGE_ASM__ */ Index: src/sys/arch/shark/shark/shark_led.c =================================================================== RCS file: src/sys/arch/shark/shark/shark_led.c diff -N src/sys/arch/shark/shark/shark_led.c --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ src/sys/arch/shark/shark/shark_led.c 18 Jun 2026 14:59:40 -0000 @@ -0,0 +1,149 @@ +/* $NetBSD$ */ + +/* + * Copyright (c) 2021 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Julian Coleman. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#include + +__KERNEL_RCSID(0, "$NetBSD$"); + +#include +#include +#include + +#include +#include +#include + +#include + +#include + +struct sharkled_led { + void *cookie; + struct led_device *led; + int num; +}; + +struct sharkled_softc { + device_t sc_dev; + struct sharkled_led sc_leds[2]; +}; + +static int sharkled_match(device_t, cfdata_t, void *); +static void sharkled_attach(device_t, device_t, void *); +int sharkled_get_led(void *cookie); +void sharkled_set_led(void *cookie, int val); + +CFATTACH_DECL_NEW(sharkled, sizeof(struct sharkled_softc), + sharkled_match, sharkled_attach, NULL, NULL); + +static int +sharkled_match(device_t parent, cfdata_t match, void *aux) +{ + struct ofbus_attach_args *oba = aux; + + /* "sequoia" interface fills out oba_ofname */ + return strcmp(oba->oba_ofname, "dec,dnard-led") == 0; +} + +#define SHARK_LED0_NAME "front" +#define SHARK_LED1_NAME "debug" + +static void +sharkled_attach(device_t parent, device_t self, void *aux) +{ + struct sharkled_softc *sc = device_private(self); + struct sharkled_led *l; + + sc->sc_dev = self; + aprint_normal(": %s, %s\n", SHARK_LED0_NAME, SHARK_LED1_NAME); + + l = &sc->sc_leds[0]; + l->cookie = sc; + l->num = 0; + led_attach(SHARK_LED0_NAME, l, sharkled_get_led, sharkled_set_led); + + l = &sc->sc_leds[1]; + l->cookie = sc; + l->num = 1; + led_attach(SHARK_LED1_NAME, l, sharkled_get_led, sharkled_set_led); +} + +int +sharkled_get_led(void *cookie) +{ + struct sharkled_led *l = cookie; + int color; + + switch(l->num) + { + case 0: + color = ledGetBiled(); + if (color & LED_BILED_YELLOW) + return 1; + else + return 0; + break; + case 1: + color = ledGetDebug(); + if (color & LED_DEBUG_STATE_1) + return 1; + else + return 0; + break; + default: + return 0; + break; + } +} + +void +sharkled_set_led(void *cookie, int val) +{ + struct sharkled_led *l = cookie; + + switch(l->num) + { + case 0: + if (val) + ledSetBiled(LED_BILED_YELLOW_ON); + else + ledSetBiled(LED_BILED_YELLOW_OFF); + break; + case 1: + if (val) + ledSetDebug(LED_DEBUG_YELLOW_ON); + else + ledSetDebug(LED_DEBUG_YELLOW_OFF); + break; + default: + break; + } +}