aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpio/gpio-omap.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/gpio/gpio-omap.c')
-rw-r--r--drivers/gpio/gpio-omap.c84
1 files changed, 14 insertions, 70 deletions
diff --git a/drivers/gpio/gpio-omap.c b/drivers/gpio/gpio-omap.c
index c57244ef428b..dfeb3a3a8f20 100644
--- a/drivers/gpio/gpio-omap.c
+++ b/drivers/gpio/gpio-omap.c
@@ -1037,18 +1037,6 @@ omap_mpuio_alloc_gc(struct gpio_bank *bank, unsigned int irq_start,
1037 IRQ_NOREQUEST | IRQ_NOPROBE, 0); 1037 IRQ_NOREQUEST | IRQ_NOPROBE, 0);
1038} 1038}
1039 1039
1040#if defined(CONFIG_OF_GPIO)
1041static inline bool omap_gpio_chip_boot_dt(struct gpio_chip *chip)
1042{
1043 return chip->of_node != NULL;
1044}
1045#else
1046static inline bool omap_gpio_chip_boot_dt(struct gpio_chip *chip)
1047{
1048 return false;
1049}
1050#endif
1051
1052static void omap_gpio_chip_init(struct gpio_bank *bank) 1040static void omap_gpio_chip_init(struct gpio_bank *bank)
1053{ 1041{
1054 int j; 1042 int j;
@@ -1080,68 +1068,24 @@ static void omap_gpio_chip_init(struct gpio_bank *bank)
1080 1068
1081 gpiochip_add(&bank->chip); 1069 gpiochip_add(&bank->chip);
1082 1070
1083 /* 1071 for (j = 0; j < bank->width; j++) {
1084 * REVISIT these explicit calls to irq_create_mapping() 1072 int irq = irq_create_mapping(bank->domain, j);
1085 * to do the GPIO to IRQ domain mapping for each GPIO in 1073 irq_set_lockdep_class(irq, &gpio_lock_class);
1086 * the bank can be removed once all OMAP platforms have 1074 irq_set_chip_data(irq, bank);
1087 * been migrated to Device Tree boot only. 1075 if (bank->is_mpuio) {
1088 * Since in DT boot irq_create_mapping() is called from 1076 omap_mpuio_alloc_gc(bank, irq, bank->width);
1089 * irq_create_of_mapping() only for the GPIO lines that 1077 } else {
1090 * are used as interrupts. 1078 irq_set_chip_and_handler(irq, &gpio_irq_chip,
1091 */ 1079 handle_simple_irq);
1092 if (!omap_gpio_chip_boot_dt(&bank->chip)) 1080 set_irq_flags(irq, IRQF_VALID);
1093 for (j = 0; j < bank->width; j++) 1081 }
1094 irq_create_mapping(bank->domain, j); 1082 }
1095 irq_set_chained_handler(bank->irq, gpio_irq_handler); 1083 irq_set_chained_handler(bank->irq, gpio_irq_handler);
1096 irq_set_handler_data(bank->irq, bank); 1084 irq_set_handler_data(bank->irq, bank);
1097} 1085}
1098 1086
1099static const struct of_device_id omap_gpio_match[]; 1087static const struct of_device_id omap_gpio_match[];
1100 1088
1101static int omap_gpio_irq_map(struct irq_domain *d, unsigned int virq,
1102 irq_hw_number_t hwirq)
1103{
1104 struct gpio_bank *bank = d->host_data;
1105 int gpio;
1106 int ret;
1107
1108 if (!bank)
1109 return -EINVAL;
1110
1111 irq_set_lockdep_class(virq, &gpio_lock_class);
1112 irq_set_chip_data(virq, bank);
1113 if (bank->is_mpuio) {
1114 omap_mpuio_alloc_gc(bank, virq, bank->width);
1115 } else {
1116 irq_set_chip_and_handler(virq, &gpio_irq_chip,
1117 handle_simple_irq);
1118 set_irq_flags(virq, IRQF_VALID);
1119 }
1120
1121 /*
1122 * REVISIT most GPIO IRQ chip drivers need to call
1123 * gpio_request() before a GPIO line can be used as an
1124 * IRQ. Ideally this should be handled by the IRQ core
1125 * but until then this has to be done on a per driver
1126 * basis. Remove this once this is managed by the core.
1127 */
1128 if (omap_gpio_chip_boot_dt(&bank->chip)) {
1129 gpio = irq_to_gpio(bank, hwirq);
1130 ret = gpio_request_one(gpio, GPIOF_IN, NULL);
1131 if (ret) {
1132 dev_err(bank->dev, "Could not request GPIO%d\n", gpio);
1133 return ret;
1134 }
1135 }
1136
1137 return 0;
1138}
1139
1140static struct irq_domain_ops omap_gpio_irq_ops = {
1141 .xlate = irq_domain_xlate_onetwocell,
1142 .map = omap_gpio_irq_map,
1143};
1144
1145static int omap_gpio_probe(struct platform_device *pdev) 1089static int omap_gpio_probe(struct platform_device *pdev)
1146{ 1090{
1147 struct device *dev = &pdev->dev; 1091 struct device *dev = &pdev->dev;
@@ -1207,10 +1151,10 @@ static int omap_gpio_probe(struct platform_device *pdev)
1207 } 1151 }
1208 1152
1209 bank->domain = irq_domain_add_legacy(node, bank->width, irq_base, 1153 bank->domain = irq_domain_add_legacy(node, bank->width, irq_base,
1210 0, &omap_gpio_irq_ops, bank); 1154 0, &irq_domain_simple_ops, NULL);
1211#else 1155#else
1212 bank->domain = irq_domain_add_linear(node, bank->width, 1156 bank->domain = irq_domain_add_linear(node, bank->width,
1213 &omap_gpio_irq_ops, bank); 1157 &irq_domain_simple_ops, NULL);
1214#endif 1158#endif
1215 if (!bank->domain) { 1159 if (!bank->domain) {
1216 dev_err(dev, "Couldn't register an IRQ domain\n"); 1160 dev_err(dev, "Couldn't register an IRQ domain\n");