2 * Copyright (C) 2017, Bin Meng <bmeng.cn@gmail.com>
4 * SPDX-License-Identifier: GPL-2.0+
8 * This library provides CMOS (inside RTC SRAM) access routines at a very
9 * early stage when driver model is not available yet. Only read access is
10 * provided. The 16-bit/32-bit read are compatible with driver model RTC
11 * uclass write ops, that data is stored in little-endian mode.
15 #include <asm/early_cmos.h>
18 u8 cmos_read8(u8 addr)
20 outb(addr, CMOS_IO_PORT);
22 return inb(CMOS_IO_PORT + 1);
25 u16 cmos_read16(u8 addr)
31 for (i = 0; i < sizeof(value); i++) {
32 data = cmos_read8(addr + i);
33 value |= data << (i << 3);
39 u32 cmos_read32(u8 addr)
45 for (i = 0; i < sizeof(value); i++) {
46 data = cmos_read8(addr + i);
47 value |= data << (i << 3);