mirror of
https://github.com/AuxXxilium/linux_dsm_epyc7002.git
synced 2025-04-15 06:57:33 +07:00
watchdog: mtx-1: Convert to use GPIO descriptor
This converts the MTX-1 driver to grab a GPIO descriptor associated with the device instead of using a resource with a global GPIO number. Augment the driver and the boardfile. Cc: Ralf Baechle <ralf@linux-mips.org> Cc: Paul Burton <paul.burton@mips.com> Cc: James Hogan <jhogan@kernel.org> Cc: linux-mips@linux-mips.org Cc: Florian Fainelli <f.fainelli@gmail.com> Reviewed-by: Florian Fainelli <f.fainelli@gmail.com> Signed-off-by: Linus Walleij <linus.walleij@linaro.org> Acked-by: Paul Burton <paul.burton@mips.com> Reviewed-by: Guenter Roeck <linux@roeck-us.net> Signed-off-by: Guenter Roeck <linux@roeck-us.net> Signed-off-by: Wim Van Sebroeck <wim@linux-watchdog.org>
This commit is contained in:
parent
22ec9bb1cb
commit
d2b911db8b
@ -24,6 +24,7 @@
|
|||||||
#include <linux/platform_device.h>
|
#include <linux/platform_device.h>
|
||||||
#include <linux/leds.h>
|
#include <linux/leds.h>
|
||||||
#include <linux/gpio.h>
|
#include <linux/gpio.h>
|
||||||
|
#include <linux/gpio/machine.h>
|
||||||
#include <linux/gpio_keys.h>
|
#include <linux/gpio_keys.h>
|
||||||
#include <linux/input.h>
|
#include <linux/input.h>
|
||||||
#include <linux/mtd/partitions.h>
|
#include <linux/mtd/partitions.h>
|
||||||
@ -130,20 +131,18 @@ static struct platform_device mtx1_button = {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
static struct resource mtx1_wdt_res[] = {
|
static struct gpiod_lookup_table mtx1_wdt_gpio_table = {
|
||||||
[0] = {
|
.dev_id = "mtx1-wdt.0",
|
||||||
.start = 215,
|
.table = {
|
||||||
.end = 215,
|
/* Global number 215 is offset 15 on Alchemy GPIO 2 */
|
||||||
.name = "mtx1-wdt-gpio",
|
GPIO_LOOKUP("alchemy-gpio2", 15, NULL, GPIO_ACTIVE_HIGH),
|
||||||
.flags = IORESOURCE_IRQ,
|
{ },
|
||||||
}
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
static struct platform_device mtx1_wdt = {
|
static struct platform_device mtx1_wdt = {
|
||||||
.name = "mtx1-wdt",
|
.name = "mtx1-wdt",
|
||||||
.id = 0,
|
.id = 0,
|
||||||
.num_resources = ARRAY_SIZE(mtx1_wdt_res),
|
|
||||||
.resource = mtx1_wdt_res,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
static const struct gpio_led default_leds[] = {
|
static const struct gpio_led default_leds[] = {
|
||||||
@ -310,6 +309,7 @@ static int __init mtx1_register_devices(void)
|
|||||||
}
|
}
|
||||||
gpio_direction_input(mtx1_gpio_button[0].gpio);
|
gpio_direction_input(mtx1_gpio_button[0].gpio);
|
||||||
out:
|
out:
|
||||||
|
gpiod_add_lookup_table(&mtx1_wdt_gpio_table);
|
||||||
return platform_add_devices(mtx1_devs, ARRAY_SIZE(mtx1_devs));
|
return platform_add_devices(mtx1_devs, ARRAY_SIZE(mtx1_devs));
|
||||||
}
|
}
|
||||||
arch_initcall(mtx1_register_devices);
|
arch_initcall(mtx1_register_devices);
|
||||||
|
@ -39,7 +39,7 @@
|
|||||||
#include <linux/platform_device.h>
|
#include <linux/platform_device.h>
|
||||||
#include <linux/io.h>
|
#include <linux/io.h>
|
||||||
#include <linux/uaccess.h>
|
#include <linux/uaccess.h>
|
||||||
#include <linux/gpio.h>
|
#include <linux/gpio/consumer.h>
|
||||||
|
|
||||||
#include <asm/mach-au1x00/au1000.h>
|
#include <asm/mach-au1x00/au1000.h>
|
||||||
|
|
||||||
@ -55,7 +55,7 @@ static struct {
|
|||||||
int queue;
|
int queue;
|
||||||
int default_ticks;
|
int default_ticks;
|
||||||
unsigned long inuse;
|
unsigned long inuse;
|
||||||
unsigned gpio;
|
struct gpio_desc *gpiod;
|
||||||
unsigned int gstate;
|
unsigned int gstate;
|
||||||
} mtx1_wdt_device;
|
} mtx1_wdt_device;
|
||||||
|
|
||||||
@ -67,7 +67,7 @@ static void mtx1_wdt_trigger(struct timer_list *unused)
|
|||||||
|
|
||||||
/* toggle wdt gpio */
|
/* toggle wdt gpio */
|
||||||
mtx1_wdt_device.gstate = !mtx1_wdt_device.gstate;
|
mtx1_wdt_device.gstate = !mtx1_wdt_device.gstate;
|
||||||
gpio_set_value(mtx1_wdt_device.gpio, mtx1_wdt_device.gstate);
|
gpiod_set_value(mtx1_wdt_device.gpiod, mtx1_wdt_device.gstate);
|
||||||
|
|
||||||
if (mtx1_wdt_device.queue && ticks)
|
if (mtx1_wdt_device.queue && ticks)
|
||||||
mod_timer(&mtx1_wdt_device.timer, jiffies + MTX1_WDT_INTERVAL);
|
mod_timer(&mtx1_wdt_device.timer, jiffies + MTX1_WDT_INTERVAL);
|
||||||
@ -90,7 +90,7 @@ static void mtx1_wdt_start(void)
|
|||||||
if (!mtx1_wdt_device.queue) {
|
if (!mtx1_wdt_device.queue) {
|
||||||
mtx1_wdt_device.queue = 1;
|
mtx1_wdt_device.queue = 1;
|
||||||
mtx1_wdt_device.gstate = 1;
|
mtx1_wdt_device.gstate = 1;
|
||||||
gpio_set_value(mtx1_wdt_device.gpio, 1);
|
gpiod_set_value(mtx1_wdt_device.gpiod, 1);
|
||||||
mod_timer(&mtx1_wdt_device.timer, jiffies + MTX1_WDT_INTERVAL);
|
mod_timer(&mtx1_wdt_device.timer, jiffies + MTX1_WDT_INTERVAL);
|
||||||
}
|
}
|
||||||
mtx1_wdt_device.running++;
|
mtx1_wdt_device.running++;
|
||||||
@ -105,7 +105,7 @@ static int mtx1_wdt_stop(void)
|
|||||||
if (mtx1_wdt_device.queue) {
|
if (mtx1_wdt_device.queue) {
|
||||||
mtx1_wdt_device.queue = 0;
|
mtx1_wdt_device.queue = 0;
|
||||||
mtx1_wdt_device.gstate = 0;
|
mtx1_wdt_device.gstate = 0;
|
||||||
gpio_set_value(mtx1_wdt_device.gpio, 0);
|
gpiod_set_value(mtx1_wdt_device.gpiod, 0);
|
||||||
}
|
}
|
||||||
ticks = mtx1_wdt_device.default_ticks;
|
ticks = mtx1_wdt_device.default_ticks;
|
||||||
spin_unlock_irqrestore(&mtx1_wdt_device.lock, flags);
|
spin_unlock_irqrestore(&mtx1_wdt_device.lock, flags);
|
||||||
@ -198,12 +198,11 @@ static int mtx1_wdt_probe(struct platform_device *pdev)
|
|||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
mtx1_wdt_device.gpio = pdev->resource[0].start;
|
mtx1_wdt_device.gpiod = devm_gpiod_get(&pdev->dev,
|
||||||
ret = devm_gpio_request_one(&pdev->dev, mtx1_wdt_device.gpio,
|
NULL, GPIOD_OUT_HIGH);
|
||||||
GPIOF_OUT_INIT_HIGH, "mtx1-wdt");
|
if (IS_ERR(mtx1_wdt_device.gpiod)) {
|
||||||
if (ret < 0) {
|
|
||||||
dev_err(&pdev->dev, "failed to request gpio");
|
dev_err(&pdev->dev, "failed to request gpio");
|
||||||
return ret;
|
return PTR_ERR(mtx1_wdt_device.gpiod);
|
||||||
}
|
}
|
||||||
|
|
||||||
spin_lock_init(&mtx1_wdt_device.lock);
|
spin_lock_init(&mtx1_wdt_device.lock);
|
||||||
|
Loading…
Reference in New Issue
Block a user