changelog shortlog tags branches changeset file revisions annotate raw help

Mercurial > hg > plan9front / sys/src/9/bcm/devarch.c

revision 7152: e93129fc35e7
parent 6853: 8ae0e1edff80
child 7153: 7048df8bc401
     1.1--- a/sys/src/9/bcm/devarch.c
     1.2+++ b/sys/src/9/bcm/devarch.c
     1.3@@ -172,3 +172,31 @@ archinit(void)
     1.4 	addarchfile("cputype", 0444, cputyperead, nil);
     1.5 	addarchfile("cputemp", 0444, cputempread, nil);
     1.6 }
     1.7+
     1.8+void
     1.9+okay(int on)
    1.10+{
    1.11+	static int first;
    1.12+	static int okled, polarity;
    1.13+	char *p;
    1.14+
    1.15+	if(!first++){
    1.16+		p = getconf("bcm2709.disk_led_gpio");
    1.17+		if(p == nil)
    1.18+			p = getconf("bcm2708.disk_led_gpio");
    1.19+		if(p != nil)
    1.20+			okled = strtol(p, 0, 0);
    1.21+		else
    1.22+			okled = 'v';
    1.23+		p = getconf("bcm2709.disk_led_active_low");
    1.24+		if(p == nil)
    1.25+			p = getconf("bcm2708.disk_led_active_low");
    1.26+		polarity = (p == nil || *p == '1');
    1.27+		if(okled != 'v')
    1.28+			gpiosel(okled, Output);
    1.29+	}
    1.30+	if(okled == 'v')
    1.31+		vgpset(0, on);
    1.32+	else if(okled != 0)
    1.33+		gpioout(okled, on^polarity);
    1.34+}