Skip to content

Commit af340b7

Browse files
elkabloarndb
authored andcommitted
platform: cznic: turris-omnia-mcu: Make GPIO code optional
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: ed46f1f ("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>
1 parent 74a22fc commit af340b7

File tree

4 files changed

+37
-18
lines changed

4 files changed

+37
-18
lines changed

drivers/platform/cznic/Kconfig

Lines changed: 25 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -16,31 +16,38 @@ config TURRIS_OMNIA_MCU
1616
tristate "Turris Omnia MCU driver"
1717
depends on MACH_ARMADA_38X || COMPILE_TEST
1818
depends on I2C
19-
depends on OF
20-
depends on GPIOLIB
21-
select GPIOLIB_IRQCHIP
2219
help
2320
Say Y here to add support for the features implemented by the
2421
microcontroller on the CZ.NIC's Turris Omnia SOHO router.
25-
The features include:
26-
- GPIO pins
27-
- to get front button press events (the front button can be
28-
configured either to generate press events to the CPU or to change
29-
front LEDs panel brightness)
30-
- to enable / disable USB port voltage regulators and to detect
31-
USB overcurrent
32-
- to detect MiniPCIe / mSATA card presence in MiniPCIe port 0
33-
- to configure resets of various peripherals on board revisions 32+
34-
- to enable / disable the VHV voltage regulator to the SOC in order
35-
to be able to program SOC's OTP on board revisions 32+
36-
- to get input from the LED output pins of the WAN ethernet PHY, LAN
37-
switch and MiniPCIe ports
38-
Other features can be enabled by subsequent config options.
22+
This option only enables the core part of the driver. Specific
23+
features can be enabled by subsequent config options.
3924
To compile this driver as a module, choose M here; the module will be
4025
called turris-omnia-mcu.
4126

4227
if TURRIS_OMNIA_MCU
4328

29+
config TURRIS_OMNIA_MCU_GPIO
30+
bool "Turris Omnia MCU GPIOs"
31+
default y
32+
depends on GPIOLIB
33+
depends on OF
34+
select GPIOLIB_IRQCHIP
35+
help
36+
Say Y here to add support for controlling MCU GPIO pins and receiving
37+
MCU interrupts on CZ.NIC's Turris Omnia.
38+
This enables you to
39+
- get front button press events (the front button can be configured
40+
either to generate press events to the CPU or to change front LEDs
41+
panel brightness),
42+
- enable / disable USB port voltage regulators and to detect USB
43+
overcurrent,
44+
- detect MiniPCIe / mSATA card presence in MiniPCIe port 0,
45+
- configure resets of various peripherals on board revisions 32+,
46+
- enable / disable the VHV voltage regulator to the SOC in order to be
47+
able to program SOC's OTP on board revisions 32+,
48+
- get input from the LED output pins of the WAN ethernet PHY, LAN
49+
switch and MiniPCIe ports.
50+
4451
config TURRIS_OMNIA_MCU_SYSOFF_WAKEUP
4552
bool "Turris Omnia MCU system off and RTC wakeup"
4653
default y
@@ -62,6 +69,7 @@ config TURRIS_OMNIA_MCU_WATCHDOG
6269
config TURRIS_OMNIA_MCU_TRNG
6370
bool "Turris Omnia MCU true random number generator"
6471
default y
72+
depends on TURRIS_OMNIA_MCU_GPIO
6573
depends on HW_RANDOM
6674
help
6775
Say Y here to add support for the true random number generator

drivers/platform/cznic/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
obj-$(CONFIG_TURRIS_OMNIA_MCU) += turris-omnia-mcu.o
44
turris-omnia-mcu-y := turris-omnia-mcu-base.o
5-
turris-omnia-mcu-y += turris-omnia-mcu-gpio.o
5+
turris-omnia-mcu-$(CONFIG_TURRIS_OMNIA_MCU_GPIO) += turris-omnia-mcu-gpio.o
66
turris-omnia-mcu-$(CONFIG_TURRIS_OMNIA_MCU_SYSOFF_WAKEUP) += turris-omnia-mcu-sys-off-wakeup.o
77
turris-omnia-mcu-$(CONFIG_TURRIS_OMNIA_MCU_TRNG) += turris-omnia-mcu-trng.o
88
turris-omnia-mcu-$(CONFIG_TURRIS_OMNIA_MCU_WATCHDOG) += turris-omnia-mcu-watchdog.o

drivers/platform/cznic/turris-omnia-mcu-base.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,9 @@ static const struct attribute_group omnia_mcu_base_group = {
197197

198198
static const struct attribute_group *omnia_mcu_groups[] = {
199199
&omnia_mcu_base_group,
200+
#ifdef CONFIG_TURRIS_OMNIA_MCU_GPIO
200201
&omnia_mcu_gpio_group,
202+
#endif
201203
#ifdef CONFIG_TURRIS_OMNIA_MCU_SYSOFF_WAKEUP
202204
&omnia_mcu_poweroff_group,
203205
#endif

drivers/platform/cznic/turris-omnia-mcu.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ struct omnia_mcu {
3333
u8 board_first_mac[ETH_ALEN];
3434
u8 board_revision;
3535

36+
#ifdef CONFIG_TURRIS_OMNIA_MCU_GPIO
3637
/* GPIO chip */
3738
struct gpio_chip gc;
3839
struct mutex lock;
@@ -41,6 +42,7 @@ struct omnia_mcu {
4142
struct delayed_work button_release_emul_work;
4243
unsigned long last_status;
4344
bool button_pressed_emul;
45+
#endif
4446

4547
#ifdef CONFIG_TURRIS_OMNIA_MCU_SYSOFF_WAKEUP
4648
/* RTC device for configuring wake-up */
@@ -188,9 +190,16 @@ static inline int omnia_cmd_read_u8(const struct i2c_client *client, u8 cmd,
188190
return omnia_cmd_read(client, cmd, reply, sizeof(*reply));
189191
}
190192

193+
#ifdef CONFIG_TURRIS_OMNIA_MCU_GPIO
191194
extern const u8 omnia_int_to_gpio_idx[32];
192195
extern const struct attribute_group omnia_mcu_gpio_group;
193196
int omnia_mcu_register_gpiochip(struct omnia_mcu *mcu);
197+
#else
198+
static inline int omnia_mcu_register_gpiochip(struct omnia_mcu *mcu)
199+
{
200+
return 0;
201+
}
202+
#endif
194203

195204
#ifdef CONFIG_TURRIS_OMNIA_MCU_SYSOFF_WAKEUP
196205
extern const struct attribute_group omnia_mcu_poweroff_group;

0 commit comments

Comments
 (0)