]> git.ipfire.org Git - people/ms/u-boot.git/blame - drivers/misc/nuvoton_nct6102d.c
Remove CONFIG_SYS_BOOTCOUNT_SINGLEWORD
[people/ms/u-boot.git] / drivers / misc / nuvoton_nct6102d.c
CommitLineData
4cf9e464
SR
1/*
2 * Copyright (C) 2016 Stefan Roese <sr@denx.de>
3 *
4 * SPDX-License-Identifier: GPL-2.0+
5 */
6
7#include <common.h>
8#include <nuvoton_nct6102d.h>
9#include <asm/io.h>
10#include <asm/pnp_def.h>
11
12static void superio_outb(int reg, int val)
13{
14 outb(reg, NCT_EFER);
15 outb(val, NCT_EFDR);
16}
17
18static inline int superio_inb(int reg)
19{
20 outb(reg, NCT_EFER);
21 return inb(NCT_EFDR);
22}
23
24static int superio_enter(void)
25{
26 outb(NCT_ENTRY_KEY, NCT_EFER); /* Enter extended function mode */
27 outb(NCT_ENTRY_KEY, NCT_EFER); /* Again according to manual */
28
29 return 0;
30}
31
32static void superio_select(int ld)
33{
34 superio_outb(NCT_LD_SELECT_REG, ld);
35}
36
37static void superio_exit(void)
38{
39 outb(NCT_EXIT_KEY, NCT_EFER); /* Leave extended function mode */
40}
41
42/*
43 * The Nuvoton NCT6102D starts per default after reset with both,
44 * the internal watchdog and the internal legacy UART enabled. This
45 * code provides a function to disable the watchdog.
46 */
47int nct6102d_wdt_disable(void)
48{
49 superio_enter();
50 /* Select logical device for WDT */
51 superio_select(NCT6102D_LD_WDT);
52 superio_outb(NCT6102D_WDT_TIMEOUT, 0x00);
53 superio_exit();
54
55 return 0;
56}