mirror of
https://github.com/hardkernel/linux.git
synced 2026-06-08 20:07:46 +09:00
ODROID-COMMON: BACKPORT: add amlogic gpio to irq
FROM: https://patchwork.kernel.org/project/linux-arm-kernel/patch/tencent_CF204C2A172AA4207DADEEB243A75474B10A@qq.com/ Signed-off-by: Dongjin Kim <tobetter@gmail.com> Change-Id: Id20016e76ae3040fb70d0abf554640d7cddf6d0e
This commit is contained in:
committed by
Mauro Ribeiro
parent
9c0235f0cc
commit
b6a1bb2469
@@ -51,6 +51,7 @@
|
||||
#include <linux/property.h>
|
||||
#include <linux/regmap.h>
|
||||
#include <linux/seq_file.h>
|
||||
#include <linux/of_irq.h>
|
||||
|
||||
#include "../core.h"
|
||||
#include "../pinctrl-utils.h"
|
||||
@@ -601,6 +602,34 @@ static int meson_gpio_get(struct gpio_chip *chip, unsigned gpio)
|
||||
return !!(val & BIT(bit));
|
||||
}
|
||||
|
||||
static int meson_gpio_to_irq(struct gpio_chip *chip, unsigned int gpio)
|
||||
{
|
||||
struct meson_pinctrl *pc = gpiochip_get_data(chip);
|
||||
struct meson_bank *bank;
|
||||
struct irq_fwspec fwspec;
|
||||
int hwirq;
|
||||
|
||||
if (meson_get_bank(pc, gpio, &bank))
|
||||
return -EINVAL;
|
||||
|
||||
if (bank->irq_first < 0) {
|
||||
dev_warn(pc->dev, "no support irq for pin[%d]\n", gpio);
|
||||
return -EINVAL;
|
||||
}
|
||||
if (!pc->of_irq) {
|
||||
dev_err(pc->dev, "invalid device node of gpio INTC\n");
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
hwirq = gpio - bank->first + bank->irq_first;
|
||||
fwspec.fwnode = of_node_to_fwnode(pc->of_irq);
|
||||
fwspec.param_count = 2;
|
||||
fwspec.param[0] = hwirq;
|
||||
fwspec.param[1] = IRQ_TYPE_NONE;
|
||||
|
||||
return irq_create_fwspec_mapping(&fwspec);
|
||||
}
|
||||
|
||||
static int meson_gpiolib_register(struct meson_pinctrl *pc)
|
||||
{
|
||||
int ret;
|
||||
@@ -616,6 +645,7 @@ static int meson_gpiolib_register(struct meson_pinctrl *pc)
|
||||
pc->chip.direction_output = meson_gpio_direction_output;
|
||||
pc->chip.get = meson_gpio_get;
|
||||
pc->chip.set = meson_gpio_set;
|
||||
pc->chip.to_irq = meson_gpio_to_irq;
|
||||
pc->chip.base = -1;
|
||||
pc->chip.ngpio = pc->data->num_pins;
|
||||
pc->chip.can_sleep = false;
|
||||
@@ -679,6 +709,12 @@ static int meson_pinctrl_parse_dt(struct meson_pinctrl *pc)
|
||||
pc->fwnode = gpiochip_node_get_first(pc->dev);
|
||||
gpio_np = to_of_node(pc->fwnode);
|
||||
|
||||
pc->of_irq = of_find_compatible_node(NULL,
|
||||
NULL, "amlogic,meson-gpio-intc");
|
||||
if (!pc->of_irq)
|
||||
pc->of_irq = of_find_compatible_node(NULL,
|
||||
NULL, "amlogic,meson-gpio-intc-ext");
|
||||
|
||||
pc->reg_mux = meson_map_resource(pc, gpio_np, "mux");
|
||||
if (IS_ERR_OR_NULL(pc->reg_mux)) {
|
||||
dev_err(pc->dev, "mux registers not found\n");
|
||||
|
||||
@@ -134,6 +134,8 @@ struct meson_pinctrl {
|
||||
struct regmap *reg_ds;
|
||||
struct gpio_chip chip;
|
||||
struct fwnode_handle *fwnode;
|
||||
struct device_node *of_node;
|
||||
struct device_node *of_irq;
|
||||
};
|
||||
|
||||
#define FUNCTION(fn) \
|
||||
|
||||
Reference in New Issue
Block a user