From: u.kleine-koenig@pengutronix.de (Uwe Kleine-König)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 07/14] ARM: LPC32XX: Misc support functions
Date: Fri, 12 Feb 2010 21:06:09 +0100 [thread overview]
Message-ID: <20100212200609.GA947@pengutronix.de> (raw)
In-Reply-To: <1265674295-23996-8-git-send-email-wellsk40@gmail.com>
Hi Kevin,
> +/*
> + * Detects and returns IRAM size for the device variation
> + */
> +#define LPC32XX_IRAM_BANK_SIZE (128 * SZ_1K)
SZ_128K ?
> +static u32 iram_size;
> +u32 lpc32xx_return_iram_size(void)
> +{
> + if (iram_size == 0) {
> + u32 savedval;
> + void __iomem *iramptr1, *iramptr2;
> +
> + iramptr1 = io_p2v(LPC32XX_IRAM_BASE);
> + iramptr2 = io_p2v(LPC32XX_IRAM_BASE + LPC32XX_IRAM_BANK_SIZE);
> + savedval = __raw_readl(iramptr2);
> +
> + __raw_writel(savedval + 1, iramptr2);
> +
> + /*
> + * If IRAM size is 128K, the value at iramptr2 will wrap back
> + * into iramptr1
> + */
> + if (__raw_readl(iramptr1) == __raw_readl(iramptr2))
> + iram_size = LPC32XX_IRAM_BANK_SIZE;
> + else
> + iram_size = LPC32XX_IRAM_BANK_SIZE * 2;
> +
> + __raw_writel(savedval, iramptr2);
> + }
> +
> + return iram_size;
> +}
I didn't understand this. The size of IRAM is either 128KiB or 256KiB,
right. And if it's 128KiB it's mirrored.
So if the content of a 256KiB IRAM happens to be
00000: 00000001 ....
...
20000: 00000000 ....
the above code does
savedval = 8
IRAM[20000] = 1
iram_size = LPC32XX_IRAM_BANK_SIZE;
IMHO you should do:
savedval1 = __raw_readl(iramptr1);
savedval2 = __raw_readl(iramptr2);
if (savedval1 == savedval2) {
__raw_writel(savedval2 + 1, iramptr2);
if (__raw_readl(iramptr1) == savedval2 + 1)
iram_size = LPC32XX_IRAM_BANK_SIZE;
else
iram_size = 2 * LPC32XX_IRAM_BANK_SIZE;
__raw_writel(savedval2, iramptr2);
} else
iram_size = 2 * LPC32XX_IRAM_BANK_SIZE;
> diff --git a/arch/arm/mach-lpc32xx/common.h b/arch/arm/mach-lpc32xx/common.h
> new file mode 100644
> index 0000000..8161efe
> --- /dev/null
> +++ b/arch/arm/mach-lpc32xx/common.h
> @@ -0,0 +1,75 @@
> +/*
> + * arch/arm/mach-lpc32xx/common.h
> + *
> + * Author: Kevin Wells <kevin.wells@nxp.com>
> + *
> + * Copyright (C) 2009-2010 NXP Semiconductors
> + *
> + * 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.
> + *
> + * 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.
> + */
> +
> +#ifndef __LPC32XX_COMMON_H
> +#define __LPC32XX_COMMON_H
> +
> +#include <linux/platform_device.h>
> +
> +/*
> + * Arch specific platform device structures
> + */
> +extern struct platform_device watchdog_device;
lpc32xx_watchdoc_device?
> +extern struct platform_device i2c0_device;
> +extern struct platform_device i2c1_device;
> +extern struct platform_device i2c2_device;
I prefer using functions to add these devices because then it's easier
to add support for now SoCs that happen to have the watchdog at a
different address. Then you can just do:
static struct resource watchdog_resources[] __initdata = {
{
.flags = ...;
},
};
int __init lpc32xx_add_watchdog(void)
{
if (cpu_is_lpc3212()) {
watchdog_resources[0].start = LPC3212_WATCHDOG_BASE;
} else if (cpu_is_lpc3214()) {
watchdog_resources[0].start = LPC3214_WATCHDOG_BASE;
} else
return -ENODEV;
watchdog_resources[0].end = watchdog_resources[0].start + SZ_4K;
....
}
or something similar. Another variation is:
static struct resource watchdog_resources[] __initdata = {
...
}
int __init lpc32xx_add_watchdog(sometype baseaddr)
{
watchdog_resources[0].start = base;
...
}
and then in a header do:
#define lpc3212_add_watchdog() lpc32xx_add_watchdog(LPC3212_WATCHDOG_BASE)
#define lpc3214_add_watchdog() lpc32xx_add_watchdog(LPC3214_WATCHDOG_BASE)
or provide an inline function.
When providing platform_devices as in your patch you have to do:
extern struct platform_device lpc3212_watchdog_device;
extern struct platform_device lpc3214_watchdog_device;
and at least in a kernel that supports both SoCs one or the other only
sits in RAM doing nothing.
But YMMV.
Best regards
Uwe
--
Pengutronix e.K. | Uwe Kleine-K?nig |
Industrial Linux Solutions | http://www.pengutronix.de/ |
next prev parent reply other threads:[~2010-02-12 20:06 UTC|newest]
Thread overview: 44+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-02-09 0:11 LPC32XX architecture files (updated v3) wellsk40 at gmail.com
2010-02-09 0:11 ` [PATCH 01/14] ARM: LPC32XX: Initial architecture header files wellsk40 at gmail.com
2010-02-09 9:31 ` Uwe Kleine-König
2010-02-09 9:52 ` Uwe Kleine-König
2010-02-09 9:59 ` Russell King - ARM Linux
2010-02-09 16:52 ` Uwe Kleine-König
2010-02-09 16:52 ` Uwe Kleine-König
2010-02-09 17:10 ` H Hartley Sweeten
2010-02-09 17:10 ` H Hartley Sweeten
2010-02-09 17:58 ` Russell King - ARM Linux
2010-02-09 17:58 ` Russell King - ARM Linux
2010-02-09 18:22 ` Josh Triplett
2010-02-09 19:17 ` Kevin Wells
2010-02-09 0:11 ` [PATCH 02/14] ARM: LPC32XX: Debug and IRQ macros wellsk40 at gmail.com
2010-02-09 9:45 ` Uwe Kleine-König
2010-02-09 0:11 ` [PATCH 03/14] ARM: LPC32XX: Clock driver wellsk40 at gmail.com
2010-02-09 10:39 ` Uwe Kleine-König
2010-02-09 19:18 ` Kevin Wells
2010-02-19 0:42 ` Kevin Wells
2010-02-19 9:21 ` Uwe Kleine-König
2010-02-09 0:11 ` [PATCH 04/14] ARM: LPC32XX: GPIO, timer, and IRQ drivers wellsk40 at gmail.com
2010-02-09 10:58 ` Uwe Kleine-König
2010-02-09 0:11 ` [PATCH 05/14] ARM: LPC32XX: System suspend support wellsk40 at gmail.com
2010-02-09 17:03 ` Uwe Kleine-König
2010-02-09 19:18 ` Kevin Wells
2010-02-14 16:51 ` Pavel Machek
2010-02-14 19:45 ` Russell King - ARM Linux
2010-02-09 0:11 ` [PATCH 06/14] ARM: LPC32XX: Serial support code wellsk40 at gmail.com
2010-02-09 0:11 ` [PATCH 07/14] ARM: LPC32XX: Misc support functions wellsk40 at gmail.com
2010-02-12 20:06 ` Uwe Kleine-König [this message]
2010-02-09 0:11 ` [PATCH 08/14] ARM: LPC32XX: Phytec 3250 platform support wellsk40 at gmail.com
2010-02-12 20:08 ` Uwe Kleine-König
2010-02-16 19:43 ` Kevin Wells
2010-02-09 0:11 ` [PATCH 09/14] ARM: LPC32XX: Arch config menu supoport and makefiles wellsk40 at gmail.com
2010-02-09 0:11 ` [PATCH 10/14] ARM: LPC32XX: Default PHY3250 kernel config (ramdisk) wellsk40 at gmail.com
2010-02-09 0:11 ` [PATCH 11/14] ARM: Add support for the LPC32XX arch wellsk40 at gmail.com
2010-02-09 0:11 ` [PATCH 12/14] AMBA: CLCD: LPC32XX register swap in the clcd header file wellsk40 at gmail.com
2010-02-12 14:31 ` Russell King - ARM Linux
2010-02-12 16:32 ` Kevin Wells
2010-02-12 16:41 ` Russell King - ARM Linux
2010-02-16 20:27 ` Kevin Wells
2010-02-18 17:21 ` Russell King - ARM Linux
2010-02-09 0:11 ` [PATCH 13/14] i2c: Add support for the LPC32XX arch wellsk40 at gmail.com
2010-02-09 0:11 ` [PATCH 14/14] WATCHDOG: " wellsk40 at gmail.com
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=20100212200609.GA947@pengutronix.de \
--to=u.kleine-koenig@pengutronix.de \
--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.