@@ -1133,6 +1133,45 @@ static int cs35l41_get_speaker_id(struct device *dev, int amp_index,
11331133 return speaker_id ;
11341134}
11351135
1136+ /*
1137+ * Device CLSA010(0/1) doesn't have _DSD so a gpiod_get by the label reset won't work.
1138+ * And devices created by serial-multi-instantiate don't have their device struct
1139+ * pointing to the correct fwnode, so acpi_dev must be used here.
1140+ * And devm functions expect that the device requesting the resource has the correct
1141+ * fwnode.
1142+ */
1143+ static int cs35l41_no_acpi_dsd (struct cs35l41_hda * cs35l41 , struct device * physdev , int id ,
1144+ const char * hid )
1145+ {
1146+ struct cs35l41_hw_cfg * hw_cfg = & cs35l41 -> hw_cfg ;
1147+
1148+ /* check I2C address to assign the index */
1149+ cs35l41 -> index = id == 0x40 ? 0 : 1 ;
1150+ cs35l41 -> channel_index = 0 ;
1151+ cs35l41 -> reset_gpio = gpiod_get_index (physdev , NULL , 0 , GPIOD_OUT_HIGH );
1152+ cs35l41 -> speaker_id = cs35l41_get_speaker_id (physdev , 0 , 0 , 2 );
1153+ hw_cfg -> spk_pos = cs35l41 -> index ;
1154+ hw_cfg -> gpio2 .func = CS35L41_INTERRUPT ;
1155+ hw_cfg -> gpio2 .valid = true;
1156+ hw_cfg -> valid = true;
1157+ put_device (physdev );
1158+
1159+ if (strncmp (hid , "CLSA0100" , 8 ) == 0 ) {
1160+ hw_cfg -> bst_type = CS35L41_EXT_BOOST_NO_VSPK_SWITCH ;
1161+ } else if (strncmp (hid , "CLSA0101" , 8 ) == 0 ) {
1162+ hw_cfg -> bst_type = CS35L41_EXT_BOOST ;
1163+ hw_cfg -> gpio1 .func = CS35l41_VSPK_SWITCH ;
1164+ hw_cfg -> gpio1 .valid = true;
1165+ } else {
1166+ hw_cfg -> valid = false;
1167+ hw_cfg -> gpio1 .valid = false;
1168+ hw_cfg -> gpio2 .valid = false;
1169+ return - EINVAL ;
1170+ }
1171+
1172+ return 0 ;
1173+ }
1174+
11361175static int cs35l41_hda_read_acpi (struct cs35l41_hda * cs35l41 , const char * hid , int id )
11371176{
11381177 struct cs35l41_hw_cfg * hw_cfg = & cs35l41 -> hw_cfg ;
@@ -1161,7 +1200,7 @@ static int cs35l41_hda_read_acpi(struct cs35l41_hda *cs35l41, const char *hid, i
11611200 property = "cirrus,dev-index" ;
11621201 ret = device_property_count_u32 (physdev , property );
11631202 if (ret <= 0 )
1164- goto no_acpi_dsd ;
1203+ return cs35l41_no_acpi_dsd ( cs35l41 , physdev , id , hid ) ;
11651204
11661205 if (ret > ARRAY_SIZE (values )) {
11671206 ret = - EINVAL ;
@@ -1255,31 +1294,6 @@ static int cs35l41_hda_read_acpi(struct cs35l41_hda *cs35l41, const char *hid, i
12551294 dev_err (cs35l41 -> dev , "Failed property %s: %d\n" , property , ret );
12561295
12571296 return ret ;
1258-
1259- no_acpi_dsd :
1260- /*
1261- * Device CLSA0100 doesn't have _DSD so a gpiod_get by the label reset won't work.
1262- * And devices created by serial-multi-instantiate don't have their device struct
1263- * pointing to the correct fwnode, so acpi_dev must be used here.
1264- * And devm functions expect that the device requesting the resource has the correct
1265- * fwnode.
1266- */
1267- if (strncmp (hid , "CLSA0100" , 8 ) != 0 )
1268- return - EINVAL ;
1269-
1270- /* check I2C address to assign the index */
1271- cs35l41 -> index = id == 0x40 ? 0 : 1 ;
1272- cs35l41 -> hw_cfg .spk_pos = cs35l41 -> index ;
1273- cs35l41 -> channel_index = 0 ;
1274- cs35l41 -> reset_gpio = gpiod_get_index (physdev , NULL , 0 , GPIOD_OUT_HIGH );
1275- cs35l41 -> hw_cfg .bst_type = CS35L41_EXT_BOOST_NO_VSPK_SWITCH ;
1276- cs35l41 -> speaker_id = cs35l41_get_speaker_id (physdev , 0 , 0 , 2 );
1277- hw_cfg -> gpio2 .func = CS35L41_INTERRUPT ;
1278- hw_cfg -> gpio2 .valid = true;
1279- cs35l41 -> hw_cfg .valid = true;
1280- put_device (physdev );
1281-
1282- return 0 ;
12831297}
12841298
12851299int cs35l41_hda_probe (struct device * dev , const char * device_name , int id , int irq ,
0 commit comments