2018-03-20 12:57:03 +00:00
|
|
|
// SPDX-License-Identifier: GPL-2.0
|
|
|
|
|
|
|
|
#ifndef __USB_TYPEC_MUX
|
|
|
|
#define __USB_TYPEC_MUX
|
|
|
|
|
2020-03-02 13:53:47 +00:00
|
|
|
#include <linux/property.h>
|
2018-03-20 12:57:03 +00:00
|
|
|
#include <linux/usb/typec.h>
|
|
|
|
|
|
|
|
struct device;
|
2019-05-31 14:15:41 +00:00
|
|
|
struct typec_mux;
|
2022-04-22 22:23:48 +00:00
|
|
|
struct typec_mux_dev;
|
2019-05-31 14:15:41 +00:00
|
|
|
struct typec_switch;
|
2022-04-22 22:23:48 +00:00
|
|
|
struct typec_switch_dev;
|
2019-12-30 14:26:08 +00:00
|
|
|
struct typec_altmode;
|
2019-05-31 14:15:41 +00:00
|
|
|
struct fwnode_handle;
|
2018-03-20 12:57:03 +00:00
|
|
|
|
2022-04-22 22:23:48 +00:00
|
|
|
typedef int (*typec_switch_set_fn_t)(struct typec_switch_dev *sw,
|
2019-05-31 14:15:41 +00:00
|
|
|
enum typec_orientation orientation);
|
2018-03-20 12:57:03 +00:00
|
|
|
|
2019-05-31 14:15:41 +00:00
|
|
|
struct typec_switch_desc {
|
|
|
|
struct fwnode_handle *fwnode;
|
|
|
|
typec_switch_set_fn_t set;
|
2020-03-02 13:53:45 +00:00
|
|
|
const char *name;
|
2019-05-31 14:15:41 +00:00
|
|
|
void *drvdata;
|
2018-03-20 12:57:03 +00:00
|
|
|
};
|
|
|
|
|
2020-03-02 13:53:47 +00:00
|
|
|
struct typec_switch *fwnode_typec_switch_get(struct fwnode_handle *fwnode);
|
2018-03-20 12:57:03 +00:00
|
|
|
void typec_switch_put(struct typec_switch *sw);
|
2020-03-02 13:53:46 +00:00
|
|
|
int typec_switch_set(struct typec_switch *sw,
|
|
|
|
enum typec_orientation orientation);
|
|
|
|
|
2020-03-02 13:53:47 +00:00
|
|
|
static inline struct typec_switch *typec_switch_get(struct device *dev)
|
|
|
|
{
|
|
|
|
return fwnode_typec_switch_get(dev_fwnode(dev));
|
|
|
|
}
|
|
|
|
|
2022-04-22 22:23:48 +00:00
|
|
|
struct typec_switch_dev *
|
2019-05-31 14:15:41 +00:00
|
|
|
typec_switch_register(struct device *parent,
|
|
|
|
const struct typec_switch_desc *desc);
|
2022-04-22 22:23:48 +00:00
|
|
|
void typec_switch_unregister(struct typec_switch_dev *sw);
|
2018-03-20 12:57:03 +00:00
|
|
|
|
2022-04-22 22:23:48 +00:00
|
|
|
void typec_switch_set_drvdata(struct typec_switch_dev *sw, void *data);
|
|
|
|
void *typec_switch_get_drvdata(struct typec_switch_dev *sw);
|
2019-05-31 14:15:41 +00:00
|
|
|
|
2019-12-30 14:26:08 +00:00
|
|
|
struct typec_mux_state {
|
|
|
|
struct typec_altmode *alt;
|
|
|
|
unsigned long mode;
|
|
|
|
void *data;
|
|
|
|
};
|
|
|
|
|
2022-04-22 22:23:48 +00:00
|
|
|
typedef int (*typec_mux_set_fn_t)(struct typec_mux_dev *mux,
|
2019-12-30 14:26:08 +00:00
|
|
|
struct typec_mux_state *state);
|
2019-05-31 14:15:41 +00:00
|
|
|
|
|
|
|
struct typec_mux_desc {
|
|
|
|
struct fwnode_handle *fwnode;
|
|
|
|
typec_mux_set_fn_t set;
|
2020-03-02 13:53:45 +00:00
|
|
|
const char *name;
|
2019-05-31 14:15:41 +00:00
|
|
|
void *drvdata;
|
|
|
|
};
|
|
|
|
|
2022-06-15 17:20:18 +00:00
|
|
|
#if IS_ENABLED(CONFIG_TYPEC)
|
|
|
|
|
2023-05-26 13:14:34 +00:00
|
|
|
struct typec_mux *fwnode_typec_mux_get(struct fwnode_handle *fwnode);
|
2018-03-20 12:57:03 +00:00
|
|
|
void typec_mux_put(struct typec_mux *mux);
|
2020-03-02 13:53:46 +00:00
|
|
|
int typec_mux_set(struct typec_mux *mux, struct typec_mux_state *state);
|
|
|
|
|
2022-04-22 22:23:48 +00:00
|
|
|
struct typec_mux_dev *
|
2019-05-31 14:15:41 +00:00
|
|
|
typec_mux_register(struct device *parent, const struct typec_mux_desc *desc);
|
2022-04-22 22:23:48 +00:00
|
|
|
void typec_mux_unregister(struct typec_mux_dev *mux);
|
2018-03-20 12:57:03 +00:00
|
|
|
|
2022-04-22 22:23:48 +00:00
|
|
|
void typec_mux_set_drvdata(struct typec_mux_dev *mux, void *data);
|
|
|
|
void *typec_mux_get_drvdata(struct typec_mux_dev *mux);
|
2019-05-31 14:15:41 +00:00
|
|
|
|
2022-06-15 17:20:18 +00:00
|
|
|
#else
|
|
|
|
|
2023-06-01 05:03:25 +00:00
|
|
|
static inline struct typec_mux *fwnode_typec_mux_get(struct fwnode_handle *fwnode)
|
2022-06-15 17:20:18 +00:00
|
|
|
{
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void typec_mux_put(struct typec_mux *mux) {}
|
|
|
|
|
|
|
|
static inline int typec_mux_set(struct typec_mux *mux, struct typec_mux_state *state)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline struct typec_mux_dev *
|
|
|
|
typec_mux_register(struct device *parent, const struct typec_mux_desc *desc)
|
|
|
|
{
|
|
|
|
return ERR_PTR(-EOPNOTSUPP);
|
|
|
|
}
|
|
|
|
static inline void typec_mux_unregister(struct typec_mux_dev *mux) {}
|
|
|
|
|
|
|
|
static inline void typec_mux_set_drvdata(struct typec_mux_dev *mux, void *data) {}
|
|
|
|
static inline void *typec_mux_get_drvdata(struct typec_mux_dev *mux)
|
|
|
|
{
|
|
|
|
return ERR_PTR(-EOPNOTSUPP);
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif /* CONFIG_TYPEC */
|
|
|
|
|
2023-05-26 13:14:34 +00:00
|
|
|
static inline struct typec_mux *typec_mux_get(struct device *dev)
|
2022-06-15 17:20:18 +00:00
|
|
|
{
|
2023-05-26 13:14:34 +00:00
|
|
|
return fwnode_typec_mux_get(dev_fwnode(dev));
|
2022-06-15 17:20:18 +00:00
|
|
|
}
|
|
|
|
|
2018-03-20 12:57:03 +00:00
|
|
|
#endif /* __USB_TYPEC_MUX */
|