From patchwork Tue Jun 21 07:18:31 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ohad Ben Cohen X-Patchwork-Id: 908132 Received: from comal.ext.ti.com (comal.ext.ti.com [198.47.26.152]) by demeter2.kernel.org (8.14.4/8.14.4) with ESMTP id p5N5AsiM002412 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Thu, 23 Jun 2011 05:11:14 GMT Received: from dlep33.itg.ti.com ([157.170.170.112]) by comal.ext.ti.com (8.13.7/8.13.7) with ESMTP id p5N59hRd006339 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Thu, 23 Jun 2011 00:09:43 -0500 Received: from linux.omap.com (smtp-le.itg.ti.com [157.170.170.27]) by dlep33.itg.ti.com (8.13.7/8.13.8) with ESMTP id p5N59g0U020863; Thu, 23 Jun 2011 00:09:42 -0500 (CDT) Received: from linux.omap.com (localhost [127.0.0.1]) by linux.omap.com (Postfix) with ESMTP id C597F80631; Thu, 23 Jun 2011 00:09:42 -0500 (CDT) X-Original-To: davinci-linux-open-source@linux.davincidsp.com Delivered-To: davinci-linux-open-source@linux.davincidsp.com Received: from dflp53.itg.ti.com (dflp53.itg.ti.com [128.247.5.6]) by linux.omap.com (Postfix) with ESMTP id 7048C80626 for ; Tue, 21 Jun 2011 02:22:18 -0500 (CDT) Received: from white.ext.ti.com (white.ext.ti.com [192.94.93.38]) by dflp53.itg.ti.com (8.13.8/8.13.8) with ESMTP id p5L7MIgt022142 for ; Tue, 21 Jun 2011 02:22:18 -0500 (CDT) Received: from psmtp.com (na3sys009amx232.postini.com [74.125.149.116]) by white.ext.ti.com (8.13.7/8.13.7) with SMTP id p5L7MGIv003645 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Tue, 21 Jun 2011 02:22:17 -0500 Received: from mail-wy0-f173.google.com ([74.125.82.173]) (using TLSv1) by na3sys009amx232.postini.com ([74.125.148.10]) with SMTP; Tue, 21 Jun 2011 07:22:17 GMT Received: by mail-wy0-f173.google.com with SMTP id 28so1537410wyf.4 for ; Tue, 21 Jun 2011 00:22:16 -0700 (PDT) Received: by 10.216.143.74 with SMTP id k52mr433314wej.8.1308640936326; Tue, 21 Jun 2011 00:22:16 -0700 (PDT) Received: from localhost.localdomain (46-116-119-47.bb.netvision.net.il [46.116.119.47]) by mx.google.com with ESMTPS id o19sm3767542wbh.38.2011.06.21.00.22.14 (version=TLSv1/SSLv3 cipher=OTHER); Tue, 21 Jun 2011 00:22:15 -0700 (PDT) From: Ohad Ben-Cohen To: , , Subject: [RFC 5/8] remoteproc: add davinci implementation Date: Tue, 21 Jun 2011 10:18:31 +0300 Message-Id: <1308640714-17961-6-git-send-email-ohad@wizery.com> X-Mailer: git-send-email 1.7.1 In-Reply-To: <1308640714-17961-1-git-send-email-ohad@wizery.com> References: <1308640714-17961-1-git-send-email-ohad@wizery.com> X-pstn-neptune: 0/0/0.00/0 X-pstn-levels: (S:99.90000/99.90000 CV:99.9000 FC:95.5390 LC:95.5390 R:95.9108 P:95.9108 M:97.0282 C:98.6951 ) X-pstn-settings: 2 (0.5000:0.0750) s cv GT3 gt2 gt1 r p m c X-pstn-addresses: from [35/1] X-Mailman-Approved-At: Thu, 23 Jun 2011 00:07:34 -0500 Cc: Ohad Ben-Cohen , davinci-linux-open-source , Arnd Bergmann , Brian Swetland , Rusty Russell , Grant Likely , akpm@linux-foundation.org X-BeenThere: davinci-linux-open-source@linux.davincidsp.com X-Mailman-Version: 2.1.12 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: davinci-linux-open-source-bounces@linux.davincidsp.com Errors-To: davinci-linux-open-source-bounces@linux.davincidsp.com X-Greylist: Sender succeeded STARTTLS authentication, not delayed by milter-greylist-4.2.6 (demeter2.kernel.org [140.211.167.43]); Thu, 23 Jun 2011 05:11:14 +0000 (UTC) From: Mark Grosen Add remoteproc implementation for da850, so we can boot its DSP. Signed-off-by: Mark Grosen Signed-off-by: Ohad Ben-Cohen --- arch/arm/mach-davinci/include/mach/remoteproc.h | 28 +++++ drivers/remoteproc/Kconfig | 16 +++ drivers/remoteproc/Makefile | 1 + drivers/remoteproc/davinci_remoteproc.c | 147 +++++++++++++++++++++++ 4 files changed, 192 insertions(+), 0 deletions(-) create mode 100644 arch/arm/mach-davinci/include/mach/remoteproc.h create mode 100644 drivers/remoteproc/davinci_remoteproc.c diff --git a/arch/arm/mach-davinci/include/mach/remoteproc.h b/arch/arm/mach-davinci/include/mach/remoteproc.h new file mode 100644 index 0000000..af6e88c --- /dev/null +++ b/arch/arm/mach-davinci/include/mach/remoteproc.h @@ -0,0 +1,28 @@ +/* + * Remote Processor + * + * Copyright (C) 2011 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 _DAVINCI_REMOTEPROC_H +#define _DAVINCI_REMOTEPROC_H + +#include + +struct davinci_rproc_pdata { + struct rproc_ops *ops; + char *name; + char *clk_name; + char *firmware; +}; + +#endif /* _DAVINCI_REMOTEPROC_H */ diff --git a/drivers/remoteproc/Kconfig b/drivers/remoteproc/Kconfig index 88421bd..1e594b5 100644 --- a/drivers/remoteproc/Kconfig +++ b/drivers/remoteproc/Kconfig @@ -26,3 +26,19 @@ config OMAP_REMOTE_PROC It's safe to say n here if you're not interested in multimedia offloading or just want a bare minimum kernel. + +config DAVINCI_REMOTE_PROC + tristate "Davinci remoteproc support" + depends on ARCH_DAVINCI_DA850 + select REMOTE_PROC + default y + help + Say y here to support Davinci's DSP remote processor via the remote + processor framework (currently only da850 is supported). + + Usually you want to say y here, in order to enable multimedia + use-cases to run on your platform (multimedia codecs are + offloaded to remote DSP processors using this framework). + + It's safe to say n here if you're not interested in multimedia + offloading or just want a bare minimum kernel. diff --git a/drivers/remoteproc/Makefile b/drivers/remoteproc/Makefile index 0198b1d..e83dac9 100644 --- a/drivers/remoteproc/Makefile +++ b/drivers/remoteproc/Makefile @@ -4,3 +4,4 @@ obj-$(CONFIG_REMOTE_PROC) += remoteproc.o obj-$(CONFIG_OMAP_REMOTE_PROC) += omap_remoteproc.o +obj-$(CONFIG_DAVINCI_REMOTE_PROC) += davinci_remoteproc.o diff --git a/drivers/remoteproc/davinci_remoteproc.c b/drivers/remoteproc/davinci_remoteproc.c new file mode 100644 index 0000000..0e26fe9 --- /dev/null +++ b/drivers/remoteproc/davinci_remoteproc.c @@ -0,0 +1,147 @@ +/* + * Remote processor machine-specific module for Davinci + * + * Copyright (C) 2011 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. + */ + +#define pr_fmt(fmt) "%s: " fmt, __func__ + +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +/* + * Technical Reference: + * OMAP-L138 Applications Processor System Reference Guide + * http://www.ti.com/litv/pdf/sprugm7d + */ + +/* local reset bit (0 is asserted) in MDCTL15 register (section 9.6.18) */ +#define LRST BIT(8) + +/* next state bits in MDCTL15 register (section 9.6.18) */ +#define NEXT_ENABLED 0x3 + +/* register for DSP boot address in SYSCFG0 module (section 11.5.6) */ +#define HOST1CFG 0x44 + +static inline int davinci_rproc_start(struct rproc *rproc, u64 bootaddr) +{ + struct device *dev = rproc->dev; + struct davinci_rproc_pdata *pdata = dev->platform_data; + struct davinci_soc_info *soc_info = &davinci_soc_info; + void __iomem *psc_base; + struct clk *dsp_clk; + + /* hw requires the start (boot) address be on 1KB boundary */ + if (bootaddr & 0x3ff) { + dev_err(dev, "invalid boot address: must be aligned to 1KB\n"); + return -EINVAL; + } + + dsp_clk = clk_get(dev, pdata->clk_name); + if (IS_ERR_OR_NULL(dsp_clk)) { + dev_err(dev, "clk_get error: %ld\n", PTR_ERR(dsp_clk)); + return PTR_ERR(dsp_clk); + } + + clk_enable(dsp_clk); + rproc->priv = dsp_clk; + + psc_base = ioremap(soc_info->psc_bases[0], SZ_4K); + + /* insure local reset is asserted before writing start address */ + __raw_writel(NEXT_ENABLED, psc_base + MDCTL + 4 * DA8XX_LPSC0_GEM); + + __raw_writel(bootaddr, DA8XX_SYSCFG0_VIRT(HOST1CFG)); + + /* de-assert local reset to start the dsp running */ + __raw_writel(LRST | NEXT_ENABLED, psc_base + MDCTL + + 4 * DA8XX_LPSC0_GEM); + + iounmap(psc_base); + + return 0; +} + +static inline int davinci_rproc_stop(struct rproc *rproc) +{ + struct davinci_soc_info *soc_info = &davinci_soc_info; + void __iomem *psc_base; + struct clk *dsp_clk = rproc->priv; + + psc_base = ioremap(soc_info->psc_bases[0], SZ_4K); + + /* halt the dsp by asserting local reset */ + __raw_writel(NEXT_ENABLED, psc_base + MDCTL + 4 * DA8XX_LPSC0_GEM); + + clk_disable(dsp_clk); + clk_put(dsp_clk); + + iounmap(psc_base); + + return 0; +} + +static struct rproc_ops davinci_rproc_ops = { + .start = davinci_rproc_start, + .stop = davinci_rproc_stop, +}; + +static int davinci_rproc_probe(struct platform_device *pdev) +{ + struct davinci_rproc_pdata *pdata = pdev->dev.platform_data; + + return rproc_register(&pdev->dev, pdata->name, &davinci_rproc_ops, + pdata->firmware, NULL, THIS_MODULE); +} + +static int __devexit davinci_rproc_remove(struct platform_device *pdev) +{ + struct davinci_rproc_pdata *pdata = pdev->dev.platform_data; + + return rproc_unregister(pdata->name); +} + +static struct platform_driver davinci_rproc_driver = { + .probe = davinci_rproc_probe, + .remove = __devexit_p(davinci_rproc_remove), + .driver = { + .name = "davinci-rproc", + .owner = THIS_MODULE, + }, +}; + +static int __init davinci_rproc_init(void) +{ + return platform_driver_register(&davinci_rproc_driver); +} +module_init(davinci_rproc_init); + +static void __exit davinci_rproc_exit(void) +{ + platform_driver_unregister(&davinci_rproc_driver); +} +module_exit(davinci_rproc_exit); + +MODULE_LICENSE("GPL v2"); +MODULE_DESCRIPTION("Davinci Remote Processor control driver");