Lines Matching defs:offset

59  * p2o: function ptr for pin to offset conversion. This is required only for
60 * machines where mapping b/w pin and offset is not 1-to-1.
61 * o2p: function ptr for offset to pin conversion. This is required only for
62 * machines where mapping b/w pin and offset is not 1-to-1.
73 int (*o2p)(int offset); /* offset_to_pin */
84 u32 offset = PIN_OFFSET(pin);
90 return !!(val & (1 << offset));
95 u32 offset = PIN_OFFSET(pin);
99 mask = 1 << offset;
105 u32 offset = PIN_OFFSET(pin);
109 mask = 1 << offset;
115 static int plgpio_direction_input(struct gpio_chip *chip, unsigned offset)
120 /* get correct offset for "offset" pin */
122 offset = plgpio->p2o(offset);
123 if (offset == -1)
128 plgpio_reg_set(plgpio->regmap, offset, plgpio->regs.dir);
134 static int plgpio_direction_output(struct gpio_chip *chip, unsigned offset,
139 unsigned dir_offset = offset, wdata_offset = offset, tmp;
141 /* get correct offset for "offset" pin */
143 tmp = plgpio->p2o(offset);
167 static int plgpio_get_value(struct gpio_chip *chip, unsigned offset)
171 if (offset >= chip->ngpio)
174 /* get correct offset for "offset" pin */
176 offset = plgpio->p2o(offset);
177 if (offset == -1)
181 return is_plgpio_set(plgpio->regmap, offset, plgpio->regs.rdata);
184 static void plgpio_set_value(struct gpio_chip *chip, unsigned offset, int value)
188 if (offset >= chip->ngpio)
191 /* get correct offset for "offset" pin */
193 offset = plgpio->p2o(offset);
194 if (offset == -1)
199 plgpio_reg_set(plgpio->regmap, offset, plgpio->regs.wdata);
201 plgpio_reg_reset(plgpio->regmap, offset, plgpio->regs.wdata);
204 static int plgpio_request(struct gpio_chip *chip, unsigned offset)
207 int gpio = chip->base + offset;
211 if (offset >= chip->ngpio)
230 ret = plgpio_direction_input(chip, offset);
234 /* get correct offset for "offset" pin */
236 offset = plgpio->p2o(offset);
237 if (offset == -1) {
244 plgpio_reg_set(plgpio->regmap, offset, plgpio->regs.enb);
256 static void plgpio_free(struct gpio_chip *chip, unsigned offset)
259 int gpio = chip->base + offset;
262 if (offset >= chip->ngpio)
268 /* get correct offset for "offset" pin */
270 offset = plgpio->p2o(offset);
271 if (offset == -1)
276 plgpio_reg_reset(plgpio->regmap, offset, plgpio->regs.enb);
291 int offset = d->hwirq;
294 /* get correct offset for "offset" pin */
296 offset = plgpio->p2o(offset);
297 if (offset == -1)
302 plgpio_reg_set(plgpio->regmap, offset, plgpio->regs.ie);
311 int offset = d->hwirq;
314 /* get correct offset for "offset" pin */
316 offset = plgpio->p2o(offset);
317 if (offset == -1)
323 plgpio_reg_reset(plgpio->regmap, offset, plgpio->regs.ie);
331 int offset = d->hwirq;
335 if (offset >= plgpio->chip.ngpio)
349 reg_off = REG_OFFSET(0, plgpio->regs.eit, offset);
352 offset = PIN_OFFSET(offset);
354 regmap_write(plgpio->regmap, reg_off, val | (1 << offset));
356 regmap_write(plgpio->regmap, reg_off, val & ~(1 << offset));
375 int regs_count, count, pin, offset, i = 0;
405 for_each_set_bit(offset, &pendingl, MAX_GPIO_PER_REG) {
406 /* get correct pin for "offset" */
408 pin = plgpio->o2p(offset);
412 pin = offset;
423 * pin to offset and offset to pin converter functions
426 * for different plgpio pins. For example: for pin 27, bit offset is 23, pin
427 * 28-33 are not supported, pin 95 has offset bit 95, bit 100 has offset bit 1
431 int offset = pin;
434 offset += 4;
436 offset = -1;
438 offset -= 2;
440 offset = 101 - pin;
442 offset = -1;
444 return offset;
447 static int spear310_o2p(int offset)
449 if (offset <= 3)
450 return 101 - offset;
451 else if (offset <= 31)
452 return offset - 4;
454 return offset + 2;