Commit 927c1fa266ead17acb09e9397dbd33578f3ee267
Committed by
Marek Vasut
1 parent
fc909c0563
Exists in
v2017.01-smarct4x
and in
34 other branches
Create API to map between CPU physical and bus addresses
On some SoCs, DMA-capable peripherals see a different address space to the CPU's physical address space. Create an API to allow platform-agnostic drivers to convert between the two address spaces when programming DMA operations. This API will exist on all platforms, but will have a dummy implementation when this feature is not required. Other platforms will enable CONFIG_PHYS_TO_BUS and provide the required implementation. Signed-off-by: Stephen Warren <swarren@wwwdotorg.org>
Showing 2 changed files with 33 additions and 0 deletions Side-by-side Diff
drivers/Kconfig
... | ... | @@ -53,4 +53,12 @@ |
53 | 53 | source "drivers/thermal/Kconfig" |
54 | 54 | |
55 | 55 | endmenu |
56 | + | |
57 | +config PHYS_TO_BUS | |
58 | + bool | |
59 | + help | |
60 | + Some SoCs use a different address map for CPU physical addresses and | |
61 | + peripheral DMA master accesses. If yours does, select this option in | |
62 | + your platform's Kconfig, and implement the appropriate mapping | |
63 | + functions in your platform's support code. |
include/phys2bus.h
1 | +/* | |
2 | + * Copyright 2015 Stephen Warren | |
3 | + * | |
4 | + * SPDX-License-Identifier: GPL-2.0+ | |
5 | + */ | |
6 | + | |
7 | +#ifndef _BUS_ADDR_H | |
8 | +#define _BUS_ADDR_H | |
9 | + | |
10 | +#ifdef CONFIG_PHYS_TO_BUS | |
11 | +unsigned long phys_to_bus(unsigned long phys); | |
12 | +unsigned long bus_to_phys(unsigned long bus); | |
13 | +#else | |
14 | +static inline unsigned long phys_to_bus(unsigned long phys) | |
15 | +{ | |
16 | + return phys; | |
17 | +} | |
18 | + | |
19 | +static inline unsigned long bus_to_phys(unsigned long bus) | |
20 | +{ | |
21 | + return bus; | |
22 | +} | |
23 | +#endif | |
24 | + | |
25 | +#endif |