Browse Source
This commit adds the pfic interrupt controller driver for WCH CH32V003. Signed-off-by: Michael Hope <michaelh@juju.nz> Signed-off-by: Dhiru Kholia <dhiru.kholia@gmail.com>pull/82071/head
5 changed files with 73 additions and 0 deletions
@ -0,0 +1,9 @@
@@ -0,0 +1,9 @@
|
||||
# Copyright (c) 2024 Michael Hope |
||||
# SPDX-License-Identifier: Apache-2.0 |
||||
|
||||
config WCH_PFIC |
||||
bool "WCH Programmable Fast Interrupt Controller (PFIC)" |
||||
default y |
||||
depends on DT_HAS_WCH_PFIC_ENABLED |
||||
help |
||||
Interrupt controller for WCH PFIC. |
@ -0,0 +1,43 @@
@@ -0,0 +1,43 @@
|
||||
/*
|
||||
* Copyright (c) 2024 Michael Hope |
||||
* |
||||
* SPDX-License-Identifier: Apache-2.0 |
||||
*/ |
||||
|
||||
#define DT_DRV_COMPAT wch_pfic |
||||
|
||||
#include <ch32fun.h> |
||||
|
||||
#include <zephyr/arch/cpu.h> |
||||
#include <zephyr/init.h> |
||||
#include <zephyr/irq.h> |
||||
#include <zephyr/kernel.h> |
||||
|
||||
#define SEVONPEND (1 << 4) |
||||
#define WFITOWFE (1 << 3) |
||||
|
||||
void arch_irq_enable(unsigned int irq) |
||||
{ |
||||
PFIC->IENR[irq / 32] = 1 << (irq % 32); |
||||
} |
||||
|
||||
void arch_irq_disable(unsigned int irq) |
||||
{ |
||||
PFIC->IRER[irq / 32] |= 1 << (irq % 32); |
||||
} |
||||
|
||||
int arch_irq_is_enabled(unsigned int irq) |
||||
{ |
||||
return ((PFIC->ISR[irq >> 5] & (1 << (irq & 0x1F))) != 0); |
||||
} |
||||
|
||||
static int pfic_init(void) |
||||
{ |
||||
/* `wfi` is called with interrupts disabled. Configure the PFIC to wake up on any event,
|
||||
* including any interrupt. |
||||
*/ |
||||
PFIC->SCTLR = SEVONPEND | WFITOWFE; |
||||
return 0; |
||||
} |
||||
|
||||
SYS_INIT(pfic_init, PRE_KERNEL_1, CONFIG_INTC_INIT_PRIORITY); |
@ -0,0 +1,18 @@
@@ -0,0 +1,18 @@
|
||||
# Copyright (c) 2024 Michael Hope |
||||
# SPDX-License-Identifier: Apache-2.0 |
||||
|
||||
description: WCH CH32V00x Programmable Fast Interrupt Controller (PFIC) |
||||
|
||||
compatible: "wch,pfic" |
||||
|
||||
include: [interrupt-controller.yaml, base.yaml] |
||||
|
||||
properties: |
||||
reg: |
||||
required: true |
||||
|
||||
"#interrupt-cells": |
||||
const: 1 |
||||
|
||||
interrupt-cells: |
||||
- irq |
Loading…
Reference in new issue