blob: 3838b3f74f40738bec07dd601b1512964413215f [file] [log] [blame]
Tom Rini83d290c2018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
Stefan Roese85056932016-01-19 14:05:10 +01002/*
3 * Copyright (C) 2016 Stefan Roese <sr@denx.de>
Stefan Roese85056932016-01-19 14:05:10 +01004 */
5
6#include <common.h>
7#include <asm/io.h>
8#include <asm/pnp_def.h>
9
10#define WINBOND_ENTRY_KEY 0x87
11#define WINBOND_EXIT_KEY 0xaa
12
13/* Enable configuration: pass entry key '0x87' into index port dev twice */
14static void pnp_enter_conf_state(u16 dev)
15{
16 u16 port = dev >> 8;
17
18 outb(WINBOND_ENTRY_KEY, port);
19 outb(WINBOND_ENTRY_KEY, port);
20}
21
22/* Disable configuration: pass exit key '0xAA' into index port dev */
23static void pnp_exit_conf_state(u16 dev)
24{
25 u16 port = dev >> 8;
26
27 outb(WINBOND_EXIT_KEY, port);
28}
29
30/* Bring up early serial debugging output before the RAM is initialized */
31void winbond_enable_serial(uint dev, uint iobase, uint irq)
32{
33 pnp_enter_conf_state(dev);
34 pnp_set_logical_device(dev);
35 pnp_set_enable(dev, 0);
36 pnp_set_iobase(dev, PNP_IDX_IO0, iobase);
37 pnp_set_irq(dev, PNP_IDX_IRQ0, irq);
38 pnp_set_enable(dev, 1);
39 pnp_exit_conf_state(dev);
40}