37
37
#include "adrv9001_bf.h"
38
38
#include "adi_adrv9001_hal.h"
39
39
#ifdef __KERNEL__
40
- #include <linux/cleanup.h>
41
- #include <linux/mutex.h>
42
40
#include <linux/string.h>
43
-
44
- static DEFINE_MUTEX (dma_wr_lock );
45
41
#endif
46
42
47
43
/* Header files related to libraries */
@@ -107,8 +103,8 @@ const char* const adrv9001_error_table_CmdCtrlMboxCmdError[] =
107
103
"Command error"
108
104
};
109
105
110
- const char * const adrv9001_error_table_CmdError [] =
111
- {
106
+ const char * const adrv9001_error_table_CmdError [] =
107
+ {
112
108
"Error occurred during an Init Calibration. Check that no signal is being applied to the Rx ports. Check that "
113
109
"correct external LOs are applied, and synchronized, where appropriate" ,
114
110
"Error occurred during a Tracking Calibration. Disable tracking calibrations, reset and program. If enabled "
@@ -257,7 +253,7 @@ static __maybe_unused int32_t adrv9001_DmaMemReadByte(adi_adrv9001_Device_t *dev
257
253
}
258
254
259
255
regRead |= ADRV9001_DMA_CTL_LEGACY_MODE ;
260
-
256
+
261
257
/* bus size, 2'b00=byte; 2'b01=half-word; 2'b10=full-word; 2'b11=invalid */
262
258
/* core_bf.bus_size.write(bf_status, 2'b10); */
263
259
regRead |= ADRV9001_BF_ENCODE (0 , ADRV9001_DMA_CTL_BUS_SIZE_MASK , ADRV9001_DMA_CTL_BUS_SIZE_SHIFT );
@@ -329,7 +325,7 @@ static __maybe_unused int32_t adrv9001_DmaMemReadByte(adi_adrv9001_Device_t *dev
329
325
returnData [i + 1 ] = dataRead0 ;
330
326
ADRV9001_SPIREADBYTEDMA (device , "ARM_DMA_DATA_2" , ADRV9001_ADDR_ARM_DMA_DATA2 , & dataRead0 );
331
327
returnData [i + 2 ] = dataRead0 ;
332
-
328
+
333
329
/* 'single_instruction' has to be cleared before reading DMA_DATA3 and set back after */
334
330
ADI_EXPECT (adrv9001_NvsRegmapCore_SingleInstruction_Set , device , 0x0 );
335
331
ADRV9001_SPIREADBYTEDMA (device , "ARM_DMA_DATA_3" , ADRV9001_ADDR_ARM_DMA_DATA3 , & dataRead0 );
@@ -1046,7 +1042,7 @@ static void adrv9001_LoadSsiConfig(adi_adrv9001_Device_t *device, uint32_t *offs
1046
1042
cfgData [tempOffset ++ ] = (uint8_t )ssiConfig -> cmosClkInversionEn ;
1047
1043
1048
1044
cfgData [tempOffset ++ ] = (uint8_t )ssiConfig -> ddrEn ;
1049
-
1045
+
1050
1046
cfgData [tempOffset ++ ] = (uint8_t )ssiConfig -> rxMaskStrobeEn ;
1051
1047
1052
1048
/* 4 bytes of padding is needed for alignment */
@@ -1567,15 +1563,15 @@ typedef struct
1567
1563
duplexMode_e duplexMode;
1568
1564
uint8_t fhModeOn;
1569
1565
uint8_t reserved1[1u]; //< Reserved for future feature
1570
- uint8_t numDynamicProfile; // Number of Profile. =1 means only one profile and no switching
1566
+ uint8_t numDynamicProfile; // Number of Profile. =1 means only one profile and no switching
1571
1567
mcsMode_e mcsMode; // MCS mode selection: 0 - Disable, 1 - MCS Only, 2 - MCS + RFPLL phase sync
1572
- adcType_e adcTypeMonitor; // ADC type used in Monitor Mode
1573
- uint16_t pllLockTime_us; // Required lock time in microseconds for PLLs, based on ref_clk and loop bandwidth
1574
- pllModulus_t pllModuli; // PLL moduli
1575
- uint16_t pllPhaseSyncWait_us; // Worst case phase sync wait time in FH
1576
- mcsInf_e mcsInterfaceType; // 0-Disabled, 1-CMOS, 2-LVDS
1577
- uint8_t warmBootEnable; // Enable WarmBoot - Load initCal cefficients instead of running initCals
1578
- uint32_t reserved[1u]; // Reserved for future feature
1568
+ adcType_e adcTypeMonitor; // ADC type used in Monitor Mode
1569
+ uint16_t pllLockTime_us; // Required lock time in microseconds for PLLs, based on ref_clk and loop bandwidth
1570
+ pllModulus_t pllModuli; // PLL moduli
1571
+ uint16_t pllPhaseSyncWait_us; // Worst case phase sync wait time in FH
1572
+ mcsInf_e mcsInterfaceType; // 0-Disabled, 1-CMOS, 2-LVDS
1573
+ uint8_t warmBootEnable; // Enable WarmBoot - Load initCal cefficients instead of running initCals
1574
+ uint32_t reserved[1u]; // Reserved for future feature
1579
1575
} deviceSysConfig_t;
1580
1576
*/
1581
1577
static void adrv9001_DeviceSysConfigWrite (adi_adrv9001_Device_t * device , const adi_adrv9001_DeviceSysConfig_t * sysConfig , uint8_t cfgData [], uint32_t * offset )
@@ -1613,13 +1609,13 @@ static void adrv9001_DeviceSysConfigWrite(adi_adrv9001_Device_t *device, const a
1613
1609
{
1614
1610
adrv9001_LoadFourBytes (& tempOffset , cfgData , sysConfig -> pllModulus .dmModulus [i ]);
1615
1611
}
1616
-
1612
+
1617
1613
/* PLL phase sync wait time in us */
1618
1614
adrv9001_LoadTwoBytes (& tempOffset , cfgData , sysConfig -> pllPhaseSyncWait_us );
1619
1615
1620
1616
cfgData [tempOffset ++ ] = sysConfig -> mcsInterfaceType ;
1621
1617
cfgData [tempOffset ++ ] = sysConfig -> warmBootEnable ;
1622
-
1618
+
1623
1619
/* 4 bytes padding; Reserved for future use */
1624
1620
tempOffset += 4 ;
1625
1621
@@ -1998,7 +1994,7 @@ int32_t adrv9001_DmaMemWrite(adi_adrv9001_Device_t *device, uint32_t address, co
1998
1994
int32_t recoveryAction = ADI_COMMON_ACT_NO_ACTION ;
1999
1995
uint8_t singleInstruction = 0 ;
2000
1996
uint8_t spiMode = 0 ;
2001
-
1997
+
2002
1998
ADI_ENTRY_PTR_ARRAY_EXPECT (device , data , byteCount );
2003
1999
2004
2000
ADRV9001_DMAINFO ("ARM_MEM_WRITE" , armMemAddress , byteCount );
@@ -2019,7 +2015,7 @@ int32_t adrv9001_DmaMemWrite(adi_adrv9001_Device_t *device, uint32_t address, co
2019
2015
/* If Address is not on word boundary, Or ByteCount is not on Word boundary */
2020
2016
if (((armMemAddress & 0x00000003 ) > 0 ) || ((byteCount & 0x00000003 ) > 0 ))
2021
2017
{
2022
- if ((ADI_ADRV9001_ARM_SINGLE_SPI_WRITE_MODE_STANDARD_BYTES_252 == spiWriteMode ) ||
2018
+ if ((ADI_ADRV9001_ARM_SINGLE_SPI_WRITE_MODE_STANDARD_BYTES_252 == spiWriteMode ) ||
2023
2019
(ADI_ADRV9001_ARM_SINGLE_SPI_WRITE_MODE_STREAMING_BYTES_4 == spiWriteMode ))
2024
2020
{
2025
2021
ADI_ERROR_REPORT (& device -> common ,
@@ -2063,7 +2059,7 @@ int32_t adrv9001_DmaMemWrite(adi_adrv9001_Device_t *device, uint32_t address, co
2063
2059
2064
2060
/* setting up the DMA control register for a write */
2065
2061
ADRV9001_SPIWRITEBYTEDMA (device , "ARM_DMA_CTL" , ADRV9001_ADDR_ARM_DMA_CTL , regWrite );
2066
-
2062
+
2067
2063
/* Enable single instruction and disable SPI streaming mode by default.
2068
2064
* If ADRV9001 SPI streming mode is selected, then single instruction and single instruction are disbled */
2069
2065
ADI_EXPECT (adrv9001_NvsRegmapCore_SingleInstruction_Set , device , 0x1 );
@@ -2198,15 +2194,14 @@ int32_t adrv9001_DmaMemWriteFH(adi_adrv9001_Device_t *device, adi_adrv9001_FhHop
2198
2194
static uint8_t addrLsbArray [ADI_ADRV9001_FREQ_HOPPING_MAX_NUM_BYTES ];
2199
2195
static uint8_t dataArray [ADI_ADRV9001_FREQ_HOPPING_MAX_NUM_BYTES ];
2200
2196
2201
- guard (mutex )(& dma_wr_lock );
2202
2197
memset (addrMsbArray , 0 , sizeof (addrMsbArray ));
2203
2198
memset (addrLsbArray , 0 , sizeof (addrLsbArray ));
2204
2199
memset (dataArray , 0 , sizeof (dataArray ));
2205
2200
#endif
2206
2201
2207
2202
ADI_ENTRY_PTR_ARRAY_EXPECT (device , numHopTableEntries , numHopTableEntriesByteCount );
2208
2203
ADI_ENTRY_PTR_ARRAY_EXPECT (device , hopTableBufferData , hopTableBufferDataByteCount );
2209
-
2204
+
2210
2205
/* Trigger appropriate SPI Interrupt upon table load */
2211
2206
if (hopSignal == ADI_ADRV9001_FH_HOP_SIGNAL_1 )
2212
2207
{
@@ -2222,7 +2217,7 @@ int32_t adrv9001_DmaMemWriteFH(adi_adrv9001_Device_t *device, adi_adrv9001_FhHop
2222
2217
}
2223
2218
2224
2219
ADRV9001_DMAINFO ("ARM_MEM_WRITE" , armMemAddress , byteCount );
2225
-
2220
+
2226
2221
regWrite &= ~ADRV9001_DMA_CTL_RD_WRB ;
2227
2222
regWrite |= ADRV9001_DMA_CTL_SYS_CODEB ;
2228
2223
regWrite |= ADRV9001_BF_ENCODE (2 , ADRV9001_DMA_CTL_BUS_SIZE_MASK , ADRV9001_DMA_CTL_BUS_SIZE_SHIFT );
@@ -2232,7 +2227,7 @@ int32_t adrv9001_DmaMemWriteFH(adi_adrv9001_Device_t *device, adi_adrv9001_FhHop
2232
2227
{
2233
2228
regWrite |= ADRV9001_DMA_CTL_AUTO_INCR ;
2234
2229
}
2235
-
2230
+
2236
2231
/* setting up the DMA control register for a write */
2237
2232
addrMsbArray [addrIndex ] = (uint8_t )(((ADRV9001_SPI_WRITE_POLARITY & 0x01 ) << 7 ) | ((ADRV9001_ADDR_ARM_DMA_CTL >> 8 ) & 0x7F ));
2238
2233
addrLsbArray [addrIndex ] = (uint8_t )ADRV9001_ADDR_ARM_DMA_CTL ;
@@ -2272,7 +2267,7 @@ int32_t adrv9001_DmaMemWriteFH(adi_adrv9001_Device_t *device, adi_adrv9001_FhHop
2272
2267
dataArray [addrIndex ] = numHopTableEntries [dataIndex ];
2273
2268
addrIndex ++ ;
2274
2269
}
2275
-
2270
+
2276
2271
addrMsbArray [addrIndex ] = (uint8_t )(((ADRV9001_SPI_WRITE_POLARITY & 0x01 ) << 7 ) | ((ADRV9001_ADDR_ARM_DMA_ADDR3 >> 8 ) & 0x7F ));
2277
2272
addrLsbArray [addrIndex ] = (uint8_t )ADRV9001_ADDR_ARM_DMA_ADDR3 ;
2278
2273
dataArray [addrIndex ] = (uint8_t )((hopTableBufferAddress ) >> ADRV9001_ADDR_ARM_DMA_ADDR3_BYTE_SHIFT );
@@ -2426,7 +2421,7 @@ int32_t adrv9001_DmaMemRead(adi_adrv9001_Device_t *device, uint32_t address, uin
2426
2421
returnData [i + 2 ] = dataRead ;
2427
2422
ADRV9001_SPIREADBYTEDMA (device , "ARM_DMA_DATA_1" , ADRV9001_ADDR_ARM_DMA_DATA1 , & dataRead );
2428
2423
returnData [i + 1 ] = dataRead ;
2429
-
2424
+
2430
2425
/* 'single_instruction' has to be cleared before reading DMA_DATA3 and set back after */
2431
2426
ADI_EXPECT (adrv9001_NvsRegmapCore_SingleInstruction_Set , device , 0x0 );
2432
2427
ADRV9001_SPIREADBYTEDMA (device , "ARM_DMA_DATA_0" , ADRV9001_ADDR_ARM_DMA_DATA0 , & dataRead );
@@ -2496,7 +2491,7 @@ int32_t adrv9001_FlexStreamProcessorMemWrite(adi_adrv9001_Device_t *device,
2496
2491
/* If Address is not on word boundary, Or ByteCount is not on Word boundary */
2497
2492
if (((flexSpAddress & 0x00000003 ) > 0 ) || ((byteCount & 0x00000003 ) > 0 ))
2498
2493
{
2499
- if ((ADI_ADRV9001_ARM_SINGLE_SPI_WRITE_MODE_STANDARD_BYTES_252 == spiWriteMode ) ||
2494
+ if ((ADI_ADRV9001_ARM_SINGLE_SPI_WRITE_MODE_STANDARD_BYTES_252 == spiWriteMode ) ||
2500
2495
(ADI_ADRV9001_ARM_SINGLE_SPI_WRITE_MODE_STREAMING_BYTES_4 == spiWriteMode ))
2501
2496
{
2502
2497
ADI_ERROR_REPORT (& device -> common ,
@@ -2531,7 +2526,7 @@ int32_t adrv9001_FlexStreamProcessorMemWrite(adi_adrv9001_Device_t *device,
2531
2526
2532
2527
/* setting up the flex SP DMA control register for a write */
2533
2528
ADRV9001_SPIWRITEBYTEDMA (device , "FLEX_SP_ARM_DMA_CTL" , ADRV9001_ADDR_FLEX_SP_ARM_DMA_CTL , regWrite );
2534
-
2529
+
2535
2530
/* Enable single instruction and disable SPI streaming mode by default.
2536
2531
* If ADRV9001 SPI streming mode is selected, then single instruction and single instruction are disbled */
2537
2532
ADI_EXPECT (adrv9001_NvsRegmapCore_SingleInstruction_Set , device , 0x1 );
@@ -2797,7 +2792,7 @@ static const char* adrv9001_CmdErrMsgGet(uint32_t errCode)
2797
2792
{
2798
2793
return adrv9001_error_table_CmdError [6 ];
2799
2794
}
2800
-
2795
+
2801
2796
return NULL ;
2802
2797
}
2803
2798
@@ -2854,7 +2849,7 @@ int32_t adrv9001_ArmCmdErrorHandler(adi_adrv9001_Device_t *device, uint32_t detE
2854
2849
2855
2850
ADI_EXPECT (adrv9001_ArmMailBoxErrCodeGet , device , & mailboxErrCode );
2856
2851
errorString = adrv9001_CmdErrMsgGet (mailboxErrCode );
2857
-
2852
+
2858
2853
ADI_ERROR_REPORT (& device -> common ,
2859
2854
ADI_ADRV9001_SRC_ARMCMD ,
2860
2855
mailboxErrCode ,
@@ -2956,7 +2951,7 @@ static uint32_t adrv9001_ArmProfileWrite_Validate(adi_adrv9001_Device_t *device,
2956
2951
ADI_ERROR_RETURN (device -> common .error .newAction );
2957
2952
}
2958
2953
}
2959
-
2954
+
2960
2955
/* Range check parameters in adi_adrv9001_TxSettings_t */
2961
2956
for (i = 0 ; i < ADI_ADRV9001_MAX_TXCHANNELS ; i ++ )
2962
2957
{
@@ -2972,7 +2967,7 @@ static uint32_t adrv9001_ArmProfileWrite_Validate(adi_adrv9001_Device_t *device,
2972
2967
ADI_RANGE_CHECK (device , init -> tx .txProfile [i ].txSsiConfig .ssiDataFormatSel , ADI_ADRV9001_SSI_FORMAT_2_BIT_SYMBOL_DATA , ADI_ADRV9001_SSI_FORMAT_22_BIT_I_Q_DATA_1_BIT_GAIN_CHANGE_8_BIT_GAIN_INDEX );
2973
2968
ADI_RANGE_CHECK (device , init -> tx .txProfile [i ].txSsiConfig .numLaneSel , ADI_ADRV9001_SSI_1_LANE , ADI_ADRV9001_SSI_4_LANE );
2974
2969
ADI_RANGE_CHECK (device , init -> tx .txProfile [i ].txSsiConfig .strobeType , ADI_ADRV9001_SSI_SHORT_STROBE , ADI_ADRV9001_SSI_LONG_STROBE );
2975
-
2970
+
2976
2971
if ((ADI_ADRV9001_SSI_TYPE_LVDS == init -> tx .txProfile [i ].txSsiConfig .ssiType ) &&
2977
2972
(false == init -> tx .txProfile [i ].txSsiConfig .ddrEn ) &&
2978
2973
(init -> tx .txProfile [i ].txInterfaceSampleRate_Hz > 30720000 ))
@@ -3149,7 +3144,7 @@ int32_t adrv9001_ArmProfileWrite(adi_adrv9001_Device_t *device, const adi_adrv90
3149
3144
cfgData [offset ++ ] = (uint8_t )(init -> clocks .armPowerSavingClkDiv - 1 );
3150
3145
3151
3146
cfgData [offset ++ ] = (uint8_t )init -> clocks .refClockOutEnable ;
3152
-
3147
+
3153
3148
cfgData [offset ++ ] = (uint8_t )init -> clocks .auxPllPower ;
3154
3149
cfgData [offset ++ ] = (uint8_t )init -> clocks .clkPllPower ;
3155
3150
@@ -3208,14 +3203,14 @@ int32_t adrv9001_ArmProfileWrite(adi_adrv9001_Device_t *device, const adi_adrv90
3208
3203
if (ADRV9001_BF_EQUAL (device -> devStateInfo .profilesValid , ADI_ADRV9001_TX_PROFILE_VALID ))
3209
3204
{
3210
3205
armChannels |= (init -> tx .txInitChannelMask & (ADI_ADRV9001_TX1 | ADI_ADRV9001_TX2 ));
3211
-
3206
+
3212
3207
/* Tx channels must have a valid and enabled ILB channel unless the signaling is Direct FM/FSK */
3213
3208
if (ADRV9001_BF_EQUAL (init -> tx .txInitChannelMask , ADI_ADRV9001_TX1 ) &&
3214
3209
(init -> tx .txProfile [0 ].outputSignaling != ADI_ADRV9001_TX_DIRECT_FM_FSK ))
3215
3210
{
3216
3211
armChannels |= (init -> rx .rxInitChannelMask & ADI_ADRV9001_ILB1 );
3217
3212
}
3218
-
3213
+
3219
3214
if (ADRV9001_BF_EQUAL (init -> tx .txInitChannelMask , ADI_ADRV9001_TX2 ) &&
3220
3215
(init -> tx .txProfile [1 ].outputSignaling != ADI_ADRV9001_TX_DIRECT_FM_FSK ))
3221
3216
{
@@ -3504,7 +3499,7 @@ int32_t adrv9001_DynamicProfile_Write(adi_adrv9001_Device_t *device,
3504
3499
int32_t recoveryAction = ADI_COMMON_ACT_NO_ACTION ;
3505
3500
uint32_t offset = 0 ;
3506
3501
uint8_t cfgData [ADRV9001_DYNAMIC_PROFILE_BLOB_SIZE ] = { 0 };
3507
-
3502
+
3508
3503
cfgData [offset ++ ] = dynamicProfile -> dynamicProfileIndex ;
3509
3504
cfgData [offset ++ ] = 0 ; // padding
3510
3505
cfgData [offset ++ ] = 0 ; // padding
0 commit comments