/** * th1520_aon_call_rpc() - Send an RPC request to the TH1520 AON subsystem * @aon_chan: Pointer to the AON channel structure * @msg: Pointer to the message (RPC payload) that will be sent * * This function sends an RPC message to the TH1520 AON subsystem via mailbox. * It takes the provided @msg buffer, formats it with version and service flags, * then blocks until the RPC completes or times out. The completion is signaled * by the `aon_chan->done` completion, which is waited upon for a duration * defined by `MAX_RX_TIMEOUT`. * * Return: * * 0 on success * * -ETIMEDOUT if the RPC call times out * * A negative error code if the mailbox send fails or if AON responds with * a non-zero error code (converted via th1520_aon_to_linux_errno()).
*/ int th1520_aon_call_rpc(struct th1520_aon_chan *aon_chan, void *msg)
{ struct th1520_aon_rpc_msg_hdr *hdr = msg; int ret;
/** * th1520_aon_power_update() - Change power state of a resource via TH1520 AON * @aon_chan: Pointer to the AON channel structure * @rsrc: Resource ID whose power state needs to be updated * @power_on: Boolean indicating whether the resource should be powered on (true) * or powered off (false) * * This function requests the TH1520 AON subsystem to set the power mode of the * given resource (@rsrc) to either on or off. It constructs the message in * `struct th1520_aon_msg_req_set_resource_power_mode` and then invokes * th1520_aon_call_rpc() to make the request. If the AON call fails, an error * message is logged along with the specific return code. * * Return: * * 0 on success * * A negative error code in case of failures (propagated from * th1520_aon_call_rpc()).
*/ int th1520_aon_power_update(struct th1520_aon_chan *aon_chan, u16 rsrc, bool power_on)
{ struct th1520_aon_msg_req_set_resource_power_mode msg = {}; struct th1520_aon_rpc_msg_hdr *hdr = &msg.hdr; int ret;
ret = th1520_aon_call_rpc(aon_chan, &msg); if (ret)
dev_err(aon_chan->cl.dev, "failed to power %s resource %d ret %d\n",
power_on ? "up" : "off", rsrc, ret);
/** * th1520_aon_init() - Initialize TH1520 AON firmware protocol interface * @dev: Device pointer for the AON subsystem * * This function initializes the TH1520 AON firmware protocol interface by: * - Allocating and initializing the AON channel structure * - Setting up the mailbox client * - Requesting the AON mailbox channel * - Initializing synchronization primitives * * Return: * * Valid pointer to th1520_aon_chan structure on success * * ERR_PTR(-ENOMEM) if memory allocation fails * * ERR_PTR() with other negative error codes from mailbox operations
*/ struct th1520_aon_chan *th1520_aon_init(struct device *dev)
{ struct th1520_aon_chan *aon_chan; struct mbox_client *cl; int ret;
aon_chan = kzalloc(sizeof(*aon_chan), GFP_KERNEL); if (!aon_chan) return ERR_PTR(-ENOMEM);
/** * th1520_aon_deinit() - Clean up TH1520 AON firmware protocol interface * @aon_chan: Pointer to the AON channel structure to clean up * * This function cleans up resources allocated by th1520_aon_init(): * - Frees the mailbox channel * - Frees the AON channel
*/ void th1520_aon_deinit(struct th1520_aon_chan *aon_chan)
{
mbox_free_channel(aon_chan->ch);
kfree(aon_chan);
}
EXPORT_SYMBOL_GPL(th1520_aon_deinit);
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.