Skip to content

Commit 4a58aac

Browse files
committed
Merge tag 'iio-fixes-for-6.17b' of ssh://gitolite.kernel.org/pub/scm/linux/kernel/git/jic23/iio into char-misc-next
Jonathan writes: IIO: 2nd set of fixes for the 6.17 cycle (or 6.18 merge window) adi,ad5360 - Use a signed int type to be able to hold a potential error return. adi,ad5421 - Use a signed int type to be able to hold a potential error return. adi,adf4350 - Ensure rules on VCO frequency and prescaler values are met. - Fix a wrong offset for the clock divisor control field. xilinx,ams - Unmask alarms correctly if an event is disabled and re-enabled. - Fix a wrong register field mask. * tag 'iio-fixes-for-6.17b' of ssh://gitolite.kernel.org/pub/scm/linux/kernel/git/jic23/iio: iio: dac: ad5421: use int type to store negative error codes iio: dac: ad5360: use int type to store negative error codes iio: frequency: adf4350: Fix ADF4350_REG3_12BIT_CLKDIV_MODE iio: frequency: adf4350: Fix prescaler usage. iio: xilinx-ams: Fix AMS_ALARM_THR_DIRECT_MASK iio: xilinx-ams: Unmask interrupts after updating alarms iio/adc/pac1934: fix channel disable configuration
2 parents ef50926 + 3379c90 commit 4a58aac

File tree

6 files changed

+60
-33
lines changed

6 files changed

+60
-33
lines changed

drivers/iio/adc/pac1934.c

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@
8888
#define PAC1934_VPOWER_3_ADDR 0x19
8989
#define PAC1934_VPOWER_4_ADDR 0x1A
9090
#define PAC1934_REFRESH_V_REG_ADDR 0x1F
91+
#define PAC1934_SLOW_REG_ADDR 0x20
9192
#define PAC1934_CTRL_STAT_REGS_ADDR 0x1C
9293
#define PAC1934_PID_REG_ADDR 0xFD
9394
#define PAC1934_MID_REG_ADDR 0xFE
@@ -1265,8 +1266,23 @@ static int pac1934_chip_configure(struct pac1934_chip_info *info)
12651266
/* no SLOW triggered REFRESH, clear POR */
12661267
regs[PAC1934_SLOW_REG_OFF] = 0;
12671268

1268-
ret = i2c_smbus_write_block_data(client, PAC1934_CTRL_STAT_REGS_ADDR,
1269-
ARRAY_SIZE(regs), (u8 *)regs);
1269+
/*
1270+
* Write the three bytes sequentially, as the device does not support
1271+
* block write.
1272+
*/
1273+
ret = i2c_smbus_write_byte_data(client, PAC1934_CTRL_STAT_REGS_ADDR,
1274+
regs[PAC1934_CHANNEL_DIS_REG_OFF]);
1275+
if (ret)
1276+
return ret;
1277+
1278+
ret = i2c_smbus_write_byte_data(client,
1279+
PAC1934_CTRL_STAT_REGS_ADDR + PAC1934_NEG_PWR_REG_OFF,
1280+
regs[PAC1934_NEG_PWR_REG_OFF]);
1281+
if (ret)
1282+
return ret;
1283+
1284+
ret = i2c_smbus_write_byte_data(client, PAC1934_SLOW_REG_ADDR,
1285+
regs[PAC1934_SLOW_REG_OFF]);
12701286
if (ret)
12711287
return ret;
12721288

drivers/iio/adc/xilinx-ams.c

Lines changed: 26 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@
118118
#define AMS_ALARM_THRESHOLD_OFF_10 0x10
119119
#define AMS_ALARM_THRESHOLD_OFF_20 0x20
120120

121-
#define AMS_ALARM_THR_DIRECT_MASK BIT(1)
121+
#define AMS_ALARM_THR_DIRECT_MASK BIT(0)
122122
#define AMS_ALARM_THR_MIN 0x0000
123123
#define AMS_ALARM_THR_MAX (BIT(16) - 1)
124124

@@ -389,6 +389,29 @@ static void ams_update_pl_alarm(struct ams *ams, unsigned long alarm_mask)
389389
ams_pl_update_reg(ams, AMS_REG_CONFIG3, AMS_REGCFG3_ALARM_MASK, cfg);
390390
}
391391

392+
static void ams_unmask(struct ams *ams)
393+
{
394+
unsigned int status, unmask;
395+
396+
status = readl(ams->base + AMS_ISR_0);
397+
398+
/* Clear those bits which are not active anymore */
399+
unmask = (ams->current_masked_alarm ^ status) & ams->current_masked_alarm;
400+
401+
/* Clear status of disabled alarm */
402+
unmask |= ams->intr_mask;
403+
404+
ams->current_masked_alarm &= status;
405+
406+
/* Also clear those which are masked out anyway */
407+
ams->current_masked_alarm &= ~ams->intr_mask;
408+
409+
/* Clear the interrupts before we unmask them */
410+
writel(unmask, ams->base + AMS_ISR_0);
411+
412+
ams_update_intrmask(ams, ~AMS_ALARM_MASK, ~AMS_ALARM_MASK);
413+
}
414+
392415
static void ams_update_alarm(struct ams *ams, unsigned long alarm_mask)
393416
{
394417
unsigned long flags;
@@ -401,6 +424,7 @@ static void ams_update_alarm(struct ams *ams, unsigned long alarm_mask)
401424

402425
spin_lock_irqsave(&ams->intr_lock, flags);
403426
ams_update_intrmask(ams, AMS_ISR0_ALARM_MASK, ~alarm_mask);
427+
ams_unmask(ams);
404428
spin_unlock_irqrestore(&ams->intr_lock, flags);
405429
}
406430

@@ -1035,28 +1059,9 @@ static void ams_handle_events(struct iio_dev *indio_dev, unsigned long events)
10351059
static void ams_unmask_worker(struct work_struct *work)
10361060
{
10371061
struct ams *ams = container_of(work, struct ams, ams_unmask_work.work);
1038-
unsigned int status, unmask;
10391062

10401063
spin_lock_irq(&ams->intr_lock);
1041-
1042-
status = readl(ams->base + AMS_ISR_0);
1043-
1044-
/* Clear those bits which are not active anymore */
1045-
unmask = (ams->current_masked_alarm ^ status) & ams->current_masked_alarm;
1046-
1047-
/* Clear status of disabled alarm */
1048-
unmask |= ams->intr_mask;
1049-
1050-
ams->current_masked_alarm &= status;
1051-
1052-
/* Also clear those which are masked out anyway */
1053-
ams->current_masked_alarm &= ~ams->intr_mask;
1054-
1055-
/* Clear the interrupts before we unmask them */
1056-
writel(unmask, ams->base + AMS_ISR_0);
1057-
1058-
ams_update_intrmask(ams, ~AMS_ALARM_MASK, ~AMS_ALARM_MASK);
1059-
1064+
ams_unmask(ams);
10601065
spin_unlock_irq(&ams->intr_lock);
10611066

10621067
/* If still pending some alarm re-trigger the timer */

drivers/iio/dac/ad5360.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,7 @@ static int ad5360_update_ctrl(struct iio_dev *indio_dev, unsigned int set,
262262
unsigned int clr)
263263
{
264264
struct ad5360_state *st = iio_priv(indio_dev);
265-
unsigned int ret;
265+
int ret;
266266

267267
mutex_lock(&st->lock);
268268

drivers/iio/dac/ad5421.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ static int ad5421_update_ctrl(struct iio_dev *indio_dev, unsigned int set,
186186
unsigned int clr)
187187
{
188188
struct ad5421_state *st = iio_priv(indio_dev);
189-
unsigned int ret;
189+
int ret;
190190

191191
mutex_lock(&st->lock);
192192

drivers/iio/frequency/adf4350.c

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,19 @@ static int adf4350_set_freq(struct adf4350_state *st, unsigned long long freq)
149149
if (freq > ADF4350_MAX_OUT_FREQ || freq < st->min_out_freq)
150150
return -EINVAL;
151151

152+
st->r4_rf_div_sel = 0;
153+
154+
/*
155+
* !\TODO: The below computation is making sure we get a power of 2
156+
* shift (st->r4_rf_div_sel) so that freq becomes higher or equal to
157+
* ADF4350_MIN_VCO_FREQ. This might be simplified with fls()/fls_long()
158+
* and friends.
159+
*/
160+
while (freq < ADF4350_MIN_VCO_FREQ) {
161+
freq <<= 1;
162+
st->r4_rf_div_sel++;
163+
}
164+
152165
if (freq > ADF4350_MAX_FREQ_45_PRESC) {
153166
prescaler = ADF4350_REG1_PRESCALER;
154167
mdiv = 75;
@@ -157,13 +170,6 @@ static int adf4350_set_freq(struct adf4350_state *st, unsigned long long freq)
157170
mdiv = 23;
158171
}
159172

160-
st->r4_rf_div_sel = 0;
161-
162-
while (freq < ADF4350_MIN_VCO_FREQ) {
163-
freq <<= 1;
164-
st->r4_rf_div_sel++;
165-
}
166-
167173
/*
168174
* Allow a predefined reference division factor
169175
* if not set, compute our own

include/linux/iio/frequency/adf4350.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151

5252
/* REG3 Bit Definitions */
5353
#define ADF4350_REG3_12BIT_CLKDIV(x) ((x) << 3)
54-
#define ADF4350_REG3_12BIT_CLKDIV_MODE(x) ((x) << 16)
54+
#define ADF4350_REG3_12BIT_CLKDIV_MODE(x) ((x) << 15)
5555
#define ADF4350_REG3_12BIT_CSR_EN (1 << 18)
5656
#define ADF4351_REG3_CHARGE_CANCELLATION_EN (1 << 21)
5757
#define ADF4351_REG3_ANTI_BACKLASH_3ns_EN (1 << 22)

0 commit comments

Comments
 (0)