[PATCH 3/8] mikrobus: Add mikrobus driver

From: Ayush Singh
Date: Wed Sep 11 2024 - 10:29:06 EST


A simple platform driver for now that does nothing. This is required
because without a platform driver, the mikrobus_gpio0 nexus node cannot
be used.

In future, this driver will also allow for dynamic board detection using
1-wire eeprom in new mikrobus boards.

Signed-off-by: Ayush Singh <ayush@xxxxxxxxxxxxxxx>
---
MAINTAINERS | 1 +
drivers/misc/Kconfig | 17 +++++++++++++++++
drivers/misc/Makefile | 1 +
drivers/misc/mikrobus.rs | 32 ++++++++++++++++++++++++++++++++
4 files changed, 51 insertions(+)

diff --git a/MAINTAINERS b/MAINTAINERS
index 0cc27446b18a..d0c18bd7b558 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -15433,6 +15433,7 @@ MIKROBUS CONNECTOR
M: Ayush Singh <ayush@xxxxxxxxxxxxxxx>
S: Maintained
F: Documentation/devicetree/bindings/connector/mikrobus-connector.yaml
+F: drivers/misc/mikrobus.rs

MIKROTIK CRS3XX 98DX3236 BOARD SUPPORT
M: Luka Kovacic <luka.kovacic@xxxxxxxxxx>
diff --git a/drivers/misc/Kconfig b/drivers/misc/Kconfig
index 3fe7e2a9bd29..30defb522e98 100644
--- a/drivers/misc/Kconfig
+++ b/drivers/misc/Kconfig
@@ -610,6 +610,23 @@ config MARVELL_CN10K_DPI
To compile this driver as a module, choose M here: the module
will be called mrvl_cn10k_dpi.

+menuconfig MIKROBUS
+ tristate "Module for instantiating devices on mikroBUS ports"
+ help
+ This option enables the mikroBUS driver. mikroBUS is an add-on
+ board socket standard that offers maximum expandability with
+ the smallest number of pins. The mikroBUS driver instantiates
+ devices on a mikroBUS port described by identifying data present
+ in an add-on board resident EEPROM, more details on the mikroBUS
+ driver support and discussion can be found in this eLinux wiki :
+ elinux.org/Mikrobus
+
+
+ Say Y here to enable support for this driver.
+
+ To compile this code as a module, chose M here: the module
+ will be called mikrobus.ko
+
source "drivers/misc/c2port/Kconfig"
source "drivers/misc/eeprom/Kconfig"
source "drivers/misc/cb710/Kconfig"
diff --git a/drivers/misc/Makefile b/drivers/misc/Makefile
index a9f94525e181..86ea188e3cf9 100644
--- a/drivers/misc/Makefile
+++ b/drivers/misc/Makefile
@@ -72,3 +72,4 @@ obj-$(CONFIG_TPS6594_PFSM) += tps6594-pfsm.o
obj-$(CONFIG_NSM) += nsm.o
obj-$(CONFIG_MARVELL_CN10K_DPI) += mrvl_cn10k_dpi.o
obj-y += keba/
+obj-$(CONFIG_MIKROBUS) += mikrobus.o
diff --git a/drivers/misc/mikrobus.rs b/drivers/misc/mikrobus.rs
new file mode 100644
index 000000000000..a52268efd71b
--- /dev/null
+++ b/drivers/misc/mikrobus.rs
@@ -0,0 +1,32 @@
+// SPDX-License-Identifier: GPL-2.0
+
+//! MikroBUS driver
+
+use kernel::c_str;
+use kernel::platform::{self, DeviceId};
+use kernel::prelude::*;
+
+kernel::module_platform_driver! {
+ driver: MikrobusDriver,
+ of_table: [DeviceId::new(c_str!("mikrobus-connector"))],
+ name: "mikrobus",
+ author: "Ayush Singh <ayush@xxxxxxxxxxxxxxx>",
+ description: "MikroBUS connector Driver",
+ license: "GPL",
+}
+
+struct MikrobusDriver;
+
+#[vtable]
+impl platform::Driver for MikrobusDriver {
+ const NAME: &'static CStr = c_str!("MikroBUS");
+
+ fn probe(_dev: &mut platform::Device) -> Result {
+ pr_debug!("Mikrobus Driver (probe)\n");
+ Ok(())
+ }
+
+ fn remove(_dev: &mut platform::Device) {
+ pr_debug!("Mikrobus Driver (remove)\n");
+ }
+}

--
2.46.0