Release 4.12 drivers/gpio/gpio-arizona.c
  
  
  
/*
 * gpiolib support for Wolfson Arizona class devices
 *
 * Copyright 2012 Wolfson Microelectronics PLC.
 *
 * Author: Mark Brown <broonie@opensource.wolfsonmicro.com>
 *
 *  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/slab.h>
#include <linux/module.h>
#include <linux/gpio.h>
#include <linux/platform_device.h>
#include <linux/pm_runtime.h>
#include <linux/seq_file.h>
#include <linux/mfd/arizona/core.h>
#include <linux/mfd/arizona/pdata.h>
#include <linux/mfd/arizona/registers.h>
struct arizona_gpio {
	
struct arizona *arizona;
	
struct gpio_chip gpio_chip;
};
static int arizona_gpio_direction_in(struct gpio_chip *chip, unsigned offset)
{
	struct arizona_gpio *arizona_gpio = gpiochip_get_data(chip);
	struct arizona *arizona = arizona_gpio->arizona;
	return regmap_update_bits(arizona->regmap, ARIZONA_GPIO1_CTRL + offset,
				  ARIZONA_GPN_DIR, ARIZONA_GPN_DIR);
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp | 
| Mark Brown | 48 | 97.96% | 1 | 50.00% | 
| Linus Walleij | 1 | 2.04% | 1 | 50.00% | 
| Total | 49 | 100.00% | 2 | 100.00% | 
static int arizona_gpio_get(struct gpio_chip *chip, unsigned offset)
{
	struct arizona_gpio *arizona_gpio = gpiochip_get_data(chip);
	struct arizona *arizona = arizona_gpio->arizona;
	unsigned int reg, val;
	int ret;
	reg = ARIZONA_GPIO1_CTRL + offset;
	ret = regmap_read(arizona->regmap, reg, &val);
	if (ret < 0)
		return ret;
	/* Resume to read actual registers for input pins */
	if (val & ARIZONA_GPN_DIR) {
		ret = pm_runtime_get_sync(chip->parent);
		if (ret < 0) {
			dev_err(chip->parent, "Failed to resume: %d\n", ret);
			return ret;
		}
		/* Register is cached, drop it to ensure a physical read */
		ret = regcache_drop_region(arizona->regmap, reg, reg);
		if (ret < 0) {
			dev_err(chip->parent, "Failed to drop cache: %d\n",
				ret);
			return ret;
		}
		ret = regmap_read(arizona->regmap, reg, &val);
		if (ret < 0)
			return ret;
		pm_runtime_mark_last_busy(chip->parent);
		pm_runtime_put_autosuspend(chip->parent);
	}
	if (val & ARIZONA_GPN_LVL)
		return 1;
	else
		return 0;
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp | 
| Charles Keepax | 122 | 61.93% | 1 | 33.33% | 
| Mark Brown | 74 | 37.56% | 1 | 33.33% | 
| Linus Walleij | 1 | 0.51% | 1 | 33.33% | 
| Total | 197 | 100.00% | 3 | 100.00% | 
static int arizona_gpio_direction_out(struct gpio_chip *chip,
				     unsigned offset, int value)
{
	struct arizona_gpio *arizona_gpio = gpiochip_get_data(chip);
	struct arizona *arizona = arizona_gpio->arizona;
	if (value)
		value = ARIZONA_GPN_LVL;
	return regmap_update_bits(arizona->regmap, ARIZONA_GPIO1_CTRL + offset,
				  ARIZONA_GPN_DIR | ARIZONA_GPN_LVL, value);
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp | 
| Mark Brown | 61 | 98.39% | 1 | 50.00% | 
| Linus Walleij | 1 | 1.61% | 1 | 50.00% | 
| Total | 62 | 100.00% | 2 | 100.00% | 
static void arizona_gpio_set(struct gpio_chip *chip, unsigned offset, int value)
{
	struct arizona_gpio *arizona_gpio = gpiochip_get_data(chip);
	struct arizona *arizona = arizona_gpio->arizona;
	if (value)
		value = ARIZONA_GPN_LVL;
	regmap_update_bits(arizona->regmap, ARIZONA_GPIO1_CTRL + offset,
			   ARIZONA_GPN_LVL, value);
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp | 
| Mark Brown | 58 | 98.31% | 1 | 50.00% | 
| Linus Walleij | 1 | 1.69% | 1 | 50.00% | 
| Total | 59 | 100.00% | 2 | 100.00% | 
static const struct gpio_chip template_chip = {
	.label			= "arizona",
	.owner			= THIS_MODULE,
	.direction_input	= arizona_gpio_direction_in,
	.get			= arizona_gpio_get,
	.direction_output	= arizona_gpio_direction_out,
	.set			= arizona_gpio_set,
	.can_sleep		= true,
};
static int arizona_gpio_probe(struct platform_device *pdev)
{
	struct arizona *arizona = dev_get_drvdata(pdev->dev.parent);
	struct arizona_pdata *pdata = dev_get_platdata(arizona->dev);
	struct arizona_gpio *arizona_gpio;
	int ret;
	arizona_gpio = devm_kzalloc(&pdev->dev, sizeof(*arizona_gpio),
				    GFP_KERNEL);
	if (!arizona_gpio)
		return -ENOMEM;
	arizona_gpio->arizona = arizona;
	arizona_gpio->gpio_chip = template_chip;
	arizona_gpio->gpio_chip.parent = &pdev->dev;
#ifdef CONFIG_OF_GPIO
	arizona_gpio->gpio_chip.of_node = arizona->dev->of_node;
#endif
	switch (arizona->type) {
	case WM5102:
	case WM5110:
	case WM8280:
	case WM8997:
	case WM8998:
	case WM1814:
		arizona_gpio->gpio_chip.ngpio = 5;
		break;
	case WM1831:
	case CS47L24:
		arizona_gpio->gpio_chip.ngpio = 2;
		break;
	default:
		dev_err(&pdev->dev, "Unknown chip variant %d\n",
			arizona->type);
		return -EINVAL;
	}
	if (pdata && pdata->gpio_base)
		arizona_gpio->gpio_chip.base = pdata->gpio_base;
	else
		arizona_gpio->gpio_chip.base = -1;
	ret = devm_gpiochip_add_data(&pdev->dev, &arizona_gpio->gpio_chip,
				     arizona_gpio);
	if (ret < 0) {
		dev_err(&pdev->dev, "Could not register gpiochip, %d\n",
			ret);
		return ret;
	}
	return 0;
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp | 
| Mark Brown | 193 | 76.59% | 1 | 8.33% | 
| Richard Fitzgerald | 24 | 9.52% | 3 | 25.00% | 
| Charles Keepax | 22 | 8.73% | 3 | 25.00% | 
| Laxman Dewangan | 6 | 2.38% | 1 | 8.33% | 
| Linus Walleij | 3 | 1.19% | 2 | 16.67% | 
| Jingoo Han | 3 | 1.19% | 1 | 8.33% | 
| Varka Bhadram | 1 | 0.40% | 1 | 8.33% | 
| Total | 252 | 100.00% | 12 | 100.00% | 
static struct platform_driver arizona_gpio_driver = {
	.driver.name	= "arizona-gpio",
	.probe		= arizona_gpio_probe,
};
module_platform_driver(arizona_gpio_driver);
MODULE_AUTHOR("Mark Brown <broonie@opensource.wolfsonmicro.com>");
MODULE_DESCRIPTION("GPIO interface for Arizona devices");
MODULE_LICENSE("GPL");
MODULE_ALIAS("platform:arizona-gpio");
Overall Contributors
| Person | Tokens | Prop | Commits | CommitProp | 
| Mark Brown | 561 | 74.70% | 1 | 6.67% | 
| Charles Keepax | 147 | 19.57% | 4 | 26.67% | 
| Richard Fitzgerald | 24 | 3.20% | 3 | 20.00% | 
| Linus Walleij | 8 | 1.07% | 3 | 20.00% | 
| Laxman Dewangan | 6 | 0.80% | 1 | 6.67% | 
| Jingoo Han | 3 | 0.40% | 1 | 6.67% | 
| Varka Bhadram | 1 | 0.13% | 1 | 6.67% | 
| Julia Lawall | 1 | 0.13% | 1 | 6.67% | 
| Total | 751 | 100.00% | 15 | 100.00% | 
Information contained on this website is for historical information purposes only and does not indicate or represent copyright ownership.