fixes several compile errors, reserves memory for second core, adds u-boot env parsin...
[openwrt/svn-archive/archive.git] / target / linux / ifxmips / files / include / asm-mips / ifxmips / ifxmips_gptu.h
1 #ifndef __DANUBE_GPTU_DEV_H__2005_07_26__10_19__
2 #define __DANUBE_GPTU_DEV_H__2005_07_26__10_19__
3
4
5 /******************************************************************************
6 Copyright (c) 2002, Infineon Technologies. All rights reserved.
7
8 No Warranty
9 Because the program is licensed free of charge, there is no warranty for
10 the program, to the extent permitted by applicable law. Except when
11 otherwise stated in writing the copyright holders and/or other parties
12 provide the program "as is" without warranty of any kind, either
13 expressed or implied, including, but not limited to, the implied
14 warranties of merchantability and fitness for a particular purpose. The
15 entire risk as to the quality and performance of the program is with
16 you. should the program prove defective, you assume the cost of all
17 necessary servicing, repair or correction.
18
19 In no event unless required by applicable law or agreed to in writing
20 will any copyright holder, or any other party who may modify and/or
21 redistribute the program as permitted above, be liable to you for
22 damages, including any general, special, incidental or consequential
23 damages arising out of the use or inability to use the program
24 (including but not limited to loss of data or data being rendered
25 inaccurate or losses sustained by you or third parties or a failure of
26 the program to operate with any other programs), even if such holder or
27 other party has been advised of the possibility of such damages.
28 ******************************************************************************/
29
30
31 /*
32 * ####################################
33 * Definition
34 * ####################################
35 */
36
37 /*
38 * Available Timer/Counter Index
39 */
40 #define TIMER(n, X) (n * 2 + (X ? 1 : 0))
41 #define TIMER_ANY 0x00
42 #define TIMER1A TIMER(1, 0)
43 #define TIMER1B TIMER(1, 1)
44 #define TIMER2A TIMER(2, 0)
45 #define TIMER2B TIMER(2, 1)
46 #define TIMER3A TIMER(3, 0)
47 #define TIMER3B TIMER(3, 1)
48
49 /*
50 * Flag of Timer/Counter
51 * These flags specify the way in which timer is configured.
52 */
53 /* Bit size of timer/counter. */
54 #define TIMER_FLAG_16BIT 0x0000
55 #define TIMER_FLAG_32BIT 0x0001
56 /* Switch between timer and counter. */
57 #define TIMER_FLAG_TIMER 0x0000
58 #define TIMER_FLAG_COUNTER 0x0002
59 /* Stop or continue when overflowing/underflowing. */
60 #define TIMER_FLAG_ONCE 0x0000
61 #define TIMER_FLAG_CYCLIC 0x0004
62 /* Count up or counter down. */
63 #define TIMER_FLAG_UP 0x0000
64 #define TIMER_FLAG_DOWN 0x0008
65 /* Count on specific level or edge. */
66 #define TIMER_FLAG_HIGH_LEVEL_SENSITIVE 0x0000
67 #define TIMER_FLAG_LOW_LEVEL_SENSITIVE 0x0040
68 #define TIMER_FLAG_RISE_EDGE 0x0010
69 #define TIMER_FLAG_FALL_EDGE 0x0020
70 #define TIMER_FLAG_ANY_EDGE 0x0030
71 /* Signal is syncronous to module clock or not. */
72 #define TIMER_FLAG_UNSYNC 0x0000
73 #define TIMER_FLAG_SYNC 0x0080
74 /* Different interrupt handle type. */
75 #define TIMER_FLAG_NO_HANDLE 0x0000
76 #if defined(__KERNEL__)
77 #define TIMER_FLAG_CALLBACK_IN_IRQ 0x0100
78 #endif // defined(__KERNEL__)
79 #define TIMER_FLAG_SIGNAL 0x0300
80 /* Internal clock source or external clock source */
81 #define TIMER_FLAG_INT_SRC 0x0000
82 #define TIMER_FLAG_EXT_SRC 0x1000
83
84
85 /*
86 * ioctl Command
87 */
88 #define GPTU_REQUEST_TIMER 0x01 /* General method to setup timer/counter. */
89 #define GPTU_FREE_TIMER 0x02 /* Free timer/counter. */
90 #define GPTU_START_TIMER 0x03 /* Start or resume timer/counter. */
91 #define GPTU_STOP_TIMER 0x04 /* Suspend timer/counter. */
92 #define GPTU_GET_COUNT_VALUE 0x05 /* Get current count value. */
93 #define GPTU_CALCULATE_DIVIDER 0x06 /* Calculate timer divider from given freq.*/
94 #define GPTU_SET_TIMER 0x07 /* Simplified method to setup timer. */
95 #define GPTU_SET_COUNTER 0x08 /* Simplified method to setup counter. */
96
97 /*
98 * Data Type Used to Call ioctl
99 */
100 struct gptu_ioctl_param {
101 unsigned int timer; /* In command GPTU_REQUEST_TIMER, GPTU_SET_TIMER, and *
102 * GPTU_SET_COUNTER, this field is ID of expected *
103 * timer/counter. If it's zero, a timer/counter would *
104 * be dynamically allocated and ID would be stored in *
105 * this field. *
106 * In command GPTU_GET_COUNT_VALUE, this field is *
107 * ignored. *
108 * In other command, this field is ID of timer/counter *
109 * allocated. */
110 unsigned int flag; /* In command GPTU_REQUEST_TIMER, GPTU_SET_TIMER, and *
111 * GPTU_SET_COUNTER, this field contains flags to *
112 * specify how to configure timer/counter. *
113 * In command GPTU_START_TIMER, zero indicate start *
114 * and non-zero indicate resume timer/counter. *
115 * In other command, this field is ignored. */
116 unsigned long value; /* In command GPTU_REQUEST_TIMER, this field contains *
117 * init/reload value. *
118 * In command GPTU_SET_TIMER, this field contains *
119 * frequency (0.001Hz) of timer. *
120 * In command GPTU_GET_COUNT_VALUE, current count *
121 * value would be stored in this field. *
122 * In command GPTU_CALCULATE_DIVIDER, this field *
123 * contains frequency wanted, and after calculation, *
124 * divider would be stored in this field to overwrite *
125 * the frequency. *
126 * In other command, this field is ignored. */
127 int pid; /* In command GPTU_REQUEST_TIMER and GPTU_SET_TIMER, *
128 * if signal is required, this field contains process *
129 * ID to which signal would be sent. *
130 * In other command, this field is ignored. */
131 int sig; /* In command GPTU_REQUEST_TIMER and GPTU_SET_TIMER, *
132 * if signal is required, this field contains signal *
133 * number which would be sent. *
134 * In other command, this field is ignored. */
135 };
136
137 /*
138 * ####################################
139 * Data Type
140 * ####################################
141 */
142 typedef void (*timer_callback)(unsigned long arg);
143
144
145 #if defined(__KERNEL__)
146 extern int ifxmips_request_timer(unsigned int, unsigned int, unsigned long, unsigned long, unsigned long);
147 extern int ifxmips_free_timer(unsigned int);
148 extern int ifxmips_start_timer(unsigned int, int);
149 extern int ifxmips_stop_timer(unsigned int);
150 extern int ifxmips_reset_counter_flags(u32 timer, u32 flags);
151 extern int ifxmips_get_count_value(unsigned int, unsigned long *);
152
153 extern u32 cal_divider(unsigned long);
154
155 extern int set_timer(unsigned int, unsigned int, int, int, unsigned int, unsigned long, unsigned long);
156 extern int set_counter (unsigned int timer, unsigned int flag, u32 reload, unsigned long arg1, unsigned long arg2);
157 // extern int set_counter(unsigned int, int, int, int, unsigned int, unsigned int, unsigned long, unsigned long);
158 #endif // defined(__KERNEL__)
159
160
161 #endif // __DANUBE_GPTU_DEV_H__2005_07_26__10_19__