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_INTCP
22 #include <arch/bd/intcp.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_INTCP_PL011_BASE0
;
43 uart_addr
= (unsigned char *) ARM_INTCP_PL011_BASE1
;
45 uart_addr
+= ARM_INTCP_PL011_DR
* 4;
52 unsigned char armbd_uart_received (int port
)
54 unsigned *uart_addr
= (unsigned *) ARM_INTCP_PL011_BASE0
;
57 uart_addr
= (unsigned *) ARM_INTCP_PL011_BASE1
;
61 if (*uart_addr
& ARM_INTCP_PL011_RXFE
)
67 unsigned char armbd_uart_read (int port
)
69 arm_rcv_block
*uart_addr
= (arm_rcv_block
*) ARM_INTCP_PL011_BASE0
;
72 uart_addr
= (arm_rcv_block
*) ARM_INTCP_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_INTCP_PL110_BASE
;
103 unsigned *p
= (unsigned *) &c
[offset
];
108 unsigned armbd_pl110_read (unsigned offset
)
110 char *c
= (char *) ARM_INTCP_PL110_BASE
;
111 unsigned *p
= (unsigned *) &c
[offset
];
116 void armbd_display_enable ()
118 #ifdef CONFIG_DRV_ARM_BOARD_INTCP_PL110
119 armbd_pl110_write ((0x4 << 2), 0x500000); /* upper video memory address */
120 armbd_pl110_write ((0x5 << 2), 0x600000); /* lower video memory address */
122 armbd_pl110_write ((0x7 << 2), ARM_INTCP_PL110_CR_EN
|
123 ARM_INTCP_PL110_CR_PWR
|
124 ARM_INTCP_PL110_CR_16BPP
); /* enable device and set to 16bpp mode */
126 armbd_pl110_write ((0x0 << 2), 157); /* 640 */
127 armbd_pl110_write ((0x1 << 2), 599); /* 400 */
132 vgafb
= (unsigned char *) 0x500000;
133 vgadb
= (unsigned char *) 0x500000;
139 void armbd_display_turnon ()
141 unsigned r
= armbd_pl110_read (0x7 << 2);
143 if (r
& ARM_INTCP_PL110_CR_PWR
)
146 r
|= ARM_INTCP_PL110_CR_PWR
;
148 armbd_pl110_write ((0x7 << 2), r
); /* enable device */
151 void armbd_display_turnoff ()
153 unsigned r
= armbd_pl110_read (0x7 << 2);
155 if (!(r
& ARM_INTCP_PL110_CR_PWR
))
158 r
&= ~ARM_INTCP_PL110_CR_PWR
;
160 armbd_pl110_write ((0x7 << 2), r
); /* disable device */
165 * ARM PrimeCell PS2 Keyboard/Mouse Interface
166 * Keyboard & Mouse over PS2
169 #define KBD_CMD_ENABLE 0xF4 /* Enable scanning */
170 #define KBD_REPLY_ACK 0xFA /* Command ACK */
171 #define KBD_CMD_RESET_ENABLE 0xF6 /* reset and enable scanning */
173 void armbd_pl050_write (unsigned offset
, unsigned val
)
175 char *c
= (char *) ARM_INTCP_PL050_KB_BASE
;
176 unsigned *p
= (unsigned *) &c
[offset
];
181 unsigned armbd_pl050_read (unsigned offset
)
183 char *c
= (char *) ARM_INTCP_PL050_KB_BASE
;
184 unsigned *p
= (unsigned *) &c
[offset
];
189 unsigned armbd_kbd_data ()
191 return armbd_pl050_read (1 << 2) == ARM_INTCP_PL050_TXEMPTY
? 0 : 1;
194 unsigned armbd_kbd_scancode ()
196 return armbd_pl050_read (2 << 2);
199 unsigned armbd_kbd_ack ()
201 armbd_pl050_write (2 << 2, KBD_REPLY_ACK
);
204 unsigned armbd_kbd_init ()
206 armbd_pl050_write (2 << 2, KBD_CMD_RESET_ENABLE
);
208 // armbd_pl050_write (2 << 2, KBD_CMD_SET_RATE);