Lines Matching full:ec

19 #include <linux/olpc-ec.h>
42 /* Pending EC commands */
49 * EC event mask to be applied during suspend (defining wakeup
55 * Running an EC command while suspending means we don't always finish
56 * the command before the machine suspends. This means that the EC
58 * of time (while the OS is asleep) the EC times out and restarts its
61 * the EC... and everyone's uphappy.
79 struct olpc_ec_priv *ec = container_of(w, struct olpc_ec_priv, worker); in olpc_ec_worker() local
84 spin_lock_irqsave(&ec->cmd_q_lock, flags); in olpc_ec_worker()
85 if (!list_empty(&ec->cmd_q)) { in olpc_ec_worker()
86 desc = list_first_entry(&ec->cmd_q, struct ec_cmd_desc, node); in olpc_ec_worker()
89 spin_unlock_irqrestore(&ec->cmd_q_lock, flags); in olpc_ec_worker()
95 /* Protect the EC hw with a mutex; only run one cmd at a time */ in olpc_ec_worker()
96 mutex_lock(&ec->cmd_lock); in olpc_ec_worker()
99 mutex_unlock(&ec->cmd_lock); in olpc_ec_worker()
105 schedule_work(&ec->worker); in olpc_ec_worker()
113 struct olpc_ec_priv *ec) in queue_ec_descriptor() argument
119 spin_lock_irqsave(&ec->cmd_q_lock, flags); in queue_ec_descriptor()
120 list_add_tail(&desc->node, &ec->cmd_q); in queue_ec_descriptor()
121 spin_unlock_irqrestore(&ec->cmd_q_lock, flags); in queue_ec_descriptor()
123 schedule_work(&ec->worker); in queue_ec_descriptor()
128 struct olpc_ec_priv *ec = ec_priv; in olpc_ec_cmd() local
138 if (!ec) in olpc_ec_cmd()
142 if (WARN_ON(ec->suspended)) in olpc_ec_cmd()
155 queue_ec_descriptor(&desc, ec); in olpc_ec_cmd()
157 /* Timeouts must be handled in the platform-specific EC hook */ in olpc_ec_cmd()
167 struct olpc_ec_priv *ec = ec_priv; in olpc_ec_wakeup_set() local
169 if (WARN_ON(!ec)) in olpc_ec_wakeup_set()
172 ec->ec_wakeup_mask |= value; in olpc_ec_wakeup_set()
178 struct olpc_ec_priv *ec = ec_priv; in olpc_ec_wakeup_clear() local
180 if (WARN_ON(!ec)) in olpc_ec_wakeup_clear()
183 ec->ec_wakeup_mask &= ~value; in olpc_ec_wakeup_clear()
189 struct olpc_ec_priv *ec = ec_priv; in olpc_ec_mask_write() local
191 if (WARN_ON(!ec)) in olpc_ec_mask_write()
194 /* EC version 0x5f adds support for wide SCI mask */ in olpc_ec_mask_write()
195 if (ec->version >= 0x5f) { in olpc_ec_mask_write()
208 * Returns true if the compile and runtime configurations allow for EC events
222 struct olpc_ec_priv *ec = ec_priv; in olpc_ec_sci_query() local
225 if (WARN_ON(!ec)) in olpc_ec_sci_query()
228 /* EC version 0x5f adds support for wide SCI mask */ in olpc_ec_sci_query()
229 if (ec->version >= 0x5f) { in olpc_ec_sci_query()
251 * arbitrary EC commands from userspace.
281 pr_debug("olpc-ec: bad ec cmd: cmd:response-count [arg1 [arg2 ...]]\n"); in ec_dbgfs_cmd_write()
291 pr_debug("olpc-ec: debugfs cmd 0x%02x with %d args %5ph, want %d returns\n", in ec_dbgfs_cmd_write()
298 pr_debug("olpc-ec: response %8ph (%d bytes expected)\n", in ec_dbgfs_cmd_write()
334 dbgfs_dir = debugfs_create_dir("olpc-ec", NULL); in olpc_ec_setup_debugfs()
349 static int olpc_ec_set_dcon_power(struct olpc_ec_priv *ec, bool state) in olpc_ec_set_dcon_power() argument
354 if (ec->dcon_enabled == state) in olpc_ec_set_dcon_power()
361 ec->dcon_enabled = state; in olpc_ec_set_dcon_power()
367 struct olpc_ec_priv *ec = rdev_get_drvdata(rdev); in dcon_regulator_enable() local
369 return olpc_ec_set_dcon_power(ec, true); in dcon_regulator_enable()
374 struct olpc_ec_priv *ec = rdev_get_drvdata(rdev); in dcon_regulator_disable() local
376 return olpc_ec_set_dcon_power(ec, false); in dcon_regulator_disable()
381 struct olpc_ec_priv *ec = rdev_get_drvdata(rdev); in dcon_regulator_is_enabled() local
383 return ec->dcon_enabled ? 1 : 0; in dcon_regulator_is_enabled()
403 struct olpc_ec_priv *ec; in olpc_ec_probe() local
411 ec = kzalloc(sizeof(*ec), GFP_KERNEL); in olpc_ec_probe()
412 if (!ec) in olpc_ec_probe()
415 ec->drv = ec_driver; in olpc_ec_probe()
416 INIT_WORK(&ec->worker, olpc_ec_worker); in olpc_ec_probe()
417 mutex_init(&ec->cmd_lock); in olpc_ec_probe()
419 INIT_LIST_HEAD(&ec->cmd_q); in olpc_ec_probe()
420 spin_lock_init(&ec->cmd_q_lock); in olpc_ec_probe()
422 ec_priv = ec; in olpc_ec_probe()
423 platform_set_drvdata(pdev, ec); in olpc_ec_probe()
425 /* get the EC revision */ in olpc_ec_probe()
426 err = olpc_ec_cmd(EC_FIRMWARE_REV, NULL, 0, &ec->version, 1); in olpc_ec_probe()
431 config.driver_data = ec; in olpc_ec_probe()
432 ec->dcon_enabled = true; in olpc_ec_probe()
440 ec->dbgfs_dir = olpc_ec_setup_debugfs(); in olpc_ec_probe()
446 kfree(ec); in olpc_ec_probe()
453 struct olpc_ec_priv *ec = platform_get_drvdata(pdev); in olpc_ec_suspend() local
456 olpc_ec_mask_write(ec->ec_wakeup_mask); in olpc_ec_suspend()
461 ec->suspended = true; in olpc_ec_suspend()
469 struct olpc_ec_priv *ec = platform_get_drvdata(pdev); in olpc_ec_resume() local
471 ec->suspended = false; in olpc_ec_resume()
483 .name = "olpc-ec",