2018-05-06 21:58:06 +00:00
|
|
|
// SPDX-License-Identifier: GPL-2.0+
|
2015-02-02 14:35:24 +00:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2015, Bin Meng <bmeng.cn@gmail.com>
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <common.h>
|
|
|
|
#include <asm/arch/device.h>
|
|
|
|
#include <asm/arch/msg_port.h>
|
2015-09-03 12:37:23 +00:00
|
|
|
#include <asm/arch/quark.h>
|
2015-02-02 14:35:24 +00:00
|
|
|
|
|
|
|
void msg_port_setup(int op, int port, int reg)
|
|
|
|
{
|
2015-09-03 12:37:23 +00:00
|
|
|
qrk_pci_write_config_dword(QUARK_HOST_BRIDGE, MSG_CTRL_REG,
|
|
|
|
(((op) << 24) | ((port) << 16) |
|
|
|
|
(((reg) << 8) & 0xff00) | MSG_BYTE_ENABLE));
|
2015-02-02 14:35:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
u32 msg_port_read(u8 port, u32 reg)
|
|
|
|
{
|
|
|
|
u32 value;
|
|
|
|
|
2015-09-03 12:37:23 +00:00
|
|
|
qrk_pci_write_config_dword(QUARK_HOST_BRIDGE, MSG_CTRL_EXT_REG,
|
|
|
|
reg & 0xffffff00);
|
2015-02-02 14:35:24 +00:00
|
|
|
msg_port_setup(MSG_OP_READ, port, reg);
|
2015-09-03 12:37:23 +00:00
|
|
|
qrk_pci_read_config_dword(QUARK_HOST_BRIDGE, MSG_DATA_REG, &value);
|
2015-02-02 14:35:24 +00:00
|
|
|
|
|
|
|
return value;
|
|
|
|
}
|
|
|
|
|
|
|
|
void msg_port_write(u8 port, u32 reg, u32 value)
|
|
|
|
{
|
2015-09-03 12:37:23 +00:00
|
|
|
qrk_pci_write_config_dword(QUARK_HOST_BRIDGE, MSG_DATA_REG, value);
|
|
|
|
qrk_pci_write_config_dword(QUARK_HOST_BRIDGE, MSG_CTRL_EXT_REG,
|
|
|
|
reg & 0xffffff00);
|
2015-02-02 14:35:24 +00:00
|
|
|
msg_port_setup(MSG_OP_WRITE, port, reg);
|
|
|
|
}
|
|
|
|
|
|
|
|
u32 msg_port_alt_read(u8 port, u32 reg)
|
|
|
|
{
|
|
|
|
u32 value;
|
|
|
|
|
2015-09-03 12:37:23 +00:00
|
|
|
qrk_pci_write_config_dword(QUARK_HOST_BRIDGE, MSG_CTRL_EXT_REG,
|
|
|
|
reg & 0xffffff00);
|
2015-02-02 14:35:24 +00:00
|
|
|
msg_port_setup(MSG_OP_ALT_READ, port, reg);
|
2015-09-03 12:37:23 +00:00
|
|
|
qrk_pci_read_config_dword(QUARK_HOST_BRIDGE, MSG_DATA_REG, &value);
|
2015-02-02 14:35:24 +00:00
|
|
|
|
|
|
|
return value;
|
|
|
|
}
|
|
|
|
|
|
|
|
void msg_port_alt_write(u8 port, u32 reg, u32 value)
|
|
|
|
{
|
2015-09-03 12:37:23 +00:00
|
|
|
qrk_pci_write_config_dword(QUARK_HOST_BRIDGE, MSG_DATA_REG, value);
|
|
|
|
qrk_pci_write_config_dword(QUARK_HOST_BRIDGE, MSG_CTRL_EXT_REG,
|
|
|
|
reg & 0xffffff00);
|
2015-02-02 14:35:24 +00:00
|
|
|
msg_port_setup(MSG_OP_ALT_WRITE, port, reg);
|
|
|
|
}
|
|
|
|
|
|
|
|
u32 msg_port_io_read(u8 port, u32 reg)
|
|
|
|
{
|
|
|
|
u32 value;
|
|
|
|
|
2015-09-03 12:37:23 +00:00
|
|
|
qrk_pci_write_config_dword(QUARK_HOST_BRIDGE, MSG_CTRL_EXT_REG,
|
|
|
|
reg & 0xffffff00);
|
2015-02-02 14:35:24 +00:00
|
|
|
msg_port_setup(MSG_OP_IO_READ, port, reg);
|
2015-09-03 12:37:23 +00:00
|
|
|
qrk_pci_read_config_dword(QUARK_HOST_BRIDGE, MSG_DATA_REG, &value);
|
2015-02-02 14:35:24 +00:00
|
|
|
|
|
|
|
return value;
|
|
|
|
}
|
|
|
|
|
|
|
|
void msg_port_io_write(u8 port, u32 reg, u32 value)
|
|
|
|
{
|
2015-09-03 12:37:23 +00:00
|
|
|
qrk_pci_write_config_dword(QUARK_HOST_BRIDGE, MSG_DATA_REG, value);
|
|
|
|
qrk_pci_write_config_dword(QUARK_HOST_BRIDGE, MSG_CTRL_EXT_REG,
|
|
|
|
reg & 0xffffff00);
|
2015-02-02 14:35:24 +00:00
|
|
|
msg_port_setup(MSG_OP_IO_WRITE, port, reg);
|
|
|
|
}
|