Tom Rini | 10e4779 | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
Minkyu Kang | 1edf0f2 | 2010-02-12 18:17:52 +0900 | [diff] [blame] | 2 | /* |
| 3 | * (C) Copyright 2009 Samsung Electronics |
| 4 | * Minkyu Kang <mk7.kang@samsung.com> |
Minkyu Kang | 1edf0f2 | 2010-02-12 18:17:52 +0900 | [diff] [blame] | 5 | */ |
| 6 | |
| 7 | #include <common.h> |
Simon Glass | 9b4e0e8 | 2014-10-20 19:48:40 -0600 | [diff] [blame] | 8 | #include <dm.h> |
| 9 | #include <errno.h> |
| 10 | #include <fdtdec.h> |
| 11 | #include <malloc.h> |
Minkyu Kang | 1edf0f2 | 2010-02-12 18:17:52 +0900 | [diff] [blame] | 12 | #include <asm/io.h> |
Joe Hershberger | f8928f1 | 2011-11-11 15:55:36 -0600 | [diff] [blame] | 13 | #include <asm/gpio.h> |
Simon Glass | 9b4e0e8 | 2014-10-20 19:48:40 -0600 | [diff] [blame] | 14 | #include <dm/device-internal.h> |
| 15 | |
| 16 | DECLARE_GLOBAL_DATA_PTR; |
Minkyu Kang | 1edf0f2 | 2010-02-12 18:17:52 +0900 | [diff] [blame] | 17 | |
Akshay Saraswat | 1376cdd | 2014-05-13 10:30:14 +0530 | [diff] [blame] | 18 | #define S5P_GPIO_GET_PIN(x) (x % GPIO_PER_BANK) |
Przemyslaw Marczak | b18c47e | 2014-01-22 11:24:10 +0100 | [diff] [blame] | 19 | |
Simon Glass | 3898ab7 | 2014-10-20 19:48:38 -0600 | [diff] [blame] | 20 | #define CON_MASK(val) (0xf << ((val) << 2)) |
| 21 | #define CON_SFR(gpio, cfg) ((cfg) << ((gpio) << 2)) |
| 22 | #define CON_SFR_UNSHIFT(val, gpio) ((val) >> ((gpio) << 2)) |
Minkyu Kang | 1edf0f2 | 2010-02-12 18:17:52 +0900 | [diff] [blame] | 23 | |
Simon Glass | 3898ab7 | 2014-10-20 19:48:38 -0600 | [diff] [blame] | 24 | #define DAT_MASK(gpio) (0x1 << (gpio)) |
| 25 | #define DAT_SET(gpio) (0x1 << (gpio)) |
Minkyu Kang | 1edf0f2 | 2010-02-12 18:17:52 +0900 | [diff] [blame] | 26 | |
Simon Glass | 3898ab7 | 2014-10-20 19:48:38 -0600 | [diff] [blame] | 27 | #define PULL_MASK(gpio) (0x3 << ((gpio) << 1)) |
| 28 | #define PULL_MODE(gpio, pull) ((pull) << ((gpio) << 1)) |
Minkyu Kang | 1edf0f2 | 2010-02-12 18:17:52 +0900 | [diff] [blame] | 29 | |
Simon Glass | 3898ab7 | 2014-10-20 19:48:38 -0600 | [diff] [blame] | 30 | #define DRV_MASK(gpio) (0x3 << ((gpio) << 1)) |
| 31 | #define DRV_SET(gpio, mode) ((mode) << ((gpio) << 1)) |
| 32 | #define RATE_MASK(gpio) (0x1 << (gpio + 16)) |
| 33 | #define RATE_SET(gpio) (0x1 << (gpio + 16)) |
Minkyu Kang | 1edf0f2 | 2010-02-12 18:17:52 +0900 | [diff] [blame] | 34 | |
Simon Glass | 9b4e0e8 | 2014-10-20 19:48:40 -0600 | [diff] [blame] | 35 | /* Platform data for each bank */ |
| 36 | struct exynos_gpio_platdata { |
| 37 | struct s5p_gpio_bank *bank; |
| 38 | const char *bank_name; /* Name of port, e.g. 'gpa0" */ |
| 39 | }; |
Akshay Saraswat | 1376cdd | 2014-05-13 10:30:14 +0530 | [diff] [blame] | 40 | |
Simon Glass | 9b4e0e8 | 2014-10-20 19:48:40 -0600 | [diff] [blame] | 41 | /* Information about each bank at run-time */ |
| 42 | struct exynos_bank_info { |
Simon Glass | 9b4e0e8 | 2014-10-20 19:48:40 -0600 | [diff] [blame] | 43 | struct s5p_gpio_bank *bank; |
| 44 | }; |
Akshay Saraswat | 1376cdd | 2014-05-13 10:30:14 +0530 | [diff] [blame] | 45 | |
Simon Glass | 9b4e0e8 | 2014-10-20 19:48:40 -0600 | [diff] [blame] | 46 | static struct s5p_gpio_bank *s5p_gpio_get_bank(unsigned int gpio) |
| 47 | { |
| 48 | const struct gpio_info *data; |
| 49 | unsigned int upto; |
| 50 | int i, count; |
| 51 | |
| 52 | data = get_gpio_data(); |
| 53 | count = get_bank_num(); |
| 54 | upto = 0; |
Akshay Saraswat | 1376cdd | 2014-05-13 10:30:14 +0530 | [diff] [blame] | 55 | |
Simon Glass | 9b4e0e8 | 2014-10-20 19:48:40 -0600 | [diff] [blame] | 56 | for (i = 0; i < count; i++) { |
| 57 | debug("i=%d, upto=%d\n", i, upto); |
| 58 | if (gpio < data->max_gpio) { |
| 59 | struct s5p_gpio_bank *bank; |
| 60 | bank = (struct s5p_gpio_bank *)data->reg_addr; |
| 61 | bank += (gpio - upto) / GPIO_PER_BANK; |
| 62 | debug("gpio=%d, bank=%p\n", gpio, bank); |
| 63 | return bank; |
Akshay Saraswat | 1376cdd | 2014-05-13 10:30:14 +0530 | [diff] [blame] | 64 | } |
Simon Glass | 9b4e0e8 | 2014-10-20 19:48:40 -0600 | [diff] [blame] | 65 | |
| 66 | upto = data->max_gpio; |
| 67 | data++; |
| 68 | } |
Akshay Saraswat | 1376cdd | 2014-05-13 10:30:14 +0530 | [diff] [blame] | 69 | |
Simon Glass | 9b4e0e8 | 2014-10-20 19:48:40 -0600 | [diff] [blame] | 70 | return NULL; |
Akshay Saraswat | 1376cdd | 2014-05-13 10:30:14 +0530 | [diff] [blame] | 71 | } |
| 72 | |
| 73 | static void s5p_gpio_cfg_pin(struct s5p_gpio_bank *bank, int gpio, int cfg) |
Minkyu Kang | 1edf0f2 | 2010-02-12 18:17:52 +0900 | [diff] [blame] | 74 | { |
| 75 | unsigned int value; |
| 76 | |
| 77 | value = readl(&bank->con); |
| 78 | value &= ~CON_MASK(gpio); |
| 79 | value |= CON_SFR(gpio, cfg); |
| 80 | writel(value, &bank->con); |
| 81 | } |
| 82 | |
Akshay Saraswat | 1376cdd | 2014-05-13 10:30:14 +0530 | [diff] [blame] | 83 | static void s5p_gpio_set_value(struct s5p_gpio_bank *bank, int gpio, int en) |
Minkyu Kang | 1edf0f2 | 2010-02-12 18:17:52 +0900 | [diff] [blame] | 84 | { |
| 85 | unsigned int value; |
| 86 | |
| 87 | value = readl(&bank->dat); |
| 88 | value &= ~DAT_MASK(gpio); |
| 89 | if (en) |
| 90 | value |= DAT_SET(gpio); |
| 91 | writel(value, &bank->dat); |
| 92 | } |
| 93 | |
Simon Glass | 9b4e0e8 | 2014-10-20 19:48:40 -0600 | [diff] [blame] | 94 | #ifdef CONFIG_SPL_BUILD |
| 95 | /* Common GPIO API - SPL does not support driver model yet */ |
| 96 | int gpio_set_value(unsigned gpio, int value) |
Akshay Saraswat | 1376cdd | 2014-05-13 10:30:14 +0530 | [diff] [blame] | 97 | { |
Simon Glass | 9b4e0e8 | 2014-10-20 19:48:40 -0600 | [diff] [blame] | 98 | s5p_gpio_set_value(s5p_gpio_get_bank(gpio), |
| 99 | s5p_gpio_get_pin(gpio), value); |
Akshay Saraswat | 1376cdd | 2014-05-13 10:30:14 +0530 | [diff] [blame] | 100 | |
Simon Glass | 9b4e0e8 | 2014-10-20 19:48:40 -0600 | [diff] [blame] | 101 | return 0; |
| 102 | } |
| 103 | #else |
| 104 | static int s5p_gpio_get_cfg_pin(struct s5p_gpio_bank *bank, int gpio) |
Akshay Saraswat | 1376cdd | 2014-05-13 10:30:14 +0530 | [diff] [blame] | 105 | { |
Simon Glass | 9b4e0e8 | 2014-10-20 19:48:40 -0600 | [diff] [blame] | 106 | unsigned int value; |
| 107 | |
| 108 | value = readl(&bank->con); |
| 109 | value &= CON_MASK(gpio); |
| 110 | return CON_SFR_UNSHIFT(value, gpio); |
Akshay Saraswat | 1376cdd | 2014-05-13 10:30:14 +0530 | [diff] [blame] | 111 | } |
| 112 | |
| 113 | static unsigned int s5p_gpio_get_value(struct s5p_gpio_bank *bank, int gpio) |
Minkyu Kang | 1edf0f2 | 2010-02-12 18:17:52 +0900 | [diff] [blame] | 114 | { |
| 115 | unsigned int value; |
| 116 | |
| 117 | value = readl(&bank->dat); |
| 118 | return !!(value & DAT_MASK(gpio)); |
| 119 | } |
Simon Glass | 9b4e0e8 | 2014-10-20 19:48:40 -0600 | [diff] [blame] | 120 | #endif /* CONFIG_SPL_BUILD */ |
Minkyu Kang | 1edf0f2 | 2010-02-12 18:17:52 +0900 | [diff] [blame] | 121 | |
Akshay Saraswat | 1376cdd | 2014-05-13 10:30:14 +0530 | [diff] [blame] | 122 | static void s5p_gpio_set_pull(struct s5p_gpio_bank *bank, int gpio, int mode) |
Minkyu Kang | 1edf0f2 | 2010-02-12 18:17:52 +0900 | [diff] [blame] | 123 | { |
| 124 | unsigned int value; |
| 125 | |
| 126 | value = readl(&bank->pull); |
| 127 | value &= ~PULL_MASK(gpio); |
| 128 | |
| 129 | switch (mode) { |
Akshay Saraswat | 1376cdd | 2014-05-13 10:30:14 +0530 | [diff] [blame] | 130 | case S5P_GPIO_PULL_DOWN: |
| 131 | case S5P_GPIO_PULL_UP: |
Minkyu Kang | 1edf0f2 | 2010-02-12 18:17:52 +0900 | [diff] [blame] | 132 | value |= PULL_MODE(gpio, mode); |
| 133 | break; |
| 134 | default: |
Minkyu Kang | ced528f | 2010-05-28 12:34:29 +0900 | [diff] [blame] | 135 | break; |
Minkyu Kang | 1edf0f2 | 2010-02-12 18:17:52 +0900 | [diff] [blame] | 136 | } |
| 137 | |
| 138 | writel(value, &bank->pull); |
| 139 | } |
| 140 | |
Akshay Saraswat | 1376cdd | 2014-05-13 10:30:14 +0530 | [diff] [blame] | 141 | static void s5p_gpio_set_drv(struct s5p_gpio_bank *bank, int gpio, int mode) |
Minkyu Kang | 1edf0f2 | 2010-02-12 18:17:52 +0900 | [diff] [blame] | 142 | { |
| 143 | unsigned int value; |
| 144 | |
| 145 | value = readl(&bank->drv); |
| 146 | value &= ~DRV_MASK(gpio); |
| 147 | |
| 148 | switch (mode) { |
Akshay Saraswat | 1376cdd | 2014-05-13 10:30:14 +0530 | [diff] [blame] | 149 | case S5P_GPIO_DRV_1X: |
| 150 | case S5P_GPIO_DRV_2X: |
| 151 | case S5P_GPIO_DRV_3X: |
| 152 | case S5P_GPIO_DRV_4X: |
Minkyu Kang | 1edf0f2 | 2010-02-12 18:17:52 +0900 | [diff] [blame] | 153 | value |= DRV_SET(gpio, mode); |
| 154 | break; |
| 155 | default: |
| 156 | return; |
| 157 | } |
| 158 | |
| 159 | writel(value, &bank->drv); |
| 160 | } |
| 161 | |
Akshay Saraswat | 1376cdd | 2014-05-13 10:30:14 +0530 | [diff] [blame] | 162 | static void s5p_gpio_set_rate(struct s5p_gpio_bank *bank, int gpio, int mode) |
Minkyu Kang | 1edf0f2 | 2010-02-12 18:17:52 +0900 | [diff] [blame] | 163 | { |
| 164 | unsigned int value; |
| 165 | |
| 166 | value = readl(&bank->drv); |
| 167 | value &= ~RATE_MASK(gpio); |
| 168 | |
| 169 | switch (mode) { |
Akshay Saraswat | 1376cdd | 2014-05-13 10:30:14 +0530 | [diff] [blame] | 170 | case S5P_GPIO_DRV_FAST: |
| 171 | case S5P_GPIO_DRV_SLOW: |
Minkyu Kang | 1edf0f2 | 2010-02-12 18:17:52 +0900 | [diff] [blame] | 172 | value |= RATE_SET(gpio); |
| 173 | break; |
| 174 | default: |
| 175 | return; |
| 176 | } |
| 177 | |
| 178 | writel(value, &bank->drv); |
| 179 | } |
Ćukasz Majewski | 1e04cae | 2011-08-22 22:34:58 +0000 | [diff] [blame] | 180 | |
Simon Glass | 9b4e0e8 | 2014-10-20 19:48:40 -0600 | [diff] [blame] | 181 | int s5p_gpio_get_pin(unsigned gpio) |
Ćukasz Majewski | 1e04cae | 2011-08-22 22:34:58 +0000 | [diff] [blame] | 182 | { |
Simon Glass | 9b4e0e8 | 2014-10-20 19:48:40 -0600 | [diff] [blame] | 183 | return S5P_GPIO_GET_PIN(gpio); |
| 184 | } |
Ćukasz Majewski | 1e04cae | 2011-08-22 22:34:58 +0000 | [diff] [blame] | 185 | |
Simon Glass | 9b4e0e8 | 2014-10-20 19:48:40 -0600 | [diff] [blame] | 186 | /* Driver model interface */ |
| 187 | #ifndef CONFIG_SPL_BUILD |
Simon Glass | 9b4e0e8 | 2014-10-20 19:48:40 -0600 | [diff] [blame] | 188 | /* set GPIO pin 'gpio' as an input */ |
| 189 | static int exynos_gpio_direction_input(struct udevice *dev, unsigned offset) |
Ćukasz Majewski | 1e04cae | 2011-08-22 22:34:58 +0000 | [diff] [blame] | 190 | { |
Simon Glass | 9b4e0e8 | 2014-10-20 19:48:40 -0600 | [diff] [blame] | 191 | struct exynos_bank_info *state = dev_get_priv(dev); |
Simon Glass | 9b4e0e8 | 2014-10-20 19:48:40 -0600 | [diff] [blame] | 192 | |
| 193 | /* Configure GPIO direction as input. */ |
| 194 | s5p_gpio_cfg_pin(state->bank, offset, S5P_GPIO_INPUT); |
| 195 | |
Ćukasz Majewski | 1e04cae | 2011-08-22 22:34:58 +0000 | [diff] [blame] | 196 | return 0; |
| 197 | } |
| 198 | |
Simon Glass | 9b4e0e8 | 2014-10-20 19:48:40 -0600 | [diff] [blame] | 199 | /* set GPIO pin 'gpio' as an output, with polarity 'value' */ |
| 200 | static int exynos_gpio_direction_output(struct udevice *dev, unsigned offset, |
| 201 | int value) |
Ćukasz Majewski | 1e04cae | 2011-08-22 22:34:58 +0000 | [diff] [blame] | 202 | { |
Simon Glass | 9b4e0e8 | 2014-10-20 19:48:40 -0600 | [diff] [blame] | 203 | struct exynos_bank_info *state = dev_get_priv(dev); |
Simon Glass | 9b4e0e8 | 2014-10-20 19:48:40 -0600 | [diff] [blame] | 204 | |
| 205 | /* Configure GPIO output value. */ |
| 206 | s5p_gpio_set_value(state->bank, offset, value); |
| 207 | |
| 208 | /* Configure GPIO direction as output. */ |
| 209 | s5p_gpio_cfg_pin(state->bank, offset, S5P_GPIO_OUTPUT); |
| 210 | |
Ćukasz Majewski | 1e04cae | 2011-08-22 22:34:58 +0000 | [diff] [blame] | 211 | return 0; |
| 212 | } |
| 213 | |
Simon Glass | 9b4e0e8 | 2014-10-20 19:48:40 -0600 | [diff] [blame] | 214 | /* read GPIO IN value of pin 'gpio' */ |
| 215 | static int exynos_gpio_get_value(struct udevice *dev, unsigned offset) |
| 216 | { |
| 217 | struct exynos_bank_info *state = dev_get_priv(dev); |
Simon Glass | 9b4e0e8 | 2014-10-20 19:48:40 -0600 | [diff] [blame] | 218 | |
| 219 | return s5p_gpio_get_value(state->bank, offset); |
| 220 | } |
| 221 | |
| 222 | /* write GPIO OUT value to pin 'gpio' */ |
| 223 | static int exynos_gpio_set_value(struct udevice *dev, unsigned offset, |
| 224 | int value) |
Ćukasz Majewski | 1e04cae | 2011-08-22 22:34:58 +0000 | [diff] [blame] | 225 | { |
Simon Glass | 9b4e0e8 | 2014-10-20 19:48:40 -0600 | [diff] [blame] | 226 | struct exynos_bank_info *state = dev_get_priv(dev); |
Simon Glass | 9b4e0e8 | 2014-10-20 19:48:40 -0600 | [diff] [blame] | 227 | |
| 228 | s5p_gpio_set_value(state->bank, offset, value); |
| 229 | |
Joe Hershberger | f8928f1 | 2011-11-11 15:55:36 -0600 | [diff] [blame] | 230 | return 0; |
Ćukasz Majewski | 1e04cae | 2011-08-22 22:34:58 +0000 | [diff] [blame] | 231 | } |
Simon Glass | 9b4e0e8 | 2014-10-20 19:48:40 -0600 | [diff] [blame] | 232 | #endif /* nCONFIG_SPL_BUILD */ |
Akshay Saraswat | 1376cdd | 2014-05-13 10:30:14 +0530 | [diff] [blame] | 233 | |
Simon Glass | 9b4e0e8 | 2014-10-20 19:48:40 -0600 | [diff] [blame] | 234 | /* |
| 235 | * There is no common GPIO API for pull, drv, pin, rate (yet). These |
| 236 | * functions are kept here to preserve function ordering for review. |
| 237 | */ |
Akshay Saraswat | 1376cdd | 2014-05-13 10:30:14 +0530 | [diff] [blame] | 238 | void gpio_set_pull(int gpio, int mode) |
| 239 | { |
| 240 | s5p_gpio_set_pull(s5p_gpio_get_bank(gpio), |
| 241 | s5p_gpio_get_pin(gpio), mode); |
| 242 | } |
| 243 | |
| 244 | void gpio_set_drv(int gpio, int mode) |
| 245 | { |
| 246 | s5p_gpio_set_drv(s5p_gpio_get_bank(gpio), |
| 247 | s5p_gpio_get_pin(gpio), mode); |
| 248 | } |
| 249 | |
| 250 | void gpio_cfg_pin(int gpio, int cfg) |
| 251 | { |
| 252 | s5p_gpio_cfg_pin(s5p_gpio_get_bank(gpio), |
| 253 | s5p_gpio_get_pin(gpio), cfg); |
| 254 | } |
| 255 | |
| 256 | void gpio_set_rate(int gpio, int mode) |
| 257 | { |
| 258 | s5p_gpio_set_rate(s5p_gpio_get_bank(gpio), |
| 259 | s5p_gpio_get_pin(gpio), mode); |
| 260 | } |
Simon Glass | 9b4e0e8 | 2014-10-20 19:48:40 -0600 | [diff] [blame] | 261 | |
| 262 | #ifndef CONFIG_SPL_BUILD |
| 263 | static int exynos_gpio_get_function(struct udevice *dev, unsigned offset) |
| 264 | { |
| 265 | struct exynos_bank_info *state = dev_get_priv(dev); |
| 266 | int cfg; |
| 267 | |
Simon Glass | 9b4e0e8 | 2014-10-20 19:48:40 -0600 | [diff] [blame] | 268 | cfg = s5p_gpio_get_cfg_pin(state->bank, offset); |
| 269 | if (cfg == S5P_GPIO_OUTPUT) |
| 270 | return GPIOF_OUTPUT; |
| 271 | else if (cfg == S5P_GPIO_INPUT) |
| 272 | return GPIOF_INPUT; |
| 273 | else |
| 274 | return GPIOF_FUNC; |
| 275 | } |
| 276 | |
| 277 | static const struct dm_gpio_ops gpio_exynos_ops = { |
Simon Glass | 9b4e0e8 | 2014-10-20 19:48:40 -0600 | [diff] [blame] | 278 | .direction_input = exynos_gpio_direction_input, |
| 279 | .direction_output = exynos_gpio_direction_output, |
| 280 | .get_value = exynos_gpio_get_value, |
| 281 | .set_value = exynos_gpio_set_value, |
| 282 | .get_function = exynos_gpio_get_function, |
Simon Glass | 9b4e0e8 | 2014-10-20 19:48:40 -0600 | [diff] [blame] | 283 | }; |
| 284 | |
| 285 | static int gpio_exynos_probe(struct udevice *dev) |
| 286 | { |
Simon Glass | de0977b | 2015-03-05 12:25:20 -0700 | [diff] [blame] | 287 | struct gpio_dev_priv *uc_priv = dev_get_uclass_priv(dev); |
Simon Glass | 9b4e0e8 | 2014-10-20 19:48:40 -0600 | [diff] [blame] | 288 | struct exynos_bank_info *priv = dev->priv; |
| 289 | struct exynos_gpio_platdata *plat = dev->platdata; |
| 290 | |
| 291 | /* Only child devices have ports */ |
| 292 | if (!plat) |
| 293 | return 0; |
| 294 | |
| 295 | priv->bank = plat->bank; |
| 296 | |
| 297 | uc_priv->gpio_count = GPIO_PER_BANK; |
| 298 | uc_priv->bank_name = plat->bank_name; |
| 299 | |
| 300 | return 0; |
| 301 | } |
| 302 | |
| 303 | /** |
| 304 | * We have a top-level GPIO device with no actual GPIOs. It has a child |
| 305 | * device for each Exynos GPIO bank. |
| 306 | */ |
| 307 | static int gpio_exynos_bind(struct udevice *parent) |
| 308 | { |
| 309 | struct exynos_gpio_platdata *plat = parent->platdata; |
| 310 | struct s5p_gpio_bank *bank, *base; |
| 311 | const void *blob = gd->fdt_blob; |
| 312 | int node; |
| 313 | |
| 314 | /* If this is a child device, there is nothing to do here */ |
| 315 | if (plat) |
| 316 | return 0; |
| 317 | |
Simon Glass | ba1dea4 | 2017-05-17 17:18:05 -0600 | [diff] [blame] | 318 | base = (struct s5p_gpio_bank *)devfdt_get_addr(parent); |
Simon Glass | dd79d6e | 2017-01-17 16:52:55 -0700 | [diff] [blame] | 319 | for (node = fdt_first_subnode(blob, dev_of_offset(parent)), bank = base; |
Simon Glass | 9b4e0e8 | 2014-10-20 19:48:40 -0600 | [diff] [blame] | 320 | node > 0; |
| 321 | node = fdt_next_subnode(blob, node), bank++) { |
| 322 | struct exynos_gpio_platdata *plat; |
| 323 | struct udevice *dev; |
| 324 | fdt_addr_t reg; |
| 325 | int ret; |
| 326 | |
| 327 | if (!fdtdec_get_bool(blob, node, "gpio-controller")) |
| 328 | continue; |
| 329 | plat = calloc(1, sizeof(*plat)); |
| 330 | if (!plat) |
| 331 | return -ENOMEM; |
Simon Glass | 9b4e0e8 | 2014-10-20 19:48:40 -0600 | [diff] [blame] | 332 | |
Przemyslaw Marczak | 85ed2b4 | 2015-09-30 13:14:51 +0200 | [diff] [blame] | 333 | plat->bank_name = fdt_get_name(blob, node, NULL); |
Simon Glass | 9b4e0e8 | 2014-10-20 19:48:40 -0600 | [diff] [blame] | 334 | ret = device_bind(parent, parent->driver, |
Przemyslaw Marczak | 85ed2b4 | 2015-09-30 13:14:51 +0200 | [diff] [blame] | 335 | plat->bank_name, plat, -1, &dev); |
Simon Glass | 9b4e0e8 | 2014-10-20 19:48:40 -0600 | [diff] [blame] | 336 | if (ret) |
| 337 | return ret; |
Przemyslaw Marczak | 85ed2b4 | 2015-09-30 13:14:51 +0200 | [diff] [blame] | 338 | |
Simon Glass | dd79d6e | 2017-01-17 16:52:55 -0700 | [diff] [blame] | 339 | dev_set_of_offset(dev, node); |
Przemyslaw Marczak | 85ed2b4 | 2015-09-30 13:14:51 +0200 | [diff] [blame] | 340 | |
Simon Glass | ba1dea4 | 2017-05-17 17:18:05 -0600 | [diff] [blame] | 341 | reg = devfdt_get_addr(dev); |
Przemyslaw Marczak | 85ed2b4 | 2015-09-30 13:14:51 +0200 | [diff] [blame] | 342 | if (reg != FDT_ADDR_T_NONE) |
| 343 | bank = (struct s5p_gpio_bank *)((ulong)base + reg); |
| 344 | |
| 345 | plat->bank = bank; |
| 346 | |
| 347 | debug("dev at %p: %s\n", bank, plat->bank_name); |
Simon Glass | 9b4e0e8 | 2014-10-20 19:48:40 -0600 | [diff] [blame] | 348 | } |
| 349 | |
| 350 | return 0; |
| 351 | } |
| 352 | |
| 353 | static const struct udevice_id exynos_gpio_ids[] = { |
| 354 | { .compatible = "samsung,s5pc100-pinctrl" }, |
| 355 | { .compatible = "samsung,s5pc110-pinctrl" }, |
| 356 | { .compatible = "samsung,exynos4210-pinctrl" }, |
| 357 | { .compatible = "samsung,exynos4x12-pinctrl" }, |
| 358 | { .compatible = "samsung,exynos5250-pinctrl" }, |
| 359 | { .compatible = "samsung,exynos5420-pinctrl" }, |
| 360 | { } |
| 361 | }; |
| 362 | |
| 363 | U_BOOT_DRIVER(gpio_exynos) = { |
| 364 | .name = "gpio_exynos", |
| 365 | .id = UCLASS_GPIO, |
| 366 | .of_match = exynos_gpio_ids, |
| 367 | .bind = gpio_exynos_bind, |
| 368 | .probe = gpio_exynos_probe, |
| 369 | .priv_auto_alloc_size = sizeof(struct exynos_bank_info), |
| 370 | .ops = &gpio_exynos_ops, |
| 371 | }; |
| 372 | #endif |