Skip to contentSkip to conversation

pruss mfd drivers.

PATCH Superseded Subhasish Ghosh 11 participants 81 messages Apr 22, 2011 – May 30, 2011

Subsystems (5)

v4 of 5 Superseded Latest is v5 →

lore
Share & tools
lore
#0 lore raw

v4 cover pruss mfd drivers.

				PRUSS Functional Block Diagram
		/-------------------------------------------------------\
		|							|
		|			|------|			|
	32GPO<------->PRU CORE-0 <----->|      |<----> DRAM 0		|
	30GPI<------->(4KB IRAM)	|  S   |	(512 Bytes)	|
		|			|      |			|
	32GPO<------->PRU CORE-1 <----->|  C   |<----> DRAM 1		|
	30GPI<------->(4KB IRAM)	|      |	(512 Bytes)	|
		|			|  R   |			|
		|			|      |			|

Ints to ARM/ | Interrupt <---->| |-------------------------> Master I/F (to SCR2)
DSP INTC <------------->Controller | |<------------------------- Slave I/F (from SCR2)
Events from | (INTC) |------| |
Periph + PRUs | |

		\-------------------------------------------------------/

Programmable Realtime Unit (PRU) is basically a 32-bit RISC processor available within TI's DA8XX SOCs. It consists of local instruction and data RAM and also has access to SOC resources via a Switched Central Resource (SCR).

There are two PRU's available within DA8XX SOC's PRUSS, hence providing two execution cores. Devices/Protocols can be emulated on these utilizing either both or only one of the PRUs independently.

The rational behind the MFD driver being the fact that multiple devices can be implemented on the cores independently.
It's also possible, as in our case, to implement a single device on both the PRU's resulting in improved load sharing.

A detailed description is also available here:
http://processors.wiki.ti.com/index.php/Programmable_Realtime_Unit_Subsystem

version 4:
=========
MFD:
* added mfd_cells in the board file
* exported seperate multiwrite/read functions
* removed clk_get_pruss api
* improved coding style
* removed code duplications
* renamed files to pruss based
* used make C=1
* added __iomem cookie for io addresses
* used iowrite/read instead of __raw variants

SUART:
* changes for the new mfd_cell implementation
* code cleanup
* used iowrite/read instead of __raw variants
* used make C=1

NOTE:
* as requested by the owner the CAN driver patch is submitted seperately.

version 3:
=========
* added locking to mfd driver.
* removed typedefs.
* resource allocation through mfd.
* renamed da8xx_register_pruss to da8xx_register_pruss_mfd.
* removed da8xx_pruss directory for suart.
* combined all suart headers.
* modified register structure for pruss.
* added function clk_add_alias_mcasp.
* suart api layer cleanup.
* removed semaphore usage.
* updated to latest internal code base.
* removed __suart_err/dbg.

version 2:
==========
* added pruss TTY Soft-UART driver.
* added pruss Soft-UART board and platform changes.
* fixed previous review comments.
* reordered patch sequence.

version 1:
==========
* added pruss mfd driver.

Subhasish Ghosh (11):
mfd: add pruss mfd driver.
da850: add pruss clock.
da850: pruss platform specific additions.
da850: pruss board specific additions.
mfd: pruss SUART private data.
da850: pruss SUART board specific additions.
da850: pruss SUART platform specific additions.
tty: add pruss SUART driver
mfd: pruss CAN private data.
da850: pruss CAN platform specific additions.
da850: pruss CAN board specific additions.

 arch/arm/mach-davinci/board-da850-evm.c    |  104 ++
 arch/arm/mach-davinci/da850.c              |   12 +
 arch/arm/mach-davinci/devices-da8xx.c      |   81 ++
 arch/arm/mach-davinci/include/mach/da8xx.h |    4 +
 arch/arm/mach-davinci/include/mach/mux.h   |    5 +
 drivers/mfd/Kconfig                        |   10 +
 drivers/mfd/Makefile                       |    1 +
 drivers/mfd/pruss.c                        |  513 +++++++++
 drivers/tty/serial/Kconfig                 |   18 +
 drivers/tty/serial/Makefile                |    6 +
 drivers/tty/serial/pruss_suart.c           | 1061 +++++++++++++++++
 drivers/tty/serial/pruss_suart.h           | 1038 +++++++++++++++++
 drivers/tty/serial/pruss_suart_api.c       | 1710 ++++++++++++++++++++++++++++
 drivers/tty/serial/pruss_suart_utils.c     |  393 +++++++
 include/linux/mfd/pruss.h                  |  140 +++
 include/linux/mfd/pruss_core.h             |  128 +++
 include/linux/serial_core.h                |    2 +
 17 files changed, 5226 insertions(+), 0 deletions(-)
 create mode 100644 drivers/mfd/pruss.c
 create mode 100644 drivers/tty/serial/pruss_suart.c
 create mode 100644 drivers/tty/serial/pruss_suart.h
 create mode 100644 drivers/tty/serial/pruss_suart_api.c
 create mode 100644 drivers/tty/serial/pruss_suart_utils.c
 create mode 100644 include/linux/mfd/pruss.h
 create mode 100644 include/linux/mfd/pruss_core.h
Signature · 1 line
1.7.2.3
#1 lore raw

PATCH v4 1/11 mfd: add pruss mfd driver.

This patch adds the pruss MFD driver and associated include files. For details regarding the PRUSS please refer the folowing link:
http://processors.wiki.ti.com/index.php/Programmable_Realtime_Unit_Subsystem

The rational behind the MFD driver being the fact that multiple devices can be implemented on the cores independently. This is determined by the nature of the program which is loaded into the PRU's instruction memory. A device may be de-initialized and another loaded or two different devices can be run simultaneously on the two cores.
It's also possible, as in our case, to implement a single device on both the PRU's resulting in improved load sharing.

---
 drivers/mfd/Kconfig            |   10 +
 drivers/mfd/Makefile           |    1 +
 drivers/mfd/pruss.c            |  513 ++++++++++++++++++++++++++++++++++++++++
 include/linux/mfd/pruss.h      |  130 ++++++++++
 include/linux/mfd/pruss_core.h |  128 ++++++++++
 5 files changed, 782 insertions(+), 0 deletions(-)
 create mode 100644 drivers/mfd/pruss.c
 create mode 100644 include/linux/mfd/pruss.h
 create mode 100644 include/linux/mfd/pruss_core.h
drivers/mfd/Kconfig +10 -0
index 0284c53..41479e4 100644
@@ -92,6 +92,16 @@ config MFD_TI_SSP
 	  To compile this driver as a module, choose M here: the
 	  module will be called ti-ssp.
 
+config MFD_DA8XX_PRUSS
+	tristate "Texas Instruments DA8XX PRUSS support"
+	depends on ARCH_DAVINCI_DA850
+	select MFD_CORE
+	help
+	  This driver provides support API for the programmable
+	  realtime unit (PRU) present on TI's da8xx processors. It
+	  provides basic read, write, config, enable, disable
+	  routines to facilitate devices emulated on it.
+
 config HTC_EGPIO
 	bool "HTC EGPIO support"
 	depends on GENERIC_HARDIRQS && GPIOLIB && ARM
drivers/mfd/Makefile +1 -0
index c56b6c7..8015dea 100644
@@ -13,6 +13,7 @@ obj-$(CONFIG_HTC_PASIC3)	+= htc-pasic3.o
 obj-$(CONFIG_HTC_I2CPLD)	+= htc-i2cpld.o
 
 obj-$(CONFIG_MFD_DAVINCI_VOICECODEC)	+= davinci_voicecodec.o
+obj-$(CONFIG_MFD_DA8XX_PRUSS)	+= pruss.o
 obj-$(CONFIG_MFD_DM355EVM_MSP)	+= dm355evm_msp.o
 obj-$(CONFIG_MFD_TI_SSP)	+= ti-ssp.o
 
drivers/mfd/pruss.c new file +513 -0

513 lines not on this page · raw message

include/linux/mfd/pruss.h new file +130 -0

130 lines not on this page · raw message

include/linux/mfd/pruss_core.h new file +128 -0

128 lines not on this page · raw message

Signature · 1 line
1.7.2.3
#2 lore raw

Re: [PATCH v4 01/11] mfd: add pruss mfd driver.

Quoted 91 lines · Subhasish Ghosh

This patch adds the pruss MFD driver and associated include files. For details regarding the PRUSS please refer the folowing link:
http://processors.wiki.ti.com/index.php/Programmable_Realtime_Unit_Subsystem

The rational behind the MFD driver being the fact that multiple devices can be implemented on the cores independently. This is determined by the nature of the program which is loaded into the PRU's instruction memory. A device may be de-initialized and another loaded or two different devices can be run simultaneously on the two cores.
It's also possible, as in our case, to implement a single device on both the PRU's resulting in improved load sharing.

---
 drivers/mfd/Kconfig            |   10 +
 drivers/mfd/Makefile           |    1 +
 drivers/mfd/pruss.c            |  513 ++++++++++++++++++++++++++++++++++++++++
 include/linux/mfd/pruss.h      |  130 ++++++++++
 include/linux/mfd/pruss_core.h |  128 ++++++++++
 5 files changed, 782 insertions(+), 0 deletions(-)
 create mode 100644 drivers/mfd/pruss.c
 create mode 100644 include/linux/mfd/pruss.h
 create mode 100644 include/linux/mfd/pruss_core.h
drivers/mfd/Kconfig +10 -0
index 0284c53..41479e4 100644
@@ -92,6 +92,16 @@ config MFD_TI_SSP
 	  To compile this driver as a module, choose M here: the
 	  module will be called ti-ssp.
 
+config MFD_DA8XX_PRUSS
+	tristate "Texas Instruments DA8XX PRUSS support"
+	depends on ARCH_DAVINCI_DA850
+	select MFD_CORE
+	help
+	  This driver provides support API for the programmable
+	  realtime unit (PRU) present on TI's da8xx processors. It
+	  provides basic read, write, config, enable, disable
+	  routines to facilitate devices emulated on it.
+
 config HTC_EGPIO
 	bool "HTC EGPIO support"
 	depends on GENERIC_HARDIRQS && GPIOLIB && ARM
drivers/mfd/Makefile +1 -0
index c56b6c7..8015dea 100644
@@ -13,6 +13,7 @@ obj-$(CONFIG_HTC_PASIC3)	+= htc-pasic3.o
 obj-$(CONFIG_HTC_I2CPLD)	+= htc-i2cpld.o
 
 obj-$(CONFIG_MFD_DAVINCI_VOICECODEC)	+= davinci_voicecodec.o
+obj-$(CONFIG_MFD_DA8XX_PRUSS)	+= pruss.o
 obj-$(CONFIG_MFD_DM355EVM_MSP)	+= dm355evm_msp.o
 obj-$(CONFIG_MFD_TI_SSP)	+= ti-ssp.o
 
drivers/mfd/pruss.c new file +28 -0
new file mode 100644
index 0000000..6836d5a
@@ -0,0 +1,513 @@
+/*
+ * Copyright (C) 2010, 2011 Texas Instruments Incorporated
+ *
+ * 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
+ * Free Software Foundation version 2.
+ *
+ * This program is distributed "as is" WITHOUT ANY WARRANTY of any kind,
+ * whether express or implied; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ */
+
+#include <linux/init.h>
+#include <linux/kernel.h>
+#include <linux/types.h>
+#include <linux/module.h>
+#include <linux/bitops.h>
+#include <linux/interrupt.h>
+#include <linux/spinlock.h>
+#include <linux/errno.h>
+#include <linux/platform_device.h>
+#include <linux/clk.h>
+#include <linux/mfd/pruss.h>
+#include <linux/mfd/core.h>
+#include <linux/io.h>
+#include <linux/slab.h>
+#include <linux/err.h>

drivers/mfd/pruss.c line 38

Quoted 10 lines
drivers/mfd/pruss.c new file +10 -0
+
+struct pruss_priv {
+	struct device *dev;
+	spinlock_t lock;
+	struct resource *res;
+	struct clk *clk;
+	void __iomem *ioaddr;
+};
+
+s32 pruss_disable(struct device *dev, u8 pruss_num)

make it a int function

Quoted 28 lines
drivers/mfd/pruss.c new file +28 -0
+{
+	struct pruss_priv *pruss = dev_get_drvdata(dev->parent);
+	struct prusscore_regs __iomem *h_pruss;
+	struct pruss_map __iomem *pruss_mmap = pruss->ioaddr;
+	u32 temp_reg;
+
+	if ((pruss_num != PRUCORE_0) && (pruss_num != PRUCORE_1))
+		return -EINVAL;
+
+	spin_lock(&pruss->lock);
+
+	/* pruss deinit */
+	iowrite32(0xFFFFFFFF, &pruss_mmap->intc.statclrint[pruss_num]);
+
+	/* Disable PRU */
+	h_pruss = &pruss_mmap->core[pruss_num];
+	temp_reg = ioread32(&h_pruss->control);
+	temp_reg = (temp_reg &
+			~PRUCORE_CONTROL_COUNTENABLE_MASK) |
+			((PRUCORE_CONTROL_COUNTENABLE_DISABLE <<
+			PRUCORE_CONTROL_COUNTENABLE_SHIFT) &
+			PRUCORE_CONTROL_COUNTENABLE_MASK);
+	iowrite32(temp_reg, &h_pruss->control);
+
+	temp_reg = ioread32(&h_pruss->control);
+	temp_reg = (temp_reg &
+		~PRUCORE_CONTROL_ENABLE_MASK) |
+		((PRUCORE_CONTROL_ENABLE_DISABLE <<

drivers/mfd/pruss.c line 76

Quoted 10 lines
drivers/mfd/pruss.c new file +10 -0
+		PRUCORE_CONTROL_ENABLE_SHIFT) &
+		PRUCORE_CONTROL_ENABLE_MASK);
+	iowrite32(temp_reg, &h_pruss->control);
+
+	/* Reset PRU */
+	iowrite32(PRUCORE_CONTROL_RESETVAL,
+				&h_pruss->control);
+	spin_unlock(&pruss->lock);
+
+	return 0;

make it a void function?

drivers/mfd/pruss.c line 80

Quoted 4 lines
drivers/mfd/pruss.c new file +4 -0
+}
+EXPORT_SYMBOL_GPL(pruss_disable);
+
+s32 pruss_enable(struct device *dev, u8 pruss_num)

int?

Quoted 4 lines
drivers/mfd/pruss.c new file +4 -0
+{
+	struct pruss_priv *pruss = dev_get_drvdata(dev->parent);
+	struct prusscore_regs __iomem *h_pruss;
+	struct pruss_map __iomem *pruss_mmap = pruss->ioaddr;

drivers/mfd/pruss.c line 94

Quoted 10 lines
drivers/mfd/pruss.c new file +10 -0
+	u32 i;
+
+	if ((pruss_num != PRUCORE_0) && (pruss_num != PRUCORE_1))
+		return -EINVAL;
+
+	h_pruss = &pruss_mmap->core[pruss_num];
+
+	/* Reset PRU  */
+	spin_lock(&pruss->lock);
+	iowrite32(PRUCORE_CONTROL_RESETVAL, &h_pruss->control);

no need to lock the ram reset below?

drivers/mfd/pruss.c line 103

Quoted 9 lines
drivers/mfd/pruss.c new file +9 -0
+	spin_unlock(&pruss->lock);
+
+	/* Reset any garbage in the ram */
+	if (pruss_num == PRUCORE_0)
+		for (i = 0; i < PRUSS_PRU0_RAM_SZ; i++)
+			iowrite32(0x0, &pruss_mmap->dram0[i]);
+	else if (pruss_num == PRUCORE_1)
+		for (i = 0; i < PRUSS_PRU1_RAM_SZ; i++)
+			iowrite32(0x0, &pruss_mmap->dram1[i]);

if you make a array for these

+struct pruss_map {
+ u8 dram0[512];
+ u8 res1[7680];

+ u8 dram1[512];
+ u8 res2[7680];
..}

you don't need the if..else..

Quoted 9 lines
drivers/mfd/pruss.c new file +9 -0
+
+	return 0;
+}
+EXPORT_SYMBOL_GPL(pruss_enable);
+
+/* Load the specified PRU with code */
+s32 pruss_load(struct device *dev, u8 pruss_num,
+			u32 *pruss_code, u32 code_size_in_words)
+{

drivers/mfd/pruss.c line 122

Quoted 10 lines
drivers/mfd/pruss.c new file +10 -0
+	struct pruss_priv *pruss = dev_get_drvdata(dev->parent);
+	struct pruss_map __iomem *pruss_mmap = pruss->ioaddr;
+	u32 __iomem *pruss_iram;
+	u32 i;
+
+	if (pruss_num == PRUCORE_0)
+		pruss_iram = (u32 __iomem *)&pruss_mmap->iram0;
+	else if (pruss_num == PRUCORE_1)
+		pruss_iram = (u32 __iomem *)&pruss_mmap->iram1;
+	else

same here

Quoted 6 lines
drivers/mfd/pruss.c new file +6 -0
+		return -EINVAL;
+
+	pruss_enable(dev, pruss_num);
+
+	spin_lock(&pruss->lock);
+	/* Copy dMAX code to its instruction RAM  */

drivers/mfd/pruss.c line 138

Quoted 10 lines
drivers/mfd/pruss.c new file +10 -0
+	for (i = 0; i < code_size_in_words; i++)
+		iowrite32(pruss_code[i], (pruss_iram + i));
+
+	spin_unlock(&pruss->lock);
+
+	return 0;
+}
+EXPORT_SYMBOL_GPL(pruss_load);
+
+s32 pruss_run(struct device *dev, u8 pruss_num)

int?

Quoted 43 lines
drivers/mfd/pruss.c new file +43 -0
+{
+	struct pruss_priv *pruss = dev_get_drvdata(dev->parent);
+	struct prusscore_regs __iomem *h_pruss;
+	struct pruss_map __iomem *pruss_mmap = pruss->ioaddr;
+	u32 temp_reg;
+
+	if ((pruss_num != PRUCORE_0) && (pruss_num != PRUCORE_1))
+		return -EINVAL;
+
+	h_pruss = &pruss_mmap->core[pruss_num];
+
+	/* Enable dMAX, let it execute the code we just copied */
+	spin_lock(&pruss->lock);
+	temp_reg = ioread32(&h_pruss->control);
+	temp_reg = (temp_reg &
+			~PRUCORE_CONTROL_COUNTENABLE_MASK) |
+			((PRUCORE_CONTROL_COUNTENABLE_ENABLE <<
+			PRUCORE_CONTROL_COUNTENABLE_SHIFT) &
+			PRUCORE_CONTROL_COUNTENABLE_MASK);
+	iowrite32(temp_reg, &h_pruss->control);
+
+	temp_reg = ioread32(&h_pruss->control);
+	temp_reg = (temp_reg &
+			~PRUCORE_CONTROL_ENABLE_MASK) |
+			((PRUCORE_CONTROL_ENABLE_ENABLE <<
+			PRUCORE_CONTROL_ENABLE_SHIFT) &
+			PRUCORE_CONTROL_ENABLE_MASK);
+	iowrite32(temp_reg, &h_pruss->control);
+	spin_unlock(&pruss->lock);
+
+	return 0;
+}
+EXPORT_SYMBOL_GPL(pruss_run);
+
+s32 pruss_wait_for_halt(struct device *dev, u8 pruss_num, u32 timeout)
+{
+	struct pruss_priv *pruss = dev_get_drvdata(dev->parent);
+	struct prusscore_regs __iomem *h_pruss;
+	struct pruss_map __iomem *pruss_mmap = pruss->ioaddr;
+	u32 temp_reg;
+	u32 cnt = timeout;
+
+	if ((pruss_num != PRUCORE_0) && (pruss_num != PRUCORE_1))

drivers/mfd/pruss.c line 191

Quoted 10 lines
drivers/mfd/pruss.c new file +10 -0
+		return -EINVAL;
+
+	h_pruss = &pruss_mmap->core[pruss_num];
+
+	while (cnt--) {
+		temp_reg = ioread32(&h_pruss->control);
+		if (((temp_reg & PRUCORE_CONTROL_RUNSTATE_MASK) >>
+				PRUCORE_CONTROL_RUNSTATE_SHIFT) ==
+				PRUCORE_CONTROL_RUNSTATE_HALT)
+			break;

how long might this take? what about some delay, sleep, or reschedule?

drivers/mfd/pruss.c line 203

Quoted 12 lines
drivers/mfd/pruss.c new file +12 -0
+	}
+	if (!cnt)
+		return -EBUSY;
+
+	return 0;
+}
+EXPORT_SYMBOL_GPL(pruss_wait_for_halt);
+
+s32 pruss_writeb(struct device *dev, u32 offset, u8 pdatatowrite)
+{
+	struct pruss_priv *pruss = dev_get_drvdata(dev->parent);
+	void __iomem *paddresstowrite;

we usually don't use "p" variable names for pointers

drivers/mfd/pruss.c line 212

Quoted 9 lines
drivers/mfd/pruss.c new file +9 -0
+
+	paddresstowrite = pruss->ioaddr + offset;
+	iowrite8(pdatatowrite, paddresstowrite);
+
+	return 0;
+}
+EXPORT_SYMBOL_GPL(pruss_writeb);
+
+s32 pruss_rmwb(struct device *dev, u32 offset, u8 mask, u8 val)

void function?

Quoted 9 lines
drivers/mfd/pruss.c new file +9 -0
+{
+	struct pruss_priv *pruss = dev_get_drvdata(dev->parent);
+	void __iomem *paddress;
+	u32 preg_data;
+
+	paddress = pruss->ioaddr + offset;
+
+	spin_lock(&pruss->lock);
+	preg_data = ioread8(paddress);

drivers/mfd/pruss.c line 231

Quoted 10 lines
drivers/mfd/pruss.c new file +10 -0
+	preg_data &= ~mask;
+	preg_data |= val;
+	iowrite8(preg_data, paddress);
+	spin_unlock(&pruss->lock);
+
+	return 0;
+}
+EXPORT_SYMBOL_GPL(pruss_rmwb);
+
+s32 pruss_readb(struct device *dev, u32 offset, u8 *pdatatoread)

void?

drivers/mfd/pruss.c line 244

Quoted 13 lines
drivers/mfd/pruss.c new file +13 -0
+{
+	struct pruss_priv *pruss = dev_get_drvdata(dev->parent);
+	void __iomem *paddresstoread;
+
+	paddresstoread = pruss->ioaddr + offset ;
+	*pdatatoread = ioread8(paddresstoread);
+
+	return 0;
+}
+EXPORT_SYMBOL_GPL(pruss_readb);
+
+s32 pruss_readb_multi(struct device *dev, u32 offset,
+		u8 *pdatatoread, u16 bytestoread)

viod?

drivers/mfd/pruss.c line 248

Quoted 4 lines
drivers/mfd/pruss.c new file +4 -0
+{
+	struct pruss_priv *pruss = dev_get_drvdata(dev->parent);
+	u8 __iomem *paddresstoread;
+	u16 i;

int?

drivers/mfd/pruss.c line 260

Quoted 12 lines
drivers/mfd/pruss.c new file +12 -0
+
+	paddresstoread = pruss->ioaddr + offset;
+
+	for (i = 0; i < bytestoread; i++)
+		*pdatatoread++ = ioread8(paddresstoread++);
+
+	return 0;
+}
+EXPORT_SYMBOL_GPL(pruss_readb_multi);
+
+s32 pruss_writel(struct device *dev, u32 offset,
+		u32 pdatatowrite)

void?

drivers/mfd/pruss.c line 273

Quoted 13 lines
drivers/mfd/pruss.c new file +13 -0
+{
+	struct pruss_priv *pruss = dev_get_drvdata(dev->parent);
+	void __iomem *paddresstowrite;
+
+	paddresstowrite = pruss->ioaddr + offset;
+	iowrite32(pdatatowrite, paddresstowrite);
+
+	return 0;
+}
+EXPORT_SYMBOL_GPL(pruss_writel);
+
+s32 pruss_writel_multi(struct device *dev, u32 offset,
+		u32 *pdatatowrite, u16 wordstowrite)

void?

drivers/mfd/pruss.c line 282

Quoted 9 lines
drivers/mfd/pruss.c new file +9 -0
+{
+	struct pruss_priv *pruss = dev_get_drvdata(dev->parent);
+	u32 __iomem *paddresstowrite;
+	u16 i;
+
+	paddresstowrite = pruss->ioaddr + offset;
+
+	for (i = 0; i < wordstowrite; i++)
+		iowrite32(*pdatatowrite++, paddresstowrite++);

memcopy_to_iomem?

drivers/mfd/pruss.c line 288

Quoted 6 lines
drivers/mfd/pruss.c new file +6 -0
+
+	return 0;
+}
+EXPORT_SYMBOL_GPL(pruss_writel_multi);
+
+s32 pruss_rmwl(struct device *dev, u32 offset, u32 mask, u32 val)

void?

Quoted 9 lines
drivers/mfd/pruss.c new file +9 -0
+{
+	struct pruss_priv *pruss = dev_get_drvdata(dev->parent);
+	void __iomem *paddress;
+	u32 preg_data;
+
+	paddress = pruss->ioaddr + offset;
+
+	spin_lock(&pruss->lock);
+	preg_data = ioread32(paddress);

drivers/mfd/pruss.c line 307

Quoted 10 lines
drivers/mfd/pruss.c new file +10 -0
+	preg_data &= ~mask;
+	preg_data |= val;
+	iowrite32(preg_data, paddress);
+	spin_unlock(&pruss->lock);
+
+	return 0;
+}
+EXPORT_SYMBOL_GPL(pruss_rmwl);
+
+s32 pruss_readl(struct device *dev, u32 offset, u32 *pdatatoread)

void? or return the read value

Quoted 466 lines
drivers/mfd/pruss.c new file +206 -0
+{
+	struct pruss_priv *pruss = dev_get_drvdata(dev->parent);
+	void __iomem *paddresstoread;
+
+	paddresstoread = pruss->ioaddr + offset;
+	*pdatatoread = ioread32(paddresstoread);
+
+	return 0;
+}
+EXPORT_SYMBOL_GPL(pruss_readl);
+
+s32 pruss_readl_multi(struct device *dev, u32 offset,
+		u32 *pdatatoread, u16 wordstoread)
+{
+	struct pruss_priv *pruss = dev_get_drvdata(dev->parent);
+	u32 __iomem *paddresstoread;
+	u16 i;
+
+	paddresstoread = pruss->ioaddr + offset;
+	for (i = 0; i < wordstoread; i++)
+		*pdatatoread++ = ioread32(paddresstoread++);
+
+	return 0;
+}
+EXPORT_SYMBOL_GPL(pruss_readl_multi);
+
+s32 pruss_writew(struct device *dev, u32 offset, u16 pdatatowrite)
+{
+	struct pruss_priv *pruss = dev_get_drvdata(dev->parent);
+	void __iomem *paddresstowrite;
+
+	paddresstowrite = pruss->ioaddr + offset;
+	iowrite16(pdatatowrite, paddresstowrite);
+
+	return 0;
+}
+EXPORT_SYMBOL_GPL(pruss_writew);
+
+s32 pruss_rmww(struct device *dev, u32 offset, u16 mask, u16 val)
+{
+	struct pruss_priv *pruss = dev_get_drvdata(dev->parent);
+	void __iomem *paddress;
+	u32 preg_data;
+
+	paddress = pruss->ioaddr + offset;
+
+	spin_lock(&pruss->lock);
+	preg_data = ioread16(paddress);
+	preg_data &= ~mask;
+	preg_data |= val;
+	iowrite16(preg_data, paddress);
+	spin_unlock(&pruss->lock);
+
+	return 0;
+}
+EXPORT_SYMBOL_GPL(pruss_rmww);
+
+s32 pruss_readw(struct device *dev, u32 offset, u16 *pdatatoread)
+{
+	struct pruss_priv *pruss = dev_get_drvdata(dev->parent);
+	void __iomem *paddresstoread;
+
+	paddresstoread = pruss->ioaddr + offset;
+	*pdatatoread = ioread16(paddresstoread);
+
+	return 0;
+}
+EXPORT_SYMBOL_GPL(pruss_readw);
+
+s32 pruss_idx_writel(struct device *dev, u32 offset, u32 value)
+{
+	struct pruss_priv *pruss = dev_get_drvdata(dev->parent);
+	void __iomem *paddresstowrite;
+
+	paddresstowrite = pruss->ioaddr + offset;
+	iowrite32(value, paddresstowrite);
+
+	return 0;
+}
+EXPORT_SYMBOL_GPL(pruss_idx_writel);
+
+static int pruss_mfd_add_devices(struct platform_device *pdev)
+{
+	struct device *dev = &pdev->dev;
+	struct mfd_cell *cell = pdev->dev.platform_data;
+	s32 err, i, num_devices = 0;
+
+	for (i = 0; cell[i].name; i++) {
+		err = mfd_add_devices(dev, 0, &cell[i], 1, NULL, 0);
+		if (err) {
+			dev_err(dev, "cannot add mfd cell: %s\n",
+						cell[i].name);
+			continue;
+		}
+		num_devices++;
+		dev_info(dev, "mfd: added %s device\n", cell[i].name);
+	}
+
+	return num_devices;
+}
+
+static int __devinit pruss_probe(struct platform_device *pdev)
+{
+	struct pruss_priv *pruss_dev = NULL;
+	s32 err;
+
+	pruss_dev = kzalloc(sizeof(struct pruss_priv), GFP_KERNEL);
+	if (!pruss_dev)
+		return -ENOMEM;
+
+	pruss_dev->res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+	if (!pruss_dev->res) {
+		dev_err(&pdev->dev,
+		"unable to get pruss memory resources!\n");
+		err = -ENODEV;
+		goto probe_exit_kfree;
+	}
+
+	if (!request_mem_region(pruss_dev->res->start,
+		resource_size(pruss_dev->res), dev_name(&pdev->dev))) {
+		dev_err(&pdev->dev, "pruss memory region already claimed!\n");
+		err = -EBUSY;
+		goto probe_exit_kfree;
+	}
+
+	pruss_dev->ioaddr = ioremap(pruss_dev->res->start,
+	resource_size(pruss_dev->res));
+	if (!pruss_dev->ioaddr) {
+		dev_err(&pdev->dev, "ioremap failed\n");
+		err = -ENOMEM;
+		goto probe_exit_free_region;
+	}
+
+	pruss_dev->clk = clk_get(NULL, "pruss");
+	if (IS_ERR(pruss_dev->clk)) {
+		dev_err(&pdev->dev, "no clock available: pruss\n");
+		err = -ENODEV;
+		pruss_dev->clk = NULL;
+		goto probe_exit_iounmap;
+	}
+	spin_lock_init(&pruss_dev->lock);
+
+	clk_enable(pruss_dev->clk);
+
+	err = pruss_mfd_add_devices(pdev);
+	if (!err)
+		goto probe_exit_clock;
+
+	platform_set_drvdata(pdev, pruss_dev);
+	pruss_dev->dev = &pdev->dev;
+	return 0;
+
+probe_exit_clock:
+	clk_put(pruss_dev->clk);
+	clk_disable(pruss_dev->clk);
+probe_exit_iounmap:
+	iounmap(pruss_dev->ioaddr);
+probe_exit_free_region:
+	release_mem_region(pruss_dev->res->start,
+			resource_size(pruss_dev->res));
+probe_exit_kfree:
+	kfree(pruss_dev);
+	return err;
+}
+
+static int __devexit pruss_remove(struct platform_device *pdev)
+{
+	struct device *dev = &pdev->dev;
+	struct pruss_priv *pruss = dev_get_drvdata(dev);
+
+	mfd_remove_devices(dev);
+	pruss_disable(dev, PRUCORE_0);
+	pruss_disable(dev, PRUCORE_1);
+	clk_disable(pruss->clk);
+	clk_put(pruss->clk);
+	iounmap(pruss->ioaddr);
+	release_mem_region(pruss->res->start, resource_size(pruss->res));
+	kfree(pruss);
+	dev_set_drvdata(dev, NULL);
+	return 0;
+}
+
+static struct platform_driver pruss_driver = {
+	.probe	= pruss_probe,
+	.remove	= __devexit_p(pruss_remove),
+	.driver	= {
+		.name	= "pruss_mfd",
+		.owner	= THIS_MODULE,
+	}
+};
+
+static int __init pruss_init(void)
+{
+	return platform_driver_register(&pruss_driver);
+}
+module_init(pruss_init);
+
+static void __exit pruss_exit(void)
+{
+	platform_driver_unregister(&pruss_driver);
+}
+module_exit(pruss_exit);
+
+MODULE_DESCRIPTION("Programmable Realtime Unit (PRU) Driver");
+MODULE_AUTHOR("Subhasish Ghosh");
+MODULE_LICENSE("GPL");
include/linux/mfd/pruss.h new file +130 -0
new file mode 100644
index 0000000..8ef25b3
@@ -0,0 +1,130 @@
+/*
+ * Copyright (C) 2010, 2011 Texas Instruments Incorporated
+ * Author: Jitendra Kumar <[email protected]>
+ *
+ * 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
+ * Free Software Foundation version 2.
+ *
+ * This program is distributed "as is" WITHOUT ANY WARRANTY of any kind,
+ * whether express or implied; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ */
+
+#ifndef _PRUSS_H_
+#define _PRUSS_H_
+
+#include <linux/types.h>
+#include <linux/platform_device.h>
+#include "pruss_core.h"
+
+#define PRUSS_NUM0			PRUCORE_0
+#define PRUSS_NUM1			PRUCORE_1
+
+#define PRUSS_PRU0_RAM_SZ		512
+#define PRUSS_PRU1_RAM_SZ		512
+#define PRUSS_PRU0_BASE_ADDRESS		0
+#define PRUSS_PRU1_BASE_ADDRESS		0x2000
+#define PRUSS_INTC_BASE_ADDRESS		(PRUSS_PRU0_BASE_ADDRESS + 0x4000)
+#define PRUSS_INTC_GLBLEN		(PRUSS_INTC_BASE_ADDRESS + 0x10)
+#define PRUSS_INTC_GLBLNSTLVL		(PRUSS_INTC_BASE_ADDRESS + 0x1C)
+#define PRUSS_INTC_STATIDXSET		(PRUSS_INTC_BASE_ADDRESS + 0x20)
+#define PRUSS_INTC_STATIDXCLR		(PRUSS_INTC_BASE_ADDRESS + 0x24)
+#define PRUSS_INTC_ENIDXSET		(PRUSS_INTC_BASE_ADDRESS + 0x28)
+#define PRUSS_INTC_ENIDXCLR		(PRUSS_INTC_BASE_ADDRESS + 0x2C)
+#define PRUSS_INTC_HSTINTENIDXSET	(PRUSS_INTC_BASE_ADDRESS + 0x34)
+#define PRUSS_INTC_HSTINTENIDXCLR	(PRUSS_INTC_BASE_ADDRESS + 0x38)
+#define PRUSS_INTC_GLBLPRIIDX		(PRUSS_INTC_BASE_ADDRESS + 0x80)
+#define PRUSS_INTC_STATSETINT0		(PRUSS_INTC_BASE_ADDRESS + 0x200)
+#define PRUSS_INTC_STATSETINT1		(PRUSS_INTC_BASE_ADDRESS + 0x204)
+#define PRUSS_INTC_STATCLRINT0		(PRUSS_INTC_BASE_ADDRESS + 0x280)
+#define PRUSS_INTC_STATCLRINT1		(PRUSS_INTC_BASE_ADDRESS + 0x284)
+#define PRUSS_INTC_ENABLESET0		(PRUSS_INTC_BASE_ADDRESS + 0x300)
+#define PRUSS_INTC_ENABLESET1		(PRUSS_INTC_BASE_ADDRESS + 0x304)
+#define PRUSS_INTC_ENABLECLR0		(PRUSS_INTC_BASE_ADDRESS + 0x380)
+#define PRUSS_INTC_ENABLECLR1		(PRUSS_INTC_BASE_ADDRESS + 0x384)
+#define PRUSS_INTC_CHANMAP0		(PRUSS_INTC_BASE_ADDRESS + 0x400)
+#define PRUSS_INTC_CHANMAP1		(PRUSS_INTC_BASE_ADDRESS + 0x404)
+#define PRUSS_INTC_CHANMAP2		(PRUSS_INTC_BASE_ADDRESS + 0x408)
+#define PRUSS_INTC_CHANMAP3		(PRUSS_INTC_BASE_ADDRESS + 0x40C)
+#define PRUSS_INTC_CHANMAP4		(PRUSS_INTC_BASE_ADDRESS + 0x410)
+#define PRUSS_INTC_CHANMAP5		(PRUSS_INTC_BASE_ADDRESS + 0x414)
+#define PRUSS_INTC_CHANMAP6		(PRUSS_INTC_BASE_ADDRESS + 0x418)
+#define PRUSS_INTC_CHANMAP7		(PRUSS_INTC_BASE_ADDRESS + 0x41C)
+#define PRUSS_INTC_CHANMAP8		(PRUSS_INTC_BASE_ADDRESS + 0x420)
+#define PRUSS_INTC_CHANMAP9		(PRUSS_INTC_BASE_ADDRESS + 0x424)
+#define PRUSS_INTC_CHANMAP10		(PRUSS_INTC_BASE_ADDRESS + 0x428)
+#define PRUSS_INTC_CHANMAP11		(PRUSS_INTC_BASE_ADDRESS + 0x42C)
+#define PRUSS_INTC_CHANMAP12		(PRUSS_INTC_BASE_ADDRESS + 0x430)
+#define PRUSS_INTC_CHANMAP13		(PRUSS_INTC_BASE_ADDRESS + 0x434)
+#define PRUSS_INTC_CHANMAP14		(PRUSS_INTC_BASE_ADDRESS + 0x438)
+#define PRUSS_INTC_CHANMAP15		(PRUSS_INTC_BASE_ADDRESS + 0x43C)
+#define PRUSS_INTC_HOSTMAP0		(PRUSS_INTC_BASE_ADDRESS + 0x800)
+#define PRUSS_INTC_HOSTMAP1		(PRUSS_INTC_BASE_ADDRESS + 0x804)
+#define PRUSS_INTC_HOSTMAP2		(PRUSS_INTC_BASE_ADDRESS + 0x808)
+#define PRUSS_INTC_POLARITY0		(PRUSS_INTC_BASE_ADDRESS + 0xD00)
+#define PRUSS_INTC_POLARITY1		(PRUSS_INTC_BASE_ADDRESS + 0xD04)
+#define PRUSS_INTC_TYPE0		(PRUSS_INTC_BASE_ADDRESS + 0xD80)
+#define PRUSS_INTC_TYPE1		(PRUSS_INTC_BASE_ADDRESS + 0xD84)
+#define PRUSS_INTC_HOSTINTEN		(PRUSS_INTC_BASE_ADDRESS + 0x1500)
+#define PRUSS_INTC_HOSTINTLVL_MAX	9
+
+#define PRU_INTC_HOSTMAP0_CHAN		(0x03020100)
+#define PRU_INTC_HOSTMAP1_CHAN		(0x07060504)
+#define PRU_INTC_HOSTMAP2_CHAN		(0x00000908)
+
+#define PRU_INTC_CHANMAP7_SYS_EVT31	(0x00000000)
+#define PRU_INTC_CHANMAP8_FULL		(0x02020100)
+#define PRU_INTC_CHANMAP9_FULL		(0x04040303)
+#define PRU_INTC_CHANMAP10_FULL		(0x06060505)
+#define PRU_INTC_CHANMAP11_FULL		(0x08080707)
+#define PRU_INTC_CHANMAP12_FULL		(0x00010909)
+#define PRU_INTC_CHANMAP8_HALF		(0x03020100)
+#define PRU_INTC_CHANMAP9_HALF		(0x07060504)
+#define PRU_INTC_CHANMAP10_HALF		(0x03020908)
+#define PRU_INTC_CHANMAP11_HALF		(0x07060504)
+#define PRU_INTC_CHANMAP12_HALF		(0x00010908)
+#define PRU_INTC_REGMAP_MASK		(0xFFFFFFFF)
+
+s32 pruss_enable(struct device *dev, u8 pruss_num);
+
+s32 pruss_load(struct device *dev, u8 pruss_num,
+	u32 *pruss_code, u32 code_size_in_words);
+
+s32 pruss_run(struct device *dev, u8 pruss_num);
+
+s32 pruss_wait_for_halt(struct device *dev, u8 pruss_num, u32 timeout);
+
+s32 pruss_disable(struct device *dev, u8 pruss_num);
+
+s32 pruss_writeb(struct device *dev, u32 offset, u8 pdatatowrite);
+
+s32 pruss_rmwb(struct device *dev, u32 offset, u8 mask, u8 val);
+
+s32 pruss_readb(struct device *dev, u32 offset, u8 *pdatatoread);
+
+s32 pruss_readb_multi(struct device *dev, u32 offset,
+		u8 *pdatatoread, u16 bytestoread);
+
+s32 pruss_readl(struct device *dev, u32 offset, u32 *pdatatoread);
+
+s32 pruss_readl_multi(struct device *dev, u32 offset,
+		u32 *pdatatoread, u16 wordstoread);
+
+s32 pruss_writel(struct device *dev, u32 offset, u32 pdatatowrite);
+
+s32 pruss_writel_multi(struct device *dev, u32 offset,
+		u32 *pdatatowrite, u16 wordstowrite);
+
+s32 pruss_rmwl(struct device *dev, u32 offset, u32 mask, u32 val);
+
+s32 pruss_idx_writel(struct device *dev, u32 offset, u32 value);
+
+s32 pruss_writew(struct device *dev, u32 offset, u16 datatowrite);
+
+s32 pruss_rmww(struct device *dev, u32 offset, u16 mask, u16 val);
+
+s32 pruss_readw(struct device *dev, u32 offset, u16 *pdatatoread);
+
+#endif	/* End _PRUSS_H_ */
include/linux/mfd/pruss_core.h new file +118 -0
new file mode 100644
index 0000000..48e2b99
@@ -0,0 +1,128 @@
+/*
+ * Copyright (C) 2010, 2011 Texas Instruments Incorporated
+ * Author: Jitendra Kumar <[email protected]>
+ *
+ * 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
+ * Free Software Foundation version 2.
+ *
+ * This program is distributed "as is" WITHOUT ANY WARRANTY of any kind,
+ * whether express or implied; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ */
+
+#ifndef _PRUSS_CORE_H_
+#define _PRUSS_CORE_H_
+
+#include <linux/types.h>
+
+#define PRUCORE_0		(0)
+#define PRUCORE_1		(1)
+
+#define PRUCORE_CONTROL_PCRESETVAL_MASK			(0xFFFF0000u)
+#define PRUCORE_CONTROL_PCRESETVAL_SHIFT		(0x00000010u)
+#define PRUCORE_CONTROL_PCRESETVAL_RESETVAL		(0x00000000u)
+#define PRUCORE_CONTROL_RUNSTATE_MASK			(0x00008000u)
+#define PRUCORE_CONTROL_RUNSTATE_SHIFT			(0x0000000Fu)
+#define PRUCORE_CONTROL_RUNSTATE_RESETVAL		(0x00000000u)
+#define PRUCORE_CONTROL_RUNSTATE_HALT			(0x00000000u)
+#define PRUCORE_CONTROL_RUNSTATE_RUN			(0x00000001u)
+#define PRUCORE_CONTROL_SINGLESTEP_MASK			(0x00000100u)
+#define PRUCORE_CONTROL_SINGLESTEP_SHIFT		(0x00000008u)
+#define PRUCORE_CONTROL_SINGLESTEP_RESETVAL		(0x00000000u)
+#define PRUCORE_CONTROL_SINGLESTEP_FREERUN		(0x00000000u)
+#define PRUCORE_CONTROL_SINGLESTEP_SINGLE		(0x00000001u)
+#define PRUCORE_CONTROL_COUNTENABLE_MASK		(0x00000008u)
+#define PRUCORE_CONTROL_COUNTENABLE_SHIFT		(0x00000003u)
+#define PRUCORE_CONTROL_COUNTENABLE_RESETVAL		(0x00000000u)
+#define PRUCORE_CONTROL_COUNTENABLE_DISABLE		(0x00000000u)
+#define PRUCORE_CONTROL_COUNTENABLE_ENABLE		(0x00000001u)
+#define PRUCORE_CONTROL_SLEEPING_MASK			(0x00000004u)
+#define PRUCORE_CONTROL_SLEEPING_SHIFT			(0x00000002u)
+#define PRUCORE_CONTROL_SLEEPING_RESETVAL		(0x00000000u)
+#define PRUCORE_CONTROL_SLEEPING_NOTASLEEP		(0x00000000u)
+#define PRUCORE_CONTROL_SLEEPING_ASLEEP			(0x00000001u)
+#define PRUCORE_CONTROL_ENABLE_MASK			(0x00000002u)
+#define PRUCORE_CONTROL_ENABLE_SHIFT			(0x00000001u)
+#define PRUCORE_CONTROL_ENABLE_RESETVAL			(0x00000000u)
+#define PRUCORE_CONTROL_ENABLE_DISABLE			(0x00000000u)
+#define PRUCORE_CONTROL_ENABLE_ENABLE			(0x00000001u)
+#define PRUCORE_CONTROL_SOFTRESET_MASK			(0x00000001u)
+#define PRUCORE_CONTROL_SOFTRESET_SHIFT			(0x00000000u)
+#define PRUCORE_CONTROL_SOFTRESET_RESETVAL		(0x00000000u)
+#define PRUCORE_CONTROL_SOFTRESET_RESET			(0x00000000u)
+#define PRUCORE_CONTROL_SOFTRESET_OUT_OF_RESET		(0x00000001u)
+#define PRUCORE_CONTROL_RESETVAL			(0x00000000u)
+
+struct prusscore_regs {
+	u32 control;
+	u32 status;
+	u32 wakeup;
+	u32 cyclecnt;
+	u32 stallcnt;
+	u8  rsvd0[12];
+	u32 contabblkidx0;
+	u32 contabblkidx1;
+	u32 contabproptr0;
+	u32 contabproptr1;
+	u8  rsvd1[976];
+	u32 intgpr[32];
+	u32 intcter[32];
+	u8  rsvd2[768];
+};
+
+struct pruss_intc_regs {
+	u32 revid;
+	u32 control;
+	u8  res1[8];
+	u32 glblen;
+	u8  res2[8];
+	u32 glblnstlvl;
+	u32 statidxset;
+	u32 statidxclr;
+	u32 enidxset;
+	u32 enidxclr;
+	u8  res3[4];
+	u32 hostintenidxset;
+	u32 hostintenidxclr;
+	u8  res4[68];
+	u32 glblpriidx;
+	u8  res5[380];
+	u32 statsetint[2];
+	u8  res6[120];
+	u32 statclrint[2];
+	u8  res7[120];
+	u32 enableset[2];
+	u8  res8[120];
+	u32 enableclr[2];
+	u8  res9[120];
+	u32 chanmap[16];
+	u8  res10[960];
+	u32 hostmap[2];
+	u8  res11[248];
+	u32 hostintpriidx[10];
+	u8  res12[984];
+	u32 polarity[2];
+	u8  res13[120];
+	u32 type[2];
+	u8  res14[888];
+	u32 hostintnstlvl[10];
+	u8  res15[984];
+	u32 hostinten;
+	u8  res16[6907];
+};
+
+struct pruss_map {
+	u8 dram0[512];
+	u8 res1[7680];

include/linux/mfd/pruss_core.h line 128

Quoted 10 lines
include/linux/mfd/pruss_core.h new file +10 -0
+	u8 dram1[512];
+	u8 res2[7680];
+	struct pruss_intc_regs intc;
+	struct prusscore_regs core[2];
+	u8 iram0[4096];
+	u8 res3[12288];
+	u8 iram1[4096];
+	u8 res4[12288];
+};
+#endif

regards, Marc

Signature · 12 lines
Pengutronix e.K.                  | Marc Kleine-Budde           |
Industrial Linux Solutions        | Phone: +49-231-2826-924     |
Vertretung West/Dortmund          | Fax:   +49-5121-206917-5555 |
Amtsgericht Hildesheim, HRA 2686  | http://www.pengutronix.de   |

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 262 bytes
Desc: OpenPGP digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20110422/15a6ff63/attachment-0001.sig>
#3 lore raw

Re: [PATCH v4 01/11] mfd: add pruss mfd driver.

Hi Mark,

- Is it ok to have u32 etc for __iomem cookie ?

Review

Quoted 2 lines
(quoted diff) +2 -0
+
+s32 pruss_disable(struct device *dev, u8 pruss_num)

make it a int function

SG -- Ok will do

drivers/mfd/pruss.c line 76

Quoted 7 lines
drivers/mfd/pruss.c new file +7 -0
+
+	/* Reset PRU */
+	iowrite32(PRUCORE_CONTROL_RESETVAL,
+				&h_pruss->control);
+	spin_unlock(&pruss->lock);
+
+	return 0;

make it a void function?

SG -- This should be int, in case of invalid pru num, we ret an error.

drivers/mfd/pruss.c line 80

Quoted 4 lines
drivers/mfd/pruss.c new file +4 -0
+}
+EXPORT_SYMBOL_GPL(pruss_disable);
+
+s32 pruss_enable(struct device *dev, u8 pruss_num)

int?

SG -- Ok will do

drivers/mfd/pruss.c line 94

Quoted 9 lines
drivers/mfd/pruss.c new file +9 -0
+
+	if ((pruss_num != PRUCORE_0) && (pruss_num != PRUCORE_1))
+		return -EINVAL;
+
+	h_pruss = &pruss_mmap->core[pruss_num];
+
+	/* Reset PRU  */
+	spin_lock(&pruss->lock);
+	iowrite32(PRUCORE_CONTROL_RESETVAL, &h_pruss->control);

no need to lock the ram reset below?

SG -- I don't think its required. We just reset the RAM during init and since each pru can only be attached to only one device, the access
will be already serialized based upon the pru num.

drivers/mfd/pruss.c line 103

Quoted 7 lines
drivers/mfd/pruss.c new file +7 -0
+	/* Reset any garbage in the ram */
+	if (pruss_num == PRUCORE_0)
+		for (i = 0; i < PRUSS_PRU0_RAM_SZ; i++)
+			iowrite32(0x0, &pruss_mmap->dram0[i]);
+	else if (pruss_num == PRUCORE_1)
+		for (i = 0; i < PRUSS_PRU1_RAM_SZ; i++)
+			iowrite32(0x0, &pruss_mmap->dram1[i]);

if you make a array for these
+struct pruss_map {
+ u8 dram0[512];
+ u8 res1[7680];

+ u8 dram1[512];
+ u8 res2[7680];
..}
you don't need the if..else..

SG - The dram/iram is not contiguous, there is a reserved space in between, how do I declare an array for it.

Quoted 4 lines
drivers/mfd/pruss.c new file +4 -0
+/* Load the specified PRU with code */
+s32 pruss_load(struct device *dev, u8 pruss_num,
+			u32 *pruss_code, u32 code_size_in_words)
+{

drivers/mfd/pruss.c line 122

Quoted 10 lines
drivers/mfd/pruss.c new file +10 -0
+	struct pruss_priv *pruss = dev_get_drvdata(dev->parent);
+	struct pruss_map __iomem *pruss_mmap = pruss->ioaddr;
+	u32 __iomem *pruss_iram;
+	u32 i;
+
+	if (pruss_num == PRUCORE_0)
+		pruss_iram = (u32 __iomem *)&pruss_mmap->iram0;
+	else if (pruss_num == PRUCORE_1)
+		pruss_iram = (u32 __iomem *)&pruss_mmap->iram1;
+	else

same here

SG - same here.

Quoted 1 line

+s32 pruss_run(struct device *dev, u8 pruss_num)

int?

SG - Ok, Will do.

drivers/mfd/pruss.c line 191

Quoted 6 lines
drivers/mfd/pruss.c new file +6 -0
+	while (cnt--) {
+		temp_reg = ioread32(&h_pruss->control);
+		if (((temp_reg & PRUCORE_CONTROL_RUNSTATE_MASK) >>
+				PRUCORE_CONTROL_RUNSTATE_SHIFT) ==
+				PRUCORE_CONTROL_RUNSTATE_HALT)
+			break;

how long might this take? what about some delay, sleep, or reschedule?

SG - This does not take more than 10 to 20 counts,

drivers/mfd/pruss.c line 203

Quoted 4 lines
drivers/mfd/pruss.c new file +4 -0
+s32 pruss_writeb(struct device *dev, u32 offset, u8 pdatatowrite)
+{
+	struct pruss_priv *pruss = dev_get_drvdata(dev->parent);
+	void __iomem *paddresstowrite;

we usually don't use "p" variable names for pointers

SG - Ok, will remove.

Quoted 1 line

+s32 pruss_rmwb(struct device *dev, u32 offset, u8 mask, u8 val)

void function?

SG - Ok, will do.

Review

Quoted 2 lines
(quoted diff) +2 -0
+
+s32 pruss_readb(struct device *dev, u32 offset, u8 *pdatatoread)

void?

SG - Ok, will do.

drivers/mfd/pruss.c line 244

Quoted 13 lines
drivers/mfd/pruss.c new file +13 -0
+{
+	struct pruss_priv *pruss = dev_get_drvdata(dev->parent);
+	void __iomem *paddresstoread;
+
+	paddresstoread = pruss->ioaddr + offset ;
+	*pdatatoread = ioread8(paddresstoread);
+
+	return 0;
+}
+EXPORT_SYMBOL_GPL(pruss_readb);
+
+s32 pruss_readb_multi(struct device *dev, u32 offset,
+		u8 *pdatatoread, u16 bytestoread)

viod?

SG - Ok, will do.

drivers/mfd/pruss.c line 248

Quoted 4 lines
drivers/mfd/pruss.c new file +4 -0
+{
+	struct pruss_priv *pruss = dev_get_drvdata(dev->parent);
+	u8 __iomem *paddresstoread;
+	u16 i;

int?

SG - Ok, will do.

drivers/mfd/pruss.c line 260

Quoted 6 lines
drivers/mfd/pruss.c new file +6 -0
+	return 0;
+}
+EXPORT_SYMBOL_GPL(pruss_readb_multi);
+
+s32 pruss_writel(struct device *dev, u32 offset,
+		u32 pdatatowrite)

void?

SG - Ok, will do.

drivers/mfd/pruss.c line 273

Quoted 6 lines
drivers/mfd/pruss.c new file +6 -0
+	return 0;
+}
+EXPORT_SYMBOL_GPL(pruss_writel);
+
+s32 pruss_writel_multi(struct device *dev, u32 offset,
+		u32 *pdatatowrite, u16 wordstowrite)

void?

SG - Ok, will do.

drivers/mfd/pruss.c line 282

Quoted 9 lines
drivers/mfd/pruss.c new file +9 -0
+{
+	struct pruss_priv *pruss = dev_get_drvdata(dev->parent);
+	u32 __iomem *paddresstowrite;
+	u16 i;
+
+	paddresstowrite = pruss->ioaddr + offset;
+
+	for (i = 0; i < wordstowrite; i++)
+		iowrite32(*pdatatowrite++, paddresstowrite++);

memcopy_to_iomem?

SG -- I did not understand, could you please elaborate.

drivers/mfd/pruss.c line 288

Quoted 2 lines
drivers/mfd/pruss.c new file +2 -0
+
+s32 pruss_rmwl(struct device *dev, u32 offset, u32 mask, u32 val)

void?

SG - Ok, will do.

drivers/mfd/pruss.c line 307

Quoted 4 lines
drivers/mfd/pruss.c new file +4 -0
+}
+EXPORT_SYMBOL_GPL(pruss_rmwl);
+
+s32 pruss_readl(struct device *dev, u32 offset, u32 *pdatatoread)

void? or return the read value

SG - Ok, will do.

#4 lore raw

Re: [PATCH v4 01/11] mfd: add pruss mfd driver.

Quoted 1 line · Subhasish Ghosh

Hi Mark,

I'm Marc.

Quoted 1 line

- Is it ok to have u32 etc for __iomem cookie ?

no - "void __iomem *" is "void __iomem *"

Quoted 15 lines
Quoted 1 line

+s32 pruss_disable(struct device *dev, u8 pruss_num)

make it a int function

SG -- Ok will do

drivers/mfd/pruss.c line 76

Quoted 7 lines
drivers/mfd/pruss.c new file +7 -0
+
+    /* Reset PRU */
+    iowrite32(PRUCORE_CONTROL_RESETVAL,
+                &h_pruss->control);
+    spin_unlock(&pruss->lock);
+
+    return 0;

make it a void function?

Quoted 1 line

SG -- This should be int, in case of invalid pru num, we ret an error.

Yes - Sorry.

Quoted 21 lines

drivers/mfd/pruss.c line 80

Quoted 4 lines
drivers/mfd/pruss.c new file +4 -0
+}
+EXPORT_SYMBOL_GPL(pruss_disable);
+
+s32 pruss_enable(struct device *dev, u8 pruss_num)

int?

SG -- Ok will do

drivers/mfd/pruss.c line 94

Quoted 9 lines
drivers/mfd/pruss.c new file +9 -0
+
+    if ((pruss_num != PRUCORE_0) && (pruss_num != PRUCORE_1))
+        return -EINVAL;
+
+    h_pruss = &pruss_mmap->core[pruss_num];
+
+    /* Reset PRU  */
+    spin_lock(&pruss->lock);
+    iowrite32(PRUCORE_CONTROL_RESETVAL, &h_pruss->control);

no need to lock the ram reset below?

Quoted 3 lines

SG -- I don't think its required. We just reset the RAM during init and since each pru can only be attached to only one device, the access
will be already serialized based upon the pru num.

In the other function you lock the access to the ram, but not here.

Quoted 17 lines

drivers/mfd/pruss.c line 103

Quoted 7 lines
drivers/mfd/pruss.c new file +7 -0
+    /* Reset any garbage in the ram */
+    if (pruss_num == PRUCORE_0)
+        for (i = 0; i < PRUSS_PRU0_RAM_SZ; i++)
+            iowrite32(0x0, &pruss_mmap->dram0[i]);
+    else if (pruss_num == PRUCORE_1)
+        for (i = 0; i < PRUSS_PRU1_RAM_SZ; i++)
+            iowrite32(0x0, &pruss_mmap->dram1[i]);

if you make a array for these

include/linux/mfd/pruss_core.h new file +5 -0
+struct pruss_map {
+    u8 dram0[512];
+    u8 res1[7680];
 
+    u8 dram1[512];
+    u8 res2[7680];

..}
you don't need the if..else..

Quoted 2 lines

SG - The dram/iram is not contiguous, there is a reserved space in between, how do I declare an array for it.

This is the struct you have:

struct pruss_map {
	u8 dram0[512];
	u8 res1[7680];

	u8 dram1[512];
	u8 res2[7680];

...
}

If you want to describe the ram with an array it translates to:

struct pruss_dram {
	u8 dram[512];
	u8 res[7680];
};
struct pruss_map {
	struct pruss_dram[2];

...
};

BTW: Why do you declare the dram as "u8" "u32" seems more natural to me.

Quoted 16 lines
Quoted 4 lines
drivers/mfd/pruss.c new file +4 -0
+/* Load the specified PRU with code */
+s32 pruss_load(struct device *dev, u8 pruss_num,
+            u32 *pruss_code, u32 code_size_in_words)
+{

drivers/mfd/pruss.c line 122

Quoted 10 lines
drivers/mfd/pruss.c new file +10 -0
+    struct pruss_priv *pruss = dev_get_drvdata(dev->parent);
+    struct pruss_map __iomem *pruss_mmap = pruss->ioaddr;
+    u32 __iomem *pruss_iram;
+    u32 i;
+
+    if (pruss_num == PRUCORE_0)
+        pruss_iram = (u32 __iomem *)&pruss_mmap->iram0;
+    else if (pruss_num == PRUCORE_1)
+        pruss_iram = (u32 __iomem *)&pruss_mmap->iram1;
+    else

same here

Quoted 1 line

SG - same here.

same here :)

Quoted 12 lines
Quoted 1 line

+s32 pruss_run(struct device *dev, u8 pruss_num)

int?

SG - Ok, Will do.

drivers/mfd/pruss.c line 191

Quoted 6 lines
drivers/mfd/pruss.c new file +6 -0
+    while (cnt--) {
+        temp_reg = ioread32(&h_pruss->control);
+        if (((temp_reg & PRUCORE_CONTROL_RUNSTATE_MASK) >>
+                PRUCORE_CONTROL_RUNSTATE_SHIFT) ==
+                PRUCORE_CONTROL_RUNSTATE_HALT)
+            break;
Quoted 3 lines

how long might this take? what about some delay, sleep, or reschedule?

SG - This does not take more than 10 to 20 counts,

Does it make sense, that the timeout is a parameter to that function?

Quoted 81 lines

drivers/mfd/pruss.c line 203

Quoted 6 lines
drivers/mfd/pruss.c new file +4 -0
+s32 pruss_writeb(struct device *dev, u32 offset, u8 pdatatowrite)
+{
+    struct pruss_priv *pruss = dev_get_drvdata(dev->parent);
+    void __iomem *paddresstowrite;

we usually don't use "p" variable names for pointers

SG - Ok, will remove.

Quoted 1 line

+s32 pruss_rmwb(struct device *dev, u32 offset, u8 mask, u8 val)

void function?

SG - Ok, will do.

Review

Quoted 2 lines
(quoted diff) +2 -0
+
+s32 pruss_readb(struct device *dev, u32 offset, u8 *pdatatoread)

void?

SG - Ok, will do.

drivers/mfd/pruss.c line 244

Quoted 13 lines
drivers/mfd/pruss.c new file +13 -0
+{
+    struct pruss_priv *pruss = dev_get_drvdata(dev->parent);
+    void __iomem *paddresstoread;
+
+    paddresstoread = pruss->ioaddr + offset ;
+    *pdatatoread = ioread8(paddresstoread);
+
+    return 0;
+}
+EXPORT_SYMBOL_GPL(pruss_readb);
+
+s32 pruss_readb_multi(struct device *dev, u32 offset,
+        u8 *pdatatoread, u16 bytestoread)

viod?

SG - Ok, will do.

drivers/mfd/pruss.c line 248

Quoted 4 lines
drivers/mfd/pruss.c new file +4 -0
+{
+    struct pruss_priv *pruss = dev_get_drvdata(dev->parent);
+    u8 __iomem *paddresstoread;
+    u16 i;

int?

SG - Ok, will do.

drivers/mfd/pruss.c line 260

Quoted 6 lines
drivers/mfd/pruss.c new file +6 -0
+    return 0;
+}
+EXPORT_SYMBOL_GPL(pruss_readb_multi);
+
+s32 pruss_writel(struct device *dev, u32 offset,
+        u32 pdatatowrite)

void?

SG - Ok, will do.

drivers/mfd/pruss.c line 273

Quoted 6 lines
drivers/mfd/pruss.c new file +6 -0
+    return 0;
+}
+EXPORT_SYMBOL_GPL(pruss_writel);
+
+s32 pruss_writel_multi(struct device *dev, u32 offset,
+        u32 *pdatatowrite, u16 wordstowrite)

void?

SG - Ok, will do.

drivers/mfd/pruss.c line 282

Quoted 9 lines
drivers/mfd/pruss.c new file +9 -0
+{
+    struct pruss_priv *pruss = dev_get_drvdata(dev->parent);
+    u32 __iomem *paddresstowrite;
+    u16 i;
+
+    paddresstowrite = pruss->ioaddr + offset;
+
+    for (i = 0; i < wordstowrite; i++)
+        iowrite32(*pdatatowrite++, paddresstowrite++);

memcopy_to_iomem?

Quoted 1 line

SG -- I did not understand, could you please elaborate.

You could use memcpy_toio() - although it seems it does copy bytes internally.

http://lxr.linux.no/linux+v2.6.38/arch/arm/include/asm/io.h#L222

Quoted 9 lines

drivers/mfd/pruss.c line 288

Quoted 4 lines
drivers/mfd/pruss.c new file +2 -0
+
+s32 pruss_rmwl(struct device *dev, u32 offset, u32 mask, u32 val)

void?

SG - Ok, will do.

Quoted 10 lines

drivers/mfd/pruss.c line 307

Quoted 4 lines
drivers/mfd/pruss.c new file +4 -0
+}
+EXPORT_SYMBOL_GPL(pruss_rmwl);
+
+s32 pruss_readl(struct device *dev, u32 offset, u32 *pdatatoread)

void? or return the read value

SG - Ok, will do.

regards,
Marc

Signature · 12 lines
Pengutronix e.K.                  | Marc Kleine-Budde           |
Industrial Linux Solutions        | Phone: +49-231-2826-924     |
Vertretung West/Dortmund          | Fax:   +49-5121-206917-5555 |
Amtsgericht Hildesheim, HRA 2686  | http://www.pengutronix.de   |

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 262 bytes
Desc: OpenPGP digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20110427/0ddba555/attachment-0001.sig>
#5 lore raw

Re: [PATCH v4 01/11] mfd: add pruss mfd driver.

Quoted 4 lines · Marc Kleine-Budde
Quoted 1 line · Subhasish Ghosh

- Is it ok to have u32 etc for __iomem cookie ?

no - "void __iomem *" is "void __iomem *"

Actually, it is _provided_ you don't directly dereference it. You can then do pointer arithmetic on it in the usual way - which is about the only valid thing to do with an __iomem pointer. The voidness just acts as an additional check against direct dereferences of this.

The important thing though is that the code passes sparse checks.

#6 lore raw

Re: [PATCH v4 01/11] mfd: add pruss mfd driver.

My problem is, I am doing something like this:

s32 pruss_writel_multi(struct device *dev, u32 offset,
u32 *pdatatowrite, u16 wordstowrite)

{
       struct pruss_priv *pruss = dev_get_drvdata(dev->parent);
       u32 __iomem *paddresstowrite;
       u16 i;

       paddresstowrite = pruss->ioaddr + offset;

       for (i = 0; i < wordstowrite; i++)
               iowrite32(*pdatatowrite++, paddresstowrite++);

       return 0;
}

So, if I make paddresstowrite as void, it will not work. The above implementation does not generate any sparse errors though.

Quoted 12 lines · Marc Kleine-Budde
Quoted 4 lines · Subhasish Ghosh
Quoted 1 line

- Is it ok to have u32 etc for __iomem cookie ?

no - "void __iomem *" is "void __iomem *"

Actually, it is _provided_ you don't directly dereference it. You can then do pointer arithmetic on it in the usual way - which is about the only valid thing to do with an __iomem pointer. The voidness just acts as an additional check against direct dereferences of this.

The important thing though is that the code passes sparse checks.

#7 lore raw

Re: [PATCH v4 01/11] mfd: add pruss mfd driver.

Quoted 17 lines · Subhasish Ghosh

My problem is, I am doing something like this:

s32 pruss_writel_multi(struct device *dev, u32 offset,
u32 *pdatatowrite, u16 wordstowrite)

{
       struct pruss_priv *pruss = dev_get_drvdata(dev->parent);
       u32 __iomem *paddresstowrite;
       u16 i;

       paddresstowrite = pruss->ioaddr + offset;

       for (i = 0; i < wordstowrite; i++)
               iowrite32(*pdatatowrite++, paddresstowrite++);

       return 0;
}
Quoted 2 lines

So, if I make paddresstowrite as void, it will not work. The above implementation does not generate any sparse errors though.

Incrementing a u32 pointer will result in increasing the address by 4 bytes. Incrementing a void pointer will result in increasing the address by just one byte. (Pointer arithmetic on void * is a gnu extension but IMHO a pretty nice one, though)

regards, Marc

Signature · 12 lines
Pengutronix e.K.                  | Marc Kleine-Budde           |
Industrial Linux Solutions        | Phone: +49-231-2826-924     |
Vertretung West/Dortmund          | Fax:   +49-5121-206917-5555 |
Amtsgericht Hildesheim, HRA 2686  | http://www.pengutronix.de   |

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 262 bytes
Desc: OpenPGP digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20110427/d0a11efa/attachment.sig>
#8 lore raw

Re: [PATCH v4 01/11] mfd: add pruss mfd driver.

Hi,

Quoted 17 lines · Subhasish Ghosh

My problem is, I am doing something like this:

s32 pruss_writel_multi(struct device *dev, u32 offset,
u32 *pdatatowrite, u16 wordstowrite)

{
       struct pruss_priv *pruss = dev_get_drvdata(dev->parent);
       u32 __iomem *paddresstowrite;
       u16 i;

       paddresstowrite = pruss->ioaddr + offset;

       for (i = 0; i < wordstowrite; i++)
               iowrite32(*pdatatowrite++, paddresstowrite++);

       return 0;
}
Quoted 2 lines

So, if I make paddresstowrite as void, it will not work. The above implementation does not generate any sparse errors though.

Yes, that why I can work with readb_multi even if I have void __iomen *.

But, how do I solve this problem. In the above function, I must use u32 __iomem *

#9 lore raw

Re: [PATCH v4 01/11] mfd: add pruss mfd driver.

Quoted 18 lines · On Thursday 28 April 2011 09:22:49 Subhasish Ghosh wrote:
Quoted 17 lines · Subhasish Ghosh

My problem is, I am doing something like this:

s32 pruss_writel_multi(struct device *dev, u32 offset,
u32 *pdatatowrite, u16 wordstowrite)

{
       struct pruss_priv *pruss = dev_get_drvdata(dev->parent);
       u32 __iomem *paddresstowrite;
       u16 i;

       paddresstowrite = pruss->ioaddr + offset;

       for (i = 0; i < wordstowrite; i++)
               iowrite32(*pdatatowrite++, paddresstowrite++);

       return 0;
}
Quoted 8 lines
Quoted 2 lines

So, if I make paddresstowrite as void, it will not work. The above implementation does not generate any sparse errors though.

Yes, that why I can work with readb_multi even if I have void __iomen *.

But, how do I solve this problem. In the above function, I must use u32 __iomem *

I believe you were talking about different things. The code you cited above looks correct to me. For clarity, I would write the loop as

       for (i = 0; i < wordstowrite; i++)
               iowrite32(pdatatowrite[i], &paddresstowrite[i]);

but your version is just as correct, and I would not complain about it.

It is absolutely valid to pass either a 'void __iomem *' or a 'u32 __iomem *' into iowrite32(). What is not valid is to cast between a 'void __iomem *' and a plain 'u32' (no pointer). While that may work in most cases, there are a lot of reasons why that is considered bad style and you should never write code like that. I believe that is what Marc was referring to, but you don't do it in your code.

The initial comments that Marc made were about the return value of the accessor functions that always return success. Just make those return void instead. Again, this is unrelated to the pointer types.

Arnd

#10 lore raw

Re: [PATCH v4 01/11] mfd: add pruss mfd driver.

In reply to Subhasish Ghosh
Quoted 12 lines · Subhasish Ghosh

This patch adds the pruss MFD driver and associated include files. For details regarding the PRUSS please refer the folowing link:
http://processors.wiki.ti.com/index.php/Programmable_Realtime_Unit_Subsystem

The rational behind the MFD driver being the fact that multiple devices can be implemented on the cores independently. This is determined by the nature of the program which is loaded into the PRU's instruction memory. A device may be de-initialized and another loaded or two different devices can be run simultaneously on the two cores.
It's also possible, as in our case, to implement a single device on both the PRU's resulting in improved load sharing.

Quoted 1 line

Hi Subhasish,

This looks like great progress since the last time I looked at the pruss mfd driver, good work there!

Thanks to your explanations and the documentation link, I now have a better understanding of what is actually going on here, but I'd still like to understandhow the decision is made regarding what programs are loaded into each PRU and how the MFD cells are set up.

Is this a fixed setting for each board that strictly depends on how the external pins are connected, or is it possible to use the same hardware for different purposes based on the program?

If I read your code correctly, you hardwire the usage of the two PRUs in the da850 board code, which makes it impossible to use them in different ways even if the hardware supports it. If this is indeed the case, using an MFD device might not be the best option and we should try to come up with a way to dynamically repurpose the PRU with some user interface.

Arnd

#11 lore raw

Re: [PATCH v4 01/11] mfd: add pruss mfd driver.

PRU's resulting in improved load sharing.

Quoted 14 lines
Quoted 2 lines

Hi Subhasish,

This looks like great progress since the last time I looked at the pruss mfd driver, good work there!

Thanks to your explanations and the documentation link, I now have a better understanding of what is actually going on here, but I'd still like to understandhow the decision is made regarding what programs are loaded into each PRU and how the MFD cells are set up.

Quoted 3 lines

Is this a fixed setting for each board that strictly depends on how the external pins are connected, or is it possible to use the same hardware for different purposes based on the program?

SG -- The PRU pins are exposed as is on the main board,
we have separate add on daughter cards specific to the protocol implemented on it.

Quoted 7 lines

If I read your code correctly, you hardwire the usage of the two PRUs in the da850 board code, which makes it impossible to use them in different ways even if the hardware supports it. If this is indeed the case, using an MFD device might not be the best option and we should try to come up with a way to dynamically repurpose the PRU with some user interface.

SG -- It depends upon how the firmware is implemented. If another
firmware is downloaded on it, it will emulate another device. Also, if a firmware emulated on it supports switching between
devices,
that too is possible. Its just a microcontroller, we can do
whatever we feel like
with it. Both the PRUs have separate instruction/data ram, so
both can be used
to implement two different devices.

#12 lore raw

Re: [PATCH v4 01/11] mfd: add pruss mfd driver.

Quoted 8 lines · Subhasish Ghosh
Quoted 7 lines

If I read your code correctly, you hardwire the usage of the two PRUs in the da850 board code, which makes it impossible to use them in different ways even if the hardware supports it. If this is indeed the case, using an MFD device might not be the best option and we should try to come up with a way to dynamically repurpose the PRU with some user interface.

Quoted 9 lines

SG -- It depends upon how the firmware is implemented. If another
firmware is downloaded on it, it will emulate another device. Also, if a firmware emulated on it supports switching between
devices,
that too is possible. Its just a microcontroller, we can do
whatever we feel like
with it. Both the PRUs have separate instruction/data ram, so
both can be used
to implement two different devices.

I see. So the problem that I see with the current code is that you force the system to provide a set of devices from the MFD, which then get passed to the individual drivers (uart and can) that load the firmware they need. Please correct me if I am reading your code wrong.

What I suggest you do instead is to have the request_firmware call in the low-level MFD driver, so the user can provide the firmware that he/she wants to use, and then the MFD driver will create the devices that match the firmware loaded into the device.

You can easily do that by adding a small header to the firmware format and interpret that header by the MFD driver. When the name of the subdevice is part of that header, the MFD driver does not need to understand the difference, it can simply pass that on when creating its child devices.

Arnd

#13 lore raw

Re: [PATCH v4 01/11] mfd: add pruss mfd driver.

Hi,

Quoted 21 lines
Quoted 9 lines

SG -- It depends upon how the firmware is implemented. If another
firmware is downloaded on it, it will emulate another device. Also, if a firmware emulated on it supports switching between
devices,
that too is possible. Its just a microcontroller, we can do
whatever we feel like
with it. Both the PRUs have separate instruction/data ram, so
both can be used
to implement two different devices.

I see. So the problem that I see with the current code is that you force the system to provide a set of devices from the MFD, which then get passed to the individual drivers (uart and can) that load the firmware they need. Please correct me if I am reading your code wrong.

What I suggest you do instead is to have the request_firmware call in the low-level MFD driver, so the user can provide the firmware that he/she wants to use, and then the MFD driver will create the devices that match the firmware loaded into the device.

Quoted 5 lines

You can easily do that by adding a small header to the firmware format and interpret that header by the MFD driver. When the name of the subdevice is part of that header, the MFD driver does not need to understand the difference, it can simply pass that on when creating its child devices.

I don't understand why loading the firmware should be done at the MFD driver.
The user already specifies the device he/she wants to start on the PRU via modprobe. A driver can be inserted, which can download a printer firmware on one PRU and a scanner firmware on the other. This way both cores can be used for separate purposes. I mean, say in a real MFD controller, that will also have two separate cores running on it, just that, the firmware on it would not be downloaded runtime but fused in some non volatile memory.

#14 lore raw

Re: [PATCH v4 01/11] mfd: add pruss mfd driver.

Quoted 7 lines · On Thursday 28 April 2011 09:17:21 Subhasish Ghosh wrote:
Quoted 6 lines

You can easily do that by adding a small header to the firmware format and interpret that header by the MFD driver. When the name of the subdevice is part of that header, the MFD driver does not need to understand the difference, it can simply pass that on when creating its child devices.

Quoted 12 lines

I don't understand why loading the firmware should be done at the MFD driver.
The user already specifies the device he/she wants to start on the PRU via modprobe.
A driver can be inserted, which can download a printer firmware on one PRU and a
scanner firmware on the other. This way both cores can be used for separate purposes.
I mean, say in a real MFD controller, that will also have two separate cores running on it,
just that, the firmware on it would not be downloaded runtime but fused in some non volatile memory.

Then I must be misreading what your code currently does, because it does not match your explanations. What I see in the platform code is that you create MFD cells for specific devices that get automatically created by the MFD driver. This will cause udev to load the drivers for these devices, which then load the firmware they need.

Also, I cannot see how the method you describe would make it possible to the same driver into both units, e.g. when you want to have two serial ports. The reason is that you currently hardcode the PRU number in the driver and that you cannot load a single driver twice.

Finally, I'm trying to make sure that whatever solution you come up with will still work when we migrate the code to using a flattened device tree. In that case, you would ideally put the device firmware into the device tree as a property that matches whatever you have connected on the specific board (at least as an option, you can still fall back to request_firmware). You definitely want automatic module loading in that case.

Note that using module loading with specific parameters in order to match the hardware is not a recommended procedure any more. The code really needs to work the same way when all drivers are built into the kernel. It should not be hard to use the firmware loading mechanism in the MFD driver to both load the firmware and configure the devices appropriately so we always use the right driver for the currently active devices.

Arnd

BTW, something is wrong with your email client line wrapping. I've fixed this up manually before when replying, but please find a way to get this right in the future.

#15 lore raw

Re: [PATCH v4 01/11] mfd: add pruss mfd driver.

Hi Arnd,

How about just doing something like:

#> echo da8xx_pruss_uart >> firmware.bin

i.e just append the device name (from the board file) into the firmware file.

In the driver probe, we can parse from the bottom, when it reaches "da8xx_pruss", the rest of the upper data is the firmware and from the full name, we can determine if it's a CAN, UART or any other peripheral.

So, based on the platform_data, which the MFD driver received, it can find out which device to initialize.

Also, does the line wrapping look any better ?

Quoted 61 lines · On Thursday 28 April 2011 09:17:21 Subhasish Ghosh wrote:
Quoted 16 lines
Quoted 6 lines

You can easily do that by adding a small header to the firmware format and interpret that header by the MFD driver. When the name of the subdevice is part of that header, the MFD driver does not need to understand the difference, it can simply pass that on when creating its child devices.

I don't understand why loading the firmware should be done at the MFD driver.
The user already specifies the device he/she wants to start on the PRU via
modprobe.
A driver can be inserted, which can download a printer firmware on one PRU
and a
scanner firmware on the other. This way both cores can be used for

Quoted 8 lines

separate
purposes.
I mean, say in a real MFD controller, that will also have two separate cores
running on it,
just that, the firmware on it would not be downloaded runtime but fused in
some non volatile memory.

Then I must be misreading what your code currently does, because it does not
match your explanations. What I see in the platform code is that you create
MFD cells for specific devices that get automatically created by the MFD driver. This will cause udev to load the drivers for these devices, which then load the firmware they need.

Also, I cannot see how the method you describe would make it possible to the same driver into both units, e.g. when you want to have two serial ports. The reason is that you currently hardcode the PRU number in the driver and that you cannot load a single driver twice.

Finally, I'm trying to make sure that whatever solution you come up with will still work when we migrate the code to using a flattened device tree. In that case, you would ideally put the device firmware into the device tree as a property that matches whatever you have connected on the specific
board (at least as an option, you can still fall back to request_firmware).
You definitely want automatic module loading in that case.

Note that using module loading with specific parameters in order to match the hardware is not a recommended procedure any more. The code really needs to work the same way when all drivers are built into the kernel. It should not be hard to use the firmware loading mechanism in the MFD driver to both load the firmware and configure the devices appropriately so we always use the right driver for the currently active devices.

Arnd

BTW, something is wrong with your email client line wrapping. I've fixed this up manually before when replying, but please find a way to get this right in the future.

#16 lore raw

Re: [PATCH v4 01/11] mfd: add pruss mfd driver.

Quoted 6 lines · Subhasish Ghosh

How about just doing something like:

#> echo da8xx_pruss_uart >> firmware.bin

i.e just append the device name (from the board file) into the firmware file.

That sounds fine to me. I would put a header in the beginning, but feel free to use whatever format you find useful there.

Quoted 7 lines

In the driver probe, we can parse from the bottom, when it reaches "da8xx_pruss", the rest of the upper data is the firmware and from the full name, we can determine if it's a CAN, UART or any other peripheral.

So, based on the platform_data, which the MFD driver received, it can find out which device to initialize.

In my opinion, the MFD driver should not know the possible values at all, or look at platform_data for the children, but take all that information from the firmware file.

The only thing that the MFD driver needs to know is how many PRUs there are and how they are connected to the host bus (memory regions, irqs, clocks, ...). It can then load firmware files, either one for the entire MFD or one per PRU core (whatever works best for you) and create child devices with the information it finds in there about what code to load into each PRU and what drivers to load for them.

When you prepend the "da8xx_pruss_" string to the name you find in the firmware file, the pruss driver can be sure that it does not accidentally load a different module, e.g. when a malicious user was able to exchange the firmware file.

Quoted 1 line

Also, does the line wrapping look any better ?

Looks good now, yes.

Arnd

#17 lore raw

RE: [PATCH v4 01/11] mfd: add pruss mfd driver.

In reply to Subhasish Ghosh

Hi Subhasish,

Quoted 9 lines · Subhasish Ghosh

Hi Arnd,

How about just doing something like:

#> echo da8xx_pruss_uart >> firmware.bin

i.e just append the device name (from the board file) into the firmware file.

Quoted 7 lines

In the driver probe, we can parse from the bottom, when it reaches "da8xx_pruss", the rest of the upper data is the firmware and from the full name, we can determine if it's a CAN, UART or any other peripheral.

So, based on the platform_data, which the MFD driver received, it can find out which device to initialize.

If you are defining a firmware header, it may be worthwhile making sure you include information on features of the device being supported (I assume there will be differences in CAN features if the firmware uses both PRUs to support CAN versus UART on one PRU and CAN on another PRU).

The MFD driver can parse this information and pass this on to the UART or CAN drivers.

Thanks,
Sekhar

Quoted 67 lines

Also, does the line wrapping look any better ?

Quoted 61 lines · On Thursday 28 April 2011 09:17:21 Subhasish Ghosh wrote:
Quoted 16 lines
Quoted 6 lines

You can easily do that by adding a small header to the firmware format and interpret that header by the MFD driver. When the name of the subdevice is part of that header, the MFD driver does not need to understand the difference, it can simply pass that on when creating its child devices.

I don't understand why loading the firmware should be done at the MFD driver.
The user already specifies the device he/she wants to start on the PRU via
modprobe.
A driver can be inserted, which can download a printer firmware on one PRU
and a
scanner firmware on the other. This way both cores can be used for

Quoted 8 lines

separate
purposes.
I mean, say in a real MFD controller, that will also have two separate cores
running on it,
just that, the firmware on it would not be downloaded runtime but fused in
some non volatile memory.

Then I must be misreading what your code currently does, because it does not
match your explanations. What I see in the platform code is that you create
MFD cells for specific devices that get automatically created by the MFD driver. This will cause udev to load the drivers for these devices, which then load the firmware they need.

Also, I cannot see how the method you describe would make it possible to the same driver into both units, e.g. when you want to have two serial ports. The reason is that you currently hardcode the PRU number in the driver and that you cannot load a single driver twice.

Finally, I'm trying to make sure that whatever solution you come up with will still work when we migrate the code to using a flattened device tree. In that case, you would ideally put the device firmware into the device tree as a property that matches whatever you have connected on the specific
board (at least as an option, you can still fall back to request_firmware).
You definitely want automatic module loading in that case.

Note that using module loading with specific parameters in order to match the hardware is not a recommended procedure any more. The code really needs to work the same way when all drivers are built into the kernel. It should not be hard to use the firmware loading mechanism in the MFD driver to both load the firmware and configure the devices appropriately so we always use the right driver for the currently active devices.

Arnd

BTW, something is wrong with your email client line wrapping. I've fixed this up manually before when replying, but please find a way to get this right in the future.

#18 lore raw

Re: [PATCH v4 01/11] mfd: add pruss mfd driver.

I am a bit lost,

If I understand correctly, there are two problems

1. In case of udev based driver loading, we will end up loading both the drivers and the associated firmware. This is not acceptable because both UART & CAN use PRU0 & PRU1.

2. How do we switch between devices at run time.
This is required because MFD devices should be
capable of doing that.

Ok, if that understanding is somewhat correct, then, what we are trying to do is load the firmware from the MFD driver itself.

So, in case of a switch between device, say from UART to CAN, all the user has to do is copy a new firmware.

This firmware should contain some info regarding the device, like say, device name & prunum.

So, in case a device requires both PRUs, then the firmware would download for both PRUs.

In case a device requires only one PRU, then it can be downloaded only into the requested PRU. So, the other PRU remains open for any other firmware/device.

After loading the firmware, the MFD device should create the platform devices based upon the firmware.

So, if only one PRU is used for UART, then the other PRU can be used for CAN and the MFD should create two platform_devices.

If the UART uses both the PRUs, then the MFD should download the firmware into both the PRUs but create only one platform_device.

But, in this case how do we download two different firmware on two different PRUs. One way is to keep the firmware files as its now, but add another file say firmware-config.txt, consisting a list of parameters like,

START
MFD_ID0#0
MFD_ID0_PRU_NUM#PRU0
MFD_ID1#1
MFD_ID1_PRU_NUM#PRU1
END

OR

START
MFD_ID0#0
MFD_ID0_PRU_NUM#PRU0:PRU1
END

So, the MFD driver can do a request_firmware on this file first, parse the device info and decide to request the main firmware. This becomes something like the devices table that we have on PPC.

Also, if PRU0 is loaded, we need some way of maintaining the usage_count, So that the PRU0 is not loaded again accidently. We can increase the usage_count from the MFD driver. But, to decrement the usage_count, we can add an API which will be called when the CAN or UART driver is rmmod.

Now how do we handle switch between devices.

We can either do a rmmod of the MFD driver, then again modprobe it. So, the request_firmware is run again and the appropriate device is loaded based upon the changed firmware-config.txt.

But, this does not look good, say what if the MFD driver is in-build. Another way is that we can add a sysfs entry, which when written with anything can re-evaluate the firmware_config.

What the hell, does anything make any sense ?

Quoted 110 lines

Hi Subhasish,

Quoted 9 lines · Subhasish Ghosh

Hi Arnd,

How about just doing something like:

#> echo da8xx_pruss_uart >> firmware.bin

i.e just append the device name (from the board file) into the firmware file.

Quoted 7 lines

In the driver probe, we can parse from the bottom, when it reaches "da8xx_pruss", the rest of the upper data is the firmware and from the full name, we can determine if it's a CAN, UART or any other peripheral.

So, based on the platform_data, which the MFD driver received, it can find out which device to initialize.

If you are defining a firmware header, it may be worthwhile making sure you include information on features of the device being supported (I assume there will be differences in CAN features if the firmware uses both PRUs to support CAN versus UART on one PRU and CAN on another PRU).

The MFD driver can parse this information and pass this on to the UART or CAN drivers.

Thanks,
Sekhar

Quoted 76 lines

Also, does the line wrapping look any better ?

Quoted 70 lines · On Thursday 28 April 2011 09:17:21 Subhasish Ghosh wrote:
Quoted 17 lines
Quoted 6 lines

You can easily do that by adding a small header to the firmware format and interpret that header by the MFD driver. When the name of the subdevice is part of that header, the MFD driver does not need to understand the difference, it can simply pass that on when creating its child devices.

I don't understand why loading the firmware should be done at the MFD driver.
The user already specifies the device he/she wants to start on the PRU via
modprobe.
A driver can be inserted, which can download a printer firmware on one PRU
and a
scanner firmware on the other. This way both cores can be used for separate

Quoted 8 lines

purposes.
I mean, say in a real MFD controller, that will also have two separate cores
running on it,
just that, the firmware on it would not be downloaded runtime but fused
in
some non volatile memory.

Then I must be misreading what your code currently does, because it does
not
match your explanations. What I see in the platform code is that you create
MFD cells for specific devices that get automatically created by the MFD
driver. This will cause udev to load the drivers for these devices, which
then load the firmware they need.

Also, I cannot see how the method you describe would make it possible to
the same driver into both units, e.g. when you want to have two serial ports. The reason is that you currently hardcode the PRU number in the driver and that you cannot load a single driver twice.

Finally, I'm trying to make sure that whatever solution you come up with
will still work when we migrate the code to using a flattened device tree.
In that case, you would ideally put the device firmware into the device tree as a property that matches whatever you have connected on the specific
board (at least as an option, you can still fall back to request_firmware).
You definitely want automatic module loading in that case.

Note that using module loading with specific parameters in order to match the hardware is not a recommended procedure any more. The code really needs to work the same way when all drivers are built into the kernel. It should not be hard to use the firmware loading mechanism in the MFD driver to both load the firmware and configure the devices appropriately so we always use the right driver for the currently active devices.

Arnd

BTW, something is wrong with your email client line wrapping. I've fixed
this up manually before when replying, but please find a way to get this
right in the future.

#19 lore raw

Re: [PATCH v4 01/11] mfd: add pruss mfd driver.

Quoted 9 lines · Subhasish Ghosh

I am a bit lost,

If I understand correctly, there are two problems

1. In case of udev based driver loading, we will end up loading both the drivers and the associated firmware. This is not acceptable because both UART & CAN use PRU0 & PRU1.

Quoted 7 lines

2. How do we switch between devices at run time.
This is required because MFD devices should be
capable of doing that.

Ok, if that understanding is somewhat correct, then, what we are trying to do is load the firmware from the MFD driver itself.

I would describe the problem differently:

You hardcode the usage of the pruss in the platform code, even though it is completely defined by the software you load into it. I think it is essential that all the configuration of the pruss is dynamic and not hardcoded in the platform code, so that it is at all possible to load other firmware into it.

Describing the device in the firmware file instead of the platform code is one way to get there, but there may be other ways that you could come up with.

Quoted 5 lines

So, in case of a switch between device, say from UART to CAN, all the user has to do is copy a new firmware.

This firmware should contain some info regarding the device, like say, device name & prunum.

Right.

Quoted 7 lines

So, in case a device requires both PRUs, then the firmware would download for both PRUs.

In case a device requires only one PRU, then it can be downloaded only into the requested PRU. So, the other PRU remains open for any other firmware/device.

Quoted 8 lines

After loading the firmware, the MFD device should create the platform devices based upon the firmware.

So, if only one PRU is used for UART, then the other PRU can be used for CAN and the MFD should create two platform_devices.

If the UART uses both the PRUs, then the MFD should download the firmware into both the PRUs but create only one platform_device.

As I mentioned, I did not have a good idea for how to abstract the fact that there may be either one or two child devices, depending on the firmware. A possible way to deal with this would be to have only a single firmware image files that contains the code for both PRUs, with a header indicating how many devices there should be and what they are called.

Quoted 19 lines

But, in this case how do we download two different firmware on two different PRUs. One way is to keep the firmware files as its now, but add another file say firmware-config.txt, consisting a list of parameters like,

START
MFD_ID0#0
MFD_ID0_PRU_NUM#PRU0
MFD_ID1#1
MFD_ID1_PRU_NUM#PRU1
END

OR

START
MFD_ID0#0
MFD_ID0_PRU_NUM#PRU0:PRU1
END

Quoted 4 lines

So, the MFD driver can do a request_firmware on this file first, parse the device info and decide to request the main firmware. This becomes something like the devices table that we have on PPC.

Yes, this would be another option. I generally don't like parsing data in the kernel, but it's not completely unrealistic.

Quoted 5 lines

Also, if PRU0 is loaded, we need some way of maintaining the usage_count, So that the PRU0 is not loaded again accidently. We can increase the usage_count from the MFD driver. But, to decrement the usage_count, we can add an API which will be called when the CAN or UART driver is rmmod.

Not necesarily. You can make the interface so that the child device gets registered after the firmware got loaded, but unregistered if you start loading new firmware. We have hotplug support for a lot of devices, and it's not hard to write the serial/can/... drivers in a way that allows the underlying device to go away.

You should not actually need to unload the device driver. E.g. when the drivers are built into the kernel, you can still remove the device and put it back in there using the ->probe and ->remove callbacks of the platform driver.

Quoted 9 lines

Now how do we handle switch between devices.

We can either do a rmmod of the MFD driver, then again modprobe it. So, the request_firmware is run again and the appropriate device is loaded based upon the changed firmware-config.txt.

But, this does not look good, say what if the MFD driver is in-build. Another way is that we can add a sysfs entry, which when written with anything can re-evaluate the firmware_config.

Yes, I think that a sysfs entry would be good here, basically to reset the entire unit and remove the child devices, followed by a new call to request_firmware.

Instead of passing a configuration file into the MFD driver and calling it a firmware, I can see three other options that I believe would be nicer:

1. have a single firmware blob that describes the child devices and the code that is to be loaded into both units. If they are acting as one device, either make sure you only create one child node, or create one with a name that no driver binds to.

2. Call request_firmware separately for the two child devices, and configure them separately based on the information in the firmware files. In the case where they should act as a single device, call the children e.g. "pruss-uart-a" and "pruss-uart-b", then bind to both names in the pruss-uart drivers and only start using the device when you have both nodes for the same parent.

3. Do the configuration through sysfs files in the MFD device node, which then cause the creation of the child devices. This means you need extra user space scripts to write the addititonal files, but is also the most flexible way.

Arnd

#20 lore raw

Re: [PATCH v4 01/11] mfd: add pruss mfd driver.

Quoted 17 lines

Instead of passing a configuration file into the MFD driver and calling it a firmware, I can see three other options that I believe would be nicer:

1. have a single firmware blob that describes the child devices and the code that is to be loaded into both units. If they are acting as one device, either make sure you only create one child node, or create one with a name that no driver binds to.

2. Call request_firmware separately for the two child devices, and configure them separately based on the information in the firmware files. In the case where they should act as a single device, call the children e.g. "pruss-uart-a" and "pruss-uart-b", then bind to both names in the pruss-uart drivers and only start using the device when you have both nodes for the same parent.

Quoted 5 lines

3. Do the configuration through sysfs files in the MFD device node, which then cause the creation of the child devices. This means you need extra user space scripts to write the addititonal files, but is also the most flexible way.

Are you suggesting something like:

/sys..../pruss/pru0/id
/sys..../pruss/pru0/fw_name
/sys..../pruss/pru0/load

/sys..../pruss/pru1/id
/sys..../pruss/pru1/fw_name
/sys..../pruss/pru1/load

I can program these configs and store them in the pru private. Then write something into load.
This can load the PRU based upon the configs.
But, I am not sure how to do this effectively using sysfs, I mean I don't want to end up writing six write and six read handlers.

#21 lore raw

Re: [PATCH v4 01/11] mfd: add pruss mfd driver.

Quoted 25 lines · Subhasish Ghosh
Quoted 17 lines

Instead of passing a configuration file into the MFD driver and calling it a firmware, I can see three other options that I believe would be nicer:

1. have a single firmware blob that describes the child devices and the code that is to be loaded into both units. If they are acting as one device, either make sure you only create one child node, or create one with a name that no driver binds to.

2. Call request_firmware separately for the two child devices, and configure them separately based on the information in the firmware files. In the case where they should act as a single device, call the children e.g. "pruss-uart-a" and "pruss-uart-b", then bind to both names in the pruss-uart drivers and only start using the device when you have both nodes for the same parent.

Quoted 5 lines

3. Do the configuration through sysfs files in the MFD device node, which then cause the creation of the child devices. This means you need extra user space scripts to write the addititonal files, but is also the most flexible way.

Are you suggesting something like:

Quoted 7 lines

/sys..../pruss/pru0/id
/sys..../pruss/pru0/fw_name
/sys..../pruss/pru0/load

/sys..../pruss/pru1/id
/sys..../pruss/pru1/fw_name
/sys..../pruss/pru1/load

No, that is none of the three I suggested.

Quoted 6 lines

I can program these configs and store them in the pru private. Then write something into load.
This can load the PRU based upon the configs.
But, I am not sure how to do this effectively using sysfs, I mean I don't want to end up writing six write and six read handlers.

Please look into implementing one of the three I suggested before you go off in another direction. In case of the third one, the idea was to configure the name of the device for each pru using sysfs, which then gets bound to the driver, which loads its own firmware as you do today. Only in the first two suggestions, the mfd driver would be responsible for loading the firmware.

Arnd

#22 lore raw

Re: [PATCH v4 01/11] mfd: add pruss mfd driver.

Quoted 6 lines

Please look into implementing one of the three I suggested before you go off in another direction. In case of the third one, the idea was to configure the name of the device for each pru using sysfs, which then gets bound to the driver, which loads its own firmware as you do today. Only in the first two suggestions, the mfd driver would be responsible for loading the firmware.

Ok, thanks for the clarification.
Instead of passing the device name, will it be ok to pass the mfd_id. The benefit will be that I can use the ID directly as an array index for the mfd_cell entries.

Just to verify my understanding, all that's needs to be done is add a sysfs entry at
/sys/devices/platform/pruss_mfd/mfd_id

Writing to this entry would create the respective device. Rewriting would unload the old (mfd_remove_device) and reload the new device.
Reading may return the various devices and their name aliases.

#23 lore raw

Re: [PATCH v4 01/11] mfd: add pruss mfd driver.

Quoted 11 lines · Subhasish Ghosh
Quoted 6 lines

Please look into implementing one of the three I suggested before you go off in another direction. In case of the third one, the idea was to configure the name of the device for each pru using sysfs, which then gets bound to the driver, which loads its own firmware as you do today. Only in the first two suggestions, the mfd driver would be responsible for loading the firmware.

Ok, thanks for the clarification.
Instead of passing the device name, will it be ok to pass the mfd_id. The benefit will be that I can use the ID directly as an array index for the mfd_cell entries.

I think a device name would be clearer here, especially in order to avoid conflicts when the list gets extended in different ways depending on which kernel runs.

We had a little discussion at the Linaro Developer Summit about your driver and mfd drivers in general. There was a general feeling among some people (including me) that by the point you dynamically create the subdevices, MFD is probably not the right abstraction any more, as it does not provide any service that you need.

Instead, maybe you can simply call platform_device_register at that stage to create the children and not use MFD at all.

Samuel, can you comment on this as well? Do you still see pruss as an MFD driver when the uses are completely dynamic and determined by the firmware loaded into it?

Quoted 7 lines

Just to verify my understanding, all that's needs to be done is add a sysfs entry at
/sys/devices/platform/pruss_mfd/mfd_id

Writing to this entry would create the respective device. Rewriting would unload the old (mfd_remove_device) and reload the new device.

Yes

Quoted 2 lines

Reading may return the various devices and their name aliases.

I would just return the current value. You might want to have two files in sysfs, one per PRU, so you can set them individually.

Arnd

#24 lore raw

Re: [PATCH v4 01/11] mfd: add pruss mfd driver.

Quoted 16 lines
Quoted 5 lines

Ok, thanks for the clarification.
Instead of passing the device name, will it be ok to pass the mfd_id. The benefit will be that I can use the ID directly as an array index for the mfd_cell entries.

I think a device name would be clearer here, especially in order to avoid conflicts when the list gets extended in different ways depending on which kernel runs.

We had a little discussion at the Linaro Developer Summit about your driver and mfd drivers in general. There was a general feeling among some people (including me) that by the point you dynamically create the subdevices, MFD is probably not the right abstraction any more, as it does not provide any service that you need.

Quoted 7 lines

Instead, maybe you can simply call platform_device_register at that stage to create the children and not use MFD at all.

Samuel, can you comment on this as well? Do you still see pruss as an MFD driver when the uses are completely dynamic and determined by the firmware loaded into it?

Hi Arnd,

But in that case, where do I fit my driver.
It's a microcontroller inside of a processor, guess that's unique for Linux. Will a misc device be a better choice.

In that case I can remove the MFD cell from the board_file and add an array of platform_device for the UART & CAN.

Regarding device register, I will have to implement something similar to mfd_add_devices and mark the dev->parent.

Did I miss something or will that be fine.

#25 lore raw

Re: [PATCH v4 01/11] mfd: add pruss mfd driver.

Quoted 9 lines · Subhasish Ghosh
Quoted 6 lines

Instead, maybe you can simply call platform_device_register at that stage to create the children and not use MFD at all.

Samuel, can you comment on this as well? Do you still see pruss as an MFD driver when the uses are completely dynamic and determined by the firmware loaded into it?

But in that case, where do I fit my driver.
It's a microcontroller inside of a processor, guess that's unique for Linux.

It's not that unusual in hardware terms, really. There's an awful lot of this going on in the audio area especially at the minute so there's going to be some effort around providing some framework support for this which should have some general usability but that's not there yet.

Quoted 4 lines

Will a misc device be a better choice.

In that case I can remove the MFD cell from the board_file and add an array of platform_device for the UART & CAN.

I think that for me so long as it can simultaneously do two unrelated functions which need to be arbitrated between there's probably a place for it in MFD, certainly at the minute.

#26 lore raw

Re: [PATCH v4 01/11] mfd: add pruss mfd driver.

Quoted 8 lines · Mark Brown
Quoted 4 lines

Will a misc device be a better choice.

In that case I can remove the MFD cell from the board_file and add an array of platform_device for the UART & CAN.

I think that for me so long as it can simultaneously do two unrelated functions which need to be arbitrated between there's probably a place for it in MFD, certainly at the minute.

I guess drivers/mfd would be a better place than drivers/misc, but it might not need to be an mfd driver in the sense that it registers mfd cells.

The more important point is to remove the device registration from the board file. You definitely should not have the cells in the board file, but replacing them with platform devices in the board file makes it no better.

My whole point has been that you register them from the main pruss driver based on run-time data instead of compile-time pre-configured stuff in the board file.

Arnd

#27 lore raw

Re: [PATCH v4 01/11] mfd: add pruss mfd driver.

Quoted 2 lines · Arnd Bergmann

I guess drivers/mfd would be a better place than drivers/misc, but it might not need to be an mfd driver in the sense that it registers mfd cells.

Yes, it might be more sensible to just open code. OTOH mfd_cell is marginally easier to use.

Quoted 3 lines

The more important point is to remove the device registration from the board file. You definitely should not have the cells in the board file, but replacing them with platform devices in the board file makes it no better.

Agreed entirely, it should be something higher level than that.

Quoted 3 lines

My whole point has been that you register them from the main pruss driver based on run-time data instead of compile-time pre-configured stuff in the board file.

I'm not so sure - if the usage is fixed as a result of the pins on the device being wired a CAN bus then it seems reasonable to tell the system about that so it'll stop the user trying to run SPI or something against it at runtime.

#28 lore raw

Re: [PATCH v4 01/11] mfd: add pruss mfd driver.

Quoted 8 lines · Mark Brown
Quoted 3 lines

My whole point has been that you register them from the main pruss driver based on run-time data instead of compile-time pre-configured stuff in the board file.

I'm not so sure - if the usage is fixed as a result of the pins on the device being wired a CAN bus then it seems reasonable to tell the system about that so it'll stop the user trying to run SPI or something against it at runtime.

I'm mostly worried about the case where the pins are not hardwired for some specific function -- Subhasish was mentioning that these may be implemented using a pluggable extension board and I want to make sure that you are not required to recompile the kernel when changing the extension board.

However, you made a good point that in many cases it will be hardwired so it may be valuable to preconfigure this in a way that does not require scripts to set up variables in sysfs when you already know what is there.

Note that my suggestion to put the device name into the firmware file covers this case, because you can then simply ship a firmware blob that matches the hardware configuration. Thinking about the future device tree setup, you can even put the firmware blob itself into a property in the device tree file.

Arnd

#29 lore raw

Re: [PATCH v4 01/11] mfd: add pruss mfd driver.

Hi!,

Quoted 19 lines
Quoted 8 lines
Quoted 3 lines

My whole point has been that you register them from the main pruss driver based on run-time data instead of compile-time pre-configured stuff in the board file.

I'm not so sure - if the usage is fixed as a result of the pins on the device being wired a CAN bus then it seems reasonable to tell the system about that so it'll stop the user trying to run SPI or something against it at runtime.

I'm mostly worried about the case where the pins are not hardwired for some specific function -- Subhasish was mentioning that these may be implemented using a pluggable extension board and I want to make sure that you are not required to recompile the kernel when changing the extension board.

However, you made a good point that in many cases it will be hardwired so it may be valuable to preconfigure this in a way that does not require scripts to set up variables in sysfs when you already know what is there.

Quoted 6 lines

Note that my suggestion to put the device name into the firmware file covers this case, because you can then simply ship a firmware blob that matches the hardware configuration. Thinking about the future device tree setup, you can even put the firmware blob itself into a property in the device tree file.

I earlier had an implementation where I used a pruss_devices structure in the board file.

http://linux.omap.com/pipermail/davinci-linux-open-source/
2011-March/022339.html.

We can use this implementation along with the sysfs to load the devices runtime. The configs that I have in the board_file for the devices structure, are fixed for a board. To swap the boards, we do not need to re-compile the kernel.

#30 lore raw

Re: [PATCH v4 01/11] mfd: add pruss mfd driver.

Quoted 8 lines · Subhasish Ghosh

I earlier had an implementation where I used a pruss_devices structure in the board file.

http://linux.omap.com/pipermail/davinci-linux-open-source/
2011-March/022339.html.

We can use this implementation along with the sysfs to load the devices runtime.

Possibly, but the actual data structures might end up differently when they are built around a sysfs interface. If you have a sysfs interface, it is more important to have that in a clean way than the board file, so we should first discuss the set of sysfs attributes that you are going to need, and then see how to represent that in platform data for predefined boards.

Quoted 3 lines

The configs that I have in the board_file for the devices
structure, are fixed for a board. To swap the boards, we do not need to re-compile the kernel.

The other point to consider is that we are definitely moving towards the flattened device tree for these definitions now. It's probably good to make the sysfs attributes directly correspond to fdt device properties. I'm not sure if we also need to allow platform data. The easiest way could be to just require the use of device tree for predefined pruss devices.

I'm sorry that this is moving in a different direction now, you had an unfortunate timing here.

Let's first discuss the exact properties that are really required to define the differences between PRU backends, as those will be required in any case. What do you need for PRU specific data besides the firmware and the name of the device?

Arnd

#31 lore raw

Re: [PATCH v4 01/11] mfd: add pruss mfd driver.

Hi Arnd,

Quoted 24 lines
Quoted 5 lines

http://linux.omap.com/pipermail/davinci-linux-open-source/
2011-March/022339.html.

We can use this implementation along with the sysfs to load the devices runtime.

Possibly, but the actual data structures might end up differently when they are built around a sysfs interface. If you have a sysfs interface, it is more important to have that in a clean way than the board file, so we should first discuss the set of sysfs attributes that you are going to need, and then see how to represent that in platform data for predefined boards.

Quoted 3 lines

The configs that I have in the board_file for the devices
structure, are fixed for a board. To swap the boards, we do not need to re-compile the kernel.

The other point to consider is that we are definitely moving towards the flattened device tree for these definitions now. It's probably good to make the sysfs attributes directly correspond to fdt device properties. I'm not sure if we also need to allow platform data. The easiest way could be to just require the use of device tree for predefined pruss devices.

Quoted 7 lines

I'm sorry that this is moving in a different direction now, you had an unfortunate timing here.

Let's first discuss the exact properties that are really required to define the differences between PRU backends, as those will be required in any case. What do you need for PRU specific data besides the firmware and the name of the device?

Would it be a good approach to first get a basic sensible driver into the tree and then work towards improving and adjusting for future compatibilities.
That way we can gradually build towards the perfect driver in steps, rather than digressing far too off suddenly. That would be some source of motivation for me too.

#32 lore raw

Re: [PATCH v4 01/11] mfd: add pruss mfd driver

Quoted 3 lines · Subhasish Ghosh

Would it be a good approach to first get a basic sensible driver into the tree and then work towards improving and adjusting for future compatibilities.

The main problem with that is that you cannot really change user-visible interfaces after the driver is merged. Anything regarding sysfs attributes and firmware file contents needs to be fixed. You can however still change in-kernel interfaces at a later point without problems.

Quoted 3 lines

That way we can gradually build towards the perfect driver in steps, rather than digressing far too off suddenly. That would be some source of motivation for me too.

You can definitely add the driver to drivers/staging/pruss/, as the rules for staging drivers are different. I think that would indeed be helpful at this point. As soon as all interfaces have stabilized, you can then move the individual parts to their final location.

Greg maintains the staging drivers, and he can surely point you to a document describing what is required for a driver. Mainly, this includes having a patch that adds a single directory with all the driver files under drivers/staging. The driver must be able to compile without errors and you need a TODO file listing the remaining issues that prevent you from having a non-staging driver.

I think the list will be relatively short, given that you have made a lot of progress and the driver is now essentially ready, aside from a few details and the big question of how the firmware should be configured and loaded.

Arnd

#33 lore raw

Re: [PATCH v4 01/11] mfd: add pruss mfd driver

Quoted 15 lines · Arnd Bergmann
Quoted 3 lines · Subhasish Ghosh

Would it be a good approach to first get a basic sensible driver into the tree and then work towards improving and adjusting for future compatibilities.

The main problem with that is that you cannot really change user-visible interfaces after the driver is merged. Anything regarding sysfs attributes and firmware file contents needs to be fixed. You can however still change in-kernel interfaces at a later point without problems.

Quoted 3 lines

That way we can gradually build towards the perfect driver in steps, rather than digressing far too off suddenly. That would be some source of motivation for me too.

Quoted 8 lines

You can definitely add the driver to drivers/staging/pruss/, as the rules for staging drivers are different. I think that would indeed be helpful at this point. As soon as all interfaces have stabilized, you can then move the individual parts to their final location.

Greg maintains the staging drivers, and he can surely point you to a document describing what is required for a driver.

There really are only 3 rules:
- proper license
- self-contained in a drivers/staging/DRIVER_NAME/ directory
- must properly build

Quoted 5 lines

Mainly, this includes having a patch that adds a single directory with all the driver files under drivers/staging. The driver must be able to compile without errors and you need a TODO file listing the remaining issues that prevent you from having a non-staging driver.

Ah, forgot the TODO on the list of rules, I'll have to add that next time.

Someone feel free to send me a patch :)

thanks,

greg k-h

#34 lore raw

Re: [PATCH v4 01/11] mfd: add pruss mfd driver

Greg,

Quoted 5 lines

There really are only 3 rules:
- proper license
- self-contained in a drivers/staging/DRIVER_NAME/ directory
- must properly build

Quoted 9 lines
Quoted 5 lines

Mainly, this includes having a patch that adds a single directory with all the driver files under drivers/staging. The driver must be able to compile without errors and you need a TODO file listing the remaining issues that prevent you from having a non-staging driver.

Ah, forgot the TODO on the list of rules, I'll have to add that next time.

How do I handle the headers. I have two header files in the include/linux/mfd.

Should I submit them as a separate patch into mfd.

These headers are also used by pruss uart implementation.

#35 lore raw

Re: [PATCH v4 01/11] mfd: add pruss mfd driver

Quoted 13 lines · Subhasish Ghosh

Greg,

Quoted 11 lines

There really are only 3 rules:
- proper license
- self-contained in a drivers/staging/DRIVER_NAME/ directory
- must properly build

Quoted 5 lines

Mainly, this includes having a patch that adds a single directory with all the driver files under drivers/staging. The driver must be able to compile without errors and you need a TODO file listing the remaining issues that prevent you from having a non-staging driver.

Quoted 5 lines
Quoted 3 lines

Ah, forgot the TODO on the list of rules, I'll have to add that next time.

How do I handle the headers. I have two header files in the include/linux/mfd.

Why would they be in there for a single driver?

Quoted 3 lines

Should I submit them as a separate patch into mfd.

These headers are also used by pruss uart implementation.

Then put them in the staging directory for your driver, why would anything outside of your driver need a .h file?

thanks,

greg k-h

#36 lore raw

Re: [PATCH v4 01/11] mfd: add pruss mfd driver

Greg,

Quoted 4 lines
Quoted 3 lines
Quoted 1 line

How do I handle the headers. I have two header files in the include/linux/mfd.

Quoted 9 lines

Why would they be in there for a single driver?

Quoted 3 lines

Should I submit them as a separate patch into mfd.

These headers are also used by pruss uart implementation.

Then put them in the staging directory for your driver, why would anything outside of your driver need a .h file?

There are two header files in the include/linux/mfd/pruss.h & pruss_core.h

the file pruss.h is included by the pruss_suart_api.c (tty uart driver) for some data structures, defines and function prototypes.

#37 lore raw

Re: [PATCH v4 01/11] mfd: add pruss mfd driver

In reply to Subhasish Ghosh
Quoted 9 lines · Subhasish Ghosh
Quoted 3 lines

Ah, forgot the TODO on the list of rules, I'll have to add that next time.

How do I handle the headers. I have two header files in the include/linux/mfd.

Should I submit them as a separate patch into mfd.

These headers are also used by pruss uart implementation.

During the time when the drivers are in staging, all files need to be in the same directory, including the header and the drivers using it. They can get moved at the time when the driver gets turned into a regular non-staging driver.

Arnd

#38 lore raw

Re: [PATCH v4 01/11] mfd: add pruss mfd driver

Quoted 7 lines · Subhasish Ghosh
Quoted 6 lines
Quoted 3 lines

Ah, forgot the TODO on the list of rules, I'll have to add that next time.

How do I handle the headers. I have two header files in the include/linux/mfd.

Quoted 8 lines
Quoted 3 lines

Should I submit them as a separate patch into mfd.

These headers are also used by pruss uart implementation.

During the time when the drivers are in staging, all files need to be in the same directory, including the header and the drivers using it. They can get moved at the time when the driver gets turned into a regular non-staging driver.

OK, so the UART implementation needs to be moved into staging as well ?

And what about the boardfile changes, array of mfd_cells implementation etc.

#39 lore raw

Re: [PATCH v4 01/11] mfd: add pruss mfd driver

Quoted 9 lines · Subhasish Ghosh
Quoted 5 lines

During the time when the drivers are in staging, all files need to be in the same directory, including the header and the drivers using it. They can get moved at the time when the driver gets turned into a regular non-staging driver.

OK, so the UART implementation needs to be moved into staging as well ?

And what about the boardfile changes, array of mfd_cells implementation etc.

All of that, too.

Note that you are citing exactly the points that are the reason for the discussion we are having. The mfd_cells are the main concern for the cases where the information is not static.

Arnd

#40 lore raw

Re: [PATCH v4 01/11] mfd: add pruss mfd driver

Quoted 9 lines · Subhasish Ghosh
Quoted 8 lines
Quoted 5 lines

During the time when the drivers are in staging, all files need to be in the same directory, including the header and the drivers using it. They can get moved at the time when the driver gets turned into a regular non-staging driver.

OK, so the UART implementation needs to be moved into staging as well ?

Quoted 7 lines
Quoted 1 line

And what about the boardfile changes, array of mfd_cells implementation etc.

All of that, too.

Note that you are citing exactly the points that are the reason for the discussion we are having. The mfd_cells are the main concern for the cases where the information is not static.

Yes, but by destroying the structure that I have currently in the platform files, I will be basically going backwards.

If only the platform_data is what is going to change with some additions of sysfs attributes, then will it be correct to have the platform data as an empty pointer and keep the rest as is ?

That way, I can keep the platform changes untouched and move just the drivers into staging.

I cannot destroy the complete platform code as there are other drivers (PRUSS UIO) depending on them.

#41 lore raw

Re: [PATCH v4 01/11] mfd: add pruss mfd driver.

In reply to Arnd Bergmann

Hi Arnd,

Quoted 6 lines · Arnd Bergmann
Quoted 5 lines · Mark Brown
Quoted 4 lines

Will a misc device be a better choice.

In that case I can remove the MFD cell from the board_file and add an array of platform_device for the UART & CAN.

Quoted 7 lines
Quoted 3 lines

I think that for me so long as it can simultaneously do two unrelated functions which need to be arbitrated between there's probably a place for it in MFD, certainly at the minute.

I guess drivers/mfd would be a better place than drivers/misc, but it might not need to be an mfd driver in the sense that it registers mfd cells.

I agree with that. Although if it makes it to drivers/mfd/, I'd prefer to see it using the MF API.

Quoted 7 lines

The more important point is to remove the device registration from the board file. You definitely should not have the cells in the board file, but replacing them with platform devices in the board file makes it no better.

My whole point has been that you register them from the main pruss driver based on run-time data instead of compile-time pre-configured stuff in the board file.

That's certainly right.

Cheers,
Samuel.

Signature · 2 lines
Intel Open Source Technology Centre
http://oss.intel.com/
#42 lore raw

Re: [PATCH v4 01/11] mfd: add pruss mfd driver.

In reply to Arnd Bergmann

Hi Arnd,

Quoted 17 lines · Arnd Bergmann
Quoted 11 lines · Subhasish Ghosh
Quoted 6 lines

Please look into implementing one of the three I suggested before you go off in another direction. In case of the third one, the idea was to configure the name of the device for each pru using sysfs, which then gets bound to the driver, which loads its own firmware as you do today. Only in the first two suggestions, the mfd driver would be responsible for loading the firmware.

Ok, thanks for the clarification.
Instead of passing the device name, will it be ok to pass the mfd_id. The benefit will be that I can use the ID directly as an array index for the mfd_cell entries.

I think a device name would be clearer here, especially in order to avoid conflicts when the list gets extended in different ways depending on which kernel runs.

Quoted 5 lines

We had a little discussion at the Linaro Developer Summit about your driver and mfd drivers in general. There was a general feeling among some people (including me) that by the point you dynamically create the subdevices, MFD is probably not the right abstraction any more, as it does not provide any service that you need.

I agree it's not what it's been designed for.

Quoted 2 lines

Instead, maybe you can simply call platform_device_register at that stage to create the children and not use MFD at all.

The MFD APIs are slightly easier to use though, imho.

Quoted 3 lines

Samuel, can you comment on this as well? Do you still see pruss as an MFD driver when the uses are completely dynamic and determined by the firmware loaded into it?

Even though that is definitely not a typical MFD use case, I wouldn't object strongly against it. Right now mfd is probably the least worst choice for this kind of drivers, which still doesn't make it an ideal situation.

Cheers,
Samuel.

Signature · 2 lines
Intel Open Source Technology Centre
http://oss.intel.com/
#43 lore raw

Re: [PATCH v4 01/11] mfd: add pruss mfd driver.

Hi Samuel,

Quoted 15 lines · Samuel Ortiz
Quoted 6 lines · Arnd Bergmann

On Wednesday 11 May 2011, Subhasish Ghosh wrote:
We had a little discussion at the Linaro Developer Summit about your driver and mfd drivers in general. There was a general feeling among some people (including me) that by the point you dynamically create the subdevices, MFD is probably not the right abstraction any more, as it does not provide any service that you need.

I agree it's not what it's been designed for.

Quoted 2 lines

Instead, maybe you can simply call platform_device_register at that stage to create the children and not use MFD at all.

The MFD APIs are slightly easier to use though, imho.

Quoted 6 lines
Quoted 3 lines

Samuel, can you comment on this as well? Do you still see pruss as an MFD driver when the uses are completely dynamic and determined by the firmware loaded into it?

Even though that is definitely not a typical MFD use case, I wouldn't object strongly against it. Right now mfd is probably the least worst choice for this kind of drivers, which still doesn't make it an ideal situation.

Thanks for your input! When you say that MFD APIs are easier to use than platform_device APIs, is that something we should fix with platform devices to make them easier to use?

Arnd

#44 lore raw

PATCH v4 2/11 da850: add pruss clock.

In reply to Subhasish Ghosh

This patch adds the PRUSS clock.

---
 arch/arm/mach-davinci/da850.c |    7 +++++++
 1 files changed, 7 insertions(+), 0 deletions(-)
arch/arm/mach-davinci/da850.c +7 -0
index 2d50885..a7cf2d0 100644
@@ -238,6 +238,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,
@@ -401,6 +407,7 @@ static struct clk_lookup da850_clks[] = {
 	CLK(NULL,		"tpcc1",	&tpcc1_clk),
 	CLK(NULL,		"tptc2",	&tptc2_clk),
 	CLK(NULL,		"uart0",	&uart0_clk),
+	CLK(NULL,		"pruss",	&pruss_clk),
 	CLK(NULL,		"uart1",	&uart1_clk),
 	CLK(NULL,		"uart2",	&uart2_clk),
 	CLK(NULL,		"aintc",	&aintc_clk),
Signature · 1 line
1.7.2.3
#45 lore raw

PATCH v4 3/11 da850: pruss platform specific additions.

In reply to Subhasish Ghosh

This patch adds the platform device and assignes the platform resources for the PRUSS mfd driver.

---
 arch/arm/mach-davinci/devices-da8xx.c      |   63 ++++++++++++++++++++++++++++
 arch/arm/mach-davinci/include/mach/da8xx.h |    4 ++
 2 files changed, 67 insertions(+), 0 deletions(-)
arch/arm/mach-davinci/devices-da8xx.c +63 -0
index 625d4b6..f51c9ad 100644
@@ -20,6 +20,7 @@
 #include <mach/time.h>
 #include <mach/da8xx.h>
 #include <mach/cpuidle.h>
+#include <linux/mfd/pruss.h>
 
 #include "clock.h"
 
@@ -510,6 +511,68 @@ void __init da8xx_register_mcasp(int id, struct snd_platform_data *pdata)
 	}
 }
 
+static struct resource da8xx_pruss_resources[] = {
+	{
+		.name	= "da8xx_pruss",
+		.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_mfddev = {
+	.name		= "pruss_mfd",
+	.id		= -1,
+	.num_resources	= ARRAY_SIZE(da8xx_pruss_resources),
+	.resource	= da8xx_pruss_resources,
+};
+
+int __init da8xx_register_pruss_mfd(struct mfd_cell *cell)
+{
+	da8xx_pruss_mfddev.dev.platform_data = cell;
+	return platform_device_register(&da8xx_pruss_mfddev);
+}
+
 static const struct display_panel disp_panel = {
 	QVGA,
 	16,
arch/arm/mach-davinci/include/mach/da8xx.h +4 -0
index 09b8ddb..0c23035 100644
@@ -16,6 +16,8 @@
 #include <linux/platform_device.h>
 #include <linux/davinci_emac.h>
 #include <linux/spi/spi.h>
+#include <linux/mfd/pruss.h>
+#include <linux/mfd/core.h>
 
 #include <mach/serial.h>
 #include <mach/edma.h>
@@ -73,6 +75,7 @@ extern unsigned int da850_max_speed;
 #define DA8XX_DDR2_CTL_BASE	0xb0000000
 #define DA8XX_ARM_RAM_BASE	0xffff0000
 #define DA8XX_SHARED_RAM_BASE	0x80000000
+#define DA8XX_PRUSS_MEM_BASE	0x01C30000
 
 void __init da830_init(void);
 void __init da850_init(void);
@@ -85,6 +88,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_mfd(struct mfd_cell *);
 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.2.3
#46 lore raw

Re: [PATCH v4 03/11] da850: pruss platform specific additions.

Hello.

Quoted 4 lines · Subhasish Ghosh

This patch adds the platform device and assignes the platform resources for the PRUSS mfd driver.

[...]

Quoted 4 lines
arch/arm/mach-davinci/include/mach/da8xx.h +0 -0
index 09b8ddb..0c23035 100644

[...]

arch/arm/mach-davinci/include/mach/da8xx.h extern unsigned int da850_max_speed; · line 78

Quoted 6 lines
  #include<mach/edma.h>
arch/arm/mach-davinci/include/mach/da8xx.h +1 -0
@@ -73,6 +75,7 @@ extern unsigned int da850_max_speed;
  #define DA8XX_DDR2_CTL_BASE	0xb0000000
  #define DA8XX_ARM_RAM_BASE	0xffff0000
  #define DA8XX_SHARED_RAM_BASE	0x80000000
+#define DA8XX_PRUSS_MEM_BASE	0x01C30000

Keep the list sorted please. Also, this macro doesn't seem used outside
devices-da8xx.c, so should be moved there...

WBR, Sergei

#47 lore raw

Re: [PATCH v4 03/11] da850: pruss platform specific additions.

Quoted 10 lines

arch/arm/mach-davinci/include/mach/da8xx.h extern unsigned int da850_max_speed; · line 78

Quoted 7 lines
  #include<mach/edma.h>
arch/arm/mach-davinci/include/mach/da8xx.h +1 -0
@@ -73,6 +75,7 @@ extern unsigned int da850_max_speed;
  #define DA8XX_DDR2_CTL_BASE 0xb0000000
  #define DA8XX_ARM_RAM_BASE 0xffff0000
  #define DA8XX_SHARED_RAM_BASE 0x80000000
+#define DA8XX_PRUSS_MEM_BASE 0x01C30000

Keep the list sorted please. Also, this macro doesn't seem used outside
devices-da8xx.c, so should be moved there...

SG - But would it not be better to have all device addresses at the same place.

#48 lore raw

Re: [PATCH v4 03/11] da850: pruss platform specific additions.

Hello.

Quoted 11 lines · Subhasish Ghosh
Quoted 9 lines

arch/arm/mach-davinci/include/mach/da8xx.h extern unsigned int da850_max_speed; · line 78

Quoted 6 lines

#include<mach/edma.h>

arch/arm/mach-davinci/include/mach/da8xx.h +1 -0
@@ -73,6 +75,7 @@ extern unsigned int da850_max_speed;
 #define DA8XX_DDR2_CTL_BASE 0xb0000000
 #define DA8XX_ARM_RAM_BASE 0xffff0000
 #define DA8XX_SHARED_RAM_BASE 0x80000000
+#define DA8XX_PRUSS_MEM_BASE 0x01C30000

Keep the list sorted please. Also, this macro doesn't seem used outside devices-da8xx.c, so should be moved there...

SG - But would it not be better to have all device addresses at the same place.

They are not at the same place already -- which is intentional. The ones
used locally in devices-da8xx.c should be #define'd there.

WBR, Sergei

#49 lore raw

Re: [PATCH v4 03/11] da850: pruss platform specific additions.

Quoted 10 lines
Quoted 9 lines
Quoted 9 lines

arch/arm/mach-davinci/include/mach/da8xx.h extern unsigned int da850_max_speed; · line 78

Quoted 6 lines

#include<mach/edma.h>

arch/arm/mach-davinci/include/mach/da8xx.h +1 -0
@@ -73,6 +75,7 @@ extern unsigned int da850_max_speed;
 #define DA8XX_DDR2_CTL_BASE 0xb0000000
 #define DA8XX_ARM_RAM_BASE 0xffff0000
 #define DA8XX_SHARED_RAM_BASE 0x80000000
+#define DA8XX_PRUSS_MEM_BASE 0x01C30000

Keep the list sorted please. Also, this macro doesn't seem used outside devices-da8xx.c, so should be moved there...

Quoted 4 lines
Quoted 1 line

SG - But would it not be better to have all device addresses at the same place.

They are not at the same place already -- which is intentional. The
ones used locally in devices-da8xx.c should be #define'd there.

SG -- Ok, Will do

#50 lore raw

PATCH v4 4/11 da850: pruss board specific additions.

In reply to Subhasish Ghosh

This patch adds board specific initializations and setup routines.

---
 arch/arm/mach-davinci/board-da850-evm.c |   14 ++++++++++++++
 1 files changed, 14 insertions(+), 0 deletions(-)
arch/arm/mach-davinci/board-da850-evm.c +14 -0
index a7b41bf..0b6b948 100644
@@ -1117,6 +1117,15 @@ static __init int da850_evm_init_cpufreq(void)
 static __init int da850_evm_init_cpufreq(void) { return 0; }
 #endif
 
+static struct mfd_cell cell[] = {
+	{.name = NULL,},
+};
+
+static int __init da8xx_evm_setup_pruss(void)
+{
+	return da8xx_register_pruss_mfd(cell);
+}
+
 static __init void da850_evm_init(void)
 {
 	int ret;
@@ -1191,6 +1200,11 @@ static __init void da850_evm_init(void)
 
 	da8xx_register_mcasp(0, &da850_evm_snd_data);
 
+	ret = da8xx_evm_setup_pruss();
+	if (ret)
+		pr_warning("%s: pruss initialization failed: %d\n",
+				__func__, ret);
+
 	ret = davinci_cfg_reg_list(da850_lcdcntl_pins);
 	if (ret)
 		pr_warning("da850_evm_init: lcdcntl mux setup failed: %d\n",
Signature · 1 line
1.7.2.3
#51 lore raw

PATCH v4 5/11 mfd: pruss SUART private data.

In reply to Subhasish Ghosh

This patch adds the PRUSS SUART data.

---
 include/linux/mfd/pruss.h |    5 +++++
 1 files changed, 5 insertions(+), 0 deletions(-)
include/linux/mfd/pruss.h +5 -0
index 8ef25b3..c5e2af2 100644
@@ -87,6 +87,11 @@
 #define PRU_INTC_CHANMAP12_HALF		(0x00010908)
 #define PRU_INTC_REGMAP_MASK		(0xFFFFFFFF)
 
+struct da850_evm_pruss_suart_data {
+	u32 version;
+	int (*setup)(void);
+};
+
 s32 pruss_enable(struct device *dev, u8 pruss_num);
 
 s32 pruss_load(struct device *dev, u8 pruss_num,
Signature · 1 line
1.7.2.3
#52 lore raw

PATCH v4 6/11 da850: pruss SUART board specific additions.

In reply to Subhasish Ghosh

This patch adds the pruss SUART pin mux and registers the device with the pruss mfd driver.

---
 arch/arm/mach-davinci/board-da850-evm.c |   46 ++++++++++++++++++++++++++++++-
 1 files changed, 45 insertions(+), 1 deletions(-)
arch/arm/mach-davinci/board-da850-evm.c +45 -1
index 0b6b948..e7fdf31 100644
@@ -1117,8 +1117,52 @@ static __init int da850_evm_init_cpufreq(void)
 static __init int da850_evm_init_cpufreq(void) { return 0; }
 #endif
 
+static const short da850_evm_pruss_suart_pins[] = {
+	DA850_AHCLKX, DA850_ACLKX, DA850_AFSX,
+	DA850_AHCLKR, DA850_ACLKR, DA850_AFSR,
+	DA850_AXR_13, DA850_AXR_9, DA850_AXR_7,
+	DA850_AXR_14, DA850_AXR_10, DA850_AXR_8,
+	-1
+};
+
+static int __init da850_evm_pruss_suart_setup(void)
+{
+	int ret;
+
+	ret = davinci_cfg_reg_list(da850_evm_pruss_suart_pins);
+	if (ret)
+		pr_warning("%s: da850_evm_pruss_suart_pins "
+			"mux setup failed: %d\n", __func__, ret);
+	return ret;
+}
+
+static struct da850_evm_pruss_suart_data suart_data = {
+	.version	= 1,
+	.setup		= da850_evm_pruss_suart_setup,
+};
+
+static struct resource da850_evm_pruss_suart_resource[] = {
+	{
+		.name	= "da8xx_mcasp0_iomem",
+		.start	= DAVINCI_DA8XX_MCASP0_REG_BASE,
+		.end	= DAVINCI_DA8XX_MCASP0_REG_BASE +
+				(SZ_1K * 12) - 1,
+		.flags	= IORESOURCE_MEM,
+	},
+};
+
 static struct mfd_cell cell[] = {
-	{.name = NULL,},
+	{
+		.id		= 0,
+		.name		= "da8xx_pruss_uart",
+		.platform_data	= &suart_data,
+		.data_size	= sizeof(suart_data),
+		.num_resources  = ARRAY_SIZE(da850_evm_pruss_suart_resource),
+		.resources	= da850_evm_pruss_suart_resource,
+	},
+	{
+		.name		= NULL,
+	},
 };
 
 static int __init da8xx_evm_setup_pruss(void)
Signature · 1 line
1.7.2.3
#53 lore raw

PATCH v4 7/11 da850: pruss SUART platform specific additions.

In reply to Subhasish Ghosh

This patch adds the McASP clock alias.
The alias is used by the pruss suart driver
for enabling the McASP PSC.

---
 arch/arm/mach-davinci/devices-da8xx.c |   18 ++++++++++++++++++
 1 files changed, 18 insertions(+), 0 deletions(-)
arch/arm/mach-davinci/devices-da8xx.c +18 -0
index f51c9ad..8f41ae4 100644
@@ -567,9 +567,27 @@ static struct platform_device da8xx_pruss_mfddev = {
 	.resource	= da8xx_pruss_resources,
 };
 
+#ifdef CONFIG_SERIAL_PRUSS_SUART_MODULE
+static int da8xx_mcasp_clk_add_alias(void)
+{
+	return clk_add_alias(NULL, "da8xx_pruss_uart.0",
+			NULL, &da850_mcasp_device.dev);
+}
+#else
+static int da8xx_mcasp_clk_add_alias(void)
+{
+	return 0;
+}
+#endif
 int __init da8xx_register_pruss_mfd(struct mfd_cell *cell)
 {
+	int ret;
+
 	da8xx_pruss_mfddev.dev.platform_data = cell;
+
+	ret = da8xx_mcasp_clk_add_alias();
+	if (ret < 0)
+		return ret;
 	return platform_device_register(&da8xx_pruss_mfddev);
 }
 
Signature · 1 line
1.7.2.3
#54 lore raw

PATCH v4 8/11 tty: add pruss SUART driver

In reply to Subhasish Ghosh

This patch adds support for the TTY compliant
Soft-UART device emulated on PRUSS.

This patch depends on:
davinci: macro rename DA8XX_LPSC0_DMAX to DA8XX_LPSC0_PRUSS.

            https://patchwork.kernel.org/patch/615681/
davinci: changed SRAM allocator to shared ram.
            https://patchwork.kernel.org/patch/549351/
---
 drivers/tty/serial/Kconfig             |   18 +
 drivers/tty/serial/Makefile            |    6 +
 drivers/tty/serial/pruss_suart.c       | 1061 ++++++++++++++++++++
 drivers/tty/serial/pruss_suart.h       | 1038 +++++++++++++++++++
 drivers/tty/serial/pruss_suart_api.c   | 1710 ++++++++++++++++++++++++++++++++
 drivers/tty/serial/pruss_suart_utils.c |  393 ++++++++
 include/linux/serial_core.h            |    2 +
 7 files changed, 4228 insertions(+), 0 deletions(-)
 create mode 100644 drivers/tty/serial/pruss_suart.c
 create mode 100644 drivers/tty/serial/pruss_suart.h
 create mode 100644 drivers/tty/serial/pruss_suart_api.c
 create mode 100644 drivers/tty/serial/pruss_suart_utils.c
drivers/tty/serial/Kconfig +18 -0
index 2b83346..6c26ebf 100644
@@ -1596,4 +1596,22 @@ config SERIAL_PCH_UART
 	  This driver is for PCH(Platform controller Hub) UART of Intel EG20T
 	  which is an IOH(Input/Output Hub) for x86 embedded processor.
 	  Enabling PCH_DMA, this PCH UART works as DMA mode.
+
+config SERIAL_PRUSS_SUART
+	depends on ARCH_DAVINCI && ARCH_DAVINCI_DA850
+	select SERIAL_CORE
+	tristate "PRUSS based SoftUART emulation on DA8XX"
+	---help---
+	This driver emulates up to eight different UARTs on the PRUSS.
+	You may modify the NR_SUARTS macro in the driver to emulate
+	less number of UARTS as per your requirement.
+	If not sure, mark No
+
+config PRUSS_SUART_MCASP
+	depends on ARCH_DAVINCI_DA830 && SERIAL_PRUSS_SUART
+	default "0"
+	int "McASP number"
+	---help---
+	Enter the McASP number to use with SUART (0, 1 or 2).
+	You will need to recompile the kernel if this is changed.
 endmenu
drivers/tty/serial/Makefile +6 -0
index 8ea92e9..e1eaaf3 100644
@@ -92,3 +92,9 @@ obj-$(CONFIG_SERIAL_MRST_MAX3110)	+= mrst_max3110.o
 obj-$(CONFIG_SERIAL_MFD_HSU)	+= mfd.o
 obj-$(CONFIG_SERIAL_IFX6X60)  	+= ifx6x60.o
 obj-$(CONFIG_SERIAL_PCH_UART)	+= pch_uart.o
+
+pruss_uart-objs :=	pruss_suart.o \
+			pruss_suart_api.o \
+			pruss_suart_utils.o
+
+obj-$(CONFIG_SERIAL_PRUSS_SUART) += pruss_uart.o
drivers/tty/serial/pruss_suart.c new file +1061 -0

1,061 lines not on this page · raw message

drivers/tty/serial/pruss_suart.h new file +1038 -0

1,038 lines not on this page · raw message

drivers/tty/serial/pruss_suart_api.c new file +1710 -0

870 lines not on this page · raw message

drivers/tty/serial/pruss_suart_utils.c new file +393 -0

393 lines not on this page · raw message

include/linux/serial_core.h +2 -0
index 758c5b0..eae37fe 100644

Lines of this file are not shown. View the raw message.

The rest of this diff is not shown. View the raw message.

Signature · 1 line
1.7.2.3

Part of the diff is not shown here. View the raw message.

#55 lore raw

Re: [PATCH v4 08/11] tty: add pruss SUART driver

Quoted 8 lines · Subhasish Ghosh

This patch adds support for the TTY compliant
Soft-UART device emulated on PRUSS.

This patch depends on:
davinci: macro rename DA8XX_LPSC0_DMAX to DA8XX_LPSC0_PRUSS.

            https://patchwork.kernel.org/patch/615681/
davinci: changed SRAM allocator to shared ram.
            https://patchwork.kernel.org/patch/549351/

Who is going to be applying these patches to the tree?

Should this driver go through a davinci subtree because of these dependancies?

thanks,

greg k-h

#56 lore raw

RE: [PATCH v4 08/11] tty: add pruss SUART driver

Quoted 7 lines · Greg KH
Quoted 6 lines · Subhasish Ghosh

This patch adds support for the TTY compliant
Soft-UART device emulated on PRUSS.

This patch depends on:
davinci: macro rename DA8XX_LPSC0_DMAX to DA8XX_LPSC0_PRUSS.

            https://patchwork.kernel.org/patch/615681/

This is already in mainline. Plus this patch
doesn't really seem to depend on this commit.

Quoted 2 lines
Quoted 2 lines

davinci: changed SRAM allocator to shared ram.

            https://patchwork.kernel.org/patch/549351/

There should be no build time dependency with this patch (the above patch just changes which pool of SRAM the allocation happens from)

But, this brings out an important dependency of the patch calling platform specific sram allocator functions. There has been SRAM allocator consolidation work done by Russell and as a result the SRAM allocator API for DaVinci will actually change. The driver should probably just get sram space through platform data so that it doesn't depend on the platform specific sram allocation function.

Quoted 5 lines

Who is going to be applying these patches to the tree?

Should this driver go through a davinci subtree because of these dependancies?

No, driver and platform changes can be merged separately if the above aspect is taken care of. Russell has been pushing back on merging driver patches through his tree unless absolutely required.

Thanks,
Sekhar

#57 lore raw

Re: [PATCH v4 08/11] tty: add pruss SUART driver

Quoted 19 lines · Sekhar
Quoted 7 lines · Greg KH
Quoted 6 lines · Subhasish Ghosh

This patch adds support for the TTY compliant
Soft-UART device emulated on PRUSS.

This patch depends on:
davinci: macro rename DA8XX_LPSC0_DMAX to DA8XX_LPSC0_PRUSS.

            https://patchwork.kernel.org/patch/615681/

This is already in mainline. Plus this patch
doesn't really seem to depend on this commit.

Quoted 2 lines
Quoted 2 lines

davinci: changed SRAM allocator to shared ram.

            https://patchwork.kernel.org/patch/549351/

There should be no build time dependency with this patch (the above patch just changes which pool of SRAM the allocation happens from)

Quoted 7 lines

But, this brings out an important dependency of the patch calling platform specific sram allocator functions. There has been SRAM allocator consolidation work done by Russell and as a result the SRAM allocator API for DaVinci will actually change. The driver should probably just get sram space through platform data so that it doesn't depend on the platform specific sram allocation function.

Ok, care to fix up the code then?

Quoted 9 lines
Quoted 4 lines

Who is going to be applying these patches to the tree?

Should this driver go through a davinci subtree because of these dependancies?

No, driver and platform changes can be merged separately if the above aspect is taken care of. Russell has been pushing back on merging driver patches through his tree unless absolutely required.

That's fine, I'll take it through my tree then, care to resolve the above issue and resend it?

thanks,

greg k-h

#58 lore raw

Re: [PATCH v4 08/11] tty: add pruss SUART driver

Quoted 9 lines
Quoted 9 lines

There should be no build time dependency with this patch (the above patch just changes which pool of SRAM the allocation happens from)

But, this brings out an important dependency of the patch calling platform specific sram allocator functions. There has been SRAM allocator consolidation work done by Russell and as a result the SRAM allocator API for DaVinci will actually change.

I earlier had an implementation where I would get the sram memory addresses through the .resource structure and ioremap it in the driver.

Quoted 3 lines
Quoted 3 lines

The driver should probably just get sram
space through platform data so that it doesn't depend on the platform specific sram allocation function.

Are you suggesting that I go back to that implementation. Also, should I remove the dependency list from the patch comments then.

--------------------------------------------------
From: "Greg KH" <[email protected]>
Sent: Tuesday, April 26, 2011 6:15 PM
To: "Nori, Sekhar" <[email protected]>
Cc: "Greg KH" <[email protected]>; "Subhasish Ghosh" <[email protected]>; <[email protected]>; <[email protected]>; "Watkins, Melissa" <[email protected]>; <[email protected]>; "Andrew Morton" <[email protected]>; "Randy Dunlap" <[email protected]>; "open list" <[email protected]>
Subject: Re: [PATCH v4 08/11] tty: add pruss SUART driver

Quoted 46 lines · Sekhar
Quoted 19 lines · Greg KH
Quoted 7 lines · Subhasish Ghosh
Quoted 6 lines

This patch adds support for the TTY compliant
Soft-UART device emulated on PRUSS.

This patch depends on:
davinci: macro rename DA8XX_LPSC0_DMAX to DA8XX_LPSC0_PRUSS.

            https://patchwork.kernel.org/patch/615681/

This is already in mainline. Plus this patch
doesn't really seem to depend on this commit.

Quoted 2 lines
Quoted 2 lines

davinci: changed SRAM allocator to shared ram.

            https://patchwork.kernel.org/patch/549351/

There should be no build time dependency with this patch (the above patch just changes which pool of SRAM the allocation happens from)

Quoted 7 lines

But, this brings out an important dependency of the patch calling platform specific sram allocator functions. There has been SRAM allocator consolidation work done by Russell and as a result the SRAM allocator API for DaVinci will actually change. The driver should probably just get sram space through platform data so that it doesn't depend on the platform specific sram allocation function.

Ok, care to fix up the code then?

Quoted 9 lines
Quoted 4 lines

Who is going to be applying these patches to the tree?

Should this driver go through a davinci subtree because of these dependancies?

No, driver and platform changes can be merged separately if the above aspect is taken care of. Russell has been pushing back on merging driver patches through his tree unless absolutely required.

That's fine, I'll take it through my tree then, care to resolve the above issue and resend it?

thanks,

greg k-h

#59 lore raw

RE: [PATCH v4 08/11] tty: add pruss SUART driver

Quoted 4 lines · Subhasish Ghosh
Quoted 4 lines
Quoted 4 lines

There should be no build time dependency with this patch (the above patch just changes which pool of SRAM the allocation happens from)

Quoted 8 lines
Quoted 5 lines
Quoted 5 lines

But, this brings out an important dependency of the patch calling platform specific sram allocator functions. There has been SRAM allocator consolidation work done by Russell and as a result the SRAM allocator API for DaVinci will actually change.

I earlier had an implementation where I would get the sram memory addresses through the .resource structure and ioremap it in the driver.

This is wrong since it assumes the whole SRAM is available for usage by your driver. We already have an allocator for SRAM.

Quoted 6 lines
Quoted 4 lines
Quoted 4 lines

The driver should probably just get sram
space through platform data so that it doesn't depend on the platform specific sram allocation function.

Are you suggesting that I go back to that implementation.

No, the platform code should use the SRAM allocator and pass on the allocated memory to the driver.

Thanks,
Sekhar

#60 lore raw

Re: [PATCH v4 08/11] tty: add pruss SUART driver

Quoted 8 lines
Quoted 5 lines
Quoted 3 lines
Quoted 3 lines

The driver should probably just get sram
space through platform data so that it doesn't depend on the platform specific sram allocation function.

Are you suggesting that I go back to that implementation.

No, the platform code should use the SRAM allocator and pass on the allocated memory to the driver.

SG - So, should I call the sram_alloc() in the platform setup function. Something like this:

suart_probe() {
...
pdata.setup(&sram_aadr);
...use sram data;
}

suart_remove() {
...
pdata.free(&sram_aadr);
...
}

#61 lore raw

RE: [PATCH v4 08/11] tty: add pruss SUART driver

Hi Subhasish,

Quoted 10 lines · Subhasish Ghosh
Quoted 8 lines
Quoted 5 lines
Quoted 3 lines
Quoted 3 lines

The driver should probably just get sram
space through platform data so that it doesn't depend on the platform specific sram allocation function.

Are you suggesting that I go back to that implementation.

No, the platform code should use the SRAM allocator and pass on the allocated memory to the driver.

SG - So, should I call the sram_alloc() in the platform setup function.

Can you please shed some light on how SRAM is being used in the driver? Looking at the driver, it looks like it is used as a shared buffer between the PRU firmware and kernel.

If yes, how do you cope with dynamic allocation of SRAM? That is, how do you inform the firmware what portion of SRAM has been allocated to the driver?

Also, usage of SRAM is not required for basic driver function, correct? So, a platform which does not have SRAM to spare for this driver could still have a portion of SDRAM/DDR allocated to be used as the shared buffer? I guess SRAM was used only for lower access times. But it should still be possible to sustain lower baudrates with SDRAM/DDR?

Thanks,
Sekhar

#62 lore raw

Re: [PATCH v4 08/11] tty: add pruss SUART driver

Quoted 25 lines

Hi Subhasish,

Quoted 10 lines · Subhasish Ghosh
Quoted 8 lines
Quoted 5 lines
Quoted 3 lines
Quoted 3 lines

The driver should probably just get sram
space through platform data so that it doesn't depend on the platform specific sram allocation function.

Are you suggesting that I go back to that implementation.

No, the platform code should use the SRAM allocator and pass on the allocated memory to the driver.

SG - So, should I call the sram_alloc() in the platform setup function.

Can you please shed some light on how SRAM is being used in the driver? Looking at the driver, it looks like it is used as a shared buffer between the PRU firmware and kernel.

If yes, how do you cope with dynamic allocation of SRAM? That is, how do you inform the firmware what portion of SRAM has been allocated to the driver?

Quoted 7 lines

Also, usage of SRAM is not required for basic driver function, correct? So, a platform which does not have SRAM to spare for this driver could still have a portion of SDRAM/DDR allocated to be used as the shared buffer? I guess SRAM was used only for lower access times. But it should still be possible to sustain lower baudrates with SDRAM/DDR?

The sram is allocated dynamically in the driver. After allocation, we write the pointer into the PRU, so in case the driver allocates memory form the DDR, it will write this info into the
PRU and it will work. But, because of DDR access latencies, the UART
will work only for lower baud rates.

#63 lore raw

RE: [PATCH v4 08/11] tty: add pruss SUART driver

Quoted 20 lines · Subhasish Ghosh
Quoted 12 lines
Quoted 1 line

SG - So, should I call the sram_alloc() in the platform setup function.

Can you please shed some light on how SRAM is being used in the driver? Looking at the driver, it looks like it is used as a shared buffer between the PRU firmware and kernel.

If yes, how do you cope with dynamic allocation of SRAM? That is, how do you inform the firmware what portion of SRAM has been allocated to the driver?

Quoted 7 lines

Also, usage of SRAM is not required for basic driver function, correct? So, a platform which does not have SRAM to spare for this driver could still have a portion of SDRAM/DDR allocated to be used as the shared buffer? I guess SRAM was used only for lower access times. But it should still be possible to sustain lower baudrates with SDRAM/DDR?

Quoted 5 lines

The sram is allocated dynamically in the driver.
After allocation, we write the pointer into the PRU, so in case the driver allocates memory form the DDR, it will write this info into the PRU and it will work. But, because of DDR access latencies, the UART will work only for lower baud rates.

Thanks for the clarification. In this case, the driver should use platform callbacks to get/put fast fifo space. In case this callback is not populated by the platform or returns an error, the driver should fall back to allocating from DDR.

Thanks,
Sekhar

#64 lore raw

Re: [PATCH v4 08/11] tty: add pruss SUART driver

In reply to Nori, Sekhar
Quoted 10 lines
Quoted 6 lines
Quoted 4 lines
Quoted 4 lines

The driver should probably just get sram
space through platform data so that it doesn't depend on the platform specific sram allocation function.

Are you suggesting that I go back to that implementation.

No, the platform code should use the SRAM allocator and pass on the allocated memory to the driver.

Say, if the driver is loaded as a module.
If I allocate the sram in the platform code, how to I free it when the driver is unloaded.

#65 lore raw

RE: [PATCH v4 08/11] tty: add pruss SUART driver

Quoted 7 lines · Subhasish Ghosh
Quoted 7 lines
Quoted 6 lines
Quoted 4 lines
Quoted 4 lines

The driver should probably just get sram
space through platform data so that it doesn't depend on the platform specific sram allocation function.

Are you suggesting that I go back to that implementation.

Quoted 7 lines
Quoted 3 lines

No, the platform code should use the SRAM allocator and pass on the allocated memory to the driver.

Say, if the driver is loaded as a module.
If I allocate the sram in the platform code, how to I free it when the driver is unloaded.

This is what I said in my last e-mail. What is
the issue you see with this approach?

| Thanks for the clarification. In this case, the driver
| should use platform callbacks to get/put fast fifo
| space. In case this callback is not populated by the
| platform or returns an error, the driver should fall
| back to allocating from DDR.

Thanks,
Sekhar

#66 lore raw

Re: [PATCH v4 08/11] tty: add pruss SUART driver

Quoted 5 lines
Quoted 4 lines

Say, if the driver is loaded as a module.
If I allocate the sram in the platform code, how to I free it when the driver is unloaded.

Quoted 9 lines

This is what I said in my last e-mail. What is
the issue you see with this approach?

| Thanks for the clarification. In this case, the driver
| should use platform callbacks to get/put fast fifo
| space. In case this callback is not populated by the
| platform or returns an error, the driver should fall
| back to allocating from DDR.

ok, so what you are suggesting is that I implement some callbacks (like .fifo_alloc, .fifo_dealloc) which can allocate memory using sram_alloc.
My doubt is, if already such API's are there (by Russel) or you are suggesting to implement them.

#67 lore raw

Re: [PATCH v4 08/11] tty: add pruss SUART driver

In reply to Subhasish Ghosh

Hi Greg,

I am observing a RX FIFO sized data loss problem with my driver.

I observed that if I start the TX before the RX, then there are no errors, but, if I start a TX after a RX, then I observe the error (FIFO sized data chunks missing).

Say, for example, if I use all three UARTS and on all three I start RX, then for every TX started I would observe
one error on all the RX data buffer.

So, if I start only two TX, then I will see only two errors on all the three RX UARTS.

#68 lore raw

Re: [PATCH v4 08/11] tty: add pruss SUART driver

Quoted 2 lines

I then modified this function to as follows and the error is not observed anymore.

That looks like you are somehow calling uart_carrier_raised somewhere with interrupts disabled ?

Alan

#69 lore raw

Re: [PATCH v4 08/11] tty: add pruss SUART driver

Quoted 6 lines
Quoted 2 lines

I then modified this function to as follows and the error is not observed anymore.

That looks like you are somehow calling uart_carrier_raised somewhere with interrupts disabled ?

I am not calling this function in my driver atall, this is getting called by tty_port.c

int tty_port_block_til_ready(struct tty_port *port,
struct tty_struct *tty, struct file *filp)
{
/* Probe the carrier. For devices with no carrier detect this

                  will always return true */
               cd = tty_port_carrier_raised(port);
               if (!(port->flags & ASYNC_CLOSING) &&
                               (do_clocal || cd))
                       break;
               if (signal_pending(current)) {
                       retval = -ERESTARTSYS;
                       break;
               }
#70 lore raw

Re: [PATCH v4 08/11] tty: add pruss SUART driver

Quoted 8 lines · On Mon, 9 May 2011 19:20:17 +0530 "Subhasish Ghosh"…
Quoted 6 lines
Quoted 2 lines

I then modified this function to as follows and the error is not observed anymore.

That looks like you are somehow calling uart_carrier_raised somewhere with interrupts disabled ?

I am not calling this function in my driver atall, this is getting called by tty_port.c

Can you verify the status of the interrupt flags at the point that routine is called in your code and get a backtrace of the path. It should never be gettng called with interrupts off, and if it is we need to know what the path is. Otherwise that code change would imply a bug in the core code for the platform which seems less likely.

#71 lore raw

Re: [PATCH v4 08/11] tty: add pruss SUART driver

Hi Alan,

Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
Quoted 2 lines

I then modified this function to as follows and the error is not observed anymore.

That looks like you are somehow calling uart_carrier_raised somewhere with interrupts disabled ?

Quoted 8 lines
Quoted 2 lines

I am not calling this function in my driver atall, this is getting called by tty_port.c

Can you verify the status of the interrupt flags at the point that routine is called in your code and get a backtrace of the path. It should never be gettng called with interrupts off, and if it is we need to know what the path is. Otherwise that code change would imply a bug in the core code for the platform which seems less likely.

Here is the back trace:

root@arago:~# ------------[ cut here ]------------
WARNING: at drivers/tty/serial/pruss_suart.c:295 uart_carrier_raised+0x2c/0x74()
Modules linked in: pruss_uart
[<c002e888>] (unwind_backtrace+0x0/0xec) from [<c003e400>] (warn_slowpath_common+0x4c/0x64)
[<c003e400>] (warn_slowpath_common+0x4c/0x64) from [<c003e430>] (warn_slowpath_null+0x18/0x1c)
[<c003e430>] (warn_slowpath_null+0x18/0x1c) from [<c0190744>] (uart_carrier_raised+0x2c/0x74)
[<c0190744>] (uart_carrier_raised+0x2c/0x74) from [<c0182b84>] (tty_port_carrier_raised+0x1c/0x20)
[<c0182b84>] (tty_port_carrier_raised+0x1c/0x20) from [<c0183174>] (tty_port_block_til_ready+0x254/0x328)
[<c0183174>] (tty_port_block_til_ready+0x254/0x328) from [<c017d3ac>] (tty_open+0x310/0x478)
[<c017d3ac>] (tty_open+0x310/0x478) from [<c009f5d8>] (chrdev_open+0x1b4/0x1d0)
[<c009f5d8>] (chrdev_open+0x1b4/0x1d0) from [<c009ae34>] (__dentry_open+0x170/0x27c)
[<c009ae34>] (__dentry_open+0x170/0x27c) from [<c009b008>] (nameidata_to_filp+0x50/0x5c)
[<c009b008>] (nameidata_to_filp+0x50/0x5c) from [<c00a70e0>] (finish_open+0x90/0x17c)
[<c00a70e0>] (finish_open+0x90/0x17c) from [<c00a8fa4>] (do_filp_open+0x23c/0x520)
[<c00a8fa4>] (do_filp_open+0x23c/0x520) from [<c009ac0c>] (do_sys_open+0x58/0xe4)
[<c009ac0c>] (do_sys_open+0x58/0xe4) from [<c0029fa0>] (ret_fast_syscall+0x0/0x2c)

flags ---> 0xA0000013

This is how I generated the trace:

static void pruss_suart_enable_ms(struct uart_port *port)

{
       struct omapl_pru_suart *soft_uart =
           container_of(port, struct omapl_pru_suart, port[port->line]);
       struct device *dev = soft_uart->dev;

       WARN_ON(1);
       dev_dbg(dev, "modem control timer not supported\n");
} 
#72 lore raw

Re: [PATCH v4 08/11] tty: add pruss SUART driver

Trace all looks fine. I can't see anything else taking the lock so you'll need to do a bit more debugging and find out why the spin lock change makes the difference and what the real root cause is.

#73 lore raw

Re: [PATCH v4 08/11] tty: add pruss SUART driver

Quoted 3 lines

Trace all looks fine. I can't see anything else taking the lock so you'll need to do a bit more debugging and find out why the spin lock change makes the difference and what the real root cause is.

We do not support Modem control signals. So, I use -clocal with stty, but I observe that still enable_ms and get_mctrl handlers get called. Is that normal, how can I disable these functions from getting called.

Actually, this same driver works perfectly with 2.6.33 kernel. With this Kernel I do not observe that these handlers getting called. So, basically the code path is different.

Further, I only use the port->lock to disable interrupts, so its never possible that
while interrupts are disabled by my driver, the TTY is executing anything.

There is another lock in the MFD driver, but that only uses spin_lock/unlock variant.

#74 lore raw

Re: [PATCH v4 08/11] tty: add pruss SUART driver

Quoted 3 lines

We do not support Modem control signals. So, I use -clocal with stty, but I observe that still enable_ms and get_mctrl handlers get called. Is that normal, how can I disable these functions from getting called.

It is normal.

Quoted 3 lines

Actually, this same driver works perfectly with 2.6.33 kernel. With this Kernel I do not observe that these handlers getting called. So, basically the code path is different.

Quite possibly - but you'll need to trace down and understand *why* the problem exists. Finding which kernel introduces it might be a step in the right direction.

Alan

#75 lore raw

PATCH v4 9/11 mfd: pruss CAN private data.

In reply to Subhasish Ghosh

This patch adds the PRUSS CAN data.

---
 include/linux/mfd/pruss.h |    5 +++++
 1 files changed, 5 insertions(+), 0 deletions(-)
include/linux/mfd/pruss.h +5 -0
index c5e2af2..3b46156 100644
@@ -92,6 +92,11 @@ struct da850_evm_pruss_suart_data {
 	int (*setup)(void);
 };
 
+struct da850_evm_pruss_can_data {
+	u32 version;
+	int (*setup)(void);
+};
+
 s32 pruss_enable(struct device *dev, u8 pruss_num);
 
 s32 pruss_load(struct device *dev, u8 pruss_num,
Signature · 1 line
1.7.2.3
#76 lore raw

PATCH v4 10/11 da850: pruss CAN platform specific additions.

In reply to Subhasish Ghosh

This patch adds the necessary pins for the pruss CAN.

---
 arch/arm/mach-davinci/da850.c            |    5 +++++
 arch/arm/mach-davinci/include/mach/mux.h |    5 +++++
 2 files changed, 10 insertions(+), 0 deletions(-)
arch/arm/mach-davinci/da850.c +5 -0
index a7cf2d0..84a5e64 100644
@@ -581,7 +581,12 @@ static const struct mux_config da850_pins[] = {
 	MUX_CFG(DA850, EMA_CLK,		6,	0,	15,	1,	false)
 	MUX_CFG(DA850, EMA_WAIT_1,	6,	24,	15,	1,	false)
 	MUX_CFG(DA850, NEMA_CS_2,	7,	0,	15,	1,	false)
+	/* PRU functions for soft CAN */
+	MUX_CFG(DA850, PRUSS_PRU0_R31_0,	7,	28,	15,	0,	false)
+	MUX_CFG(DA850, PRUSS_PRU1_R30_15,	12,	0,	15,	4,	false)
+	MUX_CFG(DA850, PRUSS_PRU1_R31_18,	11,	20,	15,	0,	false)
 	/* GPIO function */
+	MUX_CFG(DA850, GPIO2_0,		6,	28,	15,	8,	false)
 	MUX_CFG(DA850, GPIO2_4,		6,	12,	15,	8,	false)
 	MUX_CFG(DA850, GPIO2_6,		6,	4,	15,	8,	false)
 	MUX_CFG(DA850, GPIO2_8,		5,	28,	15,	8,	false)
arch/arm/mach-davinci/include/mach/mux.h +5 -0
index 5d4e0fe..85b3a0d 100644
@@ -906,8 +906,13 @@ enum davinci_da850_index {
 	DA850_EMA_CLK,
 	DA850_EMA_WAIT_1,
 	DA850_NEMA_CS_2,
+	/* PRU I/O */
+	DA850_PRUSS_PRU0_R31_0,
+	DA850_PRUSS_PRU1_R30_15,
+	DA850_PRUSS_PRU1_R31_18,
 
 	/* GPIO function */
+	DA850_GPIO2_0,
 	DA850_GPIO2_4,
 	DA850_GPIO2_6,
 	DA850_GPIO2_8,
Signature · 1 line
1.7.2.3
#77 lore raw

PATCH v4 11/11 da850: pruss CAN board specific additions.

In reply to Subhasish Ghosh

This patch adds the pruss CAN pinmux and registers the device with the pruss mfd driver.

---
 arch/arm/mach-davinci/board-da850-evm.c |   46 +++++++++++++++++++++++++++++++
 1 files changed, 46 insertions(+), 0 deletions(-)
arch/arm/mach-davinci/board-da850-evm.c +46 -0
index e7fdf31..e1ff18c 100644
@@ -48,6 +48,7 @@
 
 #define DA850_MMCSD_CD_PIN		GPIO_TO_PIN(4, 0)
 #define DA850_MMCSD_WP_PIN		GPIO_TO_PIN(4, 1)
+#define DA850_PRUSS_CAN_TRX_PIN		GPIO_TO_PIN(2, 0)
 
 #define DA850_MII_MDIO_CLKEN_PIN	GPIO_TO_PIN(2, 6)
 
@@ -1117,6 +1118,43 @@ static __init int da850_evm_init_cpufreq(void)
 static __init int da850_evm_init_cpufreq(void) { return 0; }
 #endif
 
+static const short da850_evm_pruss_can_pins[] = {
+	DA850_PRUSS_PRU0_R31_0, DA850_PRUSS_PRU1_R30_15,
+	DA850_PRUSS_PRU1_R31_18, DA850_GPIO2_0,
+	-1
+};
+
+static int __init da850_evm_pruss_can_setup(void)
+{
+	int ret, val = 0;
+	void __iomem *cfg_chip3_reg;
+
+	ret = davinci_cfg_reg_list(da850_evm_pruss_can_pins);
+	if (ret)
+		pr_warning("%s: da850_evm_pruss_can_pins mux setup "
+					"failed:%d\n", __func__, ret);
+	cfg_chip3_reg = DA8XX_SYSCFG0_VIRT(DA8XX_CFGCHIP3_REG);
+	val = __raw_readl(cfg_chip3_reg);
+	val |= BIT(3);
+	__raw_writel(val, cfg_chip3_reg);
+
+	/* value = 0 to enable the CAN transceiver */
+	ret = gpio_request_one(DA850_PRUSS_CAN_TRX_PIN,
+			GPIOF_OUT_INIT_LOW, "pruss_can_en");
+	if (ret) {
+		pr_warning("Cannot setup GPIO %d\n", DA850_PRUSS_CAN_TRX_PIN);
+		gpio_free(DA850_PRUSS_CAN_TRX_PIN);
+	}
+
+	return ret;
+}
+
+static struct da850_evm_pruss_can_data can_data = {
+	.version	= 1,
+	.setup		= da850_evm_pruss_can_setup,
+};
+
+
 static const short da850_evm_pruss_suart_pins[] = {
 	DA850_AHCLKX, DA850_ACLKX, DA850_AFSX,
 	DA850_AHCLKR, DA850_ACLKR, DA850_AFSR,
@@ -1161,6 +1199,14 @@ static struct mfd_cell cell[] = {
 		.resources	= da850_evm_pruss_suart_resource,
 	},
 	{
+		.id		= 1,
+		.name		= "da8xx_pruss_can",
+		.platform_data	= &can_data,
+		.data_size	= sizeof(can_data),
+		.num_resources  = 0,
+		.resources	= NULL,
+	},
+	{
 		.name		= NULL,
 	},
 };
Signature · 1 line
1.7.2.3
#78 lore raw

Re: [PATCH v4 11/11] da850: pruss CAN board specific additions.

Quoted 48 lines · Subhasish Ghosh

This patch adds the pruss CAN pinmux and registers the device with the pruss mfd driver.

---
 arch/arm/mach-davinci/board-da850-evm.c |   46 +++++++++++++++++++++++++++++++
 1 files changed, 46 insertions(+), 0 deletions(-)
arch/arm/mach-davinci/board-da850-evm.c +25 -0
index e7fdf31..e1ff18c 100644
@@ -48,6 +48,7 @@
 
 #define DA850_MMCSD_CD_PIN		GPIO_TO_PIN(4, 0)
 #define DA850_MMCSD_WP_PIN		GPIO_TO_PIN(4, 1)
+#define DA850_PRUSS_CAN_TRX_PIN		GPIO_TO_PIN(2, 0)
 
 #define DA850_MII_MDIO_CLKEN_PIN	GPIO_TO_PIN(2, 6)
 
@@ -1117,6 +1118,43 @@ static __init int da850_evm_init_cpufreq(void)
 static __init int da850_evm_init_cpufreq(void) { return 0; }
 #endif
 
+static const short da850_evm_pruss_can_pins[] = {
+	DA850_PRUSS_PRU0_R31_0, DA850_PRUSS_PRU1_R30_15,
+	DA850_PRUSS_PRU1_R31_18, DA850_GPIO2_0,
+	-1
+};
+
+static int __init da850_evm_pruss_can_setup(void)
+{
+	int ret, val = 0;
+	void __iomem *cfg_chip3_reg;
+
+	ret = davinci_cfg_reg_list(da850_evm_pruss_can_pins);
+	if (ret)
+		pr_warning("%s: da850_evm_pruss_can_pins mux setup "
+					"failed:%d\n", __func__, ret);
+	cfg_chip3_reg = DA8XX_SYSCFG0_VIRT(DA8XX_CFGCHIP3_REG);
+	val = __raw_readl(cfg_chip3_reg);
+	val |= BIT(3);
+	__raw_writel(val, cfg_chip3_reg);
+
+	/* value = 0 to enable the CAN transceiver */
+	ret = gpio_request_one(DA850_PRUSS_CAN_TRX_PIN,
+			GPIOF_OUT_INIT_LOW, "pruss_can_en");
+	if (ret) {

arch/arm/mach-davinci/board-da850-evm.c static __init int da850_evm_init_cpufreq(void) · line 1154

Quoted 10 lines
arch/arm/mach-davinci/board-da850-evm.c +10 -0
+		pr_warning("Cannot setup GPIO %d\n", DA850_PRUSS_CAN_TRX_PIN);
+		gpio_free(DA850_PRUSS_CAN_TRX_PIN);
+	}
+
+	return ret;
+}
+
+static struct da850_evm_pruss_can_data can_data = {
+	.version	= 1,
+	.setup		= da850_evm_pruss_can_setup,

I suggest to do the pinmux setup unconditionally before registering the can driver. Rename setup into transceiver_switch and extend the driver to switch on and off the transceiver. Call the transceiver switch from open and close in the can drver.

Quoted 11 lines
arch/arm/mach-davinci/board-da850-evm.c +4 -0
+};
+
+
 static const short da850_evm_pruss_suart_pins[] = {
 	DA850_AHCLKX, DA850_ACLKX, DA850_AFSX,
 	DA850_AHCLKR, DA850_ACLKR, DA850_AFSR,
@@ -1161,6 +1199,14 @@ static struct mfd_cell cell[] = {
 		.resources	= da850_evm_pruss_suart_resource,
 	},
 	{
+		.id		= 1,

arch/arm/mach-davinci/board-da850-evm.c static struct mfd_cell cell[] = { · line 1212

Quoted 10 lines
arch/arm/mach-davinci/board-da850-evm.c +7 -0
+		.name		= "da8xx_pruss_can",
+		.platform_data	= &can_data,
+		.data_size	= sizeof(can_data),
+		.num_resources  = 0,
+		.resources	= NULL,
+	},
+	{
 		.name		= NULL,
 	},
 };

Marc

Signature · 12 lines
Pengutronix e.K.                  | Marc Kleine-Budde           |
Industrial Linux Solutions        | Phone: +49-231-2826-924     |
Vertretung West/Dortmund          | Fax:   +49-5121-206917-5555 |
Amtsgericht Hildesheim, HRA 2686  | http://www.pengutronix.de   |

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 262 bytes
Desc: OpenPGP digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20110422/3613b9b9/attachment.sig>
#79 lore raw

Re: [PATCH v4 11/11] da850: pruss CAN board specific additions.

In reply to Subhasish Ghosh

Hello.

Quoted 12 lines · Subhasish Ghosh

This patch adds the pruss CAN pinmux and registers the device with the pruss mfd driver.

---
  arch/arm/mach-davinci/board-da850-evm.c |   46 +++++++++++++++++++++++++++++++
  1 files changed, 46 insertions(+), 0 deletions(-)
arch/arm/mach-davinci/board-da850-evm.c +0 -0
index e7fdf31..e1ff18c 100644

[...]

Quoted 9 lines
arch/arm/mach-davinci/board-da850-evm.c +5 -0
@@ -1117,6 +1118,43 @@ static __init int da850_evm_init_cpufreq(void)
  static __init int da850_evm_init_cpufreq(void) { return 0; }
  #endif
 
+static const short da850_evm_pruss_can_pins[] = {
+	DA850_PRUSS_PRU0_R31_0, DA850_PRUSS_PRU1_R30_15,
+	DA850_PRUSS_PRU1_R31_18, DA850_GPIO2_0,
+	-1
+};

arch/arm/mach-davinci/board-da850-evm.c static __init int da850_evm_init_cpufreq(void) · line 1135

Quoted 10 lines
arch/arm/mach-davinci/board-da850-evm.c +10 -0
+
+static int __init da850_evm_pruss_can_setup(void)
+{
+	int ret, val = 0;
+	void __iomem *cfg_chip3_reg;
+
+	ret = davinci_cfg_reg_list(da850_evm_pruss_can_pins);
+	if (ret)
+		pr_warning("%s: da850_evm_pruss_can_pins mux setup "
+					"failed:%d\n", __func__, ret);

Yet you continue to initialize... you should stop here I think.

arch/arm/mach-davinci/board-da850-evm.c static __init int da850_evm_init_cpufreq(void) · line 1146

Quoted 6 lines
arch/arm/mach-davinci/board-da850-evm.c +6 -0
+	/* value = 0 to enable the CAN transceiver */
+	ret = gpio_request_one(DA850_PRUSS_CAN_TRX_PIN,
+			GPIOF_OUT_INIT_LOW, "pruss_can_en");
+	if (ret) {
+		pr_warning("Cannot setup GPIO %d\n", DA850_PRUSS_CAN_TRX_PIN);
+		gpio_free(DA850_PRUSS_CAN_TRX_PIN);

Doesn't gpio_request_one() handle freeing GPIO on error?

WBR, Sergei

#80 lore raw

Re: [PATCH v4 11/11] da850: pruss CAN board specific additions.

Quoted 12 lines

arch/arm/mach-davinci/board-da850-evm.c static __init int da850_evm_init_cpufreq(void) · line 1135

Quoted 10 lines
arch/arm/mach-davinci/board-da850-evm.c +9 -0
+static int __init da850_evm_pruss_can_setup(void)
+{
+ int ret, val = 0;
+ void __iomem *cfg_chip3_reg;
+
+ ret = davinci_cfg_reg_list(da850_evm_pruss_can_pins);
+ if (ret)
+ pr_warning("%s: da850_evm_pruss_can_pins mux setup "
+ "failed:%d\n", __func__, ret);

Yet you continue to initialize... you should stop here I think.

SG - Ok, will ret error.

Quoted 9 lines
Quoted 7 lines

+ /* value = 0 to enable the CAN transceiver */
+ ret = gpio_request_one(DA850_PRUSS_CAN_TRX_PIN,
+ GPIOF_OUT_INIT_LOW, "pruss_can_en");
+ if (ret) {
+ pr_warning("Cannot setup GPIO %d\n", DA850_PRUSS_CAN_TRX_PIN);
+ gpio_free(DA850_PRUSS_CAN_TRX_PIN);

Doesn't gpio_request_one() handle freeing GPIO on error?

SG - It does handle error, will remove. But I have another problem,
Suppose the init failed due to some other reason during probe. How can I do a gpio_free, do I need some kind of deinit for the
setup ?