Lines Matching refs:mlxsw_i2c
66 struct mlxsw_i2c { struct
98 mlxsw_i2c_convert_mbox(struct mlxsw_i2c *mlxsw_i2c, u8 *buf) in mlxsw_i2c_convert_mbox() argument
104 mlxsw_i2c->cmd.mb_off_in = tmp & in mlxsw_i2c_convert_mbox()
106 mlxsw_i2c->cmd.mb_size_in = (tmp & GENMASK(31, in mlxsw_i2c_convert_mbox()
111 mlxsw_i2c->cmd.mb_off_out = tmp & in mlxsw_i2c_convert_mbox()
113 mlxsw_i2c->cmd.mb_size_out = (tmp & GENMASK(31, in mlxsw_i2c_convert_mbox()
136 struct mlxsw_i2c *mlxsw_i2c, u8 *p_status) in mlxsw_i2c_wait_go_bit() argument
180 struct mlxsw_i2c *mlxsw_i2c, in mlxsw_i2c_write_cmd() argument
227 struct mlxsw_i2c *mlxsw_i2c, u16 opcode, u32 in_mod) in mlxsw_i2c_write_init_cmd() argument
268 err = mlxsw_i2c_wait_go_bit(client, mlxsw_i2c, &status); in mlxsw_i2c_write_init_cmd()
286 struct mlxsw_i2c *mlxsw_i2c) in mlxsw_i2c_get_mbox() argument
306 mlxsw_i2c_convert_mbox(mlxsw_i2c, &buf[MLXSW_I2C_MBOX_OUT_PARAM_OFF]); in mlxsw_i2c_get_mbox()
317 struct mlxsw_i2c *mlxsw_i2c = i2c_get_clientdata(client); in mlxsw_i2c_write() local
319 int off = mlxsw_i2c->cmd.mb_off_in, chunk_size, i, j; in mlxsw_i2c_write()
326 tran_buf = kmalloc(mlxsw_i2c->block_size + MLXSW_I2C_ADDR_BUF_SIZE, in mlxsw_i2c_write()
333 chunk_size = (in_mbox_size > mlxsw_i2c->block_size) ? in mlxsw_i2c_write()
334 mlxsw_i2c->block_size : in_mbox_size; in mlxsw_i2c_write()
338 mlxsw_i2c->block_size * i, chunk_size); in mlxsw_i2c_write()
363 err = mlxsw_i2c_write_cmd(client, mlxsw_i2c, 0); in mlxsw_i2c_write()
371 err = mlxsw_i2c_wait_go_bit(client, mlxsw_i2c, p_status); in mlxsw_i2c_write()
395 struct mlxsw_i2c *mlxsw_i2c = i2c_get_clientdata(client); in mlxsw_i2c_cmd() local
399 int off = mlxsw_i2c->cmd.mb_off_out; in mlxsw_i2c_cmd()
409 num = reg_size / mlxsw_i2c->block_size; in mlxsw_i2c_cmd()
410 if (reg_size % mlxsw_i2c->block_size) in mlxsw_i2c_cmd()
413 if (mutex_lock_interruptible(&mlxsw_i2c->cmd.lock) < 0) { in mlxsw_i2c_cmd()
424 mutex_unlock(&mlxsw_i2c->cmd.lock); in mlxsw_i2c_cmd()
430 num = reg_size / mlxsw_i2c->block_size; in mlxsw_i2c_cmd()
432 if (mutex_lock_interruptible(&mlxsw_i2c->cmd.lock) < 0) { in mlxsw_i2c_cmd()
437 err = mlxsw_i2c_write_init_cmd(client, mlxsw_i2c, opcode, in mlxsw_i2c_cmd()
446 chunk_size = (reg_size > mlxsw_i2c->block_size) ? in mlxsw_i2c_cmd()
447 mlxsw_i2c->block_size : reg_size; in mlxsw_i2c_cmd()
475 mutex_unlock(&mlxsw_i2c->cmd.lock); in mlxsw_i2c_cmd()
480 mutex_unlock(&mlxsw_i2c->cmd.lock); in mlxsw_i2c_cmd()
490 struct mlxsw_i2c *mlxsw_i2c = bus_priv; in mlxsw_i2c_cmd_exec() local
492 return mlxsw_i2c_cmd(mlxsw_i2c->dev, opcode, in_mod, in_mbox_size, in mlxsw_i2c_cmd_exec()
513 struct mlxsw_i2c *mlxsw_i2c = bus_priv; in mlxsw_i2c_init() local
517 mlxsw_i2c->core = mlxsw_core; in mlxsw_i2c_init()
527 mlxsw_i2c->bus_info.fw_rev.major = in mlxsw_i2c_init()
529 mlxsw_i2c->bus_info.fw_rev.minor = in mlxsw_i2c_init()
531 mlxsw_i2c->bus_info.fw_rev.subminor = in mlxsw_i2c_init()
543 struct mlxsw_i2c *mlxsw_i2c = bus_priv; in mlxsw_i2c_fini() local
545 mlxsw_i2c->core = NULL; in mlxsw_i2c_fini()
561 struct mlxsw_i2c *mlxsw_i2c; in mlxsw_i2c_probe() local
565 mlxsw_i2c = devm_kzalloc(&client->dev, sizeof(*mlxsw_i2c), GFP_KERNEL); in mlxsw_i2c_probe()
566 if (!mlxsw_i2c) in mlxsw_i2c_probe()
578 mlxsw_i2c->block_size = max_t(u16, MLXSW_I2C_BLK_DEF, in mlxsw_i2c_probe()
582 mlxsw_i2c->block_size = MLXSW_I2C_BLK_DEF; in mlxsw_i2c_probe()
585 i2c_set_clientdata(client, mlxsw_i2c); in mlxsw_i2c_probe()
586 mutex_init(&mlxsw_i2c->cmd.lock); in mlxsw_i2c_probe()
601 err = mlxsw_i2c_write_cmd(client, mlxsw_i2c, 1); in mlxsw_i2c_probe()
608 err = mlxsw_i2c_wait_go_bit(client, mlxsw_i2c, &status); in mlxsw_i2c_probe()
623 err = mlxsw_i2c_get_mbox(client, mlxsw_i2c); in mlxsw_i2c_probe()
630 id->name, mlxsw_i2c->cmd.mb_size_in, in mlxsw_i2c_probe()
631 mlxsw_i2c->cmd.mb_off_in, mlxsw_i2c->cmd.mb_size_out, in mlxsw_i2c_probe()
632 mlxsw_i2c->cmd.mb_off_out); in mlxsw_i2c_probe()
635 mlxsw_i2c->bus_info.device_kind = id->name; in mlxsw_i2c_probe()
636 mlxsw_i2c->bus_info.device_name = client->name; in mlxsw_i2c_probe()
637 mlxsw_i2c->bus_info.dev = &client->dev; in mlxsw_i2c_probe()
638 mlxsw_i2c->bus_info.low_frequency = true; in mlxsw_i2c_probe()
639 mlxsw_i2c->dev = &client->dev; in mlxsw_i2c_probe()
641 err = mlxsw_core_bus_device_register(&mlxsw_i2c->bus_info, in mlxsw_i2c_probe()
642 &mlxsw_i2c_bus, mlxsw_i2c, false, in mlxsw_i2c_probe()
659 struct mlxsw_i2c *mlxsw_i2c = i2c_get_clientdata(client); in mlxsw_i2c_remove() local
661 mlxsw_core_bus_device_unregister(mlxsw_i2c->core, false); in mlxsw_i2c_remove()
662 mutex_destroy(&mlxsw_i2c->cmd.lock); in mlxsw_i2c_remove()