ti_gpio.c (256281) | ti_gpio.c (266105) |
---|---|
1/*- 2 * Copyright (c) 2011 3 * Ben Gray <ben.r.gray@gmail.com>. 4 * All rights reserved. 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions 8 * are met: --- 26 unchanged lines hidden (view full) --- 35 * 36 * Beware the OMA datasheet(s) lists GPIO banks 1-6, whereas I've used 0-5 here 37 * in the code. 38 * 39 * 40 */ 41 42#include <sys/cdefs.h> | 1/*- 2 * Copyright (c) 2011 3 * Ben Gray <ben.r.gray@gmail.com>. 4 * All rights reserved. 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions 8 * are met: --- 26 unchanged lines hidden (view full) --- 35 * 36 * Beware the OMA datasheet(s) lists GPIO banks 1-6, whereas I've used 0-5 here 37 * in the code. 38 * 39 * 40 */ 41 42#include <sys/cdefs.h> |
43__FBSDID("$FreeBSD: stable/10/sys/arm/ti/ti_gpio.c 247391 2013-02-27 08:34:32Z gonzo $"); | 43__FBSDID("$FreeBSD: stable/10/sys/arm/ti/ti_gpio.c 266105 2014-05-15 01:27:53Z loos $"); |
44 45#include <sys/param.h> 46#include <sys/systm.h> 47#include <sys/bus.h> 48 49#include <sys/kernel.h> 50#include <sys/module.h> 51#include <sys/rman.h> --- 486 unchanged lines hidden (view full) --- 538 return (EINVAL); 539 } 540 541 /* Sanity check the pin is not configured as an output */ 542 val = ti_gpio_read_4(sc, bank, TI_GPIO_OE); 543 544 /* Read the value on the pin */ 545 if (val & mask) | 44 45#include <sys/param.h> 46#include <sys/systm.h> 47#include <sys/bus.h> 48 49#include <sys/kernel.h> 50#include <sys/module.h> 51#include <sys/rman.h> --- 486 unchanged lines hidden (view full) --- 538 return (EINVAL); 539 } 540 541 /* Sanity check the pin is not configured as an output */ 542 val = ti_gpio_read_4(sc, bank, TI_GPIO_OE); 543 544 /* Read the value on the pin */ 545 if (val & mask) |
546 *value = (ti_gpio_read_4(sc, bank, TI_GPIO_DATAOUT) & mask) ? 1 : 0; 547 else | |
548 *value = (ti_gpio_read_4(sc, bank, TI_GPIO_DATAIN) & mask) ? 1 : 0; | 546 *value = (ti_gpio_read_4(sc, bank, TI_GPIO_DATAIN) & mask) ? 1 : 0; |
547 else 548 *value = (ti_gpio_read_4(sc, bank, TI_GPIO_DATAOUT) & mask) ? 1 : 0; |
|
549 550 TI_GPIO_UNLOCK(sc); 551 552 return (0); 553} 554 555/** 556 * ti_gpio_pin_toggle - Toggles a given GPIO pin --- 226 unchanged lines hidden (view full) --- 783 bus_release_resource(dev, SYS_RES_IRQ, i, sc->sc_irq_res[i]); 784 } 785 786 TI_GPIO_LOCK_DESTROY(sc); 787 788 return(0); 789} 790 | 549 550 TI_GPIO_UNLOCK(sc); 551 552 return (0); 553} 554 555/** 556 * ti_gpio_pin_toggle - Toggles a given GPIO pin --- 226 unchanged lines hidden (view full) --- 783 bus_release_resource(dev, SYS_RES_IRQ, i, sc->sc_irq_res[i]); 784 } 785 786 TI_GPIO_LOCK_DESTROY(sc); 787 788 return(0); 789} 790 |
791static phandle_t 792ti_gpio_get_node(device_t bus, device_t dev) 793{ 794 795 /* We only have one child, the GPIO bus, which needs our own node. */ 796 return (ofw_bus_get_node(bus)); 797} 798 |
|
791static device_method_t ti_gpio_methods[] = { 792 DEVMETHOD(device_probe, ti_gpio_probe), 793 DEVMETHOD(device_attach, ti_gpio_attach), 794 DEVMETHOD(device_detach, ti_gpio_detach), 795 796 /* GPIO protocol */ 797 DEVMETHOD(gpio_pin_max, ti_gpio_pin_max), 798 DEVMETHOD(gpio_pin_getname, ti_gpio_pin_getname), 799 DEVMETHOD(gpio_pin_getflags, ti_gpio_pin_getflags), 800 DEVMETHOD(gpio_pin_getcaps, ti_gpio_pin_getcaps), 801 DEVMETHOD(gpio_pin_setflags, ti_gpio_pin_setflags), 802 DEVMETHOD(gpio_pin_get, ti_gpio_pin_get), 803 DEVMETHOD(gpio_pin_set, ti_gpio_pin_set), 804 DEVMETHOD(gpio_pin_toggle, ti_gpio_pin_toggle), | 799static device_method_t ti_gpio_methods[] = { 800 DEVMETHOD(device_probe, ti_gpio_probe), 801 DEVMETHOD(device_attach, ti_gpio_attach), 802 DEVMETHOD(device_detach, ti_gpio_detach), 803 804 /* GPIO protocol */ 805 DEVMETHOD(gpio_pin_max, ti_gpio_pin_max), 806 DEVMETHOD(gpio_pin_getname, ti_gpio_pin_getname), 807 DEVMETHOD(gpio_pin_getflags, ti_gpio_pin_getflags), 808 DEVMETHOD(gpio_pin_getcaps, ti_gpio_pin_getcaps), 809 DEVMETHOD(gpio_pin_setflags, ti_gpio_pin_setflags), 810 DEVMETHOD(gpio_pin_get, ti_gpio_pin_get), 811 DEVMETHOD(gpio_pin_set, ti_gpio_pin_set), 812 DEVMETHOD(gpio_pin_toggle, ti_gpio_pin_toggle), |
813 814 /* ofw_bus interface */ 815 DEVMETHOD(ofw_bus_get_node, ti_gpio_get_node), 816 |
|
805 {0, 0}, 806}; 807 808static driver_t ti_gpio_driver = { 809 "gpio", 810 ti_gpio_methods, 811 sizeof(struct ti_gpio_softc), 812}; 813static devclass_t ti_gpio_devclass; 814 815DRIVER_MODULE(ti_gpio, simplebus, ti_gpio_driver, ti_gpio_devclass, 0, 0); | 817 {0, 0}, 818}; 819 820static driver_t ti_gpio_driver = { 821 "gpio", 822 ti_gpio_methods, 823 sizeof(struct ti_gpio_softc), 824}; 825static devclass_t ti_gpio_devclass; 826 827DRIVER_MODULE(ti_gpio, simplebus, ti_gpio_driver, ti_gpio_devclass, 0, 0); |