Lines Matching +full:100 +full:base +full:- +full:t
8 * SPDX-License-Identifier: Apache-2.0
23 #include "i2c-priv.h"
26 LPI2C_Type *base; member
46 const struct rv32m1_lpi2c_config *config = dev->config; in rv32m1_lpi2c_configure()
52 /* Slave mode not supported - yet */ in rv32m1_lpi2c_configure()
54 return -ENOTSUP; in rv32m1_lpi2c_configure()
58 /* FSL LPI2C driver only supports 7-bit addressing */ in rv32m1_lpi2c_configure()
60 return -ENOTSUP; in rv32m1_lpi2c_configure()
65 baudrate = KHZ(100); in rv32m1_lpi2c_configure()
73 /* TODO: only if SCL pin implements current source pull-up */ in rv32m1_lpi2c_configure()
77 /* TODO: ultra-fast requires pin_config setting */ in rv32m1_lpi2c_configure()
83 return -ENOTSUP; in rv32m1_lpi2c_configure()
86 err = clock_control_get_rate(config->clock_dev, config->clock_subsys, &clk_freq); in rv32m1_lpi2c_configure()
89 return -EINVAL; in rv32m1_lpi2c_configure()
92 LPI2C_MasterSetBaudRate(config->base, clk_freq, baudrate); in rv32m1_lpi2c_configure()
97 static void rv32m1_lpi2c_master_transfer_callback(LPI2C_Type *base, in rv32m1_lpi2c_master_transfer_callback() argument
104 ARG_UNUSED(base); in rv32m1_lpi2c_master_transfer_callback()
107 data->completion_status = completionStatus; in rv32m1_lpi2c_master_transfer_callback()
108 k_sem_give(&data->completion_sync); in rv32m1_lpi2c_master_transfer_callback()
130 const struct rv32m1_lpi2c_config *config = dev->config; in rv32m1_lpi2c_transfer()
131 struct rv32m1_lpi2c_data *data = dev->data; in rv32m1_lpi2c_transfer()
136 k_sem_take(&data->transfer_sync, K_FOREVER); in rv32m1_lpi2c_transfer()
140 if (I2C_MSG_ADDR_10_BITS & msgs->flags) { in rv32m1_lpi2c_transfer()
141 ret = -ENOTSUP; in rv32m1_lpi2c_transfer()
146 transfer.flags = rv32m1_lpi2c_convert_flags(msgs->flags); in rv32m1_lpi2c_transfer()
151 if (i != 0 && !(msgs->flags & I2C_MSG_RESTART)) { in rv32m1_lpi2c_transfer()
156 transfer.direction = (msgs->flags & I2C_MSG_READ) in rv32m1_lpi2c_transfer()
160 transfer.data = msgs->buf; in rv32m1_lpi2c_transfer()
161 transfer.dataSize = msgs->len; in rv32m1_lpi2c_transfer()
164 status = LPI2C_MasterTransferNonBlocking(config->base, in rv32m1_lpi2c_transfer()
165 &data->handle, in rv32m1_lpi2c_transfer()
168 /* Return an error if the transfer didn't start successfully in rv32m1_lpi2c_transfer()
173 ret = -EIO; in rv32m1_lpi2c_transfer()
178 k_sem_take(&data->completion_sync, K_FOREVER); in rv32m1_lpi2c_transfer()
180 /* Return an error if the transfer didn't complete in rv32m1_lpi2c_transfer()
183 if (data->completion_status != kStatus_Success) { in rv32m1_lpi2c_transfer()
185 data->completion_status); in rv32m1_lpi2c_transfer()
186 LPI2C_MasterTransferAbort(config->base, &data->handle); in rv32m1_lpi2c_transfer()
187 ret = -EIO; in rv32m1_lpi2c_transfer()
196 k_sem_give(&data->transfer_sync); in rv32m1_lpi2c_transfer()
202 const struct rv32m1_lpi2c_config *config = dev->config; in rv32m1_lpi2c_isr()
203 struct rv32m1_lpi2c_data *data = dev->data; in rv32m1_lpi2c_isr()
205 LPI2C_MasterTransferHandleIRQ(config->base, &data->handle); in rv32m1_lpi2c_isr()
210 const struct rv32m1_lpi2c_config *config = dev->config; in rv32m1_lpi2c_init()
211 struct rv32m1_lpi2c_data *data = dev->data; in rv32m1_lpi2c_init()
216 CLOCK_SetIpSrc(config->clock_ip_name, config->clock_ip_src); in rv32m1_lpi2c_init()
218 if (!device_is_ready(config->clock_dev)) { in rv32m1_lpi2c_init()
220 return -ENODEV; in rv32m1_lpi2c_init()
223 err = clock_control_on(config->clock_dev, config->clock_subsys); in rv32m1_lpi2c_init()
226 return -EINVAL; in rv32m1_lpi2c_init()
229 err = clock_control_get_rate(config->clock_dev, config->clock_subsys, &clk_freq); in rv32m1_lpi2c_init()
232 return -EINVAL; in rv32m1_lpi2c_init()
236 LPI2C_MasterInit(config->base, &master_config, clk_freq); in rv32m1_lpi2c_init()
237 LPI2C_MasterTransferCreateHandle(config->base, &data->handle, in rv32m1_lpi2c_init()
241 dev_cfg = i2c_map_dt_bitrate(config->bitrate); in rv32m1_lpi2c_init()
248 err = pinctrl_apply_state(config->pincfg, PINCTRL_STATE_DEFAULT); in rv32m1_lpi2c_init()
253 config->irq_config_func(dev); in rv32m1_lpi2c_init()
270 .base = \