]> Zhao Yanbai Git Server - minix.git/commitdiff
arm:fix GPIO revision check on DM37XX. 06/1206/1
authorKees Jongenburger <kees.jongenburger@gmail.com>
Fri, 10 Jan 2014 11:00:13 +0000 (12:00 +0100)
committerKees Jongenburger <kees.jongenburger@gmail.com>
Mon, 20 Jan 2014 08:33:16 +0000 (09:33 +0100)
The GPIO revision check assumed the major and minor revision numbers where
located at same location in the register. This is not true.

Change-Id: Ieaff07ed8a19e6b4cf1d121a41d3290880b78a82

drivers/gpio/gpio.c
lib/libgpio/gpio_omap.c

index 58cd06b49ee54e05c2641bebd2e4b36f243164b2..b9da4e522a0c34648cd65f84e88c58ec3685567b 100644 (file)
@@ -53,7 +53,7 @@ struct gpio_cbdata
 {
        struct gpio *gpio;      /* obtained from the driver */
        int type;               /* read=0/on=1/off=2 */
-           TAILQ_ENTRY(gpio_cbdata) next;
+       TAILQ_ENTRY(gpio_cbdata) next;
 };
 
 /* list of inodes used in this driver */
index 41e1c36eb9297237c38a976585a03d77e32bfd8a..05e761d9e6ba64065efb26433cee2c440314bb1b 100644 (file)
@@ -379,6 +379,27 @@ omap_message_hook(message * m)
        return OK;
 }
 
+static int revision_matches(u32_t board_id,u32_t rev) {
+       /* figures out if the collected resition matches the one expected
+        * from the board */
+       if (BOARD_IS_BBXM(board_id)){
+               if(
+                  DM37XX_GPIO_REVISION_MAJOR(rev) != 2
+                  || DM37XX_GPIO_REVISION_MINOR(rev) !=  5
+                  ) {
+                       return 0;
+               }
+       } else if (BOARD_IS_BB(board_id)){
+               if (
+                   AM335X_GPIO_REVISION_MAJOR(rev) != 0
+                   || AM335X_GPIO_REVISION_MINOR(rev) != 1
+                   ) {
+                       return 0;
+               }
+       }
+       return 1;
+}
+
 static int
 omap_gpio_init(struct gpio_driver *gpdrv)
 {
@@ -422,22 +443,9 @@ omap_gpio_init(struct gpio_driver *gpdrv)
                        return EPERM;   /* fixme */
                }
 
-               revision = 0;
                revision = read32(bank->base_address + regs->REVISION);
-               unsigned int expected_major = 0;
-               unsigned int expected_minor = 0;
-               if (BOARD_IS_BBXM(machine.board_id)){
-                       expected_major = 2;
-                       expected_minor = 5;
-               } else if (BOARD_IS_BB(machine.board_id)){
-                       expected_major = 0;
-                       expected_minor = 1;
-               }
                /* test if we can access it */
-               if (
-                   AM335X_GPIO_REVISION_MAJOR(revision) != expected_major
-                   || AM335X_GPIO_REVISION_MINOR(revision) != expected_minor
-                   ) {
+               if (! revision_matches(machine.board_id,revision)) {
                        log_warn(&log,
                            "Failed to read the revision of GPIO bank %s.. disabling\n",
                            bank->name);