Skip to content

Commit 954a1b9

Browse files
BrentK-ADInunojsa
authored andcommitted
iio: frequency: adf4030: Add 3.3V CMOS support
Adds support to enable the 3.3v logic levels based on device tree configuration through adi,cmos-3v3-enable. Register 0x5C which contains interrupt masks and CMOS_OV field was moved from the default register array to manually configured in adf4030_startup. Signed-off-by: Brent Kowal <brent.kowal@analog.com>
1 parent 93c70a9 commit 954a1b9

File tree

1 file changed

+27
-7
lines changed

1 file changed

+27
-7
lines changed

drivers/iio/frequency/adf4030.c

Lines changed: 27 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,13 @@
8888
/* REG 0x5A */
8989
#define ADF4030_PLL_CAL_EN_MSK BIT(6)
9090

91+
/* REG 0x5C */
92+
#define ADF4030_TEMP_INT_MSK BIT(1)
93+
#define ADF4030_ALIGN_INT_MSK BIT(2)
94+
#define ADF4030_LD_INT_MSK BIT(3)
95+
#define ADF4030_TDC_ERR_INT_MSK BIT(4)
96+
#define ADF4030_CMOS_OV_MSK BIT(7)
97+
9198
/* REG 0x61 */
9299
#define ADF4030_EN_ADC_MSK BIT(0)
93100
#define ADF4030_EN_ADC_CLK_MSK BIT(1)
@@ -202,6 +209,7 @@ struct adf4030_state {
202209
unsigned int num_channels;
203210
bool adc_enabled;
204211
bool spi_3wire_en;
212+
bool cmos_3v3_en;
205213

206214
u8 vals[3] __aligned(IIO_DMA_MINALIGN);
207215
};
@@ -217,13 +225,13 @@ static const struct regmap_config adf4030_regmap_config = {
217225
static const struct reg_sequence adf4030_reg_default[] = {
218226
{0x6A, 0x0A}, {0x69, 0x0A}, {0x66, 0x80}, {0x64, 0x1E}, {0x63, 0x1E},
219227
{0x62, 0x4C}, {0x61, 0x05}, {0x60, 0x2B}, {0x5F, 0x5D}, {0x5E, 0x32},
220-
{0x5D, 0x10}, {0x5C, 0x1E}, {0x5B, 0xC9}, {0x5A, 0x17}, {0x59, 0x49},
221-
{0x58, 0x53}, {0x57, 0x45}, {0x56, 0x7D}, {0x55, 0x01}, {0x54, 0x90},
222-
{0x53, 0x19}, {0x52, 0xE9}, {0x50, 0xE9}, {0x4E, 0xE9}, {0x4C, 0xE9},
223-
{0x4A, 0xE9}, {0x48, 0xE9}, {0x46, 0xE9}, {0x44, 0xE9}, {0x42, 0xE9},
224-
{0x40, 0xE9}, {0x3C, 0xFF}, {0x3B, 0xFC}, {0x37, 0x02}, {0x35, 0x05},
225-
{0x34, 0x24}, {0x33, 0x1D}, {0x32, 0x1D}, {0x31, 0x45}, {0x16, 0x06},
226-
{0x11, 0x1F}, {0x10, 0x1F}
228+
{0x5D, 0x10}, {0x5B, 0xC9}, {0x5A, 0x17}, {0x59, 0x49}, {0x58, 0x53},
229+
{0x57, 0x45}, {0x56, 0x7D}, {0x55, 0x01}, {0x54, 0x90}, {0x53, 0x19},
230+
{0x52, 0xE9}, {0x50, 0xE9}, {0x4E, 0xE9}, {0x4C, 0xE9}, {0x4A, 0xE9},
231+
{0x48, 0xE9}, {0x46, 0xE9}, {0x44, 0xE9}, {0x42, 0xE9}, {0x40, 0xE9},
232+
{0x3C, 0xFF}, {0x3B, 0xFC}, {0x37, 0x02}, {0x35, 0x05}, {0x34, 0x24},
233+
{0x33, 0x1D}, {0x32, 0x1D}, {0x31, 0x45}, {0x16, 0x06}, {0x11, 0x1F},
234+
{0x10, 0x1F}
227235
};
228236

229237
static int adf4030_compute_r_n(u32 ref_freq, u32 vco_freq, u32 *rdiv, u32 *ndiv)
@@ -1139,6 +1147,16 @@ static int adf4030_startup(struct adf4030_state *st, u32 ref_input_freq_hz,
11391147
if (ret)
11401148
return ret;
11411149

1150+
/* Setup the CMOS Level and IRQ Masks */
1151+
ret = regmap_write(st->regmap, ADF4030_REG(0x5C),
1152+
FIELD_PREP(ADF4030_TEMP_INT_MSK, 1) |
1153+
FIELD_PREP(ADF4030_ALIGN_INT_MSK, 1) |
1154+
FIELD_PREP(ADF4030_LD_INT_MSK, 1) |
1155+
FIELD_PREP(ADF4030_TDC_ERR_INT_MSK, 1) |
1156+
FIELD_PREP(ADF4030_CMOS_OV_MSK, st->cmos_3v3_en));
1157+
if (ret)
1158+
return ret;
1159+
11421160
ret = regmap_write(st->regmap, ADF4030_REG(0x01), 0);
11431161
if (ret)
11441162
return ret;
@@ -1276,6 +1294,8 @@ static int adf4030_parse_fw(struct adf4030_state *st)
12761294
st->spi_3wire_en = device_property_read_bool(dev,
12771295
"adi,spi-3wire-enable");
12781296

1297+
st->cmos_3v3_en = device_property_read_bool(dev, "adi,cmos-3v3-enable");
1298+
12791299
ret = device_property_read_u32(dev, "adi,vco-frequency-hz",
12801300
&st->vco_freq);
12811301
if (ret)

0 commit comments

Comments
 (0)