1 /* 2 * Copyright (C) 2022 HiSilicon (Shanghai) Technologies CO., LIMITED. 3 * 4 * This program is free software; you can redistribute it and/or 5 * modify it under the terms of the GNU General Public License 6 * as published by the Free Software Foundation; either version 2 7 * of the License, or (at your option) any later version. 8 * 9 * This program is distributed in the hope that it will be useful, 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 * GNU General Public License for more details. 13 * 14 * You should have received a copy of the GNU General Public License 15 * along with this program; if not, write to the Free Software 16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 17 */ 18 19 #ifndef __HIMEDIA_H__ 20 #define __HIMEDIA_H__ 21 22 #include <asm/types.h> 23 #include <asm/atomic.h> 24 #include <linux/module.h> 25 #include <linux/device.h> 26 #include <linux/major.h> 27 #include <linux/fs.h> 28 29 30 #include "hi_type.h" 31 #include "hi_module.h" 32 33 #ifdef __cplusplus 34 extern "C" { 35 #endif /* End of #ifdef __cplusplus */ 36 37 #define HIMEDIA_DEVICE_NAME_MAX_LEN 64 38 39 #define HIMEDIA_DEVICE_MAJOR 218 40 #define HIMEDIA_DYNAMIC_MINOR 255 41 42 typedef struct tag_pm_basedev { 43 HI_S32 id; 44 const HI_S8 *name; 45 struct device dev; 46 } pm_basedev; 47 48 #define TO_PM_BASEDEV(x) container_of((x), pm_basedev, dev) 49 50 typedef struct tag_pm_baseops { 51 HI_S32 (*probe)(pm_basedev *); 52 HI_S32 (*remove)(pm_basedev *); 53 HI_VOID (*shutdown)(pm_basedev *); 54 HI_S32 (*prepare)(pm_basedev *); 55 HI_VOID (*complete)(pm_basedev *); 56 HI_S32 (*suspend)(pm_basedev *, pm_message_t state); 57 HI_S32 (*suspend_late)(pm_basedev *, pm_message_t state); 58 HI_S32 (*resume_early)(pm_basedev *); 59 HI_S32 (*resume)(pm_basedev *); 60 } pm_baseops; 61 62 typedef struct tag_pm_basedrv { 63 HI_S32(*probe)(pm_basedev *); 64 HI_S32 (*remove)(pm_basedev *); 65 HI_VOID (*shutdown)(pm_basedev *); 66 HI_S32 (*suspend)(pm_basedev *, pm_message_t state); 67 HI_S32 (*suspend_late)(pm_basedev *, pm_message_t state); 68 HI_S32 (*resume_early)(pm_basedev *); 69 HI_S32 (*resume)(pm_basedev *); 70 struct device_driver driver; 71 } pm_basedrv; 72 73 #define to_himedia_basedrv(drv) container_of((drv), pm_basedrv, driver) 74 75 typedef struct hi_umap_device { 76 HI_CHAR devfs_name[HIMEDIA_DEVICE_NAME_MAX_LEN]; /* devfs */ 77 HI_S32 minor; 78 struct module *owner; 79 struct file_operations *fops; 80 pm_baseops *drvops; 81 } umap_device, *ptr_umap_device; 82 83 typedef struct tag_pm_device { 84 HI_U32 minor; 85 const HI_S8 *name; 86 struct module *owner; 87 const struct file_operations *app_ops; 88 pm_baseops *base_ops; 89 struct list_head list; 90 struct device *app_device; 91 pm_basedev *base_device; 92 pm_basedrv *base_driver; 93 umap_device *umap_dev; 94 void *dev; 95 } pm_device; 96 97 98 HI_S32 drv_pm_mod_init(HI_VOID); 99 HI_VOID drv_pm_mod_exit(HI_VOID); 100 HI_S32 hi_drv_pm_register(pm_device *); 101 HI_S32 hi_drv_pm_un_register(pm_device *); 102 103 #ifdef __cplusplus 104 } 105 #endif /* End of #ifdef __cplusplus */ 106 107 #endif /* __HIMEDIA_H__ */ 108 109