Source-Changes-HG archive

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

[src/trunk]: src/sys/arch/evbarm/tsarm Add sysctl tree hw.tspld.* for query o...



details:   https://anonhg.NetBSD.org/src/rev/eb8958f8fbd4
branches:  trunk
changeset: 574218:eb8958f8fbd4
user:      joff <joff%NetBSD.org@localhost>
date:      Thu Feb 24 03:52:22 2005 +0000

description:
Add sysctl tree hw.tspld.* for query of jumper states, pld revision,
board model/options, etc...

diffstat:

 sys/arch/evbarm/tsarm/tspld.c |  190 ++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 183 insertions(+), 7 deletions(-)

diffs (263 lines):

diff -r 129199365e60 -r eb8958f8fbd4 sys/arch/evbarm/tsarm/tspld.c
--- a/sys/arch/evbarm/tsarm/tspld.c     Wed Feb 23 22:56:20 2005 +0000
+++ b/sys/arch/evbarm/tsarm/tspld.c     Thu Feb 24 03:52:22 2005 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: tspld.c,v 1.4 2005/01/09 21:35:51 joff Exp $   */
+/*     $NetBSD: tspld.c,v 1.5 2005/02/24 03:52:22 joff Exp $   */
 
 /*-
  * Copyright (c) 2004 Jesse Off
@@ -35,9 +35,10 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: tspld.c,v 1.4 2005/01/09 21:35:51 joff Exp $");
+__KERNEL_RCSID(0, "$NetBSD: tspld.c,v 1.5 2005/02/24 03:52:22 joff Exp $");
 
 #include <sys/param.h>
+#include <sys/sysctl.h>
 #include <sys/systm.h>
 #include <sys/device.h>
 #include <sys/wdog.h>
@@ -71,6 +72,14 @@
        bus_space_handle_t      sc_wdogfeed_ioh;        
        bus_space_handle_t      sc_wdogctrl_ioh;        
        struct sysmon_wdog      sc_wdog;
+       unsigned char *         sc_com2mode;
+       unsigned char *         sc_model;
+       unsigned char           sc_pldrev[4];
+       uint32_t                sc_rs485;
+       uint32_t                sc_adc;
+       uint32_t                sc_jp[6];
+       uint32_t                sc_blaster_present;
+       uint32_t                sc_blaster_boot;
 };
 
 CFATTACH_DECL(tspld, sizeof(struct tspld_softc),
@@ -96,17 +105,59 @@
        int     i, rev, features, jp, model;
        struct tspld_softc *sc = (struct tspld_softc *)self;
        bus_space_handle_t      ioh;
+        struct sysctlnode *node;
+
+       if (sysctl_createv(NULL, 0, NULL, NULL,
+                               CTLFLAG_PERMANENT, CTLTYPE_NODE, "hw",
+                               NULL, NULL, 0, NULL, 0,
+                               CTL_HW, CTL_EOL) != 0) {
+               printf("%s: could not create sysctl\n",
+                       sc->sc_dev.dv_xname);
+               return;
+       }
+       if (sysctl_createv(NULL, 0, NULL, &node,
+                               0, CTLTYPE_NODE, "tspld",
+                               NULL,
+                               NULL, 0, NULL, 0,
+                               CTL_HW, CTL_CREATE, CTL_EOL) != 0) {
+                printf("%s: could not create sysctl\n",
+                       sc->sc_dev.dv_xname);
+               return;
+       }
 
        sc->sc_iot = &ep93xx_bs_tag;
         bus_space_map(sc->sc_iot, TS7XXX_IO16_HWBASE + TS7XXX_MODEL, 2, 0, 
                &ioh);
        model = bus_space_read_2(sc->sc_iot, ioh, 0) & 0x7;
+       sc->sc_model = (model ? "TS-7250" : "TS-7200");
+       if ((i = sysctl_createv(NULL, 0, NULL, NULL,
+                               0, CTLTYPE_STRING, "boardmodel",
+                               SYSCTL_DESCR("Technologic Systems board model"),
+                               NULL, 0, sc->sc_model, 0,
+                               CTL_HW, node->sysctl_num, CTL_CREATE, CTL_EOL))
+                               != 0) {
+                printf("%s: could not create sysctl\n", 
+                       sc->sc_dev.dv_xname);
+               return;
+       }
        bus_space_unmap(sc->sc_iot, ioh, 2);
 
         bus_space_map(sc->sc_iot, TS7XXX_IO16_HWBASE + TS7XXX_PLDREV, 2, 0, 
                &ioh);
        rev = bus_space_read_2(sc->sc_iot, ioh, 0) & 0x7;
        rev = 'A' + rev - 1;
+       sc->sc_pldrev[0] = rev;
+       sc->sc_pldrev[1] = 0;
+       if ((i = sysctl_createv(NULL, 0, NULL, NULL,
+                               0, CTLTYPE_STRING, "pldrev",
+                               SYSCTL_DESCR("CPLD revision"),
+                               NULL, 0, sc->sc_pldrev, 0,
+                               CTL_HW, node->sysctl_num, CTL_CREATE, CTL_EOL))
+                               != 0) {
+                printf("%s: could not create sysctl\n", 
+                       sc->sc_dev.dv_xname);
+               return;
+       }
        bus_space_unmap(sc->sc_iot, ioh, 2);
 
         bus_space_map(sc->sc_iot, TS7XXX_IO16_HWBASE + TS7XXX_FEATURES, 2, 0, 
@@ -120,29 +171,153 @@
        jp = (~((i & 0x18) >> 1) & 0xc) | (i & 0x3);
        bus_space_unmap(sc->sc_iot, ioh, 1);
 
+       if ((i = sysctl_createv(NULL, 0, NULL, NULL,
+                               0, CTLTYPE_INT, "blaster_present",
+                               SYSCTL_DESCR("Whether or not a TS-9420/TS-9202 blaster board is connected"),
+                               NULL, 0, &sc->sc_blaster_present, 0,
+                               CTL_HW, node->sysctl_num, CTL_CREATE, CTL_EOL))
+                               != 0) {
+                printf("%s: could not create sysctl\n", 
+                       sc->sc_dev.dv_xname);
+               return;
+       }
+       if ((i = sysctl_createv(NULL, 0, NULL, NULL,
+                               0, CTLTYPE_INT, "blaster_boot",
+                               SYSCTL_DESCR("Whether or not a blast board was used to boot"),
+                               NULL, 0, &sc->sc_blaster_boot, 0,
+                               CTL_HW, node->sysctl_num, CTL_CREATE, CTL_EOL))
+                               != 0) {
+                printf("%s: could not create sysctl\n", 
+                       sc->sc_dev.dv_xname);
+               return;
+       }
         bus_space_map(sc->sc_iot, TS7XXX_IO16_HWBASE + TS7XXX_STATUS2, 2, 0, 
                &ioh);
        i = bus_space_read_2(sc->sc_iot, ioh, 0) & 0x1;
+       sc->sc_blaster_boot = sc->sc_blaster_present = 0;
+       if (i & 0x2)
+               sc->sc_blaster_boot = 1;
+       if (i & 0x4)    
+               sc->sc_blaster_present = 1;
        jp |= (i << 4);
        bus_space_unmap(sc->sc_iot, ioh, 1);
 
-       printf(": Technologic Systems TS-7%s rev %c, features 0x%x", 
-               (model ? "250" : "200"), rev, features);
-       if (features == 0x1) 
+       if ((i = sysctl_createv(NULL, 0, NULL, NULL,
+                               0, CTLTYPE_INT, "rs485_avail",
+                               SYSCTL_DESCR("RS485 level driver for COM2 available"),
+                               NULL, 0, &sc->sc_rs485, 0,
+                               CTL_HW, node->sysctl_num, CTL_CREATE, CTL_EOL))
+                               != 0) {
+                printf("%s: could not create sysctl\n", 
+                       sc->sc_dev.dv_xname);
+               return;
+       }
+       sc->sc_com2mode = "rs232";
+       if ((i = sysctl_createv(NULL, 0, NULL, NULL,
+                               0, CTLTYPE_STRING, "com2_mode",
+                               SYSCTL_DESCR("line driver type for COM2"),
+                               NULL, 0, sc->sc_com2mode, 0,
+                               CTL_HW, node->sysctl_num, CTL_CREATE, CTL_EOL))
+                               != 0) {
+                printf("%s: could not create sysctl\n", 
+                       sc->sc_dev.dv_xname);
+               return;
+       }
+       if ((i = sysctl_createv(NULL, 0, NULL, NULL,
+                               0, CTLTYPE_INT, "max197adc_avail",
+                               SYSCTL_DESCR("Maxim 197 Analog to Digital Converter available"),
+                               NULL, 0, &sc->sc_adc, 0,
+                               CTL_HW, node->sysctl_num, CTL_CREATE, CTL_EOL))
+                               != 0) {
+                printf("%s: could not create sysctl\n", 
+                       sc->sc_dev.dv_xname);
+               return;
+       }
+       printf(": Technologic Systems %s rev %c, features 0x%x", 
+               sc->sc_model, rev, features);
+       sc->sc_adc = sc->sc_rs485 = 0;
+       if (features == 0x1) {
                printf("<MAX197-ADC>");
-       else if (features == 0x2) 
+               sc->sc_adc = 1;
+       } else if (features == 0x2) {
                printf("<RS485>");
-       else if (features == 0x3) 
+               sc->sc_rs485 = 1;
+       } else if (features == 0x3) {
                printf("<MAX197-ADC,RS485>");
+               sc->sc_adc = sc->sc_rs485 = 1;
+       }
        printf("\n");
+       if ((i = sysctl_createv(NULL, 0, NULL, NULL,
+                               0, CTLTYPE_INT, "jp1",
+                               SYSCTL_DESCR("onboard jumper setting"),
+                               NULL, 0, &sc->sc_jp[0], 0,
+                               CTL_HW, node->sysctl_num, CTL_CREATE, CTL_EOL))
+                               != 0) {
+                printf("%s: could not create sysctl\n", 
+                       sc->sc_dev.dv_xname);
+               return;
+       }
+       if ((i = sysctl_createv(NULL, 0, NULL, NULL,
+                               0, CTLTYPE_INT, "jp2",
+                               SYSCTL_DESCR("onboard jumper setting"),
+                               NULL, 0, &sc->sc_jp[1], 0,
+                               CTL_HW, node->sysctl_num, CTL_CREATE, CTL_EOL))
+                               != 0) {
+                printf("%s: could not create sysctl\n", 
+                       sc->sc_dev.dv_xname);
+               return;
+       }
+       if ((i = sysctl_createv(NULL, 0, NULL, NULL,
+                               0, CTLTYPE_INT, "jp3",
+                               SYSCTL_DESCR("onboard jumper setting"),
+                               NULL, 0, &sc->sc_jp[2], 0,
+                               CTL_HW, node->sysctl_num, CTL_CREATE, CTL_EOL))
+                               != 0) {
+                printf("%s: could not create sysctl\n", 
+                       sc->sc_dev.dv_xname);
+               return;
+       }
+       if ((i = sysctl_createv(NULL, 0, NULL, NULL,
+                               0, CTLTYPE_INT, "jp4",
+                               SYSCTL_DESCR("onboard jumper setting"),
+                               NULL, 0, &sc->sc_jp[3], 0,
+                               CTL_HW, node->sysctl_num, CTL_CREATE, CTL_EOL))
+                               != 0) {
+                printf("%s: could not create sysctl\n", 
+                       sc->sc_dev.dv_xname);
+               return;
+       }
+       if ((i = sysctl_createv(NULL, 0, NULL, NULL,
+                               0, CTLTYPE_INT, "jp5",
+                               SYSCTL_DESCR("onboard jumper setting"),
+                               NULL, 0, &sc->sc_jp[4], 0,
+                               CTL_HW, node->sysctl_num, CTL_CREATE, CTL_EOL))
+                               != 0) {
+                printf("%s: could not create sysctl\n", 
+                       sc->sc_dev.dv_xname);
+               return;
+       }
+       if ((i = sysctl_createv(NULL, 0, NULL, NULL,
+                               0, CTLTYPE_INT, "jp6",
+                               SYSCTL_DESCR("onboard jumper setting"),
+                               NULL, 0, &sc->sc_jp[5], 0,
+                               CTL_HW, node->sysctl_num, CTL_CREATE, CTL_EOL))
+                               != 0) {
+                printf("%s: could not create sysctl\n", 
+                       sc->sc_dev.dv_xname);
+               return;
+       }
        printf("%s: jumpers 0x%x", sc->sc_dev.dv_xname, jp);
        if (jp) {
                printf("<");
                for(i = 0; i < 5; i++) {
                        if (jp & (1 << i)) {
+                               sc->sc_jp[i + 1] = 1;
                                printf("JP%d", i + 2);
                                jp &= ~(1 << i);
                                if (jp) printf(",");
+                       } else {
+                               sc->sc_jp[i + 2] = 0;
                        }
                }
                printf(">");
@@ -162,6 +337,7 @@
        sysmon_wdog_register(&sc->sc_wdog);
        tspld_wdog_setmode(&sc->sc_wdog);
 
+
        /* Set the on board peripherals bus callback */
        config_defer(self, tspld_callback);
 }



Home | Main Index | Thread Index | Old Index