Explorar o código

Merge tag 'davinci-for-v3.10/soc-2-v2' of git://git.kernel.org/pub/scm/linux/kernel/git/nsekhar/linux-davinci into next/soc

From Sekhar Nori:
v3.10 SoC updates for DaVinci

This set of patches add support for remoteproc
used to control the DSP and also fix sparse
errors existing for quite some time.

* tag 'davinci-for-v3.10/soc-2-v2' of git://git.kernel.org/pub/scm/linux/kernel/git/nsekhar/linux-davinci:
  ARM: davinci: ensure global variables are declared
  ARM: davinci: sram.c: fix incorrect type in assignment
  ARM: davinci: da8xx dt: make file local symbols static
  ARM: davinci: da8xx: add remoteproc support

Signed-off-by: Olof Johansson <olof@lixom.net>
Olof Johansson %!s(int64=12) %!d(string=hai) anos
pai
achega
a100caaf12

+ 6 - 0
Documentation/kernel-parameters.txt

@@ -44,6 +44,7 @@ parameter is applicable:
 	AVR32	AVR32 architecture is enabled.
 	AVR32	AVR32 architecture is enabled.
 	AX25	Appropriate AX.25 support is enabled.
 	AX25	Appropriate AX.25 support is enabled.
 	BLACKFIN Blackfin architecture is enabled.
 	BLACKFIN Blackfin architecture is enabled.
+	CMA	Contiguous Memory Area support is enabled.
 	DRM	Direct Rendering Management support is enabled.
 	DRM	Direct Rendering Management support is enabled.
 	DYNAMIC_DEBUG Build in debug messages and enable them at runtime
 	DYNAMIC_DEBUG Build in debug messages and enable them at runtime
 	EDD	BIOS Enhanced Disk Drive Services (EDD) is enabled
 	EDD	BIOS Enhanced Disk Drive Services (EDD) is enabled
@@ -2663,6 +2664,11 @@ bytes respectively. Such letter suffixes can also be entirely omitted.
 			Useful for devices that are detected asynchronously
 			Useful for devices that are detected asynchronously
 			(e.g. USB and MMC devices).
 			(e.g. USB and MMC devices).
 
 
+	rproc_mem=nn[KMG][@address]
+			[KNL,ARM,CMA] Remoteproc physical memory block.
+			Memory area to be used by remote processor image,
+			managed by CMA.
+
 	rw		[KNL] Mount root device read-write on boot
 	rw		[KNL] Mount root device read-write on boot
 
 
 	S		[KNL] Run init in single mode
 	S		[KNL] Run init in single mode

+ 2 - 2
arch/arm/mach-davinci/da8xx-dt.c

@@ -20,7 +20,7 @@
 
 
 #define DA8XX_NUM_UARTS	3
 #define DA8XX_NUM_UARTS	3
 
 
-void __init da8xx_uart_clk_enable(void)
+static void __init da8xx_uart_clk_enable(void)
 {
 {
 	int i;
 	int i;
 	for (i = 0; i < DA8XX_NUM_UARTS; i++)
 	for (i = 0; i < DA8XX_NUM_UARTS; i++)
@@ -37,7 +37,7 @@ static void __init da8xx_init_irq(void)
 	of_irq_init(da8xx_irq_match);
 	of_irq_init(da8xx_irq_match);
 }
 }
 
 
-struct of_dev_auxdata da850_auxdata_lookup[] __initdata = {
+static struct of_dev_auxdata da850_auxdata_lookup[] __initdata = {
 	OF_DEV_AUXDATA("ti,davinci-i2c", 0x01c22000, "i2c_davinci.1", NULL),
 	OF_DEV_AUXDATA("ti,davinci-i2c", 0x01c22000, "i2c_davinci.1", NULL),
 	OF_DEV_AUXDATA("ti,davinci-wdt", 0x01c21000, "watchdog", NULL),
 	OF_DEV_AUXDATA("ti,davinci-wdt", 0x01c21000, "watchdog", NULL),
 	OF_DEV_AUXDATA("ti,da830-mmc", 0x01c40000, "da830-mmc.0", NULL),
 	OF_DEV_AUXDATA("ti,da830-mmc", 0x01c40000, "da830-mmc.0", NULL),

+ 87 - 1
arch/arm/mach-davinci/devices-da8xx.c

@@ -12,7 +12,7 @@
  */
  */
 #include <linux/init.h>
 #include <linux/init.h>
 #include <linux/platform_device.h>
 #include <linux/platform_device.h>
-#include <linux/dma-mapping.h>
+#include <linux/dma-contiguous.h>
 #include <linux/serial_8250.h>
 #include <linux/serial_8250.h>
 #include <linux/ahci_platform.h>
 #include <linux/ahci_platform.h>
 #include <linux/clk.h>
 #include <linux/clk.h>
@@ -714,6 +714,92 @@ int __init da850_register_mmcsd1(struct davinci_mmc_config *config)
 }
 }
 #endif
 #endif
 
 
+static struct resource da8xx_rproc_resources[] = {
+	{ /* DSP boot address */
+		.start		= DA8XX_SYSCFG0_BASE + DA8XX_HOST1CFG_REG,
+		.end		= DA8XX_SYSCFG0_BASE + DA8XX_HOST1CFG_REG + 3,
+		.flags		= IORESOURCE_MEM,
+	},
+	{ /* DSP interrupt registers */
+		.start		= DA8XX_SYSCFG0_BASE + DA8XX_CHIPSIG_REG,
+		.end		= DA8XX_SYSCFG0_BASE + DA8XX_CHIPSIG_REG + 7,
+		.flags		= IORESOURCE_MEM,
+	},
+	{ /* dsp irq */
+		.start		= IRQ_DA8XX_CHIPINT0,
+		.end		= IRQ_DA8XX_CHIPINT0,
+		.flags		= IORESOURCE_IRQ,
+	},
+};
+
+static struct platform_device da8xx_dsp = {
+	.name	= "davinci-rproc",
+	.dev	= {
+		.coherent_dma_mask	= DMA_BIT_MASK(32),
+	},
+	.num_resources	= ARRAY_SIZE(da8xx_rproc_resources),
+	.resource	= da8xx_rproc_resources,
+};
+
+#if IS_ENABLED(CONFIG_DA8XX_REMOTEPROC)
+
+static phys_addr_t rproc_base __initdata;
+static unsigned long rproc_size __initdata;
+
+static int __init early_rproc_mem(char *p)
+{
+	char *endp;
+
+	if (p == NULL)
+		return 0;
+
+	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;
+
+	if (!rproc_base || !rproc_size) {
+		pr_err("%s: 'rproc_mem=nn@address' badly specified\n"
+		       "    'nn' and 'address' must both be non-zero\n",
+		       __func__);
+
+		return;
+	}
+
+	pr_info("%s: reserving 0x%lx @ 0x%lx...\n",
+		__func__, rproc_size, (unsigned long)rproc_base);
+
+	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);
+}
+
+#else
+
+void __init da8xx_rproc_reserve_cma(void)
+{
+}
+
+#endif
+
+int __init da8xx_register_rproc(void)
+{
+	int ret;
+
+	ret = platform_device_register(&da8xx_dsp);
+	if (ret)
+		pr_err("%s: can't register DSP device: %d\n", __func__, ret);
+
+	return ret;
+};
+
 static struct resource da8xx_rtc_resources[] = {
 static struct resource da8xx_rtc_resources[] = {
 	{
 	{
 		.start		= DA8XX_RTC_BASE,
 		.start		= DA8XX_RTC_BASE,

+ 4 - 0
arch/arm/mach-davinci/include/mach/da8xx.h

@@ -54,6 +54,8 @@ extern unsigned int da850_max_speed;
 #define DA8XX_SYSCFG0_BASE	(IO_PHYS + 0x14000)
 #define DA8XX_SYSCFG0_BASE	(IO_PHYS + 0x14000)
 #define DA8XX_SYSCFG0_VIRT(x)	(da8xx_syscfg0_base + (x))
 #define DA8XX_SYSCFG0_VIRT(x)	(da8xx_syscfg0_base + (x))
 #define DA8XX_JTAG_ID_REG	0x18
 #define DA8XX_JTAG_ID_REG	0x18
+#define DA8XX_HOST1CFG_REG	0x44
+#define DA8XX_CHIPSIG_REG	0x174
 #define DA8XX_CFGCHIP0_REG	0x17c
 #define DA8XX_CFGCHIP0_REG	0x17c
 #define DA8XX_CFGCHIP1_REG	0x180
 #define DA8XX_CFGCHIP1_REG	0x180
 #define DA8XX_CFGCHIP2_REG	0x184
 #define DA8XX_CFGCHIP2_REG	0x184
@@ -105,6 +107,8 @@ int __init da850_register_vpif_display
 int __init da850_register_vpif_capture
 int __init da850_register_vpif_capture
 			(struct vpif_capture_config *capture_config);
 			(struct vpif_capture_config *capture_config);
 void da8xx_restart(char mode, const char *cmd);
 void da8xx_restart(char mode, const char *cmd);
+void da8xx_rproc_reserve_cma(void);
+int da8xx_register_rproc(void);
 
 
 extern struct platform_device da8xx_serial_device;
 extern struct platform_device da8xx_serial_device;
 extern struct emac_platform_data da8xx_emac_pdata;
 extern struct emac_platform_data da8xx_emac_pdata;

+ 1 - 0
arch/arm/mach-davinci/pm.c

@@ -19,6 +19,7 @@
 #include <asm/delay.h>
 #include <asm/delay.h>
 #include <asm/io.h>
 #include <asm/io.h>
 
 
+#include <mach/common.h>
 #include <mach/da8xx.h>
 #include <mach/da8xx.h>
 #include <mach/sram.h>
 #include <mach/sram.h>
 #include <mach/pm.h>
 #include <mach/pm.h>

+ 2 - 2
arch/arm/mach-davinci/sram.c

@@ -62,7 +62,7 @@ static int __init sram_init(void)
 	phys_addr_t phys = davinci_soc_info.sram_dma;
 	phys_addr_t phys = davinci_soc_info.sram_dma;
 	unsigned len = davinci_soc_info.sram_len;
 	unsigned len = davinci_soc_info.sram_len;
 	int status = 0;
 	int status = 0;
-	void *addr;
+	void __iomem *addr;
 
 
 	if (len) {
 	if (len) {
 		len = min_t(unsigned, len, SRAM_SIZE);
 		len = min_t(unsigned, len, SRAM_SIZE);
@@ -75,7 +75,7 @@ static int __init sram_init(void)
 		addr = ioremap(phys, len);
 		addr = ioremap(phys, len);
 		if (!addr)
 		if (!addr)
 			return -ENOMEM;
 			return -ENOMEM;
-		status = gen_pool_add_virt(sram_pool, (unsigned)addr,
+		status = gen_pool_add_virt(sram_pool, (unsigned long) addr,
 					   phys, len, -1);
 					   phys, len, -1);
 		if (status < 0)
 		if (status < 0)
 			iounmap(addr);
 			iounmap(addr);

+ 1 - 0
arch/arm/mach-davinci/usb.c

@@ -10,6 +10,7 @@
 #include <mach/common.h>
 #include <mach/common.h>
 #include <mach/irqs.h>
 #include <mach/irqs.h>
 #include <mach/cputype.h>
 #include <mach/cputype.h>
+#include <mach/da8xx.h>
 #include <linux/platform_data/usb-davinci.h>
 #include <linux/platform_data/usb-davinci.h>
 
 
 #define DAVINCI_USB_OTG_BASE	0x01c64000
 #define DAVINCI_USB_OTG_BASE	0x01c64000