Thomas Abraham | 43b169d | 2012-09-07 06:07:19 +0900 | [diff] [blame] | 1 | /* |
| 2 | * Exynos specific support for Samsung pinctrl/gpiolib driver with eint support. |
| 3 | * |
| 4 | * Copyright (c) 2012 Samsung Electronics Co., Ltd. |
| 5 | * http://www.samsung.com |
| 6 | * Copyright (c) 2012 Linaro Ltd |
| 7 | * http://www.linaro.org |
| 8 | * |
| 9 | * Author: Thomas Abraham <thomas.ab@samsung.com> |
| 10 | * |
| 11 | * This program is free software; you can redistribute it and/or modify |
| 12 | * it under the terms of the GNU General Public License as published by |
| 13 | * the Free Software Foundation; either version 2 of the License, or |
| 14 | * (at your option) any later version. |
| 15 | * |
| 16 | * This file contains the Samsung Exynos specific information required by the |
| 17 | * the Samsung pinctrl/gpiolib driver. It also includes the implementation of |
| 18 | * external gpio and wakeup interrupt support. |
| 19 | */ |
| 20 | |
| 21 | #include <linux/module.h> |
| 22 | #include <linux/device.h> |
| 23 | #include <linux/interrupt.h> |
| 24 | #include <linux/irqdomain.h> |
| 25 | #include <linux/irq.h> |
Catalin Marinas | de88cbb | 2013-01-18 15:31:37 +0000 | [diff] [blame] | 26 | #include <linux/irqchip/chained_irq.h> |
Thomas Abraham | 43b169d | 2012-09-07 06:07:19 +0900 | [diff] [blame] | 27 | #include <linux/of_irq.h> |
| 28 | #include <linux/io.h> |
| 29 | #include <linux/slab.h> |
Tomasz Figa | 1984695 | 2013-03-18 22:31:50 +0100 | [diff] [blame] | 30 | #include <linux/spinlock.h> |
Thomas Abraham | 43b169d | 2012-09-07 06:07:19 +0900 | [diff] [blame] | 31 | #include <linux/err.h> |
| 32 | |
Thomas Abraham | 43b169d | 2012-09-07 06:07:19 +0900 | [diff] [blame] | 33 | #include "pinctrl-samsung.h" |
| 34 | #include "pinctrl-exynos.h" |
| 35 | |
Tomasz Figa | 499147c | 2013-03-18 22:31:52 +0100 | [diff] [blame] | 36 | |
| 37 | static struct samsung_pin_bank_type bank_type_off = { |
| 38 | .fld_width = { 4, 1, 2, 2, 2, 2, }, |
Tomasz Figa | 43fc9e7 | 2013-03-18 22:31:53 +0100 | [diff] [blame] | 39 | .reg_offset = { 0x00, 0x04, 0x08, 0x0c, 0x10, 0x14, }, |
Tomasz Figa | 499147c | 2013-03-18 22:31:52 +0100 | [diff] [blame] | 40 | }; |
| 41 | |
| 42 | static struct samsung_pin_bank_type bank_type_alive = { |
| 43 | .fld_width = { 4, 1, 2, 2, }, |
Tomasz Figa | 43fc9e7 | 2013-03-18 22:31:53 +0100 | [diff] [blame] | 44 | .reg_offset = { 0x00, 0x04, 0x08, 0x0c, }, |
Tomasz Figa | 499147c | 2013-03-18 22:31:52 +0100 | [diff] [blame] | 45 | }; |
| 46 | |
Thomas Abraham | 43b169d | 2012-09-07 06:07:19 +0900 | [diff] [blame] | 47 | /* list of external wakeup controllers supported */ |
| 48 | static const struct of_device_id exynos_wkup_irq_ids[] = { |
| 49 | { .compatible = "samsung,exynos4210-wakeup-eint", }, |
Axel Lin | afa538c | 2012-11-02 21:46:13 +0800 | [diff] [blame] | 50 | { } |
Thomas Abraham | 43b169d | 2012-09-07 06:07:19 +0900 | [diff] [blame] | 51 | }; |
| 52 | |
| 53 | static void exynos_gpio_irq_unmask(struct irq_data *irqd) |
| 54 | { |
Tomasz Figa | 595be72 | 2012-10-11 10:11:16 +0200 | [diff] [blame] | 55 | struct samsung_pin_bank *bank = irq_data_get_irq_chip_data(irqd); |
| 56 | struct samsung_pinctrl_drv_data *d = bank->drvdata; |
| 57 | unsigned long reg_mask = d->ctrl->geint_mask + bank->eint_offset; |
Thomas Abraham | 43b169d | 2012-09-07 06:07:19 +0900 | [diff] [blame] | 58 | unsigned long mask; |
| 59 | |
| 60 | mask = readl(d->virt_base + reg_mask); |
Tomasz Figa | 595be72 | 2012-10-11 10:11:16 +0200 | [diff] [blame] | 61 | mask &= ~(1 << irqd->hwirq); |
Thomas Abraham | 43b169d | 2012-09-07 06:07:19 +0900 | [diff] [blame] | 62 | writel(mask, d->virt_base + reg_mask); |
| 63 | } |
| 64 | |
| 65 | static void exynos_gpio_irq_mask(struct irq_data *irqd) |
| 66 | { |
Tomasz Figa | 595be72 | 2012-10-11 10:11:16 +0200 | [diff] [blame] | 67 | struct samsung_pin_bank *bank = irq_data_get_irq_chip_data(irqd); |
| 68 | struct samsung_pinctrl_drv_data *d = bank->drvdata; |
| 69 | unsigned long reg_mask = d->ctrl->geint_mask + bank->eint_offset; |
Thomas Abraham | 43b169d | 2012-09-07 06:07:19 +0900 | [diff] [blame] | 70 | unsigned long mask; |
| 71 | |
| 72 | mask = readl(d->virt_base + reg_mask); |
Tomasz Figa | 595be72 | 2012-10-11 10:11:16 +0200 | [diff] [blame] | 73 | mask |= 1 << irqd->hwirq; |
Thomas Abraham | 43b169d | 2012-09-07 06:07:19 +0900 | [diff] [blame] | 74 | writel(mask, d->virt_base + reg_mask); |
| 75 | } |
| 76 | |
| 77 | static void exynos_gpio_irq_ack(struct irq_data *irqd) |
| 78 | { |
Tomasz Figa | 595be72 | 2012-10-11 10:11:16 +0200 | [diff] [blame] | 79 | struct samsung_pin_bank *bank = irq_data_get_irq_chip_data(irqd); |
| 80 | struct samsung_pinctrl_drv_data *d = bank->drvdata; |
| 81 | unsigned long reg_pend = d->ctrl->geint_pend + bank->eint_offset; |
Thomas Abraham | 43b169d | 2012-09-07 06:07:19 +0900 | [diff] [blame] | 82 | |
Tomasz Figa | 595be72 | 2012-10-11 10:11:16 +0200 | [diff] [blame] | 83 | writel(1 << irqd->hwirq, d->virt_base + reg_pend); |
Thomas Abraham | 43b169d | 2012-09-07 06:07:19 +0900 | [diff] [blame] | 84 | } |
| 85 | |
| 86 | static int exynos_gpio_irq_set_type(struct irq_data *irqd, unsigned int type) |
| 87 | { |
Tomasz Figa | 595be72 | 2012-10-11 10:11:16 +0200 | [diff] [blame] | 88 | struct samsung_pin_bank *bank = irq_data_get_irq_chip_data(irqd); |
Tomasz Figa | 499147c | 2013-03-18 22:31:52 +0100 | [diff] [blame] | 89 | struct samsung_pin_bank_type *bank_type = bank->type; |
Tomasz Figa | 595be72 | 2012-10-11 10:11:16 +0200 | [diff] [blame] | 90 | struct samsung_pinctrl_drv_data *d = bank->drvdata; |
Thomas Abraham | 43b169d | 2012-09-07 06:07:19 +0900 | [diff] [blame] | 91 | struct samsung_pin_ctrl *ctrl = d->ctrl; |
Tomasz Figa | 595be72 | 2012-10-11 10:11:16 +0200 | [diff] [blame] | 92 | unsigned int pin = irqd->hwirq; |
| 93 | unsigned int shift = EXYNOS_EINT_CON_LEN * pin; |
Thomas Abraham | 43b169d | 2012-09-07 06:07:19 +0900 | [diff] [blame] | 94 | unsigned int con, trig_type; |
Tomasz Figa | 595be72 | 2012-10-11 10:11:16 +0200 | [diff] [blame] | 95 | unsigned long reg_con = ctrl->geint_con + bank->eint_offset; |
Tomasz Figa | 1984695 | 2013-03-18 22:31:50 +0100 | [diff] [blame] | 96 | unsigned long flags; |
Tomasz Figa | ee2f573 | 2012-09-21 07:33:48 +0900 | [diff] [blame] | 97 | unsigned int mask; |
Thomas Abraham | 43b169d | 2012-09-07 06:07:19 +0900 | [diff] [blame] | 98 | |
| 99 | switch (type) { |
| 100 | case IRQ_TYPE_EDGE_RISING: |
| 101 | trig_type = EXYNOS_EINT_EDGE_RISING; |
| 102 | break; |
| 103 | case IRQ_TYPE_EDGE_FALLING: |
| 104 | trig_type = EXYNOS_EINT_EDGE_FALLING; |
| 105 | break; |
| 106 | case IRQ_TYPE_EDGE_BOTH: |
| 107 | trig_type = EXYNOS_EINT_EDGE_BOTH; |
| 108 | break; |
| 109 | case IRQ_TYPE_LEVEL_HIGH: |
| 110 | trig_type = EXYNOS_EINT_LEVEL_HIGH; |
| 111 | break; |
| 112 | case IRQ_TYPE_LEVEL_LOW: |
| 113 | trig_type = EXYNOS_EINT_LEVEL_LOW; |
| 114 | break; |
| 115 | default: |
| 116 | pr_err("unsupported external interrupt type\n"); |
| 117 | return -EINVAL; |
| 118 | } |
| 119 | |
| 120 | if (type & IRQ_TYPE_EDGE_BOTH) |
| 121 | __irq_set_handler_locked(irqd->irq, handle_edge_irq); |
| 122 | else |
| 123 | __irq_set_handler_locked(irqd->irq, handle_level_irq); |
| 124 | |
| 125 | con = readl(d->virt_base + reg_con); |
| 126 | con &= ~(EXYNOS_EINT_CON_MASK << shift); |
| 127 | con |= trig_type << shift; |
| 128 | writel(con, d->virt_base + reg_con); |
Tomasz Figa | ee2f573 | 2012-09-21 07:33:48 +0900 | [diff] [blame] | 129 | |
Tomasz Figa | 43fc9e7 | 2013-03-18 22:31:53 +0100 | [diff] [blame] | 130 | reg_con = bank->pctl_offset + bank_type->reg_offset[PINCFG_TYPE_FUNC]; |
Tomasz Figa | 499147c | 2013-03-18 22:31:52 +0100 | [diff] [blame] | 131 | shift = pin * bank_type->fld_width[PINCFG_TYPE_FUNC]; |
| 132 | mask = (1 << bank_type->fld_width[PINCFG_TYPE_FUNC]) - 1; |
Tomasz Figa | ee2f573 | 2012-09-21 07:33:48 +0900 | [diff] [blame] | 133 | |
Tomasz Figa | 1984695 | 2013-03-18 22:31:50 +0100 | [diff] [blame] | 134 | spin_lock_irqsave(&bank->slock, flags); |
| 135 | |
Tomasz Figa | ee2f573 | 2012-09-21 07:33:48 +0900 | [diff] [blame] | 136 | con = readl(d->virt_base + reg_con); |
| 137 | con &= ~(mask << shift); |
| 138 | con |= EXYNOS_EINT_FUNC << shift; |
| 139 | writel(con, d->virt_base + reg_con); |
| 140 | |
Tomasz Figa | 1984695 | 2013-03-18 22:31:50 +0100 | [diff] [blame] | 141 | spin_unlock_irqrestore(&bank->slock, flags); |
| 142 | |
Thomas Abraham | 43b169d | 2012-09-07 06:07:19 +0900 | [diff] [blame] | 143 | return 0; |
| 144 | } |
| 145 | |
| 146 | /* |
| 147 | * irq_chip for gpio interrupts. |
| 148 | */ |
| 149 | static struct irq_chip exynos_gpio_irq_chip = { |
| 150 | .name = "exynos_gpio_irq_chip", |
| 151 | .irq_unmask = exynos_gpio_irq_unmask, |
| 152 | .irq_mask = exynos_gpio_irq_mask, |
| 153 | .irq_ack = exynos_gpio_irq_ack, |
| 154 | .irq_set_type = exynos_gpio_irq_set_type, |
| 155 | }; |
| 156 | |
Thomas Abraham | 43b169d | 2012-09-07 06:07:19 +0900 | [diff] [blame] | 157 | static int exynos_gpio_irq_map(struct irq_domain *h, unsigned int virq, |
| 158 | irq_hw_number_t hw) |
| 159 | { |
Tomasz Figa | 595be72 | 2012-10-11 10:11:16 +0200 | [diff] [blame] | 160 | struct samsung_pin_bank *b = h->host_data; |
Thomas Abraham | 43b169d | 2012-09-07 06:07:19 +0900 | [diff] [blame] | 161 | |
Tomasz Figa | 595be72 | 2012-10-11 10:11:16 +0200 | [diff] [blame] | 162 | irq_set_chip_data(virq, b); |
Thomas Abraham | 43b169d | 2012-09-07 06:07:19 +0900 | [diff] [blame] | 163 | irq_set_chip_and_handler(virq, &exynos_gpio_irq_chip, |
| 164 | handle_level_irq); |
| 165 | set_irq_flags(virq, IRQF_VALID); |
| 166 | return 0; |
| 167 | } |
| 168 | |
Thomas Abraham | 43b169d | 2012-09-07 06:07:19 +0900 | [diff] [blame] | 169 | /* |
| 170 | * irq domain callbacks for external gpio interrupt controller. |
| 171 | */ |
| 172 | static const struct irq_domain_ops exynos_gpio_irqd_ops = { |
| 173 | .map = exynos_gpio_irq_map, |
Thomas Abraham | 43b169d | 2012-09-07 06:07:19 +0900 | [diff] [blame] | 174 | .xlate = irq_domain_xlate_twocell, |
| 175 | }; |
| 176 | |
| 177 | static irqreturn_t exynos_eint_gpio_irq(int irq, void *data) |
| 178 | { |
| 179 | struct samsung_pinctrl_drv_data *d = data; |
| 180 | struct samsung_pin_ctrl *ctrl = d->ctrl; |
| 181 | struct samsung_pin_bank *bank = ctrl->pin_banks; |
| 182 | unsigned int svc, group, pin, virq; |
| 183 | |
| 184 | svc = readl(d->virt_base + ctrl->svc); |
| 185 | group = EXYNOS_SVC_GROUP(svc); |
| 186 | pin = svc & EXYNOS_SVC_NUM_MASK; |
| 187 | |
| 188 | if (!group) |
| 189 | return IRQ_HANDLED; |
| 190 | bank += (group - 1); |
| 191 | |
Tomasz Figa | 595be72 | 2012-10-11 10:11:16 +0200 | [diff] [blame] | 192 | virq = irq_linear_revmap(bank->irq_domain, pin); |
Thomas Abraham | 43b169d | 2012-09-07 06:07:19 +0900 | [diff] [blame] | 193 | if (!virq) |
| 194 | return IRQ_NONE; |
| 195 | generic_handle_irq(virq); |
| 196 | return IRQ_HANDLED; |
| 197 | } |
| 198 | |
| 199 | /* |
| 200 | * exynos_eint_gpio_init() - setup handling of external gpio interrupts. |
| 201 | * @d: driver data of samsung pinctrl driver. |
| 202 | */ |
| 203 | static int exynos_eint_gpio_init(struct samsung_pinctrl_drv_data *d) |
| 204 | { |
Tomasz Figa | 595be72 | 2012-10-11 10:11:16 +0200 | [diff] [blame] | 205 | struct samsung_pin_bank *bank; |
Thomas Abraham | 43b169d | 2012-09-07 06:07:19 +0900 | [diff] [blame] | 206 | struct device *dev = d->dev; |
| 207 | unsigned int ret; |
Tomasz Figa | 595be72 | 2012-10-11 10:11:16 +0200 | [diff] [blame] | 208 | unsigned int i; |
Thomas Abraham | 43b169d | 2012-09-07 06:07:19 +0900 | [diff] [blame] | 209 | |
| 210 | if (!d->irq) { |
| 211 | dev_err(dev, "irq number not available\n"); |
| 212 | return -EINVAL; |
| 213 | } |
| 214 | |
| 215 | ret = devm_request_irq(dev, d->irq, exynos_eint_gpio_irq, |
| 216 | 0, dev_name(dev), d); |
| 217 | if (ret) { |
| 218 | dev_err(dev, "irq request failed\n"); |
| 219 | return -ENXIO; |
| 220 | } |
| 221 | |
Tomasz Figa | 595be72 | 2012-10-11 10:11:16 +0200 | [diff] [blame] | 222 | bank = d->ctrl->pin_banks; |
| 223 | for (i = 0; i < d->ctrl->nr_banks; ++i, ++bank) { |
| 224 | if (bank->eint_type != EINT_TYPE_GPIO) |
| 225 | continue; |
| 226 | bank->irq_domain = irq_domain_add_linear(bank->of_node, |
| 227 | bank->nr_pins, &exynos_gpio_irqd_ops, bank); |
| 228 | if (!bank->irq_domain) { |
| 229 | dev_err(dev, "gpio irq domain add failed\n"); |
| 230 | return -ENXIO; |
| 231 | } |
Thomas Abraham | 43b169d | 2012-09-07 06:07:19 +0900 | [diff] [blame] | 232 | } |
| 233 | |
| 234 | return 0; |
| 235 | } |
| 236 | |
| 237 | static void exynos_wkup_irq_unmask(struct irq_data *irqd) |
| 238 | { |
Tomasz Figa | a04b07c | 2012-10-11 10:11:18 +0200 | [diff] [blame] | 239 | struct samsung_pin_bank *b = irq_data_get_irq_chip_data(irqd); |
| 240 | struct samsung_pinctrl_drv_data *d = b->drvdata; |
| 241 | unsigned long reg_mask = d->ctrl->weint_mask + b->eint_offset; |
Thomas Abraham | 43b169d | 2012-09-07 06:07:19 +0900 | [diff] [blame] | 242 | unsigned long mask; |
| 243 | |
| 244 | mask = readl(d->virt_base + reg_mask); |
Tomasz Figa | a04b07c | 2012-10-11 10:11:18 +0200 | [diff] [blame] | 245 | mask &= ~(1 << irqd->hwirq); |
Thomas Abraham | 43b169d | 2012-09-07 06:07:19 +0900 | [diff] [blame] | 246 | writel(mask, d->virt_base + reg_mask); |
| 247 | } |
| 248 | |
| 249 | static void exynos_wkup_irq_mask(struct irq_data *irqd) |
| 250 | { |
Tomasz Figa | a04b07c | 2012-10-11 10:11:18 +0200 | [diff] [blame] | 251 | struct samsung_pin_bank *b = irq_data_get_irq_chip_data(irqd); |
| 252 | struct samsung_pinctrl_drv_data *d = b->drvdata; |
| 253 | unsigned long reg_mask = d->ctrl->weint_mask + b->eint_offset; |
Thomas Abraham | 43b169d | 2012-09-07 06:07:19 +0900 | [diff] [blame] | 254 | unsigned long mask; |
| 255 | |
| 256 | mask = readl(d->virt_base + reg_mask); |
Tomasz Figa | a04b07c | 2012-10-11 10:11:18 +0200 | [diff] [blame] | 257 | mask |= 1 << irqd->hwirq; |
Thomas Abraham | 43b169d | 2012-09-07 06:07:19 +0900 | [diff] [blame] | 258 | writel(mask, d->virt_base + reg_mask); |
| 259 | } |
| 260 | |
| 261 | static void exynos_wkup_irq_ack(struct irq_data *irqd) |
| 262 | { |
Tomasz Figa | a04b07c | 2012-10-11 10:11:18 +0200 | [diff] [blame] | 263 | struct samsung_pin_bank *b = irq_data_get_irq_chip_data(irqd); |
| 264 | struct samsung_pinctrl_drv_data *d = b->drvdata; |
| 265 | unsigned long pend = d->ctrl->weint_pend + b->eint_offset; |
Thomas Abraham | 43b169d | 2012-09-07 06:07:19 +0900 | [diff] [blame] | 266 | |
Tomasz Figa | a04b07c | 2012-10-11 10:11:18 +0200 | [diff] [blame] | 267 | writel(1 << irqd->hwirq, d->virt_base + pend); |
Thomas Abraham | 43b169d | 2012-09-07 06:07:19 +0900 | [diff] [blame] | 268 | } |
| 269 | |
| 270 | static int exynos_wkup_irq_set_type(struct irq_data *irqd, unsigned int type) |
| 271 | { |
Tomasz Figa | a04b07c | 2012-10-11 10:11:18 +0200 | [diff] [blame] | 272 | struct samsung_pin_bank *bank = irq_data_get_irq_chip_data(irqd); |
Tomasz Figa | 499147c | 2013-03-18 22:31:52 +0100 | [diff] [blame] | 273 | struct samsung_pin_bank_type *bank_type = bank->type; |
Tomasz Figa | a04b07c | 2012-10-11 10:11:18 +0200 | [diff] [blame] | 274 | struct samsung_pinctrl_drv_data *d = bank->drvdata; |
| 275 | unsigned int pin = irqd->hwirq; |
| 276 | unsigned long reg_con = d->ctrl->weint_con + bank->eint_offset; |
Thomas Abraham | 43b169d | 2012-09-07 06:07:19 +0900 | [diff] [blame] | 277 | unsigned long shift = EXYNOS_EINT_CON_LEN * pin; |
| 278 | unsigned long con, trig_type; |
Tomasz Figa | 1984695 | 2013-03-18 22:31:50 +0100 | [diff] [blame] | 279 | unsigned long flags; |
Tomasz Figa | 22b9ba0 | 2012-10-11 10:11:19 +0200 | [diff] [blame] | 280 | unsigned int mask; |
Thomas Abraham | 43b169d | 2012-09-07 06:07:19 +0900 | [diff] [blame] | 281 | |
| 282 | switch (type) { |
| 283 | case IRQ_TYPE_EDGE_RISING: |
| 284 | trig_type = EXYNOS_EINT_EDGE_RISING; |
| 285 | break; |
| 286 | case IRQ_TYPE_EDGE_FALLING: |
| 287 | trig_type = EXYNOS_EINT_EDGE_FALLING; |
| 288 | break; |
| 289 | case IRQ_TYPE_EDGE_BOTH: |
| 290 | trig_type = EXYNOS_EINT_EDGE_BOTH; |
| 291 | break; |
| 292 | case IRQ_TYPE_LEVEL_HIGH: |
| 293 | trig_type = EXYNOS_EINT_LEVEL_HIGH; |
| 294 | break; |
| 295 | case IRQ_TYPE_LEVEL_LOW: |
| 296 | trig_type = EXYNOS_EINT_LEVEL_LOW; |
| 297 | break; |
| 298 | default: |
| 299 | pr_err("unsupported external interrupt type\n"); |
| 300 | return -EINVAL; |
| 301 | } |
| 302 | |
| 303 | if (type & IRQ_TYPE_EDGE_BOTH) |
| 304 | __irq_set_handler_locked(irqd->irq, handle_edge_irq); |
| 305 | else |
| 306 | __irq_set_handler_locked(irqd->irq, handle_level_irq); |
| 307 | |
| 308 | con = readl(d->virt_base + reg_con); |
| 309 | con &= ~(EXYNOS_EINT_CON_MASK << shift); |
| 310 | con |= trig_type << shift; |
| 311 | writel(con, d->virt_base + reg_con); |
Tomasz Figa | 22b9ba0 | 2012-10-11 10:11:19 +0200 | [diff] [blame] | 312 | |
Tomasz Figa | 43fc9e7 | 2013-03-18 22:31:53 +0100 | [diff] [blame] | 313 | reg_con = bank->pctl_offset + bank_type->reg_offset[PINCFG_TYPE_FUNC]; |
Tomasz Figa | 499147c | 2013-03-18 22:31:52 +0100 | [diff] [blame] | 314 | shift = pin * bank_type->fld_width[PINCFG_TYPE_FUNC]; |
| 315 | mask = (1 << bank_type->fld_width[PINCFG_TYPE_FUNC]) - 1; |
Tomasz Figa | 22b9ba0 | 2012-10-11 10:11:19 +0200 | [diff] [blame] | 316 | |
Tomasz Figa | 1984695 | 2013-03-18 22:31:50 +0100 | [diff] [blame] | 317 | spin_lock_irqsave(&bank->slock, flags); |
| 318 | |
Tomasz Figa | 22b9ba0 | 2012-10-11 10:11:19 +0200 | [diff] [blame] | 319 | con = readl(d->virt_base + reg_con); |
| 320 | con &= ~(mask << shift); |
| 321 | con |= EXYNOS_EINT_FUNC << shift; |
| 322 | writel(con, d->virt_base + reg_con); |
| 323 | |
Tomasz Figa | 1984695 | 2013-03-18 22:31:50 +0100 | [diff] [blame] | 324 | spin_unlock_irqrestore(&bank->slock, flags); |
| 325 | |
Thomas Abraham | 43b169d | 2012-09-07 06:07:19 +0900 | [diff] [blame] | 326 | return 0; |
| 327 | } |
| 328 | |
Tomasz Figa | ad350cd | 2013-05-17 18:24:27 +0200 | [diff] [blame^] | 329 | static u32 exynos_eint_wake_mask = 0xffffffff; |
| 330 | |
| 331 | u32 exynos_get_eint_wake_mask(void) |
| 332 | { |
| 333 | return exynos_eint_wake_mask; |
| 334 | } |
| 335 | |
| 336 | static int exynos_wkup_irq_set_wake(struct irq_data *irqd, unsigned int on) |
| 337 | { |
| 338 | struct samsung_pin_bank *bank = irq_data_get_irq_chip_data(irqd); |
| 339 | unsigned long bit = 1UL << (2 * bank->eint_offset + irqd->hwirq); |
| 340 | |
| 341 | pr_info("wake %s for irq %d\n", on ? "enabled" : "disabled", irqd->irq); |
| 342 | |
| 343 | if (!on) |
| 344 | exynos_eint_wake_mask |= bit; |
| 345 | else |
| 346 | exynos_eint_wake_mask &= ~bit; |
| 347 | |
| 348 | return 0; |
| 349 | } |
| 350 | |
Thomas Abraham | 43b169d | 2012-09-07 06:07:19 +0900 | [diff] [blame] | 351 | /* |
| 352 | * irq_chip for wakeup interrupts |
| 353 | */ |
| 354 | static struct irq_chip exynos_wkup_irq_chip = { |
| 355 | .name = "exynos_wkup_irq_chip", |
| 356 | .irq_unmask = exynos_wkup_irq_unmask, |
| 357 | .irq_mask = exynos_wkup_irq_mask, |
| 358 | .irq_ack = exynos_wkup_irq_ack, |
| 359 | .irq_set_type = exynos_wkup_irq_set_type, |
Tomasz Figa | ad350cd | 2013-05-17 18:24:27 +0200 | [diff] [blame^] | 360 | .irq_set_wake = exynos_wkup_irq_set_wake, |
Thomas Abraham | 43b169d | 2012-09-07 06:07:19 +0900 | [diff] [blame] | 361 | }; |
| 362 | |
| 363 | /* interrupt handler for wakeup interrupts 0..15 */ |
| 364 | static void exynos_irq_eint0_15(unsigned int irq, struct irq_desc *desc) |
| 365 | { |
| 366 | struct exynos_weint_data *eintd = irq_get_handler_data(irq); |
Tomasz Figa | a04b07c | 2012-10-11 10:11:18 +0200 | [diff] [blame] | 367 | struct samsung_pin_bank *bank = eintd->bank; |
Thomas Abraham | 43b169d | 2012-09-07 06:07:19 +0900 | [diff] [blame] | 368 | struct irq_chip *chip = irq_get_chip(irq); |
| 369 | int eint_irq; |
| 370 | |
| 371 | chained_irq_enter(chip, desc); |
| 372 | chip->irq_mask(&desc->irq_data); |
| 373 | |
| 374 | if (chip->irq_ack) |
| 375 | chip->irq_ack(&desc->irq_data); |
| 376 | |
Tomasz Figa | a04b07c | 2012-10-11 10:11:18 +0200 | [diff] [blame] | 377 | eint_irq = irq_linear_revmap(bank->irq_domain, eintd->irq); |
Thomas Abraham | 43b169d | 2012-09-07 06:07:19 +0900 | [diff] [blame] | 378 | generic_handle_irq(eint_irq); |
| 379 | chip->irq_unmask(&desc->irq_data); |
| 380 | chained_irq_exit(chip, desc); |
| 381 | } |
| 382 | |
Tomasz Figa | a04b07c | 2012-10-11 10:11:18 +0200 | [diff] [blame] | 383 | static inline void exynos_irq_demux_eint(unsigned long pend, |
| 384 | struct irq_domain *domain) |
Thomas Abraham | 43b169d | 2012-09-07 06:07:19 +0900 | [diff] [blame] | 385 | { |
| 386 | unsigned int irq; |
| 387 | |
| 388 | while (pend) { |
| 389 | irq = fls(pend) - 1; |
Tomasz Figa | a04b07c | 2012-10-11 10:11:18 +0200 | [diff] [blame] | 390 | generic_handle_irq(irq_find_mapping(domain, irq)); |
Thomas Abraham | 43b169d | 2012-09-07 06:07:19 +0900 | [diff] [blame] | 391 | pend &= ~(1 << irq); |
| 392 | } |
| 393 | } |
| 394 | |
| 395 | /* interrupt handler for wakeup interrupt 16 */ |
| 396 | static void exynos_irq_demux_eint16_31(unsigned int irq, struct irq_desc *desc) |
| 397 | { |
| 398 | struct irq_chip *chip = irq_get_chip(irq); |
Tomasz Figa | a04b07c | 2012-10-11 10:11:18 +0200 | [diff] [blame] | 399 | struct exynos_muxed_weint_data *eintd = irq_get_handler_data(irq); |
| 400 | struct samsung_pinctrl_drv_data *d = eintd->banks[0]->drvdata; |
| 401 | struct samsung_pin_ctrl *ctrl = d->ctrl; |
Thomas Abraham | 43b169d | 2012-09-07 06:07:19 +0900 | [diff] [blame] | 402 | unsigned long pend; |
Tomasz Figa | de59049 | 2012-09-21 07:33:55 +0900 | [diff] [blame] | 403 | unsigned long mask; |
Tomasz Figa | a04b07c | 2012-10-11 10:11:18 +0200 | [diff] [blame] | 404 | int i; |
Thomas Abraham | 43b169d | 2012-09-07 06:07:19 +0900 | [diff] [blame] | 405 | |
| 406 | chained_irq_enter(chip, desc); |
Tomasz Figa | a04b07c | 2012-10-11 10:11:18 +0200 | [diff] [blame] | 407 | |
| 408 | for (i = 0; i < eintd->nr_banks; ++i) { |
| 409 | struct samsung_pin_bank *b = eintd->banks[i]; |
| 410 | pend = readl(d->virt_base + ctrl->weint_pend + b->eint_offset); |
| 411 | mask = readl(d->virt_base + ctrl->weint_mask + b->eint_offset); |
| 412 | exynos_irq_demux_eint(pend & ~mask, b->irq_domain); |
| 413 | } |
| 414 | |
Thomas Abraham | 43b169d | 2012-09-07 06:07:19 +0900 | [diff] [blame] | 415 | chained_irq_exit(chip, desc); |
| 416 | } |
| 417 | |
| 418 | static int exynos_wkup_irq_map(struct irq_domain *h, unsigned int virq, |
| 419 | irq_hw_number_t hw) |
| 420 | { |
| 421 | irq_set_chip_and_handler(virq, &exynos_wkup_irq_chip, handle_level_irq); |
| 422 | irq_set_chip_data(virq, h->host_data); |
| 423 | set_irq_flags(virq, IRQF_VALID); |
| 424 | return 0; |
| 425 | } |
| 426 | |
| 427 | /* |
| 428 | * irq domain callbacks for external wakeup interrupt controller. |
| 429 | */ |
| 430 | static const struct irq_domain_ops exynos_wkup_irqd_ops = { |
| 431 | .map = exynos_wkup_irq_map, |
| 432 | .xlate = irq_domain_xlate_twocell, |
| 433 | }; |
| 434 | |
| 435 | /* |
| 436 | * exynos_eint_wkup_init() - setup handling of external wakeup interrupts. |
| 437 | * @d: driver data of samsung pinctrl driver. |
| 438 | */ |
| 439 | static int exynos_eint_wkup_init(struct samsung_pinctrl_drv_data *d) |
| 440 | { |
| 441 | struct device *dev = d->dev; |
Tomasz Figa | c3ad056 | 2012-09-21 07:34:01 +0900 | [diff] [blame] | 442 | struct device_node *wkup_np = NULL; |
| 443 | struct device_node *np; |
Tomasz Figa | a04b07c | 2012-10-11 10:11:18 +0200 | [diff] [blame] | 444 | struct samsung_pin_bank *bank; |
Thomas Abraham | 43b169d | 2012-09-07 06:07:19 +0900 | [diff] [blame] | 445 | struct exynos_weint_data *weint_data; |
Tomasz Figa | a04b07c | 2012-10-11 10:11:18 +0200 | [diff] [blame] | 446 | struct exynos_muxed_weint_data *muxed_data; |
| 447 | unsigned int muxed_banks = 0; |
| 448 | unsigned int i; |
Thomas Abraham | 43b169d | 2012-09-07 06:07:19 +0900 | [diff] [blame] | 449 | int idx, irq; |
| 450 | |
Tomasz Figa | c3ad056 | 2012-09-21 07:34:01 +0900 | [diff] [blame] | 451 | for_each_child_of_node(dev->of_node, np) { |
| 452 | if (of_match_node(exynos_wkup_irq_ids, np)) { |
| 453 | wkup_np = np; |
| 454 | break; |
| 455 | } |
Thomas Abraham | 43b169d | 2012-09-07 06:07:19 +0900 | [diff] [blame] | 456 | } |
Tomasz Figa | c3ad056 | 2012-09-21 07:34:01 +0900 | [diff] [blame] | 457 | if (!wkup_np) |
| 458 | return -ENODEV; |
Thomas Abraham | 43b169d | 2012-09-07 06:07:19 +0900 | [diff] [blame] | 459 | |
Tomasz Figa | a04b07c | 2012-10-11 10:11:18 +0200 | [diff] [blame] | 460 | bank = d->ctrl->pin_banks; |
| 461 | for (i = 0; i < d->ctrl->nr_banks; ++i, ++bank) { |
| 462 | if (bank->eint_type != EINT_TYPE_WKUP) |
| 463 | continue; |
| 464 | |
| 465 | bank->irq_domain = irq_domain_add_linear(bank->of_node, |
| 466 | bank->nr_pins, &exynos_wkup_irqd_ops, bank); |
| 467 | if (!bank->irq_domain) { |
| 468 | dev_err(dev, "wkup irq domain add failed\n"); |
| 469 | return -ENXIO; |
| 470 | } |
| 471 | |
| 472 | if (!of_find_property(bank->of_node, "interrupts", NULL)) { |
| 473 | bank->eint_type = EINT_TYPE_WKUP_MUX; |
| 474 | ++muxed_banks; |
| 475 | continue; |
| 476 | } |
| 477 | |
| 478 | weint_data = devm_kzalloc(dev, bank->nr_pins |
| 479 | * sizeof(*weint_data), GFP_KERNEL); |
| 480 | if (!weint_data) { |
| 481 | dev_err(dev, "could not allocate memory for weint_data\n"); |
| 482 | return -ENOMEM; |
| 483 | } |
| 484 | |
| 485 | for (idx = 0; idx < bank->nr_pins; ++idx) { |
| 486 | irq = irq_of_parse_and_map(bank->of_node, idx); |
| 487 | if (!irq) { |
| 488 | dev_err(dev, "irq number for eint-%s-%d not found\n", |
| 489 | bank->name, idx); |
| 490 | continue; |
| 491 | } |
| 492 | weint_data[idx].irq = idx; |
| 493 | weint_data[idx].bank = bank; |
| 494 | irq_set_handler_data(irq, &weint_data[idx]); |
| 495 | irq_set_chained_handler(irq, exynos_irq_eint0_15); |
| 496 | } |
Thomas Abraham | 43b169d | 2012-09-07 06:07:19 +0900 | [diff] [blame] | 497 | } |
| 498 | |
Tomasz Figa | a04b07c | 2012-10-11 10:11:18 +0200 | [diff] [blame] | 499 | if (!muxed_banks) |
| 500 | return 0; |
| 501 | |
| 502 | irq = irq_of_parse_and_map(wkup_np, 0); |
| 503 | if (!irq) { |
| 504 | dev_err(dev, "irq number for muxed EINTs not found\n"); |
| 505 | return 0; |
| 506 | } |
| 507 | |
| 508 | muxed_data = devm_kzalloc(dev, sizeof(*muxed_data) |
| 509 | + muxed_banks*sizeof(struct samsung_pin_bank *), GFP_KERNEL); |
| 510 | if (!muxed_data) { |
| 511 | dev_err(dev, "could not allocate memory for muxed_data\n"); |
Thomas Abraham | 43b169d | 2012-09-07 06:07:19 +0900 | [diff] [blame] | 512 | return -ENOMEM; |
| 513 | } |
| 514 | |
Tomasz Figa | a04b07c | 2012-10-11 10:11:18 +0200 | [diff] [blame] | 515 | irq_set_chained_handler(irq, exynos_irq_demux_eint16_31); |
| 516 | irq_set_handler_data(irq, muxed_data); |
Thomas Abraham | 43b169d | 2012-09-07 06:07:19 +0900 | [diff] [blame] | 517 | |
Tomasz Figa | a04b07c | 2012-10-11 10:11:18 +0200 | [diff] [blame] | 518 | bank = d->ctrl->pin_banks; |
| 519 | idx = 0; |
| 520 | for (i = 0; i < d->ctrl->nr_banks; ++i, ++bank) { |
| 521 | if (bank->eint_type != EINT_TYPE_WKUP_MUX) |
| 522 | continue; |
Thomas Abraham | 43b169d | 2012-09-07 06:07:19 +0900 | [diff] [blame] | 523 | |
Tomasz Figa | a04b07c | 2012-10-11 10:11:18 +0200 | [diff] [blame] | 524 | muxed_data->banks[idx++] = bank; |
Thomas Abraham | 43b169d | 2012-09-07 06:07:19 +0900 | [diff] [blame] | 525 | } |
Tomasz Figa | a04b07c | 2012-10-11 10:11:18 +0200 | [diff] [blame] | 526 | muxed_data->nr_banks = muxed_banks; |
| 527 | |
Thomas Abraham | 43b169d | 2012-09-07 06:07:19 +0900 | [diff] [blame] | 528 | return 0; |
| 529 | } |
| 530 | |
| 531 | /* pin banks of exynos4210 pin-controller 0 */ |
| 532 | static struct samsung_pin_bank exynos4210_pin_banks0[] = { |
Tomasz Figa | 1b6056d | 2012-10-11 10:11:15 +0200 | [diff] [blame] | 533 | EXYNOS_PIN_BANK_EINTG(8, 0x000, "gpa0", 0x00), |
| 534 | EXYNOS_PIN_BANK_EINTG(6, 0x020, "gpa1", 0x04), |
| 535 | EXYNOS_PIN_BANK_EINTG(8, 0x040, "gpb", 0x08), |
| 536 | EXYNOS_PIN_BANK_EINTG(5, 0x060, "gpc0", 0x0c), |
| 537 | EXYNOS_PIN_BANK_EINTG(5, 0x080, "gpc1", 0x10), |
| 538 | EXYNOS_PIN_BANK_EINTG(4, 0x0A0, "gpd0", 0x14), |
| 539 | EXYNOS_PIN_BANK_EINTG(4, 0x0C0, "gpd1", 0x18), |
| 540 | EXYNOS_PIN_BANK_EINTG(5, 0x0E0, "gpe0", 0x1c), |
| 541 | EXYNOS_PIN_BANK_EINTG(8, 0x100, "gpe1", 0x20), |
| 542 | EXYNOS_PIN_BANK_EINTG(6, 0x120, "gpe2", 0x24), |
| 543 | EXYNOS_PIN_BANK_EINTG(8, 0x140, "gpe3", 0x28), |
| 544 | EXYNOS_PIN_BANK_EINTG(8, 0x160, "gpe4", 0x2c), |
| 545 | EXYNOS_PIN_BANK_EINTG(8, 0x180, "gpf0", 0x30), |
| 546 | EXYNOS_PIN_BANK_EINTG(8, 0x1A0, "gpf1", 0x34), |
| 547 | EXYNOS_PIN_BANK_EINTG(8, 0x1C0, "gpf2", 0x38), |
| 548 | EXYNOS_PIN_BANK_EINTG(6, 0x1E0, "gpf3", 0x3c), |
Thomas Abraham | 43b169d | 2012-09-07 06:07:19 +0900 | [diff] [blame] | 549 | }; |
| 550 | |
| 551 | /* pin banks of exynos4210 pin-controller 1 */ |
| 552 | static struct samsung_pin_bank exynos4210_pin_banks1[] = { |
Tomasz Figa | 1b6056d | 2012-10-11 10:11:15 +0200 | [diff] [blame] | 553 | EXYNOS_PIN_BANK_EINTG(8, 0x000, "gpj0", 0x00), |
| 554 | EXYNOS_PIN_BANK_EINTG(5, 0x020, "gpj1", 0x04), |
| 555 | EXYNOS_PIN_BANK_EINTG(7, 0x040, "gpk0", 0x08), |
| 556 | EXYNOS_PIN_BANK_EINTG(7, 0x060, "gpk1", 0x0c), |
| 557 | EXYNOS_PIN_BANK_EINTG(7, 0x080, "gpk2", 0x10), |
| 558 | EXYNOS_PIN_BANK_EINTG(7, 0x0A0, "gpk3", 0x14), |
| 559 | EXYNOS_PIN_BANK_EINTG(8, 0x0C0, "gpl0", 0x18), |
| 560 | EXYNOS_PIN_BANK_EINTG(3, 0x0E0, "gpl1", 0x1c), |
| 561 | EXYNOS_PIN_BANK_EINTG(8, 0x100, "gpl2", 0x20), |
Tomasz Figa | 40ba622 | 2012-10-11 10:11:09 +0200 | [diff] [blame] | 562 | EXYNOS_PIN_BANK_EINTN(6, 0x120, "gpy0"), |
| 563 | EXYNOS_PIN_BANK_EINTN(4, 0x140, "gpy1"), |
| 564 | EXYNOS_PIN_BANK_EINTN(6, 0x160, "gpy2"), |
| 565 | EXYNOS_PIN_BANK_EINTN(8, 0x180, "gpy3"), |
| 566 | EXYNOS_PIN_BANK_EINTN(8, 0x1A0, "gpy4"), |
| 567 | EXYNOS_PIN_BANK_EINTN(8, 0x1C0, "gpy5"), |
| 568 | EXYNOS_PIN_BANK_EINTN(8, 0x1E0, "gpy6"), |
Tomasz Figa | a04b07c | 2012-10-11 10:11:18 +0200 | [diff] [blame] | 569 | EXYNOS_PIN_BANK_EINTW(8, 0xC00, "gpx0", 0x00), |
| 570 | EXYNOS_PIN_BANK_EINTW(8, 0xC20, "gpx1", 0x04), |
| 571 | EXYNOS_PIN_BANK_EINTW(8, 0xC40, "gpx2", 0x08), |
| 572 | EXYNOS_PIN_BANK_EINTW(8, 0xC60, "gpx3", 0x0c), |
Thomas Abraham | 43b169d | 2012-09-07 06:07:19 +0900 | [diff] [blame] | 573 | }; |
| 574 | |
| 575 | /* pin banks of exynos4210 pin-controller 2 */ |
| 576 | static struct samsung_pin_bank exynos4210_pin_banks2[] = { |
Tomasz Figa | 40ba622 | 2012-10-11 10:11:09 +0200 | [diff] [blame] | 577 | EXYNOS_PIN_BANK_EINTN(7, 0x000, "gpz"), |
Thomas Abraham | 43b169d | 2012-09-07 06:07:19 +0900 | [diff] [blame] | 578 | }; |
| 579 | |
| 580 | /* |
| 581 | * Samsung pinctrl driver data for Exynos4210 SoC. Exynos4210 SoC includes |
| 582 | * three gpio/pin-mux/pinconfig controllers. |
| 583 | */ |
| 584 | struct samsung_pin_ctrl exynos4210_pin_ctrl[] = { |
| 585 | { |
| 586 | /* pin-controller instance 0 data */ |
| 587 | .pin_banks = exynos4210_pin_banks0, |
| 588 | .nr_banks = ARRAY_SIZE(exynos4210_pin_banks0), |
Thomas Abraham | 43b169d | 2012-09-07 06:07:19 +0900 | [diff] [blame] | 589 | .geint_con = EXYNOS_GPIO_ECON_OFFSET, |
| 590 | .geint_mask = EXYNOS_GPIO_EMASK_OFFSET, |
| 591 | .geint_pend = EXYNOS_GPIO_EPEND_OFFSET, |
| 592 | .svc = EXYNOS_SVC_OFFSET, |
| 593 | .eint_gpio_init = exynos_eint_gpio_init, |
| 594 | .label = "exynos4210-gpio-ctrl0", |
| 595 | }, { |
| 596 | /* pin-controller instance 1 data */ |
| 597 | .pin_banks = exynos4210_pin_banks1, |
| 598 | .nr_banks = ARRAY_SIZE(exynos4210_pin_banks1), |
Thomas Abraham | 43b169d | 2012-09-07 06:07:19 +0900 | [diff] [blame] | 599 | .geint_con = EXYNOS_GPIO_ECON_OFFSET, |
| 600 | .geint_mask = EXYNOS_GPIO_EMASK_OFFSET, |
| 601 | .geint_pend = EXYNOS_GPIO_EPEND_OFFSET, |
| 602 | .weint_con = EXYNOS_WKUP_ECON_OFFSET, |
| 603 | .weint_mask = EXYNOS_WKUP_EMASK_OFFSET, |
| 604 | .weint_pend = EXYNOS_WKUP_EPEND_OFFSET, |
| 605 | .svc = EXYNOS_SVC_OFFSET, |
| 606 | .eint_gpio_init = exynos_eint_gpio_init, |
| 607 | .eint_wkup_init = exynos_eint_wkup_init, |
| 608 | .label = "exynos4210-gpio-ctrl1", |
| 609 | }, { |
| 610 | /* pin-controller instance 2 data */ |
| 611 | .pin_banks = exynos4210_pin_banks2, |
| 612 | .nr_banks = ARRAY_SIZE(exynos4210_pin_banks2), |
Thomas Abraham | 43b169d | 2012-09-07 06:07:19 +0900 | [diff] [blame] | 613 | .label = "exynos4210-gpio-ctrl2", |
| 614 | }, |
| 615 | }; |
Tomasz Figa | 6edc794 | 2012-11-07 08:44:59 +0900 | [diff] [blame] | 616 | |
| 617 | /* pin banks of exynos4x12 pin-controller 0 */ |
| 618 | static struct samsung_pin_bank exynos4x12_pin_banks0[] = { |
| 619 | EXYNOS_PIN_BANK_EINTG(8, 0x000, "gpa0", 0x00), |
| 620 | EXYNOS_PIN_BANK_EINTG(6, 0x020, "gpa1", 0x04), |
| 621 | EXYNOS_PIN_BANK_EINTG(8, 0x040, "gpb", 0x08), |
| 622 | EXYNOS_PIN_BANK_EINTG(5, 0x060, "gpc0", 0x0c), |
| 623 | EXYNOS_PIN_BANK_EINTG(5, 0x080, "gpc1", 0x10), |
| 624 | EXYNOS_PIN_BANK_EINTG(4, 0x0A0, "gpd0", 0x14), |
| 625 | EXYNOS_PIN_BANK_EINTG(4, 0x0C0, "gpd1", 0x18), |
| 626 | EXYNOS_PIN_BANK_EINTG(8, 0x180, "gpf0", 0x30), |
| 627 | EXYNOS_PIN_BANK_EINTG(8, 0x1A0, "gpf1", 0x34), |
| 628 | EXYNOS_PIN_BANK_EINTG(8, 0x1C0, "gpf2", 0x38), |
| 629 | EXYNOS_PIN_BANK_EINTG(6, 0x1E0, "gpf3", 0x3c), |
| 630 | EXYNOS_PIN_BANK_EINTG(8, 0x240, "gpj0", 0x40), |
| 631 | EXYNOS_PIN_BANK_EINTG(5, 0x260, "gpj1", 0x44), |
| 632 | }; |
| 633 | |
| 634 | /* pin banks of exynos4x12 pin-controller 1 */ |
| 635 | static struct samsung_pin_bank exynos4x12_pin_banks1[] = { |
| 636 | EXYNOS_PIN_BANK_EINTG(7, 0x040, "gpk0", 0x08), |
| 637 | EXYNOS_PIN_BANK_EINTG(7, 0x060, "gpk1", 0x0c), |
| 638 | EXYNOS_PIN_BANK_EINTG(7, 0x080, "gpk2", 0x10), |
| 639 | EXYNOS_PIN_BANK_EINTG(7, 0x0A0, "gpk3", 0x14), |
| 640 | EXYNOS_PIN_BANK_EINTG(7, 0x0C0, "gpl0", 0x18), |
| 641 | EXYNOS_PIN_BANK_EINTG(2, 0x0E0, "gpl1", 0x1c), |
| 642 | EXYNOS_PIN_BANK_EINTG(8, 0x100, "gpl2", 0x20), |
| 643 | EXYNOS_PIN_BANK_EINTG(8, 0x260, "gpm0", 0x24), |
| 644 | EXYNOS_PIN_BANK_EINTG(7, 0x280, "gpm1", 0x28), |
| 645 | EXYNOS_PIN_BANK_EINTG(5, 0x2A0, "gpm2", 0x2c), |
| 646 | EXYNOS_PIN_BANK_EINTG(8, 0x2C0, "gpm3", 0x30), |
| 647 | EXYNOS_PIN_BANK_EINTG(8, 0x2E0, "gpm4", 0x34), |
| 648 | EXYNOS_PIN_BANK_EINTN(6, 0x120, "gpy0"), |
| 649 | EXYNOS_PIN_BANK_EINTN(4, 0x140, "gpy1"), |
| 650 | EXYNOS_PIN_BANK_EINTN(6, 0x160, "gpy2"), |
| 651 | EXYNOS_PIN_BANK_EINTN(8, 0x180, "gpy3"), |
| 652 | EXYNOS_PIN_BANK_EINTN(8, 0x1A0, "gpy4"), |
| 653 | EXYNOS_PIN_BANK_EINTN(8, 0x1C0, "gpy5"), |
| 654 | EXYNOS_PIN_BANK_EINTN(8, 0x1E0, "gpy6"), |
| 655 | EXYNOS_PIN_BANK_EINTW(8, 0xC00, "gpx0", 0x00), |
| 656 | EXYNOS_PIN_BANK_EINTW(8, 0xC20, "gpx1", 0x04), |
| 657 | EXYNOS_PIN_BANK_EINTW(8, 0xC40, "gpx2", 0x08), |
| 658 | EXYNOS_PIN_BANK_EINTW(8, 0xC60, "gpx3", 0x0c), |
| 659 | }; |
| 660 | |
| 661 | /* pin banks of exynos4x12 pin-controller 2 */ |
| 662 | static struct samsung_pin_bank exynos4x12_pin_banks2[] = { |
| 663 | EXYNOS_PIN_BANK_EINTG(7, 0x000, "gpz", 0x00), |
| 664 | }; |
| 665 | |
| 666 | /* pin banks of exynos4x12 pin-controller 3 */ |
| 667 | static struct samsung_pin_bank exynos4x12_pin_banks3[] = { |
| 668 | EXYNOS_PIN_BANK_EINTG(8, 0x000, "gpv0", 0x00), |
| 669 | EXYNOS_PIN_BANK_EINTG(8, 0x020, "gpv1", 0x04), |
| 670 | EXYNOS_PIN_BANK_EINTG(8, 0x040, "gpv2", 0x08), |
| 671 | EXYNOS_PIN_BANK_EINTG(8, 0x060, "gpv3", 0x0c), |
| 672 | EXYNOS_PIN_BANK_EINTG(2, 0x080, "gpv4", 0x10), |
| 673 | }; |
| 674 | |
| 675 | /* |
| 676 | * Samsung pinctrl driver data for Exynos4x12 SoC. Exynos4x12 SoC includes |
| 677 | * four gpio/pin-mux/pinconfig controllers. |
| 678 | */ |
| 679 | struct samsung_pin_ctrl exynos4x12_pin_ctrl[] = { |
| 680 | { |
| 681 | /* pin-controller instance 0 data */ |
| 682 | .pin_banks = exynos4x12_pin_banks0, |
| 683 | .nr_banks = ARRAY_SIZE(exynos4x12_pin_banks0), |
| 684 | .geint_con = EXYNOS_GPIO_ECON_OFFSET, |
| 685 | .geint_mask = EXYNOS_GPIO_EMASK_OFFSET, |
| 686 | .geint_pend = EXYNOS_GPIO_EPEND_OFFSET, |
| 687 | .svc = EXYNOS_SVC_OFFSET, |
| 688 | .eint_gpio_init = exynos_eint_gpio_init, |
| 689 | .label = "exynos4x12-gpio-ctrl0", |
| 690 | }, { |
| 691 | /* pin-controller instance 1 data */ |
| 692 | .pin_banks = exynos4x12_pin_banks1, |
| 693 | .nr_banks = ARRAY_SIZE(exynos4x12_pin_banks1), |
| 694 | .geint_con = EXYNOS_GPIO_ECON_OFFSET, |
| 695 | .geint_mask = EXYNOS_GPIO_EMASK_OFFSET, |
| 696 | .geint_pend = EXYNOS_GPIO_EPEND_OFFSET, |
| 697 | .weint_con = EXYNOS_WKUP_ECON_OFFSET, |
| 698 | .weint_mask = EXYNOS_WKUP_EMASK_OFFSET, |
| 699 | .weint_pend = EXYNOS_WKUP_EPEND_OFFSET, |
| 700 | .svc = EXYNOS_SVC_OFFSET, |
| 701 | .eint_gpio_init = exynos_eint_gpio_init, |
| 702 | .eint_wkup_init = exynos_eint_wkup_init, |
| 703 | .label = "exynos4x12-gpio-ctrl1", |
| 704 | }, { |
| 705 | /* pin-controller instance 2 data */ |
| 706 | .pin_banks = exynos4x12_pin_banks2, |
| 707 | .nr_banks = ARRAY_SIZE(exynos4x12_pin_banks2), |
| 708 | .geint_con = EXYNOS_GPIO_ECON_OFFSET, |
| 709 | .geint_mask = EXYNOS_GPIO_EMASK_OFFSET, |
| 710 | .geint_pend = EXYNOS_GPIO_EPEND_OFFSET, |
| 711 | .svc = EXYNOS_SVC_OFFSET, |
| 712 | .eint_gpio_init = exynos_eint_gpio_init, |
| 713 | .label = "exynos4x12-gpio-ctrl2", |
| 714 | }, { |
| 715 | /* pin-controller instance 3 data */ |
| 716 | .pin_banks = exynos4x12_pin_banks3, |
| 717 | .nr_banks = ARRAY_SIZE(exynos4x12_pin_banks3), |
| 718 | .geint_con = EXYNOS_GPIO_ECON_OFFSET, |
| 719 | .geint_mask = EXYNOS_GPIO_EMASK_OFFSET, |
| 720 | .geint_pend = EXYNOS_GPIO_EPEND_OFFSET, |
| 721 | .svc = EXYNOS_SVC_OFFSET, |
| 722 | .eint_gpio_init = exynos_eint_gpio_init, |
| 723 | .label = "exynos4x12-gpio-ctrl3", |
| 724 | }, |
| 725 | }; |
Thomas Abraham | f67faf4 | 2012-12-28 10:37:27 -0800 | [diff] [blame] | 726 | |
| 727 | /* pin banks of exynos5250 pin-controller 0 */ |
| 728 | static struct samsung_pin_bank exynos5250_pin_banks0[] = { |
| 729 | EXYNOS_PIN_BANK_EINTG(8, 0x000, "gpa0", 0x00), |
| 730 | EXYNOS_PIN_BANK_EINTG(6, 0x020, "gpa1", 0x04), |
| 731 | EXYNOS_PIN_BANK_EINTG(8, 0x040, "gpa2", 0x08), |
| 732 | EXYNOS_PIN_BANK_EINTG(5, 0x060, "gpb0", 0x0c), |
| 733 | EXYNOS_PIN_BANK_EINTG(5, 0x080, "gpb1", 0x10), |
| 734 | EXYNOS_PIN_BANK_EINTG(4, 0x0A0, "gpb2", 0x14), |
| 735 | EXYNOS_PIN_BANK_EINTG(4, 0x0C0, "gpb3", 0x18), |
| 736 | EXYNOS_PIN_BANK_EINTG(7, 0x0E0, "gpc0", 0x1c), |
| 737 | EXYNOS_PIN_BANK_EINTG(4, 0x100, "gpc1", 0x20), |
| 738 | EXYNOS_PIN_BANK_EINTG(7, 0x120, "gpc2", 0x24), |
| 739 | EXYNOS_PIN_BANK_EINTG(7, 0x140, "gpc3", 0x28), |
| 740 | EXYNOS_PIN_BANK_EINTG(4, 0x160, "gpd0", 0x2c), |
| 741 | EXYNOS_PIN_BANK_EINTG(8, 0x180, "gpd1", 0x30), |
| 742 | EXYNOS_PIN_BANK_EINTG(7, 0x2E0, "gpc4", 0x34), |
| 743 | EXYNOS_PIN_BANK_EINTN(6, 0x1A0, "gpy0"), |
| 744 | EXYNOS_PIN_BANK_EINTN(4, 0x1C0, "gpy1"), |
| 745 | EXYNOS_PIN_BANK_EINTN(6, 0x1E0, "gpy2"), |
| 746 | EXYNOS_PIN_BANK_EINTN(8, 0x200, "gpy3"), |
| 747 | EXYNOS_PIN_BANK_EINTN(8, 0x220, "gpy4"), |
| 748 | EXYNOS_PIN_BANK_EINTN(8, 0x240, "gpy5"), |
| 749 | EXYNOS_PIN_BANK_EINTN(8, 0x260, "gpy6"), |
| 750 | EXYNOS_PIN_BANK_EINTW(8, 0xC00, "gpx0", 0x00), |
| 751 | EXYNOS_PIN_BANK_EINTW(8, 0xC20, "gpx1", 0x04), |
| 752 | EXYNOS_PIN_BANK_EINTW(8, 0xC40, "gpx2", 0x08), |
| 753 | EXYNOS_PIN_BANK_EINTW(8, 0xC60, "gpx3", 0x0c), |
| 754 | }; |
| 755 | |
| 756 | /* pin banks of exynos5250 pin-controller 1 */ |
| 757 | static struct samsung_pin_bank exynos5250_pin_banks1[] = { |
| 758 | EXYNOS_PIN_BANK_EINTG(8, 0x000, "gpe0", 0x00), |
| 759 | EXYNOS_PIN_BANK_EINTG(2, 0x020, "gpe1", 0x04), |
| 760 | EXYNOS_PIN_BANK_EINTG(4, 0x040, "gpf0", 0x08), |
| 761 | EXYNOS_PIN_BANK_EINTG(4, 0x060, "gpf1", 0x0c), |
| 762 | EXYNOS_PIN_BANK_EINTG(8, 0x080, "gpg0", 0x10), |
| 763 | EXYNOS_PIN_BANK_EINTG(8, 0x0A0, "gpg1", 0x14), |
| 764 | EXYNOS_PIN_BANK_EINTG(2, 0x0C0, "gpg2", 0x18), |
| 765 | EXYNOS_PIN_BANK_EINTG(4, 0x0E0, "gph0", 0x1c), |
| 766 | EXYNOS_PIN_BANK_EINTG(8, 0x100, "gph1", 0x20), |
| 767 | }; |
| 768 | |
| 769 | /* pin banks of exynos5250 pin-controller 2 */ |
| 770 | static struct samsung_pin_bank exynos5250_pin_banks2[] = { |
| 771 | EXYNOS_PIN_BANK_EINTG(8, 0x000, "gpv0", 0x00), |
| 772 | EXYNOS_PIN_BANK_EINTG(8, 0x020, "gpv1", 0x04), |
| 773 | EXYNOS_PIN_BANK_EINTG(8, 0x060, "gpv2", 0x08), |
| 774 | EXYNOS_PIN_BANK_EINTG(8, 0x080, "gpv3", 0x0c), |
| 775 | EXYNOS_PIN_BANK_EINTG(2, 0x0C0, "gpv4", 0x10), |
| 776 | }; |
| 777 | |
| 778 | /* pin banks of exynos5250 pin-controller 3 */ |
| 779 | static struct samsung_pin_bank exynos5250_pin_banks3[] = { |
| 780 | EXYNOS_PIN_BANK_EINTG(7, 0x000, "gpz", 0x00), |
| 781 | }; |
| 782 | |
| 783 | /* |
| 784 | * Samsung pinctrl driver data for Exynos5250 SoC. Exynos5250 SoC includes |
| 785 | * four gpio/pin-mux/pinconfig controllers. |
| 786 | */ |
| 787 | struct samsung_pin_ctrl exynos5250_pin_ctrl[] = { |
| 788 | { |
| 789 | /* pin-controller instance 0 data */ |
| 790 | .pin_banks = exynos5250_pin_banks0, |
| 791 | .nr_banks = ARRAY_SIZE(exynos5250_pin_banks0), |
| 792 | .geint_con = EXYNOS_GPIO_ECON_OFFSET, |
| 793 | .geint_mask = EXYNOS_GPIO_EMASK_OFFSET, |
| 794 | .geint_pend = EXYNOS_GPIO_EPEND_OFFSET, |
| 795 | .weint_con = EXYNOS_WKUP_ECON_OFFSET, |
| 796 | .weint_mask = EXYNOS_WKUP_EMASK_OFFSET, |
| 797 | .weint_pend = EXYNOS_WKUP_EPEND_OFFSET, |
| 798 | .svc = EXYNOS_SVC_OFFSET, |
| 799 | .eint_gpio_init = exynos_eint_gpio_init, |
| 800 | .eint_wkup_init = exynos_eint_wkup_init, |
| 801 | .label = "exynos5250-gpio-ctrl0", |
| 802 | }, { |
| 803 | /* pin-controller instance 1 data */ |
| 804 | .pin_banks = exynos5250_pin_banks1, |
| 805 | .nr_banks = ARRAY_SIZE(exynos5250_pin_banks1), |
| 806 | .geint_con = EXYNOS_GPIO_ECON_OFFSET, |
| 807 | .geint_mask = EXYNOS_GPIO_EMASK_OFFSET, |
| 808 | .geint_pend = EXYNOS_GPIO_EPEND_OFFSET, |
| 809 | .svc = EXYNOS_SVC_OFFSET, |
| 810 | .eint_gpio_init = exynos_eint_gpio_init, |
| 811 | .label = "exynos5250-gpio-ctrl1", |
| 812 | }, { |
| 813 | /* pin-controller instance 2 data */ |
| 814 | .pin_banks = exynos5250_pin_banks2, |
| 815 | .nr_banks = ARRAY_SIZE(exynos5250_pin_banks2), |
| 816 | .geint_con = EXYNOS_GPIO_ECON_OFFSET, |
| 817 | .geint_mask = EXYNOS_GPIO_EMASK_OFFSET, |
| 818 | .geint_pend = EXYNOS_GPIO_EPEND_OFFSET, |
| 819 | .svc = EXYNOS_SVC_OFFSET, |
| 820 | .eint_gpio_init = exynos_eint_gpio_init, |
| 821 | .label = "exynos5250-gpio-ctrl2", |
| 822 | }, { |
| 823 | /* pin-controller instance 3 data */ |
| 824 | .pin_banks = exynos5250_pin_banks3, |
| 825 | .nr_banks = ARRAY_SIZE(exynos5250_pin_banks3), |
| 826 | .geint_con = EXYNOS_GPIO_ECON_OFFSET, |
| 827 | .geint_mask = EXYNOS_GPIO_EMASK_OFFSET, |
| 828 | .geint_pend = EXYNOS_GPIO_EPEND_OFFSET, |
| 829 | .svc = EXYNOS_SVC_OFFSET, |
| 830 | .eint_gpio_init = exynos_eint_gpio_init, |
| 831 | .label = "exynos5250-gpio-ctrl3", |
| 832 | }, |
| 833 | }; |