Print this page
bcm2835: use the real uart instead of the mini-uart
The real uart is more capable.  We'll want to use it for the real console
eventually anyway, so let's bite the bullet now when no one will really
notice.  (For comparison, the Linux kernel uses the real uart and totally
lacks a driver for the miniuart.)
   1 /*
   2  * This file and its contents are supplied under the terms of the
   3  * Common Development and Distribution License ("CDDL"), version 1.0.
   4  * You may only use this file in accordance with the terms of version
   5  * 1.0 of the CDDL.
   6  *
   7  * A full copy of the text of the CDDL should have accompanied this
   8  * source.  A copy of the CDDL is also available via the Internet at
   9  * http://www.illumos.org/license/CDDL.
  10  */
  11 
  12 /*
  13  * Copyright (c) 2013 Joyent, Inc.  All rights reserved.
  14  */
  15 
  16 /*
  17  * bcm2835 boot console implementation
  18  */
  19 
  20 #include "miniuart.h"
  21 
  22 /*
  23  * There are a few different potential boot consoles that we could have on the
  24  * bcm2835. There is both a mini uart and a full functioning uart. Generally,
  25  * people will use the mini uart, but we want to support both. As such we have a
  26  * single global ops vector that we set once during bcons_init and never again.
  27  */
  28 #define BMC2835_CONSNAME_MAX    24
  29 typedef struct bcm2835_consops {
  30         char bco_name[BMC2835_CONSNAME_MAX];
  31         void (*bco_putc)(uint8_t);
  32         uint8_t (*bco_getc)(void);
  33         int (*bco_isc)(void);
  34 } bcm2835_consops_t;
  35 
  36 static bcm2835_consops_t consops;
  37 
  38 /*
  39  * For now, we only support the mini uart.
  40  */
  41 void
  42 bcons_init(char *bstr)
  43 {
  44         bcm2835_miniuart_init();
  45         consops.bco_putc = bcm2835_miniuart_putc;
  46         consops.bco_getc = bcm2835_miniuart_getc;
  47         consops.bco_isc = bcm2835_miniuart_isc;
  48 }
  49 
  50 void
  51 bcons_putchar(int c)
  52 {
  53         consops.bco_putc(c);
  54 }
  55 
  56 void
  57 bcons_puts(const char *str)
  58 {
  59         const char *c = str;
  60         while (*c != '\0')
  61                 consops.bco_putc(*c++);
  62 }
  63 
  64 int
  65 bcons_getchar(void)
  66 {
  67         return (consops.bco_getc());
   1 /*
   2  * This file and its contents are supplied under the terms of the
   3  * Common Development and Distribution License ("CDDL"), version 1.0.
   4  * You may only use this file in accordance with the terms of version
   5  * 1.0 of the CDDL.
   6  *
   7  * A full copy of the text of the CDDL should have accompanied this
   8  * source.  A copy of the CDDL is also available via the Internet at
   9  * http://www.illumos.org/license/CDDL.
  10  */
  11 
  12 /*
  13  * Copyright (c) 2013 Joyent, Inc.  All rights reserved.
  14  */
  15 
  16 /*
  17  * bcm2835 boot console implementation
  18  */
  19 
  20 #include "bcm2835_uart.h"
  21 
  22 /*
  23  * There are a few different potential boot consoles that we could have on the
  24  * bcm2835. There is both a mini uart and a full functioning uart. Generally,
  25  * people will use one of them, but we want to support both. As such we have a
  26  * single global ops vector that we set once during bcons_init and never again.
  27  */
  28 #define BMC2835_CONSNAME_MAX    24
  29 typedef struct bcm2835_consops {
  30         char bco_name[BMC2835_CONSNAME_MAX];
  31         void (*bco_putc)(uint8_t);
  32         uint8_t (*bco_getc)(void);
  33         int (*bco_isc)(void);
  34 } bcm2835_consops_t;
  35 
  36 static bcm2835_consops_t consops;
  37 
  38 /*
  39  * For now, we only support the real uart.
  40  */
  41 void
  42 bcons_init(char *bstr)
  43 {
  44         bcm2835_uart_init();
  45         consops.bco_putc = bcm2835_uart_putc;
  46         consops.bco_getc = bcm2835_uart_getc;
  47         consops.bco_isc = bcm2835_uart_isc;
  48 }
  49 
  50 void
  51 bcons_putchar(int c)
  52 {
  53         consops.bco_putc(c);
  54 }
  55 
  56 void
  57 bcons_puts(const char *str)
  58 {
  59         const char *c = str;
  60         while (*c != '\0')
  61                 consops.bco_putc(*c++);
  62 }
  63 
  64 int
  65 bcons_getchar(void)
  66 {
  67         return (consops.bco_getc());