diff options
| author | Gwendal Grignou <gwendal@chromium.org> | 2015-06-09 07:04:47 -0400 |
|---|---|---|
| committer | Lee Jones <lee.jones@linaro.org> | 2015-06-15 08:18:23 -0400 |
| commit | 57b33ff077beebb68481a2b6b8e5fe58ca998169 (patch) | |
| tree | 9ebb2bc1a6e413156f1409220c4328c72efbb1b9 /include/linux/mfd | |
| parent | d365407079d33106f76bd486a863de05eb5ae95d (diff) | |
mfd: cros_ec: Support multiple EC in a system
Chromebooks can have more than one Embedded Controller so the
cros_ec device id has to be incremented for each EC registered.
Add a new structure to represent multiple EC as different char
devices (e.g: /dev/cros_ec, /dev/cros_pd). It connects to
cros_ec_device and allows sysfs inferface for cros_pd.
Also reduce number of allocated objects, make chromeos sysfs
class object a static and add refcounting to prevent object
deletion while command is in progress.
Signed-off-by: Gwendal Grignou <gwendal@chromium.org>
Reviewed-by: Dmitry Torokhov <dtor@chromium.org>
Signed-off-by: Javier Martinez Canillas <javier.martinez@collabora.co.uk>
Tested-by: Heiko Stuebner <heiko@sntech.de>
Acked-by: Lee Jones <lee.jones@linaro.org>
Acked-by: Olof Johansson <olof@lixom.net>
Signed-off-by: Lee Jones <lee.jones@linaro.org>
Diffstat (limited to 'include/linux/mfd')
| -rw-r--r-- | include/linux/mfd/cros_ec.h | 44 |
1 files changed, 38 insertions, 6 deletions
diff --git a/include/linux/mfd/cros_ec.h b/include/linux/mfd/cros_ec.h index 92e13aaa450c..da72671a42fa 100644 --- a/include/linux/mfd/cros_ec.h +++ b/include/linux/mfd/cros_ec.h | |||
| @@ -17,10 +17,14 @@ | |||
| 17 | #define __LINUX_MFD_CROS_EC_H | 17 | #define __LINUX_MFD_CROS_EC_H |
| 18 | 18 | ||
| 19 | #include <linux/cdev.h> | 19 | #include <linux/cdev.h> |
| 20 | #include <linux/device.h> | ||
| 20 | #include <linux/notifier.h> | 21 | #include <linux/notifier.h> |
| 21 | #include <linux/mfd/cros_ec_commands.h> | 22 | #include <linux/mfd/cros_ec_commands.h> |
| 22 | #include <linux/mutex.h> | 23 | #include <linux/mutex.h> |
| 23 | 24 | ||
| 25 | #define CROS_EC_DEV_NAME "cros_ec" | ||
| 26 | #define CROS_EC_DEV_PD_NAME "cros_pd" | ||
| 27 | |||
| 24 | /* | 28 | /* |
| 25 | * The EC is unresponsive for a time after a reboot command. Add a | 29 | * The EC is unresponsive for a time after a reboot command. Add a |
| 26 | * simple delay to make sure that the bus stays locked. | 30 | * simple delay to make sure that the bus stays locked. |
| @@ -71,11 +75,8 @@ struct cros_ec_command { | |||
| 71 | /** | 75 | /** |
| 72 | * struct cros_ec_device - Information about a ChromeOS EC device | 76 | * struct cros_ec_device - Information about a ChromeOS EC device |
| 73 | * | 77 | * |
| 74 | * @ec_name: name of EC device (e.g. 'chromeos-ec') | ||
| 75 | * @phys_name: name of physical comms layer (e.g. 'i2c-4') | 78 | * @phys_name: name of physical comms layer (e.g. 'i2c-4') |
| 76 | * @dev: Device pointer for physical comms device | 79 | * @dev: Device pointer for physical comms device |
| 77 | * @vdev: Device pointer for virtual comms device | ||
| 78 | * @cdev: Character device structure for virtual comms device | ||
| 79 | * @was_wake_device: true if this device was set to wake the system from | 80 | * @was_wake_device: true if this device was set to wake the system from |
| 80 | * sleep at the last suspend | 81 | * sleep at the last suspend |
| 81 | * @cmd_readmem: direct read of the EC memory-mapped region, if supported | 82 | * @cmd_readmem: direct read of the EC memory-mapped region, if supported |
| @@ -87,6 +88,7 @@ struct cros_ec_command { | |||
| 87 | * | 88 | * |
| 88 | * @priv: Private data | 89 | * @priv: Private data |
| 89 | * @irq: Interrupt to use | 90 | * @irq: Interrupt to use |
| 91 | * @id: Device id | ||
| 90 | * @din: input buffer (for data from EC) | 92 | * @din: input buffer (for data from EC) |
| 91 | * @dout: output buffer (for data to EC) | 93 | * @dout: output buffer (for data to EC) |
| 92 | * \note | 94 | * \note |
| @@ -109,11 +111,8 @@ struct cros_ec_command { | |||
| 109 | struct cros_ec_device { | 111 | struct cros_ec_device { |
| 110 | 112 | ||
| 111 | /* These are used by other drivers that want to talk to the EC */ | 113 | /* These are used by other drivers that want to talk to the EC */ |
| 112 | const char *ec_name; | ||
| 113 | const char *phys_name; | 114 | const char *phys_name; |
| 114 | struct device *dev; | 115 | struct device *dev; |
| 115 | struct device *vdev; | ||
| 116 | struct cdev cdev; | ||
| 117 | bool was_wake_device; | 116 | bool was_wake_device; |
| 118 | struct class *cros_class; | 117 | struct class *cros_class; |
| 119 | int (*cmd_readmem)(struct cros_ec_device *ec, unsigned int offset, | 118 | int (*cmd_readmem)(struct cros_ec_device *ec, unsigned int offset, |
| @@ -138,6 +137,35 @@ struct cros_ec_device { | |||
| 138 | struct mutex lock; | 137 | struct mutex lock; |
| 139 | }; | 138 | }; |
| 140 | 139 | ||
| 140 | /* struct cros_ec_platform - ChromeOS EC platform information | ||
| 141 | * | ||
| 142 | * @ec_name: name of EC device (e.g. 'cros-ec', 'cros-pd', ...) | ||
| 143 | * used in /dev/ and sysfs. | ||
| 144 | * @cmd_offset: offset to apply for each command. Set when | ||
| 145 | * registering a devicde behind another one. | ||
| 146 | */ | ||
| 147 | struct cros_ec_platform { | ||
| 148 | const char *ec_name; | ||
| 149 | u16 cmd_offset; | ||
| 150 | }; | ||
| 151 | |||
| 152 | /* | ||
| 153 | * struct cros_ec_dev - ChromeOS EC device entry point | ||
| 154 | * | ||
| 155 | * @class_dev: Device structure used in sysfs | ||
| 156 | * @cdev: Character device structure in /dev | ||
| 157 | * @ec_dev: cros_ec_device structure to talk to the physical device | ||
| 158 | * @dev: pointer to the platform device | ||
| 159 | * @cmd_offset: offset to apply for each command. | ||
| 160 | */ | ||
| 161 | struct cros_ec_dev { | ||
| 162 | struct device class_dev; | ||
| 163 | struct cdev cdev; | ||
| 164 | struct cros_ec_device *ec_dev; | ||
| 165 | struct device *dev; | ||
| 166 | u16 cmd_offset; | ||
| 167 | }; | ||
| 168 | |||
| 141 | /** | 169 | /** |
| 142 | * cros_ec_suspend - Handle a suspend operation for the ChromeOS EC device | 170 | * cros_ec_suspend - Handle a suspend operation for the ChromeOS EC device |
| 143 | * | 171 | * |
| @@ -224,4 +252,8 @@ int cros_ec_register(struct cros_ec_device *ec_dev); | |||
| 224 | */ | 252 | */ |
| 225 | int cros_ec_query_all(struct cros_ec_device *ec_dev); | 253 | int cros_ec_query_all(struct cros_ec_device *ec_dev); |
| 226 | 254 | ||
| 255 | /* sysfs stuff */ | ||
| 256 | extern struct attribute_group cros_ec_attr_group; | ||
| 257 | extern struct attribute_group cros_ec_lightbar_attr_group; | ||
| 258 | |||
| 227 | #endif /* __LINUX_MFD_CROS_EC_H */ | 259 | #endif /* __LINUX_MFD_CROS_EC_H */ |
