Lines Matching full:pctl
81 static void apple_gpio_set_reg(struct apple_gpio_pinctrl *pctl, in apple_gpio_set_reg() argument
84 regmap_update_bits(pctl->map, REG_GPIO(pin), mask, value); in apple_gpio_set_reg()
87 static u32 apple_gpio_get_reg(struct apple_gpio_pinctrl *pctl, in apple_gpio_get_reg() argument
93 ret = regmap_read(pctl->map, REG_GPIO(pin), &val); in apple_gpio_get_reg()
108 struct apple_gpio_pinctrl *pctl; in apple_gpio_dt_node_to_map() local
118 pctl = pinctrl_dev_get_drvdata(pctldev); in apple_gpio_dt_node_to_map()
122 dev_err(pctl->dev, in apple_gpio_dt_node_to_map()
148 function_name = pinmux_generic_get_function_name(pctl->pctldev, func); in apple_gpio_dt_node_to_map()
149 ret = pinctrl_utils_add_map_mux(pctl->pctldev, map, in apple_gpio_dt_node_to_map()
176 struct apple_gpio_pinctrl *pctl = pinctrl_dev_get_drvdata(pctldev); in apple_gpio_pinmux_set() local
179 pctl, group, REG_GPIOx_PERIPH | REG_GPIOx_INPUT_ENABLE, in apple_gpio_pinmux_set()
197 struct apple_gpio_pinctrl *pctl = gpiochip_get_data(chip); in apple_gpio_get_direction() local
198 unsigned int reg = apple_gpio_get_reg(pctl, offset); in apple_gpio_get_direction()
207 struct apple_gpio_pinctrl *pctl = gpiochip_get_data(chip); in apple_gpio_get() local
208 unsigned int reg = apple_gpio_get_reg(pctl, offset); in apple_gpio_get()
215 reg = readl_relaxed(pctl->base + REG_GPIO(offset)); in apple_gpio_get()
222 struct apple_gpio_pinctrl *pctl = gpiochip_get_data(chip); in apple_gpio_set() local
224 apple_gpio_set_reg(pctl, offset, REG_GPIOx_DATA, value ? REG_GPIOx_DATA : 0); in apple_gpio_set()
229 struct apple_gpio_pinctrl *pctl = gpiochip_get_data(chip); in apple_gpio_direction_input() local
231 apple_gpio_set_reg(pctl, offset, in apple_gpio_direction_input()
242 struct apple_gpio_pinctrl *pctl = gpiochip_get_data(chip); in apple_gpio_direction_output() local
244 apple_gpio_set_reg(pctl, offset, in apple_gpio_direction_output()
255 struct apple_gpio_pinctrl *pctl = gpiochip_get_data(irq_data_get_irq_chip_data(data)); in apple_gpio_irq_ack() local
256 unsigned int irqgrp = FIELD_GET(REG_GPIOx_GRP, apple_gpio_get_reg(pctl, data->hwirq)); in apple_gpio_irq_ack()
258 writel(BIT(data->hwirq % 32), pctl->base + REG_IRQ(irqgrp, data->hwirq)); in apple_gpio_irq_ack()
282 struct apple_gpio_pinctrl *pctl = gpiochip_get_data(gc); in apple_gpio_irq_mask() local
284 apple_gpio_set_reg(pctl, data->hwirq, REG_GPIOx_MODE, in apple_gpio_irq_mask()
292 struct apple_gpio_pinctrl *pctl = gpiochip_get_data(gc); in apple_gpio_irq_unmask() local
296 apple_gpio_set_reg(pctl, data->hwirq, REG_GPIOx_MODE, in apple_gpio_irq_unmask()
303 struct apple_gpio_pinctrl *pctl = gpiochip_get_data(chip); in apple_gpio_irq_startup() local
305 apple_gpio_set_reg(pctl, data->hwirq, REG_GPIOx_GRP, in apple_gpio_irq_startup()
316 struct apple_gpio_pinctrl *pctl = gpiochip_get_data(irq_data_get_irq_chip_data(data)); in apple_gpio_irq_set_type() local
322 apple_gpio_set_reg(pctl, data->hwirq, REG_GPIOx_MODE, in apple_gpio_irq_set_type()
336 struct apple_gpio_pinctrl *pctl; in apple_gpio_irq_handler() local
341 pctl = container_of(grpp - *grpp, typeof(*pctl), irqgrps[0]); in apple_gpio_irq_handler()
342 gc = &pctl->gpio_chip; in apple_gpio_irq_handler()
346 pending = readl_relaxed(pctl->base + REG_IRQ(*grpp, pinh)); in apple_gpio_irq_handler()
366 static int apple_gpio_register(struct apple_gpio_pinctrl *pctl) in apple_gpio_register() argument
368 struct gpio_irq_chip *girq = &pctl->gpio_chip.irq; in apple_gpio_register()
372 pctl->gpio_chip.label = dev_name(pctl->dev); in apple_gpio_register()
373 pctl->gpio_chip.request = gpiochip_generic_request; in apple_gpio_register()
374 pctl->gpio_chip.free = gpiochip_generic_free; in apple_gpio_register()
375 pctl->gpio_chip.get_direction = apple_gpio_get_direction; in apple_gpio_register()
376 pctl->gpio_chip.direction_input = apple_gpio_direction_input; in apple_gpio_register()
377 pctl->gpio_chip.direction_output = apple_gpio_direction_output; in apple_gpio_register()
378 pctl->gpio_chip.get = apple_gpio_get; in apple_gpio_register()
379 pctl->gpio_chip.set = apple_gpio_set; in apple_gpio_register()
380 pctl->gpio_chip.base = -1; in apple_gpio_register()
381 pctl->gpio_chip.ngpio = pctl->pinctrl_desc.npins; in apple_gpio_register()
382 pctl->gpio_chip.parent = pctl->dev; in apple_gpio_register()
401 ret = platform_get_irq(to_platform_device(pctl->dev), i); in apple_gpio_register()
406 pctl->irqgrps[i] = i; in apple_gpio_register()
407 irq_data[i] = &pctl->irqgrps[i]; in apple_gpio_register()
416 ret = devm_gpiochip_add_data(pctl->dev, &pctl->gpio_chip, pctl); in apple_gpio_register()
427 struct apple_gpio_pinctrl *pctl; in apple_gpio_pinctrl_probe() local
444 pctl = devm_kzalloc(&pdev->dev, struct_size(pctl, irqgrps, nirqs), in apple_gpio_pinctrl_probe()
446 if (!pctl) in apple_gpio_pinctrl_probe()
448 pctl->dev = &pdev->dev; in apple_gpio_pinctrl_probe()
449 pctl->gpio_chip.irq.num_parents = nirqs; in apple_gpio_pinctrl_probe()
450 dev_set_drvdata(&pdev->dev, pctl); in apple_gpio_pinctrl_probe()
465 pctl->base = devm_platform_ioremap_resource(pdev, 0); in apple_gpio_pinctrl_probe()
466 if (IS_ERR(pctl->base)) in apple_gpio_pinctrl_probe()
467 return PTR_ERR(pctl->base); in apple_gpio_pinctrl_probe()
469 pctl->map = devm_regmap_init_mmio(&pdev->dev, pctl->base, ®map_config); in apple_gpio_pinctrl_probe()
470 if (IS_ERR(pctl->map)) in apple_gpio_pinctrl_probe()
471 return dev_err_probe(&pdev->dev, PTR_ERR(pctl->map), in apple_gpio_pinctrl_probe()
480 pins[i].drv_data = pctl; in apple_gpio_pinctrl_probe()
485 pctl->pinctrl_desc.name = dev_name(pctl->dev); in apple_gpio_pinctrl_probe()
486 pctl->pinctrl_desc.pins = pins; in apple_gpio_pinctrl_probe()
487 pctl->pinctrl_desc.npins = npins; in apple_gpio_pinctrl_probe()
488 pctl->pinctrl_desc.pctlops = &apple_gpio_pinctrl_ops; in apple_gpio_pinctrl_probe()
489 pctl->pinctrl_desc.pmxops = &apple_gpio_pinmux_ops; in apple_gpio_pinctrl_probe()
491 pctl->pctldev = devm_pinctrl_register(&pdev->dev, &pctl->pinctrl_desc, pctl); in apple_gpio_pinctrl_probe()
492 if (IS_ERR(pctl->pctldev)) in apple_gpio_pinctrl_probe()
493 return dev_err_probe(&pdev->dev, PTR_ERR(pctl->pctldev), in apple_gpio_pinctrl_probe()
497 res = pinctrl_generic_add_group(pctl->pctldev, pins[i].name, in apple_gpio_pinctrl_probe()
498 pin_nums + i, 1, pctl); in apple_gpio_pinctrl_probe()
500 return dev_err_probe(pctl->dev, res, in apple_gpio_pinctrl_probe()
505 res = pinmux_generic_add_function(pctl->pctldev, pinmux_functions[i], in apple_gpio_pinctrl_probe()
506 pin_names, npins, pctl); in apple_gpio_pinctrl_probe()
508 return dev_err_probe(pctl->dev, res, in apple_gpio_pinctrl_probe()
512 return apple_gpio_register(pctl); in apple_gpio_pinctrl_probe()