3 * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
5 * See file CREDITS for list of people who contributed to this
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License as
10 * published by the Free Software Foundation; either version 2 of
11 * the License, or (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
28 #define CFG_ENV_ADDR (CFG_FLASH_BASE + CFG_ENV_OFFSET)
31 flash_info_t flash_info[CFG_MAX_FLASH_BANKS]; /* info for FLASH chips */
33 /*-----------------------------------------------------------------------
36 static int write_word (flash_info_t *info, ulong dest, ulong data);
38 static ulong flash_get_size (vu_long *addr, flash_info_t *info);
39 static void flash_get_offsets (ulong base, flash_info_t *info);
42 static int my_in_8( unsigned char *addr);
43 static void my_out_8( unsigned char *addr, int val);
45 #ifdef CONFIG_BOOT_16B
46 static int my_in_be16( unsigned short *addr);
47 static void my_out_be16( unsigned short *addr, int val);
49 #ifdef CONFIG_BOOT_32B
50 static unsigned my_in_be32( unsigned *addr);
51 static void my_out_be32( unsigned *addr, int val);
53 /*-----------------------------------------------------------------------
56 unsigned long flash_init (void)
58 volatile immap_t *immap = (immap_t *)CFG_IMMR;
59 volatile memctl8xx_t *memctl = &immap->im_memctl;
60 unsigned long size_b0, size_b1;
65 /* Init: no FLASHes known */
66 for (i=0; i<CFG_MAX_FLASH_BANKS; ++i) {
67 flash_info[i].flash_id = FLASH_UNKNOWN;
70 #ifndef CONFIG_FEL8xx_AT
71 memctl->memc_or5 = (0xffff8000 | CFG_OR_TIMING_DOC ); /* 32k bytes */
72 memctl->memc_br5 = CFG_DOC_BASE | 0x401;
74 memctl->memc_or3 = (0xffff8000 | CFG_OR_TIMING_DOC ); /* 32k bytes */
75 memctl->memc_br3 = CFG_DOC_BASE | 0x401;
78 #if defined( CONFIG_BOOT_8B)
79 // memctl->memc_or0 = 0xfff80ff4; /* 4MB bytes */
80 // memctl->memc_br0 = 0x40000401;
81 size_b0 = 0x80000; /* 512 K */
82 flash_info[0].flash_id = FLASH_MAN_AMD | FLASH_AM040;
83 flash_info[0].sector_count = 8;
84 flash_info[0].size = 0x00080000;
85 /* set up sector start address table */
86 for (i = 0; i < flash_info[0].sector_count; i++)
87 flash_info[0].start[i] = 0x40000000 + (i * 0x10000);
88 /* protect all sectors */
89 for (i = 0; i < flash_info[0].sector_count; i++)
90 flash_info[0].protect[i] = 0x1;
91 #elif defined (CONFIG_BOOT_16B)
92 // memctl->memc_or0 = 0xfff80ff4; /* 4MB bytes */
93 // memctl->memc_br0 = 0x40000401;
94 size_b0 = 0x400000; /* 4MB , assume AMD29LV320B */
95 flash_info[0].flash_id = FLASH_MAN_AMD | FLASH_AM320B;
96 flash_info[0].sector_count = 67;
97 flash_info[0].size = 0x00400000;
98 /* set up sector start address table */
99 flash_info[0].start[0] = 0x40000000 ;
100 flash_info[0].start[1] = 0x40000000 + 0x4000;
101 flash_info[0].start[2] = 0x40000000 + 0x6000;
102 flash_info[0].start[3] = 0x40000000 + 0x8000;
103 for (i = 4; i < flash_info[0].sector_count; i++)
104 flash_info[0].start[i] = 0x40000000 + 0x10000 + ((i-4) * 0x10000);
105 /* protect all sectors */
106 for (i = 0; i < flash_info[0].sector_count; i++)
107 flash_info[0].protect[i] = 0x1;
111 #ifdef CONFIG_BOOT_32B
113 /* Static FLASH Bank configuration here - FIXME XXX */
115 size_b0 = flash_get_size((vu_long *)FLASH_BASE0_PRELIM, &flash_info[0]);
117 if (flash_info[0].flash_id == FLASH_UNKNOWN) {
118 printf ("## Unknown FLASH on Bank 0 - Size = 0x%08lx = %ld MB\n",
119 size_b0, size_b0<<20);
122 size_b1 = flash_get_size((vu_long *)FLASH_BASE1_PRELIM, &flash_info[1]);
124 if (size_b1 > size_b0) {
126 "Bank 1 (0x%08lx = %ld MB) > Bank 0 (0x%08lx = %ld MB)\n",
127 size_b1, size_b1<<20,
130 flash_info[0].flash_id = FLASH_UNKNOWN;
131 flash_info[1].flash_id = FLASH_UNKNOWN;
132 flash_info[0].sector_count = -1;
133 flash_info[1].sector_count = -1;
134 flash_info[0].size = 0;
135 flash_info[1].size = 0;
139 /* Remap FLASH according to real size */
140 memctl->memc_or0 = CFG_OR_TIMING_FLASH | (-size_b0 & OR_AM_MSK);
141 memctl->memc_br0 = (CFG_FLASH_BASE & BR_BA_MSK) | BR_MS_GPCM | BR_V;
143 /* Re-do sizing to get full correct info */
144 size_b0 = flash_get_size((vu_long *)CFG_FLASH_BASE, &flash_info[0]);
146 flash_get_offsets (CFG_FLASH_BASE, &flash_info[0]);
148 #if CFG_MONITOR_BASE >= CFG_FLASH_BASE
149 /* monitor protection ON by default */
150 flash_protect(FLAG_PROTECT_SET,
152 CFG_MONITOR_BASE+CFG_MONITOR_LEN-1,
156 #ifdef CFG_ENV_IS_IN_FLASH
157 /* ENV protection ON by default */
158 flash_protect(FLAG_PROTECT_SET,
160 CFG_ENV_ADDR+CFG_ENV_SIZE-1,
165 memctl->memc_or1 = CFG_OR_TIMING_FLASH | (-size_b1 & 0xFFFF8000);
166 memctl->memc_br1 = ((CFG_FLASH_BASE + size_b0) & BR_BA_MSK) |
169 /* Re-do sizing to get full correct info */
170 size_b1 = flash_get_size((vu_long *)(CFG_FLASH_BASE + size_b0),
173 flash_get_offsets (CFG_FLASH_BASE + size_b0, &flash_info[1]);
175 #if CFG_MONITOR_BASE >= CFG_FLASH_BASE
176 /* monitor protection ON by default */
177 flash_protect(FLAG_PROTECT_SET,
179 CFG_MONITOR_BASE+CFG_MONITOR_LEN-1,
183 #ifdef CFG_ENV_IS_IN_FLASH
184 /* ENV protection ON by default */
185 flash_protect(FLAG_PROTECT_SET,
187 CFG_ENV_ADDR+CFG_ENV_SIZE-1,
191 memctl->memc_br1 = 0; /* invalidate bank */
193 flash_info[1].flash_id = FLASH_UNKNOWN;
194 flash_info[1].sector_count = -1;
197 flash_info[0].size = size_b0;
198 flash_info[1].size = size_b1;
201 #endif /* CONFIG_BOOT_32B */
203 return (size_b0 + size_b1);
206 /*-----------------------------------------------------------------------
208 static void flash_get_offsets (ulong base, flash_info_t *info)
212 /* set up sector start address table */
213 if (info->flash_id & FLASH_BTYPE) {
214 /* set sector offsets for bottom boot block type */
215 info->start[0] = base + 0x00000000;
216 info->start[1] = base + 0x00008000;
217 info->start[2] = base + 0x0000C000;
218 info->start[3] = base + 0x00010000;
219 for (i = 4; i < info->sector_count; i++) {
220 info->start[i] = base + (i * 0x00020000) - 0x00060000;
223 /* set sector offsets for top boot block type */
224 i = info->sector_count - 1;
225 info->start[i--] = base + info->size - 0x00008000;
226 info->start[i--] = base + info->size - 0x0000C000;
227 info->start[i--] = base + info->size - 0x00010000;
228 for (; i >= 0; i--) {
229 info->start[i] = base + i * 0x00020000;
234 /*-----------------------------------------------------------------------
236 void flash_print_info (flash_info_t *info)
240 if (info->flash_id == FLASH_UNKNOWN) {
241 printf ("missing or unknown FLASH type\n");
245 switch (info->flash_id & FLASH_VENDMASK) {
246 case FLASH_MAN_AMD: printf ("AMD "); break;
247 case FLASH_MAN_FUJ: printf ("FUJITSU "); break;
248 default: printf ("Unknown Vendor "); break;
251 switch (info->flash_id & FLASH_TYPEMASK) {
252 case FLASH_AM400B: printf ("AM29LV400B (4 Mbit, bottom boot sect)\n");
254 case FLASH_AM400T: printf ("AM29LV400T (4 Mbit, top boot sector)\n");
256 case FLASH_AM800B: printf ("AM29LV800B (8 Mbit, bottom boot sect)\n");
258 case FLASH_AM800T: printf ("AM29LV800T (8 Mbit, top boot sector)\n");
260 case FLASH_AM160B: printf ("AM29LV160B (16 Mbit, bottom boot sect)\n");
262 case FLASH_AM160T: printf ("AM29LV160T (16 Mbit, top boot sector)\n");
264 case FLASH_AM320B: printf ("AM29LV320B (32 Mbit, bottom boot sect)\n");
266 case FLASH_AM320T: printf ("AM29LV320T (32 Mbit, top boot sector)\n");
268 default: printf ("Unknown Chip Type\n");
272 printf (" Size: %ld MB in %d Sectors\n",
273 info->size >> 20, info->sector_count);
275 printf (" Sector Start Addresses:");
276 for (i=0; i<info->sector_count; ++i) {
281 info->protect[i] ? " (RO)" : " "
288 /*-----------------------------------------------------------------------
292 /*-----------------------------------------------------------------------
296 * The following code cannot be run from FLASH!
299 static ulong flash_get_size (vu_long *addr, flash_info_t *info)
303 ulong base = (ulong)addr;
305 /* Write auto select command: read Manufacturer ID */
306 addr[0x0555] = 0x00AA00AA;
307 addr[0x02AA] = 0x00550055;
308 addr[0x0555] = 0x00900090;
314 info->flash_id = FLASH_MAN_AMD;
317 info->flash_id = FLASH_MAN_FUJ;
320 info->flash_id = FLASH_UNKNOWN;
321 info->sector_count = 0;
323 return (0); /* no or unknown flash */
326 value = addr[1]; /* device ID */
330 info->flash_id += FLASH_AM400T;
331 info->sector_count = 11;
332 info->size = 0x00100000;
336 info->flash_id += FLASH_AM400B;
337 info->sector_count = 11;
338 info->size = 0x00100000;
342 info->flash_id += FLASH_AM800T;
343 info->sector_count = 19;
344 info->size = 0x00200000;
348 info->flash_id += FLASH_AM800B;
349 info->sector_count = 19;
350 info->size = 0x00200000;
354 info->flash_id += FLASH_AM160T;
355 info->sector_count = 35;
356 info->size = 0x00400000;
360 info->flash_id += FLASH_AM160B;
361 info->sector_count = 35;
362 info->size = 0x00400000;
364 #if 0 /* enable when device IDs are available */
366 info->flash_id += FLASH_AM320T;
367 info->sector_count = 67;
368 info->size = 0x00800000;
372 info->flash_id += FLASH_AM320B;
373 info->sector_count = 67;
374 info->size = 0x00800000;
378 info->flash_id = FLASH_UNKNOWN;
379 return (0); /* => no or unknown flash */
382 /* set up sector start address table */
383 if (info->flash_id & FLASH_BTYPE) {
384 /* set sector offsets for bottom boot block type */
385 info->start[0] = base + 0x00000000;
386 info->start[1] = base + 0x00008000;
387 info->start[2] = base + 0x0000C000;
388 info->start[3] = base + 0x00010000;
389 for (i = 4; i < info->sector_count; i++) {
390 info->start[i] = base + (i * 0x00020000) - 0x00060000;
393 /* set sector offsets for top boot block type */
394 i = info->sector_count - 1;
395 info->start[i--] = base + info->size - 0x00008000;
396 info->start[i--] = base + info->size - 0x0000C000;
397 info->start[i--] = base + info->size - 0x00010000;
398 for (; i >= 0; i--) {
399 info->start[i] = base + i * 0x00020000;
403 /* check for protected sectors */
404 for (i = 0; i < info->sector_count; i++) {
405 /* read sector protection at sector address, (A7 .. A0) = 0x02 */
406 /* D0 = 1 if protected */
407 addr = (volatile unsigned long *)(info->start[i]);
408 info->protect[i] = addr[2] & 1;
412 * Prevent writes to uninitialized FLASH.
414 if (info->flash_id != FLASH_UNKNOWN) {
415 addr = (volatile unsigned long *)info->start[0];
417 *addr = 0x00F000F0; /* reset bank */
424 /*-----------------------------------------------------------------------
427 int flash_erase (flash_info_t *info, int s_first, int s_last)
429 vu_long *addr = (vu_long*)(info->start[0]);
430 int flag, prot, sect, l_sect,in_mid,in_did;
431 ulong start, now, last;
433 if ((s_first < 0) || (s_first > s_last)) {
434 if (info->flash_id == FLASH_UNKNOWN) {
435 printf ("- missing\n");
437 printf ("- no sectors to erase\n");
442 if ((info->flash_id == FLASH_UNKNOWN) ||
443 (info->flash_id > FLASH_AMD_COMP)) {
444 printf ("Can't erase unknown flash type %08lx - aborted\n",
450 for (sect=s_first; sect<=s_last; ++sect) {
451 if (info->protect[sect]) {
457 printf ("- Warning: %d protected sectors will not be erased!\n",
465 /* Disable interrupts which might cause a timeout here */
466 flag = disable_interrupts();
467 #if defined (CONFIG_BOOT_8B )
468 my_out_8( (unsigned char * ) ((ulong)addr+0x555) , 0xaa );
469 my_out_8( (unsigned char * ) ((ulong)addr+0x2aa) , 0x55 );
470 my_out_8( (unsigned char * ) ((ulong)addr+0x555) , 0x90 );
471 in_mid=my_in_8( (unsigned char * ) addr );
472 in_did=my_in_8( (unsigned char * ) ((ulong)addr+1) );
473 printf(" man ID=0x%x, dev ID=0x%x.\n",in_mid,in_did );
474 my_out_8( (unsigned char *)addr, 0xf0);
476 my_out_8( (unsigned char *) ((ulong)addr+0x555),0xaa );
477 my_out_8( (unsigned char *) ((ulong)addr+0x2aa),0x55 );
478 my_out_8( (unsigned char *) ((ulong)addr+0x555),0x80 );
479 my_out_8( (unsigned char *) ((ulong)addr+0x555),0xaa );
480 my_out_8( (unsigned char *) ((ulong)addr+0x2aa),0x55 );
481 /* Start erase on unprotected sectors */
482 for (sect = s_first; sect<=s_last; sect++) {
483 if (info->protect[sect] == 0) { /* not protected */
484 addr = (vu_long*)(info->start[sect]);
485 //addr[0] = 0x00300030;
486 my_out_8( (unsigned char *) ((ulong)addr),0x30 );
490 #elif defined(CONFIG_BOOT_16B )
491 my_out_be16( (unsigned short * ) ((ulong)addr+ (0xaaa)) , 0xaa );
492 my_out_be16( (unsigned short * ) ((ulong)addr+ (0x554)) , 0x55 );
493 my_out_be16( (unsigned short * ) ((ulong)addr+ (0xaaa)) , 0x90 );
494 in_mid=my_in_be16( (unsigned short * ) addr );
495 in_did=my_in_be16 ( (unsigned short * ) ((ulong)addr+2) );
496 printf(" man ID=0x%x, dev ID=0x%x.\n",in_mid,in_did );
497 my_out_be16( (unsigned short *)addr, 0xf0);
499 my_out_be16( (unsigned short *) ((ulong)addr+ 0xaaa),0xaa );
500 my_out_be16( (unsigned short *) ((ulong)addr+0x554),0x55 );
501 my_out_be16( (unsigned short *) ((ulong)addr+0xaaa),0x80 );
502 my_out_be16( (unsigned short *) ((ulong)addr+0xaaa),0xaa );
503 my_out_be16( (unsigned short *) ((ulong)addr+0x554),0x55 );
504 /* Start erase on unprotected sectors */
505 for (sect = s_first; sect<=s_last; sect++) {
506 if (info->protect[sect] == 0) { /* not protected */
507 addr = (vu_long*)(info->start[sect]);
508 my_out_be16( (unsigned short *) ((ulong)addr),0x30 );
513 #elif defined(CONFIG_BOOT_32B)
514 my_out_be32( (unsigned * ) ((ulong)addr+0x1554) , 0xaa );
515 my_out_be32( (unsigned * ) ((ulong)addr+0xaa8) , 0x55 );
516 my_out_be32( (unsigned *) ((ulong)addr+0x1554) , 0x90 );
517 in_mid=my_in_be32( (unsigned * ) addr );
518 in_did=my_in_be32( (unsigned * ) ((ulong)addr+4) );
519 printf(" man ID=0x%x, dev ID=0x%x.\n",in_mid,in_did );
520 my_out_be32( (unsigned *)addr, 0xf0);
522 my_out_be32( (unsigned *) ((ulong)addr+0x1554),0xaa );
523 my_out_be32( (unsigned *) ((ulong)addr+0xaa8),0x55 );
524 my_out_be32( (unsigned *) ((ulong)addr+0x1554),0x80 );
525 my_out_be32( (unsigned *) ((ulong)addr+0x1554),0xaa );
526 my_out_be32( (unsigned *) ((ulong)addr+0xaa8),0x55 );
527 /* Start erase on unprotected sectors */
528 for (sect = s_first; sect<=s_last; sect++) {
529 if (info->protect[sect] == 0) { /* not protected */
530 addr = (vu_long*)(info->start[sect]);
531 my_out_be32( (unsigned *) ((ulong)addr),0x00300030 );
537 # error CONFIG_BOOT_(size)B missing.
539 /* re-enable interrupts if necessary */
543 /* wait at least 80us - let's wait 1 ms */
547 * We wait for the last triggered sector
552 start = get_timer (0);
554 addr = (vu_long*)(info->start[l_sect]);
555 #if defined (CONFIG_BOOT_8B)
556 while ( (my_in_8((unsigned char *)addr) & 0x80) != 0x80 )
557 #elif defined(CONFIG_BOOT_16B )
558 while ( (my_in_be16((unsigned short *)addr) & 0x0080) != 0x0080 )
559 #elif defined(CONFIG_BOOT_32B)
560 while ( (my_in_be32((unsigned *)addr) & 0x00800080) != 0x00800080 )
562 # error CONFIG_BOOT_(size)B missing.
565 if ((now = get_timer(start)) > CFG_FLASH_ERASE_TOUT) {
566 printf ("Timeout\n");
569 /* show that we're waiting */
570 if ((now - last) > 1000) { /* every second */
576 /* reset to read mode */
577 addr = (volatile unsigned long *)info->start[0];
578 #if defined (CONFIG_BOOT_8B)
579 my_out_8( (unsigned char *)addr, 0xf0);
580 #elif defined(CONFIG_BOOT_16B )
581 my_out_be16( (unsigned short * ) addr , 0x00f0 );
582 #elif defined(CONFIG_BOOT_32B)
583 my_out_be32 ( (unsigned *)addr, 0x00F000F0 ); /* reset bank */
585 # error CONFIG_BOOT_(size)B missing.
591 /*-----------------------------------------------------------------------
592 * Copy memory to flash, returns:
595 * 2 - Flash not erased
598 int write_buff (flash_info_t *info, uchar *src, ulong addr, ulong cnt)
603 wp = (addr & ~3); /* get lower word aligned address */
606 * handle unaligned start bytes
608 if ((l = addr - wp) != 0) {
610 for (i=0, cp=wp; i<l; ++i, ++cp) {
611 data = (data << 8) | (*(uchar *)cp);
613 for (; i<4 && cnt>0; ++i) {
614 data = (data << 8) | *src++;
618 for (; cnt==0 && i<4; ++i, ++cp) {
619 data = (data << 8) | (*(uchar *)cp);
622 if ((rc = write_word(info, wp, data)) != 0) {
629 * handle word aligned part
633 for (i=0; i<4; ++i) {
634 data = (data << 8) | *src++;
636 if ((rc = write_word(info, wp, data)) != 0) {
648 * handle unaligned tail bytes
651 for (i=0, cp=wp; i<4 && cnt>0; ++i, ++cp) {
652 data = (data << 8) | *src++;
655 for (; i<4; ++i, ++cp) {
656 data = (data << 8) | (*(uchar *)cp);
659 return (write_word(info, wp, data));
662 /*-----------------------------------------------------------------------
663 * Write a word to Flash, returns:
666 * 2 - Flash not erased
668 static int write_word (flash_info_t *info, ulong dest, ulong data)
670 ulong addr = (ulong)(info->start[0]);
676 /* Check if Flash is (sufficiently) erased */
677 if ( ((ulong) *(ulong *)dest & data) != data ) {
680 /* Disable interrupts which might cause a timeout here */
681 flag = disable_interrupts();
682 #if defined(CONFIG_BOOT_8B)
686 my_out_8( (unsigned char * ) (addr+0x555) , 0xaa );
687 my_out_8( (unsigned char * ) (addr+0x2aa) , 0x55 );
688 my_out_8( (unsigned char * ) (addr+0x555) , 0x90 );
689 in_mid=my_in_8( (unsigned char * ) addr );
690 in_did=my_in_8( (unsigned char * ) (addr+1) );
691 printf(" man ID=0x%x, dev ID=0x%x.\n",in_mid,in_did );
692 my_out_8( (unsigned char *)addr, 0xf0);
698 data_ch[0]=(int ) ((data>>24) & 0xff);
699 data_ch[1]=(int ) ((data>>16) &0xff );
700 data_ch[2]=(int ) ((data >>8) & 0xff);
701 data_ch[3]=(int ) (data & 0xff);
703 my_out_8( (unsigned char *) (addr+0x555),0xaa);
704 my_out_8((unsigned char *) (addr+0x2aa),0x55);
705 my_out_8( (unsigned char *) (addr+0x555),0xa0);
706 my_out_8((unsigned char *) (dest+i) ,data_ch[i]);
707 /* re-enable interrupts if necessary */
711 start = get_timer (0);
713 while( ( my_in_8((unsigned char *) (dest+i)) ) != ( data_ch[i] ) ) {
714 if (get_timer(start) > CFG_FLASH_WRITE_TOUT ) {
720 #elif defined( CONFIG_BOOT_16B)
721 data_short[0]=(int) (data>>16) & 0xffff;
722 data_short[1]=(int ) data & 0xffff ;
724 my_out_be16( (unsigned short *) ((ulong)addr+ 0xaaa),0xaa );
725 my_out_be16( (unsigned short *) ((ulong)addr+ 0x554),0x55 );
726 my_out_be16( (unsigned short *) ((ulong)addr+ 0xaaa),0xa0 );
727 my_out_be16( (unsigned short *) (dest+(i*2)) ,data_short[i]);
728 /* re-enable interrupts if necessary */
731 start = get_timer (0);
733 while( ( my_in_be16((unsigned short *) (dest+(i*2))) ) != ( data_short[i] ) ) {
734 if (get_timer(start) > CFG_FLASH_WRITE_TOUT ) {
739 #elif defined( CONFIG_BOOT_32B)
740 addr[0x0555] = 0x00AA00AA;
741 addr[0x02AA] = 0x00550055;
742 addr[0x0555] = 0x00A000A0;
744 *((vu_long *)dest) = data;
746 /* re-enable interrupts if necessary */
750 /* data polling for D7 */
751 start = get_timer (0);
752 while ((*((vu_long *)dest) & 0x00800080) != (data & 0x00800080)) {
753 if (get_timer(start) > CFG_FLASH_WRITE_TOUT) {
762 #ifdef CONFIG_BOOT_8B
763 static int my_in_8 ( unsigned char *addr)
766 __asm__ __volatile__("lbz%U1%X1 %0,%1; eieio" : "=r" (ret) : "m" (*addr));
770 static void my_out_8 ( unsigned char *addr, int val)
772 __asm__ __volatile__("stb%U0%X0 %1,%0; eieio" : "=m" (*addr) : "r" (val));
775 #ifdef CONFIG_BOOT_16B
776 static int my_in_be16( unsigned short *addr)
779 __asm__ __volatile__("lhz%U1%X1 %0,%1; eieio" : "=r" (ret) : "m" (*addr));
782 static void my_out_be16( unsigned short *addr, int val)
784 __asm__ __volatile__("sth%U0%X0 %1,%0; eieio" : "=m" (*addr) : "r" (val));
787 #ifdef CONFIG_BOOT_32B
788 static unsigned my_in_be32( unsigned *addr)
791 __asm__ __volatile__("lwz%U1%X1 %0,%1; eieio" : "=r" (ret) : "m" (*addr));
794 static void my_out_be32( unsigned *addr, int val)
796 __asm__ __volatile__("stw%U0%X0 %1,%0; eieio" : "=m" (*addr) : "r" (val));