Lines Matching full:pctrl

69 static u32 owl_read_field(struct owl_pinctrl *pctrl, u32 reg,  in owl_read_field()  argument
74 tmp = readl_relaxed(pctrl->base + reg); in owl_read_field()
80 static void owl_write_field(struct owl_pinctrl *pctrl, u32 reg, u32 arg, in owl_write_field() argument
88 owl_update_bits(pctrl->base + reg, mask, (arg << bit)); in owl_write_field()
93 struct owl_pinctrl *pctrl = pinctrl_dev_get_drvdata(pctrldev); in owl_get_groups_count() local
95 return pctrl->soc->ngroups; in owl_get_groups_count()
101 struct owl_pinctrl *pctrl = pinctrl_dev_get_drvdata(pctrldev); in owl_get_group_name() local
103 return pctrl->soc->groups[group].name; in owl_get_group_name()
111 struct owl_pinctrl *pctrl = pinctrl_dev_get_drvdata(pctrldev); in owl_get_group_pins() local
113 *pins = pctrl->soc->groups[group].pads; in owl_get_group_pins()
114 *num_pins = pctrl->soc->groups[group].npads; in owl_get_group_pins()
123 struct owl_pinctrl *pctrl = pinctrl_dev_get_drvdata(pctrldev); in owl_pin_dbg_show() local
125 seq_printf(s, "%s", dev_name(pctrl->dev)); in owl_pin_dbg_show()
139 struct owl_pinctrl *pctrl = pinctrl_dev_get_drvdata(pctrldev); in owl_get_funcs_count() local
141 return pctrl->soc->nfunctions; in owl_get_funcs_count()
147 struct owl_pinctrl *pctrl = pinctrl_dev_get_drvdata(pctrldev); in owl_get_func_name() local
149 return pctrl->soc->functions[function].name; in owl_get_func_name()
157 struct owl_pinctrl *pctrl = pinctrl_dev_get_drvdata(pctrldev); in owl_get_func_groups() local
159 *groups = pctrl->soc->functions[function].groups; in owl_get_func_groups()
160 *num_groups = pctrl->soc->functions[function].ngroups; in owl_get_func_groups()
196 struct owl_pinctrl *pctrl = pinctrl_dev_get_drvdata(pctrldev); in owl_set_mux() local
201 g = &pctrl->soc->groups[group]; in owl_set_mux()
206 raw_spin_lock_irqsave(&pctrl->lock, flags); in owl_set_mux()
208 owl_update_bits(pctrl->base + g->mfpctl_reg, mask, val); in owl_set_mux()
210 raw_spin_unlock_irqrestore(&pctrl->lock, flags); in owl_set_mux()
258 struct owl_pinctrl *pctrl = pinctrl_dev_get_drvdata(pctrldev); in owl_pin_config_get() local
263 info = &pctrl->soc->padinfo[pin]; in owl_pin_config_get()
269 arg = owl_read_field(pctrl, reg, bit, width); in owl_pin_config_get()
271 if (!pctrl->soc->padctl_val2arg) in owl_pin_config_get()
274 ret = pctrl->soc->padctl_val2arg(info, param, &arg); in owl_pin_config_get()
288 struct owl_pinctrl *pctrl = pinctrl_dev_get_drvdata(pctrldev); in owl_pin_config_set() local
295 info = &pctrl->soc->padinfo[pin]; in owl_pin_config_set()
305 if (!pctrl->soc->padctl_arg2val) in owl_pin_config_set()
308 ret = pctrl->soc->padctl_arg2val(info, param, &arg); in owl_pin_config_set()
312 raw_spin_lock_irqsave(&pctrl->lock, flags); in owl_pin_config_set()
314 owl_write_field(pctrl, reg, arg, bit, width); in owl_pin_config_set()
316 raw_spin_unlock_irqrestore(&pctrl->lock, flags); in owl_pin_config_set()
427 struct owl_pinctrl *pctrl = pinctrl_dev_get_drvdata(pctrldev); in owl_group_config_get() local
432 g = &pctrl->soc->groups[group]; in owl_group_config_get()
438 arg = owl_read_field(pctrl, reg, bit, width); in owl_group_config_get()
455 struct owl_pinctrl *pctrl = pinctrl_dev_get_drvdata(pctrldev); in owl_group_config_set() local
461 g = &pctrl->soc->groups[group]; in owl_group_config_set()
476 raw_spin_lock_irqsave(&pctrl->lock, flags); in owl_group_config_set()
478 owl_write_field(pctrl, reg, arg, bit, width); in owl_group_config_set()
480 raw_spin_unlock_irqrestore(&pctrl->lock, flags); in owl_group_config_set()
502 owl_gpio_get_port(struct owl_pinctrl *pctrl, unsigned int *pin) in owl_gpio_get_port() argument
506 for (i = 0; i < pctrl->soc->nports; i++) { in owl_gpio_get_port()
507 const struct owl_gpio_port *port = &pctrl->soc->ports[i]; in owl_gpio_get_port()
536 struct owl_pinctrl *pctrl = gpiochip_get_data(chip); in owl_gpio_request() local
541 port = owl_gpio_get_port(pctrl, &offset); in owl_gpio_request()
545 gpio_base = pctrl->base + port->offset; in owl_gpio_request()
551 raw_spin_lock_irqsave(&pctrl->lock, flags); in owl_gpio_request()
553 raw_spin_unlock_irqrestore(&pctrl->lock, flags); in owl_gpio_request()
560 struct owl_pinctrl *pctrl = gpiochip_get_data(chip); in owl_gpio_free() local
565 port = owl_gpio_get_port(pctrl, &offset); in owl_gpio_free()
569 gpio_base = pctrl->base + port->offset; in owl_gpio_free()
571 raw_spin_lock_irqsave(&pctrl->lock, flags); in owl_gpio_free()
577 raw_spin_unlock_irqrestore(&pctrl->lock, flags); in owl_gpio_free()
582 struct owl_pinctrl *pctrl = gpiochip_get_data(chip); in owl_gpio_get() local
588 port = owl_gpio_get_port(pctrl, &offset); in owl_gpio_get()
592 gpio_base = pctrl->base + port->offset; in owl_gpio_get()
594 raw_spin_lock_irqsave(&pctrl->lock, flags); in owl_gpio_get()
596 raw_spin_unlock_irqrestore(&pctrl->lock, flags); in owl_gpio_get()
603 struct owl_pinctrl *pctrl = gpiochip_get_data(chip); in owl_gpio_set() local
608 port = owl_gpio_get_port(pctrl, &offset); in owl_gpio_set()
612 gpio_base = pctrl->base + port->offset; in owl_gpio_set()
614 raw_spin_lock_irqsave(&pctrl->lock, flags); in owl_gpio_set()
616 raw_spin_unlock_irqrestore(&pctrl->lock, flags); in owl_gpio_set()
621 struct owl_pinctrl *pctrl = gpiochip_get_data(chip); in owl_gpio_direction_input() local
626 port = owl_gpio_get_port(pctrl, &offset); in owl_gpio_direction_input()
630 gpio_base = pctrl->base + port->offset; in owl_gpio_direction_input()
632 raw_spin_lock_irqsave(&pctrl->lock, flags); in owl_gpio_direction_input()
635 raw_spin_unlock_irqrestore(&pctrl->lock, flags); in owl_gpio_direction_input()
643 struct owl_pinctrl *pctrl = gpiochip_get_data(chip); in owl_gpio_direction_output() local
648 port = owl_gpio_get_port(pctrl, &offset); in owl_gpio_direction_output()
652 gpio_base = pctrl->base + port->offset; in owl_gpio_direction_output()
654 raw_spin_lock_irqsave(&pctrl->lock, flags); in owl_gpio_direction_output()
658 raw_spin_unlock_irqrestore(&pctrl->lock, flags); in owl_gpio_direction_output()
663 static void irq_set_type(struct owl_pinctrl *pctrl, int gpio, unsigned int type) in irq_set_type() argument
678 if (owl_gpio_get(&pctrl->chip, gpio)) in irq_set_type()
704 port = owl_gpio_get_port(pctrl, &gpio); in irq_set_type()
708 gpio_base = pctrl->base + port->offset; in irq_set_type()
710 raw_spin_lock_irqsave(&pctrl->lock, flags); in irq_set_type()
718 raw_spin_unlock_irqrestore(&pctrl->lock, flags); in irq_set_type()
724 struct owl_pinctrl *pctrl = gpiochip_get_data(gc); in owl_gpio_irq_mask() local
732 port = owl_gpio_get_port(pctrl, &gpio); in owl_gpio_irq_mask()
736 gpio_base = pctrl->base + port->offset; in owl_gpio_irq_mask()
738 raw_spin_lock_irqsave(&pctrl->lock, flags); in owl_gpio_irq_mask()
748 raw_spin_unlock_irqrestore(&pctrl->lock, flags); in owl_gpio_irq_mask()
756 struct owl_pinctrl *pctrl = gpiochip_get_data(gc); in owl_gpio_irq_unmask() local
764 port = owl_gpio_get_port(pctrl, &gpio); in owl_gpio_irq_unmask()
770 gpio_base = pctrl->base + port->offset; in owl_gpio_irq_unmask()
771 raw_spin_lock_irqsave(&pctrl->lock, flags); in owl_gpio_irq_unmask()
782 raw_spin_unlock_irqrestore(&pctrl->lock, flags); in owl_gpio_irq_unmask()
788 struct owl_pinctrl *pctrl = gpiochip_get_data(gc); in owl_gpio_irq_ack() local
801 irq_set_type(pctrl, hwirq, IRQ_TYPE_EDGE_FALLING); in owl_gpio_irq_ack()
803 irq_set_type(pctrl, hwirq, IRQ_TYPE_EDGE_RISING); in owl_gpio_irq_ack()
806 port = owl_gpio_get_port(pctrl, &gpio); in owl_gpio_irq_ack()
810 gpio_base = pctrl->base + port->offset; in owl_gpio_irq_ack()
812 raw_spin_lock_irqsave(&pctrl->lock, flags); in owl_gpio_irq_ack()
817 raw_spin_unlock_irqrestore(&pctrl->lock, flags); in owl_gpio_irq_ack()
823 struct owl_pinctrl *pctrl = gpiochip_get_data(gc); in owl_gpio_irq_set_type() local
830 irq_set_type(pctrl, data->hwirq, type); in owl_gpio_irq_set_type()
847 struct owl_pinctrl *pctrl = irq_desc_get_handler_data(desc); in owl_gpio_irq_handler() local
849 struct irq_domain *domain = pctrl->chip.irq.domain; in owl_gpio_irq_handler()
858 for (i = 0; i < pctrl->soc->nports; i++) { in owl_gpio_irq_handler()
859 port = &pctrl->soc->ports[i]; in owl_gpio_irq_handler()
860 base = pctrl->base + port->offset; in owl_gpio_irq_handler()
863 if (parent != pctrl->irq[i]) in owl_gpio_irq_handler()
882 static int owl_gpio_init(struct owl_pinctrl *pctrl) in owl_gpio_init() argument
888 chip = &pctrl->chip; in owl_gpio_init()
890 chip->ngpio = pctrl->soc->ngpios; in owl_gpio_init()
891 chip->label = dev_name(pctrl->dev); in owl_gpio_init()
892 chip->parent = pctrl->dev; in owl_gpio_init()
900 gpio_irq->parent_handler_data = pctrl; in owl_gpio_init()
901 gpio_irq->num_parents = pctrl->num_irq; in owl_gpio_init()
902 gpio_irq->parents = pctrl->irq; in owl_gpio_init()
904 gpio_irq->map = devm_kcalloc(pctrl->dev, chip->ngpio, in owl_gpio_init()
909 for (i = 0, offset = 0; i < pctrl->soc->nports; i++) { in owl_gpio_init()
910 const struct owl_gpio_port *port = &pctrl->soc->ports[i]; in owl_gpio_init()
918 ret = gpiochip_add_data(&pctrl->chip, pctrl); in owl_gpio_init()
920 dev_err(pctrl->dev, "failed to register gpiochip\n"); in owl_gpio_init()
930 struct owl_pinctrl *pctrl; in owl_pinctrl_probe() local
933 pctrl = devm_kzalloc(&pdev->dev, sizeof(*pctrl), GFP_KERNEL); in owl_pinctrl_probe()
934 if (!pctrl) in owl_pinctrl_probe()
937 pctrl->base = devm_platform_ioremap_resource(pdev, 0); in owl_pinctrl_probe()
938 if (IS_ERR(pctrl->base)) in owl_pinctrl_probe()
939 return PTR_ERR(pctrl->base); in owl_pinctrl_probe()
942 pctrl->clk = devm_clk_get(&pdev->dev, NULL); in owl_pinctrl_probe()
943 if (IS_ERR(pctrl->clk)) { in owl_pinctrl_probe()
945 return PTR_ERR(pctrl->clk); in owl_pinctrl_probe()
948 ret = clk_prepare_enable(pctrl->clk); in owl_pinctrl_probe()
954 raw_spin_lock_init(&pctrl->lock); in owl_pinctrl_probe()
960 pctrl->chip.direction_input = owl_gpio_direction_input; in owl_pinctrl_probe()
961 pctrl->chip.direction_output = owl_gpio_direction_output; in owl_pinctrl_probe()
962 pctrl->chip.get = owl_gpio_get; in owl_pinctrl_probe()
963 pctrl->chip.set = owl_gpio_set; in owl_pinctrl_probe()
964 pctrl->chip.request = owl_gpio_request; in owl_pinctrl_probe()
965 pctrl->chip.free = owl_gpio_free; in owl_pinctrl_probe()
967 pctrl->soc = soc_data; in owl_pinctrl_probe()
968 pctrl->dev = &pdev->dev; in owl_pinctrl_probe()
970 pctrl->pctrldev = devm_pinctrl_register(&pdev->dev, in owl_pinctrl_probe()
971 &owl_pinctrl_desc, pctrl); in owl_pinctrl_probe()
972 if (IS_ERR(pctrl->pctrldev)) { in owl_pinctrl_probe()
974 ret = PTR_ERR(pctrl->pctrldev); in owl_pinctrl_probe()
982 pctrl->num_irq = ret; in owl_pinctrl_probe()
984 pctrl->irq = devm_kcalloc(&pdev->dev, pctrl->num_irq, in owl_pinctrl_probe()
985 sizeof(*pctrl->irq), GFP_KERNEL); in owl_pinctrl_probe()
986 if (!pctrl->irq) { in owl_pinctrl_probe()
991 for (i = 0; i < pctrl->num_irq ; i++) { in owl_pinctrl_probe()
995 pctrl->irq[i] = ret; in owl_pinctrl_probe()
998 ret = owl_gpio_init(pctrl); in owl_pinctrl_probe()
1002 platform_set_drvdata(pdev, pctrl); in owl_pinctrl_probe()
1007 clk_disable_unprepare(pctrl->clk); in owl_pinctrl_probe()