Requires CMA services.

New 'clk_reset()' API added so that the DSP's reset state can be
toggled separately from its enable/disable operation.

Signed-off-by: Robert Tivy <[email protected]>
---
 arch/arm/mach-davinci/board-da850-evm.c        |   10 +++
 arch/arm/mach-davinci/board-omapl138-hawk.c    |   10 +++
 arch/arm/mach-davinci/clock.c                  |   22 +++++++
 arch/arm/mach-davinci/clock.h                  |    1 +
 arch/arm/mach-davinci/da850.c                  |   17 ++++++
 arch/arm/mach-davinci/devices-da8xx.c          |   78 +++++++++++++++++++++++-
 arch/arm/mach-davinci/include/mach/da8xx.h     |    1 +
 arch/arm/mach-davinci/include/mach/psc.h       |    3 +
 arch/arm/mach-davinci/psc.c                    |   27 ++++++++
 arch/arm/mach-davinci/remoteproc.h             |   23 +++++++
 include/linux/clk.h                            |   17 ++++++
 include/linux/platform_data/da8xx-remoteproc.h |   34 +++++++++++
 12 files changed, 242 insertions(+), 1 deletion(-)
 create mode 100644 arch/arm/mach-davinci/remoteproc.h
 create mode 100644 include/linux/platform_data/da8xx-remoteproc.h

diff --git a/arch/arm/mach-davinci/board-da850-evm.c 
b/arch/arm/mach-davinci/board-da850-evm.c
index 6c172b3..4e86008 100644
--- a/arch/arm/mach-davinci/board-da850-evm.c
+++ b/arch/arm/mach-davinci/board-da850-evm.c
@@ -48,6 +48,8 @@
 #include <media/tvp514x.h>
 #include <media/adv7343.h>
 
+#include "remoteproc.h"
+
 #define DA850_EVM_PHY_ID               "davinci_mdio-0:00"
 #define DA850_LCD_PWR_PIN              GPIO_TO_PIN(2, 8)
 #define DA850_LCD_BL_PIN               GPIO_TO_PIN(2, 15)
@@ -1550,6 +1552,11 @@ static __init void da850_evm_init(void)
                pr_warn("%s: sata registration failed: %d\n", __func__, ret);
 
        da850_evm_setup_mac_addr();
+
+       ret = da8xx_register_rproc();
+       if (ret)
+               pr_warn("%s: dsp/rproc registration failed: %d\n",
+                       __func__, ret);
 }
 
 #ifdef CONFIG_SERIAL_8250_CONSOLE
@@ -1577,4 +1584,7 @@ MACHINE_START(DAVINCI_DA850_EVM, "DaVinci 
DA850/OMAP-L138/AM18x EVM")
        .init_late      = davinci_init_late,
        .dma_zone_size  = SZ_128M,
        .restart        = da8xx_restart,
+#ifdef CONFIG_CMA
+       .reserve        = da8xx_rproc_reserve_cma,
+#endif
 MACHINE_END
diff --git a/arch/arm/mach-davinci/board-omapl138-hawk.c 
b/arch/arm/mach-davinci/board-omapl138-hawk.c
index 8aea169..a0b81c1 100644
--- a/arch/arm/mach-davinci/board-omapl138-hawk.c
+++ b/arch/arm/mach-davinci/board-omapl138-hawk.c
@@ -21,6 +21,8 @@
 #include <mach/da8xx.h>
 #include <mach/mux.h>
 
+#include "remoteproc.h"
+
 #define HAWKBOARD_PHY_ID               "davinci_mdio-0:07"
 #define DA850_HAWK_MMCSD_CD_PIN                GPIO_TO_PIN(3, 12)
 #define DA850_HAWK_MMCSD_WP_PIN                GPIO_TO_PIN(3, 13)
@@ -311,6 +313,11 @@ static __init void omapl138_hawk_init(void)
        if (ret)
                pr_warn("%s: watchdog registration failed: %d\n",
                        __func__, ret);
+
+       ret = da8xx_register_rproc();
+       if (ret)
+               pr_warn("%s: dsp/rproc registration failed: %d\n",
+                       __func__, ret);
 }
 
 #ifdef CONFIG_SERIAL_8250_CONSOLE
@@ -338,4 +345,7 @@ MACHINE_START(OMAPL138_HAWKBOARD, "AM18x/OMAP-L138 
Hawkboard")
        .init_late      = davinci_init_late,
        .dma_zone_size  = SZ_128M,
        .restart        = da8xx_restart,
+#ifdef CONFIG_CMA
+       .reserve        = da8xx_rproc_reserve_cma,
+#endif
 MACHINE_END
diff --git a/arch/arm/mach-davinci/clock.c b/arch/arm/mach-davinci/clock.c
index 34668ea..3fad759 100644
--- a/arch/arm/mach-davinci/clock.c
+++ b/arch/arm/mach-davinci/clock.c
@@ -31,6 +31,13 @@ static LIST_HEAD(clocks);
 static DEFINE_MUTEX(clocks_mutex);
 static DEFINE_SPINLOCK(clockfw_lock);
 
+static void __clk_reset(struct clk *clk, bool reset)
+{
+       if (clk->flags & CLK_PSC)
+               davinci_psc_reset_config(clk->domain, clk->gpsc, clk->lpsc,
+                               reset, clk->flags);
+}
+
 static void __clk_enable(struct clk *clk)
 {
        if (clk->parent)
@@ -52,6 +59,21 @@ static void __clk_disable(struct clk *clk)
                __clk_disable(clk->parent);
 }
 
+int clk_reset(struct clk *clk, bool reset)
+{
+       unsigned long flags;
+
+       if (clk == NULL || IS_ERR(clk))
+               return -EINVAL;
+
+       spin_lock_irqsave(&clockfw_lock, flags);
+       __clk_reset(clk, reset);
+       spin_unlock_irqrestore(&clockfw_lock, flags);
+
+       return 0;
+}
+EXPORT_SYMBOL(clk_reset);
+
 int clk_enable(struct clk *clk)
 {
        unsigned long flags;
diff --git a/arch/arm/mach-davinci/clock.h b/arch/arm/mach-davinci/clock.h
index 46f0f1b..89aa95e 100644
--- a/arch/arm/mach-davinci/clock.h
+++ b/arch/arm/mach-davinci/clock.h
@@ -112,6 +112,7 @@ struct clk {
 #define PRE_PLL                        BIT(4) /* source is before PLL mult/div 
*/
 #define PSC_SWRSTDISABLE       BIT(5) /* Disable state is SwRstDisable */
 #define PSC_FORCE              BIT(6) /* Force module state transtition */
+#define PSC_LRST               BIT(8) /* Use local reset on enable/disable */
 
 #define CLK(dev, con, ck)      \
        {                       \
diff --git a/arch/arm/mach-davinci/da850.c b/arch/arm/mach-davinci/da850.c
index b90c172..4008fdc 100644
--- a/arch/arm/mach-davinci/da850.c
+++ b/arch/arm/mach-davinci/da850.c
@@ -76,6 +76,13 @@ static struct clk pll0_aux_clk = {
        .flags          = CLK_PLL | PRE_PLL,
 };
 
+static struct clk pll0_sysclk1 = {
+       .name           = "pll0_sysclk1",
+       .parent         = &pll0_clk,
+       .flags          = CLK_PLL,
+       .div_reg        = PLLDIV1,
+};
+
 static struct clk pll0_sysclk2 = {
        .name           = "pll0_sysclk2",
        .parent         = &pll0_clk,
@@ -362,10 +369,19 @@ static struct clk sata_clk = {
        .flags          = PSC_FORCE,
 };
 
+static struct clk dsp_clk = {
+       .name           = "dsp",
+       .parent         = &pll0_sysclk1,
+       .domain         = DAVINCI_GPSC_DSPDOMAIN,
+       .lpsc           = DA8XX_LPSC0_GEM,
+       .flags          = PSC_LRST,
+};
+
 static struct clk_lookup da850_clks[] = {
        CLK(NULL,               "ref",          &ref_clk),
        CLK(NULL,               "pll0",         &pll0_clk),
        CLK(NULL,               "pll0_aux",     &pll0_aux_clk),
+       CLK(NULL,               "pll0_sysclk1", &pll0_sysclk1),
        CLK(NULL,               "pll0_sysclk2", &pll0_sysclk2),
        CLK(NULL,               "pll0_sysclk3", &pll0_sysclk3),
        CLK(NULL,               "pll0_sysclk4", &pll0_sysclk4),
@@ -406,6 +422,7 @@ static struct clk_lookup da850_clks[] = {
        CLK("spi_davinci.1",    NULL,           &spi1_clk),
        CLK("vpif",             NULL,           &vpif_clk),
        CLK("ahci",             NULL,           &sata_clk),
+       CLK("davinci-rproc.0",  NULL,           &dsp_clk),
        CLK(NULL,               NULL,           NULL),
 };
 
diff --git a/arch/arm/mach-davinci/devices-da8xx.c 
b/arch/arm/mach-davinci/devices-da8xx.c
index 466b70c..ae54769 100644
--- a/arch/arm/mach-davinci/devices-da8xx.c
+++ b/arch/arm/mach-davinci/devices-da8xx.c
@@ -12,10 +12,13 @@
  */
 #include <linux/init.h>
 #include <linux/platform_device.h>
-#include <linux/dma-mapping.h>
+#ifdef CONFIG_CMA
+#include <linux/dma-contiguous.h>
+#endif
 #include <linux/serial_8250.h>
 #include <linux/ahci_platform.h>
 #include <linux/clk.h>
+#include <linux/platform_data/da8xx-remoteproc.h>
 
 #include <mach/cputype.h>
 #include <mach/common.h>
@@ -655,6 +658,79 @@ int __init da850_register_mmcsd1(struct davinci_mmc_config 
*config)
 }
 #endif
 
+static struct resource da8xx_rproc_resources[] = {
+       { /* HOST1CFG syscfg offset - DSP boot address */
+               .start          = 0x44,
+               .end            = 0x44,
+               .flags          = IORESOURCE_MEM,
+       },
+       { /* dsp irq */
+               .start          = IRQ_DA8XX_CHIPINT0,
+               .end            = IRQ_DA8XX_CHIPINT0,
+               .flags          = IORESOURCE_IRQ,
+       },
+};
+
+static struct da8xx_rproc_pdata rproc_pdata = {
+       .name           = "dsp",
+       .firmware       = "da8xx-dsp.xe674",
+};
+
+static struct platform_device da8xx_dsp = {
+       .name   = "davinci-rproc",
+       .id     = 0,
+       .dev    = {
+               .platform_data          = &rproc_pdata,
+               .coherent_dma_mask      = DMA_BIT_MASK(32),
+       },
+       .num_resources  = ARRAY_SIZE(da8xx_rproc_resources),
+       .resource       = da8xx_rproc_resources,
+};
+
+#ifdef CONFIG_CMA
+
+static phys_addr_t rproc_base __initdata = CONFIG_DAVINCI_DSP_RPROC_CMA_BASE;
+static unsigned long rproc_size __initdata = CONFIG_DAVINCI_DSP_RPROC_CMA_SIZE;
+
+static int __init early_rproc_mem(char *p)
+{
+       char *endp;
+
+       rproc_size = memparse(p, &endp);
+       if (*endp == '@')
+               rproc_base = memparse(endp + 1, NULL);
+
+       return 0;
+}
+early_param("rproc_mem", early_rproc_mem);
+
+void __init da8xx_rproc_reserve_cma(void)
+{
+       int ret;
+
+       ret = dma_declare_contiguous(&da8xx_dsp.dev, rproc_size, rproc_base, 0);
+       if (ret)
+               pr_err("%s: dma_declare_contiguous failed %d\n", __func__, ret);
+}
+
+#endif
+
+int __init da8xx_register_rproc(void)
+{
+       int ret;
+
+       ret = platform_device_register(&da8xx_dsp);
+       if (ret) {
+               pr_err("%s: platform_device_register: %d\n", __func__, ret);
+
+               return ret;
+       }
+
+       dev_set_name(&da8xx_dsp.dev, "%s.%d", da8xx_dsp.name, da8xx_dsp.id);
+
+       return 0;
+};
+
 static struct resource da8xx_rtc_resources[] = {
        {
                .start          = DA8XX_RTC_BASE,
diff --git a/arch/arm/mach-davinci/include/mach/da8xx.h 
b/arch/arm/mach-davinci/include/mach/da8xx.h
index aaccdc4..5c7f7f7 100644
--- a/arch/arm/mach-davinci/include/mach/da8xx.h
+++ b/arch/arm/mach-davinci/include/mach/da8xx.h
@@ -95,6 +95,7 @@ int da850_register_cpufreq(char *async_clk);
 int da8xx_register_cpuidle(void);
 void __iomem * __init da8xx_get_mem_ctlr(void);
 int da850_register_pm(struct platform_device *pdev);
+int da8xx_register_rproc(void);
 int __init da850_register_sata(unsigned long refclkpn);
 int __init da850_register_vpif(void);
 int __init da850_register_vpif_display
diff --git a/arch/arm/mach-davinci/include/mach/psc.h 
b/arch/arm/mach-davinci/include/mach/psc.h
index 40a0027..21746bd 100644
--- a/arch/arm/mach-davinci/include/mach/psc.h
+++ b/arch/arm/mach-davinci/include/mach/psc.h
@@ -246,6 +246,7 @@
 
 #define MDSTAT_STATE_MASK      0x3f
 #define PDSTAT_STATE_MASK      0x1f
+#define MDCTL_LRST             BIT(8)
 #define MDCTL_FORCE            BIT(31)
 #define PDCTL_NEXT             BIT(0)
 #define PDCTL_EPCGOOD          BIT(8)
@@ -253,6 +254,8 @@
 #ifndef __ASSEMBLER__
 
 extern int davinci_psc_is_clk_active(unsigned int ctlr, unsigned int id);
+extern void davinci_psc_reset_config(unsigned int domain, unsigned int ctlr,
+               unsigned int id, bool reset, u32 flags);
 extern void davinci_psc_config(unsigned int domain, unsigned int ctlr,
                unsigned int id, bool enable, u32 flags);
 
diff --git a/arch/arm/mach-davinci/psc.c b/arch/arm/mach-davinci/psc.c
index bddaba9..2be8b8a 100644
--- a/arch/arm/mach-davinci/psc.c
+++ b/arch/arm/mach-davinci/psc.c
@@ -48,6 +48,33 @@ int __init davinci_psc_is_clk_active(unsigned int ctlr, 
unsigned int id)
        return mdstat & BIT(12);
 }
 
+void davinci_psc_reset_config(unsigned int domain, unsigned int ctlr,
+               unsigned int id, bool reset, u32 flags)
+{
+       u32 mdctl;
+       void __iomem *psc_base;
+       struct davinci_soc_info *soc_info = &davinci_soc_info;
+
+       if (!soc_info->psc_bases || (ctlr >= soc_info->psc_bases_num)) {
+               pr_warn("PSC: Bad psc data: 0x%x[%d]\n",
+                               (int)soc_info->psc_bases, ctlr);
+               return;
+       }
+
+       psc_base = ioremap(soc_info->psc_bases[ctlr], SZ_4K);
+
+       if (flags & PSC_LRST) {
+               mdctl = readl(psc_base + MDCTL + 4 * id);
+               if (reset)
+                       mdctl &= ~MDCTL_LRST;
+               else
+                       mdctl |= MDCTL_LRST;
+               writel(mdctl, psc_base + MDCTL + 4 * id);
+       }
+
+       iounmap(psc_base);
+}
+
 /* Enable or disable a PSC domain */
 void davinci_psc_config(unsigned int domain, unsigned int ctlr,
                unsigned int id, bool enable, u32 flags)
diff --git a/arch/arm/mach-davinci/remoteproc.h 
b/arch/arm/mach-davinci/remoteproc.h
new file mode 100644
index 0000000..a94c013
--- /dev/null
+++ b/arch/arm/mach-davinci/remoteproc.h
@@ -0,0 +1,23 @@
+/*
+ * Remote Processor
+ *
+ * Copyright (C) 2011-2012 Texas Instruments, Inc.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * version 2 as published by the Free Software Foundation.
+ *
+ * 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.
+ */
+
+#ifndef _MACH_REMOTEPROC_H
+#define _MACH_REMOTEPROC_H
+
+#ifdef CONFIG_CMA
+extern void __init da8xx_rproc_reserve_cma(void);
+#endif
+
+#endif /* _MACH_REMOTEPROC_H */
diff --git a/include/linux/clk.h b/include/linux/clk.h
index b3ac22d..9b1a56f 100644
--- a/include/linux/clk.h
+++ b/include/linux/clk.h
@@ -187,6 +187,23 @@ int clk_enable(struct clk *clk);
 void clk_disable(struct clk *clk);
 
 /**
+ * clk_reset - inform the system when the clock source should be reset or
+ * taken out of reset.
+ * @clk: clock source
+ *
+ * Applies to clock sources that have an associated reset for the device
+ * controlled by the clock.
+ *
+ * If the device being clocked can not be reset/taken-out-of-reset, this
+ * should return success.
+ *
+ * May be called from atomic contexts.
+ *
+ * Returns success (0) or negative errno.
+ */
+int clk_reset(struct clk *clk, bool reset);
+
+/**
  * clk_get_rate - obtain the current clock rate (in Hz) for a clock source.
  *               This is only valid once the clock source has been enabled.
  * @clk: clock source
diff --git a/include/linux/platform_data/da8xx-remoteproc.h 
b/include/linux/platform_data/da8xx-remoteproc.h
new file mode 100644
index 0000000..1e79809
--- /dev/null
+++ b/include/linux/platform_data/da8xx-remoteproc.h
@@ -0,0 +1,34 @@
+/*
+ * Remote Processor
+ *
+ * Copyright (C) 2011-2012 Texas Instruments, Inc.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * version 2 as published by the Free Software Foundation.
+ *
+ * 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.
+ */
+
+#ifndef __DA8XX_REMOTEPROC_H__
+#define __DA8XX_REMOTEPROC_H__
+
+#include <linux/remoteproc.h>
+
+/**
+ * struct da8xx_rproc_pdata - da8xx remoteproc's platform data
+ * @name: the remoteproc's name
+ * @clk_name: the remoteproc's clock
+ * @firmware: name of firmware file to load
+ * @ops: start/stop rproc handlers
+ */
+struct da8xx_rproc_pdata {
+       const char *name;
+       const char *firmware;
+       const struct rproc_ops *ops;
+};
+
+#endif /* __DA8XX_REMOTEPROC_H__ */
-- 
1.7.9.4

_______________________________________________
Davinci-linux-open-source mailing list
[email protected]
http://linux.davincidsp.com/mailman/listinfo/davinci-linux-open-source

Reply via email to