wm831x_wdt.c (c1144d29f405ce1f4e6ede6482beb3d0d09750c6) | wm831x_wdt.c (30f57e0f22bb94e0226febde03a012db3cc328f1) |
---|---|
1// SPDX-License-Identifier: GPL-2.0+ 2/* 3 * Watchdog driver for the wm831x PMICs 4 * 5 * Copyright (C) 2009 Wolfson Microelectronics 6 */ 7 8#include <linux/module.h> --- 166 unchanged lines hidden (view full) --- 175 .start = wm831x_wdt_start, 176 .stop = wm831x_wdt_stop, 177 .ping = wm831x_wdt_ping, 178 .set_timeout = wm831x_wdt_set_timeout, 179}; 180 181static int wm831x_wdt_probe(struct platform_device *pdev) 182{ | 1// SPDX-License-Identifier: GPL-2.0+ 2/* 3 * Watchdog driver for the wm831x PMICs 4 * 5 * Copyright (C) 2009 Wolfson Microelectronics 6 */ 7 8#include <linux/module.h> --- 166 unchanged lines hidden (view full) --- 175 .start = wm831x_wdt_start, 176 .stop = wm831x_wdt_stop, 177 .ping = wm831x_wdt_ping, 178 .set_timeout = wm831x_wdt_set_timeout, 179}; 180 181static int wm831x_wdt_probe(struct platform_device *pdev) 182{ |
183 struct wm831x *wm831x = dev_get_drvdata(pdev->dev.parent); 184 struct wm831x_pdata *chip_pdata = dev_get_platdata(pdev->dev.parent); | 183 struct device *dev = &pdev->dev; 184 struct wm831x *wm831x = dev_get_drvdata(dev->parent); 185 struct wm831x_pdata *chip_pdata = dev_get_platdata(dev->parent); |
185 struct wm831x_watchdog_pdata *pdata; 186 struct wm831x_wdt_drvdata *driver_data; 187 struct watchdog_device *wm831x_wdt; 188 int reg, ret, i; 189 190 ret = wm831x_reg_read(wm831x, WM831X_WATCHDOG); 191 if (ret < 0) { 192 dev_err(wm831x->dev, "Failed to read watchdog status: %d\n", 193 ret); 194 return ret; 195 } 196 reg = ret; 197 198 if (reg & WM831X_WDOG_DEBUG) 199 dev_warn(wm831x->dev, "Watchdog is paused\n"); 200 | 186 struct wm831x_watchdog_pdata *pdata; 187 struct wm831x_wdt_drvdata *driver_data; 188 struct watchdog_device *wm831x_wdt; 189 int reg, ret, i; 190 191 ret = wm831x_reg_read(wm831x, WM831X_WATCHDOG); 192 if (ret < 0) { 193 dev_err(wm831x->dev, "Failed to read watchdog status: %d\n", 194 ret); 195 return ret; 196 } 197 reg = ret; 198 199 if (reg & WM831X_WDOG_DEBUG) 200 dev_warn(wm831x->dev, "Watchdog is paused\n"); 201 |
201 driver_data = devm_kzalloc(&pdev->dev, sizeof(*driver_data), 202 GFP_KERNEL); | 202 driver_data = devm_kzalloc(dev, sizeof(*driver_data), GFP_KERNEL); |
203 if (!driver_data) 204 return -ENOMEM; 205 206 mutex_init(&driver_data->lock); 207 driver_data->wm831x = wm831x; 208 209 wm831x_wdt = &driver_data->wdt; 210 211 wm831x_wdt->info = &wm831x_wdt_info; 212 wm831x_wdt->ops = &wm831x_wdt_ops; | 203 if (!driver_data) 204 return -ENOMEM; 205 206 mutex_init(&driver_data->lock); 207 driver_data->wm831x = wm831x; 208 209 wm831x_wdt = &driver_data->wdt; 210 211 wm831x_wdt->info = &wm831x_wdt_info; 212 wm831x_wdt->ops = &wm831x_wdt_ops; |
213 wm831x_wdt->parent = &pdev->dev; | 213 wm831x_wdt->parent = dev; |
214 watchdog_set_nowayout(wm831x_wdt, nowayout); 215 watchdog_set_drvdata(wm831x_wdt, driver_data); 216 217 reg = wm831x_reg_read(wm831x, WM831X_WATCHDOG); 218 reg &= WM831X_WDOG_TO_MASK; 219 for (i = 0; i < ARRAY_SIZE(wm831x_wdt_cfgs); i++) 220 if (wm831x_wdt_cfgs[i].val == reg) 221 break; --- 13 unchanged lines hidden (view full) --- 235 reg &= ~(WM831X_WDOG_SECACT_MASK | WM831X_WDOG_PRIMACT_MASK | 236 WM831X_WDOG_RST_SRC); 237 238 reg |= pdata->primary << WM831X_WDOG_PRIMACT_SHIFT; 239 reg |= pdata->secondary << WM831X_WDOG_SECACT_SHIFT; 240 reg |= pdata->software << WM831X_WDOG_RST_SRC_SHIFT; 241 242 if (pdata->update_gpio) { | 214 watchdog_set_nowayout(wm831x_wdt, nowayout); 215 watchdog_set_drvdata(wm831x_wdt, driver_data); 216 217 reg = wm831x_reg_read(wm831x, WM831X_WATCHDOG); 218 reg &= WM831X_WDOG_TO_MASK; 219 for (i = 0; i < ARRAY_SIZE(wm831x_wdt_cfgs); i++) 220 if (wm831x_wdt_cfgs[i].val == reg) 221 break; --- 13 unchanged lines hidden (view full) --- 235 reg &= ~(WM831X_WDOG_SECACT_MASK | WM831X_WDOG_PRIMACT_MASK | 236 WM831X_WDOG_RST_SRC); 237 238 reg |= pdata->primary << WM831X_WDOG_PRIMACT_SHIFT; 239 reg |= pdata->secondary << WM831X_WDOG_SECACT_SHIFT; 240 reg |= pdata->software << WM831X_WDOG_RST_SRC_SHIFT; 241 242 if (pdata->update_gpio) { |
243 ret = devm_gpio_request_one(&pdev->dev, 244 pdata->update_gpio, 245 GPIOF_OUT_INIT_LOW, 246 "Watchdog update"); | 243 ret = devm_gpio_request_one(dev, pdata->update_gpio, 244 GPIOF_OUT_INIT_LOW, 245 "Watchdog update"); |
247 if (ret < 0) { 248 dev_err(wm831x->dev, 249 "Failed to request update GPIO: %d\n", 250 ret); 251 return ret; 252 } 253 254 driver_data->update_gpio = pdata->update_gpio; --- 8 unchanged lines hidden (view full) --- 263 wm831x_reg_lock(wm831x); 264 } else { 265 dev_err(wm831x->dev, 266 "Failed to unlock security key: %d\n", ret); 267 return ret; 268 } 269 } 270 | 246 if (ret < 0) { 247 dev_err(wm831x->dev, 248 "Failed to request update GPIO: %d\n", 249 ret); 250 return ret; 251 } 252 253 driver_data->update_gpio = pdata->update_gpio; --- 8 unchanged lines hidden (view full) --- 262 wm831x_reg_lock(wm831x); 263 } else { 264 dev_err(wm831x->dev, 265 "Failed to unlock security key: %d\n", ret); 266 return ret; 267 } 268 } 269 |
271 ret = devm_watchdog_register_device(&pdev->dev, &driver_data->wdt); | 270 ret = devm_watchdog_register_device(dev, &driver_data->wdt); |
272 if (ret != 0) { 273 dev_err(wm831x->dev, "watchdog_register_device() failed: %d\n", 274 ret); 275 return ret; 276 } 277 278 return 0; 279} --- 14 unchanged lines hidden --- | 271 if (ret != 0) { 272 dev_err(wm831x->dev, "watchdog_register_device() failed: %d\n", 273 ret); 274 return ret; 275 } 276 277 return 0; 278} --- 14 unchanged lines hidden --- |