@@ -19,6 +19,8 @@ struct gpio_reg {
19
19
u32 direction ;
20
20
u32 out ;
21
21
void __iomem * reg ;
22
+ struct irq_domain * irqdomain ;
23
+ const int * irqs ;
22
24
};
23
25
24
26
#define to_gpio_reg (x ) container_of(x, struct gpio_reg, gc)
@@ -96,6 +98,17 @@ static void gpio_reg_set_multiple(struct gpio_chip *gc, unsigned long *mask,
96
98
spin_unlock_irqrestore (& r -> lock , flags );
97
99
}
98
100
101
+ static int gpio_reg_to_irq (struct gpio_chip * gc , unsigned offset )
102
+ {
103
+ struct gpio_reg * r = to_gpio_reg (gc );
104
+ int irq = r -> irqs [offset ];
105
+
106
+ if (irq >= 0 && r -> irqdomain )
107
+ irq = irq_find_mapping (r -> irqdomain , irq );
108
+
109
+ return irq ;
110
+ }
111
+
99
112
/**
100
113
* gpio_reg_init - add a fixed in/out register as gpio
101
114
* @dev: optional struct device associated with this register
@@ -104,7 +117,12 @@ static void gpio_reg_set_multiple(struct gpio_chip *gc, unsigned long *mask,
104
117
* @label: GPIO chip label
105
118
* @direction: bitmask of fixed direction, one per GPIO signal, 1 = in
106
119
* @def_out: initial GPIO output value
107
- * @names: array of %num strings describing each GPIO signal
120
+ * @names: array of %num strings describing each GPIO signal or %NULL
121
+ * @irqdom: irq domain or %NULL
122
+ * @irqs: array of %num ints describing the interrupt mapping for each
123
+ * GPIO signal, or %NULL. If @irqdom is %NULL, then this
124
+ * describes the Linux interrupt number, otherwise it describes
125
+ * the hardware interrupt number in the specified irq domain.
108
126
*
109
127
* Add a single-register GPIO device containing up to 32 GPIO signals,
110
128
* where each GPIO has a fixed input or output configuration. Only
@@ -114,7 +132,7 @@ static void gpio_reg_set_multiple(struct gpio_chip *gc, unsigned long *mask,
114
132
*/
115
133
struct gpio_chip * gpio_reg_init (struct device * dev , void __iomem * reg ,
116
134
int base , int num , const char * label , u32 direction , u32 def_out ,
117
- const char * const * names )
135
+ const char * const * names , struct irq_domain * irqdom , const int * irqs )
118
136
{
119
137
struct gpio_reg * r ;
120
138
int ret ;
@@ -136,12 +154,15 @@ struct gpio_chip *gpio_reg_init(struct device *dev, void __iomem *reg,
136
154
r -> gc .set = gpio_reg_set ;
137
155
r -> gc .get = gpio_reg_get ;
138
156
r -> gc .set_multiple = gpio_reg_set_multiple ;
157
+ if (irqs )
158
+ r -> gc .to_irq = gpio_reg_to_irq ;
139
159
r -> gc .base = base ;
140
160
r -> gc .ngpio = num ;
141
161
r -> gc .names = names ;
142
162
r -> direction = direction ;
143
163
r -> out = def_out ;
144
164
r -> reg = reg ;
165
+ r -> irqs = irqs ;
145
166
146
167
if (dev )
147
168
ret = devm_gpiochip_add_data (dev , & r -> gc , r );
0 commit comments