blob: acf1fa88944456119619e57d2813041e3eb04b20 [file] [log] [blame]
Pete Popovbdf21b12005-07-14 17:47:57 +00001/*
2 * This program is free software; you can distribute it and/or modify it
3 * under the terms of the GNU General Public License (Version 2) as
4 * published by the Free Software Foundation.
5 *
6 * This program is distributed in the hope it will be useful, but WITHOUT
7 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
8 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
9 * for more details.
10 *
11 * You should have received a copy of the GNU General Public License along
12 * with this program; if not, write to the Free Software Foundation, Inc.,
13 * 59 Temple Place - Suite 330, Boston MA 02111-1307, USA.
14 */
15#include <linux/init.h>
16#include <linux/proc_fs.h>
17#include <linux/irq.h>
18#include <linux/sched.h>
19#include <linux/slab.h>
20#include <linux/interrupt.h>
21#include <linux/kernel_stat.h>
22#include <linux/random.h>
23
24#include <asm/io.h>
Pete Popovbdf21b12005-07-14 17:47:57 +000025#include <int.h>
26#include <uart.h>
27
28
Ralf Baechle49a89ef2007-10-11 23:46:15 +010029static int pnx8550_timers_read(char* page, char** start, off_t offset, int count, int* eof, void* data)
Pete Popovbdf21b12005-07-14 17:47:57 +000030{
31 int len = 0;
32 int configPR = read_c0_config7();
33
34 if (offset==0) {
Ralf Baechle21a151d2007-10-11 23:46:15 +010035 len += sprintf(&page[len], "Timer: count, compare, tc, status\n");
36 len += sprintf(&page[len], " 1: %11i, %8i, %1i, %s\n",
Pete Popovbdf21b12005-07-14 17:47:57 +000037 read_c0_count(), read_c0_compare(),
38 (configPR>>6)&0x1, ((configPR>>3)&0x1)? "off":"on");
Ralf Baechle21a151d2007-10-11 23:46:15 +010039 len += sprintf(&page[len], " 2: %11i, %8i, %1i, %s\n",
Pete Popovbdf21b12005-07-14 17:47:57 +000040 read_c0_count2(), read_c0_compare2(),
41 (configPR>>7)&0x1, ((configPR>>4)&0x1)? "off":"on");
Ralf Baechle21a151d2007-10-11 23:46:15 +010042 len += sprintf(&page[len], " 3: %11i, %8i, %1i, %s\n",
Pete Popovbdf21b12005-07-14 17:47:57 +000043 read_c0_count3(), read_c0_compare3(),
44 (configPR>>8)&0x1, ((configPR>>5)&0x1)? "off":"on");
45 }
46
47 return len;
48}
49
Ralf Baechle49a89ef2007-10-11 23:46:15 +010050static int pnx8550_registers_read(char* page, char** start, off_t offset, int count, int* eof, void* data)
Pete Popovbdf21b12005-07-14 17:47:57 +000051{
52 int len = 0;
53
54 if (offset==0) {
Ralf Baechle21a151d2007-10-11 23:46:15 +010055 len += sprintf(&page[len], "config1: %#10.8x\n", read_c0_config1());
56 len += sprintf(&page[len], "config2: %#10.8x\n", read_c0_config2());
57 len += sprintf(&page[len], "config3: %#10.8x\n", read_c0_config3());
58 len += sprintf(&page[len], "configPR: %#10.8x\n", read_c0_config7());
59 len += sprintf(&page[len], "status: %#10.8x\n", read_c0_status());
60 len += sprintf(&page[len], "cause: %#10.8x\n", read_c0_cause());
61 len += sprintf(&page[len], "count: %#10.8x\n", read_c0_count());
62 len += sprintf(&page[len], "count_2: %#10.8x\n", read_c0_count2());
63 len += sprintf(&page[len], "count_3: %#10.8x\n", read_c0_count3());
64 len += sprintf(&page[len], "compare: %#10.8x\n", read_c0_compare());
65 len += sprintf(&page[len], "compare_2: %#10.8x\n", read_c0_compare2());
66 len += sprintf(&page[len], "compare_3: %#10.8x\n", read_c0_compare3());
Pete Popovbdf21b12005-07-14 17:47:57 +000067 }
68
69 return len;
70}
71
72static struct proc_dir_entry* pnx8550_dir = NULL;
73static struct proc_dir_entry* pnx8550_timers = NULL;
74static struct proc_dir_entry* pnx8550_registers = NULL;
75
76static int pnx8550_proc_init( void )
77{
78
79 // Create /proc/pnx8550
Robert P. J. Day105b1bc2007-07-10 06:37:56 -040080 pnx8550_dir = proc_mkdir("pnx8550", NULL);
Alexey Dobriyanb653d0812007-02-10 01:45:54 -080081 if (!pnx8550_dir) {
Pete Popovbdf21b12005-07-14 17:47:57 +000082 printk(KERN_ERR "Can't create pnx8550 proc dir\n");
83 return -1;
84 }
85
86 // Create /proc/pnx8550/timers
Robert P. J. Day105b1bc2007-07-10 06:37:56 -040087 pnx8550_timers = create_proc_read_entry(
88 "timers",
89 0,
90 pnx8550_dir,
91 pnx8550_timers_read,
92 NULL);
93
94 if (!pnx8550_timers)
Pete Popovbdf21b12005-07-14 17:47:57 +000095 printk(KERN_ERR "Can't create pnx8550 timers proc file\n");
Pete Popovbdf21b12005-07-14 17:47:57 +000096
97 // Create /proc/pnx8550/registers
Robert P. J. Day105b1bc2007-07-10 06:37:56 -040098 pnx8550_registers = create_proc_read_entry(
99 "registers",
100 0,
101 pnx8550_dir,
102 pnx8550_registers_read,
103 NULL);
104
105 if (!pnx8550_registers)
Pete Popovbdf21b12005-07-14 17:47:57 +0000106 printk(KERN_ERR "Can't create pnx8550 registers proc file\n");
Pete Popovbdf21b12005-07-14 17:47:57 +0000107
108 return 0;
109}
110
111__initcall(pnx8550_proc_init);