* [PATCH v4 1/3] ARM: OMAP: Beagle: revision detection
@ 2010-08-16 14:36 Robert Nelson
2010-08-16 14:36 ` [PATCH v4 2/3] ARM: OMAP: Beagle: only Cx boards use pin 23 for write protect Robert Nelson
` (3 more replies)
0 siblings, 4 replies; 8+ messages in thread
From: Robert Nelson @ 2010-08-16 14:36 UTC (permalink / raw)
To: tony; +Cc: linux-omap, Robert Nelson, Jarkko Nikula
Due to the omap3530 ES3.0 Silicon being used on both the
B5/B6 and C1/2/3 Beagle we can't use the cpu_is_omap34xx()
routines to differentiate the Beagle Boards.
However gpio pins 171,172,173 where setup for this prupose, so
lets use them.
Changes:
for older U-Boot's, use omap_mux_init_gpio()
keep Beagle Rev in board-omap3beagle.c
Tested on Beagle Revisions: B5, C2, C4, and xMA
Signed-off-by: Robert Nelson <robertcnelson@gmail.com>
Cc: Jarkko Nikula <jhnikula@gmail.com>
---
arch/arm/mach-omap2/board-omap3beagle.c | 79 +++++++++++++++++++++++++++++++
1 files changed, 79 insertions(+), 0 deletions(-)
diff --git a/arch/arm/mach-omap2/board-omap3beagle.c b/arch/arm/mach-omap2/board-omap3beagle.c
index 87969c7..01a288f 100644
--- a/arch/arm/mach-omap2/board-omap3beagle.c
+++ b/arch/arm/mach-omap2/board-omap3beagle.c
@@ -50,6 +50,84 @@
#define NAND_BLOCK_SIZE SZ_128K
+/*
+ * OMAP3 Beagle revision
+ * Run time detection of Beagle revision is done by reading GPIO.
+ * GPIO ID -
+ * AXBX = GPIO173, GPIO172, GPIO171: 1 1 1
+ * C1_3 = GPIO173, GPIO172, GPIO171: 1 1 0
+ * C4 = GPIO173, GPIO172, GPIO171: 1 0 1
+ * XM = GPIO173, GPIO172, GPIO171: 0 0 0
+ */
+enum {
+ OMAP3BEAGLE_BOARD_AXBX = 0,
+ OMAP3BEAGLE_BOARD_C1_3,
+ OMAP3BEAGLE_BOARD_C4,
+ OMAP3BEAGLE_BOARD_XM,
+};
+
+static u8 omap3_beagle_version;
+
+u8 get_omap3_beagle_rev(void)
+{
+ return omap3_beagle_version;
+}
+
+static void __init omap3_beagle_get_revision(void)
+{
+ int ret;
+ u16 beagle_rev = 0;
+
+ omap_mux_init_gpio(171, OMAP_PIN_INPUT_PULLUP);
+ omap_mux_init_gpio(172, OMAP_PIN_INPUT_PULLUP);
+ omap_mux_init_gpio(173, OMAP_PIN_INPUT_PULLUP);
+
+ ret = gpio_request(171, "rev_id_0");
+ if (ret < 0)
+ goto fail;
+
+ ret = gpio_request(172, "rev_id_1");
+ if (ret < 0)
+ goto fail;
+
+ ret = gpio_request(173, "rev_id_2");
+ if (ret < 0)
+ goto fail;
+
+ gpio_direction_input(171);
+ gpio_direction_input(172);
+ gpio_direction_input(173);
+
+ beagle_rev = gpio_get_value(171) | (gpio_get_value(172) << 1)
+ | (gpio_get_value(173) << 2);
+
+ switch (beagle_rev) {
+ case 7:
+ printk(KERN_INFO "OMAP3 Beagle Rev: Ax/Bx\n");
+ omap3_beagle_version = OMAP3BEAGLE_BOARD_AXBX;
+ break;
+ case 6:
+ printk(KERN_INFO "OMAP3 Beagle Rev: C1/C2/C3\n");
+ omap3_beagle_version = OMAP3BEAGLE_BOARD_C1_3;
+ break;
+ case 5:
+ printk(KERN_INFO "OMAP3 Beagle Rev: C4\n");
+ omap3_beagle_version = OMAP3BEAGLE_BOARD_C4;
+ break;
+ case 0:
+ printk(KERN_INFO "OMAP3 Beagle Rev: xM\n");
+ omap3_beagle_version = OMAP3BEAGLE_BOARD_XM;
+ break;
+ default:
+ printk(KERN_INFO "OMAP3 Beagle Rev: unknown %hd\n", beagle_rev);
+ omap3_beagle_version = OMAP3BEAGLE_BOARD_XM;
+ }
+
+ return;
+fail:
+ printk(KERN_ERR "Unable to get revision detection GPIO pins\n");
+}
+
static struct mtd_partition omap3beagle_nand_partitions[] = {
/* All the partition sizes are listed in terms of NAND block size */
{
@@ -464,6 +542,7 @@ static struct omap_musb_board_data musb_board_data = {
static void __init omap3_beagle_init(void)
{
omap3_mux_init(board_mux, OMAP_PACKAGE_CBB);
+ omap3_beagle_get_revision();
omap3_beagle_i2c_init();
platform_add_devices(omap3_beagle_devices,
ARRAY_SIZE(omap3_beagle_devices));
--
1.7.0.4
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH v4 2/3] ARM: OMAP: Beagle: only Cx boards use pin 23 for write protect
2010-08-16 14:36 [PATCH v4 1/3] ARM: OMAP: Beagle: revision detection Robert Nelson
@ 2010-08-16 14:36 ` Robert Nelson
2010-08-16 14:36 ` [PATCH v4 3/3] ARM: OMAP: Beagle: no gpio_wp pin connection on xM Robert Nelson
` (2 subsequent siblings)
3 siblings, 0 replies; 8+ messages in thread
From: Robert Nelson @ 2010-08-16 14:36 UTC (permalink / raw)
To: tony; +Cc: linux-omap, Robert Nelson
system_rev comes from u-boot and is a constant 0x20, so
Bx boards also fall in this 'if' and will get setup with the
wrong gpio_wp pin. Switch to using the Beagle revision routine
to correcly set pin 23 only for C1/2/3 and C4 Boards. Bx boards
will then use the correct default pin setting.
Signed-off-by: Robert Nelson <robertcnelson@gmail.com>
---
arch/arm/mach-omap2/board-omap3beagle.c | 3 ++-
1 files changed, 2 insertions(+), 1 deletions(-)
diff --git a/arch/arm/mach-omap2/board-omap3beagle.c b/arch/arm/mach-omap2/board-omap3beagle.c
index e470336..08fa68f 100644
--- a/arch/arm/mach-omap2/board-omap3beagle.c
+++ b/arch/arm/mach-omap2/board-omap3beagle.c
@@ -244,7 +244,8 @@ static struct gpio_led gpio_leds[];
static int beagle_twl_gpio_setup(struct device *dev,
unsigned gpio, unsigned ngpio)
{
- if (system_rev >= 0x20 && system_rev <= 0x34301000) {
+ if ((get_omap3_beagle_rev() == OMAP3BEAGLE_BOARD_C1_3) ||
+ (get_omap3_beagle_rev() == OMAP3BEAGLE_BOARD_C4)) {
omap_mux_init_gpio(23, OMAP_PIN_INPUT);
mmc[0].gpio_wp = 23;
} else {
--
1.7.0.4
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH v4 3/3] ARM: OMAP: Beagle: no gpio_wp pin connection on xM
2010-08-16 14:36 [PATCH v4 1/3] ARM: OMAP: Beagle: revision detection Robert Nelson
2010-08-16 14:36 ` [PATCH v4 2/3] ARM: OMAP: Beagle: only Cx boards use pin 23 for write protect Robert Nelson
@ 2010-08-16 14:36 ` Robert Nelson
2010-08-17 5:48 ` [PATCH v4 1/3] ARM: OMAP: Beagle: revision detection Jarkko Nikula
2010-08-17 6:10 ` Tony Lindgren
3 siblings, 0 replies; 8+ messages in thread
From: Robert Nelson @ 2010-08-16 14:36 UTC (permalink / raw)
To: tony; +Cc: linux-omap, Robert Nelson
The omap3630 based BeagleBoard xM uses a MicroSD card slot with
no write protection.
Signed-off-by: Robert Nelson <robertcnelson@gmail.com>
---
arch/arm/mach-omap2/board-omap3beagle.c | 4 +++-
1 files changed, 3 insertions(+), 1 deletions(-)
diff --git a/arch/arm/mach-omap2/board-omap3beagle.c b/arch/arm/mach-omap2/board-omap3beagle.c
index 08fa68f..449a776 100644
--- a/arch/arm/mach-omap2/board-omap3beagle.c
+++ b/arch/arm/mach-omap2/board-omap3beagle.c
@@ -244,7 +244,9 @@ static struct gpio_led gpio_leds[];
static int beagle_twl_gpio_setup(struct device *dev,
unsigned gpio, unsigned ngpio)
{
- if ((get_omap3_beagle_rev() == OMAP3BEAGLE_BOARD_C1_3) ||
+ if (get_omap3_beagle_rev() == OMAP3BEAGLE_BOARD_XM) {
+ mmc[0].gpio_wp = -EINVAL;
+ } else if ((get_omap3_beagle_rev() == OMAP3BEAGLE_BOARD_C1_3) ||
(get_omap3_beagle_rev() == OMAP3BEAGLE_BOARD_C4)) {
omap_mux_init_gpio(23, OMAP_PIN_INPUT);
mmc[0].gpio_wp = 23;
--
1.7.0.4
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH v4 1/3] ARM: OMAP: Beagle: revision detection
2010-08-16 14:36 [PATCH v4 1/3] ARM: OMAP: Beagle: revision detection Robert Nelson
2010-08-16 14:36 ` [PATCH v4 2/3] ARM: OMAP: Beagle: only Cx boards use pin 23 for write protect Robert Nelson
2010-08-16 14:36 ` [PATCH v4 3/3] ARM: OMAP: Beagle: no gpio_wp pin connection on xM Robert Nelson
@ 2010-08-17 5:48 ` Jarkko Nikula
2010-08-17 20:10 ` Robert Nelson
2010-08-17 6:10 ` Tony Lindgren
3 siblings, 1 reply; 8+ messages in thread
From: Jarkko Nikula @ 2010-08-17 5:48 UTC (permalink / raw)
To: Robert Nelson; +Cc: tony, linux-omap
Hi
On Mon, 16 Aug 2010 09:36:41 -0500
Robert Nelson <robertcnelson@gmail.com> wrote:
> +u8 get_omap3_beagle_rev(void)
> +{
> + return omap3_beagle_version;
> +}
> +
> +static void __init omap3_beagle_get_revision(void)
> +{
> + int ret;
> + u16 beagle_rev = 0;
> +
> + omap_mux_init_gpio(171, OMAP_PIN_INPUT_PULLUP);
> + omap_mux_init_gpio(172, OMAP_PIN_INPUT_PULLUP);
> + omap_mux_init_gpio(173, OMAP_PIN_INPUT_PULLUP);
> +
> + ret = gpio_request(171, "rev_id_0");
> + if (ret < 0)
> + goto fail;
> +
> + ret = gpio_request(172, "rev_id_1");
> + if (ret < 0)
> + goto fail;
> +
> + ret = gpio_request(173, "rev_id_2");
> + if (ret < 0)
> + goto fail;
> +
Sorry, I didn't notice this earlier: you should free already allocated
gpios if the next one fails.
<minor>
I was thinking would it make a sense to rename funtions below. I.e. to
indicate that only one of them is for runtime revision detection and
another is for revision initialization only. What do you think?
get_omap3_beagle_rev -> omap3_beagle_get_rev
omap3_beagle_get_revision -> omap3_beagle_init_rev
</minor>
Otherwise the set looks goot to me.
--
Jarkko
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH v4 1/3] ARM: OMAP: Beagle: revision detection
2010-08-16 14:36 [PATCH v4 1/3] ARM: OMAP: Beagle: revision detection Robert Nelson
` (2 preceding siblings ...)
2010-08-17 5:48 ` [PATCH v4 1/3] ARM: OMAP: Beagle: revision detection Jarkko Nikula
@ 2010-08-17 6:10 ` Tony Lindgren
2010-08-17 20:11 ` Robert Nelson
3 siblings, 1 reply; 8+ messages in thread
From: Tony Lindgren @ 2010-08-17 6:10 UTC (permalink / raw)
To: Robert Nelson; +Cc: linux-omap, Jarkko Nikula
* Robert Nelson <robertcnelson@gmail.com> [100816 17:29]:
> Due to the omap3530 ES3.0 Silicon being used on both the
> B5/B6 and C1/2/3 Beagle we can't use the cpu_is_omap34xx()
> routines to differentiate the Beagle Boards.
>
> However gpio pins 171,172,173 where setup for this prupose, so
> lets use them.
>
> Changes:
> for older U-Boot's, use omap_mux_init_gpio()
> keep Beagle Rev in board-omap3beagle.c
>
> Tested on Beagle Revisions: B5, C2, C4, and xMA
Looks good, just one minor comment below.
> Signed-off-by: Robert Nelson <robertcnelson@gmail.com>
> Cc: Jarkko Nikula <jhnikula@gmail.com>
> ---
> arch/arm/mach-omap2/board-omap3beagle.c | 79 +++++++++++++++++++++++++++++++
> 1 files changed, 79 insertions(+), 0 deletions(-)
>
> diff --git a/arch/arm/mach-omap2/board-omap3beagle.c b/arch/arm/mach-omap2/board-omap3beagle.c
> index 87969c7..01a288f 100644
> --- a/arch/arm/mach-omap2/board-omap3beagle.c
> +++ b/arch/arm/mach-omap2/board-omap3beagle.c
> @@ -50,6 +50,84 @@
>
> #define NAND_BLOCK_SIZE SZ_128K
>
> +/*
> + * OMAP3 Beagle revision
> + * Run time detection of Beagle revision is done by reading GPIO.
> + * GPIO ID -
> + * AXBX = GPIO173, GPIO172, GPIO171: 1 1 1
> + * C1_3 = GPIO173, GPIO172, GPIO171: 1 1 0
> + * C4 = GPIO173, GPIO172, GPIO171: 1 0 1
> + * XM = GPIO173, GPIO172, GPIO171: 0 0 0
> + */
> +enum {
> + OMAP3BEAGLE_BOARD_AXBX = 0,
> + OMAP3BEAGLE_BOARD_C1_3,
> + OMAP3BEAGLE_BOARD_C4,
> + OMAP3BEAGLE_BOARD_XM,
> +};
> +
> +static u8 omap3_beagle_version;
> +
> +u8 get_omap3_beagle_rev(void)
> +{
> + return omap3_beagle_version;
> +}
Please make this static u8 get_omap3_beagle_rev().
Regards,
Tony
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH v4 1/3] ARM: OMAP: Beagle: revision detection
2010-08-17 5:48 ` [PATCH v4 1/3] ARM: OMAP: Beagle: revision detection Jarkko Nikula
@ 2010-08-17 20:10 ` Robert Nelson
2010-08-18 6:34 ` Jarkko Nikula
0 siblings, 1 reply; 8+ messages in thread
From: Robert Nelson @ 2010-08-17 20:10 UTC (permalink / raw)
To: Jarkko Nikula; +Cc: tony, linux-omap
On Tue, Aug 17, 2010 at 12:48 AM, Jarkko Nikula <jhnikula@gmail.com> wrote:
> Hi
>
> On Mon, 16 Aug 2010 09:36:41 -0500
> Robert Nelson <robertcnelson@gmail.com> wrote:
>
>> +u8 get_omap3_beagle_rev(void)
>> +{
>> + return omap3_beagle_version;
>> +}
>> +
>> +static void __init omap3_beagle_get_revision(void)
>> +{
>> + int ret;
>> + u16 beagle_rev = 0;
>> +
>> + omap_mux_init_gpio(171, OMAP_PIN_INPUT_PULLUP);
>> + omap_mux_init_gpio(172, OMAP_PIN_INPUT_PULLUP);
>> + omap_mux_init_gpio(173, OMAP_PIN_INPUT_PULLUP);
>> +
>> + ret = gpio_request(171, "rev_id_0");
>> + if (ret < 0)
>> + goto fail;
>> +
>> + ret = gpio_request(172, "rev_id_1");
>> + if (ret < 0)
>> + goto fail;
>> +
>> + ret = gpio_request(173, "rev_id_2");
>> + if (ret < 0)
>> + goto fail;
>> +
>
Thanks Jarkko
> Sorry, I didn't notice this earlier: you should free already allocated
> gpios if the next one fails.
Sure, i'll add something like:
fail3:
gpio_free(173);
fail2:
gpio_free(172);
fail1:
gpio_free(171);
Do you have any preference if the gpio allocation fails? Right now
it'll just halts, we could just return as Cx based board.. Which would
be the route the current kernel would take without this patch...
> <minor>
> I was thinking would it make a sense to rename funtions below. I.e. to
> indicate that only one of them is for runtime revision detection and
> another is for revision initialization only. What do you think?
>
> get_omap3_beagle_rev -> omap3_beagle_get_rev
> omap3_beagle_get_revision -> omap3_beagle_init_rev
That does help clear up the two functions a little.
I didn't give much thought to the names, they just came from the evm
board revision example: s/evm/beagle/g
Regards,
--
Robert Nelson
http://www.rcn-ee.com/
--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH v4 1/3] ARM: OMAP: Beagle: revision detection
2010-08-17 6:10 ` Tony Lindgren
@ 2010-08-17 20:11 ` Robert Nelson
0 siblings, 0 replies; 8+ messages in thread
From: Robert Nelson @ 2010-08-17 20:11 UTC (permalink / raw)
To: Tony Lindgren; +Cc: linux-omap, Jarkko Nikula
On Tue, Aug 17, 2010 at 1:10 AM, Tony Lindgren <tony@atomide.com> wrote:
> * Robert Nelson <robertcnelson@gmail.com> [100816 17:29]:
>> Due to the omap3530 ES3.0 Silicon being used on both the
>> B5/B6 and C1/2/3 Beagle we can't use the cpu_is_omap34xx()
>> routines to differentiate the Beagle Boards.
>>
>> However gpio pins 171,172,173 where setup for this prupose, so
>> lets use them.
>>
>> Changes:
>> for older U-Boot's, use omap_mux_init_gpio()
>> keep Beagle Rev in board-omap3beagle.c
>>
>> Tested on Beagle Revisions: B5, C2, C4, and xMA
>
> Looks good, just one minor comment below.
>
>> Signed-off-by: Robert Nelson <robertcnelson@gmail.com>
>> Cc: Jarkko Nikula <jhnikula@gmail.com>
>> ---
>> arch/arm/mach-omap2/board-omap3beagle.c | 79 +++++++++++++++++++++++++++++++
>> 1 files changed, 79 insertions(+), 0 deletions(-)
>>
>> diff --git a/arch/arm/mach-omap2/board-omap3beagle.c b/arch/arm/mach-omap2/board-omap3beagle.c
>> index 87969c7..01a288f 100644
>> --- a/arch/arm/mach-omap2/board-omap3beagle.c
>> +++ b/arch/arm/mach-omap2/board-omap3beagle.c
>> @@ -50,6 +50,84 @@
>>
>> #define NAND_BLOCK_SIZE SZ_128K
>>
>> +/*
>> + * OMAP3 Beagle revision
>> + * Run time detection of Beagle revision is done by reading GPIO.
>> + * GPIO ID -
>> + * AXBX = GPIO173, GPIO172, GPIO171: 1 1 1
>> + * C1_3 = GPIO173, GPIO172, GPIO171: 1 1 0
>> + * C4 = GPIO173, GPIO172, GPIO171: 1 0 1
>> + * XM = GPIO173, GPIO172, GPIO171: 0 0 0
>> + */
>> +enum {
>> + OMAP3BEAGLE_BOARD_AXBX = 0,
>> + OMAP3BEAGLE_BOARD_C1_3,
>> + OMAP3BEAGLE_BOARD_C4,
>> + OMAP3BEAGLE_BOARD_XM,
>> +};
>> +
>> +static u8 omap3_beagle_version;
>> +
>> +u8 get_omap3_beagle_rev(void)
>> +{
>> + return omap3_beagle_version;
>> +}
>
> Please make this static u8 get_omap3_beagle_rev().
Thanks Tony,
that's changed..
Regards,
--
Robert Nelson
http://www.rcn-ee.com/
--
To unsubscribe from this list: send the line "unsubscribe linux-omap" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH v4 1/3] ARM: OMAP: Beagle: revision detection
2010-08-17 20:10 ` Robert Nelson
@ 2010-08-18 6:34 ` Jarkko Nikula
0 siblings, 0 replies; 8+ messages in thread
From: Jarkko Nikula @ 2010-08-18 6:34 UTC (permalink / raw)
To: Robert Nelson; +Cc: tony, linux-omap
On Tue, 17 Aug 2010 15:10:35 -0500
Robert Nelson <robertcnelson@gmail.com> wrote:
> Do you have any preference if the gpio allocation fails? Right now
> it'll just halts, we could just return as Cx based board.. Which would
> be the route the current kernel would take without this patch...
>
I think current code printing the error and letting the revision to be
zero or undefined is just fine. It's easier to debug if we let system
to continue booting instead of halting at early stage as there is no
any fatal risk with mmc gpio_wp if we cannot determine the revision.
--
Jarkko
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2010-08-18 6:34 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-08-16 14:36 [PATCH v4 1/3] ARM: OMAP: Beagle: revision detection Robert Nelson
2010-08-16 14:36 ` [PATCH v4 2/3] ARM: OMAP: Beagle: only Cx boards use pin 23 for write protect Robert Nelson
2010-08-16 14:36 ` [PATCH v4 3/3] ARM: OMAP: Beagle: no gpio_wp pin connection on xM Robert Nelson
2010-08-17 5:48 ` [PATCH v4 1/3] ARM: OMAP: Beagle: revision detection Jarkko Nikula
2010-08-17 20:10 ` Robert Nelson
2010-08-18 6:34 ` Jarkko Nikula
2010-08-17 6:10 ` Tony Lindgren
2010-08-17 20:11 ` Robert Nelson
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).