Skip to contentSkip to conversation

Introduce Synology x86 NAS LEDs driver

PATCH In review Ondrej Zary 2 participants 5 messages Nov 24 x86 platform drivers

lore
Share & tools
lore
#0 lore raw

PATCH v3 1/1 Introduce Synology x86 NAS LEDs driver

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

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

Unfortunately, the DMI data in BIOS is not very helpful to identify the device as almost all strings are "To be filled by O.E.M.". Match also the BIOS date and then check presence of PCI devices (host bridge, LPC bridge, onboard SiI3531 SATA controller and i82574L ethernet controller) to avoid activation on other systems.

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

---
Changes in v3:
- descriptions changed to mention LEDs
- GPIO swnodes are used instead of gpiod
- improved PCI device presence checking

Changes in v2:
- fixed includes (order, added missing, removed kernel.h)
- added missing DMI and PCI dependencies to Kconfig
- added PCI device presence check details to changelog
- used %pe for error message

---
 drivers/platform/x86/Kconfig        |  16 ++
 drivers/platform/x86/Makefile       |   3 +
 drivers/platform/x86/synology-x86.c | 253 ++++++++++++++++++++++++++++
 3 files changed, 272 insertions(+)
 create mode 100644 drivers/platform/x86/synology-x86.c
drivers/platform/x86/Kconfig +16 -0
index 9ce384e0475e..64aa44c7f239 100644
@@ -1059,6 +1059,22 @@ config OXP_EC
 
 source "drivers/platform/x86/tuxedo/Kconfig"
 
+config SYNOLOGY_X86
+	tristate "Synology x86 NAS LEDs driver"
+	depends on DMI
+	depends on GPIOLIB
+	depends on LPC_ICH
+	depends on GPIO_ICH
+	depends on LEDS_CLASS
+	depends on PCI
+	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
drivers/platform/x86/Makefile +3 -0
index 229057234d00..a1806eb0efc9 100644
@@ -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
drivers/platform/x86/synology-x86.c new file +253 -0

253 lines not on this page · raw message

Signature · 1 line
Ondrej Zary
#1 lore raw
Quoted 13 lines · Ondrej Zary

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

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

Unfortunately, the DMI data in BIOS is not very helpful to identify the device as almost all strings are "To be filled by O.E.M.". Match also the BIOS date and then check presence of PCI devices (host bridge, LPC bridge, onboard SiI3531 SATA controller and i82574L ethernet controller) to avoid activation on other systems.

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

...

Quoted 30 lines
drivers/platform/x86/synology-x86.c new file +27 -0
+struct synology_pci_dev {
+	unsigned int bus;
+	unsigned int devfn;
+	struct pci_device_id id;
+};
+
+/* onboard PCI devices found in DS411+ to confirm the machine type (after DMI match) */
+static const struct synology_pci_dev ds411plus_pci_devices[] __initconst = {
+	/* 00:00.0 Host bridge: Intel Corporation Atom Processor D4xx/D5xx/N4xx/N5xx DMI Bridge */
+	{ 0, PCI_DEVFN(0, 0), { PCI_DEVICE_SUB(PCI_VENDOR_ID_INTEL, 0xa000,
+					       PCI_VENDOR_ID_INTEL, 0xa000) } },
+	/* 00:1f.0 ISA bridge: Intel Corporation 82801IR (ICH9R) LPC Interface Controller */
+	{ 0, PCI_DEVFN(0x1f, 0), { PCI_DEVICE_SUB(PCI_VENDOR_ID_INTEL, 0x2916,
+						  PCI_VENDOR_ID_INTEL, 0x2916) } },
 
+	/* 02:00.0 Mass storage controller: Silicon Image, Inc. SiI 3531 Serial ATA Controller */
+	{ 2, PCI_DEVFN(0x00, 0), { PCI_DEVICE_SUB(PCI_VENDOR_ID_CMD, 0x3531,
+						  PCI_VENDOR_ID_CMD, 0x3531) } },
+	/* 03:00.0 Ethernet controller: Intel Corporation 82574L Gigabit Network Connection */
+	{ 3, PCI_DEVFN(0x00, 0), { PCI_DEVICE_SUB(PCI_VENDOR_ID_INTEL, 0x10d3,
+						  PCI_VENDOR_ID_INTEL, 0x0000) } },
+	{}
 
+};
 
+/* check if all PCI devices in the list are present at specified locations */
+static bool __init synology_pci_devices_present(const struct synology_pci_dev *list)
+{
+	const struct synology_pci_dev *d;
+

drivers/platform/x86/synology-x86.c line 190

Quoted 10 lines
drivers/platform/x86/synology-x86.c new file +9 -0
+	for (d = list; d->id.vendor; d++) {
+		struct pci_dev *pdev = pci_get_domain_bus_and_slot(0, d->bus, d->devfn);
+
+		if (!pdev)
+			return false;
 
+		bool matched = d->id.vendor == pdev->vendor &&
+			       d->id.device == pdev->device &&
+			       d->id.subvendor == pdev->subsystem_vendor &&
+			       d->id.subdevice == pdev->subsystem_device;

Don't mix variable definitions with the code (it's exceptionally possible for a couple of cases, none of which is this one). Can't it use pci_match_id() approach with driver_data? (If we ever need this check.)

drivers/platform/x86/synology-x86.c line 198

Quoted 7 lines
drivers/platform/x86/synology-x86.c new file +7 -0
+		pci_dev_put(pdev);
+		if (!matched)
+			return false;
+	}
+
+	return true;
+}

Yeah, this becomes an ugly part of the patch...

...

drivers/platform/x86/synology-x86.c line 209

Quoted 9 lines
drivers/platform/x86/synology-x86.c new file +8 -0
+static int __init synology_init(void)
+{
+	struct platform_device_info leds_info = {
+		.name = "leds-gpio",
+		.id = PLATFORM_DEVID_NONE,
+	};
+	int err;
 
+

No blank line in the definition block.

drivers/platform/x86/synology-x86.c line 210

Quoted 1 line
drivers/platform/x86/synology-x86.c new file +1 -0
+	const struct dmi_system_id *dmi = dmi_first_match(synology_systems);

Split assignment and keep the variables in reversed xmas tree order.

Quoted 29 lines
drivers/platform/x86/synology-x86.c new file +29 -0
+	if (!dmi)
+		return -ENODEV;
+
+	/* DS411+ DMI match is too generic, confirm by onboard PCI devices */
+	if (!strcmp(dmi->ident, "DS411+") && !synology_pci_devices_present(ds411plus_pci_devices))
+		return -ENODEV;
+
+	pr_info("Detected Synology NAS %s\n", dmi->ident);
+
+	err = software_node_register_node_group(synology_swnodes);
+	if (err) {
+		pr_err("failed to register software nodes: %d\n", err);
+		return err;
+	}
+
+	leds_info.fwnode = software_node_fwnode(&synology_gpio_leds_node);
+	synology_leds_pdev = platform_device_register_full(&leds_info);
+	err = PTR_ERR_OR_ZERO(synology_leds_pdev);
+	if (err) {
+		pr_err("error registering platform device: %pe\n", synology_leds_pdev);
+		goto err_unregister;
+	}
+
+	return 0;
+
+err_unregister:
+	software_node_unregister_node_group(synology_swnodes);
+	return err;
+}
Signature · 2 lines
With Best Regards,
Andy Shevchenko
#2 lore raw
Quoted 53 lines · On Tuesday 24 November 2026 18:03:00 Andy Shevchenko wrote:
Quoted 13 lines · Ondrej Zary

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

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

Unfortunately, the DMI data in BIOS is not very helpful to identify the device as almost all strings are "To be filled by O.E.M.". Match also the BIOS date and then check presence of PCI devices (host bridge, LPC bridge, onboard SiI3531 SATA controller and i82574L ethernet controller) to avoid activation on other systems.

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

...

Quoted 35 lines
drivers/platform/x86/synology-x86.c new file +32 -0
+struct synology_pci_dev {
+	unsigned int bus;
+	unsigned int devfn;
+	struct pci_device_id id;
+};
+
+/* onboard PCI devices found in DS411+ to confirm the machine type (after DMI match) */
+static const struct synology_pci_dev ds411plus_pci_devices[] __initconst = {
+	/* 00:00.0 Host bridge: Intel Corporation Atom Processor D4xx/D5xx/N4xx/N5xx DMI Bridge */
+	{ 0, PCI_DEVFN(0, 0), { PCI_DEVICE_SUB(PCI_VENDOR_ID_INTEL, 0xa000,
+					       PCI_VENDOR_ID_INTEL, 0xa000) } },
+	/* 00:1f.0 ISA bridge: Intel Corporation 82801IR (ICH9R) LPC Interface Controller */
+	{ 0, PCI_DEVFN(0x1f, 0), { PCI_DEVICE_SUB(PCI_VENDOR_ID_INTEL, 0x2916,
+						  PCI_VENDOR_ID_INTEL, 0x2916) } },
 
+	/* 02:00.0 Mass storage controller: Silicon Image, Inc. SiI 3531 Serial ATA Controller */
+	{ 2, PCI_DEVFN(0x00, 0), { PCI_DEVICE_SUB(PCI_VENDOR_ID_CMD, 0x3531,
+						  PCI_VENDOR_ID_CMD, 0x3531) } },
+	/* 03:00.0 Ethernet controller: Intel Corporation 82574L Gigabit Network Connection */
+	{ 3, PCI_DEVFN(0x00, 0), { PCI_DEVICE_SUB(PCI_VENDOR_ID_INTEL, 0x10d3,
+						  PCI_VENDOR_ID_INTEL, 0x0000) } },
+	{}
 
+};
 
+/* check if all PCI devices in the list are present at specified locations */
+static bool __init synology_pci_devices_present(const struct synology_pci_dev *list)
+{
+	const struct synology_pci_dev *d;
+
+	for (d = list; d->id.vendor; d++) {
+		struct pci_dev *pdev = pci_get_domain_bus_and_slot(0, d->bus, d->devfn);
+
+		if (!pdev)
+			return false;
Quoted 8 lines

drivers/platform/x86/synology-x86.c line 190

Quoted 4 lines
drivers/platform/x86/synology-x86.c new file +4 -0
+		bool matched = d->id.vendor == pdev->vendor &&
+			       d->id.device == pdev->device &&
+			       d->id.subvendor == pdev->subsystem_vendor &&
+			       d->id.subdevice == pdev->subsystem_device;

Don't mix variable definitions with the code (it's exceptionally possible for a couple of cases, none of which is this one). Can't it use pci_match_id() approach with driver_data? (If we ever need this check.)

I don't see how can pci_match_id() be used here. I can merge pci bus and devfun into driver_data to fit into pci_device_id table but there's no pci_dev which could be matched against that table (and walking all PCI devices does not seem to be an improvement).

Signature · 1 line
Ondrej Zary
#3 lore raw
Quoted 2 lines · Ondrej Zary
Quoted 1 line · On Tuesday 24 November 2026 18:03:00 Andy Shevchenko wrote:

On Tue, Nov 24, 2026 at 01:45:46PM +0100, Ondrej Zary wrote:

...

Quoted 45 lines
Quoted 36 lines
Quoted 35 lines
drivers/platform/x86/synology-x86.c new file +32 -0
+struct synology_pci_dev {
+	unsigned int bus;
+	unsigned int devfn;
+	struct pci_device_id id;
+};
+
+/* onboard PCI devices found in DS411+ to confirm the machine type (after DMI match) */
+static const struct synology_pci_dev ds411plus_pci_devices[] __initconst = {
+	/* 00:00.0 Host bridge: Intel Corporation Atom Processor D4xx/D5xx/N4xx/N5xx DMI Bridge */
+	{ 0, PCI_DEVFN(0, 0), { PCI_DEVICE_SUB(PCI_VENDOR_ID_INTEL, 0xa000,
+					       PCI_VENDOR_ID_INTEL, 0xa000) } },
+	/* 00:1f.0 ISA bridge: Intel Corporation 82801IR (ICH9R) LPC Interface Controller */
+	{ 0, PCI_DEVFN(0x1f, 0), { PCI_DEVICE_SUB(PCI_VENDOR_ID_INTEL, 0x2916,
+						  PCI_VENDOR_ID_INTEL, 0x2916) } },
 
+	/* 02:00.0 Mass storage controller: Silicon Image, Inc. SiI 3531 Serial ATA Controller */
+	{ 2, PCI_DEVFN(0x00, 0), { PCI_DEVICE_SUB(PCI_VENDOR_ID_CMD, 0x3531,
+						  PCI_VENDOR_ID_CMD, 0x3531) } },
+	/* 03:00.0 Ethernet controller: Intel Corporation 82574L Gigabit Network Connection */
+	{ 3, PCI_DEVFN(0x00, 0), { PCI_DEVICE_SUB(PCI_VENDOR_ID_INTEL, 0x10d3,
+						  PCI_VENDOR_ID_INTEL, 0x0000) } },
+	{}
 
+};
 
+/* check if all PCI devices in the list are present at specified locations */
+static bool __init synology_pci_devices_present(const struct synology_pci_dev *list)
+{
+	const struct synology_pci_dev *d;
+
+	for (d = list; d->id.vendor; d++) {
+		struct pci_dev *pdev = pci_get_domain_bus_and_slot(0, d->bus, d->devfn);
+
+		if (!pdev)
+			return false;
Quoted 8 lines

drivers/platform/x86/synology-x86.c line 190

Quoted 4 lines
drivers/platform/x86/synology-x86.c new file +4 -0
+		bool matched = d->id.vendor == pdev->vendor &&
+			       d->id.device == pdev->device &&
+			       d->id.subvendor == pdev->subsystem_vendor &&
+			       d->id.subdevice == pdev->subsystem_device;

Don't mix variable definitions with the code (it's exceptionally possible for a couple of cases, none of which is this one). Can't it use pci_match_id() approach with driver_data? (If we ever need this check.)

Quoted 4 lines

I don't see how can pci_match_id() be used here. I can merge pci bus and devfun into driver_data to fit into pci_device_id table but there's no pci_dev which could be matched against that table (and walking all PCI devices does not seem to be an improvement).

_After_ DMI match the walk over all PCI devices is not a big deal. The code will be nicer. But maybe there is a better choice? Like checking CPUID? Or maybe something interesting is present in the ACPI tables?

Signature · 2 lines
With Best Regards,
Andy Shevchenko
#4 lore raw
Quoted 51 lines · On Tuesday 24 November 2026 21:13:21 Andy Shevchenko wrote:
Quoted 2 lines · Ondrej Zary
Quoted 1 line · On Tuesday 24 November 2026 18:03:00 Andy Shevchenko wrote:

On Tue, Nov 24, 2026 at 01:45:46PM +0100, Ondrej Zary wrote:

...

Quoted 45 lines
Quoted 44 lines
Quoted 30 lines
drivers/platform/x86/synology-x86.c new file +27 -0
+struct synology_pci_dev {
+	unsigned int bus;
+	unsigned int devfn;
+	struct pci_device_id id;
+};
+
+/* onboard PCI devices found in DS411+ to confirm the machine type (after DMI match) */
+static const struct synology_pci_dev ds411plus_pci_devices[] __initconst = {
+	/* 00:00.0 Host bridge: Intel Corporation Atom Processor D4xx/D5xx/N4xx/N5xx DMI Bridge */
+	{ 0, PCI_DEVFN(0, 0), { PCI_DEVICE_SUB(PCI_VENDOR_ID_INTEL, 0xa000,
+					       PCI_VENDOR_ID_INTEL, 0xa000) } },
+	/* 00:1f.0 ISA bridge: Intel Corporation 82801IR (ICH9R) LPC Interface Controller */
+	{ 0, PCI_DEVFN(0x1f, 0), { PCI_DEVICE_SUB(PCI_VENDOR_ID_INTEL, 0x2916,
+						  PCI_VENDOR_ID_INTEL, 0x2916) } },
 
+	/* 02:00.0 Mass storage controller: Silicon Image, Inc. SiI 3531 Serial ATA Controller */
+	{ 2, PCI_DEVFN(0x00, 0), { PCI_DEVICE_SUB(PCI_VENDOR_ID_CMD, 0x3531,
+						  PCI_VENDOR_ID_CMD, 0x3531) } },
+	/* 03:00.0 Ethernet controller: Intel Corporation 82574L Gigabit Network Connection */
+	{ 3, PCI_DEVFN(0x00, 0), { PCI_DEVICE_SUB(PCI_VENDOR_ID_INTEL, 0x10d3,
+						  PCI_VENDOR_ID_INTEL, 0x0000) } },
+	{}
 
+};
 
+/* check if all PCI devices in the list are present at specified locations */
+static bool __init synology_pci_devices_present(const struct synology_pci_dev *list)
+{
+	const struct synology_pci_dev *d;
+

drivers/platform/x86/synology-x86.c line 190

Quoted 10 lines
drivers/platform/x86/synology-x86.c new file +9 -0
+	for (d = list; d->id.vendor; d++) {
+		struct pci_dev *pdev = pci_get_domain_bus_and_slot(0, d->bus, d->devfn);
+
+		if (!pdev)
+			return false;
 
+		bool matched = d->id.vendor == pdev->vendor &&
+			       d->id.device == pdev->device &&
+			       d->id.subvendor == pdev->subsystem_vendor &&
+			       d->id.subdevice == pdev->subsystem_device;

Don't mix variable definitions with the code (it's exceptionally possible for a couple of cases, none of which is this one). Can't it use pci_match_id() approach with driver_data? (If we ever need this check.)

Quoted 8 lines
Quoted 4 lines

I don't see how can pci_match_id() be used here. I can merge pci bus and devfun into driver_data to fit into pci_device_id table but there's no pci_dev which could be matched against that table (and walking all PCI devices does not seem to be an improvement).

_After_ DMI match the walk over all PCI devices is not a big deal. The code will be nicer. But maybe there is a better choice? Like checking CPUID? Or maybe something interesting is present in the ACPI tables?

pci_find_next_bus() and pci_walk_bus() with a callback or list_for_each_entry()?
Then pci_match_id() and finally test if the matched device has proper bus and devfn numbers. Doesn't look like a recipe for nice code.

I'll check ACPI tables tomorrow but I doubt there's anything done properly in the BIOS (even int13 support is buggy and requires GRUB patch).

Signature · 1 line
Ondrej Zary