Skip to content

Commit 4bf783d

Browse files
Jason-JH LinAngeloGioacchino Del Regno
authored andcommitted
soc: mediatek: mtk-cmdq: Add pa_base parsing for hardware without subsys ID support
When GCE executes instructions, it typically locates the corresponding hardware register using the subsys ID. For hardware that does not support subsys ID, the subsys ID is set to an invalid value, and the physical address must be used to generate GCE instructions. The main advantage of using subsys ID is to reduce the number of instructions. Without subsys ID, an additional `ASSIGN` instruction is needed to assign the high bytes of the physical address, which can impact performance if too many instructions are required. However, if the hardware does not support subsys ID, using the physical address is the only option to achieve the same functionality. This commit adds a pa_base parsing flow to the cmdq_client_reg structure to handle hardware without subsys ID support. Signed-off-by: Jason-JH Lin <jason-jh.lin@mediatek.com> Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com> Acked-by: Jassi Brar <jassisinghbrar@gmail.com> Acked-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com> Signed-off-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
1 parent c775b23 commit 4bf783d

2 files changed

Lines changed: 17 additions & 2 deletions

File tree

drivers/soc/mediatek/mtk-cmdq-helper.c

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
#include <linux/module.h>
99
#include <linux/mailbox_controller.h>
1010
#include <linux/of.h>
11+
#include <linux/of_address.h>
1112
#include <linux/soc/mediatek/mtk-cmdq.h>
1213

1314
#define CMDQ_WRITE_ENABLE_MASK BIT(0)
@@ -60,20 +61,31 @@ int cmdq_dev_get_client_reg(struct device *dev,
6061
struct cmdq_client_reg *client_reg, int idx)
6162
{
6263
struct of_phandle_args spec;
64+
struct resource res;
6365
int err;
6466

6567
if (!client_reg)
6668
return -ENOENT;
6769

70+
err = of_address_to_resource(dev->of_node, 0, &res);
71+
if (err) {
72+
dev_err(dev, "Missing reg in %s node\n", dev->of_node->full_name);
73+
return -EINVAL;
74+
}
75+
client_reg->pa_base = res.start;
76+
6877
err = of_parse_phandle_with_fixed_args(dev->of_node,
6978
"mediatek,gce-client-reg",
7079
3, idx, &spec);
7180
if (err < 0) {
72-
dev_warn(dev,
81+
dev_dbg(dev,
7382
"error %d can't parse gce-client-reg property (%d)",
7483
err, idx);
7584

76-
return err;
85+
/* make subsys invalid */
86+
client_reg->subsys = CMDQ_SUBSYS_INVALID;
87+
88+
return 0;
7789
}
7890

7991
client_reg->subsys = (u8)spec.args[0];

include/linux/soc/mediatek/mtk-cmdq.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@
2323
#define CMDQ_THR_SPR_IDX2 (2)
2424
#define CMDQ_THR_SPR_IDX3 (3)
2525

26+
#define CMDQ_SUBSYS_INVALID (U8_MAX)
27+
2628
struct cmdq_pkt;
2729

2830
enum cmdq_logic_op {
@@ -52,6 +54,7 @@ struct cmdq_operand {
5254

5355
struct cmdq_client_reg {
5456
u8 subsys;
57+
phys_addr_t pa_base;
5558
u16 offset;
5659
u16 size;
5760
};

0 commit comments

Comments
 (0)