aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/mfd/cros_ec.c2
-rw-r--r--drivers/mfd/cros_ec_i2c.c4
-rw-r--r--drivers/mfd/cros_ec_spi.c10
-rw-r--r--include/linux/mfd/cros_ec.h65
4 files changed, 43 insertions, 38 deletions
diff --git a/drivers/mfd/cros_ec.c b/drivers/mfd/cros_ec.c
index 38fe9bf0d169..04e053c71cc6 100644
--- a/drivers/mfd/cros_ec.c
+++ b/drivers/mfd/cros_ec.c
@@ -57,7 +57,7 @@ static int cros_ec_command_sendrecv(struct cros_ec_device *ec_dev,
57 msg.in_buf = in_buf; 57 msg.in_buf = in_buf;
58 msg.in_len = in_len; 58 msg.in_len = in_len;
59 59
60 return ec_dev->command_xfer(ec_dev, &msg); 60 return ec_dev->cmd_xfer(ec_dev, &msg);
61} 61}
62 62
63static int cros_ec_command_recv(struct cros_ec_device *ec_dev, 63static int cros_ec_command_recv(struct cros_ec_device *ec_dev,
diff --git a/drivers/mfd/cros_ec_i2c.c b/drivers/mfd/cros_ec_i2c.c
index 4f71be99a183..777e529abb16 100644
--- a/drivers/mfd/cros_ec_i2c.c
+++ b/drivers/mfd/cros_ec_i2c.c
@@ -29,7 +29,7 @@ static inline struct cros_ec_device *to_ec_dev(struct device *dev)
29 return i2c_get_clientdata(client); 29 return i2c_get_clientdata(client);
30} 30}
31 31
32static int cros_ec_command_xfer(struct cros_ec_device *ec_dev, 32static int cros_ec_cmd_xfer_i2c(struct cros_ec_device *ec_dev,
33 struct cros_ec_msg *msg) 33 struct cros_ec_msg *msg)
34{ 34{
35 struct i2c_client *client = ec_dev->priv; 35 struct i2c_client *client = ec_dev->priv;
@@ -136,7 +136,7 @@ static int cros_ec_i2c_probe(struct i2c_client *client,
136 ec_dev->dev = dev; 136 ec_dev->dev = dev;
137 ec_dev->priv = client; 137 ec_dev->priv = client;
138 ec_dev->irq = client->irq; 138 ec_dev->irq = client->irq;
139 ec_dev->command_xfer = cros_ec_command_xfer; 139 ec_dev->cmd_xfer = cros_ec_cmd_xfer_i2c;
140 ec_dev->ec_name = client->name; 140 ec_dev->ec_name = client->name;
141 ec_dev->phys_name = client->adapter->name; 141 ec_dev->phys_name = client->adapter->name;
142 ec_dev->parent = &client->dev; 142 ec_dev->parent = &client->dev;
diff --git a/drivers/mfd/cros_ec_spi.c b/drivers/mfd/cros_ec_spi.c
index 1fcc65ecad0e..6c3075fb5dc7 100644
--- a/drivers/mfd/cros_ec_spi.c
+++ b/drivers/mfd/cros_ec_spi.c
@@ -73,7 +73,7 @@
73 * if no record 73 * if no record
74 * @end_of_msg_delay: used to set the delay_usecs on the spi_transfer that 74 * @end_of_msg_delay: used to set the delay_usecs on the spi_transfer that
75 * is sent when we want to turn off CS at the end of a transaction. 75 * is sent when we want to turn off CS at the end of a transaction.
76 * @lock: mutex to ensure only one user of cros_ec_command_spi_xfer at a time 76 * @lock: mutex to ensure only one user of cros_ec_cmd_xfer_spi at a time
77 */ 77 */
78struct cros_ec_spi { 78struct cros_ec_spi {
79 struct spi_device *spi; 79 struct spi_device *spi;
@@ -210,13 +210,13 @@ static int cros_ec_spi_receive_response(struct cros_ec_device *ec_dev,
210} 210}
211 211
212/** 212/**
213 * cros_ec_command_spi_xfer - Transfer a message over SPI and receive the reply 213 * cros_ec_cmd_xfer_spi - Transfer a message over SPI and receive the reply
214 * 214 *
215 * @ec_dev: ChromeOS EC device 215 * @ec_dev: ChromeOS EC device
216 * @ec_msg: Message to transfer 216 * @ec_msg: Message to transfer
217 */ 217 */
218static int cros_ec_command_spi_xfer(struct cros_ec_device *ec_dev, 218static int cros_ec_cmd_xfer_spi(struct cros_ec_device *ec_dev,
219 struct cros_ec_msg *ec_msg) 219 struct cros_ec_msg *ec_msg)
220{ 220{
221 struct cros_ec_spi *ec_spi = ec_dev->priv; 221 struct cros_ec_spi *ec_spi = ec_dev->priv;
222 struct spi_transfer trans; 222 struct spi_transfer trans;
@@ -368,7 +368,7 @@ static int cros_ec_spi_probe(struct spi_device *spi)
368 ec_dev->dev = dev; 368 ec_dev->dev = dev;
369 ec_dev->priv = ec_spi; 369 ec_dev->priv = ec_spi;
370 ec_dev->irq = spi->irq; 370 ec_dev->irq = spi->irq;
371 ec_dev->command_xfer = cros_ec_command_spi_xfer; 371 ec_dev->cmd_xfer = cros_ec_cmd_xfer_spi;
372 ec_dev->ec_name = ec_spi->spi->modalias; 372 ec_dev->ec_name = ec_spi->spi->modalias;
373 ec_dev->phys_name = dev_name(&ec_spi->spi->dev); 373 ec_dev->phys_name = dev_name(&ec_spi->spi->dev);
374 ec_dev->parent = &ec_spi->spi->dev; 374 ec_dev->parent = &ec_spi->spi->dev;
diff --git a/include/linux/mfd/cros_ec.h b/include/linux/mfd/cros_ec.h
index 2ee3190b691c..79a35857cc9e 100644
--- a/include/linux/mfd/cros_ec.h
+++ b/include/linux/mfd/cros_ec.h
@@ -16,7 +16,9 @@
16#ifndef __LINUX_MFD_CROS_EC_H 16#ifndef __LINUX_MFD_CROS_EC_H
17#define __LINUX_MFD_CROS_EC_H 17#define __LINUX_MFD_CROS_EC_H
18 18
19#include <linux/notifier.h>
19#include <linux/mfd/cros_ec_commands.h> 20#include <linux/mfd/cros_ec_commands.h>
21#include <linux/mutex.h>
20 22
21/* 23/*
22 * Command interface between EC and AP, for LPC, I2C and SPI interfaces. 24 * Command interface between EC and AP, for LPC, I2C and SPI interfaces.
@@ -55,34 +57,53 @@ struct cros_ec_msg {
55/** 57/**
56 * struct cros_ec_device - Information about a ChromeOS EC device 58 * struct cros_ec_device - Information about a ChromeOS EC device
57 * 59 *
60 * @ec_name: name of EC device (e.g. 'chromeos-ec')
61 * @phys_name: name of physical comms layer (e.g. 'i2c-4')
62 * @dev: Device pointer
63 * @was_wake_device: true if this device was set to wake the system from
64 * sleep at the last suspend
65 * @event_notifier: interrupt event notifier for transport devices
66 * @command_send: send a command
67 * @command_recv: receive a response
68 * @command_sendrecv: send a command and receive a response
69 *
58 * @name: Name of this EC interface 70 * @name: Name of this EC interface
59 * @priv: Private data 71 * @priv: Private data
60 * @irq: Interrupt to use 72 * @irq: Interrupt to use
61 * @din: input buffer (from EC) 73 * @din: input buffer (for data from EC)
62 * @dout: output buffer (to EC) 74 * @dout: output buffer (for data to EC)
63 * \note 75 * \note
64 * These two buffers will always be dword-aligned and include enough 76 * These two buffers will always be dword-aligned and include enough
65 * space for up to 7 word-alignment bytes also, so we can ensure that 77 * space for up to 7 word-alignment bytes also, so we can ensure that
66 * the body of the message is always dword-aligned (64-bit). 78 * the body of the message is always dword-aligned (64-bit).
67 *
68 * We use this alignment to keep ARM and x86 happy. Probably word 79 * We use this alignment to keep ARM and x86 happy. Probably word
69 * alignment would be OK, there might be a small performance advantage 80 * alignment would be OK, there might be a small performance advantage
70 * to using dword. 81 * to using dword.
71 * @din_size: size of din buffer to allocate (zero to use static din) 82 * @din_size: size of din buffer to allocate (zero to use static din)
72 * @dout_size: size of dout buffer to allocate (zero to use static dout) 83 * @dout_size: size of dout buffer to allocate (zero to use static dout)
73 * @command_send: send a command
74 * @command_recv: receive a command
75 * @ec_name: name of EC device (e.g. 'chromeos-ec')
76 * @phys_name: name of physical comms layer (e.g. 'i2c-4')
77 * @parent: pointer to parent device (e.g. i2c or spi device) 84 * @parent: pointer to parent device (e.g. i2c or spi device)
78 * @dev: Device pointer
79 * dev_lock: Lock to prevent concurrent access
80 * @wake_enabled: true if this device can wake the system from sleep 85 * @wake_enabled: true if this device can wake the system from sleep
81 * @was_wake_device: true if this device was set to wake the system from 86 * @lock: one transaction at a time
82 * sleep at the last suspend 87 * @cmd_xfer: low-level channel to the EC
83 * @event_notifier: interrupt event notifier for transport devices
84 */ 88 */
85struct cros_ec_device { 89struct cros_ec_device {
90
91 /* These are used by other drivers that want to talk to the EC */
92 const char *ec_name;
93 const char *phys_name;
94 struct device *dev;
95 bool was_wake_device;
96 struct class *cros_class;
97 struct blocking_notifier_head event_notifier;
98 int (*command_send)(struct cros_ec_device *ec,
99 uint16_t cmd, void *out_buf, int out_len);
100 int (*command_recv)(struct cros_ec_device *ec,
101 uint16_t cmd, void *in_buf, int in_len);
102 int (*command_sendrecv)(struct cros_ec_device *ec,
103 uint16_t cmd, void *out_buf, int out_len,
104 void *in_buf, int in_len);
105
106 /* These are used to implement the platform-specific interface */
86 const char *name; 107 const char *name;
87 void *priv; 108 void *priv;
88 int irq; 109 int irq;
@@ -90,26 +111,10 @@ struct cros_ec_device {
90 uint8_t *dout; 111 uint8_t *dout;
91 int din_size; 112 int din_size;
92 int dout_size; 113 int dout_size;
93 int (*command_send)(struct cros_ec_device *ec,
94 uint16_t cmd, void *out_buf, int out_len);
95 int (*command_recv)(struct cros_ec_device *ec,
96 uint16_t cmd, void *in_buf, int in_len);
97 int (*command_sendrecv)(struct cros_ec_device *ec,
98 uint16_t cmd, void *out_buf, int out_len,
99 void *in_buf, int in_len);
100 int (*command_xfer)(struct cros_ec_device *ec,
101 struct cros_ec_msg *msg);
102
103 const char *ec_name;
104 const char *phys_name;
105 struct device *parent; 114 struct device *parent;
106
107 /* These are --private-- fields - do not assign */
108 struct device *dev;
109 struct mutex dev_lock;
110 bool wake_enabled; 115 bool wake_enabled;
111 bool was_wake_device; 116 struct mutex lock;
112 struct blocking_notifier_head event_notifier; 117 int (*cmd_xfer)(struct cros_ec_device *ec, struct cros_ec_msg *msg);
113}; 118};
114 119
115/** 120/**