diff --git a/drivers/soundwire/cadence_master.c b/drivers/soundwire/cadence_master.c index 37c7d5666801d5..3663bf4946c014 100644 --- a/drivers/soundwire/cadence_master.c +++ b/drivers/soundwire/cadence_master.c @@ -1352,6 +1352,16 @@ int sdw_cdns_init(struct sdw_cdns *cdns) { u32 val; + { + int ret; + + dev_info(cdns->dev, "starting bra test\n"); + ret = sdw_cdns_test_bra_data_block(); + if (ret < 0) + return ret; + dev_info(cdns->dev, "done bra test\n"); + } + cdns_init_clock_ctrl(cdns); sdw_cdns_check_self_clearing_bits(cdns, __func__, false, 0); @@ -2307,5 +2317,89 @@ int sdw_cdns_prepare_read_dma_buffer(u8 dev_num, u32 start_register, } EXPORT_SYMBOL(sdw_cdns_prepare_read_dma_buffer); +int sdw_cdns_test_bra_data_block(void) +{ + u8 dev_num = 2; + u8 data[7]; + int data_size = ARRAY_SIZE(data); + int requested_bytes_per_frame = 3; + int data_per_frame; + u8 dma_buffer[256]; + int dma_buffer_size; + unsigned int pdi0_buffer_size; + unsigned int pdi1_buffer_size; + unsigned int num_frames; + + u32 start_register = 0x12345678; + int total_dma_data_written; + int ret; + int row = 50; + int col = 4; + + /* first frame */ + data[0] = 0xED; + data[1] = 0xD1; + data[2] = 0xEA; + + /* second frame */ + data[3] = 0xED; + data[4] = 0xD1; + data[5] = 0xEA; + + /* third partial frame */ + data[6] = 0xDD; + + ret = sdw_cdns_bpt_find_buffer_sizes(0, + row, col, + data_size, + requested_bytes_per_frame, + &data_per_frame, + &pdi0_buffer_size, + &pdi1_buffer_size, + &num_frames); + if (ret < 0) + return ret; + + dma_buffer_size = pdi0_buffer_size; + + ret = sdw_cdns_prepare_write_dma_buffer(dev_num, start_register, + data, data_size, + data_per_frame, + dma_buffer, dma_buffer_size, + &total_dma_data_written); + if (ret < 0) + return ret; + + print_hex_dump_debug("DMA data: ", DUMP_PREFIX_OFFSET, + 4, 4, dma_buffer, total_dma_data_written, false); + + ret = sdw_cdns_bpt_find_buffer_sizes(1, + row, col, + data_size, + requested_bytes_per_frame, + &data_per_frame, + &pdi0_buffer_size, + &pdi1_buffer_size, + &num_frames); + if (ret < 0) + return ret; + + dma_buffer_size = pdi0_buffer_size; + + ret = sdw_cdns_prepare_read_dma_buffer(dev_num, start_register, + data_size, + data_per_frame, + dma_buffer, dma_buffer_size, + &total_dma_data_written); + if (ret < 0) + return ret; + + print_hex_dump_debug("DMA data: ", DUMP_PREFIX_OFFSET, + 4, 4, dma_buffer, total_dma_data_written, false); + + return 0; +} +EXPORT_SYMBOL(sdw_cdns_test_bra_data_block); + MODULE_LICENSE("Dual BSD/GPL"); MODULE_DESCRIPTION("Cadence Soundwire Library"); diff --git a/drivers/soundwire/cadence_master.h b/drivers/soundwire/cadence_master.h index aae246997add90..d22c7a632d4cd8 100644 --- a/drivers/soundwire/cadence_master.h +++ b/drivers/soundwire/cadence_master.h @@ -224,4 +224,6 @@ int sdw_cdns_prepare_read_dma_buffer(u8 dev_num, u32 start_register, u8 *dma_buffer, int dma_buffer_size, int *dma_buffer_total_bytes); +int sdw_cdns_test_bra_data_block(void); + #endif /* __SDW_CADENCE_H */