omap_hwmod.h 16 KB

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