mirror of
https://github.com/torvalds/linux.git
synced 2026-03-08 05:44:45 +01:00
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. -----BEGIN PGP SIGNATURE----- iQJFBAABCgAvFiEEbilms4eEBlKRJoGxVIU0mcT0FogFAmjJGHERHGppYzIzQGtl cm5lbC5vcmcACgkQVIU0mcT0FohYZRAAihwyDUJy9t5DkfxBsfVj6y+PvgSOy6g6 74ipeo6Bg7JNuvG+S7gTbc0qa3FwQXh8NVR2DBZRsQAB8EfWLS7VchbiRHiIg0Ia HYoAnMLwYTZ181ig21Avgo3K6hBEEUCmilhpM3ZGiZdrto1GTQvFYZ73yVPxmdiB Y+g7W2bjYdHawZCJCnluRrJqyV+cxaXyoNS7Pgqz/vAww9oFNOB2Xc+Dt8lqqP8p k0VFs1NIC7+58nWuwNbfAFfXJxpVcqtgWWLJKC860/DGwjE41zxnJSipfH0r7+kX IJ5k7CsyYaaTFYdXhpNf3EIjZ2j0eg5I7A/Rq0eQYLswxY9oZWAx6ds6Tz+0iqQb i5oRn1xKPrY1K/g6sMFL9fs20US9EKn3RVYHy535ZjNJO9A1vwMhoOR/e5oZbZkC WA8jInyw8nAyVvKStidB7k1CTLydrBbEzuueYD6vgF/JcqDQTC4uX14qTeMrF9lB CMFuUgPmer9wTT9s7en5vqwR+nORSEy3aew6aAVRiiwaAwvdDQuR1j+mJANGjlpz bM3JOkBfvElo50OhtR80PO23v9lE+jn+u+2vRzuvz7eWTpBJkhThUniunDWTDZsF QRkAHBIo4jibBGYqEsFxUhJOK3H0nxj7wkmhmoDMjzKCSQd8nTTUarEaiRDED1cd jnYME2cq3Mc= =YwFX -----END PGP SIGNATURE----- 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
This commit is contained in:
commit
4a58aac59f
6 changed files with 60 additions and 33 deletions
|
|
@ -88,6 +88,7 @@
|
|||
#define PAC1934_VPOWER_3_ADDR 0x19
|
||||
#define PAC1934_VPOWER_4_ADDR 0x1A
|
||||
#define PAC1934_REFRESH_V_REG_ADDR 0x1F
|
||||
#define PAC1934_SLOW_REG_ADDR 0x20
|
||||
#define PAC1934_CTRL_STAT_REGS_ADDR 0x1C
|
||||
#define PAC1934_PID_REG_ADDR 0xFD
|
||||
#define PAC1934_MID_REG_ADDR 0xFE
|
||||
|
|
@ -1265,8 +1266,23 @@ static int pac1934_chip_configure(struct pac1934_chip_info *info)
|
|||
/* no SLOW triggered REFRESH, clear POR */
|
||||
regs[PAC1934_SLOW_REG_OFF] = 0;
|
||||
|
||||
ret = i2c_smbus_write_block_data(client, PAC1934_CTRL_STAT_REGS_ADDR,
|
||||
ARRAY_SIZE(regs), (u8 *)regs);
|
||||
/*
|
||||
* Write the three bytes sequentially, as the device does not support
|
||||
* block write.
|
||||
*/
|
||||
ret = i2c_smbus_write_byte_data(client, PAC1934_CTRL_STAT_REGS_ADDR,
|
||||
regs[PAC1934_CHANNEL_DIS_REG_OFF]);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
ret = i2c_smbus_write_byte_data(client,
|
||||
PAC1934_CTRL_STAT_REGS_ADDR + PAC1934_NEG_PWR_REG_OFF,
|
||||
regs[PAC1934_NEG_PWR_REG_OFF]);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
ret = i2c_smbus_write_byte_data(client, PAC1934_SLOW_REG_ADDR,
|
||||
regs[PAC1934_SLOW_REG_OFF]);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
|
|
|
|||
|
|
@ -118,7 +118,7 @@
|
|||
#define AMS_ALARM_THRESHOLD_OFF_10 0x10
|
||||
#define AMS_ALARM_THRESHOLD_OFF_20 0x20
|
||||
|
||||
#define AMS_ALARM_THR_DIRECT_MASK BIT(1)
|
||||
#define AMS_ALARM_THR_DIRECT_MASK BIT(0)
|
||||
#define AMS_ALARM_THR_MIN 0x0000
|
||||
#define AMS_ALARM_THR_MAX (BIT(16) - 1)
|
||||
|
||||
|
|
@ -389,6 +389,29 @@ static void ams_update_pl_alarm(struct ams *ams, unsigned long alarm_mask)
|
|||
ams_pl_update_reg(ams, AMS_REG_CONFIG3, AMS_REGCFG3_ALARM_MASK, cfg);
|
||||
}
|
||||
|
||||
static void ams_unmask(struct ams *ams)
|
||||
{
|
||||
unsigned int status, unmask;
|
||||
|
||||
status = readl(ams->base + AMS_ISR_0);
|
||||
|
||||
/* Clear those bits which are not active anymore */
|
||||
unmask = (ams->current_masked_alarm ^ status) & ams->current_masked_alarm;
|
||||
|
||||
/* Clear status of disabled alarm */
|
||||
unmask |= ams->intr_mask;
|
||||
|
||||
ams->current_masked_alarm &= status;
|
||||
|
||||
/* Also clear those which are masked out anyway */
|
||||
ams->current_masked_alarm &= ~ams->intr_mask;
|
||||
|
||||
/* Clear the interrupts before we unmask them */
|
||||
writel(unmask, ams->base + AMS_ISR_0);
|
||||
|
||||
ams_update_intrmask(ams, ~AMS_ALARM_MASK, ~AMS_ALARM_MASK);
|
||||
}
|
||||
|
||||
static void ams_update_alarm(struct ams *ams, unsigned long alarm_mask)
|
||||
{
|
||||
unsigned long flags;
|
||||
|
|
@ -401,6 +424,7 @@ static void ams_update_alarm(struct ams *ams, unsigned long alarm_mask)
|
|||
|
||||
spin_lock_irqsave(&ams->intr_lock, flags);
|
||||
ams_update_intrmask(ams, AMS_ISR0_ALARM_MASK, ~alarm_mask);
|
||||
ams_unmask(ams);
|
||||
spin_unlock_irqrestore(&ams->intr_lock, flags);
|
||||
}
|
||||
|
||||
|
|
@ -1035,28 +1059,9 @@ static void ams_handle_events(struct iio_dev *indio_dev, unsigned long events)
|
|||
static void ams_unmask_worker(struct work_struct *work)
|
||||
{
|
||||
struct ams *ams = container_of(work, struct ams, ams_unmask_work.work);
|
||||
unsigned int status, unmask;
|
||||
|
||||
spin_lock_irq(&ams->intr_lock);
|
||||
|
||||
status = readl(ams->base + AMS_ISR_0);
|
||||
|
||||
/* Clear those bits which are not active anymore */
|
||||
unmask = (ams->current_masked_alarm ^ status) & ams->current_masked_alarm;
|
||||
|
||||
/* Clear status of disabled alarm */
|
||||
unmask |= ams->intr_mask;
|
||||
|
||||
ams->current_masked_alarm &= status;
|
||||
|
||||
/* Also clear those which are masked out anyway */
|
||||
ams->current_masked_alarm &= ~ams->intr_mask;
|
||||
|
||||
/* Clear the interrupts before we unmask them */
|
||||
writel(unmask, ams->base + AMS_ISR_0);
|
||||
|
||||
ams_update_intrmask(ams, ~AMS_ALARM_MASK, ~AMS_ALARM_MASK);
|
||||
|
||||
ams_unmask(ams);
|
||||
spin_unlock_irq(&ams->intr_lock);
|
||||
|
||||
/* If still pending some alarm re-trigger the timer */
|
||||
|
|
|
|||
|
|
@ -262,7 +262,7 @@ static int ad5360_update_ctrl(struct iio_dev *indio_dev, unsigned int set,
|
|||
unsigned int clr)
|
||||
{
|
||||
struct ad5360_state *st = iio_priv(indio_dev);
|
||||
unsigned int ret;
|
||||
int ret;
|
||||
|
||||
mutex_lock(&st->lock);
|
||||
|
||||
|
|
|
|||
|
|
@ -186,7 +186,7 @@ static int ad5421_update_ctrl(struct iio_dev *indio_dev, unsigned int set,
|
|||
unsigned int clr)
|
||||
{
|
||||
struct ad5421_state *st = iio_priv(indio_dev);
|
||||
unsigned int ret;
|
||||
int ret;
|
||||
|
||||
mutex_lock(&st->lock);
|
||||
|
||||
|
|
|
|||
|
|
@ -149,6 +149,19 @@ static int adf4350_set_freq(struct adf4350_state *st, unsigned long long freq)
|
|||
if (freq > ADF4350_MAX_OUT_FREQ || freq < st->min_out_freq)
|
||||
return -EINVAL;
|
||||
|
||||
st->r4_rf_div_sel = 0;
|
||||
|
||||
/*
|
||||
* !\TODO: The below computation is making sure we get a power of 2
|
||||
* shift (st->r4_rf_div_sel) so that freq becomes higher or equal to
|
||||
* ADF4350_MIN_VCO_FREQ. This might be simplified with fls()/fls_long()
|
||||
* and friends.
|
||||
*/
|
||||
while (freq < ADF4350_MIN_VCO_FREQ) {
|
||||
freq <<= 1;
|
||||
st->r4_rf_div_sel++;
|
||||
}
|
||||
|
||||
if (freq > ADF4350_MAX_FREQ_45_PRESC) {
|
||||
prescaler = ADF4350_REG1_PRESCALER;
|
||||
mdiv = 75;
|
||||
|
|
@ -157,13 +170,6 @@ static int adf4350_set_freq(struct adf4350_state *st, unsigned long long freq)
|
|||
mdiv = 23;
|
||||
}
|
||||
|
||||
st->r4_rf_div_sel = 0;
|
||||
|
||||
while (freq < ADF4350_MIN_VCO_FREQ) {
|
||||
freq <<= 1;
|
||||
st->r4_rf_div_sel++;
|
||||
}
|
||||
|
||||
/*
|
||||
* Allow a predefined reference division factor
|
||||
* if not set, compute our own
|
||||
|
|
|
|||
|
|
@ -51,7 +51,7 @@
|
|||
|
||||
/* REG3 Bit Definitions */
|
||||
#define ADF4350_REG3_12BIT_CLKDIV(x) ((x) << 3)
|
||||
#define ADF4350_REG3_12BIT_CLKDIV_MODE(x) ((x) << 16)
|
||||
#define ADF4350_REG3_12BIT_CLKDIV_MODE(x) ((x) << 15)
|
||||
#define ADF4350_REG3_12BIT_CSR_EN (1 << 18)
|
||||
#define ADF4351_REG3_CHARGE_CANCELLATION_EN (1 << 21)
|
||||
#define ADF4351_REG3_ANTI_BACKLASH_3ns_EN (1 << 22)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue