xref: /rk3399_rockchip-uboot/arch/arm/mach-bcm283x/msg.c (revision 70997d88c40b4d74c4eac80c85f3a2676aa15d82)
1 /*
2  * (C) Copyright 2012 Stephen Warren
3  *
4  * SPDX-License-Identifier:	GPL-2.0+
5  */
6 
7 #include <common.h>
8 #include <memalign.h>
9 #include <asm/arch/mbox.h>
10 
11 struct msg_set_power_state {
12 	struct bcm2835_mbox_hdr hdr;
13 	struct bcm2835_mbox_tag_set_power_state set_power_state;
14 	u32 end_tag;
15 };
16 
17 int bcm2835_power_on_module(u32 module)
18 {
19 	ALLOC_CACHE_ALIGN_BUFFER(struct msg_set_power_state, msg_pwr, 1);
20 	int ret;
21 
22 	BCM2835_MBOX_INIT_HDR(msg_pwr);
23 	BCM2835_MBOX_INIT_TAG(&msg_pwr->set_power_state,
24 			      SET_POWER_STATE);
25 	msg_pwr->set_power_state.body.req.device_id = module;
26 	msg_pwr->set_power_state.body.req.state =
27 		BCM2835_MBOX_SET_POWER_STATE_REQ_ON |
28 		BCM2835_MBOX_SET_POWER_STATE_REQ_WAIT;
29 
30 	ret = bcm2835_mbox_call_prop(BCM2835_MBOX_PROP_CHAN,
31 				     &msg_pwr->hdr);
32 	if (ret) {
33 		printf("bcm2835: Could not set module %u power state\n",
34 		       module);
35 		return -EIO;
36 	}
37 
38 	return 0;
39 }
40