From: Kees Jongenburger Date: Fri, 10 Jan 2014 11:00:13 +0000 (+0100) Subject: arm:fix GPIO revision check on DM37XX. X-Git-Tag: v3.3.0~651 X-Git-Url: http://zhaoyanbai.com/repos/%22http:/www.isc.org/icons/index.css?a=commitdiff_plain;h=refs%2Fchanges%2F06%2F1206%2F1;p=minix.git arm:fix GPIO revision check on DM37XX. 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 --- diff --git a/drivers/gpio/gpio.c b/drivers/gpio/gpio.c index 58cd06b49..b9da4e522 100644 --- a/drivers/gpio/gpio.c +++ b/drivers/gpio/gpio.c @@ -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 */ diff --git a/lib/libgpio/gpio_omap.c b/lib/libgpio/gpio_omap.c index 41e1c36eb..05e761d9e 100644 --- a/lib/libgpio/gpio_omap.c +++ b/lib/libgpio/gpio_omap.c @@ -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);