Skip to content
View in the app

A better way to browse. Learn more.

Armbian Community Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Error on request_irq() - Orange Pie

Featured Replies

Hello,

 

I'm trying to use pin PC3 as an interrupt, but it returns the error code -22 in the gpio_to_irq() function. In user-space i can use it normally as a GPIO, but I need it to function as an interrupt in a driver.

Board: Orange Pi One, Armbian 23.8.0

 

#define GPIO_PIN 67
#define GPIO_PIN_DESC "GPIO PC3"

static int __init mytapp_controller_proc_init(void)
{
	int ret,gpio_irq;

	uint8_t idx = 0;

	printk("mytapp_controller_proc_init 444%d\n",GPIO_PIN);

	msg = kmalloc(PROCFS_MAX_SIZE, GFP_KERNEL);
	if(!msg){
		printk(KERN_ALERT "Error: kmalloc error\n");
		return -ENOMEM;
	}

   if (gpio_request(GPIO_PIN, GPIO_PIN_DESC)) {
      printk("GPIO request failure: %s\n", GPIO_PIN_DESC);
      return -1;
   }

   if (gpio_direction_input(GPIO_PIN)) {
      printk("GPIO set direction input failure %s\n", GPIO_PIN_DESC);
      return -1;
   }
 
   if ( (gpio_irq = gpio_to_irq(GPIO_PIN)) < 0 ) {
      printk("GPIO to IRQ mapping failure %s\n", GPIO_PIN_DESC);
      return -1;
   }

    ret = request_irq(gpio_irq, sample_irq, IRQF_TRIGGER_FALLING, "flow_sensor", 0);
    if (ret < 0) {
        printk(KERN_ALERT "%s: request_irg failed with %u\n", __func__, ret);
        return -1;
    }

   return 0;
}

 

 

It shows as GPIO IN:

 

root@orangepione:/home/mytapp# cat /sys/kernel/debug/gpio
gpiochip0: GPIOs 0-223, parent: platform/1c20800.pinctrl, 1c20800.pinctrl:
 gpio-15  (                    |orangepi:red:status ) out lo 
 gpio-67  (                    |GPIO PC3            ) in  hi 
 gpio-166 (                    |cd                  ) in  lo ACTIVE LOW
 gpio-204 (                    |usb0_id_det         ) in  hi IRQ 

gpiochip1: GPIOs 352-383, parent: platform/1f02c00.pinctrl, 1f02c00.pinctrl:
 gpio-354 (                    |usb0-vbus           ) out hi 
 gpio-355 (                    |sw4                 ) in  hi IRQ ACTIVE LOW
 gpio-358 (                    |vdd-cpux            ) out lo 
 gpio-362 (                    |orangepi:green:pwr  ) out hi 

 

I also tryied PC0 and doesn't work too. The PA3 and works fine.

 

Any ideia?

Best regards

 

Edited by João Paulo Bodanese

Solved by João Paulo Bodanese

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.