2019-04-10 09:43:42 +02:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2019 Intel Corporation
|
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
|
|
*/
|
|
|
|
|
2020-03-24 21:45:46 +01:00
|
|
|
#define DT_DRV_COMPAT microchip_xec_gpio
|
|
|
|
|
2019-04-10 09:43:42 +02:00
|
|
|
#include <errno.h>
|
2022-05-06 10:25:46 +02:00
|
|
|
#include <zephyr/device.h>
|
2022-10-11 20:05:39 +02:00
|
|
|
#include <zephyr/irq.h>
|
2022-05-06 10:25:46 +02:00
|
|
|
#include <zephyr/drivers/gpio.h>
|
|
|
|
#include <zephyr/sys/sys_io.h>
|
2019-04-10 09:43:42 +02:00
|
|
|
#include <soc.h>
|
|
|
|
|
2022-10-21 20:18:01 +02:00
|
|
|
#include <zephyr/drivers/gpio/gpio_utils.h>
|
2019-04-10 09:43:42 +02:00
|
|
|
|
2021-08-05 20:32:48 +02:00
|
|
|
#define XEC_GPIO_EDGE_DLY_COUNT 4
|
2021-07-22 15:57:41 +02:00
|
|
|
|
2019-10-01 20:39:00 +02:00
|
|
|
#define GPIO_IN_BASE(config) \
|
2020-05-27 18:26:57 +02:00
|
|
|
((__IO uint32_t *)(GPIO_PARIN_BASE + (config->port_num << 2)))
|
2019-10-01 20:39:00 +02:00
|
|
|
|
|
|
|
#define GPIO_OUT_BASE(config) \
|
2020-05-27 18:26:57 +02:00
|
|
|
((__IO uint32_t *)(GPIO_PAROUT_BASE + (config->port_num << 2)))
|
2019-04-10 09:43:42 +02:00
|
|
|
|
2020-05-27 18:26:57 +02:00
|
|
|
static const uint32_t valid_ctrl_masks[NUM_MCHP_GPIO_PORTS] = {
|
2019-04-10 09:43:42 +02:00
|
|
|
(MCHP_GPIO_PORT_A_BITMAP),
|
|
|
|
(MCHP_GPIO_PORT_B_BITMAP),
|
|
|
|
(MCHP_GPIO_PORT_C_BITMAP),
|
|
|
|
(MCHP_GPIO_PORT_D_BITMAP),
|
|
|
|
(MCHP_GPIO_PORT_E_BITMAP),
|
|
|
|
(MCHP_GPIO_PORT_F_BITMAP)
|
|
|
|
};
|
|
|
|
|
|
|
|
struct gpio_xec_data {
|
2019-09-20 14:36:21 +02:00
|
|
|
/* gpio_driver_data needs to be first */
|
|
|
|
struct gpio_driver_data common;
|
2019-04-10 09:43:42 +02:00
|
|
|
/* port ISR callback routine address */
|
|
|
|
sys_slist_t callbacks;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct gpio_xec_config {
|
2019-12-11 17:45:17 +01:00
|
|
|
/* gpio_driver_config needs to be first */
|
|
|
|
struct gpio_driver_config common;
|
2020-05-27 18:26:57 +02:00
|
|
|
__IO uint32_t *pcr1_base;
|
|
|
|
uint8_t girq_id;
|
|
|
|
uint32_t port_num;
|
|
|
|
uint32_t flags;
|
2019-04-10 09:43:42 +02:00
|
|
|
};
|
|
|
|
|
2020-10-14 22:10:16 +02:00
|
|
|
/*
|
|
|
|
* notes: The GPIO parallel output bits are read-only until the
|
|
|
|
* Alternate-Output-Disable (AOD) bit is set in the pin's control
|
|
|
|
* register. To preload a parallel output value to prevent certain
|
|
|
|
* classes of glitching for output pins we must:
|
|
|
|
* Set GPIO control AOD=1 with the pin direction set to input.
|
|
|
|
* Program the new pin value in the respective GPIO parallel output
|
|
|
|
* register.
|
|
|
|
* Program other GPIO control bits except direction.
|
|
|
|
* Last step set the GPIO control register direction bit to output.
|
|
|
|
*/
|
2020-04-30 20:33:38 +02:00
|
|
|
static int gpio_xec_configure(const struct device *dev,
|
2020-01-30 19:12:39 +01:00
|
|
|
gpio_pin_t pin, gpio_flags_t flags)
|
2019-04-10 09:43:42 +02:00
|
|
|
{
|
2020-05-28 20:44:16 +02:00
|
|
|
const struct gpio_xec_config *config = dev->config;
|
2020-05-27 18:26:57 +02:00
|
|
|
__IO uint32_t *current_pcr1;
|
|
|
|
uint32_t pcr1 = 0U;
|
|
|
|
uint32_t mask = 0U;
|
2019-04-10 09:43:42 +02:00
|
|
|
|
|
|
|
/* Validate pin number range in terms of current port */
|
2019-10-01 20:39:00 +02:00
|
|
|
if ((valid_ctrl_masks[config->port_num] & BIT(pin)) == 0U) {
|
2019-04-10 09:43:42 +02:00
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
2019-10-01 20:39:00 +02:00
|
|
|
/* Don't support "open source" mode */
|
|
|
|
if (((flags & GPIO_SINGLE_ENDED) != 0U) &&
|
|
|
|
((flags & GPIO_LINE_OPEN_DRAIN) == 0U)) {
|
|
|
|
return -ENOTSUP;
|
2019-04-10 09:43:42 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/* The flags contain options that require touching registers in the
|
|
|
|
* PCRs for a given GPIO. There are no GPIO modules in Microchip SOCs!
|
2020-10-14 22:10:16 +02:00
|
|
|
* Keep direction as input until last.
|
|
|
|
* Clear input pad disable allowing input pad to operate.
|
2021-03-17 19:24:00 +01:00
|
|
|
* Clear Power gate to allow pads to operate.
|
2019-04-10 09:43:42 +02:00
|
|
|
*/
|
|
|
|
mask |= MCHP_GPIO_CTRL_DIR_MASK;
|
2019-09-27 03:22:34 +02:00
|
|
|
mask |= MCHP_GPIO_CTRL_INPAD_DIS_MASK;
|
2021-03-17 19:24:00 +01:00
|
|
|
mask |= MCHP_GPIO_CTRL_PWRG_MASK;
|
2023-08-05 02:46:52 +02:00
|
|
|
mask |= MCHP_GPIO_CTRL_AOD_MASK;
|
|
|
|
|
|
|
|
current_pcr1 = config->pcr1_base + pin;
|
|
|
|
|
|
|
|
if (flags == GPIO_DISCONNECTED) {
|
|
|
|
pcr1 |= MCHP_GPIO_CTRL_PWRG_OFF;
|
|
|
|
*current_pcr1 = (*current_pcr1 & ~mask) | pcr1;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
pcr1 = MCHP_GPIO_CTRL_PWRG_VTR_IO;
|
|
|
|
|
|
|
|
/* Always enable input pad */
|
|
|
|
if (*current_pcr1 & BIT(MCHP_GPIO_CTRL_INPAD_DIS_POS)) {
|
|
|
|
*current_pcr1 &= ~BIT(MCHP_GPIO_CTRL_INPAD_DIS_POS);
|
|
|
|
}
|
2019-04-10 09:43:42 +02:00
|
|
|
|
|
|
|
/* Figure out the pullup/pulldown configuration and keep it in the
|
|
|
|
* pcr1 variable
|
|
|
|
*/
|
|
|
|
mask |= MCHP_GPIO_CTRL_PUD_MASK;
|
|
|
|
|
2019-10-01 20:39:00 +02:00
|
|
|
if ((flags & GPIO_PULL_UP) != 0U) {
|
2019-04-10 09:43:42 +02:00
|
|
|
/* Enable the pull and select the pullup resistor. */
|
|
|
|
pcr1 |= MCHP_GPIO_CTRL_PUD_PU;
|
2019-10-01 20:39:00 +02:00
|
|
|
} else if ((flags & GPIO_PULL_DOWN) != 0U) {
|
2019-04-10 09:43:42 +02:00
|
|
|
/* Enable the pull and select the pulldown resistor */
|
|
|
|
pcr1 |= MCHP_GPIO_CTRL_PUD_PD;
|
|
|
|
}
|
|
|
|
|
2019-10-01 20:39:00 +02:00
|
|
|
/* Push-pull or open drain */
|
|
|
|
mask |= MCHP_GPIO_CTRL_BUFT_MASK;
|
|
|
|
|
|
|
|
if ((flags & GPIO_OPEN_DRAIN) != 0U) {
|
|
|
|
/* Open drain */
|
|
|
|
pcr1 |= MCHP_GPIO_CTRL_BUFT_OPENDRAIN;
|
|
|
|
} else {
|
|
|
|
/* Push-pull */
|
|
|
|
pcr1 |= MCHP_GPIO_CTRL_BUFT_PUSHPULL;
|
|
|
|
}
|
|
|
|
|
2020-05-07 06:32:07 +02:00
|
|
|
if ((flags & GPIO_OUTPUT) != 0U) {
|
2023-08-05 02:46:52 +02:00
|
|
|
mask |= MCHP_GPIO_CTRL_OUTV_HI;
|
2020-05-07 06:32:07 +02:00
|
|
|
if ((flags & GPIO_OUTPUT_INIT_HIGH) != 0U) {
|
2023-08-05 02:46:52 +02:00
|
|
|
pcr1 |= BIT(MCHP_GPIO_CTRL_OUTVAL_POS);
|
2020-05-07 06:32:07 +02:00
|
|
|
} else if ((flags & GPIO_OUTPUT_INIT_LOW) != 0U) {
|
2023-08-05 02:46:52 +02:00
|
|
|
pcr1 &= ~BIT(MCHP_GPIO_CTRL_OUTVAL_POS);
|
|
|
|
} else { /* Copy current input state to output state */
|
|
|
|
if ((*current_pcr1 & MCHP_GPIO_CTRL_PWRG_MASK) ==
|
|
|
|
MCHP_GPIO_CTRL_PWRG_OFF) {
|
|
|
|
*current_pcr1 = (*current_pcr1 &
|
|
|
|
~MCHP_GPIO_CTRL_PWRG_MASK) |
|
|
|
|
MCHP_GPIO_CTRL_PWRG_VTR_IO;
|
|
|
|
}
|
|
|
|
if (*current_pcr1 & BIT(MCHP_GPIO_CTRL_INPAD_VAL_POS)) {
|
|
|
|
pcr1 |= BIT(MCHP_GPIO_CTRL_OUTVAL_POS);
|
|
|
|
} else {
|
|
|
|
pcr1 &= ~BIT(MCHP_GPIO_CTRL_OUTVAL_POS);
|
|
|
|
}
|
2020-05-07 06:32:07 +02:00
|
|
|
}
|
2020-10-14 22:10:16 +02:00
|
|
|
|
2023-08-05 02:46:52 +02:00
|
|
|
pcr1 |= MCHP_GPIO_CTRL_DIR_OUTPUT;
|
2020-05-07 06:32:07 +02:00
|
|
|
}
|
|
|
|
|
2023-08-05 02:46:52 +02:00
|
|
|
*current_pcr1 = (*current_pcr1 & ~mask) | pcr1;
|
|
|
|
/* Control output bit becomes ready only and parallel output r/w */
|
|
|
|
*current_pcr1 = *current_pcr1 | BIT(MCHP_GPIO_CTRL_AOD_POS);
|
|
|
|
|
2019-10-01 20:39:00 +02:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2020-04-30 20:33:38 +02:00
|
|
|
static int gpio_xec_pin_interrupt_configure(const struct device *dev,
|
|
|
|
gpio_pin_t pin,
|
|
|
|
enum gpio_int_mode mode,
|
|
|
|
enum gpio_int_trig trig)
|
2019-10-01 20:39:00 +02:00
|
|
|
{
|
2020-05-28 20:44:16 +02:00
|
|
|
const struct gpio_xec_config *config = dev->config;
|
2020-05-27 18:26:57 +02:00
|
|
|
__IO uint32_t *current_pcr1;
|
|
|
|
uint32_t pcr1 = 0U;
|
|
|
|
uint32_t mask = 0U;
|
|
|
|
uint32_t gpio_interrupt = 0U;
|
2019-10-01 20:39:00 +02:00
|
|
|
|
|
|
|
/* Validate pin number range in terms of current port */
|
|
|
|
if ((valid_ctrl_masks[config->port_num] & BIT(pin)) == 0U) {
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Check if GPIO port supports interrupts */
|
|
|
|
if ((mode != GPIO_INT_MODE_DISABLED) &&
|
|
|
|
((config->flags & GPIO_INT_ENABLE) == 0U)) {
|
|
|
|
return -ENOTSUP;
|
|
|
|
}
|
|
|
|
|
2020-05-09 00:03:21 +02:00
|
|
|
/* Disable interrupt in the EC aggregator */
|
|
|
|
MCHP_GIRQ_ENCLR(config->girq_id) = BIT(pin);
|
|
|
|
|
2022-02-24 13:00:55 +01:00
|
|
|
/* Assemble mask for level/edge triggered interrupts */
|
2019-04-10 09:43:42 +02:00
|
|
|
mask |= MCHP_GPIO_CTRL_IDET_MASK;
|
|
|
|
|
2019-10-01 20:39:00 +02:00
|
|
|
if (mode == GPIO_INT_MODE_DISABLED) {
|
|
|
|
/* Explicitly disable interrupts, otherwise the configuration
|
|
|
|
* results in level triggered/low interrupts
|
|
|
|
*/
|
|
|
|
pcr1 |= MCHP_GPIO_CTRL_IDET_DISABLE;
|
|
|
|
} else {
|
|
|
|
if (mode == GPIO_INT_MODE_LEVEL) {
|
|
|
|
/* Enable level interrupts */
|
|
|
|
if (trig == GPIO_INT_TRIG_HIGH) {
|
2019-04-10 09:43:42 +02:00
|
|
|
gpio_interrupt = MCHP_GPIO_CTRL_IDET_LVL_HI;
|
|
|
|
} else {
|
|
|
|
gpio_interrupt = MCHP_GPIO_CTRL_IDET_LVL_LO;
|
|
|
|
}
|
2019-10-01 20:39:00 +02:00
|
|
|
} else {
|
|
|
|
/* Enable edge interrupts */
|
|
|
|
switch (trig) {
|
|
|
|
case GPIO_INT_TRIG_LOW:
|
|
|
|
gpio_interrupt = MCHP_GPIO_CTRL_IDET_FEDGE;
|
|
|
|
break;
|
|
|
|
case GPIO_INT_TRIG_HIGH:
|
|
|
|
gpio_interrupt = MCHP_GPIO_CTRL_IDET_REDGE;
|
|
|
|
break;
|
|
|
|
case GPIO_INT_TRIG_BOTH:
|
|
|
|
gpio_interrupt = MCHP_GPIO_CTRL_IDET_BEDGE;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
2019-04-10 09:43:42 +02:00
|
|
|
}
|
2019-10-01 20:39:00 +02:00
|
|
|
|
2019-04-10 09:43:42 +02:00
|
|
|
pcr1 |= gpio_interrupt;
|
|
|
|
}
|
2019-10-01 20:39:00 +02:00
|
|
|
|
2019-04-10 09:43:42 +02:00
|
|
|
/* Now write contents of pcr1 variable to the PCR1 register that
|
|
|
|
* corresponds to the GPIO being configured
|
|
|
|
*/
|
|
|
|
current_pcr1 = config->pcr1_base + pin;
|
|
|
|
*current_pcr1 = (*current_pcr1 & ~mask) | pcr1;
|
2021-08-05 20:32:48 +02:00
|
|
|
/* delay for HW to synchronize after it ungates its clock */
|
|
|
|
for (int i = 0; i < XEC_GPIO_EDGE_DLY_COUNT; i++) {
|
|
|
|
(void)*current_pcr1;
|
|
|
|
}
|
2019-04-10 09:43:42 +02:00
|
|
|
|
2020-05-09 00:03:21 +02:00
|
|
|
if (mode != GPIO_INT_MODE_DISABLED) {
|
|
|
|
/* We enable the interrupts in the EC aggregator so that the
|
|
|
|
* result can be forwarded to the ARM NVIC
|
|
|
|
*/
|
|
|
|
MCHP_GIRQ_SRC_CLR(config->girq_id, pin);
|
|
|
|
MCHP_GIRQ_ENSET(config->girq_id) = BIT(pin);
|
|
|
|
}
|
|
|
|
|
2019-04-10 09:43:42 +02:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2020-04-30 20:33:38 +02:00
|
|
|
static int gpio_xec_port_set_masked_raw(const struct device *dev,
|
|
|
|
uint32_t mask,
|
2020-05-27 18:26:57 +02:00
|
|
|
uint32_t value)
|
2019-10-01 20:39:00 +02:00
|
|
|
{
|
2020-05-28 20:44:16 +02:00
|
|
|
const struct gpio_xec_config *config = dev->config;
|
2019-10-01 20:39:00 +02:00
|
|
|
|
|
|
|
/* GPIO output registers are used for writing */
|
2020-05-27 18:26:57 +02:00
|
|
|
__IO uint32_t *gpio_base = GPIO_OUT_BASE(config);
|
2019-10-01 20:39:00 +02:00
|
|
|
|
|
|
|
*gpio_base = (*gpio_base & ~mask) | (mask & value);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2020-04-30 20:33:38 +02:00
|
|
|
static int gpio_xec_port_set_bits_raw(const struct device *dev, uint32_t mask)
|
2019-10-01 20:39:00 +02:00
|
|
|
{
|
2020-05-28 20:44:16 +02:00
|
|
|
const struct gpio_xec_config *config = dev->config;
|
2019-10-01 20:39:00 +02:00
|
|
|
|
|
|
|
/* GPIO output registers are used for writing */
|
2020-05-27 18:26:57 +02:00
|
|
|
__IO uint32_t *gpio_base = GPIO_OUT_BASE(config);
|
2019-10-01 20:39:00 +02:00
|
|
|
|
|
|
|
*gpio_base |= mask;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2020-04-30 20:33:38 +02:00
|
|
|
static int gpio_xec_port_clear_bits_raw(const struct device *dev,
|
|
|
|
uint32_t mask)
|
2019-10-01 20:39:00 +02:00
|
|
|
{
|
2020-05-28 20:44:16 +02:00
|
|
|
const struct gpio_xec_config *config = dev->config;
|
2019-10-01 20:39:00 +02:00
|
|
|
|
|
|
|
/* GPIO output registers are used for writing */
|
2020-05-27 18:26:57 +02:00
|
|
|
__IO uint32_t *gpio_base = GPIO_OUT_BASE(config);
|
2019-10-01 20:39:00 +02:00
|
|
|
|
|
|
|
*gpio_base &= ~mask;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2020-04-30 20:33:38 +02:00
|
|
|
static int gpio_xec_port_toggle_bits(const struct device *dev, uint32_t mask)
|
2019-10-01 20:39:00 +02:00
|
|
|
{
|
2020-05-28 20:44:16 +02:00
|
|
|
const struct gpio_xec_config *config = dev->config;
|
2019-10-01 20:39:00 +02:00
|
|
|
|
|
|
|
/* GPIO output registers are used for writing */
|
2020-05-27 18:26:57 +02:00
|
|
|
__IO uint32_t *gpio_base = GPIO_OUT_BASE(config);
|
2019-10-01 20:39:00 +02:00
|
|
|
|
|
|
|
*gpio_base ^= mask;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2020-04-30 20:33:38 +02:00
|
|
|
static int gpio_xec_port_get_raw(const struct device *dev, uint32_t *value)
|
2019-04-10 09:43:42 +02:00
|
|
|
{
|
2020-05-28 20:44:16 +02:00
|
|
|
const struct gpio_xec_config *config = dev->config;
|
2019-04-10 09:43:42 +02:00
|
|
|
|
|
|
|
/* GPIO input registers are used for reading */
|
2020-05-27 18:26:57 +02:00
|
|
|
__IO uint32_t *gpio_base = GPIO_IN_BASE(config);
|
2019-04-10 09:43:42 +02:00
|
|
|
|
|
|
|
*value = *gpio_base;
|
2019-10-01 20:39:00 +02:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2020-04-30 20:33:38 +02:00
|
|
|
static int gpio_xec_manage_callback(const struct device *dev,
|
2019-08-02 11:31:51 +02:00
|
|
|
struct gpio_callback *callback, bool set)
|
2019-04-10 09:43:42 +02:00
|
|
|
{
|
2020-05-28 21:23:02 +02:00
|
|
|
struct gpio_xec_data *data = dev->data;
|
2019-04-10 09:43:42 +02:00
|
|
|
|
|
|
|
gpio_manage_callback(&data->callbacks, callback, set);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
isr: Normalize usage of device instance through ISR
The goal of this patch is to replace the 'void *' parameter by 'struct
device *' if they use such variable or just 'const void *' on all
relevant ISRs
This will avoid not-so-nice const qualifier tweaks when device instances
will be constant.
Note that only the ISR passed to IRQ_CONNECT are of interest here.
In order to do so, the script fix_isr.py below is necessary:
from pathlib import Path
import subprocess
import pickle
import mmap
import sys
import re
import os
cocci_template = """
@r_fix_isr_0
@
type ret_type;
identifier P;
identifier D;
@@
-ret_type <!fn!>(void *P)
+ret_type <!fn!>(const struct device *P)
{
...
(
const struct device *D = (const struct device *)P;
|
const struct device *D = P;
)
...
}
@r_fix_isr_1
@
type ret_type;
identifier P;
identifier D;
@@
-ret_type <!fn!>(void *P)
+ret_type <!fn!>(const struct device *P)
{
...
const struct device *D;
...
(
D = (const struct device *)P;
|
D = P;
)
...
}
@r_fix_isr_2
@
type ret_type;
identifier A;
@@
-ret_type <!fn!>(void *A)
+ret_type <!fn!>(const void *A)
{
...
}
@r_fix_isr_3
@
const struct device *D;
@@
-<!fn!>((void *)D);
+<!fn!>(D);
@r_fix_isr_4
@
type ret_type;
identifier D;
identifier P;
@@
-ret_type <!fn!>(const struct device *P)
+ret_type <!fn!>(const struct device *D)
{
...
(
-const struct device *D = (const struct device *)P;
|
-const struct device *D = P;
)
...
}
@r_fix_isr_5
@
type ret_type;
identifier D;
identifier P;
@@
-ret_type <!fn!>(const struct device *P)
+ret_type <!fn!>(const struct device *D)
{
...
-const struct device *D;
...
(
-D = (const struct device *)P;
|
-D = P;
)
...
}
"""
def find_isr(fn):
db = []
data = None
start = 0
try:
with open(fn, 'r+') as f:
data = str(mmap.mmap(f.fileno(), 0).read())
except Exception as e:
return db
while True:
isr = ""
irq = data.find('IRQ_CONNECT', start)
while irq > -1:
p = 1
arg = 1
p_o = data.find('(', irq)
if p_o < 0:
irq = -1
break;
pos = p_o + 1
while p > 0:
if data[pos] == ')':
p -= 1
elif data[pos] == '(':
p += 1
elif data[pos] == ',' and p == 1:
arg += 1
if arg == 3:
isr += data[pos]
pos += 1
isr = isr.strip(',\\n\\t ')
if isr not in db and len(isr) > 0:
db.append(isr)
start = pos
break
if irq < 0:
break
return db
def patch_isr(fn, isr_list):
if len(isr_list) <= 0:
return
for isr in isr_list:
tmplt = cocci_template.replace('<!fn!>', isr)
with open('/tmp/isr_fix.cocci', 'w') as f:
f.write(tmplt)
cmd = ['spatch', '--sp-file', '/tmp/isr_fix.cocci', '--in-place', fn]
subprocess.run(cmd)
def process_files(path):
if path.is_file() and path.suffix in ['.h', '.c']:
p = str(path.parent) + '/' + path.name
isr_list = find_isr(p)
patch_isr(p, isr_list)
elif path.is_dir():
for p in path.iterdir():
process_files(p)
if len(sys.argv) < 2:
print("You need to provide a dir/file path")
sys.exit(1)
process_files(Path(sys.argv[1]))
And is run: ./fix_isr.py <zephyr root directory>
Finally, some files needed manual fixes such.
Fixes #27399
Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
2020-06-17 14:58:56 +02:00
|
|
|
static void gpio_gpio_xec_port_isr(const struct device *dev)
|
2019-04-10 09:43:42 +02:00
|
|
|
{
|
2020-05-28 20:44:16 +02:00
|
|
|
const struct gpio_xec_config *config = dev->config;
|
2020-05-28 21:23:02 +02:00
|
|
|
struct gpio_xec_data *data = dev->data;
|
2020-05-27 18:26:57 +02:00
|
|
|
uint32_t girq_result;
|
2019-04-10 09:43:42 +02:00
|
|
|
|
|
|
|
/* Figure out which interrupts have been triggered from the EC
|
|
|
|
* aggregator result register
|
|
|
|
*/
|
|
|
|
girq_result = MCHP_GIRQ_RESULT(config->girq_id);
|
|
|
|
|
|
|
|
/* Clear source register in aggregator before firing callbacks */
|
|
|
|
REG32(MCHP_GIRQ_SRC_ADDR(config->girq_id)) = girq_result;
|
|
|
|
|
2020-06-13 02:07:29 +02:00
|
|
|
gpio_fire_callbacks(&data->callbacks, dev, girq_result);
|
2019-04-10 09:43:42 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
static const struct gpio_driver_api gpio_xec_driver_api = {
|
2020-01-30 19:12:39 +01:00
|
|
|
.pin_configure = gpio_xec_configure,
|
2019-10-01 20:39:00 +02:00
|
|
|
.port_get_raw = gpio_xec_port_get_raw,
|
|
|
|
.port_set_masked_raw = gpio_xec_port_set_masked_raw,
|
|
|
|
.port_set_bits_raw = gpio_xec_port_set_bits_raw,
|
|
|
|
.port_clear_bits_raw = gpio_xec_port_clear_bits_raw,
|
|
|
|
.port_toggle_bits = gpio_xec_port_toggle_bits,
|
|
|
|
.pin_interrupt_configure = gpio_xec_pin_interrupt_configure,
|
2019-04-10 09:43:42 +02:00
|
|
|
.manage_callback = gpio_xec_manage_callback,
|
|
|
|
};
|
|
|
|
|
2020-05-11 20:56:08 +02:00
|
|
|
#if DT_NODE_HAS_STATUS(DT_NODELABEL(gpio_000_036), okay)
|
2020-04-30 20:33:38 +02:00
|
|
|
static int gpio_xec_port000_036_init(const struct device *dev);
|
2019-04-10 09:43:42 +02:00
|
|
|
|
|
|
|
static const struct gpio_xec_config gpio_xec_port000_036_config = {
|
2019-12-11 17:45:17 +01:00
|
|
|
.common = {
|
2020-04-25 04:37:16 +02:00
|
|
|
.port_pin_mask = GPIO_PORT_PIN_MASK_FROM_DT_NODE(
|
2020-10-14 22:10:16 +02:00
|
|
|
DT_NODELABEL(gpio_000_036)),
|
2019-12-11 17:45:17 +01:00
|
|
|
},
|
2020-05-27 18:26:57 +02:00
|
|
|
.pcr1_base = (uint32_t *) DT_REG_ADDR(DT_NODELABEL(gpio_000_036)),
|
2019-04-10 09:43:42 +02:00
|
|
|
.port_num = MCHP_GPIO_000_036,
|
2020-04-25 04:37:16 +02:00
|
|
|
#if DT_IRQ_HAS_CELL(DT_NODELABEL(gpio_000_036), irq)
|
2019-04-10 09:43:42 +02:00
|
|
|
.girq_id = MCHP_GIRQ11_ID,
|
2019-10-01 20:39:00 +02:00
|
|
|
.flags = GPIO_INT_ENABLE,
|
2019-04-10 09:43:42 +02:00
|
|
|
#else
|
|
|
|
.flags = 0,
|
|
|
|
#endif
|
|
|
|
};
|
|
|
|
|
|
|
|
static struct gpio_xec_data gpio_xec_port000_036_data;
|
|
|
|
|
2020-12-10 17:20:42 +01:00
|
|
|
DEVICE_DT_DEFINE(DT_NODELABEL(gpio_000_036),
|
2020-10-14 22:10:16 +02:00
|
|
|
gpio_xec_port000_036_init,
|
2021-04-28 10:55:48 +02:00
|
|
|
NULL,
|
2020-10-14 22:10:16 +02:00
|
|
|
&gpio_xec_port000_036_data, &gpio_xec_port000_036_config,
|
2021-12-04 22:00:59 +01:00
|
|
|
PRE_KERNEL_1, CONFIG_GPIO_INIT_PRIORITY,
|
2020-10-14 22:10:16 +02:00
|
|
|
&gpio_xec_driver_api);
|
2019-04-10 09:43:42 +02:00
|
|
|
|
2020-04-30 20:33:38 +02:00
|
|
|
static int gpio_xec_port000_036_init(const struct device *dev)
|
2019-04-10 09:43:42 +02:00
|
|
|
{
|
2020-04-25 04:37:16 +02:00
|
|
|
#if DT_IRQ_HAS_CELL(DT_NODELABEL(gpio_000_036), irq)
|
2020-05-28 20:44:16 +02:00
|
|
|
const struct gpio_xec_config *config = dev->config;
|
2019-04-10 09:43:42 +02:00
|
|
|
|
|
|
|
/* Turn on the block enable in the EC aggregator */
|
|
|
|
MCHP_GIRQ_BLK_SETEN(config->girq_id);
|
|
|
|
|
2020-04-25 04:37:16 +02:00
|
|
|
IRQ_CONNECT(DT_IRQ(DT_NODELABEL(gpio_000_036), irq),
|
2020-10-14 22:10:16 +02:00
|
|
|
DT_IRQ(DT_NODELABEL(gpio_000_036), priority),
|
2020-12-10 17:20:42 +01:00
|
|
|
gpio_gpio_xec_port_isr,
|
|
|
|
DEVICE_DT_GET(DT_NODELABEL(gpio_000_036)), 0U);
|
2019-04-10 09:43:42 +02:00
|
|
|
|
2020-04-25 04:37:16 +02:00
|
|
|
irq_enable(DT_IRQ(DT_NODELABEL(gpio_000_036), irq));
|
2019-04-10 09:43:42 +02:00
|
|
|
#endif
|
|
|
|
return 0;
|
|
|
|
}
|
2020-05-11 20:56:08 +02:00
|
|
|
#endif /* DT_NODE_HAS_STATUS(DT_NODELABEL(gpio_000_036), okay) */
|
2019-04-10 09:43:42 +02:00
|
|
|
|
2020-05-11 20:56:08 +02:00
|
|
|
#if DT_NODE_HAS_STATUS(DT_NODELABEL(gpio_040_076), okay)
|
2020-04-30 20:33:38 +02:00
|
|
|
static int gpio_xec_port040_076_init(const struct device *dev);
|
2019-04-10 09:43:42 +02:00
|
|
|
|
|
|
|
static const struct gpio_xec_config gpio_xec_port040_076_config = {
|
2019-12-11 17:45:17 +01:00
|
|
|
.common = {
|
2020-04-25 04:37:16 +02:00
|
|
|
.port_pin_mask = GPIO_PORT_PIN_MASK_FROM_DT_NODE(
|
2020-10-14 22:10:16 +02:00
|
|
|
DT_NODELABEL(gpio_040_076)),
|
2019-12-11 17:45:17 +01:00
|
|
|
},
|
2020-05-27 18:26:57 +02:00
|
|
|
.pcr1_base = (uint32_t *) DT_REG_ADDR(DT_NODELABEL(gpio_040_076)),
|
2019-04-10 09:43:42 +02:00
|
|
|
.port_num = MCHP_GPIO_040_076,
|
2020-04-25 04:37:16 +02:00
|
|
|
#if DT_IRQ_HAS_CELL(DT_NODELABEL(gpio_040_076), irq)
|
2019-04-10 09:43:42 +02:00
|
|
|
.girq_id = MCHP_GIRQ10_ID,
|
2019-10-01 20:39:00 +02:00
|
|
|
.flags = GPIO_INT_ENABLE,
|
2019-04-10 09:43:42 +02:00
|
|
|
#else
|
|
|
|
.flags = 0,
|
|
|
|
#endif
|
|
|
|
};
|
|
|
|
|
|
|
|
static struct gpio_xec_data gpio_xec_port040_076_data;
|
|
|
|
|
2020-12-10 17:20:42 +01:00
|
|
|
DEVICE_DT_DEFINE(DT_NODELABEL(gpio_040_076),
|
2020-10-14 22:10:16 +02:00
|
|
|
gpio_xec_port040_076_init,
|
2021-04-28 10:55:48 +02:00
|
|
|
NULL,
|
2020-10-14 22:10:16 +02:00
|
|
|
&gpio_xec_port040_076_data, &gpio_xec_port040_076_config,
|
2021-12-04 22:00:59 +01:00
|
|
|
PRE_KERNEL_1, CONFIG_GPIO_INIT_PRIORITY,
|
2020-10-14 22:10:16 +02:00
|
|
|
&gpio_xec_driver_api);
|
2019-04-10 09:43:42 +02:00
|
|
|
|
2020-04-30 20:33:38 +02:00
|
|
|
static int gpio_xec_port040_076_init(const struct device *dev)
|
2019-04-10 09:43:42 +02:00
|
|
|
{
|
2020-04-25 04:37:16 +02:00
|
|
|
#if DT_IRQ_HAS_CELL(DT_NODELABEL(gpio_040_076), irq)
|
2020-05-28 20:44:16 +02:00
|
|
|
const struct gpio_xec_config *config = dev->config;
|
2019-04-10 09:43:42 +02:00
|
|
|
|
|
|
|
/* Turn on the block enable in the EC aggregator */
|
|
|
|
MCHP_GIRQ_BLK_SETEN(config->girq_id);
|
|
|
|
|
2020-04-25 04:37:16 +02:00
|
|
|
IRQ_CONNECT(DT_IRQ(DT_NODELABEL(gpio_040_076), irq),
|
2020-10-14 22:10:16 +02:00
|
|
|
DT_IRQ(DT_NODELABEL(gpio_040_076), priority),
|
2020-12-10 17:20:42 +01:00
|
|
|
gpio_gpio_xec_port_isr,
|
|
|
|
DEVICE_DT_GET(DT_NODELABEL(gpio_040_076)), 0U);
|
2019-04-10 09:43:42 +02:00
|
|
|
|
2020-04-25 04:37:16 +02:00
|
|
|
irq_enable(DT_IRQ(DT_NODELABEL(gpio_040_076), irq));
|
2019-04-10 09:43:42 +02:00
|
|
|
#endif
|
|
|
|
return 0;
|
|
|
|
}
|
2020-05-11 20:56:08 +02:00
|
|
|
#endif /* DT_NODE_HAS_STATUS(DT_NODELABEL(gpio_040_076), okay) */
|
2019-04-10 09:43:42 +02:00
|
|
|
|
2020-05-11 20:56:08 +02:00
|
|
|
#if DT_NODE_HAS_STATUS(DT_NODELABEL(gpio_100_136), okay)
|
2020-04-30 20:33:38 +02:00
|
|
|
static int gpio_xec_port100_136_init(const struct device *dev);
|
2019-04-10 09:43:42 +02:00
|
|
|
|
|
|
|
static const struct gpio_xec_config gpio_xec_port100_136_config = {
|
2019-12-11 17:45:17 +01:00
|
|
|
.common = {
|
2020-04-25 04:37:16 +02:00
|
|
|
.port_pin_mask = GPIO_PORT_PIN_MASK_FROM_DT_NODE(
|
2020-10-14 22:10:16 +02:00
|
|
|
DT_NODELABEL(gpio_100_136)),
|
2019-12-11 17:45:17 +01:00
|
|
|
},
|
2020-05-27 18:26:57 +02:00
|
|
|
.pcr1_base = (uint32_t *) DT_REG_ADDR(DT_NODELABEL(gpio_100_136)),
|
2019-04-10 09:43:42 +02:00
|
|
|
.port_num = MCHP_GPIO_100_136,
|
2020-04-25 04:37:16 +02:00
|
|
|
#if DT_IRQ_HAS_CELL(DT_NODELABEL(gpio_100_136), irq)
|
2019-04-10 09:43:42 +02:00
|
|
|
.girq_id = MCHP_GIRQ09_ID,
|
2019-10-01 20:39:00 +02:00
|
|
|
.flags = GPIO_INT_ENABLE,
|
2019-04-10 09:43:42 +02:00
|
|
|
#else
|
|
|
|
.flags = 0,
|
|
|
|
#endif
|
|
|
|
};
|
|
|
|
|
|
|
|
static struct gpio_xec_data gpio_xec_port100_136_data;
|
|
|
|
|
2020-12-10 17:20:42 +01:00
|
|
|
DEVICE_DT_DEFINE(DT_NODELABEL(gpio_100_136),
|
2020-10-14 22:10:16 +02:00
|
|
|
gpio_xec_port100_136_init,
|
2021-04-28 10:55:48 +02:00
|
|
|
NULL,
|
2020-10-14 22:10:16 +02:00
|
|
|
&gpio_xec_port100_136_data, &gpio_xec_port100_136_config,
|
2021-12-04 22:00:59 +01:00
|
|
|
PRE_KERNEL_1, CONFIG_GPIO_INIT_PRIORITY,
|
2020-10-14 22:10:16 +02:00
|
|
|
&gpio_xec_driver_api);
|
2019-04-10 09:43:42 +02:00
|
|
|
|
2020-04-30 20:33:38 +02:00
|
|
|
static int gpio_xec_port100_136_init(const struct device *dev)
|
2019-04-10 09:43:42 +02:00
|
|
|
{
|
2020-04-25 04:37:16 +02:00
|
|
|
#if DT_IRQ_HAS_CELL(DT_NODELABEL(gpio_100_136), irq)
|
2020-05-28 20:44:16 +02:00
|
|
|
const struct gpio_xec_config *config = dev->config;
|
2019-04-10 09:43:42 +02:00
|
|
|
|
|
|
|
/* Turn on the block enable in the EC aggregator */
|
|
|
|
MCHP_GIRQ_BLK_SETEN(config->girq_id);
|
|
|
|
|
2020-04-25 04:37:16 +02:00
|
|
|
IRQ_CONNECT(DT_IRQ(DT_NODELABEL(gpio_100_136), irq),
|
2020-10-14 22:10:16 +02:00
|
|
|
DT_IRQ(DT_NODELABEL(gpio_100_136), priority),
|
2020-12-10 17:20:42 +01:00
|
|
|
gpio_gpio_xec_port_isr,
|
|
|
|
DEVICE_DT_GET(DT_NODELABEL(gpio_100_136)), 0U);
|
2019-04-10 09:43:42 +02:00
|
|
|
|
2020-04-25 04:37:16 +02:00
|
|
|
irq_enable(DT_IRQ(DT_NODELABEL(gpio_100_136), irq));
|
2019-04-10 09:43:42 +02:00
|
|
|
#endif
|
|
|
|
return 0;
|
|
|
|
}
|
2020-05-11 20:56:08 +02:00
|
|
|
#endif /* DT_NODE_HAS_STATUS(DT_NODELABEL(gpio_100_136), okay) */
|
2019-04-10 09:43:42 +02:00
|
|
|
|
2020-05-11 20:56:08 +02:00
|
|
|
#if DT_NODE_HAS_STATUS(DT_NODELABEL(gpio_140_176), okay)
|
2020-04-30 20:33:38 +02:00
|
|
|
static int gpio_xec_port140_176_init(const struct device *dev);
|
2019-04-10 09:43:42 +02:00
|
|
|
|
|
|
|
static const struct gpio_xec_config gpio_xec_port140_176_config = {
|
2019-12-11 17:45:17 +01:00
|
|
|
.common = {
|
2020-04-25 04:37:16 +02:00
|
|
|
.port_pin_mask = GPIO_PORT_PIN_MASK_FROM_DT_NODE(
|
2020-10-14 22:10:16 +02:00
|
|
|
DT_NODELABEL(gpio_140_176)),
|
2019-12-11 17:45:17 +01:00
|
|
|
},
|
2020-05-27 18:26:57 +02:00
|
|
|
.pcr1_base = (uint32_t *) DT_REG_ADDR(DT_NODELABEL(gpio_140_176)),
|
2019-04-10 09:43:42 +02:00
|
|
|
.port_num = MCHP_GPIO_140_176,
|
2020-04-25 04:37:16 +02:00
|
|
|
#if DT_IRQ_HAS_CELL(DT_NODELABEL(gpio_140_176), irq)
|
2019-04-10 09:43:42 +02:00
|
|
|
.girq_id = MCHP_GIRQ08_ID,
|
2019-10-01 20:39:00 +02:00
|
|
|
.flags = GPIO_INT_ENABLE,
|
2019-04-10 09:43:42 +02:00
|
|
|
#else
|
|
|
|
.flags = 0,
|
|
|
|
#endif
|
|
|
|
};
|
|
|
|
|
|
|
|
static struct gpio_xec_data gpio_xec_port140_176_data;
|
|
|
|
|
2020-12-10 17:20:42 +01:00
|
|
|
DEVICE_DT_DEFINE(DT_NODELABEL(gpio_140_176),
|
2020-10-14 22:10:16 +02:00
|
|
|
gpio_xec_port140_176_init,
|
2021-04-28 10:55:48 +02:00
|
|
|
NULL,
|
2020-10-14 22:10:16 +02:00
|
|
|
&gpio_xec_port140_176_data, &gpio_xec_port140_176_config,
|
2021-12-04 22:00:59 +01:00
|
|
|
PRE_KERNEL_1, CONFIG_GPIO_INIT_PRIORITY,
|
2020-10-14 22:10:16 +02:00
|
|
|
&gpio_xec_driver_api);
|
2019-04-10 09:43:42 +02:00
|
|
|
|
2020-04-30 20:33:38 +02:00
|
|
|
static int gpio_xec_port140_176_init(const struct device *dev)
|
2019-04-10 09:43:42 +02:00
|
|
|
{
|
2020-04-25 04:37:16 +02:00
|
|
|
#if DT_IRQ_HAS_CELL(DT_NODELABEL(gpio_140_176), irq)
|
2020-05-28 20:44:16 +02:00
|
|
|
const struct gpio_xec_config *config = dev->config;
|
2019-04-10 09:43:42 +02:00
|
|
|
|
|
|
|
/* Turn on the block enable in the EC aggregator */
|
|
|
|
MCHP_GIRQ_BLK_SETEN(config->girq_id);
|
|
|
|
|
2020-04-25 04:37:16 +02:00
|
|
|
IRQ_CONNECT(DT_IRQ(DT_NODELABEL(gpio_140_176), irq),
|
2020-10-14 22:10:16 +02:00
|
|
|
DT_IRQ(DT_NODELABEL(gpio_140_176), priority),
|
2020-12-10 17:20:42 +01:00
|
|
|
gpio_gpio_xec_port_isr,
|
|
|
|
DEVICE_DT_GET(DT_NODELABEL(gpio_140_176)), 0U);
|
2019-04-10 09:43:42 +02:00
|
|
|
|
2020-04-25 04:37:16 +02:00
|
|
|
irq_enable(DT_IRQ(DT_NODELABEL(gpio_140_176), irq));
|
2019-04-10 09:43:42 +02:00
|
|
|
#endif
|
|
|
|
return 0;
|
|
|
|
}
|
2020-05-11 20:56:08 +02:00
|
|
|
#endif /* DT_NODE_HAS_STATUS(DT_NODELABEL(gpio_140_176), okay) */
|
2019-04-10 09:43:42 +02:00
|
|
|
|
2020-05-11 20:56:08 +02:00
|
|
|
#if DT_NODE_HAS_STATUS(DT_NODELABEL(gpio_200_236), okay)
|
2020-04-30 20:33:38 +02:00
|
|
|
static int gpio_xec_port200_236_init(const struct device *dev);
|
2019-04-10 09:43:42 +02:00
|
|
|
|
|
|
|
static const struct gpio_xec_config gpio_xec_port200_236_config = {
|
2019-12-11 17:45:17 +01:00
|
|
|
.common = {
|
2020-04-25 04:37:16 +02:00
|
|
|
.port_pin_mask = GPIO_PORT_PIN_MASK_FROM_DT_NODE(
|
2020-10-14 22:10:16 +02:00
|
|
|
DT_NODELABEL(gpio_200_236)),
|
2019-12-11 17:45:17 +01:00
|
|
|
},
|
2020-05-27 18:26:57 +02:00
|
|
|
.pcr1_base = (uint32_t *) DT_REG_ADDR(DT_NODELABEL(gpio_200_236)),
|
2019-04-10 09:43:42 +02:00
|
|
|
.port_num = MCHP_GPIO_200_236,
|
2020-04-25 04:37:16 +02:00
|
|
|
#if DT_IRQ_HAS_CELL(DT_NODELABEL(gpio_200_236), irq)
|
2019-04-10 09:43:42 +02:00
|
|
|
.girq_id = MCHP_GIRQ12_ID,
|
2019-10-01 20:39:00 +02:00
|
|
|
.flags = GPIO_INT_ENABLE,
|
2019-04-10 09:43:42 +02:00
|
|
|
#else
|
|
|
|
.flags = 0,
|
|
|
|
#endif
|
|
|
|
};
|
|
|
|
|
|
|
|
static struct gpio_xec_data gpio_xec_port200_236_data;
|
|
|
|
|
2020-12-10 17:20:42 +01:00
|
|
|
DEVICE_DT_DEFINE(DT_NODELABEL(gpio_200_236),
|
2020-10-14 22:10:16 +02:00
|
|
|
gpio_xec_port200_236_init,
|
2021-04-28 10:55:48 +02:00
|
|
|
NULL,
|
2020-10-14 22:10:16 +02:00
|
|
|
&gpio_xec_port200_236_data, &gpio_xec_port200_236_config,
|
2021-12-04 22:00:59 +01:00
|
|
|
PRE_KERNEL_1, CONFIG_GPIO_INIT_PRIORITY,
|
2020-10-14 22:10:16 +02:00
|
|
|
&gpio_xec_driver_api);
|
2019-04-10 09:43:42 +02:00
|
|
|
|
2020-04-30 20:33:38 +02:00
|
|
|
static int gpio_xec_port200_236_init(const struct device *dev)
|
2019-04-10 09:43:42 +02:00
|
|
|
{
|
2020-04-25 04:37:16 +02:00
|
|
|
#if DT_IRQ_HAS_CELL(DT_NODELABEL(gpio_200_236), irq)
|
2020-05-28 20:44:16 +02:00
|
|
|
const struct gpio_xec_config *config = dev->config;
|
2019-04-10 09:43:42 +02:00
|
|
|
|
|
|
|
/* Turn on the block enable in the EC aggregator */
|
|
|
|
MCHP_GIRQ_BLK_SETEN(config->girq_id);
|
|
|
|
|
2020-04-25 04:37:16 +02:00
|
|
|
IRQ_CONNECT(DT_IRQ(DT_NODELABEL(gpio_200_236), irq),
|
2020-10-14 22:10:16 +02:00
|
|
|
DT_IRQ(DT_NODELABEL(gpio_200_236), priority),
|
2020-12-10 17:20:42 +01:00
|
|
|
gpio_gpio_xec_port_isr,
|
|
|
|
DEVICE_DT_GET(DT_NODELABEL(gpio_200_236)), 0U);
|
2019-04-10 09:43:42 +02:00
|
|
|
|
2020-04-25 04:37:16 +02:00
|
|
|
irq_enable(DT_IRQ(DT_NODELABEL(gpio_200_236), irq));
|
2019-04-10 09:43:42 +02:00
|
|
|
#endif
|
|
|
|
return 0;
|
|
|
|
}
|
2020-05-11 20:56:08 +02:00
|
|
|
#endif /* DT_NODE_HAS_STATUS(DT_NODELABEL(gpio_200_236), okay) */
|
2019-04-10 09:43:42 +02:00
|
|
|
|
2020-05-11 20:56:08 +02:00
|
|
|
#if DT_NODE_HAS_STATUS(DT_NODELABEL(gpio_240_276), okay)
|
2020-04-30 20:33:38 +02:00
|
|
|
static int gpio_xec_port240_276_init(const struct device *dev);
|
2019-04-10 09:43:42 +02:00
|
|
|
|
|
|
|
static const struct gpio_xec_config gpio_xec_port240_276_config = {
|
2019-12-11 17:45:17 +01:00
|
|
|
.common = {
|
2020-04-25 04:37:16 +02:00
|
|
|
.port_pin_mask = GPIO_PORT_PIN_MASK_FROM_DT_NODE(
|
2020-10-14 22:10:16 +02:00
|
|
|
DT_NODELABEL(gpio_240_276)),
|
2019-12-11 17:45:17 +01:00
|
|
|
},
|
2020-05-27 18:26:57 +02:00
|
|
|
.pcr1_base = (uint32_t *) DT_REG_ADDR(DT_NODELABEL(gpio_240_276)),
|
2019-04-10 09:43:42 +02:00
|
|
|
.port_num = MCHP_GPIO_240_276,
|
2020-04-25 04:37:16 +02:00
|
|
|
#if DT_IRQ_HAS_CELL(DT_NODELABEL(gpio_240_276), irq)
|
2019-04-10 09:43:42 +02:00
|
|
|
.girq_id = MCHP_GIRQ26_ID,
|
2019-10-01 20:39:00 +02:00
|
|
|
.flags = GPIO_INT_ENABLE,
|
2019-04-10 09:43:42 +02:00
|
|
|
#else
|
|
|
|
.flags = 0,
|
|
|
|
#endif
|
|
|
|
};
|
|
|
|
|
|
|
|
static struct gpio_xec_data gpio_xec_port240_276_data;
|
|
|
|
|
2020-12-10 17:20:42 +01:00
|
|
|
DEVICE_DT_DEFINE(DT_NODELABEL(gpio_240_276),
|
2020-10-14 22:10:16 +02:00
|
|
|
gpio_xec_port240_276_init,
|
2021-04-28 10:55:48 +02:00
|
|
|
NULL,
|
2020-10-14 22:10:16 +02:00
|
|
|
&gpio_xec_port240_276_data, &gpio_xec_port240_276_config,
|
2021-12-04 22:00:59 +01:00
|
|
|
PRE_KERNEL_1, CONFIG_GPIO_INIT_PRIORITY,
|
2020-10-14 22:10:16 +02:00
|
|
|
&gpio_xec_driver_api);
|
2019-04-10 09:43:42 +02:00
|
|
|
|
2020-04-30 20:33:38 +02:00
|
|
|
static int gpio_xec_port240_276_init(const struct device *dev)
|
2019-04-10 09:43:42 +02:00
|
|
|
{
|
2020-04-25 04:37:16 +02:00
|
|
|
#if DT_IRQ_HAS_CELL(DT_NODELABEL(gpio_240_276), irq)
|
2020-05-28 20:44:16 +02:00
|
|
|
const struct gpio_xec_config *config = dev->config;
|
2019-04-10 09:43:42 +02:00
|
|
|
|
|
|
|
/* Turn on the block enable in the EC aggregator */
|
|
|
|
MCHP_GIRQ_BLK_SETEN(config->girq_id);
|
|
|
|
|
2020-04-25 04:37:16 +02:00
|
|
|
IRQ_CONNECT(DT_IRQ(DT_NODELABEL(gpio_240_276), irq),
|
2020-10-14 22:10:16 +02:00
|
|
|
DT_IRQ(DT_NODELABEL(gpio_240_276), priority),
|
2020-12-10 17:20:42 +01:00
|
|
|
gpio_gpio_xec_port_isr,
|
|
|
|
DEVICE_DT_GET(DT_NODELABEL(gpio_240_276)), 0U);
|
2019-04-10 09:43:42 +02:00
|
|
|
|
2020-04-25 04:37:16 +02:00
|
|
|
irq_enable(DT_IRQ(DT_NODELABEL(gpio_240_276), irq));
|
2019-04-10 09:43:42 +02:00
|
|
|
#endif
|
|
|
|
return 0;
|
|
|
|
}
|
2020-05-11 20:56:08 +02:00
|
|
|
#endif /* DT_NODE_HAS_STATUS(DT_NODELABEL(gpio_240_276), okay) */
|