blob: a3ca037d25f7d97da49dca8538bcff64195cb999 [file] [log] [blame]
Tom Rini10e47792018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
Stefan Roese4a269f22016-07-19 07:45:46 +02002/*
3 * Copyright (C) 2016 Stefan Roese <sr@denx.de>
Stefan Roese4a269f22016-07-19 07:45:46 +02004 */
5
Stefan Roese4a269f22016-07-19 07:45:46 +02006#include <nuvoton_nct6102d.h>
7#include <asm/io.h>
8#include <asm/pnp_def.h>
9
10static void superio_outb(int reg, int val)
11{
12 outb(reg, NCT_EFER);
13 outb(val, NCT_EFDR);
14}
15
16static inline int superio_inb(int reg)
17{
18 outb(reg, NCT_EFER);
19 return inb(NCT_EFDR);
20}
21
22static int superio_enter(void)
23{
24 outb(NCT_ENTRY_KEY, NCT_EFER); /* Enter extended function mode */
25 outb(NCT_ENTRY_KEY, NCT_EFER); /* Again according to manual */
26
27 return 0;
28}
29
30static void superio_select(int ld)
31{
32 superio_outb(NCT_LD_SELECT_REG, ld);
33}
34
35static void superio_exit(void)
36{
37 outb(NCT_EXIT_KEY, NCT_EFER); /* Leave extended function mode */
38}
39
40/*
41 * The Nuvoton NCT6102D starts per default after reset with both,
42 * the internal watchdog and the internal legacy UART enabled. This
43 * code provides a function to disable the watchdog.
44 */
45int nct6102d_wdt_disable(void)
46{
47 superio_enter();
48 /* Select logical device for WDT */
49 superio_select(NCT6102D_LD_WDT);
50 superio_outb(NCT6102D_WDT_TIMEOUT, 0x00);
51 superio_exit();
52
53 return 0;
54}