gpio: sch: Switch to memory mapped IO accessors

Convert driver to use memory mapped IO accessors.

Signed-off-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Acked-by: William Breathitt Gray <wbg@kernel.org>
Acked-by: Linus Walleij <linus.walleij@linaro.org>
This commit is contained in:
Andy Shevchenko 2024-04-10 10:21:02 +03:00 committed by Andy Shevchenko
parent d8a26a18d9
commit abaed898da

View File

@ -38,8 +38,8 @@
struct sch_gpio { struct sch_gpio {
struct gpio_chip chip; struct gpio_chip chip;
void __iomem *regs;
spinlock_t lock; spinlock_t lock;
unsigned short iobase;
unsigned short resume_base; unsigned short resume_base;
/* GPE handling */ /* GPE handling */
@ -75,7 +75,7 @@ static int sch_gpio_reg_get(struct sch_gpio *sch, unsigned int gpio, unsigned in
offset = sch_gpio_offset(sch, gpio, reg); offset = sch_gpio_offset(sch, gpio, reg);
bit = sch_gpio_bit(sch, gpio); bit = sch_gpio_bit(sch, gpio);
reg_val = !!(inb(sch->iobase + offset) & BIT(bit)); reg_val = !!(ioread8(sch->regs + offset) & BIT(bit));
return reg_val; return reg_val;
} }
@ -89,12 +89,14 @@ static void sch_gpio_reg_set(struct sch_gpio *sch, unsigned int gpio, unsigned i
offset = sch_gpio_offset(sch, gpio, reg); offset = sch_gpio_offset(sch, gpio, reg);
bit = sch_gpio_bit(sch, gpio); bit = sch_gpio_bit(sch, gpio);
reg_val = inb(sch->iobase + offset); reg_val = ioread8(sch->regs + offset);
if (val) if (val)
outb(reg_val | BIT(bit), sch->iobase + offset); reg_val |= BIT(bit);
else else
outb((reg_val & ~BIT(bit)), sch->iobase + offset); reg_val &= ~BIT(bit);
iowrite8(reg_val, sch->regs + offset);
} }
static int sch_gpio_direction_in(struct gpio_chip *gc, unsigned int gpio_num) static int sch_gpio_direction_in(struct gpio_chip *gc, unsigned int gpio_num)
@ -267,8 +269,8 @@ static u32 sch_gpio_gpe_handler(acpi_handle gpe_device, u32 gpe, void *context)
spin_lock_irqsave(&sch->lock, flags); spin_lock_irqsave(&sch->lock, flags);
core_status = inl(sch->iobase + CORE_BANK_OFFSET + GTS); core_status = ioread32(sch->regs + CORE_BANK_OFFSET + GTS);
resume_status = inl(sch->iobase + RESUME_BANK_OFFSET + GTS); resume_status = ioread32(sch->regs + RESUME_BANK_OFFSET + GTS);
spin_unlock_irqrestore(&sch->lock, flags); spin_unlock_irqrestore(&sch->lock, flags);
@ -319,9 +321,11 @@ static int sch_gpio_install_gpe_handler(struct sch_gpio *sch)
static int sch_gpio_probe(struct platform_device *pdev) static int sch_gpio_probe(struct platform_device *pdev)
{ {
struct device *dev = &pdev->dev;
struct gpio_irq_chip *girq; struct gpio_irq_chip *girq;
struct sch_gpio *sch; struct sch_gpio *sch;
struct resource *res; struct resource *res;
void __iomem *regs;
int ret; int ret;
sch = devm_kzalloc(&pdev->dev, sizeof(*sch), GFP_KERNEL); sch = devm_kzalloc(&pdev->dev, sizeof(*sch), GFP_KERNEL);
@ -332,12 +336,13 @@ static int sch_gpio_probe(struct platform_device *pdev)
if (!res) if (!res)
return -EBUSY; return -EBUSY;
if (!devm_request_region(&pdev->dev, res->start, resource_size(res), regs = devm_ioport_map(dev, res->start, resource_size(res));
pdev->name)) if (!regs)
return -EBUSY; return -EBUSY;
sch->regs = regs;
spin_lock_init(&sch->lock); spin_lock_init(&sch->lock);
sch->iobase = res->start;
sch->chip = sch_gpio_chip; sch->chip = sch_gpio_chip;
sch->chip.label = dev_name(&pdev->dev); sch->chip.label = dev_name(&pdev->dev);
sch->chip.parent = &pdev->dev; sch->chip.parent = &pdev->dev;