All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] misc: add driver for Renesas R-Car Gyro-ADC/speed-pulse interfaces
@ 2013-07-12 23:51 ` Sergei Shtylyov
  0 siblings, 0 replies; 20+ messages in thread
From: Sergei Shtylyov @ 2013-07-12 23:51 UTC (permalink / raw)
  To: arnd, linux-kernel, gregkh; +Cc: linux-sh

Add the driver for Gyro-ADC/speed-pulse interfaces found in Renesas R-Car SoCs.
Though  being two separate devices, they have to be driven together because of
the shared start/stop register (located in Gyro-ADC still). At this time, only
speed-pulse interface is fully supported, the Gyro-ADC is just initialized and
started/stopped synchronously with the speed-pulse interface.  A user interface
is implemented via several sysfs files which allow to read and reset the speed-
pulse interface's registers.

Signed-off-by: Sergei Shtylyov <sergei.shtylyov@cogentembedded.com>

---
This patch is againt the 'char-misc-next' barnch of Greg KH's 'char-misc.git'.

 drivers/misc/Kconfig                     |   10 +
 drivers/misc/Makefile                    |    1 
 drivers/misc/rcar-gyro-adc-speed-pulse.c |  231 +++++++++++++++++++++++++++++++
 3 files changed, 242 insertions(+)

Index: char-misc/drivers/misc/Kconfig
=================================--- char-misc.orig/drivers/misc/Kconfig
+++ char-misc/drivers/misc/Kconfig
@@ -528,6 +528,16 @@ config SRAM
 	  the genalloc API. It is supposed to be used for small on-chip SRAM
 	  areas found on many SoCs.
 
+config RCAR_GYRO_ADC_SPEED_PULSE
+	tristate "Renesas R-Car Gyro-ADC and speed-pulse interfaces driver"
+	depends on HAS_IOMEM
+	help
+	  This driver allows you to read speed pulse signal characteristics via
+	  sysfs. The Gyro-ADC interface is not currently supported.
+
+	  This driver can also be built as a module. If so, the module
+	  will be called rcar_gyro_adc_speed_pulse.
+
 source "drivers/misc/c2port/Kconfig"
 source "drivers/misc/eeprom/Kconfig"
 source "drivers/misc/cb710/Kconfig"
Index: char-misc/drivers/misc/Makefile
=================================--- char-misc.orig/drivers/misc/Makefile
+++ char-misc/drivers/misc/Makefile
@@ -53,3 +53,4 @@ obj-$(CONFIG_INTEL_MEI)		+= mei/
 obj-$(CONFIG_VMWARE_VMCI)	+= vmw_vmci/
 obj-$(CONFIG_LATTICE_ECP3_CONFIG)	+= lattice-ecp3-config.o
 obj-$(CONFIG_SRAM)		+= sram.o
+obj-$(CONFIG_RCAR_GYRO_ADC_SPEED_PULSE)	+= rcar-gyro-adc-speed-pulse.o
Index: char-misc/drivers/misc/rcar-gyro-adc-speed-pulse.c
=================================--- /dev/null
+++ char-misc/drivers/misc/rcar-gyro-adc-speed-pulse.c
@@ -0,0 +1,231 @@
+/*
+ * Renesas R-Car Gyro-ADC and speed-pulse interfaces driver
+ *
+ * Copyright (C) 2013  Renesas Solutions Corp.
+ * Copyright (C) 2013  Cogent Embedded, Inc.
+ *
+ * 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; of the License.
+ *
+ * NOTE: Gyro-ADC interface is not really supported yet, just initialized
+ * and started/stopped synchronously with the speed-pulse interface.
+ */
+
+#include <linux/clk.h>
+#include <linux/err.h>
+#include <linux/gfp.h>
+#include <linux/init.h>
+#include <linux/io.h>
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/platform_device.h>
+#include <linux/stat.h>
+#include <linux/types.h>
+
+#include <asm/div64.h>
+
+/* Gyro-ADC interface registers */
+#define	ADC_MODE_SELECT			0x00
+#define	ADC_SPEED_START_STOP		0x04
+#define	ADC_CLOCK_LENGTH_COUNT		0x08
+#define	_1_25_MS_LENGTH_COUNT		0x0C
+#define	AD_CH_REAL_DATA(n)		(0x10 + (n) * 4)
+#define	AD_CH_ADD_DATA(n)		(0x30 + (n) * 4)
+#define	AD_CH_10MS_DATA_FIFO(n)		(0x50 + (n) * 4)
+#define	AD_FIFO_STATUS			0x70
+
+/* Speed-pulse interface registers */
+#define	SPEED_PULSE_COUNT_DATA		0x000
+#define	SPEED_PULSE_FILTER_SETTING	0x004
+#define	SPEED_PULSE_COUNT_CLEARING	0x008
+#define	SPEED_PULSE_100MS_LATCH_DATA	0x00C
+#define	_100_MS_INT_COUNT		0x010
+#define	INT_STATUS_AND_CLEAR		0x018
+#define	_500_KHZ_FREQ_COUNT_SETTING	0x01C
+#define	SPEED_PULSE_OFFSET_A		0x100
+#define	SPEED_PULSE_OFFSET_B		0x104
+#define	SPEED_PULSE_WIDTH		0x108
+#define	SPEED_PULSE_OBSERVE_A		0x10C
+#define	SPEED_PULSE_OBSERVE_B		0x110
+#define	SPEED_PULSE_WIDTH_CLEARING	0x114
+#define	SPEED_PULSE_WIDTH_TEST		0x118
+
+struct rcar_adc_sp_priv {
+	void __iomem *adc_base;
+	void __iomem *sp_base;
+	struct clk *adc_clk;
+	struct clk *sp_clk;
+};
+
+static u16 filter_time_const;
+module_param_named(filter, filter_time_const, ushort, S_IRUGO);
+MODULE_PARM_DESC(filter,
+		 "Low-pass filter time constant in microseconds (default=0)");
+
+static ssize_t rcar_adc_sp_show_pulse_count(struct device *dev,
+					    struct device_attribute *attr,
+					    char *buf)
+{
+	struct rcar_adc_sp_priv *priv = dev_get_drvdata(dev);
+	u32 value = __raw_readl(priv->sp_base + SPEED_PULSE_COUNT_DATA);
+
+	return sprintf(buf, "%u\n", value);
+}
+
+#define BUILD_CLEAR(what, reg)						\
+static ssize_t rcar_adc_sp_clear_##what(struct device *dev,		\
+					struct device_attribute *attr,	\
+					const char *buf, size_t count)	\
+{									\
+	struct rcar_adc_sp_priv *priv = dev_get_drvdata(dev);		\
+	u32 value;							\
+									\
+	if (kstrtouint(buf, 10, &value) < 0)				\
+		return -EINVAL;						\
+	if (value > 1)							\
+		return -EINVAL;						\
+									\
+	__raw_writel(value, priv->sp_base + (reg));			\
+									\
+	return count;							\
+}
+
+#define BUILD_SHOW(what, reg)						\
+static ssize_t rcar_adc_sp_show_##what(struct device *dev,		\
+				       struct device_attribute *attr,	\
+				       char *buf)			\
+{									\
+	struct rcar_adc_sp_priv *priv = dev_get_drvdata(dev);		\
+	u32 value = __raw_readl(priv->sp_base + (reg));			\
+									\
+	return sprintf(buf, "%u\n", value * 2); /* in us */		\
+}
+
+BUILD_CLEAR(pulse_count, SPEED_PULSE_COUNT_CLEARING)
+BUILD_CLEAR(pulse_width, SPEED_PULSE_WIDTH_CLEARING)
+
+BUILD_SHOW(pulse_width, SPEED_PULSE_WIDTH)
+BUILD_SHOW(pulse_offset, SPEED_PULSE_OFFSET_A)
+BUILD_SHOW(pulse_observed, SPEED_PULSE_OBSERVE_A)
+
+static DEVICE_ATTR(pulse_count, S_IRUGO | S_IWUSR, rcar_adc_sp_show_pulse_count,
+		   rcar_adc_sp_clear_pulse_count);
+static DEVICE_ATTR(pulse_width, S_IRUGO | S_IWUSR, rcar_adc_sp_show_pulse_width,
+		   rcar_adc_sp_clear_pulse_width);
+static DEVICE_ATTR(pulse_offset, S_IRUGO, rcar_adc_sp_show_pulse_offset, NULL);
+static DEVICE_ATTR(pulse_observed, S_IRUGO, rcar_adc_sp_show_pulse_observed,
+		   NULL);
+
+static struct attribute *rcar_adc_sp_attributes[] = {
+	&dev_attr_pulse_count.attr,
+	&dev_attr_pulse_width.attr,
+	&dev_attr_pulse_offset.attr,
+	&dev_attr_pulse_observed.attr,
+	NULL
+};
+
+static const struct attribute_group rcar_adc_sp_attr_group = {
+	.attrs = rcar_adc_sp_attributes,
+};
+
+static __init int rcar_adc_sp_probe(struct platform_device *pdev)
+{
+	struct rcar_adc_sp_priv *priv;
+	struct resource *res;
+	unsigned long freq;
+	u32 value;
+	u64 temp;
+	int err;
+
+	priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL);
+	if (!priv)
+		return -ENOMEM;
+	platform_set_drvdata(pdev, priv);
+
+	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+	priv->adc_base = devm_ioremap_resource(&pdev->dev, res);
+	if (IS_ERR(priv->adc_base))
+		return PTR_ERR(priv->adc_base);
+
+	res = platform_get_resource(pdev, IORESOURCE_MEM, 1);
+	priv->sp_base = devm_ioremap_resource(&pdev->dev, res);
+	if (IS_ERR(priv->sp_base))
+		return PTR_ERR(priv->sp_base);
+
+	priv->adc_clk = devm_clk_get(&pdev->dev, "gyro-adc");
+	if (IS_ERR(priv->adc_clk))
+		return PTR_ERR(priv->adc_clk);
+
+	priv->sp_clk = devm_clk_get(&pdev->dev, "speed-pulse");
+	if (IS_ERR(priv->sp_clk))
+		return PTR_ERR(priv->sp_clk);
+
+	err = sysfs_create_group(&pdev->dev.kobj, &rcar_adc_sp_attr_group);
+	if (err)
+		return err;
+
+	clk_enable(priv->adc_clk);
+	clk_enable(priv->sp_clk);
+
+	/* Select mode 1 by default */
+	__raw_writel(0, priv->sp_base + ADC_MODE_SELECT);
+
+	freq = clk_get_rate(priv->adc_clk);
+
+	/* Select 10 us period for mode 1 */
+	value = DIV_ROUND_UP(freq * 10, 1000000);
+	if (value & 1)
+		value++;
+	__raw_writel(value, priv->sp_base + ADC_CLOCK_LENGTH_COUNT);
+
+	/* 1.25 ms period */
+	temp = freq * 1250ULL + 999999;
+	do_div(temp, 1000000);
+	value = (u32)temp;
+	__raw_writel(value, priv->sp_base + _1_25_MS_LENGTH_COUNT);
+
+	temp = freq * (u64)filter_time_const / 8 + 999999;
+	do_div(temp, 1000000);
+	value = (u32)temp;
+	__raw_writel(value, priv->sp_base + SPEED_PULSE_FILTER_SETTING);
+
+	freq = clk_get_rate(priv->sp_clk);
+
+	/* 2 us period */
+	value = DIV_ROUND_UP(freq * 2, 1000000);
+	__raw_writel(value, priv->sp_base + _500_KHZ_FREQ_COUNT_SETTING);
+
+	/* Start Gyro-ADC and speed-pulse interfaces */
+	__raw_writel(1, priv->adc_base + ADC_SPEED_START_STOP);
+
+	return 0;
+}
+
+static __exit int rcar_adc_sp_remove(struct platform_device *pdev)
+{
+	struct rcar_adc_sp_priv *priv = platform_get_drvdata(pdev);
+
+	/* Stop Gyro-ADC and speed-pulse interfaces */
+	__raw_writel(0, priv->adc_base + ADC_SPEED_START_STOP);
+
+	clk_disable(priv->sp_clk);
+	clk_disable(priv->adc_clk);
+
+	sysfs_remove_group(&pdev->dev.kobj, &rcar_adc_sp_attr_group);
+	return 0;
+}
+
+static struct platform_driver rcar_adc_sp_driver = {
+	.driver = {
+		.name	= "rcar-gyro-adc-speed-pulse",
+		.owner	= THIS_MODULE,
+	},
+	.remove	= __exit_p(rcar_adc_sp__remove),
+};
+
+module_platform_driver_probe(rcar_adc_sp_driver, rcar_adc_sp_probe);
+
+MODULE_AUTHOR("Sergei Shtylyov <sergei.shtylyov@cogentembedded.com>");
+MODULE_DESCRIPTION("Renesas R-Car Gyro-ADC and speed-pulse interfaces driver");
+MODULE_LICENSE("GPL v2");

^ permalink raw reply	[flat|nested] 20+ messages in thread

* [PATCH] misc: add driver for Renesas R-Car Gyro-ADC/speed-pulse interfaces
@ 2013-07-12 23:51 ` Sergei Shtylyov
  0 siblings, 0 replies; 20+ messages in thread
From: Sergei Shtylyov @ 2013-07-12 23:51 UTC (permalink / raw)
  To: arnd, linux-kernel, gregkh; +Cc: linux-sh

Add the driver for Gyro-ADC/speed-pulse interfaces found in Renesas R-Car SoCs.
Though  being two separate devices, they have to be driven together because of
the shared start/stop register (located in Gyro-ADC still). At this time, only
speed-pulse interface is fully supported, the Gyro-ADC is just initialized and
started/stopped synchronously with the speed-pulse interface.  A user interface
is implemented via several sysfs files which allow to read and reset the speed-
pulse interface's registers.

Signed-off-by: Sergei Shtylyov <sergei.shtylyov@cogentembedded.com>

---
This patch is againt the 'char-misc-next' barnch of Greg KH's 'char-misc.git'.

 drivers/misc/Kconfig                     |   10 +
 drivers/misc/Makefile                    |    1 
 drivers/misc/rcar-gyro-adc-speed-pulse.c |  231 +++++++++++++++++++++++++++++++
 3 files changed, 242 insertions(+)

Index: char-misc/drivers/misc/Kconfig
===================================================================
--- char-misc.orig/drivers/misc/Kconfig
+++ char-misc/drivers/misc/Kconfig
@@ -528,6 +528,16 @@ config SRAM
 	  the genalloc API. It is supposed to be used for small on-chip SRAM
 	  areas found on many SoCs.
 
+config RCAR_GYRO_ADC_SPEED_PULSE
+	tristate "Renesas R-Car Gyro-ADC and speed-pulse interfaces driver"
+	depends on HAS_IOMEM
+	help
+	  This driver allows you to read speed pulse signal characteristics via
+	  sysfs. The Gyro-ADC interface is not currently supported.
+
+	  This driver can also be built as a module. If so, the module
+	  will be called rcar_gyro_adc_speed_pulse.
+
 source "drivers/misc/c2port/Kconfig"
 source "drivers/misc/eeprom/Kconfig"
 source "drivers/misc/cb710/Kconfig"
Index: char-misc/drivers/misc/Makefile
===================================================================
--- char-misc.orig/drivers/misc/Makefile
+++ char-misc/drivers/misc/Makefile
@@ -53,3 +53,4 @@ obj-$(CONFIG_INTEL_MEI)		+= mei/
 obj-$(CONFIG_VMWARE_VMCI)	+= vmw_vmci/
 obj-$(CONFIG_LATTICE_ECP3_CONFIG)	+= lattice-ecp3-config.o
 obj-$(CONFIG_SRAM)		+= sram.o
+obj-$(CONFIG_RCAR_GYRO_ADC_SPEED_PULSE)	+= rcar-gyro-adc-speed-pulse.o
Index: char-misc/drivers/misc/rcar-gyro-adc-speed-pulse.c
===================================================================
--- /dev/null
+++ char-misc/drivers/misc/rcar-gyro-adc-speed-pulse.c
@@ -0,0 +1,231 @@
+/*
+ * Renesas R-Car Gyro-ADC and speed-pulse interfaces driver
+ *
+ * Copyright (C) 2013  Renesas Solutions Corp.
+ * Copyright (C) 2013  Cogent Embedded, Inc.
+ *
+ * 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; of the License.
+ *
+ * NOTE: Gyro-ADC interface is not really supported yet, just initialized
+ * and started/stopped synchronously with the speed-pulse interface.
+ */
+
+#include <linux/clk.h>
+#include <linux/err.h>
+#include <linux/gfp.h>
+#include <linux/init.h>
+#include <linux/io.h>
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/platform_device.h>
+#include <linux/stat.h>
+#include <linux/types.h>
+
+#include <asm/div64.h>
+
+/* Gyro-ADC interface registers */
+#define	ADC_MODE_SELECT			0x00
+#define	ADC_SPEED_START_STOP		0x04
+#define	ADC_CLOCK_LENGTH_COUNT		0x08
+#define	_1_25_MS_LENGTH_COUNT		0x0C
+#define	AD_CH_REAL_DATA(n)		(0x10 + (n) * 4)
+#define	AD_CH_ADD_DATA(n)		(0x30 + (n) * 4)
+#define	AD_CH_10MS_DATA_FIFO(n)		(0x50 + (n) * 4)
+#define	AD_FIFO_STATUS			0x70
+
+/* Speed-pulse interface registers */
+#define	SPEED_PULSE_COUNT_DATA		0x000
+#define	SPEED_PULSE_FILTER_SETTING	0x004
+#define	SPEED_PULSE_COUNT_CLEARING	0x008
+#define	SPEED_PULSE_100MS_LATCH_DATA	0x00C
+#define	_100_MS_INT_COUNT		0x010
+#define	INT_STATUS_AND_CLEAR		0x018
+#define	_500_KHZ_FREQ_COUNT_SETTING	0x01C
+#define	SPEED_PULSE_OFFSET_A		0x100
+#define	SPEED_PULSE_OFFSET_B		0x104
+#define	SPEED_PULSE_WIDTH		0x108
+#define	SPEED_PULSE_OBSERVE_A		0x10C
+#define	SPEED_PULSE_OBSERVE_B		0x110
+#define	SPEED_PULSE_WIDTH_CLEARING	0x114
+#define	SPEED_PULSE_WIDTH_TEST		0x118
+
+struct rcar_adc_sp_priv {
+	void __iomem *adc_base;
+	void __iomem *sp_base;
+	struct clk *adc_clk;
+	struct clk *sp_clk;
+};
+
+static u16 filter_time_const;
+module_param_named(filter, filter_time_const, ushort, S_IRUGO);
+MODULE_PARM_DESC(filter,
+		 "Low-pass filter time constant in microseconds (default=0)");
+
+static ssize_t rcar_adc_sp_show_pulse_count(struct device *dev,
+					    struct device_attribute *attr,
+					    char *buf)
+{
+	struct rcar_adc_sp_priv *priv = dev_get_drvdata(dev);
+	u32 value = __raw_readl(priv->sp_base + SPEED_PULSE_COUNT_DATA);
+
+	return sprintf(buf, "%u\n", value);
+}
+
+#define BUILD_CLEAR(what, reg)						\
+static ssize_t rcar_adc_sp_clear_##what(struct device *dev,		\
+					struct device_attribute *attr,	\
+					const char *buf, size_t count)	\
+{									\
+	struct rcar_adc_sp_priv *priv = dev_get_drvdata(dev);		\
+	u32 value;							\
+									\
+	if (kstrtouint(buf, 10, &value) < 0)				\
+		return -EINVAL;						\
+	if (value > 1)							\
+		return -EINVAL;						\
+									\
+	__raw_writel(value, priv->sp_base + (reg));			\
+									\
+	return count;							\
+}
+
+#define BUILD_SHOW(what, reg)						\
+static ssize_t rcar_adc_sp_show_##what(struct device *dev,		\
+				       struct device_attribute *attr,	\
+				       char *buf)			\
+{									\
+	struct rcar_adc_sp_priv *priv = dev_get_drvdata(dev);		\
+	u32 value = __raw_readl(priv->sp_base + (reg));			\
+									\
+	return sprintf(buf, "%u\n", value * 2); /* in us */		\
+}
+
+BUILD_CLEAR(pulse_count, SPEED_PULSE_COUNT_CLEARING)
+BUILD_CLEAR(pulse_width, SPEED_PULSE_WIDTH_CLEARING)
+
+BUILD_SHOW(pulse_width, SPEED_PULSE_WIDTH)
+BUILD_SHOW(pulse_offset, SPEED_PULSE_OFFSET_A)
+BUILD_SHOW(pulse_observed, SPEED_PULSE_OBSERVE_A)
+
+static DEVICE_ATTR(pulse_count, S_IRUGO | S_IWUSR, rcar_adc_sp_show_pulse_count,
+		   rcar_adc_sp_clear_pulse_count);
+static DEVICE_ATTR(pulse_width, S_IRUGO | S_IWUSR, rcar_adc_sp_show_pulse_width,
+		   rcar_adc_sp_clear_pulse_width);
+static DEVICE_ATTR(pulse_offset, S_IRUGO, rcar_adc_sp_show_pulse_offset, NULL);
+static DEVICE_ATTR(pulse_observed, S_IRUGO, rcar_adc_sp_show_pulse_observed,
+		   NULL);
+
+static struct attribute *rcar_adc_sp_attributes[] = {
+	&dev_attr_pulse_count.attr,
+	&dev_attr_pulse_width.attr,
+	&dev_attr_pulse_offset.attr,
+	&dev_attr_pulse_observed.attr,
+	NULL
+};
+
+static const struct attribute_group rcar_adc_sp_attr_group = {
+	.attrs = rcar_adc_sp_attributes,
+};
+
+static __init int rcar_adc_sp_probe(struct platform_device *pdev)
+{
+	struct rcar_adc_sp_priv *priv;
+	struct resource *res;
+	unsigned long freq;
+	u32 value;
+	u64 temp;
+	int err;
+
+	priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL);
+	if (!priv)
+		return -ENOMEM;
+	platform_set_drvdata(pdev, priv);
+
+	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+	priv->adc_base = devm_ioremap_resource(&pdev->dev, res);
+	if (IS_ERR(priv->adc_base))
+		return PTR_ERR(priv->adc_base);
+
+	res = platform_get_resource(pdev, IORESOURCE_MEM, 1);
+	priv->sp_base = devm_ioremap_resource(&pdev->dev, res);
+	if (IS_ERR(priv->sp_base))
+		return PTR_ERR(priv->sp_base);
+
+	priv->adc_clk = devm_clk_get(&pdev->dev, "gyro-adc");
+	if (IS_ERR(priv->adc_clk))
+		return PTR_ERR(priv->adc_clk);
+
+	priv->sp_clk = devm_clk_get(&pdev->dev, "speed-pulse");
+	if (IS_ERR(priv->sp_clk))
+		return PTR_ERR(priv->sp_clk);
+
+	err = sysfs_create_group(&pdev->dev.kobj, &rcar_adc_sp_attr_group);
+	if (err)
+		return err;
+
+	clk_enable(priv->adc_clk);
+	clk_enable(priv->sp_clk);
+
+	/* Select mode 1 by default */
+	__raw_writel(0, priv->sp_base + ADC_MODE_SELECT);
+
+	freq = clk_get_rate(priv->adc_clk);
+
+	/* Select 10 us period for mode 1 */
+	value = DIV_ROUND_UP(freq * 10, 1000000);
+	if (value & 1)
+		value++;
+	__raw_writel(value, priv->sp_base + ADC_CLOCK_LENGTH_COUNT);
+
+	/* 1.25 ms period */
+	temp = freq * 1250ULL + 999999;
+	do_div(temp, 1000000);
+	value = (u32)temp;
+	__raw_writel(value, priv->sp_base + _1_25_MS_LENGTH_COUNT);
+
+	temp = freq * (u64)filter_time_const / 8 + 999999;
+	do_div(temp, 1000000);
+	value = (u32)temp;
+	__raw_writel(value, priv->sp_base + SPEED_PULSE_FILTER_SETTING);
+
+	freq = clk_get_rate(priv->sp_clk);
+
+	/* 2 us period */
+	value = DIV_ROUND_UP(freq * 2, 1000000);
+	__raw_writel(value, priv->sp_base + _500_KHZ_FREQ_COUNT_SETTING);
+
+	/* Start Gyro-ADC and speed-pulse interfaces */
+	__raw_writel(1, priv->adc_base + ADC_SPEED_START_STOP);
+
+	return 0;
+}
+
+static __exit int rcar_adc_sp_remove(struct platform_device *pdev)
+{
+	struct rcar_adc_sp_priv *priv = platform_get_drvdata(pdev);
+
+	/* Stop Gyro-ADC and speed-pulse interfaces */
+	__raw_writel(0, priv->adc_base + ADC_SPEED_START_STOP);
+
+	clk_disable(priv->sp_clk);
+	clk_disable(priv->adc_clk);
+
+	sysfs_remove_group(&pdev->dev.kobj, &rcar_adc_sp_attr_group);
+	return 0;
+}
+
+static struct platform_driver rcar_adc_sp_driver = {
+	.driver = {
+		.name	= "rcar-gyro-adc-speed-pulse",
+		.owner	= THIS_MODULE,
+	},
+	.remove	= __exit_p(rcar_adc_sp__remove),
+};
+
+module_platform_driver_probe(rcar_adc_sp_driver, rcar_adc_sp_probe);
+
+MODULE_AUTHOR("Sergei Shtylyov <sergei.shtylyov@cogentembedded.com>");
+MODULE_DESCRIPTION("Renesas R-Car Gyro-ADC and speed-pulse interfaces driver");
+MODULE_LICENSE("GPL v2");

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH] misc: add driver for Renesas R-Car Gyro-ADC/speed-pulse interfaces
  2013-07-12 23:51 ` Sergei Shtylyov
@ 2013-07-13  0:57   ` Greg KH
  -1 siblings, 0 replies; 20+ messages in thread
From: Greg KH @ 2013-07-13  0:57 UTC (permalink / raw)
  To: Sergei Shtylyov; +Cc: arnd, linux-kernel, linux-sh

On Sat, Jul 13, 2013 at 03:51:42AM +0400, Sergei Shtylyov wrote:
> Add the driver for Gyro-ADC/speed-pulse interfaces found in Renesas R-Car SoCs.
> Though  being two separate devices, they have to be driven together because of
> the shared start/stop register (located in Gyro-ADC still). At this time, only
> speed-pulse interface is fully supported, the Gyro-ADC is just initialized and
> started/stopped synchronously with the speed-pulse interface.  A user interface
> is implemented via several sysfs files which allow to read and reset the speed-
> pulse interface's registers.

If you modify/create/remove sysfs files, you also have to document them
in Documentation/ABI/ which is missing from this patch.

Your sysfs files are also being created in a "racy" way, i.e. after
userspace is told about the device, please fix that as well.

And are you sure you want to control this through sysfs?  There's no
other better user/kernel apis for it?

thanks,

greg k-h

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH] misc: add driver for Renesas R-Car Gyro-ADC/speed-pulse interfaces
@ 2013-07-13  0:57   ` Greg KH
  0 siblings, 0 replies; 20+ messages in thread
From: Greg KH @ 2013-07-13  0:57 UTC (permalink / raw)
  To: Sergei Shtylyov; +Cc: arnd, linux-kernel, linux-sh

On Sat, Jul 13, 2013 at 03:51:42AM +0400, Sergei Shtylyov wrote:
> Add the driver for Gyro-ADC/speed-pulse interfaces found in Renesas R-Car SoCs.
> Though  being two separate devices, they have to be driven together because of
> the shared start/stop register (located in Gyro-ADC still). At this time, only
> speed-pulse interface is fully supported, the Gyro-ADC is just initialized and
> started/stopped synchronously with the speed-pulse interface.  A user interface
> is implemented via several sysfs files which allow to read and reset the speed-
> pulse interface's registers.

If you modify/create/remove sysfs files, you also have to document them
in Documentation/ABI/ which is missing from this patch.

Your sysfs files are also being created in a "racy" way, i.e. after
userspace is told about the device, please fix that as well.

And are you sure you want to control this through sysfs?  There's no
other better user/kernel apis for it?

thanks,

greg k-h

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH] misc: add driver for Renesas R-Car Gyro-ADC/speed-pulse interfaces
  2013-07-13  0:57   ` Greg KH
@ 2013-07-13  1:15     ` Sergei Shtylyov
  -1 siblings, 0 replies; 20+ messages in thread
From: Sergei Shtylyov @ 2013-07-13  1:15 UTC (permalink / raw)
  To: Greg KH; +Cc: arnd, linux-kernel, linux-sh

Hello.

    Can't get to sleep, sigh...

On 07/13/2013 04:57 AM, Greg KH wrote:

>> Add the driver for Gyro-ADC/speed-pulse interfaces found in Renesas R-Car SoCs.
>> Though  being two separate devices, they have to be driven together because of
>> the shared start/stop register (located in Gyro-ADC still). At this time, only
>> speed-pulse interface is fully supported, the Gyro-ADC is just initialized and
>> started/stopped synchronously with the speed-pulse interface.  A user interface
>> is implemented via several sysfs files which allow to read and reset the speed-
>> pulse interface's registers.

> If you modify/create/remove sysfs files, you also have to document them
> in Documentation/ABI/ which is missing from this patch.

    I've looked there and didn't find the documentation for my closest
model driver, drivers/misc/ti_dac7512.c (or for many other drivers), so 
I thought I too can do without it.

> Your sysfs files are also being created in a "racy" way, i.e. after
> userspace is told about the device, please fix that as well.

    Not sure I understand you. Could you elaborate?

> And are you sure you want to control this through sysfs?  There's no
> other better user/kernel apis for it?

    I found none, besides ioctl(), as the device driven is rather 
unique. But I thought that sysfs is "ioctl() today", so I went with it...

> thanks,

> greg k-h

WBR, Sergei


^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH] misc: add driver for Renesas R-Car Gyro-ADC/speed-pulse interfaces
@ 2013-07-13  1:15     ` Sergei Shtylyov
  0 siblings, 0 replies; 20+ messages in thread
From: Sergei Shtylyov @ 2013-07-13  1:15 UTC (permalink / raw)
  To: Greg KH; +Cc: arnd, linux-kernel, linux-sh

Hello.

    Can't get to sleep, sigh...

On 07/13/2013 04:57 AM, Greg KH wrote:

>> Add the driver for Gyro-ADC/speed-pulse interfaces found in Renesas R-Car SoCs.
>> Though  being two separate devices, they have to be driven together because of
>> the shared start/stop register (located in Gyro-ADC still). At this time, only
>> speed-pulse interface is fully supported, the Gyro-ADC is just initialized and
>> started/stopped synchronously with the speed-pulse interface.  A user interface
>> is implemented via several sysfs files which allow to read and reset the speed-
>> pulse interface's registers.

> If you modify/create/remove sysfs files, you also have to document them
> in Documentation/ABI/ which is missing from this patch.

    I've looked there and didn't find the documentation for my closest
model driver, drivers/misc/ti_dac7512.c (or for many other drivers), so 
I thought I too can do without it.

> Your sysfs files are also being created in a "racy" way, i.e. after
> userspace is told about the device, please fix that as well.

    Not sure I understand you. Could you elaborate?

> And are you sure you want to control this through sysfs?  There's no
> other better user/kernel apis for it?

    I found none, besides ioctl(), as the device driven is rather 
unique. But I thought that sysfs is "ioctl() today", so I went with it...

> thanks,

> greg k-h

WBR, Sergei


^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH] misc: add driver for Renesas R-Car Gyro-ADC/speed-pulse interfaces
  2013-07-13  1:15     ` Sergei Shtylyov
@ 2013-07-13  1:30       ` Greg KH
  -1 siblings, 0 replies; 20+ messages in thread
From: Greg KH @ 2013-07-13  1:30 UTC (permalink / raw)
  To: Sergei Shtylyov; +Cc: arnd, linux-kernel, linux-sh

On Sat, Jul 13, 2013 at 05:15:16AM +0400, Sergei Shtylyov wrote:
> Hello.
> 
>    Can't get to sleep, sigh...
> 
> On 07/13/2013 04:57 AM, Greg KH wrote:
> 
> >>Add the driver for Gyro-ADC/speed-pulse interfaces found in Renesas R-Car SoCs.
> >>Though  being two separate devices, they have to be driven together because of
> >>the shared start/stop register (located in Gyro-ADC still). At this time, only
> >>speed-pulse interface is fully supported, the Gyro-ADC is just initialized and
> >>started/stopped synchronously with the speed-pulse interface.  A user interface
> >>is implemented via several sysfs files which allow to read and reset the speed-
> >>pulse interface's registers.
> 
> >If you modify/create/remove sysfs files, you also have to document them
> >in Documentation/ABI/ which is missing from this patch.
> 
>    I've looked there and didn't find the documentation for my closest
> model driver, drivers/misc/ti_dac7512.c (or for many other drivers),
> so I thought I too can do without it.

Nope, that driver should be fixed as well, care to do so?

> >Your sysfs files are also being created in a "racy" way, i.e. after
> >userspace is told about the device, please fix that as well.
> 
>    Not sure I understand you. Could you elaborate?

Please read the driver model documentation, it goes into the details of
how to do this properly.  As does this post from me a week or so ago:
	http://kroah.com/log/blog/2013/06/26/how-to-create-a-sysfs-file-correctly/

greg k-h

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH] misc: add driver for Renesas R-Car Gyro-ADC/speed-pulse interfaces
@ 2013-07-13  1:30       ` Greg KH
  0 siblings, 0 replies; 20+ messages in thread
From: Greg KH @ 2013-07-13  1:30 UTC (permalink / raw)
  To: Sergei Shtylyov; +Cc: arnd, linux-kernel, linux-sh

On Sat, Jul 13, 2013 at 05:15:16AM +0400, Sergei Shtylyov wrote:
> Hello.
> 
>    Can't get to sleep, sigh...
> 
> On 07/13/2013 04:57 AM, Greg KH wrote:
> 
> >>Add the driver for Gyro-ADC/speed-pulse interfaces found in Renesas R-Car SoCs.
> >>Though  being two separate devices, they have to be driven together because of
> >>the shared start/stop register (located in Gyro-ADC still). At this time, only
> >>speed-pulse interface is fully supported, the Gyro-ADC is just initialized and
> >>started/stopped synchronously with the speed-pulse interface.  A user interface
> >>is implemented via several sysfs files which allow to read and reset the speed-
> >>pulse interface's registers.
> 
> >If you modify/create/remove sysfs files, you also have to document them
> >in Documentation/ABI/ which is missing from this patch.
> 
>    I've looked there and didn't find the documentation for my closest
> model driver, drivers/misc/ti_dac7512.c (or for many other drivers),
> so I thought I too can do without it.

Nope, that driver should be fixed as well, care to do so?

> >Your sysfs files are also being created in a "racy" way, i.e. after
> >userspace is told about the device, please fix that as well.
> 
>    Not sure I understand you. Could you elaborate?

Please read the driver model documentation, it goes into the details of
how to do this properly.  As does this post from me a week or so ago:
	http://kroah.com/log/blog/2013/06/26/how-to-create-a-sysfs-file-correctly/

greg k-h

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH] misc: add driver for Renesas R-Car Gyro-ADC/speed-pulse interfaces
  2013-07-13  1:15     ` Sergei Shtylyov
@ 2013-07-13  7:58       ` Arnd Bergmann
  -1 siblings, 0 replies; 20+ messages in thread
From: Arnd Bergmann @ 2013-07-13  7:58 UTC (permalink / raw)
  To: Sergei Shtylyov; +Cc: Greg KH, linux-kernel, linux-sh

On Saturday 13 July 2013, Sergei Shtylyov wrote:
> > And are you sure you want to control this through sysfs?  There's no
> > other better user/kernel apis for it?
> 
>     I found none, besides ioctl(), as the device driven is rather 
> unique. But I thought that sysfs is "ioctl() today", so I went with it...
> 

It does sound like it would fit better into IIO than just a misc driver,
even if it's the only hardware of its kind.

	Arnd

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH] misc: add driver for Renesas R-Car Gyro-ADC/speed-pulse interfaces
@ 2013-07-13  7:58       ` Arnd Bergmann
  0 siblings, 0 replies; 20+ messages in thread
From: Arnd Bergmann @ 2013-07-13  7:58 UTC (permalink / raw)
  To: Sergei Shtylyov; +Cc: Greg KH, linux-kernel, linux-sh

On Saturday 13 July 2013, Sergei Shtylyov wrote:
> > And are you sure you want to control this through sysfs?  There's no
> > other better user/kernel apis for it?
> 
>     I found none, besides ioctl(), as the device driven is rather 
> unique. But I thought that sysfs is "ioctl() today", so I went with it...
> 

It does sound like it would fit better into IIO than just a misc driver,
even if it's the only hardware of its kind.

	Arnd

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH] misc: add driver for Renesas R-Car Gyro-ADC/speed-pulse interfaces
  2013-07-13  7:58       ` Arnd Bergmann
@ 2013-07-13 22:26         ` Sergei Shtylyov
  -1 siblings, 0 replies; 20+ messages in thread
From: Sergei Shtylyov @ 2013-07-13 22:26 UTC (permalink / raw)
  To: Arnd Bergmann; +Cc: Greg KH, linux-kernel, linux-sh

Hello.

On 07/13/2013 11:58 AM, Arnd Bergmann wrote:

>>> And are you sure you want to control this through sysfs?  There's no
>>> other better user/kernel apis for it?

>>      I found none, besides ioctl(), as the device driven is rather
>> unique. But I thought that sysfs is "ioctl() today", so I went with it...

> It does sound like it would fit better into IIO than just a misc driver,
> even if it's the only hardware of its kind.

    I got somewhat familiarized myself with drivers/iio/ infrastructure 
and I have found a place only the for ADC device in which the customer 
currently has no interest.
    The other trouble is that I'll have to backport this driver to 3.4 
which doesn't contain the IIO infrastructure at all. :-(

> 	Arnd

WBR, Sergei



^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH] misc: add driver for Renesas R-Car Gyro-ADC/speed-pulse interfaces
@ 2013-07-13 22:26         ` Sergei Shtylyov
  0 siblings, 0 replies; 20+ messages in thread
From: Sergei Shtylyov @ 2013-07-13 22:26 UTC (permalink / raw)
  To: Arnd Bergmann; +Cc: Greg KH, linux-kernel, linux-sh

Hello.

On 07/13/2013 11:58 AM, Arnd Bergmann wrote:

>>> And are you sure you want to control this through sysfs?  There's no
>>> other better user/kernel apis for it?

>>      I found none, besides ioctl(), as the device driven is rather
>> unique. But I thought that sysfs is "ioctl() today", so I went with it...

> It does sound like it would fit better into IIO than just a misc driver,
> even if it's the only hardware of its kind.

    I got somewhat familiarized myself with drivers/iio/ infrastructure 
and I have found a place only the for ADC device in which the customer 
currently has no interest.
    The other trouble is that I'll have to backport this driver to 3.4 
which doesn't contain the IIO infrastructure at all. :-(

> 	Arnd

WBR, Sergei



^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH] misc: add driver for Renesas R-Car Gyro-ADC/speed-pulse interfaces
  2013-07-13  1:30       ` Greg KH
@ 2013-07-13 22:44         ` Sergei Shtylyov
  -1 siblings, 0 replies; 20+ messages in thread
From: Sergei Shtylyov @ 2013-07-13 22:44 UTC (permalink / raw)
  To: Greg KH; +Cc: arnd, linux-kernel, linux-sh, daniel

Hello.

On 07/13/2013 05:30 AM, Greg KH wrote:

>>>> Add the driver for Gyro-ADC/speed-pulse interfaces found in Renesas R-Car SoCs.
>>>> Though  being two separate devices, they have to be driven together because of
>>>> the shared start/stop register (located in Gyro-ADC still). At this time, only
>>>> speed-pulse interface is fully supported, the Gyro-ADC is just initialized and
>>>> started/stopped synchronously with the speed-pulse interface.  A user interface
>>>> is implemented via several sysfs files which allow to read and reset the speed-
>>>> pulse interface's registers.

>>> If you modify/create/remove sysfs files, you also have to document them
>>> in Documentation/ABI/ which is missing from this patch.

>>     I've looked there and didn't find the documentation for my closest
>> model driver, drivers/misc/ti_dac7512.c (or for many other drivers),
>> so I thought I too can do without it.

> Nope, that driver should be fixed as well, care to do so?

    Sorry, I don't. The driver has an author, which I'm CCing.

>>> Your sysfs files are also being created in a "racy" way, i.e. after
>>> userspace is told about the device, please fix that as well.

>>     Not sure I understand you. Could you elaborate?

> Please read the driver model documentation, it goes into the details of
> how to do this properly.  As does this post from me a week or so ago:
> 	http://kroah.com/log/blog/2013/06/26/how-to-create-a-sysfs-file-correctly/

    Thank you. Probably a good read for ti_dac7512 driver too.

> greg k-h

WBR, Sergei


^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH] misc: add driver for Renesas R-Car Gyro-ADC/speed-pulse interfaces
@ 2013-07-13 22:44         ` Sergei Shtylyov
  0 siblings, 0 replies; 20+ messages in thread
From: Sergei Shtylyov @ 2013-07-13 22:44 UTC (permalink / raw)
  To: Greg KH; +Cc: arnd, linux-kernel, linux-sh, daniel

Hello.

On 07/13/2013 05:30 AM, Greg KH wrote:

>>>> Add the driver for Gyro-ADC/speed-pulse interfaces found in Renesas R-Car SoCs.
>>>> Though  being two separate devices, they have to be driven together because of
>>>> the shared start/stop register (located in Gyro-ADC still). At this time, only
>>>> speed-pulse interface is fully supported, the Gyro-ADC is just initialized and
>>>> started/stopped synchronously with the speed-pulse interface.  A user interface
>>>> is implemented via several sysfs files which allow to read and reset the speed-
>>>> pulse interface's registers.

>>> If you modify/create/remove sysfs files, you also have to document them
>>> in Documentation/ABI/ which is missing from this patch.

>>     I've looked there and didn't find the documentation for my closest
>> model driver, drivers/misc/ti_dac7512.c (or for many other drivers),
>> so I thought I too can do without it.

> Nope, that driver should be fixed as well, care to do so?

    Sorry, I don't. The driver has an author, which I'm CCing.

>>> Your sysfs files are also being created in a "racy" way, i.e. after
>>> userspace is told about the device, please fix that as well.

>>     Not sure I understand you. Could you elaborate?

> Please read the driver model documentation, it goes into the details of
> how to do this properly.  As does this post from me a week or so ago:
> 	http://kroah.com/log/blog/2013/06/26/how-to-create-a-sysfs-file-correctly/

    Thank you. Probably a good read for ti_dac7512 driver too.

> greg k-h

WBR, Sergei


^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH] misc: add driver for Renesas R-Car Gyro-ADC/speed-pulse interfaces
  2013-07-13 22:26         ` Sergei Shtylyov
@ 2013-07-13 23:17           ` Greg KH
  -1 siblings, 0 replies; 20+ messages in thread
From: Greg KH @ 2013-07-13 23:17 UTC (permalink / raw)
  To: Sergei Shtylyov; +Cc: Arnd Bergmann, linux-kernel, linux-sh

On Sun, Jul 14, 2013 at 02:26:14AM +0400, Sergei Shtylyov wrote:
>    The other trouble is that I'll have to backport this driver to
> 3.4 which doesn't contain the IIO infrastructure at all. :-(

That doesn't matter to us, we can't accept a driver that should be using
the iio subsystem, but isn't.  So please port it to use that.

thanks,

greg k-h

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH] misc: add driver for Renesas R-Car Gyro-ADC/speed-pulse interfaces
@ 2013-07-13 23:17           ` Greg KH
  0 siblings, 0 replies; 20+ messages in thread
From: Greg KH @ 2013-07-13 23:17 UTC (permalink / raw)
  To: Sergei Shtylyov; +Cc: Arnd Bergmann, linux-kernel, linux-sh

On Sun, Jul 14, 2013 at 02:26:14AM +0400, Sergei Shtylyov wrote:
>    The other trouble is that I'll have to backport this driver to
> 3.4 which doesn't contain the IIO infrastructure at all. :-(

That doesn't matter to us, we can't accept a driver that should be using
the iio subsystem, but isn't.  So please port it to use that.

thanks,

greg k-h

^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH] misc: add driver for Renesas R-Car Gyro-ADC/speed-pulse interfaces
  2013-07-13 22:26         ` Sergei Shtylyov
@ 2013-07-14  8:12           ` Lars-Peter Clausen
  -1 siblings, 0 replies; 20+ messages in thread
From: Lars-Peter Clausen @ 2013-07-14  8:12 UTC (permalink / raw)
  To: Sergei Shtylyov; +Cc: Arnd Bergmann, Greg KH, linux-kernel, linux-sh

On 07/14/2013 12:26 AM, Sergei Shtylyov wrote:
> Hello.
> 
> On 07/13/2013 11:58 AM, Arnd Bergmann wrote:
> 
>>>> And are you sure you want to control this through sysfs?  There's no
>>>> other better user/kernel apis for it?
> 
>>>      I found none, besides ioctl(), as the device driven is rather
>>> unique. But I thought that sysfs is "ioctl() today", so I went with it...
> 
>> It does sound like it would fit better into IIO than just a misc driver,
>> even if it's the only hardware of its kind.
> 
>    I got somewhat familiarized myself with drivers/iio/ infrastructure and I
> have found a place only the for ADC device in which the customer currently
> has no interest.
>    The other trouble is that I'll have to backport this driver to 3.4 which
> doesn't contain the IIO infrastructure at all. :-(

It has, it's just still in staging in 3.4. But the API (except for minor
modifications) and more importantly the ABI are the same.

There is a angular velocity channel type in IIO. maybe that could be used to
report the Speed-Pulse-ADC values.

- Lars


^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH] misc: add driver for Renesas R-Car Gyro-ADC/speed-pulse interfaces
@ 2013-07-14  8:12           ` Lars-Peter Clausen
  0 siblings, 0 replies; 20+ messages in thread
From: Lars-Peter Clausen @ 2013-07-14  8:12 UTC (permalink / raw)
  To: Sergei Shtylyov; +Cc: Arnd Bergmann, Greg KH, linux-kernel, linux-sh

On 07/14/2013 12:26 AM, Sergei Shtylyov wrote:
> Hello.
> 
> On 07/13/2013 11:58 AM, Arnd Bergmann wrote:
> 
>>>> And are you sure you want to control this through sysfs?  There's no
>>>> other better user/kernel apis for it?
> 
>>>      I found none, besides ioctl(), as the device driven is rather
>>> unique. But I thought that sysfs is "ioctl() today", so I went with it...
> 
>> It does sound like it would fit better into IIO than just a misc driver,
>> even if it's the only hardware of its kind.
> 
>    I got somewhat familiarized myself with drivers/iio/ infrastructure and I
> have found a place only the for ADC device in which the customer currently
> has no interest.
>    The other trouble is that I'll have to backport this driver to 3.4 which
> doesn't contain the IIO infrastructure at all. :-(

It has, it's just still in staging in 3.4. But the API (except for minor
modifications) and more importantly the ABI are the same.

There is a angular velocity channel type in IIO. maybe that could be used to
report the Speed-Pulse-ADC values.

- Lars


^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH] misc: add driver for Renesas R-Car Gyro-ADC/speed-pulse interfaces
  2013-07-14  8:12           ` Lars-Peter Clausen
@ 2013-07-14 19:57             ` Sergei Shtylyov
  -1 siblings, 0 replies; 20+ messages in thread
From: Sergei Shtylyov @ 2013-07-14 19:57 UTC (permalink / raw)
  To: Lars-Peter Clausen; +Cc: Arnd Bergmann, Greg KH, linux-kernel, linux-sh

Hello.

On 07/14/2013 12:12 PM, Lars-Peter Clausen wrote:

>>>>> And are you sure you want to control this through sysfs?  There's no
>>>>> other better user/kernel apis for it?

>>>>       I found none, besides ioctl(), as the device driven is rather
>>>> unique. But I thought that sysfs is "ioctl() today", so I went with it...

>>> It does sound like it would fit better into IIO than just a misc driver,
>>> even if it's the only hardware of its kind.

>>     I got somewhat familiarized myself with drivers/iio/ infrastructure and I
>> have found a place only the for ADC device in which the customer currently
>> has no interest.
>>     The other trouble is that I'll have to backport this driver to 3.4 which
>> doesn't contain the IIO infrastructure at all. :-(

> It has, it's just still in staging in 3.4. But the API (except for minor
> modifications) and more importantly the ABI are the same.

    Thank you for the useful information. I wouldn't probably have 
figured it out to search there.

> There is a angular velocity channel type in IIO. maybe that could be used to
> report the Speed-Pulse-ADC values.

    You probably misunderstood from my terse description. Multichannel 
ADC interface is separate from the speed-pulse interface which has on 
its single input digital PWM signal of varying frequency. Speed pulse 
i/f measures pulse count and period. I've found no adequate channel type 
in IIO infrastructure so far. I'll mail the IIO maintainers with a 
request for help probably...

> - Lars

WBR, Sergei


^ permalink raw reply	[flat|nested] 20+ messages in thread

* Re: [PATCH] misc: add driver for Renesas R-Car Gyro-ADC/speed-pulse interfaces
@ 2013-07-14 19:57             ` Sergei Shtylyov
  0 siblings, 0 replies; 20+ messages in thread
From: Sergei Shtylyov @ 2013-07-14 19:57 UTC (permalink / raw)
  To: Lars-Peter Clausen; +Cc: Arnd Bergmann, Greg KH, linux-kernel, linux-sh

Hello.

On 07/14/2013 12:12 PM, Lars-Peter Clausen wrote:

>>>>> And are you sure you want to control this through sysfs?  There's no
>>>>> other better user/kernel apis for it?

>>>>       I found none, besides ioctl(), as the device driven is rather
>>>> unique. But I thought that sysfs is "ioctl() today", so I went with it...

>>> It does sound like it would fit better into IIO than just a misc driver,
>>> even if it's the only hardware of its kind.

>>     I got somewhat familiarized myself with drivers/iio/ infrastructure and I
>> have found a place only the for ADC device in which the customer currently
>> has no interest.
>>     The other trouble is that I'll have to backport this driver to 3.4 which
>> doesn't contain the IIO infrastructure at all. :-(

> It has, it's just still in staging in 3.4. But the API (except for minor
> modifications) and more importantly the ABI are the same.

    Thank you for the useful information. I wouldn't probably have 
figured it out to search there.

> There is a angular velocity channel type in IIO. maybe that could be used to
> report the Speed-Pulse-ADC values.

    You probably misunderstood from my terse description. Multichannel 
ADC interface is separate from the speed-pulse interface which has on 
its single input digital PWM signal of varying frequency. Speed pulse 
i/f measures pulse count and period. I've found no adequate channel type 
in IIO infrastructure so far. I'll mail the IIO maintainers with a 
request for help probably...

> - Lars

WBR, Sergei


^ permalink raw reply	[flat|nested] 20+ messages in thread

end of thread, other threads:[~2013-07-14 19:57 UTC | newest]

Thread overview: 20+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-07-12 23:51 [PATCH] misc: add driver for Renesas R-Car Gyro-ADC/speed-pulse interfaces Sergei Shtylyov
2013-07-12 23:51 ` Sergei Shtylyov
2013-07-13  0:57 ` Greg KH
2013-07-13  0:57   ` Greg KH
2013-07-13  1:15   ` Sergei Shtylyov
2013-07-13  1:15     ` Sergei Shtylyov
2013-07-13  1:30     ` Greg KH
2013-07-13  1:30       ` Greg KH
2013-07-13 22:44       ` Sergei Shtylyov
2013-07-13 22:44         ` Sergei Shtylyov
2013-07-13  7:58     ` Arnd Bergmann
2013-07-13  7:58       ` Arnd Bergmann
2013-07-13 22:26       ` Sergei Shtylyov
2013-07-13 22:26         ` Sergei Shtylyov
2013-07-13 23:17         ` Greg KH
2013-07-13 23:17           ` Greg KH
2013-07-14  8:12         ` Lars-Peter Clausen
2013-07-14  8:12           ` Lars-Peter Clausen
2013-07-14 19:57           ` Sergei Shtylyov
2013-07-14 19:57             ` Sergei Shtylyov

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.