• Hugo Villeneuve's avatar
    serial: sc16is7xx: improve regmap debugfs by using one regmap per port · 3837a037
    Hugo Villeneuve authored
    With this current driver regmap implementation, it is hard to make sense
    of the register addresses displayed using the regmap debugfs interface,
    because they do not correspond to the actual register addresses documented
    in the datasheet. For example, register 1 is displayed as registers 04 thru
    07:
    
    $ cat /sys/kernel/debug/regmap/spi0.0/registers
      04: 10 -> Port 0, register offset 1
      05: 10 -> Port 1, register offset 1
      06: 00 -> Port 2, register offset 1 -> invalid
      07: 00 -> port 3, register offset 1 -> invalid
      ...
    
    The reason is that bits 0 and 1 of the register address correspond to the
    channel (port) bits, so the register address itself starts at bit 2, and we
    must 'mentally' shift each register address by 2 bits to get its real
    address/offset.
    
    Also, only channels 0 and 1 are supported by the chip, so channel mask
    combinations of 10b and 11b are invalid, and the display of these
    registers is useless.
    
    This patch adds a separate regmap configuration for each port, similar to
    what is done in the max310x driver, so that register addresses displayed
    match the register addresses in the chip datasheet. Also, each port now has
    its own debugfs entry.
    
    Example with new regmap implementation:
    
    $ cat /sys/kernel/debug/regmap/spi0.0-port0/registers
    1: 10
    2: 01
    3: 00
    ...
    
    $ cat /sys/kernel/debug/regmap/spi0.0-port1/registers
    1: 10
    2: 01
    3: 00
    
    As an added bonus, this also simplifies some operations (read/write/modify)
    because it is no longer necessary to manually shift register addresses.
    Signed-off-by: default avatarHugo Villeneuve <hvilleneuve@dimonoff.com>
    Link: https://lore.kernel.org/r/20231030211447.974779-1-hugo@hugovil.comSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
    3837a037
sc16is7xx.c 53 KB