7d66b900c8f92d93f9e3c92530c885cb87acc7c5
[oweals/u-boot.git] / drivers / spi / ich.c
1 // SPDX-License-Identifier: GPL-2.0+
2 /*
3  * Copyright (c) 2011-12 The Chromium OS Authors.
4  *
5  * This file is derived from the flashrom project.
6  */
7
8 #define LOG_CATEGORY    UCLASS_SPI
9
10 #include <common.h>
11 #include <div64.h>
12 #include <dm.h>
13 #include <dt-structs.h>
14 #include <errno.h>
15 #include <malloc.h>
16 #include <pch.h>
17 #include <pci.h>
18 #include <pci_ids.h>
19 #include <spi.h>
20 #include <spi-mem.h>
21 #include <asm/io.h>
22
23 #include "ich.h"
24
25 #ifdef DEBUG_TRACE
26 #define debug_trace(fmt, args...) debug(fmt, ##args)
27 #else
28 #define debug_trace(x, args...)
29 #endif
30
31 struct ich_spi_platdata {
32 #if CONFIG_IS_ENABLED(OF_PLATDATA)
33         struct dtd_intel_fast_spi dtplat;
34 #endif
35         enum ich_version ich_version;   /* Controller version, 7 or 9 */
36         bool lockdown;                  /* lock down controller settings? */
37         ulong mmio_base;                /* Base of MMIO registers */
38         pci_dev_t bdf;                  /* PCI address used by of-platdata */
39 };
40
41 static u8 ich_readb(struct ich_spi_priv *priv, int reg)
42 {
43         u8 value = readb(priv->base + reg);
44
45         debug_trace("read %2.2x from %4.4x\n", value, reg);
46
47         return value;
48 }
49
50 static u16 ich_readw(struct ich_spi_priv *priv, int reg)
51 {
52         u16 value = readw(priv->base + reg);
53
54         debug_trace("read %4.4x from %4.4x\n", value, reg);
55
56         return value;
57 }
58
59 static u32 ich_readl(struct ich_spi_priv *priv, int reg)
60 {
61         u32 value = readl(priv->base + reg);
62
63         debug_trace("read %8.8x from %4.4x\n", value, reg);
64
65         return value;
66 }
67
68 static void ich_writeb(struct ich_spi_priv *priv, u8 value, int reg)
69 {
70         writeb(value, priv->base + reg);
71         debug_trace("wrote %2.2x to %4.4x\n", value, reg);
72 }
73
74 static void ich_writew(struct ich_spi_priv *priv, u16 value, int reg)
75 {
76         writew(value, priv->base + reg);
77         debug_trace("wrote %4.4x to %4.4x\n", value, reg);
78 }
79
80 static void ich_writel(struct ich_spi_priv *priv, u32 value, int reg)
81 {
82         writel(value, priv->base + reg);
83         debug_trace("wrote %8.8x to %4.4x\n", value, reg);
84 }
85
86 static void write_reg(struct ich_spi_priv *priv, const void *value,
87                       int dest_reg, uint32_t size)
88 {
89         memcpy_toio(priv->base + dest_reg, value, size);
90 }
91
92 static void read_reg(struct ich_spi_priv *priv, int src_reg, void *value,
93                      uint32_t size)
94 {
95         memcpy_fromio(value, priv->base + src_reg, size);
96 }
97
98 static void ich_set_bbar(struct ich_spi_priv *ctlr, uint32_t minaddr)
99 {
100         const uint32_t bbar_mask = 0x00ffff00;
101         uint32_t ichspi_bbar;
102
103         minaddr &= bbar_mask;
104         ichspi_bbar = ich_readl(ctlr, ctlr->bbar) & ~bbar_mask;
105         ichspi_bbar |= minaddr;
106         ich_writel(ctlr, ichspi_bbar, ctlr->bbar);
107 }
108
109 /* @return 1 if the SPI flash supports the 33MHz speed */
110 static bool ich9_can_do_33mhz(struct udevice *dev)
111 {
112         struct ich_spi_priv *priv = dev_get_priv(dev);
113         u32 fdod, speed;
114
115         /* Observe SPI Descriptor Component Section 0 */
116         dm_pci_write_config32(priv->pch, 0xb0, 0x1000);
117
118         /* Extract the Write/Erase SPI Frequency from descriptor */
119         dm_pci_read_config32(priv->pch, 0xb4, &fdod);
120
121         /* Bits 23:21 have the fast read clock frequency, 0=20MHz, 1=33MHz */
122         speed = (fdod >> 21) & 7;
123
124         return speed == 1;
125 }
126
127 static void spi_lock_down(struct ich_spi_platdata *plat, void *sbase)
128 {
129         if (plat->ich_version == ICHV_7) {
130                 struct ich7_spi_regs *ich7_spi = sbase;
131
132                 setbits_le16(&ich7_spi->spis, SPIS_LOCK);
133         } else if (plat->ich_version == ICHV_9) {
134                 struct ich9_spi_regs *ich9_spi = sbase;
135
136                 setbits_le16(&ich9_spi->hsfs, HSFS_FLOCKDN);
137         }
138 }
139
140 static bool spi_lock_status(struct ich_spi_platdata *plat, void *sbase)
141 {
142         int lock = 0;
143
144         if (plat->ich_version == ICHV_7) {
145                 struct ich7_spi_regs *ich7_spi = sbase;
146
147                 lock = readw(&ich7_spi->spis) & SPIS_LOCK;
148         } else if (plat->ich_version == ICHV_9) {
149                 struct ich9_spi_regs *ich9_spi = sbase;
150
151                 lock = readw(&ich9_spi->hsfs) & HSFS_FLOCKDN;
152         }
153
154         return lock != 0;
155 }
156
157 static int spi_setup_opcode(struct ich_spi_priv *ctlr, struct spi_trans *trans,
158                             bool lock)
159 {
160         uint16_t optypes;
161         uint8_t opmenu[ctlr->menubytes];
162
163         if (!lock) {
164                 /* The lock is off, so just use index 0. */
165                 ich_writeb(ctlr, trans->opcode, ctlr->opmenu);
166                 optypes = ich_readw(ctlr, ctlr->optype);
167                 optypes = (optypes & 0xfffc) | (trans->type & 0x3);
168                 ich_writew(ctlr, optypes, ctlr->optype);
169                 return 0;
170         } else {
171                 /* The lock is on. See if what we need is on the menu. */
172                 uint8_t optype;
173                 uint16_t opcode_index;
174
175                 /* Write Enable is handled as atomic prefix */
176                 if (trans->opcode == SPI_OPCODE_WREN)
177                         return 0;
178
179                 read_reg(ctlr, ctlr->opmenu, opmenu, sizeof(opmenu));
180                 for (opcode_index = 0; opcode_index < ctlr->menubytes;
181                                 opcode_index++) {
182                         if (opmenu[opcode_index] == trans->opcode)
183                                 break;
184                 }
185
186                 if (opcode_index == ctlr->menubytes) {
187                         debug("ICH SPI: Opcode %x not found\n", trans->opcode);
188                         return -EINVAL;
189                 }
190
191                 optypes = ich_readw(ctlr, ctlr->optype);
192                 optype = (optypes >> (opcode_index * 2)) & 0x3;
193
194                 if (optype != trans->type) {
195                         debug("ICH SPI: Transaction doesn't fit type %d\n",
196                               optype);
197                         return -ENOSPC;
198                 }
199                 return opcode_index;
200         }
201 }
202
203 /*
204  * Wait for up to 6s til status register bit(s) turn 1 (in case wait_til_set
205  * below is true) or 0. In case the wait was for the bit(s) to set - write
206  * those bits back, which would cause resetting them.
207  *
208  * Return the last read status value on success or -1 on failure.
209  */
210 static int ich_status_poll(struct ich_spi_priv *ctlr, u16 bitmask,
211                            int wait_til_set)
212 {
213         int timeout = 600000; /* This will result in 6s */
214         u16 status = 0;
215
216         while (timeout--) {
217                 status = ich_readw(ctlr, ctlr->status);
218                 if (wait_til_set ^ ((status & bitmask) == 0)) {
219                         if (wait_til_set) {
220                                 ich_writew(ctlr, status & bitmask,
221                                            ctlr->status);
222                         }
223                         return status;
224                 }
225                 udelay(10);
226         }
227         debug("ICH SPI: SCIP timeout, read %x, expected %x, wts %x %x\n",
228               status, bitmask, wait_til_set, status & bitmask);
229
230         return -ETIMEDOUT;
231 }
232
233 static void ich_spi_config_opcode(struct udevice *dev)
234 {
235         struct ich_spi_priv *ctlr = dev_get_priv(dev);
236
237         /*
238          * PREOP, OPTYPE, OPMENU1/OPMENU2 registers can be locked down
239          * to prevent accidental or intentional writes. Before they get
240          * locked down, these registers should be initialized properly.
241          */
242         ich_writew(ctlr, SPI_OPPREFIX, ctlr->preop);
243         ich_writew(ctlr, SPI_OPTYPE, ctlr->optype);
244         ich_writel(ctlr, SPI_OPMENU_LOWER, ctlr->opmenu);
245         ich_writel(ctlr, SPI_OPMENU_UPPER, ctlr->opmenu + sizeof(u32));
246 }
247
248 static int ich_spi_exec_op(struct spi_slave *slave, const struct spi_mem_op *op)
249 {
250         struct udevice *bus = dev_get_parent(slave->dev);
251         struct ich_spi_platdata *plat = dev_get_platdata(bus);
252         struct ich_spi_priv *ctlr = dev_get_priv(bus);
253         uint16_t control;
254         int16_t opcode_index;
255         int with_address;
256         int status;
257         struct spi_trans *trans = &ctlr->trans;
258         bool lock = spi_lock_status(plat, ctlr->base);
259         int ret = 0;
260
261         trans->in = NULL;
262         trans->out = NULL;
263         trans->type = 0xFF;
264
265         if (op->data.nbytes) {
266                 if (op->data.dir == SPI_MEM_DATA_IN) {
267                         trans->in = op->data.buf.in;
268                         trans->bytesin = op->data.nbytes;
269                 } else {
270                         trans->out = op->data.buf.out;
271                         trans->bytesout = op->data.nbytes;
272                 }
273         }
274
275         if (trans->opcode != op->cmd.opcode)
276                 trans->opcode = op->cmd.opcode;
277
278         if (lock && trans->opcode == SPI_OPCODE_WRDIS)
279                 return 0;
280
281         if (trans->opcode == SPI_OPCODE_WREN) {
282                 /*
283                  * Treat Write Enable as Atomic Pre-Op if possible
284                  * in order to prevent the Management Engine from
285                  * issuing a transaction between WREN and DATA.
286                  */
287                 if (!lock)
288                         ich_writew(ctlr, trans->opcode, ctlr->preop);
289                 return 0;
290         }
291
292         ret = ich_status_poll(ctlr, SPIS_SCIP, 0);
293         if (ret < 0)
294                 return ret;
295
296         if (plat->ich_version == ICHV_7)
297                 ich_writew(ctlr, SPIS_CDS | SPIS_FCERR, ctlr->status);
298         else
299                 ich_writeb(ctlr, SPIS_CDS | SPIS_FCERR, ctlr->status);
300
301         /* Try to guess spi transaction type */
302         if (op->data.dir == SPI_MEM_DATA_OUT) {
303                 if (op->addr.nbytes)
304                         trans->type = SPI_OPCODE_TYPE_WRITE_WITH_ADDRESS;
305                 else
306                         trans->type = SPI_OPCODE_TYPE_WRITE_NO_ADDRESS;
307         } else {
308                 if (op->addr.nbytes)
309                         trans->type = SPI_OPCODE_TYPE_READ_WITH_ADDRESS;
310                 else
311                         trans->type = SPI_OPCODE_TYPE_READ_NO_ADDRESS;
312         }
313         /* Special erase case handling */
314         if (op->addr.nbytes && !op->data.buswidth)
315                 trans->type = SPI_OPCODE_TYPE_WRITE_WITH_ADDRESS;
316
317         opcode_index = spi_setup_opcode(ctlr, trans, lock);
318         if (opcode_index < 0)
319                 return -EINVAL;
320
321         if (op->addr.nbytes) {
322                 trans->offset = op->addr.val;
323                 with_address = 1;
324         }
325
326         if (ctlr->speed && ctlr->max_speed >= 33000000) {
327                 int byte;
328
329                 byte = ich_readb(ctlr, ctlr->speed);
330                 if (ctlr->cur_speed >= 33000000)
331                         byte |= SSFC_SCF_33MHZ;
332                 else
333                         byte &= ~SSFC_SCF_33MHZ;
334                 ich_writeb(ctlr, byte, ctlr->speed);
335         }
336
337         /* Preset control fields */
338         control = SPIC_SCGO | ((opcode_index & 0x07) << 4);
339
340         /* Issue atomic preop cycle if needed */
341         if (ich_readw(ctlr, ctlr->preop))
342                 control |= SPIC_ACS;
343
344         if (!trans->bytesout && !trans->bytesin) {
345                 /* SPI addresses are 24 bit only */
346                 if (with_address) {
347                         ich_writel(ctlr, trans->offset & 0x00FFFFFF,
348                                    ctlr->addr);
349                 }
350                 /*
351                  * This is a 'no data' command (like Write Enable), its
352                  * bitesout size was 1, decremented to zero while executing
353                  * spi_setup_opcode() above. Tell the chip to send the
354                  * command.
355                  */
356                 ich_writew(ctlr, control, ctlr->control);
357
358                 /* wait for the result */
359                 status = ich_status_poll(ctlr, SPIS_CDS | SPIS_FCERR, 1);
360                 if (status < 0)
361                         return status;
362
363                 if (status & SPIS_FCERR) {
364                         debug("ICH SPI: Command transaction error\n");
365                         return -EIO;
366                 }
367
368                 return 0;
369         }
370
371         while (trans->bytesout || trans->bytesin) {
372                 uint32_t data_length;
373
374                 /* SPI addresses are 24 bit only */
375                 ich_writel(ctlr, trans->offset & 0x00FFFFFF, ctlr->addr);
376
377                 if (trans->bytesout)
378                         data_length = min(trans->bytesout, ctlr->databytes);
379                 else
380                         data_length = min(trans->bytesin, ctlr->databytes);
381
382                 /* Program data into FDATA0 to N */
383                 if (trans->bytesout) {
384                         write_reg(ctlr, trans->out, ctlr->data, data_length);
385                         trans->bytesout -= data_length;
386                 }
387
388                 /* Add proper control fields' values */
389                 control &= ~((ctlr->databytes - 1) << 8);
390                 control |= SPIC_DS;
391                 control |= (data_length - 1) << 8;
392
393                 /* write it */
394                 ich_writew(ctlr, control, ctlr->control);
395
396                 /* Wait for Cycle Done Status or Flash Cycle Error */
397                 status = ich_status_poll(ctlr, SPIS_CDS | SPIS_FCERR, 1);
398                 if (status < 0)
399                         return status;
400
401                 if (status & SPIS_FCERR) {
402                         debug("ICH SPI: Data transaction error %x\n", status);
403                         return -EIO;
404                 }
405
406                 if (trans->bytesin) {
407                         read_reg(ctlr, ctlr->data, trans->in, data_length);
408                         trans->bytesin -= data_length;
409                 }
410         }
411
412         /* Clear atomic preop now that xfer is done */
413         if (!lock)
414                 ich_writew(ctlr, 0, ctlr->preop);
415
416         return 0;
417 }
418
419 static int ich_spi_adjust_size(struct spi_slave *slave, struct spi_mem_op *op)
420 {
421         unsigned int page_offset;
422         int addr = op->addr.val;
423         unsigned int byte_count = op->data.nbytes;
424
425         if (hweight32(ICH_BOUNDARY) == 1) {
426                 page_offset = addr & (ICH_BOUNDARY - 1);
427         } else {
428                 u64 aux = addr;
429
430                 page_offset = do_div(aux, ICH_BOUNDARY);
431         }
432
433         if (op->data.dir == SPI_MEM_DATA_IN) {
434                 if (slave->max_read_size) {
435                         op->data.nbytes = min(ICH_BOUNDARY - page_offset,
436                                               slave->max_read_size);
437                 }
438         } else if (slave->max_write_size) {
439                 op->data.nbytes = min(ICH_BOUNDARY - page_offset,
440                                       slave->max_write_size);
441         }
442
443         op->data.nbytes = min(op->data.nbytes, byte_count);
444
445         return 0;
446 }
447
448 static int ich_protect_lockdown(struct udevice *dev)
449 {
450         struct ich_spi_platdata *plat = dev_get_platdata(dev);
451         struct ich_spi_priv *priv = dev_get_priv(dev);
452         int ret = -ENOSYS;
453
454         /* Disable the BIOS write protect so write commands are allowed */
455         if (priv->pch)
456                 ret = pch_set_spi_protect(priv->pch, false);
457         if (ret == -ENOSYS) {
458                 u8 bios_cntl;
459
460                 bios_cntl = ich_readb(priv, priv->bcr);
461                 bios_cntl &= ~BIT(5);   /* clear Enable InSMM_STS (EISS) */
462                 bios_cntl |= 1;         /* Write Protect Disable (WPD) */
463                 ich_writeb(priv, bios_cntl, priv->bcr);
464         } else if (ret) {
465                 debug("%s: Failed to disable write-protect: err=%d\n",
466                       __func__, ret);
467                 return ret;
468         }
469
470         /* Lock down SPI controller settings if required */
471         if (plat->lockdown) {
472                 ich_spi_config_opcode(dev);
473                 spi_lock_down(plat, priv->base);
474         }
475
476         return 0;
477 }
478
479 static int ich_init_controller(struct udevice *dev,
480                                struct ich_spi_platdata *plat,
481                                struct ich_spi_priv *ctlr)
482 {
483         ctlr->base = (void *)plat->mmio_base;
484         if (plat->ich_version == ICHV_7) {
485                 struct ich7_spi_regs *ich7_spi = ctlr->base;
486
487                 ctlr->opmenu = offsetof(struct ich7_spi_regs, opmenu);
488                 ctlr->menubytes = sizeof(ich7_spi->opmenu);
489                 ctlr->optype = offsetof(struct ich7_spi_regs, optype);
490                 ctlr->addr = offsetof(struct ich7_spi_regs, spia);
491                 ctlr->data = offsetof(struct ich7_spi_regs, spid);
492                 ctlr->databytes = sizeof(ich7_spi->spid);
493                 ctlr->status = offsetof(struct ich7_spi_regs, spis);
494                 ctlr->control = offsetof(struct ich7_spi_regs, spic);
495                 ctlr->bbar = offsetof(struct ich7_spi_regs, bbar);
496                 ctlr->preop = offsetof(struct ich7_spi_regs, preop);
497         } else if (plat->ich_version == ICHV_9) {
498                 struct ich9_spi_regs *ich9_spi = ctlr->base;
499
500                 ctlr->opmenu = offsetof(struct ich9_spi_regs, opmenu);
501                 ctlr->menubytes = sizeof(ich9_spi->opmenu);
502                 ctlr->optype = offsetof(struct ich9_spi_regs, optype);
503                 ctlr->addr = offsetof(struct ich9_spi_regs, faddr);
504                 ctlr->data = offsetof(struct ich9_spi_regs, fdata);
505                 ctlr->databytes = sizeof(ich9_spi->fdata);
506                 ctlr->status = offsetof(struct ich9_spi_regs, ssfs);
507                 ctlr->control = offsetof(struct ich9_spi_regs, ssfc);
508                 ctlr->speed = ctlr->control + 2;
509                 ctlr->bbar = offsetof(struct ich9_spi_regs, bbar);
510                 ctlr->preop = offsetof(struct ich9_spi_regs, preop);
511                 ctlr->bcr = offsetof(struct ich9_spi_regs, bcr);
512                 ctlr->pr = &ich9_spi->pr[0];
513         } else {
514                 debug("ICH SPI: Unrecognised ICH version %d\n",
515                       plat->ich_version);
516                 return -EINVAL;
517         }
518
519         /* Work out the maximum speed we can support */
520         ctlr->max_speed = 20000000;
521         if (plat->ich_version == ICHV_9 && ich9_can_do_33mhz(dev))
522                 ctlr->max_speed = 33000000;
523         debug("ICH SPI: Version ID %d detected at %lx, speed %ld\n",
524               plat->ich_version, plat->mmio_base, ctlr->max_speed);
525
526         ich_set_bbar(ctlr, 0);
527
528         return 0;
529 }
530
531 static int ich_spi_probe(struct udevice *dev)
532 {
533         struct ich_spi_platdata *plat = dev_get_platdata(dev);
534         struct ich_spi_priv *priv = dev_get_priv(dev);
535         int ret;
536
537         ret = ich_init_controller(dev, plat, priv);
538         if (ret)
539                 return ret;
540
541         ret = ich_protect_lockdown(dev);
542         if (ret)
543                 return ret;
544
545         priv->cur_speed = priv->max_speed;
546
547         return 0;
548 }
549
550 static int ich_spi_remove(struct udevice *bus)
551 {
552         /*
553          * Configure SPI controller so that the Linux MTD driver can fully
554          * access the SPI NOR chip
555          */
556         ich_spi_config_opcode(bus);
557
558         return 0;
559 }
560
561 static int ich_spi_set_speed(struct udevice *bus, uint speed)
562 {
563         struct ich_spi_priv *priv = dev_get_priv(bus);
564
565         priv->cur_speed = speed;
566
567         return 0;
568 }
569
570 static int ich_spi_set_mode(struct udevice *bus, uint mode)
571 {
572         debug("%s: mode=%d\n", __func__, mode);
573
574         return 0;
575 }
576
577 static int ich_spi_child_pre_probe(struct udevice *dev)
578 {
579         struct udevice *bus = dev_get_parent(dev);
580         struct ich_spi_platdata *plat = dev_get_platdata(bus);
581         struct ich_spi_priv *priv = dev_get_priv(bus);
582         struct spi_slave *slave = dev_get_parent_priv(dev);
583
584         /*
585          * Yes this controller can only write a small number of bytes at
586          * once! The limit is typically 64 bytes.
587          */
588         slave->max_write_size = priv->databytes;
589         /*
590          * ICH 7 SPI controller only supports array read command
591          * and byte program command for SST flash
592          */
593         if (plat->ich_version == ICHV_7)
594                 slave->mode = SPI_RX_SLOW | SPI_TX_BYTE;
595
596         return 0;
597 }
598
599 static int ich_spi_ofdata_to_platdata(struct udevice *dev)
600 {
601         struct ich_spi_platdata *plat = dev_get_platdata(dev);
602
603 #if !CONFIG_IS_ENABLED(OF_PLATDATA)
604         struct ich_spi_priv *priv = dev_get_priv(dev);
605
606         /* Find a PCH if there is one */
607         uclass_first_device(UCLASS_PCH, &priv->pch);
608         if (!priv->pch)
609                 priv->pch = dev_get_parent(dev);
610
611         plat->ich_version = dev_get_driver_data(dev);
612         plat->lockdown = dev_read_bool(dev, "intel,spi-lock-down");
613         pch_get_spi_base(priv->pch, &plat->mmio_base);
614 #else
615         plat->ich_version = ICHV_APL;
616         plat->mmio_base = plat->dtplat.early_regs[0];
617         plat->bdf = pci_ofplat_get_devfn(plat->dtplat.reg[0]);
618 #endif
619         debug("%s: mmio_base=%lx\n", __func__, plat->mmio_base);
620
621         return 0;
622 }
623
624 static const struct spi_controller_mem_ops ich_controller_mem_ops = {
625         .adjust_op_size = ich_spi_adjust_size,
626         .supports_op    = NULL,
627         .exec_op        = ich_spi_exec_op,
628 };
629
630 static const struct dm_spi_ops ich_spi_ops = {
631         /* xfer is not supported */
632         .set_speed      = ich_spi_set_speed,
633         .set_mode       = ich_spi_set_mode,
634         .mem_ops        = &ich_controller_mem_ops,
635         /*
636          * cs_info is not needed, since we require all chip selects to be
637          * in the device tree explicitly
638          */
639 };
640
641 static const struct udevice_id ich_spi_ids[] = {
642         { .compatible = "intel,ich7-spi", ICHV_7 },
643         { .compatible = "intel,ich9-spi", ICHV_9 },
644         { }
645 };
646
647 U_BOOT_DRIVER(intel_fast_spi) = {
648         .name   = "intel_fast_spi",
649         .id     = UCLASS_SPI,
650         .of_match = ich_spi_ids,
651         .ops    = &ich_spi_ops,
652         .ofdata_to_platdata = ich_spi_ofdata_to_platdata,
653         .platdata_auto_alloc_size = sizeof(struct ich_spi_platdata),
654         .priv_auto_alloc_size = sizeof(struct ich_spi_priv),
655         .child_pre_probe = ich_spi_child_pre_probe,
656         .probe  = ich_spi_probe,
657         .remove = ich_spi_remove,
658         .flags  = DM_FLAG_OS_PREPARE,
659 };