summaryrefslogtreecommitdiff
path: root/sys/arch
diff options
context:
space:
mode:
authorMark Kettenis <kettenis@cvs.openbsd.org>2018-05-31 20:03:19 +0000
committerMark Kettenis <kettenis@cvs.openbsd.org>2018-05-31 20:03:19 +0000
commit11975d9791bb6948a0dff38484b21d56dcc0cfbd (patch)
tree3b2a4d8ead18d2526851fed03065babb53edc67a /sys/arch
parent28dd2d6559606c8e3362c9aea5408fc4db644cf7 (diff)
Move com_fdt.c to dev/fdt since we can share it between armv7 and arm64 now.
ok patrick@
Diffstat (limited to 'sys/arch')
-rw-r--r--sys/arch/arm64/conf/files.arm646
-rw-r--r--sys/arch/arm64/dev/com_fdt.c160
-rw-r--r--sys/arch/armv7/conf/files.armv76
-rw-r--r--sys/arch/armv7/dev/com_fdt.c160
4 files changed, 2 insertions, 330 deletions
diff --git a/sys/arch/arm64/conf/files.arm64 b/sys/arch/arm64/conf/files.arm64
index edb7391860b..de1af97f530 100644
--- a/sys/arch/arm64/conf/files.arm64
+++ b/sys/arch/arm64/conf/files.arm64
@@ -1,4 +1,4 @@
-# $OpenBSD: files.arm64,v 1.21 2018/05/04 16:12:12 visa Exp $
+# $OpenBSD: files.arm64,v 1.22 2018/05/31 20:03:18 kettenis Exp $
maxpartitions 16
maxusers 2 8 64
@@ -111,10 +111,6 @@ include "dev/sdmmc/files.sdmmc"
# Machine-independent FDT drivers
include "dev/fdt/files.fdt"
-# Console related stuff
-attach com at fdt with com_fdt
-file arch/arm64/dev/com_fdt.c com_fdt
-
# ARM PrimeCell PL011 UART
device pluart
attach pluart at fdt
diff --git a/sys/arch/arm64/dev/com_fdt.c b/sys/arch/arm64/dev/com_fdt.c
deleted file mode 100644
index 988de52a77f..00000000000
--- a/sys/arch/arm64/dev/com_fdt.c
+++ /dev/null
@@ -1,160 +0,0 @@
-/* $OpenBSD: com_fdt.c,v 1.6 2018/05/14 19:25:54 kettenis Exp $ */
-/*
- * Copyright (c) 2016 Patrick Wildt <patrick@blueri.se>
- *
- * Permission to use, copy, modify, and distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
- * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- */
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/device.h>
-#include <sys/tty.h>
-
-#include <machine/intr.h>
-#include <machine/bus.h>
-#include <machine/fdt.h>
-
-#include <dev/ic/comreg.h>
-#include <dev/ic/comvar.h>
-#include <dev/cons.h>
-
-#include <dev/ofw/fdt.h>
-#include <dev/ofw/openfirm.h>
-#include <dev/ofw/ofw_clock.h>
-#include <dev/ofw/ofw_pinctrl.h>
-
-#define com_usr 31 /* Synopsys DesignWare UART */
-
-int com_fdt_match(struct device *, void *, void *);
-void com_fdt_attach(struct device *, struct device *, void *);
-int com_fdt_intr_designware(void *);
-
-struct cfattach com_fdt_ca = {
- sizeof (struct com_softc), com_fdt_match, com_fdt_attach
-};
-
-struct consdev com_fdt_cons = {
- NULL, NULL, comcngetc, comcnputc, comcnpollc, NULL,
- NODEV, CN_LOWPRI
-};
-
-void
-com_fdt_init_cons(void)
-{
- struct fdt_reg reg;
- void *node;
-
- if ((node = fdt_find_cons("brcm,bcm2835-aux-uart")) == NULL &&
- (node = fdt_find_cons("snps,dw-apb-uart")) == NULL &&
- (node = fdt_find_cons("ti,omap3-uart")) == NULL &&
- (node = fdt_find_cons("ti,omap4-uart")) == NULL)
- return;
- if (fdt_get_reg(node, 0, &reg))
- return;
-
- /*
- * Figuring out the clock frequency is rather complicated as
- * on many SoCs this requires traversing a fair amount of the
- * clock tree. Instead we rely on the firmware to set up the
- * console for us and bypass the cominit() call that
- * comcnattach() does by doing the minimal setup here.
- */
-
- comcons_reg_width = OF_getpropint(stdout_node, "reg-io-width", 4);
- comcons_reg_shift = OF_getpropint(stdout_node, "reg-shift", 2);
-
- comconsiot = fdt_cons_bs_tag;
- if (bus_space_map(comconsiot, reg.addr, reg.size, 0, &comconsioh))
- return;
-
- cn_tab = &com_fdt_cons;
-}
-
-int
-com_fdt_match(struct device *parent, void *match, void *aux)
-{
- struct fdt_attach_args *faa = aux;
-
- return (OF_is_compatible(faa->fa_node, "brcm,bcm2835-aux-uart") ||
- OF_is_compatible(faa->fa_node, "snps,dw-apb-uart") ||
- OF_is_compatible(faa->fa_node, "ti,omap3-uart") ||
- OF_is_compatible(faa->fa_node, "ti,omap4-uart"));
-}
-
-void
-com_fdt_attach(struct device *parent, struct device *self, void *aux)
-{
- struct com_softc *sc = (struct com_softc *)self;
- struct fdt_attach_args *faa = aux;
- int (*intr)(void *) = comintr;
- uint32_t freq;
-
- if (faa->fa_nreg < 1)
- return;
-
- clock_enable(faa->fa_node, NULL);
-
- /*
- * Determine the clock frequency after enabling the clock.
- * This gives the clock code a chance to configure the
- * appropriate frequency for us.
- */
- freq = OF_getpropint(faa->fa_node, "clock-frequency", 0);
- if (freq == 0)
- freq = clock_get_frequency(faa->fa_node, NULL);
-
- sc->sc_iot = faa->fa_iot;
- sc->sc_iobase = faa->fa_reg[0].addr;
- sc->sc_uarttype = COM_UART_16550;
- sc->sc_frequency = freq ? freq : COM_FREQ;
-
- sc->sc_reg_width = OF_getpropint(faa->fa_node, "reg-io-width", 4);
- sc->sc_reg_shift = OF_getpropint(faa->fa_node, "reg-shift", 2);
-
- if (OF_is_compatible(faa->fa_node, "snps,dw-apb-uart"))
- intr = com_fdt_intr_designware;
-
- if (OF_is_compatible(faa->fa_node, "ti,omap3-uart") ||
- OF_is_compatible(faa->fa_node, "ti,omap4-uart"))
- sc->sc_uarttype = COM_UART_TI16750;
-
- if (stdout_node == faa->fa_node) {
- SET(sc->sc_hwflags, COM_HW_CONSOLE);
- SET(sc->sc_swflags, COM_SW_SOFTCAR);
- comconsfreq = sc->sc_frequency;
- comconsrate = stdout_speed ? stdout_speed : B115200;
- }
-
- if (bus_space_map(sc->sc_iot, faa->fa_reg[0].addr,
- faa->fa_reg[0].size, 0, &sc->sc_ioh)) {
- printf("%s: bus_space_map failed\n", __func__);
- return;
- }
-
- pinctrl_byname(faa->fa_node, "default");
-
- com_attach_subr(sc);
-
- arm_intr_establish_fdt(faa->fa_node, IPL_TTY, intr,
- sc, sc->sc_dev.dv_xname);
-}
-
-int
-com_fdt_intr_designware(void *cookie)
-{
- struct com_softc *sc = cookie;
-
- com_read_reg(sc, com_usr);
-
- return comintr(sc);
-}
diff --git a/sys/arch/armv7/conf/files.armv7 b/sys/arch/armv7/conf/files.armv7
index 02908c23394..664ec7f357c 100644
--- a/sys/arch/armv7/conf/files.armv7
+++ b/sys/arch/armv7/conf/files.armv7
@@ -1,4 +1,4 @@
-# $OpenBSD: files.armv7,v 1.35 2018/05/04 16:12:12 visa Exp $
+# $OpenBSD: files.armv7,v 1.36 2018/05/31 20:03:18 kettenis Exp $
maxpartitions 16
maxusers 2 8 64
@@ -76,10 +76,6 @@ include "arch/armv7/vexpress/files.vexpress"
include "arch/armv7/broadcom/files.broadcom"
include "arch/armv7/marvell/files.marvell"
-# Console related stuff
-attach com at fdt with com_fdt
-file arch/armv7/dev/com_fdt.c com_fdt
-
# ARM PrimeCell PL011 UART
device pluart
attach pluart at fdt
diff --git a/sys/arch/armv7/dev/com_fdt.c b/sys/arch/armv7/dev/com_fdt.c
deleted file mode 100644
index 55fe4132e52..00000000000
--- a/sys/arch/armv7/dev/com_fdt.c
+++ /dev/null
@@ -1,160 +0,0 @@
-/* $OpenBSD: com_fdt.c,v 1.14 2018/05/31 09:12:59 kettenis Exp $ */
-/*
- * Copyright (c) 2016 Patrick Wildt <patrick@blueri.se>
- *
- * Permission to use, copy, modify, and distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
- * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- */
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/device.h>
-#include <sys/tty.h>
-
-#include <machine/intr.h>
-#include <machine/bus.h>
-#include <machine/fdt.h>
-
-#include <dev/ic/comreg.h>
-#include <dev/ic/comvar.h>
-#include <dev/cons.h>
-
-#include <dev/ofw/fdt.h>
-#include <dev/ofw/openfirm.h>
-#include <dev/ofw/ofw_clock.h>
-#include <dev/ofw/ofw_pinctrl.h>
-
-#define com_usr 31 /* Synopsys DesignWare UART */
-
-int com_fdt_match(struct device *, void *, void *);
-void com_fdt_attach(struct device *, struct device *, void *);
-int com_fdt_intr_designware(void *);
-
-struct cfattach com_fdt_ca = {
- sizeof (struct com_softc), com_fdt_match, com_fdt_attach
-};
-
-struct consdev com_fdt_cons = {
- NULL, NULL, comcngetc, comcnputc, comcnpollc, NULL,
- NODEV, CN_LOWPRI
-};
-
-void
-com_fdt_init_cons(void)
-{
- struct fdt_reg reg;
- void *node;
-
- if ((node = fdt_find_cons("brcm,bcm2835-aux-uart")) == NULL &&
- (node = fdt_find_cons("snps,dw-apb-uart")) == NULL &&
- (node = fdt_find_cons("ti,omap3-uart")) == NULL &&
- (node = fdt_find_cons("ti,omap4-uart")) == NULL)
- return;
- if (fdt_get_reg(node, 0, &reg))
- return;
-
- /*
- * Figuring out the clock frequency is rather complicated as
- * on many SoCs this requires traversing a fair amount of the
- * clock tree. Instead we rely on the firmware to set up the
- * console for us and bypass the cominit() call that
- * comcnattach() does by doing the minimal setup here.
- */
-
- comcons_reg_width = OF_getpropint(stdout_node, "reg-io-width", 4);
- comcons_reg_shift = OF_getpropint(stdout_node, "reg-shift", 2);
-
- comconsiot = fdt_cons_bs_tag;
- if (bus_space_map(comconsiot, reg.addr, reg.size, 0, &comconsioh))
- return;
-
- cn_tab = &com_fdt_cons;
-}
-
-int
-com_fdt_match(struct device *parent, void *match, void *aux)
-{
- struct fdt_attach_args *faa = aux;
-
- return (OF_is_compatible(faa->fa_node, "brcm,bcm2835-aux-uart") ||
- OF_is_compatible(faa->fa_node, "snps,dw-apb-uart") ||
- OF_is_compatible(faa->fa_node, "ti,omap3-uart") ||
- OF_is_compatible(faa->fa_node, "ti,omap4-uart"));
-}
-
-void
-com_fdt_attach(struct device *parent, struct device *self, void *aux)
-{
- struct com_softc *sc = (struct com_softc *)self;
- struct fdt_attach_args *faa = aux;
- int (*intr)(void *) = comintr;
- uint32_t freq;
-
- if (faa->fa_nreg < 1)
- return;
-
- clock_enable(faa->fa_node, NULL);
-
- /*
- * Determine the clock frequency after enabling the clock.
- * This gives the clock code a chance to configure the
- * appropriate frequency for us.
- */
- freq = OF_getpropint(faa->fa_node, "clock-frequency", 0);
- if (freq == 0)
- freq = clock_get_frequency(faa->fa_node, NULL);
-
- sc->sc_iot = faa->fa_iot;
- sc->sc_iobase = faa->fa_reg[0].addr;
- sc->sc_uarttype = COM_UART_16550;
- sc->sc_frequency = freq ? freq : COM_FREQ;
-
- sc->sc_reg_width = OF_getpropint(faa->fa_node, "reg-io-width", 4);
- sc->sc_reg_shift = OF_getpropint(faa->fa_node, "reg-shift", 2);
-
- if (OF_is_compatible(faa->fa_node, "snps,dw-apb-uart"))
- intr = com_fdt_intr_designware;
-
- if (OF_is_compatible(faa->fa_node, "ti,omap3-uart") ||
- OF_is_compatible(faa->fa_node, "ti,omap4-uart"))
- sc->sc_uarttype = COM_UART_TI16750;
-
- if (stdout_node == faa->fa_node) {
- SET(sc->sc_hwflags, COM_HW_CONSOLE);
- SET(sc->sc_swflags, COM_SW_SOFTCAR);
- comconsfreq = sc->sc_frequency;
- comconsrate = stdout_speed ? stdout_speed : B115200;
- }
-
- if (bus_space_map(sc->sc_iot, faa->fa_reg[0].addr,
- faa->fa_reg[0].size, 0, &sc->sc_ioh)) {
- printf("%s: bus_space_map failed\n", __func__);
- return;
- }
-
- pinctrl_byname(faa->fa_node, "default");
-
- com_attach_subr(sc);
-
- arm_intr_establish_fdt(faa->fa_node, IPL_TTY, intr,
- sc, sc->sc_dev.dv_xname);
-}
-
-int
-com_fdt_intr_designware(void *cookie)
-{
- struct com_softc *sc = cookie;
-
- com_read_reg(sc, com_usr);
-
- return comintr(sc);
-}