~ubuntu-branches/ubuntu/saucy/u-boot/saucy

« back to all changes in this revision

Viewing changes to debian/patches/dreamplug-untested-2.patch

  • Committer: Bazaar Package Importer
  • Author(s): Clint Adams
  • Date: 2011-07-24 09:35:32 UTC
  • mfrom: (16.1.16 sid)
  • Revision ID: james.westby@ubuntu.com-20110724093532-8gkkvtczkjagf4gv
Tags: 2011.06-3
Add DreamPlug support.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
From: Jason Cooper <u-boot@lakedaemon.net>
 
2
 
 
3
rewrite of the not-merged code from Globalscale Technologies.  This RTC is
 
4
known to exist in the DreamPlug platform and is accessed via two registers.
 
5
 
 
6
Signed-off-by: Jason Cooper <u-boot@lakedaemon.net>
 
7
---
 
8
Questions:
 
9
  - I completely rewrote this, should I add mention of Commercial/GPL2+/BSD
 
10
    (pick your license) source files I based it on?
 
11
        http://people.debian.org/~clint/dreamplug/dreamplug-uboot-gti.tar.gz
 
12
         - The link is a dirty git tree.  The uncommitted stuff is how they
 
13
           modified Guruplug u-boot to work on the Dreamplug.
 
14
                - chmod -x the changed files to undo the windows fs stuff.
 
15
                - the usb storage changes are already in.
 
16
                - I'm close on the SPI flash stuff.
 
17
                - This patch is the RTC driver.
 
18
                - Their MPP cfg is cleaner than mine, I'll use theirs.
 
19
                - I'll add the clock stuff in a future patch.
 
20
  - I feel that register definitions should be somewhere else, like SoC code.
 
21
    But I don't know if this is Dreamplug-specific, kirkwood-specific, or other?
 
22
  - common/cmd_date.c assumes I2C interface, is that harmless?
 
23
  - common/cmd_date.c checks return value.  The register ops have no return
 
24
    value.  I assume it's safe to always return zero?
 
25
  - Is there an easy way to calc the day of the year based on the info in the
 
26
    date register?  I don't like leaving that set ot zero.
 
27
  - This is compile-tested.  Once I get back to my Dreamplug, I will test.
 
28
  - checkpatch has 2 warnings about volatile.  My understanding is that it is
 
29
    needed when reading/writing registers.
 
30
 
 
31
 drivers/rtc/Makefile        |    1 +
 
32
 drivers/rtc/mvinteg_rtc.c   |  151 +++++++++++++++++++++++++++++++++++++++++++
 
33
 drivers/rtc/mvinteg_rtc.h   |   89 +++++++++++++++++++++++++
 
34
 include/configs/dreamplug.h |    8 ++
 
35
 4 files changed, 249 insertions(+), 0 deletions(-)
 
36
 create mode 100644 drivers/rtc/mvinteg_rtc.c
 
37
 create mode 100644 drivers/rtc/mvinteg_rtc.h
 
38
 
 
39
diff --git a/drivers/rtc/Makefile b/drivers/rtc/Makefile
 
40
index e4be4a4..ed63e9c 100644
 
41
--- a/drivers/rtc/Makefile
 
42
+++ b/drivers/rtc/Makefile
 
43
@@ -55,6 +55,7 @@ COBJS-$(CONFIG_MCFRTC) += mcfrtc.o
 
44
 COBJS-$(CONFIG_RTC_MK48T59) += mk48t59.o
 
45
 COBJS-$(CONFIG_RTC_MPC5200) += mpc5xxx.o
 
46
 COBJS-$(CONFIG_RTC_MPC8xx) += mpc8xx.o
 
47
+COBJS-$(CONFIG_RTC_MVINTEG) += mvinteg_rtc.o
 
48
 COBJS-$(CONFIG_RTC_PCF8563) += pcf8563.o
 
49
 COBJS-$(CONFIG_RTC_PL031) += pl031.o
 
50
 COBJS-$(CONFIG_RTC_PT7C4338) += pt7c4338.o
 
51
diff --git a/drivers/rtc/mvinteg_rtc.c b/drivers/rtc/mvinteg_rtc.c
 
52
new file mode 100644
 
53
index 0000000..1fcfba5
 
54
--- /dev/null
 
55
+++ b/drivers/rtc/mvinteg_rtc.c
 
56
@@ -0,0 +1,151 @@
 
57
+/*
 
58
+ * Copyright (C) 2011
 
59
+ * Jason Cooper <u-boot@lakedaemon.net>
 
60
+ *
 
61
+ * See file CREDITS for list of people who contributed to this
 
62
+ * project.
 
63
+ *
 
64
+ * This program is free software; you can redistribute it and/or
 
65
+ * modify it under the terms of the GNU General Public License as
 
66
+ * published by the Free Software Foundation; either version 2 of
 
67
+ * the License, or (at your option) any later version.
 
68
+ *
 
69
+ * This program is distributed in the hope that it will be useful,
 
70
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
71
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
72
+ * GNU General Public License for more details.
 
73
+ *
 
74
+ * You should have received a copy of the GNU General Public License
 
75
+ * along with this program; if not, write to the Free Software
 
76
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
 
77
+ * MA 02111-1307 USA
 
78
+ */
 
79
+
 
80
+/*
 
81
+ * Date & Time support for Marvell Integrated RTC
 
82
+ */
 
83
+
 
84
+#include <common.h>
 
85
+#include <command.h>
 
86
+#include <rtc.h>
 
87
+#include "mvinteg_rtc.h"
 
88
+
 
89
+/* This RTC does not support century, so we assume 20 */
 
90
+#define CENTURY 20
 
91
+
 
92
+int rtc_get(struct rtc_time *t)
 
93
+{
 
94
+       u32 time;
 
95
+       u32 date;
 
96
+       u8  tens;
 
97
+       u8  single;
 
98
+
 
99
+       /* read the time register */
 
100
+       time = MV_REG_READ(MVINTEG_RTCTIME_REG);
 
101
+
 
102
+       /* read the date register */
 
103
+       date = MV_REG_READ(MVINTEG_RTCDATE_REG);
 
104
+
 
105
+       /* seconds */
 
106
+       tens   = ((time & MVINTEG_10SEC_MSK) >> MVINTEG_10SEC_SFT);
 
107
+       single = ((time & MVINTEG_SEC_MSK)   >> MVINTEG_SEC_SFT);
 
108
+       t->tm_sec = 10 * tens + single;
 
109
+
 
110
+       /* minutes */
 
111
+       tens   = ((time & MVINTEG_10MIN_MSK) >> MVINTEG_10MIN_SFT);
 
112
+       single = ((time & MVINTEG_MIN_MSK)   >> MVINTEG_MIN_SFT);
 
113
+       t->tm_min = 10 * tens + single;
 
114
+
 
115
+       /* hours */
 
116
+       tens   = ((time & MVINTEG_10HOUR_MSK) >> MVINTEG_10HOUR_SFT);
 
117
+       single = ((time & MVINTEG_HOUR_MSK)   >> MVINTEG_HOUR_SFT);
 
118
+       t->tm_hour = 10 * tens + single;
 
119
+
 
120
+       /* day */
 
121
+       t->tm_wday = ((time & MVINTEG_DAY_MSK) >> MVINTEG_DAY_SFT);
 
122
+       t->tm_wday--;
 
123
+
 
124
+       /* date */
 
125
+       tens   = ((date & MVINTEG_10DATE_MSK) >> MVINTEG_10DATE_SFT);
 
126
+       single = ((date & MVINTEG_DATE_MSK)   >> MVINTEG_DATE_SFT);
 
127
+       t->tm_mday = 10 * tens + single;
 
128
+
 
129
+       /* month */
 
130
+       tens   = ((date & MVINTEG_10MON_MSK) >> MVINTEG_10MON_SFT);
 
131
+       single = ((date & MVINTEG_MON_MSK)   >> MVINTEG_MON_SFT);
 
132
+       t->tm_mon = 10 * tens + single;
 
133
+
 
134
+       /* year */
 
135
+       tens   = ((date * MVINTEG_10YEAR_MSK) >> MVINTEG_10YEAR_SFT);
 
136
+       single = ((date & MVINTEG_YEAR_MSK)   >> MVINTEG_YEAR_SFT);
 
137
+       t->tm_year = (CENTURY * 100) + (10 * tens) + single;
 
138
+
 
139
+       /* not supported in this RTC */
 
140
+       t->tm_yday  = 0;
 
141
+       t->tm_isdst = 0;
 
142
+
 
143
+       return 0;
 
144
+}
 
145
+
 
146
+int rtc_set(struct rtc_time *t)
 
147
+{
 
148
+       u32 time = 0;
 
149
+       u32 date = 0;
 
150
+       u32 tens;
 
151
+       u32 single;
 
152
+
 
153
+       /* seconds */
 
154
+       tens   = t->tm_sec / 10;
 
155
+       single = t->tm_sec % 10;
 
156
+       time |= ((tens   << MVINTEG_10SEC_SFT) & MVINTEG_10SEC_MSK) |
 
157
+               ((single << MVINTEG_SEC_SFT)   & MVINTEG_SEC_MSK);
 
158
+
 
159
+       /* minutes */
 
160
+       tens   = t->tm_min / 10;
 
161
+       single = t->tm_min % 10;
 
162
+       time |= ((tens   << MVINTEG_10MIN_SFT) & MVINTEG_10MIN_MSK) |
 
163
+               ((single << MVINTEG_MIN_SFT)   & MVINTEG_MIN_MSK);
 
164
+
 
165
+       /* hours (24) */
 
166
+       tens   = t->tm_hour / 10;
 
167
+       single = t->tm_hour % 10;
 
168
+       time |= ((tens   << MVINTEG_10HOUR_SFT) & MVINTEG_10HOUR_MSK) |
 
169
+               ((single << MVINTEG_HOUR_SFT)   & MVINTEG_HOUR_MSK);
 
170
+
 
171
+       /* day */
 
172
+       single = t->tm_wday + 1;
 
173
+       time |= ((single << MVINTEG_DAY_SFT) & MVINTEG_DAY_MSK);
 
174
+
 
175
+       /* date */
 
176
+       tens   = t->tm_mday / 10;
 
177
+       single = t->tm_mday % 10;
 
178
+       date |= ((tens   << MVINTEG_10DATE_SFT) & MVINTEG_10DATE_MSK) |
 
179
+               ((single << MVINTEG_DATE_SFT)   & MVINTEG_DATE_MSK);
 
180
+
 
181
+       /* month */
 
182
+       tens   = t->tm_mon / 10;
 
183
+       single = t->tm_mon % 10;
 
184
+       date |= ((tens   << MVINTEG_10MON_SFT) & MVINTEG_10MON_MSK) |
 
185
+               ((single << MVINTEG_MON_SFT)   & MVINTEG_MON_MSK);
 
186
+
 
187
+       /* year */
 
188
+       if ((t->tm_year / 100) != CENTURY)
 
189
+               printf("Warning: Only century %d supported.\n", CENTURY);
 
190
+       tens   = (t->tm_year % 100) / 10;
 
191
+       single = (t->tm_year % 100) % 10;
 
192
+       date |= ((tens   << MVINTEG_10YEAR_SFT) & MVINTEG_10YEAR_MSK) |
 
193
+               ((single << MVINTEG_YEAR_SFT)   & MVINTEG_YEAR_MSK);
 
194
+
 
195
+       /* write the time register */
 
196
+       MV_REG_WRITE(MVINTEG_RTCTIME_REG, time);
 
197
+
 
198
+       /* write the date register */
 
199
+       MV_REG_WRITE(MVINTEG_RTCDATE_REG, date);
 
200
+
 
201
+       return 0;
 
202
+}
 
203
+
 
204
+void rtc_reset(void)
 
205
+{
 
206
+       /* no init routine for this RTC needed */
 
207
+}
 
208
diff --git a/drivers/rtc/mvinteg_rtc.h b/drivers/rtc/mvinteg_rtc.h
 
209
new file mode 100644
 
210
index 0000000..08070d9
 
211
--- /dev/null
 
212
+++ b/drivers/rtc/mvinteg_rtc.h
 
213
@@ -0,0 +1,89 @@
 
214
+/*
 
215
+ * Copyright (C) 2011
 
216
+ * Jason Cooper <u-boot@lakedaemon.net>
 
217
+ *
 
218
+ * See file CREDITS for list of people who contributed to this
 
219
+ * project.
 
220
+ *
 
221
+ * This program is free software; you can redistribute it and/or
 
222
+ * modify it under the terms of the GNU General Public License as
 
223
+ * published by the Free Software Foundation; either version 2 of
 
224
+ * the License, or (at your option) any later version.
 
225
+ *
 
226
+ * This program is distributed in the hope that it will be useful,
 
227
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
228
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
229
+ * GNU General Public License for more details.
 
230
+ *
 
231
+ * You should have received a copy of the GNU General Public License
 
232
+ * along with this program; if not, write to the Free Software
 
233
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
 
234
+ * MA 02111-1307 USA
 
235
+ */
 
236
+
 
237
+/*
 
238
+ * Date & Time support for Marvell Integrated RTC
 
239
+ */
 
240
+
 
241
+#ifndef _MVINTEG_RTC_H_
 
242
+#define _MVINTEG_RTC_H_
 
243
+
 
244
+#include <compiler.h>
 
245
+
 
246
+#define INTERNAL_REG_BASE_ADDR 0xf1000000
 
247
+
 
248
+/* register operations macros */
 
249
+#define MV_REG_READ(offset) \
 
250
+       le32_to_cpu( \
 
251
+       *(volatile unsigned int *)(INTERNAL_REG_BASE_ADDR + offset))
 
252
+
 
253
+#define MV_REG_WRITE(offset, data) \
 
254
+       do { \
 
255
+               *(volatile unsigned int *)(INTERNAL_REG_BASE_ADDR + offset) = \
 
256
+               cpu_to_le32(data) \
 
257
+       } while (0);
 
258
+
 
259
+/* RTC registers */
 
260
+#define MVINTEG_RTCTIME_REG 0x10300
 
261
+#define MVINTEG_RTCDATE_REG 0x10304
 
262
+
 
263
+/* time register */
 
264
+#define MVINTEG_SEC_SFT                0
 
265
+#define MVINTEG_SEC_MSK                (0xf << MVINTEG_SEC_SFT)
 
266
+#define MVINTEG_10SEC_SFT      4
 
267
+#define MVINTEG_10SEC_MSK      (0x7 << MVINTEG_10SEC_SFT)
 
268
+
 
269
+#define MVINTEG_MIN_SFT                8
 
270
+#define MVINTEG_MIN_MSK                (0xf << MVINTEG_MIN_SFT)
 
271
+#define MVINTEG_10MIN_SFT      12
 
272
+#define MVINTEG_10MIN_MSK      (0x7 << MVINTEG_10MIN_SFT)
 
273
+
 
274
+#define MVINTEG_HOUR_SFT       16
 
275
+#define MVINTEG_HOUR_MSK       (0xf << MVINTEG_HOUR_SFT)
 
276
+#define MVINTEG_10HOUR_SFT     20
 
277
+#define MVINTEG_10HOUR_MSK     (0x3 << MVINTEG_10HOUR_SFT)
 
278
+
 
279
+#define MVINTEG_HRFMT_SFT      22
 
280
+#define MVINTEG_HRFMT12_MSK    (0x1 << MVINTEG_HRFMT_SFT)
 
281
+#define MVINTEG_HRFMT24_MSK    (0x0 << MVINTEG_HRFMT_SFT)
 
282
+
 
283
+#define MVINTEG_DAY_SFT                24
 
284
+#define MVINTEG_DAY_MSK                (0x7 << MVINTEG_DAY_SFT)
 
285
+
 
286
+/* date register */
 
287
+#define MVINTEG_DATE_SFT       0
 
288
+#define MVINTEG_DATE_MSK       (0xf << MVINTEG_DATE_SFT)
 
289
+#define MVINTEG_10DATE_SFT     4
 
290
+#define MVINTEG_10DATE_MSK     (0x3 << MVINTEG_10DATE_SFT)
 
291
+
 
292
+#define MVINTEG_MON_SFT                8
 
293
+#define MVINTEG_MON_MSK                (0xf << MVINTEG_MON_SFT)
 
294
+#define MVINTEG_10MON_SFT      12
 
295
+#define MVINTEG_10MON_MSK      (0x1 << MVINTEG_10MON_SFT)
 
296
+
 
297
+#define MVINTEG_YEAR_SFT       16
 
298
+#define MVINTEG_YEAR_MSK       (0xf << MVINTEG_YEAR_SFT)
 
299
+#define MVINTEG_10YEAR_SFT     20
 
300
+#define MVINTEG_10YEAR_MSK     (0xf << MVINTEG_10YEAR_SFT)
 
301
+
 
302
+#endif
 
303
diff --git a/include/configs/dreamplug.h b/include/configs/dreamplug.h
 
304
index 6aceed9..ed153fe 100644
 
305
--- a/include/configs/dreamplug.h
 
306
+++ b/include/configs/dreamplug.h
 
307
@@ -109,6 +109,14 @@
 
308
 #define CONFIG_SYS_ATA_IDE0_OFFSET     MV_SATA_PORT0_OFFSET
 
309
 #endif /*CONFIG_MVSATA_IDE*/
 
310
 
 
311
+/*
 
312
+ * RTC driver configuration
 
313
+ */
 
314
+#ifdef CONFIG_CMD_DATE
 
315
+#define CONFIG_RTC_MVINTEG
 
316
+#endif /* CONFIG_CMD_DATE */
 
317
+
 
318
+
 
319
 #define CONFIG_SYS_ALT_MEMTEST
 
320
 
 
321
 #endif /* _CONFIG_DREAMPLUG_H */
 
322
-- 
 
323
1.7.0.4