Lines Matching refs:atmel_pioctrl

129 struct atmel_pioctrl {  struct
161 static unsigned int atmel_gpio_read(struct atmel_pioctrl *atmel_pioctrl, in atmel_gpio_read() argument
164 return readl_relaxed(atmel_pioctrl->reg_base in atmel_gpio_read()
168 static void atmel_gpio_write(struct atmel_pioctrl *atmel_pioctrl, in atmel_gpio_write() argument
172 writel_relaxed(val, atmel_pioctrl->reg_base in atmel_gpio_write()
186 struct atmel_pioctrl *atmel_pioctrl = irq_data_get_irq_chip_data(d); in atmel_gpio_irq_set_type() local
187 struct atmel_pin *pin = atmel_pioctrl->pins[d->hwirq]; in atmel_gpio_irq_set_type()
190 atmel_gpio_write(atmel_pioctrl, pin->bank, ATMEL_PIO_MSKR, in atmel_gpio_irq_set_type()
192 reg = atmel_gpio_read(atmel_pioctrl, pin->bank, ATMEL_PIO_CFGR); in atmel_gpio_irq_set_type()
221 atmel_gpio_write(atmel_pioctrl, pin->bank, ATMEL_PIO_CFGR, reg); in atmel_gpio_irq_set_type()
228 struct atmel_pioctrl *atmel_pioctrl = irq_data_get_irq_chip_data(d); in atmel_gpio_irq_mask() local
229 struct atmel_pin *pin = atmel_pioctrl->pins[d->hwirq]; in atmel_gpio_irq_mask()
231 atmel_gpio_write(atmel_pioctrl, pin->bank, ATMEL_PIO_IDR, in atmel_gpio_irq_mask()
237 struct atmel_pioctrl *atmel_pioctrl = irq_data_get_irq_chip_data(d); in atmel_gpio_irq_unmask() local
238 struct atmel_pin *pin = atmel_pioctrl->pins[d->hwirq]; in atmel_gpio_irq_unmask()
240 atmel_gpio_write(atmel_pioctrl, pin->bank, ATMEL_PIO_IER, in atmel_gpio_irq_unmask()
246 struct atmel_pioctrl *atmel_pioctrl = irq_data_get_irq_chip_data(d); in atmel_gpio_irq_set_wake() local
251 irq_set_irq_wake(atmel_pioctrl->irqs[bank], on); in atmel_gpio_irq_set_wake()
254 atmel_pioctrl->pm_wakeup_sources[bank] |= BIT(line); in atmel_gpio_irq_set_wake()
256 atmel_pioctrl->pm_wakeup_sources[bank] &= ~(BIT(line)); in atmel_gpio_irq_set_wake()
272 struct atmel_pioctrl *atmel_pioctrl = gpiochip_get_data(chip); in atmel_gpio_to_irq() local
274 return irq_find_mapping(atmel_pioctrl->irq_domain, offset); in atmel_gpio_to_irq()
280 struct atmel_pioctrl *atmel_pioctrl = irq_desc_get_handler_data(desc); in atmel_gpio_irq_handler() local
286 for (n = 0; n < atmel_pioctrl->nbanks; n++) { in atmel_gpio_irq_handler()
287 if (atmel_pioctrl->irqs[n] == irq) { in atmel_gpio_irq_handler()
294 dev_err(atmel_pioctrl->dev, in atmel_gpio_irq_handler()
302 isr = (unsigned long)atmel_gpio_read(atmel_pioctrl, bank, in atmel_gpio_irq_handler()
304 isr &= (unsigned long)atmel_gpio_read(atmel_pioctrl, bank, in atmel_gpio_irq_handler()
311 atmel_pioctrl->gpio_chip, in atmel_gpio_irq_handler()
321 struct atmel_pioctrl *atmel_pioctrl = gpiochip_get_data(chip); in atmel_gpio_direction_input() local
322 struct atmel_pin *pin = atmel_pioctrl->pins[offset]; in atmel_gpio_direction_input()
325 atmel_gpio_write(atmel_pioctrl, pin->bank, ATMEL_PIO_MSKR, in atmel_gpio_direction_input()
327 reg = atmel_gpio_read(atmel_pioctrl, pin->bank, ATMEL_PIO_CFGR); in atmel_gpio_direction_input()
329 atmel_gpio_write(atmel_pioctrl, pin->bank, ATMEL_PIO_CFGR, reg); in atmel_gpio_direction_input()
336 struct atmel_pioctrl *atmel_pioctrl = gpiochip_get_data(chip); in atmel_gpio_get() local
337 struct atmel_pin *pin = atmel_pioctrl->pins[offset]; in atmel_gpio_get()
340 reg = atmel_gpio_read(atmel_pioctrl, pin->bank, ATMEL_PIO_PDSR); in atmel_gpio_get()
348 struct atmel_pioctrl *atmel_pioctrl = gpiochip_get_data(chip); in atmel_gpio_get_multiple() local
351 bitmap_zero(bits, atmel_pioctrl->npins); in atmel_gpio_get_multiple()
353 for (bank = 0; bank < atmel_pioctrl->nbanks; bank++) { in atmel_gpio_get_multiple()
365 reg = atmel_gpio_read(atmel_pioctrl, bank, ATMEL_PIO_PDSR); in atmel_gpio_get_multiple()
376 struct atmel_pioctrl *atmel_pioctrl = gpiochip_get_data(chip); in atmel_gpio_direction_output() local
377 struct atmel_pin *pin = atmel_pioctrl->pins[offset]; in atmel_gpio_direction_output()
380 atmel_gpio_write(atmel_pioctrl, pin->bank, in atmel_gpio_direction_output()
384 atmel_gpio_write(atmel_pioctrl, pin->bank, ATMEL_PIO_MSKR, in atmel_gpio_direction_output()
386 reg = atmel_gpio_read(atmel_pioctrl, pin->bank, ATMEL_PIO_CFGR); in atmel_gpio_direction_output()
388 atmel_gpio_write(atmel_pioctrl, pin->bank, ATMEL_PIO_CFGR, reg); in atmel_gpio_direction_output()
395 struct atmel_pioctrl *atmel_pioctrl = gpiochip_get_data(chip); in atmel_gpio_set() local
396 struct atmel_pin *pin = atmel_pioctrl->pins[offset]; in atmel_gpio_set()
398 atmel_gpio_write(atmel_pioctrl, pin->bank, in atmel_gpio_set()
406 struct atmel_pioctrl *atmel_pioctrl = gpiochip_get_data(chip); in atmel_gpio_set_multiple() local
409 for (bank = 0; bank < atmel_pioctrl->nbanks; bank++) { in atmel_gpio_set_multiple()
424 atmel_gpio_write(atmel_pioctrl, bank, ATMEL_PIO_SODR, bitmask); in atmel_gpio_set_multiple()
427 atmel_gpio_write(atmel_pioctrl, bank, ATMEL_PIO_CODR, bitmask); in atmel_gpio_set_multiple()
451 struct atmel_pioctrl *atmel_pioctrl = pinctrl_dev_get_drvdata(pctldev); in atmel_pin_config_read() local
452 unsigned int bank = atmel_pioctrl->pins[pin_id]->bank; in atmel_pin_config_read()
453 unsigned int line = atmel_pioctrl->pins[pin_id]->line; in atmel_pin_config_read()
454 void __iomem *addr = atmel_pioctrl->reg_base in atmel_pin_config_read()
467 struct atmel_pioctrl *atmel_pioctrl = pinctrl_dev_get_drvdata(pctldev); in atmel_pin_config_write() local
468 unsigned int bank = atmel_pioctrl->pins[pin_id]->bank; in atmel_pin_config_write()
469 unsigned int line = atmel_pioctrl->pins[pin_id]->line; in atmel_pin_config_write()
470 void __iomem *addr = atmel_pioctrl->reg_base in atmel_pin_config_write()
481 struct atmel_pioctrl *atmel_pioctrl = pinctrl_dev_get_drvdata(pctldev); in atmel_pctl_get_groups_count() local
483 return atmel_pioctrl->npins; in atmel_pctl_get_groups_count()
489 struct atmel_pioctrl *atmel_pioctrl = pinctrl_dev_get_drvdata(pctldev); in atmel_pctl_get_group_name() local
491 return atmel_pioctrl->groups[selector].name; in atmel_pctl_get_group_name()
499 struct atmel_pioctrl *atmel_pioctrl = pinctrl_dev_get_drvdata(pctldev); in atmel_pctl_get_group_pins() local
501 *pins = (unsigned int *)&atmel_pioctrl->groups[selector].pin; in atmel_pctl_get_group_pins()
510 struct atmel_pioctrl *atmel_pioctrl = pinctrl_dev_get_drvdata(pctldev); in atmel_pctl_find_group_by_pin() local
513 for (i = 0; i < atmel_pioctrl->npins; i++) { in atmel_pctl_find_group_by_pin()
514 struct atmel_group *grp = atmel_pioctrl->groups + i; in atmel_pctl_find_group_by_pin()
528 struct atmel_pioctrl *atmel_pioctrl = pinctrl_dev_get_drvdata(pctldev); in atmel_pctl_xlate_pinfunc() local
545 atmel_pioctrl->pins[pin_id]->mux = func_id; in atmel_pctl_xlate_pinfunc()
546 atmel_pioctrl->pins[pin_id]->ioset = ATMEL_GET_PIN_IOSET(pinfunc); in atmel_pctl_xlate_pinfunc()
548 if (np->parent == atmel_pioctrl->node) in atmel_pctl_xlate_pinfunc()
549 atmel_pioctrl->pins[pin_id]->device = np->name; in atmel_pctl_xlate_pinfunc()
551 atmel_pioctrl->pins[pin_id]->device = np->parent->name; in atmel_pctl_xlate_pinfunc()
694 struct atmel_pioctrl *atmel_pioctrl = pinctrl_dev_get_drvdata(pctldev); in atmel_pmx_get_function_groups() local
696 *groups = atmel_pioctrl->group_names; in atmel_pmx_get_function_groups()
697 *num_groups = atmel_pioctrl->npins; in atmel_pmx_get_function_groups()
706 struct atmel_pioctrl *atmel_pioctrl = pinctrl_dev_get_drvdata(pctldev); in atmel_pmx_set_mux() local
711 atmel_functions[function], atmel_pioctrl->groups[group].name); in atmel_pmx_set_mux()
713 pin = atmel_pioctrl->groups[group].pin; in atmel_pmx_set_mux()
734 struct atmel_pioctrl *atmel_pioctrl = pinctrl_dev_get_drvdata(pctldev); in atmel_conf_pin_config_group_get() local
736 struct atmel_group *grp = atmel_pioctrl->groups + group; in atmel_conf_pin_config_group_get()
776 if (!atmel_pioctrl->slew_rate_support) in atmel_conf_pin_config_group_get()
802 struct atmel_pioctrl *atmel_pioctrl = pinctrl_dev_get_drvdata(pctldev); in atmel_conf_pin_config_group_set() local
803 struct atmel_group *grp = atmel_pioctrl->groups + group; in atmel_conf_pin_config_group_set()
811 if (atmel_pioctrl->slew_rate_support) in atmel_conf_pin_config_group_set()
869 writel_relaxed(mask, atmel_pioctrl->reg_base + in atmel_conf_pin_config_group_set()
873 writel_relaxed(mask, atmel_pioctrl->reg_base + in atmel_conf_pin_config_group_set()
879 if (!atmel_pioctrl->slew_rate_support) in atmel_conf_pin_config_group_set()
936 struct atmel_pioctrl *atmel_pioctrl = pinctrl_dev_get_drvdata(pctldev); in atmel_conf_pin_config_dbg_show() local
939 if (!atmel_pioctrl->pins[pin_id]->device) in atmel_conf_pin_config_dbg_show()
943 atmel_pioctrl->pins[pin_id]->device, in atmel_conf_pin_config_dbg_show()
944 atmel_pioctrl->pins[pin_id]->ioset); in atmel_conf_pin_config_dbg_show()
959 if (atmel_pioctrl->slew_rate_support && (conf & ATMEL_PIO_SR_MASK)) in atmel_conf_pin_config_dbg_show()
993 struct atmel_pioctrl *atmel_pioctrl = dev_get_drvdata(dev); in atmel_pctrl_suspend() local
1000 for (i = 0; i < atmel_pioctrl->nbanks; i++) { in atmel_pctrl_suspend()
1001 atmel_pioctrl->pm_suspend_backup[i].imr = in atmel_pctrl_suspend()
1002 atmel_gpio_read(atmel_pioctrl, i, ATMEL_PIO_IMR); in atmel_pctrl_suspend()
1003 atmel_gpio_write(atmel_pioctrl, i, ATMEL_PIO_IDR, in atmel_pctrl_suspend()
1004 ~atmel_pioctrl->pm_wakeup_sources[i]); in atmel_pctrl_suspend()
1005 atmel_pioctrl->pm_suspend_backup[i].odsr = in atmel_pctrl_suspend()
1006 atmel_gpio_read(atmel_pioctrl, i, ATMEL_PIO_ODSR); in atmel_pctrl_suspend()
1008 atmel_gpio_write(atmel_pioctrl, i, in atmel_pctrl_suspend()
1010 atmel_pioctrl->pm_suspend_backup[i].cfgr[j] = in atmel_pctrl_suspend()
1011 atmel_gpio_read(atmel_pioctrl, i, in atmel_pctrl_suspend()
1021 struct atmel_pioctrl *atmel_pioctrl = dev_get_drvdata(dev); in atmel_pctrl_resume() local
1024 for (i = 0; i < atmel_pioctrl->nbanks; i++) { in atmel_pctrl_resume()
1025 atmel_gpio_write(atmel_pioctrl, i, ATMEL_PIO_IER, in atmel_pctrl_resume()
1026 atmel_pioctrl->pm_suspend_backup[i].imr); in atmel_pctrl_resume()
1027 atmel_gpio_write(atmel_pioctrl, i, ATMEL_PIO_SODR, in atmel_pctrl_resume()
1028 atmel_pioctrl->pm_suspend_backup[i].odsr); in atmel_pctrl_resume()
1030 atmel_gpio_write(atmel_pioctrl, i, in atmel_pctrl_resume()
1032 atmel_gpio_write(atmel_pioctrl, i, ATMEL_PIO_CFGR, in atmel_pctrl_resume()
1033 atmel_pioctrl->pm_suspend_backup[i].cfgr[j]); in atmel_pctrl_resume()
1084 struct atmel_pioctrl *atmel_pioctrl; in atmel_pinctrl_probe() local
1087 atmel_pioctrl = devm_kzalloc(dev, sizeof(*atmel_pioctrl), GFP_KERNEL); in atmel_pinctrl_probe()
1088 if (!atmel_pioctrl) in atmel_pinctrl_probe()
1090 atmel_pioctrl->dev = dev; in atmel_pinctrl_probe()
1091 atmel_pioctrl->node = dev->of_node; in atmel_pinctrl_probe()
1092 platform_set_drvdata(pdev, atmel_pioctrl); in atmel_pinctrl_probe()
1098 atmel_pioctrl->nbanks = atmel_pioctrl_data->nbanks; in atmel_pinctrl_probe()
1099 atmel_pioctrl->npins = atmel_pioctrl->nbanks * ATMEL_PIO_NPINS_PER_BANK; in atmel_pinctrl_probe()
1102 atmel_pioctrl->npins -= ATMEL_PIO_NPINS_PER_BANK; in atmel_pinctrl_probe()
1103 atmel_pioctrl->npins += atmel_pioctrl_data->last_bank_count; in atmel_pinctrl_probe()
1105 atmel_pioctrl->slew_rate_support = atmel_pioctrl_data->slew_rate_support; in atmel_pinctrl_probe()
1107 atmel_pioctrl->reg_base = devm_platform_ioremap_resource(pdev, 0); in atmel_pinctrl_probe()
1108 if (IS_ERR(atmel_pioctrl->reg_base)) in atmel_pinctrl_probe()
1109 return PTR_ERR(atmel_pioctrl->reg_base); in atmel_pinctrl_probe()
1111 atmel_pioctrl->clk = devm_clk_get_enabled(dev, NULL); in atmel_pinctrl_probe()
1112 if (IS_ERR(atmel_pioctrl->clk)) in atmel_pinctrl_probe()
1113 return dev_err_probe(dev, PTR_ERR(atmel_pioctrl->clk), "failed to get clock\n"); in atmel_pinctrl_probe()
1115 atmel_pioctrl->pins = devm_kcalloc(dev, in atmel_pinctrl_probe()
1116 atmel_pioctrl->npins, in atmel_pinctrl_probe()
1117 sizeof(*atmel_pioctrl->pins), in atmel_pinctrl_probe()
1119 if (!atmel_pioctrl->pins) in atmel_pinctrl_probe()
1122 pin_desc = devm_kcalloc(dev, atmel_pioctrl->npins, sizeof(*pin_desc), in atmel_pinctrl_probe()
1127 atmel_pinctrl_desc.npins = atmel_pioctrl->npins; in atmel_pinctrl_probe()
1133 atmel_pioctrl->npins, sizeof(*group_names), in atmel_pinctrl_probe()
1137 atmel_pioctrl->group_names = group_names; in atmel_pinctrl_probe()
1139 atmel_pioctrl->groups = devm_kcalloc(&pdev->dev, in atmel_pinctrl_probe()
1140 atmel_pioctrl->npins, sizeof(*atmel_pioctrl->groups), in atmel_pinctrl_probe()
1142 if (!atmel_pioctrl->groups) in atmel_pinctrl_probe()
1144 for (i = 0 ; i < atmel_pioctrl->npins; i++) { in atmel_pinctrl_probe()
1145 struct atmel_group *group = atmel_pioctrl->groups + i; in atmel_pinctrl_probe()
1149 atmel_pioctrl->pins[i] = devm_kzalloc(dev, in atmel_pinctrl_probe()
1150 sizeof(**atmel_pioctrl->pins), GFP_KERNEL); in atmel_pinctrl_probe()
1151 if (!atmel_pioctrl->pins[i]) in atmel_pinctrl_probe()
1154 atmel_pioctrl->pins[i]->pin_id = i; in atmel_pinctrl_probe()
1155 atmel_pioctrl->pins[i]->bank = bank; in atmel_pinctrl_probe()
1156 atmel_pioctrl->pins[i]->line = line; in atmel_pinctrl_probe()
1171 atmel_pioctrl->gpio_chip = &atmel_gpio_chip; in atmel_pinctrl_probe()
1172 atmel_pioctrl->gpio_chip->ngpio = atmel_pioctrl->npins; in atmel_pinctrl_probe()
1173 atmel_pioctrl->gpio_chip->label = dev_name(dev); in atmel_pinctrl_probe()
1174 atmel_pioctrl->gpio_chip->parent = dev; in atmel_pinctrl_probe()
1175 atmel_pioctrl->gpio_chip->names = atmel_pioctrl->group_names; in atmel_pinctrl_probe()
1176 atmel_pioctrl->gpio_chip->set_config = gpiochip_generic_config; in atmel_pinctrl_probe()
1178 atmel_pioctrl->pm_wakeup_sources = devm_kcalloc(dev, in atmel_pinctrl_probe()
1179 atmel_pioctrl->nbanks, in atmel_pinctrl_probe()
1180 sizeof(*atmel_pioctrl->pm_wakeup_sources), in atmel_pinctrl_probe()
1182 if (!atmel_pioctrl->pm_wakeup_sources) in atmel_pinctrl_probe()
1185 atmel_pioctrl->pm_suspend_backup = devm_kcalloc(dev, in atmel_pinctrl_probe()
1186 atmel_pioctrl->nbanks, in atmel_pinctrl_probe()
1187 sizeof(*atmel_pioctrl->pm_suspend_backup), in atmel_pinctrl_probe()
1189 if (!atmel_pioctrl->pm_suspend_backup) in atmel_pinctrl_probe()
1192 atmel_pioctrl->irqs = devm_kcalloc(dev, in atmel_pinctrl_probe()
1193 atmel_pioctrl->nbanks, in atmel_pinctrl_probe()
1194 sizeof(*atmel_pioctrl->irqs), in atmel_pinctrl_probe()
1196 if (!atmel_pioctrl->irqs) in atmel_pinctrl_probe()
1200 for (i = 0; i < atmel_pioctrl->nbanks; i++) { in atmel_pinctrl_probe()
1207 atmel_pioctrl->irqs[i] = ret; in atmel_pinctrl_probe()
1208 irq_set_chained_handler_and_data(ret, atmel_gpio_irq_handler, atmel_pioctrl); in atmel_pinctrl_probe()
1212 atmel_pioctrl->irq_domain = irq_domain_add_linear(dev->of_node, in atmel_pinctrl_probe()
1213 atmel_pioctrl->gpio_chip->ngpio, in atmel_pinctrl_probe()
1215 if (!atmel_pioctrl->irq_domain) in atmel_pinctrl_probe()
1218 for (i = 0; i < atmel_pioctrl->npins; i++) { in atmel_pinctrl_probe()
1219 int irq = irq_create_mapping(atmel_pioctrl->irq_domain, i); in atmel_pinctrl_probe()
1223 irq_set_chip_data(irq, atmel_pioctrl); in atmel_pinctrl_probe()
1230 atmel_pioctrl->pinctrl_dev = devm_pinctrl_register(&pdev->dev, in atmel_pinctrl_probe()
1232 atmel_pioctrl); in atmel_pinctrl_probe()
1233 if (IS_ERR(atmel_pioctrl->pinctrl_dev)) { in atmel_pinctrl_probe()
1234 ret = PTR_ERR(atmel_pioctrl->pinctrl_dev); in atmel_pinctrl_probe()
1239 ret = gpiochip_add_data(atmel_pioctrl->gpio_chip, atmel_pioctrl); in atmel_pinctrl_probe()
1245 ret = gpiochip_add_pin_range(atmel_pioctrl->gpio_chip, dev_name(dev), in atmel_pinctrl_probe()
1246 0, 0, atmel_pioctrl->gpio_chip->ngpio); in atmel_pinctrl_probe()
1257 gpiochip_remove(atmel_pioctrl->gpio_chip); in atmel_pinctrl_probe()
1260 irq_domain_remove(atmel_pioctrl->irq_domain); in atmel_pinctrl_probe()