Bridle API 4.1.99
A Zephyr based application framework
|
MFD Driver for an SC16IS75X bridge. More...
#include <zephyr/kernel.h>
#include <zephyr/devicetree.h>
#include <zephyr/drivers/gpio/gpio_utils.h>
#include <zephyr/drivers/mfd/sc16is75x.h>
#include "mfd_sc16is75x.h"
#include "zephyr/sys/util_macro.h"
#include <zephyr/logging/log.h>
Macros | |
#define | SC16IS75X_SA_RD true |
#define | SC16IS75X_SA_WR false |
#define | READ_SC16IS75X_CHANNEL(dev, ch, reg, buf, len) mfd_sc16is75x_read((dev), (ch), SC16IS75X_REG_##reg, (buf), (len)); |
#define | WRITE_SC16IS75X_CHANNEL(dev, ch, reg, buf, len) mfd_sc16is75x_write((dev), (ch), SC16IS75X_REG_##reg, (buf), (len)); |
#define | MFD_SC16IS75X_CHILD_CHANNEL(child) |
For a given child node, if it's a UART controller: return the channel id (reg property), with a comma. | |
#define | MFD_SC16IS75X_UART_CHANNELS(inst) {DT_INST_FOREACH_CHILD_STATUS_OKAY(inst, MFD_SC16IS75X_CHILD_CHANNEL)} |
Construct a bracketed list of all child UART controllers' channel id (== reg property) | |
#define | MFD_SC16IS75X_DEFINE_SPI_BUS(inst) |
Construct struct initializer entries for an SPI bus configuration. | |
#define | MFD_SC16IS75X_DEFINE_I2C_BUS(inst) .i2c = I2C_DT_SPEC_INST_GET(inst), .bus_init = mfd_sc16is75x_i2c_init |
Construct struct initializer entries for an I2C bus configuration. | |
#define | MFD_SC16IS75X_DEFINE_BUS(inst) |
Return one of the two bus initializer lists above, selecting the correct bus based on the devicetree. | |
#define | MFD_SC16IS75X_DEFINE(inst) |
Initializer macro for a device driver instance. | |
Functions | |
LOG_MODULE_REGISTER (mfd_sc16is75x, CONFIG_MFD_LOG_LEVEL) | |
static int | mfd_sc16is75x_sub_address (const bool read, const uint8_t reg, const uint8_t channel, uint8_t *sub_address) |
static int | mfd_sc16is75x_read (const struct device *dev, const uint8_t channel, const uint8_t reg, uint8_t *buf, const size_t len) |
static int | mfd_sc16is75x_write (const struct device *dev, const uint8_t channel, const uint8_t reg, const uint8_t *buf, const size_t len) |
int | mfd_sc16is75x_read_register (const struct device *dev, const uint8_t channel, const uint8_t reg, uint8_t *value) |
Read from an internal register. | |
int | mfd_sc16is75x_write_register (const struct device *dev, const uint8_t channel, const uint8_t reg, const uint8_t value) |
Write to an internal register. | |
int | mfd_sc16is75x_set_register_bit (const struct device *dev, const uint8_t channel, const uint8_t reg, const uint8_t bit, const bool value) |
Enable or disable a bit in an internal register. | |
int | mfd_sc16is75x_read_fifo (const struct device *dev, const uint8_t channel, uint8_t *buf, const size_t len) |
Read data from FIFO. | |
int | mfd_sc16is75x_write_fifo (const struct device *dev, const uint8_t channel, const uint8_t *buf, const size_t len) |
Write data to FIFO. | |
static int | mfd_sc16is75x_chip_reset (const struct device *dev) |
Reset device. | |
static int | mfd_sc16is75x_configure_gpio_pin (const struct device *dev, const struct gpio_dt_spec *gpio, const gpio_flags_t flags) |
Set up GPIO pin. | |
static int | mfd_sc16is75x_sw_reset (const struct device *dev) |
static int | mfd_sc16is75x_pm_device_pm_action (const struct device *dev, enum pm_device_action action) |
static int | mfd_sc16is75x_init (const struct device *dev) |
DT_INST_FOREACH_STATUS_OKAY (MFD_SC16IS75X_DEFINE) | |
MFD Driver for an SC16IS75X bridge.
#define MFD_SC16IS75X_CHILD_CHANNEL | ( | child | ) |
For a given child node, if it's a UART controller: return the channel id (reg
property), with a comma.
If the child is not a UART controller, return nothing.
Note that since the property is technically an array, we take the 0th entry to avoid extra braces.
#define MFD_SC16IS75X_DEFINE | ( | inst | ) |
Initializer macro for a device driver instance.
In order to count the number of channels, we create an instance of the channels list. Unfortunately, GCC doesn't like us using this same instance for initialization, so we have to invoke the list construction macro again to get a naked initializer list later.
#define MFD_SC16IS75X_DEFINE_BUS | ( | inst | ) |
Return one of the two bus initializer lists above, selecting the correct bus based on the devicetree.
#define MFD_SC16IS75X_DEFINE_I2C_BUS | ( | inst | ) | .i2c = I2C_DT_SPEC_INST_GET(inst), .bus_init = mfd_sc16is75x_i2c_init |
Construct struct initializer entries for an I2C bus configuration.
#define MFD_SC16IS75X_DEFINE_SPI_BUS | ( | inst | ) |
Construct struct initializer entries for an SPI bus configuration.
#define MFD_SC16IS75X_UART_CHANNELS | ( | inst | ) | {DT_INST_FOREACH_CHILD_STATUS_OKAY(inst, MFD_SC16IS75X_CHILD_CHANNEL)} |
Construct a bracketed list of all child UART controllers' channel id (== reg
property)
#define READ_SC16IS75X_CHANNEL | ( | dev, | |
ch, | |||
reg, | |||
buf, | |||
len | |||
) | mfd_sc16is75x_read((dev), (ch), SC16IS75X_REG_##reg, (buf), (len)); |
#define SC16IS75X_SA_RD true |
#define SC16IS75X_SA_WR false |
#define WRITE_SC16IS75X_CHANNEL | ( | dev, | |
ch, | |||
reg, | |||
buf, | |||
len | |||
) | mfd_sc16is75x_write((dev), (ch), SC16IS75X_REG_##reg, (buf), (len)); |
DT_INST_FOREACH_STATUS_OKAY | ( | MFD_SC16IS75X_DEFINE | ) |
LOG_MODULE_REGISTER | ( | mfd_sc16is75x | , |
CONFIG_MFD_LOG_LEVEL | |||
) |
|
static |
Reset device.
dev | An SC16IS75X MFD device. |
0 | On success. |
|
static |
Set up GPIO pin.
dev | An SC16IS75X MFD device. |
gpio | The GPIO specification from devicetree. |
flags | Additional GPIO flags. |
0 | On success. |
|
static |
|
static |
|
static |
|
inlinestatic |
|
static |
|
static |