1// SPDX-License-Identifier: GPL-2.0
2/*
3 * Copyright (c) 2024, Linaro Ltd. All rights reserved.
4 */
5
6#include <linux/err.h>
7#include <linux/interrupt.h>
8#include <linux/kernel.h>
9#include <linux/mod_devicetable.h>
10#include <linux/module.h>
11#include <linux/platform_device.h>
12#include <linux/regmap.h>
13#include <linux/regulator/consumer.h>
14#include <linux/slab.h>
15#include <linux/usb/pd.h>
16#include <linux/usb/tcpm.h>
17#include "qcom_pmic_typec.h"
18#include "qcom_pmic_typec_pdphy.h"
19
20static int qcom_pmic_typec_pdphy_stub_pd_transmit(struct tcpc_dev *tcpc,
21 enum tcpm_transmit_type type,
22 const struct pd_message *msg,
23 unsigned int negotiated_rev)
24{
25 struct pmic_typec *tcpm = tcpc_to_tcpm(tcpc);
26 struct device *dev = tcpm->dev;
27
28 dev_dbg(dev, "pdphy_transmit: type=%d\n", type);
29
30 tcpm_pd_transmit_complete(port: tcpm->tcpm_port,
31 status: TCPC_TX_SUCCESS);
32
33 return 0;
34}
35
36static int qcom_pmic_typec_pdphy_stub_set_pd_rx(struct tcpc_dev *tcpc, bool on)
37{
38 struct pmic_typec *tcpm = tcpc_to_tcpm(tcpc);
39 struct device *dev = tcpm->dev;
40
41 dev_dbg(dev, "set_pd_rx: %s\n", on ? "on" : "off");
42
43 return 0;
44}
45
46static int qcom_pmic_typec_pdphy_stub_set_roles(struct tcpc_dev *tcpc, bool attached,
47 enum typec_role power_role,
48 enum typec_data_role data_role)
49{
50 struct pmic_typec *tcpm = tcpc_to_tcpm(tcpc);
51 struct device *dev = tcpm->dev;
52
53 dev_dbg(dev, "pdphy_set_roles: data_role_host=%d power_role_src=%d\n",
54 data_role, power_role);
55
56 return 0;
57}
58
59static int qcom_pmic_typec_pdphy_stub_start(struct pmic_typec *tcpm,
60 struct tcpm_port *tcpm_port)
61{
62 return 0;
63}
64
65static void qcom_pmic_typec_pdphy_stub_stop(struct pmic_typec *tcpm)
66{
67}
68
69int qcom_pmic_typec_pdphy_stub_probe(struct platform_device *pdev,
70 struct pmic_typec *tcpm)
71{
72 tcpm->tcpc.set_pd_rx = qcom_pmic_typec_pdphy_stub_set_pd_rx;
73 tcpm->tcpc.set_roles = qcom_pmic_typec_pdphy_stub_set_roles;
74 tcpm->tcpc.pd_transmit = qcom_pmic_typec_pdphy_stub_pd_transmit;
75
76 tcpm->pdphy_start = qcom_pmic_typec_pdphy_stub_start;
77 tcpm->pdphy_stop = qcom_pmic_typec_pdphy_stub_stop;
78
79 return 0;
80}
81

source code of linux/drivers/usb/typec/tcpm/qcom/qcom_pmic_typec_pdphy_stub.c