#include <linux/debugfs.h>
#include <asm/unaligned.h>
+#include "es2.h"
#include "greybus.h"
#include "kernel_ver.h"
#include "connection.h"
#define REQUEST_LATENCY_TAG_EN 0x06
#define REQUEST_LATENCY_TAG_DIS 0x07
+/* vendor request to control the CSI transmitter */
+#define REQUEST_CSI_TX_CONTROL 0x08
+
/*
* @endpoint: bulk in endpoint for CPort data
* @urb: array of urbs for the CPort in messages
__u8 endpoint_out;
};
+struct es2_ap_csi_config_request {
+ u8 csi_id;
+ u8 clock_mode;
+ u8 num_lanes;
+ u8 padding;
+ __le32 bus_freq;
+} __attribute__((__packed__));
+
static inline struct es2_ap_dev *hd_to_es2(struct gb_host_device *hd)
{
return (struct es2_ap_dev *)&hd->hd_priv;
}
#endif
+int es2_ap_csi_setup(struct gb_host_device *hd, bool start,
+ struct es2_ap_csi_config *cfg)
+{
+ struct es2_ap_csi_config_request cfg_req;
+ struct es2_ap_dev *es2 = hd_to_es2(hd);
+ struct usb_device *udev = es2->usb_dev;
+ int retval;
+
+ cfg_req.csi_id = cfg->csi_id;
+
+ if (start) {
+ cfg_req.clock_mode = cfg->clock_mode;
+ cfg_req.num_lanes = cfg->num_lanes;
+ cfg_req.padding = 0;
+ cfg_req.bus_freq = cfg->bus_freq;
+ } else {
+ cfg_req.clock_mode = 0;
+ cfg_req.num_lanes = 0;
+ cfg_req.padding = 0;
+ cfg_req.bus_freq = 0;
+ }
+
+ retval = usb_control_msg(udev, usb_sndctrlpipe(udev, 0),
+ REQUEST_CSI_TX_CONTROL,
+ USB_DIR_OUT | USB_TYPE_VENDOR |
+ USB_RECIP_INTERFACE, 0, 0, &cfg_req,
+ sizeof(cfg_req), ES2_TIMEOUT);
+ if (retval < 0) {
+ dev_err(&udev->dev, "failed to setup csi: %d\n", retval);
+ return retval;
+ }
+
+ return 0;
+}
+EXPORT_SYMBOL_GPL(es2_ap_csi_setup);
+
static int es2_cport_in_enable(struct es2_ap_dev *es2,
struct es2_cport_in *cport_in)
{
--- /dev/null
+/*
+ * Greybus "AP" USB driver for "ES2" controller chips
+ *
+ * Copyright 2015 Google Inc.
+ * Copyright 2015 Linaro Ltd.
+ *
+ * Released under the GPLv2 only.
+ */
+
+#ifndef __ES2_H
+#define __ES2_H
+
+#include <linux/types.h>
+
+struct gb_host_device;
+
+struct es2_ap_csi_config {
+ u8 csi_id;
+ u8 clock_mode;
+ u8 num_lanes;
+ u32 bus_freq;
+};
+
+int es2_ap_csi_setup(struct gb_host_device *hd, bool start,
+ struct es2_ap_csi_config *cfg);
+
+#endif /* __ES2_H */