1 /* 2 * Copyright (c) 2020 HiSilicon (Shanghai) Technologies CO., LIMITED. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 * Description: Common, (non-)os independant, UART driver interface 15 */ 16 17 #ifndef PLATFORM_DRIVER_H 18 #define PLATFORM_DRIVER_H 19 20 #include "list.h" 21 22 /** @addtogroup DRIVERS 23 * @{ 24 */ 25 /** @addtogroup DRIVER_PLATFORM 26 * @{ 27 */ 28 /** @defgroup DRIVER_PLATFORM_PLATFORM_DRIVER CHIP Platform PLATFORM Driver 29 * @{ 30 */ 31 typedef enum { 32 DEV_WAKEUP, // !< Represents this is a wakeup device. 33 DEV_ZOMBIE // !< Represents this is not a wakeup device. 34 } dev_type_e; 35 36 typedef enum { 37 DEV_POWER_ON, // !< Represents this device have power on. 38 DEV_POWER_OFF // !< Represents this device have power off. 39 } dev_power_e; 40 41 struct driver_operation { 42 void (*init)(void); 43 int (*open)(void); 44 int (*close)(void); 45 void (*resume)(void); 46 void (*suspend)(void); 47 int (*deinit)(void); 48 }; 49 50 typedef struct plt_dev_t { 51 char *name; 52 dev_type_e device_t; 53 dev_power_e power_status; 54 struct list_head device_list; 55 struct driver_operation *driver; 56 } plt_dev_t; 57 58 /** 59 * @brief Platform driver init. 60 */ 61 int platform_driver_init(void); 62 63 /** 64 * @brief Platform device driver register. 65 * @param device device 66 * @return None 67 */ 68 int platform_driver_register(plt_dev_t *device); 69 70 /** 71 * @brief Platform device resume.restore clock or power on. 72 * @return None 73 */ 74 void platform_device_resume(void); 75 /** 76 * @brief Platform device suspend.gating clock or power off. 77 * @return None 78 */ 79 void platform_device_suspend(void); 80 81 /** 82 * @} 83 */ 84 /** 85 * @} 86 */ 87 /** 88 * @} 89 */ 90 #endif 91