summaryrefslogtreecommitdiff
path: root/arch/arm/common/boottime.c
blob: 73e9e04ed37714b6ade4df26c3a519cb86131807 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
/*
 * Copyright (C) ST-Ericsson SA 2009-2010
 *
 * Author: Jonas Aaberg <jonas.aberg@stericsson.com> for ST-Ericsson
 *
 * License terms: GNU General Public License (GPL) version 2
 *
 * Store boot times measured during for example u-boot startup.
 */

#include <linux/kernel.h>
#include <linux/init.h>
#include <linux/boottime.h>
#include <linux/string.h>
#include <asm/setup.h>

static u32 bootloader_idle;
static u32 bootloader_total;

static int __init boottime_parse_tag(const struct tag *tag)
{
	int i;
	char buff[BOOTTIME_MAX_NAME_LEN];

	bootloader_idle = tag->u.boottime.idle;
	bootloader_total = tag->u.boottime.total;

	for (i = 0; i < tag->u.boottime.num; i++) {
		snprintf(buff, BOOTTIME_MAX_NAME_LEN, "%s+0x0/0x0",
			 tag->u.boottime.entry[i].name);
		buff[BOOTTIME_MAX_NAME_LEN - 1] = '\0';
		boottime_mark_wtime(buff, tag->u.boottime.entry[i].time);
	}

	return 0;
}

__tagtable(ATAG_BOOTTIME,  boottime_parse_tag);

int boottime_bootloader_idle(void)
{
	if (bootloader_total == 0)
		return 0;

	return (int) ((bootloader_idle) / (bootloader_total / 100));
}