diff options
| -rw-r--r-- | drivers/gpio/gpio-msm-v2.c | 2 | ||||
| -rw-r--r-- | drivers/gpio/gpio-omap.c | 84 |
2 files changed, 71 insertions, 15 deletions
diff --git a/drivers/gpio/gpio-msm-v2.c b/drivers/gpio/gpio-msm-v2.c index f4491a497cc8..c2fa77086eb5 100644 --- a/drivers/gpio/gpio-msm-v2.c +++ b/drivers/gpio/gpio-msm-v2.c | |||
| @@ -378,7 +378,7 @@ static int msm_gpio_probe(struct platform_device *pdev) | |||
| 378 | int ret, ngpio; | 378 | int ret, ngpio; |
| 379 | struct resource *res; | 379 | struct resource *res; |
| 380 | 380 | ||
| 381 | if (!of_property_read_u32(pdev->dev.of_node, "ngpio", &ngpio)) { | 381 | if (of_property_read_u32(pdev->dev.of_node, "ngpio", &ngpio)) { |
| 382 | dev_err(&pdev->dev, "%s: ngpio property missing\n", __func__); | 382 | dev_err(&pdev->dev, "%s: ngpio property missing\n", __func__); |
| 383 | return -EINVAL; | 383 | return -EINVAL; |
| 384 | } | 384 | } |
diff --git a/drivers/gpio/gpio-omap.c b/drivers/gpio/gpio-omap.c index dfeb3a3a8f20..c57244ef428b 100644 --- a/drivers/gpio/gpio-omap.c +++ b/drivers/gpio/gpio-omap.c | |||
| @@ -1037,6 +1037,18 @@ 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) | ||
| 1041 | static inline bool omap_gpio_chip_boot_dt(struct gpio_chip *chip) | ||
| 1042 | { | ||
| 1043 | return chip->of_node != NULL; | ||
| 1044 | } | ||
| 1045 | #else | ||
| 1046 | static inline bool omap_gpio_chip_boot_dt(struct gpio_chip *chip) | ||
| 1047 | { | ||
| 1048 | return false; | ||
| 1049 | } | ||
| 1050 | #endif | ||
| 1051 | |||
| 1040 | static void omap_gpio_chip_init(struct gpio_bank *bank) | 1052 | static void omap_gpio_chip_init(struct gpio_bank *bank) |
| 1041 | { | 1053 | { |
| 1042 | int j; | 1054 | int j; |
| @@ -1068,24 +1080,68 @@ static void omap_gpio_chip_init(struct gpio_bank *bank) | |||
| 1068 | 1080 | ||
| 1069 | gpiochip_add(&bank->chip); | 1081 | gpiochip_add(&bank->chip); |
| 1070 | 1082 | ||
| 1071 | for (j = 0; j < bank->width; j++) { | 1083 | /* |
| 1072 | int irq = irq_create_mapping(bank->domain, j); | 1084 | * REVISIT these explicit calls to irq_create_mapping() |
| 1073 | irq_set_lockdep_class(irq, &gpio_lock_class); | 1085 | * to do the GPIO to IRQ domain mapping for each GPIO in |
| 1074 | irq_set_chip_data(irq, bank); | 1086 | * the bank can be removed once all OMAP platforms have |
| 1075 | if (bank->is_mpuio) { | 1087 | * been migrated to Device Tree boot only. |
| 1076 | omap_mpuio_alloc_gc(bank, irq, bank->width); | 1088 | * Since in DT boot irq_create_mapping() is called from |
| 1077 | } else { | 1089 | * irq_create_of_mapping() only for the GPIO lines that |
| 1078 | irq_set_chip_and_handler(irq, &gpio_irq_chip, | 1090 | * are used as interrupts. |
| 1079 | handle_simple_irq); | 1091 | */ |
| 1080 | set_irq_flags(irq, IRQF_VALID); | 1092 | if (!omap_gpio_chip_boot_dt(&bank->chip)) |
| 1081 | } | 1093 | for (j = 0; j < bank->width; j++) |
| 1082 | } | 1094 | irq_create_mapping(bank->domain, j); |
| 1083 | irq_set_chained_handler(bank->irq, gpio_irq_handler); | 1095 | irq_set_chained_handler(bank->irq, gpio_irq_handler); |
| 1084 | irq_set_handler_data(bank->irq, bank); | 1096 | irq_set_handler_data(bank->irq, bank); |
| 1085 | } | 1097 | } |
| 1086 | 1098 | ||
| 1087 | static const struct of_device_id omap_gpio_match[]; | 1099 | static const struct of_device_id omap_gpio_match[]; |
| 1088 | 1100 | ||
| 1101 | static 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 | |||
| 1140 | static struct irq_domain_ops omap_gpio_irq_ops = { | ||
| 1141 | .xlate = irq_domain_xlate_onetwocell, | ||
| 1142 | .map = omap_gpio_irq_map, | ||
| 1143 | }; | ||
| 1144 | |||
| 1089 | static int omap_gpio_probe(struct platform_device *pdev) | 1145 | static int omap_gpio_probe(struct platform_device *pdev) |
| 1090 | { | 1146 | { |
| 1091 | struct device *dev = &pdev->dev; | 1147 | struct device *dev = &pdev->dev; |
| @@ -1151,10 +1207,10 @@ static int omap_gpio_probe(struct platform_device *pdev) | |||
| 1151 | } | 1207 | } |
| 1152 | 1208 | ||
| 1153 | bank->domain = irq_domain_add_legacy(node, bank->width, irq_base, | 1209 | bank->domain = irq_domain_add_legacy(node, bank->width, irq_base, |
| 1154 | 0, &irq_domain_simple_ops, NULL); | 1210 | 0, &omap_gpio_irq_ops, bank); |
| 1155 | #else | 1211 | #else |
| 1156 | bank->domain = irq_domain_add_linear(node, bank->width, | 1212 | bank->domain = irq_domain_add_linear(node, bank->width, |
| 1157 | &irq_domain_simple_ops, NULL); | 1213 | &omap_gpio_irq_ops, bank); |
| 1158 | #endif | 1214 | #endif |
| 1159 | if (!bank->domain) { | 1215 | if (!bank->domain) { |
| 1160 | dev_err(dev, "Couldn't register an IRQ domain\n"); | 1216 | dev_err(dev, "Couldn't register an IRQ domain\n"); |
