]> Git Repo - u-boot.git/blame - arch/x86/lib/early_cmos.c
SPDX: Convert all of our single license tags to Linux Kernel style
[u-boot.git] / arch / x86 / lib / early_cmos.c
CommitLineData
83d290c5 1// SPDX-License-Identifier: GPL-2.0+
9f1fad1e
BM
2/*
3 * Copyright (C) 2017, Bin Meng <[email protected]>
9f1fad1e
BM
4 */
5
6/*
7 * This library provides CMOS (inside RTC SRAM) access routines at a very
8 * early stage when driver model is not available yet. Only read access is
9 * provided. The 16-bit/32-bit read are compatible with driver model RTC
10 * uclass write ops, that data is stored in little-endian mode.
11 */
12
13#include <common.h>
14#include <asm/early_cmos.h>
15#include <asm/io.h>
16
17u8 cmos_read8(u8 addr)
18{
19 outb(addr, CMOS_IO_PORT);
20
21 return inb(CMOS_IO_PORT + 1);
22}
23
24u16 cmos_read16(u8 addr)
25{
26 u16 value = 0;
27 u16 data;
28 int i;
29
30 for (i = 0; i < sizeof(value); i++) {
31 data = cmos_read8(addr + i);
32 value |= data << (i << 3);
33 }
34
35 return value;
36}
37
38u32 cmos_read32(u8 addr)
39{
40 u32 value = 0;
41 u32 data;
42 int i;
43
44 for (i = 0; i < sizeof(value); i++) {
45 data = cmos_read8(addr + i);
46 value |= data << (i << 3);
47 }
48
49 return value;
50}
This page took 0.066763 seconds and 4 git commands to generate.