blob: 341b627a65f5919a6cd07f2f364a1e0371bada41 [file] [log] [blame]
Tom Rini83d290c2018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
Bin Mengafee3fb2015-02-02 22:35:28 +08002/*
3 * Copyright (C) 2015, Bin Meng <bmeng.cn@gmail.com>
Bin Mengafee3fb2015-02-02 22:35:28 +08004 */
5
6#include <common.h>
Bin Meng316fd392015-09-03 05:37:25 -07007#include <asm/io.h>
8#include <asm/arch/device.h>
Bin Meng316fd392015-09-03 05:37:25 -07009#include <asm/arch/quark.h>
Bin Mengafee3fb2015-02-02 22:35:28 +080010
Bin Meng316fd392015-09-03 05:37:25 -070011/*
12 * Intel Galileo gen2 board uses GPIO Resume Well bank pin0 as the PERST# pin.
13 *
14 * We cannot use any public GPIO APIs in <asm-generic/gpio.h> to control this
Simon Glassd1998a92020-12-03 16:55:21 -070015 * pin, as these APIs will eventually call into gpio_ich6_of_to_plat()
Bin Meng316fd392015-09-03 05:37:25 -070016 * in the Intel ICH6 GPIO driver where it calls PCI configuration space access
17 * APIs which will trigger PCI enumeration process.
18 *
19 * Check <asm/arch-quark/quark.h> for more details.
20 */
21void board_assert_perst(void)
22{
23 u32 base, port, val;
24
25 /* retrieve the GPIO IO base */
Bin Meng2b7ff262016-02-01 01:40:48 -080026 qrk_pci_read_config_dword(QUARK_LEGACY_BRIDGE, LB_GBA, &base);
Bin Meng316fd392015-09-03 05:37:25 -070027 base = (base & 0xffff) & ~0x7f;
28
29 /* enable the pin */
30 port = base + 0x20;
31 val = inl(port);
32 val |= (1 << 0);
33 outl(val, port);
34
35 /* configure the pin as output */
36 port = base + 0x24;
37 val = inl(port);
38 val &= ~(1 << 0);
39 outl(val, port);
40
41 /* pull it down (assert) */
42 port = base + 0x28;
43 val = inl(port);
44 val &= ~(1 << 0);
45 outl(val, port);
46}
47
48void board_deassert_perst(void)
49{
50 u32 base, port, val;
51
52 /* retrieve the GPIO IO base */
Bin Meng2b7ff262016-02-01 01:40:48 -080053 qrk_pci_read_config_dword(QUARK_LEGACY_BRIDGE, LB_GBA, &base);
Bin Meng316fd392015-09-03 05:37:25 -070054 base = (base & 0xffff) & ~0x7f;
55
56 /* pull it up (de-assert) */
57 port = base + 0x28;
58 val = inl(port);
59 val |= (1 << 0);
60 outl(val, port);
61}