All of lore.kernel.org
 help / color / mirror / Atom feed
From: jonsmirl@gmail.com (jonsmirl at gmail.com)
To: linux-arm-kernel@lists.infradead.org
Subject: ioremap to a specific virtual address
Date: Fri, 23 Mar 2012 21:14:19 -0400	[thread overview]
Message-ID: <CAKON4OwhcFDMC4dWjU7x4u2CPT7C2BxVuCDkTN0j14gTndi3tA@mail.gmail.com> (raw)
In-Reply-To: <201203231931.06376.arnd@arndb.de>

On Fri, Mar 23, 2012 at 3:31 PM, Arnd Bergmann <arnd@arndb.de> wrote:
> On Friday 23 March 2012, jonsmirl at gmail.com wrote:
>> On Fri, Mar 23, 2012 at 11:20 AM, Arnd Bergmann <arnd@arndb.de> wrote:
>> > On Friday 23 March 2012, jonsmirl at gmail.com wrote:
>> >> I will need to check how similar the chips actually are. NXP did not
>> >> use primecells in the lpc31xx family.
>> >>
>> >> I'd be happy to have some help. My trees are here:
>> >> https://github.com/jonsmirl
>> >
>> > I've taken a brief look at your tree, some comments:
>> >
>> > * Once you're done with the DT conversion, you should be able to
>> > ?completely remvoe the three board files. You probably know that already
>>
>> Thanks for the feedback.
>>
>> I don't think I can completely remove the board files. Some of the
>> generic devices have board specific callbacks. DM9000 for example. I
>> am setting up of_dev_auxdata for the boards so that I can pass these
>> callbacks in.
>
> There are some cases where it's not possible to avoid platform_data,
> but in most cases there is another better solution.
>
> If you end up having to use platform_data, the auxdata mechanism
> is the way to go.
>
>> # define DM_IO_DELAY() ? ? ? ?do { gpio_get_value(GPIO_MNAND_RYBN3);} while(0)
>>
>> static void dm9000_dumpblk(void __iomem *reg, int count)
>> {
>> ? ? ? int i;
>> ? ? ? int tmp;
>>
>> ? ? ? count = (count + 1) >> 1;
>> ? ? ? for (i = 0; i < count; i++) {
>> ? ? ? ? ? ? ? DM_IO_DELAY();
>> ? ? ? ? ? ? ? tmp = readw(reg);
>> ? ? ? }
>> }
>>
>> static void dm9000_inblk(void __iomem *reg, void *data, int count)
>> {
>> ? ? ? int i;
>> ? ? ? u16* pdata = (u16*)data;
>> ? ? ? count = (count + 1) >> 1;
>> ? ? ? for (i = 0; i < count; i++) {
>> ? ? ? ? ? ? ? DM_IO_DELAY();
>> ? ? ? ? ? ? ? *pdata++ = readw(reg);
>> ? ? ? }
>> }
>>
>> static struct dm9000_plat_data dm9000_platdata = {
>> ? ? ? .flags ? ? ? ? ?= DM9000_PLATF_16BITONLY | DM9000_PLATF_NO_EEPROM |
>> DM9000_PLATF_SIMPLE_PHY,
>
> The flags can become simple empty properties if necessary, so there is no
> need to keep these.
>
>> ? ? ? .dumpblk = dm9000_dumpblk,
>> ? ? ? .inblk = dm9000_inblk,
>> };
>
> I can see two possible ways besides platform_data for the register access:

The dm9000 is on the LPC3131 reference design board. It is not our
hardware so I'm not sure what it is doing with the GPIO pin. I'm
porting the reference board code in the hopes that someone will help
out in this effort.

Another piece of board specific glue is this bit that needs to be
executed before accessing the dm9000. It puts the bus in the board's
range in 8/16/32b mode, timings, etc.

tatic void __init ea_add_device_dm9000(void)
{
	/*
	 * Configure Chip-Select 2 on SMC for the DM9000.
	 * Note: These timings were calculated for MASTER_CLOCK = 90000000
	 *  according to the DM9000 timings.
	 */
	MPMC_STCONFIG1 = 0x81;
	MPMC_STWTWEN1 = 1;
	MPMC_STWTOEN1 = 1;
	MPMC_STWTRD1 = 4;
	MPMC_STWTPG1 = 1;
	MPMC_STWTWR1 = 1;
	MPMC_STWTTURN1 = 2;
	/* enable oe toggle between consec reads */
	SYS_MPMC_WTD_DEL1 = _BIT(5) | 4;

An external  LCD controller on CS1 needs a different setup.

static void __init ea_add_device_ssd1289(void)
{
	MPMC_STCONFIG0 = 0x81;
	MPMC_STWTWEN0  = 0;
	MPMC_STWTOEN0  = 0;
	MPMC_STWTRD0   = 31;
	MPMC_STWTPG0   = 0;
	MPMC_STWTWR0   = 3;
	MPMC_STWTTURN0 = 0;

>
> 1. generalize the driver's accessors. Since your platform wants to read
> a gpio pin before every access, you can provide a gpio line as the
> property in the dm9000 device node and access that in the same place
> in the common code if the gpio line is set, but skip the access otherwise.
> No other platform in mainline actually needs to override the functions,
> so there are hardly any disadvantages to this.
>
> 2. convert the entire driver to use the "regmap" infrastructure to abstract
> the registers, and implement a driver that implements the slow I/O. This
> would be a rather complex solution and probably not worth it, compared
> with the overhead of the first one or just staying with auxdata.
>
> If any problem turns out to be really hard to convert over from
> platform_data to device tree properties, auxdata is usually an acceptable
> solution, or you could submit the port with more of those hacks when
> there is reason to believe that you will fix them up later.
>
> ? ? ? ?Arnd



-- 
Jon Smirl
jonsmirl at gmail.com

  reply	other threads:[~2012-03-24  1:14 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-03-23  0:23 ioremap to a specific virtual address jonsmirl at gmail.com
2012-03-23  4:00 ` Nicolas Pitre
2012-03-23  4:17   ` jonsmirl at gmail.com
2012-03-23  4:28     ` Nicolas Pitre
2012-03-23 13:25       ` jonsmirl at gmail.com
2012-03-23 14:07         ` Arnd Bergmann
2012-03-23 14:32           ` jonsmirl at gmail.com
2012-03-23 14:49             ` Arnd Bergmann
2012-03-23 15:20             ` Arnd Bergmann
2012-03-23 18:28               ` jonsmirl at gmail.com
2012-03-23 19:31                 ` Arnd Bergmann
2012-03-24  1:14                   ` jonsmirl at gmail.com [this message]
2012-03-25 17:34                     ` Arnd Bergmann
2012-03-26  8:47                       ` Arnd Bergmann
2012-03-26 13:11                         ` jonsmirl at gmail.com
2012-03-26 11:21                   ` jonsmirl at gmail.com
2012-03-23 14:52           ` Roland Stigge
2012-03-23 15:05             ` jonsmirl at gmail.com
2012-03-23 15:12               ` Roland Stigge
2012-03-31 23:12   ` jonsmirl at gmail.com
2012-03-31 23:52     ` Nicolas Pitre
2012-04-01  0:08       ` jonsmirl at gmail.com
2012-04-01 19:46         ` Arnd Bergmann
2012-04-01 21:41           ` jonsmirl at gmail.com
2012-04-02  1:18             ` Nicolas Pitre
2012-04-02  7:31               ` Arnd Bergmann

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=CAKON4OwhcFDMC4dWjU7x4u2CPT7C2BxVuCDkTN0j14gTndi3tA@mail.gmail.com \
    --to=jonsmirl@gmail.com \
    --cc=linux-arm-kernel@lists.infradead.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.