-
Notifications
You must be signed in to change notification settings - Fork 970
iio: adc: adrv902x: add init cal and status attrs #3526
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -55,6 +55,9 @@ | |
| adrv9025_JESD204_FSM_STATE, | ||
| adrv9025_JESD204_FSM_RESUME, | ||
| adrv9025_JESD204_FSM_CTRL, | ||
| ADRV9025_INIT_CALS_COMPLETE_CHECK, | ||
| ADRV9025_INIT_STATUS_ALL, | ||
| ADRV9025_TRACKING_STATUS_ALL | ||
| }; | ||
|
|
||
| static int __adrv9025_dev_err(struct adrv9025_rf_phy *phy, const char *function, | ||
|
|
@@ -561,6 +564,67 @@ | |
|
|
||
| ret = sysfs_emit(buf, "%d\n", phy->is_initialized); | ||
| break; | ||
|
|
||
| case ADRV9025_INIT_CALS_COMPLETE_CHECK: | ||
| uint8_t status; | ||
| uint8_t ARMflag; | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same comment as above |
||
| ret = adi_adrv9025_InitCalsCheckCompleteGet(phy->madDevice, &status, &ARMflag); | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The naming of the ARMflag is inconsistent, as it uses CamelCase. The kernel preferred style is arm_flag. |
||
| if (ret) | ||
| adrv9025_dev_err(phy); | ||
|
|
||
| ret = sysfs_emit(buf, "Status: %d, ARM is error?: %d\n", status, ARMflag); | ||
|
|
||
| break; | ||
| case ADRV9025_INIT_STATUS_ALL: | ||
| adi_adrv9025_InitCalStatus_t initStatus; | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same comment, move declaration to the top of the switch case. |
||
| ret = adi_adrv9025_InitCalsDetailedStatusGet(phy->madDevice, &initStatus); | ||
|
Check warning on line 580 in drivers/iio/adc/adrv902x/adrv9025.c
|
||
| if (ret) | ||
| adrv9025_dev_err(phy); | ||
|
|
||
| ret = sysfs_emit(buf, | ||
| "initErrCode: 0x%08x (objId=0x%02x err=0x%02x)\n" | ||
| "initErrCal: 0x%08x, durationUsec: %u\n" | ||
| "calsSincePowerUp: [0x%08x 0x%08x 0x%08x 0x%08x]\n" | ||
| "calsLastRun: [0x%08x 0x%08x 0x%08x 0x%08x]\n", | ||
| initStatus.initErrCode, | ||
| (initStatus.initErrCode >> 8) & 0xFF, initStatus.initErrCode & 0xFF, | ||
| initStatus.initErrCal, initStatus.calsDurationUsec, | ||
| initStatus.calsSincePowerUp[0], initStatus.calsSincePowerUp[1], | ||
| initStatus.calsSincePowerUp[2], initStatus.calsSincePowerUp[3], | ||
| initStatus.calsLastRun[0], initStatus.calsLastRun[1], | ||
| initStatus.calsLastRun[2], initStatus.calsLastRun[3]); | ||
| break; | ||
|
|
||
| case ADRV9025_TRACKING_STATUS_ALL: | ||
| adi_adrv9025_TrackingCalState_t st; | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. another mid-block declaration. Move declaration to the top or wrap each case body in braces to create a new scope. |
||
|
|
||
| ret = adi_adrv9025_TrackingCalAllStateGet(phy->madDevice, &st); | ||
| if (ret) | ||
| adrv9025_dev_err(phy); | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hmm... Should you return ret or return adrv9025_dev_err(phy)? or please check this everywhere in the code. |
||
|
|
||
| ret = sysfs_emit(buf, | ||
| "calError: 0x%016llx\n" | ||
| "rxQec: [%u %u %u %u]\n" | ||
| "orxQec: [%u %u %u %u]\n" | ||
| "txLol: [%u %u %u %u]\n" | ||
| "txQec: [%u %u %u %u]\n" | ||
| "txDpd: [%u %u %u %u]\n" | ||
| "txClgc: [%u %u %u %u]\n" | ||
| "txVswr: [%u %u %u %u]\n" | ||
| "rxHd2: [%u %u %u %u]\n" | ||
| "deserializer: %u\n", | ||
| (unsigned long long)st.calError, | ||
| st.rx1Qec, st.rx2Qec, st.rx3Qec, st.rx4Qec, | ||
| st.orx1Qec, st.orx2Qec, st.orx3Qec, st.orx4Qec, | ||
| st.tx1Lol, st.tx2Lol, st.tx3Lol, st.tx4Lol, | ||
| st.tx1Qec, st.tx2Qec, st.tx3Qec, st.tx4Qec, | ||
| st.tx1Dpd, st.tx2Dpd, st.tx3Dpd, st.tx4Dpd, | ||
| st.tx1Clgc, st.tx2Clgc, st.tx3Clgc, st.tx4Clgc, | ||
| st.tx1Vswr, st.tx2Vswr, st.tx3Vswr, st.tx4Vswr, | ||
| st.rx1Hd2, st.rx2Hd2, st.rx3Hd2, st.rx4Hd2, | ||
| st.deserializer); | ||
| break; | ||
|
|
||
| default: | ||
| ret = -EINVAL; | ||
| } | ||
|
|
@@ -585,6 +649,10 @@ | |
| ADRV9025_INIT_CAL | | ||
| (ADI_ADRV9025_TX_LO_LEAKAGE_INTERNAL << 8)); | ||
|
|
||
| static IIO_DEVICE_ATTR(init_cals_complete_check, 0444, | ||
| adrv9025_phy_show, NULL, | ||
| ADRV9025_INIT_CALS_COMPLETE_CHECK); | ||
|
|
||
| static IIO_DEVICE_ATTR(calibrate_tx_lol_ext_en, 0644, | ||
| adrv9025_phy_show, adrv9025_phy_store, | ||
| ADRV9025_INIT_CAL | | ||
|
|
@@ -594,9 +662,31 @@ | |
| adrv9025_phy_show, adrv9025_phy_store, | ||
| ADRV9025_INIT_CAL | (ADI_ADRV9025_EXTERNAL_PATH_DELAY << 8)); | ||
|
|
||
| static IIO_DEVICE_ATTR(calibrate_orx_qec_en, 0644, | ||
| adrv9025_phy_show, adrv9025_phy_store, | ||
| ADRV9025_INIT_CAL | (ADI_ADRV9025_ORX_QEC_INIT << 8)); | ||
|
|
||
| static IIO_DEVICE_ATTR(calibrate_orx_lo_delay_en, 0644, | ||
| adrv9025_phy_show, adrv9025_phy_store, | ||
| ADRV9025_INIT_CAL | (ADI_ADRV9025_ORX_LO_DELAY << 8)); | ||
|
|
||
| static IIO_DEVICE_ATTR(calibrate_adc_en, 0644, | ||
| adrv9025_phy_show, adrv9025_phy_store, | ||
| ADRV9025_INIT_CAL | (ADI_ADRV9025_ADC_TUNER << 8)); | ||
|
|
||
| static IIO_DEVICE_ATTR(calibrate_orx_adc_en, 0644, | ||
| adrv9025_phy_show, adrv9025_phy_store, | ||
| ADRV9025_INIT_CAL | (ADI_ADRV9025_ORX_TIA << 8)); | ||
|
|
||
| static IIO_DEVICE_ATTR(calibrate_mask, 0644, adrv9025_phy_show, | ||
| adrv9025_phy_store, ADRV9025_CAL_MASK); | ||
|
|
||
| static IIO_DEVICE_ATTR(init_cals_all_status, 0644, adrv9025_phy_show, | ||
| NULL, ADRV9025_INIT_STATUS_ALL); | ||
|
|
||
| static IIO_DEVICE_ATTR(tracking_cals_all_status, 0644, adrv9025_phy_show, | ||
| NULL, ADRV9025_TRACKING_STATUS_ALL); | ||
|
|
||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This looks like wrong permissions. init_cals_all_status and tracking_cals_all_status are declared with mode 0644 but pass NULL for the store function. Probably it should be 0444 |
||
| static IIO_DEVICE_ATTR(dpd_tx_mask, 0644, adrv9025_phy_show, | ||
| adrv9025_phy_store, ADRV9025_DPD_TX_MASK); | ||
|
|
||
|
|
@@ -633,12 +723,19 @@ | |
|
|
||
| static struct attribute *adrv9026_phy_attributes[] = { | ||
| &iio_dev_attr_calibrate.dev_attr.attr, | ||
| &iio_dev_attr_init_cals_complete_check.dev_attr.attr, | ||
| &iio_dev_attr_calibrate_rx_qec_en.dev_attr.attr, | ||
| &iio_dev_attr_calibrate_tx_qec_en.dev_attr.attr, | ||
| &iio_dev_attr_calibrate_tx_lol_en.dev_attr.attr, | ||
| &iio_dev_attr_calibrate_tx_lol_ext_en.dev_attr.attr, | ||
| &iio_dev_attr_calibrate_ext_path_delay_en.dev_attr.attr, | ||
| &iio_dev_attr_calibrate_orx_qec_en.dev_attr.attr, | ||
| &iio_dev_attr_calibrate_orx_lo_delay_en.dev_attr.attr, | ||
| &iio_dev_attr_calibrate_adc_en.dev_attr.attr, | ||
| &iio_dev_attr_calibrate_orx_adc_en.dev_attr.attr, | ||
| &iio_dev_attr_calibrate_mask.dev_attr.attr, | ||
| &iio_dev_attr_init_cals_all_status.dev_attr.attr, | ||
| &iio_dev_attr_tracking_cals_all_status.dev_attr.attr, | ||
| &iio_dev_attr_jesd204_fsm_error.dev_attr.attr, | ||
| &iio_dev_attr_jesd204_fsm_state.dev_attr.attr, | ||
| &iio_dev_attr_jesd204_fsm_paused.dev_attr.attr, | ||
|
|
@@ -649,12 +746,19 @@ | |
|
|
||
| static struct attribute *adrv9029_phy_attributes[] = { | ||
| &iio_dev_attr_calibrate.dev_attr.attr, | ||
| &iio_dev_attr_init_cals_complete_check.dev_attr.attr, | ||
| &iio_dev_attr_calibrate_rx_qec_en.dev_attr.attr, | ||
| &iio_dev_attr_calibrate_tx_qec_en.dev_attr.attr, | ||
| &iio_dev_attr_calibrate_tx_lol_en.dev_attr.attr, | ||
| &iio_dev_attr_calibrate_tx_lol_ext_en.dev_attr.attr, | ||
| &iio_dev_attr_calibrate_ext_path_delay_en.dev_attr.attr, | ||
| &iio_dev_attr_calibrate_orx_qec_en.dev_attr.attr, | ||
| &iio_dev_attr_calibrate_orx_lo_delay_en.dev_attr.attr, | ||
| &iio_dev_attr_calibrate_adc_en.dev_attr.attr, | ||
| &iio_dev_attr_calibrate_orx_adc_en.dev_attr.attr, | ||
| &iio_dev_attr_calibrate_mask.dev_attr.attr, | ||
| &iio_dev_attr_init_cals_all_status.dev_attr.attr, | ||
| &iio_dev_attr_tracking_cals_all_status.dev_attr.attr, | ||
| &iio_dev_attr_dpd_tx_mask.dev_attr.attr, | ||
| &iio_dev_attr_dpd_reset.dev_attr.attr, | ||
| &iio_dev_attr_dpd_tracking_config_set.dev_attr.attr, | ||
|
|
@@ -2442,7 +2546,7 @@ | |
| static long adrv9025_bb_round_rate(struct clk_hw *hw, unsigned long rate, | ||
| unsigned long *prate) | ||
| { | ||
| struct adrv9025_clock *clk_priv = to_clk_priv(hw); | ||
|
Check warning on line 2549 in drivers/iio/adc/adrv902x/adrv9025.c
|
||
|
|
||
| dev_dbg(&clk_priv->spi->dev, "%s: Rate %lu Hz", __func__, rate); | ||
|
|
||
|
|
@@ -2580,7 +2684,7 @@ | |
| static int adrv9025_jesd204_link_pre_setup(struct jesd204_dev *jdev, | ||
| enum jesd204_state_op_reason reason) | ||
| { | ||
| struct device *dev = jesd204_dev_to_device(jdev); | ||
|
Check warning on line 2687 in drivers/iio/adc/adrv902x/adrv9025.c
|
||
| struct adrv9025_jesd204_priv *priv = jesd204_dev_priv(jdev); | ||
| struct adrv9025_rf_phy *phy = priv->phy; | ||
| long dev_clk; | ||
|
|
@@ -2615,7 +2719,7 @@ | |
| enum jesd204_state_op_reason reason, | ||
| struct jesd204_link *lnk) | ||
| { | ||
| struct device *dev = jesd204_dev_to_device(jdev); | ||
|
Check warning on line 2722 in drivers/iio/adc/adrv902x/adrv9025.c
|
||
| struct adrv9025_jesd204_priv *priv = jesd204_dev_priv(jdev); | ||
| struct adrv9025_rf_phy *phy = priv->phy; | ||
| adi_adrv9025_FrmCfg_t *framer = NULL; | ||
|
|
@@ -2725,7 +2829,7 @@ | |
| static int adrv9025_jesd204_link_setup(struct jesd204_dev *jdev, | ||
| enum jesd204_state_op_reason reason) | ||
| { | ||
| struct device *dev = jesd204_dev_to_device(jdev); | ||
|
Check warning on line 2832 in drivers/iio/adc/adrv902x/adrv9025.c
|
||
| struct adrv9025_jesd204_priv *priv = jesd204_dev_priv(jdev); | ||
| struct adrv9025_rf_phy *phy = priv->phy; | ||
| int ret; | ||
|
|
@@ -2783,7 +2887,7 @@ | |
| static int adrv9025_jesd204_setup_stage1(struct jesd204_dev *jdev, | ||
| enum jesd204_state_op_reason reason) | ||
| { | ||
| struct device *dev = jesd204_dev_to_device(jdev); | ||
|
Check warning on line 2890 in drivers/iio/adc/adrv902x/adrv9025.c
|
||
| struct adrv9025_jesd204_priv *priv = jesd204_dev_priv(jdev); | ||
| struct adrv9025_rf_phy *phy = priv->phy; | ||
| int ret, i; | ||
|
|
@@ -2822,7 +2926,7 @@ | |
| static int adrv9025_jesd204_setup_stage2(struct jesd204_dev *jdev, | ||
| enum jesd204_state_op_reason reason) | ||
| { | ||
| struct device *dev = jesd204_dev_to_device(jdev); | ||
|
Check warning on line 2929 in drivers/iio/adc/adrv902x/adrv9025.c
|
||
| struct adrv9025_jesd204_priv *priv = jesd204_dev_priv(jdev); | ||
| struct adrv9025_rf_phy *phy = priv->phy; | ||
| int ret; | ||
|
|
@@ -2856,7 +2960,7 @@ | |
| enum jesd204_state_op_reason reason, | ||
| struct jesd204_link *lnk) | ||
| { | ||
| struct device *dev = jesd204_dev_to_device(jdev); | ||
|
Check warning on line 2963 in drivers/iio/adc/adrv902x/adrv9025.c
|
||
| struct adrv9025_jesd204_priv *priv = jesd204_dev_priv(jdev); | ||
| struct adrv9025_rf_phy *phy = priv->phy; | ||
| int ret; | ||
|
|
@@ -2964,7 +3068,7 @@ | |
| enum jesd204_state_op_reason reason, | ||
| struct jesd204_link *lnk) | ||
| { | ||
| struct device *dev = jesd204_dev_to_device(jdev); | ||
|
Check warning on line 3071 in drivers/iio/adc/adrv902x/adrv9025.c
|
||
| struct adrv9025_jesd204_priv *priv = jesd204_dev_priv(jdev); | ||
| struct adrv9025_rf_phy *phy = priv->phy; | ||
| int ret; | ||
|
|
@@ -3019,7 +3123,7 @@ | |
| enum jesd204_state_op_reason reason, | ||
| struct jesd204_link *lnk) | ||
| { | ||
| struct device *dev = jesd204_dev_to_device(jdev); | ||
|
Check warning on line 3126 in drivers/iio/adc/adrv902x/adrv9025.c
|
||
| struct adrv9025_jesd204_priv *priv = jesd204_dev_priv(jdev); | ||
| struct adrv9025_rf_phy *phy = priv->phy; | ||
| int ret; | ||
|
|
@@ -3094,7 +3198,7 @@ | |
| static int adrv9025_jesd204_post_running_stage(struct jesd204_dev *jdev, | ||
| enum jesd204_state_op_reason reason) | ||
| { | ||
| struct device *dev = jesd204_dev_to_device(jdev); | ||
|
Check warning on line 3201 in drivers/iio/adc/adrv902x/adrv9025.c
|
||
| struct adrv9025_jesd204_priv *priv = jesd204_dev_priv(jdev); | ||
| struct adrv9025_rf_phy *phy = priv->phy; | ||
| int ret; | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Variables declared mid-block violate kernel style. Move all declarations to the top of the switch case