2626
2727struct pmic_typec_resources {
2828 const struct pmic_typec_pdphy_resources * pdphy_res ;
29- struct pmic_typec_port_resources * port_res ;
29+ const struct pmic_typec_port_resources * port_res ;
3030};
3131
32- static int qcom_pmic_typec_get_vbus (struct tcpc_dev * tcpc )
33- {
34- struct pmic_typec * tcpm = tcpc_to_tcpm (tcpc );
35- int ret ;
36-
37- mutex_lock (& tcpm -> lock );
38- ret = tcpm -> vbus_enabled || qcom_pmic_typec_port_get_vbus (tcpm -> pmic_typec_port );
39- mutex_unlock (& tcpm -> lock );
40-
41- return ret ;
42- }
43-
44- static int qcom_pmic_typec_set_vbus (struct tcpc_dev * tcpc , bool on , bool sink )
45- {
46- struct pmic_typec * tcpm = tcpc_to_tcpm (tcpc );
47- int ret = 0 ;
48-
49- mutex_lock (& tcpm -> lock );
50- if (tcpm -> vbus_enabled == on )
51- goto done ;
52-
53- ret = qcom_pmic_typec_port_set_vbus (tcpm -> pmic_typec_port , on );
54- if (ret )
55- goto done ;
56-
57- tcpm -> vbus_enabled = on ;
58- tcpm_vbus_change (tcpm -> tcpm_port );
59-
60- done :
61- dev_dbg (tcpm -> dev , "set_vbus set: %d result %d\n" , on , ret );
62- mutex_unlock (& tcpm -> lock );
63-
64- return ret ;
65- }
66-
67- static int qcom_pmic_typec_set_vconn (struct tcpc_dev * tcpc , bool on )
68- {
69- struct pmic_typec * tcpm = tcpc_to_tcpm (tcpc );
70-
71- return qcom_pmic_typec_port_set_vconn (tcpm -> pmic_typec_port , on );
72- }
73-
74- static int qcom_pmic_typec_get_cc (struct tcpc_dev * tcpc ,
75- enum typec_cc_status * cc1 ,
76- enum typec_cc_status * cc2 )
77- {
78- struct pmic_typec * tcpm = tcpc_to_tcpm (tcpc );
79-
80- return qcom_pmic_typec_port_get_cc (tcpm -> pmic_typec_port , cc1 , cc2 );
81- }
82-
83- static int qcom_pmic_typec_set_cc (struct tcpc_dev * tcpc ,
84- enum typec_cc_status cc )
85- {
86- struct pmic_typec * tcpm = tcpc_to_tcpm (tcpc );
87-
88- return qcom_pmic_typec_port_set_cc (tcpm -> pmic_typec_port , cc );
89- }
90-
91- static int qcom_pmic_typec_set_polarity (struct tcpc_dev * tcpc ,
92- enum typec_cc_polarity pol )
93- {
94- /* Polarity is set separately by phy-qcom-qmp.c */
95- return 0 ;
96- }
97-
98- static int qcom_pmic_typec_start_toggling (struct tcpc_dev * tcpc ,
99- enum typec_port_type port_type ,
100- enum typec_cc_status cc )
101- {
102- struct pmic_typec * tcpm = tcpc_to_tcpm (tcpc );
103-
104- return qcom_pmic_typec_port_start_toggling (tcpm -> pmic_typec_port ,
105- port_type , cc );
106- }
107-
10832static int qcom_pmic_typec_init (struct tcpc_dev * tcpc )
10933{
11034 return 0 ;
@@ -131,13 +55,6 @@ static int qcom_pmic_typec_probe(struct platform_device *pdev)
13155
13256 tcpm -> dev = dev ;
13357 tcpm -> tcpc .init = qcom_pmic_typec_init ;
134- tcpm -> tcpc .get_vbus = qcom_pmic_typec_get_vbus ;
135- tcpm -> tcpc .set_vbus = qcom_pmic_typec_set_vbus ;
136- tcpm -> tcpc .set_cc = qcom_pmic_typec_set_cc ;
137- tcpm -> tcpc .get_cc = qcom_pmic_typec_get_cc ;
138- tcpm -> tcpc .set_polarity = qcom_pmic_typec_set_polarity ;
139- tcpm -> tcpc .set_vconn = qcom_pmic_typec_set_vconn ;
140- tcpm -> tcpc .start_toggling = qcom_pmic_typec_start_toggling ;
14158
14259 regmap = dev_get_regmap (dev -> parent , NULL );
14360 if (!regmap ) {
@@ -149,11 +66,7 @@ static int qcom_pmic_typec_probe(struct platform_device *pdev)
14966 if (ret )
15067 return ret ;
15168
152- tcpm -> pmic_typec_port = qcom_pmic_typec_port_alloc (dev );
153- if (IS_ERR (tcpm -> pmic_typec_port ))
154- return PTR_ERR (tcpm -> pmic_typec_port );
155-
156- ret = qcom_pmic_typec_port_probe (pdev , tcpm -> pmic_typec_port ,
69+ ret = qcom_pmic_typec_port_probe (pdev , tcpm ,
15770 res -> port_res , regmap , base [0 ]);
15871 if (ret )
15972 return ret ;
@@ -163,7 +76,6 @@ static int qcom_pmic_typec_probe(struct platform_device *pdev)
16376 if (ret )
16477 return ret ;
16578
166- mutex_init (& tcpm -> lock );
16779 platform_set_drvdata (pdev , tcpm );
16880
16981 tcpm -> tcpc .fwnode = device_get_named_child_node (tcpm -> dev , "connector" );
@@ -180,8 +92,7 @@ static int qcom_pmic_typec_probe(struct platform_device *pdev)
18092 goto fwnode_remove ;
18193 }
18294
183- ret = qcom_pmic_typec_port_start (tcpm -> pmic_typec_port ,
184- tcpm -> tcpm_port );
95+ ret = tcpm -> port_start (tcpm , tcpm -> tcpm_port );
18596 if (ret )
18697 goto fwnode_remove ;
18798
@@ -202,50 +113,12 @@ static void qcom_pmic_typec_remove(struct platform_device *pdev)
202113 struct pmic_typec * tcpm = platform_get_drvdata (pdev );
203114
204115 tcpm -> pdphy_stop (tcpm );
205- qcom_pmic_typec_port_stop ( tcpm -> pmic_typec_port );
116+ tcpm -> port_stop ( tcpm );
206117 tcpm_unregister_port (tcpm -> tcpm_port );
207118 fwnode_remove_software_node (tcpm -> tcpc .fwnode );
208119}
209120
210- static struct pmic_typec_port_resources pm8150b_port_res = {
211- .irq_params = {
212- {
213- .irq_name = "vpd-detect" ,
214- .virq = PMIC_TYPEC_VPD_IRQ ,
215- },
216-
217- {
218- .irq_name = "cc-state-change" ,
219- .virq = PMIC_TYPEC_CC_STATE_IRQ ,
220- },
221- {
222- .irq_name = "vconn-oc" ,
223- .virq = PMIC_TYPEC_VCONN_OC_IRQ ,
224- },
225-
226- {
227- .irq_name = "vbus-change" ,
228- .virq = PMIC_TYPEC_VBUS_IRQ ,
229- },
230-
231- {
232- .irq_name = "attach-detach" ,
233- .virq = PMIC_TYPEC_ATTACH_DETACH_IRQ ,
234- },
235- {
236- .irq_name = "legacy-cable-detect" ,
237- .virq = PMIC_TYPEC_LEGACY_CABLE_IRQ ,
238- },
239-
240- {
241- .irq_name = "try-snk-src-detect" ,
242- .virq = PMIC_TYPEC_TRY_SNK_SRC_IRQ ,
243- },
244- },
245- .nr_irqs = 7 ,
246- };
247-
248- static struct pmic_typec_resources pm8150b_typec_res = {
121+ static const struct pmic_typec_resources pm8150b_typec_res = {
249122 .pdphy_res = & pm8150b_pdphy_res ,
250123 .port_res = & pm8150b_port_res ,
251124};
0 commit comments