Skip to content

Commit 74442b9

Browse files
committed
iio: adc: adrv902x: Add tracking config
Add tracking configuration settings. Signed-off-by: George Mois <[email protected]>
1 parent eefd8a7 commit 74442b9

File tree

2 files changed

+107
-9
lines changed

2 files changed

+107
-9
lines changed

drivers/iio/adc/adrv902x/adrv9025.c

Lines changed: 106 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ enum adrv9025_iio_dev_attr {
4747
ADRV9025_CAL_MASK,
4848
ADRV9025_DPD_TX_MASK,
4949
ADRV9025_DPD_RESET,
50+
ADRV9025_DPD_CONFIG_SET,
5051
adrv9025_JESD204_FSM_ERROR,
5152
adrv9025_JESD204_FSM_PAUSED,
5253
adrv9025_JESD204_FSM_STATE,
@@ -396,6 +397,20 @@ static ssize_t adrv9025_phy_store(struct device *dev,
396397
ret = adrv9025_dev_err(phy);
397398
}
398399
break;
400+
case ADRV9025_DPD_CONFIG_SET:
401+
ret = kstrtobool(buf, &enable);
402+
if (ret)
403+
break;
404+
405+
phy->dpdTrackingConfig->txChannelMask = phy->dpdTxChannel;
406+
407+
if (enable) {
408+
ret = adi_adrv9025_DpdTrackingConfigSet(phy->madDevice,
409+
phy->dpdTrackingConfig);
410+
if (ret)
411+
ret = adrv9025_dev_err(phy);
412+
}
413+
break;
399414
case adrv9025_JESD204_FSM_RESUME:
400415
if (!phy->jdev) {
401416
ret = -ENOTSUPP;
@@ -587,6 +602,9 @@ static IIO_DEVICE_ATTR(dpd_tx_mask, 0644, adrv9025_phy_show,
587602
static IIO_DEVICE_ATTR(dpd_reset, 0200, NULL,
588603
adrv9025_phy_store, ADRV9025_DPD_RESET);
589604

605+
static IIO_DEVICE_ATTR(dpd_tracking_config_set, 0200, NULL,
606+
adrv9025_phy_store, ADRV9025_DPD_CONFIG_SET);
607+
590608
static IIO_DEVICE_ATTR(jesd204_fsm_error, 0444,
591609
adrv9025_phy_show,
592610
NULL,
@@ -622,6 +640,7 @@ static struct attribute *adrv9025_phy_attributes[] = {
622640
&iio_dev_attr_calibrate_mask.dev_attr.attr,
623641
&iio_dev_attr_dpd_tx_mask.dev_attr.attr,
624642
&iio_dev_attr_dpd_reset.dev_attr.attr,
643+
&iio_dev_attr_dpd_tracking_config_set.dev_attr.attr,
625644
&iio_dev_attr_jesd204_fsm_error.dev_attr.attr,
626645
&iio_dev_attr_jesd204_fsm_state.dev_attr.attr,
627646
&iio_dev_attr_jesd204_fsm_paused.dev_attr.attr,
@@ -3010,6 +3029,72 @@ static int adrv9025_phy_parse_agc_dt(struct iio_dev *iodev, struct device *dev)
30103029
&phy->agcConfig->agcSlowloopFastGainChangeBlockEnable, 0, 0, 1);
30113030
}
30123031

3032+
static int adrv9025_phy_parse_dpd_config_dt(struct iio_dev *iodev, struct device *dev)
3033+
{
3034+
struct adrv9025_rf_phy *phy = iio_priv(iodev);
3035+
struct device_node *np = dev->of_node;
3036+
int ret;
3037+
3038+
ret = ADRV9025_OF_PROP("adi,dpd-indirect-regularization-value",
3039+
&phy->dpdTrackingConfig->dpdIndirectRegularizationValue, 20, 0, 63);
3040+
if (ret)
3041+
return ret;
3042+
3043+
ret = ADRV9025_OF_PROP("adi,dpd-direct-regularization-value",
3044+
&phy->dpdTrackingConfig->dpdDirectRegularizationValue, 35, 0, 63);
3045+
if (ret)
3046+
return ret;
3047+
3048+
ret = ADRV9025_OF_PROP("adi,dpd-samples",
3049+
&phy->dpdTrackingConfig->dpdSamples, 16384, 4096, 61440);
3050+
if (ret)
3051+
return ret;
3052+
3053+
ret = ADRV9025_OF_PROP("adi,dpd-m-threshold",
3054+
&phy->dpdTrackingConfig->dpdMThreshold, 2920, 0, 32767);
3055+
if (ret)
3056+
return ret;
3057+
3058+
ret = ADRV9025_OF_PROP("adi,dpd-peak-search-window-size",
3059+
&phy->dpdTrackingConfig->dpdPeakSearchWindowSize, 65535, 0, 16777215);
3060+
if (ret)
3061+
return ret;
3062+
3063+
ret = ADRV9025_OF_PROP("adi,dpd-update-mode",
3064+
&phy->dpdTrackingConfig->dpdUpdateMode, 0, 0, 2);
3065+
if (ret)
3066+
return ret;
3067+
3068+
ret = ADRV9025_OF_PROP("adi,dpd-min-avg-signal-level",
3069+
&phy->dpdTrackingConfig->minAvgSignalLevel, 519, 0, 65535);
3070+
if (ret)
3071+
return ret;
3072+
3073+
ret = ADRV9025_OF_PROP("adi,dpd-mu",
3074+
&phy->dpdTrackingConfig->dpdMu, 50, 0, 100);
3075+
if (ret)
3076+
return ret;
3077+
3078+
ret = ADRV9025_OF_PROP("adi,dpd-min-avg-signal-level-orx",
3079+
&phy->dpdTrackingConfig->minAvgSignalLevelOrx, 519, 0, 65535);
3080+
if (ret)
3081+
return ret;
3082+
3083+
ret = ADRV9025_OF_PROP("adi,dpd-filter-sel",
3084+
&phy->dpdTrackingConfig->dpdFilterSel, 0, 0, 1);
3085+
if (ret)
3086+
return ret;
3087+
3088+
ret = ADRV9025_OF_PROP("adi,dpd-enable-direct-learning",
3089+
&phy->dpdTrackingConfig->enableDirectLearning, 0, 0, 1);
3090+
if (ret)
3091+
return ret;
3092+
3093+
return ADRV9025_OF_PROP("adi,dpd-indirect-regularization-low-power-value",
3094+
&phy->dpdTrackingConfig->dpdIndirectRegularizationLowPowerValue,
3095+
20, 0, 63);
3096+
}
3097+
30133098
static int adrv9025_parse_dpd_coef(struct adrv9025_rf_phy *phy, char *data, u32 size)
30143099
{
30153100
u8 dpdNumFeatures = 0, i, j, k, lut;
@@ -3201,11 +3286,20 @@ static int adrv9025_probe(struct spi_device *spi)
32013286
phy->dpdModelConfig = kzalloc(sizeof(adi_adrv9025_DpdModelConfig_v2_t), GFP_KERNEL);
32023287
if (!(phy->dpdModelConfig))
32033288
return -ENOMEM;
3289+
phy->dpdTrackingConfig = kzalloc(sizeof(adi_adrv9025_DpdTrackingConfig_t), GFP_KERNEL);
3290+
if (!(phy->dpdTrackingConfig)) {
3291+
ret = -ENOMEM;
3292+
goto err_free_dpd_model;
3293+
}
32043294
mutex_init(&phy->lock);
32053295

32063296
ret = adrv9025_phy_parse_agc_dt(indio_dev, &spi->dev);
32073297
if (ret)
3208-
goto err_free_dpd_model;
3298+
goto err_free_dpd_tracking_config;
3299+
3300+
ret = adrv9025_phy_parse_dpd_config_dt(indio_dev, &spi->dev);
3301+
if (ret)
3302+
goto err_free_dpd_tracking_config;
32093303

32103304
priv = jesd204_dev_priv(jdev);
32113305
priv->phy = phy;
@@ -3220,15 +3314,15 @@ static int adrv9025_probe(struct spi_device *spi)
32203314
} else {
32213315
dev_err(&spi->dev, "error missing dt property: adi,arm-firmware-name\n");
32223316
ret = -EINVAL;
3223-
goto err_free_dpd_model;
3317+
goto err_free_dpd_tracking_config;
32243318
}
32253319

32263320
if (!of_property_read_string(np, "adi,stream-firmware-name", &name)) {
32273321
strncpy(phy->platformFiles.streamImageFile, name, sizeof(phy->platformFiles.streamImageFile));
32283322
} else {
32293323
dev_err(&spi->dev, "error missing dt property: adi,stream-firmware-name\n");
32303324
ret = -EINVAL;
3231-
goto err_free_dpd_model;
3325+
goto err_free_dpd_tracking_config;
32323326
}
32333327

32343328
for (i = 0; i < ARRAY_SIZE(phy->platformFiles.rxGainTableFileArr); i++) {
@@ -3260,7 +3354,7 @@ static int adrv9025_probe(struct spi_device *spi)
32603354

32613355
ret = clk_prepare_enable(phy->dev_clk);
32623356
if (ret)
3263-
goto err_free_dpd_model;
3357+
goto err_free_dpd_tracking_config;
32643358

32653359
phy->spiSettings.msbFirst = 1;
32663360
phy->spiSettings.enSpiStreaming = 0;
@@ -3271,7 +3365,7 @@ static int adrv9025_probe(struct spi_device *spi)
32713365
ret = adi_adrv9025_HwOpen(phy->madDevice, &phy->spiSettings);
32723366
if (ret) {
32733367
ret = adrv9025_dev_err(phy);
3274-
goto err_free_dpd_model;
3368+
goto err_free_dpd_tracking_config;
32753369
}
32763370

32773371
adi_common_LogLevelSet(&phy->madDevice->common,
@@ -3282,26 +3376,26 @@ static int adrv9025_probe(struct spi_device *spi)
32823376
if (ret) {
32833377
dev_err(&spi->dev, "error missing dt property: adi,device-profile-name\n");
32843378
ret = -EINVAL;
3285-
goto err_free_dpd_model;
3379+
goto err_free_dpd_tracking_config;
32863380
}
32873381

32883382
ret = adi_adrv9025_ConfigFileLoad(phy->madDevice, name, &phy->deviceInitStruct);
32893383
if (ret) {
32903384
ret = adrv9025_dev_err(phy);
3291-
goto err_free_dpd_model;
3385+
goto err_free_dpd_tracking_config;
32923386
}
32933387

32943388
ret = of_property_read_string(np, "adi,init-profile-name", &name);
32953389
if (ret) {
32963390
dev_err(&spi->dev, "error missing dt property: adi,init-profile-name\n");
32973391
ret = adrv9025_dev_err(phy);
3298-
goto err_free_dpd_model;
3392+
goto err_free_dpd_tracking_config;
32993393
}
33003394

33013395
ret = adi_adrv9025_UtilityInitFileLoad(phy->madDevice, name, &phy->adrv9025PostMcsInitInst);
33023396
if (ret) {
33033397
ret = adrv9025_dev_err(phy);
3304-
goto err_free_dpd_model;
3398+
goto err_free_dpd_tracking_config;
33053399
}
33063400

33073401
phy->cal_mask.channelMask = phy->adrv9025PostMcsInitInst.initCals.channelMask;
@@ -3400,6 +3494,8 @@ static int adrv9025_probe(struct spi_device *spi)
34003494
of_clk_del_provider(np);
34013495
out_disable_clocks:
34023496
clk_disable_unprepare(phy->dev_clk);
3497+
err_free_dpd_tracking_config:
3498+
kfree(phy->dpdTrackingConfig);
34033499
err_free_dpd_model:
34043500
kfree(phy->dpdModelConfig);
34053501

@@ -3413,6 +3509,7 @@ static void adrv9025_remove(struct spi_device *spi)
34133509
iio_device_unregister(phy->indio_dev);
34143510
of_clk_del_provider(spi->dev.of_node);
34153511
clk_disable_unprepare(phy->dev_clk);
3512+
kfree(phy->dpdTrackingConfig);
34163513
kfree(phy->dpdModelConfig);
34173514

34183515
adrv9025_shutdown(phy);

drivers/iio/adc/adrv902x/adrv9025.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,7 @@ struct adrv9025_rf_phy {
170170
/* DPD */
171171
adi_adrv9025_DpdModelConfig_v2_t *dpdModelConfig;
172172
adi_adrv9025_TxChannels_e dpdTxChannel;
173+
adi_adrv9025_DpdTrackingConfig_t *dpdTrackingConfig;
173174
};
174175

175176
int adrv9025_hdl_loopback(struct adrv9025_rf_phy *phy, bool enable);

0 commit comments

Comments
 (0)