2626
2727/* use for A1 like chips */
2828#define REG_PIN_A1_SEL 0x04
29- /* Used for s4 chips */
30- #define REG_EDGE_POL_S4 0x1c
3129
3230/*
3331 * Note: The S905X3 datasheet reports that BOTH_EDGE is controlled by
@@ -72,6 +70,7 @@ struct meson_gpio_irq_params {
7270 bool support_edge_both ;
7371 unsigned int edge_both_offset ;
7472 unsigned int edge_single_offset ;
73+ unsigned int edge_pol_reg ;
7574 unsigned int pol_low_offset ;
7675 unsigned int pin_sel_mask ;
7776 struct irq_ctl_ops ops ;
@@ -105,13 +104,26 @@ struct meson_gpio_irq_params {
105104 .pin_sel_mask = 0x7f, \
106105 .nr_channels = 8, \
107106
107+ #define INIT_MESON_A4_AO_COMMON_DATA (irqs ) \
108+ INIT_MESON_COMMON(irqs, meson_a1_gpio_irq_init, \
109+ meson_a1_gpio_irq_sel_pin, \
110+ meson_s4_gpio_irq_set_type) \
111+ .support_edge_both = true, \
112+ .edge_both_offset = 0, \
113+ .edge_single_offset = 12, \
114+ .edge_pol_reg = 0x8, \
115+ .pol_low_offset = 0, \
116+ .pin_sel_mask = 0xff, \
117+ .nr_channels = 2, \
118+
108119#define INIT_MESON_S4_COMMON_DATA (irqs ) \
109120 INIT_MESON_COMMON(irqs, meson_a1_gpio_irq_init, \
110121 meson_a1_gpio_irq_sel_pin, \
111122 meson_s4_gpio_irq_set_type) \
112123 .support_edge_both = true, \
113124 .edge_both_offset = 0, \
114125 .edge_single_offset = 12, \
126+ .edge_pol_reg = 0x1c, \
115127 .pol_low_offset = 0, \
116128 .pin_sel_mask = 0xff, \
117129 .nr_channels = 12, \
@@ -146,6 +158,18 @@ static const struct meson_gpio_irq_params a1_params = {
146158 INIT_MESON_A1_COMMON_DATA (62 )
147159};
148160
161+ static const struct meson_gpio_irq_params a4_params = {
162+ INIT_MESON_S4_COMMON_DATA (81 )
163+ };
164+
165+ static const struct meson_gpio_irq_params a4_ao_params = {
166+ INIT_MESON_A4_AO_COMMON_DATA (8 )
167+ };
168+
169+ static const struct meson_gpio_irq_params a5_params = {
170+ INIT_MESON_S4_COMMON_DATA (99 )
171+ };
172+
149173static const struct meson_gpio_irq_params s4_params = {
150174 INIT_MESON_S4_COMMON_DATA (82 )
151175};
@@ -168,6 +192,9 @@ static const struct of_device_id meson_irq_gpio_matches[] __maybe_unused = {
168192 { .compatible = "amlogic,meson-sm1-gpio-intc" , .data = & sm1_params },
169193 { .compatible = "amlogic,meson-a1-gpio-intc" , .data = & a1_params },
170194 { .compatible = "amlogic,meson-s4-gpio-intc" , .data = & s4_params },
195+ { .compatible = "amlogic,a4-gpio-ao-intc" , .data = & a4_ao_params },
196+ { .compatible = "amlogic,a4-gpio-intc" , .data = & a4_params },
197+ { .compatible = "amlogic,a5-gpio-intc" , .data = & a5_params },
171198 { .compatible = "amlogic,c3-gpio-intc" , .data = & c3_params },
172199 { .compatible = "amlogic,t7-gpio-intc" , .data = & t7_params },
173200 { }
@@ -299,11 +326,10 @@ meson_gpio_irq_release_channel(struct meson_gpio_irq_controller *ctl,
299326static int meson8_gpio_irq_set_type (struct meson_gpio_irq_controller * ctl ,
300327 unsigned int type , u32 * channel_hwirq )
301328{
302- u32 val = 0 ;
329+ const struct meson_gpio_irq_params * params = ctl -> params ;
303330 unsigned int idx ;
304- const struct meson_gpio_irq_params * params ;
331+ u32 val = 0 ;
305332
306- params = ctl -> params ;
307333 idx = meson_gpio_irq_get_channel_idx (ctl , channel_hwirq );
308334
309335 /*
@@ -356,19 +382,19 @@ static int meson8_gpio_irq_set_type(struct meson_gpio_irq_controller *ctl,
356382static int meson_s4_gpio_irq_set_type (struct meson_gpio_irq_controller * ctl ,
357383 unsigned int type , u32 * channel_hwirq )
358384{
359- u32 val = 0 ;
385+ const struct meson_gpio_irq_params * params = ctl -> params ;
360386 unsigned int idx ;
387+ u32 val = 0 ;
361388
362389 idx = meson_gpio_irq_get_channel_idx (ctl , channel_hwirq );
363390
364391 type &= IRQ_TYPE_SENSE_MASK ;
365392
366- meson_gpio_irq_update_bits (ctl , REG_EDGE_POL_S4 , BIT (idx ), 0 );
393+ meson_gpio_irq_update_bits (ctl , params -> edge_pol_reg , BIT (idx ), 0 );
367394
368395 if (type == IRQ_TYPE_EDGE_BOTH ) {
369- val |= BIT (ctl -> params -> edge_both_offset + idx );
370- meson_gpio_irq_update_bits (ctl , REG_EDGE_POL_S4 ,
371- BIT (ctl -> params -> edge_both_offset + idx ), val );
396+ val = BIT (ctl -> params -> edge_both_offset + idx );
397+ meson_gpio_irq_update_bits (ctl , params -> edge_pol_reg , val , val );
372398 return 0 ;
373399 }
374400
@@ -378,7 +404,7 @@ static int meson_s4_gpio_irq_set_type(struct meson_gpio_irq_controller *ctl,
378404 if (type & (IRQ_TYPE_EDGE_RISING | IRQ_TYPE_EDGE_FALLING ))
379405 val |= BIT (ctl -> params -> edge_single_offset + idx );
380406
381- meson_gpio_irq_update_bits (ctl , REG_EDGE_POL ,
407+ meson_gpio_irq_update_bits (ctl , params -> edge_pol_reg ,
382408 BIT (idx ) | BIT (12 + idx ), val );
383409 return 0 ;
384410};
0 commit comments