Unified · Split
| @@ -19,6 +19,7 @@ PMIC's from Qualcomm. · 18 unmodified lines | ||
| 19 | 19 | "qcom,pm8998-gpio" |
| 20 | 20 | "qcom,pma8084-gpio" |
| 21 | 21 | "qcom,pmi8994-gpio" |
| 22 | + "qcom,pmi8998-gpio" | |
| 22 | 23 | "qcom,pms405-gpio" |
| 23 | 24 | |
| 24 | 25 | And must contain either "qcom,spmi-gpio" or "qcom,ssbi-gpio" |
| @@ -64,42 +64,8 @@ · 63 unmodified lines | ||
| 64 | 64 | reg = <0xc000>; |
| 65 | 65 | gpio-controller; |
| 66 | 66 | #gpio-cells = <2>; |
| 67 | − interrupts = <0 0xc0 0 IRQ_TYPE_NONE>, | |
| 68 | − <0 0xc1 0 IRQ_TYPE_NONE>, | |
| 69 | − <0 0xc2 0 IRQ_TYPE_NONE>, | |
| 70 | − <0 0xc3 0 IRQ_TYPE_NONE>, | |
| 71 | − <0 0xc4 0 IRQ_TYPE_NONE>, | |
| 72 | − <0 0xc5 0 IRQ_TYPE_NONE>, | |
| 73 | − <0 0xc6 0 IRQ_TYPE_NONE>, | |
| 74 | − <0 0xc7 0 IRQ_TYPE_NONE>, | |
| 75 | − <0 0xc8 0 IRQ_TYPE_NONE>, | |
| 76 | − <0 0xc9 0 IRQ_TYPE_NONE>, | |
| 77 | − <0 0xca 0 IRQ_TYPE_NONE>, | |
| 78 | − <0 0xcb 0 IRQ_TYPE_NONE>, | |
| 79 | − <0 0xcc 0 IRQ_TYPE_NONE>, | |
| 80 | − <0 0xcd 0 IRQ_TYPE_NONE>, | |
| 81 | − <0 0xce 0 IRQ_TYPE_NONE>, | |
| 82 | − <0 0xcf 0 IRQ_TYPE_NONE>, | |
| 83 | − <0 0xd0 0 IRQ_TYPE_NONE>, | |
| 84 | − <0 0xd1 0 IRQ_TYPE_NONE>, | |
| 85 | − <0 0xd2 0 IRQ_TYPE_NONE>, | |
| 86 | − <0 0xd3 0 IRQ_TYPE_NONE>, | |
| 87 | − <0 0xd4 0 IRQ_TYPE_NONE>, | |
| 88 | − <0 0xd5 0 IRQ_TYPE_NONE>, | |
| 89 | − <0 0xd6 0 IRQ_TYPE_NONE>, | |
| 90 | − <0 0xd7 0 IRQ_TYPE_NONE>, | |
| 91 | − <0 0xd8 0 IRQ_TYPE_NONE>, | |
| 92 | − <0 0xd9 0 IRQ_TYPE_NONE>, | |
| 93 | − <0 0xda 0 IRQ_TYPE_NONE>, | |
| 94 | − <0 0xdb 0 IRQ_TYPE_NONE>, | |
| 95 | − <0 0xdc 0 IRQ_TYPE_NONE>, | |
| 96 | − <0 0xdd 0 IRQ_TYPE_NONE>, | |
| 97 | − <0 0xde 0 IRQ_TYPE_NONE>, | |
| 98 | − <0 0xdf 0 IRQ_TYPE_NONE>, | |
| 99 | − <0 0xe0 0 IRQ_TYPE_NONE>, | |
| 100 | − <0 0xe1 0 IRQ_TYPE_NONE>, | |
| 101 | − <0 0xe2 0 IRQ_TYPE_NONE>, | |
| 102 | − <0 0xe3 0 IRQ_TYPE_NONE>; | |
| 67 | + interrupt-controller; | |
| 68 | + #interrupt-cells = <2>; | |
| 103 | 69 | |
| 104 | 70 | boost_bypass_n_pin: boost-bypass { |
| 105 | 71 | pins = "gpio21"; |
| @@ -32,28 +32,8 @@ · 31 unmodified lines | ||
| 32 | 32 | reg = <0xc000>; |
| 33 | 33 | gpio-controller; |
| 34 | 34 | #gpio-cells = <2>; |
| 35 | − interrupts = <0 0xc0 0 IRQ_TYPE_NONE>, | |
| 36 | − <0 0xc1 0 IRQ_TYPE_NONE>, | |
| 37 | − <0 0xc2 0 IRQ_TYPE_NONE>, | |
| 38 | − <0 0xc3 0 IRQ_TYPE_NONE>, | |
| 39 | − <0 0xc4 0 IRQ_TYPE_NONE>, | |
| 40 | − <0 0xc5 0 IRQ_TYPE_NONE>, | |
| 41 | − <0 0xc6 0 IRQ_TYPE_NONE>, | |
| 42 | − <0 0xc7 0 IRQ_TYPE_NONE>, | |
| 43 | − <0 0xc8 0 IRQ_TYPE_NONE>, | |
| 44 | − <0 0xc9 0 IRQ_TYPE_NONE>, | |
| 45 | − <0 0xca 0 IRQ_TYPE_NONE>, | |
| 46 | − <0 0xcb 0 IRQ_TYPE_NONE>, | |
| 47 | − <0 0xcc 0 IRQ_TYPE_NONE>, | |
| 48 | − <0 0xcd 0 IRQ_TYPE_NONE>, | |
| 49 | − <0 0xce 0 IRQ_TYPE_NONE>, | |
| 50 | − <0 0xcf 0 IRQ_TYPE_NONE>, | |
| 51 | − <0 0xd0 0 IRQ_TYPE_NONE>, | |
| 52 | − <0 0xd1 0 IRQ_TYPE_NONE>, | |
| 53 | − <0 0xd2 0 IRQ_TYPE_NONE>, | |
| 54 | − <0 0xd3 0 IRQ_TYPE_NONE>, | |
| 55 | − <0 0xd4 0 IRQ_TYPE_NONE>, | |
| 56 | − <0 0xd5 0 IRQ_TYPE_NONE>; | |
| 35 | + interrupt-controller; | |
| 36 | + #interrupt-cells = <2>; | |
| 57 | 37 | }; |
| 58 | 38 | |
| 59 | 39 | pma8084_mpps: mpps@a000 { |
| @@ -16,10 +16,8 @@ · 15 unmodified lines | ||
| 16 | 16 | reg = <0xc000>; |
| 17 | 17 | gpio-controller; |
| 18 | 18 | #gpio-cells = <2>; |
| 19 | − interrupts = <0 0xc0 0 IRQ_TYPE_NONE>, | |
| 20 | − <0 0xc1 0 IRQ_TYPE_NONE>, | |
| 21 | − <0 0xc2 0 IRQ_TYPE_NONE>, | |
| 22 | − <0 0xc3 0 IRQ_TYPE_NONE>; | |
| 19 | + interrupt-controller; | |
| 20 | + #interrupt-cells = <2>; | |
| 23 | 21 | }; |
| 24 | 22 | |
| 25 | 23 | }; |
| @@ -94,32 +94,8 @@ · 93 unmodified lines | ||
| 94 | 94 | reg = <0xc000>; |
| 95 | 95 | gpio-controller; |
| 96 | 96 | #gpio-cells = <2>; |
| 97 | − interrupts = <0 0xc0 0 IRQ_TYPE_NONE>, | |
| 98 | − <0 0xc1 0 IRQ_TYPE_NONE>, | |
| 99 | − <0 0xc2 0 IRQ_TYPE_NONE>, | |
| 100 | − <0 0xc3 0 IRQ_TYPE_NONE>, | |
| 101 | − <0 0xc4 0 IRQ_TYPE_NONE>, | |
| 102 | − <0 0xc5 0 IRQ_TYPE_NONE>, | |
| 103 | − <0 0xc6 0 IRQ_TYPE_NONE>, | |
| 104 | − <0 0xc7 0 IRQ_TYPE_NONE>, | |
| 105 | − <0 0xc8 0 IRQ_TYPE_NONE>, | |
| 106 | − <0 0xc9 0 IRQ_TYPE_NONE>, | |
| 107 | − <0 0xca 0 IRQ_TYPE_NONE>, | |
| 108 | − <0 0xcb 0 IRQ_TYPE_NONE>, | |
| 109 | − <0 0xcc 0 IRQ_TYPE_NONE>, | |
| 110 | − <0 0xcd 0 IRQ_TYPE_NONE>, | |
| 111 | − <0 0xce 0 IRQ_TYPE_NONE>, | |
| 112 | − <0 0xcf 0 IRQ_TYPE_NONE>, | |
| 113 | − <0 0xd0 0 IRQ_TYPE_NONE>, | |
| 114 | − <0 0xd1 0 IRQ_TYPE_NONE>, | |
| 115 | − <0 0xd2 0 IRQ_TYPE_NONE>, | |
| 116 | − <0 0xd3 0 IRQ_TYPE_NONE>, | |
| 117 | − <0 0xd4 0 IRQ_TYPE_NONE>, | |
| 118 | − <0 0xd5 0 IRQ_TYPE_NONE>, | |
| 119 | − <0 0xd6 0 IRQ_TYPE_NONE>, | |
| 120 | − <0 0xd7 0 IRQ_TYPE_NONE>, | |
| 121 | − <0 0xd8 0 IRQ_TYPE_NONE>, | |
| 122 | − <0 0xd9 0 IRQ_TYPE_NONE>; | |
| 97 | + interrupt-controller; | |
| 98 | + #interrupt-cells = <2>; | |
| 123 | 99 | }; |
| 124 | 100 | |
| 125 | 101 | }; |
| @@ -15,16 +15,8 @@ · 14 unmodified lines | ||
| 15 | 15 | reg = <0xc000>; |
| 16 | 16 | gpio-controller; |
| 17 | 17 | #gpio-cells = <2>; |
| 18 | − interrupts = <2 0xc0 0 IRQ_TYPE_NONE>, | |
| 19 | − <2 0xc1 0 IRQ_TYPE_NONE>, | |
| 20 | − <2 0xc2 0 IRQ_TYPE_NONE>, | |
| 21 | − <2 0xc3 0 IRQ_TYPE_NONE>, | |
| 22 | − <2 0xc4 0 IRQ_TYPE_NONE>, | |
| 23 | − <2 0xc5 0 IRQ_TYPE_NONE>, | |
| 24 | − <2 0xc6 0 IRQ_TYPE_NONE>, | |
| 25 | − <2 0xc7 0 IRQ_TYPE_NONE>, | |
| 26 | − <2 0xc8 0 IRQ_TYPE_NONE>, | |
| 27 | − <2 0xc9 0 IRQ_TYPE_NONE>; | |
| 18 | + interrupt-controller; | |
| 19 | + #interrupt-cells = <2>; | |
| 28 | 20 | }; |
| 29 | 21 | }; |
| 30 | 22 | |
| @@ -14,20 +14,8 @@ · 13 unmodified lines | ||
| 14 | 14 | reg = <0xc000>; |
| 15 | 15 | gpio-controller; |
| 16 | 16 | #gpio-cells = <2>; |
| 17 | − interrupts = <0 0xc0 0 IRQ_TYPE_NONE>, | |
| 18 | − <0 0xc1 0 IRQ_TYPE_NONE>, | |
| 19 | − <0 0xc2 0 IRQ_TYPE_NONE>, | |
| 20 | − <0 0xc3 0 IRQ_TYPE_NONE>, | |
| 21 | − <0 0xc4 0 IRQ_TYPE_NONE>, | |
| 22 | − <0 0xc5 0 IRQ_TYPE_NONE>, | |
| 23 | − <0 0xc6 0 IRQ_TYPE_NONE>, | |
| 24 | − <0 0xc7 0 IRQ_TYPE_NONE>, | |
| 25 | − <0 0xc8 0 IRQ_TYPE_NONE>, | |
| 26 | − <0 0xc9 0 IRQ_TYPE_NONE>, | |
| 27 | − <0 0xca 0 IRQ_TYPE_NONE>, | |
| 28 | − <0 0xcb 0 IRQ_TYPE_NONE>, | |
| 29 | − <0 0xcc 0 IRQ_TYPE_NONE>, | |
| 30 | − <0 0xcd 0 IRQ_TYPE_NONE>; | |
| 17 | + interrupt-controller; | |
| 18 | + #interrupt-cells = <2>; | |
| 31 | 19 | }; |
| 32 | 20 | }; |
| 33 | 21 | |
| @@ -1775,6 +1775,43 @@ static const struct irq_domain_ops gpiochip_domain_ops = { · 1774 unmodified lines | ||
| 1775 | 1775 | .xlate = irq_domain_xlate_twocell, |
| 1776 | 1776 | }; |
| 1777 | 1777 | |
| 1778 | +/** | |
| 1779 | + * gpiochip_irq_domain_activate() - Lock a GPIO to be used as an IRQ | |
| 1780 | + * @domain: The IRQ domain used by this IRQ chip | |
| 1781 | + * @data: Outermost irq_data associated with the IRQ | |
| 1782 | + * @reserve: If set, only reserve an interrupt vector instead of assigning one | |
| 1783 | + * | |
| 1784 | + * This function is a wrapper that calls gpiochip_lock_as_irq() and is to be | |
| 1785 | + * used as the activate function for the &struct irq_domain_ops. The host_data | |
| 1786 | + * for the IRQ domain must be the &struct gpio_chip. | |
| 1787 | + */ | |
| 1788 | +int gpiochip_irq_domain_activate(struct irq_domain *domain, | |
| 1789 | + struct irq_data *data, bool reserve) | |
| 1790 | +{ | |
| 1791 | + struct gpio_chip *chip = domain->host_data; | |
| 1792 | + | |
| 1793 | + return gpiochip_lock_as_irq(chip, data->hwirq); | |
| 1794 | +} | |
| 1795 | +EXPORT_SYMBOL_GPL(gpiochip_irq_domain_activate); | |
| 1796 | + | |
| 1797 | +/** | |
| 1798 | + * gpiochip_irq_domain_deactivate() - Unlock a GPIO used as an IRQ | |
| 1799 | + * @domain: The IRQ domain used by this IRQ chip | |
| 1800 | + * @data: Outermost irq_data associated with the IRQ | |
| 1801 | + * | |
| 1802 | + * This function is a wrapper that will call gpiochip_unlock_as_irq() and is to | |
| 1803 | + * be used as the deactivate function for the &struct irq_domain_ops. The | |
| 1804 | + * host_data for the IRQ domain must be the &struct gpio_chip. | |
| 1805 | + */ | |
| 1806 | +void gpiochip_irq_domain_deactivate(struct irq_domain *domain, | |
| 1807 | + struct irq_data *data) | |
| 1808 | +{ | |
| 1809 | + struct gpio_chip *chip = domain->host_data; | |
| 1810 | + | |
| 1811 | + return gpiochip_unlock_as_irq(chip, data->hwirq); | |
| 1812 | +} | |
| 1813 | +EXPORT_SYMBOL_GPL(gpiochip_irq_domain_deactivate); | |
| 1814 | + | |
| 1778 | 1815 | static int gpiochip_to_irq(struct gpio_chip *chip, unsigned offset) |
| 1779 | 1816 | { |
| 1780 | 1817 | if (!gpiochip_irqchip_irq_valid(chip, offset)) |
| @@ -12,6 +12,7 @@ · 11 unmodified lines | ||
| 12 | 12 | */ |
| 13 | 13 | |
| 14 | 14 | #include <linux/gpio/driver.h> |
| 15 | +#include <linux/interrupt.h> | |
| 15 | 16 | #include <linux/module.h> |
| 16 | 17 | #include <linux/of.h> |
| 17 | 18 | #include <linux/of_irq.h> |
| @@ -136,7 +137,6 @@ enum pmic_gpio_func_index { · 118 unmodified lines | ||
| 136 | 137 | /** |
| 137 | 138 | * struct pmic_gpio_pad - keep current GPIO settings |
| 138 | 139 | * @base: Address base in SPMI device. |
| 139 | − * @irq: IRQ number which this GPIO generate. | |
| 140 | 140 | * @is_enabled: Set to false when GPIO should be put in high Z state. |
| 141 | 141 | * @out_value: Cached pin output value |
| 142 | 142 | * @have_buffer: Set to true if GPIO output could be configured in push-pull, |
| @@ -156,7 +156,6 @@ enum pmic_gpio_func_index { · 13 unmodified lines | ||
| 156 | 156 | */ |
| 157 | 157 | struct pmic_gpio_pad { |
| 158 | 158 | u16 base; |
| 159 | − int irq; | |
| 160 | 159 | bool is_enabled; |
| 161 | 160 | bool out_value; |
| 162 | 161 | bool have_buffer; |
| @@ -179,6 +178,8 @@ struct pmic_gpio_state { · 16 unmodified lines | ||
| 179 | 178 | struct regmap *map; |
| 180 | 179 | struct pinctrl_dev *ctrl; |
| 181 | 180 | struct gpio_chip chip; |
| 181 | + struct fwnode_handle *fwnode; | |
| 182 | + struct irq_domain *domain; | |
| 182 | 183 | }; |
| 183 | 184 | |
| 184 | 185 | static const struct pinconf_generic_params pmic_gpio_bindings[] = { |
| @@ -761,11 +762,18 @@ static int pmic_gpio_of_xlate(struct gpio_chip *chip, · 576 unmodified lines | ||
| 761 | 762 | static int pmic_gpio_to_irq(struct gpio_chip *chip, unsigned pin) |
| 762 | 763 | { |
| 763 | 764 | struct pmic_gpio_state *state = gpiochip_get_data(chip); |
| 764 | − struct pmic_gpio_pad *pad; | |
| 765 | + struct irq_fwspec fwspec; | |
| 765 | 766 | |
| 766 | − pad = state->ctrl->desc->pins[pin].drv_data; | |
| 767 | + fwspec.fwnode = state->fwnode; | |
| 768 | + fwspec.param_count = 2; | |
| 769 | + fwspec.param[0] = pin + PMIC_GPIO_PHYSICAL_OFFSET; | |
| 770 | + /* | |
| 771 | + * Set the type to a safe value temporarily. This will be overwritten | |
| 772 | + * later with the proper value by irq_set_type. | |
| 773 | + */ | |
| 774 | + fwspec.param[1] = IRQ_TYPE_EDGE_RISING; | |
| 767 | 775 | |
| 768 | − return pad->irq; | |
| 776 | + return irq_create_fwspec_mapping(&fwspec); | |
| 769 | 777 | } |
| 770 | 778 | |
| 771 | 779 | static void pmic_gpio_dbg_show(struct seq_file *s, struct gpio_chip *chip) |
| @@ -935,8 +943,78 @@ static int pmic_gpio_populate(struct pmic_gpio_state *state, · 163 unmodified lines | ||
| 935 | 943 | return 0; |
| 936 | 944 | } |
| 937 | 945 | |
| 946 | +static struct irq_chip pmic_gpio_irq_chip = { | |
| 947 | + .name = "spmi-gpio", | |
| 948 | + .irq_ack = irq_chip_ack_parent, | |
| 949 | + .irq_mask = irq_chip_mask_parent, | |
| 950 | + .irq_unmask = irq_chip_unmask_parent, | |
| 951 | + .irq_set_type = irq_chip_set_type_parent, | |
| 952 | + .irq_set_wake = irq_chip_set_wake_parent, | |
| 953 | + .flags = IRQCHIP_MASK_ON_SUSPEND, | |
| 954 | +}; | |
| 955 | + | |
| 956 | +static int pmic_gpio_domain_translate(struct irq_domain *domain, | |
| 957 | + struct irq_fwspec *fwspec, | |
| 958 | + unsigned long *hwirq, | |
| 959 | + unsigned int *type) | |
| 960 | +{ | |
| 961 | + struct pmic_gpio_state *state = container_of(domain->host_data, | |
| 962 | + struct pmic_gpio_state, | |
| 963 | + chip); | |
| 964 | + | |
| 965 | + if (fwspec->param_count != 2 || fwspec->param[0] >= state->chip.ngpio) | |
| 966 | + return -EINVAL; | |
| 967 | + | |
| 968 | + *hwirq = fwspec->param[0] - PMIC_GPIO_PHYSICAL_OFFSET; | |
| 969 | + *type = fwspec->param[1]; | |
| 970 | + | |
| 971 | + return 0; | |
| 972 | +} | |
| 973 | + | |
| 974 | +static int pmic_gpio_domain_alloc(struct irq_domain *domain, unsigned int virq, | |
| 975 | + unsigned int nr_irqs, void *data) | |
| 976 | +{ | |
| 977 | + struct pmic_gpio_state *state = container_of(domain->host_data, | |
| 978 | + struct pmic_gpio_state, | |
| 979 | + chip); | |
| 980 | + struct irq_fwspec *fwspec = data; | |
| 981 | + struct irq_fwspec parent_fwspec; | |
| 982 | + irq_hw_number_t hwirq; | |
| 983 | + unsigned int type; | |
| 984 | + int ret, i; | |
| 985 | + | |
| 986 | + ret = pmic_gpio_domain_translate(domain, fwspec, &hwirq, &type); | |
| 987 | + if (ret) | |
| 988 | + return ret; | |
| 989 | + | |
| 990 | + for (i = 0; i < nr_irqs; i++) | |
| 991 | + irq_domain_set_info(domain, virq + i, hwirq + i, | |
| 992 | + &pmic_gpio_irq_chip, state, | |
| 993 | + handle_level_irq, NULL, NULL); | |
| 994 | + | |
| 995 | + parent_fwspec.fwnode = domain->parent->fwnode; | |
| 996 | + parent_fwspec.param_count = 4; | |
| 997 | + parent_fwspec.param[0] = 0; | |
| 998 | + parent_fwspec.param[1] = hwirq + 0xc0; | |
| 999 | + parent_fwspec.param[2] = 0; | |
| 1000 | + parent_fwspec.param[3] = fwspec->param[1]; | |
| 1001 | + | |
| 1002 | + return irq_domain_alloc_irqs_parent(domain, virq, nr_irqs, | |
| 1003 | + &parent_fwspec); | |
| 1004 | +} | |
| 1005 | + | |
| 1006 | +static const struct irq_domain_ops pmic_gpio_domain_ops = { | |
| 1007 | + .activate = gpiochip_irq_domain_activate, | |
| 1008 | + .alloc = pmic_gpio_domain_alloc, | |
| 1009 | + .deactivate = gpiochip_irq_domain_deactivate, | |
| 1010 | + .free = irq_domain_free_irqs_common, | |
| 1011 | + .translate = pmic_gpio_domain_translate, | |
| 1012 | +}; | |
| 1013 | + | |
| 938 | 1014 | static int pmic_gpio_probe(struct platform_device *pdev) |
| 939 | 1015 | { |
| 1016 | + struct irq_domain *parent_domain; | |
| 1017 | + struct device_node *parent_node; | |
| 940 | 1018 | struct device *dev = &pdev->dev; |
| 941 | 1019 | struct pinctrl_pin_desc *pindesc; |
| 942 | 1020 | struct pinctrl_desc *pctrldesc; |
| @@ -951,13 +1029,7 @@ static int pmic_gpio_probe(struct platform_device *pdev) · 8 unmodified lines | ||
| 951 | 1029 | return ret; |
| 952 | 1030 | } |
| 953 | 1031 | |
| 954 | − npins = platform_irq_count(pdev); | |
| 955 | − if (!npins) | |
| 956 | − return -EINVAL; | |
| 957 | − if (npins < 0) | |
| 958 | − return npins; | |
| 959 | − | |
| 960 | − BUG_ON(npins > ARRAY_SIZE(pmic_gpio_groups)); | |
| 1032 | + npins = (uintptr_t) device_get_match_data(&pdev->dev); | |
| 961 | 1033 | |
| 962 | 1034 | state = devm_kzalloc(dev, sizeof(*state), GFP_KERNEL); |
| 963 | 1035 | if (!state) |
| @@ -999,10 +1071,6 @@ static int pmic_gpio_probe(struct platform_device *pdev) · 35 unmodified lines | ||
| 999 | 1071 | pindesc->number = i; |
| 1000 | 1072 | pindesc->name = pmic_gpio_groups[i]; |
| 1001 | 1073 | |
| 1002 | − pad->irq = platform_get_irq(pdev, i); | |
| 1003 | − if (pad->irq < 0) | |
| 1004 | − return pad->irq; | |
| 1005 | − | |
| 1006 | 1074 | pad->base = reg + i * PMIC_GPIO_ADDRESS_RANGE; |
| 1007 | 1075 | |
| 1008 | 1076 | ret = pmic_gpio_populate(state, pad); |
| @@ -1022,10 +1090,28 @@ static int pmic_gpio_probe(struct platform_device *pdev) · 13 unmodified lines | ||
| 1022 | 1090 | if (IS_ERR(state->ctrl)) |
| 1023 | 1091 | return PTR_ERR(state->ctrl); |
| 1024 | 1092 | |
| 1093 | + parent_node = of_irq_find_parent(state->dev->of_node); | |
| 1094 | + if (!parent_node) | |
| 1095 | + return -ENXIO; | |
| 1096 | + | |
| 1097 | + parent_domain = irq_find_host(parent_node); | |
| 1098 | + of_node_put(parent_node); | |
| 1099 | + if (!parent_domain) | |
| 1100 | + return -ENXIO; | |
| 1101 | + | |
| 1102 | + state->fwnode = of_node_to_fwnode(state->dev->of_node); | |
| 1103 | + state->domain = irq_domain_create_hierarchy(parent_domain, 0, | |
| 1104 | + state->chip.ngpio, | |
| 1105 | + state->fwnode, | |
| 1106 | + &pmic_gpio_domain_ops, | |
| 1107 | + &state->chip); | |
| 1108 | + if (!state->domain) | |
| 1109 | + return -ENODEV; | |
| 1110 | + | |
| 1025 | 1111 | ret = gpiochip_add_data(&state->chip, state); |
| 1026 | 1112 | if (ret) { |
| 1027 | 1113 | dev_err(state->dev, "can't add gpio chip\n"); |
| 1028 | − return ret; | |
| 1114 | + goto err_chip_add_data; | |
| 1029 | 1115 | } |
| 1030 | 1116 | |
| 1031 | 1117 | /* |
| @@ -1051,6 +1137,8 @@ static int pmic_gpio_probe(struct platform_device *pdev) · 19 unmodified lines | ||
| 1051 | 1137 | |
| 1052 | 1138 | err_range: |
| 1053 | 1139 | gpiochip_remove(&state->chip); |
| 1140 | +err_chip_add_data: | |
| 1141 | + irq_domain_remove(state->domain); | |
| 1054 | 1142 | return ret; |
| 1055 | 1143 | } |
| 1056 | 1144 | |
| @@ -1059,17 +1147,21 @@ static int pmic_gpio_remove(struct platform_device *pdev) · 2 unmodified lines | ||
| 1059 | 1147 | struct pmic_gpio_state *state = platform_get_drvdata(pdev); |
| 1060 | 1148 | |
| 1061 | 1149 | gpiochip_remove(&state->chip); |
| 1150 | + irq_domain_remove(state->domain); | |
| 1062 | 1151 | return 0; |
| 1063 | 1152 | } |
| 1064 | 1153 | |
| 1065 | 1154 | static const struct of_device_id pmic_gpio_of_match[] = { |
| 1066 | − { .compatible = "qcom,pm8916-gpio" }, /* 4 GPIO's */ | |
| 1067 | − { .compatible = "qcom,pm8941-gpio" }, /* 36 GPIO's */ | |
| 1068 | − { .compatible = "qcom,pm8994-gpio" }, /* 22 GPIO's */ | |
| 1069 | − { .compatible = "qcom,pmi8994-gpio" }, /* 10 GPIO's */ | |
| 1070 | − { .compatible = "qcom,pma8084-gpio" }, /* 22 GPIO's */ | |
| 1071 | − { .compatible = "qcom,pms405-gpio" }, /* 12 GPIO's, holes on 1 9 10 */ | |
| 1072 | − { .compatible = "qcom,spmi-gpio" }, /* Generic */ | |
| 1155 | + { .compatible = "qcom,pm8005-gpio", .data = (void *) 4 }, | |
| 1156 | + { .compatible = "qcom,pm8916-gpio", .data = (void *) 4 }, | |
| 1157 | + { .compatible = "qcom,pm8941-gpio", .data = (void *) 36 }, | |
| 1158 | + { .compatible = "qcom,pm8994-gpio", .data = (void *) 22 }, | |
| 1159 | + { .compatible = "qcom,pmi8994-gpio", .data = (void *) 10 }, | |
| 1160 | + { .compatible = "qcom,pm8998-gpio", .data = (void *) 26 }, | |
| 1161 | + { .compatible = "qcom,pmi8998-gpio", .data = (void *) 14 }, | |
| 1162 | + { .compatible = "qcom,pma8084-gpio", .data = (void *) 22 }, | |
| 1163 | + /* pms405 has 12 GPIOs with holes on 1, 9, and 10 */ | |
| 1164 | + { .compatible = "qcom,pms405-gpio", .data = (void *) 12 }, | |
| 1073 | 1165 | { }, |
| 1074 | 1166 | }; |
| 1075 | 1167 | |
| @@ -666,7 +666,8 @@ static int qpnpint_get_irqchip_state(struct irq_data *d, · 665 unmodified lines | ||
| 666 | 666 | return 0; |
| 667 | 667 | } |
| 668 | 668 | |
| 669 | −static int qpnpint_irq_request_resources(struct irq_data *d) | |
| 669 | +static int qpnpint_irq_domain_activate(struct irq_domain *domain, | |
| 670 | + struct irq_data *d, bool reserve) | |
| 670 | 671 | { |
| 671 | 672 | struct spmi_pmic_arb *pmic_arb = irq_data_get_irq_chip_data(d); |
| 672 | 673 | u16 periph = hwirq_to_per(d->hwirq); |
| @@ -692,27 +693,25 @@ static struct irq_chip pmic_arb_irqchip = { · 19 unmodified lines | ||
| 692 | 693 | .irq_set_type = qpnpint_irq_set_type, |
| 693 | 694 | .irq_set_wake = qpnpint_irq_set_wake, |
| 694 | 695 | .irq_get_irqchip_state = qpnpint_get_irqchip_state, |
| 695 | − .irq_request_resources = qpnpint_irq_request_resources, | |
| 696 | 696 | .flags = IRQCHIP_MASK_ON_SUSPEND, |
| 697 | 697 | }; |
| 698 | 698 | |
| 699 | −static int qpnpint_irq_domain_dt_translate(struct irq_domain *d, | |
| 700 | − struct device_node *controller, | |
| 701 | − const u32 *intspec, | |
| 702 | − unsigned int intsize, | |
| 703 | − unsigned long *out_hwirq, | |
| 704 | − unsigned int *out_type) | |
| 699 | +static int qpnpint_irq_domain_translate(struct irq_domain *d, | |
| 700 | + struct irq_fwspec *fwspec, | |
| 701 | + unsigned long *out_hwirq, | |
| 702 | + unsigned int *out_type) | |
| 705 | 703 | { |
| 706 | 704 | struct spmi_pmic_arb *pmic_arb = d->host_data; |
| 705 | + u32 *intspec = fwspec->param; | |
| 707 | 706 | u16 apid, ppid; |
| 708 | 707 | int rc; |
| 709 | 708 | |
| 710 | 709 | dev_dbg(&pmic_arb->spmic->dev, "intspec[0] 0x%1x intspec[1] 0x%02x intspec[2] 0x%02x\n", |
| 711 | 710 | intspec[0], intspec[1], intspec[2]); |
| 712 | 711 | |
| 713 | − if (irq_domain_get_of_node(d) != controller) | |
| 712 | + if (irq_domain_get_of_node(d) != pmic_arb->spmic->dev.of_node) | |
| 714 | 713 | return -EINVAL; |
| 715 | − if (intsize != 4) | |
| 714 | + if (fwspec->param_count != 4) | |
| 716 | 715 | return -EINVAL; |
| 717 | 716 | if (intspec[0] > 0xF || intspec[1] > 0xFF || intspec[2] > 0x7) |
| 718 | 717 | return -EINVAL; |
| @@ -740,17 +739,50 @@ static int qpnpint_irq_domain_dt_translate(struct irq_domain *d, · 21 unmodified lines | ||
| 740 | 739 | return 0; |
| 741 | 740 | } |
| 742 | 741 | |
| 743 | −static int qpnpint_irq_domain_map(struct irq_domain *d, | |
| 744 | − unsigned int virq, | |
| 745 | − irq_hw_number_t hwirq) | |
| 742 | + | |
| 743 | +static int qpnpint_irq_domain_map(struct spmi_pmic_arb *pmic_arb, | |
| 744 | + struct irq_domain *domain, unsigned int virq, | |
| 745 | + irq_hw_number_t hwirq, unsigned int type) | |
| 746 | 746 | { |
| 747 | − struct spmi_pmic_arb *pmic_arb = d->host_data; | |
| 747 | + irq_flow_handler_t handler; | |
| 748 | + | |
| 749 | + dev_dbg(&pmic_arb->spmic->dev, "virq = %u, hwirq = %lu, type = %u\n", | |
| 750 | + virq, hwirq, type); | |
| 751 | + | |
| 752 | + if (type & IRQ_TYPE_EDGE_BOTH) | |
| 753 | + handler = handle_edge_irq; | |
| 754 | + else if (type & (IRQ_TYPE_LEVEL_LOW | IRQ_TYPE_LEVEL_HIGH)) | |
| 755 | + handler = handle_level_irq; | |
| 756 | + else | |
| 757 | + return -EINVAL; | |
| 748 | 758 | |
| 749 | − dev_dbg(&pmic_arb->spmic->dev, "virq = %u, hwirq = %lu\n", virq, hwirq); | |
| 759 | + irq_domain_set_info(domain, virq, hwirq, &pmic_arb_irqchip, pmic_arb, | |
| 760 | + handler, NULL, NULL); | |
| 761 | + | |
| 762 | + return 0; | |
| 763 | +} | |
| 764 | + | |
| 765 | +static int qpnpint_irq_domain_alloc(struct irq_domain *domain, | |
| 766 | + unsigned int virq, unsigned int nr_irqs, | |
| 767 | + void *data) | |
| 768 | +{ | |
| 769 | + struct spmi_pmic_arb *pmic_arb = domain->host_data; | |
| 770 | + struct irq_fwspec *fwspec = data; | |
| 771 | + irq_hw_number_t hwirq; | |
| 772 | + unsigned int type; | |
| 773 | + int ret, i; | |
| 774 | + | |
| 775 | + ret = qpnpint_irq_domain_translate(domain, fwspec, &hwirq, &type); | |
| 776 | + if (ret) | |
| 777 | + return ret; | |
| 778 | + | |
| 779 | + for (i = 0; i < nr_irqs; i++) { | |
| 780 | + ret = qpnpint_irq_domain_map(pmic_arb, domain, virq + i, | |
| 781 | + hwirq + i, type); | |
| 782 | + if (ret) | |
| 783 | + return ret; | |
| 784 | + } | |
| 750 | 785 | |
| 751 | − irq_set_chip_and_handler(virq, &pmic_arb_irqchip, handle_level_irq); | |
| 752 | − irq_set_chip_data(virq, d->host_data); | |
| 753 | − irq_set_noprobe(virq); | |
| 754 | 786 | return 0; |
| 755 | 787 | } |
| 756 | 788 | |
| @@ -1126,8 +1158,10 @@ static const struct pmic_arb_ver_ops pmic_arb_v5 = { · 369 unmodified lines | ||
| 1126 | 1158 | }; |
| 1127 | 1159 | |
| 1128 | 1160 | static const struct irq_domain_ops pmic_arb_irq_domain_ops = { |
| 1129 | − .map = qpnpint_irq_domain_map, | |
| 1130 | − .xlate = qpnpint_irq_domain_dt_translate, | |
| 1161 | + .activate = qpnpint_irq_domain_activate, | |
| 1162 | + .alloc = qpnpint_irq_domain_alloc, | |
| 1163 | + .free = irq_domain_free_irqs_common, | |
| 1164 | + .translate = qpnpint_irq_domain_translate, | |
| 1131 | 1165 | }; |
| 1132 | 1166 | |
| 1133 | 1167 | static int spmi_pmic_arb_probe(struct platform_device *pdev) |
| @@ -472,6 +472,11 @@ int gpiochip_irq_map(struct irq_domain *d, unsigned int irq, · 471 unmodified lines | ||
| 472 | 472 | irq_hw_number_t hwirq); |
| 473 | 473 | void gpiochip_irq_unmap(struct irq_domain *d, unsigned int irq); |
| 474 | 474 | |
| 475 | +int gpiochip_irq_domain_activate(struct irq_domain *domain, | |
| 476 | + struct irq_data *data, bool reserve); | |
| 477 | +void gpiochip_irq_domain_deactivate(struct irq_domain *domain, | |
| 478 | + struct irq_data *data); | |
| 479 | + | |
| 475 | 480 | void gpiochip_set_chained_irqchip(struct gpio_chip *gpiochip, |
| 476 | 481 | struct irq_chip *irqchip, |
| 477 | 482 | unsigned int parent_irq, |