Lines Matching refs:iod
206 static int ti_iodelay_pinconf_set(struct ti_iodelay_device *iod, in ti_iodelay_pinconf_set() argument
209 const struct ti_iodelay_reg_data *reg = iod->reg_data; in ti_iodelay_pinconf_set()
210 struct ti_iodelay_reg_values *ival = &iod->reg_init_conf_values; in ti_iodelay_pinconf_set()
211 struct device *dev = iod->dev; in ti_iodelay_pinconf_set()
264 r = regmap_update_bits(iod->regmap, cfg->offset, reg_mask, reg_val); in ti_iodelay_pinconf_set()
281 static int ti_iodelay_pinconf_init_dev(struct ti_iodelay_device *iod) in ti_iodelay_pinconf_init_dev() argument
283 const struct ti_iodelay_reg_data *reg = iod->reg_data; in ti_iodelay_pinconf_init_dev()
284 struct device *dev = iod->dev; in ti_iodelay_pinconf_init_dev()
285 struct ti_iodelay_reg_values *ival = &iod->reg_init_conf_values; in ti_iodelay_pinconf_init_dev()
290 r = regmap_update_bits(iod->regmap, reg->reg_global_lock_offset, in ti_iodelay_pinconf_init_dev()
296 r = regmap_read(iod->regmap, reg->reg_refclk_offset, &val); in ti_iodelay_pinconf_init_dev()
302 r = regmap_read(iod->regmap, reg->reg_coarse_offset, &val); in ti_iodelay_pinconf_init_dev()
323 dev_dbg(iod->dev, "coarse: ref=0x%04x delay=0x%04x cdpe=0x%08x\n", in ti_iodelay_pinconf_init_dev()
326 r = regmap_read(iod->regmap, reg->reg_fine_offset, &val); in ti_iodelay_pinconf_init_dev()
347 dev_dbg(iod->dev, "fine: ref=0x%04x delay=0x%04x fdpe=0x%08x\n", in ti_iodelay_pinconf_init_dev()
359 static void ti_iodelay_pinconf_deinit_dev(struct ti_iodelay_device *iod) in ti_iodelay_pinconf_deinit_dev() argument
361 const struct ti_iodelay_reg_data *reg = iod->reg_data; in ti_iodelay_pinconf_deinit_dev()
364 regmap_update_bits(iod->regmap, reg->reg_global_lock_offset, in ti_iodelay_pinconf_deinit_dev()
376 ti_iodelay_get_pingroup(struct ti_iodelay_device *iod, unsigned int selector) in ti_iodelay_get_pingroup() argument
380 g = pinctrl_generic_get_group(iod->pctl, selector); in ti_iodelay_get_pingroup()
382 dev_err(iod->dev, "%s could not find pingroup %i\n", __func__, in ti_iodelay_get_pingroup()
396 static int ti_iodelay_offset_to_pin(struct ti_iodelay_device *iod, in ti_iodelay_offset_to_pin() argument
399 const struct ti_iodelay_reg_data *r = iod->reg_data; in ti_iodelay_offset_to_pin()
403 dev_err(iod->dev, "mux offset out of range: 0x%x (0x%x)\n", in ti_iodelay_offset_to_pin()
429 struct ti_iodelay_device *iod; in ti_iodelay_node_iterator() local
435 iod = pinctrl_dev_get_drvdata(pctldev); in ti_iodelay_node_iterator()
436 if (!iod) in ti_iodelay_node_iterator()
439 r = iod->reg_data; in ti_iodelay_node_iterator()
442 dev_err(iod->dev, "invalid args_count for spec: %i\n", in ti_iodelay_node_iterator()
453 pin = ti_iodelay_offset_to_pin(iod, cfg[pin_index].offset); in ti_iodelay_node_iterator()
455 dev_err(iod->dev, "could not add functions for %pOFn %ux\n", in ti_iodelay_node_iterator()
461 pd = &iod->pa[pin]; in ti_iodelay_node_iterator()
464 dev_dbg(iod->dev, "%pOFn offset=%x a_delay = %d g_delay = %d\n", in ti_iodelay_node_iterator()
488 struct ti_iodelay_device *iod; in ti_iodelay_dt_node_to_map() local
494 iod = pinctrl_dev_get_drvdata(pctldev); in ti_iodelay_dt_node_to_map()
495 if (!iod) in ti_iodelay_dt_node_to_map()
502 *map = devm_kzalloc(iod->dev, sizeof(**map), GFP_KERNEL); in ti_iodelay_dt_node_to_map()
507 g = devm_kzalloc(iod->dev, sizeof(*g), GFP_KERNEL); in ti_iodelay_dt_node_to_map()
513 pins = devm_kcalloc(iod->dev, rows, sizeof(*pins), GFP_KERNEL); in ti_iodelay_dt_node_to_map()
517 cfg = devm_kcalloc(iod->dev, rows, sizeof(*cfg), GFP_KERNEL); in ti_iodelay_dt_node_to_map()
541 error = pinctrl_generic_add_group(iod->pctl, np->name, pins, i, g); in ti_iodelay_dt_node_to_map()
554 devm_kfree(iod->dev, cfg); in ti_iodelay_dt_node_to_map()
556 devm_kfree(iod->dev, pins); in ti_iodelay_dt_node_to_map()
558 devm_kfree(iod->dev, g); in ti_iodelay_dt_node_to_map()
560 devm_kfree(iod->dev, *map); in ti_iodelay_dt_node_to_map()
577 struct ti_iodelay_device *iod; in ti_iodelay_pinconf_group_get() local
580 iod = pinctrl_dev_get_drvdata(pctldev); in ti_iodelay_pinconf_group_get()
581 group = ti_iodelay_get_pingroup(iod, selector); in ti_iodelay_pinconf_group_get()
604 struct ti_iodelay_device *iod; in ti_iodelay_pinconf_group_set() local
609 iod = pinctrl_dev_get_drvdata(pctldev); in ti_iodelay_pinconf_group_set()
610 dev = iod->dev; in ti_iodelay_pinconf_group_set()
611 group = ti_iodelay_get_pingroup(iod, selector); in ti_iodelay_pinconf_group_set()
625 if (ti_iodelay_pinconf_set(iod, &group->cfg[i])) in ti_iodelay_pinconf_group_set()
638 static unsigned int ti_iodelay_pin_to_offset(struct ti_iodelay_device *iod, in ti_iodelay_pin_to_offset() argument
641 const struct ti_iodelay_reg_data *r = iod->reg_data; in ti_iodelay_pin_to_offset()
655 struct ti_iodelay_device *iod; in ti_iodelay_pin_dbg_show() local
662 iod = pinctrl_dev_get_drvdata(pctldev); in ti_iodelay_pin_dbg_show()
663 r = iod->reg_data; in ti_iodelay_pin_dbg_show()
665 offset = ti_iodelay_pin_to_offset(iod, pin); in ti_iodelay_pin_dbg_show()
666 pd = &iod->pa[pin]; in ti_iodelay_pin_dbg_show()
669 regmap_read(iod->regmap, offset, &in); in ti_iodelay_pin_dbg_show()
670 regmap_read(iod->regmap, offset + r->regmap_config->reg_stride, &oen); in ti_iodelay_pin_dbg_show()
671 regmap_read(iod->regmap, offset + r->regmap_config->reg_stride * 2, in ti_iodelay_pin_dbg_show()
675 iod->phys_base + offset, in ti_iodelay_pin_dbg_show()
693 struct ti_iodelay_device *iod; in ti_iodelay_pinconf_group_dbg_show() local
697 iod = pinctrl_dev_get_drvdata(pctldev); in ti_iodelay_pinconf_group_dbg_show()
698 group = ti_iodelay_get_pingroup(iod, selector); in ti_iodelay_pinconf_group_dbg_show()
707 regmap_read(iod->regmap, cfg->offset, ®), in ti_iodelay_pinconf_group_dbg_show()
742 struct ti_iodelay_device *iod, u32 base_phy) in ti_iodelay_alloc_pins() argument
744 const struct ti_iodelay_reg_data *r = iod->reg_data; in ti_iodelay_alloc_pins()
749 nr_pins = ti_iodelay_offset_to_pin(iod, r->regmap_config->max_register); in ti_iodelay_alloc_pins()
752 iod->pa = devm_kcalloc(dev, nr_pins, sizeof(*iod->pa), GFP_KERNEL); in ti_iodelay_alloc_pins()
753 if (!iod->pa) in ti_iodelay_alloc_pins()
756 iod->desc.pins = iod->pa; in ti_iodelay_alloc_pins()
757 iod->desc.npins = nr_pins; in ti_iodelay_alloc_pins()
762 pin = &iod->pa[i]; in ti_iodelay_alloc_pins()
824 struct ti_iodelay_device *iod; in ti_iodelay_probe() local
840 iod = devm_kzalloc(dev, sizeof(*iod), GFP_KERNEL); in ti_iodelay_probe()
841 if (!iod) { in ti_iodelay_probe()
845 iod->dev = dev; in ti_iodelay_probe()
846 iod->reg_data = match->data; in ti_iodelay_probe()
856 iod->phys_base = res->start; in ti_iodelay_probe()
857 iod->reg_base = devm_ioremap_resource(dev, res); in ti_iodelay_probe()
858 if (IS_ERR(iod->reg_base)) { in ti_iodelay_probe()
859 ret = PTR_ERR(iod->reg_base); in ti_iodelay_probe()
863 iod->regmap = devm_regmap_init_mmio(dev, iod->reg_base, in ti_iodelay_probe()
864 iod->reg_data->regmap_config); in ti_iodelay_probe()
865 if (IS_ERR(iod->regmap)) { in ti_iodelay_probe()
867 ret = PTR_ERR(iod->regmap); in ti_iodelay_probe()
871 if (ti_iodelay_pinconf_init_dev(iod)) in ti_iodelay_probe()
874 ret = ti_iodelay_alloc_pins(dev, iod, res->start); in ti_iodelay_probe()
878 iod->desc.pctlops = &ti_iodelay_pinctrl_ops; in ti_iodelay_probe()
880 iod->desc.confops = &ti_iodelay_pinctrl_pinconf_ops; in ti_iodelay_probe()
881 iod->desc.name = dev_name(dev); in ti_iodelay_probe()
882 iod->desc.owner = THIS_MODULE; in ti_iodelay_probe()
884 ret = pinctrl_register_and_init(&iod->desc, dev, iod, &iod->pctl); in ti_iodelay_probe()
890 platform_set_drvdata(pdev, iod); in ti_iodelay_probe()
892 return pinctrl_enable(iod->pctl); in ti_iodelay_probe()
907 struct ti_iodelay_device *iod = platform_get_drvdata(pdev); in ti_iodelay_remove() local
909 if (!iod) in ti_iodelay_remove()
912 if (iod->pctl) in ti_iodelay_remove()
913 pinctrl_unregister(iod->pctl); in ti_iodelay_remove()
915 ti_iodelay_pinconf_deinit_dev(iod); in ti_iodelay_remove()