Skip to contentSkip to conversation

Add platform device support for keypad driver

PATCH New 양진성 2 participants 3 messages Sep 5, 2009 – Sep 7, 2009

Subsystems (2)
lore
Share & tools
lore

양진성

author
#0 lore raw

PATCH 8/12 Add platform device support for keypad driver

This patch includes platform device information and resources support for s3c keypad driver.

---
 arch/arm/plat-s3c/dev-keypad.c |   66 ++++++++++++++++++++++++++++++++++++++++
 1 files changed, 66 insertions(+), 0 deletions(-)
 create mode 100644 arch/arm/plat-s3c/dev-keypad.c
arch/arm/plat-s3c/dev-keypad.c new file +66 -0
new file mode 100644
index 0000000..74c5443
@@ -0,0 +1,66 @@
+/* linux/arch/arm/plat-s3c/dev-keypad.c
+ *
+ * Base S3C Keypad resource and device definitions
+ *
+ * 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/kernel.h>
+#include <linux/types.h>
+#include <linux/interrupt.h>
+#include <linux/list.h>
+#include <linux/platform_device.h>
+
+#include <asm/mach/arch.h>
+#include <asm/mach/irq.h>
+#include <mach/hardware.h>
+#include <mach/map.h>
+
+#include <plat/keypad.h>
+
+static struct resource s3c_keypad_resource[] = {
+	[0] = {
+		.start = S3C_PA_KEYPAD,
+		.end   = S3C_PA_KEYPAD + S3C_SZ_KEYPAD - 1,
+		.flags = IORESOURCE_MEM,
+	},
+	[1] = {
+		.start = IRQ_KEYPAD,
+		.end   = IRQ_KEYPAD,
+		.flags = IORESOURCE_IRQ,
+	}
+};
+
+struct platform_device s3c_device_keypad = {
+	.name		= "s3c-keypad",
+	.id		= -1,
+	.num_resources 	= ARRAY_SIZE(s3c_keypad_resource),
+	.resource 	= s3c_keypad_resource,
+};
+EXPORT_SYMBOL(s3c_device_keypad);
+
+static struct s3c_platform_keypad default_keypad_data __initdata = {
+	.nr_rows = 8,
+	.nr_cols = 8,
+	.max_keys = 64,
+	.max_masks = 32,
+	.delay = 50,
+};
+
+void __init s3c_keypad_set_platdata(struct s3c_platform_keypad *pd)
+{
+	struct s3c_platform_keypad *npd;
+
+	if (!pd)
+		pd = &default_keypad_data;
+
+	npd = kmemdup(pd, sizeof(struct s3c_platform_keypad), GFP_KERNEL);
+	if (!npd)
+		printk(KERN_ERR "%s: no memory for platform data\n", __func__);
+
+	s3c_device_keypad.dev.platform_data = npd;
+}
+
Signature · 1 line
1.6.2.5
#1 lore raw

PATCH 8/12 Add platform device support for keypad driver

2009/9/5 ??? <[email protected]>:

Quoted 16 lines

This patch includes platform device information and resources support for s3c keypad driver.

---
?arch/arm/plat-s3c/dev-keypad.c | ? 66 ++++++++++++++++++++++++++++++++++++++++ ?1 files changed, 66 insertions(+), 0 deletions(-)
?create mode 100644 arch/arm/plat-s3c/dev-keypad.c

arch/arm/plat-s3c/dev-keypad.c new file +0 -0
new file mode 100644
index 0000000..74c5443

arch/arm/plat-s3c/dev-keypad.c line 1

Quoted 1 line
arch/arm/plat-s3c/dev-keypad.c new file +1 -0
@@ -0,0 +1,66 @@
+/* linux/arch/arm/plat-s3c/dev-keypad.c

Where's the copyright? Don't forget to add copyright

Quoted 47 lines
arch/arm/plat-s3c/dev-keypad.c new file +47 -0
+ *
+ * Base S3C Keypad resource and device definitions
+ *
+ * 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/kernel.h>
+#include <linux/types.h>
+#include <linux/interrupt.h>
+#include <linux/list.h>
+#include <linux/platform_device.h>
+
+#include <asm/mach/arch.h>
+#include <asm/mach/irq.h>
+#include <mach/hardware.h>
+#include <mach/map.h>
+
+#include <plat/keypad.h>
+
+static struct resource s3c_keypad_resource[] = {
+ ? ? ? [0] = {
+ ? ? ? ? ? ? ? .start = S3C_PA_KEYPAD,
+ ? ? ? ? ? ? ? .end ? = S3C_PA_KEYPAD + S3C_SZ_KEYPAD - 1,
+ ? ? ? ? ? ? ? .flags = IORESOURCE_MEM,
+ ? ? ? },
+ ? ? ? [1] = {
+ ? ? ? ? ? ? ? .start = IRQ_KEYPAD,
+ ? ? ? ? ? ? ? .end ? = IRQ_KEYPAD,
+ ? ? ? ? ? ? ? .flags = IORESOURCE_IRQ,
+ ? ? ? }
+};
+
+struct platform_device s3c_device_keypad = {
+ ? ? ? .name ? ? ? ? ? = "s3c-keypad",
+ ? ? ? .id ? ? ? ? ? ? = -1,
+ ? ? ? .num_resources ?= ARRAY_SIZE(s3c_keypad_resource),
+ ? ? ? .resource ? ? ? = s3c_keypad_resource,
+};
+EXPORT_SYMBOL(s3c_device_keypad);
+
+static struct s3c_platform_keypad default_keypad_data __initdata = {
+ ? ? ? .nr_rows = 8,
+ ? ? ? .nr_cols = 8,
+ ? ? ? .max_keys = 64,

arch/arm/plat-s3c/dev-keypad.c

Quoted 10 lines
arch/arm/plat-s3c/dev-keypad.c new file +10 -0
+ ? ? ? .max_masks = 32,
+ ? ? ? .delay = 50,
+};
+
+void __init s3c_keypad_set_platdata(struct s3c_platform_keypad *pd)
+{
+ ? ? ? struct s3c_platform_keypad *npd;
+
+ ? ? ? if (!pd)
+ ? ? ? ? ? ? ? pd = &default_keypad_data;

If you want to set the default it. just assign it at platform_device directly. No need to check pd at here.

Thank you,
Kyungmin Park

Quoted 17 lines
arch/arm/plat-s3c/dev-keypad.c new file +8 -1
+
+ ? ? ? npd = kmemdup(pd, sizeof(struct s3c_platform_keypad), GFP_KERNEL);
+ ? ? ? if (!npd)
+ ? ? ? ? ? ? ? printk(KERN_ERR "%s: no memory for platform data\n", __func__);
+
+ ? ? ? s3c_device_keypad.dev.platform_data = npd;
+}
+
--

1.6.2.5

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel at lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

#2 lore raw

PATCH 8/12 Add platform device support for keypad driver

Hi

Quoted 1 line

Where's the copyright? Don't forget to add copyright

Sorry, I'll add it.

Quoted 10 lines

arch/arm/plat-s3c/dev-keypad.c line 58

Quoted 6 lines
arch/arm/plat-s3c/dev-keypad.c new file +6 -0
+void __init s3c_keypad_set_platdata(struct s3c_platform_keypad *pd)
+{
+       struct s3c_platform_keypad *npd;
+
+       if (!pd)
+               pd = &default_keypad_data;

If you want to set the default it. just assign it at platform_device directly. No need to check pd at here.

Ok, got it. I will modify with following your comments.

Best Regards
--
Jinsung, Yang <[email protected]>
AP Development Team
System LSI, Semiconductor Business
SAMSUNG Electronics Co., LTD