Skip to content
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

driver: intc: add MIWU driver support in NPCM series. #113

Merged
merged 1 commit into from
Jun 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions boards/nuvoton/npcm400f_evb/npcm400f_evb_defconfig
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,6 @@ CONFIG_UART_CONSOLE=y
# GPIO Driver
CONFIG_GPIO=y
CONFIG_GPIO_NPCM=y

# MIWU Driver
CONFIG_NPCM_MIWU=y
32 changes: 2 additions & 30 deletions drivers/gpio/gpio_npcm.c
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ const struct device *npcm_get_gpio_dev(int port)
return gpio_devs[port];
}

#ifdef CONFIG_NPCM_MIWU
void npcm_gpio_enable_io_pads(const struct device *dev, int pin)
{
const struct gpio_npcm_config *const config = dev->config;
Expand Down Expand Up @@ -104,14 +103,6 @@ void npcm_gpio_disable_io_pads(const struct device *dev, int pin)
npcm_miwu_io_disable(io_wui);
}
}
#else
void npcm_gpio_enable_io_pads(const struct device *dev, int pin)
{
}
void npcm_gpio_disable_io_pads(const struct device *dev, int pin)
{
}
#endif

/* GPIO api functions */
static int gpio_npcm_config(const struct device *dev,
Expand Down Expand Up @@ -277,7 +268,6 @@ static int gpio_npcm_port_toggle_bits(const struct device *dev,
return 0;
}

#ifdef CONFIG_NPCM_MIWU
static int gpio_npcm_pin_interrupt_configure(const struct device *dev,
gpio_pin_t pin,
enum gpio_int_mode mode,
Expand Down Expand Up @@ -337,23 +327,12 @@ static int gpio_npcm_pin_interrupt_configure(const struct device *dev,

return 0;
}
#else
static int gpio_npcm_pin_interrupt_configure(const struct device *dev,
gpio_pin_t pin,
enum gpio_int_mode mode,
enum gpio_int_trig trig)
{
return -EINVAL;
}
#endif


#ifdef CONFIG_NPCM_MIWU
static int gpio_npcm_manage_callback(const struct device *dev,
struct gpio_callback *callback, bool set)
{
const struct gpio_npcm_config *const config = dev->config;
struct miwu_io_callback *miwu_cb = (struct miwu_io_callback *)callback;
struct miwu_callback *miwu_cb = (struct miwu_callback *)callback;
int pin = find_lsb_set(callback->pin_mask) - 1;

/* pin_mask should not be zero */
Expand All @@ -373,15 +352,8 @@ static int gpio_npcm_manage_callback(const struct device *dev,
config->port);

/* Insert or remove a IO callback which being called in MIWU ISRs */
return npcm_miwu_manage_gpio_callback(miwu_cb, set);
return npcm_miwu_manage_callback(miwu_cb, set);
}
#else
static int gpio_npcm_manage_callback(const struct device *dev,
struct gpio_callback *callback, bool set)
{
return -EINVAL;
}
#endif

/* GPIO driver registration */
static const struct gpio_driver_api gpio_npcm_driver = {
Expand Down
1 change: 1 addition & 0 deletions drivers/interrupt_controller/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ zephyr_library_sources_ifdef(CONFIG_LEON_IRQMP intc_irqmp.c)
zephyr_library_sources_ifdef(CONFIG_LOAPIC intc_loapic.c intc_system_apic.c)
zephyr_library_sources_ifdef(CONFIG_LOAPIC_SPURIOUS_VECTOR intc_loapic_spurious.S)
zephyr_library_sources_ifdef(CONFIG_MCHP_ECIA_XEC intc_mchp_ecia_xec.c)
zephyr_library_sources_ifdef(CONFIG_NPCM_MIWU intc_npcm_miwu.c)
zephyr_library_sources_ifdef(CONFIG_NPCX_MIWU intc_miwu.c)
zephyr_library_sources_ifdef(CONFIG_PLIC intc_plic.c)
zephyr_library_sources_ifdef(CONFIG_RV32M1_INTMUX intc_rv32m1_intmux.c)
Expand Down
2 changes: 2 additions & 0 deletions drivers/interrupt_controller/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@ source "drivers/interrupt_controller/Kconfig.sam0"

source "drivers/interrupt_controller/Kconfig.gic"

source "drivers/interrupt_controller/Kconfig.npcm"

source "drivers/interrupt_controller/Kconfig.npcx"

source "drivers/interrupt_controller/Kconfig.intel_vtd"
Expand Down
13 changes: 13 additions & 0 deletions drivers/interrupt_controller/Kconfig.npcm
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# NPCM GPIO driver configuration options

# Copyright (c) 2024 Nuvoton Technology Corporation.
# SPDX-License-Identifier: Apache-2.0

config NPCM_MIWU
bool "Nuvoton NPCM embedded controller (EC) miwu driver"
default y
depends on SOC_FAMILY_NPCM
help
This option enables the Multi-Input Wake-Up Unit (MIWU) driver
for NPCM family ofprocessors.
This is required for GPIO, RTC, LPC/eSPI interrupt support.
Loading
Loading