Lines Matching +full:soc +full:- +full:s

1 // SPDX-License-Identifier: GPL-2.0-only
3 * Copyright (C) ST-Ericsson SA 2013
32 #include <linux/pinctrl/pinconf-generic.h>
39 #include "../pinctrl-utils.h"
41 #include "pinctrl-abx500.h"
89 struct abx500_pinctrl_soc_data *soc; member
105 ret = abx500_get_register_interruptible(pct->dev, in abx500_gpio_get_bit()
108 dev_err(pct->dev, in abx500_gpio_get_bit()
109 "%s read reg =%x, offset=%x failed (%d)\n", in abx500_gpio_get_bit()
127 ret = abx500_mask_and_set_register_interruptible(pct->dev, in abx500_gpio_set_bits()
130 dev_err(pct->dev, "%s write reg, %x offset %x failed (%d)\n", in abx500_gpio_set_bits()
137 * abx500_gpio_get() - Get the particular GPIO value
146 u8 gpio_offset = offset - 1; in abx500_gpio_get()
162 dev_err(pct->dev, "%s failed (%d)\n", __func__, ret); in abx500_gpio_get()
176 dev_err(pct->dev, "%s write failed (%d)\n", __func__, ret); in abx500_gpio_set()
202 dev_err(pct->dev, "%s failed (%d)\n", __func__, ret); in abx500_gpio_direction_output()
227 for (i = 0; i < pct->irq_cluster_size; i++) { in abx500_gpio_to_irq()
229 &pct->irq_cluster[i]; in abx500_gpio_to_irq()
231 if (gpio >= cluster->start && gpio <= cluster->end) { in abx500_gpio_to_irq()
233 * The ABx500 GPIO's associated IRQs are clustered together in abx500_gpio_to_irq()
235 * To solve this quandry, we have placed the read-in values in abx500_gpio_to_irq()
238 hwirq = gpio - cluster->start + cluster->to_irq; in abx500_gpio_to_irq()
239 return irq_create_mapping(pct->parent->domain, hwirq); in abx500_gpio_to_irq()
243 return -EINVAL; in abx500_gpio_to_irq()
250 struct alternate_functions af = pct->soc->alternate_functions[gpio]; in abx500_set_mode()
266 dev_dbg(pct->dev, "pin %d doesn't support %s mode\n", gpio, in abx500_set_mode()
268 return -EINVAL; in abx500_set_mode()
272 offset = gpio - 1; in abx500_set_mode()
355 dev_dbg(pct->dev, "unknown alt_setting %d\n", alt_setting); in abx500_set_mode()
357 return -EINVAL; in abx500_set_mode()
361 dev_err(pct->dev, "%s failed (%d)\n", __func__, ret); in abx500_set_mode()
375 struct alternate_functions af = pct->soc->alternate_functions[gpio]; in abx500_get_mode()
377 unsigned offset = gpio - 1; in abx500_get_mode()
398 dev_err(pct->dev, in abx500_get_mode()
399 "alt_bitX value not in correct range (-1 to 7)\n"); in abx500_get_mode()
400 return -EINVAL; in abx500_get_mode()
405 dev_err(pct->dev, in abx500_get_mode()
407 return -EINVAL; in abx500_get_mode()
448 dev_err(pct->dev, "%s failed (%d)\n", __func__, ret); in abx500_get_mode()
452 static void abx500_gpio_dbg_show_one(struct seq_file *s, in abx500_gpio_dbg_show_one() argument
458 u8 gpio_offset = offset - 1; in abx500_gpio_dbg_show_one()
459 int mode = -1; in abx500_gpio_dbg_show_one()
462 int ret = -ENOMEM; in abx500_gpio_dbg_show_one()
478 char *label __free(kfree) = gpiochip_dup_line_label(chip, offset - 1); in abx500_gpio_dbg_show_one()
487 seq_printf(s, " gpio-%-3d (%-20.20s) %-3s", in abx500_gpio_dbg_show_one()
497 seq_printf(s, " %-9s", pull_up_down[pd]); in abx500_gpio_dbg_show_one()
499 seq_printf(s, " %-9s", chip->get(chip, offset) ? "hi" : "lo"); in abx500_gpio_dbg_show_one()
503 seq_printf(s, " %s", (mode < 0) ? "unknown" : modes[mode]); in abx500_gpio_dbg_show_one()
507 dev_err(pct->dev, "%s failed (%d)\n", __func__, ret); in abx500_gpio_dbg_show_one()
510 static void abx500_gpio_dbg_show(struct seq_file *s, struct gpio_chip *chip) in abx500_gpio_dbg_show() argument
513 unsigned gpio = chip->base; in abx500_gpio_dbg_show()
515 struct pinctrl_dev *pctldev = pct->pctldev; in abx500_gpio_dbg_show()
517 for (i = 0; i < chip->ngpio; i++, gpio++) { in abx500_gpio_dbg_show()
519 abx500_gpio_dbg_show_one(s, pctldev, chip, i + 1, gpio); in abx500_gpio_dbg_show()
520 seq_putc(s, '\n'); in abx500_gpio_dbg_show()
525 static inline void abx500_gpio_dbg_show_one(struct seq_file *s, in abx500_gpio_dbg_show_one() argument
535 .label = "abx500-gpio",
551 return pct->soc->nfunctions; in abx500_pmx_get_funcs_cnt()
559 return pct->soc->functions[function].name; in abx500_pmx_get_func_name()
569 *groups = pct->soc->functions[function].groups; in abx500_pmx_get_func_groups()
570 *num_groups = pct->soc->functions[function].ngroups; in abx500_pmx_get_func_groups()
579 struct gpio_chip *chip = &pct->chip; in abx500_pmx_set()
584 g = &pct->soc->groups[group]; in abx500_pmx_set()
585 if (g->altsetting < 0) in abx500_pmx_set()
586 return -EINVAL; in abx500_pmx_set()
588 dev_dbg(pct->dev, "enable group %s, %u pins\n", g->name, g->npins); in abx500_pmx_set()
590 for (i = 0; i < g->npins; i++) { in abx500_pmx_set()
591 dev_dbg(pct->dev, "setting pin %d to altsetting %d\n", in abx500_pmx_set()
592 g->pins[i], g->altsetting); in abx500_pmx_set()
594 ret = abx500_set_mode(pctldev, chip, g->pins[i], g->altsetting); in abx500_pmx_set()
598 dev_err(pct->dev, "%s failed (%d)\n", __func__, ret); in abx500_pmx_set()
617 for (i = 0; i < pct->soc->gpio_num_ranges; i++) { in abx500_gpio_request_enable()
618 p = &pct->soc->gpio_ranges[i]; in abx500_gpio_request_enable()
619 if ((offset >= p->offset) && in abx500_gpio_request_enable()
620 (offset < (p->offset + p->npins))) in abx500_gpio_request_enable()
624 if (i == pct->soc->gpio_num_ranges) { in abx500_gpio_request_enable()
625 dev_err(pct->dev, "%s failed to locate range\n", __func__); in abx500_gpio_request_enable()
626 return -ENODEV; in abx500_gpio_request_enable()
629 dev_dbg(pct->dev, "enable GPIO by altfunc %d at gpio %d\n", in abx500_gpio_request_enable()
630 p->altfunc, offset); in abx500_gpio_request_enable()
632 ret = abx500_set_mode(pct->pctldev, &pct->chip, in abx500_gpio_request_enable()
633 offset, p->altfunc); in abx500_gpio_request_enable()
635 dev_err(pct->dev, "%s setting altfunc failed\n", __func__); in abx500_gpio_request_enable()
659 return pct->soc->ngroups; in abx500_get_groups_cnt()
667 return pct->soc->groups[selector].name; in abx500_get_group_name()
677 *pins = pct->soc->groups[selector].pins; in abx500_get_group_pins()
678 *num_pins = pct->soc->groups[selector].npins; in abx500_get_group_pins()
684 struct seq_file *s, unsigned offset) in abx500_pin_dbg_show() argument
687 struct gpio_chip *chip = &pct->chip; in abx500_pin_dbg_show()
689 abx500_gpio_dbg_show_one(s, pctldev, chip, offset, in abx500_pin_dbg_show()
690 chip->base + offset - 1); in abx500_pin_dbg_show()
699 return -ENOSPC; in abx500_dt_add_map_mux()
717 return -ENOSPC; in abx500_dt_add_map_configs()
721 return -ENOMEM; in abx500_dt_add_map_configs()
740 for (i = 0; i < npct->soc->npins; i++) in abx500_find_pin_name()
741 if (npct->soc->pins[i].number == pin_number) in abx500_find_pin_name()
742 return npct->soc->pins[i].name; in abx500_find_pin_name()
844 return -ENOSYS; in abx500_pin_config_get()
853 struct gpio_chip *chip = &pct->chip; in abx500_pin_config_set()
855 int ret = -EINVAL; in abx500_pin_config_set()
864 dev_dbg(chip->parent, "pin %d [%#lx]: %s %s\n", in abx500_pin_config_set()
872 offset = pin - 1; in abx500_pin_config_set()
919 dev_err(chip->parent, in abx500_pin_config_set()
925 dev_err(pct->dev, "%s failed (%d)\n", __func__, ret); in abx500_pin_config_set()
937 .name = "pinctrl-abx500",
944 static int abx500_get_gpio_num(struct abx500_pinctrl_soc_data *soc) in abx500_get_gpio_num() argument
952 * Compute number of GPIOs from the last SoC gpio range descriptors in abx500_get_gpio_num()
957 for (i = 0; i < soc->gpio_num_ranges; i++) { in abx500_get_gpio_num()
962 p = &soc->gpio_ranges[i]; in abx500_get_gpio_num()
963 gstart = p->offset; in abx500_get_gpio_num()
964 gend = p->offset + p->npins - 1; in abx500_get_gpio_num()
978 npins = highest - lowest + 1; in abx500_get_gpio_num()
983 { .compatible = "stericsson,ab8500-gpio", .data = (void *)PINCTRL_AB8500, },
984 { .compatible = "stericsson,ab8505-gpio", .data = (void *)PINCTRL_AB8505, },
990 struct device_node *np = pdev->dev.of_node; in abx500_gpio_probe()
992 unsigned int id = -1; in abx500_gpio_probe()
997 dev_err(&pdev->dev, "gpio dt node missing\n"); in abx500_gpio_probe()
998 return -ENODEV; in abx500_gpio_probe()
1001 pct = devm_kzalloc(&pdev->dev, sizeof(*pct), GFP_KERNEL); in abx500_gpio_probe()
1003 return -ENOMEM; in abx500_gpio_probe()
1005 pct->dev = &pdev->dev; in abx500_gpio_probe()
1006 pct->parent = dev_get_drvdata(pdev->dev.parent); in abx500_gpio_probe()
1007 pct->chip = abx500gpio_chip; in abx500_gpio_probe()
1008 pct->chip.parent = &pdev->dev; in abx500_gpio_probe()
1009 pct->chip.base = -1; /* Dynamic allocation */ in abx500_gpio_probe()
1011 id = (unsigned long)device_get_match_data(&pdev->dev); in abx500_gpio_probe()
1016 abx500_pinctrl_ab8500_init(&pct->soc); in abx500_gpio_probe()
1019 abx500_pinctrl_ab8505_init(&pct->soc); in abx500_gpio_probe()
1022 dev_err(&pdev->dev, "Unsupported pinctrl sub driver (%d)\n", id); in abx500_gpio_probe()
1023 return -EINVAL; in abx500_gpio_probe()
1026 if (!pct->soc) { in abx500_gpio_probe()
1027 dev_err(&pdev->dev, "Invalid SOC data\n"); in abx500_gpio_probe()
1028 return -EINVAL; in abx500_gpio_probe()
1031 pct->chip.ngpio = abx500_get_gpio_num(pct->soc); in abx500_gpio_probe()
1032 pct->irq_cluster = pct->soc->gpio_irq_cluster; in abx500_gpio_probe()
1033 pct->irq_cluster_size = pct->soc->ngpio_irq_cluster; in abx500_gpio_probe()
1035 ret = gpiochip_add_data(&pct->chip, pct); in abx500_gpio_probe()
1037 dev_err(&pdev->dev, "unable to add gpiochip: %d\n", ret); in abx500_gpio_probe()
1040 dev_info(&pdev->dev, "added gpiochip\n"); in abx500_gpio_probe()
1042 abx500_pinctrl_desc.pins = pct->soc->pins; in abx500_gpio_probe()
1043 abx500_pinctrl_desc.npins = pct->soc->npins; in abx500_gpio_probe()
1044 pct->pctldev = devm_pinctrl_register(&pdev->dev, &abx500_pinctrl_desc, in abx500_gpio_probe()
1046 if (IS_ERR(pct->pctldev)) { in abx500_gpio_probe()
1047 dev_err(&pdev->dev, in abx500_gpio_probe()
1049 ret = PTR_ERR(pct->pctldev); in abx500_gpio_probe()
1052 dev_info(&pdev->dev, "registered pin controller\n"); in abx500_gpio_probe()
1055 for (i = 0; i < pct->soc->gpio_num_ranges; i++) { in abx500_gpio_probe()
1056 const struct abx500_pinrange *p = &pct->soc->gpio_ranges[i]; in abx500_gpio_probe()
1058 ret = gpiochip_add_pin_range(&pct->chip, in abx500_gpio_probe()
1059 dev_name(&pdev->dev), in abx500_gpio_probe()
1060 p->offset - 1, p->offset, p->npins); in abx500_gpio_probe()
1066 dev_info(&pdev->dev, "initialized abx500 pinctrl driver\n"); in abx500_gpio_probe()
1071 gpiochip_remove(&pct->chip); in abx500_gpio_probe()
1076 * abx500_gpio_remove() - remove Ab8500-gpio driver
1083 gpiochip_remove(&pct->chip); in abx500_gpio_remove()
1088 .name = "abx500-gpio",