Changes since v5:
- fix typo
- remove gce-event-name form the dt-binding
- add reasons in commit message
Changes since v4:
- refine the architecture of the packet encoder function
- refine the gce enevt property
- change the patch's title
Changes since v3:
- fix a typo in dt-binding and dtsi
- cast the return value to right format
Changes since v2:
- according to CK's review comment, change the property name and
refine the parameter
- change the patch's title
- remove unused property from dt-binding and dts
Changes since v1:
- add prefix "cmdq" in the commit subject
- add dt-binding document for get event and subsys function
- add fix up tag in fixup patch
- fix up some coding style (alignment)
MTK will support gce function on mt8183 platform.
dt-binding: gce: add gce header file for mt8183
mailbox: mediatek: cmdq: support mt8183 gce function
arm64: dts: add gce node for mt8183
Besides above patches, we refine gce driver on those patches.
mailbox: mediatek: cmdq: move the CMDQ_IRQ_MASK into cmdq driver data
soc: mediatek: cmdq: clear the event in cmdq initial flow
In order to enhance the convenience of gce usage, we add new helper
functions and refine the method of instruction combining.
dt-binding: gce: remove thread-num property
dt-binding: gce: add binding for gce subsys property
dt-binding: gce: add binding for gce event property
soc: mediatek: cmdq: define the instruction struct
soc: mediatek: cmdq: add polling function
soc: mediatek: cmdq: add cmdq_dev_get_subsys function
soc: mediatek: cmdq: add cmdq_dev_get_event function
Bibby Hsieh (12):
dt-binding: gce: remove thread-num property
dt-binding: gce: add gce header file for mt8183
dt-binding: gce: add binding for gce subsys property
dt-binding: gce: add binding for gce event property
mailbox: mediatek: cmdq: move the CMDQ_IRQ_MASK into cmdq driver data
mailbox: mediatek: cmdq: support mt8183 gce function
soc: mediatek: cmdq: clear the event in cmdq initial flow
soc: mediatek: cmdq: define the instruction struct
soc: mediatek: cmdq: add polling function
soc: mediatek: cmdq: add cmdq_dev_get_subsys function
soc: mediatek: cmdq: add cmdq_dev_get_event function
arm64: dts: add gce node for mt8183
.../devicetree/bindings/mailbox/mtk-gce.txt | 28 ++-
arch/arm64/boot/dts/mediatek/mt8183.dtsi | 11 ++
drivers/mailbox/mtk-cmdq-mailbox.c | 18 +-
drivers/soc/mediatek/mtk-cmdq-helper.c | 184 ++++++++++++++----
include/dt-bindings/gce/mt8183-gce.h | 177 +++++++++++++++++
include/linux/mailbox/mtk-cmdq-mailbox.h | 5 +
include/linux/soc/mediatek/mtk-cmdq.h | 62 +++++-
7 files changed, 423 insertions(+), 62 deletions(-)
create mode 100644 include/dt-bindings/gce/mt8183-gce.h
--
2.18.0
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
@@ -127,81 +137,108 @@ static int cmdq_pkt_append_command(struct cmdq_pkt *pkt, enum cmdq_code code,pkt->cmd_buf_size+=CMDQ_INST_SIZE;WARN_ONCE(1,"%s: buffer size %u is too small !\n",__func__,(u32)pkt->buf_size);-return-ENOMEM;+returnNULL;}-cmd_ptr=pkt->va_base+pkt->cmd_buf_size;-(*cmd_ptr)=(u64)((code<<CMDQ_OP_CODE_SHIFT)|arg_a)<<32|arg_b;+pkt->cmd_buf_size+=CMDQ_INST_SIZE;-return0;+returnpkt->va_base+pkt->cmd_buf_size-CMDQ_INST_SIZE;}-intcmdq_pkt_write(structcmdq_pkt*pkt,u32value,u32subsys,u32offset)+intcmdq_pkt_write(structcmdq_pkt*pkt,u8subsys,u16offset,u32value){-u32arg_a=(offset&CMDQ_ARG_A_WRITE_MASK)|-(subsys<<CMDQ_SUBSYS_SHIFT);+structcmdq_instruction*inst;++inst=cmdq_pkt_append_command(pkt);+if(!inst)+return-ENOMEM;++inst->op=CMDQ_CODE_WRITE;+inst->value=value;+inst->offset=offset;+inst->subsys=subsys;-returncmdq_pkt_append_command(pkt,CMDQ_CODE_WRITE,arg_a,value);+return0;}EXPORT_SYMBOL(cmdq_pkt_write);-intcmdq_pkt_write_mask(structcmdq_pkt*pkt,u32value,-u32subsys,u32offset,u32mask)+intcmdq_pkt_write_mask(structcmdq_pkt*pkt,u8subsys,u16offset,+u32value,u32mask){+structcmdq_instruction*inst;u32offset_mask=offset;-interr=0;if(mask!=0xffffffff){-err=cmdq_pkt_append_command(pkt,CMDQ_CODE_MASK,0,~mask);+inst=cmdq_pkt_append_command(pkt);+if(!inst)+return-ENOMEM;++inst->op=CMDQ_CODE_MASK;+inst->mask=~mask;offset_mask|=CMDQ_WRITE_ENABLE_MASK;}-err|=cmdq_pkt_write(pkt,value,subsys,offset_mask);-returnerr;+returncmdq_pkt_write(pkt,subsys,offset_mask,value);}EXPORT_SYMBOL(cmdq_pkt_write_mask);-intcmdq_pkt_wfe(structcmdq_pkt*pkt,u32event)+intcmdq_pkt_wfe(structcmdq_pkt*pkt,u16event){-u32arg_b;+structcmdq_instruction*inst;if(event>=CMDQ_MAX_EVENT)return-EINVAL;-/*-*WFEarg_b-*bit0-11:waitvalue-*bit15:1-wait,0-nowait-*bit16-27:updatevalue-*bit31:1-update,0-noupdate-*/-arg_b=CMDQ_WFE_UPDATE|CMDQ_WFE_WAIT|CMDQ_WFE_WAIT_VALUE;+inst=cmdq_pkt_append_command(pkt);+if(!inst)+return-ENOMEM;++inst->op=CMDQ_CODE_WFE;+inst->value=CMDQ_WFE_OPTION;+inst->event=event;-returncmdq_pkt_append_command(pkt,CMDQ_CODE_WFE,event,arg_b);+return0;}EXPORT_SYMBOL(cmdq_pkt_wfe);-intcmdq_pkt_clear_event(structcmdq_pkt*pkt,u32event)+intcmdq_pkt_clear_event(structcmdq_pkt*pkt,u16event){+structcmdq_instruction*inst;+if(event>=CMDQ_MAX_EVENT)return-EINVAL;-returncmdq_pkt_append_command(pkt,CMDQ_CODE_WFE,event,-CMDQ_WFE_UPDATE);+inst=cmdq_pkt_append_command(pkt);+if(!inst)+return-ENOMEM;++inst->op=CMDQ_CODE_WFE;+inst->value=CMDQ_WFE_UPDATE;+inst->event=event;++return0;}EXPORT_SYMBOL(cmdq_pkt_clear_event);staticintcmdq_pkt_finalize(structcmdq_pkt*pkt){-interr;+structcmdq_instruction*inst;++inst=cmdq_pkt_append_command(pkt);+if(!inst)+return-ENOMEM;-/* insert EOC and generate IRQ for each command iteration */-err=cmdq_pkt_append_command(pkt,CMDQ_CODE_EOC,0,CMDQ_EOC_IRQ_EN);+inst->op=CMDQ_CODE_EOC;+inst->value=CMDQ_EOC_IRQ_EN;-/* JUMP to end */-err|=cmdq_pkt_append_command(pkt,CMDQ_CODE_JUMP,0,CMDQ_JUMP_PASS);+inst=cmdq_pkt_append_command(pkt);+if(!inst)+return-ENOMEM;++inst->op=CMDQ_CODE_JUMP;+inst->value=CMDQ_JUMP_PASS;-returnerr;+return0;}staticvoidcmdq_pkt_flush_async_cb(structcmdq_cb_datadata)
Hi, Bibby:
On Thu, 2019-05-16 at 17:02 +0800, Bibby Hsieh wrote:
Define a instruction structure for gce driver to append command.
This structure can make the client's code more readability.
Signed-off-by: Bibby Hsieh <redacted>
---
drivers/soc/mediatek/mtk-cmdq-helper.c | 113 +++++++++++++++--------
include/linux/mailbox/mtk-cmdq-mailbox.h | 2 +
include/linux/soc/mediatek/mtk-cmdq.h | 14 +--
3 files changed, 84 insertions(+), 45 deletions(-)
[snip]
/**
* cmdq_pkt_write_mask() - append write command with mask to the CMDQ packet
* @pkt: the CMDQ packet
- * @value: the specified target register value
* @subsys: the CMDQ sub system code
* @offset: register offset from CMDQ sub system
+ * @value: the specified target register value
* @mask: the specified target register mask
*
* Return: 0 for success; else the error code is returned
*/
-int cmdq_pkt_write_mask(struct cmdq_pkt *pkt, u32 value,
- u32 subsys, u32 offset, u32 mask);
+int cmdq_pkt_write_mask(struct cmdq_pkt *pkt, u8 subsys, u16 offset,
+ u32 value, u32 mask);
You have do two things for this interface: one is reordering the
parameter, another one is changing type of subsys from u32 to u8.
Define the instruction struct is not necessary to change the order and
type. I would like you to separate these two things to another patches.
So the patch sequence may be:
1. Reorder parameter of cmdq_pkt_write_mask()
2. Change subsys type to u8
3. define the instruction struct
Regards,
CK
quoted hunk
/**
* cmdq_pkt_wfe() - append wait for event command to the CMDQ packet
@@ -88,7 +88,7 @@ int cmdq_pkt_write_mask(struct cmdq_pkt *pkt, u32 value, * * Return: 0 for success; else the error code is returned */-int cmdq_pkt_wfe(struct cmdq_pkt *pkt, u32 event);+int cmdq_pkt_wfe(struct cmdq_pkt *pkt, u16 event); /** * cmdq_pkt_clear_event() - append clear event command to the CMDQ packet
@@ -97,7 +97,7 @@ int cmdq_pkt_wfe(struct cmdq_pkt *pkt, u32 event); * * Return: 0 for success; else the error code is returned */-int cmdq_pkt_clear_event(struct cmdq_pkt *pkt, u32 event);+int cmdq_pkt_clear_event(struct cmdq_pkt *pkt, u16 event); /** * cmdq_pkt_flush_async() - trigger CMDQ to asynchronously execute the CMDQ
"thread-num" is an unused property so we remove it from example.
Signed-off-by: Bibby Hsieh <redacted>
Reviewed-by: Rob Herring <robh@kernel.org>
---
Documentation/devicetree/bindings/mailbox/mtk-gce.txt | 1 -
1 file changed, 1 deletion(-)
GCE cannot know the register base address, this function
can help cmdq client to get the relationship of subsys
and register base address.
Signed-off-by: Bibby Hsieh <redacted>
---
drivers/soc/mediatek/mtk-cmdq-helper.c | 25 +++++++++++++++++++++++++
include/linux/soc/mediatek/mtk-cmdq.h | 18 ++++++++++++++++++
2 files changed, 43 insertions(+)
Hi, Bibby:
On Thu, 2019-05-16 at 17:02 +0800, Bibby Hsieh wrote:
quoted hunk
GCE cannot know the register base address, this function
can help cmdq client to get the relationship of subsys
and register base address.
Signed-off-by: Bibby Hsieh <redacted>
---
drivers/soc/mediatek/mtk-cmdq-helper.c | 25 +++++++++++++++++++++++++
include/linux/soc/mediatek/mtk-cmdq.h | 18 ++++++++++++++++++
2 files changed, 43 insertions(+)
@@ -142,4 +148,16 @@ int cmdq_pkt_flush_async(struct cmdq_pkt *pkt, cmdq_async_flush_cb cb, */ int cmdq_pkt_flush(struct cmdq_pkt *pkt);+/**+ * cmdq_dev_get_subsys() - parse sub system from the device node of CMDQ client+ * @dev: device of CMDQ mailbox client+ * @idx: the index of desired subsys+ *+ * Return: CMDQ subsys pointer+ *+ * Help CMDQ client pasing the sub system number+ * from the device node of CMDQ client.+ */+struct cmdq_subsys *cmdq_dev_get_subsys(struct device *dev, int idx);+ #endif /* __MTK_CMDQ_H__ */
@@ -9,7 +9,7 @@ CMDQ driver uses mailbox framework for communication. Please refer to mailbox.txt for generic information about mailbox device-tree bindings. Required properties:-- compatible: Must be "mediatek,mt8173-gce"+- compatible: can be "mediatek,mt8173-gce" or "mediatek,mt8183-gce" - reg: Address range of the GCE unit - interrupts: The interrupt signal from the GCE block - clock: Clocks according to the common clock binding
@@ -28,8 +28,8 @@ Required properties for a client device: - mediatek,gce-subsys: u32, specify the sub-system id which is corresponding to the register address.-Some vaules of properties are defined in 'dt-bindings/gce/mt8173-gce.h'. Such as-sub-system ids, thread priority, event ids.+Some vaules of properties are defined in 'dt-bindings/gce/mt8173-gce.h'+or 'dt-binding/gce/mt8183-gce.h'. Such as sub-system ids, thread priority, event ids. Example:
GCE hardware stored event information in own internal sysram,
if the initial value in those sysram is not zero value
it will cause a situation that gce can wait the event immediately
after client ask gce to wait event but not really trigger the
corresponding hardware.
In order to make sure that the wait event function is
exactly correct, we need to clear the sysram value in
cmdq initial flow.
Fixes: 623a6143a845 ("mailbox: mediatek: Add Mediatek CMDQ driver")
Signed-off-by: Bibby Hsieh <redacted>
Reviewed-by: CK Hu <redacted>
---
drivers/mailbox/mtk-cmdq-mailbox.c | 5 +++++
include/linux/mailbox/mtk-cmdq-mailbox.h | 2 ++
include/linux/soc/mediatek/mtk-cmdq.h | 3 ---
3 files changed, 7 insertions(+), 3 deletions(-)
tcmdq driver provide a function that get the relationship
of sub system number from device node for client.
add specification for #subsys-cells, mediatek,gce-subsys.
Signed-off-by: Bibby Hsieh <redacted>
---
.../devicetree/bindings/mailbox/mtk-gce.txt | 15 ++++++++++++---
1 file changed, 12 insertions(+), 3 deletions(-)
@@ -21,11 +21,19 @@ Required properties: priority: Priority of GCE thread. atomic_exec: GCE processing continuous packets of commands in atomic way.+- #subsys-cells: Should be 3.+ <&phandle subsys_number start_offset size>+ phandle: Label name of a gce node.+ subsys_number: specify the sub-system id which is corresponding+ to the register address.+ start_offset: the start offset of register address that GCE can access.+ size: the total size of register address that GCE can access. Required properties for a client device: - mboxes: Client use mailbox to communicate with GCE, it should have this property and list of phandle, mailbox specifiers.-- mediatek,gce-subsys: u32, specify the sub-system id which is corresponding+Optional properties for a client device:+- mediatek,gce-client-reg: u32, specify the sub-system id which is corresponding to the register address. Some vaules of properties are defined in 'dt-bindings/gce/mt8173-gce.h'
@@ -40,6 +48,7 @@ Example: clocks = <&infracfg CLK_INFRA_GCE>; clock-names = "gce"; #mbox-cells = <3>;+ #subsys-cells = <3>; }; Example for a client device:
@@ -21,11 +21,19 @@ Required properties: priority: Priority of GCE thread. atomic_exec: GCE processing continuous packets of commands in atomic way.+- #subsys-cells: Should be 3.+ <&phandle subsys_number start_offset size>+ phandle: Label name of a gce node.+ subsys_number: specify the sub-system id which is corresponding+ to the register address.+ start_offset: the start offset of register address that GCE can access.+ size: the total size of register address that GCE can access. Required properties for a client device: - mboxes: Client use mailbox to communicate with GCE, it should have this property and list of phandle, mailbox specifiers.-- mediatek,gce-subsys: u32, specify the sub-system id which is corresponding+Optional properties for a client device:+- mediatek,gce-client-reg: u32, specify the sub-system id which is corresponding to the register address. Some vaules of properties are defined in 'dt-bindings/gce/mt8173-gce.h'
@@ -40,6 +48,7 @@ Example: clocks = <&infracfg CLK_INFRA_GCE>; clock-names = "gce"; #mbox-cells = <3>;+ #subsys-cells = <3>; }; Example for a client device:
Client hardware would send event to GCE hardware,
mediatek,gce-event-names and mediatek,gce-events
can be used to present the event.
Signed-off-by: Bibby Hsieh <redacted>
---
Documentation/devicetree/bindings/mailbox/mtk-gce.txt | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
@@ -35,6 +35,8 @@ Required properties for a client device: Optional properties for a client device: - mediatek,gce-client-reg: u32, specify the sub-system id which is corresponding to the register address.+- mediatek,gce-events: u32, the event number defined in+ 'dt-bindings/gce/mt8173-gce.h' or 'dt-binding/gce/mt8183-gce.h'. Some vaules of properties are defined in 'dt-bindings/gce/mt8173-gce.h' or 'dt-binding/gce/mt8183-gce.h'. Such as sub-system ids, thread priority, event ids.
From: Rob Herring <robh@kernel.org> Date: 2019-05-24 21:54:11
On Thu, May 16, 2019 at 05:02:16PM +0800, Bibby Hsieh wrote:
Client hardware would send event to GCE hardware,
mediatek,gce-event-names and mediatek,gce-events
We removed mediatek,gce-event-names?
quoted hunk
can be used to present the event.
Signed-off-by: Bibby Hsieh <redacted>
---
Documentation/devicetree/bindings/mailbox/mtk-gce.txt | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
@@ -35,6 +35,8 @@ Required properties for a client device: Optional properties for a client device: - mediatek,gce-client-reg: u32, specify the sub-system id which is corresponding to the register address.+- mediatek,gce-events: u32, the event number defined in+ 'dt-bindings/gce/mt8173-gce.h' or 'dt-binding/gce/mt8183-gce.h'.
This and the example don't match. Is it an u32 or an array of u32? If
the latter, how many elements?
quoted hunk
Some vaules of properties are defined in 'dt-bindings/gce/mt8173-gce.h'
or 'dt-binding/gce/mt8183-gce.h'. Such as sub-system ids, thread priority, event ids.
When client ask gce to clear or wait for event,
client need to pass event number to the API.
We suggest client store the event information in device node,
so we provide an API for client parse the event property.
Signed-off-by: Bibby Hsieh <redacted>
---
drivers/soc/mediatek/mtk-cmdq-helper.c | 18 ++++++++++++++++++
include/linux/soc/mediatek/mtk-cmdq.h | 12 ++++++++++++
2 files changed, 30 insertions(+)
Hi, Bibby:
On Thu, 2019-05-16 at 17:02 +0800, Bibby Hsieh wrote:
quoted hunk
When client ask gce to clear or wait for event,
client need to pass event number to the API.
We suggest client store the event information in device node,
so we provide an API for client parse the event property.
Signed-off-by: Bibby Hsieh <redacted>
---
drivers/soc/mediatek/mtk-cmdq-helper.c | 18 ++++++++++++++++++
include/linux/soc/mediatek/mtk-cmdq.h | 12 ++++++++++++
2 files changed, 30 insertions(+)
The interrupt mask and thread number has positive correlation,
so we move the CMDQ_IRQ_MASK into cmdq driver data and calculate
it by thread number.
Signed-off-by: Bibby Hsieh <redacted>
Reviewed-by: CK Hu <redacted>
---
drivers/mailbox/mtk-cmdq-mailbox.c | 12 +++++++-----
1 file changed, 7 insertions(+), 5 deletions(-)
@@ -472,6 +472,9 @@ static int cmdq_probe(struct platform_device *pdev)dev_err(dev,"failed to get irq\n");return-EINVAL;}++cmdq->thread_nr=(u32)(unsignedlong)of_device_get_match_data(dev);+cmdq->irq_mask=GENMASK(cmdq->thread_nr-1,0);err=devm_request_irq(dev,cmdq->irq,cmdq_irq_handler,IRQF_SHARED,"mtk_cmdq",cmdq);if(err<0){
@@ -488,7 +491,6 @@ static int cmdq_probe(struct platform_device *pdev)returnPTR_ERR(cmdq->clock);}-cmdq->thread_nr=(u32)(unsignedlong)of_device_get_match_data(dev);cmdq->mbox.dev=dev;cmdq->mbox.chans=devm_kcalloc(dev,cmdq->thread_nr,sizeof(*cmdq->mbox.chans),GFP_KERNEL);
--
2.18.0
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel