Commit 48ace624 authored by Arnd Bergmann's avatar Arnd Bergmann Committed by Andi Shyti

i2c: ocores: convert to ioport_map() for IORESOURCE_IO

There is at least one machine that uses this driver but does not
have support for inb()/outb() instructions.

Convert this to using ioport_map() so it can build on architectures
that don't provide these but work correctly on machines that require
using port I/O.

Fixes: 47c21d2d ("i2c: add HAS_IOPORT dependencies")
Reported-by: default avatarGeert Uytterhoeven <geert@linux-m68k.org>
Link: https://lore.kernel.org/lkml/CAMuHMdVUQ2WgtpYPYfO2T=itMmZ7w=geREqDtsP8Q3ODh9rxdw@mail.gmail.com/Signed-off-by: default avatarArnd Bergmann <arnd@arndb.de>
Acked-by: default avatarPeter Korsgaard <peter@korsgaard.com>
Signed-off-by: default avatarAndi Shyti <andi.shyti@kernel.org>
parent 47c21d2d
...@@ -885,7 +885,6 @@ config I2C_NPCM ...@@ -885,7 +885,6 @@ config I2C_NPCM
config I2C_OCORES config I2C_OCORES
tristate "OpenCores I2C Controller" tristate "OpenCores I2C Controller"
depends on HAS_IOPORT
help help
If you say yes to this option, support will be included for the If you say yes to this option, support will be included for the
OpenCores I2C controller. For details see OpenCores I2C controller. For details see
......
...@@ -32,7 +32,6 @@ ...@@ -32,7 +32,6 @@
*/ */
struct ocores_i2c { struct ocores_i2c {
void __iomem *base; void __iomem *base;
int iobase;
u32 reg_shift; u32 reg_shift;
u32 reg_io_width; u32 reg_io_width;
unsigned long flags; unsigned long flags;
...@@ -136,16 +135,6 @@ static inline u8 oc_getreg_32be(struct ocores_i2c *i2c, int reg) ...@@ -136,16 +135,6 @@ static inline u8 oc_getreg_32be(struct ocores_i2c *i2c, int reg)
return ioread32be(i2c->base + (reg << i2c->reg_shift)); return ioread32be(i2c->base + (reg << i2c->reg_shift));
} }
static void oc_setreg_io_8(struct ocores_i2c *i2c, int reg, u8 value)
{
outb(value, i2c->iobase + reg);
}
static inline u8 oc_getreg_io_8(struct ocores_i2c *i2c, int reg)
{
return inb(i2c->iobase + reg);
}
static inline void oc_setreg(struct ocores_i2c *i2c, int reg, u8 value) static inline void oc_setreg(struct ocores_i2c *i2c, int reg, u8 value)
{ {
i2c->setreg(i2c, reg, value); i2c->setreg(i2c, reg, value);
...@@ -618,15 +607,19 @@ static int ocores_i2c_probe(struct platform_device *pdev) ...@@ -618,15 +607,19 @@ static int ocores_i2c_probe(struct platform_device *pdev)
res = platform_get_resource(pdev, IORESOURCE_IO, 0); res = platform_get_resource(pdev, IORESOURCE_IO, 0);
if (!res) if (!res)
return -EINVAL; return -EINVAL;
i2c->iobase = res->start;
if (!devm_request_region(&pdev->dev, res->start, if (!devm_request_region(&pdev->dev, res->start,
resource_size(res), resource_size(res),
pdev->name)) { pdev->name)) {
dev_err(&pdev->dev, "Can't get I/O resource.\n"); dev_err(&pdev->dev, "Can't get I/O resource.\n");
return -EBUSY; return -EBUSY;
} }
i2c->setreg = oc_setreg_io_8; i2c->base = devm_ioport_map(&pdev->dev, res->start,
i2c->getreg = oc_getreg_io_8; resource_size(res));
if (!i2c->base) {
dev_err(&pdev->dev, "Can't map I/O resource.\n");
return -EBUSY;
}
i2c->reg_io_width = 1;
} }
pdata = dev_get_platdata(&pdev->dev); pdata = dev_get_platdata(&pdev->dev);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment