mirror of
https://github.com/zephyrproject-rtos/zephyr
synced 2025-09-08 14:32:36 +00:00
The file gpio_dw_registers.h already had the 4-port GPIO registers defined, yet the gpio_dw.c implementation didn't support it properly. There are 4 ports here, not 2, and only PORTA can support interrupts and debounce. On the em_starterkit board, for example, PORTA has 3 bits for buttons: A, L and R. The other 3 ports should not be used with interrupts & debounce. I've re-worked this file to derive the port number from the base address given. The lower 6 bits are divided by 12 to derive the port number. From this, the registers EXT_PORTA, EXT_PORTB, EXT_PORTC or EXT_PORTD can be read. Also, for those ports that don't support interrupts, set irq_num to 0, and that code will be avoided. I've verified that I can access GPIO now correctly on the EM Starterkit. The em_starterkit board support will be submitted soon but I'm staging in this change first. Change-Id: I98dbe083e03e046b40e07b4b14a99a39a6d0f0be Signed-off-by: Chuck Jordan <cjordan@synopsys.com>
62 lines
1.4 KiB
C
62 lines
1.4 KiB
C
/*
|
|
* Copyright (c) 2015 Intel Corporation.
|
|
*
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
* you may not use this file except in compliance with the License.
|
|
* You may obtain a copy of the License at
|
|
*
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
*
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
* See the License for the specific language governing permissions and
|
|
* limitations under the License.
|
|
*/
|
|
|
|
#include <stdint.h>
|
|
#include <gpio.h>
|
|
#include "gpio_dw_registers.h"
|
|
|
|
#ifdef CONFIG_PCI
|
|
#include <pci/pci.h>
|
|
#include <pci/pci_mgr.h>
|
|
#endif /* CONFIG_PCI */
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
extern int gpio_dw_initialize(struct device *port);
|
|
typedef void (*gpio_config_irq_t)(struct device *port);
|
|
|
|
struct gpio_dw_config {
|
|
uint32_t base_addr;
|
|
uint32_t bits;
|
|
uint32_t irq_num; /* set to 0 if GPIO port cannot interrupt */
|
|
|
|
#ifdef CONFIG_PCI
|
|
struct pci_dev_info pci_dev;
|
|
#endif /* CONFIG_PCI */
|
|
gpio_config_irq_t config_func;
|
|
|
|
#ifdef CONFIG_GPIO_DW_SHARED_IRQ
|
|
char *shared_irq_dev_name;
|
|
#endif /* CONFIG_GPIO_DW_SHARED_IRQ */
|
|
|
|
#ifdef CONFIG_GPIO_DW_CLOCK_GATE
|
|
void *clock_data;
|
|
#endif
|
|
};
|
|
|
|
struct gpio_dw_runtime {
|
|
#ifdef CONFIG_GPIO_DW_CLOCK_GATE
|
|
struct device *clock;
|
|
#endif
|
|
sys_slist_t callbacks;
|
|
};
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|