// SPDX-License-Identifier: GPL-2.0
/*
* SVC Greybus driver.
*
* Copyright 2015 Google Inc.
* Copyright 2015 Linaro Ltd.
*/
#include <linux/debugfs.h>
#include <linux/workqueue.h>
#include <linux/greybus.h>
#define SVC_INTF_EJECT_TIMEOUT 9000
#define SVC_INTF_ACTIVATE_TIMEOUT 6000
#define SVC_INTF_RESUME_TIMEOUT 3000
struct gb_svc_deferred_request {
struct work_struct work;
struct gb_operation *operation;
};
static int gb_svc_queue_deferred_request(struct gb_operation *operation);
static ssize_t endo_id_show(struct device *dev,
struct device_attribute *attr, char *buf)
{
struct gb_svc *svc = to_gb_svc(dev);
return sprintf(buf, "0x%04x\n", svc->endo_id);
}
static DEVICE_ATTR_RO(endo_id);
static ssize_t ap_intf_id_show(struct device *dev,
struct device_attribute *attr, char *buf)
{
struct gb_svc *svc = to_gb_svc(dev);
return sprintf(buf, "%u\n", svc->ap_intf_id);
}
static DEVICE_ATTR_RO(ap_intf_id);
// FIXME
// This is a hack, we need to do this "right" and clean the interface up
// properly, not just forcibly yank the thing out of the system and hope for the
// best. But for now, people want their modules to come out without having to
// throw the thing to the ground or get out a screwdriver.
static ssize_t intf_eject_store(struct device *dev,
struct device_attribute *attr, const char *buf,
size_t len)
{
struct gb_svc *svc = to_gb_svc(dev);
unsigned short intf_id;
int ret;
ret = kstrtou16(buf, 10, &intf_id);
if (ret < 0)
return ret;
dev_warn(dev, "Forcibly trying to eject interface %d\n", intf_id);
ret = gb_svc_intf_eject(svc, intf_id);
if (ret < 0)
return ret;
return len;
}
static DEVICE_ATTR_WO(intf_eject);
static ssize_t watchdog_show(struct device *dev, struct device_attribute *attr,
char *buf)
{
struct gb_svc *svc = to_gb_svc(dev);
return sprintf(buf, "%s\n"