15 #define DW_I2C_TIMEOUT_US 10000
17 #define DW_I2C_FLUSH_TIMEOUT_US 160000
147 #define DW_I2C_COMP_TYPE 0x44570140
206 .clk_speed_mhz = 133,
213 .clk_speed_mhz = 150,
220 .clk_speed_mhz = 216,
316 size_t byte,
int send_stop)
331 cmd = segment->
buf[byte];
335 if (send_stop &&
byte == segment->
len - 1)
379 if (
CONFIG(DRIVERS_I2C_DESIGNWARE_DEBUG)) {
387 for (
byte = 0;
byte < segments->
len;
byte++) {
398 "read" :
"write",
bus, segments->
slave);
403 if (
CONFIG(DRIVERS_I2C_DESIGNWARE_DEBUG)) {
405 for (j = 0; j < segments->
len; j++)
460 const struct i2c_msg *orig_msg = msg;
465 if (
count == 0 || !msg)
471 for (i = 0, start = 0; i <
count; i++, msg++) {
493 void *hcnt_reg, *lcnt_reg;
505 hcnt_reg = &
regs->hs_scl_hcnt;
506 lcnt_reg = &
regs->hs_scl_lcnt;
509 hcnt_reg = &
regs->fs_scl_hcnt;
510 lcnt_reg = &
regs->fs_scl_lcnt;
513 hcnt_reg = &
regs->ss_scl_hcnt;
514 lcnt_reg = &
regs->ss_scl_lcnt;
538 int fall_cnt, rise_cnt, min_tlow_cnt, min_thigh_cnt, spk_cnt;
539 int hcnt, lcnt, period_cnt, diff, tot;
540 int data_hold_time_ns;
573 "dw_i2c: period %d rise %d fall %d tlow %d thigh %d spk %d\n",
574 period_cnt, rise_cnt, fall_cnt, min_tlow_cnt, min_thigh_cnt,
582 hcnt = min_thigh_cnt - fall_cnt - 7 - spk_cnt;
583 lcnt = min_tlow_cnt - rise_cnt + fall_cnt - 1;
585 if (hcnt < 0 || lcnt < 0) {
593 tot = hcnt + lcnt + 7 + spk_cnt + rise_cnt + 1;
595 if (tot < period_cnt) {
596 diff = (period_cnt - tot) / 2;
599 tot = hcnt + lcnt + 7 + spk_cnt + rise_cnt + 1;
600 lcnt += period_cnt - tot;
615 hcnt, lcnt,
config->sda_hold);
625 const int ic_clk = CONFIG_DRIVERS_I2C_DESIGNWARE_CLOCK_MHZ;
632 "DRIVERS_I2C_DESIGNWARE_CLOCK_MHZ can't be zero!");
809 unsigned int speed, i;
const char * acpi_device_path(const struct device *dev)
void acpigen_write_dword(unsigned int data)
void acpigen_pop_len(void)
void acpigen_write_scope(const char *name)
char * acpigen_write_package(int nr_el)
void acpigen_write_word(unsigned int data)
void acpigen_write_name(const char *name)
static void write32(void *addr, uint32_t val)
static uint32_t read32(const void *addr)
void * memcpy(void *dest, const void *src, size_t n)
#define DIV_ROUND_UP(x, y)
cb_err
coreboot error codes
@ CB_ERR
Generic error code.
@ CB_SUCCESS
Call completed successfully.
#define printk(level,...)
static enum cb_err dw_i2c_set_speed_config(unsigned int bus, const struct dw_i2c_speed_config *config)
void dw_i2c_dev_init(struct device *dev)
static enum cb_err dw_i2c_gen_config_rise_fall_time(struct dw_i2c_regs *regs, enum i2c_speed speed, const struct dw_i2c_bus_config *bcfg, int ic_clk, struct dw_i2c_speed_config *config)
static enum cb_err dw_i2c_transfer_byte(struct dw_i2c_regs *regs, const struct i2c_msg *segment, size_t byte, int send_stop)
int platform_i2c_transfer(unsigned int bus, struct i2c_msg *msg, int count)
static enum cb_err dw_i2c_transfer(unsigned int bus, const struct i2c_msg *msg, size_t count)
static int counts_from_time(const struct freq *f, int ns)
static void dw_i2c_enable(struct dw_i2c_regs *regs)
struct dw_i2c_regs __packed
static enum cb_err _dw_i2c_transfer(unsigned int bus, const struct i2c_msg *segments, size_t count)
static const struct soc_clock * get_soc_descriptor(int ic_clk)
void dw_i2c_acpi_fill_ssdt(const struct device *dev)
enum cb_err dw_i2c_gen_speed_config(uintptr_t dw_i2c_addr, enum i2c_speed speed, const struct dw_i2c_bus_config *bcfg, struct dw_i2c_speed_config *config)
static int dw_i2c_dev_transfer(struct device *dev, const struct i2c_msg *msg, size_t count)
#define DW_I2C_TIMEOUT_US
static const struct i2c_descriptor * get_bus_descriptor(enum i2c_speed speed)
static void dw_i2c_acpi_write_speed_config(const struct dw_i2c_speed_config *config)
enum cb_err dw_i2c_init(unsigned int bus, const struct dw_i2c_bus_config *bcfg)
static int counts_from_freq(const struct freq *fast, const struct freq *slow)
static const struct soc_clock soc_clocks[]
static enum cb_err dw_i2c_set_speed(unsigned int bus, enum i2c_speed speed, const struct dw_i2c_bus_config *bcfg)
#define DW_I2C_FLUSH_TIMEOUT_US
static enum cb_err dw_i2c_wait_for_bus_idle(struct dw_i2c_regs *regs)
static enum cb_err dw_i2c_disable(struct dw_i2c_regs *regs)
const struct i2c_bus_operations dw_i2c_bus_ops
static const struct i2c_descriptor speed_descriptors[]
@ STATUS_RX_FIFO_NOT_EMPTY
@ STATUS_TX_FIFO_NOT_FULL
uintptr_t dw_i2c_base_address(unsigned int bus)
int dw_i2c_soc_dev_to_bus(const struct device *dev)
const struct dw_i2c_bus_config * dw_i2c_get_soc_cfg(unsigned int bus)
#define DW_I2C_SPEED_CONFIG_COUNT
void acpigen_write_scope_end(void)
static int stopwatch_expired(struct stopwatch *sw)
static void stopwatch_init_usecs_expire(struct stopwatch *sw, long us)
#define BIOS_INFO
BIOS_INFO - Expected events.
#define BIOS_DEBUG
BIOS_DEBUG - Verbose output.
#define BIOS_ERR
BIOS_ERR - System in incomplete state.
_Static_assert(sizeof(hls_t)==HLS_SIZE, "HLS_SIZE must equal to sizeof(hls_t)")
struct dw_i2c_speed_config speed_config[DW_I2C_SPEED_CONFIG_COUNT]
uint32_t clear_tx_over_intr
uint32_t clear_rx_over_intr
uint32_t clear_rx_under_intr
uint32_t ack_general_call
uint32_t slv_data_nak_only
uint32_t clear_gen_call_intr
uint32_t clear_stop_det_intr
uint32_t clear_rx_done_intr
uint32_t clear_start_det_intr
uint32_t clear_rd_req_intr
uint32_t clear_tx_abrt_intr
uint32_t clear_activity_intr
int(* transfer)(struct device *, const struct i2c_msg *, size_t count)
struct i2c_msg - an I2C transaction segment beginning with START @addr: Slave address,...
static struct am335x_pinmux_regs * regs