Lines Matching refs:occ

15 #include <linux/fsi-occ.h>
40 struct occ {
49 #define to_occ(x) container_of((x), struct occ, mdev)
60 struct occ *occ;
75 struct occ *occ = to_occ(mdev);
86 client->occ = occ;
154 * Copy the user command (assume user data follows the occ command
181 rc = fsi_occ_submit(client->occ->dev, cmd, data_length + 6, cmd,
238 static int occ_getsram(struct occ *occ, u32 address, void *data, ssize_t len)
260 rc = sbefifo_submit(occ->sbefifo, cmd, 5, resp, &resp_len);
264 rc = sbefifo_parse_status(occ->sbefifo, SBEFIFO_CMD_GET_OCC_SRAM,
271 dev_err(occ->dev, "SRAM read expected %d bytes got %zd\n",
281 dev_err(occ->dev, "SRAM read returned failure status: %08x\n",
290 static int occ_putsram(struct occ *occ, u32 address, const void *data,
321 rc = sbefifo_submit(occ->sbefifo, buf, cmd_len, buf, &resp_len);
325 rc = sbefifo_parse_status(occ->sbefifo, SBEFIFO_CMD_PUT_OCC_SRAM,
331 dev_err(occ->dev, "SRAM write response length invalid: %zd\n",
337 dev_err(occ->dev,
347 dev_err(occ->dev, "SRAM write returned failure status: %08x\n",
356 static int occ_trigger_attn(struct occ *occ)
373 rc = sbefifo_submit(occ->sbefifo, buf, 7, buf, &resp_len);
377 rc = sbefifo_parse_status(occ->sbefifo, SBEFIFO_CMD_PUT_OCC_SRAM,
383 dev_err(occ->dev, "SRAM attn response length invalid: %zd\n",
389 dev_err(occ->dev,
399 dev_err(occ->dev, "SRAM attn returned failure status: %08x\n",
413 struct occ *occ = dev_get_drvdata(dev);
420 if (!occ)
428 mutex_lock(&occ->occ_lock);
432 rc = occ_putsram(occ, OCC_SRAM_CMD_ADDR, request, req_len);
436 rc = occ_trigger_attn(occ);
440 /* Read occ response header */
443 rc = occ_getsram(occ, OCC_SRAM_RSP_ADDR, resp, 8);
453 dev_err(occ->dev, "resp timeout status=%02x "
480 rc = occ_getsram(occ, OCC_SRAM_RSP_ADDR + 8,
490 mutex_unlock(&occ->occ_lock);
509 struct occ *occ;
514 .name = "occ-hwmon",
517 occ = devm_kzalloc(dev, sizeof(*occ), GFP_KERNEL);
518 if (!occ)
521 occ->dev = dev;
522 occ->sbefifo = dev->parent;
523 mutex_init(&occ->occ_lock);
529 occ->idx = ida_simple_get(&occ_ida, reg, reg + 1,
531 if (occ->idx < 0)
532 occ->idx = ida_simple_get(&occ_ida, 1, INT_MAX,
535 occ->idx = ida_simple_get(&occ_ida, 1, INT_MAX,
539 occ->idx = ida_simple_get(&occ_ida, 1, INT_MAX, GFP_KERNEL);
542 platform_set_drvdata(pdev, occ);
544 snprintf(occ->name, sizeof(occ->name), "occ%d", occ->idx);
545 occ->mdev.fops = &occ_fops;
546 occ->mdev.minor = MISC_DYNAMIC_MINOR;
547 occ->mdev.name = occ->name;
548 occ->mdev.parent = dev;
550 rc = misc_register(&occ->mdev);
553 ida_simple_remove(&occ_ida, occ->idx);
557 hwmon_dev_info.id = occ->idx;
567 struct occ *occ = platform_get_drvdata(pdev);
569 misc_deregister(&occ->mdev);
573 ida_simple_remove(&occ_ida, occ->idx);
579 { .compatible = "ibm,p9-occ" },
586 .name = "occ",