예제 #1
0
static uint32_t get_uint32_t(void) {
	struct vc_msg_uint32_t vc_msg __attribute__((aligned(16)));

	vc_msg.msg_size = sizeof(struct vc_msg_uint32_t);
	vc_msg.request_code = 0;
	vc_msg.tag.tag_id = RPI_FIRMWARE_FRAMEBUFFER_GET_GPIOVIRTBUF;
	vc_msg.tag.buffer_size = 4;
	vc_msg.tag.data_size = 0;
	vc_msg.tag.value = 0;
	vc_msg.end_tag = 0;

	clean_data_cache();
	dsb();

	dmb();
	bcm2835_mailbox_flush();
	bcm2835_mailbox_write(BCM2835_MAILBOX_PROP_CHANNEL, GPU_MEM_BASE + (uint32_t)&vc_msg);
	(void)bcm2835_mailbox_read(BCM2835_MAILBOX_PROP_CHANNEL);
	dmb();

	invalidate_data_cache();
	dsb();

	if (vc_msg.request_code != BCM2835_MAILBOX_SUCCESS) {
		return 0;
	}

	return vc_msg.tag.value;
}
예제 #2
0
uint32_t bcm2835_vc_set_clock_rate(int clock_id, uint32_t clock_rate) {
	uint32_t mb_addr = 0x40007000;		// 0x7000 in L2 cache coherent mode
	struct  vc_msg_get_clock_rate *vc_msg = (struct vc_msg_get_clock_rate *)mb_addr;

	vc_msg->msg_size = sizeof(struct vc_msg_get_clock_rate);
	vc_msg->request_code = 0;
	vc_msg->tag.tag_id = BCM2835_MAILBOX_TAG_SET_CLOCK_RATE;
	vc_msg->tag.buffer_size = 8;
	vc_msg->tag.data_size = 8;	/* we're sending the clock ID and the new rates which is a total of 2 words */
	vc_msg->tag.dev_id = clock_id;
	vc_msg->tag.val = clock_rate;
	vc_msg->end_tag = 0;

	bcm2835_mailbox_write(BCM2835_MAILBOX_PROP_CHANNEL, mb_addr);
	bcm2835_mailbox_read(BCM2835_MAILBOX_PROP_CHANNEL);

	if (vc_msg->request_code != BCM2835_MAILBOX_SUCCESS) {
		return 0;
	}

	return vc_msg->tag.val;
}