aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrew Victor <andrew@sanpeople.com>2007-10-15 09:27:41 -0400
committerRussell King <rmk+kernel@arm.linux.org.uk>2008-01-26 09:38:48 -0500
commit20118ff97823822bf4d52ccb528ce2b5042c3057 (patch)
treeacb975d7b95373cd82e5ba0903926c032d895454
parent7d77ce8f67358c6b7708726f8fa230cd58d75b2c (diff)
[ARM] 4603/1: KS8695: debugfs interface to view pin state
This patch adds a debug interface (if CONFIG_DEBUG_FS is selected) to display the basic configuration and current state of the GPIO pins on the Kendin/Micrel KS8695 processor. Signed-off-by: Andrew Victor <andrew@sanpeople.com> Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>
-rw-r--r--arch/arm/mach-ks8695/gpio.c83
-rw-r--r--include/asm-arm/arch-ks8695/regs-gpio.h2
2 files changed, 85 insertions, 0 deletions
diff --git a/arch/arm/mach-ks8695/gpio.c b/arch/arm/mach-ks8695/gpio.c
index b1aa3cb3d4a3..5e46191c0af9 100644
--- a/arch/arm/mach-ks8695/gpio.c
+++ b/arch/arm/mach-ks8695/gpio.c
@@ -20,6 +20,8 @@
20#include <linux/kernel.h> 20#include <linux/kernel.h>
21#include <linux/mm.h> 21#include <linux/mm.h>
22#include <linux/init.h> 22#include <linux/init.h>
23#include <linux/debugfs.h>
24#include <linux/seq_file.h>
23#include <linux/module.h> 25#include <linux/module.h>
24 26
25#include <asm/io.h> 27#include <asm/io.h>
@@ -216,3 +218,84 @@ int irq_to_gpio(unsigned int irq)
216 return (irq - KS8695_IRQ_EXTERN0); 218 return (irq - KS8695_IRQ_EXTERN0);
217} 219}
218EXPORT_SYMBOL(irq_to_gpio); 220EXPORT_SYMBOL(irq_to_gpio);
221
222
223/* .... Debug interface ..................................................... */
224
225#ifdef CONFIG_DEBUG_FS
226
227static int ks8695_gpio_show(struct seq_file *s, void *unused)
228{
229 unsigned int enable[] = { IOPC_IOEINT0EN, IOPC_IOEINT1EN, IOPC_IOEINT2EN, IOPC_IOEINT3EN, IOPC_IOTIM0EN, IOPC_IOTIM1EN };
230 unsigned int intmask[] = { IOPC_IOEINT0TM, IOPC_IOEINT1TM, IOPC_IOEINT2TM, IOPC_IOEINT3TM };
231 unsigned long mode, ctrl, data;
232 int i;
233
234 mode = __raw_readl(KS8695_GPIO_VA + KS8695_IOPM);
235 ctrl = __raw_readl(KS8695_GPIO_VA + KS8695_IOPC);
236 data = __raw_readl(KS8695_GPIO_VA + KS8695_IOPD);
237
238 seq_printf(s, "Pin\tI/O\tFunction\tState\n\n");
239
240 for (i = KS8695_GPIO_0; i <= KS8695_GPIO_15 ; i++) {
241 seq_printf(s, "%i:\t", i);
242
243 seq_printf(s, "%s\t", (mode & IOPM_(i)) ? "Output" : "Input");
244
245 if (i <= KS8695_GPIO_3) {
246 if (ctrl & enable[i]) {
247 seq_printf(s, "EXT%i ", i);
248
249 switch ((ctrl & intmask[i]) >> (4 * i)) {
250 case IOPC_TM_LOW:
251 seq_printf(s, "(Low)"); break;
252 case IOPC_TM_HIGH:
253 seq_printf(s, "(High)"); break;
254 case IOPC_TM_RISING:
255 seq_printf(s, "(Rising)"); break;
256 case IOPC_TM_FALLING:
257 seq_printf(s, "(Falling)"); break;
258 case IOPC_TM_EDGE:
259 seq_printf(s, "(Edges)"); break;
260 }
261 }
262 else
263 seq_printf(s, "GPIO\t");
264 }
265 else if (i <= KS8695_GPIO_5) {
266 if (ctrl & enable[i])
267 seq_printf(s, "TOUT%i\t", i - KS8695_GPIO_4);
268 else
269 seq_printf(s, "GPIO\t");
270 }
271 else
272 seq_printf(s, "GPIO\t");
273
274 seq_printf(s, "\t");
275
276 seq_printf(s, "%i\n", (data & IOPD_(i)) ? 1 : 0);
277 }
278 return 0;
279}
280
281static int ks8695_gpio_open(struct inode *inode, struct file *file)
282{
283 return single_open(file, ks8695_gpio_show, NULL);
284}
285
286static const struct file_operations ks8695_gpio_operations = {
287 .open = ks8695_gpio_open,
288 .read = seq_read,
289 .llseek = seq_lseek,
290 .release = single_release,
291};
292
293static int __init ks8695_gpio_debugfs_init(void)
294{
295 /* /sys/kernel/debug/ks8695_gpio */
296 (void) debugfs_create_file("ks8695_gpio", S_IFREG | S_IRUGO, NULL, NULL, &ks8695_gpio_operations);
297 return 0;
298}
299postcore_initcall(ks8695_gpio_debugfs_init);
300
301#endif
diff --git a/include/asm-arm/arch-ks8695/regs-gpio.h b/include/asm-arm/arch-ks8695/regs-gpio.h
index 57fcf9fc82e4..6b95d77aea19 100644
--- a/include/asm-arm/arch-ks8695/regs-gpio.h
+++ b/include/asm-arm/arch-ks8695/regs-gpio.h
@@ -49,5 +49,7 @@
49#define IOPC_TM_FALLING (4) /* Falling Edge Detection */ 49#define IOPC_TM_FALLING (4) /* Falling Edge Detection */
50#define IOPC_TM_EDGE (6) /* Both Edge Detection */ 50#define IOPC_TM_EDGE (6) /* Both Edge Detection */
51 51
52/* Port Data Register */
53#define IOPD_(x) (1 << (x)) /* Signal Level of GPIO Pin x */
52 54
53#endif 55#endif