Skip to content

Commit 2c7589a

Browse files
Stephen BarberLee Jones
authored andcommitted
mfd: cros_ec: add proto v3 skeleton
Add support in cros_ec.c to handle EC host command protocol v3. For v3+, probe for maximum shared protocol version and max request, response, and passthrough sizes. For now, this will always fall back to v2, since there is no bus-specific code for handling proto v3 packets. Signed-off-by: Stephen Barber <[email protected]> Signed-off-by: Javier Martinez Canillas <[email protected]> Reviewed-by: Gwendal Grignou <[email protected]> Tested-by: Gwendal Grignou <[email protected]> Tested-by: Heiko Stuebner <[email protected]> Acked-by: Lee Jones <[email protected]> Acked-by: Olof Johansson <[email protected]> Signed-off-by: Lee Jones <[email protected]>
1 parent 062476f commit 2c7589a

File tree

6 files changed

+355
-50
lines changed

6 files changed

+355
-50
lines changed

drivers/mfd/cros_ec.c

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -36,19 +36,22 @@ int cros_ec_register(struct cros_ec_device *ec_dev)
3636
struct device *dev = ec_dev->dev;
3737
int err = 0;
3838

39-
if (ec_dev->din_size) {
40-
ec_dev->din = devm_kzalloc(dev, ec_dev->din_size, GFP_KERNEL);
41-
if (!ec_dev->din)
42-
return -ENOMEM;
43-
}
44-
if (ec_dev->dout_size) {
45-
ec_dev->dout = devm_kzalloc(dev, ec_dev->dout_size, GFP_KERNEL);
46-
if (!ec_dev->dout)
47-
return -ENOMEM;
48-
}
39+
ec_dev->max_request = sizeof(struct ec_params_hello);
40+
ec_dev->max_response = sizeof(struct ec_response_get_protocol_info);
41+
ec_dev->max_passthru = 0;
42+
43+
ec_dev->din = devm_kzalloc(dev, ec_dev->din_size, GFP_KERNEL);
44+
if (!ec_dev->din)
45+
return -ENOMEM;
46+
47+
ec_dev->dout = devm_kzalloc(dev, ec_dev->dout_size, GFP_KERNEL);
48+
if (!ec_dev->dout)
49+
return -ENOMEM;
4950

5051
mutex_init(&ec_dev->lock);
5152

53+
cros_ec_query_all(ec_dev);
54+
5255
err = mfd_add_devices(dev, 0, cros_devs,
5356
ARRAY_SIZE(cros_devs),
5457
NULL, ec_dev->irq, NULL);

drivers/mfd/cros_ec_i2c.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,8 +143,12 @@ static int cros_ec_i2c_probe(struct i2c_client *client,
143143
ec_dev->priv = client;
144144
ec_dev->irq = client->irq;
145145
ec_dev->cmd_xfer = cros_ec_cmd_xfer_i2c;
146+
ec_dev->pkt_xfer = NULL;
146147
ec_dev->ec_name = client->name;
147148
ec_dev->phys_name = client->adapter->name;
149+
ec_dev->din_size = sizeof(struct ec_host_response) +
150+
sizeof(struct ec_response_get_protocol_info);
151+
ec_dev->dout_size = sizeof(struct ec_host_request);
148152

149153
err = cros_ec_register(ec_dev);
150154
if (err) {

drivers/mfd/cros_ec_spi.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -361,10 +361,13 @@ static int cros_ec_spi_probe(struct spi_device *spi)
361361
ec_dev->priv = ec_spi;
362362
ec_dev->irq = spi->irq;
363363
ec_dev->cmd_xfer = cros_ec_cmd_xfer_spi;
364+
ec_dev->pkt_xfer = NULL;
364365
ec_dev->ec_name = ec_spi->spi->modalias;
365366
ec_dev->phys_name = dev_name(&ec_spi->spi->dev);
366-
ec_dev->din_size = EC_MSG_BYTES + EC_MSG_PREAMBLE_COUNT;
367-
ec_dev->dout_size = EC_MSG_BYTES;
367+
ec_dev->din_size = EC_MSG_PREAMBLE_COUNT +
368+
sizeof(struct ec_host_response) +
369+
sizeof(struct ec_response_get_protocol_info);
370+
ec_dev->dout_size = sizeof(struct ec_host_request);
368371

369372
err = cros_ec_register(ec_dev);
370373
if (err) {

drivers/platform/chrome/cros_ec_lpc.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,11 @@ static int cros_ec_lpc_probe(struct platform_device *pdev)
215215
ec_dev->ec_name = pdev->name;
216216
ec_dev->phys_name = dev_name(dev);
217217
ec_dev->cmd_xfer = cros_ec_cmd_xfer_lpc;
218+
ec_dev->pkt_xfer = NULL;
218219
ec_dev->cmd_readmem = cros_ec_lpc_readmem;
220+
ec_dev->din_size = sizeof(struct ec_host_response) +
221+
sizeof(struct ec_response_get_protocol_info);
222+
ec_dev->dout_size = sizeof(struct ec_host_request);
219223

220224
ret = cros_ec_register(ec_dev);
221225
if (ret) {

0 commit comments

Comments
 (0)