aboutsummaryrefslogtreecommitdiffstats
path: root/recipes-kernel/most
diff options
context:
space:
mode:
authorJan-Simon Moeller <jsmoeller@linuxfoundation.org>2020-12-08 11:15:02 +0100
committerJan-Simon Moeller <jsmoeller@linuxfoundation.org>2020-12-17 13:58:05 +0000
commit41591d4f8c586aa801220fac0924556f406c58bd (patch)
tree85a2803d48a094fb0ba3a76b9e3d0870a4e5edc2 /recipes-kernel/most
parent4830bcef14e7f49cdc851c646a69c9bb9bd92e82 (diff)
SPEC-3723: restructure meta-agl-demo
All demo related components should be in here now. We keep the packagegroups on purpose for now to stay backward-compatible. v2: layer does pass yocto-check-layer, dependencies adapted v3: remove the dynamic-layer setup, use all-in-one approach v4: Fixed comments from Paul Barker. Tnx! v5: Removed wayland/weston/agl-compositor additions, except for demo specific weston-init bbappend Follow-up changes required later: - massaging packagegroups - scrub of recipes Bug-AGL: SPEC-3723 Signed-off-by: Jan-Simon Moeller <jsmoeller@linuxfoundation.org> Signed-off-by: Scott Murray <scott.murray@konsulko.com> Change-Id: I47cefd8c23d46b2cdd063470e3f7d97d5ad952d8
Diffstat (limited to 'recipes-kernel/most')
-rw-r--r--recipes-kernel/most/files/0002-src-most-add-auto-conf-feature.patch472
-rw-r--r--recipes-kernel/most/files/0003-core-remove-kernel-log-for-MBO-status.patch26
-rw-r--r--recipes-kernel/most/files/0004-most-video-set-device_caps.patch25
-rw-r--r--recipes-kernel/most/files/0005-most-video-set-V4L2_CAP_DEVICE_CAPS-flag.patch25
-rw-r--r--recipes-kernel/most/files/0006-dim2-fix-startup-sequence.patch186
-rw-r--r--recipes-kernel/most/files/0007-dim2-use-device-tree.patch378
-rw-r--r--recipes-kernel/most/files/0008-dim2-read-clock-speed-from-the-device-tree.patch92
-rw-r--r--recipes-kernel/most/files/0009-dim2-use-device-for-coherent-memory-allocation.patch47
-rw-r--r--recipes-kernel/most/files/0010-backport-usb-setup-timer.patch35
-rw-r--r--recipes-kernel/most/files/0011-handle-snd_pcm_lib_mmap_vmalloc-removal.patch30
-rw-r--r--recipes-kernel/most/files/0012-Fix-build-with-5.4-kernel.patch68
-rw-r--r--recipes-kernel/most/most.bb14
-rw-r--r--recipes-kernel/most/most.bbappend15
13 files changed, 1413 insertions, 0 deletions
diff --git a/recipes-kernel/most/files/0002-src-most-add-auto-conf-feature.patch b/recipes-kernel/most/files/0002-src-most-add-auto-conf-feature.patch
new file mode 100644
index 000000000..dd811c81b
--- /dev/null
+++ b/recipes-kernel/most/files/0002-src-most-add-auto-conf-feature.patch
@@ -0,0 +1,472 @@
+From 9cb7cb85f59509ac445116e9458c502cf6cb74e6 Mon Sep 17 00:00:00 2001
+From: Christian Gromm <christian.gromm@microchip.com>
+Date: Thu, 9 Nov 2017 13:20:23 +0100
+Subject: [PATCH 2/2] src: most: add auto conf feature
+
+This patch adds the auto configuration feature to the driver
+sources. It is needed to have the driver configured automatically
+upon start up w/o the need for userspace to set up sysfs.
+
+Signed-off-by: Christian Gromm <christian.gromm@microchip.com>
+---
+ driver/Makefile | 3 +
+ driver/default_conf.c | 162 ++++++++++++++++++++++++++++++++++++++++++++++
+ driver/include/mostcore.h | 64 ++++++++++++++++++
+ driver/mostcore/core.c | 120 ++++++++++++++++++++++++++++------
+ 4 files changed, 331 insertions(+), 18 deletions(-)
+ create mode 100644 driver/default_conf.c
+
+diff --git a/Makefile b/Makefile
+index e77a4b6..6d74ebe 100644
+--- a/Makefile
++++ b/Makefile
+@@ -6,6 +6,9 @@ obj-m := mostcore.o
+ mostcore-y := mostcore/core.o
+ CFLAGS_core.o := -I$(src)/include/
+
++obj-m += default_conf.o
++CFLAGL_default_conf.o := -I$(src)/include
++
+ obj-m += aim_cdev.o
+ aim_cdev-y := aim-cdev/cdev.o
+ CFLAGS_cdev.o := -I$(src)/include/
+diff --git a/default_conf.c b/default_conf.c
+new file mode 100644
+index 0000000..adb1786
+--- /dev/null
++++ b/default_conf.c
+@@ -0,0 +1,162 @@
++/*
++ * default_conf.c - Default configuration for the MOST channels.
++ *
++ * Copyright (C) 2017, Microchip Technology Germany II GmbH & Co. KG
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ * GNU General Public License for more details.
++ *
++ * This file is licensed under GPLv2.
++ */
++
++#include "include/mostcore.h"
++#include <linux/module.h>
++
++static struct most_config_probe config_probes[] = {
++
++ /* OS81118 Control */
++ {
++ .ch_name = "ep8f",
++ .cfg = {
++ .direction = MOST_CH_RX,
++ .data_type = MOST_CH_CONTROL,
++ .num_buffers = 16,
++ .buffer_size = 64,
++ },
++ .aim_name = "cdev",
++ .aim_param = "inic-usb-crx",
++ },
++ {
++ .ch_name = "ep0f",
++ .cfg = {
++ .direction = MOST_CH_TX,
++ .data_type = MOST_CH_CONTROL,
++ .num_buffers = 16,
++ .buffer_size = 64,
++ },
++ .aim_name = "cdev",
++ .aim_param = "inic-usb-ctx",
++ },
++ /* OS81118 Async */
++ {
++ .ch_name = "ep8e",
++ .cfg = {
++ .direction = MOST_CH_RX,
++ .data_type = MOST_CH_ASYNC,
++ .num_buffers = 20,
++ .buffer_size = 1522,
++ },
++ .aim_name = "networking",
++ .aim_param = "inic-usb-arx",
++ },
++ {
++ .ch_name = "ep0e",
++ .cfg = {
++ .direction = MOST_CH_TX,
++ .data_type = MOST_CH_ASYNC,
++ .num_buffers = 20,
++ .buffer_size = 1522,
++ },
++ .aim_name = "networking",
++ .aim_param = "inic-usb-atx",
++ },
++ /* OS81210 Control */
++ {
++ .ch_name = "ep87",
++ .cfg = {
++ .direction = MOST_CH_RX,
++ .data_type = MOST_CH_CONTROL,
++ .num_buffers = 16,
++ .buffer_size = 64,
++ },
++ .aim_name = "cdev",
++ .aim_param = "inic-usb-crx",
++ },
++ {
++ .ch_name = "ep07",
++ .cfg = {
++ .direction = MOST_CH_TX,
++ .data_type = MOST_CH_CONTROL,
++ .num_buffers = 16,
++ .buffer_size = 64,
++ },
++ .aim_name = "cdev",
++ .aim_param = "inic-usb-ctx",
++ },
++ /* OS81210 Async */
++ {
++ .ch_name = "ep86",
++ .cfg = {
++ .direction = MOST_CH_RX,
++ .data_type = MOST_CH_ASYNC,
++ .num_buffers = 20,
++ .buffer_size = 1522,
++ },
++ .aim_name = "networking",
++ .aim_param = "inic-usb-arx",
++ },
++ {
++ .ch_name = "ep06",
++ .cfg = {
++ .direction = MOST_CH_TX,
++ .data_type = MOST_CH_ASYNC,
++ .num_buffers = 20,
++ .buffer_size = 1522,
++ },
++ .aim_name = "networking",
++ .aim_param = "inic-usb-atx",
++ },
++ /* Streaming channels (common for all INICs) */
++ {
++ .ch_name = "ep01",
++ .cfg = {
++ .direction = MOST_CH_TX,
++ .data_type = MOST_CH_SYNC,
++ .num_buffers = 8,
++ .buffer_size = 2 * 12 * 42,
++ .subbuffer_size = 12,
++ .packets_per_xact = 42,
++ },
++ .aim_name = "sound",
++ .aim_param = "ep01-6ch.6x16",
++ },
++ {
++ .ch_name = "ep02",
++ .cfg = {
++ .direction = MOST_CH_TX,
++ .data_type = MOST_CH_ISOC,
++ .num_buffers = 8,
++ .buffer_size = 40 * 188,
++ .subbuffer_size = 188,
++ .packets_per_xact = 2,
++ },
++ .aim_name = "cdev",
++ .aim_param = "inic-usb-itx1",
++ },
++
++ /* sentinel */
++ {}
++};
++
++static struct most_config_set config_set = {
++ .probes = config_probes
++};
++
++static int __init mod_init(void)
++{
++ most_register_config_set(&config_set);
++ return 0;
++}
++
++static void __exit mod_exit(void)
++{
++ most_deregister_config_set(&config_set);
++}
++
++module_init(mod_init);
++module_exit(mod_exit);
++MODULE_LICENSE("GPL");
++MODULE_AUTHOR("Andrey Shvetsov <andrey.shvetsov@k2l.de>");
++MODULE_DESCRIPTION("Default configuration for the MOST channels");
+diff --git a/include/mostcore.h b/include/mostcore.h
+index dc87121..3c00efb 100644
+--- a/include/mostcore.h
++++ b/include/mostcore.h
+@@ -145,6 +145,39 @@ struct most_channel_config {
+ u16 dbr_size;
+ };
+
++/**
++ * struct most_config_probe - matching rule, channel configuration and
++ * the optional AIM name used for the automatic configuration and linking
++ * of the channel
++ * @dev_name: optional matching device id
++ * ("usb_device 1-1:1.0," "dim2-12345678", etc.)
++ * @ch_name: matching channel name ("ep8f", "ca2", etc.)
++ * @cfg: configuration that will be applied for the found channel
++ * @aim_name: optional name of the AIM that will be linked to the channel
++ * ("cdev", "networking", "v4l", "sound")
++ * @aim_param: AIM dependent parameter (it is the character device name
++ * for the cdev AIM, PCM format for the audio AIM, etc.)
++ */
++struct most_config_probe {
++ const char *dev_name;
++ const char *ch_name;
++ struct most_channel_config cfg;
++ const char *aim_name;
++ const char *aim_param;
++};
++
++/**
++ * struct most_config_set - the configuration set containing
++ * several automatic configurations for the different channels
++ * @probes: list of the matching rules and the configurations,
++ * that must be ended with the empty structure
++ * @list: list head used by the MostCore
++ */
++struct most_config_set {
++ const struct most_config_probe *probes;
++ struct list_head list;
++};
++
+ /*
+ * struct mbo - MOST Buffer Object.
+ * @context: context for core completion handler
+@@ -285,6 +318,37 @@ struct most_aim {
+ };
+
+ /**
++ * most_register_config_set - registers the configuration set
++ *
++ * @cfg_set: configuration set to be registered for the future probes
++ *
++ * The function registers the given configuration set.
++ *
++ * It is possible to register or deregister several configuration sets
++ * independently. Different configuration sets may contain the
++ * overlapped matching rules but later registered configuration set has
++ * the higher priority over the prior registered set.
++ *
++ * The only the first matched configuration is applied for each
++ * channel.
++ *
++ * The configuration for the channel is applied at the time of
++ * registration of the parent most_interface.
++ */
++void most_register_config_set(struct most_config_set *cfg_set);
++
++/**
++ * most_deregister_config_set - deregisters the prior registered
++ * configuration set
++ *
++ * @cfg_set: configuration set to be deregistered
++ *
++ * The calling of this function does not change the current
++ * configuration of the channels.
++ */
++void most_deregister_config_set(struct most_config_set *cfg_set);
++
++/**
+ * most_register_interface - Registers instance of the interface.
+ * @iface: Pointer to the interface instance description.
+ *
+diff --git a/mostcore/core.c b/mostcore/core.c
+index 9e0a352..6035cf0 100644
+--- a/mostcore/core.c
++++ b/mostcore/core.c
+@@ -36,6 +36,8 @@ static struct class *most_class;
+ static struct device *core_dev;
+ static struct ida mdev_id;
+ static int dummy_num_buffers;
++static struct list_head config_probes;
++struct mutex config_probes_mt; /* config_probes */
+
+ struct most_c_aim_obj {
+ struct most_aim *ptr;
+@@ -918,6 +920,30 @@ most_c_obj *get_channel_by_name(char *mdev, char *mdev_ch)
+ return c;
+ }
+
++static int link_channel_to_aim(struct most_c_obj *c, struct most_aim *aim,
++ char *aim_param)
++{
++ int ret;
++ struct most_aim **aim_ptr;
++
++ if (!c->aim0.ptr)
++ aim_ptr = &c->aim0.ptr;
++ else if (!c->aim1.ptr)
++ aim_ptr = &c->aim1.ptr;
++ else
++ return -ENOSPC;
++
++ *aim_ptr = aim;
++ ret = aim->probe_channel(c->iface, c->channel_id,
++ &c->cfg, &c->kobj, aim_param);
++ if (ret) {
++ *aim_ptr = NULL;
++ return ret;
++ }
++
++ return 0;
++}
++
+ /**
+ * add_link_store - store() function for add_link attribute
+ * @aim_obj: pointer to AIM object
+@@ -946,45 +972,33 @@ static ssize_t add_link_store(struct most_aim_obj *aim_obj,
+ size_t len)
+ {
+ struct most_c_obj *c;
+- struct most_aim **aim_ptr;
+ char buffer[STRING_SIZE];
+ char *mdev;
+ char *mdev_ch;
+- char *mdev_devnod;
++ char *aim_param;
+ char devnod_buf[STRING_SIZE];
+ int ret;
+ size_t max_len = min_t(size_t, len + 1, STRING_SIZE);
+
+ strlcpy(buffer, buf, max_len);
+
+- ret = split_string(buffer, &mdev, &mdev_ch, &mdev_devnod);
++ ret = split_string(buffer, &mdev, &mdev_ch, &aim_param);
+ if (ret)
+ return ret;
+
+- if (!mdev_devnod || *mdev_devnod == 0) {
++ if (!aim_param || *aim_param == 0) {
+ snprintf(devnod_buf, sizeof(devnod_buf), "%s-%s", mdev,
+ mdev_ch);
+- mdev_devnod = devnod_buf;
++ aim_param = devnod_buf;
+ }
+
+ c = get_channel_by_name(mdev, mdev_ch);
+ if (IS_ERR(c))
+ return -ENODEV;
+
+- if (!c->aim0.ptr)
+- aim_ptr = &c->aim0.ptr;
+- else if (!c->aim1.ptr)
+- aim_ptr = &c->aim1.ptr;
+- else
+- return -ENOSPC;
+-
+- *aim_ptr = aim_obj->driver;
+- ret = aim_obj->driver->probe_channel(c->iface, c->channel_id,
+- &c->cfg, &c->kobj, mdev_devnod);
+- if (ret) {
+- *aim_ptr = NULL;
++ ret = link_channel_to_aim(c, aim_obj->driver, aim_param);
++ if (ret)
+ return ret;
+- }
+
+ return len;
+ }
+@@ -1679,6 +1693,73 @@ int most_deregister_aim(struct most_aim *aim)
+ }
+ EXPORT_SYMBOL_GPL(most_deregister_aim);
+
++void most_register_config_set(struct most_config_set *cfg_set)
++{
++ mutex_lock(&config_probes_mt);
++ list_add(&cfg_set->list, &config_probes);
++ mutex_unlock(&config_probes_mt);
++}
++EXPORT_SYMBOL(most_register_config_set);
++
++void most_deregister_config_set(struct most_config_set *cfg_set)
++{
++ mutex_lock(&config_probes_mt);
++ list_del(&cfg_set->list);
++ mutex_unlock(&config_probes_mt);
++}
++EXPORT_SYMBOL(most_deregister_config_set);
++
++static int probe_aim(struct most_c_obj *c,
++ const char *aim_name, const char *aim_param)
++{
++ struct most_aim_obj *aim_obj;
++ char buf[STRING_SIZE];
++
++ list_for_each_entry(aim_obj, &aim_list, list) {
++ if (!strcmp(aim_obj->driver->name, aim_name)) {
++ strlcpy(buf, aim_param ? aim_param : "", sizeof(buf));
++ return link_channel_to_aim(c, aim_obj->driver, buf);
++ }
++ }
++ return 0;
++}
++
++static bool probe_config_set(struct most_c_obj *c,
++ const char *dev_name, const char *ch_name,
++ const struct most_config_probe *p)
++{
++ int err;
++
++ for (; p->ch_name; p++) {
++ if ((p->dev_name && strcmp(dev_name, p->dev_name)) ||
++ strcmp(ch_name, p->ch_name))
++ continue;
++
++ c->cfg = p->cfg;
++ if (p->aim_name) {
++ err = probe_aim(c, p->aim_name, p->aim_param);
++ if (err)
++ pr_err("failed to autolink %s to %s: %d\n",
++ ch_name, p->aim_name, err);
++ }
++ return true;
++ }
++ return false;
++}
++
++static void find_configuration(struct most_c_obj *c, const char *dev_name,
++ const char *ch_name)
++{
++ struct most_config_set *plist;
++
++ mutex_lock(&config_probes_mt);
++ list_for_each_entry(plist, &config_probes, list) {
++ if (probe_config_set(c, dev_name, ch_name, plist->probes))
++ break;
++ }
++ mutex_unlock(&config_probes_mt);
++}
++
+ /**
+ * most_register_interface - registers an interface with core
+ * @iface: pointer to the instance of the interface description.
+@@ -1777,6 +1858,7 @@ struct kobject *most_register_interface(struct most_interface *iface)
+ mutex_init(&c->start_mutex);
+ mutex_init(&c->nq_mutex);
+ list_add_tail(&c->list, &inst->channel_list);
++ find_configuration(c, iface->description, channel_name);
+ }
+ pr_info("registered new MOST device mdev%d (%s)\n",
+ inst->dev_id, iface->description);
+@@ -1880,6 +1962,8 @@ static int __init most_init(void)
+ pr_info("init()\n");
+ INIT_LIST_HEAD(&instance_list);
+ INIT_LIST_HEAD(&aim_list);
++ INIT_LIST_HEAD(&config_probes);
++ mutex_init(&config_probes_mt);
+ ida_init(&mdev_id);
+
+ err = bus_register(&most_bus);
+--
+2.7.4
+
diff --git a/recipes-kernel/most/files/0003-core-remove-kernel-log-for-MBO-status.patch b/recipes-kernel/most/files/0003-core-remove-kernel-log-for-MBO-status.patch
new file mode 100644
index 000000000..4703844a1
--- /dev/null
+++ b/recipes-kernel/most/files/0003-core-remove-kernel-log-for-MBO-status.patch
@@ -0,0 +1,26 @@
+From b269994be937cbb31c0d73ecc899ca8a545a6a4a Mon Sep 17 00:00:00 2001
+From: Christian Gromm <christian.gromm@microchip.com>
+Date: Mon, 4 Sep 2017 11:09:17 +0200
+Subject: [PATCH 3/5] core: remove kernel log for MBO status
+
+Signed-off-by: Christian Gromm <christian.gromm@microchip.com>
+---
+ driver/mostcore/core.c | 2 --
+ 1 file changed, 2 deletions(-)
+
+diff --git a/mostcore/core.c b/mostcore/core.c
+index 931efb9..595becc 100644
+--- a/mostcore/core.c
++++ b/mostcore/core.c
+@@ -1348,8 +1348,6 @@ static void most_write_completion(struct mbo *mbo)
+ BUG_ON((!mbo) || (!mbo->context));
+
+ c = mbo->context;
+- if (mbo->status == MBO_E_INVAL)
+- pr_info("WARN: Tx MBO status: invalid\n");
+ if (unlikely(c->is_poisoned || (mbo->status == MBO_E_CLOSE)))
+ trash_mbo(mbo);
+ else
+--
+2.7.4
+
diff --git a/recipes-kernel/most/files/0004-most-video-set-device_caps.patch b/recipes-kernel/most/files/0004-most-video-set-device_caps.patch
new file mode 100644
index 000000000..010d4b0d0
--- /dev/null
+++ b/recipes-kernel/most/files/0004-most-video-set-device_caps.patch
@@ -0,0 +1,25 @@
+From a5fd2ae8d4a3b2a8f7a33a4ea469ea7ee0d946ef Mon Sep 17 00:00:00 2001
+From: Christian Gromm <christian.gromm@microchip.com>
+Date: Mon, 4 Sep 2017 15:36:38 +0200
+Subject: [PATCH 4/5] most: video: set device_caps
+
+Signed-off-by: Christian Gromm <christian.gromm@microchip.com>
+---
+ driver/aim-v4l2/video.c | 1 +
+ 1 file changed, 1 insertion(+)
+
+diff --git a/aim-v4l2/video.c b/aim-v4l2/video.c
+index e074841..6405a03 100644
+--- a/aim-v4l2/video.c
++++ b/aim-v4l2/video.c
+@@ -263,6 +263,7 @@ static int vidioc_querycap(struct file *file, void *priv,
+ snprintf(cap->bus_info, sizeof(cap->bus_info),
+ "%s", mdev->iface->description);
+
++ cap->device_caps =
+ cap->capabilities =
+ V4L2_CAP_READWRITE |
+ V4L2_CAP_TUNER |
+--
+2.7.4
+
diff --git a/recipes-kernel/most/files/0005-most-video-set-V4L2_CAP_DEVICE_CAPS-flag.patch b/recipes-kernel/most/files/0005-most-video-set-V4L2_CAP_DEVICE_CAPS-flag.patch
new file mode 100644
index 000000000..ebaee9e14
--- /dev/null
+++ b/recipes-kernel/most/files/0005-most-video-set-V4L2_CAP_DEVICE_CAPS-flag.patch
@@ -0,0 +1,25 @@
+From 7518453386ad3e82008186a6c9ca86ed8c136801 Mon Sep 17 00:00:00 2001
+From: Christian Gromm <christian.gromm@microchip.com>
+Date: Mon, 4 Sep 2017 16:08:38 +0200
+Subject: [PATCH 5/5] most: video: set V4L2_CAP_DEVICE_CAPS flag
+
+Signed-off-by: Christian Gromm <christian.gromm@microchip.com>
+---
+ driver/aim-v4l2/video.c | 1 +
+ 1 file changed, 1 insertion(+)
+
+diff --git a/aim-v4l2/video.c b/aim-v4l2/video.c
+index 6405a03..db75d4d 100644
+--- a/aim-v4l2/video.c
++++ b/aim-v4l2/video.c
+@@ -265,6 +265,7 @@ static int vidioc_querycap(struct file *file, void *priv,
+
+ cap->device_caps =
+ cap->capabilities =
++ V4L2_CAP_DEVICE_CAPS |
+ V4L2_CAP_READWRITE |
+ V4L2_CAP_TUNER |
+ V4L2_CAP_VIDEO_CAPTURE;
+--
+2.7.4
+
diff --git a/recipes-kernel/most/files/0006-dim2-fix-startup-sequence.patch b/recipes-kernel/most/files/0006-dim2-fix-startup-sequence.patch
new file mode 100644
index 000000000..59c6ae671
--- /dev/null
+++ b/recipes-kernel/most/files/0006-dim2-fix-startup-sequence.patch
@@ -0,0 +1,186 @@
+From 63bcd9b421ae7927948bffec9566db47f40ea290 Mon Sep 17 00:00:00 2001
+From: Andrey Shvetsov <andrey.shvetsov@k2l.de>
+Date: Tue, 30 Jan 2018 17:34:09 +0100
+Subject: [PATCH] staging: most: dim2: fix startup sequence
+
+Platform specific initializations (pdata->init) must be done before DIM2
+IP module startup (dim_startup).
+
+Signed-off-by: Andrey Shvetsov <andrey.shvetsov@k2l.de>
+---
+ hdm-dim2/dim2_hdm.c | 90 +++++++++++++++++++++++++++++++++++++++---------------------------------------------------
+ 1 file changed, 39 insertions(+), 51 deletions(-)
+
+diff --git a/hdm-dim2/dim2_hdm.c b/hdm-dim2/dim2_hdm.c
+index 893b8e4..e4629a5 100644
+--- a/hdm-dim2/dim2_hdm.c
++++ b/hdm-dim2/dim2_hdm.c
+@@ -155,38 +155,6 @@ void dimcb_on_error(u8 error_id, const char *error_message)
+ }
+
+ /**
+- * startup_dim - initialize the dim2 interface
+- * @pdev: platform device
+- */
+-static int startup_dim(struct platform_device *pdev)
+-{
+- struct dim2_hdm *dev = platform_get_drvdata(pdev);
+- struct dim2_platform_data *pdata = pdev->dev.platform_data;
+- u8 hal_ret;
+- int ret;
+-
+- if (!pdata) {
+- pr_err("missing platform data\n");
+- return -EINVAL;
+- }
+-
+- ret = pdata->init ? pdata->init(pdata, dev->io_base) : 0;
+- if (ret)
+- return ret;
+-
+- pr_info("sync: num of frames per sub-buffer: %u\n", fcnt);
+- hal_ret = dim_startup(dev->io_base, pdata->clk_speed, fcnt);
+- if (hal_ret != DIM_NO_ERROR) {
+- pr_err("dim_startup failed: %d\n", hal_ret);
+- if (pdata && pdata->destroy)
+- pdata->destroy(pdata);
+- return -ENODEV;
+- }
+-
+- return 0;
+-}
+-
+-/**
+ * try_start_dim_transfer - try to transfer a buffer on a channel
+ * @hdm_ch: channel specific data
+ *
+@@ -727,10 +695,12 @@ static void dma_free(struct mbo *mbo, u32 size)
+ */
+ static int dim2_probe(struct platform_device *pdev)
+ {
++ struct dim2_platform_data *pdata = pdev->dev.platform_data;
+ struct dim2_hdm *dev;
+ struct resource *res;
+ int ret, i;
+ struct kobject *kobj;
++ u8 hal_ret;
+ int irq;
+
+ dev = devm_kzalloc(&pdev->dev, sizeof(*dev), GFP_KERNEL);
+@@ -745,38 +715,59 @@ static int dim2_probe(struct platform_device *pdev)
+ if (IS_ERR(dev->io_base))
+ return PTR_ERR(dev->io_base);
+
++ if (!pdata) {
++ dev_err(&pdev->dev, "missing platform data\n");
++ return -EINVAL;
++ }
++
++ ret = pdata->init ? pdata->init(pdata, dev->io_base) : 0;
++ if (ret)
++ return ret;
++
++ dev_info(&pdev->dev, "sync: num of frames per sub-buffer: %u\n", fcnt);
++ hal_ret = dim_startup(dev->io_base, pdata->clk_speed, fcnt);
++ if (hal_ret != DIM_NO_ERROR) {
++ dev_err(&pdev->dev, "dim_startup failed: %d\n", hal_ret);
++ ret = -ENODEV;
++ goto err_bsp_destroy;
++ }
++
+ irq = platform_get_irq(pdev, 0);
+ if (irq < 0) {
+ dev_err(&pdev->dev, "failed to get ahb0_int irq: %d\n", irq);
+- return irq;
++ ret = irq;
++ goto err_shutdown_dim;
+ }
+
+ ret = devm_request_irq(&pdev->dev, irq, dim2_ahb_isr, 0,
+ "dim2_ahb0_int", dev);
+ if (ret) {
+ dev_err(&pdev->dev, "failed to request ahb0_int irq %d\n", irq);
+- return ret;
++ goto err_shutdown_dim;
+ }
+
+ irq = platform_get_irq(pdev, 1);
+ if (irq < 0) {
+ dev_err(&pdev->dev, "failed to get mlb_int irq: %d\n", irq);
+- return irq;
++ ret = irq;
++ goto err_shutdown_dim;
+ }
+
+ ret = devm_request_irq(&pdev->dev, irq, dim2_mlb_isr, 0,
+ "dim2_mlb_int", dev);
+ if (ret) {
+ dev_err(&pdev->dev, "failed to request mlb_int irq %d\n", irq);
+- return ret;
++ goto err_shutdown_dim;
+ }
+
+ init_waitqueue_head(&dev->netinfo_waitq);
+ dev->deliver_netinfo = 0;
+- dev->netinfo_task = kthread_run(&deliver_netinfo_thread, (void *)dev,
++ dev->netinfo_task = kthread_run(&deliver_netinfo_thread, dev,
+ "dim2_netinfo");
+- if (IS_ERR(dev->netinfo_task))
+- return PTR_ERR(dev->netinfo_task);
++ if (IS_ERR(dev->netinfo_task)) {
++ ret = PTR_ERR(dev->netinfo_task);
++ goto err_shutdown_dim;
++ }
+
+ for (i = 0; i < DMA_CHANNELS; i++) {
+ struct most_channel_capability *cap = dev->capabilities + i;
+@@ -833,20 +824,17 @@ static int dim2_probe(struct platform_device *pdev)
+ if (ret)
+ goto err_unreg_iface;
+
+- ret = startup_dim(pdev);
+- if (ret) {
+- dev_err(&pdev->dev, "failed to initialize DIM2\n");
+- goto err_destroy_bus;
+- }
+-
+ return 0;
+
+-err_destroy_bus:
+- dim2_sysfs_destroy(&dev->bus);
+ err_unreg_iface:
+ most_deregister_interface(&dev->most_iface);
+ err_stop_thread:
+ kthread_stop(dev->netinfo_task);
++err_shutdown_dim:
++ dim_shutdown();
++err_bsp_destroy:
++ if (pdata && pdata->destroy)
++ pdata->destroy(pdata);
+
+ return ret;
+ }
+@@ -863,6 +851,10 @@ static int dim2_remove(struct platform_device *pdev)
+ struct dim2_platform_data *pdata = pdev->dev.platform_data;
+ unsigned long flags;
+
++ dim2_sysfs_destroy(&dev->bus);
++ most_deregister_interface(&dev->most_iface);
++ kthread_stop(dev->netinfo_task);
++
+ spin_lock_irqsave(&dim_lock, flags);
+ dim_shutdown();
+ spin_unlock_irqrestore(&dim_lock, flags);
+@@ -870,10 +862,6 @@ static int dim2_remove(struct platform_device *pdev)
+ if (pdata && pdata->destroy)
+ pdata->destroy(pdata);
+
+- dim2_sysfs_destroy(&dev->bus);
+- most_deregister_interface(&dev->most_iface);
+- kthread_stop(dev->netinfo_task);
+-
+ /*
+ * break link to local platform_device_id struct
+ * to prevent crash by unload platform device module
+--
+libgit2 0.26.0
diff --git a/recipes-kernel/most/files/0007-dim2-use-device-tree.patch b/recipes-kernel/most/files/0007-dim2-use-device-tree.patch
new file mode 100644
index 000000000..679fab79c
--- /dev/null
+++ b/recipes-kernel/most/files/0007-dim2-use-device-tree.patch
@@ -0,0 +1,378 @@
+From 8e16207392cd715ea88f6780981a3d55ab005588 Mon Sep 17 00:00:00 2001
+From: Andrey Shvetsov <andrey.shvetsov@k2l.de>
+Date: Mon, 12 Feb 2018 12:23:37 +0100
+Subject: [PATCH] staging: most: dim2: use device tree
+
+Current dim2 driver expects the existence of a platform driver that
+implements the platform specific initialization and delivery of the irq
+numbers.
+
+This patch integrates the device tree activity and platform specific
+code into the driver.
+
+Signed-off-by: Andrey Shvetsov <andrey.shvetsov@k2l.de>
+---
+ hdm-dim2/dim2_hdm.c | 222 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-----------------------------
+ hdm-dim2/dim2_hdm.h | 28 ----------------------------
+ hdm-dim2/platform/dim2_arwen_mlb3.c | 165 ---------------------------------------------------------------------------------------------------------------------------------------------------------------------
+ hdm-dim2/platform/dim2_arwen_mlb6.c | 169 -------------------------------------------------------------------------------------------------------------------------------------------------------------------------
+ hdm-dim2/platform/dim2_h2_dt.c | 227 -----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
+ hdm-dim2/platform/dim2_mx6q.c | 192 ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
+ hdm-dim2/platform/dim2_mx6q_dt.c | 224 --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
+ 7 files changed, 193 insertions(+), 1034 deletions(-)
+ delete mode 100644 hdm-dim2/dim2_hdm.h
+ delete mode 100644 hdm-dim2/platform/dim2_arwen_mlb3.c
+ delete mode 100644 hdm-dim2/platform/dim2_arwen_mlb6.c
+ delete mode 100644 hdm-dim2/platform/dim2_h2_dt.c
+ delete mode 100644 hdm-dim2/platform/dim2_mx6q.c
+ delete mode 100644 hdm-dim2/platform/dim2_mx6q_dt.c
+
+diff --git a/hdm-dim2/dim2_hdm.c b/hdm-dim2/dim2_hdm.c
+index e4629a5..2dba917 100644
+--- a/hdm-dim2/dim2_hdm.c
++++ b/hdm-dim2/dim2_hdm.c
+@@ -14,6 +14,7 @@
+ #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
+
+ #include <linux/module.h>
++#include <linux/of_platform.h>
+ #include <linux/printk.h>
+ #include <linux/kernel.h>
+ #include <linux/init.h>
+@@ -21,13 +22,13 @@
+ #include <linux/interrupt.h>
+ #include <linux/slab.h>
+ #include <linux/io.h>
++#include <linux/clk.h>
+ #include <linux/dma-mapping.h>
+ #include <linux/sched.h>
+ #include <linux/kthread.h>
+
+ #include <mostcore.h>
+ #include "dim2_hal.h"
+-#include "dim2_hdm.h"
+ #include "dim2_errors.h"
+ #include "dim2_sysfs.h"
+
+@@ -93,6 +94,9 @@ struct dim2_hdm {
+ struct most_interface most_iface;
+ char name[16 + sizeof "dim2-"];
+ void __iomem *io_base;
++ u8 clk_speed;
++ struct clk *clk;
++ struct clk *clk_pll;
+ struct task_struct *netinfo_task;
+ wait_queue_head_t netinfo_waitq;
+ int deliver_netinfo;
+@@ -102,6 +106,12 @@ struct dim2_hdm {
+ struct medialb_bus bus;
+ void (*on_netinfo)(struct most_interface *,
+ unsigned char, unsigned char *);
++ void (*disable_platform)(struct platform_device *);
++};
++
++struct dim2_platform_data {
++ int (*enable)(struct platform_device *);
++ void (*disable)(struct platform_device *);
+ };
+
+ #define iface_to_hdm(iface) container_of(iface, struct dim2_hdm, most_iface)
+@@ -686,6 +696,8 @@ static void dma_free(struct mbo *mbo, u32 size)
+ dma_free_coherent(NULL, size, mbo->virt_address, mbo->bus_address);
+ }
+
++static const struct of_device_id dim2_of_match[];
++
+ /*
+ * dim2_probe - dim2 probe handler
+ * @pdev: platform device structure
+@@ -695,7 +707,7 @@ static void dma_free(struct mbo *mbo, u32 size)
+ */
+ static int dim2_probe(struct platform_device *pdev)
+ {
+- struct dim2_platform_data *pdata = pdev->dev.platform_data;
++ const struct dim2_platform_data *pdata;
+ struct dim2_hdm *dev;
+ struct resource *res;
+ int ret, i;
+@@ -703,6 +715,8 @@ static int dim2_probe(struct platform_device *pdev)
+ u8 hal_ret;
+ int irq;
+
++ enum { MLB_INT_IDX, AHB0_INT_IDX };
++
+ dev = devm_kzalloc(&pdev->dev, sizeof(*dev), GFP_KERNEL);
+ if (!dev)
+ return -ENOMEM;
+@@ -710,29 +724,30 @@ static int dim2_probe(struct platform_device *pdev)
+ dev->atx_idx = -1;
+
+ platform_set_drvdata(pdev, dev);
++
++ dev->clk_speed = CLK_4096FS;
++
+ res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+ dev->io_base = devm_ioremap_resource(&pdev->dev, res);
+ if (IS_ERR(dev->io_base))
+ return PTR_ERR(dev->io_base);
+
+- if (!pdata) {
+- dev_err(&pdev->dev, "missing platform data\n");
+- return -EINVAL;
+- }
+-
+- ret = pdata->init ? pdata->init(pdata, dev->io_base) : 0;
++ pdata = of_match_node(dim2_of_match, pdev->dev.of_node)->data;
++ ret = pdata && pdata->enable ? pdata->enable(pdev) : 0;
+ if (ret)
+ return ret;
+
++ dev->disable_platform = pdata ? pdata->disable : 0;
++
+ dev_info(&pdev->dev, "sync: num of frames per sub-buffer: %u\n", fcnt);
+- hal_ret = dim_startup(dev->io_base, pdata->clk_speed, fcnt);
++ hal_ret = dim_startup(dev->io_base, dev->clk_speed, fcnt);
+ if (hal_ret != DIM_NO_ERROR) {
+ dev_err(&pdev->dev, "dim_startup failed: %d\n", hal_ret);
+ ret = -ENODEV;
+- goto err_bsp_destroy;
++ goto err_disable_platform;
+ }
+
+- irq = platform_get_irq(pdev, 0);
++ irq = platform_get_irq(pdev, AHB0_INT_IDX);
+ if (irq < 0) {
+ dev_err(&pdev->dev, "failed to get ahb0_int irq: %d\n", irq);
+ ret = irq;
+@@ -746,7 +761,7 @@ static int dim2_probe(struct platform_device *pdev)
+ goto err_shutdown_dim;
+ }
+
+- irq = platform_get_irq(pdev, 1);
++ irq = platform_get_irq(pdev, MLB_INT_IDX);
+ if (irq < 0) {
+ dev_err(&pdev->dev, "failed to get mlb_int irq: %d\n", irq);
+ ret = irq;
+@@ -832,9 +847,9 @@ static int dim2_probe(struct platform_device *pdev)
+ kthread_stop(dev->netinfo_task);
+ err_shutdown_dim:
+ dim_shutdown();
+-err_bsp_destroy:
+- if (pdata && pdata->destroy)
+- pdata->destroy(pdata);
++err_disable_platform:
++ if (dev->disable_platform)
++ dev->disable_platform(pdev);
+
+ return ret;
+ }
+@@ -848,7 +863,6 @@ static int dim2_probe(struct platform_device *pdev)
+ static int dim2_remove(struct platform_device *pdev)
+ {
+ struct dim2_hdm *dev = platform_get_drvdata(pdev);
+- struct dim2_platform_data *pdata = pdev->dev.platform_data;
+ unsigned long flags;
+
+ dim2_sysfs_destroy(&dev->bus);
+@@ -859,37 +873,187 @@ static int dim2_remove(struct platform_device *pdev)
+ dim_shutdown();
+ spin_unlock_irqrestore(&dim_lock, flags);
+
+- if (pdata && pdata->destroy)
+- pdata->destroy(pdata);
++ if (dev->disable_platform)
++ dev->disable_platform(pdev);
++
++ return 0;
++}
++
++/* platform specific functions [[ */
++
++static int fsl_mx6_enable(struct platform_device *pdev)
++{
++ struct dim2_hdm *dev = platform_get_drvdata(pdev);
++ int ret;
++
++ dev->clk = devm_clk_get(&pdev->dev, "mlb");
++ if (IS_ERR_OR_NULL(dev->clk)) {
++ dev_err(&pdev->dev, "unable to get mlb clock\n");
++ return -EFAULT;
++ }
++
++ ret = clk_prepare_enable(dev->clk);
++ if (ret) {
++ dev_err(&pdev->dev, "%s\n", "clk_prepare_enable failed");
++ return ret;
++ }
++
++ if (dev->clk_speed >= CLK_2048FS) {
++ /* enable pll */
++ dev->clk_pll = devm_clk_get(&pdev->dev, "pll8_mlb");
++ if (IS_ERR_OR_NULL(dev->clk_pll)) {
++ dev_err(&pdev->dev, "unable to get mlb pll clock\n");
++ clk_disable_unprepare(dev->clk);
++ return -EFAULT;
++ }
++
++ writel(0x888, dev->io_base + 0x38);
++ clk_prepare_enable(dev->clk_pll);
++ }
++
++ return 0;
++}
++
++static void fsl_mx6_disable(struct platform_device *pdev)
++{
++ struct dim2_hdm *dev = platform_get_drvdata(pdev);
++
++ if (dev->clk_speed >= CLK_2048FS)
++ clk_disable_unprepare(dev->clk_pll);
++
++ clk_disable_unprepare(dev->clk);
++}
++
++static int rcar_h2_enable(struct platform_device *pdev)
++{
++ struct dim2_hdm *dev = platform_get_drvdata(pdev);
++ int ret;
++
++ dev->clk = devm_clk_get(&pdev->dev, NULL);
++ if (IS_ERR(dev->clk)) {
++ dev_err(&pdev->dev, "cannot get clock\n");
++ return PTR_ERR(dev->clk);
++ }
++
++ ret = clk_prepare_enable(dev->clk);
++ if (ret) {
++ dev_err(&pdev->dev, "%s\n", "clk_prepare_enable failed");
++ return ret;
++ }
++
++ if (dev->clk_speed >= CLK_2048FS) {
++ /* enable MLP pll and LVDS drivers */
++ writel(0x03, dev->io_base + 0x600);
++ /* set bias */
++ writel(0x888, dev->io_base + 0x38);
++ } else {
++ /* PLL */
++ writel(0x04, dev->io_base + 0x600);
++ }
++
+
+- /*
+- * break link to local platform_device_id struct
+- * to prevent crash by unload platform device module
+- */
+- pdev->id_entry = NULL;
++ /* BBCR = 0b11 */
++ writel(0x03, dev->io_base + 0x500);
++ writel(0x0002FF02, dev->io_base + 0x508);
+
+ return 0;
+ }
+
+-static const struct platform_device_id dim2_id[] = {
+- { "medialb_dim2" },
+- { }, /* Terminating entry */
++static void rcar_h2_disable(struct platform_device *pdev)
++{
++ struct dim2_hdm *dev = platform_get_drvdata(pdev);
++
++ clk_disable_unprepare(dev->clk);
++
++ /* disable PLLs and LVDS drivers */
++ writel(0x0, dev->io_base + 0x600);
++}
++
++static int rcar_m3_enable(struct platform_device *pdev)
++{
++ struct dim2_hdm *dev = platform_get_drvdata(pdev);
++ u32 enable_512fs = dev->clk_speed == CLK_512FS;
++ int ret;
++
++ dev->clk = devm_clk_get(&pdev->dev, NULL);
++ if (IS_ERR(dev->clk)) {
++ dev_err(&pdev->dev, "cannot get clock\n");
++ return PTR_ERR(dev->clk);
++ }
++
++ ret = clk_prepare_enable(dev->clk);
++ if (ret) {
++ dev_err(&pdev->dev, "%s\n", "clk_prepare_enable failed");
++ return ret;
++ }
++
++ /* PLL */
++ writel(0x04, dev->io_base + 0x600);
++
++ writel(enable_512fs, dev->io_base + 0x604);
++
++ /* BBCR = 0b11 */
++ writel(0x03, dev->io_base + 0x500);
++ writel(0x0002FF02, dev->io_base + 0x508);
++
++ return 0;
++}
++
++static void rcar_m3_disable(struct platform_device *pdev)
++{
++ struct dim2_hdm *dev = platform_get_drvdata(pdev);
++
++ clk_disable_unprepare(dev->clk);
++
++ /* disable PLLs and LVDS drivers */
++ writel(0x0, dev->io_base + 0x600);
++}
++
++/* ]] platform specific functions */
++
++enum dim2_platforms { FSL_MX6, RCAR_H2, RCAR_M3 };
++
++static struct dim2_platform_data plat_data[] = {
++ [FSL_MX6] = { .enable = fsl_mx6_enable, .disable = fsl_mx6_disable },
++ [RCAR_H2] = { .enable = rcar_h2_enable, .disable = rcar_h2_disable },
++ [RCAR_M3] = { .enable = rcar_m3_enable, .disable = rcar_m3_disable },
++};
++
++static const struct of_device_id dim2_of_match[] = {
++ {
++ .compatible = "fsl,imx6q-mlb150",
++ .data = plat_data + FSL_MX6
++ },
++ {
++ .compatible = "renesas,mlp",
++ .data = plat_data + RCAR_H2
++ },
++ {
++ .compatible = "rcar,medialb-dim2",
++ .data = plat_data + RCAR_M3
++ },
++ {
++ .compatible = "xlnx,axi4-os62420_3pin-1.00.a",
++ },
++ {
++ .compatible = "xlnx,axi4-os62420_6pin-1.00.a",
++ },
++ {},
+ };
+
+-MODULE_DEVICE_TABLE(platform, dim2_id);
++MODULE_DEVICE_TABLE(of, dim2_of_match);
+
+ static struct platform_driver dim2_driver = {
+ .probe = dim2_probe,
+ .remove = dim2_remove,
+- .id_table = dim2_id,
+ .driver = {
+ .name = "hdm_dim2",
++ .of_match_table = dim2_of_match,
+ },
+ };
+
+ module_platform_driver(dim2_driver);
+
+-MODULE_AUTHOR("Jain Roy Ambi <JainRoy.Ambi@microchip.com>");
+ MODULE_AUTHOR("Andrey Shvetsov <andrey.shvetsov@k2l.de>");
+ MODULE_DESCRIPTION("MediaLB DIM2 Hardware Dependent Module");
+ MODULE_LICENSE("GPL");
+libgit2 0.26.0
diff --git a/recipes-kernel/most/files/0008-dim2-read-clock-speed-from-the-device-tree.patch b/recipes-kernel/most/files/0008-dim2-read-clock-speed-from-the-device-tree.patch
new file mode 100644
index 000000000..1b01fb156
--- /dev/null
+++ b/recipes-kernel/most/files/0008-dim2-read-clock-speed-from-the-device-tree.patch
@@ -0,0 +1,92 @@
+From 839ad403a2d8081a6c15f6fc2836b01919338f3c Mon Sep 17 00:00:00 2001
+From: Andrey Shvetsov <andrey.shvetsov@k2l.de>
+Date: Mon, 12 Feb 2018 12:24:37 +0100
+Subject: [PATCH] staging: most: dim2: read clock speed from the device tree
+
+This implements reading of the clock speed parameter from the device
+tree.
+
+Signed-off-by: Andrey Shvetsov <andrey.shvetsov@k2l.de>
+---
+ Documentation/devicetree/bindings/inic/microchip,inic-dim2.txt | 64 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+ hdm-dim2/dim2_hdm.c | 50 +++++++++++++++++++++++++++++++++++++++++++++++++-
+ 2 files changed, 113 insertions(+), 1 deletion(-)
+ create mode 100644 Documentation/devicetree/bindings/inic/microchip,inic-dim2.txt
+
+diff --git a/hdm-dim2/dim2_hdm.c b/hdm-dim2/dim2_hdm.c
+index 2dba917..05e1896 100644
+--- a/hdm-dim2/dim2_hdm.c
++++ b/hdm-dim2/dim2_hdm.c
+@@ -698,6 +698,42 @@ static void dma_free(struct mbo *mbo, u32 size)
+
+ static const struct of_device_id dim2_of_match[];
+
++static struct {
++ const char *clock_speed;
++ u8 clk_speed;
++} clk_mt[] = {
++ { "256fs", CLK_256FS },
++ { "512fs", CLK_512FS },
++ { "1024fs", CLK_1024FS },
++ { "2048fs", CLK_2048FS },
++ { "3072fs", CLK_3072FS },
++ { "4096fs", CLK_4096FS },
++ { "6144fs", CLK_6144FS },
++ { "8192fs", CLK_8192FS },
++};
++
++/**
++ * get_dim2_clk_speed - converts string to DIM2 clock speed value
++ *
++ * @clock_speed: string in the format "{NUMBER}fs"
++ * @val: pointer to get one of the CLK_{NUMBER}FS values
++ *
++ * By success stores one of the CLK_{NUMBER}FS in the *val and returns 0,
++ * otherwise returns -EINVAL.
++ */
++static int get_dim2_clk_speed(const char *clock_speed, u8 *val)
++{
++ int i;
++
++ for (i = 0; i < ARRAY_SIZE(clk_mt); i++) {
++ if (!strcmp(clock_speed, clk_mt[i].clock_speed)) {
++ *val = clk_mt[i].clk_speed;
++ return 0;
++ }
++ }
++ return -EINVAL;
++}
++
+ /*
+ * dim2_probe - dim2 probe handler
+ * @pdev: platform device structure
+@@ -708,6 +744,7 @@ static const struct of_device_id dim2_of_match[];
+ static int dim2_probe(struct platform_device *pdev)
+ {
+ const struct dim2_platform_data *pdata;
++ const char *clock_speed;
+ struct dim2_hdm *dev;
+ struct resource *res;
+ int ret, i;
+@@ -725,7 +762,18 @@ static int dim2_probe(struct platform_device *pdev)
+
+ platform_set_drvdata(pdev, dev);
+
+- dev->clk_speed = CLK_4096FS;
++ ret = of_property_read_string(pdev->dev.of_node,
++ "microchip,clock-speed", &clock_speed);
++ if (ret) {
++ dev_err(&pdev->dev, "missing dt property clock-speed\n");
++ return ret;
++ }
++
++ ret = get_dim2_clk_speed(clock_speed, &dev->clk_speed);
++ if (ret) {
++ dev_err(&pdev->dev, "bad dt property clock-speed\n");
++ return ret;
++ }
+
+ res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+ dev->io_base = devm_ioremap_resource(&pdev->dev, res);
+--
+libgit2 0.26.0
diff --git a/recipes-kernel/most/files/0009-dim2-use-device-for-coherent-memory-allocation.patch b/recipes-kernel/most/files/0009-dim2-use-device-for-coherent-memory-allocation.patch
new file mode 100644
index 000000000..08cd6f99d
--- /dev/null
+++ b/recipes-kernel/most/files/0009-dim2-use-device-for-coherent-memory-allocation.patch
@@ -0,0 +1,47 @@
+From 756f2f1f90524c2620ed7951e436d13bdb929a6b Mon Sep 17 00:00:00 2001
+From: Andrey Shvetsov <andrey.shvetsov@k2l.de>
+Date: Mon, 12 Feb 2018 12:25:37 +0100
+Subject: [PATCH] staging: most: dim2: use device for coherent memory allocation
+
+On several modern architectures the allocation of coherent memory needs
+a device that has the dma_ops properly set. This patch enables use of
+the DIM2 platform device for the allocation process.
+
+Signed-off-by: Andrey Shvetsov <andrey.shvetsov@k2l.de>
+---
+ hdm-dim2/dim2_hdm.c | 9 +++++++--
+ 1 file changed, 7 insertions(+), 2 deletions(-)
+
+diff --git a/hdm-dim2/dim2_hdm.c b/hdm-dim2/dim2_hdm.c
+index 05e1896..1847091 100644
+--- a/hdm-dim2/dim2_hdm.c
++++ b/hdm-dim2/dim2_hdm.c
+@@ -688,12 +688,16 @@ static int poison_channel(struct most_interface *most_iface, int ch_idx)
+
+ static void *dma_alloc(struct mbo *mbo, u32 size)
+ {
+- return dma_alloc_coherent(NULL, size, &mbo->bus_address, GFP_KERNEL);
++ struct device *dev = mbo->ifp->dev;
++
++ return dma_alloc_coherent(dev, size, &mbo->bus_address, GFP_KERNEL);
+ }
+
+ static void dma_free(struct mbo *mbo, u32 size)
+ {
+- dma_free_coherent(NULL, size, mbo->virt_address, mbo->bus_address);
++ struct device *dev = mbo->ifp->dev;
++
++ dma_free_coherent(dev, size, mbo->virt_address, mbo->bus_address);
+ }
+
+ static const struct of_device_id dim2_of_match[];
+@@ -875,6 +879,7 @@ static int dim2_probe(struct platform_device *pdev)
+ dev->most_iface.poison_channel = poison_channel;
+ dev->most_iface.request_netinfo = request_netinfo;
+ dev->most_iface.extra_attrs = DBR_ATTRS;
++ dev->most_iface.dev = &pdev->dev;
+
+ kobj = most_register_interface(&dev->most_iface);
+ if (IS_ERR(kobj)) {
+--
+libgit2 0.26.0
diff --git a/recipes-kernel/most/files/0010-backport-usb-setup-timer.patch b/recipes-kernel/most/files/0010-backport-usb-setup-timer.patch
new file mode 100644
index 000000000..ff21b2130
--- /dev/null
+++ b/recipes-kernel/most/files/0010-backport-usb-setup-timer.patch
@@ -0,0 +1,35 @@
+From 8eaec876f732c7e4b238ada5f9304c6da2380eb1 Mon Sep 17 00:00:00 2001
+From: Andrey Shvetsov <andrey.shvetsov@k2l.de>
+Date: Fri, 8 Feb 2019 22:44:32 +0000
+Subject: [PATCH] backport: usb: setup_timer
+
+---
+ driver/hdm-usb/hdm_usb.c | 7 +++----
+ 1 file changed, 3 insertions(+), 4 deletions(-)
+
+diff --git a/hdm-usb/hdm_usb.c b/hdm-usb/hdm_usb.c
+index 5b0af88..9896835 100644
+--- a/hdm-usb/hdm_usb.c
++++ b/hdm-usb/hdm_usb.c
+@@ -760,9 +760,9 @@ static void hdm_request_netinfo(struct most_interface *iface, int channel,
+ * The handler runs in interrupt context. That's why we need to defer the
+ * tasks to a work queue.
+ */
+-static void link_stat_timer_handler(unsigned long data)
++static void link_stat_timer_handler(struct timer_list *t)
+ {
+- struct most_dev *mdev = (struct most_dev *)data;
++ struct most_dev *mdev = from_timer(mdev, t, link_stat_timer);
+
+ schedule_work(&mdev->poll_work_obj);
+ mdev->link_stat_timer.expires = jiffies + (2 * HZ);
+@@ -1154,8 +1154,7 @@ hdm_probe(struct usb_interface *interface, const struct usb_device_id *id)
+ num_endpoints = usb_iface_desc->desc.bNumEndpoints;
+ mutex_init(&mdev->io_mutex);
+ INIT_WORK(&mdev->poll_work_obj, wq_netinfo);
+- setup_timer(&mdev->link_stat_timer, link_stat_timer_handler,
+- (unsigned long)mdev);
++ timer_setup(&mdev->link_stat_timer, link_stat_timer_handler, 0);
+
+ mdev->usb_device = usb_dev;
+ mdev->link_stat_timer.expires = jiffies + (2 * HZ);
diff --git a/recipes-kernel/most/files/0011-handle-snd_pcm_lib_mmap_vmalloc-removal.patch b/recipes-kernel/most/files/0011-handle-snd_pcm_lib_mmap_vmalloc-removal.patch
new file mode 100644
index 000000000..d4383c4f6
--- /dev/null
+++ b/recipes-kernel/most/files/0011-handle-snd_pcm_lib_mmap_vmalloc-removal.patch
@@ -0,0 +1,30 @@
+Handle snd_pcm_lib_mmap_vmalloc removal in 4.19
+
+Add .mmap field back to pcm_ops for kernels older than 4.19.
+
+Upstream-Status: Inappropriate
+
+Signed-off-by: Scott Murray <scott.murray@konsulko.com>
+
+diff --git a/aim-sound/sound.c b/aim-sound/sound.c
+index 4b3329b..c0a26be 100644
+--- a/aim-sound/sound.c
++++ b/aim-sound/sound.c
+@@ -17,6 +17,7 @@
+ #include <linux/printk.h>
+ #include <linux/kernel.h>
+ #include <linux/init.h>
++#include <linux/version.h>
+ #include <sound/core.h>
+ #include <sound/pcm.h>
+ #include <sound/pcm_params.h>
+@@ -463,6 +464,9 @@ static const struct snd_pcm_ops pcm_ops = {
+ .trigger = pcm_trigger,
+ .pointer = pcm_pointer,
+ .page = snd_pcm_lib_get_vmalloc_page,
++#if LINUX_VERSION_CODE < KERNEL_VERSION(4,19,0)
++ .mmap = snd_pcm_lib_mmap_vmalloc,
++#endif
+ };
+
+ static int split_arg_list(char *buf, char **card_name, u16 *ch_num,
diff --git a/recipes-kernel/most/files/0012-Fix-build-with-5.4-kernel.patch b/recipes-kernel/most/files/0012-Fix-build-with-5.4-kernel.patch
new file mode 100644
index 000000000..02eca27d2
--- /dev/null
+++ b/recipes-kernel/most/files/0012-Fix-build-with-5.4-kernel.patch
@@ -0,0 +1,68 @@
+From 877d7475413bb787deb07aa83bafac03efa399fa Mon Sep 17 00:00:00 2001
+From: Paul Barker <paul.barker@sancloud.co.uk>
+Date: Mon, 24 Feb 2020 14:58:52 +0000
+Subject: [PATCH] Fix build with 5.4 kernel
+
+Signed-off-by: Paul Barker <paul.barker@sancloud.co.uk>
+---
+ driver/Makefile | 11 ++++++++++-
+ 1 file changed, 10 insertions(+), 1 deletion(-)
+
+diff --git a/Makefile b/Makefile
+index 281241d..609e692 100644
+--- a/Makefile
++++ b/Makefile
+@@ -5,6 +5,7 @@ SRC := $(shell pwd)
+ obj-m := mostcore.o
+ mostcore-y := mostcore/core.o
+ CFLAGS_core.o := -I$(src)/include/
++CFLAGS_mostcore/core.o := -I$(src)/include/
+
+ obj-m += default_conf.o
+ CFLAGL_default_conf.o := -I$(src)/include
+@@ -12,33 +13,41 @@ CFLAGL_default_conf.o := -I$(src)/include
+ obj-m += aim_cdev.o
+ aim_cdev-y := aim-cdev/cdev.o
+ CFLAGS_cdev.o := -I$(src)/include/
++CFLAGS_aim-cdev/cdev.o := -I$(src)/include/
+
+ obj-m += aim_network.o
+ aim_network-y := aim-network/networking.o
+ CFLAGS_networking.o := -I$(src)/include/
++CFLAGS_aim-network/networking.o := -I$(src)/include/
+
+ obj-m += aim_sound.o
+ aim_sound-y := aim-sound/sound.o
+ CFLAGS_sound.o := -I$(src)/include/
++CFLAGS_aim-sound/sound.o := -I$(src)/include/
+
+ obj-m += aim_v4l2.o
+ aim_v4l2-y := aim-v4l2/video.o
+ CFLAGS_video.o := -Idrivers/media/video -I$(src)/include/
++CFLAGS_aim-v4l2/video.o := -Idrivers/media/video -I$(src)/include/
+
+ obj-m += hdm_i2c.o
+ hdm_i2c-y := hdm-i2c/hdm_i2c.o
+ CFLAGS_hdm_i2c.o := -I$(src)/include/
++CFLAGS_hdm-i2c/hdm_i2c.o := -I$(src)/include/
+
+ ifdef CONFIG_OF
+ obj-m += hdm_dim2.o
+ hdm_dim2-y := hdm-dim2/dim2_hdm.o hdm-dim2/dim2_hal.o hdm-dim2/dim2_sysfs.o
+ CFLAGS_dim2_hdm.o := -I$(src)/include/
++CFLAGS_hdm-dim2/dim2_hdm.o := -I$(src)/include/
++CFLAGS_hdm-dim2/dim2_hal.o := -I$(src)/include/
++CFLAGS_hdm-dim2/dim2_sysfs.o := -I$(src)/include/
+ endif
+
+ obj-m += hdm_usb.o
+ hdm_usb-y := hdm-usb/hdm_usb.o
+ CFLAGS_hdm_usb.o := -I$(src)/include/
+-
++CFLAGS_hdm-usb/hdm_usb.o := -I$(src)/include/
+
+ all:
+ $(MAKE) -C $(KERNEL_SRC) M=$(SRC) modules
+--
+2.20.1
+
diff --git a/recipes-kernel/most/most.bb b/recipes-kernel/most/most.bb
new file mode 100644
index 000000000..48959a6ee
--- /dev/null
+++ b/recipes-kernel/most/most.bb
@@ -0,0 +1,14 @@
+DESCRIPTION = "Build MOST driver"
+LICENSE = "GPLv2"
+LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/GPL-2.0;md5=801f80980d171dd6425610833a22dbe6"
+
+inherit module
+
+PV = "0.1"
+
+SRC_URI = "git://gerrit.automotivelinux.org/gerrit/src/most;protocol=https;branch=${AGL_BRANCH}"
+
+S = "${WORKDIR}/git/driver"
+SRCREV = "e4dbbaf9e7652efaed0df3e0aab4464f5f228573"
+
+KERNEL_MODULE_AUTOLOAD += "aim_cdev aim_sound aim_network aim_v4l2 hdm_i2c hdm_dim2 hdm_usb mostcore"
diff --git a/recipes-kernel/most/most.bbappend b/recipes-kernel/most/most.bbappend
new file mode 100644
index 000000000..ad422eb57
--- /dev/null
+++ b/recipes-kernel/most/most.bbappend
@@ -0,0 +1,15 @@
+FILESEXTRAPATHS_prepend := "${THISDIR}/files:"
+
+SRC_URI_append = " \
+ file://0002-src-most-add-auto-conf-feature.patch \
+ file://0003-core-remove-kernel-log-for-MBO-status.patch \
+ file://0004-most-video-set-device_caps.patch \
+ file://0005-most-video-set-V4L2_CAP_DEVICE_CAPS-flag.patch \
+ file://0006-dim2-fix-startup-sequence.patch \
+ file://0007-dim2-use-device-tree.patch \
+ file://0008-dim2-read-clock-speed-from-the-device-tree.patch \
+ file://0009-dim2-use-device-for-coherent-memory-allocation.patch \
+ file://0010-backport-usb-setup-timer.patch \
+ file://0011-handle-snd_pcm_lib_mmap_vmalloc-removal.patch \
+ file://0012-Fix-build-with-5.4-kernel.patch \
+"