Xo Wang | 3f87de8 | 2016-09-22 11:17:01 -0700 | [diff] [blame] | 1 | /** |
| 2 | * Copyright © 2016 Google Inc. |
| 3 | * Copyright © 2016 IBM Corporation |
| 4 | * |
| 5 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | * you may not use this file except in compliance with the License. |
| 7 | * You may obtain a copy of the License at |
| 8 | * |
| 9 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | * |
| 11 | * Unless required by applicable law or agreed to in writing, software |
| 12 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | * See the License for the specific language governing permissions and |
| 15 | * limitations under the License. |
| 16 | */ |
| 17 | |
Lei YU | 75a18a2 | 2016-11-22 01:47:47 +0800 | [diff] [blame] | 18 | #ifndef __GPIO_CONFIGS_H__ |
| 19 | #define __GPIO_CONFIGS_H__ |
Xo Wang | 3f87de8 | 2016-09-22 11:17:01 -0700 | [diff] [blame] | 20 | |
| 21 | #include <stddef.h> |
| 22 | #include <glib.h> |
| 23 | #include "gpio.h" |
| 24 | |
| 25 | typedef struct PowerGpio { |
Xo Wang | c1ce68b | 2016-09-22 16:34:37 -0700 | [diff] [blame] | 26 | /* Optional active high pin enabling writes to latched power_up pins. */ |
| 27 | GPIO latch_out; /* NULL name if not used. */ |
Xo Wang | 3f87de8 | 2016-09-22 11:17:01 -0700 | [diff] [blame] | 28 | /* Active high pin that is asserted following successful host power up. */ |
| 29 | GPIO power_good_in; |
| 30 | /* Selectable polarity pins enabling host power rails. */ |
| 31 | size_t num_power_up_outs; |
| 32 | GPIO *power_up_outs; |
| 33 | /* TRUE for active high */ |
| 34 | gboolean *power_up_pols; |
| 35 | /* Selectable polarity pins holding system complexes in reset. */ |
| 36 | size_t num_reset_outs; |
| 37 | GPIO *reset_outs; |
| 38 | /* TRUE for active high */ |
| 39 | gboolean *reset_pols; |
Yi Li | 0475f65 | 2016-10-25 13:19:59 +0800 | [diff] [blame] | 40 | size_t num_pci_reset_outs; |
| 41 | GPIO *pci_reset_outs; |
| 42 | /* TRUE for active high */ |
| 43 | gboolean *pci_reset_pols; |
| 44 | gboolean *pci_reset_holds; |
Xo Wang | 3f87de8 | 2016-09-22 11:17:01 -0700 | [diff] [blame] | 45 | } PowerGpio; |
| 46 | |
Lei YU | 75a18a2 | 2016-11-22 01:47:47 +0800 | [diff] [blame] | 47 | typedef struct GpioConfigs { |
| 48 | PowerGpio power_gpio; |
Lei YU | 75a18a2 | 2016-11-22 01:47:47 +0800 | [diff] [blame] | 49 | } GpioConfigs; |
| 50 | |
| 51 | /* Read system configuration for GPIOs. */ |
Matt Spinler | 0f3fd5a | 2018-08-08 11:15:26 -0500 | [diff] [blame] | 52 | gboolean read_gpios(GpioConfigs *gpios); |
Xo Wang | 3f87de8 | 2016-09-22 11:17:01 -0700 | [diff] [blame] | 53 | /* Frees internal buffers. Does not free parameter. Does not close GPIOs. */ |
Lei YU | 75a18a2 | 2016-11-22 01:47:47 +0800 | [diff] [blame] | 54 | void free_gpios(GpioConfigs *gpios); |
Xo Wang | 3f87de8 | 2016-09-22 11:17:01 -0700 | [diff] [blame] | 55 | |
| 56 | #endif |