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