]> git.karo-electronics.de Git - karo-tx-linux.git/blobdiff - include/linux/mfd/cros_ec.h
mfd: cros_ec: cleanup: remove unused fields from struct cros_ec_device
[karo-tx-linux.git] / include / linux / mfd / cros_ec.h
index 887ef4f7bef7225995d4e4e2afda86ab6f5ad1cc..2b0c5982dbc1531622b919395e05680a0b9827ef 100644 (file)
@@ -16,7 +16,9 @@
 #ifndef __LINUX_MFD_CROS_EC_H
 #define __LINUX_MFD_CROS_EC_H
 
+#include <linux/notifier.h>
 #include <linux/mfd/cros_ec_commands.h>
+#include <linux/mutex.h>
 
 /*
  * Command interface between EC and AP, for LPC, I2C and SPI interfaces.
@@ -33,83 +35,85 @@ enum {
                                        EC_MSG_TX_PROTO_BYTES,
 };
 
-/**
- * struct cros_ec_msg - A message sent to the EC, and its reply
- *
+/*
  * @version: Command version number (often 0)
- * @cmd: Command to send (EC_CMD_...)
- * @out_buf: Outgoing payload (to EC)
- * @outlen: Outgoing length
- * @in_buf: Incoming payload (from EC)
- * @in_len: Incoming length
+ * @command: Command to send (EC_CMD_...)
+ * @outdata: Outgoing data to EC
+ * @outsize: Outgoing length in bytes
+ * @indata: Where to put the incoming data from EC
+ * @insize: Incoming length in bytes (filled in by EC)
+ * @result: EC's response to the command (separate from communication failure)
  */
-struct cros_ec_msg {
-       u8 version;
-       u8 cmd;
-       uint8_t *out_buf;
-       int out_len;
-       uint8_t *in_buf;
-       int in_len;
+struct cros_ec_command {
+       uint32_t version;
+       uint32_t command;
+       uint8_t *outdata;
+       uint32_t outsize;
+       uint8_t *indata;
+       uint32_t insize;
+       uint32_t result;
 };
 
 /**
  * struct cros_ec_device - Information about a ChromeOS EC device
  *
- * @name: Name of this EC interface
+ * @ec_name: name of EC device (e.g. 'chromeos-ec')
+ * @phys_name: name of physical comms layer (e.g. 'i2c-4')
+ * @dev: Device pointer
+ * @was_wake_device: true if this device was set to wake the system from
+ * sleep at the last suspend
+ * @event_notifier: interrupt event notifier for transport devices
+ * @command_send: send a command
+ * @command_recv: receive a response
+ * @command_sendrecv: send a command and receive a response
+ *
  * @priv: Private data
  * @irq: Interrupt to use
- * @din: input buffer (from EC)
- * @dout: output buffer (to EC)
+ * @din: input buffer (for data from EC)
+ * @dout: output buffer (for data to EC)
  * \note
  * These two buffers will always be dword-aligned and include enough
  * space for up to 7 word-alignment bytes also, so we can ensure that
  * the body of the message is always dword-aligned (64-bit).
- *
  * We use this alignment to keep ARM and x86 happy. Probably word
  * alignment would be OK, there might be a small performance advantage
  * to using dword.
- * @din_size: size of din buffer
- * @dout_size: size of dout buffer
- * @command_send: send a command
- * @command_recv: receive a command
- * @ec_name: name of EC device (e.g. 'chromeos-ec')
- * @phys_name: name of physical comms layer (e.g. 'i2c-4')
+ * @din_size: size of din buffer to allocate (zero to use static din)
+ * @dout_size: size of dout buffer to allocate (zero to use static dout)
  * @parent: pointer to parent device (e.g. i2c or spi device)
- * @dev: Device pointer
- * dev_lock: Lock to prevent concurrent access
  * @wake_enabled: true if this device can wake the system from sleep
- * @was_wake_device: true if this device was set to wake the system from
- * sleep at the last suspend
- * @event_notifier: interrupt event notifier for transport devices
+ * @lock: one transaction at a time
+ * @cmd_xfer: low-level channel to the EC
  */
 struct cros_ec_device {
-       const char *name;
+
+       /* These are used by other drivers that want to talk to the EC */
+       const char *ec_name;
+       const char *phys_name;
+       struct device *dev;
+       bool was_wake_device;
+       struct class *cros_class;
+       struct blocking_notifier_head event_notifier;
+       int (*command_send)(struct cros_ec_device *ec,
+                           uint16_t cmd, void *out_buf, int out_len);
+       int (*command_recv)(struct cros_ec_device *ec,
+                           uint16_t cmd, void *in_buf, int in_len);
+       int (*command_sendrecv)(struct cros_ec_device *ec,
+                               uint16_t cmd, void *out_buf, int out_len,
+                               void *in_buf, int in_len);
+
+       /* These are used to implement the platform-specific interface */
        void *priv;
        int irq;
        uint8_t *din;
        uint8_t *dout;
        int din_size;
        int dout_size;
-       int (*command_send)(struct cros_ec_device *ec,
-                       uint16_t cmd, void *out_buf, int out_len);
-       int (*command_recv)(struct cros_ec_device *ec,
-                       uint16_t cmd, void *in_buf, int in_len);
-       int (*command_sendrecv)(struct cros_ec_device *ec,
-                       uint16_t cmd, void *out_buf, int out_len,
-                       void *in_buf, int in_len);
-       int (*command_xfer)(struct cros_ec_device *ec,
-                       struct cros_ec_msg *msg);
-
-       const char *ec_name;
-       const char *phys_name;
        struct device *parent;
-
-       /* These are --private-- fields - do not assign */
-       struct device *dev;
-       struct mutex dev_lock;
        bool wake_enabled;
-       bool was_wake_device;
-       struct blocking_notifier_head event_notifier;
+       struct mutex lock;
+       int (*cmd_xfer)(struct cros_ec_device *ec,
+                       struct cros_ec_command *msg);
 };
 
 /**
@@ -143,13 +147,12 @@ int cros_ec_resume(struct cros_ec_device *ec_dev);
  * @msg: Message to write
  */
 int cros_ec_prepare_tx(struct cros_ec_device *ec_dev,
-                      struct cros_ec_msg *msg);
+                      struct cros_ec_command *msg);
 
 /**
  * cros_ec_remove - Remove a ChromeOS EC
  *
- * Call this to deregister a ChromeOS EC. After this you should call
- * cros_ec_free().
+ * Call this to deregister a ChromeOS EC, then clean up any private data.
  *
  * @ec_dev: Device to register
  * @return 0 if ok, -ve on error