1295016Sjkim/*- 2162911Ssimon * SPDX-License-Identifier: BSD-2-Clause 3162911Ssimon * 4162911Ssimon * Copyright (c) 2020 The FreeBSD Foundation 5162911Ssimon * 6162911Ssimon * This software was developed by Bj��rn Zeeb under sponsorship from 7162911Ssimon * the FreeBSD Foundation. 8162911Ssimon * 9162911Ssimon * Redistribution and use in source and binary forms, with or without 10280304Sjkim * modification, are permitted provided that the following conditions 11162911Ssimon * are met: 12162911Ssimon * 1. Redistributions of source code must retain the above copyright 13162911Ssimon * notice, this list of conditions and the following disclaimer. 14162911Ssimon * 2. Redistributions in binary form must reproduce the above copyright 15162911Ssimon * notice, this list of conditions and the following disclaimer in the 16162911Ssimon * documentation and/or other materials provided with the distribution. 17162911Ssimon * 18162911Ssimon * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 19162911Ssimon * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 20162911Ssimon * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 21162911Ssimon * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 22162911Ssimon * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 23162911Ssimon * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 24162911Ssimon * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 25162911Ssimon * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 26162911Ssimon * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 27162911Ssimon * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 28162911Ssimon * SUCH DAMAGE. 29162911Ssimon */ 30162911Ssimon 31162911Ssimon#ifndef _LINUXKPI_LINUX_PM_H 32162911Ssimon#define _LINUXKPI_LINUX_PM_H 33162911Ssimon 34162911Ssimon#include <linux/kernel.h> /* pr_debug */ 35162911Ssimon#include <asm/atomic.h> 36162911Ssimon 37162911Ssimon/* Needed but breaks linux_usb.c */ 38162911Ssimon/* #include <linux/completion.h> */ 39162911Ssimon/* #include <linux/wait.h> */ 40162911Ssimon 41162911Ssimonstruct device; 42162911Ssimon 43162911Ssimontypedef struct pm_message { 44162911Ssimon int event; 45162911Ssimon} pm_message_t; 46162911Ssimon 47162911Ssimonstruct dev_pm_domain { 48162911Ssimon}; 49162911Ssimon 50162911Ssimonstruct dev_pm_info { 51162911Ssimon atomic_t usage_count; 52162911Ssimon}; 53162911Ssimon 54162911Ssimon#define PM_EVENT_FREEZE 0x0001 55162911Ssimon#define PM_EVENT_SUSPEND 0x0002 56162911Ssimon 57162911Ssimon#define pm_sleep_ptr(_p) \ 58280304Sjkim IS_ENABLED(CONFIG_PM_SLEEP) ? (_p) : NULL 59280304Sjkim 60280304Sjkim#ifdef CONFIG_PM_SLEEP 61280304Sjkim#define SIMPLE_DEV_PM_OPS(_name, _suspendfunc, _resumefunc) \ 62280304Sjkimconst struct dev_pm_ops _name = { \ 63280304Sjkim .suspend = _suspendfunc, \ 64162911Ssimon .resume = _resumefunc, \ 65162911Ssimon .freeze = _suspendfunc, \ 66280304Sjkim .thaw = _resumefunc, \ 67162911Ssimon .poweroff = _suspendfunc, \ 68162911Ssimon .restore = _resumefunc, \ 69280304Sjkim} 70280304Sjkim 71280304Sjkim#define DEFINE_SIMPLE_DEV_PM_OPS(_name, _suspendfunc, _resumefunc) \ 72162911Ssimonconst struct dev_pm_ops _name = { \ 73162911Ssimon .suspend = _suspendfunc, \ 74280304Sjkim .resume = _resumefunc, \ 75162911Ssimon .freeze = _suspendfunc, \ 76162911Ssimon .thaw = _resumefunc, \ 77280304Sjkim .poweroff = _suspendfunc, \ 78280304Sjkim .restore = _resumefunc, \ 79280304Sjkim} 80280304Sjkim#else 81280304Sjkim#define SIMPLE_DEV_PM_OPS(_name, _suspendfunc, _resumefunc) \ 82280304Sjkimconst struct dev_pm_ops _name = { \ 83280304Sjkim} 84280304Sjkim#define DEFINE_SIMPLE_DEV_PM_OPS(_name, _suspendfunc, _resumefunc) \ 85280304Sjkimconst struct dev_pm_ops _name = { \ 86280304Sjkim} 87280304Sjkim#endif 88280304Sjkim 89280304Sjkimstatic inline void 90280304Sjkimpm_wakeup_event(struct device *dev __unused, unsigned int x __unused) 91280304Sjkim{ 92162911Ssimon 93280304Sjkim pr_debug("%s: TODO\n", __func__); 94280304Sjkim} 95280304Sjkim 96162911Ssimon#endif /* _LINUXKPI_LINUX_PM_H */ 97280304Sjkim