Blame view
drivers/pinctrl/pinctrl-at91.c
51.7 KB
28b665f6b treewide: Replace... |
1 |
// SPDX-License-Identifier: GPL-2.0-only |
6732ae5cb ARM: at91: add pi... |
2 3 4 5 |
/* * at91 pinctrl driver based on at91 pinmux core * * Copyright (C) 2011-2012 Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com> |
6732ae5cb ARM: at91: add pi... |
6 7 8 9 10 |
*/ #include <linux/clk.h> #include <linux/err.h> #include <linux/init.h> |
6732ae5cb ARM: at91: add pi... |
11 12 13 14 15 16 |
#include <linux/of.h> #include <linux/of_device.h> #include <linux/of_address.h> #include <linux/of_irq.h> #include <linux/slab.h> #include <linux/interrupt.h> |
6732ae5cb ARM: at91: add pi... |
17 |
#include <linux/io.h> |
1c5fb66af pinctrl: Include ... |
18 |
#include <linux/gpio/driver.h> |
6732ae5cb ARM: at91: add pi... |
19 20 21 22 23 24 |
#include <linux/pinctrl/machine.h> #include <linux/pinctrl/pinconf.h> #include <linux/pinctrl/pinctrl.h> #include <linux/pinctrl/pinmux.h> /* Since we request GPIOs from ourself */ #include <linux/pinctrl/consumer.h> |
c654b6bf2 pinctrl: at91: us... |
25 |
#include "pinctrl-at91.h" |
6732ae5cb ARM: at91: add pi... |
26 |
#include "core.h" |
94daf85e3 pinctrl: at91: co... |
27 |
#define MAX_GPIO_BANKS 5 |
6732ae5cb ARM: at91: add pi... |
28 29 30 31 32 33 34 35 36 37 38 39 40 |
#define MAX_NB_GPIO_PER_BANK 32 struct at91_pinctrl_mux_ops; struct at91_gpio_chip { struct gpio_chip chip; struct pinctrl_gpio_range range; struct at91_gpio_chip *next; /* Bank sharing same clock */ int pioc_hwirq; /* PIO bank interrupt identifier on AIC */ int pioc_virq; /* PIO bank Linux virtual interrupt */ int pioc_idx; /* PIO bank index */ void __iomem *regbase; /* PIO bank virtual address */ struct clk *clock; /* associated clock */ |
6732ae5cb ARM: at91: add pi... |
41 42 |
struct at91_pinctrl_mux_ops *ops; /* ops */ }; |
6732ae5cb ARM: at91: add pi... |
43 44 45 |
static struct at91_gpio_chip *gpio_chips[MAX_GPIO_BANKS]; static int gpio_banks; |
525fae213 pinctrl: at91: fi... |
46 |
#define PULL_UP (1 << 0) |
6732ae5cb ARM: at91: add pi... |
47 |
#define MULTI_DRIVE (1 << 1) |
7ebd7a3ae pinctrl: at91 add... |
48 49 50 |
#define DEGLITCH (1 << 2) #define PULL_DOWN (1 << 3) #define DIS_SCHMIT (1 << 4) |
4334ac2db pinctrl: at91: ad... |
51 52 53 |
#define DRIVE_STRENGTH_SHIFT 5 #define DRIVE_STRENGTH_MASK 0x3 #define DRIVE_STRENGTH (DRIVE_STRENGTH_MASK << DRIVE_STRENGTH_SHIFT) |
96bb12dea pinctrl: at91: ad... |
54 55 56 |
#define OUTPUT (1 << 7) #define OUTPUT_VAL_SHIFT 8 #define OUTPUT_VAL (0x1 << OUTPUT_VAL_SHIFT) |
64e21add8 pinctrl: at91: ad... |
57 58 59 |
#define SLEWRATE_SHIFT 9 #define SLEWRATE_MASK 0x1 #define SLEWRATE (SLEWRATE_MASK << SLEWRATE_SHIFT) |
7ebd7a3ae pinctrl: at91 add... |
60 61 62 |
#define DEBOUNCE (1 << 16) #define DEBOUNCE_VAL_SHIFT 17 #define DEBOUNCE_VAL (0x3fff << DEBOUNCE_VAL_SHIFT) |
6732ae5cb ARM: at91: add pi... |
63 |
|
aa78655d4 pinctrl: pinctrl-... |
64 |
/* |
4334ac2db pinctrl: at91: ad... |
65 66 67 68 69 70 71 72 |
* These defines will translated the dt binding settings to our internal * settings. They are not necessarily the same value as the register setting. * The actual drive strength current of low, medium and high must be looked up * from the corresponding device datasheet. This value is different for pins * that are even in the same banks. It is also dependent on VCC. * DRIVE_STRENGTH_DEFAULT is just a placeholder to avoid changing the drive * strength when there is no dt config for it. */ |
b67328e1c pinctrl: at91: ad... |
73 74 75 76 77 78 79 80 81 |
enum drive_strength_bit { DRIVE_STRENGTH_BIT_DEF, DRIVE_STRENGTH_BIT_LOW, DRIVE_STRENGTH_BIT_MED, DRIVE_STRENGTH_BIT_HI, }; #define DRIVE_STRENGTH_BIT_MSK(name) (DRIVE_STRENGTH_BIT_##name << \ DRIVE_STRENGTH_SHIFT) |
4334ac2db pinctrl: at91: ad... |
82 |
|
64e21add8 pinctrl: at91: ad... |
83 |
enum slewrate_bit { |
64e21add8 pinctrl: at91: ad... |
84 |
SLEWRATE_BIT_ENA, |
0b3292852 pinctrl: at91: En... |
85 |
SLEWRATE_BIT_DIS, |
64e21add8 pinctrl: at91: ad... |
86 87 88 |
}; #define SLEWRATE_BIT_MSK(name) (SLEWRATE_BIT_##name << SLEWRATE_SHIFT) |
4334ac2db pinctrl: at91: ad... |
89 |
/** |
6732ae5cb ARM: at91: add pi... |
90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 |
* struct at91_pmx_func - describes AT91 pinmux functions * @name: the name of this specific function * @groups: corresponding pin groups * @ngroups: the number of groups */ struct at91_pmx_func { const char *name; const char **groups; unsigned ngroups; }; enum at91_mux { AT91_MUX_GPIO = 0, AT91_MUX_PERIPH_A = 1, AT91_MUX_PERIPH_B = 2, AT91_MUX_PERIPH_C = 3, AT91_MUX_PERIPH_D = 4, }; /** * struct at91_pmx_pin - describes an At91 pin mux * @bank: the bank of the pin * @pin: the pin number in the @bank * @mux: the mux mode : gpio or periph_x of the pin i.e. alternate function. * @conf: the configuration of the pin: PULL_UP, MULTIDRIVE etc... */ struct at91_pmx_pin { uint32_t bank; uint32_t pin; enum at91_mux mux; unsigned long conf; }; /** * struct at91_pin_group - describes an At91 pin group * @name: the name of this specific pin group * @pins_conf: the mux mode for each pin in this group. The size of this * array is the same as pins. * @pins: an array of discrete physical pins used in this group, taken * from the driver-local pin enumeration space * @npins: the number of pins in this group array, i.e. the number of * elements in .pins so we can iterate over that array */ struct at91_pin_group { const char *name; struct at91_pmx_pin *pins_conf; unsigned int *pins; unsigned npins; }; /** |
c2eb9e7f0 pinctrl: at91: co... |
141 |
* struct at91_pinctrl_mux_ops - describes an AT91 mux ops group |
6732ae5cb ARM: at91: add pi... |
142 143 144 145 146 147 148 149 150 |
* on new IP with support for periph C and D the way to mux in * periph A and B has changed * So provide the right call back * if not present means the IP does not support it * @get_periph: return the periph mode configured * @mux_A_periph: mux as periph A * @mux_B_periph: mux as periph B * @mux_C_periph: mux as periph C * @mux_D_periph: mux as periph D |
7ebd7a3ae pinctrl: at91 add... |
151 152 153 154 155 156 157 158 |
* @get_deglitch: get deglitch status * @set_deglitch: enable/disable deglitch * @get_debounce: get debounce status * @set_debounce: enable/disable debounce * @get_pulldown: get pulldown status * @set_pulldown: enable/disable pulldown * @get_schmitt_trig: get schmitt trigger status * @disable_schmitt_trig: disable schmitt trigger |
aa78655d4 pinctrl: pinctrl-... |
159 160 161 162 |
* @get_drivestrength: get driver strength * @set_drivestrength: set driver strength * @get_slewrate: get slew rate * @set_slewrate: set slew rate |
6732ae5cb ARM: at91: add pi... |
163 164 165 166 167 168 169 170 |
* @irq_type: return irq type */ struct at91_pinctrl_mux_ops { enum at91_mux (*get_periph)(void __iomem *pio, unsigned mask); void (*mux_A_periph)(void __iomem *pio, unsigned mask); void (*mux_B_periph)(void __iomem *pio, unsigned mask); void (*mux_C_periph)(void __iomem *pio, unsigned mask); void (*mux_D_periph)(void __iomem *pio, unsigned mask); |
7ebd7a3ae pinctrl: at91 add... |
171 |
bool (*get_deglitch)(void __iomem *pio, unsigned pin); |
77966ad7b pinctrl: at91: fi... |
172 |
void (*set_deglitch)(void __iomem *pio, unsigned mask, bool is_on); |
7ebd7a3ae pinctrl: at91 add... |
173 |
bool (*get_debounce)(void __iomem *pio, unsigned pin, u32 *div); |
77966ad7b pinctrl: at91: fi... |
174 |
void (*set_debounce)(void __iomem *pio, unsigned mask, bool is_on, u32 div); |
7ebd7a3ae pinctrl: at91 add... |
175 |
bool (*get_pulldown)(void __iomem *pio, unsigned pin); |
77966ad7b pinctrl: at91: fi... |
176 |
void (*set_pulldown)(void __iomem *pio, unsigned mask, bool is_on); |
7ebd7a3ae pinctrl: at91 add... |
177 178 |
bool (*get_schmitt_trig)(void __iomem *pio, unsigned pin); void (*disable_schmitt_trig)(void __iomem *pio, unsigned mask); |
4334ac2db pinctrl: at91: ad... |
179 180 181 |
unsigned (*get_drivestrength)(void __iomem *pio, unsigned pin); void (*set_drivestrength)(void __iomem *pio, unsigned pin, u32 strength); |
64e21add8 pinctrl: at91: ad... |
182 183 |
unsigned (*get_slewrate)(void __iomem *pio, unsigned pin); void (*set_slewrate)(void __iomem *pio, unsigned pin, u32 slewrate); |
6732ae5cb ARM: at91: add pi... |
184 185 186 187 188 189 190 191 192 193 |
/* irq */ int (*irq_type)(struct irq_data *d, unsigned type); }; static int gpio_irq_type(struct irq_data *d, unsigned type); static int alt_gpio_irq_type(struct irq_data *d, unsigned type); struct at91_pinctrl { struct device *dev; struct pinctrl_dev *pctl; |
a0b957f30 pinctrl: at91: al... |
194 |
int nactive_banks; |
6732ae5cb ARM: at91: add pi... |
195 196 197 198 199 200 201 202 203 204 205 206 |
uint32_t *mux_mask; int nmux; struct at91_pmx_func *functions; int nfunctions; struct at91_pin_group *groups; int ngroups; struct at91_pinctrl_mux_ops *ops; }; |
56411f3c0 pinctrl: fix inco... |
207 |
static inline const struct at91_pin_group *at91_pinctrl_find_group_by_name( |
6732ae5cb ARM: at91: add pi... |
208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 |
const struct at91_pinctrl *info, const char *name) { const struct at91_pin_group *grp = NULL; int i; for (i = 0; i < info->ngroups; i++) { if (strcmp(info->groups[i].name, name)) continue; grp = &info->groups[i]; dev_dbg(info->dev, "%s: %d 0:%d ", name, grp->npins, grp->pins[0]); break; } return grp; } static int at91_get_groups_count(struct pinctrl_dev *pctldev) { struct at91_pinctrl *info = pinctrl_dev_get_drvdata(pctldev); return info->ngroups; } static const char *at91_get_group_name(struct pinctrl_dev *pctldev, unsigned selector) { struct at91_pinctrl *info = pinctrl_dev_get_drvdata(pctldev); return info->groups[selector].name; } static int at91_get_group_pins(struct pinctrl_dev *pctldev, unsigned selector, const unsigned **pins, unsigned *npins) { struct at91_pinctrl *info = pinctrl_dev_get_drvdata(pctldev); if (selector >= info->ngroups) return -EINVAL; *pins = info->groups[selector].pins; *npins = info->groups[selector].npins; return 0; } static void at91_pin_dbg_show(struct pinctrl_dev *pctldev, struct seq_file *s, unsigned offset) { seq_printf(s, "%s", dev_name(pctldev->dev)); } static int at91_dt_node_to_map(struct pinctrl_dev *pctldev, struct device_node *np, struct pinctrl_map **map, unsigned *num_maps) { struct at91_pinctrl *info = pinctrl_dev_get_drvdata(pctldev); const struct at91_pin_group *grp; struct pinctrl_map *new_map; struct device_node *parent; int map_num = 1; int i; |
6732ae5cb ARM: at91: add pi... |
273 274 |
/* |
61e310a1e pinctrl: at91: co... |
275 |
* first find the group of this node and check if we need to create |
6732ae5cb ARM: at91: add pi... |
276 277 278 279 |
* config maps for pins */ grp = at91_pinctrl_find_group_by_name(info, np->name); if (!grp) { |
94f4e54ce pinctrl: Convert ... |
280 281 282 |
dev_err(info->dev, "unable to find group for node %pOFn ", np); |
6732ae5cb ARM: at91: add pi... |
283 284 285 286 |
return -EINVAL; } map_num += grp->npins; |
a86854d0c treewide: devm_kz... |
287 288 |
new_map = devm_kcalloc(pctldev->dev, map_num, sizeof(*new_map), GFP_KERNEL); |
6732ae5cb ARM: at91: add pi... |
289 290 291 292 293 294 295 296 297 |
if (!new_map) return -ENOMEM; *map = new_map; *num_maps = map_num; /* create mux map */ parent = of_get_parent(np); if (!parent) { |
c62b2b344 drivers/pinctrl/p... |
298 |
devm_kfree(pctldev->dev, new_map); |
6732ae5cb ARM: at91: add pi... |
299 300 301 302 303 304 305 306 307 308 |
return -EINVAL; } new_map[0].type = PIN_MAP_TYPE_MUX_GROUP; new_map[0].data.mux.function = parent->name; new_map[0].data.mux.group = np->name; of_node_put(parent); /* create config map */ new_map++; for (i = 0; i < grp->npins; i++) { |
6732ae5cb ARM: at91: add pi... |
309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 |
new_map[i].type = PIN_MAP_TYPE_CONFIGS_PIN; new_map[i].data.configs.group_or_pin = pin_get_name(pctldev, grp->pins[i]); new_map[i].data.configs.configs = &grp->pins_conf[i].conf; new_map[i].data.configs.num_configs = 1; } dev_dbg(pctldev->dev, "maps: function %s group %s num %d ", (*map)->data.mux.function, (*map)->data.mux.group, map_num); return 0; } static void at91_dt_free_map(struct pinctrl_dev *pctldev, struct pinctrl_map *map, unsigned num_maps) { } |
022ab148d pinctrl: Declare ... |
327 |
static const struct pinctrl_ops at91_pctrl_ops = { |
6732ae5cb ARM: at91: add pi... |
328 329 330 331 332 333 334 |
.get_groups_count = at91_get_groups_count, .get_group_name = at91_get_group_name, .get_group_pins = at91_get_group_pins, .pin_dbg_show = at91_pin_dbg_show, .dt_node_to_map = at91_dt_node_to_map, .dt_free_map = at91_dt_free_map, }; |
3c93600d3 pinctrl: at91: Fi... |
335 |
static void __iomem *pin_to_controller(struct at91_pinctrl *info, |
6732ae5cb ARM: at91: add pi... |
336 337 |
unsigned int bank) { |
1ab36387e pinctrl: at91: fi... |
338 339 |
if (!gpio_chips[bank]) return NULL; |
6732ae5cb ARM: at91: add pi... |
340 341 342 343 344 345 346 347 348 349 350 351 |
return gpio_chips[bank]->regbase; } static inline int pin_to_bank(unsigned pin) { return pin /= MAX_NB_GPIO_PER_BANK; } static unsigned pin_to_mask(unsigned int pin) { return 1 << pin; } |
4334ac2db pinctrl: at91: ad... |
352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 |
static unsigned two_bit_pin_value_shift_amount(unsigned int pin) { /* return the shift value for a pin for "two bit" per pin registers, * i.e. drive strength */ return 2*((pin >= MAX_NB_GPIO_PER_BANK/2) ? pin - MAX_NB_GPIO_PER_BANK/2 : pin); } static unsigned sama5d3_get_drive_register(unsigned int pin) { /* drive strength is split between two registers * with two bits per pin */ return (pin >= MAX_NB_GPIO_PER_BANK/2) ? SAMA5D3_PIO_DRIVER2 : SAMA5D3_PIO_DRIVER1; } static unsigned at91sam9x5_get_drive_register(unsigned int pin) { /* drive strength is split between two registers * with two bits per pin */ return (pin >= MAX_NB_GPIO_PER_BANK/2) ? AT91SAM9X5_PIO_DRIVER2 : AT91SAM9X5_PIO_DRIVER1; } |
6732ae5cb ARM: at91: add pi... |
375 376 377 378 379 380 381 |
static void at91_mux_disable_interrupt(void __iomem *pio, unsigned mask) { writel_relaxed(mask, pio + PIO_IDR); } static unsigned at91_mux_get_pullup(void __iomem *pio, unsigned pin) { |
05d3534a3 pinctrl: at91: fi... |
382 |
return !((readl_relaxed(pio + PIO_PUSR) >> pin) & 0x1); |
6732ae5cb ARM: at91: add pi... |
383 384 385 386 |
} static void at91_mux_set_pullup(void __iomem *pio, unsigned mask, bool on) { |
3d7842739 pinctrl: at91: di... |
387 388 |
if (on) writel_relaxed(mask, pio + PIO_PPDDR); |
6732ae5cb ARM: at91: add pi... |
389 390 |
writel_relaxed(mask, pio + (on ? PIO_PUER : PIO_PUDR)); } |
96bb12dea pinctrl: at91: ad... |
391 392 393 394 395 396 397 398 399 400 401 402 |
static bool at91_mux_get_output(void __iomem *pio, unsigned int pin, bool *val) { *val = (readl_relaxed(pio + PIO_ODSR) >> pin) & 0x1; return (readl_relaxed(pio + PIO_OSR) >> pin) & 0x1; } static void at91_mux_set_output(void __iomem *pio, unsigned int mask, bool is_on, bool val) { writel_relaxed(mask, pio + (val ? PIO_SODR : PIO_CODR)); writel_relaxed(mask, pio + (is_on ? PIO_OER : PIO_ODR)); } |
6732ae5cb ARM: at91: add pi... |
403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 |
static unsigned at91_mux_get_multidrive(void __iomem *pio, unsigned pin) { return (readl_relaxed(pio + PIO_MDSR) >> pin) & 0x1; } static void at91_mux_set_multidrive(void __iomem *pio, unsigned mask, bool on) { writel_relaxed(mask, pio + (on ? PIO_MDER : PIO_MDDR)); } static void at91_mux_set_A_periph(void __iomem *pio, unsigned mask) { writel_relaxed(mask, pio + PIO_ASR); } static void at91_mux_set_B_periph(void __iomem *pio, unsigned mask) { writel_relaxed(mask, pio + PIO_BSR); } static void at91_mux_pio3_set_A_periph(void __iomem *pio, unsigned mask) { writel_relaxed(readl_relaxed(pio + PIO_ABCDSR1) & ~mask, pio + PIO_ABCDSR1); writel_relaxed(readl_relaxed(pio + PIO_ABCDSR2) & ~mask, pio + PIO_ABCDSR2); } static void at91_mux_pio3_set_B_periph(void __iomem *pio, unsigned mask) { writel_relaxed(readl_relaxed(pio + PIO_ABCDSR1) | mask, pio + PIO_ABCDSR1); writel_relaxed(readl_relaxed(pio + PIO_ABCDSR2) & ~mask, pio + PIO_ABCDSR2); } static void at91_mux_pio3_set_C_periph(void __iomem *pio, unsigned mask) { writel_relaxed(readl_relaxed(pio + PIO_ABCDSR1) & ~mask, pio + PIO_ABCDSR1); writel_relaxed(readl_relaxed(pio + PIO_ABCDSR2) | mask, pio + PIO_ABCDSR2); } static void at91_mux_pio3_set_D_periph(void __iomem *pio, unsigned mask) { writel_relaxed(readl_relaxed(pio + PIO_ABCDSR1) | mask, pio + PIO_ABCDSR1); writel_relaxed(readl_relaxed(pio + PIO_ABCDSR2) | mask, pio + PIO_ABCDSR2); } static enum at91_mux at91_mux_pio3_get_periph(void __iomem *pio, unsigned mask) { unsigned select; if (readl_relaxed(pio + PIO_PSR) & mask) return AT91_MUX_GPIO; select = !!(readl_relaxed(pio + PIO_ABCDSR1) & mask); select |= (!!(readl_relaxed(pio + PIO_ABCDSR2) & mask) << 1); return select + 1; } static enum at91_mux at91_mux_get_periph(void __iomem *pio, unsigned mask) { unsigned select; if (readl_relaxed(pio + PIO_PSR) & mask) return AT91_MUX_GPIO; select = readl_relaxed(pio + PIO_ABSR) & mask; return select + 1; } |
7ebd7a3ae pinctrl: at91 add... |
476 477 |
static bool at91_mux_get_deglitch(void __iomem *pio, unsigned pin) { |
d480239ba pinctrl: at91: co... |
478 |
return (readl_relaxed(pio + PIO_IFSR) >> pin) & 0x1; |
7ebd7a3ae pinctrl: at91 add... |
479 480 481 482 |
} static void at91_mux_set_deglitch(void __iomem *pio, unsigned mask, bool is_on) { |
d480239ba pinctrl: at91: co... |
483 |
writel_relaxed(mask, pio + (is_on ? PIO_IFER : PIO_IFDR)); |
7ebd7a3ae pinctrl: at91 add... |
484 |
} |
c8dba02e7 pinctrl: at91: fi... |
485 486 |
static bool at91_mux_pio3_get_deglitch(void __iomem *pio, unsigned pin) { |
d480239ba pinctrl: at91: co... |
487 488 |
if ((readl_relaxed(pio + PIO_IFSR) >> pin) & 0x1) return !((readl_relaxed(pio + PIO_IFSCSR) >> pin) & 0x1); |
c8dba02e7 pinctrl: at91: fi... |
489 490 491 |
return false; } |
7ebd7a3ae pinctrl: at91 add... |
492 493 494 |
static void at91_mux_pio3_set_deglitch(void __iomem *pio, unsigned mask, bool is_on) { if (is_on) |
d480239ba pinctrl: at91: co... |
495 |
writel_relaxed(mask, pio + PIO_IFSCDR); |
7ebd7a3ae pinctrl: at91 add... |
496 497 498 499 500 |
at91_mux_set_deglitch(pio, mask, is_on); } static bool at91_mux_pio3_get_debounce(void __iomem *pio, unsigned pin, u32 *div) { |
d480239ba pinctrl: at91: co... |
501 |
*div = readl_relaxed(pio + PIO_SCDR); |
7ebd7a3ae pinctrl: at91 add... |
502 |
|
d480239ba pinctrl: at91: co... |
503 504 |
return ((readl_relaxed(pio + PIO_IFSR) >> pin) & 0x1) && ((readl_relaxed(pio + PIO_IFSCSR) >> pin) & 0x1); |
7ebd7a3ae pinctrl: at91 add... |
505 506 507 508 509 510 |
} static void at91_mux_pio3_set_debounce(void __iomem *pio, unsigned mask, bool is_on, u32 div) { if (is_on) { |
d480239ba pinctrl: at91: co... |
511 512 513 |
writel_relaxed(mask, pio + PIO_IFSCER); writel_relaxed(div & PIO_SCDR_DIV, pio + PIO_SCDR); writel_relaxed(mask, pio + PIO_IFER); |
c8dba02e7 pinctrl: at91: fi... |
514 |
} else |
d480239ba pinctrl: at91: co... |
515 |
writel_relaxed(mask, pio + PIO_IFSCDR); |
7ebd7a3ae pinctrl: at91 add... |
516 517 518 519 |
} static bool at91_mux_pio3_get_pulldown(void __iomem *pio, unsigned pin) { |
d480239ba pinctrl: at91: co... |
520 |
return !((readl_relaxed(pio + PIO_PPDSR) >> pin) & 0x1); |
7ebd7a3ae pinctrl: at91 add... |
521 522 523 524 |
} static void at91_mux_pio3_set_pulldown(void __iomem *pio, unsigned mask, bool is_on) { |
3d7842739 pinctrl: at91: di... |
525 |
if (is_on) |
d480239ba pinctrl: at91: co... |
526 |
writel_relaxed(mask, pio + PIO_PUDR); |
3d7842739 pinctrl: at91: di... |
527 |
|
d480239ba pinctrl: at91: co... |
528 |
writel_relaxed(mask, pio + (is_on ? PIO_PPDER : PIO_PPDDR)); |
7ebd7a3ae pinctrl: at91 add... |
529 530 531 532 |
} static void at91_mux_pio3_disable_schmitt_trig(void __iomem *pio, unsigned mask) { |
d480239ba pinctrl: at91: co... |
533 |
writel_relaxed(readl_relaxed(pio + PIO_SCHMITT) | mask, pio + PIO_SCHMITT); |
7ebd7a3ae pinctrl: at91 add... |
534 535 536 537 |
} static bool at91_mux_pio3_get_schmitt_trig(void __iomem *pio, unsigned pin) { |
d480239ba pinctrl: at91: co... |
538 |
return (readl_relaxed(pio + PIO_SCHMITT) >> pin) & 0x1; |
7ebd7a3ae pinctrl: at91 add... |
539 |
} |
4334ac2db pinctrl: at91: ad... |
540 541 |
static inline u32 read_drive_strength(void __iomem *reg, unsigned pin) { |
d480239ba pinctrl: at91: co... |
542 |
unsigned tmp = readl_relaxed(reg); |
4334ac2db pinctrl: at91: ad... |
543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 |
tmp = tmp >> two_bit_pin_value_shift_amount(pin); return tmp & DRIVE_STRENGTH_MASK; } static unsigned at91_mux_sama5d3_get_drivestrength(void __iomem *pio, unsigned pin) { unsigned tmp = read_drive_strength(pio + sama5d3_get_drive_register(pin), pin); /* SAMA5 strength is 1:1 with our defines, * except 0 is equivalent to low per datasheet */ if (!tmp) |
b67328e1c pinctrl: at91: ad... |
558 |
tmp = DRIVE_STRENGTH_BIT_MSK(LOW); |
4334ac2db pinctrl: at91: ad... |
559 560 561 562 563 564 565 566 567 568 569 570 |
return tmp; } static unsigned at91_mux_sam9x5_get_drivestrength(void __iomem *pio, unsigned pin) { unsigned tmp = read_drive_strength(pio + at91sam9x5_get_drive_register(pin), pin); /* strength is inverse in SAM9x5s hardware with the pinctrl defines * hardware: 0 = hi, 1 = med, 2 = low, 3 = rsvd */ |
b67328e1c pinctrl: at91: ad... |
571 |
tmp = DRIVE_STRENGTH_BIT_MSK(HI) - tmp; |
4334ac2db pinctrl: at91: ad... |
572 573 574 |
return tmp; } |
42ef75576 pinctrl: at91: ad... |
575 576 577 578 579 580 581 582 583 584 |
static unsigned at91_mux_sam9x60_get_drivestrength(void __iomem *pio, unsigned pin) { unsigned tmp = readl_relaxed(pio + SAM9X60_PIO_DRIVER1); if (tmp & BIT(pin)) return DRIVE_STRENGTH_BIT_HI; return DRIVE_STRENGTH_BIT_LOW; } |
64e21add8 pinctrl: at91: ad... |
585 586 587 588 589 590 591 592 593 |
static unsigned at91_mux_sam9x60_get_slewrate(void __iomem *pio, unsigned pin) { unsigned tmp = readl_relaxed(pio + SAM9X60_PIO_SLEWR); if ((tmp & BIT(pin))) return SLEWRATE_BIT_ENA; return SLEWRATE_BIT_DIS; } |
4334ac2db pinctrl: at91: ad... |
594 595 |
static void set_drive_strength(void __iomem *reg, unsigned pin, u32 strength) { |
d480239ba pinctrl: at91: co... |
596 |
unsigned tmp = readl_relaxed(reg); |
4334ac2db pinctrl: at91: ad... |
597 598 599 600 |
unsigned shift = two_bit_pin_value_shift_amount(pin); tmp &= ~(DRIVE_STRENGTH_MASK << shift); tmp |= strength << shift; |
d480239ba pinctrl: at91: co... |
601 |
writel_relaxed(tmp, reg); |
4334ac2db pinctrl: at91: ad... |
602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 |
} static void at91_mux_sama5d3_set_drivestrength(void __iomem *pio, unsigned pin, u32 setting) { /* do nothing if setting is zero */ if (!setting) return; /* strength is 1 to 1 with setting for SAMA5 */ set_drive_strength(pio + sama5d3_get_drive_register(pin), pin, setting); } static void at91_mux_sam9x5_set_drivestrength(void __iomem *pio, unsigned pin, u32 setting) { /* do nothing if setting is zero */ if (!setting) return; /* strength is inverse on SAM9x5s with our defines * 0 = hi, 1 = med, 2 = low, 3 = rsvd */ |
b67328e1c pinctrl: at91: ad... |
624 |
setting = DRIVE_STRENGTH_BIT_MSK(HI) - setting; |
4334ac2db pinctrl: at91: ad... |
625 626 627 628 |
set_drive_strength(pio + at91sam9x5_get_drive_register(pin), pin, setting); } |
42ef75576 pinctrl: at91: ad... |
629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 |
static void at91_mux_sam9x60_set_drivestrength(void __iomem *pio, unsigned pin, u32 setting) { unsigned int tmp; if (setting <= DRIVE_STRENGTH_BIT_DEF || setting == DRIVE_STRENGTH_BIT_MED || setting > DRIVE_STRENGTH_BIT_HI) return; tmp = readl_relaxed(pio + SAM9X60_PIO_DRIVER1); /* Strength is 0: low, 1: hi */ if (setting == DRIVE_STRENGTH_BIT_LOW) tmp &= ~BIT(pin); else tmp |= BIT(pin); writel_relaxed(tmp, pio + SAM9X60_PIO_DRIVER1); } |
64e21add8 pinctrl: at91: ad... |
649 650 651 652 |
static void at91_mux_sam9x60_set_slewrate(void __iomem *pio, unsigned pin, u32 setting) { unsigned int tmp; |
0b3292852 pinctrl: at91: En... |
653 |
if (setting < SLEWRATE_BIT_ENA || setting > SLEWRATE_BIT_DIS) |
64e21add8 pinctrl: at91: ad... |
654 655 656 657 658 659 660 661 662 663 664 |
return; tmp = readl_relaxed(pio + SAM9X60_PIO_SLEWR); if (setting == SLEWRATE_BIT_DIS) tmp &= ~BIT(pin); else tmp |= BIT(pin); writel_relaxed(tmp, pio + SAM9X60_PIO_SLEWR); } |
6732ae5cb ARM: at91: add pi... |
665 666 667 668 |
static struct at91_pinctrl_mux_ops at91rm9200_ops = { .get_periph = at91_mux_get_periph, .mux_A_periph = at91_mux_set_A_periph, .mux_B_periph = at91_mux_set_B_periph, |
7ebd7a3ae pinctrl: at91 add... |
669 670 |
.get_deglitch = at91_mux_get_deglitch, .set_deglitch = at91_mux_set_deglitch, |
6732ae5cb ARM: at91: add pi... |
671 672 673 674 675 676 677 678 679 |
.irq_type = gpio_irq_type, }; static struct at91_pinctrl_mux_ops at91sam9x5_ops = { .get_periph = at91_mux_pio3_get_periph, .mux_A_periph = at91_mux_pio3_set_A_periph, .mux_B_periph = at91_mux_pio3_set_B_periph, .mux_C_periph = at91_mux_pio3_set_C_periph, .mux_D_periph = at91_mux_pio3_set_D_periph, |
c8dba02e7 pinctrl: at91: fi... |
680 |
.get_deglitch = at91_mux_pio3_get_deglitch, |
7ebd7a3ae pinctrl: at91 add... |
681 682 683 684 685 686 687 |
.set_deglitch = at91_mux_pio3_set_deglitch, .get_debounce = at91_mux_pio3_get_debounce, .set_debounce = at91_mux_pio3_set_debounce, .get_pulldown = at91_mux_pio3_get_pulldown, .set_pulldown = at91_mux_pio3_set_pulldown, .get_schmitt_trig = at91_mux_pio3_get_schmitt_trig, .disable_schmitt_trig = at91_mux_pio3_disable_schmitt_trig, |
4334ac2db pinctrl: at91: ad... |
688 689 690 691 |
.get_drivestrength = at91_mux_sam9x5_get_drivestrength, .set_drivestrength = at91_mux_sam9x5_set_drivestrength, .irq_type = alt_gpio_irq_type, }; |
42ef75576 pinctrl: at91: ad... |
692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 |
static const struct at91_pinctrl_mux_ops sam9x60_ops = { .get_periph = at91_mux_pio3_get_periph, .mux_A_periph = at91_mux_pio3_set_A_periph, .mux_B_periph = at91_mux_pio3_set_B_periph, .mux_C_periph = at91_mux_pio3_set_C_periph, .mux_D_periph = at91_mux_pio3_set_D_periph, .get_deglitch = at91_mux_pio3_get_deglitch, .set_deglitch = at91_mux_pio3_set_deglitch, .get_debounce = at91_mux_pio3_get_debounce, .set_debounce = at91_mux_pio3_set_debounce, .get_pulldown = at91_mux_pio3_get_pulldown, .set_pulldown = at91_mux_pio3_set_pulldown, .get_schmitt_trig = at91_mux_pio3_get_schmitt_trig, .disable_schmitt_trig = at91_mux_pio3_disable_schmitt_trig, .get_drivestrength = at91_mux_sam9x60_get_drivestrength, .set_drivestrength = at91_mux_sam9x60_set_drivestrength, |
64e21add8 pinctrl: at91: ad... |
708 709 |
.get_slewrate = at91_mux_sam9x60_get_slewrate, .set_slewrate = at91_mux_sam9x60_set_slewrate, |
42ef75576 pinctrl: at91: ad... |
710 711 712 |
.irq_type = alt_gpio_irq_type, }; |
4334ac2db pinctrl: at91: ad... |
713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 |
static struct at91_pinctrl_mux_ops sama5d3_ops = { .get_periph = at91_mux_pio3_get_periph, .mux_A_periph = at91_mux_pio3_set_A_periph, .mux_B_periph = at91_mux_pio3_set_B_periph, .mux_C_periph = at91_mux_pio3_set_C_periph, .mux_D_periph = at91_mux_pio3_set_D_periph, .get_deglitch = at91_mux_pio3_get_deglitch, .set_deglitch = at91_mux_pio3_set_deglitch, .get_debounce = at91_mux_pio3_get_debounce, .set_debounce = at91_mux_pio3_set_debounce, .get_pulldown = at91_mux_pio3_get_pulldown, .set_pulldown = at91_mux_pio3_set_pulldown, .get_schmitt_trig = at91_mux_pio3_get_schmitt_trig, .disable_schmitt_trig = at91_mux_pio3_disable_schmitt_trig, .get_drivestrength = at91_mux_sama5d3_get_drivestrength, .set_drivestrength = at91_mux_sama5d3_set_drivestrength, |
6732ae5cb ARM: at91: add pi... |
729 730 731 732 733 734 |
.irq_type = alt_gpio_irq_type, }; static void at91_pin_dbg(const struct device *dev, const struct at91_pmx_pin *pin) { if (pin->mux) { |
4b6fe45a7 pinctrl: pinctrl-... |
735 736 |
dev_dbg(dev, "pio%c%d configured as periph%c with conf = 0x%lx ", |
6732ae5cb ARM: at91: add pi... |
737 738 |
pin->bank + 'A', pin->pin, pin->mux - 1 + 'A', pin->conf); } else { |
4b6fe45a7 pinctrl: pinctrl-... |
739 740 |
dev_dbg(dev, "pio%c%d configured as gpio with conf = 0x%lx ", |
6732ae5cb ARM: at91: add pi... |
741 742 743 |
pin->bank + 'A', pin->pin, pin->conf); } } |
3c93600d3 pinctrl: at91: Fi... |
744 |
static int pin_check_config(struct at91_pinctrl *info, const char *name, |
6732ae5cb ARM: at91: add pi... |
745 746 747 748 749 |
int index, const struct at91_pmx_pin *pin) { int mux; /* check if it's a valid config */ |
a0b957f30 pinctrl: at91: al... |
750 |
if (pin->bank >= gpio_banks) { |
6732ae5cb ARM: at91: add pi... |
751 752 |
dev_err(info->dev, "%s: pin conf %d bank_id %d >= nbanks %d ", |
a0b957f30 pinctrl: at91: al... |
753 |
name, index, pin->bank, gpio_banks); |
6732ae5cb ARM: at91: add pi... |
754 755 |
return -EINVAL; } |
a0b957f30 pinctrl: at91: al... |
756 757 758 759 760 761 |
if (!gpio_chips[pin->bank]) { dev_err(info->dev, "%s: pin conf %d bank_id %d not enabled ", name, index, pin->bank); return -ENXIO; } |
6732ae5cb ARM: at91: add pi... |
762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 |
if (pin->pin >= MAX_NB_GPIO_PER_BANK) { dev_err(info->dev, "%s: pin conf %d pin_bank_id %d >= %d ", name, index, pin->pin, MAX_NB_GPIO_PER_BANK); return -EINVAL; } if (!pin->mux) return 0; mux = pin->mux - 1; if (mux >= info->nmux) { dev_err(info->dev, "%s: pin conf %d mux_id %d >= nmux %d ", name, index, mux, info->nmux); return -EINVAL; } if (!(info->mux_mask[pin->bank * info->nmux + mux] & 1 << pin->pin)) { dev_err(info->dev, "%s: pin conf %d mux_id %d not supported for pio%c%d ", name, index, mux, pin->bank + 'A', pin->pin); return -EINVAL; } return 0; } static void at91_mux_gpio_disable(void __iomem *pio, unsigned mask) { writel_relaxed(mask, pio + PIO_PDR); } static void at91_mux_gpio_enable(void __iomem *pio, unsigned mask, bool input) { writel_relaxed(mask, pio + PIO_PER); writel_relaxed(mask, pio + (input ? PIO_ODR : PIO_OER)); } |
03e9f0cac pinctrl: clean up... |
801 802 |
static int at91_pmx_set(struct pinctrl_dev *pctldev, unsigned selector, unsigned group) |
6732ae5cb ARM: at91: add pi... |
803 804 805 806 807 808 809 810 811 812 813 814 815 816 |
{ struct at91_pinctrl *info = pinctrl_dev_get_drvdata(pctldev); const struct at91_pmx_pin *pins_conf = info->groups[group].pins_conf; const struct at91_pmx_pin *pin; uint32_t npins = info->groups[group].npins; int i, ret; unsigned mask; void __iomem *pio; dev_dbg(info->dev, "enable function %s group %s ", info->functions[selector].name, info->groups[group].name); /* first check that all the pins of the group are valid with a valid |
61e310a1e pinctrl: at91: co... |
817 |
* parameter */ |
6732ae5cb ARM: at91: add pi... |
818 819 820 821 822 823 824 825 826 827 828 |
for (i = 0; i < npins; i++) { pin = &pins_conf[i]; ret = pin_check_config(info, info->groups[group].name, i, pin); if (ret) return ret; } for (i = 0; i < npins; i++) { pin = &pins_conf[i]; at91_pin_dbg(info->dev, pin); pio = pin_to_controller(info, pin->bank); |
1ab36387e pinctrl: at91: fi... |
829 830 831 |
if (!pio) continue; |
6732ae5cb ARM: at91: add pi... |
832 833 |
mask = pin_to_mask(pin->pin); at91_mux_disable_interrupt(pio, mask); |
3c93600d3 pinctrl: at91: Fi... |
834 |
switch (pin->mux) { |
6732ae5cb ARM: at91: add pi... |
835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 |
case AT91_MUX_GPIO: at91_mux_gpio_enable(pio, mask, 1); break; case AT91_MUX_PERIPH_A: info->ops->mux_A_periph(pio, mask); break; case AT91_MUX_PERIPH_B: info->ops->mux_B_periph(pio, mask); break; case AT91_MUX_PERIPH_C: if (!info->ops->mux_C_periph) return -EINVAL; info->ops->mux_C_periph(pio, mask); break; case AT91_MUX_PERIPH_D: if (!info->ops->mux_D_periph) return -EINVAL; info->ops->mux_D_periph(pio, mask); break; } if (pin->mux) at91_mux_gpio_disable(pio, mask); } return 0; } |
6732ae5cb ARM: at91: add pi... |
861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 |
static int at91_pmx_get_funcs_count(struct pinctrl_dev *pctldev) { struct at91_pinctrl *info = pinctrl_dev_get_drvdata(pctldev); return info->nfunctions; } static const char *at91_pmx_get_func_name(struct pinctrl_dev *pctldev, unsigned selector) { struct at91_pinctrl *info = pinctrl_dev_get_drvdata(pctldev); return info->functions[selector].name; } static int at91_pmx_get_groups(struct pinctrl_dev *pctldev, unsigned selector, const char * const **groups, unsigned * const num_groups) { struct at91_pinctrl *info = pinctrl_dev_get_drvdata(pctldev); *groups = info->functions[selector].groups; *num_groups = info->functions[selector].ngroups; return 0; } |
f6f94f666 pinctrl: at91: St... |
887 888 889 |
static int at91_gpio_request_enable(struct pinctrl_dev *pctldev, struct pinctrl_gpio_range *range, unsigned offset) |
6732ae5cb ARM: at91: add pi... |
890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 |
{ struct at91_pinctrl *npct = pinctrl_dev_get_drvdata(pctldev); struct at91_gpio_chip *at91_chip; struct gpio_chip *chip; unsigned mask; if (!range) { dev_err(npct->dev, "invalid range "); return -EINVAL; } if (!range->gc) { dev_err(npct->dev, "missing GPIO chip in range "); return -EINVAL; } chip = range->gc; |
370ea6113 pinctrl: at91: us... |
907 |
at91_chip = gpiochip_get_data(chip); |
6732ae5cb ARM: at91: add pi... |
908 909 910 911 912 913 914 915 916 917 918 919 920 921 |
dev_dbg(npct->dev, "enable pin %u as GPIO ", offset); mask = 1 << (offset - chip->base); dev_dbg(npct->dev, "enable pin %u as PIO%c%d 0x%x ", offset, 'A' + range->id, offset - chip->base, mask); writel_relaxed(mask, at91_chip->regbase + PIO_PER); return 0; } |
f6f94f666 pinctrl: at91: St... |
922 923 924 |
static void at91_gpio_disable_free(struct pinctrl_dev *pctldev, struct pinctrl_gpio_range *range, unsigned offset) |
6732ae5cb ARM: at91: add pi... |
925 926 927 928 929 930 931 |
{ struct at91_pinctrl *npct = pinctrl_dev_get_drvdata(pctldev); dev_dbg(npct->dev, "disable pin %u as GPIO ", offset); /* Set the pin to some default state, GPIO is usually default */ } |
022ab148d pinctrl: Declare ... |
932 |
static const struct pinmux_ops at91_pmx_ops = { |
6732ae5cb ARM: at91: add pi... |
933 934 935 |
.get_functions_count = at91_pmx_get_funcs_count, .get_function_name = at91_pmx_get_func_name, .get_function_groups = at91_pmx_get_groups, |
03e9f0cac pinctrl: clean up... |
936 |
.set_mux = at91_pmx_set, |
6732ae5cb ARM: at91: add pi... |
937 938 939 940 941 942 943 944 945 946 |
.gpio_request_enable = at91_gpio_request_enable, .gpio_disable_free = at91_gpio_disable_free, }; static int at91_pinconf_get(struct pinctrl_dev *pctldev, unsigned pin_id, unsigned long *config) { struct at91_pinctrl *info = pinctrl_dev_get_drvdata(pctldev); void __iomem *pio; unsigned pin; |
7ebd7a3ae pinctrl: at91 add... |
947 |
int div; |
96bb12dea pinctrl: at91: ad... |
948 |
bool out; |
6732ae5cb ARM: at91: add pi... |
949 |
|
1292e6936 pinctrl: at91: in... |
950 951 |
*config = 0; dev_dbg(info->dev, "%s:%d, pin_id=%d", __func__, __LINE__, pin_id); |
6732ae5cb ARM: at91: add pi... |
952 |
pio = pin_to_controller(info, pin_to_bank(pin_id)); |
1ab36387e pinctrl: at91: fi... |
953 954 955 |
if (!pio) return -EINVAL; |
6732ae5cb ARM: at91: add pi... |
956 957 958 959 960 961 962 |
pin = pin_id % MAX_NB_GPIO_PER_BANK; if (at91_mux_get_multidrive(pio, pin)) *config |= MULTI_DRIVE; if (at91_mux_get_pullup(pio, pin)) *config |= PULL_UP; |
7ebd7a3ae pinctrl: at91 add... |
963 964 965 966 967 968 969 970 |
if (info->ops->get_deglitch && info->ops->get_deglitch(pio, pin)) *config |= DEGLITCH; if (info->ops->get_debounce && info->ops->get_debounce(pio, pin, &div)) *config |= DEBOUNCE | (div << DEBOUNCE_VAL_SHIFT); if (info->ops->get_pulldown && info->ops->get_pulldown(pio, pin)) *config |= PULL_DOWN; if (info->ops->get_schmitt_trig && info->ops->get_schmitt_trig(pio, pin)) *config |= DIS_SCHMIT; |
4334ac2db pinctrl: at91: ad... |
971 972 973 |
if (info->ops->get_drivestrength) *config |= (info->ops->get_drivestrength(pio, pin) << DRIVE_STRENGTH_SHIFT); |
64e21add8 pinctrl: at91: ad... |
974 975 |
if (info->ops->get_slewrate) *config |= (info->ops->get_slewrate(pio, pin) << SLEWRATE_SHIFT); |
96bb12dea pinctrl: at91: ad... |
976 977 |
if (at91_mux_get_output(pio, pin, &out)) *config |= OUTPUT | (out << OUTPUT_VAL_SHIFT); |
7ebd7a3ae pinctrl: at91 add... |
978 |
|
6732ae5cb ARM: at91: add pi... |
979 980 981 982 |
return 0; } static int at91_pinconf_set(struct pinctrl_dev *pctldev, |
03b054e96 pinctrl: Pass all... |
983 984 |
unsigned pin_id, unsigned long *configs, unsigned num_configs) |
6732ae5cb ARM: at91: add pi... |
985 986 987 988 |
{ struct at91_pinctrl *info = pinctrl_dev_get_drvdata(pctldev); unsigned mask; void __iomem *pio; |
03b054e96 pinctrl: Pass all... |
989 990 |
int i; unsigned long config; |
4334ac2db pinctrl: at91: ad... |
991 |
unsigned pin; |
03b054e96 pinctrl: Pass all... |
992 993 994 995 996 997 998 999 |
for (i = 0; i < num_configs; i++) { config = configs[i]; dev_dbg(info->dev, "%s:%d, pin_id=%d, config=0x%lx", __func__, __LINE__, pin_id, config); pio = pin_to_controller(info, pin_to_bank(pin_id)); |
1ab36387e pinctrl: at91: fi... |
1000 1001 1002 |
if (!pio) return -EINVAL; |
4334ac2db pinctrl: at91: ad... |
1003 1004 |
pin = pin_id % MAX_NB_GPIO_PER_BANK; mask = pin_to_mask(pin); |
03b054e96 pinctrl: Pass all... |
1005 1006 1007 |
if (config & PULL_UP && config & PULL_DOWN) return -EINVAL; |
96bb12dea pinctrl: at91: ad... |
1008 1009 |
at91_mux_set_output(pio, mask, config & OUTPUT, (config & OUTPUT_VAL) >> OUTPUT_VAL_SHIFT); |
03b054e96 pinctrl: Pass all... |
1010 1011 1012 1013 1014 1015 |
at91_mux_set_pullup(pio, mask, config & PULL_UP); at91_mux_set_multidrive(pio, mask, config & MULTI_DRIVE); if (info->ops->set_deglitch) info->ops->set_deglitch(pio, mask, config & DEGLITCH); if (info->ops->set_debounce) info->ops->set_debounce(pio, mask, config & DEBOUNCE, |
7ebd7a3ae pinctrl: at91 add... |
1016 |
(config & DEBOUNCE_VAL) >> DEBOUNCE_VAL_SHIFT); |
03b054e96 pinctrl: Pass all... |
1017 1018 1019 1020 |
if (info->ops->set_pulldown) info->ops->set_pulldown(pio, mask, config & PULL_DOWN); if (info->ops->disable_schmitt_trig && config & DIS_SCHMIT) info->ops->disable_schmitt_trig(pio, mask); |
4334ac2db pinctrl: at91: ad... |
1021 1022 1023 1024 |
if (info->ops->set_drivestrength) info->ops->set_drivestrength(pio, pin, (config & DRIVE_STRENGTH) >> DRIVE_STRENGTH_SHIFT); |
64e21add8 pinctrl: at91: ad... |
1025 1026 1027 |
if (info->ops->set_slewrate) info->ops->set_slewrate(pio, pin, (config & SLEWRATE) >> SLEWRATE_SHIFT); |
03b054e96 pinctrl: Pass all... |
1028 1029 |
} /* for each config */ |
7ebd7a3ae pinctrl: at91 add... |
1030 |
|
6732ae5cb ARM: at91: add pi... |
1031 1032 |
return 0; } |
4d9b8a8e4 pinctrl: at91: im... |
1033 1034 1035 1036 1037 1038 1039 1040 |
#define DBG_SHOW_FLAG(flag) do { \ if (config & flag) { \ if (num_conf) \ seq_puts(s, "|"); \ seq_puts(s, #flag); \ num_conf++; \ } \ } while (0) |
b67328e1c pinctrl: at91: ad... |
1041 |
#define DBG_SHOW_FLAG_MASKED(mask, flag, name) do { \ |
4334ac2db pinctrl: at91: ad... |
1042 1043 1044 |
if ((config & mask) == flag) { \ if (num_conf) \ seq_puts(s, "|"); \ |
b67328e1c pinctrl: at91: ad... |
1045 |
seq_puts(s, #name); \ |
4334ac2db pinctrl: at91: ad... |
1046 1047 1048 |
num_conf++; \ } \ } while (0) |
6732ae5cb ARM: at91: add pi... |
1049 1050 1051 |
static void at91_pinconf_dbg_show(struct pinctrl_dev *pctldev, struct seq_file *s, unsigned pin_id) { |
4d9b8a8e4 pinctrl: at91: im... |
1052 |
unsigned long config; |
445d20260 pinctrl: pinctrl-... |
1053 |
int val, num_conf = 0; |
4d9b8a8e4 pinctrl: at91: im... |
1054 |
|
445d20260 pinctrl: pinctrl-... |
1055 |
at91_pinconf_get(pctldev, pin_id, &config); |
4d9b8a8e4 pinctrl: at91: im... |
1056 1057 1058 1059 1060 1061 |
DBG_SHOW_FLAG(MULTI_DRIVE); DBG_SHOW_FLAG(PULL_UP); DBG_SHOW_FLAG(PULL_DOWN); DBG_SHOW_FLAG(DIS_SCHMIT); DBG_SHOW_FLAG(DEGLITCH); |
b67328e1c pinctrl: at91: ad... |
1062 1063 1064 1065 1066 1067 |
DBG_SHOW_FLAG_MASKED(DRIVE_STRENGTH, DRIVE_STRENGTH_BIT_MSK(LOW), DRIVE_STRENGTH_LOW); DBG_SHOW_FLAG_MASKED(DRIVE_STRENGTH, DRIVE_STRENGTH_BIT_MSK(MED), DRIVE_STRENGTH_MED); DBG_SHOW_FLAG_MASKED(DRIVE_STRENGTH, DRIVE_STRENGTH_BIT_MSK(HI), DRIVE_STRENGTH_HI); |
64e21add8 pinctrl: at91: ad... |
1068 |
DBG_SHOW_FLAG(SLEWRATE); |
4d9b8a8e4 pinctrl: at91: im... |
1069 1070 1071 1072 1073 |
DBG_SHOW_FLAG(DEBOUNCE); if (config & DEBOUNCE) { val = config >> DEBOUNCE_VAL_SHIFT; seq_printf(s, "(%d)", val); } |
6732ae5cb ARM: at91: add pi... |
1074 |
|
4d9b8a8e4 pinctrl: at91: im... |
1075 |
return; |
6732ae5cb ARM: at91: add pi... |
1076 1077 1078 1079 1080 1081 |
} static void at91_pinconf_group_dbg_show(struct pinctrl_dev *pctldev, struct seq_file *s, unsigned group) { } |
022ab148d pinctrl: Declare ... |
1082 |
static const struct pinconf_ops at91_pinconf_ops = { |
6732ae5cb ARM: at91: add pi... |
1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 |
.pin_config_get = at91_pinconf_get, .pin_config_set = at91_pinconf_set, .pin_config_dbg_show = at91_pinconf_dbg_show, .pin_config_group_dbg_show = at91_pinconf_group_dbg_show, }; static struct pinctrl_desc at91_pinctrl_desc = { .pctlops = &at91_pctrl_ops, .pmxops = &at91_pmx_ops, .confops = &at91_pinconf_ops, .owner = THIS_MODULE, }; static const char *gpio_compat = "atmel,at91rm9200-gpio"; |
150632b09 Drivers: pinctrl:... |
1097 1098 |
static void at91_pinctrl_child_count(struct at91_pinctrl *info, struct device_node *np) |
6732ae5cb ARM: at91: add pi... |
1099 1100 1101 1102 1103 |
{ struct device_node *child; for_each_child_of_node(np, child) { if (of_device_is_compatible(child, gpio_compat)) { |
a0b957f30 pinctrl: at91: al... |
1104 1105 |
if (of_device_is_available(child)) info->nactive_banks++; |
6732ae5cb ARM: at91: add pi... |
1106 1107 1108 1109 1110 1111 |
} else { info->nfunctions++; info->ngroups += of_get_child_count(child); } } } |
150632b09 Drivers: pinctrl:... |
1112 1113 |
static int at91_pinctrl_mux_mask(struct at91_pinctrl *info, struct device_node *np) |
6732ae5cb ARM: at91: add pi... |
1114 1115 1116 |
{ int ret = 0; int size; |
1164d73a9 pinctrl: at91: Re... |
1117 |
const __be32 *list; |
6732ae5cb ARM: at91: add pi... |
1118 1119 1120 1121 1122 1123 1124 1125 1126 |
list = of_get_property(np, "atmel,mux-mask", &size); if (!list) { dev_err(info->dev, "can not read the mux-mask of %d ", size); return -EINVAL; } size /= sizeof(*list); |
a0b957f30 pinctrl: at91: al... |
1127 1128 1129 |
if (!size || size % gpio_banks) { dev_err(info->dev, "wrong mux mask array should be by %d ", gpio_banks); |
6732ae5cb ARM: at91: add pi... |
1130 1131 |
return -EINVAL; } |
a0b957f30 pinctrl: at91: al... |
1132 |
info->nmux = size / gpio_banks; |
6732ae5cb ARM: at91: add pi... |
1133 |
|
a86854d0c treewide: devm_kz... |
1134 1135 |
info->mux_mask = devm_kcalloc(info->dev, size, sizeof(u32), GFP_KERNEL); |
3da941b04 pinctrl: at91: De... |
1136 |
if (!info->mux_mask) |
6732ae5cb ARM: at91: add pi... |
1137 |
return -ENOMEM; |
6732ae5cb ARM: at91: add pi... |
1138 1139 1140 1141 1142 1143 1144 1145 |
ret = of_property_read_u32_array(np, "atmel,mux-mask", info->mux_mask, size); if (ret) dev_err(info->dev, "can not read the mux-mask of %d ", size); return ret; } |
150632b09 Drivers: pinctrl:... |
1146 1147 1148 |
static int at91_pinctrl_parse_groups(struct device_node *np, struct at91_pin_group *grp, struct at91_pinctrl *info, u32 index) |
6732ae5cb ARM: at91: add pi... |
1149 1150 1151 |
{ struct at91_pmx_pin *pin; int size; |
1164d73a9 pinctrl: at91: Re... |
1152 |
const __be32 *list; |
6732ae5cb ARM: at91: add pi... |
1153 |
int i, j; |
94f4e54ce pinctrl: Convert ... |
1154 1155 |
dev_dbg(info->dev, "group(%d): %pOFn ", index, np); |
6732ae5cb ARM: at91: add pi... |
1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 |
/* Initialise group */ grp->name = np->name; /* * the binding format is atmel,pins = <bank pin mux CONFIG ...>, * do sanity check and calculate pins number */ list = of_get_property(np, "atmel,pins", &size); /* we do not check return since it's safe node passed down */ size /= sizeof(*list); if (!size || size % 4) { dev_err(info->dev, "wrong pins number or pins and configs should be by 4 "); return -EINVAL; } grp->npins = size / 4; |
a86854d0c treewide: devm_kz... |
1174 1175 1176 1177 1178 1179 |
pin = grp->pins_conf = devm_kcalloc(info->dev, grp->npins, sizeof(struct at91_pmx_pin), GFP_KERNEL); grp->pins = devm_kcalloc(info->dev, grp->npins, sizeof(unsigned int), GFP_KERNEL); |
6732ae5cb ARM: at91: add pi... |
1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 |
if (!grp->pins_conf || !grp->pins) return -ENOMEM; for (i = 0, j = 0; i < size; i += 4, j++) { pin->bank = be32_to_cpu(*list++); pin->pin = be32_to_cpu(*list++); grp->pins[j] = pin->bank * MAX_NB_GPIO_PER_BANK + pin->pin; pin->mux = be32_to_cpu(*list++); pin->conf = be32_to_cpu(*list++); at91_pin_dbg(info->dev, pin); pin++; } return 0; } |
150632b09 Drivers: pinctrl:... |
1196 1197 |
static int at91_pinctrl_parse_functions(struct device_node *np, struct at91_pinctrl *info, u32 index) |
6732ae5cb ARM: at91: add pi... |
1198 1199 1200 1201 1202 1203 1204 |
{ struct device_node *child; struct at91_pmx_func *func; struct at91_pin_group *grp; int ret; static u32 grp_index; u32 i = 0; |
94f4e54ce pinctrl: Convert ... |
1205 1206 |
dev_dbg(info->dev, "parse function(%d): %pOFn ", index, np); |
6732ae5cb ARM: at91: add pi... |
1207 1208 1209 1210 1211 1212 |
func = &info->functions[index]; /* Initialise function */ func->name = np->name; func->ngroups = of_get_child_count(np); |
ca7162add pinctrl: pinctrl-... |
1213 |
if (func->ngroups == 0) { |
6732ae5cb ARM: at91: add pi... |
1214 1215 1216 1217 |
dev_err(info->dev, "no groups defined "); return -EINVAL; } |
a86854d0c treewide: devm_kz... |
1218 1219 |
func->groups = devm_kcalloc(info->dev, func->ngroups, sizeof(char *), GFP_KERNEL); |
6732ae5cb ARM: at91: add pi... |
1220 1221 1222 1223 1224 1225 1226 |
if (!func->groups) return -ENOMEM; for_each_child_of_node(np, child) { func->groups[i] = child->name; grp = &info->groups[grp_index++]; ret = at91_pinctrl_parse_groups(child, grp, info, i++); |
d94b986aa pinctrl: at91: ad... |
1227 1228 |
if (ret) { of_node_put(child); |
6732ae5cb ARM: at91: add pi... |
1229 |
return ret; |
d94b986aa pinctrl: at91: ad... |
1230 |
} |
6732ae5cb ARM: at91: add pi... |
1231 1232 1233 1234 |
} return 0; } |
baa9946e3 pinctrl: constify... |
1235 |
static const struct of_device_id at91_pinctrl_of_match[] = { |
4334ac2db pinctrl: at91: ad... |
1236 |
{ .compatible = "atmel,sama5d3-pinctrl", .data = &sama5d3_ops }, |
6732ae5cb ARM: at91: add pi... |
1237 1238 |
{ .compatible = "atmel,at91sam9x5-pinctrl", .data = &at91sam9x5_ops }, { .compatible = "atmel,at91rm9200-pinctrl", .data = &at91rm9200_ops }, |
a2fcb1ce8 pinctrl: at91: ad... |
1239 |
{ .compatible = "microchip,sam9x60-pinctrl", .data = &sam9x60_ops }, |
6732ae5cb ARM: at91: add pi... |
1240 1241 |
{ /* sentinel */ } }; |
150632b09 Drivers: pinctrl:... |
1242 1243 |
static int at91_pinctrl_probe_dt(struct platform_device *pdev, struct at91_pinctrl *info) |
6732ae5cb ARM: at91: add pi... |
1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 |
{ int ret = 0; int i, j; uint32_t *tmp; struct device_node *np = pdev->dev.of_node; struct device_node *child; if (!np) return -ENODEV; info->dev = &pdev->dev; |
3c93600d3 pinctrl: at91: Fi... |
1255 |
info->ops = (struct at91_pinctrl_mux_ops *) |
6732ae5cb ARM: at91: add pi... |
1256 1257 |
of_match_device(at91_pinctrl_of_match, &pdev->dev)->data; at91_pinctrl_child_count(info, np); |
a0b957f30 pinctrl: at91: al... |
1258 |
if (gpio_banks < 1) { |
61e310a1e pinctrl: at91: co... |
1259 1260 |
dev_err(&pdev->dev, "you need to specify at least one gpio-controller "); |
6732ae5cb ARM: at91: add pi... |
1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 |
return -EINVAL; } ret = at91_pinctrl_mux_mask(info, np); if (ret) return ret; dev_dbg(&pdev->dev, "nmux = %d ", info->nmux); dev_dbg(&pdev->dev, "mux-mask "); tmp = info->mux_mask; |
a0b957f30 pinctrl: at91: al... |
1274 |
for (i = 0; i < gpio_banks; i++) { |
6732ae5cb ARM: at91: add pi... |
1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 |
for (j = 0; j < info->nmux; j++, tmp++) { dev_dbg(&pdev->dev, "%d:%d\t0x%x ", i, j, tmp[0]); } } dev_dbg(&pdev->dev, "nfunctions = %d ", info->nfunctions); dev_dbg(&pdev->dev, "ngroups = %d ", info->ngroups); |
a86854d0c treewide: devm_kz... |
1285 1286 1287 |
info->functions = devm_kcalloc(&pdev->dev, info->nfunctions, sizeof(struct at91_pmx_func), |
6732ae5cb ARM: at91: add pi... |
1288 1289 1290 |
GFP_KERNEL); if (!info->functions) return -ENOMEM; |
a86854d0c treewide: devm_kz... |
1291 1292 1293 |
info->groups = devm_kcalloc(&pdev->dev, info->ngroups, sizeof(struct at91_pin_group), |
6732ae5cb ARM: at91: add pi... |
1294 1295 1296 |
GFP_KERNEL); if (!info->groups) return -ENOMEM; |
a0b957f30 pinctrl: at91: al... |
1297 1298 |
dev_dbg(&pdev->dev, "nbanks = %d ", gpio_banks); |
6732ae5cb ARM: at91: add pi... |
1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 |
dev_dbg(&pdev->dev, "nfunctions = %d ", info->nfunctions); dev_dbg(&pdev->dev, "ngroups = %d ", info->ngroups); i = 0; for_each_child_of_node(np, child) { if (of_device_is_compatible(child, gpio_compat)) continue; ret = at91_pinctrl_parse_functions(child, info, i++); if (ret) { dev_err(&pdev->dev, "failed to parse function "); |
d94b986aa pinctrl: at91: ad... |
1313 |
of_node_put(child); |
6732ae5cb ARM: at91: add pi... |
1314 1315 1316 1317 1318 1319 |
return ret; } } return 0; } |
150632b09 Drivers: pinctrl:... |
1320 |
static int at91_pinctrl_probe(struct platform_device *pdev) |
6732ae5cb ARM: at91: add pi... |
1321 1322 1323 |
{ struct at91_pinctrl *info; struct pinctrl_pin_desc *pdesc; |
a0b957f30 pinctrl: at91: al... |
1324 |
int ret, i, j, k, ngpio_chips_enabled = 0; |
6732ae5cb ARM: at91: add pi... |
1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 |
info = devm_kzalloc(&pdev->dev, sizeof(*info), GFP_KERNEL); if (!info) return -ENOMEM; ret = at91_pinctrl_probe_dt(pdev, info); if (ret) return ret; /* * We need all the GPIO drivers to probe FIRST, or we will not be able * to obtain references to the struct gpio_chip * for them, and we * need this to proceed. */ |
a0b957f30 pinctrl: at91: al... |
1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 |
for (i = 0; i < gpio_banks; i++) if (gpio_chips[i]) ngpio_chips_enabled++; if (ngpio_chips_enabled < info->nactive_banks) { dev_warn(&pdev->dev, "All GPIO chips are not registered yet (%d/%d) ", ngpio_chips_enabled, info->nactive_banks); devm_kfree(&pdev->dev, info); return -EPROBE_DEFER; |
6732ae5cb ARM: at91: add pi... |
1350 1351 1352 |
} at91_pinctrl_desc.name = dev_name(&pdev->dev); |
a0b957f30 pinctrl: at91: al... |
1353 |
at91_pinctrl_desc.npins = gpio_banks * MAX_NB_GPIO_PER_BANK; |
6732ae5cb ARM: at91: add pi... |
1354 |
at91_pinctrl_desc.pins = pdesc = |
a86854d0c treewide: devm_kz... |
1355 1356 1357 |
devm_kcalloc(&pdev->dev, at91_pinctrl_desc.npins, sizeof(*pdesc), GFP_KERNEL); |
6732ae5cb ARM: at91: add pi... |
1358 1359 1360 |
if (!at91_pinctrl_desc.pins) return -ENOMEM; |
a0b957f30 pinctrl: at91: al... |
1361 |
for (i = 0, k = 0; i < gpio_banks; i++) { |
6732ae5cb ARM: at91: add pi... |
1362 1363 1364 1365 1366 1367 1368 1369 |
for (j = 0; j < MAX_NB_GPIO_PER_BANK; j++, k++) { pdesc->number = k; pdesc->name = kasprintf(GFP_KERNEL, "pio%c%d", i + 'A', j); pdesc++; } } platform_set_drvdata(pdev, info); |
5c67425a4 pinctrl: at91: Us... |
1370 1371 |
info->pctl = devm_pinctrl_register(&pdev->dev, &at91_pinctrl_desc, info); |
6732ae5cb ARM: at91: add pi... |
1372 |
|
323de9efd pinctrl: make pin... |
1373 |
if (IS_ERR(info->pctl)) { |
6732ae5cb ARM: at91: add pi... |
1374 1375 |
dev_err(&pdev->dev, "could not register AT91 pinctrl driver "); |
323de9efd pinctrl: make pin... |
1376 |
return PTR_ERR(info->pctl); |
6732ae5cb ARM: at91: add pi... |
1377 1378 1379 |
} /* We will handle a range of GPIO pins */ |
a0b957f30 pinctrl: at91: al... |
1380 1381 1382 |
for (i = 0; i < gpio_banks; i++) if (gpio_chips[i]) pinctrl_add_gpio_range(info->pctl, &gpio_chips[i]->range); |
6732ae5cb ARM: at91: add pi... |
1383 1384 1385 1386 1387 |
dev_info(&pdev->dev, "initialized AT91 pinctrl driver "); return 0; |
6732ae5cb ARM: at91: add pi... |
1388 |
} |
8af584b86 pinctrl: at91: im... |
1389 1390 |
static int at91_gpio_get_direction(struct gpio_chip *chip, unsigned offset) { |
370ea6113 pinctrl: at91: us... |
1391 |
struct at91_gpio_chip *at91_gpio = gpiochip_get_data(chip); |
8af584b86 pinctrl: at91: im... |
1392 1393 1394 1395 1396 |
void __iomem *pio = at91_gpio->regbase; unsigned mask = 1 << offset; u32 osr; osr = readl_relaxed(pio + PIO_OSR); |
3c8278735 pinctrl: Use new ... |
1397 1398 1399 1400 |
if (osr & mask) return GPIO_LINE_DIRECTION_OUT; return GPIO_LINE_DIRECTION_IN; |
8af584b86 pinctrl: at91: im... |
1401 |
} |
6732ae5cb ARM: at91: add pi... |
1402 1403 |
static int at91_gpio_direction_input(struct gpio_chip *chip, unsigned offset) { |
370ea6113 pinctrl: at91: us... |
1404 |
struct at91_gpio_chip *at91_gpio = gpiochip_get_data(chip); |
6732ae5cb ARM: at91: add pi... |
1405 1406 1407 1408 1409 1410 1411 1412 1413 |
void __iomem *pio = at91_gpio->regbase; unsigned mask = 1 << offset; writel_relaxed(mask, pio + PIO_ODR); return 0; } static int at91_gpio_get(struct gpio_chip *chip, unsigned offset) { |
370ea6113 pinctrl: at91: us... |
1414 |
struct at91_gpio_chip *at91_gpio = gpiochip_get_data(chip); |
6732ae5cb ARM: at91: add pi... |
1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 |
void __iomem *pio = at91_gpio->regbase; unsigned mask = 1 << offset; u32 pdsr; pdsr = readl_relaxed(pio + PIO_PDSR); return (pdsr & mask) != 0; } static void at91_gpio_set(struct gpio_chip *chip, unsigned offset, int val) { |
370ea6113 pinctrl: at91: us... |
1426 |
struct at91_gpio_chip *at91_gpio = gpiochip_get_data(chip); |
6732ae5cb ARM: at91: add pi... |
1427 1428 1429 1430 1431 |
void __iomem *pio = at91_gpio->regbase; unsigned mask = 1 << offset; writel_relaxed(mask, pio + (val ? PIO_SODR : PIO_CODR)); } |
1893b2cfa pinctrl: at91: Ad... |
1432 1433 1434 |
static void at91_gpio_set_multiple(struct gpio_chip *chip, unsigned long *mask, unsigned long *bits) { |
370ea6113 pinctrl: at91: us... |
1435 |
struct at91_gpio_chip *at91_gpio = gpiochip_get_data(chip); |
1893b2cfa pinctrl: at91: Ad... |
1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 |
void __iomem *pio = at91_gpio->regbase; #define BITS_MASK(bits) (((bits) == 32) ? ~0U : (BIT(bits) - 1)) /* Mask additionally to ngpio as not all GPIO controllers have 32 pins */ uint32_t set_mask = (*mask & *bits) & BITS_MASK(chip->ngpio); uint32_t clear_mask = (*mask & ~(*bits)) & BITS_MASK(chip->ngpio); writel_relaxed(set_mask, pio + PIO_SODR); writel_relaxed(clear_mask, pio + PIO_CODR); } |
6732ae5cb ARM: at91: add pi... |
1446 1447 1448 |
static int at91_gpio_direction_output(struct gpio_chip *chip, unsigned offset, int val) { |
370ea6113 pinctrl: at91: us... |
1449 |
struct at91_gpio_chip *at91_gpio = gpiochip_get_data(chip); |
6732ae5cb ARM: at91: add pi... |
1450 1451 1452 1453 1454 1455 1456 1457 |
void __iomem *pio = at91_gpio->regbase; unsigned mask = 1 << offset; writel_relaxed(mask, pio + (val ? PIO_SODR : PIO_CODR)); writel_relaxed(mask, pio + PIO_OER); return 0; } |
6732ae5cb ARM: at91: add pi... |
1458 1459 1460 1461 1462 |
#ifdef CONFIG_DEBUG_FS static void at91_gpio_dbg_show(struct seq_file *s, struct gpio_chip *chip) { enum at91_mux mode; int i; |
370ea6113 pinctrl: at91: us... |
1463 |
struct at91_gpio_chip *at91_gpio = gpiochip_get_data(chip); |
6732ae5cb ARM: at91: add pi... |
1464 |
void __iomem *pio = at91_gpio->regbase; |
5bae1f08e pinctrl: at91: Ma... |
1465 |
const char *gpio_label; |
6732ae5cb ARM: at91: add pi... |
1466 |
|
5bae1f08e pinctrl: at91: Ma... |
1467 |
for_each_requested_gpio(chip, i, gpio_label) { |
47f227163 pinctrl/at91: Fix... |
1468 |
unsigned mask = pin_to_mask(i); |
6732ae5cb ARM: at91: add pi... |
1469 |
|
6732ae5cb ARM: at91: add pi... |
1470 1471 1472 1473 |
mode = at91_gpio->ops->get_periph(pio, mask); seq_printf(s, "[%s] GPIO%s%d: ", gpio_label, chip->label, i); if (mode == AT91_MUX_GPIO) { |
853b6bf04 pinctrl: at91: en... |
1474 1475 1476 1477 1478 1479 1480 1481 |
seq_printf(s, "[gpio] "); seq_printf(s, "%s ", readl_relaxed(pio + PIO_OSR) & mask ? "output" : "input"); seq_printf(s, "%s ", readl_relaxed(pio + PIO_PDSR) & mask ? "set" : "clear"); |
6732ae5cb ARM: at91: add pi... |
1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 |
} else { seq_printf(s, "[periph %c] ", mode + 'A' - 1); } } } #else #define at91_gpio_dbg_show NULL #endif /* Several AIC controller irqs are dispatched through this GPIO handler. * To use any AT91_PIN_* as an externally triggered IRQ, first call * at91_set_gpio_input() then maybe enable its glitch filter. * Then just request_irq() with the pin ID; it works like any ARM IRQ * handler. * First implementation always triggers on rising and falling edges * whereas the newer PIO3 can be additionally configured to trigger on * level, edge with any polarity. * * Alternatively, certain pins may be used directly as IRQ0..IRQ6 after * configuring them with at91_set_a_periph() or at91_set_b_periph(). * IRQ0..IRQ6 should be configurable, e.g. level vs edge triggering. */ static void gpio_irq_mask(struct irq_data *d) { struct at91_gpio_chip *at91_gpio = irq_data_get_irq_chip_data(d); void __iomem *pio = at91_gpio->regbase; unsigned mask = 1 << d->hwirq; if (pio) writel_relaxed(mask, pio + PIO_IDR); } static void gpio_irq_unmask(struct irq_data *d) { struct at91_gpio_chip *at91_gpio = irq_data_get_irq_chip_data(d); void __iomem *pio = at91_gpio->regbase; unsigned mask = 1 << d->hwirq; if (pio) writel_relaxed(mask, pio + PIO_IER); } static int gpio_irq_type(struct irq_data *d, unsigned type) { switch (type) { case IRQ_TYPE_NONE: case IRQ_TYPE_EDGE_BOTH: return 0; default: return -EINVAL; } } /* Alternate irq type for PIO3 support */ static int alt_gpio_irq_type(struct irq_data *d, unsigned type) { struct at91_gpio_chip *at91_gpio = irq_data_get_irq_chip_data(d); void __iomem *pio = at91_gpio->regbase; unsigned mask = 1 << d->hwirq; switch (type) { case IRQ_TYPE_EDGE_RISING: |
c639845bc pinctrl/at91: Use... |
1547 |
irq_set_handler_locked(d, handle_simple_irq); |
6732ae5cb ARM: at91: add pi... |
1548 1549 1550 1551 |
writel_relaxed(mask, pio + PIO_ESR); writel_relaxed(mask, pio + PIO_REHLSR); break; case IRQ_TYPE_EDGE_FALLING: |
c639845bc pinctrl/at91: Use... |
1552 |
irq_set_handler_locked(d, handle_simple_irq); |
6732ae5cb ARM: at91: add pi... |
1553 1554 1555 1556 |
writel_relaxed(mask, pio + PIO_ESR); writel_relaxed(mask, pio + PIO_FELLSR); break; case IRQ_TYPE_LEVEL_LOW: |
c639845bc pinctrl/at91: Use... |
1557 |
irq_set_handler_locked(d, handle_level_irq); |
6732ae5cb ARM: at91: add pi... |
1558 1559 1560 1561 |
writel_relaxed(mask, pio + PIO_LSR); writel_relaxed(mask, pio + PIO_FELLSR); break; case IRQ_TYPE_LEVEL_HIGH: |
c639845bc pinctrl/at91: Use... |
1562 |
irq_set_handler_locked(d, handle_level_irq); |
6732ae5cb ARM: at91: add pi... |
1563 1564 1565 1566 1567 1568 1569 1570 |
writel_relaxed(mask, pio + PIO_LSR); writel_relaxed(mask, pio + PIO_REHLSR); break; case IRQ_TYPE_EDGE_BOTH: /* * disable additional interrupt modes: * fall back to default behavior */ |
c639845bc pinctrl/at91: Use... |
1571 |
irq_set_handler_locked(d, handle_simple_irq); |
6732ae5cb ARM: at91: add pi... |
1572 1573 1574 1575 |
writel_relaxed(mask, pio + PIO_AIMDR); return 0; case IRQ_TYPE_NONE: default: |
1c5fb66af pinctrl: Include ... |
1576 1577 |
pr_warn("AT91: No type for GPIO irq offset %d ", d->irq); |
6732ae5cb ARM: at91: add pi... |
1578 1579 1580 1581 1582 1583 1584 1585 |
return -EINVAL; } /* enable additional interrupt modes */ writel_relaxed(mask, pio + PIO_AIMER); return 0; } |
80cc37329 pinctrl/at91: con... |
1586 1587 1588 1589 |
static void gpio_irq_ack(struct irq_data *d) { /* the interrupt is already cleared before by reading ISR */ } |
6732ae5cb ARM: at91: add pi... |
1590 |
#ifdef CONFIG_PM |
647f8d94a ARM: at91: add gp... |
1591 1592 1593 |
static u32 wakeups[MAX_GPIO_BANKS]; static u32 backups[MAX_GPIO_BANKS]; |
6732ae5cb ARM: at91: add pi... |
1594 1595 1596 1597 |
static int gpio_irq_set_wake(struct irq_data *d, unsigned state) { struct at91_gpio_chip *at91_gpio = irq_data_get_irq_chip_data(d); unsigned bank = at91_gpio->pioc_idx; |
647f8d94a ARM: at91: add gp... |
1598 |
unsigned mask = 1 << d->hwirq; |
6732ae5cb ARM: at91: add pi... |
1599 1600 1601 |
if (unlikely(bank >= MAX_GPIO_BANKS)) return -EINVAL; |
647f8d94a ARM: at91: add gp... |
1602 1603 1604 1605 |
if (state) wakeups[bank] |= mask; else wakeups[bank] &= ~mask; |
6732ae5cb ARM: at91: add pi... |
1606 1607 1608 1609 |
irq_set_irq_wake(at91_gpio->pioc_virq, state); return 0; } |
647f8d94a ARM: at91: add gp... |
1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 |
void at91_pinctrl_gpio_suspend(void) { int i; for (i = 0; i < gpio_banks; i++) { void __iomem *pio; if (!gpio_chips[i]) continue; pio = gpio_chips[i]->regbase; |
d480239ba pinctrl: at91: co... |
1622 1623 1624 |
backups[i] = readl_relaxed(pio + PIO_IMR); writel_relaxed(backups[i], pio + PIO_IDR); writel_relaxed(wakeups[i], pio + PIO_IER); |
647f8d94a ARM: at91: add gp... |
1625 |
|
795f9953e pinctrl: at91: fi... |
1626 1627 1628 |
if (!wakeups[i]) clk_disable_unprepare(gpio_chips[i]->clock); else |
647f8d94a ARM: at91: add gp... |
1629 1630 1631 |
printk(KERN_DEBUG "GPIO-%c may wake for %08x ", 'A'+i, wakeups[i]); |
647f8d94a ARM: at91: add gp... |
1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 |
} } void at91_pinctrl_gpio_resume(void) { int i; for (i = 0; i < gpio_banks; i++) { void __iomem *pio; if (!gpio_chips[i]) continue; pio = gpio_chips[i]->regbase; |
37ef1d924 pinctrl: at91: re... |
1646 1647 |
if (!wakeups[i]) clk_prepare_enable(gpio_chips[i]->clock); |
647f8d94a ARM: at91: add gp... |
1648 |
|
d480239ba pinctrl: at91: co... |
1649 1650 |
writel_relaxed(wakeups[i], pio + PIO_IDR); writel_relaxed(backups[i], pio + PIO_IER); |
647f8d94a ARM: at91: add gp... |
1651 1652 |
} } |
6732ae5cb ARM: at91: add pi... |
1653 1654 |
#else #define gpio_irq_set_wake NULL |
647f8d94a ARM: at91: add gp... |
1655 |
#endif /* CONFIG_PM */ |
6732ae5cb ARM: at91: add pi... |
1656 |
|
bd0b9ac40 genirq: Remove ir... |
1657 |
static void gpio_irq_handler(struct irq_desc *desc) |
6732ae5cb ARM: at91: add pi... |
1658 |
{ |
5663bb27d pinctrl: Use irq_... |
1659 |
struct irq_chip *chip = irq_desc_get_chip(desc); |
80cc37329 pinctrl/at91: con... |
1660 |
struct gpio_chip *gpio_chip = irq_desc_get_handler_data(desc); |
370ea6113 pinctrl: at91: us... |
1661 |
struct at91_gpio_chip *at91_gpio = gpiochip_get_data(gpio_chip); |
6732ae5cb ARM: at91: add pi... |
1662 1663 1664 1665 1666 1667 1668 |
void __iomem *pio = at91_gpio->regbase; unsigned long isr; int n; chained_irq_enter(chip, desc); for (;;) { /* Reading ISR acks pending (edge triggered) GPIO interrupts. |
c2eb9e7f0 pinctrl: at91: co... |
1669 |
* When there are none pending, we're finished unless we need |
6732ae5cb ARM: at91: add pi... |
1670 1671 1672 1673 1674 1675 1676 1677 |
* to process multiple banks (like ID_PIOCDE on sam9263). */ isr = readl_relaxed(pio + PIO_ISR) & readl_relaxed(pio + PIO_IMR); if (!isr) { if (!at91_gpio->next) break; at91_gpio = at91_gpio->next; pio = at91_gpio->regbase; |
cccb0c3e6 pinctrl/at91: Fix... |
1678 |
gpio_chip = &at91_gpio->chip; |
6732ae5cb ARM: at91: add pi... |
1679 1680 |
continue; } |
05daa16a8 pinctrl/at91: usi... |
1681 |
for_each_set_bit(n, &isr, BITS_PER_LONG) { |
80cc37329 pinctrl/at91: con... |
1682 |
generic_handle_irq(irq_find_mapping( |
f0fbe7bce gpio: Move irqdom... |
1683 |
gpio_chip->irq.domain, n)); |
6732ae5cb ARM: at91: add pi... |
1684 1685 1686 1687 1688 |
} } chained_irq_exit(chip, desc); /* now it may re-trigger */ } |
834e16786 pinctrl: at91: Fi... |
1689 |
static int at91_gpio_of_irq_setup(struct platform_device *pdev, |
6732ae5cb ARM: at91: add pi... |
1690 1691 |
struct at91_gpio_chip *at91_gpio) { |
a0b957f30 pinctrl: at91: al... |
1692 |
struct gpio_chip *gpiochip_prev = NULL; |
cccb0c3e6 pinctrl/at91: Fix... |
1693 |
struct at91_gpio_chip *prev = NULL; |
6732ae5cb ARM: at91: add pi... |
1694 |
struct irq_data *d = irq_get_irq_data(at91_gpio->pioc_virq); |
0c3dfa176 pinctrl: at91: do... |
1695 |
struct irq_chip *gpio_irqchip; |
35dea5d74 pinctrl: at91: Pa... |
1696 1697 |
struct gpio_irq_chip *girq; int i; |
6732ae5cb ARM: at91: add pi... |
1698 |
|
35dea5d74 pinctrl: at91: Pa... |
1699 1700 |
gpio_irqchip = devm_kzalloc(&pdev->dev, sizeof(*gpio_irqchip), GFP_KERNEL); |
0c3dfa176 pinctrl: at91: do... |
1701 1702 |
if (!gpio_irqchip) return -ENOMEM; |
6732ae5cb ARM: at91: add pi... |
1703 |
at91_gpio->pioc_hwirq = irqd_to_hwirq(d); |
0c3dfa176 pinctrl: at91: do... |
1704 1705 1706 1707 1708 1709 1710 |
gpio_irqchip->name = "GPIO"; gpio_irqchip->irq_ack = gpio_irq_ack; gpio_irqchip->irq_disable = gpio_irq_mask; gpio_irqchip->irq_mask = gpio_irq_mask; gpio_irqchip->irq_unmask = gpio_irq_unmask; gpio_irqchip->irq_set_wake = gpio_irq_set_wake, gpio_irqchip->irq_set_type = at91_gpio->ops->irq_type; |
6732ae5cb ARM: at91: add pi... |
1711 1712 1713 |
/* Disable irqs of this PIO controller */ writel_relaxed(~0, at91_gpio->regbase + PIO_IDR); |
80cc37329 pinctrl/at91: con... |
1714 1715 1716 1717 1718 |
/* * Let the generic code handle this edge IRQ, the the chained * handler will perform the actual work of handling the parent * interrupt. */ |
35dea5d74 pinctrl: at91: Pa... |
1719 1720 1721 1722 |
girq = &at91_gpio->chip.irq; girq->chip = gpio_irqchip; girq->default_type = IRQ_TYPE_NONE; girq->handler = handle_edge_irq; |
6732ae5cb ARM: at91: add pi... |
1723 |
|
35dea5d74 pinctrl: at91: Pa... |
1724 1725 |
/* * The top level handler handles one bank of GPIOs, except |
cccb0c3e6 pinctrl/at91: Fix... |
1726 1727 1728 |
* on some SoC it can handle up to three... * We only set up the handler for the first of the list. */ |
a0b957f30 pinctrl: at91: al... |
1729 1730 |
gpiochip_prev = irq_get_handler_data(at91_gpio->pioc_virq); if (!gpiochip_prev) { |
35dea5d74 pinctrl: at91: Pa... |
1731 1732 1733 1734 1735 1736 1737 1738 |
girq->parent_handler = gpio_irq_handler; girq->num_parents = 1; girq->parents = devm_kcalloc(&pdev->dev, 1, sizeof(*girq->parents), GFP_KERNEL); if (!girq->parents) return -ENOMEM; girq->parents[0] = at91_gpio->pioc_virq; |
cccb0c3e6 pinctrl/at91: Fix... |
1739 |
return 0; |
a0b957f30 pinctrl: at91: al... |
1740 |
} |
cccb0c3e6 pinctrl/at91: Fix... |
1741 |
|
370ea6113 pinctrl: at91: us... |
1742 |
prev = gpiochip_get_data(gpiochip_prev); |
a0b957f30 pinctrl: at91: al... |
1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 |
/* we can only have 2 banks before */ for (i = 0; i < 2; i++) { if (prev->next) { prev = prev->next; } else { prev->next = at91_gpio; return 0; } } return -EINVAL; |
6732ae5cb ARM: at91: add pi... |
1754 1755 1756 |
} /* This structure is replicated for each GPIO block allocated at probe time */ |
234b6513f pinctrl: at91: Ma... |
1757 |
static const struct gpio_chip at91_gpio_template = { |
98c85d583 pinctrl: replace ... |
1758 1759 |
.request = gpiochip_generic_request, .free = gpiochip_generic_free, |
8af584b86 pinctrl: at91: im... |
1760 |
.get_direction = at91_gpio_get_direction, |
6732ae5cb ARM: at91: add pi... |
1761 1762 1763 1764 |
.direction_input = at91_gpio_direction_input, .get = at91_gpio_get, .direction_output = at91_gpio_direction_output, .set = at91_gpio_set, |
1893b2cfa pinctrl: at91: Ad... |
1765 |
.set_multiple = at91_gpio_set_multiple, |
6732ae5cb ARM: at91: add pi... |
1766 |
.dbg_show = at91_gpio_dbg_show, |
9fb1f39eb gpio/pinctrl: mak... |
1767 |
.can_sleep = false, |
6732ae5cb ARM: at91: add pi... |
1768 1769 |
.ngpio = MAX_NB_GPIO_PER_BANK, }; |
baa9946e3 pinctrl: constify... |
1770 |
static const struct of_device_id at91_gpio_of_match[] = { |
6732ae5cb ARM: at91: add pi... |
1771 1772 |
{ .compatible = "atmel,at91sam9x5-gpio", .data = &at91sam9x5_ops, }, { .compatible = "atmel,at91rm9200-gpio", .data = &at91rm9200_ops }, |
a2fcb1ce8 pinctrl: at91: ad... |
1773 |
{ .compatible = "microchip,sam9x60-gpio", .data = &sam9x60_ops }, |
6732ae5cb ARM: at91: add pi... |
1774 1775 |
{ /* sentinel */ } }; |
150632b09 Drivers: pinctrl:... |
1776 |
static int at91_gpio_probe(struct platform_device *pdev) |
6732ae5cb ARM: at91: add pi... |
1777 1778 |
{ struct device_node *np = pdev->dev.of_node; |
6732ae5cb ARM: at91: add pi... |
1779 1780 1781 1782 |
struct at91_gpio_chip *at91_chip = NULL; struct gpio_chip *chip; struct pinctrl_gpio_range *range; int ret = 0; |
32b01a366 pinctrl: at91: pr... |
1783 |
int irq, i; |
6732ae5cb ARM: at91: add pi... |
1784 1785 |
int alias_idx = of_alias_get_id(np, "gpio"); uint32_t ngpio; |
32b01a366 pinctrl: at91: pr... |
1786 |
char **names; |
6732ae5cb ARM: at91: add pi... |
1787 1788 1789 1790 1791 1792 |
BUG_ON(alias_idx >= ARRAY_SIZE(gpio_chips)); if (gpio_chips[alias_idx]) { ret = -EBUSY; goto err; } |
6732ae5cb ARM: at91: add pi... |
1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 |
irq = platform_get_irq(pdev, 0); if (irq < 0) { ret = irq; goto err; } at91_chip = devm_kzalloc(&pdev->dev, sizeof(*at91_chip), GFP_KERNEL); if (!at91_chip) { ret = -ENOMEM; goto err; } |
4b024225c pinctrl: use devm... |
1804 |
at91_chip->regbase = devm_platform_ioremap_resource(pdev, 0); |
9e0c1fb29 pinctrl: Convert ... |
1805 1806 |
if (IS_ERR(at91_chip->regbase)) { ret = PTR_ERR(at91_chip->regbase); |
6732ae5cb ARM: at91: add pi... |
1807 1808 |
goto err; } |
3c93600d3 pinctrl: at91: Fi... |
1809 |
at91_chip->ops = (struct at91_pinctrl_mux_ops *) |
6732ae5cb ARM: at91: add pi... |
1810 1811 1812 |
of_match_device(at91_gpio_of_match, &pdev->dev)->data; at91_chip->pioc_virq = irq; at91_chip->pioc_idx = alias_idx; |
02b837ffe pinctrl: at91: Sw... |
1813 |
at91_chip->clock = devm_clk_get(&pdev->dev, NULL); |
6732ae5cb ARM: at91: add pi... |
1814 1815 1816 |
if (IS_ERR(at91_chip->clock)) { dev_err(&pdev->dev, "failed to get clock, ignoring. "); |
70e419742 pinctrl: at91: Fi... |
1817 |
ret = PTR_ERR(at91_chip->clock); |
6732ae5cb ARM: at91: add pi... |
1818 1819 |
goto err; } |
7d3a3fe64 pinctrl: at91: Me... |
1820 |
ret = clk_prepare_enable(at91_chip->clock); |
70e419742 pinctrl: at91: Fi... |
1821 |
if (ret) { |
7d3a3fe64 pinctrl: at91: Me... |
1822 1823 |
dev_err(&pdev->dev, "failed to prepare and enable clock, ignoring. "); |
70e419742 pinctrl: at91: Fi... |
1824 |
goto clk_enable_err; |
6732ae5cb ARM: at91: add pi... |
1825 1826 1827 1828 1829 1830 1831 |
} at91_chip->chip = at91_gpio_template; chip = &at91_chip->chip; chip->of_node = np; chip->label = dev_name(&pdev->dev); |
58383c784 gpio: change memb... |
1832 |
chip->parent = &pdev->dev; |
6732ae5cb ARM: at91: add pi... |
1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 |
chip->owner = THIS_MODULE; chip->base = alias_idx * MAX_NB_GPIO_PER_BANK; if (!of_property_read_u32(np, "#gpio-lines", &ngpio)) { if (ngpio >= MAX_NB_GPIO_PER_BANK) pr_err("at91_gpio.%d, gpio-nb >= %d failback to %d ", alias_idx, MAX_NB_GPIO_PER_BANK, MAX_NB_GPIO_PER_BANK); else chip->ngpio = ngpio; } |
a86854d0c treewide: devm_kz... |
1844 |
names = devm_kcalloc(&pdev->dev, chip->ngpio, sizeof(char *), |
3c93600d3 pinctrl: at91: Fi... |
1845 |
GFP_KERNEL); |
32b01a366 pinctrl: at91: pr... |
1846 1847 1848 |
if (!names) { ret = -ENOMEM; |
70e419742 pinctrl: at91: Fi... |
1849 |
goto clk_enable_err; |
32b01a366 pinctrl: at91: pr... |
1850 1851 1852 1853 |
} for (i = 0; i < chip->ngpio; i++) names[i] = kasprintf(GFP_KERNEL, "pio%c%d", alias_idx + 'A', i); |
3c93600d3 pinctrl: at91: Fi... |
1854 |
chip->names = (const char *const *)names; |
32b01a366 pinctrl: at91: pr... |
1855 |
|
6732ae5cb ARM: at91: add pi... |
1856 1857 1858 1859 1860 1861 1862 |
range = &at91_chip->range; range->name = chip->label; range->id = alias_idx; range->pin_base = range->base = range->id * MAX_NB_GPIO_PER_BANK; range->npins = chip->ngpio; range->gc = chip; |
35dea5d74 pinctrl: at91: Pa... |
1863 1864 1865 |
ret = at91_gpio_of_irq_setup(pdev, at91_chip); if (ret) goto gpiochip_add_err; |
370ea6113 pinctrl: at91: us... |
1866 |
ret = gpiochip_add_data(chip, at91_chip); |
6732ae5cb ARM: at91: add pi... |
1867 |
if (ret) |
70e419742 pinctrl: at91: Fi... |
1868 |
goto gpiochip_add_err; |
6732ae5cb ARM: at91: add pi... |
1869 1870 1871 |
gpio_chips[alias_idx] = at91_chip; gpio_banks = max(gpio_banks, alias_idx + 1); |
6732ae5cb ARM: at91: add pi... |
1872 1873 1874 1875 |
dev_info(&pdev->dev, "at address %p ", at91_chip->regbase); return 0; |
70e419742 pinctrl: at91: Fi... |
1876 |
gpiochip_add_err: |
70e419742 pinctrl: at91: Fi... |
1877 |
clk_enable_err: |
7d3a3fe64 pinctrl: at91: Me... |
1878 |
clk_disable_unprepare(at91_chip->clock); |
6732ae5cb ARM: at91: add pi... |
1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 |
err: dev_err(&pdev->dev, "Failure %i for GPIO %i ", ret, alias_idx); return ret; } static struct platform_driver at91_gpio_driver = { .driver = { .name = "gpio-at91", |
606fca94f pinctrl: remove r... |
1889 |
.of_match_table = at91_gpio_of_match, |
6732ae5cb ARM: at91: add pi... |
1890 1891 1892 1893 1894 1895 1896 |
}, .probe = at91_gpio_probe, }; static struct platform_driver at91_pinctrl_driver = { .driver = { .name = "pinctrl-at91", |
606fca94f pinctrl: remove r... |
1897 |
.of_match_table = at91_pinctrl_of_match, |
6732ae5cb ARM: at91: add pi... |
1898 1899 |
}, .probe = at91_pinctrl_probe, |
6732ae5cb ARM: at91: add pi... |
1900 |
}; |
bab7f5a40 pinctrl: at91: Us... |
1901 1902 1903 1904 |
static struct platform_driver * const drivers[] = { &at91_gpio_driver, &at91_pinctrl_driver, }; |
6732ae5cb ARM: at91: add pi... |
1905 1906 |
static int __init at91_pinctrl_init(void) { |
bab7f5a40 pinctrl: at91: Us... |
1907 |
return platform_register_drivers(drivers, ARRAY_SIZE(drivers)); |
6732ae5cb ARM: at91: add pi... |
1908 1909 |
} arch_initcall(at91_pinctrl_init); |