summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatt Redfearn <matt.redfearn@imgtec.com>2015-07-15 17:52:48 +0300
committerMatt Redfearn <matt.redfearn@imgtec.com>2015-07-15 17:52:48 +0300
commit367f34c092e7ba9dd7e4c41993a00dc13a857bdf (patch)
tree76baa0dd47ceac70377007d0ab127127455d8bc2
parenta30f816f77893486ea5ee610972733bf2962c897 (diff)
downloadCI20_u-boot-367f34c092e7ba9dd7e4c41993a00dc13a857bdf.tar.xz
ci20: Detect board revision
Read the pull-downs on port C pins 18/19 to determine board revision. Export this in global variable for other things Signed-off-by: Matt Redfearn <matt.redfearn@imgtec.com>
-rw-r--r--board/imgtec/ci20/ci20.c29
1 files changed, 28 insertions, 1 deletions
diff --git a/board/imgtec/ci20/ci20.c b/board/imgtec/ci20/ci20.c
index 767efb189..3d8dfe838 100644
--- a/board/imgtec/ci20/ci20.c
+++ b/board/imgtec/ci20/ci20.c
@@ -29,6 +29,13 @@
#include <asm/arch/nand.h>
#include <asm/jz_mmc.h>
+#define CI20_GPIO_REV_PORT (2) /* Port C */
+#define CI20_GPIO_REV_SHIFT (18) /* Bit 18 */
+#define CI20_GPIO_REV_BITS (3) /* 2 bits */
+#define CI20_GPIO_REV_MASK (CI20_GPIO_REV_BITS << CI20_GPIO_REV_SHIFT)
+
+int ci20_revision = 0;
+
struct ci20_otp {
uint32_t serial_number;
uint32_t date;
@@ -167,7 +174,27 @@ int board_eth_init(bd_t *bis)
/* U-Boot common routines */
int checkboard(void)
{
- puts("Board: ci20 (Ingenic XBurst JZ4780 SoC)\n");
+ int val;
+
+ gpio_port_direction_input(CI20_GPIO_REV_PORT, CI20_GPIO_REV_SHIFT);
+ gpio_port_direction_input(CI20_GPIO_REV_PORT, CI20_GPIO_REV_SHIFT+1);
+
+ /* Re-enable pullups (gpio_port_direction_input turns them off) */
+ writel(CI20_GPIO_REV_MASK, GPIO_PXPENC(CI20_GPIO_REV_PORT));
+
+ /* Read PC18/19 for version */
+ val = readl(GPIO_PXPIN(CI20_GPIO_REV_PORT));
+ val = (val & CI20_GPIO_REV_MASK) >> CI20_GPIO_REV_SHIFT;
+
+ /* pulldowns invert the revision number */
+ switch (val) {
+#define CI20_REV(a, b) case(b): ci20_revision = a; break
+ CI20_REV(1, 3); /* Rev 1 boards had no pulldowns - giving 3 */
+ CI20_REV(2, 1); /* Rev 2 boards pulldown port C bit 18 giving 1 */
+#undef CI20_REV
+ }
+
+ printf("Board: ci20 (r%d) (Ingenic XBurst JZ4780 SoC)\n", ci20_revision);
return 0;
}