• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2018-2019, ARM Limited and Contributors. All rights reserved.
3  *
4  * SPDX-License-Identifier: BSD-3-Clause
5  */
6 
7 #include <assert.h>
8 
9 #include <platform_def.h>
10 
11 #include <arch_helpers.h>
12 
13 #include <drivers/rpi3/mailbox/rpi3_mbox.h>
14 
15 #define RPI3_MBOX_BUFFER_SIZE		U(256)
16 static uint8_t __aligned(16) rpi3_mbox_buffer[RPI3_MBOX_BUFFER_SIZE];
17 
18 /*******************************************************************************
19  * Request board revision. Returns the revision and 0 on success, -1 on error.
20  ******************************************************************************/
rpi3_vc_hardware_get_board_revision(uint32_t * revision)21 int rpi3_vc_hardware_get_board_revision(uint32_t *revision)
22 {
23 	uint32_t tag_request_size = sizeof(uint32_t);
24 	rpi3_mbox_request_t *req = (rpi3_mbox_request_t *) rpi3_mbox_buffer;
25 
26 	assert(revision != NULL);
27 
28 	VERBOSE("rpi3: mbox: Sending request at %p\n", (void *)req);
29 
30 	req->size = sizeof(rpi3_mbox_buffer);
31 	req->code = RPI3_MBOX_PROCESS_REQUEST;
32 
33 	req->tags[0] = RPI3_TAG_HARDWARE_GET_BOARD_REVISION;
34 	req->tags[1] = tag_request_size; /* Space available for the response */
35 	req->tags[2] = RPI3_TAG_REQUEST;
36 	req->tags[3] = 0; /* Placeholder for the response */
37 
38 	req->tags[4] = RPI3_TAG_END;
39 
40 	rpi3_vc_mailbox_request_send(req, RPI3_MBOX_BUFFER_SIZE);
41 
42 	if (req->code != RPI3_MBOX_REQUEST_SUCCESSFUL) {
43 		ERROR("rpi3: mbox: Code = 0x%08x\n", req->code);
44 		return -1;
45 	}
46 
47 	if (req->tags[2] != (RPI3_TAG_IS_RESPONSE | tag_request_size)) {
48 		ERROR("rpi3: mbox: get board revision failed (0x%08x)\n",
49 		      req->tags[2]);
50 		return -1;
51 	}
52 
53 	*revision = req->tags[3];
54 
55 	return 0;
56 }
57