This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

AM625: AM625 GPIO not accessible in custom kernel character driver

Part Number: AM625

Tool/software:

Hi Team, 

I'm trying to write custom kernel character driver buzzer with some additional tones.

I have implemented following changes:

  1. Define pin as GPIO1_10 (E18) in device tree
  2. Define node with above pins and set status as "okay"
  3. write custom character driver as a Linux Loadable Kernel Module (LKM) at "drivers/misc/tfs_buzzer.c" to access same gpio using gpio_request API

AM62 DataSheet:- https://www.variscite.com/wp-content/uploads/2023/01/VAR-SOM-AM62_Datasheet.pdf

Base Image:- https://variwiki.com/index.php?title=Yocto_Build_Release&release=am62-yocto-kirkstone-6.1.83_09.02.01.10-v1.1

 

arch/arm64/boot/dts/ti/k3-am625-var-som-symphony.dts

 

/ {

    /*  Buzzer Enable */

    tfs_buzzer_enable_gpio: tfs-buzzer-enable-gpio {

        label = "BuzzerEnable";

        linux,default-trigger = "default-on";

        gpios = <&main_gpio0 22 GPIO_ACTIVE_HIGH>;

        status = "okay";

    };

 

    /*  Buzzer Tone */

    tfs_buzzer_tone_gpio: tfs-buzzer-tone-gpio {

        label = "BuzzerTone";

        linux,default-trigger = "default-on";

        gpios = <&main_gpio1 10 GPIO_ACTIVE_HIGH>;

        status = "okay";

    };

};

 

main_pmx0 {

    status = "okay";

    pinctrl-names = "default";

    pinctrl-0 = <&display_pins_default>;

 

    display_pins_default: display-default-pins {

        pinctrl-single,pins = <

            /* Buzzer Pins */

            AM62X_IOPAD(0x0058, PIN_OUTPUT_PULLUP, 7) /* (R23) GPMC0_AD7.GPIO0_22 */

            AM62X_IOPAD(0x01a0, PIN_OUTPUT_PULLUP, 7) /* (E18) MCASP0_AXR0.GPIO1_10 */

         >;

    };

};

drivers/misc/tfs_buzzer.c

static int buzzer_gpio_init(void)

{

    int ret = -1;

    int gpio_num = 378;

 

    ret = gpio_request(gpio_num, "BUZZER_GPIO");

    if (ret) {

        if (ret == -EPROBE_DEFER) {

            pr_info("GPIO %d request deferred, retrying later\n", gpio_num);

        } else {

            pr_err("Failed to request GPIO %d for BUZZER_GPIO: %d\n", gpio_num, ret);

        }

        return ret;

    } else {

        gpio_direction_output(gpio_num, 1);

        gpio_set_value(gpio_num, 1); // default buzzer is disabled

        buzzer_dev->status = BUZZER_DISABLE;

    }

 

    return 0;

}
 

Driver Error:

gpio_request() returns code -517 corresponds to -EPROBE_DEFER. This error code indicates that the GPIO request is being deferred because a required resource is not yet available

GPIO_Info