3 * Copyright (C) 2009 Tomas 'ZeXx86' Jedrzejek (zexx86@zexos.org)
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
21 #ifdef CONFIG_DRV_ARM_BOARD_VERPB
22 #include <arch/bd/verpb.h>
27 * Serial cable input/output
34 unsigned break_err
: 1;
35 unsigned ovrrun_err
: 1;
36 } __attribute__ ((__packed__
)) arm_rcv_block
;
38 int armbd_uart_write (int port
, unsigned char c
)
40 unsigned char *uart_addr
= (unsigned char *) ARM_VERPB_PL011_BASE0
;
43 uart_addr
= (unsigned char *) ARM_VERPB_PL011_BASE1
;
45 uart_addr
+= ARM_VERPB_PL011_DR
* 4;
52 unsigned char armbd_uart_received (int port
)
54 unsigned *uart_addr
= (unsigned *) ARM_VERPB_PL011_BASE0
;
57 uart_addr
= (unsigned *) ARM_VERPB_PL011_BASE1
;
61 if (*uart_addr
& ARM_VERPB_PL011_RXFE
)
67 unsigned char armbd_uart_read (int port
)
69 arm_rcv_block
*uart_addr
= (arm_rcv_block
*) ARM_VERPB_PL011_BASE0
;
72 uart_addr
= (arm_rcv_block
*) ARM_VERPB_PL011_BASE1
;
74 #ifdef ARM_UART_ERR_LOG
75 unsigned char err
= 0;
77 /* there is error on uart, lets clean it */
78 if (uart_addr
->ovrrun_err
)
81 if (uart_addr
->break_err
)
84 if (uart_addr
->par_err
)
87 if (uart_addr
->fr_err
)
96 * ARM PrimeCell Color LCD Controller
100 void armbd_pl110_write (unsigned offset
, unsigned val
)
102 char *c
= (char *) ARM_VERPB_PL110_BASE
;
103 unsigned *p
= (unsigned *) &c
[offset
];
108 unsigned armbd_pl110_read (unsigned offset
)
110 char *c
= (char *) ARM_VERPB_PL110_BASE
;
111 unsigned *p
= (unsigned *) &c
[offset
];
116 void armbd_display_enable ()
118 armbd_pl110_write ((0x4 << 2), 0x500000); /* upper video memory address */
119 armbd_pl110_write ((0x5 << 2), 0x600000); /* lower video memory address */
120 armbd_pl110_write ((0x7 << 2), ARM_VERPB_PL110_CR_EN
|
121 ARM_VERPB_PL110_CR_PWR
); /* enable device */
122 armbd_pl110_write ((0x0 << 2), 157); /* 640 */
123 armbd_pl110_write ((0x1 << 2), 399); /* 400 */
128 * ARM PrimeCell PS2 Keyboard/Mouse Interface
129 * Keyboard & Mouse over PS2
132 #define KBD_CMD_ENABLE 0xF4 /* Enable scanning */
133 #define KBD_REPLY_ACK 0xFA /* Command ACK */
134 #define KBD_CMD_RESET_ENABLE 0xF6 /* reset and enable scanning */
136 void armbd_pl050_write (unsigned offset
, unsigned val
)
138 char *c
= (char *) ARM_INTCP_PL050_KB_BASE
;
139 unsigned *p
= (unsigned *) &c
[offset
];
144 unsigned armbd_pl050_read (unsigned offset
)
146 char *c
= (char *) ARM_INTCP_PL050_KB_BASE
;
147 unsigned *p
= (unsigned *) &c
[offset
];
152 unsigned armbd_kbd_data ()
154 return armbd_pl050_read (1 << 2) == ARM_INTCP_PL050_TXEMPTY
? 0 : 1;
157 unsigned armbd_kbd_scancode ()
159 return armbd_pl050_read (2 << 2);
162 unsigned armbd_kbd_ack ()
164 armbd_pl050_write (2 << 2, KBD_REPLY_ACK
);
167 unsigned armbd_kbd_init ()
169 armbd_pl050_write (2 << 2, KBD_CMD_RESET_ENABLE
);
171 // armbd_pl050_write (2 << 2, KBD_CMD_SET_RATE);