Lines Matching +full:master +full:- +full:can +full:- +full:reg
4 * SPDX-License-Identifier: Apache-2.0
18 #include "i2c-priv.h"
22 #define I2C_REG(config, reg) ((mem_addr_t) ((config)->base + reg)) argument
23 #define IS_SET(config, reg, value) (sys_read8(I2C_REG(config, reg)) & (value)) argument
73 const struct i2c_sifive_cfg *config = dev->config; in i2c_sifive_busy()
82 const struct i2c_sifive_cfg *config = dev->config; in i2c_sifive_send_addr()
103 return -EIO; in i2c_sifive_send_addr()
113 const struct i2c_sifive_cfg *config = dev->config; in i2c_sifive_write_msg()
123 for (uint32_t i = 0; i < msg->len; i++) { in i2c_sifive_write_msg()
128 /* Put data in transmit reg */ in i2c_sifive_write_msg()
129 sys_write8((msg->buf)[i], I2C_REG(config, REG_TRANSMIT)); in i2c_sifive_write_msg()
135 if (i == (msg->len - 1)) { in i2c_sifive_write_msg()
137 if (msg->flags & I2C_MSG_STOP) { in i2c_sifive_write_msg()
142 /* Write command reg */ in i2c_sifive_write_msg()
151 return -EIO; in i2c_sifive_write_msg()
162 const struct i2c_sifive_cfg *config = dev->config; in i2c_sifive_read_msg()
170 for (int i = 0; i < msg->len; i++) { in i2c_sifive_read_msg()
175 if (i == (msg->len - 1)) { in i2c_sifive_read_msg()
180 if (msg->flags & I2C_MSG_STOP) { in i2c_sifive_read_msg()
185 /* Write command reg */ in i2c_sifive_read_msg()
193 (msg->buf)[i] = sys_read8(I2C_REG(config, REG_RECEIVE)); in i2c_sifive_read_msg()
210 return -EINVAL; in i2c_sifive_configure()
212 config = dev->config; in i2c_sifive_configure()
215 return -EINVAL; in i2c_sifive_configure()
234 return -ENOTSUP; in i2c_sifive_configure()
238 prescale = (config->f_sys / (i2c_speed * 5U)) - 1; in i2c_sifive_configure()
245 /* Support I2C Master mode only */ in i2c_sifive_configure()
247 LOG_ERR("I2C only supports operation as master"); in i2c_sifive_configure()
248 return -ENOTSUP; in i2c_sifive_configure()
252 * Driver does not support 10-bit addressing. This can be added in i2c_sifive_configure()
256 LOG_ERR("I2C driver does not support 10-bit addresses"); in i2c_sifive_configure()
257 return -ENOTSUP; in i2c_sifive_configure()
276 return -EINVAL; in i2c_sifive_transfer()
278 if (dev->config == NULL) { in i2c_sifive_transfer()
280 return -EINVAL; in i2c_sifive_transfer()
283 return -EINVAL; in i2c_sifive_transfer()
304 const struct i2c_sifive_cfg *config = dev->config; in i2c_sifive_init()
308 dev_config = (I2C_MODE_CONTROLLER | i2c_map_dt_bitrate(config->f_bus)); in i2c_sifive_init()