.. | .. |
---|
16 | 16 | #include <linux/soc/rockchip/rk_vendor_storage.h> |
---|
17 | 17 | #include <linux/uaccess.h> |
---|
18 | 18 | #include <linux/vmalloc.h> |
---|
| 19 | +#include <misc/rkflash_vendor_storage.h> |
---|
19 | 20 | |
---|
20 | 21 | #define MTD_VENDOR_PART_START 0 |
---|
21 | | -#define MTD_VENDOR_PART_SIZE 8 |
---|
| 22 | +#define MTD_VENDOR_PART_SIZE FLASH_VENDOR_PART_SIZE |
---|
22 | 23 | #define MTD_VENDOR_PART_NUM 1 |
---|
23 | | -#define MTD_VENDOR_TAG 0x524B5644 |
---|
24 | | - |
---|
25 | | -struct rk_vendor_req { |
---|
26 | | - u32 tag; |
---|
27 | | - u16 id; |
---|
28 | | - u16 len; |
---|
29 | | - u8 data[1024]; |
---|
30 | | -}; |
---|
31 | | - |
---|
32 | | -struct vendor_item { |
---|
33 | | - u16 id; |
---|
34 | | - u16 offset; |
---|
35 | | - u16 size; |
---|
36 | | - u16 flag; |
---|
37 | | -}; |
---|
38 | | - |
---|
39 | | -struct vendor_info { |
---|
40 | | - u32 tag; |
---|
41 | | - u32 version; |
---|
42 | | - u16 next_index; |
---|
43 | | - u16 item_num; |
---|
44 | | - u16 free_offset; |
---|
45 | | - u16 free_size; |
---|
46 | | - struct vendor_item item[62]; |
---|
47 | | - u8 data[MTD_VENDOR_PART_SIZE * 512 - 512 - 8]; |
---|
48 | | - u32 hash; |
---|
49 | | - u32 version2; |
---|
50 | | -}; |
---|
| 24 | +#define MTD_VENDOR_TAG VENDOR_HEAD_TAG |
---|
51 | 25 | |
---|
52 | 26 | struct mtd_nand_info { |
---|
53 | 27 | u32 blk_offset; |
---|
.. | .. |
---|
65 | 39 | #define GET_LOCK_FLAG_IO _IOW('r', 0x53, unsigned int) |
---|
66 | 40 | #endif |
---|
67 | 41 | |
---|
68 | | -#define VENDOR_REQ_TAG 0x56524551 |
---|
69 | | -#define VENDOR_READ_IO _IOW('v', 0x01, unsigned int) |
---|
70 | | -#define VENDOR_WRITE_IO _IOW('v', 0x02, unsigned int) |
---|
71 | | - |
---|
72 | 42 | static u8 *g_idb_buffer; |
---|
73 | | -static struct vendor_info *g_vendor; |
---|
| 43 | +static struct flash_vendor_info *g_vendor; |
---|
74 | 44 | static DEFINE_MUTEX(vendor_ops_mutex); |
---|
75 | 45 | static struct mtd_info *mtd; |
---|
76 | 46 | static const char *vendor_mtd_name = "vnvm"; |
---|
77 | 47 | static struct mtd_nand_info nand_info; |
---|
| 48 | +static struct platform_device *g_pdev; |
---|
78 | 49 | |
---|
79 | 50 | static int mtd_vendor_nand_write(void) |
---|
80 | 51 | { |
---|
.. | .. |
---|
305 | 276 | { |
---|
306 | 277 | long ret = -1; |
---|
307 | 278 | int size; |
---|
308 | | - struct rk_vendor_req *v_req; |
---|
| 279 | + struct RK_VENDOR_REQ *v_req; |
---|
309 | 280 | u32 *page_buf; |
---|
310 | 281 | |
---|
311 | 282 | page_buf = kmalloc(4096, GFP_KERNEL); |
---|
.. | .. |
---|
314 | 285 | |
---|
315 | 286 | mutex_lock(&vendor_ops_mutex); |
---|
316 | 287 | |
---|
317 | | - v_req = (struct rk_vendor_req *)page_buf; |
---|
| 288 | + v_req = (struct RK_VENDOR_REQ *)page_buf; |
---|
318 | 289 | |
---|
319 | 290 | switch (cmd) { |
---|
320 | 291 | case VENDOR_READ_IO: |
---|
.. | .. |
---|
436 | 407 | |
---|
437 | 408 | g_idb_buffer = NULL; |
---|
438 | 409 | ret = platform_driver_register(&vendor_storage_driver); |
---|
| 410 | + if (ret) |
---|
| 411 | + return ret; |
---|
439 | 412 | |
---|
440 | 413 | pdev = platform_device_register_simple("mtd_vendor_storage", |
---|
441 | 414 | -1, NULL, 0); |
---|
.. | .. |
---|
443 | 416 | platform_driver_unregister(&vendor_storage_driver); |
---|
444 | 417 | return PTR_ERR(pdev); |
---|
445 | 418 | } |
---|
| 419 | + g_pdev = pdev; |
---|
446 | 420 | |
---|
447 | 421 | return ret; |
---|
448 | 422 | } |
---|
449 | 423 | |
---|
| 424 | +static __exit void vendor_storage_deinit(void) |
---|
| 425 | +{ |
---|
| 426 | + platform_device_unregister(g_pdev); |
---|
| 427 | + platform_driver_unregister(&vendor_storage_driver); |
---|
| 428 | +} |
---|
| 429 | + |
---|
450 | 430 | device_initcall_sync(vendor_storage_init); |
---|
| 431 | +module_exit(vendor_storage_deinit); |
---|
| 432 | +MODULE_LICENSE("GPL"); |
---|