1616#include <linux/of.h>
1717#include <linux/of_address.h>
1818
19- #define NUM_CHANNEL 8
19+ #define MAX_NUM_CHANNEL 64
2020#define MAX_INPUT_MUX 256
2121
2222#define REG_EDGE_POL 0x00
@@ -60,6 +60,7 @@ struct irq_ctl_ops {
6060
6161struct meson_gpio_irq_params {
6262 unsigned int nr_hwirq ;
63+ unsigned int nr_channels ;
6364 bool support_edge_both ;
6465 unsigned int edge_both_offset ;
6566 unsigned int edge_single_offset ;
@@ -81,6 +82,7 @@ struct meson_gpio_irq_params {
8182 .edge_single_offset = 0, \
8283 .pol_low_offset = 16, \
8384 .pin_sel_mask = 0xff, \
85+ .nr_channels = 8, \
8486
8587#define INIT_MESON_A1_COMMON_DATA (irqs ) \
8688 INIT_MESON_COMMON(irqs, meson_a1_gpio_irq_init, \
@@ -90,6 +92,7 @@ struct meson_gpio_irq_params {
9092 .edge_single_offset = 8, \
9193 .pol_low_offset = 0, \
9294 .pin_sel_mask = 0x7f, \
95+ .nr_channels = 8, \
9396
9497static const struct meson_gpio_irq_params meson8_params = {
9598 INIT_MESON8_COMMON_DATA (134 )
@@ -136,8 +139,8 @@ static const struct of_device_id meson_irq_gpio_matches[] = {
136139struct meson_gpio_irq_controller {
137140 const struct meson_gpio_irq_params * params ;
138141 void __iomem * base ;
139- u32 channel_irqs [NUM_CHANNEL ];
140- DECLARE_BITMAP (channel_map , NUM_CHANNEL );
142+ u32 channel_irqs [MAX_NUM_CHANNEL ];
143+ DECLARE_BITMAP (channel_map , MAX_NUM_CHANNEL );
141144 spinlock_t lock ;
142145};
143146
@@ -207,8 +210,8 @@ meson_gpio_irq_request_channel(struct meson_gpio_irq_controller *ctl,
207210 spin_lock_irqsave (& ctl -> lock , flags );
208211
209212 /* Find a free channel */
210- idx = find_first_zero_bit (ctl -> channel_map , NUM_CHANNEL );
211- if (idx >= NUM_CHANNEL ) {
213+ idx = find_first_zero_bit (ctl -> channel_map , ctl -> params -> nr_channels );
214+ if (idx >= ctl -> params -> nr_channels ) {
212215 spin_unlock_irqrestore (& ctl -> lock , flags );
213216 pr_err ("No channel available\n" );
214217 return - ENOSPC ;
@@ -450,10 +453,10 @@ static int meson_gpio_irq_parse_dt(struct device_node *node, struct meson_gpio_i
450453 ret = of_property_read_variable_u32_array (node ,
451454 "amlogic,channel-interrupts" ,
452455 ctl -> channel_irqs ,
453- NUM_CHANNEL ,
454- NUM_CHANNEL );
456+ ctl -> params -> nr_channels ,
457+ ctl -> params -> nr_channels );
455458 if (ret < 0 ) {
456- pr_err ("can't get %d channel interrupts\n" , NUM_CHANNEL );
459+ pr_err ("can't get %d channel interrupts\n" , ctl -> params -> nr_channels );
457460 return ret ;
458461 }
459462
@@ -507,7 +510,7 @@ static int meson_gpio_irq_of_init(struct device_node *node, struct device_node *
507510 }
508511
509512 pr_info ("%d to %d gpio interrupt mux initialized\n" ,
510- ctl -> params -> nr_hwirq , NUM_CHANNEL );
513+ ctl -> params -> nr_hwirq , ctl -> params -> nr_channels );
511514
512515 return 0 ;
513516
0 commit comments