217
217
#define SUN8I_A23_CODEC_DAC_TXCNT (0x1c)
218
218
#define SUN8I_A23_CODEC_ADC_RXCNT (0x20)
219
219
220
+ /* TX FIFO moved on H3 */
221
+ #define SUN8I_H3_CODEC_DAC_TXDATA (0x20)
222
+ #define SUN8I_H3_CODEC_DAC_DBG (0x48)
223
+ #define SUN8I_H3_CODEC_ADC_DBG (0x4c)
224
+
225
+ /* TODO H3 DAP (Digital Audio Processing) bits */
226
+
220
227
struct sun4i_codec {
221
228
struct device * dev ;
222
229
struct regmap * regmap ;
@@ -1293,6 +1300,44 @@ static struct snd_soc_card *sun8i_a23_codec_create_card(struct device *dev)
1293
1300
return card ;
1294
1301
};
1295
1302
1303
+ static struct snd_soc_card * sun8i_h3_codec_create_card (struct device * dev )
1304
+ {
1305
+ struct snd_soc_card * card ;
1306
+ int ret ;
1307
+
1308
+ card = devm_kzalloc (dev , sizeof (* card ), GFP_KERNEL );
1309
+ if (!card )
1310
+ return ERR_PTR (- ENOMEM );
1311
+
1312
+ aux_dev .codec_of_node = of_parse_phandle (dev -> of_node ,
1313
+ "allwinner,codec-analog-controls" ,
1314
+ 0 );
1315
+ if (!aux_dev .codec_of_node ) {
1316
+ dev_err (dev , "Can't find analog controls for codec.\n" );
1317
+ return ERR_PTR (- EINVAL );
1318
+ };
1319
+
1320
+ card -> dai_link = sun4i_codec_create_link (dev , & card -> num_links );
1321
+ if (!card -> dai_link )
1322
+ return ERR_PTR (- ENOMEM );
1323
+
1324
+ card -> dev = dev ;
1325
+ card -> name = "H3 Audio Codec" ;
1326
+ card -> dapm_widgets = sun6i_codec_card_dapm_widgets ;
1327
+ card -> num_dapm_widgets = ARRAY_SIZE (sun6i_codec_card_dapm_widgets );
1328
+ card -> dapm_routes = sun8i_codec_card_routes ;
1329
+ card -> num_dapm_routes = ARRAY_SIZE (sun8i_codec_card_routes );
1330
+ card -> aux_dev = & aux_dev ;
1331
+ card -> num_aux_devs = 1 ;
1332
+ card -> fully_routed = true;
1333
+
1334
+ ret = snd_soc_of_parse_audio_routing (card , "allwinner,audio-routing" );
1335
+ if (ret )
1336
+ dev_warn (dev , "failed to parse audio-routing: %d\n" , ret );
1337
+
1338
+ return card ;
1339
+ };
1340
+
1296
1341
static const struct regmap_config sun4i_codec_regmap_config = {
1297
1342
.reg_bits = 32 ,
1298
1343
.reg_stride = 4 ,
@@ -1321,6 +1366,13 @@ static const struct regmap_config sun8i_a23_codec_regmap_config = {
1321
1366
.max_register = SUN8I_A23_CODEC_ADC_RXCNT ,
1322
1367
};
1323
1368
1369
+ static const struct regmap_config sun8i_h3_codec_regmap_config = {
1370
+ .reg_bits = 32 ,
1371
+ .reg_stride = 4 ,
1372
+ .val_bits = 32 ,
1373
+ .max_register = SUN8I_H3_CODEC_ADC_DBG ,
1374
+ };
1375
+
1324
1376
struct sun4i_codec_quirks {
1325
1377
const struct regmap_config * regmap_config ;
1326
1378
const struct snd_soc_codec_driver * codec ;
@@ -1369,6 +1421,21 @@ static const struct sun4i_codec_quirks sun8i_a23_codec_quirks = {
1369
1421
.has_reset = true,
1370
1422
};
1371
1423
1424
+ static const struct sun4i_codec_quirks sun8i_h3_codec_quirks = {
1425
+ .regmap_config = & sun8i_h3_codec_regmap_config ,
1426
+ /*
1427
+ * TODO Share the codec structure with A23 for now.
1428
+ * This should be split out when adding digital audio
1429
+ * processing support for the H3.
1430
+ */
1431
+ .codec = & sun8i_a23_codec_codec ,
1432
+ .create_card = sun8i_h3_codec_create_card ,
1433
+ .reg_adc_fifoc = REG_FIELD (SUN6I_CODEC_ADC_FIFOC , 0 , 31 ),
1434
+ .reg_dac_txdata = SUN8I_H3_CODEC_DAC_TXDATA ,
1435
+ .reg_adc_rxdata = SUN6I_CODEC_ADC_RXDATA ,
1436
+ .has_reset = true,
1437
+ };
1438
+
1372
1439
static const struct of_device_id sun4i_codec_of_match [] = {
1373
1440
{
1374
1441
.compatible = "allwinner,sun4i-a10-codec" ,
@@ -1386,6 +1453,10 @@ static const struct of_device_id sun4i_codec_of_match[] = {
1386
1453
.compatible = "allwinner,sun8i-a23-codec" ,
1387
1454
.data = & sun8i_a23_codec_quirks ,
1388
1455
},
1456
+ {
1457
+ .compatible = "allwinner,sun8i-h3-codec" ,
1458
+ .data = & sun8i_h3_codec_quirks ,
1459
+ },
1389
1460
{}
1390
1461
};
1391
1462
MODULE_DEVICE_TABLE (of , sun4i_codec_of_match );
0 commit comments