Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 321751
b: refs/heads/master
c: 8857df3
h: refs/heads/master
i:
  321749: 1ef475c
  321747: cf70d14
  321743: 45fc7ea
v: v3
  • Loading branch information
Michael Hennerich authored and Jonathan Cameron committed Aug 16, 2012
1 parent ca59805 commit 76e69f1
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 10 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: dfffd0d65fdf16d034681716dcbea74776f62e40
refs/heads/master: 8857df3aceb7a8eb7558059b7da109e41dd1fb95
24 changes: 15 additions & 9 deletions trunk/drivers/iio/frequency/adf4350.c
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ static int adf4350_set_freq(struct adf4350_state *st, unsigned long long freq)
{
struct adf4350_platform_data *pdata = st->pdata;
u64 tmp;
u32 div_gcd, prescaler;
u32 div_gcd, prescaler, chspc;
u16 mdiv, r_cnt = 0;
u8 band_sel_div;

Expand Down Expand Up @@ -158,14 +158,20 @@ static int adf4350_set_freq(struct adf4350_state *st, unsigned long long freq)
if (pdata->ref_div_factor)
r_cnt = pdata->ref_div_factor - 1;

do {
r_cnt = adf4350_tune_r_cnt(st, r_cnt);
chspc = st->chspc;

st->r1_mod = st->fpfd / st->chspc;
while (st->r1_mod > ADF4350_MAX_MODULUS) {
r_cnt = adf4350_tune_r_cnt(st, r_cnt);
st->r1_mod = st->fpfd / st->chspc;
}
do {
do {
do {
r_cnt = adf4350_tune_r_cnt(st, r_cnt);
st->r1_mod = st->fpfd / chspc;
if (r_cnt > ADF4350_MAX_R_CNT) {
/* try higher spacing values */
chspc++;
r_cnt = 0;
}
} while ((st->r1_mod > ADF4350_MAX_MODULUS) && r_cnt);
} while (r_cnt == 0);

tmp = freq * (u64)st->r1_mod + (st->fpfd > 1);
do_div(tmp, st->fpfd); /* Div round closest (n + d/2)/d */
Expand Down Expand Up @@ -194,7 +200,7 @@ static int adf4350_set_freq(struct adf4350_state *st, unsigned long long freq)
st->regs[ADF4350_REG0] = ADF4350_REG0_INT(st->r0_int) |
ADF4350_REG0_FRACT(st->r0_fract);

st->regs[ADF4350_REG1] = ADF4350_REG1_PHASE(0) |
st->regs[ADF4350_REG1] = ADF4350_REG1_PHASE(1) |
ADF4350_REG1_MOD(st->r1_mod) |
prescaler;

Expand Down
2 changes: 2 additions & 0 deletions trunk/include/linux/iio/frequency/adf4350.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,8 @@
#define ADF4350_MAX_BANDSEL_CLK 125000 /* Hz */
#define ADF4350_MAX_FREQ_REFIN 250000000 /* Hz */
#define ADF4350_MAX_MODULUS 4095
#define ADF4350_MAX_R_CNT 1023


/**
* struct adf4350_platform_data - platform specific information
Expand Down

0 comments on commit 76e69f1

Please sign in to comment.