Lines Matching refs:master
97 static int fsi_master_read(struct fsi_master *master, int link,
99 static int fsi_master_write(struct fsi_master *master, int link,
101 static int fsi_master_break(struct fsi_master *master, int link);
197 struct fsi_master *master = slave->master; in fsi_slave_report_and_clear_errors() local
205 rc = fsi_master_read(master, link, id, FSI_SLAVE_BASE + FSI_SISC, in fsi_slave_report_and_clear_errors()
210 rc = fsi_master_read(master, link, id, FSI_SLAVE_BASE + FSI_SSTAT, in fsi_slave_report_and_clear_errors()
219 return fsi_master_write(master, link, id, FSI_SLAVE_BASE + FSI_SISC, in fsi_slave_report_and_clear_errors()
266 return fsi_master_write(slave->master, slave->link, slave->id, in fsi_slave_set_smode()
274 struct fsi_master *master = slave->master; in fsi_slave_handle_error() local
296 if (master->term) { in fsi_slave_handle_error()
297 rc = master->term(master, link, id); in fsi_slave_handle_error()
299 rc = fsi_master_read(master, link, id, 0, in fsi_slave_handle_error()
312 rc = fsi_master_break(master, link); in fsi_slave_handle_error()
323 if (master->link_config) in fsi_slave_handle_error()
324 master->link_config(master, link, in fsi_slave_handle_error()
342 rc = fsi_master_read(slave->master, slave->link, in fsi_slave_read()
367 rc = fsi_master_write(slave->master, slave->link, in fsi_slave_write()
511 slave->master->idx, slave->link, in fsi_slave_scan()
643 static struct device_node *fsi_slave_find_of_node(struct fsi_master *master, in fsi_slave_find_of_node() argument
648 parent = dev_of_node(&master->dev); in fsi_slave_find_of_node()
770 struct fsi_master *master = slave->master; in send_term_store() local
772 if (!master->term) in send_term_store()
775 master->term(master, slave->link, slave->id); in send_term_store()
794 struct fsi_master *master = slave->master; in slave_send_echo_store() local
804 if (!master->link_config) in slave_send_echo_store()
814 if (master->link_config) in slave_send_echo_store()
815 master->link_config(master, slave->link, in slave_send_echo_store()
981 static int fsi_slave_init(struct fsi_master *master, int link, uint8_t id) in fsi_slave_init() argument
995 rc = fsi_master_read(master, link, id, 0, &data, sizeof(data)); in fsi_slave_init()
997 dev_dbg(&master->dev, "can't read slave %02x:%02x %d\n", in fsi_slave_init()
1005 trace_fsi_slave_invalid_cfam(master, link, cfam_id); in fsi_slave_init()
1006 dev_warn(&master->dev, "slave %02x:%02x invalid cfam id CRC!\n", in fsi_slave_init()
1011 dev_dbg(&master->dev, "fsi: found chip %08x at %02x:%02x:%02x\n", in fsi_slave_init()
1012 cfam_id, master->idx, link, id); in fsi_slave_init()
1017 if (master->flags & FSI_MASTER_FLAG_SWCLOCK) { in fsi_slave_init()
1019 rc = fsi_master_write(master, link, id, in fsi_slave_init()
1023 dev_warn(&master->dev, in fsi_slave_init()
1037 slave->dev.parent = &master->dev; in fsi_slave_init()
1038 slave->dev.of_node = fsi_slave_find_of_node(master, link, id); in fsi_slave_init()
1042 slave->master = master; in fsi_slave_init()
1059 rc = fsi_master_write(master, link, id, FSI_SLAVE_BASE + FSI_SLBUS, in fsi_slave_init()
1062 dev_warn(&master->dev, in fsi_slave_init()
1068 dev_warn(&master->dev, in fsi_slave_init()
1095 if (master->link_config) in fsi_slave_init()
1096 master->link_config(master, link, in fsi_slave_init()
1108 dev_dbg(&master->dev, "failed during slave scan with: %d\n", in fsi_slave_init()
1136 static int fsi_master_read(struct fsi_master *master, int link, in fsi_master_read() argument
1141 trace_fsi_master_read(master, link, slave_id, addr, size); in fsi_master_read()
1145 rc = master->read(master, link, slave_id, addr, val, size); in fsi_master_read()
1147 trace_fsi_master_rw_result(master, link, slave_id, addr, size, in fsi_master_read()
1153 static int fsi_master_write(struct fsi_master *master, int link, in fsi_master_write() argument
1158 trace_fsi_master_write(master, link, slave_id, addr, size, val); in fsi_master_write()
1162 rc = master->write(master, link, slave_id, addr, val, size); in fsi_master_write()
1164 trace_fsi_master_rw_result(master, link, slave_id, addr, size, in fsi_master_write()
1170 static int fsi_master_link_disable(struct fsi_master *master, int link) in fsi_master_link_disable() argument
1172 if (master->link_enable) in fsi_master_link_disable()
1173 return master->link_enable(master, link, false); in fsi_master_link_disable()
1178 static int fsi_master_link_enable(struct fsi_master *master, int link) in fsi_master_link_enable() argument
1180 if (master->link_enable) in fsi_master_link_enable()
1181 return master->link_enable(master, link, true); in fsi_master_link_enable()
1189 static int fsi_master_break(struct fsi_master *master, int link) in fsi_master_break() argument
1193 trace_fsi_master_break(master, link); in fsi_master_break()
1195 if (master->send_break) in fsi_master_break()
1196 rc = master->send_break(master, link); in fsi_master_break()
1197 if (master->link_config) in fsi_master_break()
1198 master->link_config(master, link, 16, 16); in fsi_master_break()
1203 static int fsi_master_scan(struct fsi_master *master) in fsi_master_scan() argument
1207 trace_fsi_master_scan(master, true); in fsi_master_scan()
1208 for (link = 0; link < master->n_links; link++) { in fsi_master_scan()
1209 rc = fsi_master_link_enable(master, link); in fsi_master_scan()
1211 dev_dbg(&master->dev, in fsi_master_scan()
1215 rc = fsi_master_break(master, link); in fsi_master_scan()
1217 fsi_master_link_disable(master, link); in fsi_master_scan()
1218 dev_dbg(&master->dev, in fsi_master_scan()
1223 rc = fsi_slave_init(master, link, 0); in fsi_master_scan()
1225 fsi_master_link_disable(master, link); in fsi_master_scan()
1247 static void fsi_master_unscan(struct fsi_master *master) in fsi_master_unscan() argument
1249 trace_fsi_master_scan(master, false); in fsi_master_unscan()
1250 device_for_each_child(&master->dev, NULL, fsi_master_remove_slave); in fsi_master_unscan()
1253 int fsi_master_rescan(struct fsi_master *master) in fsi_master_rescan() argument
1257 mutex_lock(&master->scan_lock); in fsi_master_rescan()
1258 fsi_master_unscan(master); in fsi_master_rescan()
1259 rc = fsi_master_scan(master); in fsi_master_rescan()
1260 mutex_unlock(&master->scan_lock); in fsi_master_rescan()
1269 struct fsi_master *master = to_fsi_master(dev); in master_rescan_store() local
1272 rc = fsi_master_rescan(master); in master_rescan_store()
1284 struct fsi_master *master = to_fsi_master(dev); in master_break_store() local
1286 fsi_master_break(master, 0); in master_break_store()
1299 ATTRIBUTE_GROUPS(master);
1306 int fsi_master_register(struct fsi_master *master) in fsi_master_register() argument
1311 mutex_init(&master->scan_lock); in fsi_master_register()
1314 if (master->idx) { in fsi_master_register()
1315 master->idx = ida_alloc_range(&master_ida, master->idx, in fsi_master_register()
1316 master->idx, GFP_KERNEL); in fsi_master_register()
1318 master->idx = ida_alloc(&master_ida, GFP_KERNEL); in fsi_master_register()
1321 if (master->idx < 0) in fsi_master_register()
1322 return master->idx; in fsi_master_register()
1324 if (!dev_name(&master->dev)) in fsi_master_register()
1325 dev_set_name(&master->dev, "fsi%d", master->idx); in fsi_master_register()
1327 master->dev.class = &fsi_master_class; in fsi_master_register()
1329 mutex_lock(&master->scan_lock); in fsi_master_register()
1330 rc = device_register(&master->dev); in fsi_master_register()
1332 ida_free(&master_ida, master->idx); in fsi_master_register()
1336 np = dev_of_node(&master->dev); in fsi_master_register()
1338 fsi_master_scan(master); in fsi_master_register()
1341 mutex_unlock(&master->scan_lock); in fsi_master_register()
1346 void fsi_master_unregister(struct fsi_master *master) in fsi_master_unregister() argument
1348 int idx = master->idx; in fsi_master_unregister()
1350 trace_fsi_master_unregister(master); in fsi_master_unregister()
1352 mutex_lock(&master->scan_lock); in fsi_master_unregister()
1353 fsi_master_unscan(master); in fsi_master_unregister()
1354 master->n_links = 0; in fsi_master_unregister()
1355 mutex_unlock(&master->scan_lock); in fsi_master_unregister()
1357 device_unregister(&master->dev); in fsi_master_unregister()