Lines Matching full:slave

45  * FSI slave engine control register offsets
49 #define FSI_SSTAT 0x14 /* R : Slave status */
90 uint32_t size; /* size of slave address space */
140 return fsi_slave_read(dev->slave, dev->addr + addr, val, size); in fsi_device_read()
150 return fsi_slave_write(dev->slave, dev->addr + addr, val, size); in fsi_device_write()
158 return fsi_slave_read(dev->slave, addr, val, sizeof(uint32_t)); in fsi_device_peek()
169 static struct fsi_device *fsi_create_device(struct fsi_slave *slave) in fsi_create_device() argument
177 dev->dev.parent = &slave->dev; in fsi_create_device()
184 /* FSI slave support */
185 static int fsi_slave_calc_addr(struct fsi_slave *slave, uint32_t *addrp, in fsi_slave_calc_addr() argument
191 if (addr > slave->size) in fsi_slave_calc_addr()
194 /* For 23 bit addressing, we encode the extra two bits in the slave in fsi_slave_calc_addr()
195 * id (and the slave's actual ID needs to be 0). in fsi_slave_calc_addr()
198 if (slave->id != 0) in fsi_slave_calc_addr()
209 static int fsi_slave_report_and_clear_errors(struct fsi_slave *slave) in fsi_slave_report_and_clear_errors() argument
211 struct fsi_master *master = slave->master; in fsi_slave_report_and_clear_errors()
216 link = slave->link; in fsi_slave_report_and_clear_errors()
217 id = slave->id; in fsi_slave_report_and_clear_errors()
229 dev_dbg(&slave->dev, "status: 0x%08x, sisc: 0x%08x\n", in fsi_slave_report_and_clear_errors()
237 /* Encode slave local bus echo delay */
243 /* Encode slave local bus send delay */
249 /* Encode slave local bus clock rate ratio */
255 /* Encode slave ID */
269 static int fsi_slave_set_smode(struct fsi_slave *slave) in fsi_slave_set_smode() argument
274 /* set our smode register with the slave ID field to 0; this enables in fsi_slave_set_smode()
275 * extended slave addressing in fsi_slave_set_smode()
277 smode = fsi_slave_smode(slave->id, slave->t_send_delay, slave->t_echo_delay); in fsi_slave_set_smode()
280 return fsi_master_write(slave->master, slave->link, slave->id, in fsi_slave_set_smode()
285 static int fsi_slave_handle_error(struct fsi_slave *slave, bool write, in fsi_slave_handle_error() argument
288 struct fsi_master *master = slave->master; in fsi_slave_handle_error()
296 link = slave->link; in fsi_slave_handle_error()
297 id = slave->id; in fsi_slave_handle_error()
299 dev_dbg(&slave->dev, "handling error on %s to 0x%08x[%zd]", in fsi_slave_handle_error()
303 * communication with the slave in fsi_slave_handle_error()
305 rc = fsi_slave_report_and_clear_errors(slave); in fsi_slave_handle_error()
316 rc = fsi_slave_report_and_clear_errors(slave); in fsi_slave_handle_error()
322 send_delay = slave->t_send_delay; in fsi_slave_handle_error()
323 echo_delay = slave->t_echo_delay; in fsi_slave_handle_error()
325 /* getting serious, reset the slave via BREAK */ in fsi_slave_handle_error()
330 slave->t_send_delay = send_delay; in fsi_slave_handle_error()
331 slave->t_echo_delay = echo_delay; in fsi_slave_handle_error()
333 rc = fsi_slave_set_smode(slave); in fsi_slave_handle_error()
339 slave->t_send_delay, in fsi_slave_handle_error()
340 slave->t_echo_delay); in fsi_slave_handle_error()
342 return fsi_slave_report_and_clear_errors(slave); in fsi_slave_handle_error()
345 int fsi_slave_read(struct fsi_slave *slave, uint32_t addr, in fsi_slave_read() argument
348 uint8_t id = slave->id; in fsi_slave_read()
351 rc = fsi_slave_calc_addr(slave, &addr, &id); in fsi_slave_read()
356 rc = fsi_master_read(slave->master, slave->link, in fsi_slave_read()
361 err_rc = fsi_slave_handle_error(slave, false, addr, size); in fsi_slave_read()
370 int fsi_slave_write(struct fsi_slave *slave, uint32_t addr, in fsi_slave_write() argument
373 uint8_t id = slave->id; in fsi_slave_write()
376 rc = fsi_slave_calc_addr(slave, &addr, &id); in fsi_slave_write()
381 rc = fsi_master_write(slave->master, slave->link, in fsi_slave_write()
386 err_rc = fsi_slave_handle_error(slave, true, addr, size); in fsi_slave_write()
395 int fsi_slave_claim_range(struct fsi_slave *slave, in fsi_slave_claim_range() argument
401 if (addr + size > slave->size) in fsi_slave_claim_range()
409 void fsi_slave_release_range(struct fsi_slave *slave, in fsi_slave_release_range() argument
445 /* Find a matching node for the slave engine at @address, using @size bytes
453 parent = dev_of_node(&dev->slave->dev); in fsi_device_find_of_node()
466 static int fsi_slave_scan(struct fsi_slave *slave) in fsi_slave_scan() argument
474 * We keep the peek mode and slave engines for the core; so start in fsi_slave_scan()
485 rc = fsi_slave_read(slave, (i + 1) * sizeof(data), in fsi_slave_scan()
488 dev_warn(&slave->dev, in fsi_slave_scan()
489 "error reading slave registers\n"); in fsi_slave_scan()
496 dev_warn(&slave->dev, in fsi_slave_scan()
497 "crc error in slave register at 0x%04x\n", in fsi_slave_scan()
516 dev = fsi_create_device(slave); in fsi_slave_scan()
520 dev->slave = slave; in fsi_slave_scan()
529 dev_dbg(&slave->dev, in fsi_slave_scan()
535 slave->master->idx, slave->link, in fsi_slave_scan()
536 slave->id, i - 2); in fsi_slave_scan()
541 dev_warn(&slave->dev, "add failed: %d\n", rc); in fsi_slave_scan()
584 struct fsi_slave *slave = to_fsi_slave(kobj_to_dev(kobj)); in fsi_slave_sysfs_raw_read() local
597 rc = fsi_slave_read(slave, off, buf + total_len, read_len); in fsi_slave_sysfs_raw_read()
611 struct fsi_slave *slave = to_fsi_slave(kobj_to_dev(kobj)); in fsi_slave_sysfs_raw_write() local
624 rc = fsi_slave_write(slave, off, buf + total_len, write_len); in fsi_slave_sysfs_raw_write()
646 struct fsi_slave *slave = to_fsi_slave(dev); in fsi_slave_release() local
648 fsi_free_minor(slave->dev.devt); in fsi_slave_release()
650 kfree(slave); in fsi_slave_release()
676 /* Find a matching node for the slave at (link, id). Returns NULL if none
699 struct fsi_slave *slave = filep->private_data; in cfam_read() local
716 rc = fsi_slave_read(slave, off, &data, read_len); in cfam_read()
735 struct fsi_slave *slave = filep->private_data; in cfam_write() local
758 rc = fsi_slave_write(slave, off, &data, write_len); in cfam_write()
786 struct fsi_slave *slave = container_of(inode->i_cdev, struct fsi_slave, cdev); in cfam_open() local
788 file->private_data = slave; in cfam_open()
805 struct fsi_slave *slave = to_fsi_slave(dev); in send_term_store() local
806 struct fsi_master *master = slave->master; in send_term_store()
811 master->term(master, slave->link, slave->id); in send_term_store()
821 struct fsi_slave *slave = to_fsi_slave(dev); in slave_send_echo_show() local
823 return sprintf(buf, "%u\n", slave->t_send_delay); in slave_send_echo_show()
829 struct fsi_slave *slave = to_fsi_slave(dev); in slave_send_echo_store() local
830 struct fsi_master *master = slave->master; in slave_send_echo_store()
844 slave->t_send_delay = val; in slave_send_echo_store()
845 slave->t_echo_delay = val; in slave_send_echo_store()
847 rc = fsi_slave_set_smode(slave); in slave_send_echo_store()
851 master->link_config(master, slave->link, in slave_send_echo_store()
852 slave->t_send_delay, in slave_send_echo_store()
853 slave->t_echo_delay); in slave_send_echo_store()
865 struct fsi_slave *slave = to_fsi_slave(dev); in chip_id_show() local
867 return sprintf(buf, "%d\n", slave->chip_id); in chip_id_show()
876 struct fsi_slave *slave = to_fsi_slave(dev); in cfam_id_show() local
878 return sprintf(buf, "0x%x\n", slave->cfam_id); in cfam_id_show()
903 struct fsi_slave *slave = to_fsi_slave(dev); in cfam_devnode() local
906 return kasprintf(GFP_KERNEL, "fsi/cfam%d", slave->cdev_idx); in cfam_devnode()
908 return kasprintf(GFP_KERNEL, "cfam%d", slave->cdev_idx); in cfam_devnode()
944 static int __fsi_get_new_minor(struct fsi_slave *slave, enum fsi_dev_type type, in __fsi_get_new_minor() argument
947 int cid = slave->chip_id; in __fsi_get_new_minor()
977 return __fsi_get_new_minor(fdev->slave, type, out_dev, out_index); in fsi_get_new_minor()
990 struct fsi_slave *slave; in fsi_slave_init() local
1003 dev_dbg(&master->dev, "can't read slave %02x:%02x %d\n", in fsi_slave_init()
1012 dev_warn(&master->dev, "slave %02x:%02x invalid cfam id CRC!\n", in fsi_slave_init()
1021 * clock, put the slave into async mode in fsi_slave_init()
1030 "can't set llmode on slave:%02x:%02x %d\n", in fsi_slave_init()
1034 /* We can communicate with a slave; create the slave device and in fsi_slave_init()
1037 slave = kzalloc(sizeof(*slave), GFP_KERNEL); in fsi_slave_init()
1038 if (!slave) in fsi_slave_init()
1041 dev_set_name(&slave->dev, "slave@%02x:%02x", link, id); in fsi_slave_init()
1042 slave->dev.type = &cfam_type; in fsi_slave_init()
1043 slave->dev.parent = &master->dev; in fsi_slave_init()
1044 slave->dev.of_node = fsi_slave_find_of_node(master, link, id); in fsi_slave_init()
1045 slave->dev.release = fsi_slave_release; in fsi_slave_init()
1046 device_initialize(&slave->dev); in fsi_slave_init()
1047 slave->cfam_id = cfam_id; in fsi_slave_init()
1048 slave->master = master; in fsi_slave_init()
1049 slave->link = link; in fsi_slave_init()
1050 slave->id = id; in fsi_slave_init()
1051 slave->size = FSI_SLAVE_SIZE_23b; in fsi_slave_init()
1052 slave->t_send_delay = 16; in fsi_slave_init()
1053 slave->t_echo_delay = 16; in fsi_slave_init()
1056 slave->chip_id = -1; in fsi_slave_init()
1057 if (slave->dev.of_node) { in fsi_slave_init()
1059 if (!of_property_read_u32(slave->dev.of_node, "chip-id", &prop)) in fsi_slave_init()
1060 slave->chip_id = prop; in fsi_slave_init()
1069 "can't set slbus on slave:%02x:%02x %d\n", link, id, in fsi_slave_init()
1072 rc = fsi_slave_set_smode(slave); in fsi_slave_init()
1075 "can't set smode on slave:%02x:%02x %d\n", in fsi_slave_init()
1081 rc = __fsi_get_new_minor(slave, fsi_dev_cfam, &slave->dev.devt, in fsi_slave_init()
1082 &slave->cdev_idx); in fsi_slave_init()
1086 trace_fsi_slave_init(slave); in fsi_slave_init()
1089 cdev_init(&slave->cdev, &cfam_fops); in fsi_slave_init()
1090 rc = cdev_device_add(&slave->cdev, &slave->dev); in fsi_slave_init()
1092 dev_err(&slave->dev, "Error %d creating slave device\n", rc); in fsi_slave_init()
1103 slave->t_send_delay, in fsi_slave_init()
1104 slave->t_echo_delay); in fsi_slave_init()
1107 rc = device_create_bin_file(&slave->dev, &fsi_slave_raw_attr); in fsi_slave_init()
1109 dev_warn(&slave->dev, "failed to create raw attr: %d\n", rc); in fsi_slave_init()
1112 rc = fsi_slave_scan(slave); in fsi_slave_init()
1114 dev_dbg(&master->dev, "failed during slave scan with: %d\n", in fsi_slave_init()
1120 fsi_free_minor(slave->dev.devt); in fsi_slave_init()
1122 of_node_put(slave->dev.of_node); in fsi_slave_init()
1123 kfree(slave); in fsi_slave_init()
1244 struct fsi_slave *slave = to_fsi_slave(dev); in fsi_master_remove_slave() local
1247 cdev_device_del(&slave->cdev, &slave->dev); in fsi_master_remove_slave()