From patchwork Thu Aug 25 13:47:03 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Lezcano X-Patchwork-Id: 3675 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id C714923F22 for ; Thu, 25 Aug 2011 13:47:08 +0000 (UTC) Received: from mail-gw0-f52.google.com (mail-gw0-f52.google.com [74.125.83.52]) by fiordland.canonical.com (Postfix) with ESMTP id 82754A188C7 for ; Thu, 25 Aug 2011 13:47:08 +0000 (UTC) Received: by gwj15 with SMTP id 15so2491533gwj.11 for ; Thu, 25 Aug 2011 06:47:08 -0700 (PDT) Received: by 10.150.240.14 with SMTP id n14mr966974ybh.41.1314280027955; Thu, 25 Aug 2011 06:47:07 -0700 (PDT) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.151.27.20 with SMTP id e20cs238187ybj; Thu, 25 Aug 2011 06:47:07 -0700 (PDT) Received: by 10.216.72.139 with SMTP id t11mr5550035wed.91.1314280025389; Thu, 25 Aug 2011 06:47:05 -0700 (PDT) Received: from mtagate2.uk.ibm.com (mtagate2.uk.ibm.com [194.196.100.162]) by mx.google.com with ESMTPS id l23si1583121weq.92.2011.08.25.06.47.04 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 25 Aug 2011 06:47:05 -0700 (PDT) Received-SPF: neutral (google.com: 194.196.100.162 is neither permitted nor denied by best guess record for domain of daniel.lezcano@linaro.org) client-ip=194.196.100.162; Authentication-Results: mx.google.com; spf=neutral (google.com: 194.196.100.162 is neither permitted nor denied by best guess record for domain of daniel.lezcano@linaro.org) smtp.mail=daniel.lezcano@linaro.org Received: from d06nrmr1507.portsmouth.uk.ibm.com (d06nrmr1507.portsmouth.uk.ibm.com [9.149.38.233]) by mtagate2.uk.ibm.com (8.13.1/8.13.1) with ESMTP id p7PDl4sn020733 for ; Thu, 25 Aug 2011 13:47:04 GMT Received: from d06av07.portsmouth.uk.ibm.com (d06av07.portsmouth.uk.ibm.com [9.149.37.248]) by d06nrmr1507.portsmouth.uk.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id p7PDl4t02597010 for ; Thu, 25 Aug 2011 14:47:04 +0100 Received: from d06av07.portsmouth.uk.ibm.com (loopback [127.0.0.1]) by d06av07.portsmouth.uk.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id p7PDl3Kq025252 for ; Thu, 25 Aug 2011 07:47:03 -0600 Received: from smtp.lab.toulouse-stg.fr.ibm.com (srv01.lab.toulouse-stg.fr.ibm.com [9.101.4.1]) by d06av07.portsmouth.uk.ibm.com (8.14.4/8.13.1/NCO v10.0 AVin) with ESMTP id p7PDl3S5025226; Thu, 25 Aug 2011 07:47:03 -0600 Received: from localhost.localdomain (sig-9-145-110-19.uk.ibm.com [9.145.110.19]) by smtp.lab.toulouse-stg.fr.ibm.com (Postfix) with ESMTP id C10D921101F; Thu, 25 Aug 2011 15:47:02 +0200 (CEST) From: Daniel Lezcano To: linaro-dev@lists.linaro.org Subject: [powerdebug 3/7] read the gpio directory structure Date: Thu, 25 Aug 2011 15:47:03 +0200 Message-Id: <1314280027-7547-3-git-send-email-daniel.lezcano@linaro.org> X-Mailer: git-send-email 1.7.4.1 In-Reply-To: <1314280027-7547-1-git-send-email-daniel.lezcano@linaro.org> References: <1314280027-7547-1-git-send-email-daniel.lezcano@linaro.org> Read the gpio directory structure where we will read the different data we are interested in. Signed-off-by: Daniel Lezcano --- Makefile | 2 +- gpio.c | 103 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ gpio.h | 17 ++++++++++ 3 files changed, 121 insertions(+), 1 deletions(-) create mode 100644 gpio.c create mode 100644 gpio.h 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 (IBM Corporation) + * - initial API and implementation + *******************************************************************************/ + +#ifndef _GNU_SOURCE +#define _GNU_SOURCE +#include +#undef _GNU_SOURCE +#endif +#include +#include +#include +#include +#include +#include +#include + +#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 (IBM Corporation) + * - initial API and implementation + *******************************************************************************/ + +extern int gpio_init(void); +extern int gpio_dump(void);