aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Lezcano <daniel.lezcano@linaro.org>2011-08-25 15:46:13 +0200
committerDaniel Lezcano <daniel.lezcano@linaro.org>2011-08-25 15:46:13 +0200
commit03fc66bc96ad1664465568f7d99fad17f1e68794 (patch)
treebb98d2050af45db39e47e1b4516b3154885d3fc8
parent269de4f0bbe07a6607eac062129fc0fd68c5a32e (diff)
downloadpowerdebugV2-03fc66bc96ad1664465568f7d99fad17f1e68794.tar.gz
read the gpio directory structure
Read the gpio directory structure where we will read the different data we are interested in. Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
-rw-r--r--Makefile2
-rw-r--r--gpio.c103
-rw-r--r--gpio.h17
3 files changed, 121 insertions, 1 deletions
diff --git a/Makefile b/Makefile
index 8d41b24..2da9d67 100644
--- a/Makefile
+++ b/Makefile
@@ -4,7 +4,7 @@ MANDIR=/usr/share/man/man8
CFLAGS?=-O1 -g -Wall -Wshadow
CC?=gcc
-OBJS = powerdebug.o sensor.o clocks.o regulator.o \
+OBJS = powerdebug.o sensor.o clocks.o regulator.o gpio.o \
display.o tree.o utils.o mainloop.o
default: powerdebug
diff --git a/gpio.c b/gpio.c
new file mode 100644
index 0000000..fc60d00
--- /dev/null
+++ b/gpio.c
@@ -0,0 +1,103 @@
+/*******************************************************************************
+ * Copyright (C) 2010, Linaro Limited.
+ *
+ * This file is part of PowerDebug.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Daniel Lezcano <daniel.lezcano@linaro.org> (IBM Corporation)
+ * - initial API and implementation
+ *******************************************************************************/
+
+#ifndef _GNU_SOURCE
+#define _GNU_SOURCE
+#include <stdio.h>
+#undef _GNU_SOURCE
+#endif
+#include <mntent.h>
+#include <string.h>
+#include <stdbool.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <sys/param.h>
+#include <sys/stat.h>
+
+#include "powerdebug.h"
+#include "display.h"
+#include "tree.h"
+#include "utils.h"
+
+#define SYSFS_GPIO "/sys/class/gpio"
+
+static struct tree *gpio_tree = NULL;
+
+static int gpio_display(bool refresh)
+{
+ return 0;
+}
+
+static int gpio_select(void)
+{
+ return 0;
+}
+
+static int gpio_find(const char *name)
+{
+ return 0;
+}
+
+static int gpio_selectf(void)
+{
+ return 0;
+}
+
+static struct display_ops gpio_ops = {
+ .display = gpio_display,
+ .select = gpio_select,
+ .find = gpio_find,
+ .selectf = gpio_selectf,
+};
+
+static inline int read_gpio_cb(struct tree *t, void *data)
+{
+ return 0;
+}
+
+static int read_gpio_info(struct tree *tree)
+{
+ return 0;
+}
+
+static int fill_gpio_cb(struct tree *t, void *data)
+{
+ return 0;
+}
+
+static int fill_gpio_tree(void)
+{
+ return 0;
+}
+
+int gpio_dump(void)
+{
+ return 0;
+}
+
+/*
+ * Initialize the gpio framework
+ */
+int gpio_init(void)
+{
+ gpio_tree = tree_load(SYSFS_GPIO, NULL, false);
+ if (!gpio_tree)
+ return -1;
+
+ if (fill_gpio_tree())
+ return -1;
+
+ return display_register(GPIO, &gpio_ops);
+}
diff --git a/gpio.h b/gpio.h
new file mode 100644
index 0000000..38f035f
--- /dev/null
+++ b/gpio.h
@@ -0,0 +1,17 @@
+/*******************************************************************************
+ * Copyright (C) 2010, Linaro Limited.
+ *
+ * This file is part of PowerDebug.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Daniel Lezcano <daniel.lezcano@linaro.org> (IBM Corporation)
+ * - initial API and implementation
+ *******************************************************************************/
+
+extern int gpio_init(void);
+extern int gpio_dump(void);