irqchip/meson-gpio: Add support for Meson-S4 SoC
Subsystems (3)
v3 cover irqchip/meson-gpio: Add support for Meson-S4 SoC
This patchset add support for GPIO interrupt controller of Meson-S4 SoC Which has something different with current other meson chips. To support the new chips, current gpio irqchip driver need to rework as below:
1. support more than 8 gpio irq lines.
2. add a set trigger type callback function.
With above work, add support for S4 gpio irqchip
Changes since v2 at [1]:
- rework nr channels allocations
- move old controller set_type to a callback
Changes since v1 at [0]:
- fix leaking issue
- fix some typos
- change implementation of new feature.
[0] https://lore.kernel.org/linux-amlogic/[email protected]/
[1] https://lore.kernel.org/linux-amlogic/[email protected]/
Qianggui Song (4):
dt-bindings: interrupt-controller: New binding for Meson-S4 SoCs irqchip/meson-gpio: support more than 8 channels gpio irq irqchip/meson-gpio: add select trigger type callback irqchip/meson-gpio: Add support for meson s4 SoCs
.../amlogic,meson-gpio-intc.txt | 1 + drivers/irqchip/irq-meson-gpio.c | 108 +++++++++++++++--- 2 files changed, 93 insertions(+), 16 deletions(-)
Signature · 7 lines
2.34.1 _______________________________________________ linux-amlogic mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-amlogic
PATCH v3 1/4 dt-bindings: interrupt-controller: New binding for Meson-S4 SoCs
Update dt-binding document for GPIO interrupt controller of Meson-S4 SoCs
--- .../bindings/interrupt-controller/amlogic,meson-gpio-intc.txt | 1 + 1 file changed, 1 insertion(+)
Documentation/devicetree/bindings/interrupt-controller/amlogic,meson-gpio-intc.txt +1 -0
@@ -18,6 +18,7 @@ Required properties: "amlogic,meson-g12a-gpio-intc" for G12A SoCs (S905D2, S905X2, S905Y2) "amlogic,meson-sm1-gpio-intc" for SM1 SoCs (S905D3, S905X3, S905Y3) "amlogic,meson-a1-gpio-intc" for A1 SoCs (A113L) + "amlogic,meson-s4-gpio-intc" for S4 SoCs (S802X2, S905Y4, S805X2G, S905W2) - reg : Specifies base physical address and size of the registers. - interrupt-controller : Identifies the node as an interrupt controller. - #interrupt-cells : Specifies the number of cells needed to encode an
Signature · 7 lines
2.34.1 _______________________________________________ linux-amlogic mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-amlogic
[irqchip: irq/irqchip-next] dt-bindings: interrupt-controller: New binding for Meson-S4 SoCs
The following commit has been merged into the irq/irqchip-next branch of irqchip:
The following commit has been merged into the irq/irqchip-next branch of irqchip:
Commit-ID: d6a3be863dcf8c51ba2d18d8fd47a1fadb1336aa Gitweb: https://git.kernel.org/pub/scm/linux/kernel/git/maz/arm-platforms/d6a3be863dcf8c51ba2d18d8fd47a1fadb1336aa Author: Qianggui Song <[email protected]> AuthorDate: Fri, 25 Feb 2022 13:52:03 +08:00 Committer: Marc Zyngier <[email protected]> CommitterDate: Fri, 04 Mar 2022 17:01:03
dt-bindings: interrupt-controller: New binding for Meson-S4 SoCs
Update dt-binding document for GPIO interrupt controller of Meson-S4 SoCs
--- Documentation/devicetree/bindings/interrupt-controller/amlogic,meson-gpio-intc.txt | 1 + 1 file changed, 1 insertion(+)
Documentation/devicetree/bindings/interrupt-controller/amlogic,meson-gpio-intc.txt +1 -0
@@ -18,6 +18,7 @@ Required properties: "amlogic,meson-g12a-gpio-intc" for G12A SoCs (S905D2, S905X2, S905Y2) "amlogic,meson-sm1-gpio-intc" for SM1 SoCs (S905D3, S905X3, S905Y3) "amlogic,meson-a1-gpio-intc" for A1 SoCs (A113L) + "amlogic,meson-s4-gpio-intc" for S4 SoCs (S802X2, S905Y4, S805X2G, S905W2) - reg : Specifies base physical address and size of the registers. - interrupt-controller : Identifies the node as an interrupt controller. - #interrupt-cells : Specifies the number of cells needed to encode an
PATCH v3 2/4 irqchip/meson-gpio: support more than 8 channels gpio irq
In reply to Qianggui SongCurrent meson gpio irqchip driver only support 8 channels for gpio irq line, later chips may have more then 8 channels, so need to modify code to support more.
--- drivers/irqchip/irq-meson-gpio.c | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-)
drivers/irqchip/irq-meson-gpio.c +12 -9
@@ -16,7 +16,7 @@#include <linux/of.h> #include <linux/of_address.h> -#define NUM_CHANNEL 8 +#define MAX_NUM_CHANNEL 64#define MAX_INPUT_MUX 256#define REG_EDGE_POL 0x00
@@ -60,6 +60,7 @@ struct irq_ctl_ops {struct meson_gpio_irq_params {unsigned int nr_hwirq; +unsigned int nr_channels;bool support_edge_both;unsigned int edge_both_offset;unsigned int edge_single_offset;
@@ -81,6 +82,7 @@ struct meson_gpio_irq_params { .edge_single_offset = 0, \ .pol_low_offset = 16, \ .pin_sel_mask = 0xff, \ + .nr_channels = 8, \#define INIT_MESON_A1_COMMON_DATA (irqs) \ INIT_MESON_COMMON(irqs, meson_a1_gpio_irq_init, \
@@ -90,6 +92,7 @@ struct meson_gpio_irq_params { .edge_single_offset = 8, \ .pol_low_offset = 0, \ .pin_sel_mask = 0x7f, \ + .nr_channels = 8, \static const struct meson_gpio_irq_params meson8_params = {INIT_MESON8_COMMON_DATA (134 )
@@ -136,8 +139,8 @@ static const struct of_device_id meson_irq_gpio_matches[] = {struct meson_gpio_irq_controller {const struct meson_gpio_irq_params *params;void __iomem *base; -u32 channel_irqs[NUM_CHANNEL ]; - DECLARE_BITMAP(channel_map, NUM_CHANNEL); +u32 channel_irqs[MAX_NUM_CHANNEL ]; + DECLARE_BITMAP(channel_map, MAX_NUM_CHANNEL);spinlock_t lock; };
@@ -207,8 +210,8 @@ meson_gpio_irq_request_channel(struct meson_gpio_irq_controller *ctl,spin_lock_irqsave (&ctl->lock, flags);/* Find a free channel */ - idx =find_first_zero_bit (ctl->channel_map,NUM_CHANNEL ); -if (idx >=NUM_CHANNEL ) { + idx =find_first_zero_bit (ctl->channel_map, ctl->params->nr_channels); +if (idx >= ctl->params->nr_channels) {spin_unlock_irqrestore (&ctl->lock, flags);pr_err ("No channel available\n" );return -ENOSPC ;
@@ -450,10 +453,10 @@ static int meson_gpio_irq_parse_dt(struct device_node *node, struct meson_gpio_i ret =of_property_read_variable_u32_array (node,"amlogic,channel-interrupts" , ctl->channel_irqs, -NUM_CHANNEL , -NUM_CHANNEL ); + ctl->params->nr_channels, + ctl->params->nr_channels);if (ret <0 ) { -pr_err ("can't get %d channel interrupts\n" ,NUM_CHANNEL ); +pr_err ("can't get %d channel interrupts\n" , ctl->params->nr_channels);return ret; }
@@ -507,7 +510,7 @@ static int meson_gpio_irq_of_init(struct device_node *node, struct device_node * }pr_info ("%d to %d gpio interrupt mux initialized\n" , - ctl->params->nr_hwirq,NUM_CHANNEL ); + ctl->params->nr_hwirq, ctl->params->nr_channels);return 0 ;
Signature · 7 lines
2.34.1 _______________________________________________ linux-amlogic mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-amlogic
[irqchip: irq/irqchip-next] irqchip/meson-gpio: support more than 8 channels gpio irq
The following commit has been merged into the irq/irqchip-next branch of irqchip:
The following commit has been merged into the irq/irqchip-next branch of irqchip:
Commit-ID: cc311074f681443266ed9f5969a5b5a0e833c5bc Gitweb: https://git.kernel.org/pub/scm/linux/kernel/git/maz/arm-platforms/cc311074f681443266ed9f5969a5b5a0e833c5bc Author: Qianggui Song <[email protected]> AuthorDate: Fri, 25 Feb 2022 13:52:04 +08:00 Committer: Marc Zyngier <[email protected]> CommitterDate: Fri, 04 Mar 2022 17:01:03
irqchip/meson-gpio: support more than 8 channels gpio irq
Current meson gpio irqchip driver only support 8 channels for gpio irq line, later chips may have more then 8 channels, so need to modify code to support more.
--- drivers/irqchip/irq-meson-gpio.c | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-)
drivers/irqchip/irq-meson-gpio.c +12 -9
@@ -16,7 +16,7 @@#include <linux/of.h> #include <linux/of_address.h> -#define NUM_CHANNEL 8 +#define MAX_NUM_CHANNEL 64#define MAX_INPUT_MUX 256#define REG_EDGE_POL 0x00
@@ -60,6 +60,7 @@ struct irq_ctl_ops {struct meson_gpio_irq_params {unsigned int nr_hwirq; +unsigned int nr_channels;bool support_edge_both;unsigned int edge_both_offset;unsigned int edge_single_offset;
@@ -81,6 +82,7 @@ struct meson_gpio_irq_params { .edge_single_offset = 0, \ .pol_low_offset = 16, \ .pin_sel_mask = 0xff, \ + .nr_channels = 8, \#define INIT_MESON_A1_COMMON_DATA (irqs) \ INIT_MESON_COMMON(irqs, meson_a1_gpio_irq_init, \
@@ -90,6 +92,7 @@ struct meson_gpio_irq_params { .edge_single_offset = 8, \ .pol_low_offset = 0, \ .pin_sel_mask = 0x7f, \ + .nr_channels = 8, \static const struct meson_gpio_irq_params meson8_params = {INIT_MESON8_COMMON_DATA (134 )
@@ -136,8 +139,8 @@ static const struct of_device_id meson_irq_gpio_matches[] = {struct meson_gpio_irq_controller {const struct meson_gpio_irq_params *params;void __iomem *base; -u32 channel_irqs[NUM_CHANNEL ]; - DECLARE_BITMAP(channel_map, NUM_CHANNEL); +u32 channel_irqs[MAX_NUM_CHANNEL ]; + DECLARE_BITMAP(channel_map, MAX_NUM_CHANNEL);spinlock_t lock; };
@@ -207,8 +210,8 @@ meson_gpio_irq_request_channel(struct meson_gpio_irq_controller *ctl,spin_lock_irqsave (&ctl->lock, flags);/* Find a free channel */ - idx =find_first_zero_bit (ctl->channel_map,NUM_CHANNEL ); -if (idx >=NUM_CHANNEL ) { + idx =find_first_zero_bit (ctl->channel_map, ctl->params->nr_channels); +if (idx >= ctl->params->nr_channels) {spin_unlock_irqrestore (&ctl->lock, flags);pr_err ("No channel available\n" );return -ENOSPC ;
@@ -450,10 +453,10 @@ static int meson_gpio_irq_parse_dt(struct device_node *node, struct meson_gpio_i ret =of_property_read_variable_u32_array (node,"amlogic,channel-interrupts" , ctl->channel_irqs, -NUM_CHANNEL , -NUM_CHANNEL ); + ctl->params->nr_channels, + ctl->params->nr_channels);if (ret <0 ) { -pr_err ("can't get %d channel interrupts\n" ,NUM_CHANNEL ); +pr_err ("can't get %d channel interrupts\n" , ctl->params->nr_channels);return ret; }
@@ -507,7 +510,7 @@ static int meson_gpio_irq_of_init(struct device_node *node, struct device_node * }pr_info ("%d to %d gpio interrupt mux initialized\n" , - ctl->params->nr_hwirq,NUM_CHANNEL ); + ctl->params->nr_hwirq, ctl->params->nr_channels);return 0 ;
PATCH v3 3/4 irqchip/meson-gpio: add select trigger type callback
In reply to Qianggui SongDue to some chips may use different registers and offset, provide a set trigger type call back and add one for old controller.
--- drivers/irqchip/irq-meson-gpio.c | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-)
drivers/irqchip/irq-meson-gpio.c +13 -7
@@ -51,11 +51,15 @@ static void meson_a1_gpio_irq_sel_pin(struct meson_gpio_irq_controller *ctl,unsigned int channel, unsigned long hwirq);static void meson_a1_gpio_irq_init (struct meson_gpio_irq_controller *ctl); +static int meson8_gpio_irq_set_type (struct meson_gpio_irq_controller *ctl, +unsigned int type,u32 *channel_hwirq);struct irq_ctl_ops {void (*gpio_irq_sel_pin)(struct meson_gpio_irq_controller *ctl,unsigned int channel,unsigned long hwirq);void (*gpio_irq_init)(struct meson_gpio_irq_controller *ctl); +int (*gpio_irq_set_type)(struct meson_gpio_irq_controller *ctl, +unsigned int type,u32 *channel_hwirq); };struct meson_gpio_irq_params {
@@ -69,16 +73,18 @@ struct meson_gpio_irq_params {struct irq_ctl_ops ops; }; -#define INIT_MESON_COMMON (irqs, init, sel) \ +#define INIT_MESON_COMMON (irqs, init, sel, type) \ .nr_hwirq = irqs, \ .ops = { \ .gpio_irq_init = init, \ .gpio_irq_sel_pin = sel, \ + .gpio_irq_set_type = type, \ },#define INIT_MESON8_COMMON_DATA (irqs) \ INIT_MESON_COMMON(irqs, meson_gpio_irq_init_dummy, \ - meson8_gpio_irq_sel_pin) \ + meson8_gpio_irq_sel_pin, \ + meson8_gpio_irq_set_type) \ .edge_single_offset = 0, \ .pol_low_offset = 16, \ .pin_sel_mask = 0xff, \
@@ -86,7 +92,8 @@ struct meson_gpio_irq_params {#define INIT_MESON_A1_COMMON_DATA (irqs) \ INIT_MESON_COMMON(irqs, meson_a1_gpio_irq_init, \ - meson_a1_gpio_irq_sel_pin) \ + meson_a1_gpio_irq_sel_pin, \ + meson8_gpio_irq_set_type) \ .support_edge_both = true, \ .edge_both_offset = 16, \ .edge_single_offset = 8, \
@@ -259,9 +266,8 @@ meson_gpio_irq_release_channel(struct meson_gpio_irq_controller *ctl,clear_bit (idx, ctl->channel_map); } -static int meson_gpio_irq_type_setup (struct meson_gpio_irq_controller *ctl, -unsigned int type, -u32 *channel_hwirq) +static int meson8_gpio_irq_set_type (struct meson_gpio_irq_controller *ctl, +unsigned int type,u32 *channel_hwirq) {u32 val =0 ;unsigned int idx;
@@ -326,7 +332,7 @@ static int meson_gpio_irq_set_type(struct irq_data *data, unsigned int type)u32 *channel_hwirq =irq_data_get_irq_chip_data (data);int ret; - ret =meson_gpio_irq_type_setup (ctl, type, channel_hwirq); + ret = ctl->params->ops.gpio_irq_set_type (ctl, type, channel_hwirq);if (ret)return ret;
Signature · 7 lines
2.34.1 _______________________________________________ linux-amlogic mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-amlogic
[irqchip: irq/irqchip-next] irqchip/meson-gpio: add select trigger type callback
The following commit has been merged into the irq/irqchip-next branch of irqchip:
The following commit has been merged into the irq/irqchip-next branch of irqchip:
Commit-ID: be6692b923355206ab8cd3705d3ef0e0768adb90 Gitweb: https://git.kernel.org/pub/scm/linux/kernel/git/maz/arm-platforms/be6692b923355206ab8cd3705d3ef0e0768adb90 Author: Qianggui Song <[email protected]> AuthorDate: Fri, 25 Feb 2022 13:52:05 +08:00 Committer: Marc Zyngier <[email protected]> CommitterDate: Fri, 04 Mar 2022 17:01:04
irqchip/meson-gpio: add select trigger type callback
Due to some chips may use different registers and offset, provide a set trigger type call back and add one for old controller.
--- drivers/irqchip/irq-meson-gpio.c | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-)
drivers/irqchip/irq-meson-gpio.c +13 -7
@@ -51,11 +51,15 @@ static void meson_a1_gpio_irq_sel_pin(struct meson_gpio_irq_controller *ctl,unsigned int channel, unsigned long hwirq);static void meson_a1_gpio_irq_init (struct meson_gpio_irq_controller *ctl); +static int meson8_gpio_irq_set_type (struct meson_gpio_irq_controller *ctl, +unsigned int type,u32 *channel_hwirq);struct irq_ctl_ops {void (*gpio_irq_sel_pin)(struct meson_gpio_irq_controller *ctl,unsigned int channel,unsigned long hwirq);void (*gpio_irq_init)(struct meson_gpio_irq_controller *ctl); +int (*gpio_irq_set_type)(struct meson_gpio_irq_controller *ctl, +unsigned int type,u32 *channel_hwirq); };struct meson_gpio_irq_params {
@@ -69,16 +73,18 @@ struct meson_gpio_irq_params {struct irq_ctl_ops ops; }; -#define INIT_MESON_COMMON (irqs, init, sel) \ +#define INIT_MESON_COMMON (irqs, init, sel, type) \ .nr_hwirq = irqs, \ .ops = { \ .gpio_irq_init = init, \ .gpio_irq_sel_pin = sel, \ + .gpio_irq_set_type = type, \ },#define INIT_MESON8_COMMON_DATA (irqs) \ INIT_MESON_COMMON(irqs, meson_gpio_irq_init_dummy, \ - meson8_gpio_irq_sel_pin) \ + meson8_gpio_irq_sel_pin, \ + meson8_gpio_irq_set_type) \ .edge_single_offset = 0, \ .pol_low_offset = 16, \ .pin_sel_mask = 0xff, \
@@ -86,7 +92,8 @@ struct meson_gpio_irq_params {#define INIT_MESON_A1_COMMON_DATA (irqs) \ INIT_MESON_COMMON(irqs, meson_a1_gpio_irq_init, \ - meson_a1_gpio_irq_sel_pin) \ + meson_a1_gpio_irq_sel_pin, \ + meson8_gpio_irq_set_type) \ .support_edge_both = true, \ .edge_both_offset = 16, \ .edge_single_offset = 8, \
@@ -259,9 +266,8 @@ meson_gpio_irq_release_channel(struct meson_gpio_irq_controller *ctl,clear_bit (idx, ctl->channel_map); } -static int meson_gpio_irq_type_setup (struct meson_gpio_irq_controller *ctl, -unsigned int type, -u32 *channel_hwirq) +static int meson8_gpio_irq_set_type (struct meson_gpio_irq_controller *ctl, +unsigned int type,u32 *channel_hwirq) {u32 val =0 ;unsigned int idx;
@@ -326,7 +332,7 @@ static int meson_gpio_irq_set_type(struct irq_data *data, unsigned int type)u32 *channel_hwirq =irq_data_get_irq_chip_data (data);int ret; - ret =meson_gpio_irq_type_setup (ctl, type, channel_hwirq); + ret = ctl->params->ops.gpio_irq_set_type (ctl, type, channel_hwirq);if (ret)return ret;
PATCH v3 4/4 irqchip/meson-gpio: Add support for meson s4 SoCs
In reply to Qianggui SongThe meson s4 SoCs support 12 gpio irq lines compared with previous serial chips and have something different, details are as below.
IRQ Number:
- 80:68 13 pins on bank Z
- 67:48 20 pins on bank X
- 47:36 12 pins on bank H
- 35:24 12 pins on bank D
- 23:22 2 pins on bank E
- 21:14 8 pins on bank C
- 13:0 13 pins on bank B
--- drivers/irqchip/irq-meson-gpio.c | 67 ++++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+)
drivers/irqchip/irq-meson-gpio.c +67 -0
@@ -26,6 +26,8 @@/* use for A1 like chips */ #define REG_PIN_A1_SEL 0x04 +/* Used for s4 chips */ +#define REG_EDGE_POL_S4 0x1c/* * Note: The S905X3 datasheet reports that BOTH_EDGE is controlled by
@@ -53,6 +55,8 @@ static void meson_a1_gpio_irq_sel_pin(struct meson_gpio_irq_controller *ctl,static void meson_a1_gpio_irq_init (struct meson_gpio_irq_controller *ctl);static int meson8_gpio_irq_set_type (struct meson_gpio_irq_controller *ctl,unsigned int type,u32 *channel_hwirq); +static int meson_s4_gpio_irq_set_type (struct meson_gpio_irq_controller *ctl, +unsigned int type,u32 *channel_hwirq);struct irq_ctl_ops { void (*gpio_irq_sel_pin)(struct meson_gpio_irq_controller *ctl,
@@ -101,6 +105,17 @@ struct meson_gpio_irq_params { .pin_sel_mask = 0x7f, \ .nr_channels = 8, \ +#define INIT_MESON_S4_COMMON_DATA (irqs) \ + INIT_MESON_COMMON(irqs, meson_a1_gpio_irq_init, \ + meson_a1_gpio_irq_sel_pin, \ + meson_s4_gpio_irq_set_type) \ + .support_edge_both = true, \ + .edge_both_offset = 0, \ + .edge_single_offset = 12, \ + .pol_low_offset = 0, \ + .pin_sel_mask = 0xff, \ + .nr_channels = 12, \ +static const struct meson_gpio_irq_params meson8_params = {INIT_MESON8_COMMON_DATA (134 ) };
@@ -131,6 +146,10 @@ static const struct meson_gpio_irq_params a1_params = {INIT_MESON_A1_COMMON_DATA (62 ) }; +static const struct meson_gpio_irq_params s4_params = { +INIT_MESON_S4_COMMON_DATA (82 ) +}; +static const struct of_device_id meson_irq_gpio_matches[] = { { .compatible ="amlogic,meson8-gpio-intc" , .data = &meson8_params }, { .compatible ="amlogic,meson8b-gpio-intc" , .data = &meson8b_params },
@@ -140,6 +159,7 @@ static const struct of_device_id meson_irq_gpio_matches[] = { { .compatible = "amlogic,meson-g12a-gpio-intc", .data = &axg_params }, { .compatible = "amlogic,meson-sm1-gpio-intc", .data = &sm1_params }, { .compatible = "amlogic,meson-a1-gpio-intc", .data = &a1_params }, + { .compatible = "amlogic,meson-s4-gpio-intc", .data = &s4_params }, { } };
@@ -308,6 +328,53 @@ static int meson8_gpio_irq_set_type(struct meson_gpio_irq_controller *ctl,return 0 ; } +/* +* gpio irq relative registers for s4 +* -PADCTRL_GPIO_IRQ_CTRL0 +* bit[31]: enable/disable all the irq lines +* bit[12-23]: single edge trigger +* bit[0-11]: polarity trigger +* +* -PADCTRL_GPIO_IRQ_CTRL[X] +* bit[0-16]: 7 bits to choose gpio source for irq line 2*[X] - 2 +* bit[16-22]:7 bits to choose gpio source for irq line 2*[X] - 1 +* where X = 1-6 +* +* -PADCTRL_GPIO_IRQ_CTRL[7] +* bit[0-11]: both edge trigger +*/ +static int meson_s4_gpio_irq_set_type (struct meson_gpio_irq_controller *ctl, +unsigned int type,u32 *channel_hwirq) +{ +u32 val =0 ; +unsigned int idx; +const struct meson_gpio_irq_params *params; + + params = ctl->params; + idx =meson_gpio_irq_get_channel_idx (ctl, channel_hwirq); + + type &=IRQ_TYPE_SENSE_MASK ; + +meson_gpio_irq_update_bits (ctl,REG_EDGE_POL_S4 ,BIT (idx),0 ); + +if (type ==IRQ_TYPE_EDGE_BOTH ) { + val |=BIT (ctl->params->edge_both_offset + idx); +meson_gpio_irq_update_bits (ctl,REG_EDGE_POL_S4 , +BIT (ctl->params->edge_both_offset + idx), val); +return 0 ; + } + +if (type & (IRQ_TYPE_LEVEL_LOW |IRQ_TYPE_EDGE_FALLING )) + val |=BIT (ctl->params->pol_low_offset + idx); + +if (type & (IRQ_TYPE_EDGE_RISING |IRQ_TYPE_EDGE_FALLING )) + val |=BIT (ctl->params->edge_single_offset + idx); + +meson_gpio_irq_update_bits (ctl,REG_EDGE_POL , +BIT (idx) |BIT (12 + idx), val); +return 0 ; +}; +static unsigned int meson_gpio_irq_type_output (unsigned int type) {unsigned int sense = type &IRQ_TYPE_SENSE_MASK ;
Signature · 7 lines
2.34.1 _______________________________________________ linux-amlogic mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-amlogic
[irqchip: irq/irqchip-next] irqchip/meson-gpio: Add support for meson s4 SoCs
The following commit has been merged into the irq/irqchip-next branch of irqchip:
The following commit has been merged into the irq/irqchip-next branch of irqchip:
Commit-ID: d8a61a2ec7e75723083d33800423b151106922e0 Gitweb: https://git.kernel.org/pub/scm/linux/kernel/git/maz/arm-platforms/d8a61a2ec7e75723083d33800423b151106922e0 Author: Qianggui Song <[email protected]> AuthorDate: Fri, 25 Feb 2022 13:52:06 +08:00 Committer: Marc Zyngier <[email protected]> CommitterDate: Fri, 04 Mar 2022 17:01:04
irqchip/meson-gpio: Add support for meson s4 SoCs
The meson s4 SoCs support 12 gpio irq lines compared with previous serial chips and have something different, details are as below.
IRQ Number:
- 80:68 13 pins on bank Z
- 67:48 20 pins on bank X
- 47:36 12 pins on bank H
- 35:24 12 pins on bank D
- 23:22 2 pins on bank E
- 21:14 8 pins on bank C
- 13:0 13 pins on bank B
--- drivers/irqchip/irq-meson-gpio.c | 67 +++++++++++++++++++++++++++++++- 1 file changed, 67 insertions(+)
drivers/irqchip/irq-meson-gpio.c +67 -0
@@ -26,6 +26,8 @@/* use for A1 like chips */ #define REG_PIN_A1_SEL 0x04 +/* Used for s4 chips */ +#define REG_EDGE_POL_S4 0x1c/* * Note: The S905X3 datasheet reports that BOTH_EDGE is controlled by
@@ -53,6 +55,8 @@ static void meson_a1_gpio_irq_sel_pin(struct meson_gpio_irq_controller *ctl,static void meson_a1_gpio_irq_init (struct meson_gpio_irq_controller *ctl);static int meson8_gpio_irq_set_type (struct meson_gpio_irq_controller *ctl,unsigned int type,u32 *channel_hwirq); +static int meson_s4_gpio_irq_set_type (struct meson_gpio_irq_controller *ctl, +unsigned int type,u32 *channel_hwirq);struct irq_ctl_ops { void (*gpio_irq_sel_pin)(struct meson_gpio_irq_controller *ctl,
@@ -101,6 +105,17 @@ struct meson_gpio_irq_params { .pin_sel_mask = 0x7f, \ .nr_channels = 8, \ +#define INIT_MESON_S4_COMMON_DATA (irqs) \ + INIT_MESON_COMMON(irqs, meson_a1_gpio_irq_init, \ + meson_a1_gpio_irq_sel_pin, \ + meson_s4_gpio_irq_set_type) \ + .support_edge_both = true, \ + .edge_both_offset = 0, \ + .edge_single_offset = 12, \ + .pol_low_offset = 0, \ + .pin_sel_mask = 0xff, \ + .nr_channels = 12, \ +static const struct meson_gpio_irq_params meson8_params = {INIT_MESON8_COMMON_DATA (134 ) };
@@ -131,6 +146,10 @@ static const struct meson_gpio_irq_params a1_params = {INIT_MESON_A1_COMMON_DATA (62 ) }; +static const struct meson_gpio_irq_params s4_params = { +INIT_MESON_S4_COMMON_DATA (82 ) +}; +static const struct of_device_id meson_irq_gpio_matches[] = { { .compatible ="amlogic,meson8-gpio-intc" , .data = &meson8_params }, { .compatible ="amlogic,meson8b-gpio-intc" , .data = &meson8b_params },
@@ -140,6 +159,7 @@ static const struct of_device_id meson_irq_gpio_matches[] = { { .compatible = "amlogic,meson-g12a-gpio-intc", .data = &axg_params }, { .compatible = "amlogic,meson-sm1-gpio-intc", .data = &sm1_params }, { .compatible = "amlogic,meson-a1-gpio-intc", .data = &a1_params }, + { .compatible = "amlogic,meson-s4-gpio-intc", .data = &s4_params }, { } };
@@ -308,6 +328,53 @@ static int meson8_gpio_irq_set_type(struct meson_gpio_irq_controller *ctl,return 0 ; } +/* +* gpio irq relative registers for s4 +* -PADCTRL_GPIO_IRQ_CTRL0 +* bit[31]: enable/disable all the irq lines +* bit[12-23]: single edge trigger +* bit[0-11]: polarity trigger +* +* -PADCTRL_GPIO_IRQ_CTRL[X] +* bit[0-16]: 7 bits to choose gpio source for irq line 2*[X] - 2 +* bit[16-22]:7 bits to choose gpio source for irq line 2*[X] - 1 +* where X = 1-6 +* +* -PADCTRL_GPIO_IRQ_CTRL[7] +* bit[0-11]: both edge trigger +*/ +static int meson_s4_gpio_irq_set_type (struct meson_gpio_irq_controller *ctl, +unsigned int type,u32 *channel_hwirq) +{ +u32 val =0 ; +unsigned int idx; +const struct meson_gpio_irq_params *params; + + params = ctl->params; + idx =meson_gpio_irq_get_channel_idx (ctl, channel_hwirq); + + type &=IRQ_TYPE_SENSE_MASK ; + +meson_gpio_irq_update_bits (ctl,REG_EDGE_POL_S4 ,BIT (idx),0 ); + +if (type ==IRQ_TYPE_EDGE_BOTH ) { + val |=BIT (ctl->params->edge_both_offset + idx); +meson_gpio_irq_update_bits (ctl,REG_EDGE_POL_S4 , +BIT (ctl->params->edge_both_offset + idx), val); +return 0 ; + } + +if (type & (IRQ_TYPE_LEVEL_LOW |IRQ_TYPE_EDGE_FALLING )) + val |=BIT (ctl->params->pol_low_offset + idx); + +if (type & (IRQ_TYPE_EDGE_RISING |IRQ_TYPE_EDGE_FALLING )) + val |=BIT (ctl->params->edge_single_offset + idx); + +meson_gpio_irq_update_bits (ctl,REG_EDGE_POL , +BIT (idx) |BIT (12 + idx), val); +return 0 ; +}; +static unsigned int meson_gpio_irq_type_output (unsigned int type) {unsigned int sense = type &IRQ_TYPE_SENSE_MASK ;
[irqchip: irq/irqchip-next] irqchip/meson-gpio: Add support for meson s4 SoCs
In reply to Qianggui SongThe following commit has been merged into the irq/irqchip-next branch of irqchip:
The following commit has been merged into the irq/irqchip-next branch of irqchip:
Commit-ID: d6c47d21a0ef9a76c537f8c5258b49d61f2e160f Gitweb: https://git.kernel.org/pub/scm/linux/kernel/git/maz/arm-platforms/d6c47d21a0ef9a76c537f8c5258b49d61f2e160f Author: Qianggui Song <[email protected]> AuthorDate: Fri, 25 Feb 2022 13:52:06 +08:00 Committer: Marc Zyngier <[email protected]> CommitterDate: Wed, 09 Mar 2022 11:19:56
irqchip/meson-gpio: Add support for meson s4 SoCs
The meson s4 SoCs support 12 gpio irq lines compared with previous serial chips and have something different, details are as below.
IRQ Number:
- 80:68 13 pins on bank Z
- 67:48 20 pins on bank X
- 47:36 12 pins on bank H
- 35:24 12 pins on bank D
- 23:22 2 pins on bank E
- 21:14 8 pins on bank C
- 13:0 13 pins on bank B
--- drivers/irqchip/irq-meson-gpio.c | 65 +++++++++++++++++++++++++++++++- 1 file changed, 65 insertions(+)
drivers/irqchip/irq-meson-gpio.c +65 -0
@@ -26,6 +26,8 @@/* use for A1 like chips */ #define REG_PIN_A1_SEL 0x04 +/* Used for s4 chips */ +#define REG_EDGE_POL_S4 0x1c/* * Note: The S905X3 datasheet reports that BOTH_EDGE is controlled by
@@ -53,6 +55,8 @@ static void meson_a1_gpio_irq_sel_pin(struct meson_gpio_irq_controller *ctl,static void meson_a1_gpio_irq_init (struct meson_gpio_irq_controller *ctl);static int meson8_gpio_irq_set_type (struct meson_gpio_irq_controller *ctl,unsigned int type,u32 *channel_hwirq); +static int meson_s4_gpio_irq_set_type (struct meson_gpio_irq_controller *ctl, +unsigned int type,u32 *channel_hwirq);struct irq_ctl_ops { void (*gpio_irq_sel_pin)(struct meson_gpio_irq_controller *ctl,
@@ -101,6 +105,17 @@ struct meson_gpio_irq_params { .pin_sel_mask = 0x7f, \ .nr_channels = 8, \ +#define INIT_MESON_S4_COMMON_DATA (irqs) \ + INIT_MESON_COMMON(irqs, meson_a1_gpio_irq_init, \ + meson_a1_gpio_irq_sel_pin, \ + meson_s4_gpio_irq_set_type) \ + .support_edge_both = true, \ + .edge_both_offset = 0, \ + .edge_single_offset = 12, \ + .pol_low_offset = 0, \ + .pin_sel_mask = 0xff, \ + .nr_channels = 12, \ +static const struct meson_gpio_irq_params meson8_params = {INIT_MESON8_COMMON_DATA (134 ) };
@@ -131,6 +146,10 @@ static const struct meson_gpio_irq_params a1_params = {INIT_MESON_A1_COMMON_DATA (62 ) }; +static const struct meson_gpio_irq_params s4_params = { +INIT_MESON_S4_COMMON_DATA (82 ) +}; +static const struct of_device_id meson_irq_gpio_matches[] = { { .compatible ="amlogic,meson8-gpio-intc" , .data = &meson8_params }, { .compatible ="amlogic,meson8b-gpio-intc" , .data = &meson8b_params },
@@ -140,6 +159,7 @@ static const struct of_device_id meson_irq_gpio_matches[] = { { .compatible = "amlogic,meson-g12a-gpio-intc", .data = &axg_params }, { .compatible = "amlogic,meson-sm1-gpio-intc", .data = &sm1_params }, { .compatible = "amlogic,meson-a1-gpio-intc", .data = &a1_params }, + { .compatible = "amlogic,meson-s4-gpio-intc", .data = &s4_params }, { } };
@@ -308,6 +328,51 @@ static int meson8_gpio_irq_set_type(struct meson_gpio_irq_controller *ctl,return 0 ; } +/* +* gpio irq relative registers for s4 +* -PADCTRL_GPIO_IRQ_CTRL0 +* bit[31]: enable/disable all the irq lines +* bit[12-23]: single edge trigger +* bit[0-11]: polarity trigger +* +* -PADCTRL_GPIO_IRQ_CTRL[X] +* bit[0-16]: 7 bits to choose gpio source for irq line 2*[X] - 2 +* bit[16-22]:7 bits to choose gpio source for irq line 2*[X] - 1 +* where X = 1-6 +* +* -PADCTRL_GPIO_IRQ_CTRL[7] +* bit[0-11]: both edge trigger +*/ +static int meson_s4_gpio_irq_set_type (struct meson_gpio_irq_controller *ctl, +unsigned int type,u32 *channel_hwirq) +{ +u32 val =0 ; +unsigned int idx; + + idx =meson_gpio_irq_get_channel_idx (ctl, channel_hwirq); + + type &=IRQ_TYPE_SENSE_MASK ; + +meson_gpio_irq_update_bits (ctl,REG_EDGE_POL_S4 ,BIT (idx),0 ); + +if (type ==IRQ_TYPE_EDGE_BOTH ) { + val |=BIT (ctl->params->edge_both_offset + idx); +meson_gpio_irq_update_bits (ctl,REG_EDGE_POL_S4 , +BIT (ctl->params->edge_both_offset + idx), val); +return 0 ; + } + +if (type & (IRQ_TYPE_LEVEL_LOW |IRQ_TYPE_EDGE_FALLING )) + val |=BIT (ctl->params->pol_low_offset + idx); + +if (type & (IRQ_TYPE_EDGE_RISING |IRQ_TYPE_EDGE_FALLING )) + val |=BIT (ctl->params->edge_single_offset + idx); + +meson_gpio_irq_update_bits (ctl,REG_EDGE_POL , +BIT (idx) |BIT (12 + idx), val); +return 0 ; +}; +static unsigned int meson_gpio_irq_type_output (unsigned int type) {unsigned int sense = type &IRQ_TYPE_SENSE_MASK ;