pc, pc64: untangle embedded controller (ec) dependency from devarch

This commit is contained in:
cinap_lenrek 2014-12-13 06:23:23 +01:00
parent 6a3b9012d5
commit 25a9cc3adb
6 changed files with 67 additions and 55 deletions

View file

@ -34,7 +34,6 @@ enum {
Qiow, Qiow,
Qiol, Qiol,
Qmsr, Qmsr,
Qec,
Qbase, Qbase,
Qmax = 16, Qmax = 16,
@ -64,7 +63,6 @@ static Dirtab archdir[Qmax] = {
"iow", { Qiow, 0 }, 0, 0660, "iow", { Qiow, 0 }, 0, 0660,
"iol", { Qiol, 0 }, 0, 0660, "iol", { Qiol, 0 }, 0, 0660,
"msr", { Qmsr, 0 }, 0, 0660, "msr", { Qmsr, 0 }, 0, 0660,
"ec", { Qec, 0 }, 0, 0660,
}; };
Lock archwlock; /* the lock is only for changing archdir */ Lock archwlock; /* the lock is only for changing archdir */
int narchdir = Qbase; int narchdir = Qbase;
@ -363,7 +361,7 @@ static long
archread(Chan *c, void *a, long n, vlong offset) archread(Chan *c, void *a, long n, vlong offset)
{ {
char *buf, *p; char *buf, *p;
int port, v; int port;
ushort *sp; ushort *sp;
ulong *lp; ulong *lp;
vlong *vp; vlong *vp;
@ -409,19 +407,6 @@ archread(Chan *c, void *a, long n, vlong offset)
error(Ebadarg); error(Ebadarg);
return n; return n;
case Qec:
if(offset >= 256)
error(Ebadarg);
if(offset+n > 256)
n = 256 - offset;
p = a;
for(port = offset; port < offset+n; port++){
if((v = ecread(port)) < 0)
error(Eio);
*p++ = v;
}
return n;
case Qioalloc: case Qioalloc:
break; break;
@ -501,15 +486,6 @@ archwrite(Chan *c, void *a, long n, vlong offset)
error(Ebadarg); error(Ebadarg);
return n; return n;
case Qec:
if(offset+n > 256)
error(Ebadarg);
p = a;
for(port = offset; port < offset+n; port++)
if(ecwrite(port, *p++) < 0)
error(Eio);
return n;
default: default:
if(c->qid.path < narchdir && (fn = writefn[c->qid.path])) if(c->qid.path < narchdir && (fn = writefn[c->qid.path]))
return fn(c, a, n, offset); return fn(c, a, n, offset);

View file

@ -63,30 +63,6 @@ ecwait(uchar mask, uchar val)
return -1; return -1;
} }
int
ecinit(int cmdport, int dataport)
{
print("ec: cmd %X, data %X\n", cmdport, dataport);
if(ioalloc(cmdport, 1, 0, "ec.sc") < 0){
print("ec: cant allocate cmd port %X\n", cmdport);
return -1;
}
if(ioalloc(dataport, 1, 0, "ec.data") < 0){
print("ec: cant allocate data port %X\n", dataport);
iofree(cmdport);
return -1;
}
lock(&ec);
ec.port[EC_SC] = cmdport;
ec.port[EC_DATA] = dataport;
ec.init = 1;
unlock(&ec);
return 0;
}
int int
ecread(uchar addr) ecread(uchar addr)
{ {
@ -136,3 +112,63 @@ out:
unlock(&ec); unlock(&ec);
return r; return r;
} }
static long
ecarchread(Chan*, void *a, long n, vlong off)
{
int port, v;
uchar *p;
if(off < 0 || off >= 256)
return 0;
if(off+n > 256)
n = 256 - off;
p = a;
for(port = off; port < off+n; port++){
if((v = ecread(port)) < 0)
error(Eio);
*p++ = v;
}
return n;
}
static long
ecarchwrite(Chan*, void *a, long n, vlong off)
{
int port;
uchar *p;
if(off < 0 || off+n > 256)
error(Ebadarg);
p = a;
for(port = off; port < off+n; port++)
if(ecwrite(port, *p++) < 0)
error(Eio);
return n;
}
int
ecinit(int cmdport, int dataport)
{
print("ec: cmd %X, data %X\n", cmdport, dataport);
if(ioalloc(cmdport, 1, 0, "ec.sc") < 0){
print("ec: cant allocate cmd port %X\n", cmdport);
return -1;
}
if(ioalloc(dataport, 1, 0, "ec.data") < 0){
print("ec: cant allocate data port %X\n", dataport);
iofree(cmdport);
return -1;
}
lock(&ec);
ec.port[EC_SC] = cmdport;
ec.port[EC_DATA] = dataport;
ec.init = 1;
unlock(&ec);
addarchfile("ec", 0660, ecarchread, ecarchwrite);
return 0;
}

View file

@ -70,6 +70,7 @@ link
etherwavelan wavelan devi82365 cis pci etherwavelan wavelan devi82365 cis pci
etheriwl pci wifi etheriwl pci wifi
etherrt2860 pci wifi etherrt2860 pci wifi
ethervirtio pci
ethermedium ethermedium
netdevmedium netdevmedium
loopbackmedium loopbackmedium

View file

@ -85,10 +85,9 @@ link
audiohda audiohda
misc misc
archacpi mp apic squidboy archacpi mp apic squidboy ec
archmp mp apic squidboy archmp mp apic squidboy
mtrr mtrr
ec
sdaoe sdaoe
sdide pci sdscsi sdide pci sdscsi

View file

@ -83,10 +83,9 @@ link
audiohda audiohda
misc misc
archacpi mp apic squidboy archacpi mp apic squidboy ec
archmp mp apic squidboy archmp mp apic squidboy
mtrr mtrr
ec
# sdaoe # sdaoe
sdide pci sdscsi sdide pci sdscsi

View file

@ -69,6 +69,7 @@ link
# etherwavelan wavelan devi82365 cis pci # etherwavelan wavelan devi82365 cis pci
etheriwl pci wifi etheriwl pci wifi
# etherrt2860 pci wifi # etherrt2860 pci wifi
ethervirtio pci
ethermedium ethermedium
# pcmciamodem # pcmciamodem
netdevmedium netdevmedium
@ -82,7 +83,7 @@ link
audiohda audiohda
misc misc
archacpi mp apic squidboy archacpi mp apic squidboy ec
archmp mp apic squidboy archmp mp apic squidboy
mtrr mtrr
@ -96,7 +97,7 @@ misc
# sdmmc pci pmmc # sdmmc pci pmmc
# sdloop # sdloop
# uarti8250 uarti8250
# uartisa # uartisa
# uartpci pci # uartpci pci