1*4882a593Smuzhiyun /* SPDX-License-Identifier: GPL-2.0 */
2*4882a593Smuzhiyun /*
3*4882a593Smuzhiyun * Copyright © 2016 Intel Corporation
4*4882a593Smuzhiyun *
5*4882a593Smuzhiyun * Authors:
6*4882a593Smuzhiyun * Rafael Antognolli <rafael.antognolli@intel.com>
7*4882a593Smuzhiyun * Scott Bauer <scott.bauer@intel.com>
8*4882a593Smuzhiyun */
9*4882a593Smuzhiyun
10*4882a593Smuzhiyun #ifndef LINUX_OPAL_H
11*4882a593Smuzhiyun #define LINUX_OPAL_H
12*4882a593Smuzhiyun
13*4882a593Smuzhiyun #include <uapi/linux/sed-opal.h>
14*4882a593Smuzhiyun #include <linux/kernel.h>
15*4882a593Smuzhiyun
16*4882a593Smuzhiyun struct opal_dev;
17*4882a593Smuzhiyun
18*4882a593Smuzhiyun typedef int (sec_send_recv)(void *data, u16 spsp, u8 secp, void *buffer,
19*4882a593Smuzhiyun size_t len, bool send);
20*4882a593Smuzhiyun
21*4882a593Smuzhiyun #ifdef CONFIG_BLK_SED_OPAL
22*4882a593Smuzhiyun void free_opal_dev(struct opal_dev *dev);
23*4882a593Smuzhiyun bool opal_unlock_from_suspend(struct opal_dev *dev);
24*4882a593Smuzhiyun struct opal_dev *init_opal_dev(void *data, sec_send_recv *send_recv);
25*4882a593Smuzhiyun int sed_ioctl(struct opal_dev *dev, unsigned int cmd, void __user *ioctl_ptr);
26*4882a593Smuzhiyun
is_sed_ioctl(unsigned int cmd)27*4882a593Smuzhiyun static inline bool is_sed_ioctl(unsigned int cmd)
28*4882a593Smuzhiyun {
29*4882a593Smuzhiyun switch (cmd) {
30*4882a593Smuzhiyun case IOC_OPAL_SAVE:
31*4882a593Smuzhiyun case IOC_OPAL_LOCK_UNLOCK:
32*4882a593Smuzhiyun case IOC_OPAL_TAKE_OWNERSHIP:
33*4882a593Smuzhiyun case IOC_OPAL_ACTIVATE_LSP:
34*4882a593Smuzhiyun case IOC_OPAL_SET_PW:
35*4882a593Smuzhiyun case IOC_OPAL_ACTIVATE_USR:
36*4882a593Smuzhiyun case IOC_OPAL_REVERT_TPR:
37*4882a593Smuzhiyun case IOC_OPAL_LR_SETUP:
38*4882a593Smuzhiyun case IOC_OPAL_ADD_USR_TO_LR:
39*4882a593Smuzhiyun case IOC_OPAL_ENABLE_DISABLE_MBR:
40*4882a593Smuzhiyun case IOC_OPAL_ERASE_LR:
41*4882a593Smuzhiyun case IOC_OPAL_SECURE_ERASE_LR:
42*4882a593Smuzhiyun case IOC_OPAL_PSID_REVERT_TPR:
43*4882a593Smuzhiyun case IOC_OPAL_MBR_DONE:
44*4882a593Smuzhiyun case IOC_OPAL_WRITE_SHADOW_MBR:
45*4882a593Smuzhiyun case IOC_OPAL_GENERIC_TABLE_RW:
46*4882a593Smuzhiyun return true;
47*4882a593Smuzhiyun }
48*4882a593Smuzhiyun return false;
49*4882a593Smuzhiyun }
50*4882a593Smuzhiyun #else
free_opal_dev(struct opal_dev * dev)51*4882a593Smuzhiyun static inline void free_opal_dev(struct opal_dev *dev)
52*4882a593Smuzhiyun {
53*4882a593Smuzhiyun }
54*4882a593Smuzhiyun
is_sed_ioctl(unsigned int cmd)55*4882a593Smuzhiyun static inline bool is_sed_ioctl(unsigned int cmd)
56*4882a593Smuzhiyun {
57*4882a593Smuzhiyun return false;
58*4882a593Smuzhiyun }
59*4882a593Smuzhiyun
sed_ioctl(struct opal_dev * dev,unsigned int cmd,void __user * ioctl_ptr)60*4882a593Smuzhiyun static inline int sed_ioctl(struct opal_dev *dev, unsigned int cmd,
61*4882a593Smuzhiyun void __user *ioctl_ptr)
62*4882a593Smuzhiyun {
63*4882a593Smuzhiyun return 0;
64*4882a593Smuzhiyun }
opal_unlock_from_suspend(struct opal_dev * dev)65*4882a593Smuzhiyun static inline bool opal_unlock_from_suspend(struct opal_dev *dev)
66*4882a593Smuzhiyun {
67*4882a593Smuzhiyun return false;
68*4882a593Smuzhiyun }
69*4882a593Smuzhiyun #define init_opal_dev(data, send_recv) NULL
70*4882a593Smuzhiyun #endif /* CONFIG_BLK_SED_OPAL */
71*4882a593Smuzhiyun #endif /* LINUX_OPAL_H */
72