1 /* SPDX-License-Identifier: GPL-2.0 */
3 * Copyright (C) 2015-2019 Intel Corp. All rights reserved
4 * Copyright (C) 2021-2022 Linaro Ltd
9 #include <linux/device.h>
10 #include <linux/types.h>
13 * enum rpmb_type - type of underlying storage technology
15 * @RPMB_TYPE_EMMC : emmc (JESD84-B50.1)
16 * @RPMB_TYPE_UFS : UFS (JESD220)
17 * @RPMB_TYPE_NVME : NVM Express
26 * struct rpmb_descr - RPMB description provided by the underlying block device
28 * @type : block device type
29 * @route_frames : routes frames to and from the RPMB device
30 * @dev_id : unique device identifier read from the hardware
31 * @dev_id_len : length of unique device identifier
32 * @reliable_wr_count: number of sectors that can be written in one access
33 * @capacity : capacity of the device in units of 128K
35 * @dev_id is intended to be used as input when deriving the authenticaion key.
39 int (*route_frames
)(struct device
*dev
, u8
*req
, unsigned int req_len
,
40 u8
*resp
, unsigned int resp_len
);
43 u16 reliable_wr_count
;
48 * struct rpmb_dev - device which can support RPMB partition
52 * @list_node : linked list node
53 * @descr : RPMB description
58 struct list_head list_node
;
59 struct rpmb_descr descr
;
62 #define to_rpmb_dev(x) container_of((x), struct rpmb_dev, dev)
64 #if IS_ENABLED(CONFIG_RPMB)
65 struct rpmb_dev
*rpmb_dev_get(struct rpmb_dev
*rdev
);
66 void rpmb_dev_put(struct rpmb_dev
*rdev
);
67 struct rpmb_dev
*rpmb_dev_find_device(const void *data
,
68 const struct rpmb_dev
*start
,
69 int (*match
)(struct device
*dev
,
71 int rpmb_interface_register(struct class_interface
*intf
);
72 void rpmb_interface_unregister(struct class_interface
*intf
);
73 struct rpmb_dev
*rpmb_dev_register(struct device
*dev
,
74 struct rpmb_descr
*descr
);
75 int rpmb_dev_unregister(struct rpmb_dev
*rdev
);
77 int rpmb_route_frames(struct rpmb_dev
*rdev
, u8
*req
,
78 unsigned int req_len
, u8
*resp
, unsigned int resp_len
);
81 static inline struct rpmb_dev
*rpmb_dev_get(struct rpmb_dev
*rdev
)
86 static inline void rpmb_dev_put(struct rpmb_dev
*rdev
) { }
88 static inline struct rpmb_dev
*
89 rpmb_dev_find_device(const void *data
, const struct rpmb_dev
*start
,
90 int (*match
)(struct device
*dev
, const void *data
))
95 static inline int rpmb_interface_register(struct class_interface
*intf
)
100 static inline void rpmb_interface_unregister(struct class_interface
*intf
)
104 static inline struct rpmb_dev
*
105 rpmb_dev_register(struct device
*dev
, struct rpmb_descr
*descr
)
110 static inline int rpmb_dev_unregister(struct rpmb_dev
*dev
)
115 static inline int rpmb_route_frames(struct rpmb_dev
*rdev
, u8
*req
,
116 unsigned int req_len
, u8
*resp
,
117 unsigned int resp_len
)
121 #endif /* CONFIG_RPMB */
123 #endif /* __RPMB_H__ */