Attention is currently required from: Tim Crawford. Angel Pons has posted comments on this change. ( https://review.coreboot.org/c/coreboot/+/47962 )
Change subject: mb/system76/oryp5: Enable TAS5825M smart amp ......................................................................
Patch Set 6:
(2 comments)
File src/mainboard/system76/oryp5/tas5825m.c:
https://review.coreboot.org/c/coreboot/+/47962/comment/fa8d51b6_3153441d PS5, Line 8: return
Could you clarify how using arrays would resolve checking the return? […]
Yes, you could use `tas5825m_write_block_at`.
The problem with the return is that it's within a macro, and macros with flow control statements should be avoided: https://doc.coreboot.org/coding_style.html#macros-enums-and-rtl
https://review.coreboot.org/c/coreboot/+/47962/comment/f1577e64_bff56b26 PS5, Line 67: amp_write_at(0x08, 0x00); : amp_write_at(0x09, 0xFE); : amp_write_at(0x0A, 0x00); : amp_write_at(0x0B, 0x40); : amp_write_at(0x0C, 0x00); : amp_write_at(0x0D, 0xFC); : amp_write_at(0x0E, 0x00); : amp_write_at(0x0F, 0x00); : amp_write_at(0x10, 0x00); : amp_write_at(0x11, 0xFC); : amp_write_at(0x12, 0x00); : amp_write_at(0x13, 0x00); : amp_write_at(0x14, 0x00); : amp_write_at(0x15, 0xFC); : amp_write_at(0x16, 0x00); : amp_write_at(0x17, 0x00); : amp_write_at(0x18, 0x00); : amp_write_at(0x19, 0xFC); : amp_write_at(0x1A, 0x00); : amp_write_at(0x1B, 0x00); : amp_write_at(0x1C, 0x00); : amp_write_at(0x1D, 0xFC); : amp_write_at(0x1E, 0x00); : amp_write_at(0x1F, 0x00); : amp_write_at(0x20, 0x00); : amp_write_at(0x21, 0xFC); : amp_write_at(0x22, 0x00); : amp_write_at(0x23, 0x00); : amp_write_at(0x24, 0x00); : amp_write_at(0x25, 0xFC); : amp_write_at(0x26, 0x00); : amp_write_at(0x27, 0x00); : amp_write_at(0x28, 0x00); : amp_write_at(0x29, 0xFC); : amp_write_at(0x2A, 0x50); : amp_write_at(0x2B, 0x00); : amp_write_at(0x2C, 0x00); : amp_write_at(0x2D, 0xFC); : amp_write_at(0x2E, 0x00); : amp_write_at(0x2F, 0x00); : amp_write_at(0x30, 0x00); : amp_write_at(0x31, 0xFC); : amp_write_at(0x32, 0x00); : amp_write_at(0x33, 0x00); : amp_write_at(0x34, 0x00); : amp_write_at(0x35, 0xFC); : amp_write_at(0x36, 0x00); : amp_write_at(0x37, 0x00); : amp_write_at(0x38, 0x00); : amp_write_at(0x39, 0xFC); : amp_write_at(0x3A, 0x00); : amp_write_at(0x3B, 0x00); : amp_write_at(0x3C, 0x00); : amp_write_at(0x3D, 0xFC); : amp_write_at(0x3E, 0x00); : amp_write_at(0x3F, 0x00); : amp_write_at(0x40, 0x00); : amp_write_at(0x41, 0xFC); : amp_write_at(0x42, 0x00); : amp_write_at(0x43, 0x00); : amp_write_at(0x44, 0x00); : amp_write_at(0x45, 0xFC); : amp_write_at(0x46, 0x00); : amp_write_at(0x47, 0x00); : amp_write_at(0x48, 0x00); : amp_write_at(0x49, 0xFC); : amp_write_at(0x4A, 0x00); : amp_write_at(0x4B, 0x00); : amp_write_at(0x4C, 0x00); : amp_write_at(0x4D, 0xFC); : amp_write_at(0x4E, 0x00); : amp_write_at(0x4F, 0x00); : amp_write_at(0x50, 0x00); : amp_write_at(0x51, 0xFC); : amp_write_at(0x52, 0x00); : amp_write_at(0x53, 0x00); : amp_write_at(0x54, 0x00); : amp_write_at(0x55, 0xFC); : amp_write_at(0x56, 0x00); : amp_write_at(0x57, 0x00); : amp_write_at(0x58, 0x00); : amp_write_at(0x59, 0xFC); : amp_write_at(0x5A, 0x00); : amp_write_at(0x5B, 0x00); : amp_write_at(0x5C, 0x00); : amp_write_at(0x5D, 0xFC); : amp_write_at(0x5E, 0x00); : amp_write_at(0x5F, 0x00); : amp_write_at(0x60, 0x00); : amp_write_at(0x61, 0xFC); : amp_write_at(0x62, 0x00); : amp_write_at(0x63, 0x00); : amp_write_at(0x64, 0x00); : amp_write_at(0x65, 0xFC); : amp_write_at(0x66, 0x00); : amp_write_at(0x67, 0x00); : amp_write_at(0x68, 0x00); : amp_write_at(0x69, 0x82); : amp_write_at(0x6A, 0x00); : amp_write_at(0x6B, 0x93); : amp_write_at(0x6C, 0x00); : amp_write_at(0x6D, 0xFC); : amp_write_at(0x6E, 0x00); : amp_write_at(0x6F, 0x00); : amp_write_at(0x70, 0x84); : amp_write_at(0x71, 0xC1); : amp_write_at(0x72, 0x02); : amp_write_at(0x73, 0x9F); : amp_write_at(0x74, 0x08); : amp_write_at(0x75, 0x18); : amp_write_at(0x76, 0x10); : amp_write_at(0x77, 0x00); : amp_write_at(0x78, 0x02); : amp_write_at(0x79, 0x28); : amp_write_at(0x7A, 0x00); : amp_write_at(0x7B, 0x03); : amp_write_at(0x7C, 0x8F); : amp_write_at(0x7D, 0x00); : amp_write_at(0x7E, 0xFF); : amp_write_at(0x7F, 0xF8); Looks like these values go from 8 to 0x7f, but I didn't check if there's any gaps. If there are none, then do the following:
const uint8_t page1_values[] = { 0x00 ,0xFE, 0x00, 0x40, 0x00, 0xFC, 0x00, 0x00, /* Rest of values */ };
_Static_assert(ARRAY_SIZE(page1_values) == 0x78, "Array length is wrong");
for (uint8_t i = 0; i < ARRAY_SIZE(page1_values); i++) { if (tas5825m_write_at(dev, 8 + i, page1_values[i]) < 0) return; }
You could also use `tas5825m_write_block_at`. Another interesting thing would be to use a 2D array to store the values for each page, and use two loops to program the values.