msm-sps.h 44 KB

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