Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

iio: max517: Add support for MAX520 and MAX521 chips.

MAX520 and MAX521 are protocol-compatible with the already supported
chips, just have more channels.

Signed-off-by: Antonio Fiol <antonio@fiol.es>
Signed-off-by: Jonathan Cameron <jic23@kernel.org>

authored by

Antonio Fiol and committed by
Jonathan Cameron
a878a1a6 7253606d

+42 -16
+8 -3
drivers/iio/dac/Kconfig
··· 143 143 ad7303. 144 144 145 145 config MAX517 146 - tristate "Maxim MAX517/518/519 DAC driver" 146 + tristate "Maxim MAX517/518/519/520/521 DAC driver" 147 147 depends on I2C 148 148 help 149 - If you say yes here you get support for the Maxim chips MAX517, 150 - MAX518 and MAX519 (I2C 8-Bit DACs with rail-to-rail outputs). 149 + If you say yes here you get support for the following Maxim chips 150 + (I2C 8-Bit DACs with rail-to-rail outputs): 151 + MAX517 - Single channel, single reference 152 + MAX518 - Dual channel, ref=Vdd 153 + MAX519 - Dual channel, dual reference 154 + MAX520 - Quad channel, quad reference 155 + MAX521 - Octal channel, independent ref for ch0-3, shared ref for ch4-7 151 156 152 157 This driver can also be built as a module. If so, the module 153 158 will be called max517.
+33 -12
drivers/iio/dac/max517.c
··· 39 39 ID_MAX517, 40 40 ID_MAX518, 41 41 ID_MAX519, 42 + ID_MAX520, 43 + ID_MAX521, 42 44 }; 43 45 44 46 struct max517_data { 45 47 struct i2c_client *client; 46 - unsigned short vref_mv[2]; 48 + unsigned short vref_mv[8]; 47 49 }; 48 50 49 51 /* ··· 151 149 152 150 static const struct iio_chan_spec max517_channels[] = { 153 151 MAX517_CHANNEL(0), 154 - MAX517_CHANNEL(1) 152 + MAX517_CHANNEL(1), 153 + MAX517_CHANNEL(2), 154 + MAX517_CHANNEL(3), 155 + MAX517_CHANNEL(4), 156 + MAX517_CHANNEL(5), 157 + MAX517_CHANNEL(6), 158 + MAX517_CHANNEL(7), 155 159 }; 156 160 157 161 static int max517_probe(struct i2c_client *client, ··· 166 158 struct max517_data *data; 167 159 struct iio_dev *indio_dev; 168 160 struct max517_platform_data *platform_data = client->dev.platform_data; 161 + int chan; 169 162 170 163 indio_dev = devm_iio_device_alloc(&client->dev, sizeof(*data)); 171 164 if (!indio_dev) ··· 178 169 /* establish that the iio_dev is a child of the i2c device */ 179 170 indio_dev->dev.parent = &client->dev; 180 171 181 - /* reduced channel set for MAX517 */ 182 - if (id->driver_data == ID_MAX517) 183 - indio_dev->num_channels = 1; 184 - else 172 + switch (id->driver_data) { 173 + case ID_MAX521: 174 + indio_dev->num_channels = 8; 175 + break; 176 + case ID_MAX520: 177 + indio_dev->num_channels = 4; 178 + break; 179 + case ID_MAX519: 180 + case ID_MAX518: 185 181 indio_dev->num_channels = 2; 182 + break; 183 + default: /* single channel for MAX517 */ 184 + indio_dev->num_channels = 1; 185 + break; 186 + } 186 187 indio_dev->channels = max517_channels; 187 188 indio_dev->modes = INDIO_DIRECT_MODE; 188 189 indio_dev->info = &max517_info; ··· 201 182 * Reference voltage on MAX518 and default is 5V, else take vref_mv 202 183 * from platform_data 203 184 */ 204 - if (id->driver_data == ID_MAX518 || !platform_data) { 205 - data->vref_mv[0] = data->vref_mv[1] = 5000; /* mV */ 206 - } else { 207 - data->vref_mv[0] = platform_data->vref_mv[0]; 208 - data->vref_mv[1] = platform_data->vref_mv[1]; 185 + for (chan = 0; chan < indio_dev->num_channels; chan++) { 186 + if (id->driver_data == ID_MAX518 || !platform_data) 187 + data->vref_mv[chan] = 5000; /* mV */ 188 + else 189 + data->vref_mv[chan] = platform_data->vref_mv[chan]; 209 190 } 210 191 211 192 return iio_device_register(indio_dev); ··· 221 202 { "max517", ID_MAX517 }, 222 203 { "max518", ID_MAX518 }, 223 204 { "max519", ID_MAX519 }, 205 + { "max520", ID_MAX520 }, 206 + { "max521", ID_MAX521 }, 224 207 { } 225 208 }; 226 209 MODULE_DEVICE_TABLE(i2c, max517_id); ··· 239 218 module_i2c_driver(max517_driver); 240 219 241 220 MODULE_AUTHOR("Roland Stigge <stigge@antcom.de>"); 242 - MODULE_DESCRIPTION("MAX517/MAX518/MAX519 8-bit DAC"); 221 + MODULE_DESCRIPTION("MAX517/518/519/520/521 8-bit DAC"); 243 222 MODULE_LICENSE("GPL");
+1 -1
include/linux/iio/dac/max517.h
··· 9 9 #define IIO_DAC_MAX517_H_ 10 10 11 11 struct max517_platform_data { 12 - u16 vref_mv[2]; 12 + u16 vref_mv[8]; 13 13 }; 14 14 15 15 #endif /* IIO_DAC_MAX517_H_ */