aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/pinctrl/pinctrl-xway.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/pinctrl/pinctrl-xway.c')
-rw-r--r--drivers/pinctrl/pinctrl-xway.c60
1 files changed, 46 insertions, 14 deletions
diff --git a/drivers/pinctrl/pinctrl-xway.c b/drivers/pinctrl/pinctrl-xway.c
index 5f0eb04c2336..53cb6a3a56ed 100644
--- a/drivers/pinctrl/pinctrl-xway.c
+++ b/drivers/pinctrl/pinctrl-xway.c
@@ -441,17 +441,17 @@ static int xway_pinconf_get(struct pinctrl_dev *pctldev,
441 if (port == PORT3) 441 if (port == PORT3)
442 reg = GPIO3_OD; 442 reg = GPIO3_OD;
443 else 443 else
444 reg = GPIO_OD(port); 444 reg = GPIO_OD(pin);
445 *config = LTQ_PINCONF_PACK(param, 445 *config = LTQ_PINCONF_PACK(param,
446 !!gpio_getbit(info->membase[0], reg, PORT_PIN(port))); 446 !gpio_getbit(info->membase[0], reg, PORT_PIN(pin)));
447 break; 447 break;
448 448
449 case LTQ_PINCONF_PARAM_PULL: 449 case LTQ_PINCONF_PARAM_PULL:
450 if (port == PORT3) 450 if (port == PORT3)
451 reg = GPIO3_PUDEN; 451 reg = GPIO3_PUDEN;
452 else 452 else
453 reg = GPIO_PUDEN(port); 453 reg = GPIO_PUDEN(pin);
454 if (!gpio_getbit(info->membase[0], reg, PORT_PIN(port))) { 454 if (!gpio_getbit(info->membase[0], reg, PORT_PIN(pin))) {
455 *config = LTQ_PINCONF_PACK(param, 0); 455 *config = LTQ_PINCONF_PACK(param, 0);
456 break; 456 break;
457 } 457 }
@@ -459,13 +459,18 @@ static int xway_pinconf_get(struct pinctrl_dev *pctldev,
459 if (port == PORT3) 459 if (port == PORT3)
460 reg = GPIO3_PUDSEL; 460 reg = GPIO3_PUDSEL;
461 else 461 else
462 reg = GPIO_PUDSEL(port); 462 reg = GPIO_PUDSEL(pin);
463 if (!gpio_getbit(info->membase[0], reg, PORT_PIN(port))) 463 if (!gpio_getbit(info->membase[0], reg, PORT_PIN(pin)))
464 *config = LTQ_PINCONF_PACK(param, 2); 464 *config = LTQ_PINCONF_PACK(param, 2);
465 else 465 else
466 *config = LTQ_PINCONF_PACK(param, 1); 466 *config = LTQ_PINCONF_PACK(param, 1);
467 break; 467 break;
468 468
469 case LTQ_PINCONF_PARAM_OUTPUT:
470 reg = GPIO_DIR(pin);
471 *config = LTQ_PINCONF_PACK(param,
472 gpio_getbit(info->membase[0], reg, PORT_PIN(pin)));
473 break;
469 default: 474 default:
470 dev_err(pctldev->dev, "Invalid config param %04x\n", param); 475 dev_err(pctldev->dev, "Invalid config param %04x\n", param);
471 return -ENOTSUPP; 476 return -ENOTSUPP;
@@ -488,33 +493,44 @@ static int xway_pinconf_set(struct pinctrl_dev *pctldev,
488 if (port == PORT3) 493 if (port == PORT3)
489 reg = GPIO3_OD; 494 reg = GPIO3_OD;
490 else 495 else
491 reg = GPIO_OD(port); 496 reg = GPIO_OD(pin);
492 gpio_setbit(info->membase[0], reg, PORT_PIN(port)); 497 if (arg == 0)
498 gpio_setbit(info->membase[0], reg, PORT_PIN(pin));
499 else
500 gpio_clearbit(info->membase[0], reg, PORT_PIN(pin));
493 break; 501 break;
494 502
495 case LTQ_PINCONF_PARAM_PULL: 503 case LTQ_PINCONF_PARAM_PULL:
496 if (port == PORT3) 504 if (port == PORT3)
497 reg = GPIO3_PUDEN; 505 reg = GPIO3_PUDEN;
498 else 506 else
499 reg = GPIO_PUDEN(port); 507 reg = GPIO_PUDEN(pin);
500 if (arg == 0) { 508 if (arg == 0) {
501 gpio_clearbit(info->membase[0], reg, PORT_PIN(port)); 509 gpio_clearbit(info->membase[0], reg, PORT_PIN(pin));
502 break; 510 break;
503 } 511 }
504 gpio_setbit(info->membase[0], reg, PORT_PIN(port)); 512 gpio_setbit(info->membase[0], reg, PORT_PIN(pin));
505 513
506 if (port == PORT3) 514 if (port == PORT3)
507 reg = GPIO3_PUDSEL; 515 reg = GPIO3_PUDSEL;
508 else 516 else
509 reg = GPIO_PUDSEL(port); 517 reg = GPIO_PUDSEL(pin);
510 if (arg == 1) 518 if (arg == 1)
511 gpio_clearbit(info->membase[0], reg, PORT_PIN(port)); 519 gpio_clearbit(info->membase[0], reg, PORT_PIN(pin));
512 else if (arg == 2) 520 else if (arg == 2)
513 gpio_setbit(info->membase[0], reg, PORT_PIN(port)); 521 gpio_setbit(info->membase[0], reg, PORT_PIN(pin));
514 else 522 else
515 dev_err(pctldev->dev, "Invalid pull value %d\n", arg); 523 dev_err(pctldev->dev, "Invalid pull value %d\n", arg);
516 break; 524 break;
517 525
526 case LTQ_PINCONF_PARAM_OUTPUT:
527 reg = GPIO_DIR(pin);
528 if (arg == 0)
529 gpio_clearbit(info->membase[0], reg, PORT_PIN(pin));
530 else
531 gpio_setbit(info->membase[0], reg, PORT_PIN(pin));
532 break;
533
518 default: 534 default:
519 dev_err(pctldev->dev, "Invalid config param %04x\n", param); 535 dev_err(pctldev->dev, "Invalid config param %04x\n", param);
520 return -ENOTSUPP; 536 return -ENOTSUPP;
@@ -522,9 +538,24 @@ static int xway_pinconf_set(struct pinctrl_dev *pctldev,
522 return 0; 538 return 0;
523} 539}
524 540
541int xway_pinconf_group_set(struct pinctrl_dev *pctldev,
542 unsigned selector,
543 unsigned long config)
544{
545 struct ltq_pinmux_info *info = pinctrl_dev_get_drvdata(pctldev);
546 int i, ret = 0;
547
548 for (i = 0; i < info->grps[selector].npins && !ret; i++)
549 ret = xway_pinconf_set(pctldev,
550 info->grps[selector].pins[i], config);
551
552 return ret;
553}
554
525static struct pinconf_ops xway_pinconf_ops = { 555static struct pinconf_ops xway_pinconf_ops = {
526 .pin_config_get = xway_pinconf_get, 556 .pin_config_get = xway_pinconf_get,
527 .pin_config_set = xway_pinconf_set, 557 .pin_config_set = xway_pinconf_set,
558 .pin_config_group_set = xway_pinconf_group_set,
528}; 559};
529 560
530static struct pinctrl_desc xway_pctrl_desc = { 561static struct pinctrl_desc xway_pctrl_desc = {
@@ -558,6 +589,7 @@ static inline int xway_mux_apply(struct pinctrl_dev *pctrldev,
558static const struct ltq_cfg_param xway_cfg_params[] = { 589static const struct ltq_cfg_param xway_cfg_params[] = {
559 {"lantiq,pull", LTQ_PINCONF_PARAM_PULL}, 590 {"lantiq,pull", LTQ_PINCONF_PARAM_PULL},
560 {"lantiq,open-drain", LTQ_PINCONF_PARAM_OPEN_DRAIN}, 591 {"lantiq,open-drain", LTQ_PINCONF_PARAM_OPEN_DRAIN},
592 {"lantiq,output", LTQ_PINCONF_PARAM_OUTPUT},
561}; 593};
562 594
563static struct ltq_pinmux_info xway_info = { 595static struct ltq_pinmux_info xway_info = {