Lines Matching refs:master
79 struct fsi_master *master; member
91 static int fsi_master_read(struct fsi_master *master, int link,
93 static int fsi_master_write(struct fsi_master *master, int link,
95 static int fsi_master_break(struct fsi_master *master, int link);
190 struct fsi_master *master = slave->master; in fsi_slave_report_and_clear_errors() local
198 rc = fsi_master_read(master, link, id, FSI_SLAVE_BASE + FSI_SISC, in fsi_slave_report_and_clear_errors()
203 rc = fsi_master_read(master, link, id, FSI_SLAVE_BASE + FSI_SSTAT, in fsi_slave_report_and_clear_errors()
212 return fsi_master_write(master, link, id, FSI_SLAVE_BASE + FSI_SISC, in fsi_slave_report_and_clear_errors()
216 static int fsi_slave_set_smode(struct fsi_master *master, int link, int id);
221 struct fsi_master *master = slave->master; in fsi_slave_handle_error() local
243 if (master->term) { in fsi_slave_handle_error()
244 rc = master->term(master, link, id); in fsi_slave_handle_error()
246 rc = fsi_master_read(master, link, id, 0, in fsi_slave_handle_error()
256 rc = fsi_master_break(master, link); in fsi_slave_handle_error()
260 rc = fsi_slave_set_smode(master, link, id); in fsi_slave_handle_error()
278 rc = fsi_master_read(slave->master, slave->link, in fsi_slave_read()
303 rc = fsi_master_write(slave->master, slave->link, in fsi_slave_write()
403 slave->master->idx, slave->link, in fsi_slave_scan()
516 struct fsi_master *master = slave->master; in fsi_slave_sysfs_term_write() local
518 if (!master->term) in fsi_slave_sysfs_term_write()
521 master->term(master, slave->link, slave->id); in fsi_slave_sysfs_term_write()
566 static int fsi_slave_set_smode(struct fsi_master *master, int link, int id) in fsi_slave_set_smode() argument
576 return fsi_master_write(master, link, id, FSI_SLAVE_BASE + FSI_SMODE, in fsi_slave_set_smode()
587 static int fsi_slave_init(struct fsi_master *master, int link, uint8_t id) in fsi_slave_init() argument
600 rc = fsi_master_read(master, link, id, 0, &chip_id, sizeof(chip_id)); in fsi_slave_init()
602 dev_dbg(&master->dev, "can't read slave %02x:%02x %d\n", in fsi_slave_init()
610 dev_warn(&master->dev, "slave %02x:%02x invalid chip id CRC!\n", in fsi_slave_init()
615 dev_info(&master->dev, "fsi: found chip %08x at %02x:%02x:%02x\n", in fsi_slave_init()
616 chip_id, master->idx, link, id); in fsi_slave_init()
618 rc = fsi_slave_set_smode(master, link, id); in fsi_slave_init()
620 dev_warn(&master->dev, in fsi_slave_init()
629 if (master->flags & FSI_MASTER_FLAG_SWCLOCK) { in fsi_slave_init()
631 rc = fsi_master_write(master, link, id, in fsi_slave_init()
635 dev_warn(&master->dev, in fsi_slave_init()
647 slave->master = master; in fsi_slave_init()
648 slave->dev.parent = &master->dev; in fsi_slave_init()
657 dev_warn(&master->dev, "failed to create slave device: %d\n", in fsi_slave_init()
673 dev_dbg(&master->dev, "failed during slave scan with: %d\n", in fsi_slave_init()
691 static int fsi_master_read(struct fsi_master *master, int link, in fsi_master_read() argument
696 trace_fsi_master_read(master, link, slave_id, addr, size); in fsi_master_read()
700 rc = master->read(master, link, slave_id, addr, val, size); in fsi_master_read()
702 trace_fsi_master_rw_result(master, link, slave_id, addr, size, in fsi_master_read()
708 static int fsi_master_write(struct fsi_master *master, int link, in fsi_master_write() argument
713 trace_fsi_master_write(master, link, slave_id, addr, size, val); in fsi_master_write()
717 rc = master->write(master, link, slave_id, addr, val, size); in fsi_master_write()
719 trace_fsi_master_rw_result(master, link, slave_id, addr, size, in fsi_master_write()
725 static int fsi_master_link_enable(struct fsi_master *master, int link) in fsi_master_link_enable() argument
727 if (master->link_enable) in fsi_master_link_enable()
728 return master->link_enable(master, link); in fsi_master_link_enable()
736 static int fsi_master_break(struct fsi_master *master, int link) in fsi_master_break() argument
738 trace_fsi_master_break(master, link); in fsi_master_break()
740 if (master->send_break) in fsi_master_break()
741 return master->send_break(master, link); in fsi_master_break()
746 static int fsi_master_scan(struct fsi_master *master) in fsi_master_scan() argument
750 for (link = 0; link < master->n_links; link++) { in fsi_master_scan()
751 rc = fsi_master_link_enable(master, link); in fsi_master_scan()
753 dev_dbg(&master->dev, in fsi_master_scan()
757 rc = fsi_master_break(master, link); in fsi_master_scan()
759 dev_dbg(&master->dev, in fsi_master_scan()
764 fsi_slave_init(master, link, 0); in fsi_master_scan()
783 static void fsi_master_unscan(struct fsi_master *master) in fsi_master_unscan() argument
785 device_for_each_child(&master->dev, NULL, fsi_master_remove_slave); in fsi_master_unscan()
791 struct fsi_master *master = to_fsi_master(dev); in master_rescan_store() local
794 fsi_master_unscan(master); in master_rescan_store()
795 rc = fsi_master_scan(master); in master_rescan_store()
807 struct fsi_master *master = to_fsi_master(dev); in master_break_store() local
809 fsi_master_break(master, 0); in master_break_store()
816 int fsi_master_register(struct fsi_master *master) in fsi_master_register() argument
820 if (!master) in fsi_master_register()
823 master->idx = ida_simple_get(&master_ida, 0, INT_MAX, GFP_KERNEL); in fsi_master_register()
824 dev_set_name(&master->dev, "fsi%d", master->idx); in fsi_master_register()
826 rc = device_register(&master->dev); in fsi_master_register()
828 ida_simple_remove(&master_ida, master->idx); in fsi_master_register()
832 rc = device_create_file(&master->dev, &dev_attr_rescan); in fsi_master_register()
834 device_unregister(&master->dev); in fsi_master_register()
835 ida_simple_remove(&master_ida, master->idx); in fsi_master_register()
839 rc = device_create_file(&master->dev, &dev_attr_break); in fsi_master_register()
841 device_unregister(&master->dev); in fsi_master_register()
842 ida_simple_remove(&master_ida, master->idx); in fsi_master_register()
846 fsi_master_scan(master); in fsi_master_register()
852 void fsi_master_unregister(struct fsi_master *master) in fsi_master_unregister() argument
854 if (master->idx >= 0) { in fsi_master_unregister()
855 ida_simple_remove(&master_ida, master->idx); in fsi_master_unregister()
856 master->idx = -1; in fsi_master_unregister()
859 fsi_master_unscan(master); in fsi_master_unregister()
860 device_unregister(&master->dev); in fsi_master_unregister()