blob: 568bd4db490e0f538c92a6fea4bd1cee5c63b127 [file] [log] [blame]
Bin Meng8d6ed122015-02-02 22:35:28 +08001/*
2 * Copyright (C) 2015, Bin Meng <bmeng.cn@gmail.com>
3 *
4 * SPDX-License-Identifier: GPL-2.0+
5 */
6
7#include <common.h>
Bin Meng4756cac2015-09-03 05:37:25 -07008#include <asm/io.h>
9#include <asm/arch/device.h>
Bin Meng4756cac2015-09-03 05:37:25 -070010#include <asm/arch/quark.h>
Bin Meng8d6ed122015-02-02 22:35:28 +080011
Bin Meng8d6ed122015-02-02 22:35:28 +080012int board_early_init_f(void)
13{
14 return 0;
15}
16
Bin Meng4756cac2015-09-03 05:37:25 -070017/*
18 * Intel Galileo gen2 board uses GPIO Resume Well bank pin0 as the PERST# pin.
19 *
20 * We cannot use any public GPIO APIs in <asm-generic/gpio.h> to control this
21 * pin, as these APIs will eventually call into gpio_ich6_ofdata_to_platdata()
22 * in the Intel ICH6 GPIO driver where it calls PCI configuration space access
23 * APIs which will trigger PCI enumeration process.
24 *
25 * Check <asm/arch-quark/quark.h> for more details.
26 */
27void board_assert_perst(void)
28{
29 u32 base, port, val;
30
31 /* retrieve the GPIO IO base */
Bin Meng9570d1f2016-02-01 01:40:48 -080032 qrk_pci_read_config_dword(QUARK_LEGACY_BRIDGE, LB_GBA, &base);
Bin Meng4756cac2015-09-03 05:37:25 -070033 base = (base & 0xffff) & ~0x7f;
34
35 /* enable the pin */
36 port = base + 0x20;
37 val = inl(port);
38 val |= (1 << 0);
39 outl(val, port);
40
41 /* configure the pin as output */
42 port = base + 0x24;
43 val = inl(port);
44 val &= ~(1 << 0);
45 outl(val, port);
46
47 /* pull it down (assert) */
48 port = base + 0x28;
49 val = inl(port);
50 val &= ~(1 << 0);
51 outl(val, port);
52}
53
54void board_deassert_perst(void)
55{
56 u32 base, port, val;
57
58 /* retrieve the GPIO IO base */
Bin Meng9570d1f2016-02-01 01:40:48 -080059 qrk_pci_read_config_dword(QUARK_LEGACY_BRIDGE, LB_GBA, &base);
Bin Meng4756cac2015-09-03 05:37:25 -070060 base = (base & 0xffff) & ~0x7f;
61
62 /* pull it up (de-assert) */
63 port = base + 0x28;
64 val = inl(port);
65 val |= (1 << 0);
66 outl(val, port);
67}