Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/arch/evbarm/rpi For boards with bluetooth, use AUX UART ...
details: https://anonhg.NetBSD.org/src/rev/e4ec0a14f449
branches: trunk
changeset: 355749:e4ec0a14f449
user: jmcneill <jmcneill%NetBSD.org@localhost>
date: Sat Aug 12 11:44:26 2017 +0000
description:
For boards with bluetooth, use AUX UART for console and PLCOM for bt.
diffstat:
sys/arch/evbarm/rpi/rpi_machdep.c | 81 +++++++++++++++++++++++++++++++++-----
1 files changed, 70 insertions(+), 11 deletions(-)
diffs (162 lines):
diff -r 4cb9be6ba778 -r e4ec0a14f449 sys/arch/evbarm/rpi/rpi_machdep.c
--- a/sys/arch/evbarm/rpi/rpi_machdep.c Sat Aug 12 11:41:21 2017 +0000
+++ b/sys/arch/evbarm/rpi/rpi_machdep.c Sat Aug 12 11:44:26 2017 +0000
@@ -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 @@
#include "bcmspi.h"
#include "bsciic.h"
#include "plcom.h"
+#include "com.h"
#include "genfb.h"
#include "ukbd.h"
@@ -97,6 +98,10 @@
#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 __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 @@
},
.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 @@
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 @@
#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 @@
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,10 +852,50 @@
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
#if !defined(KGDB_PLCOMUNIT) || !defined(KGDB_DEVRATE) || !defined(KGDB_CONMODE)
#error Specify KGDB_PLCOMUNIT, KGDB_DEVRATE and KGDB_CONMODE for KGDB.
Home |
Main Index |
Thread Index |
Old Index