Lines Matching +full:sparx5 +full:- +full:switch +full:- +full:reset

1 // SPDX-License-Identifier: (GPL-2.0 OR MIT)
5 * Author: <alexandre.belloni@free-electrons.com>
20 #include <linux/pinctrl/pinconf-generic.h>
23 #include <linux/reset.h>
1157 *groups = info->func[function].groups; in ocelot_get_function_groups()
1158 *num_groups = info->func[function].ngroups; in ocelot_get_function_groups()
1166 struct ocelot_pin_caps *p = info->desc->pins[pin].drv_data; in ocelot_pin_function_idx()
1170 if (function == p->functions[i]) in ocelot_pin_function_idx()
1173 if (function == p->a_functions[i]) in ocelot_pin_function_idx()
1177 return -1; in ocelot_pin_function_idx()
1180 #define REG_ALT(msb, info, p) (OCELOT_GPIO_ALT0 * (info)->stride + 4 * ((msb) + ((info)->stride * (…
1186 struct ocelot_pin_caps *pin = info->desc->pins[group].drv_data; in ocelot_pinmux_set_mux()
1187 unsigned int p = pin->pin % 32; in ocelot_pinmux_set_mux()
1192 return -EINVAL; in ocelot_pinmux_set_mux()
1202 regmap_update_bits(info->map, REG_ALT(0, info, pin->pin), in ocelot_pinmux_set_mux()
1204 regmap_update_bits(info->map, REG_ALT(1, info, pin->pin), in ocelot_pinmux_set_mux()
1205 BIT(p), f << (p - 1)); in ocelot_pinmux_set_mux()
1214 struct ocelot_pin_caps *pin = info->desc->pins[group].drv_data; in lan966x_pinmux_set_mux()
1215 unsigned int p = pin->pin % 32; in lan966x_pinmux_set_mux()
1220 return -EINVAL; in lan966x_pinmux_set_mux()
1230 regmap_update_bits(info->map, REG_ALT(0, info, pin->pin), in lan966x_pinmux_set_mux()
1232 regmap_update_bits(info->map, REG_ALT(1, info, pin->pin), in lan966x_pinmux_set_mux()
1234 regmap_update_bits(info->map, REG_ALT(2, info, pin->pin), in lan966x_pinmux_set_mux()
1240 #define REG(r, info, p) ((r) * (info)->stride + (4 * ((p) / 32)))
1249 regmap_update_bits(info->map, REG(OCELOT_GPIO_OE, info, pin), BIT(p), in ocelot_gpio_set_direction()
1262 regmap_update_bits(info->map, REG_ALT(0, info, offset), in ocelot_gpio_request_enable()
1264 regmap_update_bits(info->map, REG_ALT(1, info, offset), in ocelot_gpio_request_enable()
1277 regmap_update_bits(info->map, REG_ALT(0, info, offset), in lan966x_gpio_request_enable()
1279 regmap_update_bits(info->map, REG_ALT(1, info, offset), in lan966x_gpio_request_enable()
1281 regmap_update_bits(info->map, REG_ALT(2, info, offset), in lan966x_gpio_request_enable()
1309 return info->desc->npins; in ocelot_pctl_get_groups_count()
1317 return info->desc->pins[group].name; in ocelot_pctl_get_group_name()
1327 *pins = &info->desc->pins[group].number; in ocelot_pctl_get_group_pins()
1338 int ret = -EOPNOTSUPP; in ocelot_hw_get_value()
1340 if (info->pincfg) { in ocelot_hw_get_value()
1341 const struct ocelot_pincfg_data *opd = info->pincfg_data; in ocelot_hw_get_value()
1344 ret = regmap_read(info->pincfg, in ocelot_hw_get_value()
1345 pin * regmap_get_reg_stride(info->pincfg), in ocelot_hw_get_value()
1351 switch (reg) { in ocelot_hw_get_value()
1353 *val = regcfg & (opd->pd_bit | opd->pu_bit); in ocelot_hw_get_value()
1357 *val = regcfg & opd->schmitt_bit; in ocelot_hw_get_value()
1361 *val = regcfg & opd->drive_bits; in ocelot_hw_get_value()
1365 ret = -EOPNOTSUPP; in ocelot_hw_get_value()
1378 ret = regmap_read(info->pincfg, in ocelot_pincfg_clrsetbits()
1379 regaddr * regmap_get_reg_stride(info->pincfg), in ocelot_pincfg_clrsetbits()
1387 ret = regmap_write(info->pincfg, in ocelot_pincfg_clrsetbits()
1388 regaddr * regmap_get_reg_stride(info->pincfg), in ocelot_pincfg_clrsetbits()
1399 int ret = -EOPNOTSUPP; in ocelot_hw_set_value()
1401 if (info->pincfg) { in ocelot_hw_set_value()
1402 const struct ocelot_pincfg_data *opd = info->pincfg_data; in ocelot_hw_set_value()
1405 switch (reg) { in ocelot_hw_set_value()
1408 opd->pd_bit | opd->pu_bit, in ocelot_hw_set_value()
1414 opd->schmitt_bit, in ocelot_hw_set_value()
1421 opd->drive_bits, in ocelot_hw_set_value()
1424 ret = -EINVAL; in ocelot_hw_set_value()
1428 ret = -EOPNOTSUPP; in ocelot_hw_set_value()
1442 switch (param) { in ocelot_pinconf_get()
1452 val = !!(val & info->pincfg_data->pd_bit); in ocelot_pinconf_get()
1454 val = !!(val & info->pincfg_data->pu_bit); in ocelot_pinconf_get()
1458 if (!info->pincfg_data->schmitt_bit) in ocelot_pinconf_get()
1459 return -EOPNOTSUPP; in ocelot_pinconf_get()
1465 val = !!(val & info->pincfg_data->schmitt_bit); in ocelot_pinconf_get()
1476 err = regmap_read(info->map, REG(OCELOT_GPIO_OUT, info, pin), in ocelot_pinconf_get()
1485 err = regmap_read(info->map, REG(OCELOT_GPIO_OE, info, pin), in ocelot_pinconf_get()
1497 return -EOPNOTSUPP; in ocelot_pinconf_get()
1509 const struct ocelot_pincfg_data *opd = info->pincfg_data; in ocelot_pinconf_set()
1517 switch (param) { in ocelot_pinconf_set()
1523 opd->pu_bit : opd->pd_bit; in ocelot_pinconf_set()
1532 if (!opd->schmitt_bit) in ocelot_pinconf_set()
1533 return -EOPNOTSUPP; in ocelot_pinconf_set()
1535 arg = arg ? opd->schmitt_bit : 0; in ocelot_pinconf_set()
1557 regmap_write(info->map, in ocelot_pinconf_set()
1562 regmap_write(info->map, in ocelot_pinconf_set()
1566 regmap_update_bits(info->map, in ocelot_pinconf_set()
1574 err = -EOPNOTSUPP; in ocelot_pinconf_set()
1598 .name = "luton-pinctrl",
1609 .name = "serval-pinctrl",
1620 .name = "ocelot-pinctrl",
1631 .name = "jaguar2-pinctrl",
1642 .name = "servalt-pinctrl",
1653 .name = "sparx5-pinctrl",
1671 .name = "lan966x-pinctrl",
1690 u8 *pins = kcalloc(info->desc->npins, sizeof(u8), GFP_KERNEL); in ocelot_create_group_func_map()
1693 return -ENOMEM; in ocelot_create_group_func_map()
1696 for (npins = 0, i = 0; i < info->desc->npins; i++) { in ocelot_create_group_func_map()
1704 info->func[f].ngroups = npins; in ocelot_create_group_func_map()
1705 info->func[f].groups = devm_kcalloc(dev, npins, sizeof(char *), in ocelot_create_group_func_map()
1707 if (!info->func[f].groups) { in ocelot_create_group_func_map()
1709 return -ENOMEM; in ocelot_create_group_func_map()
1713 info->func[f].groups[i] = in ocelot_create_group_func_map()
1714 info->desc->pins[pins[i]].name; in ocelot_create_group_func_map()
1727 ret = ocelot_create_group_func_map(&pdev->dev, info); in ocelot_pinctrl_register()
1729 dev_err(&pdev->dev, "Unable to create group func map.\n"); in ocelot_pinctrl_register()
1733 info->pctl = devm_pinctrl_register(&pdev->dev, info->desc, info); in ocelot_pinctrl_register()
1734 if (IS_ERR(info->pctl)) { in ocelot_pinctrl_register()
1735 dev_err(&pdev->dev, "Failed to register pinctrl\n"); in ocelot_pinctrl_register()
1736 return PTR_ERR(info->pctl); in ocelot_pinctrl_register()
1747 regmap_read(info->map, REG(OCELOT_GPIO_IN, info, offset), &val); in ocelot_gpio_get()
1758 regmap_write(info->map, REG(OCELOT_GPIO_OUT_SET, info, offset), in ocelot_gpio_set()
1761 regmap_write(info->map, REG(OCELOT_GPIO_OUT_CLR, info, offset), in ocelot_gpio_set()
1771 regmap_read(info->map, REG(OCELOT_GPIO_OE, info, offset), &val); in ocelot_gpio_get_direction()
1782 return pinctrl_gpio_direction_input(chip->base + offset); in ocelot_gpio_direction_input()
1792 regmap_write(info->map, REG(OCELOT_GPIO_OUT_SET, info, offset), in ocelot_gpio_direction_output()
1795 regmap_write(info->map, REG(OCELOT_GPIO_OUT_CLR, info, offset), in ocelot_gpio_direction_output()
1798 return pinctrl_gpio_direction_output(chip->base + offset); in ocelot_gpio_direction_output()
1818 regmap_update_bits(info->map, REG(OCELOT_GPIO_INTR_ENA, info, gpio), in ocelot_irq_mask()
1826 struct irq_chip *parent_chip = irq_desc_get_chip(w->irq_desc); in ocelot_irq_work()
1827 struct gpio_chip *chip = irq_desc_get_chip_data(w->irq_desc); in ocelot_irq_work()
1828 struct irq_data *data = irq_desc_get_irq_data(w->irq_desc); in ocelot_irq_work()
1832 chained_irq_enter(parent_chip, w->irq_desc); in ocelot_irq_work()
1833 generic_handle_domain_irq(chip->irq.domain, gpio); in ocelot_irq_work()
1834 chained_irq_exit(parent_chip, w->irq_desc); in ocelot_irq_work()
1854 regmap_read(info->map, REG(OCELOT_GPIO_IN, info, gpio), &val); in ocelot_irq_unmask_level()
1863 regmap_read(info->map, REG(OCELOT_GPIO_INTR, info, gpio), &val); in ocelot_irq_unmask_level()
1869 regmap_write_bits(info->map, REG(OCELOT_GPIO_INTR, info, gpio), in ocelot_irq_unmask_level()
1874 regmap_update_bits(info->map, REG(OCELOT_GPIO_INTR_ENA, info, gpio), in ocelot_irq_unmask_level()
1883 regmap_read(info->map, REG(OCELOT_GPIO_IN, info, gpio), &val); in ocelot_irq_unmask_level()
1895 work->irq_desc = desc; in ocelot_irq_unmask_level()
1896 INIT_WORK(&work->irq_work, ocelot_irq_work); in ocelot_irq_unmask_level()
1897 queue_work(info->wq, &work->irq_work); in ocelot_irq_unmask_level()
1908 regmap_update_bits(info->map, REG(OCELOT_GPIO_INTR_ENA, info, gpio), in ocelot_irq_unmask()
1918 regmap_write_bits(info->map, REG(OCELOT_GPIO_INTR, info, gpio), in ocelot_irq_ack()
1961 unsigned int id_reg = OCELOT_GPIO_INTR_IDENT * info->stride; in ocelot_irq_handler()
1965 for (i = 0; i < info->stride; i++) { in ocelot_irq_handler()
1966 regmap_read(info->map, id_reg + 4 * i, &reg); in ocelot_irq_handler()
1975 min(32U, info->desc->npins - 32 * i)) in ocelot_irq_handler()
1976 generic_handle_domain_irq(chip->irq.domain, irq + 32 * i); in ocelot_irq_handler()
1989 info->gpio_chip = ocelot_gpiolib_chip; in ocelot_gpiochip_register()
1991 gc = &info->gpio_chip; in ocelot_gpiochip_register()
1992 gc->ngpio = info->desc->npins; in ocelot_gpiochip_register()
1993 gc->parent = &pdev->dev; in ocelot_gpiochip_register()
1994 gc->base = -1; in ocelot_gpiochip_register()
1995 gc->label = "ocelot-gpio"; in ocelot_gpiochip_register()
1999 girq = &gc->irq; in ocelot_gpiochip_register()
2001 girq->parent_handler = ocelot_irq_handler; in ocelot_gpiochip_register()
2002 girq->num_parents = 1; in ocelot_gpiochip_register()
2003 girq->parents = devm_kcalloc(&pdev->dev, 1, in ocelot_gpiochip_register()
2004 sizeof(*girq->parents), in ocelot_gpiochip_register()
2006 if (!girq->parents) in ocelot_gpiochip_register()
2007 return -ENOMEM; in ocelot_gpiochip_register()
2008 girq->parents[0] = irq; in ocelot_gpiochip_register()
2009 girq->default_type = IRQ_TYPE_NONE; in ocelot_gpiochip_register()
2010 girq->handler = handle_edge_irq; in ocelot_gpiochip_register()
2013 return devm_gpiochip_add_data(&pdev->dev, gc, info); in ocelot_gpiochip_register()
2017 { .compatible = "mscc,luton-pinctrl", .data = &luton_desc },
2018 { .compatible = "mscc,serval-pinctrl", .data = &serval_desc },
2019 { .compatible = "mscc,ocelot-pinctrl", .data = &ocelot_desc },
2020 { .compatible = "mscc,jaguar2-pinctrl", .data = &jaguar2_desc },
2021 { .compatible = "mscc,servalt-pinctrl", .data = &servalt_desc },
2022 { .compatible = "microchip,sparx5-pinctrl", .data = &sparx5_desc },
2023 { .compatible = "microchip,lan966x-pinctrl", .data = &lan966x_desc },
2037 .max_register = info->desc->npins * 4, in ocelot_pinctrl_create_pincfg()
2043 dev_dbg(&pdev->dev, "Failed to ioremap config registers (no extended pinconf)\n"); in ocelot_pinctrl_create_pincfg()
2047 return devm_regmap_init_mmio(&pdev->dev, base, &regmap_config); in ocelot_pinctrl_create_pincfg()
2053 struct device *dev = &pdev->dev; in ocelot_pinctrl_probe()
2055 struct reset_control *reset; in ocelot_pinctrl_probe() local
2066 return -ENOMEM; in ocelot_pinctrl_probe()
2070 return -EINVAL; in ocelot_pinctrl_probe()
2072 info->desc = devm_kmemdup(dev, &data->desc, sizeof(*info->desc), in ocelot_pinctrl_probe()
2074 if (!info->desc) in ocelot_pinctrl_probe()
2075 return -ENOMEM; in ocelot_pinctrl_probe()
2077 info->wq = alloc_ordered_workqueue("ocelot_ordered", 0); in ocelot_pinctrl_probe()
2078 if (!info->wq) in ocelot_pinctrl_probe()
2079 return -ENOMEM; in ocelot_pinctrl_probe()
2081 info->pincfg_data = &data->pincfg_data; in ocelot_pinctrl_probe()
2083 reset = devm_reset_control_get_optional_shared(dev, "switch"); in ocelot_pinctrl_probe()
2084 if (IS_ERR(reset)) in ocelot_pinctrl_probe()
2085 return dev_err_probe(dev, PTR_ERR(reset), in ocelot_pinctrl_probe()
2086 "Failed to get reset\n"); in ocelot_pinctrl_probe()
2087 reset_control_reset(reset); in ocelot_pinctrl_probe()
2089 info->stride = 1 + (info->desc->npins - 1) / 32; in ocelot_pinctrl_probe()
2091 regmap_config.max_register = OCELOT_GPIO_SD_MAP * info->stride + 15 * 4; in ocelot_pinctrl_probe()
2093 info->map = ocelot_regmap_from_resource(pdev, 0, &regmap_config); in ocelot_pinctrl_probe()
2094 if (IS_ERR(info->map)) in ocelot_pinctrl_probe()
2095 return dev_err_probe(dev, PTR_ERR(info->map), in ocelot_pinctrl_probe()
2098 info->dev = dev; in ocelot_pinctrl_probe()
2101 if (info->desc->confops) { in ocelot_pinctrl_probe()
2106 info->pincfg = pincfg; in ocelot_pinctrl_probe()
2126 destroy_workqueue(info->wq); in ocelot_pinctrl_remove()
2133 .name = "pinctrl-ocelot",