diff options
| author | Linus Walleij <linus.walleij@linaro.org> | 2018-12-22 05:12:31 -0500 |
|---|---|---|
| committer | Wim Van Sebroeck <wim@linux-watchdog.org> | 2018-12-24 02:27:56 -0500 |
| commit | d2b911db8b73bc6bfa163515b4ff142fb0dda66d (patch) | |
| tree | dead72124a5d5310ca43417ea07af78fb7a981c5 | |
| parent | 22ec9bb1cbcd613c73476ccd8f6a5e8c77793f66 (diff) | |
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>
| -rw-r--r-- | arch/mips/alchemy/board-mtx1.c | 18 | ||||
| -rw-r--r-- | drivers/watchdog/mtx-1_wdt.c | 19 |
2 files changed, 18 insertions, 19 deletions
diff --git a/arch/mips/alchemy/board-mtx1.c b/arch/mips/alchemy/board-mtx1.c index d625e6f99ae7..9d9d4ee31605 100644 --- a/arch/mips/alchemy/board-mtx1.c +++ b/arch/mips/alchemy/board-mtx1.c | |||
| @@ -24,6 +24,7 @@ | |||
| 24 | #include <linux/platform_device.h> | 24 | #include <linux/platform_device.h> |
| 25 | #include <linux/leds.h> | 25 | #include <linux/leds.h> |
| 26 | #include <linux/gpio.h> | 26 | #include <linux/gpio.h> |
| 27 | #include <linux/gpio/machine.h> | ||
| 27 | #include <linux/gpio_keys.h> | 28 | #include <linux/gpio_keys.h> |
| 28 | #include <linux/input.h> | 29 | #include <linux/input.h> |
| 29 | #include <linux/mtd/partitions.h> | 30 | #include <linux/mtd/partitions.h> |
| @@ -130,20 +131,18 @@ static struct platform_device mtx1_button = { | |||
| 130 | } | 131 | } |
| 131 | }; | 132 | }; |
| 132 | 133 | ||
| 133 | static struct resource mtx1_wdt_res[] = { | 134 | static struct gpiod_lookup_table mtx1_wdt_gpio_table = { |
| 134 | [0] = { | 135 | .dev_id = "mtx1-wdt.0", |
| 135 | .start = 215, | 136 | .table = { |
| 136 | .end = 215, | 137 | /* Global number 215 is offset 15 on Alchemy GPIO 2 */ |
| 137 | .name = "mtx1-wdt-gpio", | 138 | GPIO_LOOKUP("alchemy-gpio2", 15, NULL, GPIO_ACTIVE_HIGH), |
| 138 | .flags = IORESOURCE_IRQ, | 139 | { }, |
| 139 | } | 140 | }, |
| 140 | }; | 141 | }; |
| 141 | 142 | ||
| 142 | static struct platform_device mtx1_wdt = { | 143 | static struct platform_device mtx1_wdt = { |
| 143 | .name = "mtx1-wdt", | 144 | .name = "mtx1-wdt", |
| 144 | .id = 0, | 145 | .id = 0, |
| 145 | .num_resources = ARRAY_SIZE(mtx1_wdt_res), | ||
| 146 | .resource = mtx1_wdt_res, | ||
| 147 | }; | 146 | }; |
| 148 | 147 | ||
| 149 | static const struct gpio_led default_leds[] = { | 148 | static const struct gpio_led default_leds[] = { |
| @@ -310,6 +309,7 @@ static int __init mtx1_register_devices(void) | |||
| 310 | } | 309 | } |
| 311 | gpio_direction_input(mtx1_gpio_button[0].gpio); | 310 | gpio_direction_input(mtx1_gpio_button[0].gpio); |
| 312 | out: | 311 | out: |
| 312 | gpiod_add_lookup_table(&mtx1_wdt_gpio_table); | ||
| 313 | return platform_add_devices(mtx1_devs, ARRAY_SIZE(mtx1_devs)); | 313 | return platform_add_devices(mtx1_devs, ARRAY_SIZE(mtx1_devs)); |
| 314 | } | 314 | } |
| 315 | arch_initcall(mtx1_register_devices); | 315 | arch_initcall(mtx1_register_devices); |
diff --git a/drivers/watchdog/mtx-1_wdt.c b/drivers/watchdog/mtx-1_wdt.c index 1fa7d2b32494..e028e0a2eca0 100644 --- a/drivers/watchdog/mtx-1_wdt.c +++ b/drivers/watchdog/mtx-1_wdt.c | |||
| @@ -39,7 +39,7 @@ | |||
| 39 | #include <linux/platform_device.h> | 39 | #include <linux/platform_device.h> |
| 40 | #include <linux/io.h> | 40 | #include <linux/io.h> |
| 41 | #include <linux/uaccess.h> | 41 | #include <linux/uaccess.h> |
| 42 | #include <linux/gpio.h> | 42 | #include <linux/gpio/consumer.h> |
| 43 | 43 | ||
| 44 | #include <asm/mach-au1x00/au1000.h> | 44 | #include <asm/mach-au1x00/au1000.h> |
| 45 | 45 | ||
| @@ -55,7 +55,7 @@ static struct { | |||
| 55 | int queue; | 55 | int queue; |
| 56 | int default_ticks; | 56 | int default_ticks; |
| 57 | unsigned long inuse; | 57 | unsigned long inuse; |
| 58 | unsigned gpio; | 58 | struct gpio_desc *gpiod; |
| 59 | unsigned int gstate; | 59 | unsigned int gstate; |
| 60 | } mtx1_wdt_device; | 60 | } mtx1_wdt_device; |
| 61 | 61 | ||
| @@ -67,7 +67,7 @@ static void mtx1_wdt_trigger(struct timer_list *unused) | |||
| 67 | 67 | ||
| 68 | /* toggle wdt gpio */ | 68 | /* toggle wdt gpio */ |
| 69 | mtx1_wdt_device.gstate = !mtx1_wdt_device.gstate; | 69 | mtx1_wdt_device.gstate = !mtx1_wdt_device.gstate; |
| 70 | gpio_set_value(mtx1_wdt_device.gpio, mtx1_wdt_device.gstate); | 70 | gpiod_set_value(mtx1_wdt_device.gpiod, mtx1_wdt_device.gstate); |
| 71 | 71 | ||
| 72 | if (mtx1_wdt_device.queue && ticks) | 72 | if (mtx1_wdt_device.queue && ticks) |
| 73 | mod_timer(&mtx1_wdt_device.timer, jiffies + MTX1_WDT_INTERVAL); | 73 | mod_timer(&mtx1_wdt_device.timer, jiffies + MTX1_WDT_INTERVAL); |
| @@ -90,7 +90,7 @@ static void mtx1_wdt_start(void) | |||
| 90 | if (!mtx1_wdt_device.queue) { | 90 | if (!mtx1_wdt_device.queue) { |
| 91 | mtx1_wdt_device.queue = 1; | 91 | mtx1_wdt_device.queue = 1; |
| 92 | mtx1_wdt_device.gstate = 1; | 92 | mtx1_wdt_device.gstate = 1; |
| 93 | gpio_set_value(mtx1_wdt_device.gpio, 1); | 93 | gpiod_set_value(mtx1_wdt_device.gpiod, 1); |
| 94 | mod_timer(&mtx1_wdt_device.timer, jiffies + MTX1_WDT_INTERVAL); | 94 | mod_timer(&mtx1_wdt_device.timer, jiffies + MTX1_WDT_INTERVAL); |
| 95 | } | 95 | } |
| 96 | mtx1_wdt_device.running++; | 96 | mtx1_wdt_device.running++; |
| @@ -105,7 +105,7 @@ static int mtx1_wdt_stop(void) | |||
| 105 | if (mtx1_wdt_device.queue) { | 105 | if (mtx1_wdt_device.queue) { |
| 106 | mtx1_wdt_device.queue = 0; | 106 | mtx1_wdt_device.queue = 0; |
| 107 | mtx1_wdt_device.gstate = 0; | 107 | mtx1_wdt_device.gstate = 0; |
| 108 | gpio_set_value(mtx1_wdt_device.gpio, 0); | 108 | gpiod_set_value(mtx1_wdt_device.gpiod, 0); |
| 109 | } | 109 | } |
| 110 | ticks = mtx1_wdt_device.default_ticks; | 110 | ticks = mtx1_wdt_device.default_ticks; |
| 111 | spin_unlock_irqrestore(&mtx1_wdt_device.lock, flags); | 111 | spin_unlock_irqrestore(&mtx1_wdt_device.lock, flags); |
| @@ -198,12 +198,11 @@ static int mtx1_wdt_probe(struct platform_device *pdev) | |||
| 198 | { | 198 | { |
| 199 | int ret; | 199 | int ret; |
| 200 | 200 | ||
| 201 | mtx1_wdt_device.gpio = pdev->resource[0].start; | 201 | mtx1_wdt_device.gpiod = devm_gpiod_get(&pdev->dev, |
| 202 | ret = devm_gpio_request_one(&pdev->dev, mtx1_wdt_device.gpio, | 202 | NULL, GPIOD_OUT_HIGH); |
| 203 | GPIOF_OUT_INIT_HIGH, "mtx1-wdt"); | 203 | if (IS_ERR(mtx1_wdt_device.gpiod)) { |
| 204 | if (ret < 0) { | ||
| 205 | dev_err(&pdev->dev, "failed to request gpio"); | 204 | dev_err(&pdev->dev, "failed to request gpio"); |
| 206 | return ret; | 205 | return PTR_ERR(mtx1_wdt_device.gpiod); |
| 207 | } | 206 | } |
| 208 | 207 | ||
| 209 | spin_lock_init(&mtx1_wdt_device.lock); | 208 | spin_lock_init(&mtx1_wdt_device.lock); |
