diff options
author | Jon Hunter <jonathanh@nvidia.com> | 2016-06-07 11:12:31 -0400 |
---|---|---|
committer | Marc Zyngier <marc.zyngier@arm.com> | 2016-06-13 06:53:52 -0400 |
commit | faea645585de88303a74171321a9188fd3dd7df5 (patch) | |
tree | 9ae09b2d257e514c9fba988f7d48ae2e7a7f0ae5 /drivers/irqchip/irq-gic.c | |
parent | d6ce564cea0c9f8fe7e1b400026482f4e61d38ad (diff) |
irqchip/gic: Add helper function for chip initialisation
For GICs that require runtime power-management it is necessary to
populate the 'parent_device' member of the irqchip structure. In
preparation for supporting such GICs, move the code that initialises
the irqchip structure for a GIC into its own function called
gic_init_chip() where the parent device pointer is also set.
Instead of calling gic_init_chip() from within gic_init_bases(), move
the calls to outside of this function, so that in the future we can
avoid having to pass additional parameters to gic_init_bases() in order
set the parent device pointer or set the name to a specific string.
Signed-off-by: Jon Hunter <jonathanh@nvidia.com>
Signed-off-by: Marc Zyngier <marc.zyngier@arm.com>
Diffstat (limited to 'drivers/irqchip/irq-gic.c')
-rw-r--r-- | drivers/irqchip/irq-gic.c | 41 |
1 files changed, 27 insertions, 14 deletions
diff --git a/drivers/irqchip/irq-gic.c b/drivers/irqchip/irq-gic.c index fa0dd98993fa..94eab6e23124 100644 --- a/drivers/irqchip/irq-gic.c +++ b/drivers/irqchip/irq-gic.c | |||
@@ -1032,29 +1032,31 @@ static const struct irq_domain_ops gic_irq_domain_ops = { | |||
1032 | .unmap = gic_irq_domain_unmap, | 1032 | .unmap = gic_irq_domain_unmap, |
1033 | }; | 1033 | }; |
1034 | 1034 | ||
1035 | static int gic_init_bases(struct gic_chip_data *gic, int irq_start, | 1035 | static void gic_init_chip(struct gic_chip_data *gic, struct device *dev, |
1036 | struct fwnode_handle *handle) | 1036 | const char *name, bool use_eoimode1) |
1037 | { | 1037 | { |
1038 | irq_hw_number_t hwirq_base; | ||
1039 | int gic_irqs, irq_base, ret; | ||
1040 | |||
1041 | /* Initialize irq_chip */ | 1038 | /* Initialize irq_chip */ |
1042 | gic->chip = gic_chip; | 1039 | gic->chip = gic_chip; |
1040 | gic->chip.name = name; | ||
1041 | gic->chip.parent_device = dev; | ||
1043 | 1042 | ||
1044 | if (static_key_true(&supports_deactivate) && gic == &gic_data[0]) { | 1043 | if (use_eoimode1) { |
1045 | gic->chip.irq_mask = gic_eoimode1_mask_irq; | 1044 | gic->chip.irq_mask = gic_eoimode1_mask_irq; |
1046 | gic->chip.irq_eoi = gic_eoimode1_eoi_irq; | 1045 | gic->chip.irq_eoi = gic_eoimode1_eoi_irq; |
1047 | gic->chip.irq_set_vcpu_affinity = gic_irq_set_vcpu_affinity; | 1046 | gic->chip.irq_set_vcpu_affinity = gic_irq_set_vcpu_affinity; |
1048 | gic->chip.name = kasprintf(GFP_KERNEL, "GICv2"); | ||
1049 | } else { | ||
1050 | gic->chip.name = kasprintf(GFP_KERNEL, "GIC-%d", | ||
1051 | (int)(gic - &gic_data[0])); | ||
1052 | } | 1047 | } |
1053 | 1048 | ||
1054 | #ifdef CONFIG_SMP | 1049 | #ifdef CONFIG_SMP |
1055 | if (gic == &gic_data[0]) | 1050 | if (gic == &gic_data[0]) |
1056 | gic->chip.irq_set_affinity = gic_set_affinity; | 1051 | gic->chip.irq_set_affinity = gic_set_affinity; |
1057 | #endif | 1052 | #endif |
1053 | } | ||
1054 | |||
1055 | static int gic_init_bases(struct gic_chip_data *gic, int irq_start, | ||
1056 | struct fwnode_handle *handle) | ||
1057 | { | ||
1058 | irq_hw_number_t hwirq_base; | ||
1059 | int gic_irqs, irq_base, ret; | ||
1058 | 1060 | ||
1059 | if (IS_ENABLED(CONFIG_GIC_NON_BANKED) && gic->percpu_offset) { | 1061 | if (IS_ENABLED(CONFIG_GIC_NON_BANKED) && gic->percpu_offset) { |
1060 | /* Frankein-GIC without banked registers... */ | 1062 | /* Frankein-GIC without banked registers... */ |
@@ -1152,8 +1154,6 @@ error: | |||
1152 | free_percpu(gic->cpu_base.percpu_base); | 1154 | free_percpu(gic->cpu_base.percpu_base); |
1153 | } | 1155 | } |
1154 | 1156 | ||
1155 | kfree(gic->chip.name); | ||
1156 | |||
1157 | return ret; | 1157 | return ret; |
1158 | } | 1158 | } |
1159 | 1159 | ||
@@ -1161,7 +1161,8 @@ static int __init __gic_init_bases(struct gic_chip_data *gic, | |||
1161 | int irq_start, | 1161 | int irq_start, |
1162 | struct fwnode_handle *handle) | 1162 | struct fwnode_handle *handle) |
1163 | { | 1163 | { |
1164 | int i; | 1164 | char *name; |
1165 | int i, ret; | ||
1165 | 1166 | ||
1166 | if (WARN_ON(!gic || gic->domain)) | 1167 | if (WARN_ON(!gic || gic->domain)) |
1167 | return -EINVAL; | 1168 | return -EINVAL; |
@@ -1183,7 +1184,19 @@ static int __init __gic_init_bases(struct gic_chip_data *gic, | |||
1183 | pr_info("GIC: Using split EOI/Deactivate mode\n"); | 1184 | pr_info("GIC: Using split EOI/Deactivate mode\n"); |
1184 | } | 1185 | } |
1185 | 1186 | ||
1186 | return gic_init_bases(gic, irq_start, handle); | 1187 | if (static_key_true(&supports_deactivate) && gic == &gic_data[0]) { |
1188 | name = kasprintf(GFP_KERNEL, "GICv2"); | ||
1189 | gic_init_chip(gic, NULL, name, true); | ||
1190 | } else { | ||
1191 | name = kasprintf(GFP_KERNEL, "GIC-%d", (int)(gic-&gic_data[0])); | ||
1192 | gic_init_chip(gic, NULL, name, false); | ||
1193 | } | ||
1194 | |||
1195 | ret = gic_init_bases(gic, irq_start, handle); | ||
1196 | if (ret) | ||
1197 | kfree(name); | ||
1198 | |||
1199 | return ret; | ||
1187 | } | 1200 | } |
1188 | 1201 | ||
1189 | void __init gic_init(unsigned int gic_nr, int irq_start, | 1202 | void __init gic_init(unsigned int gic_nr, int irq_start, |