Lines Matching +full:system +full:- +full:critical +full:- +full:regulator
1 // SPDX-License-Identifier: GPL-2.0-or-later
7 * Copyright (C) 2011-2012 One Laptop per Child Foundation.
18 #include <linux/regulator/driver.h>
19 #include <linux/olpc-ec.h>
39 /* DCON regulator */
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()
87 list_del(&desc->node); in olpc_ec_worker()
89 spin_unlock_irqrestore(&ec->cmd_q_lock, flags); in olpc_ec_worker()
96 mutex_lock(&ec->cmd_lock); in olpc_ec_worker()
97 desc->err = ec_driver->ec_cmd(desc->cmd, desc->inbuf, desc->inlen, in olpc_ec_worker()
98 desc->outbuf, desc->outlen, ec_cb_arg); in olpc_ec_worker()
99 mutex_unlock(&ec->cmd_lock); in olpc_ec_worker()
102 complete(&desc->finished); in olpc_ec_worker()
105 schedule_work(&ec->worker); in olpc_ec_worker()
110 * locking is pretty critical.
117 INIT_LIST_HEAD(&desc->node); in queue_ec_descriptor()
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()
133 return -EPROBE_DEFER; in olpc_ec_cmd()
135 if (WARN_ON(!ec_driver->ec_cmd)) in olpc_ec_cmd()
136 return -ENODEV; in olpc_ec_cmd()
139 return -ENOMEM; in olpc_ec_cmd()
142 if (WARN_ON(ec->suspended)) in olpc_ec_cmd()
143 return -EBUSY; in olpc_ec_cmd()
157 /* Timeouts must be handled in the platform-specific EC hook */ in olpc_ec_cmd()
172 ec->ec_wakeup_mask |= value; in olpc_ec_wakeup_set()
183 ec->ec_wakeup_mask &= ~value; in olpc_ec_wakeup_clear()
192 return -ENODEV; in olpc_ec_mask_write()
195 if (ec->version >= 0x5f) { in olpc_ec_mask_write()
209 * to wake the system.
216 return ec_driver->wakeup_available; in olpc_ec_wakeup_available()
226 return -ENODEV; in olpc_ec_sci_query()
229 if (ec->version >= 0x5f) { in olpc_ec_sci_query()
281 pr_debug("olpc-ec: bad ec cmd: cmd:response-count [arg1 [arg2 ...]]\n"); in ec_dbgfs_cmd_write()
282 size = -EINVAL; in ec_dbgfs_cmd_write()
287 ec_cmd_bytes = m - 2; 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()
321 r = rp - respbuf; in ec_dbgfs_cmd_read()
334 dbgfs_dir = debugfs_create_dir("olpc-ec", NULL); in olpc_ec_setup_debugfs()
354 if (ec->dcon_enabled == state) in olpc_ec_set_dcon_power()
361 ec->dcon_enabled = state; in olpc_ec_set_dcon_power()
383 return ec->dcon_enabled ? 1 : 0; in dcon_regulator_is_enabled()
405 struct regulator_dev *regulator; in olpc_ec_probe() local
409 return -ENODEV; in olpc_ec_probe()
413 return -ENOMEM; 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()
426 err = olpc_ec_cmd(EC_FIRMWARE_REV, NULL, 0, &ec->version, 1); in olpc_ec_probe()
430 config.dev = pdev->dev.parent; in olpc_ec_probe()
432 ec->dcon_enabled = true; in olpc_ec_probe()
433 regulator = devm_regulator_register(&pdev->dev, &dcon_desc, &config); in olpc_ec_probe()
434 if (IS_ERR(regulator)) { in olpc_ec_probe()
435 dev_err(&pdev->dev, "failed to register DCON regulator\n"); in olpc_ec_probe()
436 err = PTR_ERR(regulator); in olpc_ec_probe()
440 ec->dbgfs_dir = olpc_ec_setup_debugfs(); in olpc_ec_probe()
456 olpc_ec_mask_write(ec->ec_wakeup_mask); in olpc_ec_suspend()
458 if (ec_driver->suspend) in olpc_ec_suspend()
459 err = ec_driver->suspend(pdev); in olpc_ec_suspend()
461 ec->suspended = true; in olpc_ec_suspend()
471 ec->suspended = false; in olpc_ec_resume()
472 return ec_driver->resume ? ec_driver->resume(pdev) : 0; in olpc_ec_resume()
483 .name = "olpc-ec",