Magnus Damm | 2967dab | 2008-10-08 20:41:43 +0900 | [diff] [blame] | 1 | /* |
Paul Mundt | b3c185a | 2012-06-20 17:29:04 +0900 | [diff] [blame] | 2 | * SuperH Pin Function Controller support. |
Magnus Damm | 2967dab | 2008-10-08 20:41:43 +0900 | [diff] [blame] | 3 | * |
| 4 | * Copyright (C) 2008 Magnus Damm |
Paul Mundt | b3c185a | 2012-06-20 17:29:04 +0900 | [diff] [blame] | 5 | * Copyright (C) 2009 - 2012 Paul Mundt |
Magnus Damm | 2967dab | 2008-10-08 20:41:43 +0900 | [diff] [blame] | 6 | * |
| 7 | * This file is subject to the terms and conditions of the GNU General Public |
| 8 | * License. See the file "COPYING" in the main directory of this archive |
| 9 | * for more details. |
| 10 | */ |
Laurent Pinchart | c6193ea | 2012-12-15 23:50:47 +0100 | [diff] [blame] | 11 | |
| 12 | #define DRV_NAME "sh-pfc" |
Paul Mundt | b72421d | 2010-10-04 03:54:56 +0900 | [diff] [blame] | 13 | |
Magnus Damm | 2967dab | 2008-10-08 20:41:43 +0900 | [diff] [blame] | 14 | #include <linux/bitops.h> |
Laurent Pinchart | 90efde2 | 2012-12-15 23:50:52 +0100 | [diff] [blame] | 15 | #include <linux/err.h> |
| 16 | #include <linux/errno.h> |
| 17 | #include <linux/io.h> |
Magnus Damm | b0e1021 | 2011-12-09 12:14:27 +0900 | [diff] [blame] | 18 | #include <linux/ioport.h> |
Laurent Pinchart | 90efde2 | 2012-12-15 23:50:52 +0100 | [diff] [blame] | 19 | #include <linux/kernel.h> |
| 20 | #include <linux/module.h> |
Laurent Pinchart | fe1c9a8 | 2013-06-17 20:50:02 +0200 | [diff] [blame] | 21 | #include <linux/of.h> |
| 22 | #include <linux/of_device.h> |
Paul Mundt | ca5481c6 | 2012-07-10 12:08:14 +0900 | [diff] [blame] | 23 | #include <linux/pinctrl/machine.h> |
Laurent Pinchart | c6193ea | 2012-12-15 23:50:47 +0100 | [diff] [blame] | 24 | #include <linux/platform_device.h> |
Laurent Pinchart | 90efde2 | 2012-12-15 23:50:52 +0100 | [diff] [blame] | 25 | #include <linux/slab.h> |
Magnus Damm | b0e1021 | 2011-12-09 12:14:27 +0900 | [diff] [blame] | 26 | |
Laurent Pinchart | f916513 | 2012-12-15 23:50:44 +0100 | [diff] [blame] | 27 | #include "core.h" |
| 28 | |
Laurent Pinchart | 70c8f01 | 2013-12-11 04:26:26 +0100 | [diff] [blame] | 29 | static int sh_pfc_map_resources(struct sh_pfc *pfc, |
| 30 | struct platform_device *pdev) |
Magnus Damm | b0e1021 | 2011-12-09 12:14:27 +0900 | [diff] [blame] | 31 | { |
Laurent Pinchart | 70c8f01 | 2013-12-11 04:26:26 +0100 | [diff] [blame] | 32 | unsigned int num_windows = 0; |
| 33 | unsigned int num_irqs = 0; |
| 34 | struct sh_pfc_window *windows; |
| 35 | unsigned int *irqs = NULL; |
Magnus Damm | b0e1021 | 2011-12-09 12:14:27 +0900 | [diff] [blame] | 36 | struct resource *res; |
Laurent Pinchart | 70c8f01 | 2013-12-11 04:26:26 +0100 | [diff] [blame] | 37 | unsigned int i; |
Magnus Damm | b0e1021 | 2011-12-09 12:14:27 +0900 | [diff] [blame] | 38 | |
Laurent Pinchart | 70c8f01 | 2013-12-11 04:26:26 +0100 | [diff] [blame] | 39 | /* Count the MEM and IRQ resources. */ |
| 40 | for (i = 0; i < pdev->num_resources; ++i) { |
| 41 | switch (resource_type(&pdev->resource[i])) { |
| 42 | case IORESOURCE_MEM: |
| 43 | num_windows++; |
| 44 | break; |
| 45 | |
| 46 | case IORESOURCE_IRQ: |
| 47 | num_irqs++; |
| 48 | break; |
| 49 | } |
| 50 | } |
| 51 | |
| 52 | if (num_windows == 0) |
Laurent Pinchart | bee9f22 | 2013-02-16 23:39:07 +0100 | [diff] [blame] | 53 | return -EINVAL; |
Laurent Pinchart | 973931a | 2012-12-15 23:50:55 +0100 | [diff] [blame] | 54 | |
Laurent Pinchart | 70c8f01 | 2013-12-11 04:26:26 +0100 | [diff] [blame] | 55 | /* Allocate memory windows and IRQs arrays. */ |
| 56 | windows = devm_kzalloc(pfc->dev, num_windows * sizeof(*windows), |
| 57 | GFP_KERNEL); |
| 58 | if (windows == NULL) |
Laurent Pinchart | 1724acf | 2012-12-15 23:50:48 +0100 | [diff] [blame] | 59 | return -ENOMEM; |
Magnus Damm | b0e1021 | 2011-12-09 12:14:27 +0900 | [diff] [blame] | 60 | |
Laurent Pinchart | 70c8f01 | 2013-12-11 04:26:26 +0100 | [diff] [blame] | 61 | pfc->num_windows = num_windows; |
| 62 | pfc->windows = windows; |
Laurent Pinchart | 973931a | 2012-12-15 23:50:55 +0100 | [diff] [blame] | 63 | |
Laurent Pinchart | 70c8f01 | 2013-12-11 04:26:26 +0100 | [diff] [blame] | 64 | if (num_irqs) { |
| 65 | irqs = devm_kzalloc(pfc->dev, num_irqs * sizeof(*irqs), |
| 66 | GFP_KERNEL); |
| 67 | if (irqs == NULL) |
Laurent Pinchart | 1724acf | 2012-12-15 23:50:48 +0100 | [diff] [blame] | 68 | return -ENOMEM; |
Laurent Pinchart | 70c8f01 | 2013-12-11 04:26:26 +0100 | [diff] [blame] | 69 | |
| 70 | pfc->num_irqs = num_irqs; |
| 71 | pfc->irqs = irqs; |
| 72 | } |
| 73 | |
| 74 | /* Fill them. */ |
| 75 | for (i = 0, res = pdev->resource; i < pdev->num_resources; i++, res++) { |
| 76 | switch (resource_type(res)) { |
| 77 | case IORESOURCE_MEM: |
| 78 | windows->phys = res->start; |
| 79 | windows->size = resource_size(res); |
| 80 | windows->virt = devm_ioremap_resource(pfc->dev, res); |
| 81 | if (IS_ERR(windows->virt)) |
| 82 | return -ENOMEM; |
| 83 | windows++; |
| 84 | break; |
| 85 | |
| 86 | case IORESOURCE_IRQ: |
| 87 | *irqs++ = res->start; |
| 88 | break; |
| 89 | } |
Magnus Damm | b0e1021 | 2011-12-09 12:14:27 +0900 | [diff] [blame] | 90 | } |
| 91 | |
| 92 | return 0; |
Magnus Damm | b0e1021 | 2011-12-09 12:14:27 +0900 | [diff] [blame] | 93 | } |
| 94 | |
Laurent Pinchart | e51d534 | 2013-02-17 00:26:33 +0100 | [diff] [blame] | 95 | static void __iomem *sh_pfc_phys_to_virt(struct sh_pfc *pfc, |
| 96 | unsigned long address) |
Magnus Damm | b0e1021 | 2011-12-09 12:14:27 +0900 | [diff] [blame] | 97 | { |
Laurent Pinchart | 4aeacd5 | 2012-12-15 23:50:53 +0100 | [diff] [blame] | 98 | struct sh_pfc_window *window; |
Laurent Pinchart | bee9f22 | 2013-02-16 23:39:07 +0100 | [diff] [blame] | 99 | unsigned int i; |
Magnus Damm | b0e1021 | 2011-12-09 12:14:27 +0900 | [diff] [blame] | 100 | |
| 101 | /* scan through physical windows and convert address */ |
Laurent Pinchart | bee9f22 | 2013-02-16 23:39:07 +0100 | [diff] [blame] | 102 | for (i = 0; i < pfc->num_windows; i++) { |
Laurent Pinchart | 5b46ac3 | 2013-12-11 04:26:25 +0100 | [diff] [blame] | 103 | window = pfc->windows + i; |
Magnus Damm | b0e1021 | 2011-12-09 12:14:27 +0900 | [diff] [blame] | 104 | |
| 105 | if (address < window->phys) |
| 106 | continue; |
| 107 | |
| 108 | if (address >= (window->phys + window->size)) |
| 109 | continue; |
| 110 | |
| 111 | return window->virt + (address - window->phys); |
| 112 | } |
| 113 | |
Laurent Pinchart | bee9f22 | 2013-02-16 23:39:07 +0100 | [diff] [blame] | 114 | BUG(); |
Laurent Pinchart | 1960d58 | 2013-03-26 01:44:52 +0100 | [diff] [blame] | 115 | return NULL; |
Magnus Damm | b0e1021 | 2011-12-09 12:14:27 +0900 | [diff] [blame] | 116 | } |
Magnus Damm | 2967dab | 2008-10-08 20:41:43 +0900 | [diff] [blame] | 117 | |
Laurent Pinchart | 1a0039d | 2013-03-08 17:43:54 +0100 | [diff] [blame] | 118 | int sh_pfc_get_pin_index(struct sh_pfc *pfc, unsigned int pin) |
Laurent Pinchart | 934cb02 | 2013-02-14 22:35:09 +0100 | [diff] [blame] | 119 | { |
Laurent Pinchart | 63d5738 | 2013-02-15 01:33:38 +0100 | [diff] [blame] | 120 | unsigned int offset; |
| 121 | unsigned int i; |
| 122 | |
Laurent Pinchart | acac8ed | 2013-07-15 18:38:30 +0200 | [diff] [blame] | 123 | for (i = 0, offset = 0; i < pfc->nr_ranges; ++i) { |
| 124 | const struct sh_pfc_pin_range *range = &pfc->ranges[i]; |
Laurent Pinchart | 63d5738 | 2013-02-15 01:33:38 +0100 | [diff] [blame] | 125 | |
| 126 | if (pin <= range->end) |
Laurent Pinchart | acac8ed | 2013-07-15 18:38:30 +0200 | [diff] [blame] | 127 | return pin >= range->start |
| 128 | ? offset + pin - range->start : -1; |
Laurent Pinchart | 63d5738 | 2013-02-15 01:33:38 +0100 | [diff] [blame] | 129 | |
Laurent Pinchart | acac8ed | 2013-07-15 18:38:30 +0200 | [diff] [blame] | 130 | offset += range->end - range->start + 1; |
Laurent Pinchart | 63d5738 | 2013-02-15 01:33:38 +0100 | [diff] [blame] | 131 | } |
| 132 | |
Laurent Pinchart | b705c05 | 2013-03-10 16:38:23 +0100 | [diff] [blame] | 133 | return -EINVAL; |
Laurent Pinchart | 934cb02 | 2013-02-14 22:35:09 +0100 | [diff] [blame] | 134 | } |
| 135 | |
Laurent Pinchart | 533743d | 2013-07-15 13:03:20 +0200 | [diff] [blame] | 136 | static int sh_pfc_enum_in_range(u16 enum_id, const struct pinmux_range *r) |
Magnus Damm | 2967dab | 2008-10-08 20:41:43 +0900 | [diff] [blame] | 137 | { |
| 138 | if (enum_id < r->begin) |
| 139 | return 0; |
| 140 | |
| 141 | if (enum_id > r->end) |
| 142 | return 0; |
| 143 | |
| 144 | return 1; |
| 145 | } |
| 146 | |
Geert Uytterhoeven | fc88936 | 2015-02-27 18:38:04 +0100 | [diff] [blame^] | 147 | u32 sh_pfc_read_raw_reg(void __iomem *mapped_reg, unsigned long reg_width) |
Magnus Damm | 3292094 | 2008-12-25 18:17:26 +0900 | [diff] [blame] | 148 | { |
| 149 | switch (reg_width) { |
| 150 | case 8: |
Magnus Damm | b0e1021 | 2011-12-09 12:14:27 +0900 | [diff] [blame] | 151 | return ioread8(mapped_reg); |
Magnus Damm | 3292094 | 2008-12-25 18:17:26 +0900 | [diff] [blame] | 152 | case 16: |
Magnus Damm | b0e1021 | 2011-12-09 12:14:27 +0900 | [diff] [blame] | 153 | return ioread16(mapped_reg); |
Magnus Damm | 3292094 | 2008-12-25 18:17:26 +0900 | [diff] [blame] | 154 | case 32: |
Magnus Damm | b0e1021 | 2011-12-09 12:14:27 +0900 | [diff] [blame] | 155 | return ioread32(mapped_reg); |
Magnus Damm | 3292094 | 2008-12-25 18:17:26 +0900 | [diff] [blame] | 156 | } |
| 157 | |
| 158 | BUG(); |
| 159 | return 0; |
| 160 | } |
| 161 | |
Laurent Pinchart | 41f1219 | 2013-02-15 02:04:55 +0100 | [diff] [blame] | 162 | void sh_pfc_write_raw_reg(void __iomem *mapped_reg, unsigned long reg_width, |
Geert Uytterhoeven | fc88936 | 2015-02-27 18:38:04 +0100 | [diff] [blame^] | 163 | u32 data) |
Magnus Damm | 3292094 | 2008-12-25 18:17:26 +0900 | [diff] [blame] | 164 | { |
| 165 | switch (reg_width) { |
| 166 | case 8: |
Magnus Damm | b0e1021 | 2011-12-09 12:14:27 +0900 | [diff] [blame] | 167 | iowrite8(data, mapped_reg); |
Magnus Damm | 3292094 | 2008-12-25 18:17:26 +0900 | [diff] [blame] | 168 | return; |
| 169 | case 16: |
Magnus Damm | b0e1021 | 2011-12-09 12:14:27 +0900 | [diff] [blame] | 170 | iowrite16(data, mapped_reg); |
Magnus Damm | 3292094 | 2008-12-25 18:17:26 +0900 | [diff] [blame] | 171 | return; |
| 172 | case 32: |
Magnus Damm | b0e1021 | 2011-12-09 12:14:27 +0900 | [diff] [blame] | 173 | iowrite32(data, mapped_reg); |
Magnus Damm | 3292094 | 2008-12-25 18:17:26 +0900 | [diff] [blame] | 174 | return; |
| 175 | } |
| 176 | |
| 177 | BUG(); |
| 178 | } |
| 179 | |
Laurent Pinchart | 4aeacd5 | 2012-12-15 23:50:53 +0100 | [diff] [blame] | 180 | static void sh_pfc_config_reg_helper(struct sh_pfc *pfc, |
Laurent Pinchart | cd3c1be | 2013-02-16 18:47:05 +0100 | [diff] [blame] | 181 | const struct pinmux_cfg_reg *crp, |
Laurent Pinchart | 4aeacd5 | 2012-12-15 23:50:53 +0100 | [diff] [blame] | 182 | unsigned long in_pos, |
Geert Uytterhoeven | fc88936 | 2015-02-27 18:38:04 +0100 | [diff] [blame^] | 183 | void __iomem **mapped_regp, u32 *maskp, |
Laurent Pinchart | 4aeacd5 | 2012-12-15 23:50:53 +0100 | [diff] [blame] | 184 | unsigned long *posp) |
Magnus Damm | 2967dab | 2008-10-08 20:41:43 +0900 | [diff] [blame] | 185 | { |
Laurent Pinchart | 8d72a7f | 2013-12-11 04:26:21 +0100 | [diff] [blame] | 186 | unsigned int k; |
Magnus Damm | f78a26f | 2011-12-14 01:01:05 +0900 | [diff] [blame] | 187 | |
Laurent Pinchart | 4aeacd5 | 2012-12-15 23:50:53 +0100 | [diff] [blame] | 188 | *mapped_regp = sh_pfc_phys_to_virt(pfc, crp->reg); |
Magnus Damm | 2967dab | 2008-10-08 20:41:43 +0900 | [diff] [blame] | 189 | |
Magnus Damm | f78a26f | 2011-12-14 01:01:05 +0900 | [diff] [blame] | 190 | if (crp->field_width) { |
| 191 | *maskp = (1 << crp->field_width) - 1; |
| 192 | *posp = crp->reg_width - ((in_pos + 1) * crp->field_width); |
| 193 | } else { |
| 194 | *maskp = (1 << crp->var_field_width[in_pos]) - 1; |
| 195 | *posp = crp->reg_width; |
| 196 | for (k = 0; k <= in_pos; k++) |
| 197 | *posp -= crp->var_field_width[k]; |
| 198 | } |
Magnus Damm | 0fc64cc | 2008-12-25 18:17:18 +0900 | [diff] [blame] | 199 | } |
Magnus Damm | 2967dab | 2008-10-08 20:41:43 +0900 | [diff] [blame] | 200 | |
Laurent Pinchart | 4aeacd5 | 2012-12-15 23:50:53 +0100 | [diff] [blame] | 201 | static void sh_pfc_write_config_reg(struct sh_pfc *pfc, |
Laurent Pinchart | cd3c1be | 2013-02-16 18:47:05 +0100 | [diff] [blame] | 202 | const struct pinmux_cfg_reg *crp, |
Geert Uytterhoeven | fc88936 | 2015-02-27 18:38:04 +0100 | [diff] [blame^] | 203 | unsigned long field, u32 value) |
Magnus Damm | 18925e1 | 2011-12-14 01:00:55 +0900 | [diff] [blame] | 204 | { |
| 205 | void __iomem *mapped_reg; |
Geert Uytterhoeven | fc88936 | 2015-02-27 18:38:04 +0100 | [diff] [blame^] | 206 | unsigned long pos; |
| 207 | u32 mask, data; |
Magnus Damm | 18925e1 | 2011-12-14 01:00:55 +0900 | [diff] [blame] | 208 | |
Laurent Pinchart | 4aeacd5 | 2012-12-15 23:50:53 +0100 | [diff] [blame] | 209 | sh_pfc_config_reg_helper(pfc, crp, field, &mapped_reg, &mask, &pos); |
Magnus Damm | 18925e1 | 2011-12-14 01:00:55 +0900 | [diff] [blame] | 210 | |
Geert Uytterhoeven | fc88936 | 2015-02-27 18:38:04 +0100 | [diff] [blame^] | 211 | dev_dbg(pfc->dev, "write_reg addr = %lx, value = 0x%x, field = %ld, " |
Laurent Pinchart | 9a643c9 | 2013-03-10 18:00:02 +0100 | [diff] [blame] | 212 | "r_width = %ld, f_width = %ld\n", |
| 213 | crp->reg, value, field, crp->reg_width, crp->field_width); |
Magnus Damm | 0fc64cc | 2008-12-25 18:17:18 +0900 | [diff] [blame] | 214 | |
| 215 | mask = ~(mask << pos); |
| 216 | value = value << pos; |
Magnus Damm | 2967dab | 2008-10-08 20:41:43 +0900 | [diff] [blame] | 217 | |
Laurent Pinchart | 4aeacd5 | 2012-12-15 23:50:53 +0100 | [diff] [blame] | 218 | data = sh_pfc_read_raw_reg(mapped_reg, crp->reg_width); |
Magnus Damm | e499ada | 2011-12-14 01:01:14 +0900 | [diff] [blame] | 219 | data &= mask; |
| 220 | data |= value; |
| 221 | |
Laurent Pinchart | 19bb7fe3 | 2012-12-15 23:51:20 +0100 | [diff] [blame] | 222 | if (pfc->info->unlock_reg) |
Laurent Pinchart | 4aeacd5 | 2012-12-15 23:50:53 +0100 | [diff] [blame] | 223 | sh_pfc_write_raw_reg( |
Laurent Pinchart | 19bb7fe3 | 2012-12-15 23:51:20 +0100 | [diff] [blame] | 224 | sh_pfc_phys_to_virt(pfc, pfc->info->unlock_reg), 32, |
Laurent Pinchart | 4aeacd5 | 2012-12-15 23:50:53 +0100 | [diff] [blame] | 225 | ~data); |
Magnus Damm | e499ada | 2011-12-14 01:01:14 +0900 | [diff] [blame] | 226 | |
Laurent Pinchart | 4aeacd5 | 2012-12-15 23:50:53 +0100 | [diff] [blame] | 227 | sh_pfc_write_raw_reg(mapped_reg, crp->reg_width, data); |
Magnus Damm | 2967dab | 2008-10-08 20:41:43 +0900 | [diff] [blame] | 228 | } |
| 229 | |
Laurent Pinchart | 533743d | 2013-07-15 13:03:20 +0200 | [diff] [blame] | 230 | static int sh_pfc_get_config_reg(struct sh_pfc *pfc, u16 enum_id, |
Laurent Pinchart | cd3c1be | 2013-02-16 18:47:05 +0100 | [diff] [blame] | 231 | const struct pinmux_cfg_reg **crp, int *fieldp, |
Geert Uytterhoeven | fc88936 | 2015-02-27 18:38:04 +0100 | [diff] [blame^] | 232 | u32 *valuep) |
Magnus Damm | 2967dab | 2008-10-08 20:41:43 +0900 | [diff] [blame] | 233 | { |
Laurent Pinchart | cd3c1be | 2013-02-16 18:47:05 +0100 | [diff] [blame] | 234 | const struct pinmux_cfg_reg *config_reg; |
Geert Uytterhoeven | fc88936 | 2015-02-27 18:38:04 +0100 | [diff] [blame^] | 235 | unsigned long r_width, f_width, curr_width; |
| 236 | unsigned int k, m, pos, bit_pos; |
| 237 | u32 ncomb, n; |
Magnus Damm | 2967dab | 2008-10-08 20:41:43 +0900 | [diff] [blame] | 238 | |
| 239 | k = 0; |
| 240 | while (1) { |
Laurent Pinchart | 19bb7fe3 | 2012-12-15 23:51:20 +0100 | [diff] [blame] | 241 | config_reg = pfc->info->cfg_regs + k; |
Magnus Damm | 2967dab | 2008-10-08 20:41:43 +0900 | [diff] [blame] | 242 | |
| 243 | r_width = config_reg->reg_width; |
| 244 | f_width = config_reg->field_width; |
| 245 | |
| 246 | if (!r_width) |
| 247 | break; |
Magnus Damm | f78a26f | 2011-12-14 01:01:05 +0900 | [diff] [blame] | 248 | |
| 249 | pos = 0; |
| 250 | m = 0; |
| 251 | for (bit_pos = 0; bit_pos < r_width; bit_pos += curr_width) { |
| 252 | if (f_width) |
| 253 | curr_width = f_width; |
| 254 | else |
| 255 | curr_width = config_reg->var_field_width[m]; |
| 256 | |
| 257 | ncomb = 1 << curr_width; |
| 258 | for (n = 0; n < ncomb; n++) { |
| 259 | if (config_reg->enum_ids[pos + n] == enum_id) { |
| 260 | *crp = config_reg; |
| 261 | *fieldp = m; |
| 262 | *valuep = n; |
Magnus Damm | f78a26f | 2011-12-14 01:01:05 +0900 | [diff] [blame] | 263 | return 0; |
| 264 | } |
Magnus Damm | 2967dab | 2008-10-08 20:41:43 +0900 | [diff] [blame] | 265 | } |
Magnus Damm | f78a26f | 2011-12-14 01:01:05 +0900 | [diff] [blame] | 266 | pos += ncomb; |
| 267 | m++; |
Magnus Damm | 2967dab | 2008-10-08 20:41:43 +0900 | [diff] [blame] | 268 | } |
| 269 | k++; |
| 270 | } |
| 271 | |
Laurent Pinchart | b705c05 | 2013-03-10 16:38:23 +0100 | [diff] [blame] | 272 | return -EINVAL; |
Magnus Damm | 2967dab | 2008-10-08 20:41:43 +0900 | [diff] [blame] | 273 | } |
| 274 | |
Laurent Pinchart | 533743d | 2013-07-15 13:03:20 +0200 | [diff] [blame] | 275 | static int sh_pfc_mark_to_enum(struct sh_pfc *pfc, u16 mark, int pos, |
| 276 | u16 *enum_idp) |
Magnus Damm | 2967dab | 2008-10-08 20:41:43 +0900 | [diff] [blame] | 277 | { |
Laurent Pinchart | 533743d | 2013-07-15 13:03:20 +0200 | [diff] [blame] | 278 | const u16 *data = pfc->info->gpio_data; |
Laurent Pinchart | 8d72a7f | 2013-12-11 04:26:21 +0100 | [diff] [blame] | 279 | unsigned int k; |
Magnus Damm | 2967dab | 2008-10-08 20:41:43 +0900 | [diff] [blame] | 280 | |
Magnus Damm | 2967dab | 2008-10-08 20:41:43 +0900 | [diff] [blame] | 281 | if (pos) { |
| 282 | *enum_idp = data[pos + 1]; |
| 283 | return pos + 1; |
| 284 | } |
| 285 | |
Laurent Pinchart | 19bb7fe3 | 2012-12-15 23:51:20 +0100 | [diff] [blame] | 286 | for (k = 0; k < pfc->info->gpio_data_size; k++) { |
Laurent Pinchart | a68fdca9 | 2013-02-14 17:36:56 +0100 | [diff] [blame] | 287 | if (data[k] == mark) { |
Magnus Damm | 2967dab | 2008-10-08 20:41:43 +0900 | [diff] [blame] | 288 | *enum_idp = data[k + 1]; |
| 289 | return k + 1; |
| 290 | } |
| 291 | } |
| 292 | |
Laurent Pinchart | 9a643c9 | 2013-03-10 18:00:02 +0100 | [diff] [blame] | 293 | dev_err(pfc->dev, "cannot locate data/mark enum_id for mark %d\n", |
| 294 | mark); |
Laurent Pinchart | b705c05 | 2013-03-10 16:38:23 +0100 | [diff] [blame] | 295 | return -EINVAL; |
Magnus Damm | 2967dab | 2008-10-08 20:41:43 +0900 | [diff] [blame] | 296 | } |
| 297 | |
Laurent Pinchart | 861601d | 2013-03-10 15:29:14 +0100 | [diff] [blame] | 298 | int sh_pfc_config_mux(struct sh_pfc *pfc, unsigned mark, int pinmux_type) |
Magnus Damm | 2967dab | 2008-10-08 20:41:43 +0900 | [diff] [blame] | 299 | { |
Laurent Pinchart | cd3c1be | 2013-02-16 18:47:05 +0100 | [diff] [blame] | 300 | const struct pinmux_cfg_reg *cr = NULL; |
Laurent Pinchart | 533743d | 2013-07-15 13:03:20 +0200 | [diff] [blame] | 301 | u16 enum_id; |
Laurent Pinchart | cd3c1be | 2013-02-16 18:47:05 +0100 | [diff] [blame] | 302 | const struct pinmux_range *range; |
Geert Uytterhoeven | fc88936 | 2015-02-27 18:38:04 +0100 | [diff] [blame^] | 303 | int in_range, pos, field; |
| 304 | u32 value; |
Laurent Pinchart | b705c05 | 2013-03-10 16:38:23 +0100 | [diff] [blame] | 305 | int ret; |
Magnus Damm | 2967dab | 2008-10-08 20:41:43 +0900 | [diff] [blame] | 306 | |
| 307 | switch (pinmux_type) { |
Laurent Pinchart | e3c4705 | 2013-03-10 17:30:25 +0100 | [diff] [blame] | 308 | case PINMUX_TYPE_GPIO: |
Magnus Damm | 2967dab | 2008-10-08 20:41:43 +0900 | [diff] [blame] | 309 | case PINMUX_TYPE_FUNCTION: |
| 310 | range = NULL; |
| 311 | break; |
| 312 | |
| 313 | case PINMUX_TYPE_OUTPUT: |
Laurent Pinchart | 19bb7fe3 | 2012-12-15 23:51:20 +0100 | [diff] [blame] | 314 | range = &pfc->info->output; |
Magnus Damm | 2967dab | 2008-10-08 20:41:43 +0900 | [diff] [blame] | 315 | break; |
| 316 | |
| 317 | case PINMUX_TYPE_INPUT: |
Laurent Pinchart | 19bb7fe3 | 2012-12-15 23:51:20 +0100 | [diff] [blame] | 318 | range = &pfc->info->input; |
Magnus Damm | 2967dab | 2008-10-08 20:41:43 +0900 | [diff] [blame] | 319 | break; |
| 320 | |
Magnus Damm | 2967dab | 2008-10-08 20:41:43 +0900 | [diff] [blame] | 321 | default: |
Laurent Pinchart | b705c05 | 2013-03-10 16:38:23 +0100 | [diff] [blame] | 322 | return -EINVAL; |
Magnus Damm | 2967dab | 2008-10-08 20:41:43 +0900 | [diff] [blame] | 323 | } |
| 324 | |
| 325 | pos = 0; |
| 326 | enum_id = 0; |
Magnus Damm | ad4a07f | 2011-12-14 01:00:46 +0900 | [diff] [blame] | 327 | field = 0; |
| 328 | value = 0; |
Laurent Pinchart | e3c4705 | 2013-03-10 17:30:25 +0100 | [diff] [blame] | 329 | |
| 330 | /* Iterate over all the configuration fields we need to update. */ |
Magnus Damm | 2967dab | 2008-10-08 20:41:43 +0900 | [diff] [blame] | 331 | while (1) { |
Laurent Pinchart | a68fdca9 | 2013-02-14 17:36:56 +0100 | [diff] [blame] | 332 | pos = sh_pfc_mark_to_enum(pfc, mark, pos, &enum_id); |
Laurent Pinchart | b705c05 | 2013-03-10 16:38:23 +0100 | [diff] [blame] | 333 | if (pos < 0) |
| 334 | return pos; |
Magnus Damm | 2967dab | 2008-10-08 20:41:43 +0900 | [diff] [blame] | 335 | |
| 336 | if (!enum_id) |
| 337 | break; |
| 338 | |
Laurent Pinchart | e3c4705 | 2013-03-10 17:30:25 +0100 | [diff] [blame] | 339 | /* Check if the configuration field selects a function. If it |
| 340 | * doesn't, skip the field if it's not applicable to the |
| 341 | * requested pinmux type. |
| 342 | */ |
Laurent Pinchart | 19bb7fe3 | 2012-12-15 23:51:20 +0100 | [diff] [blame] | 343 | in_range = sh_pfc_enum_in_range(enum_id, &pfc->info->function); |
Magnus Damm | 50dd314 | 2010-01-19 13:52:28 +0000 | [diff] [blame] | 344 | if (!in_range) { |
Laurent Pinchart | e3c4705 | 2013-03-10 17:30:25 +0100 | [diff] [blame] | 345 | if (pinmux_type == PINMUX_TYPE_FUNCTION) { |
| 346 | /* Functions are allowed to modify all |
| 347 | * fields. |
| 348 | */ |
| 349 | in_range = 1; |
| 350 | } else if (pinmux_type != PINMUX_TYPE_GPIO) { |
| 351 | /* Input/output types can only modify fields |
| 352 | * that correspond to their respective ranges. |
Magnus Damm | 50dd314 | 2010-01-19 13:52:28 +0000 | [diff] [blame] | 353 | */ |
Laurent Pinchart | 4aeacd5 | 2012-12-15 23:50:53 +0100 | [diff] [blame] | 354 | in_range = sh_pfc_enum_in_range(enum_id, range); |
Magnus Damm | 2967dab | 2008-10-08 20:41:43 +0900 | [diff] [blame] | 355 | |
Magnus Damm | 50dd314 | 2010-01-19 13:52:28 +0000 | [diff] [blame] | 356 | /* |
| 357 | * special case pass through for fixed |
| 358 | * input-only or output-only pins without |
| 359 | * function enum register association. |
| 360 | */ |
| 361 | if (in_range && enum_id == range->force) |
| 362 | continue; |
Magnus Damm | 50dd314 | 2010-01-19 13:52:28 +0000 | [diff] [blame] | 363 | } |
Laurent Pinchart | e3c4705 | 2013-03-10 17:30:25 +0100 | [diff] [blame] | 364 | /* GPIOs are only allowed to modify function fields. */ |
Magnus Damm | 42eed42 | 2008-10-22 18:29:17 +0900 | [diff] [blame] | 365 | } |
| 366 | |
Magnus Damm | 2967dab | 2008-10-08 20:41:43 +0900 | [diff] [blame] | 367 | if (!in_range) |
| 368 | continue; |
| 369 | |
Laurent Pinchart | b705c05 | 2013-03-10 16:38:23 +0100 | [diff] [blame] | 370 | ret = sh_pfc_get_config_reg(pfc, enum_id, &cr, &field, &value); |
| 371 | if (ret < 0) |
| 372 | return ret; |
Magnus Damm | 2967dab | 2008-10-08 20:41:43 +0900 | [diff] [blame] | 373 | |
Laurent Pinchart | 861601d | 2013-03-10 15:29:14 +0100 | [diff] [blame] | 374 | sh_pfc_write_config_reg(pfc, cr, field, value); |
Magnus Damm | 2967dab | 2008-10-08 20:41:43 +0900 | [diff] [blame] | 375 | } |
| 376 | |
| 377 | return 0; |
Magnus Damm | 2967dab | 2008-10-08 20:41:43 +0900 | [diff] [blame] | 378 | } |
| 379 | |
Laurent Pinchart | acac8ed | 2013-07-15 18:38:30 +0200 | [diff] [blame] | 380 | static int sh_pfc_init_ranges(struct sh_pfc *pfc) |
| 381 | { |
| 382 | struct sh_pfc_pin_range *range; |
| 383 | unsigned int nr_ranges; |
| 384 | unsigned int i; |
| 385 | |
| 386 | if (pfc->info->pins[0].pin == (u16)-1) { |
| 387 | /* Pin number -1 denotes that the SoC doesn't report pin numbers |
| 388 | * in its pin arrays yet. Consider the pin numbers range as |
| 389 | * continuous and allocate a single range. |
| 390 | */ |
| 391 | pfc->nr_ranges = 1; |
| 392 | pfc->ranges = devm_kzalloc(pfc->dev, sizeof(*pfc->ranges), |
| 393 | GFP_KERNEL); |
| 394 | if (pfc->ranges == NULL) |
| 395 | return -ENOMEM; |
| 396 | |
| 397 | pfc->ranges->start = 0; |
| 398 | pfc->ranges->end = pfc->info->nr_pins - 1; |
| 399 | pfc->nr_gpio_pins = pfc->info->nr_pins; |
| 400 | |
| 401 | return 0; |
| 402 | } |
| 403 | |
Laurent Pinchart | 4f82e3e | 2013-07-15 21:10:54 +0200 | [diff] [blame] | 404 | /* Count, allocate and fill the ranges. The PFC SoC data pins array must |
| 405 | * be sorted by pin numbers, and pins without a GPIO port must come |
| 406 | * last. |
| 407 | */ |
Laurent Pinchart | acac8ed | 2013-07-15 18:38:30 +0200 | [diff] [blame] | 408 | for (i = 1, nr_ranges = 1; i < pfc->info->nr_pins; ++i) { |
| 409 | if (pfc->info->pins[i-1].pin != pfc->info->pins[i].pin - 1) |
| 410 | nr_ranges++; |
| 411 | } |
| 412 | |
| 413 | pfc->nr_ranges = nr_ranges; |
| 414 | pfc->ranges = devm_kzalloc(pfc->dev, sizeof(*pfc->ranges) * nr_ranges, |
| 415 | GFP_KERNEL); |
| 416 | if (pfc->ranges == NULL) |
| 417 | return -ENOMEM; |
| 418 | |
| 419 | range = pfc->ranges; |
| 420 | range->start = pfc->info->pins[0].pin; |
| 421 | |
| 422 | for (i = 1; i < pfc->info->nr_pins; ++i) { |
Laurent Pinchart | 4f82e3e | 2013-07-15 21:10:54 +0200 | [diff] [blame] | 423 | if (pfc->info->pins[i-1].pin == pfc->info->pins[i].pin - 1) |
| 424 | continue; |
| 425 | |
| 426 | range->end = pfc->info->pins[i-1].pin; |
| 427 | if (!(pfc->info->pins[i-1].configs & SH_PFC_PIN_CFG_NO_GPIO)) |
| 428 | pfc->nr_gpio_pins = range->end + 1; |
| 429 | |
| 430 | range++; |
| 431 | range->start = pfc->info->pins[i].pin; |
Laurent Pinchart | acac8ed | 2013-07-15 18:38:30 +0200 | [diff] [blame] | 432 | } |
| 433 | |
| 434 | range->end = pfc->info->pins[i-1].pin; |
Laurent Pinchart | 4f82e3e | 2013-07-15 21:10:54 +0200 | [diff] [blame] | 435 | if (!(pfc->info->pins[i-1].configs & SH_PFC_PIN_CFG_NO_GPIO)) |
| 436 | pfc->nr_gpio_pins = range->end + 1; |
Laurent Pinchart | acac8ed | 2013-07-15 18:38:30 +0200 | [diff] [blame] | 437 | |
| 438 | return 0; |
| 439 | } |
| 440 | |
Laurent Pinchart | fe1c9a8 | 2013-06-17 20:50:02 +0200 | [diff] [blame] | 441 | #ifdef CONFIG_OF |
| 442 | static const struct of_device_id sh_pfc_of_table[] = { |
Niklas Söderlund | 1e7d5d8 | 2015-01-25 14:49:52 +0100 | [diff] [blame] | 443 | #ifdef CONFIG_PINCTRL_PFC_EMEV2 |
| 444 | { |
| 445 | .compatible = "renesas,pfc-emev2", |
| 446 | .data = &emev2_pinmux_info, |
| 447 | }, |
| 448 | #endif |
Laurent Pinchart | fe1c9a8 | 2013-06-17 20:50:02 +0200 | [diff] [blame] | 449 | #ifdef CONFIG_PINCTRL_PFC_R8A73A4 |
| 450 | { |
| 451 | .compatible = "renesas,pfc-r8a73a4", |
| 452 | .data = &r8a73a4_pinmux_info, |
| 453 | }, |
| 454 | #endif |
| 455 | #ifdef CONFIG_PINCTRL_PFC_R8A7740 |
| 456 | { |
| 457 | .compatible = "renesas,pfc-r8a7740", |
| 458 | .data = &r8a7740_pinmux_info, |
| 459 | }, |
| 460 | #endif |
| 461 | #ifdef CONFIG_PINCTRL_PFC_R8A7778 |
| 462 | { |
| 463 | .compatible = "renesas,pfc-r8a7778", |
| 464 | .data = &r8a7778_pinmux_info, |
| 465 | }, |
| 466 | #endif |
| 467 | #ifdef CONFIG_PINCTRL_PFC_R8A7779 |
| 468 | { |
| 469 | .compatible = "renesas,pfc-r8a7779", |
| 470 | .data = &r8a7779_pinmux_info, |
| 471 | }, |
| 472 | #endif |
| 473 | #ifdef CONFIG_PINCTRL_PFC_R8A7790 |
| 474 | { |
| 475 | .compatible = "renesas,pfc-r8a7790", |
| 476 | .data = &r8a7790_pinmux_info, |
| 477 | }, |
| 478 | #endif |
Hisashi Nakamura | 5088451 | 2013-10-17 06:46:05 +0900 | [diff] [blame] | 479 | #ifdef CONFIG_PINCTRL_PFC_R8A7791 |
| 480 | { |
| 481 | .compatible = "renesas,pfc-r8a7791", |
| 482 | .data = &r8a7791_pinmux_info, |
| 483 | }, |
| 484 | #endif |
Laurent Pinchart | fe1c9a8 | 2013-06-17 20:50:02 +0200 | [diff] [blame] | 485 | #ifdef CONFIG_PINCTRL_PFC_SH73A0 |
| 486 | { |
| 487 | .compatible = "renesas,pfc-sh73a0", |
| 488 | .data = &sh73a0_pinmux_info, |
| 489 | }, |
| 490 | #endif |
| 491 | { }, |
| 492 | }; |
| 493 | MODULE_DEVICE_TABLE(of, sh_pfc_of_table); |
| 494 | #endif |
| 495 | |
Laurent Pinchart | c6193ea | 2012-12-15 23:50:47 +0100 | [diff] [blame] | 496 | static int sh_pfc_probe(struct platform_device *pdev) |
Magnus Damm | 2967dab | 2008-10-08 20:41:43 +0900 | [diff] [blame] | 497 | { |
Laurent Pinchart | fe1c9a8 | 2013-06-17 20:50:02 +0200 | [diff] [blame] | 498 | const struct platform_device_id *platid = platform_get_device_id(pdev); |
| 499 | #ifdef CONFIG_OF |
| 500 | struct device_node *np = pdev->dev.of_node; |
| 501 | #endif |
Laurent Pinchart | cd3c1be | 2013-02-16 18:47:05 +0100 | [diff] [blame] | 502 | const struct sh_pfc_soc_info *info; |
Laurent Pinchart | c6193ea | 2012-12-15 23:50:47 +0100 | [diff] [blame] | 503 | struct sh_pfc *pfc; |
Magnus Damm | 0fc64cc | 2008-12-25 18:17:18 +0900 | [diff] [blame] | 504 | int ret; |
Magnus Damm | 2967dab | 2008-10-08 20:41:43 +0900 | [diff] [blame] | 505 | |
Laurent Pinchart | fe1c9a8 | 2013-06-17 20:50:02 +0200 | [diff] [blame] | 506 | #ifdef CONFIG_OF |
| 507 | if (np) |
| 508 | info = of_match_device(sh_pfc_of_table, &pdev->dev)->data; |
| 509 | else |
| 510 | #endif |
| 511 | info = platid ? (const void *)platid->driver_data : NULL; |
| 512 | |
Laurent Pinchart | 19bb7fe3 | 2012-12-15 23:51:20 +0100 | [diff] [blame] | 513 | if (info == NULL) |
Laurent Pinchart | c6193ea | 2012-12-15 23:50:47 +0100 | [diff] [blame] | 514 | return -ENODEV; |
Magnus Damm | 0fc64cc | 2008-12-25 18:17:18 +0900 | [diff] [blame] | 515 | |
Magnus Damm | 8c43fcc | 2013-02-14 21:23:47 +0900 | [diff] [blame] | 516 | pfc = devm_kzalloc(&pdev->dev, sizeof(*pfc), GFP_KERNEL); |
Laurent Pinchart | c6193ea | 2012-12-15 23:50:47 +0100 | [diff] [blame] | 517 | if (pfc == NULL) |
| 518 | return -ENOMEM; |
Magnus Damm | b0e1021 | 2011-12-09 12:14:27 +0900 | [diff] [blame] | 519 | |
Laurent Pinchart | 19bb7fe3 | 2012-12-15 23:51:20 +0100 | [diff] [blame] | 520 | pfc->info = info; |
Laurent Pinchart | c6193ea | 2012-12-15 23:50:47 +0100 | [diff] [blame] | 521 | pfc->dev = &pdev->dev; |
| 522 | |
Laurent Pinchart | 70c8f01 | 2013-12-11 04:26:26 +0100 | [diff] [blame] | 523 | ret = sh_pfc_map_resources(pfc, pdev); |
Laurent Pinchart | c6193ea | 2012-12-15 23:50:47 +0100 | [diff] [blame] | 524 | if (unlikely(ret < 0)) |
Laurent Pinchart | d4e62d0 | 2012-12-15 23:50:43 +0100 | [diff] [blame] | 525 | return ret; |
Laurent Pinchart | d4e62d0 | 2012-12-15 23:50:43 +0100 | [diff] [blame] | 526 | |
Laurent Pinchart | c6193ea | 2012-12-15 23:50:47 +0100 | [diff] [blame] | 527 | spin_lock_init(&pfc->lock); |
Magnus Damm | 69edbba | 2008-12-25 18:17:34 +0900 | [diff] [blame] | 528 | |
Laurent Pinchart | 0c15106 | 2013-04-21 20:21:57 +0200 | [diff] [blame] | 529 | if (info->ops && info->ops->init) { |
| 530 | ret = info->ops->init(pfc); |
| 531 | if (ret < 0) |
| 532 | return ret; |
| 533 | } |
| 534 | |
Paul Mundt | ca5481c6 | 2012-07-10 12:08:14 +0900 | [diff] [blame] | 535 | pinctrl_provide_dummies(); |
Magnus Damm | 69edbba | 2008-12-25 18:17:34 +0900 | [diff] [blame] | 536 | |
Laurent Pinchart | acac8ed | 2013-07-15 18:38:30 +0200 | [diff] [blame] | 537 | ret = sh_pfc_init_ranges(pfc); |
| 538 | if (ret < 0) |
| 539 | return ret; |
| 540 | |
Paul Mundt | ca5481c6 | 2012-07-10 12:08:14 +0900 | [diff] [blame] | 541 | /* |
| 542 | * Initialize pinctrl bindings first |
| 543 | */ |
Laurent Pinchart | c6193ea | 2012-12-15 23:50:47 +0100 | [diff] [blame] | 544 | ret = sh_pfc_register_pinctrl(pfc); |
Laurent Pinchart | f9492fd | 2012-12-15 23:50:45 +0100 | [diff] [blame] | 545 | if (unlikely(ret != 0)) |
Laurent Pinchart | 0a332c9 | 2014-09-11 00:55:55 +0300 | [diff] [blame] | 546 | return ret; |
Magnus Damm | 69edbba | 2008-12-25 18:17:34 +0900 | [diff] [blame] | 547 | |
Laurent Pinchart | 6f6a4a6 | 2012-12-15 23:50:46 +0100 | [diff] [blame] | 548 | #ifdef CONFIG_GPIO_SH_PFC |
Paul Mundt | ca5481c6 | 2012-07-10 12:08:14 +0900 | [diff] [blame] | 549 | /* |
| 550 | * Then the GPIO chip |
| 551 | */ |
Laurent Pinchart | c6193ea | 2012-12-15 23:50:47 +0100 | [diff] [blame] | 552 | ret = sh_pfc_register_gpiochip(pfc); |
Laurent Pinchart | 6f6a4a6 | 2012-12-15 23:50:46 +0100 | [diff] [blame] | 553 | if (unlikely(ret != 0)) { |
Paul Mundt | ca5481c6 | 2012-07-10 12:08:14 +0900 | [diff] [blame] | 554 | /* |
| 555 | * If the GPIO chip fails to come up we still leave the |
| 556 | * PFC state as it is, given that there are already |
| 557 | * extant users of it that have succeeded by this point. |
| 558 | */ |
Laurent Pinchart | 9a643c9 | 2013-03-10 18:00:02 +0100 | [diff] [blame] | 559 | dev_notice(pfc->dev, "failed to init GPIO chip, ignoring...\n"); |
Paul Mundt | ca5481c6 | 2012-07-10 12:08:14 +0900 | [diff] [blame] | 560 | } |
Laurent Pinchart | 6f6a4a6 | 2012-12-15 23:50:46 +0100 | [diff] [blame] | 561 | #endif |
Paul Mundt | ca5481c6 | 2012-07-10 12:08:14 +0900 | [diff] [blame] | 562 | |
Laurent Pinchart | c6193ea | 2012-12-15 23:50:47 +0100 | [diff] [blame] | 563 | platform_set_drvdata(pdev, pfc); |
| 564 | |
Laurent Pinchart | 9a643c9 | 2013-03-10 18:00:02 +0100 | [diff] [blame] | 565 | dev_info(pfc->dev, "%s support registered\n", info->name); |
Paul Mundt | ca5481c6 | 2012-07-10 12:08:14 +0900 | [diff] [blame] | 566 | |
Paul Mundt | b3c185a | 2012-06-20 17:29:04 +0900 | [diff] [blame] | 567 | return 0; |
Paul Mundt | b72421d | 2010-10-04 03:54:56 +0900 | [diff] [blame] | 568 | } |
Laurent Pinchart | 6f6a4a6 | 2012-12-15 23:50:46 +0100 | [diff] [blame] | 569 | |
Laurent Pinchart | c6193ea | 2012-12-15 23:50:47 +0100 | [diff] [blame] | 570 | static int sh_pfc_remove(struct platform_device *pdev) |
| 571 | { |
| 572 | struct sh_pfc *pfc = platform_get_drvdata(pdev); |
| 573 | |
| 574 | #ifdef CONFIG_GPIO_SH_PFC |
| 575 | sh_pfc_unregister_gpiochip(pfc); |
| 576 | #endif |
| 577 | sh_pfc_unregister_pinctrl(pfc); |
| 578 | |
Laurent Pinchart | c6193ea | 2012-12-15 23:50:47 +0100 | [diff] [blame] | 579 | return 0; |
| 580 | } |
| 581 | |
| 582 | static const struct platform_device_id sh_pfc_id_table[] = { |
Niklas Söderlund | 1e7d5d8 | 2015-01-25 14:49:52 +0100 | [diff] [blame] | 583 | #ifdef CONFIG_PINCTRL_PFC_EMEV2 |
| 584 | { "pfc-emev2", (kernel_ulong_t)&emev2_pinmux_info }, |
| 585 | #endif |
Magnus Damm | c98f6c2 | 2013-03-26 22:49:49 +0900 | [diff] [blame] | 586 | #ifdef CONFIG_PINCTRL_PFC_R8A73A4 |
| 587 | { "pfc-r8a73a4", (kernel_ulong_t)&r8a73a4_pinmux_info }, |
| 588 | #endif |
Laurent Pinchart | d5b1521 | 2012-12-15 23:51:21 +0100 | [diff] [blame] | 589 | #ifdef CONFIG_PINCTRL_PFC_R8A7740 |
| 590 | { "pfc-r8a7740", (kernel_ulong_t)&r8a7740_pinmux_info }, |
| 591 | #endif |
Kuninori Morimoto | 87f8c98 | 2013-04-12 05:37:20 +0000 | [diff] [blame] | 592 | #ifdef CONFIG_PINCTRL_PFC_R8A7778 |
| 593 | { "pfc-r8a7778", (kernel_ulong_t)&r8a7778_pinmux_info }, |
| 594 | #endif |
Laurent Pinchart | 881023d | 2012-12-15 23:51:22 +0100 | [diff] [blame] | 595 | #ifdef CONFIG_PINCTRL_PFC_R8A7779 |
| 596 | { "pfc-r8a7779", (kernel_ulong_t)&r8a7779_pinmux_info }, |
| 597 | #endif |
Koji Matsuoka | 58c229e | 2013-04-08 11:08:53 +0900 | [diff] [blame] | 598 | #ifdef CONFIG_PINCTRL_PFC_R8A7790 |
| 599 | { "pfc-r8a7790", (kernel_ulong_t)&r8a7790_pinmux_info }, |
| 600 | #endif |
Laurent Pinchart | ccda552 | 2012-12-15 23:51:29 +0100 | [diff] [blame] | 601 | #ifdef CONFIG_PINCTRL_PFC_SH7203 |
| 602 | { "pfc-sh7203", (kernel_ulong_t)&sh7203_pinmux_info }, |
| 603 | #endif |
Laurent Pinchart | a8d42fc | 2012-12-15 23:51:30 +0100 | [diff] [blame] | 604 | #ifdef CONFIG_PINCTRL_PFC_SH7264 |
| 605 | { "pfc-sh7264", (kernel_ulong_t)&sh7264_pinmux_info }, |
| 606 | #endif |
Laurent Pinchart | f5e811f | 2012-12-15 23:51:31 +0100 | [diff] [blame] | 607 | #ifdef CONFIG_PINCTRL_PFC_SH7269 |
| 608 | { "pfc-sh7269", (kernel_ulong_t)&sh7269_pinmux_info }, |
| 609 | #endif |
Laurent Pinchart | 5d5166d | 2012-12-15 23:51:24 +0100 | [diff] [blame] | 610 | #ifdef CONFIG_PINCTRL_PFC_SH73A0 |
| 611 | { "pfc-sh73a0", (kernel_ulong_t)&sh73a0_pinmux_info }, |
| 612 | #endif |
Laurent Pinchart | 74cad60 | 2012-12-15 23:51:32 +0100 | [diff] [blame] | 613 | #ifdef CONFIG_PINCTRL_PFC_SH7720 |
| 614 | { "pfc-sh7720", (kernel_ulong_t)&sh7720_pinmux_info }, |
| 615 | #endif |
Laurent Pinchart | f5e25ae | 2012-12-15 23:51:33 +0100 | [diff] [blame] | 616 | #ifdef CONFIG_PINCTRL_PFC_SH7722 |
| 617 | { "pfc-sh7722", (kernel_ulong_t)&sh7722_pinmux_info }, |
| 618 | #endif |
Laurent Pinchart | d05afa0 | 2012-12-15 23:51:34 +0100 | [diff] [blame] | 619 | #ifdef CONFIG_PINCTRL_PFC_SH7723 |
| 620 | { "pfc-sh7723", (kernel_ulong_t)&sh7723_pinmux_info }, |
| 621 | #endif |
Laurent Pinchart | 0ff25ba | 2012-12-15 23:51:35 +0100 | [diff] [blame] | 622 | #ifdef CONFIG_PINCTRL_PFC_SH7724 |
| 623 | { "pfc-sh7724", (kernel_ulong_t)&sh7724_pinmux_info }, |
| 624 | #endif |
Laurent Pinchart | ac1ebc2 | 2012-12-15 23:51:36 +0100 | [diff] [blame] | 625 | #ifdef CONFIG_PINCTRL_PFC_SH7734 |
| 626 | { "pfc-sh7734", (kernel_ulong_t)&sh7734_pinmux_info }, |
| 627 | #endif |
Laurent Pinchart | 0bb9267 | 2012-12-15 23:51:37 +0100 | [diff] [blame] | 628 | #ifdef CONFIG_PINCTRL_PFC_SH7757 |
| 629 | { "pfc-sh7757", (kernel_ulong_t)&sh7757_pinmux_info }, |
| 630 | #endif |
Laurent Pinchart | a56398e | 2012-12-15 23:51:38 +0100 | [diff] [blame] | 631 | #ifdef CONFIG_PINCTRL_PFC_SH7785 |
| 632 | { "pfc-sh7785", (kernel_ulong_t)&sh7785_pinmux_info }, |
| 633 | #endif |
Laurent Pinchart | d2a31bd | 2012-12-15 23:51:39 +0100 | [diff] [blame] | 634 | #ifdef CONFIG_PINCTRL_PFC_SH7786 |
| 635 | { "pfc-sh7786", (kernel_ulong_t)&sh7786_pinmux_info }, |
| 636 | #endif |
Laurent Pinchart | d5d9a81 | 2012-12-15 23:51:40 +0100 | [diff] [blame] | 637 | #ifdef CONFIG_PINCTRL_PFC_SHX3 |
| 638 | { "pfc-shx3", (kernel_ulong_t)&shx3_pinmux_info }, |
| 639 | #endif |
Laurent Pinchart | c6193ea | 2012-12-15 23:50:47 +0100 | [diff] [blame] | 640 | { "sh-pfc", 0 }, |
| 641 | { }, |
| 642 | }; |
| 643 | MODULE_DEVICE_TABLE(platform, sh_pfc_id_table); |
| 644 | |
| 645 | static struct platform_driver sh_pfc_driver = { |
| 646 | .probe = sh_pfc_probe, |
| 647 | .remove = sh_pfc_remove, |
| 648 | .id_table = sh_pfc_id_table, |
| 649 | .driver = { |
| 650 | .name = DRV_NAME, |
Laurent Pinchart | fe1c9a8 | 2013-06-17 20:50:02 +0200 | [diff] [blame] | 651 | .of_match_table = of_match_ptr(sh_pfc_of_table), |
Laurent Pinchart | c6193ea | 2012-12-15 23:50:47 +0100 | [diff] [blame] | 652 | }, |
| 653 | }; |
| 654 | |
Laurent Pinchart | 40ee6fc | 2012-12-15 23:50:54 +0100 | [diff] [blame] | 655 | static int __init sh_pfc_init(void) |
| 656 | { |
| 657 | return platform_driver_register(&sh_pfc_driver); |
| 658 | } |
| 659 | postcore_initcall(sh_pfc_init); |
| 660 | |
Laurent Pinchart | c6193ea | 2012-12-15 23:50:47 +0100 | [diff] [blame] | 661 | static void __exit sh_pfc_exit(void) |
| 662 | { |
| 663 | platform_driver_unregister(&sh_pfc_driver); |
| 664 | } |
| 665 | module_exit(sh_pfc_exit); |
| 666 | |
Laurent Pinchart | 6f6a4a6 | 2012-12-15 23:50:46 +0100 | [diff] [blame] | 667 | MODULE_AUTHOR("Magnus Damm, Paul Mundt, Laurent Pinchart"); |
| 668 | MODULE_DESCRIPTION("Pin Control and GPIO driver for SuperH pin function controller"); |
| 669 | MODULE_LICENSE("GPL v2"); |