Lines Matching refs:iod

209 static int ti_iodelay_pinconf_set(struct ti_iodelay_device *iod,  in ti_iodelay_pinconf_set()  argument
212 const struct ti_iodelay_reg_data *reg = iod->reg_data; in ti_iodelay_pinconf_set()
213 struct ti_iodelay_reg_values *ival = &iod->reg_init_conf_values; in ti_iodelay_pinconf_set()
214 struct device *dev = iod->dev; in ti_iodelay_pinconf_set()
267 r = regmap_update_bits(iod->regmap, cfg->offset, reg_mask, reg_val); in ti_iodelay_pinconf_set()
284 struct ti_iodelay_device *iod = data; in ti_iodelay_pinconf_deinit_dev() local
285 const struct ti_iodelay_reg_data *reg = iod->reg_data; in ti_iodelay_pinconf_deinit_dev()
288 regmap_update_bits(iod->regmap, reg->reg_global_lock_offset, in ti_iodelay_pinconf_deinit_dev()
300 static int ti_iodelay_pinconf_init_dev(struct ti_iodelay_device *iod) in ti_iodelay_pinconf_init_dev() argument
302 const struct ti_iodelay_reg_data *reg = iod->reg_data; in ti_iodelay_pinconf_init_dev()
303 struct device *dev = iod->dev; in ti_iodelay_pinconf_init_dev()
304 struct ti_iodelay_reg_values *ival = &iod->reg_init_conf_values; in ti_iodelay_pinconf_init_dev()
309 r = regmap_update_bits(iod->regmap, reg->reg_global_lock_offset, in ti_iodelay_pinconf_init_dev()
314 r = devm_add_action_or_reset(iod->dev, ti_iodelay_pinconf_deinit_dev, in ti_iodelay_pinconf_init_dev()
315 iod); in ti_iodelay_pinconf_init_dev()
320 r = regmap_read(iod->regmap, reg->reg_refclk_offset, &val); in ti_iodelay_pinconf_init_dev()
326 r = regmap_read(iod->regmap, reg->reg_coarse_offset, &val); in ti_iodelay_pinconf_init_dev()
347 dev_dbg(iod->dev, "coarse: ref=0x%04x delay=0x%04x cdpe=0x%08x\n", in ti_iodelay_pinconf_init_dev()
350 r = regmap_read(iod->regmap, reg->reg_fine_offset, &val); in ti_iodelay_pinconf_init_dev()
371 dev_dbg(iod->dev, "fine: ref=0x%04x delay=0x%04x fdpe=0x%08x\n", in ti_iodelay_pinconf_init_dev()
385 ti_iodelay_get_pingroup(struct ti_iodelay_device *iod, unsigned int selector) in ti_iodelay_get_pingroup() argument
389 g = pinctrl_generic_get_group(iod->pctl, selector); in ti_iodelay_get_pingroup()
391 dev_err(iod->dev, "%s could not find pingroup %i\n", __func__, in ti_iodelay_get_pingroup()
405 static int ti_iodelay_offset_to_pin(struct ti_iodelay_device *iod, in ti_iodelay_offset_to_pin() argument
408 const struct ti_iodelay_reg_data *r = iod->reg_data; in ti_iodelay_offset_to_pin()
412 dev_err(iod->dev, "mux offset out of range: 0x%x (0x%x)\n", in ti_iodelay_offset_to_pin()
438 struct ti_iodelay_device *iod; in ti_iodelay_node_iterator() local
444 iod = pinctrl_dev_get_drvdata(pctldev); in ti_iodelay_node_iterator()
445 if (!iod) in ti_iodelay_node_iterator()
448 r = iod->reg_data; in ti_iodelay_node_iterator()
451 dev_err(iod->dev, "invalid args_count for spec: %i\n", in ti_iodelay_node_iterator()
462 pin = ti_iodelay_offset_to_pin(iod, cfg[pin_index].offset); in ti_iodelay_node_iterator()
464 dev_err(iod->dev, "could not add functions for %pOFn %ux\n", in ti_iodelay_node_iterator()
470 pd = &iod->pa[pin]; in ti_iodelay_node_iterator()
473 dev_dbg(iod->dev, "%pOFn offset=%x a_delay = %d g_delay = %d\n", in ti_iodelay_node_iterator()
497 struct ti_iodelay_device *iod; in ti_iodelay_dt_node_to_map() local
503 iod = pinctrl_dev_get_drvdata(pctldev); in ti_iodelay_dt_node_to_map()
504 if (!iod) in ti_iodelay_dt_node_to_map()
511 *map = devm_kzalloc(iod->dev, sizeof(**map), GFP_KERNEL); in ti_iodelay_dt_node_to_map()
516 g = devm_kzalloc(iod->dev, sizeof(*g), GFP_KERNEL); in ti_iodelay_dt_node_to_map()
522 pins = devm_kcalloc(iod->dev, rows, sizeof(*pins), GFP_KERNEL); in ti_iodelay_dt_node_to_map()
528 cfg = devm_kcalloc(iod->dev, rows, sizeof(*cfg), GFP_KERNEL); in ti_iodelay_dt_node_to_map()
552 error = pinctrl_generic_add_group(iod->pctl, np->name, pins, i, g); in ti_iodelay_dt_node_to_map()
565 devm_kfree(iod->dev, cfg); in ti_iodelay_dt_node_to_map()
567 devm_kfree(iod->dev, pins); in ti_iodelay_dt_node_to_map()
569 devm_kfree(iod->dev, g); in ti_iodelay_dt_node_to_map()
571 devm_kfree(iod->dev, *map); in ti_iodelay_dt_node_to_map()
588 struct ti_iodelay_device *iod; in ti_iodelay_pinconf_group_get() local
591 iod = pinctrl_dev_get_drvdata(pctldev); in ti_iodelay_pinconf_group_get()
592 group = ti_iodelay_get_pingroup(iod, selector); in ti_iodelay_pinconf_group_get()
615 struct ti_iodelay_device *iod; in ti_iodelay_pinconf_group_set() local
620 iod = pinctrl_dev_get_drvdata(pctldev); in ti_iodelay_pinconf_group_set()
621 dev = iod->dev; in ti_iodelay_pinconf_group_set()
622 group = ti_iodelay_get_pingroup(iod, selector); in ti_iodelay_pinconf_group_set()
636 if (ti_iodelay_pinconf_set(iod, &group->cfg[i])) in ti_iodelay_pinconf_group_set()
649 static unsigned int ti_iodelay_pin_to_offset(struct ti_iodelay_device *iod, in ti_iodelay_pin_to_offset() argument
652 const struct ti_iodelay_reg_data *r = iod->reg_data; in ti_iodelay_pin_to_offset()
666 struct ti_iodelay_device *iod; in ti_iodelay_pin_dbg_show() local
673 iod = pinctrl_dev_get_drvdata(pctldev); in ti_iodelay_pin_dbg_show()
674 r = iod->reg_data; in ti_iodelay_pin_dbg_show()
676 offset = ti_iodelay_pin_to_offset(iod, pin); in ti_iodelay_pin_dbg_show()
677 pd = &iod->pa[pin]; in ti_iodelay_pin_dbg_show()
680 regmap_read(iod->regmap, offset, &in); in ti_iodelay_pin_dbg_show()
681 regmap_read(iod->regmap, offset + r->regmap_config->reg_stride, &oen); in ti_iodelay_pin_dbg_show()
682 regmap_read(iod->regmap, offset + r->regmap_config->reg_stride * 2, in ti_iodelay_pin_dbg_show()
686 iod->phys_base + offset, in ti_iodelay_pin_dbg_show()
704 struct ti_iodelay_device *iod; in ti_iodelay_pinconf_group_dbg_show() local
708 iod = pinctrl_dev_get_drvdata(pctldev); in ti_iodelay_pinconf_group_dbg_show()
709 group = ti_iodelay_get_pingroup(iod, selector); in ti_iodelay_pinconf_group_dbg_show()
718 regmap_read(iod->regmap, cfg->offset, &reg); in ti_iodelay_pinconf_group_dbg_show()
752 struct ti_iodelay_device *iod, u32 base_phy) in ti_iodelay_alloc_pins() argument
754 const struct ti_iodelay_reg_data *r = iod->reg_data; in ti_iodelay_alloc_pins()
759 nr_pins = ti_iodelay_offset_to_pin(iod, r->regmap_config->max_register); in ti_iodelay_alloc_pins()
762 iod->pa = devm_kcalloc(dev, nr_pins, sizeof(*iod->pa), GFP_KERNEL); in ti_iodelay_alloc_pins()
763 if (!iod->pa) in ti_iodelay_alloc_pins()
766 iod->desc.pins = iod->pa; in ti_iodelay_alloc_pins()
767 iod->desc.npins = nr_pins; in ti_iodelay_alloc_pins()
772 pin = &iod->pa[i]; in ti_iodelay_alloc_pins()
833 struct ti_iodelay_device *iod; in ti_iodelay_probe() local
841 iod = devm_kzalloc(dev, sizeof(*iod), GFP_KERNEL); in ti_iodelay_probe()
842 if (!iod) in ti_iodelay_probe()
845 iod->dev = dev; in ti_iodelay_probe()
846 iod->reg_data = device_get_match_data(dev); in ti_iodelay_probe()
847 if (!iod->reg_data) { in ti_iodelay_probe()
853 iod->reg_base = devm_platform_get_and_ioremap_resource(pdev, 0, &res); in ti_iodelay_probe()
854 if (IS_ERR(iod->reg_base)) in ti_iodelay_probe()
855 return PTR_ERR(iod->reg_base); in ti_iodelay_probe()
857 iod->phys_base = res->start; in ti_iodelay_probe()
859 iod->regmap = devm_regmap_init_mmio(dev, iod->reg_base, in ti_iodelay_probe()
860 iod->reg_data->regmap_config); in ti_iodelay_probe()
861 if (IS_ERR(iod->regmap)) { in ti_iodelay_probe()
863 return PTR_ERR(iod->regmap); in ti_iodelay_probe()
866 ret = ti_iodelay_pinconf_init_dev(iod); in ti_iodelay_probe()
870 ret = ti_iodelay_alloc_pins(dev, iod, res->start); in ti_iodelay_probe()
874 iod->desc.pctlops = &ti_iodelay_pinctrl_ops; in ti_iodelay_probe()
876 iod->desc.confops = &ti_iodelay_pinctrl_pinconf_ops; in ti_iodelay_probe()
877 iod->desc.name = dev_name(dev); in ti_iodelay_probe()
878 iod->desc.owner = THIS_MODULE; in ti_iodelay_probe()
880 ret = devm_pinctrl_register_and_init(dev, &iod->desc, iod, &iod->pctl); in ti_iodelay_probe()
886 return pinctrl_enable(iod->pctl); in ti_iodelay_probe()