aboutsummaryrefslogtreecommitdiffstats
path: root/arch/cris/arch-v32/drivers
diff options
context:
space:
mode:
Diffstat (limited to 'arch/cris/arch-v32/drivers')
-rw-r--r--arch/cris/arch-v32/drivers/Kconfig1
-rw-r--r--arch/cris/arch-v32/drivers/Makefile1
-rw-r--r--arch/cris/arch-v32/drivers/axisflashmap.c8
-rw-r--r--arch/cris/arch-v32/drivers/mach-a3/nandflash.c2
-rw-r--r--arch/cris/arch-v32/drivers/mach-fs/nandflash.c2
-rw-r--r--arch/cris/arch-v32/drivers/pcf8563.c377
-rw-r--r--arch/cris/arch-v32/drivers/sync_serial.c2
7 files changed, 4 insertions, 389 deletions
diff --git a/arch/cris/arch-v32/drivers/Kconfig b/arch/cris/arch-v32/drivers/Kconfig
index a2dd740c5907..1633b120aa81 100644
--- a/arch/cris/arch-v32/drivers/Kconfig
+++ b/arch/cris/arch-v32/drivers/Kconfig
@@ -406,7 +406,6 @@ config ETRAX_AXISFLASHMAP
406 select MTD_CHAR 406 select MTD_CHAR
407 select MTD_BLOCK 407 select MTD_BLOCK
408 select MTD_PARTITIONS 408 select MTD_PARTITIONS
409 select MTD_CONCAT
410 select MTD_COMPLEX_MAPPINGS 409 select MTD_COMPLEX_MAPPINGS
411 help 410 help
412 This option enables MTD mapping of flash devices. Needed to use 411 This option enables MTD mapping of flash devices. Needed to use
diff --git a/arch/cris/arch-v32/drivers/Makefile b/arch/cris/arch-v32/drivers/Makefile
index e8c02437edaf..39aa3c117a86 100644
--- a/arch/cris/arch-v32/drivers/Makefile
+++ b/arch/cris/arch-v32/drivers/Makefile
@@ -7,7 +7,6 @@ obj-$(CONFIG_ETRAX_AXISFLASHMAP) += axisflashmap.o
7obj-$(CONFIG_ETRAXFS) += mach-fs/ 7obj-$(CONFIG_ETRAXFS) += mach-fs/
8obj-$(CONFIG_CRIS_MACH_ARTPEC3) += mach-a3/ 8obj-$(CONFIG_CRIS_MACH_ARTPEC3) += mach-a3/
9obj-$(CONFIG_ETRAX_IOP_FW_LOAD) += iop_fw_load.o 9obj-$(CONFIG_ETRAX_IOP_FW_LOAD) += iop_fw_load.o
10obj-$(CONFIG_ETRAX_PCF8563) += pcf8563.o
11obj-$(CONFIG_ETRAX_I2C) += i2c.o 10obj-$(CONFIG_ETRAX_I2C) += i2c.o
12obj-$(CONFIG_ETRAX_SYNCHRONOUS_SERIAL) += sync_serial.o 11obj-$(CONFIG_ETRAX_SYNCHRONOUS_SERIAL) += sync_serial.o
13obj-$(CONFIG_PCI) += pci/ 12obj-$(CONFIG_PCI) += pci/
diff --git a/arch/cris/arch-v32/drivers/axisflashmap.c b/arch/cris/arch-v32/drivers/axisflashmap.c
index 51e1e85df96d..7b155f8203b8 100644
--- a/arch/cris/arch-v32/drivers/axisflashmap.c
+++ b/arch/cris/arch-v32/drivers/axisflashmap.c
@@ -215,7 +215,7 @@ static struct mtd_partition main_partition = {
215}; 215};
216#endif 216#endif
217 217
218/* Auxilliary partition if we find another flash */ 218/* Auxiliary partition if we find another flash */
219static struct mtd_partition aux_partition = { 219static struct mtd_partition aux_partition = {
220 .name = "aux", 220 .name = "aux",
221 .size = 0, 221 .size = 0,
@@ -275,7 +275,6 @@ static struct mtd_info *flash_probe(void)
275 } 275 }
276 276
277 if (count > 1) { 277 if (count > 1) {
278#ifdef CONFIG_MTD_CONCAT
279 /* Since the concatenation layer adds a small overhead we 278 /* Since the concatenation layer adds a small overhead we
280 * could try to figure out if the chips in cse0 and cse1 are 279 * could try to figure out if the chips in cse0 and cse1 are
281 * identical and reprobe the whole cse0+cse1 window. But since 280 * identical and reprobe the whole cse0+cse1 window. But since
@@ -284,11 +283,6 @@ static struct mtd_info *flash_probe(void)
284 * complicating the probing procedure. 283 * complicating the probing procedure.
285 */ 284 */
286 mtd_total = mtd_concat_create(mtds, count, "cse0+cse1"); 285 mtd_total = mtd_concat_create(mtds, count, "cse0+cse1");
287#else
288 printk(KERN_ERR "%s and %s: Cannot concatenate due to kernel "
289 "(mis)configuration!\n", map_cse0.name, map_cse1.name);
290 mtd_toal = NULL;
291#endif
292 if (!mtd_total) { 286 if (!mtd_total) {
293 printk(KERN_ERR "%s and %s: Concatenation failed!\n", 287 printk(KERN_ERR "%s and %s: Concatenation failed!\n",
294 map_cse0.name, map_cse1.name); 288 map_cse0.name, map_cse1.name);
diff --git a/arch/cris/arch-v32/drivers/mach-a3/nandflash.c b/arch/cris/arch-v32/drivers/mach-a3/nandflash.c
index 25d6f2b3a721..f58f2c1c5295 100644
--- a/arch/cris/arch-v32/drivers/mach-a3/nandflash.c
+++ b/arch/cris/arch-v32/drivers/mach-a3/nandflash.c
@@ -165,7 +165,7 @@ struct mtd_info *__init crisv32_nand_flash_probe(void)
165 /* Enable the following for a flash based bad block table */ 165 /* Enable the following for a flash based bad block table */
166 /* this->options = NAND_USE_FLASH_BBT; */ 166 /* this->options = NAND_USE_FLASH_BBT; */
167 167
168 /* Scan to find existance of the device */ 168 /* Scan to find existence of the device */
169 if (nand_scan(crisv32_mtd, 1)) { 169 if (nand_scan(crisv32_mtd, 1)) {
170 err = -ENXIO; 170 err = -ENXIO;
171 goto out_mtd; 171 goto out_mtd;
diff --git a/arch/cris/arch-v32/drivers/mach-fs/nandflash.c b/arch/cris/arch-v32/drivers/mach-fs/nandflash.c
index c5a0f54763cc..d5b0cc9f976b 100644
--- a/arch/cris/arch-v32/drivers/mach-fs/nandflash.c
+++ b/arch/cris/arch-v32/drivers/mach-fs/nandflash.c
@@ -156,7 +156,7 @@ struct mtd_info *__init crisv32_nand_flash_probe(void)
156 /* Enable the following for a flash based bad block table */ 156 /* Enable the following for a flash based bad block table */
157 /* this->options = NAND_USE_FLASH_BBT; */ 157 /* this->options = NAND_USE_FLASH_BBT; */
158 158
159 /* Scan to find existance of the device */ 159 /* Scan to find existence of the device */
160 if (nand_scan(crisv32_mtd, 1)) { 160 if (nand_scan(crisv32_mtd, 1)) {
161 err = -ENXIO; 161 err = -ENXIO;
162 goto out_ior; 162 goto out_ior;
diff --git a/arch/cris/arch-v32/drivers/pcf8563.c b/arch/cris/arch-v32/drivers/pcf8563.c
deleted file mode 100644
index b6e4fc0aad42..000000000000
--- a/arch/cris/arch-v32/drivers/pcf8563.c
+++ /dev/null
@@ -1,377 +0,0 @@
1/*
2 * PCF8563 RTC
3 *
4 * From Phillips' datasheet:
5 *
6 * The PCF8563 is a CMOS real-time clock/calendar optimized for low power
7 * consumption. A programmable clock output, interrupt output and voltage
8 * low detector are also provided. All address and data are transferred
9 * serially via two-line bidirectional I2C-bus. Maximum bus speed is
10 * 400 kbits/s. The built-in word address register is incremented
11 * automatically after each written or read byte.
12 *
13 * Copyright (c) 2002-2007, Axis Communications AB
14 * All rights reserved.
15 *
16 * Author: Tobias Anderberg <tobiasa@axis.com>.
17 *
18 */
19
20#include <linux/module.h>
21#include <linux/kernel.h>
22#include <linux/types.h>
23#include <linux/sched.h>
24#include <linux/init.h>
25#include <linux/fs.h>
26#include <linux/ioctl.h>
27#include <linux/delay.h>
28#include <linux/bcd.h>
29#include <linux/mutex.h>
30
31#include <asm/uaccess.h>
32#include <asm/system.h>
33#include <asm/io.h>
34#include <asm/rtc.h>
35
36#include "i2c.h"
37
38#define PCF8563_MAJOR 121 /* Local major number. */
39#define DEVICE_NAME "rtc" /* Name which is registered in /proc/devices. */
40#define PCF8563_NAME "PCF8563"
41#define DRIVER_VERSION "$Revision: 1.17 $"
42
43/* Two simple wrapper macros, saves a few keystrokes. */
44#define rtc_read(x) i2c_readreg(RTC_I2C_READ, x)
45#define rtc_write(x,y) i2c_writereg(RTC_I2C_WRITE, x, y)
46
47static DEFINE_MUTEX(pcf8563_mutex);
48static DEFINE_MUTEX(rtc_lock); /* Protect state etc */
49
50static const unsigned char days_in_month[] =
51 { 0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
52
53static long pcf8563_unlocked_ioctl(struct file *filp, unsigned int cmd, unsigned long arg);
54
55/* Cache VL bit value read at driver init since writing the RTC_SECOND
56 * register clears the VL status.
57 */
58static int voltage_low;
59
60static const struct file_operations pcf8563_fops = {
61 .owner = THIS_MODULE,
62 .unlocked_ioctl = pcf8563_unlocked_ioctl,
63 .llseek = noop_llseek,
64};
65
66unsigned char
67pcf8563_readreg(int reg)
68{
69 unsigned char res = rtc_read(reg);
70
71 /* The PCF8563 does not return 0 for unimplemented bits. */
72 switch (reg) {
73 case RTC_SECONDS:
74 case RTC_MINUTES:
75 res &= 0x7F;
76 break;
77 case RTC_HOURS:
78 case RTC_DAY_OF_MONTH:
79 res &= 0x3F;
80 break;
81 case RTC_WEEKDAY:
82 res &= 0x07;
83 break;
84 case RTC_MONTH:
85 res &= 0x1F;
86 break;
87 case RTC_CONTROL1:
88 res &= 0xA8;
89 break;
90 case RTC_CONTROL2:
91 res &= 0x1F;
92 break;
93 case RTC_CLOCKOUT_FREQ:
94 case RTC_TIMER_CONTROL:
95 res &= 0x83;
96 break;
97 }
98 return res;
99}
100
101void
102pcf8563_writereg(int reg, unsigned char val)
103{
104 rtc_write(reg, val);
105}
106
107void
108get_rtc_time(struct rtc_time *tm)
109{
110 tm->tm_sec = rtc_read(RTC_SECONDS);
111 tm->tm_min = rtc_read(RTC_MINUTES);
112 tm->tm_hour = rtc_read(RTC_HOURS);
113 tm->tm_mday = rtc_read(RTC_DAY_OF_MONTH);
114 tm->tm_wday = rtc_read(RTC_WEEKDAY);
115 tm->tm_mon = rtc_read(RTC_MONTH);
116 tm->tm_year = rtc_read(RTC_YEAR);
117
118 if (tm->tm_sec & 0x80) {
119 printk(KERN_ERR "%s: RTC Voltage Low - reliable date/time "
120 "information is no longer guaranteed!\n", PCF8563_NAME);
121 }
122
123 tm->tm_year = bcd2bin(tm->tm_year) +
124 ((tm->tm_mon & 0x80) ? 100 : 0);
125 tm->tm_sec &= 0x7F;
126 tm->tm_min &= 0x7F;
127 tm->tm_hour &= 0x3F;
128 tm->tm_mday &= 0x3F;
129 tm->tm_wday &= 0x07; /* Not coded in BCD. */
130 tm->tm_mon &= 0x1F;
131
132 tm->tm_sec = bcd2bin(tm->tm_sec);
133 tm->tm_min = bcd2bin(tm->tm_min);
134 tm->tm_hour = bcd2bin(tm->tm_hour);
135 tm->tm_mday = bcd2bin(tm->tm_mday);
136 tm->tm_mon = bcd2bin(tm->tm_mon);
137 tm->tm_mon--; /* Month is 1..12 in RTC but 0..11 in linux */
138}
139
140int __init
141pcf8563_init(void)
142{
143 static int res;
144 static int first = 1;
145
146 if (!first)
147 return res;
148 first = 0;
149
150 /* Initiate the i2c protocol. */
151 res = i2c_init();
152 if (res < 0) {
153 printk(KERN_CRIT "pcf8563_init: Failed to init i2c.\n");
154 return res;
155 }
156
157 /*
158 * First of all we need to reset the chip. This is done by
159 * clearing control1, control2 and clk freq and resetting
160 * all alarms.
161 */
162 if (rtc_write(RTC_CONTROL1, 0x00) < 0)
163 goto err;
164
165 if (rtc_write(RTC_CONTROL2, 0x00) < 0)
166 goto err;
167
168 if (rtc_write(RTC_CLOCKOUT_FREQ, 0x00) < 0)
169 goto err;
170
171 if (rtc_write(RTC_TIMER_CONTROL, 0x03) < 0)
172 goto err;
173
174 /* Reset the alarms. */
175 if (rtc_write(RTC_MINUTE_ALARM, 0x80) < 0)
176 goto err;
177
178 if (rtc_write(RTC_HOUR_ALARM, 0x80) < 0)
179 goto err;
180
181 if (rtc_write(RTC_DAY_ALARM, 0x80) < 0)
182 goto err;
183
184 if (rtc_write(RTC_WEEKDAY_ALARM, 0x80) < 0)
185 goto err;
186
187 /* Check for low voltage, and warn about it. */
188 if (rtc_read(RTC_SECONDS) & 0x80) {
189 voltage_low = 1;
190 printk(KERN_WARNING "%s: RTC Voltage Low - reliable "
191 "date/time information is no longer guaranteed!\n",
192 PCF8563_NAME);
193 }
194
195 return res;
196
197err:
198 printk(KERN_INFO "%s: Error initializing chip.\n", PCF8563_NAME);
199 res = -1;
200 return res;
201}
202
203void __exit
204pcf8563_exit(void)
205{
206 unregister_chrdev(PCF8563_MAJOR, DEVICE_NAME);
207}
208
209/*
210 * ioctl calls for this driver. Why return -ENOTTY upon error? Because
211 * POSIX says so!
212 */
213static int pcf8563_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
214{
215 /* Some sanity checks. */
216 if (_IOC_TYPE(cmd) != RTC_MAGIC)
217 return -ENOTTY;
218
219 if (_IOC_NR(cmd) > RTC_MAX_IOCTL)
220 return -ENOTTY;
221
222 switch (cmd) {
223 case RTC_RD_TIME:
224 {
225 struct rtc_time tm;
226
227 mutex_lock(&rtc_lock);
228 memset(&tm, 0, sizeof tm);
229 get_rtc_time(&tm);
230
231 if (copy_to_user((struct rtc_time *) arg, &tm,
232 sizeof tm)) {
233 mutex_unlock(&rtc_lock);
234 return -EFAULT;
235 }
236
237 mutex_unlock(&rtc_lock);
238
239 return 0;
240 }
241 case RTC_SET_TIME:
242 {
243 int leap;
244 int year;
245 int century;
246 struct rtc_time tm;
247
248 memset(&tm, 0, sizeof tm);
249 if (!capable(CAP_SYS_TIME))
250 return -EPERM;
251
252 if (copy_from_user(&tm, (struct rtc_time *) arg,
253 sizeof tm))
254 return -EFAULT;
255
256 /* Convert from struct tm to struct rtc_time. */
257 tm.tm_year += 1900;
258 tm.tm_mon += 1;
259
260 /*
261 * Check if tm.tm_year is a leap year. A year is a leap
262 * year if it is divisible by 4 but not 100, except
263 * that years divisible by 400 _are_ leap years.
264 */
265 year = tm.tm_year;
266 leap = (tm.tm_mon == 2) &&
267 ((year % 4 == 0 && year % 100 != 0) || year % 400 == 0);
268
269 /* Perform some sanity checks. */
270 if ((tm.tm_year < 1970) ||
271 (tm.tm_mon > 12) ||
272 (tm.tm_mday == 0) ||
273 (tm.tm_mday > days_in_month[tm.tm_mon] + leap) ||
274 (tm.tm_wday >= 7) ||
275 (tm.tm_hour >= 24) ||
276 (tm.tm_min >= 60) ||
277 (tm.tm_sec >= 60))
278 return -EINVAL;
279
280 century = (tm.tm_year >= 2000) ? 0x80 : 0;
281 tm.tm_year = tm.tm_year % 100;
282
283 tm.tm_year = bin2bcd(tm.tm_year);
284 tm.tm_mon = bin2bcd(tm.tm_mon);
285 tm.tm_mday = bin2bcd(tm.tm_mday);
286 tm.tm_hour = bin2bcd(tm.tm_hour);
287 tm.tm_min = bin2bcd(tm.tm_min);
288 tm.tm_sec = bin2bcd(tm.tm_sec);
289 tm.tm_mon |= century;
290
291 mutex_lock(&rtc_lock);
292
293 rtc_write(RTC_YEAR, tm.tm_year);
294 rtc_write(RTC_MONTH, tm.tm_mon);
295 rtc_write(RTC_WEEKDAY, tm.tm_wday); /* Not coded in BCD. */
296 rtc_write(RTC_DAY_OF_MONTH, tm.tm_mday);
297 rtc_write(RTC_HOURS, tm.tm_hour);
298 rtc_write(RTC_MINUTES, tm.tm_min);
299 rtc_write(RTC_SECONDS, tm.tm_sec);
300
301 mutex_unlock(&rtc_lock);
302
303 return 0;
304 }
305 case RTC_VL_READ:
306 if (voltage_low)
307 printk(KERN_ERR "%s: RTC Voltage Low - "
308 "reliable date/time information is no "
309 "longer guaranteed!\n", PCF8563_NAME);
310
311 if (copy_to_user((int *) arg, &voltage_low, sizeof(int)))
312 return -EFAULT;
313 return 0;
314
315 case RTC_VL_CLR:
316 {
317 /* Clear the VL bit in the seconds register in case
318 * the time has not been set already (which would
319 * have cleared it). This does not really matter
320 * because of the cached voltage_low value but do it
321 * anyway for consistency. */
322
323 int ret = rtc_read(RTC_SECONDS);
324
325 rtc_write(RTC_SECONDS, (ret & 0x7F));
326
327 /* Clear the cached value. */
328 voltage_low = 0;
329
330 return 0;
331 }
332 default:
333 return -ENOTTY;
334 }
335
336 return 0;
337}
338
339static long pcf8563_unlocked_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
340{
341 int ret;
342
343 mutex_lock(&pcf8563_mutex);
344 return pcf8563_ioctl(filp, cmd, arg);
345 mutex_unlock(&pcf8563_mutex);
346
347 return ret;
348}
349
350static int __init pcf8563_register(void)
351{
352 if (pcf8563_init() < 0) {
353 printk(KERN_INFO "%s: Unable to initialize Real-Time Clock "
354 "Driver, %s\n", PCF8563_NAME, DRIVER_VERSION);
355 return -1;
356 }
357
358 if (register_chrdev(PCF8563_MAJOR, DEVICE_NAME, &pcf8563_fops) < 0) {
359 printk(KERN_INFO "%s: Unable to get major numer %d for RTC "
360 "device.\n", PCF8563_NAME, PCF8563_MAJOR);
361 return -1;
362 }
363
364 printk(KERN_INFO "%s Real-Time Clock Driver, %s\n", PCF8563_NAME,
365 DRIVER_VERSION);
366
367 /* Check for low voltage, and warn about it. */
368 if (voltage_low) {
369 printk(KERN_WARNING "%s: RTC Voltage Low - reliable date/time "
370 "information is no longer guaranteed!\n", PCF8563_NAME);
371 }
372
373 return 0;
374}
375
376module_init(pcf8563_register);
377module_exit(pcf8563_exit);
diff --git a/arch/cris/arch-v32/drivers/sync_serial.c b/arch/cris/arch-v32/drivers/sync_serial.c
index c8637a9195ea..a6a180bc566f 100644
--- a/arch/cris/arch-v32/drivers/sync_serial.c
+++ b/arch/cris/arch-v32/drivers/sync_serial.c
@@ -33,7 +33,7 @@
33#include <asm/sync_serial.h> 33#include <asm/sync_serial.h>
34 34
35 35
36/* The receiver is a bit tricky beacuse of the continuous stream of data.*/ 36/* The receiver is a bit tricky because of the continuous stream of data.*/
37/* */ 37/* */
38/* Three DMA descriptors are linked together. Each DMA descriptor is */ 38/* Three DMA descriptors are linked together. Each DMA descriptor is */
39/* responsible for port->bufchunk of a common buffer. */ 39/* responsible for port->bufchunk of a common buffer. */