Skip to content

mfd: flipper-one-mcu: register the SW button interrupt - #17

Merged
alchark merged 1 commit into
flipperdevices:flipper-develfrom
munzzyy:mfd-fomcu-swbtn-irq
Jul 28, 2026
Merged

mfd: flipper-one-mcu: register the SW button interrupt#17
alchark merged 1 commit into
flipperdevices:flipper-develfrom
munzzyy:mfd-fomcu-swbtn-irq

Conversation

@munzzyy

@munzzyy munzzyy commented Jul 27, 2026

Copy link
Copy Markdown

fomcu_irqs[] has no entry for FOMCU_INT_INPUT_SWBTN, so the SW button interrupt is allocated but can never fire.

REGMAP_IRQ_REG() is a designated initialiser — [_irq] = { .reg_offset = ..., .mask = ... } — so the enum value is the array index, not the position in the list. The enum runs BTN, TOUCH, HEADSET, SWBTN, UCSI_EVENT, and the array initialises 0, 1, 2 and 4. Index 3 is left as an implicit zero.

Because UCSI_EVENT is index 4, ARRAY_SIZE() is still 5, so num_irqs looks right and nothing complains. Building the array exactly as it is on flipper-devel:

ARRAY_SIZE(fomcu_irqs) = 5  (num_irqs reported to regmap-irq)

  [0] INPUT_BTN      reg_offset=0 mask=0x01
  [1] INPUT_TOUCH    reg_offset=0 mask=0x02
  [2] INPUT_HEADSET  reg_offset=0 mask=0x04
  [3] INPUT_SWBTN    reg_offset=0 mask=0x00   <-- status & 0 is always 0
  [4] UCSI_EVENT     reg_offset=2 mask=0x01

A .mask of 0 means regmap_irq_thread() ANDs the status word with 0 for that irq, so it never calls the handler, and masking and unmasking it write nothing.

Nothing fails loudly, which is what makes it awkward to spot. fo_input_irqs declares the resource, the domain hands out a virq for index 3, platform_get_irq_byname(pdev, "flipper-one-input-swbtn") succeeds, devm_request_threaded_irq() succeeds and the input device registers advertising KEY_POWER. Probe is clean. The button just does nothing.

FOMCU_INTSTS_INPUT_SWBTN is already defined as BIT(3) in the header, so this is only a missing line in the table. With it, index 3 gets mask=0x08 and the array size is unchanged.

Caveat on testing: there's no aarch64 cross-compiler on this machine and I don't have the hardware, so I haven't built the kernel or pressed the button. The reasoning is from the macro expansion and regmap-irq's mask handling, and the numbers above come from compiling the real table. Worth a quick confirmation from someone with a board that KEY_POWER starts arriving.

@munzzyy
munzzyy requested a review from a team July 27, 2026 20:26

@alchark alchark left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for spotting this! It wasn’t working indeed, and I haven’t yet gad chance to debug.

Could you please amend the commit with your full name in the sign-off line per kernel requirements? I’ll then merge at once, and fold it into a co-developed-by upon next rebase+squash.

Signed-off-by: Cole Munz <Munzzyy1@proton.me>
@munzzyy
munzzyy force-pushed the mfd-fomcu-swbtn-irq branch from 277f94d to 38c59b0 Compare July 28, 2026 04:03
@munzzyy

munzzyy commented Jul 28, 2026

Copy link
Copy Markdown
Author

Done — commit is now signed off as Cole Munz, same diff otherwise. Good to hear the button really was dead on your end. Thanks for the quick turnaround!

@alchark alchark left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a lot for your contribution!

@alchark
alchark merged commit 8c6f049 into flipperdevices:flipper-devel Jul 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants