-
Notifications
You must be signed in to change notification settings - Fork 6.9k
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
[topic-gpio] samples: drivers: espi: Migrate to new gpio API #22154
[topic-gpio] samples: drivers: espi: Migrate to new gpio API #22154
Conversation
This commit makes following changes to GPIO dt-bindings flags: - Added GPIO_ACTIVE_LOW, GPIO_ACTIVE_HIGH to indicate pin active state. - Added GPIO_OPEN_DRAIN, GPIO_OPEN_SOURCE to configure single ended pin driving mode. - Added GPIO_PULL_UP, GPIO_PULL_DOWN flags. - GPIO_INPUT, GPIO_OUTPUT to configure pin as input or output. - Added GPIO_OUTPUT_LOW, GPIO_OUTPUT_HIGH flags to initialize output in low or high state. - reworked GPIO_INT_* flags to configure pin interrupts. - following flags were deprecated: GPIO_DIR_*, GPIO_DS_DISCONNECT_*, GPIO_PUD_*, GPIO_INT_ACTIVE_*, GPIO_INT_DOUBLE_EDGE, GPIO_POL_*. To be aligned with Linux DTS standard any GPIO flags that should not be used in DTS files are moved from include/dt-bindings/gpio/gpio.h file to include/drivers/gpio.h with an exception of several old flags which removal would cause DTS compilation errors. Those remaining old flags will be removed from include/dt-bindings/gpio/gpio.h at a later stage. Signed-off-by: Piotr Mienkowski <piotr.mienkowski@gmail.com>
This commit adds following functions which work with pin logical levels (take into account GPIO_ACTIVE_LOW flag): - gpio_port_get, gpio_port_set_masked, gpio_port_set_bits, gpio_port_clear_bits, gpio_port_set_clr_bits - gpio_pin_get, gpio_pin_set Functions which work with pin physical levels: - gpio_port_get_raw, gpio_port_set_masked_raw, gpio_port_set_bits_raw, gpio_port_clear_bits_raw, gpio_port_set_clr_bits_raw - gpio_pin_get_raw, gpio_pin_set_raw As well as functions: - gpio_port_toggle_bits, gpio_pin_toggle_bits Signed-off-by: Piotr Mienkowski <piotr.mienkowski@gmail.com>
This commit moves interrupt configuration for a single pin from gpio_pin_configure to gpio_pin_interrupt_configure function. Signed-off-by: Piotr Mienkowski <piotr.mienkowski@gmail.com>
Both pin sets and values encoding pin values are ultimately represented by 32-bit unsigned integers. Provide typedefs that make the role of a parameter explicit. Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no> Signed-off-by: Piotr Mienkowski <piotr.mienkowski@gmail.com>
gpio_api_1pin testcase verifies following new GPIO API functionality: - pin active level flags - input/output configuration flags - pin drive flags - gpio_port_*, gpio_pin_* functions - pin interrupts The test is using only 1 GPIO pin (defined in DTS as LED0) and relies on the ability of the driver to configure pin simultanously as in/out. Drivers that do not allow to configure pins in in/out mode should still pass the test, however, most of the testcases will be skipped. The test does not require any modifications to board hardware. Signed-off-by: Piotr Mienkowski <piotr.mienkowski@gmail.com>
Update driver code and board files to use new GPIO configuration flags such as GPIO_ACTIVE_LOW. Also add implementation of new port_* driver API as well as gpio_pin_interrupt_configure function. Tested on efr32_slwstk6061a board. Signed-off-by: Piotr Mienkowski <piotr.mienkowski@gmail.com>
Update driver code and board files to use new GPIO configuration flags such as GPIO_ACTIVE_LOW. Also add implementation of new port_* driver API as well as gpio_pin_interrupt_configure function. Tested on sam_e70_xplained board. Signed-off-by: Piotr Mienkowski <piotr.mienkowski@gmail.com>
Update driver code and board files to use new GPIO configuration flags such as GPIO_ACTIVE_LOW. Also add implementation of new port_* driver API as well as gpio_pin_interrupt_configure function. Tested on nrf52840_pca10056 board. Signed-off-by: Piotr Mienkowski <piotr.mienkowski@gmail.com> Signed-off-by: Peter Bigot <peter.bigot@nordicsemi.no>
Update driver code and board files to use new GPIO configuration flags such as GPIO_ACTIVE_LOW. Also add implementation of new port_* driver API as well as gpio_pin_interrupt_configure function. Tested on frdm_k64f board. Signed-off-by: Piotr Mienkowski <piotr.mienkowski@gmail.com>
Update gpio_pin_configure() to take into account GPIO flags defined by the devicetree. Signed-off-by: Piotr Mienkowski <piotr.mienkowski@gmail.com>
Update gpio_pin_configure() to take into account GPIO flags defined by the devicetree. Use gpio_pin_get/gpio_pin_set to verify reading/writing of logical pin values. Use gpio_pin_interrupt_configure() to configure interrupts. Signed-off-by: Piotr Mienkowski <piotr.mienkowski@gmail.com>
Change when we clear interrupt status to happen before we handle the callbacks. As the callbacks might manipluate the GPIO state and cause a GPIO interrupt. If we clear interrupt status after than we might miss an interrupt. Also only clear interrupts for interrupts that are we have enabled and that were reported when we read from the interrupt status. Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
Move z_impl_gpio_pin_interrupt_configure before gpio_pin_configure so we can utilize z_impl_gpio_pin_interrupt_configure in gpio_pin_configure in the future. Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
Move handling of logical flag support into gpio_pin_configure and gpio_pin_interrupt_configure. This way drivers don't need to know anything about logical levels. Signed-off-by: Kumar Gala <kumar.gala@linaro.org> Signed-off-by: Piotr Mienkowski <piotr.mienkowski@gmail.com>
Remove handling for GPIO_INT_LEVELS_LOGICAL in driver now that we do that in gpio_pin_interrupt_configure and gpio_pin_configure. Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
Remove handling for GPIO_INT_LEVELS_LOGICAL in driver now that we do that in gpio_pin_interrupt_configure and gpio_pin_configure. Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
Remove handling for GPIO_INT_LEVELS_LOGICAL in driver now that we do that in gpio_pin_interrupt_configure and gpio_pin_configure. Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
Remove handling for GPIO_INT_LEVELS_LOGICAL in driver now that we do that in gpio_pin_interrupt_configure and gpio_pin_configure. Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
Add gpio_driver_data as the first element in the driver data as the gpio core expects this. Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
Add gpio_driver_data as the first element in the driver data as the gpio core expects this. Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
Add gpio_driver_data as the first element in the driver data as the gpio core expects this. Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
Add gpio_driver_data as the first element in the driver data as the gpio core expects this. Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
Add gpio_driver_data as the first element in the driver data as the gpio core expects this. Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
Add gpio_driver_data as the first element in the driver data as the gpio core expects this. Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
Add gpio_driver_data as the first element in the driver data as the gpio core expects this. Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
Add gpio_driver_data as the first element in the driver data as the gpio core expects this. Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
Add gpio_driver_data as the first element in the driver data as the gpio core expects this. Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
Add gpio_driver_data as the first element in the driver data as the gpio core expects this. Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
Add gpio_driver_data as the first element in the driver data as the gpio core expects this. Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
Add gpio_driver_data as the first element in the driver data as the gpio core expects this. Signed-off-by: Kumar Gala <kumar.gala@linaro.org>
All checks are passing now. Tip: The bot edits this comment instead of posting a new one, so you can check the comment's history to see earlier messages. |
@albertofloyd thank you. Can you fix the checkpatch issues please? |
3881eeb
to
96d7f97
Compare
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.
Block pending review of devicetree binding approach.
96d7f97
to
1cdb0c1
Compare
Define device tree bindings for eSPI pins required for a simple eSPI handshake between master and slave. Signed-off-by: Jose Alberto Meza <jose.a.meza.arellano@intel.com>
Define pins used for eSPI handshake in MEC1501 boards. Signed-off-by: Jose Alberto Meza <jose.a.meza.arellano@intel.com>
Use device tree definitions to simplify KConfig. Remove per board project configurations. Signed-off-by: Jose Alberto Meza <jose.a.meza.arellano@intel.com>
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.
Thanks, the devicetree looks more like what I expected, but there are a few additional changes.
@@ -0,0 +1,19 @@ | |||
# Copyright (c) 2018, Intel Corporation |
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.
Please update copyright date since this is a new file.
if (ret) { | ||
printk("RSMRST_PWRGD timeout!\n"); | ||
return; | ||
} | ||
|
||
ret = gpio_pin_write(gpio_dev1, CONFIG_ESPI_INIT_PIN, 1); | ||
ret = gpio_pin_write(gpio_dev1, DT_GPIO_ESPI_PINS_RSM_GPIOS_PIN, 1); |
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.
Should be gpio_pin_set
.
ret = gpio_pin_configure(gpio_dev0, CONFIG_PWRGD_PIN, GPIO_DIR_IN); | ||
#ifdef DT_GPIO_ESPI_PINS_PWRG_GPIOS_CONTROLLER | ||
ret = gpio_pin_configure(gpio_dev0, DT_GPIO_ESPI_PINS_PWRG_GPIOS_PIN, | ||
DT_GPIO_ESPI_PINS_PWRG_GPIOS_FLAGS); |
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.
This needs to have a direction, probably GPIO_OUTPUT_ACTIVE
, ORd in.
pins { | ||
compatible = "gpio-espi"; | ||
/* MCHP_GPIO_012 */ | ||
pwrg-gpios = <&gpioa 10 0>; |
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.
Specify GPIO_ACTIVE_LOW
or GPIO_ACTIVE_HIGH
, for all gpio selectors.
pwrg-gpios: | ||
type: phandle-array | ||
required: true | ||
description: Board GPIO used to detect power rails are stable. |
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.
Document whether this is an input or an output of the device (I probably guessed wrong in my comment at the configuration call where I assumed it was a processor output acting like a switch) and its nominal active level.
@@ -12,12 +12,15 @@ | |||
#include <drivers/gpio.h> | |||
#include <drivers/espi.h> | |||
|
|||
#ifdef CONFIG_ESPI_GPIO_DEV_NEEDED | |||
#ifdef DT_GPIO_ESPI_PINS_PWRG_GPIOS_CONTROLLER | |||
static struct device *gpio_dev0; |
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.
It would be nice if this were pwrg_gpio_dev
(similarly rsm_gpio
below) so maintainers don't have to guess what the numbering indicates.
@albertofloyd This needs to be rebased, and the review comments addressed. If you can't get to this I will rebase it and modify the code if you wish. We need to get this to a mergeable state in the next two days to meet deadline. |
Looking closely there are some problems with this.
After rebasing the sample does not build due to a lingering reference to This sample doesn't need to be converted to devicetree at the same time as converting new GPIO API. For integration testing and branch cleanup I'm proposing to use pabigot@6593d39 which is far simpler and allows us to make progress on the topic branch. I'll issue a PR for https://github.com/pabigot/zephyr/commits/tg/espi which contains that commit as soon as the topic branch rebase that's in progress has been completed. This will allow time for a more careful determination of how devicetree information for the eSPI infrastructure should be implemented. For now I'm marking this DNM. |
I think this makes sense. The conversion to DT will probably require additional discussions, including @galak and others. Using #22298 instead allows us to move forward with the GPIO work and delay the transition of this driver to DT. |
Agreed. Please file an issue to make sure it isn't forgotten. |
Use device tree definitions to simplify KConfig.
Remove per board project configurations.