Lines Matching full:ec
19 #include <linux/olpc-ec.h>
43 /* Pending EC commands */
50 * EC event mask to be applied during suspend (defining wakeup
56 * Running an EC command while suspending means we don't always finish
57 * the command before the machine suspends. This means that the EC
59 * of time (while the OS is asleep) the EC times out and restarts its
62 * the EC... and everyone's uphappy.
80 struct olpc_ec_priv *ec = container_of(w, struct olpc_ec_priv, worker); in olpc_ec_worker() local
85 spin_lock_irqsave(&ec->cmd_q_lock, flags); in olpc_ec_worker()
86 if (!list_empty(&ec->cmd_q)) { in olpc_ec_worker()
87 desc = list_first_entry(&ec->cmd_q, struct ec_cmd_desc, node); in olpc_ec_worker()
90 spin_unlock_irqrestore(&ec->cmd_q_lock, flags); in olpc_ec_worker()
96 /* Protect the EC hw with a mutex; only run one cmd at a time */ in olpc_ec_worker()
97 mutex_lock(&ec->cmd_lock); in olpc_ec_worker()
100 mutex_unlock(&ec->cmd_lock); in olpc_ec_worker()
106 schedule_work(&ec->worker); in olpc_ec_worker()
114 struct olpc_ec_priv *ec) in queue_ec_descriptor() argument
120 spin_lock_irqsave(&ec->cmd_q_lock, flags); in queue_ec_descriptor()
121 list_add_tail(&desc->node, &ec->cmd_q); in queue_ec_descriptor()
122 spin_unlock_irqrestore(&ec->cmd_q_lock, flags); in queue_ec_descriptor()
124 schedule_work(&ec->worker); in queue_ec_descriptor()
129 struct olpc_ec_priv *ec = ec_priv; in olpc_ec_cmd() local
139 if (!ec) in olpc_ec_cmd()
143 if (WARN_ON(ec->suspended)) in olpc_ec_cmd()
156 queue_ec_descriptor(&desc, ec); in olpc_ec_cmd()
158 /* Timeouts must be handled in the platform-specific EC hook */ in olpc_ec_cmd()
168 struct olpc_ec_priv *ec = ec_priv; in olpc_ec_wakeup_set() local
170 if (WARN_ON(!ec)) in olpc_ec_wakeup_set()
173 ec->ec_wakeup_mask |= value; in olpc_ec_wakeup_set()
179 struct olpc_ec_priv *ec = ec_priv; in olpc_ec_wakeup_clear() local
181 if (WARN_ON(!ec)) in olpc_ec_wakeup_clear()
184 ec->ec_wakeup_mask &= ~value; in olpc_ec_wakeup_clear()
190 struct olpc_ec_priv *ec = ec_priv; in olpc_ec_mask_write() local
192 if (WARN_ON(!ec)) in olpc_ec_mask_write()
195 /* EC version 0x5f adds support for wide SCI mask */ in olpc_ec_mask_write()
196 if (ec->version >= 0x5f) { in olpc_ec_mask_write()
209 * Returns true if the compile and runtime configurations allow for EC events
223 struct olpc_ec_priv *ec = ec_priv; in olpc_ec_sci_query() local
226 if (WARN_ON(!ec)) in olpc_ec_sci_query()
229 /* EC version 0x5f adds support for wide SCI mask */ in olpc_ec_sci_query()
230 if (ec->version >= 0x5f) { in olpc_ec_sci_query()
252 * arbitrary EC commands from userspace.
282 pr_debug("olpc-ec: bad ec cmd: cmd:response-count [arg1 [arg2 ...]]\n"); in ec_dbgfs_cmd_write()
292 pr_debug("olpc-ec: debugfs cmd 0x%02x with %d args %5ph, want %d returns\n", in ec_dbgfs_cmd_write()
299 pr_debug("olpc-ec: response %8ph (%d bytes expected)\n", in ec_dbgfs_cmd_write()
335 dbgfs_dir = debugfs_create_dir("olpc-ec", NULL); in olpc_ec_setup_debugfs()
353 static int olpc_ec_set_dcon_power(struct olpc_ec_priv *ec, bool state) in olpc_ec_set_dcon_power() argument
358 if (ec->dcon_enabled == state) in olpc_ec_set_dcon_power()
365 ec->dcon_enabled = state; in olpc_ec_set_dcon_power()
371 struct olpc_ec_priv *ec = rdev_get_drvdata(rdev); in dcon_regulator_enable() local
373 return olpc_ec_set_dcon_power(ec, true); in dcon_regulator_enable()
378 struct olpc_ec_priv *ec = rdev_get_drvdata(rdev); in dcon_regulator_disable() local
380 return olpc_ec_set_dcon_power(ec, false); in dcon_regulator_disable()
385 struct olpc_ec_priv *ec = rdev_get_drvdata(rdev); in dcon_regulator_is_enabled() local
387 return ec->dcon_enabled ? 1 : 0; in dcon_regulator_is_enabled()
406 struct olpc_ec_priv *ec; in olpc_ec_probe() local
413 ec = kzalloc(sizeof(*ec), GFP_KERNEL); in olpc_ec_probe()
414 if (!ec) in olpc_ec_probe()
417 ec->drv = ec_driver; in olpc_ec_probe()
418 INIT_WORK(&ec->worker, olpc_ec_worker); in olpc_ec_probe()
419 mutex_init(&ec->cmd_lock); in olpc_ec_probe()
421 INIT_LIST_HEAD(&ec->cmd_q); in olpc_ec_probe()
422 spin_lock_init(&ec->cmd_q_lock); in olpc_ec_probe()
424 ec_priv = ec; in olpc_ec_probe()
425 platform_set_drvdata(pdev, ec); in olpc_ec_probe()
427 /* get the EC revision */ in olpc_ec_probe()
428 err = olpc_ec_cmd(EC_FIRMWARE_REV, NULL, 0, &ec->version, 1); in olpc_ec_probe()
433 config.driver_data = ec; in olpc_ec_probe()
434 ec->dcon_enabled = true; in olpc_ec_probe()
435 ec->dcon_rdev = devm_regulator_register(&pdev->dev, &dcon_desc, in olpc_ec_probe()
437 if (IS_ERR(ec->dcon_rdev)) { in olpc_ec_probe()
439 err = PTR_ERR(ec->dcon_rdev); in olpc_ec_probe()
443 ec->dbgfs_dir = olpc_ec_setup_debugfs(); in olpc_ec_probe()
449 kfree(ec); in olpc_ec_probe()
456 struct olpc_ec_priv *ec = platform_get_drvdata(pdev); in olpc_ec_suspend() local
459 olpc_ec_mask_write(ec->ec_wakeup_mask); in olpc_ec_suspend()
464 ec->suspended = true; in olpc_ec_suspend()
472 struct olpc_ec_priv *ec = platform_get_drvdata(pdev); in olpc_ec_resume() local
474 ec->suspended = false; in olpc_ec_resume()
486 .name = "olpc-ec",