1 // SPDX-License-Identifier: (GPL-2.0 OR BSD-3-Clause) 2 // Copyright(c) 2024 Intel Corporation 3 4 /* 5 * The MIPI SDCA specification is available for public downloads at 6 * https://www.mipi.org/mipi-sdca-v1-0-download 7 */ 8 9 #include <linux/acpi.h> 10 #include <linux/soundwire/sdw.h> 11 #include <sound/sdca.h> 12 #include <sound/sdca_function.h> 13 sdca_lookup_interface_revision(struct sdw_slave * slave)14void sdca_lookup_interface_revision(struct sdw_slave *slave) 15 { 16 struct fwnode_handle *fwnode = slave->dev.fwnode; 17 18 /* 19 * if this property is not present, then the sdca_interface_revision will 20 * remain zero, which will be considered as 'not defined' or 'invalid'. 21 */ 22 fwnode_property_read_u32(fwnode, "mipi-sdw-sdca-interface-revision", 23 &slave->sdca_data.interface_revision); 24 } 25 EXPORT_SYMBOL_NS(sdca_lookup_interface_revision, "SND_SOC_SDCA"); 26 sdca_device_quirk_rt712_vb(struct sdw_slave * slave)27static bool sdca_device_quirk_rt712_vb(struct sdw_slave *slave) 28 { 29 struct sdw_slave_id *id = &slave->id; 30 int i; 31 32 /* 33 * The RT712_VA relies on the v06r04 draft, and the 34 * RT712_VB on a more recent v08r01 draft. 35 */ 36 if (slave->sdca_data.interface_revision < 0x0801) 37 return false; 38 39 if (id->mfg_id != 0x025d) 40 return false; 41 42 if (id->part_id != 0x712 && 43 id->part_id != 0x713 && 44 id->part_id != 0x716 && 45 id->part_id != 0x717) 46 return false; 47 48 for (i = 0; i < slave->sdca_data.num_functions; i++) { 49 if (slave->sdca_data.sdca_func[i].type == 50 SDCA_FUNCTION_TYPE_SMART_MIC) 51 return true; 52 } 53 54 return false; 55 } 56 sdca_device_quirk_match(struct sdw_slave * slave,enum sdca_quirk quirk)57bool sdca_device_quirk_match(struct sdw_slave *slave, enum sdca_quirk quirk) 58 { 59 switch (quirk) { 60 case SDCA_QUIRKS_RT712_VB: 61 return sdca_device_quirk_rt712_vb(slave); 62 default: 63 break; 64 } 65 return false; 66 } 67 EXPORT_SYMBOL_NS(sdca_device_quirk_match, "SND_SOC_SDCA"); 68