Bridle API 4.1.99
A Zephyr based application framework
Loading...
Searching...
No Matches
mfd_sc16is75x.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2024 TiaC Systems
3 * SPDX-License-Identifier: Apache-2.0
4 */
5
11#ifndef ZEPHYR_DRIVERS_MFD_SC16IS75X_H_
12#define ZEPHYR_DRIVERS_MFD_SC16IS75X_H_
13
14#ifdef __cplusplus
15extern "C" {
16#endif
17
18#define DT_DRV_COMPAT nxp_sc16is75x
19
20#include <zephyr/kernel.h>
21#include <zephyr/device.h>
22#include <zephyr/pm/device.h>
23#include <zephyr/drivers/gpio.h>
25
26#if DT_ANY_INST_ON_BUS_STATUS_OKAY(spi)
27#include <zephyr/drivers/spi.h>
28#endif /* DT_ANY_INST_ON_BUS_STATUS_OKAY(spi) */
29
30#if DT_ANY_INST_ON_BUS_STATUS_OKAY(i2c)
31#include <zephyr/drivers/i2c.h>
32#endif /* DT_ANY_INST_ON_BUS_STATUS_OKAY(i2c) */
33
44#if DT_ANY_INST_ON_BUS_STATUS_OKAY(spi)
45 struct spi_dt_spec spi;
46#endif /* DT_ANY_INST_ON_BUS_STATUS_OKAY(spi) */
47#if DT_ANY_INST_ON_BUS_STATUS_OKAY(i2c)
48 struct i2c_dt_spec i2c;
49#endif /* DT_ANY_INST_ON_BUS_STATUS_OKAY(i2c) */
51 int (*bus_init)(const struct device *dev);
53 struct gpio_dt_spec reset;
55 uint8_t n_channels;
58#ifdef CONFIG_MFD_SC16IS75X_INTERRUPTS
60 struct gpio_dt_spec interrupt;
61#endif /* CONFIG_MFD_SC16IS75X_INTERRUPTS */
62};
63
73 int (*read_raw)(const struct device *dev, const uint8_t sub_address, uint8_t *buf,
74 const size_t len);
76 int (*write_raw)(const struct device *dev, const uint8_t sub_address, const uint8_t *buf,
77 const size_t len);
78#ifdef CONFIG_MFD_SC16IS75X_ASYNC
79 int (*read_raw_signal)(const struct device *dev, const uint8_t sub_address, uint8_t *buf,
80 const size_t len, struct k_poll_signal *signal);
81#endif /* CONFIG_MFD_SC16IS75X_ASYNC */
82};
83
84#ifdef CONFIG_MFD_SC16IS75X_ASWQ
85
89int mfd_sc16is75x_read_raw_signal(const struct device *dev, const uint8_t sub_address, uint8_t *buf,
90 const size_t len, struct k_poll_signal *signal);
91
92#endif /* CONFIG_MFD_SC16IS75X_ASWQ */
93
104 const struct device *self;
108 struct k_mutex transaction_lock;
109#ifdef CONFIG_MFD_SC16IS75X_ASWQ
111 struct k_work_q work_queue;
113 k_thread_stack_t *work_queue_stack;
114#endif /* CONFIG_MFD_SC16IS75X_ASWQ */
115#ifdef CONFIG_MFD_SC16IS75X_INTERRUPTS
117 struct gpio_callback interrupt_cb;
119 struct k_work interrupt_work;
121 sys_slist_t callbacks;
122#endif /* CONFIG_MFD_SC16IS75X_INTERRUPTS */
123};
124
125int mfd_sc16is75x_spi_init(const struct device *dev);
126int mfd_sc16is75x_i2c_init(const struct device *dev);
127
128#ifdef __cplusplus
129}
130#endif
131
132#endif /* ZEPHYR_DRIVERS_MFD_SC16IS75X_H_*/
#define SC16IS75X_UART_CHANNELS_MAX
Maximum UART channels.
Definition sc16is75x.h:271
int mfd_sc16is75x_i2c_init(const struct device *dev)
Definition mfd_sc16is75x_i2c.c:126
int mfd_sc16is75x_spi_init(const struct device *dev)
Definition mfd_sc16is75x_spi.c:177
int mfd_sc16is75x_read_raw_signal(const struct device *dev, const uint8_t sub_address, uint8_t *buf, const size_t len, struct k_poll_signal *signal)
Definition mfd_sc16is75x_async.c:58
MFD Interface for an SC16IS75X bridge.
SC16IS75X MFD configuration data.
Definition mfd_sc16is75x.h:43
struct gpio_dt_spec reset
GPIO pin for chip reset.
Definition mfd_sc16is75x.h:53
int(* bus_init)(const struct device *dev)
bus specific initialization function (SPI or I2C)
Definition mfd_sc16is75x.h:51
uint8_t channels[SC16IS75X_UART_CHANNELS_MAX]
UART channel numbers.
Definition mfd_sc16is75x.h:57
uint8_t n_channels
Number of UART channels provided by this device.
Definition mfd_sc16is75x.h:55
SC16IS75X MFD data.
Definition mfd_sc16is75x.h:102
struct k_mutex transaction_lock
Mutex to allow locking across multiple transactions.
Definition mfd_sc16is75x.h:108
const struct mfd_sc16is75x_transfer_function * transfer_function
bus specific transfer functions (SPI or I2C)
Definition mfd_sc16is75x.h:106
const struct device * self
Back refernce to driver instance.
Definition mfd_sc16is75x.h:104
SC16IS75X MFD bus transfer functions.
Definition mfd_sc16is75x.h:71
int(* write_raw)(const struct device *dev, const uint8_t sub_address, const uint8_t *buf, const size_t len)
write raw data
Definition mfd_sc16is75x.h:76
int(* read_raw)(const struct device *dev, const uint8_t sub_address, uint8_t *buf, const size_t len)
read raw data
Definition mfd_sc16is75x.h:73