Skip to content

Commit

Permalink
ad525x_dpot: add support for ADN2860 and AD528x pots
Browse files Browse the repository at this point in the history
New parts supported:
	AD5280, AD5282, ADN2860

Signed-off-by: Michael Hennerich <[email protected]>
Signed-off-by: Mike Frysinger <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
mhennerich authored and torvalds committed May 25, 2010
1 parent e3ae684 commit c74cba6
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 14 deletions.
3 changes: 2 additions & 1 deletion drivers/misc/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ config AD525X_DPOT
AD5204, AD5206, AD5207, AD5231, AD5232, AD5233, AD5235,
AD5260, AD5262, AD5263, AD5290, AD5291, AD5292, AD5293,
AD7376, AD8400, AD8402, AD8403, ADN2850, AD5241, AD5242,
AD5243, AD5245, AD5246, AD5247, AD5248
AD5243, AD5245, AD5246, AD5247, AD5248, AD5280, AD5282,
ADN2860
digital potentiometer chips.

See Documentation/misc-devices/ad525x_dpot.txt for the
Expand Down
3 changes: 3 additions & 0 deletions drivers/misc/ad525x_dpot-i2c.c
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,9 @@ static const struct i2c_device_id ad_dpot_id[] = {
{"ad5246", AD5246_ID},
{"ad5247", AD5247_ID},
{"ad5248", AD5248_ID},
{"ad5280", AD5280_ID},
{"ad5282", AD5282_ID},
{"adn2860", ADN2860_ID},
{}
};
MODULE_DEVICE_TABLE(i2c, ad_dpot_id);
Expand Down
28 changes: 17 additions & 11 deletions drivers/misc/ad525x_dpot.c
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@
* AD5243 2 256 2.5, 10, 50, 100
* AD5248 2 256 2.5, 10, 50, 100
* AD5242 2 256 20, 50, 200
* AD5280 1 256 20, 50, 200
* AD5282 2 256 20, 50, 200
* ADN2860 3 512 25, 250
*
* See Documentation/misc-devices/ad525x_dpot.txt for more info.
*
Expand Down Expand Up @@ -154,6 +157,8 @@ static s32 dpot_read_i2c(struct dpot_data *dpot, u8 reg)
case DPOT_UID(AD5242_ID):
case DPOT_UID(AD5243_ID):
case DPOT_UID(AD5248_ID):
case DPOT_UID(AD5280_ID):
case DPOT_UID(AD5282_ID):
ctrl = ((reg & DPOT_RDAC_MASK) == DPOT_RDAC0) ?
0 : DPOT_AD5291_RDAC_AB;
return dpot_read_r8d8(dpot, ctrl);
Expand Down Expand Up @@ -250,21 +255,22 @@ static s32 dpot_write_i2c(struct dpot_data *dpot, u8 reg, u16 value)
case DPOT_UID(AD5242_ID):
case DPOT_UID(AD5243_ID):
case DPOT_UID(AD5248_ID):
ctrl = ((reg & DPOT_RDAC_MASK) == DPOT_RDAC0) ? 0 : DPOT_AD5291_RDAC_AB;
case DPOT_UID(AD5280_ID):
case DPOT_UID(AD5282_ID):
ctrl = ((reg & DPOT_RDAC_MASK) == DPOT_RDAC0) ?
0 : DPOT_AD5291_RDAC_AB;
return dpot_write_r8d8(dpot, ctrl, value);
break;


default:
if (reg & DPOT_ADDR_CMD)
return dpot_write_d8(dpot, reg);
if (reg & DPOT_ADDR_CMD)
return dpot_write_d8(dpot, reg);

if (dpot->max_pos > 256)
return dpot_write_r8d16(dpot, (reg & 0xF8) |
((reg & 0x7) << 1), value);
else
/* All other registers require instruction + data bytes */
return dpot_write_r8d8(dpot, reg, value);
if (dpot->max_pos > 256)
return dpot_write_r8d16(dpot, (reg & 0xF8) |
((reg & 0x7) << 1), value);
else
/* All other registers require instruction + data bytes */
return dpot_write_r8d8(dpot, reg, value);
}
}

Expand Down
6 changes: 4 additions & 2 deletions drivers/misc/ad525x_dpot.h
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,10 @@ enum dpot_devid {
AD5246_ID = DPOT_CONF(F_RDACS_RW, BRDAC0, 7, 37),
AD5247_ID = DPOT_CONF(F_RDACS_RW, BRDAC0, 7, 38),
AD5248_ID = DPOT_CONF(F_RDACS_RW, BRDAC0 | BRDAC1, 8, 39),


AD5280_ID = DPOT_CONF(F_RDACS_RW, BRDAC0, 8, 40),
AD5282_ID = DPOT_CONF(F_RDACS_RW, BRDAC0 | BRDAC1, 8, 41),
ADN2860_ID = DPOT_CONF(F_RDACS_RW_TOL | F_CMD_INC,
BRDAC0 | BRDAC1 | BRDAC2, 9, 42),
};

#define DPOT_RDAC0 0
Expand Down

0 comments on commit c74cba6

Please sign in to comment.