1 // SPDX-License-Identifier: GPL-2.0+
3 * Pinctrl driver for Nexell SoCs
4 * (C) Copyright 2016 Nexell
5 * Bongyu, KOO <freestyle@nexell.co.kr>
12 #include "pinctrl-nexell.h"
13 #include "pinctrl-s5pxx18.h"
15 DECLARE_GLOBAL_DATA_PTR;
17 /* given a pin-name, return the address of pin config registers */
18 unsigned long pin_to_bank_base(struct udevice *dev, const char *pin_name,
21 struct nexell_pinctrl_priv *priv = dev_get_priv(dev);
22 const struct nexell_pin_ctrl *pin_ctrl = priv->pin_ctrl;
23 const struct nexell_pin_bank_data *bank_data = pin_ctrl->pin_banks;
24 u32 nr_banks = pin_ctrl->nr_banks, idx = 0;
28 * The format of the pin name is <bank name>-<pin_number>.
29 * Example: gpioa-4 (gpioa is the bank name and 4 is the pin number)
31 while (pin_name[idx] != '-') {
32 bank[idx] = pin_name[idx];
36 *pin = (u32)simple_strtoul(&pin_name[++idx], NULL, 10);
38 /* lookup the pin bank data using the pin bank name */
39 for (idx = 0; idx < nr_banks; idx++)
40 if (!strcmp(bank, bank_data[idx].name))
43 return priv->base + bank_data[idx].offset;
46 int nexell_pinctrl_probe(struct udevice *dev)
48 struct nexell_pinctrl_priv *priv;
51 priv = dev_get_priv(dev);
55 base = devfdt_get_addr(dev);
56 if (base == FDT_ADDR_T_NONE)
61 priv->pin_ctrl = (struct nexell_pin_ctrl *)dev_get_driver_data(dev);
63 s5pxx18_pinctrl_init(dev);