Commit 34c202c7eb24d04c577722c14b90fbedf517fd22

Authored by Wolfgang Denk
1 parent 88b2533de0

common/cmd_ide.c: CodingStyle cleanup

Make file acceptable to checkpatch.

This is only a basic clean up to the extend possible without any real
changes to the source code. Warnings due to line over 80 characters
were accepted because these affect only printf()s with user visible
strings.  No attempts were made to fix warnings about volatile and
externs - these need a more thorough cleanup.

Signed-off-by: Wolfgang Denk <wd@denx.de>

Showing 1 changed file with 874 additions and 840 deletions Side-by-side Diff

Changes suppressed. Click to show
1 1 /*
2   - * (C) Copyright 2000-2005
  2 + * (C) Copyright 2000-2011
3 3 * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
4 4 *
5 5 * See file CREDITS for list of people who contributed to this
... ... @@ -119,7 +119,6 @@
119 119 #endif
120 120 };
121 121  
122   -
123 122 static int ide_bus_ok[CONFIG_SYS_IDE_MAXBUS];
124 123  
125 124 block_dev_desc_t ide_dev_desc[CONFIG_SYS_IDE_MAXDEVICE];
126 125  
127 126  
128 127  
129 128  
130 129  
131 130  
132 131  
133 132  
134 133  
135 134  
136 135  
137 136  
138 137  
139 138  
140 139  
141 140  
142 141  
143 142  
144 143  
145 144  
146 145  
147 146  
148 147  
149 148  
150 149  
151 150  
152 151  
153 152  
154 153  
155 154  
156 155  
157 156  
158 157  
159 158  
160 159  
161 160  
162 161  
... ... @@ -173,176 +172,167 @@
173 172  
174 173 /* ------------------------------------------------------------------------- */
175 174  
176   -int do_ide (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
  175 +int do_ide(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[])
177 176 {
178   - int rcode = 0;
  177 + int rcode = 0;
179 178  
180   - switch (argc) {
181   - case 0:
182   - case 1:
183   - return cmd_usage(cmdtp);
184   - case 2:
185   - if (strncmp(argv[1],"res",3) == 0) {
186   - puts ("\nReset IDE"
  179 + switch (argc) {
  180 + case 0:
  181 + case 1:
  182 + return cmd_usage(cmdtp);
  183 + case 2:
  184 + if (strncmp(argv[1], "res", 3) == 0) {
  185 + puts("\nReset IDE"
187 186 #ifdef CONFIG_IDE_8xx_DIRECT
188   - " on PCMCIA " PCMCIA_SLOT_MSG
  187 + " on PCMCIA " PCMCIA_SLOT_MSG
189 188 #endif
190   - ": ");
  189 + ": ");
191 190  
192   - ide_init ();
193   - return 0;
194   - } else if (strncmp(argv[1],"inf",3) == 0) {
195   - int i;
  191 + ide_init();
  192 + return 0;
  193 + } else if (strncmp(argv[1], "inf", 3) == 0) {
  194 + int i;
196 195  
197   - putc ('\n');
  196 + putc('\n');
198 197  
199   - for (i=0; i<CONFIG_SYS_IDE_MAXDEVICE; ++i) {
200   - if (ide_dev_desc[i].type==DEV_TYPE_UNKNOWN)
201   - continue; /* list only known devices */
202   - printf ("IDE device %d: ", i);
203   - dev_print(&ide_dev_desc[i]);
204   - }
205   - return 0;
  198 + for (i = 0; i < CONFIG_SYS_IDE_MAXDEVICE; ++i) {
  199 + if (ide_dev_desc[i].type == DEV_TYPE_UNKNOWN)
  200 + continue; /* list only known devices */
  201 + printf("IDE device %d: ", i);
  202 + dev_print(&ide_dev_desc[i]);
  203 + }
  204 + return 0;
206 205  
207   - } else if (strncmp(argv[1],"dev",3) == 0) {
208   - if ((curr_device < 0) || (curr_device >= CONFIG_SYS_IDE_MAXDEVICE)) {
209   - puts ("\nno IDE devices available\n");
210   - return 1;
211   - }
212   - printf ("\nIDE device %d: ", curr_device);
213   - dev_print(&ide_dev_desc[curr_device]);
214   - return 0;
215   - } else if (strncmp(argv[1],"part",4) == 0) {
216   - int dev, ok;
  206 + } else if (strncmp(argv[1], "dev", 3) == 0) {
  207 + if ((curr_device < 0)
  208 + || (curr_device >= CONFIG_SYS_IDE_MAXDEVICE)) {
  209 + puts("\nno IDE devices available\n");
  210 + return 1;
  211 + }
  212 + printf("\nIDE device %d: ", curr_device);
  213 + dev_print(&ide_dev_desc[curr_device]);
  214 + return 0;
  215 + } else if (strncmp(argv[1], "part", 4) == 0) {
  216 + int dev, ok;
217 217  
218   - for (ok=0, dev=0; dev<CONFIG_SYS_IDE_MAXDEVICE; ++dev) {
219   - if (ide_dev_desc[dev].part_type!=PART_TYPE_UNKNOWN) {
220   - ++ok;
221   - if (dev)
222   - putc ('\n');
223   - print_part(&ide_dev_desc[dev]);
  218 + for (ok = 0, dev = 0;
  219 + dev < CONFIG_SYS_IDE_MAXDEVICE;
  220 + ++dev) {
  221 + if (ide_dev_desc[dev].part_type !=
  222 + PART_TYPE_UNKNOWN) {
  223 + ++ok;
  224 + if (dev)
  225 + putc('\n');
  226 + print_part(&ide_dev_desc[dev]);
  227 + }
224 228 }
  229 + if (!ok) {
  230 + puts("\nno IDE devices available\n");
  231 + rcode++;
  232 + }
  233 + return rcode;
225 234 }
226   - if (!ok) {
227   - puts ("\nno IDE devices available\n");
228   - rcode ++;
229   - }
230   - return rcode;
231   - }
232   - return cmd_usage(cmdtp);
233   - case 3:
234   - if (strncmp(argv[1],"dev",3) == 0) {
235   - int dev = (int)simple_strtoul(argv[2], NULL, 10);
  235 + return cmd_usage(cmdtp);
  236 + case 3:
  237 + if (strncmp(argv[1], "dev", 3) == 0) {
  238 + int dev = (int) simple_strtoul(argv[2], NULL, 10);
236 239  
237   - printf ("\nIDE device %d: ", dev);
238   - if (dev >= CONFIG_SYS_IDE_MAXDEVICE) {
239   - puts ("unknown device\n");
240   - return 1;
241   - }
242   - dev_print(&ide_dev_desc[dev]);
243   - /*ide_print (dev);*/
  240 + printf("\nIDE device %d: ", dev);
  241 + if (dev >= CONFIG_SYS_IDE_MAXDEVICE) {
  242 + puts("unknown device\n");
  243 + return 1;
  244 + }
  245 + dev_print(&ide_dev_desc[dev]);
  246 + /*ide_print (dev); */
244 247  
245   - if (ide_dev_desc[dev].type == DEV_TYPE_UNKNOWN) {
246   - return 1;
247   - }
  248 + if (ide_dev_desc[dev].type == DEV_TYPE_UNKNOWN)
  249 + return 1;
248 250  
249   - curr_device = dev;
  251 + curr_device = dev;
250 252  
251   - puts ("... is now current device\n");
  253 + puts("... is now current device\n");
252 254  
253   - return 0;
254   - } else if (strncmp(argv[1],"part",4) == 0) {
255   - int dev = (int)simple_strtoul(argv[2], NULL, 10);
  255 + return 0;
  256 + } else if (strncmp(argv[1], "part", 4) == 0) {
  257 + int dev = (int) simple_strtoul(argv[2], NULL, 10);
256 258  
257   - if (ide_dev_desc[dev].part_type!=PART_TYPE_UNKNOWN) {
  259 + if (ide_dev_desc[dev].part_type != PART_TYPE_UNKNOWN) {
258 260 print_part(&ide_dev_desc[dev]);
259   - } else {
260   - printf ("\nIDE device %d not available\n", dev);
261   - rcode = 1;
  261 + } else {
  262 + printf("\nIDE device %d not available\n",
  263 + dev);
  264 + rcode = 1;
  265 + }
  266 + return rcode;
262 267 }
263   - return rcode;
264   -#if 0
265   - } else if (strncmp(argv[1],"pio",4) == 0) {
266   - int mode = (int)simple_strtoul(argv[2], NULL, 10);
267 268  
268   - if ((mode >= 0) && (mode <= IDE_MAX_PIO_MODE)) {
269   - puts ("\nSetting ");
270   - pio_mode = mode;
271   - ide_init ();
272   - } else {
273   - printf ("\nInvalid PIO mode %d (0 ... %d only)\n",
274   - mode, IDE_MAX_PIO_MODE);
275   - }
276   - return;
277   -#endif
278   - }
  269 + return cmd_usage(cmdtp);
  270 + default:
  271 + /* at least 4 args */
279 272  
280   - return cmd_usage(cmdtp);
281   - default:
282   - /* at least 4 args */
  273 + if (strcmp(argv[1], "read") == 0) {
  274 + ulong addr = simple_strtoul(argv[2], NULL, 16);
  275 + ulong cnt = simple_strtoul(argv[4], NULL, 16);
  276 + ulong n;
283 277  
284   - if (strcmp(argv[1],"read") == 0) {
285   - ulong addr = simple_strtoul(argv[2], NULL, 16);
286   - ulong cnt = simple_strtoul(argv[4], NULL, 16);
287   - ulong n;
288 278 #ifdef CONFIG_SYS_64BIT_LBA
289   - lbaint_t blk = simple_strtoull(argv[3], NULL, 16);
  279 + lbaint_t blk = simple_strtoull(argv[3], NULL, 16);
290 280  
291   - printf ("\nIDE read: device %d block # %Ld, count %ld ... ",
292   - curr_device, blk, cnt);
  281 + printf("\nIDE read: device %d block # %lld, count %ld ... ",
  282 + curr_device, blk, cnt);
293 283 #else
294   - lbaint_t blk = simple_strtoul(argv[3], NULL, 16);
  284 + lbaint_t blk = simple_strtoul(argv[3], NULL, 16);
295 285  
296   - printf ("\nIDE read: device %d block # %ld, count %ld ... ",
297   - curr_device, blk, cnt);
  286 + printf("\nIDE read: device %d block # %ld, count %ld ... ",
  287 + curr_device, blk, cnt);
298 288 #endif
299 289  
300   - n = ide_dev_desc[curr_device].block_read (curr_device,
301   - blk, cnt,
302   - (ulong *)addr);
303   - /* flush cache after read */
304   - flush_cache (addr, cnt*ide_dev_desc[curr_device].blksz);
  290 + n = ide_dev_desc[curr_device].block_read(curr_device,
  291 + blk, cnt,
  292 + (ulong *)addr);
  293 + /* flush cache after read */
  294 + flush_cache(addr,
  295 + cnt * ide_dev_desc[curr_device].blksz);
305 296  
306   - printf ("%ld blocks read: %s\n",
307   - n, (n==cnt) ? "OK" : "ERROR");
308   - if (n==cnt) {
309   - return 0;
310   - } else {
311   - return 1;
312   - }
313   - } else if (strcmp(argv[1],"write") == 0) {
314   - ulong addr = simple_strtoul(argv[2], NULL, 16);
315   - ulong cnt = simple_strtoul(argv[4], NULL, 16);
316   - ulong n;
  297 + printf("%ld blocks read: %s\n",
  298 + n, (n == cnt) ? "OK" : "ERROR");
  299 + if (n == cnt)
  300 + return 0;
  301 + else
  302 + return 1;
  303 + } else if (strcmp(argv[1], "write") == 0) {
  304 + ulong addr = simple_strtoul(argv[2], NULL, 16);
  305 + ulong cnt = simple_strtoul(argv[4], NULL, 16);
  306 + ulong n;
  307 +
317 308 #ifdef CONFIG_SYS_64BIT_LBA
318   - lbaint_t blk = simple_strtoull(argv[3], NULL, 16);
  309 + lbaint_t blk = simple_strtoull(argv[3], NULL, 16);
319 310  
320   - printf ("\nIDE write: device %d block # %Ld, count %ld ... ",
321   - curr_device, blk, cnt);
  311 + printf("\nIDE write: device %d block # %lld, count %ld ... ",
  312 + curr_device, blk, cnt);
322 313 #else
323   - lbaint_t blk = simple_strtoul(argv[3], NULL, 16);
  314 + lbaint_t blk = simple_strtoul(argv[3], NULL, 16);
324 315  
325   - printf ("\nIDE write: device %d block # %ld, count %ld ... ",
326   - curr_device, blk, cnt);
  316 + printf("\nIDE write: device %d block # %ld, count %ld ... ",
  317 + curr_device, blk, cnt);
327 318 #endif
  319 + n = ide_write(curr_device, blk, cnt, (ulong *) addr);
328 320  
329   - n = ide_write (curr_device, blk, cnt, (ulong *)addr);
  321 + printf("%ld blocks written: %s\n",
  322 + n, (n == cnt) ? "OK" : "ERROR");
  323 + if (n == cnt)
  324 + return 0;
  325 + else
  326 + return 1;
  327 + } else {
  328 + return cmd_usage(cmdtp);
  329 + }
330 330  
331   - printf ("%ld blocks written: %s\n",
332   - n, (n==cnt) ? "OK" : "ERROR");
333   - if (n==cnt)
334   - return 0;
335   - else
336   - return 1;
337   - } else {
338   - return cmd_usage(cmdtp);
  331 + return rcode;
339 332 }
340   -
341   - return rcode;
342   - }
343 333 }
344 334  
345   -int do_diskboot (cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
  335 +int do_diskboot(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[])
346 336 {
347 337 char *boot_device = NULL;
348 338 char *ep;
349 339  
350 340  
351 341  
352 342  
353 343  
354 344  
355 345  
356 346  
357 347  
358 348  
359 349  
360 350  
361 351  
362 352  
363 353  
364 354  
365 355  
366 356  
367 357  
368 358  
369 359  
370 360  
371 361  
372 362  
373 363  
374 364  
375 365  
376 366  
... ... @@ -350,112 +340,115 @@
350 340 ulong addr, cnt;
351 341 disk_partition_t info;
352 342 image_header_t *hdr;
  343 +
353 344 #if defined(CONFIG_FIT)
354 345 const void *fit_hdr = NULL;
355 346 #endif
356 347  
357   - show_boot_progress (41);
  348 + show_boot_progress(41);
358 349 switch (argc) {
359 350 case 1:
360 351 addr = CONFIG_SYS_LOAD_ADDR;
361   - boot_device = getenv ("bootdevice");
  352 + boot_device = getenv("bootdevice");
362 353 break;
363 354 case 2:
364 355 addr = simple_strtoul(argv[1], NULL, 16);
365   - boot_device = getenv ("bootdevice");
  356 + boot_device = getenv("bootdevice");
366 357 break;
367 358 case 3:
368 359 addr = simple_strtoul(argv[1], NULL, 16);
369 360 boot_device = argv[2];
370 361 break;
371 362 default:
372   - show_boot_progress (-42);
  363 + show_boot_progress(-42);
373 364 return cmd_usage(cmdtp);
374 365 }
375   - show_boot_progress (42);
  366 + show_boot_progress(42);
376 367  
377 368 if (!boot_device) {
378   - puts ("\n** No boot device **\n");
379   - show_boot_progress (-43);
  369 + puts("\n** No boot device **\n");
  370 + show_boot_progress(-43);
380 371 return 1;
381 372 }
382   - show_boot_progress (43);
  373 + show_boot_progress(43);
383 374  
384 375 dev = simple_strtoul(boot_device, &ep, 16);
385 376  
386   - if (ide_dev_desc[dev].type==DEV_TYPE_UNKNOWN) {
387   - printf ("\n** Device %d not available\n", dev);
388   - show_boot_progress (-44);
  377 + if (ide_dev_desc[dev].type == DEV_TYPE_UNKNOWN) {
  378 + printf("\n** Device %d not available\n", dev);
  379 + show_boot_progress(-44);
389 380 return 1;
390 381 }
391   - show_boot_progress (44);
  382 + show_boot_progress(44);
392 383  
393 384 if (*ep) {
394 385 if (*ep != ':') {
395   - puts ("\n** Invalid boot device, use `dev[:part]' **\n");
396   - show_boot_progress (-45);
  386 + puts("\n** Invalid boot device, use `dev[:part]' **\n");
  387 + show_boot_progress(-45);
397 388 return 1;
398 389 }
399 390 part = simple_strtoul(++ep, NULL, 16);
400 391 }
401   - show_boot_progress (45);
402   - if (get_partition_info (&ide_dev_desc[dev], part, &info)) {
403   - show_boot_progress (-46);
  392 + show_boot_progress(45);
  393 + if (get_partition_info(&ide_dev_desc[dev], part, &info)) {
  394 + show_boot_progress(-46);
404 395 return 1;
405 396 }
406   - show_boot_progress (46);
407   - if ((strncmp((char *)info.type, BOOT_PART_TYPE, sizeof(info.type)) != 0) &&
408   - (strncmp((char *)info.type, BOOT_PART_COMP, sizeof(info.type)) != 0)) {
409   - printf ("\n** Invalid partition type \"%.32s\""
410   - " (expect \"" BOOT_PART_TYPE "\")\n",
  397 + show_boot_progress(46);
  398 + if ((strncmp((char *)info.type, BOOT_PART_TYPE, sizeof(info.type)) != 0)
  399 + &&
  400 + (strncmp((char *)info.type, BOOT_PART_COMP, sizeof(info.type)) != 0)
  401 + ) {
  402 + printf("\n** Invalid partition type \"%.32s\"" " (expect \""
  403 + BOOT_PART_TYPE "\")\n",
411 404 info.type);
412   - show_boot_progress (-47);
  405 + show_boot_progress(-47);
413 406 return 1;
414 407 }
415   - show_boot_progress (47);
  408 + show_boot_progress(47);
416 409  
417   - printf ("\nLoading from IDE device %d, partition %d: "
418   - "Name: %.32s Type: %.32s\n",
419   - dev, part, info.name, info.type);
  410 + printf("\nLoading from IDE device %d, partition %d: "
  411 + "Name: %.32s Type: %.32s\n", dev, part, info.name, info.type);
420 412  
421   - debug ("First Block: %ld, # of blocks: %ld, Block Size: %ld\n",
422   - info.start, info.size, info.blksz);
  413 + debug("First Block: %ld, # of blocks: %ld, Block Size: %ld\n",
  414 + info.start, info.size, info.blksz);
423 415  
424   - if (ide_dev_desc[dev].block_read (dev, info.start, 1, (ulong *)addr) != 1) {
425   - printf ("** Read error on %d:%d\n", dev, part);
426   - show_boot_progress (-48);
  416 + if (ide_dev_desc[dev].
  417 + block_read(dev, info.start, 1, (ulong *) addr) != 1) {
  418 + printf("** Read error on %d:%d\n", dev, part);
  419 + show_boot_progress(-48);
427 420 return 1;
428 421 }
429   - show_boot_progress (48);
  422 + show_boot_progress(48);
430 423  
431   - switch (genimg_get_format ((void *)addr)) {
  424 + switch (genimg_get_format((void *) addr)) {
432 425 case IMAGE_FORMAT_LEGACY:
433   - hdr = (image_header_t *)addr;
  426 + hdr = (image_header_t *) addr;
434 427  
435   - show_boot_progress (49);
  428 + show_boot_progress(49);
436 429  
437   - if (!image_check_hcrc (hdr)) {
438   - puts ("\n** Bad Header Checksum **\n");
439   - show_boot_progress (-50);
  430 + if (!image_check_hcrc(hdr)) {
  431 + puts("\n** Bad Header Checksum **\n");
  432 + show_boot_progress(-50);
440 433 return 1;
441 434 }
442   - show_boot_progress (50);
  435 + show_boot_progress(50);
443 436  
444   - image_print_contents (hdr);
  437 + image_print_contents(hdr);
445 438  
446   - cnt = image_get_image_size (hdr);
  439 + cnt = image_get_image_size(hdr);
447 440 break;
448 441 #if defined(CONFIG_FIT)
449 442 case IMAGE_FORMAT_FIT:
450   - fit_hdr = (const void *)addr;
451   - puts ("Fit image detected...\n");
  443 + fit_hdr = (const void *) addr;
  444 + puts("Fit image detected...\n");
452 445  
453   - cnt = fit_get_size (fit_hdr);
  446 + cnt = fit_get_size(fit_hdr);
454 447 break;
455 448 #endif
456 449 default:
457   - show_boot_progress (-49);
458   - puts ("** Unknown image type\n");
  450 + show_boot_progress(-49);
  451 + puts("** Unknown image type\n");
459 452 return 1;
460 453 }
461 454  
462 455  
463 456  
464 457  
... ... @@ -463,24 +456,24 @@
463 456 cnt /= info.blksz;
464 457 cnt -= 1;
465 458  
466   - if (ide_dev_desc[dev].block_read (dev, info.start+1, cnt,
467   - (ulong *)(addr+info.blksz)) != cnt) {
468   - printf ("** Read error on %d:%d\n", dev, part);
469   - show_boot_progress (-51);
  459 + if (ide_dev_desc[dev].block_read(dev, info.start + 1, cnt,
  460 + (ulong *)(addr + info.blksz)) != cnt) {
  461 + printf("** Read error on %d:%d\n", dev, part);
  462 + show_boot_progress(-51);
470 463 return 1;
471 464 }
472   - show_boot_progress (51);
  465 + show_boot_progress(51);
473 466  
474 467 #if defined(CONFIG_FIT)
475 468 /* This cannot be done earlier, we need complete FIT image in RAM first */
476   - if (genimg_get_format ((void *)addr) == IMAGE_FORMAT_FIT) {
477   - if (!fit_check_format (fit_hdr)) {
478   - show_boot_progress (-140);
479   - puts ("** Bad FIT image format\n");
  469 + if (genimg_get_format((void *) addr) == IMAGE_FORMAT_FIT) {
  470 + if (!fit_check_format(fit_hdr)) {
  471 + show_boot_progress(-140);
  472 + puts("** Bad FIT image format\n");
480 473 return 1;
481 474 }
482   - show_boot_progress (141);
483   - fit_print_contents (fit_hdr);
  475 + show_boot_progress(141);
  476 + fit_print_contents(fit_hdr);
484 477 }
485 478 #endif
486 479  
487 480  
... ... @@ -493,11 +486,11 @@
493 486  
494 487 /* ------------------------------------------------------------------------- */
495 488  
496   -void inline
497   -__ide_outb(int dev, int port, unsigned char val)
  489 +inline void __ide_outb(int dev, int port, unsigned char val)
498 490 {
499   - debug ("ide_outb (dev= %d, port= 0x%x, val= 0x%02x) : @ 0x%08lx\n",
500   - dev, port, val, (ATA_CURR_BASE(dev)+CONFIG_SYS_ATA_PORT_ADDR(port)));
  491 + debug("ide_outb (dev= %d, port= 0x%x, val= 0x%02x) : @ 0x%08lx\n",
  492 + dev, port, val,
  493 + (ATA_CURR_BASE(dev) + CONFIG_SYS_ATA_PORT_ADDR(port)));
501 494  
502 495 #if defined(CONFIG_IDE_AHB)
503 496 if (port) {
504 497  
505 498  
506 499  
507 500  
508 501  
509 502  
510 503  
511 504  
512 505  
513 506  
514 507  
515 508  
516 509  
517 510  
518 511  
519 512  
... ... @@ -508,71 +501,74 @@
508 501 outb(val, (ATA_CURR_BASE(dev)));
509 502 }
510 503 #else
511   - outb(val, (ATA_CURR_BASE(dev)+CONFIG_SYS_ATA_PORT_ADDR(port)));
  504 + outb(val, (ATA_CURR_BASE(dev) + CONFIG_SYS_ATA_PORT_ADDR(port)));
512 505 #endif
513 506 }
514 507  
515   -void ide_outb (int dev, int port, unsigned char val)
516   - __attribute__((weak, alias("__ide_outb")));
  508 +void ide_outb(int dev, int port, unsigned char val)
  509 + __attribute__ ((weak, alias("__ide_outb")));
517 510  
518   -unsigned char inline
519   -__ide_inb(int dev, int port)
  511 +inline unsigned char __ide_inb(int dev, int port)
520 512 {
521 513 uchar val;
522 514  
523 515 #if defined(CONFIG_IDE_AHB)
524 516 val = ide_read_register(dev, port);
525 517 #else
526   - val = inb((ATA_CURR_BASE(dev)+CONFIG_SYS_ATA_PORT_ADDR(port)));
  518 + val = inb((ATA_CURR_BASE(dev) + CONFIG_SYS_ATA_PORT_ADDR(port)));
527 519 #endif
528 520  
529   - debug ("ide_inb (dev= %d, port= 0x%x) : @ 0x%08lx -> 0x%02x\n",
530   - dev, port, (ATA_CURR_BASE(dev)+CONFIG_SYS_ATA_PORT_ADDR(port)), val);
  521 + debug("ide_inb (dev= %d, port= 0x%x) : @ 0x%08lx -> 0x%02x\n",
  522 + dev, port,
  523 + (ATA_CURR_BASE(dev) + CONFIG_SYS_ATA_PORT_ADDR(port)), val);
531 524 return val;
532 525 }
  526 +
533 527 unsigned char ide_inb(int dev, int port)
534   - __attribute__((weak, alias("__ide_inb")));
  528 + __attribute__ ((weak, alias("__ide_inb")));
535 529  
536 530 #ifdef CONFIG_TUNE_PIO
537   -int inline
538   -__ide_set_piomode(int pio_mode)
  531 +inline int __ide_set_piomode(int pio_mode)
539 532 {
540 533 return 0;
541 534 }
542   -int inline ide_set_piomode(int pio_mode)
543   - __attribute__((weak, alias("__ide_set_piomode")));
  535 +
  536 +inline int ide_set_piomode(int pio_mode)
  537 + __attribute__ ((weak, alias("__ide_set_piomode")));
544 538 #endif
545 539  
546   -void ide_init (void)
  540 +void ide_init(void)
547 541 {
548 542  
549 543 #ifdef CONFIG_IDE_8xx_DIRECT
550   - volatile immap_t *immr = (immap_t *)CONFIG_SYS_IMMR;
  544 + volatile immap_t *immr = (immap_t *) CONFIG_SYS_IMMR;
551 545 volatile pcmconf8xx_t *pcmp = &(immr->im_pcmcia);
552 546 #endif
553 547 unsigned char c;
554 548 int i, bus;
  549 +
555 550 #if defined(CONFIG_SC3)
556 551 unsigned int ata_reset_time = ATA_RESET_TIME;
557 552 #endif
558 553 #ifdef CONFIG_IDE_8xx_PCCARD
559   - extern int pcmcia_on (void);
560   - extern int ide_devices_found; /* Initialized in check_ide_device() */
561   -#endif /* CONFIG_IDE_8xx_PCCARD */
  554 + extern int pcmcia_on(void);
  555 + extern int ide_devices_found; /* Initialized in check_ide_device() */
  556 +#endif /* CONFIG_IDE_8xx_PCCARD */
562 557  
563 558 #ifdef CONFIG_IDE_PREINIT
564   - extern int ide_preinit (void);
  559 + extern int ide_preinit(void);
  560 +
565 561 WATCHDOG_RESET();
566 562  
567   - if (ide_preinit ()) {
568   - puts ("ide_preinit failed\n");
  563 + if (ide_preinit()) {
  564 + puts("ide_preinit failed\n");
569 565 return;
570 566 }
571   -#endif /* CONFIG_IDE_PREINIT */
  567 +#endif /* CONFIG_IDE_PREINIT */
572 568  
573 569 #ifdef CONFIG_IDE_8xx_PCCARD
574   - extern int pcmcia_on (void);
575   - extern int ide_devices_found; /* Initialized in check_ide_device() */
  570 + extern int pcmcia_on(void);
  571 + extern int ide_devices_found; /* Initialized in check_ide_device() */
576 572  
577 573 WATCHDOG_RESET();
578 574  
579 575  
580 576  
581 577  
582 578  
583 579  
584 580  
585 581  
586 582  
587 583  
588 584  
589 585  
590 586  
591 587  
592 588  
593 589  
594 590  
595 591  
596 592  
597 593  
598 594  
599 595  
600 596  
601 597  
... ... @@ -581,129 +577,135 @@
581 577 pcmcia_on();
582 578 if (!ide_devices_found)
583 579 return;
584   - udelay (1000000); /* 1 s */
585   -#endif /* CONFIG_IDE_8xx_PCCARD */
  580 + udelay(1000000); /* 1 s */
  581 +#endif /* CONFIG_IDE_8xx_PCCARD */
586 582  
587 583 WATCHDOG_RESET();
588 584  
589 585 #ifdef CONFIG_IDE_8xx_DIRECT
590 586 /* Initialize PIO timing tables */
591   - for (i=0; i <= IDE_MAX_PIO_MODE; ++i) {
592   - pio_config_clk[i].t_setup = PCMCIA_MK_CLKS(pio_config_ns[i].t_setup,
593   - gd->bus_clk);
594   - pio_config_clk[i].t_length = PCMCIA_MK_CLKS(pio_config_ns[i].t_length,
595   - gd->bus_clk);
596   - pio_config_clk[i].t_hold = PCMCIA_MK_CLKS(pio_config_ns[i].t_hold,
597   - gd->bus_clk);
598   - debug ( "PIO Mode %d: setup=%2d ns/%d clk"
599   - " len=%3d ns/%d clk"
600   - " hold=%2d ns/%d clk\n",
601   - i,
602   - pio_config_ns[i].t_setup, pio_config_clk[i].t_setup,
603   - pio_config_ns[i].t_length, pio_config_clk[i].t_length,
604   - pio_config_ns[i].t_hold, pio_config_clk[i].t_hold);
  587 + for (i = 0; i <= IDE_MAX_PIO_MODE; ++i) {
  588 + pio_config_clk[i].t_setup =
  589 + PCMCIA_MK_CLKS(pio_config_ns[i].t_setup, gd->bus_clk);
  590 + pio_config_clk[i].t_length =
  591 + PCMCIA_MK_CLKS(pio_config_ns[i].t_length,
  592 + gd->bus_clk);
  593 + pio_config_clk[i].t_hold =
  594 + PCMCIA_MK_CLKS(pio_config_ns[i].t_hold, gd->bus_clk);
  595 + debug("PIO Mode %d: setup=%2d ns/%d clk" " len=%3d ns/%d clk"
  596 + " hold=%2d ns/%d clk\n", i, pio_config_ns[i].t_setup,
  597 + pio_config_clk[i].t_setup, pio_config_ns[i].t_length,
  598 + pio_config_clk[i].t_length, pio_config_ns[i].t_hold,
  599 + pio_config_clk[i].t_hold);
605 600 }
606 601 #endif /* CONFIG_IDE_8xx_DIRECT */
607 602  
608   - /* Reset the IDE just to be sure.
  603 + /*
  604 + * Reset the IDE just to be sure.
609 605 * Light LED's to show
610 606 */
611   - ide_led ((LED_IDE1 | LED_IDE2), 1); /* LED's on */
612   - ide_reset (); /* ATAPI Drives seems to need a proper IDE Reset */
  607 + ide_led((LED_IDE1 | LED_IDE2), 1); /* LED's on */
613 608  
  609 + /* ATAPI Drives seems to need a proper IDE Reset */
  610 + ide_reset();
  611 +
614 612 #ifdef CONFIG_IDE_8xx_DIRECT
615 613 /* PCMCIA / IDE initialization for common mem space */
616 614 pcmp->pcmc_pgcrb = 0;
617 615  
618 616 /* start in PIO mode 0 - most relaxed timings */
619 617 pio_mode = 0;
620   - set_pcmcia_timing (pio_mode);
  618 + set_pcmcia_timing(pio_mode);
621 619 #endif /* CONFIG_IDE_8xx_DIRECT */
622 620  
623 621 /*
624 622 * Wait for IDE to get ready.
625 623 * According to spec, this can take up to 31 seconds!
626 624 */
627   - for (bus=0; bus<CONFIG_SYS_IDE_MAXBUS; ++bus) {
628   - int dev = bus * (CONFIG_SYS_IDE_MAXDEVICE / CONFIG_SYS_IDE_MAXBUS);
  625 + for (bus = 0; bus < CONFIG_SYS_IDE_MAXBUS; ++bus) {
  626 + int dev =
  627 + bus * (CONFIG_SYS_IDE_MAXDEVICE /
  628 + CONFIG_SYS_IDE_MAXBUS);
629 629  
630 630 #ifdef CONFIG_IDE_8xx_PCCARD
631 631 /* Skip non-ide devices from probing */
632 632 if ((ide_devices_found & (1 << bus)) == 0) {
633   - ide_led ((LED_IDE1 | LED_IDE2), 0); /* LED's off */
  633 + ide_led((LED_IDE1 | LED_IDE2), 0); /* LED's off */
634 634 continue;
635 635 }
636 636 #endif
637   - printf ("Bus %d: ", bus);
  637 + printf("Bus %d: ", bus);
638 638  
639 639 ide_bus_ok[bus] = 0;
640 640  
641 641 /* Select device
642 642 */
643   - udelay (100000); /* 100 ms */
644   - ide_outb (dev, ATA_DEV_HD, ATA_LBA | ATA_DEVICE(dev));
645   - udelay (100000); /* 100 ms */
  643 + udelay(100000); /* 100 ms */
  644 + ide_outb(dev, ATA_DEV_HD, ATA_LBA | ATA_DEVICE(dev));
  645 + udelay(100000); /* 100 ms */
646 646 i = 0;
647 647 do {
648   - udelay (10000); /* 10 ms */
  648 + udelay(10000); /* 10 ms */
649 649  
650   - c = ide_inb (dev, ATA_STATUS);
  650 + c = ide_inb(dev, ATA_STATUS);
651 651 i++;
652 652 #if defined(CONFIG_SC3)
653 653 if (i > (ata_reset_time * 100)) {
654 654 #else
655 655 if (i > (ATA_RESET_TIME * 100)) {
656 656 #endif
657   - puts ("** Timeout **\n");
658   - ide_led ((LED_IDE1 | LED_IDE2), 0); /* LED's off */
  657 + puts("** Timeout **\n");
  658 + /* LED's off */
  659 + ide_led((LED_IDE1 | LED_IDE2), 0);
659 660 return;
660 661 }
661   - if ((i >= 100) && ((i%100)==0)) {
662   - putc ('.');
663   - }
  662 + if ((i >= 100) && ((i % 100) == 0))
  663 + putc('.');
  664 +
664 665 } while (c & ATA_STAT_BUSY);
665 666  
666 667 if (c & (ATA_STAT_BUSY | ATA_STAT_FAULT)) {
667   - puts ("not available ");
668   - debug ("Status = 0x%02X ", c);
669   -#ifndef CONFIG_ATAPI /* ATAPI Devices do not set DRDY */
670   - } else if ((c & ATA_STAT_READY) == 0) {
671   - puts ("not available ");
672   - debug ("Status = 0x%02X ", c);
  668 + puts("not available ");
  669 + debug("Status = 0x%02X ", c);
  670 +#ifndef CONFIG_ATAPI /* ATAPI Devices do not set DRDY */
  671 + } else if ((c & ATA_STAT_READY) == 0) {
  672 + puts("not available ");
  673 + debug("Status = 0x%02X ", c);
673 674 #endif
674 675 } else {
675   - puts ("OK ");
  676 + puts("OK ");
676 677 ide_bus_ok[bus] = 1;
677 678 }
678 679 WATCHDOG_RESET();
679 680 }
680 681  
681   - putc ('\n');
  682 + putc('\n');
682 683  
683   - ide_led ((LED_IDE1 | LED_IDE2), 0); /* LED's off */
  684 + ide_led((LED_IDE1 | LED_IDE2), 0); /* LED's off */
684 685  
685 686 curr_device = -1;
686   - for (i=0; i<CONFIG_SYS_IDE_MAXDEVICE; ++i) {
  687 + for (i = 0; i < CONFIG_SYS_IDE_MAXDEVICE; ++i) {
687 688 #ifdef CONFIG_IDE_LED
688 689 int led = (IDE_BUS(i) == 0) ? LED_IDE1 : LED_IDE2;
689 690 #endif
690   - ide_dev_desc[i].type=DEV_TYPE_UNKNOWN;
691   - ide_dev_desc[i].if_type=IF_TYPE_IDE;
692   - ide_dev_desc[i].dev=i;
693   - ide_dev_desc[i].part_type=PART_TYPE_UNKNOWN;
694   - ide_dev_desc[i].blksz=0;
695   - ide_dev_desc[i].lba=0;
696   - ide_dev_desc[i].block_read=ide_read;
  691 + ide_dev_desc[i].type = DEV_TYPE_UNKNOWN;
  692 + ide_dev_desc[i].if_type = IF_TYPE_IDE;
  693 + ide_dev_desc[i].dev = i;
  694 + ide_dev_desc[i].part_type = PART_TYPE_UNKNOWN;
  695 + ide_dev_desc[i].blksz = 0;
  696 + ide_dev_desc[i].lba = 0;
  697 + ide_dev_desc[i].block_read = ide_read;
697 698 ide_dev_desc[i].block_write = ide_write;
698 699 if (!ide_bus_ok[IDE_BUS(i)])
699 700 continue;
700   - ide_led (led, 1); /* LED on */
  701 + ide_led(led, 1); /* LED on */
701 702 ide_ident(&ide_dev_desc[i]);
702   - ide_led (led, 0); /* LED off */
  703 + ide_led(led, 0); /* LED off */
703 704 dev_print(&ide_dev_desc[i]);
704   -/* ide_print (i); */
  705 +
705 706 if ((ide_dev_desc[i].lba > 0) && (ide_dev_desc[i].blksz > 0)) {
706   - init_part (&ide_dev_desc[i]); /* initialize partition type */
  707 + /* initialize partition type */
  708 + init_part(&ide_dev_desc[i]);
707 709 if (curr_device < 0)
708 710 curr_device = i;
709 711 }
... ... @@ -714,7 +716,7 @@
714 716 /* ------------------------------------------------------------------------- */
715 717  
716 718 #ifdef CONFIG_PARTITIONS
717   -block_dev_desc_t * ide_get_dev(int dev)
  719 +block_dev_desc_t *ide_get_dev(int dev)
718 720 {
719 721 return (dev < CONFIG_SYS_IDE_MAXDEVICE) ? &ide_dev_desc[dev] : NULL;
720 722 }
721 723  
722 724  
723 725  
724 726  
725 727  
726 728  
727 729  
728 730  
729 731  
730 732  
731 733  
732 734  
733 735  
734 736  
735 737  
736 738  
737 739  
738 740  
739 741  
740 742  
741 743  
742 744  
... ... @@ -723,91 +725,91 @@
723 725  
724 726 #ifdef CONFIG_IDE_8xx_DIRECT
725 727  
726   -static void
727   -set_pcmcia_timing (int pmode)
  728 +static void set_pcmcia_timing(int pmode)
728 729 {
729   - volatile immap_t *immr = (immap_t *)CONFIG_SYS_IMMR;
  730 + volatile immap_t *immr = (immap_t *) CONFIG_SYS_IMMR;
730 731 volatile pcmconf8xx_t *pcmp = &(immr->im_pcmcia);
731 732 ulong timings;
732 733  
733   - debug ("Set timing for PIO Mode %d\n", pmode);
  734 + debug("Set timing for PIO Mode %d\n", pmode);
734 735  
735 736 timings = PCMCIA_SHT(pio_config_clk[pmode].t_hold)
736 737 | PCMCIA_SST(pio_config_clk[pmode].t_setup)
737   - | PCMCIA_SL (pio_config_clk[pmode].t_length)
738   - ;
  738 + | PCMCIA_SL(pio_config_clk[pmode].t_length);
739 739  
740   - /* IDE 0
  740 + /*
  741 + * IDE 0
741 742 */
742 743 pcmp->pcmc_pbr0 = CONFIG_SYS_PCMCIA_PBR0;
743 744 pcmp->pcmc_por0 = CONFIG_SYS_PCMCIA_POR0
744 745 #if (CONFIG_SYS_PCMCIA_POR0 != 0)
745   - | timings
  746 + | timings
746 747 #endif
747   - ;
748   - debug ("PBR0: %08x POR0: %08x\n", pcmp->pcmc_pbr0, pcmp->pcmc_por0);
  748 + ;
  749 + debug("PBR0: %08x POR0: %08x\n", pcmp->pcmc_pbr0, pcmp->pcmc_por0);
749 750  
750 751 pcmp->pcmc_pbr1 = CONFIG_SYS_PCMCIA_PBR1;
751 752 pcmp->pcmc_por1 = CONFIG_SYS_PCMCIA_POR1
752 753 #if (CONFIG_SYS_PCMCIA_POR1 != 0)
753   - | timings
  754 + | timings
754 755 #endif
755   - ;
756   - debug ("PBR1: %08x POR1: %08x\n", pcmp->pcmc_pbr1, pcmp->pcmc_por1);
  756 + ;
  757 + debug("PBR1: %08x POR1: %08x\n", pcmp->pcmc_pbr1, pcmp->pcmc_por1);
757 758  
758 759 pcmp->pcmc_pbr2 = CONFIG_SYS_PCMCIA_PBR2;
759 760 pcmp->pcmc_por2 = CONFIG_SYS_PCMCIA_POR2
760 761 #if (CONFIG_SYS_PCMCIA_POR2 != 0)
761   - | timings
  762 + | timings
762 763 #endif
763   - ;
764   - debug ("PBR2: %08x POR2: %08x\n", pcmp->pcmc_pbr2, pcmp->pcmc_por2);
  764 + ;
  765 + debug("PBR2: %08x POR2: %08x\n", pcmp->pcmc_pbr2, pcmp->pcmc_por2);
765 766  
766 767 pcmp->pcmc_pbr3 = CONFIG_SYS_PCMCIA_PBR3;
767 768 pcmp->pcmc_por3 = CONFIG_SYS_PCMCIA_POR3
768 769 #if (CONFIG_SYS_PCMCIA_POR3 != 0)
769   - | timings
  770 + | timings
770 771 #endif
771   - ;
772   - debug ("PBR3: %08x POR3: %08x\n", pcmp->pcmc_pbr3, pcmp->pcmc_por3);
  772 + ;
  773 + debug("PBR3: %08x POR3: %08x\n", pcmp->pcmc_pbr3, pcmp->pcmc_por3);
773 774  
774   - /* IDE 1
  775 + /*
  776 + * IDE 1
775 777 */
776 778 pcmp->pcmc_pbr4 = CONFIG_SYS_PCMCIA_PBR4;
777 779 pcmp->pcmc_por4 = CONFIG_SYS_PCMCIA_POR4
778 780 #if (CONFIG_SYS_PCMCIA_POR4 != 0)
779   - | timings
  781 + | timings
780 782 #endif
781   - ;
782   - debug ("PBR4: %08x POR4: %08x\n", pcmp->pcmc_pbr4, pcmp->pcmc_por4);
  783 + ;
  784 + debug("PBR4: %08x POR4: %08x\n", pcmp->pcmc_pbr4, pcmp->pcmc_por4);
783 785  
784 786 pcmp->pcmc_pbr5 = CONFIG_SYS_PCMCIA_PBR5;
785 787 pcmp->pcmc_por5 = CONFIG_SYS_PCMCIA_POR5
786 788 #if (CONFIG_SYS_PCMCIA_POR5 != 0)
787   - | timings
  789 + | timings
788 790 #endif
789   - ;
790   - debug ("PBR5: %08x POR5: %08x\n", pcmp->pcmc_pbr5, pcmp->pcmc_por5);
  791 + ;
  792 + debug("PBR5: %08x POR5: %08x\n", pcmp->pcmc_pbr5, pcmp->pcmc_por5);
791 793  
792 794 pcmp->pcmc_pbr6 = CONFIG_SYS_PCMCIA_PBR6;
793 795 pcmp->pcmc_por6 = CONFIG_SYS_PCMCIA_POR6
794 796 #if (CONFIG_SYS_PCMCIA_POR6 != 0)
795   - | timings
  797 + | timings
796 798 #endif
797   - ;
798   - debug ("PBR6: %08x POR6: %08x\n", pcmp->pcmc_pbr6, pcmp->pcmc_por6);
  799 + ;
  800 + debug("PBR6: %08x POR6: %08x\n", pcmp->pcmc_pbr6, pcmp->pcmc_por6);
799 801  
800 802 pcmp->pcmc_pbr7 = CONFIG_SYS_PCMCIA_PBR7;
801 803 pcmp->pcmc_por7 = CONFIG_SYS_PCMCIA_POR7
802 804 #if (CONFIG_SYS_PCMCIA_POR7 != 0)
803   - | timings
  805 + | timings
804 806 #endif
805   - ;
806   - debug ("PBR7: %08x POR7: %08x\n", pcmp->pcmc_pbr7, pcmp->pcmc_por7);
  807 + ;
  808 + debug("PBR7: %08x POR7: %08x\n", pcmp->pcmc_pbr7, pcmp->pcmc_por7);
807 809  
808 810 }
809 811  
810   -#endif /* CONFIG_IDE_8xx_DIRECT */
  812 +#endif /* CONFIG_IDE_8xx_DIRECT */
811 813  
812 814 /* ------------------------------------------------------------------------- */
813 815  
814 816  
815 817  
816 818  
817 819  
818 820  
... ... @@ -817,32 +819,35 @@
817 819 (defined(CONFIG_SOC_AU1X00) && !defined(CONFIG_GTH2))
818 820 #define input_swap_data(x,y,z) input_data(x,y,z)
819 821 #else
820   -static void
821   -input_swap_data(int dev, ulong *sect_buf, int words)
  822 +static void input_swap_data(int dev, ulong *sect_buf, int words)
822 823 {
823 824 #if defined(CONFIG_CPC45)
824 825 uchar i;
825   - volatile uchar *pbuf_even = (uchar *)(ATA_CURR_BASE(dev)+ATA_DATA_EVEN);
826   - volatile uchar *pbuf_odd = (uchar *)(ATA_CURR_BASE(dev)+ATA_DATA_ODD);
827   - ushort *dbuf = (ushort *)sect_buf;
  826 + volatile uchar *pbuf_even =
  827 + (uchar *) (ATA_CURR_BASE(dev) + ATA_DATA_EVEN);
  828 + volatile uchar *pbuf_odd =
  829 + (uchar *) (ATA_CURR_BASE(dev) + ATA_DATA_ODD);
  830 + ushort *dbuf = (ushort *) sect_buf;
828 831  
829 832 while (words--) {
830   - for (i=0; i<2; i++) {
831   - *(((uchar *)(dbuf)) + 1) = *pbuf_even;
832   - *(uchar *)dbuf = *pbuf_odd;
833   - dbuf+=1;
  833 + for (i = 0; i < 2; i++) {
  834 + *(((uchar *) (dbuf)) + 1) = *pbuf_even;
  835 + *(uchar *) dbuf = *pbuf_odd;
  836 + dbuf += 1;
834 837 }
835 838 }
836 839 #else
837   - volatile ushort *pbuf = (ushort *)(ATA_CURR_BASE(dev)+ATA_DATA_REG);
838   - ushort *dbuf = (ushort *)sect_buf;
  840 + volatile ushort *pbuf =
  841 + (ushort *) (ATA_CURR_BASE(dev) + ATA_DATA_REG);
  842 + ushort *dbuf = (ushort *) sect_buf;
839 843  
840   - debug("in input swap data base for read is %lx\n", (unsigned long) pbuf);
  844 + debug("in input swap data base for read is %lx\n",
  845 + (unsigned long) pbuf);
841 846  
842 847 while (words--) {
843 848 #ifdef __MIPS__
844   - *dbuf++ = swab16p((u16*)pbuf);
845   - *dbuf++ = swab16p((u16*)pbuf);
  849 + *dbuf++ = swab16p((u16 *) pbuf);
  850 + *dbuf++ = swab16p((u16 *) pbuf);
846 851 #elif defined(CONFIG_PCS440EP)
847 852 *dbuf++ = *pbuf;
848 853 *dbuf++ = *pbuf;
849 854  
850 855  
851 856  
... ... @@ -853,21 +858,20 @@
853 858 }
854 859 #endif
855 860 }
856   -#endif /* __LITTLE_ENDIAN || CONFIG_AU1X00 */
  861 +#endif /* __LITTLE_ENDIAN || CONFIG_AU1X00 */
857 862  
858 863  
859 864 #if defined(CONFIG_IDE_SWAP_IO)
860   -static void
861   -output_data(int dev, const ulong *sect_buf, int words)
  865 +static void output_data(int dev, const ulong *sect_buf, int words)
862 866 {
863 867 #if defined(CONFIG_CPC45)
864   - uchar *dbuf;
865   - volatile uchar *pbuf_even;
866   - volatile uchar *pbuf_odd;
  868 + uchar *dbuf;
  869 + volatile uchar *pbuf_even;
  870 + volatile uchar *pbuf_odd;
867 871  
868   - pbuf_even = (uchar *)(ATA_CURR_BASE(dev)+ATA_DATA_EVEN);
869   - pbuf_odd = (uchar *)(ATA_CURR_BASE(dev)+ATA_DATA_ODD);
870   - dbuf = (uchar *)sect_buf;
  872 + pbuf_even = (uchar *) (ATA_CURR_BASE(dev) + ATA_DATA_EVEN);
  873 + pbuf_odd = (uchar *) (ATA_CURR_BASE(dev) + ATA_DATA_ODD);
  874 + dbuf = (uchar *) sect_buf;
871 875 while (words--) {
872 876 EIEIO;
873 877 *pbuf_even = *dbuf++;
874 878  
... ... @@ -879,11 +883,11 @@
879 883 *pbuf_odd = *dbuf++;
880 884 }
881 885 #else
882   - ushort *dbuf;
883   - volatile ushort *pbuf;
  886 + ushort *dbuf;
  887 + volatile ushort *pbuf;
884 888  
885   - pbuf = (ushort *)(ATA_CURR_BASE(dev)+ATA_DATA_REG);
886   - dbuf = (ushort *)sect_buf;
  889 + pbuf = (ushort *) (ATA_CURR_BASE(dev) + ATA_DATA_REG);
  890 + dbuf = (ushort *) sect_buf;
887 891 while (words--) {
888 892 #if defined(CONFIG_PCS440EP)
889 893 /* not tested, because CF was write protected */
890 894  
891 895  
892 896  
893 897  
894 898  
... ... @@ -900,30 +904,28 @@
900 904 }
901 905 #endif
902 906 }
903   -#else /* ! CONFIG_IDE_SWAP_IO */
904   -static void
905   -output_data(int dev, const ulong *sect_buf, int words)
  907 +#else /* ! CONFIG_IDE_SWAP_IO */
  908 +static void output_data(int dev, const ulong *sect_buf, int words)
906 909 {
907 910 #if defined(CONFIG_IDE_AHB)
908 911 ide_write_data(dev, sect_buf, words);
909 912 #else
910   - outsw(ATA_CURR_BASE(dev)+ATA_DATA_REG, sect_buf, words << 1);
  913 + outsw(ATA_CURR_BASE(dev) + ATA_DATA_REG, sect_buf, words << 1);
911 914 #endif
912 915 }
913   -#endif /* CONFIG_IDE_SWAP_IO */
  916 +#endif /* CONFIG_IDE_SWAP_IO */
914 917  
915 918 #if defined(CONFIG_IDE_SWAP_IO)
916   -static void
917   -input_data(int dev, ulong *sect_buf, int words)
  919 +static void input_data(int dev, ulong *sect_buf, int words)
918 920 {
919 921 #if defined(CONFIG_CPC45)
920   - uchar *dbuf;
921   - volatile uchar *pbuf_even;
922   - volatile uchar *pbuf_odd;
  922 + uchar *dbuf;
  923 + volatile uchar *pbuf_even;
  924 + volatile uchar *pbuf_odd;
923 925  
924   - pbuf_even = (uchar *)(ATA_CURR_BASE(dev)+ATA_DATA_EVEN);
925   - pbuf_odd = (uchar *)(ATA_CURR_BASE(dev)+ATA_DATA_ODD);
926   - dbuf = (uchar *)sect_buf;
  926 + pbuf_even = (uchar *) (ATA_CURR_BASE(dev) + ATA_DATA_EVEN);
  927 + pbuf_odd = (uchar *) (ATA_CURR_BASE(dev) + ATA_DATA_ODD);
  928 + dbuf = (uchar *) sect_buf;
927 929 while (words--) {
928 930 *dbuf++ = *pbuf_even;
929 931 EIEIO;
930 932  
... ... @@ -939,11 +941,11 @@
939 941 SYNC;
940 942 }
941 943 #else
942   - ushort *dbuf;
943   - volatile ushort *pbuf;
  944 + ushort *dbuf;
  945 + volatile ushort *pbuf;
944 946  
945   - pbuf = (ushort *)(ATA_CURR_BASE(dev)+ATA_DATA_REG);
946   - dbuf = (ushort *)sect_buf;
  947 + pbuf = (ushort *) (ATA_CURR_BASE(dev) + ATA_DATA_REG);
  948 + dbuf = (ushort *) sect_buf;
947 949  
948 950 debug("in input data base for read is %lx\n", (unsigned long) pbuf);
949 951  
950 952  
951 953  
952 954  
... ... @@ -962,22 +964,21 @@
962 964 }
963 965 #endif
964 966 }
965   -#else /* ! CONFIG_IDE_SWAP_IO */
966   -static void
967   -input_data(int dev, ulong *sect_buf, int words)
  967 +#else /* ! CONFIG_IDE_SWAP_IO */
  968 +static void input_data(int dev, ulong *sect_buf, int words)
968 969 {
969 970 #if defined(CONFIG_IDE_AHB)
970 971 ide_read_data(dev, sect_buf, words);
971 972 #else
972   - insw(ATA_CURR_BASE(dev)+ATA_DATA_REG, sect_buf, words << 1);
  973 + insw(ATA_CURR_BASE(dev) + ATA_DATA_REG, sect_buf, words << 1);
973 974 #endif
974 975 }
975 976  
976   -#endif /* CONFIG_IDE_SWAP_IO */
  977 +#endif /* CONFIG_IDE_SWAP_IO */
977 978  
978 979 /* -------------------------------------------------------------------------
979 980 */
980   -static void ide_ident (block_dev_desc_t *dev_desc)
  981 +static void ide_ident(block_dev_desc_t *dev_desc)
981 982 {
982 983 unsigned char c;
983 984 hd_driveid_t iop;
984 985  
985 986  
986 987  
987 988  
988 989  
989 990  
990 991  
991 992  
992 993  
993 994  
994 995  
995 996  
996 997  
997 998  
... ... @@ -995,82 +996,95 @@
995 996 int mode, cycle_time;
996 997 #endif
997 998 int device;
998   - device=dev_desc->dev;
999   - printf (" Device %d: ", device);
1000 999  
1001   - ide_led (DEVICE_LED(device), 1); /* LED on */
  1000 + device = dev_desc->dev;
  1001 + printf(" Device %d: ", device);
  1002 +
  1003 + ide_led(DEVICE_LED(device), 1); /* LED on */
1002 1004 /* Select device
1003 1005 */
1004   - ide_outb (device, ATA_DEV_HD, ATA_LBA | ATA_DEVICE(device));
1005   - dev_desc->if_type=IF_TYPE_IDE;
  1006 + ide_outb(device, ATA_DEV_HD, ATA_LBA | ATA_DEVICE(device));
  1007 + dev_desc->if_type = IF_TYPE_IDE;
1006 1008 #ifdef CONFIG_ATAPI
1007 1009  
1008   - do_retry = 0;
1009   - retries = 0;
  1010 + do_retry = 0;
  1011 + retries = 0;
1010 1012  
1011   - /* Warning: This will be tricky to read */
1012   - while (retries <= 1) {
1013   - /* check signature */
1014   - if ((ide_inb(device,ATA_SECT_CNT) == 0x01) &&
1015   - (ide_inb(device,ATA_SECT_NUM) == 0x01) &&
1016   - (ide_inb(device,ATA_CYL_LOW) == 0x14) &&
1017   - (ide_inb(device,ATA_CYL_HIGH) == 0xEB)) {
1018   - /* ATAPI Signature found */
1019   - dev_desc->if_type=IF_TYPE_ATAPI;
1020   - /* Start Ident Command
1021   - */
1022   - ide_outb (device, ATA_COMMAND, ATAPI_CMD_IDENT);
1023   - /*
1024   - * Wait for completion - ATAPI devices need more time
1025   - * to become ready
1026   - */
1027   - c = ide_wait (device, ATAPI_TIME_OUT);
1028   - } else
  1013 + /* Warning: This will be tricky to read */
  1014 + while (retries <= 1) {
  1015 + /* check signature */
  1016 + if ((ide_inb(device, ATA_SECT_CNT) == 0x01) &&
  1017 + (ide_inb(device, ATA_SECT_NUM) == 0x01) &&
  1018 + (ide_inb(device, ATA_CYL_LOW) == 0x14) &&
  1019 + (ide_inb(device, ATA_CYL_HIGH) == 0xEB)) {
  1020 + /* ATAPI Signature found */
  1021 + dev_desc->if_type = IF_TYPE_ATAPI;
  1022 + /*
  1023 + * Start Ident Command
  1024 + */
  1025 + ide_outb(device, ATA_COMMAND, ATAPI_CMD_IDENT);
  1026 + /*
  1027 + * Wait for completion - ATAPI devices need more time
  1028 + * to become ready
  1029 + */
  1030 + c = ide_wait(device, ATAPI_TIME_OUT);
  1031 + } else
1029 1032 #endif
1030   - {
1031   - /* Start Ident Command
1032   - */
1033   - ide_outb (device, ATA_COMMAND, ATA_CMD_IDENT);
  1033 + {
  1034 + /*
  1035 + * Start Ident Command
  1036 + */
  1037 + ide_outb(device, ATA_COMMAND, ATA_CMD_IDENT);
1034 1038  
1035   - /* Wait for completion
1036   - */
1037   - c = ide_wait (device, IDE_TIME_OUT);
1038   - }
1039   - ide_led (DEVICE_LED(device), 0); /* LED off */
  1039 + /*
  1040 + * Wait for completion
  1041 + */
  1042 + c = ide_wait(device, IDE_TIME_OUT);
  1043 + }
  1044 + ide_led(DEVICE_LED(device), 0); /* LED off */
1040 1045  
1041   - if (((c & ATA_STAT_DRQ) == 0) ||
1042   - ((c & (ATA_STAT_FAULT|ATA_STAT_ERR)) != 0) ) {
  1046 + if (((c & ATA_STAT_DRQ) == 0) ||
  1047 + ((c & (ATA_STAT_FAULT | ATA_STAT_ERR)) != 0)) {
1043 1048 #ifdef CONFIG_ATAPI
1044   - {
1045   - /* Need to soft reset the device in case it's an ATAPI... */
1046   - debug ("Retrying...\n");
1047   - ide_outb (device, ATA_DEV_HD, ATA_LBA | ATA_DEVICE(device));
1048   - udelay(100000);
1049   - ide_outb (device, ATA_COMMAND, 0x08);
1050   - udelay (500000); /* 500 ms */
1051   - }
1052   - /* Select device
1053   - */
1054   - ide_outb (device, ATA_DEV_HD, ATA_LBA | ATA_DEVICE(device));
1055   - retries++;
  1049 + {
  1050 + /*
  1051 + * Need to soft reset the device
  1052 + * in case it's an ATAPI...
  1053 + */
  1054 + debug("Retrying...\n");
  1055 + ide_outb(device, ATA_DEV_HD,
  1056 + ATA_LBA | ATA_DEVICE(device));
  1057 + udelay(100000);
  1058 + ide_outb(device, ATA_COMMAND, 0x08);
  1059 + udelay(500000); /* 500 ms */
  1060 + }
  1061 + /*
  1062 + * Select device
  1063 + */
  1064 + ide_outb(device, ATA_DEV_HD,
  1065 + ATA_LBA | ATA_DEVICE(device));
  1066 + retries++;
1056 1067 #else
1057   - return;
  1068 + return;
1058 1069 #endif
1059   - }
  1070 + }
1060 1071 #ifdef CONFIG_ATAPI
1061   - else
1062   - break;
1063   - } /* see above - ugly to read */
  1072 + else
  1073 + break;
  1074 + } /* see above - ugly to read */
1064 1075  
1065   - if (retries == 2) /* Not found */
  1076 + if (retries == 2) /* Not found */
1066 1077 return;
1067 1078 #endif
1068 1079  
1069   - input_swap_data (device, (ulong *)&iop, ATA_SECTORWORDS);
  1080 + input_swap_data(device, (ulong *)&iop, ATA_SECTORWORDS);
1070 1081  
1071   - ident_cpy ((unsigned char*)dev_desc->revision, iop.fw_rev, sizeof(dev_desc->revision));
1072   - ident_cpy ((unsigned char*)dev_desc->vendor, iop.model, sizeof(dev_desc->vendor));
1073   - ident_cpy ((unsigned char*)dev_desc->product, iop.serial_no, sizeof(dev_desc->product));
  1082 + ident_cpy((unsigned char *) dev_desc->revision, iop.fw_rev,
  1083 + sizeof(dev_desc->revision));
  1084 + ident_cpy((unsigned char *) dev_desc->vendor, iop.model,
  1085 + sizeof(dev_desc->vendor));
  1086 + ident_cpy((unsigned char *) dev_desc->product, iop.serial_no,
  1087 + sizeof(dev_desc->product));
1074 1088 #ifdef __LITTLE_ENDIAN
1075 1089 /*
1076 1090 * firmware revision, model, and serial number have Big Endian Byte
... ... @@ -1080,9 +1094,9 @@
1080 1094 * 6.2.1.6: Identify Drive, Table 39 for more details
1081 1095 */
1082 1096  
1083   - strswab (dev_desc->revision);
1084   - strswab (dev_desc->vendor);
1085   - strswab (dev_desc->product);
  1097 + strswab(dev_desc->revision);
  1098 + strswab(dev_desc->vendor);
  1099 + strswab(dev_desc->product);
1086 1100 #endif /* __LITTLE_ENDIAN */
1087 1101  
1088 1102 if ((iop.config & 0x0080) == 0x0080)
... ... @@ -1095,7 +1109,8 @@
1095 1109 pio_mode = iop.tPIO;
1096 1110 if (pio_mode > 2) {
1097 1111 printf("WARNING: Invalid PIO (word 51 = %d).\n", pio_mode);
1098   - pio_mode = 0; /* Force it to dead slow, and hope for the best... */
  1112 + /* Force it to dead slow, and hope for the best... */
  1113 + pio_mode = 0;
1099 1114 }
1100 1115  
1101 1116 /* Any CompactFlash Storage Card that supports PIO mode 3 or above
... ... @@ -1103,7 +1118,8 @@
1103 1118 * in words 64 through 70.
1104 1119 */
1105 1120 if (iop.field_valid & 0x02) {
1106   - /* Mode 3 and above are possible. Check in order from slow
  1121 + /*
  1122 + * Mode 3 and above are possible. Check in order from slow
1107 1123 * to fast, so we wind up with the highest mode allowed.
1108 1124 */
1109 1125 if (iop.eide_pio_modes & 0x01)
1110 1126  
1111 1127  
1112 1128  
1113 1129  
1114 1130  
1115 1131  
... ... @@ -1128,30 +1144,34 @@
1128 1144 */
1129 1145 mode = iop.tPIO;
1130 1146  
1131   - printf ("tPIO = 0x%02x = %d\n",mode, mode);
  1147 + printf("tPIO = 0x%02x = %d\n", mode, mode);
1132 1148 if (mode > 2) { /* 2 is maximum allowed tPIO value */
1133 1149 mode = 2;
1134   - debug ("Override tPIO -> 2\n");
  1150 + debug("Override tPIO -> 2\n");
1135 1151 }
1136 1152 if (iop.field_valid & 2) { /* drive implements ATA2? */
1137   - debug ("Drive implements ATA2\n");
  1153 + debug("Drive implements ATA2\n");
1138 1154 if (iop.capability & 8) { /* drive supports use_iordy? */
1139 1155 cycle_time = iop.eide_pio_iordy;
1140 1156 } else {
1141 1157 cycle_time = iop.eide_pio;
1142 1158 }
1143   - debug ("cycle time = %d\n", cycle_time);
  1159 + debug("cycle time = %d\n", cycle_time);
1144 1160 mode = 4;
1145   - if (cycle_time > 120) mode = 3; /* 120 ns for PIO mode 4 */
1146   - if (cycle_time > 180) mode = 2; /* 180 ns for PIO mode 3 */
1147   - if (cycle_time > 240) mode = 1; /* 240 ns for PIO mode 4 */
1148   - if (cycle_time > 383) mode = 0; /* 383 ns for PIO mode 4 */
  1161 + if (cycle_time > 120)
  1162 + mode = 3; /* 120 ns for PIO mode 4 */
  1163 + if (cycle_time > 180)
  1164 + mode = 2; /* 180 ns for PIO mode 3 */
  1165 + if (cycle_time > 240)
  1166 + mode = 1; /* 240 ns for PIO mode 4 */
  1167 + if (cycle_time > 383)
  1168 + mode = 0; /* 383 ns for PIO mode 4 */
1149 1169 }
1150   - printf ("PIO mode to use: PIO %d\n", mode);
  1170 + printf("PIO mode to use: PIO %d\n", mode);
1151 1171 #endif /* 0 */
1152 1172  
1153 1173 #ifdef CONFIG_ATAPI
1154   - if (dev_desc->if_type==IF_TYPE_ATAPI) {
  1174 + if (dev_desc->if_type == IF_TYPE_ATAPI) {
1155 1175 atapi_inquiry(dev_desc);
1156 1176 return;
1157 1177 }
... ... @@ -1160,7 +1180,7 @@
1160 1180 #ifdef __BIG_ENDIAN
1161 1181 /* swap shorts */
1162 1182 dev_desc->lba = (iop.lba_capacity << 16) | (iop.lba_capacity >> 16);
1163   -#else /* ! __BIG_ENDIAN */
  1183 +#else /* ! __BIG_ENDIAN */
1164 1184 /*
1165 1185 * do not swap shorts on little endian
1166 1186 *
1167 1187  
1168 1188  
1169 1189  
1170 1190  
1171 1191  
1172 1192  
... ... @@ -1168,48 +1188,49 @@
1168 1188 * 6.2.1.6: Identfy Drive, Table 39, Word Address 57-58 for details.
1169 1189 */
1170 1190 dev_desc->lba = iop.lba_capacity;
1171   -#endif /* __BIG_ENDIAN */
  1191 +#endif /* __BIG_ENDIAN */
1172 1192  
1173 1193 #ifdef CONFIG_LBA48
1174   - if (iop.command_set_2 & 0x0400) { /* LBA 48 support */
  1194 + if (iop.command_set_2 & 0x0400) { /* LBA 48 support */
1175 1195 dev_desc->lba48 = 1;
1176   - dev_desc->lba = (unsigned long long)iop.lba48_capacity[0] |
1177   - ((unsigned long long)iop.lba48_capacity[1] << 16) |
1178   - ((unsigned long long)iop.lba48_capacity[2] << 32) |
1179   - ((unsigned long long)iop.lba48_capacity[3] << 48);
  1196 + dev_desc->lba = (unsigned long long) iop.lba48_capacity[0] |
  1197 + ((unsigned long long) iop.lba48_capacity[1] << 16) |
  1198 + ((unsigned long long) iop.lba48_capacity[2] << 32) |
  1199 + ((unsigned long long) iop.lba48_capacity[3] << 48);
1180 1200 } else {
1181 1201 dev_desc->lba48 = 0;
1182 1202 }
1183 1203 #endif /* CONFIG_LBA48 */
1184 1204 /* assuming HD */
1185   - dev_desc->type=DEV_TYPE_HARDDISK;
1186   - dev_desc->blksz=ATA_BLOCKSIZE;
1187   - dev_desc->lun=0; /* just to fill something in... */
  1205 + dev_desc->type = DEV_TYPE_HARDDISK;
  1206 + dev_desc->blksz = ATA_BLOCKSIZE;
  1207 + dev_desc->lun = 0; /* just to fill something in... */
1188 1208  
1189   -#if 0 /* only used to test the powersaving mode,
1190   - * if enabled, the drive goes after 5 sec
1191   - * in standby mode */
1192   - ide_outb (device, ATA_DEV_HD, ATA_LBA | ATA_DEVICE(device));
1193   - c = ide_wait (device, IDE_TIME_OUT);
1194   - ide_outb (device, ATA_SECT_CNT, 1);
1195   - ide_outb (device, ATA_LBA_LOW, 0);
1196   - ide_outb (device, ATA_LBA_MID, 0);
1197   - ide_outb (device, ATA_LBA_HIGH, 0);
1198   - ide_outb (device, ATA_DEV_HD, ATA_LBA | ATA_DEVICE(device));
1199   - ide_outb (device, ATA_COMMAND, 0xe3);
1200   - udelay (50);
1201   - c = ide_wait (device, IDE_TIME_OUT); /* can't take over 500 ms */
  1209 +#if 0 /* only used to test the powersaving mode,
  1210 + * if enabled, the drive goes after 5 sec
  1211 + * in standby mode */
  1212 + ide_outb(device, ATA_DEV_HD, ATA_LBA | ATA_DEVICE(device));
  1213 + c = ide_wait(device, IDE_TIME_OUT);
  1214 + ide_outb(device, ATA_SECT_CNT, 1);
  1215 + ide_outb(device, ATA_LBA_LOW, 0);
  1216 + ide_outb(device, ATA_LBA_MID, 0);
  1217 + ide_outb(device, ATA_LBA_HIGH, 0);
  1218 + ide_outb(device, ATA_DEV_HD, ATA_LBA | ATA_DEVICE(device));
  1219 + ide_outb(device, ATA_COMMAND, 0xe3);
  1220 + udelay(50);
  1221 + c = ide_wait(device, IDE_TIME_OUT); /* can't take over 500 ms */
1202 1222 #endif
1203 1223 }
1204 1224  
1205 1225  
1206 1226 /* ------------------------------------------------------------------------- */
1207 1227  
1208   -ulong ide_read (int device, lbaint_t blknr, ulong blkcnt, void *buffer)
  1228 +ulong ide_read(int device, lbaint_t blknr, ulong blkcnt, void *buffer)
1209 1229 {
1210 1230 ulong n = 0;
1211 1231 unsigned char c;
1212   - unsigned char pwrsave=0; /* power save */
  1232 + unsigned char pwrsave = 0; /* power save */
  1233 +
1213 1234 #ifdef CONFIG_LBA48
1214 1235 unsigned char lba48 = 0;
1215 1236  
1216 1237  
1217 1238  
1218 1239  
1219 1240  
1220 1241  
1221 1242  
1222 1243  
1223 1244  
1224 1245  
1225 1246  
1226 1247  
1227 1248  
1228 1249  
1229 1250  
1230 1251  
1231 1252  
1232 1253  
1233 1254  
1234 1255  
1235 1256  
1236 1257  
1237 1258  
1238 1259  
1239 1260  
1240 1261  
1241 1262  
... ... @@ -1219,121 +1240,125 @@
1219 1240 }
1220 1241 #endif
1221 1242 debug("ide_read dev %d start %lX, blocks %lX buffer at %lX\n",
1222   - device, blknr, blkcnt, (ulong)buffer);
  1243 + device, blknr, blkcnt, (ulong) buffer);
1223 1244  
1224   - ide_led (DEVICE_LED(device), 1); /* LED on */
  1245 + ide_led(DEVICE_LED(device), 1); /* LED on */
1225 1246  
1226 1247 /* Select device
1227 1248 */
1228   - ide_outb (device, ATA_DEV_HD, ATA_LBA | ATA_DEVICE(device));
1229   - c = ide_wait (device, IDE_TIME_OUT);
  1249 + ide_outb(device, ATA_DEV_HD, ATA_LBA | ATA_DEVICE(device));
  1250 + c = ide_wait(device, IDE_TIME_OUT);
1230 1251  
1231 1252 if (c & ATA_STAT_BUSY) {
1232   - printf ("IDE read: device %d not ready\n", device);
  1253 + printf("IDE read: device %d not ready\n", device);
1233 1254 goto IDE_READ_E;
1234 1255 }
1235 1256  
1236 1257 /* first check if the drive is in Powersaving mode, if yes,
1237 1258 * increase the timeout value */
1238   - ide_outb (device, ATA_COMMAND, ATA_CMD_CHK_PWR);
1239   - udelay (50);
  1259 + ide_outb(device, ATA_COMMAND, ATA_CMD_CHK_PWR);
  1260 + udelay(50);
1240 1261  
1241   - c = ide_wait (device, IDE_TIME_OUT); /* can't take over 500 ms */
  1262 + c = ide_wait(device, IDE_TIME_OUT); /* can't take over 500 ms */
1242 1263  
1243 1264 if (c & ATA_STAT_BUSY) {
1244   - printf ("IDE read: device %d not ready\n", device);
  1265 + printf("IDE read: device %d not ready\n", device);
1245 1266 goto IDE_READ_E;
1246 1267 }
1247 1268 if ((c & ATA_STAT_ERR) == ATA_STAT_ERR) {
1248   - printf ("No Powersaving mode %X\n", c);
  1269 + printf("No Powersaving mode %X\n", c);
1249 1270 } else {
1250   - c = ide_inb(device,ATA_SECT_CNT);
1251   - debug ("Powersaving %02X\n",c);
1252   - if(c==0)
1253   - pwrsave=1;
  1271 + c = ide_inb(device, ATA_SECT_CNT);
  1272 + debug("Powersaving %02X\n", c);
  1273 + if (c == 0)
  1274 + pwrsave = 1;
1254 1275 }
1255 1276  
1256 1277  
1257 1278 while (blkcnt-- > 0) {
1258 1279  
1259   - c = ide_wait (device, IDE_TIME_OUT);
  1280 + c = ide_wait(device, IDE_TIME_OUT);
1260 1281  
1261 1282 if (c & ATA_STAT_BUSY) {
1262   - printf ("IDE read: device %d not ready\n", device);
  1283 + printf("IDE read: device %d not ready\n", device);
1263 1284 break;
1264 1285 }
1265 1286 #ifdef CONFIG_LBA48
1266 1287 if (lba48) {
1267 1288 /* write high bits */
1268   - ide_outb (device, ATA_SECT_CNT, 0);
1269   - ide_outb (device, ATA_LBA_LOW, (blknr >> 24) & 0xFF);
  1289 + ide_outb(device, ATA_SECT_CNT, 0);
  1290 + ide_outb(device, ATA_LBA_LOW, (blknr >> 24) & 0xFF);
1270 1291 #ifdef CONFIG_SYS_64BIT_LBA
1271   - ide_outb (device, ATA_LBA_MID, (blknr >> 32) & 0xFF);
1272   - ide_outb (device, ATA_LBA_HIGH, (blknr >> 40) & 0xFF);
  1292 + ide_outb(device, ATA_LBA_MID, (blknr >> 32) & 0xFF);
  1293 + ide_outb(device, ATA_LBA_HIGH, (blknr >> 40) & 0xFF);
1273 1294 #else
1274   - ide_outb (device, ATA_LBA_MID, 0);
1275   - ide_outb (device, ATA_LBA_HIGH, 0);
  1295 + ide_outb(device, ATA_LBA_MID, 0);
  1296 + ide_outb(device, ATA_LBA_HIGH, 0);
1276 1297 #endif
1277 1298 }
1278 1299 #endif
1279   - ide_outb (device, ATA_SECT_CNT, 1);
1280   - ide_outb (device, ATA_LBA_LOW, (blknr >> 0) & 0xFF);
1281   - ide_outb (device, ATA_LBA_MID, (blknr >> 8) & 0xFF);
1282   - ide_outb (device, ATA_LBA_HIGH, (blknr >> 16) & 0xFF);
  1300 + ide_outb(device, ATA_SECT_CNT, 1);
  1301 + ide_outb(device, ATA_LBA_LOW, (blknr >> 0) & 0xFF);
  1302 + ide_outb(device, ATA_LBA_MID, (blknr >> 8) & 0xFF);
  1303 + ide_outb(device, ATA_LBA_HIGH, (blknr >> 16) & 0xFF);
1283 1304  
1284 1305 #ifdef CONFIG_LBA48
1285 1306 if (lba48) {
1286   - ide_outb (device, ATA_DEV_HD, ATA_LBA | ATA_DEVICE(device) );
1287   - ide_outb (device, ATA_COMMAND, ATA_CMD_READ_EXT);
  1307 + ide_outb(device, ATA_DEV_HD,
  1308 + ATA_LBA | ATA_DEVICE(device));
  1309 + ide_outb(device, ATA_COMMAND, ATA_CMD_READ_EXT);
1288 1310  
1289 1311 } else
1290 1312 #endif
1291 1313 {
1292   - ide_outb (device, ATA_DEV_HD, ATA_LBA |
1293   - ATA_DEVICE(device) |
1294   - ((blknr >> 24) & 0xF) );
1295   - ide_outb (device, ATA_COMMAND, ATA_CMD_READ);
  1314 + ide_outb(device, ATA_DEV_HD, ATA_LBA |
  1315 + ATA_DEVICE(device) | ((blknr >> 24) & 0xF));
  1316 + ide_outb(device, ATA_COMMAND, ATA_CMD_READ);
1296 1317 }
1297 1318  
1298   - udelay (50);
  1319 + udelay(50);
1299 1320  
1300   - if(pwrsave) {
1301   - c = ide_wait (device, IDE_SPIN_UP_TIME_OUT); /* may take up to 4 sec */
1302   - pwrsave=0;
  1321 + if (pwrsave) {
  1322 + /* may take up to 4 sec */
  1323 + c = ide_wait(device, IDE_SPIN_UP_TIME_OUT);
  1324 + pwrsave = 0;
1303 1325 } else {
1304   - c = ide_wait (device, IDE_TIME_OUT); /* can't take over 500 ms */
  1326 + /* can't take over 500 ms */
  1327 + c = ide_wait(device, IDE_TIME_OUT);
1305 1328 }
1306 1329  
1307   - if ((c&(ATA_STAT_DRQ|ATA_STAT_BUSY|ATA_STAT_ERR)) != ATA_STAT_DRQ) {
  1330 + if ((c & (ATA_STAT_DRQ | ATA_STAT_BUSY | ATA_STAT_ERR)) !=
  1331 + ATA_STAT_DRQ) {
1308 1332 #if defined(CONFIG_SYS_64BIT_LBA)
1309   - printf ("Error (no IRQ) dev %d blk %Ld: status 0x%02x\n",
  1333 + printf("Error (no IRQ) dev %d blk %lld: status 0x%02x\n",
1310 1334 device, blknr, c);
1311 1335 #else
1312   - printf ("Error (no IRQ) dev %d blk %ld: status 0x%02x\n",
1313   - device, (ulong)blknr, c);
  1336 + printf("Error (no IRQ) dev %d blk %ld: status 0x%02x\n",
  1337 + device, (ulong) blknr, c);
1314 1338 #endif
1315 1339 break;
1316 1340 }
1317 1341  
1318   - input_data (device, buffer, ATA_SECTORWORDS);
1319   - (void) ide_inb (device, ATA_STATUS); /* clear IRQ */
  1342 + input_data(device, buffer, ATA_SECTORWORDS);
  1343 + (void) ide_inb(device, ATA_STATUS); /* clear IRQ */
1320 1344  
1321 1345 ++n;
1322 1346 ++blknr;
1323 1347 buffer += ATA_BLOCKSIZE;
1324 1348 }
1325 1349 IDE_READ_E:
1326   - ide_led (DEVICE_LED(device), 0); /* LED off */
  1350 + ide_led(DEVICE_LED(device), 0); /* LED off */
1327 1351 return (n);
1328 1352 }
1329 1353  
1330 1354 /* ------------------------------------------------------------------------- */
1331 1355  
1332 1356  
1333   -ulong ide_write (int device, lbaint_t blknr, ulong blkcnt, const void *buffer)
  1357 +ulong ide_write(int device, lbaint_t blknr, ulong blkcnt, const void *buffer)
1334 1358 {
1335 1359 ulong n = 0;
1336 1360 unsigned char c;
  1361 +
1337 1362 #ifdef CONFIG_LBA48
1338 1363 unsigned char lba48 = 0;
1339 1364  
1340 1365  
1341 1366  
1342 1367  
1343 1368  
1344 1369  
1345 1370  
1346 1371  
1347 1372  
1348 1373  
1349 1374  
1350 1375  
1351 1376  
1352 1377  
1353 1378  
1354 1379  
1355 1380  
... ... @@ -1343,76 +1368,78 @@
1343 1368 }
1344 1369 #endif
1345 1370  
1346   - ide_led (DEVICE_LED(device), 1); /* LED on */
  1371 + ide_led(DEVICE_LED(device), 1); /* LED on */
1347 1372  
1348 1373 /* Select device
1349 1374 */
1350   - ide_outb (device, ATA_DEV_HD, ATA_LBA | ATA_DEVICE(device));
  1375 + ide_outb(device, ATA_DEV_HD, ATA_LBA | ATA_DEVICE(device));
1351 1376  
1352 1377 while (blkcnt-- > 0) {
1353 1378  
1354   - c = ide_wait (device, IDE_TIME_OUT);
  1379 + c = ide_wait(device, IDE_TIME_OUT);
1355 1380  
1356 1381 if (c & ATA_STAT_BUSY) {
1357   - printf ("IDE read: device %d not ready\n", device);
  1382 + printf("IDE read: device %d not ready\n", device);
1358 1383 goto WR_OUT;
1359 1384 }
1360 1385 #ifdef CONFIG_LBA48
1361 1386 if (lba48) {
1362 1387 /* write high bits */
1363   - ide_outb (device, ATA_SECT_CNT, 0);
1364   - ide_outb (device, ATA_LBA_LOW, (blknr >> 24) & 0xFF);
  1388 + ide_outb(device, ATA_SECT_CNT, 0);
  1389 + ide_outb(device, ATA_LBA_LOW, (blknr >> 24) & 0xFF);
1365 1390 #ifdef CONFIG_SYS_64BIT_LBA
1366   - ide_outb (device, ATA_LBA_MID, (blknr >> 32) & 0xFF);
1367   - ide_outb (device, ATA_LBA_HIGH, (blknr >> 40) & 0xFF);
  1391 + ide_outb(device, ATA_LBA_MID, (blknr >> 32) & 0xFF);
  1392 + ide_outb(device, ATA_LBA_HIGH, (blknr >> 40) & 0xFF);
1368 1393 #else
1369   - ide_outb (device, ATA_LBA_MID, 0);
1370   - ide_outb (device, ATA_LBA_HIGH, 0);
  1394 + ide_outb(device, ATA_LBA_MID, 0);
  1395 + ide_outb(device, ATA_LBA_HIGH, 0);
1371 1396 #endif
1372 1397 }
1373 1398 #endif
1374   - ide_outb (device, ATA_SECT_CNT, 1);
1375   - ide_outb (device, ATA_LBA_LOW, (blknr >> 0) & 0xFF);
1376   - ide_outb (device, ATA_LBA_MID, (blknr >> 8) & 0xFF);
1377   - ide_outb (device, ATA_LBA_HIGH, (blknr >> 16) & 0xFF);
  1399 + ide_outb(device, ATA_SECT_CNT, 1);
  1400 + ide_outb(device, ATA_LBA_LOW, (blknr >> 0) & 0xFF);
  1401 + ide_outb(device, ATA_LBA_MID, (blknr >> 8) & 0xFF);
  1402 + ide_outb(device, ATA_LBA_HIGH, (blknr >> 16) & 0xFF);
1378 1403  
1379 1404 #ifdef CONFIG_LBA48
1380 1405 if (lba48) {
1381   - ide_outb (device, ATA_DEV_HD, ATA_LBA | ATA_DEVICE(device) );
1382   - ide_outb (device, ATA_COMMAND, ATA_CMD_WRITE_EXT);
  1406 + ide_outb(device, ATA_DEV_HD,
  1407 + ATA_LBA | ATA_DEVICE(device));
  1408 + ide_outb(device, ATA_COMMAND, ATA_CMD_WRITE_EXT);
1383 1409  
1384 1410 } else
1385 1411 #endif
1386 1412 {
1387   - ide_outb (device, ATA_DEV_HD, ATA_LBA |
1388   - ATA_DEVICE(device) |
1389   - ((blknr >> 24) & 0xF) );
1390   - ide_outb (device, ATA_COMMAND, ATA_CMD_WRITE);
  1413 + ide_outb(device, ATA_DEV_HD, ATA_LBA |
  1414 + ATA_DEVICE(device) | ((blknr >> 24) & 0xF));
  1415 + ide_outb(device, ATA_COMMAND, ATA_CMD_WRITE);
1391 1416 }
1392 1417  
1393   - udelay (50);
  1418 + udelay(50);
1394 1419  
1395   - c = ide_wait (device, IDE_TIME_OUT); /* can't take over 500 ms */
  1420 + /* can't take over 500 ms */
  1421 + c = ide_wait(device, IDE_TIME_OUT);
1396 1422  
1397   - if ((c&(ATA_STAT_DRQ|ATA_STAT_BUSY|ATA_STAT_ERR)) != ATA_STAT_DRQ) {
  1423 + if ((c & (ATA_STAT_DRQ | ATA_STAT_BUSY | ATA_STAT_ERR)) !=
  1424 + ATA_STAT_DRQ) {
1398 1425 #if defined(CONFIG_SYS_64BIT_LBA)
1399   - printf ("Error (no IRQ) dev %d blk %Ld: status 0x%02x\n",
  1426 + printf("Error (no IRQ) dev %d blk %lld: status 0x%02x\n",
1400 1427 device, blknr, c);
1401 1428 #else
1402   - printf ("Error (no IRQ) dev %d blk %ld: status 0x%02x\n",
1403   - device, (ulong)blknr, c);
  1429 + printf("Error (no IRQ) dev %d blk %ld: status 0x%02x\n",
  1430 + device, (ulong) blknr, c);
1404 1431 #endif
1405 1432 goto WR_OUT;
1406 1433 }
1407 1434  
1408   - output_data (device, buffer, ATA_SECTORWORDS);
1409   - c = ide_inb (device, ATA_STATUS); /* clear IRQ */
  1435 + output_data(device, buffer, ATA_SECTORWORDS);
  1436 + c = ide_inb(device, ATA_STATUS); /* clear IRQ */
1410 1437 ++n;
1411 1438 ++blknr;
1412 1439 buffer += ATA_BLOCKSIZE;
1413 1440 }
1414 1441 WR_OUT:
1415   - ide_led (DEVICE_LED(device), 0); /* LED off */
  1442 + ide_led(DEVICE_LED(device), 0); /* LED off */
1416 1443 return (n);
1417 1444 }
1418 1445  
1419 1446  
1420 1447  
1421 1448  
... ... @@ -1423,23 +1450,24 @@
1423 1450 * terminate the string
1424 1451 * "len" is the size of available memory including the terminating '\0'
1425 1452 */
1426   -static void ident_cpy (unsigned char *dst, unsigned char *src, unsigned int len)
  1453 +static void ident_cpy(unsigned char *dst, unsigned char *src,
  1454 + unsigned int len)
1427 1455 {
1428 1456 unsigned char *end, *last;
1429 1457  
1430 1458 last = dst;
1431   - end = src + len - 1;
  1459 + end = src + len - 1;
1432 1460  
1433 1461 /* reserve space for '\0' */
1434 1462 if (len < 2)
1435 1463 goto OUT;
1436 1464  
1437 1465 /* skip leading white space */
1438   - while ((*src) && (src<end) && (*src==' '))
  1466 + while ((*src) && (src < end) && (*src == ' '))
1439 1467 ++src;
1440 1468  
1441 1469 /* copy string, omitting trailing white space */
1442   - while ((*src) && (src<end)) {
  1470 + while ((*src) && (src < end)) {
1443 1471 *dst++ = *src;
1444 1472 if (*src++ != ' ')
1445 1473 last = dst;
1446 1474  
1447 1475  
1448 1476  
... ... @@ -1454,16 +1482,15 @@
1454 1482 * Wait until Busy bit is off, or timeout (in ms)
1455 1483 * Return last status
1456 1484 */
1457   -static uchar ide_wait (int dev, ulong t)
  1485 +static uchar ide_wait(int dev, ulong t)
1458 1486 {
1459   - ulong delay = 10 * t; /* poll every 100 us */
  1487 + ulong delay = 10 * t; /* poll every 100 us */
1460 1488 uchar c;
1461 1489  
1462 1490 while ((c = ide_inb(dev, ATA_STATUS)) & ATA_STAT_BUSY) {
1463   - udelay (100);
1464   - if (delay-- == 0) {
  1491 + udelay(100);
  1492 + if (delay-- == 0)
1465 1493 break;
1466   - }
1467 1494 }
1468 1495 return (c);
1469 1496 }
1470 1497  
1471 1498  
1472 1499  
1473 1500  
... ... @@ -1473,20 +1500,20 @@
1473 1500 #ifdef CONFIG_IDE_RESET
1474 1501 extern void ide_set_reset(int idereset);
1475 1502  
1476   -static void ide_reset (void)
  1503 +static void ide_reset(void)
1477 1504 {
1478 1505 #if defined(CONFIG_SYS_PB_12V_ENABLE) || defined(CONFIG_SYS_PB_IDE_MOTOR)
1479   - volatile immap_t *immr = (immap_t *)CONFIG_SYS_IMMR;
  1506 + volatile immap_t *immr = (immap_t *) CONFIG_SYS_IMMR;
1480 1507 #endif
1481 1508 int i;
1482 1509  
1483 1510 curr_device = -1;
1484   - for (i=0; i<CONFIG_SYS_IDE_MAXBUS; ++i)
  1511 + for (i = 0; i < CONFIG_SYS_IDE_MAXBUS; ++i)
1485 1512 ide_bus_ok[i] = 0;
1486   - for (i=0; i<CONFIG_SYS_IDE_MAXDEVICE; ++i)
  1513 + for (i = 0; i < CONFIG_SYS_IDE_MAXDEVICE; ++i)
1487 1514 ide_dev_desc[i].type = DEV_TYPE_UNKNOWN;
1488 1515  
1489   - ide_set_reset (1); /* assert reset */
  1516 + ide_set_reset(1); /* assert reset */
1490 1517  
1491 1518 /* the reset signal shall be asserted for et least 25 us */
1492 1519 udelay(25);
1493 1520  
1494 1521  
1495 1522  
... ... @@ -1494,19 +1521,20 @@
1494 1521 WATCHDOG_RESET();
1495 1522  
1496 1523 #ifdef CONFIG_SYS_PB_12V_ENABLE
1497   - immr->im_cpm.cp_pbdat &= ~(CONFIG_SYS_PB_12V_ENABLE); /* 12V Enable output OFF */
  1524 + /* 12V Enable output OFF */
  1525 + immr->im_cpm.cp_pbdat &= ~(CONFIG_SYS_PB_12V_ENABLE);
  1526 +
1498 1527 immr->im_cpm.cp_pbpar &= ~(CONFIG_SYS_PB_12V_ENABLE);
1499 1528 immr->im_cpm.cp_pbodr &= ~(CONFIG_SYS_PB_12V_ENABLE);
1500   - immr->im_cpm.cp_pbdir |= CONFIG_SYS_PB_12V_ENABLE;
  1529 + immr->im_cpm.cp_pbdir |= CONFIG_SYS_PB_12V_ENABLE;
1501 1530  
1502   - /* wait 500 ms for the voltage to stabilize
1503   - */
1504   - for (i=0; i<500; ++i) {
1505   - udelay (1000);
1506   - }
  1531 + /* wait 500 ms for the voltage to stabilize */
  1532 + for (i = 0; i < 500; ++i)
  1533 + udelay(1000);
1507 1534  
1508   - immr->im_cpm.cp_pbdat |= CONFIG_SYS_PB_12V_ENABLE; /* 12V Enable output ON */
1509   -#endif /* CONFIG_SYS_PB_12V_ENABLE */
  1535 + /* 12V Enable output ON */
  1536 + immr->im_cpm.cp_pbdat |= CONFIG_SYS_PB_12V_ENABLE;
  1537 +#endif /* CONFIG_SYS_PB_12V_ENABLE */
1510 1538  
1511 1539 #ifdef CONFIG_SYS_PB_IDE_MOTOR
1512 1540 /* configure IDE Motor voltage monitor pin as input */
1513 1541  
1514 1542  
1515 1543  
... ... @@ -1514,27 +1542,26 @@
1514 1542 immr->im_cpm.cp_pbodr &= ~(CONFIG_SYS_PB_IDE_MOTOR);
1515 1543 immr->im_cpm.cp_pbdir &= ~(CONFIG_SYS_PB_IDE_MOTOR);
1516 1544  
1517   - /* wait up to 1 s for the motor voltage to stabilize
1518   - */
1519   - for (i=0; i<1000; ++i) {
  1545 + /* wait up to 1 s for the motor voltage to stabilize */
  1546 + for (i = 0; i < 1000; ++i) {
1520 1547 if ((immr->im_cpm.cp_pbdat & CONFIG_SYS_PB_IDE_MOTOR) != 0) {
1521 1548 break;
1522 1549 }
1523   - udelay (1000);
  1550 + udelay(1000);
1524 1551 }
1525 1552  
1526 1553 if (i == 1000) { /* Timeout */
1527   - printf ("\nWarning: 5V for IDE Motor missing\n");
1528   -# ifdef CONFIG_STATUS_LED
1529   -# ifdef STATUS_LED_YELLOW
1530   - status_led_set (STATUS_LED_YELLOW, STATUS_LED_ON );
1531   -# endif
1532   -# ifdef STATUS_LED_GREEN
1533   - status_led_set (STATUS_LED_GREEN, STATUS_LED_OFF);
1534   -# endif
1535   -# endif /* CONFIG_STATUS_LED */
  1554 + printf("\nWarning: 5V for IDE Motor missing\n");
  1555 +#ifdef CONFIG_STATUS_LED
  1556 +#ifdef STATUS_LED_YELLOW
  1557 + status_led_set(STATUS_LED_YELLOW, STATUS_LED_ON);
  1558 +#endif
  1559 +#ifdef STATUS_LED_GREEN
  1560 + status_led_set(STATUS_LED_GREEN, STATUS_LED_OFF);
  1561 +#endif
  1562 +#endif /* CONFIG_STATUS_LED */
1536 1563 }
1537   -#endif /* CONFIG_SYS_PB_IDE_MOTOR */
  1564 +#endif /* CONFIG_SYS_PB_IDE_MOTOR */
1538 1565  
1539 1566 WATCHDOG_RESET();
1540 1567  
1541 1568  
... ... @@ -1542,12 +1569,11 @@
1542 1569 ide_set_reset(0);
1543 1570  
1544 1571 /* wait 250 ms */
1545   - for (i=0; i<250; ++i) {
1546   - udelay (1000);
1547   - }
  1572 + for (i = 0; i < 250; ++i)
  1573 + udelay(1000);
1548 1574 }
1549 1575  
1550   -#endif /* CONFIG_IDE_RESET */
  1576 +#endif /* CONFIG_IDE_RESET */
1551 1577  
1552 1578 /* ------------------------------------------------------------------------- */
1553 1579  
1554 1580  
1555 1581  
1556 1582  
1557 1583  
... ... @@ -1556,22 +1582,21 @@
1556 1582 !defined(CONFIG_KUP4K) && \
1557 1583 !defined(CONFIG_KUP4X)
1558 1584  
1559   -static uchar led_buffer = 0; /* Buffer for current LED status */
  1585 +static uchar led_buffer; /* Buffer for current LED status */
1560 1586  
1561   -static void ide_led (uchar led, uchar status)
  1587 +static void ide_led(uchar led, uchar status)
1562 1588 {
1563 1589 uchar *led_port = LED_PORT;
1564 1590  
1565   - if (status) { /* switch LED on */
1566   - led_buffer |= led;
1567   - } else { /* switch LED off */
  1591 + if (status) /* switch LED on */
  1592 + led_buffer |= led;
  1593 + else /* switch LED off */
1568 1594 led_buffer &= ~led;
1569   - }
1570 1595  
1571 1596 *led_port = led_buffer;
1572 1597 }
1573 1598  
1574   -#endif /* CONFIG_IDE_LED */
  1599 +#endif /* CONFIG_IDE_LED */
1575 1600  
1576 1601 #if defined(CONFIG_OF_IDE_FIXUP)
1577 1602 int ide_device_present(int dev)
1578 1603  
1579 1604  
... ... @@ -1591,16 +1616,15 @@
1591 1616 #if defined(CONFIG_IDE_SWAP_IO)
1592 1617 /* since ATAPI may use commands with not 4 bytes alligned length
1593 1618 * we have our own transfer functions, 2 bytes alligned */
1594   -static void
1595   -output_data_shorts(int dev, ushort *sect_buf, int shorts)
  1619 +static void output_data_shorts(int dev, ushort *sect_buf, int shorts)
1596 1620 {
1597 1621 #if defined(CONFIG_CPC45)
1598   - uchar *dbuf;
1599   - volatile uchar *pbuf_even;
1600   - volatile uchar *pbuf_odd;
  1622 + uchar *dbuf;
  1623 + volatile uchar *pbuf_even;
  1624 + volatile uchar *pbuf_odd;
1601 1625  
1602   - pbuf_even = (uchar *)(ATA_CURR_BASE(dev)+ATA_DATA_EVEN);
1603   - pbuf_odd = (uchar *)(ATA_CURR_BASE(dev)+ATA_DATA_ODD);
  1626 + pbuf_even = (uchar *) (ATA_CURR_BASE(dev) + ATA_DATA_EVEN);
  1627 + pbuf_odd = (uchar *) (ATA_CURR_BASE(dev) + ATA_DATA_ODD);
1604 1628 while (shorts--) {
1605 1629 EIEIO;
1606 1630 *pbuf_even = *dbuf++;
1607 1631  
1608 1632  
... ... @@ -1608,13 +1632,14 @@
1608 1632 *pbuf_odd = *dbuf++;
1609 1633 }
1610 1634 #else
1611   - ushort *dbuf;
1612   - volatile ushort *pbuf;
  1635 + ushort *dbuf;
  1636 + volatile ushort *pbuf;
1613 1637  
1614   - pbuf = (ushort *)(ATA_CURR_BASE(dev)+ATA_DATA_REG);
1615   - dbuf = (ushort *)sect_buf;
  1638 + pbuf = (ushort *) (ATA_CURR_BASE(dev) + ATA_DATA_REG);
  1639 + dbuf = (ushort *) sect_buf;
1616 1640  
1617   - debug ("in output data shorts base for read is %lx\n", (unsigned long) pbuf);
  1641 + debug("in output data shorts base for read is %lx\n",
  1642 + (unsigned long) pbuf);
1618 1643  
1619 1644 while (shorts--) {
1620 1645 EIEIO;
1621 1646  
1622 1647  
... ... @@ -1623,16 +1648,15 @@
1623 1648 #endif
1624 1649 }
1625 1650  
1626   -static void
1627   -input_data_shorts(int dev, ushort *sect_buf, int shorts)
  1651 +static void input_data_shorts(int dev, ushort *sect_buf, int shorts)
1628 1652 {
1629 1653 #if defined(CONFIG_CPC45)
1630   - uchar *dbuf;
1631   - volatile uchar *pbuf_even;
1632   - volatile uchar *pbuf_odd;
  1654 + uchar *dbuf;
  1655 + volatile uchar *pbuf_even;
  1656 + volatile uchar *pbuf_odd;
1633 1657  
1634   - pbuf_even = (uchar *)(ATA_CURR_BASE(dev)+ATA_DATA_EVEN);
1635   - pbuf_odd = (uchar *)(ATA_CURR_BASE(dev)+ATA_DATA_ODD);
  1658 + pbuf_even = (uchar *) (ATA_CURR_BASE(dev) + ATA_DATA_EVEN);
  1659 + pbuf_odd = (uchar *) (ATA_CURR_BASE(dev) + ATA_DATA_ODD);
1636 1660 while (shorts--) {
1637 1661 EIEIO;
1638 1662 *dbuf++ = *pbuf_even;
1639 1663  
1640 1664  
... ... @@ -1640,13 +1664,14 @@
1640 1664 *dbuf++ = *pbuf_odd;
1641 1665 }
1642 1666 #else
1643   - ushort *dbuf;
1644   - volatile ushort *pbuf;
  1667 + ushort *dbuf;
  1668 + volatile ushort *pbuf;
1645 1669  
1646   - pbuf = (ushort *)(ATA_CURR_BASE(dev)+ATA_DATA_REG);
1647   - dbuf = (ushort *)sect_buf;
  1670 + pbuf = (ushort *) (ATA_CURR_BASE(dev) + ATA_DATA_REG);
  1671 + dbuf = (ushort *) sect_buf;
1648 1672  
1649   - debug("in input data shorts base for read is %lx\n", (unsigned long) pbuf);
  1673 + debug("in input data shorts base for read is %lx\n",
  1674 + (unsigned long) pbuf);
1650 1675  
1651 1676 while (shorts--) {
1652 1677 EIEIO;
1653 1678  
1654 1679  
1655 1680  
1656 1681  
... ... @@ -1655,20 +1680,18 @@
1655 1680 #endif
1656 1681 }
1657 1682  
1658   -#else /* ! CONFIG_IDE_SWAP_IO */
1659   -static void
1660   -output_data_shorts(int dev, ushort *sect_buf, int shorts)
  1683 +#else /* ! CONFIG_IDE_SWAP_IO */
  1684 +static void output_data_shorts(int dev, ushort *sect_buf, int shorts)
1661 1685 {
1662   - outsw(ATA_CURR_BASE(dev)+ATA_DATA_REG, sect_buf, shorts);
  1686 + outsw(ATA_CURR_BASE(dev) + ATA_DATA_REG, sect_buf, shorts);
1663 1687 }
1664 1688  
1665   -static void
1666   -input_data_shorts(int dev, ushort *sect_buf, int shorts)
  1689 +static void input_data_shorts(int dev, ushort *sect_buf, int shorts)
1667 1690 {
1668   - insw(ATA_CURR_BASE(dev)+ATA_DATA_REG, sect_buf, shorts);
  1691 + insw(ATA_CURR_BASE(dev) + ATA_DATA_REG, sect_buf, shorts);
1669 1692 }
1670 1693  
1671   -#endif /* CONFIG_IDE_SWAP_IO */
  1694 +#endif /* CONFIG_IDE_SWAP_IO */
1672 1695  
1673 1696 /*
1674 1697 * Wait until (Status & mask) == res, or timeout (in ms)
1675 1698  
1676 1699  
1677 1700  
1678 1701  
1679 1702  
... ... @@ -1676,20 +1699,21 @@
1676 1699 * This is used since some ATAPI CD ROMs clears their Busy Bit first
1677 1700 * and then they set their DRQ Bit
1678 1701 */
1679   -static uchar atapi_wait_mask (int dev, ulong t,uchar mask, uchar res)
  1702 +static uchar atapi_wait_mask(int dev, ulong t, uchar mask, uchar res)
1680 1703 {
1681   - ulong delay = 10 * t; /* poll every 100 us */
  1704 + ulong delay = 10 * t; /* poll every 100 us */
1682 1705 uchar c;
1683 1706  
1684   - c = ide_inb(dev,ATA_DEV_CTL); /* prevents to read the status before valid */
  1707 + /* prevents to read the status before valid */
  1708 + c = ide_inb(dev, ATA_DEV_CTL);
  1709 +
1685 1710 while (((c = ide_inb(dev, ATA_STATUS)) & mask) != res) {
1686 1711 /* break if error occurs (doesn't make sense to wait more) */
1687   - if((c & ATA_STAT_ERR)==ATA_STAT_ERR)
  1712 + if ((c & ATA_STAT_ERR) == ATA_STAT_ERR)
1688 1713 break;
1689   - udelay (100);
1690   - if (delay-- == 0) {
  1714 + udelay(100);
  1715 + if (delay-- == 0)
1691 1716 break;
1692   - }
1693 1717 }
1694 1718 return (c);
1695 1719 }
1696 1720  
1697 1721  
1698 1722  
1699 1723  
1700 1724  
1701 1725  
1702 1726  
1703 1727  
1704 1728  
1705 1729  
1706 1730  
1707 1731  
1708 1732  
1709 1733  
1710 1734  
1711 1735  
1712 1736  
1713 1737  
1714 1738  
1715 1739  
1716 1740  
1717 1741  
1718 1742  
1719 1743  
1720 1744  
1721 1745  
... ... @@ -1697,106 +1721,122 @@
1697 1721 /*
1698 1722 * issue an atapi command
1699 1723 */
1700   -unsigned char atapi_issue(int device,unsigned char* ccb,int ccblen, unsigned char * buffer,int buflen)
  1724 +unsigned char atapi_issue(int device, unsigned char *ccb, int ccblen,
  1725 + unsigned char *buffer, int buflen)
1701 1726 {
1702   - unsigned char c,err,mask,res;
  1727 + unsigned char c, err, mask, res;
1703 1728 int n;
1704   - ide_led (DEVICE_LED(device), 1); /* LED on */
1705 1729  
  1730 + ide_led(DEVICE_LED(device), 1); /* LED on */
  1731 +
1706 1732 /* Select device
1707 1733 */
1708   - mask = ATA_STAT_BUSY|ATA_STAT_DRQ;
  1734 + mask = ATA_STAT_BUSY | ATA_STAT_DRQ;
1709 1735 res = 0;
1710   - ide_outb (device, ATA_DEV_HD, ATA_LBA | ATA_DEVICE(device));
1711   - c = atapi_wait_mask(device,ATAPI_TIME_OUT,mask,res);
  1736 + ide_outb(device, ATA_DEV_HD, ATA_LBA | ATA_DEVICE(device));
  1737 + c = atapi_wait_mask(device, ATAPI_TIME_OUT, mask, res);
1712 1738 if ((c & mask) != res) {
1713   - printf ("ATAPI_ISSUE: device %d not ready status %X\n", device,c);
1714   - err=0xFF;
  1739 + printf("ATAPI_ISSUE: device %d not ready status %X\n", device,
  1740 + c);
  1741 + err = 0xFF;
1715 1742 goto AI_OUT;
1716 1743 }
1717 1744 /* write taskfile */
1718   - ide_outb (device, ATA_ERROR_REG, 0); /* no DMA, no overlaped */
1719   - ide_outb (device, ATA_SECT_CNT, 0);
1720   - ide_outb (device, ATA_SECT_NUM, 0);
1721   - ide_outb (device, ATA_CYL_LOW, (unsigned char)(buflen & 0xFF));
1722   - ide_outb (device, ATA_CYL_HIGH, (unsigned char)((buflen>>8) & 0xFF));
1723   - ide_outb (device, ATA_DEV_HD, ATA_LBA | ATA_DEVICE(device));
  1745 + ide_outb(device, ATA_ERROR_REG, 0); /* no DMA, no overlaped */
  1746 + ide_outb(device, ATA_SECT_CNT, 0);
  1747 + ide_outb(device, ATA_SECT_NUM, 0);
  1748 + ide_outb(device, ATA_CYL_LOW, (unsigned char) (buflen & 0xFF));
  1749 + ide_outb(device, ATA_CYL_HIGH,
  1750 + (unsigned char) ((buflen >> 8) & 0xFF));
  1751 + ide_outb(device, ATA_DEV_HD, ATA_LBA | ATA_DEVICE(device));
1724 1752  
1725   - ide_outb (device, ATA_COMMAND, ATAPI_CMD_PACKET);
1726   - udelay (50);
  1753 + ide_outb(device, ATA_COMMAND, ATAPI_CMD_PACKET);
  1754 + udelay(50);
1727 1755  
1728   - mask = ATA_STAT_DRQ|ATA_STAT_BUSY|ATA_STAT_ERR;
  1756 + mask = ATA_STAT_DRQ | ATA_STAT_BUSY | ATA_STAT_ERR;
1729 1757 res = ATA_STAT_DRQ;
1730   - c = atapi_wait_mask(device,ATAPI_TIME_OUT,mask,res);
  1758 + c = atapi_wait_mask(device, ATAPI_TIME_OUT, mask, res);
1731 1759  
1732   - if ((c & mask) != res) { /* DRQ must be 1, BSY 0 */
1733   - printf ("ATAPI_ISSUE: Error (no IRQ) before sending ccb dev %d status 0x%02x\n",device,c);
1734   - err=0xFF;
  1760 + if ((c & mask) != res) { /* DRQ must be 1, BSY 0 */
  1761 + printf("ATAPI_ISSUE: Error (no IRQ) before sending ccb dev %d status 0x%02x\n",
  1762 + device, c);
  1763 + err = 0xFF;
1735 1764 goto AI_OUT;
1736 1765 }
1737 1766  
1738   - output_data_shorts (device, (unsigned short *)ccb,ccblen/2); /* write command block */
  1767 + /* write command block */
  1768 + output_data_shorts(device, (unsigned short *) ccb, ccblen / 2);
  1769 +
1739 1770 /* ATAPI Command written wait for completition */
1740   - udelay (5000); /* device must set bsy */
  1771 + udelay(5000); /* device must set bsy */
1741 1772  
1742   - mask = ATA_STAT_DRQ|ATA_STAT_BUSY|ATA_STAT_ERR;
1743   - /* if no data wait for DRQ = 0 BSY = 0
1744   - * if data wait for DRQ = 1 BSY = 0 */
1745   - res=0;
1746   - if(buflen)
  1773 + mask = ATA_STAT_DRQ | ATA_STAT_BUSY | ATA_STAT_ERR;
  1774 + /*
  1775 + * if no data wait for DRQ = 0 BSY = 0
  1776 + * if data wait for DRQ = 1 BSY = 0
  1777 + */
  1778 + res = 0;
  1779 + if (buflen)
1747 1780 res = ATA_STAT_DRQ;
1748   - c = atapi_wait_mask(device,ATAPI_TIME_OUT,mask,res);
1749   - if ((c & mask) != res ) {
  1781 + c = atapi_wait_mask(device, ATAPI_TIME_OUT, mask, res);
  1782 + if ((c & mask) != res) {
1750 1783 if (c & ATA_STAT_ERR) {
1751   - err=(ide_inb(device,ATA_ERROR_REG))>>4;
1752   - debug ("atapi_issue 1 returned sense key %X status %02X\n",err,c);
  1784 + err = (ide_inb(device, ATA_ERROR_REG)) >> 4;
  1785 + debug("atapi_issue 1 returned sense key %X status %02X\n",
  1786 + err, c);
1753 1787 } else {
1754   - printf ("ATAPI_ISSUE: (no DRQ) after sending ccb (%x) status 0x%02x\n", ccb[0],c);
1755   - err=0xFF;
  1788 + printf("ATAPI_ISSUE: (no DRQ) after sending ccb (%x) status 0x%02x\n",
  1789 + ccb[0], c);
  1790 + err = 0xFF;
1756 1791 }
1757 1792 goto AI_OUT;
1758 1793 }
1759   - n=ide_inb(device, ATA_CYL_HIGH);
1760   - n<<=8;
1761   - n+=ide_inb(device, ATA_CYL_LOW);
1762   - if(n>buflen) {
1763   - printf("ERROR, transfer bytes %d requested only %d\n",n,buflen);
1764   - err=0xff;
  1794 + n = ide_inb(device, ATA_CYL_HIGH);
  1795 + n <<= 8;
  1796 + n += ide_inb(device, ATA_CYL_LOW);
  1797 + if (n > buflen) {
  1798 + printf("ERROR, transfer bytes %d requested only %d\n", n,
  1799 + buflen);
  1800 + err = 0xff;
1765 1801 goto AI_OUT;
1766 1802 }
1767   - if((n==0)&&(buflen<0)) {
1768   - printf("ERROR, transfer bytes %d requested %d\n",n,buflen);
1769   - err=0xff;
  1803 + if ((n == 0) && (buflen < 0)) {
  1804 + printf("ERROR, transfer bytes %d requested %d\n", n, buflen);
  1805 + err = 0xff;
1770 1806 goto AI_OUT;
1771 1807 }
1772   - if(n!=buflen) {
1773   - debug ("WARNING, transfer bytes %d not equal with requested %d\n",n,buflen);
  1808 + if (n != buflen) {
  1809 + debug("WARNING, transfer bytes %d not equal with requested %d\n",
  1810 + n, buflen);
1774 1811 }
1775   - if(n!=0) { /* data transfer */
1776   - debug ("ATAPI_ISSUE: %d Bytes to transfer\n",n);
1777   - /* we transfer shorts */
1778   - n>>=1;
  1812 + if (n != 0) { /* data transfer */
  1813 + debug("ATAPI_ISSUE: %d Bytes to transfer\n", n);
  1814 + /* we transfer shorts */
  1815 + n >>= 1;
1779 1816 /* ok now decide if it is an in or output */
1780   - if ((ide_inb(device, ATA_SECT_CNT)&0x02)==0) {
1781   - debug ("Write to device\n");
1782   - output_data_shorts(device,(unsigned short *)buffer,n);
  1817 + if ((ide_inb(device, ATA_SECT_CNT) & 0x02) == 0) {
  1818 + debug("Write to device\n");
  1819 + output_data_shorts(device, (unsigned short *) buffer,
  1820 + n);
1783 1821 } else {
1784   - debug ("Read from device @ %p shorts %d\n",buffer,n);
1785   - input_data_shorts(device,(unsigned short *)buffer,n);
  1822 + debug("Read from device @ %p shorts %d\n", buffer, n);
  1823 + input_data_shorts(device, (unsigned short *) buffer,
  1824 + n);
1786 1825 }
1787 1826 }
1788   - udelay(5000); /* seems that some CD ROMs need this... */
1789   - mask = ATA_STAT_BUSY|ATA_STAT_ERR;
1790   - res=0;
1791   - c = atapi_wait_mask(device,ATAPI_TIME_OUT,mask,res);
  1827 + udelay(5000); /* seems that some CD ROMs need this... */
  1828 + mask = ATA_STAT_BUSY | ATA_STAT_ERR;
  1829 + res = 0;
  1830 + c = atapi_wait_mask(device, ATAPI_TIME_OUT, mask, res);
1792 1831 if ((c & ATA_STAT_ERR) == ATA_STAT_ERR) {
1793   - err=(ide_inb(device,ATA_ERROR_REG) >> 4);
1794   - debug ("atapi_issue 2 returned sense key %X status %X\n",err,c);
  1832 + err = (ide_inb(device, ATA_ERROR_REG) >> 4);
  1833 + debug("atapi_issue 2 returned sense key %X status %X\n", err,
  1834 + c);
1795 1835 } else {
1796 1836 err = 0;
1797 1837 }
1798 1838 AI_OUT:
1799   - ide_led (DEVICE_LED(device), 0); /* LED off */
  1839 + ide_led(DEVICE_LED(device), 0); /* LED off */
1800 1840 return (err);
1801 1841 }
1802 1842  
1803 1843  
1804 1844  
1805 1845  
1806 1846  
1807 1847  
1808 1848  
1809 1849  
1810 1850  
1811 1851  
1812 1852  
1813 1853  
1814 1854  
1815 1855  
1816 1856  
1817 1857  
1818 1858  
1819 1859  
1820 1860  
1821 1861  
1822 1862  
1823 1863  
1824 1864  
1825 1865  
1826 1866  
1827 1867  
1828 1868  
1829 1869  
1830 1870  
1831 1871  
1832 1872  
1833 1873  
1834 1874  
1835 1875  
1836 1876  
... ... @@ -1808,155 +1848,153 @@
1808 1848 #define ATAPI_DRIVE_NOT_READY 100
1809 1849 #define ATAPI_UNIT_ATTN 10
1810 1850  
1811   -unsigned char atapi_issue_autoreq (int device,
1812   - unsigned char* ccb,
1813   - int ccblen,
1814   - unsigned char *buffer,
1815   - int buflen)
  1851 +unsigned char atapi_issue_autoreq(int device,
  1852 + unsigned char *ccb,
  1853 + int ccblen,
  1854 + unsigned char *buffer, int buflen)
1816 1855 {
1817   - unsigned char sense_data[18],sense_ccb[12];
1818   - unsigned char res,key,asc,ascq;
1819   - int notready,unitattn;
  1856 + unsigned char sense_data[18], sense_ccb[12];
  1857 + unsigned char res, key, asc, ascq;
  1858 + int notready, unitattn;
1820 1859  
1821   - unitattn=ATAPI_UNIT_ATTN;
1822   - notready=ATAPI_DRIVE_NOT_READY;
  1860 + unitattn = ATAPI_UNIT_ATTN;
  1861 + notready = ATAPI_DRIVE_NOT_READY;
1823 1862  
1824 1863 retry:
1825   - res= atapi_issue(device,ccb,ccblen,buffer,buflen);
1826   - if (res==0)
1827   - return (0); /* Ok */
  1864 + res = atapi_issue(device, ccb, ccblen, buffer, buflen);
  1865 + if (res == 0)
  1866 + return 0; /* Ok */
1828 1867  
1829   - if (res==0xFF)
1830   - return (0xFF); /* error */
  1868 + if (res == 0xFF)
  1869 + return 0xFF; /* error */
1831 1870  
1832   - debug ("(auto_req)atapi_issue returned sense key %X\n",res);
  1871 + debug("(auto_req)atapi_issue returned sense key %X\n", res);
1833 1872  
1834   - memset(sense_ccb,0,sizeof(sense_ccb));
1835   - memset(sense_data,0,sizeof(sense_data));
1836   - sense_ccb[0]=ATAPI_CMD_REQ_SENSE;
1837   - sense_ccb[4]=18; /* allocation Length */
  1873 + memset(sense_ccb, 0, sizeof(sense_ccb));
  1874 + memset(sense_data, 0, sizeof(sense_data));
  1875 + sense_ccb[0] = ATAPI_CMD_REQ_SENSE;
  1876 + sense_ccb[4] = 18; /* allocation Length */
1838 1877  
1839   - res=atapi_issue(device,sense_ccb,12,sense_data,18);
1840   - key=(sense_data[2]&0xF);
1841   - asc=(sense_data[12]);
1842   - ascq=(sense_data[13]);
  1878 + res = atapi_issue(device, sense_ccb, 12, sense_data, 18);
  1879 + key = (sense_data[2] & 0xF);
  1880 + asc = (sense_data[12]);
  1881 + ascq = (sense_data[13]);
1843 1882  
1844   - debug ("ATAPI_CMD_REQ_SENSE returned %x\n",res);
1845   - debug (" Sense page: %02X key %02X ASC %02X ASCQ %02X\n",
1846   - sense_data[0],
1847   - key,
1848   - asc,
1849   - ascq);
  1883 + debug("ATAPI_CMD_REQ_SENSE returned %x\n", res);
  1884 + debug(" Sense page: %02X key %02X ASC %02X ASCQ %02X\n",
  1885 + sense_data[0], key, asc, ascq);
1850 1886  
1851   - if((key==0))
1852   - return 0; /* ok device ready */
  1887 + if ((key == 0))
  1888 + return 0; /* ok device ready */
1853 1889  
1854   - if((key==6)|| (asc==0x29) || (asc==0x28)) { /* Unit Attention */
1855   - if(unitattn-->0) {
1856   - udelay(200*1000);
  1890 + if ((key == 6) || (asc == 0x29) || (asc == 0x28)) { /* Unit Attention */
  1891 + if (unitattn-- > 0) {
  1892 + udelay(200 * 1000);
1857 1893 goto retry;
1858 1894 }
1859   - printf("Unit Attention, tried %d\n",ATAPI_UNIT_ATTN);
  1895 + printf("Unit Attention, tried %d\n", ATAPI_UNIT_ATTN);
1860 1896 goto error;
1861 1897 }
1862   - if((asc==0x4) && (ascq==0x1)) { /* not ready, but will be ready soon */
1863   - if (notready-->0) {
1864   - udelay(200*1000);
  1898 + if ((asc == 0x4) && (ascq == 0x1)) {
  1899 + /* not ready, but will be ready soon */
  1900 + if (notready-- > 0) {
  1901 + udelay(200 * 1000);
1865 1902 goto retry;
1866 1903 }
1867   - printf("Drive not ready, tried %d times\n",ATAPI_DRIVE_NOT_READY);
  1904 + printf("Drive not ready, tried %d times\n",
  1905 + ATAPI_DRIVE_NOT_READY);
1868 1906 goto error;
1869 1907 }
1870   - if(asc==0x3a) {
1871   - debug ("Media not present\n");
  1908 + if (asc == 0x3a) {
  1909 + debug("Media not present\n");
1872 1910 goto error;
1873 1911 }
1874 1912  
1875   - printf ("ERROR: Unknown Sense key %02X ASC %02X ASCQ %02X\n",key,asc,ascq);
  1913 + printf("ERROR: Unknown Sense key %02X ASC %02X ASCQ %02X\n", key, asc,
  1914 + ascq);
1876 1915 error:
1877   - debug ("ERROR Sense key %02X ASC %02X ASCQ %02X\n",key,asc,ascq);
  1916 + debug("ERROR Sense key %02X ASC %02X ASCQ %02X\n", key, asc, ascq);
1878 1917 return (0xFF);
1879 1918 }
1880 1919  
1881 1920  
1882   -static void atapi_inquiry(block_dev_desc_t * dev_desc)
  1921 +static void atapi_inquiry(block_dev_desc_t *dev_desc)
1883 1922 {
1884   - unsigned char ccb[12]; /* Command descriptor block */
1885   - unsigned char iobuf[64]; /* temp buf */
  1923 + unsigned char ccb[12]; /* Command descriptor block */
  1924 + unsigned char iobuf[64]; /* temp buf */
1886 1925 unsigned char c;
1887 1926 int device;
1888 1927  
1889   - device=dev_desc->dev;
1890   - dev_desc->type=DEV_TYPE_UNKNOWN; /* not yet valid */
1891   - dev_desc->block_read=atapi_read;
  1928 + device = dev_desc->dev;
  1929 + dev_desc->type = DEV_TYPE_UNKNOWN; /* not yet valid */
  1930 + dev_desc->block_read = atapi_read;
1892 1931  
1893   - memset(ccb,0,sizeof(ccb));
1894   - memset(iobuf,0,sizeof(iobuf));
  1932 + memset(ccb, 0, sizeof(ccb));
  1933 + memset(iobuf, 0, sizeof(iobuf));
1895 1934  
1896   - ccb[0]=ATAPI_CMD_INQUIRY;
1897   - ccb[4]=40; /* allocation Legnth */
1898   - c=atapi_issue_autoreq(device,ccb,12,(unsigned char *)iobuf,40);
  1935 + ccb[0] = ATAPI_CMD_INQUIRY;
  1936 + ccb[4] = 40; /* allocation Legnth */
  1937 + c = atapi_issue_autoreq(device, ccb, 12, (unsigned char *) iobuf, 40);
1899 1938  
1900   - debug ("ATAPI_CMD_INQUIRY returned %x\n",c);
1901   - if (c!=0)
  1939 + debug("ATAPI_CMD_INQUIRY returned %x\n", c);
  1940 + if (c != 0)
1902 1941 return;
1903 1942  
1904 1943 /* copy device ident strings */
1905   - ident_cpy((unsigned char*)dev_desc->vendor,&iobuf[8],8);
1906   - ident_cpy((unsigned char*)dev_desc->product,&iobuf[16],16);
1907   - ident_cpy((unsigned char*)dev_desc->revision,&iobuf[32],5);
  1944 + ident_cpy((unsigned char *) dev_desc->vendor, &iobuf[8], 8);
  1945 + ident_cpy((unsigned char *) dev_desc->product, &iobuf[16], 16);
  1946 + ident_cpy((unsigned char *) dev_desc->revision, &iobuf[32], 5);
1908 1947  
1909   - dev_desc->lun=0;
1910   - dev_desc->lba=0;
1911   - dev_desc->blksz=0;
1912   - dev_desc->type=iobuf[0] & 0x1f;
  1948 + dev_desc->lun = 0;
  1949 + dev_desc->lba = 0;
  1950 + dev_desc->blksz = 0;
  1951 + dev_desc->type = iobuf[0] & 0x1f;
1913 1952  
1914   - if ((iobuf[1]&0x80)==0x80)
  1953 + if ((iobuf[1] & 0x80) == 0x80)
1915 1954 dev_desc->removable = 1;
1916 1955 else
1917 1956 dev_desc->removable = 0;
1918 1957  
1919   - memset(ccb,0,sizeof(ccb));
1920   - memset(iobuf,0,sizeof(iobuf));
1921   - ccb[0]=ATAPI_CMD_START_STOP;
1922   - ccb[4]=0x03; /* start */
  1958 + memset(ccb, 0, sizeof(ccb));
  1959 + memset(iobuf, 0, sizeof(iobuf));
  1960 + ccb[0] = ATAPI_CMD_START_STOP;
  1961 + ccb[4] = 0x03; /* start */
1923 1962  
1924   - c=atapi_issue_autoreq(device,ccb,12,(unsigned char *)iobuf,0);
  1963 + c = atapi_issue_autoreq(device, ccb, 12, (unsigned char *) iobuf, 0);
1925 1964  
1926   - debug ("ATAPI_CMD_START_STOP returned %x\n",c);
1927   - if (c!=0)
  1965 + debug("ATAPI_CMD_START_STOP returned %x\n", c);
  1966 + if (c != 0)
1928 1967 return;
1929 1968  
1930   - memset(ccb,0,sizeof(ccb));
1931   - memset(iobuf,0,sizeof(iobuf));
1932   - c=atapi_issue_autoreq(device,ccb,12,(unsigned char *)iobuf,0);
  1969 + memset(ccb, 0, sizeof(ccb));
  1970 + memset(iobuf, 0, sizeof(iobuf));
  1971 + c = atapi_issue_autoreq(device, ccb, 12, (unsigned char *) iobuf, 0);
1933 1972  
1934   - debug ("ATAPI_CMD_UNIT_TEST_READY returned %x\n",c);
1935   - if (c!=0)
  1973 + debug("ATAPI_CMD_UNIT_TEST_READY returned %x\n", c);
  1974 + if (c != 0)
1936 1975 return;
1937 1976  
1938   - memset(ccb,0,sizeof(ccb));
1939   - memset(iobuf,0,sizeof(iobuf));
1940   - ccb[0]=ATAPI_CMD_READ_CAP;
1941   - c=atapi_issue_autoreq(device,ccb,12,(unsigned char *)iobuf,8);
1942   - debug ("ATAPI_CMD_READ_CAP returned %x\n",c);
1943   - if (c!=0)
  1977 + memset(ccb, 0, sizeof(ccb));
  1978 + memset(iobuf, 0, sizeof(iobuf));
  1979 + ccb[0] = ATAPI_CMD_READ_CAP;
  1980 + c = atapi_issue_autoreq(device, ccb, 12, (unsigned char *) iobuf, 8);
  1981 + debug("ATAPI_CMD_READ_CAP returned %x\n", c);
  1982 + if (c != 0)
1944 1983 return;
1945 1984  
1946   - debug ("Read Cap: LBA %02X%02X%02X%02X blksize %02X%02X%02X%02X\n",
1947   - iobuf[0],iobuf[1],iobuf[2],iobuf[3],
1948   - iobuf[4],iobuf[5],iobuf[6],iobuf[7]);
  1985 + debug("Read Cap: LBA %02X%02X%02X%02X blksize %02X%02X%02X%02X\n",
  1986 + iobuf[0], iobuf[1], iobuf[2], iobuf[3],
  1987 + iobuf[4], iobuf[5], iobuf[6], iobuf[7]);
1949 1988  
1950   - dev_desc->lba =((unsigned long)iobuf[0]<<24) +
1951   - ((unsigned long)iobuf[1]<<16) +
1952   - ((unsigned long)iobuf[2]<< 8) +
1953   - ((unsigned long)iobuf[3]);
1954   - dev_desc->blksz=((unsigned long)iobuf[4]<<24) +
1955   - ((unsigned long)iobuf[5]<<16) +
1956   - ((unsigned long)iobuf[6]<< 8) +
1957   - ((unsigned long)iobuf[7]);
  1989 + dev_desc->lba = ((unsigned long) iobuf[0] << 24) +
  1990 + ((unsigned long) iobuf[1] << 16) +
  1991 + ((unsigned long) iobuf[2] << 8) + ((unsigned long) iobuf[3]);
  1992 + dev_desc->blksz = ((unsigned long) iobuf[4] << 24) +
  1993 + ((unsigned long) iobuf[5] << 16) +
  1994 + ((unsigned long) iobuf[6] << 8) + ((unsigned long) iobuf[7]);
1958 1995 #ifdef CONFIG_LBA48
1959   - dev_desc->lba48 = 0; /* ATAPI devices cannot use 48bit addressing (ATA/ATAPI v7) */
  1996 + /* ATAPI devices cannot use 48bit addressing (ATA/ATAPI v7) */
  1997 + dev_desc->lba48 = 0;
1960 1998 #endif
1961 1999 return;
1962 2000 }
1963 2001  
1964 2002  
1965 2003  
1966 2004  
1967 2005  
1968 2006  
... ... @@ -1969,45 +2007,46 @@
1969 2007 */
1970 2008 #define ATAPI_READ_MAX_BYTES 2048 /* we read max 2kbytes */
1971 2009 #define ATAPI_READ_BLOCK_SIZE 2048 /* assuming CD part */
1972   -#define ATAPI_READ_MAX_BLOCK ATAPI_READ_MAX_BYTES/ATAPI_READ_BLOCK_SIZE /* max blocks */
  2010 +#define ATAPI_READ_MAX_BLOCK (ATAPI_READ_MAX_BYTES/ATAPI_READ_BLOCK_SIZE)
1973 2011  
1974   -ulong atapi_read (int device, lbaint_t blknr, ulong blkcnt, void *buffer)
  2012 +ulong atapi_read(int device, lbaint_t blknr, ulong blkcnt, void *buffer)
1975 2013 {
1976 2014 ulong n = 0;
1977   - unsigned char ccb[12]; /* Command descriptor block */
  2015 + unsigned char ccb[12]; /* Command descriptor block */
1978 2016 ulong cnt;
1979 2017  
1980   - debug ("atapi_read dev %d start %lX, blocks %lX buffer at %lX\n",
1981   - device, blknr, blkcnt, (ulong)buffer);
  2018 + debug("atapi_read dev %d start %lX, blocks %lX buffer at %lX\n",
  2019 + device, blknr, blkcnt, (ulong) buffer);
1982 2020  
1983 2021 do {
1984   - if (blkcnt>ATAPI_READ_MAX_BLOCK) {
1985   - cnt=ATAPI_READ_MAX_BLOCK;
1986   - } else {
1987   - cnt=blkcnt;
1988   - }
1989   - ccb[0]=ATAPI_CMD_READ_12;
1990   - ccb[1]=0; /* reserved */
1991   - ccb[2]=(unsigned char) (blknr>>24) & 0xFF; /* MSB Block */
1992   - ccb[3]=(unsigned char) (blknr>>16) & 0xFF; /* */
1993   - ccb[4]=(unsigned char) (blknr>> 8) & 0xFF;
1994   - ccb[5]=(unsigned char) blknr & 0xFF; /* LSB Block */
1995   - ccb[6]=(unsigned char) (cnt >>24) & 0xFF; /* MSB Block count */
1996   - ccb[7]=(unsigned char) (cnt >>16) & 0xFF;
1997   - ccb[8]=(unsigned char) (cnt >> 8) & 0xFF;
1998   - ccb[9]=(unsigned char) cnt & 0xFF; /* LSB Block */
1999   - ccb[10]=0; /* reserved */
2000   - ccb[11]=0; /* reserved */
  2022 + if (blkcnt > ATAPI_READ_MAX_BLOCK)
  2023 + cnt = ATAPI_READ_MAX_BLOCK;
  2024 + else
  2025 + cnt = blkcnt;
2001 2026  
2002   - if (atapi_issue_autoreq(device,ccb,12,
2003   - (unsigned char *)buffer,
2004   - cnt*ATAPI_READ_BLOCK_SIZE) == 0xFF) {
  2027 + ccb[0] = ATAPI_CMD_READ_12;
  2028 + ccb[1] = 0; /* reserved */
  2029 + ccb[2] = (unsigned char) (blknr >> 24) & 0xFF; /* MSB Block */
  2030 + ccb[3] = (unsigned char) (blknr >> 16) & 0xFF; /* */
  2031 + ccb[4] = (unsigned char) (blknr >> 8) & 0xFF;
  2032 + ccb[5] = (unsigned char) blknr & 0xFF; /* LSB Block */
  2033 + ccb[6] = (unsigned char) (cnt >> 24) & 0xFF; /* MSB Block cnt */
  2034 + ccb[7] = (unsigned char) (cnt >> 16) & 0xFF;
  2035 + ccb[8] = (unsigned char) (cnt >> 8) & 0xFF;
  2036 + ccb[9] = (unsigned char) cnt & 0xFF; /* LSB Block */
  2037 + ccb[10] = 0; /* reserved */
  2038 + ccb[11] = 0; /* reserved */
  2039 +
  2040 + if (atapi_issue_autoreq(device, ccb, 12,
  2041 + (unsigned char *) buffer,
  2042 + cnt * ATAPI_READ_BLOCK_SIZE)
  2043 + == 0xFF) {
2005 2044 return (n);
2006 2045 }
2007   - n+=cnt;
2008   - blkcnt-=cnt;
2009   - blknr+=cnt;
2010   - buffer+=(cnt*ATAPI_READ_BLOCK_SIZE);
  2046 + n += cnt;
  2047 + blkcnt -= cnt;
  2048 + blknr += cnt;
  2049 + buffer += (cnt * ATAPI_READ_BLOCK_SIZE);
2011 2050 } while (blkcnt > 0);
2012 2051 return (n);
2013 2052 }
2014 2053  
... ... @@ -2016,22 +2055,17 @@
2016 2055  
2017 2056 #endif /* CONFIG_ATAPI */
2018 2057  
2019   -U_BOOT_CMD(
2020   - ide, 5, 1, do_ide,
2021   - "IDE sub-system",
2022   - "reset - reset IDE controller\n"
2023   - "ide info - show available IDE devices\n"
2024   - "ide device [dev] - show or set current device\n"
2025   - "ide part [dev] - print partition table of one or all IDE devices\n"
2026   - "ide read addr blk# cnt\n"
2027   - "ide write addr blk# cnt - read/write `cnt'"
2028   - " blocks starting at block `blk#'\n"
2029   - " to/from memory address `addr'"
2030   -);
  2058 +U_BOOT_CMD(ide, 5, 1, do_ide,
  2059 + "IDE sub-system",
  2060 + "reset - reset IDE controller\n"
  2061 + "ide info - show available IDE devices\n"
  2062 + "ide device [dev] - show or set current device\n"
  2063 + "ide part [dev] - print partition table of one or all IDE devices\n"
  2064 + "ide read addr blk# cnt\n"
  2065 + "ide write addr blk# cnt - read/write `cnt'"
  2066 + " blocks starting at block `blk#'\n"
  2067 + " to/from memory address `addr'");
2031 2068  
2032   -U_BOOT_CMD(
2033   - diskboot, 3, 1, do_diskboot,
2034   - "boot from IDE device",
2035   - "loadAddr dev:part"
2036   -);
  2069 +U_BOOT_CMD(diskboot, 3, 1, do_diskboot,
  2070 + "boot from IDE device", "loadAddr dev:part");