blob: 4db6113f4d54774e8447dd6956e9907351e606e7 [file] [log] [blame]
Duncan Laurie045f1532012-12-17 11:29:10 -08001/*
2 * This file is part of the coreboot project.
3 *
4 * Copyright (C) 2012 Google Inc. All rights reserved.
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; version 2 of the License.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
Duncan Laurie045f1532012-12-17 11:29:10 -080014 */
15
16#ifndef INTEL_LYNXPOINT_LP_GPIO_H
17#define INTEL_LYNXPOINT_LP_GPIO_H
18
19/* LynxPoint LP GPIOBASE Registers */
20#define GPIO_OWNER(set) (0x00 + ((set) * 4))
21#define GPIO_PIRQ_APIC_EN 0x10
22#define GPIO_BLINK 0x18
23#define GPIO_SER_BLINK 0x1c
24#define GPIO_SER_BLINK_CS 0x20
25#define GPIO_SER_BLINK_DATA 0x24
26#define GPIO_ROUTE(set) (0x30 + ((set) * 4))
Duncan Laurie045f1532012-12-17 11:29:10 -080027#define GPIO_RESET(set) (0x60 + ((set) * 4))
28#define GPIO_GLOBAL_CONFIG 0x7c
29#define GPIO_IRQ_IS(set) (0x80 + ((set) * 4))
30#define GPIO_IRQ_IE(set) (0x90 + ((set) * 4))
31#define GPIO_CONFIG0(gpio) (0x100 + ((gpio) * 8))
32#define GPIO_CONFIG1(gpio) (0x104 + ((gpio) * 8))
33
34#define MAX_GPIO_NUMBER 94 /* zero based */
Duncan Laurie55ad9722013-04-23 13:43:23 -070035#define GPIO_LIST_END 0xffffffff
Duncan Laurie045f1532012-12-17 11:29:10 -080036
37/* conf0 */
38
39#define GPIO_MODE_NATIVE (0 << 0)
40#define GPIO_MODE_GPIO (1 << 0)
41
42#define GPIO_DIR_OUTPUT (0 << 2)
43#define GPIO_DIR_INPUT (1 << 2)
44
45#define GPIO_NO_INVERT (0 << 3)
46#define GPIO_INVERT (1 << 3)
47
48#define GPIO_IRQ_EDGE (0 << 4)
49#define GPIO_IRQ_LEVEL (1 << 4)
50
51#define GPI_LEVEL (1 << 30)
52
Duncan Laurie55ad9722013-04-23 13:43:23 -070053#define GPO_LEVEL_SHIFT 31
54#define GPO_LEVEL_MASK (1 << GPO_LEVEL_SHIFT)
55#define GPO_LEVEL_LOW (0 << GPO_LEVEL_SHIFT)
56#define GPO_LEVEL_HIGH (1 << GPO_LEVEL_SHIFT)
Duncan Laurie045f1532012-12-17 11:29:10 -080057
58/* conf1 */
59
60#define GPIO_PULL_NONE (0 << 0)
61#define GPIO_PULL_DOWN (1 << 0)
62#define GPIO_PULL_UP (2 << 0)
63
64#define GPIO_SENSE_ENABLE (0 << 2)
65#define GPIO_SENSE_DISABLE (1 << 2)
66
67/* owner */
68
69#define GPIO_OWNER_ACPI 0
70#define GPIO_OWNER_GPIO 1
71
72/* route */
73
74#define GPIO_ROUTE_SCI 0
75#define GPIO_ROUTE_SMI 1
76
77/* irqen */
78
79#define GPIO_IRQ_DISABLE 0
80#define GPIO_IRQ_ENABLE 1
81
82/* blink */
83
84#define GPO_NO_BLINK 0
85#define GPO_BLINK 1
86
87/* reset */
88
89#define GPIO_RESET_PWROK 0
90#define GPIO_RESET_RSMRST 1
91
Duncan Lauriec5939992013-05-24 11:06:49 -070092/* pirq route to io-apic */
93
94#define GPIO_PIRQ_APIC_MASK 0
95#define GPIO_PIRQ_APIC_ROUTE 1
96
Duncan Laurie55ad9722013-04-23 13:43:23 -070097#define LP_GPIO_END \
98 { .conf0 = GPIO_LIST_END }
99
100#define LP_GPIO_NATIVE \
101 { .conf0 = GPIO_MODE_NATIVE }
102
103#define LP_GPIO_UNUSED \
104 { .conf0 = GPIO_MODE_GPIO | GPIO_DIR_INPUT, \
105 .owner = GPIO_OWNER_GPIO, \
106 .conf1 = GPIO_SENSE_DISABLE }
107
108#define LP_GPIO_ACPI_SCI \
109 { .conf0 = GPIO_MODE_GPIO | GPIO_DIR_INPUT | GPIO_INVERT, \
110 .owner = GPIO_OWNER_ACPI, \
111 .route = GPIO_ROUTE_SCI }
112
113#define LP_GPIO_ACPI_SMI \
Duncan Lauriecd7bb2f2013-05-21 09:28:28 -0700114 { .conf0 = GPIO_MODE_GPIO | GPIO_DIR_INPUT | GPIO_INVERT, \
Duncan Laurie55ad9722013-04-23 13:43:23 -0700115 .owner = GPIO_OWNER_ACPI, \
116 .route = GPIO_ROUTE_SMI }
117
118#define LP_GPIO_INPUT \
119 { .conf0 = GPIO_MODE_GPIO | GPIO_DIR_INPUT, \
120 .owner = GPIO_OWNER_GPIO }
121
Duncan Laurie994611a2013-05-29 07:48:47 -0700122#define LP_GPIO_INPUT_INVERT \
123 { .conf0 = GPIO_MODE_GPIO | GPIO_DIR_INPUT | GPIO_INVERT, \
124 .owner = GPIO_OWNER_GPIO }
125
Duncan Laurie55ad9722013-04-23 13:43:23 -0700126#define LP_GPIO_IRQ_EDGE \
127 { .conf0 = GPIO_MODE_GPIO | GPIO_DIR_INPUT | GPIO_IRQ_EDGE, \
128 .owner = GPIO_OWNER_GPIO, \
129 .irqen = GPIO_IRQ_ENABLE }
130
131#define LP_GPIO_IRQ_LEVEL \
132 { .conf0 = GPIO_MODE_GPIO | GPIO_DIR_INPUT | GPIO_IRQ_LEVEL, \
133 .owner = GPIO_OWNER_GPIO, \
134 .irqen = GPIO_IRQ_ENABLE }
135
Duncan Lauriec5939992013-05-24 11:06:49 -0700136#define LP_GPIO_PIRQ \
137 { .conf0 = GPIO_MODE_GPIO | GPIO_DIR_INPUT, \
138 .owner = GPIO_OWNER_GPIO, \
139 .pirq = GPIO_PIRQ_APIC_ROUTE }
140
Duncan Laurie55ad9722013-04-23 13:43:23 -0700141#define LP_GPIO_OUT_HIGH \
142 { .conf0 = GPIO_MODE_GPIO | GPIO_DIR_OUTPUT | GPO_LEVEL_HIGH, \
143 .owner = GPIO_OWNER_GPIO, \
144 .conf1 = GPIO_SENSE_DISABLE }
145
146#define LP_GPIO_OUT_LOW \
147 { .conf0 = GPIO_MODE_GPIO | GPIO_DIR_OUTPUT | GPO_LEVEL_LOW, \
148 .owner = GPIO_OWNER_GPIO, \
149 .conf1 = GPIO_SENSE_DISABLE }
150
Duncan Laurie045f1532012-12-17 11:29:10 -0800151struct pch_lp_gpio_map {
152 u8 gpio;
153 u32 conf0;
154 u32 conf1;
155 u8 owner;
156 u8 route;
157 u8 irqen;
158 u8 reset;
159 u8 blink;
Duncan Lauriec5939992013-05-24 11:06:49 -0700160 u8 pirq;
Duncan Laurie045f1532012-12-17 11:29:10 -0800161} __attribute__ ((packed));
162
163/* Configure GPIOs with mainboard provided settings */
164void setup_pch_lp_gpios(const struct pch_lp_gpio_map map[]);
165
166#endif