changelog shortlog tags branches files raw gz bz2 help

Mercurial > hg > plan9front / changeset: bcm: move okay() from uartmini.c to devarch.c

changeset 7152: e93129fc35e7
parent 7151: 50ff71b7598a
child 7153: 7048df8bc401
author: cinap_lenrek@felloff.net
date: Wed, 10 Apr 2019 15:06:56 +0200
files: sys/src/9/bcm/devarch.c sys/src/9/bcm/uartmini.c
description: bcm: move okay() from uartmini.c to devarch.c
     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+}
     2.1--- a/sys/src/9/bcm/uartmini.c
     2.2+++ b/sys/src/9/bcm/uartmini.c
     2.3@@ -332,31 +332,3 @@ PhysUart miniphysuart = {
     2.4 	.getc		= getc,
     2.5 	.putc		= putc,
     2.6 };
     2.7-
     2.8-void
     2.9-okay(int on)
    2.10-{
    2.11-	static int first;
    2.12-	static int okled, polarity;
    2.13-	char *p;
    2.14-
    2.15-	if(!first++){
    2.16-		p = getconf("bcm2709.disk_led_gpio");
    2.17-		if(p == nil)
    2.18-			p = getconf("bcm2708.disk_led_gpio");
    2.19-		if(p != nil)
    2.20-			okled = strtol(p, 0, 0);
    2.21-		else
    2.22-			okled = 'v';
    2.23-		p = getconf("bcm2709.disk_led_active_low");
    2.24-		if(p == nil)
    2.25-			p = getconf("bcm2708.disk_led_active_low");
    2.26-		polarity = (p == nil || *p == '1');
    2.27-		if(okled != 'v')
    2.28-			gpiosel(okled, Output);
    2.29-	}
    2.30-	if(okled == 'v')
    2.31-		vgpset(0, on);
    2.32-	else if(okled != 0)
    2.33-		gpioout(okled, on^polarity);
    2.34-}