Lines Matching +full:cn9670 +full:- +full:wdt

1 // SPDX-License-Identifier: GPL-2.0
30 * Driver will use hardware in mode-3 above so that system can reboot in case
90 writeq(GTI_CWD_INT_PENDING_STATUS(priv->wdt_timer_idx), in gti_wdt_interrupt()
91 priv->base + GTI_CWD_INT); in gti_wdt_interrupt()
103 priv->base + GTI_CWD_POKE(priv->wdt_timer_idx)); in gti_wdt_ping()
113 if (!wdev->pretimeout) in gti_wdt_start()
114 return -EINVAL; in gti_wdt_start()
116 set_bit(WDOG_HW_RUNNING, &wdev->status); in gti_wdt_start()
119 writeq(GTI_CWD_INT_PENDING_STATUS(priv->wdt_timer_idx), in gti_wdt_start()
120 priv->base + GTI_CWD_INT); in gti_wdt_start()
123 writeq(GTI_CWD_INT_ENA_SET_VAL(priv->wdt_timer_idx), in gti_wdt_start()
124 priv->base + GTI_CWD_INT_ENA_SET); in gti_wdt_start()
127 regval = readq(priv->base + GTI_CWD_WDOG(priv->wdt_timer_idx)); in gti_wdt_start()
129 writeq(regval, priv->base + GTI_CWD_WDOG(priv->wdt_timer_idx)); in gti_wdt_start()
140 writeq(GTI_CWD_INT_ENA_CLR_VAL(priv->wdt_timer_idx), in gti_wdt_stop()
141 priv->base + GTI_CWD_INT_ENA_CLR); in gti_wdt_stop()
144 regval = readq(priv->base + GTI_CWD_WDOG(priv->wdt_timer_idx)); in gti_wdt_stop()
146 writeq(regval, priv->base + GTI_CWD_WDOG(priv->wdt_timer_idx)); in gti_wdt_stop()
158 wdev->timeout = timeout; in gti_wdt_settimeout()
161 wdev->pretimeout = timeout / 3; in gti_wdt_settimeout()
164 timeout_wdog = (u64)priv->clock_freq * wdev->pretimeout; in gti_wdt_settimeout()
169 /* GTI_CWD_WDOG.CNT: reload counter is 16-bit */ in gti_wdt_settimeout()
175 * GTI_CWD_WDOG.LEN is 24bit, lower 8-bits should be zero and in gti_wdt_settimeout()
176 * upper 16-bits are same as GTI_CWD_WDOG.CNT in gti_wdt_settimeout()
178 regval = readq(priv->base + GTI_CWD_WDOG(priv->wdt_timer_idx)); in gti_wdt_settimeout()
182 writeq(regval, priv->base + GTI_CWD_WDOG(priv->wdt_timer_idx)); in gti_wdt_settimeout()
191 struct watchdog_device *wdog_dev = &priv->wdev; in gti_wdt_set_pretimeout()
195 writeq(GTI_CWD_INT_ENA_CLR_VAL(priv->wdt_timer_idx), in gti_wdt_set_pretimeout()
196 priv->base + GTI_CWD_INT_ENA_CLR); in gti_wdt_set_pretimeout()
201 if (timeout * 3 <= wdog_dev->max_timeout) in gti_wdt_set_pretimeout()
204 return -EINVAL; in gti_wdt_set_pretimeout()
217 priv->sclk = devm_clk_get_enabled(&pdev->dev, NULL); in gti_wdt_get_cntfrq()
218 if (IS_ERR(priv->sclk)) in gti_wdt_get_cntfrq()
219 return PTR_ERR(priv->sclk); in gti_wdt_get_cntfrq()
221 err = devm_add_action_or_reset(&pdev->dev, in gti_wdt_get_cntfrq()
222 gti_clk_disable_unprepare, priv->sclk); in gti_wdt_get_cntfrq()
226 priv->clock_freq = clk_get_rate(priv->sclk); in gti_wdt_get_cntfrq()
227 if (!priv->clock_freq) in gti_wdt_get_cntfrq()
228 return -EINVAL; in gti_wdt_get_cntfrq()
251 struct device *dev = &pdev->dev; in gti_wdt_probe()
258 priv = devm_kzalloc(&pdev->dev, sizeof(*priv), GFP_KERNEL); in gti_wdt_probe()
260 return -ENOMEM; in gti_wdt_probe()
262 priv->base = devm_platform_ioremap_resource(pdev, 0); in gti_wdt_probe()
263 if (IS_ERR(priv->base)) in gti_wdt_probe()
264 return dev_err_probe(&pdev->dev, PTR_ERR(priv->base), in gti_wdt_probe()
269 return dev_err_probe(&pdev->dev, err, in gti_wdt_probe()
272 priv->data = of_device_get_match_data(dev); in gti_wdt_probe()
275 priv->wdt_timer_idx = priv->data->gti_num_timers - 1; in gti_wdt_probe()
277 err = of_property_read_u32(dev->of_node, "marvell,wdt-timer-index", in gti_wdt_probe()
280 if (wdt_idx >= priv->data->gti_num_timers) in gti_wdt_probe()
281 return dev_err_probe(&pdev->dev, -EINVAL, in gti_wdt_probe()
284 priv->wdt_timer_idx = wdt_idx; in gti_wdt_probe()
287 wdog_dev = &priv->wdev; in gti_wdt_probe()
288 wdog_dev->info = &gti_wdt_ident; in gti_wdt_probe()
289 wdog_dev->ops = &gti_wdt_ops; in gti_wdt_probe()
290 wdog_dev->parent = dev; in gti_wdt_probe()
297 max_pretimeout = (max_pretimeout * 1024) / priv->clock_freq; in gti_wdt_probe()
298 wdog_dev->pretimeout = max_pretimeout; in gti_wdt_probe()
301 wdog_dev->max_timeout = max_pretimeout * 3; in gti_wdt_probe()
302 wdog_dev->max_hw_heartbeat_ms = max_pretimeout * 1000; in gti_wdt_probe()
304 wdog_dev->min_timeout = 3; in gti_wdt_probe()
305 wdog_dev->timeout = wdog_dev->pretimeout; in gti_wdt_probe()
309 gti_wdt_settimeout(wdog_dev, wdog_dev->timeout); in gti_wdt_probe()
322 pdev->name, &priv->wdev); in gti_wdt_probe()
326 dev_info(dev, "Watchdog enabled (timeout=%d sec)\n", wdog_dev->timeout); in gti_wdt_probe()
331 { .compatible = "marvell,cn9670-wdt", .data = &match_data_octeontx2},
332 { .compatible = "marvell,cn10624-wdt", .data = &match_data_cn10k},
339 .name = "gti-wdt",