2 * embedded controller (usually at ports 0x66/0x62)
5 #include "../port/lib.h"
10 #include "../port/error.h"
17 /* Embedded Controller Status, EC_SC (R) */
25 /* Embedded Controller Command Set */
36 int port[2]; /* EC_SC and EC_DATA */
42 return inb(ec.port[reg]);
45 ecwr(int reg, uchar val)
47 outb(ec.port[reg], val);
51 ecwait(uchar mask, uchar val)
56 for(i=0; i<1000; i++){
62 print("ec: wait timeout status=%x pc=%#p\n", s, getcallerpc(&mask));
91 ecwrite(uchar addr, uchar val)
117 ecarchread(Chan*, void *a, long n, vlong off)
122 if(off < 0 || off >= 256)
127 for(port = off; port < off+n; port++){
128 if((v = ecread(port)) < 0)
136 ecarchwrite(Chan*, void *a, long n, vlong off)
141 if(off < 0 || off+n > 256)
144 for(port = off; port < off+n; port++)
145 if(ecwrite(port, *p++) < 0)
151 ecinit(int cmdport, int dataport)
153 print("ec: cmd %X, data %X\n", cmdport, dataport);
155 if(ioalloc(cmdport, 1, 0, "ec.sc") < 0){
156 print("ec: cant allocate cmd port %X\n", cmdport);
159 if(ioalloc(dataport, 1, 0, "ec.data") < 0){
160 print("ec: cant allocate data port %X\n", dataport);
166 ec.port[EC_SC] = cmdport;
167 ec.port[EC_DATA] = dataport;
171 addarchfile("ec", 0660, ecarchread, ecarchwrite);