Lines Matching +full:soc +full:- +full:s
1 // SPDX-License-Identifier: GPL-2.0-only
3 * Copyright (C) ST-Ericsson SA 2013
33 #include <linux/pinctrl/pinconf-generic.h>
40 #include "../pinctrl-utils.h"
42 #include "pinctrl-abx500.h"
90 struct abx500_pinctrl_soc_data *soc; member
106 ret = abx500_get_register_interruptible(pct->dev, in abx500_gpio_get_bit()
109 dev_err(pct->dev, in abx500_gpio_get_bit()
110 "%s read reg =%x, offset=%x failed (%d)\n", in abx500_gpio_get_bit()
128 ret = abx500_mask_and_set_register_interruptible(pct->dev, in abx500_gpio_set_bits()
131 dev_err(pct->dev, "%s write reg, %x offset %x failed (%d)\n", in abx500_gpio_set_bits()
138 * abx500_gpio_get() - Get the particular GPIO value
147 u8 gpio_offset = offset - 1; in abx500_gpio_get()
163 dev_err(pct->dev, "%s failed (%d)\n", __func__, ret); in abx500_gpio_get()
177 dev_err(pct->dev, "%s write failed (%d)\n", __func__, ret); in abx500_gpio_set()
203 dev_err(pct->dev, "%s failed (%d)\n", __func__, ret); in abx500_gpio_direction_output()
228 for (i = 0; i < pct->irq_cluster_size; i++) { in abx500_gpio_to_irq()
230 &pct->irq_cluster[i]; in abx500_gpio_to_irq()
232 if (gpio >= cluster->start && gpio <= cluster->end) { in abx500_gpio_to_irq()
234 * The ABx500 GPIO's associated IRQs are clustered together in abx500_gpio_to_irq()
236 * To solve this quandry, we have placed the read-in values in abx500_gpio_to_irq()
239 hwirq = gpio - cluster->start + cluster->to_irq; in abx500_gpio_to_irq()
240 return irq_create_mapping(pct->parent->domain, hwirq); in abx500_gpio_to_irq()
244 return -EINVAL; in abx500_gpio_to_irq()
251 struct alternate_functions af = pct->soc->alternate_functions[gpio]; in abx500_set_mode()
267 dev_dbg(pct->dev, "pin %d doesn't support %s mode\n", gpio, in abx500_set_mode()
269 return -EINVAL; in abx500_set_mode()
273 offset = gpio - 1; in abx500_set_mode()
356 dev_dbg(pct->dev, "unknown alt_setting %d\n", alt_setting); in abx500_set_mode()
358 return -EINVAL; in abx500_set_mode()
362 dev_err(pct->dev, "%s failed (%d)\n", __func__, ret); in abx500_set_mode()
376 struct alternate_functions af = pct->soc->alternate_functions[gpio]; in abx500_get_mode()
378 unsigned offset = gpio - 1; in abx500_get_mode()
399 dev_err(pct->dev, in abx500_get_mode()
400 "alt_bitX value not in correct range (-1 to 7)\n"); in abx500_get_mode()
401 return -EINVAL; in abx500_get_mode()
406 dev_err(pct->dev, in abx500_get_mode()
408 return -EINVAL; in abx500_get_mode()
449 dev_err(pct->dev, "%s failed (%d)\n", __func__, ret); in abx500_get_mode()
453 static void abx500_gpio_dbg_show_one(struct seq_file *s, in abx500_gpio_dbg_show_one() argument
459 u8 gpio_offset = offset - 1; in abx500_gpio_dbg_show_one()
460 int mode = -1; in abx500_gpio_dbg_show_one()
463 int ret = -ENOMEM; in abx500_gpio_dbg_show_one()
479 char *label __free(kfree) = gpiochip_dup_line_label(chip, offset - 1); in abx500_gpio_dbg_show_one()
488 seq_printf(s, " gpio-%-3d (%-20.20s) %-3s", in abx500_gpio_dbg_show_one()
498 seq_printf(s, " %-9s", pull_up_down[pd]); in abx500_gpio_dbg_show_one()
500 seq_printf(s, " %-9s", str_hi_lo(chip->get(chip, offset))); in abx500_gpio_dbg_show_one()
504 seq_printf(s, " %s", (mode < 0) ? "unknown" : modes[mode]); in abx500_gpio_dbg_show_one()
508 dev_err(pct->dev, "%s failed (%d)\n", __func__, ret); in abx500_gpio_dbg_show_one()
511 static void abx500_gpio_dbg_show(struct seq_file *s, struct gpio_chip *chip) in abx500_gpio_dbg_show() argument
514 unsigned gpio = chip->base; in abx500_gpio_dbg_show()
516 struct pinctrl_dev *pctldev = pct->pctldev; in abx500_gpio_dbg_show()
518 for (i = 0; i < chip->ngpio; i++, gpio++) { in abx500_gpio_dbg_show()
520 abx500_gpio_dbg_show_one(s, pctldev, chip, i + 1, gpio); in abx500_gpio_dbg_show()
521 seq_putc(s, '\n'); in abx500_gpio_dbg_show()
526 static inline void abx500_gpio_dbg_show_one(struct seq_file *s, in abx500_gpio_dbg_show_one() argument
536 .label = "abx500-gpio",
552 return pct->soc->nfunctions; in abx500_pmx_get_funcs_cnt()
560 return pct->soc->functions[function].name; in abx500_pmx_get_func_name()
570 *groups = pct->soc->functions[function].groups; in abx500_pmx_get_func_groups()
571 *num_groups = pct->soc->functions[function].ngroups; in abx500_pmx_get_func_groups()
580 struct gpio_chip *chip = &pct->chip; in abx500_pmx_set()
585 g = &pct->soc->groups[group]; in abx500_pmx_set()
586 if (g->altsetting < 0) in abx500_pmx_set()
587 return -EINVAL; in abx500_pmx_set()
589 dev_dbg(pct->dev, "enable group %s, %u pins\n", g->name, g->npins); in abx500_pmx_set()
591 for (i = 0; i < g->npins; i++) { in abx500_pmx_set()
592 dev_dbg(pct->dev, "setting pin %d to altsetting %d\n", in abx500_pmx_set()
593 g->pins[i], g->altsetting); in abx500_pmx_set()
595 ret = abx500_set_mode(pctldev, chip, g->pins[i], g->altsetting); in abx500_pmx_set()
599 dev_err(pct->dev, "%s failed (%d)\n", __func__, ret); in abx500_pmx_set()
618 for (i = 0; i < pct->soc->gpio_num_ranges; i++) { in abx500_gpio_request_enable()
619 p = &pct->soc->gpio_ranges[i]; in abx500_gpio_request_enable()
620 if ((offset >= p->offset) && in abx500_gpio_request_enable()
621 (offset < (p->offset + p->npins))) in abx500_gpio_request_enable()
625 if (i == pct->soc->gpio_num_ranges) { in abx500_gpio_request_enable()
626 dev_err(pct->dev, "%s failed to locate range\n", __func__); in abx500_gpio_request_enable()
627 return -ENODEV; in abx500_gpio_request_enable()
630 dev_dbg(pct->dev, "enable GPIO by altfunc %d at gpio %d\n", in abx500_gpio_request_enable()
631 p->altfunc, offset); in abx500_gpio_request_enable()
633 ret = abx500_set_mode(pct->pctldev, &pct->chip, in abx500_gpio_request_enable()
634 offset, p->altfunc); in abx500_gpio_request_enable()
636 dev_err(pct->dev, "%s setting altfunc failed\n", __func__); in abx500_gpio_request_enable()
660 return pct->soc->ngroups; in abx500_get_groups_cnt()
668 return pct->soc->groups[selector].name; in abx500_get_group_name()
678 *pins = pct->soc->groups[selector].pins; in abx500_get_group_pins()
679 *num_pins = pct->soc->groups[selector].npins; in abx500_get_group_pins()
685 struct seq_file *s, unsigned offset) in abx500_pin_dbg_show() argument
688 struct gpio_chip *chip = &pct->chip; in abx500_pin_dbg_show()
690 abx500_gpio_dbg_show_one(s, pctldev, chip, offset, in abx500_pin_dbg_show()
691 chip->base + offset - 1); in abx500_pin_dbg_show()
700 return -ENOSPC; in abx500_dt_add_map_mux()
718 return -ENOSPC; in abx500_dt_add_map_configs()
722 return -ENOMEM; in abx500_dt_add_map_configs()
741 for (i = 0; i < npct->soc->npins; i++) in abx500_find_pin_name()
742 if (npct->soc->pins[i].number == pin_number) in abx500_find_pin_name()
743 return npct->soc->pins[i].name; in abx500_find_pin_name()
845 return -ENOSYS; in abx500_pin_config_get()
854 struct gpio_chip *chip = &pct->chip; in abx500_pin_config_set()
856 int ret = -EINVAL; in abx500_pin_config_set()
865 dev_dbg(chip->parent, "pin %d [%#lx]: %s %s\n", in abx500_pin_config_set()
873 offset = pin - 1; in abx500_pin_config_set()
920 dev_err(chip->parent, in abx500_pin_config_set()
926 dev_err(pct->dev, "%s failed (%d)\n", __func__, ret); in abx500_pin_config_set()
938 .name = "pinctrl-abx500",
945 static int abx500_get_gpio_num(struct abx500_pinctrl_soc_data *soc) in abx500_get_gpio_num() argument
953 * Compute number of GPIOs from the last SoC gpio range descriptors in abx500_get_gpio_num()
958 for (i = 0; i < soc->gpio_num_ranges; i++) { in abx500_get_gpio_num()
963 p = &soc->gpio_ranges[i]; in abx500_get_gpio_num()
964 gstart = p->offset; in abx500_get_gpio_num()
965 gend = p->offset + p->npins - 1; in abx500_get_gpio_num()
979 npins = highest - lowest + 1; in abx500_get_gpio_num()
984 { .compatible = "stericsson,ab8500-gpio", .data = (void *)PINCTRL_AB8500, },
985 { .compatible = "stericsson,ab8505-gpio", .data = (void *)PINCTRL_AB8505, },
991 struct device_node *np = pdev->dev.of_node; in abx500_gpio_probe()
993 unsigned int id = -1; in abx500_gpio_probe()
998 dev_err(&pdev->dev, "gpio dt node missing\n"); in abx500_gpio_probe()
999 return -ENODEV; in abx500_gpio_probe()
1002 pct = devm_kzalloc(&pdev->dev, sizeof(*pct), GFP_KERNEL); in abx500_gpio_probe()
1004 return -ENOMEM; in abx500_gpio_probe()
1006 pct->dev = &pdev->dev; in abx500_gpio_probe()
1007 pct->parent = dev_get_drvdata(pdev->dev.parent); in abx500_gpio_probe()
1008 pct->chip = abx500gpio_chip; in abx500_gpio_probe()
1009 pct->chip.parent = &pdev->dev; in abx500_gpio_probe()
1010 pct->chip.base = -1; /* Dynamic allocation */ in abx500_gpio_probe()
1012 id = (unsigned long)device_get_match_data(&pdev->dev); in abx500_gpio_probe()
1017 abx500_pinctrl_ab8500_init(&pct->soc); in abx500_gpio_probe()
1020 abx500_pinctrl_ab8505_init(&pct->soc); in abx500_gpio_probe()
1023 dev_err(&pdev->dev, "Unsupported pinctrl sub driver (%d)\n", id); in abx500_gpio_probe()
1024 return -EINVAL; in abx500_gpio_probe()
1027 if (!pct->soc) { in abx500_gpio_probe()
1028 dev_err(&pdev->dev, "Invalid SOC data\n"); in abx500_gpio_probe()
1029 return -EINVAL; in abx500_gpio_probe()
1032 pct->chip.ngpio = abx500_get_gpio_num(pct->soc); in abx500_gpio_probe()
1033 pct->irq_cluster = pct->soc->gpio_irq_cluster; in abx500_gpio_probe()
1034 pct->irq_cluster_size = pct->soc->ngpio_irq_cluster; in abx500_gpio_probe()
1036 ret = gpiochip_add_data(&pct->chip, pct); in abx500_gpio_probe()
1038 dev_err(&pdev->dev, "unable to add gpiochip: %d\n", ret); in abx500_gpio_probe()
1041 dev_info(&pdev->dev, "added gpiochip\n"); in abx500_gpio_probe()
1043 abx500_pinctrl_desc.pins = pct->soc->pins; in abx500_gpio_probe()
1044 abx500_pinctrl_desc.npins = pct->soc->npins; in abx500_gpio_probe()
1045 pct->pctldev = devm_pinctrl_register(&pdev->dev, &abx500_pinctrl_desc, in abx500_gpio_probe()
1047 if (IS_ERR(pct->pctldev)) { in abx500_gpio_probe()
1048 dev_err(&pdev->dev, in abx500_gpio_probe()
1050 ret = PTR_ERR(pct->pctldev); in abx500_gpio_probe()
1053 dev_info(&pdev->dev, "registered pin controller\n"); in abx500_gpio_probe()
1056 for (i = 0; i < pct->soc->gpio_num_ranges; i++) { in abx500_gpio_probe()
1057 const struct abx500_pinrange *p = &pct->soc->gpio_ranges[i]; in abx500_gpio_probe()
1059 ret = gpiochip_add_pin_range(&pct->chip, in abx500_gpio_probe()
1060 dev_name(&pdev->dev), in abx500_gpio_probe()
1061 p->offset - 1, p->offset, p->npins); in abx500_gpio_probe()
1067 dev_info(&pdev->dev, "initialized abx500 pinctrl driver\n"); in abx500_gpio_probe()
1072 gpiochip_remove(&pct->chip); in abx500_gpio_probe()
1077 * abx500_gpio_remove() - remove Ab8500-gpio driver
1084 gpiochip_remove(&pct->chip); in abx500_gpio_remove()
1089 .name = "abx500-gpio",