ti_hdmi_4xxx_ip.c 40 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423
  1. /*
  2. * ti_hdmi_4xxx_ip.c
  3. *
  4. * HDMI TI81xx, TI38xx, TI OMAP4 etc IP driver Library
  5. * Copyright (C) 2010-2011 Texas Instruments Incorporated - http://www.ti.com/
  6. * Authors: Yong Zhi
  7. * Mythri pk <mythripk@ti.com>
  8. *
  9. * This program is free software; you can redistribute it and/or modify it
  10. * under the terms of the GNU General Public License version 2 as published by
  11. * the Free Software Foundation.
  12. *
  13. * This program is distributed in the hope that it will be useful, but WITHOUT
  14. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  15. * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
  16. * more details.
  17. *
  18. * You should have received a copy of the GNU General Public License along with
  19. * this program. If not, see <http://www.gnu.org/licenses/>.
  20. */
  21. #include <linux/kernel.h>
  22. #include <linux/module.h>
  23. #include <linux/err.h>
  24. #include <linux/io.h>
  25. #include <linux/interrupt.h>
  26. #include <linux/mutex.h>
  27. #include <linux/delay.h>
  28. #include <linux/string.h>
  29. #include <linux/seq_file.h>
  30. #include <linux/gpio.h>
  31. #if defined(CONFIG_OMAP4_DSS_HDMI_AUDIO)
  32. #include <sound/asound.h>
  33. #include <sound/asoundef.h>
  34. #endif
  35. #include "ti_hdmi_4xxx_ip.h"
  36. #include "dss.h"
  37. #include "dss_features.h"
  38. static inline void hdmi_write_reg(void __iomem *base_addr,
  39. const u16 idx, u32 val)
  40. {
  41. __raw_writel(val, base_addr + idx);
  42. }
  43. static inline u32 hdmi_read_reg(void __iomem *base_addr,
  44. const u16 idx)
  45. {
  46. return __raw_readl(base_addr + idx);
  47. }
  48. static inline void __iomem *hdmi_wp_base(struct hdmi_ip_data *ip_data)
  49. {
  50. return ip_data->base_wp;
  51. }
  52. static inline void __iomem *hdmi_phy_base(struct hdmi_ip_data *ip_data)
  53. {
  54. return ip_data->base_wp + ip_data->phy_offset;
  55. }
  56. static inline void __iomem *hdmi_pll_base(struct hdmi_ip_data *ip_data)
  57. {
  58. return ip_data->base_wp + ip_data->pll_offset;
  59. }
  60. static inline void __iomem *hdmi_av_base(struct hdmi_ip_data *ip_data)
  61. {
  62. return ip_data->base_wp + ip_data->core_av_offset;
  63. }
  64. static inline void __iomem *hdmi_core_sys_base(struct hdmi_ip_data *ip_data)
  65. {
  66. return ip_data->base_wp + ip_data->core_sys_offset;
  67. }
  68. static inline int hdmi_wait_for_bit_change(void __iomem *base_addr,
  69. const u16 idx,
  70. int b2, int b1, u32 val)
  71. {
  72. u32 t = 0;
  73. while (val != REG_GET(base_addr, idx, b2, b1)) {
  74. udelay(1);
  75. if (t++ > 10000)
  76. return !val;
  77. }
  78. return val;
  79. }
  80. static int hdmi_pll_init(struct hdmi_ip_data *ip_data)
  81. {
  82. u32 r;
  83. void __iomem *pll_base = hdmi_pll_base(ip_data);
  84. struct hdmi_pll_info *fmt = &ip_data->pll_data;
  85. /* PLL start always use manual mode */
  86. REG_FLD_MOD(pll_base, PLLCTRL_PLL_CONTROL, 0x0, 0, 0);
  87. r = hdmi_read_reg(pll_base, PLLCTRL_CFG1);
  88. r = FLD_MOD(r, fmt->regm, 20, 9); /* CFG1_PLL_REGM */
  89. r = FLD_MOD(r, fmt->regn - 1, 8, 1); /* CFG1_PLL_REGN */
  90. hdmi_write_reg(pll_base, PLLCTRL_CFG1, r);
  91. r = hdmi_read_reg(pll_base, PLLCTRL_CFG2);
  92. r = FLD_MOD(r, 0x0, 12, 12); /* PLL_HIGHFREQ divide by 2 */
  93. r = FLD_MOD(r, 0x1, 13, 13); /* PLL_REFEN */
  94. r = FLD_MOD(r, 0x0, 14, 14); /* PHY_CLKINEN de-assert during locking */
  95. r = FLD_MOD(r, fmt->refsel, 22, 21); /* REFSEL */
  96. if (fmt->dcofreq) {
  97. /* divider programming for frequency beyond 1000Mhz */
  98. REG_FLD_MOD(pll_base, PLLCTRL_CFG3, fmt->regsd, 17, 10);
  99. r = FLD_MOD(r, 0x4, 3, 1); /* 1000MHz and 2000MHz */
  100. } else {
  101. r = FLD_MOD(r, 0x2, 3, 1); /* 500MHz and 1000MHz */
  102. }
  103. hdmi_write_reg(pll_base, PLLCTRL_CFG2, r);
  104. r = hdmi_read_reg(pll_base, PLLCTRL_CFG4);
  105. r = FLD_MOD(r, fmt->regm2, 24, 18);
  106. r = FLD_MOD(r, fmt->regmf, 17, 0);
  107. hdmi_write_reg(pll_base, PLLCTRL_CFG4, r);
  108. /* go now */
  109. REG_FLD_MOD(pll_base, PLLCTRL_PLL_GO, 0x1, 0, 0);
  110. /* wait for bit change */
  111. if (hdmi_wait_for_bit_change(pll_base, PLLCTRL_PLL_GO,
  112. 0, 0, 1) != 1) {
  113. pr_err("PLL GO bit not set\n");
  114. return -ETIMEDOUT;
  115. }
  116. /* Wait till the lock bit is set in PLL status */
  117. if (hdmi_wait_for_bit_change(pll_base,
  118. PLLCTRL_PLL_STATUS, 1, 1, 1) != 1) {
  119. pr_err("cannot lock PLL\n");
  120. pr_err("CFG1 0x%x\n",
  121. hdmi_read_reg(pll_base, PLLCTRL_CFG1));
  122. pr_err("CFG2 0x%x\n",
  123. hdmi_read_reg(pll_base, PLLCTRL_CFG2));
  124. pr_err("CFG4 0x%x\n",
  125. hdmi_read_reg(pll_base, PLLCTRL_CFG4));
  126. return -ETIMEDOUT;
  127. }
  128. pr_debug("PLL locked!\n");
  129. return 0;
  130. }
  131. /* PHY_PWR_CMD */
  132. static int hdmi_set_phy_pwr(struct hdmi_ip_data *ip_data, enum hdmi_phy_pwr val)
  133. {
  134. /* Command for power control of HDMI PHY */
  135. REG_FLD_MOD(hdmi_wp_base(ip_data), HDMI_WP_PWR_CTRL, val, 7, 6);
  136. /* Status of the power control of HDMI PHY */
  137. if (hdmi_wait_for_bit_change(hdmi_wp_base(ip_data),
  138. HDMI_WP_PWR_CTRL, 5, 4, val) != val) {
  139. pr_err("Failed to set PHY power mode to %d\n", val);
  140. return -ETIMEDOUT;
  141. }
  142. return 0;
  143. }
  144. /* PLL_PWR_CMD */
  145. static int hdmi_set_pll_pwr(struct hdmi_ip_data *ip_data, enum hdmi_pll_pwr val)
  146. {
  147. /* Command for power control of HDMI PLL */
  148. REG_FLD_MOD(hdmi_wp_base(ip_data), HDMI_WP_PWR_CTRL, val, 3, 2);
  149. /* wait till PHY_PWR_STATUS is set */
  150. if (hdmi_wait_for_bit_change(hdmi_wp_base(ip_data), HDMI_WP_PWR_CTRL,
  151. 1, 0, val) != val) {
  152. pr_err("Failed to set PLL_PWR_STATUS\n");
  153. return -ETIMEDOUT;
  154. }
  155. return 0;
  156. }
  157. static int hdmi_pll_reset(struct hdmi_ip_data *ip_data)
  158. {
  159. /* SYSRESET controlled by power FSM */
  160. REG_FLD_MOD(hdmi_pll_base(ip_data), PLLCTRL_PLL_CONTROL, 0x0, 3, 3);
  161. /* READ 0x0 reset is in progress */
  162. if (hdmi_wait_for_bit_change(hdmi_pll_base(ip_data),
  163. PLLCTRL_PLL_STATUS, 0, 0, 1) != 1) {
  164. pr_err("Failed to sysreset PLL\n");
  165. return -ETIMEDOUT;
  166. }
  167. return 0;
  168. }
  169. int ti_hdmi_4xxx_pll_enable(struct hdmi_ip_data *ip_data)
  170. {
  171. u16 r = 0;
  172. r = hdmi_set_pll_pwr(ip_data, HDMI_PLLPWRCMD_ALLOFF);
  173. if (r)
  174. return r;
  175. r = hdmi_set_pll_pwr(ip_data, HDMI_PLLPWRCMD_BOTHON_ALLCLKS);
  176. if (r)
  177. return r;
  178. r = hdmi_pll_reset(ip_data);
  179. if (r)
  180. return r;
  181. r = hdmi_pll_init(ip_data);
  182. if (r)
  183. return r;
  184. return 0;
  185. }
  186. void ti_hdmi_4xxx_pll_disable(struct hdmi_ip_data *ip_data)
  187. {
  188. hdmi_set_pll_pwr(ip_data, HDMI_PLLPWRCMD_ALLOFF);
  189. }
  190. static int hdmi_check_hpd_state(struct hdmi_ip_data *ip_data)
  191. {
  192. unsigned long flags;
  193. bool hpd;
  194. int r;
  195. /* this should be in ti_hdmi_4xxx_ip private data */
  196. static DEFINE_SPINLOCK(phy_tx_lock);
  197. spin_lock_irqsave(&phy_tx_lock, flags);
  198. hpd = gpio_get_value(ip_data->hpd_gpio);
  199. if (hpd == ip_data->phy_tx_enabled) {
  200. spin_unlock_irqrestore(&phy_tx_lock, flags);
  201. return 0;
  202. }
  203. if (hpd)
  204. r = hdmi_set_phy_pwr(ip_data, HDMI_PHYPWRCMD_TXON);
  205. else
  206. r = hdmi_set_phy_pwr(ip_data, HDMI_PHYPWRCMD_LDOON);
  207. if (r) {
  208. DSSERR("Failed to %s PHY TX power\n",
  209. hpd ? "enable" : "disable");
  210. goto err;
  211. }
  212. ip_data->phy_tx_enabled = hpd;
  213. err:
  214. spin_unlock_irqrestore(&phy_tx_lock, flags);
  215. return r;
  216. }
  217. static irqreturn_t hpd_irq_handler(int irq, void *data)
  218. {
  219. struct hdmi_ip_data *ip_data = data;
  220. hdmi_check_hpd_state(ip_data);
  221. return IRQ_HANDLED;
  222. }
  223. int ti_hdmi_4xxx_phy_enable(struct hdmi_ip_data *ip_data)
  224. {
  225. u16 r = 0;
  226. void __iomem *phy_base = hdmi_phy_base(ip_data);
  227. r = hdmi_set_phy_pwr(ip_data, HDMI_PHYPWRCMD_LDOON);
  228. if (r)
  229. return r;
  230. /*
  231. * Read address 0 in order to get the SCP reset done completed
  232. * Dummy access performed to make sure reset is done
  233. */
  234. hdmi_read_reg(phy_base, HDMI_TXPHY_TX_CTRL);
  235. /*
  236. * Write to phy address 0 to configure the clock
  237. * use HFBITCLK write HDMI_TXPHY_TX_CONTROL_FREQOUT field
  238. */
  239. REG_FLD_MOD(phy_base, HDMI_TXPHY_TX_CTRL, 0x1, 31, 30);
  240. /* Write to phy address 1 to start HDMI line (TXVALID and TMDSCLKEN) */
  241. hdmi_write_reg(phy_base, HDMI_TXPHY_DIGITAL_CTRL, 0xF0000000);
  242. /* Setup max LDO voltage */
  243. REG_FLD_MOD(phy_base, HDMI_TXPHY_POWER_CTRL, 0xB, 3, 0);
  244. /* Write to phy address 3 to change the polarity control */
  245. REG_FLD_MOD(phy_base, HDMI_TXPHY_PAD_CFG_CTRL, 0x1, 27, 27);
  246. r = request_threaded_irq(gpio_to_irq(ip_data->hpd_gpio),
  247. NULL, hpd_irq_handler,
  248. IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING |
  249. IRQF_ONESHOT, "hpd", ip_data);
  250. if (r) {
  251. DSSERR("HPD IRQ request failed\n");
  252. hdmi_set_phy_pwr(ip_data, HDMI_PHYPWRCMD_OFF);
  253. return r;
  254. }
  255. r = hdmi_check_hpd_state(ip_data);
  256. if (r) {
  257. free_irq(gpio_to_irq(ip_data->hpd_gpio), ip_data);
  258. hdmi_set_phy_pwr(ip_data, HDMI_PHYPWRCMD_OFF);
  259. return r;
  260. }
  261. return 0;
  262. }
  263. void ti_hdmi_4xxx_phy_disable(struct hdmi_ip_data *ip_data)
  264. {
  265. free_irq(gpio_to_irq(ip_data->hpd_gpio), ip_data);
  266. hdmi_set_phy_pwr(ip_data, HDMI_PHYPWRCMD_OFF);
  267. ip_data->phy_tx_enabled = false;
  268. }
  269. static int hdmi_core_ddc_init(struct hdmi_ip_data *ip_data)
  270. {
  271. void __iomem *base = hdmi_core_sys_base(ip_data);
  272. /* Turn on CLK for DDC */
  273. REG_FLD_MOD(base, HDMI_CORE_AV_DPD, 0x7, 2, 0);
  274. /* IN_PROG */
  275. if (REG_GET(base, HDMI_CORE_DDC_STATUS, 4, 4) == 1) {
  276. /* Abort transaction */
  277. REG_FLD_MOD(base, HDMI_CORE_DDC_CMD, 0xf, 3, 0);
  278. /* IN_PROG */
  279. if (hdmi_wait_for_bit_change(base, HDMI_CORE_DDC_STATUS,
  280. 4, 4, 0) != 0) {
  281. DSSERR("Timeout aborting DDC transaction\n");
  282. return -ETIMEDOUT;
  283. }
  284. }
  285. /* Clk SCL Devices */
  286. REG_FLD_MOD(base, HDMI_CORE_DDC_CMD, 0xA, 3, 0);
  287. /* HDMI_CORE_DDC_STATUS_IN_PROG */
  288. if (hdmi_wait_for_bit_change(base, HDMI_CORE_DDC_STATUS,
  289. 4, 4, 0) != 0) {
  290. DSSERR("Timeout starting SCL clock\n");
  291. return -ETIMEDOUT;
  292. }
  293. /* Clear FIFO */
  294. REG_FLD_MOD(base, HDMI_CORE_DDC_CMD, 0x9, 3, 0);
  295. /* HDMI_CORE_DDC_STATUS_IN_PROG */
  296. if (hdmi_wait_for_bit_change(base, HDMI_CORE_DDC_STATUS,
  297. 4, 4, 0) != 0) {
  298. DSSERR("Timeout clearing DDC fifo\n");
  299. return -ETIMEDOUT;
  300. }
  301. return 0;
  302. }
  303. static int hdmi_core_ddc_edid(struct hdmi_ip_data *ip_data,
  304. u8 *pedid, int ext)
  305. {
  306. void __iomem *base = hdmi_core_sys_base(ip_data);
  307. u32 i;
  308. char checksum;
  309. u32 offset = 0;
  310. /* HDMI_CORE_DDC_STATUS_IN_PROG */
  311. if (hdmi_wait_for_bit_change(base, HDMI_CORE_DDC_STATUS,
  312. 4, 4, 0) != 0) {
  313. DSSERR("Timeout waiting DDC to be ready\n");
  314. return -ETIMEDOUT;
  315. }
  316. if (ext % 2 != 0)
  317. offset = 0x80;
  318. /* Load Segment Address Register */
  319. REG_FLD_MOD(base, HDMI_CORE_DDC_SEGM, ext / 2, 7, 0);
  320. /* Load Slave Address Register */
  321. REG_FLD_MOD(base, HDMI_CORE_DDC_ADDR, 0xA0 >> 1, 7, 1);
  322. /* Load Offset Address Register */
  323. REG_FLD_MOD(base, HDMI_CORE_DDC_OFFSET, offset, 7, 0);
  324. /* Load Byte Count */
  325. REG_FLD_MOD(base, HDMI_CORE_DDC_COUNT1, 0x80, 7, 0);
  326. REG_FLD_MOD(base, HDMI_CORE_DDC_COUNT2, 0x0, 1, 0);
  327. /* Set DDC_CMD */
  328. if (ext)
  329. REG_FLD_MOD(base, HDMI_CORE_DDC_CMD, 0x4, 3, 0);
  330. else
  331. REG_FLD_MOD(base, HDMI_CORE_DDC_CMD, 0x2, 3, 0);
  332. /* HDMI_CORE_DDC_STATUS_BUS_LOW */
  333. if (REG_GET(base, HDMI_CORE_DDC_STATUS, 6, 6) == 1) {
  334. pr_err("I2C Bus Low?\n");
  335. return -EIO;
  336. }
  337. /* HDMI_CORE_DDC_STATUS_NO_ACK */
  338. if (REG_GET(base, HDMI_CORE_DDC_STATUS, 5, 5) == 1) {
  339. pr_err("I2C No Ack\n");
  340. return -EIO;
  341. }
  342. for (i = 0; i < 0x80; ++i) {
  343. int t;
  344. /* IN_PROG */
  345. if (REG_GET(base, HDMI_CORE_DDC_STATUS, 4, 4) == 0) {
  346. DSSERR("operation stopped when reading edid\n");
  347. return -EIO;
  348. }
  349. t = 0;
  350. /* FIFO_EMPTY */
  351. while (REG_GET(base, HDMI_CORE_DDC_STATUS, 2, 2) == 1) {
  352. if (t++ > 10000) {
  353. DSSERR("timeout reading edid\n");
  354. return -ETIMEDOUT;
  355. }
  356. udelay(1);
  357. }
  358. pedid[i] = REG_GET(base, HDMI_CORE_DDC_DATA, 7, 0);
  359. }
  360. checksum = 0;
  361. for (i = 0; i < 0x80; ++i)
  362. checksum += pedid[i];
  363. if (checksum != 0) {
  364. pr_err("E-EDID checksum failed!!\n");
  365. return -EIO;
  366. }
  367. return 0;
  368. }
  369. int ti_hdmi_4xxx_read_edid(struct hdmi_ip_data *ip_data,
  370. u8 *edid, int len)
  371. {
  372. int r, l;
  373. if (len < 128)
  374. return -EINVAL;
  375. r = hdmi_core_ddc_init(ip_data);
  376. if (r)
  377. return r;
  378. r = hdmi_core_ddc_edid(ip_data, edid, 0);
  379. if (r)
  380. return r;
  381. l = 128;
  382. if (len >= 128 * 2 && edid[0x7e] > 0) {
  383. r = hdmi_core_ddc_edid(ip_data, edid + 0x80, 1);
  384. if (r)
  385. return r;
  386. l += 128;
  387. }
  388. return l;
  389. }
  390. bool ti_hdmi_4xxx_detect(struct hdmi_ip_data *ip_data)
  391. {
  392. return gpio_get_value(ip_data->hpd_gpio);
  393. }
  394. static void hdmi_core_init(struct hdmi_core_video_config *video_cfg,
  395. struct hdmi_core_infoframe_avi *avi_cfg,
  396. struct hdmi_core_packet_enable_repeat *repeat_cfg)
  397. {
  398. pr_debug("Enter hdmi_core_init\n");
  399. /* video core */
  400. video_cfg->ip_bus_width = HDMI_INPUT_8BIT;
  401. video_cfg->op_dither_truc = HDMI_OUTPUTTRUNCATION_8BIT;
  402. video_cfg->deep_color_pkt = HDMI_DEEPCOLORPACKECTDISABLE;
  403. video_cfg->pkt_mode = HDMI_PACKETMODERESERVEDVALUE;
  404. video_cfg->hdmi_dvi = HDMI_DVI;
  405. video_cfg->tclk_sel_clkmult = HDMI_FPLL10IDCK;
  406. /* info frame */
  407. avi_cfg->db1_format = 0;
  408. avi_cfg->db1_active_info = 0;
  409. avi_cfg->db1_bar_info_dv = 0;
  410. avi_cfg->db1_scan_info = 0;
  411. avi_cfg->db2_colorimetry = 0;
  412. avi_cfg->db2_aspect_ratio = 0;
  413. avi_cfg->db2_active_fmt_ar = 0;
  414. avi_cfg->db3_itc = 0;
  415. avi_cfg->db3_ec = 0;
  416. avi_cfg->db3_q_range = 0;
  417. avi_cfg->db3_nup_scaling = 0;
  418. avi_cfg->db4_videocode = 0;
  419. avi_cfg->db5_pixel_repeat = 0;
  420. avi_cfg->db6_7_line_eoftop = 0 ;
  421. avi_cfg->db8_9_line_sofbottom = 0;
  422. avi_cfg->db10_11_pixel_eofleft = 0;
  423. avi_cfg->db12_13_pixel_sofright = 0;
  424. /* packet enable and repeat */
  425. repeat_cfg->audio_pkt = 0;
  426. repeat_cfg->audio_pkt_repeat = 0;
  427. repeat_cfg->avi_infoframe = 0;
  428. repeat_cfg->avi_infoframe_repeat = 0;
  429. repeat_cfg->gen_cntrl_pkt = 0;
  430. repeat_cfg->gen_cntrl_pkt_repeat = 0;
  431. repeat_cfg->generic_pkt = 0;
  432. repeat_cfg->generic_pkt_repeat = 0;
  433. }
  434. static void hdmi_core_powerdown_disable(struct hdmi_ip_data *ip_data)
  435. {
  436. pr_debug("Enter hdmi_core_powerdown_disable\n");
  437. REG_FLD_MOD(hdmi_core_sys_base(ip_data), HDMI_CORE_CTRL1, 0x0, 0, 0);
  438. }
  439. static void hdmi_core_swreset_release(struct hdmi_ip_data *ip_data)
  440. {
  441. pr_debug("Enter hdmi_core_swreset_release\n");
  442. REG_FLD_MOD(hdmi_core_sys_base(ip_data), HDMI_CORE_SYS_SRST, 0x0, 0, 0);
  443. }
  444. static void hdmi_core_swreset_assert(struct hdmi_ip_data *ip_data)
  445. {
  446. pr_debug("Enter hdmi_core_swreset_assert\n");
  447. REG_FLD_MOD(hdmi_core_sys_base(ip_data), HDMI_CORE_SYS_SRST, 0x1, 0, 0);
  448. }
  449. /* HDMI_CORE_VIDEO_CONFIG */
  450. static void hdmi_core_video_config(struct hdmi_ip_data *ip_data,
  451. struct hdmi_core_video_config *cfg)
  452. {
  453. u32 r = 0;
  454. void __iomem *core_sys_base = hdmi_core_sys_base(ip_data);
  455. /* sys_ctrl1 default configuration not tunable */
  456. r = hdmi_read_reg(core_sys_base, HDMI_CORE_CTRL1);
  457. r = FLD_MOD(r, HDMI_CORE_CTRL1_VEN_FOLLOWVSYNC, 5, 5);
  458. r = FLD_MOD(r, HDMI_CORE_CTRL1_HEN_FOLLOWHSYNC, 4, 4);
  459. r = FLD_MOD(r, HDMI_CORE_CTRL1_BSEL_24BITBUS, 2, 2);
  460. r = FLD_MOD(r, HDMI_CORE_CTRL1_EDGE_RISINGEDGE, 1, 1);
  461. hdmi_write_reg(core_sys_base, HDMI_CORE_CTRL1, r);
  462. REG_FLD_MOD(core_sys_base,
  463. HDMI_CORE_SYS_VID_ACEN, cfg->ip_bus_width, 7, 6);
  464. /* Vid_Mode */
  465. r = hdmi_read_reg(core_sys_base, HDMI_CORE_SYS_VID_MODE);
  466. /* dither truncation configuration */
  467. if (cfg->op_dither_truc > HDMI_OUTPUTTRUNCATION_12BIT) {
  468. r = FLD_MOD(r, cfg->op_dither_truc - 3, 7, 6);
  469. r = FLD_MOD(r, 1, 5, 5);
  470. } else {
  471. r = FLD_MOD(r, cfg->op_dither_truc, 7, 6);
  472. r = FLD_MOD(r, 0, 5, 5);
  473. }
  474. hdmi_write_reg(core_sys_base, HDMI_CORE_SYS_VID_MODE, r);
  475. /* HDMI_Ctrl */
  476. r = hdmi_read_reg(hdmi_av_base(ip_data), HDMI_CORE_AV_HDMI_CTRL);
  477. r = FLD_MOD(r, cfg->deep_color_pkt, 6, 6);
  478. r = FLD_MOD(r, cfg->pkt_mode, 5, 3);
  479. r = FLD_MOD(r, cfg->hdmi_dvi, 0, 0);
  480. hdmi_write_reg(hdmi_av_base(ip_data), HDMI_CORE_AV_HDMI_CTRL, r);
  481. /* TMDS_CTRL */
  482. REG_FLD_MOD(core_sys_base,
  483. HDMI_CORE_SYS_TMDS_CTRL, cfg->tclk_sel_clkmult, 6, 5);
  484. }
  485. static void hdmi_core_aux_infoframe_avi_config(struct hdmi_ip_data *ip_data)
  486. {
  487. u32 val;
  488. char sum = 0, checksum = 0;
  489. void __iomem *av_base = hdmi_av_base(ip_data);
  490. struct hdmi_core_infoframe_avi info_avi = ip_data->avi_cfg;
  491. sum += 0x82 + 0x002 + 0x00D;
  492. hdmi_write_reg(av_base, HDMI_CORE_AV_AVI_TYPE, 0x082);
  493. hdmi_write_reg(av_base, HDMI_CORE_AV_AVI_VERS, 0x002);
  494. hdmi_write_reg(av_base, HDMI_CORE_AV_AVI_LEN, 0x00D);
  495. val = (info_avi.db1_format << 5) |
  496. (info_avi.db1_active_info << 4) |
  497. (info_avi.db1_bar_info_dv << 2) |
  498. (info_avi.db1_scan_info);
  499. hdmi_write_reg(av_base, HDMI_CORE_AV_AVI_DBYTE(0), val);
  500. sum += val;
  501. val = (info_avi.db2_colorimetry << 6) |
  502. (info_avi.db2_aspect_ratio << 4) |
  503. (info_avi.db2_active_fmt_ar);
  504. hdmi_write_reg(av_base, HDMI_CORE_AV_AVI_DBYTE(1), val);
  505. sum += val;
  506. val = (info_avi.db3_itc << 7) |
  507. (info_avi.db3_ec << 4) |
  508. (info_avi.db3_q_range << 2) |
  509. (info_avi.db3_nup_scaling);
  510. hdmi_write_reg(av_base, HDMI_CORE_AV_AVI_DBYTE(2), val);
  511. sum += val;
  512. hdmi_write_reg(av_base, HDMI_CORE_AV_AVI_DBYTE(3),
  513. info_avi.db4_videocode);
  514. sum += info_avi.db4_videocode;
  515. val = info_avi.db5_pixel_repeat;
  516. hdmi_write_reg(av_base, HDMI_CORE_AV_AVI_DBYTE(4), val);
  517. sum += val;
  518. val = info_avi.db6_7_line_eoftop & 0x00FF;
  519. hdmi_write_reg(av_base, HDMI_CORE_AV_AVI_DBYTE(5), val);
  520. sum += val;
  521. val = ((info_avi.db6_7_line_eoftop >> 8) & 0x00FF);
  522. hdmi_write_reg(av_base, HDMI_CORE_AV_AVI_DBYTE(6), val);
  523. sum += val;
  524. val = info_avi.db8_9_line_sofbottom & 0x00FF;
  525. hdmi_write_reg(av_base, HDMI_CORE_AV_AVI_DBYTE(7), val);
  526. sum += val;
  527. val = ((info_avi.db8_9_line_sofbottom >> 8) & 0x00FF);
  528. hdmi_write_reg(av_base, HDMI_CORE_AV_AVI_DBYTE(8), val);
  529. sum += val;
  530. val = info_avi.db10_11_pixel_eofleft & 0x00FF;
  531. hdmi_write_reg(av_base, HDMI_CORE_AV_AVI_DBYTE(9), val);
  532. sum += val;
  533. val = ((info_avi.db10_11_pixel_eofleft >> 8) & 0x00FF);
  534. hdmi_write_reg(av_base, HDMI_CORE_AV_AVI_DBYTE(10), val);
  535. sum += val;
  536. val = info_avi.db12_13_pixel_sofright & 0x00FF;
  537. hdmi_write_reg(av_base, HDMI_CORE_AV_AVI_DBYTE(11), val);
  538. sum += val;
  539. val = ((info_avi.db12_13_pixel_sofright >> 8) & 0x00FF);
  540. hdmi_write_reg(av_base, HDMI_CORE_AV_AVI_DBYTE(12), val);
  541. sum += val;
  542. checksum = 0x100 - sum;
  543. hdmi_write_reg(av_base, HDMI_CORE_AV_AVI_CHSUM, checksum);
  544. }
  545. static void hdmi_core_av_packet_config(struct hdmi_ip_data *ip_data,
  546. struct hdmi_core_packet_enable_repeat repeat_cfg)
  547. {
  548. /* enable/repeat the infoframe */
  549. hdmi_write_reg(hdmi_av_base(ip_data), HDMI_CORE_AV_PB_CTRL1,
  550. (repeat_cfg.audio_pkt << 5) |
  551. (repeat_cfg.audio_pkt_repeat << 4) |
  552. (repeat_cfg.avi_infoframe << 1) |
  553. (repeat_cfg.avi_infoframe_repeat));
  554. /* enable/repeat the packet */
  555. hdmi_write_reg(hdmi_av_base(ip_data), HDMI_CORE_AV_PB_CTRL2,
  556. (repeat_cfg.gen_cntrl_pkt << 3) |
  557. (repeat_cfg.gen_cntrl_pkt_repeat << 2) |
  558. (repeat_cfg.generic_pkt << 1) |
  559. (repeat_cfg.generic_pkt_repeat));
  560. }
  561. static void hdmi_wp_init(struct omap_video_timings *timings,
  562. struct hdmi_video_format *video_fmt)
  563. {
  564. pr_debug("Enter hdmi_wp_init\n");
  565. timings->hbp = 0;
  566. timings->hfp = 0;
  567. timings->hsw = 0;
  568. timings->vbp = 0;
  569. timings->vfp = 0;
  570. timings->vsw = 0;
  571. video_fmt->packing_mode = HDMI_PACK_10b_RGB_YUV444;
  572. video_fmt->y_res = 0;
  573. video_fmt->x_res = 0;
  574. }
  575. int ti_hdmi_4xxx_wp_video_start(struct hdmi_ip_data *ip_data)
  576. {
  577. REG_FLD_MOD(hdmi_wp_base(ip_data), HDMI_WP_VIDEO_CFG, true, 31, 31);
  578. return 0;
  579. }
  580. void ti_hdmi_4xxx_wp_video_stop(struct hdmi_ip_data *ip_data)
  581. {
  582. REG_FLD_MOD(hdmi_wp_base(ip_data), HDMI_WP_VIDEO_CFG, false, 31, 31);
  583. }
  584. static void hdmi_wp_video_init_format(struct hdmi_video_format *video_fmt,
  585. struct omap_video_timings *timings, struct hdmi_config *param)
  586. {
  587. pr_debug("Enter hdmi_wp_video_init_format\n");
  588. video_fmt->y_res = param->timings.y_res;
  589. video_fmt->x_res = param->timings.x_res;
  590. timings->hbp = param->timings.hbp;
  591. timings->hfp = param->timings.hfp;
  592. timings->hsw = param->timings.hsw;
  593. timings->vbp = param->timings.vbp;
  594. timings->vfp = param->timings.vfp;
  595. timings->vsw = param->timings.vsw;
  596. }
  597. static void hdmi_wp_video_config_format(struct hdmi_ip_data *ip_data,
  598. struct hdmi_video_format *video_fmt)
  599. {
  600. u32 l = 0;
  601. REG_FLD_MOD(hdmi_wp_base(ip_data), HDMI_WP_VIDEO_CFG,
  602. video_fmt->packing_mode, 10, 8);
  603. l |= FLD_VAL(video_fmt->y_res, 31, 16);
  604. l |= FLD_VAL(video_fmt->x_res, 15, 0);
  605. hdmi_write_reg(hdmi_wp_base(ip_data), HDMI_WP_VIDEO_SIZE, l);
  606. }
  607. static void hdmi_wp_video_config_interface(struct hdmi_ip_data *ip_data)
  608. {
  609. u32 r;
  610. pr_debug("Enter hdmi_wp_video_config_interface\n");
  611. r = hdmi_read_reg(hdmi_wp_base(ip_data), HDMI_WP_VIDEO_CFG);
  612. r = FLD_MOD(r, ip_data->cfg.timings.vsync_pol, 7, 7);
  613. r = FLD_MOD(r, ip_data->cfg.timings.hsync_pol, 6, 6);
  614. r = FLD_MOD(r, ip_data->cfg.timings.interlace, 3, 3);
  615. r = FLD_MOD(r, 1, 1, 0); /* HDMI_TIMING_MASTER_24BIT */
  616. hdmi_write_reg(hdmi_wp_base(ip_data), HDMI_WP_VIDEO_CFG, r);
  617. }
  618. static void hdmi_wp_video_config_timing(struct hdmi_ip_data *ip_data,
  619. struct omap_video_timings *timings)
  620. {
  621. u32 timing_h = 0;
  622. u32 timing_v = 0;
  623. pr_debug("Enter hdmi_wp_video_config_timing\n");
  624. timing_h |= FLD_VAL(timings->hbp, 31, 20);
  625. timing_h |= FLD_VAL(timings->hfp, 19, 8);
  626. timing_h |= FLD_VAL(timings->hsw, 7, 0);
  627. hdmi_write_reg(hdmi_wp_base(ip_data), HDMI_WP_VIDEO_TIMING_H, timing_h);
  628. timing_v |= FLD_VAL(timings->vbp, 31, 20);
  629. timing_v |= FLD_VAL(timings->vfp, 19, 8);
  630. timing_v |= FLD_VAL(timings->vsw, 7, 0);
  631. hdmi_write_reg(hdmi_wp_base(ip_data), HDMI_WP_VIDEO_TIMING_V, timing_v);
  632. }
  633. void ti_hdmi_4xxx_basic_configure(struct hdmi_ip_data *ip_data)
  634. {
  635. /* HDMI */
  636. struct omap_video_timings video_timing;
  637. struct hdmi_video_format video_format;
  638. /* HDMI core */
  639. struct hdmi_core_infoframe_avi avi_cfg = ip_data->avi_cfg;
  640. struct hdmi_core_video_config v_core_cfg;
  641. struct hdmi_core_packet_enable_repeat repeat_cfg;
  642. struct hdmi_config *cfg = &ip_data->cfg;
  643. hdmi_wp_init(&video_timing, &video_format);
  644. hdmi_core_init(&v_core_cfg,
  645. &avi_cfg,
  646. &repeat_cfg);
  647. hdmi_wp_video_init_format(&video_format, &video_timing, cfg);
  648. hdmi_wp_video_config_timing(ip_data, &video_timing);
  649. /* video config */
  650. video_format.packing_mode = HDMI_PACK_24b_RGB_YUV444_YUV422;
  651. hdmi_wp_video_config_format(ip_data, &video_format);
  652. hdmi_wp_video_config_interface(ip_data);
  653. /*
  654. * configure core video part
  655. * set software reset in the core
  656. */
  657. hdmi_core_swreset_assert(ip_data);
  658. /* power down off */
  659. hdmi_core_powerdown_disable(ip_data);
  660. v_core_cfg.pkt_mode = HDMI_PACKETMODE24BITPERPIXEL;
  661. v_core_cfg.hdmi_dvi = cfg->cm.mode;
  662. hdmi_core_video_config(ip_data, &v_core_cfg);
  663. /* release software reset in the core */
  664. hdmi_core_swreset_release(ip_data);
  665. /*
  666. * configure packet
  667. * info frame video see doc CEA861-D page 65
  668. */
  669. avi_cfg.db1_format = HDMI_INFOFRAME_AVI_DB1Y_RGB;
  670. avi_cfg.db1_active_info =
  671. HDMI_INFOFRAME_AVI_DB1A_ACTIVE_FORMAT_OFF;
  672. avi_cfg.db1_bar_info_dv = HDMI_INFOFRAME_AVI_DB1B_NO;
  673. avi_cfg.db1_scan_info = HDMI_INFOFRAME_AVI_DB1S_0;
  674. avi_cfg.db2_colorimetry = HDMI_INFOFRAME_AVI_DB2C_NO;
  675. avi_cfg.db2_aspect_ratio = HDMI_INFOFRAME_AVI_DB2M_NO;
  676. avi_cfg.db2_active_fmt_ar = HDMI_INFOFRAME_AVI_DB2R_SAME;
  677. avi_cfg.db3_itc = HDMI_INFOFRAME_AVI_DB3ITC_NO;
  678. avi_cfg.db3_ec = HDMI_INFOFRAME_AVI_DB3EC_XVYUV601;
  679. avi_cfg.db3_q_range = HDMI_INFOFRAME_AVI_DB3Q_DEFAULT;
  680. avi_cfg.db3_nup_scaling = HDMI_INFOFRAME_AVI_DB3SC_NO;
  681. avi_cfg.db4_videocode = cfg->cm.code;
  682. avi_cfg.db5_pixel_repeat = HDMI_INFOFRAME_AVI_DB5PR_NO;
  683. avi_cfg.db6_7_line_eoftop = 0;
  684. avi_cfg.db8_9_line_sofbottom = 0;
  685. avi_cfg.db10_11_pixel_eofleft = 0;
  686. avi_cfg.db12_13_pixel_sofright = 0;
  687. hdmi_core_aux_infoframe_avi_config(ip_data);
  688. /* enable/repeat the infoframe */
  689. repeat_cfg.avi_infoframe = HDMI_PACKETENABLE;
  690. repeat_cfg.avi_infoframe_repeat = HDMI_PACKETREPEATON;
  691. /* wakeup */
  692. repeat_cfg.audio_pkt = HDMI_PACKETENABLE;
  693. repeat_cfg.audio_pkt_repeat = HDMI_PACKETREPEATON;
  694. hdmi_core_av_packet_config(ip_data, repeat_cfg);
  695. }
  696. void ti_hdmi_4xxx_wp_dump(struct hdmi_ip_data *ip_data, struct seq_file *s)
  697. {
  698. #define DUMPREG(r) seq_printf(s, "%-35s %08x\n", #r,\
  699. hdmi_read_reg(hdmi_wp_base(ip_data), r))
  700. DUMPREG(HDMI_WP_REVISION);
  701. DUMPREG(HDMI_WP_SYSCONFIG);
  702. DUMPREG(HDMI_WP_IRQSTATUS_RAW);
  703. DUMPREG(HDMI_WP_IRQSTATUS);
  704. DUMPREG(HDMI_WP_PWR_CTRL);
  705. DUMPREG(HDMI_WP_IRQENABLE_SET);
  706. DUMPREG(HDMI_WP_VIDEO_CFG);
  707. DUMPREG(HDMI_WP_VIDEO_SIZE);
  708. DUMPREG(HDMI_WP_VIDEO_TIMING_H);
  709. DUMPREG(HDMI_WP_VIDEO_TIMING_V);
  710. DUMPREG(HDMI_WP_WP_CLK);
  711. DUMPREG(HDMI_WP_AUDIO_CFG);
  712. DUMPREG(HDMI_WP_AUDIO_CFG2);
  713. DUMPREG(HDMI_WP_AUDIO_CTRL);
  714. DUMPREG(HDMI_WP_AUDIO_DATA);
  715. }
  716. void ti_hdmi_4xxx_pll_dump(struct hdmi_ip_data *ip_data, struct seq_file *s)
  717. {
  718. #define DUMPPLL(r) seq_printf(s, "%-35s %08x\n", #r,\
  719. hdmi_read_reg(hdmi_pll_base(ip_data), r))
  720. DUMPPLL(PLLCTRL_PLL_CONTROL);
  721. DUMPPLL(PLLCTRL_PLL_STATUS);
  722. DUMPPLL(PLLCTRL_PLL_GO);
  723. DUMPPLL(PLLCTRL_CFG1);
  724. DUMPPLL(PLLCTRL_CFG2);
  725. DUMPPLL(PLLCTRL_CFG3);
  726. DUMPPLL(PLLCTRL_CFG4);
  727. }
  728. void ti_hdmi_4xxx_core_dump(struct hdmi_ip_data *ip_data, struct seq_file *s)
  729. {
  730. int i;
  731. #define CORE_REG(i, name) name(i)
  732. #define DUMPCORE(r) seq_printf(s, "%-35s %08x\n", #r,\
  733. hdmi_read_reg(hdmi_core_sys_base(ip_data), r))
  734. #define DUMPCOREAV(r) seq_printf(s, "%-35s %08x\n", #r,\
  735. hdmi_read_reg(hdmi_av_base(ip_data), r))
  736. #define DUMPCOREAV2(i, r) seq_printf(s, "%s[%d]%*s %08x\n", #r, i, \
  737. (i < 10) ? 32 - strlen(#r) : 31 - strlen(#r), " ", \
  738. hdmi_read_reg(hdmi_av_base(ip_data), CORE_REG(i, r)))
  739. DUMPCORE(HDMI_CORE_SYS_VND_IDL);
  740. DUMPCORE(HDMI_CORE_SYS_DEV_IDL);
  741. DUMPCORE(HDMI_CORE_SYS_DEV_IDH);
  742. DUMPCORE(HDMI_CORE_SYS_DEV_REV);
  743. DUMPCORE(HDMI_CORE_SYS_SRST);
  744. DUMPCORE(HDMI_CORE_CTRL1);
  745. DUMPCORE(HDMI_CORE_SYS_SYS_STAT);
  746. DUMPCORE(HDMI_CORE_SYS_DE_DLY);
  747. DUMPCORE(HDMI_CORE_SYS_DE_CTRL);
  748. DUMPCORE(HDMI_CORE_SYS_DE_TOP);
  749. DUMPCORE(HDMI_CORE_SYS_DE_CNTL);
  750. DUMPCORE(HDMI_CORE_SYS_DE_CNTH);
  751. DUMPCORE(HDMI_CORE_SYS_DE_LINL);
  752. DUMPCORE(HDMI_CORE_SYS_DE_LINH_1);
  753. DUMPCORE(HDMI_CORE_SYS_VID_ACEN);
  754. DUMPCORE(HDMI_CORE_SYS_VID_MODE);
  755. DUMPCORE(HDMI_CORE_SYS_INTR_STATE);
  756. DUMPCORE(HDMI_CORE_SYS_INTR1);
  757. DUMPCORE(HDMI_CORE_SYS_INTR2);
  758. DUMPCORE(HDMI_CORE_SYS_INTR3);
  759. DUMPCORE(HDMI_CORE_SYS_INTR4);
  760. DUMPCORE(HDMI_CORE_SYS_UMASK1);
  761. DUMPCORE(HDMI_CORE_SYS_TMDS_CTRL);
  762. DUMPCORE(HDMI_CORE_DDC_ADDR);
  763. DUMPCORE(HDMI_CORE_DDC_SEGM);
  764. DUMPCORE(HDMI_CORE_DDC_OFFSET);
  765. DUMPCORE(HDMI_CORE_DDC_COUNT1);
  766. DUMPCORE(HDMI_CORE_DDC_COUNT2);
  767. DUMPCORE(HDMI_CORE_DDC_STATUS);
  768. DUMPCORE(HDMI_CORE_DDC_CMD);
  769. DUMPCORE(HDMI_CORE_DDC_DATA);
  770. DUMPCOREAV(HDMI_CORE_AV_ACR_CTRL);
  771. DUMPCOREAV(HDMI_CORE_AV_FREQ_SVAL);
  772. DUMPCOREAV(HDMI_CORE_AV_N_SVAL1);
  773. DUMPCOREAV(HDMI_CORE_AV_N_SVAL2);
  774. DUMPCOREAV(HDMI_CORE_AV_N_SVAL3);
  775. DUMPCOREAV(HDMI_CORE_AV_CTS_SVAL1);
  776. DUMPCOREAV(HDMI_CORE_AV_CTS_SVAL2);
  777. DUMPCOREAV(HDMI_CORE_AV_CTS_SVAL3);
  778. DUMPCOREAV(HDMI_CORE_AV_CTS_HVAL1);
  779. DUMPCOREAV(HDMI_CORE_AV_CTS_HVAL2);
  780. DUMPCOREAV(HDMI_CORE_AV_CTS_HVAL3);
  781. DUMPCOREAV(HDMI_CORE_AV_AUD_MODE);
  782. DUMPCOREAV(HDMI_CORE_AV_SPDIF_CTRL);
  783. DUMPCOREAV(HDMI_CORE_AV_HW_SPDIF_FS);
  784. DUMPCOREAV(HDMI_CORE_AV_SWAP_I2S);
  785. DUMPCOREAV(HDMI_CORE_AV_SPDIF_ERTH);
  786. DUMPCOREAV(HDMI_CORE_AV_I2S_IN_MAP);
  787. DUMPCOREAV(HDMI_CORE_AV_I2S_IN_CTRL);
  788. DUMPCOREAV(HDMI_CORE_AV_I2S_CHST0);
  789. DUMPCOREAV(HDMI_CORE_AV_I2S_CHST1);
  790. DUMPCOREAV(HDMI_CORE_AV_I2S_CHST2);
  791. DUMPCOREAV(HDMI_CORE_AV_I2S_CHST4);
  792. DUMPCOREAV(HDMI_CORE_AV_I2S_CHST5);
  793. DUMPCOREAV(HDMI_CORE_AV_ASRC);
  794. DUMPCOREAV(HDMI_CORE_AV_I2S_IN_LEN);
  795. DUMPCOREAV(HDMI_CORE_AV_HDMI_CTRL);
  796. DUMPCOREAV(HDMI_CORE_AV_AUDO_TXSTAT);
  797. DUMPCOREAV(HDMI_CORE_AV_AUD_PAR_BUSCLK_1);
  798. DUMPCOREAV(HDMI_CORE_AV_AUD_PAR_BUSCLK_2);
  799. DUMPCOREAV(HDMI_CORE_AV_AUD_PAR_BUSCLK_3);
  800. DUMPCOREAV(HDMI_CORE_AV_TEST_TXCTRL);
  801. DUMPCOREAV(HDMI_CORE_AV_DPD);
  802. DUMPCOREAV(HDMI_CORE_AV_PB_CTRL1);
  803. DUMPCOREAV(HDMI_CORE_AV_PB_CTRL2);
  804. DUMPCOREAV(HDMI_CORE_AV_AVI_TYPE);
  805. DUMPCOREAV(HDMI_CORE_AV_AVI_VERS);
  806. DUMPCOREAV(HDMI_CORE_AV_AVI_LEN);
  807. DUMPCOREAV(HDMI_CORE_AV_AVI_CHSUM);
  808. for (i = 0; i < HDMI_CORE_AV_AVI_DBYTE_NELEMS; i++)
  809. DUMPCOREAV2(i, HDMI_CORE_AV_AVI_DBYTE);
  810. DUMPCOREAV(HDMI_CORE_AV_SPD_TYPE);
  811. DUMPCOREAV(HDMI_CORE_AV_SPD_VERS);
  812. DUMPCOREAV(HDMI_CORE_AV_SPD_LEN);
  813. DUMPCOREAV(HDMI_CORE_AV_SPD_CHSUM);
  814. for (i = 0; i < HDMI_CORE_AV_SPD_DBYTE_NELEMS; i++)
  815. DUMPCOREAV2(i, HDMI_CORE_AV_SPD_DBYTE);
  816. DUMPCOREAV(HDMI_CORE_AV_AUDIO_TYPE);
  817. DUMPCOREAV(HDMI_CORE_AV_AUDIO_VERS);
  818. DUMPCOREAV(HDMI_CORE_AV_AUDIO_LEN);
  819. DUMPCOREAV(HDMI_CORE_AV_AUDIO_CHSUM);
  820. for (i = 0; i < HDMI_CORE_AV_AUD_DBYTE_NELEMS; i++)
  821. DUMPCOREAV2(i, HDMI_CORE_AV_AUD_DBYTE);
  822. DUMPCOREAV(HDMI_CORE_AV_MPEG_TYPE);
  823. DUMPCOREAV(HDMI_CORE_AV_MPEG_VERS);
  824. DUMPCOREAV(HDMI_CORE_AV_MPEG_LEN);
  825. DUMPCOREAV(HDMI_CORE_AV_MPEG_CHSUM);
  826. for (i = 0; i < HDMI_CORE_AV_MPEG_DBYTE_NELEMS; i++)
  827. DUMPCOREAV2(i, HDMI_CORE_AV_MPEG_DBYTE);
  828. for (i = 0; i < HDMI_CORE_AV_GEN_DBYTE_NELEMS; i++)
  829. DUMPCOREAV2(i, HDMI_CORE_AV_GEN_DBYTE);
  830. DUMPCOREAV(HDMI_CORE_AV_CP_BYTE1);
  831. for (i = 0; i < HDMI_CORE_AV_GEN2_DBYTE_NELEMS; i++)
  832. DUMPCOREAV2(i, HDMI_CORE_AV_GEN2_DBYTE);
  833. DUMPCOREAV(HDMI_CORE_AV_CEC_ADDR_ID);
  834. }
  835. void ti_hdmi_4xxx_phy_dump(struct hdmi_ip_data *ip_data, struct seq_file *s)
  836. {
  837. #define DUMPPHY(r) seq_printf(s, "%-35s %08x\n", #r,\
  838. hdmi_read_reg(hdmi_phy_base(ip_data), r))
  839. DUMPPHY(HDMI_TXPHY_TX_CTRL);
  840. DUMPPHY(HDMI_TXPHY_DIGITAL_CTRL);
  841. DUMPPHY(HDMI_TXPHY_POWER_CTRL);
  842. DUMPPHY(HDMI_TXPHY_PAD_CFG_CTRL);
  843. }
  844. #if defined(CONFIG_OMAP4_DSS_HDMI_AUDIO)
  845. static void ti_hdmi_4xxx_wp_audio_config_format(struct hdmi_ip_data *ip_data,
  846. struct hdmi_audio_format *aud_fmt)
  847. {
  848. u32 r;
  849. DSSDBG("Enter hdmi_wp_audio_config_format\n");
  850. r = hdmi_read_reg(hdmi_wp_base(ip_data), HDMI_WP_AUDIO_CFG);
  851. r = FLD_MOD(r, aud_fmt->stereo_channels, 26, 24);
  852. r = FLD_MOD(r, aud_fmt->active_chnnls_msk, 23, 16);
  853. r = FLD_MOD(r, aud_fmt->en_sig_blk_strt_end, 5, 5);
  854. r = FLD_MOD(r, aud_fmt->type, 4, 4);
  855. r = FLD_MOD(r, aud_fmt->justification, 3, 3);
  856. r = FLD_MOD(r, aud_fmt->sample_order, 2, 2);
  857. r = FLD_MOD(r, aud_fmt->samples_per_word, 1, 1);
  858. r = FLD_MOD(r, aud_fmt->sample_size, 0, 0);
  859. hdmi_write_reg(hdmi_wp_base(ip_data), HDMI_WP_AUDIO_CFG, r);
  860. }
  861. static void ti_hdmi_4xxx_wp_audio_config_dma(struct hdmi_ip_data *ip_data,
  862. struct hdmi_audio_dma *aud_dma)
  863. {
  864. u32 r;
  865. DSSDBG("Enter hdmi_wp_audio_config_dma\n");
  866. r = hdmi_read_reg(hdmi_wp_base(ip_data), HDMI_WP_AUDIO_CFG2);
  867. r = FLD_MOD(r, aud_dma->transfer_size, 15, 8);
  868. r = FLD_MOD(r, aud_dma->block_size, 7, 0);
  869. hdmi_write_reg(hdmi_wp_base(ip_data), HDMI_WP_AUDIO_CFG2, r);
  870. r = hdmi_read_reg(hdmi_wp_base(ip_data), HDMI_WP_AUDIO_CTRL);
  871. r = FLD_MOD(r, aud_dma->mode, 9, 9);
  872. r = FLD_MOD(r, aud_dma->fifo_threshold, 8, 0);
  873. hdmi_write_reg(hdmi_wp_base(ip_data), HDMI_WP_AUDIO_CTRL, r);
  874. }
  875. static void ti_hdmi_4xxx_core_audio_config(struct hdmi_ip_data *ip_data,
  876. struct hdmi_core_audio_config *cfg)
  877. {
  878. u32 r;
  879. void __iomem *av_base = hdmi_av_base(ip_data);
  880. /*
  881. * Parameters for generation of Audio Clock Recovery packets
  882. */
  883. REG_FLD_MOD(av_base, HDMI_CORE_AV_N_SVAL1, cfg->n, 7, 0);
  884. REG_FLD_MOD(av_base, HDMI_CORE_AV_N_SVAL2, cfg->n >> 8, 7, 0);
  885. REG_FLD_MOD(av_base, HDMI_CORE_AV_N_SVAL3, cfg->n >> 16, 7, 0);
  886. if (cfg->cts_mode == HDMI_AUDIO_CTS_MODE_SW) {
  887. REG_FLD_MOD(av_base, HDMI_CORE_AV_CTS_SVAL1, cfg->cts, 7, 0);
  888. REG_FLD_MOD(av_base,
  889. HDMI_CORE_AV_CTS_SVAL2, cfg->cts >> 8, 7, 0);
  890. REG_FLD_MOD(av_base,
  891. HDMI_CORE_AV_CTS_SVAL3, cfg->cts >> 16, 7, 0);
  892. } else {
  893. REG_FLD_MOD(av_base, HDMI_CORE_AV_AUD_PAR_BUSCLK_1,
  894. cfg->aud_par_busclk, 7, 0);
  895. REG_FLD_MOD(av_base, HDMI_CORE_AV_AUD_PAR_BUSCLK_2,
  896. (cfg->aud_par_busclk >> 8), 7, 0);
  897. REG_FLD_MOD(av_base, HDMI_CORE_AV_AUD_PAR_BUSCLK_3,
  898. (cfg->aud_par_busclk >> 16), 7, 0);
  899. }
  900. /* Set ACR clock divisor */
  901. REG_FLD_MOD(av_base,
  902. HDMI_CORE_AV_FREQ_SVAL, cfg->mclk_mode, 2, 0);
  903. r = hdmi_read_reg(av_base, HDMI_CORE_AV_ACR_CTRL);
  904. /*
  905. * Use TMDS clock for ACR packets. For devices that use
  906. * the MCLK, this is the first part of the MCLK initialization.
  907. */
  908. r = FLD_MOD(r, 0, 2, 2);
  909. r = FLD_MOD(r, cfg->en_acr_pkt, 1, 1);
  910. r = FLD_MOD(r, cfg->cts_mode, 0, 0);
  911. hdmi_write_reg(av_base, HDMI_CORE_AV_ACR_CTRL, r);
  912. /* For devices using MCLK, this completes its initialization. */
  913. if (cfg->use_mclk)
  914. REG_FLD_MOD(av_base, HDMI_CORE_AV_ACR_CTRL, 1, 2, 2);
  915. /* Override of SPDIF sample frequency with value in I2S_CHST4 */
  916. REG_FLD_MOD(av_base, HDMI_CORE_AV_SPDIF_CTRL,
  917. cfg->fs_override, 1, 1);
  918. /*
  919. * Set IEC-60958-3 channel status word. It is passed to the IP
  920. * just as it is received. The user of the driver is responsible
  921. * for its contents.
  922. */
  923. hdmi_write_reg(av_base, HDMI_CORE_AV_I2S_CHST0,
  924. cfg->iec60958_cfg->status[0]);
  925. hdmi_write_reg(av_base, HDMI_CORE_AV_I2S_CHST1,
  926. cfg->iec60958_cfg->status[1]);
  927. hdmi_write_reg(av_base, HDMI_CORE_AV_I2S_CHST2,
  928. cfg->iec60958_cfg->status[2]);
  929. /* yes, this is correct: status[3] goes to CHST4 register */
  930. hdmi_write_reg(av_base, HDMI_CORE_AV_I2S_CHST4,
  931. cfg->iec60958_cfg->status[3]);
  932. /* yes, this is correct: status[4] goes to CHST5 register */
  933. hdmi_write_reg(av_base, HDMI_CORE_AV_I2S_CHST5,
  934. cfg->iec60958_cfg->status[4]);
  935. /* set I2S parameters */
  936. r = hdmi_read_reg(av_base, HDMI_CORE_AV_I2S_IN_CTRL);
  937. r = FLD_MOD(r, cfg->i2s_cfg.sck_edge_mode, 6, 6);
  938. r = FLD_MOD(r, cfg->i2s_cfg.vbit, 4, 4);
  939. r = FLD_MOD(r, cfg->i2s_cfg.justification, 2, 2);
  940. r = FLD_MOD(r, cfg->i2s_cfg.direction, 1, 1);
  941. r = FLD_MOD(r, cfg->i2s_cfg.shift, 0, 0);
  942. hdmi_write_reg(av_base, HDMI_CORE_AV_I2S_IN_CTRL, r);
  943. REG_FLD_MOD(av_base, HDMI_CORE_AV_I2S_IN_LEN,
  944. cfg->i2s_cfg.in_length_bits, 3, 0);
  945. /* Audio channels and mode parameters */
  946. REG_FLD_MOD(av_base, HDMI_CORE_AV_HDMI_CTRL, cfg->layout, 2, 1);
  947. r = hdmi_read_reg(av_base, HDMI_CORE_AV_AUD_MODE);
  948. r = FLD_MOD(r, cfg->i2s_cfg.active_sds, 7, 4);
  949. r = FLD_MOD(r, cfg->en_dsd_audio, 3, 3);
  950. r = FLD_MOD(r, cfg->en_parallel_aud_input, 2, 2);
  951. r = FLD_MOD(r, cfg->en_spdif, 1, 1);
  952. hdmi_write_reg(av_base, HDMI_CORE_AV_AUD_MODE, r);
  953. /* Audio channel mappings */
  954. /* TODO: Make channel mapping dynamic. For now, map channels
  955. * in the ALSA order: FL/FR/RL/RR/C/LFE/SL/SR. Remapping is needed as
  956. * HDMI speaker order is different. See CEA-861 Section 6.6.2.
  957. */
  958. hdmi_write_reg(av_base, HDMI_CORE_AV_I2S_IN_MAP, 0x78);
  959. REG_FLD_MOD(av_base, HDMI_CORE_AV_SWAP_I2S, 1, 5, 5);
  960. }
  961. static void ti_hdmi_4xxx_core_audio_infoframe_cfg(struct hdmi_ip_data *ip_data,
  962. struct snd_cea_861_aud_if *info_aud)
  963. {
  964. u8 sum = 0, checksum = 0;
  965. void __iomem *av_base = hdmi_av_base(ip_data);
  966. /*
  967. * Set audio info frame type, version and length as
  968. * described in HDMI 1.4a Section 8.2.2 specification.
  969. * Checksum calculation is defined in Section 5.3.5.
  970. */
  971. hdmi_write_reg(av_base, HDMI_CORE_AV_AUDIO_TYPE, 0x84);
  972. hdmi_write_reg(av_base, HDMI_CORE_AV_AUDIO_VERS, 0x01);
  973. hdmi_write_reg(av_base, HDMI_CORE_AV_AUDIO_LEN, 0x0a);
  974. sum += 0x84 + 0x001 + 0x00a;
  975. hdmi_write_reg(av_base, HDMI_CORE_AV_AUD_DBYTE(0),
  976. info_aud->db1_ct_cc);
  977. sum += info_aud->db1_ct_cc;
  978. hdmi_write_reg(av_base, HDMI_CORE_AV_AUD_DBYTE(1),
  979. info_aud->db2_sf_ss);
  980. sum += info_aud->db2_sf_ss;
  981. hdmi_write_reg(av_base, HDMI_CORE_AV_AUD_DBYTE(2), info_aud->db3);
  982. sum += info_aud->db3;
  983. hdmi_write_reg(av_base, HDMI_CORE_AV_AUD_DBYTE(3), info_aud->db4_ca);
  984. sum += info_aud->db4_ca;
  985. hdmi_write_reg(av_base, HDMI_CORE_AV_AUD_DBYTE(4),
  986. info_aud->db5_dminh_lsv);
  987. sum += info_aud->db5_dminh_lsv;
  988. hdmi_write_reg(av_base, HDMI_CORE_AV_AUD_DBYTE(5), 0x00);
  989. hdmi_write_reg(av_base, HDMI_CORE_AV_AUD_DBYTE(6), 0x00);
  990. hdmi_write_reg(av_base, HDMI_CORE_AV_AUD_DBYTE(7), 0x00);
  991. hdmi_write_reg(av_base, HDMI_CORE_AV_AUD_DBYTE(8), 0x00);
  992. hdmi_write_reg(av_base, HDMI_CORE_AV_AUD_DBYTE(9), 0x00);
  993. checksum = 0x100 - sum;
  994. hdmi_write_reg(av_base,
  995. HDMI_CORE_AV_AUDIO_CHSUM, checksum);
  996. /*
  997. * TODO: Add MPEG and SPD enable and repeat cfg when EDID parsing
  998. * is available.
  999. */
  1000. }
  1001. int ti_hdmi_4xxx_audio_config(struct hdmi_ip_data *ip_data,
  1002. struct omap_dss_audio *audio)
  1003. {
  1004. struct hdmi_audio_format audio_format;
  1005. struct hdmi_audio_dma audio_dma;
  1006. struct hdmi_core_audio_config core;
  1007. int err, n, cts, channel_count;
  1008. unsigned int fs_nr;
  1009. bool word_length_16b = false;
  1010. if (!audio || !audio->iec || !audio->cea || !ip_data)
  1011. return -EINVAL;
  1012. core.iec60958_cfg = audio->iec;
  1013. /*
  1014. * In the IEC-60958 status word, check if the audio sample word length
  1015. * is 16-bit as several optimizations can be performed in such case.
  1016. */
  1017. if (!(audio->iec->status[4] & IEC958_AES4_CON_MAX_WORDLEN_24))
  1018. if (audio->iec->status[4] & IEC958_AES4_CON_WORDLEN_20_16)
  1019. word_length_16b = true;
  1020. /* I2S configuration. See Phillips' specification */
  1021. if (word_length_16b)
  1022. core.i2s_cfg.justification = HDMI_AUDIO_JUSTIFY_LEFT;
  1023. else
  1024. core.i2s_cfg.justification = HDMI_AUDIO_JUSTIFY_RIGHT;
  1025. /*
  1026. * The I2S input word length is twice the lenght given in the IEC-60958
  1027. * status word. If the word size is greater than
  1028. * 20 bits, increment by one.
  1029. */
  1030. core.i2s_cfg.in_length_bits = audio->iec->status[4]
  1031. & IEC958_AES4_CON_WORDLEN;
  1032. if (audio->iec->status[4] & IEC958_AES4_CON_MAX_WORDLEN_24)
  1033. core.i2s_cfg.in_length_bits++;
  1034. core.i2s_cfg.sck_edge_mode = HDMI_AUDIO_I2S_SCK_EDGE_RISING;
  1035. core.i2s_cfg.vbit = HDMI_AUDIO_I2S_VBIT_FOR_PCM;
  1036. core.i2s_cfg.direction = HDMI_AUDIO_I2S_MSB_SHIFTED_FIRST;
  1037. core.i2s_cfg.shift = HDMI_AUDIO_I2S_FIRST_BIT_SHIFT;
  1038. /* convert sample frequency to a number */
  1039. switch (audio->iec->status[3] & IEC958_AES3_CON_FS) {
  1040. case IEC958_AES3_CON_FS_32000:
  1041. fs_nr = 32000;
  1042. break;
  1043. case IEC958_AES3_CON_FS_44100:
  1044. fs_nr = 44100;
  1045. break;
  1046. case IEC958_AES3_CON_FS_48000:
  1047. fs_nr = 48000;
  1048. break;
  1049. case IEC958_AES3_CON_FS_88200:
  1050. fs_nr = 88200;
  1051. break;
  1052. case IEC958_AES3_CON_FS_96000:
  1053. fs_nr = 96000;
  1054. break;
  1055. case IEC958_AES3_CON_FS_176400:
  1056. fs_nr = 176400;
  1057. break;
  1058. case IEC958_AES3_CON_FS_192000:
  1059. fs_nr = 192000;
  1060. break;
  1061. default:
  1062. return -EINVAL;
  1063. }
  1064. err = hdmi_compute_acr(fs_nr, &n, &cts);
  1065. /* Audio clock regeneration settings */
  1066. core.n = n;
  1067. core.cts = cts;
  1068. if (dss_has_feature(FEAT_HDMI_CTS_SWMODE)) {
  1069. core.aud_par_busclk = 0;
  1070. core.cts_mode = HDMI_AUDIO_CTS_MODE_SW;
  1071. core.use_mclk = dss_has_feature(FEAT_HDMI_AUDIO_USE_MCLK);
  1072. } else {
  1073. core.aud_par_busclk = (((128 * 31) - 1) << 8);
  1074. core.cts_mode = HDMI_AUDIO_CTS_MODE_HW;
  1075. core.use_mclk = true;
  1076. }
  1077. if (core.use_mclk)
  1078. core.mclk_mode = HDMI_AUDIO_MCLK_128FS;
  1079. /* Audio channels settings */
  1080. channel_count = (audio->cea->db1_ct_cc &
  1081. CEA861_AUDIO_INFOFRAME_DB1CC) + 1;
  1082. switch (channel_count) {
  1083. case 2:
  1084. audio_format.active_chnnls_msk = 0x03;
  1085. break;
  1086. case 3:
  1087. audio_format.active_chnnls_msk = 0x07;
  1088. break;
  1089. case 4:
  1090. audio_format.active_chnnls_msk = 0x0f;
  1091. break;
  1092. case 5:
  1093. audio_format.active_chnnls_msk = 0x1f;
  1094. break;
  1095. case 6:
  1096. audio_format.active_chnnls_msk = 0x3f;
  1097. break;
  1098. case 7:
  1099. audio_format.active_chnnls_msk = 0x7f;
  1100. break;
  1101. case 8:
  1102. audio_format.active_chnnls_msk = 0xff;
  1103. break;
  1104. default:
  1105. return -EINVAL;
  1106. }
  1107. /*
  1108. * the HDMI IP needs to enable four stereo channels when transmitting
  1109. * more than 2 audio channels
  1110. */
  1111. if (channel_count == 2) {
  1112. audio_format.stereo_channels = HDMI_AUDIO_STEREO_ONECHANNEL;
  1113. core.i2s_cfg.active_sds = HDMI_AUDIO_I2S_SD0_EN;
  1114. core.layout = HDMI_AUDIO_LAYOUT_2CH;
  1115. } else {
  1116. audio_format.stereo_channels = HDMI_AUDIO_STEREO_FOURCHANNELS;
  1117. core.i2s_cfg.active_sds = HDMI_AUDIO_I2S_SD0_EN |
  1118. HDMI_AUDIO_I2S_SD1_EN | HDMI_AUDIO_I2S_SD2_EN |
  1119. HDMI_AUDIO_I2S_SD3_EN;
  1120. core.layout = HDMI_AUDIO_LAYOUT_8CH;
  1121. }
  1122. core.en_spdif = false;
  1123. /* use sample frequency from channel status word */
  1124. core.fs_override = true;
  1125. /* enable ACR packets */
  1126. core.en_acr_pkt = true;
  1127. /* disable direct streaming digital audio */
  1128. core.en_dsd_audio = false;
  1129. /* use parallel audio interface */
  1130. core.en_parallel_aud_input = true;
  1131. /* DMA settings */
  1132. if (word_length_16b)
  1133. audio_dma.transfer_size = 0x10;
  1134. else
  1135. audio_dma.transfer_size = 0x20;
  1136. audio_dma.block_size = 0xC0;
  1137. audio_dma.mode = HDMI_AUDIO_TRANSF_DMA;
  1138. audio_dma.fifo_threshold = 0x20; /* in number of samples */
  1139. /* audio FIFO format settings */
  1140. if (word_length_16b) {
  1141. audio_format.samples_per_word = HDMI_AUDIO_ONEWORD_TWOSAMPLES;
  1142. audio_format.sample_size = HDMI_AUDIO_SAMPLE_16BITS;
  1143. audio_format.justification = HDMI_AUDIO_JUSTIFY_LEFT;
  1144. } else {
  1145. audio_format.samples_per_word = HDMI_AUDIO_ONEWORD_ONESAMPLE;
  1146. audio_format.sample_size = HDMI_AUDIO_SAMPLE_24BITS;
  1147. audio_format.justification = HDMI_AUDIO_JUSTIFY_RIGHT;
  1148. }
  1149. audio_format.type = HDMI_AUDIO_TYPE_LPCM;
  1150. audio_format.sample_order = HDMI_AUDIO_SAMPLE_LEFT_FIRST;
  1151. /* disable start/stop signals of IEC 60958 blocks */
  1152. audio_format.en_sig_blk_strt_end = HDMI_AUDIO_BLOCK_SIG_STARTEND_ON;
  1153. /* configure DMA and audio FIFO format*/
  1154. ti_hdmi_4xxx_wp_audio_config_dma(ip_data, &audio_dma);
  1155. ti_hdmi_4xxx_wp_audio_config_format(ip_data, &audio_format);
  1156. /* configure the core*/
  1157. ti_hdmi_4xxx_core_audio_config(ip_data, &core);
  1158. /* configure CEA 861 audio infoframe*/
  1159. ti_hdmi_4xxx_core_audio_infoframe_cfg(ip_data, audio->cea);
  1160. return 0;
  1161. }
  1162. int ti_hdmi_4xxx_wp_audio_enable(struct hdmi_ip_data *ip_data)
  1163. {
  1164. REG_FLD_MOD(hdmi_wp_base(ip_data),
  1165. HDMI_WP_AUDIO_CTRL, true, 31, 31);
  1166. return 0;
  1167. }
  1168. void ti_hdmi_4xxx_wp_audio_disable(struct hdmi_ip_data *ip_data)
  1169. {
  1170. REG_FLD_MOD(hdmi_wp_base(ip_data),
  1171. HDMI_WP_AUDIO_CTRL, false, 31, 31);
  1172. }
  1173. int ti_hdmi_4xxx_audio_start(struct hdmi_ip_data *ip_data)
  1174. {
  1175. REG_FLD_MOD(hdmi_av_base(ip_data),
  1176. HDMI_CORE_AV_AUD_MODE, true, 0, 0);
  1177. REG_FLD_MOD(hdmi_wp_base(ip_data),
  1178. HDMI_WP_AUDIO_CTRL, true, 30, 30);
  1179. return 0;
  1180. }
  1181. void ti_hdmi_4xxx_audio_stop(struct hdmi_ip_data *ip_data)
  1182. {
  1183. REG_FLD_MOD(hdmi_av_base(ip_data),
  1184. HDMI_CORE_AV_AUD_MODE, false, 0, 0);
  1185. REG_FLD_MOD(hdmi_wp_base(ip_data),
  1186. HDMI_WP_AUDIO_CTRL, false, 30, 30);
  1187. }
  1188. #endif