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

View file

@ -63,30 +63,6 @@ ecwait(uchar mask, uchar val)
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
ecread(uchar addr)
{
@ -136,3 +112,63 @@ out:
unlock(&ec);
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
etheriwl pci wifi
etherrt2860 pci wifi
ethervirtio pci
ethermedium
netdevmedium
loopbackmedium

View file

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

View file

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

View file

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