@@ -33,6 +33,8 @@
#include <linux/platform_data/mtd-nand-omap2.h>
+#include "../gpio/gpiolib.h"
+
#define DEVICE_NAME "omap-gpmc"
/* GPMC register offsets */
@@ -1985,6 +1987,11 @@ void gpmc_read_settings_dt(struct device_node *np, struct gpmc_settings *p)
"gpmc,wait-on-read");
p->wait_on_write = of_property_read_bool(np,
"gpmc,wait-on-write");
+ p->wait_pin_polarity = of_property_read_u32(np,
+ "gpmc,wait-pin-polarity",
+ &p->wait_pin_polarity);
+ if (p->wait_pin_polarity < 0)
+ p->wait_pin_polarity = GPIO_ACTIVE_HIGH;
if (!p->wait_on_read && !p->wait_on_write)
pr_debug("%s: rd/wr wait monitoring not enabled!\n",
__func__);
@@ -2216,10 +2223,11 @@ static int gpmc_probe_generic_child(struct platform_device *pdev,
if (gpmc_s.wait_on_read || gpmc_s.wait_on_write) {
unsigned int wait_pin = gpmc_s.wait_pin;
- waitpin_desc = gpiochip_request_own_desc(&gpmc->gpio_chip,
- wait_pin, "WAITPIN",
- GPIO_ACTIVE_HIGH,
- GPIOD_IN);
+ waitpin_desc =
+ gpiochip_request_own_desc(&gpmc->gpio_chip,
+ wait_pin, "WAITPIN",
+ gpmc_s.wait_pin_polarity ? GPIO_ACTIVE_HIGH : GPIO_ACTIVE_LOW,
+ GPIOD_IN);
if (IS_ERR(waitpin_desc)) {
ret = PTR_ERR(waitpin_desc);
if (ret == -EBUSY) {
@@ -2348,7 +2356,19 @@ static int gpmc_gpio_get_direction(struct gpio_chip *chip, unsigned int offset)
static int gpmc_gpio_direction_input(struct gpio_chip *chip,
unsigned int offset)
{
- return 0; /* we're input only */
+ u32 reg;
+ struct gpio_desc *desc = gpiochip_get_desc(chip, offset);
+
+ offset += 8;
+ reg = gpmc_read_reg(GPMC_CONFIG);
+
+ if (BIT(FLAG_ACTIVE_LOW) & desc->flags)
+ reg &= ~BIT(offset);
+ else
+ reg |= BIT(offset);
+
+ gpmc_write_reg(GPMC_CONFIG, reg);
+ return 0;
}
static int gpmc_gpio_direction_output(struct gpio_chip *chip,
@@ -149,6 +149,7 @@ struct gpmc_settings {
u32 device_width; /* device bus width (8 or 16 bit) */
u32 mux_add_data; /* multiplex address & data */
u32 wait_pin; /* wait-pin to be used */
+ u32 wait_pin_polarity; /* wait-pin polarity */
};
/* Data for each chip select */