summaryrefslogtreecommitdiffstats
path: root/recipes-kernel
diff options
context:
space:
mode:
authorChristian Gromm <christian.gromm@microchip.com>2018-02-14 10:02:33 +0100
committerJan-Simon Moeller <jsmoeller@linuxfoundation.org>2018-03-13 09:35:33 +0000
commit585d982e95591bc67ccbedd80e3d8d65c43896e5 (patch)
treebf8b02060c1891920e6fc7bdedfba10eb2e3556b /recipes-kernel
parent7bc9507e4a6f4bcaf921232012115539eaa6012a (diff)
recipes-kernel: most: add patch set for DT support
This patch adds a set of patches to enable DT usage of the DIM2 module. It is needed to use the MediaLB (DIM) interface with the Kingfisher. Change-Id: Idd71bea6f2c17cb579f0b44884037e7046380034 Signed-off-by: Christian Gromm <christian.gromm@microchip.com>
Diffstat (limited to 'recipes-kernel')
-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/most.bbappend4
5 files changed, 707 insertions, 0 deletions
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 00000000..59c6ae67
--- /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 00000000..679fab79
--- /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 00000000..1b01fb15
--- /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 00000000..08cd6f99
--- /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/most.bbappend b/recipes-kernel/most/most.bbappend
index bca20d59..d85565fc 100644
--- a/recipes-kernel/most/most.bbappend
+++ b/recipes-kernel/most/most.bbappend
@@ -5,4 +5,8 @@ SRC_URI_append = " \
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 \
"