1 /* SPDX-License-Identifier: GPL-2.0+ */ 2 /* 3 * Copyright (C) 2023 Advanced Micro Devices, Inc. All rights reserved. 4 */ 5 6 #ifndef __SDW_AMD_H 7 #define __SDW_AMD_H 8 9 #include <linux/soundwire/sdw.h> 10 11 /* AMD pm_runtime quirk definitions */ 12 13 /* 14 * Force the clock to stop(ClockStopMode0) when suspend callback 15 * is invoked. 16 */ 17 #define AMD_SDW_CLK_STOP_MODE 1 18 19 /* 20 * Stop the bus when runtime suspend/system level suspend callback 21 * is invoked. If set, a complete bus reset and re-enumeration will 22 * be performed when the bus restarts. In-band wake interrupts are 23 * not supported in this mode. 24 */ 25 #define AMD_SDW_POWER_OFF_MODE 2 26 #define ACP_SDW0 0 27 #define ACP_SDW1 1 28 29 struct acp_sdw_pdata { 30 u16 instance; 31 /* mutex to protect acp common register access */ 32 struct mutex *acp_sdw_lock; 33 }; 34 35 struct sdw_manager_reg_mask { 36 u32 sw_pad_enable_mask; 37 u32 sw_pad_pulldown_mask; 38 u32 acp_sdw_intr_mask; 39 }; 40 41 /** 42 * struct sdw_amd_dai_runtime: AMD sdw dai runtime data 43 * 44 * @name: SoundWire stream name 45 * @stream: stream runtime 46 * @bus: Bus handle 47 * @stream_type: Stream type 48 */ 49 struct sdw_amd_dai_runtime { 50 char *name; 51 struct sdw_stream_runtime *stream; 52 struct sdw_bus *bus; 53 enum sdw_stream_type stream_type; 54 }; 55 56 /** 57 * struct amd_sdw_manager - amd manager driver context 58 * @bus: bus handle 59 * @dev: linux device 60 * @mmio: SoundWire registers mmio base 61 * @acp_mmio: acp registers mmio base 62 * @reg_mask: register mask structure per manager instance 63 * @amd_sdw_irq_thread: SoundWire manager irq workqueue 64 * @amd_sdw_work: peripheral status work queue 65 * @probe_work: SoundWire manager probe workqueue 66 * @acp_sdw_lock: mutex to protect acp share register access 67 * @status: peripheral devices status array 68 * @num_din_ports: number of input ports 69 * @num_dout_ports: number of output ports 70 * @cols_index: Column index in frame shape 71 * @rows_index: Rows index in frame shape 72 * @instance: SoundWire manager instance 73 * @quirks: SoundWire manager quirks 74 * @wake_en_mask: wake enable mask per SoundWire manager 75 * @clk_stopped: flag set to true when clock is stopped 76 * @power_mode_mask: flag interprets amd SoundWire manager power mode 77 * @dai_runtime_array: dai runtime array 78 */ 79 struct amd_sdw_manager { 80 struct sdw_bus bus; 81 struct device *dev; 82 83 void __iomem *mmio; 84 void __iomem *acp_mmio; 85 86 struct sdw_manager_reg_mask *reg_mask; 87 struct work_struct amd_sdw_irq_thread; 88 struct work_struct amd_sdw_work; 89 struct work_struct probe_work; 90 /* mutex to protect acp common register access */ 91 struct mutex *acp_sdw_lock; 92 93 enum sdw_slave_status status[SDW_MAX_DEVICES + 1]; 94 95 int num_din_ports; 96 int num_dout_ports; 97 98 int cols_index; 99 int rows_index; 100 101 u32 instance; 102 u32 quirks; 103 u32 wake_en_mask; 104 u32 power_mode_mask; 105 bool clk_stopped; 106 107 struct sdw_amd_dai_runtime **dai_runtime_array; 108 }; 109 #endif 110