Skip to content

Commit

Permalink
RFC : mikroBUS driver for add-on boards
Browse files Browse the repository at this point in the history
Attached is a patch for the mikroBUS driver which helps to
instantiate an add-on board device on a mikrobus port by fetching
the device identifier manifest binary from an EEPROM on-board
the device. mikroBUS is an add-on board socket standard by
MikroElektronika that can be freely used by anyone
following the guidelines, more details and discussions on
the status of the driver can be found here in this eLinux wiki:
https://elinux.org/Mikrobus

In the current state of the driver, more than 80 different
add-on boards have been tested on the BeagleBoard.org
PocketBeagle and the manifest binary is generated using the same
manifesto tool used to generate Greybus manifest binaries,
The pull request to manifesto to add new descriptors specific
to mikrobus is here : projectara/manifesto#2
The utilization of Greybus manifest binaries here is not entirely
coincidental, We are evaluating ways to add mikroBUS sockets and
devices via Greybus expansion.

The mikroBUS standard includes SPI, I2C, UART, PWM, ADC, GPIO
and power (3.3V and 5V) connections to interface common embedded
peripherals, There are more than 750 add-on boards ranging from
wireless connectivity boards to human-machine interface sensors
which conform to the mikroBUS standard, out of which more than 140
boards already have support in the Linux kernel.Today, there is no
mainlinesolution for enabling mikroBUS add-on boards at run-time, the
most straight forward method for loading drivers is to provide
device-tree overlay fragments at boot time, this method suffers
from the need to maintain a large out-of-tree database for which there
is need to maintain an overlay for every mikroBUS add-on board for every
Linux system and for every mikroBUS socket on that system.

The mikroBUS driver tries to solve the problem by using extended version
of the greybus manifest to describe the add-on board device specific
information required by the device driver and uses it along with the fixed
port specific information to probe the specific device driver.The manifest
binary is now fetched from an I2C EEPROM over the I2C bus on the mikroBUS
port(subject to change in mikroBUS v3 specification) and enumerate drivers
for the add-on devices.There is also ongoing work to define a mikroBUS
v3 standard in which the addon board includes a non-volatile storage to
store the device identifier manifest binary, once the mikroBUS v3 standard
is released, the mikroBUS can be seen as a probeable bus such that the
kernel can discover the device on the bus at boot time.

The driver also has a few debug SysFS interfaces for testing on add-on
boards without an EEPROM, these can be used in the following manner:
(example for mikroBUS port 1 on BeagleBoard.org PocketBeagle):

printf "%b" '\x01\x00\x00\x59\x32\x17' > /sys/bus/mikrobus/add_port

The bytes in the byte array sequence are (in order):

	* i2c_adap_nr
	* spi_master_nr
	* serdev_ctlr_nr
	* rst_gpio_nr
	* pwm_gpio_nr
	* int_gpio_nr
* add_port sysFS entry is purely for debug and in the actual state
of the driver, port configuration will be loaded from a suitable
device tree overlay fragment.

echo 0 > /sys/bus/mikrobus/del_port (to delete the attached port)
echo 1 >  /sys/class/mikrobus-port/mikrobus-0/rescan (to rescan the EEPROM
contents on the I2C bus on the mikroBUS port).

cat board_manifest.mnfb >  /sys/class/mikrobus-port/mikrobus-0/new_device
* debug interface to pass the manifest binary in case an EEPROM is absent
echo 0 >  /sys/class/mikrobus-port/mikrobus-0/delete_device
* to unload the loaded board on the mikrobus port

These sysFS interfaces are only implemented for debug purposes and
in the actual implementation of the driver these will be removed and
the manifest binary will be fetched from the non volatile storage on-board
the device.

The mikroBUS driver enable the mikroBUS to be a probeable bus such that
the kernel can discover the device and automatically load the drivers.
There are already several Linux platforms with mikroBUS sockets and the
mikroBUS driver helps to reduce the time to develop and debug
support for various mikroBUS add-on boards. Further, it opens up
the possibility for support under dynamically instantiated buses
such as with Greybus.

Please let know the feedback you have on this patch or the approach used.

Thanks,

Vaishnav M A

Signed-off-by: Vaishnav M A <[email protected]>
  • Loading branch information
vaishnavachath authored and intel-lab-lkp committed Jul 24, 2020
1 parent 92ca3dd commit 211edf7
Show file tree
Hide file tree
Showing 10 changed files with 1,272 additions and 0 deletions.
6 changes: 6 additions & 0 deletions MAINTAINERS
Original file line number Diff line number Diff line change
Expand Up @@ -11404,6 +11404,12 @@ M: Oliver Neukum <[email protected]>
S: Maintained
F: drivers/usb/image/microtek.*

MIKROBUS ADDON BOARD DRIVER
M: Vaishnav M A <[email protected]>
S: Maintained
W: https://elinux.org/Mikrobus
F: drivers/misc/mikrobus/

MIPS
M: Thomas Bogendoerfer <[email protected]>
L: [email protected]
Expand Down
1 change: 1 addition & 0 deletions drivers/misc/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -472,4 +472,5 @@ source "drivers/misc/ocxl/Kconfig"
source "drivers/misc/cardreader/Kconfig"
source "drivers/misc/habanalabs/Kconfig"
source "drivers/misc/uacce/Kconfig"
source "drivers/misc/mikrobus/Kconfig"
endmenu
1 change: 1 addition & 0 deletions drivers/misc/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ obj-$(CONFIG_VMWARE_BALLOON) += vmw_balloon.o
obj-$(CONFIG_PCH_PHUB) += pch_phub.o
obj-y += ti-st/
obj-y += lis3lv02d/
obj-y += mikrobus/
obj-$(CONFIG_ALTERA_STAPL) +=altera-stapl/
obj-$(CONFIG_INTEL_MEI) += mei/
obj-$(CONFIG_VMWARE_VMCI) += vmw_vmci/
Expand Down
16 changes: 16 additions & 0 deletions drivers/misc/mikrobus/Kconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
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 helps in
instantiating devices on the mikroBUS port with identifier
data fetched from an EEPROM on the device, 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
5 changes: 5 additions & 0 deletions drivers/misc/mikrobus/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# SPDX-License-Identifier: GPL-2.0
# mikroBUS Core

mikrobus-y := mikrobus_core.o mikrobus_manifest.o
obj-$(CONFIG_MIKROBUS) += mikrobus.o
Loading

0 comments on commit 211edf7

Please sign in to comment.