Merge remote-tracking branch 'stable/linux-3.0.y' into develop-3.0
[firefly-linux-kernel-4.4.55.git] / include / linux / bp-auto.h
1 #ifndef _BP_AUTO_H\r
2 #define _BP_AUTO_H\r
3 #include <linux/miscdevice.h>\r
4 #include <linux/wakelock.h>\r
5 \r
6 struct bp_private_data;\r
7 \r
8 #define BP_UNKNOW_DATA  -1\r
9 #define BP_OFF          0\r
10 #define BP_ON           1\r
11 #define BP_SUSPEND      2\r
12 #define BP_WAKE         3\r
13 \r
14 #define BP_IOCTL_BASE 'm'\r
15 \r
16 #define BP_IOCTL_RESET          _IOW(BP_IOCTL_BASE, 0x00, int)\r
17 #define BP_IOCTL_POWON          _IOW(BP_IOCTL_BASE, 0x01, int)\r
18 #define BP_IOCTL_POWOFF         _IOW(BP_IOCTL_BASE, 0x02, int)\r
19 #define BP_IOCTL_WRITE_STATUS   _IOW(BP_IOCTL_BASE, 0x03, int)\r
20 #define BP_IOCTL_GET_STATUS     _IOR(BP_IOCTL_BASE, 0x04, int)\r
21 #define BP_IOCTL_SET_PVID       _IOW(BP_IOCTL_BASE, 0x05, int)\r
22 #define BP_IOCTL_GET_BPID       _IOR(BP_IOCTL_BASE, 0x06, int)\r
23 \r
24 enum bp_id{\r
25         BP_ID_INVALID = 0,\r
26                 \r
27         BP_ID_MT6229,\r
28         BP_ID_MU509,\r
29         BP_ID_MI700,\r
30         BP_ID_MW100,\r
31         BP_ID_TD8801,\r
32         \r
33         BP_ID_NUM,\r
34 };\r
35 \r
36 \r
37 \r
38 enum bp_bus_type{\r
39         BP_BUS_TYPE_INVALID = 0,\r
40                 \r
41         BP_BUS_TYPE_UART,\r
42         BP_BUS_TYPE_SPI,\r
43         BP_BUS_TYPE_USB,\r
44         BP_BUS_TYPE_SDIO,\r
45         BP_BUS_TYPE_USB_UART,\r
46         BP_BUS_TYPE_SPI_UART,\r
47         BP_BUS_TYPE_SDIO_UART,\r
48         \r
49         BP_BUS_TYPE_NUM_ID,\r
50 };\r
51 \r
52 struct bp_platform_data {       \r
53         int board_id;\r
54         int bp_id;\r
55         int (*init_platform_hw)(void);          \r
56         int (*exit_platform_hw)(void);  \r
57 \r
58         int bp_power;\r
59         int bp_en;\r
60         int bp_reset;\r
61         int ap_ready;\r
62         int bp_ready;\r
63         int ap_wakeup_bp;\r
64         int bp_wakeup_ap;       \r
65         int bp_usb_en;\r
66         int bp_uart_en;\r
67         \r
68         int gpio_valid;\r
69 };\r
70 \r
71 \r
72 struct bp_operate {\r
73         char *name;\r
74         int bp_id;\r
75         int bp_bus;\r
76         \r
77         int bp_pid;     \r
78         int bp_vid;\r
79         int bp_power;\r
80         int bp_en;\r
81         int bp_reset;\r
82         int ap_ready;\r
83         int bp_ready;\r
84         int ap_wakeup_bp;\r
85         int bp_wakeup_ap;       \r
86         int bp_usb_en;\r
87         int bp_uart_en;\r
88         int trig;\r
89         \r
90         int (*active)(struct bp_private_data *bp, int enable);\r
91         int (*init)(struct bp_private_data *bp);\r
92         int (*reset)(struct bp_private_data *bp);\r
93         int (*ap_wake_bp)(struct bp_private_data *bp, int wake);\r
94         int (*bp_wake_ap)(struct bp_private_data *bp);\r
95         int (*shutdown)(struct bp_private_data *bp);\r
96         int (*read_status)(struct bp_private_data *bp);\r
97         int (*write_status)(struct bp_private_data *bp);\r
98         int (*suspend)(struct bp_private_data *bp);\r
99         int (*resume)(struct bp_private_data *bp);      \r
100         \r
101         char *misc_name;\r
102         struct miscdevice *private_miscdev;\r
103         \r
104 };\r
105 \r
106 \r
107 struct bp_private_data {        \r
108         struct device *dev;\r
109         int status;\r
110         int suspend_status;\r
111         struct wake_lock bp_wakelock;\r
112         struct delayed_work wakeup_work;        /*report second event*/\r
113         struct bp_platform_data *pdata;\r
114         struct bp_operate *ops; \r
115         struct file_operations fops;\r
116         struct miscdevice miscdev;\r
117         struct file_operations id_fops;\r
118         struct miscdevice id_miscdev;\r
119 #ifdef CONFIG_HAS_EARLYSUSPEND\r
120         struct  early_suspend early_suspend;\r
121 #endif\r
122 };\r
123 \r
124 extern int bp_register_slave(struct bp_private_data *bp,\r
125                         struct bp_platform_data *slave_pdata,\r
126                         struct bp_operate *(*get_bp_ops)(void));\r
127 \r
128 \r
129 extern int bp_unregister_slave(struct bp_private_data *bp,\r
130                         struct bp_platform_data *slave_pdata,\r
131                         struct bp_operate *(*get_bp_ops)(void));\r
132 \r
133 \r
134 #endif\r
135 \r