Module Name: src
Committed By: jmcneill
Date: Sat Aug 12 11:44:26 UTC 2017
Modified Files:
src/sys/arch/evbarm/rpi: rpi_machdep.c
Log Message:
For boards with bluetooth, use AUX UART for console and PLCOM for bt.
To generate a diff of this commit:
cvs rdiff -u -r1.78 -r1.79 src/sys/arch/evbarm/rpi/rpi_machdep.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sys/arch/evbarm/rpi/rpi_machdep.c
diff -u src/sys/arch/evbarm/rpi/rpi_machdep.c:1.78 src/sys/arch/evbarm/rpi/rpi_machdep.c:1.79
--- src/sys/arch/evbarm/rpi/rpi_machdep.c:1.78 Tue Aug 1 00:01:56 2017
+++ src/sys/arch/evbarm/rpi/rpi_machdep.c Sat Aug 12 11:44:26 2017
@@ -1,4 +1,4 @@
-/* $NetBSD: rpi_machdep.c,v 1.78 2017/08/01 00:01:56 jmcneill Exp $ */
+/* $NetBSD: rpi_machdep.c,v 1.79 2017/08/12 11:44:26 jmcneill Exp $ */
/*-
* Copyright (c) 2012 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: rpi_machdep.c,v 1.78 2017/08/01 00:01:56 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rpi_machdep.c,v 1.79 2017/08/12 11:44:26 jmcneill Exp $");
#include "opt_arm_debug.h"
#include "opt_bcm283x.h"
@@ -47,6 +47,7 @@ __KERNEL_RCSID(0, "$NetBSD: rpi_machdep.
#include "bcmspi.h"
#include "bsciic.h"
#include "plcom.h"
+#include "com.h"
#include "genfb.h"
#include "ukbd.h"
@@ -97,6 +98,10 @@ __KERNEL_RCSID(0, "$NetBSD: rpi_machdep.
#include <evbarm/dev/plcomvar.h>
#endif
+#if NCOM > 0
+#include <dev/ic/comvar.h>
+#endif
+
#if NGENFB > 0
#include <dev/videomode/videomode.h>
#include <dev/videomode/edidvar.h>
@@ -182,6 +187,7 @@ static struct plcom_instance rpi_pi = {
static struct __aligned(16) {
struct vcprop_buffer_hdr vb_hdr;
struct vcprop_tag_clockrate vbt_uartclockrate;
+ struct vcprop_tag_clockrate vbt_coreclockrate;
struct vcprop_tag_boardrev vbt_boardrev;
struct vcprop_tag end;
} vb_uart = {
@@ -197,6 +203,14 @@ static struct __aligned(16) {
},
.id = VCPROP_CLK_UART
},
+ .vbt_coreclockrate = {
+ .tag = {
+ .vpt_tag = VCPROPTAG_GET_CLOCKRATE,
+ .vpt_len = VCPROPTAG_LEN(vb_uart.vbt_coreclockrate),
+ .vpt_rcode = VCPROPTAG_REQUEST
+ },
+ .id = VCPROP_CLK_CORE
+ },
.vbt_boardrev = {
.tag = {
.vpt_tag = VCPROPTAG_GET_BOARDREVISION,
@@ -466,9 +480,15 @@ rpi_uartinit(void)
if (vcprop_tag_success_p(&vb_uart.vbt_boardrev.tag)) {
if (rpi_rev_has_btwifi(vb_uart.vbt_boardrev.rev)) {
+#if NCOM > 0
+ /* Enable AUX UART on GPIO header */
+ bcm2835gpio_function_select(14, BCM2835_GPIO_ALT5);
+ bcm2835gpio_function_select(15, BCM2835_GPIO_ALT5);
+#else
/* Enable UART0 (PL011) on GPIO header */
bcm2835gpio_function_select(14, BCM2835_GPIO_ALT0);
bcm2835gpio_function_select(15, BCM2835_GPIO_ALT0);
+#endif
}
}
@@ -501,9 +521,15 @@ rpi_pinctrl(void)
#endif
if (rpi_rev_has_btwifi(vb.vbt_boardrev.rev)) {
+#if NCOM > 0
+ /* Enable UART0 (PL011) on BT */
+ bcm2835gpio_function_select(32, BCM2835_GPIO_ALT3);
+ bcm2835gpio_function_select(33, BCM2835_GPIO_ALT3);
+#else
/* Enable AUX UART on BT */
bcm2835gpio_function_select(32, BCM2835_GPIO_ALT5);
bcm2835gpio_function_select(33, BCM2835_GPIO_ALT5);
+#endif
bcm2835gpio_function_setpull(32, BCM2835_GPIO_GPPUD_PULLOFF);
bcm2835gpio_function_setpull(33, BCM2835_GPIO_GPPUD_PULLUP);
bcm2835gpio_function_select(43, BCM2835_GPIO_ALT0);
@@ -814,16 +840,9 @@ initarm(void *arg)
return initarm_common(KERNEL_VM_BASE, KERNEL_VM_SIZE, NULL, 0);
}
-void
-consinit(void)
+static void
+consinit_plcom(void)
{
- static int consinit_called = 0;
-
- if (consinit_called != 0)
- return;
-
- consinit_called = 1;
-
#if (NPLCOM > 0 && defined(PLCONSOLE))
/*
* Initialise the diagnostic serial console
@@ -833,8 +852,48 @@ consinit(void)
plcomcnattach(&rpi_pi, plcomcnspeed, uart_clk,
plcomcnmode, PLCOMCNUNIT);
+#endif
+}
+
+static void
+consinit_com(void)
+{
+#if NCOM > 0
+ bus_space_tag_t iot = &bcm2835_a4x_bs_tag;
+ const bus_addr_t addr = BCM2835_AUX_UART_BASE;
+ const int speed = B115200;
+ u_int freq = 0;
+ const u_int flags = TTYDEF_CFLAG;
+
+ if (vcprop_tag_success_p(&vb_uart.vbt_coreclockrate.tag))
+ freq = vb.vbt_coreclockrate.rate * 2;
+
+ comcnattach(iot, addr, speed, freq, COM_TYPE_BCMAUXUART, flags);
+#endif
+}
+
+void
+consinit(void)
+{
+ static int consinit_called = 0;
+ bool use_auxuart = false;
+ if (consinit_called != 0)
+ return;
+
+ consinit_called = 1;
+
+#if NCOM > 0
+ if (vcprop_tag_success_p(&vb_uart.vbt_boardrev.tag) &&
+ rpi_rev_has_btwifi(vb_uart.vbt_boardrev.rev)) {
+ use_auxuart = true;
+ }
#endif
+
+ if (use_auxuart)
+ consinit_com();
+ else
+ consinit_plcom();
}
#ifdef KGDB