mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: "Alexander Shiyan" <shc_work@mail.ru>
To: "Sascha Hauer" <s.hauer@pengutronix.de>
Cc: barebox@lists.infradead.org
Subject: Re[2]: [RFC] Add Generic GPIO driver
Date: Mon, 18 Feb 2013 14:13:22 +0400	[thread overview]
Message-ID: <1361182402.423724727@f309.mail.ru> (raw)
In-Reply-To: <20130218100642.GO1906@pengutronix.de>

> On Fri, Feb 15, 2013 at 10:49:27PM +0400, Alexander Shiyan wrote:
> > This patch adds generic memory-mapped GPIO controller support.
> > Code taken from Linux Kernel and adopted for barebox.
> 
> I'm fine with this if you add a user for it. I wonder though if it's
> worth it to have this driver for barebox. If I have a driver in the
> kernel that already uses it, then this makes it simple to copy it, but
> should I have to write a new gpio driver, I'm unsure if it's simpler
> to write a new gpio driver or to register with the generic gpio
> driver.

Here's an example that I'm checking:

/*
 * Copyright (C) 2013 Alexander Shiyan <shc_work@mail.ru>
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License as
 * published by the Free Software Foundation; either version 2 of
 * the License, or (at your option) any later version.
 */

#include <init.h>
#include <common.h>
#include <malloc.h>

#include <linux/basic_mmio_gpio.h>

static int clps711x_gpio_probe(struct device_d *dev)
{
	int err;
	void __iomem *dat, *dir, *dir_inv;
	struct bgpio_chip *bgc;
	struct bgpio_pdata *pdata = dev->platform_data;

	if (!pdata)
		return -ENODATA;

	dat = dev_request_mem_region_by_name(dev, "dat");
	dir = dev_request_mem_region_by_name(dev, "dir");
	dir_inv = dev_request_mem_region_by_name(dev, "dir_inv");
	if (!dat || (!dir && !dir_inv))
		return -EINVAL;

	bgc = xzalloc(sizeof(struct bgpio_chip));
	if (!bgc)
		return -ENOMEM;

	err = bgpio_init(bgc, dev, 1, dat, NULL, NULL, dir, dir_inv, 0);
	if (err) {
		free(bgc);
		return err;
	}

	bgc->gc.base = pdata->base;
	bgc->gc.ngpio = pdata->ngpio;

	return gpiochip_add(&bgc->gc);
}

static struct driver_d clps711x_gpio_driver = {
	.name	= "clps711x-gpio",
	.probe	= clps711x_gpio_probe,
};

static __init int clps711x_gpio_register(void)
{
	return platform_driver_register(&clps711x_gpio_driver);
}
coredevice_initcall(clps711x_gpio_register);

---
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

  reply	other threads:[~2013-02-18 10:13 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-02-15 18:49 Alexander Shiyan
2013-02-18 10:06 ` Sascha Hauer
2013-02-18 10:13   ` Alexander Shiyan [this message]
2013-02-18 10:19     ` Sascha Hauer
2013-02-19  7:09       ` Re[2]: " Alexander Shiyan
2013-02-19  7:26         ` Sascha Hauer
2013-02-19  7:34           ` Re[2]: " Alexander Shiyan

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=1361182402.423724727@f309.mail.ru \
    --to=shc_work@mail.ru \
    --cc=barebox@lists.infradead.org \
    --cc=s.hauer@pengutronix.de \
    /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