Lines Matching +full:pin +full:- +full:offset

4  * SPDX-License-Identifier: Apache-2.0
13 #include <zephyr/dt-bindings/gpio/snps-designware-gpio.h>
38 static inline uint32_t dw_read(uint32_t base_addr, uint32_t offset) in dw_read() argument
40 return sys_in32(base_addr + offset); in dw_read()
43 static inline void dw_write(uint32_t base_addr, uint32_t offset, in dw_write() argument
46 sys_out32(val, base_addr + offset); in dw_write()
49 static void dw_set_bit(uint32_t base_addr, uint32_t offset, in dw_set_bit() argument
53 sys_io_clear_bit(base_addr + offset, bit); in dw_set_bit()
55 sys_io_set_bit(base_addr + offset, bit); in dw_set_bit()
59 static inline uint32_t dw_read(uint32_t base_addr, uint32_t offset) in dw_read() argument
61 return sys_read32(base_addr + offset); in dw_read()
64 static inline void dw_write(uint32_t base_addr, uint32_t offset, in dw_write() argument
67 sys_write32(val, base_addr + offset); in dw_write()
70 static void dw_set_bit(uint32_t base_addr, uint32_t offset, in dw_set_bit() argument
74 sys_clear_bit(base_addr + offset, bit); in dw_set_bit()
76 sys_set_bit(base_addr + offset, bit); in dw_set_bit()
94 return ((int)(config->irq_num) > 0U); in dw_interrupt_support()
101 /* 4-port GPIO implementation translates from base address to port */ in dw_get_ext_port()
125 /* 4-port GPIO implementation translates from base address to port */ in dw_get_data_port()
149 /* 4-port GPIO implementation translates from base address to port */ in dw_get_dir_port()
170 gpio_pin_t pin, in gpio_dw_pin_interrupt_configure() argument
174 struct gpio_dw_runtime *context = port->data; in gpio_dw_pin_interrupt_configure()
175 const struct gpio_dw_config *config = port->config; in gpio_dw_pin_interrupt_configure()
176 uint32_t base_addr = dw_base_to_block_base(context->base_addr); in gpio_dw_pin_interrupt_configure()
177 uint32_t port_base_addr = context->base_addr; in gpio_dw_pin_interrupt_configure()
182 /* Check for invalid pin number */ in gpio_dw_pin_interrupt_configure()
183 if (pin >= config->ngpios) { in gpio_dw_pin_interrupt_configure()
184 return -EINVAL; in gpio_dw_pin_interrupt_configure()
187 /* Only PORT-A supports interrupts */ in gpio_dw_pin_interrupt_configure()
189 return -ENOTSUP; in gpio_dw_pin_interrupt_configure()
195 return -ENOTSUP; in gpio_dw_pin_interrupt_configure()
198 /* Interrupt to be enabled but pin is not set to input */ in gpio_dw_pin_interrupt_configure()
199 dir_reg = dw_read(base_addr, dir_port) & BIT(pin); in gpio_dw_pin_interrupt_configure()
201 return -EINVAL; in gpio_dw_pin_interrupt_configure()
208 return -ENOTSUP; in gpio_dw_pin_interrupt_configure()
212 dw_set_bit(base_addr, INTEN, pin, false); in gpio_dw_pin_interrupt_configure()
215 dw_set_bit(base_addr, INTMASK, pin, true); in gpio_dw_pin_interrupt_configure()
216 dw_write(base_addr, PORTA_EOI, BIT(pin)); in gpio_dw_pin_interrupt_configure()
220 dw_set_bit(base_addr, INTTYPE_LEVEL, pin, in gpio_dw_pin_interrupt_configure()
224 dw_set_bit(base_addr, INT_POLARITY, pin, in gpio_dw_pin_interrupt_configure()
228 dw_set_bit(base_addr, INTEN, pin, true); in gpio_dw_pin_interrupt_configure()
229 dw_set_bit(base_addr, INTMASK, pin, false); in gpio_dw_pin_interrupt_configure()
236 uint32_t pin, int flags) in dw_pin_config() argument
238 struct gpio_dw_runtime *context = port->data; in dw_pin_config()
239 const struct gpio_dw_config *config = port->config; in dw_pin_config()
240 uint32_t base_addr = dw_base_to_block_base(context->base_addr); in dw_pin_config()
241 uint32_t port_base_addr = context->base_addr; in dw_pin_config()
248 dw_set_bit(base_addr, dir_port, pin, pin_is_output); in dw_pin_config()
252 gpio_dw_port_set_bits_raw(port, BIT(pin)); in dw_pin_config()
254 gpio_dw_port_clear_bits_raw(port, BIT(pin)); in dw_pin_config()
258 /* Use built-in debounce. in dw_pin_config()
264 dw_set_bit(base_addr, PORTA_DEBOUNCE, pin, need_debounce); in dw_pin_config()
269 gpio_pin_t pin, in gpio_dw_config() argument
272 const struct gpio_dw_config *config = port->config; in gpio_dw_config()
275 /* Check for invalid pin number */ in gpio_dw_config()
276 if (pin >= config->ngpios) { in gpio_dw_config()
277 return -EINVAL; in gpio_dw_config()
280 /* Does not support disconnected pin, and in gpio_dw_config()
286 return -ENOTSUP; in gpio_dw_config()
289 /* No open-drain support */ in gpio_dw_config()
291 return -ENOTSUP; in gpio_dw_config()
294 /* Does not support pull-up/pull-down */ in gpio_dw_config()
296 return -ENOTSUP; in gpio_dw_config()
299 dw_pin_config(port, pin, flags); in gpio_dw_config()
306 struct gpio_dw_runtime *context = port->data; in gpio_dw_port_get_raw()
307 uint32_t base_addr = dw_base_to_block_base(context->base_addr); in gpio_dw_port_get_raw()
308 uint32_t port_base_addr = context->base_addr; in gpio_dw_port_get_raw()
319 struct gpio_dw_runtime *context = port->data; in gpio_dw_port_set_masked_raw()
320 uint32_t base_addr = dw_base_to_block_base(context->base_addr); in gpio_dw_port_set_masked_raw()
321 uint32_t port_base_addr = context->base_addr; in gpio_dw_port_set_masked_raw()
334 struct gpio_dw_runtime *context = port->data; in gpio_dw_port_set_bits_raw()
335 uint32_t base_addr = dw_base_to_block_base(context->base_addr); in gpio_dw_port_set_bits_raw()
336 uint32_t port_base_addr = context->base_addr; in gpio_dw_port_set_bits_raw()
350 struct gpio_dw_runtime *context = port->data; in gpio_dw_port_clear_bits_raw()
351 uint32_t base_addr = dw_base_to_block_base(context->base_addr); in gpio_dw_port_clear_bits_raw()
352 uint32_t port_base_addr = context->base_addr; in gpio_dw_port_clear_bits_raw()
365 struct gpio_dw_runtime *context = port->data; in gpio_dw_port_toggle_bits()
366 uint32_t base_addr = dw_base_to_block_base(context->base_addr); in gpio_dw_port_toggle_bits()
367 uint32_t port_base_addr = context->base_addr; in gpio_dw_port_toggle_bits()
382 struct gpio_dw_runtime *context = port->data; in gpio_dw_manage_callback()
384 return gpio_manage_callback(&context->callbacks, callback, set); in gpio_dw_manage_callback()
390 struct gpio_dw_runtime *context = port->data; in gpio_dw_isr()
391 uint32_t base_addr = dw_base_to_block_base(context->base_addr); in gpio_dw_isr()
398 gpio_fire_callbacks(&context->callbacks, port, int_status); in gpio_dw_isr()
415 struct gpio_dw_runtime *context = port->data; in gpio_dw_initialize()
416 const struct gpio_dw_config *config = port->config; in gpio_dw_initialize()
421 base_addr = dw_base_to_block_base(context->base_addr); in gpio_dw_initialize()
431 config->config_func(port); in gpio_dw_initialize()