Release 4.7 drivers/gpio/gpio-tps65910.c
/*
* TI TPS6591x GPIO driver
*
* Copyright 2010 Texas Instruments Inc.
*
* Author: Graeme Gregory <gg@slimlogic.co.uk>
* Author: Jorge Eduardo Candelaria <jedu@slimlogic.co.uk>
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at your
* option) any later version.
*
*/
#include <linux/kernel.h>
#include <linux/init.h>
#include <linux/errno.h>
#include <linux/gpio.h>
#include <linux/i2c.h>
#include <linux/platform_device.h>
#include <linux/mfd/tps65910.h>
#include <linux/of_device.h>
struct tps65910_gpio {
struct gpio_chip gpio_chip;
struct tps65910 *tps65910;
};
static int tps65910_gpio_get(struct gpio_chip *gc, unsigned offset)
{
struct tps65910_gpio *tps65910_gpio = gpiochip_get_data(gc);
struct tps65910 *tps65910 = tps65910_gpio->tps65910;
unsigned int val;
tps65910_reg_read(tps65910, TPS65910_GPIO0 + offset, &val);
if (val & GPIO_STS_MASK)
return 1;
return 0;
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
graeme gregory | graeme gregory | 43 | 70.49% | 1 | 20.00% |
laxman dewangan | laxman dewangan | 11 | 18.03% | 1 | 20.00% |
rhyland klein | rhyland klein | 3 | 4.92% | 1 | 20.00% |
jorge eduardo candelaria | jorge eduardo candelaria | 3 | 4.92% | 1 | 20.00% |
linus walleij | linus walleij | 1 | 1.64% | 1 | 20.00% |
| Total | 61 | 100.00% | 5 | 100.00% |
static void tps65910_gpio_set(struct gpio_chip *gc, unsigned offset,
int value)
{
struct tps65910_gpio *tps65910_gpio = gpiochip_get_data(gc);
struct tps65910 *tps65910 = tps65910_gpio->tps65910;
if (value)
tps65910_reg_set_bits(tps65910, TPS65910_GPIO0 + offset,
GPIO_SET_MASK);
else
tps65910_reg_clear_bits(tps65910, TPS65910_GPIO0 + offset,
GPIO_SET_MASK);
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
graeme gregory | graeme gregory | 43 | 68.25% | 1 | 20.00% |
laxman dewangan | laxman dewangan | 11 | 17.46% | 1 | 20.00% |
jorge eduardo candelaria | jorge eduardo candelaria | 6 | 9.52% | 1 | 20.00% |
rhyland klein | rhyland klein | 2 | 3.17% | 1 | 20.00% |
linus walleij | linus walleij | 1 | 1.59% | 1 | 20.00% |
| Total | 63 | 100.00% | 5 | 100.00% |
static int tps65910_gpio_output(struct gpio_chip *gc, unsigned offset,
int value)
{
struct tps65910_gpio *tps65910_gpio = gpiochip_get_data(gc);
struct tps65910 *tps65910 = tps65910_gpio->tps65910;
/* Set the initial value */
tps65910_gpio_set(gc, offset, value);
return tps65910_reg_set_bits(tps65910, TPS65910_GPIO0 + offset,
GPIO_CFG_MASK);
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
graeme gregory | graeme gregory | 41 | 70.69% | 1 | 16.67% |
laxman dewangan | laxman dewangan | 12 | 20.69% | 2 | 33.33% |
jorge eduardo candelaria | jorge eduardo candelaria | 3 | 5.17% | 1 | 16.67% |
linus walleij | linus walleij | 1 | 1.72% | 1 | 16.67% |
rhyland klein | rhyland klein | 1 | 1.72% | 1 | 16.67% |
| Total | 58 | 100.00% | 6 | 100.00% |
static int tps65910_gpio_input(struct gpio_chip *gc, unsigned offset)
{
struct tps65910_gpio *tps65910_gpio = gpiochip_get_data(gc);
struct tps65910 *tps65910 = tps65910_gpio->tps65910;
return tps65910_reg_clear_bits(tps65910, TPS65910_GPIO0 + offset,
GPIO_CFG_MASK);
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
graeme gregory | graeme gregory | 29 | 64.44% | 1 | 20.00% |
laxman dewangan | laxman dewangan | 11 | 24.44% | 1 | 20.00% |
jorge eduardo candelaria | jorge eduardo candelaria | 3 | 6.67% | 1 | 20.00% |
linus walleij | linus walleij | 1 | 2.22% | 1 | 20.00% |
rhyland klein | rhyland klein | 1 | 2.22% | 1 | 20.00% |
| Total | 45 | 100.00% | 5 | 100.00% |
#ifdef CONFIG_OF
static struct tps65910_board *tps65910_parse_dt_for_gpio(struct device *dev,
struct tps65910 *tps65910, int chip_ngpio)
{
struct tps65910_board *tps65910_board = tps65910->of_plat_data;
unsigned int prop_array[TPS6591X_MAX_NUM_GPIO];
int ngpio = min(chip_ngpio, TPS6591X_MAX_NUM_GPIO);
int ret;
int idx;
tps65910_board->gpio_base = -1;
ret = of_property_read_u32_array(tps65910->dev->of_node,
"ti,en-gpio-sleep", prop_array, ngpio);
if (ret < 0) {
dev_dbg(dev, "ti,en-gpio-sleep not specified\n");
return tps65910_board;
}
for (idx = 0; idx < ngpio; idx++)
tps65910_board->en_gpio_sleep[idx] = (prop_array[idx] != 0);
return tps65910_board;
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
laxman dewangan | laxman dewangan | 127 | 100.00% | 1 | 100.00% |
| Total | 127 | 100.00% | 1 | 100.00% |
#else
static struct tps65910_board *tps65910_parse_dt_for_gpio(struct device *dev,
struct tps65910 *tps65910, int chip_ngpio)
{
return NULL;
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
laxman dewangan | laxman dewangan | 24 | 100.00% | 1 | 100.00% |
| Total | 24 | 100.00% | 1 | 100.00% |
#endif
static int tps65910_gpio_probe(struct platform_device *pdev)
{
struct tps65910 *tps65910 = dev_get_drvdata(pdev->dev.parent);
struct tps65910_board *pdata = dev_get_platdata(tps65910->dev);
struct tps65910_gpio *tps65910_gpio;
int ret;
int i;
tps65910_gpio = devm_kzalloc(&pdev->dev,
sizeof(*tps65910_gpio), GFP_KERNEL);
if (!tps65910_gpio)
return -ENOMEM;
tps65910_gpio->tps65910 = tps65910;
tps65910_gpio->gpio_chip.owner = THIS_MODULE;
tps65910_gpio->gpio_chip.label = tps65910->i2c_client->name;
switch (tps65910_chip_id(tps65910)) {
case TPS65910:
tps65910_gpio->gpio_chip.ngpio = TPS65910_NUM_GPIO;
break;
case TPS65911:
tps65910_gpio->gpio_chip.ngpio = TPS65911_NUM_GPIO;
break;
default:
return -EINVAL;
}
tps65910_gpio->gpio_chip.can_sleep = true;
tps65910_gpio->gpio_chip.direction_input = tps65910_gpio_input;
tps65910_gpio->gpio_chip.direction_output = tps65910_gpio_output;
tps65910_gpio->gpio_chip.set = tps65910_gpio_set;
tps65910_gpio->gpio_chip.get = tps65910_gpio_get;
tps65910_gpio->gpio_chip.parent = &pdev->dev;
#ifdef CONFIG_OF_GPIO
tps65910_gpio->gpio_chip.of_node = tps65910->dev->of_node;
#endif
if (pdata && pdata->gpio_base)
tps65910_gpio->gpio_chip.base = pdata->gpio_base;
else
tps65910_gpio->gpio_chip.base = -1;
if (!pdata && tps65910->dev->of_node)
pdata = tps65910_parse_dt_for_gpio(&pdev->dev, tps65910,
tps65910_gpio->gpio_chip.ngpio);
if (!pdata)
goto skip_init;
/* Configure sleep control for gpios if provided */
for (i = 0; i < tps65910_gpio->gpio_chip.ngpio; ++i) {
if (!pdata->en_gpio_sleep[i])
continue;
ret = tps65910_reg_set_bits(tps65910,
TPS65910_GPIO0 + i, GPIO_SLEEP_MASK);
if (ret < 0)
dev_warn(tps65910->dev,
"GPIO Sleep setting failed with err %d\n", ret);
}
skip_init:
ret = devm_gpiochip_add_data(&pdev->dev, &tps65910_gpio->gpio_chip,
tps65910_gpio);
if (ret < 0) {
dev_err(&pdev->dev, "Could not register gpiochip, %d\n", ret);
return ret;
}
platform_set_drvdata(pdev, tps65910_gpio);
return ret;
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
laxman dewangan | laxman dewangan | 274 | 71.17% | 5 | 38.46% |
graeme gregory | graeme gregory | 78 | 20.26% | 1 | 7.69% |
jorge eduardo candelaria | jorge eduardo candelaria | 21 | 5.45% | 1 | 7.69% |
gerard snitselaar | gerard snitselaar | 5 | 1.30% | 1 | 7.69% |
linus walleij | linus walleij | 4 | 1.04% | 3 | 23.08% |
axel lin | axel lin | 2 | 0.52% | 1 | 7.69% |
rhyland klein | rhyland klein | 1 | 0.26% | 1 | 7.69% |
| Total | 385 | 100.00% | 13 | 100.00% |
static struct platform_driver tps65910_gpio_driver = {
.driver.name = "tps65910-gpio",
.driver.owner = THIS_MODULE,
.probe = tps65910_gpio_probe,
};
static int __init tps65910_gpio_init(void)
{
return platform_driver_register(&tps65910_gpio_driver);
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
laxman dewangan | laxman dewangan | 16 | 100.00% | 1 | 100.00% |
| Total | 16 | 100.00% | 1 | 100.00% |
subsys_initcall(tps65910_gpio_init);
Overall Contributors
| Person | Tokens | Prop | Commits | CommitProp |
laxman dewangan | laxman dewangan | 544 | 63.55% | 6 | 40.00% |
graeme gregory | graeme gregory | 251 | 29.32% | 1 | 6.67% |
jorge eduardo candelaria | jorge eduardo candelaria | 36 | 4.21% | 1 | 6.67% |
linus walleij | linus walleij | 8 | 0.93% | 3 | 20.00% |
rhyland klein | rhyland klein | 8 | 0.93% | 1 | 6.67% |
gerard snitselaar | gerard snitselaar | 5 | 0.58% | 1 | 6.67% |
axel lin | axel lin | 2 | 0.23% | 1 | 6.67% |
paul gortmaker | paul gortmaker | 2 | 0.23% | 1 | 6.67% |
| Total | 856 | 100.00% | 15 | 100.00% |
Information contained on this website is for historical information purposes only and does not indicate or represent copyright ownership.