blob: 2c8a56c75001a5ab56951e2bdff53098a3d105a2 [file] [log] [blame]
Tom Rini10e47792018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0
Marek Vasut3066a062017-09-15 21:13:55 +02002/*
3 * Pin Control driver for SuperH Pin Function Controller.
4 *
5 * Authors: Magnus Damm, Paul Mundt, Laurent Pinchart
6 *
7 * Copyright (C) 2008 Magnus Damm
8 * Copyright (C) 2009 - 2012 Paul Mundt
9 * Copyright (C) 2017 Marek Vasut
Marek Vasut3066a062017-09-15 21:13:55 +020010 */
11
12#define DRV_NAME "sh-pfc"
13
14#include <common.h>
15#include <dm.h>
16#include <errno.h>
Simon Glass9bc15642020-02-03 07:36:16 -070017#include <dm/device_compat.h>
Simon Glassd66c5f72020-02-03 07:36:15 -070018#include <dm/devres.h>
Marek Vasut3066a062017-09-15 21:13:55 +020019#include <dm/pinctrl.h>
Simon Glass4dcacfc2020-05-10 11:40:13 -060020#include <linux/bitops.h>
Simon Glassc06c1be2020-05-10 11:40:08 -060021#include <linux/bug.h>
Marek Vasut3066a062017-09-15 21:13:55 +020022#include <linux/io.h>
23#include <linux/sizes.h>
24
25#include "sh_pfc.h"
26
Marek Vasut3066a062017-09-15 21:13:55 +020027enum sh_pfc_model {
Marek Vasutc40f2d62018-01-17 22:18:59 +010028 SH_PFC_R8A7790 = 0,
Marek Vasut06ef9e82018-01-17 17:14:45 +010029 SH_PFC_R8A7791,
Marek Vasut1ef39302018-01-17 22:29:50 +010030 SH_PFC_R8A7792,
Marek Vasut06ef9e82018-01-17 17:14:45 +010031 SH_PFC_R8A7793,
Marek Vasut4dd88d52018-01-17 22:33:59 +010032 SH_PFC_R8A7794,
Marek Vasutc40f2d62018-01-17 22:18:59 +010033 SH_PFC_R8A7795,
Marek Vasutd0f9c7b2023-01-26 21:01:41 +010034 SH_PFC_R8A77960,
35 SH_PFC_R8A77961,
Adam Ford96980fb2020-06-30 09:30:09 -050036 SH_PFC_R8A774A1,
Biju Dasd1d78882020-10-28 10:34:21 +000037 SH_PFC_R8A774B1,
Lad Prabhakar53b88b92021-03-15 22:24:04 +000038 SH_PFC_R8A774C0,
Biju Das121bd002020-10-28 10:34:22 +000039 SH_PFC_R8A774E1,
Marek Vasut72269e02019-03-04 01:32:44 +010040 SH_PFC_R8A77965,
Marek Vasuta0e11e52017-10-09 20:57:29 +020041 SH_PFC_R8A77970,
Marek Vasuta6a7f482019-07-29 19:59:44 +020042 SH_PFC_R8A77980,
Marek Vasut68a77042018-04-26 13:09:20 +020043 SH_PFC_R8A77990,
Marek Vasut7d35e642017-10-08 20:57:37 +020044 SH_PFC_R8A77995,
Marek Vasut4dbc6532021-04-27 01:55:54 +020045 SH_PFC_R8A779A0,
LUU HOAI9b68f5d2023-02-28 22:34:40 +010046 SH_PFC_R8A779F0,
Marek Vasut3066a062017-09-15 21:13:55 +020047};
48
49struct sh_pfc_pin_config {
50 u32 type;
Lad Prabhakar13ed8d52020-11-28 13:13:08 +000051 const char *name;
Marek Vasut3066a062017-09-15 21:13:55 +020052};
53
54struct sh_pfc_pinctrl {
55 struct sh_pfc *pfc;
56
57 struct sh_pfc_pin_config *configs;
Marek Vasut3066a062017-09-15 21:13:55 +020058};
59
60struct sh_pfc_pin_range {
61 u16 start;
62 u16 end;
63};
64
65struct sh_pfc_pinctrl_priv {
66 struct sh_pfc pfc;
67 struct sh_pfc_pinctrl pmx;
68};
69
70int sh_pfc_get_pin_index(struct sh_pfc *pfc, unsigned int pin)
71{
72 unsigned int offset;
73 unsigned int i;
74
75 for (i = 0, offset = 0; i < pfc->nr_ranges; ++i) {
76 const struct sh_pfc_pin_range *range = &pfc->ranges[i];
77
78 if (pin <= range->end)
79 return pin >= range->start
80 ? offset + pin - range->start : -1;
81
82 offset += range->end - range->start + 1;
83 }
84
85 return -EINVAL;
86}
87
88static int sh_pfc_enum_in_range(u16 enum_id, const struct pinmux_range *r)
89{
90 if (enum_id < r->begin)
91 return 0;
92
93 if (enum_id > r->end)
94 return 0;
95
96 return 1;
97}
98
99u32 sh_pfc_read_raw_reg(void __iomem *mapped_reg, unsigned int reg_width)
100{
101 switch (reg_width) {
102 case 8:
103 return readb(mapped_reg);
104 case 16:
105 return readw(mapped_reg);
106 case 32:
107 return readl(mapped_reg);
108 }
109
110 BUG();
111 return 0;
112}
113
114void sh_pfc_write_raw_reg(void __iomem *mapped_reg, unsigned int reg_width,
115 u32 data)
116{
117 switch (reg_width) {
118 case 8:
119 writeb(data, mapped_reg);
120 return;
121 case 16:
122 writew(data, mapped_reg);
123 return;
124 case 32:
125 writel(data, mapped_reg);
126 return;
127 }
128
129 BUG();
130}
131
Marek Vasuteb13e0f2018-06-10 16:05:48 +0200132u32 sh_pfc_read(struct sh_pfc *pfc, u32 reg)
Marek Vasut3066a062017-09-15 21:13:55 +0200133{
Marek Vasut068a90b2018-06-19 06:13:42 +0200134 return sh_pfc_read_raw_reg((void __iomem *)(uintptr_t)reg, 32);
Marek Vasut3066a062017-09-15 21:13:55 +0200135}
136
Marek Vasut651d5a72021-04-27 22:03:38 +0200137static void sh_pfc_unlock_reg(struct sh_pfc *pfc, u32 reg, u32 data)
Marek Vasut3066a062017-09-15 21:13:55 +0200138{
Marek Vasut651d5a72021-04-27 22:03:38 +0200139 u32 unlock;
Marek Vasut3066a062017-09-15 21:13:55 +0200140
Marek Vasut651d5a72021-04-27 22:03:38 +0200141 if (!pfc->info->unlock_reg)
142 return;
Marek Vasut3066a062017-09-15 21:13:55 +0200143
Marek Vasut651d5a72021-04-27 22:03:38 +0200144 if (pfc->info->unlock_reg >= 0x80000000UL)
145 unlock = pfc->info->unlock_reg;
146 else
147 /* unlock_reg is a mask */
148 unlock = reg & ~pfc->info->unlock_reg;
149
150 sh_pfc_write_raw_reg((void __iomem *)(uintptr_t)unlock, 32, ~data);
151}
152
153void sh_pfc_write(struct sh_pfc *pfc, u32 reg, u32 data)
154{
155 sh_pfc_unlock_reg(pfc, reg, data);
Marek Vasut068a90b2018-06-19 06:13:42 +0200156 sh_pfc_write_raw_reg((void __iomem *)(uintptr_t)reg, 32, data);
Marek Vasut3066a062017-09-15 21:13:55 +0200157}
158
159static void sh_pfc_config_reg_helper(struct sh_pfc *pfc,
160 const struct pinmux_cfg_reg *crp,
161 unsigned int in_pos,
162 void __iomem **mapped_regp, u32 *maskp,
163 unsigned int *posp)
164{
165 unsigned int k;
166
167 *mapped_regp = (void __iomem *)(uintptr_t)crp->reg;
168
169 if (crp->field_width) {
170 *maskp = (1 << crp->field_width) - 1;
171 *posp = crp->reg_width - ((in_pos + 1) * crp->field_width);
172 } else {
173 *maskp = (1 << crp->var_field_width[in_pos]) - 1;
174 *posp = crp->reg_width;
175 for (k = 0; k <= in_pos; k++)
Marek Vasutd1bc9322023-01-26 21:01:35 +0100176 *posp -= abs(crp->var_field_width[k]);
Marek Vasut3066a062017-09-15 21:13:55 +0200177 }
178}
179
180static void sh_pfc_write_config_reg(struct sh_pfc *pfc,
181 const struct pinmux_cfg_reg *crp,
182 unsigned int field, u32 value)
183{
184 void __iomem *mapped_reg;
Marek Vasut3066a062017-09-15 21:13:55 +0200185 unsigned int pos;
186 u32 mask, data;
187
188 sh_pfc_config_reg_helper(pfc, crp, field, &mapped_reg, &mask, &pos);
189
190 dev_dbg(pfc->dev, "write_reg addr = %x, value = 0x%x, field = %u, "
191 "r_width = %u, f_width = %u\n",
192 crp->reg, value, field, crp->reg_width, crp->field_width);
193
194 mask = ~(mask << pos);
195 value = value << pos;
196
197 data = sh_pfc_read_raw_reg(mapped_reg, crp->reg_width);
198 data &= mask;
199 data |= value;
200
Marek Vasut651d5a72021-04-27 22:03:38 +0200201 sh_pfc_unlock_reg(pfc, crp->reg, data);
Marek Vasut3066a062017-09-15 21:13:55 +0200202 sh_pfc_write_raw_reg(mapped_reg, crp->reg_width, data);
203}
204
205static int sh_pfc_get_config_reg(struct sh_pfc *pfc, u16 enum_id,
206 const struct pinmux_cfg_reg **crp,
207 unsigned int *fieldp, u32 *valuep)
208{
209 unsigned int k = 0;
210
211 while (1) {
212 const struct pinmux_cfg_reg *config_reg =
213 pfc->info->cfg_regs + k;
214 unsigned int r_width = config_reg->reg_width;
215 unsigned int f_width = config_reg->field_width;
216 unsigned int curr_width;
217 unsigned int bit_pos;
218 unsigned int pos = 0;
219 unsigned int m = 0;
220
221 if (!r_width)
222 break;
223
Marek Vasutd1bc9322023-01-26 21:01:35 +0100224 for (bit_pos = 0; bit_pos < r_width; bit_pos += curr_width, m++) {
Marek Vasut3066a062017-09-15 21:13:55 +0200225 u32 ncomb;
226 u32 n;
227
Marek Vasutd1bc9322023-01-26 21:01:35 +0100228 if (f_width) {
Marek Vasut3066a062017-09-15 21:13:55 +0200229 curr_width = f_width;
Marek Vasutd1bc9322023-01-26 21:01:35 +0100230 } else {
231 curr_width = abs(config_reg->var_field_width[m]);
232 if (config_reg->var_field_width[m] < 0)
233 continue;
234 }
Marek Vasut3066a062017-09-15 21:13:55 +0200235
236 ncomb = 1 << curr_width;
237 for (n = 0; n < ncomb; n++) {
238 if (config_reg->enum_ids[pos + n] == enum_id) {
239 *crp = config_reg;
240 *fieldp = m;
241 *valuep = n;
242 return 0;
243 }
244 }
245 pos += ncomb;
Marek Vasut3066a062017-09-15 21:13:55 +0200246 }
247 k++;
248 }
249
250 return -EINVAL;
251}
252
253static int sh_pfc_mark_to_enum(struct sh_pfc *pfc, u16 mark, int pos,
254 u16 *enum_idp)
255{
256 const u16 *data = pfc->info->pinmux_data;
257 unsigned int k;
258
259 if (pos) {
260 *enum_idp = data[pos + 1];
261 return pos + 1;
262 }
263
264 for (k = 0; k < pfc->info->pinmux_data_size; k++) {
265 if (data[k] == mark) {
266 *enum_idp = data[k + 1];
267 return k + 1;
268 }
269 }
270
271 dev_err(pfc->dev, "cannot locate data/mark enum_id for mark %d\n",
272 mark);
273 return -EINVAL;
274}
275
276int sh_pfc_config_mux(struct sh_pfc *pfc, unsigned mark, int pinmux_type)
277{
278 const struct pinmux_range *range;
279 int pos = 0;
280
281 switch (pinmux_type) {
282 case PINMUX_TYPE_GPIO:
283 case PINMUX_TYPE_FUNCTION:
284 range = NULL;
285 break;
286
287 case PINMUX_TYPE_OUTPUT:
288 range = &pfc->info->output;
289 break;
290
291 case PINMUX_TYPE_INPUT:
292 range = &pfc->info->input;
293 break;
294
295 default:
296 return -EINVAL;
297 }
298
299 /* Iterate over all the configuration fields we need to update. */
300 while (1) {
301 const struct pinmux_cfg_reg *cr;
302 unsigned int field;
303 u16 enum_id;
304 u32 value;
305 int in_range;
306 int ret;
307
308 pos = sh_pfc_mark_to_enum(pfc, mark, pos, &enum_id);
309 if (pos < 0)
310 return pos;
311
312 if (!enum_id)
313 break;
314
315 /* Check if the configuration field selects a function. If it
316 * doesn't, skip the field if it's not applicable to the
317 * requested pinmux type.
318 */
319 in_range = sh_pfc_enum_in_range(enum_id, &pfc->info->function);
320 if (!in_range) {
321 if (pinmux_type == PINMUX_TYPE_FUNCTION) {
322 /* Functions are allowed to modify all
323 * fields.
324 */
325 in_range = 1;
326 } else if (pinmux_type != PINMUX_TYPE_GPIO) {
327 /* Input/output types can only modify fields
328 * that correspond to their respective ranges.
329 */
330 in_range = sh_pfc_enum_in_range(enum_id, range);
331
332 /*
333 * special case pass through for fixed
334 * input-only or output-only pins without
335 * function enum register association.
336 */
337 if (in_range && enum_id == range->force)
338 continue;
339 }
340 /* GPIOs are only allowed to modify function fields. */
341 }
342
343 if (!in_range)
344 continue;
345
346 ret = sh_pfc_get_config_reg(pfc, enum_id, &cr, &field, &value);
347 if (ret < 0)
348 return ret;
349
350 sh_pfc_write_config_reg(pfc, cr, field, value);
351 }
352
353 return 0;
354}
355
Marek Vasuteb13e0f2018-06-10 16:05:48 +0200356const struct pinmux_bias_reg *
Marek Vasutd1bc9322023-01-26 21:01:35 +0100357rcar_pin_to_bias_reg(const struct sh_pfc_soc_info *info, unsigned int pin,
358 unsigned int *bit)
Marek Vasut3066a062017-09-15 21:13:55 +0200359{
Marek Vasuteb13e0f2018-06-10 16:05:48 +0200360 unsigned int i, j;
Marek Vasut3066a062017-09-15 21:13:55 +0200361
Marek Vasutd1bc9322023-01-26 21:01:35 +0100362 for (i = 0; info->bias_regs[i].puen || info->bias_regs[i].pud; i++) {
363 for (j = 0; j < ARRAY_SIZE(info->bias_regs[i].pins); j++) {
364 if (info->bias_regs[i].pins[j] == pin) {
Marek Vasuteb13e0f2018-06-10 16:05:48 +0200365 *bit = j;
Marek Vasutd1bc9322023-01-26 21:01:35 +0100366 return &info->bias_regs[i];
Marek Vasuteb13e0f2018-06-10 16:05:48 +0200367 }
368 }
369 }
Marek Vasut3066a062017-09-15 21:13:55 +0200370
Marek Vasuteb13e0f2018-06-10 16:05:48 +0200371 WARN_ONCE(1, "Pin %u is not in bias info list\n", pin);
Marek Vasut3066a062017-09-15 21:13:55 +0200372
373 return NULL;
374}
375
Marek Vasutd1bc9322023-01-26 21:01:35 +0100376unsigned int rcar_pinmux_get_bias(struct sh_pfc *pfc, unsigned int pin)
377{
378 const struct pinmux_bias_reg *reg;
379 unsigned int bit;
380
381 reg = rcar_pin_to_bias_reg(pfc->info, pin, &bit);
382 if (!reg)
383 return PIN_CONFIG_BIAS_DISABLE;
384
385 if (reg->puen) {
386 if (!(sh_pfc_read(pfc, reg->puen) & BIT(bit)))
387 return PIN_CONFIG_BIAS_DISABLE;
388 else if (!reg->pud || (sh_pfc_read(pfc, reg->pud) & BIT(bit)))
389 return PIN_CONFIG_BIAS_PULL_UP;
390 else
391 return PIN_CONFIG_BIAS_PULL_DOWN;
392 } else {
393 if (sh_pfc_read(pfc, reg->pud) & BIT(bit))
394 return PIN_CONFIG_BIAS_PULL_DOWN;
395 else
396 return PIN_CONFIG_BIAS_DISABLE;
397 }
398}
399
400void rcar_pinmux_set_bias(struct sh_pfc *pfc, unsigned int pin,
401 unsigned int bias)
402{
403 const struct pinmux_bias_reg *reg;
404 u32 enable, updown;
405 unsigned int bit;
406
407 reg = rcar_pin_to_bias_reg(pfc->info, pin, &bit);
408 if (!reg)
409 return;
410
411 if (reg->puen) {
412 enable = sh_pfc_read(pfc, reg->puen) & ~BIT(bit);
413 if (bias != PIN_CONFIG_BIAS_DISABLE) {
414 enable |= BIT(bit);
415
416 if (reg->pud) {
417 updown = sh_pfc_read(pfc, reg->pud) & ~BIT(bit);
418 if (bias == PIN_CONFIG_BIAS_PULL_UP)
419 updown |= BIT(bit);
420
421 sh_pfc_write(pfc, reg->pud, updown);
422 }
423 }
424 sh_pfc_write(pfc, reg->puen, enable);
425 } else {
426 enable = sh_pfc_read(pfc, reg->pud) & ~BIT(bit);
427 if (bias == PIN_CONFIG_BIAS_PULL_DOWN)
428 enable |= BIT(bit);
429
430 sh_pfc_write(pfc, reg->pud, enable);
431 }
432}
433
Marek Vasut3066a062017-09-15 21:13:55 +0200434static int sh_pfc_init_ranges(struct sh_pfc *pfc)
435{
436 struct sh_pfc_pin_range *range;
437 unsigned int nr_ranges;
438 unsigned int i;
439
440 if (pfc->info->pins[0].pin == (u16)-1) {
441 /* Pin number -1 denotes that the SoC doesn't report pin numbers
442 * in its pin arrays yet. Consider the pin numbers range as
443 * continuous and allocate a single range.
444 */
445 pfc->nr_ranges = 1;
446 pfc->ranges = kzalloc(sizeof(*pfc->ranges), GFP_KERNEL);
447 if (pfc->ranges == NULL)
448 return -ENOMEM;
449
450 pfc->ranges->start = 0;
451 pfc->ranges->end = pfc->info->nr_pins - 1;
452 pfc->nr_gpio_pins = pfc->info->nr_pins;
453
454 return 0;
455 }
456
457 /* Count, allocate and fill the ranges. The PFC SoC data pins array must
458 * be sorted by pin numbers, and pins without a GPIO port must come
459 * last.
460 */
461 for (i = 1, nr_ranges = 1; i < pfc->info->nr_pins; ++i) {
462 if (pfc->info->pins[i-1].pin != pfc->info->pins[i].pin - 1)
463 nr_ranges++;
464 }
465
466 pfc->nr_ranges = nr_ranges;
467 pfc->ranges = kzalloc(sizeof(*pfc->ranges) * nr_ranges, GFP_KERNEL);
468 if (pfc->ranges == NULL)
469 return -ENOMEM;
470
471 range = pfc->ranges;
472 range->start = pfc->info->pins[0].pin;
473
474 for (i = 1; i < pfc->info->nr_pins; ++i) {
475 if (pfc->info->pins[i-1].pin == pfc->info->pins[i].pin - 1)
476 continue;
477
478 range->end = pfc->info->pins[i-1].pin;
479 if (!(pfc->info->pins[i-1].configs & SH_PFC_PIN_CFG_NO_GPIO))
480 pfc->nr_gpio_pins = range->end + 1;
481
482 range++;
483 range->start = pfc->info->pins[i].pin;
484 }
485
486 range->end = pfc->info->pins[i-1].pin;
487 if (!(pfc->info->pins[i-1].configs & SH_PFC_PIN_CFG_NO_GPIO))
488 pfc->nr_gpio_pins = range->end + 1;
489
490 return 0;
491}
492
493static int sh_pfc_pinctrl_get_pins_count(struct udevice *dev)
494{
495 struct sh_pfc_pinctrl_priv *priv = dev_get_priv(dev);
496
497 return priv->pfc.info->nr_pins;
498}
499
500static const char *sh_pfc_pinctrl_get_pin_name(struct udevice *dev,
501 unsigned selector)
502{
503 struct sh_pfc_pinctrl_priv *priv = dev_get_priv(dev);
504
505 return priv->pfc.info->pins[selector].name;
506}
507
508static int sh_pfc_pinctrl_get_groups_count(struct udevice *dev)
509{
510 struct sh_pfc_pinctrl_priv *priv = dev_get_priv(dev);
511
512 return priv->pfc.info->nr_groups;
513}
514
515static const char *sh_pfc_pinctrl_get_group_name(struct udevice *dev,
516 unsigned selector)
517{
518 struct sh_pfc_pinctrl_priv *priv = dev_get_priv(dev);
519
520 return priv->pfc.info->groups[selector].name;
521}
522
Lad Prabhakar23ea9b42020-11-28 13:13:09 +0000523static int sh_pfc_pinctrl_get_pin_muxing(struct udevice *dev,
524 unsigned int selector,
525 char *buf, int size)
526{
527 struct sh_pfc_pinctrl_priv *priv = dev_get_priv(dev);
528 struct sh_pfc_pinctrl *pmx = &priv->pmx;
529 struct sh_pfc *pfc = &priv->pfc;
530 struct sh_pfc_pin_config *cfg;
531 const struct sh_pfc_pin *pin;
532 int idx;
533
534 pin = &priv->pfc.info->pins[selector];
535 if (!pin) {
536 snprintf(buf, size, "Unknown");
537 return -EINVAL;
538 }
539
540 idx = sh_pfc_get_pin_index(pfc, pin->pin);
541 cfg = &pmx->configs[idx];
542 snprintf(buf, size, "%s", cfg->name);
543
544 return 0;
545}
546
Marek Vasut3066a062017-09-15 21:13:55 +0200547static int sh_pfc_pinctrl_get_functions_count(struct udevice *dev)
548{
549 struct sh_pfc_pinctrl_priv *priv = dev_get_priv(dev);
550
551 return priv->pfc.info->nr_functions;
552}
553
554static const char *sh_pfc_pinctrl_get_function_name(struct udevice *dev,
555 unsigned selector)
556{
557 struct sh_pfc_pinctrl_priv *priv = dev_get_priv(dev);
558
559 return priv->pfc.info->functions[selector].name;
560}
561
Marek Vasut02d34f02019-04-21 22:46:25 +0200562static int sh_pfc_gpio_request_enable(struct udevice *dev,
563 unsigned pin_selector)
Marek Vasut489d79c2017-11-26 18:07:29 +0100564{
565 struct sh_pfc_pinctrl_priv *priv = dev_get_priv(dev);
566 struct sh_pfc_pinctrl *pmx = &priv->pmx;
567 struct sh_pfc *pfc = &priv->pfc;
568 struct sh_pfc_pin_config *cfg;
569 const struct sh_pfc_pin *pin = NULL;
Marek Vasut0cc19362019-04-21 22:46:25 +0200570 int i, ret, idx;
Marek Vasut489d79c2017-11-26 18:07:29 +0100571
titron09bf4982019-07-22 17:45:37 +0800572 for (i = 0; i < pfc->info->nr_pins; i++) {
Marek Vasut489d79c2017-11-26 18:07:29 +0100573 if (priv->pfc.info->pins[i].pin != pin_selector)
574 continue;
575
576 pin = &priv->pfc.info->pins[i];
577 break;
578 }
579
580 if (!pin)
581 return -EINVAL;
582
583 idx = sh_pfc_get_pin_index(pfc, pin->pin);
584 cfg = &pmx->configs[idx];
585
Lad Prabhakar13ed8d52020-11-28 13:13:08 +0000586 if (cfg->type != PINMUX_TYPE_NONE) {
587 if (!strcmp(cfg->name, pin->name))
588 return 0;
589
590 dev_err(pfc->dev, "Pin already used as %s\n",
591 cfg->name);
Marek Vasut489d79c2017-11-26 18:07:29 +0100592 return -EBUSY;
Lad Prabhakar13ed8d52020-11-28 13:13:08 +0000593 }
Marek Vasut489d79c2017-11-26 18:07:29 +0100594
Marek Vasut0cc19362019-04-21 22:46:25 +0200595 ret = sh_pfc_config_mux(pfc, pin->enum_id, PINMUX_TYPE_GPIO);
596 if (ret)
597 return ret;
598
599 cfg->type = PINMUX_TYPE_GPIO;
Lad Prabhakar13ed8d52020-11-28 13:13:08 +0000600 cfg->name = "gpio";
Marek Vasut0cc19362019-04-21 22:46:25 +0200601
602 return 0;
Marek Vasut489d79c2017-11-26 18:07:29 +0100603}
604
Marek Vasut02d34f02019-04-21 22:46:25 +0200605static int sh_pfc_gpio_disable_free(struct udevice *dev,
606 unsigned pin_selector)
607{
608 struct sh_pfc_pinctrl_priv *priv = dev_get_priv(dev);
609 struct sh_pfc_pinctrl *pmx = &priv->pmx;
610 struct sh_pfc *pfc = &priv->pfc;
611 struct sh_pfc_pin_config *cfg;
612 const struct sh_pfc_pin *pin = NULL;
613 int i, idx;
614
titron09bf4982019-07-22 17:45:37 +0800615 for (i = 0; i < pfc->info->nr_pins; i++) {
Marek Vasut02d34f02019-04-21 22:46:25 +0200616 if (priv->pfc.info->pins[i].pin != pin_selector)
617 continue;
618
619 pin = &priv->pfc.info->pins[i];
620 break;
621 }
622
623 if (!pin)
624 return -EINVAL;
625
626 idx = sh_pfc_get_pin_index(pfc, pin->pin);
627 cfg = &pmx->configs[idx];
628
629 cfg->type = PINMUX_TYPE_NONE;
Lad Prabhakar13ed8d52020-11-28 13:13:08 +0000630 cfg->name = "none";
Marek Vasut02d34f02019-04-21 22:46:25 +0200631
632 return 0;
633}
634
Marek Vasut5e6db842017-11-26 17:42:16 +0100635static int sh_pfc_pinctrl_pin_set(struct udevice *dev, unsigned pin_selector,
636 unsigned func_selector)
637{
638 struct sh_pfc_pinctrl_priv *priv = dev_get_priv(dev);
639 struct sh_pfc_pinctrl *pmx = &priv->pmx;
640 struct sh_pfc *pfc = &priv->pfc;
641 const struct sh_pfc_pin *pin = &priv->pfc.info->pins[pin_selector];
642 int idx = sh_pfc_get_pin_index(pfc, pin->pin);
643 struct sh_pfc_pin_config *cfg = &pmx->configs[idx];
Lad Prabhakar13ed8d52020-11-28 13:13:08 +0000644 int ret;
Marek Vasut5e6db842017-11-26 17:42:16 +0100645
Lad Prabhakar13ed8d52020-11-28 13:13:08 +0000646 if (cfg->type != PINMUX_TYPE_NONE) {
647 if (!strcmp(cfg->name, pin->name))
648 return 0;
649
650 dev_err(pfc->dev, "Pin already used as %s\n",
651 cfg->name);
Marek Vasut5e6db842017-11-26 17:42:16 +0100652 return -EBUSY;
Lad Prabhakar13ed8d52020-11-28 13:13:08 +0000653 }
654
655 ret = sh_pfc_config_mux(pfc, pin->enum_id, PINMUX_TYPE_FUNCTION);
656 if (ret)
657 return ret;
Marek Vasut5e6db842017-11-26 17:42:16 +0100658
Lad Prabhakar13ed8d52020-11-28 13:13:08 +0000659 cfg->type = PINMUX_TYPE_FUNCTION;
660 cfg->name = "function";
661
662 return 0;
Marek Vasut5e6db842017-11-26 17:42:16 +0100663}
664
Marek Vasut3066a062017-09-15 21:13:55 +0200665static int sh_pfc_pinctrl_group_set(struct udevice *dev, unsigned group_selector,
666 unsigned func_selector)
667{
668 struct sh_pfc_pinctrl_priv *priv = dev_get_priv(dev);
669 struct sh_pfc_pinctrl *pmx = &priv->pmx;
670 struct sh_pfc *pfc = &priv->pfc;
671 const struct sh_pfc_pin_group *grp = &priv->pfc.info->groups[group_selector];
Lad Prabhakar13ed8d52020-11-28 13:13:08 +0000672 bool grp_pins_configured = true;
673 struct sh_pfc_pin_config *cfg;
Marek Vasut3066a062017-09-15 21:13:55 +0200674 unsigned int i;
675 int ret = 0;
Lad Prabhakar13ed8d52020-11-28 13:13:08 +0000676 int idx;
Marek Vasut3066a062017-09-15 21:13:55 +0200677
678 for (i = 0; i < grp->nr_pins; ++i) {
Lad Prabhakar13ed8d52020-11-28 13:13:08 +0000679 idx = sh_pfc_get_pin_index(pfc, grp->pins[i]);
680 cfg = &pmx->configs[idx];
Marek Vasut3066a062017-09-15 21:13:55 +0200681
682 if (cfg->type != PINMUX_TYPE_NONE) {
Lad Prabhakar13ed8d52020-11-28 13:13:08 +0000683 if (!strcmp(cfg->name, grp->name))
684 continue;
685
686 dev_err(pfc->dev, "Pin already used as %s\n",
687 cfg->name);
Marek Vasut3066a062017-09-15 21:13:55 +0200688 ret = -EBUSY;
689 goto done;
Lad Prabhakar13ed8d52020-11-28 13:13:08 +0000690 } else {
691 grp_pins_configured = false;
Marek Vasut3066a062017-09-15 21:13:55 +0200692 }
693 }
694
Lad Prabhakar13ed8d52020-11-28 13:13:08 +0000695 if (grp_pins_configured)
696 return 0;
697
Marek Vasut3066a062017-09-15 21:13:55 +0200698 for (i = 0; i < grp->nr_pins; ++i) {
699 ret = sh_pfc_config_mux(pfc, grp->mux[i], PINMUX_TYPE_FUNCTION);
700 if (ret < 0)
701 break;
Lad Prabhakar13ed8d52020-11-28 13:13:08 +0000702
703 idx = sh_pfc_get_pin_index(pfc, grp->pins[i]);
704 cfg = &pmx->configs[idx];
705 cfg->type = PINMUX_TYPE_FUNCTION;
706 cfg->name = priv->pfc.info->groups[group_selector].name;
Marek Vasut3066a062017-09-15 21:13:55 +0200707 }
708
709done:
710 return ret;
711}
Marek Vasutc9dd9ae2017-09-28 00:56:24 +0200712#if CONFIG_IS_ENABLED(PINCONF)
713static const struct pinconf_param sh_pfc_pinconf_params[] = {
714 { "bias-disable", PIN_CONFIG_BIAS_DISABLE, 0 },
715 { "bias-pull-up", PIN_CONFIG_BIAS_PULL_UP, 1 },
716 { "bias-pull-down", PIN_CONFIG_BIAS_PULL_DOWN, 1 },
717 { "drive-strength", PIN_CONFIG_DRIVE_STRENGTH, 0 },
718 { "power-source", PIN_CONFIG_POWER_SOURCE, 3300 },
719};
720
721static void __iomem *
722sh_pfc_pinconf_find_drive_strength_reg(struct sh_pfc *pfc, unsigned int pin,
723 unsigned int *offset, unsigned int *size)
724{
725 const struct pinmux_drive_reg_field *field;
726 const struct pinmux_drive_reg *reg;
727 unsigned int i;
728
729 for (reg = pfc->info->drive_regs; reg->reg; ++reg) {
730 for (i = 0; i < ARRAY_SIZE(reg->fields); ++i) {
731 field = &reg->fields[i];
732
733 if (field->size && field->pin == pin) {
734 *offset = field->offset;
735 *size = field->size;
736
737 return (void __iomem *)(uintptr_t)reg->reg;
738 }
739 }
740 }
741
742 return NULL;
743}
744
745static int sh_pfc_pinconf_set_drive_strength(struct sh_pfc *pfc,
746 unsigned int pin, u16 strength)
747{
748 unsigned int offset;
749 unsigned int size;
750 unsigned int step;
751 void __iomem *reg;
Marek Vasutc9dd9ae2017-09-28 00:56:24 +0200752 u32 val;
753
754 reg = sh_pfc_pinconf_find_drive_strength_reg(pfc, pin, &offset, &size);
755 if (!reg)
756 return -EINVAL;
757
758 step = size == 2 ? 6 : 3;
759
760 if (strength < step || strength > 24)
761 return -EINVAL;
762
763 /* Convert the value from mA based on a full drive strength value of
764 * 24mA. We can make the full value configurable later if needed.
765 */
766 strength = strength / step - 1;
767
768 val = sh_pfc_read_raw_reg(reg, 32);
Marek Vasut0d9c8102018-06-13 08:02:55 +0200769 val &= ~GENMASK(offset + 4 - 1, offset);
Marek Vasutc9dd9ae2017-09-28 00:56:24 +0200770 val |= strength << offset;
771
Marek Vasut651d5a72021-04-27 22:03:38 +0200772 sh_pfc_unlock_reg(pfc, (uintptr_t)reg, val);
Marek Vasutc9dd9ae2017-09-28 00:56:24 +0200773 sh_pfc_write_raw_reg(reg, 32, val);
774
775 return 0;
776}
777
778/* Check whether the requested parameter is supported for a pin. */
779static bool sh_pfc_pinconf_validate(struct sh_pfc *pfc, unsigned int _pin,
780 unsigned int param)
781{
782 int idx = sh_pfc_get_pin_index(pfc, _pin);
783 const struct sh_pfc_pin *pin = &pfc->info->pins[idx];
784
785 switch (param) {
786 case PIN_CONFIG_BIAS_DISABLE:
787 return pin->configs &
788 (SH_PFC_PIN_CFG_PULL_UP | SH_PFC_PIN_CFG_PULL_DOWN);
789
790 case PIN_CONFIG_BIAS_PULL_UP:
791 return pin->configs & SH_PFC_PIN_CFG_PULL_UP;
792
793 case PIN_CONFIG_BIAS_PULL_DOWN:
794 return pin->configs & SH_PFC_PIN_CFG_PULL_DOWN;
795
796 case PIN_CONFIG_DRIVE_STRENGTH:
797 return pin->configs & SH_PFC_PIN_CFG_DRIVE_STRENGTH;
798
799 case PIN_CONFIG_POWER_SOURCE:
800 return pin->configs & SH_PFC_PIN_CFG_IO_VOLTAGE;
801
802 default:
803 return false;
804 }
805}
806
807static int sh_pfc_pinconf_set(struct sh_pfc_pinctrl *pmx, unsigned _pin,
808 unsigned int param, unsigned int arg)
809{
810 struct sh_pfc *pfc = pmx->pfc;
811 void __iomem *pocctrl;
Marek Vasutc9dd9ae2017-09-28 00:56:24 +0200812 u32 addr, val;
813 int bit, ret;
814
815 if (!sh_pfc_pinconf_validate(pfc, _pin, param))
816 return -ENOTSUPP;
817
818 switch (param) {
819 case PIN_CONFIG_BIAS_PULL_UP:
820 case PIN_CONFIG_BIAS_PULL_DOWN:
821 case PIN_CONFIG_BIAS_DISABLE:
822 if (!pfc->info->ops || !pfc->info->ops->set_bias)
823 return -ENOTSUPP;
824
825 pfc->info->ops->set_bias(pfc, _pin, param);
826
827 break;
828
829 case PIN_CONFIG_DRIVE_STRENGTH:
830 ret = sh_pfc_pinconf_set_drive_strength(pfc, _pin, arg);
831 if (ret < 0)
832 return ret;
833
834 break;
835
836 case PIN_CONFIG_POWER_SOURCE:
837 if (!pfc->info->ops || !pfc->info->ops->pin_to_pocctrl)
838 return -ENOTSUPP;
839
Marek Vasutc02d50a2023-01-26 21:01:40 +0100840 bit = pfc->info->ops->pin_to_pocctrl(_pin, &addr);
Marek Vasutc9dd9ae2017-09-28 00:56:24 +0200841 if (bit < 0) {
842 printf("invalid pin %#x", _pin);
843 return bit;
844 }
845
846 if (arg != 1800 && arg != 3300)
847 return -EINVAL;
848
849 pocctrl = (void __iomem *)(uintptr_t)addr;
850
851 val = sh_pfc_read_raw_reg(pocctrl, 32);
852 if (arg == 3300)
853 val |= BIT(bit);
854 else
855 val &= ~BIT(bit);
856
Marek Vasut651d5a72021-04-27 22:03:38 +0200857 sh_pfc_unlock_reg(pfc, addr, val);
Marek Vasutc9dd9ae2017-09-28 00:56:24 +0200858 sh_pfc_write_raw_reg(pocctrl, 32, val);
859
860 break;
861
862 default:
863 return -ENOTSUPP;
864 }
865
866 return 0;
867}
868
Marek Vasut5e6db842017-11-26 17:42:16 +0100869static int sh_pfc_pinconf_pin_set(struct udevice *dev,
870 unsigned int pin_selector,
871 unsigned int param, unsigned int arg)
872{
873 struct sh_pfc_pinctrl_priv *priv = dev_get_priv(dev);
874 struct sh_pfc_pinctrl *pmx = &priv->pmx;
875 struct sh_pfc *pfc = &priv->pfc;
876 const struct sh_pfc_pin *pin = &pfc->info->pins[pin_selector];
877
878 sh_pfc_pinconf_set(pmx, pin->pin, param, arg);
879
880 return 0;
881}
Marek Vasutc9dd9ae2017-09-28 00:56:24 +0200882
883static int sh_pfc_pinconf_group_set(struct udevice *dev,
884 unsigned int group_selector,
885 unsigned int param, unsigned int arg)
886{
887 struct sh_pfc_pinctrl_priv *priv = dev_get_priv(dev);
888 struct sh_pfc_pinctrl *pmx = &priv->pmx;
889 struct sh_pfc *pfc = &priv->pfc;
890 const struct sh_pfc_pin_group *grp = &pfc->info->groups[group_selector];
891 unsigned int i;
892
893 for (i = 0; i < grp->nr_pins; i++)
894 sh_pfc_pinconf_set(pmx, grp->pins[i], param, arg);
895
896 return 0;
897}
898#endif
Marek Vasut3066a062017-09-15 21:13:55 +0200899
900static struct pinctrl_ops sh_pfc_pinctrl_ops = {
901 .get_pins_count = sh_pfc_pinctrl_get_pins_count,
902 .get_pin_name = sh_pfc_pinctrl_get_pin_name,
903 .get_groups_count = sh_pfc_pinctrl_get_groups_count,
904 .get_group_name = sh_pfc_pinctrl_get_group_name,
Lad Prabhakar23ea9b42020-11-28 13:13:09 +0000905 .get_pin_muxing = sh_pfc_pinctrl_get_pin_muxing,
Marek Vasut3066a062017-09-15 21:13:55 +0200906 .get_functions_count = sh_pfc_pinctrl_get_functions_count,
907 .get_function_name = sh_pfc_pinctrl_get_function_name,
908
Marek Vasutc9dd9ae2017-09-28 00:56:24 +0200909#if CONFIG_IS_ENABLED(PINCONF)
910 .pinconf_num_params = ARRAY_SIZE(sh_pfc_pinconf_params),
911 .pinconf_params = sh_pfc_pinconf_params,
Marek Vasut5e6db842017-11-26 17:42:16 +0100912 .pinconf_set = sh_pfc_pinconf_pin_set,
Marek Vasutc9dd9ae2017-09-28 00:56:24 +0200913 .pinconf_group_set = sh_pfc_pinconf_group_set,
914#endif
Marek Vasut5e6db842017-11-26 17:42:16 +0100915 .pinmux_set = sh_pfc_pinctrl_pin_set,
Marek Vasut3066a062017-09-15 21:13:55 +0200916 .pinmux_group_set = sh_pfc_pinctrl_group_set,
917 .set_state = pinctrl_generic_set_state,
Marek Vasut02d34f02019-04-21 22:46:25 +0200918
919 .gpio_request_enable = sh_pfc_gpio_request_enable,
920 .gpio_disable_free = sh_pfc_gpio_disable_free,
Marek Vasut3066a062017-09-15 21:13:55 +0200921};
922
923static int sh_pfc_map_pins(struct sh_pfc *pfc, struct sh_pfc_pinctrl *pmx)
924{
925 unsigned int i;
926
927 /* Allocate and initialize the pins and configs arrays. */
928 pmx->configs = kzalloc(sizeof(*pmx->configs) * pfc->info->nr_pins,
929 GFP_KERNEL);
930 if (unlikely(!pmx->configs))
931 return -ENOMEM;
932
933 for (i = 0; i < pfc->info->nr_pins; ++i) {
934 struct sh_pfc_pin_config *cfg = &pmx->configs[i];
935 cfg->type = PINMUX_TYPE_NONE;
Lad Prabhakar13ed8d52020-11-28 13:13:08 +0000936 cfg->name = "none";
Marek Vasut3066a062017-09-15 21:13:55 +0200937 }
938
939 return 0;
940}
941
942
943static int sh_pfc_pinctrl_probe(struct udevice *dev)
944{
945 struct sh_pfc_pinctrl_priv *priv = dev_get_priv(dev);
946 enum sh_pfc_model model = dev_get_driver_data(dev);
947 fdt_addr_t base;
948
Masahiro Yamadaa89b4de2020-07-17 14:36:48 +0900949 base = dev_read_addr(dev);
Marek Vasut3066a062017-09-15 21:13:55 +0200950 if (base == FDT_ADDR_T_NONE)
951 return -EINVAL;
952
953 priv->pfc.regs = devm_ioremap(dev, base, SZ_2K);
954 if (!priv->pfc.regs)
955 return -ENOMEM;
956
Marek Vasutc40f2d62018-01-17 22:18:59 +0100957#ifdef CONFIG_PINCTRL_PFC_R8A7790
958 if (model == SH_PFC_R8A7790)
959 priv->pfc.info = &r8a7790_pinmux_info;
960#endif
Marek Vasut06ef9e82018-01-17 17:14:45 +0100961#ifdef CONFIG_PINCTRL_PFC_R8A7791
962 if (model == SH_PFC_R8A7791)
963 priv->pfc.info = &r8a7791_pinmux_info;
964#endif
Marek Vasut1ef39302018-01-17 22:29:50 +0100965#ifdef CONFIG_PINCTRL_PFC_R8A7792
966 if (model == SH_PFC_R8A7792)
967 priv->pfc.info = &r8a7792_pinmux_info;
968#endif
Marek Vasut06ef9e82018-01-17 17:14:45 +0100969#ifdef CONFIG_PINCTRL_PFC_R8A7793
970 if (model == SH_PFC_R8A7793)
971 priv->pfc.info = &r8a7793_pinmux_info;
972#endif
Marek Vasut4dd88d52018-01-17 22:33:59 +0100973#ifdef CONFIG_PINCTRL_PFC_R8A7794
974 if (model == SH_PFC_R8A7794)
975 priv->pfc.info = &r8a7794_pinmux_info;
976#endif
Marek Vasutc02d50a2023-01-26 21:01:40 +0100977#ifdef CONFIG_PINCTRL_PFC_R8A77951
Marek Vasut3066a062017-09-15 21:13:55 +0200978 if (model == SH_PFC_R8A7795)
Marek Vasutc02d50a2023-01-26 21:01:40 +0100979 priv->pfc.info = &r8a77951_pinmux_info;
Marek Vasut3066a062017-09-15 21:13:55 +0200980#endif
Marek Vasutd0f9c7b2023-01-26 21:01:41 +0100981#ifdef CONFIG_PINCTRL_PFC_R8A77960
982 if (model == SH_PFC_R8A77960)
983 priv->pfc.info = &r8a77960_pinmux_info;
984#endif
985#ifdef CONFIG_PINCTRL_PFC_R8A77961
986 if (model == SH_PFC_R8A77961)
987 priv->pfc.info = &r8a77961_pinmux_info;
Marek Vasut3066a062017-09-15 21:13:55 +0200988#endif
Adam Ford96980fb2020-06-30 09:30:09 -0500989#ifdef CONFIG_PINCTRL_PFC_R8A774A1
990 if (model == SH_PFC_R8A774A1)
991 priv->pfc.info = &r8a774a1_pinmux_info;
992#endif
Biju Dasd1d78882020-10-28 10:34:21 +0000993#ifdef CONFIG_PINCTRL_PFC_R8A774B1
994 if (model == SH_PFC_R8A774B1)
995 priv->pfc.info = &r8a774b1_pinmux_info;
996#endif
Lad Prabhakar53b88b92021-03-15 22:24:04 +0000997#ifdef CONFIG_PINCTRL_PFC_R8A774C0
998 if (model == SH_PFC_R8A774C0)
999 priv->pfc.info = &r8a774c0_pinmux_info;
1000#endif
Biju Das121bd002020-10-28 10:34:22 +00001001#ifdef CONFIG_PINCTRL_PFC_R8A774E1
1002 if (model == SH_PFC_R8A774E1)
1003 priv->pfc.info = &r8a774e1_pinmux_info;
1004#endif
Marek Vasut72269e02019-03-04 01:32:44 +01001005#ifdef CONFIG_PINCTRL_PFC_R8A77965
1006 if (model == SH_PFC_R8A77965)
1007 priv->pfc.info = &r8a77965_pinmux_info;
1008#endif
Marek Vasuta0e11e52017-10-09 20:57:29 +02001009#ifdef CONFIG_PINCTRL_PFC_R8A77970
1010 if (model == SH_PFC_R8A77970)
1011 priv->pfc.info = &r8a77970_pinmux_info;
1012#endif
Marek Vasuta6a7f482019-07-29 19:59:44 +02001013#ifdef CONFIG_PINCTRL_PFC_R8A77980
1014 if (model == SH_PFC_R8A77980)
1015 priv->pfc.info = &r8a77980_pinmux_info;
1016#endif
Marek Vasut68a77042018-04-26 13:09:20 +02001017#ifdef CONFIG_PINCTRL_PFC_R8A77990
1018 if (model == SH_PFC_R8A77990)
1019 priv->pfc.info = &r8a77990_pinmux_info;
1020#endif
Marek Vasut7d35e642017-10-08 20:57:37 +02001021#ifdef CONFIG_PINCTRL_PFC_R8A77995
1022 if (model == SH_PFC_R8A77995)
1023 priv->pfc.info = &r8a77995_pinmux_info;
1024#endif
Marek Vasut4dbc6532021-04-27 01:55:54 +02001025#ifdef CONFIG_PINCTRL_PFC_R8A779A0
1026 if (model == SH_PFC_R8A779A0)
1027 priv->pfc.info = &r8a779a0_pinmux_info;
1028#endif
LUU HOAI9b68f5d2023-02-28 22:34:40 +01001029#ifdef CONFIG_PINCTRL_PFC_R8A779F0
1030 if (model == SH_PFC_R8A779F0)
1031 priv->pfc.info = &r8a779f0_pinmux_info;
1032#endif
Marek Vasut3066a062017-09-15 21:13:55 +02001033
1034 priv->pmx.pfc = &priv->pfc;
1035 sh_pfc_init_ranges(&priv->pfc);
1036 sh_pfc_map_pins(&priv->pfc, &priv->pmx);
1037
1038 return 0;
1039}
1040
1041static const struct udevice_id sh_pfc_pinctrl_ids[] = {
Marek Vasutc40f2d62018-01-17 22:18:59 +01001042#ifdef CONFIG_PINCTRL_PFC_R8A7790
1043 {
1044 .compatible = "renesas,pfc-r8a7790",
1045 .data = SH_PFC_R8A7790,
1046 },
1047#endif
Marek Vasut06ef9e82018-01-17 17:14:45 +01001048#ifdef CONFIG_PINCTRL_PFC_R8A7791
1049 {
1050 .compatible = "renesas,pfc-r8a7791",
1051 .data = SH_PFC_R8A7791,
1052 },
1053#endif
Marek Vasut1ef39302018-01-17 22:29:50 +01001054#ifdef CONFIG_PINCTRL_PFC_R8A7792
1055 {
1056 .compatible = "renesas,pfc-r8a7792",
1057 .data = SH_PFC_R8A7792,
1058 },
1059#endif
Marek Vasut06ef9e82018-01-17 17:14:45 +01001060#ifdef CONFIG_PINCTRL_PFC_R8A7793
1061 {
1062 .compatible = "renesas,pfc-r8a7793",
1063 .data = SH_PFC_R8A7793,
1064 },
1065#endif
Marek Vasut4dd88d52018-01-17 22:33:59 +01001066#ifdef CONFIG_PINCTRL_PFC_R8A7794
1067 {
1068 .compatible = "renesas,pfc-r8a7794",
1069 .data = SH_PFC_R8A7794,
1070 },
1071#endif
Marek Vasutc02d50a2023-01-26 21:01:40 +01001072#ifdef CONFIG_PINCTRL_PFC_R8A77951
Marek Vasut3066a062017-09-15 21:13:55 +02001073 {
1074 .compatible = "renesas,pfc-r8a7795",
1075 .data = SH_PFC_R8A7795,
1076 },
1077#endif
Marek Vasutd0f9c7b2023-01-26 21:01:41 +01001078#ifdef CONFIG_PINCTRL_PFC_R8A77960
Marek Vasut3066a062017-09-15 21:13:55 +02001079 {
1080 .compatible = "renesas,pfc-r8a7796",
Marek Vasutd0f9c7b2023-01-26 21:01:41 +01001081 .data = SH_PFC_R8A77960,
1082 },
1083#endif
1084#ifdef CONFIG_PINCTRL_PFC_R8A77961
1085 {
1086 .compatible = "renesas,pfc-r8a77961",
1087 .data = SH_PFC_R8A77961,
Marek Vasut72269e02019-03-04 01:32:44 +01001088 },
1089#endif
Adam Ford96980fb2020-06-30 09:30:09 -05001090#ifdef CONFIG_PINCTRL_PFC_R8A774A1
1091 {
1092 .compatible = "renesas,pfc-r8a774a1",
1093 .data = SH_PFC_R8A774A1,
1094 },
1095#endif
Biju Dasd1d78882020-10-28 10:34:21 +00001096#ifdef CONFIG_PINCTRL_PFC_R8A774B1
1097 {
1098 .compatible = "renesas,pfc-r8a774b1",
1099 .data = SH_PFC_R8A774B1,
1100 },
1101#endif
Lad Prabhakar53b88b92021-03-15 22:24:04 +00001102#ifdef CONFIG_PINCTRL_PFC_R8A774C0
1103 {
1104 .compatible = "renesas,pfc-r8a774c0",
1105 .data = SH_PFC_R8A774C0,
1106 },
1107#endif
Biju Das121bd002020-10-28 10:34:22 +00001108#ifdef CONFIG_PINCTRL_PFC_R8A774E1
1109 {
1110 .compatible = "renesas,pfc-r8a774e1",
1111 .data = SH_PFC_R8A774E1,
1112 },
1113#endif
Marek Vasut72269e02019-03-04 01:32:44 +01001114#ifdef CONFIG_PINCTRL_PFC_R8A77965
1115 {
Marek Vasut20d721e2018-02-26 10:35:15 +01001116 .compatible = "renesas,pfc-r8a77965",
Marek Vasut72269e02019-03-04 01:32:44 +01001117 .data = SH_PFC_R8A77965,
Marek Vasut3066a062017-09-15 21:13:55 +02001118 },
1119#endif
Marek Vasuta0e11e52017-10-09 20:57:29 +02001120#ifdef CONFIG_PINCTRL_PFC_R8A77970
1121 {
1122 .compatible = "renesas,pfc-r8a77970",
1123 .data = SH_PFC_R8A77970,
1124 },
1125#endif
Marek Vasuta6a7f482019-07-29 19:59:44 +02001126#ifdef CONFIG_PINCTRL_PFC_R8A77980
1127 {
1128 .compatible = "renesas,pfc-r8a77980",
1129 .data = SH_PFC_R8A77980,
1130 },
1131#endif
Marek Vasut68a77042018-04-26 13:09:20 +02001132#ifdef CONFIG_PINCTRL_PFC_R8A77990
1133 {
1134 .compatible = "renesas,pfc-r8a77990",
1135 .data = SH_PFC_R8A77990,
1136 },
1137#endif
Marek Vasut7d35e642017-10-08 20:57:37 +02001138#ifdef CONFIG_PINCTRL_PFC_R8A77995
1139 {
1140 .compatible = "renesas,pfc-r8a77995",
1141 .data = SH_PFC_R8A77995,
1142 },
1143#endif
Marek Vasut4dbc6532021-04-27 01:55:54 +02001144#ifdef CONFIG_PINCTRL_PFC_R8A779A0
1145 {
1146 .compatible = "renesas,pfc-r8a779a0",
1147 .data = SH_PFC_R8A779A0,
1148 },
1149#endif
LUU HOAI9b68f5d2023-02-28 22:34:40 +01001150#ifdef CONFIG_PINCTRL_PFC_R8A779F0
1151 {
1152 .compatible = "renesas,pfc-r8a779f0",
1153 .data = SH_PFC_R8A779F0,
1154 },
1155#endif
Marek Vasut4dbc6532021-04-27 01:55:54 +02001156
Marek Vasut3066a062017-09-15 21:13:55 +02001157 { },
1158};
1159
1160U_BOOT_DRIVER(pinctrl_sh_pfc) = {
1161 .name = "sh_pfc_pinctrl",
1162 .id = UCLASS_PINCTRL,
1163 .of_match = sh_pfc_pinctrl_ids,
Simon Glass8a2b47f2020-12-03 16:55:17 -07001164 .priv_auto = sizeof(struct sh_pfc_pinctrl_priv),
Marek Vasut3066a062017-09-15 21:13:55 +02001165 .ops = &sh_pfc_pinctrl_ops,
1166 .probe = sh_pfc_pinctrl_probe,
1167};