Lines Matching +full:int +full:- +full:map +full:- +full:mask
1 // SPDX-License-Identifier: GPL-2.0
3 * GPIO library for the ACCES IDIO-16 family
15 #include "gpio-idio-16.h"
33 struct regmap *map; member
34 unsigned int irq_mask;
37 static int idio_16_handle_mask_sync(const int index, const unsigned int mask_buf_def, in idio_16_handle_mask_sync()
38 const unsigned int mask_buf, void *const irq_drv_data) in idio_16_handle_mask_sync()
41 const unsigned int prev_mask = data->irq_mask; in idio_16_handle_mask_sync()
42 int err; in idio_16_handle_mask_sync()
43 unsigned int val; in idio_16_handle_mask_sync()
45 /* exit early if no change since the previous mask */ in idio_16_handle_mask_sync()
49 /* remember the current mask for the next mask sync */ in idio_16_handle_mask_sync()
50 data->irq_mask = mask_buf; in idio_16_handle_mask_sync()
54 err = regmap_write(data->map, IDIO_16_CLEAR_INTERRUPT, 0x00); in idio_16_handle_mask_sync()
57 return regmap_read(data->map, IDIO_16_ENABLE_IRQ, &val); in idio_16_handle_mask_sync()
62 return regmap_write(data->map, IDIO_16_DISABLE_IRQ, 0x00); in idio_16_handle_mask_sync()
67 static int idio_16_reg_mask_xlate(struct gpio_regmap *const gpio, const unsigned int base, in idio_16_reg_mask_xlate()
68 const unsigned int offset, unsigned int *const reg, in idio_16_reg_mask_xlate()
69 unsigned int *const mask) in idio_16_reg_mask_xlate() argument
71 unsigned int stride; in idio_16_reg_mask_xlate()
78 stride = (offset - 16) / IDIO_16_NGPIO_PER_REG; in idio_16_reg_mask_xlate()
82 *mask = BIT(offset % IDIO_16_NGPIO_PER_REG); in idio_16_reg_mask_xlate()
95 * devm_idio_16_regmap_register - Register an IDIO-16 GPIO device
96 * @dev: device that is registering this IDIO-16 GPIO device
99 * Registers an IDIO-16 GPIO device. Returns 0 on success and negative error number on failure.
101 int devm_idio_16_regmap_register(struct device *const dev, in devm_idio_16_regmap_register()
105 int err; in devm_idio_16_regmap_register()
110 if (!config->parent) in devm_idio_16_regmap_register()
111 return -EINVAL; in devm_idio_16_regmap_register()
113 if (!config->map) in devm_idio_16_regmap_register()
114 return -EINVAL; in devm_idio_16_regmap_register()
116 if (!config->regmap_irqs) in devm_idio_16_regmap_register()
117 return -EINVAL; in devm_idio_16_regmap_register()
121 return -ENOMEM; in devm_idio_16_regmap_register()
122 data->map = config->map; in devm_idio_16_regmap_register()
126 return -ENOMEM; in devm_idio_16_regmap_register()
128 chip->name = dev_name(dev); in devm_idio_16_regmap_register()
129 chip->status_base = IDIO_16_INTERRUPT_STATUS; in devm_idio_16_regmap_register()
130 chip->mask_base = IDIO_16_ENABLE_IRQ; in devm_idio_16_regmap_register()
131 chip->ack_base = IDIO_16_CLEAR_INTERRUPT; in devm_idio_16_regmap_register()
132 chip->no_status = config->no_status; in devm_idio_16_regmap_register()
133 chip->num_regs = 1; in devm_idio_16_regmap_register()
134 chip->irqs = config->regmap_irqs; in devm_idio_16_regmap_register()
135 chip->num_irqs = config->num_regmap_irqs; in devm_idio_16_regmap_register()
136 chip->handle_mask_sync = idio_16_handle_mask_sync; in devm_idio_16_regmap_register()
137 chip->irq_drv_data = data; in devm_idio_16_regmap_register()
140 err = regmap_write(data->map, IDIO_16_DISABLE_IRQ, 0x00); in devm_idio_16_regmap_register()
144 err = devm_regmap_add_irq_chip(dev, data->map, config->irq, 0, 0, chip, &chip_data); in devm_idio_16_regmap_register()
148 if (config->filters) { in devm_idio_16_regmap_register()
150 err = regmap_write(data->map, IDIO_16_DEACTIVATE_INPUT_FILTERS, 0x00); in devm_idio_16_regmap_register()
155 gpio_config.parent = config->parent; in devm_idio_16_regmap_register()
156 gpio_config.regmap = data->map; in devm_idio_16_regmap_register()
171 MODULE_DESCRIPTION("ACCES IDIO-16 GPIO Library");