Lines Matching refs:pfc
29 struct sh_pfc *pfc; member
40 return chip->pfc; in gpio_to_pfc()
47 int idx = sh_pfc_get_pin_index(chip->pfc, offset); in gpio_get_data_reg()
74 struct sh_pfc *pfc = chip->pfc; in gpio_setup_data_reg() local
76 const struct sh_pfc_pin *pin = &pfc->info->pins[idx]; in gpio_setup_data_reg()
81 for (i = 0, dreg = pfc->info->data_regs; dreg->reg_width; ++i, ++dreg) { in gpio_setup_data_reg()
96 struct sh_pfc *pfc = chip->pfc; in gpio_setup_data_regs() local
103 for (i = 0; pfc->info->data_regs[i].reg_width; ++i) in gpio_setup_data_regs()
106 chip->regs = devm_kcalloc(pfc->dev, i, sizeof(*chip->regs), in gpio_setup_data_regs()
111 for (i = 0, dreg = pfc->info->data_regs; dreg->reg_width; ++i, ++dreg) { in gpio_setup_data_regs()
116 for (i = 0; i < pfc->info->nr_pins; i++) { in gpio_setup_data_regs()
117 if (pfc->info->pins[i].enum_id == 0) in gpio_setup_data_regs()
132 struct sh_pfc *pfc = gpio_to_pfc(gc); in gpio_pin_request() local
133 int idx = sh_pfc_get_pin_index(pfc, offset); in gpio_pin_request()
135 if (idx < 0 || pfc->info->pins[idx].enum_id == 0) in gpio_pin_request()
199 struct sh_pfc *pfc = gpio_to_pfc(gc); in gpio_pin_to_irq() local
202 for (i = 0; i < pfc->info->gpio_irq_size; i++) { in gpio_pin_to_irq()
203 const short *gpios = pfc->info->gpio_irq[i].gpios; in gpio_pin_to_irq()
207 return pfc->irqs[i]; in gpio_pin_to_irq()
216 struct sh_pfc *pfc = chip->pfc; in gpio_pin_setup() local
220 chip->pins = devm_kcalloc(pfc->dev, in gpio_pin_setup()
221 pfc->info->nr_pins, sizeof(*chip->pins), in gpio_pin_setup()
238 gc->label = pfc->info->name; in gpio_pin_setup()
239 gc->parent = pfc->dev; in gpio_pin_setup()
242 gc->ngpio = pfc->nr_gpio_pins; in gpio_pin_setup()
254 struct sh_pfc *pfc = gpio_to_pfc(gc); in gpio_function_request() local
255 unsigned int mark = pfc->info->func_gpios[offset].enum_id; in gpio_function_request()
259 dev_notice_once(pfc->dev, in gpio_function_request()
265 spin_lock_irqsave(&pfc->lock, flags); in gpio_function_request()
266 ret = sh_pfc_config_mux(pfc, mark, PINMUX_TYPE_FUNCTION); in gpio_function_request()
267 spin_unlock_irqrestore(&pfc->lock, flags); in gpio_function_request()
274 struct sh_pfc *pfc = chip->pfc; in gpio_function_setup() local
279 gc->label = pfc->info->name; in gpio_function_setup()
281 gc->base = pfc->nr_gpio_pins; in gpio_function_setup()
282 gc->ngpio = pfc->info->nr_func_gpios; in gpio_function_setup()
293 sh_pfc_add_gpiochip(struct sh_pfc *pfc, int(*setup)(struct sh_pfc_chip *), in sh_pfc_add_gpiochip() argument
299 chip = devm_kzalloc(pfc->dev, sizeof(*chip), GFP_KERNEL); in sh_pfc_add_gpiochip()
304 chip->pfc = pfc; in sh_pfc_add_gpiochip()
310 ret = devm_gpiochip_add_data(pfc->dev, &chip->gpio_chip, chip); in sh_pfc_add_gpiochip()
314 dev_info(pfc->dev, "%s handling gpio %u -> %u\n", in sh_pfc_add_gpiochip()
321 int sh_pfc_register_gpiochip(struct sh_pfc *pfc) in sh_pfc_register_gpiochip() argument
327 if (pfc->info->data_regs == NULL) in sh_pfc_register_gpiochip()
335 address = pfc->info->data_regs[0].reg; in sh_pfc_register_gpiochip()
336 for (i = 0; i < pfc->num_windows; ++i) { in sh_pfc_register_gpiochip()
337 struct sh_pfc_window *window = &pfc->windows[i]; in sh_pfc_register_gpiochip()
344 if (i == pfc->num_windows) in sh_pfc_register_gpiochip()
348 if (pfc->num_irqs != pfc->info->gpio_irq_size) { in sh_pfc_register_gpiochip()
349 dev_err(pfc->dev, "invalid number of IRQ resources\n"); in sh_pfc_register_gpiochip()
354 chip = sh_pfc_add_gpiochip(pfc, gpio_pin_setup, &pfc->windows[i]); in sh_pfc_register_gpiochip()
358 pfc->gpio = chip; in sh_pfc_register_gpiochip()
360 if (IS_ENABLED(CONFIG_OF) && pfc->dev->of_node) in sh_pfc_register_gpiochip()
370 for (i = 0; i < pfc->nr_ranges; ++i) { in sh_pfc_register_gpiochip()
371 const struct sh_pfc_pin_range *range = &pfc->ranges[i]; in sh_pfc_register_gpiochip()
374 if (range->start >= pfc->nr_gpio_pins) in sh_pfc_register_gpiochip()
378 dev_name(pfc->dev), range->start, range->start, in sh_pfc_register_gpiochip()
385 if (pfc->info->nr_func_gpios) { in sh_pfc_register_gpiochip()
386 chip = sh_pfc_add_gpiochip(pfc, gpio_function_setup, NULL); in sh_pfc_register_gpiochip()