Lines Matching refs:cfg

57 static inline void i2c_gd32_enable_interrupts(const struct i2c_gd32_config *cfg)  in i2c_gd32_enable_interrupts()  argument
59 I2C_CTL1(cfg->reg) |= I2C_CTL1_ERRIE; in i2c_gd32_enable_interrupts()
60 I2C_CTL1(cfg->reg) |= I2C_CTL1_EVIE; in i2c_gd32_enable_interrupts()
61 I2C_CTL1(cfg->reg) |= I2C_CTL1_BUFIE; in i2c_gd32_enable_interrupts()
64 static inline void i2c_gd32_disable_interrupts(const struct i2c_gd32_config *cfg) in i2c_gd32_disable_interrupts() argument
66 I2C_CTL1(cfg->reg) &= ~I2C_CTL1_ERRIE; in i2c_gd32_disable_interrupts()
67 I2C_CTL1(cfg->reg) &= ~I2C_CTL1_EVIE; in i2c_gd32_disable_interrupts()
68 I2C_CTL1(cfg->reg) &= ~I2C_CTL1_BUFIE; in i2c_gd32_disable_interrupts()
72 const struct i2c_gd32_config *cfg) in i2c_gd32_xfer_read() argument
75 *data->current->buf = I2C_DATA(cfg->reg); in i2c_gd32_xfer_read()
85 const struct i2c_gd32_config *cfg) in i2c_gd32_xfer_write() argument
88 I2C_DATA(cfg->reg) = *data->current->buf; in i2c_gd32_xfer_write()
100 const struct i2c_gd32_config *cfg = dev->config; in i2c_gd32_handle_rbne() local
110 i2c_gd32_xfer_read(data, cfg); in i2c_gd32_handle_rbne()
124 I2C_CTL1(cfg->reg) &= ~I2C_CTL1_BUFIE; in i2c_gd32_handle_rbne()
132 i2c_gd32_xfer_read(data, cfg); in i2c_gd32_handle_rbne()
141 const struct i2c_gd32_config *cfg = dev->config; in i2c_gd32_handle_tbe() local
150 I2C_CTL1(cfg->reg) &= ~I2C_CTL1_BUFIE; in i2c_gd32_handle_tbe()
152 i2c_gd32_xfer_write(data, cfg); in i2c_gd32_handle_tbe()
156 I2C_CTL0(cfg->reg) |= I2C_CTL0_STOP; in i2c_gd32_handle_tbe()
165 const struct i2c_gd32_config *cfg = dev->config; in i2c_gd32_handle_btc() local
173 I2C_CTL0(cfg->reg) |= I2C_CTL0_STOP; in i2c_gd32_handle_btc()
177 i2c_gd32_xfer_read(data, cfg); in i2c_gd32_handle_btc()
185 I2C_CTL0(cfg->reg) &= ~I2C_CTL0_ACKEN; in i2c_gd32_handle_btc()
188 i2c_gd32_xfer_read(data, cfg); in i2c_gd32_handle_btc()
203 const struct i2c_gd32_config *cfg = dev->config; in i2c_gd32_handle_addsend() local
206 I2C_CTL0(cfg->reg) &= ~I2C_CTL0_ACKEN; in i2c_gd32_handle_addsend()
210 I2C_STAT0(cfg->reg); in i2c_gd32_handle_addsend()
211 I2C_STAT1(cfg->reg); in i2c_gd32_handle_addsend()
218 I2C_CTL0(cfg->reg) |= I2C_CTL0_START; in i2c_gd32_handle_addsend()
225 I2C_CTL0(cfg->reg) |= I2C_CTL0_STOP; in i2c_gd32_handle_addsend()
232 const struct i2c_gd32_config *cfg = dev->config; in i2c_gd32_event_isr() local
235 stat = I2C_STAT0(cfg->reg); in i2c_gd32_event_isr()
239 I2C_DATA(cfg->reg) = (data->addr1 << 1U) | 1U; in i2c_gd32_event_isr()
241 I2C_DATA(cfg->reg) = (data->addr1 << 1U) | 0U; in i2c_gd32_event_isr()
244 I2C_DATA(cfg->reg) = data->addr2; in i2c_gd32_event_isr()
263 const struct i2c_gd32_config *cfg = dev->config; in i2c_gd32_error_isr() local
266 stat = I2C_STAT0(cfg->reg); in i2c_gd32_error_isr()
269 I2C_STAT0(cfg->reg) &= ~I2C_STAT0_BERR; in i2c_gd32_error_isr()
274 I2C_STAT0(cfg->reg) &= ~I2C_STAT0_LOSTARB; in i2c_gd32_error_isr()
279 I2C_STAT0(cfg->reg) &= ~I2C_STAT0_AERR; in i2c_gd32_error_isr()
285 I2C_CTL0(cfg->reg) |= I2C_CTL0_STOP; in i2c_gd32_error_isr()
313 const struct i2c_gd32_config *cfg = dev->config; in i2c_gd32_xfer_begin() local
321 I2C_CTL0(cfg->reg) |= I2C_CTL0_ACKEN; in i2c_gd32_xfer_begin()
326 I2C_CTL0(cfg->reg) |= I2C_CTL0_POAP; in i2c_gd32_xfer_begin()
341 i2c_gd32_enable_interrupts(cfg); in i2c_gd32_xfer_begin()
344 I2C_CTL0(cfg->reg) |= I2C_CTL0_START; in i2c_gd32_xfer_begin()
350 const struct i2c_gd32_config *cfg = dev->config; in i2c_gd32_xfer_end() local
352 i2c_gd32_disable_interrupts(cfg); in i2c_gd32_xfer_end()
355 while (I2C_STAT1(cfg->reg) & I2C_STAT1_I2CBSY) { in i2c_gd32_xfer_end()
369 const struct i2c_gd32_config *cfg = dev->config; in i2c_gd32_msg_read() local
371 if (I2C_STAT1(cfg->reg) & I2C_STAT1_I2CBSY) { in i2c_gd32_msg_read()
386 const struct i2c_gd32_config *cfg = dev->config; in i2c_gd32_msg_write() local
388 if (I2C_STAT1(cfg->reg) & I2C_STAT1_I2CBSY) { in i2c_gd32_msg_write()
406 const struct i2c_gd32_config *cfg = dev->config; in i2c_gd32_transfer() local
449 I2C_CTL0(cfg->reg) |= I2C_CTL0_I2CEN; in i2c_gd32_transfer()
483 I2C_CTL0(cfg->reg) &= ~I2C_CTL0_I2CEN; in i2c_gd32_transfer()
494 const struct i2c_gd32_config *cfg = dev->config; in i2c_gd32_configure() local
501 I2C_CTL0(cfg->reg) &= ~I2C_CTL0_I2CEN; in i2c_gd32_configure()
504 (clock_control_subsys_t)&cfg->clkid, in i2c_gd32_configure()
553 I2C_CTL1(cfg->reg) &= ~I2C_CTL1_I2CCLK; in i2c_gd32_configure()
554 I2C_CTL1(cfg->reg) |= freq; in i2c_gd32_configure()
558 I2C_RT(cfg->reg) = I2CCLK_MAX; in i2c_gd32_configure()
560 I2C_RT(cfg->reg) = freq + 1U; in i2c_gd32_configure()
566 I2C_CKCFG(cfg->reg) &= ~I2C_CKCFG_CLKC; in i2c_gd32_configure()
567 I2C_CKCFG(cfg->reg) |= clkc; in i2c_gd32_configure()
569 I2C_CKCFG(cfg->reg) &= ~I2C_CKCFG_FAST; in i2c_gd32_configure()
581 I2C_RT(cfg->reg) = freq * 300U / 1000U + 1U; in i2c_gd32_configure()
590 I2C_CKCFG(cfg->reg) |= I2C_CKCFG_DTCY; in i2c_gd32_configure()
591 I2C_CKCFG(cfg->reg) &= ~I2C_CKCFG_CLKC; in i2c_gd32_configure()
592 I2C_CKCFG(cfg->reg) |= clkc; in i2c_gd32_configure()
594 I2C_CKCFG(cfg->reg) |= I2C_CKCFG_FAST; in i2c_gd32_configure()
598 I2C_FMPCFG(cfg->reg) &= ~I2C_FMPCFG_FMPEN; in i2c_gd32_configure()
612 I2C_RT(cfg->reg) = freq * 120U / 1000U + 1U; in i2c_gd32_configure()
621 I2C_CKCFG(cfg->reg) |= I2C_CKCFG_DTCY; in i2c_gd32_configure()
622 I2C_CKCFG(cfg->reg) &= ~I2C_CKCFG_CLKC; in i2c_gd32_configure()
623 I2C_CKCFG(cfg->reg) |= clkc; in i2c_gd32_configure()
625 I2C_CKCFG(cfg->reg) |= I2C_CKCFG_FAST; in i2c_gd32_configure()
628 I2C_FMPCFG(cfg->reg) |= I2C_FMPCFG_FMPEN; in i2c_gd32_configure()
655 const struct i2c_gd32_config *cfg = dev->config; in i2c_gd32_init() local
659 err = pinctrl_apply_state(cfg->pcfg, PINCTRL_STATE_DEFAULT); in i2c_gd32_init()
671 (clock_control_subsys_t)&cfg->clkid); in i2c_gd32_init()
673 (void)reset_line_toggle_dt(&cfg->reset); in i2c_gd32_init()
675 cfg->irq_cfg_func(); in i2c_gd32_init()
677 bitrate_cfg = i2c_map_dt_bitrate(cfg->bitrate); in i2c_gd32_init()