blob: 53d4e4503a74cf813a7eef33b5ca903f9033981d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
// SPDX-License-Identifier: GPL-2.0-only
/*
* Copyright (C) 2021-2022 Digiteq Automotive
* author: Martin Tuma <martin.tuma@digiteqautomotive.com>
*/
#include <linux/ioport.h>
#include "mgb4_regs.h"
int mgb4_regs_map(struct resource *res, struct mgb4_regs *regs)
{
regs->mapbase = res->start;
regs->mapsize = res->end - res->start;
if (!request_mem_region(regs->mapbase, regs->mapsize, res->name))
return -EINVAL;
regs->membase = ioremap(regs->mapbase, regs->mapsize);
if (!regs->membase) {
release_mem_region(regs->mapbase, regs->mapsize);
return -EINVAL;
}
return 0;
}
void mgb4_regs_free(struct mgb4_regs *regs)
{
iounmap(regs->membase);
release_mem_region(regs->mapbase, regs->mapsize);
}
|