• Pierre-Louis Bossart's avatar
    soundwire: debugfs: add interface to read/write commands · fe46d2a4
    Pierre-Louis Bossart authored
    We have an existing debugfs files to read standard registers
    (DP0/SCP/DPn).
    
    This patch provides a more generic interface to ANY set of read/write
    contiguous registers in a peripheral device. In follow-up patches,
    this interface will be extended to use BRA transfers.
    
    The sequence is to use the following files added under the existing
    debugsfs directory for each peripheral device:
    
    command (write 0, read 1)
    num_bytes
    start_address
    firmware_file (only for writes)
    read_buffer (only for reads)
    
    Example for a read command - this checks the 6 bytes used for
    enumeration.
    
    cd /sys/kernel/debug/soundwire/master-0-0/sdw\:0\:025d\:0711\:01/
    echo 1 > command
    echo 6 > num_bytes
    echo 0x50 > start_address
    echo 1 > go
    cat read_buffer
    address 0x50 val 0x30
    address 0x51 val 0x02
    address 0x52 val 0x5d
    address 0x53 val 0x07
    address 0x54 val 0x11
    address 0x55 val 0x01
    
    Example with a 2-byte firmware file written in DP0 address 0x22
    
    od -x /lib/firmware/test_firmware
    0000000 0a37
    0000002
    
    cd /sys/kernel/debug/soundwire/master-0-0/sdw\:0\:025d\:0711\:01/
    echo 0 > command
    echo 2 > num_bytes
    echo 0x22 > start_address
    echo "test_firmware" > firmware_file
    echo 1 > go
    
    cd /sys/kernel/debug/soundwire/master-0-0/sdw\:0\:025d\:0711\:01/
    echo 1 > command
    echo 2 > num_bytes
    echo 0x22 > start_address
    echo 1 > go
    cat read_buffer
    
    address 0x22 val 0x37
    address 0x23 val 0x0a
    Signed-off-by: default avatarPierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
    Reviewed-by: default avatarRander Wang <rander.wang@intel.com>
    Signed-off-by: default avatarBard Liao <yung-chuan.liao@linux.intel.com>
    Link: https://lore.kernel.org/r/20240603065841.4860-1-yung-chuan.liao@linux.intel.comSigned-off-by: default avatarVinod Koul <vkoul@kernel.org>
    fe46d2a4
debugfs.c 7.97 KB