int rproc_load(int id, ulong addr, ulong size) { struct udevice *dev = NULL; struct dm_rproc_uclass_pdata *uc_pdata; const struct dm_rproc_ops *ops; int ret; ret = uclass_get_device_by_seq(UCLASS_REMOTEPROC, id, &dev); if (ret) { debug("Unknown remote processor id '%d' requested(%d)\n", id, ret); return ret; } uc_pdata = dev_get_uclass_platdata(dev); ops = rproc_get_ops(dev); if (!ops) { debug("%s driver has no ops?\n", dev->name); return -EINVAL; } debug("Loading to '%s' from address 0x%08lX size of %lu bytes\n", uc_pdata->name, addr, size); if (ops->load) return ops->load(dev, addr, size); debug("%s: data corruption?? mandatory function is missing!\n", dev->name); return -EINVAL; };
/** * rproc_post_probe() - post probe accessor for the uclass * @dev: deivce we finished probing * * initiate init function after the probe is completed. This allows * the remote processor drivers to split up the initializations between * probe and init as needed. * * Return: if the remote proc driver has a init routine, invokes it and * hands over the return value. overall, 0 if all went well, else appropriate * error value. */ static int rproc_post_probe(struct udevice *dev) { const struct dm_rproc_ops *ops; ops = rproc_get_ops(dev); if (!ops) { debug("%s driver has no ops?\n", dev->name); return -EINVAL; } if (ops->init) return ops->init(dev); return 0; }
/** * print_remoteproc_list() - print all the remote processor devices * * Return: 0 if no error, else returns appropriate error value. */ static int print_remoteproc_list(void) { struct udevice *dev; struct uclass *uc; int ret; char *type; ret = uclass_get(UCLASS_REMOTEPROC, &uc); if (ret) { printf("Cannot find Remote processor class\n"); return ret; } uclass_foreach_dev(dev, uc) { struct dm_rproc_uclass_pdata *uc_pdata; const struct dm_rproc_ops *ops = rproc_get_ops(dev); uc_pdata = dev_get_uclass_platdata(dev); switch (uc_pdata->mem_type) { case RPROC_INTERNAL_MEMORY_MAPPED: type = "internal memory mapped"; break; default: type = "unknown"; break; } printf("%d - Name:'%s' type:'%s' supports: %s%s%s%s%s%s\n", dev->seq, uc_pdata->name, type, ops->load ? "load " : "", ops->start ? "start " : "", ops->stop ? "stop " : "", ops->reset ? "reset " : "", ops->is_running ? "is_running " : "", ops->ping ? "ping " : ""); } return 0; }
/** * _rproc_ops_wrapper() - wrapper for invoking remote proc driver callback * @id: id of the remote processor * @op: one of rproc_ops that indicate what operation to invoke * * Most of the checks and verification for remoteproc operations are more * or less same for almost all operations. This allows us to put a wrapper * and use the common checks to allow the driver to function appropriately. * * Return: 0 if all ok, else appropriate error value. */ static int _rproc_ops_wrapper(int id, enum rproc_ops op) { struct udevice *dev = NULL; struct dm_rproc_uclass_pdata *uc_pdata; const struct dm_rproc_ops *ops; int (*fn)(struct udevice *dev); bool mandatory = false; char *op_str; int ret; ret = uclass_get_device_by_seq(UCLASS_REMOTEPROC, id, &dev); if (ret) { debug("Unknown remote processor id '%d' requested(%d)\n", id, ret); return ret; } uc_pdata = dev_get_uclass_platdata(dev); ops = rproc_get_ops(dev); if (!ops) { debug("%s driver has no ops?\n", dev->name); return -EINVAL; } switch (op) { case RPROC_START: fn = ops->start; mandatory = true; op_str = "Starting"; break; case RPROC_STOP: fn = ops->stop; op_str = "Stopping"; break; case RPROC_RESET: fn = ops->reset; op_str = "Resetting"; break; case RPROC_RUNNING: fn = ops->is_running; op_str = "Checking if running:"; break; case RPROC_PING: fn = ops->ping; op_str = "Pinging"; break; default: debug("what is '%d' operation??\n", op); return -EINVAL; } debug("%s %s...\n", op_str, uc_pdata->name); if (fn) return fn(dev); if (mandatory) debug("%s: data corruption?? mandatory function is missing!\n", dev->name); return -ENOSYS; }
/** * rproc_pre_probe() - Pre probe accessor for the uclass * @dev: device for which we are preprobing * * Parses and fills up the uclass pdata for use as needed by core and * remote proc drivers. * * Return: 0 if all wernt ok, else appropriate error value. */ static int rproc_pre_probe(struct udevice *dev) { struct dm_rproc_uclass_pdata *uc_pdata; const struct dm_rproc_ops *ops; uc_pdata = dev_get_uclass_platdata(dev); /* See if we need to populate via fdt */ if (!dev->platdata) { #if CONFIG_IS_ENABLED(OF_CONTROL) int node = dev->of_offset; const void *blob = gd->fdt_blob; bool tmp; if (!blob) { debug("'%s' no dt?\n", dev->name); return -EINVAL; } debug("'%s': using fdt\n", dev->name); uc_pdata->name = fdt_getprop(blob, node, "remoteproc-name", NULL); /* Default is internal memory mapped */ uc_pdata->mem_type = RPROC_INTERNAL_MEMORY_MAPPED; tmp = fdtdec_get_bool(blob, node, "remoteproc-internal-memory-mapped"); if (tmp) uc_pdata->mem_type = RPROC_INTERNAL_MEMORY_MAPPED; #else /* Nothing much we can do about this, can we? */ return -EINVAL; #endif } else { struct dm_rproc_uclass_pdata *pdata = dev->platdata; debug("'%s': using legacy data\n", dev->name); if (pdata->name) uc_pdata->name = pdata->name; uc_pdata->mem_type = pdata->mem_type; uc_pdata->driver_plat_data = pdata->driver_plat_data; } /* Else try using device Name */ if (!uc_pdata->name) uc_pdata->name = dev->name; if (!uc_pdata->name) { debug("Unnamed device!"); return -EINVAL; } if (!rproc_name_is_unique(dev, uc_pdata->name)) { debug("%s duplicate name '%s'\n", dev->name, uc_pdata->name); return -EINVAL; } ops = rproc_get_ops(dev); if (!ops) { debug("%s driver has no ops?\n", dev->name); return -EINVAL; } if (!ops->load || !ops->start) { debug("%s driver has missing mandatory ops?\n", dev->name); return -EINVAL; } return 0; }