Lines Matching full:pctrl

66 #define cv1800_pinctrl_get_component_addr(pctrl, _comp)		\  argument
67 ((pctrl)->regs[(_comp)->area] + (_comp)->offset)
78 static int cv1800_set_power_cfg(struct cv1800_pinctrl *pctrl, in cv1800_set_power_cfg() argument
81 if (domain >= pctrl->data->npd) in cv1800_set_power_cfg()
84 if (pctrl->power_cfg[domain] && pctrl->power_cfg[domain] != cfg) in cv1800_set_power_cfg()
87 pctrl->power_cfg[domain] = cfg; in cv1800_set_power_cfg()
92 static int cv1800_get_power_cfg(struct cv1800_pinctrl *pctrl, in cv1800_get_power_cfg() argument
95 return pctrl->power_cfg[domain]; in cv1800_get_power_cfg()
98 static struct cv1800_pin *cv1800_get_pin(struct cv1800_pinctrl *pctrl, in cv1800_get_pin() argument
101 return bsearch((void *)pin, pctrl->data->pindata, pctrl->data->npins, in cv1800_get_pin()
115 static const char *cv1800_get_power_cfg_desc(struct cv1800_pinctrl *pctrl, in cv1800_get_power_cfg_desc() argument
118 return pctrl->data->pdnames[domain]; in cv1800_get_power_cfg_desc()
124 struct cv1800_pinctrl *pctrl = pinctrl_dev_get_drvdata(pctldev); in cv1800_pctrl_dbg_show() local
125 struct cv1800_pin *pin = cv1800_get_pin(pctrl, pin_id); in cv1800_pctrl_dbg_show()
138 cv1800_get_power_cfg_desc(pctrl, pin->power_domain)); in cv1800_pctrl_dbg_show()
141 reg = cv1800_pinctrl_get_component_addr(pctrl, &pin->mux); in cv1800_pctrl_dbg_show()
146 reg = cv1800_pinctrl_get_component_addr(pctrl, &pin->mux2); in cv1800_pctrl_dbg_show()
152 reg = cv1800_pinctrl_get_component_addr(pctrl, &pin->conf); in cv1800_pctrl_dbg_show()
207 struct cv1800_pinctrl *pctrl = pinctrl_dev_get_drvdata(pctldev); in cv1800_pctrl_dt_node_to_map() local
208 struct device *dev = pctrl->dev; in cv1800_pctrl_dt_node_to_map()
229 mutex_lock(&pctrl->mutex); in cv1800_pctrl_dt_node_to_map()
273 pinmuxs[i].pin = cv1800_get_pin(pctrl, pins[i]); in cv1800_pctrl_dt_node_to_map()
306 ret = cv1800_set_power_cfg(pctrl, pinmuxs[0].pin->power_domain, in cv1800_pctrl_dt_node_to_map()
350 mutex_unlock(&pctrl->mutex); in cv1800_pctrl_dt_node_to_map()
358 mutex_unlock(&pctrl->mutex); in cv1800_pctrl_dt_node_to_map()
374 struct cv1800_pinctrl *pctrl = pinctrl_dev_get_drvdata(pctldev); in cv1800_pmx_set_mux() local
394 reg_mux = cv1800_pinctrl_get_component_addr(pctrl, &pin->mux); in cv1800_pmx_set_mux()
395 reg_mux2 = cv1800_pinctrl_get_component_addr(pctrl, &pin->mux2); in cv1800_pmx_set_mux()
399 raw_spin_lock_irqsave(&pctrl->lock, flags); in cv1800_pmx_set_mux()
403 raw_spin_unlock_irqrestore(&pctrl->lock, flags); in cv1800_pmx_set_mux()
424 static u32 cv1800_pull_down_typical_resistor(struct cv1800_pinctrl *pctrl, in cv1800_pull_down_typical_resistor() argument
427 return pctrl->data->vddio_ops->get_pull_down(pin, pctrl->power_cfg); in cv1800_pull_down_typical_resistor()
430 static u32 cv1800_pull_up_typical_resistor(struct cv1800_pinctrl *pctrl, in cv1800_pull_up_typical_resistor() argument
433 return pctrl->data->vddio_ops->get_pull_up(pin, pctrl->power_cfg); in cv1800_pull_up_typical_resistor()
436 static int cv1800_pinctrl_oc2reg(struct cv1800_pinctrl *pctrl, in cv1800_pinctrl_oc2reg() argument
442 len = pctrl->data->vddio_ops->get_oc_map(pin, pctrl->power_cfg, &map); in cv1800_pinctrl_oc2reg()
454 static int cv1800_pinctrl_reg2oc(struct cv1800_pinctrl *pctrl, in cv1800_pinctrl_reg2oc() argument
460 len = pctrl->data->vddio_ops->get_oc_map(pin, pctrl->power_cfg, &map); in cv1800_pinctrl_reg2oc()
470 static int cv1800_pinctrl_schmitt2reg(struct cv1800_pinctrl *pctrl, in cv1800_pinctrl_schmitt2reg() argument
476 len = pctrl->data->vddio_ops->get_schmitt_map(pin, pctrl->power_cfg, in cv1800_pinctrl_schmitt2reg()
489 static int cv1800_pinctrl_reg2schmitt(struct cv1800_pinctrl *pctrl, in cv1800_pinctrl_reg2schmitt() argument
495 len = pctrl->data->vddio_ops->get_schmitt_map(pin, pctrl->power_cfg, in cv1800_pinctrl_reg2schmitt()
509 struct cv1800_pinctrl *pctrl = pinctrl_dev_get_drvdata(pctldev); in cv1800_pconf_get() local
511 struct cv1800_pin *pin = cv1800_get_pin(pctrl, pin_id); in cv1800_pconf_get()
525 value = readl(cv1800_pinctrl_get_component_addr(pctrl, &pin->conf)); in cv1800_pconf_get()
530 arg = cv1800_pull_down_typical_resistor(pctrl, pin); in cv1800_pconf_get()
534 arg = cv1800_pull_up_typical_resistor(pctrl, pin); in cv1800_pconf_get()
539 ret = cv1800_pinctrl_reg2oc(pctrl, pin, arg); in cv1800_pconf_get()
546 ret = cv1800_pinctrl_reg2schmitt(pctrl, pin, arg); in cv1800_pconf_get()
554 arg = cv1800_get_power_cfg(pctrl, pin->power_domain); in cv1800_pconf_get()
573 static int cv1800_pinconf_compute_config(struct cv1800_pinctrl *pctrl, in cv1800_pinconf_compute_config() argument
605 ret = cv1800_pinctrl_oc2reg(pctrl, pin, arg); in cv1800_pinconf_compute_config()
612 ret = cv1800_pinctrl_schmitt2reg(pctrl, pin, arg); in cv1800_pinconf_compute_config()
639 static int cv1800_pin_set_config(struct cv1800_pinctrl *pctrl, in cv1800_pin_set_config() argument
643 struct cv1800_pin *pin = cv1800_get_pin(pctrl, pin_id); in cv1800_pin_set_config()
650 addr = cv1800_pinctrl_get_component_addr(pctrl, &pin->conf); in cv1800_pin_set_config()
652 raw_spin_lock_irqsave(&pctrl->lock, flags); in cv1800_pin_set_config()
654 raw_spin_unlock_irqrestore(&pctrl->lock, flags); in cv1800_pin_set_config()
663 struct cv1800_pinctrl *pctrl = pinctrl_dev_get_drvdata(pctldev); in cv1800_pconf_set() local
664 struct cv1800_pin *pin = cv1800_get_pin(pctrl, pin_id); in cv1800_pconf_set()
670 if (cv1800_pinconf_compute_config(pctrl, pin, in cv1800_pconf_set()
674 return cv1800_pin_set_config(pctrl, pin_id, value); in cv1800_pconf_set()
682 struct cv1800_pinctrl *pctrl = pinctrl_dev_get_drvdata(pctldev); in cv1800_pconf_group_set() local
694 if (cv1800_pinconf_compute_config(pctrl, pinmuxs[0].pin, in cv1800_pconf_group_set()
699 cv1800_pin_set_config(pctrl, group->grp.pins[i], value); in cv1800_pconf_group_set()
714 struct cv1800_pinctrl *pctrl; in cv1800_pinctrl_probe() local
725 pctrl = devm_kzalloc(dev, sizeof(*pctrl), GFP_KERNEL); in cv1800_pinctrl_probe()
726 if (!pctrl) in cv1800_pinctrl_probe()
729 pctrl->power_cfg = devm_kcalloc(dev, pctrl_data->npd, in cv1800_pinctrl_probe()
731 if (!pctrl->power_cfg) in cv1800_pinctrl_probe()
734 pctrl->regs[0] = devm_platform_ioremap_resource_byname(pdev, "sys"); in cv1800_pinctrl_probe()
735 if (IS_ERR(pctrl->regs[0])) in cv1800_pinctrl_probe()
736 return PTR_ERR(pctrl->regs[0]); in cv1800_pinctrl_probe()
738 pctrl->regs[1] = devm_platform_ioremap_resource_byname(pdev, "rtc"); in cv1800_pinctrl_probe()
739 if (IS_ERR(pctrl->regs[1])) in cv1800_pinctrl_probe()
740 return PTR_ERR(pctrl->regs[1]); in cv1800_pinctrl_probe()
742 pctrl->pdesc.name = dev_name(dev); in cv1800_pinctrl_probe()
743 pctrl->pdesc.pins = pctrl_data->pins; in cv1800_pinctrl_probe()
744 pctrl->pdesc.npins = pctrl_data->npins; in cv1800_pinctrl_probe()
745 pctrl->pdesc.pctlops = &cv1800_pctrl_ops; in cv1800_pinctrl_probe()
746 pctrl->pdesc.pmxops = &cv1800_pmx_ops; in cv1800_pinctrl_probe()
747 pctrl->pdesc.confops = &cv1800_pconf_ops; in cv1800_pinctrl_probe()
748 pctrl->pdesc.owner = THIS_MODULE; in cv1800_pinctrl_probe()
750 pctrl->data = pctrl_data; in cv1800_pinctrl_probe()
751 pctrl->dev = dev; in cv1800_pinctrl_probe()
752 raw_spin_lock_init(&pctrl->lock); in cv1800_pinctrl_probe()
753 mutex_init(&pctrl->mutex); in cv1800_pinctrl_probe()
755 platform_set_drvdata(pdev, pctrl); in cv1800_pinctrl_probe()
757 ret = devm_pinctrl_register_and_init(dev, &pctrl->pdesc, in cv1800_pinctrl_probe()
758 pctrl, &pctrl->pctl_dev); in cv1800_pinctrl_probe()
763 return pinctrl_enable(pctrl->pctl_dev); in cv1800_pinctrl_probe()