broadwell: Split IOBP into separate files
Pull the IOBP related defines and functions from pch.c/pch.h into separate iobp.c/iobp.h. BUG=chrome-os-partner:28234 TEST=None Change-Id: Ic510360c14594f4fd46249c238ac851372045893 Signed-off-by: Duncan Laurie <dlaurie@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/198734 Reviewed-by: Aaron Durbin <adurbin@chromium.org>
This commit is contained in:
parent
e6e12c39ef
commit
f93b8bda71
4 changed files with 152 additions and 107 deletions
27
src/soc/intel/broadwell/broadwell/iobp.h
Normal file
27
src/soc/intel/broadwell/broadwell/iobp.h
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
/*
|
||||
* This file is part of the coreboot project.
|
||||
*
|
||||
* Copyright (C) 2014 Google Inc.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; version 2 of the License.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#ifndef _BROADWELL_IOBP_H_
|
||||
#define _BROADWELL_IOBP_H_
|
||||
|
||||
u32 pch_iobp_read(u32 address);
|
||||
void pch_iobp_write(u32 address, u32 data);
|
||||
void pch_iobp_update(u32 address, u32 andvalue, u32 orvalue);
|
||||
|
||||
#endif
|
||||
|
|
@ -105,9 +105,6 @@ u16 get_gpiobase(void);
|
|||
#include "chip.h"
|
||||
void pch_enable(device_t dev);
|
||||
void pch_disable_devfn(device_t dev);
|
||||
u32 pch_iobp_read(u32 address);
|
||||
void pch_iobp_write(u32 address, u32 data);
|
||||
void pch_iobp_update(u32 address, u32 andvalue, u32 orvalue);
|
||||
#if CONFIG_ELOG
|
||||
void pch_log_state(void);
|
||||
#endif
|
||||
|
|
|
|||
125
src/soc/intel/broadwell/iobp.c
Normal file
125
src/soc/intel/broadwell/iobp.c
Normal file
|
|
@ -0,0 +1,125 @@
|
|||
/*
|
||||
* This file is part of the coreboot project.
|
||||
*
|
||||
* Copyright (C) 2014 Google Inc.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; version 2 of the License.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#include <console/console.h>
|
||||
#include <delay.h>
|
||||
#include <arch/io.h>
|
||||
#include <broadwell/iobp.h>
|
||||
#include <broadwell/rcba.h>
|
||||
|
||||
#define IOBP_RETRY 1000
|
||||
|
||||
static inline int iobp_poll(void)
|
||||
{
|
||||
unsigned try;
|
||||
|
||||
for (try = IOBP_RETRY; try > 0; try--) {
|
||||
u16 status = RCBA16(IOBPS);
|
||||
if ((status & IOBPS_READY) == 0)
|
||||
return 1;
|
||||
udelay(10);
|
||||
}
|
||||
|
||||
printk(BIOS_ERR, "IOBP: timeout waiting for transaction to complete\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
u32 pch_iobp_read(u32 address)
|
||||
{
|
||||
u16 status;
|
||||
|
||||
if (!iobp_poll())
|
||||
return 0;
|
||||
|
||||
/* Set the address */
|
||||
RCBA32(IOBPIRI) = address;
|
||||
|
||||
/* READ OPCODE */
|
||||
status = RCBA16(IOBPS);
|
||||
status &= ~IOBPS_MASK;
|
||||
status |= IOBPS_READ;
|
||||
RCBA16(IOBPS) = status;
|
||||
|
||||
/* Undocumented magic */
|
||||
RCBA16(IOBPU) = IOBPU_MAGIC;
|
||||
|
||||
/* Set ready bit */
|
||||
status = RCBA16(IOBPS);
|
||||
status |= IOBPS_READY;
|
||||
RCBA16(IOBPS) = status;
|
||||
|
||||
if (!iobp_poll())
|
||||
return 0;
|
||||
|
||||
/* Check for successful transaction */
|
||||
status = RCBA16(IOBPS);
|
||||
if (status & IOBPS_TX_MASK) {
|
||||
printk(BIOS_ERR, "IOBP: read 0x%08x failed\n", address);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Read IOBP data */
|
||||
return RCBA32(IOBPD);
|
||||
}
|
||||
|
||||
void pch_iobp_write(u32 address, u32 data)
|
||||
{
|
||||
u16 status;
|
||||
|
||||
if (!iobp_poll())
|
||||
return;
|
||||
|
||||
/* Set the address */
|
||||
RCBA32(IOBPIRI) = address;
|
||||
|
||||
/* WRITE OPCODE */
|
||||
status = RCBA16(IOBPS);
|
||||
status &= ~IOBPS_MASK;
|
||||
status |= IOBPS_WRITE;
|
||||
RCBA16(IOBPS) = status;
|
||||
|
||||
RCBA32(IOBPD) = data;
|
||||
|
||||
/* Undocumented magic */
|
||||
RCBA16(IOBPU) = IOBPU_MAGIC;
|
||||
|
||||
/* Set ready bit */
|
||||
status = RCBA16(IOBPS);
|
||||
status |= IOBPS_READY;
|
||||
RCBA16(IOBPS) = status;
|
||||
|
||||
if (!iobp_poll())
|
||||
return;
|
||||
|
||||
/* Check for successful transaction */
|
||||
status = RCBA16(IOBPS);
|
||||
if (status & IOBPS_TX_MASK)
|
||||
printk(BIOS_ERR, "IOBP: write 0x%08x failed\n", address);
|
||||
}
|
||||
|
||||
void pch_iobp_update(u32 address, u32 andvalue, u32 orvalue)
|
||||
{
|
||||
u32 data = pch_iobp_read(address);
|
||||
|
||||
/* Update the data */
|
||||
data &= andvalue;
|
||||
data |= orvalue;
|
||||
|
||||
pch_iobp_write(address, data);
|
||||
}
|
||||
|
|
@ -184,110 +184,6 @@ void pch_disable_devfn(device_t dev)
|
|||
}
|
||||
}
|
||||
|
||||
#define IOBP_RETRY 1000
|
||||
static inline int iobp_poll(void)
|
||||
{
|
||||
unsigned try;
|
||||
|
||||
for (try = IOBP_RETRY; try > 0; try--) {
|
||||
u16 status = RCBA16(IOBPS);
|
||||
if ((status & IOBPS_READY) == 0)
|
||||
return 1;
|
||||
udelay(10);
|
||||
}
|
||||
|
||||
printk(BIOS_ERR, "IOBP: timeout waiting for transaction to complete\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
u32 pch_iobp_read(u32 address)
|
||||
{
|
||||
u16 status;
|
||||
|
||||
if (!iobp_poll())
|
||||
return 0;
|
||||
|
||||
/* Set the address */
|
||||
RCBA32(IOBPIRI) = address;
|
||||
|
||||
/* READ OPCODE */
|
||||
status = RCBA16(IOBPS);
|
||||
status &= ~IOBPS_MASK;
|
||||
status |= IOBPS_READ;
|
||||
RCBA16(IOBPS) = status;
|
||||
|
||||
/* Undocumented magic */
|
||||
RCBA16(IOBPU) = IOBPU_MAGIC;
|
||||
|
||||
/* Set ready bit */
|
||||
status = RCBA16(IOBPS);
|
||||
status |= IOBPS_READY;
|
||||
RCBA16(IOBPS) = status;
|
||||
|
||||
if (!iobp_poll())
|
||||
return 0;
|
||||
|
||||
/* Check for successful transaction */
|
||||
status = RCBA16(IOBPS);
|
||||
if (status & IOBPS_TX_MASK) {
|
||||
printk(BIOS_ERR, "IOBP: read 0x%08x failed\n", address);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Read IOBP data */
|
||||
return RCBA32(IOBPD);
|
||||
}
|
||||
|
||||
void pch_iobp_write(u32 address, u32 data)
|
||||
{
|
||||
u16 status;
|
||||
|
||||
if (!iobp_poll())
|
||||
return;
|
||||
|
||||
/* Set the address */
|
||||
RCBA32(IOBPIRI) = address;
|
||||
|
||||
/* WRITE OPCODE */
|
||||
status = RCBA16(IOBPS);
|
||||
status &= ~IOBPS_MASK;
|
||||
status |= IOBPS_WRITE;
|
||||
RCBA16(IOBPS) = status;
|
||||
|
||||
RCBA32(IOBPD) = data;
|
||||
|
||||
/* Undocumented magic */
|
||||
RCBA16(IOBPU) = IOBPU_MAGIC;
|
||||
|
||||
/* Set ready bit */
|
||||
status = RCBA16(IOBPS);
|
||||
status |= IOBPS_READY;
|
||||
RCBA16(IOBPS) = status;
|
||||
|
||||
if (!iobp_poll())
|
||||
return;
|
||||
|
||||
/* Check for successful transaction */
|
||||
status = RCBA16(IOBPS);
|
||||
if (status & IOBPS_TX_MASK) {
|
||||
printk(BIOS_ERR, "IOBP: write 0x%08x failed\n", address);
|
||||
return;
|
||||
}
|
||||
|
||||
printk(BIOS_INFO, "IOBP: set 0x%08x to 0x%08x\n", address, data);
|
||||
}
|
||||
|
||||
void pch_iobp_update(u32 address, u32 andvalue, u32 orvalue)
|
||||
{
|
||||
u32 data = pch_iobp_read(address);
|
||||
|
||||
/* Update the data */
|
||||
data &= andvalue;
|
||||
data |= orvalue;
|
||||
|
||||
pch_iobp_write(address, data);
|
||||
}
|
||||
|
||||
void pch_enable(device_t dev)
|
||||
{
|
||||
u32 reg32;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue