Lines Matching refs:sp
157 int (*get_status)(struct rave_sp *sp, struct rave_sp_status *);
210 struct rave_sp *sp = dev_get_drvdata(dev->parent); in rave_sp_unregister_event_notifier() local
212 struct blocking_notifier_head *bnh = &sp->event_notifier_list; in rave_sp_unregister_event_notifier()
220 struct rave_sp *sp = dev_get_drvdata(dev->parent); in devm_rave_sp_register_event_notifier() local
229 ret = blocking_notifier_chain_register(&sp->event_notifier_list, nb); in devm_rave_sp_register_event_notifier()
282 static int rave_sp_write(struct rave_sp *sp, const u8 *data, u8 data_size) in rave_sp_write() argument
284 const size_t checksum_length = sp->variant->checksum->length; in rave_sp_write()
296 sp->variant->checksum->subroutine(data, data_size, crc); in rave_sp_write()
308 return serdev_device_write(sp->serdev, frame, length, HZ); in rave_sp_write()
342 int rave_sp_exec(struct rave_sp *sp, in rave_sp_exec() argument
355 command = sp->variant->cmd.translate(data[0]); in rave_sp_exec()
359 ackid = atomic_inc_return(&sp->ackid); in rave_sp_exec()
363 mutex_lock(&sp->bus_lock); in rave_sp_exec()
365 mutex_lock(&sp->reply_lock); in rave_sp_exec()
366 sp->reply = &reply; in rave_sp_exec()
367 mutex_unlock(&sp->reply_lock); in rave_sp_exec()
372 rave_sp_write(sp, data, data_size); in rave_sp_exec()
375 dev_err(&sp->serdev->dev, "Command timeout\n"); in rave_sp_exec()
378 mutex_lock(&sp->reply_lock); in rave_sp_exec()
379 sp->reply = NULL; in rave_sp_exec()
380 mutex_unlock(&sp->reply_lock); in rave_sp_exec()
383 mutex_unlock(&sp->bus_lock); in rave_sp_exec()
388 static void rave_sp_receive_event(struct rave_sp *sp, in rave_sp_receive_event() argument
396 rave_sp_write(sp, cmd, sizeof(cmd)); in rave_sp_receive_event()
398 blocking_notifier_call_chain(&sp->event_notifier_list, in rave_sp_receive_event()
403 static void rave_sp_receive_reply(struct rave_sp *sp, in rave_sp_receive_reply() argument
406 struct device *dev = &sp->serdev->dev; in rave_sp_receive_reply()
410 mutex_lock(&sp->reply_lock); in rave_sp_receive_reply()
411 reply = sp->reply; in rave_sp_receive_reply()
422 sp->reply = NULL; in rave_sp_receive_reply()
434 mutex_unlock(&sp->reply_lock); in rave_sp_receive_reply()
437 static void rave_sp_receive_frame(struct rave_sp *sp, in rave_sp_receive_frame() argument
441 const size_t checksum_length = sp->variant->checksum->length; in rave_sp_receive_frame()
444 struct device *dev = &sp->serdev->dev; in rave_sp_receive_frame()
460 sp->variant->checksum->subroutine(data, payload_length, in rave_sp_receive_frame()
469 rave_sp_receive_event(sp, data, length); in rave_sp_receive_frame()
471 rave_sp_receive_reply(sp, data, length); in rave_sp_receive_frame()
478 struct rave_sp *sp = dev_get_drvdata(dev); in rave_sp_receive_buf() local
479 struct rave_sp_deframer *deframer = &sp->deframer; in rave_sp_receive_buf()
498 rave_sp_receive_frame(sp, in rave_sp_receive_buf()
664 static int rave_sp_rdu1_get_status(struct rave_sp *sp, in rave_sp_rdu1_get_status() argument
672 return rave_sp_exec(sp, cmd, sizeof(cmd), status, sizeof(*status)); in rave_sp_rdu1_get_status()
675 static int rave_sp_emulated_get_status(struct rave_sp *sp, in rave_sp_emulated_get_status() argument
684 ret = rave_sp_exec(sp, cmd, sizeof(cmd), &status->firmware_version, in rave_sp_emulated_get_status()
690 return rave_sp_exec(sp, cmd, sizeof(cmd), &status->bootloader_version, in rave_sp_emulated_get_status()
694 static int rave_sp_get_status(struct rave_sp *sp) in rave_sp_get_status() argument
696 struct device *dev = &sp->serdev->dev; in rave_sp_get_status()
701 ret = sp->variant->cmd.get_status(sp, &status); in rave_sp_get_status()
709 sp->part_number_firmware = version; in rave_sp_get_status()
715 sp->part_number_bootloader = version; in rave_sp_get_status()
772 struct rave_sp *sp; in rave_sp_probe() local
782 sp = devm_kzalloc(dev, sizeof(*sp), GFP_KERNEL); in rave_sp_probe()
783 if (!sp) in rave_sp_probe()
786 sp->serdev = serdev; in rave_sp_probe()
787 dev_set_drvdata(dev, sp); in rave_sp_probe()
789 sp->variant = of_device_get_match_data(dev); in rave_sp_probe()
790 if (!sp->variant) in rave_sp_probe()
793 mutex_init(&sp->bus_lock); in rave_sp_probe()
794 mutex_init(&sp->reply_lock); in rave_sp_probe()
795 BLOCKING_INIT_NOTIFIER_HEAD(&sp->event_notifier_list); in rave_sp_probe()
811 ret = rave_sp_get_status(sp); in rave_sp_probe()
814 sp->part_number_firmware = unknown; in rave_sp_probe()
815 sp->part_number_bootloader = unknown; in rave_sp_probe()
822 dev_info(dev, "Firmware version: %s", sp->part_number_firmware); in rave_sp_probe()
823 dev_info(dev, "Bootloader version: %s", sp->part_number_bootloader); in rave_sp_probe()