Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/arch Replace sscom with a much simpler uart driver. The ...



details:   https://anonhg.NetBSD.org/src/rev/3c97ccd522fd
branches:  trunk
changeset: 324473:3c97ccd522fd
user:      jmcneill <jmcneill%NetBSD.org@localhost>
date:      Thu Jul 05 13:11:57 2018 +0000

description:
Replace sscom with a much simpler uart driver. The simpler driver is 1/4th
the size and has the added benefit of not freezing when an arrow key is
pressed.

diffstat:

 sys/arch/arm/samsung/exynos5422_clock.c |    22 +-
 sys/arch/arm/samsung/exynos_soc.c       |    45 +-
 sys/arch/arm/samsung/exynos_sscom.c     |   305 ----
 sys/arch/arm/samsung/exynos_uart.c      |   598 ++++++++
 sys/arch/arm/samsung/files.exynos       |    11 +-
 sys/arch/arm/samsung/sscom.c            |  2109 -------------------------------
 sys/arch/arm/samsung/sscom_reg.h        |     3 +-
 sys/arch/arm/samsung/sscom_var.h        |   262 ---
 sys/arch/evbarm/conf/EXYNOS             |     6 +-
 sys/arch/evbarm/exynos/exynos_start.S   |   120 +-
 10 files changed, 652 insertions(+), 2829 deletions(-)

diffs (truncated from 3639 to 300 lines):

diff -r 439dabf95175 -r 3c97ccd522fd sys/arch/arm/samsung/exynos5422_clock.c
--- a/sys/arch/arm/samsung/exynos5422_clock.c   Thu Jul 05 13:11:03 2018 +0000
+++ b/sys/arch/arm/samsung/exynos5422_clock.c   Thu Jul 05 13:11:57 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: exynos5422_clock.c,v 1.11 2018/07/04 23:06:28 jmcneill Exp $ */
+/* $NetBSD: exynos5422_clock.c,v 1.12 2018/07/05 13:11:58 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2015 Jared D. McNeill <jmcneill%invisible.ca@localhost>
@@ -29,7 +29,7 @@
 #include "locators.h"
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: exynos5422_clock.c,v 1.11 2018/07/04 23:06:28 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: exynos5422_clock.c,v 1.12 2018/07/05 13:11:58 jmcneill Exp $");
 
 #include <sys/param.h>
 #include <sys/bus.h>
@@ -555,6 +555,24 @@
        CLK_GATE("usbd301", "aclk200_fsys", EXYNOS5422_GATE_IP_FSYS,
            __BIT(20), CLK_SET_RATE_PARENT),
 
+       CLK_GATE("uart0", "mout_user_aclk66_peric", EXYNOS5422_GATE_IP_PERIC,
+           __BIT(0), CLK_SET_RATE_PARENT),
+       CLK_GATE("uart1", "mout_user_aclk66_peric", EXYNOS5422_GATE_IP_PERIC,
+           __BIT(1), CLK_SET_RATE_PARENT),
+       CLK_GATE("uart2", "mout_user_aclk66_peric", EXYNOS5422_GATE_IP_PERIC,
+           __BIT(2), CLK_SET_RATE_PARENT),
+       CLK_GATE("uart3", "mout_user_aclk66_peric", EXYNOS5422_GATE_IP_PERIC,
+           __BIT(3), CLK_SET_RATE_PARENT),
+       CLK_GATE("i2c0", "mout_user_aclk66_peric", EXYNOS5422_GATE_IP_PERIC,
+           __BIT(6), CLK_SET_RATE_PARENT),
+       CLK_GATE("i2c1", "mout_user_aclk66_peric", EXYNOS5422_GATE_IP_PERIC,
+           __BIT(7), CLK_SET_RATE_PARENT),
+       CLK_GATE("i2c2", "mout_user_aclk66_peric", EXYNOS5422_GATE_IP_PERIC,
+           __BIT(8), CLK_SET_RATE_PARENT),
+       CLK_GATE("i2c3", "mout_user_aclk66_peric", EXYNOS5422_GATE_IP_PERIC,
+           __BIT(9), CLK_SET_RATE_PARENT),
+       CLK_GATE("i2c_hdmi", "mout_user_aclk66_peric", EXYNOS5422_GATE_IP_PERIC,
+           __BIT(14), CLK_SET_RATE_PARENT),
        CLK_GATE("pwm", "mout_user_aclk66_peric", EXYNOS5422_GATE_IP_PERIC,
            __BIT(24), CLK_SET_RATE_PARENT),
 };
diff -r 439dabf95175 -r 3c97ccd522fd sys/arch/arm/samsung/exynos_soc.c
--- a/sys/arch/arm/samsung/exynos_soc.c Thu Jul 05 13:11:03 2018 +0000
+++ b/sys/arch/arm/samsung/exynos_soc.c Thu Jul 05 13:11:57 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: exynos_soc.c,v 1.32 2017/06/10 15:13:18 jmcneill Exp $ */
+/*     $NetBSD: exynos_soc.c,v 1.33 2018/07/05 13:11:58 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2014 The NetBSD Foundation, Inc.
@@ -32,7 +32,7 @@
 #include "opt_exynos.h"
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(1, "$NetBSD: exynos_soc.c,v 1.32 2017/06/10 15:13:18 jmcneill Exp $");
+__KERNEL_RCSID(1, "$NetBSD: exynos_soc.c,v 1.33 2018/07/05 13:11:58 jmcneill Exp $");
 
 #include <sys/param.h>
 #include <sys/bus.h>
@@ -137,47 +137,6 @@
 static int sysctl_cpufreq_target(SYSCTLFN_ARGS);
 static int sysctl_cpufreq_current(SYSCTLFN_ARGS);
 
-/*
- * the early serial console
- */
-#ifdef EXYNOS_CONSOLE_EARLY
-
-#include "opt_sscom.h"
-#include <arm/samsung/sscom_reg.h>
-#include <arm/samsung/sscom_var.h>
-#include <dev/cons.h>
-
-static volatile uint8_t *uart_base;
-
-#define CON_REG(a) (*((volatile uint32_t *)(uart_base + (a))))
-
-static int
-exynos_cngetc(dev_t dv)
-{
-        if ((CON_REG(SSCOM_UTRSTAT) & UTRSTAT_RXREADY) == 0)
-               return -1;
-
-       return CON_REG(SSCOM_URXH);
-}
-
-static void
-exynos_cnputc(dev_t dv, int c)
-{
-       int timo = 150000;
-
-       while ((CON_REG(SSCOM_UFSTAT) & UFSTAT_TXFULL) && --timo > 0);
-
-       CON_REG(SSCOM_UTXH) = c & 0xff;
-}
-
-static struct consdev exynos_earlycons = {
-       .cn_putc = exynos_cnputc,
-       .cn_getc = exynos_cngetc,
-       .cn_pollc = nullcnpollc,
-};
-#endif /* EXYNOS_CONSOLE_EARLY */
-
-
 #ifdef ARM_TRUSTZONE_FIRMWARE
 int
 exynos_do_idle(void)
diff -r 439dabf95175 -r 3c97ccd522fd sys/arch/arm/samsung/exynos_sscom.c
--- a/sys/arch/arm/samsung/exynos_sscom.c       Thu Jul 05 13:11:03 2018 +0000
+++ /dev/null   Thu Jan 01 00:00:00 1970 +0000
@@ -1,305 +0,0 @@
-/*     $NetBSD: exynos_sscom.c,v 1.11 2018/07/04 13:14:51 jmcneill Exp $ */
-
-/*
- * Copyright (c) 2014 Reinoud Zandijk
- * Copyright (c) 2002, 2003 Fujitsu Component Limited
- * Copyright (c) 2002, 2003 Genetec Corporation
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- * 3. Neither the name of The Fujitsu Component Limited nor the name of
- *    Genetec corporation may not be used to endorse or promote products
- *    derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY FUJITSU COMPONENT LIMITED AND GENETEC
- * CORPORATION ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
- * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED.  IN NO EVENT SHALL FUJITSU COMPONENT LIMITED OR GENETEC
- * CORPORATION BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
- * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
- * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
- * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: exynos_sscom.c,v 1.11 2018/07/04 13:14:51 jmcneill Exp $");
-
-#include "opt_sscom.h"
-#include "opt_ddb.h"
-#include "opt_kgdb.h"
-
-#include <sys/param.h>
-#include <sys/systm.h>
-#include <sys/ioctl.h>
-#include <sys/select.h>
-#include <sys/tty.h>
-#include <sys/proc.h>
-#include <sys/conf.h>
-#include <sys/file.h>
-#include <sys/uio.h>
-#include <sys/kernel.h>
-#include <sys/syslog.h>
-#include <sys/types.h>
-#include <sys/device.h>
-#include <sys/malloc.h>
-#include <sys/timepps.h>
-#include <sys/vnode.h>
-
-#include <machine/intr.h>
-#include <sys/bus.h>
-
-#include <arm/samsung/sscom_reg.h>
-#include <arm/samsung/sscom_var.h>
-#include <arm/samsung/exynos_reg.h>
-#include <arm/samsung/exynos_var.h>
-#include <sys/termios.h>
-
-#include <dev/fdt/fdtvar.h>
-
-#include <evbarm/exynos/platform.h>
-
-extern int num_exynos_uarts_entries;
-extern int exynos_uarts[];
-
-static int sscom_match(device_t, cfdata_t, void *);
-static void sscom_attach(device_t, device_t, void *);
-
-CFATTACH_DECL_NEW(exynos_sscom, sizeof(struct sscom_softc), sscom_match,
-    sscom_attach, NULL, NULL);
-
-static const char * const compatible[] = {
-       "samsung,exynos4210-uart",
-       NULL
-};
-
-static int
-sscom_match(device_t parent, cfdata_t cf, void *aux)
-{
-       struct fdt_attach_args * const faa = aux;
-
-       return of_match_compatible(faa->faa_phandle, compatible);
-}
-
-static void
-exynos_unmask_interrupts(struct sscom_softc *sc, int intbits)
-{
-       uint32_t val = bus_space_read_4(sc->sc_iot, sc->sc_ioh, SSCOM_UINTM);
-       val &= ~intbits;
-       bus_space_write_4(sc->sc_iot, sc->sc_ioh, SSCOM_UINTM, val);
-}
-
-static void
-exynos_mask_interrupts(struct sscom_softc *sc, int intbits)
-{
-       uint32_t val = bus_space_read_4(sc->sc_iot, sc->sc_ioh, SSCOM_UINTM);
-       val |= intbits;
-       bus_space_write_4(sc->sc_iot, sc->sc_ioh, SSCOM_UINTM, val);
-}
-
-static void
-exynos_change_txrx_interrupts(struct sscom_softc *sc, bool unmask_p,
-    u_int flags)
-{
-       int intbits = 0;
-       if (flags & SSCOM_HW_RXINT)
-               intbits |= UINT_RXD;
-       if (flags & SSCOM_HW_TXINT)
-               intbits |= UINT_TXD;
-       if (unmask_p) {
-               exynos_unmask_interrupts(sc, intbits);
-       } else {
-               exynos_mask_interrupts(sc, intbits);
-       }
-}
-
-static int
-exynos_pending_interrupts(struct sscom_softc *sc)
-{
-       uint32_t val, ret = 0;
-
-       val = bus_space_read_4(sc->sc_iot, sc->sc_ioh, SSCOM_UINTP);
-       if (val & UINT_RXD)
-               ret |= SSCOM_HW_RXINT;
-       if (val & UINT_TXD)
-               ret |= SSCOM_HW_TXINT;
-
-       return ret;
-}
-
-static void
-exynos_clear_interrupts(struct sscom_softc *sc, u_int flags)
-{
-       uint32_t val = 0;
-
-       if (flags & SSCOM_HW_RXINT)
-               val |= UINT_RXD;
-       if (flags & SSCOM_HW_TXINT)
-               val |= UINT_TXD;
-       bus_space_write_4(sc->sc_iot, sc->sc_ioh, SSCOM_UINTP, val);
-}
-
-static void
-sscom_attach(device_t parent, device_t self, void *aux)
-{
-       struct sscom_softc *sc = device_private(self);
-       struct fdt_attach_args *faa = aux;
-       const int phandle = faa->faa_phandle;
-       bus_space_tag_t bst = faa->faa_bst;
-       bus_space_handle_t bsh;
-       struct clk *clk_uart, *clk_uart_baud0;
-       char intrstr[128];
-       bus_addr_t addr;
-       bus_size_t size;
-
-       if (fdtbus_get_reg(phandle, 0, &addr, &size) != 0) {
-               aprint_error(": couldn't get registers\n");
-               return;
-       }
-
-       if (bus_space_map(bst, addr, size, 0, &bsh) != 0) {
-               aprint_error(": couldn't map registers\n");
-               return;
-       }
-
-       clk_uart = fdtbus_clock_get(phandle, "uart");
-       if (clk_uart != NULL) {
-               if (clk_enable(clk_uart) != 0) {
-                       aprint_error(": couldn't enable uart clock\n");
-                       return;
-               }
-       }
-       clk_uart_baud0 = fdtbus_clock_get(phandle, "clk_uart_baud0");
-       if (clk_uart_baud0 == NULL) {
-               aprint_error(": couldn't get baud clock\n");
-               return;
-       }



Home | Main Index | Thread Index | Old Index