(Patches split per file for review, see cover letter for more information) Signed-off-by: Lachlan Hodges --- drivers/net/wireless/morsemicro/mm81x/bus.h | 90 +++++++++++++++++++++ 1 file changed, 90 insertions(+) create mode 100644 drivers/net/wireless/morsemicro/mm81x/bus.h diff --git a/drivers/net/wireless/morsemicro/mm81x/bus.h b/drivers/net/wireless/morsemicro/mm81x/bus.h new file mode 100644 index 000000000000..3c0b8bb1d8c3 --- /dev/null +++ b/drivers/net/wireless/morsemicro/mm81x/bus.h @@ -0,0 +1,90 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +/* + * Copyright (c) 2017-2026 Morse Micro + */ + +#ifndef _MM81X_BUS_H_ +#define _MM81X_BUS_H_ + +#include +#include "core.h" + +enum mm81x_bus_type { + MM81X_BUS_TYPE_USB, + MM81X_BUS_TYPE_SDIO, +}; + +struct mm81x_bus_ops { + int (*dm_read)(struct mm81x *mm, u32 addr, u8 *data, int len); + int (*dm_write)(struct mm81x *mm, u32 addr, const u8 *data, int len); + int (*reg32_read)(struct mm81x *mm, u32 addr, u32 *data); + int (*reg32_write)(struct mm81x *mm, u32 addr, u32 data); + void (*set_bus_enable)(struct mm81x *mm, bool enable); + void (*config_burst_mode)(struct mm81x *mm, bool enable_burst); + void (*claim)(struct mm81x *mm); + void (*set_irq)(struct mm81x *mm, bool enable); + void (*release)(struct mm81x *mm); + unsigned int bulk_alignment; +}; + +/* + * Default TX alignment for buses which don't care. mac80211 will give us + * SKBs aligned to the 2 byte boundary, so 2 is effectively a noop. + */ +#define MM81X_BUS_DEFAULT_BULK_ALIGNMENT (2) + +/* mm81x_dm_read - len must be rounded up to the nearest 4-byte boundary */ +static inline int mm81x_dm_read(struct mm81x *mm, u32 addr, u8 *data, int len) +{ + return mm->bus_ops->dm_read(mm, addr, data, len); +} + +static inline int mm81x_dm_write(struct mm81x *mm, u32 addr, const u8 *data, + int len) +{ + return mm->bus_ops->dm_write(mm, addr, data, len); +} + +static inline int mm81x_reg32_read(struct mm81x *mm, u32 addr, u32 *data) +{ + return mm->bus_ops->reg32_read(mm, addr, data); +} + +static inline int mm81x_reg32_write(struct mm81x *mm, u32 addr, u32 data) +{ + return mm->bus_ops->reg32_write(mm, addr, data); +} + +static inline void mm81x_set_bus_enable(struct mm81x *mm, bool enable) +{ + mm->bus_ops->set_bus_enable(mm, enable); +} + +static inline void mm81x_bus_config_burst_mode(struct mm81x *mm, + bool enable_burst) +{ + if (mm->bus_ops->config_burst_mode) + mm->bus_ops->config_burst_mode(mm, enable_burst); +} + +static inline void mm81x_claim_bus(struct mm81x *mm) +{ + mm->bus_ops->claim(mm); +} + +static inline void mm81x_bus_set_irq(struct mm81x *mm, bool enable) +{ + mm->bus_ops->set_irq(mm, enable); +} + +static inline void mm81x_release_bus(struct mm81x *mm) +{ + mm->bus_ops->release(mm); +} + +static inline unsigned int mm81x_bus_get_alignment(struct mm81x *mm) +{ + return mm->bus_ops->bulk_alignment; +} + +#endif /* !_MM81X_BUS_H_ */ -- 2.43.0