linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/3] Update for the Broadcom STB DPFE driver
@ 2018-02-13 20:40 Markus Mayer
  2018-02-13 20:40 ` [PATCH 1/3] memory: brcmstb: dpfe: properly mask vendor error bits Markus Mayer
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Markus Mayer @ 2018-02-13 20:40 UTC (permalink / raw)
  To: Brian Norris, Florian Fainelli, Gregory Fong
  Cc: Markus Mayer, Broadcom Kernel List, ARM Kernel List,
	Linux Kernel Mailing List

This series primarily introduces a new way of passing information from
the DCPU to the host CPU.

Previously, all communication was via the DCPU data RAM. This
communication mode is still supported. In addition, we now support
passing data via the message RAM. The driver will dynamically detect
which method to use upon receiving a reply.

The series also contains two fixes to the driver that have no direct
relation with the new communication feature.

Markus Mayer (3):
  memory: brcmstb: dpfe: properly mask vendor error bits
  memory: brcmstb: dpfe: fix type declaration of variable "ret"
  memory: brcmstb: dpfe: support new way of passing data from the DCPU

 drivers/memory/brcmstb_dpfe.c | 74 +++++++++++++++++++++++++++++++++++--------
 1 file changed, 60 insertions(+), 14 deletions(-)

-- 
2.7.4

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH 1/3] memory: brcmstb: dpfe: properly mask vendor error bits
  2018-02-13 20:40 [PATCH 0/3] Update for the Broadcom STB DPFE driver Markus Mayer
@ 2018-02-13 20:40 ` Markus Mayer
  2018-02-23 18:56   ` Florian Fainelli
  2018-02-13 20:40 ` [PATCH 2/3] memory: brcmstb: dpfe: fix type declaration of variable "ret" Markus Mayer
  2018-02-13 20:40 ` [PATCH 3/3] memory: brcmstb: dpfe: support new way of passing data from the DCPU Markus Mayer
  2 siblings, 1 reply; 7+ messages in thread
From: Markus Mayer @ 2018-02-13 20:40 UTC (permalink / raw)
  To: Brian Norris, Florian Fainelli, Gregory Fong
  Cc: Markus Mayer, Broadcom Kernel List, ARM Kernel List,
	Linux Kernel Mailing List

We were printing the entire 32 bit register rather than just the lower
8 bits. Anything above bit 7 is reserved and may be any random value.

Fixes: 2f330caff577 ("memory: brcmstb: Add driver for DPFE")
Signed-off-by: Markus Mayer <mmayer@broadcom.com>
---
 drivers/memory/brcmstb_dpfe.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/memory/brcmstb_dpfe.c b/drivers/memory/brcmstb_dpfe.c
index 0a7bdbed3a6f..088153760e52 100644
--- a/drivers/memory/brcmstb_dpfe.c
+++ b/drivers/memory/brcmstb_dpfe.c
@@ -603,7 +603,8 @@ static ssize_t show_vendor(struct device *dev, struct device_attribute *devattr,
 		       readl_relaxed(info + DRAM_VENDOR_MR6) & DRAM_VENDOR_MASK,
 		       readl_relaxed(info + DRAM_VENDOR_MR7) & DRAM_VENDOR_MASK,
 		       readl_relaxed(info + DRAM_VENDOR_MR8) & DRAM_VENDOR_MASK,
-		       readl_relaxed(info + DRAM_VENDOR_ERROR));
+		       readl_relaxed(info + DRAM_VENDOR_ERROR) &
+				     DRAM_VENDOR_MASK);
 }
 
 static int brcmstb_dpfe_resume(struct platform_device *pdev)
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH 2/3] memory: brcmstb: dpfe: fix type declaration of variable "ret"
  2018-02-13 20:40 [PATCH 0/3] Update for the Broadcom STB DPFE driver Markus Mayer
  2018-02-13 20:40 ` [PATCH 1/3] memory: brcmstb: dpfe: properly mask vendor error bits Markus Mayer
@ 2018-02-13 20:40 ` Markus Mayer
  2018-02-23 18:56   ` Florian Fainelli
  2018-02-13 20:40 ` [PATCH 3/3] memory: brcmstb: dpfe: support new way of passing data from the DCPU Markus Mayer
  2 siblings, 1 reply; 7+ messages in thread
From: Markus Mayer @ 2018-02-13 20:40 UTC (permalink / raw)
  To: Brian Norris, Florian Fainelli, Gregory Fong
  Cc: Markus Mayer, Broadcom Kernel List, ARM Kernel List,
	Linux Kernel Mailing List

In some functions, variable "ret" should be ssize_t, so we fix it.

Fixes: 2f330caff577 ("memory: brcmstb: Add driver for DPFE")
Signed-off-by: Markus Mayer <mmayer@broadcom.com>
---
 drivers/memory/brcmstb_dpfe.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/memory/brcmstb_dpfe.c b/drivers/memory/brcmstb_dpfe.c
index 088153760e52..2013a91217a9 100644
--- a/drivers/memory/brcmstb_dpfe.c
+++ b/drivers/memory/brcmstb_dpfe.c
@@ -507,7 +507,7 @@ static ssize_t show_info(struct device *dev, struct device_attribute *devattr,
 {
 	u32 response[MSG_FIELD_MAX];
 	unsigned int info;
-	int ret;
+	ssize_t ret;
 
 	ret = generic_show(DPFE_CMD_GET_INFO, response, dev, buf);
 	if (ret)
@@ -531,7 +531,7 @@ static ssize_t show_refresh(struct device *dev,
 	unsigned int offset;
 	u8 refresh, sr_abort, ppre, thermal_offs, tuf;
 	u32 mr4;
-	int ret;
+	ssize_t ret;
 
 	ret = generic_show(DPFE_CMD_GET_REFRESH, response, dev, buf);
 	if (ret)
@@ -588,7 +588,7 @@ static ssize_t show_vendor(struct device *dev, struct device_attribute *devattr,
 	struct private_data *priv;
 	void __iomem *info;
 	unsigned int offset;
-	int ret;
+	ssize_t ret;
 
 	ret = generic_show(DPFE_CMD_GET_VENDOR, response, dev, buf);
 	if (ret)
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH 3/3] memory: brcmstb: dpfe: support new way of passing data from the DCPU
  2018-02-13 20:40 [PATCH 0/3] Update for the Broadcom STB DPFE driver Markus Mayer
  2018-02-13 20:40 ` [PATCH 1/3] memory: brcmstb: dpfe: properly mask vendor error bits Markus Mayer
  2018-02-13 20:40 ` [PATCH 2/3] memory: brcmstb: dpfe: fix type declaration of variable "ret" Markus Mayer
@ 2018-02-13 20:40 ` Markus Mayer
  2018-02-23 18:57   ` Florian Fainelli
  2 siblings, 1 reply; 7+ messages in thread
From: Markus Mayer @ 2018-02-13 20:40 UTC (permalink / raw)
  To: Brian Norris, Florian Fainelli, Gregory Fong
  Cc: Markus Mayer, Broadcom Kernel List, ARM Kernel List,
	Linux Kernel Mailing List

The DCPU can now send message data in two ways:
  - via the data RAM, as before (this is now message type 0)
  - via the message RAM (this is message type 1)

In order to support both methods, we check the message type of the
response (bits 31:28) and then treat the offset (bits 27:0)
accordingly.

Signed-off-by: Markus Mayer <mmayer@broadcom.com>
---
 drivers/memory/brcmstb_dpfe.c | 65 ++++++++++++++++++++++++++++++++++++-------
 1 file changed, 55 insertions(+), 10 deletions(-)

diff --git a/drivers/memory/brcmstb_dpfe.c b/drivers/memory/brcmstb_dpfe.c
index 2013a91217a9..e9c1485c32b9 100644
--- a/drivers/memory/brcmstb_dpfe.c
+++ b/drivers/memory/brcmstb_dpfe.c
@@ -45,8 +45,16 @@
 #define REG_TO_DCPU_MBOX	0x10
 #define REG_TO_HOST_MBOX	0x14
 
+/* Macros to process offsets returned by the DCPU */
+#define DRAM_MSG_ADDR_OFFSET	0x0
+#define DRAM_MSG_TYPE_OFFSET	0x1c
+#define DRAM_MSG_ADDR_MASK	((1UL << DRAM_MSG_TYPE_OFFSET) - 1)
+#define DRAM_MSG_TYPE_MASK	((1UL << \
+				 (BITS_PER_LONG - DRAM_MSG_TYPE_OFFSET)) - 1)
+
 /* Message RAM */
-#define DCPU_MSG_RAM(x)		(0x100 + (x) * sizeof(u32))
+#define DCPU_MSG_RAM_START	0x100
+#define DCPU_MSG_RAM(x)		(DCPU_MSG_RAM_START + (x) * sizeof(u32))
 
 /* DRAM Info Offsets & Masks */
 #define DRAM_INFO_INTERVAL	0x0
@@ -255,6 +263,40 @@ static unsigned int get_msg_chksum(const u32 msg[])
 	return sum;
 }
 
+static void __iomem *get_msg_ptr(struct private_data *priv, u32 response,
+				 char *buf, ssize_t *size)
+{
+	unsigned int msg_type;
+	unsigned int offset;
+	void __iomem *ptr = NULL;
+
+	msg_type = (response >> DRAM_MSG_TYPE_OFFSET) & DRAM_MSG_TYPE_MASK;
+	offset = (response >> DRAM_MSG_ADDR_OFFSET) & DRAM_MSG_ADDR_MASK;
+
+	/*
+	 * msg_type == 1: the offset is relative to the message RAM
+	 * msg_type == 0: the offset is relative to the data RAM (this is the
+	 *                previous way of passing data)
+	 * msg_type is anything else: there's critical hardware problem
+	 */
+	switch (msg_type) {
+	case 1:
+		ptr = priv->regs + DCPU_MSG_RAM_START + offset;
+		break;
+	case 0:
+		ptr = priv->dmem + offset;
+		break;
+	default:
+		dev_emerg(priv->dev, "invalid message reply from DCPU: %#x\n",
+			response);
+		if (buf && size)
+			*size = sprintf(buf,
+				"FATAL: communication error with DCPU\n");
+	}
+
+	return ptr;
+}
+
 static int __send_command(struct private_data *priv, unsigned int cmd,
 			  u32 result[])
 {
@@ -528,7 +570,6 @@ static ssize_t show_refresh(struct device *dev,
 	u32 response[MSG_FIELD_MAX];
 	void __iomem *info;
 	struct private_data *priv;
-	unsigned int offset;
 	u8 refresh, sr_abort, ppre, thermal_offs, tuf;
 	u32 mr4;
 	ssize_t ret;
@@ -538,8 +579,10 @@ static ssize_t show_refresh(struct device *dev,
 		return ret;
 
 	priv = dev_get_drvdata(dev);
-	offset = response[MSG_ARG0];
-	info = priv->dmem + offset;
+
+	info = get_msg_ptr(priv, response[MSG_ARG0], buf, &ret);
+	if (!info)
+		return ret;
 
 	mr4 = readl_relaxed(info + DRAM_INFO_MR4) & DRAM_INFO_MR4_MASK;
 
@@ -561,7 +604,6 @@ static ssize_t store_refresh(struct device *dev, struct device_attribute *attr,
 	u32 response[MSG_FIELD_MAX];
 	struct private_data *priv;
 	void __iomem *info;
-	unsigned int offset;
 	unsigned long val;
 	int ret;
 
@@ -574,8 +616,10 @@ static ssize_t store_refresh(struct device *dev, struct device_attribute *attr,
 	if (ret)
 		return ret;
 
-	offset = response[MSG_ARG0];
-	info = priv->dmem + offset;
+	info = get_msg_ptr(priv, response[MSG_ARG0], NULL, NULL);
+	if (!info)
+		return -EIO;
+
 	writel_relaxed(val, info + DRAM_INFO_INTERVAL);
 
 	return count;
@@ -587,16 +631,17 @@ static ssize_t show_vendor(struct device *dev, struct device_attribute *devattr,
 	u32 response[MSG_FIELD_MAX];
 	struct private_data *priv;
 	void __iomem *info;
-	unsigned int offset;
 	ssize_t ret;
 
 	ret = generic_show(DPFE_CMD_GET_VENDOR, response, dev, buf);
 	if (ret)
 		return ret;
 
-	offset = response[MSG_ARG0];
 	priv = dev_get_drvdata(dev);
-	info = priv->dmem + offset;
+
+	info = get_msg_ptr(priv, response[MSG_ARG0], buf, &ret);
+	if (!info)
+		return ret;
 
 	return sprintf(buf, "%#x %#x %#x %#x %#x\n",
 		       readl_relaxed(info + DRAM_VENDOR_MR5) & DRAM_VENDOR_MASK,
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH 1/3] memory: brcmstb: dpfe: properly mask vendor error bits
  2018-02-13 20:40 ` [PATCH 1/3] memory: brcmstb: dpfe: properly mask vendor error bits Markus Mayer
@ 2018-02-23 18:56   ` Florian Fainelli
  0 siblings, 0 replies; 7+ messages in thread
From: Florian Fainelli @ 2018-02-23 18:56 UTC (permalink / raw)
  To: bcm-kernel-feedback-list, Markus Mayer, Brian Norris, Gregory Fong
  Cc: ARM Kernel List, Linux Kernel Mailing List

On Tue, 13 Feb 2018 12:40:38 -0800, Markus Mayer <mmayer@broadcom.com> wrote:
> We were printing the entire 32 bit register rather than just the lower
> 8 bits. Anything above bit 7 is reserved and may be any random value.
> 
> Fixes: 2f330caff577 ("memory: brcmstb: Add driver for DPFE")
> Signed-off-by: Markus Mayer <mmayer@broadcom.com>
> ---

Applied to drivers/fixes, thanks!
--
Florian

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 2/3] memory: brcmstb: dpfe: fix type declaration of variable "ret"
  2018-02-13 20:40 ` [PATCH 2/3] memory: brcmstb: dpfe: fix type declaration of variable "ret" Markus Mayer
@ 2018-02-23 18:56   ` Florian Fainelli
  0 siblings, 0 replies; 7+ messages in thread
From: Florian Fainelli @ 2018-02-23 18:56 UTC (permalink / raw)
  To: bcm-kernel-feedback-list, Markus Mayer, Brian Norris, Gregory Fong
  Cc: ARM Kernel List, Linux Kernel Mailing List

On Tue, 13 Feb 2018 12:40:39 -0800, Markus Mayer <mmayer@broadcom.com> wrote:
> In some functions, variable "ret" should be ssize_t, so we fix it.
> 
> Fixes: 2f330caff577 ("memory: brcmstb: Add driver for DPFE")
> Signed-off-by: Markus Mayer <mmayer@broadcom.com>
> ---

Applied to drivers/fixes, thanks!
--
Florian

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH 3/3] memory: brcmstb: dpfe: support new way of passing data from the DCPU
  2018-02-13 20:40 ` [PATCH 3/3] memory: brcmstb: dpfe: support new way of passing data from the DCPU Markus Mayer
@ 2018-02-23 18:57   ` Florian Fainelli
  0 siblings, 0 replies; 7+ messages in thread
From: Florian Fainelli @ 2018-02-23 18:57 UTC (permalink / raw)
  To: bcm-kernel-feedback-list, Markus Mayer, Brian Norris, Gregory Fong
  Cc: ARM Kernel List, Linux Kernel Mailing List

On Tue, 13 Feb 2018 12:40:40 -0800, Markus Mayer <mmayer@broadcom.com> wrote:
> The DCPU can now send message data in two ways:
>   - via the data RAM, as before (this is now message type 0)
>   - via the message RAM (this is message type 1)
> 
> In order to support both methods, we check the message type of the
> response (bits 31:28) and then treat the offset (bits 27:0)
> accordingly.
> 
> Signed-off-by: Markus Mayer <mmayer@broadcom.com>
> ---

Applied to drivers/fixes, thanks!
--
Florian

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2018-02-23 19:12 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-02-13 20:40 [PATCH 0/3] Update for the Broadcom STB DPFE driver Markus Mayer
2018-02-13 20:40 ` [PATCH 1/3] memory: brcmstb: dpfe: properly mask vendor error bits Markus Mayer
2018-02-23 18:56   ` Florian Fainelli
2018-02-13 20:40 ` [PATCH 2/3] memory: brcmstb: dpfe: fix type declaration of variable "ret" Markus Mayer
2018-02-23 18:56   ` Florian Fainelli
2018-02-13 20:40 ` [PATCH 3/3] memory: brcmstb: dpfe: support new way of passing data from the DCPU Markus Mayer
2018-02-23 18:57   ` Florian Fainelli

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).