Skip to content

rtc-pcf2127: Add support for PCF2131 INTB# interrupt output selection #20

@ajlennon

Description

@ajlennon

Summary

The PCF2131 RTC has dual interrupt outputs (INTA# and INTB#) but the current rtc-pcf2127 driver only supports INTA# output. Request to add device tree property support for selecting INTB# output.

Hardware Background

The PCF2131 features:

  • INTA#: Primary interrupt output (open-drain, active-low)
  • INTB#: Secondary interrupt output (open-drain, active-low)
  • Interrupt mask registers to route different sources to either output:
    • PCF2131_REG_INT_A_MASK1 (0x12) / PCF2131_REG_INT_A_MASK2 (0x13)
    • PCF2131_REG_INT_B_MASK1 (0x14) / PCF2131_REG_INT_B_MASK2 (0x15)

Current Driver Behavior

The driver currently defaults all interrupt sources to INTA# in pcf2127_configure_interrupt_pins():

/* Routes ALL interrupts to INTA# only */
ret = regmap_write(pcf2127->regmap, PCF2131_REG_INT_A_MASK1, 0x00);
ret = regmap_write(pcf2127->regmap, PCF2131_REG_INT_A_MASK2, 0x00);

Proposed Enhancement

Add device tree property support for INTB# selection:

Device Tree Property

pcf2131: rtc@53 {
    compatible = "nxp,pcf2131";
    reg = <0x53>;
    interrupt-parent = <&gpio_controller>;
    interrupts = <XX IRQ_TYPE_LEVEL_LOW>;
    interrupt-names = "alarm";
    nxp,use-intb-output;  /* New property to select INTB# */
    wakeup-source;
};

Driver Modification

static int pcf2127_configure_interrupt_pins(struct device *dev)
{
    struct pcf2127 *pcf2127 = dev_get_drvdata(dev);
    bool use_intb = device_property_read_bool(dev, "nxp,use-intb-output");
    
    if (use_intb) {
        /* Route interrupts to INTB# */
        regmap_write(pcf2127->regmap, PCF2131_REG_INT_A_MASK1, 0xFF);
        regmap_write(pcf2127->regmap, PCF2131_REG_INT_A_MASK2, 0xFF);
        regmap_write(pcf2127->regmap, PCF2131_REG_INT_B_MASK1, 0x00);
        regmap_write(pcf2127->regmap, PCF2131_REG_INT_B_MASK2, 0x00);
    } else {
        /* Default: Route interrupts to INTA# (current behavior) */
        regmap_write(pcf2127->regmap, PCF2131_REG_INT_A_MASK1, 0x00);
        regmap_write(pcf2127->regmap, PCF2131_REG_INT_A_MASK2, 0x00);
        regmap_write(pcf2127->regmap, PCF2131_REG_INT_B_MASK1, 0xFF);
        regmap_write(pcf2127->regmap, PCF2131_REG_INT_B_MASK2, 0xFF);
    }
    return 0;
}

Use Case

In our hardware design:

  • INTA# → Connected to i.MX93 GPIO for direct system wake
  • INTB# → Connected to PMU (MCXC143VFM) for power management wake

Having both options available would provide flexibility for different wake scenarios and power management strategies.

Backward Compatibility

This enhancement maintains full backward compatibility:

  • Default behavior (INTA#) unchanged
  • New functionality only enabled with explicit device tree property
  • No impact on existing implementations

References

  • PCF2131 datasheet interrupt routing registers
  • Current driver: drivers/rtc/rtc-pcf2127.c
  • Related: PCF2131 support was added in kernel 6.6

Would appreciate consideration for this enhancement to fully utilize the PCF2131's dual interrupt capability.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions