msm-sps.h 46 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * Copyright (c) 2016-2021, The Linux Foundation. All rights reserved.
  4. * Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved.
  5. */
  6. /* Smart-Peripheral-Switch (SPS) API. */
  7. #ifndef _SPS_H_
  8. #define _SPS_H_
  9. #include <linux/errno.h>
  10. #include <linux/types.h>
  11. #if defined(CONFIG_PHYS_ADDR_T_64BIT) || defined(CONFIG_ARM_LPAE)
  12. /* Returns upper 4bits of 36bits physical address */
  13. #define SPS_GET_UPPER_ADDR(addr) ((addr & 0xF00000000ULL) >> 32)
  14. /* Returns 36bits physical address from 32bit address &
  15. * flags word
  16. */
  17. #define DESC_FULL_ADDR(flags, addr) ((((phys_addr_t)flags & 0xF) << 32) | addr)
  18. /* Returns flags word with flags and 4bit upper address
  19. * from flags and 36bit physical address
  20. */
  21. #define DESC_FLAG_WORD(flags, addr) (((addr & 0xF00000000ULL) >> 32) | flags)
  22. #else
  23. #define SPS_GET_UPPER_ADDR(addr) (0)
  24. #define DESC_FULL_ADDR(flags, addr) (addr)
  25. #define DESC_FLAG_WORD(flags, addr) (flags)
  26. #endif
  27. /* Returns upper 4bits of 36bits physical address from
  28. * flags word
  29. */
  30. #define DESC_UPPER_ADDR(flags) ((flags & 0xF))
  31. /* Returns lower 32bits of 36bits physical address */
  32. #define SPS_GET_LOWER_ADDR(addr) ((u32)(addr & 0xFFFFFFFF))
  33. /* SPS device handle indicating use of system memory */
  34. #define SPS_DEV_HANDLE_MEM (~0x0ul>>1)
  35. /* SPS device handle indicating use of BAM-DMA */
  36. /* SPS device handle invalid value */
  37. #define SPS_DEV_HANDLE_INVALID 0
  38. /* BAM invalid IRQ value */
  39. #define SPS_IRQ_INVALID 0
  40. /* Invalid address value */
  41. #define SPS_ADDR_INVALID (0xDEADBEEF)
  42. /* Invalid peripheral device enumeration class */
  43. #define SPS_CLASS_INVALID (0xDEADBEEF)
  44. /*
  45. * This value specifies different configurations for an SPS connection.
  46. * A non-default value instructs the SPS driver to search for the configuration
  47. * in the fixed connection mapping table.
  48. */
  49. #define SPS_CONFIG_DEFAULT 0
  50. /*
  51. * This value instructs the SPS driver to use the default BAM-DMA channel
  52. * threshold
  53. */
  54. #define SPS_DMA_THRESHOLD_DEFAULT 0
  55. /* Flag bits supported by SPS hardware for struct sps_iovec */
  56. #define SPS_IOVEC_FLAG_INT 0x8000 /* Generate interrupt */
  57. #define SPS_IOVEC_FLAG_EOT 0x4000 /* Generate end-of-transfer indication */
  58. #define SPS_IOVEC_FLAG_EOB 0x2000 /* Generate end-of-block indication */
  59. #define SPS_IOVEC_FLAG_NWD 0x1000 /* notify when done */
  60. #define SPS_IOVEC_FLAG_CMD 0x0800 /* command descriptor */
  61. #define SPS_IOVEC_FLAG_LOCK 0x0400 /* pipe lock */
  62. #define SPS_IOVEC_FLAG_UNLOCK 0x0200 /* pipe unlock */
  63. #define SPS_IOVEC_FLAG_IMME 0x0100 /* immediate command descriptor */
  64. #define SPS_IOVEC_FLAG_NO_SUBMIT 0x0020 /* Do not submit descriptor to HW */
  65. #define SPS_IOVEC_FLAG_DEFAULT 0x0010 /* Use driver default */
  66. /* Maximum descriptor/iovec size */
  67. #define SPS_IOVEC_MAX_SIZE (32 * 1024 - 1) /* 32K-1 bytes due to HW limit */
  68. /* BAM device options flags */
  69. /*
  70. * BAM will be configured and enabled at boot. Otherwise, BAM will be
  71. * configured and enabled when first pipe connect occurs.
  72. */
  73. #define SPS_BAM_OPT_ENABLE_AT_BOOT 1UL
  74. /* BAM IRQ is disabled */
  75. #define SPS_BAM_OPT_IRQ_DISABLED (1UL << 1)
  76. /* BAM peripheral is a BAM-DMA */
  77. #define SPS_BAM_OPT_BAMDMA (1UL << 2)
  78. /* BAM IRQ is registered for apps wakeup */
  79. #define SPS_BAM_OPT_IRQ_WAKEUP (1UL << 3)
  80. /* Ignore external block pipe reset */
  81. #define SPS_BAM_NO_EXT_P_RST (1UL << 4)
  82. /* Don't enable local clock gating */
  83. #define SPS_BAM_NO_LOCAL_CLK_GATING (1UL << 5)
  84. /* Don't enable writeback cancel*/
  85. #define SPS_BAM_CANCEL_WB (1UL << 6)
  86. /* BAM uses SMMU */
  87. #define SPS_BAM_SMMU_EN (1UL << 9)
  88. /* Confirm resource status before access BAM*/
  89. #define SPS_BAM_RES_CONFIRM (1UL << 7)
  90. /* Hold memory for BAM DMUX */
  91. #define SPS_BAM_HOLD_MEM (1UL << 8)
  92. /* Use cached write pointer */
  93. #define SPS_BAM_CACHED_WP (1UL << 10)
  94. /* BAM device management flags */
  95. /* BAM global device control is managed remotely */
  96. #define SPS_BAM_MGR_DEVICE_REMOTE 1UL
  97. /* BAM device supports multiple execution environments */
  98. #define SPS_BAM_MGR_MULTI_EE (1UL << 1)
  99. /* BAM pipes are *not* allocated locally */
  100. #define SPS_BAM_MGR_PIPE_NO_ALLOC (1UL << 2)
  101. /* BAM pipes are *not* configured locally */
  102. #define SPS_BAM_MGR_PIPE_NO_CONFIG (1UL << 3)
  103. /* BAM pipes are *not* controlled locally */
  104. #define SPS_BAM_MGR_PIPE_NO_CTRL (1UL << 4)
  105. /* "Globbed" management properties */
  106. #define SPS_BAM_MGR_NONE \
  107. (SPS_BAM_MGR_DEVICE_REMOTE | SPS_BAM_MGR_PIPE_NO_ALLOC | \
  108. SPS_BAM_MGR_PIPE_NO_CONFIG | SPS_BAM_MGR_PIPE_NO_CTRL)
  109. #define SPS_BAM_MGR_LOCAL 0
  110. #define SPS_BAM_MGR_LOCAL_SHARED SPS_BAM_MGR_MULTI_EE
  111. #define SPS_BAM_MGR_REMOTE_SHARED \
  112. (SPS_BAM_MGR_DEVICE_REMOTE | SPS_BAM_MGR_MULTI_EE | \
  113. SPS_BAM_MGR_PIPE_NO_ALLOC)
  114. #define SPS_BAM_MGR_ACCESS_MASK SPS_BAM_MGR_NONE
  115. /*
  116. * BAM security configuration
  117. */
  118. #define SPS_BAM_NUM_EES 4
  119. #define SPS_BAM_SEC_DO_NOT_CONFIG 0
  120. #define SPS_BAM_SEC_DO_CONFIG 0x0A434553
  121. /* BAM pipe selection */
  122. #define SPS_BAM_PIPE(n) (1UL << (n))
  123. /* This enum specifies the operational mode for an SPS connection */
  124. enum sps_mode {
  125. SPS_MODE_SRC = 0, /* end point is the source (producer) */
  126. SPS_MODE_DEST, /* end point is the destination (consumer) */
  127. };
  128. /*
  129. * This enum is a set of bit flag options for SPS connection.
  130. * The enums should be OR'd together to create the option set
  131. * for the SPS connection.
  132. */
  133. enum sps_option {
  134. /*
  135. * Options to enable specific SPS hardware interrupts.
  136. * These bit flags are also used to indicate interrupt source
  137. * for the SPS_EVENT_IRQ event.
  138. */
  139. SPS_O_DESC_DONE = 0x00000001, /* Descriptor processed */
  140. SPS_O_INACTIVE = 0x00000002, /* Inactivity timeout */
  141. SPS_O_WAKEUP = 0x00000004, /* Peripheral wake up */
  142. SPS_O_OUT_OF_DESC = 0x00000008,/* Out of descriptors */
  143. SPS_O_ERROR = 0x00000010, /* Error */
  144. SPS_O_EOT = 0x00000020, /* End-of-transfer */
  145. SPS_O_RST_ERROR = 0x00000040, /* Pipe reset unsucessful error */
  146. SPS_O_HRESP_ERROR = 0x00000080,/* Errorneous Hresponse by AHB MASTER */
  147. /* Options to enable hardware features */
  148. SPS_O_STREAMING = 0x00010000, /* Enable streaming mode (no EOT) */
  149. /* Use MTI/SETPEND instead of BAM interrupt */
  150. SPS_O_IRQ_MTI = 0x00020000,
  151. /* NWD bit written with EOT for BAM2BAM producer pipe */
  152. SPS_O_WRITE_NWD = 0x00040000,
  153. /* EOT set after pipe SW offset advanced */
  154. SPS_O_LATE_EOT = 0x00080000,
  155. /* Options to enable software features */
  156. /* Do not disable a pipe during disconnection */
  157. SPS_O_NO_DISABLE = 0x00800000,
  158. /* Transfer operation should be polled */
  159. SPS_O_POLL = 0x01000000,
  160. /* Disable queuing of transfer events for the connection end point */
  161. SPS_O_NO_Q = 0x02000000,
  162. SPS_O_FLOWOFF = 0x04000000, /* Graceful halt */
  163. /* SPS_O_WAKEUP will be disabled after triggered */
  164. SPS_O_WAKEUP_IS_ONESHOT = 0x08000000,
  165. /**
  166. * Client must read each descriptor from the FIFO
  167. * using sps_get_iovec()
  168. */
  169. SPS_O_ACK_TRANSFERS = 0x10000000,
  170. /* Connection is automatically enabled */
  171. SPS_O_AUTO_ENABLE = 0x20000000,
  172. /* DISABLE endpoint synchronization for config/enable/disable */
  173. SPS_O_NO_EP_SYNC = 0x40000000,
  174. /* Allow partial polling duing IRQ mode */
  175. SPS_O_HYBRID = 0x80000000,
  176. /* Allow dummy BAM connection */
  177. SPS_O_DUMMY_PEER = 0x00000400,
  178. };
  179. /**
  180. * This enum specifies BAM DMA channel priority. Clients should use
  181. * SPS_DMA_PRI_DEFAULT unless a specific priority is required.
  182. */
  183. enum sps_dma_priority {
  184. SPS_DMA_PRI_DEFAULT = 0,
  185. SPS_DMA_PRI_LOW,
  186. SPS_DMA_PRI_MED,
  187. SPS_DMA_PRI_HIGH,
  188. };
  189. /*
  190. * This enum specifies the ownership of a connection resource.
  191. * Remote or shared ownership is only possible/meaningful on the processor
  192. * that controls resource.
  193. */
  194. enum sps_owner {
  195. SPS_OWNER_LOCAL = 0x1, /* Resource is owned by local processor */
  196. SPS_OWNER_REMOTE = 0x2, /* Resource is owned by a satellite processor */
  197. };
  198. /* This enum indicates the event associated with a client event trigger */
  199. enum sps_event {
  200. SPS_EVENT_INVALID = 0,
  201. SPS_EVENT_EOT, /* End-of-transfer */
  202. SPS_EVENT_DESC_DONE, /* Descriptor processed */
  203. SPS_EVENT_OUT_OF_DESC, /* Out of descriptors */
  204. SPS_EVENT_WAKEUP, /* Peripheral wake up */
  205. SPS_EVENT_FLOWOFF, /* Graceful halt (idle) */
  206. SPS_EVENT_INACTIVE, /* Inactivity timeout */
  207. SPS_EVENT_ERROR, /* Error */
  208. SPS_EVENT_RST_ERROR, /* Pipe Reset unsuccessful */
  209. SPS_EVENT_HRESP_ERROR, /* Errorneous Hresponse by AHB Master*/
  210. SPS_EVENT_MAX,
  211. };
  212. /*
  213. * This enum specifies the event trigger mode and is an argument for the
  214. * sps_register_event() function.
  215. */
  216. enum sps_trigger {
  217. /* Trigger with payload for callback */
  218. SPS_TRIGGER_CALLBACK = 0,
  219. /* Trigger without payload for wait or poll */
  220. SPS_TRIGGER_WAIT,
  221. };
  222. /*
  223. * This enum indicates the desired halting mechanism and is an argument for the
  224. * sps_flow_off() function
  225. */
  226. enum sps_flow_off {
  227. SPS_FLOWOFF_FORCED = 0, /* Force hardware into halt state */
  228. /* Allow hardware to empty pipe before halting */
  229. SPS_FLOWOFF_GRACEFUL,
  230. };
  231. /*
  232. * This enum indicates the target memory heap and is an argument for the
  233. * sps_mem_alloc() function.
  234. */
  235. enum sps_mem {
  236. SPS_MEM_LOCAL = 0, /* SPS subsystem local (pipe) memory */
  237. SPS_MEM_UC, /* Microcontroller (ARM7) local memory */
  238. };
  239. /*
  240. * This enum indicates a timer control operation and is an argument for the
  241. * sps_timer_ctrl() function.
  242. */
  243. enum sps_timer_op {
  244. SPS_TIMER_OP_CONFIG = 0,
  245. SPS_TIMER_OP_RESET,
  246. /* SPS_TIMER_OP_START, Not supported by hardware yet */
  247. /* SPS_TIMER_OP_STOP, Not supported by hardware yet */
  248. SPS_TIMER_OP_READ,
  249. };
  250. /*
  251. * This enum indicates the inactivity timer operating mode and is an
  252. * argument for the sps_timer_ctrl() function.
  253. */
  254. enum sps_timer_mode {
  255. SPS_TIMER_MODE_ONESHOT = 0,
  256. /* SPS_TIMER_MODE_PERIODIC, Not supported by hardware yet */
  257. };
  258. /* This enum indicates the cases when callback the user of BAM */
  259. enum sps_callback_case {
  260. SPS_CALLBACK_BAM_ERROR_IRQ = 1, /* BAM ERROR IRQ */
  261. SPS_CALLBACK_BAM_HRESP_ERR_IRQ, /* Erroneous HResponse */
  262. SPS_CALLBACK_BAM_TIMER_IRQ, /* Inactivity timer */
  263. SPS_CALLBACK_BAM_RES_REQ, /* Request resource */
  264. SPS_CALLBACK_BAM_RES_REL, /* Release resource */
  265. SPS_CALLBACK_BAM_POLL, /* To poll each pipe */
  266. };
  267. /*
  268. * This enum indicates the command type in a command element
  269. */
  270. enum sps_command_type {
  271. SPS_WRITE_COMMAND = 0,
  272. SPS_READ_COMMAND,
  273. };
  274. /**
  275. * struct msm_sps_platform_data - SPS Platform specific data.
  276. * @bamdma_restricted_pipes - Bitmask of pipes restricted from local use.
  277. *
  278. */
  279. struct msm_sps_platform_data {
  280. u32 bamdma_restricted_pipes;
  281. };
  282. /**
  283. * This data type corresponds to the native I/O vector (BAM descriptor)
  284. * supported by SPS hardware
  285. *
  286. * @addr - Buffer physical address.
  287. * @size - Buffer size in bytes.
  288. * @flags -Flag bitmask (see SPS_IOVEC_FLAG_ #defines).
  289. *
  290. */
  291. struct sps_iovec {
  292. u32 addr;
  293. u32 size:16;
  294. u32 flags:16;
  295. };
  296. /**
  297. * This data type corresponds to the native Command Element
  298. * supported by SPS hardware
  299. *
  300. * @addr - register address.
  301. * @command - command type.
  302. * @data - for write command: content to be written into peripheral register.
  303. * for read command: dest addr to write peripheral register value to.
  304. * @mask - register mask.
  305. * @reserved - for future usage.
  306. *
  307. */
  308. struct sps_command_element {
  309. u32 addr:24;
  310. u32 command:8;
  311. u32 data;
  312. u32 mask;
  313. u32 reserved;
  314. };
  315. /*
  316. * BAM device's security configuration
  317. */
  318. struct sps_bam_pipe_sec_config_props {
  319. u32 pipe_mask;
  320. u32 vmid;
  321. };
  322. struct sps_bam_sec_config_props {
  323. /* Per-EE configuration - This is a pipe bit mask for each EE */
  324. struct sps_bam_pipe_sec_config_props ees[SPS_BAM_NUM_EES];
  325. };
  326. /**
  327. * This struct defines a BAM device. The client must memset() this struct to
  328. * zero before writing device information. A value of zero for uninitialized
  329. * values will instruct the SPS driver to use general defaults or
  330. * hardware/BIOS supplied values.
  331. *
  332. *
  333. * @options - See SPS_BAM_OPT_* bit flag.
  334. * @phys_addr - BAM base physical address (not peripheral address).
  335. * @virt_addr - BAM base virtual address.
  336. * @virt_size - For virtual mapping.
  337. * @irq - IRQ enum for use in ISR vector install.
  338. * @num_pipes - number of pipes. Can be read from hardware.
  339. * @summing_threshold - BAM event threshold.
  340. *
  341. * @periph_class - Peripheral device enumeration class.
  342. * @periph_dev_id - Peripheral global device ID.
  343. * @periph_phys_addr - Peripheral base physical address, for BAM-DMA only.
  344. * @periph_virt_addr - Peripheral base virtual address.
  345. * @periph_virt_size - Size for virtual mapping.
  346. *
  347. * @callback - callback function for BAM user.
  348. * @user - pointer to user data.
  349. *
  350. * @event_threshold - Pipe event threshold.
  351. * @desc_size - Size (bytes) of descriptor FIFO.
  352. * @data_size - Size (bytes) of data FIFO.
  353. * @desc_mem_id - Heap ID for default descriptor FIFO allocations.
  354. * @data_mem_id - Heap ID for default data FIFO allocations.
  355. *
  356. * @manage - BAM device management flags (see SPS_BAM_MGR_*).
  357. * @restricted_pipes - Bitmask of pipes restricted from local use.
  358. * @ee - Local execution environment index.
  359. *
  360. * @irq_gen_addr - MTI interrupt generation address. This configuration only
  361. * applies to BAM rev 1 and 2 hardware. MTIs are only supported on BAMs when
  362. * global config is controlled by a remote processor.
  363. * NOTE: This address must correspond to the MTI associated with the "irq" IRQ
  364. * enum specified above.
  365. *
  366. * @sec_config - must be set to SPS_BAM_SEC_DO_CONFIG to perform BAM security
  367. * configuration. Only the processor that manages the BAM is allowed to
  368. * perform the configuration. The global (top-level) BAM interrupt will be
  369. * assigned to the EE of the processor that manages the BAM.
  370. *
  371. * @p_sec_config_props - BAM device's security configuration
  372. *
  373. */
  374. struct sps_bam_props {
  375. /* BAM device properties. */
  376. u32 options;
  377. phys_addr_t phys_addr;
  378. void __iomem *virt_addr;
  379. u32 virt_size;
  380. u32 irq;
  381. u32 num_pipes;
  382. u32 summing_threshold;
  383. /* Peripheral device properties */
  384. u32 periph_class;
  385. u32 periph_dev_id;
  386. phys_addr_t periph_phys_addr;
  387. void *periph_virt_addr;
  388. u32 periph_virt_size;
  389. /* Connection pipe parameter defaults. */
  390. u32 event_threshold;
  391. u32 desc_size;
  392. u32 data_size;
  393. u32 desc_mem_id;
  394. u32 data_mem_id;
  395. /* Feedback to BAM user */
  396. void (*callback)(enum sps_callback_case, void *user);
  397. void *user;
  398. /* Security properties */
  399. u32 manage;
  400. u32 restricted_pipes;
  401. u32 ee;
  402. /* Log Level property */
  403. u32 ipc_loglevel;
  404. /* BAM MTI interrupt generation */
  405. u32 irq_gen_addr;
  406. /* Security configuration properties */
  407. u32 sec_config;
  408. struct sps_bam_sec_config_props *p_sec_config_props;
  409. /* Logging control */
  410. bool constrained_logging;
  411. u32 logging_number;
  412. };
  413. /**
  414. * This struct specifies memory buffer properties.
  415. *
  416. * @base - Buffer virtual address.
  417. * @phys_base - Buffer physical address.
  418. * @size - Specifies buffer size (or maximum size).
  419. * @min_size - If non-zero, specifies buffer minimum size.
  420. *
  421. */
  422. struct sps_mem_buffer {
  423. void *base;
  424. phys_addr_t phys_base;
  425. unsigned long iova;
  426. u32 size;
  427. u32 min_size;
  428. };
  429. /**
  430. * This struct defines a connection's end point and is used as the argument
  431. * for the sps_connect(), sps_get_config(), and sps_set_config() functions.
  432. * For system mode pipe, use SPS_DEV_HANDLE_MEM for the end point that
  433. * corresponds to system memory.
  434. *
  435. * The client can force SPS to reserve a specific pipe on a BAM.
  436. * If the pipe is in use, the sps_connect/set_config() will fail.
  437. *
  438. * @source - Source BAM.
  439. * @src_pipe_index - BAM pipe index, 0 to 30.
  440. * @destination - Destination BAM.
  441. * @dest_pipe_index - BAM pipe index, 0 to 30.
  442. *
  443. * @mode - specifies which end (source or destination) of the connection will
  444. * be controlled/referenced by the client.
  445. *
  446. * @config - This value is for future use and should be set to
  447. * SPS_CONFIG_DEFAULT or left as default from sps_get_config().
  448. *
  449. * @options - OR'd connection end point options (see SPS_O defines).
  450. *
  451. * WARNING: The memory provided should be physically contiguous and non-cached.
  452. * The user can use one of the following:
  453. * 1. sps_alloc_mem() - allocated from pipe-memory.
  454. * 2. dma_alloc_coherent() - allocate coherent DMA memory.
  455. * 3. dma_map_single() - for using memory allocated by kmalloc().
  456. *
  457. * @desc - Descriptor FIFO.
  458. * @data - Data FIFO (BAM-to-BAM mode only).
  459. *
  460. * @event_thresh - Pipe event threshold or derivative.
  461. * @lock_group - The lock group this pipe belongs to.
  462. *
  463. * @sps_reserved - Reserved word - client must not modify.
  464. *
  465. */
  466. struct sps_connect {
  467. unsigned long source;
  468. unsigned long source_iova;
  469. u32 src_pipe_index;
  470. unsigned long destination;
  471. unsigned long dest_iova;
  472. u32 dest_pipe_index;
  473. enum sps_mode mode;
  474. u32 config;
  475. enum sps_option options;
  476. struct sps_mem_buffer desc;
  477. struct sps_mem_buffer data;
  478. u32 event_thresh;
  479. u32 lock_group;
  480. /* SETPEND/MTI interrupt generation parameters */
  481. u32 irq_gen_addr;
  482. u32 irq_gen_data;
  483. u32 sps_reserved;
  484. };
  485. /**
  486. * This struct defines a satellite connection's end point. The client of the
  487. * SPS driver on the satellite processor must call sps_get_config() to
  488. * initialize a struct sps_connect, then copy the values from the struct
  489. * sps_satellite to the struct sps_connect before making the sps_connect()
  490. * call to the satellite SPS driver.
  491. *
  492. */
  493. struct sps_satellite {
  494. /**
  495. * These values must be copied to either the source or destination
  496. * corresponding values in the connect struct.
  497. */
  498. phys_addr_t dev;
  499. u32 pipe_index;
  500. /**
  501. * These values must be copied to the corresponding values in the
  502. * connect struct
  503. */
  504. u32 config;
  505. enum sps_option options;
  506. };
  507. /**
  508. * This struct defines parameters for allocation of a BAM DMA channel. The
  509. * client must memset() this struct to zero before writing allocation
  510. * information. A value of zero for uninitialized values will instruct
  511. * the SPS driver to use defaults or "don't care".
  512. *
  513. * @dev - Associated BAM device handle, or SPS_DEV_HANDLE_DMA.
  514. *
  515. * @src_owner - Source owner processor ID.
  516. * @dest_owner - Destination owner processor ID.
  517. *
  518. */
  519. struct sps_alloc_dma_chan {
  520. unsigned long dev;
  521. /* BAM DMA channel configuration parameters */
  522. u32 threshold;
  523. enum sps_dma_priority priority;
  524. /**
  525. * Owner IDs are global host processor identifiers used by the system
  526. * SROT when establishing execution environments.
  527. */
  528. u32 src_owner;
  529. u32 dest_owner;
  530. };
  531. /**
  532. * This struct defines parameters for an allocated BAM DMA channel.
  533. *
  534. * @dev - BAM DMA device handle.
  535. * @dest_pipe_index - Destination/input/write pipe index.
  536. * @src_pipe_index - Source/output/read pipe index.
  537. *
  538. */
  539. struct sps_dma_chan {
  540. unsigned long dev;
  541. u32 dest_pipe_index;
  542. u32 src_pipe_index;
  543. };
  544. /**
  545. * This struct is an argument passed payload when triggering a callback event
  546. * object registered for an SPS connection end point.
  547. *
  548. * @user - Pointer registered with sps_register_event().
  549. *
  550. * @event_id - Which event.
  551. *
  552. * @iovec - The associated I/O vector. If the end point is a system-mode
  553. * producer, the size will reflect the actual number of bytes written to the
  554. * buffer by the pipe. NOTE: If this I/O vector was part of a set submitted to
  555. * sps_transfer(), then the vector array itself will be updated with all of
  556. * the actual counts.
  557. *
  558. * @user - Pointer registered with the transfer.
  559. *
  560. */
  561. struct sps_event_notify {
  562. void *user;
  563. enum sps_event event_id;
  564. /* Data associated with the event */
  565. union {
  566. /* Data for SPS_EVENT_IRQ */
  567. struct {
  568. u32 mask;
  569. } irq;
  570. /* Data for SPS_EVENT_EOT or SPS_EVENT_DESC_DONE */
  571. struct {
  572. struct sps_iovec iovec;
  573. void *user;
  574. } transfer;
  575. /* Data for SPS_EVENT_ERROR */
  576. struct {
  577. u32 status;
  578. } err;
  579. } data;
  580. };
  581. /**
  582. * This struct defines a event registration parameters and is used as the
  583. * argument for the sps_register_event() function.
  584. *
  585. * @options - Event options that will trigger the event object.
  586. * @mode - Event trigger mode.
  587. *
  588. * @xfer_done - a pointer to a completion object. NULL if not in use.
  589. *
  590. * @callback - a callback to call on completion. NULL if not in use.
  591. *
  592. * @user - User pointer that will be provided in event callback data.
  593. *
  594. */
  595. struct sps_register_event {
  596. enum sps_option options;
  597. enum sps_trigger mode;
  598. struct completion *xfer_done;
  599. void (*callback)(struct sps_event_notify *notify);
  600. void *user;
  601. };
  602. /**
  603. * This struct defines a system memory transfer's parameters and is used as the
  604. * argument for the sps_transfer() function.
  605. *
  606. * @iovec_phys - Physical address of I/O vectors buffer.
  607. * @iovec - Pointer to I/O vectors buffer.
  608. * @iovec_count - Number of I/O vectors.
  609. * @user - User pointer passed in callback event.
  610. *
  611. */
  612. struct sps_transfer {
  613. phys_addr_t iovec_phys;
  614. struct sps_iovec *iovec;
  615. u32 iovec_count;
  616. void *user;
  617. };
  618. /**
  619. * This struct defines a timer control operation parameters and is used as an
  620. * argument for the sps_timer_ctrl() function.
  621. *
  622. * @op - Timer control operation.
  623. * @timeout_msec - Inactivity timeout (msec).
  624. *
  625. */
  626. struct sps_timer_ctrl {
  627. enum sps_timer_op op;
  628. /**
  629. * The following configuration parameters must be set when the timer
  630. * control operation is SPS_TIMER_OP_CONFIG.
  631. */
  632. enum sps_timer_mode mode;
  633. u32 timeout_msec;
  634. };
  635. /**
  636. * This struct defines a timer control operation result and is used as an
  637. * argument for the sps_timer_ctrl() function.
  638. */
  639. struct sps_timer_result {
  640. u32 current_timer;
  641. };
  642. /*----------------------------------------------------------------------------
  643. * Functions specific to sps interface
  644. * ---------------------------------------------------------------------------
  645. */
  646. struct sps_pipe; /* Forward declaration */
  647. #if IS_ENABLED(CONFIG_SPS)
  648. /**
  649. * Register a BAM device
  650. *
  651. * This function registers a BAM device with the SPS driver. For each
  652. *peripheral that includes a BAM, the peripheral driver must register
  653. * the BAM with the SPS driver.
  654. *
  655. * A requirement is that the peripheral driver must remain attached
  656. * to the SPS driver until the BAM is deregistered. Otherwise, the
  657. * system may attempt to unload the SPS driver. BAM registrations would
  658. * be lost.
  659. *
  660. * @bam_props - Pointer to struct for BAM device properties.
  661. *
  662. * @dev_handle - Device handle will be written to this location (output).
  663. *
  664. * @return 0 on success, negative value on error
  665. *
  666. */
  667. int sps_register_bam_device(const struct sps_bam_props *bam_props,
  668. unsigned long *dev_handle);
  669. /**
  670. * Deregister a BAM device
  671. *
  672. * This function deregisters a BAM device from the SPS driver. The peripheral
  673. * driver should deregister a BAM when the peripheral driver is shut down or
  674. * when BAM use should be disabled.
  675. *
  676. * A BAM cannot be deregistered if any of its pipes is in an active connection.
  677. *
  678. * When all BAMs have been deregistered, the system is free to unload the
  679. * SPS driver.
  680. *
  681. * @dev_handle - BAM device handle.
  682. *
  683. * @return 0 on success, negative value on error
  684. *
  685. */
  686. int sps_deregister_bam_device(unsigned long dev_handle);
  687. /**
  688. * Allocate client state context
  689. *
  690. * This function allocate and initializes a client state context struct.
  691. *
  692. * @return pointer to client state context
  693. *
  694. */
  695. struct sps_pipe *sps_alloc_endpoint(void);
  696. /**
  697. * Free client state context
  698. *
  699. * This function de-initializes and free a client state context struct.
  700. *
  701. * @ctx - client context for SPS connection end point
  702. *
  703. * @return 0 on success, negative value on error
  704. *
  705. */
  706. int sps_free_endpoint(struct sps_pipe *h);
  707. /**
  708. * Get the configuration parameters for an SPS connection end point
  709. *
  710. * This function retrieves the configuration parameters for an SPS connection
  711. * end point.
  712. * This function may be called before the end point is connected (before
  713. * sps_connect is called). This allows the client to specify parameters before
  714. * the connection is established.
  715. *
  716. * The client must call this function to fill it's struct sps_connect
  717. * struct before modifying values and passing the struct to sps_set_config().
  718. *
  719. * @h - client context for SPS connection end point
  720. *
  721. * @config - Pointer to buffer for the end point's configuration parameters.
  722. * Must not be NULL.
  723. *
  724. * @return 0 on success, negative value on error
  725. *
  726. */
  727. int sps_get_config(struct sps_pipe *h, struct sps_connect *config);
  728. /**
  729. * Allocate memory from the SPS Pipe-Memory.
  730. *
  731. * @h - client context for SPS connection end point
  732. *
  733. * @mem - memory type - N/A.
  734. *
  735. * @mem_buffer - Pointer to struct for allocated memory properties.
  736. *
  737. * @return 0 on success, negative value on error
  738. *
  739. */
  740. int sps_alloc_mem(struct sps_pipe *h, enum sps_mem mem,
  741. struct sps_mem_buffer *mem_buffer);
  742. /**
  743. * Free memory from the SPS Pipe-Memory.
  744. *
  745. * @h - client context for SPS connection end point
  746. *
  747. * @mem_buffer - Pointer to struct for allocated memory properties.
  748. *
  749. * @return 0 on success, negative value on error
  750. *
  751. */
  752. int sps_free_mem(struct sps_pipe *h, struct sps_mem_buffer *mem_buffer);
  753. /**
  754. * Connect an SPS connection end point
  755. *
  756. * This function creates a connection between two SPS peripherals or between
  757. * an SPS peripheral and the local host processor (via system memory, end
  758. *point SPS_DEV_HANDLE_MEM). Establishing the connection includes
  759. * initialization of the SPS hardware and allocation of any other connection
  760. * resources (buffer memory, etc.).
  761. *
  762. * This function requires the client to specify both the source and
  763. * destination end points of the SPS connection. However, the handle
  764. * returned applies only to the end point of the connection that the client
  765. * controls. The end point under control must be specified by the
  766. * enum sps_mode mode argument, either SPS_MODE_SRC, SPS_MODE_DEST, or
  767. * SPS_MODE_CTL. Note that SPS_MODE_CTL is only supported for I/O
  768. * accelerator connections, and only a limited set of control operations are
  769. * allowed (TBD).
  770. *
  771. * For a connection involving system memory
  772. * (SPS_DEV_HANDLE_MEM), the peripheral end point must be
  773. * specified. For example, SPS_MODE_SRC must be specified for a
  774. * BAM-to-system connection, since the BAM pipe is the data
  775. * producer.
  776. *
  777. * For a specific peripheral-to-peripheral connection, there may be more than
  778. * one required configuration. For example, there might be high-performance
  779. * and low-power configurations for a connection between the two peripherals.
  780. * The config argument allows the client to specify different configurations,
  781. * which may require different system resource allocations and hardware
  782. * initialization.
  783. *
  784. * A client is allowed to create one and only one connection for its
  785. * struct sps_pipe. The handle is used to identify the connection end point
  786. * in subsequent SPS driver calls. A specific connection source or
  787. * destination end point can be associated with one and only one
  788. * struct sps_pipe.
  789. *
  790. * The client must establish an open device handle to the SPS. To do so, the
  791. * client must attach to the SPS driver and open the SPS device by calling
  792. * the following functions.
  793. *
  794. * @h - client context for SPS connection end point
  795. *
  796. * @connect - Pointer to connection parameters
  797. *
  798. * @return 0 on success, negative value on error
  799. *
  800. */
  801. int sps_connect(struct sps_pipe *h, struct sps_connect *connect);
  802. /**
  803. * Disconnect an SPS connection end point
  804. *
  805. * This function disconnects an SPS connection end point.
  806. * The SPS hardware associated with that end point will be disabled.
  807. * For a connection involving system memory (SPS_DEV_HANDLE_MEM), all
  808. * connection resources are deallocated. For a peripheral-to-peripheral
  809. * connection, the resources associated with the connection will not be
  810. * deallocated until both end points are closed.
  811. *
  812. * The client must call sps_connect() for the handle before calling
  813. * this function.
  814. *
  815. * @h - client context for SPS connection end point
  816. *
  817. * @return 0 on success, negative value on error
  818. *
  819. */
  820. int sps_disconnect(struct sps_pipe *h);
  821. /**
  822. * Register an event object for an SPS connection end point
  823. *
  824. * This function registers a callback event object for an SPS connection end
  825. *point. The registered event object will be triggered for the set of
  826. * events specified in reg->options that are enabled for the end point.
  827. *
  828. * There can only be one registered event object for each event. If an event
  829. * object is already registered for an event, it will be replaced. If
  830. *reg->event handle is NULL, then any registered event object for the
  831. * event will be deregistered. Option bits in reg->options not associated
  832. * with events are ignored.
  833. *
  834. * The client must call sps_connect() for the handle before calling
  835. * this function.
  836. *
  837. * @h - client context for SPS connection end point
  838. *
  839. * @reg - Pointer to event registration parameters
  840. *
  841. * @return 0 on success, negative value on error
  842. *
  843. */
  844. int sps_register_event(struct sps_pipe *h, struct sps_register_event *reg);
  845. /**
  846. * Perform a single DMA transfer on an SPS connection end point
  847. *
  848. * This function submits a DMA transfer request consisting of a single buffer
  849. * for an SPS connection end point associated with a peripheral-to/from-memory
  850. * connection. The request will be submitted immediately to hardware if the
  851. * hardware is idle (data flow off, no other pending transfers). Otherwise, it
  852. * will be queued for later handling in the SPS driver work loop.
  853. *
  854. * The data buffer must be DMA ready. The client is responsible for insuring
  855. *physically contiguous memory, cache maintenance, and memory barrier. For
  856. * more information, see Appendix A.
  857. *
  858. * The client must not modify the data buffer until the completion indication is
  859. * received.
  860. *
  861. * This function cannot be used if transfer queuing is disabled (see option
  862. * SPS_O_NO_Q). The client must set the SPS_O_EOT option to receive a callback
  863. * event trigger when the transfer is complete. The SPS driver will insure the
  864. * appropriate flags in the I/O vectors are set to generate the completion
  865. * indication.
  866. *
  867. * The return value from this function may indicate that an error occurred.
  868. * Possible causes include invalid arguments.
  869. *
  870. * @h - client context for SPS connection end point
  871. *
  872. * @addr - Physical address of buffer to transfer.
  873. *
  874. * WARNING: The memory provided should be physically contiguous and
  875. * non-cached.
  876. *
  877. * The user can use one of the following:
  878. * 1. sps_alloc_mem() - allocated from pipe-memory.
  879. * 2. dma_alloc_coherent() - allocate DMA memory.
  880. * 3. dma_map_single() for memory allocated by kmalloc().
  881. *
  882. * @size - Size in bytes of buffer to transfer
  883. *
  884. * @user - User pointer that will be returned to user as part of
  885. * event payload
  886. *
  887. * @return 0 on success, negative value on error
  888. *
  889. */
  890. int sps_transfer_one(struct sps_pipe *h, phys_addr_t addr, u32 size,
  891. void *user, u32 flags);
  892. /**
  893. * Read event queue for an SPS connection end point
  894. *
  895. * This function reads event queue for an SPS connection end point.
  896. *
  897. * @h - client context for SPS connection end point
  898. *
  899. * @event - pointer to client's event data buffer
  900. *
  901. * @return 0 on success, negative value on error
  902. *
  903. */
  904. int sps_get_event(struct sps_pipe *h, struct sps_event_notify *event);
  905. /**
  906. * Get processed I/O vector (completed transfers)
  907. *
  908. * This function fetches the next processed I/O vector.
  909. *
  910. * @h - client context for SPS connection end point
  911. *
  912. * @iovec - Pointer to I/O vector struct (output).
  913. * This struct will be zeroed if there are no more processed I/O vectors.
  914. *
  915. * @return 0 on success, negative value on error
  916. *
  917. */
  918. int sps_get_iovec(struct sps_pipe *h, struct sps_iovec *iovec);
  919. /**
  920. * Enable an SPS connection end point
  921. *
  922. * This function enables an SPS connection end point.
  923. *
  924. * @h - client context for SPS connection end point
  925. *
  926. * @return 0 on success, negative value on error
  927. *
  928. */
  929. int sps_flow_on(struct sps_pipe *h);
  930. /**
  931. * Disable an SPS connection end point
  932. *
  933. * This function disables an SPS connection end point.
  934. *
  935. * @h - client context for SPS connection end point
  936. *
  937. * @mode - Desired mode for disabling pipe data flow
  938. *
  939. * @return 0 on success, negative value on error
  940. *
  941. */
  942. int sps_flow_off(struct sps_pipe *h, enum sps_flow_off mode);
  943. /**
  944. * Perform a Multiple DMA transfer on an SPS connection end point
  945. *
  946. * This function submits a DMA transfer request for an SPS connection end point
  947. * associated with a peripheral-to/from-memory connection. The request will be
  948. * submitted immediately to hardware if the hardware is idle (data flow off, no
  949. * other pending transfers). Otherwise, it will be queued for later handling in
  950. * the SPS driver work loop.
  951. *
  952. * The data buffers referenced by the I/O vectors must be DMA ready.
  953. * The client is responsible for insuring physically contiguous memory,
  954. * any cache maintenance, and memory barrier. For more information,
  955. * see Appendix A.
  956. *
  957. * The I/O vectors must specify physical addresses for the referenced buffers.
  958. *
  959. * The client must not modify the data buffers referenced by I/O vectors until
  960. * the completion indication is received.
  961. *
  962. * If transfer queuing is disabled (see option SPS_O_NO_Q), the client is
  963. * responsible for setting the appropriate flags in the I/O vectors to generate
  964. * the completion indication. Also, the client is responsible for enabling the
  965. * appropriate connection callback event options for completion indication (see
  966. * sps_connect(), sps_set_config()).
  967. *
  968. * If transfer queuing is enabled, the client must set the SPS_O_EOT option to
  969. * receive a callback event trigger when the transfer is complete. The SPS
  970. * driver will insure the appropriate flags in the I/O vectors are set to
  971. * generate the completion indication. The client must not set any flags in the
  972. * I/O vectors, as this may cause the SPS driver to become out of sync with the
  973. * hardware.
  974. *
  975. * The return value from this function may indicate that an error occurred.
  976. * Possible causes include invalid arguments. If transfer queuing is disabled,
  977. * an error will occur if the pipe is already processing a transfer.
  978. *
  979. * @h - client context for SPS connection end point
  980. *
  981. * @transfer - Pointer to transfer parameter struct
  982. *
  983. * @return 0 on success, negative value on error
  984. *
  985. */
  986. int sps_transfer(struct sps_pipe *h, struct sps_transfer *transfer);
  987. /**
  988. * Determine whether an SPS connection end point FIFO is empty
  989. *
  990. * This function returns the empty state of an SPS connection end point.
  991. *
  992. * @h - client context for SPS connection end point
  993. *
  994. * @empty - pointer to client's empty status word (boolean)
  995. *
  996. * @return 0 on success, negative value on error
  997. *
  998. */
  999. int sps_is_pipe_empty(struct sps_pipe *h, u32 *empty);
  1000. /**
  1001. * Reset an SPS BAM device
  1002. *
  1003. * This function resets an SPS BAM device.
  1004. *
  1005. * @dev - device handle for the BAM
  1006. *
  1007. * @return 0 on success, negative value on error
  1008. *
  1009. */
  1010. int sps_device_reset(unsigned long dev);
  1011. /**
  1012. * Set the configuration parameters for an SPS connection end point
  1013. *
  1014. * This function sets the configuration parameters for an SPS connection
  1015. * end point. This function may be called before the end point is connected
  1016. * (before sps_connect is called). This allows the client to specify
  1017. *parameters before the connection is established. The client is allowed
  1018. * to pre-allocate resources and override driver defaults.
  1019. *
  1020. * The client must call sps_get_config() to fill it's struct sps_connect
  1021. * struct before modifying values and passing the struct to this function.
  1022. * Only those parameters that differ from the current configuration will
  1023. * be processed.
  1024. *
  1025. * @h - client context for SPS connection end point
  1026. *
  1027. * @config - Pointer to the end point's new configuration parameters.
  1028. *
  1029. * @return 0 on success, negative value on error
  1030. *
  1031. */
  1032. int sps_set_config(struct sps_pipe *h, struct sps_connect *config);
  1033. /**
  1034. * Set ownership of an SPS connection end point
  1035. *
  1036. * This function sets the ownership of an SPS connection end point to
  1037. * either local (default) or non-local. This function is used to
  1038. * retrieve the struct sps_connect data that must be used by a
  1039. * satellite processor when calling sps_connect().
  1040. *
  1041. * Non-local ownership is only possible/meaningful on the processor
  1042. * that controls resource allocations (apps processor). Setting ownership
  1043. * to non-local on a satellite processor will fail.
  1044. *
  1045. * Setting ownership from non-local to local will succeed only if the
  1046. * owning satellite processor has properly brought the end point to
  1047. * an idle condition.
  1048. *
  1049. * This function will succeed if the connection end point is already in
  1050. * the specified ownership state.
  1051. *
  1052. * @h - client context for SPS connection end point
  1053. *
  1054. * @owner - New ownership of the connection end point
  1055. *
  1056. * @connect - Pointer to buffer for satellite processor connect data.
  1057. * Can be NULL to avoid retrieving the connect data. Will be ignored
  1058. * if the end point ownership is set to local.
  1059. *
  1060. * @return 0 on success, negative value on error
  1061. *
  1062. */
  1063. int sps_set_owner(struct sps_pipe *h, enum sps_owner owner,
  1064. struct sps_satellite *connect);
  1065. #ifdef CONFIG_SPS_SUPPORT_BAMDMA
  1066. /**
  1067. * Allocate a BAM DMA channel
  1068. *
  1069. * This function allocates a BAM DMA channel. A "BAM DMA" is a special
  1070. * DMA peripheral with a BAM front end. The DMA peripheral acts as a conduit
  1071. * for data to flow into a consumer pipe and then out of a producer pipe.
  1072. * It's primarily purpose is to serve as a path for interprocessor communication
  1073. * that allows each processor to control and protect it's own memory space.
  1074. *
  1075. * @alloc - Pointer to struct for BAM DMA channel allocation properties.
  1076. *
  1077. * @chan - Allocated channel information will be written to this
  1078. * location (output).
  1079. *
  1080. * @return 0 on success, negative value on error
  1081. *
  1082. */
  1083. int sps_alloc_dma_chan(const struct sps_alloc_dma_chan *alloc,
  1084. struct sps_dma_chan *chan);
  1085. /**
  1086. * Free a BAM DMA channel
  1087. *
  1088. * This function frees a BAM DMA channel.
  1089. *
  1090. * @chan - Pointer to information for channel to free
  1091. *
  1092. * @return 0 on success, negative value on error
  1093. *
  1094. */
  1095. int sps_free_dma_chan(struct sps_dma_chan *chan);
  1096. /**
  1097. * Get the BAM handle for BAM-DMA.
  1098. *
  1099. * The BAM handle should be use as source/destination in the sps_connect().
  1100. *
  1101. * @return handle on success, zero on error
  1102. *
  1103. */
  1104. unsigned long sps_dma_get_bam_handle(void);
  1105. /**
  1106. * Free the BAM handle for BAM-DMA.
  1107. *
  1108. */
  1109. void sps_dma_free_bam_handle(unsigned long h);
  1110. #else
  1111. static inline int sps_alloc_dma_chan(const struct sps_alloc_dma_chan *alloc,
  1112. struct sps_dma_chan *chan)
  1113. {
  1114. return -EPERM;
  1115. }
  1116. static inline int sps_free_dma_chan(struct sps_dma_chan *chan)
  1117. {
  1118. return -EPERM;
  1119. }
  1120. static inline unsigned long sps_dma_get_bam_handle(void)
  1121. {
  1122. return 0;
  1123. }
  1124. static inline void sps_dma_free_bam_handle(unsigned long h)
  1125. {
  1126. }
  1127. #endif
  1128. /**
  1129. * Get number of free transfer entries for an SPS connection end point
  1130. *
  1131. * This function returns the number of free transfer entries for an
  1132. * SPS connection end point.
  1133. *
  1134. * @h - client context for SPS connection end point
  1135. *
  1136. * @count - pointer to count status
  1137. *
  1138. * @return 0 on success, negative value on error
  1139. *
  1140. */
  1141. int sps_get_free_count(struct sps_pipe *h, u32 *count);
  1142. /**
  1143. * Perform timer control
  1144. *
  1145. * This function performs timer control operations.
  1146. *
  1147. * @h - client context for SPS connection end point
  1148. *
  1149. * @timer_ctrl - Pointer to timer control specification
  1150. *
  1151. * @timer_result - Pointer to buffer for timer operation result.
  1152. * This argument can be NULL if no result is expected for the operation.
  1153. * If non-NULL, the current timer value will always provided.
  1154. *
  1155. * @return 0 on success, negative value on error
  1156. *
  1157. */
  1158. int sps_timer_ctrl(struct sps_pipe *h,
  1159. struct sps_timer_ctrl *timer_ctrl,
  1160. struct sps_timer_result *timer_result);
  1161. /**
  1162. * Find the handle of a BAM device based on the physical address
  1163. *
  1164. * This function finds a BAM device in the BAM registration list that
  1165. * matches the specified physical address, and returns its handle.
  1166. *
  1167. * @phys_addr - physical address of the BAM
  1168. *
  1169. * @h - device handle of the BAM
  1170. *
  1171. * @return 0 on success, negative value on error
  1172. *
  1173. */
  1174. int sps_phy2h(phys_addr_t phys_addr, unsigned long *handle);
  1175. /**
  1176. * Setup desc/data FIFO for bam-to-bam connection
  1177. *
  1178. * @mem_buffer - Pointer to struct for allocated memory properties.
  1179. *
  1180. * @addr - address of FIFO
  1181. *
  1182. * @size - FIFO size
  1183. *
  1184. * @use_offset - use address offset instead of absolute address
  1185. *
  1186. * @return 0 on success, negative value on error
  1187. *
  1188. */
  1189. int sps_setup_bam2bam_fifo(struct sps_mem_buffer *mem_buffer,
  1190. u32 addr, u32 size, int use_offset);
  1191. /**
  1192. * Get the number of unused descriptors in the descriptor FIFO
  1193. * of a pipe
  1194. *
  1195. * @h - client context for SPS connection end point
  1196. *
  1197. * @desc_num - number of unused descriptors
  1198. *
  1199. * @return 0 on success, negative value on error
  1200. *
  1201. */
  1202. int sps_get_unused_desc_num(struct sps_pipe *h, u32 *desc_num);
  1203. /**
  1204. * Get the debug info of BAM registers and descriptor FIFOs
  1205. *
  1206. * @dev - BAM device handle
  1207. *
  1208. * @option - debugging option
  1209. *
  1210. * @para - parameter used for an option (such as pipe combination)
  1211. *
  1212. * @tb_sel - testbus selection
  1213. *
  1214. * @desc_sel - selection of descriptors
  1215. *
  1216. * @return 0 on success, negative value on error
  1217. *
  1218. */
  1219. int sps_get_bam_debug_info(unsigned long dev, u32 option, u32 para,
  1220. u32 tb_sel, u32 desc_sel);
  1221. /**
  1222. * Vote for or relinquish BAM DMA clock
  1223. *
  1224. * @clk_on - to turn on or turn off the clock
  1225. *
  1226. * @return 0 on success, negative value on error
  1227. *
  1228. */
  1229. int sps_ctrl_bam_dma_clk(bool clk_on);
  1230. /*
  1231. * sps_pipe_reset - reset a pipe of a BAM.
  1232. * @dev: BAM device handle
  1233. * @pipe: pipe index
  1234. *
  1235. * This function resets a pipe of a BAM.
  1236. *
  1237. * Return: 0 on success, negative value on error
  1238. */
  1239. int sps_pipe_reset(unsigned long dev, u32 pipe);
  1240. /*
  1241. * sps_pipe_disable - disable a pipe of a BAM.
  1242. * @dev: BAM device handle
  1243. * @pipe: pipe index
  1244. *
  1245. * This function disables a pipe of a BAM.
  1246. *
  1247. * Return: 0 on success, negative value on error
  1248. */
  1249. int sps_pipe_disable(unsigned long dev, u32 pipe);
  1250. /*
  1251. * sps_pipe_pending_desc - checking pending descriptor.
  1252. * @dev: BAM device handle
  1253. * @pipe: pipe index
  1254. * @pending: indicate if there is any pending descriptor.
  1255. *
  1256. * This function checks if a pipe of a BAM has any pending descriptor.
  1257. *
  1258. * Return: 0 on success, negative value on error
  1259. */
  1260. int sps_pipe_pending_desc(unsigned long dev, u32 pipe, bool *pending);
  1261. /*
  1262. * sps_bam_process_irq - process IRQ of a BAM.
  1263. * @dev: BAM device handle
  1264. *
  1265. * This function processes any pending IRQ of a BAM.
  1266. *
  1267. * Return: 0 on success, negative value on error
  1268. */
  1269. int sps_bam_process_irq(unsigned long dev);
  1270. /*
  1271. * sps_bam_enable_irqs - enable IRQs of a BAM.
  1272. * @dev: BAM device handle
  1273. *
  1274. * This function enables all IRQs of a BAM.
  1275. *
  1276. * Return: 0 on success, negative value on error
  1277. */
  1278. int sps_bam_enable_irqs(unsigned long dev);
  1279. /*
  1280. * sps_bam_disable_irqs - disable IRQs of a BAM.
  1281. * @dev: BAM device handle
  1282. *
  1283. * This function disables all IRQs of a BAM.
  1284. *
  1285. * Return: 0 on success, negative value on error
  1286. */
  1287. int sps_bam_disable_irqs(unsigned long dev);
  1288. /*
  1289. * sps_get_bam_addr - get address info of a BAM.
  1290. * @dev: BAM device handle
  1291. * @base: beginning address
  1292. * @size: address range size
  1293. *
  1294. * This function returns the address info of a BAM.
  1295. *
  1296. * Return: 0 on success, negative value on error
  1297. */
  1298. int sps_get_bam_addr(unsigned long dev, phys_addr_t *base,
  1299. u32 *size);
  1300. /*
  1301. * sps_pipe_inject_zlt - inject a ZLT with EOT.
  1302. * @dev: BAM device handle
  1303. * @pipe_index: pipe index
  1304. *
  1305. * This function injects a ZLT with EOT for a pipe of a BAM.
  1306. *
  1307. * Return: 0 on success, negative value on error
  1308. */
  1309. int sps_pipe_inject_zlt(unsigned long dev, u32 pipe_index);
  1310. #else
  1311. static inline int sps_register_bam_device(const struct sps_bam_props
  1312. *bam_props, unsigned long *dev_handle)
  1313. {
  1314. return -EPERM;
  1315. }
  1316. static inline int sps_deregister_bam_device(unsigned long dev_handle)
  1317. {
  1318. return -EPERM;
  1319. }
  1320. static inline struct sps_pipe *sps_alloc_endpoint(void)
  1321. {
  1322. return NULL;
  1323. }
  1324. static inline int sps_free_endpoint(struct sps_pipe *h)
  1325. {
  1326. return -EPERM;
  1327. }
  1328. static inline int sps_get_config(struct sps_pipe *h, struct sps_connect *config)
  1329. {
  1330. return -EPERM;
  1331. }
  1332. static inline int sps_alloc_mem(struct sps_pipe *h, enum sps_mem mem,
  1333. struct sps_mem_buffer *mem_buffer)
  1334. {
  1335. return -EPERM;
  1336. }
  1337. static inline int sps_free_mem(struct sps_pipe *h,
  1338. struct sps_mem_buffer *mem_buffer)
  1339. {
  1340. return -EPERM;
  1341. }
  1342. static inline int sps_connect(struct sps_pipe *h, struct sps_connect *connect)
  1343. {
  1344. return -EPERM;
  1345. }
  1346. static inline int sps_disconnect(struct sps_pipe *h)
  1347. {
  1348. return -EPERM;
  1349. }
  1350. static inline int sps_register_event(struct sps_pipe *h,
  1351. struct sps_register_event *reg)
  1352. {
  1353. return -EPERM;
  1354. }
  1355. static inline int sps_transfer_one(struct sps_pipe *h, phys_addr_t addr,
  1356. u32 size, void *user, u32 flags)
  1357. {
  1358. return -EPERM;
  1359. }
  1360. static inline int sps_get_event(struct sps_pipe *h,
  1361. struct sps_event_notify *event)
  1362. {
  1363. return -EPERM;
  1364. }
  1365. static inline int sps_get_iovec(struct sps_pipe *h, struct sps_iovec *iovec)
  1366. {
  1367. return -EPERM;
  1368. }
  1369. static inline int sps_flow_on(struct sps_pipe *h)
  1370. {
  1371. return -EPERM;
  1372. }
  1373. static inline int sps_flow_off(struct sps_pipe *h, enum sps_flow_off mode)
  1374. {
  1375. return -EPERM;
  1376. }
  1377. static inline int sps_transfer(struct sps_pipe *h,
  1378. struct sps_transfer *transfer)
  1379. {
  1380. return -EPERM;
  1381. }
  1382. static inline int sps_is_pipe_empty(struct sps_pipe *h, u32 *empty)
  1383. {
  1384. return -EPERM;
  1385. }
  1386. static inline int sps_device_reset(unsigned long dev)
  1387. {
  1388. return -EPERM;
  1389. }
  1390. static inline int sps_set_config(struct sps_pipe *h, struct sps_connect *config)
  1391. {
  1392. return -EPERM;
  1393. }
  1394. static inline int sps_set_owner(struct sps_pipe *h, enum sps_owner owner,
  1395. struct sps_satellite *connect)
  1396. {
  1397. return -EPERM;
  1398. }
  1399. static inline int sps_get_free_count(struct sps_pipe *h, u32 *count)
  1400. {
  1401. return -EPERM;
  1402. }
  1403. static inline int sps_alloc_dma_chan(const struct sps_alloc_dma_chan *alloc,
  1404. struct sps_dma_chan *chan)
  1405. {
  1406. return -EPERM;
  1407. }
  1408. static inline int sps_free_dma_chan(struct sps_dma_chan *chan)
  1409. {
  1410. return -EPERM;
  1411. }
  1412. static inline unsigned long sps_dma_get_bam_handle(void)
  1413. {
  1414. return 0;
  1415. }
  1416. static inline void sps_dma_free_bam_handle(unsigned long h)
  1417. {
  1418. }
  1419. static inline int sps_timer_ctrl(struct sps_pipe *h,
  1420. struct sps_timer_ctrl *timer_ctrl,
  1421. struct sps_timer_result *timer_result)
  1422. {
  1423. return -EPERM;
  1424. }
  1425. static inline int sps_phy2h(phys_addr_t phys_addr, unsigned long *handle)
  1426. {
  1427. return -EPERM;
  1428. }
  1429. static inline int sps_setup_bam2bam_fifo(struct sps_mem_buffer *mem_buffer,
  1430. u32 addr, u32 size, int use_offset)
  1431. {
  1432. return -EPERM;
  1433. }
  1434. static inline int sps_get_unused_desc_num(struct sps_pipe *h, u32 *desc_num)
  1435. {
  1436. return -EPERM;
  1437. }
  1438. static inline int sps_get_bam_debug_info(unsigned long dev, u32 option,
  1439. u32 para, u32 tb_sel, u32 desc_sel)
  1440. {
  1441. return -EPERM;
  1442. }
  1443. static inline int sps_ctrl_bam_dma_clk(bool clk_on)
  1444. {
  1445. return -EPERM;
  1446. }
  1447. static inline int sps_pipe_reset(unsigned long dev, u32 pipe)
  1448. {
  1449. return -EPERM;
  1450. }
  1451. static inline int sps_pipe_disable(unsigned long dev, u32 pipe)
  1452. {
  1453. return -EPERM;
  1454. }
  1455. static inline int sps_pipe_pending_desc(unsigned long dev, u32 pipe,
  1456. bool *pending)
  1457. {
  1458. return -EPERM;
  1459. }
  1460. static inline int sps_bam_process_irq(unsigned long dev)
  1461. {
  1462. return -EPERM;
  1463. }
  1464. static inline int sps_bam_enable_irqs(unsigned long dev)
  1465. {
  1466. return -EPERM;
  1467. }
  1468. static inline int sps_bam_disable_irqs(unsigned long dev)
  1469. {
  1470. return -EPERM;
  1471. }
  1472. static inline int sps_get_bam_addr(unsigned long dev, phys_addr_t *base,
  1473. u32 *size)
  1474. {
  1475. return -EPERM;
  1476. }
  1477. static inline int sps_pipe_inject_zlt(unsigned long dev, u32 pipe_index)
  1478. {
  1479. return -EPERM;
  1480. }
  1481. #endif
  1482. #endif /* _SPS_H_ */