@@ -112,7 +112,7 @@ struct scmi_chan_info {
112
112
* @version: SCMI revision information containing protocol version,
113
113
* implementation version and (sub-)vendor identification.
114
114
* @minfo: Message info
115
- * @tx_idr: IDR object to map protocol id to channel info pointer
115
+ * @tx_idr: IDR object to map protocol id to Tx channel info pointer
116
116
* @protocols_imp: List of protocols implemented, currently maximum of
117
117
* MAX_PROTOCOLS_IMP elements allocated by the base protocol
118
118
* @node: List head
@@ -640,22 +640,27 @@ static int scmi_xfer_info_init(struct scmi_info *sinfo)
640
640
return 0 ;
641
641
}
642
642
643
- static int scmi_mailbox_check (struct device_node * np )
643
+ static int scmi_mailbox_check (struct device_node * np , int idx )
644
644
{
645
- return of_parse_phandle_with_args (np , "mboxes" , "#mbox-cells" , 0 , NULL );
645
+ return of_parse_phandle_with_args (np , "mboxes" , "#mbox-cells" ,
646
+ idx , NULL );
646
647
}
647
648
648
- static inline int
649
- scmi_mbox_chan_setup ( struct scmi_info * info , struct device * dev , int prot_id )
649
+ static int scmi_mbox_chan_setup ( struct scmi_info * info , struct device * dev ,
650
+ int prot_id , bool tx )
650
651
{
651
- int ret ;
652
+ int ret , idx ;
652
653
struct resource res ;
653
654
resource_size_t size ;
654
655
struct device_node * shmem , * np = dev -> of_node ;
655
656
struct scmi_chan_info * cinfo ;
656
657
struct mbox_client * cl ;
658
+ const char * desc = tx ? "Tx" : "Rx" ;
659
+
660
+ /* Transmit channel is first entry i.e. index 0 */
661
+ idx = tx ? 0 : 1 ;
657
662
658
- if (scmi_mailbox_check (np )) {
663
+ if (scmi_mailbox_check (np , idx )) {
659
664
cinfo = idr_find (& info -> tx_idr , SCMI_PROTOCOL_BASE );
660
665
goto idr_alloc ;
661
666
}
@@ -669,31 +674,31 @@ scmi_mbox_chan_setup(struct scmi_info *info, struct device *dev, int prot_id)
669
674
cl = & cinfo -> cl ;
670
675
cl -> dev = dev ;
671
676
cl -> rx_callback = scmi_rx_callback ;
672
- cl -> tx_prepare = scmi_tx_prepare ;
677
+ cl -> tx_prepare = tx ? scmi_tx_prepare : NULL ;
673
678
cl -> tx_block = false;
674
- cl -> knows_txdone = true ;
679
+ cl -> knows_txdone = tx ;
675
680
676
- shmem = of_parse_phandle (np , "shmem" , 0 );
681
+ shmem = of_parse_phandle (np , "shmem" , idx );
677
682
ret = of_address_to_resource (shmem , 0 , & res );
678
683
of_node_put (shmem );
679
684
if (ret ) {
680
- dev_err (dev , "failed to get SCMI Tx payload mem resource \n" );
685
+ dev_err (dev , "failed to get SCMI %s payload memory \n" , desc );
681
686
return ret ;
682
687
}
683
688
684
689
size = resource_size (& res );
685
690
cinfo -> payload = devm_ioremap (info -> dev , res .start , size );
686
691
if (!cinfo -> payload ) {
687
- dev_err (dev , "failed to ioremap SCMI Tx payload\n" );
692
+ dev_err (dev , "failed to ioremap SCMI %s payload\n" , desc );
688
693
return - EADDRNOTAVAIL ;
689
694
}
690
695
691
- /* Transmit channel is first entry i.e. index 0 */
692
- cinfo -> chan = mbox_request_channel (cl , 0 );
696
+ cinfo -> chan = mbox_request_channel (cl , idx );
693
697
if (IS_ERR (cinfo -> chan )) {
694
698
ret = PTR_ERR (cinfo -> chan );
695
699
if (ret != - EPROBE_DEFER )
696
- dev_err (dev , "failed to request SCMI Tx mailbox\n" );
700
+ dev_err (dev , "failed to request SCMI %s mailbox\n" ,
701
+ desc );
697
702
return ret ;
698
703
}
699
704
@@ -721,7 +726,7 @@ scmi_create_protocol_device(struct device_node *np, struct scmi_info *info,
721
726
return ;
722
727
}
723
728
724
- if (scmi_mbox_chan_setup (info , & sdev -> dev , prot_id )) {
729
+ if (scmi_mbox_chan_setup (info , & sdev -> dev , prot_id , true )) {
725
730
dev_err (& sdev -> dev , "failed to setup transport\n" );
726
731
scmi_device_destroy (sdev );
727
732
return ;
@@ -741,7 +746,7 @@ static int scmi_probe(struct platform_device *pdev)
741
746
struct device_node * child , * np = dev -> of_node ;
742
747
743
748
/* Only mailbox method supported, check for the presence of one */
744
- if (scmi_mailbox_check (np )) {
749
+ if (scmi_mailbox_check (np , 0 )) {
745
750
dev_err (dev , "no mailbox found in %pOF\n" , np );
746
751
return - EINVAL ;
747
752
}
@@ -769,7 +774,7 @@ static int scmi_probe(struct platform_device *pdev)
769
774
handle -> dev = info -> dev ;
770
775
handle -> version = & info -> version ;
771
776
772
- ret = scmi_mbox_chan_setup (info , dev , SCMI_PROTOCOL_BASE );
777
+ ret = scmi_mbox_chan_setup (info , dev , SCMI_PROTOCOL_BASE , true );
773
778
if (ret )
774
779
return ret ;
775
780
0 commit comments