- First stab at getting the ppc ports building and working.
[coreboot.git] / src / mainboard / motorola / sandpointx3_altimus_mpc7410 / flash / flash.c
1 /* Copyright 2000  AG Electronics Ltd. */
2 /* This code is distributed without warranty under the GPL v2 (see COPYING) */
3
4 #include <string.h>
5 #include <console/console.h>
6 #include <stdlib.h>
7 #include "../flash.h"
8
9 static flash_device *first_flash = 0;
10
11 int register_flash_device (const flash_fn * fn, char *tag, void *data)
12 {
13     flash_device *device = malloc (sizeof (flash_device));
14
15     if (device)
16     {
17         const char *result;
18         device->fn = fn;
19         device->tag = tag;
20         device->data = data;
21         if ((result = fn->identify(device)) != 0)
22         {
23             printk_info("Registered flash %s\n", result);
24             device->next = first_flash;
25             first_flash = device;
26         }
27         return result ? 0 : -1;
28     }
29     return -1;
30 }
31
32 flash_device *find_flash_device(const char *name)
33 {
34     int len = strlen(name);
35
36     if (first_flash)
37     {
38         flash_device *flash;
39
40         for (flash = first_flash; flash; flash = flash->next)
41             if (strlen(flash->tag) == len && memcmp(name, flash->tag, len) == 0)
42                 return flash;
43     }
44     printk_info ("No flash %s registered\n", name);
45     return 0;
46 }