1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
|
/*
* Copyright (C) ST-Ericsson SA 2009
*
* See file CREDITS for list of people who contributed to this
* project.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; either version 2 of
* the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
* MA 02111-1307 USA
*/
#ifndef _COMMON_H_
#define _COMMON_H_
#include <common.h>
#define PASS (1)
#define FAIL (0)
#define IO(addr) (*((u32*) (addr)))
#define HIO(addr) (*((u16*) (addr)))
#define BIO(addr) (*((u8*) (addr)))
/*
* macro to get at IO space
*/
#define IO_ADDRESS(x) (x)
#define REG_WRITE_BITS(reg,val,mask,sb) (writel(((readl(reg) & ~(mask)) | (((val)<<(sb)) & (mask))), reg))
#define nmdk_error(format, arg...) printf(": " format "\n" , ## arg)
#if !defined(FALSE) && !defined(TRUE)
typedef enum {FALSE, TRUE} t_bool;
#else /* FALSE & TRUE already defined */
typedef enum {BOOL_FALSE, BOOL_TRUE} t_bool;
#endif /* !defined(FALSE) && !defined(TRUE) */
/*-----------------------------------------------------------------------------
* Bit mask definition
*---------------------------------------------------------------------------*/
#define MASK_NULL8 0x00
#define MASK_NULL16 0x0000
#define MASK_NULL32 0x00000000
#define MASK_ALL8 0xFF
#define MASK_ALL16 0xFFFF
#define MASK_ALL32 0xFFFFFFFF
#define MASK_BIT0 (1UL<<0)
#define MASK_BIT1 (1UL<<1)
#define MASK_BIT2 (1UL<<2)
#define MASK_BIT3 (1UL<<3)
#define MASK_BIT4 (1UL<<4)
#define MASK_BIT5 (1UL<<5)
#define MASK_BIT6 (1UL<<6)
#define MASK_BIT7 (1UL<<7)
#define MASK_BIT8 (1UL<<8)
#define MASK_BIT9 (1UL<<9)
#define MASK_BIT10 (1UL<<10)
#define MASK_BIT11 (1UL<<11)
#define MASK_BIT12 (1UL<<12)
#define MASK_BIT13 (1UL<<13)
#define MASK_BIT14 (1UL<<14)
#define MASK_BIT15 (1UL<<15)
#define MASK_BIT16 (1UL<<16)
#define MASK_BIT17 (1UL<<17)
#define MASK_BIT18 (1UL<<18)
#define MASK_BIT19 (1UL<<19)
#define MASK_BIT20 (1UL<<20)
#define MASK_BIT21 (1UL<<21)
#define MASK_BIT22 (1UL<<22)
#define MASK_BIT23 (1UL<<23)
#define MASK_BIT24 (1UL<<24)
#define MASK_BIT25 (1UL<<25)
#define MASK_BIT26 (1UL<<26)
#define MASK_BIT27 (1UL<<27)
#define MASK_BIT28 (1UL<<28)
#define MASK_BIT29 (1UL<<29)
#define MASK_BIT30 (1UL<<30)
#define MASK_BIT31 (1UL<<31)
#define NOMADIK_INTERNAL_ERROR (-8)
#define NOMADIK_NOT_CONFIGURED (-7)
#define NOMADIK_REQUEST_PENDING (-6)
#define NOMADIK_REQUEST_NOT_APPLICABLE (-5)
#define NOMADIK_INVALID_PARAMETER (-4)
#define NOMADIK_UNSUPPORTED_FEATURE (-3)
#define NOMADIK_UNSUPPORTED_HW (-2)
#define NOMADIK_ERROR (-1)
#define NOMADIK_OK ( 0)
#define NOMADIK_INTERNAL_EVENT ( 1)
#define NOMADIK_REMAINING_PENDING_EVENTS ( 2)
#define NOMADIK_REMAINING_FILTER_PENDING_EVENTS ( 3)
#define NOMADIK_NO_MORE_PENDING_EVENT ( 4)
#define NOMADIK_NO_MORE_FILTER_PENDING_EVENT ( 5)
#define NOMADIK_NO_PENDING_EVENT_ERROR ( 7)
#define NOMADIK_MAX_ERROR_VALUE (-65) /* HW specific error codes
* should start from this offset
*/
/*-----------------------------------------------------------------------------
* Bit setting or clearing
*---------------------------------------------------------------------------*/
#define NOMADIK_SET_BITS(reg,mask) ((reg) |= (mask))
#define NOMADIK_CLEAR_BITS(reg,mask) ((reg) &= ~(mask))
#define NOMADIK_READ_BITS(reg,mask) ((reg) & (mask))
#define NOMADIK_WRITE_BITS(reg,val,mask) ((reg) = (((reg) & ~(mask)) | ((val) & (mask))))
#define NOMADIK_READ_REG(reg) (reg)
#define NOMADIK_WRITE_REG(reg,val) ((reg) = (val))
/*
* Definition of the different kind of addresses manipulated into a system with MMU
* (handle physical AND logical addresses)
*/
typedef u32 t_physical_address;
typedef u32 t_logical_address;
/*function prototypes*/
void gpio_init(void);
int u8500_is_earlydrop(void);
int cpu_is_u8500v11(void);
int cpu_is_u8500v1(void);
int cpu_is_u8500v2(void);
#endif /* _COMMON_H_ */
|