aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJavier Martin <javier.martin@vista-silicon.com>2012-04-10 05:26:59 -0400
committerSascha Hauer <s.hauer@pengutronix.de>2012-04-16 03:49:31 -0400
commit435ca24116bc5365a10fa0be1bf1c1e4c5680157 (patch)
tree2a9955e254df83ad5bb5bcc65f7a35b3d46f2e35
parent19a3dab69747e1bace7987da5cd527fe998d7012 (diff)
ARM i.MX: Visstrim_M10: Add board version detection.
Visstrim_M10 boards have 3 gpios to detect the expansion board version attached and other 3 to detect the motherboard revision. Signed-off-by: Javier Martin <javier.martin@vista-silicon.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
-rw-r--r--arch/arm/mach-imx/mach-imx27_visstrim_m10.c55
1 files changed, 55 insertions, 0 deletions
diff --git a/arch/arm/mach-imx/mach-imx27_visstrim_m10.c b/arch/arm/mach-imx/mach-imx27_visstrim_m10.c
index f7b074f496f0..748ba2e311b5 100644
--- a/arch/arm/mach-imx/mach-imx27_visstrim_m10.c
+++ b/arch/arm/mach-imx/mach-imx27_visstrim_m10.c
@@ -38,6 +38,7 @@
38#include <asm/mach-types.h> 38#include <asm/mach-types.h>
39#include <asm/mach/arch.h> 39#include <asm/mach/arch.h>
40#include <asm/mach/time.h> 40#include <asm/mach/time.h>
41#include <asm/system.h>
41#include <mach/common.h> 42#include <mach/common.h>
42#include <mach/iomux-mx27.h> 43#include <mach/iomux-mx27.h>
43 44
@@ -48,6 +49,14 @@
48#define OTG_PHY_CS_GPIO (GPIO_PORTF + 17) 49#define OTG_PHY_CS_GPIO (GPIO_PORTF + 17)
49#define SDHC1_IRQ IRQ_GPIOB(25) 50#define SDHC1_IRQ IRQ_GPIOB(25)
50 51
52#define MOTHERBOARD_BIT2 (GPIO_PORTD + 31)
53#define MOTHERBOARD_BIT1 (GPIO_PORTD + 30)
54#define MOTHERBOARD_BIT0 (GPIO_PORTD + 29)
55
56#define EXPBOARD_BIT2 (GPIO_PORTD + 25)
57#define EXPBOARD_BIT1 (GPIO_PORTD + 27)
58#define EXPBOARD_BIT0 (GPIO_PORTD + 28)
59
51static const int visstrim_m10_pins[] __initconst = { 60static const int visstrim_m10_pins[] __initconst = {
52 /* UART1 (console) */ 61 /* UART1 (console) */
53 PE12_PF_UART1_TXD, 62 PE12_PF_UART1_TXD,
@@ -119,6 +128,23 @@ static const int visstrim_m10_pins[] __initconst = {
119 PB19_PF_CSI_D7, 128 PB19_PF_CSI_D7,
120 PB20_PF_CSI_VSYNC, 129 PB20_PF_CSI_VSYNC,
121 PB21_PF_CSI_HSYNC, 130 PB21_PF_CSI_HSYNC,
131 /* mother board version */
132 MOTHERBOARD_BIT2 | GPIO_GPIO | GPIO_IN | GPIO_PUEN,
133 MOTHERBOARD_BIT1 | GPIO_GPIO | GPIO_IN | GPIO_PUEN,
134 MOTHERBOARD_BIT0 | GPIO_GPIO | GPIO_IN | GPIO_PUEN,
135 /* expansion board version */
136 EXPBOARD_BIT2 | GPIO_GPIO | GPIO_IN | GPIO_PUEN,
137 EXPBOARD_BIT1 | GPIO_GPIO | GPIO_IN | GPIO_PUEN,
138 EXPBOARD_BIT0 | GPIO_GPIO | GPIO_IN | GPIO_PUEN,
139};
140
141static struct gpio visstrim_m10_version_gpios[] = {
142 { EXPBOARD_BIT0, GPIOF_IN, "exp-version-0" },
143 { EXPBOARD_BIT1, GPIOF_IN, "exp-version-1" },
144 { EXPBOARD_BIT2, GPIOF_IN, "exp-version-2" },
145 { MOTHERBOARD_BIT0, GPIOF_IN, "mother-version-0" },
146 { MOTHERBOARD_BIT1, GPIOF_IN, "mother-version-1" },
147 { MOTHERBOARD_BIT2, GPIOF_IN, "mother-version-2" },
122}; 148};
123 149
124/* Camera */ 150/* Camera */
@@ -369,11 +395,40 @@ static const struct imx_ssi_platform_data visstrim_m10_ssi_pdata __initconst = {
369 .flags = IMX_SSI_DMA | IMX_SSI_SYN, 395 .flags = IMX_SSI_DMA | IMX_SSI_SYN,
370}; 396};
371 397
398static void __init visstrim_m10_revision(void)
399{
400 int exp_version = 0;
401 int mo_version = 0;
402 int ret;
403
404 ret = gpio_request_array(visstrim_m10_version_gpios,
405 ARRAY_SIZE(visstrim_m10_version_gpios));
406 if (ret) {
407 pr_err("Failed to request version gpios");
408 return;
409 }
410
411 /* Get expansion board version (negative logic) */
412 exp_version |= !gpio_get_value(EXPBOARD_BIT2) << 2;
413 exp_version |= !gpio_get_value(EXPBOARD_BIT1) << 1;
414 exp_version |= !gpio_get_value(EXPBOARD_BIT0);
415
416 /* Get mother board version (negative logic) */
417 mo_version |= !gpio_get_value(MOTHERBOARD_BIT2) << 2;
418 mo_version |= !gpio_get_value(MOTHERBOARD_BIT1) << 1;
419 mo_version |= !gpio_get_value(MOTHERBOARD_BIT0);
420
421 system_rev = 0x27000;
422 system_rev |= (mo_version << 4);
423 system_rev |= exp_version;
424}
425
372static void __init visstrim_m10_board_init(void) 426static void __init visstrim_m10_board_init(void)
373{ 427{
374 int ret; 428 int ret;
375 429
376 imx27_soc_init(); 430 imx27_soc_init();
431 visstrim_m10_revision();
377 432
378 ret = mxc_gpio_setup_multiple_pins(visstrim_m10_pins, 433 ret = mxc_gpio_setup_multiple_pins(visstrim_m10_pins,
379 ARRAY_SIZE(visstrim_m10_pins), "VISSTRIM_M10"); 434 ARRAY_SIZE(visstrim_m10_pins), "VISSTRIM_M10");