omap_hwmod.h 15 KB

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