Haavard Skinnemoen | 5f97f7f | 2006-09-25 23:32:13 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2004-2006 Atmel Corporation |
| 3 | * |
| 4 | * Based on linux/include/asm-arm/setup.h |
| 5 | * Copyright (C) 1997-1999 Russel King |
| 6 | * |
| 7 | * This program is free software; you can redistribute it and/or modify |
| 8 | * it under the terms of the GNU General Public License version 2 as |
| 9 | * published by the Free Software Foundation. |
| 10 | */ |
| 11 | #ifndef __ASM_AVR32_SETUP_H__ |
| 12 | #define __ASM_AVR32_SETUP_H__ |
| 13 | |
| 14 | #define COMMAND_LINE_SIZE 256 |
| 15 | |
Adrian Bunk | 7d1362c | 2006-12-06 20:40:38 -0800 | [diff] [blame] | 16 | #ifdef __KERNEL__ |
| 17 | |
Haavard Skinnemoen | 5f97f7f | 2006-09-25 23:32:13 -0700 | [diff] [blame] | 18 | /* Magic number indicating that a tag table is present */ |
| 19 | #define ATAG_MAGIC 0xa2a25441 |
| 20 | |
| 21 | #ifndef __ASSEMBLY__ |
| 22 | |
| 23 | /* |
| 24 | * Generic memory range, used by several tags. |
| 25 | * |
| 26 | * addr is always physical. |
| 27 | * size is measured in bytes. |
| 28 | * next is for use by the OS, e.g. for grouping regions into |
| 29 | * linked lists. |
| 30 | */ |
| 31 | struct tag_mem_range { |
| 32 | u32 addr; |
| 33 | u32 size; |
| 34 | struct tag_mem_range * next; |
| 35 | }; |
| 36 | |
| 37 | /* The list ends with an ATAG_NONE node. */ |
| 38 | #define ATAG_NONE 0x00000000 |
| 39 | |
| 40 | struct tag_header { |
| 41 | u32 size; |
| 42 | u32 tag; |
| 43 | }; |
| 44 | |
| 45 | /* The list must start with an ATAG_CORE node */ |
| 46 | #define ATAG_CORE 0x54410001 |
| 47 | |
| 48 | struct tag_core { |
| 49 | u32 flags; |
| 50 | u32 pagesize; |
| 51 | u32 rootdev; |
| 52 | }; |
| 53 | |
| 54 | /* it is allowed to have multiple ATAG_MEM nodes */ |
| 55 | #define ATAG_MEM 0x54410002 |
| 56 | /* ATAG_MEM uses tag_mem_range */ |
| 57 | |
| 58 | /* command line: \0 terminated string */ |
| 59 | #define ATAG_CMDLINE 0x54410003 |
| 60 | |
| 61 | struct tag_cmdline { |
| 62 | char cmdline[1]; /* this is the minimum size */ |
| 63 | }; |
| 64 | |
| 65 | /* Ramdisk image (may be compressed) */ |
| 66 | #define ATAG_RDIMG 0x54410004 |
| 67 | /* ATAG_RDIMG uses tag_mem_range */ |
| 68 | |
| 69 | /* Information about various clocks present in the system */ |
| 70 | #define ATAG_CLOCK 0x54410005 |
| 71 | |
| 72 | struct tag_clock { |
| 73 | u32 clock_id; /* Which clock are we talking about? */ |
| 74 | u32 clock_flags; /* Special features */ |
| 75 | u64 clock_hz; /* Clock speed in Hz */ |
| 76 | }; |
| 77 | |
| 78 | /* The clock types we know about */ |
| 79 | #define CLOCK_BOOTCPU 0 |
| 80 | |
| 81 | /* Memory reserved for the system (e.g. the bootloader) */ |
| 82 | #define ATAG_RSVD_MEM 0x54410006 |
| 83 | /* ATAG_RSVD_MEM uses tag_mem_range */ |
| 84 | |
| 85 | /* Ethernet information */ |
| 86 | |
| 87 | #define ATAG_ETHERNET 0x54410007 |
| 88 | |
| 89 | struct tag_ethernet { |
| 90 | u8 mac_index; |
| 91 | u8 mii_phy_addr; |
| 92 | u8 hw_address[6]; |
| 93 | }; |
| 94 | |
| 95 | #define ETH_INVALID_PHY 0xff |
| 96 | |
| 97 | struct tag { |
| 98 | struct tag_header hdr; |
| 99 | union { |
| 100 | struct tag_core core; |
| 101 | struct tag_mem_range mem_range; |
| 102 | struct tag_cmdline cmdline; |
| 103 | struct tag_clock clock; |
| 104 | struct tag_ethernet ethernet; |
| 105 | } u; |
| 106 | }; |
| 107 | |
| 108 | struct tagtable { |
| 109 | u32 tag; |
| 110 | int (*parse)(struct tag *); |
| 111 | }; |
| 112 | |
Adrian Bunk | 3ff6eec | 2008-01-24 22:16:20 +0100 | [diff] [blame] | 113 | #define __tag __used __attribute__((__section__(".taglist.init"))) |
Haavard Skinnemoen | 5f97f7f | 2006-09-25 23:32:13 -0700 | [diff] [blame] | 114 | #define __tagtable(tag, fn) \ |
| 115 | static struct tagtable __tagtable_##fn __tag = { tag, fn } |
| 116 | |
| 117 | #define tag_member_present(tag,member) \ |
| 118 | ((unsigned long)(&((struct tag *)0L)->member + 1) \ |
| 119 | <= (tag)->hdr.size * 4) |
| 120 | |
| 121 | #define tag_next(t) ((struct tag *)((u32 *)(t) + (t)->hdr.size)) |
| 122 | #define tag_size(type) ((sizeof(struct tag_header) + sizeof(struct type)) >> 2) |
| 123 | |
| 124 | #define for_each_tag(t,base) \ |
| 125 | for (t = base; t->hdr.size; t = tag_next(t)) |
| 126 | |
Haavard Skinnemoen | 5f97f7f | 2006-09-25 23:32:13 -0700 | [diff] [blame] | 127 | extern struct tag *bootloader_tags; |
| 128 | |
Haavard Skinnemoen | d80e2bb | 2007-03-21 16:23:41 +0100 | [diff] [blame] | 129 | extern resource_size_t fbmem_start; |
| 130 | extern resource_size_t fbmem_size; |
Haavard Skinnemoen | d801176 | 2007-03-21 16:02:57 +0100 | [diff] [blame] | 131 | |
| 132 | void setup_processor(void); |
Haavard Skinnemoen | 5f97f7f | 2006-09-25 23:32:13 -0700 | [diff] [blame] | 133 | |
Haavard Skinnemoen | 5f97f7f | 2006-09-25 23:32:13 -0700 | [diff] [blame] | 134 | #endif /* !__ASSEMBLY__ */ |
| 135 | |
Adrian Bunk | 7d1362c | 2006-12-06 20:40:38 -0800 | [diff] [blame] | 136 | #endif /* __KERNEL__ */ |
| 137 | |
Haavard Skinnemoen | 5f97f7f | 2006-09-25 23:32:13 -0700 | [diff] [blame] | 138 | #endif /* __ASM_AVR32_SETUP_H__ */ |