Tom Rini | 83d290c | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0+ */ |
Stephen Warren | 927c1fa | 2015-03-24 20:07:33 -0600 | [diff] [blame] | 2 | /* |
| 3 | * Copyright 2015 Stephen Warren |
Stephen Warren | 927c1fa | 2015-03-24 20:07:33 -0600 | [diff] [blame] | 4 | */ |
| 5 | |
| 6 | #ifndef _BUS_ADDR_H |
| 7 | #define _BUS_ADDR_H |
| 8 | |
| 9 | #ifdef CONFIG_PHYS_TO_BUS |
| 10 | unsigned long phys_to_bus(unsigned long phys); |
| 11 | unsigned long bus_to_phys(unsigned long bus); |
| 12 | #else |
| 13 | static inline unsigned long phys_to_bus(unsigned long phys) |
| 14 | { |
| 15 | return phys; |
| 16 | } |
| 17 | |
| 18 | static inline unsigned long bus_to_phys(unsigned long bus) |
| 19 | { |
| 20 | return bus; |
| 21 | } |
| 22 | #endif |
| 23 | |
Nicolas Saenz Julienne | 2a15a25 | 2021-01-12 13:55:26 +0100 | [diff] [blame] | 24 | #if CONFIG_IS_ENABLED(DM) |
| 25 | #include <dm/device.h> |
| 26 | |
| 27 | static inline dma_addr_t dev_phys_to_bus(struct udevice *dev, phys_addr_t phys) |
| 28 | { |
| 29 | return phys - dev_get_dma_offset(dev); |
| 30 | } |
| 31 | |
| 32 | static inline phys_addr_t dev_bus_to_phys(struct udevice *dev, dma_addr_t bus) |
| 33 | { |
| 34 | return bus + dev_get_dma_offset(dev); |
| 35 | } |
| 36 | #else |
| 37 | #define dev_phys_to_bus(_, _addr) _addr |
| 38 | #define dev_bus_to_phys(_, _addr) _addr |
| 39 | #endif |
| 40 | |
Stephen Warren | 927c1fa | 2015-03-24 20:07:33 -0600 | [diff] [blame] | 41 | #endif |