static int __init read_init void int int trans_buf 20 unsigned long 03

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
static int __init read_init(void)
{
int i = 0;
int trans_buf[20];
unsigned long j; /* 03/07/28 */
printk(KERN_ERR "read keyboard\n"); /* 03/07/28 */
/* Clear the FIFO buffers and disable them (they will be reenabled in change_speed())*/
_reg_UART1_UCR2 &= SRST;
/* delay for the reset*/
for (i = 0; i < 1000; i++);
_reg_UART1_UCR1 |= UARTEN; /* Enable the UART */
_reg_UART1_UCR2 |= (RXEN | TXEN); /* 02/11/15 */
_reg_UART1_UCR2 |= PREN; /* 02/11/15 */
_reg_UART1_UCR2 |= WS; /* 02/11/15 */
/* not ignore RTS line */
_reg_UART1_UCR2 &= 0x0000bfff; /* IRTS=0 02/11/15 */
/* CTS line control */
_reg_UART1_UCR2 &= 0x0000dfff; /* CTSC=0 02/11/15 */
_reg_UART1_UCR2 |= CTS; /* 02/11/15 */
/*this is funny that UCR4 must be set as follows*/
_reg_UART1_UCR4 = 1;
/* and set the speed of the serial port */
_reg_UART1_UBIR = 0xf;
_reg_UART1_UBMR = 8000000 / 38400; /* baudrate=38400 */
_reg_UART1_UFCR = 0x00000A01; /* 02/11/15 */
/* delay for transmit data*/
for (i = 0; i < 50000; i++);
j = jiffies + 2; /* 20ms wait */ /* 03/07/28 */
while(jiffies < j){schedule();} /* 03/07/28 */
/* HOST Shutdown Complite COMMAND */
trans_buf[0] = 0x000000D7;
trans_buf[1] = 0x00000000;
trans_buf[2] = 0x00000000;
trans_buf[3] = 0x00000000;
trans_buf[4] = 0x00000028;
for(i=0; i<5; i++){
_reg_UART1_UTXD=trans_buf[i];
};
for(i=0; i<20; i++){
while (!(_reg_UART1_UCR2 & 0x0001));
trans_buf[i] = _reg_UART1_URXD;
printk(KERN_ERR "%d char is 0x%x\n", i, trans_buf[i]);
}
return 0;
}