summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorViresh Kumar <viresh.kumar@linaro.org>2021-12-13 13:01:05 +0530
committerViresh Kumar <viresh.kumar@linaro.org>2021-12-13 13:01:05 +0530
commit9798369a9dc474b73fe162fbdc73c59253061a8a (patch)
tree61c0699b5f68a9924b3a0ed8c5caaa03bb145408
parentcf7a16bdb98e5ada12b0d5865168c2989b17fe37 (diff)
updates
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
-rw-r--r--gpio-mock.c75
1 files changed, 74 insertions, 1 deletions
diff --git a/gpio-mock.c b/gpio-mock.c
index 734be99..c9c6b33 100644
--- a/gpio-mock.c
+++ b/gpio-mock.c
@@ -10,6 +10,7 @@
#define pr_fmt(fmt) "GPIO Mock: " fmt
+#include <linux/debugfs.h>
#include <linux/module.h>
#include <linux/moduleparam.h>
#include <linux/printk.h>
@@ -28,6 +29,8 @@ struct mock_gpio_chip {
struct gpio_chip gc;
struct gpio_line lines[NGPIO];
};
+static struct mock_gpio_chip *mock_gc;
+unsigned int val = 0;
static const char *gpio_line_names[NGPIO] = {
"gpio0",
@@ -89,9 +92,68 @@ static int mock_gpio_direction_output(struct gpio_chip *gc,
return 0;
}
+static void mock_gpio_irq_enable(struct irq_data *d)
+{
+ struct gpio_chip *gc = irq_data_get_irq_chip_data(d);
+ struct mock_gpio_chip *mock_gc = gpiochip_get_data(gc);
+
+ pr_info("%s: %d: %u\n", __func__, __LINE__, d->hwirq);
+}
+
+static void mock_gpio_irq_disable(struct irq_data *d)
+{
+ struct gpio_chip *gc = irq_data_get_irq_chip_data(d);
+ struct mock_gpio_chip *mock_gc = gpiochip_get_data(gc);
+
+ pr_info("%s: %d: %u\n", __func__, __LINE__, d->hwirq);
+}
+
+static void mock_gpio_irq_mask(struct irq_data *d)
+{
+ struct gpio_chip *gc = irq_data_get_irq_chip_data(d);
+ struct mock_gpio_chip *mock_gc = gpiochip_get_data(gc);
+
+ pr_info("%s: %d: %u\n", __func__, __LINE__, d->hwirq);
+}
+
+static void mock_gpio_irq_unmask(struct irq_data *d)
+{
+ struct gpio_chip *gc = irq_data_get_irq_chip_data(d);
+ struct mock_gpio_chip *mock_gc = gpiochip_get_data(gc);
+
+ pr_info("%s: %d: %u\n", __func__, __LINE__, d->hwirq);
+}
+
+static int mock_gpio_irq_set_type(struct irq_data *d, unsigned int type)
+{
+ struct gpio_chip *gc = irq_data_get_irq_chip_data(d);
+ struct mock_gpio_chip *mock_gc = gpiochip_get_data(gc);
+
+ pr_info("%s: %d: %u\n", __func__, __LINE__, d->hwirq);
+
+ return 0;
+}
+
+static struct irq_chip irq_chip = {
+ .name = "mock-gpio",
+ .irq_enable = mock_gpio_irq_enable,
+ .irq_disable = mock_gpio_irq_disable,
+ .irq_mask = mock_gpio_irq_mask,
+ .irq_unmask = mock_gpio_irq_unmask,
+ .irq_set_type = mock_gpio_irq_set_type,
+};
+
+static int mock_gpio_irq(void *data, u64 val)
+{
+ pr_info("%s: %d: %u\n", __func__, __LINE__, val);
+ generic_handle_domain_irq(mock_gc->gc.irq.domain, val);
+ return 0;
+}
+
+DEFINE_DEBUGFS_ATTRIBUTE(mock_gpio_fops, NULL, mock_gpio_irq, "%llu\n");
+
static int mock_gpio_probe(struct platform_device *pdev)
{
- struct mock_gpio_chip *mock_gc;
int i, ret;
pr_info("%s: %d\n", __func__, __LINE__);
@@ -110,6 +172,13 @@ static int mock_gpio_probe(struct platform_device *pdev)
mock_gc->gc.base = -1;
mock_gc->gc.label = dev_name(&pdev->dev);
mock_gc->gc.names = gpio_line_names;
+ mock_gc->gc.owner = THIS_MODULE;
+ mock_gc->gc.irq.parent_handler = NULL;
+ mock_gc->gc.irq.num_parents = 0;
+ mock_gc->gc.irq.parents = NULL;
+ mock_gc->gc.irq.default_type = IRQ_TYPE_NONE;
+ mock_gc->gc.irq.handler = handle_edge_irq;
+ mock_gc->gc.irq.chip = &irq_chip;
for (i = 0; i < NGPIO; i++)
mock_gc->lines[i].dir = 1;
@@ -156,6 +225,10 @@ static int __init mock_gpio_init(void)
}
+ rootdir = debugfs_create_dir("mockgpio", NULL);
+ file = debugfs_create_file("gpio", S_IRUGO | S_IWUSR, rootdir,
+ NULL, &mock_gpio_fops);
+
pr_info("%s: %d: %d\n", __func__, __LINE__, ret);
return ret;
}