2019-04-02 23:11:01

by Markus Mayer

[permalink] [raw]
Subject: [PATCH 0/6] memory: brcmstb: dpfe: introduce DPFE API v3

From: Markus Mayer <[email protected]>

This series introduces a new API for communicating with the DCPU.
It will be used as the default going forward.

Before adding the new API, there is also some code cleanup and
hardening.

This series is based on drivers/next of
https://github.com/Broadcom/stblinux.git, since it builds on top of
recently upstreamed changes that are present in this branch.

Markus Mayer (6):
memory: brcmstb: dpfe: remove unused code and fix formatting
memory: brcmstb: dpfe: report firmware loading error
memory: brcmstb: dpfe: wait for DCPU to be ready
memory: brcmstb: dpfe: prepare support for multiple API versions
memory: brcmstb: dpfe: prepare for API-dependent sysfs attributes
memory: brcmstb: dpfe: introduce DPFE API v3

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

--
2.17.1


2019-04-02 23:08:59

by Markus Mayer

[permalink] [raw]
Subject: [PATCH 3/6] memory: brcmstb: dpfe: wait for DCPU to be ready

From: Markus Mayer <[email protected]>

We wait for the DCPU to be ready before sending a command.

Signed-off-by: Markus Mayer <[email protected]>
---
drivers/memory/brcmstb_dpfe.c | 12 ++++++++++++
1 file changed, 12 insertions(+)

diff --git a/drivers/memory/brcmstb_dpfe.c b/drivers/memory/brcmstb_dpfe.c
index c67774a4fe8b..f8d05a8266c3 100644
--- a/drivers/memory/brcmstb_dpfe.c
+++ b/drivers/memory/brcmstb_dpfe.c
@@ -304,6 +304,18 @@ static int __send_command(struct private_data *priv, unsigned int cmd,

mutex_lock(&priv->lock);

+ /* Wait for DCPU to become ready */
+ for (i = 0; i < DELAY_LOOP_MAX; i++) {
+ resp = readl_relaxed(regs + REG_TO_HOST_MBOX);
+ if (resp == 0)
+ break;
+ msleep(1);
+ }
+ if (resp != 0) {
+ mutex_unlock(&priv->lock);
+ return -ETIMEDOUT;
+ }
+
/* Write command and arguments to message area */
for (i = 0; i < MSG_FIELD_MAX; i++)
writel_relaxed(msg[i], regs + DCPU_MSG_RAM(i));
--
2.17.1

2019-04-02 23:09:02

by Markus Mayer

[permalink] [raw]
Subject: [PATCH 6/6] memory: brcmstb: dpfe: introduce DPFE API v3

From: Markus Mayer <[email protected]>

Introduce code to handle DPFE API v3. We also change the driver to
default to v3 by default and use API v2 only for select chips.

Signed-off-by: Markus Mayer <[email protected]>
---
drivers/memory/brcmstb_dpfe.c | 114 +++++++++++++++++++++++++++++++---
1 file changed, 105 insertions(+), 9 deletions(-)

diff --git a/drivers/memory/brcmstb_dpfe.c b/drivers/memory/brcmstb_dpfe.c
index 43a53246abb3..bc6bf263c859 100644
--- a/drivers/memory/brcmstb_dpfe.c
+++ b/drivers/memory/brcmstb_dpfe.c
@@ -76,7 +76,7 @@
#define DRAM_MR4_TH_OFFS_MASK 0x3
#define DRAM_MR4_TUF_MASK 0x1

-/* DRAM Vendor Offsets & Masks */
+/* DRAM Vendor Offsets & Masks (API v2) */
#define DRAM_VENDOR_MR5 0x0
#define DRAM_VENDOR_MR6 0x4
#define DRAM_VENDOR_MR7 0x8
@@ -85,6 +85,15 @@
#define DRAM_VENDOR_MASK 0xff
#define DRAM_VENDOR_SHIFT 24 /* We need to look at byte 3 */

+/* DRAM Information Offsets & Masks (API v3) */
+#define DRAM_DDR_INFO_MR4 0x0
+#define DRAM_DDR_INFO_MR5 0x4
+#define DRAM_DDR_INFO_MR6 0x8
+#define DRAM_DDR_INFO_MR7 0xc
+#define DRAM_DDR_INFO_MR8 0x10
+#define DRAM_DDR_INFO_ERROR 0x14
+#define DRAM_DDR_INFO_MASK 0xff
+
/* Reset register bits & masks */
#define DCPU_RESET_SHIFT 0x0
#define DCPU_RESET_MASK 0x1
@@ -121,7 +130,7 @@ enum dpfe_msg_fields {
MSG_ARG_COUNT,
MSG_ARG0,
MSG_CHKSUM,
- MSG_FIELD_MAX /* Last entry */
+ MSG_FIELD_MAX = 16 /* Max number of arguments */
};

enum dpfe_commands {
@@ -196,6 +205,7 @@ static ssize_t show_refresh(struct device *, struct device_attribute *, char *);
static ssize_t store_refresh(struct device *, struct device_attribute *,
const char *, size_t);
static ssize_t show_vendor(struct device *, struct device_attribute *, char *);
+static ssize_t show_dram(struct device *, struct device_attribute *, char *);

/*
* Declare our attributes early, so they can be referenced in the API data
@@ -205,6 +215,7 @@ static ssize_t show_vendor(struct device *, struct device_attribute *, char *);
static DEVICE_ATTR(dpfe_info, 0444, show_info, NULL);
static DEVICE_ATTR(dpfe_refresh, 0644, show_refresh, store_refresh);
static DEVICE_ATTR(dpfe_vendor, 0444, show_vendor, NULL);
+static DEVICE_ATTR(dpfe_dram, 0444, show_dram, NULL);

/* API v2 sysfs attributes */
static struct attribute *dpfe_v2_attrs[] = {
@@ -215,6 +226,14 @@ static struct attribute *dpfe_v2_attrs[] = {
};
ATTRIBUTE_GROUPS(dpfe_v2);

+/* API v3 sysfs attributes */
+static struct attribute *dpfe_v3_attrs[] = {
+ &dev_attr_dpfe_info.attr,
+ &dev_attr_dpfe_dram.attr,
+ NULL
+};
+ATTRIBUTE_GROUPS(dpfe_v3);
+
/* API v2 firmware commands */
static const struct dpfe_api dpfe_api_v2 = {
.version = 2,
@@ -245,6 +264,34 @@ static const struct dpfe_api dpfe_api_v2 = {
}
};

+/* API v3 firmware commands */
+static const struct dpfe_api dpfe_api_v3 = {
+ .version = 3,
+ .fw_name = NULL, /* We expect the firmware to have been downloaded! */
+ .sysfs_attrs = dpfe_v3_groups,
+ .command = {
+ [DPFE_CMD_GET_INFO] = {
+ [MSG_HEADER] = DPFE_MSG_TYPE_COMMAND,
+ [MSG_COMMAND] = 0x0101,
+ [MSG_ARG_COUNT] = 1,
+ [MSG_ARG0] = 1,
+ [MSG_CHKSUM] = 0x104,
+ },
+ [DPFE_CMD_GET_REFRESH] = {
+ [MSG_HEADER] = DPFE_MSG_TYPE_COMMAND,
+ [MSG_COMMAND] = 0x0202,
+ [MSG_ARG_COUNT] = 0,
+ /*
+ * This is a bit ugly. Without arguments, the checksum
+ * follows right after the argument count and not at
+ * offset MSG_CHKSUM.
+ */
+ [MSG_ARG0] = 0x203,
+ },
+ /* There's no GET_VENDOR command in API v3. */
+ },
+};
+
static bool is_dcpu_enabled(void __iomem *regs)
{
u32 val;
@@ -286,13 +333,13 @@ static void __enable_dcpu(void __iomem *regs)
writel_relaxed(val, regs + REG_DCPU_RESET);
}

-static unsigned int get_msg_chksum(const u32 msg[])
+static unsigned int get_msg_chksum(const u32 msg[], unsigned int max)
{
unsigned int sum = 0;
unsigned int i;

/* Don't include the last field in the checksum. */
- for (i = 0; i < MSG_FIELD_MAX - 1; i++)
+ for (i = 0; i < max; i++)
sum += msg[i];

return sum;
@@ -305,6 +352,11 @@ static void __iomem *get_msg_ptr(struct private_data *priv, u32 response,
unsigned int offset;
void __iomem *ptr = NULL;

+ /* There is no need to use this function for API v3 or later. */
+ if (unlikely(priv->dpfe_api->version >= 3)) {
+ return NULL;
+ }
+
msg_type = (response >> DRAM_MSG_TYPE_OFFSET) & DRAM_MSG_TYPE_MASK;
offset = (response >> DRAM_MSG_ADDR_OFFSET) & DRAM_MSG_ADDR_MASK;

@@ -332,12 +384,25 @@ static void __iomem *get_msg_ptr(struct private_data *priv, u32 response,
return ptr;
}

+static void __finalize_command(struct private_data *priv)
+{
+ unsigned int release_mbox;
+
+ /*
+ * It depends on the API version which MBOX register we have to write to
+ * to signal we are done.
+ */
+ release_mbox = (priv->dpfe_api->version < 3)
+ ? REG_TO_HOST_MBOX : REG_TO_DCPU_MBOX;
+ writel_relaxed(0, priv->regs + release_mbox);
+}
+
static int __send_command(struct private_data *priv, unsigned int cmd,
u32 result[])
{
const u32 *msg = priv->dpfe_api->command[cmd];
void __iomem *regs = priv->regs;
- unsigned int i, chksum;
+ unsigned int i, chksum, chksum_idx;
int ret = 0;
u32 resp;

@@ -381,10 +446,11 @@ static int __send_command(struct private_data *priv, unsigned int cmd,
/* Read response data */
for (i = 0; i < MSG_FIELD_MAX; i++)
result[i] = readl_relaxed(regs + DCPU_MSG_RAM(i));
+ chksum_idx = result[MSG_ARG_COUNT] + MSG_ARG_COUNT + 1;
}

/* Tell DCPU we are done */
- writel_relaxed(0, regs + REG_TO_HOST_MBOX);
+ __finalize_command(priv);

mutex_unlock(&priv->lock);

@@ -392,8 +458,8 @@ static int __send_command(struct private_data *priv, unsigned int cmd,
return ret;

/* Verify response */
- chksum = get_msg_chksum(result);
- if (chksum != result[MSG_CHKSUM])
+ chksum = get_msg_chksum(result, chksum_idx);
+ if (chksum != result[chksum_idx])
resp = DCPU_RET_ERR_CHKSUM;

if (resp != DCPU_RET_SUCCESS) {
@@ -710,6 +776,30 @@ static ssize_t show_vendor(struct device *dev, struct device_attribute *devattr,
return sprintf(buf, "%#x %#x %#x %#x %#x\n", mr5, mr6, mr7, mr8, err);
}

+static ssize_t show_dram(struct device *dev, struct device_attribute *devattr,
+ char *buf)
+{
+ u32 response[MSG_FIELD_MAX];
+ struct private_data *priv;
+ ssize_t ret;
+ u32 mr4, mr5, mr6, mr7, mr8, err;
+
+ priv = dev_get_drvdata(dev);
+ ret = generic_show(DPFE_CMD_GET_REFRESH, response, priv, buf);
+ if (ret)
+ return ret;
+
+ mr4 = response[MSG_ARG0 + 0] & DRAM_INFO_MR4_MASK;
+ mr5 = response[MSG_ARG0 + 1] & DRAM_DDR_INFO_MASK;
+ mr6 = response[MSG_ARG0 + 2] & DRAM_DDR_INFO_MASK;
+ mr7 = response[MSG_ARG0 + 3] & DRAM_DDR_INFO_MASK;
+ mr8 = response[MSG_ARG0 + 4] & DRAM_DDR_INFO_MASK;
+ err = response[MSG_ARG0 + 5] & DRAM_DDR_INFO_MASK;
+
+ return sprintf(buf, "%#x %#x %#x %#x %#x %#x\n", mr4, mr5, mr6, mr7,
+ mr8, err);
+}
+
static int brcmstb_dpfe_resume(struct platform_device *pdev)
{
struct init_data init;
@@ -787,7 +877,13 @@ static int brcmstb_dpfe_remove(struct platform_device *pdev)
}

static const struct of_device_id brcmstb_dpfe_of_match[] = {
- { .compatible = "brcm,dpfe-cpu", .data = &dpfe_api_v2 },
+ /* Use legacy API v2 for a select number of chips */
+ { .compatible = "brcm,bcm7268-dpfe-cpu", .data = &dpfe_api_v2 },
+ { .compatible = "brcm,bcm7271-dpfe-cpu", .data = &dpfe_api_v2 },
+ { .compatible = "brcm,bcm7278-dpfe-cpu", .data = &dpfe_api_v2 },
+ { .compatible = "brcm,bcm7211-dpfe-cpu", .data = &dpfe_api_v2 },
+ /* API v3 is the default going forward */
+ { .compatible = "brcm,dpfe-cpu", .data = &dpfe_api_v3 },
{}
};
MODULE_DEVICE_TABLE(of, brcmstb_dpfe_of_match);
--
2.17.1

2019-04-02 23:10:01

by Markus Mayer

[permalink] [raw]
Subject: [PATCH 2/6] memory: brcmstb: dpfe: report firmware loading error

From: Markus Mayer <[email protected]>

Print an error message if the DCPU firmware couldn't be downloaded.

Signed-off-by: Markus Mayer <[email protected]>
---
drivers/memory/brcmstb_dpfe.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/memory/brcmstb_dpfe.c b/drivers/memory/brcmstb_dpfe.c
index f143e40e528b..c67774a4fe8b 100644
--- a/drivers/memory/brcmstb_dpfe.c
+++ b/drivers/memory/brcmstb_dpfe.c
@@ -703,8 +703,10 @@ static int brcmstb_dpfe_probe(struct platform_device *pdev)
}

ret = brcmstb_dpfe_download_firmware(pdev, &init);
- if (ret)
+ if (ret) {
+ dev_err(dev, "Couldn't download firmware -- %d\n", ret);
return ret;
+ }

ret = sysfs_create_groups(&pdev->dev.kobj, dpfe_groups);
if (!ret)
--
2.17.1

2019-04-02 23:11:17

by Markus Mayer

[permalink] [raw]
Subject: [PATCH 1/6] memory: brcmstb: dpfe: remove unused code and fix formatting

From: Markus Mayer <[email protected]>

Remove an unused struct and fix source code formatting in a few areas.

Signed-off-by: Markus Mayer <[email protected]>
---
drivers/memory/brcmstb_dpfe.c | 13 ++-----------
1 file changed, 2 insertions(+), 11 deletions(-)

diff --git a/drivers/memory/brcmstb_dpfe.c b/drivers/memory/brcmstb_dpfe.c
index fae3ac3d65c6..f143e40e528b 100644
--- a/drivers/memory/brcmstb_dpfe.c
+++ b/drivers/memory/brcmstb_dpfe.c
@@ -131,14 +131,6 @@ enum dpfe_commands {
DPFE_CMD_MAX /* Last entry */
};

-struct dpfe_msg {
- u32 header;
- u32 command;
- u32 arg_count;
- u32 arg0;
- u32 chksum; /* This is the sum of all other entries. */
-};
-
/*
* Format of the binary firmware file:
*
@@ -585,7 +577,7 @@ static ssize_t show_refresh(struct device *dev,
return ret;

mr4 = (readl_relaxed(info + DRAM_INFO_MR4) >> DRAM_INFO_MR4_SHIFT) &
- DRAM_INFO_MR4_MASK;
+ DRAM_INFO_MR4_MASK;

refresh = (mr4 >> DRAM_MR4_REFRESH) & DRAM_MR4_REFRESH_MASK;
sr_abort = (mr4 >> DRAM_MR4_SR_ABORT) & DRAM_MR4_SR_ABORT_MASK;
@@ -612,7 +604,6 @@ static ssize_t store_refresh(struct device *dev, struct device_attribute *attr,
return -EINVAL;

priv = dev_get_drvdata(dev);
-
ret = __send_command(priv, DPFE_CMD_GET_REFRESH, response);
if (ret)
return ret;
@@ -627,7 +618,7 @@ static ssize_t store_refresh(struct device *dev, struct device_attribute *attr,
}

static ssize_t show_vendor(struct device *dev, struct device_attribute *devattr,
- char *buf)
+ char *buf)
{
u32 response[MSG_FIELD_MAX];
struct private_data *priv;
--
2.17.1

2019-04-02 23:11:44

by Markus Mayer

[permalink] [raw]
Subject: [PATCH 4/6] memory: brcmstb: dpfe: prepare support for multiple API versions

From: Markus Mayer <[email protected]>

Extend the driver, so it can handle different API versions for
interacting with the DCPU. This is in preparation for the upcoming API
v3.

Signed-off-by: Markus Mayer <[email protected]>
---
drivers/memory/brcmstb_dpfe.c | 87 ++++++++++++++++++++++++-----------
1 file changed, 59 insertions(+), 28 deletions(-)

diff --git a/drivers/memory/brcmstb_dpfe.c b/drivers/memory/brcmstb_dpfe.c
index f8d05a8266c3..9ad5ea08c134 100644
--- a/drivers/memory/brcmstb_dpfe.c
+++ b/drivers/memory/brcmstb_dpfe.c
@@ -35,10 +35,10 @@
#include <linux/io.h>
#include <linux/module.h>
#include <linux/of_address.h>
+#include <linux/of_device.h>
#include <linux/platform_device.h>

#define DRVNAME "brcmstb-dpfe"
-#define FIRMWARE_NAME "dpfe.bin"

/* DCPU register offsets */
#define REG_DCPU_RESET 0x0
@@ -164,12 +164,20 @@ struct init_data {
bool is_big_endian;
};

+/* API version and corresponding commands */
+struct dpfe_api {
+ int version;
+ const char *fw_name;
+ u32 command[DPFE_CMD_MAX][MSG_FIELD_MAX];
+};
+
/* Things we need for as long as we are active. */
struct private_data {
void __iomem *regs;
void __iomem *dmem;
void __iomem *imem;
struct device *dev;
+ const struct dpfe_api *dpfe_api;
struct mutex lock;
};

@@ -178,29 +186,33 @@ static const char *error_text[] = {
"Incorrect checksum", "Malformed command", "Timed out",
};

-/* List of supported firmware commands */
-static const u32 dpfe_commands[DPFE_CMD_MAX][MSG_FIELD_MAX] = {
- [DPFE_CMD_GET_INFO] = {
- [MSG_HEADER] = DPFE_MSG_TYPE_COMMAND,
- [MSG_COMMAND] = 1,
- [MSG_ARG_COUNT] = 1,
- [MSG_ARG0] = 1,
- [MSG_CHKSUM] = 4,
- },
- [DPFE_CMD_GET_REFRESH] = {
- [MSG_HEADER] = DPFE_MSG_TYPE_COMMAND,
- [MSG_COMMAND] = 2,
- [MSG_ARG_COUNT] = 1,
- [MSG_ARG0] = 1,
- [MSG_CHKSUM] = 5,
- },
- [DPFE_CMD_GET_VENDOR] = {
- [MSG_HEADER] = DPFE_MSG_TYPE_COMMAND,
- [MSG_COMMAND] = 2,
- [MSG_ARG_COUNT] = 1,
- [MSG_ARG0] = 2,
- [MSG_CHKSUM] = 6,
- },
+/* API v2 firmware commands */
+static const struct dpfe_api dpfe_api_v2 = {
+ .version = 2,
+ .fw_name = "dpfe.bin",
+ .command = {
+ [DPFE_CMD_GET_INFO] = {
+ [MSG_HEADER] = DPFE_MSG_TYPE_COMMAND,
+ [MSG_COMMAND] = 1,
+ [MSG_ARG_COUNT] = 1,
+ [MSG_ARG0] = 1,
+ [MSG_CHKSUM] = 4,
+ },
+ [DPFE_CMD_GET_REFRESH] = {
+ [MSG_HEADER] = DPFE_MSG_TYPE_COMMAND,
+ [MSG_COMMAND] = 2,
+ [MSG_ARG_COUNT] = 1,
+ [MSG_ARG0] = 1,
+ [MSG_CHKSUM] = 5,
+ },
+ [DPFE_CMD_GET_VENDOR] = {
+ [MSG_HEADER] = DPFE_MSG_TYPE_COMMAND,
+ [MSG_COMMAND] = 2,
+ [MSG_ARG_COUNT] = 1,
+ [MSG_ARG0] = 2,
+ [MSG_CHKSUM] = 6,
+ },
+ }
};

static bool is_dcpu_enabled(void __iomem *regs)
@@ -293,7 +305,7 @@ static void __iomem *get_msg_ptr(struct private_data *priv, u32 response,
static int __send_command(struct private_data *priv, unsigned int cmd,
u32 result[])
{
- const u32 *msg = dpfe_commands[cmd];
+ const u32 *msg = priv->dpfe_api->command[cmd];
void __iomem *regs = priv->regs;
unsigned int i, chksum;
int ret = 0;
@@ -492,7 +504,15 @@ static int brcmstb_dpfe_download_firmware(struct platform_device *pdev,
return 0;
}

- ret = request_firmware(&fw, FIRMWARE_NAME, dev);
+ /*
+ * If the firmware filename is NULL it means the boot firmware has to
+ * download the DCPU firmware for us. If that didn't work, we have to
+ * bail, since downloading it ourselves wouldn't work either.
+ */
+ if (!priv->dpfe_api->fw_name)
+ return -ENODEV;
+
+ ret = request_firmware(&fw, priv->dpfe_api->fw_name, dev);
/* request_firmware() prints its own error messages. */
if (ret)
return ret;
@@ -714,6 +734,16 @@ static int brcmstb_dpfe_probe(struct platform_device *pdev)
return -ENOENT;
}

+ priv->dpfe_api = of_device_get_match_data(dev);
+ if (unlikely(!priv->dpfe_api)) {
+ /*
+ * It should be impossible to end up here, but to be safe we
+ * check anyway.
+ */
+ dev_err(dev, "Couldn't determine API\n");
+ return -ENOENT;
+ }
+
ret = brcmstb_dpfe_download_firmware(pdev, &init);
if (ret) {
dev_err(dev, "Couldn't download firmware -- %d\n", ret);
@@ -722,7 +752,8 @@ static int brcmstb_dpfe_probe(struct platform_device *pdev)

ret = sysfs_create_groups(&pdev->dev.kobj, dpfe_groups);
if (!ret)
- dev_info(dev, "registered.\n");
+ dev_info(dev, "registered with API v%d.\n",
+ priv->dpfe_api->version);

return ret;
}
@@ -735,7 +766,7 @@ static int brcmstb_dpfe_remove(struct platform_device *pdev)
}

static const struct of_device_id brcmstb_dpfe_of_match[] = {
- { .compatible = "brcm,dpfe-cpu", },
+ { .compatible = "brcm,dpfe-cpu", .data = &dpfe_api_v2 },
{}
};
MODULE_DEVICE_TABLE(of, brcmstb_dpfe_of_match);
--
2.17.1

2019-04-02 23:12:56

by Markus Mayer

[permalink] [raw]
Subject: [PATCH 5/6] memory: brcmstb: dpfe: prepare for API-dependent sysfs attributes

From: Markus Mayer <[email protected]>

Prepare the driver so that sysfs attributes can differ based on the API
version.

Signed-off-by: Markus Mayer <[email protected]>
---
drivers/memory/brcmstb_dpfe.c | 47 +++++++++++++++++++++++++----------
1 file changed, 34 insertions(+), 13 deletions(-)

diff --git a/drivers/memory/brcmstb_dpfe.c b/drivers/memory/brcmstb_dpfe.c
index 9ad5ea08c134..43a53246abb3 100644
--- a/drivers/memory/brcmstb_dpfe.c
+++ b/drivers/memory/brcmstb_dpfe.c
@@ -168,6 +168,7 @@ struct init_data {
struct dpfe_api {
int version;
const char *fw_name;
+ const struct attribute_group **sysfs_attrs;
u32 command[DPFE_CMD_MAX][MSG_FIELD_MAX];
};

@@ -186,10 +187,39 @@ static const char *error_text[] = {
"Incorrect checksum", "Malformed command", "Timed out",
};

+/*
+ * Forward declaration of our sysfs attribute functions, so we can declare the
+ * attribute data structures early.
+ */
+static ssize_t show_info(struct device *, struct device_attribute *, char *);
+static ssize_t show_refresh(struct device *, struct device_attribute *, char *);
+static ssize_t store_refresh(struct device *, struct device_attribute *,
+ const char *, size_t);
+static ssize_t show_vendor(struct device *, struct device_attribute *, char *);
+
+/*
+ * Declare our attributes early, so they can be referenced in the API data
+ * structure. We need to do this, because the attributes depend on the API
+ * version.
+ */
+static DEVICE_ATTR(dpfe_info, 0444, show_info, NULL);
+static DEVICE_ATTR(dpfe_refresh, 0644, show_refresh, store_refresh);
+static DEVICE_ATTR(dpfe_vendor, 0444, show_vendor, NULL);
+
+/* API v2 sysfs attributes */
+static struct attribute *dpfe_v2_attrs[] = {
+ &dev_attr_dpfe_info.attr,
+ &dev_attr_dpfe_refresh.attr,
+ &dev_attr_dpfe_vendor.attr,
+ NULL
+};
+ATTRIBUTE_GROUPS(dpfe_v2);
+
/* API v2 firmware commands */
static const struct dpfe_api dpfe_api_v2 = {
.version = 2,
.fw_name = "dpfe.bin",
+ .sysfs_attrs = dpfe_v2_groups,
.command = {
[DPFE_CMD_GET_INFO] = {
[MSG_HEADER] = DPFE_MSG_TYPE_COMMAND,
@@ -687,17 +717,6 @@ static int brcmstb_dpfe_resume(struct platform_device *pdev)
return brcmstb_dpfe_download_firmware(pdev, &init);
}

-static DEVICE_ATTR(dpfe_info, 0444, show_info, NULL);
-static DEVICE_ATTR(dpfe_refresh, 0644, show_refresh, store_refresh);
-static DEVICE_ATTR(dpfe_vendor, 0444, show_vendor, NULL);
-static struct attribute *dpfe_attrs[] = {
- &dev_attr_dpfe_info.attr,
- &dev_attr_dpfe_refresh.attr,
- &dev_attr_dpfe_vendor.attr,
- NULL
-};
-ATTRIBUTE_GROUPS(dpfe);
-
static int brcmstb_dpfe_probe(struct platform_device *pdev)
{
struct device *dev = &pdev->dev;
@@ -750,7 +769,7 @@ static int brcmstb_dpfe_probe(struct platform_device *pdev)
return ret;
}

- ret = sysfs_create_groups(&pdev->dev.kobj, dpfe_groups);
+ ret = sysfs_create_groups(&pdev->dev.kobj, priv->dpfe_api->sysfs_attrs);
if (!ret)
dev_info(dev, "registered with API v%d.\n",
priv->dpfe_api->version);
@@ -760,7 +779,9 @@ static int brcmstb_dpfe_probe(struct platform_device *pdev)

static int brcmstb_dpfe_remove(struct platform_device *pdev)
{
- sysfs_remove_groups(&pdev->dev.kobj, dpfe_groups);
+ struct private_data *priv = dev_get_drvdata(&pdev->dev);
+
+ sysfs_remove_groups(&pdev->dev.kobj, priv->dpfe_api->sysfs_attrs);

return 0;
}
--
2.17.1

2019-04-17 18:56:02

by Florian Fainelli

[permalink] [raw]
Subject: Re: [PATCH 3/6] memory: brcmstb: dpfe: wait for DCPU to be ready

On Tue, 2 Apr 2019 16:01:00 -0700, Markus Mayer <[email protected]> wrote:
> From: Markus Mayer <[email protected]>
>
> We wait for the DCPU to be ready before sending a command.
>
> Signed-off-by: Markus Mayer <[email protected]>
> ---

Applied to drivers/next, thanks!
--
Florian

2019-04-17 18:56:12

by Florian Fainelli

[permalink] [raw]
Subject: Re: [PATCH 4/6] memory: brcmstb: dpfe: prepare support for multiple API versions

On Tue, 2 Apr 2019 16:01:01 -0700, Markus Mayer <[email protected]> wrote:
> From: Markus Mayer <[email protected]>
>
> Extend the driver, so it can handle different API versions for
> interacting with the DCPU. This is in preparation for the upcoming API
> v3.
>
> Signed-off-by: Markus Mayer <[email protected]>
> ---

Applied to drivers/next, thanks!
--
Florian

2019-04-17 18:56:19

by Florian Fainelli

[permalink] [raw]
Subject: Re: [PATCH 5/6] memory: brcmstb: dpfe: prepare for API-dependent sysfs attributes

On Tue, 2 Apr 2019 16:01:02 -0700, Markus Mayer <[email protected]> wrote:
> From: Markus Mayer <[email protected]>
>
> Prepare the driver so that sysfs attributes can differ based on the API
> version.
>
> Signed-off-by: Markus Mayer <[email protected]>
> ---

Applied to drivers/next, thanks!
--
Florian

2019-04-17 18:56:33

by Florian Fainelli

[permalink] [raw]
Subject: Re: [PATCH 6/6] memory: brcmstb: dpfe: introduce DPFE API v3

On Tue, 2 Apr 2019 16:01:03 -0700, Markus Mayer <[email protected]> wrote:
> From: Markus Mayer <[email protected]>
>
> Introduce code to handle DPFE API v3. We also change the driver to
> default to v3 by default and use API v2 only for select chips.
>
> Signed-off-by: Markus Mayer <[email protected]>
> ---

Applied to drivers/next, thanks!
--
Florian

2019-04-17 18:56:46

by Florian Fainelli

[permalink] [raw]
Subject: Re: [PATCH 1/6] memory: brcmstb: dpfe: remove unused code and fix formatting

On Tue, 2 Apr 2019 16:00:58 -0700, Markus Mayer <[email protected]> wrote:
> From: Markus Mayer <[email protected]>
>
> Remove an unused struct and fix source code formatting in a few areas.
>
> Signed-off-by: Markus Mayer <[email protected]>
> ---

Applied to drivers/next, thanks!
--
Florian

2019-04-17 18:56:52

by Florian Fainelli

[permalink] [raw]
Subject: Re: [PATCH 2/6] memory: brcmstb: dpfe: report firmware loading error

On Tue, 2 Apr 2019 16:00:59 -0700, Markus Mayer <[email protected]> wrote:
> From: Markus Mayer <[email protected]>
>
> Print an error message if the DCPU firmware couldn't be downloaded.
>
> Signed-off-by: Markus Mayer <[email protected]>
> ---

Applied to drivers/next, thanks!
--
Florian