hc
2024-03-26 e9199a72d842cbda78ac614eee5db7cdaa6f2530
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
/* SPDX-License-Identifier: GPL-2.0 */
 
/* Copyright (c) 2018 Rockchip Electronics Co. Ltd. */
 
#ifndef __RKFLASH_BLK_H
#define __RKFLASH_BLK_H
 
#include <linux/semaphore.h>
#include "rkflash_api.h"
 
/* RKFLASH Dev Patition Max Count */
#define MAX_PART_COUNT 32
#define RK_PARTITION_TAG    0x50464B52
 
struct flash_part {
   unsigned char name[32];
   unsigned int offset;
   unsigned int size;
   unsigned char type;
};
 
struct flash_blk_ops {
   char *name;
   int major;
   int minorbits;
   int last_dev_index;
   struct request_queue *rq;
   spinlock_t queue_lock; /* queue lock */
 
   /* block-mq */
   struct list_head rq_list;
   struct blk_mq_tag_set *tag_set;
 
   struct list_head devs;
   struct module *owner;
};
 
struct flash_blk_dev {
   struct flash_blk_ops *blk_ops;
   struct list_head list;
   int devnum;
   unsigned int size;
   unsigned int off_size;
   int readonly;
   int writeonly;
   int disable_access;
   void *blkcore_priv;
};
 
enum ENUM_PARTITION_TYPE {
   PART_VENDOR = 1 << 0,
   PART_IDBLOCK = 1 << 1,
   PART_KERNEL = 1 << 2,
   PART_BOOT = 1 << 3,
   PART_USER = 1 << 31
};
 
struct STRUCT_DATETIME {
   unsigned short    year;
   unsigned char    month;
   unsigned char    day;
   unsigned char    hour;
   unsigned char    min;
   unsigned char    sec;
   unsigned char    reserve;
};
 
struct STRUCT_FW_HEADER {
   unsigned int    ui_fw_tag;    /* "RKFP" */
   struct STRUCT_DATETIME    dt_release_data_time;
   unsigned int    ui_fw_ver;
   unsigned int    ui_size;    /* size of sturct,unit of u8 */
   unsigned int    ui_part_entry_offset;    /* unit of sector */
   unsigned int    ui_backup_part_entry_offset;
   unsigned int    ui_part_entry_size;    /* unit of u8 */
   unsigned int    ui_part_entry_count;
   unsigned int    ui_fw_size;    /* unit of u8 */
   unsigned char    reserved[464];
   unsigned int    ui_part_entry_crc;
   unsigned int    ui_header_crc;
};
 
struct STRUCT_PART_ENTRY {
   unsigned char    sz_name[32];
   enum ENUM_PARTITION_TYPE em_part_type;
   unsigned int    ui_pt_off;    /* unit of sector */
   unsigned int    ui_pt_sz;    /* unit of sector */
   unsigned int    ui_data_length;    /* unit of u8 */
   unsigned int    ui_part_property;
   unsigned char    reserved[76];
};
 
struct STRUCT_PART_INFO {
   struct STRUCT_FW_HEADER hdr;    /* 0.5KB */
   struct STRUCT_PART_ENTRY part[12];    /* 1.5KB */
} __packed;
 
/* Including Dev APIs */
#ifdef CONFIG_RK_SFC_NAND_MTD
int sfc_nand_mtd_init(struct SFNAND_DEV *p_dev, struct mutex *lock);
#endif
#ifdef CONFIG_RK_SFC_NOR_MTD
int sfc_nor_mtd_init(struct SFNOR_DEV *p_dev, struct mutex *lock);
#endif
 
int rkflash_dev_suspend(void);
int rkflash_dev_resume(void __iomem *reg_addr);
void rkflash_dev_shutdown(void);
void rkflash_dev_flush(void);
int rkflash_dev_init(void __iomem *reg_addr,
            enum flash_type type,
            const struct flash_boot_ops *ops);
int rkflash_dev_exit(void);
int rkflash_vendor_read(u32 sec, u32 n_sec, void *p_data);
int rkflash_vendor_write(u32 sec, u32 n_sec, void *p_data);
 
#endif