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