blob: e89572c00a4b02607110a41fc6766c4802680291 [file] [log] [blame]
Tom Rini8b0c8a12018-05-06 18:27:01 -04001/* SPDX-License-Identifier: GPL-2.0+ OR BSD-2-Clause */
Rafal Jaworowski9e1d16c2008-02-21 11:56:44 +01002/*
3 * (C) Copyright 2007-2008 Semihalf
4 *
5 * Written by: Rafal Jaworowski <raj@semihalf.com>
Rafal Jaworowski9e1d16c2008-02-21 11:56:44 +01006 */
7
Rafal Jaworowskia19be782008-01-09 19:39:36 +01008#ifndef _API_PUBLIC_H_
9#define _API_PUBLIC_H_
10
Tom Rini901d9532024-05-01 19:31:37 -060011#include <linux/types.h>
12
Rafal Jaworowskia19be782008-01-09 19:39:36 +010013#define API_EINVAL 1 /* invalid argument(s) */
14#define API_ENODEV 2 /* no device */
15#define API_ENOMEM 3 /* no memory */
16#define API_EBUSY 4 /* busy, occupied etc. */
17#define API_EIO 5 /* I/O error */
Rafal Jaworowski6feb82d2009-01-23 13:27:18 +010018#define API_ESYSC 6 /* syscall error */
Rafal Jaworowskia19be782008-01-09 19:39:36 +010019
20typedef int (*scp_t)(int, int *, ...);
21
22#define API_SIG_VERSION 1
23#define API_SIG_MAGIC "UBootAPI"
24#define API_SIG_MAGLEN 8
25
26struct api_signature {
27 char magic[API_SIG_MAGLEN]; /* magic string */
28 uint16_t version; /* API version */
29 uint32_t checksum; /* checksum of this sig struct */
30 scp_t syscall; /* entry point to the API */
31};
32
33enum {
34 API_RSVD = 0,
35 API_GETC,
36 API_PUTC,
37 API_TSTC,
38 API_PUTS,
39 API_RESET,
40 API_GET_SYS_INFO,
41 API_UDELAY,
42 API_GET_TIMER,
43 API_DEV_ENUM,
44 API_DEV_OPEN,
45 API_DEV_CLOSE,
46 API_DEV_READ,
47 API_DEV_WRITE,
48 API_ENV_ENUM,
49 API_ENV_GET,
50 API_ENV_SET,
Che-Liang Chiou0d460412011-10-20 23:04:22 +000051 API_DISPLAY_GET_INFO,
52 API_DISPLAY_DRAW_BITMAP,
53 API_DISPLAY_CLEAR,
Rafal Jaworowskia19be782008-01-09 19:39:36 +010054 API_MAXCALL
55};
56
57#define MR_ATTR_FLASH 0x0001
58#define MR_ATTR_DRAM 0x0002
59#define MR_ATTR_SRAM 0x0003
60
61struct mem_region {
62 unsigned long start;
63 unsigned long size;
64 int flags;
65};
66
67struct sys_info {
68 unsigned long clk_bus;
69 unsigned long clk_cpu;
70 unsigned long bar;
71 struct mem_region *mr;
72 int mr_no; /* number of memory regions */
73};
74
Marek BehĂșn706fa762021-03-06 23:43:22 +010075/*
76 * FIXME: Previously this code was:
77 *
78 * #undef CONFIG_SYS_64BIT_LBA
79 * #ifdef CONFIG_SYS_64BIT_LBA
80 * typedef u_int64_t lbasize_t;
81 * #else
82 * typedef unsigned long lbasize_t;
83 * #endif
84 *
85 * But we cannot just undefine CONFIG_SYS_64BIT_LBA, because then in
86 * api/api_storage.c the type signature of lbaint_t will be different if
87 * CONFIG_SYS_64BIT_LBA is enabled for the board, which can result in various
88 * bugs.
89 * So simply define lbasize_t as an unsigned long, since this was what was done
90 * anyway for at least 13 years, but don't undefine CONFIG_SYS_64BIT_LBA.
91 */
Rafal Jaworowskia19be782008-01-09 19:39:36 +010092typedef unsigned long lbasize_t;
Marek BehĂșn706fa762021-03-06 23:43:22 +010093
Rafal Jaworowskia19be782008-01-09 19:39:36 +010094typedef unsigned long lbastart_t;
95
96#define DEV_TYP_NONE 0x0000
97#define DEV_TYP_NET 0x0001
98
99#define DEV_TYP_STOR 0x0002
100#define DT_STOR_IDE 0x0010
101#define DT_STOR_SCSI 0x0020
102#define DT_STOR_USB 0x0040
103#define DT_STOR_MMC 0x0080
Stefan Roese37628252008-08-06 14:05:38 +0200104#define DT_STOR_SATA 0x0100
Rafal Jaworowskia19be782008-01-09 19:39:36 +0100105
106#define DEV_STA_CLOSED 0x0000 /* invalid, closed */
107#define DEV_STA_OPEN 0x0001 /* open i.e. active */
108
109struct device_info {
110 int type;
111 void *cookie;
112
113 union {
114 struct {
115 lbasize_t block_count; /* no of blocks */
116 unsigned long block_size; /* size of one block */
117 } storage;
118
119 struct {
120 unsigned char hwaddr[6];
121 } net;
122 } info;
123#define di_stor info.storage
124#define di_net info.net
125
126 int state;
127};
128
Che-Liang Chiou0d460412011-10-20 23:04:22 +0000129#define DISPLAY_TYPE_LCD 0x0001
130#define DISPLAY_TYPE_VIDEO 0x0002
131
132struct display_info {
133 int type;
134 /* screen size in pixels */
135 int pixel_width;
136 int pixel_height;
137 /* screen size in rows and columns of text */
138 int screen_rows;
139 int screen_cols;
140};
141
Rafal Jaworowskia19be782008-01-09 19:39:36 +0100142#endif /* _API_PUBLIC_H_ */