Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/arch Use the VC property mailbox to request the UART clo...
details: https://anonhg.NetBSD.org/src/rev/c14e762f0ff9
branches: trunk
changeset: 820300:c14e762f0ff9
user: skrll <skrll%NetBSD.org@localhost>
date: Fri Jan 06 14:55:37 2017 +0000
description:
Use the VC property mailbox to request the UART clock rate and use it
appropriately
Newer firmwares use 48MHz
diffstat:
sys/arch/arm/broadcom/bcm2835_plcom.c | 12 +++++-
sys/arch/evbarm/rpi/rpi_machdep.c | 60 ++++++++++++++++++++++++++++++++--
2 files changed, 66 insertions(+), 6 deletions(-)
diffs (161 lines):
diff -r 6ec926d79afc -r c14e762f0ff9 sys/arch/arm/broadcom/bcm2835_plcom.c
--- a/sys/arch/arm/broadcom/bcm2835_plcom.c Fri Jan 06 14:53:32 2017 +0000
+++ b/sys/arch/arm/broadcom/bcm2835_plcom.c Fri Jan 06 14:55:37 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: bcm2835_plcom.c,v 1.3 2015/07/29 14:22:49 skrll Exp $ */
+/* $NetBSD: bcm2835_plcom.c,v 1.4 2017/01/06 14:55:37 skrll Exp $ */
/*-
* Copyright (c) 2012 The NetBSD Foundation, Inc.
@@ -32,7 +32,7 @@
/* Interface to plcom (PL011) serial driver. */
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: bcm2835_plcom.c,v 1.3 2015/07/29 14:22:49 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: bcm2835_plcom.c,v 1.4 2017/01/06 14:55:37 skrll Exp $");
#include <sys/types.h>
#include <sys/device.h>
@@ -69,11 +69,19 @@
bcm2835_plcom_attach(device_t parent, device_t self, void *aux)
{
struct plcom_softc *sc = device_private(self);
+ prop_dictionary_t dict = device_properties(self);
struct amba_attach_args *aaa = aux;
void *ih;
sc->sc_dev = self;
sc->sc_frequency = BCM2835_UART0_CLK;
+
+ /* Fetch the UART clock frequency from property if set. */
+ prop_number_t frequency = prop_dictionary_get(dict, "frequency");
+ if (frequency != NULL) {
+ sc->sc_frequency = prop_number_integer_value(frequency);
+ }
+
sc->sc_hwflags = PLCOM_HW_TXFIFO_DISABLE;
sc->sc_swflags = 0;
sc->sc_set_mcr = NULL;
diff -r 6ec926d79afc -r c14e762f0ff9 sys/arch/evbarm/rpi/rpi_machdep.c
--- a/sys/arch/evbarm/rpi/rpi_machdep.c Fri Jan 06 14:53:32 2017 +0000
+++ b/sys/arch/evbarm/rpi/rpi_machdep.c Fri Jan 06 14:55:37 2017 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: rpi_machdep.c,v 1.69 2017/01/06 14:53:32 skrll Exp $ */
+/* $NetBSD: rpi_machdep.c,v 1.70 2017/01/06 14:55:37 skrll 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.69 2017/01/06 14:53:32 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rpi_machdep.c,v 1.70 2017/01/06 14:55:37 skrll Exp $");
#include "opt_arm_debug.h"
#include "opt_bcm283x.h"
@@ -131,6 +131,8 @@
#define RPI_FB_HEIGHT 720
#endif
+int uart_clk = BCM2835_UART0_CLK;
+
#define PLCONADDR BCM2835_UART0_BASE
#ifndef CONSDEVNAME
@@ -177,6 +179,28 @@
static struct __aligned(16) {
struct vcprop_buffer_hdr vb_hdr;
+ struct vcprop_tag_clockrate vbt_uartclockrate;
+ struct vcprop_tag end;
+} vb_uart = {
+ .vb_hdr = {
+ .vpb_len = sizeof(vb_uart),
+ .vpb_rcode = VCPROP_PROCESS_REQUEST,
+ },
+ .vbt_uartclockrate = {
+ .tag = {
+ .vpt_tag = VCPROPTAG_GET_CLOCKRATE,
+ .vpt_len = VCPROPTAG_LEN(vb_uart.vbt_uartclockrate),
+ .vpt_rcode = VCPROPTAG_REQUEST
+ },
+ .id = VCPROP_CLK_UART
+ },
+ .end = {
+ .vpt_tag = VCPROPTAG_NULL
+ }
+};
+
+static struct __aligned(16) {
+ struct vcprop_buffer_hdr vb_hdr;
struct vcprop_tag_fwrev vbt_fwrev;
struct vcprop_tag_boardmodel vbt_boardmodel;
struct vcprop_tag_boardrev vbt_boardrev;
@@ -391,6 +415,26 @@
static void
+rpi_uartinit(void)
+{
+ const paddr_t pa = BCM2835_PERIPHERALS_BUS_TO_PHYS(BCM2835_ARMMBOX_BASE);
+ const bus_space_tag_t iot = &bcm2835_bs_tag;
+ const bus_space_handle_t ioh = BCM2835_IOPHYSTOVIRT(pa);
+ uint32_t res;
+
+ bcm2835_mbox_write(iot, ioh, BCMMBOX_CHANARM2VC, KERN_VTOPHYS(&vb_uart));
+
+ bcm2835_mbox_read(iot, ioh, BCMMBOX_CHANARM2VC, &res);
+
+ cpu_dcache_inv_range((vaddr_t)&vb, sizeof(vb));
+
+ if (vcprop_tag_success_p(&vb_uart.vbt_uartclockrate.tag))
+ uart_clk = vb_uart.vbt_uartclockrate.rate;
+}
+
+
+
+static void
rpi_bootparams(void)
{
const paddr_t pa = BCM2835_PERIPHERALS_BUS_TO_PHYS(BCM2835_ARMMBOX_BASE);
@@ -596,6 +640,8 @@
cpu_domains((DOMAIN_CLIENT << (PMAP_DOMAIN_KERNEL*2)) | DOMAIN_CLIENT);
+ rpi_uartinit();
+
consinit();
/* Talk to the user */
@@ -704,7 +750,7 @@
*/
rpi_pi.pi_iobase = consaddr;
- plcomcnattach(&rpi_pi, plcomcnspeed, BCM2835_UART0_CLK,
+ plcomcnattach(&rpi_pi, plcomcnspeed, uart_clk,
plcomcnmode, PLCOMCNUNIT);
#endif
@@ -728,7 +774,7 @@
rpi_pi.pi_iobase = consaddr;
- res = plcom_kgdb_attach(&rpi_pi, KGDB_DEVRATE, BCM2835_UART0_CLK,
+ res = plcom_kgdb_attach(&rpi_pi, KGDB_DEVRATE, uart_clk,
KGDB_CONMODE, KGDB_PLCOMUNIT);
if (res)
panic("KGDB uart can not be initialized, err=%d.", res);
@@ -1085,6 +1131,12 @@
}
#endif
+ if (device_is_a(dev, "plcom") &&
+ vcprop_tag_success_p(&vb_uart.vbt_uartclockrate.tag) &&
+ vb_uart.vbt_uartclockrate.rate > 0) {
+ prop_dictionary_set_uint32(dict,
+ "frequency", vb_uart.vbt_uartclockrate.rate);
+ }
if (device_is_a(dev, "bcmdmac") &&
vcprop_tag_success_p(&vb.vbt_dmachan.tag)) {
prop_dictionary_set_uint32(dict,
Home |
Main Index |
Thread Index |
Old Index