88 "INTR_STAT %x\nCONTROL %x\nTRANSFER_LEN %x\nTRANSAC_LEN %x\n"
89 "DELAY_LEN %x\nTIMING %x\nSTART %x\nFIFO_STAT %x\nIO_CONFIG %x\n"
90 "HS %x\nDEBUGSTAT %x\nEXT_CONF %x\n",
138 assert(seg[0].len > 0 && seg[0].len <= 255);
139 write_len = seg[0].
len;
140 write_buffer = seg[0].
buf;
144 assert(seg[0].len > 0 && seg[0].len <= 255);
145 read_len = seg[0].
len;
146 read_buffer = seg[0].
buf;
151 assert(seg[0].len > 0 && seg[0].len <= 255);
152 assert(seg[1].len > 0 && seg[1].len <= 255);
153 write_len = seg[0].
len;
154 read_len = seg[1].
len;
155 write_buffer = seg[0].
buf;
156 read_buffer = seg[1].
buf;
172 memcpy(_dma_coherent, write_buffer, write_len);
212 memcpy(_dma_coherent, write_buffer, write_len);
259 memcpy(read_buffer, _dma_coherent, read_len);
287 return (left_count >= 2 &&
308 for (i = 0; i < seg_count; i++) {
345 uint32_t su_sta_cnt, low_cnt, high_cnt, max_step_cnt;
346 uint32_t sda_max, sda_min, clk_ns, max_sta_cnt = 0x100;
355 if (su_sta_cnt > max_sta_cnt)
360 if (2 * step_cnt > low_cnt && low_cnt < max_step_cnt) {
361 if (low_cnt > step_cnt) {
362 high_cnt = 2 * step_cnt - low_cnt;
372 if (sda_max > low_cnt)
376 if (sda_min < low_cnt)
379 if (sda_min > sda_max)
386 ac_timing->
ltiming |= (sample_cnt << 12) | (low_cnt << 9);
388 ac_timing->
ext |= (su_sta_cnt << 1) | (1 << 0);
390 ac_timing->
htiming = (sample_cnt << 8) | (high_cnt);
391 ac_timing->
ltiming = (sample_cnt << 6) | (low_cnt);
392 ac_timing->
ext = (su_sta_cnt << 8) | (1 << 0);
422 int32_t clock_div_constraint = 0;
429 base_step_cnt = max_step_cnt;
442 if (sample_cnt == 1) {
444 clock_div_constraint = 1;
446 clock_div_constraint = 0;
449 clock_div_constraint = 1;
450 else if (clk_div == 0)
451 clock_div_constraint = -1;
453 clock_div_constraint = 0;
456 step_cnt =
DIV_ROUND_UP(opt_div + clock_div_constraint, sample_cnt);
457 if (step_cnt > max_step_cnt)
460 cnt_mul = step_cnt * sample_cnt;
461 if (cnt_mul >= best_mul)
465 target_speed, step_cnt - 1,
471 base_sample_cnt = sample_cnt;
472 base_step_cnt = step_cnt;
473 if (best_mul == opt_div + clock_div_constraint)
481 sample_cnt = base_sample_cnt;
482 step_cnt = base_step_cnt;
484 if (clk_src / (2 * (sample_cnt * step_cnt - clock_div_constraint)) >
488 *timing_step_cnt = step_cnt - 1;
489 *timing_sample_cnt = sample_cnt - 1;
497 uint32_t clk_src, clk_div, step_cnt, sample_cnt;
508 for (clk_div = 1; clk_div <= max_clk_div; clk_div++) {
515 &l_step_cnt, &l_sample_cnt))
520 &step_cnt, &sample_cnt))
526 &l_step_cnt, &l_sample_cnt))
536 if (clk_div > max_clk_div) {
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 assert(statement)
#define GENMASK(high, low)
#define DIV_ROUND_UP(x, y)
#define printk(level,...)
#define I2C_TIME_CLR_VALUE
#define MAX_HS_STEP_CNT_DIV
#define I2C_FAST_MODE_BUFFER
#define I2C_FAST_MODE_PLUS_BUFFER
#define MAX_SAMPLE_CNT_DIV
#define I2C_STANDARD_MODE_BUFFER
@ I2C_TRANSFER_FAIL_TIMEOUT
@ I2C_TRANSFER_FAIL_ACKERR
@ I2C_TRANSFER_FAIL_HS_NACKERR
#define I2C_TIME_DEFAULT_VALUE
static int stopwatch_expired(struct stopwatch *sw)
static void stopwatch_init_usecs_expire(struct stopwatch *sw, long us)
#define BIOS_DEBUG
BIOS_DEBUG - Verbose output.
#define BIOS_ERR
BIOS_ERR - System in incomplete state.
const struct smm_save_state_ops *legacy_ops __weak
int platform_i2c_transfer(unsigned int bus, struct i2c_msg *segment, int seg_count)
static struct spi_slave slave
unsigned long long uint64_t
struct i2c_msg - an I2C transaction segment beginning with START @addr: Slave address,...
struct mt_i2c_dma_regs * i2c_dma_regs
struct mt_i2c_regs * i2c_regs
struct mtk_i2c_ac_timing ac_timing
static struct am335x_pinmux_regs * regs