]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
platform: cznic: turris-omnia-mcu: Make GPIO code optional
authorMarek Behún <kabel@kernel.org>
Fri, 19 Jul 2024 08:57:56 +0000 (10:57 +0200)
committerArnd Bergmann <arnd@arndb.de>
Wed, 7 Aug 2024 12:43:54 +0000 (14:43 +0200)
Make the GPIO part of the driver optional, under a boolean config
option. Move the dependency to GPIOLIB and OF and the selection of
GPIOLIB_IRQCHIP to this new option.

This makes the turris-omnia-mcu driver available for compilation even if
GPIOLIB or OF are disabled.

Fixes: ed46f1f7731d ("platform: cznic: turris-omnia-mcu: fix Kconfig dependencies")
Signed-off-by: Marek Behún <kabel@kernel.org>
Link: https://lore.kernel.org/r/20240719085756.30598-5-kabel@kernel.org
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
drivers/platform/cznic/Kconfig
drivers/platform/cznic/Makefile
drivers/platform/cznic/turris-omnia-mcu-base.c
drivers/platform/cznic/turris-omnia-mcu.h

index f02856226dd74e6dc9b114a08a6c624c348abef3..a111eca8ff57d2b291d1d2388ef32e0d34a402e5 100644 (file)
@@ -16,31 +16,38 @@ config TURRIS_OMNIA_MCU
        tristate "Turris Omnia MCU driver"
        depends on MACH_ARMADA_38X || COMPILE_TEST
        depends on I2C
-       depends on OF
-       depends on GPIOLIB
-       select GPIOLIB_IRQCHIP
        help
          Say Y here to add support for the features implemented by the
          microcontroller on the CZ.NIC's Turris Omnia SOHO router.
-         The features include:
-         - GPIO pins
-           - to get front button press events (the front button can be
-             configured either to generate press events to the CPU or to change
-             front LEDs panel brightness)
-           - to enable / disable USB port voltage regulators and to detect
-             USB overcurrent
-           - to detect MiniPCIe / mSATA card presence in MiniPCIe port 0
-           - to configure resets of various peripherals on board revisions 32+
-           - to enable / disable the VHV voltage regulator to the SOC in order
-             to be able to program SOC's OTP on board revisions 32+
-           - to get input from the LED output pins of the WAN ethernet PHY, LAN
-             switch and MiniPCIe ports
-         Other features can be enabled by subsequent config options.
+         This option only enables the core part of the driver. Specific
+         features can be enabled by subsequent config options.
          To compile this driver as a module, choose M here; the module will be
          called turris-omnia-mcu.
 
 if TURRIS_OMNIA_MCU
 
+config TURRIS_OMNIA_MCU_GPIO
+       bool "Turris Omnia MCU GPIOs"
+       default y
+       depends on GPIOLIB
+       depends on OF
+       select GPIOLIB_IRQCHIP
+       help
+         Say Y here to add support for controlling MCU GPIO pins and receiving
+         MCU interrupts on CZ.NIC's Turris Omnia.
+         This enables you to
+         - get front button press events (the front button can be configured
+           either to generate press events to the CPU or to change front LEDs
+           panel brightness),
+         - enable / disable USB port voltage regulators and to detect USB
+           overcurrent,
+         - detect MiniPCIe / mSATA card presence in MiniPCIe port 0,
+         - configure resets of various peripherals on board revisions 32+,
+         - enable / disable the VHV voltage regulator to the SOC in order to be
+           able to program SOC's OTP on board revisions 32+,
+         - get input from the LED output pins of the WAN ethernet PHY, LAN
+           switch and MiniPCIe ports.
+
 config TURRIS_OMNIA_MCU_SYSOFF_WAKEUP
        bool "Turris Omnia MCU system off and RTC wakeup"
        default y
@@ -62,6 +69,7 @@ config TURRIS_OMNIA_MCU_WATCHDOG
 config TURRIS_OMNIA_MCU_TRNG
        bool "Turris Omnia MCU true random number generator"
        default y
+       depends on TURRIS_OMNIA_MCU_GPIO
        depends on HW_RANDOM
        help
          Say Y here to add support for the true random number generator
index 380530ba74f7be98b86c00d1a76cc5de8d2f787c..ce6d997f34d66e943d44c1993cce63142e00ffbf 100644 (file)
@@ -2,7 +2,7 @@
 
 obj-$(CONFIG_TURRIS_OMNIA_MCU) += turris-omnia-mcu.o
 turris-omnia-mcu-y             := turris-omnia-mcu-base.o
-turris-omnia-mcu-y             += turris-omnia-mcu-gpio.o
+turris-omnia-mcu-$(CONFIG_TURRIS_OMNIA_MCU_GPIO)               += turris-omnia-mcu-gpio.o
 turris-omnia-mcu-$(CONFIG_TURRIS_OMNIA_MCU_SYSOFF_WAKEUP)      += turris-omnia-mcu-sys-off-wakeup.o
 turris-omnia-mcu-$(CONFIG_TURRIS_OMNIA_MCU_TRNG)               += turris-omnia-mcu-trng.o
 turris-omnia-mcu-$(CONFIG_TURRIS_OMNIA_MCU_WATCHDOG)           += turris-omnia-mcu-watchdog.o
index 7b514e60273dc8cc5b1377bc9585e763d71a1621..58f9afae28673753eed1ad5aebb51529ab8849e6 100644 (file)
@@ -197,7 +197,9 @@ static const struct attribute_group omnia_mcu_base_group = {
 
 static const struct attribute_group *omnia_mcu_groups[] = {
        &omnia_mcu_base_group,
+#ifdef CONFIG_TURRIS_OMNIA_MCU_GPIO
        &omnia_mcu_gpio_group,
+#endif
 #ifdef CONFIG_TURRIS_OMNIA_MCU_SYSOFF_WAKEUP
        &omnia_mcu_poweroff_group,
 #endif
index 75fa2111546f773f39e2d686a090a440d25a3ca0..fed0d357fea39c0adb8eb1ee440ffaaae984a976 100644 (file)
@@ -33,6 +33,7 @@ struct omnia_mcu {
        u8 board_first_mac[ETH_ALEN];
        u8 board_revision;
 
+#ifdef CONFIG_TURRIS_OMNIA_MCU_GPIO
        /* GPIO chip */
        struct gpio_chip gc;
        struct mutex lock;
@@ -41,6 +42,7 @@ struct omnia_mcu {
        struct delayed_work button_release_emul_work;
        unsigned long last_status;
        bool button_pressed_emul;
+#endif
 
 #ifdef CONFIG_TURRIS_OMNIA_MCU_SYSOFF_WAKEUP
        /* RTC device for configuring wake-up */
@@ -188,9 +190,16 @@ static inline int omnia_cmd_read_u8(const struct i2c_client *client, u8 cmd,
        return omnia_cmd_read(client, cmd, reply, sizeof(*reply));
 }
 
+#ifdef CONFIG_TURRIS_OMNIA_MCU_GPIO
 extern const u8 omnia_int_to_gpio_idx[32];
 extern const struct attribute_group omnia_mcu_gpio_group;
 int omnia_mcu_register_gpiochip(struct omnia_mcu *mcu);
+#else
+static inline int omnia_mcu_register_gpiochip(struct omnia_mcu *mcu)
+{
+       return 0;
+}
+#endif
 
 #ifdef CONFIG_TURRIS_OMNIA_MCU_SYSOFF_WAKEUP
 extern const struct attribute_group omnia_mcu_poweroff_group;