linux/drivers/platform/surface/surface_acpi_notify.c

// SPDX-License-Identifier: GPL-2.0+
/*
 * Driver for the Surface ACPI Notify (SAN) interface/shim.
 *
 * Translates communication from ACPI to Surface System Aggregator Module
 * (SSAM/SAM) requests and back, specifically SAM-over-SSH. Translates SSAM
 * events back to ACPI notifications. Allows handling of discrete GPU
 * notifications sent from ACPI via the SAN interface by providing them to any
 * registered external driver.
 *
 * Copyright (C) 2019-2022 Maximilian Luz <[email protected]>
 */

#include <asm/unaligned.h>
#include <linux/acpi.h>
#include <linux/delay.h>
#include <linux/jiffies.h>
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/notifier.h>
#include <linux/platform_device.h>
#include <linux/rwsem.h>

#include <linux/surface_aggregator/controller.h>
#include <linux/surface_acpi_notify.h>

struct san_data {};

#define to_san_data(ptr, member)

static struct workqueue_struct *san_wq;

/* -- dGPU notifier interface. ---------------------------------------------- */

struct san_rqsg_if {};

static struct san_rqsg_if san_rqsg_if =;

static int san_set_rqsg_interface_device(struct device *dev)
{}

/**
 * san_client_link() - Link client as consumer to SAN device.
 * @client: The client to link.
 *
 * Sets up a device link between the provided client device as consumer and
 * the SAN device as provider. This function can be used to ensure that the
 * SAN interface has been set up and will be set up for as long as the driver
 * of the client device is bound. This guarantees that, during that time, all
 * dGPU events will be received by any registered notifier.
 *
 * The link will be automatically removed once the client device's driver is
 * unbound.
 *
 * Return: Returns zero on success, %-ENXIO if the SAN interface has not been
 * set up yet, and %-ENOMEM if device link creation failed.
 */
int san_client_link(struct device *client)
{}
EXPORT_SYMBOL_GPL();

/**
 * san_dgpu_notifier_register() - Register a SAN dGPU notifier.
 * @nb: The notifier-block to register.
 *
 * Registers a SAN dGPU notifier, receiving any new SAN dGPU events sent from
 * ACPI. The registered notifier will be called with &struct san_dgpu_event
 * as notifier data and the command ID of that event as notifier action.
 */
int san_dgpu_notifier_register(struct notifier_block *nb)
{}
EXPORT_SYMBOL_GPL();

/**
 * san_dgpu_notifier_unregister() - Unregister a SAN dGPU notifier.
 * @nb: The notifier-block to unregister.
 */
int san_dgpu_notifier_unregister(struct notifier_block *nb)
{}
EXPORT_SYMBOL_GPL();

static int san_dgpu_notifier_call(struct san_dgpu_event *evt)
{}


/* -- ACPI _DSM event relay. ------------------------------------------------ */

#define SAN_DSM_REVISION

/* 93b666c5-70c6-469f-a215-3d487c91ab3c */
static const guid_t SAN_DSM_UUID =;

enum san_dsm_event_fn {};

enum sam_event_cid_bat {};

enum sam_event_cid_tmp {};

struct san_event_work {};

static int san_acpi_notify_event(struct device *dev, u64 func,
				 union acpi_object *param)
{}

static int san_evt_bat_adp(struct device *dev, const struct ssam_event *event)
{}

static int san_evt_bat_bix(struct device *dev, const struct ssam_event *event)
{}

static int san_evt_bat_bst(struct device *dev, const struct ssam_event *event)
{}

static int san_evt_bat_dptf(struct device *dev, const struct ssam_event *event)
{}

static unsigned long san_evt_bat_delay(u8 cid)
{}

static bool san_evt_bat(const struct ssam_event *event, struct device *dev)
{}

static void san_evt_bat_workfn(struct work_struct *work)
{}

static u32 san_evt_bat_nf(struct ssam_event_notifier *nf,
			  const struct ssam_event *event)
{}

static int san_evt_tmp_trip(struct device *dev, const struct ssam_event *event)
{}

static bool san_evt_tmp(const struct ssam_event *event, struct device *dev)
{}

static u32 san_evt_tmp_nf(struct ssam_event_notifier *nf,
			  const struct ssam_event *event)
{}


/* -- ACPI GSB OperationRegion handler -------------------------------------- */

struct gsb_data_in {} __packed;

struct gsb_data_rqsx {} __packed;

struct gsb_data_etwl {} __packed;

struct gsb_data_out {} __packed;

gsb_buffer_data;

struct gsb_buffer {} __packed;

#define SAN_GSB_MAX_RQSX_PAYLOAD
#define SAN_GSB_MAX_RESPONSE

#define SAN_GSB_COMMAND

enum san_gsb_request_cv {};

#define SAN_REQUEST_NUM_TRIES

static acpi_status san_etwl(struct san_data *d, struct gsb_buffer *b)
{}

static
struct gsb_data_rqsx *san_validate_rqsx(struct device *dev, const char *type,
					struct gsb_buffer *b)
{}

static void gsb_rqsx_response_error(struct gsb_buffer *gsb, int status)
{}

static void gsb_rqsx_response_success(struct gsb_buffer *gsb, u8 *ptr, size_t len)
{}

static acpi_status san_rqst_fixup_suspended(struct san_data *d,
					    struct ssam_request *rqst,
					    struct gsb_buffer *gsb)
{}

static acpi_status san_rqst(struct san_data *d, struct gsb_buffer *buffer)
{}

static acpi_status san_rqsg(struct san_data *d, struct gsb_buffer *buffer)
{}

static acpi_status san_opreg_handler(u32 function, acpi_physical_address command,
				     u32 bits, u64 *value64, void *opreg_context,
				     void *region_context)
{}


/* -- Driver setup. --------------------------------------------------------- */

static int san_events_register(struct platform_device *pdev)
{}

static void san_events_unregister(struct platform_device *pdev)
{}

#define san_consumer_printk(level, dev, handle, fmt, ...)

#define san_consumer_dbg(dev, handle, fmt, ...)

#define san_consumer_warn(dev, handle, fmt, ...)

static acpi_status san_consumer_setup(acpi_handle handle, u32 lvl,
				      void *context, void **rv)
{}

static int san_consumer_links_setup(struct platform_device *pdev)
{}

static int san_probe(struct platform_device *pdev)
{}

static void san_remove(struct platform_device *pdev)
{}

static const struct acpi_device_id san_match[] =;
MODULE_DEVICE_TABLE(acpi, san_match);

static struct platform_driver surface_acpi_notify =;

static int __init san_init(void)
{}
module_init();

static void __exit san_exit(void)
{}
module_exit(san_exit);

MODULE_AUTHOR();
MODULE_DESCRIPTION();
MODULE_LICENSE();