xref: /OK3568_Linux_fs/u-boot/include/rockusb.h (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1 /*
2  * Copyright 2017 Rockchip Electronics Co., Ltd
3  * Frank Wang <frank.wang@rock-chips.com>
4  *
5  * SPDX-License-Identifier:	GPL-2.0+
6  */
7 
8 #ifndef __ROCKUSB_H__
9 #define __ROCKUSB_H__
10 
11 #include <common.h>
12 #include <part.h>
13 #include <linux/usb/composite.h>
14 
15 enum rkusb_cmd {
16 	RKUSB_TEST_UNIT_READY	= 0x00,
17 	RKUSB_READ_FLASH_ID	= 0x01,
18 	RKUSB_SET_DEVICE_ID	= 0x02,
19 	RKUSB_TEST_BAD_BLOCK	= 0x03,
20 	RKUSB_READ_10		= 0x04,
21 	RKUSB_WRITE_10		= 0x05,
22 	RKUSB_ERASE_10		= 0x06,
23 	RKUSB_WRITE_SPARE	= 0x07,
24 	RKUSB_READ_SPARE	= 0x08,
25 	RKUSB_ERASE_10_FORCE	= 0x0B,
26 	RKUSB_GET_VERSION	= 0x0C,
27 	RKUSB_LBA_READ_10	= 0x14,
28 	RKUSB_LBA_WRITE_10	= 0x15,
29 	RKUSB_ERASE_SYS_DISK	= 0x16,
30 	RKUSB_SDRAM_READ_10	= 0x17,
31 	RKUSB_SDRAM_WRITE_10	= 0x18,
32 	RKUSB_SDRAM_EXECUTE	= 0x19,
33 	RKUSB_READ_FLASH_INFO	= 0x1A,
34 	RKUSB_GET_CHIP_VER	= 0x1B,
35 	RKUSB_LOW_FORMAT	= 0x1C,
36 	RKUSB_SET_RESET_FLAG	= 0x1E,
37 	RKUSB_SPI_READ_10	= 0x21,
38 	RKUSB_SPI_WRITE_10	= 0x22,
39 	RKUSB_LBA_ERASE		= 0x25,
40 	RKUSB_VS_WRITE		= 0x26,
41 	RKUSB_VS_READ		= 0x27,
42 	RKUSB_GET_STORAGE_MEDIA = 0x2B,
43 	RKUSB_SESSION		= 0x30,
44 	RKUSB_READ_CAPACITY	= 0xAA,
45 	RKUSB_RESET		= 0xFF,
46 };
47 
48 enum rkusb_rc {
49 	RKUSB_RC_ERROR		= -1,
50 	RKUSB_RC_CONTINUE	= 0,
51 	RKUSB_RC_FINISHED	= 1,
52 	RKUSB_RC_UNKNOWN_CMND	= 2,
53 };
54 
55 struct fsg_common;
56 
57 #ifdef CONFIG_CMD_ROCKUSB
58 #define IS_RKUSB_UMS_DNL(name)	(!strncmp((name), "rkusb_ums_dnl", 13))
59 
60 int rkusb_do_check_parity(struct fsg_common *common);
61 #else
62 #define IS_RKUSB_UMS_DNL(name)	0
63 
64 struct fsg_buffhd;
65 struct fsg_dev;
66 struct fsg_common;
67 struct fsg_config;
68 
69 static struct usb_descriptor_header *rkusb_fs_function[];
70 static struct usb_descriptor_header *rkusb_hs_function[];
71 
rkusb_cmd_process(struct fsg_common * common,struct fsg_buffhd * bh,int * reply)72 static inline int rkusb_cmd_process(struct fsg_common *common,
73 				    struct fsg_buffhd *bh, int *reply)
74 {
75 	return -EPERM;
76 }
77 
rkusb_do_check_parity(struct fsg_common * common)78 static inline int rkusb_do_check_parity(struct fsg_common *common)
79 {
80 	return -EOPNOTSUPP;
81 }
82 #endif
83 
84 /* Wait at maximum 60 seconds for cable connection */
85 #define RKUSB_CABLE_READY_TIMEOUT	60
86 #define SECTOR_SIZE			0x200
87 
88 #define RKUSB_READ_LIMIT_ADDR	        (32 * 2048)	/* 32MB */
89 
90 struct rockusb {
91 	struct ums *ums;
92 	int ums_cnt;
93 };
94 
95 #endif /* __ROCKUSB_H__ */
96