Release 4.11 drivers/bcma/driver_gpio.c
/*
* Broadcom specific AMBA
* GPIO driver
*
* Copyright 2011, Broadcom Corporation
* Copyright 2012, Hauke Mehrtens <hauke@hauke-m.de>
*
* Licensed under the GNU/GPL. See COPYING for details.
*/
#include <linux/gpio/driver.h>
#include <linux/interrupt.h>
#include <linux/export.h>
#include <linux/bcma/bcma.h>
#include "bcma_private.h"
#define BCMA_GPIO_MAX_PINS 32
static int bcma_gpio_get_value(struct gpio_chip *chip, unsigned gpio)
{
struct bcma_drv_cc *cc = gpiochip_get_data(chip);
return !!bcma_chipco_gpio_in(cc, 1 << gpio);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Hauke Mehrtens | 35 | 97.22% | 1 | 50.00% |
Linus Walleij | 1 | 2.78% | 1 | 50.00% |
Total | 36 | 100.00% | 2 | 100.00% |
static void bcma_gpio_set_value(struct gpio_chip *chip, unsigned gpio,
int value)
{
struct bcma_drv_cc *cc = gpiochip_get_data(chip);
bcma_chipco_gpio_out(cc, 1 << gpio, value ? 1 << gpio : 0);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Hauke Mehrtens | 43 | 97.73% | 1 | 50.00% |
Linus Walleij | 1 | 2.27% | 1 | 50.00% |
Total | 44 | 100.00% | 2 | 100.00% |
static int bcma_gpio_direction_input(struct gpio_chip *chip, unsigned gpio)
{
struct bcma_drv_cc *cc = gpiochip_get_data(chip);
bcma_chipco_gpio_outen(cc, 1 << gpio, 0);
return 0;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Hauke Mehrtens | 37 | 97.37% | 1 | 50.00% |
Linus Walleij | 1 | 2.63% | 1 | 50.00% |
Total | 38 | 100.00% | 2 | 100.00% |
static int bcma_gpio_direction_output(struct gpio_chip *chip, unsigned gpio,
int value)
{
struct bcma_drv_cc *cc = gpiochip_get_data(chip);
bcma_chipco_gpio_outen(cc, 1 << gpio, 1 << gpio);
bcma_chipco_gpio_out(cc, 1 << gpio, value ? 1 << gpio : 0);
return 0;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Hauke Mehrtens | 59 | 98.33% | 1 | 50.00% |
Linus Walleij | 1 | 1.67% | 1 | 50.00% |
Total | 60 | 100.00% | 2 | 100.00% |
static int bcma_gpio_request(struct gpio_chip *chip, unsigned gpio)
{
struct bcma_drv_cc *cc = gpiochip_get_data(chip);
bcma_chipco_gpio_control(cc, 1 << gpio, 0);
/* clear pulldown */
bcma_chipco_gpio_pulldown(cc, 1 << gpio, 0);
/* Set pullup */
bcma_chipco_gpio_pullup(cc, 1 << gpio, 1 << gpio);
return 0;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Hauke Mehrtens | 63 | 98.44% | 1 | 50.00% |
Linus Walleij | 1 | 1.56% | 1 | 50.00% |
Total | 64 | 100.00% | 2 | 100.00% |
static void bcma_gpio_free(struct gpio_chip *chip, unsigned gpio)
{
struct bcma_drv_cc *cc = gpiochip_get_data(chip);
/* clear pullup */
bcma_chipco_gpio_pullup(cc, 1 << gpio, 0);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Hauke Mehrtens | 35 | 97.22% | 1 | 50.00% |
Linus Walleij | 1 | 2.78% | 1 | 50.00% |
Total | 36 | 100.00% | 2 | 100.00% |
#if IS_BUILTIN(CONFIG_BCM47XX) || IS_BUILTIN(CONFIG_ARCH_BCM_5301X)
static void bcma_gpio_irq_unmask(struct irq_data *d)
{
struct gpio_chip *gc = irq_data_get_irq_chip_data(d);
struct bcma_drv_cc *cc = gpiochip_get_data(gc);
int gpio = irqd_to_hwirq(d);
u32 val = bcma_chipco_gpio_in(cc, BIT(gpio));
bcma_chipco_gpio_polarity(cc, BIT(gpio), val);
bcma_chipco_gpio_intmask(cc, BIT(gpio), BIT(gpio));
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Hauke Mehrtens | 37 | 46.84% | 2 | 40.00% |
Rafał Miłecki | 32 | 40.51% | 1 | 20.00% |
Linus Walleij | 10 | 12.66% | 2 | 40.00% |
Total | 79 | 100.00% | 5 | 100.00% |
static void bcma_gpio_irq_mask(struct irq_data *d)
{
struct gpio_chip *gc = irq_data_get_irq_chip_data(d);
struct bcma_drv_cc *cc = gpiochip_get_data(gc);
int gpio = irqd_to_hwirq(d);
bcma_chipco_gpio_intmask(cc, BIT(gpio), 0);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Rafał Miłecki | 39 | 76.47% | 1 | 33.33% |
Linus Walleij | 12 | 23.53% | 2 | 66.67% |
Total | 51 | 100.00% | 3 | 100.00% |
static struct irq_chip bcma_gpio_irq_chip = {
.name = "BCMA-GPIO",
.irq_mask = bcma_gpio_irq_mask,
.irq_unmask = bcma_gpio_irq_unmask,
};
static irqreturn_t bcma_gpio_irq_handler(int irq, void *dev_id)
{
struct bcma_drv_cc *cc = dev_id;
struct gpio_chip *gc = &cc->gpio;
u32 val = bcma_cc_read32(cc, BCMA_CC_GPIOIN);
u32 mask = bcma_cc_read32(cc, BCMA_CC_GPIOIRQ);
u32 pol = bcma_cc_read32(cc, BCMA_CC_GPIOPOL);
unsigned long irqs = (val ^ pol) & mask;
int gpio;
if (!irqs)
return IRQ_NONE;
for_each_set_bit(gpio, &irqs, gc->ngpio)
generic_handle_irq(irq_find_mapping(gc->irqdomain, gpio));
bcma_chipco_gpio_polarity(cc, irqs, val & irqs);
return IRQ_HANDLED;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Rafał Miłecki | 103 | 88.03% | 2 | 66.67% |
Linus Walleij | 14 | 11.97% | 1 | 33.33% |
Total | 117 | 100.00% | 3 | 100.00% |
static int bcma_gpio_irq_init(struct bcma_drv_cc *cc)
{
struct gpio_chip *chip = &cc->gpio;
int hwirq, err;
if (cc->core->bus->hosttype != BCMA_HOSTTYPE_SOC)
return 0;
hwirq = bcma_core_irq(cc->core, 0);
err = request_irq(hwirq, bcma_gpio_irq_handler, IRQF_SHARED, "gpio",
cc);
if (err)
return err;
bcma_chipco_gpio_intmask(cc, ~0, 0);
bcma_cc_set32(cc, BCMA_CC_IRQMASK, BCMA_CC_IRQ_GPIO);
err = gpiochip_irqchip_add(chip,
&bcma_gpio_irq_chip,
0,
handle_simple_irq,
IRQ_TYPE_NONE);
if (err) {
free_irq(hwirq, cc);
return err;
}
return 0;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Rafał Miłecki | 89 | 69.53% | 1 | 25.00% |
Linus Walleij | 27 | 21.09% | 1 | 25.00% |
Hauke Mehrtens | 12 | 9.38% | 2 | 50.00% |
Total | 128 | 100.00% | 4 | 100.00% |
static void bcma_gpio_irq_exit(struct bcma_drv_cc *cc)
{
if (cc->core->bus->hosttype != BCMA_HOSTTYPE_SOC)
return;
bcma_cc_mask32(cc, BCMA_CC_IRQMASK, ~BCMA_CC_IRQ_GPIO);
free_irq(bcma_core_irq(cc->core, 0), cc);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Rafał Miłecki | 45 | 93.75% | 1 | 33.33% |
Hauke Mehrtens | 2 | 4.17% | 1 | 33.33% |
Linus Walleij | 1 | 2.08% | 1 | 33.33% |
Total | 48 | 100.00% | 3 | 100.00% |
#else
static int bcma_gpio_irq_init(struct bcma_drv_cc *cc)
{
return 0;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Rafał Miłecki | 13 | 92.86% | 1 | 50.00% |
Linus Walleij | 1 | 7.14% | 1 | 50.00% |
Total | 14 | 100.00% | 2 | 100.00% |
static void bcma_gpio_irq_exit(struct bcma_drv_cc *cc)
{
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Rafał Miłecki | 9 | 90.00% | 1 | 50.00% |
Linus Walleij | 1 | 10.00% | 1 | 50.00% |
Total | 10 | 100.00% | 2 | 100.00% |
#endif
int bcma_gpio_init(struct bcma_drv_cc *cc)
{
struct bcma_bus *bus = cc->core->bus;
struct gpio_chip *chip = &cc->gpio;
int err;
chip->label = "bcma_gpio";
chip->owner = THIS_MODULE;
chip->request = bcma_gpio_request;
chip->free = bcma_gpio_free;
chip->get = bcma_gpio_get_value;
chip->set = bcma_gpio_set_value;
chip->direction_input = bcma_gpio_direction_input;
chip->direction_output = bcma_gpio_direction_output;
chip->owner = THIS_MODULE;
chip->parent = bcma_bus_get_host_dev(bus);
#if IS_BUILTIN(CONFIG_OF)
if (cc->core->bus->hosttype == BCMA_HOSTTYPE_SOC)
chip->of_node = cc->core->dev.of_node;
#endif
switch (bus->chipinfo.id) {
case BCMA_CHIP_ID_BCM4707:
case BCMA_CHIP_ID_BCM5357:
case BCMA_CHIP_ID_BCM53572:
case BCMA_CHIP_ID_BCM47094:
chip->ngpio = 32;
break;
default:
chip->ngpio = 16;
}
/*
* Register SoC GPIO devices with absolute GPIO pin base.
* On MIPS, we don't have Device Tree and we can't use relative (per chip)
* GPIO numbers.
* On some ARM devices, user space may want to access some system GPIO
* pins directly, which is easier to do with a predictable GPIO base.
*/
if (IS_BUILTIN(CONFIG_BCM47XX) ||
cc->core->bus->hosttype == BCMA_HOSTTYPE_SOC)
chip->base = bus->num * BCMA_GPIO_MAX_PINS;
else
chip->base = -1;
err = gpiochip_add_data(chip, cc);
if (err)
return err;
err = bcma_gpio_irq_init(cc);
if (err) {
gpiochip_remove(chip);
return err;
}
return 0;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Rafał Miłecki | 110 | 45.64% | 6 | 46.15% |
Hauke Mehrtens | 94 | 39.00% | 2 | 15.38% |
Linus Walleij | 19 | 7.88% | 3 | 23.08% |
Felix Fietkau | 18 | 7.47% | 2 | 15.38% |
Total | 241 | 100.00% | 13 | 100.00% |
int bcma_gpio_unregister(struct bcma_drv_cc *cc)
{
bcma_gpio_irq_exit(cc);
gpiochip_remove(&cc->gpio);
return 0;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Hauke Mehrtens | 18 | 69.23% | 1 | 25.00% |
Rafał Miłecki | 4 | 15.38% | 1 | 25.00% |
abdoulaye berthe | 3 | 11.54% | 1 | 25.00% |
Linus Walleij | 1 | 3.85% | 1 | 25.00% |
Total | 26 | 100.00% | 4 | 100.00% |
Overall Contributors
Person | Tokens | Prop | Commits | CommitProp |
Rafał Miłecki | 490 | 46.71% | 9 | 45.00% |
Hauke Mehrtens | 445 | 42.42% | 5 | 25.00% |
Linus Walleij | 93 | 8.87% | 3 | 15.00% |
Felix Fietkau | 18 | 1.72% | 2 | 10.00% |
abdoulaye berthe | 3 | 0.29% | 1 | 5.00% |
Total | 1049 | 100.00% | 20 | 100.00% |
Information contained on this website is for historical information purposes only and does not indicate or represent copyright ownership.