Blame view
drivers/gpio/gpio-ts4800.c
2.04 KB
5041e7914 gpio: add TS-4800... |
1 2 3 4 5 6 7 8 9 10 11 |
/* * GPIO driver for the TS-4800 board * * Copyright (c) 2016 - Savoir-faire Linux * * This file is licensed under the terms of the GNU General Public * License version 2. This program is licensed "as is" without any * warranty of any kind, whether express or implied. */ #include <linux/gpio/driver.h> |
7de9a6c75 gpio: ts4800: fix... |
12 |
#include <linux/module.h> |
5041e7914 gpio: add TS-4800... |
13 14 15 16 17 18 19 20 21 22 23 24 25 |
#include <linux/of_address.h> #include <linux/of_device.h> #include <linux/platform_device.h> #define DEFAULT_PIN_NUMBER 16 #define INPUT_REG_OFFSET 0x00 #define OUTPUT_REG_OFFSET 0x02 #define DIRECTION_REG_OFFSET 0x04 static int ts4800_gpio_probe(struct platform_device *pdev) { struct device_node *node; struct gpio_chip *chip; |
5041e7914 gpio: add TS-4800... |
26 27 28 29 30 31 32 |
void __iomem *base_addr; int retval; u32 ngpios; chip = devm_kzalloc(&pdev->dev, sizeof(struct gpio_chip), GFP_KERNEL); if (!chip) return -ENOMEM; |
f7a6e467e drivers: gpio: ts... |
33 |
base_addr = devm_platform_ioremap_resource(pdev, 0); |
5041e7914 gpio: add TS-4800... |
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
if (IS_ERR(base_addr)) return PTR_ERR(base_addr); node = pdev->dev.of_node; if (!node) return -EINVAL; retval = of_property_read_u32(node, "ngpios", &ngpios); if (retval == -EINVAL) ngpios = DEFAULT_PIN_NUMBER; else if (retval) return retval; retval = bgpio_init(chip, &pdev->dev, 2, base_addr + INPUT_REG_OFFSET, base_addr + OUTPUT_REG_OFFSET, NULL, |
047b2f62c gpio: TS-4800: re... |
49 |
base_addr + DIRECTION_REG_OFFSET, NULL, 0); |
5041e7914 gpio: add TS-4800... |
50 51 52 53 54 |
if (retval) { dev_err(&pdev->dev, "bgpio_init failed "); return retval; } |
5041e7914 gpio: add TS-4800... |
55 56 57 |
chip->ngpio = ngpios; platform_set_drvdata(pdev, chip); |
33ba54ee4 gpio: ts4800: Use... |
58 |
return devm_gpiochip_add_data(&pdev->dev, chip, NULL); |
5041e7914 gpio: add TS-4800... |
59 60 61 62 63 64 |
} static const struct of_device_id ts4800_gpio_of_match[] = { { .compatible = "technologic,ts4800-gpio", }, {}, }; |
91f1551a7 gpio: ts4800: Fix... |
65 |
MODULE_DEVICE_TABLE(of, ts4800_gpio_of_match); |
5041e7914 gpio: add TS-4800... |
66 67 68 69 70 71 72 |
static struct platform_driver ts4800_gpio_driver = { .driver = { .name = "ts4800-gpio", .of_match_table = ts4800_gpio_of_match, }, .probe = ts4800_gpio_probe, |
5041e7914 gpio: add TS-4800... |
73 74 75 76 77 78 79 |
}; module_platform_driver_probe(ts4800_gpio_driver, ts4800_gpio_probe); MODULE_AUTHOR("Julien Grossholtz <julien.grossholtz@savoirfairelinux.com>"); MODULE_DESCRIPTION("TS4800 FPGA GPIO driver"); MODULE_LICENSE("GPL v2"); |