public inbox for linux-omap@vger.kernel.org
 help / color / mirror / Atom feed
From: Tony Lindgren <tony-4v6yS6AI5VpBDgjK7y7TUQ@public.gmane.org>
To: Kevin Hilman <khilman-1D3HCaltpLuhEniVeURVKkEOCMrvLtNR@public.gmane.org>
Cc: linux-arm-kernel-xIg/pKzrS19vn6HldHNs0ANdhmdF6hFW@public.gmane.org,
	linux-arm-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	linux-omap-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	Peter 'p2' De Schrijver
	<peter.de-schrijver-xNZwKgViW5gAvxtiuMwx3w@public.gmane.org>
Subject: Re: [PATCH 08/10] OMAP3: Debug observability and ETK padconf implementation
Date: Mon, 17 Aug 2009 11:07:19 +0300	[thread overview]
Message-ID: <20090817080718.GJ7278@atomide.com> (raw)
In-Reply-To: <1250182359-18830-9-git-send-email-khilman-1D3HCaltpLuhEniVeURVKkEOCMrvLtNR@public.gmane.org>

* Kevin Hilman <khilman-1D3HCaltpLuhEniVeURVKkEOCMrvLtNR@public.gmane.org> [090813 19:53]:
> From: Peter 'p2' De Schrijver <peter.de-schrijver-xNZwKgViW5gAvxtiuMwx3w@public.gmane.org>
> 
> Signed-off-by: Peter 'p2' De Schrijver <peter.de-schrijver-xNZwKgViW5gAvxtiuMwx3w@public.gmane.org>
> Signed-off-by: Kevin Hilman <khilman-1D3HCaltpLuhEniVeURVKkEOCMrvLtNR@public.gmane.org>
> ---
>  arch/arm/mach-omap2/debobs.c             |  240 ++++++++++++++++++++++++++++++
>  arch/arm/plat-omap/include/mach/debobs.h |    7 +
>  2 files changed, 247 insertions(+), 0 deletions(-)
>  create mode 100644 arch/arm/mach-omap2/debobs.c
>  create mode 100644 arch/arm/plat-omap/include/mach/debobs.h
> 
> diff --git a/arch/arm/mach-omap2/debobs.c b/arch/arm/mach-omap2/debobs.c
> new file mode 100644
> index 0000000..397a599
> --- /dev/null
> +++ b/arch/arm/mach-omap2/debobs.c
> @@ -0,0 +1,240 @@
> +/*
> + * arch/arm/mach-omap2/debobs.c

Should this name be 34xx-debobs.c?


> + *
> + * Handle debobs pads
> + *
> + * Copyright (C) 2008 Nokia Corporation
> + *
> + * Written by Peter De Schrijver <peter.de-schrijver-xNZwKgViW5gAvxtiuMwx3w@public.gmane.org>
> + *
> + * This file is subject to the terms and conditions of the GNU General
> + * Public License. See the file "COPYING" in the main directory of this
> + * archive for more details.
> + *
> + * This program is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> + * GNU General Public License for more details.
> + *
> + * You should have received a copy of the GNU General Public License
> + * along with this program; if not, write to the Free Software
> + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
> + */
> +
> +
> +#include <linux/kernel.h>
> +#include <linux/init.h>
> +#include <linux/debugfs.h>
> +#include <linux/uaccess.h>
> +#include <linux/module.h>
> +#include <linux/gpio.h>
> +
> +#include <mach/control.h>
> +#include <mach/mux.h>
> +#include <mach/board.h>
> +
> +#define ETK_GPIO_BEGIN		12
> +#define ETK_GPIO(i)		(ETK_GPIO_BEGIN + i)
> +#define NUM_OF_DEBOBS_PADS	18
> +
> +static int debobs_initialized;
> +
> +enum debobs_pad_mode {
> +	GPIO = 0,
> +	OBS = 1,
> +	ETK = 2,
> +	NO_MODE = 3,
> +};
> +
> +static char *debobs_pad_mode_names[] = {
> +	[GPIO] = "GPIO",
> +	[OBS] = "OBS",
> +	[ETK] = "ETK",
> +};
> +
> +struct obs {
> +	u16 offset;
> +	u8 value;
> +	u8 mask;
> +};
> +
> +struct debobs_pad {
> +	enum debobs_pad_mode mode;
> +	struct obs core_obs;
> +	struct obs wakeup_obs;
> +};
> +
> +static struct debobs_pad debobs_pads[NUM_OF_DEBOBS_PADS];
> +
> +static int debobs_mode_open(struct inode *inode, struct file *file)
> +{
> +	file->private_data = inode->i_private;
> +
> +	return 0;
> +}
> +
> +static ssize_t debobs_mode_read(struct file *file, char __user *user_buf,
> +				size_t count, loff_t *ppos)
> +{
> +	char buffer[10];
> +	int size;
> +	int pad_number = (int)file->private_data;
> +	struct debobs_pad *e = &debobs_pads[pad_number];
> +
> +	size = snprintf(buffer, sizeof(buffer), "%s\n",
> +			debobs_pad_mode_names[e->mode]);
> +	return simple_read_from_buffer(user_buf, count, ppos, buffer, size);
> +}
> +
> +static ssize_t debobs_mode_write(struct file *file, const char __user *user_buf,
> +				size_t count, loff_t *ppos)
> +{
> +	char buffer[10];
> +	int buf_size, i, pad_number;
> +	u16 muxmode = OMAP34XX_MUX_MODE7;
> +
> +	memset(buffer, 0, sizeof(buffer));
> +	buf_size = min(count, (sizeof(buffer)-1));
> +
> +	if (copy_from_user(buffer, user_buf, buf_size))
> +		return -EFAULT;
> +
> +	pad_number = (int)file->private_data;
> +
> +	for (i = 0; i < NO_MODE; i++) {
> +		if (!strnicmp(debobs_pad_mode_names[i],
> +				buffer,
> +				strlen(debobs_pad_mode_names[i]))) {
> +			switch (i) {
> +			case ETK:
> +				muxmode = OMAP34XX_MUX_MODE0;
> +				break;
> +			case GPIO:
> +				muxmode = OMAP34XX_MUX_MODE4;
> +				break;
> +			case OBS:
> +				muxmode = OMAP34XX_MUX_MODE7;
> +				break;
> +			}
> +			omap_ctrl_writew(muxmode,
> +					OMAP343X_PADCONF_ETK(pad_number));
> +			debobs_pads[pad_number].mode = i;
> +
> +			return count;
> +		}
> +	}
> +
> +	return -EINVAL;
> +}

We need to keep processor specific stuff out of generic code in general.
Otherwise we'll easily mess up things for the other processors.


> +
> +static const struct file_operations debobs_mode_fops = {
> +	.open 	= debobs_mode_open,
> +	.read	= debobs_mode_read,
> +	.write	= debobs_mode_write,
> +};
> +
> +static int debobs_get(void *data, u64 *val)
> +{
> +	struct obs *o = data;
> +
> +	*val = o->value;
> +
> +	return 0;
> +}
> +
> +static int debobs_set(void *data, u64 val)
> +{
> +	struct obs *o = data;
> +
> +	val &= BIT(o->mask) - 1;
> +
> +	omap_ctrl_writeb(val, o->offset);
> +	o->value = val;
> +
> +	return 0;
> +}
> +
> +DEFINE_SIMPLE_ATTRIBUTE(debobs_fops, debobs_get, debobs_set, "%llu\n");
> +
> +static inline int __init _new_debobs_pad(struct debobs_pad *pad, char *name,
> +					int number, struct dentry *root)
> +{
> +	struct dentry *d;
> +	struct obs *o;
> +
> +	d = debugfs_create_dir(name, root);
> +	if (IS_ERR(d))
> +		return PTR_ERR(d);
> +
> +	omap_ctrl_writew(OMAP34XX_MUX_MODE4, OMAP343X_PADCONF_ETK(number));
> +	gpio_direction_input(ETK_GPIO(number));
> +	gpio_export(ETK_GPIO(number), 1);
> +	(void) debugfs_create_file("mode", S_IRUGO | S_IWUGO, d,
> +					(void *)number, &debobs_mode_fops);
> +
> +	o = &pad->core_obs;
> +	o->offset = OMAP343X_CONTROL_DEBOBS(number);
> +	o->value = omap_ctrl_readw(o->offset);
> +	o->mask = 7;
> +	(void) debugfs_create_file("coreobs", S_IRUGO | S_IWUGO, d, o,
> +					&debobs_fops);
> +
> +	o = &pad->wakeup_obs;
> +	o->offset = OMAP343X_CONTROL_WKUP_DEBOBSMUX(number);
> +	o->value = omap_ctrl_readb(o->offset);
> +	o->mask = 5;
> +	(void) debugfs_create_file("wakeupobs", S_IRUGO | S_IWUGO, d, o,
> +					&debobs_fops);
> +
> +	return 0;
> +}
> +
> +/* Public functions */
> +
> +void debug_gpio_set(unsigned gpio, int value)
> +{
> +	if (!debobs_initialized)
> +		return ;
> +
> +	WARN_ON(gpio >= NUM_OF_DEBOBS_PADS);
> +	if (gpio < NUM_OF_DEBOBS_PADS)
> +		__gpio_set_value(ETK_GPIO(gpio), value);
> +}
> +
> +int debug_gpio_get(unsigned gpio)
> +{
> +	if (!debobs_initialized)
> +		return -EINVAL;
> +
> +	WARN_ON(gpio >= NUM_OF_DEBOBS_PADS);
> +	if (gpio < NUM_OF_DEBOBS_PADS)
> +		return __gpio_get_value(ETK_GPIO(gpio));
> +
> +	return -EINVAL;
> +}
> +
> +int __init init_debobs(void)
> +{
> +	struct dentry *debobs_root;
> +	int i, err;
> +	char name[10];
> +
> +	debobs_root = debugfs_create_dir("debobs", NULL);
> +	if (IS_ERR(debobs_root))
> +		return PTR_ERR(debobs_root);
> +
> +	for (i = 0; i < NUM_OF_DEBOBS_PADS; i++) {
> +		snprintf(name, sizeof(name), "hw_dbg%d", i);
> +		if (!gpio_request(ETK_GPIO(i), name)) {
> +			err = _new_debobs_pad(&debobs_pads[i], name, i,
> +						debobs_root);
> +		} else
> +			gpio_free(ETK_GPIO(i));
> +	}
> +
> +	debobs_initialized = 1;
> +
> +	return 0;
> +}
> +
> +late_initcall_sync(init_debobs);
> diff --git a/arch/arm/plat-omap/include/mach/debobs.h b/arch/arm/plat-omap/include/mach/debobs.h
> new file mode 100644
> index 0000000..67f765d
> --- /dev/null
> +++ b/arch/arm/plat-omap/include/mach/debobs.h
> @@ -0,0 +1,7 @@
> +#ifndef __DEBOBS_H
> +#define __DEBOBS_H
> +
> +void debug_gpio_set(unsigned gpio, int value);
> +int debug_gpio_get(unsigned gpio);
> +
> +#endif
> -- 
> 1.6.4
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-arm" in
> the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
--
To unsubscribe from this list: send the line "unsubscribe linux-arm" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

  parent reply	other threads:[~2009-08-17  8:07 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-08-13 16:52 [PATCH 00/10] OMAP PM debug infrastructure for 2.6.32 Kevin Hilman
     [not found] ` <1250182359-18830-1-git-send-email-khilman-1D3HCaltpLuhEniVeURVKkEOCMrvLtNR@public.gmane.org>
2009-08-13 16:52   ` [PATCH 01/10] OMAP: PM counter infrastructure Kevin Hilman
2009-08-13 16:52     ` [PATCH 02/10] OMAP: PM: Hook into PM counters Kevin Hilman
     [not found]       ` <1250182359-18830-3-git-send-email-khilman-1D3HCaltpLuhEniVeURVKkEOCMrvLtNR@public.gmane.org>
2009-08-13 16:52         ` [PATCH 03/10] OMAP: PM: Add closures to clkdm_for_each and pwrdm_for_each Kevin Hilman
     [not found]           ` <1250182359-18830-4-git-send-email-khilman-1D3HCaltpLuhEniVeURVKkEOCMrvLtNR@public.gmane.org>
2009-08-13 16:52             ` [PATCH 04/10] OMAP: PM: Add pm-debug counters Kevin Hilman
2009-08-13 16:52               ` [PATCH 05/10] OMAP: PM debug: make powerdomains use PM-debug counters Kevin Hilman
     [not found]                 ` <1250182359-18830-6-git-send-email-khilman-1D3HCaltpLuhEniVeURVKkEOCMrvLtNR@public.gmane.org>
2009-08-13 16:52                   ` [PATCH 06/10] OMAP: PM debug: Add PRCM register dump support Kevin Hilman
     [not found]                     ` <1250182359-18830-7-git-send-email-khilman-1D3HCaltpLuhEniVeURVKkEOCMrvLtNR@public.gmane.org>
2009-08-13 16:52                       ` [PATCH 07/10] OMAP: PM: Add definitions for ETK pads and observability registers Kevin Hilman
     [not found]                         ` <1250182359-18830-8-git-send-email-khilman-1D3HCaltpLuhEniVeURVKkEOCMrvLtNR@public.gmane.org>
2009-08-13 16:52                           ` [PATCH 08/10] OMAP3: Debug observability and ETK padconf implementation Kevin Hilman
     [not found]                             ` <1250182359-18830-9-git-send-email-khilman-1D3HCaltpLuhEniVeURVKkEOCMrvLtNR@public.gmane.org>
2009-08-13 16:52                               ` [PATCH 09/10] OMAP3: Add debug observablity (debobs) Kconfig item Kevin Hilman
     [not found]                                 ` <1250182359-18830-10-git-send-email-khilman-1D3HCaltpLuhEniVeURVKkEOCMrvLtNR@public.gmane.org>
2009-08-13 16:52                                   ` [PATCH 10/10] OMAP: PM: Added suspend target state control to debugfs for OMAP3 Kevin Hilman
     [not found]                                     ` <1250182359-18830-11-git-send-email-khilman-1D3HCaltpLuhEniVeURVKkEOCMrvLtNR@public.gmane.org>
2009-08-13 18:42                                       ` Aguirre Rodriguez, Sergio Alberto
     [not found]                                         ` <A24693684029E5489D1D202277BE89444A78398A-EovWT4A8QTWIQmiDNMet8wC/G2K4zDHf@public.gmane.org>
2009-08-13 21:35                                           ` Kevin Hilman
2009-08-17  8:10                                       ` Tony Lindgren
2009-08-18 12:43                                         ` Kevin Hilman
2009-08-17  8:08                                   ` [PATCH 09/10] OMAP3: Add debug observablity (debobs) Kconfig item Tony Lindgren
2009-08-17  8:07                               ` Tony Lindgren [this message]
2009-08-15  5:10                           ` [PATCH 07/10] OMAP: PM: Add definitions for ETK pads and observability registers Gadiyar, Anand
2009-08-18 12:12                             ` Kevin Hilman
2009-08-17  8:03                       ` [PATCH 06/10] OMAP: PM debug: Add PRCM register dump support Tony Lindgren
2009-08-13 18:39                     ` Aguirre Rodriguez, Sergio Alberto
     [not found]                       ` <A24693684029E5489D1D202277BE89444A78397F-EovWT4A8QTWIQmiDNMet8wC/G2K4zDHf@public.gmane.org>
2009-08-13 21:34                         ` Kevin Hilman
     [not found]                           ` <87eirfe6uo.fsf-1D3HCaltpLuhEniVeURVKkEOCMrvLtNR@public.gmane.org>
2009-08-13 22:28                             ` Kevin Hilman

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20090817080718.GJ7278@atomide.com \
    --to=tony-4v6ys6ai5vpbdgjk7y7tuq@public.gmane.org \
    --cc=khilman-1D3HCaltpLuhEniVeURVKkEOCMrvLtNR@public.gmane.org \
    --cc=linux-arm-kernel-xIg/pKzrS19vn6HldHNs0ANdhmdF6hFW@public.gmane.org \
    --cc=linux-arm-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=linux-omap-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=peter.de-schrijver-xNZwKgViW5gAvxtiuMwx3w@public.gmane.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox