2 #include "../port/lib.h"
33 Uart* uartenable(Uart *);
35 extern PhysUart zynqphysuart;
37 static Ctlr zctlr[1] = {
44 static Uart zuart[1] = {
49 .phys = &zynqphysuart,
76 for(i = 0; i < 128; i++){
77 if((ct->r[CHANSTAT] & TXFULL) != 0)
79 if(uart->op >= uart->oe && uartstageoutput(uart) == 0)
81 ct->r[FIFO] = *uart->op++;
86 zuartintr(Ureg *, void *arg)
95 fl = ct->r[INTSTAT] & ct->r[MASK];
97 if((fl & RXTRIG) != 0)
98 while((ct->r[CHANSTAT] & RXEMPTY) == 0){
102 if((fl & TXEMPTY) != 0)
107 zuartenable(Uart *uart, int ie)
113 while((ctlr->r[CHANSTAT] & TXEMPTY) == 0)
115 ctlr->r[IRQDIS] = -1;
116 ctlr->r[RXFIFOLVL] = 1;
119 intrenable(ctlr->irq, zuartintr, uart, LEVEL, uart->name);
122 ctlr->r[IRQEN] = RXTRIG | TXEMPTY;
128 zuartgetc(Uart *uart)
133 while((c->r[CHANSTAT] & RXEMPTY) != 0)
139 zuartputc(Uart *uart, int c)
144 while((ct->r[CHANSTAT] & TXFULL) != 0)
158 if(uartenable(uart) != nil){
167 zuartbits(Uart *uart, int n)
188 zuartbaud(Uart *, int n)
190 print("uart baud %d\n", n);
195 zuartparity(Uart *uart, int p)
202 ct->r[MODE] = ct->r[MODE] & ~0x38 | 0x08;
205 ct->r[MODE] = ct->r[MODE] & ~0x38;
208 ct->r[MODE] = ct->r[MODE] & 0x38 | 0x20;
216 zuartnop(Uart *, int)
221 zuartnope(Uart *, int)
227 PhysUart zynqphysuart = {
229 .enable = zuartenable,
235 .parity = zuartparity,
243 .modemctl = zuartnop,