aboutsummaryrefslogtreecommitdiff
path: root/src/soc/amd/stoneyridge/sm.c
diff options
context:
space:
mode:
authorRichard Spiegel <richard.spiegel@amd.corp-partner.google.com>2018-10-24 12:51:21 -0700
committerPatrick Georgi <pgeorgi@google.com>2019-01-30 11:01:37 +0000
commitb40e193948c0af380e9dc19c06a5c93ff8b4f2f0 (patch)
tree3de92e0841b9ef7e2c2c3a86e6b4cfd404f827dd /src/soc/amd/stoneyridge/sm.c
parent9ca43191ab454c777102f9634b5d40478cd4dc58 (diff)
soc/amd/stoneyridge: Access SMBUS through MMIO
Currently SMBUS registers are accessed through IO, but with stoneyridge they can be accessed through MMIO. This reduces the time of execution by a tiny amount (MMIO write is faster than IO write, though MMIO read is about as fast as IO read) as most of the time consumed is actually transaction time. Convert code to MMIO access. BUG=b:117754784 TEST=Used IO to write and MMIO to read, to confirm a one to one relationship between IO and MMIO. Then build and boot grunt. Change-Id: Ibe1471d1d578611e7d666f70bc97de4c3b74d7f8 Signed-off-by: Richard Spiegel <richard.spiegel@silverbackltd.com> Reviewed-on: https://review.coreboot.org/c/29258 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Martin Roth <martinroth@google.com>
Diffstat (limited to 'src/soc/amd/stoneyridge/sm.c')
-rw-r--r--src/soc/amd/stoneyridge/sm.c39
1 files changed, 14 insertions, 25 deletions
diff --git a/src/soc/amd/stoneyridge/sm.c b/src/soc/amd/stoneyridge/sm.c
index 22cbde8854..82c265e475 100644
--- a/src/soc/amd/stoneyridge/sm.c
+++ b/src/soc/amd/stoneyridge/sm.c
@@ -35,60 +35,49 @@ static void sm_init(struct device *dev)
setup_ioapic(VIO_APIC_VADDR, CONFIG_MAX_CPUS);
}
-static int lsmbus_recv_byte(struct device *dev)
+static u32 get_sm_mmio(struct device *dev)
{
- u8 device;
struct resource *res;
struct bus *pbus;
- device = dev->path.i2c.device;
pbus = get_pbus_smbus(dev);
-
res = find_resource(pbus->dev, 0x90);
+ if (res->base == SMB_BASE_ADDR)
+ return SMBUS_MMIO_BASE;
- return do_smbus_recv_byte(res->base, device);
+ return ASF_MMIO_BASE;
}
-static int lsmbus_send_byte(struct device *dev, u8 val)
+static int lsmbus_recv_byte(struct device *dev)
{
u8 device;
- struct resource *res;
- struct bus *pbus;
device = dev->path.i2c.device;
- pbus = get_pbus_smbus(dev);
+ return do_smbus_recv_byte(get_sm_mmio(dev), device);
+}
- res = find_resource(pbus->dev, 0x90);
+static int lsmbus_send_byte(struct device *dev, u8 val)
+{
+ u8 device;
- return do_smbus_send_byte(res->base, device, val);
+ device = dev->path.i2c.device;
+ return do_smbus_send_byte(get_sm_mmio(dev), device, val);
}
static int lsmbus_read_byte(struct device *dev, u8 address)
{
u8 device;
- struct resource *res;
- struct bus *pbus;
device = dev->path.i2c.device;
- pbus = get_pbus_smbus(dev);
-
- res = find_resource(pbus->dev, 0x90);
-
- return do_smbus_read_byte(res->base, device, address);
+ return do_smbus_read_byte(get_sm_mmio(dev), device, address);
}
static int lsmbus_write_byte(struct device *dev, u8 address, u8 val)
{
u8 device;
- struct resource *res;
- struct bus *pbus;
device = dev->path.i2c.device;
- pbus = get_pbus_smbus(dev);
-
- res = find_resource(pbus->dev, 0x90);
-
- return do_smbus_write_byte(res->base, device, address, val);
+ return do_smbus_write_byte(get_sm_mmio(dev), device, address, val);
}
static struct smbus_bus_operations lops_smbus_bus = {
.recv_byte = lsmbus_recv_byte,