18c16567dSChristoph Hellwig /* SPDX-License-Identifier: GPL-2.0 */
2455a7b23SScott Bauer /*
3455a7b23SScott Bauer * Copyright © 2016 Intel Corporation
4455a7b23SScott Bauer *
5455a7b23SScott Bauer * Authors:
6455a7b23SScott Bauer * Rafael Antognolli <[email protected]>
7455a7b23SScott Bauer * Scott Bauer <[email protected]>
8455a7b23SScott Bauer */
9455a7b23SScott Bauer
10455a7b23SScott Bauer #ifndef LINUX_OPAL_H
11455a7b23SScott Bauer #define LINUX_OPAL_H
12455a7b23SScott Bauer
13455a7b23SScott Bauer #include <uapi/linux/sed-opal.h>
1456fb8d90SChristophe JAILLET #include <linux/compiler_types.h>
1556fb8d90SChristophe JAILLET #include <linux/types.h>
16455a7b23SScott Bauer
17455a7b23SScott Bauer struct opal_dev;
18455a7b23SScott Bauer
194f1244c8SChristoph Hellwig typedef int (sec_send_recv)(void *data, u16 spsp, u8 secp, void *buffer,
204f1244c8SChristoph Hellwig size_t len, bool send);
21455a7b23SScott Bauer
22455a7b23SScott Bauer #ifdef CONFIG_BLK_SED_OPAL
237d6d1578SScott Bauer void free_opal_dev(struct opal_dev *dev);
24455a7b23SScott Bauer bool opal_unlock_from_suspend(struct opal_dev *dev);
254f1244c8SChristoph Hellwig struct opal_dev *init_opal_dev(void *data, sec_send_recv *send_recv);
26e225c20eSScott Bauer int sed_ioctl(struct opal_dev *dev, unsigned int cmd, void __user *ioctl_ptr);
27455a7b23SScott Bauer
283bfeb612SGreg Joyce #define OPAL_AUTH_KEY "opal-boot-pin"
293bfeb612SGreg Joyce #define OPAL_AUTH_KEY_PREV "opal-boot-pin-prev"
303bfeb612SGreg Joyce
is_sed_ioctl(unsigned int cmd)31455a7b23SScott Bauer static inline bool is_sed_ioctl(unsigned int cmd)
32455a7b23SScott Bauer {
33455a7b23SScott Bauer switch (cmd) {
34455a7b23SScott Bauer case IOC_OPAL_SAVE:
35455a7b23SScott Bauer case IOC_OPAL_LOCK_UNLOCK:
36455a7b23SScott Bauer case IOC_OPAL_TAKE_OWNERSHIP:
37455a7b23SScott Bauer case IOC_OPAL_ACTIVATE_LSP:
38455a7b23SScott Bauer case IOC_OPAL_SET_PW:
39455a7b23SScott Bauer case IOC_OPAL_ACTIVATE_USR:
40455a7b23SScott Bauer case IOC_OPAL_REVERT_TPR:
41455a7b23SScott Bauer case IOC_OPAL_LR_SETUP:
42455a7b23SScott Bauer case IOC_OPAL_ADD_USR_TO_LR:
43455a7b23SScott Bauer case IOC_OPAL_ENABLE_DISABLE_MBR:
44455a7b23SScott Bauer case IOC_OPAL_ERASE_LR:
45455a7b23SScott Bauer case IOC_OPAL_SECURE_ERASE_LR:
465e4c7cf6SRevanth Rajashekar case IOC_OPAL_PSID_REVERT_TPR:
47c9888443SJonas Rabenstein case IOC_OPAL_MBR_DONE:
48a9b25b4cSJonas Rabenstein case IOC_OPAL_WRITE_SHADOW_MBR:
4951f421c8SRevanth Rajashekar case IOC_OPAL_GENERIC_TABLE_RW:
50c6ea7060S[email protected] case IOC_OPAL_GET_STATUS:
514c4dd04eSOndrej Kozina case IOC_OPAL_GET_LR_STATUS:
529e05a259SOndrej Kozina case IOC_OPAL_GET_GEOMETRY:
539fb10726SGreg Joyce case IOC_OPAL_DISCOVERY:
545c82efc1SGreg Joyce case IOC_OPAL_REVERT_LSP:
55*b21d948fSGreg Joyce case IOC_OPAL_SET_SID_PW:
56455a7b23SScott Bauer return true;
57455a7b23SScott Bauer }
58455a7b23SScott Bauer return false;
59455a7b23SScott Bauer }
60455a7b23SScott Bauer #else
free_opal_dev(struct opal_dev * dev)617d6d1578SScott Bauer static inline void free_opal_dev(struct opal_dev *dev)
627d6d1578SScott Bauer {
637d6d1578SScott Bauer }
647d6d1578SScott Bauer
is_sed_ioctl(unsigned int cmd)65455a7b23SScott Bauer static inline bool is_sed_ioctl(unsigned int cmd)
66455a7b23SScott Bauer {
67455a7b23SScott Bauer return false;
68455a7b23SScott Bauer }
69455a7b23SScott Bauer
sed_ioctl(struct opal_dev * dev,unsigned int cmd,void __user * ioctl_ptr)70455a7b23SScott Bauer static inline int sed_ioctl(struct opal_dev *dev, unsigned int cmd,
71e225c20eSScott Bauer void __user *ioctl_ptr)
72455a7b23SScott Bauer {
73455a7b23SScott Bauer return 0;
74455a7b23SScott Bauer }
opal_unlock_from_suspend(struct opal_dev * dev)75455a7b23SScott Bauer static inline bool opal_unlock_from_suspend(struct opal_dev *dev)
76455a7b23SScott Bauer {
77455a7b23SScott Bauer return false;
78455a7b23SScott Bauer }
794f1244c8SChristoph Hellwig #define init_opal_dev(data, send_recv) NULL
80455a7b23SScott Bauer #endif /* CONFIG_BLK_SED_OPAL */
81455a7b23SScott Bauer #endif /* LINUX_OPAL_H */
82