Can't get events from nPM1300 MFD

I would like to get the events offered by the mfd driver for VBUS detect but for some reason my callback is never triggered.

I'm doing this atm:

static void pmic_evt_cb(const struct device *dev, struct gpio_callback *cb, uint32_t pins)
{
    LOG_INF("PMIC Event: %d\n", pins);
}

main:

if (!device_is_ready(pmic)) {
LOG_ERR("PMIC device not ready.\n");
return;
}
static struct gpio_callback event_cb;
gpio_init_callback(&event_cb, pmic_evt_cb, BIT(NPM1300_EVENT_VBUS_DETECTED));
mfd_npm1300_add_callback(pmic, &event_cb);


Devicetree:

npm1300_pmic: npm1300@6b {
	status = "okay";
	compatible = "nordic,npm1300";
	reg = <0x6b>;
	host-int-gpios = <&gpio1 9 0>;
	pmic-int-pin = <0>;
	
	...

Loosely following the EK sample.
Removing and attaching VBUS does not trigger my callback as I would expect. Is there something that needs to be configured to enable them?
I'm using NCS2.7

Parents Reply Children
  • I found the issue but not quite sure what exactly the cause is. In a hunch I removed the GPIO device definition that I had copied from the EK shield overlay. Without that it starts to work.

    npm1300_gpio: gpio-controller {
    compatible = "nordic,npm1300-gpio";
    gpio-controller;
    #gpio-cells = <2>;
    ngpios = <5>;
    };

    Is the GPIO driver mutually exclusive to getting event interrupts or is it clashing in other ways with the mfd driver?
    I don't need the GPIO controller in this application so its fine but I would like to understand what went wrong here in the future. I don't quite understand what the gpio-cells and ngpios property tell the driver in the context of the nPM1300.

  • It is not clear to me what you originally added and what you have removed now. Did you change any of the NCS devicetree files, or did you just remove something from your overlay file? If so, what did it look like before when it was not working, and what does it look like now?

    Best regards,

    Edvin

  • The snippet I posted in the previous reply was part of the npm1300_pmic node. Identical setup to how the overlay for the EK shield looks.
    When deleting this npm1300_gpio node it started working, no other changes were made.

Related