Ralf Baechle | 35189fa | 2006-06-18 16:39:46 +0100 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2004, 2005 by Basler Vision Technologies AG |
| 3 | * Author: Thomas Koeller <thomas.koeller@baslerweb.com> |
| 4 | * |
| 5 | * Procfs support for Basler eXcite |
| 6 | * |
| 7 | * This program is free software; you can redistribute it and/or modify |
| 8 | * it under the terms of the GNU General Public License as published by |
| 9 | * the Free Software Foundation; either version 2 of the License, or |
| 10 | * (at your option) any later version. |
| 11 | * |
| 12 | * This program is distributed in the hope that it will be useful, |
| 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 15 | * GNU General Public License for more details. |
| 16 | * |
| 17 | * You should have received a copy of the GNU General Public License |
| 18 | * along with this program; if not, write to the Free Software |
| 19 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 20 | */ |
Alexey Dobriyan | 4bd61f7 | 2008-04-29 01:01:50 -0700 | [diff] [blame] | 21 | #include <linux/module.h> |
Ralf Baechle | 35189fa | 2006-06-18 16:39:46 +0100 | [diff] [blame] | 22 | #include <linux/proc_fs.h> |
Alexey Dobriyan | 4bd61f7 | 2008-04-29 01:01:50 -0700 | [diff] [blame] | 23 | #include <linux/seq_file.h> |
Ralf Baechle | 35189fa | 2006-06-18 16:39:46 +0100 | [diff] [blame] | 24 | #include <linux/stat.h> |
| 25 | #include <asm/page.h> |
| 26 | #include <asm/io.h> |
| 27 | #include <asm/system.h> |
| 28 | #include <asm/rm9k-ocd.h> |
| 29 | |
| 30 | #include <excite.h> |
| 31 | |
Alexey Dobriyan | 4bd61f7 | 2008-04-29 01:01:50 -0700 | [diff] [blame] | 32 | static int excite_unit_id_proc_show(struct seq_file *m, void *v) |
Ralf Baechle | 35189fa | 2006-06-18 16:39:46 +0100 | [diff] [blame] | 33 | { |
Alexey Dobriyan | 4bd61f7 | 2008-04-29 01:01:50 -0700 | [diff] [blame] | 34 | seq_printf(m, "%06x", unit_id); |
| 35 | return 0; |
Ralf Baechle | 35189fa | 2006-06-18 16:39:46 +0100 | [diff] [blame] | 36 | } |
| 37 | |
Alexey Dobriyan | 4bd61f7 | 2008-04-29 01:01:50 -0700 | [diff] [blame] | 38 | static int excite_unit_id_proc_open(struct inode *inode, struct file *file) |
| 39 | { |
| 40 | return single_open(file, excite_unit_id_proc_show, NULL); |
| 41 | } |
| 42 | |
| 43 | static const struct file_operations excite_unit_id_proc_fops = { |
| 44 | .owner = THIS_MODULE, |
| 45 | .open = excite_unit_id_proc_open, |
| 46 | .read = seq_read, |
| 47 | .llseek = seq_lseek, |
| 48 | .release = single_release, |
| 49 | }; |
| 50 | |
Ralf Baechle | 35189fa | 2006-06-18 16:39:46 +0100 | [diff] [blame] | 51 | static int |
| 52 | excite_bootrom_read(char *page, char **start, off_t off, int count, |
| 53 | int *eof, void *data) |
| 54 | { |
| 55 | void __iomem * src; |
| 56 | |
| 57 | if (off >= EXCITE_SIZE_BOOTROM) { |
| 58 | *eof = 1; |
| 59 | return 0; |
| 60 | } |
| 61 | |
| 62 | if ((off + count) > EXCITE_SIZE_BOOTROM) |
| 63 | count = EXCITE_SIZE_BOOTROM - off; |
| 64 | |
| 65 | src = ioremap(EXCITE_PHYS_BOOTROM + off, count); |
| 66 | if (src) { |
| 67 | memcpy_fromio(page, src, count); |
| 68 | iounmap(src); |
| 69 | *start = page; |
| 70 | } else { |
| 71 | count = -ENOMEM; |
| 72 | } |
| 73 | |
| 74 | return count; |
| 75 | } |
| 76 | |
| 77 | void excite_procfs_init(void) |
| 78 | { |
| 79 | /* Create & populate /proc/excite */ |
Alexey Dobriyan | c74c120 | 2008-04-29 01:01:44 -0700 | [diff] [blame] | 80 | struct proc_dir_entry * const pdir = proc_mkdir("excite", NULL); |
Ralf Baechle | 35189fa | 2006-06-18 16:39:46 +0100 | [diff] [blame] | 81 | if (pdir) { |
| 82 | struct proc_dir_entry * e; |
| 83 | |
Alexey Dobriyan | 4bd61f7 | 2008-04-29 01:01:50 -0700 | [diff] [blame] | 84 | e = proc_create("unit_id", S_IRUGO, pdir, |
| 85 | &excite_unit_id_proc_fops); |
Ralf Baechle | 35189fa | 2006-06-18 16:39:46 +0100 | [diff] [blame] | 86 | if (e) e->size = 6; |
| 87 | |
| 88 | e = create_proc_read_entry("bootrom", S_IRUGO, pdir, |
| 89 | excite_bootrom_read, NULL); |
| 90 | if (e) e->size = EXCITE_SIZE_BOOTROM; |
| 91 | } |
| 92 | } |