Skip to contentSkip to conversation

uio_pruss cleanup and platform support

PATCH Superseded Matt Porter 3 participants 25 messages Oct 3, 2012 – Oct 5, 2012

Subsystems (4)

v3 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

v3 cover uio_pruss cleanup and platform support

Changes since v2:
- Dropped AM33xx/OMAP support from series.
- Changed the DA850 L3 RAM gen_pool support to be based on a previous Davinci SRAM series from Subhasish Ghosh and Ben Gardiner.

Changes since v1:
- Replaced uio_pruss private SRAM API use with genalloc
- Added DA850 platform device and clock support
- Added DA850 L3 RAM gen_pool support
- Split out DT binding

This series enables uio_pruss on DA850 and removes use of the private SRAM API by the driver. The driver previously was not enabled by any platform and the private SRAM API was accessing an invalid SRAM bank.

Ben Gardiner (2):
ARM: davinci: sram: ioremap the davinci_soc_info specified sram
regions
ARM: davinci: da850-dm646x: remove the SRAM_VIRT iotable entry

Matt Porter (3):
ARM: davinci: add platform hook to fetch the SRAM pool
ARM: davinci: Add support for PRUSS on DA850
uio: uio_pruss: replace private SRAM API with genalloc

Subhasish Ghosh (1):
ARM: davinci: da850: changed SRAM allocator to shared ram.

 arch/arm/mach-davinci/board-da850-evm.c     |   12 +++++
 arch/arm/mach-davinci/da850.c               |   17 +++----
 arch/arm/mach-davinci/devices-da8xx.c       |   66 +++++++++++++++++++++++++++
 arch/arm/mach-davinci/dm355.c               |    6 ---
 arch/arm/mach-davinci/dm365.c               |    6 ---
 arch/arm/mach-davinci/dm644x.c              |    6 ---
 arch/arm/mach-davinci/dm646x.c              |    6 ---
 arch/arm/mach-davinci/include/mach/common.h |    2 -
 arch/arm/mach-davinci/include/mach/da8xx.h  |    3 ++
 arch/arm/mach-davinci/include/mach/sram.h   |    3 ++
 arch/arm/mach-davinci/sram.c                |   22 +++++++--
 drivers/uio/Kconfig                         |    1 +
 drivers/uio/uio_pruss.c                     |   24 +++++++---
 include/linux/platform_data/uio_pruss.h     |    3 +-
 14 files changed, 132 insertions(+), 45 deletions(-)
Signature · 1 line
1.7.9.5
#1 lore raw

PATCH v3 1/6 ARM: davinci: sram: ioremap the davinci_soc_info specified sram regions

From: Ben Gardiner <[email protected]>

The current davinci init sets up SRAM in iotables. There has been an observed failure to boot a da850 with 128K specified in the iotable.

Make the davinci sram allocator -- now based on RMK's consolidated SRAM support -- do an ioremap of the region specified by the entries in davinci_soc_info before registering with gen_pool_add_virt().

This commit breaks runtime of davinci boards since the regions that the sram init is now trying to ioremap have been iomapped by their iotable entries. The iotable entries will be removed in the patches to come.

[rebased to mainline as the consolidated SRAM support was dropped]
---
 arch/arm/mach-davinci/sram.c |   17 ++++++++++++++---
 1 file changed, 14 insertions(+), 3 deletions(-)
arch/arm/mach-davinci/sram.c +14 -3
index db0f778..0e8ca4f 100644
@@ -10,6 +10,7 @@
  */
 #include <linux/module.h>
 #include <linux/init.h>
+#include <linux/io.h>
 #include <linux/genalloc.h>
 
 #include <mach/common.h>
@@ -32,7 +33,7 @@ void *sram_alloc(size_t len, dma_addr_t *dma)
 		return NULL;
 
 	if (dma)
-		*dma = dma_base + (vaddr - SRAM_VIRT);
+		*dma = gen_pool_virt_to_phys(sram_pool, vaddr);
 	return (void *)vaddr;
 
 }
@@ -53,8 +54,10 @@ EXPORT_SYMBOL(sram_free);
  */
 static int __init sram_init(void)
 {
+	phys_addr_t phys = davinci_soc_info.sram_dma;
 	unsigned len = davinci_soc_info.sram_len;
 	int status = 0;
+	void *addr;
 
 	if (len) {
 		len = min_t(unsigned, len, SRAM_SIZE);
@@ -62,8 +65,16 @@ static int __init sram_init(void)
 		if (!sram_pool)
 			status = -ENOMEM;
 	}
-	if (sram_pool)
-		status = gen_pool_add(sram_pool, SRAM_VIRT, len, -1);
+
+	if (sram_pool) {
+		addr = ioremap(phys, len);
+		if (!addr)
+			return -ENOMEM;
+		if((status = gen_pool_add_virt(sram_pool, (unsigned)addr,
+					       phys, len, -1)))
+			iounmap(addr);
+	}
+
 	WARN_ON(status < 0);
 	return status;
 }
Signature · 1 line
1.7.9.5
#2 lore raw

Re: [PATCH v3 1/6] ARM: davinci: sram: ioremap the davinci_soc_info specified sram regions

Quoted 7 lines · Matt Porter

From: Ben Gardiner <[email protected]>

The current davinci init sets up SRAM in iotables. There has been an observed failure to boot a da850 with 128K specified in the iotable.

Make the davinci sram allocator -- now based on RMK's consolidated SRAM support -- do an ioremap of the region specified by the entries in

The part about being based on RMK's consolidated SRAM support should be dropped.

Quoted 6 lines

davinci_soc_info before registering with gen_pool_add_virt().

This commit breaks runtime of davinci boards since the regions that the sram init is now trying to ioremap have been iomapped by their iotable entries. The iotable entries will be removed in the patches to come.

I would prefer merging 2/6 into this for this reason.

Quoted 43 lines
[rebased to mainline as the consolidated SRAM support was dropped]
---
 arch/arm/mach-davinci/sram.c |   17 ++++++++++++++---
 1 file changed, 14 insertions(+), 3 deletions(-)
arch/arm/mach-davinci/sram.c +4 -1
index db0f778..0e8ca4f 100644
@@ -10,6 +10,7 @@
  */
 #include <linux/module.h>
 #include <linux/init.h>
+#include <linux/io.h>
 #include <linux/genalloc.h>
 
 #include <mach/common.h>
@@ -32,7 +33,7 @@ void *sram_alloc(size_t len, dma_addr_t *dma)
 		return NULL;
 
 	if (dma)
-		*dma = dma_base + (vaddr - SRAM_VIRT);
+		*dma = gen_pool_virt_to_phys(sram_pool, vaddr);
 	return (void *)vaddr;
 
 }
@@ -53,8 +54,10 @@ EXPORT_SYMBOL(sram_free);
  */
 static int __init sram_init(void)
 {
+	phys_addr_t phys = davinci_soc_info.sram_dma;
 	unsigned len = davinci_soc_info.sram_len;
 	int status = 0;
+	void *addr;
 
 	if (len) {
 		len = min_t(unsigned, len, SRAM_SIZE);
@@ -62,8 +65,16 @@ static int __init sram_init(void)
 		if (!sram_pool)
 			status = -ENOMEM;

arch/arm/mach-davinci/sram.c static int __init sram_init(void) · line 74

Quoted 10 lines
arch/arm/mach-davinci/sram.c +7 -2
 	}
-	if (sram_pool)
-		status = gen_pool_add(sram_pool, SRAM_VIRT, len, -1);
+
+	if (sram_pool) {
+		addr = ioremap(phys, len);
+		if (!addr)
+			return -ENOMEM;
+		if((status = gen_pool_add_virt(sram_pool, (unsigned)addr,
+					       phys, len, -1)))

Nit: prefer to set status outside of if().

Looks good otherwise. Thanks for reviving this.

Thanks,
Sekhar

#3 lore raw

Re: [PATCH v3 1/6] ARM: davinci: sram: ioremap the davinci_soc_info specified sram regions

Quoted 11 lines · Sekhar Nori
Quoted 7 lines · Matt Porter

From: Ben Gardiner <[email protected]>

The current davinci init sets up SRAM in iotables. There has been an observed failure to boot a da850 with 128K specified in the iotable.

Make the davinci sram allocator -- now based on RMK's consolidated SRAM support -- do an ioremap of the region specified by the entries in

The part about being based on RMK's consolidated SRAM support should be dropped.

Ok, cruft from trying to preserve Ben's original patch comments. Will remove.

Quoted 8 lines
Quoted 6 lines

davinci_soc_info before registering with gen_pool_add_virt().

This commit breaks runtime of davinci boards since the regions that the sram init is now trying to ioremap have been iomapped by their iotable entries. The iotable entries will be removed in the patches to come.

I would prefer merging 2/6 into this for this reason.

Ok, makes sense. This again comes from me trying to just use the original patches. I'll squash these together for v4.

Quoted 48 lines
Quoted 48 lines
[rebased to mainline as the consolidated SRAM support was dropped]
---
 arch/arm/mach-davinci/sram.c |   17 ++++++++++++++---
 1 file changed, 14 insertions(+), 3 deletions(-)
arch/arm/mach-davinci/sram.c +5 -3
index db0f778..0e8ca4f 100644
@@ -10,6 +10,7 @@
  */
 #include <linux/module.h>
 #include <linux/init.h>
+#include <linux/io.h>
 #include <linux/genalloc.h>
 
 #include <mach/common.h>
@@ -32,7 +33,7 @@ void *sram_alloc(size_t len, dma_addr_t *dma)
 		return NULL;
 
 	if (dma)
-		*dma = dma_base + (vaddr - SRAM_VIRT);
+		*dma = gen_pool_virt_to_phys(sram_pool, vaddr);
 	return (void *)vaddr;
 
 }
@@ -53,8 +54,10 @@ EXPORT_SYMBOL(sram_free);
  */
 static int __init sram_init(void)
 {
+	phys_addr_t phys = davinci_soc_info.sram_dma;
 	unsigned len = davinci_soc_info.sram_len;
 	int status = 0;
+	void *addr;
 
 	if (len) {
 		len = min_t(unsigned, len, SRAM_SIZE);
@@ -62,8 +65,16 @@ static int __init sram_init(void)
 		if (!sram_pool)
 			status = -ENOMEM;
 	}
-	if (sram_pool)
-		status = gen_pool_add(sram_pool, SRAM_VIRT, len, -1);
+
Quoted 8 lines

arch/arm/mach-davinci/sram.c static int __init sram_init(void) · line 74

Quoted 6 lines
arch/arm/mach-davinci/sram.c +6 -0
+	if (sram_pool) {
+		addr = ioremap(phys, len);
+		if (!addr)
+			return -ENOMEM;
+		if((status = gen_pool_add_virt(sram_pool, (unsigned)addr,
+					       phys, len, -1)))

Nit: prefer to set status outside of if().

Ok. Will change.

Quoted 2 lines

Looks good otherwise. Thanks for reviving this.

No problem, I'm just glad we seem to have a workable solution now.

Also, if you could check the conversation with Phillip about gen_pool_find_by_phys(), I wonder what you think about depending on that now, or waiting to convert to it when it goes upstream.

I'm torn as I see all the pdata going away anyway when Davinci is fully converted to DT, and then also any use of find_by_phys() would go away in favor of using the of helpers with his driver.

-Matt

#4 lore raw

PATCH v3 2/6 ARM: davinci: da850-dm646x: remove the SRAM_VIRT iotable entry

In reply to Matt Porter

From: Ben Gardiner <[email protected]>

The sram regions defined for da850-dm646x in their iotable entries are also defined in their davinci_soc_info's.

Remove this duplicate information which is now uneccessary since sram init will ioremap the regions defined by their davinci_soc_info's.

Since this removal completely removes all uses of SRAM_VIRT, also remove the SRAM_VIRT definition.

---
 arch/arm/mach-davinci/da850.c               |    6 ------
 arch/arm/mach-davinci/dm355.c               |    6 ------
 arch/arm/mach-davinci/dm365.c               |    6 ------
 arch/arm/mach-davinci/dm644x.c              |    6 ------
 arch/arm/mach-davinci/dm646x.c              |    6 ------
 arch/arm/mach-davinci/include/mach/common.h |    2 --
 6 files changed, 32 deletions(-)
arch/arm/mach-davinci/da850.c +0 -6
index 6676dee..b4b324f 100644
@@ -713,12 +713,6 @@ static struct map_desc da850_io_desc[] = {
 		.length		= DA8XX_CP_INTC_SIZE,
 		.type		= MT_DEVICE
 	},
-	{
-		.virtual	= SRAM_VIRT,
-		.pfn		= __phys_to_pfn(DA8XX_ARM_RAM_BASE),
-		.length		= SZ_8K,
-		.type		= MT_DEVICE
-	},
 };
 
 static u32 da850_psc_bases[] = { DA8XX_PSC0_BASE, DA8XX_PSC1_BASE };
arch/arm/mach-davinci/dm355.c +0 -6
index a255434..b49c3b7 100644
@@ -758,12 +758,6 @@ static struct map_desc dm355_io_desc[] = {
 		.length		= IO_SIZE,
 		.type		= MT_DEVICE
 	},
-	{
-		.virtual	= SRAM_VIRT,
-		.pfn		= __phys_to_pfn(0x00010000),
-		.length		= SZ_32K,
-		.type		= MT_MEMORY_NONCACHED,
-	},
 };
 
 /* Contents of JTAG ID register used to identify exact cpu type */
arch/arm/mach-davinci/dm365.c +0 -6
index b680c83..6c39805 100644
@@ -985,12 +985,6 @@ static struct map_desc dm365_io_desc[] = {
 		.length		= IO_SIZE,
 		.type		= MT_DEVICE
 	},
-	{
-		.virtual	= SRAM_VIRT,
-		.pfn		= __phys_to_pfn(0x00010000),
-		.length		= SZ_32K,
-		.type		= MT_MEMORY_NONCACHED,
-	},
 };
 
 static struct resource dm365_ks_resources[] = {
arch/arm/mach-davinci/dm644x.c +0 -6
index 0755d46..f8aaa7d 100644
@@ -795,12 +795,6 @@ static struct map_desc dm644x_io_desc[] = {
 		.length		= IO_SIZE,
 		.type		= MT_DEVICE
 	},
-	{
-		.virtual	= SRAM_VIRT,
-		.pfn		= __phys_to_pfn(0x00008000),
-		.length		= SZ_16K,
-		.type		= MT_MEMORY_NONCACHED,
-	},
 };
 
 /* Contents of JTAG ID register used to identify exact cpu type */
arch/arm/mach-davinci/dm646x.c +0 -6
index 97c0f8e..ac7b431 100644
@@ -756,12 +756,6 @@ static struct map_desc dm646x_io_desc[] = {
 		.length		= IO_SIZE,
 		.type		= MT_DEVICE
 	},
-	{
-		.virtual	= SRAM_VIRT,
-		.pfn		= __phys_to_pfn(0x00010000),
-		.length		= SZ_32K,
-		.type		= MT_MEMORY_NONCACHED,
-	},
 };
 
 /* Contents of JTAG ID register used to identify exact cpu type */
arch/arm/mach-davinci/include/mach/common.h +0 -2
index bdc4aa8..046c723 100644
@@ -104,8 +104,6 @@ int davinci_pm_init(void);
 static inline int davinci_pm_init(void) { return 0; }
 #endif
 
-/* standard place to map on-chip SRAMs; they *may* support DMA */
-#define SRAM_VIRT	0xfffe0000
 #define SRAM_SIZE	SZ_128K
 
 #endif /* __ARCH_ARM_MACH_DAVINCI_COMMON_H */
Signature · 1 line
1.7.9.5
#5 lore raw

Re: [PATCH v3 2/6] ARM: davinci: da850-dm646x: remove the SRAM_VIRT iotable entry

Quoted 5 lines · Matt Porter

From: Ben Gardiner <[email protected]>

The sram regions defined for da850-dm646x in their iotable entries are also defined in their davinci_soc_info's.

Quoted 8 lines

Remove this duplicate information which is now uneccessary since sram init will ioremap the regions defined by their davinci_soc_info's.

Since this removal completely removes all uses of SRAM_VIRT, also remove the SRAM_VIRT definition.

What testing was done with this patch? Can you please add that information to the commit text as well.

Thanks,
Sekhar

#6 lore raw

Re: [PATCH v3 2/6] ARM: davinci: da850-dm646x: remove the SRAM_VIRT iotable entry

Quoted 9 lines · Sekhar Nori
Quoted 8 lines · Matt Porter

From: Ben Gardiner <[email protected]>

The sram regions defined for da850-dm646x in their iotable entries are also defined in their davinci_soc_info's.

Remove this duplicate information which is now uneccessary since sram init will ioremap the regions defined by their davinci_soc_info's.

Quoted 8 lines
Quoted 5 lines

Since this removal completely removes all uses of SRAM_VIRT, also remove the SRAM_VIRT definition.

What testing was done with this patch? Can you please add that information to the commit text as well.

I have only tested on AM180x with uio_pruss and davinci-pcm (series for that posted a short while ago). In the uio_pruss case, I run the sample applications from the userspace PRU package that test communication with the shared SRAM, DDR, and internal PRU SRAM. For davinci-pcm, my series enables shared SRAM ping-pong buffering which is working comparably to pcm capture/playback without ping-pong buffering enabled on AM180x.

I have not tested PM at all...yet.

I'll add this detail to the commit.

-Matt

#7 lore raw

PATCH v3 3/6 ARM: davinci: da850: changed SRAM allocator to shared ram.

In reply to Matt Porter

From: Subhasish Ghosh <[email protected]>

This patch modifies the sram allocator to allocate memory from the DA8XX shared RAM.

[rebased onto consolidated SRAM patches]
[rebased to mainline as consolidated SRAM patches were dropped]
---
 arch/arm/mach-davinci/da850.c              |    4 ++--
 arch/arm/mach-davinci/include/mach/da8xx.h |    1 +
 2 files changed, 3 insertions(+), 2 deletions(-)
arch/arm/mach-davinci/da850.c +2 -2
index b4b324f..d8d69de 100644
@@ -1081,8 +1081,8 @@ static struct davinci_soc_info davinci_soc_info_da850 = {
 	.gpio_irq		= IRQ_DA8XX_GPIO0,
 	.serial_dev		= &da8xx_serial_device,
 	.emac_pdata		= &da8xx_emac_pdata,
-	.sram_dma		= DA8XX_ARM_RAM_BASE,
-	.sram_len		= SZ_8K,
+	.sram_dma		= DA8XX_SHARED_RAM_BASE,
+	.sram_len		= SZ_128K,
 };
 
 void __init da850_init(void)
arch/arm/mach-davinci/include/mach/da8xx.h +1 -0
index c9ee723..20553cf 100644
@@ -68,6 +68,7 @@ extern unsigned int da850_max_speed;
 #define DA8XX_AEMIF_CS2_BASE	0x60000000
 #define DA8XX_AEMIF_CS3_BASE	0x62000000
 #define DA8XX_AEMIF_CTL_BASE	0x68000000
+#define DA8XX_SHARED_RAM_BASE	0x80000000
 #define DA8XX_ARM_RAM_BASE	0xffff0000
 
 void __init da830_init(void);
Signature · 1 line
1.7.9.5
#8 lore raw

Re: [PATCH v3 3/6] ARM: davinci: da850: changed SRAM allocator to shared ram.

Matt,

Quoted 10 lines · Matt Porter

From: Subhasish Ghosh <[email protected]>

This patch modifies the sram allocator to allocate memory from the DA8XX shared RAM.

[rebased onto consolidated SRAM patches]
[rebased to mainline as consolidated SRAM patches were dropped]

Were you able to test PM with this change or you need my help?

Thanks,
Sekhar

#9 lore raw

Re: [PATCH v3 3/6] ARM: davinci: da850: changed SRAM allocator to shared ram.

Quoted 8 lines · Sekhar Nori

Matt,

Quoted 5 lines · Matt Porter

From: Subhasish Ghosh <[email protected]>

This patch modifies the sram allocator to allocate memory from the DA8XX shared RAM.

Quoted 7 lines
Quoted 5 lines
[rebased onto consolidated SRAM patches]
[rebased to mainline as consolidated SRAM patches were dropped]

Were you able to test PM with this change or you need my help?

I'll try it out now and if I have problems I may need to enlist your help here. :)

-Matt

#10 lore raw

Re: [PATCH v3 3/6] ARM: davinci: da850: changed SRAM allocator to shared ram.

In reply to Sekhar Nori
Quoted 8 lines · Sekhar Nori

Matt,

Quoted 5 lines · Matt Porter

From: Subhasish Ghosh <[email protected]>

This patch modifies the sram allocator to allocate memory from the DA8XX shared RAM.

Quoted 7 lines
Quoted 5 lines
[rebased onto consolidated SRAM patches]
[rebased to mainline as consolidated SRAM patches were dropped]

Were you able to test PM with this change or you need my help?

I verified suspend/resume is working fine with this change on AM180x EVM. Will note this all in v4.

-Matt

#11 lore raw

PATCH v3 4/6 ARM: davinci: add platform hook to fetch the SRAM pool

In reply to Matt Porter

Adds sram_get_gen_pool() which allows platform code to get the SRAM gen_pool for purposes of providing it in platform data for driver genalloc use.

---
 arch/arm/mach-davinci/include/mach/sram.h |    3 +++
 arch/arm/mach-davinci/sram.c              |    5 +++++
 2 files changed, 8 insertions(+)
arch/arm/mach-davinci/include/mach/sram.h +3 -0
index 111f7cc..4e5db56 100644
@@ -24,4 +24,7 @@
 extern void *sram_alloc(size_t len, dma_addr_t *dma);
 extern void sram_free(void *addr, size_t len);
 
+/* Get the struct gen_pool * for use in platform data */
+extern struct gen_pool *sram_get_gen_pool(void);
+
 #endif /* __MACH_SRAM_H */
arch/arm/mach-davinci/sram.c +5 -0
index 0e8ca4f..b47b64d 100644
@@ -18,6 +18,11 @@
 
 static struct gen_pool *sram_pool;
 
+struct gen_pool *sram_get_gen_pool(void)
+{
+	return sram_pool;
+}
+
 void *sram_alloc(size_t len, dma_addr_t *dma)
 {
 	unsigned long vaddr;
Signature · 1 line
1.7.9.5
#12 lore raw

PATCH v3 5/6 ARM: davinci: Add support for PRUSS on DA850

In reply to Matt Porter

Adds PRUSS clock, registers the L3RAM pool, and registers the platform device for uio_pruss on DA850.

---
 arch/arm/mach-davinci/board-da850-evm.c    |   12 +++++
 arch/arm/mach-davinci/da850.c              |    7 +++
 arch/arm/mach-davinci/devices-da8xx.c      |   66 ++++++++++++++++++++++++++++
 arch/arm/mach-davinci/include/mach/da8xx.h |    2 +
 4 files changed, 87 insertions(+)
arch/arm/mach-davinci/board-da850-evm.c +12 -0
index 1295e61..acc6e84 100644
@@ -29,6 +29,7 @@
 #include <linux/regulator/machine.h>
 #include <linux/regulator/tps6507x.h>
 #include <linux/input/tps6507x-ts.h>
+#include <linux/platform_data/uio_pruss.h>
 #include <linux/spi/spi.h>
 #include <linux/spi/flash.h>
 #include <linux/delay.h>
@@ -42,6 +43,7 @@
 #include <mach/da8xx.h>
 #include <linux/platform_data/mtd-davinci.h>
 #include <mach/mux.h>
+#include <mach/sram.h>
 #include <linux/platform_data/mtd-davinci-aemif.h>
 #include <linux/platform_data/spi-davinci.h>
 
@@ -1253,6 +1255,10 @@ static __init int da850_wl12xx_init(void)
 
 #endif /* CONFIG_DA850_WL12XX */
 
+struct uio_pruss_pdata da8xx_pruss_uio_pdata = {
+	.pintc_base	= 0x4000,
+};
+
 #define DA850EVM_SATA_REFCLKPN_RATE	(100 * 1000 * 1000)
 
 static __init void da850_evm_init(void)
@@ -1339,6 +1345,12 @@ static __init void da850_evm_init(void)
 		pr_warning("da850_evm_init: lcdcntl mux setup failed: %d\n",
 				ret);
 
+	da8xx_pruss_uio_pdata.l3ram_pool = sram_get_gen_pool();
+	ret = da8xx_register_pruss_uio(&da8xx_pruss_uio_pdata);
+	if (ret)
+		pr_warning("pruss_uio initialization failed: %d\n",
+				ret);
+
 	/* Handle board specific muxing for LCD here */
 	ret = davinci_cfg_reg_list(da850_evm_lcdc_pins);
 	if (ret)
arch/arm/mach-davinci/da850.c +7 -0
index d8d69de..7c01d31 100644
@@ -212,6 +212,12 @@ static struct clk tptc2_clk = {
 	.flags		= ALWAYS_ENABLED,
 };
 
+static struct clk pruss_clk = {
+	.name		= "pruss",
+	.parent		= &pll0_sysclk2,
+	.lpsc		= DA8XX_LPSC0_PRUSS,
+};
+
 static struct clk uart0_clk = {
 	.name		= "uart0",
 	.parent		= &pll0_sysclk2,
@@ -378,6 +384,7 @@ static struct clk_lookup da850_clks[] = {
 	CLK(NULL,		"tptc1",	&tptc1_clk),
 	CLK(NULL,		"tpcc1",	&tpcc1_clk),
 	CLK(NULL,		"tptc2",	&tptc2_clk),
+	CLK(NULL,		"pruss",	&pruss_clk),
 	CLK(NULL,		"uart0",	&uart0_clk),
 	CLK(NULL,		"uart1",	&uart1_clk),
 	CLK(NULL,		"uart2",	&uart2_clk),
arch/arm/mach-davinci/devices-da8xx.c +66 -0

72 lines not on this page · raw message

arch/arm/mach-davinci/include/mach/da8xx.h +2 -0
index 20553cf..138e618 100644
@@ -25,6 +25,7 @@
 #include <linux/platform_data/mmc-davinci.h>
 #include <linux/platform_data/usb-davinci.h>
 #include <linux/platform_data/spi-davinci.h>
+#include <linux/platform_data/uio_pruss.h>
 
 extern void __iomem *da8xx_syscfg0_base;
 extern void __iomem *da8xx_syscfg1_base;
@@ -83,6 +84,7 @@ int da8xx_register_watchdog(void);
 int da8xx_register_usb20(unsigned mA, unsigned potpgt);
 int da8xx_register_usb11(struct da8xx_ohci_root_hub *pdata);
 int da8xx_register_emac(void);
+int da8xx_register_pruss_uio(struct uio_pruss_pdata *config);
 int da8xx_register_lcdc(struct da8xx_lcdc_platform_data *pdata);
 int da8xx_register_mmcsd0(struct davinci_mmc_config *config);
 int da850_register_mmcsd1(struct davinci_mmc_config *config);
Signature · 1 line
1.7.9.5
#13 lore raw

Re: [PATCH v3 5/6] ARM: davinci: Add support for PRUSS on DA850

Quoted 4 lines · Matt Porter

Adds PRUSS clock, registers the L3RAM pool, and registers the platform device for uio_pruss on DA850.

I am interested in knowing how this patch was tested.

Quoted 20 lines
---
 arch/arm/mach-davinci/board-da850-evm.c    |   12 +++++
 arch/arm/mach-davinci/da850.c              |    7 +++
 arch/arm/mach-davinci/devices-da8xx.c      |   66 ++++++++++++++++++++++++++++
 arch/arm/mach-davinci/include/mach/da8xx.h |    2 +
 4 files changed, 87 insertions(+)
arch/arm/mach-davinci/board-da850-evm.c +1 -0
index 1295e61..acc6e84 100644
@@ -29,6 +29,7 @@
 #include <linux/regulator/machine.h>
 #include <linux/regulator/tps6507x.h>
 #include <linux/input/tps6507x-ts.h>
+#include <linux/platform_data/uio_pruss.h>
 #include <linux/spi/spi.h>
 #include <linux/spi/flash.h>
 #include <linux/delay.h>

arch/arm/mach-davinci/board-da850-evm.c line 48

Quoted 6 lines
arch/arm/mach-davinci/board-da850-evm.c +1 -0
@@ -42,6 +43,7 @@
 #include <mach/da8xx.h>
 #include <linux/platform_data/mtd-davinci.h>
 #include <mach/mux.h>
+#include <mach/sram.h>
 #include <linux/platform_data/mtd-davinci-aemif.h>
 #include <linux/platform_data/spi-davinci.h>

I know you did not introduce the mess, but can you include a patch to fix the mixture of mach/ and linux/ includes here? mach/ includes should follow the linux/ includes.

Quoted 13 lines
arch/arm/mach-davinci/board-da850-evm.c +4 -0
@@ -1253,6 +1255,10 @@ static __init int da850_wl12xx_init(void)
 
 #endif /* CONFIG_DA850_WL12XX */
 
+struct uio_pruss_pdata da8xx_pruss_uio_pdata = {
+	.pintc_base	= 0x4000,
+};
+
 #define DA850EVM_SATA_REFCLKPN_RATE	(100 * 1000 * 1000)
 
 static __init void da850_evm_init(void)

arch/arm/mach-davinci/board-da850-evm.c static __init void da850_evm_init(void) · line 1348

Quoted 4 lines
arch/arm/mach-davinci/board-da850-evm.c +1 -0
@@ -1339,6 +1345,12 @@ static __init void da850_evm_init(void)
 		pr_warning("da850_evm_init: lcdcntl mux setup failed: %d\n",
 				ret);
 
+	da8xx_pruss_uio_pdata.l3ram_pool = sram_get_gen_pool();

I wonder if this platform data should still be called l3ram pool. L3RAM is OMAP terminology. May be just call it sram_pool? Also this patch should follow 6/6 to prevent build breakage.

arch/arm/mach-davinci/da850.c

Quoted 12 lines
arch/arm/mach-davinci/board-da850-evm.c +5 -0
+	ret = da8xx_register_pruss_uio(&da8xx_pruss_uio_pdata);
+	if (ret)
+		pr_warning("pruss_uio initialization failed: %d\n",
+				ret);
+
 	/* Handle board specific muxing for LCD here */
 	ret = davinci_cfg_reg_list(da850_evm_lcdc_pins);
 	if (ret)
arch/arm/mach-davinci/da850.c +0 -0
index d8d69de..7c01d31 100644

Can you separate out board and SoC changes into different patches?

Quoted 14 lines
arch/arm/mach-davinci/da850.c +6 -0
@@ -212,6 +212,12 @@ static struct clk tptc2_clk = {
 	.flags		= ALWAYS_ENABLED,
 };
 
+static struct clk pruss_clk = {
+	.name		= "pruss",
+	.parent		= &pll0_sysclk2,
+	.lpsc		= DA8XX_LPSC0_PRUSS,
+};
+
 static struct clk uart0_clk = {
 	.name		= "uart0",
 	.parent		= &pll0_sysclk2,

arch/arm/mach-davinci/da850.c static struct clk_lookup da850_clks[] = { · line 387

Quoted 4 lines
arch/arm/mach-davinci/da850.c +1 -0
@@ -378,6 +384,7 @@ static struct clk_lookup da850_clks[] = {
 	CLK(NULL,		"tptc1",	&tptc1_clk),
 	CLK(NULL,		"tpcc1",	&tpcc1_clk),
 	CLK(NULL,		"tptc2",	&tptc2_clk),
+	CLK(NULL,		"pruss",	&pruss_clk),

This is actually incorrect since we should use device name rather than con_id for matching the clock. If there is just one clock that the driver needs, connection id should be NULL. Looking at the driver now, the clk_get() call seems to pass a valid device pointer. So, I wonder how you are able to look up the clock even with a NULL device name.

arch/arm/mach-davinci/devices-da8xx.c void __init da8xx_register_mcasp(int id, struct snd_platform_data *pdata) · line 521

Quoted 12 lines
arch/arm/mach-davinci/da850.c +0 -0
 	CLK(NULL,		"uart0",	&uart0_clk),
 	CLK(NULL,		"uart1",	&uart1_clk),
 	CLK(NULL,		"uart2",	&uart2_clk),
arch/arm/mach-davinci/devices-da8xx.c +1 -0
index bd2f72b..7c2e0d2 100644
@@ -518,6 +518,72 @@ void __init da8xx_register_mcasp(int id, struct snd_platform_data *pdata)
 	}
 }
 
+#define DA8XX_PRUSS_MEM_BASE		0x01C30000

In this file all base addresses are added at the top of the file. The defines are sorted in ascending order of address. If that's broken, its all my fault, but please don't add to the breakage when adding this entry :)

Quoted 46 lines
arch/arm/mach-davinci/devices-da8xx.c +46 -0
+
+static struct resource da8xx_pruss_resources[] = {
+	{
+		.start	= DA8XX_PRUSS_MEM_BASE,
+		.end	= DA8XX_PRUSS_MEM_BASE + 0xFFFF,
+		.flags	= IORESOURCE_MEM,
+	},
+	{
+		.start	= IRQ_DA8XX_EVTOUT0,
+		.end	= IRQ_DA8XX_EVTOUT0,
+		.flags	= IORESOURCE_IRQ,
+	},
+	{
+		.start	= IRQ_DA8XX_EVTOUT1,
+		.end	= IRQ_DA8XX_EVTOUT1,
+		.flags	= IORESOURCE_IRQ,
+	},
+	{
+		.start	= IRQ_DA8XX_EVTOUT2,
+		.end	= IRQ_DA8XX_EVTOUT2,
+		.flags	= IORESOURCE_IRQ,
+	},
+	{
+		.start	= IRQ_DA8XX_EVTOUT3,
+		.end	= IRQ_DA8XX_EVTOUT3,
+		.flags	= IORESOURCE_IRQ,
+	},
+	{
+		.start	= IRQ_DA8XX_EVTOUT4,
+		.end	= IRQ_DA8XX_EVTOUT4,
+		.flags	= IORESOURCE_IRQ,
+	},
+	{
+		.start	= IRQ_DA8XX_EVTOUT5,
+		.end	= IRQ_DA8XX_EVTOUT5,
+		.flags	= IORESOURCE_IRQ,
+	},
+	{
+		.start	= IRQ_DA8XX_EVTOUT6,
+		.end	= IRQ_DA8XX_EVTOUT6,
+		.flags	= IORESOURCE_IRQ,
+	},
+	{
+		.start	= IRQ_DA8XX_EVTOUT7,
+		.end	= IRQ_DA8XX_EVTOUT7,
+		.flags	= IORESOURCE_IRQ,

arch/arm/mach-davinci/devices-da8xx.c void __init da8xx_register_mcasp(int id, struct snd_platform_data *pdata) · line 577

Quoted 10 lines
arch/arm/mach-davinci/devices-da8xx.c +10 -0
+	},
+};
+
+static struct platform_device da8xx_pruss_uio_dev = {
+	.name		= "pruss_uio",
+	.id		= -1,
+	.num_resources	= ARRAY_SIZE(da8xx_pruss_resources),
+	.resource	= da8xx_pruss_resources,
+	.dev	 =	{
+		.coherent_dma_mask = 0xffffffff,

DMA_BIT_MASK(32)?

Thanks,
Sekhar

#14 lore raw

Re: [PATCH v3 5/6] ARM: davinci: Add support for PRUSS on DA850

Quoted 7 lines · Sekhar Nori
Quoted 4 lines · Matt Porter

Adds PRUSS clock, registers the L3RAM pool, and registers the platform device for uio_pruss on DA850.

I am interested in knowing how this patch was tested.

I'll add similar test information in the commit that I mention in my other reply. Basically, I use the examples in the PRU package downloadable from ti.com. There's a PRU_memAccessL3andDDR example which will fail miserably if the uio_pruss driver SRAM resource is not configured properly. With the complete series in place, it's able to complete execution successfully, communicating via the shared sram pool.

Quoted 22 lines
Quoted 22 lines
---
 arch/arm/mach-davinci/board-da850-evm.c    |   12 +++++
 arch/arm/mach-davinci/da850.c              |    7 +++
 arch/arm/mach-davinci/devices-da8xx.c      |   66 ++++++++++++++++++++++++++++
 arch/arm/mach-davinci/include/mach/da8xx.h |    2 +
 4 files changed, 87 insertions(+)
arch/arm/mach-davinci/board-da850-evm.c +1 -0
index 1295e61..acc6e84 100644
@@ -29,6 +29,7 @@
 #include <linux/regulator/machine.h>
 #include <linux/regulator/tps6507x.h>
 #include <linux/input/tps6507x-ts.h>
+#include <linux/platform_data/uio_pruss.h>
 #include <linux/spi/spi.h>
 #include <linux/spi/flash.h>
 #include <linux/delay.h>
@@ -42,6 +43,7 @@
 #include <mach/da8xx.h>
 #include <linux/platform_data/mtd-davinci.h>
Quoted 8 lines

arch/arm/mach-davinci/board-da850-evm.c line 48

Quoted 4 lines
arch/arm/mach-davinci/board-da850-evm.c +1 -0
 #include <mach/mux.h>
+#include <mach/sram.h>
 #include <linux/platform_data/mtd-davinci-aemif.h>
 #include <linux/platform_data/spi-davinci.h>

I know you did not introduce the mess, but can you include a patch to fix the mixture of mach/ and linux/ includes here? mach/ includes should follow the linux/ includes.

Ok. Yeah, I agree it's a mess there.

Quoted 15 lines
Quoted 15 lines
arch/arm/mach-davinci/board-da850-evm.c +4 -0
@@ -1253,6 +1255,10 @@ static __init int da850_wl12xx_init(void)
 
 #endif /* CONFIG_DA850_WL12XX */
 
+struct uio_pruss_pdata da8xx_pruss_uio_pdata = {
+	.pintc_base	= 0x4000,
+};
+
 #define DA850EVM_SATA_REFCLKPN_RATE	(100 * 1000 * 1000)
 
 static __init void da850_evm_init(void)
@@ -1339,6 +1345,12 @@ static __init void da850_evm_init(void)
 		pr_warning("da850_evm_init: lcdcntl mux setup failed: %d\n",
 				ret);
 
Quoted 5 lines

arch/arm/mach-davinci/board-da850-evm.c static __init void da850_evm_init(void) · line 1348

Quoted 1 line
arch/arm/mach-davinci/board-da850-evm.c +1 -0
+	da8xx_pruss_uio_pdata.l3ram_pool = sram_get_gen_pool();

I wonder if this platform data should still be called l3ram pool. L3RAM is OMAP terminology. May be just call it sram_pool? Also this patch should follow 6/6 to prevent build breakage.

I agree, I'll change to sram_pool. I went back and forth on this because I found even the userspace PRU tools had it called L3...I think it's wise just say sram and avoid confusion. I'll move the patch too.

Quoted 6 lines
Quoted 6 lines
arch/arm/mach-davinci/board-da850-evm.c +5 -0
+	ret = da8xx_register_pruss_uio(&da8xx_pruss_uio_pdata);
+	if (ret)
+		pr_warning("pruss_uio initialization failed: %d\n",
+				ret);
+
 	/* Handle board specific muxing for LCD here */
Quoted 8 lines

arch/arm/mach-davinci/da850.c

Quoted 6 lines
arch/arm/mach-davinci/board-da850-evm.c +0 -0
 	ret = davinci_cfg_reg_list(da850_evm_lcdc_pins);
 	if (ret)
arch/arm/mach-davinci/da850.c +0 -0
index d8d69de..7c01d31 100644

Can you separate out board and SoC changes into different patches?

Ok, yes.

Quoted 16 lines
Quoted 16 lines
arch/arm/mach-davinci/da850.c +6 -0
@@ -212,6 +212,12 @@ static struct clk tptc2_clk = {
 	.flags		= ALWAYS_ENABLED,
 };
 
+static struct clk pruss_clk = {
+	.name		= "pruss",
+	.parent		= &pll0_sysclk2,
+	.lpsc		= DA8XX_LPSC0_PRUSS,
+};
+
 static struct clk uart0_clk = {
 	.name		= "uart0",
 	.parent		= &pll0_sysclk2,
@@ -378,6 +384,7 @@ static struct clk_lookup da850_clks[] = {
 	CLK(NULL,		"tptc1",	&tptc1_clk),
 	CLK(NULL,		"tpcc1",	&tpcc1_clk),
Quoted 8 lines

arch/arm/mach-davinci/da850.c static struct clk_lookup da850_clks[] = { · line 387

Quoted 2 lines
arch/arm/mach-davinci/da850.c +1 -0
 	CLK(NULL,		"tptc2",	&tptc2_clk),
+	CLK(NULL,		"pruss",	&pruss_clk),

This is actually incorrect since we should use device name rather than con_id for matching the clock. If there is just one clock that the driver needs, connection id should be NULL. Looking at the driver now, the clk_get() call seems to pass a valid device pointer. So, I wonder how you are able to look up the clock even with a NULL device name.

Hrm, I'll look into this. This part was a not looked at closely, just a quick copy/paste/modify and worked as tested with the PRU examples so I didn't look further. I'll look again let you know why it actually works. I'm guessing I got lucky here, and should be a simple fix.

Quoted 11 lines
Quoted 11 lines
arch/arm/mach-davinci/da850.c +0 -0
 	CLK(NULL,		"uart0",	&uart0_clk),
 	CLK(NULL,		"uart1",	&uart1_clk),
 	CLK(NULL,		"uart2",	&uart2_clk),
arch/arm/mach-davinci/devices-da8xx.c +0 -0
index bd2f72b..7c2e0d2 100644
@@ -518,6 +518,72 @@ void __init da8xx_register_mcasp(int id, struct snd_platform_data *pdata)
 	}
 }
 
Quoted 5 lines

arch/arm/mach-davinci/devices-da8xx.c void __init da8xx_register_mcasp(int id, struct snd_platform_data *pdata) · line 521

Quoted 1 line
arch/arm/mach-davinci/devices-da8xx.c +1 -0
+#define DA8XX_PRUSS_MEM_BASE		0x01C30000

In this file all base addresses are added at the top of the file. The defines are sorted in ascending order of address. If that's broken, its all my fault, but please don't add to the breakage when adding this entry :)

Ok :) Will fix.

Quoted 50 lines
Quoted 50 lines
arch/arm/mach-davinci/devices-da8xx.c +50 -0
+
+static struct resource da8xx_pruss_resources[] = {
+	{
+		.start	= DA8XX_PRUSS_MEM_BASE,
+		.end	= DA8XX_PRUSS_MEM_BASE + 0xFFFF,
+		.flags	= IORESOURCE_MEM,
+	},
+	{
+		.start	= IRQ_DA8XX_EVTOUT0,
+		.end	= IRQ_DA8XX_EVTOUT0,
+		.flags	= IORESOURCE_IRQ,
+	},
+	{
+		.start	= IRQ_DA8XX_EVTOUT1,
+		.end	= IRQ_DA8XX_EVTOUT1,
+		.flags	= IORESOURCE_IRQ,
+	},
+	{
+		.start	= IRQ_DA8XX_EVTOUT2,
+		.end	= IRQ_DA8XX_EVTOUT2,
+		.flags	= IORESOURCE_IRQ,
+	},
+	{
+		.start	= IRQ_DA8XX_EVTOUT3,
+		.end	= IRQ_DA8XX_EVTOUT3,
+		.flags	= IORESOURCE_IRQ,
+	},
+	{
+		.start	= IRQ_DA8XX_EVTOUT4,
+		.end	= IRQ_DA8XX_EVTOUT4,
+		.flags	= IORESOURCE_IRQ,
+	},
+	{
+		.start	= IRQ_DA8XX_EVTOUT5,
+		.end	= IRQ_DA8XX_EVTOUT5,
+		.flags	= IORESOURCE_IRQ,
+	},
+	{
+		.start	= IRQ_DA8XX_EVTOUT6,
+		.end	= IRQ_DA8XX_EVTOUT6,
+		.flags	= IORESOURCE_IRQ,
+	},
+	{
+		.start	= IRQ_DA8XX_EVTOUT7,
+		.end	= IRQ_DA8XX_EVTOUT7,
+		.flags	= IORESOURCE_IRQ,
+	},
+};
+
+static struct platform_device da8xx_pruss_uio_dev = {
Quoted 8 lines

arch/arm/mach-davinci/devices-da8xx.c void __init da8xx_register_mcasp(int id, struct snd_platform_data *pdata) · line 577

Quoted 6 lines
arch/arm/mach-davinci/devices-da8xx.c +6 -0
+	.name		= "pruss_uio",
+	.id		= -1,
+	.num_resources	= ARRAY_SIZE(da8xx_pruss_resources),
+	.resource	= da8xx_pruss_resources,
+	.dev	 =	{
+		.coherent_dma_mask = 0xffffffff,

DMA_BIT_MASK(32)?

Yeah, more copy/paste/modify stuff. I'll fix that.

-Matt

#15 lore raw

Re: [PATCH v3 5/6] ARM: davinci: Add support for PRUSS on DA850

In reply to Sekhar Nori
Quoted 13 lines · Sekhar Nori
Quoted 12 lines · Matt Porter
arch/arm/mach-davinci/da850.c +6 -0
+static struct clk pruss_clk = {
+	.name		= "pruss",
+	.parent		= &pll0_sysclk2,
+	.lpsc		= DA8XX_LPSC0_PRUSS,
+};
+
 static struct clk uart0_clk = {
 	.name		= "uart0",
 	.parent		= &pll0_sysclk2,
@@ -378,6 +384,7 @@ static struct clk_lookup da850_clks[] = {
 	CLK(NULL,		"tptc1",	&tptc1_clk),
 	CLK(NULL,		"tpcc1",	&tpcc1_clk),
Quoted 8 lines

arch/arm/mach-davinci/da850.c static struct clk_lookup da850_clks[] = { · line 387

Quoted 2 lines
arch/arm/mach-davinci/da850.c +1 -0
 	CLK(NULL,		"tptc2",	&tptc2_clk),
+	CLK(NULL,		"pruss",	&pruss_clk),

This is actually incorrect since we should use device name rather than con_id for matching the clock. If there is just one clock that the driver needs, connection id should be NULL. Looking at the driver now, the clk_get() call seems to pass a valid device pointer. So, I wonder how you are able to look up the clock even with a NULL device name.

I doublechecked the clk_get() find implentation to confirm that I indeed did get lucky here. Since pruss has only one instance and the clk_find() implementation looks for the best found match, it's able to find the clock just by the con_id, though it's not the "best possible" match in the find implementation...it's the "best found" match.. As you noted, this is incorrect though for a clock expected to be used from a driver context so I will address this in the update.

-Matt

#16 lore raw

Re: [PATCH v3 5/6] ARM: davinci: Add support for PRUSS on DA850

Quoted 23 lines · Matt Porter
Quoted 13 lines · Sekhar Nori
Quoted 12 lines · Matt Porter
arch/arm/mach-davinci/da850.c +6 -0
+static struct clk pruss_clk = {
+	.name		= "pruss",
+	.parent		= &pll0_sysclk2,
+	.lpsc		= DA8XX_LPSC0_PRUSS,
+};
+
 static struct clk uart0_clk = {
 	.name		= "uart0",
 	.parent		= &pll0_sysclk2,
@@ -378,6 +384,7 @@ static struct clk_lookup da850_clks[] = {
 	CLK(NULL,		"tptc1",	&tptc1_clk),
 	CLK(NULL,		"tpcc1",	&tpcc1_clk),
Quoted 8 lines

arch/arm/mach-davinci/da850.c static struct clk_lookup da850_clks[] = { · line 387

Quoted 2 lines
arch/arm/mach-davinci/da850.c +1 -0
 	CLK(NULL,		"tptc2",	&tptc2_clk),
+	CLK(NULL,		"pruss",	&pruss_clk),

This is actually incorrect since we should use device name rather than con_id for matching the clock. If there is just one clock that the driver needs, connection id should be NULL. Looking at the driver now, the clk_get() call seems to pass a valid device pointer. So, I wonder how you are able to look up the clock even with a NULL device name.

Quoted 7 lines

I doublechecked the clk_get() find implentation to confirm that I indeed did get lucky here. Since pruss has only one instance and the clk_find() implementation looks for the best found match, it's able to find the clock just by the con_id, though it's not the "best possible" match in the find implementation...it's the "best found" match.. As you noted, this is incorrect though for a clock expected to be used from a driver context so I will address this in the update.

Thanks for debugging and clarifying.

Regards,
Sekhar

#17 lore raw

PATCH v3 6/6 uio: uio_pruss: replace private SRAM API with genalloc

In reply to Matt Porter

Remove the use of the private DaVinci SRAM API in favor of genalloc. The pool to be used is provided by platform data.

---
 drivers/uio/Kconfig                     |    1 +
 drivers/uio/uio_pruss.c                 |   24 +++++++++++++++++-------
 include/linux/platform_data/uio_pruss.h |    3 ++-
 3 files changed, 20 insertions(+), 8 deletions(-)
drivers/uio/Kconfig +1 -0
index 6f3ea9b..c48b938 100644
@@ -97,6 +97,7 @@ config UIO_NETX
 config UIO_PRUSS
 	tristate "Texas Instruments PRUSS driver"
 	depends on ARCH_DAVINCI_DA850
+	select GENERIC_ALLOCATOR
 	help
 	  PRUSS driver for OMAPL138/DA850/AM18XX devices
 	  PRUSS driver requires user space components, examples and user space
drivers/uio/uio_pruss.c +17 -7
index 33a7a27..1b55db3 100644
@@ -25,7 +25,7 @@
 #include <linux/clk.h>
 #include <linux/dma-mapping.h>
 #include <linux/slab.h>
-#include <mach/sram.h>
+#include <linux/genalloc.h>
 
 #define DRV_NAME "pruss_uio"
 #define DRV_VERSION "1.0"
@@ -65,10 +65,11 @@ struct uio_pruss_dev {
 	dma_addr_t sram_paddr;
 	dma_addr_t ddr_paddr;
 	void __iomem *prussio_vaddr;
-	void *sram_vaddr;
+	unsigned long sram_vaddr;
 	void *ddr_vaddr;
 	unsigned int hostirq_start;
 	unsigned int pintc_base;
+	struct gen_pool *sram_pool;
 };
 
 static irqreturn_t pruss_handler(int irq, struct uio_info *info)
@@ -106,7 +107,9 @@ static void pruss_cleanup(struct platform_device *dev,
 			gdev->ddr_paddr);
 	}
 	if (gdev->sram_vaddr)
-		sram_free(gdev->sram_vaddr, sram_pool_sz);
+		gen_pool_free(gdev->sram_pool,
+			      gdev->sram_vaddr,
+			      sram_pool_sz);
 	kfree(gdev->info);
 	clk_put(gdev->pruss_clk);
 	kfree(gdev);
@@ -152,10 +155,17 @@ static int __devinit pruss_probe(struct platform_device *dev)
 		goto out_free;
 	}
 
-	gdev->sram_vaddr = sram_alloc(sram_pool_sz, &(gdev->sram_paddr));
-	if (!gdev->sram_vaddr) {
-		dev_err(&dev->dev, "Could not allocate SRAM pool\n");
-		goto out_free;
+	if (pdata->l3ram_pool) {
+		gdev->sram_pool = pdata->l3ram_pool;
+		gdev->sram_vaddr =
+			gen_pool_alloc(gdev->sram_pool, sram_pool_sz);
+		if (!gdev->sram_vaddr) {
+			dev_err(&dev->dev, "Could not allocate SRAM pool\n");
+			goto out_free;
+		}
+		gdev->sram_paddr =
+			gen_pool_virt_to_phys(gdev->sram_pool,
+					      gdev->sram_vaddr);
 	}
 
 	gdev->ddr_vaddr = dma_alloc_coherent(&dev->dev, extram_pool_sz,
include/linux/platform_data/uio_pruss.h +2 -1
index f39140a..e500fe6 100644
@@ -20,6 +20,7 @@
 
 /* To configure the PRUSS INTC base offset for UIO driver */
 struct uio_pruss_pdata {
-	u32	pintc_base;
+	u32		pintc_base;
+	struct gen_pool *l3ram_pool;
 };
 #endif /* _UIO_PRUSS_H_ */
Signature · 1 line
1.7.9.5
#18 lore raw
In reply to Matt Porter

Hi Matt,

Quoted 4 lines · Matt Porter

This series enables uio_pruss on DA850 and removes use of the private SRAM API by the driver. The driver previously was not enabled by any platform and the private SRAM API was accessing an invalid SRAM bank.

have you seen my SRAM patch series at https://lkml.org/lkml/2012/9/7/281
"Add device tree support for on-chip SRAM" ?

I think the generic SRAM/genalloc driver (https://lkml.org/lkml/2012/9/7/282)
could be useful to map the L3RAM on Davinci.
With the gen_pool lookup patch (https://lkml.org/lkml/2012/9/7/284) the uio_pruss driver could then use the gen_pool_find_by_phys() (or of_get_named_gen_pool() for initialization from device tree) to retrieve the struct gen_pool*.

This way you could avoid handing it over via platform data and you could get rid of arch/arm/mach-davinci/{sram.c,include/mach/sram.h} completely.

regards
Philipp

Signature · 4 lines
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |
#19 lore raw
Quoted 10 lines · Philipp Zabel

Hi Matt,

Quoted 4 lines · Matt Porter

This series enables uio_pruss on DA850 and removes use of the private SRAM API by the driver. The driver previously was not enabled by any platform and the private SRAM API was accessing an invalid SRAM bank.

have you seen my SRAM patch series at https://lkml.org/lkml/2012/9/7/281
"Add device tree support for on-chip SRAM" ?

Yes.

Quoted 9 lines

I think the generic SRAM/genalloc driver (https://lkml.org/lkml/2012/9/7/282)
could be useful to map the L3RAM on Davinci.
With the gen_pool lookup patch (https://lkml.org/lkml/2012/9/7/284) the uio_pruss driver could then use the gen_pool_find_by_phys() (or of_get_named_gen_pool() for initialization from device tree) to retrieve the struct gen_pool*.

This way you could avoid handing it over via platform data and you could get rid of arch/arm/mach-davinci/{sram.c,include/mach/sram.h} completely.

I did miss the gen_pool_find_by_phys() call in that series. That does look useful. I actually mentioned your series in an earlier posting since I like it, but since the initialization of the driver was inherently tied to DT it's not usable for DaVinci that's just starting to convert to DT and needs !DT support as well.

I do see it moving to your driver exclusively, but I wanted to make this series focused on only getting rid of the private SRAM API using the existing pdata framework that's already there. I think once gen_pool_find_by_phys() goes upstream we can switch to that and get the address from a resource in the !DT case. I guess we should see if Sekhar would like to see this happen in two steps or just have us depend on the gen_pool_find_by_phys() patch now.

BTW, I was going to post a patch for your driver to allow configurability of the allocation order, but have been busy with other things. We'll eventually need that when switching to it as the hardcoded page size order isn't going to work for all cases.

-Matt

#20 lore raw
Quoted 30 lines · Matt Porter
Quoted 10 lines · Philipp Zabel

Hi Matt,

Quoted 4 lines · Matt Porter

This series enables uio_pruss on DA850 and removes use of the private SRAM API by the driver. The driver previously was not enabled by any platform and the private SRAM API was accessing an invalid SRAM bank.

have you seen my SRAM patch series at https://lkml.org/lkml/2012/9/7/281
"Add device tree support for on-chip SRAM" ?

Yes.

Quoted 9 lines

I think the generic SRAM/genalloc driver (https://lkml.org/lkml/2012/9/7/282)
could be useful to map the L3RAM on Davinci.
With the gen_pool lookup patch (https://lkml.org/lkml/2012/9/7/284) the uio_pruss driver could then use the gen_pool_find_by_phys() (or of_get_named_gen_pool() for initialization from device tree) to retrieve the struct gen_pool*.

This way you could avoid handing it over via platform data and you could get rid of arch/arm/mach-davinci/{sram.c,include/mach/sram.h} completely.

I did miss the gen_pool_find_by_phys() call in that series. That does look useful. I actually mentioned your series in an earlier posting since I like it, but since the initialization of the driver was inherently tied to DT it's not usable for DaVinci that's just starting to convert to DT and needs !DT support as well.

Quoted 7 lines

I do see it moving to your driver exclusively, but I wanted to make this series focused on only getting rid of the private SRAM API using the existing pdata framework that's already there. I think once gen_pool_find_by_phys() goes upstream we can switch to that and get the address from a resource in the !DT case. I guess we should see if Sekhar would like to see this happen in two steps or just have us depend on the gen_pool_find_by_phys() patch now.

I prefer going with this series now and switching to the SRAM driver once it is available mainline.

Thanks,
Sekhar

#21 lore raw
Quoted 39 lines · Sekhar Nori
Quoted 30 lines · Matt Porter
Quoted 10 lines · Philipp Zabel

Hi Matt,

Quoted 4 lines · Matt Porter

This series enables uio_pruss on DA850 and removes use of the private SRAM API by the driver. The driver previously was not enabled by any platform and the private SRAM API was accessing an invalid SRAM bank.

have you seen my SRAM patch series at https://lkml.org/lkml/2012/9/7/281
"Add device tree support for on-chip SRAM" ?

Yes.

Quoted 9 lines

I think the generic SRAM/genalloc driver (https://lkml.org/lkml/2012/9/7/282)
could be useful to map the L3RAM on Davinci.
With the gen_pool lookup patch (https://lkml.org/lkml/2012/9/7/284) the uio_pruss driver could then use the gen_pool_find_by_phys() (or of_get_named_gen_pool() for initialization from device tree) to retrieve the struct gen_pool*.

This way you could avoid handing it over via platform data and you could get rid of arch/arm/mach-davinci/{sram.c,include/mach/sram.h} completely.

I did miss the gen_pool_find_by_phys() call in that series. That does look useful. I actually mentioned your series in an earlier posting since I like it, but since the initialization of the driver was inherently tied to DT it's not usable for DaVinci that's just starting to convert to DT and needs !DT support as well.

Quoted 7 lines

I do see it moving to your driver exclusively, but I wanted to make this series focused on only getting rid of the private SRAM API using the existing pdata framework that's already there. I think once gen_pool_find_by_phys() goes upstream we can switch to that and get the address from a resource in the !DT case. I guess we should see if Sekhar would like to see this happen in two steps or just have us depend on the gen_pool_find_by_phys() patch now.

Quoted 2 lines

I prefer going with this series now and switching to the SRAM driver once it is available mainline.

Ok, thanks. In that case, I'll also plan to keep the davinci-pcm series using the same approach for now too.

-Matt

#22 lore raw
In reply to Matt Porter
Quoted 7 lines · Matt Porter
Quoted 7 lines

I think the generic SRAM/genalloc driver (https://lkml.org/lkml/2012/9/7/282)
could be useful to map the L3RAM on Davinci.
With the gen_pool lookup patch (https://lkml.org/lkml/2012/9/7/284) the uio_pruss driver could then use the gen_pool_find_by_phys() (or of_get_named_gen_pool() for initialization from device tree) to retrieve the struct gen_pool*.

Quoted 6 lines
Quoted 2 lines

This way you could avoid handing it over via platform data and you could get rid of arch/arm/mach-davinci/{sram.c,include/mach/sram.h} completely.

I did miss the gen_pool_find_by_phys() call in that series. That does look useful. I actually mentioned your series in an earlier posting since I like it,

That I did miss.

Quoted 3 lines

but since the initialization of the driver was inherently tied to DT it's not usable for DaVinci that's just starting to convert to DT and needs !DT support as well.

There should be no dependency on DT in the sram driver. It just requests and remaps the first given iomem resource and creates a gen_pool from that. This should work just as well for the !DT case.
Maybe it's just my choice of patch series subject gave you that impression? If there's a real issue for !DT, I should fix it.

Quoted 7 lines

I do see it moving to your driver exclusively, but I wanted to make this series focused on only getting rid of the private SRAM API using the existing pdata framework that's already there. I think once gen_pool_find_by_phys() goes upstream we can switch to that and get the address from a resource in the !DT case. I guess we should see if Sekhar would like to see this happen in two steps or just have us depend on the gen_pool_find_by_phys() patch now.

Thanks, I'm glad you are aware of the sram driver and consider it useful.

Quoted 4 lines

BTW, I was going to post a patch for your driver to allow configurability of the allocation order, but have been busy with other things. We'll eventually need that when switching to it as the hardcoded page size order isn't going to work for all cases.

Good point.

regards
Philipp

Signature · 4 lines
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |
#23 lore raw
Quoted 21 lines · Philipp Zabel
Quoted 7 lines · Matt Porter
Quoted 7 lines

I think the generic SRAM/genalloc driver (https://lkml.org/lkml/2012/9/7/282)
could be useful to map the L3RAM on Davinci.
With the gen_pool lookup patch (https://lkml.org/lkml/2012/9/7/284) the uio_pruss driver could then use the gen_pool_find_by_phys() (or of_get_named_gen_pool() for initialization from device tree) to retrieve the struct gen_pool*.

Quoted 6 lines
Quoted 2 lines

This way you could avoid handing it over via platform data and you could get rid of arch/arm/mach-davinci/{sram.c,include/mach/sram.h} completely.

I did miss the gen_pool_find_by_phys() call in that series. That does look useful. I actually mentioned your series in an earlier posting since I like it,

That I did miss.

Quoted 3 lines

but since the initialization of the driver was inherently tied to DT it's not usable for DaVinci that's just starting to convert to DT and needs !DT support as well.

Quoted 5 lines

There should be no dependency on DT in the sram driver. It just requests and remaps the first given iomem resource and creates a gen_pool from that. This should work just as well for the !DT case.
Maybe it's just my choice of patch series subject gave you that impression? If there's a real issue for !DT, I should fix it.

*sigh*, I see now. I looked at v2 and got wrapped up in the DT use case and missed your platform device support. I think it will work just fine for us to use in a "phase 2" of this work, replacing the backend of davinci sram allocation with this as Sekhar seems to be open to.

Quoted 8 lines
Quoted 7 lines

I do see it moving to your driver exclusively, but I wanted to make this series focused on only getting rid of the private SRAM API using the existing pdata framework that's already there. I think once gen_pool_find_by_phys() goes upstream we can switch to that and get the address from a resource in the !DT case. I guess we should see if Sekhar would like to see this happen in two steps or just have us depend on the gen_pool_find_by_phys() patch now.

Quoted 8 lines

Thanks, I'm glad you are aware of the sram driver and consider it useful.

Quoted 4 lines

BTW, I was going to post a patch for your driver to allow configurability of the allocation order, but have been busy with other things. We'll eventually need that when switching to it as the hardcoded page size order isn't going to work for all cases.

Good point.

I think this is the only blocker to DaVinci adopting it once it goes upstream. I can add a patch in your driver thread if that helps.

-Matt

#24 lore raw
Quoted 20 lines · Matt Porter

*sigh*, I see now. I looked at v2 and got wrapped up in the DT use case and missed your platform device support. I think it will work just fine for us to use in a "phase 2" of this work, replacing the backend of davinci sram allocation with this as Sekhar seems to be open to.

Quoted 15 lines
Quoted 7 lines

I do see it moving to your driver exclusively, but I wanted to make this series focused on only getting rid of the private SRAM API using the existing pdata framework that's already there. I think once gen_pool_find_by_phys() goes upstream we can switch to that and get the address from a resource in the !DT case. I guess we should see if Sekhar would like to see this happen in two steps or just have us depend on the gen_pool_find_by_phys() patch now.

Thanks, I'm glad you are aware of the sram driver and consider it useful.

Quoted 4 lines

BTW, I was going to post a patch for your driver to allow configurability of the allocation order, but have been busy with other things. We'll eventually need that when switching to it as the hardcoded page size order isn't going to work for all cases.

Quoted 4 lines
Quoted 1 line

Good point.

I think this is the only blocker to DaVinci adopting it once it goes upstream. I can add a patch in your driver thread if that helps.

Yes, that would be welcome.

regards
Philipp

Signature · 4 lines
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |