1 /* SPDX-License-Identifier: GPL-2.0+ */
3 * Driver interface derived from:
4 * /include/sandbox_host.h
5 * Copyright 2022 Google LLC
16 #define LBA 64 + 512 + 33
18 #define RK_TAG 0xFCDC8C3B
19 #define NFC_SYS_DATA_SIZE 4
21 #define STEP_SIZE 1024
22 #define BUF_SIZE 512 * 512
24 struct nand_para_info {
55 struct blk_desc *desc;
64 char uuid_part_str[UUID_STR_LEN + 1];
65 char uuid_disk_str[UUID_STR_LEN + 1];
69 struct nand_para_info *info;
71 u32 idb_need_write_back;
72 struct bootblk idblock[5];
84 u16 boot_code1_offset;
85 u16 boot_code2_offset;
93 * rkmtd_rc4() - Rockchip specific RC4 Encryption Algorithm
95 * Encrypt Rockchip boot block header version 1 and data
97 * @buf: Pointer to data buffer
98 * @len: Data buffer size
100 void rkmtd_rc4(u8 *buf, u32 len);
103 * struct rkmtd_ops - operations supported by UCLASS_RKMTD
107 * @attach_mtd: - Attach a new rkmtd driver to the device structure
109 * @attach_mtd.dev: Device to update
110 * @attach_mtd.Returns: 0 if OK, -EEXIST if a driver is already attached,
111 * other -ve on other error
113 int (*attach_mtd)(struct udevice *dev);
116 * @detach_mtd: - Detach a rkmtd driver from the device structure
118 * @detach_mtd.dev: Device to detach from
119 * @detach_mtd.Returns: 0 if OK, -ENOENT if no driver is attached,
120 * other -ve on other error
122 int (*detach_mtd)(struct udevice *dev);
125 #define rkmtd_get_ops(dev) ((struct rkmtd_ops *)(dev)->driver->ops)
128 * rkmtd_get_cur_dev() - Get the current device
130 * Returns current device, or NULL if none
132 struct udevice *rkmtd_get_cur_dev(void);
135 * rkmtd_set_cur_dev() - Set the current device
137 * Sets the current device, or clears it if @dev is NULL
139 * @dev: Device to set as the current one
141 void rkmtd_set_cur_dev(struct udevice *dev);
144 * rkmtd_find_by_label() - Find a rkmtd device by label
146 * Searches all rkmtd devices to find one with the given label
148 * @label: Label to find
149 * Returns: associated device, or NULL if not found
151 struct udevice *rkmtd_find_by_label(const char *label);
154 * rkmtd_attach() - Attach a new rkmtd driver to the device structure
156 * @dev: Device to update
157 * Returns: 0 if OK, -EEXIST if a file is already attached, other -ve on
160 int rkmtd_attach(struct udevice *dev);
163 * rkmtd_detach() - Detach a rkmtd driver from the device structure
165 * @dev: Device to detach from
166 * Returns: 0 if OK, -ENOENT if no file is attached, other -ve on other
169 int rkmtd_detach(struct udevice *dev);
172 * rkmtd_create_device() - Create a new rkmtd device
174 * Any existing device with the same label is removed and unbound first
176 * @label: Label of the attachment, e.g. "test1"
177 * @devp: Returns the device created, on success
178 * Returns: 0 if OK, -ve on error
180 int rkmtd_create_device(const char *label, struct udevice **devp);
183 * rkmtd_create_attach_mtd() - Create a new rkmtd device and attach driver
185 * @label: Label of the attachment, e.g. "test1"
186 * @devp: Returns the device created, on success
187 * Returns: 0 if OK, -ve on error
189 int rkmtd_create_attach_mtd(const char *label, struct udevice **devp);
191 #endif /* __RKMTD__ */