From: Dmitry Torokhov <dmitry.torokhov@gmail.com>
To: Arnd Bergmann <arnd@arndb.de>, Mark Brown <broonie@kernel.org>,
Krzysztof Kozlowski <krzk@kernel.org>
Cc: linux-input@vger.kernel.org, devicetree@vger.kernel.org,
linux-kernel@vger.kernel.org,
linux-arm-kernel@lists.infradead.org,
linux-samsung-soc@vger.kernel.org, patches@opensource.cirrus.com
Subject: [PATCH 13/14] ARM: s3c: crag6410: use software nodes/properties to set up GPIO keys
Date: Sun, 18 Aug 2024 21:58:10 -0700 [thread overview]
Message-ID: <20240819045813.2154642-14-dmitry.torokhov@gmail.com> (raw)
In-Reply-To: <20240819045813.2154642-1-dmitry.torokhov@gmail.com>
Switch the gpio-keys device to use software inodes/properties to
describe the buttons and switches. This will allow dropping support
for platform data from the gpio-keys driver in the future.
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
---
arch/arm/mach-s3c/gpio-samsung-s3c64xx.h | 5 ++
arch/arm/mach-s3c/gpio-samsung.c | 35 +++++++++++
arch/arm/mach-s3c/mach-crag6410.c | 80 +++++++++++++++++-------
3 files changed, 99 insertions(+), 21 deletions(-)
diff --git a/arch/arm/mach-s3c/gpio-samsung-s3c64xx.h b/arch/arm/mach-s3c/gpio-samsung-s3c64xx.h
index 8ed144a0d474..7cf16cc085ea 100644
--- a/arch/arm/mach-s3c/gpio-samsung-s3c64xx.h
+++ b/arch/arm/mach-s3c/gpio-samsung-s3c64xx.h
@@ -13,6 +13,8 @@
#ifdef CONFIG_GPIO_SAMSUNG
+#include <linux/property.h>
+
/* GPIO bank sizes */
#define S3C64XX_GPIO_A_NR (8)
#define S3C64XX_GPIO_B_NR (7)
@@ -89,6 +91,9 @@ enum s3c_gpio_number {
/* define the number of gpios we need to the one after the GPQ() range */
#define GPIO_BOARD_START (S3C64XX_GPQ(S3C64XX_GPIO_Q_NR) + 1)
+extern const struct software_node samsung_gpiochip_nodes[];
+#define SAMSUNG_GPIO_NODE(node) &samsung_gpiochip_nodes[(node) - 'A']
+
#endif /* GPIO_SAMSUNG */
#endif /* GPIO_SAMSUNG_S3C64XX_H */
diff --git a/arch/arm/mach-s3c/gpio-samsung.c b/arch/arm/mach-s3c/gpio-samsung.c
index 87daaa09e2c3..82f325112d30 100644
--- a/arch/arm/mach-s3c/gpio-samsung.c
+++ b/arch/arm/mach-s3c/gpio-samsung.c
@@ -21,6 +21,7 @@
#include <linux/device.h>
#include <linux/ioport.h>
#include <linux/of.h>
+#include <linux/property.h>
#include <linux/slab.h>
#include <linux/of_address.h>
@@ -788,6 +789,38 @@ static struct samsung_gpio_chip s3c64xx_gpios_2bit[] = {
},
};
+const struct software_node samsung_gpiochip_nodes[] = {
+ SOFTWARE_NODE("GPA", NULL, NULL),
+ SOFTWARE_NODE("GPB", NULL, NULL),
+ SOFTWARE_NODE("GPC", NULL, NULL),
+ SOFTWARE_NODE("GPD", NULL, NULL),
+ SOFTWARE_NODE("GPE", NULL, NULL),
+ SOFTWARE_NODE("GPF", NULL, NULL),
+ SOFTWARE_NODE("GPG", NULL, NULL),
+ SOFTWARE_NODE("GPH", NULL, NULL),
+ SOFTWARE_NODE("GPI", NULL, NULL),
+ SOFTWARE_NODE("GPJ", NULL, NULL),
+ SOFTWARE_NODE("GPK", NULL, NULL),
+ SOFTWARE_NODE("GPL", NULL, NULL),
+ SOFTWARE_NODE("GPM", NULL, NULL),
+ SOFTWARE_NODE("GPN", NULL, NULL),
+ SOFTWARE_NODE("GPO", NULL, NULL),
+ SOFTWARE_NODE("GPP", NULL, NULL),
+ SOFTWARE_NODE("GPQ", NULL, NULL),
+};
+#define NUM_SAMSUNG_GPIOCHIPS ARRAY_SIZE(samsung_gpiochip_nodes)
+
+static void __init samsung_setup_gpiochip_nodes(void)
+{
+ const struct software_node *group[NUM_SAMSUNG_GPIOCHIPS + 1] = { 0 };
+ int i;
+
+ for (i = 0; i < NUM_SAMSUNG_GPIOCHIPS; i++)
+ group[i] = &samsung_gpiochip_nodes[i];
+
+ software_node_register_node_group(group);
+}
+
/* TODO: cleanup soc_is_* */
static __init int samsung_gpiolib_init(void)
{
@@ -811,6 +844,8 @@ static __init int samsung_gpiolib_init(void)
S3C64XX_VA_GPIO);
samsung_gpiolib_add_4bit2_chips(s3c64xx_gpios_4bit2,
ARRAY_SIZE(s3c64xx_gpios_4bit2));
+
+ samsung_setup_gpiochip_nodes();
}
return 0;
diff --git a/arch/arm/mach-s3c/mach-crag6410.c b/arch/arm/mach-s3c/mach-crag6410.c
index 16b6ef312aaf..6aa74db08af9 100644
--- a/arch/arm/mach-s3c/mach-crag6410.c
+++ b/arch/arm/mach-s3c/mach-crag6410.c
@@ -18,11 +18,13 @@
#include <linux/input/matrix_keypad.h>
#include <linux/gpio.h>
#include <linux/gpio/machine.h>
+#include <linux/gpio/property.h>
#include <linux/leds.h>
#include <linux/delay.h>
#include <linux/mmc/host.h>
#include <linux/regulator/machine.h>
#include <linux/regulator/fixed.h>
+#include <linux/property.h>
#include <linux/pwm.h>
#include <linux/pwm_backlight.h>
#include <linux/dm9000.h>
@@ -227,32 +229,68 @@ static void __init crag6410_setup_keypad(void)
pr_err("failed to instantiate keypad device");
}
-static struct gpio_keys_button crag6410_gpio_keys[] = {
- [0] = {
- .code = KEY_SUSPEND,
- .gpio = S3C64XX_GPL(10), /* EINT 18 */
- .type = EV_KEY,
- .wakeup = 1,
- .active_low = 1,
- },
- [1] = {
- .code = SW_FRONT_PROXIMITY,
- .gpio = S3C64XX_GPN(11), /* EINT 11 */
- .type = EV_SW,
- },
+static const struct software_node crag6410_gpio_keys_node = {
+ .name = "crag6410-gpio-keys",
};
-static struct gpio_keys_platform_data crag6410_gpio_keydata = {
- .buttons = crag6410_gpio_keys,
- .nbuttons = ARRAY_SIZE(crag6410_gpio_keys),
+static const struct property_entry crag6410_suspend_key_props[] = {
+ PROPERTY_ENTRY_U32("linux,code", KEY_SUSPEND),
+ PROPERTY_ENTRY_GPIO("gpios",
+ SAMSUNG_GPIO_NODE('L'), 10, /* EINT 18 */
+ GPIO_ACTIVE_LOW),
+ PROPERTY_ENTRY_BOOL("wakeup-source"),
+ { }
};
-static struct platform_device crag6410_gpio_keydev = {
- .name = "gpio-keys",
- .id = 0,
- .dev.platform_data = &crag6410_gpio_keydata,
+static const struct software_node crag6410_suspend_key_node = {
+ .parent = &crag6410_gpio_keys_node,
+ .properties = crag6410_suspend_key_props,
+};
+
+static const struct property_entry crag6410_prox_sw_props[] = {
+ PROPERTY_ENTRY_U32("linux,type", EV_SW),
+ PROPERTY_ENTRY_U32("linux,code", SW_FRONT_PROXIMITY),
+ PROPERTY_ENTRY_GPIO("gpios",
+ SAMSUNG_GPIO_NODE('N'), 11, /* EINT 11 */
+ GPIO_ACTIVE_HIGH),
+ { }
+};
+
+static const struct software_node crag6410_prox_sw_node = {
+ .parent = &crag6410_gpio_keys_node,
+ .properties = crag6410_prox_sw_props,
};
+static const struct software_node *crag6410_gpio_keys_swnodes[] = {
+ &crag6410_gpio_keys_node,
+ &crag6410_suspend_key_node,
+ &crag6410_prox_sw_node,
+ NULL
+};
+
+static void __init crag6410_setup_gpio_keys(void)
+{
+ struct platform_device_info keys_info = {
+ .name = "gpio-keys",
+ .id = 0,
+ };
+ struct platform_device *pd;
+ int err;
+
+ err = software_node_register_node_group(crag6410_gpio_keys_swnodes);
+ if (err) {
+ pr_err("failed to register gpio-keys software nodes: %d\n", err);
+ return;
+ }
+
+ keys_info.fwnode = software_node_fwnode(&crag6410_gpio_keys_node);
+
+ pd = platform_device_register_full(&keys_info);
+ err = PTR_ERR_OR_ZERO(pd);
+ if (err)
+ pr_err("failed to create gpio-keys device: %d\n", err);
+}
+
static struct resource crag6410_dm9k_resource[] = {
[0] = DEFINE_RES_MEM(S3C64XX_PA_XM0CSN5, 2),
[1] = DEFINE_RES_MEM(S3C64XX_PA_XM0CSN5 + (1 << 8), 2),
@@ -393,7 +431,6 @@ static struct platform_device *crag6410_devs0[] __initdata = {
&samsung_device_pwm,
&s3c64xx_device_iis0,
&s3c64xx_device_iis1,
- &crag6410_gpio_keydev,
};
static struct platform_device *crag6410_devs1[] __initdata = {
@@ -897,6 +934,7 @@ static void __init crag6410_machine_init(void)
platform_add_devices(crag6410_devs0, ARRAY_SIZE(crag6410_devs0));
crag6410_setup_keypad();
+ crag6410_setup_gpio_keys();
platform_add_devices(crag6410_devs1, ARRAY_SIZE(crag6410_devs1));
--
2.46.0.184.g6999bdac58-goog
next prev parent reply other threads:[~2024-08-19 4:58 UTC|newest]
Thread overview: 39+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-08-19 4:57 [PATCH 00/14] Remove support for platform data from samsung keypad Dmitry Torokhov
2024-08-19 4:57 ` [PATCH 01/14] Input: samsung-keypad - switch to using devm_clk_get_prepared() Dmitry Torokhov
2024-08-19 12:51 ` Krzysztof Kozlowski
2024-08-19 14:46 ` Dmitry Torokhov
2024-08-19 4:57 ` [PATCH 02/14] Input: samsung-keypad - do not set input device's parent explicitly Dmitry Torokhov
2024-08-19 12:51 ` Krzysztof Kozlowski
2024-08-19 4:58 ` [PATCH 03/14] Input: samsung-keypad - do not combine memory allocation checks Dmitry Torokhov
2024-08-19 12:52 ` Krzysztof Kozlowski
2024-08-19 4:58 ` [PATCH 04/14] Input: samsung-keypad - use struct_size() helper Dmitry Torokhov
2024-08-19 12:52 ` Krzysztof Kozlowski
2024-08-19 4:58 ` [PATCH 05/14] Input: samsung-keypad - use devm to disable runtime PM Dmitry Torokhov
2024-08-19 12:54 ` Krzysztof Kozlowski
2024-08-19 14:47 ` Dmitry Torokhov
2024-08-19 4:58 ` [PATCH 06/14] Input: samsung-keypad - use guard notation to acquire mutex Dmitry Torokhov
2024-08-22 15:48 ` Krzysztof Kozlowski
2024-08-22 18:07 ` Dmitry Torokhov
2024-08-23 6:06 ` Krzysztof Kozlowski
2024-08-23 8:32 ` Dmitry Torokhov
2024-08-23 8:52 ` Krzysztof Kozlowski
2024-08-23 15:41 ` Dmitry Torokhov
2024-08-19 4:58 ` [PATCH 07/14] Input: samsung-keypad - use per-chip parameters Dmitry Torokhov
2024-08-19 12:57 ` Krzysztof Kozlowski
2024-08-19 4:58 ` [PATCH 08/14] Input: samsung-keypad - use BIT() and GENMASK() where appropriate Dmitry Torokhov
2024-08-19 4:58 ` [PATCH 09/14] dt-bindings: input: samsung,s3c6410-keypad: introduce compact binding Dmitry Torokhov
2024-08-19 13:02 ` Krzysztof Kozlowski
2024-08-19 15:49 ` Dmitry Torokhov
2024-08-19 16:48 ` Conor Dooley
2024-08-19 17:14 ` Dmitry Torokhov
2024-08-19 4:58 ` [PATCH 10/14] Input: samsung-keypad - handle " Dmitry Torokhov
2024-08-19 4:58 ` [PATCH 11/14] ARM: s3c: crag6410: switch keypad device to software properties Dmitry Torokhov
2024-08-22 15:41 ` Krzysztof Kozlowski
2024-08-19 4:58 ` [PATCH 12/14] Input: samsung-keypad - remove support for platform data Dmitry Torokhov
2024-08-19 4:58 ` Dmitry Torokhov [this message]
2024-08-22 15:50 ` [PATCH 13/14] ARM: s3c: crag6410: use software nodes/properties to set up GPIO keys Krzysztof Kozlowski
2024-08-19 4:58 ` [PATCH 14/14] ARM: s3c: crag6410 - convert GPIO lookup tables to property entries Dmitry Torokhov
2024-08-22 15:49 ` Krzysztof Kozlowski
2024-08-19 9:40 ` [PATCH 00/14] Remove support for platform data from samsung keypad Arnd Bergmann
2024-10-04 13:38 ` Dmitry Torokhov
2024-10-04 14:58 ` Mark Brown
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240819045813.2154642-14-dmitry.torokhov@gmail.com \
--to=dmitry.torokhov@gmail.com \
--cc=arnd@arndb.de \
--cc=broonie@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=krzk@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-input@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-samsung-soc@vger.kernel.org \
--cc=patches@opensource.cirrus.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).