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