Contains support for both CMA-based contiguous physical memory and "hard-coded" non-kernel contiguous physical memory, distinguished by the CONFIG_CMA .config setting
Signed-off-by: Robert Tivy <[email protected]> --- CMA support has not been tested, due to CMA not being available for OMAP-L138 in the v3.5 kernel. It is understood that CMA will be available for OMAP-L138 in a future kernel. arch/arm/mach-davinci/board-da850-evm.c | 14 +++- arch/arm/mach-davinci/board-omapl138-hawk.c | 14 +++- arch/arm/mach-davinci/clock.h | 3 +- arch/arm/mach-davinci/da850.c | 19 ++++- arch/arm/mach-davinci/devices-da8xx.c | 100 ++++++++++++++++++++++++ arch/arm/mach-davinci/include/mach/da8xx.h | 1 + arch/arm/mach-davinci/include/mach/psc.h | 3 +- arch/arm/mach-davinci/psc.c | 8 +- arch/arm/mach-davinci/remoteproc.h | 25 ++++++ include/linux/platform_data/da8xx-remoteproc.h | 34 ++++++++ 10 files changed, 215 insertions(+), 6 deletions(-) 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 bbb3c73..4034945 100644 --- a/arch/arm/mach-davinci/board-da850-evm.c +++ b/arch/arm/mach-davinci/board-da850-evm.c @@ -1,7 +1,7 @@ /* * TI DA850/OMAP-L138 EVM board * - * Copyright (C) 2009 Texas Instruments Incorporated - http://www.ti.com/ + * Copyright (C) 2009-2012 Texas Instruments Incorporated - http://www.ti.com/ * * Derived from: arch/arm/mach-davinci/board-da830-evm.c * Original Copyrights follow: @@ -45,6 +45,8 @@ #include <mach/aemif.h> #include <mach/spi.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) @@ -1371,6 +1373,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 @@ -1398,4 +1405,9 @@ 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, +#else + .reserve = da8xx_rproc_reserve_contig, +#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..1880722 100644 --- a/arch/arm/mach-davinci/board-omapl138-hawk.c +++ b/arch/arm/mach-davinci/board-omapl138-hawk.c @@ -3,7 +3,7 @@ * * Initial code: Syed Mohammed Khasim * - * Copyright (C) 2009 Texas Instruments Incorporated - http://www.ti.com + * Copyright (C) 2009-2012 Texas Instruments Incorporated - http://www.ti.com * * This file is licensed under the terms of the GNU General Public License * version 2. This program is licensed "as is" without any warranty of @@ -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,9 @@ 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, +#else + .reserve = da8xx_rproc_reserve_contig, +#endif MACHINE_END diff --git a/arch/arm/mach-davinci/clock.h b/arch/arm/mach-davinci/clock.h index 46f0f1b..8481638 100644 --- a/arch/arm/mach-davinci/clock.h +++ b/arch/arm/mach-davinci/clock.h @@ -1,7 +1,7 @@ /* * TI DaVinci clock definitions * - * Copyright (C) 2006-2007 Texas Instruments. + * Copyright (C) 2006-2012 Texas Instruments. * Copyright (C) 2008-2009 Deep Root Systems, LLC * * This program is free software; you can redistribute it and/or modify @@ -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 b44dc84..28395e2 100644 --- a/arch/arm/mach-davinci/da850.c +++ b/arch/arm/mach-davinci/da850.c @@ -1,7 +1,7 @@ /* * TI DA850/OMAP-L138 chip specific setup * - * Copyright (C) 2009 Texas Instruments Incorporated - http://www.ti.com/ + * Copyright (C) 2009-2012 Texas Instruments Incorporated - http://www.ti.com/ * * Derived from: arch/arm/mach-davinci/da830.c * Original Copyrights follow: @@ -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, @@ -355,10 +362,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), @@ -398,6 +414,7 @@ static struct clk_lookup da850_clks[] = { CLK("spi_davinci.0", NULL, &spi0_clk), CLK("spi_davinci.1", NULL, &spi1_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 190eeb6..eb239b5 100644 --- a/arch/arm/mach-davinci/devices-da8xx.c +++ b/arch/arm/mach-davinci/devices-da8xx.c @@ -1,6 +1,7 @@ /* * DA8XX/OMAP L1XX platform device data * + * Copyright (C) 2012 Texas Instruments, Inc. * Copyright (c) 2007-2009, MontaVista Software, Inc. <[email protected]> * Derived from code that was: * Copyright (C) 2006 Komal Shah <[email protected]> @@ -12,10 +13,16 @@ */ #include <linux/init.h> #include <linux/platform_device.h> +#ifdef CONFIG_CMA +#include <linux/dma-contiguous.h> +#else #include <linux/dma-mapping.h> +#include <linux/memblock.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> @@ -660,6 +667,99 @@ int __init da850_register_mmcsd1(struct davinci_mmc_config *config) } #endif +static struct platform_device *da8xx_dsp; + +#ifdef CONFIG_CMA + +/* + * The following address range was chosen because the XDC Platform for + * OMAP-L138 DSP has this range as its default code/data placement. + */ +#define DA8XX_RPROC_CMA_BASE (0xc3000000) + +void __init da8xx_rproc_reserve_cma(void) +{ + int ret; + + ret = dma_declare_contiguous(&da8xx_dsp->dev, + CONFIG_DAVINCI_DSP_CMA_SIZE, DA8XX_RPROC_CMA_BASE, 0); + if (ret) + pr_err("%s: dma_declare_contiguous failed %d\n", __func__, ret); +} + +#else + +/* + * The following address range was chosen because the XDC Platform for + * OMAP-L138 DSP has this range as its default code/data placement. + * + * System integrators must ensure that Linux does not own this range. + */ +#define DA_CONTIG_BASE (0xc3000000) +#define DA_CONTIG_SIZE (0x02000000) + +void __init da8xx_rproc_reserve_contig(void) +{ + pr_debug("%s: reserving contig memory\n", __func__); + + if (memblock_is_region_reserved(DA_CONTIG_BASE, DA_CONTIG_SIZE) || + memblock_reserve(DA_CONTIG_BASE, DA_CONTIG_SIZE) < 0) { + pr_err("%s: memory already reserved\n", __func__); + return; + } +} + +#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, + }, +}; + +int __init da8xx_register_rproc(void) +{ + struct da8xx_rproc_pdata rproc_pdata = { + .name = "dsp", + .firmware = "da8xx-dsp.xe674", + }; + int ret; + + da8xx_dsp = platform_device_register_resndata(NULL, "davinci-rproc", 0, + da8xx_rproc_resources, ARRAY_SIZE(da8xx_rproc_resources), + &rproc_pdata, sizeof(rproc_pdata)); + + ret = dma_set_coherent_mask(&da8xx_dsp->dev, DMA_BIT_MASK(32)); + if (ret) { + dev_err(&da8xx_dsp->dev, "dma_set_coherent_mask: %d\n", ret); + + return ret; + } + +#ifndef CONFIG_CMA + ret = dma_declare_coherent_memory(&da8xx_dsp->dev, + DA_CONTIG_BASE, DA_CONTIG_BASE, + DA_CONTIG_SIZE, + DMA_MEMORY_MAP | DMA_MEMORY_EXCLUSIVE); + + if (!(ret & DMA_MEMORY_MAP)) { + pr_err("%s: dma_declare_coherent failure\n", __func__); + platform_device_unregister(da8xx_dsp); + + return -ENOMEM; + } +#endif + + 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 a2f1f27..b1e782c 100644 --- a/arch/arm/mach-davinci/include/mach/da8xx.h +++ b/arch/arm/mach-davinci/include/mach/da8xx.h @@ -91,6 +91,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); void da8xx_restart(char mode, const char *cmd); diff --git a/arch/arm/mach-davinci/include/mach/psc.h b/arch/arm/mach-davinci/include/mach/psc.h index 405318e..b119411 100644 --- a/arch/arm/mach-davinci/include/mach/psc.h +++ b/arch/arm/mach-davinci/include/mach/psc.h @@ -1,7 +1,7 @@ /* * DaVinci Power & Sleep Controller (PSC) defines * - * Copyright (C) 2006 Texas Instruments. + * Copyright (C) 2006-2012 Texas Instruments. * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the @@ -245,6 +245,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) diff --git a/arch/arm/mach-davinci/psc.c b/arch/arm/mach-davinci/psc.c index bddaba9..b2fc3bd 100644 --- a/arch/arm/mach-davinci/psc.c +++ b/arch/arm/mach-davinci/psc.c @@ -1,7 +1,7 @@ /* * TI DaVinci Power and Sleep Controller (PSC) * - * Copyright (C) 2006 Texas Instruments. + * Copyright (C) 2006-2012 Texas Instruments. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -77,6 +77,12 @@ void davinci_psc_config(unsigned int domain, unsigned int ctlr, mdctl |= next_state; if (flags & PSC_FORCE) mdctl |= MDCTL_FORCE; + if (flags & PSC_LRST) { + if (!enable) + mdctl &= ~MDCTL_LRST; + else + mdctl |= MDCTL_LRST; + } __raw_writel(mdctl, psc_base + MDCTL + 4 * id); pdstat = __raw_readl(psc_base + PDSTAT + 4 * domain); diff --git a/arch/arm/mach-davinci/remoteproc.h b/arch/arm/mach-davinci/remoteproc.h new file mode 100644 index 0000000..b5a98f6 --- /dev/null +++ b/arch/arm/mach-davinci/remoteproc.h @@ -0,0 +1,25 @@ +/* + * 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); +#else +extern void __init da8xx_rproc_reserve_contig(void); +#endif + +#endif /* _MACH_REMOTEPROC_H */ 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
