From 4c1e0a97351a5e88e7e503b40cdbe0f220039a5e Mon Sep 17 00:00:00 2001 From: Thierry Reding Date: Thu, 22 Sep 2022 15:41:24 +0200 Subject: firmware: tegra: bpmp: Use iosys-map helpers The shared memory used for inter-processor communication between the CPU and the BPMP can reside either in system memory or in I/O memory. Use the iosys-map helpers to abstract these differences away. Signed-off-by: Thierry Reding --- include/soc/tegra/bpmp.h | 17 +++++++++++++++-- include/soc/tegra/ivc.h | 11 ++++++----- 2 files changed, 21 insertions(+), 7 deletions(-) (limited to 'include/soc') diff --git a/include/soc/tegra/bpmp.h b/include/soc/tegra/bpmp.h index f2604e99af09..5842e38bb288 100644 --- a/include/soc/tegra/bpmp.h +++ b/include/soc/tegra/bpmp.h @@ -6,6 +6,7 @@ #ifndef __SOC_TEGRA_BPMP_H #define __SOC_TEGRA_BPMP_H +#include #include #include #include @@ -36,10 +37,22 @@ struct tegra_bpmp_mb_data { u8 data[MSG_DATA_MIN_SZ]; } __packed; +#define tegra_bpmp_mb_read(dst, mb, size) \ + iosys_map_memcpy_from(dst, mb, offsetof(struct tegra_bpmp_mb_data, data), size) + +#define tegra_bpmp_mb_write(mb, src, size) \ + iosys_map_memcpy_to(mb, offsetof(struct tegra_bpmp_mb_data, data), src, size) + +#define tegra_bpmp_mb_read_field(mb, field) \ + iosys_map_rd_field(mb, 0, struct tegra_bpmp_mb_data, field) + +#define tegra_bpmp_mb_write_field(mb, field, value) \ + iosys_map_wr_field(mb, 0, struct tegra_bpmp_mb_data, field, value) + struct tegra_bpmp_channel { struct tegra_bpmp *bpmp; - struct tegra_bpmp_mb_data *ib; - struct tegra_bpmp_mb_data *ob; + struct iosys_map ib; + struct iosys_map ob; struct completion completion; struct tegra_ivc *ivc; unsigned int index; diff --git a/include/soc/tegra/ivc.h b/include/soc/tegra/ivc.h index 4aeb77cc22c5..116793b26330 100644 --- a/include/soc/tegra/ivc.h +++ b/include/soc/tegra/ivc.h @@ -7,6 +7,7 @@ #include #include +#include #include struct tegra_ivc_header; @@ -15,7 +16,7 @@ struct tegra_ivc { struct device *peer; struct { - struct tegra_ivc_header *channel; + struct iosys_map map; unsigned int position; dma_addr_t phys; } rx, tx; @@ -36,7 +37,7 @@ struct tegra_ivc { * * Returns a pointer to the frame, or an error encoded pointer. */ -void *tegra_ivc_read_get_next_frame(struct tegra_ivc *ivc); +int tegra_ivc_read_get_next_frame(struct tegra_ivc *ivc, struct iosys_map *map); /** * tegra_ivc_read_advance - Advance the read queue @@ -56,7 +57,7 @@ int tegra_ivc_read_advance(struct tegra_ivc *ivc); * * Returns a pointer to the frame, or an error encoded pointer. */ -void *tegra_ivc_write_get_next_frame(struct tegra_ivc *ivc); +int tegra_ivc_write_get_next_frame(struct tegra_ivc *ivc, struct iosys_map *map); /** * tegra_ivc_write_advance - Advance the write queue @@ -91,8 +92,8 @@ void tegra_ivc_reset(struct tegra_ivc *ivc); size_t tegra_ivc_align(size_t size); unsigned tegra_ivc_total_queue_size(unsigned queue_size); -int tegra_ivc_init(struct tegra_ivc *ivc, struct device *peer, void *rx, - dma_addr_t rx_phys, void *tx, dma_addr_t tx_phys, +int tegra_ivc_init(struct tegra_ivc *ivc, struct device *peer, const struct iosys_map *rx, + dma_addr_t rx_phys, const struct iosys_map *tx, dma_addr_t tx_phys, unsigned int num_frames, size_t frame_size, void (*notify)(struct tegra_ivc *ivc, void *data), void *data); -- cgit v1.2.3