Lines Matching +full:norequest +full:- +full:mask
1 // SPDX-License-Identifier: GPL-2.0-only
3 * Copyright (C) ST-Ericsson SA 2010
5 * Author: Rabin Vincent <rabin.vincent@stericsson.com> for ST-Ericsson
44 struct stmpe *stmpe = stmpe_gpio->stmpe; in stmpe_gpio_get()
45 u8 reg = stmpe->regs[STMPE_IDX_GPMR_LSB + (offset / 8)]; in stmpe_gpio_get()
46 u8 mask = BIT(offset % 8); in stmpe_gpio_get() local
53 return !!(ret & mask); in stmpe_gpio_get()
59 struct stmpe *stmpe = stmpe_gpio->stmpe; in stmpe_gpio_set()
61 u8 reg = stmpe->regs[which + (offset / 8)]; in stmpe_gpio_set()
62 u8 mask = BIT(offset % 8); in stmpe_gpio_set() local
68 if (stmpe->regs[STMPE_IDX_GPSR_LSB] == stmpe->regs[STMPE_IDX_GPCR_LSB]) in stmpe_gpio_set()
69 stmpe_set_bits(stmpe, reg, mask, val ? mask : 0); in stmpe_gpio_set()
71 stmpe_reg_write(stmpe, reg, mask); in stmpe_gpio_set()
78 struct stmpe *stmpe = stmpe_gpio->stmpe; in stmpe_gpio_get_direction()
79 u8 reg = stmpe->regs[STMPE_IDX_GPDR_LSB] - (offset / 8); in stmpe_gpio_get_direction()
80 u8 mask = BIT(offset % 8); in stmpe_gpio_get_direction() local
87 if (ret & mask) in stmpe_gpio_get_direction()
97 struct stmpe *stmpe = stmpe_gpio->stmpe; in stmpe_gpio_direction_output()
98 u8 reg = stmpe->regs[STMPE_IDX_GPDR_LSB + (offset / 8)]; in stmpe_gpio_direction_output()
99 u8 mask = BIT(offset % 8); in stmpe_gpio_direction_output() local
103 return stmpe_set_bits(stmpe, reg, mask, mask); in stmpe_gpio_direction_output()
110 struct stmpe *stmpe = stmpe_gpio->stmpe; in stmpe_gpio_direction_input()
111 u8 reg = stmpe->regs[STMPE_IDX_GPDR_LSB + (offset / 8)]; in stmpe_gpio_direction_input()
112 u8 mask = BIT(offset % 8); in stmpe_gpio_direction_input() local
114 return stmpe_set_bits(stmpe, reg, mask, 0); in stmpe_gpio_direction_input()
120 struct stmpe *stmpe = stmpe_gpio->stmpe; in stmpe_gpio_request()
122 if (stmpe_gpio->norequest_mask & BIT(offset)) in stmpe_gpio_request()
123 return -EINVAL; in stmpe_gpio_request()
144 int offset = d->hwirq; in stmpe_gpio_irq_set_type()
146 int mask = BIT(offset % 8); in stmpe_gpio_irq_set_type() local
149 return -EINVAL; in stmpe_gpio_irq_set_type()
152 if (stmpe_gpio->stmpe->partnum == STMPE801 || in stmpe_gpio_irq_set_type()
153 stmpe_gpio->stmpe->partnum == STMPE1600) in stmpe_gpio_irq_set_type()
157 stmpe_gpio->regs[REG_RE][regoffset] |= mask; in stmpe_gpio_irq_set_type()
159 stmpe_gpio->regs[REG_RE][regoffset] &= ~mask; in stmpe_gpio_irq_set_type()
162 stmpe_gpio->regs[REG_FE][regoffset] |= mask; in stmpe_gpio_irq_set_type()
164 stmpe_gpio->regs[REG_FE][regoffset] &= ~mask; in stmpe_gpio_irq_set_type()
174 mutex_lock(&stmpe_gpio->irq_lock); in stmpe_gpio_irq_lock()
181 struct stmpe *stmpe = stmpe_gpio->stmpe; in stmpe_gpio_irq_sync_unlock()
182 int num_banks = DIV_ROUND_UP(stmpe->num_gpios, 8); in stmpe_gpio_irq_sync_unlock()
201 if (stmpe->partnum == STMPE1600) { in stmpe_gpio_irq_sync_unlock()
202 stmpe_reg_read(stmpe, stmpe->regs[STMPE_IDX_GPMR_LSB]); in stmpe_gpio_irq_sync_unlock()
203 stmpe_reg_read(stmpe, stmpe->regs[STMPE_IDX_GPMR_CSB]); in stmpe_gpio_irq_sync_unlock()
208 if ((stmpe->partnum == STMPE801 || in stmpe_gpio_irq_sync_unlock()
209 stmpe->partnum == STMPE1600) && in stmpe_gpio_irq_sync_unlock()
214 u8 old = stmpe_gpio->oldregs[i][j]; in stmpe_gpio_irq_sync_unlock()
215 u8 new = stmpe_gpio->regs[i][j]; in stmpe_gpio_irq_sync_unlock()
220 stmpe_gpio->oldregs[i][j] = new; in stmpe_gpio_irq_sync_unlock()
221 stmpe_reg_write(stmpe, stmpe->regs[regmap[i][j]], new); in stmpe_gpio_irq_sync_unlock()
225 mutex_unlock(&stmpe_gpio->irq_lock); in stmpe_gpio_irq_sync_unlock()
232 int offset = d->hwirq; in stmpe_gpio_irq_mask()
234 int mask = BIT(offset % 8); in stmpe_gpio_irq_mask() local
236 stmpe_gpio->regs[REG_IE][regoffset] &= ~mask; in stmpe_gpio_irq_mask()
244 int offset = d->hwirq; in stmpe_gpio_irq_unmask()
246 int mask = BIT(offset % 8); in stmpe_gpio_irq_unmask() local
249 stmpe_gpio->regs[REG_IE][regoffset] |= mask; in stmpe_gpio_irq_unmask()
257 struct stmpe *stmpe = stmpe_gpio->stmpe; in stmpe_dbg_show_one()
260 u8 dir_reg = stmpe->regs[STMPE_IDX_GPDR_LSB + bank]; in stmpe_dbg_show_one()
261 u8 mask = BIT(offset % 8); in stmpe_dbg_show_one() local
272 dir = !!(ret & mask); in stmpe_dbg_show_one()
275 seq_printf(s, " gpio-%-3d (%-20.20s) out %s", in stmpe_dbg_show_one()
285 "edge-inactive", in stmpe_dbg_show_one()
286 "edge-asserted", in stmpe_dbg_show_one()
287 "not-supported" in stmpe_dbg_show_one()
290 "no-rising-edge-detection", in stmpe_dbg_show_one()
291 "rising-edge-detection", in stmpe_dbg_show_one()
292 "not-supported" in stmpe_dbg_show_one()
295 "no-falling-edge-detection", in stmpe_dbg_show_one()
296 "falling-edge-detection", in stmpe_dbg_show_one()
297 "not-supported" in stmpe_dbg_show_one()
305 switch (stmpe->partnum) { in stmpe_dbg_show_one()
311 edge_det_reg = stmpe->regs[STMPE_IDX_GPEDR_LSB + bank]; in stmpe_dbg_show_one()
315 edge_det = !!(ret & mask); in stmpe_dbg_show_one()
318 rise_reg = stmpe->regs[STMPE_IDX_GPRER_LSB + bank]; in stmpe_dbg_show_one()
319 fall_reg = stmpe->regs[STMPE_IDX_GPFER_LSB + bank]; in stmpe_dbg_show_one()
324 rise = !!(ret & mask); in stmpe_dbg_show_one()
328 fall = !!(ret & mask); in stmpe_dbg_show_one()
332 irqen_reg = stmpe->regs[STMPE_IDX_IEGPIOR_LSB + bank]; in stmpe_dbg_show_one()
342 irqen = !!(ret & mask); in stmpe_dbg_show_one()
344 seq_printf(s, " gpio-%-3d (%-20.20s) in %s %13s %13s %25s %25s", in stmpe_dbg_show_one()
348 irqen ? "IRQ-enabled" : "IRQ-disabled", in stmpe_dbg_show_one()
357 unsigned gpio = gc->base; in stmpe_dbg_show()
359 for (i = 0; i < gc->ngpio; i++, gpio++) { in stmpe_dbg_show()
366 .name = "stmpe-gpio",
381 struct stmpe *stmpe = stmpe_gpio->stmpe; in stmpe_gpio_irq()
383 int num_banks = DIV_ROUND_UP(stmpe->num_gpios, 8); in stmpe_gpio_irq()
396 if (stmpe->partnum == STMPE1600) in stmpe_gpio_irq()
397 statmsbreg = stmpe->regs[STMPE_IDX_ISGPIOR_LSB]; in stmpe_gpio_irq()
399 statmsbreg = stmpe->regs[STMPE_IDX_ISGPIOR_MSB]; in stmpe_gpio_irq()
406 int bank = (stmpe_gpio->stmpe->partnum == STMPE1600) ? i : in stmpe_gpio_irq()
407 num_banks - i - 1; in stmpe_gpio_irq()
408 unsigned int enabled = stmpe_gpio->regs[REG_IE][bank]; in stmpe_gpio_irq()
418 int child_irq = irq_find_mapping(stmpe_gpio->chip.irq.domain, in stmpe_gpio_irq()
430 if (stmpe->partnum != STMPE801 && stmpe->partnum != STMPE1600 && in stmpe_gpio_irq()
431 stmpe->partnum != STMPE1801) { in stmpe_gpio_irq()
434 stmpe->regs[STMPE_IDX_GPEDR_MSB] + i, in stmpe_gpio_irq()
449 if (!stmpe_gpio->norequest_mask) in stmpe_init_irq_valid_mask()
454 if (stmpe_gpio->norequest_mask & BIT(i)) in stmpe_init_irq_valid_mask()
466 struct device *dev = &pdev->dev; in stmpe_gpio_probe()
467 struct stmpe *stmpe = dev_get_drvdata(dev->parent); in stmpe_gpio_probe()
471 if (stmpe->num_gpios > MAX_GPIOS) { in stmpe_gpio_probe()
473 return -EINVAL; in stmpe_gpio_probe()
478 return -ENOMEM; in stmpe_gpio_probe()
480 mutex_init(&stmpe_gpio->irq_lock); in stmpe_gpio_probe()
482 stmpe_gpio->stmpe = stmpe; in stmpe_gpio_probe()
483 stmpe_gpio->chip = template_chip; in stmpe_gpio_probe()
484 stmpe_gpio->chip.ngpio = stmpe->num_gpios; in stmpe_gpio_probe()
485 stmpe_gpio->chip.parent = dev; in stmpe_gpio_probe()
486 stmpe_gpio->chip.base = -1; in stmpe_gpio_probe()
489 stmpe_gpio->chip.dbg_show = stmpe_dbg_show; in stmpe_gpio_probe()
491 device_property_read_u32(dev, "st,norequest-mask", &stmpe_gpio->norequest_mask); in stmpe_gpio_probe()
506 IRQF_ONESHOT, "stmpe-gpio", stmpe_gpio); in stmpe_gpio_probe()
510 girq = &stmpe_gpio->chip.irq; in stmpe_gpio_probe()
513 girq->parent_handler = NULL; in stmpe_gpio_probe()
514 girq->num_parents = 0; in stmpe_gpio_probe()
515 girq->parents = NULL; in stmpe_gpio_probe()
516 girq->default_type = IRQ_TYPE_NONE; in stmpe_gpio_probe()
517 girq->handler = handle_simple_irq; in stmpe_gpio_probe()
518 girq->threaded = true; in stmpe_gpio_probe()
519 girq->init_valid_mask = stmpe_init_irq_valid_mask; in stmpe_gpio_probe()
522 return devm_gpiochip_add_data(dev, &stmpe_gpio->chip, stmpe_gpio); in stmpe_gpio_probe()
528 .name = "stmpe-gpio",