Lines Matching +full:cros +full:- +full:ec

1 // SPDX-License-Identifier: GPL-2.0
3 * Driver for cros-ec proximity sensor exposed through MKBP switch
27 struct cros_ec_device *ec; member
75 msg->command = EC_CMD_MKBP_INFO; in cros_ec_mkbp_proximity_query()
76 msg->version = 1; in cros_ec_mkbp_proximity_query()
77 msg->outsize = sizeof(*params); in cros_ec_mkbp_proximity_query()
78 msg->insize = insize; in cros_ec_mkbp_proximity_query()
80 params->info_type = EC_MKBP_INFO_CURRENT; in cros_ec_mkbp_proximity_query()
81 params->event_type = EC_MKBP_EVENT_SWITCH; in cros_ec_mkbp_proximity_query()
88 dev_warn(ec_dev->dev, "wrong result size: %d != %zu\n", ret, in cros_ec_mkbp_proximity_query()
90 return -EPROTO; in cros_ec_mkbp_proximity_query()
102 struct iio_dev *indio_dev = data->indio_dev; in cros_ec_mkbp_proximity_push_event()
103 struct cros_ec_device *ec = data->ec; in cros_ec_mkbp_proximity_push_event() local
105 mutex_lock(&data->lock); in cros_ec_mkbp_proximity_push_event()
106 if (state != data->last_proximity) { in cros_ec_mkbp_proximity_push_event()
107 if (data->enabled) { in cros_ec_mkbp_proximity_push_event()
108 timestamp = ktime_to_ns(ec->last_event_time); in cros_ec_mkbp_proximity_push_event()
117 data->last_proximity = state; in cros_ec_mkbp_proximity_push_event()
119 mutex_unlock(&data->lock); in cros_ec_mkbp_proximity_push_event()
127 struct cros_ec_device *ec = _ec; in cros_ec_mkbp_proximity_notify() local
128 u8 event_type = ec->event_data.event_type & EC_MKBP_EVENT_TYPE_MASK; in cros_ec_mkbp_proximity_notify()
136 switches = &ec->event_data.data.switches; in cros_ec_mkbp_proximity_notify()
149 struct cros_ec_device *ec = data->ec; in cros_ec_mkbp_proximity_read_raw() local
151 if (chan->type == IIO_PROXIMITY && mask == IIO_CHAN_INFO_RAW) in cros_ec_mkbp_proximity_read_raw()
152 return cros_ec_mkbp_proximity_query(ec, val); in cros_ec_mkbp_proximity_read_raw()
154 return -EINVAL; in cros_ec_mkbp_proximity_read_raw()
164 return data->enabled; in cros_ec_mkbp_proximity_read_event_config()
174 mutex_lock(&data->lock); in cros_ec_mkbp_proximity_write_event_config()
175 data->enabled = state; in cros_ec_mkbp_proximity_write_event_config()
176 mutex_unlock(&data->lock); in cros_ec_mkbp_proximity_write_event_config()
190 struct cros_ec_device *ec = data->ec; in cros_ec_mkbp_proximity_resume() local
193 ret = cros_ec_mkbp_proximity_query(ec, &state); in cros_ec_mkbp_proximity_resume()
209 struct device *dev = &pdev->dev; in cros_ec_mkbp_proximity_probe()
210 struct cros_ec_device *ec = dev_get_drvdata(dev->parent); in cros_ec_mkbp_proximity_probe() local
217 return -ENOMEM; in cros_ec_mkbp_proximity_probe()
220 data->ec = ec; in cros_ec_mkbp_proximity_probe()
221 data->indio_dev = indio_dev; in cros_ec_mkbp_proximity_probe()
222 data->last_proximity = -1; /* Unknown to start */ in cros_ec_mkbp_proximity_probe()
223 mutex_init(&data->lock); in cros_ec_mkbp_proximity_probe()
226 indio_dev->name = dev->driver->name; in cros_ec_mkbp_proximity_probe()
227 indio_dev->info = &cros_ec_mkbp_proximity_info; in cros_ec_mkbp_proximity_probe()
228 indio_dev->modes = INDIO_DIRECT_MODE; in cros_ec_mkbp_proximity_probe()
229 indio_dev->channels = cros_ec_mkbp_proximity_chan_spec; in cros_ec_mkbp_proximity_probe()
230 indio_dev->num_channels = ARRAY_SIZE(cros_ec_mkbp_proximity_chan_spec); in cros_ec_mkbp_proximity_probe()
236 data->notifier.notifier_call = cros_ec_mkbp_proximity_notify; in cros_ec_mkbp_proximity_probe()
237 blocking_notifier_chain_register(&ec->event_notifier, &data->notifier); in cros_ec_mkbp_proximity_probe()
245 struct cros_ec_device *ec = data->ec; in cros_ec_mkbp_proximity_remove() local
247 blocking_notifier_chain_unregister(&ec->event_notifier, in cros_ec_mkbp_proximity_remove()
248 &data->notifier); in cros_ec_mkbp_proximity_remove()
252 { .compatible = "google,cros-ec-mkbp-proximity" },
259 .name = "cros-ec-mkbp-proximity",
269 MODULE_DESCRIPTION("ChromeOS EC MKBP proximity sensor driver");