Commit a47137a5 authored by Linus Walleij's avatar Linus Walleij Committed by Lee Jones

mfd/omap1: htc-i2cpld: Convert to a pure GPIO driver

Instead of passing GPIO numbers pertaining to ourselves through
platform data, just request GPIO descriptors from our own GPIO
chips and use them, and cut down on the unnecessary complexity.

Cc: Aaro Koskinen <aaro.koskinen@iki.fi>
Cc: Janusz Krzysztofik <jmkrzyszt@gmail.com>
Cc: Tony Lindgren <tony@atomide.com>
Cc: Cory Maccarrone <darkstar6262@gmail.com>
Cc: linux-omap@vger.kernel.org
Signed-off-by: default avatarLinus Walleij <linus.walleij@linaro.org>
Signed-off-by: default avatarLee Jones <lee@kernel.org>
Link: https://lore.kernel.org/r/20220905115810.5987-1-linus.walleij@linaro.org
parent 6a96f6c1
...@@ -141,13 +141,6 @@ ...@@ -141,13 +141,6 @@
#define HTCPLD_GPIO_DOWN_DPAD HTCPLD_BASE(7, 4) #define HTCPLD_GPIO_DOWN_DPAD HTCPLD_BASE(7, 4)
#define HTCPLD_GPIO_ENTER_DPAD HTCPLD_BASE(7, 3) #define HTCPLD_GPIO_ENTER_DPAD HTCPLD_BASE(7, 3)
/*
* The htcpld chip requires a gpio write to a specific line
* to re-enable interrupts after one has occurred.
*/
#define HTCPLD_GPIO_INT_RESET_HI HTCPLD_BASE(2, 7)
#define HTCPLD_GPIO_INT_RESET_LO HTCPLD_BASE(2, 0)
/* Chip 5 */ /* Chip 5 */
#define HTCPLD_IRQ_RIGHT_KBD HTCPLD_IRQ(0, 7) #define HTCPLD_IRQ_RIGHT_KBD HTCPLD_IRQ(0, 7)
#define HTCPLD_IRQ_UP_KBD HTCPLD_IRQ(0, 6) #define HTCPLD_IRQ_UP_KBD HTCPLD_IRQ(0, 6)
...@@ -348,8 +341,6 @@ static struct htcpld_chip_platform_data htcpld_chips[] = { ...@@ -348,8 +341,6 @@ static struct htcpld_chip_platform_data htcpld_chips[] = {
}; };
static struct htcpld_core_platform_data htcpld_pfdata = { static struct htcpld_core_platform_data htcpld_pfdata = {
.int_reset_gpio_hi = HTCPLD_GPIO_INT_RESET_HI,
.int_reset_gpio_lo = HTCPLD_GPIO_INT_RESET_LO,
.i2c_adapter_id = 1, .i2c_adapter_id = 1,
.chip = htcpld_chips, .chip = htcpld_chips,
......
...@@ -20,7 +20,9 @@ ...@@ -20,7 +20,9 @@
#include <linux/irq.h> #include <linux/irq.h>
#include <linux/spinlock.h> #include <linux/spinlock.h>
#include <linux/htcpld.h> #include <linux/htcpld.h>
#include <linux/gpio.h> #include <linux/gpio/driver.h>
#include <linux/gpio/machine.h>
#include <linux/gpio/consumer.h>
#include <linux/slab.h> #include <linux/slab.h>
struct htcpld_chip { struct htcpld_chip {
...@@ -58,8 +60,8 @@ struct htcpld_data { ...@@ -58,8 +60,8 @@ struct htcpld_data {
uint irq_start; uint irq_start;
int nirqs; int nirqs;
uint chained_irq; uint chained_irq;
unsigned int int_reset_gpio_hi; struct gpio_desc *int_reset_gpio_hi;
unsigned int int_reset_gpio_lo; struct gpio_desc *int_reset_gpio_lo;
/* htcpld info */ /* htcpld info */
struct htcpld_chip *chip; struct htcpld_chip *chip;
...@@ -196,9 +198,9 @@ static irqreturn_t htcpld_handler(int irq, void *dev) ...@@ -196,9 +198,9 @@ static irqreturn_t htcpld_handler(int irq, void *dev)
* be asserted. * be asserted.
*/ */
if (htcpld->int_reset_gpio_hi) if (htcpld->int_reset_gpio_hi)
gpio_set_value(htcpld->int_reset_gpio_hi, 1); gpiod_set_value(htcpld->int_reset_gpio_hi, 1);
if (htcpld->int_reset_gpio_lo) if (htcpld->int_reset_gpio_lo)
gpio_set_value(htcpld->int_reset_gpio_lo, 0); gpiod_set_value(htcpld->int_reset_gpio_lo, 0);
return IRQ_HANDLED; return IRQ_HANDLED;
} }
...@@ -562,35 +564,26 @@ static int htcpld_core_probe(struct platform_device *pdev) ...@@ -562,35 +564,26 @@ static int htcpld_core_probe(struct platform_device *pdev)
return ret; return ret;
/* Request the GPIO(s) for the int reset and set them up */ /* Request the GPIO(s) for the int reset and set them up */
if (pdata->int_reset_gpio_hi) { htcpld->int_reset_gpio_hi = gpiochip_request_own_desc(&htcpld->chip[2].chip_out,
ret = gpio_request(pdata->int_reset_gpio_hi, "htcpld-core"); 7, "htcpld-core", GPIO_ACTIVE_HIGH,
if (ret) { GPIOD_OUT_HIGH);
/* if (!htcpld->int_reset_gpio_hi)
* If it failed, that sucks, but we can probably /*
* continue on without it. * If it failed, that sucks, but we can probably
*/ * continue on without it.
dev_warn(dev, "Unable to request int_reset_gpio_hi -- interrupts may not work\n"); */
htcpld->int_reset_gpio_hi = 0; dev_warn(dev, "Unable to request int_reset_gpio_hi -- interrupts may not work\n");
} else {
htcpld->int_reset_gpio_hi = pdata->int_reset_gpio_hi;
gpio_set_value(htcpld->int_reset_gpio_hi, 1);
}
}
if (pdata->int_reset_gpio_lo) {
ret = gpio_request(pdata->int_reset_gpio_lo, "htcpld-core"); htcpld->int_reset_gpio_lo = gpiochip_request_own_desc(&htcpld->chip[2].chip_out,
if (ret) { 0, "htcpld-core", GPIO_ACTIVE_HIGH,
/* GPIOD_OUT_LOW);
* If it failed, that sucks, but we can probably if (!htcpld->int_reset_gpio_lo)
* continue on without it. /*
*/ * If it failed, that sucks, but we can probably
dev_warn(dev, "Unable to request int_reset_gpio_lo -- interrupts may not work\n"); * continue on without it.
htcpld->int_reset_gpio_lo = 0; */
} else { dev_warn(dev, "Unable to request int_reset_gpio_lo -- interrupts may not work\n");
htcpld->int_reset_gpio_lo = pdata->int_reset_gpio_lo;
gpio_set_value(htcpld->int_reset_gpio_lo, 0);
}
}
dev_info(dev, "Initialized successfully\n"); dev_info(dev, "Initialized successfully\n");
return 0; return 0;
......
...@@ -13,8 +13,6 @@ struct htcpld_chip_platform_data { ...@@ -13,8 +13,6 @@ struct htcpld_chip_platform_data {
}; };
struct htcpld_core_platform_data { struct htcpld_core_platform_data {
unsigned int int_reset_gpio_hi;
unsigned int int_reset_gpio_lo;
unsigned int i2c_adapter_id; unsigned int i2c_adapter_id;
struct htcpld_chip_platform_data *chip; struct htcpld_chip_platform_data *chip;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment