Message ID | 20250113-mdb-max7360-support-v3-0-9519b4acb0b1@bootlin.com |
---|---|
Headers | show |
Series | Add support for MAX7360 | expand |
On Mon, Jan 13, 2025 at 01:42:25PM +0100, Mathieu Dubois-Briand wrote: > + interrupt-controller: true > + > + "#interrupt-cells": > + const: 2 > + > + maxim,constant-current-disable: > + $ref: /schemas/types.yaml#/definitions/uint32 > + description: > Drop > > + Bit field, each bit disables constant-current output of the associated > + GPIO, starting from the least significant bit for the first GPIO. maximum: 0xff? > + > +required: > + - compatible > + - gpio-controller > + - ngpios > + allOf: here, so you won't re-indent it later. > +if: > + properties: > + compatible: > + contains: > + enum: > + - maxim,max7360-gpio > +then: > + required: > + - interrupt-controller > +else: > + properties: > + interrupt-controller: false > + maxim,constant-current-disable: false > + > + ngpios: > + maximum: 6 > + > +additionalProperties: false > + > +examples: > + - | > + gpio { > + compatible = "maxim,max7360-gpio"; > + > + gpio-controller; > + #gpio-cells = <2>; > + ngpios = <8>; > + maxim,constant-current-disable = <0x06>; > + > + interrupt-controller; > + #interrupt-cells = <2>; > + }; ... > + interrupt-names: > + items: > + - const: inti > + - const: intk > + > + keypad-debounce-delay-ms: > + description: Keypad debounce delay in ms > + minimum: 9 > + maximum: 40 > + default: 9 > + > + autorepeat: true Drop, not needed. > + > + rotary-debounce-delay-ms: > + description: Rotary encoder debounce delay in ms > + minimum: 0 > + maximum: 15 > + default: 0 > + > + linux,axis: > + description: The input subsystem axis to map to this rotary encoder. Missing type. I guess you wanted to reference rotary encoder schema, next to input and matrix-keymap? > + > + "#pwm-cells": > + const: 3 > + > + gpio: > + $ref: /schemas/gpio/maxim,max7360-gpio.yaml# > + description: > Drop > > + PORT0 to PORT7 general purpose input/output pins configuration. > + > + gpo: > + $ref: /schemas/gpio/maxim,max7360-gpio.yaml# > + description: > Drop > > + COL2 to COL7 general purpose output pins configuration. > + Allows to use unused keypad columns as outputs. > + The MAX7360 has 8 column lines and 6 of them can be used as GPOs. Value > + of ngpios must be coherent with the value of keypad,num-columns, as their > + sum must not exceed the number of physical lines. > + > +required: > + - compatible > + - reg > + - interrupts > + - interrupt-names > + - linux,keymap > + - linux,axis > + - "#pwm-cells" gpio and gpo nodes are optional? How would the driver behave? I assume you need to define the partition between GPIOs, especially that 'ngpios' are a required property in their schema. > + > +unevaluatedProperties: false > + > +examples: > + - | > + #include <dt-bindings/input/input.h> > + #include <dt-bindings/interrupt-controller/arm-gic.h> > + > + i2c { > + #address-cells = <1>; > + #size-cells = <0>; > + > + io-expander@38 { > + compatible = "maxim,max7360"; > + reg = <0x38>; > + > + interrupt-parent = <&gpio1>; > + interrupts = <23 IRQ_TYPE_LEVEL_LOW>, > + <24 IRQ_TYPE_LEVEL_LOW>; > + interrupt-names = "inti", "intk"; > + > + keypad,num-rows = <8>; > + keypad,num-columns = <4>; > + linux,keymap = < > + MATRIX_KEY(0x00, 0x00, KEY_F5) > + MATRIX_KEY(0x01, 0x00, KEY_F4) > + MATRIX_KEY(0x02, 0x01, KEY_F6) > + >; > + keypad-debounce-delay-ms = <10>; > + autorepeat; > + > + rotary-debounce-delay-ms = <2>; > + linux,axis = <0>; /* REL_X */ > + > + #pwm-cells = <3>; > + > + max7360_gpio: gpio { > + compatible = "maxim,max7360-gpio"; > + > + gpio-controller; > + #gpio-cells = <2>; > + ngpios = <8>; > + maxim,constant-current-disable = <0x06>; > + > + interrupt-controller; > + #interrupt-cells = <0x2>; > + }; > + > + max7360_gpo: gpo { > + compatible = "maxim,max7360-gpo"; > + > + gpio-controller; > + #gpio-cells = <2>; > + ngpios = <4>; > + }; > + }; > + }; > > -- > 2.39.5 >
On Mon Jan 13, 2025 at 1:42 PM CET, Mathieu Dubois-Briand wrote: > Add driver for Maxim Integrated MAX7360 rotary encoder controller, > supporting a single rotary switch. > > Signed-off-by: Mathieu Dubois-Briand <mathieu.dubois-briand@bootlin.com> > --- ... > +static irqreturn_t max7360_rotary_irq(int irq, void *data) > +{ > + struct max7360_rotary *max7360_rotary = data; > + int val; > + int ret; > + > + ret = regmap_read(max7360_rotary->regmap, MAX7360_REG_RTR_CNT, &val); > + if (ret < 0) { > + dev_err(&max7360_rotary->input->dev, > + "Failed to read rotary counter\n"); > + return IRQ_NONE; > + } > + > + if (val == 0) { > + dev_dbg(&max7360_rotary->input->dev, > + "Got a spurious interrupt\n"); > + > + return IRQ_NONE; > + } > + > + input_report_rel(max7360_rotary->input, max7360_rotary->axis, > + (int8_t)val); > + input_sync(max7360_rotary->input); > + I have a question about the type of events reported here. I used rotary_encoder.c as a reference, so I'm reporting some EV_REL events on a given axis, such as REL_X. On the other hand, I know there is an out-of-tree version of this driver that is instead reporting key events, such as KEY_DOWN or KEY_UP. I also know there are existing applications that do rely on this behaviour. So my question is, what is the best kind of events to report here ? Is there any guideline that do apply here? Should I better try to mimic the behaviour of the existing out-of-tree driver, or should I mimic the behaviour of rotary_encoder.c, so we have a similar behaviour for all in-kernel rotary encoder drivers? > + return IRQ_HANDLED; > +} > +
This series implements a set of drivers allowing to support the Maxim Integrated MAX7360 device. The MAX7360 is an I2C key-switch and led controller, with following functionalities: - Keypad controller for a key matrix of up to 8 rows and 8 columns. - Rotary encoder support, for a single rotary encoder. - Up to 8 PWM outputs. - Up to 8 GPIOs with support for interrupts and 6 GPOs. Chipset pins are shared between all functionalities, so all cannot be used at the same time. Signed-off-by: Mathieu Dubois-Briand <mathieu.dubois-briand@bootlin.com> --- Changes in v3: - Fix MFD device tree binding to add gpio child nodes. - Fix various small issues in device tree bindings. - Add missing line returns in error messages. - Use dev_err_probe() when possible. - Link to v2: https://lore.kernel.org/r/20241223-mdb-max7360-support-v2-0-37a8d22c36ed@bootlin.com Changes in v2: - Removing device tree subnodes for keypad, rotary encoder and pwm functionalities. - Fixed dt-bindings syntax and naming. - Fixed missing handling of requested period in PWM driver. - Cleanup of the code - Link to v1: https://lore.kernel.org/r/20241219-mdb-max7360-support-v1-0-8e8317584121@bootlin.com --- Kamel Bouhara (2): mfd: Add max7360 support pwm: max7360: Add MAX7360 PWM support Mathieu Dubois-Briand (5): dt-bindings: mfd: gpio: Add MAX7360 gpio: max7360: Add MAX7360 gpio support input: keyboard: Add support for MAX7360 keypad input: misc: Add support for MAX7360 rotary MAINTAINERS: Add entry on MAX7360 driver .../bindings/gpio/maxim,max7360-gpio.yaml | 90 ++++ .../devicetree/bindings/mfd/maxim,max7360.yaml | 140 +++++++ MAINTAINERS | 12 + drivers/gpio/Kconfig | 11 + drivers/gpio/Makefile | 1 + drivers/gpio/gpio-max7360.c | 454 +++++++++++++++++++++ drivers/input/keyboard/Kconfig | 12 + drivers/input/keyboard/Makefile | 1 + drivers/input/keyboard/max7360-keypad.c | 284 +++++++++++++ drivers/input/misc/Kconfig | 11 + drivers/input/misc/Makefile | 1 + drivers/input/misc/max7360-rotary.c | 183 +++++++++ drivers/mfd/Kconfig | 12 + drivers/mfd/Makefile | 1 + drivers/mfd/max7360.c | 296 ++++++++++++++ drivers/pwm/Kconfig | 11 + drivers/pwm/Makefile | 1 + drivers/pwm/pwm-max7360.c | 220 ++++++++++ include/linux/mfd/max7360.h | 109 +++++ 19 files changed, 1850 insertions(+) --- base-commit: 78d4f34e2115b517bcbfe7ec0d018bbbb6f9b0b8 change-id: 20241219-mdb-max7360-support-223a8ce45ba3 Best regards,