Lines Matching +full:soc +full:- +full:s
1 // SPDX-License-Identifier: GPL-2.0-only
3 * Copyright (C) ST-Ericsson SA 2013
28 #include <linux/pinctrl/pinconf-generic.h>
31 #include "pinctrl-abx500.h"
34 #include "../pinctrl-utils.h"
82 struct abx500_pinctrl_soc_data *soc; member
98 ret = abx500_get_register_interruptible(pct->dev, in abx500_gpio_get_bit()
101 dev_err(pct->dev, in abx500_gpio_get_bit()
102 "%s read reg =%x, offset=%x failed (%d)\n", in abx500_gpio_get_bit()
120 ret = abx500_mask_and_set_register_interruptible(pct->dev, in abx500_gpio_set_bits()
123 dev_err(pct->dev, "%s write reg, %x offset %x failed (%d)\n", in abx500_gpio_set_bits()
130 * abx500_gpio_get() - Get the particular GPIO value
139 u8 gpio_offset = offset - 1; in abx500_gpio_get()
155 dev_err(pct->dev, "%s failed (%d)\n", __func__, ret); in abx500_gpio_get()
169 dev_err(pct->dev, "%s write failed (%d)\n", __func__, ret); in abx500_gpio_set()
195 dev_err(pct->dev, "%s failed (%d)\n", __func__, ret); in abx500_gpio_direction_output()
220 for (i = 0; i < pct->irq_cluster_size; i++) { in abx500_gpio_to_irq()
222 &pct->irq_cluster[i]; in abx500_gpio_to_irq()
224 if (gpio >= cluster->start && gpio <= cluster->end) { in abx500_gpio_to_irq()
226 * The ABx500 GPIO's associated IRQs are clustered together in abx500_gpio_to_irq()
228 * To solve this quandry, we have placed the read-in values in abx500_gpio_to_irq()
231 hwirq = gpio - cluster->start + cluster->to_irq; in abx500_gpio_to_irq()
232 return irq_create_mapping(pct->parent->domain, hwirq); in abx500_gpio_to_irq()
236 return -EINVAL; in abx500_gpio_to_irq()
243 struct alternate_functions af = pct->soc->alternate_functions[gpio]; in abx500_set_mode()
259 dev_dbg(pct->dev, "pin %d doesn't support %s mode\n", gpio, in abx500_set_mode()
261 return -EINVAL; in abx500_set_mode()
265 offset = gpio - 1; in abx500_set_mode()
348 dev_dbg(pct->dev, "unknown alt_setting %d\n", alt_setting); in abx500_set_mode()
350 return -EINVAL; in abx500_set_mode()
354 dev_err(pct->dev, "%s failed (%d)\n", __func__, ret); in abx500_set_mode()
368 struct alternate_functions af = pct->soc->alternate_functions[gpio]; in abx500_get_mode()
370 unsigned offset = gpio - 1; in abx500_get_mode()
391 dev_err(pct->dev, in abx500_get_mode()
392 "alt_bitX value not in correct range (-1 to 7)\n"); in abx500_get_mode()
393 return -EINVAL; in abx500_get_mode()
398 dev_err(pct->dev, in abx500_get_mode()
400 return -EINVAL; in abx500_get_mode()
441 dev_err(pct->dev, "%s failed (%d)\n", __func__, ret); in abx500_get_mode()
447 static void abx500_gpio_dbg_show_one(struct seq_file *s, in abx500_gpio_dbg_show_one() argument
453 const char *label = gpiochip_is_requested(chip, offset - 1); in abx500_gpio_dbg_show_one()
454 u8 gpio_offset = offset - 1; in abx500_gpio_dbg_show_one()
455 int mode = -1; in abx500_gpio_dbg_show_one()
479 seq_printf(s, " gpio-%-3d (%-20.20s) %-3s", in abx500_gpio_dbg_show_one()
489 seq_printf(s, " %-9s", pull_up_down[pd]); in abx500_gpio_dbg_show_one()
491 seq_printf(s, " %-9s", chip->get(chip, offset) ? "hi" : "lo"); in abx500_gpio_dbg_show_one()
495 seq_printf(s, " %s", (mode < 0) ? "unknown" : modes[mode]); in abx500_gpio_dbg_show_one()
499 dev_err(pct->dev, "%s failed (%d)\n", __func__, ret); in abx500_gpio_dbg_show_one()
502 static void abx500_gpio_dbg_show(struct seq_file *s, struct gpio_chip *chip) in abx500_gpio_dbg_show() argument
505 unsigned gpio = chip->base; in abx500_gpio_dbg_show()
507 struct pinctrl_dev *pctldev = pct->pctldev; in abx500_gpio_dbg_show()
509 for (i = 0; i < chip->ngpio; i++, gpio++) { in abx500_gpio_dbg_show()
511 abx500_gpio_dbg_show_one(s, pctldev, chip, i + 1, gpio); in abx500_gpio_dbg_show()
512 seq_putc(s, '\n'); in abx500_gpio_dbg_show()
517 static inline void abx500_gpio_dbg_show_one(struct seq_file *s, in abx500_gpio_dbg_show_one() argument
527 .label = "abx500-gpio",
543 return pct->soc->nfunctions; in abx500_pmx_get_funcs_cnt()
551 return pct->soc->functions[function].name; in abx500_pmx_get_func_name()
561 *groups = pct->soc->functions[function].groups; in abx500_pmx_get_func_groups()
562 *num_groups = pct->soc->functions[function].ngroups; in abx500_pmx_get_func_groups()
571 struct gpio_chip *chip = &pct->chip; in abx500_pmx_set()
576 g = &pct->soc->groups[group]; in abx500_pmx_set()
577 if (g->altsetting < 0) in abx500_pmx_set()
578 return -EINVAL; in abx500_pmx_set()
580 dev_dbg(pct->dev, "enable group %s, %u pins\n", g->name, g->npins); in abx500_pmx_set()
582 for (i = 0; i < g->npins; i++) { in abx500_pmx_set()
583 dev_dbg(pct->dev, "setting pin %d to altsetting %d\n", in abx500_pmx_set()
584 g->pins[i], g->altsetting); in abx500_pmx_set()
586 ret = abx500_set_mode(pctldev, chip, g->pins[i], g->altsetting); in abx500_pmx_set()
590 dev_err(pct->dev, "%s failed (%d)\n", __func__, ret); in abx500_pmx_set()
609 for (i = 0; i < pct->soc->gpio_num_ranges; i++) { in abx500_gpio_request_enable()
610 p = &pct->soc->gpio_ranges[i]; in abx500_gpio_request_enable()
611 if ((offset >= p->offset) && in abx500_gpio_request_enable()
612 (offset < (p->offset + p->npins))) in abx500_gpio_request_enable()
616 if (i == pct->soc->gpio_num_ranges) { in abx500_gpio_request_enable()
617 dev_err(pct->dev, "%s failed to locate range\n", __func__); in abx500_gpio_request_enable()
618 return -ENODEV; in abx500_gpio_request_enable()
621 dev_dbg(pct->dev, "enable GPIO by altfunc %d at gpio %d\n", in abx500_gpio_request_enable()
622 p->altfunc, offset); in abx500_gpio_request_enable()
624 ret = abx500_set_mode(pct->pctldev, &pct->chip, in abx500_gpio_request_enable()
625 offset, p->altfunc); in abx500_gpio_request_enable()
627 dev_err(pct->dev, "%s setting altfunc failed\n", __func__); in abx500_gpio_request_enable()
651 return pct->soc->ngroups; in abx500_get_groups_cnt()
659 return pct->soc->groups[selector].name; in abx500_get_group_name()
669 *pins = pct->soc->groups[selector].pins; in abx500_get_group_pins()
670 *num_pins = pct->soc->groups[selector].npins; in abx500_get_group_pins()
676 struct seq_file *s, unsigned offset) in abx500_pin_dbg_show() argument
679 struct gpio_chip *chip = &pct->chip; in abx500_pin_dbg_show()
681 abx500_gpio_dbg_show_one(s, pctldev, chip, offset, in abx500_pin_dbg_show()
682 chip->base + offset - 1); in abx500_pin_dbg_show()
691 return -ENOSPC; in abx500_dt_add_map_mux()
709 return -ENOSPC; in abx500_dt_add_map_configs()
714 return -ENOMEM; in abx500_dt_add_map_configs()
733 for (i = 0; i < npct->soc->npins; i++) in abx500_find_pin_name()
734 if (npct->soc->pins[i].number == pin_number) in abx500_find_pin_name()
735 return npct->soc->pins[i].name; in abx500_find_pin_name()
839 return -ENOSYS; in abx500_pin_config_get()
848 struct gpio_chip *chip = &pct->chip; in abx500_pin_config_set()
850 int ret = -EINVAL; in abx500_pin_config_set()
859 dev_dbg(chip->parent, "pin %d [%#lx]: %s %s\n", in abx500_pin_config_set()
867 offset = pin - 1; in abx500_pin_config_set()
914 dev_err(chip->parent, in abx500_pin_config_set()
920 dev_err(pct->dev, "%s failed (%d)\n", __func__, ret); in abx500_pin_config_set()
932 .name = "pinctrl-abx500",
939 static int abx500_get_gpio_num(struct abx500_pinctrl_soc_data *soc) in abx500_get_gpio_num() argument
947 * Compute number of GPIOs from the last SoC gpio range descriptors in abx500_get_gpio_num()
952 for (i = 0; i < soc->gpio_num_ranges; i++) { in abx500_get_gpio_num()
957 p = &soc->gpio_ranges[i]; in abx500_get_gpio_num()
958 gstart = p->offset; in abx500_get_gpio_num()
959 gend = p->offset + p->npins - 1; in abx500_get_gpio_num()
973 npins = highest - lowest + 1; in abx500_get_gpio_num()
978 { .compatible = "stericsson,ab8500-gpio", .data = (void *)PINCTRL_AB8500, },
979 { .compatible = "stericsson,ab8505-gpio", .data = (void *)PINCTRL_AB8505, },
985 struct device_node *np = pdev->dev.of_node; in abx500_gpio_probe()
988 unsigned int id = -1; in abx500_gpio_probe()
993 dev_err(&pdev->dev, "gpio dt node missing\n"); in abx500_gpio_probe()
994 return -ENODEV; in abx500_gpio_probe()
997 pct = devm_kzalloc(&pdev->dev, sizeof(*pct), GFP_KERNEL); in abx500_gpio_probe()
999 return -ENOMEM; in abx500_gpio_probe()
1001 pct->dev = &pdev->dev; in abx500_gpio_probe()
1002 pct->parent = dev_get_drvdata(pdev->dev.parent); in abx500_gpio_probe()
1003 pct->chip = abx500gpio_chip; in abx500_gpio_probe()
1004 pct->chip.parent = &pdev->dev; in abx500_gpio_probe()
1005 pct->chip.base = -1; /* Dynamic allocation */ in abx500_gpio_probe()
1007 match = of_match_device(abx500_gpio_match, &pdev->dev); in abx500_gpio_probe()
1009 dev_err(&pdev->dev, "gpio dt not matching\n"); in abx500_gpio_probe()
1010 return -ENODEV; in abx500_gpio_probe()
1012 id = (unsigned long)match->data; 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()
1090 .name = "abx500-gpio",