summaryrefslogtreecommitdiff
path: root/arch/arm/mach-uniphier/soc-info.c
blob: ce2d4b6dea4cc5f9b0d246857590b2e656c20f4c (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
// SPDX-License-Identifier: GPL-2.0+
/*
 * Copyright (C) 2017 Socionext Inc.
 *   Author: Masahiro Yamada <yamada.masahiro@socionext.com>
 */

#include <linux/io.h>
#include <linux/types.h>

#include "sg-regs.h"
#include "soc-info.h"

static unsigned int __uniphier_get_revision_field(unsigned int mask,
						  unsigned int shift)
{
	u32 revision = readl(SG_REVISION);

	return (revision >> shift) & mask;
}

unsigned int uniphier_get_soc_id(void)
{
	return __uniphier_get_revision_field(0xff, 16);
}

unsigned int uniphier_get_soc_model(void)
{
	return __uniphier_get_revision_field(0x7, 8);
}

unsigned int uniphier_get_soc_revision(void)
{
	return __uniphier_get_revision_field(0x1f, 0);
}