All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Introduce Synology NAS x86 platform driver
@ 2026-11-20 20:11 Ondrej Zary
  2026-11-20 21:01 ` Ilpo Järvinen
  0 siblings, 1 reply; 2+ messages in thread
From: Ondrej Zary @ 2026-11-20 20:11 UTC (permalink / raw)
  To: Hans de Goede, Ilpo Järvinen; +Cc: platform-driver-x86, linux-kernel

Add platform driver for Synology x86-based NAS devices to support HDD LEDs
controller by ICH9 GPIO pins.

Only DS411+II is supported for now (DS411+ should be the same except CPU).

Buttons and other LEDs are not supported by this driver because they're
controlled by a PIC MCU (connected through serial port).

Signed-off-by: Ondrej Zary <linux@zary.sk>
---
 drivers/platform/x86/Kconfig        |  14 ++++
 drivers/platform/x86/Makefile       |   3 +
 drivers/platform/x86/synology-x86.c | 126 ++++++++++++++++++++++++++++
 3 files changed, 143 insertions(+)
 create mode 100644 drivers/platform/x86/synology-x86.c

diff --git a/drivers/platform/x86/Kconfig b/drivers/platform/x86/Kconfig
index 9ce384e0475e..04f6452b5a32 100644
--- a/drivers/platform/x86/Kconfig
+++ b/drivers/platform/x86/Kconfig
@@ -1059,6 +1059,20 @@ config OXP_EC
 
 source "drivers/platform/x86/tuxedo/Kconfig"
 
+config SYNOLOGY_X86
+	tristate "Synology x86 NAS Platform Driver"
+	depends on GPIOLIB
+	depends on LPC_ICH
+	depends on GPIO_ICH
+	depends on LEDS_CLASS
+	select LEDS_GPIO
+	help
+	  This driver provides support for the HDD LEDs on Synology x86 NAS
+	  devices.
+
+	  To compile this driver as a module, choose M here: the module
+	  will be called synology-x86.
+
 endif # X86_PLATFORM_DEVICES
 
 config P2SB
diff --git a/drivers/platform/x86/Makefile b/drivers/platform/x86/Makefile
index 229057234d00..a1806eb0efc9 100644
--- a/drivers/platform/x86/Makefile
+++ b/drivers/platform/x86/Makefile
@@ -166,3 +166,6 @@ obj-$(CONFIG_SEL3350_PLATFORM)		+= sel3350-platform.o
 
 # OneXPlayer
 obj-$(CONFIG_OXP_EC)			+= oxpec.o
+
+# Synology
+obj-$(CONFIG_SYNOLOGY_X86)		+= synology-x86.o
diff --git a/drivers/platform/x86/synology-x86.c b/drivers/platform/x86/synology-x86.c
new file mode 100644
index 000000000000..2fcf735ba3be
--- /dev/null
+++ b/drivers/platform/x86/synology-x86.c
@@ -0,0 +1,126 @@
+// SPDX-License-Identifier: GPL-2.0+
+
+/*
+ * Synology x86 NAS platform driver
+ *
+ * Inspired by platform/x86/meraki-mx100.c
+ *
+ * Copyright (C) 2026 Ondrej Zary <linux@zary.sk>
+ */
+
+#include <linux/dmi.h>
+#include <linux/pci.h>
+#include <linux/err.h>
+#include <linux/gpio/machine.h>
+#include <linux/kernel.h>
+#include <linux/leds.h>
+#include <linux/module.h>
+#include <linux/platform_device.h>
+
+static const struct gpio_led synology_leds[] = {
+	{ .name = "synology:green:hdd1"	},
+	{ .name = "synology:amber:hdd1" },
+	{ .name = "synology:green:hdd2" },
+	{ .name = "synology:amber:hdd2"	},
+	{ .name = "synology:green:hdd3" },
+	{ .name = "synology:amber:hdd3"	},
+	{ .name = "synology:green:hdd4" },
+	{ .name = "synology:amber:hdd4" },
+};
+
+static const struct gpio_led_platform_data synology_leds_pdata = {
+	.num_leds	= ARRAY_SIZE(synology_leds),
+	.leds		= synology_leds,
+};
+
+#define GPIO_ICH_DRIVER_NAME "gpio_ich"
+
+static struct gpiod_lookup_table synology_leds_table = {
+	.dev_id = "leds-gpio",
+	.table = {
+		GPIO_LOOKUP_IDX(GPIO_ICH_DRIVER_NAME, 16, NULL, 0, GPIO_ACTIVE_HIGH),
+		GPIO_LOOKUP_IDX(GPIO_ICH_DRIVER_NAME, 18, NULL, 1, GPIO_ACTIVE_HIGH),
+		GPIO_LOOKUP_IDX(GPIO_ICH_DRIVER_NAME, 20, NULL, 2, GPIO_ACTIVE_HIGH),
+		GPIO_LOOKUP_IDX(GPIO_ICH_DRIVER_NAME, 32, NULL, 3, GPIO_ACTIVE_HIGH),
+		GPIO_LOOKUP_IDX(GPIO_ICH_DRIVER_NAME, 33, NULL, 4, GPIO_ACTIVE_HIGH),
+		GPIO_LOOKUP_IDX(GPIO_ICH_DRIVER_NAME, 34, NULL, 5, GPIO_ACTIVE_HIGH),
+		GPIO_LOOKUP_IDX(GPIO_ICH_DRIVER_NAME, 49, NULL, 6, GPIO_ACTIVE_HIGH),
+		GPIO_LOOKUP_IDX(GPIO_ICH_DRIVER_NAME, 55, NULL, 7, GPIO_ACTIVE_HIGH),
+		{}
+	}
+};
+
+static const struct dmi_system_id synology_systems[] __initconst = {
+	{
+		.ident = "DS411+",	/* DS411+II is the same with faster CPU */
+		.matches = {
+			/* Synology did not put anything in DMI strings */
+			DMI_EXACT_MATCH(DMI_SYS_VENDOR, "To Be Filled By O.E.M."),
+			DMI_EXACT_MATCH(DMI_PRODUCT_NAME, "To Be Filled By O.E.M."),
+			DMI_EXACT_MATCH(DMI_BOARD_NAME, "To be filled by O.E.M."),
+			DMI_EXACT_MATCH(DMI_BIOS_DATE, "05/21/2012"),
+		},
+	},
+	{}
+};
+MODULE_DEVICE_TABLE(dmi, synology_systems);
+
+static struct platform_device *synology_leds_pdev;
+
+static int __init synology_init(void)
+{
+	int ret;
+
+	static const struct pci_device_id pci_sii3531[] = {
+		{ PCI_DEVICE_SUB(PCI_VENDOR_ID_CMD, 0x3531, PCI_VENDOR_ID_CMD, 0x3531) },
+		{ }
+	};
+
+	static const struct pci_device_id pci_i82574l[] = {
+		{ PCI_DEVICE_SUB(PCI_VENDOR_ID_INTEL, 0x10d3, PCI_VENDOR_ID_INTEL, 0x0000) },
+		{ }
+	};
+
+	const struct dmi_system_id *dmi = dmi_first_match(synology_systems);
+
+	if (!dmi)
+		return -ENODEV;
+
+	/* DS411+ DMI match is too generic, confirm by onboard PCI devices */
+	if (!strcmp(dmi->ident, "DS411+")) {
+		if (!pci_dev_present(pci_sii3531)
+		 || !pci_dev_present(pci_i82574l))
+			return -ENODEV;
+	}
+
+	pr_info("Detected Synology NAS %s\n", dmi->ident);
+
+	gpiod_add_lookup_table(&synology_leds_table);
+
+	synology_leds_pdev = platform_device_register_data(NULL,
+		"leds-gpio", PLATFORM_DEVID_NONE, &synology_leds_pdata,
+		sizeof(synology_leds_pdata));
+	if (IS_ERR(synology_leds_pdev)) {
+		pr_err("error registering platform device: %ld\n", PTR_ERR(synology_leds_pdev));
+		ret = PTR_ERR(synology_leds_pdev);
+		goto err;
+	}
+
+	return 0;
+
+err:
+	gpiod_remove_lookup_table(&synology_leds_table);
+	return ret;
+}
+module_init(synology_init);
+
+static void __exit synology_exit(void)
+{
+	platform_device_unregister(synology_leds_pdev);
+	gpiod_remove_lookup_table(&synology_leds_table);
+}
+module_exit(synology_exit);
+
+MODULE_AUTHOR("Ondrej Zary <linux@zary.sk>");
+MODULE_DESCRIPTION("Synology x86 NAS Platform Driver");
+MODULE_LICENSE("GPL");
-- 
Ondrej Zary


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

* Re: [PATCH] Introduce Synology NAS x86 platform driver
  2026-11-20 20:11 [PATCH] Introduce Synology NAS x86 platform driver Ondrej Zary
@ 2026-11-20 21:01 ` Ilpo Järvinen
  0 siblings, 0 replies; 2+ messages in thread
From: Ilpo Järvinen @ 2026-11-20 21:01 UTC (permalink / raw)
  To: Ondrej Zary; +Cc: Hans de Goede, platform-driver-x86, LKML

On Fri, 20 Nov 2026, Ondrej Zary wrote:

> Add platform driver for Synology x86-based NAS devices to support HDD LEDs
> controller by ICH9 GPIO pins.
> 
> Only DS411+II is supported for now (DS411+ should be the same except CPU).
> 
> Buttons and other LEDs are not supported by this driver because they're
> controlled by a PIC MCU (connected through serial port).
> 
> Signed-off-by: Ondrej Zary <linux@zary.sk>
> ---
>  drivers/platform/x86/Kconfig        |  14 ++++
>  drivers/platform/x86/Makefile       |   3 +
>  drivers/platform/x86/synology-x86.c | 126 ++++++++++++++++++++++++++++
>  3 files changed, 143 insertions(+)
>  create mode 100644 drivers/platform/x86/synology-x86.c
> 
> diff --git a/drivers/platform/x86/Kconfig b/drivers/platform/x86/Kconfig
> index 9ce384e0475e..04f6452b5a32 100644
> --- a/drivers/platform/x86/Kconfig
> +++ b/drivers/platform/x86/Kconfig
> @@ -1059,6 +1059,20 @@ config OXP_EC
>  
>  source "drivers/platform/x86/tuxedo/Kconfig"
>  
> +config SYNOLOGY_X86
> +	tristate "Synology x86 NAS Platform Driver"
> +	depends on GPIOLIB
> +	depends on LPC_ICH
> +	depends on GPIO_ICH
> +	depends on LEDS_CLASS
> +	select LEDS_GPIO
> +	help
> +	  This driver provides support for the HDD LEDs on Synology x86 NAS
> +	  devices.
> +
> +	  To compile this driver as a module, choose M here: the module
> +	  will be called synology-x86.
> +
>  endif # X86_PLATFORM_DEVICES
>  
>  config P2SB
> diff --git a/drivers/platform/x86/Makefile b/drivers/platform/x86/Makefile
> index 229057234d00..a1806eb0efc9 100644
> --- a/drivers/platform/x86/Makefile
> +++ b/drivers/platform/x86/Makefile
> @@ -166,3 +166,6 @@ obj-$(CONFIG_SEL3350_PLATFORM)		+= sel3350-platform.o
>  
>  # OneXPlayer
>  obj-$(CONFIG_OXP_EC)			+= oxpec.o
> +
> +# Synology
> +obj-$(CONFIG_SYNOLOGY_X86)		+= synology-x86.o
> diff --git a/drivers/platform/x86/synology-x86.c b/drivers/platform/x86/synology-x86.c
> new file mode 100644
> index 000000000000..2fcf735ba3be
> --- /dev/null
> +++ b/drivers/platform/x86/synology-x86.c
> @@ -0,0 +1,126 @@
> +// SPDX-License-Identifier: GPL-2.0+
> +

Extra empty line.

> +/*
> + * Synology x86 NAS platform driver
> + *
> + * Inspired by platform/x86/meraki-mx100.c
> + *
> + * Copyright (C) 2026 Ondrej Zary <linux@zary.sk>
> + */
> +
> +#include <linux/dmi.h>
> +#include <linux/pci.h>

Please order alphabetically.

> +#include <linux/err.h>
> +#include <linux/gpio/machine.h>
> +#include <linux/kernel.h>

What for is this?

> +#include <linux/leds.h>
> +#include <linux/module.h>
> +#include <linux/platform_device.h>
> +
> +static const struct gpio_led synology_leds[] = {
> +	{ .name = "synology:green:hdd1"	},
> +	{ .name = "synology:amber:hdd1" },
> +	{ .name = "synology:green:hdd2" },
> +	{ .name = "synology:amber:hdd2"	},
> +	{ .name = "synology:green:hdd3" },
> +	{ .name = "synology:amber:hdd3"	},
> +	{ .name = "synology:green:hdd4" },
> +	{ .name = "synology:amber:hdd4" },
> +};
> +
> +static const struct gpio_led_platform_data synology_leds_pdata = {
> +	.num_leds	= ARRAY_SIZE(synology_leds),

Add include.

> +	.leds		= synology_leds,
> +};
> +
> +#define GPIO_ICH_DRIVER_NAME "gpio_ich"
> +
> +static struct gpiod_lookup_table synology_leds_table = {
> +	.dev_id = "leds-gpio",
> +	.table = {
> +		GPIO_LOOKUP_IDX(GPIO_ICH_DRIVER_NAME, 16, NULL, 0, GPIO_ACTIVE_HIGH),
> +		GPIO_LOOKUP_IDX(GPIO_ICH_DRIVER_NAME, 18, NULL, 1, GPIO_ACTIVE_HIGH),
> +		GPIO_LOOKUP_IDX(GPIO_ICH_DRIVER_NAME, 20, NULL, 2, GPIO_ACTIVE_HIGH),
> +		GPIO_LOOKUP_IDX(GPIO_ICH_DRIVER_NAME, 32, NULL, 3, GPIO_ACTIVE_HIGH),
> +		GPIO_LOOKUP_IDX(GPIO_ICH_DRIVER_NAME, 33, NULL, 4, GPIO_ACTIVE_HIGH),
> +		GPIO_LOOKUP_IDX(GPIO_ICH_DRIVER_NAME, 34, NULL, 5, GPIO_ACTIVE_HIGH),
> +		GPIO_LOOKUP_IDX(GPIO_ICH_DRIVER_NAME, 49, NULL, 6, GPIO_ACTIVE_HIGH),
> +		GPIO_LOOKUP_IDX(GPIO_ICH_DRIVER_NAME, 55, NULL, 7, GPIO_ACTIVE_HIGH),
> +		{}
> +	}
> +};
> +
> +static const struct dmi_system_id synology_systems[] __initconst = {
> +	{
> +		.ident = "DS411+",	/* DS411+II is the same with faster CPU */
> +		.matches = {
> +			/* Synology did not put anything in DMI strings */
> +			DMI_EXACT_MATCH(DMI_SYS_VENDOR, "To Be Filled By O.E.M."),
> +			DMI_EXACT_MATCH(DMI_PRODUCT_NAME, "To Be Filled By O.E.M."),
> +			DMI_EXACT_MATCH(DMI_BOARD_NAME, "To be filled by O.E.M."),
> +			DMI_EXACT_MATCH(DMI_BIOS_DATE, "05/21/2012"),
> +		},
> +	},
> +	{}
> +};
> +MODULE_DEVICE_TABLE(dmi, synology_systems);
> +
> +static struct platform_device *synology_leds_pdev;
> +
> +static int __init synology_init(void)
> +{
> +	int ret;
> +
> +	static const struct pci_device_id pci_sii3531[] = {
> +		{ PCI_DEVICE_SUB(PCI_VENDOR_ID_CMD, 0x3531, PCI_VENDOR_ID_CMD, 0x3531) },

Some include is surely missing.

> +		{ }
> +	};
> +
> +	static const struct pci_device_id pci_i82574l[] = {
> +		{ PCI_DEVICE_SUB(PCI_VENDOR_ID_INTEL, 0x10d3, PCI_VENDOR_ID_INTEL, 0x0000) },
> +		{ }
> +	};
> +
> +	const struct dmi_system_id *dmi = dmi_first_match(synology_systems);

Are you missing DMI dep from Kconfig?

> +
> +	if (!dmi)
> +		return -ENODEV;
> +
> +	/* DS411+ DMI match is too generic, confirm by onboard PCI devices */
> +	if (!strcmp(dmi->ident, "DS411+")) {

Include.

> +		if (!pci_dev_present(pci_sii3531)
> +		 || !pci_dev_present(pci_i82574l))

|| should be on the previous line.

Should this depend on PCI too?

Details missing from the changelog.

> +			return -ENODEV;
> +	}
> +
> +	pr_info("Detected Synology NAS %s\n", dmi->ident);

Missing include.

> +
> +	gpiod_add_lookup_table(&synology_leds_table);
> +
> +	synology_leds_pdev = platform_device_register_data(NULL,
> +		"leds-gpio", PLATFORM_DEVID_NONE, &synology_leds_pdata,
> +		sizeof(synology_leds_pdata));
> +	if (IS_ERR(synology_leds_pdev)) {
> +		pr_err("error registering platform device: %ld\n", PTR_ERR(synology_leds_pdev));

Use %pe

> +		ret = PTR_ERR(synology_leds_pdev);
> +		goto err;
> +	}
> +
> +	return 0;
> +
> +err:
> +	gpiod_remove_lookup_table(&synology_leds_table);
> +	return ret;
> +}
> +module_init(synology_init);
> +
> +static void __exit synology_exit(void)
> +{
> +	platform_device_unregister(synology_leds_pdev);
> +	gpiod_remove_lookup_table(&synology_leds_table);
> +}
> +module_exit(synology_exit);
> +
> +MODULE_AUTHOR("Ondrej Zary <linux@zary.sk>");
> +MODULE_DESCRIPTION("Synology x86 NAS Platform Driver");
> +MODULE_LICENSE("GPL");
> 

-- 
 i.


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

end of thread, other threads:[~2026-11-20 21:01 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-20 20:11 [PATCH] Introduce Synology NAS x86 platform driver Ondrej Zary
2026-11-20 21:01 ` Ilpo Järvinen

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.