• Home
  • History
  • Annotate
  • Raw
  • Download
  • only in /asus-wl-520gu-7.0.1.45/src/cfe/cfe/dev/

Lines Matching defs:softc

136 static int flash_sector_query(flashdev_t *softc,flash_sector_t *sector);
152 * FLASH_OP_BEGIN(softc)
158 * softc - our softc.
164 #define flash_op_begin(softc) softc->fd_iptr = 0;
167 * FLASH_OP_ADD(softc,op,dest,src,cnt)
172 * softc - our flash
179 static void flash_op_add(flashdev_t *softc,long base,long op,long dest,long src,long cnt)
181 flashinstr_t *fi = &(softc->fd_inst[softc->fd_iptr]);
189 softc->fd_iptr++;
194 * FLASH_OP_EXECUTE(softc)
199 * softc - our flash
205 static int flash_op_execute(flashdev_t *softc)
207 flash_op_add(softc,softc->fd_probe.flash_phys,FEOP_RETURN,0,0,0);
213 for (idx = 0; idx < softc->fd_iptr; idx++) {
215 softc->fd_inst[idx].fi_op,
216 softc->fd_inst[idx].fi_base,
217 softc->fd_inst[idx].fi_dest,
218 softc->fd_inst[idx].fi_src,
219 softc->fd_inst[idx].fi_cnt);
227 if (softc->fd_probe.flash_engine_hook) {
228 return (*(softc->fd_probe.flash_engine_hook))(&(softc->fd_inst[0]));
235 return (*flashop_engine_ram)(&(softc->fd_inst[0]));
292 * FLASH_ERASE_RANGE(softc,range)
297 * softc - our flash
305 static int flash_erase_range(flashdev_t *softc,flash_range_t *range)
310 if (softc->fd_probe.flash_type != FLASH_TYPE_FLASH) {
314 if (range->range_base+range->range_length > softc->fd_probe.flash_size) {
323 res = flash_sector_query(softc,&sector);
333 flash_op_begin(softc);
334 flash_op_add(softc,softc->fd_probe.flash_phys,
335 softc->fd_erasefunc,
338 res = flash_op_execute(softc);
350 * FLASH_ERASE_ALL(softc)
356 * softc - our flash
363 static int flash_erase_all(flashdev_t *softc)
368 range.range_length = softc->fd_probe.flash_size *
369 softc->fd_probe.flash_nchips;
371 return flash_erase_range(softc,&range);
434 * FLASH_SECTOR_QUERY(softc,sector)
440 * softc - our flash info
448 static int flash_sector_query(flashdev_t *softc,flash_sector_t *sector)
458 if (softc->fd_probe.flash_type != FLASH_TYPE_FLASH) {
462 if (softc->fd_probe.flash_nsectors == 0) {
467 whichchip = sector->flash_sector_idx / softc->fd_ttlsect;
468 if (whichchip >= softc->fd_probe.flash_nchips) {
474 offset = softc->fd_probe.flash_size * whichchip;
475 secidx = sector->flash_sector_idx % softc->fd_ttlsect;
478 for (idx = 0; idx < softc->fd_probe.flash_nsectors; idx++) {
479 nblks = FLASH_SECTOR_NBLKS(softc->fd_probe.flash_sectors[idx]);
480 blksiz = FLASH_SECTOR_SIZE(softc->fd_probe.flash_sectors[idx]);
494 if (idx == softc->fd_probe.flash_nsectors) {
503 * FLASH_SET_CMDSET(softc,cmdset,bus16,dev16)
508 * softc - our flash
521 static void flash_set_cmdset(flashdev_t *softc,int cmdset,int bus16,int dev16)
527 softc->fd_erasefunc = FEOP_INTELEXT_ERASE16;
528 softc->fd_pgmfunc = FEOP_INTELEXT_PGM16;
529 softc->fd_readfunc = FEOP_READ16;
532 softc->fd_erasefunc = FEOP_INTELEXT_ERASE8;
533 softc->fd_pgmfunc = FEOP_INTELEXT_PGM8;
534 softc->fd_readfunc = FEOP_READ8;
539 softc->fd_erasefunc = FEOP_INTEL_ERASE16;
540 softc->fd_pgmfunc = FEOP_INTEL_PGM16;
541 softc->fd_readfunc = FEOP_READ16;
544 softc->fd_erasefunc = FEOP_INTEL_ERASE8;
545 softc->fd_pgmfunc = FEOP_INTEL_PGM8;
546 softc->fd_readfunc = FEOP_READ8;
554 softc->fd_erasefunc = FEOP_AMD_ERASE8;
555 softc->fd_pgmfunc = FEOP_AMD_PGM8;
556 softc->fd_readfunc = FEOP_READ8;
559 softc->fd_erasefunc = FEOP_AMD_ERASE16;
560 softc->fd_pgmfunc = FEOP_AMD_PGM16;
561 softc->fd_readfunc = FEOP_READ16;
564 softc->fd_erasefunc = FEOP_AMD_ERASE16B;
565 softc->fd_pgmfunc = FEOP_AMD_PGM16B;
566 softc->fd_readfunc = FEOP_READ8;
573 softc->fd_erasefunc = FEOP_SST_ERASE16;
574 softc->fd_pgmfunc = FEOP_SST_PGM16;
575 softc->fd_readfunc = FEOP_READ16;
579 softc->fd_erasefunc = FEOP_RETURN;
580 softc->fd_pgmfunc = FEOP_RETURN;
581 softc->fd_readfunc = bus16 ? FEOP_READ16 : FEOP_READ8;
587 softc->fd_erasefunc = FEOP_RETURN;
588 softc->fd_pgmfunc = FEOP_RETURN;
589 softc->fd_readfunc = bus16 ? FEOP_READ16 : FEOP_READ8;
596 * FLASH_CFI_PROBE(softc)
603 * softc - out flash
608 static int flash_cfi_probe(flashdev_t *softc)
623 if (softc->fd_probe.flash_flags & FLASH_FLG_BUS16) {
632 if (softc->fd_probe.flash_flags & FLASH_FLG_DEV16) {
633 idx = (softc->fd_probe.flash_flags & FLASH_FLG_BUS16) ?
637 flash_op_begin(softc);
638 flash_op_add(softc,softc->fd_probe.flash_phys,
640 flash_op_execute(softc);
656 flash_op_begin(softc);
657 flash_op_add(softc,softc->fd_probe.flash_phys,
659 flash_op_execute(softc);
678 flash_set_cmdset(softc,-1,bus16,dev16);
682 softc->fd_probe.flash_type = FLASH_TYPE_FLASH;
696 softc->fd_probe.flash_size = (1 << (unsigned int)(cfidata[FLASH_CFI_DEVICE_SIZE]));
708 softc->fd_probe.flash_nsectors = regcnt;
717 if (softc->fd_probe.flash_flags & FLASH_FLG_DEV16) {
718 idx = (softc->fd_probe.flash_flags & FLASH_FLG_BUS16) ?
722 flash_op_begin(softc);
723 flash_op_add(softc,softc->fd_probe.flash_phys,
725 flash_op_execute(softc);
746 softc->fd_probe.flash_sectors[((regcnt-1)-idx)] =
751 softc->fd_probe.flash_sectors[idx] =
760 flash_set_cmdset(softc,cmdset,bus16,dev16);
769 * FLASH_DO_PROBE(softc)
775 * softc - our structure
780 static int flash_do_probe(flashdev_t *softc)
792 softc->fd_inst = KMALLOC(FLASH_MAX_INST*sizeof(flashinstr_t),0);
793 if (!softc->fd_inst) return FLASH_TYPE_ROM;
800 ptr = (volatile uint8_t *) UNCADDR(softc->fd_probe.flash_phys);
811 softc->fd_probe.flash_type = FLASH_TYPE_SRAM;
823 softc->fd_probe.flash_type = FLASH_TYPE_ROM;
837 if (softc->fd_probe.flash_type == FLASH_TYPE_ROM) {
838 flash_cfi_probe(softc);
842 KFREE(softc->fd_inst);
843 softc->fd_inst = NULL;
845 return softc->fd_probe.flash_type;
873 static void flash_do_parts(flashdev_t *softc)
878 newflash_probe_t *probe = &(softc->fd_probe);
879 flashpart_t *parts = &(softc->fd_parts[0]);
929 static void flashdrv_allocbuf(flashdev_t *softc)
943 softc->fd_sectorbuffer = flash_sector_buffer;
966 flashdev_t *softc;
993 softc = (flashdev_t *) KMALLOC(sizeof(flashdev_t),0);
994 if (softc) {
995 memset(softc,0,sizeof(flashdev_t));
997 flashdrv_allocbuf(softc);
1003 memcpy(&(softc->fd_probe),probe,sizeof(newflash_probe_t));
1004 if (softc->fd_probe.flash_nchips == 0) {
1005 softc->fd_probe.flash_nchips = 1;
1010 softc->fd_probe.flash_phys = probe_a;
1011 softc->fd_probe.flash_size = (probe_b & FLASH_SIZE_MASK);
1012 softc->fd_probe.flash_flags = (probe_b & FLASH_FLG_MASK);
1013 softc->fd_probe.flash_nchips = 1;
1016 if (softc->fd_probe.flash_flags & FLASH_FLG_MANUAL) {
1018 flash_set_cmdset(softc,softc->fd_probe.flash_cmdset,
1019 ((softc->fd_probe.flash_flags & FLASH_FLG_BUS16) ? 1 : 0),
1020 ((softc->fd_probe.flash_flags & FLASH_FLG_DEV16) ? 1 : 0));
1025 flash_do_probe(softc);
1032 softc->fd_ttlsize = softc->fd_probe.flash_nchips * softc->fd_probe.flash_size;
1037 softc->fd_probe.flash_phys,
1038 softc->fd_ttlsize/1024);
1039 if (softc->fd_probe.flash_nchips > 1) {
1040 xsprintf(x," (%d chips)",softc->fd_probe.flash_nchips);
1049 if (softc->fd_probe.flash_nparts == 0) {
1050 softc->fd_parts[0].fp_dev = softc;
1051 softc->fd_parts[0].fp_offset = 0;
1052 softc->fd_parts[0].fp_size = softc->fd_probe.flash_size;
1053 cfe_attach(drv,&(softc->fd_parts[0]),NULL,descr);
1059 flash_do_parts(softc);
1065 for (idx = 0; idx < softc->fd_probe.flash_nparts; idx++) {
1071 softc->fd_probe.flash_phys,
1072 softc->fd_parts[idx].fp_offset,
1073 (softc->fd_parts[idx].fp_size+1023)/1024);
1075 softc->fd_parts[idx].fp_dev = softc;
1076 if (softc->fd_probe.flash_parts[idx].fp_name == NULL) {
1081 nptr = softc->fd_probe.flash_parts[idx].fp_name;
1085 &(softc->fd_parts[idx]),
1095 softc->fd_ttlsect = 0;
1096 for (idx = 0; idx < softc->fd_probe.flash_nsectors; idx++) {
1097 softc->fd_ttlsect += FLASH_SECTOR_NBLKS(softc->fd_probe.flash_sectors[idx]);
1120 flashdev_t *softc = part->fp_dev;
1121 int ttlsect = softc->fd_ttlsect;
1129 ttlsect = (ttlsect * 2 * softc->fd_probe.flash_nchips) + 6;
1139 softc->fd_inst = KMALLOC(ttlsect*sizeof(flashinstr_t),0);
1140 if (!softc->fd_inst) return CFE_ERR_NOMEM;
1163 flashdev_t *softc = part->fp_dev;
1177 flash_op_begin(softc);
1178 flash_op_add(softc,softc->fd_probe.flash_phys,
1179 softc->fd_readfunc,(long)buffer->buf_ptr,offset,blen);
1180 flash_op_execute(softc);
1225 flashdev_t *softc = part->fp_dev;
1260 flash_op_begin(softc);
1263 res = flash_sector_query(softc,&sector);
1269 whichchip = sector.flash_sector_idx / softc->fd_ttlsect;
1270 chipbase = softc->fd_probe.flash_phys +
1271 (long) (whichchip * softc->fd_probe.flash_size);
1277 flash_op_add(softc,chipbase,
1278 softc->fd_erasefunc,
1281 flash_op_add(softc,chipbase,
1282 softc->fd_pgmfunc,
1290 flash_op_add(softc,chipbase,
1291 softc->fd_readfunc,
1292 (long)(softc->fd_sectorbuffer),
1296 flash_op_add(softc,chipbase,
1298 ((long)(softc->fd_sectorbuffer))+(outrange.range_base-sector.flash_sector_offset),
1302 flash_op_add(softc,chipbase,
1303 softc->fd_erasefunc,
1307 flash_op_add(softc,chipbase,
1308 softc->fd_pgmfunc,
1310 (long)(softc->fd_sectorbuffer),
1323 flash_op_add(softc,softc->fd_probe.flash_phys,FEOP_REBOOT,0,0,0);
1326 res = flash_op_execute(softc);
1356 flashdev_t *softc = part->fp_dev;
1370 if (softc->fd_probe.flash_nparts <= 1) {
1386 if (offset >= softc->fd_probe.flash_size) return -1;
1388 flash_op_begin(softc);
1389 flash_op_add(softc,
1390 softc->fd_probe.flash_phys,
1391 softc->fd_erasefunc,
1394 flash_op_execute(softc);
1400 flash_erase_all(softc);
1410 info->flash_base = softc->fd_probe.flash_phys;
1411 info->flash_size = softc->fd_probe.flash_size;
1412 info->flash_type = softc->fd_probe.flash_type;
1419 return flash_sector_query(softc,(flash_sector_t *) buffer->buf_ptr);
1427 return flash_erase_range(softc,&range);
1431 if (softc->fd_probe.flash_ioctl_hook) {
1432 return (*(softc->fd_probe.flash_ioctl_hook))(ctx,buffer);
1455 flashdev_t *softc = part->fp_dev;
1457 if (softc->fd_inst) {
1458 KFREE(softc->fd_inst);
1461 softc->fd_inst = NULL;