Lines Matching refs:occ
42 struct occ { struct
58 #define to_occ(x) container_of((x), struct occ, mdev) argument
69 struct occ *occ; member
84 struct occ *occ = to_occ(mdev); in occ_open() local
95 client->occ = occ; in occ_open()
98 get_device(occ->dev); in occ_open()
180 rc = fsi_occ_submit(client->occ->dev, cmd, data_length + 6, cmd, in occ_write()
202 put_device(client->occ->dev); in occ_release()
217 static void occ_save_ffdc(struct occ *occ, __be32 *resp, size_t parsed_len, in occ_save_ffdc() argument
225 if (ffdc_len > occ->client_buffer_size) in occ_save_ffdc()
226 ffdc_len = occ->client_buffer_size; in occ_save_ffdc()
228 memcpy(occ->client_buffer, ffdc, ffdc_len); in occ_save_ffdc()
229 occ->client_response_size = ffdc_len; in occ_save_ffdc()
233 static int occ_verify_checksum(struct occ *occ, struct occ_response *resp, in occ_verify_checksum() argument
250 dev_err(occ->dev, "Bad checksum: %04x!=%04x\n", checksum, in occ_verify_checksum()
258 static int occ_getsram(struct occ *occ, u32 offset, void *data, ssize_t len) in occ_getsram() argument
263 __be32 *resp = occ->buffer; in occ_getsram()
271 switch (occ->version) { in occ_getsram()
291 rc = sbefifo_submit(occ->sbefifo, cmd, cmd_len, resp, &resp_len); in occ_getsram()
295 rc = sbefifo_parse_status(occ->sbefifo, SBEFIFO_CMD_GET_OCC_SRAM, in occ_getsram()
298 dev_err(occ->dev, "SRAM read returned failure status: %08x\n", in occ_getsram()
300 occ_save_ffdc(occ, resp, parsed_len, resp_len); in occ_getsram()
308 dev_err(occ->dev, "SRAM read expected %d bytes got %zd\n", in occ_getsram()
318 static int occ_putsram(struct occ *occ, const void *data, ssize_t len, in occ_putsram() argument
324 __be32 *buf = occ->buffer; in occ_putsram()
328 cmd_len = (occ->version == occ_p10) ? 6 : 5; in occ_putsram()
338 switch (occ->version) { in occ_putsram()
364 rc = sbefifo_submit(occ->sbefifo, buf, cmd_len, buf, &resp_len); in occ_putsram()
368 rc = sbefifo_parse_status(occ->sbefifo, SBEFIFO_CMD_PUT_OCC_SRAM, in occ_putsram()
371 dev_err(occ->dev, "SRAM write returned failure status: %08x\n", in occ_putsram()
373 occ_save_ffdc(occ, buf, parsed_len, resp_len); in occ_putsram()
380 dev_err(occ->dev, "SRAM write response length invalid: %zd\n", in occ_putsram()
386 dev_err(occ->dev, in occ_putsram()
396 static int occ_trigger_attn(struct occ *occ) in occ_trigger_attn() argument
398 __be32 *buf = occ->buffer; in occ_trigger_attn()
403 switch (occ->version) { in occ_trigger_attn()
425 rc = sbefifo_submit(occ->sbefifo, buf, cmd_len, buf, &resp_len); in occ_trigger_attn()
429 rc = sbefifo_parse_status(occ->sbefifo, SBEFIFO_CMD_PUT_OCC_SRAM, in occ_trigger_attn()
432 dev_err(occ->dev, "SRAM attn returned failure status: %08x\n", in occ_trigger_attn()
434 occ_save_ffdc(occ, buf, parsed_len, resp_len); in occ_trigger_attn()
441 dev_err(occ->dev, "SRAM attn response length invalid: %zd\n", in occ_trigger_attn()
447 dev_err(occ->dev, in occ_trigger_attn()
471 struct occ *occ = dev_get_drvdata(dev); in fsi_occ_submit() local
485 if (!occ) in fsi_occ_submit()
499 rc = mutex_lock_interruptible(&occ->occ_lock); in fsi_occ_submit()
503 occ->client_buffer = response; in fsi_occ_submit()
504 occ->client_buffer_size = user_resp_len; in fsi_occ_submit()
505 occ->client_response_size = 0; in fsi_occ_submit()
507 if (!occ->buffer) { in fsi_occ_submit()
520 seq_no = occ->sequence_number++; in fsi_occ_submit()
521 if (!occ->sequence_number) in fsi_occ_submit()
522 occ->sequence_number = 1; in fsi_occ_submit()
525 rc = occ_putsram(occ, request, req_len, seq_no, checksum); in fsi_occ_submit()
529 rc = occ_trigger_attn(occ); in fsi_occ_submit()
536 rc = occ_getsram(occ, 0, resp, 8); in fsi_occ_submit()
542 dev_err(occ->dev, in fsi_occ_submit()
571 rc = occ_getsram(occ, 0, resp, in fsi_occ_submit()
588 rc = occ_verify_checksum(occ, resp, resp_data_length); in fsi_occ_submit()
592 occ->client_response_size = resp_data_length + 7; in fsi_occ_submit()
595 *resp_len = occ->client_response_size; in fsi_occ_submit()
596 mutex_unlock(&occ->occ_lock); in fsi_occ_submit()
627 struct occ *occ; in occ_probe() local
636 occ = devm_kzalloc(dev, sizeof(*occ), GFP_KERNEL); in occ_probe()
637 if (!occ) in occ_probe()
641 occ->buffer = kvmalloc(OCC_MAX_RESP_WORDS * 4, GFP_KERNEL); in occ_probe()
642 if (!occ->buffer) in occ_probe()
645 occ->version = (uintptr_t)of_device_get_match_data(dev); in occ_probe()
646 occ->dev = dev; in occ_probe()
647 occ->sbefifo = dev->parent; in occ_probe()
652 occ->sequence_number = (u8)((jiffies % 0xff) + 1); in occ_probe()
653 mutex_init(&occ->occ_lock); in occ_probe()
659 occ->idx = ida_simple_get(&occ_ida, reg, reg + 1, in occ_probe()
661 if (occ->idx < 0) in occ_probe()
662 occ->idx = ida_simple_get(&occ_ida, 1, INT_MAX, in occ_probe()
665 occ->idx = ida_simple_get(&occ_ida, 1, INT_MAX, in occ_probe()
669 occ->idx = ida_simple_get(&occ_ida, 1, INT_MAX, GFP_KERNEL); in occ_probe()
672 platform_set_drvdata(pdev, occ); in occ_probe()
674 snprintf(occ->name, sizeof(occ->name), "occ%d", occ->idx); in occ_probe()
675 occ->mdev.fops = &occ_fops; in occ_probe()
676 occ->mdev.minor = MISC_DYNAMIC_MINOR; in occ_probe()
677 occ->mdev.name = occ->name; in occ_probe()
678 occ->mdev.parent = dev; in occ_probe()
680 rc = misc_register(&occ->mdev); in occ_probe()
683 ida_simple_remove(&occ_ida, occ->idx); in occ_probe()
684 kvfree(occ->buffer); in occ_probe()
690 snprintf(child_name, sizeof(child_name), "%s.%d", hwmon_dev_info.name, occ->idx); in occ_probe()
696 occ->platform_hwmon = true; in occ_probe()
697 hwmon_dev_info.id = occ->idx; in occ_probe()
708 struct occ *occ = platform_get_drvdata(pdev); in occ_remove() local
710 misc_deregister(&occ->mdev); in occ_remove()
712 mutex_lock(&occ->occ_lock); in occ_remove()
713 kvfree(occ->buffer); in occ_remove()
714 occ->buffer = NULL; in occ_remove()
715 mutex_unlock(&occ->occ_lock); in occ_remove()
717 if (occ->platform_hwmon) in occ_remove()
722 ida_simple_remove(&occ_ida, occ->idx); in occ_remove()