1176480Smarcel/*
2176480Smarcel * (C) Copyright 2007-2008 Semihalf
3176480Smarcel *
4176480Smarcel * Written by: Rafal Jaworowski <raj@semihalf.com>
5176480Smarcel *
6176480Smarcel * This file is dual licensed; you can use it under the terms of
7176480Smarcel * either the GPL, or the BSD license, at your option.
8176480Smarcel *
9176480Smarcel * I. GPL:
10176480Smarcel *
11176480Smarcel * This file is free software; you can redistribute it and/or
12176480Smarcel * modify it under the terms of the GNU General Public License as
13176480Smarcel * published by the Free Software Foundation; either version 2 of
14176480Smarcel * the License, or (at your option) any later version.
15176480Smarcel *
16176480Smarcel * This file is distributed in the hope that it will be useful,
17176480Smarcel * but WITHOUT ANY WARRANTY; without even the implied warranty of
18176480Smarcel * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19176480Smarcel * GNU General Public License for more details.
20176480Smarcel *
21176480Smarcel * You should have received a copy of the GNU General Public License
22176480Smarcel * along with this program; if not, write to the Free Software
23176480Smarcel * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
24176480Smarcel * MA 02111-1307 USA
25176480Smarcel *
26176480Smarcel * Alternatively,
27176480Smarcel *
28176480Smarcel * II. BSD license:
29176480Smarcel *
30176480Smarcel * Redistribution and use in source and binary forms, with or without
31176480Smarcel * modification, are permitted provided that the following conditions
32176480Smarcel * are met:
33176480Smarcel * 1. Redistributions of source code must retain the above copyright
34176480Smarcel *    notice, this list of conditions and the following disclaimer.
35176480Smarcel * 2. Redistributions in binary form must reproduce the above copyright
36176480Smarcel *    notice, this list of conditions and the following disclaimer in the
37176480Smarcel *    documentation and/or other materials provided with the distribution.
38176480Smarcel *
39176480Smarcel * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
40176480Smarcel * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
41176480Smarcel * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
42176480Smarcel * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
43176480Smarcel * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
44176480Smarcel * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
45176480Smarcel * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
46176480Smarcel * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
47176480Smarcel * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
48176480Smarcel * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
49176480Smarcel * SUCH DAMAGE.
50176480Smarcel *
51176480Smarcel * $FreeBSD$
52176480Smarcel *
53176480Smarcel * This file needs to be kept in sync with U-Boot reference:
54176480Smarcel * http://www.denx.de/cgi-bin/gitweb.cgi?p=u-boot.git;a=blob;f=include/api_public.h
55176480Smarcel */
56176348Smarcel
57176348Smarcel#ifndef _API_PUBLIC_H_
58177152Sobrien#define	_API_PUBLIC_H_
59176348Smarcel
60177152Sobrien#define	API_EINVAL		1	/* invalid argument(s)	*/
61177152Sobrien#define	API_ENODEV		2	/* no device		*/
62177152Sobrien#define	API_ENOMEM		3	/* no memory		*/
63177152Sobrien#define	API_EBUSY		4	/* busy, occupied etc.	*/
64177152Sobrien#define	API_EIO			5	/* I/O error		*/
65183598Sraj#define	API_ESYSC		6	/* syscall error	*/
66176348Smarcel
67177152Sobrientypedef int (*scp_t)(int, int *, ...);
68176348Smarcel
69177152Sobrien#define	API_SIG_VERSION	1
70177152Sobrien#define	API_SIG_MAGIC	"UBootAPI"
71177152Sobrien#define	API_SIG_MAGLEN	8
72176348Smarcel
73176348Smarcelstruct api_signature {
74176348Smarcel	char		magic[API_SIG_MAGLEN];	/* magic string */
75177152Sobrien	uint16_t	version;	/* API version */
76177152Sobrien	uint32_t	checksum;	/* checksum of this sig struct */
77177152Sobrien	scp_t		syscall;	/* entry point to the API */
78176348Smarcel};
79176348Smarcel
80176348Smarcelenum {
81176348Smarcel	API_RSVD = 0,
82176348Smarcel	API_GETC,
83176348Smarcel	API_PUTC,
84176348Smarcel	API_TSTC,
85176348Smarcel	API_PUTS,
86176348Smarcel	API_RESET,
87176348Smarcel	API_GET_SYS_INFO,
88176348Smarcel	API_UDELAY,
89176348Smarcel	API_GET_TIMER,
90176348Smarcel	API_DEV_ENUM,
91176348Smarcel	API_DEV_OPEN,
92176348Smarcel	API_DEV_CLOSE,
93176348Smarcel	API_DEV_READ,
94176348Smarcel	API_DEV_WRITE,
95176348Smarcel	API_ENV_ENUM,
96176348Smarcel	API_ENV_GET,
97176348Smarcel	API_ENV_SET,
98176348Smarcel	API_MAXCALL
99176348Smarcel};
100176348Smarcel
101177152Sobrien#define	MR_ATTR_FLASH	0x0001
102177152Sobrien#define	MR_ATTR_DRAM	0x0002
103177152Sobrien#define	MR_ATTR_SRAM	0x0003
104176348Smarcel
105176348Smarcelstruct mem_region {
106176348Smarcel	unsigned long	start;
107176348Smarcel	unsigned long	size;
108176348Smarcel	int		flags;
109176348Smarcel};
110176348Smarcel
111176348Smarcelstruct sys_info {
112176348Smarcel	unsigned long		clk_bus;
113176348Smarcel	unsigned long		clk_cpu;
114176348Smarcel	unsigned long		bar;
115176348Smarcel	struct mem_region	*mr;
116176348Smarcel	int			mr_no;	/* number of memory regions */
117176348Smarcel};
118176348Smarcel
119176348Smarcel#undef CFG_64BIT_LBA
120176348Smarcel#ifdef CFG_64BIT_LBA
121183599Srajtypedef	uint64_t lbasize_t;
122176348Smarcel#else
123176348Smarceltypedef unsigned long lbasize_t;
124176348Smarcel#endif
125176348Smarceltypedef unsigned long lbastart_t;
126176348Smarcel
127177152Sobrien#define	DEV_TYP_NONE	0x0000
128177152Sobrien#define	DEV_TYP_NET	0x0001
129176348Smarcel
130177152Sobrien#define	DEV_TYP_STOR	0x0002
131177152Sobrien#define	DT_STOR_IDE	0x0010
132177152Sobrien#define	DT_STOR_SCSI	0x0020
133177152Sobrien#define	DT_STOR_USB	0x0040
134177152Sobrien#define	DT_STOR_MMC	0x0080
135176348Smarcel
136177152Sobrien#define	DEV_STA_CLOSED	0x0000		/* invalid, closed */
137177152Sobrien#define	DEV_STA_OPEN	0x0001		/* open i.e. active */
138176348Smarcel
139176348Smarcelstruct device_info {
140176348Smarcel	int	type;
141176348Smarcel	void	*cookie;
142176348Smarcel
143176348Smarcel	union {
144176348Smarcel		struct {
145176348Smarcel			lbasize_t	block_count;	/* no of blocks */
146176348Smarcel			unsigned long	block_size;	/* size of one block */
147176348Smarcel		} storage;
148176348Smarcel
149176348Smarcel		struct {
150176348Smarcel			unsigned char	hwaddr[6];
151176348Smarcel		} net;
152176348Smarcel	} info;
153177152Sobrien#define	di_stor info.storage
154177152Sobrien#define	di_net info.net
155176348Smarcel
156176348Smarcel	int	state;
157176348Smarcel};
158176348Smarcel
159176348Smarcel#endif /* _API_PUBLIC_H_ */
160