Skip to contentSkip to conversation

mfd: Add support for IO functions of AAEON devices

PATCH In review [email protected] 3 participants 10 messages May 25, 2021 – May 26, 2021

Subsystems (5)
lore
Share & tools
lore
#0 lore raw

PATCH 1/5 mfd: Add support for IO functions of AAEON devices

From: Kunyang_Fan <[email protected]>

This adds the supports for multiple IO functions of the AAEON x86 devices and makes use of the WMI interface to control the these IO devices including:

- GPIO
- LED
- Watchdog
- HWMON

It also adds the mfd child device drivers to support the above IO functions.

---
 MAINTAINERS             | 12 +++++++
 drivers/mfd/Kconfig     | 12 +++++++
 drivers/mfd/Makefile    |  1 +
 drivers/mfd/mfd-aaeon.c | 77 +++++++++++++++++++++++++++++++++++++++++
 4 files changed, 102 insertions(+)
 create mode 100644 drivers/mfd/mfd-aaeon.c
MAINTAINERS +12 -0
index 1c19c1e2c970..49783dd44367 100644
@@ -257,6 +257,18 @@ W:	http://www.adaptec.com/
 F:	Documentation/scsi/aacraid.rst
 F:	drivers/scsi/aacraid/
 
+AAEON DEVICE DRIVER WITH WMI INTERFACE
+M:	Edward Lin<[email protected]>
+M:	Kunyang Fan <[email protected]>
+M:	Frank Hsieh <[email protected]>
+M:	Jacob Wu <[email protected]>
+S:	Supported
+F:	drivers/gpio/gpio-aaeon.c
+F:	drivers/hwmon/hwmon-aaeon.c
+F:	drivers/leds/leds-aaeon.c
+F:	drivers/mfd/mfd-aaeon.c
+F:	drivers/watchdog/wdt_aaeon.c
+
 ABI/API
 L:	[email protected]
 F:	include/linux/syscalls.h
drivers/mfd/Kconfig +12 -0
index a37d7d171382..f172564eed0d 100644
@@ -2053,6 +2053,18 @@ config MFD_WCD934X
 	  This driver provides common support WCD934x audio codec and its
 	  associated Pin Controller, Soundwire Controller and Audio codec.
 
+
+config MFD_AAEON
+	tristate "AAEON WMI MFD devices"
+	depends on ASUS_WMI
+	help
+	  Say yes here to support mltiple IO devices on Single Board Computers
+	  produced by AAEON.
+
+	  This driver leverages the ASUS WMI interface to access device
+	  resources.
+
+
 menu "Multimedia Capabilities Port drivers"
 	depends on ARCH_SA1100
 
drivers/mfd/Makefile +1 -0
index 9367a92f795a..36fff3d0da7e 100644
@@ -264,3 +264,4 @@ obj-$(CONFIG_MFD_ROHM_BD718XX)	+= rohm-bd718x7.o
 obj-$(CONFIG_MFD_STMFX) 	+= stmfx.o
 
 obj-$(CONFIG_SGI_MFD_IOC3)	+= ioc3.o
+obj-$(CONFIG_MFD_AAEON)		+= mfd-aaeon.o
drivers/mfd/mfd-aaeon.c new file +77 -0

77 lines not on this page · raw message

Signature · 1 line
2.25.1
#1 lore raw

PATCH 2/5 gpio: add driver for AAEON devices

From: Kunyang_Fan <[email protected]>

This patch add support for the GPIO pins whose control are transported to BIOS through ASUS WMI interface.

---
 drivers/gpio/Kconfig      |  11 ++
 drivers/gpio/Makefile     |   1 +
 drivers/gpio/gpio-aaeon.c | 205 ++++++++++++++++++++++++++++++++++++++
 3 files changed, 217 insertions(+)
 create mode 100644 drivers/gpio/gpio-aaeon.c
drivers/gpio/Kconfig +11 -0
index 6d2437676a75..26acac425583 100644
@@ -1356,6 +1356,17 @@ endmenu
 menu "PCI GPIO expanders"
 	depends on PCI
 
+config GPIO_AAEON
+	tristate "AAEON GPIO support"
+	depends on ASUS_WMI
+	select MFD_AAEON
+	help
+	  Say yes here to support GPIO pins on Single Board Computers produced
+	  by AAEON.
+
+	  This driver leverages the ASUS WMI interface to access device
+	  resources.
+
 config GPIO_AMD8111
 	tristate "AMD 8111 GPIO driver"
 	depends on X86 || COMPILE_TEST
drivers/gpio/Makefile +1 -0
index 1e4894e0bf0f..50682c5c49d3 100644
@@ -23,6 +23,7 @@ obj-$(CONFIG_GPIO_104_IDI_48)		+= gpio-104-idi-48.o
 obj-$(CONFIG_GPIO_104_IDIO_16)		+= gpio-104-idio-16.o
 obj-$(CONFIG_GPIO_74X164)		+= gpio-74x164.o
 obj-$(CONFIG_GPIO_74XX_MMIO)		+= gpio-74xx-mmio.o
+obj-$(CONFIG_GPIO_AAEON)                += gpio-aaeon.o
 obj-$(CONFIG_GPIO_ADNP)			+= gpio-adnp.o
 obj-$(CONFIG_GPIO_ADP5520)		+= gpio-adp5520.o
 obj-$(CONFIG_GPIO_ADP5588)		+= gpio-adp5588.o
drivers/gpio/gpio-aaeon.c new file +205 -0

205 lines not on this page · raw message

Signature · 1 line
2.25.1
#2 lore raw

Re: [PATCH 2/5] gpio: add driver for AAEON devices

Quoted 7 lines · On Tue, May 25, 2021 at 8:42 AM <[email protected]> wrote:

From: Kunyang_Fan <[email protected]>

This patch add support for the GPIO pins whose control are transported to BIOS through ASUS WMI interface.

Missed SoB of the submitter. Dunno if it's a critical issue.

...

Quoted 1 line

+obj-$(CONFIG_GPIO_AAEON) += gpio-aaeon.o

Way too generic file name. So the configuration option name.

...

Quoted 4 lines

+ * 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.

Same as for all patches.

...

drivers/gpio/gpio-aaeon.c line 54

Quoted 11 lines
drivers/gpio/gpio-aaeon.c new file +11 -0
+static int aaeon_gpio_get_number(void);
+static int aaeon_gpio_get_direction(struct gpio_chip *chip,
+                                unsigned int offset);
+static int aaeon_gpio_output_set_direction(struct gpio_chip *chip,
+                                unsigned int offset, int value);
+static int aaeon_gpio_input_set_direction(struct gpio_chip *chip,
+                                unsigned int offset);
+static int aaeon_gpio_get(struct gpio_chip *chip,
+                                unsigned int offset);
+static void aaeon_gpio_set(struct gpio_chip *chip, unsigned int offset,
+                                int value);

Why forward declarations?!

...

drivers/gpio/gpio-aaeon.c line 80

Quoted 5 lines
drivers/gpio/gpio-aaeon.c new file +4 -0
+static int aaeon_gpio_get_direction(struct gpio_chip *chip, unsigned int offset)
+{
 
+       int err, retval;
+       u32 dev_id = 0x0;

Reversed xmas tree order.

Quoted 1 line

+ dev_id |= offset;

Just keep it in the definition block

       u32 dev_id = offset;

Ditto for all the rest similar lines.

Quoted 7 lines
drivers/gpio/gpio-aaeon.c new file +7 -0
+       err = asus_wmi_evaluate_method(GET_DIRECTION_METHOD_ID, dev_id,
+                                      0, &retval);
+       if (err)
+               return err;
+
+       return retval;
+}

...

drivers/gpio/gpio-aaeon.c line 164

Quoted 6 lines
drivers/gpio/gpio-aaeon.c new file +6 -0
+static int __init aaeon_gpio_probe(struct platform_device *pdev)
+{
+       int err, i;
+       int dio_number = 0;
+       struct aaeon_gpio_data *data;
+       struct aaeon_gpio_bank *bank;

Reversed xmas tree order, same for the all similar places across the series.

drivers/gpio/gpio-aaeon.c line 170

Quoted 5 lines
drivers/gpio/gpio-aaeon.c new file +5 -0
+       /* Prevent other drivers adding this platfom device */
+       if (!wmi_has_guid(AAEON_WMI_MGMT_GUID)) {
+               pr_debug("AAEON Management GUID not found\n");
+               return -ENODEV;
+       }

Dead code?

drivers/gpio/gpio-aaeon.c line 174

Quoted 3 lines
drivers/gpio/gpio-aaeon.c new file +3 -0
+       dio_number = aaeon_gpio_get_number();
+       if (dio_number < 0)
+               return -ENODEV;

Why shadowing error code?

drivers/gpio/gpio-aaeon.c line 186

Quoted 11 lines
drivers/gpio/gpio-aaeon.c new file +11 -0
+       data = devm_kzalloc(&pdev->dev, sizeof(*data), GFP_KERNEL);
+       if (!data)
+               return -ENOMEM;
+
+       data->nr_bank = ARRAY_SIZE(aaeon_gpio_bank);
+       data->bank = aaeon_gpio_bank;
+       platform_set_drvdata(pdev, data);
+       bank = &data->bank[0];
+       bank->chip.parent = &pdev->dev;
+       bank->chip.ngpio = dio_number;
+       bank->data = data;

+ blank line

drivers/gpio/gpio-aaeon.c line 191

Quoted 5 lines
drivers/gpio/gpio-aaeon.c new file +5 -0
+       err = devm_gpiochip_add_data(&pdev->dev, &bank->chip, bank);
+       if (err)
+               pr_debug("Failed to register gpiochip %d: %d\n", i, err);
+
+       return err;

Besides the fact of using dev_dbg() and another fact that it is not needed (device core can print it for you)

return devm_...(...);

Quoted 1 line

+}

...

Quoted 1 line

+

Redundant blank line (same applies for entire series).

Quoted 1 line

+module_platform_driver_probe(aaeon_gpio_driver, aaeon_gpio_probe);

Signature · 2 lines
With Best Regards,
Andy Shevchenko
#3 lore raw

Re: [PATCH 2/5] gpio: add driver for AAEON devices

Quoted 11 lines · Andy Shevchenko
Quoted 7 lines · On Tue, May 25, 2021 at 8:42 AM <[email protected]> wrote:

From: Kunyang_Fan <[email protected]>

This patch add support for the GPIO pins whose control are transported to BIOS through ASUS WMI interface.

Missed SoB of the submitter. Dunno if it's a critical issue.

Yes, it is. Every person touching patch, which includes sender, must SoB it. This applies also to other patches in the series.

Best regards,
Krzysztof

#4 lore raw

PATCH 3/5 watchdog: add driver for AAEON devices

In reply to [email protected]

From: Kunyang_Fan <[email protected]>

This patch adds support for the watchdog whose control are transported to BIOS through ASUS WMI interface.

This driver imitates the old type SIO watchdog driver to provide the basic control for watchdog functions.

---
 drivers/watchdog/Kconfig     |  12 ++
 drivers/watchdog/Makefile    |   1 +
 drivers/watchdog/wdt_aaeon.c | 242 +++++++++++++++++++++++++++++++++++
 3 files changed, 255 insertions(+)
 create mode 100644 drivers/watchdog/wdt_aaeon.c
drivers/watchdog/Kconfig +12 -0
index 2b2839e89b7b..8fa00a9cfdfd 100644
@@ -1623,6 +1623,18 @@ config NIC7018_WDT
 	  To compile this driver as a module, choose M here: the module will be
 	  called nic7018_wdt.
 
+config AAEON_IWMI_WDT
+	tristate "AAEON Watchdog Timer"
+	depends on ASUS_WMI
+	select MFD_AAEON
+	help
+	  This is the driver for the hardware watchdog on Single Board
+	  Computers produced by AAEON.Say `Y' here to support its built-in
+	  watchdog timer feature.
+
+	  This driver leverages the ASUS WMI interface to access device
+	  resources.
+
 # M68K Architecture
 
 config M54xx_WATCHDOG
drivers/watchdog/Makefile +1 -0
index 97bed1d3d97c..9d27fec12480 100644
@@ -145,6 +145,7 @@ obj-$(CONFIG_INTEL_MEI_WDT) += mei_wdt.o
 obj-$(CONFIG_NI903X_WDT) += ni903x_wdt.o
 obj-$(CONFIG_NIC7018_WDT) += nic7018_wdt.o
 obj-$(CONFIG_MLX_WDT) += mlx_wdt.o
+obj-$(CONFIG_AAEON_IWMI_WDT) += wdt_aaeon.o
 
 # M68K Architecture
 obj-$(CONFIG_M54xx_WATCHDOG) += m54xx_wdt.o
drivers/watchdog/wdt_aaeon.c new file +242 -0

242 lines not on this page · raw message

Signature · 1 line
2.25.1
#5 lore raw

PATCH 4/5 hwmon: add driver for AAEON devices

In reply to [email protected]

From: Kunyang_Fan <[email protected]>

This refator patch adds support for the hwmon information which are transported to userspace through ASUS WMI interface.

---
 drivers/hwmon/Kconfig       |  11 +
 drivers/hwmon/Makefile      |   1 +
 drivers/hwmon/hwmon-aaeon.c | 564 ++++++++++++++++++++++++++++++++++++
 3 files changed, 576 insertions(+)
 create mode 100644 drivers/hwmon/hwmon-aaeon.c
drivers/hwmon/Kconfig +11 -0
index 288ae9f63588..93ef0a431a7e 100644
@@ -38,6 +38,17 @@ config HWMON_DEBUG_CHIP
 
 comment "Native drivers"
 
+config SENSORS_AAEON
+	tristate "AAEON hwmon driver"
+	depends on X86
+	select MFD_AAEON
+	help
+	  This hwmon driver adds support for reporting temperature or fan
+	  speed and voltage on Single Board Computers produced by AAEON.
+
+	  This driver leverages the ASUS WMI interface to access device
+	  resources.
+
 config SENSORS_AB8500
 	tristate "AB8500 thermal monitoring"
 	depends on AB8500_GPADC && AB8500_BM && (IIO = y)
drivers/hwmon/Makefile +1 -0
index 3e32c21f5efe..43d8e2fed7b1 100644
@@ -79,6 +79,7 @@ obj-$(CONFIG_SENSORS_GL520SM)	+= gl520sm.o
 obj-$(CONFIG_SENSORS_GSC)	+= gsc-hwmon.o
 obj-$(CONFIG_SENSORS_GPIO_FAN)	+= gpio-fan.o
 obj-$(CONFIG_SENSORS_HIH6130)	+= hih6130.o
+obj-$(CONFIG_SENSORS_AAEON)     += hwmon-aaeon.o
 obj-$(CONFIG_SENSORS_ULTRA45)	+= ultra45_env.o
 obj-$(CONFIG_SENSORS_I5500)	+= i5500_temp.o
 obj-$(CONFIG_SENSORS_I5K_AMB)	+= i5k_amb.o
drivers/hwmon/hwmon-aaeon.c new file +564 -0

564 lines not on this page · raw message

Signature · 1 line
2.25.1
#6 lore raw

PATCH 5/5 leds: add driver for AAEON devices

In reply to [email protected]

From: Kunyang_Fan <[email protected]>

This patch adds support for the led devices which can be controlled from sysfs through ASUS WMI interface.

---
 drivers/leds/Kconfig      |  11 +++
 drivers/leds/Makefile     |   1 +
 drivers/leds/leds-aaeon.c | 142 ++++++++++++++++++++++++++++++++++++++
 3 files changed, 154 insertions(+)
 create mode 100644 drivers/leds/leds-aaeon.c
drivers/leds/Kconfig +11 -0
index be4536eef1fe..34d1b80855af 100644
@@ -49,6 +49,17 @@ config LEDS_88PM860X
 	  This option enables support for on-chip LED drivers found on Marvell
 	  Semiconductor 88PM8606 PMIC.
 
+config LEDS_AAEON
+	tristate "AAEON LED driver"
+	depends on X86
+	select MFD_AAEON
+	help
+	  This led driver adds support for LED brightness control on Single
+	  Board Computers produced by AAEON.
+
+	  This driver leverages the ASUS WMI interface to access device
+	  resources.
+
 config LEDS_AAT1290
 	tristate "LED support for the AAT1290"
 	depends on LEDS_CLASS_FLASH
drivers/leds/Makefile +1 -0
index d6b8a792c936..a8a77acc5e11 100644
@@ -8,6 +8,7 @@ obj-$(CONFIG_LEDS_TRIGGERS)		+= led-triggers.o
 
 # LED Platform Drivers (keep this sorted, M-| sort)
 obj-$(CONFIG_LEDS_88PM860X)		+= leds-88pm860x.o
+obj-$(CONFIG_LEDS_AAEON)		+= leds-aaeon.o
 obj-$(CONFIG_LEDS_AAT1290)		+= leds-aat1290.o
 obj-$(CONFIG_LEDS_ADP5520)		+= leds-adp5520.o
 obj-$(CONFIG_LEDS_AN30259A)		+= leds-an30259a.o
drivers/leds/leds-aaeon.c new file +142 -0

142 lines not on this page · raw message

Signature · 1 line
2.25.1
#7 lore raw

Re: [PATCH 5/5] leds: add driver for AAEON devices

Quoted 74 lines · On Tue, 25 May 2021 at 01:42, <[email protected]> wrote:

From: Kunyang_Fan <[email protected]>

This patch adds support for the led devices which can be controlled from sysfs through ASUS WMI interface.

---
 drivers/leds/Kconfig      |  11 +++
 drivers/leds/Makefile     |   1 +
 drivers/leds/leds-aaeon.c | 142 ++++++++++++++++++++++++++++++++++++++
 3 files changed, 154 insertions(+)
 create mode 100644 drivers/leds/leds-aaeon.c
drivers/leds/Kconfig +11 -0
index be4536eef1fe..34d1b80855af 100644
@@ -49,6 +49,17 @@ config LEDS_88PM860X
          This option enables support for on-chip LED drivers found on Marvell
          Semiconductor 88PM8606 PMIC.
 
+config LEDS_AAEON
+       tristate "AAEON LED driver"
+       depends on X86
+       select MFD_AAEON
+       help
+         This led driver adds support for LED brightness control on Single
+         Board Computers produced by AAEON.
+
+         This driver leverages the ASUS WMI interface to access device
+         resources.
+
 config LEDS_AAT1290
        tristate "LED support for the AAT1290"
        depends on LEDS_CLASS_FLASH
drivers/leds/Makefile +1 -0
index d6b8a792c936..a8a77acc5e11 100644
@@ -8,6 +8,7 @@ obj-$(CONFIG_LEDS_TRIGGERS)             += led-triggers.o
 
 # LED Platform Drivers (keep this sorted, M-| sort)
 obj-$(CONFIG_LEDS_88PM860X)            += leds-88pm860x.o
+obj-$(CONFIG_LEDS_AAEON)               += leds-aaeon.o
 obj-$(CONFIG_LEDS_AAT1290)             += leds-aat1290.o
 obj-$(CONFIG_LEDS_ADP5520)             += leds-adp5520.o
 obj-$(CONFIG_LEDS_AN30259A)            += leds-an30259a.o
drivers/leds/leds-aaeon.c new file +20 -0
new file mode 100644
index 000000000000..10090a4bff65
@@ -0,0 +1,142 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * AAEON LED driver
+ *
+ * Copyright (c) 2021, AAEON Ltd.
+ *
+ * Author: Kunyang Fan <[email protected]>
+ *
+ * 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.
+ */
+#include <linux/acpi.h>
+#include <linux/bitops.h>
+#include <linux/leds.h>
+#include <linux/module.h>
+#include <linux/platform_data/x86/asus-wmi.h>
+#include <linux/platform_device.h>
+

drivers/leds/leds-aaeon.c line 30

Quoted 10 lines
drivers/leds/leds-aaeon.c new file +10 -0
+#define DRVNAME "led_aaeon"
+#define ASUS_NB_WMI_EVENT_GUID   "0B3CBB35-E3C2-45ED-91C2-4C5A6D195D1C"
+#define AAEON_WMI_MGMT_GUID      "97845ED0-4E6D-11DE-8A39-0800200C9A66"
+
+#define GET_LED_NUMBER_ID        0x00060000
+#define GET_LED_METHOD_ID        0x00060001
+#define SET_LED_METHOD_ID        0x00060002
+#define GET_LED_NUMBER_METHOD_ID 0x10
+
+

Previous patches apply here as well (no double blank lines, missing SoB, missing CC to maintainers, not needed license text).

Quoted 17 lines
drivers/leds/leds-aaeon.c new file +17 -0
+struct aaeon_led_data {
+       int id;
+       struct led_classdev cdev;
+};
+
+static int aaeon_led_get_number(void)
+{
+       int err, retval;
+
+       err = asus_wmi_evaluate_method(GET_LED_NUMBER_ID,
+                                      GET_LED_NUMBER_METHOD_ID,
+                                      0, &retval);
+       if (err)
+               return err;
+
+       return retval;
+}

drivers/leds/leds-aaeon.c line 57

Quoted 10 lines
drivers/leds/leds-aaeon.c new file +10 -0
+
+static enum led_brightness aaeon_led_brightness_get(struct led_classdev
+                                                     *cdev)
+{
+       int err, brightness;
+       struct aaeon_led_data *led =
+                       container_of(cdev, struct aaeon_led_data, cdev);
+       u32 arg0;
+
+       arg0 = (u32)(led->id & 0xF);

Hm, why do you need a cast here?

Quoted 18 lines
drivers/leds/leds-aaeon.c new file +18 -0
+       err = asus_wmi_evaluate_method(GET_LED_METHOD_ID, arg0, 0, &brightness);
+       if (err)
+               return err;
+
+       return brightness;
+};
+
+static void aaeon_led_brightness_set(struct led_classdev *cdev,
+                                      enum led_brightness brightness)
+{
+       int err, retval;
+       struct aaeon_led_data *led =
+                       container_of(cdev, struct aaeon_led_data, cdev);
+       u32 arg0;
+
+       arg0 = (u32)(led->id & 0xF);
+       if (brightness != LED_OFF)
+               arg0 |= BIT(16);

drivers/leds/leds-aaeon.c line 85

Quoted 10 lines
drivers/leds/leds-aaeon.c new file +10 -0
+
+       err = asus_wmi_evaluate_method(SET_LED_METHOD_ID, arg0, 0, &retval);
+};
+
+static int __init aaeon_add_led_device(struct platform_device *pdev,
+                                          int id)
+{
+       struct aaeon_led_data *led;
+
+       led = devm_kzalloc(&pdev->dev, sizeof(struct aaeon_led_data), GFP_KERNEL);

sizeof(*led)

Quoted 7 lines
drivers/leds/leds-aaeon.c new file +7 -0
+       if (!led)
+               return -ENOMEM;
+
+       led->id = id;
+       led->cdev.brightness_get = aaeon_led_brightness_get;
+       led->cdev.brightness_set = aaeon_led_brightness_set;
+       led->cdev.name = devm_kasprintf(&pdev->dev, GFP_KERNEL, "led:%d:", id);

drivers/leds/leds-aaeon.c line 102

Quoted 10 lines
drivers/leds/leds-aaeon.c new file +10 -0
+
+       if (!led->cdev.name)
+               return -ENOMEM;
+
+       return devm_led_classdev_register(&pdev->dev, &led->cdev);
+}
+
+static int aaeon_led_probe(struct platform_device *pdev)
+{
+       int err = -ENODEV, i;

Split declaration of initialized and uninitialized variables.

drivers/leds/leds-aaeon.c line 105

Quoted 3 lines
drivers/leds/leds-aaeon.c new file +3 -0
+       int led_number = 0;
+
+       pr_debug("aaeon led device probe!\n");

No printks for simple probes. This pollutes the dmesg without any benefit.

Best regards,
Krzysztof

#8 lore raw
In reply to [email protected]

+Cc: Hans (dunno if it's something you would like to be informed of)

Quoted 7 lines · On Tue, May 25, 2021 at 8:42 AM <[email protected]> wrote:

From: Kunyang_Fan <[email protected]>

This adds the supports for multiple IO functions of the AAEON x86 devices and makes use of the WMI interface to control the these IO devices including:

Quoted 7 lines

- GPIO
- LED
- Watchdog
- HWMON

It also adds the mfd child device drivers to support the above IO functions.

Do I miss the cover letter?

...

drivers/mfd/Kconfig config MFD_WCD934X · line 2061

Quoted 5 lines
drivers/mfd/Kconfig +5 -0
+config MFD_AAEON
+       tristate "AAEON WMI MFD devices"
+       depends on ASUS_WMI
+       help
+         Say yes here to support mltiple IO devices on Single Board Computers

multiple

drivers/mfd/Kconfig config MFD_WCD934X · line 2065

Quoted 4 lines
drivers/mfd/Kconfig +4 -0
+         produced by AAEON.
+
+         This driver leverages the ASUS WMI interface to access device
+         resources.

I'm wondering should it be some kind of WMI framework part to bridge WMI parts to MFD or so?

...

Quoted 4 lines

+ *
+ * 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.

Please, drop all these duplications in all files. SPDX is enough.

...

drivers/mfd/mfd-aaeon.c line 44

Quoted 3 lines
drivers/mfd/mfd-aaeon.c new file +3 -0
+static int aaeon_wmi_probe(struct wmi_device *wdev, const void *context)
+{
+       struct aaeon_wmi_priv *priv;
       struct aaeon_wmi_priv *priv = context;

drivers/mfd/mfd-aaeon.c line 49

Quoted 4 lines
drivers/mfd/mfd-aaeon.c new file +4 -0
+       if (!wmi_has_guid(AAEON_WMI_MGMT_GUID)) {
+               dev_info(&wdev->dev, "AAEON Management GUID not found\n");
+               return -ENODEV;
+       }

Dead code?

Quoted 1 line

+ priv = (struct aaeon_wmi_priv *)context;

See above.

Quoted 5 lines
drivers/mfd/mfd-aaeon.c new file +5 -0
+       dev_set_drvdata(&wdev->dev, priv);
+
+       return devm_mfd_add_devices(&wdev->dev, 0, priv->cells,
+                                   priv->ncells, NULL, 0, NULL);
+}

...

drivers/mfd/mfd-aaeon.c line 71

Quoted 9 lines
drivers/mfd/mfd-aaeon.c new file +8 -0
+static struct wmi_driver aaeon_wmi_driver = {
+       .driver = {
+               .name = "mfd-aaeon",
+       },
+       .id_table = aaeon_wmi_id_table,
+       .probe = aaeon_wmi_probe,
+};
 
+

Redundant blank line.

Quoted 1 line

+module_wmi_driver(aaeon_wmi_driver);

Signature · 2 lines
With Best Regards,
Andy Shevchenko
#9 lore raw
In reply to [email protected]
Quoted 15 lines · On Tue, 25 May 2021 at 01:42, <[email protected]> wrote:

From: Kunyang_Fan <[email protected]>

This adds the supports for multiple IO functions of the AAEON x86 devices and makes use of the WMI interface to control the these IO devices including:

- GPIO
- LED
- Watchdog
- HWMON

It also adds the mfd child device drivers to support the above IO functions.

Quoted 6 lines
---
 MAINTAINERS             | 12 +++++++
 drivers/mfd/Kconfig     | 12 +++++++
 drivers/mfd/Makefile    |  1 +
 drivers/mfd/mfd-aaeon.c | 77 +++++++++++++++++++++++++++++++++++++++++

Please CC all required maintainers - you skipped several people. You will get their list from scripts/get_maintainer.pl.

MAINTAINERS W: http://www.adaptec.com/ · line 261

Quoted 13 lines
 4 files changed, 102 insertions(+)
 create mode 100644 drivers/mfd/mfd-aaeon.c
MAINTAINERS +2 -0
index 1c19c1e2c970..49783dd44367 100644
@@ -257,6 +257,18 @@ W: http://www.adaptec.com/
 F:     Documentation/scsi/aacraid.rst
 F:     drivers/scsi/aacraid/
 
+AAEON DEVICE DRIVER WITH WMI INTERFACE
+M:     Edward Lin<[email protected]>

Missing space.

MAINTAINERS W: http://www.adaptec.com/ · line 264

Quoted 3 lines
MAINTAINERS +3 -0
+M:     Kunyang Fan <[email protected]>
+M:     Frank Hsieh <[email protected]>
+M:     Jacob Wu <[email protected]>

Why do you need four maintainers? Did they contribute to the code? Are they all going to provide reviews?

Quoted 15 lines
MAINTAINERS +7 -0
+S:     Supported
+F:     drivers/gpio/gpio-aaeon.c
+F:     drivers/hwmon/hwmon-aaeon.c
+F:     drivers/leds/leds-aaeon.c
+F:     drivers/mfd/mfd-aaeon.c
+F:     drivers/watchdog/wdt_aaeon.c
+
 ABI/API
 L:     [email protected]
 F:     include/linux/syscalls.h
drivers/mfd/Kconfig +0 -0
index a37d7d171382..f172564eed0d 100644

drivers/mfd/Kconfig config MFD_WCD934X · line 2056

Quoted 4 lines
drivers/mfd/Kconfig +1 -0
@@ -2053,6 +2053,18 @@ config MFD_WCD934X
          This driver provides common support WCD934x audio codec and its
          associated Pin Controller, Soundwire Controller and Audio codec.
 
+

No double blank lines.

drivers/mfd/Kconfig config MFD_WCD934X · line 2061

Quoted 5 lines
drivers/mfd/Kconfig +5 -0
+config MFD_AAEON
+       tristate "AAEON WMI MFD devices"
+       depends on ASUS_WMI
+       help
+         Say yes here to support mltiple IO devices on Single Board Computers

Please run spellcheck on entire submission.

Quoted 25 lines
drivers/mfd/Kconfig +6 -0
+         produced by AAEON.
+
+         This driver leverages the ASUS WMI interface to access device
+         resources.
+
+
 menu "Multimedia Capabilities Port drivers"
        depends on ARCH_SA1100
 
drivers/mfd/Makefile +1 -0
index 9367a92f795a..36fff3d0da7e 100644
@@ -264,3 +264,4 @@ obj-$(CONFIG_MFD_ROHM_BD718XX)      += rohm-bd718x7.o
 obj-$(CONFIG_MFD_STMFX)        += stmfx.o
 
 obj-$(CONFIG_SGI_MFD_IOC3)     += ioc3.o
+obj-$(CONFIG_MFD_AAEON)                += mfd-aaeon.o
drivers/mfd/mfd-aaeon.c new file +1 -0
new file mode 100644
index 000000000000..9d2efde53cad
@@ -0,0 +1,77 @@
+// SPDX-License-Identifier: GPL-2.0-or-later

drivers/mfd/mfd-aaeon.c line 11

Quoted 10 lines
drivers/mfd/mfd-aaeon.c new file +10 -0
+/*
+ * UP Board main platform driver and FPGA configuration support
+ *
+ * Copyright (c) 2021, AAEON Ltd.
+ *
+ * Author: Kunyang_Fan <[email protected]>
+ *
+ * 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.

No need for GPL text since you use SPDX.

Quoted 30 lines
drivers/mfd/mfd-aaeon.c new file +30 -0
+ */
+
+#include <linux/acpi.h>
+#include <linux/gpio.h>
+#include <linux/kernel.h>
+#include <linux/mfd/core.h>
+#include <linux/module.h>
+#include <linux/platform_device.h>
+#include <linux/leds.h>
+#include <linux/wmi.h>
+
+#define AAEON_WMI_MGMT_GUID      "97845ED0-4E6D-11DE-8A39-0800200C9A66"
+
+struct aaeon_wmi_priv {
+       const struct mfd_cell *cells;
+       size_t ncells;
+};
+
+static const struct mfd_cell aaeon_mfd_cells[] = {
+       { .name = "gpio-aaeon" },
+       { .name = "hwmon-aaeon"},
+       { .name = "leds-aaeon"},
+       { .name = "wdt-aaeon"},
+};
+
+static const struct aaeon_wmi_priv aaeon_wmi_priv_data = {
+       .cells = aaeon_mfd_cells,
+       .ncells = ARRAY_SIZE(aaeon_mfd_cells),
+};
+

drivers/mfd/mfd-aaeon.c line 51

Quoted 10 lines
drivers/mfd/mfd-aaeon.c new file +10 -0
+static int aaeon_wmi_probe(struct wmi_device *wdev, const void *context)
+{
+       struct aaeon_wmi_priv *priv;
+
+       if (!wmi_has_guid(AAEON_WMI_MGMT_GUID)) {
+               dev_info(&wdev->dev, "AAEON Management GUID not found\n");
+               return -ENODEV;
+       }
+
+

No double blank lines.

drivers/mfd/mfd-aaeon.c line 53

Quoted 2 lines
drivers/mfd/mfd-aaeon.c new file +2 -0
+       priv = (struct aaeon_wmi_priv *)context;
+       dev_set_drvdata(&wdev->dev, priv);

No, why do you need to store device ID table as private data?

Best regards,
Krzysztof