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/module.h> 11 #include <linux/property.h> 12 #include <linux/soundwire/sdw.h> 13 #include <sound/sdca.h> 14 #include <sound/sdca_function.h> 15 sdca_lookup_interface_revision(struct sdw_slave * slave)16void sdca_lookup_interface_revision(struct sdw_slave *slave) 17 { 18 struct fwnode_handle *fwnode = slave->dev.fwnode; 19 20 /* 21 * if this property is not present, then the sdca_interface_revision will 22 * remain zero, which will be considered as 'not defined' or 'invalid'. 23 */ 24 fwnode_property_read_u32(fwnode, "mipi-sdw-sdca-interface-revision", 25 &slave->sdca_data.interface_revision); 26 } 27 EXPORT_SYMBOL_NS(sdca_lookup_interface_revision, "SND_SOC_SDCA"); 28 sdca_device_quirk_rt712_vb(struct sdw_slave * slave)29static bool sdca_device_quirk_rt712_vb(struct sdw_slave *slave) 30 { 31 struct sdw_slave_id *id = &slave->id; 32 int i; 33 34 /* 35 * The RT712_VA relies on the v06r04 draft, and the 36 * RT712_VB on a more recent v08r01 draft. 37 */ 38 if (slave->sdca_data.interface_revision < 0x0801) 39 return false; 40 41 if (id->mfg_id != 0x025d) 42 return false; 43 44 if (id->part_id != 0x712 && 45 id->part_id != 0x713 && 46 id->part_id != 0x716 && 47 id->part_id != 0x717) 48 return false; 49 50 for (i = 0; i < slave->sdca_data.num_functions; i++) { 51 if (slave->sdca_data.function[i].type == SDCA_FUNCTION_TYPE_SMART_MIC) 52 return true; 53 } 54 55 return false; 56 } 57 sdca_device_quirk_match(struct sdw_slave * slave,enum sdca_quirk quirk)58bool sdca_device_quirk_match(struct sdw_slave *slave, enum sdca_quirk quirk) 59 { 60 switch (quirk) { 61 case SDCA_QUIRKS_RT712_VB: 62 return sdca_device_quirk_rt712_vb(slave); 63 default: 64 break; 65 } 66 return false; 67 } 68 EXPORT_SYMBOL_NS(sdca_device_quirk_match, "SND_SOC_SDCA"); 69