Lines Matching +full:ocelot +full:- +full:miim

1 // SPDX-License-Identifier: (GPL-2.0 OR MIT)
5 * Author: <alexandre.belloni@free-electrons.com>
13 #include <linux/mfd/ocelot.h>
21 #include <linux/pinctrl/pinconf-generic.h>
239 [FUNC_MIIM] = "miim",
534 OCELOT_P(14, MIIM, TWI_SCL_M, SFP);
535 OCELOT_P(15, MIIM, TWI_SCL_M, SFP);
638 JAGUAR2_P(56, MIIM, SFP);
639 JAGUAR2_P(57, MIIM, SFP);
640 JAGUAR2_P(58, MIIM, SFP);
641 JAGUAR2_P(59, MIIM, SFP);
750 SERVALT_P(22, MIIM, SFP, TWI2);
751 SERVALT_P(23, MIIM, SFP, TWI2);
872 SPARX5_P(52, SFP, MIIM, TWI_SCL_M);
873 SPARX5_P(53, SFP, MIIM, TWI_SCL_M);
876 SPARX5_P(56, MIIM, SFP, TWI_SCL_M);
877 SPARX5_P(57, MIIM, SFP, TWI_SCL_M);
878 SPARX5_P(58, MIIM, SFP, TWI_SCL_M);
879 SPARX5_P(59, MIIM, SFP, NONE);
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()
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()
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()
1407 opd->pd_bit | opd->pu_bit, in ocelot_hw_set_value()
1413 opd->schmitt_bit, in ocelot_hw_set_value()
1420 opd->drive_bits, in ocelot_hw_set_value()
1423 ret = -EINVAL; in ocelot_hw_set_value()
1427 ret = -EOPNOTSUPP; in ocelot_hw_set_value()
1451 val = !!(val & info->pincfg_data->pd_bit); in ocelot_pinconf_get()
1453 val = !!(val & info->pincfg_data->pu_bit); in ocelot_pinconf_get()
1457 if (!info->pincfg_data->schmitt_bit) in ocelot_pinconf_get()
1458 return -EOPNOTSUPP; in ocelot_pinconf_get()
1464 val = !!(val & info->pincfg_data->schmitt_bit); in ocelot_pinconf_get()
1475 err = regmap_read(info->map, REG(OCELOT_GPIO_OUT, info, pin), in ocelot_pinconf_get()
1484 err = regmap_read(info->map, REG(OCELOT_GPIO_OE, info, pin), in ocelot_pinconf_get()
1496 return -EOPNOTSUPP; in ocelot_pinconf_get()
1508 const struct ocelot_pincfg_data *opd = info->pincfg_data; in ocelot_pinconf_set()
1522 opd->pu_bit : opd->pd_bit; in ocelot_pinconf_set()
1531 if (!opd->schmitt_bit) in ocelot_pinconf_set()
1532 return -EOPNOTSUPP; in ocelot_pinconf_set()
1534 arg = arg ? opd->schmitt_bit : 0; in ocelot_pinconf_set()
1556 regmap_write(info->map, in ocelot_pinconf_set()
1561 regmap_write(info->map, in ocelot_pinconf_set()
1565 regmap_update_bits(info->map, in ocelot_pinconf_set()
1573 err = -EOPNOTSUPP; in ocelot_pinconf_set()
1597 .name = "luton-pinctrl",
1608 .name = "serval-pinctrl",
1619 .name = "ocelot-pinctrl",
1630 .name = "jaguar2-pinctrl",
1641 .name = "servalt-pinctrl",
1652 .name = "sparx5-pinctrl",
1670 .name = "lan966x-pinctrl",
1689 u8 *pins = kcalloc(info->desc->npins, sizeof(u8), GFP_KERNEL); in ocelot_create_group_func_map()
1692 return -ENOMEM; in ocelot_create_group_func_map()
1695 for (npins = 0, i = 0; i < info->desc->npins; i++) { in ocelot_create_group_func_map()
1703 info->func[f].ngroups = npins; in ocelot_create_group_func_map()
1704 info->func[f].groups = devm_kcalloc(dev, npins, sizeof(char *), in ocelot_create_group_func_map()
1706 if (!info->func[f].groups) { in ocelot_create_group_func_map()
1708 return -ENOMEM; in ocelot_create_group_func_map()
1712 info->func[f].groups[i] = in ocelot_create_group_func_map()
1713 info->desc->pins[pins[i]].name; in ocelot_create_group_func_map()
1726 ret = ocelot_create_group_func_map(&pdev->dev, info); in ocelot_pinctrl_register()
1728 dev_err(&pdev->dev, "Unable to create group func map.\n"); in ocelot_pinctrl_register()
1732 info->pctl = devm_pinctrl_register(&pdev->dev, info->desc, info); in ocelot_pinctrl_register()
1733 if (IS_ERR(info->pctl)) { in ocelot_pinctrl_register()
1734 dev_err(&pdev->dev, "Failed to register pinctrl\n"); in ocelot_pinctrl_register()
1735 return PTR_ERR(info->pctl); in ocelot_pinctrl_register()
1746 regmap_read(info->map, REG(OCELOT_GPIO_IN, info, offset), &val); in ocelot_gpio_get()
1757 regmap_write(info->map, REG(OCELOT_GPIO_OUT_SET, info, offset), in ocelot_gpio_set()
1760 regmap_write(info->map, REG(OCELOT_GPIO_OUT_CLR, info, offset), in ocelot_gpio_set()
1770 regmap_read(info->map, REG(OCELOT_GPIO_OE, info, offset), &val); in ocelot_gpio_get_direction()
1785 regmap_write(info->map, REG(OCELOT_GPIO_OUT_SET, info, offset), in ocelot_gpio_direction_output()
1788 regmap_write(info->map, REG(OCELOT_GPIO_OUT_CLR, info, offset), in ocelot_gpio_direction_output()
1811 regmap_update_bits(info->map, REG(OCELOT_GPIO_INTR_ENA, info, gpio), in ocelot_irq_mask()
1819 struct irq_chip *parent_chip = irq_desc_get_chip(w->irq_desc); in ocelot_irq_work()
1820 struct gpio_chip *chip = irq_desc_get_chip_data(w->irq_desc); in ocelot_irq_work()
1821 struct irq_data *data = irq_desc_get_irq_data(w->irq_desc); in ocelot_irq_work()
1825 chained_irq_enter(parent_chip, w->irq_desc); in ocelot_irq_work()
1826 generic_handle_domain_irq(chip->irq.domain, gpio); in ocelot_irq_work()
1827 chained_irq_exit(parent_chip, w->irq_desc); in ocelot_irq_work()
1847 regmap_read(info->map, REG(OCELOT_GPIO_IN, info, gpio), &val); in ocelot_irq_unmask_level()
1856 regmap_read(info->map, REG(OCELOT_GPIO_INTR, info, gpio), &val); in ocelot_irq_unmask_level()
1862 regmap_write_bits(info->map, REG(OCELOT_GPIO_INTR, info, gpio), in ocelot_irq_unmask_level()
1867 regmap_update_bits(info->map, REG(OCELOT_GPIO_INTR_ENA, info, gpio), in ocelot_irq_unmask_level()
1876 regmap_read(info->map, REG(OCELOT_GPIO_IN, info, gpio), &val); in ocelot_irq_unmask_level()
1888 work->irq_desc = desc; in ocelot_irq_unmask_level()
1889 INIT_WORK(&work->irq_work, ocelot_irq_work); in ocelot_irq_unmask_level()
1890 queue_work(info->wq, &work->irq_work); in ocelot_irq_unmask_level()
1901 regmap_update_bits(info->map, REG(OCELOT_GPIO_INTR_ENA, info, gpio), in ocelot_irq_unmask()
1911 regmap_write_bits(info->map, REG(OCELOT_GPIO_INTR, info, gpio), in ocelot_irq_ack()
1954 unsigned int id_reg = OCELOT_GPIO_INTR_IDENT * info->stride; in ocelot_irq_handler()
1960 for (i = 0; i < info->stride; i++) { in ocelot_irq_handler()
1961 regmap_read(info->map, id_reg + 4 * i, &reg); in ocelot_irq_handler()
1968 min(32U, info->desc->npins - 32 * i)) in ocelot_irq_handler()
1969 generic_handle_domain_irq(chip->irq.domain, irq + 32 * i); in ocelot_irq_handler()
1982 info->gpio_chip = ocelot_gpiolib_chip; in ocelot_gpiochip_register()
1984 gc = &info->gpio_chip; in ocelot_gpiochip_register()
1985 gc->ngpio = info->desc->npins; in ocelot_gpiochip_register()
1986 gc->parent = &pdev->dev; in ocelot_gpiochip_register()
1987 gc->base = -1; in ocelot_gpiochip_register()
1988 gc->label = "ocelot-gpio"; in ocelot_gpiochip_register()
1992 girq = &gc->irq; in ocelot_gpiochip_register()
1994 girq->parent_handler = ocelot_irq_handler; in ocelot_gpiochip_register()
1995 girq->num_parents = 1; in ocelot_gpiochip_register()
1996 girq->parents = devm_kcalloc(&pdev->dev, 1, in ocelot_gpiochip_register()
1997 sizeof(*girq->parents), in ocelot_gpiochip_register()
1999 if (!girq->parents) in ocelot_gpiochip_register()
2000 return -ENOMEM; in ocelot_gpiochip_register()
2001 girq->parents[0] = irq; in ocelot_gpiochip_register()
2002 girq->default_type = IRQ_TYPE_NONE; in ocelot_gpiochip_register()
2003 girq->handler = handle_edge_irq; in ocelot_gpiochip_register()
2006 return devm_gpiochip_add_data(&pdev->dev, gc, info); in ocelot_gpiochip_register()
2010 { .compatible = "mscc,luton-pinctrl", .data = &luton_desc },
2011 { .compatible = "mscc,serval-pinctrl", .data = &serval_desc },
2012 { .compatible = "mscc,ocelot-pinctrl", .data = &ocelot_desc },
2013 { .compatible = "mscc,jaguar2-pinctrl", .data = &jaguar2_desc },
2014 { .compatible = "mscc,servalt-pinctrl", .data = &servalt_desc },
2015 { .compatible = "microchip,sparx5-pinctrl", .data = &sparx5_desc },
2016 { .compatible = "microchip,lan966x-pinctrl", .data = &lan966x_desc },
2030 .max_register = info->desc->npins * 4, in ocelot_pinctrl_create_pincfg()
2036 dev_dbg(&pdev->dev, "Failed to ioremap config registers (no extended pinconf)\n"); in ocelot_pinctrl_create_pincfg()
2040 return devm_regmap_init_mmio(&pdev->dev, base, &regmap_config); in ocelot_pinctrl_create_pincfg()
2051 struct device *dev = &pdev->dev; in ocelot_pinctrl_probe()
2064 return -ENOMEM; in ocelot_pinctrl_probe()
2068 return -EINVAL; in ocelot_pinctrl_probe()
2070 info->desc = devm_kmemdup(dev, &data->desc, sizeof(*info->desc), in ocelot_pinctrl_probe()
2072 if (!info->desc) in ocelot_pinctrl_probe()
2073 return -ENOMEM; in ocelot_pinctrl_probe()
2075 info->wq = alloc_ordered_workqueue("ocelot_ordered", 0); in ocelot_pinctrl_probe()
2076 if (!info->wq) in ocelot_pinctrl_probe()
2077 return -ENOMEM; in ocelot_pinctrl_probe()
2080 info->wq); in ocelot_pinctrl_probe()
2084 info->pincfg_data = &data->pincfg_data; in ocelot_pinctrl_probe()
2092 info->stride = 1 + (info->desc->npins - 1) / 32; in ocelot_pinctrl_probe()
2094 regmap_config.max_register = OCELOT_GPIO_SD_MAP * info->stride + 15 * 4; in ocelot_pinctrl_probe()
2096 info->map = ocelot_regmap_from_resource(pdev, 0, &regmap_config); in ocelot_pinctrl_probe()
2097 if (IS_ERR(info->map)) in ocelot_pinctrl_probe()
2098 return dev_err_probe(dev, PTR_ERR(info->map), in ocelot_pinctrl_probe()
2101 info->dev = dev; in ocelot_pinctrl_probe()
2104 if (info->desc->confops) { in ocelot_pinctrl_probe()
2109 info->pincfg = pincfg; in ocelot_pinctrl_probe()
2127 .name = "pinctrl-ocelot",
2135 MODULE_DESCRIPTION("Ocelot Chip Pinctrl Driver");