1
0

initcalls: Add initial implementation

Create simple serial subsystem which makes use of initcalls, and convert
existing serial drivers to its use.
This commit is contained in:
2012-10-04 00:26:35 -04:00
parent 3f624153e7
commit 9d86813d8c
14 changed files with 219 additions and 102 deletions

View File

@ -18,8 +18,11 @@
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#include <init.h>
#include <types.h>
#include <drivers/serial.h>
#define VC_MMU_IO_OFFSET(addr) (addr - 0x7E000000 + 0x20000000)
/* Auxiliary IO registers (includes both mini-UART and SPI) */
@ -57,7 +60,7 @@
#define GPPUD VC_MMU_IO_OFFSET(0x7E200094)
#define GPPUDCLK0 VC_MMU_IO_OFFSET(0x7E200098)
void mini_uart_init() {
void mini_uart_device_init() {
uint32 aux_enables;
uint32 gpfsel1;
unsigned int i;
@ -96,10 +99,23 @@ void mini_uart_init() {
*(uint32 *)AUX_MU_CNTL_REG = 2; //enable TX
}
void mini_uart_putc(char c) {
int mini_uart_putc(char c) {
/* Wait until the serial buffer is empty */
while (!(*(volatile uint32*)AUX_MU_LSR_REG & MINI_UART_TX_EMPTY));
/* When it's empty, write our character */
*(volatile uint32*)AUX_MU_IO_REG = c;
return 0;
}
struct serial_dev mini_uart_dev = {
.putc = &mini_uart_putc
};
void mini_uart_init() {
mini_uart_device_init();
serial_register_device(&mini_uart_dev);
}
early_initcall(mini_uart_init);