linux/drivers/usb/typec/pd.c

// SPDX-License-Identifier: GPL-2.0
/*
 * USB Power Delivery sysfs entries
 *
 * Copyright (C) 2022, Intel Corporation
 * Author: Heikki Krogerus <[email protected]>
 */

#include <linux/slab.h>
#include <linux/usb/pd.h>

#include "pd.h"

static DEFINE_IDA(pd_ida);

static struct class pd_class =;

#define to_pdo(o)

struct pdo {};

static void pdo_release(struct device *dev)
{}

/* -------------------------------------------------------------------------- */
/* Fixed Supply */

static ssize_t
dual_role_power_show(struct device *dev, struct device_attribute *attr, char *buf)
{}
static DEVICE_ATTR_RO(dual_role_power);

static ssize_t
usb_suspend_supported_show(struct device *dev, struct device_attribute *attr, char *buf)
{}
static DEVICE_ATTR_RO(usb_suspend_supported);

static ssize_t
higher_capability_show(struct device *dev, struct device_attribute *attr, char *buf)
{}
static DEVICE_ATTR_RO(higher_capability);

static ssize_t
unconstrained_power_show(struct device *dev, struct device_attribute *attr, char *buf)
{}
static DEVICE_ATTR_RO(unconstrained_power);

static ssize_t
usb_communication_capable_show(struct device *dev, struct device_attribute *attr, char *buf)
{}
static DEVICE_ATTR_RO(usb_communication_capable);

static ssize_t
dual_role_data_show(struct device *dev, struct device_attribute *attr, char *buf)
{}
static DEVICE_ATTR_RO(dual_role_data);

static ssize_t
unchunked_extended_messages_supported_show(struct device *dev,
					   struct device_attribute *attr, char *buf)
{}
static DEVICE_ATTR_RO(unchunked_extended_messages_supported);

static ssize_t
peak_current_show(struct device *dev, struct device_attribute *attr, char *buf)
{}
static DEVICE_ATTR_RO(peak_current);

static ssize_t
fast_role_swap_current_show(struct device *dev, struct device_attribute *attr, char *buf)
{}
static DEVICE_ATTR_RO(fast_role_swap_current);

static ssize_t voltage_show(struct device *dev, struct device_attribute *attr, char *buf)
{}
static DEVICE_ATTR_RO(voltage);

/* Shared with Variable supplies, both source and sink */
static ssize_t current_show(struct device *dev, struct device_attribute *attr, char *buf)
{}

/* Shared with Variable type supplies */
static struct device_attribute maximum_current_attr =;

static struct device_attribute operational_current_attr =;

static struct attribute *source_fixed_supply_attrs[] =;

static umode_t fixed_attr_is_visible(struct kobject *kobj, struct attribute *attr, int n)
{}

static const struct attribute_group source_fixed_supply_group =;
__ATTRIBUTE_GROUPS();

static const struct device_type source_fixed_supply_type =;

static struct attribute *sink_fixed_supply_attrs[] =;

static const struct attribute_group sink_fixed_supply_group =;
__ATTRIBUTE_GROUPS();

static const struct device_type sink_fixed_supply_type =;

/* -------------------------------------------------------------------------- */
/* Variable Supply */

static ssize_t
maximum_voltage_show(struct device *dev, struct device_attribute *attr, char *buf)
{}
static DEVICE_ATTR_RO(maximum_voltage);

static ssize_t
minimum_voltage_show(struct device *dev, struct device_attribute *attr, char *buf)
{}
static DEVICE_ATTR_RO(minimum_voltage);

static struct attribute *source_variable_supply_attrs[] =;
ATTRIBUTE_GROUPS();

static const struct device_type source_variable_supply_type =;

static struct attribute *sink_variable_supply_attrs[] =;
ATTRIBUTE_GROUPS();

static const struct device_type sink_variable_supply_type =;

/* -------------------------------------------------------------------------- */
/* Battery */

static ssize_t
maximum_power_show(struct device *dev, struct device_attribute *attr, char *buf)
{}
static DEVICE_ATTR_RO(maximum_power);

static ssize_t
operational_power_show(struct device *dev, struct device_attribute *attr, char *buf)
{}
static DEVICE_ATTR_RO(operational_power);

static struct attribute *source_battery_attrs[] =;
ATTRIBUTE_GROUPS();

static const struct device_type source_battery_type =;

static struct attribute *sink_battery_attrs[] =;
ATTRIBUTE_GROUPS();

static const struct device_type sink_battery_type =;

/* -------------------------------------------------------------------------- */
/* Standard Power Range (SPR) Programmable Power Supply (PPS) */

static ssize_t
pps_power_limited_show(struct device *dev, struct device_attribute *attr, char *buf)
{}
static DEVICE_ATTR_RO(pps_power_limited);

static ssize_t
pps_max_voltage_show(struct device *dev, struct device_attribute *attr, char *buf)
{}

static ssize_t
pps_min_voltage_show(struct device *dev, struct device_attribute *attr, char *buf)
{}

static ssize_t
pps_max_current_show(struct device *dev, struct device_attribute *attr, char *buf)
{}

static struct device_attribute pps_max_voltage_attr =;

static struct device_attribute pps_min_voltage_attr =;

static struct device_attribute pps_max_current_attr =;

static struct attribute *source_pps_attrs[] =;
ATTRIBUTE_GROUPS();

static const struct device_type source_pps_type =;

static struct attribute *sink_pps_attrs[] =;
ATTRIBUTE_GROUPS();

static const struct device_type sink_pps_type =;

/* -------------------------------------------------------------------------- */

static const char * const supply_name[] =;

static const char * const apdo_supply_name[] =;

static const struct device_type *source_type[] =;

static const struct device_type *source_apdo_type[] =;

static const struct device_type *sink_type[] =;

static const struct device_type *sink_apdo_type[] =;

/* REVISIT: Export when EPR_*_Capabilities need to be supported. */
static int add_pdo(struct usb_power_delivery_capabilities *cap, u32 pdo, int position)
{}

static int remove_pdo(struct device *dev, void *data)
{}

/* -------------------------------------------------------------------------- */

static const char * const cap_name[] =;

static void pd_capabilities_release(struct device *dev)
{}

static const struct device_type pd_capabilities_type =;

/**
 * usb_power_delivery_register_capabilities - Register a set of capabilities.
 * @pd: The USB PD instance that the capabilities belong to.
 * @desc: Description of the Capabilities Message.
 *
 * This function registers a Capabilities Message described in @desc. The
 * capabilities will have their own sub-directory under @pd in sysfs.
 *
 * The function returns pointer to struct usb_power_delivery_capabilities, or
 * ERR_PRT(errno).
 */
struct usb_power_delivery_capabilities *
usb_power_delivery_register_capabilities(struct usb_power_delivery *pd,
					 struct usb_power_delivery_capabilities_desc *desc)
{}
EXPORT_SYMBOL_GPL();

/**
 * usb_power_delivery_unregister_capabilities - Unregister a set of capabilities
 * @cap: The capabilities
 */
void usb_power_delivery_unregister_capabilities(struct usb_power_delivery_capabilities *cap)
{}
EXPORT_SYMBOL_GPL();

/* -------------------------------------------------------------------------- */

static ssize_t revision_show(struct device *dev, struct device_attribute *attr, char *buf)
{}
static DEVICE_ATTR_RO(revision);

static ssize_t version_show(struct device *dev, struct device_attribute *attr, char *buf)
{}
static DEVICE_ATTR_RO(version);

static struct attribute *pd_attrs[] =;

static umode_t pd_attr_is_visible(struct kobject *kobj, struct attribute *attr, int n)
{}

static const struct attribute_group pd_group =;
__ATTRIBUTE_GROUPS();

static void pd_release(struct device *dev)
{}

static const struct device_type pd_type =;

struct usb_power_delivery *usb_power_delivery_find(const char *name)
{}

/**
 * usb_power_delivery_register - Register USB Power Delivery Support.
 * @parent: Parent device.
 * @desc: Description of the USB PD contract.
 *
 * This routine can be used to register USB Power Delivery capabilities that a
 * device or devices can support. These capabilities represent all the
 * capabilities that can be negotiated with a partner, so not only the Power
 * Capabilities that are negotiated using the USB PD Capabilities Message.
 *
 * The USB Power Delivery Support object that this routine generates can be used
 * as the parent object for all the actual USB Power Delivery Messages and
 * objects that can be negotiated with the partner.
 *
 * Returns handle to struct usb_power_delivery or ERR_PTR.
 */
struct usb_power_delivery *
usb_power_delivery_register(struct device *parent, struct usb_power_delivery_desc *desc)
{}
EXPORT_SYMBOL_GPL();

/**
 * usb_power_delivery_unregister - Unregister USB Power Delivery Support.
 * @pd: The USB PD contract.
 */
void usb_power_delivery_unregister(struct usb_power_delivery *pd)
{}
EXPORT_SYMBOL_GPL();

/**
 * usb_power_delivery_link_device - Link device to its USB PD object.
 * @pd: The USB PD instance.
 * @dev: The device.
 *
 * This function can be used to create a symlink named "usb_power_delivery" for
 * @dev that points to @pd.
 */
int usb_power_delivery_link_device(struct usb_power_delivery *pd, struct device *dev)
{}
EXPORT_SYMBOL_GPL();

/**
 * usb_power_delivery_unlink_device - Unlink device from its USB PD object.
 * @pd: The USB PD instance.
 * @dev: The device.
 *
 * Remove the symlink that was previously created with pd_link_device().
 */
void usb_power_delivery_unlink_device(struct usb_power_delivery *pd, struct device *dev)
{}
EXPORT_SYMBOL_GPL();

/* -------------------------------------------------------------------------- */

int __init usb_power_delivery_init(void)
{}

void __exit usb_power_delivery_exit(void)
{}