| Pete Popov | bdf21b1 | 2005-07-14 17:47:57 +0000 | [diff] [blame] | 1 | /* | 
 | 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> | 
| Pete Popov | bdf21b1 | 2005-07-14 17:47:57 +0000 | [diff] [blame] | 19 | #include <linux/interrupt.h> | 
 | 20 | #include <linux/kernel_stat.h> | 
 | 21 | #include <linux/random.h> | 
 | 22 |  | 
 | 23 | #include <asm/io.h> | 
| Pete Popov | bdf21b1 | 2005-07-14 17:47:57 +0000 | [diff] [blame] | 24 | #include <int.h> | 
 | 25 | #include <uart.h> | 
 | 26 |  | 
 | 27 |  | 
| Ralf Baechle | 49a89ef | 2007-10-11 23:46:15 +0100 | [diff] [blame] | 28 | static int pnx8550_timers_read(char* page, char** start, off_t offset, int count, int* eof, void* data) | 
| Pete Popov | bdf21b1 | 2005-07-14 17:47:57 +0000 | [diff] [blame] | 29 | { | 
 | 30 |         int len = 0; | 
 | 31 | 	int configPR = read_c0_config7(); | 
 | 32 |  | 
 | 33 |         if (offset==0) { | 
| Ralf Baechle | 21a151d | 2007-10-11 23:46:15 +0100 | [diff] [blame] | 34 | 		len += sprintf(&page[len], "Timer:       count,  compare, tc, status\n"); | 
 | 35 |                 len += sprintf(&page[len], "    1: %11i, %8i,  %1i, %s\n", | 
| Pete Popov | bdf21b1 | 2005-07-14 17:47:57 +0000 | [diff] [blame] | 36 | 			       read_c0_count(), read_c0_compare(), | 
 | 37 | 			      (configPR>>6)&0x1, ((configPR>>3)&0x1)? "off":"on"); | 
| Ralf Baechle | 21a151d | 2007-10-11 23:46:15 +0100 | [diff] [blame] | 38 |                 len += sprintf(&page[len], "    2: %11i, %8i,  %1i, %s\n", | 
| Pete Popov | bdf21b1 | 2005-07-14 17:47:57 +0000 | [diff] [blame] | 39 | 			       read_c0_count2(), read_c0_compare2(), | 
 | 40 | 			      (configPR>>7)&0x1, ((configPR>>4)&0x1)? "off":"on"); | 
| Ralf Baechle | 21a151d | 2007-10-11 23:46:15 +0100 | [diff] [blame] | 41 |                 len += sprintf(&page[len], "    3: %11i, %8i,  %1i, %s\n", | 
| Pete Popov | bdf21b1 | 2005-07-14 17:47:57 +0000 | [diff] [blame] | 42 | 			       read_c0_count3(), read_c0_compare3(), | 
 | 43 | 			      (configPR>>8)&0x1, ((configPR>>5)&0x1)? "off":"on"); | 
 | 44 |         } | 
 | 45 |  | 
 | 46 |         return len; | 
 | 47 | } | 
 | 48 |  | 
| Ralf Baechle | 49a89ef | 2007-10-11 23:46:15 +0100 | [diff] [blame] | 49 | static int pnx8550_registers_read(char* page, char** start, off_t offset, int count, int* eof, void* data) | 
| Pete Popov | bdf21b1 | 2005-07-14 17:47:57 +0000 | [diff] [blame] | 50 | { | 
 | 51 |         int len = 0; | 
 | 52 |  | 
 | 53 |         if (offset==0) { | 
| Ralf Baechle | 21a151d | 2007-10-11 23:46:15 +0100 | [diff] [blame] | 54 |                 len += sprintf(&page[len], "config1:   %#10.8x\n", read_c0_config1()); | 
 | 55 |                 len += sprintf(&page[len], "config2:   %#10.8x\n", read_c0_config2()); | 
 | 56 |                 len += sprintf(&page[len], "config3:   %#10.8x\n", read_c0_config3()); | 
 | 57 |                 len += sprintf(&page[len], "configPR:  %#10.8x\n", read_c0_config7()); | 
 | 58 |                 len += sprintf(&page[len], "status:    %#10.8x\n", read_c0_status()); | 
 | 59 |                 len += sprintf(&page[len], "cause:     %#10.8x\n", read_c0_cause()); | 
 | 60 |                 len += sprintf(&page[len], "count:     %#10.8x\n", read_c0_count()); | 
 | 61 |                 len += sprintf(&page[len], "count_2:   %#10.8x\n", read_c0_count2()); | 
 | 62 |                 len += sprintf(&page[len], "count_3:   %#10.8x\n", read_c0_count3()); | 
 | 63 |                 len += sprintf(&page[len], "compare:   %#10.8x\n", read_c0_compare()); | 
 | 64 |                 len += sprintf(&page[len], "compare_2: %#10.8x\n", read_c0_compare2()); | 
 | 65 |                 len += sprintf(&page[len], "compare_3: %#10.8x\n", read_c0_compare3()); | 
| Pete Popov | bdf21b1 | 2005-07-14 17:47:57 +0000 | [diff] [blame] | 66 |         } | 
 | 67 |  | 
 | 68 |         return len; | 
 | 69 | } | 
 | 70 |  | 
| Ralf Baechle | 982f6ff | 2009-09-17 02:25:07 +0200 | [diff] [blame] | 71 | static struct proc_dir_entry* pnx8550_dir; | 
 | 72 | static struct proc_dir_entry* pnx8550_timers; | 
 | 73 | static struct proc_dir_entry* pnx8550_registers; | 
| Pete Popov | bdf21b1 | 2005-07-14 17:47:57 +0000 | [diff] [blame] | 74 |  | 
 | 75 | static int pnx8550_proc_init( void ) | 
 | 76 | { | 
 | 77 |  | 
 | 78 | 	// Create /proc/pnx8550 | 
| Robert P. J. Day | 105b1bc | 2007-07-10 06:37:56 -0400 | [diff] [blame] | 79 |         pnx8550_dir = proc_mkdir("pnx8550", NULL); | 
| Alexey Dobriyan | b653d081 | 2007-02-10 01:45:54 -0800 | [diff] [blame] | 80 |         if (!pnx8550_dir) { | 
| Pete Popov | bdf21b1 | 2005-07-14 17:47:57 +0000 | [diff] [blame] | 81 |                 printk(KERN_ERR "Can't create pnx8550 proc dir\n"); | 
 | 82 |                 return -1; | 
 | 83 |         } | 
 | 84 |  | 
 | 85 | 	// Create /proc/pnx8550/timers | 
| Robert P. J. Day | 105b1bc | 2007-07-10 06:37:56 -0400 | [diff] [blame] | 86 |         pnx8550_timers = create_proc_read_entry( | 
 | 87 | 		"timers", | 
 | 88 | 		0, | 
 | 89 | 		pnx8550_dir, | 
 | 90 | 		pnx8550_timers_read, | 
 | 91 | 		NULL); | 
 | 92 |  | 
 | 93 |         if (!pnx8550_timers) | 
| Pete Popov | bdf21b1 | 2005-07-14 17:47:57 +0000 | [diff] [blame] | 94 |                 printk(KERN_ERR "Can't create pnx8550 timers proc file\n"); | 
| Pete Popov | bdf21b1 | 2005-07-14 17:47:57 +0000 | [diff] [blame] | 95 |  | 
 | 96 | 	// Create /proc/pnx8550/registers | 
| Robert P. J. Day | 105b1bc | 2007-07-10 06:37:56 -0400 | [diff] [blame] | 97 |         pnx8550_registers = create_proc_read_entry( | 
 | 98 | 		"registers", | 
 | 99 | 		0, | 
 | 100 | 		pnx8550_dir, | 
 | 101 | 		pnx8550_registers_read, | 
 | 102 | 		NULL); | 
 | 103 |  | 
 | 104 |         if (!pnx8550_registers) | 
| Pete Popov | bdf21b1 | 2005-07-14 17:47:57 +0000 | [diff] [blame] | 105 |                 printk(KERN_ERR "Can't create pnx8550 registers proc file\n"); | 
| Pete Popov | bdf21b1 | 2005-07-14 17:47:57 +0000 | [diff] [blame] | 106 |  | 
 | 107 | 	return 0; | 
 | 108 | } | 
 | 109 |  | 
 | 110 | __initcall(pnx8550_proc_init); |