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>
| 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: head/sys/arm/xscale/ixp425/cambria_fled.c 204198 2010-02-22 14:49:52Z rpaulo $");
| 26__FBSDID("$FreeBSD: head/sys/arm/xscale/ixp425/cambria_fled.c 205705 2010-03-26 18:49:43Z rpaulo $");
|
27/* 28 * Cambria Front Panel LED sitting on the I2C bus. 29 */ 30#include <sys/param.h> 31#include <sys/systm.h> 32#include <sys/kernel.h> 33#include <sys/module.h> 34#include <sys/bus.h> 35 36#include <machine/bus.h> 37 38#include <dev/iicbus/iiconf.h> 39#include <dev/led/led.h> 40 41#include "iicbus_if.h" 42 43#define IIC_M_WR 0 /* write operation */ 44#define LED_ADDR 0xae /* slave address */ 45 46struct fled_softc { 47 struct cdev *sc_led; 48}; 49 50static int 51fled_probe(device_t dev) 52{ 53 device_set_desc(dev, "Gateworks Cambria Front Panel LED"); 54 return 0; 55} 56 57static void 58fled_cb(void *arg, int onoff) 59{ 60 uint8_t data[1]; 61 struct iic_msg msgs[1] = { 62 { LED_ADDR, IIC_M_WR, 1, data }, 63 }; 64 device_t dev = arg; 65 66 data[0] = (onoff == 0); /* NB: low true */ 67 (void) iicbus_transfer(dev, msgs, 1); 68} 69 70static int 71fled_attach(device_t dev) 72{ 73 struct fled_softc *sc = device_get_softc(dev); 74 75 sc->sc_led = led_create(fled_cb, dev, "front"); 76
| 27/* 28 * Cambria Front Panel LED sitting on the I2C bus. 29 */ 30#include <sys/param.h> 31#include <sys/systm.h> 32#include <sys/kernel.h> 33#include <sys/module.h> 34#include <sys/bus.h> 35 36#include <machine/bus.h> 37 38#include <dev/iicbus/iiconf.h> 39#include <dev/led/led.h> 40 41#include "iicbus_if.h" 42 43#define IIC_M_WR 0 /* write operation */ 44#define LED_ADDR 0xae /* slave address */ 45 46struct fled_softc { 47 struct cdev *sc_led; 48}; 49 50static int 51fled_probe(device_t dev) 52{ 53 device_set_desc(dev, "Gateworks Cambria Front Panel LED"); 54 return 0; 55} 56 57static void 58fled_cb(void *arg, int onoff) 59{ 60 uint8_t data[1]; 61 struct iic_msg msgs[1] = { 62 { LED_ADDR, IIC_M_WR, 1, data }, 63 }; 64 device_t dev = arg; 65 66 data[0] = (onoff == 0); /* NB: low true */ 67 (void) iicbus_transfer(dev, msgs, 1); 68} 69 70static int 71fled_attach(device_t dev) 72{ 73 struct fled_softc *sc = device_get_softc(dev); 74 75 sc->sc_led = led_create(fled_cb, dev, "front"); 76
|
77 fled_cb(sc, 1); /* Turn on LED */
| 77 fled_cb(dev, 1); /* Turn on LED */
|
78 79 return 0; 80} 81 82static int 83fled_detach(device_t dev) 84{ 85 struct fled_softc *sc = device_get_softc(dev); 86 87 if (sc->sc_led != NULL) 88 led_destroy(sc->sc_led); 89 90 return 0; 91} 92 93static device_method_t fled_methods[] = { 94 DEVMETHOD(device_probe, fled_probe), 95 DEVMETHOD(device_attach, fled_attach), 96 DEVMETHOD(device_detach, fled_detach), 97 98 {0, 0}, 99}; 100 101static driver_t fled_driver = { 102 "fled", 103 fled_methods, 104 sizeof(struct fled_softc), 105}; 106static devclass_t fled_devclass; 107 108DRIVER_MODULE(fled, iicbus, fled_driver, fled_devclass, 0, 0); 109MODULE_VERSION(fled, 1); 110MODULE_DEPEND(fled, iicbus, 1, 1, 1);
| 78 79 return 0; 80} 81 82static int 83fled_detach(device_t dev) 84{ 85 struct fled_softc *sc = device_get_softc(dev); 86 87 if (sc->sc_led != NULL) 88 led_destroy(sc->sc_led); 89 90 return 0; 91} 92 93static device_method_t fled_methods[] = { 94 DEVMETHOD(device_probe, fled_probe), 95 DEVMETHOD(device_attach, fled_attach), 96 DEVMETHOD(device_detach, fled_detach), 97 98 {0, 0}, 99}; 100 101static driver_t fled_driver = { 102 "fled", 103 fled_methods, 104 sizeof(struct fled_softc), 105}; 106static devclass_t fled_devclass; 107 108DRIVER_MODULE(fled, iicbus, fled_driver, fled_devclass, 0, 0); 109MODULE_VERSION(fled, 1); 110MODULE_DEPEND(fled, iicbus, 1, 1, 1);
|