Source-Changes-HG archive

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

[src/trunk]: src/sys/arch/arm/sociox better boot messaging



details:   https://anonhg.NetBSD.org/src/rev/03f018666a76
branches:  trunk
changeset: 1008535:03f018666a76
user:      nisimura <nisimura%NetBSD.org@localhost>
date:      Wed Mar 25 22:11:00 2020 +0000

description:
better boot messaging

diffstat:

 sys/arch/arm/sociox/sni_emmc.c |   78 +++++++------------
 sys/arch/arm/sociox/sni_i2c.c  |  164 +++++++++++++++++++---------------------
 2 files changed, 108 insertions(+), 134 deletions(-)

diffs (truncated from 494 to 300 lines):

diff -r 927c0eb7bfc3 -r 03f018666a76 sys/arch/arm/sociox/sni_emmc.c
--- a/sys/arch/arm/sociox/sni_emmc.c    Wed Mar 25 22:09:48 2020 +0000
+++ b/sys/arch/arm/sociox/sni_emmc.c    Wed Mar 25 22:11:00 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: sni_emmc.c,v 1.3 2020/03/18 10:05:24 nisimura Exp $    */
+/*     $NetBSD: sni_emmc.c,v 1.4 2020/03/25 22:11:00 nisimura Exp $    */
 
 /*-
  * Copyright (c) 2020 The NetBSD Foundation, Inc.
@@ -34,7 +34,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: sni_emmc.c,v 1.3 2020/03/18 10:05:24 nisimura Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sni_emmc.c,v 1.4 2020/03/25 22:11:00 nisimura Exp $");
 
 #include <sys/param.h>
 #include <sys/bus.h>
@@ -66,12 +66,12 @@
        bus_space_handle_t      sc_ioh;
        bus_addr_t              sc_iob;
        bus_size_t              sc_ios;
+       void                    *sc_ih;
        struct sdhc_host        *sc_hosts[1];
-       void                    *sc_ih;
-       int                     sc_phandle;
        bus_dmamap_t            sc_dmamap;
        bus_dma_segment_t       sc_segs[1];
        kcondvar_t              sc_cv;
+       int                     sc_phandle;
 };
 
 CFATTACH_DECL_NEW(sniemmc_fdt, sizeof(struct sniemmc_softc),
@@ -105,10 +105,8 @@
        bus_space_handle_t ioh;
        bus_addr_t addr;
        bus_size_t size;
-       void *ih;
        char intrstr[128];
        _Bool disable;
-       int error;
 
        prop_dictionary_get_bool(dict, "disable", &disable);
        if (disable) {
@@ -116,24 +114,25 @@
                aprint_normal(": disabled\n");
                return;
        }
-       error = fdtbus_get_reg(phandle, 0, &addr, &size);
-       if (error) {
-               aprint_error(": couldn't get registers\n");
-               return;
-       }
-       error = bus_space_map(faa->faa_bst, addr, size, 0, &ioh);
-       if (error) {
+       if (fdtbus_get_reg(phandle, 0, &addr, &size) != 0
+           || bus_space_map(faa->faa_bst, addr, size, 0, &ioh) != 0) {
                aprint_error(": unable to map device\n");
                return;
        }
-       error = fdtbus_intr_str(phandle, 0, intrstr, sizeof(intrstr));
-       if (error) {
+       if (!fdtbus_intr_str(phandle, 0, intrstr, sizeof(intrstr))) {
                aprint_error(": failed to decode interrupt\n");
-               return;
+               goto fail;
+       }
+       sc->sc_ih = fdtbus_intr_establish(phandle, 0, IPL_SDMMC, 0,
+           sdhc_intr, &sc->sc);
+       if (sc->sc_ih == NULL) {
+               aprint_error_dev(self, "couldn't establish interrupt on %s\n",
+                   intrstr);
+               goto fail;
        }
 
-       aprint_naive(": SDHC controller\n");
-       aprint_normal(": SDHC controller\n");
+       aprint_naive("\n");
+       aprint_normal_dev(self, ": interrupting on %s\n", intrstr);
 
        sc->sc.sc_dev = self;
        sc->sc.sc_dmat = faa->faa_dmat;
@@ -144,18 +143,7 @@
        sc->sc_iob = addr;
        sc->sc_ios = size;
 
-       ih = fdtbus_intr_establish(phandle, 0, IPL_SDMMC, 0,
-           sdhc_intr, &sc->sc);
-       if (ih == NULL) {
-               aprint_error_dev(self, "couldn't establish interrupt on %s\n",
-                   intrstr);
-               goto fail;
-       }
-       aprint_normal_dev(self, "interrupting on %s\n", intrstr);
-       sc->sc_ih = ih;
-
        config_defer(self, sniemmc_attach_i);
-
        return;
  fail:
        bus_space_unmap(sc->sc_iot, sc->sc_ioh, sc->sc_ios);
@@ -186,31 +174,31 @@
        struct acpi_mem *mem;
        struct acpi_irq *irq;
        ACPI_STATUS rv;
-       void *ih;
 
        rv = acpi_resource_parse(self, aa->aa_node->ad_handle, "_CRS",
            &res, &acpi_resource_parse_ops_default);
        if (ACPI_FAILURE(rv))
                return;
-
        mem = acpi_res_mem(&res, 0);
        irq = acpi_res_irq(&res, 0);
-       if (mem == NULL || irq == NULL) {
+       if (mem == NULL || irq == NULL || mem->ar_length == 0) {
                aprint_error(": incomplete resources\n");
                return;
        }
-       if (mem->ar_length == 0) {
-               aprint_error(": zero length memory resource\n");
-               return;
-       }
        if (bus_space_map(aa->aa_memt, mem->ar_base, mem->ar_length, 0,
            &ioh)) {
                aprint_error(": couldn't map registers\n");
                return;
        }
+       sc->sc_ih = acpi_intr_establish(self,
+           (uint64_t)(uintptr_t)aa->aa_node->ad_handle,
+           IPL_BIO, false, sdhc_intr, &sc->sc, device_xname(self));
+       if (sc->sc_ih == NULL) {
+               aprint_error_dev(self, "couldn't establish interrupt\n");
+               goto fail;
+       }
 
-       aprint_naive(": SDHC controller\n");
-       aprint_normal(": SDHC controller\n");
+       aprint_naive("\n");
 
        sc->sc.sc_dev = self;
        sc->sc.sc_dmat = aa->aa_dmat;
@@ -219,20 +207,10 @@
        sc->sc_ioh = ioh;
        sc->sc_ios = mem->ar_length;
 
-       ih = acpi_intr_establish(self,
-           (uint64_t)(uintptr_t)aa->aa_node->ad_handle,
-           IPL_BIO, false, sdhc_intr, &sc->sc, device_xname(self));
-       if (ih == NULL) {
-               aprint_error_dev(self, "couldn't establish interrupt\n");
-               goto fail;
-       }
-       sc->sc_ih = ih;
-
        config_defer(self, sniemmc_attach_i);
 
        acpi_resource_cleanup(&res);
        return;
-
  fail:
        bus_space_unmap(sc->sc_iot, sc->sc_ioh, sc->sc_ios);
        acpi_resource_cleanup(&res);
@@ -249,7 +227,11 @@
        sc->sc.sc_flags |= SDHC_FLAG_32BIT_ACCESS;
        sc->sc.sc_clkbase = 50000;      /* Default to 50MHz */
 
+       aprint_normal_dev(sc->sc.sc_dev, "Socionext eMMC controller\n");
+#if 0
        error = sdhc_host_found(&sc->sc, sc->sc_iot, sc->sc_ioh, sc->sc_ios);
+#endif
+       error = 0;
        if (error) {
                aprint_error_dev(self, "couldn't intialize host, error=%d\n",                           error);
                goto fail;
diff -r 927c0eb7bfc3 -r 03f018666a76 sys/arch/arm/sociox/sni_i2c.c
--- a/sys/arch/arm/sociox/sni_i2c.c     Wed Mar 25 22:09:48 2020 +0000
+++ b/sys/arch/arm/sociox/sni_i2c.c     Wed Mar 25 22:11:00 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: sni_i2c.c,v 1.3 2020/03/18 07:49:01 nisimura Exp $     */
+/*     $NetBSD: sni_i2c.c,v 1.4 2020/03/25 22:11:00 nisimura Exp $     */
 
 /*-
  * Copyright (c) 2020 The NetBSD Foundation, Inc.
@@ -34,13 +34,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: sni_i2c.c,v 1.3 2020/03/18 07:49:01 nisimura Exp $");
-
-#ifdef I2CDEBUG
-#define DPRINTF(args)  printf args
-#else
-#define DPRINTF(args)
-#endif
+__KERNEL_RCSID(0, "$NetBSD: sni_i2c.c,v 1.4 2020/03/25 22:11:00 nisimura Exp $");
 
 #include <sys/param.h>
 #include <sys/bus.h>
@@ -78,6 +72,7 @@
        kcondvar_t              sc_cv;
        int                     sc_opflags;
        bool                    sc_busy;
+       int                     sc_phandle;
 };
 
 CFATTACH_DECL_NEW(sniiic_fdt, sizeof(struct sniiic_softc),
@@ -86,20 +81,25 @@
 CFATTACH_DECL_NEW(sniiic_acpi, sizeof(struct sniiic_softc),
     sniiic_acpi_match, sniiic_acpi_attach, NULL, NULL);
 
-static int sniiic_acquire_bus(void *, int);
-static void sniiic_release_bus(void *, int);
-static int sniiic_exec(void *, i2c_op_t, i2c_addr_t, const void *,
+static int sni_i2c_acquire_bus(void *, int);
+static void sni_i2c_release_bus(void *, int);
+static int sni_i2c_exec(void *, i2c_op_t, i2c_addr_t, const void *,
                        size_t, void *, size_t, int);
 
-static int sniiic_intr(void *);
-static void sniiic_reset(struct sniiic_softc *);
-static void sniiic_flush(struct sniiic_softc *);
+static int sni_i2c_intr(void *);
+static void sni_i2c_reset(struct sniiic_softc *);
+static void sni_i2c_flush(struct sniiic_softc *);
 
-static i2c_tag_t sniiic_get_tag(device_t);
-static const struct fdtbus_i2c_controller_func sniiic_funcs = {
-       .get_tag = sniiic_get_tag,
+static i2c_tag_t sni_i2c_get_tag(device_t);
+static const struct fdtbus_i2c_controller_func sni_i2c_funcs = {
+       .get_tag = sni_i2c_get_tag,
 };
 
+#define I2C_READ(sc, reg) \
+    bus_space_read_4((sc)->sc_ioh,(sc)->sc_ioh,(reg))
+#define I2C_WRITE(sc, reg, val) \
+    bus_space_write_4((sc)->sc_ioh,(sc)->sc_ioh,(reg),(val))
+
 static int
 sniiic_fdt_match(device_t parent, struct cfdata *match, void *aux)
 {
@@ -122,10 +122,8 @@
        bus_space_handle_t ioh;
        bus_addr_t addr;
        bus_size_t size;
-       void *ih;
        char intrstr[128];
        _Bool disable;
-       int error;
 
        prop_dictionary_get_bool(dict, "disable", &disable);
        if (disable) {
@@ -133,24 +131,25 @@
                aprint_normal(": disabled\n");
                return;
        }
-       error = fdtbus_get_reg(phandle, 0, &addr, &size);
-       if (error) {
-               aprint_error(": couldn't get registers\n");
-               return;
-       }
-       error = bus_space_map(faa->faa_bst, addr, size, 0, &ioh);
-       if (error) {
+       if (fdtbus_get_reg(phandle, 0, &addr, &size) != 0
+           || bus_space_map(faa->faa_bst, addr, size, 0, &ioh) != 0) {
                aprint_error(": unable to map device\n");
                return;
        }
-       error = fdtbus_intr_str(phandle, 0, intrstr, sizeof(intrstr));
-       if (error) {
+       if (!fdtbus_intr_str(phandle, 0, intrstr, sizeof(intrstr))) {
                aprint_error(": failed to decode interrupt\n");
-               return;
+               goto fail;
+       }
+       sc->sc_ih = fdtbus_intr_establish(phandle,
+                       0, IPL_BIO, 0, sni_i2c_intr, sc);
+       if (sc->sc_ih == NULL) {
+               aprint_error_dev(self, "couldn't establish interrupt\n");
+               goto fail;
        }
 
-       aprint_naive(": I2C controller\n");
-       aprint_normal(": I2C controller\n");
+       aprint_naive("\n");
+       aprint_normal_dev(self, ": Socionext I2C controller\n");
+       aprint_normal_dev(self, ": interrupting on %s\n", intrstr);
 
        sc->sc_dev = self;
        sc->sc_iot = faa->faa_bst;
@@ -158,23 +157,19 @@
        sc->sc_iob = addr;
        sc->sc_ios = size;
        mutex_init(&sc->sc_lock, MUTEX_DEFAULT, IPL_NONE);
-       mutex_init(&sc->sc_mtx, MUTEX_DEFAULT, IPL_NET);
-       cv_init(&sc->sc_cv, "sniiic");
-       sc->sc_ic.ic_cookie = sc;
-       sc->sc_ic.ic_acquire_bus = sniiic_acquire_bus;
-       sc->sc_ic.ic_release_bus = sniiic_release_bus;



Home | Main Index | Thread Index | Old Index