* Re: [PATCH] iio: max517: Add support for MAX520 and MAX521 chips.
[not found] <1427530034-22848-1-git-send-email-antonio@fiol.es>
@ 2015-03-28 10:57 ` Jonathan Cameron
0 siblings, 0 replies; 3+ messages in thread
From: Jonathan Cameron @ 2015-03-28 10:57 UTC (permalink / raw)
To: Antonio Fiol, linux-iio@vger.kernel.org
On 28/03/15 08:07, Antonio Fiol wrote:
> MAX520 and MAX521 are protocol-compatible with the already supported
> chips, just have more channels.
>
> Signed-off-by: Antonio Fiol <antonio@fiol.es>
Applied to the togreg branch of iio.git - initially pushed out as testing
for the autobuilders to play with it. Thanks.
> ---
> drivers/iio/dac/Kconfig | 11 ++++++++---
> drivers/iio/dac/max517.c | 45 +++++++++++++++++++++++++++++++-----------
> include/linux/iio/dac/max517.h | 2 +-
> 3 files changed, 42 insertions(+), 16 deletions(-)
>
> diff --git a/drivers/iio/dac/Kconfig b/drivers/iio/dac/Kconfig
> index 2236ea2..13471a7 100644
> --- a/drivers/iio/dac/Kconfig
> +++ b/drivers/iio/dac/Kconfig
> @@ -143,11 +143,16 @@ config AD7303
> ad7303.
>
> config MAX517
> - tristate "Maxim MAX517/518/519 DAC driver"
> + tristate "Maxim MAX517/518/519/520/521 DAC driver"
> depends on I2C
> help
> - If you say yes here you get support for the Maxim chips MAX517,
> - MAX518 and MAX519 (I2C 8-Bit DACs with rail-to-rail outputs).
> + If you say yes here you get support for the following Maxim chips
> + (I2C 8-Bit DACs with rail-to-rail outputs):
> + MAX517 - Single channel, single reference
> + MAX518 - Dual channel, ref=Vdd
> + MAX519 - Dual channel, dual reference
> + MAX520 - Quad channel, quad reference
> + MAX521 - Octal channel, independent ref for ch0-3, shared ref for ch4-7
>
> This driver can also be built as a module. If so, the module
> will be called max517.
> diff --git a/drivers/iio/dac/max517.c b/drivers/iio/dac/max517.c
> index 9a82a72..5507b39 100644
> --- a/drivers/iio/dac/max517.c
> +++ b/drivers/iio/dac/max517.c
> @@ -39,11 +39,13 @@ enum max517_device_ids {
> ID_MAX517,
> ID_MAX518,
> ID_MAX519,
> + ID_MAX520,
> + ID_MAX521,
> };
>
> struct max517_data {
> struct i2c_client *client;
> - unsigned short vref_mv[2];
> + unsigned short vref_mv[8];
> };
>
> /*
> @@ -149,7 +151,13 @@ static const struct iio_info max517_info = {
>
> static const struct iio_chan_spec max517_channels[] = {
> MAX517_CHANNEL(0),
> - MAX517_CHANNEL(1)
> + MAX517_CHANNEL(1),
> + MAX517_CHANNEL(2),
> + MAX517_CHANNEL(3),
> + MAX517_CHANNEL(4),
> + MAX517_CHANNEL(5),
> + MAX517_CHANNEL(6),
> + MAX517_CHANNEL(7),
> };
>
> static int max517_probe(struct i2c_client *client,
> @@ -158,6 +166,7 @@ static int max517_probe(struct i2c_client *client,
> struct max517_data *data;
> struct iio_dev *indio_dev;
> struct max517_platform_data *platform_data = client->dev.platform_data;
> + int chan;
>
> indio_dev = devm_iio_device_alloc(&client->dev, sizeof(*data));
> if (!indio_dev)
> @@ -169,11 +178,21 @@ static int max517_probe(struct i2c_client *client,
> /* establish that the iio_dev is a child of the i2c device */
> indio_dev->dev.parent = &client->dev;
>
> - /* reduced channel set for MAX517 */
> - if (id->driver_data == ID_MAX517)
> - indio_dev->num_channels = 1;
> - else
> + switch (id->driver_data) {
> + case ID_MAX521:
> + indio_dev->num_channels = 8;
> + break;
> + case ID_MAX520:
> + indio_dev->num_channels = 4;
> + break;
> + case ID_MAX519:
> + case ID_MAX518:
> indio_dev->num_channels = 2;
> + break;
> + default: /* single channel for MAX517 */
> + indio_dev->num_channels = 1;
> + break;
> + }
> indio_dev->channels = max517_channels;
> indio_dev->modes = INDIO_DIRECT_MODE;
> indio_dev->info = &max517_info;
> @@ -182,11 +201,11 @@ static int max517_probe(struct i2c_client *client,
> * Reference voltage on MAX518 and default is 5V, else take vref_mv
> * from platform_data
> */
> - if (id->driver_data == ID_MAX518 || !platform_data) {
> - data->vref_mv[0] = data->vref_mv[1] = 5000; /* mV */
> - } else {
> - data->vref_mv[0] = platform_data->vref_mv[0];
> - data->vref_mv[1] = platform_data->vref_mv[1];
> + for (chan = 0; chan < indio_dev->num_channels; chan++) {
> + if (id->driver_data == ID_MAX518 || !platform_data)
> + data->vref_mv[chan] = 5000; /* mV */
> + else
> + data->vref_mv[chan] = platform_data->vref_mv[chan];
> }
>
> return iio_device_register(indio_dev);
> @@ -202,6 +221,8 @@ static const struct i2c_device_id max517_id[] = {
> { "max517", ID_MAX517 },
> { "max518", ID_MAX518 },
> { "max519", ID_MAX519 },
> + { "max520", ID_MAX520 },
> + { "max521", ID_MAX521 },
> { }
> };
> MODULE_DEVICE_TABLE(i2c, max517_id);
> @@ -218,5 +239,5 @@ static struct i2c_driver max517_driver = {
> module_i2c_driver(max517_driver);
>
> MODULE_AUTHOR("Roland Stigge <stigge@antcom.de>");
> -MODULE_DESCRIPTION("MAX517/MAX518/MAX519 8-bit DAC");
> +MODULE_DESCRIPTION("MAX517/518/519/520/521 8-bit DAC");
> MODULE_LICENSE("GPL");
> diff --git a/include/linux/iio/dac/max517.h b/include/linux/iio/dac/max517.h
> index f6d1d25..7668716 100644
> --- a/include/linux/iio/dac/max517.h
> +++ b/include/linux/iio/dac/max517.h
> @@ -9,7 +9,7 @@
> #define IIO_DAC_MAX517_H_
>
> struct max517_platform_data {
> - u16 vref_mv[2];
> + u16 vref_mv[8];
> };
>
> #endif /* IIO_DAC_MAX517_H_ */
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH] iio: max517: Add support for MAX520 and MAX521 chips.
@ 2015-02-19 15:22 Antonio Fiol Bonnín
2015-02-19 19:00 ` Peter Meerwald
0 siblings, 1 reply; 3+ messages in thread
From: Antonio Fiol Bonnín @ 2015-02-19 15:22 UTC (permalink / raw)
To: linux-iio
MAX520 and MAX521 are protocol-compatible with the already supported
chips, just have more channels.
Signed-off-by: Antonio Fiol <antonio@fiol.es>
---
drivers/iio/dac/Kconfig | 11 ++++++++---
drivers/iio/dac/max517.c | 45 +++++++++++++++++++++++++++++++-------=
----
include/linux/iio/dac/max517.h | 2 +-
3 files changed, 42 insertions(+), 16 deletions(-)
diff --git a/drivers/iio/dac/Kconfig b/drivers/iio/dac/Kconfig
index 2236ea2..2374cce 100644
--- a/drivers/iio/dac/Kconfig
+++ b/drivers/iio/dac/Kconfig
@@ -143,11 +143,16 @@ config AD7303
ad7303.
config MAX517
- tristate "Maxim MAX517/518/519 DAC driver"
+ tristate "Maxim MAX517/518/519/520/521 DAC driver"
depends on I2C
help
- If you say yes here you get support for the Maxim chips MAX517,
- MAX518 and MAX519 (I2C 8-Bit DACs with rail-to-rail outputs).
+ If you say yes here you get support for the following Maxim chips
+ (I2C 8-Bit DACs with rail-to-rail outputs):
+ MAX517 - Single channel, single reference
+ MAX518 - dual channel, ref=3DVdd
+ MAX519 - dual channel, dual reference
+ MAX520 - quad channel, quad reference
+ MAX521 - octal channel, independent ref for ch0-3, shared ref for ch=
4-7
This driver can also be built as a module. If so, the module
will be called max517.
diff --git a/drivers/iio/dac/max517.c b/drivers/iio/dac/max517.c
index 9a82a72..993977d 100644
--- a/drivers/iio/dac/max517.c
+++ b/drivers/iio/dac/max517.c
@@ -39,11 +39,13 @@ enum max517_device_ids {
ID_MAX517,
ID_MAX518,
ID_MAX519,
+ ID_MAX520,
+ ID_MAX521,
};
struct max517_data {
struct i2c_client *client;
- unsigned short vref_mv[2];
+ unsigned short vref_mv[8];
};
/*
@@ -149,7 +151,13 @@ static const struct iio_info max517_info =3D {
static const struct iio_chan_spec max517_channels[] =3D {
MAX517_CHANNEL(0),
- MAX517_CHANNEL(1)
+ MAX517_CHANNEL(1),
+ MAX517_CHANNEL(2),
+ MAX517_CHANNEL(3),
+ MAX517_CHANNEL(4),
+ MAX517_CHANNEL(5),
+ MAX517_CHANNEL(6),
+ MAX517_CHANNEL(7)
};
static int max517_probe(struct i2c_client *client,
@@ -158,6 +166,7 @@ static int max517_probe(struct i2c_client *client,
struct max517_data *data;
struct iio_dev *indio_dev;
struct max517_platform_data *platform_data =3D client->dev.platform_da=
ta;
+ int chan;
indio_dev =3D devm_iio_device_alloc(&client->dev, sizeof(*data));
if (!indio_dev)
@@ -169,11 +178,21 @@ static int max517_probe(struct i2c_client *client,
/* establish that the iio_dev is a child of the i2c device */
indio_dev->dev.parent =3D &client->dev;
- /* reduced channel set for MAX517 */
- if (id->driver_data =3D=3D ID_MAX517)
- indio_dev->num_channels =3D 1;
- else
+ switch (id->driver_data) {
+ case ID_MAX521:
+ indio_dev->num_channels =3D 8;
+ break;
+ case ID_MAX520:
+ indio_dev->num_channels =3D 4;
+ break;
+ case ID_MAX519:
+ case ID_MAX518:
indio_dev->num_channels =3D 2;
+ break;
+ default: /* single channel for MAX517 */
+ indio_dev->num_channels =3D 1;
+ break;
+ }
indio_dev->channels =3D max517_channels;
indio_dev->modes =3D INDIO_DIRECT_MODE;
indio_dev->info =3D &max517_info;
@@ -182,11 +201,11 @@ static int max517_probe(struct i2c_client *client,
* Reference voltage on MAX518 and default is 5V, else take vref_mv
* from platform_data
*/
- if (id->driver_data =3D=3D ID_MAX518 || !platform_data) {
- data->vref_mv[0] =3D data->vref_mv[1] =3D 5000; /* mV */
- } else {
- data->vref_mv[0] =3D platform_data->vref_mv[0];
- data->vref_mv[1] =3D platform_data->vref_mv[1];
+ for (chan =3D 0; chan < indio_dev->num_channels; chan++) {
+ if (id->driver_data =3D=3D ID_MAX518 || !platform_data)
+ data->vref_mv[chan] =3D 5000; /* mV */
+ else
+ data->vref_mv[chan] =3D platform_data->vref_mv[chan];
}
return iio_device_register(indio_dev);
@@ -202,6 +221,8 @@ static const struct i2c_device_id max517_id[] =3D {
{ "max517", ID_MAX517 },
{ "max518", ID_MAX518 },
{ "max519", ID_MAX519 },
+ { "max520", ID_MAX520 },
+ { "max521", ID_MAX521 },
{ }
};
MODULE_DEVICE_TABLE(i2c, max517_id);
@@ -218,5 +239,5 @@ static struct i2c_driver max517_driver =3D {
module_i2c_driver(max517_driver);
MODULE_AUTHOR("Roland Stigge <stigge@antcom.de>");
-MODULE_DESCRIPTION("MAX517/MAX518/MAX519 8-bit DAC");
+MODULE_DESCRIPTION("MAX517/MAX518/MAX519/MAX521/MAX521 8-bit DAC");
MODULE_LICENSE("GPL");
diff --git a/include/linux/iio/dac/max517.h b/include/linux/iio/dac/max517.=
h
index f6d1d25..7668716 100644
--- a/include/linux/iio/dac/max517.h
+++ b/include/linux/iio/dac/max517.h
@@ -9,7 +9,7 @@
#define IIO_DAC_MAX517_H_
struct max517_platform_data {
- u16 vref_mv[2];
+ u16 vref_mv[8];
};
#endif /* IIO_DAC_MAX517_H_ */
--=20
1.9.1
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH] iio: max517: Add support for MAX520 and MAX521 chips.
2015-02-19 15:22 Antonio Fiol Bonnín
@ 2015-02-19 19:00 ` Peter Meerwald
0 siblings, 0 replies; 3+ messages in thread
From: Peter Meerwald @ 2015-02-19 19:00 UTC (permalink / raw)
To: Antonio Fiol Bonnín; +Cc: linux-iio
> MAX520 and MAX521 are protocol-compatible with the already supported
> chips, just have more channels.
your mail contains funny encoding characters (= is =3D)
other comments inline
> Signed-off-by: Antonio Fiol <antonio@fiol.es>
> ---
> drivers/iio/dac/Kconfig | 11 ++++++++---
> drivers/iio/dac/max517.c | 45 +++++++++++++++++++++++++++++++-------=
> ----
> include/linux/iio/dac/max517.h | 2 +-
> 3 files changed, 42 insertions(+), 16 deletions(-)
>
> diff --git a/drivers/iio/dac/Kconfig b/drivers/iio/dac/Kconfig
> index 2236ea2..2374cce 100644
> --- a/drivers/iio/dac/Kconfig
> +++ b/drivers/iio/dac/Kconfig
> @@ -143,11 +143,16 @@ config AD7303
> ad7303.
>
> config MAX517
> - tristate "Maxim MAX517/518/519 DAC driver"
> + tristate "Maxim MAX517/518/519/520/521 DAC driver"
> depends on I2C
> help
> - If you say yes here you get support for the Maxim chips MAX517,
> - MAX518 and MAX519 (I2C 8-Bit DACs with rail-to-rail outputs).
> + If you say yes here you get support for the following Maxim chips
> + (I2C 8-Bit DACs with rail-to-rail outputs):
> + MAX517 - Single channel, single reference
> + MAX518 - dual channel, ref=3DVdd
ref=3DVdd, I think this should be ref=Vdd -- the = character is escaped
by =3D
single is uppercase, dual/octal not
> + MAX519 - dual channel, dual reference
> + MAX520 - quad channel, quad reference
> + MAX521 - octal channel, independent ref for ch0-3, shared ref for ch=
> 4-7
>
> This driver can also be built as a module. If so, the module
> will be called max517.
> diff --git a/drivers/iio/dac/max517.c b/drivers/iio/dac/max517.c
> index 9a82a72..993977d 100644
> --- a/drivers/iio/dac/max517.c
> +++ b/drivers/iio/dac/max517.c
> @@ -39,11 +39,13 @@ enum max517_device_ids {
> ID_MAX517,
> ID_MAX518,
> ID_MAX519,
> + ID_MAX520,
> + ID_MAX521,
> };
>
> struct max517_data {
> struct i2c_client *client;
> - unsigned short vref_mv[2];
> + unsigned short vref_mv[8];
> };
>
> /*
> @@ -149,7 +151,13 @@ static const struct iio_info max517_info =3D {
>
> static const struct iio_chan_spec max517_channels[] =3D {
> MAX517_CHANNEL(0),
> - MAX517_CHANNEL(1)
> + MAX517_CHANNEL(1),
> + MAX517_CHANNEL(2),
> + MAX517_CHANNEL(3),
> + MAX517_CHANNEL(4),
> + MAX517_CHANNEL(5),
> + MAX517_CHANNEL(6),
> + MAX517_CHANNEL(7)
add an extra comma to the last item
> };
>
> static int max517_probe(struct i2c_client *client,
> @@ -158,6 +166,7 @@ static int max517_probe(struct i2c_client *client,
> struct max517_data *data;
> struct iio_dev *indio_dev;
> struct max517_platform_data *platform_data =3D client->dev.platform_da=
> ta;
> + int chan;
>
> indio_dev =3D devm_iio_device_alloc(&client->dev, sizeof(*data));
> if (!indio_dev)
> @@ -169,11 +178,21 @@ static int max517_probe(struct i2c_client *client,
> /* establish that the iio_dev is a child of the i2c device */
> indio_dev->dev.parent =3D &client->dev;
>
> - /* reduced channel set for MAX517 */
> - if (id->driver_data =3D=3D ID_MAX517)
> - indio_dev->num_channels =3D 1;
> - else
> + switch (id->driver_data) {
> + case ID_MAX521:
> + indio_dev->num_channels =3D 8;
> + break;
> + case ID_MAX520:
> + indio_dev->num_channels =3D 4;
> + break;
> + case ID_MAX519:
> + case ID_MAX518:
> indio_dev->num_channels =3D 2;
> + break;
> + default: /* single channel for MAX517 */
> + indio_dev->num_channels =3D 1;
> + break;
> + }
> indio_dev->channels =3D max517_channels;
> indio_dev->modes =3D INDIO_DIRECT_MODE;
> indio_dev->info =3D &max517_info;
> @@ -182,11 +201,11 @@ static int max517_probe(struct i2c_client *client,
> * Reference voltage on MAX518 and default is 5V, else take vref_mv
> * from platform_data
> */
> - if (id->driver_data =3D=3D ID_MAX518 || !platform_data) {
> - data->vref_mv[0] =3D data->vref_mv[1] =3D 5000; /* mV */
> - } else {
> - data->vref_mv[0] =3D platform_data->vref_mv[0];
> - data->vref_mv[1] =3D platform_data->vref_mv[1];
> + for (chan =3D 0; chan < indio_dev->num_channels; chan++) {
> + if (id->driver_data =3D=3D ID_MAX518 || !platform_data)
> + data->vref_mv[chan] =3D 5000; /* mV */
> + else
> + data->vref_mv[chan] =3D platform_data->vref_mv[chan];
> }
>
> return iio_device_register(indio_dev);
> @@ -202,6 +221,8 @@ static const struct i2c_device_id max517_id[] =3D {
> { "max517", ID_MAX517 },
> { "max518", ID_MAX518 },
> { "max519", ID_MAX519 },
> + { "max520", ID_MAX520 },
> + { "max521", ID_MAX521 },
> { }
> };
> MODULE_DEVICE_TABLE(i2c, max517_id);
> @@ -218,5 +239,5 @@ static struct i2c_driver max517_driver =3D {
> module_i2c_driver(max517_driver);
>
> MODULE_AUTHOR("Roland Stigge <stigge@antcom.de>");
> -MODULE_DESCRIPTION("MAX517/MAX518/MAX519 8-bit DAC");
> +MODULE_DESCRIPTION("MAX517/MAX518/MAX519/MAX521/MAX521 8-bit DAC");
maybe this could be shortened to MAX517/518/519/520/521
note that 521 is listed twice above
> MODULE_LICENSE("GPL");
> diff --git a/include/linux/iio/dac/max517.h b/include/linux/iio/dac/max517.=
> h
> index f6d1d25..7668716 100644
> --- a/include/linux/iio/dac/max517.h
> +++ b/include/linux/iio/dac/max517.h
> @@ -9,7 +9,7 @@
> #define IIO_DAC_MAX517_H_
>
> struct max517_platform_data {
> - u16 vref_mv[2];
> + u16 vref_mv[8];
> };
>
> #endif /* IIO_DAC_MAX517_H_ */
> --=20
> 1.9.1
> --
> To unsubscribe from this list: send the line "unsubscribe linux-iio" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
>
--
Peter Meerwald
+43-664-2444418 (mobile)
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2015-03-28 10:57 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <1427530034-22848-1-git-send-email-antonio@fiol.es>
2015-03-28 10:57 ` [PATCH] iio: max517: Add support for MAX520 and MAX521 chips Jonathan Cameron
2015-02-19 15:22 Antonio Fiol Bonnín
2015-02-19 19:00 ` Peter Meerwald
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).