summaryrefslogtreecommitdiff
path: root/src/superio/smsc/sch555x/emi.c
blob: 7b3b2041814890be6b900c39c15813e76f854409 (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
/* SPDX-License-Identifier: GPL-2.0-only */

#include <arch/io.h>
#include <device/pnp_ops.h>
#include "sch555x.h"

uint8_t sch555x_emi_read8(uint16_t addr)
{
	outw(addr | 0x8000, SCH555x_EMI_IOBASE + 2);
	return inb(SCH555x_EMI_IOBASE + 4);
}

uint16_t sch555x_emi_read16(uint16_t addr)
{
	outw(addr | 0x8001, SCH555x_EMI_IOBASE + 2);
	return inw(SCH555x_EMI_IOBASE + 4);
}

uint32_t sch555x_emi_read32(uint16_t addr)
{
	outw(addr | 0x8002, SCH555x_EMI_IOBASE + 2);
	return inl(SCH555x_EMI_IOBASE + 4);
}

void sch555x_emi_write8(uint16_t addr, uint8_t val)
{
	outw(addr | 0x8000, SCH555x_EMI_IOBASE + 2);
	outb(val, SCH555x_EMI_IOBASE + 4);
}

void sch555x_emi_write16(uint16_t addr, uint16_t val)
{
	outw(addr | 0x8001, SCH555x_EMI_IOBASE + 2);
	outw(val, SCH555x_EMI_IOBASE + 4);
}

void sch555x_emi_write32(uint16_t addr, uint32_t val)
{
	outw(addr | 0x8002, SCH555x_EMI_IOBASE + 2);
	outl(val, SCH555x_EMI_IOBASE + 4);
}