The Design and Implementation of the FreeBSD Operating System, Second Edition
Now available: The Design and Implementation of the FreeBSD Operating System (Second Edition)


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]

FreeBSD/Linux Kernel Cross Reference
sys/arm/xscale/ixp425/cambria_led.c

Version: -  FREEBSD  -  FREEBSD-12-STABLE  -  FREEBSD-12-0  -  FREEBSD-11-STABLE  -  FREEBSD-11-2  -  FREEBSD-11-1  -  FREEBSD-11-0  -  FREEBSD-10-STABLE  -  FREEBSD-10-4  -  FREEBSD-10-3  -  FREEBSD-10-2  -  FREEBSD-10-1  -  FREEBSD-10-0  -  FREEBSD-9-STABLE  -  FREEBSD-9-3  -  FREEBSD-9-2  -  FREEBSD-9-1  -  FREEBSD-9-0  -  FREEBSD-8-STABLE  -  FREEBSD-8-4  -  FREEBSD-8-3  -  FREEBSD-8-2  -  FREEBSD-8-1  -  FREEBSD-8-0  -  FREEBSD-7-STABLE  -  FREEBSD-7-4  -  FREEBSD-7-3  -  FREEBSD-7-2  -  FREEBSD-7-1  -  FREEBSD-7-0  -  FREEBSD-6-STABLE  -  FREEBSD-6-4  -  FREEBSD-6-3  -  FREEBSD-6-2  -  FREEBSD-6-1  -  FREEBSD-6-0  -  FREEBSD-5-STABLE  -  FREEBSD-5-5  -  FREEBSD-5-4  -  FREEBSD-5-3  -  FREEBSD-5-2  -  FREEBSD-5-1  -  FREEBSD-5-0  -  FREEBSD-4-STABLE  -  FREEBSD-3-STABLE  -  FREEBSD22  -  linux-2.6  -  linux-2.4.22  -  MK83  -  MK84  -  PLAN9  -  DFBSD  -  NETBSD  -  NETBSD5  -  NETBSD4  -  NETBSD3  -  NETBSD20  -  OPENBSD  -  xnu-517  -  xnu-792  -  xnu-792.6.70  -  xnu-1228  -  xnu-1456.1.26  -  xnu-1699.24.8  -  xnu-2050.18.24  -  OPENSOLARIS  -  minix-3-1-1 
SearchContext: -  none  -  3  -  10 

    1 /*-
    2  * Copyright (c) 2008 Sam Leffler.  All rights reserved.
    3  *
    4  * Redistribution and use in source and binary forms, with or without
    5  * modification, are permitted provided that the following conditions
    6  * are met:
    7  * 1. Redistributions of source code must retain the above copyright
    8  *    notice, this list of conditions and the following disclaimer.
    9  * 2. Redistributions in binary form must reproduce the above copyright
   10  *    notice, this list of conditions and the following disclaimer in the
   11  *    documentation and/or other materials provided with the distribution.
   12  *
   13  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
   14  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   15  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
   16  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
   17  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
   18  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
   19  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
   20  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
   21  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
   22  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
   23  */
   24 
   25 #include <sys/cdefs.h>
   26 __FBSDID("$FreeBSD: releng/10.3/sys/arm/xscale/ixp425/cambria_led.c 194015 2009-06-11 17:05:13Z avg $");
   27 
   28 /*
   29  * Gateworks Cambria Octal LED Latch driver.
   30  */
   31 #include <sys/param.h>
   32 #include <sys/systm.h>
   33 #include <sys/kernel.h>
   34 #include <sys/module.h>
   35 #include <sys/bus.h>
   36 
   37 #include <machine/armreg.h>
   38 
   39 #include <arm/xscale/ixp425/ixp425reg.h>
   40 #include <arm/xscale/ixp425/ixp425var.h>
   41 
   42 #include <dev/led/led.h>
   43 
   44 struct led_softc {
   45         device_t                sc_dev;
   46         bus_space_tag_t         sc_iot;
   47         bus_space_handle_t      sc_ioh;
   48         struct cdev             *sc_leds[8];
   49         uint8_t                 sc_latch;
   50 };
   51 
   52 static void
   53 update_latch(struct led_softc *sc, int bit, int onoff)
   54 {
   55         if (onoff)
   56                 sc->sc_latch &= ~bit;
   57         else
   58                 sc->sc_latch |= bit;
   59         bus_space_write_1(sc->sc_iot, sc->sc_ioh, 0, sc->sc_latch);
   60 }
   61 static void led_A(void *arg, int onoff) { update_latch(arg, 1<<0, onoff); }
   62 static void led_B(void *arg, int onoff) { update_latch(arg, 1<<1, onoff); }
   63 static void led_C(void *arg, int onoff) { update_latch(arg, 1<<2, onoff); }
   64 static void led_D(void *arg, int onoff) { update_latch(arg, 1<<3, onoff); }
   65 static void led_E(void *arg, int onoff) { update_latch(arg, 1<<4, onoff); }
   66 static void led_F(void *arg, int onoff) { update_latch(arg, 1<<5, onoff); }
   67 static void led_G(void *arg, int onoff) { update_latch(arg, 1<<6, onoff); }
   68 static void led_H(void *arg, int onoff) { update_latch(arg, 1<<7, onoff); }
   69 
   70 static int
   71 led_probe(device_t dev)
   72 {
   73         device_set_desc(dev, "Gateworks Octal LED Latch");
   74         return (0);
   75 }
   76 
   77 static int
   78 led_attach(device_t dev)
   79 {
   80         struct led_softc *sc = device_get_softc(dev);
   81         struct ixp425_softc *sa = device_get_softc(device_get_parent(dev));
   82 
   83         sc->sc_dev = dev;
   84         sc->sc_iot = sa->sc_iot;
   85         /* NB: write anywhere works, use first location */
   86         if (bus_space_map(sc->sc_iot, CAMBRIA_OCTAL_LED_HWBASE, sizeof(uint8_t),
   87             0, &sc->sc_ioh)) {
   88                 device_printf(dev, "cannot map LED latch (0x%lx)",
   89                     CAMBRIA_OCTAL_LED_HWBASE);
   90                 return ENXIO;
   91         }
   92 
   93         sc->sc_leds[0] = led_create(led_A, sc, "A");
   94         sc->sc_leds[1] = led_create(led_B, sc, "B");
   95         sc->sc_leds[2] = led_create(led_C, sc, "C");
   96         sc->sc_leds[3] = led_create(led_D, sc, "D");
   97         sc->sc_leds[4] = led_create(led_E, sc, "E");
   98         sc->sc_leds[5] = led_create(led_F, sc, "F");
   99         sc->sc_leds[6] = led_create(led_G, sc, "G");
  100         sc->sc_leds[7] = led_create(led_H, sc, "H");
  101 
  102         return 0;
  103 }
  104 
  105 static int
  106 led_detach(device_t dev)
  107 {
  108         struct led_softc *sc = device_get_softc(dev);
  109         int i;
  110 
  111         for (i = 0; i < 8; i++) {
  112                 struct cdev *led = sc->sc_leds[i];
  113                 if (led != NULL)
  114                         led_destroy(led);
  115         }
  116         return (0);
  117 }
  118 
  119 static device_method_t led_methods[] = {
  120         DEVMETHOD(device_probe,         led_probe),
  121         DEVMETHOD(device_attach,        led_attach),
  122         DEVMETHOD(device_detach,        led_detach),
  123 
  124         {0, 0},
  125 };
  126 
  127 static driver_t led_driver = {
  128         "led_cambria",
  129         led_methods,
  130         sizeof(struct led_softc),
  131 };
  132 static devclass_t led_devclass;
  133 DRIVER_MODULE(led_cambria, ixp, led_driver, led_devclass, 0, 0);

Cache object: 9259ba446eece7e842a69a0dc6d90895


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]


This page is part of the FreeBSD/Linux Linux Kernel Cross-Reference, and was automatically generated using a modified version of the LXR engine.