Lines Matching refs:sbefifo
119 struct sbefifo { struct
135 struct sbefifo *sbefifo; argument
149 struct sbefifo *sbefifo = container_of(dev, struct sbefifo, dev); in timeout_show() local
151 return sysfs_emit(buf, "%d\n", sbefifo->timed_out ? 1 : 0); in timeout_show()
264 static int sbefifo_regr(struct sbefifo *sbefifo, int reg, u32 *word) in sbefifo_regr() argument
269 rc = fsi_device_read(sbefifo->fsi_dev, reg, &raw_word, in sbefifo_regr()
279 static int sbefifo_regw(struct sbefifo *sbefifo, int reg, u32 word) in sbefifo_regw() argument
283 return fsi_device_write(sbefifo->fsi_dev, reg, &raw_word, in sbefifo_regw()
287 static int sbefifo_check_sbe_state(struct sbefifo *sbefifo) in sbefifo_check_sbe_state() argument
293 rc = fsi_slave_read(sbefifo->fsi_dev->slave, CFAM_GP_MBOX_SBM_ADDR, in sbefifo_check_sbe_state()
322 sbefifo->async_ffdc = true; in sbefifo_check_sbe_state()
328 static int sbefifo_down_read(struct sbefifo *sbefifo, __be32 *word) in sbefifo_down_read() argument
330 return fsi_device_read(sbefifo->fsi_dev, SBEFIFO_DOWN, word, in sbefifo_down_read()
334 static int sbefifo_up_write(struct sbefifo *sbefifo, __be32 word) in sbefifo_up_write() argument
336 return fsi_device_write(sbefifo->fsi_dev, SBEFIFO_UP, &word, in sbefifo_up_write()
340 static int sbefifo_request_reset(struct sbefifo *sbefifo) in sbefifo_request_reset() argument
342 struct device *dev = &sbefifo->fsi_dev->dev; in sbefifo_request_reset()
350 sbefifo->broken = true; in sbefifo_request_reset()
353 rc = sbefifo_regw(sbefifo, SBEFIFO_UP | SBEFIFO_REQ_RESET, 1); in sbefifo_request_reset()
362 rc = sbefifo_regr(sbefifo, SBEFIFO_UP | SBEFIFO_STS, &status); in sbefifo_request_reset()
371 sbefifo->broken = false; in sbefifo_request_reset()
382 static int sbefifo_cleanup_hw(struct sbefifo *sbefifo) in sbefifo_cleanup_hw() argument
384 struct device *dev = &sbefifo->fsi_dev->dev; in sbefifo_cleanup_hw()
389 rc = sbefifo_check_sbe_state(sbefifo); in sbefifo_cleanup_hw()
396 if (sbefifo->broken) in sbefifo_cleanup_hw()
399 rc = sbefifo_regr(sbefifo, SBEFIFO_UP | SBEFIFO_STS, &up_status); in sbefifo_cleanup_hw()
404 sbefifo->broken = true; in sbefifo_cleanup_hw()
408 rc = sbefifo_regr(sbefifo, SBEFIFO_DOWN | SBEFIFO_STS, &down_status); in sbefifo_cleanup_hw()
413 sbefifo->broken = true; in sbefifo_cleanup_hw()
420 rc = sbefifo_regw(sbefifo, SBEFIFO_DOWN, SBEFIFO_PERFORM_RESET); in sbefifo_cleanup_hw()
422 sbefifo->broken = true; in sbefifo_cleanup_hw()
426 sbefifo->broken = false; in sbefifo_cleanup_hw()
447 return sbefifo_request_reset(sbefifo); in sbefifo_cleanup_hw()
450 static int sbefifo_wait(struct sbefifo *sbefifo, bool up, in sbefifo_wait() argument
453 struct device *dev = &sbefifo->fsi_dev->dev; in sbefifo_wait()
466 rc = sbefifo_regr(sbefifo, addr, &sts); in sbefifo_wait()
480 sysfs_notify(&sbefifo->dev.kobj, NULL, dev_attr_timeout.attr.name); in sbefifo_wait()
481 sbefifo->timed_out = true; in sbefifo_wait()
488 sbefifo->timed_out = false; in sbefifo_wait()
494 static int sbefifo_send_command(struct sbefifo *sbefifo, in sbefifo_send_command() argument
497 struct device *dev = &sbefifo->fsi_dev->dev; in sbefifo_send_command()
510 rc = sbefifo_wait(sbefifo, true, &status, timeout); in sbefifo_send_command()
513 timeout = msecs_to_jiffies(sbefifo->timeout_in_cmd_ms); in sbefifo_send_command()
523 rc = sbefifo_up_write(sbefifo, *(command++)); in sbefifo_send_command()
535 rc = sbefifo_wait(sbefifo, true, &status, timeout); in sbefifo_send_command()
541 rc = sbefifo_regw(sbefifo, SBEFIFO_UP | SBEFIFO_EOT_RAISE, 0); in sbefifo_send_command()
547 static int sbefifo_read_response(struct sbefifo *sbefifo, struct iov_iter *response) in sbefifo_read_response() argument
549 struct device *dev = &sbefifo->fsi_dev->dev; in sbefifo_read_response()
559 timeout = msecs_to_jiffies(sbefifo->timeout_start_rsp_ms); in sbefifo_read_response()
562 rc = sbefifo_wait(sbefifo, false, &status, timeout); in sbefifo_read_response()
578 rc = sbefifo_down_read(sbefifo, &data); in sbefifo_read_response()
594 sbefifo->broken = true; in sbefifo_read_response()
598 rc = sbefifo_regw(sbefifo, in sbefifo_read_response()
608 sbefifo->broken = true; in sbefifo_read_response()
633 static int sbefifo_do_command(struct sbefifo *sbefifo, in sbefifo_do_command() argument
638 int rc = sbefifo_send_command(sbefifo, command, cmd_len); in sbefifo_do_command()
643 return sbefifo_read_response(sbefifo, response); in sbefifo_do_command()
646 static void sbefifo_collect_async_ffdc(struct sbefifo *sbefifo) in sbefifo_collect_async_ffdc() argument
648 struct device *dev = &sbefifo->fsi_dev->dev; in sbefifo_collect_async_ffdc()
656 sbefifo->async_ffdc = false; in sbefifo_collect_async_ffdc()
667 rc = sbefifo_do_command(sbefifo, cmd, 2, &ffdc_iter); in sbefifo_collect_async_ffdc()
687 static int __sbefifo_submit(struct sbefifo *sbefifo, in __sbefifo_submit() argument
691 struct device *dev = &sbefifo->fsi_dev->dev; in __sbefifo_submit()
694 if (sbefifo->dead) in __sbefifo_submit()
704 rc = sbefifo_cleanup_hw(sbefifo); in __sbefifo_submit()
709 if (sbefifo->async_ffdc) in __sbefifo_submit()
710 sbefifo_collect_async_ffdc(sbefifo); in __sbefifo_submit()
712 rc = sbefifo_do_command(sbefifo, command, cmd_len, response); in __sbefifo_submit()
721 sbefifo_request_reset(sbefifo); in __sbefifo_submit()
741 struct sbefifo *sbefifo; in sbefifo_submit() local
749 sbefifo = dev_get_drvdata(dev); in sbefifo_submit()
750 if (!sbefifo) in sbefifo_submit()
752 if (WARN_ON_ONCE(sbefifo->magic != SBEFIFO_MAGIC)) in sbefifo_submit()
764 rc = mutex_lock_interruptible(&sbefifo->lock); in sbefifo_submit()
767 rc = __sbefifo_submit(sbefifo, command, cmd_len, &resp_iter); in sbefifo_submit()
768 mutex_unlock(&sbefifo->lock); in sbefifo_submit()
792 struct sbefifo *sbefifo = container_of(inode->i_cdev, struct sbefifo, cdev); in sbefifo_user_open() local
800 user->sbefifo = sbefifo; in sbefifo_user_open()
817 struct sbefifo *sbefifo; in sbefifo_user_read() local
825 sbefifo = user->sbefifo; in sbefifo_user_read()
848 rc = mutex_lock_interruptible(&sbefifo->lock); in sbefifo_user_read()
851 sbefifo->timeout_in_cmd_ms = user->cmd_timeout_ms; in sbefifo_user_read()
852 sbefifo->timeout_start_rsp_ms = user->read_timeout_ms; in sbefifo_user_read()
853 rc = __sbefifo_submit(sbefifo, user->pending_cmd, cmd_len, &resp_iter); in sbefifo_user_read()
854 sbefifo->timeout_start_rsp_ms = SBEFIFO_TIMEOUT_START_RSP; in sbefifo_user_read()
855 sbefifo->timeout_in_cmd_ms = SBEFIFO_TIMEOUT_IN_CMD; in sbefifo_user_read()
856 mutex_unlock(&sbefifo->lock); in sbefifo_user_read()
872 struct sbefifo *sbefifo; in sbefifo_user_write() local
877 sbefifo = user->sbefifo; in sbefifo_user_write()
909 rc = mutex_lock_interruptible(&sbefifo->lock); in sbefifo_user_write()
912 rc = sbefifo_request_reset(user->sbefifo); in sbefifo_user_write()
913 mutex_unlock(&sbefifo->lock); in sbefifo_user_write()
947 struct device *dev = &user->sbefifo->dev; in sbefifo_cmd_timeout()
966 struct device *dev = &user->sbefifo->dev; in sbefifo_read_timeout()
1015 struct sbefifo *sbefifo = container_of(dev, struct sbefifo, dev); in sbefifo_free() local
1017 put_device(&sbefifo->fsi_dev->dev); in sbefifo_free()
1018 kfree(sbefifo); in sbefifo_free()
1028 struct sbefifo *sbefifo; in sbefifo_probe() local
1036 sbefifo = kzalloc(sizeof(*sbefifo), GFP_KERNEL); in sbefifo_probe()
1037 if (!sbefifo) in sbefifo_probe()
1042 kfree(sbefifo); in sbefifo_probe()
1046 sbefifo->magic = SBEFIFO_MAGIC; in sbefifo_probe()
1047 sbefifo->fsi_dev = fsi_dev; in sbefifo_probe()
1048 dev_set_drvdata(dev, sbefifo); in sbefifo_probe()
1049 mutex_init(&sbefifo->lock); in sbefifo_probe()
1050 sbefifo->timeout_in_cmd_ms = SBEFIFO_TIMEOUT_IN_CMD; in sbefifo_probe()
1051 sbefifo->timeout_start_rsp_ms = SBEFIFO_TIMEOUT_START_RSP; in sbefifo_probe()
1054 sbefifo->dev.type = &fsi_cdev_type; in sbefifo_probe()
1055 sbefifo->dev.parent = dev; in sbefifo_probe()
1056 sbefifo->dev.release = sbefifo_free; in sbefifo_probe()
1057 device_initialize(&sbefifo->dev); in sbefifo_probe()
1060 rc = fsi_get_new_minor(fsi_dev, fsi_dev_sbefifo, &sbefifo->dev.devt, &didx); in sbefifo_probe()
1064 dev_set_name(&sbefifo->dev, "sbefifo%d", didx); in sbefifo_probe()
1065 cdev_init(&sbefifo->cdev, &sbefifo_fops); in sbefifo_probe()
1066 rc = cdev_device_add(&sbefifo->cdev, &sbefifo->dev); in sbefifo_probe()
1069 rc, dev_name(&sbefifo->dev)); in sbefifo_probe()
1076 dev_name(&sbefifo->dev), child_idx++); in sbefifo_probe()
1083 device_create_file(&sbefifo->dev, &dev_attr_timeout); in sbefifo_probe()
1087 fsi_free_minor(sbefifo->dev.devt); in sbefifo_probe()
1089 put_device(&sbefifo->dev); in sbefifo_probe()
1106 struct sbefifo *sbefifo = dev_get_drvdata(dev); in sbefifo_remove() local
1110 device_remove_file(&sbefifo->dev, &dev_attr_timeout); in sbefifo_remove()
1112 mutex_lock(&sbefifo->lock); in sbefifo_remove()
1113 sbefifo->dead = true; in sbefifo_remove()
1114 mutex_unlock(&sbefifo->lock); in sbefifo_remove()
1116 cdev_device_del(&sbefifo->cdev, &sbefifo->dev); in sbefifo_remove()
1117 fsi_free_minor(sbefifo->dev.devt); in sbefifo_remove()
1119 put_device(&sbefifo->dev); in sbefifo_remove()