You've already forked beagleconnect-freedom
mirror of
https://github.com/beagleboard/beagleconnect-freedom.git
synced 2026-08-04 13:19:56 +00:00
752 lines
28 KiB
Diff
752 lines
28 KiB
Diff
From 3d6cc782ffe2e05f6c8384f3bebe379b9139ae01 Mon Sep 17 00:00:00 2001
|
|
From: Vaishnav M A <vaishnav@beagleboard.org>
|
|
Date: Tue, 12 Jan 2021 06:27:16 +0530
|
|
Subject: [PATCH] mikrobus: mikrobus over greybus
|
|
|
|
Tested on PocketBeagle + ATUSB + CC1352R SensorTag:
|
|
|
|
debian@beaglebone:~$ uname -a
|
|
Linux beaglebone 5.8.18-bone23 #1xross PREEMPT Tue Dec 15 15:41:20 IST 2020 armv7l GNU/Linux
|
|
|
|
All drivers probed correctly as per manifest, but a kernel panic occurs after sometime:
|
|
|
|
debian@beaglebone:~$ dmesg
|
|
[ 218.793223] greybus 1-svc: no primary interface detected on module 2
|
|
[ 218.876678] greybus 1-2.2: Interface added (greybus)
|
|
[ 218.876707] greybus 1-2.2: GMP VID=0x00000126, PID=0x00000126
|
|
[ 218.876739] greybus 1-2.2: DDBL1 Manufacturer=0x00000126, Product=0x00000126
|
|
[ 219.296368] greybus 1-2.2: excess descriptors in interface manifest
|
|
[ 220.922786] mikrobus:mikrobus_port_gb_register: mikrobus gb_probe , num cports= 3
|
|
[ 220.922793] mikrobus:mikrobus_port_gb_register: protocol added 11
|
|
[ 220.922824] mikrobus:mikrobus_port_gb_register: protocol added 3
|
|
[ 220.922829] mikrobus:mikrobus_port_gb_register: protocol added 2
|
|
[ 220.922896] mikrobus:mikrobus_port_register: registering port mikrobus-1
|
|
[ 220.931490] mikrobus_manifest:mikrobus_manifest_attach_device: parsed device 1, driver=bme280, protocol=3, reg=76
|
|
[ 220.931526] mikrobus_manifest:mikrobus_manifest_attach_device: parsed device 2, driver=opt3001, protocol=3, reg=44
|
|
[ 220.931557] mikrobus_manifest:mikrobus_manifest_parse: Greybus Service Sample Application manifest parsed with 2 devices
|
|
[ 220.931602] mikrobus mikrobus-1: registering device : bme280
|
|
[ 220.937043] mikrobus mikrobus-1: registering device : opt3001
|
|
[ 221.628678] bmp280 3-0076: supply vddd not found, using dummy regulator
|
|
[ 221.628976] bmp280 3-0076: supply vdda not found, using dummy regulator
|
|
[ 221.630669] opt3001 3-0044: Found TI OPT3001
|
|
debian@beaglebone:~$ ls /sys/bus/iio/devices/iio\:device
|
|
iio:device0/ iio:device1/ iio:device2/
|
|
debian@beaglebone:~$ ls /sys/bus/iio/devices/iio\:device1
|
|
current_timestamp_clock dev events in_illuminance_input in_illuminance_integration_time integration_time_available name power subsystem uevent
|
|
debian@beaglebone:~$ ls /sys/bus/iio/devices/iio\:device2
|
|
dev in_humidityrelative_input in_humidityrelative_oversampling_ratio in_pressure_input in_pressure_oversampling_ratio in_temp_input in_temp_oversampling_ratio name power subsystem uevent
|
|
.
|
|
.
|
|
.
|
|
[ 235.947231] 8<--- cut here ---
|
|
[ 235.951059] Unable to handle kernel NULL pointer dereference at virtual address 00000004
|
|
[ 235.964814] pgd = 1f321289
|
|
[ 235.970754] [00000004] *pgd=00000000
|
|
[ 235.977393] Internal error: Oops: 5 [#1] PREEMPT THUMB2
|
|
[ 235.983348] Modules linked in: bmp280_i2c bmp280 opt3001 gb_netlink gb_loopback(C) gb_gpio(C) gb_i2c(C) gb_spi(C) gb_gbphy(C) gb_spilib(C) greybus nhc_udp nhc_routing nhc_ipv6 nhc_mobility nhc_hop nhc_fragment nhc_dest ieee802154_6lowpan 6lowpan evdev usb_f_acm u_serial usb_f_ncm usb_f_mass_storage usb_f_rndis u_ether libcomposite iptable_nat nf_nat nf_conntrack nf_defrag_ipv6 nf_defrag_ipv4 iptable_mangle iptable_filter ip_tables x_tables atusb mac802154 ieee802154 spidev [last unloaded: gb_netlink]
|
|
[ 236.028629] CPU: 0 PID: 5 Comm: kworker/0:0 Tainted: G C O 5.8.18-bone23 #1xross
|
|
[ 236.037887] Hardware name: Generic AM33XX (Flattened Device Tree)
|
|
[ 236.044761] Workqueue: events do_work [greybus]
|
|
[ 236.050022] PC is at skb_release_data+0x52/0xe4
|
|
[ 236.055268] LR is at kfree_skb+0x23/0xa8
|
|
[ 236.059903] pc : [<c0857e6a>] lr : [<c0857583>] psr: 400f0033
|
|
[ 236.066892] sp : dc139e60 ip : a00f0013 fp : c0f1369c
|
|
[ 236.072833] r10: da5b5200 r9 : da5b5214 r8 : 00000001
|
|
[ 236.078775] r7 : da5b5300 r6 : db633c00 r5 : da5b5300 r4 : 00000000
|
|
[ 236.086026] r3 : 00000008 r2 : 00000000 r1 : 00000000 r0 : 00000000
|
|
[ 236.093279] Flags: nZcv IRQs on FIQs on Mode SVC_32 ISA Thumb Segment none
|
|
[ 236.101316] Control: 50c5387d Table: 9b5a4019 DAC: 00000051
|
|
[ 236.107785] Process kworker/0:0 (pid: 5, stack limit = 0x39163ebd)
|
|
[ 236.114689] Stack: (0xdc139e60 to 0xdc13a000)
|
|
[ 236.119766] 9e60: da5b5200 db633c00 ffffff91 bf9391cd db51c000 c0857583 db633c00 ffffff91
|
|
[ 236.128678] 9e80: dae21168 bf9391cd 00000000 00000001 00000000 c0f05288 d64e7ea0 00000000
|
|
[ 236.137590] 9ea0: 000007d0 00000cc0 da6b0e00 00000000 00000000 bf90f84d 00000cc0 d64e7ea0
|
|
[ 236.146502] 9ec0: 00000000 00000000 00000013 bf90f8b9 d64e7ea0 bf90f94d 00000000 00000cc0
|
|
[ 236.155415] 9ee0: d6543d40 db51c400 00000000 dfa07300 00000000 00000000 d6543d44 bf90e973
|
|
[ 236.164328] 9f00: 00000000 00000000 000007d0 c0153c45 c0f05288 bf90eb39 00000000 c0f05288
|
|
[ 236.173240] 9f20: dfa07305 d6543d40 dc0e5b00 00000000 dfa07300 c01377c7 dc139f50 c0137a53
|
|
[ 236.182153] 9f40: dc0e5b00 c0f1365c dc0e5b14 c0f1d060 c0f13670 dc138000 c0f1365c c0137af9
|
|
[ 236.191065] 9f60: 00000000 dc0fd080 dc0fd380 dc138000 00000000 c0137a2d dc0e5b00 dc117eb8
|
|
[ 236.199979] 9f80: dc0fd0a0 c013ba45 00000000 dc0fd380 c013b955 00000000 00000000 00000000
|
|
[ 236.208891] 9fa0: 00000000 00000000 00000000 c0100159 00000000 00000000 00000000 00000000
|
|
[ 236.217804] 9fc0: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
|
|
[ 236.226716] 9fe0: 00000000 00000000 00000000 00000000 00000013 00000000 00000000 00000000
|
|
[ 236.235638] [<c0857e6a>] (skb_release_data) from [<c0857583>] (kfree_skb+0x23/0xa8)
|
|
[ 236.244032] [<c0857583>] (kfree_skb) from [<bf9391cd>] (message_send+0x91/0x12c [gb_netlink])
|
|
[ 236.253333] [<bf9391cd>] (message_send [gb_netlink]) from [<bf90f84d>] (gb_operation_request_send+0xad/0xfc [greybus])
|
|
[ 236.264799] [<bf90f84d>] (gb_operation_request_send [greybus]) from [<bf90f8b9>] (gb_operation_request_send_sync_timeout+0x1d/0x4c [greybus])
|
|
[ 236.278268] [<bf90f8b9>] (gb_operation_request_send_sync_timeout [greybus]) from [<bf90f94d>] (gb_operation_sync_timeout+0x65/0xb0 [greybus])
|
|
[ 236.291736] [<bf90f94d>] (gb_operation_sync_timeout [greybus]) from [<bf90e973>] (gb_svc_ping+0x23/0x28 [greybus])
|
|
[ 236.302849] [<bf90e973>] (gb_svc_ping [greybus]) from [<bf90eb39>] (do_work+0x19/0xe8 [greybus])
|
|
[ 236.312387] [<bf90eb39>] (do_work [greybus]) from [<c01377c7>] (process_one_work+0x127/0x38c)
|
|
[ 236.321651] [<c01377c7>] (process_one_work) from [<c0137af9>] (worker_thread+0xcd/0x3d0)
|
|
[ 236.330482] [<c0137af9>] (worker_thread) from [<c013ba45>] (kthread+0xf1/0x124)
|
|
[ 236.338526] [<c013ba45>] (kthread) from [<c0100159>] (ret_from_fork+0x11/0x38)
|
|
[ 236.346474] Exception stack(0xdc139fb0 to 0xdc139ff8)
|
|
[ 236.352244] 9fa0: 00000000 00000000 00000000 00000000
|
|
[ 236.361156] 9fc0: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
|
|
[ 236.370067] 9fe0: 00000000 00000000 00000000 00000000 00000013 00000000
|
|
[ 236.377413] Code: 78bb 42a3 dd1b 6aa8 (6843) 07da
|
|
[ 236.394147] ---[ end trace dc655e652b764722 ]---
|
|
|
|
Signed-off-by: Vaishnav M A <vaishnav@beagleboard.org>
|
|
---
|
|
drivers/greybus/manifest.c | 18 ++
|
|
drivers/misc/mikrobus/mikrobus_core.c | 90 +++++++++-
|
|
drivers/misc/mikrobus/mikrobus_core.h | 202 ----------------------
|
|
drivers/misc/mikrobus/mikrobus_id.c | 4 +-
|
|
drivers/misc/mikrobus/mikrobus_manifest.c | 2 +-
|
|
drivers/misc/mikrobus/mikrobus_manifest.h | 2 +-
|
|
drivers/staging/greybus/gbphy.c | 10 +-
|
|
drivers/staging/greybus/gpio.c | 26 +--
|
|
drivers/staging/greybus/i2c.c | 11 +-
|
|
drivers/staging/greybus/pwm.c | 2 +-
|
|
drivers/staging/greybus/sdio.c | 2 +-
|
|
drivers/staging/greybus/spi.c | 2 +-
|
|
drivers/staging/greybus/spilib.c | 19 +-
|
|
drivers/staging/greybus/uart.c | 2 +-
|
|
drivers/staging/greybus/usb.c | 2 +-
|
|
include/linux/greybus/bundle.h | 2 +
|
|
include/linux/greybus/interface.h | 2 +
|
|
17 files changed, 126 insertions(+), 381 deletions(-)
|
|
delete mode 100644 drivers/misc/mikrobus/mikrobus_core.h
|
|
|
|
diff --git a/drivers/greybus/manifest.c b/drivers/greybus/manifest.c
|
|
index dd7040697bde..9be09511b4df 100644
|
|
--- a/drivers/greybus/manifest.c
|
|
+++ b/drivers/greybus/manifest.c
|
|
@@ -136,6 +136,17 @@ static int identify_descriptor(struct gb_interface *intf,
|
|
case GREYBUS_TYPE_CPORT:
|
|
expected_size += sizeof(struct greybus_descriptor_cport);
|
|
break;
|
|
+ case GREYBUS_TYPE_PROPERTY:
|
|
+ expected_size += sizeof(struct greybus_descriptor_property);
|
|
+ expected_size += desc->property.length;
|
|
+ expected_size = ALIGN(expected_size, 4);
|
|
+ break;
|
|
+ case GREYBUS_TYPE_DEVICE:
|
|
+ expected_size += sizeof(struct greybus_descriptor_device);
|
|
+ break;
|
|
+ case GREYBUS_TYPE_MIKROBUS:
|
|
+ expected_size += sizeof(struct greybus_descriptor_mikrobus);
|
|
+ break;
|
|
case GREYBUS_TYPE_INVALID:
|
|
default:
|
|
dev_err(&intf->dev, "invalid descriptor type (%u)\n",
|
|
@@ -372,6 +383,11 @@ static u32 gb_manifest_parse_bundles(struct gb_interface *intf)
|
|
continue;
|
|
}
|
|
|
|
+ if (class == GREYBUS_CLASS_BRIDGED_PHY){
|
|
+ bundle->manifest_blob = kmemdup(intf->manifest_blob, intf->manifest_size, GFP_KERNEL);
|
|
+ bundle->manifest_size = intf->manifest_size;
|
|
+ }
|
|
+
|
|
count++;
|
|
}
|
|
|
|
@@ -489,6 +505,8 @@ bool gb_manifest_parse(struct gb_interface *intf, void *data, size_t size)
|
|
return false;
|
|
}
|
|
|
|
+ intf->manifest_size = size;
|
|
+ intf->manifest_blob = data;
|
|
/* OK, find all the descriptors */
|
|
desc = manifest->descriptors;
|
|
size -= sizeof(*header);
|
|
diff --git a/drivers/misc/mikrobus/mikrobus_core.c b/drivers/misc/mikrobus/mikrobus_core.c
|
|
index bbf8f541d19a..f69176fc5d4e 100644
|
|
--- a/drivers/misc/mikrobus/mikrobus_core.c
|
|
+++ b/drivers/misc/mikrobus/mikrobus_core.c
|
|
@@ -21,8 +21,10 @@
|
|
#include <linux/w1-gpio.h>
|
|
#include <linux/device.h>
|
|
#include <linux/i2c.h>
|
|
+#include <linux/greybus.h>
|
|
#include <linux/gpio.h>
|
|
#include <linux/gpio/machine.h>
|
|
+#include <linux/gpio/driver.h>
|
|
#include <linux/nvmem-consumer.h>
|
|
#include <linux/nvmem-provider.h>
|
|
#include <linux/interrupt.h>
|
|
@@ -38,8 +40,9 @@
|
|
#include <linux/regulator/machine.h>
|
|
#include <linux/clk-provider.h>
|
|
#include <linux/greybus/greybus_manifest.h>
|
|
+#include <linux/greybus/gbphy.h>
|
|
+#include <linux/mikrobus.h>
|
|
|
|
-#include "mikrobus_core.h"
|
|
#include "mikrobus_manifest.h"
|
|
|
|
static DEFINE_MUTEX(core_lock);
|
|
@@ -782,7 +785,7 @@ int mikrobus_port_register(struct mikrobus_port *port)
|
|
port->dev.parent);
|
|
if (retval)
|
|
dev_warn(&port->dev, "failed to create compatibility class link\n");
|
|
- if (!port->w1_master) {
|
|
+ if (!port->w1_master && !port->disable_eeprom) {
|
|
dev_info(&port->dev, "mikrobus port %d eeprom empty probing default eeprom\n",
|
|
port->id);
|
|
mutex_lock(&core_lock);
|
|
@@ -825,6 +828,89 @@ void mikrobus_port_delete(struct mikrobus_port *port)
|
|
}
|
|
EXPORT_SYMBOL_GPL(mikrobus_port_delete);
|
|
|
|
+int mikrobus_port_gb_register(struct gbphy_host *host, void *manifest_blob, size_t manifest_size)
|
|
+{
|
|
+ struct gb_bundle *bundle = host->bundle;
|
|
+ struct addon_board_info *board;
|
|
+ struct gbphy_device *gbphy_dev, *temp;
|
|
+ struct gb_i2c_device *gb_i2c_dev;
|
|
+ struct gb_connection *spi_connection;
|
|
+ struct gb_gpio_controller *ggc;
|
|
+ struct mikrobus_port *port;
|
|
+ struct gpio_desc *desc;
|
|
+ struct gpio_descs *descs;
|
|
+ int retval;
|
|
+
|
|
+ if (bundle->num_cports == 0)
|
|
+ return -ENODEV;
|
|
+
|
|
+ port = kzalloc(sizeof(*port), GFP_KERNEL);
|
|
+ if (!port)
|
|
+ return -ENOMEM;
|
|
+
|
|
+ pr_info("mikrobus gb_probe , num cports= %zu, manifest_size %u \n", bundle->num_cports, manifest_size);
|
|
+ list_for_each_entry_safe(gbphy_dev, temp, &host->devices, list) {
|
|
+ pr_info("protocol added %d", gbphy_dev->cport_desc->protocol_id);
|
|
+ if(gbphy_dev->cport_desc->protocol_id != GREYBUS_PROTOCOL_I2C &&
|
|
+ gbphy_dev->cport_desc->protocol_id != GREYBUS_PROTOCOL_SPI &&
|
|
+ gbphy_dev->cport_desc->protocol_id != GREYBUS_PROTOCOL_GPIO){
|
|
+ pr_info("only I2C , GPIO and SPI Protocol Currently Supported");
|
|
+ kfree(port);
|
|
+ continue;
|
|
+ }
|
|
+ port->dev.parent = &gbphy_dev->dev;
|
|
+ if(gbphy_dev->cport_desc->protocol_id == GREYBUS_PROTOCOL_I2C){
|
|
+ gb_i2c_dev = (struct gb_i2c_device *) gb_gbphy_get_data(gbphy_dev);
|
|
+ port->i2c_adap = &gb_i2c_dev->adapter;
|
|
+
|
|
+ }
|
|
+ else if(gbphy_dev->cport_desc->protocol_id == GREYBUS_PROTOCOL_SPI){
|
|
+ spi_connection = gb_gbphy_get_data(gbphy_dev);
|
|
+ port->spi_mstr = (struct spi_master *)gb_connection_get_data(spi_connection);
|
|
+ }
|
|
+ else if(gbphy_dev->cport_desc->protocol_id == GREYBUS_PROTOCOL_GPIO){
|
|
+ ggc = (struct gb_gpio_controller *) gb_gbphy_get_data(gbphy_dev);
|
|
+ port->gpios = kzalloc(struct_size(descs, desc, 12), GFP_KERNEL);
|
|
+ port->gpios->desc[0] = gpio_to_desc( ggc->chip.base + 7);//PWM GPIO
|
|
+ port->gpios->desc[1] = gpio_to_desc( ggc->chip.base + 20); //INT GPIO
|
|
+ port->gpios->desc[10] = gpio_to_desc( ggc->chip.base + 19); //RST GPIO
|
|
+ }
|
|
+ }
|
|
+ port->disable_eeprom = 1;
|
|
+ retval = mikrobus_port_register(port);
|
|
+ if (retval) {
|
|
+ pr_err("port : can't register port [%d]\n", retval);
|
|
+ }
|
|
+
|
|
+ board = kzalloc(sizeof(*board), GFP_KERNEL);
|
|
+ if (!board) {
|
|
+ retval = -ENOMEM;
|
|
+ goto err_free_buf;
|
|
+ }
|
|
+ INIT_LIST_HEAD(&board->manifest_descs);
|
|
+ INIT_LIST_HEAD(&board->devices);
|
|
+ retval = mikrobus_manifest_parse(board, manifest_blob, manifest_size);
|
|
+ if (!retval) {
|
|
+ dev_err(&port->dev, "failed to parse manifest, size %lu\n",
|
|
+ manifest_size);
|
|
+ retval = -EINVAL;
|
|
+ goto err_free_board;
|
|
+ }
|
|
+ retval = mikrobus_board_register(port, board);
|
|
+ if (retval) {
|
|
+ dev_err(&port->dev, "failed to register board %s\n",
|
|
+ board->name);
|
|
+ goto err_free_board;
|
|
+ }
|
|
+ return 0;
|
|
+err_free_board:
|
|
+ kfree(board);
|
|
+err_free_buf:
|
|
+ kfree(manifest_blob);
|
|
+ return retval;
|
|
+}
|
|
+EXPORT_SYMBOL_GPL(mikrobus_port_gb_register);
|
|
+
|
|
static int mikrobus_port_probe_pinctrl_setup(struct mikrobus_port *port)
|
|
{
|
|
struct pinctrl_state *state;
|
|
diff --git a/drivers/misc/mikrobus/mikrobus_core.h b/drivers/misc/mikrobus/mikrobus_core.h
|
|
deleted file mode 100644
|
|
index ef7ddce660cb..000000000000
|
|
--- a/drivers/misc/mikrobus/mikrobus_core.h
|
|
+++ /dev/null
|
|
@@ -1,202 +0,0 @@
|
|
-/* SPDX-License-Identifier: GPL-2.0 */
|
|
-/*
|
|
- * mikroBUS Driver for instantiating add-on
|
|
- * board devices with an identifier EEPROM
|
|
- *
|
|
- * Copyright 2020 Vaishnav M A, BeagleBoard.org Foundation.
|
|
- */
|
|
-
|
|
-#ifndef __MIKROBUS_H
|
|
-#define __MIKROBUS_H
|
|
-
|
|
-#include <linux/kernel.h>
|
|
-#include <linux/device.h>
|
|
-#include <linux/i2c.h>
|
|
-#include <linux/gpio.h>
|
|
-#include <linux/gpio/consumer.h>
|
|
-#include <linux/gpio/machine.h>
|
|
-#include <linux/spi/spi.h>
|
|
-#include <linux/serdev.h>
|
|
-#include <linux/property.h>
|
|
-#include <linux/pinctrl/pinctrl.h>
|
|
-#include <linux/pinctrl/pinmux.h>
|
|
-#include <linux/pinctrl/consumer.h>
|
|
-#include <linux/nvmem-consumer.h>
|
|
-#include <linux/nvmem-provider.h>
|
|
-
|
|
-#define MIKROBUS_VERSION_MAJOR 0x00
|
|
-#define MIKROBUS_VERSION_MINOR 0x03
|
|
-
|
|
-#define MIKROBUS_NAME_SIZE 40
|
|
-#define MIKROBUS_PINCTRL_NAME_SIZE 20
|
|
-
|
|
-#define MIKROBUS_NUM_PINCTRL_STATE 4
|
|
-#define MIKROBUS_NUM_CS 2
|
|
-
|
|
-#define MIKROBUS_PINCTRL_PWM 0
|
|
-#define MIKROBUS_PINCTRL_UART 1
|
|
-#define MIKROBUS_PINCTRL_I2C 2
|
|
-#define MIKROBUS_PINCTRL_SPI 3
|
|
-
|
|
-#define MIKROBUS_PINCTRL_STATE_GPIO "gpio"
|
|
-
|
|
-#define MIKROBUS_EEPROM_EXIT_ID_CMD 0xD2
|
|
-
|
|
-extern struct bus_type mikrobus_bus_type;
|
|
-extern struct device_type mikrobus_port_type;
|
|
-extern const char *MIKROBUS_PINCTRL_STR[];
|
|
-
|
|
-enum mikrobus_property_type {
|
|
- MIKROBUS_PROPERTY_TYPE_MIKROBUS = 0x00,
|
|
- MIKROBUS_PROPERTY_TYPE_PROPERTY = 0x01,
|
|
- MIKROBUS_PROPERTY_TYPE_GPIO = 0x02,
|
|
- MIKROBUS_PROPERTY_TYPE_U8 = 0x03,
|
|
- MIKROBUS_PROPERTY_TYPE_U16 = 0x04,
|
|
- MIKROBUS_PROPERTY_TYPE_U32 = 0x05,
|
|
- MIKROBUS_PROPERTY_TYPE_U64 = 0x06,
|
|
- MIKROBUS_PROPERTY_TYPE_REGULATOR = 0x07,
|
|
- MIKROBUS_PROPERTY_TYPE_CLOCK = 0x08,
|
|
-};
|
|
-
|
|
-enum mikrobus_pin {
|
|
- MIKROBUS_PIN_PWM = 0x00,
|
|
- MIKROBUS_PIN_INT = 0x01,
|
|
- MIKROBUS_PIN_RX = 0x02,
|
|
- MIKROBUS_PIN_TX = 0x03,
|
|
- MIKROBUS_PIN_SCL = 0x04,
|
|
- MIKROBUS_PIN_SDA = 0x05,
|
|
- MIKROBUS_PIN_MOSI = 0x06,
|
|
- MIKROBUS_PIN_MISO = 0x07,
|
|
- MIKROBUS_PIN_SCK = 0x08,
|
|
- MIKROBUS_PIN_CS = 0x09,
|
|
- MIKROBUS_PIN_RST = 0x0A,
|
|
- MIKROBUS_PIN_AN = 0x0B,
|
|
- MIKROBUS_PORT_PIN_COUNT = 0x0C,
|
|
-};
|
|
-
|
|
-enum mikrobus_pin_state {
|
|
- MIKROBUS_STATE_INPUT = 0x01,
|
|
- MIKROBUS_STATE_OUTPUT_HIGH = 0x02,
|
|
- MIKROBUS_STATE_OUTPUT_LOW = 0x03,
|
|
- MIKROBUS_STATE_PWM = 0x04,
|
|
- MIKROBUS_STATE_SPI = 0x05,
|
|
- MIKROBUS_STATE_I2C = 0x06,
|
|
- MIKROBUS_STATE_UART = 0x07,
|
|
-};
|
|
-
|
|
-/*
|
|
- * board_device_info describes a single device on a mikrobus add-on
|
|
- * board, an add-on board can present one or more device to the host
|
|
- *
|
|
- * @gpio_lookup: used to provide the GPIO lookup table for
|
|
- * passing the named GPIOs to device drivers.
|
|
- * @properties: used to provide the property_entry to pass named
|
|
- * properties to device drivers, applicable only when driver uses
|
|
- * device_property_read_* calls to fetch the properties.
|
|
- * @num_gpio_resources: number of named gpio resources for the device,
|
|
- * used mainly for gpiod_lookup_table memory allocation.
|
|
- * @num_properties: number of custom properties for the device,
|
|
- * used mainly for property_entry memory allocation.
|
|
- * @protocol: used to know the type of the device and it should
|
|
- * contain one of the values defined under 'enum greybus_class_type'
|
|
- * under linux/greybus/greybus_manifest.h
|
|
- * @reg: I2C address for the device, for devices on the SPI bus
|
|
- * this field is the chip select address relative to the mikrobus
|
|
- * port:0->device chip select connected to CS pin on mikroBUS port
|
|
- * 1->device chip select connected to RST Pin on mikroBUS port
|
|
- * @mode: SPI mode
|
|
- * @max_speed_hz: SPI max speed(Hz)
|
|
- * @drv_name: device_id to match with the driver
|
|
- * @irq_type: type of IRQ trigger , match with defines in linux/interrupt.h
|
|
- * @irq: irq number relative to the mikrobus port should contain one of the
|
|
- * values defined under 'enum mikrobus_pin'
|
|
- * @id: device id starting from 1
|
|
- */
|
|
-struct board_device_info {
|
|
- struct gpiod_lookup_table *gpio_lookup;
|
|
- struct property_entry *properties;
|
|
- struct property_entry *regulators;
|
|
- struct property_entry *clocks;
|
|
- struct list_head links;
|
|
- unsigned short num_gpio_resources;
|
|
- unsigned short num_properties;
|
|
- unsigned short num_regulators;
|
|
- unsigned short num_clocks;
|
|
- unsigned short protocol;
|
|
- unsigned short reg;
|
|
- unsigned int mode;
|
|
- void *dev_client;
|
|
- u32 max_speed_hz;
|
|
- char *drv_name;
|
|
- int irq_type;
|
|
- int irq;
|
|
- int id;
|
|
-};
|
|
-
|
|
-/*
|
|
- * addon_board_info describes a mikrobus add-on device the add-on
|
|
- * board, an add-on board can present one or more device to the host
|
|
- *
|
|
- * @manifest_descs: list of manifest descriptors
|
|
- * @devices: list of devices on the board
|
|
- * @pin_state: the state of each pin on the mikrobus port required
|
|
- * for the add-on board should contain one of the values defined under
|
|
- * 'enum mikrobus_pin_state' restrictions are as per mikrobus standard
|
|
- * specifications.
|
|
- * @name: add-on board name
|
|
- */
|
|
-struct addon_board_info {
|
|
- struct list_head manifest_descs;
|
|
- struct list_head devices;
|
|
- u8 pin_state[MIKROBUS_PORT_PIN_COUNT];
|
|
- char *name;
|
|
-};
|
|
-
|
|
-/*
|
|
- * mikrobus_port describes the peripherals mapped to a
|
|
- * mikrobus port.
|
|
- *
|
|
- * @eeprom_client: i2c_client corresponding to the eeprom
|
|
- * on the add-on board.
|
|
- * @board: pointer to the attached add-on board.
|
|
- * @i2c_adap: I2C adapter attached to the mikrobus port.
|
|
- * @spi_mstr: SPI master attached to the mikrobus port.
|
|
- * @eeprom: nvmem_device for the eeprom on the add-on board.
|
|
- * @pwm: pwm_device attached to the mikrobus port PWM pin.
|
|
- * @pinctrl_selected: current pinctrl_selected state.
|
|
- * @chip_select: chip select number mapped to the SPI
|
|
- * CS pin on the mikrobus port and the RST pin on the mikrobus
|
|
- * port
|
|
- * @id: port id starting from 1
|
|
- */
|
|
-struct mikrobus_port {
|
|
- struct addon_board_info *board;
|
|
- struct nvmem_device *eeprom;
|
|
- struct i2c_adapter *i2c_adap;
|
|
- struct spi_master *spi_mstr;
|
|
- struct w1_master *w1_master;
|
|
- struct platform_device *w1_gpio;
|
|
- struct serdev_controller *ser_ctrl;
|
|
- struct gpio_descs *gpios;
|
|
- struct pwm_device *pwm;
|
|
- struct pinctrl *pinctrl;
|
|
- struct module *owner;
|
|
- struct device dev;
|
|
- char name[MIKROBUS_NAME_SIZE];
|
|
- char *pinctrl_selected[MIKROBUS_NUM_PINCTRL_STATE];
|
|
- unsigned int chip_select[MIKROBUS_NUM_CS];
|
|
- int skip_scan;
|
|
- int id;
|
|
-};
|
|
-#define to_mikrobus_port(d) container_of(d, struct mikrobus_port, dev)
|
|
-
|
|
-void mikrobus_board_unregister(struct mikrobus_port *port,
|
|
- struct addon_board_info *board);
|
|
-int mikrobus_board_register(struct mikrobus_port *port,
|
|
- struct addon_board_info *board);
|
|
-int mikrobus_port_register(struct mikrobus_port *port);
|
|
-int mikrobus_port_pinctrl_select(struct mikrobus_port *port);
|
|
-void mikrobus_port_delete(struct mikrobus_port *port);
|
|
-int mikrobus_port_scan_eeprom(struct mikrobus_port *port);
|
|
-struct mikrobus_port *mikrobus_find_port_by_w1_master(struct w1_master *master);
|
|
-#endif /* __MIKROBUS_H */
|
|
diff --git a/drivers/misc/mikrobus/mikrobus_id.c b/drivers/misc/mikrobus/mikrobus_id.c
|
|
index e891645f745c..183de02cd74f 100644
|
|
--- a/drivers/misc/mikrobus/mikrobus_id.c
|
|
+++ b/drivers/misc/mikrobus/mikrobus_id.c
|
|
@@ -14,7 +14,7 @@
|
|
#include <linux/w1.h>
|
|
#include <linux/nvmem-provider.h>
|
|
|
|
-#include "mikrobus_core.h"
|
|
+#include <linux/mikrobus.h>
|
|
|
|
#define W1_EEPROM_MIKROBUS_ID 0xAC
|
|
|
|
@@ -204,4 +204,4 @@ module_w1_family(w1_family_mikrobus_id);
|
|
MODULE_AUTHOR("Vaishnav M A <vaishnav@beagleboard.org>");
|
|
MODULE_DESCRIPTION("w1 family ac driver for mikroBUS ID EEPROM");
|
|
MODULE_LICENSE("GPL");
|
|
-MODULE_ALIAS("w1-family-" __stringify(W1_EEPROM_MIKROBUS_ID));
|
|
\ No newline at end of file
|
|
+MODULE_ALIAS("w1-family-" __stringify(W1_EEPROM_MIKROBUS_ID));
|
|
diff --git a/drivers/misc/mikrobus/mikrobus_manifest.c b/drivers/misc/mikrobus/mikrobus_manifest.c
|
|
index 9cacc3d36d4e..a5faa8bfcdbc 100644
|
|
--- a/drivers/misc/mikrobus/mikrobus_manifest.c
|
|
+++ b/drivers/misc/mikrobus/mikrobus_manifest.c
|
|
@@ -306,7 +306,7 @@ static int mikrobus_manifest_attach_device(struct addon_board_info *board,
|
|
board_dev->irq_type = dev_desc->irq_type;
|
|
board_dev->max_speed_hz = le32_to_cpu(dev_desc->max_speed_hz);
|
|
board_dev->mode = dev_desc->mode;
|
|
- pr_info("parsed device %d, driver=%s", board_dev->id, board_dev->drv_name);
|
|
+ pr_info("parsed device %d, driver=%s, protocol=%d, reg=%x", board_dev->id, board_dev->drv_name, board_dev->protocol, board_dev->reg);
|
|
|
|
if (dev_desc->prop_link > 0) {
|
|
prop_link = mikrobus_property_link_get(board, dev_desc->prop_link,
|
|
diff --git a/drivers/misc/mikrobus/mikrobus_manifest.h b/drivers/misc/mikrobus/mikrobus_manifest.h
|
|
index 36b64b2093f5..4c8b4346575e 100644
|
|
--- a/drivers/misc/mikrobus/mikrobus_manifest.h
|
|
+++ b/drivers/misc/mikrobus/mikrobus_manifest.h
|
|
@@ -12,7 +12,7 @@
|
|
#ifndef __MIKROBUS_MANIFEST_H
|
|
#define __MIKROBUS_MANIFEST_H
|
|
|
|
-#include "mikrobus_core.h"
|
|
+#include <linux/mikrobus.h>
|
|
|
|
int mikrobus_manifest_parse(struct addon_board_info *info, void *data, size_t size);
|
|
size_t mikrobus_manifest_header_validate(void *data, size_t size);
|
|
diff --git a/drivers/staging/greybus/gbphy.c b/drivers/staging/greybus/gbphy.c
|
|
index 9fc5c47be9bd..0d5004f12ff9 100644
|
|
--- a/drivers/staging/greybus/gbphy.c
|
|
+++ b/drivers/staging/greybus/gbphy.c
|
|
@@ -14,16 +14,12 @@
|
|
#include <linux/slab.h>
|
|
#include <linux/device.h>
|
|
#include <linux/greybus.h>
|
|
+#include <linux/mikrobus.h>
|
|
|
|
-#include "gbphy.h"
|
|
+#include <linux/greybus/gbphy.h>
|
|
|
|
#define GB_GBPHY_AUTOSUSPEND_MS 3000
|
|
|
|
-struct gbphy_host {
|
|
- struct gb_bundle *bundle;
|
|
- struct list_head devices;
|
|
-};
|
|
-
|
|
static DEFINE_IDA(gbphy_id);
|
|
|
|
static ssize_t protocol_id_show(struct device *dev,
|
|
@@ -305,6 +301,8 @@ static int gb_gbphy_probe(struct gb_bundle *bundle,
|
|
list_add(&gbphy_dev->list, &gbphy_host->devices);
|
|
}
|
|
|
|
+ mikrobus_port_gb_register(gbphy_host, bundle->manifest_blob, bundle->manifest_size);
|
|
+
|
|
gb_pm_runtime_put_autosuspend(bundle);
|
|
|
|
return 0;
|
|
diff --git a/drivers/staging/greybus/gpio.c b/drivers/staging/greybus/gpio.c
|
|
index 36d99f9e419e..ce3ad6690fe7 100644
|
|
--- a/drivers/staging/greybus/gpio.c
|
|
+++ b/drivers/staging/greybus/gpio.c
|
|
@@ -15,32 +15,8 @@
|
|
#include <linux/mutex.h>
|
|
#include <linux/greybus.h>
|
|
|
|
-#include "gbphy.h"
|
|
-
|
|
-struct gb_gpio_line {
|
|
- /* The following has to be an array of line_max entries */
|
|
- /* --> make them just a flags field */
|
|
- u8 active: 1,
|
|
- direction: 1, /* 0 = output, 1 = input */
|
|
- value: 1; /* 0 = low, 1 = high */
|
|
- u16 debounce_usec;
|
|
-
|
|
- u8 irq_type;
|
|
- bool irq_type_pending;
|
|
- bool masked;
|
|
- bool masked_pending;
|
|
-};
|
|
-
|
|
-struct gb_gpio_controller {
|
|
- struct gbphy_device *gbphy_dev;
|
|
- struct gb_connection *connection;
|
|
- u8 line_max; /* max line number */
|
|
- struct gb_gpio_line *lines;
|
|
+#include <linux/greybus/gbphy.h>
|
|
|
|
- struct gpio_chip chip;
|
|
- struct irq_chip irqc;
|
|
- struct mutex irq_lock;
|
|
-};
|
|
#define gpio_chip_to_gb_gpio_controller(chip) \
|
|
container_of(chip, struct gb_gpio_controller, chip)
|
|
#define irq_data_to_gpio_chip(d) (d->domain->host_data)
|
|
diff --git a/drivers/staging/greybus/i2c.c b/drivers/staging/greybus/i2c.c
|
|
index de2f6516da09..4fff1c6d88b7 100644
|
|
--- a/drivers/staging/greybus/i2c.c
|
|
+++ b/drivers/staging/greybus/i2c.c
|
|
@@ -12,16 +12,7 @@
|
|
#include <linux/i2c.h>
|
|
#include <linux/greybus.h>
|
|
|
|
-#include "gbphy.h"
|
|
-
|
|
-struct gb_i2c_device {
|
|
- struct gb_connection *connection;
|
|
- struct gbphy_device *gbphy_dev;
|
|
-
|
|
- u32 functionality;
|
|
-
|
|
- struct i2c_adapter adapter;
|
|
-};
|
|
+#include <linux/greybus/gbphy.h>
|
|
|
|
/*
|
|
* Map Greybus i2c functionality bits into Linux ones
|
|
diff --git a/drivers/staging/greybus/pwm.c b/drivers/staging/greybus/pwm.c
|
|
index 891a6a672378..2808882e2ad3 100644
|
|
--- a/drivers/staging/greybus/pwm.c
|
|
+++ b/drivers/staging/greybus/pwm.c
|
|
@@ -12,7 +12,7 @@
|
|
#include <linux/pwm.h>
|
|
#include <linux/greybus.h>
|
|
|
|
-#include "gbphy.h"
|
|
+#include <linux/greybus/gbphy.h>
|
|
|
|
struct gb_pwm_chip {
|
|
struct gb_connection *connection;
|
|
diff --git a/drivers/staging/greybus/sdio.c b/drivers/staging/greybus/sdio.c
|
|
index 0939f4a4c963..067a6b0a21e2 100644
|
|
--- a/drivers/staging/greybus/sdio.c
|
|
+++ b/drivers/staging/greybus/sdio.c
|
|
@@ -14,7 +14,7 @@
|
|
#include <linux/workqueue.h>
|
|
#include <linux/greybus.h>
|
|
|
|
-#include "gbphy.h"
|
|
+#include <linux/greybus/gbphy.h>
|
|
|
|
struct gb_sdio_host {
|
|
struct gb_connection *connection;
|
|
diff --git a/drivers/staging/greybus/spi.c b/drivers/staging/greybus/spi.c
|
|
index 68e8d272db6d..2ab5fa2e6cfa 100644
|
|
--- a/drivers/staging/greybus/spi.c
|
|
+++ b/drivers/staging/greybus/spi.c
|
|
@@ -9,7 +9,7 @@
|
|
#include <linux/module.h>
|
|
#include <linux/greybus.h>
|
|
|
|
-#include "gbphy.h"
|
|
+#include <linux/greybus/gbphy.h>
|
|
#include "spilib.h"
|
|
|
|
static struct spilib_ops *spilib_ops;
|
|
diff --git a/drivers/staging/greybus/spilib.c b/drivers/staging/greybus/spilib.c
|
|
index fc27c52de74a..529617085568 100644
|
|
--- a/drivers/staging/greybus/spilib.c
|
|
+++ b/drivers/staging/greybus/spilib.c
|
|
@@ -14,24 +14,7 @@
|
|
#include <linux/spi/spi.h>
|
|
|
|
#include "spilib.h"
|
|
-
|
|
-struct gb_spilib {
|
|
- struct gb_connection *connection;
|
|
- struct device *parent;
|
|
- struct spi_transfer *first_xfer;
|
|
- struct spi_transfer *last_xfer;
|
|
- struct spilib_ops *ops;
|
|
- u32 rx_xfer_offset;
|
|
- u32 tx_xfer_offset;
|
|
- u32 last_xfer_size;
|
|
- unsigned int op_timeout;
|
|
- u16 mode;
|
|
- u16 flags;
|
|
- u32 bits_per_word_mask;
|
|
- u8 num_chipselect;
|
|
- u32 min_speed_hz;
|
|
- u32 max_speed_hz;
|
|
-};
|
|
+#include <linux/greybus/gbphy.h>
|
|
|
|
#define GB_SPI_STATE_MSG_DONE ((void *)0)
|
|
#define GB_SPI_STATE_MSG_IDLE ((void *)1)
|
|
diff --git a/drivers/staging/greybus/uart.c b/drivers/staging/greybus/uart.c
|
|
index 607378bfebb7..7a20c2fab398 100644
|
|
--- a/drivers/staging/greybus/uart.c
|
|
+++ b/drivers/staging/greybus/uart.c
|
|
@@ -30,7 +30,7 @@
|
|
#include <linux/completion.h>
|
|
#include <linux/greybus.h>
|
|
|
|
-#include "gbphy.h"
|
|
+#include <linux/greybus/gbphy.h>
|
|
|
|
#define GB_NUM_MINORS 16 /* 16 is more than enough */
|
|
#define GB_NAME "ttyGB"
|
|
diff --git a/drivers/staging/greybus/usb.c b/drivers/staging/greybus/usb.c
|
|
index 8e9d9d59a357..df4b84f022a5 100644
|
|
--- a/drivers/staging/greybus/usb.c
|
|
+++ b/drivers/staging/greybus/usb.c
|
|
@@ -12,7 +12,7 @@
|
|
#include <linux/usb/hcd.h>
|
|
#include <linux/greybus.h>
|
|
|
|
-#include "gbphy.h"
|
|
+#include <linux/greybus/gbphy.h>
|
|
|
|
/* Greybus USB request types */
|
|
#define GB_USB_TYPE_HCD_START 0x02
|
|
diff --git a/include/linux/greybus/bundle.h b/include/linux/greybus/bundle.h
|
|
index df8d88424cb7..f54ceecf2be8 100644
|
|
--- a/include/linux/greybus/bundle.h
|
|
+++ b/include/linux/greybus/bundle.h
|
|
@@ -33,6 +33,8 @@ struct gb_bundle {
|
|
u8 *state;
|
|
|
|
struct list_head links; /* interface->bundles */
|
|
+ void *manifest_blob;
|
|
+ size_t manifest_size;
|
|
};
|
|
#define to_gb_bundle(d) container_of(d, struct gb_bundle, dev)
|
|
|
|
diff --git a/include/linux/greybus/interface.h b/include/linux/greybus/interface.h
|
|
index ce4def881e6f..a7d8d40fa300 100644
|
|
--- a/include/linux/greybus/interface.h
|
|
+++ b/include/linux/greybus/interface.h
|
|
@@ -65,6 +65,8 @@ struct gb_interface {
|
|
|
|
struct work_struct mode_switch_work;
|
|
struct completion mode_switch_completion;
|
|
+ void *manifest_blob;
|
|
+ size_t manifest_size;
|
|
};
|
|
#define to_gb_interface(d) container_of(d, struct gb_interface, dev)
|
|
|
|
--
|
|
2.30.0
|
|
|