All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jonathan Cameron <jic23@kernel.org>
To: Josef Gajdusek <atx@atalax.net>, linux-iio@vger.kernel.org
Cc: devel@driverdev.osuosl.org, gregkh@linuxfoundation.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH 5/5] staging:iio:hmc5843: Add support for spi hmc5983
Date: Mon, 07 Jul 2014 18:06:40 +0100	[thread overview]
Message-ID: <53BAD3A0.8070706@kernel.org> (raw)
In-Reply-To: <20140702135410.GF15493@dashie>

On 02/07/14 14:54, Josef Gajdusek wrote:
> This patch adds support for the hmc5983 spi interface.
> This chip is almost identical to the hmc5883. The difference being added
> temperature compensation, additional available sample rate (220Hz) and an SPI
> interface.
>
> Signed-off-by: Josef Gajdusek <atx@atx.name>
Sometimes I like how nicely regmap makes this stuff come together.
So the series all looks good to me except for the few little
bits in patch 1.

J
> ---
>   drivers/staging/iio/magnetometer/Kconfig       |   8 ++
>   drivers/staging/iio/magnetometer/Makefile      |   1 +
>   drivers/staging/iio/magnetometer/hmc5843_spi.c | 105 +++++++++++++++++++++++++
>   3 files changed, 114 insertions(+)
>   create mode 100644 drivers/staging/iio/magnetometer/hmc5843_spi.c
>
> diff --git a/drivers/staging/iio/magnetometer/Kconfig b/drivers/staging/iio/magnetometer/Kconfig
> index 32c69c0..bc5c355 100644
> --- a/drivers/staging/iio/magnetometer/Kconfig
> +++ b/drivers/staging/iio/magnetometer/Kconfig
> @@ -9,6 +9,7 @@ config SENSORS_HMC5843
>   	select IIO_BUFFER
>   	select IIO_TRIGGERED_BUFFER
>   	select SENSORS_HMC5843_I2C if (I2C)
> +	select SENSORS_HMC5843_SPI if (SPI_MASTER)
>   	help
>   	  Say Y here to add support for the Honeywell HMC5843, HMC5883 and
>   	  HMC5883L 3-Axis Magnetometer (digital compass).
> @@ -17,6 +18,7 @@ config SENSORS_HMC5843
>   	  If so, these modules will be created:
>   	  - hmc5843_core (core functions)
>   	  - hmc5843_i2c (support for HMC5843, HMC5883, HMC5883L and HMC5983)
> +	  - hmc5843_spi (support for HMC5983)
>
>   config SENSORS_HMC5843_I2C
>   	tristate
> @@ -24,4 +26,10 @@ config SENSORS_HMC5843_I2C
>   	depends on SENSORS_HMC5843
>   	select REGMAP_I2C
>
> +config SENSORS_HMC5843_SPI
> +	tristate
> +	depends on SPI_MASTER
> +	depends on SENSORS_HMC5843
> +	select REGMAP_SPI
> +
>   endmenu
> diff --git a/drivers/staging/iio/magnetometer/Makefile b/drivers/staging/iio/magnetometer/Makefile
> index 65baf1c..33761a1 100644
> --- a/drivers/staging/iio/magnetometer/Makefile
> +++ b/drivers/staging/iio/magnetometer/Makefile
> @@ -4,3 +4,4 @@
>
>   obj-$(CONFIG_SENSORS_HMC5843)		+= hmc5843_core.o
>   obj-$(CONFIG_SENSORS_HMC5843_I2C)	+= hmc5843_i2c.o
> +obj-$(CONFIG_SENSORS_HMC5843_SPI)	+= hmc5843_spi.o
> diff --git a/drivers/staging/iio/magnetometer/hmc5843_spi.c b/drivers/staging/iio/magnetometer/hmc5843_spi.c
> new file mode 100644
> index 0000000..3f71ee0
> --- /dev/null
> +++ b/drivers/staging/iio/magnetometer/hmc5843_spi.c
> @@ -0,0 +1,105 @@
> +/*
> + * SPI driver for hmc5983
> + *
> + * Copyright (C) Josef Gajdusek <atx@atx.name>
> + *
> + * This program is free software; you can redistribute it and/or modify
> + * it under the terms of the GNU General Public License version 2 as
> + * published by the Free Software Foundation.
> + *
> + * */
> +
> +#include <linux/module.h>
> +#include <linux/spi/spi.h>
> +#include <linux/iio/iio.h>
> +
> +#include "hmc5843.h"
> +
> +struct regmap_config hmc5843_spi_regmap_config = {
> +		.reg_bits = 8,
> +		.val_bits = 8,
> +
> +		.rd_table = &hmc5843_readable_table,
> +		.wr_table = &hmc5843_writable_table,
> +		.volatile_table = &hmc5843_volatile_table,
> +
> +		/* Autoincrement address pointer */
> +		.read_flag_mask = 0xc0,
> +
> +		.cache_type = REGCACHE_RBTREE,
> +};
> +
> +static int hmc5843_spi_probe(struct spi_device *spi)
> +{
> +	struct hmc5843_data *data;
> +	struct iio_dev *indio_dev;
> +	int ret;
> +
> +	indio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*data));
> +	if (indio_dev == NULL)
> +		return -ENOMEM;
> +
> +	spi->mode = SPI_MODE_3;
> +	spi->max_speed_hz = 8000000;
> +	spi->bits_per_word = 8;
> +	ret = spi_setup(spi);
> +	if (ret)
> +		return ret;
> +
> +	spi_set_drvdata(spi, indio_dev);
> +
> +	data = iio_priv(indio_dev);
> +	data->dev = &spi->dev;
> +	data->regmap = devm_regmap_init_spi(spi, &hmc5843_spi_regmap_config);
> +
> +	indio_dev->dev.parent = &spi->dev;
> +
> +	return hmc5843_common_probe(indio_dev, HMC5983_ID);
> +}
> +
> +static int hmc5843_spi_remove(struct spi_device *spi)
> +{
> +	struct iio_dev *indio_dev = spi_get_drvdata(spi);
> +	return hmc5843_common_remove(indio_dev);
> +}
> +
> +#ifdef CONFIG_PM_SLEEP
> +static int hmc5843_spi_suspend(struct device *dev)
> +{
> +	return hmc5843_common_suspend(spi_get_drvdata(to_spi_device(dev)));
> +}
> +
> +static int hmc5843_spi_resume(struct device *dev)
> +{
> +	return hmc5843_common_resume(spi_get_drvdata(to_spi_device(dev)));
> +}
> +
> +static SIMPLE_DEV_PM_OPS(hmc5843_pm_ops,
> +		hmc5843_spi_suspend, hmc5843_spi_resume);
> +#define HMC5843_PM_OPS (&hmc5843_pm_ops)
> +#else
> +#define HMC5843_PM_OPS NULL
> +#endif
> +
> +
> +static const struct spi_device_id hmc5843_id[] = {
> +	{ "hmc5983", HMC5983_ID },
> +	{ }
> +};
> +
> +static struct spi_driver hmc5843_driver = {
> +		.driver = {
> +				.name = "hmc5843",
> +				.pm = HMC5843_PM_OPS,
> +				.owner = THIS_MODULE,
> +		},
> +		.id_table = hmc5843_id,
> +		.probe = hmc5843_spi_probe,
> +		.remove = hmc5843_spi_remove,
> +};
> +
> +module_spi_driver(hmc5843_driver);
> +
> +MODULE_AUTHOR("Josef Gajdusek <atx@atx.name>");
> +MODULE_DESCRIPTION("HMC5983 SPI driver");
> +MODULE_LICENSE("GPL");
>


      reply	other threads:[~2014-07-07 17:04 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-07-02 13:48 [PATCH 0/5] staging:iio:hmc5843: Few adjustments and support for hmc5983 Josef Gajdusek
2014-07-02 13:50 ` [PATCH 1/5] staging:iio:hmc5843: Added regmap support Josef Gajdusek
2014-07-07 17:00   ` Jonathan Cameron
2014-07-07 18:50     ` Josef Gajdusek
     [not found]       ` <8e31f2b8-25ed-450e-9b70-f9338f8f3c4b@email.android.com>
2014-07-07 19:32         ` Peter Meerwald
2014-07-02 13:51 ` [PATCH 2/5] staging:iio:hmc5843: Split hmc5843.c to multiple files Josef Gajdusek
2014-07-07 17:02   ` Jonathan Cameron
2014-07-02 13:52 ` [PATCH 3/5] staging:iio:hmc5843: register <-> value arrays now can have different lengths Josef Gajdusek
2014-07-07 17:03   ` Jonathan Cameron
2014-07-02 13:53 ` [PATCH 4/5] staging:iio:hmc5843: Add support for i2c hmc5983 Josef Gajdusek
2014-07-07 17:04   ` Jonathan Cameron
2014-07-02 13:54 ` [PATCH 5/5] staging:iio:hmc5843: Add support for spi hmc5983 Josef Gajdusek
2014-07-07 17:06   ` Jonathan Cameron [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=53BAD3A0.8070706@kernel.org \
    --to=jic23@kernel.org \
    --cc=atx@atalax.net \
    --cc=devel@driverdev.osuosl.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.