-
-
Notifications
You must be signed in to change notification settings - Fork 22
Vp46xx reset pin backport #899
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
philipanda
wants to merge
4
commits into
protectli_vault_cml_v1.2.1_branch
Choose a base branch
from
vp46xx_reset_pin_backport
base: protectli_vault_cml_v1.2.1_branch
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+325
−3
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
08bc803
mb/protectli/vault_cml: Enable FP_RST button signal GPIO input
philipanda 4571427
superio/ite/common: Add common driver for GPIO and LED configuration
miczyg1 902c258
superio/ite: Enable common driver for GPIO on it8784e
philipanda 21e3c33
config.protectli_vp46xx: Bump RC
philipanda File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,191 @@ | ||
| /* SPDX-License-Identifier: GPL-2.0-or-later */ | ||
|
|
||
| #include <device/pnp_ops.h> | ||
| #include <device/pnp.h> | ||
| #include <stdint.h> | ||
|
|
||
| #include "ite.h" | ||
| #include "ite_gpio.h" | ||
|
|
||
| /* Catch ITE SIOs that enable the driver but do not configure the number of sets */ | ||
| #if CONFIG_SUPERIO_ITE_COMMON_NUM_GPIO_SETS == 0 | ||
| #error "Maximum number of ITE SIO GPIO sets not provided" | ||
| #endif | ||
|
|
||
| #if CONFIG_SUPERIO_ITE_COMMON_NUM_GPIO_SETS > 10 | ||
| #error "ITE SIO GPIO drivers only support up to 10 GPIO sets" | ||
| #endif | ||
|
|
||
| /* GPIO Polarity Select: 1: Inverting, 0: Non-inverting */ | ||
| #define ITE_GPIO_REG_POLARITY(x) \ | ||
| (((x) > 8) ? (0xd1 + ((x) - 9) * 5) \ | ||
| : (0xb0 + ((x) - 1)) \ | ||
| ) | ||
|
|
||
| /* GPIO Internal Pull-up: 1: Enable, 0: Disable */ | ||
| #define ITE_GPIO_REG_PULLUP(x) \ | ||
| (((x) > 8) ? (0xd4 + ((x) - 9) * 5) \ | ||
| : (0xb8 + ((x) - 1)) \ | ||
| ) | ||
|
|
||
| /* GPIO Function Select: 1: Simple I/O, 0: Alternate function */ | ||
| #define ITE_GPIO_REG_FN_SELECT(x) \ | ||
| (((x) > 8) ? (0xd3 + ((x) - 9) * 5) \ | ||
| : (0xc0 + ((x) - 1)) \ | ||
| ) | ||
|
|
||
| /* GPIO Mode: 0: input mode, 1: output mode */ | ||
| #define ITE_GPIO_REG_OUTPUT(x) \ | ||
| (((x) > 8) ? (0xd2 + ((x) - 9) * 5) \ | ||
| : (0xc8 + ((x) - 1)) \ | ||
| ) | ||
|
|
||
| /* GPIO LED pin mapping register */ | ||
| #define ITE_GPIO_REG_LED_PINMAP(x) (0xf8 + ((x) & 1) * 2) | ||
| #define ITE_GPIO_LED_PIN_LOC(set, pin) ((((set) & 7) << 3) | ((pin) & 7)) | ||
| #define ITE_GPIO_LED_PIN_LOC_MASK 0x3f | ||
| /* GPIO LED control register */ | ||
| #define ITE_GPIO_REG_LED_CONTROL(x) (0xf9 + ((x) & 1) * 2) | ||
| #define ITE_GPIO_LED_OUTPUT_LOW (1 << 0) | ||
| #define ITE_GPIO_LED_PINMAP_CLEAR (1 << 4) | ||
| #define ITE_GPIO_LED_SHORT_LOW_PULSE \ | ||
| (CONFIG(SUPERIO_ITE_COMMON_GPIO_LED_FREQ_5BIT) ? (1 << 5) \ | ||
| : (1 << 3) \ | ||
| ) | ||
| #define ITE_GPIO_LED_FREQ_SEL(x) \ | ||
| (CONFIG(SUPERIO_ITE_COMMON_GPIO_LED_FREQ_5BIT) \ | ||
| ? ((((x) & 0x18) << 3) | (((x) & 0x7) << 1)) \ | ||
| : (((x) & 0x3) << 1) \ | ||
| ) | ||
| #define ITE_GPIO_LED_FREQ_SEL_MASK \ | ||
| (CONFIG(SUPERIO_ITE_COMMON_GPIO_LED_FREQ_5BIT) ? 0xce : 0x06) | ||
|
|
||
| static bool ite_has_gpio_fn_select_reg(u8 set) | ||
| { | ||
| /* IT8718F has all registers for all sets. */ | ||
| if (CONFIG(SUPERIO_ITE_IT8718F)) | ||
| return true; | ||
|
|
||
| /* Typically ITE GPIO sets 6 to 8 don't have enable and polarity registers. */ | ||
| if (set < 6 || set > 8) | ||
| return true; | ||
|
|
||
| return false; | ||
| } | ||
|
|
||
| static bool ite_has_gpio_polarity_reg(u8 set) | ||
| { | ||
| /* IT8718F has all registers for all sets. */ | ||
| if (CONFIG(SUPERIO_ITE_IT8718F)) | ||
| return true; | ||
|
|
||
| /* IT8720F/IT8721F has polarity register for all GPIO sets */ | ||
| if (CONFIG(SUPERIO_ITE_IT8720F) || CONFIG(SUPERIO_ITE_IT8721F)) | ||
| return true; | ||
|
|
||
| /* Typically ITE GPIO sets 6 to 8 don't have enable and polarity registers. */ | ||
| if (set < 6 || set > 8) | ||
| return true; | ||
|
|
||
| return false; | ||
| } | ||
|
|
||
| static bool ite_has_gpio_pullup_reg(u8 set) | ||
| { | ||
| /* IT8718F/IT8720F does not have pull-up register for set 2 */ | ||
| if ((CONFIG(SUPERIO_ITE_IT8718F) || CONFIG(SUPERIO_ITE_IT8720F)) && (set == 2)) | ||
| return false; | ||
|
|
||
| /* IT8783E/F does not have pull-up register for set 6 */ | ||
| if (CONFIG(SUPERIO_ITE_IT8783EF) && (set == 6)) | ||
| return false; | ||
|
|
||
| /* | ||
| * ITE GPIO Sets 7 and 8 don't have a pullup register. | ||
| * See IT8786/IT8625 datasheet section 8.10.10. | ||
| * Also applies to IT8728F. | ||
| */ | ||
| if (set != 7 && set != 8) | ||
| return true; | ||
|
|
||
| return false; | ||
| } | ||
|
|
||
| /* | ||
| * Configures a single GPIO given its number as gpio_num, direction ("in_out" | ||
| * parameter) and properties, such as polarity and pull ("gpio_ctrl" | ||
| * parameter). The "enable" parameter can configure the GPIO in Simple I/O | ||
| * mode when set or Alternate function mode when clear. Some chips may also | ||
| * not support configuring all properties for a particular GPIO. It is left to | ||
| * the implementer to check if GPIO settings are valid for given gpio_num. | ||
| */ | ||
| void ite_gpio_setup(pnp_devfn_t gpiodev, u8 gpio_num, enum ite_gpio_direction in_out, | ||
| enum ite_gpio_mode enable, u8 gpio_ctrl) | ||
| { | ||
| u8 set = (gpio_num / 10); | ||
| u8 pin = (gpio_num % 10); | ||
|
|
||
| /* Number of configurable sets is chip dependent, 8 pins each */ | ||
| if (gpio_num < 10 || set > CONFIG_SUPERIO_ITE_COMMON_NUM_GPIO_SETS || pin > 7) | ||
| return; | ||
|
|
||
| pnp_enter_conf_state(gpiodev); | ||
| pnp_set_logical_device(gpiodev); | ||
|
|
||
| if (ite_has_gpio_fn_select_reg(set)) | ||
| pnp_unset_and_set_config(gpiodev, ITE_GPIO_REG_FN_SELECT(set), | ||
| 1 << pin, (enable & 1) << pin); | ||
|
|
||
| if (ite_has_gpio_polarity_reg(set)) | ||
| pnp_unset_and_set_config(gpiodev, ITE_GPIO_REG_POLARITY(set), | ||
| 1 << pin, | ||
| (gpio_ctrl & ITE_GPIO_POL_INVERT) ? 1 << pin : 0); | ||
|
|
||
|
|
||
| pnp_unset_and_set_config(gpiodev, ITE_GPIO_REG_OUTPUT(set), 1 << pin, (in_out & 1) << pin); | ||
|
|
||
| if (ite_has_gpio_pullup_reg(set)) | ||
| pnp_unset_and_set_config(gpiodev, ITE_GPIO_REG_PULLUP(set), 1 << pin, | ||
| (gpio_ctrl & ITE_GPIO_PULLUP_ENABLE) ? 1 << pin : 0); | ||
|
|
||
| pnp_exit_conf_state(gpiodev); | ||
| } | ||
|
|
||
| void ite_gpio_setup_led(pnp_devfn_t gpiodev, u8 gpio_num, | ||
| enum ite_gpio_led led_no, | ||
| enum ite_led_frequency freq, | ||
| u8 led_ctrl) | ||
| { | ||
| u8 set = (gpio_num / 10); | ||
| u8 pin = (gpio_num % 10); | ||
| u8 reg = 0; | ||
|
|
||
| /* Number of configurable sets is chip dependent, 8 pins each */ | ||
| if (gpio_num < 10 || set > CONFIG_SUPERIO_ITE_COMMON_NUM_GPIO_SETS || pin > 7) | ||
| return; | ||
|
|
||
| /* LED is available only for GPIO sets 1-5 */ | ||
| if (set > 5) | ||
| return; | ||
|
|
||
| pnp_enter_conf_state(gpiodev); | ||
| pnp_set_logical_device(gpiodev); | ||
|
|
||
| /* Pinmap clear bit is only available when frequency is controlled with 5 bits */ | ||
| if (CONFIG(SUPERIO_ITE_COMMON_GPIO_LED_FREQ_5BIT) && (led_ctrl & ITE_LED_PINMAP_CLEAR)) | ||
| reg |= ITE_GPIO_LED_PINMAP_CLEAR; | ||
|
|
||
| if (led_ctrl & ITE_LED_OUTPUT_LOW) | ||
| reg |= ITE_GPIO_LED_OUTPUT_LOW; | ||
|
|
||
| if (led_ctrl & ITE_LED_SHORT_LOW_PULSE) | ||
| reg |= ITE_GPIO_LED_SHORT_LOW_PULSE; | ||
|
|
||
| reg |= ITE_GPIO_LED_FREQ_SEL(freq); | ||
| pnp_write_config(gpiodev, ITE_GPIO_REG_LED_CONTROL(led_no), reg); | ||
|
|
||
| reg = ITE_GPIO_LED_PIN_LOC(set, pin); | ||
| pnp_write_config(gpiodev, ITE_GPIO_REG_LED_PINMAP(led_no), reg); | ||
|
|
||
| pnp_exit_conf_state(gpiodev); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,75 @@ | ||
| /* SPDX-License-Identifier: GPL-2.0-or-later */ | ||
|
|
||
| #ifndef SUPERIO_ITE_COMMON_GPIO_PRE_RAM_H | ||
| #define SUPERIO_ITE_COMMON_GPIO_PRE_RAM_H | ||
|
|
||
| #include <device/pnp_type.h> | ||
| #include <stdint.h> | ||
|
|
||
| #define ITE_GPIO_REG_SELECT(x) (0x25 + (x)) | ||
|
|
||
| enum ite_gpio_control { | ||
| ITE_GPIO_CONTROL_DEFAULT = 0, | ||
| ITE_GPIO_POL_INVERT = (1 << 0), | ||
| ITE_GPIO_PULLUP_ENABLE = (1 << 1), | ||
| }; | ||
|
|
||
| enum ite_gpio_direction { | ||
| ITE_GPIO_INPUT, | ||
| ITE_GPIO_OUTPUT | ||
| }; | ||
|
|
||
| enum ite_gpio_mode { | ||
| ITE_GPIO_ALT_FN_MODE, | ||
| ITE_GPIO_SIMPLE_IO_MODE | ||
| }; | ||
|
|
||
| /* There are two GP LED blink register sets */ | ||
| enum ite_gpio_led { | ||
| ITE_GPIO_LED_1, | ||
| ITE_GPIO_LED_2 | ||
| }; | ||
|
|
||
| enum ite_led_control { | ||
| ITE_LED_CONTROL_DEFAULT = 0, | ||
| ITE_LED_SHORT_LOW_PULSE = (1 << 0), | ||
| ITE_LED_OUTPUT_LOW = (1 << 1), | ||
| /* | ||
| * Only for ITE SIOs with 5-bit frequency selection. | ||
| * When enabled, the LED pin mapping register is cleared when PANSWH# is low for over 4s. | ||
| */ | ||
| ITE_LED_PINMAP_CLEAR = (1 << 2), | ||
| }; | ||
|
|
||
| enum ite_led_frequency { | ||
| /* Most ITE SIOs have 2-bit frequency selection */ | ||
| ITE_LED_FREQ_4HZ = 0, | ||
| ITE_LED_FREQ_1HZ = 1, | ||
| ITE_LED_FREQ_0P25HZ = 2, | ||
| ITE_LED_FREQ_0P125HZ = 3, | ||
| /* ITE SIOs with 5-bit frequency selection: IT8625, IT8613 */ | ||
| ITE_LED_FREQ_4HZ_DUTY_50 = 0, | ||
| ITE_LED_FREQ_1HZ_DUTY_50 = 1, | ||
| ITE_LED_FREQ_0P25HZ_DUTY_50 = 2, | ||
| ITE_LED_FREQ_2HZ_DUTY_50 = 3, | ||
| ITE_LED_FREQ_0P25HZ_DUTY_25 = 4, | ||
| ITE_LED_FREQ_0P25HZ_DUTY_75 = 5, | ||
| ITE_LED_FREQ_0P125HZ_DUTY_25 = 6, | ||
| ITE_LED_FREQ_0P125HZ_DUTY_75 = 7, | ||
| ITE_LED_FREQ_0P4HZ_DUTY_20 = 8, | ||
| ITE_LED_FREQ_0P5HZ_DUTY_50 = 16, | ||
| ITE_LED_FREQ_0P125HZ_DUTY_50 = 24, | ||
| }; | ||
|
|
||
| void ite_gpio_setup(pnp_devfn_t gpiodev, u8 gpio_num, | ||
| enum ite_gpio_direction output, | ||
| enum ite_gpio_mode enable, | ||
| u8 gpio_ctrl); | ||
|
|
||
| void ite_gpio_setup_led(pnp_devfn_t gpiodev, u8 gpio_num, | ||
| enum ite_gpio_led led_no, | ||
| enum ite_led_frequency freq, | ||
| u8 led_ctrl); | ||
|
|
||
|
|
||
| #endif /* SUPERIO_ITE_COMMON_PRE_RAM_H */ | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not a dealbreaker but might confuse someone, sometime
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's a cherry pick, I'm not sure I should touch that or it will become a merge conflict