Et voila! Nous avons un UART!
authorAlyssa Rosenzweig <alyssa@rosenzweig.io>
Sat, 31 Dec 2016 20:09:24 +0000 (12:09 -0800)
committerAlyssa Rosenzweig <alyssa@rosenzweig.io>
Sat, 31 Dec 2016 20:09:24 +0000 (12:09 -0800)
arm_chainloader/drivers/uart.c
romstage.c

index 69473da..3b20ac1 100644 (file)
@@ -1,10 +1,10 @@
 #include <hardware.h>\r
 \r
-#define UART_STATUS 0x3F201018\r
-#define UART_DATA   0x3F201000\r
-\r
 void uart_putc(unsigned int ch)\r
 {\r
-       while(mmio_read32(UART_STATUS) & 0x20);\r
-       mmio_write32(UART_DATA, ch);\r
+       while(1) {\r
+               if (mmio_read32(AUX_MU_LSR_REG) & 0x20)\r
+                       break;\r
+       }\r
+       mmio_write32(AUX_MU_IO_REG, ch);\r
 }\r
index ab2fa67..5cf7b40 100644 (file)
@@ -43,7 +43,7 @@ uint32_t g_CPUID;
 \r
 void uart_putc(unsigned int ch)\r
 {\r
-       while(UART_MSR & 0x20) break;\r
+       while(UART_MSR & 0x20);\r
        UART_RBRTHRDLL = ch;\r
 }\r
 \r
@@ -53,12 +53,13 @@ void uart_init(void) {
        ra |= 4 << 12;\r
        GP_FSEL1 = ra;\r
 \r
+        /*\r
         CM_UARTCTL = CM_PASSWORD | CM_SRC_OSC | CM_UARTCTL_FRAC_SET;\r
         udelay(150);\r
         CM_UARTDIV = CM_PASSWORD | 0x6666;\r
         udelay(150);\r
         CM_UARTCTL |= CM_UARTCTL_ENAB_SET;\r
-        udelay(150);\r
+        udelay(150);*/\r
         \r
         mmio_write32(UART_CR, 0);\r
 \r
@@ -68,11 +69,16 @@ void uart_init(void) {
        udelay(150);\r
        GP_PUDCLK0 = 0;\r
 \r
+        CM_UARTDIV = CM_PASSWORD | 0x6666;\r
+        CM_UARTCTL = CM_PASSWORD | CM_SRC_OSC | CM_UARTCTL_FRAC_SET | CM_UARTCTL_ENAB_SET;\r
+\r
+        mmio_write32(UART_ICR, 0x7FF);\r
         mmio_write32(UART_IBRD, 1);\r
         mmio_write32(UART_FBRD, 40);\r
-        mmio_write32(UART_ICR, 0x7FF);\r
         mmio_write32(UART_LCRH, 0x70);\r
         mmio_write32(UART_CR, 0x301);\r
+\r
+//        for(;;) uart_putc('B');\r
 }\r
 \r
 void led_init(void) {\r
@@ -188,12 +194,12 @@ int _main(unsigned int cpuid, unsigned int load_address) {
                __DATE__, __TIME__,\r
                "OPENSOURCE"\r
        );\r
+        }\r
 \r
        printf("CPUID    = 0x%X\n", cpuid);\r
        printf("LoadAddr = 0x%X\n", load_address);\r
 \r
        print_crap();\r
-        }\r
 \r
        g_CPUID = cpuid;\r
 \r
This page took 0.02745 seconds and 4 git commands to generate.