.. | .. |
---|
23 | 23 | #include <linux/soc/rockchip/rk_vendor_storage.h> |
---|
24 | 24 | #include <linux/kthread.h> |
---|
25 | 25 | #include <linux/delay.h> |
---|
| 26 | +#include <misc/rkflash_vendor_storage.h> |
---|
| 27 | +#include "../../mmc/host/rk_sdmmc_ops.h" |
---|
26 | 28 | |
---|
27 | 29 | #define EMMC_IDB_PART_OFFSET 64 |
---|
28 | 30 | #define EMMC_SYS_PART_OFFSET 8064 |
---|
29 | 31 | #define EMMC_BOOT_PART_SIZE 1024 |
---|
30 | 32 | #define EMMC_VENDOR_PART_START (1024 * 7) |
---|
31 | | -#define EMMC_VENDOR_PART_SIZE 128 |
---|
| 33 | +#define EMMC_VENDOR_PART_SIZE VENDOR_PART_SIZE |
---|
32 | 34 | #define EMMC_VENDOR_PART_NUM 4 |
---|
33 | | -#define EMMC_VENDOR_TAG 0x524B5644 |
---|
34 | | - |
---|
35 | | -struct rk_vendor_req { |
---|
36 | | - u32 tag; |
---|
37 | | - u16 id; |
---|
38 | | - u16 len; |
---|
39 | | - u8 data[1024]; |
---|
40 | | -}; |
---|
41 | | - |
---|
42 | | -struct vendor_item { |
---|
43 | | - u16 id; |
---|
44 | | - u16 offset; |
---|
45 | | - u16 size; |
---|
46 | | - u16 flag; |
---|
47 | | -}; |
---|
48 | | - |
---|
49 | | -struct vendor_info { |
---|
50 | | - u32 tag; |
---|
51 | | - u32 version; |
---|
52 | | - u16 next_index; |
---|
53 | | - u16 item_num; |
---|
54 | | - u16 free_offset; |
---|
55 | | - u16 free_size; |
---|
56 | | - struct vendor_item item[126]; /* 126 * 8*/ |
---|
57 | | - u8 data[EMMC_VENDOR_PART_SIZE * 512 - 1024 - 8]; |
---|
58 | | - u32 hash; |
---|
59 | | - u32 version2; |
---|
60 | | -}; |
---|
| 35 | +#define EMMC_VENDOR_TAG VENDOR_HEAD_TAG |
---|
61 | 36 | |
---|
62 | 37 | #ifdef CONFIG_ROCKCHIP_VENDOR_STORAGE_UPDATE_LOADER |
---|
63 | 38 | #define READ_SECTOR_IO _IOW('r', 0x04, unsigned int) |
---|
.. | .. |
---|
68 | 43 | #define GET_LOCK_FLAG_IO _IOW('r', 0x53, unsigned int) |
---|
69 | 44 | #endif |
---|
70 | 45 | |
---|
71 | | -#define VENDOR_REQ_TAG 0x56524551 |
---|
72 | | -#define VENDOR_READ_IO _IOW('v', 0x01, unsigned int) |
---|
73 | | -#define VENDOR_WRITE_IO _IOW('v', 0x02, unsigned int) |
---|
74 | | - |
---|
75 | 46 | static u8 *g_idb_buffer; |
---|
76 | 47 | static struct vendor_info *g_vendor; |
---|
77 | 48 | static DEFINE_MUTEX(vendor_ops_mutex); |
---|
78 | | -extern int rk_emmc_transfer(u8 *buffer, unsigned addr, unsigned blksz, |
---|
79 | | - int write); |
---|
80 | 49 | |
---|
81 | 50 | static int emmc_vendor_ops(u8 *buffer, u32 addr, u32 n_sec, int write) |
---|
82 | 51 | { |
---|
.. | .. |
---|
406 | 375 | { |
---|
407 | 376 | long ret = -1; |
---|
408 | 377 | int size; |
---|
409 | | - struct rk_vendor_req *v_req; |
---|
| 378 | + struct RK_VENDOR_REQ *v_req; |
---|
410 | 379 | u32 *page_buf; |
---|
411 | 380 | |
---|
412 | 381 | page_buf = kmalloc(4096, GFP_KERNEL); |
---|
.. | .. |
---|
415 | 384 | |
---|
416 | 385 | mutex_lock(&vendor_ops_mutex); |
---|
417 | 386 | |
---|
418 | | - v_req = (struct rk_vendor_req *)page_buf; |
---|
| 387 | + v_req = (struct RK_VENDOR_REQ *)page_buf; |
---|
419 | 388 | |
---|
420 | 389 | switch (cmd) { |
---|
421 | 390 | case VENDOR_READ_IO: |
---|
.. | .. |
---|
574 | 543 | return ret; |
---|
575 | 544 | } |
---|
576 | 545 | |
---|
577 | | -const struct file_operations vendor_storage_fops = { |
---|
| 546 | +static const struct file_operations vendor_storage_fops = { |
---|
578 | 547 | .open = vendor_storage_open, |
---|
579 | 548 | .compat_ioctl = vendor_storage_ioctl, |
---|
580 | 549 | .unlocked_ioctl = vendor_storage_ioctl, |
---|