Skip to content

Commit eace166

Browse files
mabaiocchiNicholas E Bofferding
authored andcommitted
Support GPIO Physical Presence Detect Devices
This commit makes the necessary changes to support the GPIO devices used for physical presence detection: - New attribute GPIO_INFO_PHYS_PRES - Enable GPIO Device Driver by default - GPIO Device Driver updated to support new device type - Added new GPIO PCA9551 layer to sit on top of GPIO Device Driver Change-Id: I952007503eb5d9fe873adea2eaaeccff21ae18a6 RTC:211220 Reviewed-on: http://rchgit01.rchland.ibm.com/gerrit1/84655 Reviewed-by: Ilya Smirnov <ismirno@us.ibm.com> Reviewed-by: Christopher J Engel <cjengel@us.ibm.com> Tested-by: Jenkins Server <pfd-jenkins+hostboot@us.ibm.com> Tested-by: Jenkins OP Build CI <op-jenkins+hostboot@us.ibm.com> Tested-by: Jenkins OP HW <op-hw-jenkins+hostboot@us.ibm.com> Tested-by: FSP CI Jenkins <fsp-CI-jenkins+hostboot@us.ibm.com> Reviewed-by: Nicholas E Bofferding <bofferdn@us.ibm.com>
1 parent 0247cc5 commit eace166

File tree

8 files changed

+592
-20
lines changed

8 files changed

+592
-20
lines changed

src/include/usr/gpio/gpioddreasoncodes.H

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
/* */
66
/* OpenPOWER HostBoot Project */
77
/* */
8-
/* Contributors Listed Below - COPYRIGHT 2014 */
8+
/* Contributors Listed Below - COPYRIGHT 2014,2019 */
99
/* [+] Google Inc. */
1010
/* [+] International Business Machines Corp. */
1111
/* */
@@ -40,17 +40,23 @@ namespace GPIO
4040
GPIO_READ = 0x01,
4141
GPIO_WRITE = 0x02,
4242
GPIO_READATTRIBUTES = 0x03,
43+
44+
// Use 0x10-0x1F range for PCA9551 functions
45+
GPIO_PCA9551_SET_LED = 0x10,
4346
};
4447

4548
/**
46-
* @enum grioReasonCode
49+
* @enum gpioReasonCode
4750
*/
4851
enum gpioReasonCode
4952
{
5053
GPIO_INVALID_DEVICE_TYPE = GPIO_COMP_ID | 0x00,
5154
GPIO_ATTR_INFO_NOT_FOUND = GPIO_COMP_ID | 0x01,
5255
GPIO_I2C_TARGET_NOT_FOUND = GPIO_COMP_ID | 0x02,
5356
GPIO_INVALID_OP = GPIO_COMP_ID | 0x03,
57+
58+
// Use 0x10-0x1F range for PCA9551 functions
59+
GPIO_PCA9551_DATA_MISMATCH = GPIO_COMP_ID | 0x10,
5460
};
5561

5662
};

src/include/usr/gpio/gpioif.H

Lines changed: 119 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
/* */
66
/* OpenPOWER HostBoot Project */
77
/* */
8-
/* Contributors Listed Below - COPYRIGHT 2014 */
8+
/* Contributors Listed Below - COPYRIGHT 2014,2019 */
99
/* [+] Google Inc. */
1010
/* [+] International Business Machines Corp. */
1111
/* */
@@ -26,17 +26,134 @@
2626
#ifndef __GPIOIF_H
2727
#define __GPIOIF_H
2828

29+
#include <errl/errlentry.H>
30+
2931
namespace GPIO
3032
{
3133
/**
3234
* @brief Devices to be accessed
3335
*/
3436
enum gpioDevice_t
3537
{
36-
PCA95X_GPIO = 0,
38+
// Corresponds to attribute ...
39+
PCA95X_GPIO = 0, // GPIO_INFO
40+
PCA9551_GPIO_PHYS_PRES = 1, // GPIO_INFO_PHYS_PRES
3741
INVALID_GPIO,
3842
};
3943

4044

45+
/* The following enums and interfaces are specific to PCA9551 GPIO Devices.
46+
* Documentation here: https://www.nxp.com/docs/en/data-sheet/PCA9551.pdf
47+
*/
48+
49+
/**
50+
* @brief Specific to PCA9551: LED Bit Mask to match how their status is read
51+
* back from LED "INPUT" register on PCA9551 Devices
52+
*/
53+
enum PCA9551_LEDS_t : uint8_t
54+
{
55+
PCA9551_LED0 = 0x01,
56+
PCA9551_LED1 = 0x02,
57+
PCA9551_LED2 = 0x04,
58+
PCA9551_LED3 = 0x08,
59+
PCA9551_LED4 = 0x10,
60+
PCA9551_LED5 = 0x20,
61+
PCA9551_LED6 = 0x40,
62+
PCA9551_LED7 = 0x80,
63+
};
64+
65+
/**
66+
* @brief Specific to PCA9551: Values used by the LED select registers
67+
* to determine the source of the LED data.
68+
*/
69+
enum PCA9551_LED_Output_Settings_t : uint8_t
70+
{
71+
PCA9551_OUTPUT_LOW = 0x00, // LED on
72+
PCA9551_OUTPUT_HIGH_IMPEDANCE = 0x01, // LED off; default
73+
PCA9551_OUTPUT_PWM0 = 0x02, // Output blinks at PWM0 rate
74+
PCA9551_OUTPUT_PWM1 = 0x03, // Output blinks at PWM1 rate
75+
};
76+
77+
/**
78+
* @brief Specific to PCA9551: Control register definition:
79+
sepcificies which register the operation will target
80+
*/
81+
enum PCA9551_Registers_t : uint8_t
82+
{
83+
PCA9551_REGISTER_INPUT = 0x00, // INPUT (read only) input register
84+
PCA9551_REGISTER_PCS0 = 0x01, // PSC0 (r/w) frequency prescaler 0
85+
PCA9551_REGISTER_PWM0 = 0x02, // PWM0 (r/w) PWM register 0
86+
PCA9551_REGISTER_PCS1 = 0x03, // PSC1 (r/w) frequency prescaler 1
87+
PCA9551_REGISTER_PWM1 = 0x04, // PWM1 (r/w) PWM register 1
88+
PCA9551_REGISTER_LS0 = 0x05, // LS0 (r/w) LED0 to LED3 selector
89+
PCA9551_REGISTER_LS1 = 0x06, // LS1 (r/w) LED4 to LED7 selector
90+
};
91+
92+
/**
93+
* @brief Specific to PCA9551: Helper constants to work with the bits in the
94+
* PCA9551 registers
95+
*/
96+
enum PCA9551_Constants_t : uint8_t
97+
{
98+
// Mask shifted to apply 2-bit settings to a specific LED in the output
99+
// settings register
100+
PCA9551_LED_SETTINGS_MASK = 0x03,
101+
102+
// Amount to shift the LED value per LED when walking through the LEDs
103+
// in the INPUT register (related to PCA9551_LEDS_t above)
104+
PCA9551_LED_SHIFT_AMOUNT = 0x01,
105+
106+
// Amount to shift the LED Settings MASK per LED when walking through the
107+
// LEDs in the output settings register (ie, 2 bits at a time)
108+
PCA9551_LED_SETTINGS_MASK_SHIFT_AMOUNT = 0x02,
109+
110+
// LED Divider: While the INPUT register can contain all 8 LED values
111+
// (since each value is represented by one bit), the SETTINGS registers
112+
// (PCA9551_REGISTER_LS0 and PCA9551_REGISTER_LS1) can only cover 4 LEDs
113+
// each since each setting requires 2 bits.
114+
// This divisor takes LEDs 4 to 7 and makes them look like LEDs 0 to 3
115+
PCA9551_LED_SETTINGS_DIVISOR = 0x80,
116+
};
117+
118+
/**
119+
* @brief Returns the PCA9551 Device's INPUT register which reflects the state
120+
* of the device's LEDs (aka pins)
121+
*
122+
* @param[in] i_target - Target that contains ATTR_GPIO_INFO_PHYS_PRES attribute
123+
* to run the commands against
124+
*
125+
* @param[out] o_led_data - The INPUT register data from the device
126+
*
127+
* @return errlHndl_t nullptr on success; non-nullptr on error.
128+
*/
129+
errlHndl_t gpioPca9551GetLeds(TARGETING::Target * i_target,
130+
uint8_t & o_led_data);
131+
132+
/**
133+
* @brief Sets the given LED (aka pin) of a PCA9551 Device to a certain setting
134+
* and returns the INPUT register which reflects the state of device's
135+
* LEDs (aka pins) after the setting has been run
136+
*
137+
* @param[in] i_target - Target that contains ATTR_GPIO_INFO_PHYS_PRES attribute
138+
* to run the commands against
139+
*
140+
* @param[in] i_led - The specific LED Target that contains ATTR_GPIO_INFO_PHYS_PRES attribute
141+
* to run the commands against
142+
*
143+
* @param[in] i_setting - the output setting to set the LED to
144+
*
145+
* @param[out] o_led_data - The INPUT register data from the device after the
146+
* 'set' procedure has been run allowing the caller to
147+
* evaluate if the set actually went through
148+
*
149+
* @return errlHndl_t nullptr on success; non-nullptr on error.
150+
*/
151+
152+
errlHndl_t gpioPca9551SetLed(TARGETING::Target * i_target,
153+
const PCA9551_LEDS_t i_led,
154+
const PCA9551_LED_Output_Settings_t i_setting,
155+
uint8_t & o_led_data);
156+
157+
41158
}; // GPIO NAMESPACE
42159
#endif

src/usr/gpio/HBconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
config GPIODD
2-
default n
2+
default y
33
help
44
Enable GPIO device driver support

0 commit comments

Comments
 (0)