blob: 5d2adad3197ef6f20b0a164b7eb9aae215888072 [file] [log] [blame]
Simon Glass36a6cf32019-12-08 17:40:09 -07001/* SPDX-License-Identifier: GPL-2.0 */
2/*
3 * Copyright (C) 2017 Intel Corporation.
4 * Take from coreboot project file of the same name
5 */
6
7#ifndef _ASM_ARCH_LPC_H
8#define _ASM_ARCH_LPC_H
9
10#define LPC_SERIRQ_CTL 0x64
11#define LPC_SCNT_EN BIT(7)
12#define LPC_SCNT_MODE BIT(6)
13#define LPC_IO_DECODE 0x80
14#define LPC_IOD_COMA_RANGE (0 << 0) /* 0x3F8 - 0x3FF COMA*/
15#define LPC_IOD_COMB_RANGE (1 << 4) /* 0x2F8 - 0x2FF COMB*/
16/*
17 * Use IO_<peripheral>_<IO port> style macros defined in lpc_lib.h
18 * to enable decoding of I/O locations for a peripheral
19 */
20#define LPC_IO_ENABLES 0x82
21#define LPC_GENERIC_IO_RANGE(n) ((((n) & 0x3) * 4) + 0x84)
22#define LPC_LGIR_AMASK_MASK (0xfc << 16)
23#define LPC_LGIR_ADDR_MASK 0xfffc
24#define LPC_LGIR_EN BIT(0)
25#define LPC_LGIR_MAX_WINDOW_SIZE 256
26#define LPC_GENERIC_MEM_RANGE 0x98
27#define LPC_LGMR_ADDR_MASK 0xffff0000
28#define LPC_LGMR_EN BIT(0)
29#define LPC_LGMR_WINDOW_SIZE (64 * KiB)
30#define LPC_BIOS_CNTL 0xdc
31#define LPC_BC_BILD BIT(7)
32#define LPC_BC_LE BIT(1)
33#define LPC_BC_EISS BIT(5)
34#define LPC_PCCTL 0xE0 /* PCI Clock Control */
35#define LPC_PCCTL_CLKRUN_EN BIT(0)
36
37/*
38 * IO decode enable macros are in the format IO_<peripheral>_<IO port>.
39 * For example, to open ports 0x60, 0x64 for the keyboard controller,
40 * use IOE_KBC_60_64 macro. For IOE_ macros that do not specify a port range,
41 * the port range is selectable via the IO decodes register.
42 */
43#define LPC_IOE_EC_4E_4F BIT(13)
44#define LPC_IOE_SUPERIO_2E_2F BIT(12)
45#define LPC_IOE_EC_62_66 BIT(11)
46#define LPC_IOE_KBC_60_64 BIT(10)
47#define LPC_IOE_HGE_208 BIT(9)
48#define LPC_IOE_LGE_200 BIT(8)
49#define LPC_IOE_FDD_EN BIT(3)
50#define LPC_IOE_LPT_EN BIT(2)
51#define LPC_IOE_COMB_EN BIT(1)
52#define LPC_IOE_COMA_EN BIT(0)
53#define LPC_NUM_GENERIC_IO_RANGES 4
54
55#define LPC_IO_ENABLES 0x82
56
57/**
58 * lpc_enable_fixed_io_ranges() - enable the fixed I/O ranges
59 *
60 * @io_enables: Mask of things to enable (LPC_IOE_.)
61 */
62void lpc_enable_fixed_io_ranges(uint io_enables);
63
64/**
65 * lpc_open_pmio_window() - Open an IO port range
66 *
67 * @base: Base I/O address (e.g. 0x800)
68 * @size: Size of window (e.g. 0x100)
69 * @return 0 if OK, -ENOSPC if there are no more windows available, -EALREADY
70 * if already set up
71 */
72int lpc_open_pmio_window(uint base, uint size);
73
74/**
75 * lpc_io_setup_comm_a_b() - Set up basic serial UARTs
76 *
77 * Set up the LPC to handle I/O to the COMA/COMB serial UART addresses
78 * 2f8-2ff and 3f8-3ff.
79 */
80void lpc_io_setup_comm_a_b(void);
81
82#endif