linux-ide.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Ryan Mallon <ryan@bluewatersys.com>
To: H Hartley Sweeten <hartleys@visionengravers.com>
Cc: "João Ramos" <joao.ramos@inov.pt>,
	"Sergei Shtylyov" <sshtylyov@ru.mvista.com>,
	linux-arm-kernel@lists.arm.linux.org.uk,
	linux-ide@vger.kernel.org
Subject: Re: EP93xx PIO IDE driver proposal
Date: Fri, 08 May 2009 11:12:33 +1200	[thread overview]
Message-ID: <4A036AE1.5080706@bluewatersys.com> (raw)
In-Reply-To: <BD79186B4FD85F4B8E60E381CAEE19090172C9E1@mi8nycmail19.Mi8.com>

H Hartley Sweeten wrote:
> On Thursday, May 07, 2009 3:51 PM, Ryan Mallon wrote:
>>>> You can (and should) use platform_driver_probe and still have
>>>> the module be loadable. For the gpio settings, I think that
>>>> probably the best approach is to use gpio_request for each of
>>>> the gpio pins so that gpio_lib knows that they are in use and
>>>> sysfs/debugfs will correctly show they are assigned to ide,
>>>> and then call ep93xx_ide_on_gpio, so you will have something
>>>> like in your init code:
>>> Hmmm...
>>>
>>> How about doing all the request/free's in the ep93xx_ide_on_gpio()
>>> function?  That way the platform code can initially call it and set
>>> all the pins into gpio mode (freeing them).  Then later when the
>>> IDE driver is loaded it can call the function to try and put the
>>> pins into IDE mode (requesting them).  If any of the pins are
>>> unavailable the ep93xx_ide_on_gpio() function can return the
>>> necessary error code preventing the IDE driver from loading.  When
>>> the driver is unloaded it just needs to call the core to free
>>> the gpio's.
>>>
>>> Something like:
>>>
>>> int ep93xx_ide_on_gpio(int enable)
>>> {
>>> 	u32 reg;
>>> 	int err;
>>> 	int i;
>>>
>>> 	reg = __raw_read(EP93XX_SYSCON_DEVICE_CONFIG);
>>>
>>> 	if (enable) {
>>> 		for (i = 0; i < 8; i++) {
>>> 			err = gpio_request(EP93XX_GPIO_LINE_E(i), "ep93xx_ide");
>>> 			if (err)
>>> 				goto fail_gpio_e;
>>> 			err = gpio_request(EP93XX_GPIO_LINE_F(i), "ep93xx_ide");
>>> 			if (err)
>>> 				goto fail_gpio_f;
>>> 			err = gpio_request(EP93XX_GPIO_LINE_G(i), "ep93xx_ide");
>>> 			if (err)
>>> 				goto fail_gpio_g;
>>> 		}
>>> 		reg &= ~(EP93XX_SYSCON_DEVICE_CONFIG_EONIDE |
>>> 			EP93XX_SYSCON_DEVICE_CONFIG_GONIDE |
>>> 			EP93XX_SYSCON_DEVICE_CONFIG_HONIDE);
>>> 	} else {
>>> 		for (i = 0; i < 8; i++) {
>>> 			gpio_free(EP93XX_GPIO_LINE_E(i));
>>> 			gpio_free(EP93XX_GPIO_LINE_F(i));
>>> 			gpio_free(EP93XX_GPIO_LINE_G(i));
>>> 		}
>>> 		reg |= (EP93XX_SYSCON_DEVICE_CONFIG_EONIDE |
>>> 			EP93XX_SYSCON_DEVICE_CONFIG_GONIDE |
>>> 			EP93XX_SYSCON_DEVICE_CONFIG_HONIDE);
>>> 	}
>>> 	
>>> 	__raw_writel(0xaa, EP93XX_SYSCON_SWLOCK);
>>> 	__raw_writel(reg, EP93XX_SYSCON_DEVICE_CONFIG);	
>> Is this going to be modified later to use the ep93xx_syscon_ functions
>> once they are merged?
> 
> Yes, hopefully that occurs sometime soon.  Still no responses on it.
> 
>>> 	return 0;
>>>
>>> fail_gpio_g:
>>> 	free_gpio(EP93XX_GPIO_LINE_F(i);
>>> fail_gpio_f:
>>> 	free_gpio(EP93XX_GPIO_LINE_E(i);
>>> fail_gpio_e:
>>> 	for ( ; i >= 0; --i) {
>>> 		free_gpio(EP93XX_GPIO_LINE_E(i);
>>> 		free_gpio(EP93XX_GPIO_LINE_F(i);
>>> 		free_gpio(EP93XX_GPIO_LINE_G(i);
>>> 	}
>>> 	return err;
>>> }
>> Yeah, that makes sense. Keeps the driver nice and clean that way too.
>> The ep93xx_ide_on_gpio function for core.c should be posted as a
>> separate patch though.
>>
> 
> I agree.  Actually that patch needs to go in now so that the port E/F/G
> pins will work for normal GPIO.  The syscon register defaults at reset with
> the bits cleared so the boot state has them set for IDE mode.  That drove
> me nuts for quite a while...
> 
> If wanted I will put together the necessary patch for this.

That would be good. I think that we should default all of the pins to
gpio mode on boot, and then drivers should call into core.c to put pins
in alternative function mode where necessary.

> This function will hopefully get a bit cleaner later.  I've been messing
> with an addition to the GPIOLIB API to add support for "ports".  When/if
> that goes in all the for() loops go away and you just need to do a
> gpio_port_request(...) to grab the pins and gpio_port_free(...) to put
> them back.

It would be nice if gpiolib had some understanding of alternative
function modes for gpios. However I'm not sure that it can be done in a
generic way that will suit all architectures/chips.

> Ahh.. If only the days were longer....

Agreed :-).

~Ryan

-- 
Bluewater Systems Ltd - ARM Technology Solution Centre

       Ryan Mallon                              Unit 5, Amuri Park
       Phone: +64 3 3779127                     404 Barbadoes St
       Fax:   +64 3 3779135                     PO Box 13 889
       Email: ryan@bluewatersys.com             Christchurch, 8013
       Web:   http://www.bluewatersys.com       New Zealand
       Freecall Australia  1800 148 751         USA 1800 261 2934

  reply	other threads:[~2009-05-07 23:12 UTC|newest]

Thread overview: 59+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <49CCD7C4.8000207@inov.pt>
     [not found] ` <49CFDD8F.1030306@bluewatersys.com>
     [not found]   ` <BD79186B4FD85F4B8E60E381CAEE1909014E2E09@mi8nycmail19.Mi8.com>
     [not found]     ` <49D0CAE4.9090306@inov.pt>
2009-03-30 15:34       ` EP93xx PIO IDE driver proposal Sergei Shtylyov
2009-05-04 11:24         ` João Ramos
2009-05-05 12:04           ` Sergei Shtylyov
2009-05-06 14:17             ` João Ramos
2009-05-06 17:05               ` Sergei Shtylyov
2009-05-07  9:36                 ` João Ramos
2009-05-07 11:01                   ` João Ramos
2009-05-07 13:53                   ` Alan Cox
2009-05-07 15:33                     ` João Ramos
2009-05-08 12:04                       ` Bartlomiej Zolnierkiewicz
2009-05-08 12:16                         ` João Ramos
2009-05-08 12:40                           ` Bartlomiej Zolnierkiewicz
2009-05-08 13:30                             ` Sergei Shtylyov
2009-05-08 14:09                               ` Bartlomiej Zolnierkiewicz
2009-05-08 17:28                         ` João Ramos
2009-05-08 18:02                           ` Bartlomiej Zolnierkiewicz
2009-05-08 18:16                             ` João Ramos
2009-05-08 18:55                               ` Bartlomiej Zolnierkiewicz
2009-05-08 20:24                                 ` joao.ramos
2009-05-08 21:01                                   ` Sergei Shtylyov
2009-05-08 22:07                                     ` Bartlomiej Zolnierkiewicz
2009-05-11 11:10                                       ` João Ramos
2009-05-12 16:49                                         ` Sergei Shtylyov
2009-05-12 17:23                                           ` Bartlomiej Zolnierkiewicz
2009-05-13 11:01                                             ` João Ramos
2009-05-17 15:20                                               ` Bartlomiej Zolnierkiewicz
2009-05-22 17:52                                                 ` Sergei Shtylyov
2009-05-13 14:18                                             ` João Ramos
2009-05-14 19:44                                               ` Bartlomiej Zolnierkiewicz
2009-05-15 17:01                                                 ` João Ramos
2009-05-17 16:16                                                   ` Bartlomiej Zolnierkiewicz
2009-05-18 13:49                                                     ` João Ramos
2009-05-19 13:06                                                       ` Bartlomiej Zolnierkiewicz
2009-05-19 13:20                                                         ` João Ramos
2009-05-19 13:56                                                           ` Bartlomiej Zolnierkiewicz
2009-05-19 14:05                                                             ` João Ramos
2009-05-19 15:50                                                               ` João Ramos
2009-06-06 15:26                                                                 ` Sergei Shtylyov
2009-06-22 10:01                                                                   ` Bartlomiej Zolnierkiewicz
2009-05-14 16:30                                             ` Sergei Shtylyov
2009-05-14 16:36                                               ` Sergei Shtylyov
2009-05-14 18:58                                                 ` Bartlomiej Zolnierkiewicz
2009-05-11 13:20                                 ` João Ramos
2009-05-12 16:41                                   ` Bartlomiej Zolnierkiewicz
2009-05-12 16:57                                   ` Sergei Shtylyov
2009-05-12 16:01                           ` João Ramos
2009-05-12 16:30                             ` Bartlomiej Zolnierkiewicz
2009-05-12 16:45                               ` João Ramos
2009-05-07 16:52                   ` H Hartley Sweeten
2009-05-07 22:09                     ` Ryan Mallon
2009-05-07 22:31                       ` H Hartley Sweeten
2009-05-07 22:51                         ` Ryan Mallon
2009-05-07 23:01                           ` H Hartley Sweeten
2009-05-07 23:12                             ` Ryan Mallon [this message]
2009-05-07 23:32                               ` João Ramos
2009-05-07 23:58                                 ` H Hartley Sweeten
2009-05-08 11:23                   ` Sergei Shtylyov
2009-05-08 12:47                     ` João Ramos
     [not found]       ` <49D12669.4030207@bluewatersys.com>
2009-03-31 10:36         ` Sergei Shtylyov

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=4A036AE1.5080706@bluewatersys.com \
    --to=ryan@bluewatersys.com \
    --cc=hartleys@visionengravers.com \
    --cc=joao.ramos@inov.pt \
    --cc=linux-arm-kernel@lists.arm.linux.org.uk \
    --cc=linux-ide@vger.kernel.org \
    --cc=sshtylyov@ru.mvista.com \
    /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;
as well as URLs for NNTP newsgroup(s).