Tom Rini | 10e4779 | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
Bin Meng | 8d6ed12 | 2015-02-02 22:35:28 +0800 | [diff] [blame] | 2 | /* |
| 3 | * Copyright (C) 2015, Bin Meng <bmeng.cn@gmail.com> |
Bin Meng | 8d6ed12 | 2015-02-02 22:35:28 +0800 | [diff] [blame] | 4 | */ |
| 5 | |
Bin Meng | 4756cac | 2015-09-03 05:37:25 -0700 | [diff] [blame] | 6 | #include <asm/io.h> |
| 7 | #include <asm/arch/device.h> |
Bin Meng | 4756cac | 2015-09-03 05:37:25 -0700 | [diff] [blame] | 8 | #include <asm/arch/quark.h> |
Bin Meng | 8d6ed12 | 2015-02-02 22:35:28 +0800 | [diff] [blame] | 9 | |
Bin Meng | 4756cac | 2015-09-03 05:37:25 -0700 | [diff] [blame] | 10 | /* |
| 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 Glass | aad29ae | 2020-12-03 16:55:21 -0700 | [diff] [blame] | 14 | * pin, as these APIs will eventually call into gpio_ich6_of_to_plat() |
Bin Meng | 4756cac | 2015-09-03 05:37:25 -0700 | [diff] [blame] | 15 | * 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 | */ |
| 20 | void board_assert_perst(void) |
| 21 | { |
| 22 | u32 base, port, val; |
| 23 | |
| 24 | /* retrieve the GPIO IO base */ |
Bin Meng | 9570d1f | 2016-02-01 01:40:48 -0800 | [diff] [blame] | 25 | qrk_pci_read_config_dword(QUARK_LEGACY_BRIDGE, LB_GBA, &base); |
Bin Meng | 4756cac | 2015-09-03 05:37:25 -0700 | [diff] [blame] | 26 | 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 | |
| 47 | void board_deassert_perst(void) |
| 48 | { |
| 49 | u32 base, port, val; |
| 50 | |
| 51 | /* retrieve the GPIO IO base */ |
Bin Meng | 9570d1f | 2016-02-01 01:40:48 -0800 | [diff] [blame] | 52 | qrk_pci_read_config_dword(QUARK_LEGACY_BRIDGE, LB_GBA, &base); |
Bin Meng | 4756cac | 2015-09-03 05:37:25 -0700 | [diff] [blame] | 53 | 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 | } |