omap_hwmod.h 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447
  1. /*
  2. * omap_hwmod macros, structures
  3. *
  4. * Copyright (C) 2009 Nokia Corporation
  5. * Paul Walmsley
  6. *
  7. * Created in collaboration with (alphabetical order): Benoit Cousson,
  8. * Kevin Hilman, Tony Lindgren, Rajendra Nayak, Vikram Pandita, Sakari
  9. * Poussa, Anand Sawant, Santosh Shilimkar, Richard Woodruff
  10. *
  11. * This program is free software; you can redistribute it and/or modify
  12. * it under the terms of the GNU General Public License version 2 as
  13. * published by the Free Software Foundation.
  14. *
  15. * These headers and macros are used to define OMAP on-chip module
  16. * data and their integration with other OMAP modules and Linux.
  17. *
  18. * References:
  19. * - OMAP2420 Multimedia Processor Silicon Revision 2.1.1, 2.2 (SWPU064)
  20. * - OMAP2430 Multimedia Device POP Silicon Revision 2.1 (SWPU090)
  21. * - OMAP34xx Multimedia Device Silicon Revision 3.1 (SWPU108)
  22. * - OMAP4430 Multimedia Device Silicon Revision 1.0 (SWPU140)
  23. * - Open Core Protocol Specification 2.2
  24. *
  25. * To do:
  26. * - add interconnect error log structures
  27. * - add pinmuxing
  28. * - init_conn_id_bit (CONNID_BIT_VECTOR)
  29. * - implement default hwmod SMS/SDRC flags?
  30. *
  31. */
  32. #ifndef __ARCH_ARM_PLAT_OMAP_INCLUDE_MACH_OMAP_HWMOD_H
  33. #define __ARCH_ARM_PLAT_OMAP_INCLUDE_MACH_OMAP_HWMOD_H
  34. #include <linux/kernel.h>
  35. #include <linux/ioport.h>
  36. #include <mach/cpu.h>
  37. struct omap_device;
  38. /* OCP SYSCONFIG bit shifts/masks */
  39. #define SYSC_MIDLEMODE_SHIFT 12
  40. #define SYSC_MIDLEMODE_MASK (0x3 << SYSC_MIDLEMODE_SHIFT)
  41. #define SYSC_CLOCKACTIVITY_SHIFT 8
  42. #define SYSC_CLOCKACTIVITY_MASK (0x3 << SYSC_CLOCKACTIVITY_SHIFT)
  43. #define SYSC_SIDLEMODE_SHIFT 3
  44. #define SYSC_SIDLEMODE_MASK (0x3 << SYSC_SIDLEMODE_SHIFT)
  45. #define SYSC_ENAWAKEUP_SHIFT 2
  46. #define SYSC_ENAWAKEUP_MASK (1 << SYSC_ENAWAKEUP_SHIFT)
  47. #define SYSC_SOFTRESET_SHIFT 1
  48. #define SYSC_SOFTRESET_MASK (1 << SYSC_SOFTRESET_SHIFT)
  49. /* OCP SYSSTATUS bit shifts/masks */
  50. #define SYSS_RESETDONE_SHIFT 0
  51. #define SYSS_RESETDONE_MASK (1 << SYSS_RESETDONE_SHIFT)
  52. /* Master standby/slave idle mode flags */
  53. #define HWMOD_IDLEMODE_FORCE (1 << 0)
  54. #define HWMOD_IDLEMODE_NO (1 << 1)
  55. #define HWMOD_IDLEMODE_SMART (1 << 2)
  56. /**
  57. * struct omap_hwmod_dma_info - MPU address space handled by the hwmod
  58. * @name: name of the DMA channel (module local name)
  59. * @dma_ch: DMA channel ID
  60. *
  61. * @name should be something short, e.g., "tx" or "rx". It is for use
  62. * by platform_get_resource_byname(). It is defined locally to the
  63. * hwmod.
  64. */
  65. struct omap_hwmod_dma_info {
  66. const char *name;
  67. u16 dma_ch;
  68. };
  69. /**
  70. * struct omap_hwmod_opt_clk - optional clocks used by this hwmod
  71. * @role: "sys", "32k", "tv", etc -- for use in clk_get()
  72. * @clkdev_dev_id: opt clock: clkdev dev_id string
  73. * @clkdev_con_id: opt clock: clkdev con_id string
  74. * @_clk: pointer to the struct clk (filled in at runtime)
  75. *
  76. * The module's interface clock and main functional clock should not
  77. * be added as optional clocks.
  78. */
  79. struct omap_hwmod_opt_clk {
  80. const char *role;
  81. const char *clkdev_dev_id;
  82. const char *clkdev_con_id;
  83. struct clk *_clk;
  84. };
  85. /* omap_hwmod_omap2_firewall.flags bits */
  86. #define OMAP_FIREWALL_L3 (1 << 0)
  87. #define OMAP_FIREWALL_L4 (1 << 1)
  88. /**
  89. * struct omap_hwmod_omap2_firewall - OMAP2/3 device firewall data
  90. * @l3_perm_bit: bit shift for L3_PM_*_PERMISSION_*
  91. * @l4_fw_region: L4 firewall region ID
  92. * @l4_prot_group: L4 protection group ID
  93. * @flags: (see omap_hwmod_omap2_firewall.flags macros above)
  94. */
  95. struct omap_hwmod_omap2_firewall {
  96. u8 l3_perm_bit;
  97. u8 l4_fw_region;
  98. u8 l4_prot_group;
  99. u8 flags;
  100. };
  101. /*
  102. * omap_hwmod_addr_space.flags bits
  103. *
  104. * ADDR_MAP_ON_INIT: Map this address space during omap_hwmod init.
  105. * ADDR_TYPE_RT: Address space contains module register target data.
  106. */
  107. #define ADDR_MAP_ON_INIT (1 << 0)
  108. #define ADDR_TYPE_RT (1 << 1)
  109. /**
  110. * struct omap_hwmod_addr_space - MPU address space handled by the hwmod
  111. * @pa_start: starting physical address
  112. * @pa_end: ending physical address
  113. * @flags: (see omap_hwmod_addr_space.flags macros above)
  114. *
  115. * Address space doesn't necessarily follow physical interconnect
  116. * structure. GPMC is one example.
  117. */
  118. struct omap_hwmod_addr_space {
  119. u32 pa_start;
  120. u32 pa_end;
  121. u8 flags;
  122. };
  123. /*
  124. * omap_hwmod_ocp_if.user bits: these indicate the initiators that use this
  125. * interface to interact with the hwmod. Used to add sleep dependencies
  126. * when the module is enabled or disabled.
  127. */
  128. #define OCP_USER_MPU (1 << 0)
  129. #define OCP_USER_SDMA (1 << 1)
  130. /* omap_hwmod_ocp_if.flags bits */
  131. #define OCPIF_HAS_IDLEST (1 << 0)
  132. #define OCPIF_SWSUP_IDLE (1 << 1)
  133. #define OCPIF_CAN_BURST (1 << 2)
  134. /**
  135. * struct omap_hwmod_ocp_if - OCP interface data
  136. * @master: struct omap_hwmod that initiates OCP transactions on this link
  137. * @slave: struct omap_hwmod that responds to OCP transactions on this link
  138. * @addr: address space associated with this link
  139. * @clkdev_dev_id: interface clock: clkdev dev_id string
  140. * @clkdev_con_id: interface clock: clkdev con_id string
  141. * @_clk: pointer to the interface struct clk (filled in at runtime)
  142. * @fw: interface firewall data
  143. * @addr_cnt: ARRAY_SIZE(@addr)
  144. * @width: OCP data width
  145. * @thread_cnt: number of threads
  146. * @max_burst_len: maximum burst length in @width sized words (0 if unlimited)
  147. * @user: initiators using this interface (see OCP_USER_* macros above)
  148. * @flags: OCP interface flags (see OCPIF_* macros above)
  149. *
  150. * It may also be useful to add a tag_cnt field for OCP2.x devices.
  151. *
  152. * Parameter names beginning with an underscore are managed internally by
  153. * the omap_hwmod code and should not be set during initialization.
  154. */
  155. struct omap_hwmod_ocp_if {
  156. struct omap_hwmod *master;
  157. struct omap_hwmod *slave;
  158. struct omap_hwmod_addr_space *addr;
  159. const char *clkdev_dev_id;
  160. const char *clkdev_con_id;
  161. struct clk *_clk;
  162. union {
  163. struct omap_hwmod_omap2_firewall omap2;
  164. } fw;
  165. u8 addr_cnt;
  166. u8 width;
  167. u8 thread_cnt;
  168. u8 max_burst_len;
  169. u8 user;
  170. u8 flags;
  171. };
  172. /* Macros for use in struct omap_hwmod_sysconfig */
  173. /* Flags for use in omap_hwmod_sysconfig.idlemodes */
  174. #define MASTER_STANDBY_SHIFT 2
  175. #define SLAVE_IDLE_SHIFT 0
  176. #define SIDLE_FORCE (HWMOD_IDLEMODE_FORCE << SLAVE_IDLE_SHIFT)
  177. #define SIDLE_NO (HWMOD_IDLEMODE_NO << SLAVE_IDLE_SHIFT)
  178. #define SIDLE_SMART (HWMOD_IDLEMODE_SMART << SLAVE_IDLE_SHIFT)
  179. #define MSTANDBY_FORCE (HWMOD_IDLEMODE_FORCE << MASTER_STANDBY_SHIFT)
  180. #define MSTANDBY_NO (HWMOD_IDLEMODE_NO << MASTER_STANDBY_SHIFT)
  181. #define MSTANDBY_SMART (HWMOD_IDLEMODE_SMART << MASTER_STANDBY_SHIFT)
  182. /* omap_hwmod_sysconfig.sysc_flags capability flags */
  183. #define SYSC_HAS_AUTOIDLE (1 << 0)
  184. #define SYSC_HAS_SOFTRESET (1 << 1)
  185. #define SYSC_HAS_ENAWAKEUP (1 << 2)
  186. #define SYSC_HAS_EMUFREE (1 << 3)
  187. #define SYSC_HAS_CLOCKACTIVITY (1 << 4)
  188. #define SYSC_HAS_SIDLEMODE (1 << 5)
  189. #define SYSC_HAS_MIDLEMODE (1 << 6)
  190. #define SYSS_MISSING (1 << 7)
  191. /* omap_hwmod_sysconfig.clockact flags */
  192. #define CLOCKACT_TEST_BOTH 0x0
  193. #define CLOCKACT_TEST_MAIN 0x1
  194. #define CLOCKACT_TEST_ICLK 0x2
  195. #define CLOCKACT_TEST_NONE 0x3
  196. /**
  197. * struct omap_hwmod_sysconfig - hwmod OCP_SYSCONFIG/OCP_SYSSTATUS data
  198. * @rev_offs: IP block revision register offset (from module base addr)
  199. * @sysc_offs: OCP_SYSCONFIG register offset (from module base addr)
  200. * @syss_offs: OCP_SYSSTATUS register offset (from module base addr)
  201. * @idlemodes: One or more of {SIDLE,MSTANDBY}_{OFF,FORCE,SMART}
  202. * @sysc_flags: SYS{C,S}_HAS* flags indicating SYSCONFIG bits supported
  203. * @clockact: the default value of the module CLOCKACTIVITY bits
  204. *
  205. * @clockact describes to the module which clocks are likely to be
  206. * disabled when the PRCM issues its idle request to the module. Some
  207. * modules have separate clockdomains for the interface clock and main
  208. * functional clock, and can check whether they should acknowledge the
  209. * idle request based on the internal module functionality that has
  210. * been associated with the clocks marked in @clockact. This field is
  211. * only used if HWMOD_SET_DEFAULT_CLOCKACT is set (see below)
  212. *
  213. */
  214. struct omap_hwmod_sysconfig {
  215. u16 rev_offs;
  216. u16 sysc_offs;
  217. u16 syss_offs;
  218. u8 idlemodes;
  219. u8 sysc_flags;
  220. u8 clockact;
  221. };
  222. /**
  223. * struct omap_hwmod_omap2_prcm - OMAP2/3-specific PRCM data
  224. * @module_offs: PRCM submodule offset from the start of the PRM/CM
  225. * @prcm_reg_id: PRCM register ID (e.g., 3 for CM_AUTOIDLE3)
  226. * @module_bit: register bit shift for AUTOIDLE, WKST, WKEN, GRPSEL regs
  227. * @idlest_reg_id: IDLEST register ID (e.g., 3 for CM_IDLEST3)
  228. * @idlest_idle_bit: register bit shift for CM_IDLEST slave idle bit
  229. * @idlest_stdby_bit: register bit shift for CM_IDLEST master standby bit
  230. *
  231. * @prcm_reg_id and @module_bit are specific to the AUTOIDLE, WKST,
  232. * WKEN, GRPSEL registers. In an ideal world, no extra information
  233. * would be needed for IDLEST information, but alas, there are some
  234. * exceptions, so @idlest_reg_id, @idlest_idle_bit, @idlest_stdby_bit
  235. * are needed for the IDLEST registers (c.f. 2430 I2CHS, 3430 USBHOST)
  236. */
  237. struct omap_hwmod_omap2_prcm {
  238. s16 module_offs;
  239. u8 prcm_reg_id;
  240. u8 module_bit;
  241. u8 idlest_reg_id;
  242. u8 idlest_idle_bit;
  243. u8 idlest_stdby_bit;
  244. };
  245. /**
  246. * struct omap_hwmod_omap4_prcm - OMAP4-specific PRCM data
  247. * @module_offs: PRCM submodule offset from the start of the PRM/CM1/CM2
  248. * @device_offs: device register offset from @module_offs
  249. * @submodule_wkdep_bit: bit shift of the WKDEP range
  250. */
  251. struct omap_hwmod_omap4_prcm {
  252. u32 module_offs;
  253. u16 device_offs;
  254. u8 submodule_wkdep_bit;
  255. };
  256. /*
  257. * omap_hwmod.flags definitions
  258. *
  259. * HWMOD_SWSUP_SIDLE: omap_hwmod code should manually bring module in and out
  260. * of idle, rather than relying on module smart-idle
  261. * HWMOD_SWSUP_MSTDBY: omap_hwmod code should manually bring module in and out
  262. * of standby, rather than relying on module smart-standby
  263. * HWMOD_INIT_NO_RESET: don't reset this module at boot - important for
  264. * SDRAM controller, etc.
  265. * HWMOD_INIT_NO_IDLE: don't idle this module at boot - important for SDRAM
  266. * controller, etc.
  267. * HWMOD_SET_DEFAULT_CLOCKACT: program CLOCKACTIVITY bits at startup
  268. */
  269. #define HWMOD_SWSUP_SIDLE (1 << 0)
  270. #define HWMOD_SWSUP_MSTANDBY (1 << 1)
  271. #define HWMOD_INIT_NO_RESET (1 << 2)
  272. #define HWMOD_INIT_NO_IDLE (1 << 3)
  273. #define HWMOD_SET_DEFAULT_CLOCKACT (1 << 4)
  274. /*
  275. * omap_hwmod._int_flags definitions
  276. * These are for internal use only and are managed by the omap_hwmod code.
  277. *
  278. * _HWMOD_NO_MPU_PORT: no path exists for the MPU to write to this module
  279. * _HWMOD_WAKEUP_ENABLED: set when the omap_hwmod code has enabled ENAWAKEUP
  280. * _HWMOD_SYSCONFIG_LOADED: set when the OCP_SYSCONFIG value has been cached
  281. */
  282. #define _HWMOD_NO_MPU_PORT (1 << 0)
  283. #define _HWMOD_WAKEUP_ENABLED (1 << 1)
  284. #define _HWMOD_SYSCONFIG_LOADED (1 << 2)
  285. /*
  286. * omap_hwmod._state definitions
  287. *
  288. * INITIALIZED: reset (optionally), initialized, enabled, disabled
  289. * (optionally)
  290. *
  291. *
  292. */
  293. #define _HWMOD_STATE_UNKNOWN 0
  294. #define _HWMOD_STATE_REGISTERED 1
  295. #define _HWMOD_STATE_CLKS_INITED 2
  296. #define _HWMOD_STATE_INITIALIZED 3
  297. #define _HWMOD_STATE_ENABLED 4
  298. #define _HWMOD_STATE_IDLE 5
  299. #define _HWMOD_STATE_DISABLED 6
  300. /**
  301. * struct omap_hwmod - integration data for OMAP hardware "modules" (IP blocks)
  302. * @name: name of the hwmod
  303. * @od: struct omap_device currently associated with this hwmod (internal use)
  304. * @mpu_irqs: ptr to an array of MPU IRQs (see also mpu_irqs_cnt)
  305. * @sdma_chs: ptr to an array of SDMA channel IDs (see also sdma_chs_cnt)
  306. * @prcm: PRCM data pertaining to this hwmod
  307. * @clkdev_dev_id: main clock: clkdev dev_id string
  308. * @clkdev_con_id: main clock: clkdev con_id string
  309. * @_clk: pointer to the main struct clk (filled in at runtime)
  310. * @opt_clks: other device clocks that drivers can request (0..*)
  311. * @masters: ptr to array of OCP ifs that this hwmod can initiate on
  312. * @slaves: ptr to array of OCP ifs that this hwmod can respond on
  313. * @sysconfig: device SYSCONFIG/SYSSTATUS register data
  314. * @dev_attr: arbitrary device attributes that can be passed to the driver
  315. * @_sysc_cache: internal-use hwmod flags
  316. * @_rt_va: cached register target start address (internal use)
  317. * @_mpu_port_index: cached MPU register target slave ID (internal use)
  318. * @msuspendmux_reg_id: CONTROL_MSUSPENDMUX register ID (1-6)
  319. * @msuspendmux_shift: CONTROL_MSUSPENDMUX register bit shift
  320. * @mpu_irqs_cnt: number of @mpu_irqs
  321. * @sdma_chs_cnt: number of @sdma_chs
  322. * @opt_clks_cnt: number of @opt_clks
  323. * @master_cnt: number of @master entries
  324. * @slaves_cnt: number of @slave entries
  325. * @response_lat: device OCP response latency (in interface clock cycles)
  326. * @_int_flags: internal-use hwmod flags
  327. * @_state: internal-use hwmod state
  328. * @flags: hwmod flags (documented below)
  329. * @omap_chip: OMAP chips this hwmod is present on
  330. * @node: list node for hwmod list (internal use)
  331. *
  332. * @clkdev_dev_id, @clkdev_con_id, and @clk all refer to this module's "main
  333. * clock," which for our purposes is defined as "the functional clock needed
  334. * for register accesses to complete." Modules may not have a main clock if
  335. * the interface clock also serves as a main clock.
  336. *
  337. * Parameter names beginning with an underscore are managed internally by
  338. * the omap_hwmod code and should not be set during initialization.
  339. */
  340. struct omap_hwmod {
  341. const char *name;
  342. struct omap_device *od;
  343. u8 *mpu_irqs;
  344. struct omap_hwmod_dma_info *sdma_chs;
  345. union {
  346. struct omap_hwmod_omap2_prcm omap2;
  347. struct omap_hwmod_omap4_prcm omap4;
  348. } prcm;
  349. const char *clkdev_dev_id;
  350. const char *clkdev_con_id;
  351. struct clk *_clk;
  352. struct omap_hwmod_opt_clk *opt_clks;
  353. struct omap_hwmod_ocp_if **masters; /* connect to *_IA */
  354. struct omap_hwmod_ocp_if **slaves; /* connect to *_TA */
  355. struct omap_hwmod_sysconfig *sysconfig;
  356. void *dev_attr;
  357. u32 _sysc_cache;
  358. void __iomem *_rt_va;
  359. struct list_head node;
  360. u16 flags;
  361. u8 _mpu_port_index;
  362. u8 msuspendmux_reg_id;
  363. u8 msuspendmux_shift;
  364. u8 response_lat;
  365. u8 mpu_irqs_cnt;
  366. u8 sdma_chs_cnt;
  367. u8 opt_clks_cnt;
  368. u8 masters_cnt;
  369. u8 slaves_cnt;
  370. u8 hwmods_cnt;
  371. u8 _int_flags;
  372. u8 _state;
  373. const struct omap_chip_id omap_chip;
  374. };
  375. int omap_hwmod_init(struct omap_hwmod **ohs);
  376. int omap_hwmod_register(struct omap_hwmod *oh);
  377. int omap_hwmod_unregister(struct omap_hwmod *oh);
  378. struct omap_hwmod *omap_hwmod_lookup(const char *name);
  379. int omap_hwmod_for_each(int (*fn)(struct omap_hwmod *oh));
  380. int omap_hwmod_late_init(void);
  381. int omap_hwmod_enable(struct omap_hwmod *oh);
  382. int omap_hwmod_idle(struct omap_hwmod *oh);
  383. int omap_hwmod_shutdown(struct omap_hwmod *oh);
  384. int omap_hwmod_enable_clocks(struct omap_hwmod *oh);
  385. int omap_hwmod_disable_clocks(struct omap_hwmod *oh);
  386. int omap_hwmod_reset(struct omap_hwmod *oh);
  387. void omap_hwmod_ocp_barrier(struct omap_hwmod *oh);
  388. void omap_hwmod_writel(u32 v, struct omap_hwmod *oh, u16 reg_offs);
  389. u32 omap_hwmod_readl(struct omap_hwmod *oh, u16 reg_offs);
  390. int omap_hwmod_count_resources(struct omap_hwmod *oh);
  391. int omap_hwmod_fill_resources(struct omap_hwmod *oh, struct resource *res);
  392. struct powerdomain *omap_hwmod_get_pwrdm(struct omap_hwmod *oh);
  393. int omap_hwmod_add_initiator_dep(struct omap_hwmod *oh,
  394. struct omap_hwmod *init_oh);
  395. int omap_hwmod_del_initiator_dep(struct omap_hwmod *oh,
  396. struct omap_hwmod *init_oh);
  397. int omap_hwmod_set_clockact_both(struct omap_hwmod *oh);
  398. int omap_hwmod_set_clockact_main(struct omap_hwmod *oh);
  399. int omap_hwmod_set_clockact_iclk(struct omap_hwmod *oh);
  400. int omap_hwmod_set_clockact_none(struct omap_hwmod *oh);
  401. int omap_hwmod_enable_wakeup(struct omap_hwmod *oh);
  402. int omap_hwmod_disable_wakeup(struct omap_hwmod *oh);
  403. #endif