Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/arch/arm/allwinner add chip id functions



details:   https://anonhg.NetBSD.org/src/rev/2e2f9ce38142
branches:  trunk
changeset: 332124:2e2f9ce38142
user:      jmcneill <jmcneill%NetBSD.org@localhost>
date:      Sun Sep 07 22:21:36 2014 +0000

description:
add chip id functions

diffstat:

 sys/arch/arm/allwinner/awin_board.c |  40 +++++++++++++++++++++++++++++++++++-
 sys/arch/arm/allwinner/awin_var.h   |  10 ++++++++-
 2 files changed, 47 insertions(+), 3 deletions(-)

diffs (85 lines):

diff -r af2071182cd7 -r 2e2f9ce38142 sys/arch/arm/allwinner/awin_board.c
--- a/sys/arch/arm/allwinner/awin_board.c       Sun Sep 07 22:06:36 2014 +0000
+++ b/sys/arch/arm/allwinner/awin_board.c       Sun Sep 07 22:21:36 2014 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: awin_board.c,v 1.16 2014/09/04 02:36:08 jmcneill Exp $ */
+/*     $NetBSD: awin_board.c,v 1.17 2014/09/07 22:21:36 jmcneill Exp $ */
 /*-
  * Copyright (c) 2012 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -35,7 +35,7 @@
 
 #include <sys/cdefs.h>
 
-__KERNEL_RCSID(1, "$NetBSD: awin_board.c,v 1.16 2014/09/04 02:36:08 jmcneill Exp $");
+__KERNEL_RCSID(1, "$NetBSD: awin_board.c,v 1.17 2014/09/07 22:21:36 jmcneill Exp $");
 
 #include <sys/param.h>
 #include <sys/bus.h>
@@ -240,6 +240,42 @@
        return memsize;
 }
 
+uint16_t
+awin_chip_id(void)
+{
+       static uint16_t chip_id = 0;
+       uint32_t ver;
+
+       if (!chip_id) {
+               ver = bus_space_read_4(&awin_bs_tag, awin_core_bsh,
+                   AWIN_SRAM_OFFSET + AWIN_SRAM_VER_REG);
+               ver |= AWIN_SRAM_VER_R_EN;
+               bus_space_write_4(&awin_bs_tag, awin_core_bsh,
+                   AWIN_SRAM_OFFSET + AWIN_SRAM_VER_REG, ver);
+               ver = bus_space_read_4(&awin_bs_tag, awin_core_bsh,
+                   AWIN_SRAM_OFFSET + AWIN_SRAM_VER_REG);
+
+               chip_id = __SHIFTOUT(ver, AWIN_SRAM_VER_KEY_FIELD);
+       }
+
+       return chip_id;
+}
+
+const char *
+awin_chip_name(void)
+{
+       uint16_t chip_id = awin_chip_id();
+
+       switch (chip_id) {
+       case AWIN_CHIP_ID_A10: return "A10";
+       case AWIN_CHIP_ID_A13: return "A13";
+       case AWIN_CHIP_ID_A20: return "A20";
+       case AWIN_CHIP_ID_A23: return "A23";
+       case AWIN_CHIP_ID_A31: return "A31";
+       default: return "unknown chip";
+       }
+}
+
 void
 awin_pll6_enable(void)
 {
diff -r af2071182cd7 -r 2e2f9ce38142 sys/arch/arm/allwinner/awin_var.h
--- a/sys/arch/arm/allwinner/awin_var.h Sun Sep 07 22:06:36 2014 +0000
+++ b/sys/arch/arm/allwinner/awin_var.h Sun Sep 07 22:21:36 2014 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: awin_var.h,v 1.13 2014/09/06 17:10:17 jmcneill Exp $ */
+/* $NetBSD: awin_var.h,v 1.14 2014/09/07 22:21:36 jmcneill Exp $ */
 /*-
  * Copyright (c) 2013 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -92,6 +92,14 @@
 void   awin_pll6_enable(void);
 void   awin_cpu_hatch(struct cpu_info *);
 
+#define AWIN_CHIP_ID_A10       0x1623
+#define AWIN_CHIP_ID_A13       0x1625
+#define AWIN_CHIP_ID_A31       0x1633
+#define AWIN_CHIP_ID_A23       0x1650
+#define AWIN_CHIP_ID_A20       0x1651
+uint16_t awin_chip_id(void);
+const char *awin_chip_name(void);
+
 void   awin_gpio_init(void);
 bool   awin_gpio_pinset_available(const struct awin_gpio_pinset *);
 void   awin_gpio_pinset_acquire(const struct awin_gpio_pinset *);



Home | Main Index | Thread Index | Old Index