Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

at v6.0-rc2 84 lines 1.9 kB view raw
1// SPDX-License-Identifier: GPL-2.0-only 2/* 3 * Philips UCB1400 GPIO driver 4 * 5 * Author: Marek Vasut <marek.vasut@gmail.com> 6 */ 7 8#include <linux/module.h> 9#include <linux/ucb1400.h> 10 11static int ucb1400_gpio_dir_in(struct gpio_chip *gc, unsigned off) 12{ 13 struct ucb1400_gpio *gpio; 14 gpio = gpiochip_get_data(gc); 15 ucb1400_gpio_set_direction(gpio->ac97, off, 0); 16 return 0; 17} 18 19static int ucb1400_gpio_dir_out(struct gpio_chip *gc, unsigned off, int val) 20{ 21 struct ucb1400_gpio *gpio; 22 gpio = gpiochip_get_data(gc); 23 ucb1400_gpio_set_direction(gpio->ac97, off, 1); 24 ucb1400_gpio_set_value(gpio->ac97, off, val); 25 return 0; 26} 27 28static int ucb1400_gpio_get(struct gpio_chip *gc, unsigned off) 29{ 30 struct ucb1400_gpio *gpio; 31 32 gpio = gpiochip_get_data(gc); 33 return !!ucb1400_gpio_get_value(gpio->ac97, off); 34} 35 36static void ucb1400_gpio_set(struct gpio_chip *gc, unsigned off, int val) 37{ 38 struct ucb1400_gpio *gpio; 39 gpio = gpiochip_get_data(gc); 40 ucb1400_gpio_set_value(gpio->ac97, off, val); 41} 42 43static int ucb1400_gpio_probe(struct platform_device *dev) 44{ 45 struct ucb1400_gpio *ucb = dev_get_platdata(&dev->dev); 46 int err = 0; 47 48 if (!(ucb && ucb->gpio_offset)) { 49 err = -EINVAL; 50 goto err; 51 } 52 53 platform_set_drvdata(dev, ucb); 54 55 ucb->gc.label = "ucb1400_gpio"; 56 ucb->gc.base = ucb->gpio_offset; 57 ucb->gc.ngpio = 10; 58 ucb->gc.owner = THIS_MODULE; 59 60 ucb->gc.direction_input = ucb1400_gpio_dir_in; 61 ucb->gc.direction_output = ucb1400_gpio_dir_out; 62 ucb->gc.get = ucb1400_gpio_get; 63 ucb->gc.set = ucb1400_gpio_set; 64 ucb->gc.can_sleep = true; 65 66 err = devm_gpiochip_add_data(&dev->dev, &ucb->gc, ucb); 67 68err: 69 return err; 70 71} 72 73static struct platform_driver ucb1400_gpio_driver = { 74 .probe = ucb1400_gpio_probe, 75 .driver = { 76 .name = "ucb1400_gpio" 77 }, 78}; 79 80module_platform_driver(ucb1400_gpio_driver); 81 82MODULE_DESCRIPTION("Philips UCB1400 GPIO driver"); 83MODULE_LICENSE("GPL"); 84MODULE_ALIAS("platform:ucb1400_gpio");