aboutsummaryrefslogtreecommitdiffstats
path: root/arch/mips/mm/sc-mips.c
diff options
context:
space:
mode:
authorRussell King <rmk+kernel@arm.linux.org.uk>2013-03-28 10:36:05 -0400
committerRussell King <rmk+kernel@arm.linux.org.uk>2013-04-03 11:50:23 -0400
commitf8f02ec25ce3eafb049feeb3abf34fcd6e338241 (patch)
treeebaebfd89c34d48081f2de60932f5ee418f1358a /arch/mips/mm/sc-mips.c
parent9b56febea22003c424f11248908b534eba0f1eeb (diff)
ARM: entry: move disable_irq_notrace into svc_exit
All svc exit paths need IRQs off. Rather than placing this before every user of svc_exit, combine it into this macro. Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
Diffstat (limited to 'arch/mips/mm/sc-mips.c')
0 files changed, 0 insertions, 0 deletions
litmus_2019&id=6fd5c03f823dd6a3755b277243cd4b1718475ac0'>6fd5c03f823d
8a2601f6aa83
6fd5c03f823d




8a2601f6aa83
6fd5c03f823d




aa5bd7e92932




6fd5c03f823d
aa5bd7e92932






8a2601f6aa83

aa5bd7e92932
6fd5c03f823d



8a2601f6aa83



6fd5c03f823d



aa5bd7e92932


8a2601f6aa83






6fd5c03f823d
8a2601f6aa83



6fd5c03f823d
8a2601f6aa83
aa5bd7e92932
8a2601f6aa83




aa5bd7e92932
8a2601f6aa83
aa5bd7e92932
8a2601f6aa83
6fd5c03f823d

8a2601f6aa83
aa5bd7e92932

aa5bd7e92932








fe20ba70abf7







aa5bd7e92932
c814dc136f20
aa5bd7e92932




6fd5c03f823d
aa5bd7e92932

2a4e2b8780c6
aa5bd7e92932




6fd5c03f823d

aa5bd7e92932







fe20ba70abf7







8a2601f6aa83

aa5bd7e92932

















6fd5c03f823d
aa5bd7e92932
6fd5c03f823d
aa5bd7e92932



6fd5c03f823d
aa5bd7e92932

aa5bd7e92932
6fd5c03f823d

aa5bd7e92932

6fd5c03f823d

aa5bd7e92932
6fd5c03f823d
aa5bd7e92932
6fd5c03f823d

aa5bd7e92932
6fd5c03f823d
aa5bd7e92932

6fd5c03f823d


aa5bd7e92932



aa5bd7e92932

fe102c71a65a




6fd5c03f823d





fe102c71a65a
6fd5c03f823d

aa5bd7e92932










6fd5c03f823d
aa5bd7e92932




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
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280


















                                                                        
                         



                   






                                                                        
                                                             




                                                                                






                                                                           

                                            
                                            

                                            


                                                                               
                                        


                                                                    


                                                              
                 




                                               
                 




                                          
                 




                                                 
                 




                                                         




                                                                   
                                                                              






                                                                           

                                                                  
                 



                                                



                                                                              



                                              


               






                                                                          
 



                                                        
 
                                              
 




                                                                               
                                              
 
                 
 

                                                                       
                    

 








                                                                                







                                                                      
 
                                




                                                                     
                                                                             

                                                                            
                                  




                            

                                                                          







                                                     







                                                                        

                                                 

















                                                                         
                                                    
 
                                                            



                                           
                 

 
                                                     

                                           

  

                                                                        
 
                               
 

                                                                    
 
                                                                               

                                                             


                                                                               



                                        

 




                                            





                                           
                               

  










                                               
                                                       




                            
/*
 * rtc class driver for the Maxim MAX6900 chip
 *
 * Author: Dale Farnsworth <dale@farnsworth.org>
 *
 * based on previously existing rtc class drivers
 *
 * 2007 (c) MontaVista, Software, Inc.  This file is licensed under
 * the terms of the GNU General Public License version 2.  This program
 * is licensed "as is" without any warranty of any kind, whether express
 * or implied.
 */

#include <linux/module.h>
#include <linux/i2c.h>
#include <linux/bcd.h>
#include <linux/rtc.h>
#include <linux/delay.h>

#define DRV_VERSION "0.2"

/*
 * register indices
 */
#define MAX6900_REG_SC			0	/* seconds      00-59 */
#define MAX6900_REG_MN			1	/* minutes      00-59 */
#define MAX6900_REG_HR			2	/* hours        00-23 */
#define MAX6900_REG_DT			3	/* day of month 00-31 */
#define MAX6900_REG_MO			4	/* month        01-12 */
#define MAX6900_REG_DW			5	/* day of week   1-7  */
#define MAX6900_REG_YR			6	/* year         00-99 */
#define MAX6900_REG_CT			7	/* control */
						/* register 8 is undocumented */
#define MAX6900_REG_CENTURY		9	/* century */
#define MAX6900_REG_LEN			10

#define MAX6900_BURST_LEN		8	/* can burst r/w first 8 regs */

#define MAX6900_REG_CT_WP		(1 << 7)	/* Write Protect */

/*
 * register read/write commands
 */
#define MAX6900_REG_CONTROL_WRITE	0x8e
#define MAX6900_REG_CENTURY_WRITE	0x92
#define MAX6900_REG_CENTURY_READ	0x93
#define MAX6900_REG_RESERVED_READ	0x96
#define MAX6900_REG_BURST_WRITE		0xbe
#define MAX6900_REG_BURST_READ		0xbf

#define MAX6900_IDLE_TIME_AFTER_WRITE	3	/* specification says 2.5 mS */

static struct i2c_driver max6900_driver;

static int max6900_i2c_read_regs(struct i2c_client *client, u8 *buf)
{
	u8 reg_burst_read[1] = { MAX6900_REG_BURST_READ };
	u8 reg_century_read[1] = { MAX6900_REG_CENTURY_READ };
	struct i2c_msg msgs[4] = {
		{
		 .addr = client->addr,
		 .flags = 0,	/* write */
		 .len = sizeof(reg_burst_read),
		 .buf = reg_burst_read}
		,
		{
		 .addr = client->addr,
		 .flags = I2C_M_RD,
		 .len = MAX6900_BURST_LEN,
		 .buf = buf}
		,
		{
		 .addr = client->addr,
		 .flags = 0,	/* write */
		 .len = sizeof(reg_century_read),
		 .buf = reg_century_read}
		,
		{
		 .addr = client->addr,
		 .flags = I2C_M_RD,
		 .len = sizeof(buf[MAX6900_REG_CENTURY]),
		 .buf = &buf[MAX6900_REG_CENTURY]
		 }
	};
	int rc;

	rc = i2c_transfer(client->adapter, msgs, ARRAY_SIZE(msgs));
	if (rc != ARRAY_SIZE(msgs)) {
		dev_err(&client->dev, "%s: register read failed\n", __func__);
		return -EIO;
	}
	return 0;
}

static int max6900_i2c_write_regs(struct i2c_client *client, u8 const *buf)
{
	u8 i2c_century_buf[1 + 1] = { MAX6900_REG_CENTURY_WRITE };
	struct i2c_msg century_msgs[1] = {
		{
		 .addr = client->addr,
		 .flags = 0,	/* write */
		 .len = sizeof(i2c_century_buf),
		 .buf = i2c_century_buf}
	};
	u8 i2c_burst_buf[MAX6900_BURST_LEN + 1] = { MAX6900_REG_BURST_WRITE };
	struct i2c_msg burst_msgs[1] = {
		{
		 .addr = client->addr,
		 .flags = 0,	/* write */
		 .len = sizeof(i2c_burst_buf),
		 .buf = i2c_burst_buf}
	};
	int rc;

	/*
	 * We have to make separate calls to i2c_transfer because of
	 * the need to delay after each write to the chip.  Also,
	 * we write the century byte first, since we set the write-protect
	 * bit as part of the burst write.
	 */
	i2c_century_buf[1] = buf[MAX6900_REG_CENTURY];

	rc = i2c_transfer(client->adapter, century_msgs,
			  ARRAY_SIZE(century_msgs));
	if (rc != ARRAY_SIZE(century_msgs))
		goto write_failed;

	msleep(MAX6900_IDLE_TIME_AFTER_WRITE);

	memcpy(&i2c_burst_buf[1], buf, MAX6900_BURST_LEN);

	rc = i2c_transfer(client->adapter, burst_msgs, ARRAY_SIZE(burst_msgs));
	if (rc != ARRAY_SIZE(burst_msgs))
		goto write_failed;
	msleep(MAX6900_IDLE_TIME_AFTER_WRITE);

	return 0;

 write_failed:
	dev_err(&client->dev, "%s: register write failed\n", __func__);
	return -EIO;
}

static int max6900_i2c_read_time(struct i2c_client *client, struct rtc_time *tm)
{
	int rc;
	u8 regs[MAX6900_REG_LEN];

	rc = max6900_i2c_read_regs(client, regs);
	if (rc < 0)
		return rc;

	tm->tm_sec = bcd2bin(regs[MAX6900_REG_SC]);
	tm->tm_min = bcd2bin(regs[MAX6900_REG_MN]);
	tm->tm_hour = bcd2bin(regs[MAX6900_REG_HR] & 0x3f);
	tm->tm_mday = bcd2bin(regs[MAX6900_REG_DT]);
	tm->tm_mon = bcd2bin(regs[MAX6900_REG_MO]) - 1;
	tm->tm_year = bcd2bin(regs[MAX6900_REG_YR]) +
		      bcd2bin(regs[MAX6900_REG_CENTURY]) * 100 - 1900;
	tm->tm_wday = bcd2bin(regs[MAX6900_REG_DW]);

	return rtc_valid_tm(tm);
}

static int max6900_i2c_clear_write_protect(struct i2c_client *client)
{
	int rc;
	rc = i2c_smbus_write_byte_data(client, MAX6900_REG_CONTROL_WRITE, 0);
	if (rc < 0) {
		dev_err(&client->dev, "%s: control register write failed\n",
			__func__);
		return -EIO;
	}
	return 0;
}

static int
max6900_i2c_set_time(struct i2c_client *client, struct rtc_time const *tm)
{