Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  1) // SPDX-License-Identifier: GPL-2.0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  3)  * Copyright IBM Corp. 2001,2008
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  4)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  5)  * This file contains the IRQ specific code for hvc_console
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  6)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  7)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  8) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  9) #include <linux/interrupt.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) #include "hvc_console.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) static irqreturn_t hvc_handle_interrupt(int irq, void *dev_instance)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) 	/* if hvc_poll request a repoll, then kick the hvcd thread */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) 	if (hvc_poll(dev_instance))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) 		hvc_kick();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) 	 * We're safe to always return IRQ_HANDLED as the hvcd thread will
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) 	 * iterate through each hvc_struct.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) 	return IRQ_HANDLED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27)  * For IRQ based systems these callbacks can be used
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) int notifier_add_irq(struct hvc_struct *hp, int irq)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) 	int rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) 	if (!irq) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) 		hp->irq_requested = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) 		return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) 	rc = request_irq(irq, hvc_handle_interrupt, hp->flags,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) 			"hvc_console", hp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) 	if (!rc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) 		hp->irq_requested = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) 	return rc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) void notifier_del_irq(struct hvc_struct *hp, int irq)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) 	if (!hp->irq_requested)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) 		return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) 	free_irq(irq, hp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) 	hp->irq_requested = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) void notifier_hangup_irq(struct hvc_struct *hp, int irq)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) 	notifier_del_irq(hp, irq);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) }