1
2
3
4
5#ifndef __LINUX_MTD_PFOW_H
6#define __LINUX_MTD_PFOW_H
7
8#include <linux/mtd/qinfo.h>
9
10
11
12#define PFOW_QUERY_STRING_P 0x0000
13
14#define PFOW_QUERY_STRING_F 0x0002
15
16#define PFOW_QUERY_STRING_O 0x0004
17
18#define PFOW_QUERY_STRING_W 0x0006
19
20#define PFOW_MANUFACTURER_ID 0x0020
21#define PFOW_DEVICE_ID 0x0022
22
23#define PFOW_PROGRAM_BUFFER_OFFSET 0x0040
24
25#define PFOW_PROGRAM_BUFFER_SIZE 0x0042
26
27#define PFOW_COMMAND_CODE 0x0080
28
29#define PFOW_COMMAND_DATA 0x0084
30
31#define PFOW_COMMAND_ADDRESS_L 0x0088
32
33#define PFOW_COMMAND_ADDRESS_H 0x008a
34
35#define PFOW_DATA_COUNT_L 0x0090
36
37#define PFOW_DATA_COUNT_H 0x0092
38
39#define PFOW_COMMAND_EXECUTE 0x00c0
40
41#define PFOW_CLEAR_PROGRAM_BUFFER 0x00c4
42
43#define PFOW_PROGRAM_ERASE_SUSPEND 0x00c8
44
45#define PFOW_DSR 0x00cc
46
47
48
49#define LPDDR_WORD_PROGRAM 0x0041
50#define LPDDR_BUFF_PROGRAM 0x00E9
51#define LPDDR_BLOCK_ERASE 0x0020
52#define LPDDR_LOCK_BLOCK 0x0061
53#define LPDDR_UNLOCK_BLOCK 0x0062
54#define LPDDR_READ_BLOCK_LOCK_STATUS 0x0065
55#define LPDDR_INFO_QUERY 0x0098
56#define LPDDR_READ_OTP 0x0097
57#define LPDDR_PROG_OTP 0x00C0
58#define LPDDR_RESUME 0x00D0
59
60
61#define LPDDR_START_EXECUTION 0x0001
62
63
64#define LPDDR_SUSPEND 0x0001
65
66
67
68#define DSR_DPS (1<<1)
69
70#define DSR_PSS (1<<2)
71
72
73#define DSR_VPPS (1<<3)
74#define DSR_PROGRAM_STATUS (1<<4)
75#define DSR_ERASE_STATUS (1<<5)
76
77
78#define DSR_ESS (1<<6)
79
80
81#define DSR_READY_STATUS (1<<7)
82
83
84#define DSR_RPS (0x3<<8)
85
86
87
88
89
90
91
92#define DSR_AOS (1<<12)
93#define DSR_AVAILABLE (1<<15)
94
95
96
97
98#define DSR_ERR 0x133A
99
100static inline void send_pfow_command(struct map_info *map,
101 unsigned long cmd_code, unsigned long adr,
102 unsigned long len, map_word *datum)
103{
104 int bits_per_chip = map_bankwidth(map) * 8;
105
106 map_write(map, CMD(cmd_code), map->pfow_base + PFOW_COMMAND_CODE);
107 map_write(map, CMD(adr & ((1<<bits_per_chip) - 1)),
108 map->pfow_base + PFOW_COMMAND_ADDRESS_L);
109 map_write(map, CMD(adr>>bits_per_chip),
110 map->pfow_base + PFOW_COMMAND_ADDRESS_H);
111 if (len) {
112 map_write(map, CMD(len & ((1<<bits_per_chip) - 1)),
113 map->pfow_base + PFOW_DATA_COUNT_L);
114 map_write(map, CMD(len>>bits_per_chip),
115 map->pfow_base + PFOW_DATA_COUNT_H);
116 }
117 if (datum)
118 map_write(map, *datum, map->pfow_base + PFOW_COMMAND_DATA);
119
120
121 map_write(map, CMD(LPDDR_START_EXECUTION),
122 map->pfow_base + PFOW_COMMAND_EXECUTE);
123}
124
125static inline void print_drs_error(unsigned dsr)
126{
127 int prog_status = (dsr & DSR_RPS) >> 8;
128
129 if (!(dsr & DSR_AVAILABLE))
130 printk(KERN_NOTICE"DSR.15: (0) Device not Available\n");
131 if (prog_status & 0x03)
132 printk(KERN_NOTICE"DSR.9,8: (11) Attempt to program invalid "
133 "half with 41h command\n");
134 else if (prog_status & 0x02)
135 printk(KERN_NOTICE"DSR.9,8: (10) Object Mode Program attempt "
136 "in region with Control Mode data\n");
137 else if (prog_status & 0x01)
138 printk(KERN_NOTICE"DSR.9,8: (01) Program attempt in region "
139 "with Object Mode data\n");
140 if (!(dsr & DSR_READY_STATUS))
141 printk(KERN_NOTICE"DSR.7: (0) Device is Busy\n");
142 if (dsr & DSR_ESS)
143 printk(KERN_NOTICE"DSR.6: (1) Erase Suspended\n");
144 if (dsr & DSR_ERASE_STATUS)
145 printk(KERN_NOTICE"DSR.5: (1) Erase/Blank check error\n");
146 if (dsr & DSR_PROGRAM_STATUS)
147 printk(KERN_NOTICE"DSR.4: (1) Program Error\n");
148 if (dsr & DSR_VPPS)
149 printk(KERN_NOTICE"DSR.3: (1) Vpp low detect, operation "
150 "aborted\n");
151 if (dsr & DSR_PSS)
152 printk(KERN_NOTICE"DSR.2: (1) Program suspended\n");
153 if (dsr & DSR_DPS)
154 printk(KERN_NOTICE"DSR.1: (1) Aborted Erase/Program attempt "
155 "on locked block\n");
156}
157#endif
158