sb/intel/x/smbus.c: Add block read/write support

Copy and paste the i82801gx code onto all newer southbridges. This will
be factored out into common code in a follow-up.

Change-Id: Ic4b7d657865f61703e4310423c565786badf6f40
Signed-off-by: Angel Pons <th3fanbus@gmail.com>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/48363
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Nico Huber <nico.h@gmx.de>
This commit is contained in:
Angel Pons 2020-12-05 20:25:27 +01:00
parent bb19d39487
commit 244cf7d3a6
5 changed files with 107 additions and 8 deletions

View File

@ -49,13 +49,38 @@ static int lsmbus_write_byte(struct device *dev, u8 address, u8 data)
device = dev->path.i2c.device; device = dev->path.i2c.device;
pbus = get_pbus_smbus(dev); pbus = get_pbus_smbus(dev);
res = find_resource(pbus->dev, PCI_BASE_ADDRESS_4); res = find_resource(pbus->dev, PCI_BASE_ADDRESS_4);
return do_smbus_write_byte(res->base, device, address, data); return do_smbus_write_byte(res->base, device, address, data);
} }
static int lsmbus_block_write(struct device *dev, u8 cmd, u8 bytes, const u8 *buf)
{
u16 device;
struct resource *res;
struct bus *pbus;
device = dev->path.i2c.device;
pbus = get_pbus_smbus(dev);
res = find_resource(pbus->dev, PCI_BASE_ADDRESS_4);
return do_smbus_block_write(res->base, device, cmd, bytes, buf);
}
static int lsmbus_block_read(struct device *dev, u8 cmd, u8 bytes, u8 *buf)
{
u16 device;
struct resource *res;
struct bus *pbus;
device = dev->path.i2c.device;
pbus = get_pbus_smbus(dev);
res = find_resource(pbus->dev, PCI_BASE_ADDRESS_4);
return do_smbus_block_read(res->base, device, cmd, bytes, buf);
}
static struct smbus_bus_operations lops_smbus_bus = { static struct smbus_bus_operations lops_smbus_bus = {
.read_byte = lsmbus_read_byte, .read_byte = lsmbus_read_byte,
.write_byte = lsmbus_write_byte, .write_byte = lsmbus_write_byte,
.block_read = lsmbus_block_read,
.block_write = lsmbus_block_write,
}; };
static void smbus_read_resources(struct device *dev) static void smbus_read_resources(struct device *dev)

View File

@ -38,13 +38,38 @@ static int lsmbus_write_byte(struct device *dev, u8 address, u8 data)
device = dev->path.i2c.device; device = dev->path.i2c.device;
pbus = get_pbus_smbus(dev); pbus = get_pbus_smbus(dev);
res = find_resource(pbus->dev, PCI_BASE_ADDRESS_4); res = find_resource(pbus->dev, PCI_BASE_ADDRESS_4);
return do_smbus_write_byte(res->base, device, address, data); return do_smbus_write_byte(res->base, device, address, data);
} }
static int lsmbus_block_write(struct device *dev, u8 cmd, u8 bytes, const u8 *buf)
{
u16 device;
struct resource *res;
struct bus *pbus;
device = dev->path.i2c.device;
pbus = get_pbus_smbus(dev);
res = find_resource(pbus->dev, PCI_BASE_ADDRESS_4);
return do_smbus_block_write(res->base, device, cmd, bytes, buf);
}
static int lsmbus_block_read(struct device *dev, u8 cmd, u8 bytes, u8 *buf)
{
u16 device;
struct resource *res;
struct bus *pbus;
device = dev->path.i2c.device;
pbus = get_pbus_smbus(dev);
res = find_resource(pbus->dev, PCI_BASE_ADDRESS_4);
return do_smbus_block_read(res->base, device, cmd, bytes, buf);
}
static struct smbus_bus_operations lops_smbus_bus = { static struct smbus_bus_operations lops_smbus_bus = {
.read_byte = lsmbus_read_byte, .read_byte = lsmbus_read_byte,
.write_byte = lsmbus_write_byte, .write_byte = lsmbus_write_byte,
.block_read = lsmbus_block_read,
.block_write = lsmbus_block_write,
}; };
static void smbus_read_resources(struct device *dev) static void smbus_read_resources(struct device *dev)

View File

@ -38,12 +38,10 @@ static int lsmbus_write_byte(struct device *dev, u8 address, u8 data)
device = dev->path.i2c.device; device = dev->path.i2c.device;
pbus = get_pbus_smbus(dev); pbus = get_pbus_smbus(dev);
res = find_resource(pbus->dev, PCI_BASE_ADDRESS_4); res = find_resource(pbus->dev, PCI_BASE_ADDRESS_4);
return do_smbus_write_byte(res->base, device, address, data); return do_smbus_write_byte(res->base, device, address, data);
} }
static int lsmbus_block_write(struct device *dev, u8 cmd, u8 bytes, static int lsmbus_block_write(struct device *dev, u8 cmd, u8 bytes, const u8 *buf)
const u8 *buf)
{ {
u16 device; u16 device;
struct resource *res; struct resource *res;
@ -70,8 +68,8 @@ static int lsmbus_block_read(struct device *dev, u8 cmd, u8 bytes, u8 *buf)
static struct smbus_bus_operations lops_smbus_bus = { static struct smbus_bus_operations lops_smbus_bus = {
.read_byte = lsmbus_read_byte, .read_byte = lsmbus_read_byte,
.write_byte = lsmbus_write_byte, .write_byte = lsmbus_write_byte,
.block_read = lsmbus_block_read, .block_read = lsmbus_block_read,
.block_write = lsmbus_block_write, .block_write = lsmbus_block_write,
}; };
static void smbus_read_resources(struct device *dev) static void smbus_read_resources(struct device *dev)

View File

@ -48,13 +48,38 @@ static int lsmbus_write_byte(struct device *dev, u8 address, u8 data)
device = dev->path.i2c.device; device = dev->path.i2c.device;
pbus = get_pbus_smbus(dev); pbus = get_pbus_smbus(dev);
res = find_resource(pbus->dev, PCI_BASE_ADDRESS_4); res = find_resource(pbus->dev, PCI_BASE_ADDRESS_4);
return do_smbus_write_byte(res->base, device, address, data); return do_smbus_write_byte(res->base, device, address, data);
} }
static int lsmbus_block_write(struct device *dev, u8 cmd, u8 bytes, const u8 *buf)
{
u16 device;
struct resource *res;
struct bus *pbus;
device = dev->path.i2c.device;
pbus = get_pbus_smbus(dev);
res = find_resource(pbus->dev, PCI_BASE_ADDRESS_4);
return do_smbus_block_write(res->base, device, cmd, bytes, buf);
}
static int lsmbus_block_read(struct device *dev, u8 cmd, u8 bytes, u8 *buf)
{
u16 device;
struct resource *res;
struct bus *pbus;
device = dev->path.i2c.device;
pbus = get_pbus_smbus(dev);
res = find_resource(pbus->dev, PCI_BASE_ADDRESS_4);
return do_smbus_block_read(res->base, device, cmd, bytes, buf);
}
static struct smbus_bus_operations lops_smbus_bus = { static struct smbus_bus_operations lops_smbus_bus = {
.read_byte = lsmbus_read_byte, .read_byte = lsmbus_read_byte,
.write_byte = lsmbus_write_byte, .write_byte = lsmbus_write_byte,
.block_read = lsmbus_block_read,
.block_write = lsmbus_block_write,
}; };
static void smbus_read_resources(struct device *dev) static void smbus_read_resources(struct device *dev)

View File

@ -51,9 +51,35 @@ static int lsmbus_write_byte(struct device *dev, u8 address, u8 data)
return do_smbus_write_byte(res->base, device, address, data); return do_smbus_write_byte(res->base, device, address, data);
} }
static int lsmbus_block_write(struct device *dev, u8 cmd, u8 bytes, const u8 *buf)
{
u16 device;
struct resource *res;
struct bus *pbus;
device = dev->path.i2c.device;
pbus = get_pbus_smbus(dev);
res = find_resource(pbus->dev, PCI_BASE_ADDRESS_4);
return do_smbus_block_write(res->base, device, cmd, bytes, buf);
}
static int lsmbus_block_read(struct device *dev, u8 cmd, u8 bytes, u8 *buf)
{
u16 device;
struct resource *res;
struct bus *pbus;
device = dev->path.i2c.device;
pbus = get_pbus_smbus(dev);
res = find_resource(pbus->dev, PCI_BASE_ADDRESS_4);
return do_smbus_block_read(res->base, device, cmd, bytes, buf);
}
static struct smbus_bus_operations lops_smbus_bus = { static struct smbus_bus_operations lops_smbus_bus = {
.read_byte = lsmbus_read_byte, .read_byte = lsmbus_read_byte,
.write_byte = lsmbus_write_byte, .write_byte = lsmbus_write_byte,
.block_read = lsmbus_block_read,
.block_write = lsmbus_block_write,
}; };
static void smbus_read_resources(struct device *dev) static void smbus_read_resources(struct device *dev)