Lines Matching +full:foo +full:- +full:gpios
2 * Copyright (c) 2019-2020 Nordic Semiconductor ASA
5 * Copyright (c) 2015-2016 Intel Corporation.
7 * SPDX-License-Identifier: Apache-2.0
27 #include <zephyr/dt-bindings/gpio/gpio.h>
252 * This reduced-size type is sufficient to record a pin number,
253 * e.g. from a devicetree GPIOS property.
261 * bits of the full flags field, so use a reduced-size type to record
262 * that part of a GPIOS property.
307 * foo-gpios = <&gpio0 1 GPIO_ACTIVE_LOW>,
328 * @param prop lowercase-and-underscores property name
350 * @param prop lowercase-and-underscores property name
365 * @param prop lowercase-and-underscores property name
377 * @param prop lowercase-and-underscores property name
390 * @param prop lowercase-and-underscores property name
403 * @param prop lowercase-and-underscores property name
418 * @param prop lowercase-and-underscores property name
430 * @param prop lowercase-and-underscores property name
448 * @param prop lowercase-and-underscores array property name
457 DT_PROP_BY_IDX(node_id, prop, sz_idx) - 1, \
463 * from @p "gpio-reserved-ranges"
481 * @brief Makes a bitmask of reserved GPIOs from DT @p "gpio-reserved-ranges"
484 * This macro returns the value as a bitmask of the @p "gpio-reserved-ranges"
485 * property. This property defines the disabled (or 'reserved') GPIOs in the
486 * range @p 0...ngpios-1 and is specified as an array of value's pairs that
489 * For example, setting "gpio-reserved-ranges = <3 2>, <10 1>;"
507 * compatible = "some,gpio-controller";
509 * gpio-reserved-ranges = <0 4>, <5 3>, <9 5>, <11 2>, <15 2>,
514 * compatible = "some,gpio-controller";
516 * gpio-reserved-ranges = <3 2>, <10 1>;
564 * @param ngpios number of GPIOs.
565 * @return the bitmask of reserved gpios
570 (GENMASK64(BITS_PER_LONG_LONG - 1, ngpios) \
578 * @brief Makes a bitmask of reserved GPIOs from the @p "gpio-reserved-ranges"
582 * @return the bitmask of reserved gpios
588 * @brief Makes a bitmask of reserved GPIOs from a DT_DRV_COMPAT instance's
589 * @p "gpio-reserved-ranges" property and @p "ngpios" argument
592 * @return the bitmask of reserved gpios
593 * @param ngpios number of GPIOs
600 * @brief Make a bitmask of reserved GPIOs from a DT_DRV_COMPAT instance's GPIO
601 * @p "gpio-reserved-ranges" and @p "ngpios" properties
604 * @return the bitmask of reserved gpios
611 * @brief Makes a bitmask of allowed GPIOs from DT @p "gpio-reserved-ranges"
615 * the latter, it returns a bitmask of ALLOWED gpios.
621 * compatible = "some,gpio-controller";
623 * gpio-reserved-ranges = <0 8>, <9 5>, <15 16>;
655 * @param ngpios number of GPIOs
656 * @return the bitmask of allowed gpios
663 ((GENMASK64(ngpios - 1, 0) & \
665 (GENMASK64(ngpios - 1, 0))) \
670 * @brief Makes a bitmask of allowed GPIOs from a DT_DRV_COMPAT instance's
671 * @p "gpio-reserved-ranges" property and @p "ngpios" argument
674 * @param ngpios number of GPIOs
675 * @return the bitmask of allowed gpios
840 return device_is_ready(spec->port); in gpio_is_ready_dt()
857 * @retval -ENOSYS If the operation is not implemented by the driver.
858 * @retval -ENOTSUP If any of the configuration options is not supported
860 * @retval -EINVAL Invalid argument.
861 * @retval -EBUSY Interrupt line required to configure pin interrupt is
863 * @retval -EIO I/O error when accessing an external GPIO chip.
864 * @retval -EWOULDBLOCK if operation would block.
875 (const struct gpio_driver_api *)port->api; in z_impl_gpio_pin_interrupt_configure()
877 (const struct gpio_driver_config *)port->config; in z_impl_gpio_pin_interrupt_configure()
879 (const struct gpio_driver_data *)port->data; in z_impl_gpio_pin_interrupt_configure()
886 if (api->pin_interrupt_configure == NULL) { in z_impl_gpio_pin_interrupt_configure()
887 SYS_PORT_TRACING_FUNC_EXIT(gpio_pin, interrupt_configure, port, pin, -ENOSYS); in z_impl_gpio_pin_interrupt_configure()
888 return -ENOSYS; in z_impl_gpio_pin_interrupt_configure()
915 __ASSERT((cfg->port_pin_mask & (gpio_port_pins_t)BIT(pin)) != 0U, in z_impl_gpio_pin_interrupt_configure()
919 ((data->invert & (gpio_port_pins_t)BIT(pin)) != 0)) { in z_impl_gpio_pin_interrupt_configure()
932 ret = api->pin_interrupt_configure(port, pin, mode, trig); in z_impl_gpio_pin_interrupt_configure()
944 * gpio_pin_interrupt_configure(spec->port, spec->pin, flags);
946 * The <tt>spec->dt_flags</tt> value is not used.
955 return gpio_pin_interrupt_configure(spec->port, spec->pin, flags); in gpio_pin_interrupt_configure_dt()
967 * @retval -ENOTSUP if any of the configuration options is not supported
969 * @retval -EINVAL Invalid argument.
970 * @retval -EIO I/O error when accessing an external GPIO chip.
971 * @retval -EWOULDBLOCK if operation would block.
982 (const struct gpio_driver_api *)port->api; in z_impl_gpio_pin_configure()
984 (const struct gpio_driver_config *)port->config; in z_impl_gpio_pin_configure()
986 (struct gpio_driver_data *)port->data; in z_impl_gpio_pin_configure()
1020 __ASSERT((cfg->port_pin_mask & (gpio_port_pins_t)BIT(pin)) != 0U, in z_impl_gpio_pin_configure()
1024 data->invert |= (gpio_port_pins_t)BIT(pin); in z_impl_gpio_pin_configure()
1026 data->invert &= ~(gpio_port_pins_t)BIT(pin); in z_impl_gpio_pin_configure()
1029 ret = api->pin_configure(port, pin, flags); in z_impl_gpio_pin_configure()
1039 * gpio_pin_configure(spec->port, spec->pin, spec->dt_flags | extra_flags);
1048 return gpio_pin_configure(spec->port, in gpio_pin_configure_dt()
1049 spec->pin, in gpio_pin_configure_dt()
1050 spec->dt_flags | extra_flags); in gpio_pin_configure_dt()
1067 * @retval -ENOSYS if the underlying driver does not support this call.
1068 * @retval -EIO I/O error when accessing an external GPIO chip.
1069 * @retval -EWOULDBLOCK if operation would block.
1079 const struct gpio_driver_api *api = (const struct gpio_driver_api *)port->api; in z_impl_gpio_port_get_direction()
1084 if (api->port_get_direction == NULL) { in z_impl_gpio_port_get_direction()
1085 SYS_PORT_TRACING_FUNC_EXIT(gpio_port, get_direction, port, -ENOSYS); in z_impl_gpio_port_get_direction()
1086 return -ENOSYS; in z_impl_gpio_port_get_direction()
1089 ret = api->port_get_direction(port, map, inputs, outputs); in z_impl_gpio_port_get_direction()
1103 * @retval -ENOSYS if the underlying driver does not support this call.
1104 * @retval -EIO I/O error when accessing an external GPIO chip.
1105 * @retval -EWOULDBLOCK if operation would block.
1112 (const struct gpio_driver_config *)port->config; in gpio_pin_is_input()
1114 __ASSERT((cfg->port_pin_mask & (gpio_port_pins_t)BIT(pin)) != 0U, "Unsupported pin"); in gpio_pin_is_input()
1129 * gpio_pin_is_input(spec->port, spec->pin);
1137 return gpio_pin_is_input(spec->port, spec->pin); in gpio_pin_is_input_dt()
1148 * @retval -ENOSYS if the underlying driver does not support this call.
1149 * @retval -EIO I/O error when accessing an external GPIO chip.
1150 * @retval -EWOULDBLOCK if operation would block.
1157 (const struct gpio_driver_config *)port->config; in gpio_pin_is_output()
1159 __ASSERT((cfg->port_pin_mask & (gpio_port_pins_t)BIT(pin)) != 0U, "Unsupported pin"); in gpio_pin_is_output()
1174 * gpio_pin_is_output(spec->port, spec->pin);
1182 return gpio_pin_is_output(spec->port, spec->pin); in gpio_pin_is_output_dt()
1194 * @retval -ENOSYS if getting current pin configuration is not implemented
1196 * @retval -EINVAL Invalid argument.
1197 * @retval -EIO I/O error when accessing an external GPIO chip.
1198 * @retval -EWOULDBLOCK if operation would block.
1209 (const struct gpio_driver_api *)port->api; in z_impl_gpio_pin_get_config()
1214 if (api->pin_get_config == NULL) { in z_impl_gpio_pin_get_config()
1215 SYS_PORT_TRACING_FUNC_EXIT(gpio_pin, get_config, port, pin, -ENOSYS); in z_impl_gpio_pin_get_config()
1216 return -ENOSYS; in z_impl_gpio_pin_get_config()
1219 ret = api->pin_get_config(port, pin, flags); in z_impl_gpio_pin_get_config()
1230 * gpio_pin_get_config(spec->port, spec->pin, flags);
1240 return gpio_pin_get_config(spec->port, spec->pin, flags); in gpio_pin_get_config_dt()
1257 * @retval -EIO I/O error when accessing an external GPIO chip.
1258 * @retval -EWOULDBLOCK if operation would block.
1265 const struct gpio_driver_api *api = (const struct gpio_driver_api *)port->api; in z_impl_gpio_port_get_raw()
1270 ret = api->port_get_raw(port, value); in z_impl_gpio_port_get_raw()
1290 * @retval -EIO I/O error when accessing an external GPIO chip.
1291 * @retval -EWOULDBLOCK if operation would block.
1297 (const struct gpio_driver_data *)port->data; in gpio_port_get()
1302 *value ^= data->invert; in gpio_port_get()
1322 * @retval -EIO I/O error when accessing an external GPIO chip.
1323 * @retval -EWOULDBLOCK if operation would block.
1334 (const struct gpio_driver_api *)port->api; in z_impl_gpio_port_set_masked_raw()
1339 ret = api->port_set_masked_raw(port, mask, value); in z_impl_gpio_port_set_masked_raw()
1361 * @retval -EIO I/O error when accessing an external GPIO chip.
1362 * @retval -EWOULDBLOCK if operation would block.
1369 (const struct gpio_driver_data *)port->data; in gpio_port_set_masked()
1371 value ^= data->invert; in gpio_port_set_masked()
1383 * @retval -EIO I/O error when accessing an external GPIO chip.
1384 * @retval -EWOULDBLOCK if operation would block.
1393 (const struct gpio_driver_api *)port->api; in z_impl_gpio_port_set_bits_raw()
1398 ret = api->port_set_bits_raw(port, pins); in z_impl_gpio_port_set_bits_raw()
1410 * @retval -EIO I/O error when accessing an external GPIO chip.
1411 * @retval -EWOULDBLOCK if operation would block.
1426 * @retval -EIO I/O error when accessing an external GPIO chip.
1427 * @retval -EWOULDBLOCK if operation would block.
1436 (const struct gpio_driver_api *)port->api; in z_impl_gpio_port_clear_bits_raw()
1441 ret = api->port_clear_bits_raw(port, pins); in z_impl_gpio_port_clear_bits_raw()
1453 * @retval -EIO I/O error when accessing an external GPIO chip.
1454 * @retval -EWOULDBLOCK if operation would block.
1469 * @retval -EIO I/O error when accessing an external GPIO chip.
1470 * @retval -EWOULDBLOCK if operation would block.
1479 (const struct gpio_driver_api *)port->api; in z_impl_gpio_port_toggle_bits()
1484 ret = api->port_toggle_bits(port, pins); in z_impl_gpio_port_toggle_bits()
1497 * @retval -EIO I/O error when accessing an external GPIO chip.
1498 * @retval -EWOULDBLOCK if operation would block.
1517 * @retval -EIO I/O error when accessing an external GPIO chip.
1518 * @retval -EWOULDBLOCK if operation would block.
1541 * @retval -EIO I/O error when accessing an external GPIO chip.
1542 * @retval -EWOULDBLOCK if operation would block.
1547 (const struct gpio_driver_config *)port->config; in gpio_pin_get_raw()
1551 __ASSERT((cfg->port_pin_mask & (gpio_port_pins_t)BIT(pin)) != 0U, in gpio_pin_get_raw()
1578 * @retval -EIO I/O error when accessing an external GPIO chip.
1579 * @retval -EWOULDBLOCK if operation would block.
1584 (const struct gpio_driver_config *)port->config; in gpio_pin_get()
1588 __ASSERT((cfg->port_pin_mask & (gpio_port_pins_t)BIT(pin)) != 0U, in gpio_pin_get()
1604 * gpio_pin_get(spec->port, spec->pin);
1611 return gpio_pin_get(spec->port, spec->pin); in gpio_pin_get_dt()
1626 * @retval -EIO I/O error when accessing an external GPIO chip.
1627 * @retval -EWOULDBLOCK if operation would block.
1633 (const struct gpio_driver_config *)port->config; in gpio_pin_set_raw()
1636 __ASSERT((cfg->port_pin_mask & (gpio_port_pins_t)BIT(pin)) != 0U, in gpio_pin_set_raw()
1666 * @retval -EIO I/O error when accessing an external GPIO chip.
1667 * @retval -EWOULDBLOCK if operation would block.
1673 (const struct gpio_driver_config *)port->config; in gpio_pin_set()
1675 (const struct gpio_driver_data *)port->data; in gpio_pin_set()
1677 __ASSERT((cfg->port_pin_mask & (gpio_port_pins_t)BIT(pin)) != 0U, in gpio_pin_set()
1680 if (data->invert & (gpio_port_pins_t)BIT(pin)) { in gpio_pin_set()
1692 * gpio_pin_set(spec->port, spec->pin, value);
1700 return gpio_pin_set(spec->port, spec->pin, value); in gpio_pin_set_dt()
1710 * @retval -EIO I/O error when accessing an external GPIO chip.
1711 * @retval -EWOULDBLOCK if operation would block.
1716 (const struct gpio_driver_config *)port->config; in gpio_pin_toggle()
1718 __ASSERT((cfg->port_pin_mask & (gpio_port_pins_t)BIT(pin)) != 0U, in gpio_pin_toggle()
1729 * gpio_pin_toggle(spec->port, spec->pin);
1736 return gpio_pin_toggle(spec->port, spec->pin); in gpio_pin_toggle_dt()
1754 callback->handler = handler; in gpio_init_callback()
1755 callback->pin_mask = pin_mask; in gpio_init_callback()
1765 * @retval -ENOSYS If driver does not implement the operation
1766 * @retval -errno Other negative errno code on failure.
1778 (const struct gpio_driver_api *)port->api; in gpio_add_callback()
1783 if (api->manage_callback == NULL) { in gpio_add_callback()
1784 SYS_PORT_TRACING_FUNC_EXIT(gpio, add_callback, port, -ENOSYS); in gpio_add_callback()
1785 return -ENOSYS; in gpio_add_callback()
1788 ret = api->manage_callback(port, callback, true); in gpio_add_callback()
1798 * gpio_add_callback(spec->port, callback);
1807 return gpio_add_callback(spec->port, callback); in gpio_add_callback_dt()
1815 * @retval -ENOSYS If driver does not implement the operation
1816 * @retval -errno Other negative errno code on failure.
1832 (const struct gpio_driver_api *)port->api; in gpio_remove_callback()
1837 if (api->manage_callback == NULL) { in gpio_remove_callback()
1838 SYS_PORT_TRACING_FUNC_EXIT(gpio, remove_callback, port, -ENOSYS); in gpio_remove_callback()
1839 return -ENOSYS; in gpio_remove_callback()
1842 ret = api->manage_callback(port, callback, false); in gpio_remove_callback()
1852 * gpio_remove_callback(spec->port, callback);
1861 return gpio_remove_callback(spec->port, callback); in gpio_remove_callback_dt()
1876 * @retval -ENOSYS If driver does not implement the operation
1883 (const struct gpio_driver_api *)dev->api; in z_impl_gpio_get_pending_int()
1888 if (api->get_pending_int == NULL) { in z_impl_gpio_get_pending_int()
1889 SYS_PORT_TRACING_FUNC_EXIT(gpio, get_pending_int, dev, -ENOSYS); in z_impl_gpio_get_pending_int()
1890 return -ENOSYS; in z_impl_gpio_get_pending_int()
1893 ret = api->get_pending_int(dev); in z_impl_gpio_get_pending_int()