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