All of lore.kernel.org
 help / color / mirror / Atom feed
* [RESEND][PATCH 0/5] Support for the TS-5500 board
@ 2011-07-28 21:10 Vivien Didelot
  2011-07-28 21:10 ` [RESEND][PATCH 1/5] x86: base support for TS-5500 Single Board Computer Vivien Didelot
                   ` (5 more replies)
  0 siblings, 6 replies; 15+ messages in thread
From: Vivien Didelot @ 2011-07-28 21:10 UTC (permalink / raw)
  To: linux-kernel; +Cc: Vivien Didelot, mjg, platform-driver-x86

This set of patches brings the support for the Technologic Systems TS-5500
Single Board Computer.

The first patch adds the base for the support of the board in
/arch/x86/platform/ts5500 and a documentation file in
Documentation/ABI/testing/sysfs-platform-ts5500.

The second patch adds support for GPIO.

The third patch adds support for the on-board LED.

The fourth patch brings support for the Analogic/Digital converter.

The fifth patch moves the already existing support for the Flash MTD into the
/arch/x86/platform/ts5500 directory.

Jerome Oufella (1):
  gpio: add support for TS-5500 GPIO

Jonas Fonseca (2):
  leds: add support for TS-5500 LED
  adc: add support for TS-5500 ADC

Vivien Didelot (2):
  x86: base support for TS-5500 Single Board Computer
  mtd: move support for TS-5500 MTD

 Documentation/ABI/testing/sysfs-platform-ts5500 |   46 +++
 MAINTAINERS                                     |   13 +
 arch/x86/Kconfig                                |    2 +
 arch/x86/platform/Makefile                      |    1 +
 arch/x86/platform/ts5500/Kconfig                |   47 +++
 arch/x86/platform/ts5500/Makefile               |    5 +
 arch/x86/platform/ts5500/ts5500.c               |  440 +++++++++++++++++++++++
 arch/x86/platform/ts5500/ts5500_adc.c           |  326 +++++++++++++++++
 arch/x86/platform/ts5500/ts5500_adc.h           |   62 ++++
 arch/x86/platform/ts5500/ts5500_flash.c         |  118 ++++++
 arch/x86/platform/ts5500/ts5500_gpio.c          |  421 ++++++++++++++++++++++
 arch/x86/platform/ts5500/ts5500_gpio.h          |   60 +++
 arch/x86/platform/ts5500/ts5500_leds.c          |  133 +++++++
 drivers/mtd/maps/Kconfig                        |   18 -
 drivers/mtd/maps/Makefile                       |    1 -
 drivers/mtd/maps/ts5500_flash.c                 |  121 -------
 16 files changed, 1674 insertions(+), 140 deletions(-)
 create mode 100644 Documentation/ABI/testing/sysfs-platform-ts5500
 create mode 100644 arch/x86/platform/ts5500/Kconfig
 create mode 100644 arch/x86/platform/ts5500/Makefile
 create mode 100644 arch/x86/platform/ts5500/ts5500.c
 create mode 100644 arch/x86/platform/ts5500/ts5500_adc.c
 create mode 100644 arch/x86/platform/ts5500/ts5500_adc.h
 create mode 100644 arch/x86/platform/ts5500/ts5500_flash.c
 create mode 100644 arch/x86/platform/ts5500/ts5500_gpio.c
 create mode 100644 arch/x86/platform/ts5500/ts5500_gpio.h
 create mode 100644 arch/x86/platform/ts5500/ts5500_leds.c
 delete mode 100644 drivers/mtd/maps/ts5500_flash.c

-- 
1.7.6


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

* [RESEND][PATCH 1/5] x86: base support for TS-5500 Single Board Computer
  2011-07-28 21:10 [RESEND][PATCH 0/5] Support for the TS-5500 board Vivien Didelot
@ 2011-07-28 21:10 ` Vivien Didelot
  2011-07-28 21:10 ` [RESEND][PATCH 2/5] gpio: add support for TS-5500 GPIO Vivien Didelot
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 15+ messages in thread
From: Vivien Didelot @ 2011-07-28 21:10 UTC (permalink / raw)
  To: linux-kernel; +Cc: Vivien Didelot, mjg, platform-driver-x86

Add base support for TS-5500 in arch/x86/platform/ts5500 and documentation in
Documentation/ABI/testing/sysfs-platform-ts5500.

Signed-off-by: Vivien Didelot <vivien.didelot@savoirfairelinux.com>
---
 Documentation/ABI/testing/sysfs-platform-ts5500 |   46 ++++
 MAINTAINERS                                     |    7 +
 arch/x86/Kconfig                                |    2 +
 arch/x86/platform/Makefile                      |    1 +
 arch/x86/platform/ts5500/Kconfig                |    7 +
 arch/x86/platform/ts5500/Makefile               |    1 +
 arch/x86/platform/ts5500/ts5500.c               |  296 +++++++++++++++++++++++
 7 files changed, 360 insertions(+), 0 deletions(-)
 create mode 100644 Documentation/ABI/testing/sysfs-platform-ts5500
 create mode 100644 arch/x86/platform/ts5500/Kconfig
 create mode 100644 arch/x86/platform/ts5500/Makefile
 create mode 100644 arch/x86/platform/ts5500/ts5500.c

diff --git a/Documentation/ABI/testing/sysfs-platform-ts5500 b/Documentation/ABI/testing/sysfs-platform-ts5500
new file mode 100644
index 0000000..c870564
--- /dev/null
+++ b/Documentation/ABI/testing/sysfs-platform-ts5500
@@ -0,0 +1,46 @@
+What:		/sys/devices/platform/ts5500/id
+Date:		July 2011
+KernelVersion:	2.6.39
+Contact:	"Savoir-faire Linux, Inc." <kernel-ts@savoirfairelinux.com>
+Description:
+		Product ID of the TS board. TS-5500 ID is 0x60.
+
+What:		/sys/devices/platform/ts5500/sram
+Date:		July 2011
+KernelVersion:	2.6.39
+Contact:	"Savoir-faire Linux, Inc." <kernel-ts@savoirfairelinux.com>
+Description:
+		Say if the SRAM feature is present. If it is enabled, it will
+		display "1", otherwise "0".
+
+What:		/sys/devices/platform/ts5500/ereset
+Date:		July 2011
+KernelVersion:	2.6.39
+Contact:	"Savoir-faire Linux, Inc." <kernel-ts@savoirfairelinux.com>
+Description:
+		Say if an external reset is present. If it is present, it will
+		display "1", otherwise "0".
+
+What:		/sys/devices/platform/ts5500/jp{1,2,3,4,5,6}
+Date:		July 2011
+KernelVersion:	2.6.39
+Contact:	"Savoir-faire Linux, Inc." <kernel-ts@savoirfairelinux.com>
+Description:
+		Show the state of a plugged jumper. If it is present, it will
+		display "1", otherwise "0".
+
+What:		/sys/devices/platform/ts5500/adc
+Date:		July 2011
+KernelVersion:	2.6.39
+Contact:	"Savoir-faire Linux, Inc." <kernel-ts@savoirfairelinux.com>
+Description:
+		Say if the Analogic to Digital Converter is present. If it is
+		enabled, it will display "1", otherwise "0".
+
+What:		/sys/devices/platform/ts5500/rs485
+Date:		July 2011
+KernelVersion:	2.6.39
+Contact:	"Savoir-faire Linux, Inc." <kernel-ts@savoirfairelinux.com>
+Description:
+		Say if the RS485 feature is present. If it is enabled, it
+		will display "1", otherwise "0".
\ No newline at end of file
diff --git a/MAINTAINERS b/MAINTAINERS
index 187282d..be8ce4b 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -6134,6 +6134,13 @@ W:	http://tcp-lp-mod.sourceforge.net/
 S:	Maintained
 F:	net/ipv4/tcp_lp.c
 
+TECHNOLOGIC SYSTEMS TS5500 MACHINE SUPPORT
+M:	Savoir-faire Linux Inc. <ts-kernel@savoirfairelinux.com>
+S:	Maintained
+F:  arch/x86/platform/ts5500/Kconfig
+F:  arch/x86/platform/ts5500/Makefile
+F:  arch/x86/platform/ts5500/ts5500.c
+
 TEGRA SUPPORT
 M:	Colin Cross <ccross@android.com>
 M:	Erik Gilling <konkers@android.com>
diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
index da34972..cd4bf1a 100644
--- a/arch/x86/Kconfig
+++ b/arch/x86/Kconfig
@@ -2079,6 +2079,8 @@ config OLPC_XO1
 	---help---
 	  Add support for non-essential features of the OLPC XO-1 laptop.
 
+source "arch/x86/platform/ts5500/Kconfig"
+
 endif # X86_32
 
 config AMD_NB
diff --git a/arch/x86/platform/Makefile b/arch/x86/platform/Makefile
index 021eee9..1bdc038 100644
--- a/arch/x86/platform/Makefile
+++ b/arch/x86/platform/Makefile
@@ -8,3 +8,4 @@ obj-y	+= scx200/
 obj-y	+= sfi/
 obj-y	+= visws/
 obj-y	+= uv/
+obj-y	+= ts5500/
diff --git a/arch/x86/platform/ts5500/Kconfig b/arch/x86/platform/ts5500/Kconfig
new file mode 100644
index 0000000..6428ca5
--- /dev/null
+++ b/arch/x86/platform/ts5500/Kconfig
@@ -0,0 +1,7 @@
+config TS5500
+	bool "Technologic Systems TS-5500 Single Board Computer support"
+	depends on MELAN
+	help
+	  Add support for the Technologic Systems TS-5500 platform features.
+
+	  If you have a TS-5500, say Y here.
diff --git a/arch/x86/platform/ts5500/Makefile b/arch/x86/platform/ts5500/Makefile
new file mode 100644
index 0000000..0a689a7
--- /dev/null
+++ b/arch/x86/platform/ts5500/Makefile
@@ -0,0 +1 @@
+obj-$(CONFIG_TS5500)			+= ts5500.o
diff --git a/arch/x86/platform/ts5500/ts5500.c b/arch/x86/platform/ts5500/ts5500.c
new file mode 100644
index 0000000..0135dbd
--- /dev/null
+++ b/arch/x86/platform/ts5500/ts5500.c
@@ -0,0 +1,296 @@
+/*
+ * Technologic Systems TS-5500 board - SBC info layer
+ *
+ * Copyright (c) 2010-2011 Savoir-faire Linux Inc.
+ *	Alexandre Savard <alexandre.savard@savoirfairelinux.com>
+ *	Jonas Fonseca <jonas.fonseca@savoirfairelinux.com>
+ *	Vivien Didelot <vivien.didelot@savoirfairelinux.com>
+ *
+ * Portions originate from ts_sbcinfo.c (c) Technologic Systems
+ *	Liberty Young <liberty@embeddedx86.com>
+ *
+ * These functions add sysfs platform entries to display information about
+ * the Technologic Systems TS-5500 Single Board Computer (SBC).
+ *
+ * For further information about sysfs entries, see
+ * Documentation/ABI/testing/sysfs-platform-ts5500
+ */
+
+#include <linux/module.h>
+#include <linux/ioport.h>
+#include <linux/platform_device.h>
+#include <linux/kernel.h>
+#include <linux/mutex.h>
+#include <linux/io.h>
+#include <linux/slab.h>
+#include <asm/processor.h>
+
+/* Hardware info for pre-detection */
+#define AMD_ELAN_FAMILY			4
+#define AMD_ELAN_SC520			9
+
+/* Product code register */
+#define TS5500_PRODUCT_CODE_REG		0x74
+#define TS5500_PRODUCT_CODE		0x60	/* TS-5500 product code */
+
+/* SRAM/RS-485/ADC options, and RS-485 RTS/Automatic RS-485 flags register */
+#define TS5500_SRAM_RS485_ADC_REG	0x75
+#define TS5500_SRAM_OPT			0x01	/* SRAM option */
+#define TS5500_RS485_OPT		0x02	/* RS-485 option */
+#define TS5500_ADC_OPT			0x04	/* A/D converter option */
+#define TS5500_RS485_RTS_FLAG		0x40	/* RTS for RS-485 */
+#define TS5500_RS485_AUTO_FLAG		0x80	/* Automatic RS-485 */
+
+/* External Reset/Industrial Temperature Range options register */
+#define TS5500_ERESET_ITR_REG		0x76
+#define TS5500_ERESET_OPT		0x01	/*  External Reset option */
+#define TS5500_ITR_OPT			0x02	/* Indust. Temp. Range option */
+
+/* LED/Jumpers register */
+#define TS5500_LED_JMPRS_REG		0x77
+#define TS5500_LED_FLAG			0x01	/* LED flag */
+#define TS5500_JP1			0x02	/* Automatic CMOS */
+#define TS5500_JP2			0x04	/* Enable Serial Console */
+#define TS5500_JP3			0x08	/* Write Enable Drive A */
+#define TS5500_JP4			0x10	/* Fast Console (115K baud) */
+#define TS5500_JP5			0x20	/* User Jumper */
+#define TS5500_JP6			0x40	/* Console on COM1 (req. JP2) */
+#define TS5500_JP7			0x80	/* Undocumented (Unused) */
+
+/**
+ * struct ts5500_sbc - TS-5500 SBC main structure
+ * @lock:		Read/Write mutex.
+ * @board_id:		Board name.
+ * @sram:		Check SRAM option.
+ * @rs485:		Check RS-485 option.
+ * @adc:		Check Analogic/Digital converter option.
+ * @ereset:		Check External Reset option.
+ * @itr:		Check Industrial Temperature Range option.
+ * @jumpers:		States of jumpers 1-7.
+ */
+struct ts5500_sbc {
+	struct mutex		lock;
+	int			board_id;
+	bool			sram;
+	bool			rs485;
+	bool			adc;
+	bool			ereset;
+	bool			itr;
+	u8			jumpers;
+};
+
+/* Current platform */
+struct ts5500_sbc *ts5500;
+
+/**
+ * ts5500_pre_detect() - check for TS-5500 specific features
+ *
+ * It is not safe to read ID register if we are not sure that it's a TS SBC.
+ * Since TS SBCs don't have DMI support, it is safer to check for a TS-5500
+ * specific feature such as the processor.
+ */
+static int ts5500_pre_detect(void)
+{
+	/* Check for AMD ElanSC520 Microcontroller */
+	if (!(cpu_info.x86_vendor == X86_VENDOR_AMD &&
+	      cpu_info.x86 == AMD_ELAN_FAMILY &&
+	      cpu_info.x86_model == AMD_ELAN_SC520))
+		return -ENODEV;
+
+	return 0;
+}
+
+/**
+ * ts5500_detect_config() - detect the TS board
+ * @sbc:		Structure where to store the detected board's details.
+ */
+static int ts5500_detect_config(struct ts5500_sbc *sbc)
+{
+	u8 tmp;
+	int ret = 0;
+
+	if (!request_region(TS5500_PRODUCT_CODE_REG, 4, "ts5500"))
+		return -EBUSY;
+
+	mutex_lock(&ts5500->lock);
+	tmp = inb(TS5500_PRODUCT_CODE_REG);
+	if (tmp != TS5500_PRODUCT_CODE) {
+		pr_err("This platform is not a TS-5500 (found ID 0x%x)\n", tmp);
+		ret = -ENODEV;
+		goto error;
+	}
+	sbc->board_id = tmp;
+
+	tmp = inb(TS5500_SRAM_RS485_ADC_REG);
+	ts5500->sram = !!(tmp & TS5500_SRAM_OPT);
+	ts5500->rs485 = !!(tmp & TS5500_RS485_OPT);
+	ts5500->adc = !!(tmp & TS5500_ADC_OPT);
+
+	tmp = inb(TS5500_ERESET_ITR_REG);
+	ts5500->ereset = !!(tmp & TS5500_ERESET_OPT);
+	ts5500->itr = !!(tmp & TS5500_ITR_OPT);
+
+	tmp = inb(TS5500_LED_JMPRS_REG);
+	sbc->jumpers = tmp & 0xFE;	/* All bits except the first (LED) */
+
+error:
+	mutex_unlock(&ts5500->lock);
+	release_region(TS5500_PRODUCT_CODE_REG, 4);
+	return ret;
+}
+
+#define TS5500_IS_JP_SET(sbc, jmp) (!!(sbc->jumpers & TS5500_JP##jmp))
+
+static struct platform_device *ts5500_devices[] __initdata = {
+};
+
+static ssize_t ts5500_show_id(struct device *dev,
+			      struct device_attribute *attr, char *buf)
+{
+	struct ts5500_sbc *sbc = dev_get_drvdata(dev);
+
+	return sprintf(buf, "0x%x\n", sbc->board_id);
+}
+
+static ssize_t ts5500_show_sram(struct device *dev,
+				struct device_attribute *attr, char *buf)
+{
+	struct ts5500_sbc *sbc = dev_get_drvdata(dev);
+
+	return sprintf(buf, "%d\n", sbc->sram);
+}
+
+static ssize_t ts5500_show_rs485(struct device *dev,
+				 struct device_attribute *attr, char *buf)
+{
+	struct ts5500_sbc *sbc = dev_get_drvdata(dev);
+
+	return sprintf(buf, "%d\n", sbc->rs485);
+}
+
+static ssize_t ts5500_show_adc(struct device *dev,
+			       struct device_attribute *attr, char *buf)
+{
+	struct ts5500_sbc *sbc = dev_get_drvdata(dev);
+
+	return sprintf(buf, "%d\n", sbc->adc);
+}
+
+static ssize_t ts5500_show_ereset(struct device *dev,
+					  struct device_attribute *attr,
+					  char *buf)
+{
+	struct ts5500_sbc *sbc = dev_get_drvdata(dev);
+
+	return sprintf(buf, "%d\n", sbc->ereset);
+}
+
+static ssize_t ts5500_show_itr(struct device *dev,
+			       struct device_attribute *attr,
+			       char *buf)
+{
+	struct ts5500_sbc *sbc = dev_get_drvdata(dev);
+
+	return sprintf(buf, "%d\n", sbc->itr);
+}
+
+#define TS5500_SHOW_JP(jp)						\
+	static ssize_t ts5500_show_jp##jp(struct device *dev,		\
+					  struct device_attribute *attr,\
+					  char *buf)			\
+	{								\
+		struct ts5500_sbc *sbc = dev_get_drvdata(dev);		\
+		return sprintf(buf, "%d\n", TS5500_IS_JP_SET(sbc, jp)); \
+	}
+
+TS5500_SHOW_JP(1)
+TS5500_SHOW_JP(2)
+TS5500_SHOW_JP(3)
+TS5500_SHOW_JP(4)
+TS5500_SHOW_JP(5)
+TS5500_SHOW_JP(6)
+
+static DEVICE_ATTR(id, S_IRUGO, ts5500_show_id, NULL);
+static DEVICE_ATTR(sram, S_IRUGO, ts5500_show_sram, NULL);
+static DEVICE_ATTR(rs485, S_IRUGO, ts5500_show_rs485, NULL);
+static DEVICE_ATTR(adc, S_IRUGO, ts5500_show_adc, NULL);
+static DEVICE_ATTR(ereset, S_IRUGO, ts5500_show_ereset, NULL);
+static DEVICE_ATTR(itr, S_IRUGO, ts5500_show_itr, NULL);
+static DEVICE_ATTR(jp1, S_IRUGO, ts5500_show_jp1, NULL);
+static DEVICE_ATTR(jp2, S_IRUGO, ts5500_show_jp2, NULL);
+static DEVICE_ATTR(jp3, S_IRUGO, ts5500_show_jp3, NULL);
+static DEVICE_ATTR(jp4, S_IRUGO, ts5500_show_jp4, NULL);
+static DEVICE_ATTR(jp5, S_IRUGO, ts5500_show_jp5, NULL);
+static DEVICE_ATTR(jp6, S_IRUGO, ts5500_show_jp6, NULL);
+
+static struct attribute *ts5500_attributes[] = {
+	&dev_attr_id.attr,
+	&dev_attr_sram.attr,
+	&dev_attr_rs485.attr,
+	&dev_attr_adc.attr,
+	&dev_attr_ereset.attr,
+	&dev_attr_itr.attr,
+	&dev_attr_jp1.attr,
+	&dev_attr_jp2.attr,
+	&dev_attr_jp3.attr,
+	&dev_attr_jp4.attr,
+	&dev_attr_jp5.attr,
+	&dev_attr_jp6.attr,
+	NULL
+};
+
+static const struct attribute_group ts5500_attr_group = {
+	.attrs = ts5500_attributes
+};
+
+static int __init ts5500_init(void)
+{
+	int ret;
+	struct platform_device *pdev;
+
+	/* Firstly, check specific TS-5500 hardware, such as CPU. */
+	ret = ts5500_pre_detect();
+	if (ret)
+		return ret;
+
+	ts5500 = kzalloc(sizeof(struct ts5500_sbc), GFP_KERNEL);
+	if (!ts5500)
+		return -ENOMEM;
+	mutex_init(&ts5500->lock);
+
+	ret = ts5500_detect_config(ts5500);
+	if (ret)
+		goto release_mem;
+
+	pdev = platform_device_register_simple("ts5500", -1, NULL, 0);
+	if (IS_ERR(pdev)) {
+		ret = PTR_ERR(pdev);
+		goto release_mem;
+	}
+	platform_set_drvdata(pdev, ts5500);
+
+	ret = platform_add_devices(ts5500_devices, ARRAY_SIZE(ts5500_devices));
+	if (ret)
+		goto release_pdev;
+
+	ret = sysfs_create_group(&pdev->dev.kobj,
+				 &ts5500_attr_group);
+	if (ret)
+		goto release_pdev;
+
+	return 0;
+
+release_pdev:
+	platform_device_unregister(pdev);
+release_mem:
+	kfree(ts5500);
+
+	return ret;
+}
+postcore_initcall(ts5500_init);
+
+MODULE_AUTHOR("Jonas Fonseca <jonas.fonseca@savoirfairelinux.com>");
+MODULE_AUTHOR("Alexandre Savard <alexandre.savard@savoirfairelinux.com>");
+MODULE_AUTHOR("Vivien Didelot <vivien.didelot@savoirfairelinux.com>");
+MODULE_DESCRIPTION("Technologic Systems TS-5500 Board's platform driver");
+MODULE_LICENSE("GPL");
-- 
1.7.6


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

* [RESEND][PATCH 2/5] gpio: add support for TS-5500 GPIO
  2011-07-28 21:10 [RESEND][PATCH 0/5] Support for the TS-5500 board Vivien Didelot
  2011-07-28 21:10 ` [RESEND][PATCH 1/5] x86: base support for TS-5500 Single Board Computer Vivien Didelot
@ 2011-07-28 21:10 ` Vivien Didelot
  2011-07-28 21:10 ` [RESEND][PATCH 3/5] leds: add support for TS-5500 LED Vivien Didelot
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 15+ messages in thread
From: Vivien Didelot @ 2011-07-28 21:10 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jerome Oufella, mjg, platform-driver-x86, Vivien Didelot

From: Jerome Oufella <jerome.oufella@savoirfairelinux.com>

add support for TS-5500 GPIO in /arch/x86/platform/ts5500

Signed-off-by: Vivien Didelot <vivien.didelot@savoirfairelinux.com>
---
 MAINTAINERS                            |    2 +
 arch/x86/platform/ts5500/Kconfig       |    7 +
 arch/x86/platform/ts5500/Makefile      |    1 +
 arch/x86/platform/ts5500/ts5500.c      |   21 ++
 arch/x86/platform/ts5500/ts5500_gpio.c |  421 ++++++++++++++++++++++++++++++++
 arch/x86/platform/ts5500/ts5500_gpio.h |   60 +++++
 6 files changed, 512 insertions(+), 0 deletions(-)
 create mode 100644 arch/x86/platform/ts5500/ts5500_gpio.c
 create mode 100644 arch/x86/platform/ts5500/ts5500_gpio.h

diff --git a/MAINTAINERS b/MAINTAINERS
index be8ce4b..c6cf870 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -6140,6 +6140,8 @@ S:	Maintained
 F:  arch/x86/platform/ts5500/Kconfig
 F:  arch/x86/platform/ts5500/Makefile
 F:  arch/x86/platform/ts5500/ts5500.c
+F:  arch/x86/platform/ts5500/ts5500_gpio.c
+F:  arch/x86/platform/ts5500/ts5500_gpio.h
 
 TEGRA SUPPORT
 M:	Colin Cross <ccross@android.com>
diff --git a/arch/x86/platform/ts5500/Kconfig b/arch/x86/platform/ts5500/Kconfig
index 6428ca5..bb4ef81 100644
--- a/arch/x86/platform/ts5500/Kconfig
+++ b/arch/x86/platform/ts5500/Kconfig
@@ -5,3 +5,10 @@ config TS5500
 	  Add support for the Technologic Systems TS-5500 platform features.
 
 	  If you have a TS-5500, say Y here.
+
+config TS5500_GPIO
+	bool "TS-5500 GPIO support"
+	depends on TS5500
+	default y
+	help
+	  This enables support for the DIO headers for GPIO usage.
diff --git a/arch/x86/platform/ts5500/Makefile b/arch/x86/platform/ts5500/Makefile
index 0a689a7..9eb93fe 100644
--- a/arch/x86/platform/ts5500/Makefile
+++ b/arch/x86/platform/ts5500/Makefile
@@ -1 +1,2 @@
 obj-$(CONFIG_TS5500)			+= ts5500.o
+obj-$(CONFIG_TS5500_GPIO)		+= ts5500_gpio.o
\ No newline at end of file
diff --git a/arch/x86/platform/ts5500/ts5500.c b/arch/x86/platform/ts5500/ts5500.c
index 0135dbd..1ed0097 100644
--- a/arch/x86/platform/ts5500/ts5500.c
+++ b/arch/x86/platform/ts5500/ts5500.c
@@ -24,6 +24,8 @@
 #include <linux/io.h>
 #include <linux/slab.h>
 #include <asm/processor.h>
+#include <linux/gpio.h>
+#include "ts5500_gpio.h"
 
 /* Hardware info for pre-detection */
 #define AMD_ELAN_FAMILY			4
@@ -141,7 +143,26 @@ error:
 
 #define TS5500_IS_JP_SET(sbc, jmp) (!!(sbc->jumpers & TS5500_JP##jmp))
 
+
+#ifdef CONFIG_TS5500_GPIO
+/* Callback for releasing resources */
+static void ts5500_gpio_device_release(struct device *dev)
+{
+	/* noop */
+}
+
+static struct platform_device ts5500_gpio_device = {
+	.name = "ts5500_gpio",
+	.id = -1,
+	.dev = {
+		.release = ts5500_gpio_device_release,
+	}
+};
+#endif
 static struct platform_device *ts5500_devices[] __initdata = {
+#ifdef CONFIG_TS5500_GPIO
+	&ts5500_gpio_device,
+#endif
 };
 
 static ssize_t ts5500_show_id(struct device *dev,
diff --git a/arch/x86/platform/ts5500/ts5500_gpio.c b/arch/x86/platform/ts5500/ts5500_gpio.c
new file mode 100644
index 0000000..0250973
--- /dev/null
+++ b/arch/x86/platform/ts5500/ts5500_gpio.c
@@ -0,0 +1,421 @@
+/*
+ * GPIO (DIO) driver for Technologic Systems TS-5500
+ *
+ * Copyright (c) 2010 Savoir-faire Linux Inc.
+ *	Jerome Oufella <jerome.oufella@savoirfairelinux.com>
+ *
+ * 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.
+ *
+ * TS-5500 board has 38 GPIOs referred to as DIOs in the product's literature.
+ */
+
+#include <linux/module.h>
+#include <linux/mutex.h>
+#include <linux/gpio.h>
+#include <linux/platform_device.h>
+#include <linux/slab.h>
+#include <linux/io.h>
+#include "ts5500_gpio.h"
+
+static void port_bit_set(u8 addr, int bit)
+{
+	u8 var;
+	var = inb(addr);
+	var |= (1 << bit);
+	outb(var, addr);
+}
+
+static void port_bit_clear(u8 addr, int bit)
+{
+	u8 var;
+	var = inb(addr);
+	var &= ~(1 << bit);
+	outb(var, addr);
+}
+
+/* "DIO" line to IO port mapping table for line's value */
+static const unsigned long line_to_port_map[] = {
+	0x7B, 0x7B, 0x7B, 0x7B, 0x7B, 0x7B, 0x7B, 0x7B,		/* DIO1_0~7  */
+	0x7C, 0x7C, 0x7C, 0x7C, 0x7C, 0x7C,			/* DIO1_8~13 */
+	0x7E, 0x7E, 0x7E, 0x7E, 0x7E, 0x7E, 0x7E, 0x7E,		/* DIO2_0~7  */
+	0x7F, 0x7F, 0x7F, 0x7F, 0x7F, 0x7F,			/* DIO2_8~13 */
+	0x72, 0x72, 0x72, 0x72, 0x72, 0x72, 0x72, 0x72,		/* LCD_0~7   */
+	0x73, 0x73, 0x73			   /* LCD_EN, LCD_RS, LCD_WR */
+};
+
+/* "DIO" line to IO port's bit map for line's value */
+static const int line_to_bit_map[] = {
+	0, 1, 2, 3, 4, 5, 6, 7,		/* DIO1_0~7  */
+	0, 1, 2, 3, 4, 5,		/* DIO1_8~13 */
+	0, 1, 2, 3, 4, 5, 6, 7,		/* DIO2_0~7  */
+	0, 1, 2, 3, 4, 5,		/* DIO2_8~13 */
+	0, 1, 2, 3, 4, 5, 6, 7,		/* LCD_0~7   */
+	0, 7, 6				/* LCD_EN, LCD_RS, LCD_WR */
+};
+
+/* "DIO" line's direction control mapping table */
+static const unsigned long line_to_dir_map[] = {
+	0x7A, 0x7A, 0x7A, 0x7A, 0x7A, 0x7A, 0x7A, 0x7A,		/* DIO1_0~7  */
+	0x7A, 0x7A, 0x7A, 0x7A, 0, 0,				/* DIO1_8~13 */
+	0x7D, 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, 0x7D,		/* DIO2_0~7  */
+	0x7D, 0x7D, 0x7D, 0x7D, 0, 0,				/* DIO2_8~13 */
+	0x7D, 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, 0x7D, 0x7D,		/* LCD_0~7   */
+	0, 0, 0					   /* LCD_EN, LCD_RS, LCD_WR */
+};
+
+/* "DIO" line's direction control bit-mapping table */
+static const int line_to_dir_bit_map[] = {
+	0, 0, 0, 0,  1,  1, 1, 1,	/* DIO1_0~7  */
+	5, 5, 5, 5, -1, -1,		/* DIO1_8~13 */
+	0, 0, 0, 0,  1,  1, 1, 1,	/* DIO2_0~7  */
+	5, 5, 5, 5, -1, -1,		/* DIO2_8~13 */
+	2, 2, 2, 2,  3,  3, 3, 3,	/* LCD_0~7   */
+	-1, -1, -1			/* LCD_EN, LCD_RS, LCD_WR */
+};
+
+/* This array is used to track requests for our GPIO lines */
+static int requested_gpios[TS5500_LCD_WR + 1];
+
+static int dio1_irq = 1;
+module_param(dio1_irq, int, 0644);
+MODULE_PARM_DESC(dio1_irq,
+		 "Enable usage of IRQ7 for any DIO1 line (default 1).");
+
+static int dio2_irq = 0;
+module_param(dio2_irq, int, 0644);
+MODULE_PARM_DESC(dio2_irq,
+		 "Enable usage of IRQ6 for any DIO2 line (default 0).");
+
+static int lcd_irq = 0;
+module_param(lcd_irq, int, 0644);
+MODULE_PARM_DESC(lcd_irq, "Enable usage of IRQ1 for any LCD line (default 0).");
+
+static int use_lcdio = 0;
+module_param(use_lcdio, int, 0644);
+MODULE_PARM_DESC(use_lcdio, "Enable usage of the LCD header for DIO operation"
+		 " (default 0).");
+
+/**
+ * struct ts5500_drvdata - Driver data
+ * @master:		Device.
+ * @gpio_chip:		GPIO chip.
+ * @gpio_lock:		Read/Write Mutex.
+ */
+struct ts5500_drvdata {
+	struct device *master;
+	struct gpio_chip gpio_chip;
+	struct mutex gpio_lock;
+};
+
+static int ts5500_gpio_request(struct gpio_chip *chip, unsigned offset)
+{
+	struct ts5500_drvdata *drvdata;
+
+	drvdata = container_of(chip, struct ts5500_drvdata, gpio_chip);
+
+	mutex_lock(&drvdata->gpio_lock);
+	if (requested_gpios[offset]) {
+		mutex_unlock(&drvdata->gpio_lock);
+		return -EBUSY;
+	}
+	requested_gpios[offset] = 1;
+	mutex_unlock(&drvdata->gpio_lock);
+
+	return 0;
+}
+
+static void ts5500_gpio_free(struct gpio_chip *chip, unsigned offset)
+{
+	struct ts5500_drvdata *drvdata;
+
+	drvdata = container_of(chip, struct ts5500_drvdata, gpio_chip);
+
+	mutex_lock(&drvdata->gpio_lock);
+	requested_gpios[offset] = 0;
+	mutex_unlock(&drvdata->gpio_lock);
+}
+
+static int ts5500_gpio_get(struct gpio_chip *chip, unsigned offset)
+{
+	unsigned long ioaddr;
+	u8 byte;
+	int bitno;
+	struct ts5500_drvdata *drvdata;
+
+	drvdata = container_of(chip, struct ts5500_drvdata, gpio_chip);
+
+	/* Some lines are output-only and cannot be read */
+	switch (offset) {
+	case TS5500_LCD_EN:
+		return -ENXIO;
+	default:
+		if (offset > chip->ngpio)
+			return -ENXIO;
+	}
+
+	ioaddr = line_to_port_map[offset];
+	bitno = line_to_bit_map[offset];
+
+	mutex_lock(&drvdata->gpio_lock);
+	byte = inb(ioaddr);
+	mutex_unlock(&drvdata->gpio_lock);
+
+	return (byte >> bitno) & 0x1;
+}
+
+static void ts5500_gpio_set(struct gpio_chip *chip, unsigned offset, int val)
+{
+	int bitno;
+	unsigned long ioaddr;
+	struct ts5500_drvdata *drvdata;
+
+	drvdata = container_of(chip, struct ts5500_drvdata, gpio_chip);
+
+	/* Some lines just can't be set */
+	switch (offset) {
+	case TS5500_DIO1_12:
+	case TS5500_DIO1_13:
+	case TS5500_DIO2_13:
+	case TS5500_LCD_RS:
+	case TS5500_LCD_WR:
+		return;
+	default:
+		if (offset > chip->ngpio)
+			return;
+		break;
+	}
+
+	/* Get io port and bit for 'offset' */
+	ioaddr = line_to_port_map[offset];
+	bitno = line_to_bit_map[offset];
+
+	mutex_lock(&drvdata->gpio_lock);
+	if (val == 0)
+		port_bit_clear(ioaddr, bitno);
+	else
+		port_bit_set(ioaddr, bitno);
+	mutex_unlock(&drvdata->gpio_lock);
+}
+
+static int ts5500_gpio_to_irq(struct gpio_chip *chip, unsigned offset)
+{
+	/* Only a few lines are IRQ-Capable */
+	switch (offset) {
+	case TS5500_DIO1_13:
+		return TS5500_DIO1_13_IRQ;
+	case TS5500_DIO2_13:
+		return TS5500_DIO2_13_IRQ;
+	case TS5500_LCD_RS:
+		return TS5500_LCD_RS_IRQ;
+	default:
+		break;
+	}
+
+	/*
+	 * Handle the case where the user bridged the IRQ line with another
+	 * DIO line from the same header.
+	 */
+	if (dio1_irq && offset >= TS5500_DIO1_0 && offset < TS5500_DIO1_13)
+		return TS5500_DIO1_13_IRQ;
+
+	if (dio2_irq && offset >= TS5500_DIO2_0 && offset < TS5500_DIO2_13)
+		return TS5500_DIO2_13_IRQ;
+
+	if (lcd_irq && offset >= TS5500_LCD_0 && offset <= TS5500_LCD_WR)
+		return TS5500_LCD_RS_IRQ;
+
+	return -ENXIO;
+}
+
+static int ts5500_gpio_direction_input(struct gpio_chip *chip, unsigned offset)
+{
+	unsigned long dir_reg;
+	int dir_bit;
+	struct ts5500_drvdata *drvdata;
+
+	drvdata = container_of(chip, struct ts5500_drvdata, gpio_chip);
+
+	/* Some lines cannot be set as inputs */
+	switch (offset) {
+	case TS5500_LCD_EN:
+		return -ENXIO;
+	default:
+		if (offset > chip->ngpio)
+			return -ENXIO;
+		break;
+	}
+
+	dir_reg = line_to_dir_map[offset];
+	dir_bit = line_to_dir_bit_map[offset];
+
+	mutex_lock(&drvdata->gpio_lock);
+	port_bit_clear(dir_reg, dir_bit);
+	mutex_unlock(&drvdata->gpio_lock);
+
+	return 0;
+}
+
+static int ts5500_gpio_direction_output(struct gpio_chip *chip, unsigned offset,
+					int val)
+{
+	unsigned long dir_reg, ioaddr;
+	int dir_bit, bitno;
+	struct ts5500_drvdata *drvdata;
+
+	drvdata = container_of(chip, struct ts5500_drvdata, gpio_chip);
+
+	/* Some lines cannot be set as outputs */
+	switch (offset) {
+	case TS5500_DIO1_12:
+	case TS5500_DIO1_13:
+	case TS5500_DIO2_13:
+	case TS5500_LCD_RS:
+	case TS5500_LCD_WR:
+		return -ENXIO;
+	default:
+		if (offset > chip->ngpio)
+			return -ENXIO;
+		break;
+	}
+
+	/* Get direction and value registers infos */
+	dir_reg = line_to_dir_map[offset];
+	dir_bit = line_to_dir_bit_map[offset];
+	ioaddr = line_to_port_map[offset];
+	bitno = line_to_bit_map[offset];
+
+	mutex_lock(&drvdata->gpio_lock);
+	if (val == 0)
+		port_bit_clear(ioaddr, bitno); /* Set initial line value */
+	else
+		port_bit_set(ioaddr, bitno);
+	port_bit_set(dir_reg, dir_bit); /* Set output direction for line */
+
+	/*
+	 * Confirm initial line output value
+	 * (might have been changed by input)
+	 */
+	if (val == 0)
+		port_bit_clear(ioaddr, bitno);
+	else
+		port_bit_set(ioaddr, bitno);
+	mutex_unlock(&drvdata->gpio_lock);
+
+	return 0;
+}
+
+static int __devinit ts5500_gpio_probe(struct platform_device *pdev)
+{
+	struct ts5500_drvdata *drvdata;
+	struct gpio_chip *chip;
+	int ret;
+
+	if (pdev == NULL) {
+		dev_err(&pdev->dev, "Platform device not available!\n");
+		return -ENODEV;
+	}
+
+	/* Request DIO1 */
+	if (!request_region(0x7A, 3, "ts5500-gpio-DIO1")) {
+		dev_err(&pdev->dev, "Cannot request I/O port 0x7A-7C\n");
+		goto err_req_dio1;
+	}
+
+	/* Request DIO2 */
+	if (!request_region(0x7D, 3, "ts5500-gpio-DIO2")) {
+		dev_err(&pdev->dev, "Cannot request I/O port 0x7D-7F\n");
+		goto err_req_dio2;
+	}
+
+	/* Request LCDIO if wanted */
+	if (use_lcdio && !request_region(0x72, 2, "ts5500-gpio-LCD")) {
+		dev_err(&pdev->dev, "Cannot request I/O port 0x72-73\n");
+		goto err_req_lcdio;
+	}
+
+	/* Setup the gpio_chip structure */
+	drvdata = kzalloc(sizeof(struct ts5500_drvdata), GFP_KERNEL);
+	if (drvdata == NULL)
+		goto err_alloc_dev;
+
+	memset(requested_gpios, 0, sizeof(requested_gpios));
+	mutex_init(&drvdata->gpio_lock);
+
+	drvdata->master = pdev->dev.parent;
+	chip = &drvdata->gpio_chip;
+	chip->request = ts5500_gpio_request;
+	chip->free = ts5500_gpio_free;
+	chip->to_irq = ts5500_gpio_to_irq;
+	chip->direction_input = ts5500_gpio_direction_input;
+	chip->direction_output = ts5500_gpio_direction_output;
+	chip->get = ts5500_gpio_get;
+	chip->set = ts5500_gpio_set;
+	chip->can_sleep = 0;
+	chip->base = TS5500_DIO1_0;
+	chip->label = pdev->name;
+	chip->ngpio = (use_lcdio ? TS5500_LCD_WR + 1 : TS5500_DIO2_13 + 1);
+
+	/* Enable IRQ generation */
+	mutex_lock(&drvdata->gpio_lock);
+	port_bit_set(0x7A, 7); /* DIO1_13 on IRQ7 */
+	port_bit_set(0x7D, 7); /* DIO2_13 on IRQ6 */
+	if (use_lcdio) {
+		port_bit_clear(0x7D, 4); /* Enable LCD header usage as DIO */
+		port_bit_set(0x7D, 6);   /* LCD_RS on IRQ1 */
+	}
+	mutex_unlock(&drvdata->gpio_lock);
+
+	/* Register chip */
+	ret = gpiochip_add(&drvdata->gpio_chip);
+	if (ret)
+		goto err_gpiochip_add;
+
+	platform_set_drvdata(pdev, drvdata);
+
+	return 0;
+
+err_gpiochip_add:
+	dev_err(&pdev->dev, "Failed to register the gpio chip.\n");
+	kfree(drvdata);
+
+err_alloc_dev:
+	if (use_lcdio)
+		release_region(0x72, 2);	/* Release LCD's region */
+
+err_req_lcdio:
+	release_region(0x7D, 3);		/* Release DIO2's region */
+
+err_req_dio2:
+	release_region(0x7A, 3);		/* Release DIO1's region */
+
+err_req_dio1:
+	ret = -EBUSY;
+
+	return ret;
+}
+
+static struct platform_driver ts5500_gpio_driver = {
+	.driver = {
+		.name = "ts5500_gpio",
+		.owner = THIS_MODULE,
+	},
+	.probe = ts5500_gpio_probe
+};
+
+static const struct platform_device_id ts5500_devices[] = {
+	{ "ts5500_gpio", 0 },
+	{}
+};
+MODULE_DEVICE_TABLE(platform, ts5500_devices);
+
+static int __init ts5500_gpio_init(void)
+{
+	return platform_driver_register(&ts5500_gpio_driver);
+}
+module_init(ts5500_gpio_init);
+
+MODULE_AUTHOR("Jerome Oufella <jerome.oufella@savoirfairelinux.com>");
+MODULE_LICENSE("GPL");
+MODULE_DESCRIPTION("Technologic Systems TS-5500, GPIO/DIO driver");
diff --git a/arch/x86/platform/ts5500/ts5500_gpio.h b/arch/x86/platform/ts5500/ts5500_gpio.h
new file mode 100644
index 0000000..7090263
--- /dev/null
+++ b/arch/x86/platform/ts5500/ts5500_gpio.h
@@ -0,0 +1,60 @@
+/*
+ * GPIO (DIO) driver for Technologic Systems TS-5500
+ *
+ * Copyright (c) 2010 Savoir-faire Linux Inc.
+ *	Jerome Oufella <jerome.oufella@savoirfairelinux.com>
+ *
+ * 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.
+ */
+
+#ifndef _TS5500_GPIO_H
+#define _TS5500_GPIO_H
+
+#define TS5500_DIO1_0		0
+#define TS5500_DIO1_1		1
+#define TS5500_DIO1_2		2
+#define TS5500_DIO1_3		3
+#define TS5500_DIO1_4		4
+#define TS5500_DIO1_5		5
+#define TS5500_DIO1_6		6
+#define TS5500_DIO1_7		7
+#define TS5500_DIO1_8		8
+#define TS5500_DIO1_9		9
+#define TS5500_DIO1_10		10
+#define TS5500_DIO1_11		11
+#define TS5500_DIO1_12		12
+#define TS5500_DIO1_13		13
+#define TS5500_DIO2_0		14
+#define TS5500_DIO2_1		15
+#define TS5500_DIO2_2		16
+#define TS5500_DIO2_3		17
+#define TS5500_DIO2_4		18
+#define TS5500_DIO2_5		19
+#define TS5500_DIO2_6		20
+#define TS5500_DIO2_7		21
+#define TS5500_DIO2_8		22
+#define TS5500_DIO2_9		23
+#define TS5500_DIO2_10		24
+#define TS5500_DIO2_11		25
+/* #define TS5500_DIO2_12 - Keep commented out as it simply doesn't exist. */
+#define TS5500_DIO2_13		26
+#define TS5500_LCD_0		27
+#define TS5500_LCD_1		28
+#define TS5500_LCD_2		29
+#define TS5500_LCD_3		30
+#define TS5500_LCD_4		31
+#define TS5500_LCD_5		32
+#define TS5500_LCD_6		33
+#define TS5500_LCD_7		34
+#define TS5500_LCD_EN		35
+#define TS5500_LCD_RS		36
+#define TS5500_LCD_WR		37
+
+/* Lines that can trigger IRQs */
+#define TS5500_DIO1_13_IRQ	7
+#define TS5500_DIO2_13_IRQ	6
+#define TS5500_LCD_RS_IRQ	1
+
+#endif /* _TS5500_GPIO_H */
-- 
1.7.6


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

* [RESEND][PATCH 3/5] leds: add support for TS-5500 LED
  2011-07-28 21:10 [RESEND][PATCH 0/5] Support for the TS-5500 board Vivien Didelot
  2011-07-28 21:10 ` [RESEND][PATCH 1/5] x86: base support for TS-5500 Single Board Computer Vivien Didelot
  2011-07-28 21:10 ` [RESEND][PATCH 2/5] gpio: add support for TS-5500 GPIO Vivien Didelot
@ 2011-07-28 21:10 ` Vivien Didelot
  2011-07-28 21:10 ` [RESEND][PATCH 4/5] adc: add support for TS-5500 ADC Vivien Didelot
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 15+ messages in thread
From: Vivien Didelot @ 2011-07-28 21:10 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jonas Fonseca, mjg, platform-driver-x86, Vivien Didelot

From: Jonas Fonseca <jonas.fonseca@savoirfairelinux.com>

Add support for the TS-5500 on-board LED

Signed-off-by: Vivien Didelot <vivien.didelot@savoirfairelinux.com>
---
 MAINTAINERS                            |    1 +
 arch/x86/platform/ts5500/Kconfig       |    7 ++
 arch/x86/platform/ts5500/Makefile      |    3 +-
 arch/x86/platform/ts5500/ts5500.c      |   41 ++++++++++
 arch/x86/platform/ts5500/ts5500_leds.c |  133 ++++++++++++++++++++++++++++++++
 5 files changed, 184 insertions(+), 1 deletions(-)
 create mode 100644 arch/x86/platform/ts5500/ts5500_leds.c

diff --git a/MAINTAINERS b/MAINTAINERS
index c6cf870..034a25f 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -6142,6 +6142,7 @@ F:  arch/x86/platform/ts5500/Makefile
 F:  arch/x86/platform/ts5500/ts5500.c
 F:  arch/x86/platform/ts5500/ts5500_gpio.c
 F:  arch/x86/platform/ts5500/ts5500_gpio.h
+F:  arch/x86/platform/ts5500/ts5500_leds.c
 
 TEGRA SUPPORT
 M:	Colin Cross <ccross@android.com>
diff --git a/arch/x86/platform/ts5500/Kconfig b/arch/x86/platform/ts5500/Kconfig
index bb4ef81..e7fbf34 100644
--- a/arch/x86/platform/ts5500/Kconfig
+++ b/arch/x86/platform/ts5500/Kconfig
@@ -12,3 +12,10 @@ config TS5500_GPIO
 	default y
 	help
 	  This enables support for the DIO headers for GPIO usage.
+
+config TS5500_LEDS
+	bool "TS-5500 LED Support"
+	depends on TS5500 && LEDS_CLASS
+	default y
+	help
+	  This option enables support for the on-chip LED.
diff --git a/arch/x86/platform/ts5500/Makefile b/arch/x86/platform/ts5500/Makefile
index 9eb93fe..4d23812 100644
--- a/arch/x86/platform/ts5500/Makefile
+++ b/arch/x86/platform/ts5500/Makefile
@@ -1,2 +1,3 @@
 obj-$(CONFIG_TS5500)			+= ts5500.o
-obj-$(CONFIG_TS5500_GPIO)		+= ts5500_gpio.o
\ No newline at end of file
+obj-$(CONFIG_TS5500_GPIO)		+= ts5500_gpio.o
+obj-$(CONFIG_TS5500_LEDS)		+= ts5500_leds.o
\ No newline at end of file
diff --git a/arch/x86/platform/ts5500/ts5500.c b/arch/x86/platform/ts5500/ts5500.c
index 1ed0097..a455178 100644
--- a/arch/x86/platform/ts5500/ts5500.c
+++ b/arch/x86/platform/ts5500/ts5500.c
@@ -24,6 +24,7 @@
 #include <linux/io.h>
 #include <linux/slab.h>
 #include <asm/processor.h>
+#include <linux/leds.h>
 #include <linux/gpio.h>
 #include "ts5500_gpio.h"
 
@@ -143,6 +144,43 @@ error:
 
 #define TS5500_IS_JP_SET(sbc, jmp) (!!(sbc->jumpers & TS5500_JP##jmp))
 
+#ifdef CONFIG_TS5500_LEDS
+static struct led_info ts5500_led_info = {
+	.name = "ts5500_leds",
+	.default_trigger = "ts5500_leds",
+	.flags = TS5500_LED_FLAG
+};
+
+static struct led_platform_data ts5500_led_platform_data = {
+	.num_leds = 1,
+	.leds = &ts5500_led_info
+};
+
+static struct resource ts5500_led_resources[] = {
+	{
+		.name = "ts5500_leds",
+		.start = TS5500_LED_JMPRS_REG,
+		.end = TS5500_LED_JMPRS_REG,
+		.flags = IORESOURCE_IO
+	}
+};
+
+static void ts5500_led_release(struct device *dev)
+{
+	/* noop */
+}
+
+static struct platform_device ts5500_led_device = {
+	.name = "ts5500_leds",
+	.resource = ts5500_led_resources,
+	.num_resources = ARRAY_SIZE(ts5500_led_resources),
+	.id = -1,
+	.dev = {
+		.platform_data = &ts5500_led_platform_data,
+		.release = ts5500_led_release
+	}
+};
+#endif
 
 #ifdef CONFIG_TS5500_GPIO
 /* Callback for releasing resources */
@@ -160,6 +198,9 @@ static struct platform_device ts5500_gpio_device = {
 };
 #endif
 static struct platform_device *ts5500_devices[] __initdata = {
+#ifdef CONFIG_TS5500_LEDS
+	&ts5500_led_device,
+#endif
 #ifdef CONFIG_TS5500_GPIO
 	&ts5500_gpio_device,
 #endif
diff --git a/arch/x86/platform/ts5500/ts5500_leds.c b/arch/x86/platform/ts5500/ts5500_leds.c
new file mode 100644
index 0000000..b6be116
--- /dev/null
+++ b/arch/x86/platform/ts5500/ts5500_leds.c
@@ -0,0 +1,133 @@
+/*
+ * Technologic Systems TS-5500 boards - LED driver
+ *
+ * Copyright (c) 2010 Savoir-faire Linux Inc.
+ *	Jonas Fonseca <jonas.fonseca@savoirfairelinux.com>
+ *
+ * Portions Copyright (c) 2008 Compulab, Ltd.
+ *	Mike Rapoport <mike@compulab.co.il>
+ *
+ * Portions Copyright (c) 2006-2008 Marvell International Ltd.
+ *	Eric Miao <eric.miao@marvell.com>
+ *
+ * Based on drivers/leds/leds-da903x.c from linux-2.6.32.8.
+ *
+ * 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/kernel.h>
+#include <linux/init.h>
+#include <linux/platform_device.h>
+#include <linux/slab.h>
+#include <linux/workqueue.h>
+#include <linux/io.h>
+#include <linux/leds.h>
+
+/**
+ * struct ts5500_led - LED structure
+ * @cdev:		LED class device structure.
+ * @work:		Work structure.
+ * @new_brightness:	LED brightness.
+ * @ioaddr:		LED I/O address.
+ */
+struct ts5500_led {
+	struct led_classdev	cdev;
+	struct work_struct	work;
+	enum led_brightness	new_brightness;
+	int			ioaddr;
+	int			bit;
+};
+
+static void ts5500_led_work(struct work_struct *work)
+{
+	struct ts5500_led *led = container_of(work, struct ts5500_led, work);
+	u8 val = led->new_brightness ? led->bit : 0;
+
+	outb(val, led->ioaddr);
+}
+
+static void ts5500_led_set(struct led_classdev *led_cdev,
+			   enum led_brightness value)
+{
+	struct ts5500_led *led = container_of(led_cdev, struct ts5500_led,
+					      cdev);
+
+	led->new_brightness = value;
+	schedule_work(&led->work);
+}
+
+static int __devinit ts5500_led_probe(struct platform_device *pdev)
+{
+	struct led_platform_data *pdata = pdev->dev.platform_data;
+	struct ts5500_led *led;
+	struct resource *res;
+	int ret;
+
+	if (pdata == NULL || !pdata->num_leds) {
+		dev_err(&pdev->dev, "No platform data available\n");
+		return -ENODEV;
+	}
+
+	res = platform_get_resource(pdev, IORESOURCE_IO, 0);
+	if (!res) {
+		dev_err(&pdev->dev, "Failed to get I/O resource\n");
+		return -EBUSY;
+	}
+
+	led = kzalloc(sizeof(struct ts5500_led), GFP_KERNEL);
+	if (led == NULL) {
+		dev_err(&pdev->dev, "Failed to alloc memory for LED device\n");
+		return -ENOMEM;
+	}
+
+	led->cdev.name = pdata->leds[0].name;
+	led->cdev.default_trigger = pdata->leds[0].default_trigger;
+	led->cdev.brightness_set = ts5500_led_set;
+	led->cdev.brightness = LED_OFF;
+
+	led->ioaddr = res->start;
+	led->bit = pdata->leds[0].flags;
+	led->new_brightness = LED_OFF;
+
+	INIT_WORK(&led->work, ts5500_led_work);
+
+	ret = led_classdev_register(pdev->dev.parent, &led->cdev);
+	if (ret) {
+		dev_err(&pdev->dev, "Failed to register LED\n");
+		goto err;
+	}
+
+	platform_set_drvdata(pdev, led);
+	return 0;
+
+err:
+	kfree(led);
+	return ret;
+}
+
+static struct platform_driver ts5500_led_driver = {
+	.driver = {
+		.name = "ts5500_leds",
+		.owner = THIS_MODULE
+	},
+	.probe = ts5500_led_probe
+};
+
+static const struct platform_device_id ts5500_devices[] = {
+	{ "ts5500_leds", 0 },
+	{}
+};
+MODULE_DEVICE_TABLE(platform, ts5500_devices);
+
+static int __init ts5500_led_init(void)
+{
+	return platform_driver_register(&ts5500_led_driver);
+}
+module_init(ts5500_led_init);
+
+MODULE_LICENSE("GPL");
+MODULE_AUTHOR("Jonas Fonseca <jonas.fonseca@savoirfairelinux.com>");
+MODULE_DESCRIPTION("LED driver for Technologic Systems TS-5500");
-- 
1.7.6


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

* [RESEND][PATCH 4/5] adc: add support for TS-5500 ADC
  2011-07-28 21:10 [RESEND][PATCH 0/5] Support for the TS-5500 board Vivien Didelot
                   ` (2 preceding siblings ...)
  2011-07-28 21:10 ` [RESEND][PATCH 3/5] leds: add support for TS-5500 LED Vivien Didelot
@ 2011-07-28 21:10 ` Vivien Didelot
  2011-07-28 21:10 ` [RESEND][PATCH 5/5] mtd: move support for TS-5500 MTD Vivien Didelot
  2011-08-10  3:32 ` [RESEND][PATCH 0/5] Support for the TS-5500 board Vivien Didelot
  5 siblings, 0 replies; 15+ messages in thread
From: Vivien Didelot @ 2011-07-28 21:10 UTC (permalink / raw)
  To: linux-kernel; +Cc: Jonas Fonseca, mjg, platform-driver-x86, Vivien Didelot

From: Jonas Fonseca <jonas.fonseca@savoirfairelinux.com>

add support for the TS-5500 ADC.

Signed-off-by: Vivien Didelot <vivien.didelot@savoirfairelinux.com>
---
 Documentation/ABI/testing/sysfs-platform-ts5500 |   12 +-
 MAINTAINERS                                     |    2 +
 arch/x86/platform/ts5500/Kconfig                |    6 +
 arch/x86/platform/ts5500/Makefile               |    3 +-
 arch/x86/platform/ts5500/ts5500.c               |   77 ++++++
 arch/x86/platform/ts5500/ts5500_adc.c           |  326 +++++++++++++++++++++++
 arch/x86/platform/ts5500/ts5500_adc.h           |   62 +++++
 7 files changed, 481 insertions(+), 7 deletions(-)
 create mode 100644 arch/x86/platform/ts5500/ts5500_adc.c
 create mode 100644 arch/x86/platform/ts5500/ts5500_adc.h

diff --git a/Documentation/ABI/testing/sysfs-platform-ts5500 b/Documentation/ABI/testing/sysfs-platform-ts5500
index c870564..581a76f 100644
--- a/Documentation/ABI/testing/sysfs-platform-ts5500
+++ b/Documentation/ABI/testing/sysfs-platform-ts5500
@@ -29,18 +29,18 @@ Description:
 		Show the state of a plugged jumper. If it is present, it will
 		display "1", otherwise "0".
 
-What:		/sys/devices/platform/ts5500/adc
+What:		/sys/devices/platform/ts5500/rs485
 Date:		July 2011
 KernelVersion:	2.6.39
 Contact:	"Savoir-faire Linux, Inc." <kernel-ts@savoirfairelinux.com>
 Description:
-		Say if the Analogic to Digital Converter is present. If it is
-		enabled, it will display "1", otherwise "0".
+		Say if the RS485 feature is present. If it is enabled, it
+		will display "1", otherwise "0".
 
-What:		/sys/devices/platform/ts5500/rs485
+What:		/sys/devices/platform/ts5500/adc
 Date:		July 2011
 KernelVersion:	2.6.39
 Contact:	"Savoir-faire Linux, Inc." <kernel-ts@savoirfairelinux.com>
 Description:
-		Say if the RS485 feature is present. If it is enabled, it
-		will display "1", otherwise "0".
\ No newline at end of file
+		Say if the Analogic to Digital Converter is present. If it is
+		enabled, it will display "1", otherwise "0".
\ No newline at end of file
diff --git a/MAINTAINERS b/MAINTAINERS
index 034a25f..967f5cc 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -6143,6 +6143,8 @@ F:  arch/x86/platform/ts5500/ts5500.c
 F:  arch/x86/platform/ts5500/ts5500_gpio.c
 F:  arch/x86/platform/ts5500/ts5500_gpio.h
 F:  arch/x86/platform/ts5500/ts5500_leds.c
+F:  arch/x86/platform/ts5500/ts5500_adc.c
+F:  arch/x86/platform/ts5500/ts5500_adc.h
 
 TEGRA SUPPORT
 M:	Colin Cross <ccross@android.com>
diff --git a/arch/x86/platform/ts5500/Kconfig b/arch/x86/platform/ts5500/Kconfig
index e7fbf34..f38c8b6 100644
--- a/arch/x86/platform/ts5500/Kconfig
+++ b/arch/x86/platform/ts5500/Kconfig
@@ -19,3 +19,9 @@ config TS5500_LEDS
 	default y
 	help
 	  This option enables support for the on-chip LED.
+
+config TS5500_ADC
+	bool "TS-5500 ADC"
+	depends on TS5500
+	help
+      Support for the A/D converter on Technologic Systems TS-5500 SBCs.
diff --git a/arch/x86/platform/ts5500/Makefile b/arch/x86/platform/ts5500/Makefile
index 4d23812..79b8d10 100644
--- a/arch/x86/platform/ts5500/Makefile
+++ b/arch/x86/platform/ts5500/Makefile
@@ -1,3 +1,4 @@
 obj-$(CONFIG_TS5500)			+= ts5500.o
 obj-$(CONFIG_TS5500_GPIO)		+= ts5500_gpio.o
-obj-$(CONFIG_TS5500_LEDS)		+= ts5500_leds.o
\ No newline at end of file
+obj-$(CONFIG_TS5500_LEDS)		+= ts5500_leds.o
+obj-$(CONFIG_TS5500_ADC)		+= ts5500_adc.o
diff --git a/arch/x86/platform/ts5500/ts5500.c b/arch/x86/platform/ts5500/ts5500.c
index a455178..d0c496a 100644
--- a/arch/x86/platform/ts5500/ts5500.c
+++ b/arch/x86/platform/ts5500/ts5500.c
@@ -27,6 +27,7 @@
 #include <linux/leds.h>
 #include <linux/gpio.h>
 #include "ts5500_gpio.h"
+#include "ts5500_adc.h"
 
 /* Hardware info for pre-detection */
 #define AMD_ELAN_FAMILY			4
@@ -197,6 +198,71 @@ static struct platform_device ts5500_gpio_device = {
 	}
 };
 #endif
+
+#ifdef CONFIG_TS5500_ADC
+static void ts5500_adc_release(struct device *dev)
+{
+	/* noop */
+}
+
+static struct resource ts5500_adc_resources[] = {
+	{
+		.name  = "ts5500_adc" "-data",
+		.start = TS5500_ADC_INIT_LSB_REG,
+		.end   = TS5500_ADC_MSB_REG,
+		.flags = IORESOURCE_IO,
+	},
+	{
+		.name  = "ts5500_adc" "-ctrl",
+		.start = TS5500_ADC_CTRL_REG,
+		.end   = TS5500_ADC_CTRL_REG,
+		.flags = IORESOURCE_IO,
+	}
+};
+
+static struct ts5500_adc_platform_data ts5500_adc_platform_data = {
+	.name = TS5500_ADC_NAME,
+	.ioaddr = {
+		.data = TS5500_ADC_INIT_LSB_REG,
+		.ctrl = TS5500_ADC_CTRL_REG,
+	},
+	.read = {
+		.delay     = TS5500_ADC_READ_DELAY,
+		.busy_mask = TS5500_ADC_READ_BUSY_MASK,
+	},
+	.ctrl = {
+		{ TS5500_ADC_UNIPOLAR | TS5500_ADC_RANGE_5V,
+		  TS5500_ADC_UNIPOLAR | TS5500_ADC_RANGE_10V },
+		{ TS5500_ADC_BIPOLAR  | TS5500_ADC_RANGE_5V,
+		  TS5500_ADC_BIPOLAR  | TS5500_ADC_RANGE_10V },
+	},
+	.ranges = {
+		.min = {
+			{  0,     0 },
+			{ -5000, -10000 },
+		},
+		.max = {
+			{  5000,  10000 },
+			{  5000,  10000 },
+		},
+	},
+	.scale = {
+		{ 12207, 24414 },
+		{ 24414, 48828 },
+	},
+};
+
+static struct platform_device ts5500_adc_device = {
+	.name = "ts5500_adc",
+	.id = -1,
+	.resource = ts5500_adc_resources,
+	.num_resources = ARRAY_SIZE(ts5500_adc_resources),
+	.dev = {
+		.platform_data = &ts5500_adc_platform_data,
+		.release = ts5500_adc_release,
+	},
+};
+#endif
 static struct platform_device *ts5500_devices[] __initdata = {
 #ifdef CONFIG_TS5500_LEDS
 	&ts5500_led_device,
@@ -335,6 +401,17 @@ static int __init ts5500_init(void)
 	if (ret)
 		goto release_pdev;
 
+#ifdef CONFIG_TS5500_ADC
+	if (ts5500->adc) {
+		ret = platform_device_register(&ts5500_adc_device);
+		if (ret)
+			goto release_pdev;
+	} else {
+		pr_warn("ADC config enabled, "
+			"but the platform has no A/D converter!");
+	}
+#endif
+
 	ret = sysfs_create_group(&pdev->dev.kobj,
 				 &ts5500_attr_group);
 	if (ret)
diff --git a/arch/x86/platform/ts5500/ts5500_adc.c b/arch/x86/platform/ts5500/ts5500_adc.c
new file mode 100644
index 0000000..6a85edf
--- /dev/null
+++ b/arch/x86/platform/ts5500/ts5500_adc.c
@@ -0,0 +1,326 @@
+/*
+ * Technologic Systems TS-5500 boards - Mapped MAX197 ADC driver
+ *
+ * Copyright (c) 2010 Savoir-faire Linux Inc.
+ *          Jonas Fonseca <jonas.fonseca@savoirfairelinux.com>
+ *
+ * Portions Copyright (C) 2008 Marc Pignat <marc.pignat@hevs.ch>
+ *
+ * The driver uses direct access for communication with the ADC.
+ * Should work unchanged with the MAX199 chip.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ * The TS-5500 uses a CPLD to abstract the interface to a MAX197.
+ */
+
+#include <linux/init.h>
+#include <linux/module.h>
+#include <linux/kernel.h>
+#include <linux/device.h>
+#include <linux/delay.h>
+#include <linux/platform_device.h>
+#include <linux/err.h>
+#include <linux/sysfs.h>
+#include <linux/hwmon.h>
+#include <linux/hwmon-sysfs.h>
+#include <linux/mutex.h>
+#include <linux/slab.h>
+#include <linux/io.h>
+#include "ts5500_adc.h"
+
+#define ts5500_adc_test_bit(bit, map)	(test_bit(bit, map) != 0)
+
+/**
+ * struct ts5500_adc_chip
+ * @hwmon_dev:		The hwmon device.
+ * @lock:		Read/Write mutex.
+ * @spec:		The mapped MAX197 platform data.
+ * @polarity:		bitmap for polarity.
+ * @range:		bitmap for range.
+ */
+struct ts5500_adc_chip {
+	struct device *hwmon_dev;
+	struct mutex lock;
+	struct ts5500_adc_platform_data spec;
+	DECLARE_BITMAP(polarity, TS5500_ADC_CHANNELS_MAX);
+	DECLARE_BITMAP(range, TS5500_ADC_CHANNELS_MAX);
+};
+
+static s32 ts5500_adc_scale(struct ts5500_adc_chip *chip, s16 raw,
+			    int polarity, int range)
+{
+	s32 scaled = raw;
+
+	scaled *= chip->spec.scale[polarity][range];
+	scaled /= 10000;
+
+	return scaled;
+}
+
+static int ts5500_adc_range(struct ts5500_adc_chip *chip, int is_min,
+			       int polarity, int range)
+{
+	if (is_min)
+		return chip->spec.ranges.min[polarity][range];
+	return chip->spec.ranges.max[polarity][range];
+}
+
+static int ts5500_adc_strtol(const char *buf, long *value, int range1,
+				int range2)
+{
+	if (strict_strtol(buf, 10, value))
+		return -EINVAL;
+
+	if (range1 < range2)
+		*value = SENSORS_LIMIT(*value, range1, range2);
+	else
+		*value = SENSORS_LIMIT(*value, range2, range1);
+
+	return 0;
+}
+
+static struct ts5500_adc_chip *ts5500_adc_get_drvdata(struct device *dev)
+{
+	return platform_get_drvdata(to_platform_device(dev));
+}
+
+/**
+ * ts5500_adc_show_range() - Display range on user output
+ *
+ * Function called on read access on
+ * /sys/devices/platform/ts5500-adc/in{0,1,2,3,4,5,6,7}_{min,max}
+ */
+static ssize_t ts5500_adc_show_range(struct device *dev,
+				 struct device_attribute *devattr, char *buf)
+{
+	struct ts5500_adc_chip *chip = ts5500_adc_get_drvdata(dev);
+	struct sensor_device_attribute_2 *attr = to_sensor_dev_attr_2(devattr);
+	int is_min = attr->nr != 0;
+	int polarity, range;
+
+	if (mutex_lock_interruptible(&chip->lock))
+		return -ERESTARTSYS;
+
+	polarity = ts5500_adc_test_bit(attr->index, chip->polarity);
+	range = ts5500_adc_test_bit(attr->index, chip->range);
+
+	mutex_unlock(&chip->lock);
+
+	return sprintf(buf, "%d\n",
+		       ts5500_adc_range(chip, is_min, polarity, range));
+}
+
+/**
+ * ts5500_adc_store_range() - Write range from user input
+ *
+ * Function called on write access on
+ * /sys/devices/platform/ts5500-adc/in{0,1,2,3,4,5,6,7}_{min,max}
+ */
+static ssize_t ts5500_adc_store_range(struct device *dev,
+				  struct device_attribute *devattr,
+				  const char *buf, size_t count)
+{
+	struct ts5500_adc_chip *chip = ts5500_adc_get_drvdata(dev);
+	struct sensor_device_attribute_2 *attr = to_sensor_dev_attr_2(devattr);
+	int is_min = attr->nr != 0;
+	int range1 = ts5500_adc_range(chip, is_min, 0, 0);
+	int range2 = ts5500_adc_range(chip, is_min, 1, 1);
+	long value;
+
+	if (ts5500_adc_strtol(buf, &value, range1, range2))
+		return -EINVAL;
+
+	if (mutex_lock_interruptible(&chip->lock))
+		return -ERESTARTSYS;
+
+	if (abs(value) > 5000)
+		set_bit(attr->index, chip->range);
+	else
+		clear_bit(attr->index, chip->range);
+
+	if (is_min) {
+		if (value < 0)
+			set_bit(attr->index, chip->polarity);
+		else
+			clear_bit(attr->index, chip->polarity);
+	}
+
+	mutex_unlock(&chip->lock);
+
+	return count;
+}
+
+/**
+ * ts5500_adc_show_input() - Show channel input
+ *
+ * Function called on read access on
+ * /sys/devices/platform/ts5500-adc/in{0,1,2,3,4,5,6,7}_input
+ */
+static ssize_t ts5500_adc_show_input(struct device *dev,
+				     struct device_attribute *devattr,
+				     char *buf)
+{
+	struct ts5500_adc_chip *chip = ts5500_adc_get_drvdata(dev);
+	struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
+	int polarity, range;
+	int ret;
+	u8 command;
+
+	if (mutex_lock_interruptible(&chip->lock))
+		return -ERESTARTSYS;
+
+	polarity = ts5500_adc_test_bit(attr->index, chip->polarity);
+	range = ts5500_adc_test_bit(attr->index, chip->range);
+
+	command = attr->index | chip->spec.ctrl[polarity][range];
+
+	outb(command, chip->spec.ioaddr.data);
+
+	udelay(chip->spec.read.delay);
+	ret = inb(chip->spec.ioaddr.ctrl);
+
+	if (ret & chip->spec.read.busy_mask) {
+		dev_err(dev, "device not ready (ret=0x0%x, try=%d)\n", ret,
+			range);
+		ret = -EIO;
+	} else {
+		/* LSB of conversion is at 0x196 and MSB is at 0x197 */
+		u8 lsb = inb(chip->spec.ioaddr.data);
+		u8 msb = inb(chip->spec.ioaddr.data + 1);
+		s16 raw = (msb << 8) | lsb;
+		s32 scaled = ts5500_adc_scale(chip, raw, polarity, range);
+
+		ret = sprintf(buf, "%d\n", scaled);
+	}
+
+	mutex_unlock(&chip->lock);
+	return ret;
+}
+
+static ssize_t ts5500_adc_show_name(struct device *dev,
+	struct device_attribute *devattr, char *buf)
+{
+	return sprintf(buf, "%s\n", ts5500_adc_get_drvdata(dev)->spec.name);
+}
+
+#define TS5500_ADC_HWMON_CHANNEL(chan)				\
+	SENSOR_DEVICE_ATTR(in##chan##_input, S_IRUGO,		\
+			   ts5500_adc_show_input, NULL, chan);	\
+	SENSOR_DEVICE_ATTR_2(in##chan##_max, S_IRUGO | S_IWUSR,	\
+			     ts5500_adc_show_range,		\
+			     ts5500_adc_store_range, 0, chan);	\
+	SENSOR_DEVICE_ATTR_2(in##chan##_min, S_IRUGO | S_IWUSR,	\
+			     ts5500_adc_show_range,		\
+			     ts5500_adc_store_range, 1, chan)	\
+
+#define TS5500_ADC_SYSFS_CHANNEL(chan)				\
+	&sensor_dev_attr_in##chan##_input.dev_attr.attr,	\
+	&sensor_dev_attr_in##chan##_max.dev_attr.attr,		\
+	&sensor_dev_attr_in##chan##_min.dev_attr.attr
+
+static DEVICE_ATTR(name, S_IRUGO, ts5500_adc_show_name, NULL);
+
+static TS5500_ADC_HWMON_CHANNEL(0);
+static TS5500_ADC_HWMON_CHANNEL(1);
+static TS5500_ADC_HWMON_CHANNEL(2);
+static TS5500_ADC_HWMON_CHANNEL(3);
+static TS5500_ADC_HWMON_CHANNEL(4);
+static TS5500_ADC_HWMON_CHANNEL(5);
+static TS5500_ADC_HWMON_CHANNEL(6);
+static TS5500_ADC_HWMON_CHANNEL(7);
+
+static const struct attribute_group ts5500_adc_sysfs_group = {
+	.attrs = (struct attribute *[]) {
+		&dev_attr_name.attr,
+		TS5500_ADC_SYSFS_CHANNEL(0),
+		TS5500_ADC_SYSFS_CHANNEL(1),
+		TS5500_ADC_SYSFS_CHANNEL(2),
+		TS5500_ADC_SYSFS_CHANNEL(3),
+		TS5500_ADC_SYSFS_CHANNEL(4),
+		TS5500_ADC_SYSFS_CHANNEL(5),
+		TS5500_ADC_SYSFS_CHANNEL(6),
+		TS5500_ADC_SYSFS_CHANNEL(7),
+		NULL
+	}
+};
+
+static int __devinit ts5500_adc_probe(struct platform_device *pdev)
+{
+	struct ts5500_adc_platform_data *pdata = pdev->dev.platform_data;
+	struct ts5500_adc_chip *chip;
+	int ret;
+
+	if (pdata == NULL)
+		return -ENODEV;
+
+	chip = kzalloc(sizeof *chip, GFP_KERNEL);
+	if (!chip)
+		return -ENOMEM;
+
+	chip->spec = *pdata;
+
+	mutex_init(&chip->lock);
+	mutex_lock(&chip->lock);
+
+	ret = sysfs_create_group(&pdev->dev.kobj, &ts5500_adc_sysfs_group);
+	if (ret) {
+		dev_err(&pdev->dev, "sysfs_create_group failed.\n");
+		goto error_unlock_and_free;
+	}
+
+	chip->hwmon_dev = hwmon_device_register(&pdev->dev);
+	if (IS_ERR(chip->hwmon_dev)) {
+		dev_err(&pdev->dev, "hwmon_device_register failed.\n");
+		ret = PTR_ERR(chip->hwmon_dev);
+		goto error_unregister_device;
+	}
+
+	platform_set_drvdata(pdev, chip);
+	mutex_unlock(&chip->lock);
+	return 0;
+
+error_unregister_device:
+	sysfs_remove_group(&pdev->dev.kobj, &ts5500_adc_sysfs_group);
+
+error_unlock_and_free:
+	mutex_unlock(&chip->lock);
+	kfree(chip);
+	return ret;
+}
+
+static struct platform_driver ts5500_adc_driver = {
+	.driver	= {
+		.name	= "ts5500_adc",
+		.owner	= THIS_MODULE,
+	},
+	.probe	= ts5500_adc_probe
+};
+
+static const struct platform_device_id ts5500_devices[] = {
+	{ "ts5500_adc", 0 },
+	{}
+};
+MODULE_DEVICE_TABLE(platform, ts5500_devices);
+
+static int __init ts5500_adc_init(void)
+{
+	return platform_driver_register(&ts5500_adc_driver);
+}
+module_init(ts5500_adc_init);
+
+MODULE_DESCRIPTION("TS-5500 mapped MAX197 ADC device driver");
+MODULE_AUTHOR("Jonas Fonseca <jonas.fonseca@savoirfairelinux.com>");
+MODULE_LICENSE("GPL");
diff --git a/arch/x86/platform/ts5500/ts5500_adc.h b/arch/x86/platform/ts5500/ts5500_adc.h
new file mode 100644
index 0000000..76d389f
--- /dev/null
+++ b/arch/x86/platform/ts5500/ts5500_adc.h
@@ -0,0 +1,62 @@
+#ifndef _TS5500_ADC_H
+#define _TS5500_ADC_H
+
+#define TS5500_ADC_CTRL_REG		0x195	/* Conversion state register */
+#define TS5500_ADC_INIT_LSB_REG		0x196	/* Init conv. / LSB register */
+#define TS5500_ADC_MSB_REG		0x197	/* MSB register */
+/*
+ * Control bits of A/D command
+ * bits 0-2:	selected channel (0 - 7)
+ * bits 3:	uni/bipolar (0 = unipolar (ie 0 to +5V))
+ *			    (1 = bipolar (ie -5 to +5V))
+ * bit 4:	selected range (0 = 5v range, 1 = 10V range)
+ * bit 5-7:	padded zero (unused)
+ */
+
+#define TS5500_ADC_CHANNELS_MAX		8	/* 0 to 7 channels on device */
+
+#define TS5500_ADC_BIPOLAR		0x08
+#define TS5500_ADC_UNIPOLAR		0x00
+#define TS5500_ADC_RANGE_5V		0x00	/* 0 to 5V range */
+#define TS5500_ADC_RANGE_10V		0x10	/* 0 to 10V range */
+
+#define TS5500_ADC_READ_DELAY		15	/* usec */
+#define TS5500_ADC_READ_BUSY_MASK	0x01
+#define TS5500_ADC_NAME			"MAX197 (8 channels)"
+
+/**
+ * struct ts5500_adc_platform_data
+ * @name:	Name of the device.
+ * @ioaddr:	I/O address containing:
+ *		.data:		Data register for conversion reading.
+ *		.ctrl:		A/D Control Register (bit 0 = 0 when
+ *				conversion completed).
+ * @read:	Information about conversion reading, with:
+ *		.delay:		Delay before next conversion.
+ *		.busy_mask:	Control register bit 0 equals 1 means
+ *				conversion is not completed yet.
+ * @ctrl:	Data tables addressable by [polarity][range].
+ * @ranges:	Ranges.
+ *		.min:		Min value.
+ *		.max:		Max value.
+ * @scale:	Polarity/Range coefficients to scale raw conversion reading.
+ */
+struct ts5500_adc_platform_data {
+	const char *name;
+	struct {
+		int data;
+		int ctrl;
+	} ioaddr;
+	struct {
+		u8 delay;
+		u8 busy_mask;
+	} read;
+	u8 ctrl[2][2];
+	struct {
+		int min[2][2];
+		int max[2][2];
+	} ranges;
+	int scale[2][2];
+};
+
+#endif
-- 
1.7.6


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

* [RESEND][PATCH 5/5] mtd: move support for TS-5500 MTD
  2011-07-28 21:10 [RESEND][PATCH 0/5] Support for the TS-5500 board Vivien Didelot
                   ` (3 preceding siblings ...)
  2011-07-28 21:10 ` [RESEND][PATCH 4/5] adc: add support for TS-5500 ADC Vivien Didelot
@ 2011-07-28 21:10 ` Vivien Didelot
  2011-08-10  3:32 ` [RESEND][PATCH 0/5] Support for the TS-5500 board Vivien Didelot
  5 siblings, 0 replies; 15+ messages in thread
From: Vivien Didelot @ 2011-07-28 21:10 UTC (permalink / raw)
  To: linux-kernel; +Cc: Vivien Didelot, mjg, platform-driver-x86, sean

This patch moves the existing driver for the TS-5500 Flash from
drivers/mtd/maps/ts5500_flash.c to arch/x86/platform/ts5500/, to regroup every
TS-5500 drivers under the same platform directory.

Signed-off-by: Vivien Didelot <vivien.didelot@savoirfairelinux.com>
---
 MAINTAINERS                             |    1 +
 arch/x86/platform/ts5500/Kconfig        |   20 +++++
 arch/x86/platform/ts5500/Makefile       |    1 +
 arch/x86/platform/ts5500/ts5500.c       |    5 ++
 arch/x86/platform/ts5500/ts5500_flash.c |  118 ++++++++++++++++++++++++++++++
 drivers/mtd/maps/Kconfig                |   18 -----
 drivers/mtd/maps/Makefile               |    1 -
 drivers/mtd/maps/ts5500_flash.c         |  121 -------------------------------
 8 files changed, 145 insertions(+), 140 deletions(-)
 create mode 100644 arch/x86/platform/ts5500/ts5500_flash.c
 delete mode 100644 drivers/mtd/maps/ts5500_flash.c

diff --git a/MAINTAINERS b/MAINTAINERS
index 967f5cc..5789eca 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -6145,6 +6145,7 @@ F:  arch/x86/platform/ts5500/ts5500_gpio.h
 F:  arch/x86/platform/ts5500/ts5500_leds.c
 F:  arch/x86/platform/ts5500/ts5500_adc.c
 F:  arch/x86/platform/ts5500/ts5500_adc.h
+F:  arch/x86/platform/ts5500/ts5500_flash.c
 
 TEGRA SUPPORT
 M:	Colin Cross <ccross@android.com>
diff --git a/arch/x86/platform/ts5500/Kconfig b/arch/x86/platform/ts5500/Kconfig
index f38c8b6..b7e4cd0 100644
--- a/arch/x86/platform/ts5500/Kconfig
+++ b/arch/x86/platform/ts5500/Kconfig
@@ -6,6 +6,26 @@ config TS5500
 
 	  If you have a TS-5500, say Y here.
 
+config TS5500_MTD
+	tristate "JEDEC Flash device mapped on TS-5500"
+	depends on TS5500 && MTD
+	select MTD_PARTITIONS
+	select MTD_JEDECPROBE
+	select MTD_CFI_AMDSTD
+	select CONFIG_RFD_FTL
+	help
+	  This provides a driver for the on-board flash of the Technologic
+	  System's TS-5500 board. The 2MB flash is split into 3 partitions
+	  which are accessed as separate MTD devices.
+
+	  mtd0 and mtd2 are the two BIOS drives, which use the resident
+	  flash disk (RFD) flash translation layer.
+
+	  mtd1 allows you to reprogram your BIOS. BE VERY CAREFUL.
+
+	  Note that jumper 3 ("Write Enable Drive A") must be set
+	  otherwise detection won't succeed.
+
 config TS5500_GPIO
 	bool "TS-5500 GPIO support"
 	depends on TS5500
diff --git a/arch/x86/platform/ts5500/Makefile b/arch/x86/platform/ts5500/Makefile
index 79b8d10..249f0de 100644
--- a/arch/x86/platform/ts5500/Makefile
+++ b/arch/x86/platform/ts5500/Makefile
@@ -2,3 +2,4 @@ obj-$(CONFIG_TS5500)			+= ts5500.o
 obj-$(CONFIG_TS5500_GPIO)		+= ts5500_gpio.o
 obj-$(CONFIG_TS5500_LEDS)		+= ts5500_leds.o
 obj-$(CONFIG_TS5500_ADC)		+= ts5500_adc.o
+obj-$(CONFIG_TS5500_MTD)		+= ts5500_flash.o
\ No newline at end of file
diff --git a/arch/x86/platform/ts5500/ts5500.c b/arch/x86/platform/ts5500/ts5500.c
index d0c496a..960066ae 100644
--- a/arch/x86/platform/ts5500/ts5500.c
+++ b/arch/x86/platform/ts5500/ts5500.c
@@ -417,6 +417,11 @@ static int __init ts5500_init(void)
 	if (ret)
 		goto release_pdev;
 
+
+#ifdef CONFIG_TS5500_MTD
+	if (!TS5500_IS_JP_SET(ts5500, 3))
+		pr_warn("Jumper 3 is not set, Flash drive A is read-only.");
+#endif
 	return 0;
 
 release_pdev:
diff --git a/arch/x86/platform/ts5500/ts5500_flash.c b/arch/x86/platform/ts5500/ts5500_flash.c
new file mode 100644
index 0000000..3472e77
--- /dev/null
+++ b/arch/x86/platform/ts5500/ts5500_flash.c
@@ -0,0 +1,118 @@
+/*
+ * ts5500_flash.c -- MTD map driver for Technology Systems TS-5500 board
+ *
+ * Copyright (C) 2004 Sean Young <sean@mess.org>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
+ *
+ * Note:
+ * - In order for detection to work, jumper 3 must be set.
+ * - Drive A and B use the resident flash disk (RFD) flash translation layer.
+ * - If you have created your own jffs file system and the bios overwrites
+ *   it during boot, try disabling Drive A: and B: in the boot order.
+ */
+
+#include <linux/init.h>
+#include <linux/module.h>
+#include <linux/kernel.h>
+#include <linux/mtd/map.h>
+#include <linux/mtd/mtd.h>
+#include <linux/mtd/partitions.h>
+#include <linux/types.h>
+
+#define WINDOW_ADDR	0x09400000
+#define WINDOW_SIZE	0x00200000
+
+static struct map_info ts5500_map = {
+	.name = "TS-5500 Flash",
+	.size = WINDOW_SIZE,
+	.bankwidth = 1,
+	.phys = WINDOW_ADDR
+};
+
+static struct mtd_partition ts5500_partitions[] = {
+	{
+		.name = "Drive A",
+		.offset = 0,
+		.size = 0x0e0000
+	},
+	{
+		.name = "BIOS",
+		.offset = 0x0e0000,
+		.size = 0x020000,
+	},
+	{
+		.name = "Drive B",
+		.offset = 0x100000,
+		.size = 0x100000
+	}
+};
+
+#define NUM_PARTITIONS ARRAY_SIZE(ts5500_partitions)
+
+static struct mtd_info *mymtd;
+
+static int __init init_ts5500_map(void)
+{
+	int rc = 0;
+
+	ts5500_map.virt = ioremap_nocache(ts5500_map.phys, ts5500_map.size);
+
+	if (!ts5500_map.virt) {
+		printk(KERN_ERR "Failed to ioremap_nocache\n");
+		rc = -EIO;
+		goto err2;
+	}
+
+	simple_map_init(&ts5500_map);
+
+	mymtd = do_map_probe("jedec_probe", &ts5500_map);
+	if (!mymtd)
+		mymtd = do_map_probe("map_rom", &ts5500_map);
+
+	if (!mymtd) {
+		rc = -ENXIO;
+		goto err1;
+	}
+
+	mymtd->owner = THIS_MODULE;
+	mtd_device_register(mymtd, ts5500_partitions, NUM_PARTITIONS);
+
+	return 0;
+
+err1:
+	iounmap(ts5500_map.virt);
+err2:
+	return rc;
+}
+module_init(init_ts5500_map);
+
+static void __exit cleanup_ts5500_map(void)
+{
+	if (mymtd) {
+		mtd_device_unregister(mymtd);
+		map_destroy(mymtd);
+	}
+
+	if (ts5500_map.virt) {
+		iounmap(ts5500_map.virt);
+		ts5500_map.virt = NULL;
+	}
+}
+module_exit(cleanup_ts5500_map);
+
+MODULE_LICENSE("GPL");
+MODULE_AUTHOR("Sean Young <sean@mess.org>");
+MODULE_DESCRIPTION("MTD map driver for Techology Systems TS-5500 board");
diff --git a/drivers/mtd/maps/Kconfig b/drivers/mtd/maps/Kconfig
index c0c328c..41cb511 100644
--- a/drivers/mtd/maps/Kconfig
+++ b/drivers/mtd/maps/Kconfig
@@ -127,24 +127,6 @@ config MTD_NETSC520
 	  demonstration board. If you have one of these boards and would like
 	  to use the flash chips on it, say 'Y'.
 
-config MTD_TS5500
-	tristate "JEDEC Flash device mapped on Technologic Systems TS-5500"
-	depends on X86
-	select MTD_JEDECPROBE
-	select MTD_CFI_AMDSTD
-	help
-	  This provides a driver for the on-board flash of the Technologic
-	  System's TS-5500 board. The 2MB flash is split into 3 partitions
-	  which are accessed as separate MTD devices.
-
-	  mtd0 and mtd2 are the two BIOS drives, which use the resident
-	  flash disk (RFD) flash translation layer.
-
-	  mtd1 allows you to reprogram your BIOS. BE VERY CAREFUL.
-
-	  Note that jumper 3 ("Write Enable Drive A") must be set
-	  otherwise detection won't succeed.
-
 config MTD_SBC_GXX
 	tristate "CFI Flash device mapped on Arcom SBC-GXx boards"
 	depends on X86 && MTD_CFI_INTELEXT && MTD_COMPLEX_MAPPINGS
diff --git a/drivers/mtd/maps/Makefile b/drivers/mtd/maps/Makefile
index cb48b11..f999fa3 100644
--- a/drivers/mtd/maps/Makefile
+++ b/drivers/mtd/maps/Makefile
@@ -32,7 +32,6 @@ obj-$(CONFIG_MTD_SA1100)	+= sa1100-flash.o
 obj-$(CONFIG_MTD_SBC_GXX)	+= sbc_gxx.o
 obj-$(CONFIG_MTD_SC520CDP)	+= sc520cdp.o
 obj-$(CONFIG_MTD_NETSC520)	+= netsc520.o
-obj-$(CONFIG_MTD_TS5500)	+= ts5500_flash.o
 obj-$(CONFIG_MTD_SUN_UFLASH)	+= sun_uflash.o
 obj-$(CONFIG_MTD_VMAX)		+= vmax301.o
 obj-$(CONFIG_MTD_SCx200_DOCFLASH)+= scx200_docflash.o
diff --git a/drivers/mtd/maps/ts5500_flash.c b/drivers/mtd/maps/ts5500_flash.c
deleted file mode 100644
index d1d671d..0000000
--- a/drivers/mtd/maps/ts5500_flash.c
+++ /dev/null
@@ -1,121 +0,0 @@
-/*
- * ts5500_flash.c -- MTD map driver for Technology Systems TS-5500 board
- *
- * Copyright (C) 2004 Sean Young <sean@mess.org>
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
- *
- * Note:
- * - In order for detection to work, jumper 3 must be set.
- * - Drive A and B use the resident flash disk (RFD) flash translation layer.
- * - If you have created your own jffs file system and the bios overwrites
- *   it during boot, try disabling Drive A: and B: in the boot order.
- */
-
-#include <linux/init.h>
-#include <linux/module.h>
-#include <linux/kernel.h>
-#include <linux/mtd/map.h>
-#include <linux/mtd/mtd.h>
-#include <linux/mtd/partitions.h>
-#include <linux/types.h>
-
-
-#define WINDOW_ADDR	0x09400000
-#define WINDOW_SIZE	0x00200000
-
-static struct map_info ts5500_map = {
-	.name = "TS-5500 Flash",
-	.size = WINDOW_SIZE,
-	.bankwidth = 1,
-	.phys = WINDOW_ADDR
-};
-
-static struct mtd_partition ts5500_partitions[] = {
-	{
-		.name = "Drive A",
-		.offset = 0,
-		.size = 0x0e0000
-	},
-	{
-		.name = "BIOS",
-		.offset = 0x0e0000,
-		.size = 0x020000,
-	},
-	{
-		.name = "Drive B",
-		.offset = 0x100000,
-		.size = 0x100000
-	}
-};
-
-#define NUM_PARTITIONS ARRAY_SIZE(ts5500_partitions)
-
-static struct mtd_info *mymtd;
-
-static int __init init_ts5500_map(void)
-{
-	int rc = 0;
-
-	ts5500_map.virt = ioremap_nocache(ts5500_map.phys, ts5500_map.size);
-
-	if (!ts5500_map.virt) {
-		printk(KERN_ERR "Failed to ioremap_nocache\n");
-		rc = -EIO;
-		goto err2;
-	}
-
-	simple_map_init(&ts5500_map);
-
-	mymtd = do_map_probe("jedec_probe", &ts5500_map);
-	if (!mymtd)
-		mymtd = do_map_probe("map_rom", &ts5500_map);
-
-	if (!mymtd) {
-		rc = -ENXIO;
-		goto err1;
-	}
-
-	mymtd->owner = THIS_MODULE;
-	mtd_device_register(mymtd, ts5500_partitions, NUM_PARTITIONS);
-
-	return 0;
-
-err1:
-	iounmap(ts5500_map.virt);
-err2:
-	return rc;
-}
-
-static void __exit cleanup_ts5500_map(void)
-{
-	if (mymtd) {
-		mtd_device_unregister(mymtd);
-		map_destroy(mymtd);
-	}
-
-	if (ts5500_map.virt) {
-		iounmap(ts5500_map.virt);
-		ts5500_map.virt = NULL;
-	}
-}
-
-module_init(init_ts5500_map);
-module_exit(cleanup_ts5500_map);
-
-MODULE_LICENSE("GPL");
-MODULE_AUTHOR("Sean Young <sean@mess.org>");
-MODULE_DESCRIPTION("MTD map driver for Techology Systems TS-5500 board");
-
-- 
1.7.6


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

* Re: [RESEND][PATCH 0/5] Support for the TS-5500 board
  2011-07-28 21:10 [RESEND][PATCH 0/5] Support for the TS-5500 board Vivien Didelot
                   ` (4 preceding siblings ...)
  2011-07-28 21:10 ` [RESEND][PATCH 5/5] mtd: move support for TS-5500 MTD Vivien Didelot
@ 2011-08-10  3:32 ` Vivien Didelot
  2011-08-10  5:53   ` Ike Panhc
  5 siblings, 1 reply; 15+ messages in thread
From: Vivien Didelot @ 2011-08-10  3:32 UTC (permalink / raw)
  To: Vivien Didelot; +Cc: linux-kernel, mjg, platform-driver-x86

Le Thu, 28 Jul 2011 17:10:45 -0400,
Vivien Didelot <vivien.didelot@savoirfairelinux.com> a écrit :

> This set of patches brings the support for the Technologic Systems
> TS-5500 Single Board Computer.
> 
> The first patch adds the base for the support of the board in
> /arch/x86/platform/ts5500 and a documentation file in
> Documentation/ABI/testing/sysfs-platform-ts5500.
> 
> The second patch adds support for GPIO.
> 
> The third patch adds support for the on-board LED.
> 
> The fourth patch brings support for the Analogic/Digital converter.
> 
> The fifth patch moves the already existing support for the Flash MTD
> into the /arch/x86/platform/ts5500 directory.
> 
> Jerome Oufella (1):
>   gpio: add support for TS-5500 GPIO
> 
> Jonas Fonseca (2):
>   leds: add support for TS-5500 LED
>   adc: add support for TS-5500 ADC
> 
> Vivien Didelot (2):
>   x86: base support for TS-5500 Single Board Computer
>   mtd: move support for TS-5500 MTD
> 
>  Documentation/ABI/testing/sysfs-platform-ts5500 |   46 +++
>  MAINTAINERS                                     |   13 +
>  arch/x86/Kconfig                                |    2 +
>  arch/x86/platform/Makefile                      |    1 +
>  arch/x86/platform/ts5500/Kconfig                |   47 +++
>  arch/x86/platform/ts5500/Makefile               |    5 +
>  arch/x86/platform/ts5500/ts5500.c               |  440
> +++++++++++++++++++++++
> arch/x86/platform/ts5500/ts5500_adc.c           |  326
> +++++++++++++++++ arch/x86/platform/ts5500/ts5500_adc.h           |
> 62 ++++ arch/x86/platform/ts5500/ts5500_flash.c         |  118 ++++++
> arch/x86/platform/ts5500/ts5500_gpio.c          |  421
> ++++++++++++++++++++++
> arch/x86/platform/ts5500/ts5500_gpio.h          |   60 +++
> arch/x86/platform/ts5500/ts5500_leds.c          |  133 +++++++
> drivers/mtd/maps/Kconfig                        |   18 -
> drivers/mtd/maps/Makefile                       |    1 -
> drivers/mtd/maps/ts5500_flash.c                 |  121 ------- 16
> files changed, 1674 insertions(+), 140 deletions(-) create mode
> 100644 Documentation/ABI/testing/sysfs-platform-ts5500 create mode
> 100644 arch/x86/platform/ts5500/Kconfig create mode 100644
> arch/x86/platform/ts5500/Makefile create mode 100644
> arch/x86/platform/ts5500/ts5500.c create mode 100644
> arch/x86/platform/ts5500/ts5500_adc.c create mode 100644
> arch/x86/platform/ts5500/ts5500_adc.h create mode 100644
> arch/x86/platform/ts5500/ts5500_flash.c create mode 100644
> arch/x86/platform/ts5500/ts5500_gpio.c create mode 100644
> arch/x86/platform/ts5500/ts5500_gpio.h create mode 100644
> arch/x86/platform/ts5500/ts5500_leds.c delete mode 100644
> drivers/mtd/maps/ts5500_flash.c
> 

This set of patches has been sent two times without any answer yet.
Can I have any feedback please?

Regards,
Vivien.

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

* Re: [RESEND][PATCH 0/5] Support for the TS-5500 board
  2011-08-10  3:32 ` [RESEND][PATCH 0/5] Support for the TS-5500 board Vivien Didelot
@ 2011-08-10  5:53   ` Ike Panhc
  2011-08-10  6:18     ` Corentin Chary
  0 siblings, 1 reply; 15+ messages in thread
From: Ike Panhc @ 2011-08-10  5:53 UTC (permalink / raw)
  To: Vivien Didelot; +Cc: linux-kernel, mjg, platform-driver-x86

I think platform-driver-x86 may not be the best mailing list for your patches.

Please try to use scripts/get_maintainer.pl and it can tell you who you shall ask for reviewing.

On 08/10/2011 11:32 AM, Vivien Didelot wrote:
> Le Thu, 28 Jul 2011 17:10:45 -0400,
> Vivien Didelot <vivien.didelot@savoirfairelinux.com> a écrit :
> 
>> This set of patches brings the support for the Technologic Systems
>> TS-5500 Single Board Computer.
>>
>> The first patch adds the base for the support of the board in
>> /arch/x86/platform/ts5500 and a documentation file in
>> Documentation/ABI/testing/sysfs-platform-ts5500.
>>
>> The second patch adds support for GPIO.
>>
>> The third patch adds support for the on-board LED.
>>
>> The fourth patch brings support for the Analogic/Digital converter.
>>
>> The fifth patch moves the already existing support for the Flash MTD
>> into the /arch/x86/platform/ts5500 directory.
>>
>> Jerome Oufella (1):
>>   gpio: add support for TS-5500 GPIO
>>
>> Jonas Fonseca (2):
>>   leds: add support for TS-5500 LED
>>   adc: add support for TS-5500 ADC
>>
>> Vivien Didelot (2):
>>   x86: base support for TS-5500 Single Board Computer
>>   mtd: move support for TS-5500 MTD
>>
>>  Documentation/ABI/testing/sysfs-platform-ts5500 |   46 +++
>>  MAINTAINERS                                     |   13 +
>>  arch/x86/Kconfig                                |    2 +
>>  arch/x86/platform/Makefile                      |    1 +
>>  arch/x86/platform/ts5500/Kconfig                |   47 +++
>>  arch/x86/platform/ts5500/Makefile               |    5 +
>>  arch/x86/platform/ts5500/ts5500.c               |  440
>> +++++++++++++++++++++++
>> arch/x86/platform/ts5500/ts5500_adc.c           |  326
>> +++++++++++++++++ arch/x86/platform/ts5500/ts5500_adc.h           |
>> 62 ++++ arch/x86/platform/ts5500/ts5500_flash.c         |  118 ++++++
>> arch/x86/platform/ts5500/ts5500_gpio.c          |  421
>> ++++++++++++++++++++++
>> arch/x86/platform/ts5500/ts5500_gpio.h          |   60 +++
>> arch/x86/platform/ts5500/ts5500_leds.c          |  133 +++++++
>> drivers/mtd/maps/Kconfig                        |   18 -
>> drivers/mtd/maps/Makefile                       |    1 -
>> drivers/mtd/maps/ts5500_flash.c                 |  121 ------- 16
>> files changed, 1674 insertions(+), 140 deletions(-) create mode
>> 100644 Documentation/ABI/testing/sysfs-platform-ts5500 create mode
>> 100644 arch/x86/platform/ts5500/Kconfig create mode 100644
>> arch/x86/platform/ts5500/Makefile create mode 100644
>> arch/x86/platform/ts5500/ts5500.c create mode 100644
>> arch/x86/platform/ts5500/ts5500_adc.c create mode 100644
>> arch/x86/platform/ts5500/ts5500_adc.h create mode 100644
>> arch/x86/platform/ts5500/ts5500_flash.c create mode 100644
>> arch/x86/platform/ts5500/ts5500_gpio.c create mode 100644
>> arch/x86/platform/ts5500/ts5500_gpio.h create mode 100644
>> arch/x86/platform/ts5500/ts5500_leds.c delete mode 100644
>> drivers/mtd/maps/ts5500_flash.c
>>
> 
> This set of patches has been sent two times without any answer yet.
> Can I have any feedback please?
> 
> Regards,
> Vivien.
> --
> To unsubscribe from this list: send the line "unsubscribe platform-driver-x86" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 


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

* Re: [RESEND][PATCH 0/5] Support for the TS-5500 board
  2011-08-10  5:53   ` Ike Panhc
@ 2011-08-10  6:18     ` Corentin Chary
  2011-08-10 14:06       ` Vivien Didelot
  0 siblings, 1 reply; 15+ messages in thread
From: Corentin Chary @ 2011-08-10  6:18 UTC (permalink / raw)
  To: Vivien Didelot; +Cc: Ike Panhc, linux-kernel, mjg, platform-driver-x86

On Wed, Aug 10, 2011 at 7:53 AM, Ike Panhc <ike.pan@canonical.com> wrote:
> I think platform-driver-x86 may not be the best mailing list for your patches.
>
> Please try to use scripts/get_maintainer.pl and it can tell you who you shall ask for reviewing.

Like Ike said, this is the mainling list for drivers/platform/x86, not
arch/x86, and running get_maintainer.pl on your patchs will give you
the rights people to CC.

And btw, I'm not sure we really want to put all these drivers in
arch/x86/platform/ts5500/ a re-create the arm driver mess.
drivers/leds/, drivers/gpio/  and drivers/mtd/ are probably a best choice.



-- 
Corentin Chary
http://xf.iksaif.net

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

* Re: [RESEND][PATCH 0/5] Support for the TS-5500 board
  2011-08-10  6:18     ` Corentin Chary
@ 2011-08-10 14:06       ` Vivien Didelot
  2011-08-10 14:20         ` David Woodhouse
  0 siblings, 1 reply; 15+ messages in thread
From: Vivien Didelot @ 2011-08-10 14:06 UTC (permalink / raw)
  To: Corentin Chary; +Cc: Ike Panhc, linux-kernel, mjg, platform-driver-x86

Hi,

Le Wed, 10 Aug 2011 08:18:28 +0200,
Corentin Chary <corentin.chary@gmail.com> a écrit :

> On Wed, Aug 10, 2011 at 7:53 AM, Ike Panhc <ike.pan@canonical.com>
> wrote:
> > I think platform-driver-x86 may not be the best mailing list for
> > your patches.
> >
> > Please try to use scripts/get_maintainer.pl and it can tell you who
> > you shall ask for reviewing.
> 
> Like Ike said, this is the mainling list for drivers/platform/x86, not
> arch/x86, and running get_maintainer.pl on your patchs will give you
> the rights people to CC.

Thanks for this information, it can be useful indeed.

> 
> And btw, I'm not sure we really want to put all these drivers in
> arch/x86/platform/ts5500/ a re-create the arm driver mess.
> drivers/leds/, drivers/gpio/  and drivers/mtd/ are probably a best
> choice.

In fact, this set of patches is a rewrite of the first RFC set, where
we discussed that arch/x86/platform/ could be a good place, as the
TS-5500 is a specific platform with its platform devices (the
corresponding thread is here: https://lkml.org/lkml/2011/5/3/60).

Regards,
Vivien.

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

* Re: [RESEND][PATCH 0/5] Support for the TS-5500 board
  2011-08-10 14:06       ` Vivien Didelot
@ 2011-08-10 14:20         ` David Woodhouse
  2011-08-10 19:09           ` Vivien Didelot
  0 siblings, 1 reply; 15+ messages in thread
From: David Woodhouse @ 2011-08-10 14:20 UTC (permalink / raw)
  To: Vivien Didelot
  Cc: Corentin Chary, Ike Panhc, linux-kernel, mjg, platform-driver-x86

On Wed, 2011-08-10 at 10:06 -0400, Vivien Didelot wrote:
> > And btw, I'm not sure we really want to put all these drivers in
> > arch/x86/platform/ts5500/ a re-create the arm driver mess.
> > drivers/leds/, drivers/gpio/  and drivers/mtd/ are probably a best
> > choice.
> 
> In fact, this set of patches is a rewrite of the first RFC set, where
> we discussed that arch/x86/platform/ could be a good place, as the
> TS-5500 is a specific platform with its platform devices (the
> corresponding thread is here: https://lkml.org/lkml/2011/5/3/60). 

Just expose these devices in the device-tree. You shouldn't *need* a new
MTD device driver; physmap_of should be just fine.

If your bootloader doesn't pass one, your platform-specific code should
just register its own device-tree blob during early boot. And your
device drivers should just match against the devices therein.

-- 
dwmw2


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

* Re: [RESEND][PATCH 0/5] Support for the TS-5500 board
  2011-08-10 14:20         ` David Woodhouse
@ 2011-08-10 19:09           ` Vivien Didelot
  2011-08-12 14:26             ` Vivien Didelot
  0 siblings, 1 reply; 15+ messages in thread
From: Vivien Didelot @ 2011-08-10 19:09 UTC (permalink / raw)
  To: David Woodhouse
  Cc: Corentin Chary, Ike Panhc, linux-kernel, mjg, platform-driver-x86

On Wed, 10 Aug 2011 15:20:46 +0100,
David Woodhouse <dwmw2@infradead.org> wrote:
> Just expose these devices in the device-tree. You shouldn't *need* a
> new MTD device driver; physmap_of should be just fine.

I didn't write a new MTD device driver, but just moved the already
existing one to the ts5500 platform directory. The point is that my
TS-5500 doesn't have this flash, so I couldn't try. The fifth patch
from this set could just be ignored.

> If your bootloader doesn't pass one, your platform-specific code
> should just register its own device-tree blob during early boot. And
> your device drivers should just match against the devices therein.

I'm a bit confused with what should be done for the support for an
embedded platform (X86-based) like this TS-5500. Is the actual code
hierarchy OK? What is the impact of adding a device-tree to this code?

Thanks,
Vivien.

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

* Re: [RESEND][PATCH 0/5] Support for the TS-5500 board
  2011-08-10 19:09           ` Vivien Didelot
@ 2011-08-12 14:26             ` Vivien Didelot
  2011-08-24 13:42               ` Matthew Garrett
  0 siblings, 1 reply; 15+ messages in thread
From: Vivien Didelot @ 2011-08-12 14:26 UTC (permalink / raw)
  To: Vivien Didelot
  Cc: David Woodhouse, Corentin Chary, Ike Panhc, linux-kernel, mjg,
	platform-driver-x86

On Wed, 10 Aug 2011 15:09:19 -0400,
Vivien Didelot <vivien.didelot@savoirfairelinux.com> wrote:

> On Wed, 10 Aug 2011 15:20:46 +0100,
> David Woodhouse <dwmw2@infradead.org> wrote:
> > Just expose these devices in the device-tree. You shouldn't *need* a
> > new MTD device driver; physmap_of should be just fine.
> 
> I didn't write a new MTD device driver, but just moved the already
> existing one to the ts5500 platform directory. The point is that my
> TS-5500 doesn't have this flash, so I couldn't try. The fifth patch
> from this set could just be ignored.
> 
> > If your bootloader doesn't pass one, your platform-specific code
> > should just register its own device-tree blob during early boot. And
> > your device drivers should just match against the devices therein.
> 
> I'm a bit confused with what should be done for the support for an
> embedded platform (X86-based) like this TS-5500. Is the actual code
> hierarchy OK? What is the impact of adding a device-tree to this code?
> 
> Thanks,
> Vivien.

Can I get the maintainer's view on this?

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

* Re: [RESEND][PATCH 0/5] Support for the TS-5500 board
  2011-08-12 14:26             ` Vivien Didelot
@ 2011-08-24 13:42               ` Matthew Garrett
  2011-08-24 15:16                 ` Vivien Didelot
  0 siblings, 1 reply; 15+ messages in thread
From: Matthew Garrett @ 2011-08-24 13:42 UTC (permalink / raw)
  To: Vivien Didelot
  Cc: David Woodhouse, Corentin Chary, Ike Panhc, linux-kernel,
	platform-driver-x86

On Fri, Aug 12, 2011 at 10:26:27AM -0400, Vivien Didelot wrote:
> On Wed, 10 Aug 2011 15:09:19 -0400,
> Vivien Didelot <vivien.didelot@savoirfairelinux.com> wrote:
> > I'm a bit confused with what should be done for the support for an
> > embedded platform (X86-based) like this TS-5500. Is the actual code
> > hierarchy OK? What is the impact of adding a device-tree to this code?
> > 
> > Thanks,
> > Vivien.
> 
> Can I get the maintainer's view on this?

You'd probably want to Cc: the x86 architecture maintainers - you've 
only got the one for x86-specific drivers that don't fall into other 
categories at the moment.

-- 
Matthew Garrett | mjg59@srcf.ucam.org

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

* Re: [RESEND][PATCH 0/5] Support for the TS-5500 board
  2011-08-24 13:42               ` Matthew Garrett
@ 2011-08-24 15:16                 ` Vivien Didelot
  0 siblings, 0 replies; 15+ messages in thread
From: Vivien Didelot @ 2011-08-24 15:16 UTC (permalink / raw)
  To: Matthew Garrett
  Cc: David Woodhouse, Corentin Chary, Ike Panhc, linux-kernel,
	platform-driver-x86

On Wed, 24 Aug 2011 14:42:41 +0100,
Matthew Garrett <mjg59@srcf.ucam.org> wrote:
> On Fri, Aug 12, 2011 at 10:26:27AM -0400, Vivien Didelot wrote:
> > Can I get the maintainer's view on this?
> 
> You'd probably want to Cc: the x86 architecture maintainers - you've 
> only got the one for x86-specific drivers that don't fall into other 
> categories at the moment.

Ok I see, thanks for your comment.

Regards,
Vivien.

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

end of thread, other threads:[~2011-08-24 15:16 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-07-28 21:10 [RESEND][PATCH 0/5] Support for the TS-5500 board Vivien Didelot
2011-07-28 21:10 ` [RESEND][PATCH 1/5] x86: base support for TS-5500 Single Board Computer Vivien Didelot
2011-07-28 21:10 ` [RESEND][PATCH 2/5] gpio: add support for TS-5500 GPIO Vivien Didelot
2011-07-28 21:10 ` [RESEND][PATCH 3/5] leds: add support for TS-5500 LED Vivien Didelot
2011-07-28 21:10 ` [RESEND][PATCH 4/5] adc: add support for TS-5500 ADC Vivien Didelot
2011-07-28 21:10 ` [RESEND][PATCH 5/5] mtd: move support for TS-5500 MTD Vivien Didelot
2011-08-10  3:32 ` [RESEND][PATCH 0/5] Support for the TS-5500 board Vivien Didelot
2011-08-10  5:53   ` Ike Panhc
2011-08-10  6:18     ` Corentin Chary
2011-08-10 14:06       ` Vivien Didelot
2011-08-10 14:20         ` David Woodhouse
2011-08-10 19:09           ` Vivien Didelot
2011-08-12 14:26             ` Vivien Didelot
2011-08-24 13:42               ` Matthew Garrett
2011-08-24 15:16                 ` Vivien Didelot

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.