public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Ajay Bhargav <ajay.bhargav@einfochips.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH 1/4] gpio: Adds GPIO driver support for Armada100
Date: Tue, 19 Jul 2011 09:53:09 +0530 (IST)	[thread overview]
Message-ID: <1520695248.27411.1311049389261.JavaMail.root@ahm.einfochips.com> (raw)
In-Reply-To: <F766E4F80769BD478052FB6533FA745D19FB019D4A@SC-VEXCH4.marvell.com>


----- "Prafulla Wadaskar" <prafulla@marvell.com> wrote:

> You should define all GPIO register in a single struct
> And point them with base address offsets
> 

> 
> I suggest you to add mvgpio.c instead of armada100_gpio.c
> This will be used in future by other Marvell SoCs.
> 
GPIO registers might vary for other Marvell SoCs? How to deal with
that?

> > +int gpio_request(int gp, const char *label)
> > +{
> > +	/*
> > +	 * Assumes corresponding MFP is configured peoperly
> > +	 * for use as GPIO
> > +	 */
> 
> NAK, you should check here, respective MFP is being configured as
> GPIO, if not you should return error
> 
I checked datasheet and for most GPIOs, AF1 is given as GPIO but for few
its not, so adding a glue logic to check for specific GPIOs wont be a good idea.
Thats the reason i thought its good to keep MFP out of this. Please give suggestions.

> 
> Consider now this is generic GPIO driver for marvell SOCs, define this
> macro in gpio.h
> 

ok

> > +
> > +	if (gp < ARMD_MAX_GPIO) {
> > +		switch (GPIO_TO_REG(gp)) {
> 
> Some code comments are welcomed here.
> 
> > +		case 0:
> > +			writel(GPIO_TO_BIT(gp), &gpio_regs->gcdr0);
> > +			break;
> > +		case 1:
> > +			writel(GPIO_TO_BIT(gp), &gpio_regs->gcdr1);
> > +			break;
> > +		case 2:
> > +			writel(GPIO_TO_BIT(gp), &gpio_regs->gcdr2);
> > +			break;
> > +		case 3:
> > +			writel(GPIO_TO_BIT(gp), &gpio_regs->gcdr3);
> > +			break;
> > +		default:
> > +			return -EINVAL;
> > +		}
> > +	} else {
> > +		return -EINVAL;
> > +	}
> > +	return 0;
> > +}
> > +
> > +int gpio_direction_output(int gp, int value)
> > +{
> > +	struct armdgpio_registers *gpio_regs =
> > +		(struct armdgpio_registers *)ARMD1_GPIO_BASE;
> > +
> > +	if (gp < ARMD_MAX_GPIO) {
> > +		switch (GPIO_TO_REG(gp)) {
> > +		case 0:
> > +			writel(GPIO_TO_BIT(gp), &gpio_regs->gsdr0);
> 
> Call gpio_set_value(gp, value) here which is defined below doing the
> same
> 
thanks for suggestion.

> > +			panic("Invalid GPIO pin %u\n", gp);
> > +		}
> > +	} else {
> > +		panic("Invalid GPIO pin %u\n", gp);
> 
> Can you eliminate one panic line here?
> 
> Regards..
> Prafulla . .
> 
will do that... there is no return value from this function so i thought
it wont be good to continue from this point incase designed direction is not set.

Regards,
Ajay Bhargav

  parent reply	other threads:[~2011-07-19  4:23 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-07-18  9:41 [U-Boot] [PATCH 1/4] gpio: Adds GPIO driver support for Armada100 Ajay Bhargav
2011-07-18 17:45 ` Mike Frysinger
2011-07-18 19:01 ` Prafulla Wadaskar
2011-07-19  4:04   ` Lei Wen
2011-07-19  4:01     ` Ajay Bhargav
2011-07-19  4:14       ` Lei Wen
2011-07-19  4:14         ` Ajay Bhargav
2011-07-20  3:49           ` Prafulla Wadaskar
2011-07-19  5:27     ` Wolfgang Denk
2011-07-19  5:55       ` Lei Wen
2011-07-19  4:23   ` Ajay Bhargav [this message]
2011-07-19 17:36     ` Prafulla Wadaskar
2011-07-20  7:11     ` Lei Wen
     [not found] <550445252.29883.1311070783386.JavaMail.root@ahm.einfochips.com>
2011-07-19 10:29 ` Ajay Bhargav
2011-07-19 17:36   ` Prafulla Wadaskar
2011-07-20  7:13   ` Lei Wen
     [not found] <814164661.33093.1311137863843.JavaMail.root@ahm.einfochips.com>
2011-07-20  5:36 ` Ajay Bhargav
2011-07-20  6:02   ` Wolfgang Denk
2011-07-20  6:36     ` Ajay Bhargav
2011-07-20 10:08       ` Lei Wen
2011-07-20 10:43         ` Ajay Bhargav
2011-07-20 12:18           ` Lei Wen
2011-07-20 12:20             ` Ajay Bhargav
2011-07-20 12:19           ` Wolfgang Denk
2011-07-20 12:09       ` Wolfgang Denk
     [not found] <952685375.34177.1311145646630.JavaMail.root@ahm.einfochips.com>
2011-07-20  7:14 ` Ajay Bhargav
2011-07-20  7:28   ` Lei Wen
     [not found] <1287709675.34262.1311146613076.JavaMail.root@ahm.einfochips.com>
2011-07-20  7:29 ` Ajay Bhargav
2011-07-20  7:48   ` Lei Wen
2011-07-20  7:54     ` Ajay Bhargav

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=1520695248.27411.1311049389261.JavaMail.root@ahm.einfochips.com \
    --to=ajay.bhargav@einfochips.com \
    --cc=u-boot@lists.denx.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