1 // SPDX-License-Identifier: GPL-2.0+
3 * Copyright (C) 2017, Bin Meng <bmeng.cn@gmail.com>
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.
14 #include <asm/early_cmos.h>
17 u8 cmos_read8(u8 addr)
19 outb(addr, CMOS_IO_PORT);
21 return inb(CMOS_IO_PORT + 1);
24 u16 cmos_read16(u8 addr)
30 for (i = 0; i < sizeof(value); i++) {
31 data = cmos_read8(addr + i);
32 value |= data << (i << 3);
38 u32 cmos_read32(u8 addr)
44 for (i = 0; i < sizeof(value); i++) {
45 data = cmos_read8(addr + i);
46 value |= data << (i << 3);