Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 1 | /* |
| 2 | * linux/drivers/video/omap2/dss/dsi.c |
| 3 | * |
| 4 | * Copyright (C) 2009 Nokia Corporation |
| 5 | * Author: Tomi Valkeinen <tomi.valkeinen@nokia.com> |
| 6 | * |
| 7 | * This program is free software; you can redistribute it and/or modify it |
| 8 | * under the terms of the GNU General Public License version 2 as published by |
| 9 | * the Free Software Foundation. |
| 10 | * |
| 11 | * This program is distributed in the hope that it will be useful, but WITHOUT |
| 12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
| 13 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for |
| 14 | * more details. |
| 15 | * |
| 16 | * You should have received a copy of the GNU General Public License along with |
| 17 | * this program. If not, see <http://www.gnu.org/licenses/>. |
| 18 | */ |
| 19 | |
| 20 | #define DSS_SUBSYS_NAME "DSI" |
| 21 | |
| 22 | #include <linux/kernel.h> |
| 23 | #include <linux/io.h> |
| 24 | #include <linux/clk.h> |
| 25 | #include <linux/device.h> |
| 26 | #include <linux/err.h> |
| 27 | #include <linux/interrupt.h> |
| 28 | #include <linux/delay.h> |
| 29 | #include <linux/mutex.h> |
Paul Gortmaker | 355b200 | 2011-07-03 16:17:28 -0400 | [diff] [blame] | 30 | #include <linux/module.h> |
Tomi Valkeinen | b9eb5d7 | 2010-01-11 16:33:56 +0200 | [diff] [blame] | 31 | #include <linux/semaphore.h> |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 32 | #include <linux/seq_file.h> |
| 33 | #include <linux/platform_device.h> |
| 34 | #include <linux/regulator/consumer.h> |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 35 | #include <linux/wait.h> |
Tomi Valkeinen | 18946f6 | 2010-01-12 14:16:41 +0200 | [diff] [blame] | 36 | #include <linux/workqueue.h> |
Tomi Valkeinen | 40885ab | 2010-07-28 15:53:38 +0300 | [diff] [blame] | 37 | #include <linux/sched.h> |
Archit Taneja | f1da39d | 2011-05-12 17:26:27 +0530 | [diff] [blame] | 38 | #include <linux/slab.h> |
Archit Taneja | 5a8b572 | 2011-05-12 17:26:29 +0530 | [diff] [blame] | 39 | #include <linux/debugfs.h> |
Tomi Valkeinen | 4fbafaf | 2011-05-27 10:52:19 +0300 | [diff] [blame] | 40 | #include <linux/pm_runtime.h> |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 41 | |
Tomi Valkeinen | a0b38cc | 2011-05-11 14:05:07 +0300 | [diff] [blame] | 42 | #include <video/omapdss.h> |
Archit Taneja | 7a7c48f | 2011-08-25 18:25:03 +0530 | [diff] [blame] | 43 | #include <video/mipi_display.h> |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 44 | |
| 45 | #include "dss.h" |
Archit Taneja | 819d807 | 2011-03-01 11:54:00 +0530 | [diff] [blame] | 46 | #include "dss_features.h" |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 47 | |
| 48 | /*#define VERBOSE_IRQ*/ |
| 49 | #define DSI_CATCH_MISSING_TE |
| 50 | |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 51 | struct dsi_reg { u16 idx; }; |
| 52 | |
| 53 | #define DSI_REG(idx) ((const struct dsi_reg) { idx }) |
| 54 | |
| 55 | #define DSI_SZ_REGS SZ_1K |
| 56 | /* DSI Protocol Engine */ |
| 57 | |
| 58 | #define DSI_REVISION DSI_REG(0x0000) |
| 59 | #define DSI_SYSCONFIG DSI_REG(0x0010) |
| 60 | #define DSI_SYSSTATUS DSI_REG(0x0014) |
| 61 | #define DSI_IRQSTATUS DSI_REG(0x0018) |
| 62 | #define DSI_IRQENABLE DSI_REG(0x001C) |
| 63 | #define DSI_CTRL DSI_REG(0x0040) |
Archit Taneja | 75d7247 | 2011-05-16 15:17:08 +0530 | [diff] [blame] | 64 | #define DSI_GNQ DSI_REG(0x0044) |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 65 | #define DSI_COMPLEXIO_CFG1 DSI_REG(0x0048) |
| 66 | #define DSI_COMPLEXIO_IRQ_STATUS DSI_REG(0x004C) |
| 67 | #define DSI_COMPLEXIO_IRQ_ENABLE DSI_REG(0x0050) |
| 68 | #define DSI_CLK_CTRL DSI_REG(0x0054) |
| 69 | #define DSI_TIMING1 DSI_REG(0x0058) |
| 70 | #define DSI_TIMING2 DSI_REG(0x005C) |
| 71 | #define DSI_VM_TIMING1 DSI_REG(0x0060) |
| 72 | #define DSI_VM_TIMING2 DSI_REG(0x0064) |
| 73 | #define DSI_VM_TIMING3 DSI_REG(0x0068) |
| 74 | #define DSI_CLK_TIMING DSI_REG(0x006C) |
| 75 | #define DSI_TX_FIFO_VC_SIZE DSI_REG(0x0070) |
| 76 | #define DSI_RX_FIFO_VC_SIZE DSI_REG(0x0074) |
| 77 | #define DSI_COMPLEXIO_CFG2 DSI_REG(0x0078) |
| 78 | #define DSI_RX_FIFO_VC_FULLNESS DSI_REG(0x007C) |
| 79 | #define DSI_VM_TIMING4 DSI_REG(0x0080) |
| 80 | #define DSI_TX_FIFO_VC_EMPTINESS DSI_REG(0x0084) |
| 81 | #define DSI_VM_TIMING5 DSI_REG(0x0088) |
| 82 | #define DSI_VM_TIMING6 DSI_REG(0x008C) |
| 83 | #define DSI_VM_TIMING7 DSI_REG(0x0090) |
| 84 | #define DSI_STOPCLK_TIMING DSI_REG(0x0094) |
| 85 | #define DSI_VC_CTRL(n) DSI_REG(0x0100 + (n * 0x20)) |
| 86 | #define DSI_VC_TE(n) DSI_REG(0x0104 + (n * 0x20)) |
| 87 | #define DSI_VC_LONG_PACKET_HEADER(n) DSI_REG(0x0108 + (n * 0x20)) |
| 88 | #define DSI_VC_LONG_PACKET_PAYLOAD(n) DSI_REG(0x010C + (n * 0x20)) |
| 89 | #define DSI_VC_SHORT_PACKET_HEADER(n) DSI_REG(0x0110 + (n * 0x20)) |
| 90 | #define DSI_VC_IRQSTATUS(n) DSI_REG(0x0118 + (n * 0x20)) |
| 91 | #define DSI_VC_IRQENABLE(n) DSI_REG(0x011C + (n * 0x20)) |
| 92 | |
| 93 | /* DSIPHY_SCP */ |
| 94 | |
| 95 | #define DSI_DSIPHY_CFG0 DSI_REG(0x200 + 0x0000) |
| 96 | #define DSI_DSIPHY_CFG1 DSI_REG(0x200 + 0x0004) |
| 97 | #define DSI_DSIPHY_CFG2 DSI_REG(0x200 + 0x0008) |
| 98 | #define DSI_DSIPHY_CFG5 DSI_REG(0x200 + 0x0014) |
Tomi Valkeinen | 0a0ee46 | 2010-07-27 11:11:48 +0300 | [diff] [blame] | 99 | #define DSI_DSIPHY_CFG10 DSI_REG(0x200 + 0x0028) |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 100 | |
| 101 | /* DSI_PLL_CTRL_SCP */ |
| 102 | |
| 103 | #define DSI_PLL_CONTROL DSI_REG(0x300 + 0x0000) |
| 104 | #define DSI_PLL_STATUS DSI_REG(0x300 + 0x0004) |
| 105 | #define DSI_PLL_GO DSI_REG(0x300 + 0x0008) |
| 106 | #define DSI_PLL_CONFIGURATION1 DSI_REG(0x300 + 0x000C) |
| 107 | #define DSI_PLL_CONFIGURATION2 DSI_REG(0x300 + 0x0010) |
| 108 | |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 109 | #define REG_GET(dsidev, idx, start, end) \ |
| 110 | FLD_GET(dsi_read_reg(dsidev, idx), start, end) |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 111 | |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 112 | #define REG_FLD_MOD(dsidev, idx, val, start, end) \ |
| 113 | dsi_write_reg(dsidev, idx, FLD_MOD(dsi_read_reg(dsidev, idx), val, start, end)) |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 114 | |
| 115 | /* Global interrupts */ |
| 116 | #define DSI_IRQ_VC0 (1 << 0) |
| 117 | #define DSI_IRQ_VC1 (1 << 1) |
| 118 | #define DSI_IRQ_VC2 (1 << 2) |
| 119 | #define DSI_IRQ_VC3 (1 << 3) |
| 120 | #define DSI_IRQ_WAKEUP (1 << 4) |
| 121 | #define DSI_IRQ_RESYNC (1 << 5) |
| 122 | #define DSI_IRQ_PLL_LOCK (1 << 7) |
| 123 | #define DSI_IRQ_PLL_UNLOCK (1 << 8) |
| 124 | #define DSI_IRQ_PLL_RECALL (1 << 9) |
| 125 | #define DSI_IRQ_COMPLEXIO_ERR (1 << 10) |
| 126 | #define DSI_IRQ_HS_TX_TIMEOUT (1 << 14) |
| 127 | #define DSI_IRQ_LP_RX_TIMEOUT (1 << 15) |
| 128 | #define DSI_IRQ_TE_TRIGGER (1 << 16) |
| 129 | #define DSI_IRQ_ACK_TRIGGER (1 << 17) |
| 130 | #define DSI_IRQ_SYNC_LOST (1 << 18) |
| 131 | #define DSI_IRQ_LDO_POWER_GOOD (1 << 19) |
| 132 | #define DSI_IRQ_TA_TIMEOUT (1 << 20) |
| 133 | #define DSI_IRQ_ERROR_MASK \ |
| 134 | (DSI_IRQ_HS_TX_TIMEOUT | DSI_IRQ_LP_RX_TIMEOUT | DSI_IRQ_SYNC_LOST | \ |
Archit Taneja | 8af6ff0 | 2011-09-05 16:48:27 +0530 | [diff] [blame] | 135 | DSI_IRQ_TA_TIMEOUT | DSI_IRQ_SYNC_LOST) |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 136 | #define DSI_IRQ_CHANNEL_MASK 0xf |
| 137 | |
| 138 | /* Virtual channel interrupts */ |
| 139 | #define DSI_VC_IRQ_CS (1 << 0) |
| 140 | #define DSI_VC_IRQ_ECC_CORR (1 << 1) |
| 141 | #define DSI_VC_IRQ_PACKET_SENT (1 << 2) |
| 142 | #define DSI_VC_IRQ_FIFO_TX_OVF (1 << 3) |
| 143 | #define DSI_VC_IRQ_FIFO_RX_OVF (1 << 4) |
| 144 | #define DSI_VC_IRQ_BTA (1 << 5) |
| 145 | #define DSI_VC_IRQ_ECC_NO_CORR (1 << 6) |
| 146 | #define DSI_VC_IRQ_FIFO_TX_UDF (1 << 7) |
| 147 | #define DSI_VC_IRQ_PP_BUSY_CHANGE (1 << 8) |
| 148 | #define DSI_VC_IRQ_ERROR_MASK \ |
| 149 | (DSI_VC_IRQ_CS | DSI_VC_IRQ_ECC_CORR | DSI_VC_IRQ_FIFO_TX_OVF | \ |
| 150 | DSI_VC_IRQ_FIFO_RX_OVF | DSI_VC_IRQ_ECC_NO_CORR | \ |
| 151 | DSI_VC_IRQ_FIFO_TX_UDF) |
| 152 | |
| 153 | /* ComplexIO interrupts */ |
| 154 | #define DSI_CIO_IRQ_ERRSYNCESC1 (1 << 0) |
| 155 | #define DSI_CIO_IRQ_ERRSYNCESC2 (1 << 1) |
| 156 | #define DSI_CIO_IRQ_ERRSYNCESC3 (1 << 2) |
Tomi Valkeinen | 6705615 | 2011-03-24 16:30:17 +0200 | [diff] [blame] | 157 | #define DSI_CIO_IRQ_ERRSYNCESC4 (1 << 3) |
| 158 | #define DSI_CIO_IRQ_ERRSYNCESC5 (1 << 4) |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 159 | #define DSI_CIO_IRQ_ERRESC1 (1 << 5) |
| 160 | #define DSI_CIO_IRQ_ERRESC2 (1 << 6) |
| 161 | #define DSI_CIO_IRQ_ERRESC3 (1 << 7) |
Tomi Valkeinen | 6705615 | 2011-03-24 16:30:17 +0200 | [diff] [blame] | 162 | #define DSI_CIO_IRQ_ERRESC4 (1 << 8) |
| 163 | #define DSI_CIO_IRQ_ERRESC5 (1 << 9) |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 164 | #define DSI_CIO_IRQ_ERRCONTROL1 (1 << 10) |
| 165 | #define DSI_CIO_IRQ_ERRCONTROL2 (1 << 11) |
| 166 | #define DSI_CIO_IRQ_ERRCONTROL3 (1 << 12) |
Tomi Valkeinen | 6705615 | 2011-03-24 16:30:17 +0200 | [diff] [blame] | 167 | #define DSI_CIO_IRQ_ERRCONTROL4 (1 << 13) |
| 168 | #define DSI_CIO_IRQ_ERRCONTROL5 (1 << 14) |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 169 | #define DSI_CIO_IRQ_STATEULPS1 (1 << 15) |
| 170 | #define DSI_CIO_IRQ_STATEULPS2 (1 << 16) |
| 171 | #define DSI_CIO_IRQ_STATEULPS3 (1 << 17) |
Tomi Valkeinen | 6705615 | 2011-03-24 16:30:17 +0200 | [diff] [blame] | 172 | #define DSI_CIO_IRQ_STATEULPS4 (1 << 18) |
| 173 | #define DSI_CIO_IRQ_STATEULPS5 (1 << 19) |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 174 | #define DSI_CIO_IRQ_ERRCONTENTIONLP0_1 (1 << 20) |
| 175 | #define DSI_CIO_IRQ_ERRCONTENTIONLP1_1 (1 << 21) |
| 176 | #define DSI_CIO_IRQ_ERRCONTENTIONLP0_2 (1 << 22) |
| 177 | #define DSI_CIO_IRQ_ERRCONTENTIONLP1_2 (1 << 23) |
| 178 | #define DSI_CIO_IRQ_ERRCONTENTIONLP0_3 (1 << 24) |
| 179 | #define DSI_CIO_IRQ_ERRCONTENTIONLP1_3 (1 << 25) |
Tomi Valkeinen | 6705615 | 2011-03-24 16:30:17 +0200 | [diff] [blame] | 180 | #define DSI_CIO_IRQ_ERRCONTENTIONLP0_4 (1 << 26) |
| 181 | #define DSI_CIO_IRQ_ERRCONTENTIONLP1_4 (1 << 27) |
| 182 | #define DSI_CIO_IRQ_ERRCONTENTIONLP0_5 (1 << 28) |
| 183 | #define DSI_CIO_IRQ_ERRCONTENTIONLP1_5 (1 << 29) |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 184 | #define DSI_CIO_IRQ_ULPSACTIVENOT_ALL0 (1 << 30) |
| 185 | #define DSI_CIO_IRQ_ULPSACTIVENOT_ALL1 (1 << 31) |
Tomi Valkeinen | bbecb50 | 2010-05-10 14:35:33 +0300 | [diff] [blame] | 186 | #define DSI_CIO_IRQ_ERROR_MASK \ |
| 187 | (DSI_CIO_IRQ_ERRSYNCESC1 | DSI_CIO_IRQ_ERRSYNCESC2 | \ |
Tomi Valkeinen | 6705615 | 2011-03-24 16:30:17 +0200 | [diff] [blame] | 188 | DSI_CIO_IRQ_ERRSYNCESC3 | DSI_CIO_IRQ_ERRSYNCESC4 | \ |
| 189 | DSI_CIO_IRQ_ERRSYNCESC5 | \ |
| 190 | DSI_CIO_IRQ_ERRESC1 | DSI_CIO_IRQ_ERRESC2 | \ |
| 191 | DSI_CIO_IRQ_ERRESC3 | DSI_CIO_IRQ_ERRESC4 | \ |
| 192 | DSI_CIO_IRQ_ERRESC5 | \ |
| 193 | DSI_CIO_IRQ_ERRCONTROL1 | DSI_CIO_IRQ_ERRCONTROL2 | \ |
| 194 | DSI_CIO_IRQ_ERRCONTROL3 | DSI_CIO_IRQ_ERRCONTROL4 | \ |
| 195 | DSI_CIO_IRQ_ERRCONTROL5 | \ |
Tomi Valkeinen | bbecb50 | 2010-05-10 14:35:33 +0300 | [diff] [blame] | 196 | DSI_CIO_IRQ_ERRCONTENTIONLP0_1 | DSI_CIO_IRQ_ERRCONTENTIONLP1_1 | \ |
| 197 | DSI_CIO_IRQ_ERRCONTENTIONLP0_2 | DSI_CIO_IRQ_ERRCONTENTIONLP1_2 | \ |
Tomi Valkeinen | 6705615 | 2011-03-24 16:30:17 +0200 | [diff] [blame] | 198 | DSI_CIO_IRQ_ERRCONTENTIONLP0_3 | DSI_CIO_IRQ_ERRCONTENTIONLP1_3 | \ |
| 199 | DSI_CIO_IRQ_ERRCONTENTIONLP0_4 | DSI_CIO_IRQ_ERRCONTENTIONLP1_4 | \ |
| 200 | DSI_CIO_IRQ_ERRCONTENTIONLP0_5 | DSI_CIO_IRQ_ERRCONTENTIONLP1_5) |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 201 | |
Tomi Valkeinen | 4ae2ddd | 2011-03-02 14:47:04 +0200 | [diff] [blame] | 202 | typedef void (*omap_dsi_isr_t) (void *arg, u32 mask); |
| 203 | |
| 204 | #define DSI_MAX_NR_ISRS 2 |
Tomi Valkeinen | 739a7f4 | 2011-10-13 11:22:06 +0300 | [diff] [blame] | 205 | #define DSI_MAX_NR_LANES 5 |
| 206 | |
| 207 | enum dsi_lane_function { |
| 208 | DSI_LANE_UNUSED = 0, |
| 209 | DSI_LANE_CLK, |
| 210 | DSI_LANE_DATA1, |
| 211 | DSI_LANE_DATA2, |
| 212 | DSI_LANE_DATA3, |
| 213 | DSI_LANE_DATA4, |
| 214 | }; |
| 215 | |
| 216 | struct dsi_lane_config { |
| 217 | enum dsi_lane_function function; |
| 218 | u8 polarity; |
| 219 | }; |
Tomi Valkeinen | 4ae2ddd | 2011-03-02 14:47:04 +0200 | [diff] [blame] | 220 | |
| 221 | struct dsi_isr_data { |
| 222 | omap_dsi_isr_t isr; |
| 223 | void *arg; |
| 224 | u32 mask; |
| 225 | }; |
| 226 | |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 227 | enum fifo_size { |
| 228 | DSI_FIFO_SIZE_0 = 0, |
| 229 | DSI_FIFO_SIZE_32 = 1, |
| 230 | DSI_FIFO_SIZE_64 = 2, |
| 231 | DSI_FIFO_SIZE_96 = 3, |
| 232 | DSI_FIFO_SIZE_128 = 4, |
| 233 | }; |
| 234 | |
Archit Taneja | d604914 | 2011-08-22 11:58:08 +0530 | [diff] [blame] | 235 | enum dsi_vc_source { |
| 236 | DSI_VC_SOURCE_L4 = 0, |
| 237 | DSI_VC_SOURCE_VP, |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 238 | }; |
| 239 | |
Tomi Valkeinen | dfc0fd8 | 2009-12-17 14:35:21 +0200 | [diff] [blame] | 240 | struct dsi_irq_stats { |
| 241 | unsigned long last_reset; |
| 242 | unsigned irq_count; |
| 243 | unsigned dsi_irqs[32]; |
| 244 | unsigned vc_irqs[4][32]; |
| 245 | unsigned cio_irqs[32]; |
| 246 | }; |
| 247 | |
Tomi Valkeinen | 4ae2ddd | 2011-03-02 14:47:04 +0200 | [diff] [blame] | 248 | struct dsi_isr_tables { |
| 249 | struct dsi_isr_data isr_table[DSI_MAX_NR_ISRS]; |
| 250 | struct dsi_isr_data isr_table_vc[4][DSI_MAX_NR_ISRS]; |
| 251 | struct dsi_isr_data isr_table_cio[DSI_MAX_NR_ISRS]; |
| 252 | }; |
| 253 | |
Archit Taneja | f1da39d | 2011-05-12 17:26:27 +0530 | [diff] [blame] | 254 | struct dsi_data { |
Senthilvadivu Guruswamy | c8aac01 | 2011-01-24 06:22:02 +0000 | [diff] [blame] | 255 | struct platform_device *pdev; |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 256 | void __iomem *base; |
Tomi Valkeinen | 4fbafaf | 2011-05-27 10:52:19 +0300 | [diff] [blame] | 257 | |
Tomi Valkeinen | 11ee960 | 2012-03-09 16:07:39 +0200 | [diff] [blame] | 258 | int module_id; |
| 259 | |
archit taneja | affe360 | 2011-02-23 08:41:03 +0000 | [diff] [blame] | 260 | int irq; |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 261 | |
Tomi Valkeinen | 4fbafaf | 2011-05-27 10:52:19 +0300 | [diff] [blame] | 262 | struct clk *dss_clk; |
| 263 | struct clk *sys_clk; |
| 264 | |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 265 | struct dsi_clock_info current_cinfo; |
| 266 | |
Tomi Valkeinen | 2a89dc1 | 2010-07-30 12:39:34 +0300 | [diff] [blame] | 267 | bool vdds_dsi_enabled; |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 268 | struct regulator *vdds_dsi_reg; |
| 269 | |
| 270 | struct { |
Archit Taneja | d604914 | 2011-08-22 11:58:08 +0530 | [diff] [blame] | 271 | enum dsi_vc_source source; |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 272 | struct omap_dss_device *dssdev; |
| 273 | enum fifo_size fifo_size; |
Archit Taneja | 5ee3c14 | 2011-03-02 12:35:53 +0530 | [diff] [blame] | 274 | int vc_id; |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 275 | } vc[4]; |
| 276 | |
| 277 | struct mutex lock; |
Tomi Valkeinen | b9eb5d7 | 2010-01-11 16:33:56 +0200 | [diff] [blame] | 278 | struct semaphore bus_lock; |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 279 | |
| 280 | unsigned pll_locked; |
| 281 | |
Tomi Valkeinen | 4ae2ddd | 2011-03-02 14:47:04 +0200 | [diff] [blame] | 282 | spinlock_t irq_lock; |
| 283 | struct dsi_isr_tables isr_tables; |
| 284 | /* space for a copy used by the interrupt handler */ |
| 285 | struct dsi_isr_tables isr_tables_copy; |
| 286 | |
Tomi Valkeinen | 18946f6 | 2010-01-12 14:16:41 +0200 | [diff] [blame] | 287 | int update_channel; |
Tomi Valkeinen | 5476e74 | 2011-11-03 16:34:20 +0200 | [diff] [blame] | 288 | #ifdef DEBUG |
| 289 | unsigned update_bytes; |
| 290 | #endif |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 291 | |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 292 | bool te_enabled; |
Tomi Valkeinen | 40885ab | 2010-07-28 15:53:38 +0300 | [diff] [blame] | 293 | bool ulps_enabled; |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 294 | |
Tomi Valkeinen | 18946f6 | 2010-01-12 14:16:41 +0200 | [diff] [blame] | 295 | void (*framedone_callback)(int, void *); |
| 296 | void *framedone_data; |
| 297 | |
| 298 | struct delayed_work framedone_timeout_work; |
| 299 | |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 300 | #ifdef DSI_CATCH_MISSING_TE |
| 301 | struct timer_list te_timer; |
| 302 | #endif |
| 303 | |
| 304 | unsigned long cache_req_pck; |
| 305 | unsigned long cache_clk_freq; |
| 306 | struct dsi_clock_info cache_cinfo; |
| 307 | |
| 308 | u32 errors; |
| 309 | spinlock_t errors_lock; |
| 310 | #ifdef DEBUG |
| 311 | ktime_t perf_setup_time; |
| 312 | ktime_t perf_start_time; |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 313 | #endif |
| 314 | int debug_read; |
| 315 | int debug_write; |
Tomi Valkeinen | dfc0fd8 | 2009-12-17 14:35:21 +0200 | [diff] [blame] | 316 | |
| 317 | #ifdef CONFIG_OMAP2_DSS_COLLECT_IRQ_STATS |
| 318 | spinlock_t irq_stats_lock; |
| 319 | struct dsi_irq_stats irq_stats; |
| 320 | #endif |
Taneja, Archit | 4964111 | 2011-03-14 23:28:23 -0500 | [diff] [blame] | 321 | /* DSI PLL Parameter Ranges */ |
| 322 | unsigned long regm_max, regn_max; |
| 323 | unsigned long regm_dispc_max, regm_dsi_max; |
| 324 | unsigned long fint_min, fint_max; |
| 325 | unsigned long lpdiv_max; |
Tomi Valkeinen | 24c1ae4 | 2011-04-13 17:12:52 +0300 | [diff] [blame] | 326 | |
Tomi Valkeinen | d982085 | 2011-10-12 15:05:59 +0300 | [diff] [blame] | 327 | unsigned num_lanes_supported; |
Archit Taneja | 75d7247 | 2011-05-16 15:17:08 +0530 | [diff] [blame] | 328 | |
Tomi Valkeinen | 739a7f4 | 2011-10-13 11:22:06 +0300 | [diff] [blame] | 329 | struct dsi_lane_config lanes[DSI_MAX_NR_LANES]; |
| 330 | unsigned num_lanes_used; |
Tomi Valkeinen | 24c1ae4 | 2011-04-13 17:12:52 +0300 | [diff] [blame] | 331 | |
| 332 | unsigned scp_clk_refcount; |
Archit Taneja | 7d2572f | 2012-06-29 14:31:07 +0530 | [diff] [blame] | 333 | |
| 334 | struct dss_lcd_mgr_config mgr_config; |
Archit Taneja | e67458a | 2012-08-13 14:17:30 +0530 | [diff] [blame] | 335 | struct omap_video_timings timings; |
Archit Taneja | 02c3960 | 2012-08-10 15:01:33 +0530 | [diff] [blame] | 336 | enum omap_dss_dsi_pixel_format pix_fmt; |
Archit Taneja | dca2b15 | 2012-08-16 18:02:00 +0530 | [diff] [blame] | 337 | enum omap_dss_dsi_mode mode; |
Archit Taneja | 0b3ffe3 | 2012-08-13 22:13:39 +0530 | [diff] [blame] | 338 | struct omap_dss_dsi_videomode_timings vm_timings; |
Archit Taneja | f1da39d | 2011-05-12 17:26:27 +0530 | [diff] [blame] | 339 | }; |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 340 | |
Archit Taneja | 2e868db | 2011-05-12 17:26:28 +0530 | [diff] [blame] | 341 | struct dsi_packet_sent_handler_data { |
| 342 | struct platform_device *dsidev; |
| 343 | struct completion *completion; |
| 344 | }; |
| 345 | |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 346 | static struct platform_device *dsi_pdev_map[MAX_NUM_DSI]; |
| 347 | |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 348 | #ifdef DEBUG |
Rusty Russell | 90ab5ee | 2012-01-13 09:32:20 +1030 | [diff] [blame] | 349 | static bool dsi_perf; |
| 350 | module_param(dsi_perf, bool, 0644); |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 351 | #endif |
| 352 | |
Archit Taneja | f1da39d | 2011-05-12 17:26:27 +0530 | [diff] [blame] | 353 | static inline struct dsi_data *dsi_get_dsidrv_data(struct platform_device *dsidev) |
| 354 | { |
| 355 | return dev_get_drvdata(&dsidev->dev); |
| 356 | } |
| 357 | |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 358 | static inline struct platform_device *dsi_get_dsidev_from_dssdev(struct omap_dss_device *dssdev) |
| 359 | { |
| 360 | return dsi_pdev_map[dssdev->phy.dsi.module]; |
| 361 | } |
| 362 | |
| 363 | struct platform_device *dsi_get_dsidev_from_id(int module) |
| 364 | { |
| 365 | return dsi_pdev_map[module]; |
| 366 | } |
| 367 | |
| 368 | static inline void dsi_write_reg(struct platform_device *dsidev, |
| 369 | const struct dsi_reg idx, u32 val) |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 370 | { |
Archit Taneja | f1da39d | 2011-05-12 17:26:27 +0530 | [diff] [blame] | 371 | struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev); |
| 372 | |
| 373 | __raw_writel(val, dsi->base + idx.idx); |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 374 | } |
| 375 | |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 376 | static inline u32 dsi_read_reg(struct platform_device *dsidev, |
| 377 | const struct dsi_reg idx) |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 378 | { |
Archit Taneja | f1da39d | 2011-05-12 17:26:27 +0530 | [diff] [blame] | 379 | struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev); |
| 380 | |
| 381 | return __raw_readl(dsi->base + idx.idx); |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 382 | } |
| 383 | |
Archit Taneja | 1ffefe7 | 2011-05-12 17:26:24 +0530 | [diff] [blame] | 384 | void dsi_bus_lock(struct omap_dss_device *dssdev) |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 385 | { |
Archit Taneja | f1da39d | 2011-05-12 17:26:27 +0530 | [diff] [blame] | 386 | struct platform_device *dsidev = dsi_get_dsidev_from_dssdev(dssdev); |
| 387 | struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev); |
| 388 | |
| 389 | down(&dsi->bus_lock); |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 390 | } |
| 391 | EXPORT_SYMBOL(dsi_bus_lock); |
| 392 | |
Archit Taneja | 1ffefe7 | 2011-05-12 17:26:24 +0530 | [diff] [blame] | 393 | void dsi_bus_unlock(struct omap_dss_device *dssdev) |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 394 | { |
Archit Taneja | f1da39d | 2011-05-12 17:26:27 +0530 | [diff] [blame] | 395 | struct platform_device *dsidev = dsi_get_dsidev_from_dssdev(dssdev); |
| 396 | struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev); |
| 397 | |
| 398 | up(&dsi->bus_lock); |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 399 | } |
| 400 | EXPORT_SYMBOL(dsi_bus_unlock); |
| 401 | |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 402 | static bool dsi_bus_is_locked(struct platform_device *dsidev) |
Tomi Valkeinen | 4f76502 | 2010-01-18 16:27:52 +0200 | [diff] [blame] | 403 | { |
Archit Taneja | f1da39d | 2011-05-12 17:26:27 +0530 | [diff] [blame] | 404 | struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev); |
| 405 | |
| 406 | return dsi->bus_lock.count == 0; |
Tomi Valkeinen | 4f76502 | 2010-01-18 16:27:52 +0200 | [diff] [blame] | 407 | } |
| 408 | |
Tomi Valkeinen | f36a06e | 2011-03-02 14:48:41 +0200 | [diff] [blame] | 409 | static void dsi_completion_handler(void *data, u32 mask) |
| 410 | { |
| 411 | complete((struct completion *)data); |
| 412 | } |
| 413 | |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 414 | static inline int wait_for_bit_change(struct platform_device *dsidev, |
| 415 | const struct dsi_reg idx, int bitnum, int value) |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 416 | { |
Tomi Valkeinen | 3b98409 | 2011-10-13 19:06:49 +0300 | [diff] [blame] | 417 | unsigned long timeout; |
| 418 | ktime_t wait; |
| 419 | int t; |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 420 | |
Tomi Valkeinen | 3b98409 | 2011-10-13 19:06:49 +0300 | [diff] [blame] | 421 | /* first busyloop to see if the bit changes right away */ |
| 422 | t = 100; |
| 423 | while (t-- > 0) { |
| 424 | if (REG_GET(dsidev, idx, bitnum, bitnum) == value) |
| 425 | return value; |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 426 | } |
| 427 | |
Tomi Valkeinen | 3b98409 | 2011-10-13 19:06:49 +0300 | [diff] [blame] | 428 | /* then loop for 500ms, sleeping for 1ms in between */ |
| 429 | timeout = jiffies + msecs_to_jiffies(500); |
| 430 | while (time_before(jiffies, timeout)) { |
| 431 | if (REG_GET(dsidev, idx, bitnum, bitnum) == value) |
| 432 | return value; |
| 433 | |
| 434 | wait = ns_to_ktime(1000 * 1000); |
| 435 | set_current_state(TASK_UNINTERRUPTIBLE); |
| 436 | schedule_hrtimeout(&wait, HRTIMER_MODE_REL); |
| 437 | } |
| 438 | |
| 439 | return !value; |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 440 | } |
| 441 | |
Archit Taneja | a3b3cc2 | 2011-09-08 18:42:16 +0530 | [diff] [blame] | 442 | u8 dsi_get_pixel_size(enum omap_dss_dsi_pixel_format fmt) |
| 443 | { |
| 444 | switch (fmt) { |
| 445 | case OMAP_DSS_DSI_FMT_RGB888: |
| 446 | case OMAP_DSS_DSI_FMT_RGB666: |
| 447 | return 24; |
| 448 | case OMAP_DSS_DSI_FMT_RGB666_PACKED: |
| 449 | return 18; |
| 450 | case OMAP_DSS_DSI_FMT_RGB565: |
| 451 | return 16; |
| 452 | default: |
| 453 | BUG(); |
Tomi Valkeinen | c6eee96 | 2012-05-18 11:47:02 +0300 | [diff] [blame] | 454 | return 0; |
Archit Taneja | a3b3cc2 | 2011-09-08 18:42:16 +0530 | [diff] [blame] | 455 | } |
| 456 | } |
| 457 | |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 458 | #ifdef DEBUG |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 459 | static void dsi_perf_mark_setup(struct platform_device *dsidev) |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 460 | { |
Archit Taneja | f1da39d | 2011-05-12 17:26:27 +0530 | [diff] [blame] | 461 | struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev); |
| 462 | dsi->perf_setup_time = ktime_get(); |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 463 | } |
| 464 | |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 465 | static void dsi_perf_mark_start(struct platform_device *dsidev) |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 466 | { |
Archit Taneja | f1da39d | 2011-05-12 17:26:27 +0530 | [diff] [blame] | 467 | struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev); |
| 468 | dsi->perf_start_time = ktime_get(); |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 469 | } |
| 470 | |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 471 | static void dsi_perf_show(struct platform_device *dsidev, const char *name) |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 472 | { |
Archit Taneja | f1da39d | 2011-05-12 17:26:27 +0530 | [diff] [blame] | 473 | struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev); |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 474 | ktime_t t, setup_time, trans_time; |
| 475 | u32 total_bytes; |
| 476 | u32 setup_us, trans_us, total_us; |
| 477 | |
| 478 | if (!dsi_perf) |
| 479 | return; |
| 480 | |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 481 | t = ktime_get(); |
| 482 | |
Archit Taneja | f1da39d | 2011-05-12 17:26:27 +0530 | [diff] [blame] | 483 | setup_time = ktime_sub(dsi->perf_start_time, dsi->perf_setup_time); |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 484 | setup_us = (u32)ktime_to_us(setup_time); |
| 485 | if (setup_us == 0) |
| 486 | setup_us = 1; |
| 487 | |
Archit Taneja | f1da39d | 2011-05-12 17:26:27 +0530 | [diff] [blame] | 488 | trans_time = ktime_sub(t, dsi->perf_start_time); |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 489 | trans_us = (u32)ktime_to_us(trans_time); |
| 490 | if (trans_us == 0) |
| 491 | trans_us = 1; |
| 492 | |
| 493 | total_us = setup_us + trans_us; |
| 494 | |
Tomi Valkeinen | 5476e74 | 2011-11-03 16:34:20 +0200 | [diff] [blame] | 495 | total_bytes = dsi->update_bytes; |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 496 | |
Tomi Valkeinen | 1bbb275 | 2010-01-11 16:41:10 +0200 | [diff] [blame] | 497 | printk(KERN_INFO "DSI(%s): %u us + %u us = %u us (%uHz), " |
| 498 | "%u bytes, %u kbytes/sec\n", |
| 499 | name, |
| 500 | setup_us, |
| 501 | trans_us, |
| 502 | total_us, |
| 503 | 1000*1000 / total_us, |
| 504 | total_bytes, |
| 505 | total_bytes * 1000 / total_us); |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 506 | } |
| 507 | #else |
Tomi Valkeinen | 4a9a5e3 | 2011-05-23 16:36:09 +0300 | [diff] [blame] | 508 | static inline void dsi_perf_mark_setup(struct platform_device *dsidev) |
| 509 | { |
| 510 | } |
| 511 | |
| 512 | static inline void dsi_perf_mark_start(struct platform_device *dsidev) |
| 513 | { |
| 514 | } |
| 515 | |
| 516 | static inline void dsi_perf_show(struct platform_device *dsidev, |
| 517 | const char *name) |
| 518 | { |
| 519 | } |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 520 | #endif |
| 521 | |
| 522 | static void print_irq_status(u32 status) |
| 523 | { |
Tomi Valkeinen | d80d499 | 2011-03-02 15:53:07 +0200 | [diff] [blame] | 524 | if (status == 0) |
| 525 | return; |
| 526 | |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 527 | #ifndef VERBOSE_IRQ |
| 528 | if ((status & ~DSI_IRQ_CHANNEL_MASK) == 0) |
| 529 | return; |
| 530 | #endif |
| 531 | printk(KERN_DEBUG "DSI IRQ: 0x%x: ", status); |
| 532 | |
| 533 | #define PIS(x) \ |
| 534 | if (status & DSI_IRQ_##x) \ |
| 535 | printk(#x " "); |
| 536 | #ifdef VERBOSE_IRQ |
| 537 | PIS(VC0); |
| 538 | PIS(VC1); |
| 539 | PIS(VC2); |
| 540 | PIS(VC3); |
| 541 | #endif |
| 542 | PIS(WAKEUP); |
| 543 | PIS(RESYNC); |
| 544 | PIS(PLL_LOCK); |
| 545 | PIS(PLL_UNLOCK); |
| 546 | PIS(PLL_RECALL); |
| 547 | PIS(COMPLEXIO_ERR); |
| 548 | PIS(HS_TX_TIMEOUT); |
| 549 | PIS(LP_RX_TIMEOUT); |
| 550 | PIS(TE_TRIGGER); |
| 551 | PIS(ACK_TRIGGER); |
| 552 | PIS(SYNC_LOST); |
| 553 | PIS(LDO_POWER_GOOD); |
| 554 | PIS(TA_TIMEOUT); |
| 555 | #undef PIS |
| 556 | |
| 557 | printk("\n"); |
| 558 | } |
| 559 | |
| 560 | static void print_irq_status_vc(int channel, u32 status) |
| 561 | { |
Tomi Valkeinen | d80d499 | 2011-03-02 15:53:07 +0200 | [diff] [blame] | 562 | if (status == 0) |
| 563 | return; |
| 564 | |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 565 | #ifndef VERBOSE_IRQ |
| 566 | if ((status & ~DSI_VC_IRQ_PACKET_SENT) == 0) |
| 567 | return; |
| 568 | #endif |
| 569 | printk(KERN_DEBUG "DSI VC(%d) IRQ 0x%x: ", channel, status); |
| 570 | |
| 571 | #define PIS(x) \ |
| 572 | if (status & DSI_VC_IRQ_##x) \ |
| 573 | printk(#x " "); |
| 574 | PIS(CS); |
| 575 | PIS(ECC_CORR); |
| 576 | #ifdef VERBOSE_IRQ |
| 577 | PIS(PACKET_SENT); |
| 578 | #endif |
| 579 | PIS(FIFO_TX_OVF); |
| 580 | PIS(FIFO_RX_OVF); |
| 581 | PIS(BTA); |
| 582 | PIS(ECC_NO_CORR); |
| 583 | PIS(FIFO_TX_UDF); |
| 584 | PIS(PP_BUSY_CHANGE); |
| 585 | #undef PIS |
| 586 | printk("\n"); |
| 587 | } |
| 588 | |
| 589 | static void print_irq_status_cio(u32 status) |
| 590 | { |
Tomi Valkeinen | d80d499 | 2011-03-02 15:53:07 +0200 | [diff] [blame] | 591 | if (status == 0) |
| 592 | return; |
| 593 | |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 594 | printk(KERN_DEBUG "DSI CIO IRQ 0x%x: ", status); |
| 595 | |
| 596 | #define PIS(x) \ |
| 597 | if (status & DSI_CIO_IRQ_##x) \ |
| 598 | printk(#x " "); |
| 599 | PIS(ERRSYNCESC1); |
| 600 | PIS(ERRSYNCESC2); |
| 601 | PIS(ERRSYNCESC3); |
| 602 | PIS(ERRESC1); |
| 603 | PIS(ERRESC2); |
| 604 | PIS(ERRESC3); |
| 605 | PIS(ERRCONTROL1); |
| 606 | PIS(ERRCONTROL2); |
| 607 | PIS(ERRCONTROL3); |
| 608 | PIS(STATEULPS1); |
| 609 | PIS(STATEULPS2); |
| 610 | PIS(STATEULPS3); |
| 611 | PIS(ERRCONTENTIONLP0_1); |
| 612 | PIS(ERRCONTENTIONLP1_1); |
| 613 | PIS(ERRCONTENTIONLP0_2); |
| 614 | PIS(ERRCONTENTIONLP1_2); |
| 615 | PIS(ERRCONTENTIONLP0_3); |
| 616 | PIS(ERRCONTENTIONLP1_3); |
| 617 | PIS(ULPSACTIVENOT_ALL0); |
| 618 | PIS(ULPSACTIVENOT_ALL1); |
| 619 | #undef PIS |
| 620 | |
| 621 | printk("\n"); |
| 622 | } |
| 623 | |
Tomi Valkeinen | 69b281a | 2011-03-02 14:44:27 +0200 | [diff] [blame] | 624 | #ifdef CONFIG_OMAP2_DSS_COLLECT_IRQ_STATS |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 625 | static void dsi_collect_irq_stats(struct platform_device *dsidev, u32 irqstatus, |
| 626 | u32 *vcstatus, u32 ciostatus) |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 627 | { |
Archit Taneja | f1da39d | 2011-05-12 17:26:27 +0530 | [diff] [blame] | 628 | struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev); |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 629 | int i; |
| 630 | |
Archit Taneja | f1da39d | 2011-05-12 17:26:27 +0530 | [diff] [blame] | 631 | spin_lock(&dsi->irq_stats_lock); |
Tomi Valkeinen | 69b281a | 2011-03-02 14:44:27 +0200 | [diff] [blame] | 632 | |
Archit Taneja | f1da39d | 2011-05-12 17:26:27 +0530 | [diff] [blame] | 633 | dsi->irq_stats.irq_count++; |
| 634 | dss_collect_irq_stats(irqstatus, dsi->irq_stats.dsi_irqs); |
Tomi Valkeinen | 69b281a | 2011-03-02 14:44:27 +0200 | [diff] [blame] | 635 | |
| 636 | for (i = 0; i < 4; ++i) |
Archit Taneja | f1da39d | 2011-05-12 17:26:27 +0530 | [diff] [blame] | 637 | dss_collect_irq_stats(vcstatus[i], dsi->irq_stats.vc_irqs[i]); |
Tomi Valkeinen | 69b281a | 2011-03-02 14:44:27 +0200 | [diff] [blame] | 638 | |
Archit Taneja | f1da39d | 2011-05-12 17:26:27 +0530 | [diff] [blame] | 639 | dss_collect_irq_stats(ciostatus, dsi->irq_stats.cio_irqs); |
Tomi Valkeinen | 69b281a | 2011-03-02 14:44:27 +0200 | [diff] [blame] | 640 | |
Archit Taneja | f1da39d | 2011-05-12 17:26:27 +0530 | [diff] [blame] | 641 | spin_unlock(&dsi->irq_stats_lock); |
Tomi Valkeinen | 69b281a | 2011-03-02 14:44:27 +0200 | [diff] [blame] | 642 | } |
| 643 | #else |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 644 | #define dsi_collect_irq_stats(dsidev, irqstatus, vcstatus, ciostatus) |
Tomi Valkeinen | dfc0fd8 | 2009-12-17 14:35:21 +0200 | [diff] [blame] | 645 | #endif |
| 646 | |
Tomi Valkeinen | 69b281a | 2011-03-02 14:44:27 +0200 | [diff] [blame] | 647 | static int debug_irq; |
| 648 | |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 649 | static void dsi_handle_irq_errors(struct platform_device *dsidev, u32 irqstatus, |
| 650 | u32 *vcstatus, u32 ciostatus) |
Tomi Valkeinen | 69b281a | 2011-03-02 14:44:27 +0200 | [diff] [blame] | 651 | { |
Archit Taneja | f1da39d | 2011-05-12 17:26:27 +0530 | [diff] [blame] | 652 | struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev); |
Tomi Valkeinen | 69b281a | 2011-03-02 14:44:27 +0200 | [diff] [blame] | 653 | int i; |
| 654 | |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 655 | if (irqstatus & DSI_IRQ_ERROR_MASK) { |
| 656 | DSSERR("DSI error, irqstatus %x\n", irqstatus); |
| 657 | print_irq_status(irqstatus); |
Archit Taneja | f1da39d | 2011-05-12 17:26:27 +0530 | [diff] [blame] | 658 | spin_lock(&dsi->errors_lock); |
| 659 | dsi->errors |= irqstatus & DSI_IRQ_ERROR_MASK; |
| 660 | spin_unlock(&dsi->errors_lock); |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 661 | } else if (debug_irq) { |
| 662 | print_irq_status(irqstatus); |
| 663 | } |
| 664 | |
Tomi Valkeinen | 69b281a | 2011-03-02 14:44:27 +0200 | [diff] [blame] | 665 | for (i = 0; i < 4; ++i) { |
| 666 | if (vcstatus[i] & DSI_VC_IRQ_ERROR_MASK) { |
| 667 | DSSERR("DSI VC(%d) error, vc irqstatus %x\n", |
| 668 | i, vcstatus[i]); |
| 669 | print_irq_status_vc(i, vcstatus[i]); |
| 670 | } else if (debug_irq) { |
| 671 | print_irq_status_vc(i, vcstatus[i]); |
| 672 | } |
| 673 | } |
| 674 | |
| 675 | if (ciostatus & DSI_CIO_IRQ_ERROR_MASK) { |
| 676 | DSSERR("DSI CIO error, cio irqstatus %x\n", ciostatus); |
| 677 | print_irq_status_cio(ciostatus); |
| 678 | } else if (debug_irq) { |
| 679 | print_irq_status_cio(ciostatus); |
| 680 | } |
| 681 | } |
| 682 | |
Tomi Valkeinen | 4ae2ddd | 2011-03-02 14:47:04 +0200 | [diff] [blame] | 683 | static void dsi_call_isrs(struct dsi_isr_data *isr_array, |
| 684 | unsigned isr_array_size, u32 irqstatus) |
| 685 | { |
| 686 | struct dsi_isr_data *isr_data; |
| 687 | int i; |
| 688 | |
| 689 | for (i = 0; i < isr_array_size; i++) { |
| 690 | isr_data = &isr_array[i]; |
| 691 | if (isr_data->isr && isr_data->mask & irqstatus) |
| 692 | isr_data->isr(isr_data->arg, irqstatus); |
| 693 | } |
| 694 | } |
| 695 | |
| 696 | static void dsi_handle_isrs(struct dsi_isr_tables *isr_tables, |
| 697 | u32 irqstatus, u32 *vcstatus, u32 ciostatus) |
| 698 | { |
| 699 | int i; |
| 700 | |
| 701 | dsi_call_isrs(isr_tables->isr_table, |
| 702 | ARRAY_SIZE(isr_tables->isr_table), |
| 703 | irqstatus); |
| 704 | |
| 705 | for (i = 0; i < 4; ++i) { |
| 706 | if (vcstatus[i] == 0) |
| 707 | continue; |
| 708 | dsi_call_isrs(isr_tables->isr_table_vc[i], |
| 709 | ARRAY_SIZE(isr_tables->isr_table_vc[i]), |
| 710 | vcstatus[i]); |
| 711 | } |
| 712 | |
| 713 | if (ciostatus != 0) |
| 714 | dsi_call_isrs(isr_tables->isr_table_cio, |
| 715 | ARRAY_SIZE(isr_tables->isr_table_cio), |
| 716 | ciostatus); |
| 717 | } |
| 718 | |
Tomi Valkeinen | 69b281a | 2011-03-02 14:44:27 +0200 | [diff] [blame] | 719 | static irqreturn_t omap_dsi_irq_handler(int irq, void *arg) |
| 720 | { |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 721 | struct platform_device *dsidev; |
Archit Taneja | f1da39d | 2011-05-12 17:26:27 +0530 | [diff] [blame] | 722 | struct dsi_data *dsi; |
Tomi Valkeinen | 69b281a | 2011-03-02 14:44:27 +0200 | [diff] [blame] | 723 | u32 irqstatus, vcstatus[4], ciostatus; |
| 724 | int i; |
| 725 | |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 726 | dsidev = (struct platform_device *) arg; |
Archit Taneja | f1da39d | 2011-05-12 17:26:27 +0530 | [diff] [blame] | 727 | dsi = dsi_get_dsidrv_data(dsidev); |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 728 | |
Archit Taneja | f1da39d | 2011-05-12 17:26:27 +0530 | [diff] [blame] | 729 | spin_lock(&dsi->irq_lock); |
Tomi Valkeinen | 4ae2ddd | 2011-03-02 14:47:04 +0200 | [diff] [blame] | 730 | |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 731 | irqstatus = dsi_read_reg(dsidev, DSI_IRQSTATUS); |
Tomi Valkeinen | 69b281a | 2011-03-02 14:44:27 +0200 | [diff] [blame] | 732 | |
| 733 | /* IRQ is not for us */ |
Tomi Valkeinen | 4ae2ddd | 2011-03-02 14:47:04 +0200 | [diff] [blame] | 734 | if (!irqstatus) { |
Archit Taneja | f1da39d | 2011-05-12 17:26:27 +0530 | [diff] [blame] | 735 | spin_unlock(&dsi->irq_lock); |
Tomi Valkeinen | 69b281a | 2011-03-02 14:44:27 +0200 | [diff] [blame] | 736 | return IRQ_NONE; |
Tomi Valkeinen | 4ae2ddd | 2011-03-02 14:47:04 +0200 | [diff] [blame] | 737 | } |
Tomi Valkeinen | 69b281a | 2011-03-02 14:44:27 +0200 | [diff] [blame] | 738 | |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 739 | dsi_write_reg(dsidev, DSI_IRQSTATUS, irqstatus & ~DSI_IRQ_CHANNEL_MASK); |
Tomi Valkeinen | 69b281a | 2011-03-02 14:44:27 +0200 | [diff] [blame] | 740 | /* flush posted write */ |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 741 | dsi_read_reg(dsidev, DSI_IRQSTATUS); |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 742 | |
| 743 | for (i = 0; i < 4; ++i) { |
Tomi Valkeinen | 69b281a | 2011-03-02 14:44:27 +0200 | [diff] [blame] | 744 | if ((irqstatus & (1 << i)) == 0) { |
| 745 | vcstatus[i] = 0; |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 746 | continue; |
Tomi Valkeinen | ab83b14 | 2010-06-09 15:31:01 +0300 | [diff] [blame] | 747 | } |
| 748 | |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 749 | vcstatus[i] = dsi_read_reg(dsidev, DSI_VC_IRQSTATUS(i)); |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 750 | |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 751 | dsi_write_reg(dsidev, DSI_VC_IRQSTATUS(i), vcstatus[i]); |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 752 | /* flush posted write */ |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 753 | dsi_read_reg(dsidev, DSI_VC_IRQSTATUS(i)); |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 754 | } |
| 755 | |
| 756 | if (irqstatus & DSI_IRQ_COMPLEXIO_ERR) { |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 757 | ciostatus = dsi_read_reg(dsidev, DSI_COMPLEXIO_IRQ_STATUS); |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 758 | |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 759 | dsi_write_reg(dsidev, DSI_COMPLEXIO_IRQ_STATUS, ciostatus); |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 760 | /* flush posted write */ |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 761 | dsi_read_reg(dsidev, DSI_COMPLEXIO_IRQ_STATUS); |
Tomi Valkeinen | 69b281a | 2011-03-02 14:44:27 +0200 | [diff] [blame] | 762 | } else { |
| 763 | ciostatus = 0; |
| 764 | } |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 765 | |
Tomi Valkeinen | 69b281a | 2011-03-02 14:44:27 +0200 | [diff] [blame] | 766 | #ifdef DSI_CATCH_MISSING_TE |
| 767 | if (irqstatus & DSI_IRQ_TE_TRIGGER) |
Archit Taneja | f1da39d | 2011-05-12 17:26:27 +0530 | [diff] [blame] | 768 | del_timer(&dsi->te_timer); |
Tomi Valkeinen | 69b281a | 2011-03-02 14:44:27 +0200 | [diff] [blame] | 769 | #endif |
| 770 | |
Tomi Valkeinen | 4ae2ddd | 2011-03-02 14:47:04 +0200 | [diff] [blame] | 771 | /* make a copy and unlock, so that isrs can unregister |
| 772 | * themselves */ |
Archit Taneja | f1da39d | 2011-05-12 17:26:27 +0530 | [diff] [blame] | 773 | memcpy(&dsi->isr_tables_copy, &dsi->isr_tables, |
| 774 | sizeof(dsi->isr_tables)); |
Tomi Valkeinen | 4ae2ddd | 2011-03-02 14:47:04 +0200 | [diff] [blame] | 775 | |
Archit Taneja | f1da39d | 2011-05-12 17:26:27 +0530 | [diff] [blame] | 776 | spin_unlock(&dsi->irq_lock); |
Tomi Valkeinen | 4ae2ddd | 2011-03-02 14:47:04 +0200 | [diff] [blame] | 777 | |
Archit Taneja | f1da39d | 2011-05-12 17:26:27 +0530 | [diff] [blame] | 778 | dsi_handle_isrs(&dsi->isr_tables_copy, irqstatus, vcstatus, ciostatus); |
Tomi Valkeinen | 4ae2ddd | 2011-03-02 14:47:04 +0200 | [diff] [blame] | 779 | |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 780 | dsi_handle_irq_errors(dsidev, irqstatus, vcstatus, ciostatus); |
Tomi Valkeinen | dfc0fd8 | 2009-12-17 14:35:21 +0200 | [diff] [blame] | 781 | |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 782 | dsi_collect_irq_stats(dsidev, irqstatus, vcstatus, ciostatus); |
Tomi Valkeinen | 69b281a | 2011-03-02 14:44:27 +0200 | [diff] [blame] | 783 | |
archit taneja | affe360 | 2011-02-23 08:41:03 +0000 | [diff] [blame] | 784 | return IRQ_HANDLED; |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 785 | } |
| 786 | |
Archit Taneja | f1da39d | 2011-05-12 17:26:27 +0530 | [diff] [blame] | 787 | /* dsi->irq_lock has to be locked by the caller */ |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 788 | static void _omap_dsi_configure_irqs(struct platform_device *dsidev, |
| 789 | struct dsi_isr_data *isr_array, |
Tomi Valkeinen | 4ae2ddd | 2011-03-02 14:47:04 +0200 | [diff] [blame] | 790 | unsigned isr_array_size, u32 default_mask, |
| 791 | const struct dsi_reg enable_reg, |
| 792 | const struct dsi_reg status_reg) |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 793 | { |
Tomi Valkeinen | 4ae2ddd | 2011-03-02 14:47:04 +0200 | [diff] [blame] | 794 | struct dsi_isr_data *isr_data; |
| 795 | u32 mask; |
| 796 | u32 old_mask; |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 797 | int i; |
| 798 | |
Tomi Valkeinen | 4ae2ddd | 2011-03-02 14:47:04 +0200 | [diff] [blame] | 799 | mask = default_mask; |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 800 | |
Tomi Valkeinen | 4ae2ddd | 2011-03-02 14:47:04 +0200 | [diff] [blame] | 801 | for (i = 0; i < isr_array_size; i++) { |
| 802 | isr_data = &isr_array[i]; |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 803 | |
Tomi Valkeinen | 4ae2ddd | 2011-03-02 14:47:04 +0200 | [diff] [blame] | 804 | if (isr_data->isr == NULL) |
| 805 | continue; |
| 806 | |
| 807 | mask |= isr_data->mask; |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 808 | } |
| 809 | |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 810 | old_mask = dsi_read_reg(dsidev, enable_reg); |
Tomi Valkeinen | 4ae2ddd | 2011-03-02 14:47:04 +0200 | [diff] [blame] | 811 | /* clear the irqstatus for newly enabled irqs */ |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 812 | dsi_write_reg(dsidev, status_reg, (mask ^ old_mask) & mask); |
| 813 | dsi_write_reg(dsidev, enable_reg, mask); |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 814 | |
Tomi Valkeinen | 4ae2ddd | 2011-03-02 14:47:04 +0200 | [diff] [blame] | 815 | /* flush posted writes */ |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 816 | dsi_read_reg(dsidev, enable_reg); |
| 817 | dsi_read_reg(dsidev, status_reg); |
Tomi Valkeinen | 4ae2ddd | 2011-03-02 14:47:04 +0200 | [diff] [blame] | 818 | } |
| 819 | |
Archit Taneja | f1da39d | 2011-05-12 17:26:27 +0530 | [diff] [blame] | 820 | /* dsi->irq_lock has to be locked by the caller */ |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 821 | static void _omap_dsi_set_irqs(struct platform_device *dsidev) |
Tomi Valkeinen | 4ae2ddd | 2011-03-02 14:47:04 +0200 | [diff] [blame] | 822 | { |
Archit Taneja | f1da39d | 2011-05-12 17:26:27 +0530 | [diff] [blame] | 823 | struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev); |
Tomi Valkeinen | 4ae2ddd | 2011-03-02 14:47:04 +0200 | [diff] [blame] | 824 | u32 mask = DSI_IRQ_ERROR_MASK; |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 825 | #ifdef DSI_CATCH_MISSING_TE |
Tomi Valkeinen | 4ae2ddd | 2011-03-02 14:47:04 +0200 | [diff] [blame] | 826 | mask |= DSI_IRQ_TE_TRIGGER; |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 827 | #endif |
Archit Taneja | f1da39d | 2011-05-12 17:26:27 +0530 | [diff] [blame] | 828 | _omap_dsi_configure_irqs(dsidev, dsi->isr_tables.isr_table, |
| 829 | ARRAY_SIZE(dsi->isr_tables.isr_table), mask, |
Tomi Valkeinen | 4ae2ddd | 2011-03-02 14:47:04 +0200 | [diff] [blame] | 830 | DSI_IRQENABLE, DSI_IRQSTATUS); |
| 831 | } |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 832 | |
Archit Taneja | f1da39d | 2011-05-12 17:26:27 +0530 | [diff] [blame] | 833 | /* dsi->irq_lock has to be locked by the caller */ |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 834 | static void _omap_dsi_set_irqs_vc(struct platform_device *dsidev, int vc) |
Tomi Valkeinen | 4ae2ddd | 2011-03-02 14:47:04 +0200 | [diff] [blame] | 835 | { |
Archit Taneja | f1da39d | 2011-05-12 17:26:27 +0530 | [diff] [blame] | 836 | struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev); |
| 837 | |
| 838 | _omap_dsi_configure_irqs(dsidev, dsi->isr_tables.isr_table_vc[vc], |
| 839 | ARRAY_SIZE(dsi->isr_tables.isr_table_vc[vc]), |
Tomi Valkeinen | 4ae2ddd | 2011-03-02 14:47:04 +0200 | [diff] [blame] | 840 | DSI_VC_IRQ_ERROR_MASK, |
| 841 | DSI_VC_IRQENABLE(vc), DSI_VC_IRQSTATUS(vc)); |
| 842 | } |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 843 | |
Archit Taneja | f1da39d | 2011-05-12 17:26:27 +0530 | [diff] [blame] | 844 | /* dsi->irq_lock has to be locked by the caller */ |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 845 | static void _omap_dsi_set_irqs_cio(struct platform_device *dsidev) |
Tomi Valkeinen | 4ae2ddd | 2011-03-02 14:47:04 +0200 | [diff] [blame] | 846 | { |
Archit Taneja | f1da39d | 2011-05-12 17:26:27 +0530 | [diff] [blame] | 847 | struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev); |
| 848 | |
| 849 | _omap_dsi_configure_irqs(dsidev, dsi->isr_tables.isr_table_cio, |
| 850 | ARRAY_SIZE(dsi->isr_tables.isr_table_cio), |
Tomi Valkeinen | 4ae2ddd | 2011-03-02 14:47:04 +0200 | [diff] [blame] | 851 | DSI_CIO_IRQ_ERROR_MASK, |
| 852 | DSI_COMPLEXIO_IRQ_ENABLE, DSI_COMPLEXIO_IRQ_STATUS); |
| 853 | } |
| 854 | |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 855 | static void _dsi_initialize_irq(struct platform_device *dsidev) |
Tomi Valkeinen | 4ae2ddd | 2011-03-02 14:47:04 +0200 | [diff] [blame] | 856 | { |
Archit Taneja | f1da39d | 2011-05-12 17:26:27 +0530 | [diff] [blame] | 857 | struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev); |
Tomi Valkeinen | 4ae2ddd | 2011-03-02 14:47:04 +0200 | [diff] [blame] | 858 | unsigned long flags; |
| 859 | int vc; |
| 860 | |
Archit Taneja | f1da39d | 2011-05-12 17:26:27 +0530 | [diff] [blame] | 861 | spin_lock_irqsave(&dsi->irq_lock, flags); |
Tomi Valkeinen | 4ae2ddd | 2011-03-02 14:47:04 +0200 | [diff] [blame] | 862 | |
Archit Taneja | f1da39d | 2011-05-12 17:26:27 +0530 | [diff] [blame] | 863 | memset(&dsi->isr_tables, 0, sizeof(dsi->isr_tables)); |
Tomi Valkeinen | 4ae2ddd | 2011-03-02 14:47:04 +0200 | [diff] [blame] | 864 | |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 865 | _omap_dsi_set_irqs(dsidev); |
Tomi Valkeinen | 4ae2ddd | 2011-03-02 14:47:04 +0200 | [diff] [blame] | 866 | for (vc = 0; vc < 4; ++vc) |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 867 | _omap_dsi_set_irqs_vc(dsidev, vc); |
| 868 | _omap_dsi_set_irqs_cio(dsidev); |
Tomi Valkeinen | 4ae2ddd | 2011-03-02 14:47:04 +0200 | [diff] [blame] | 869 | |
Archit Taneja | f1da39d | 2011-05-12 17:26:27 +0530 | [diff] [blame] | 870 | spin_unlock_irqrestore(&dsi->irq_lock, flags); |
Tomi Valkeinen | 4ae2ddd | 2011-03-02 14:47:04 +0200 | [diff] [blame] | 871 | } |
| 872 | |
| 873 | static int _dsi_register_isr(omap_dsi_isr_t isr, void *arg, u32 mask, |
| 874 | struct dsi_isr_data *isr_array, unsigned isr_array_size) |
| 875 | { |
| 876 | struct dsi_isr_data *isr_data; |
| 877 | int free_idx; |
| 878 | int i; |
| 879 | |
| 880 | BUG_ON(isr == NULL); |
| 881 | |
| 882 | /* check for duplicate entry and find a free slot */ |
| 883 | free_idx = -1; |
| 884 | for (i = 0; i < isr_array_size; i++) { |
| 885 | isr_data = &isr_array[i]; |
| 886 | |
| 887 | if (isr_data->isr == isr && isr_data->arg == arg && |
| 888 | isr_data->mask == mask) { |
| 889 | return -EINVAL; |
| 890 | } |
| 891 | |
| 892 | if (isr_data->isr == NULL && free_idx == -1) |
| 893 | free_idx = i; |
| 894 | } |
| 895 | |
| 896 | if (free_idx == -1) |
| 897 | return -EBUSY; |
| 898 | |
| 899 | isr_data = &isr_array[free_idx]; |
| 900 | isr_data->isr = isr; |
| 901 | isr_data->arg = arg; |
| 902 | isr_data->mask = mask; |
| 903 | |
| 904 | return 0; |
| 905 | } |
| 906 | |
| 907 | static int _dsi_unregister_isr(omap_dsi_isr_t isr, void *arg, u32 mask, |
| 908 | struct dsi_isr_data *isr_array, unsigned isr_array_size) |
| 909 | { |
| 910 | struct dsi_isr_data *isr_data; |
| 911 | int i; |
| 912 | |
| 913 | for (i = 0; i < isr_array_size; i++) { |
| 914 | isr_data = &isr_array[i]; |
| 915 | if (isr_data->isr != isr || isr_data->arg != arg || |
| 916 | isr_data->mask != mask) |
| 917 | continue; |
| 918 | |
| 919 | isr_data->isr = NULL; |
| 920 | isr_data->arg = NULL; |
| 921 | isr_data->mask = 0; |
| 922 | |
| 923 | return 0; |
| 924 | } |
| 925 | |
| 926 | return -EINVAL; |
| 927 | } |
| 928 | |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 929 | static int dsi_register_isr(struct platform_device *dsidev, omap_dsi_isr_t isr, |
| 930 | void *arg, u32 mask) |
Tomi Valkeinen | 4ae2ddd | 2011-03-02 14:47:04 +0200 | [diff] [blame] | 931 | { |
Archit Taneja | f1da39d | 2011-05-12 17:26:27 +0530 | [diff] [blame] | 932 | struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev); |
Tomi Valkeinen | 4ae2ddd | 2011-03-02 14:47:04 +0200 | [diff] [blame] | 933 | unsigned long flags; |
| 934 | int r; |
| 935 | |
Archit Taneja | f1da39d | 2011-05-12 17:26:27 +0530 | [diff] [blame] | 936 | spin_lock_irqsave(&dsi->irq_lock, flags); |
Tomi Valkeinen | 4ae2ddd | 2011-03-02 14:47:04 +0200 | [diff] [blame] | 937 | |
Archit Taneja | f1da39d | 2011-05-12 17:26:27 +0530 | [diff] [blame] | 938 | r = _dsi_register_isr(isr, arg, mask, dsi->isr_tables.isr_table, |
| 939 | ARRAY_SIZE(dsi->isr_tables.isr_table)); |
Tomi Valkeinen | 4ae2ddd | 2011-03-02 14:47:04 +0200 | [diff] [blame] | 940 | |
| 941 | if (r == 0) |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 942 | _omap_dsi_set_irqs(dsidev); |
Tomi Valkeinen | 4ae2ddd | 2011-03-02 14:47:04 +0200 | [diff] [blame] | 943 | |
Archit Taneja | f1da39d | 2011-05-12 17:26:27 +0530 | [diff] [blame] | 944 | spin_unlock_irqrestore(&dsi->irq_lock, flags); |
Tomi Valkeinen | 4ae2ddd | 2011-03-02 14:47:04 +0200 | [diff] [blame] | 945 | |
| 946 | return r; |
| 947 | } |
| 948 | |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 949 | static int dsi_unregister_isr(struct platform_device *dsidev, |
| 950 | omap_dsi_isr_t isr, void *arg, u32 mask) |
Tomi Valkeinen | 4ae2ddd | 2011-03-02 14:47:04 +0200 | [diff] [blame] | 951 | { |
Archit Taneja | f1da39d | 2011-05-12 17:26:27 +0530 | [diff] [blame] | 952 | struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev); |
Tomi Valkeinen | 4ae2ddd | 2011-03-02 14:47:04 +0200 | [diff] [blame] | 953 | unsigned long flags; |
| 954 | int r; |
| 955 | |
Archit Taneja | f1da39d | 2011-05-12 17:26:27 +0530 | [diff] [blame] | 956 | spin_lock_irqsave(&dsi->irq_lock, flags); |
Tomi Valkeinen | 4ae2ddd | 2011-03-02 14:47:04 +0200 | [diff] [blame] | 957 | |
Archit Taneja | f1da39d | 2011-05-12 17:26:27 +0530 | [diff] [blame] | 958 | r = _dsi_unregister_isr(isr, arg, mask, dsi->isr_tables.isr_table, |
| 959 | ARRAY_SIZE(dsi->isr_tables.isr_table)); |
Tomi Valkeinen | 4ae2ddd | 2011-03-02 14:47:04 +0200 | [diff] [blame] | 960 | |
| 961 | if (r == 0) |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 962 | _omap_dsi_set_irqs(dsidev); |
Tomi Valkeinen | 4ae2ddd | 2011-03-02 14:47:04 +0200 | [diff] [blame] | 963 | |
Archit Taneja | f1da39d | 2011-05-12 17:26:27 +0530 | [diff] [blame] | 964 | spin_unlock_irqrestore(&dsi->irq_lock, flags); |
Tomi Valkeinen | 4ae2ddd | 2011-03-02 14:47:04 +0200 | [diff] [blame] | 965 | |
| 966 | return r; |
| 967 | } |
| 968 | |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 969 | static int dsi_register_isr_vc(struct platform_device *dsidev, int channel, |
| 970 | omap_dsi_isr_t isr, void *arg, u32 mask) |
Tomi Valkeinen | 4ae2ddd | 2011-03-02 14:47:04 +0200 | [diff] [blame] | 971 | { |
Archit Taneja | f1da39d | 2011-05-12 17:26:27 +0530 | [diff] [blame] | 972 | struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev); |
Tomi Valkeinen | 4ae2ddd | 2011-03-02 14:47:04 +0200 | [diff] [blame] | 973 | unsigned long flags; |
| 974 | int r; |
| 975 | |
Archit Taneja | f1da39d | 2011-05-12 17:26:27 +0530 | [diff] [blame] | 976 | spin_lock_irqsave(&dsi->irq_lock, flags); |
Tomi Valkeinen | 4ae2ddd | 2011-03-02 14:47:04 +0200 | [diff] [blame] | 977 | |
| 978 | r = _dsi_register_isr(isr, arg, mask, |
Archit Taneja | f1da39d | 2011-05-12 17:26:27 +0530 | [diff] [blame] | 979 | dsi->isr_tables.isr_table_vc[channel], |
| 980 | ARRAY_SIZE(dsi->isr_tables.isr_table_vc[channel])); |
Tomi Valkeinen | 4ae2ddd | 2011-03-02 14:47:04 +0200 | [diff] [blame] | 981 | |
| 982 | if (r == 0) |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 983 | _omap_dsi_set_irqs_vc(dsidev, channel); |
Tomi Valkeinen | 4ae2ddd | 2011-03-02 14:47:04 +0200 | [diff] [blame] | 984 | |
Archit Taneja | f1da39d | 2011-05-12 17:26:27 +0530 | [diff] [blame] | 985 | spin_unlock_irqrestore(&dsi->irq_lock, flags); |
Tomi Valkeinen | 4ae2ddd | 2011-03-02 14:47:04 +0200 | [diff] [blame] | 986 | |
| 987 | return r; |
| 988 | } |
| 989 | |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 990 | static int dsi_unregister_isr_vc(struct platform_device *dsidev, int channel, |
| 991 | omap_dsi_isr_t isr, void *arg, u32 mask) |
Tomi Valkeinen | 4ae2ddd | 2011-03-02 14:47:04 +0200 | [diff] [blame] | 992 | { |
Archit Taneja | f1da39d | 2011-05-12 17:26:27 +0530 | [diff] [blame] | 993 | struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev); |
Tomi Valkeinen | 4ae2ddd | 2011-03-02 14:47:04 +0200 | [diff] [blame] | 994 | unsigned long flags; |
| 995 | int r; |
| 996 | |
Archit Taneja | f1da39d | 2011-05-12 17:26:27 +0530 | [diff] [blame] | 997 | spin_lock_irqsave(&dsi->irq_lock, flags); |
Tomi Valkeinen | 4ae2ddd | 2011-03-02 14:47:04 +0200 | [diff] [blame] | 998 | |
| 999 | r = _dsi_unregister_isr(isr, arg, mask, |
Archit Taneja | f1da39d | 2011-05-12 17:26:27 +0530 | [diff] [blame] | 1000 | dsi->isr_tables.isr_table_vc[channel], |
| 1001 | ARRAY_SIZE(dsi->isr_tables.isr_table_vc[channel])); |
Tomi Valkeinen | 4ae2ddd | 2011-03-02 14:47:04 +0200 | [diff] [blame] | 1002 | |
| 1003 | if (r == 0) |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 1004 | _omap_dsi_set_irqs_vc(dsidev, channel); |
Tomi Valkeinen | 4ae2ddd | 2011-03-02 14:47:04 +0200 | [diff] [blame] | 1005 | |
Archit Taneja | f1da39d | 2011-05-12 17:26:27 +0530 | [diff] [blame] | 1006 | spin_unlock_irqrestore(&dsi->irq_lock, flags); |
Tomi Valkeinen | 4ae2ddd | 2011-03-02 14:47:04 +0200 | [diff] [blame] | 1007 | |
| 1008 | return r; |
| 1009 | } |
| 1010 | |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 1011 | static int dsi_register_isr_cio(struct platform_device *dsidev, |
| 1012 | omap_dsi_isr_t isr, void *arg, u32 mask) |
Tomi Valkeinen | 4ae2ddd | 2011-03-02 14:47:04 +0200 | [diff] [blame] | 1013 | { |
Archit Taneja | f1da39d | 2011-05-12 17:26:27 +0530 | [diff] [blame] | 1014 | struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev); |
Tomi Valkeinen | 4ae2ddd | 2011-03-02 14:47:04 +0200 | [diff] [blame] | 1015 | unsigned long flags; |
| 1016 | int r; |
| 1017 | |
Archit Taneja | f1da39d | 2011-05-12 17:26:27 +0530 | [diff] [blame] | 1018 | spin_lock_irqsave(&dsi->irq_lock, flags); |
Tomi Valkeinen | 4ae2ddd | 2011-03-02 14:47:04 +0200 | [diff] [blame] | 1019 | |
Archit Taneja | f1da39d | 2011-05-12 17:26:27 +0530 | [diff] [blame] | 1020 | r = _dsi_register_isr(isr, arg, mask, dsi->isr_tables.isr_table_cio, |
| 1021 | ARRAY_SIZE(dsi->isr_tables.isr_table_cio)); |
Tomi Valkeinen | 4ae2ddd | 2011-03-02 14:47:04 +0200 | [diff] [blame] | 1022 | |
| 1023 | if (r == 0) |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 1024 | _omap_dsi_set_irqs_cio(dsidev); |
Tomi Valkeinen | 4ae2ddd | 2011-03-02 14:47:04 +0200 | [diff] [blame] | 1025 | |
Archit Taneja | f1da39d | 2011-05-12 17:26:27 +0530 | [diff] [blame] | 1026 | spin_unlock_irqrestore(&dsi->irq_lock, flags); |
Tomi Valkeinen | 4ae2ddd | 2011-03-02 14:47:04 +0200 | [diff] [blame] | 1027 | |
| 1028 | return r; |
| 1029 | } |
| 1030 | |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 1031 | static int dsi_unregister_isr_cio(struct platform_device *dsidev, |
| 1032 | omap_dsi_isr_t isr, void *arg, u32 mask) |
Tomi Valkeinen | 4ae2ddd | 2011-03-02 14:47:04 +0200 | [diff] [blame] | 1033 | { |
Archit Taneja | f1da39d | 2011-05-12 17:26:27 +0530 | [diff] [blame] | 1034 | struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev); |
Tomi Valkeinen | 4ae2ddd | 2011-03-02 14:47:04 +0200 | [diff] [blame] | 1035 | unsigned long flags; |
| 1036 | int r; |
| 1037 | |
Archit Taneja | f1da39d | 2011-05-12 17:26:27 +0530 | [diff] [blame] | 1038 | spin_lock_irqsave(&dsi->irq_lock, flags); |
Tomi Valkeinen | 4ae2ddd | 2011-03-02 14:47:04 +0200 | [diff] [blame] | 1039 | |
Archit Taneja | f1da39d | 2011-05-12 17:26:27 +0530 | [diff] [blame] | 1040 | r = _dsi_unregister_isr(isr, arg, mask, dsi->isr_tables.isr_table_cio, |
| 1041 | ARRAY_SIZE(dsi->isr_tables.isr_table_cio)); |
Tomi Valkeinen | 4ae2ddd | 2011-03-02 14:47:04 +0200 | [diff] [blame] | 1042 | |
| 1043 | if (r == 0) |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 1044 | _omap_dsi_set_irqs_cio(dsidev); |
Tomi Valkeinen | 4ae2ddd | 2011-03-02 14:47:04 +0200 | [diff] [blame] | 1045 | |
Archit Taneja | f1da39d | 2011-05-12 17:26:27 +0530 | [diff] [blame] | 1046 | spin_unlock_irqrestore(&dsi->irq_lock, flags); |
Tomi Valkeinen | 4ae2ddd | 2011-03-02 14:47:04 +0200 | [diff] [blame] | 1047 | |
| 1048 | return r; |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 1049 | } |
| 1050 | |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 1051 | static u32 dsi_get_errors(struct platform_device *dsidev) |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 1052 | { |
Archit Taneja | f1da39d | 2011-05-12 17:26:27 +0530 | [diff] [blame] | 1053 | struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev); |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 1054 | unsigned long flags; |
| 1055 | u32 e; |
Archit Taneja | f1da39d | 2011-05-12 17:26:27 +0530 | [diff] [blame] | 1056 | spin_lock_irqsave(&dsi->errors_lock, flags); |
| 1057 | e = dsi->errors; |
| 1058 | dsi->errors = 0; |
| 1059 | spin_unlock_irqrestore(&dsi->errors_lock, flags); |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 1060 | return e; |
| 1061 | } |
| 1062 | |
Tomi Valkeinen | 4fbafaf | 2011-05-27 10:52:19 +0300 | [diff] [blame] | 1063 | int dsi_runtime_get(struct platform_device *dsidev) |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 1064 | { |
Tomi Valkeinen | 4fbafaf | 2011-05-27 10:52:19 +0300 | [diff] [blame] | 1065 | int r; |
| 1066 | struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev); |
| 1067 | |
| 1068 | DSSDBG("dsi_runtime_get\n"); |
| 1069 | |
| 1070 | r = pm_runtime_get_sync(&dsi->pdev->dev); |
| 1071 | WARN_ON(r < 0); |
| 1072 | return r < 0 ? r : 0; |
| 1073 | } |
| 1074 | |
| 1075 | void dsi_runtime_put(struct platform_device *dsidev) |
| 1076 | { |
| 1077 | struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev); |
| 1078 | int r; |
| 1079 | |
| 1080 | DSSDBG("dsi_runtime_put\n"); |
| 1081 | |
Tomi Valkeinen | 0eaf9f5 | 2012-01-23 13:23:08 +0200 | [diff] [blame] | 1082 | r = pm_runtime_put_sync(&dsi->pdev->dev); |
Tomi Valkeinen | 5be3aeb | 2012-06-27 16:37:18 +0300 | [diff] [blame] | 1083 | WARN_ON(r < 0 && r != -ENOSYS); |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 1084 | } |
| 1085 | |
| 1086 | /* source clock for DSI PLL. this could also be PCLKFREE */ |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 1087 | static inline void dsi_enable_pll_clock(struct platform_device *dsidev, |
| 1088 | bool enable) |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 1089 | { |
Archit Taneja | f1da39d | 2011-05-12 17:26:27 +0530 | [diff] [blame] | 1090 | struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev); |
| 1091 | |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 1092 | if (enable) |
Rajendra Nayak | f11766d | 2012-06-27 14:21:26 +0530 | [diff] [blame] | 1093 | clk_prepare_enable(dsi->sys_clk); |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 1094 | else |
Rajendra Nayak | f11766d | 2012-06-27 14:21:26 +0530 | [diff] [blame] | 1095 | clk_disable_unprepare(dsi->sys_clk); |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 1096 | |
Archit Taneja | f1da39d | 2011-05-12 17:26:27 +0530 | [diff] [blame] | 1097 | if (enable && dsi->pll_locked) { |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 1098 | if (wait_for_bit_change(dsidev, DSI_PLL_STATUS, 1, 1) != 1) |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 1099 | DSSERR("cannot lock PLL when enabling clocks\n"); |
| 1100 | } |
| 1101 | } |
| 1102 | |
| 1103 | #ifdef DEBUG |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 1104 | static void _dsi_print_reset_status(struct platform_device *dsidev) |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 1105 | { |
| 1106 | u32 l; |
Tomi Valkeinen | c335cbf | 2010-10-07 13:27:42 +0300 | [diff] [blame] | 1107 | int b0, b1, b2; |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 1108 | |
| 1109 | if (!dss_debug) |
| 1110 | return; |
| 1111 | |
| 1112 | /* A dummy read using the SCP interface to any DSIPHY register is |
| 1113 | * required after DSIPHY reset to complete the reset of the DSI complex |
| 1114 | * I/O. */ |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 1115 | l = dsi_read_reg(dsidev, DSI_DSIPHY_CFG5); |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 1116 | |
| 1117 | printk(KERN_DEBUG "DSI resets: "); |
| 1118 | |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 1119 | l = dsi_read_reg(dsidev, DSI_PLL_STATUS); |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 1120 | printk("PLL (%d) ", FLD_GET(l, 0, 0)); |
| 1121 | |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 1122 | l = dsi_read_reg(dsidev, DSI_COMPLEXIO_CFG1); |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 1123 | printk("CIO (%d) ", FLD_GET(l, 29, 29)); |
| 1124 | |
Tomi Valkeinen | c335cbf | 2010-10-07 13:27:42 +0300 | [diff] [blame] | 1125 | if (dss_has_feature(FEAT_DSI_REVERSE_TXCLKESC)) { |
| 1126 | b0 = 28; |
| 1127 | b1 = 27; |
| 1128 | b2 = 26; |
| 1129 | } else { |
| 1130 | b0 = 24; |
| 1131 | b1 = 25; |
| 1132 | b2 = 26; |
| 1133 | } |
| 1134 | |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 1135 | l = dsi_read_reg(dsidev, DSI_DSIPHY_CFG5); |
Tomi Valkeinen | c335cbf | 2010-10-07 13:27:42 +0300 | [diff] [blame] | 1136 | printk("PHY (%x%x%x, %d, %d, %d)\n", |
| 1137 | FLD_GET(l, b0, b0), |
| 1138 | FLD_GET(l, b1, b1), |
| 1139 | FLD_GET(l, b2, b2), |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 1140 | FLD_GET(l, 29, 29), |
| 1141 | FLD_GET(l, 30, 30), |
| 1142 | FLD_GET(l, 31, 31)); |
| 1143 | } |
| 1144 | #else |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 1145 | #define _dsi_print_reset_status(x) |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 1146 | #endif |
| 1147 | |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 1148 | static inline int dsi_if_enable(struct platform_device *dsidev, bool enable) |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 1149 | { |
| 1150 | DSSDBG("dsi_if_enable(%d)\n", enable); |
| 1151 | |
| 1152 | enable = enable ? 1 : 0; |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 1153 | REG_FLD_MOD(dsidev, DSI_CTRL, enable, 0, 0); /* IF_EN */ |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 1154 | |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 1155 | if (wait_for_bit_change(dsidev, DSI_CTRL, 0, enable) != enable) { |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 1156 | DSSERR("Failed to set dsi_if_enable to %d\n", enable); |
| 1157 | return -EIO; |
| 1158 | } |
| 1159 | |
| 1160 | return 0; |
| 1161 | } |
| 1162 | |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 1163 | unsigned long dsi_get_pll_hsdiv_dispc_rate(struct platform_device *dsidev) |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 1164 | { |
Archit Taneja | f1da39d | 2011-05-12 17:26:27 +0530 | [diff] [blame] | 1165 | struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev); |
| 1166 | |
| 1167 | return dsi->current_cinfo.dsi_pll_hsdiv_dispc_clk; |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 1168 | } |
| 1169 | |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 1170 | static unsigned long dsi_get_pll_hsdiv_dsi_rate(struct platform_device *dsidev) |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 1171 | { |
Archit Taneja | f1da39d | 2011-05-12 17:26:27 +0530 | [diff] [blame] | 1172 | struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev); |
| 1173 | |
| 1174 | return dsi->current_cinfo.dsi_pll_hsdiv_dsi_clk; |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 1175 | } |
| 1176 | |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 1177 | static unsigned long dsi_get_txbyteclkhs(struct platform_device *dsidev) |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 1178 | { |
Archit Taneja | f1da39d | 2011-05-12 17:26:27 +0530 | [diff] [blame] | 1179 | struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev); |
| 1180 | |
| 1181 | return dsi->current_cinfo.clkin4ddr / 16; |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 1182 | } |
| 1183 | |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 1184 | static unsigned long dsi_fclk_rate(struct platform_device *dsidev) |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 1185 | { |
| 1186 | unsigned long r; |
Tomi Valkeinen | 4fbafaf | 2011-05-27 10:52:19 +0300 | [diff] [blame] | 1187 | struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev); |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 1188 | |
Tomi Valkeinen | 11ee960 | 2012-03-09 16:07:39 +0200 | [diff] [blame] | 1189 | if (dss_get_dsi_clk_source(dsi->module_id) == OMAP_DSS_CLK_SRC_FCK) { |
Archit Taneja | 1bb4783 | 2011-02-24 14:17:30 +0530 | [diff] [blame] | 1190 | /* DSI FCLK source is DSS_CLK_FCK */ |
Tomi Valkeinen | 4fbafaf | 2011-05-27 10:52:19 +0300 | [diff] [blame] | 1191 | r = clk_get_rate(dsi->dss_clk); |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 1192 | } else { |
Archit Taneja | 1bb4783 | 2011-02-24 14:17:30 +0530 | [diff] [blame] | 1193 | /* DSI FCLK source is dsi_pll_hsdiv_dsi_clk */ |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 1194 | r = dsi_get_pll_hsdiv_dsi_rate(dsidev); |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 1195 | } |
| 1196 | |
| 1197 | return r; |
| 1198 | } |
| 1199 | |
| 1200 | static int dsi_set_lp_clk_divisor(struct omap_dss_device *dssdev) |
| 1201 | { |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 1202 | struct platform_device *dsidev = dsi_get_dsidev_from_dssdev(dssdev); |
Archit Taneja | f1da39d | 2011-05-12 17:26:27 +0530 | [diff] [blame] | 1203 | struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev); |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 1204 | unsigned long dsi_fclk; |
| 1205 | unsigned lp_clk_div; |
| 1206 | unsigned long lp_clk; |
| 1207 | |
Tomi Valkeinen | c6940a3 | 2011-02-22 13:36:10 +0200 | [diff] [blame] | 1208 | lp_clk_div = dssdev->clocks.dsi.lp_clk_div; |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 1209 | |
Archit Taneja | f1da39d | 2011-05-12 17:26:27 +0530 | [diff] [blame] | 1210 | if (lp_clk_div == 0 || lp_clk_div > dsi->lpdiv_max) |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 1211 | return -EINVAL; |
| 1212 | |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 1213 | dsi_fclk = dsi_fclk_rate(dsidev); |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 1214 | |
| 1215 | lp_clk = dsi_fclk / 2 / lp_clk_div; |
| 1216 | |
| 1217 | DSSDBG("LP_CLK_DIV %u, LP_CLK %lu\n", lp_clk_div, lp_clk); |
Archit Taneja | f1da39d | 2011-05-12 17:26:27 +0530 | [diff] [blame] | 1218 | dsi->current_cinfo.lp_clk = lp_clk; |
| 1219 | dsi->current_cinfo.lp_clk_div = lp_clk_div; |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 1220 | |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 1221 | /* LP_CLK_DIVISOR */ |
| 1222 | REG_FLD_MOD(dsidev, DSI_CLK_CTRL, lp_clk_div, 12, 0); |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 1223 | |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 1224 | /* LP_RX_SYNCHRO_ENABLE */ |
| 1225 | REG_FLD_MOD(dsidev, DSI_CLK_CTRL, dsi_fclk > 30000000 ? 1 : 0, 21, 21); |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 1226 | |
| 1227 | return 0; |
| 1228 | } |
| 1229 | |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 1230 | static void dsi_enable_scp_clk(struct platform_device *dsidev) |
Tomi Valkeinen | 24c1ae4 | 2011-04-13 17:12:52 +0300 | [diff] [blame] | 1231 | { |
Archit Taneja | f1da39d | 2011-05-12 17:26:27 +0530 | [diff] [blame] | 1232 | struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev); |
| 1233 | |
| 1234 | if (dsi->scp_clk_refcount++ == 0) |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 1235 | REG_FLD_MOD(dsidev, DSI_CLK_CTRL, 1, 14, 14); /* CIO_CLK_ICG */ |
Tomi Valkeinen | 24c1ae4 | 2011-04-13 17:12:52 +0300 | [diff] [blame] | 1236 | } |
| 1237 | |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 1238 | static void dsi_disable_scp_clk(struct platform_device *dsidev) |
Tomi Valkeinen | 24c1ae4 | 2011-04-13 17:12:52 +0300 | [diff] [blame] | 1239 | { |
Archit Taneja | f1da39d | 2011-05-12 17:26:27 +0530 | [diff] [blame] | 1240 | struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev); |
| 1241 | |
| 1242 | WARN_ON(dsi->scp_clk_refcount == 0); |
| 1243 | if (--dsi->scp_clk_refcount == 0) |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 1244 | REG_FLD_MOD(dsidev, DSI_CLK_CTRL, 0, 14, 14); /* CIO_CLK_ICG */ |
Tomi Valkeinen | 24c1ae4 | 2011-04-13 17:12:52 +0300 | [diff] [blame] | 1245 | } |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 1246 | |
| 1247 | enum dsi_pll_power_state { |
| 1248 | DSI_PLL_POWER_OFF = 0x0, |
| 1249 | DSI_PLL_POWER_ON_HSCLK = 0x1, |
| 1250 | DSI_PLL_POWER_ON_ALL = 0x2, |
| 1251 | DSI_PLL_POWER_ON_DIV = 0x3, |
| 1252 | }; |
| 1253 | |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 1254 | static int dsi_pll_power(struct platform_device *dsidev, |
| 1255 | enum dsi_pll_power_state state) |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 1256 | { |
| 1257 | int t = 0; |
| 1258 | |
Tomi Valkeinen | c94dfe0 | 2011-04-15 10:42:59 +0300 | [diff] [blame] | 1259 | /* DSI-PLL power command 0x3 is not working */ |
| 1260 | if (dss_has_feature(FEAT_DSI_PLL_PWR_BUG) && |
| 1261 | state == DSI_PLL_POWER_ON_DIV) |
| 1262 | state = DSI_PLL_POWER_ON_ALL; |
| 1263 | |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 1264 | /* PLL_PWR_CMD */ |
| 1265 | REG_FLD_MOD(dsidev, DSI_CLK_CTRL, state, 31, 30); |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 1266 | |
| 1267 | /* PLL_PWR_STATUS */ |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 1268 | while (FLD_GET(dsi_read_reg(dsidev, DSI_CLK_CTRL), 29, 28) != state) { |
Tomi Valkeinen | 24be78b | 2010-01-07 14:19:48 +0200 | [diff] [blame] | 1269 | if (++t > 1000) { |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 1270 | DSSERR("Failed to set DSI PLL power mode to %d\n", |
| 1271 | state); |
| 1272 | return -ENODEV; |
| 1273 | } |
Tomi Valkeinen | 24be78b | 2010-01-07 14:19:48 +0200 | [diff] [blame] | 1274 | udelay(1); |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 1275 | } |
| 1276 | |
| 1277 | return 0; |
| 1278 | } |
| 1279 | |
| 1280 | /* calculate clock rates using dividers in cinfo */ |
Tomi Valkeinen | b6e695a | 2012-03-15 15:22:58 +0200 | [diff] [blame] | 1281 | static int dsi_calc_clock_rates(struct platform_device *dsidev, |
Sumit Semwal | ff1b2cd | 2010-12-02 11:27:11 +0000 | [diff] [blame] | 1282 | struct dsi_clock_info *cinfo) |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 1283 | { |
Archit Taneja | f1da39d | 2011-05-12 17:26:27 +0530 | [diff] [blame] | 1284 | struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev); |
| 1285 | |
| 1286 | if (cinfo->regn == 0 || cinfo->regn > dsi->regn_max) |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 1287 | return -EINVAL; |
| 1288 | |
Archit Taneja | f1da39d | 2011-05-12 17:26:27 +0530 | [diff] [blame] | 1289 | if (cinfo->regm == 0 || cinfo->regm > dsi->regm_max) |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 1290 | return -EINVAL; |
| 1291 | |
Archit Taneja | f1da39d | 2011-05-12 17:26:27 +0530 | [diff] [blame] | 1292 | if (cinfo->regm_dispc > dsi->regm_dispc_max) |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 1293 | return -EINVAL; |
| 1294 | |
Archit Taneja | f1da39d | 2011-05-12 17:26:27 +0530 | [diff] [blame] | 1295 | if (cinfo->regm_dsi > dsi->regm_dsi_max) |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 1296 | return -EINVAL; |
| 1297 | |
Tomi Valkeinen | b6e695a | 2012-03-15 15:22:58 +0200 | [diff] [blame] | 1298 | cinfo->clkin = clk_get_rate(dsi->sys_clk); |
| 1299 | cinfo->fint = cinfo->clkin / cinfo->regn; |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 1300 | |
Archit Taneja | f1da39d | 2011-05-12 17:26:27 +0530 | [diff] [blame] | 1301 | if (cinfo->fint > dsi->fint_max || cinfo->fint < dsi->fint_min) |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 1302 | return -EINVAL; |
| 1303 | |
| 1304 | cinfo->clkin4ddr = 2 * cinfo->regm * cinfo->fint; |
| 1305 | |
| 1306 | if (cinfo->clkin4ddr > 1800 * 1000 * 1000) |
| 1307 | return -EINVAL; |
| 1308 | |
Archit Taneja | 1bb4783 | 2011-02-24 14:17:30 +0530 | [diff] [blame] | 1309 | if (cinfo->regm_dispc > 0) |
| 1310 | cinfo->dsi_pll_hsdiv_dispc_clk = |
| 1311 | cinfo->clkin4ddr / cinfo->regm_dispc; |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 1312 | else |
Archit Taneja | 1bb4783 | 2011-02-24 14:17:30 +0530 | [diff] [blame] | 1313 | cinfo->dsi_pll_hsdiv_dispc_clk = 0; |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 1314 | |
Archit Taneja | 1bb4783 | 2011-02-24 14:17:30 +0530 | [diff] [blame] | 1315 | if (cinfo->regm_dsi > 0) |
| 1316 | cinfo->dsi_pll_hsdiv_dsi_clk = |
| 1317 | cinfo->clkin4ddr / cinfo->regm_dsi; |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 1318 | else |
Archit Taneja | 1bb4783 | 2011-02-24 14:17:30 +0530 | [diff] [blame] | 1319 | cinfo->dsi_pll_hsdiv_dsi_clk = 0; |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 1320 | |
| 1321 | return 0; |
| 1322 | } |
| 1323 | |
Archit Taneja | 6d523e7 | 2012-06-21 09:33:55 +0530 | [diff] [blame] | 1324 | int dsi_pll_calc_clock_div_pck(struct platform_device *dsidev, |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 1325 | unsigned long req_pck, struct dsi_clock_info *dsi_cinfo, |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 1326 | struct dispc_clock_info *dispc_cinfo) |
| 1327 | { |
Archit Taneja | f1da39d | 2011-05-12 17:26:27 +0530 | [diff] [blame] | 1328 | struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev); |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 1329 | struct dsi_clock_info cur, best; |
| 1330 | struct dispc_clock_info best_dispc; |
| 1331 | int min_fck_per_pck; |
| 1332 | int match = 0; |
Archit Taneja | 1bb4783 | 2011-02-24 14:17:30 +0530 | [diff] [blame] | 1333 | unsigned long dss_sys_clk, max_dss_fck; |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 1334 | |
Tomi Valkeinen | 4fbafaf | 2011-05-27 10:52:19 +0300 | [diff] [blame] | 1335 | dss_sys_clk = clk_get_rate(dsi->sys_clk); |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 1336 | |
Taneja, Archit | 31ef823 | 2011-03-14 23:28:22 -0500 | [diff] [blame] | 1337 | max_dss_fck = dss_feat_get_param_max(FEAT_PARAM_DSS_FCK); |
Archit Taneja | 819d807 | 2011-03-01 11:54:00 +0530 | [diff] [blame] | 1338 | |
Archit Taneja | f1da39d | 2011-05-12 17:26:27 +0530 | [diff] [blame] | 1339 | if (req_pck == dsi->cache_req_pck && |
| 1340 | dsi->cache_cinfo.clkin == dss_sys_clk) { |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 1341 | DSSDBG("DSI clock info found from cache\n"); |
Archit Taneja | f1da39d | 2011-05-12 17:26:27 +0530 | [diff] [blame] | 1342 | *dsi_cinfo = dsi->cache_cinfo; |
Archit Taneja | 6d523e7 | 2012-06-21 09:33:55 +0530 | [diff] [blame] | 1343 | dispc_find_clk_divs(req_pck, dsi_cinfo->dsi_pll_hsdiv_dispc_clk, |
| 1344 | dispc_cinfo); |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 1345 | return 0; |
| 1346 | } |
| 1347 | |
| 1348 | min_fck_per_pck = CONFIG_OMAP2_DSS_MIN_FCK_PER_PCK; |
| 1349 | |
| 1350 | if (min_fck_per_pck && |
Archit Taneja | 819d807 | 2011-03-01 11:54:00 +0530 | [diff] [blame] | 1351 | req_pck * min_fck_per_pck > max_dss_fck) { |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 1352 | DSSERR("Requested pixel clock not possible with the current " |
| 1353 | "OMAP2_DSS_MIN_FCK_PER_PCK setting. Turning " |
| 1354 | "the constraint off.\n"); |
| 1355 | min_fck_per_pck = 0; |
| 1356 | } |
| 1357 | |
| 1358 | DSSDBG("dsi_pll_calc\n"); |
| 1359 | |
| 1360 | retry: |
| 1361 | memset(&best, 0, sizeof(best)); |
| 1362 | memset(&best_dispc, 0, sizeof(best_dispc)); |
| 1363 | |
| 1364 | memset(&cur, 0, sizeof(cur)); |
Archit Taneja | 1bb4783 | 2011-02-24 14:17:30 +0530 | [diff] [blame] | 1365 | cur.clkin = dss_sys_clk; |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 1366 | |
Tomi Valkeinen | b6e695a | 2012-03-15 15:22:58 +0200 | [diff] [blame] | 1367 | /* 0.75MHz < Fint = clkin / regn < 2.1MHz */ |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 1368 | /* To reduce PLL lock time, keep Fint high (around 2 MHz) */ |
Archit Taneja | f1da39d | 2011-05-12 17:26:27 +0530 | [diff] [blame] | 1369 | for (cur.regn = 1; cur.regn < dsi->regn_max; ++cur.regn) { |
Tomi Valkeinen | b6e695a | 2012-03-15 15:22:58 +0200 | [diff] [blame] | 1370 | cur.fint = cur.clkin / cur.regn; |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 1371 | |
Archit Taneja | f1da39d | 2011-05-12 17:26:27 +0530 | [diff] [blame] | 1372 | if (cur.fint > dsi->fint_max || cur.fint < dsi->fint_min) |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 1373 | continue; |
| 1374 | |
Tomi Valkeinen | b6e695a | 2012-03-15 15:22:58 +0200 | [diff] [blame] | 1375 | /* DSIPHY(MHz) = (2 * regm / regn) * clkin */ |
Archit Taneja | f1da39d | 2011-05-12 17:26:27 +0530 | [diff] [blame] | 1376 | for (cur.regm = 1; cur.regm < dsi->regm_max; ++cur.regm) { |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 1377 | unsigned long a, b; |
| 1378 | |
| 1379 | a = 2 * cur.regm * (cur.clkin/1000); |
Tomi Valkeinen | b6e695a | 2012-03-15 15:22:58 +0200 | [diff] [blame] | 1380 | b = cur.regn; |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 1381 | cur.clkin4ddr = a / b * 1000; |
| 1382 | |
| 1383 | if (cur.clkin4ddr > 1800 * 1000 * 1000) |
| 1384 | break; |
| 1385 | |
Archit Taneja | 1bb4783 | 2011-02-24 14:17:30 +0530 | [diff] [blame] | 1386 | /* dsi_pll_hsdiv_dispc_clk(MHz) = |
| 1387 | * DSIPHY(MHz) / regm_dispc < 173MHz/186Mhz */ |
Archit Taneja | f1da39d | 2011-05-12 17:26:27 +0530 | [diff] [blame] | 1388 | for (cur.regm_dispc = 1; cur.regm_dispc < |
| 1389 | dsi->regm_dispc_max; ++cur.regm_dispc) { |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 1390 | struct dispc_clock_info cur_dispc; |
Archit Taneja | 1bb4783 | 2011-02-24 14:17:30 +0530 | [diff] [blame] | 1391 | cur.dsi_pll_hsdiv_dispc_clk = |
| 1392 | cur.clkin4ddr / cur.regm_dispc; |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 1393 | |
| 1394 | /* this will narrow down the search a bit, |
| 1395 | * but still give pixclocks below what was |
| 1396 | * requested */ |
Archit Taneja | 1bb4783 | 2011-02-24 14:17:30 +0530 | [diff] [blame] | 1397 | if (cur.dsi_pll_hsdiv_dispc_clk < req_pck) |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 1398 | break; |
| 1399 | |
Archit Taneja | 1bb4783 | 2011-02-24 14:17:30 +0530 | [diff] [blame] | 1400 | if (cur.dsi_pll_hsdiv_dispc_clk > max_dss_fck) |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 1401 | continue; |
| 1402 | |
| 1403 | if (min_fck_per_pck && |
Archit Taneja | 1bb4783 | 2011-02-24 14:17:30 +0530 | [diff] [blame] | 1404 | cur.dsi_pll_hsdiv_dispc_clk < |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 1405 | req_pck * min_fck_per_pck) |
| 1406 | continue; |
| 1407 | |
| 1408 | match = 1; |
| 1409 | |
Archit Taneja | 6d523e7 | 2012-06-21 09:33:55 +0530 | [diff] [blame] | 1410 | dispc_find_clk_divs(req_pck, |
Archit Taneja | 1bb4783 | 2011-02-24 14:17:30 +0530 | [diff] [blame] | 1411 | cur.dsi_pll_hsdiv_dispc_clk, |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 1412 | &cur_dispc); |
| 1413 | |
| 1414 | if (abs(cur_dispc.pck - req_pck) < |
| 1415 | abs(best_dispc.pck - req_pck)) { |
| 1416 | best = cur; |
| 1417 | best_dispc = cur_dispc; |
| 1418 | |
| 1419 | if (cur_dispc.pck == req_pck) |
| 1420 | goto found; |
| 1421 | } |
| 1422 | } |
| 1423 | } |
| 1424 | } |
| 1425 | found: |
| 1426 | if (!match) { |
| 1427 | if (min_fck_per_pck) { |
| 1428 | DSSERR("Could not find suitable clock settings.\n" |
| 1429 | "Turning FCK/PCK constraint off and" |
| 1430 | "trying again.\n"); |
| 1431 | min_fck_per_pck = 0; |
| 1432 | goto retry; |
| 1433 | } |
| 1434 | |
| 1435 | DSSERR("Could not find suitable clock settings.\n"); |
| 1436 | |
| 1437 | return -EINVAL; |
| 1438 | } |
| 1439 | |
Archit Taneja | 1bb4783 | 2011-02-24 14:17:30 +0530 | [diff] [blame] | 1440 | /* dsi_pll_hsdiv_dsi_clk (regm_dsi) is not used */ |
| 1441 | best.regm_dsi = 0; |
| 1442 | best.dsi_pll_hsdiv_dsi_clk = 0; |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 1443 | |
| 1444 | if (dsi_cinfo) |
| 1445 | *dsi_cinfo = best; |
| 1446 | if (dispc_cinfo) |
| 1447 | *dispc_cinfo = best_dispc; |
| 1448 | |
Archit Taneja | f1da39d | 2011-05-12 17:26:27 +0530 | [diff] [blame] | 1449 | dsi->cache_req_pck = req_pck; |
| 1450 | dsi->cache_clk_freq = 0; |
| 1451 | dsi->cache_cinfo = best; |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 1452 | |
| 1453 | return 0; |
| 1454 | } |
| 1455 | |
Tomi Valkeinen | ee144e6 | 2012-08-10 16:50:51 +0300 | [diff] [blame] | 1456 | static int dsi_pll_calc_ddrfreq(struct platform_device *dsidev, |
Tomi Valkeinen | d66b158 | 2012-09-24 15:15:06 +0300 | [diff] [blame] | 1457 | unsigned long req_clkin4ddr, struct dsi_clock_info *cinfo) |
Tomi Valkeinen | ee144e6 | 2012-08-10 16:50:51 +0300 | [diff] [blame] | 1458 | { |
| 1459 | struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev); |
| 1460 | struct dsi_clock_info cur, best; |
Tomi Valkeinen | ee144e6 | 2012-08-10 16:50:51 +0300 | [diff] [blame] | 1461 | |
| 1462 | DSSDBG("dsi_pll_calc_ddrfreq\n"); |
| 1463 | |
Tomi Valkeinen | ee144e6 | 2012-08-10 16:50:51 +0300 | [diff] [blame] | 1464 | memset(&best, 0, sizeof(best)); |
| 1465 | memset(&cur, 0, sizeof(cur)); |
| 1466 | |
Tomi Valkeinen | d66b158 | 2012-09-24 15:15:06 +0300 | [diff] [blame] | 1467 | cur.clkin = clk_get_rate(dsi->sys_clk); |
Tomi Valkeinen | ee144e6 | 2012-08-10 16:50:51 +0300 | [diff] [blame] | 1468 | |
| 1469 | for (cur.regn = 1; cur.regn < dsi->regn_max; ++cur.regn) { |
| 1470 | cur.fint = cur.clkin / cur.regn; |
| 1471 | |
| 1472 | if (cur.fint > dsi->fint_max || cur.fint < dsi->fint_min) |
| 1473 | continue; |
| 1474 | |
| 1475 | /* DSIPHY(MHz) = (2 * regm / regn) * clkin */ |
| 1476 | for (cur.regm = 1; cur.regm < dsi->regm_max; ++cur.regm) { |
| 1477 | unsigned long a, b; |
| 1478 | |
| 1479 | a = 2 * cur.regm * (cur.clkin/1000); |
| 1480 | b = cur.regn; |
| 1481 | cur.clkin4ddr = a / b * 1000; |
| 1482 | |
| 1483 | if (cur.clkin4ddr > 1800 * 1000 * 1000) |
| 1484 | break; |
| 1485 | |
| 1486 | if (abs(cur.clkin4ddr - req_clkin4ddr) < |
| 1487 | abs(best.clkin4ddr - req_clkin4ddr)) { |
| 1488 | best = cur; |
| 1489 | DSSDBG("best %ld\n", best.clkin4ddr); |
| 1490 | } |
| 1491 | |
| 1492 | if (cur.clkin4ddr == req_clkin4ddr) |
| 1493 | goto found; |
| 1494 | } |
| 1495 | } |
| 1496 | found: |
Tomi Valkeinen | ee144e6 | 2012-08-10 16:50:51 +0300 | [diff] [blame] | 1497 | if (cinfo) |
| 1498 | *cinfo = best; |
| 1499 | |
| 1500 | return 0; |
| 1501 | } |
| 1502 | |
Tomi Valkeinen | d66b158 | 2012-09-24 15:15:06 +0300 | [diff] [blame] | 1503 | static void dsi_pll_calc_dsi_fck(struct platform_device *dsidev, |
| 1504 | struct dsi_clock_info *cinfo) |
| 1505 | { |
| 1506 | unsigned long max_dsi_fck; |
| 1507 | |
| 1508 | max_dsi_fck = dss_feat_get_param_max(FEAT_PARAM_DSI_FCK); |
| 1509 | |
| 1510 | cinfo->regm_dsi = DIV_ROUND_UP(cinfo->clkin4ddr, max_dsi_fck); |
| 1511 | cinfo->dsi_pll_hsdiv_dsi_clk = cinfo->clkin4ddr / cinfo->regm_dsi; |
| 1512 | } |
| 1513 | |
| 1514 | static int dsi_pll_calc_dispc_fck(struct platform_device *dsidev, |
| 1515 | unsigned long req_pck, struct dsi_clock_info *cinfo, |
| 1516 | struct dispc_clock_info *dispc_cinfo) |
| 1517 | { |
| 1518 | struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev); |
| 1519 | unsigned regm_dispc, best_regm_dispc; |
| 1520 | unsigned long dispc_clk, best_dispc_clk; |
| 1521 | int min_fck_per_pck; |
| 1522 | unsigned long max_dss_fck; |
| 1523 | struct dispc_clock_info best_dispc; |
| 1524 | bool match; |
| 1525 | |
| 1526 | max_dss_fck = dss_feat_get_param_max(FEAT_PARAM_DSS_FCK); |
| 1527 | |
| 1528 | min_fck_per_pck = CONFIG_OMAP2_DSS_MIN_FCK_PER_PCK; |
| 1529 | |
| 1530 | if (min_fck_per_pck && |
| 1531 | req_pck * min_fck_per_pck > max_dss_fck) { |
| 1532 | DSSERR("Requested pixel clock not possible with the current " |
| 1533 | "OMAP2_DSS_MIN_FCK_PER_PCK setting. Turning " |
| 1534 | "the constraint off.\n"); |
| 1535 | min_fck_per_pck = 0; |
| 1536 | } |
| 1537 | |
| 1538 | retry: |
| 1539 | best_regm_dispc = 0; |
| 1540 | best_dispc_clk = 0; |
| 1541 | memset(&best_dispc, 0, sizeof(best_dispc)); |
| 1542 | match = false; |
| 1543 | |
| 1544 | for (regm_dispc = 1; regm_dispc < dsi->regm_dispc_max; ++regm_dispc) { |
| 1545 | struct dispc_clock_info cur_dispc; |
| 1546 | |
| 1547 | dispc_clk = cinfo->clkin4ddr / regm_dispc; |
| 1548 | |
| 1549 | /* this will narrow down the search a bit, |
| 1550 | * but still give pixclocks below what was |
| 1551 | * requested */ |
| 1552 | if (dispc_clk < req_pck) |
| 1553 | break; |
| 1554 | |
| 1555 | if (dispc_clk > max_dss_fck) |
| 1556 | continue; |
| 1557 | |
| 1558 | if (min_fck_per_pck && dispc_clk < req_pck * min_fck_per_pck) |
| 1559 | continue; |
| 1560 | |
| 1561 | match = true; |
| 1562 | |
| 1563 | dispc_find_clk_divs(req_pck, dispc_clk, &cur_dispc); |
| 1564 | |
| 1565 | if (abs(cur_dispc.pck - req_pck) < |
| 1566 | abs(best_dispc.pck - req_pck)) { |
| 1567 | best_regm_dispc = regm_dispc; |
| 1568 | best_dispc_clk = dispc_clk; |
| 1569 | best_dispc = cur_dispc; |
| 1570 | |
| 1571 | if (cur_dispc.pck == req_pck) |
| 1572 | goto found; |
| 1573 | } |
| 1574 | } |
| 1575 | |
| 1576 | if (!match) { |
| 1577 | if (min_fck_per_pck) { |
| 1578 | DSSERR("Could not find suitable clock settings.\n" |
| 1579 | "Turning FCK/PCK constraint off and" |
| 1580 | "trying again.\n"); |
| 1581 | min_fck_per_pck = 0; |
| 1582 | goto retry; |
| 1583 | } |
| 1584 | |
| 1585 | DSSERR("Could not find suitable clock settings.\n"); |
| 1586 | |
| 1587 | return -EINVAL; |
| 1588 | } |
| 1589 | found: |
| 1590 | cinfo->regm_dispc = best_regm_dispc; |
| 1591 | cinfo->dsi_pll_hsdiv_dispc_clk = best_dispc_clk; |
| 1592 | |
| 1593 | *dispc_cinfo = best_dispc; |
| 1594 | |
| 1595 | return 0; |
| 1596 | } |
| 1597 | |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 1598 | int dsi_pll_set_clock_div(struct platform_device *dsidev, |
| 1599 | struct dsi_clock_info *cinfo) |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 1600 | { |
Archit Taneja | f1da39d | 2011-05-12 17:26:27 +0530 | [diff] [blame] | 1601 | struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev); |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 1602 | int r = 0; |
| 1603 | u32 l; |
Archit Taneja | 9613c02 | 2011-03-22 06:33:36 -0500 | [diff] [blame] | 1604 | int f = 0; |
Taneja, Archit | 4964111 | 2011-03-14 23:28:23 -0500 | [diff] [blame] | 1605 | u8 regn_start, regn_end, regm_start, regm_end; |
| 1606 | u8 regm_dispc_start, regm_dispc_end, regm_dsi_start, regm_dsi_end; |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 1607 | |
| 1608 | DSSDBGF(); |
| 1609 | |
Tomi Valkeinen | b6e695a | 2012-03-15 15:22:58 +0200 | [diff] [blame] | 1610 | dsi->current_cinfo.clkin = cinfo->clkin; |
Archit Taneja | f1da39d | 2011-05-12 17:26:27 +0530 | [diff] [blame] | 1611 | dsi->current_cinfo.fint = cinfo->fint; |
| 1612 | dsi->current_cinfo.clkin4ddr = cinfo->clkin4ddr; |
| 1613 | dsi->current_cinfo.dsi_pll_hsdiv_dispc_clk = |
Archit Taneja | 1bb4783 | 2011-02-24 14:17:30 +0530 | [diff] [blame] | 1614 | cinfo->dsi_pll_hsdiv_dispc_clk; |
Archit Taneja | f1da39d | 2011-05-12 17:26:27 +0530 | [diff] [blame] | 1615 | dsi->current_cinfo.dsi_pll_hsdiv_dsi_clk = |
Archit Taneja | 1bb4783 | 2011-02-24 14:17:30 +0530 | [diff] [blame] | 1616 | cinfo->dsi_pll_hsdiv_dsi_clk; |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 1617 | |
Archit Taneja | f1da39d | 2011-05-12 17:26:27 +0530 | [diff] [blame] | 1618 | dsi->current_cinfo.regn = cinfo->regn; |
| 1619 | dsi->current_cinfo.regm = cinfo->regm; |
| 1620 | dsi->current_cinfo.regm_dispc = cinfo->regm_dispc; |
| 1621 | dsi->current_cinfo.regm_dsi = cinfo->regm_dsi; |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 1622 | |
| 1623 | DSSDBG("DSI Fint %ld\n", cinfo->fint); |
| 1624 | |
Tomi Valkeinen | b6e695a | 2012-03-15 15:22:58 +0200 | [diff] [blame] | 1625 | DSSDBG("clkin rate %ld\n", cinfo->clkin); |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 1626 | |
| 1627 | /* DSIPHY == CLKIN4DDR */ |
Tomi Valkeinen | b6e695a | 2012-03-15 15:22:58 +0200 | [diff] [blame] | 1628 | DSSDBG("CLKIN4DDR = 2 * %d / %d * %lu = %lu\n", |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 1629 | cinfo->regm, |
| 1630 | cinfo->regn, |
| 1631 | cinfo->clkin, |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 1632 | cinfo->clkin4ddr); |
| 1633 | |
| 1634 | DSSDBG("Data rate on 1 DSI lane %ld Mbps\n", |
| 1635 | cinfo->clkin4ddr / 1000 / 1000 / 2); |
| 1636 | |
| 1637 | DSSDBG("Clock lane freq %ld Hz\n", cinfo->clkin4ddr / 4); |
| 1638 | |
Archit Taneja | 1bb4783 | 2011-02-24 14:17:30 +0530 | [diff] [blame] | 1639 | DSSDBG("regm_dispc = %d, %s (%s) = %lu\n", cinfo->regm_dispc, |
Archit Taneja | 89a35e5 | 2011-04-12 13:52:23 +0530 | [diff] [blame] | 1640 | dss_get_generic_clk_source_name(OMAP_DSS_CLK_SRC_DSI_PLL_HSDIV_DISPC), |
| 1641 | dss_feat_get_clk_source_name(OMAP_DSS_CLK_SRC_DSI_PLL_HSDIV_DISPC), |
Archit Taneja | 1bb4783 | 2011-02-24 14:17:30 +0530 | [diff] [blame] | 1642 | cinfo->dsi_pll_hsdiv_dispc_clk); |
| 1643 | DSSDBG("regm_dsi = %d, %s (%s) = %lu\n", cinfo->regm_dsi, |
Archit Taneja | 89a35e5 | 2011-04-12 13:52:23 +0530 | [diff] [blame] | 1644 | dss_get_generic_clk_source_name(OMAP_DSS_CLK_SRC_DSI_PLL_HSDIV_DSI), |
| 1645 | dss_feat_get_clk_source_name(OMAP_DSS_CLK_SRC_DSI_PLL_HSDIV_DSI), |
Archit Taneja | 1bb4783 | 2011-02-24 14:17:30 +0530 | [diff] [blame] | 1646 | cinfo->dsi_pll_hsdiv_dsi_clk); |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 1647 | |
Taneja, Archit | 4964111 | 2011-03-14 23:28:23 -0500 | [diff] [blame] | 1648 | dss_feat_get_reg_field(FEAT_REG_DSIPLL_REGN, ®n_start, ®n_end); |
| 1649 | dss_feat_get_reg_field(FEAT_REG_DSIPLL_REGM, ®m_start, ®m_end); |
| 1650 | dss_feat_get_reg_field(FEAT_REG_DSIPLL_REGM_DISPC, ®m_dispc_start, |
| 1651 | ®m_dispc_end); |
| 1652 | dss_feat_get_reg_field(FEAT_REG_DSIPLL_REGM_DSI, ®m_dsi_start, |
| 1653 | ®m_dsi_end); |
| 1654 | |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 1655 | /* DSI_PLL_AUTOMODE = manual */ |
| 1656 | REG_FLD_MOD(dsidev, DSI_PLL_CONTROL, 0, 0, 0); |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 1657 | |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 1658 | l = dsi_read_reg(dsidev, DSI_PLL_CONFIGURATION1); |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 1659 | l = FLD_MOD(l, 1, 0, 0); /* DSI_PLL_STOPMODE */ |
Taneja, Archit | 4964111 | 2011-03-14 23:28:23 -0500 | [diff] [blame] | 1660 | /* DSI_PLL_REGN */ |
| 1661 | l = FLD_MOD(l, cinfo->regn - 1, regn_start, regn_end); |
| 1662 | /* DSI_PLL_REGM */ |
| 1663 | l = FLD_MOD(l, cinfo->regm, regm_start, regm_end); |
| 1664 | /* DSI_CLOCK_DIV */ |
Archit Taneja | 1bb4783 | 2011-02-24 14:17:30 +0530 | [diff] [blame] | 1665 | l = FLD_MOD(l, cinfo->regm_dispc > 0 ? cinfo->regm_dispc - 1 : 0, |
Taneja, Archit | 4964111 | 2011-03-14 23:28:23 -0500 | [diff] [blame] | 1666 | regm_dispc_start, regm_dispc_end); |
| 1667 | /* DSIPROTO_CLOCK_DIV */ |
Archit Taneja | 1bb4783 | 2011-02-24 14:17:30 +0530 | [diff] [blame] | 1668 | l = FLD_MOD(l, cinfo->regm_dsi > 0 ? cinfo->regm_dsi - 1 : 0, |
Taneja, Archit | 4964111 | 2011-03-14 23:28:23 -0500 | [diff] [blame] | 1669 | regm_dsi_start, regm_dsi_end); |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 1670 | dsi_write_reg(dsidev, DSI_PLL_CONFIGURATION1, l); |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 1671 | |
Archit Taneja | f1da39d | 2011-05-12 17:26:27 +0530 | [diff] [blame] | 1672 | BUG_ON(cinfo->fint < dsi->fint_min || cinfo->fint > dsi->fint_max); |
Archit Taneja | 9613c02 | 2011-03-22 06:33:36 -0500 | [diff] [blame] | 1673 | |
Tomi Valkeinen | f8ef3d6 | 2012-08-22 16:00:31 +0300 | [diff] [blame^] | 1674 | l = dsi_read_reg(dsidev, DSI_PLL_CONFIGURATION2); |
| 1675 | |
Archit Taneja | 9613c02 | 2011-03-22 06:33:36 -0500 | [diff] [blame] | 1676 | if (dss_has_feature(FEAT_DSI_PLL_FREQSEL)) { |
| 1677 | f = cinfo->fint < 1000000 ? 0x3 : |
| 1678 | cinfo->fint < 1250000 ? 0x4 : |
| 1679 | cinfo->fint < 1500000 ? 0x5 : |
| 1680 | cinfo->fint < 1750000 ? 0x6 : |
| 1681 | 0x7; |
Tomi Valkeinen | f8ef3d6 | 2012-08-22 16:00:31 +0300 | [diff] [blame^] | 1682 | |
| 1683 | l = FLD_MOD(l, f, 4, 1); /* DSI_PLL_FREQSEL */ |
| 1684 | } else if (dss_has_feature(FEAT_DSI_PLL_SELFREQDCO)) { |
| 1685 | f = cinfo->clkin4ddr < 1000000000 ? 0x2 : 0x4; |
| 1686 | |
| 1687 | l = FLD_MOD(l, f, 4, 1); /* PLL_SELFREQDCO */ |
Archit Taneja | 9613c02 | 2011-03-22 06:33:36 -0500 | [diff] [blame] | 1688 | } |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 1689 | |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 1690 | l = FLD_MOD(l, 1, 13, 13); /* DSI_PLL_REFEN */ |
| 1691 | l = FLD_MOD(l, 0, 14, 14); /* DSIPHY_CLKINEN */ |
| 1692 | l = FLD_MOD(l, 1, 20, 20); /* DSI_HSDIVBYPASS */ |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 1693 | dsi_write_reg(dsidev, DSI_PLL_CONFIGURATION2, l); |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 1694 | |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 1695 | REG_FLD_MOD(dsidev, DSI_PLL_GO, 1, 0, 0); /* DSI_PLL_GO */ |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 1696 | |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 1697 | if (wait_for_bit_change(dsidev, DSI_PLL_GO, 0, 0) != 0) { |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 1698 | DSSERR("dsi pll go bit not going down.\n"); |
| 1699 | r = -EIO; |
| 1700 | goto err; |
| 1701 | } |
| 1702 | |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 1703 | if (wait_for_bit_change(dsidev, DSI_PLL_STATUS, 1, 1) != 1) { |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 1704 | DSSERR("cannot lock PLL\n"); |
| 1705 | r = -EIO; |
| 1706 | goto err; |
| 1707 | } |
| 1708 | |
Archit Taneja | f1da39d | 2011-05-12 17:26:27 +0530 | [diff] [blame] | 1709 | dsi->pll_locked = 1; |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 1710 | |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 1711 | l = dsi_read_reg(dsidev, DSI_PLL_CONFIGURATION2); |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 1712 | l = FLD_MOD(l, 0, 0, 0); /* DSI_PLL_IDLE */ |
| 1713 | l = FLD_MOD(l, 0, 5, 5); /* DSI_PLL_PLLLPMODE */ |
| 1714 | l = FLD_MOD(l, 0, 6, 6); /* DSI_PLL_LOWCURRSTBY */ |
| 1715 | l = FLD_MOD(l, 0, 7, 7); /* DSI_PLL_TIGHTPHASELOCK */ |
| 1716 | l = FLD_MOD(l, 0, 8, 8); /* DSI_PLL_DRIFTGUARDEN */ |
| 1717 | l = FLD_MOD(l, 0, 10, 9); /* DSI_PLL_LOCKSEL */ |
| 1718 | l = FLD_MOD(l, 1, 13, 13); /* DSI_PLL_REFEN */ |
| 1719 | l = FLD_MOD(l, 1, 14, 14); /* DSIPHY_CLKINEN */ |
| 1720 | l = FLD_MOD(l, 0, 15, 15); /* DSI_BYPASSEN */ |
| 1721 | l = FLD_MOD(l, 1, 16, 16); /* DSS_CLOCK_EN */ |
| 1722 | l = FLD_MOD(l, 0, 17, 17); /* DSS_CLOCK_PWDN */ |
| 1723 | l = FLD_MOD(l, 1, 18, 18); /* DSI_PROTO_CLOCK_EN */ |
| 1724 | l = FLD_MOD(l, 0, 19, 19); /* DSI_PROTO_CLOCK_PWDN */ |
| 1725 | l = FLD_MOD(l, 0, 20, 20); /* DSI_HSDIVBYPASS */ |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 1726 | dsi_write_reg(dsidev, DSI_PLL_CONFIGURATION2, l); |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 1727 | |
| 1728 | DSSDBG("PLL config done\n"); |
| 1729 | err: |
| 1730 | return r; |
| 1731 | } |
| 1732 | |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 1733 | int dsi_pll_init(struct platform_device *dsidev, bool enable_hsclk, |
| 1734 | bool enable_hsdiv) |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 1735 | { |
Archit Taneja | f1da39d | 2011-05-12 17:26:27 +0530 | [diff] [blame] | 1736 | struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev); |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 1737 | int r = 0; |
| 1738 | enum dsi_pll_power_state pwstate; |
| 1739 | |
| 1740 | DSSDBG("PLL init\n"); |
| 1741 | |
Archit Taneja | f1da39d | 2011-05-12 17:26:27 +0530 | [diff] [blame] | 1742 | if (dsi->vdds_dsi_reg == NULL) { |
Tomi Valkeinen | f2988ab | 2011-03-02 10:06:48 +0200 | [diff] [blame] | 1743 | struct regulator *vdds_dsi; |
| 1744 | |
Archit Taneja | f1da39d | 2011-05-12 17:26:27 +0530 | [diff] [blame] | 1745 | vdds_dsi = regulator_get(&dsi->pdev->dev, "vdds_dsi"); |
Tomi Valkeinen | f2988ab | 2011-03-02 10:06:48 +0200 | [diff] [blame] | 1746 | |
| 1747 | if (IS_ERR(vdds_dsi)) { |
| 1748 | DSSERR("can't get VDDS_DSI regulator\n"); |
| 1749 | return PTR_ERR(vdds_dsi); |
| 1750 | } |
| 1751 | |
Archit Taneja | f1da39d | 2011-05-12 17:26:27 +0530 | [diff] [blame] | 1752 | dsi->vdds_dsi_reg = vdds_dsi; |
Tomi Valkeinen | f2988ab | 2011-03-02 10:06:48 +0200 | [diff] [blame] | 1753 | } |
Tomi Valkeinen | f2988ab | 2011-03-02 10:06:48 +0200 | [diff] [blame] | 1754 | |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 1755 | dsi_enable_pll_clock(dsidev, 1); |
Tomi Valkeinen | 24c1ae4 | 2011-04-13 17:12:52 +0300 | [diff] [blame] | 1756 | /* |
| 1757 | * Note: SCP CLK is not required on OMAP3, but it is required on OMAP4. |
| 1758 | */ |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 1759 | dsi_enable_scp_clk(dsidev); |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 1760 | |
Archit Taneja | f1da39d | 2011-05-12 17:26:27 +0530 | [diff] [blame] | 1761 | if (!dsi->vdds_dsi_enabled) { |
| 1762 | r = regulator_enable(dsi->vdds_dsi_reg); |
Tomi Valkeinen | 2a89dc1 | 2010-07-30 12:39:34 +0300 | [diff] [blame] | 1763 | if (r) |
| 1764 | goto err0; |
Archit Taneja | f1da39d | 2011-05-12 17:26:27 +0530 | [diff] [blame] | 1765 | dsi->vdds_dsi_enabled = true; |
Tomi Valkeinen | 2a89dc1 | 2010-07-30 12:39:34 +0300 | [diff] [blame] | 1766 | } |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 1767 | |
| 1768 | /* XXX PLL does not come out of reset without this... */ |
| 1769 | dispc_pck_free_enable(1); |
| 1770 | |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 1771 | if (wait_for_bit_change(dsidev, DSI_PLL_STATUS, 0, 1) != 1) { |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 1772 | DSSERR("PLL not coming out of reset.\n"); |
| 1773 | r = -ENODEV; |
Ville Syrjälä | 481dfa0 | 2010-04-22 22:50:04 +0200 | [diff] [blame] | 1774 | dispc_pck_free_enable(0); |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 1775 | goto err1; |
| 1776 | } |
| 1777 | |
| 1778 | /* XXX ... but if left on, we get problems when planes do not |
| 1779 | * fill the whole display. No idea about this */ |
| 1780 | dispc_pck_free_enable(0); |
| 1781 | |
| 1782 | if (enable_hsclk && enable_hsdiv) |
| 1783 | pwstate = DSI_PLL_POWER_ON_ALL; |
| 1784 | else if (enable_hsclk) |
| 1785 | pwstate = DSI_PLL_POWER_ON_HSCLK; |
| 1786 | else if (enable_hsdiv) |
| 1787 | pwstate = DSI_PLL_POWER_ON_DIV; |
| 1788 | else |
| 1789 | pwstate = DSI_PLL_POWER_OFF; |
| 1790 | |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 1791 | r = dsi_pll_power(dsidev, pwstate); |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 1792 | |
| 1793 | if (r) |
| 1794 | goto err1; |
| 1795 | |
| 1796 | DSSDBG("PLL init done\n"); |
| 1797 | |
| 1798 | return 0; |
| 1799 | err1: |
Archit Taneja | f1da39d | 2011-05-12 17:26:27 +0530 | [diff] [blame] | 1800 | if (dsi->vdds_dsi_enabled) { |
| 1801 | regulator_disable(dsi->vdds_dsi_reg); |
| 1802 | dsi->vdds_dsi_enabled = false; |
Tomi Valkeinen | 2a89dc1 | 2010-07-30 12:39:34 +0300 | [diff] [blame] | 1803 | } |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 1804 | err0: |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 1805 | dsi_disable_scp_clk(dsidev); |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 1806 | dsi_enable_pll_clock(dsidev, 0); |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 1807 | return r; |
| 1808 | } |
| 1809 | |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 1810 | void dsi_pll_uninit(struct platform_device *dsidev, bool disconnect_lanes) |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 1811 | { |
Archit Taneja | f1da39d | 2011-05-12 17:26:27 +0530 | [diff] [blame] | 1812 | struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev); |
| 1813 | |
| 1814 | dsi->pll_locked = 0; |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 1815 | dsi_pll_power(dsidev, DSI_PLL_POWER_OFF); |
Tomi Valkeinen | 2a89dc1 | 2010-07-30 12:39:34 +0300 | [diff] [blame] | 1816 | if (disconnect_lanes) { |
Archit Taneja | f1da39d | 2011-05-12 17:26:27 +0530 | [diff] [blame] | 1817 | WARN_ON(!dsi->vdds_dsi_enabled); |
| 1818 | regulator_disable(dsi->vdds_dsi_reg); |
| 1819 | dsi->vdds_dsi_enabled = false; |
Tomi Valkeinen | 2a89dc1 | 2010-07-30 12:39:34 +0300 | [diff] [blame] | 1820 | } |
Tomi Valkeinen | 24c1ae4 | 2011-04-13 17:12:52 +0300 | [diff] [blame] | 1821 | |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 1822 | dsi_disable_scp_clk(dsidev); |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 1823 | dsi_enable_pll_clock(dsidev, 0); |
Tomi Valkeinen | 24c1ae4 | 2011-04-13 17:12:52 +0300 | [diff] [blame] | 1824 | |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 1825 | DSSDBG("PLL uninit done\n"); |
| 1826 | } |
| 1827 | |
Archit Taneja | 5a8b572 | 2011-05-12 17:26:29 +0530 | [diff] [blame] | 1828 | static void dsi_dump_dsidev_clocks(struct platform_device *dsidev, |
| 1829 | struct seq_file *s) |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 1830 | { |
Archit Taneja | f1da39d | 2011-05-12 17:26:27 +0530 | [diff] [blame] | 1831 | struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev); |
| 1832 | struct dsi_clock_info *cinfo = &dsi->current_cinfo; |
Archit Taneja | 89a35e5 | 2011-04-12 13:52:23 +0530 | [diff] [blame] | 1833 | enum omap_dss_clk_source dispc_clk_src, dsi_clk_src; |
Tomi Valkeinen | 11ee960 | 2012-03-09 16:07:39 +0200 | [diff] [blame] | 1834 | int dsi_module = dsi->module_id; |
Archit Taneja | 067a57e | 2011-03-02 11:57:25 +0530 | [diff] [blame] | 1835 | |
| 1836 | dispc_clk_src = dss_get_dispc_clk_source(); |
Archit Taneja | 5a8b572 | 2011-05-12 17:26:29 +0530 | [diff] [blame] | 1837 | dsi_clk_src = dss_get_dsi_clk_source(dsi_module); |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 1838 | |
Tomi Valkeinen | 4fbafaf | 2011-05-27 10:52:19 +0300 | [diff] [blame] | 1839 | if (dsi_runtime_get(dsidev)) |
| 1840 | return; |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 1841 | |
Archit Taneja | 5a8b572 | 2011-05-12 17:26:29 +0530 | [diff] [blame] | 1842 | seq_printf(s, "- DSI%d PLL -\n", dsi_module + 1); |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 1843 | |
Tomi Valkeinen | b6e695a | 2012-03-15 15:22:58 +0200 | [diff] [blame] | 1844 | seq_printf(s, "dsi pll clkin\t%lu\n", cinfo->clkin); |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 1845 | |
| 1846 | seq_printf(s, "Fint\t\t%-16luregn %u\n", cinfo->fint, cinfo->regn); |
| 1847 | |
| 1848 | seq_printf(s, "CLKIN4DDR\t%-16luregm %u\n", |
| 1849 | cinfo->clkin4ddr, cinfo->regm); |
| 1850 | |
Archit Taneja | 84309f1 | 2011-12-12 11:47:41 +0530 | [diff] [blame] | 1851 | seq_printf(s, "DSI_PLL_HSDIV_DISPC (%s)\t%-16luregm_dispc %u\t(%s)\n", |
| 1852 | dss_feat_get_clk_source_name(dsi_module == 0 ? |
| 1853 | OMAP_DSS_CLK_SRC_DSI_PLL_HSDIV_DISPC : |
| 1854 | OMAP_DSS_CLK_SRC_DSI2_PLL_HSDIV_DISPC), |
Archit Taneja | 1bb4783 | 2011-02-24 14:17:30 +0530 | [diff] [blame] | 1855 | cinfo->dsi_pll_hsdiv_dispc_clk, |
| 1856 | cinfo->regm_dispc, |
Archit Taneja | 89a35e5 | 2011-04-12 13:52:23 +0530 | [diff] [blame] | 1857 | dispc_clk_src == OMAP_DSS_CLK_SRC_FCK ? |
Tomi Valkeinen | 63cf28a | 2010-02-23 17:40:00 +0200 | [diff] [blame] | 1858 | "off" : "on"); |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 1859 | |
Archit Taneja | 84309f1 | 2011-12-12 11:47:41 +0530 | [diff] [blame] | 1860 | seq_printf(s, "DSI_PLL_HSDIV_DSI (%s)\t%-16luregm_dsi %u\t(%s)\n", |
| 1861 | dss_feat_get_clk_source_name(dsi_module == 0 ? |
| 1862 | OMAP_DSS_CLK_SRC_DSI_PLL_HSDIV_DSI : |
| 1863 | OMAP_DSS_CLK_SRC_DSI2_PLL_HSDIV_DSI), |
Archit Taneja | 1bb4783 | 2011-02-24 14:17:30 +0530 | [diff] [blame] | 1864 | cinfo->dsi_pll_hsdiv_dsi_clk, |
| 1865 | cinfo->regm_dsi, |
Archit Taneja | 89a35e5 | 2011-04-12 13:52:23 +0530 | [diff] [blame] | 1866 | dsi_clk_src == OMAP_DSS_CLK_SRC_FCK ? |
Tomi Valkeinen | 63cf28a | 2010-02-23 17:40:00 +0200 | [diff] [blame] | 1867 | "off" : "on"); |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 1868 | |
Archit Taneja | 5a8b572 | 2011-05-12 17:26:29 +0530 | [diff] [blame] | 1869 | seq_printf(s, "- DSI%d -\n", dsi_module + 1); |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 1870 | |
Archit Taneja | 067a57e | 2011-03-02 11:57:25 +0530 | [diff] [blame] | 1871 | seq_printf(s, "dsi fclk source = %s (%s)\n", |
| 1872 | dss_get_generic_clk_source_name(dsi_clk_src), |
| 1873 | dss_feat_get_clk_source_name(dsi_clk_src)); |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 1874 | |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 1875 | seq_printf(s, "DSI_FCLK\t%lu\n", dsi_fclk_rate(dsidev)); |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 1876 | |
| 1877 | seq_printf(s, "DDR_CLK\t\t%lu\n", |
| 1878 | cinfo->clkin4ddr / 4); |
| 1879 | |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 1880 | seq_printf(s, "TxByteClkHS\t%lu\n", dsi_get_txbyteclkhs(dsidev)); |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 1881 | |
| 1882 | seq_printf(s, "LP_CLK\t\t%lu\n", cinfo->lp_clk); |
| 1883 | |
Tomi Valkeinen | 4fbafaf | 2011-05-27 10:52:19 +0300 | [diff] [blame] | 1884 | dsi_runtime_put(dsidev); |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 1885 | } |
| 1886 | |
Archit Taneja | 5a8b572 | 2011-05-12 17:26:29 +0530 | [diff] [blame] | 1887 | void dsi_dump_clocks(struct seq_file *s) |
Tomi Valkeinen | dfc0fd8 | 2009-12-17 14:35:21 +0200 | [diff] [blame] | 1888 | { |
Archit Taneja | 5a8b572 | 2011-05-12 17:26:29 +0530 | [diff] [blame] | 1889 | struct platform_device *dsidev; |
| 1890 | int i; |
| 1891 | |
| 1892 | for (i = 0; i < MAX_NUM_DSI; i++) { |
| 1893 | dsidev = dsi_get_dsidev_from_id(i); |
| 1894 | if (dsidev) |
| 1895 | dsi_dump_dsidev_clocks(dsidev, s); |
| 1896 | } |
| 1897 | } |
| 1898 | |
| 1899 | #ifdef CONFIG_OMAP2_DSS_COLLECT_IRQ_STATS |
| 1900 | static void dsi_dump_dsidev_irqs(struct platform_device *dsidev, |
| 1901 | struct seq_file *s) |
| 1902 | { |
Archit Taneja | f1da39d | 2011-05-12 17:26:27 +0530 | [diff] [blame] | 1903 | struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev); |
Tomi Valkeinen | dfc0fd8 | 2009-12-17 14:35:21 +0200 | [diff] [blame] | 1904 | unsigned long flags; |
| 1905 | struct dsi_irq_stats stats; |
| 1906 | |
Archit Taneja | f1da39d | 2011-05-12 17:26:27 +0530 | [diff] [blame] | 1907 | spin_lock_irqsave(&dsi->irq_stats_lock, flags); |
Tomi Valkeinen | dfc0fd8 | 2009-12-17 14:35:21 +0200 | [diff] [blame] | 1908 | |
Archit Taneja | f1da39d | 2011-05-12 17:26:27 +0530 | [diff] [blame] | 1909 | stats = dsi->irq_stats; |
| 1910 | memset(&dsi->irq_stats, 0, sizeof(dsi->irq_stats)); |
| 1911 | dsi->irq_stats.last_reset = jiffies; |
Tomi Valkeinen | dfc0fd8 | 2009-12-17 14:35:21 +0200 | [diff] [blame] | 1912 | |
Archit Taneja | f1da39d | 2011-05-12 17:26:27 +0530 | [diff] [blame] | 1913 | spin_unlock_irqrestore(&dsi->irq_stats_lock, flags); |
Tomi Valkeinen | dfc0fd8 | 2009-12-17 14:35:21 +0200 | [diff] [blame] | 1914 | |
| 1915 | seq_printf(s, "period %u ms\n", |
| 1916 | jiffies_to_msecs(jiffies - stats.last_reset)); |
| 1917 | |
| 1918 | seq_printf(s, "irqs %d\n", stats.irq_count); |
| 1919 | #define PIS(x) \ |
| 1920 | seq_printf(s, "%-20s %10d\n", #x, stats.dsi_irqs[ffs(DSI_IRQ_##x)-1]); |
| 1921 | |
Tomi Valkeinen | 11ee960 | 2012-03-09 16:07:39 +0200 | [diff] [blame] | 1922 | seq_printf(s, "-- DSI%d interrupts --\n", dsi->module_id + 1); |
Tomi Valkeinen | dfc0fd8 | 2009-12-17 14:35:21 +0200 | [diff] [blame] | 1923 | PIS(VC0); |
| 1924 | PIS(VC1); |
| 1925 | PIS(VC2); |
| 1926 | PIS(VC3); |
| 1927 | PIS(WAKEUP); |
| 1928 | PIS(RESYNC); |
| 1929 | PIS(PLL_LOCK); |
| 1930 | PIS(PLL_UNLOCK); |
| 1931 | PIS(PLL_RECALL); |
| 1932 | PIS(COMPLEXIO_ERR); |
| 1933 | PIS(HS_TX_TIMEOUT); |
| 1934 | PIS(LP_RX_TIMEOUT); |
| 1935 | PIS(TE_TRIGGER); |
| 1936 | PIS(ACK_TRIGGER); |
| 1937 | PIS(SYNC_LOST); |
| 1938 | PIS(LDO_POWER_GOOD); |
| 1939 | PIS(TA_TIMEOUT); |
| 1940 | #undef PIS |
| 1941 | |
| 1942 | #define PIS(x) \ |
| 1943 | seq_printf(s, "%-20s %10d %10d %10d %10d\n", #x, \ |
| 1944 | stats.vc_irqs[0][ffs(DSI_VC_IRQ_##x)-1], \ |
| 1945 | stats.vc_irqs[1][ffs(DSI_VC_IRQ_##x)-1], \ |
| 1946 | stats.vc_irqs[2][ffs(DSI_VC_IRQ_##x)-1], \ |
| 1947 | stats.vc_irqs[3][ffs(DSI_VC_IRQ_##x)-1]); |
| 1948 | |
| 1949 | seq_printf(s, "-- VC interrupts --\n"); |
| 1950 | PIS(CS); |
| 1951 | PIS(ECC_CORR); |
| 1952 | PIS(PACKET_SENT); |
| 1953 | PIS(FIFO_TX_OVF); |
| 1954 | PIS(FIFO_RX_OVF); |
| 1955 | PIS(BTA); |
| 1956 | PIS(ECC_NO_CORR); |
| 1957 | PIS(FIFO_TX_UDF); |
| 1958 | PIS(PP_BUSY_CHANGE); |
| 1959 | #undef PIS |
| 1960 | |
| 1961 | #define PIS(x) \ |
| 1962 | seq_printf(s, "%-20s %10d\n", #x, \ |
| 1963 | stats.cio_irqs[ffs(DSI_CIO_IRQ_##x)-1]); |
| 1964 | |
| 1965 | seq_printf(s, "-- CIO interrupts --\n"); |
| 1966 | PIS(ERRSYNCESC1); |
| 1967 | PIS(ERRSYNCESC2); |
| 1968 | PIS(ERRSYNCESC3); |
| 1969 | PIS(ERRESC1); |
| 1970 | PIS(ERRESC2); |
| 1971 | PIS(ERRESC3); |
| 1972 | PIS(ERRCONTROL1); |
| 1973 | PIS(ERRCONTROL2); |
| 1974 | PIS(ERRCONTROL3); |
| 1975 | PIS(STATEULPS1); |
| 1976 | PIS(STATEULPS2); |
| 1977 | PIS(STATEULPS3); |
| 1978 | PIS(ERRCONTENTIONLP0_1); |
| 1979 | PIS(ERRCONTENTIONLP1_1); |
| 1980 | PIS(ERRCONTENTIONLP0_2); |
| 1981 | PIS(ERRCONTENTIONLP1_2); |
| 1982 | PIS(ERRCONTENTIONLP0_3); |
| 1983 | PIS(ERRCONTENTIONLP1_3); |
| 1984 | PIS(ULPSACTIVENOT_ALL0); |
| 1985 | PIS(ULPSACTIVENOT_ALL1); |
| 1986 | #undef PIS |
| 1987 | } |
Tomi Valkeinen | dfc0fd8 | 2009-12-17 14:35:21 +0200 | [diff] [blame] | 1988 | |
Archit Taneja | 5a8b572 | 2011-05-12 17:26:29 +0530 | [diff] [blame] | 1989 | static void dsi1_dump_irqs(struct seq_file *s) |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 1990 | { |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 1991 | struct platform_device *dsidev = dsi_get_dsidev_from_id(0); |
| 1992 | |
Archit Taneja | 5a8b572 | 2011-05-12 17:26:29 +0530 | [diff] [blame] | 1993 | dsi_dump_dsidev_irqs(dsidev, s); |
| 1994 | } |
| 1995 | |
| 1996 | static void dsi2_dump_irqs(struct seq_file *s) |
| 1997 | { |
| 1998 | struct platform_device *dsidev = dsi_get_dsidev_from_id(1); |
| 1999 | |
| 2000 | dsi_dump_dsidev_irqs(dsidev, s); |
| 2001 | } |
Archit Taneja | 5a8b572 | 2011-05-12 17:26:29 +0530 | [diff] [blame] | 2002 | #endif |
| 2003 | |
| 2004 | static void dsi_dump_dsidev_regs(struct platform_device *dsidev, |
| 2005 | struct seq_file *s) |
| 2006 | { |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 2007 | #define DUMPREG(r) seq_printf(s, "%-35s %08x\n", #r, dsi_read_reg(dsidev, r)) |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 2008 | |
Tomi Valkeinen | 4fbafaf | 2011-05-27 10:52:19 +0300 | [diff] [blame] | 2009 | if (dsi_runtime_get(dsidev)) |
| 2010 | return; |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 2011 | dsi_enable_scp_clk(dsidev); |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 2012 | |
| 2013 | DUMPREG(DSI_REVISION); |
| 2014 | DUMPREG(DSI_SYSCONFIG); |
| 2015 | DUMPREG(DSI_SYSSTATUS); |
| 2016 | DUMPREG(DSI_IRQSTATUS); |
| 2017 | DUMPREG(DSI_IRQENABLE); |
| 2018 | DUMPREG(DSI_CTRL); |
| 2019 | DUMPREG(DSI_COMPLEXIO_CFG1); |
| 2020 | DUMPREG(DSI_COMPLEXIO_IRQ_STATUS); |
| 2021 | DUMPREG(DSI_COMPLEXIO_IRQ_ENABLE); |
| 2022 | DUMPREG(DSI_CLK_CTRL); |
| 2023 | DUMPREG(DSI_TIMING1); |
| 2024 | DUMPREG(DSI_TIMING2); |
| 2025 | DUMPREG(DSI_VM_TIMING1); |
| 2026 | DUMPREG(DSI_VM_TIMING2); |
| 2027 | DUMPREG(DSI_VM_TIMING3); |
| 2028 | DUMPREG(DSI_CLK_TIMING); |
| 2029 | DUMPREG(DSI_TX_FIFO_VC_SIZE); |
| 2030 | DUMPREG(DSI_RX_FIFO_VC_SIZE); |
| 2031 | DUMPREG(DSI_COMPLEXIO_CFG2); |
| 2032 | DUMPREG(DSI_RX_FIFO_VC_FULLNESS); |
| 2033 | DUMPREG(DSI_VM_TIMING4); |
| 2034 | DUMPREG(DSI_TX_FIFO_VC_EMPTINESS); |
| 2035 | DUMPREG(DSI_VM_TIMING5); |
| 2036 | DUMPREG(DSI_VM_TIMING6); |
| 2037 | DUMPREG(DSI_VM_TIMING7); |
| 2038 | DUMPREG(DSI_STOPCLK_TIMING); |
| 2039 | |
| 2040 | DUMPREG(DSI_VC_CTRL(0)); |
| 2041 | DUMPREG(DSI_VC_TE(0)); |
| 2042 | DUMPREG(DSI_VC_LONG_PACKET_HEADER(0)); |
| 2043 | DUMPREG(DSI_VC_LONG_PACKET_PAYLOAD(0)); |
| 2044 | DUMPREG(DSI_VC_SHORT_PACKET_HEADER(0)); |
| 2045 | DUMPREG(DSI_VC_IRQSTATUS(0)); |
| 2046 | DUMPREG(DSI_VC_IRQENABLE(0)); |
| 2047 | |
| 2048 | DUMPREG(DSI_VC_CTRL(1)); |
| 2049 | DUMPREG(DSI_VC_TE(1)); |
| 2050 | DUMPREG(DSI_VC_LONG_PACKET_HEADER(1)); |
| 2051 | DUMPREG(DSI_VC_LONG_PACKET_PAYLOAD(1)); |
| 2052 | DUMPREG(DSI_VC_SHORT_PACKET_HEADER(1)); |
| 2053 | DUMPREG(DSI_VC_IRQSTATUS(1)); |
| 2054 | DUMPREG(DSI_VC_IRQENABLE(1)); |
| 2055 | |
| 2056 | DUMPREG(DSI_VC_CTRL(2)); |
| 2057 | DUMPREG(DSI_VC_TE(2)); |
| 2058 | DUMPREG(DSI_VC_LONG_PACKET_HEADER(2)); |
| 2059 | DUMPREG(DSI_VC_LONG_PACKET_PAYLOAD(2)); |
| 2060 | DUMPREG(DSI_VC_SHORT_PACKET_HEADER(2)); |
| 2061 | DUMPREG(DSI_VC_IRQSTATUS(2)); |
| 2062 | DUMPREG(DSI_VC_IRQENABLE(2)); |
| 2063 | |
| 2064 | DUMPREG(DSI_VC_CTRL(3)); |
| 2065 | DUMPREG(DSI_VC_TE(3)); |
| 2066 | DUMPREG(DSI_VC_LONG_PACKET_HEADER(3)); |
| 2067 | DUMPREG(DSI_VC_LONG_PACKET_PAYLOAD(3)); |
| 2068 | DUMPREG(DSI_VC_SHORT_PACKET_HEADER(3)); |
| 2069 | DUMPREG(DSI_VC_IRQSTATUS(3)); |
| 2070 | DUMPREG(DSI_VC_IRQENABLE(3)); |
| 2071 | |
| 2072 | DUMPREG(DSI_DSIPHY_CFG0); |
| 2073 | DUMPREG(DSI_DSIPHY_CFG1); |
| 2074 | DUMPREG(DSI_DSIPHY_CFG2); |
| 2075 | DUMPREG(DSI_DSIPHY_CFG5); |
| 2076 | |
| 2077 | DUMPREG(DSI_PLL_CONTROL); |
| 2078 | DUMPREG(DSI_PLL_STATUS); |
| 2079 | DUMPREG(DSI_PLL_GO); |
| 2080 | DUMPREG(DSI_PLL_CONFIGURATION1); |
| 2081 | DUMPREG(DSI_PLL_CONFIGURATION2); |
| 2082 | |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 2083 | dsi_disable_scp_clk(dsidev); |
Tomi Valkeinen | 4fbafaf | 2011-05-27 10:52:19 +0300 | [diff] [blame] | 2084 | dsi_runtime_put(dsidev); |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 2085 | #undef DUMPREG |
| 2086 | } |
| 2087 | |
Archit Taneja | 5a8b572 | 2011-05-12 17:26:29 +0530 | [diff] [blame] | 2088 | static void dsi1_dump_regs(struct seq_file *s) |
| 2089 | { |
| 2090 | struct platform_device *dsidev = dsi_get_dsidev_from_id(0); |
| 2091 | |
| 2092 | dsi_dump_dsidev_regs(dsidev, s); |
| 2093 | } |
| 2094 | |
| 2095 | static void dsi2_dump_regs(struct seq_file *s) |
| 2096 | { |
| 2097 | struct platform_device *dsidev = dsi_get_dsidev_from_id(1); |
| 2098 | |
| 2099 | dsi_dump_dsidev_regs(dsidev, s); |
| 2100 | } |
| 2101 | |
Tomi Valkeinen | cc5c185 | 2010-10-06 15:18:13 +0300 | [diff] [blame] | 2102 | enum dsi_cio_power_state { |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 2103 | DSI_COMPLEXIO_POWER_OFF = 0x0, |
| 2104 | DSI_COMPLEXIO_POWER_ON = 0x1, |
| 2105 | DSI_COMPLEXIO_POWER_ULPS = 0x2, |
| 2106 | }; |
| 2107 | |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 2108 | static int dsi_cio_power(struct platform_device *dsidev, |
| 2109 | enum dsi_cio_power_state state) |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 2110 | { |
| 2111 | int t = 0; |
| 2112 | |
| 2113 | /* PWR_CMD */ |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 2114 | REG_FLD_MOD(dsidev, DSI_COMPLEXIO_CFG1, state, 28, 27); |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 2115 | |
| 2116 | /* PWR_STATUS */ |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 2117 | while (FLD_GET(dsi_read_reg(dsidev, DSI_COMPLEXIO_CFG1), |
| 2118 | 26, 25) != state) { |
Tomi Valkeinen | 24be78b | 2010-01-07 14:19:48 +0200 | [diff] [blame] | 2119 | if (++t > 1000) { |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 2120 | DSSERR("failed to set complexio power state to " |
| 2121 | "%d\n", state); |
| 2122 | return -ENODEV; |
| 2123 | } |
Tomi Valkeinen | 24be78b | 2010-01-07 14:19:48 +0200 | [diff] [blame] | 2124 | udelay(1); |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 2125 | } |
| 2126 | |
| 2127 | return 0; |
| 2128 | } |
| 2129 | |
Archit Taneja | 0c65622 | 2011-05-16 15:17:09 +0530 | [diff] [blame] | 2130 | static unsigned dsi_get_line_buf_size(struct platform_device *dsidev) |
| 2131 | { |
| 2132 | int val; |
| 2133 | |
| 2134 | /* line buffer on OMAP3 is 1024 x 24bits */ |
| 2135 | /* XXX: for some reason using full buffer size causes |
| 2136 | * considerable TX slowdown with update sizes that fill the |
| 2137 | * whole buffer */ |
| 2138 | if (!dss_has_feature(FEAT_DSI_GNQ)) |
| 2139 | return 1023 * 3; |
| 2140 | |
| 2141 | val = REG_GET(dsidev, DSI_GNQ, 14, 12); /* VP1_LINE_BUFFER_SIZE */ |
| 2142 | |
| 2143 | switch (val) { |
| 2144 | case 1: |
| 2145 | return 512 * 3; /* 512x24 bits */ |
| 2146 | case 2: |
| 2147 | return 682 * 3; /* 682x24 bits */ |
| 2148 | case 3: |
| 2149 | return 853 * 3; /* 853x24 bits */ |
| 2150 | case 4: |
| 2151 | return 1024 * 3; /* 1024x24 bits */ |
| 2152 | case 5: |
| 2153 | return 1194 * 3; /* 1194x24 bits */ |
| 2154 | case 6: |
| 2155 | return 1365 * 3; /* 1365x24 bits */ |
| 2156 | default: |
| 2157 | BUG(); |
Tomi Valkeinen | c6eee96 | 2012-05-18 11:47:02 +0300 | [diff] [blame] | 2158 | return 0; |
Archit Taneja | 0c65622 | 2011-05-16 15:17:09 +0530 | [diff] [blame] | 2159 | } |
| 2160 | } |
| 2161 | |
Tomi Valkeinen | 4836839 | 2011-10-13 11:22:39 +0300 | [diff] [blame] | 2162 | static int dsi_set_lane_config(struct omap_dss_device *dssdev) |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 2163 | { |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 2164 | struct platform_device *dsidev = dsi_get_dsidev_from_dssdev(dssdev); |
Tomi Valkeinen | 4836839 | 2011-10-13 11:22:39 +0300 | [diff] [blame] | 2165 | struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev); |
| 2166 | static const u8 offsets[] = { 0, 4, 8, 12, 16 }; |
| 2167 | static const enum dsi_lane_function functions[] = { |
| 2168 | DSI_LANE_CLK, |
| 2169 | DSI_LANE_DATA1, |
| 2170 | DSI_LANE_DATA2, |
| 2171 | DSI_LANE_DATA3, |
| 2172 | DSI_LANE_DATA4, |
| 2173 | }; |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 2174 | u32 r; |
Tomi Valkeinen | 4836839 | 2011-10-13 11:22:39 +0300 | [diff] [blame] | 2175 | int i; |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 2176 | |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 2177 | r = dsi_read_reg(dsidev, DSI_COMPLEXIO_CFG1); |
Archit Taneja | 75d7247 | 2011-05-16 15:17:08 +0530 | [diff] [blame] | 2178 | |
Tomi Valkeinen | 4836839 | 2011-10-13 11:22:39 +0300 | [diff] [blame] | 2179 | for (i = 0; i < dsi->num_lanes_used; ++i) { |
| 2180 | unsigned offset = offsets[i]; |
| 2181 | unsigned polarity, lane_number; |
| 2182 | unsigned t; |
Archit Taneja | 75d7247 | 2011-05-16 15:17:08 +0530 | [diff] [blame] | 2183 | |
Tomi Valkeinen | 4836839 | 2011-10-13 11:22:39 +0300 | [diff] [blame] | 2184 | for (t = 0; t < dsi->num_lanes_supported; ++t) |
| 2185 | if (dsi->lanes[t].function == functions[i]) |
| 2186 | break; |
| 2187 | |
| 2188 | if (t == dsi->num_lanes_supported) |
| 2189 | return -EINVAL; |
| 2190 | |
| 2191 | lane_number = t; |
| 2192 | polarity = dsi->lanes[t].polarity; |
| 2193 | |
| 2194 | r = FLD_MOD(r, lane_number + 1, offset + 2, offset); |
| 2195 | r = FLD_MOD(r, polarity, offset + 3, offset + 3); |
Archit Taneja | 75d7247 | 2011-05-16 15:17:08 +0530 | [diff] [blame] | 2196 | } |
Tomi Valkeinen | 4836839 | 2011-10-13 11:22:39 +0300 | [diff] [blame] | 2197 | |
| 2198 | /* clear the unused lanes */ |
| 2199 | for (; i < dsi->num_lanes_supported; ++i) { |
| 2200 | unsigned offset = offsets[i]; |
| 2201 | |
| 2202 | r = FLD_MOD(r, 0, offset + 2, offset); |
| 2203 | r = FLD_MOD(r, 0, offset + 3, offset + 3); |
| 2204 | } |
| 2205 | |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 2206 | dsi_write_reg(dsidev, DSI_COMPLEXIO_CFG1, r); |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 2207 | |
Tomi Valkeinen | 4836839 | 2011-10-13 11:22:39 +0300 | [diff] [blame] | 2208 | return 0; |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 2209 | } |
| 2210 | |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 2211 | static inline unsigned ns2ddr(struct platform_device *dsidev, unsigned ns) |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 2212 | { |
Archit Taneja | f1da39d | 2011-05-12 17:26:27 +0530 | [diff] [blame] | 2213 | struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev); |
| 2214 | |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 2215 | /* convert time in ns to ddr ticks, rounding up */ |
Archit Taneja | f1da39d | 2011-05-12 17:26:27 +0530 | [diff] [blame] | 2216 | unsigned long ddr_clk = dsi->current_cinfo.clkin4ddr / 4; |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 2217 | return (ns * (ddr_clk / 1000 / 1000) + 999) / 1000; |
| 2218 | } |
| 2219 | |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 2220 | static inline unsigned ddr2ns(struct platform_device *dsidev, unsigned ddr) |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 2221 | { |
Archit Taneja | f1da39d | 2011-05-12 17:26:27 +0530 | [diff] [blame] | 2222 | struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev); |
| 2223 | |
| 2224 | unsigned long ddr_clk = dsi->current_cinfo.clkin4ddr / 4; |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 2225 | return ddr * 1000 * 1000 / (ddr_clk / 1000); |
| 2226 | } |
| 2227 | |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 2228 | static void dsi_cio_timings(struct platform_device *dsidev) |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 2229 | { |
| 2230 | u32 r; |
| 2231 | u32 ths_prepare, ths_prepare_ths_zero, ths_trail, ths_exit; |
| 2232 | u32 tlpx_half, tclk_trail, tclk_zero; |
| 2233 | u32 tclk_prepare; |
| 2234 | |
| 2235 | /* calculate timings */ |
| 2236 | |
| 2237 | /* 1 * DDR_CLK = 2 * UI */ |
| 2238 | |
| 2239 | /* min 40ns + 4*UI max 85ns + 6*UI */ |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 2240 | ths_prepare = ns2ddr(dsidev, 70) + 2; |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 2241 | |
| 2242 | /* min 145ns + 10*UI */ |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 2243 | ths_prepare_ths_zero = ns2ddr(dsidev, 175) + 2; |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 2244 | |
| 2245 | /* min max(8*UI, 60ns+4*UI) */ |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 2246 | ths_trail = ns2ddr(dsidev, 60) + 5; |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 2247 | |
| 2248 | /* min 100ns */ |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 2249 | ths_exit = ns2ddr(dsidev, 145); |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 2250 | |
| 2251 | /* tlpx min 50n */ |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 2252 | tlpx_half = ns2ddr(dsidev, 25); |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 2253 | |
| 2254 | /* min 60ns */ |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 2255 | tclk_trail = ns2ddr(dsidev, 60) + 2; |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 2256 | |
| 2257 | /* min 38ns, max 95ns */ |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 2258 | tclk_prepare = ns2ddr(dsidev, 65); |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 2259 | |
| 2260 | /* min tclk-prepare + tclk-zero = 300ns */ |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 2261 | tclk_zero = ns2ddr(dsidev, 260); |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 2262 | |
| 2263 | DSSDBG("ths_prepare %u (%uns), ths_prepare_ths_zero %u (%uns)\n", |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 2264 | ths_prepare, ddr2ns(dsidev, ths_prepare), |
| 2265 | ths_prepare_ths_zero, ddr2ns(dsidev, ths_prepare_ths_zero)); |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 2266 | DSSDBG("ths_trail %u (%uns), ths_exit %u (%uns)\n", |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 2267 | ths_trail, ddr2ns(dsidev, ths_trail), |
| 2268 | ths_exit, ddr2ns(dsidev, ths_exit)); |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 2269 | |
| 2270 | DSSDBG("tlpx_half %u (%uns), tclk_trail %u (%uns), " |
| 2271 | "tclk_zero %u (%uns)\n", |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 2272 | tlpx_half, ddr2ns(dsidev, tlpx_half), |
| 2273 | tclk_trail, ddr2ns(dsidev, tclk_trail), |
| 2274 | tclk_zero, ddr2ns(dsidev, tclk_zero)); |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 2275 | DSSDBG("tclk_prepare %u (%uns)\n", |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 2276 | tclk_prepare, ddr2ns(dsidev, tclk_prepare)); |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 2277 | |
| 2278 | /* program timings */ |
| 2279 | |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 2280 | r = dsi_read_reg(dsidev, DSI_DSIPHY_CFG0); |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 2281 | r = FLD_MOD(r, ths_prepare, 31, 24); |
| 2282 | r = FLD_MOD(r, ths_prepare_ths_zero, 23, 16); |
| 2283 | r = FLD_MOD(r, ths_trail, 15, 8); |
| 2284 | r = FLD_MOD(r, ths_exit, 7, 0); |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 2285 | dsi_write_reg(dsidev, DSI_DSIPHY_CFG0, r); |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 2286 | |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 2287 | r = dsi_read_reg(dsidev, DSI_DSIPHY_CFG1); |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 2288 | r = FLD_MOD(r, tlpx_half, 22, 16); |
| 2289 | r = FLD_MOD(r, tclk_trail, 15, 8); |
| 2290 | r = FLD_MOD(r, tclk_zero, 7, 0); |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 2291 | dsi_write_reg(dsidev, DSI_DSIPHY_CFG1, r); |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 2292 | |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 2293 | r = dsi_read_reg(dsidev, DSI_DSIPHY_CFG2); |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 2294 | r = FLD_MOD(r, tclk_prepare, 7, 0); |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 2295 | dsi_write_reg(dsidev, DSI_DSIPHY_CFG2, r); |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 2296 | } |
| 2297 | |
Tomi Valkeinen | 9b4362f | 2011-10-13 16:06:43 +0300 | [diff] [blame] | 2298 | /* lane masks have lane 0 at lsb. mask_p for positive lines, n for negative */ |
Tomi Valkeinen | cc5c185 | 2010-10-06 15:18:13 +0300 | [diff] [blame] | 2299 | static void dsi_cio_enable_lane_override(struct omap_dss_device *dssdev, |
Tomi Valkeinen | 9b4362f | 2011-10-13 16:06:43 +0300 | [diff] [blame] | 2300 | unsigned mask_p, unsigned mask_n) |
Tomi Valkeinen | 0a0ee46 | 2010-07-27 11:11:48 +0300 | [diff] [blame] | 2301 | { |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 2302 | struct platform_device *dsidev = dsi_get_dsidev_from_dssdev(dssdev); |
Archit Taneja | 75d7247 | 2011-05-16 15:17:08 +0530 | [diff] [blame] | 2303 | struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev); |
Tomi Valkeinen | 9b4362f | 2011-10-13 16:06:43 +0300 | [diff] [blame] | 2304 | int i; |
| 2305 | u32 l; |
Tomi Valkeinen | d982085 | 2011-10-12 15:05:59 +0300 | [diff] [blame] | 2306 | u8 lptxscp_start = dsi->num_lanes_supported == 3 ? 22 : 26; |
Tomi Valkeinen | 0a0ee46 | 2010-07-27 11:11:48 +0300 | [diff] [blame] | 2307 | |
Tomi Valkeinen | 9b4362f | 2011-10-13 16:06:43 +0300 | [diff] [blame] | 2308 | l = 0; |
Tomi Valkeinen | 0a0ee46 | 2010-07-27 11:11:48 +0300 | [diff] [blame] | 2309 | |
Tomi Valkeinen | 9b4362f | 2011-10-13 16:06:43 +0300 | [diff] [blame] | 2310 | for (i = 0; i < dsi->num_lanes_supported; ++i) { |
| 2311 | unsigned p = dsi->lanes[i].polarity; |
Tomi Valkeinen | 0a0ee46 | 2010-07-27 11:11:48 +0300 | [diff] [blame] | 2312 | |
Tomi Valkeinen | 9b4362f | 2011-10-13 16:06:43 +0300 | [diff] [blame] | 2313 | if (mask_p & (1 << i)) |
| 2314 | l |= 1 << (i * 2 + (p ? 0 : 1)); |
Tomi Valkeinen | 0a0ee46 | 2010-07-27 11:11:48 +0300 | [diff] [blame] | 2315 | |
Tomi Valkeinen | 9b4362f | 2011-10-13 16:06:43 +0300 | [diff] [blame] | 2316 | if (mask_n & (1 << i)) |
| 2317 | l |= 1 << (i * 2 + (p ? 1 : 0)); |
| 2318 | } |
Tomi Valkeinen | 0a0ee46 | 2010-07-27 11:11:48 +0300 | [diff] [blame] | 2319 | |
| 2320 | /* |
| 2321 | * Bits in REGLPTXSCPDAT4TO0DXDY: |
| 2322 | * 17: DY0 18: DX0 |
| 2323 | * 19: DY1 20: DX1 |
| 2324 | * 21: DY2 22: DX2 |
Archit Taneja | 75d7247 | 2011-05-16 15:17:08 +0530 | [diff] [blame] | 2325 | * 23: DY3 24: DX3 |
| 2326 | * 25: DY4 26: DX4 |
Tomi Valkeinen | 0a0ee46 | 2010-07-27 11:11:48 +0300 | [diff] [blame] | 2327 | */ |
| 2328 | |
| 2329 | /* Set the lane override configuration */ |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 2330 | |
| 2331 | /* REGLPTXSCPDAT4TO0DXDY */ |
Archit Taneja | 75d7247 | 2011-05-16 15:17:08 +0530 | [diff] [blame] | 2332 | REG_FLD_MOD(dsidev, DSI_DSIPHY_CFG10, l, lptxscp_start, 17); |
Tomi Valkeinen | 0a0ee46 | 2010-07-27 11:11:48 +0300 | [diff] [blame] | 2333 | |
| 2334 | /* Enable lane override */ |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 2335 | |
| 2336 | /* ENLPTXSCPDAT */ |
| 2337 | REG_FLD_MOD(dsidev, DSI_DSIPHY_CFG10, 1, 27, 27); |
Tomi Valkeinen | 0a0ee46 | 2010-07-27 11:11:48 +0300 | [diff] [blame] | 2338 | } |
| 2339 | |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 2340 | static void dsi_cio_disable_lane_override(struct platform_device *dsidev) |
Tomi Valkeinen | 0a0ee46 | 2010-07-27 11:11:48 +0300 | [diff] [blame] | 2341 | { |
| 2342 | /* Disable lane override */ |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 2343 | REG_FLD_MOD(dsidev, DSI_DSIPHY_CFG10, 0, 27, 27); /* ENLPTXSCPDAT */ |
Tomi Valkeinen | 0a0ee46 | 2010-07-27 11:11:48 +0300 | [diff] [blame] | 2344 | /* Reset the lane override configuration */ |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 2345 | /* REGLPTXSCPDAT4TO0DXDY */ |
| 2346 | REG_FLD_MOD(dsidev, DSI_DSIPHY_CFG10, 0, 22, 17); |
Tomi Valkeinen | 0a0ee46 | 2010-07-27 11:11:48 +0300 | [diff] [blame] | 2347 | } |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 2348 | |
Tomi Valkeinen | 03329ac | 2010-10-07 13:59:22 +0300 | [diff] [blame] | 2349 | static int dsi_cio_wait_tx_clk_esc_reset(struct omap_dss_device *dssdev) |
| 2350 | { |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 2351 | struct platform_device *dsidev = dsi_get_dsidev_from_dssdev(dssdev); |
Tomi Valkeinen | 8dc0766 | 2011-10-13 15:26:50 +0300 | [diff] [blame] | 2352 | struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev); |
| 2353 | int t, i; |
| 2354 | bool in_use[DSI_MAX_NR_LANES]; |
| 2355 | static const u8 offsets_old[] = { 28, 27, 26 }; |
| 2356 | static const u8 offsets_new[] = { 24, 25, 26, 27, 28 }; |
| 2357 | const u8 *offsets; |
Tomi Valkeinen | 03329ac | 2010-10-07 13:59:22 +0300 | [diff] [blame] | 2358 | |
Tomi Valkeinen | 8dc0766 | 2011-10-13 15:26:50 +0300 | [diff] [blame] | 2359 | if (dss_has_feature(FEAT_DSI_REVERSE_TXCLKESC)) |
| 2360 | offsets = offsets_old; |
| 2361 | else |
| 2362 | offsets = offsets_new; |
Tomi Valkeinen | 03329ac | 2010-10-07 13:59:22 +0300 | [diff] [blame] | 2363 | |
Tomi Valkeinen | 8dc0766 | 2011-10-13 15:26:50 +0300 | [diff] [blame] | 2364 | for (i = 0; i < dsi->num_lanes_supported; ++i) |
| 2365 | in_use[i] = dsi->lanes[i].function != DSI_LANE_UNUSED; |
Tomi Valkeinen | 03329ac | 2010-10-07 13:59:22 +0300 | [diff] [blame] | 2366 | |
| 2367 | t = 100000; |
| 2368 | while (true) { |
| 2369 | u32 l; |
Tomi Valkeinen | 03329ac | 2010-10-07 13:59:22 +0300 | [diff] [blame] | 2370 | int ok; |
| 2371 | |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 2372 | l = dsi_read_reg(dsidev, DSI_DSIPHY_CFG5); |
Tomi Valkeinen | 03329ac | 2010-10-07 13:59:22 +0300 | [diff] [blame] | 2373 | |
| 2374 | ok = 0; |
Tomi Valkeinen | 8dc0766 | 2011-10-13 15:26:50 +0300 | [diff] [blame] | 2375 | for (i = 0; i < dsi->num_lanes_supported; ++i) { |
| 2376 | if (!in_use[i] || (l & (1 << offsets[i]))) |
Tomi Valkeinen | 03329ac | 2010-10-07 13:59:22 +0300 | [diff] [blame] | 2377 | ok++; |
| 2378 | } |
| 2379 | |
Tomi Valkeinen | 8dc0766 | 2011-10-13 15:26:50 +0300 | [diff] [blame] | 2380 | if (ok == dsi->num_lanes_supported) |
Tomi Valkeinen | 03329ac | 2010-10-07 13:59:22 +0300 | [diff] [blame] | 2381 | break; |
| 2382 | |
| 2383 | if (--t == 0) { |
Tomi Valkeinen | 8dc0766 | 2011-10-13 15:26:50 +0300 | [diff] [blame] | 2384 | for (i = 0; i < dsi->num_lanes_supported; ++i) { |
| 2385 | if (!in_use[i] || (l & (1 << offsets[i]))) |
Tomi Valkeinen | 03329ac | 2010-10-07 13:59:22 +0300 | [diff] [blame] | 2386 | continue; |
| 2387 | |
| 2388 | DSSERR("CIO TXCLKESC%d domain not coming " \ |
| 2389 | "out of reset\n", i); |
| 2390 | } |
| 2391 | return -EIO; |
| 2392 | } |
| 2393 | } |
| 2394 | |
| 2395 | return 0; |
| 2396 | } |
| 2397 | |
Tomi Valkeinen | 85f17e8 | 2011-10-13 15:12:23 +0300 | [diff] [blame] | 2398 | /* return bitmask of enabled lanes, lane0 being the lsb */ |
Tomi Valkeinen | 5bc416c | 2011-06-15 15:21:12 +0300 | [diff] [blame] | 2399 | static unsigned dsi_get_lane_mask(struct omap_dss_device *dssdev) |
| 2400 | { |
Tomi Valkeinen | 85f17e8 | 2011-10-13 15:12:23 +0300 | [diff] [blame] | 2401 | struct platform_device *dsidev = dsi_get_dsidev_from_dssdev(dssdev); |
| 2402 | struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev); |
| 2403 | unsigned mask = 0; |
| 2404 | int i; |
Tomi Valkeinen | 5bc416c | 2011-06-15 15:21:12 +0300 | [diff] [blame] | 2405 | |
Tomi Valkeinen | 85f17e8 | 2011-10-13 15:12:23 +0300 | [diff] [blame] | 2406 | for (i = 0; i < dsi->num_lanes_supported; ++i) { |
| 2407 | if (dsi->lanes[i].function != DSI_LANE_UNUSED) |
| 2408 | mask |= 1 << i; |
| 2409 | } |
Tomi Valkeinen | 5bc416c | 2011-06-15 15:21:12 +0300 | [diff] [blame] | 2410 | |
Tomi Valkeinen | 85f17e8 | 2011-10-13 15:12:23 +0300 | [diff] [blame] | 2411 | return mask; |
Tomi Valkeinen | 5bc416c | 2011-06-15 15:21:12 +0300 | [diff] [blame] | 2412 | } |
| 2413 | |
Tomi Valkeinen | cc5c185 | 2010-10-06 15:18:13 +0300 | [diff] [blame] | 2414 | static int dsi_cio_init(struct omap_dss_device *dssdev) |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 2415 | { |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 2416 | struct platform_device *dsidev = dsi_get_dsidev_from_dssdev(dssdev); |
Archit Taneja | f1da39d | 2011-05-12 17:26:27 +0530 | [diff] [blame] | 2417 | struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev); |
Tomi Valkeinen | 65c62bb | 2011-04-15 11:58:41 +0300 | [diff] [blame] | 2418 | int r; |
Tomi Valkeinen | 40885ab | 2010-07-28 15:53:38 +0300 | [diff] [blame] | 2419 | u32 l; |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 2420 | |
Tomi Valkeinen | cc5c185 | 2010-10-06 15:18:13 +0300 | [diff] [blame] | 2421 | DSSDBGF(); |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 2422 | |
Tomi Valkeinen | 11ee960 | 2012-03-09 16:07:39 +0200 | [diff] [blame] | 2423 | r = dss_dsi_enable_pads(dsi->module_id, dsi_get_lane_mask(dssdev)); |
Tomi Valkeinen | 5bc416c | 2011-06-15 15:21:12 +0300 | [diff] [blame] | 2424 | if (r) |
| 2425 | return r; |
Tomi Valkeinen | d1f5857 | 2010-07-30 11:57:57 +0300 | [diff] [blame] | 2426 | |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 2427 | dsi_enable_scp_clk(dsidev); |
Tomi Valkeinen | 40885ab | 2010-07-28 15:53:38 +0300 | [diff] [blame] | 2428 | |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 2429 | /* A dummy read using the SCP interface to any DSIPHY register is |
| 2430 | * required after DSIPHY reset to complete the reset of the DSI complex |
| 2431 | * I/O. */ |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 2432 | dsi_read_reg(dsidev, DSI_DSIPHY_CFG5); |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 2433 | |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 2434 | if (wait_for_bit_change(dsidev, DSI_DSIPHY_CFG5, 30, 1) != 1) { |
Tomi Valkeinen | 65c62bb | 2011-04-15 11:58:41 +0300 | [diff] [blame] | 2435 | DSSERR("CIO SCP Clock domain not coming out of reset.\n"); |
| 2436 | r = -EIO; |
| 2437 | goto err_scp_clk_dom; |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 2438 | } |
| 2439 | |
Tomi Valkeinen | 4836839 | 2011-10-13 11:22:39 +0300 | [diff] [blame] | 2440 | r = dsi_set_lane_config(dssdev); |
| 2441 | if (r) |
| 2442 | goto err_scp_clk_dom; |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 2443 | |
Tomi Valkeinen | 40885ab | 2010-07-28 15:53:38 +0300 | [diff] [blame] | 2444 | /* set TX STOP MODE timer to maximum for this operation */ |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 2445 | l = dsi_read_reg(dsidev, DSI_TIMING1); |
Tomi Valkeinen | 40885ab | 2010-07-28 15:53:38 +0300 | [diff] [blame] | 2446 | l = FLD_MOD(l, 1, 15, 15); /* FORCE_TX_STOP_MODE_IO */ |
| 2447 | l = FLD_MOD(l, 1, 14, 14); /* STOP_STATE_X16_IO */ |
| 2448 | l = FLD_MOD(l, 1, 13, 13); /* STOP_STATE_X4_IO */ |
| 2449 | l = FLD_MOD(l, 0x1fff, 12, 0); /* STOP_STATE_COUNTER_IO */ |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 2450 | dsi_write_reg(dsidev, DSI_TIMING1, l); |
Tomi Valkeinen | 40885ab | 2010-07-28 15:53:38 +0300 | [diff] [blame] | 2451 | |
Archit Taneja | f1da39d | 2011-05-12 17:26:27 +0530 | [diff] [blame] | 2452 | if (dsi->ulps_enabled) { |
Tomi Valkeinen | 9b4362f | 2011-10-13 16:06:43 +0300 | [diff] [blame] | 2453 | unsigned mask_p; |
| 2454 | int i; |
Archit Taneja | 75d7247 | 2011-05-16 15:17:08 +0530 | [diff] [blame] | 2455 | |
Tomi Valkeinen | 65c62bb | 2011-04-15 11:58:41 +0300 | [diff] [blame] | 2456 | DSSDBG("manual ulps exit\n"); |
| 2457 | |
Tomi Valkeinen | 40885ab | 2010-07-28 15:53:38 +0300 | [diff] [blame] | 2458 | /* ULPS is exited by Mark-1 state for 1ms, followed by |
| 2459 | * stop state. DSS HW cannot do this via the normal |
| 2460 | * ULPS exit sequence, as after reset the DSS HW thinks |
| 2461 | * that we are not in ULPS mode, and refuses to send the |
| 2462 | * sequence. So we need to send the ULPS exit sequence |
Tomi Valkeinen | 9b4362f | 2011-10-13 16:06:43 +0300 | [diff] [blame] | 2463 | * manually by setting positive lines high and negative lines |
| 2464 | * low for 1ms. |
Tomi Valkeinen | 40885ab | 2010-07-28 15:53:38 +0300 | [diff] [blame] | 2465 | */ |
| 2466 | |
Tomi Valkeinen | 9b4362f | 2011-10-13 16:06:43 +0300 | [diff] [blame] | 2467 | mask_p = 0; |
Archit Taneja | 75d7247 | 2011-05-16 15:17:08 +0530 | [diff] [blame] | 2468 | |
Tomi Valkeinen | 9b4362f | 2011-10-13 16:06:43 +0300 | [diff] [blame] | 2469 | for (i = 0; i < dsi->num_lanes_supported; ++i) { |
| 2470 | if (dsi->lanes[i].function == DSI_LANE_UNUSED) |
| 2471 | continue; |
| 2472 | mask_p |= 1 << i; |
| 2473 | } |
Archit Taneja | 75d7247 | 2011-05-16 15:17:08 +0530 | [diff] [blame] | 2474 | |
Tomi Valkeinen | 9b4362f | 2011-10-13 16:06:43 +0300 | [diff] [blame] | 2475 | dsi_cio_enable_lane_override(dssdev, mask_p, 0); |
Tomi Valkeinen | 40885ab | 2010-07-28 15:53:38 +0300 | [diff] [blame] | 2476 | } |
| 2477 | |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 2478 | r = dsi_cio_power(dsidev, DSI_COMPLEXIO_POWER_ON); |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 2479 | if (r) |
Tomi Valkeinen | 65c62bb | 2011-04-15 11:58:41 +0300 | [diff] [blame] | 2480 | goto err_cio_pwr; |
| 2481 | |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 2482 | if (wait_for_bit_change(dsidev, DSI_COMPLEXIO_CFG1, 29, 1) != 1) { |
Tomi Valkeinen | 65c62bb | 2011-04-15 11:58:41 +0300 | [diff] [blame] | 2483 | DSSERR("CIO PWR clock domain not coming out of reset.\n"); |
| 2484 | r = -ENODEV; |
| 2485 | goto err_cio_pwr_dom; |
| 2486 | } |
| 2487 | |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 2488 | dsi_if_enable(dsidev, true); |
| 2489 | dsi_if_enable(dsidev, false); |
| 2490 | REG_FLD_MOD(dsidev, DSI_CLK_CTRL, 1, 20, 20); /* LP_CLK_ENABLE */ |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 2491 | |
Tomi Valkeinen | 03329ac | 2010-10-07 13:59:22 +0300 | [diff] [blame] | 2492 | r = dsi_cio_wait_tx_clk_esc_reset(dssdev); |
| 2493 | if (r) |
| 2494 | goto err_tx_clk_esc_rst; |
| 2495 | |
Archit Taneja | f1da39d | 2011-05-12 17:26:27 +0530 | [diff] [blame] | 2496 | if (dsi->ulps_enabled) { |
Tomi Valkeinen | 40885ab | 2010-07-28 15:53:38 +0300 | [diff] [blame] | 2497 | /* Keep Mark-1 state for 1ms (as per DSI spec) */ |
| 2498 | ktime_t wait = ns_to_ktime(1000 * 1000); |
| 2499 | set_current_state(TASK_UNINTERRUPTIBLE); |
| 2500 | schedule_hrtimeout(&wait, HRTIMER_MODE_REL); |
| 2501 | |
| 2502 | /* Disable the override. The lanes should be set to Mark-11 |
| 2503 | * state by the HW */ |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 2504 | dsi_cio_disable_lane_override(dsidev); |
Tomi Valkeinen | 40885ab | 2010-07-28 15:53:38 +0300 | [diff] [blame] | 2505 | } |
| 2506 | |
| 2507 | /* FORCE_TX_STOP_MODE_IO */ |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 2508 | REG_FLD_MOD(dsidev, DSI_TIMING1, 0, 15, 15); |
Tomi Valkeinen | 40885ab | 2010-07-28 15:53:38 +0300 | [diff] [blame] | 2509 | |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 2510 | dsi_cio_timings(dsidev); |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 2511 | |
Archit Taneja | dca2b15 | 2012-08-16 18:02:00 +0530 | [diff] [blame] | 2512 | if (dsi->mode == OMAP_DSS_DSI_VIDEO_MODE) { |
Archit Taneja | 8af6ff0 | 2011-09-05 16:48:27 +0530 | [diff] [blame] | 2513 | /* DDR_CLK_ALWAYS_ON */ |
| 2514 | REG_FLD_MOD(dsidev, DSI_CLK_CTRL, |
Archit Taneja | 0b3ffe3 | 2012-08-13 22:13:39 +0530 | [diff] [blame] | 2515 | dsi->vm_timings.ddr_clk_always_on, 13, 13); |
Archit Taneja | 8af6ff0 | 2011-09-05 16:48:27 +0530 | [diff] [blame] | 2516 | } |
| 2517 | |
Archit Taneja | f1da39d | 2011-05-12 17:26:27 +0530 | [diff] [blame] | 2518 | dsi->ulps_enabled = false; |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 2519 | |
| 2520 | DSSDBG("CIO init done\n"); |
Tomi Valkeinen | 65c62bb | 2011-04-15 11:58:41 +0300 | [diff] [blame] | 2521 | |
| 2522 | return 0; |
| 2523 | |
Tomi Valkeinen | 03329ac | 2010-10-07 13:59:22 +0300 | [diff] [blame] | 2524 | err_tx_clk_esc_rst: |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 2525 | REG_FLD_MOD(dsidev, DSI_CLK_CTRL, 0, 20, 20); /* LP_CLK_ENABLE */ |
Tomi Valkeinen | 65c62bb | 2011-04-15 11:58:41 +0300 | [diff] [blame] | 2526 | err_cio_pwr_dom: |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 2527 | dsi_cio_power(dsidev, DSI_COMPLEXIO_POWER_OFF); |
Tomi Valkeinen | 65c62bb | 2011-04-15 11:58:41 +0300 | [diff] [blame] | 2528 | err_cio_pwr: |
Archit Taneja | f1da39d | 2011-05-12 17:26:27 +0530 | [diff] [blame] | 2529 | if (dsi->ulps_enabled) |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 2530 | dsi_cio_disable_lane_override(dsidev); |
Tomi Valkeinen | 65c62bb | 2011-04-15 11:58:41 +0300 | [diff] [blame] | 2531 | err_scp_clk_dom: |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 2532 | dsi_disable_scp_clk(dsidev); |
Tomi Valkeinen | 11ee960 | 2012-03-09 16:07:39 +0200 | [diff] [blame] | 2533 | dss_dsi_disable_pads(dsi->module_id, dsi_get_lane_mask(dssdev)); |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 2534 | return r; |
| 2535 | } |
| 2536 | |
Tomi Valkeinen | 5bc416c | 2011-06-15 15:21:12 +0300 | [diff] [blame] | 2537 | static void dsi_cio_uninit(struct omap_dss_device *dssdev) |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 2538 | { |
Tomi Valkeinen | 5bc416c | 2011-06-15 15:21:12 +0300 | [diff] [blame] | 2539 | struct platform_device *dsidev = dsi_get_dsidev_from_dssdev(dssdev); |
Tomi Valkeinen | 11ee960 | 2012-03-09 16:07:39 +0200 | [diff] [blame] | 2540 | struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev); |
Archit Taneja | f1da39d | 2011-05-12 17:26:27 +0530 | [diff] [blame] | 2541 | |
Archit Taneja | 8af6ff0 | 2011-09-05 16:48:27 +0530 | [diff] [blame] | 2542 | /* DDR_CLK_ALWAYS_ON */ |
| 2543 | REG_FLD_MOD(dsidev, DSI_CLK_CTRL, 0, 13, 13); |
| 2544 | |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 2545 | dsi_cio_power(dsidev, DSI_COMPLEXIO_POWER_OFF); |
| 2546 | dsi_disable_scp_clk(dsidev); |
Tomi Valkeinen | 11ee960 | 2012-03-09 16:07:39 +0200 | [diff] [blame] | 2547 | dss_dsi_disable_pads(dsi->module_id, dsi_get_lane_mask(dssdev)); |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 2548 | } |
| 2549 | |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 2550 | static void dsi_config_tx_fifo(struct platform_device *dsidev, |
| 2551 | enum fifo_size size1, enum fifo_size size2, |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 2552 | enum fifo_size size3, enum fifo_size size4) |
| 2553 | { |
Archit Taneja | f1da39d | 2011-05-12 17:26:27 +0530 | [diff] [blame] | 2554 | struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev); |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 2555 | u32 r = 0; |
| 2556 | int add = 0; |
| 2557 | int i; |
| 2558 | |
Archit Taneja | f1da39d | 2011-05-12 17:26:27 +0530 | [diff] [blame] | 2559 | dsi->vc[0].fifo_size = size1; |
| 2560 | dsi->vc[1].fifo_size = size2; |
| 2561 | dsi->vc[2].fifo_size = size3; |
| 2562 | dsi->vc[3].fifo_size = size4; |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 2563 | |
| 2564 | for (i = 0; i < 4; i++) { |
| 2565 | u8 v; |
Archit Taneja | f1da39d | 2011-05-12 17:26:27 +0530 | [diff] [blame] | 2566 | int size = dsi->vc[i].fifo_size; |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 2567 | |
| 2568 | if (add + size > 4) { |
| 2569 | DSSERR("Illegal FIFO configuration\n"); |
| 2570 | BUG(); |
Tomi Valkeinen | c6eee96 | 2012-05-18 11:47:02 +0300 | [diff] [blame] | 2571 | return; |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 2572 | } |
| 2573 | |
| 2574 | v = FLD_VAL(add, 2, 0) | FLD_VAL(size, 7, 4); |
| 2575 | r |= v << (8 * i); |
| 2576 | /*DSSDBG("TX FIFO vc %d: size %d, add %d\n", i, size, add); */ |
| 2577 | add += size; |
| 2578 | } |
| 2579 | |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 2580 | dsi_write_reg(dsidev, DSI_TX_FIFO_VC_SIZE, r); |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 2581 | } |
| 2582 | |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 2583 | static void dsi_config_rx_fifo(struct platform_device *dsidev, |
| 2584 | enum fifo_size size1, enum fifo_size size2, |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 2585 | enum fifo_size size3, enum fifo_size size4) |
| 2586 | { |
Archit Taneja | f1da39d | 2011-05-12 17:26:27 +0530 | [diff] [blame] | 2587 | struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev); |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 2588 | u32 r = 0; |
| 2589 | int add = 0; |
| 2590 | int i; |
| 2591 | |
Archit Taneja | f1da39d | 2011-05-12 17:26:27 +0530 | [diff] [blame] | 2592 | dsi->vc[0].fifo_size = size1; |
| 2593 | dsi->vc[1].fifo_size = size2; |
| 2594 | dsi->vc[2].fifo_size = size3; |
| 2595 | dsi->vc[3].fifo_size = size4; |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 2596 | |
| 2597 | for (i = 0; i < 4; i++) { |
| 2598 | u8 v; |
Archit Taneja | f1da39d | 2011-05-12 17:26:27 +0530 | [diff] [blame] | 2599 | int size = dsi->vc[i].fifo_size; |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 2600 | |
| 2601 | if (add + size > 4) { |
| 2602 | DSSERR("Illegal FIFO configuration\n"); |
| 2603 | BUG(); |
Tomi Valkeinen | c6eee96 | 2012-05-18 11:47:02 +0300 | [diff] [blame] | 2604 | return; |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 2605 | } |
| 2606 | |
| 2607 | v = FLD_VAL(add, 2, 0) | FLD_VAL(size, 7, 4); |
| 2608 | r |= v << (8 * i); |
| 2609 | /*DSSDBG("RX FIFO vc %d: size %d, add %d\n", i, size, add); */ |
| 2610 | add += size; |
| 2611 | } |
| 2612 | |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 2613 | dsi_write_reg(dsidev, DSI_RX_FIFO_VC_SIZE, r); |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 2614 | } |
| 2615 | |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 2616 | static int dsi_force_tx_stop_mode_io(struct platform_device *dsidev) |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 2617 | { |
| 2618 | u32 r; |
| 2619 | |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 2620 | r = dsi_read_reg(dsidev, DSI_TIMING1); |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 2621 | r = FLD_MOD(r, 1, 15, 15); /* FORCE_TX_STOP_MODE_IO */ |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 2622 | dsi_write_reg(dsidev, DSI_TIMING1, r); |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 2623 | |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 2624 | if (wait_for_bit_change(dsidev, DSI_TIMING1, 15, 0) != 0) { |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 2625 | DSSERR("TX_STOP bit not going down\n"); |
| 2626 | return -EIO; |
| 2627 | } |
| 2628 | |
| 2629 | return 0; |
| 2630 | } |
| 2631 | |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 2632 | static bool dsi_vc_is_enabled(struct platform_device *dsidev, int channel) |
Archit Taneja | cf398fb | 2011-03-23 09:59:34 +0000 | [diff] [blame] | 2633 | { |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 2634 | return REG_GET(dsidev, DSI_VC_CTRL(channel), 0, 0); |
Archit Taneja | cf398fb | 2011-03-23 09:59:34 +0000 | [diff] [blame] | 2635 | } |
| 2636 | |
| 2637 | static void dsi_packet_sent_handler_vp(void *data, u32 mask) |
| 2638 | { |
Archit Taneja | 2e868db | 2011-05-12 17:26:28 +0530 | [diff] [blame] | 2639 | struct dsi_packet_sent_handler_data *vp_data = |
| 2640 | (struct dsi_packet_sent_handler_data *) data; |
| 2641 | struct dsi_data *dsi = dsi_get_dsidrv_data(vp_data->dsidev); |
Archit Taneja | f1da39d | 2011-05-12 17:26:27 +0530 | [diff] [blame] | 2642 | const int channel = dsi->update_channel; |
| 2643 | u8 bit = dsi->te_enabled ? 30 : 31; |
Archit Taneja | cf398fb | 2011-03-23 09:59:34 +0000 | [diff] [blame] | 2644 | |
Archit Taneja | 2e868db | 2011-05-12 17:26:28 +0530 | [diff] [blame] | 2645 | if (REG_GET(vp_data->dsidev, DSI_VC_TE(channel), bit, bit) == 0) |
| 2646 | complete(vp_data->completion); |
Archit Taneja | cf398fb | 2011-03-23 09:59:34 +0000 | [diff] [blame] | 2647 | } |
| 2648 | |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 2649 | static int dsi_sync_vc_vp(struct platform_device *dsidev, int channel) |
Archit Taneja | cf398fb | 2011-03-23 09:59:34 +0000 | [diff] [blame] | 2650 | { |
Archit Taneja | f1da39d | 2011-05-12 17:26:27 +0530 | [diff] [blame] | 2651 | struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev); |
Archit Taneja | 2e868db | 2011-05-12 17:26:28 +0530 | [diff] [blame] | 2652 | DECLARE_COMPLETION_ONSTACK(completion); |
| 2653 | struct dsi_packet_sent_handler_data vp_data = { dsidev, &completion }; |
Archit Taneja | cf398fb | 2011-03-23 09:59:34 +0000 | [diff] [blame] | 2654 | int r = 0; |
| 2655 | u8 bit; |
| 2656 | |
Archit Taneja | f1da39d | 2011-05-12 17:26:27 +0530 | [diff] [blame] | 2657 | bit = dsi->te_enabled ? 30 : 31; |
Archit Taneja | cf398fb | 2011-03-23 09:59:34 +0000 | [diff] [blame] | 2658 | |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 2659 | r = dsi_register_isr_vc(dsidev, channel, dsi_packet_sent_handler_vp, |
Archit Taneja | 2e868db | 2011-05-12 17:26:28 +0530 | [diff] [blame] | 2660 | &vp_data, DSI_VC_IRQ_PACKET_SENT); |
Archit Taneja | cf398fb | 2011-03-23 09:59:34 +0000 | [diff] [blame] | 2661 | if (r) |
| 2662 | goto err0; |
| 2663 | |
| 2664 | /* Wait for completion only if TE_EN/TE_START is still set */ |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 2665 | if (REG_GET(dsidev, DSI_VC_TE(channel), bit, bit)) { |
Archit Taneja | cf398fb | 2011-03-23 09:59:34 +0000 | [diff] [blame] | 2666 | if (wait_for_completion_timeout(&completion, |
| 2667 | msecs_to_jiffies(10)) == 0) { |
| 2668 | DSSERR("Failed to complete previous frame transfer\n"); |
| 2669 | r = -EIO; |
| 2670 | goto err1; |
| 2671 | } |
| 2672 | } |
| 2673 | |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 2674 | dsi_unregister_isr_vc(dsidev, channel, dsi_packet_sent_handler_vp, |
Archit Taneja | 2e868db | 2011-05-12 17:26:28 +0530 | [diff] [blame] | 2675 | &vp_data, DSI_VC_IRQ_PACKET_SENT); |
Archit Taneja | cf398fb | 2011-03-23 09:59:34 +0000 | [diff] [blame] | 2676 | |
| 2677 | return 0; |
| 2678 | err1: |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 2679 | dsi_unregister_isr_vc(dsidev, channel, dsi_packet_sent_handler_vp, |
Archit Taneja | 2e868db | 2011-05-12 17:26:28 +0530 | [diff] [blame] | 2680 | &vp_data, DSI_VC_IRQ_PACKET_SENT); |
Archit Taneja | cf398fb | 2011-03-23 09:59:34 +0000 | [diff] [blame] | 2681 | err0: |
| 2682 | return r; |
| 2683 | } |
| 2684 | |
| 2685 | static void dsi_packet_sent_handler_l4(void *data, u32 mask) |
| 2686 | { |
Archit Taneja | 2e868db | 2011-05-12 17:26:28 +0530 | [diff] [blame] | 2687 | struct dsi_packet_sent_handler_data *l4_data = |
| 2688 | (struct dsi_packet_sent_handler_data *) data; |
| 2689 | struct dsi_data *dsi = dsi_get_dsidrv_data(l4_data->dsidev); |
Archit Taneja | f1da39d | 2011-05-12 17:26:27 +0530 | [diff] [blame] | 2690 | const int channel = dsi->update_channel; |
Archit Taneja | cf398fb | 2011-03-23 09:59:34 +0000 | [diff] [blame] | 2691 | |
Archit Taneja | 2e868db | 2011-05-12 17:26:28 +0530 | [diff] [blame] | 2692 | if (REG_GET(l4_data->dsidev, DSI_VC_CTRL(channel), 5, 5) == 0) |
| 2693 | complete(l4_data->completion); |
Archit Taneja | cf398fb | 2011-03-23 09:59:34 +0000 | [diff] [blame] | 2694 | } |
| 2695 | |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 2696 | static int dsi_sync_vc_l4(struct platform_device *dsidev, int channel) |
Archit Taneja | cf398fb | 2011-03-23 09:59:34 +0000 | [diff] [blame] | 2697 | { |
Archit Taneja | 2e868db | 2011-05-12 17:26:28 +0530 | [diff] [blame] | 2698 | DECLARE_COMPLETION_ONSTACK(completion); |
| 2699 | struct dsi_packet_sent_handler_data l4_data = { dsidev, &completion }; |
Archit Taneja | cf398fb | 2011-03-23 09:59:34 +0000 | [diff] [blame] | 2700 | int r = 0; |
| 2701 | |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 2702 | r = dsi_register_isr_vc(dsidev, channel, dsi_packet_sent_handler_l4, |
Archit Taneja | 2e868db | 2011-05-12 17:26:28 +0530 | [diff] [blame] | 2703 | &l4_data, DSI_VC_IRQ_PACKET_SENT); |
Archit Taneja | cf398fb | 2011-03-23 09:59:34 +0000 | [diff] [blame] | 2704 | if (r) |
| 2705 | goto err0; |
| 2706 | |
| 2707 | /* Wait for completion only if TX_FIFO_NOT_EMPTY is still set */ |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 2708 | if (REG_GET(dsidev, DSI_VC_CTRL(channel), 5, 5)) { |
Archit Taneja | cf398fb | 2011-03-23 09:59:34 +0000 | [diff] [blame] | 2709 | if (wait_for_completion_timeout(&completion, |
| 2710 | msecs_to_jiffies(10)) == 0) { |
| 2711 | DSSERR("Failed to complete previous l4 transfer\n"); |
| 2712 | r = -EIO; |
| 2713 | goto err1; |
| 2714 | } |
| 2715 | } |
| 2716 | |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 2717 | dsi_unregister_isr_vc(dsidev, channel, dsi_packet_sent_handler_l4, |
Archit Taneja | 2e868db | 2011-05-12 17:26:28 +0530 | [diff] [blame] | 2718 | &l4_data, DSI_VC_IRQ_PACKET_SENT); |
Archit Taneja | cf398fb | 2011-03-23 09:59:34 +0000 | [diff] [blame] | 2719 | |
| 2720 | return 0; |
| 2721 | err1: |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 2722 | dsi_unregister_isr_vc(dsidev, channel, dsi_packet_sent_handler_l4, |
Archit Taneja | 2e868db | 2011-05-12 17:26:28 +0530 | [diff] [blame] | 2723 | &l4_data, DSI_VC_IRQ_PACKET_SENT); |
Archit Taneja | cf398fb | 2011-03-23 09:59:34 +0000 | [diff] [blame] | 2724 | err0: |
| 2725 | return r; |
| 2726 | } |
| 2727 | |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 2728 | static int dsi_sync_vc(struct platform_device *dsidev, int channel) |
Archit Taneja | cf398fb | 2011-03-23 09:59:34 +0000 | [diff] [blame] | 2729 | { |
Archit Taneja | f1da39d | 2011-05-12 17:26:27 +0530 | [diff] [blame] | 2730 | struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev); |
| 2731 | |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 2732 | WARN_ON(!dsi_bus_is_locked(dsidev)); |
Archit Taneja | cf398fb | 2011-03-23 09:59:34 +0000 | [diff] [blame] | 2733 | |
| 2734 | WARN_ON(in_interrupt()); |
| 2735 | |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 2736 | if (!dsi_vc_is_enabled(dsidev, channel)) |
Archit Taneja | cf398fb | 2011-03-23 09:59:34 +0000 | [diff] [blame] | 2737 | return 0; |
| 2738 | |
Archit Taneja | d604914 | 2011-08-22 11:58:08 +0530 | [diff] [blame] | 2739 | switch (dsi->vc[channel].source) { |
| 2740 | case DSI_VC_SOURCE_VP: |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 2741 | return dsi_sync_vc_vp(dsidev, channel); |
Archit Taneja | d604914 | 2011-08-22 11:58:08 +0530 | [diff] [blame] | 2742 | case DSI_VC_SOURCE_L4: |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 2743 | return dsi_sync_vc_l4(dsidev, channel); |
Archit Taneja | cf398fb | 2011-03-23 09:59:34 +0000 | [diff] [blame] | 2744 | default: |
| 2745 | BUG(); |
Tomi Valkeinen | c6eee96 | 2012-05-18 11:47:02 +0300 | [diff] [blame] | 2746 | return -EINVAL; |
Archit Taneja | cf398fb | 2011-03-23 09:59:34 +0000 | [diff] [blame] | 2747 | } |
| 2748 | } |
| 2749 | |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 2750 | static int dsi_vc_enable(struct platform_device *dsidev, int channel, |
| 2751 | bool enable) |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 2752 | { |
Tomi Valkeinen | 446f7bf | 2010-01-11 16:12:31 +0200 | [diff] [blame] | 2753 | DSSDBG("dsi_vc_enable channel %d, enable %d\n", |
| 2754 | channel, enable); |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 2755 | |
| 2756 | enable = enable ? 1 : 0; |
| 2757 | |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 2758 | REG_FLD_MOD(dsidev, DSI_VC_CTRL(channel), enable, 0, 0); |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 2759 | |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 2760 | if (wait_for_bit_change(dsidev, DSI_VC_CTRL(channel), |
| 2761 | 0, enable) != enable) { |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 2762 | DSSERR("Failed to set dsi_vc_enable to %d\n", enable); |
| 2763 | return -EIO; |
| 2764 | } |
| 2765 | |
| 2766 | return 0; |
| 2767 | } |
| 2768 | |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 2769 | static void dsi_vc_initial_config(struct platform_device *dsidev, int channel) |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 2770 | { |
| 2771 | u32 r; |
| 2772 | |
| 2773 | DSSDBGF("%d", channel); |
| 2774 | |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 2775 | r = dsi_read_reg(dsidev, DSI_VC_CTRL(channel)); |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 2776 | |
| 2777 | if (FLD_GET(r, 15, 15)) /* VC_BUSY */ |
| 2778 | DSSERR("VC(%d) busy when trying to configure it!\n", |
| 2779 | channel); |
| 2780 | |
| 2781 | r = FLD_MOD(r, 0, 1, 1); /* SOURCE, 0 = L4 */ |
| 2782 | r = FLD_MOD(r, 0, 2, 2); /* BTA_SHORT_EN */ |
| 2783 | r = FLD_MOD(r, 0, 3, 3); /* BTA_LONG_EN */ |
| 2784 | r = FLD_MOD(r, 0, 4, 4); /* MODE, 0 = command */ |
| 2785 | r = FLD_MOD(r, 1, 7, 7); /* CS_TX_EN */ |
| 2786 | r = FLD_MOD(r, 1, 8, 8); /* ECC_TX_EN */ |
| 2787 | r = FLD_MOD(r, 0, 9, 9); /* MODE_SPEED, high speed on/off */ |
Archit Taneja | 9613c02 | 2011-03-22 06:33:36 -0500 | [diff] [blame] | 2788 | if (dss_has_feature(FEAT_DSI_VC_OCP_WIDTH)) |
| 2789 | r = FLD_MOD(r, 3, 11, 10); /* OCP_WIDTH = 32 bit */ |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 2790 | |
| 2791 | r = FLD_MOD(r, 4, 29, 27); /* DMA_RX_REQ_NB = no dma */ |
| 2792 | r = FLD_MOD(r, 4, 23, 21); /* DMA_TX_REQ_NB = no dma */ |
| 2793 | |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 2794 | dsi_write_reg(dsidev, DSI_VC_CTRL(channel), r); |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 2795 | } |
| 2796 | |
Archit Taneja | d604914 | 2011-08-22 11:58:08 +0530 | [diff] [blame] | 2797 | static int dsi_vc_config_source(struct platform_device *dsidev, int channel, |
| 2798 | enum dsi_vc_source source) |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 2799 | { |
Archit Taneja | f1da39d | 2011-05-12 17:26:27 +0530 | [diff] [blame] | 2800 | struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev); |
| 2801 | |
Archit Taneja | d604914 | 2011-08-22 11:58:08 +0530 | [diff] [blame] | 2802 | if (dsi->vc[channel].source == source) |
Tomi Valkeinen | 9ecd968 | 2010-04-30 11:24:33 +0300 | [diff] [blame] | 2803 | return 0; |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 2804 | |
| 2805 | DSSDBGF("%d", channel); |
| 2806 | |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 2807 | dsi_sync_vc(dsidev, channel); |
Archit Taneja | cf398fb | 2011-03-23 09:59:34 +0000 | [diff] [blame] | 2808 | |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 2809 | dsi_vc_enable(dsidev, channel, 0); |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 2810 | |
Tomi Valkeinen | 9ecd968 | 2010-04-30 11:24:33 +0300 | [diff] [blame] | 2811 | /* VC_BUSY */ |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 2812 | if (wait_for_bit_change(dsidev, DSI_VC_CTRL(channel), 15, 0) != 0) { |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 2813 | DSSERR("vc(%d) busy when trying to config for VP\n", channel); |
Tomi Valkeinen | 9ecd968 | 2010-04-30 11:24:33 +0300 | [diff] [blame] | 2814 | return -EIO; |
| 2815 | } |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 2816 | |
Archit Taneja | d604914 | 2011-08-22 11:58:08 +0530 | [diff] [blame] | 2817 | /* SOURCE, 0 = L4, 1 = video port */ |
| 2818 | REG_FLD_MOD(dsidev, DSI_VC_CTRL(channel), source, 1, 1); |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 2819 | |
Archit Taneja | 9613c02 | 2011-03-22 06:33:36 -0500 | [diff] [blame] | 2820 | /* DCS_CMD_ENABLE */ |
Archit Taneja | d604914 | 2011-08-22 11:58:08 +0530 | [diff] [blame] | 2821 | if (dss_has_feature(FEAT_DSI_DCS_CMD_CONFIG_VC)) { |
| 2822 | bool enable = source == DSI_VC_SOURCE_VP; |
| 2823 | REG_FLD_MOD(dsidev, DSI_VC_CTRL(channel), enable, 30, 30); |
| 2824 | } |
Archit Taneja | 9613c02 | 2011-03-22 06:33:36 -0500 | [diff] [blame] | 2825 | |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 2826 | dsi_vc_enable(dsidev, channel, 1); |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 2827 | |
Archit Taneja | d604914 | 2011-08-22 11:58:08 +0530 | [diff] [blame] | 2828 | dsi->vc[channel].source = source; |
Tomi Valkeinen | 9ecd968 | 2010-04-30 11:24:33 +0300 | [diff] [blame] | 2829 | |
| 2830 | return 0; |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 2831 | } |
| 2832 | |
Archit Taneja | 1ffefe7 | 2011-05-12 17:26:24 +0530 | [diff] [blame] | 2833 | void omapdss_dsi_vc_enable_hs(struct omap_dss_device *dssdev, int channel, |
| 2834 | bool enable) |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 2835 | { |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 2836 | struct platform_device *dsidev = dsi_get_dsidev_from_dssdev(dssdev); |
Archit Taneja | 0b3ffe3 | 2012-08-13 22:13:39 +0530 | [diff] [blame] | 2837 | struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev); |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 2838 | |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 2839 | DSSDBG("dsi_vc_enable_hs(%d, %d)\n", channel, enable); |
| 2840 | |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 2841 | WARN_ON(!dsi_bus_is_locked(dsidev)); |
Tomi Valkeinen | 61140c9 | 2010-01-12 16:00:30 +0200 | [diff] [blame] | 2842 | |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 2843 | dsi_vc_enable(dsidev, channel, 0); |
| 2844 | dsi_if_enable(dsidev, 0); |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 2845 | |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 2846 | REG_FLD_MOD(dsidev, DSI_VC_CTRL(channel), enable, 9, 9); |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 2847 | |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 2848 | dsi_vc_enable(dsidev, channel, 1); |
| 2849 | dsi_if_enable(dsidev, 1); |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 2850 | |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 2851 | dsi_force_tx_stop_mode_io(dsidev); |
Archit Taneja | 8af6ff0 | 2011-09-05 16:48:27 +0530 | [diff] [blame] | 2852 | |
| 2853 | /* start the DDR clock by sending a NULL packet */ |
Archit Taneja | 0b3ffe3 | 2012-08-13 22:13:39 +0530 | [diff] [blame] | 2854 | if (dsi->vm_timings.ddr_clk_always_on && enable) |
Archit Taneja | 8af6ff0 | 2011-09-05 16:48:27 +0530 | [diff] [blame] | 2855 | dsi_vc_send_null(dssdev, channel); |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 2856 | } |
Tomi Valkeinen | 61140c9 | 2010-01-12 16:00:30 +0200 | [diff] [blame] | 2857 | EXPORT_SYMBOL(omapdss_dsi_vc_enable_hs); |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 2858 | |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 2859 | static void dsi_vc_flush_long_data(struct platform_device *dsidev, int channel) |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 2860 | { |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 2861 | while (REG_GET(dsidev, DSI_VC_CTRL(channel), 20, 20)) { |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 2862 | u32 val; |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 2863 | val = dsi_read_reg(dsidev, DSI_VC_SHORT_PACKET_HEADER(channel)); |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 2864 | DSSDBG("\t\tb1 %#02x b2 %#02x b3 %#02x b4 %#02x\n", |
| 2865 | (val >> 0) & 0xff, |
| 2866 | (val >> 8) & 0xff, |
| 2867 | (val >> 16) & 0xff, |
| 2868 | (val >> 24) & 0xff); |
| 2869 | } |
| 2870 | } |
| 2871 | |
| 2872 | static void dsi_show_rx_ack_with_err(u16 err) |
| 2873 | { |
| 2874 | DSSERR("\tACK with ERROR (%#x):\n", err); |
| 2875 | if (err & (1 << 0)) |
| 2876 | DSSERR("\t\tSoT Error\n"); |
| 2877 | if (err & (1 << 1)) |
| 2878 | DSSERR("\t\tSoT Sync Error\n"); |
| 2879 | if (err & (1 << 2)) |
| 2880 | DSSERR("\t\tEoT Sync Error\n"); |
| 2881 | if (err & (1 << 3)) |
| 2882 | DSSERR("\t\tEscape Mode Entry Command Error\n"); |
| 2883 | if (err & (1 << 4)) |
| 2884 | DSSERR("\t\tLP Transmit Sync Error\n"); |
| 2885 | if (err & (1 << 5)) |
| 2886 | DSSERR("\t\tHS Receive Timeout Error\n"); |
| 2887 | if (err & (1 << 6)) |
| 2888 | DSSERR("\t\tFalse Control Error\n"); |
| 2889 | if (err & (1 << 7)) |
| 2890 | DSSERR("\t\t(reserved7)\n"); |
| 2891 | if (err & (1 << 8)) |
| 2892 | DSSERR("\t\tECC Error, single-bit (corrected)\n"); |
| 2893 | if (err & (1 << 9)) |
| 2894 | DSSERR("\t\tECC Error, multi-bit (not corrected)\n"); |
| 2895 | if (err & (1 << 10)) |
| 2896 | DSSERR("\t\tChecksum Error\n"); |
| 2897 | if (err & (1 << 11)) |
| 2898 | DSSERR("\t\tData type not recognized\n"); |
| 2899 | if (err & (1 << 12)) |
| 2900 | DSSERR("\t\tInvalid VC ID\n"); |
| 2901 | if (err & (1 << 13)) |
| 2902 | DSSERR("\t\tInvalid Transmission Length\n"); |
| 2903 | if (err & (1 << 14)) |
| 2904 | DSSERR("\t\t(reserved14)\n"); |
| 2905 | if (err & (1 << 15)) |
| 2906 | DSSERR("\t\tDSI Protocol Violation\n"); |
| 2907 | } |
| 2908 | |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 2909 | static u16 dsi_vc_flush_receive_data(struct platform_device *dsidev, |
| 2910 | int channel) |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 2911 | { |
| 2912 | /* RX_FIFO_NOT_EMPTY */ |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 2913 | while (REG_GET(dsidev, DSI_VC_CTRL(channel), 20, 20)) { |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 2914 | u32 val; |
| 2915 | u8 dt; |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 2916 | val = dsi_read_reg(dsidev, DSI_VC_SHORT_PACKET_HEADER(channel)); |
Tomi Valkeinen | 86a7867 | 2010-03-16 16:19:06 +0200 | [diff] [blame] | 2917 | DSSERR("\trawval %#08x\n", val); |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 2918 | dt = FLD_GET(val, 5, 0); |
Archit Taneja | 7a7c48f | 2011-08-25 18:25:03 +0530 | [diff] [blame] | 2919 | if (dt == MIPI_DSI_RX_ACKNOWLEDGE_AND_ERROR_REPORT) { |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 2920 | u16 err = FLD_GET(val, 23, 8); |
| 2921 | dsi_show_rx_ack_with_err(err); |
Archit Taneja | 7a7c48f | 2011-08-25 18:25:03 +0530 | [diff] [blame] | 2922 | } else if (dt == MIPI_DSI_RX_DCS_SHORT_READ_RESPONSE_1BYTE) { |
Tomi Valkeinen | 86a7867 | 2010-03-16 16:19:06 +0200 | [diff] [blame] | 2923 | DSSERR("\tDCS short response, 1 byte: %#x\n", |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 2924 | FLD_GET(val, 23, 8)); |
Archit Taneja | 7a7c48f | 2011-08-25 18:25:03 +0530 | [diff] [blame] | 2925 | } else if (dt == MIPI_DSI_RX_DCS_SHORT_READ_RESPONSE_2BYTE) { |
Tomi Valkeinen | 86a7867 | 2010-03-16 16:19:06 +0200 | [diff] [blame] | 2926 | DSSERR("\tDCS short response, 2 byte: %#x\n", |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 2927 | FLD_GET(val, 23, 8)); |
Archit Taneja | 7a7c48f | 2011-08-25 18:25:03 +0530 | [diff] [blame] | 2928 | } else if (dt == MIPI_DSI_RX_DCS_LONG_READ_RESPONSE) { |
Tomi Valkeinen | 86a7867 | 2010-03-16 16:19:06 +0200 | [diff] [blame] | 2929 | DSSERR("\tDCS long response, len %d\n", |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 2930 | FLD_GET(val, 23, 8)); |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 2931 | dsi_vc_flush_long_data(dsidev, channel); |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 2932 | } else { |
| 2933 | DSSERR("\tunknown datatype 0x%02x\n", dt); |
| 2934 | } |
| 2935 | } |
| 2936 | return 0; |
| 2937 | } |
| 2938 | |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 2939 | static int dsi_vc_send_bta(struct platform_device *dsidev, int channel) |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 2940 | { |
Archit Taneja | f1da39d | 2011-05-12 17:26:27 +0530 | [diff] [blame] | 2941 | struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev); |
| 2942 | |
| 2943 | if (dsi->debug_write || dsi->debug_read) |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 2944 | DSSDBG("dsi_vc_send_bta %d\n", channel); |
| 2945 | |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 2946 | WARN_ON(!dsi_bus_is_locked(dsidev)); |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 2947 | |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 2948 | /* RX_FIFO_NOT_EMPTY */ |
| 2949 | if (REG_GET(dsidev, DSI_VC_CTRL(channel), 20, 20)) { |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 2950 | DSSERR("rx fifo not empty when sending BTA, dumping data:\n"); |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 2951 | dsi_vc_flush_receive_data(dsidev, channel); |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 2952 | } |
| 2953 | |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 2954 | REG_FLD_MOD(dsidev, DSI_VC_CTRL(channel), 1, 6, 6); /* BTA_EN */ |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 2955 | |
Tomi Valkeinen | 968f8e9 | 2011-10-12 10:13:14 +0300 | [diff] [blame] | 2956 | /* flush posted write */ |
| 2957 | dsi_read_reg(dsidev, DSI_VC_CTRL(channel)); |
| 2958 | |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 2959 | return 0; |
| 2960 | } |
| 2961 | |
Archit Taneja | 1ffefe7 | 2011-05-12 17:26:24 +0530 | [diff] [blame] | 2962 | int dsi_vc_send_bta_sync(struct omap_dss_device *dssdev, int channel) |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 2963 | { |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 2964 | struct platform_device *dsidev = dsi_get_dsidev_from_dssdev(dssdev); |
Tomi Valkeinen | f36a06e | 2011-03-02 14:48:41 +0200 | [diff] [blame] | 2965 | DECLARE_COMPLETION_ONSTACK(completion); |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 2966 | int r = 0; |
| 2967 | u32 err; |
| 2968 | |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 2969 | r = dsi_register_isr_vc(dsidev, channel, dsi_completion_handler, |
Tomi Valkeinen | f36a06e | 2011-03-02 14:48:41 +0200 | [diff] [blame] | 2970 | &completion, DSI_VC_IRQ_BTA); |
| 2971 | if (r) |
| 2972 | goto err0; |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 2973 | |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 2974 | r = dsi_register_isr(dsidev, dsi_completion_handler, &completion, |
Tomi Valkeinen | 773b30b | 2010-10-08 16:15:25 +0300 | [diff] [blame] | 2975 | DSI_IRQ_ERROR_MASK); |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 2976 | if (r) |
Tomi Valkeinen | f36a06e | 2011-03-02 14:48:41 +0200 | [diff] [blame] | 2977 | goto err1; |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 2978 | |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 2979 | r = dsi_vc_send_bta(dsidev, channel); |
Tomi Valkeinen | 773b30b | 2010-10-08 16:15:25 +0300 | [diff] [blame] | 2980 | if (r) |
| 2981 | goto err2; |
| 2982 | |
Tomi Valkeinen | f36a06e | 2011-03-02 14:48:41 +0200 | [diff] [blame] | 2983 | if (wait_for_completion_timeout(&completion, |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 2984 | msecs_to_jiffies(500)) == 0) { |
| 2985 | DSSERR("Failed to receive BTA\n"); |
| 2986 | r = -EIO; |
Tomi Valkeinen | 773b30b | 2010-10-08 16:15:25 +0300 | [diff] [blame] | 2987 | goto err2; |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 2988 | } |
| 2989 | |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 2990 | err = dsi_get_errors(dsidev); |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 2991 | if (err) { |
| 2992 | DSSERR("Error while sending BTA: %x\n", err); |
| 2993 | r = -EIO; |
Tomi Valkeinen | 773b30b | 2010-10-08 16:15:25 +0300 | [diff] [blame] | 2994 | goto err2; |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 2995 | } |
Tomi Valkeinen | 773b30b | 2010-10-08 16:15:25 +0300 | [diff] [blame] | 2996 | err2: |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 2997 | dsi_unregister_isr(dsidev, dsi_completion_handler, &completion, |
Tomi Valkeinen | 773b30b | 2010-10-08 16:15:25 +0300 | [diff] [blame] | 2998 | DSI_IRQ_ERROR_MASK); |
Tomi Valkeinen | f36a06e | 2011-03-02 14:48:41 +0200 | [diff] [blame] | 2999 | err1: |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 3000 | dsi_unregister_isr_vc(dsidev, channel, dsi_completion_handler, |
Tomi Valkeinen | f36a06e | 2011-03-02 14:48:41 +0200 | [diff] [blame] | 3001 | &completion, DSI_VC_IRQ_BTA); |
| 3002 | err0: |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 3003 | return r; |
| 3004 | } |
| 3005 | EXPORT_SYMBOL(dsi_vc_send_bta_sync); |
| 3006 | |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 3007 | static inline void dsi_vc_write_long_header(struct platform_device *dsidev, |
| 3008 | int channel, u8 data_type, u16 len, u8 ecc) |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 3009 | { |
Archit Taneja | f1da39d | 2011-05-12 17:26:27 +0530 | [diff] [blame] | 3010 | struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev); |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 3011 | u32 val; |
| 3012 | u8 data_id; |
| 3013 | |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 3014 | WARN_ON(!dsi_bus_is_locked(dsidev)); |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 3015 | |
Archit Taneja | f1da39d | 2011-05-12 17:26:27 +0530 | [diff] [blame] | 3016 | data_id = data_type | dsi->vc[channel].vc_id << 6; |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 3017 | |
| 3018 | val = FLD_VAL(data_id, 7, 0) | FLD_VAL(len, 23, 8) | |
| 3019 | FLD_VAL(ecc, 31, 24); |
| 3020 | |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 3021 | dsi_write_reg(dsidev, DSI_VC_LONG_PACKET_HEADER(channel), val); |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 3022 | } |
| 3023 | |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 3024 | static inline void dsi_vc_write_long_payload(struct platform_device *dsidev, |
| 3025 | int channel, u8 b1, u8 b2, u8 b3, u8 b4) |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 3026 | { |
| 3027 | u32 val; |
| 3028 | |
| 3029 | val = b4 << 24 | b3 << 16 | b2 << 8 | b1 << 0; |
| 3030 | |
| 3031 | /* DSSDBG("\twriting %02x, %02x, %02x, %02x (%#010x)\n", |
| 3032 | b1, b2, b3, b4, val); */ |
| 3033 | |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 3034 | dsi_write_reg(dsidev, DSI_VC_LONG_PACKET_PAYLOAD(channel), val); |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 3035 | } |
| 3036 | |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 3037 | static int dsi_vc_send_long(struct platform_device *dsidev, int channel, |
| 3038 | u8 data_type, u8 *data, u16 len, u8 ecc) |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 3039 | { |
| 3040 | /*u32 val; */ |
Archit Taneja | f1da39d | 2011-05-12 17:26:27 +0530 | [diff] [blame] | 3041 | struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev); |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 3042 | int i; |
| 3043 | u8 *p; |
| 3044 | int r = 0; |
| 3045 | u8 b1, b2, b3, b4; |
| 3046 | |
Archit Taneja | f1da39d | 2011-05-12 17:26:27 +0530 | [diff] [blame] | 3047 | if (dsi->debug_write) |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 3048 | DSSDBG("dsi_vc_send_long, %d bytes\n", len); |
| 3049 | |
| 3050 | /* len + header */ |
Archit Taneja | f1da39d | 2011-05-12 17:26:27 +0530 | [diff] [blame] | 3051 | if (dsi->vc[channel].fifo_size * 32 * 4 < len + 4) { |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 3052 | DSSERR("unable to send long packet: packet too long.\n"); |
| 3053 | return -EINVAL; |
| 3054 | } |
| 3055 | |
Archit Taneja | d604914 | 2011-08-22 11:58:08 +0530 | [diff] [blame] | 3056 | dsi_vc_config_source(dsidev, channel, DSI_VC_SOURCE_L4); |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 3057 | |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 3058 | dsi_vc_write_long_header(dsidev, channel, data_type, len, ecc); |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 3059 | |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 3060 | p = data; |
| 3061 | for (i = 0; i < len >> 2; i++) { |
Archit Taneja | f1da39d | 2011-05-12 17:26:27 +0530 | [diff] [blame] | 3062 | if (dsi->debug_write) |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 3063 | DSSDBG("\tsending full packet %d\n", i); |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 3064 | |
| 3065 | b1 = *p++; |
| 3066 | b2 = *p++; |
| 3067 | b3 = *p++; |
| 3068 | b4 = *p++; |
| 3069 | |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 3070 | dsi_vc_write_long_payload(dsidev, channel, b1, b2, b3, b4); |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 3071 | } |
| 3072 | |
| 3073 | i = len % 4; |
| 3074 | if (i) { |
| 3075 | b1 = 0; b2 = 0; b3 = 0; |
| 3076 | |
Archit Taneja | f1da39d | 2011-05-12 17:26:27 +0530 | [diff] [blame] | 3077 | if (dsi->debug_write) |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 3078 | DSSDBG("\tsending remainder bytes %d\n", i); |
| 3079 | |
| 3080 | switch (i) { |
| 3081 | case 3: |
| 3082 | b1 = *p++; |
| 3083 | b2 = *p++; |
| 3084 | b3 = *p++; |
| 3085 | break; |
| 3086 | case 2: |
| 3087 | b1 = *p++; |
| 3088 | b2 = *p++; |
| 3089 | break; |
| 3090 | case 1: |
| 3091 | b1 = *p++; |
| 3092 | break; |
| 3093 | } |
| 3094 | |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 3095 | dsi_vc_write_long_payload(dsidev, channel, b1, b2, b3, 0); |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 3096 | } |
| 3097 | |
| 3098 | return r; |
| 3099 | } |
| 3100 | |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 3101 | static int dsi_vc_send_short(struct platform_device *dsidev, int channel, |
| 3102 | u8 data_type, u16 data, u8 ecc) |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 3103 | { |
Archit Taneja | f1da39d | 2011-05-12 17:26:27 +0530 | [diff] [blame] | 3104 | struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev); |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 3105 | u32 r; |
| 3106 | u8 data_id; |
| 3107 | |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 3108 | WARN_ON(!dsi_bus_is_locked(dsidev)); |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 3109 | |
Archit Taneja | f1da39d | 2011-05-12 17:26:27 +0530 | [diff] [blame] | 3110 | if (dsi->debug_write) |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 3111 | DSSDBG("dsi_vc_send_short(ch%d, dt %#x, b1 %#x, b2 %#x)\n", |
| 3112 | channel, |
| 3113 | data_type, data & 0xff, (data >> 8) & 0xff); |
| 3114 | |
Archit Taneja | d604914 | 2011-08-22 11:58:08 +0530 | [diff] [blame] | 3115 | dsi_vc_config_source(dsidev, channel, DSI_VC_SOURCE_L4); |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 3116 | |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 3117 | if (FLD_GET(dsi_read_reg(dsidev, DSI_VC_CTRL(channel)), 16, 16)) { |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 3118 | DSSERR("ERROR FIFO FULL, aborting transfer\n"); |
| 3119 | return -EINVAL; |
| 3120 | } |
| 3121 | |
Archit Taneja | f1da39d | 2011-05-12 17:26:27 +0530 | [diff] [blame] | 3122 | data_id = data_type | dsi->vc[channel].vc_id << 6; |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 3123 | |
| 3124 | r = (data_id << 0) | (data << 8) | (ecc << 24); |
| 3125 | |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 3126 | dsi_write_reg(dsidev, DSI_VC_SHORT_PACKET_HEADER(channel), r); |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 3127 | |
| 3128 | return 0; |
| 3129 | } |
| 3130 | |
Archit Taneja | 1ffefe7 | 2011-05-12 17:26:24 +0530 | [diff] [blame] | 3131 | int dsi_vc_send_null(struct omap_dss_device *dssdev, int channel) |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 3132 | { |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 3133 | struct platform_device *dsidev = dsi_get_dsidev_from_dssdev(dssdev); |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 3134 | |
Archit Taneja | 18b7d09 | 2011-09-05 17:01:08 +0530 | [diff] [blame] | 3135 | return dsi_vc_send_long(dsidev, channel, MIPI_DSI_NULL_PACKET, NULL, |
| 3136 | 0, 0); |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 3137 | } |
| 3138 | EXPORT_SYMBOL(dsi_vc_send_null); |
| 3139 | |
Archit Taneja | 6ff8aa3 | 2011-08-25 18:35:58 +0530 | [diff] [blame] | 3140 | static int dsi_vc_write_nosync_common(struct omap_dss_device *dssdev, |
| 3141 | int channel, u8 *data, int len, enum dss_dsi_content_type type) |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 3142 | { |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 3143 | struct platform_device *dsidev = dsi_get_dsidev_from_dssdev(dssdev); |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 3144 | int r; |
| 3145 | |
Archit Taneja | 6ff8aa3 | 2011-08-25 18:35:58 +0530 | [diff] [blame] | 3146 | if (len == 0) { |
| 3147 | BUG_ON(type == DSS_DSI_CONTENT_DCS); |
Archit Taneja | 7a7c48f | 2011-08-25 18:25:03 +0530 | [diff] [blame] | 3148 | r = dsi_vc_send_short(dsidev, channel, |
Archit Taneja | 6ff8aa3 | 2011-08-25 18:35:58 +0530 | [diff] [blame] | 3149 | MIPI_DSI_GENERIC_SHORT_WRITE_0_PARAM, 0, 0); |
| 3150 | } else if (len == 1) { |
| 3151 | r = dsi_vc_send_short(dsidev, channel, |
| 3152 | type == DSS_DSI_CONTENT_GENERIC ? |
| 3153 | MIPI_DSI_GENERIC_SHORT_WRITE_1_PARAM : |
Archit Taneja | 7a7c48f | 2011-08-25 18:25:03 +0530 | [diff] [blame] | 3154 | MIPI_DSI_DCS_SHORT_WRITE, data[0], 0); |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 3155 | } else if (len == 2) { |
Archit Taneja | 7a7c48f | 2011-08-25 18:25:03 +0530 | [diff] [blame] | 3156 | r = dsi_vc_send_short(dsidev, channel, |
Archit Taneja | 6ff8aa3 | 2011-08-25 18:35:58 +0530 | [diff] [blame] | 3157 | type == DSS_DSI_CONTENT_GENERIC ? |
| 3158 | MIPI_DSI_GENERIC_SHORT_WRITE_2_PARAM : |
Archit Taneja | 7a7c48f | 2011-08-25 18:25:03 +0530 | [diff] [blame] | 3159 | MIPI_DSI_DCS_SHORT_WRITE_PARAM, |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 3160 | data[0] | (data[1] << 8), 0); |
| 3161 | } else { |
Archit Taneja | 6ff8aa3 | 2011-08-25 18:35:58 +0530 | [diff] [blame] | 3162 | r = dsi_vc_send_long(dsidev, channel, |
| 3163 | type == DSS_DSI_CONTENT_GENERIC ? |
| 3164 | MIPI_DSI_GENERIC_LONG_WRITE : |
| 3165 | MIPI_DSI_DCS_LONG_WRITE, data, len, 0); |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 3166 | } |
| 3167 | |
| 3168 | return r; |
| 3169 | } |
Archit Taneja | 6ff8aa3 | 2011-08-25 18:35:58 +0530 | [diff] [blame] | 3170 | |
| 3171 | int dsi_vc_dcs_write_nosync(struct omap_dss_device *dssdev, int channel, |
| 3172 | u8 *data, int len) |
| 3173 | { |
| 3174 | return dsi_vc_write_nosync_common(dssdev, channel, data, len, |
| 3175 | DSS_DSI_CONTENT_DCS); |
| 3176 | } |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 3177 | EXPORT_SYMBOL(dsi_vc_dcs_write_nosync); |
| 3178 | |
Archit Taneja | 6ff8aa3 | 2011-08-25 18:35:58 +0530 | [diff] [blame] | 3179 | int dsi_vc_generic_write_nosync(struct omap_dss_device *dssdev, int channel, |
| 3180 | u8 *data, int len) |
| 3181 | { |
| 3182 | return dsi_vc_write_nosync_common(dssdev, channel, data, len, |
| 3183 | DSS_DSI_CONTENT_GENERIC); |
| 3184 | } |
| 3185 | EXPORT_SYMBOL(dsi_vc_generic_write_nosync); |
| 3186 | |
| 3187 | static int dsi_vc_write_common(struct omap_dss_device *dssdev, int channel, |
| 3188 | u8 *data, int len, enum dss_dsi_content_type type) |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 3189 | { |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 3190 | struct platform_device *dsidev = dsi_get_dsidev_from_dssdev(dssdev); |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 3191 | int r; |
| 3192 | |
Archit Taneja | 6ff8aa3 | 2011-08-25 18:35:58 +0530 | [diff] [blame] | 3193 | r = dsi_vc_write_nosync_common(dssdev, channel, data, len, type); |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 3194 | if (r) |
Tomi Valkeinen | 5d68e03 | 2010-02-26 11:32:56 +0200 | [diff] [blame] | 3195 | goto err; |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 3196 | |
Archit Taneja | 1ffefe7 | 2011-05-12 17:26:24 +0530 | [diff] [blame] | 3197 | r = dsi_vc_send_bta_sync(dssdev, channel); |
Tomi Valkeinen | 5d68e03 | 2010-02-26 11:32:56 +0200 | [diff] [blame] | 3198 | if (r) |
| 3199 | goto err; |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 3200 | |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 3201 | /* RX_FIFO_NOT_EMPTY */ |
| 3202 | if (REG_GET(dsidev, DSI_VC_CTRL(channel), 20, 20)) { |
Tomi Valkeinen | b63ac1e | 2010-04-09 13:20:57 +0300 | [diff] [blame] | 3203 | DSSERR("rx fifo not empty after write, dumping data:\n"); |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 3204 | dsi_vc_flush_receive_data(dsidev, channel); |
Tomi Valkeinen | b63ac1e | 2010-04-09 13:20:57 +0300 | [diff] [blame] | 3205 | r = -EIO; |
| 3206 | goto err; |
| 3207 | } |
| 3208 | |
Tomi Valkeinen | 5d68e03 | 2010-02-26 11:32:56 +0200 | [diff] [blame] | 3209 | return 0; |
| 3210 | err: |
Archit Taneja | 6ff8aa3 | 2011-08-25 18:35:58 +0530 | [diff] [blame] | 3211 | DSSERR("dsi_vc_write_common(ch %d, cmd 0x%02x, len %d) failed\n", |
Tomi Valkeinen | 5d68e03 | 2010-02-26 11:32:56 +0200 | [diff] [blame] | 3212 | channel, data[0], len); |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 3213 | return r; |
| 3214 | } |
Archit Taneja | 6ff8aa3 | 2011-08-25 18:35:58 +0530 | [diff] [blame] | 3215 | |
| 3216 | int dsi_vc_dcs_write(struct omap_dss_device *dssdev, int channel, u8 *data, |
| 3217 | int len) |
| 3218 | { |
| 3219 | return dsi_vc_write_common(dssdev, channel, data, len, |
| 3220 | DSS_DSI_CONTENT_DCS); |
| 3221 | } |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 3222 | EXPORT_SYMBOL(dsi_vc_dcs_write); |
| 3223 | |
Archit Taneja | 6ff8aa3 | 2011-08-25 18:35:58 +0530 | [diff] [blame] | 3224 | int dsi_vc_generic_write(struct omap_dss_device *dssdev, int channel, u8 *data, |
| 3225 | int len) |
| 3226 | { |
| 3227 | return dsi_vc_write_common(dssdev, channel, data, len, |
| 3228 | DSS_DSI_CONTENT_GENERIC); |
| 3229 | } |
| 3230 | EXPORT_SYMBOL(dsi_vc_generic_write); |
| 3231 | |
Archit Taneja | 1ffefe7 | 2011-05-12 17:26:24 +0530 | [diff] [blame] | 3232 | int dsi_vc_dcs_write_0(struct omap_dss_device *dssdev, int channel, u8 dcs_cmd) |
Tomi Valkeinen | 828c48f | 2009-12-16 14:53:15 +0200 | [diff] [blame] | 3233 | { |
Archit Taneja | 1ffefe7 | 2011-05-12 17:26:24 +0530 | [diff] [blame] | 3234 | return dsi_vc_dcs_write(dssdev, channel, &dcs_cmd, 1); |
Tomi Valkeinen | 828c48f | 2009-12-16 14:53:15 +0200 | [diff] [blame] | 3235 | } |
| 3236 | EXPORT_SYMBOL(dsi_vc_dcs_write_0); |
| 3237 | |
Archit Taneja | 6ff8aa3 | 2011-08-25 18:35:58 +0530 | [diff] [blame] | 3238 | int dsi_vc_generic_write_0(struct omap_dss_device *dssdev, int channel) |
| 3239 | { |
| 3240 | return dsi_vc_generic_write(dssdev, channel, NULL, 0); |
| 3241 | } |
| 3242 | EXPORT_SYMBOL(dsi_vc_generic_write_0); |
| 3243 | |
Archit Taneja | 1ffefe7 | 2011-05-12 17:26:24 +0530 | [diff] [blame] | 3244 | int dsi_vc_dcs_write_1(struct omap_dss_device *dssdev, int channel, u8 dcs_cmd, |
| 3245 | u8 param) |
Tomi Valkeinen | 828c48f | 2009-12-16 14:53:15 +0200 | [diff] [blame] | 3246 | { |
| 3247 | u8 buf[2]; |
| 3248 | buf[0] = dcs_cmd; |
| 3249 | buf[1] = param; |
Archit Taneja | 1ffefe7 | 2011-05-12 17:26:24 +0530 | [diff] [blame] | 3250 | return dsi_vc_dcs_write(dssdev, channel, buf, 2); |
Tomi Valkeinen | 828c48f | 2009-12-16 14:53:15 +0200 | [diff] [blame] | 3251 | } |
| 3252 | EXPORT_SYMBOL(dsi_vc_dcs_write_1); |
| 3253 | |
Archit Taneja | 6ff8aa3 | 2011-08-25 18:35:58 +0530 | [diff] [blame] | 3254 | int dsi_vc_generic_write_1(struct omap_dss_device *dssdev, int channel, |
| 3255 | u8 param) |
| 3256 | { |
| 3257 | return dsi_vc_generic_write(dssdev, channel, ¶m, 1); |
| 3258 | } |
| 3259 | EXPORT_SYMBOL(dsi_vc_generic_write_1); |
| 3260 | |
| 3261 | int dsi_vc_generic_write_2(struct omap_dss_device *dssdev, int channel, |
| 3262 | u8 param1, u8 param2) |
| 3263 | { |
| 3264 | u8 buf[2]; |
| 3265 | buf[0] = param1; |
| 3266 | buf[1] = param2; |
| 3267 | return dsi_vc_generic_write(dssdev, channel, buf, 2); |
| 3268 | } |
| 3269 | EXPORT_SYMBOL(dsi_vc_generic_write_2); |
| 3270 | |
Archit Taneja | b850975 | 2011-08-30 15:48:23 +0530 | [diff] [blame] | 3271 | static int dsi_vc_dcs_send_read_request(struct omap_dss_device *dssdev, |
| 3272 | int channel, u8 dcs_cmd) |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 3273 | { |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 3274 | struct platform_device *dsidev = dsi_get_dsidev_from_dssdev(dssdev); |
Archit Taneja | f1da39d | 2011-05-12 17:26:27 +0530 | [diff] [blame] | 3275 | struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev); |
Archit Taneja | b850975 | 2011-08-30 15:48:23 +0530 | [diff] [blame] | 3276 | int r; |
| 3277 | |
| 3278 | if (dsi->debug_read) |
| 3279 | DSSDBG("dsi_vc_dcs_send_read_request(ch%d, dcs_cmd %x)\n", |
| 3280 | channel, dcs_cmd); |
| 3281 | |
| 3282 | r = dsi_vc_send_short(dsidev, channel, MIPI_DSI_DCS_READ, dcs_cmd, 0); |
| 3283 | if (r) { |
| 3284 | DSSERR("dsi_vc_dcs_send_read_request(ch %d, cmd 0x%02x)" |
| 3285 | " failed\n", channel, dcs_cmd); |
| 3286 | return r; |
| 3287 | } |
| 3288 | |
| 3289 | return 0; |
| 3290 | } |
| 3291 | |
Archit Taneja | b3b89c0 | 2011-08-30 16:07:39 +0530 | [diff] [blame] | 3292 | static int dsi_vc_generic_send_read_request(struct omap_dss_device *dssdev, |
| 3293 | int channel, u8 *reqdata, int reqlen) |
| 3294 | { |
| 3295 | struct platform_device *dsidev = dsi_get_dsidev_from_dssdev(dssdev); |
| 3296 | struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev); |
| 3297 | u16 data; |
| 3298 | u8 data_type; |
| 3299 | int r; |
| 3300 | |
| 3301 | if (dsi->debug_read) |
| 3302 | DSSDBG("dsi_vc_generic_send_read_request(ch %d, reqlen %d)\n", |
| 3303 | channel, reqlen); |
| 3304 | |
| 3305 | if (reqlen == 0) { |
| 3306 | data_type = MIPI_DSI_GENERIC_READ_REQUEST_0_PARAM; |
| 3307 | data = 0; |
| 3308 | } else if (reqlen == 1) { |
| 3309 | data_type = MIPI_DSI_GENERIC_READ_REQUEST_1_PARAM; |
| 3310 | data = reqdata[0]; |
| 3311 | } else if (reqlen == 2) { |
| 3312 | data_type = MIPI_DSI_GENERIC_READ_REQUEST_2_PARAM; |
| 3313 | data = reqdata[0] | (reqdata[1] << 8); |
| 3314 | } else { |
| 3315 | BUG(); |
Tomi Valkeinen | c6eee96 | 2012-05-18 11:47:02 +0300 | [diff] [blame] | 3316 | return -EINVAL; |
Archit Taneja | b3b89c0 | 2011-08-30 16:07:39 +0530 | [diff] [blame] | 3317 | } |
| 3318 | |
| 3319 | r = dsi_vc_send_short(dsidev, channel, data_type, data, 0); |
| 3320 | if (r) { |
| 3321 | DSSERR("dsi_vc_generic_send_read_request(ch %d, reqlen %d)" |
| 3322 | " failed\n", channel, reqlen); |
| 3323 | return r; |
| 3324 | } |
| 3325 | |
| 3326 | return 0; |
| 3327 | } |
| 3328 | |
| 3329 | static int dsi_vc_read_rx_fifo(struct platform_device *dsidev, int channel, |
| 3330 | u8 *buf, int buflen, enum dss_dsi_content_type type) |
Archit Taneja | b850975 | 2011-08-30 15:48:23 +0530 | [diff] [blame] | 3331 | { |
| 3332 | struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev); |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 3333 | u32 val; |
| 3334 | u8 dt; |
| 3335 | int r; |
| 3336 | |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 3337 | /* RX_FIFO_NOT_EMPTY */ |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 3338 | if (REG_GET(dsidev, DSI_VC_CTRL(channel), 20, 20) == 0) { |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 3339 | DSSERR("RX fifo empty when trying to read.\n"); |
Tomi Valkeinen | 5d68e03 | 2010-02-26 11:32:56 +0200 | [diff] [blame] | 3340 | r = -EIO; |
| 3341 | goto err; |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 3342 | } |
| 3343 | |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 3344 | val = dsi_read_reg(dsidev, DSI_VC_SHORT_PACKET_HEADER(channel)); |
Archit Taneja | f1da39d | 2011-05-12 17:26:27 +0530 | [diff] [blame] | 3345 | if (dsi->debug_read) |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 3346 | DSSDBG("\theader: %08x\n", val); |
| 3347 | dt = FLD_GET(val, 5, 0); |
Archit Taneja | 7a7c48f | 2011-08-25 18:25:03 +0530 | [diff] [blame] | 3348 | if (dt == MIPI_DSI_RX_ACKNOWLEDGE_AND_ERROR_REPORT) { |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 3349 | u16 err = FLD_GET(val, 23, 8); |
| 3350 | dsi_show_rx_ack_with_err(err); |
Tomi Valkeinen | 5d68e03 | 2010-02-26 11:32:56 +0200 | [diff] [blame] | 3351 | r = -EIO; |
| 3352 | goto err; |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 3353 | |
Archit Taneja | b3b89c0 | 2011-08-30 16:07:39 +0530 | [diff] [blame] | 3354 | } else if (dt == (type == DSS_DSI_CONTENT_GENERIC ? |
| 3355 | MIPI_DSI_RX_GENERIC_SHORT_READ_RESPONSE_1BYTE : |
| 3356 | MIPI_DSI_RX_DCS_SHORT_READ_RESPONSE_1BYTE)) { |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 3357 | u8 data = FLD_GET(val, 15, 8); |
Archit Taneja | f1da39d | 2011-05-12 17:26:27 +0530 | [diff] [blame] | 3358 | if (dsi->debug_read) |
Archit Taneja | b3b89c0 | 2011-08-30 16:07:39 +0530 | [diff] [blame] | 3359 | DSSDBG("\t%s short response, 1 byte: %02x\n", |
| 3360 | type == DSS_DSI_CONTENT_GENERIC ? "GENERIC" : |
| 3361 | "DCS", data); |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 3362 | |
Tomi Valkeinen | 5d68e03 | 2010-02-26 11:32:56 +0200 | [diff] [blame] | 3363 | if (buflen < 1) { |
| 3364 | r = -EIO; |
| 3365 | goto err; |
| 3366 | } |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 3367 | |
| 3368 | buf[0] = data; |
| 3369 | |
| 3370 | return 1; |
Archit Taneja | b3b89c0 | 2011-08-30 16:07:39 +0530 | [diff] [blame] | 3371 | } else if (dt == (type == DSS_DSI_CONTENT_GENERIC ? |
| 3372 | MIPI_DSI_RX_GENERIC_SHORT_READ_RESPONSE_2BYTE : |
| 3373 | MIPI_DSI_RX_DCS_SHORT_READ_RESPONSE_2BYTE)) { |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 3374 | u16 data = FLD_GET(val, 23, 8); |
Archit Taneja | f1da39d | 2011-05-12 17:26:27 +0530 | [diff] [blame] | 3375 | if (dsi->debug_read) |
Archit Taneja | b3b89c0 | 2011-08-30 16:07:39 +0530 | [diff] [blame] | 3376 | DSSDBG("\t%s short response, 2 byte: %04x\n", |
| 3377 | type == DSS_DSI_CONTENT_GENERIC ? "GENERIC" : |
| 3378 | "DCS", data); |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 3379 | |
Tomi Valkeinen | 5d68e03 | 2010-02-26 11:32:56 +0200 | [diff] [blame] | 3380 | if (buflen < 2) { |
| 3381 | r = -EIO; |
| 3382 | goto err; |
| 3383 | } |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 3384 | |
| 3385 | buf[0] = data & 0xff; |
| 3386 | buf[1] = (data >> 8) & 0xff; |
| 3387 | |
| 3388 | return 2; |
Archit Taneja | b3b89c0 | 2011-08-30 16:07:39 +0530 | [diff] [blame] | 3389 | } else if (dt == (type == DSS_DSI_CONTENT_GENERIC ? |
| 3390 | MIPI_DSI_RX_GENERIC_LONG_READ_RESPONSE : |
| 3391 | MIPI_DSI_RX_DCS_LONG_READ_RESPONSE)) { |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 3392 | int w; |
| 3393 | int len = FLD_GET(val, 23, 8); |
Archit Taneja | f1da39d | 2011-05-12 17:26:27 +0530 | [diff] [blame] | 3394 | if (dsi->debug_read) |
Archit Taneja | b3b89c0 | 2011-08-30 16:07:39 +0530 | [diff] [blame] | 3395 | DSSDBG("\t%s long response, len %d\n", |
| 3396 | type == DSS_DSI_CONTENT_GENERIC ? "GENERIC" : |
| 3397 | "DCS", len); |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 3398 | |
Tomi Valkeinen | 5d68e03 | 2010-02-26 11:32:56 +0200 | [diff] [blame] | 3399 | if (len > buflen) { |
| 3400 | r = -EIO; |
| 3401 | goto err; |
| 3402 | } |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 3403 | |
| 3404 | /* two byte checksum ends the packet, not included in len */ |
| 3405 | for (w = 0; w < len + 2;) { |
| 3406 | int b; |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 3407 | val = dsi_read_reg(dsidev, |
| 3408 | DSI_VC_SHORT_PACKET_HEADER(channel)); |
Archit Taneja | f1da39d | 2011-05-12 17:26:27 +0530 | [diff] [blame] | 3409 | if (dsi->debug_read) |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 3410 | DSSDBG("\t\t%02x %02x %02x %02x\n", |
| 3411 | (val >> 0) & 0xff, |
| 3412 | (val >> 8) & 0xff, |
| 3413 | (val >> 16) & 0xff, |
| 3414 | (val >> 24) & 0xff); |
| 3415 | |
| 3416 | for (b = 0; b < 4; ++b) { |
| 3417 | if (w < len) |
| 3418 | buf[w] = (val >> (b * 8)) & 0xff; |
| 3419 | /* we discard the 2 byte checksum */ |
| 3420 | ++w; |
| 3421 | } |
| 3422 | } |
| 3423 | |
| 3424 | return len; |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 3425 | } else { |
| 3426 | DSSERR("\tunknown datatype 0x%02x\n", dt); |
Tomi Valkeinen | 5d68e03 | 2010-02-26 11:32:56 +0200 | [diff] [blame] | 3427 | r = -EIO; |
| 3428 | goto err; |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 3429 | } |
Tomi Valkeinen | 5d68e03 | 2010-02-26 11:32:56 +0200 | [diff] [blame] | 3430 | |
Tomi Valkeinen | 5d68e03 | 2010-02-26 11:32:56 +0200 | [diff] [blame] | 3431 | err: |
Archit Taneja | b3b89c0 | 2011-08-30 16:07:39 +0530 | [diff] [blame] | 3432 | DSSERR("dsi_vc_read_rx_fifo(ch %d type %s) failed\n", channel, |
| 3433 | type == DSS_DSI_CONTENT_GENERIC ? "GENERIC" : "DCS"); |
Tomi Valkeinen | 5d68e03 | 2010-02-26 11:32:56 +0200 | [diff] [blame] | 3434 | |
Archit Taneja | b850975 | 2011-08-30 15:48:23 +0530 | [diff] [blame] | 3435 | return r; |
| 3436 | } |
| 3437 | |
| 3438 | int dsi_vc_dcs_read(struct omap_dss_device *dssdev, int channel, u8 dcs_cmd, |
| 3439 | u8 *buf, int buflen) |
| 3440 | { |
| 3441 | struct platform_device *dsidev = dsi_get_dsidev_from_dssdev(dssdev); |
| 3442 | int r; |
| 3443 | |
| 3444 | r = dsi_vc_dcs_send_read_request(dssdev, channel, dcs_cmd); |
| 3445 | if (r) |
| 3446 | goto err; |
| 3447 | |
| 3448 | r = dsi_vc_send_bta_sync(dssdev, channel); |
| 3449 | if (r) |
| 3450 | goto err; |
| 3451 | |
Archit Taneja | b3b89c0 | 2011-08-30 16:07:39 +0530 | [diff] [blame] | 3452 | r = dsi_vc_read_rx_fifo(dsidev, channel, buf, buflen, |
| 3453 | DSS_DSI_CONTENT_DCS); |
Archit Taneja | b850975 | 2011-08-30 15:48:23 +0530 | [diff] [blame] | 3454 | if (r < 0) |
| 3455 | goto err; |
| 3456 | |
| 3457 | if (r != buflen) { |
| 3458 | r = -EIO; |
| 3459 | goto err; |
| 3460 | } |
| 3461 | |
| 3462 | return 0; |
| 3463 | err: |
| 3464 | DSSERR("dsi_vc_dcs_read(ch %d, cmd 0x%02x) failed\n", channel, dcs_cmd); |
| 3465 | return r; |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 3466 | } |
| 3467 | EXPORT_SYMBOL(dsi_vc_dcs_read); |
| 3468 | |
Archit Taneja | b3b89c0 | 2011-08-30 16:07:39 +0530 | [diff] [blame] | 3469 | static int dsi_vc_generic_read(struct omap_dss_device *dssdev, int channel, |
| 3470 | u8 *reqdata, int reqlen, u8 *buf, int buflen) |
| 3471 | { |
| 3472 | struct platform_device *dsidev = dsi_get_dsidev_from_dssdev(dssdev); |
| 3473 | int r; |
| 3474 | |
| 3475 | r = dsi_vc_generic_send_read_request(dssdev, channel, reqdata, reqlen); |
| 3476 | if (r) |
| 3477 | return r; |
| 3478 | |
| 3479 | r = dsi_vc_send_bta_sync(dssdev, channel); |
| 3480 | if (r) |
| 3481 | return r; |
| 3482 | |
| 3483 | r = dsi_vc_read_rx_fifo(dsidev, channel, buf, buflen, |
| 3484 | DSS_DSI_CONTENT_GENERIC); |
| 3485 | if (r < 0) |
| 3486 | return r; |
| 3487 | |
| 3488 | if (r != buflen) { |
| 3489 | r = -EIO; |
| 3490 | return r; |
| 3491 | } |
| 3492 | |
| 3493 | return 0; |
| 3494 | } |
| 3495 | |
| 3496 | int dsi_vc_generic_read_0(struct omap_dss_device *dssdev, int channel, u8 *buf, |
| 3497 | int buflen) |
| 3498 | { |
| 3499 | int r; |
| 3500 | |
| 3501 | r = dsi_vc_generic_read(dssdev, channel, NULL, 0, buf, buflen); |
| 3502 | if (r) { |
| 3503 | DSSERR("dsi_vc_generic_read_0(ch %d) failed\n", channel); |
| 3504 | return r; |
| 3505 | } |
| 3506 | |
| 3507 | return 0; |
| 3508 | } |
| 3509 | EXPORT_SYMBOL(dsi_vc_generic_read_0); |
| 3510 | |
| 3511 | int dsi_vc_generic_read_1(struct omap_dss_device *dssdev, int channel, u8 param, |
| 3512 | u8 *buf, int buflen) |
| 3513 | { |
| 3514 | int r; |
| 3515 | |
| 3516 | r = dsi_vc_generic_read(dssdev, channel, ¶m, 1, buf, buflen); |
| 3517 | if (r) { |
| 3518 | DSSERR("dsi_vc_generic_read_1(ch %d) failed\n", channel); |
| 3519 | return r; |
| 3520 | } |
| 3521 | |
| 3522 | return 0; |
| 3523 | } |
| 3524 | EXPORT_SYMBOL(dsi_vc_generic_read_1); |
| 3525 | |
| 3526 | int dsi_vc_generic_read_2(struct omap_dss_device *dssdev, int channel, |
| 3527 | u8 param1, u8 param2, u8 *buf, int buflen) |
| 3528 | { |
| 3529 | int r; |
| 3530 | u8 reqdata[2]; |
| 3531 | |
| 3532 | reqdata[0] = param1; |
| 3533 | reqdata[1] = param2; |
| 3534 | |
| 3535 | r = dsi_vc_generic_read(dssdev, channel, reqdata, 2, buf, buflen); |
| 3536 | if (r) { |
| 3537 | DSSERR("dsi_vc_generic_read_2(ch %d) failed\n", channel); |
| 3538 | return r; |
| 3539 | } |
| 3540 | |
| 3541 | return 0; |
| 3542 | } |
| 3543 | EXPORT_SYMBOL(dsi_vc_generic_read_2); |
| 3544 | |
Archit Taneja | 1ffefe7 | 2011-05-12 17:26:24 +0530 | [diff] [blame] | 3545 | int dsi_vc_set_max_rx_packet_size(struct omap_dss_device *dssdev, int channel, |
| 3546 | u16 len) |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 3547 | { |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 3548 | struct platform_device *dsidev = dsi_get_dsidev_from_dssdev(dssdev); |
| 3549 | |
Archit Taneja | 7a7c48f | 2011-08-25 18:25:03 +0530 | [diff] [blame] | 3550 | return dsi_vc_send_short(dsidev, channel, |
| 3551 | MIPI_DSI_SET_MAXIMUM_RETURN_PACKET_SIZE, len, 0); |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 3552 | } |
| 3553 | EXPORT_SYMBOL(dsi_vc_set_max_rx_packet_size); |
| 3554 | |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 3555 | static int dsi_enter_ulps(struct platform_device *dsidev) |
Tomi Valkeinen | 40885ab | 2010-07-28 15:53:38 +0300 | [diff] [blame] | 3556 | { |
Archit Taneja | f1da39d | 2011-05-12 17:26:27 +0530 | [diff] [blame] | 3557 | struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev); |
Tomi Valkeinen | 40885ab | 2010-07-28 15:53:38 +0300 | [diff] [blame] | 3558 | DECLARE_COMPLETION_ONSTACK(completion); |
Tomi Valkeinen | 522a0c2 | 2011-10-13 16:18:52 +0300 | [diff] [blame] | 3559 | int r, i; |
| 3560 | unsigned mask; |
Tomi Valkeinen | 40885ab | 2010-07-28 15:53:38 +0300 | [diff] [blame] | 3561 | |
| 3562 | DSSDBGF(); |
| 3563 | |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 3564 | WARN_ON(!dsi_bus_is_locked(dsidev)); |
Tomi Valkeinen | 40885ab | 2010-07-28 15:53:38 +0300 | [diff] [blame] | 3565 | |
Archit Taneja | f1da39d | 2011-05-12 17:26:27 +0530 | [diff] [blame] | 3566 | WARN_ON(dsi->ulps_enabled); |
Tomi Valkeinen | 40885ab | 2010-07-28 15:53:38 +0300 | [diff] [blame] | 3567 | |
Archit Taneja | f1da39d | 2011-05-12 17:26:27 +0530 | [diff] [blame] | 3568 | if (dsi->ulps_enabled) |
Tomi Valkeinen | 40885ab | 2010-07-28 15:53:38 +0300 | [diff] [blame] | 3569 | return 0; |
| 3570 | |
Tomi Valkeinen | 6cc78aa | 2011-10-13 19:22:43 +0300 | [diff] [blame] | 3571 | /* DDR_CLK_ALWAYS_ON */ |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 3572 | if (REG_GET(dsidev, DSI_CLK_CTRL, 13, 13)) { |
Tomi Valkeinen | 6cc78aa | 2011-10-13 19:22:43 +0300 | [diff] [blame] | 3573 | dsi_if_enable(dsidev, 0); |
| 3574 | REG_FLD_MOD(dsidev, DSI_CLK_CTRL, 0, 13, 13); |
| 3575 | dsi_if_enable(dsidev, 1); |
Tomi Valkeinen | 40885ab | 2010-07-28 15:53:38 +0300 | [diff] [blame] | 3576 | } |
| 3577 | |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 3578 | dsi_sync_vc(dsidev, 0); |
| 3579 | dsi_sync_vc(dsidev, 1); |
| 3580 | dsi_sync_vc(dsidev, 2); |
| 3581 | dsi_sync_vc(dsidev, 3); |
Tomi Valkeinen | 40885ab | 2010-07-28 15:53:38 +0300 | [diff] [blame] | 3582 | |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 3583 | dsi_force_tx_stop_mode_io(dsidev); |
Tomi Valkeinen | 40885ab | 2010-07-28 15:53:38 +0300 | [diff] [blame] | 3584 | |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 3585 | dsi_vc_enable(dsidev, 0, false); |
| 3586 | dsi_vc_enable(dsidev, 1, false); |
| 3587 | dsi_vc_enable(dsidev, 2, false); |
| 3588 | dsi_vc_enable(dsidev, 3, false); |
Tomi Valkeinen | 40885ab | 2010-07-28 15:53:38 +0300 | [diff] [blame] | 3589 | |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 3590 | if (REG_GET(dsidev, DSI_COMPLEXIO_CFG2, 16, 16)) { /* HS_BUSY */ |
Tomi Valkeinen | 40885ab | 2010-07-28 15:53:38 +0300 | [diff] [blame] | 3591 | DSSERR("HS busy when enabling ULPS\n"); |
| 3592 | return -EIO; |
| 3593 | } |
| 3594 | |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 3595 | if (REG_GET(dsidev, DSI_COMPLEXIO_CFG2, 17, 17)) { /* LP_BUSY */ |
Tomi Valkeinen | 40885ab | 2010-07-28 15:53:38 +0300 | [diff] [blame] | 3596 | DSSERR("LP busy when enabling ULPS\n"); |
| 3597 | return -EIO; |
| 3598 | } |
| 3599 | |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 3600 | r = dsi_register_isr_cio(dsidev, dsi_completion_handler, &completion, |
Tomi Valkeinen | 40885ab | 2010-07-28 15:53:38 +0300 | [diff] [blame] | 3601 | DSI_CIO_IRQ_ULPSACTIVENOT_ALL0); |
| 3602 | if (r) |
| 3603 | return r; |
| 3604 | |
Tomi Valkeinen | 522a0c2 | 2011-10-13 16:18:52 +0300 | [diff] [blame] | 3605 | mask = 0; |
| 3606 | |
| 3607 | for (i = 0; i < dsi->num_lanes_supported; ++i) { |
| 3608 | if (dsi->lanes[i].function == DSI_LANE_UNUSED) |
| 3609 | continue; |
| 3610 | mask |= 1 << i; |
| 3611 | } |
Tomi Valkeinen | 40885ab | 2010-07-28 15:53:38 +0300 | [diff] [blame] | 3612 | /* Assert TxRequestEsc for data lanes and TxUlpsClk for clk lane */ |
| 3613 | /* LANEx_ULPS_SIG2 */ |
Tomi Valkeinen | 522a0c2 | 2011-10-13 16:18:52 +0300 | [diff] [blame] | 3614 | REG_FLD_MOD(dsidev, DSI_COMPLEXIO_CFG2, mask, 9, 5); |
Tomi Valkeinen | 40885ab | 2010-07-28 15:53:38 +0300 | [diff] [blame] | 3615 | |
Tomi Valkeinen | a702c85 | 2011-10-12 10:10:21 +0300 | [diff] [blame] | 3616 | /* flush posted write and wait for SCP interface to finish the write */ |
| 3617 | dsi_read_reg(dsidev, DSI_COMPLEXIO_CFG2); |
Tomi Valkeinen | 40885ab | 2010-07-28 15:53:38 +0300 | [diff] [blame] | 3618 | |
| 3619 | if (wait_for_completion_timeout(&completion, |
| 3620 | msecs_to_jiffies(1000)) == 0) { |
| 3621 | DSSERR("ULPS enable timeout\n"); |
| 3622 | r = -EIO; |
| 3623 | goto err; |
| 3624 | } |
| 3625 | |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 3626 | dsi_unregister_isr_cio(dsidev, dsi_completion_handler, &completion, |
Tomi Valkeinen | 40885ab | 2010-07-28 15:53:38 +0300 | [diff] [blame] | 3627 | DSI_CIO_IRQ_ULPSACTIVENOT_ALL0); |
| 3628 | |
Tomi Valkeinen | 8ef0e61 | 2011-05-31 16:55:47 +0300 | [diff] [blame] | 3629 | /* Reset LANEx_ULPS_SIG2 */ |
Tomi Valkeinen | 522a0c2 | 2011-10-13 16:18:52 +0300 | [diff] [blame] | 3630 | REG_FLD_MOD(dsidev, DSI_COMPLEXIO_CFG2, 0, 9, 5); |
Tomi Valkeinen | 8ef0e61 | 2011-05-31 16:55:47 +0300 | [diff] [blame] | 3631 | |
Tomi Valkeinen | a702c85 | 2011-10-12 10:10:21 +0300 | [diff] [blame] | 3632 | /* flush posted write and wait for SCP interface to finish the write */ |
| 3633 | dsi_read_reg(dsidev, DSI_COMPLEXIO_CFG2); |
Tomi Valkeinen | 40885ab | 2010-07-28 15:53:38 +0300 | [diff] [blame] | 3634 | |
Archit Taneja | f1da39d | 2011-05-12 17:26:27 +0530 | [diff] [blame] | 3635 | dsi_cio_power(dsidev, DSI_COMPLEXIO_POWER_ULPS); |
Tomi Valkeinen | 40885ab | 2010-07-28 15:53:38 +0300 | [diff] [blame] | 3636 | |
| 3637 | dsi_if_enable(dsidev, false); |
| 3638 | |
| 3639 | dsi->ulps_enabled = true; |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 3640 | |
Tomi Valkeinen | 40885ab | 2010-07-28 15:53:38 +0300 | [diff] [blame] | 3641 | return 0; |
| 3642 | |
| 3643 | err: |
| 3644 | dsi_unregister_isr_cio(dsidev, dsi_completion_handler, &completion, |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 3645 | DSI_CIO_IRQ_ULPSACTIVENOT_ALL0); |
| 3646 | return r; |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 3647 | } |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 3648 | |
Tomi Valkeinen | 4ffa357 | 2010-04-12 10:40:12 +0300 | [diff] [blame] | 3649 | static void dsi_set_lp_rx_timeout(struct platform_device *dsidev, |
| 3650 | unsigned ticks, bool x4, bool x16) |
| 3651 | { |
| 3652 | unsigned long fck; |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 3653 | unsigned long total_ticks; |
| 3654 | u32 r; |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 3655 | |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 3656 | BUG_ON(ticks > 0x1fff); |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 3657 | |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 3658 | /* ticks in DSI_FCK */ |
Tomi Valkeinen | 4ffa357 | 2010-04-12 10:40:12 +0300 | [diff] [blame] | 3659 | fck = dsi_fclk_rate(dsidev); |
| 3660 | |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 3661 | r = dsi_read_reg(dsidev, DSI_TIMING2); |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 3662 | r = FLD_MOD(r, 1, 15, 15); /* LP_RX_TO */ |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 3663 | r = FLD_MOD(r, x16 ? 1 : 0, 14, 14); /* LP_RX_TO_X16 */ |
Tomi Valkeinen | 4ffa357 | 2010-04-12 10:40:12 +0300 | [diff] [blame] | 3664 | r = FLD_MOD(r, x4 ? 1 : 0, 13, 13); /* LP_RX_TO_X4 */ |
| 3665 | r = FLD_MOD(r, ticks, 12, 0); /* LP_RX_COUNTER */ |
| 3666 | dsi_write_reg(dsidev, DSI_TIMING2, r); |
| 3667 | |
| 3668 | total_ticks = ticks * (x16 ? 16 : 1) * (x4 ? 4 : 1); |
| 3669 | |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 3670 | DSSDBG("LP_RX_TO %lu ticks (%#x%s%s) = %lu ns\n", |
| 3671 | total_ticks, |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 3672 | ticks, x4 ? " x4" : "", x16 ? " x16" : "", |
| 3673 | (total_ticks * 1000) / (fck / 1000 / 1000)); |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 3674 | } |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 3675 | |
Tomi Valkeinen | 4ffa357 | 2010-04-12 10:40:12 +0300 | [diff] [blame] | 3676 | static void dsi_set_ta_timeout(struct platform_device *dsidev, unsigned ticks, |
| 3677 | bool x8, bool x16) |
| 3678 | { |
| 3679 | unsigned long fck; |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 3680 | unsigned long total_ticks; |
| 3681 | u32 r; |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 3682 | |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 3683 | BUG_ON(ticks > 0x1fff); |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 3684 | |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 3685 | /* ticks in DSI_FCK */ |
Tomi Valkeinen | 4ffa357 | 2010-04-12 10:40:12 +0300 | [diff] [blame] | 3686 | fck = dsi_fclk_rate(dsidev); |
| 3687 | |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 3688 | r = dsi_read_reg(dsidev, DSI_TIMING1); |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 3689 | r = FLD_MOD(r, 1, 31, 31); /* TA_TO */ |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 3690 | r = FLD_MOD(r, x16 ? 1 : 0, 30, 30); /* TA_TO_X16 */ |
Tomi Valkeinen | 4ffa357 | 2010-04-12 10:40:12 +0300 | [diff] [blame] | 3691 | r = FLD_MOD(r, x8 ? 1 : 0, 29, 29); /* TA_TO_X8 */ |
| 3692 | r = FLD_MOD(r, ticks, 28, 16); /* TA_TO_COUNTER */ |
| 3693 | dsi_write_reg(dsidev, DSI_TIMING1, r); |
| 3694 | |
| 3695 | total_ticks = ticks * (x16 ? 16 : 1) * (x8 ? 8 : 1); |
| 3696 | |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 3697 | DSSDBG("TA_TO %lu ticks (%#x%s%s) = %lu ns\n", |
| 3698 | total_ticks, |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 3699 | ticks, x8 ? " x8" : "", x16 ? " x16" : "", |
| 3700 | (total_ticks * 1000) / (fck / 1000 / 1000)); |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 3701 | } |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 3702 | |
Tomi Valkeinen | 4ffa357 | 2010-04-12 10:40:12 +0300 | [diff] [blame] | 3703 | static void dsi_set_stop_state_counter(struct platform_device *dsidev, |
| 3704 | unsigned ticks, bool x4, bool x16) |
| 3705 | { |
| 3706 | unsigned long fck; |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 3707 | unsigned long total_ticks; |
| 3708 | u32 r; |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 3709 | |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 3710 | BUG_ON(ticks > 0x1fff); |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 3711 | |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 3712 | /* ticks in DSI_FCK */ |
Tomi Valkeinen | 4ffa357 | 2010-04-12 10:40:12 +0300 | [diff] [blame] | 3713 | fck = dsi_fclk_rate(dsidev); |
| 3714 | |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 3715 | r = dsi_read_reg(dsidev, DSI_TIMING1); |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 3716 | r = FLD_MOD(r, 1, 15, 15); /* FORCE_TX_STOP_MODE_IO */ |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 3717 | r = FLD_MOD(r, x16 ? 1 : 0, 14, 14); /* STOP_STATE_X16_IO */ |
Tomi Valkeinen | 4ffa357 | 2010-04-12 10:40:12 +0300 | [diff] [blame] | 3718 | r = FLD_MOD(r, x4 ? 1 : 0, 13, 13); /* STOP_STATE_X4_IO */ |
| 3719 | r = FLD_MOD(r, ticks, 12, 0); /* STOP_STATE_COUNTER_IO */ |
| 3720 | dsi_write_reg(dsidev, DSI_TIMING1, r); |
| 3721 | |
| 3722 | total_ticks = ticks * (x16 ? 16 : 1) * (x4 ? 4 : 1); |
| 3723 | |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 3724 | DSSDBG("STOP_STATE_COUNTER %lu ticks (%#x%s%s) = %lu ns\n", |
| 3725 | total_ticks, |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 3726 | ticks, x4 ? " x4" : "", x16 ? " x16" : "", |
| 3727 | (total_ticks * 1000) / (fck / 1000 / 1000)); |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 3728 | } |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 3729 | |
Tomi Valkeinen | 4ffa357 | 2010-04-12 10:40:12 +0300 | [diff] [blame] | 3730 | static void dsi_set_hs_tx_timeout(struct platform_device *dsidev, |
| 3731 | unsigned ticks, bool x4, bool x16) |
| 3732 | { |
| 3733 | unsigned long fck; |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 3734 | unsigned long total_ticks; |
| 3735 | u32 r; |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 3736 | |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 3737 | BUG_ON(ticks > 0x1fff); |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 3738 | |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 3739 | /* ticks in TxByteClkHS */ |
Tomi Valkeinen | 4ffa357 | 2010-04-12 10:40:12 +0300 | [diff] [blame] | 3740 | fck = dsi_get_txbyteclkhs(dsidev); |
| 3741 | |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 3742 | r = dsi_read_reg(dsidev, DSI_TIMING2); |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 3743 | r = FLD_MOD(r, 1, 31, 31); /* HS_TX_TO */ |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 3744 | r = FLD_MOD(r, x16 ? 1 : 0, 30, 30); /* HS_TX_TO_X16 */ |
Tomi Valkeinen | 4ffa357 | 2010-04-12 10:40:12 +0300 | [diff] [blame] | 3745 | r = FLD_MOD(r, x4 ? 1 : 0, 29, 29); /* HS_TX_TO_X8 (4 really) */ |
| 3746 | r = FLD_MOD(r, ticks, 28, 16); /* HS_TX_TO_COUNTER */ |
| 3747 | dsi_write_reg(dsidev, DSI_TIMING2, r); |
| 3748 | |
| 3749 | total_ticks = ticks * (x16 ? 16 : 1) * (x4 ? 4 : 1); |
| 3750 | |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 3751 | DSSDBG("HS_TX_TO %lu ticks (%#x%s%s) = %lu ns\n", |
| 3752 | total_ticks, |
| 3753 | ticks, x4 ? " x4" : "", x16 ? " x16" : "", |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 3754 | (total_ticks * 1000) / (fck / 1000 / 1000)); |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 3755 | } |
Archit Taneja | 8af6ff0 | 2011-09-05 16:48:27 +0530 | [diff] [blame] | 3756 | |
| 3757 | static void dsi_config_vp_num_line_buffers(struct omap_dss_device *dssdev) |
| 3758 | { |
| 3759 | struct platform_device *dsidev = dsi_get_dsidev_from_dssdev(dssdev); |
Archit Taneja | dca2b15 | 2012-08-16 18:02:00 +0530 | [diff] [blame] | 3760 | struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev); |
Archit Taneja | 8af6ff0 | 2011-09-05 16:48:27 +0530 | [diff] [blame] | 3761 | int num_line_buffers; |
| 3762 | |
Archit Taneja | dca2b15 | 2012-08-16 18:02:00 +0530 | [diff] [blame] | 3763 | if (dsi->mode == OMAP_DSS_DSI_VIDEO_MODE) { |
Archit Taneja | e67458a | 2012-08-13 14:17:30 +0530 | [diff] [blame] | 3764 | struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev); |
Archit Taneja | 02c3960 | 2012-08-10 15:01:33 +0530 | [diff] [blame] | 3765 | int bpp = dsi_get_pixel_size(dsi->pix_fmt); |
Archit Taneja | 8af6ff0 | 2011-09-05 16:48:27 +0530 | [diff] [blame] | 3766 | unsigned line_buf_size = dsi_get_line_buf_size(dsidev); |
Archit Taneja | e67458a | 2012-08-13 14:17:30 +0530 | [diff] [blame] | 3767 | struct omap_video_timings *timings = &dsi->timings; |
Archit Taneja | 8af6ff0 | 2011-09-05 16:48:27 +0530 | [diff] [blame] | 3768 | /* |
| 3769 | * Don't use line buffers if width is greater than the video |
| 3770 | * port's line buffer size |
| 3771 | */ |
| 3772 | if (line_buf_size <= timings->x_res * bpp / 8) |
| 3773 | num_line_buffers = 0; |
| 3774 | else |
| 3775 | num_line_buffers = 2; |
| 3776 | } else { |
| 3777 | /* Use maximum number of line buffers in command mode */ |
| 3778 | num_line_buffers = 2; |
| 3779 | } |
| 3780 | |
| 3781 | /* LINE_BUFFER */ |
| 3782 | REG_FLD_MOD(dsidev, DSI_CTRL, num_line_buffers, 13, 12); |
| 3783 | } |
| 3784 | |
| 3785 | static void dsi_config_vp_sync_events(struct omap_dss_device *dssdev) |
| 3786 | { |
| 3787 | struct platform_device *dsidev = dsi_get_dsidev_from_dssdev(dssdev); |
Archit Taneja | 0b3ffe3 | 2012-08-13 22:13:39 +0530 | [diff] [blame] | 3788 | struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev); |
| 3789 | bool vsync_end = dsi->vm_timings.vp_vsync_end; |
| 3790 | bool hsync_end = dsi->vm_timings.vp_hsync_end; |
Archit Taneja | 8af6ff0 | 2011-09-05 16:48:27 +0530 | [diff] [blame] | 3791 | u32 r; |
| 3792 | |
| 3793 | r = dsi_read_reg(dsidev, DSI_CTRL); |
Archit Taneja | bd5a7b1 | 2012-06-26 12:38:31 +0530 | [diff] [blame] | 3794 | r = FLD_MOD(r, 1, 9, 9); /* VP_DE_POL */ |
| 3795 | r = FLD_MOD(r, 1, 10, 10); /* VP_HSYNC_POL */ |
| 3796 | r = FLD_MOD(r, 1, 11, 11); /* VP_VSYNC_POL */ |
Archit Taneja | 8af6ff0 | 2011-09-05 16:48:27 +0530 | [diff] [blame] | 3797 | r = FLD_MOD(r, 1, 15, 15); /* VP_VSYNC_START */ |
| 3798 | r = FLD_MOD(r, vsync_end, 16, 16); /* VP_VSYNC_END */ |
| 3799 | r = FLD_MOD(r, 1, 17, 17); /* VP_HSYNC_START */ |
| 3800 | r = FLD_MOD(r, hsync_end, 18, 18); /* VP_HSYNC_END */ |
| 3801 | dsi_write_reg(dsidev, DSI_CTRL, r); |
| 3802 | } |
| 3803 | |
| 3804 | static void dsi_config_blanking_modes(struct omap_dss_device *dssdev) |
| 3805 | { |
| 3806 | struct platform_device *dsidev = dsi_get_dsidev_from_dssdev(dssdev); |
Archit Taneja | 0b3ffe3 | 2012-08-13 22:13:39 +0530 | [diff] [blame] | 3807 | struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev); |
| 3808 | int blanking_mode = dsi->vm_timings.blanking_mode; |
| 3809 | int hfp_blanking_mode = dsi->vm_timings.hfp_blanking_mode; |
| 3810 | int hbp_blanking_mode = dsi->vm_timings.hbp_blanking_mode; |
| 3811 | int hsa_blanking_mode = dsi->vm_timings.hsa_blanking_mode; |
Archit Taneja | 8af6ff0 | 2011-09-05 16:48:27 +0530 | [diff] [blame] | 3812 | u32 r; |
| 3813 | |
| 3814 | /* |
| 3815 | * 0 = TX FIFO packets sent or LPS in corresponding blanking periods |
| 3816 | * 1 = Long blanking packets are sent in corresponding blanking periods |
| 3817 | */ |
| 3818 | r = dsi_read_reg(dsidev, DSI_CTRL); |
| 3819 | r = FLD_MOD(r, blanking_mode, 20, 20); /* BLANKING_MODE */ |
| 3820 | r = FLD_MOD(r, hfp_blanking_mode, 21, 21); /* HFP_BLANKING */ |
| 3821 | r = FLD_MOD(r, hbp_blanking_mode, 22, 22); /* HBP_BLANKING */ |
| 3822 | r = FLD_MOD(r, hsa_blanking_mode, 23, 23); /* HSA_BLANKING */ |
| 3823 | dsi_write_reg(dsidev, DSI_CTRL, r); |
| 3824 | } |
| 3825 | |
Archit Taneja | 6f28c29 | 2012-05-15 11:32:18 +0530 | [diff] [blame] | 3826 | /* |
| 3827 | * According to section 'HS Command Mode Interleaving' in OMAP TRM, Scenario 3 |
| 3828 | * results in maximum transition time for data and clock lanes to enter and |
| 3829 | * exit HS mode. Hence, this is the scenario where the least amount of command |
| 3830 | * mode data can be interleaved. We program the minimum amount of TXBYTECLKHS |
| 3831 | * clock cycles that can be used to interleave command mode data in HS so that |
| 3832 | * all scenarios are satisfied. |
| 3833 | */ |
| 3834 | static int dsi_compute_interleave_hs(int blank, bool ddr_alwon, int enter_hs, |
| 3835 | int exit_hs, int exiths_clk, int ddr_pre, int ddr_post) |
| 3836 | { |
| 3837 | int transition; |
| 3838 | |
| 3839 | /* |
| 3840 | * If DDR_CLK_ALWAYS_ON is set, we need to consider HS mode transition |
| 3841 | * time of data lanes only, if it isn't set, we need to consider HS |
| 3842 | * transition time of both data and clock lanes. HS transition time |
| 3843 | * of Scenario 3 is considered. |
| 3844 | */ |
| 3845 | if (ddr_alwon) { |
| 3846 | transition = enter_hs + exit_hs + max(enter_hs, 2) + 1; |
| 3847 | } else { |
| 3848 | int trans1, trans2; |
| 3849 | trans1 = ddr_pre + enter_hs + exit_hs + max(enter_hs, 2) + 1; |
| 3850 | trans2 = ddr_pre + enter_hs + exiths_clk + ddr_post + ddr_pre + |
| 3851 | enter_hs + 1; |
| 3852 | transition = max(trans1, trans2); |
| 3853 | } |
| 3854 | |
| 3855 | return blank > transition ? blank - transition : 0; |
| 3856 | } |
| 3857 | |
| 3858 | /* |
| 3859 | * According to section 'LP Command Mode Interleaving' in OMAP TRM, Scenario 1 |
| 3860 | * results in maximum transition time for data lanes to enter and exit LP mode. |
| 3861 | * Hence, this is the scenario where the least amount of command mode data can |
| 3862 | * be interleaved. We program the minimum amount of bytes that can be |
| 3863 | * interleaved in LP so that all scenarios are satisfied. |
| 3864 | */ |
| 3865 | static int dsi_compute_interleave_lp(int blank, int enter_hs, int exit_hs, |
| 3866 | int lp_clk_div, int tdsi_fclk) |
| 3867 | { |
| 3868 | int trans_lp; /* time required for a LP transition, in TXBYTECLKHS */ |
| 3869 | int tlp_avail; /* time left for interleaving commands, in CLKIN4DDR */ |
| 3870 | int ttxclkesc; /* period of LP transmit escape clock, in CLKIN4DDR */ |
| 3871 | int thsbyte_clk = 16; /* Period of TXBYTECLKHS clock, in CLKIN4DDR */ |
| 3872 | int lp_inter; /* cmd mode data that can be interleaved, in bytes */ |
| 3873 | |
| 3874 | /* maximum LP transition time according to Scenario 1 */ |
| 3875 | trans_lp = exit_hs + max(enter_hs, 2) + 1; |
| 3876 | |
| 3877 | /* CLKIN4DDR = 16 * TXBYTECLKHS */ |
| 3878 | tlp_avail = thsbyte_clk * (blank - trans_lp); |
| 3879 | |
Archit Taneja | 2e063c3 | 2012-06-04 13:36:34 +0530 | [diff] [blame] | 3880 | ttxclkesc = tdsi_fclk * lp_clk_div; |
Archit Taneja | 6f28c29 | 2012-05-15 11:32:18 +0530 | [diff] [blame] | 3881 | |
| 3882 | lp_inter = ((tlp_avail - 8 * thsbyte_clk - 5 * tdsi_fclk) / ttxclkesc - |
| 3883 | 26) / 16; |
| 3884 | |
| 3885 | return max(lp_inter, 0); |
| 3886 | } |
| 3887 | |
| 3888 | static void dsi_config_cmd_mode_interleaving(struct omap_dss_device *dssdev) |
| 3889 | { |
| 3890 | struct platform_device *dsidev = dsi_get_dsidev_from_dssdev(dssdev); |
| 3891 | struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev); |
| 3892 | int blanking_mode; |
| 3893 | int hfp_blanking_mode, hbp_blanking_mode, hsa_blanking_mode; |
| 3894 | int hsa, hfp, hbp, width_bytes, bllp, lp_clk_div; |
| 3895 | int ddr_clk_pre, ddr_clk_post, enter_hs_mode_lat, exit_hs_mode_lat; |
| 3896 | int tclk_trail, ths_exit, exiths_clk; |
| 3897 | bool ddr_alwon; |
Archit Taneja | e67458a | 2012-08-13 14:17:30 +0530 | [diff] [blame] | 3898 | struct omap_video_timings *timings = &dsi->timings; |
Archit Taneja | 02c3960 | 2012-08-10 15:01:33 +0530 | [diff] [blame] | 3899 | int bpp = dsi_get_pixel_size(dsi->pix_fmt); |
Archit Taneja | 6f28c29 | 2012-05-15 11:32:18 +0530 | [diff] [blame] | 3900 | int ndl = dsi->num_lanes_used - 1; |
| 3901 | int dsi_fclk_hsdiv = dssdev->clocks.dsi.regm_dsi + 1; |
| 3902 | int hsa_interleave_hs = 0, hsa_interleave_lp = 0; |
| 3903 | int hfp_interleave_hs = 0, hfp_interleave_lp = 0; |
| 3904 | int hbp_interleave_hs = 0, hbp_interleave_lp = 0; |
| 3905 | int bl_interleave_hs = 0, bl_interleave_lp = 0; |
| 3906 | u32 r; |
| 3907 | |
| 3908 | r = dsi_read_reg(dsidev, DSI_CTRL); |
| 3909 | blanking_mode = FLD_GET(r, 20, 20); |
| 3910 | hfp_blanking_mode = FLD_GET(r, 21, 21); |
| 3911 | hbp_blanking_mode = FLD_GET(r, 22, 22); |
| 3912 | hsa_blanking_mode = FLD_GET(r, 23, 23); |
| 3913 | |
| 3914 | r = dsi_read_reg(dsidev, DSI_VM_TIMING1); |
| 3915 | hbp = FLD_GET(r, 11, 0); |
| 3916 | hfp = FLD_GET(r, 23, 12); |
| 3917 | hsa = FLD_GET(r, 31, 24); |
| 3918 | |
| 3919 | r = dsi_read_reg(dsidev, DSI_CLK_TIMING); |
| 3920 | ddr_clk_post = FLD_GET(r, 7, 0); |
| 3921 | ddr_clk_pre = FLD_GET(r, 15, 8); |
| 3922 | |
| 3923 | r = dsi_read_reg(dsidev, DSI_VM_TIMING7); |
| 3924 | exit_hs_mode_lat = FLD_GET(r, 15, 0); |
| 3925 | enter_hs_mode_lat = FLD_GET(r, 31, 16); |
| 3926 | |
| 3927 | r = dsi_read_reg(dsidev, DSI_CLK_CTRL); |
| 3928 | lp_clk_div = FLD_GET(r, 12, 0); |
| 3929 | ddr_alwon = FLD_GET(r, 13, 13); |
| 3930 | |
| 3931 | r = dsi_read_reg(dsidev, DSI_DSIPHY_CFG0); |
| 3932 | ths_exit = FLD_GET(r, 7, 0); |
| 3933 | |
| 3934 | r = dsi_read_reg(dsidev, DSI_DSIPHY_CFG1); |
| 3935 | tclk_trail = FLD_GET(r, 15, 8); |
| 3936 | |
| 3937 | exiths_clk = ths_exit + tclk_trail; |
| 3938 | |
| 3939 | width_bytes = DIV_ROUND_UP(timings->x_res * bpp, 8); |
| 3940 | bllp = hbp + hfp + hsa + DIV_ROUND_UP(width_bytes + 6, ndl); |
| 3941 | |
| 3942 | if (!hsa_blanking_mode) { |
| 3943 | hsa_interleave_hs = dsi_compute_interleave_hs(hsa, ddr_alwon, |
| 3944 | enter_hs_mode_lat, exit_hs_mode_lat, |
| 3945 | exiths_clk, ddr_clk_pre, ddr_clk_post); |
| 3946 | hsa_interleave_lp = dsi_compute_interleave_lp(hsa, |
| 3947 | enter_hs_mode_lat, exit_hs_mode_lat, |
| 3948 | lp_clk_div, dsi_fclk_hsdiv); |
| 3949 | } |
| 3950 | |
| 3951 | if (!hfp_blanking_mode) { |
| 3952 | hfp_interleave_hs = dsi_compute_interleave_hs(hfp, ddr_alwon, |
| 3953 | enter_hs_mode_lat, exit_hs_mode_lat, |
| 3954 | exiths_clk, ddr_clk_pre, ddr_clk_post); |
| 3955 | hfp_interleave_lp = dsi_compute_interleave_lp(hfp, |
| 3956 | enter_hs_mode_lat, exit_hs_mode_lat, |
| 3957 | lp_clk_div, dsi_fclk_hsdiv); |
| 3958 | } |
| 3959 | |
| 3960 | if (!hbp_blanking_mode) { |
| 3961 | hbp_interleave_hs = dsi_compute_interleave_hs(hbp, ddr_alwon, |
| 3962 | enter_hs_mode_lat, exit_hs_mode_lat, |
| 3963 | exiths_clk, ddr_clk_pre, ddr_clk_post); |
| 3964 | |
| 3965 | hbp_interleave_lp = dsi_compute_interleave_lp(hbp, |
| 3966 | enter_hs_mode_lat, exit_hs_mode_lat, |
| 3967 | lp_clk_div, dsi_fclk_hsdiv); |
| 3968 | } |
| 3969 | |
| 3970 | if (!blanking_mode) { |
| 3971 | bl_interleave_hs = dsi_compute_interleave_hs(bllp, ddr_alwon, |
| 3972 | enter_hs_mode_lat, exit_hs_mode_lat, |
| 3973 | exiths_clk, ddr_clk_pre, ddr_clk_post); |
| 3974 | |
| 3975 | bl_interleave_lp = dsi_compute_interleave_lp(bllp, |
| 3976 | enter_hs_mode_lat, exit_hs_mode_lat, |
| 3977 | lp_clk_div, dsi_fclk_hsdiv); |
| 3978 | } |
| 3979 | |
| 3980 | DSSDBG("DSI HS interleaving(TXBYTECLKHS) HSA %d, HFP %d, HBP %d, BLLP %d\n", |
| 3981 | hsa_interleave_hs, hfp_interleave_hs, hbp_interleave_hs, |
| 3982 | bl_interleave_hs); |
| 3983 | |
| 3984 | DSSDBG("DSI LP interleaving(bytes) HSA %d, HFP %d, HBP %d, BLLP %d\n", |
| 3985 | hsa_interleave_lp, hfp_interleave_lp, hbp_interleave_lp, |
| 3986 | bl_interleave_lp); |
| 3987 | |
| 3988 | r = dsi_read_reg(dsidev, DSI_VM_TIMING4); |
| 3989 | r = FLD_MOD(r, hsa_interleave_hs, 23, 16); |
| 3990 | r = FLD_MOD(r, hfp_interleave_hs, 15, 8); |
| 3991 | r = FLD_MOD(r, hbp_interleave_hs, 7, 0); |
| 3992 | dsi_write_reg(dsidev, DSI_VM_TIMING4, r); |
| 3993 | |
| 3994 | r = dsi_read_reg(dsidev, DSI_VM_TIMING5); |
| 3995 | r = FLD_MOD(r, hsa_interleave_lp, 23, 16); |
| 3996 | r = FLD_MOD(r, hfp_interleave_lp, 15, 8); |
| 3997 | r = FLD_MOD(r, hbp_interleave_lp, 7, 0); |
| 3998 | dsi_write_reg(dsidev, DSI_VM_TIMING5, r); |
| 3999 | |
| 4000 | r = dsi_read_reg(dsidev, DSI_VM_TIMING6); |
| 4001 | r = FLD_MOD(r, bl_interleave_hs, 31, 15); |
| 4002 | r = FLD_MOD(r, bl_interleave_lp, 16, 0); |
| 4003 | dsi_write_reg(dsidev, DSI_VM_TIMING6, r); |
| 4004 | } |
| 4005 | |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 4006 | static int dsi_proto_config(struct omap_dss_device *dssdev) |
| 4007 | { |
| 4008 | struct platform_device *dsidev = dsi_get_dsidev_from_dssdev(dssdev); |
Archit Taneja | 02c3960 | 2012-08-10 15:01:33 +0530 | [diff] [blame] | 4009 | struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev); |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 4010 | u32 r; |
| 4011 | int buswidth = 0; |
| 4012 | |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 4013 | dsi_config_tx_fifo(dsidev, DSI_FIFO_SIZE_32, |
Tomi Valkeinen | dd8079d | 2009-12-16 16:49:03 +0200 | [diff] [blame] | 4014 | DSI_FIFO_SIZE_32, |
| 4015 | DSI_FIFO_SIZE_32, |
| 4016 | DSI_FIFO_SIZE_32); |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 4017 | |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 4018 | dsi_config_rx_fifo(dsidev, DSI_FIFO_SIZE_32, |
Tomi Valkeinen | dd8079d | 2009-12-16 16:49:03 +0200 | [diff] [blame] | 4019 | DSI_FIFO_SIZE_32, |
| 4020 | DSI_FIFO_SIZE_32, |
| 4021 | DSI_FIFO_SIZE_32); |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 4022 | |
| 4023 | /* XXX what values for the timeouts? */ |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 4024 | dsi_set_stop_state_counter(dsidev, 0x1000, false, false); |
| 4025 | dsi_set_ta_timeout(dsidev, 0x1fff, true, true); |
| 4026 | dsi_set_lp_rx_timeout(dsidev, 0x1fff, true, true); |
| 4027 | dsi_set_hs_tx_timeout(dsidev, 0x1fff, true, true); |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 4028 | |
Archit Taneja | 02c3960 | 2012-08-10 15:01:33 +0530 | [diff] [blame] | 4029 | switch (dsi_get_pixel_size(dsi->pix_fmt)) { |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 4030 | case 16: |
| 4031 | buswidth = 0; |
| 4032 | break; |
| 4033 | case 18: |
| 4034 | buswidth = 1; |
| 4035 | break; |
| 4036 | case 24: |
| 4037 | buswidth = 2; |
| 4038 | break; |
| 4039 | default: |
| 4040 | BUG(); |
Tomi Valkeinen | c6eee96 | 2012-05-18 11:47:02 +0300 | [diff] [blame] | 4041 | return -EINVAL; |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 4042 | } |
| 4043 | |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 4044 | r = dsi_read_reg(dsidev, DSI_CTRL); |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 4045 | r = FLD_MOD(r, 1, 1, 1); /* CS_RX_EN */ |
| 4046 | r = FLD_MOD(r, 1, 2, 2); /* ECC_RX_EN */ |
| 4047 | r = FLD_MOD(r, 1, 3, 3); /* TX_FIFO_ARBITRATION */ |
| 4048 | r = FLD_MOD(r, 1, 4, 4); /* VP_CLK_RATIO, always 1, see errata*/ |
| 4049 | r = FLD_MOD(r, buswidth, 7, 6); /* VP_DATA_BUS_WIDTH */ |
| 4050 | r = FLD_MOD(r, 0, 8, 8); /* VP_CLK_POL */ |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 4051 | r = FLD_MOD(r, 1, 14, 14); /* TRIGGER_RESET_MODE */ |
| 4052 | r = FLD_MOD(r, 1, 19, 19); /* EOT_ENABLE */ |
Archit Taneja | 9613c02 | 2011-03-22 06:33:36 -0500 | [diff] [blame] | 4053 | if (!dss_has_feature(FEAT_DSI_DCS_CMD_CONFIG_VC)) { |
| 4054 | r = FLD_MOD(r, 1, 24, 24); /* DCS_CMD_ENABLE */ |
| 4055 | /* DCS_CMD_CODE, 1=start, 0=continue */ |
| 4056 | r = FLD_MOD(r, 0, 25, 25); |
| 4057 | } |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 4058 | |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 4059 | dsi_write_reg(dsidev, DSI_CTRL, r); |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 4060 | |
Archit Taneja | 8af6ff0 | 2011-09-05 16:48:27 +0530 | [diff] [blame] | 4061 | dsi_config_vp_num_line_buffers(dssdev); |
| 4062 | |
Archit Taneja | dca2b15 | 2012-08-16 18:02:00 +0530 | [diff] [blame] | 4063 | if (dsi->mode == OMAP_DSS_DSI_VIDEO_MODE) { |
Archit Taneja | 8af6ff0 | 2011-09-05 16:48:27 +0530 | [diff] [blame] | 4064 | dsi_config_vp_sync_events(dssdev); |
| 4065 | dsi_config_blanking_modes(dssdev); |
Archit Taneja | 6f28c29 | 2012-05-15 11:32:18 +0530 | [diff] [blame] | 4066 | dsi_config_cmd_mode_interleaving(dssdev); |
Archit Taneja | 8af6ff0 | 2011-09-05 16:48:27 +0530 | [diff] [blame] | 4067 | } |
| 4068 | |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 4069 | dsi_vc_initial_config(dsidev, 0); |
| 4070 | dsi_vc_initial_config(dsidev, 1); |
| 4071 | dsi_vc_initial_config(dsidev, 2); |
| 4072 | dsi_vc_initial_config(dsidev, 3); |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 4073 | |
| 4074 | return 0; |
| 4075 | } |
| 4076 | |
| 4077 | static void dsi_proto_timings(struct omap_dss_device *dssdev) |
| 4078 | { |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 4079 | struct platform_device *dsidev = dsi_get_dsidev_from_dssdev(dssdev); |
Tomi Valkeinen | db18644 | 2011-10-13 16:12:29 +0300 | [diff] [blame] | 4080 | struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev); |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 4081 | unsigned tlpx, tclk_zero, tclk_prepare, tclk_trail; |
| 4082 | unsigned tclk_pre, tclk_post; |
| 4083 | unsigned ths_prepare, ths_prepare_ths_zero, ths_zero; |
| 4084 | unsigned ths_trail, ths_exit; |
| 4085 | unsigned ddr_clk_pre, ddr_clk_post; |
| 4086 | unsigned enter_hs_mode_lat, exit_hs_mode_lat; |
| 4087 | unsigned ths_eot; |
Tomi Valkeinen | db18644 | 2011-10-13 16:12:29 +0300 | [diff] [blame] | 4088 | int ndl = dsi->num_lanes_used - 1; |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 4089 | u32 r; |
| 4090 | |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 4091 | r = dsi_read_reg(dsidev, DSI_DSIPHY_CFG0); |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 4092 | ths_prepare = FLD_GET(r, 31, 24); |
| 4093 | ths_prepare_ths_zero = FLD_GET(r, 23, 16); |
| 4094 | ths_zero = ths_prepare_ths_zero - ths_prepare; |
| 4095 | ths_trail = FLD_GET(r, 15, 8); |
| 4096 | ths_exit = FLD_GET(r, 7, 0); |
| 4097 | |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 4098 | r = dsi_read_reg(dsidev, DSI_DSIPHY_CFG1); |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 4099 | tlpx = FLD_GET(r, 22, 16) * 2; |
| 4100 | tclk_trail = FLD_GET(r, 15, 8); |
| 4101 | tclk_zero = FLD_GET(r, 7, 0); |
| 4102 | |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 4103 | r = dsi_read_reg(dsidev, DSI_DSIPHY_CFG2); |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 4104 | tclk_prepare = FLD_GET(r, 7, 0); |
| 4105 | |
| 4106 | /* min 8*UI */ |
| 4107 | tclk_pre = 20; |
| 4108 | /* min 60ns + 52*UI */ |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 4109 | tclk_post = ns2ddr(dsidev, 60) + 26; |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 4110 | |
Archit Taneja | 8af6ff0 | 2011-09-05 16:48:27 +0530 | [diff] [blame] | 4111 | ths_eot = DIV_ROUND_UP(4, ndl); |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 4112 | |
| 4113 | ddr_clk_pre = DIV_ROUND_UP(tclk_pre + tlpx + tclk_zero + tclk_prepare, |
| 4114 | 4); |
| 4115 | ddr_clk_post = DIV_ROUND_UP(tclk_post + ths_trail, 4) + ths_eot; |
| 4116 | |
| 4117 | BUG_ON(ddr_clk_pre == 0 || ddr_clk_pre > 255); |
| 4118 | BUG_ON(ddr_clk_post == 0 || ddr_clk_post > 255); |
| 4119 | |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 4120 | r = dsi_read_reg(dsidev, DSI_CLK_TIMING); |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 4121 | r = FLD_MOD(r, ddr_clk_pre, 15, 8); |
| 4122 | r = FLD_MOD(r, ddr_clk_post, 7, 0); |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 4123 | dsi_write_reg(dsidev, DSI_CLK_TIMING, r); |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 4124 | |
| 4125 | DSSDBG("ddr_clk_pre %u, ddr_clk_post %u\n", |
| 4126 | ddr_clk_pre, |
| 4127 | ddr_clk_post); |
| 4128 | |
| 4129 | enter_hs_mode_lat = 1 + DIV_ROUND_UP(tlpx, 4) + |
| 4130 | DIV_ROUND_UP(ths_prepare, 4) + |
| 4131 | DIV_ROUND_UP(ths_zero + 3, 4); |
| 4132 | |
| 4133 | exit_hs_mode_lat = DIV_ROUND_UP(ths_trail + ths_exit, 4) + 1 + ths_eot; |
| 4134 | |
| 4135 | r = FLD_VAL(enter_hs_mode_lat, 31, 16) | |
| 4136 | FLD_VAL(exit_hs_mode_lat, 15, 0); |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 4137 | dsi_write_reg(dsidev, DSI_VM_TIMING7, r); |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 4138 | |
| 4139 | DSSDBG("enter_hs_mode_lat %u, exit_hs_mode_lat %u\n", |
| 4140 | enter_hs_mode_lat, exit_hs_mode_lat); |
Archit Taneja | 8af6ff0 | 2011-09-05 16:48:27 +0530 | [diff] [blame] | 4141 | |
Archit Taneja | dca2b15 | 2012-08-16 18:02:00 +0530 | [diff] [blame] | 4142 | if (dsi->mode == OMAP_DSS_DSI_VIDEO_MODE) { |
Archit Taneja | 8af6ff0 | 2011-09-05 16:48:27 +0530 | [diff] [blame] | 4143 | /* TODO: Implement a video mode check_timings function */ |
Archit Taneja | 0b3ffe3 | 2012-08-13 22:13:39 +0530 | [diff] [blame] | 4144 | int hsa = dsi->vm_timings.hsa; |
| 4145 | int hfp = dsi->vm_timings.hfp; |
| 4146 | int hbp = dsi->vm_timings.hbp; |
| 4147 | int vsa = dsi->vm_timings.vsa; |
| 4148 | int vfp = dsi->vm_timings.vfp; |
| 4149 | int vbp = dsi->vm_timings.vbp; |
| 4150 | int window_sync = dsi->vm_timings.window_sync; |
| 4151 | bool hsync_end = dsi->vm_timings.vp_hsync_end; |
Archit Taneja | e67458a | 2012-08-13 14:17:30 +0530 | [diff] [blame] | 4152 | struct omap_video_timings *timings = &dsi->timings; |
Archit Taneja | 02c3960 | 2012-08-10 15:01:33 +0530 | [diff] [blame] | 4153 | int bpp = dsi_get_pixel_size(dsi->pix_fmt); |
Archit Taneja | 8af6ff0 | 2011-09-05 16:48:27 +0530 | [diff] [blame] | 4154 | int tl, t_he, width_bytes; |
| 4155 | |
| 4156 | t_he = hsync_end ? |
| 4157 | ((hsa == 0 && ndl == 3) ? 1 : DIV_ROUND_UP(4, ndl)) : 0; |
| 4158 | |
| 4159 | width_bytes = DIV_ROUND_UP(timings->x_res * bpp, 8); |
| 4160 | |
| 4161 | /* TL = t_HS + HSA + t_HE + HFP + ceil((WC + 6) / NDL) + HBP */ |
| 4162 | tl = DIV_ROUND_UP(4, ndl) + (hsync_end ? hsa : 0) + t_he + hfp + |
| 4163 | DIV_ROUND_UP(width_bytes + 6, ndl) + hbp; |
| 4164 | |
| 4165 | DSSDBG("HBP: %d, HFP: %d, HSA: %d, TL: %d TXBYTECLKHS\n", hbp, |
| 4166 | hfp, hsync_end ? hsa : 0, tl); |
| 4167 | DSSDBG("VBP: %d, VFP: %d, VSA: %d, VACT: %d lines\n", vbp, vfp, |
| 4168 | vsa, timings->y_res); |
| 4169 | |
| 4170 | r = dsi_read_reg(dsidev, DSI_VM_TIMING1); |
| 4171 | r = FLD_MOD(r, hbp, 11, 0); /* HBP */ |
| 4172 | r = FLD_MOD(r, hfp, 23, 12); /* HFP */ |
| 4173 | r = FLD_MOD(r, hsync_end ? hsa : 0, 31, 24); /* HSA */ |
| 4174 | dsi_write_reg(dsidev, DSI_VM_TIMING1, r); |
| 4175 | |
| 4176 | r = dsi_read_reg(dsidev, DSI_VM_TIMING2); |
| 4177 | r = FLD_MOD(r, vbp, 7, 0); /* VBP */ |
| 4178 | r = FLD_MOD(r, vfp, 15, 8); /* VFP */ |
| 4179 | r = FLD_MOD(r, vsa, 23, 16); /* VSA */ |
| 4180 | r = FLD_MOD(r, window_sync, 27, 24); /* WINDOW_SYNC */ |
| 4181 | dsi_write_reg(dsidev, DSI_VM_TIMING2, r); |
| 4182 | |
| 4183 | r = dsi_read_reg(dsidev, DSI_VM_TIMING3); |
| 4184 | r = FLD_MOD(r, timings->y_res, 14, 0); /* VACT */ |
| 4185 | r = FLD_MOD(r, tl, 31, 16); /* TL */ |
| 4186 | dsi_write_reg(dsidev, DSI_VM_TIMING3, r); |
| 4187 | } |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 4188 | } |
| 4189 | |
Tomi Valkeinen | e4a9e94 | 2012-03-28 15:58:56 +0300 | [diff] [blame] | 4190 | int omapdss_dsi_configure_pins(struct omap_dss_device *dssdev, |
| 4191 | const struct omap_dsi_pin_config *pin_cfg) |
| 4192 | { |
| 4193 | struct platform_device *dsidev = dsi_get_dsidev_from_dssdev(dssdev); |
| 4194 | struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev); |
| 4195 | int num_pins; |
| 4196 | const int *pins; |
| 4197 | struct dsi_lane_config lanes[DSI_MAX_NR_LANES]; |
| 4198 | int num_lanes; |
| 4199 | int i; |
| 4200 | |
| 4201 | static const enum dsi_lane_function functions[] = { |
| 4202 | DSI_LANE_CLK, |
| 4203 | DSI_LANE_DATA1, |
| 4204 | DSI_LANE_DATA2, |
| 4205 | DSI_LANE_DATA3, |
| 4206 | DSI_LANE_DATA4, |
| 4207 | }; |
| 4208 | |
| 4209 | num_pins = pin_cfg->num_pins; |
| 4210 | pins = pin_cfg->pins; |
| 4211 | |
| 4212 | if (num_pins < 4 || num_pins > dsi->num_lanes_supported * 2 |
| 4213 | || num_pins % 2 != 0) |
| 4214 | return -EINVAL; |
| 4215 | |
| 4216 | for (i = 0; i < DSI_MAX_NR_LANES; ++i) |
| 4217 | lanes[i].function = DSI_LANE_UNUSED; |
| 4218 | |
| 4219 | num_lanes = 0; |
| 4220 | |
| 4221 | for (i = 0; i < num_pins; i += 2) { |
| 4222 | u8 lane, pol; |
| 4223 | int dx, dy; |
| 4224 | |
| 4225 | dx = pins[i]; |
| 4226 | dy = pins[i + 1]; |
| 4227 | |
| 4228 | if (dx < 0 || dx >= dsi->num_lanes_supported * 2) |
| 4229 | return -EINVAL; |
| 4230 | |
| 4231 | if (dy < 0 || dy >= dsi->num_lanes_supported * 2) |
| 4232 | return -EINVAL; |
| 4233 | |
| 4234 | if (dx & 1) { |
| 4235 | if (dy != dx - 1) |
| 4236 | return -EINVAL; |
| 4237 | pol = 1; |
| 4238 | } else { |
| 4239 | if (dy != dx + 1) |
| 4240 | return -EINVAL; |
| 4241 | pol = 0; |
| 4242 | } |
| 4243 | |
| 4244 | lane = dx / 2; |
| 4245 | |
| 4246 | lanes[lane].function = functions[i / 2]; |
| 4247 | lanes[lane].polarity = pol; |
| 4248 | num_lanes++; |
| 4249 | } |
| 4250 | |
| 4251 | memcpy(dsi->lanes, lanes, sizeof(dsi->lanes)); |
| 4252 | dsi->num_lanes_used = num_lanes; |
| 4253 | |
| 4254 | return 0; |
| 4255 | } |
| 4256 | EXPORT_SYMBOL(omapdss_dsi_configure_pins); |
| 4257 | |
Tomi Valkeinen | ee144e6 | 2012-08-10 16:50:51 +0300 | [diff] [blame] | 4258 | int omapdss_dsi_set_clocks(struct omap_dss_device *dssdev, |
| 4259 | unsigned long ddr_clk, unsigned long lp_clk) |
| 4260 | { |
| 4261 | struct platform_device *dsidev = dsi_get_dsidev_from_dssdev(dssdev); |
| 4262 | struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev); |
| 4263 | struct dsi_clock_info cinfo; |
| 4264 | struct dispc_clock_info dispc_cinfo; |
| 4265 | unsigned lp_clk_div; |
| 4266 | unsigned long dsi_fclk; |
| 4267 | int bpp = dsi_get_pixel_size(dssdev->panel.dsi_pix_fmt); |
| 4268 | unsigned long pck; |
| 4269 | int r; |
| 4270 | |
| 4271 | DSSDBGF("ddr_clk %lu, lp_clk %lu", ddr_clk, lp_clk); |
| 4272 | |
| 4273 | mutex_lock(&dsi->lock); |
| 4274 | |
Tomi Valkeinen | d66b158 | 2012-09-24 15:15:06 +0300 | [diff] [blame] | 4275 | /* Calculate PLL output clock */ |
| 4276 | r = dsi_pll_calc_ddrfreq(dsidev, ddr_clk * 4, &cinfo); |
Tomi Valkeinen | ee144e6 | 2012-08-10 16:50:51 +0300 | [diff] [blame] | 4277 | if (r) |
| 4278 | goto err; |
| 4279 | |
Tomi Valkeinen | d66b158 | 2012-09-24 15:15:06 +0300 | [diff] [blame] | 4280 | /* Calculate PLL's DSI clock */ |
| 4281 | dsi_pll_calc_dsi_fck(dsidev, &cinfo); |
| 4282 | |
| 4283 | /* Calculate PLL's DISPC clock and pck & lck divs */ |
| 4284 | pck = cinfo.clkin4ddr / 16 * (dsi->num_lanes_used - 1) * 8 / bpp; |
| 4285 | DSSDBG("finding dispc dividers for pck %lu\n", pck); |
| 4286 | r = dsi_pll_calc_dispc_fck(dsidev, pck, &cinfo, &dispc_cinfo); |
| 4287 | if (r) |
| 4288 | goto err; |
| 4289 | |
| 4290 | /* Calculate LP clock */ |
| 4291 | dsi_fclk = cinfo.dsi_pll_hsdiv_dsi_clk; |
| 4292 | lp_clk_div = DIV_ROUND_UP(dsi_fclk, lp_clk * 2); |
| 4293 | |
Tomi Valkeinen | ee144e6 | 2012-08-10 16:50:51 +0300 | [diff] [blame] | 4294 | dssdev->clocks.dsi.regn = cinfo.regn; |
| 4295 | dssdev->clocks.dsi.regm = cinfo.regm; |
| 4296 | dssdev->clocks.dsi.regm_dispc = cinfo.regm_dispc; |
| 4297 | dssdev->clocks.dsi.regm_dsi = cinfo.regm_dsi; |
| 4298 | |
Tomi Valkeinen | ee144e6 | 2012-08-10 16:50:51 +0300 | [diff] [blame] | 4299 | dssdev->clocks.dsi.lp_clk_div = lp_clk_div; |
| 4300 | |
Tomi Valkeinen | ee144e6 | 2012-08-10 16:50:51 +0300 | [diff] [blame] | 4301 | dssdev->clocks.dispc.channel.lck_div = dispc_cinfo.lck_div; |
| 4302 | dssdev->clocks.dispc.channel.pck_div = dispc_cinfo.pck_div; |
| 4303 | |
Tomi Valkeinen | ee144e6 | 2012-08-10 16:50:51 +0300 | [diff] [blame] | 4304 | dssdev->clocks.dispc.dispc_fclk_src = OMAP_DSS_CLK_SRC_FCK; |
| 4305 | |
| 4306 | dssdev->clocks.dispc.channel.lcd_clk_src = |
| 4307 | dsi->module_id == 0 ? |
| 4308 | OMAP_DSS_CLK_SRC_DSI_PLL_HSDIV_DISPC : |
| 4309 | OMAP_DSS_CLK_SRC_DSI2_PLL_HSDIV_DISPC; |
| 4310 | |
| 4311 | dssdev->clocks.dsi.dsi_fclk_src = |
| 4312 | dsi->module_id == 0 ? |
| 4313 | OMAP_DSS_CLK_SRC_DSI_PLL_HSDIV_DSI : |
| 4314 | OMAP_DSS_CLK_SRC_DSI2_PLL_HSDIV_DSI; |
| 4315 | |
| 4316 | mutex_unlock(&dsi->lock); |
| 4317 | return 0; |
| 4318 | err: |
| 4319 | mutex_unlock(&dsi->lock); |
| 4320 | return r; |
| 4321 | } |
| 4322 | EXPORT_SYMBOL(omapdss_dsi_set_clocks); |
| 4323 | |
Tomi Valkeinen | 9a147a6 | 2011-11-09 15:30:11 +0200 | [diff] [blame] | 4324 | int dsi_enable_video_output(struct omap_dss_device *dssdev, int channel) |
Archit Taneja | 8af6ff0 | 2011-09-05 16:48:27 +0530 | [diff] [blame] | 4325 | { |
| 4326 | struct platform_device *dsidev = dsi_get_dsidev_from_dssdev(dssdev); |
Archit Taneja | e67458a | 2012-08-13 14:17:30 +0530 | [diff] [blame] | 4327 | struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev); |
Archit Taneja | 02c3960 | 2012-08-10 15:01:33 +0530 | [diff] [blame] | 4328 | int bpp = dsi_get_pixel_size(dsi->pix_fmt); |
Archit Taneja | 8af6ff0 | 2011-09-05 16:48:27 +0530 | [diff] [blame] | 4329 | u8 data_type; |
| 4330 | u16 word_count; |
Tomi Valkeinen | 33ca237 | 2011-11-21 13:42:58 +0200 | [diff] [blame] | 4331 | int r; |
Archit Taneja | 8af6ff0 | 2011-09-05 16:48:27 +0530 | [diff] [blame] | 4332 | |
Archit Taneja | dca2b15 | 2012-08-16 18:02:00 +0530 | [diff] [blame] | 4333 | if (dsi->mode == OMAP_DSS_DSI_VIDEO_MODE) { |
Archit Taneja | 02c3960 | 2012-08-10 15:01:33 +0530 | [diff] [blame] | 4334 | switch (dsi->pix_fmt) { |
Tomi Valkeinen | 9a147a6 | 2011-11-09 15:30:11 +0200 | [diff] [blame] | 4335 | case OMAP_DSS_DSI_FMT_RGB888: |
| 4336 | data_type = MIPI_DSI_PACKED_PIXEL_STREAM_24; |
| 4337 | break; |
| 4338 | case OMAP_DSS_DSI_FMT_RGB666: |
| 4339 | data_type = MIPI_DSI_PIXEL_STREAM_3BYTE_18; |
| 4340 | break; |
| 4341 | case OMAP_DSS_DSI_FMT_RGB666_PACKED: |
| 4342 | data_type = MIPI_DSI_PACKED_PIXEL_STREAM_18; |
| 4343 | break; |
| 4344 | case OMAP_DSS_DSI_FMT_RGB565: |
| 4345 | data_type = MIPI_DSI_PACKED_PIXEL_STREAM_16; |
| 4346 | break; |
| 4347 | default: |
| 4348 | BUG(); |
Tomi Valkeinen | c6eee96 | 2012-05-18 11:47:02 +0300 | [diff] [blame] | 4349 | return -EINVAL; |
Tomi Valkeinen | 9a147a6 | 2011-11-09 15:30:11 +0200 | [diff] [blame] | 4350 | }; |
Archit Taneja | 8af6ff0 | 2011-09-05 16:48:27 +0530 | [diff] [blame] | 4351 | |
Tomi Valkeinen | 9a147a6 | 2011-11-09 15:30:11 +0200 | [diff] [blame] | 4352 | dsi_if_enable(dsidev, false); |
| 4353 | dsi_vc_enable(dsidev, channel, false); |
Archit Taneja | 8af6ff0 | 2011-09-05 16:48:27 +0530 | [diff] [blame] | 4354 | |
Tomi Valkeinen | 9a147a6 | 2011-11-09 15:30:11 +0200 | [diff] [blame] | 4355 | /* MODE, 1 = video mode */ |
| 4356 | REG_FLD_MOD(dsidev, DSI_VC_CTRL(channel), 1, 4, 4); |
Archit Taneja | 8af6ff0 | 2011-09-05 16:48:27 +0530 | [diff] [blame] | 4357 | |
Archit Taneja | e67458a | 2012-08-13 14:17:30 +0530 | [diff] [blame] | 4358 | word_count = DIV_ROUND_UP(dsi->timings.x_res * bpp, 8); |
Archit Taneja | 8af6ff0 | 2011-09-05 16:48:27 +0530 | [diff] [blame] | 4359 | |
Tomi Valkeinen | 9a147a6 | 2011-11-09 15:30:11 +0200 | [diff] [blame] | 4360 | dsi_vc_write_long_header(dsidev, channel, data_type, |
| 4361 | word_count, 0); |
Archit Taneja | 8af6ff0 | 2011-09-05 16:48:27 +0530 | [diff] [blame] | 4362 | |
Tomi Valkeinen | 9a147a6 | 2011-11-09 15:30:11 +0200 | [diff] [blame] | 4363 | dsi_vc_enable(dsidev, channel, true); |
| 4364 | dsi_if_enable(dsidev, true); |
| 4365 | } |
Archit Taneja | 8af6ff0 | 2011-09-05 16:48:27 +0530 | [diff] [blame] | 4366 | |
Tomi Valkeinen | 33ca237 | 2011-11-21 13:42:58 +0200 | [diff] [blame] | 4367 | r = dss_mgr_enable(dssdev->manager); |
| 4368 | if (r) { |
Archit Taneja | dca2b15 | 2012-08-16 18:02:00 +0530 | [diff] [blame] | 4369 | if (dsi->mode == OMAP_DSS_DSI_VIDEO_MODE) { |
Tomi Valkeinen | 33ca237 | 2011-11-21 13:42:58 +0200 | [diff] [blame] | 4370 | dsi_if_enable(dsidev, false); |
| 4371 | dsi_vc_enable(dsidev, channel, false); |
| 4372 | } |
| 4373 | |
| 4374 | return r; |
| 4375 | } |
Archit Taneja | 8af6ff0 | 2011-09-05 16:48:27 +0530 | [diff] [blame] | 4376 | |
| 4377 | return 0; |
| 4378 | } |
Tomi Valkeinen | 9a147a6 | 2011-11-09 15:30:11 +0200 | [diff] [blame] | 4379 | EXPORT_SYMBOL(dsi_enable_video_output); |
Archit Taneja | 8af6ff0 | 2011-09-05 16:48:27 +0530 | [diff] [blame] | 4380 | |
Tomi Valkeinen | 9a147a6 | 2011-11-09 15:30:11 +0200 | [diff] [blame] | 4381 | void dsi_disable_video_output(struct omap_dss_device *dssdev, int channel) |
Archit Taneja | 8af6ff0 | 2011-09-05 16:48:27 +0530 | [diff] [blame] | 4382 | { |
| 4383 | struct platform_device *dsidev = dsi_get_dsidev_from_dssdev(dssdev); |
Archit Taneja | dca2b15 | 2012-08-16 18:02:00 +0530 | [diff] [blame] | 4384 | struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev); |
Archit Taneja | 8af6ff0 | 2011-09-05 16:48:27 +0530 | [diff] [blame] | 4385 | |
Archit Taneja | dca2b15 | 2012-08-16 18:02:00 +0530 | [diff] [blame] | 4386 | if (dsi->mode == OMAP_DSS_DSI_VIDEO_MODE) { |
Tomi Valkeinen | 9a147a6 | 2011-11-09 15:30:11 +0200 | [diff] [blame] | 4387 | dsi_if_enable(dsidev, false); |
| 4388 | dsi_vc_enable(dsidev, channel, false); |
Archit Taneja | 8af6ff0 | 2011-09-05 16:48:27 +0530 | [diff] [blame] | 4389 | |
Tomi Valkeinen | 9a147a6 | 2011-11-09 15:30:11 +0200 | [diff] [blame] | 4390 | /* MODE, 0 = command mode */ |
| 4391 | REG_FLD_MOD(dsidev, DSI_VC_CTRL(channel), 0, 4, 4); |
Archit Taneja | 8af6ff0 | 2011-09-05 16:48:27 +0530 | [diff] [blame] | 4392 | |
Tomi Valkeinen | 9a147a6 | 2011-11-09 15:30:11 +0200 | [diff] [blame] | 4393 | dsi_vc_enable(dsidev, channel, true); |
| 4394 | dsi_if_enable(dsidev, true); |
| 4395 | } |
Archit Taneja | 8af6ff0 | 2011-09-05 16:48:27 +0530 | [diff] [blame] | 4396 | |
Tomi Valkeinen | 7797c6d | 2011-11-04 10:22:46 +0200 | [diff] [blame] | 4397 | dss_mgr_disable(dssdev->manager); |
Archit Taneja | 8af6ff0 | 2011-09-05 16:48:27 +0530 | [diff] [blame] | 4398 | } |
Tomi Valkeinen | 9a147a6 | 2011-11-09 15:30:11 +0200 | [diff] [blame] | 4399 | EXPORT_SYMBOL(dsi_disable_video_output); |
Archit Taneja | 8af6ff0 | 2011-09-05 16:48:27 +0530 | [diff] [blame] | 4400 | |
Archit Taneja | 55cd63a | 2012-08-09 15:41:13 +0530 | [diff] [blame] | 4401 | static void dsi_update_screen_dispc(struct omap_dss_device *dssdev) |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 4402 | { |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 4403 | struct platform_device *dsidev = dsi_get_dsidev_from_dssdev(dssdev); |
Archit Taneja | f1da39d | 2011-05-12 17:26:27 +0530 | [diff] [blame] | 4404 | struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev); |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 4405 | unsigned bytespp; |
| 4406 | unsigned bytespl; |
| 4407 | unsigned bytespf; |
| 4408 | unsigned total_len; |
| 4409 | unsigned packet_payload; |
| 4410 | unsigned packet_len; |
| 4411 | u32 l; |
Tomi Valkeinen | 0f16aa0 | 2010-04-12 09:57:19 +0300 | [diff] [blame] | 4412 | int r; |
Archit Taneja | f1da39d | 2011-05-12 17:26:27 +0530 | [diff] [blame] | 4413 | const unsigned channel = dsi->update_channel; |
Archit Taneja | 0c65622 | 2011-05-16 15:17:09 +0530 | [diff] [blame] | 4414 | const unsigned line_buf_size = dsi_get_line_buf_size(dsidev); |
Archit Taneja | 55cd63a | 2012-08-09 15:41:13 +0530 | [diff] [blame] | 4415 | u16 w = dsi->timings.x_res; |
| 4416 | u16 h = dsi->timings.y_res; |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 4417 | |
Tomi Valkeinen | 5476e74 | 2011-11-03 16:34:20 +0200 | [diff] [blame] | 4418 | DSSDBG("dsi_update_screen_dispc(%dx%d)\n", w, h); |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 4419 | |
Archit Taneja | d604914 | 2011-08-22 11:58:08 +0530 | [diff] [blame] | 4420 | dsi_vc_config_source(dsidev, channel, DSI_VC_SOURCE_VP); |
Tomi Valkeinen | 18946f6 | 2010-01-12 14:16:41 +0200 | [diff] [blame] | 4421 | |
Archit Taneja | 02c3960 | 2012-08-10 15:01:33 +0530 | [diff] [blame] | 4422 | bytespp = dsi_get_pixel_size(dsi->pix_fmt) / 8; |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 4423 | bytespl = w * bytespp; |
| 4424 | bytespf = bytespl * h; |
| 4425 | |
| 4426 | /* NOTE: packet_payload has to be equal to N * bytespl, where N is |
| 4427 | * number of lines in a packet. See errata about VP_CLK_RATIO */ |
| 4428 | |
| 4429 | if (bytespf < line_buf_size) |
| 4430 | packet_payload = bytespf; |
| 4431 | else |
| 4432 | packet_payload = (line_buf_size) / bytespl * bytespl; |
| 4433 | |
| 4434 | packet_len = packet_payload + 1; /* 1 byte for DCS cmd */ |
| 4435 | total_len = (bytespf / packet_payload) * packet_len; |
| 4436 | |
| 4437 | if (bytespf % packet_payload) |
| 4438 | total_len += (bytespf % packet_payload) + 1; |
| 4439 | |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 4440 | l = FLD_VAL(total_len, 23, 0); /* TE_SIZE */ |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 4441 | dsi_write_reg(dsidev, DSI_VC_TE(channel), l); |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 4442 | |
Archit Taneja | 7a7c48f | 2011-08-25 18:25:03 +0530 | [diff] [blame] | 4443 | dsi_vc_write_long_header(dsidev, channel, MIPI_DSI_DCS_LONG_WRITE, |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 4444 | packet_len, 0); |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 4445 | |
Archit Taneja | f1da39d | 2011-05-12 17:26:27 +0530 | [diff] [blame] | 4446 | if (dsi->te_enabled) |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 4447 | l = FLD_MOD(l, 1, 30, 30); /* TE_EN */ |
| 4448 | else |
| 4449 | l = FLD_MOD(l, 1, 31, 31); /* TE_START */ |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 4450 | dsi_write_reg(dsidev, DSI_VC_TE(channel), l); |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 4451 | |
| 4452 | /* We put SIDLEMODE to no-idle for the duration of the transfer, |
| 4453 | * because DSS interrupts are not capable of waking up the CPU and the |
| 4454 | * framedone interrupt could be delayed for quite a long time. I think |
| 4455 | * the same goes for any DSS interrupts, but for some reason I have not |
| 4456 | * seen the problem anywhere else than here. |
| 4457 | */ |
| 4458 | dispc_disable_sidle(); |
| 4459 | |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 4460 | dsi_perf_mark_start(dsidev); |
Tomi Valkeinen | 18946f6 | 2010-01-12 14:16:41 +0200 | [diff] [blame] | 4461 | |
Archit Taneja | 49dbf58 | 2011-05-16 15:17:07 +0530 | [diff] [blame] | 4462 | r = schedule_delayed_work(&dsi->framedone_timeout_work, |
| 4463 | msecs_to_jiffies(250)); |
Tomi Valkeinen | 0f16aa0 | 2010-04-12 09:57:19 +0300 | [diff] [blame] | 4464 | BUG_ON(r == 0); |
Tomi Valkeinen | 18946f6 | 2010-01-12 14:16:41 +0200 | [diff] [blame] | 4465 | |
Archit Taneja | 55cd63a | 2012-08-09 15:41:13 +0530 | [diff] [blame] | 4466 | dss_mgr_set_timings(dssdev->manager, &dsi->timings); |
| 4467 | |
Tomi Valkeinen | 1cb0017 | 2011-11-18 11:14:01 +0200 | [diff] [blame] | 4468 | dss_mgr_start_update(dssdev->manager); |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 4469 | |
Archit Taneja | f1da39d | 2011-05-12 17:26:27 +0530 | [diff] [blame] | 4470 | if (dsi->te_enabled) { |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 4471 | /* disable LP_RX_TO, so that we can receive TE. Time to wait |
| 4472 | * for TE is longer than the timer allows */ |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 4473 | REG_FLD_MOD(dsidev, DSI_TIMING2, 0, 15, 15); /* LP_RX_TO */ |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 4474 | |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 4475 | dsi_vc_send_bta(dsidev, channel); |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 4476 | |
| 4477 | #ifdef DSI_CATCH_MISSING_TE |
Archit Taneja | f1da39d | 2011-05-12 17:26:27 +0530 | [diff] [blame] | 4478 | mod_timer(&dsi->te_timer, jiffies + msecs_to_jiffies(250)); |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 4479 | #endif |
| 4480 | } |
| 4481 | } |
| 4482 | |
| 4483 | #ifdef DSI_CATCH_MISSING_TE |
| 4484 | static void dsi_te_timeout(unsigned long arg) |
| 4485 | { |
| 4486 | DSSERR("TE not received for 250ms!\n"); |
| 4487 | } |
| 4488 | #endif |
| 4489 | |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 4490 | static void dsi_handle_framedone(struct platform_device *dsidev, int error) |
Tomi Valkeinen | 18946f6 | 2010-01-12 14:16:41 +0200 | [diff] [blame] | 4491 | { |
Archit Taneja | f1da39d | 2011-05-12 17:26:27 +0530 | [diff] [blame] | 4492 | struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev); |
| 4493 | |
Tomi Valkeinen | ab83b14 | 2010-06-09 15:31:01 +0300 | [diff] [blame] | 4494 | /* SIDLEMODE back to smart-idle */ |
| 4495 | dispc_enable_sidle(); |
| 4496 | |
Archit Taneja | f1da39d | 2011-05-12 17:26:27 +0530 | [diff] [blame] | 4497 | if (dsi->te_enabled) { |
Tomi Valkeinen | ab83b14 | 2010-06-09 15:31:01 +0300 | [diff] [blame] | 4498 | /* enable LP_RX_TO again after the TE */ |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 4499 | REG_FLD_MOD(dsidev, DSI_TIMING2, 1, 15, 15); /* LP_RX_TO */ |
Tomi Valkeinen | ab83b14 | 2010-06-09 15:31:01 +0300 | [diff] [blame] | 4500 | } |
| 4501 | |
Archit Taneja | f1da39d | 2011-05-12 17:26:27 +0530 | [diff] [blame] | 4502 | dsi->framedone_callback(error, dsi->framedone_data); |
Tomi Valkeinen | ab83b14 | 2010-06-09 15:31:01 +0300 | [diff] [blame] | 4503 | |
| 4504 | if (!error) |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 4505 | dsi_perf_show(dsidev, "DISPC"); |
Tomi Valkeinen | ab83b14 | 2010-06-09 15:31:01 +0300 | [diff] [blame] | 4506 | } |
| 4507 | |
| 4508 | static void dsi_framedone_timeout_work_callback(struct work_struct *work) |
| 4509 | { |
Archit Taneja | f1da39d | 2011-05-12 17:26:27 +0530 | [diff] [blame] | 4510 | struct dsi_data *dsi = container_of(work, struct dsi_data, |
| 4511 | framedone_timeout_work.work); |
Tomi Valkeinen | 0f16aa0 | 2010-04-12 09:57:19 +0300 | [diff] [blame] | 4512 | /* XXX While extremely unlikely, we could get FRAMEDONE interrupt after |
| 4513 | * 250ms which would conflict with this timeout work. What should be |
| 4514 | * done is first cancel the transfer on the HW, and then cancel the |
Tomi Valkeinen | ab83b14 | 2010-06-09 15:31:01 +0300 | [diff] [blame] | 4515 | * possibly scheduled framedone work. However, cancelling the transfer |
| 4516 | * on the HW is buggy, and would probably require resetting the whole |
| 4517 | * DSI */ |
Tomi Valkeinen | 0f16aa0 | 2010-04-12 09:57:19 +0300 | [diff] [blame] | 4518 | |
Tomi Valkeinen | ab83b14 | 2010-06-09 15:31:01 +0300 | [diff] [blame] | 4519 | DSSERR("Framedone not received for 250ms!\n"); |
Tomi Valkeinen | 18946f6 | 2010-01-12 14:16:41 +0200 | [diff] [blame] | 4520 | |
Archit Taneja | f1da39d | 2011-05-12 17:26:27 +0530 | [diff] [blame] | 4521 | dsi_handle_framedone(dsi->pdev, -ETIMEDOUT); |
Tomi Valkeinen | 18946f6 | 2010-01-12 14:16:41 +0200 | [diff] [blame] | 4522 | } |
| 4523 | |
Tomi Valkeinen | ab83b14 | 2010-06-09 15:31:01 +0300 | [diff] [blame] | 4524 | static void dsi_framedone_irq_callback(void *data, u32 mask) |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 4525 | { |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 4526 | struct omap_dss_device *dssdev = (struct omap_dss_device *) data; |
| 4527 | struct platform_device *dsidev = dsi_get_dsidev_from_dssdev(dssdev); |
Archit Taneja | f1da39d | 2011-05-12 17:26:27 +0530 | [diff] [blame] | 4528 | struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev); |
| 4529 | |
Tomi Valkeinen | ab83b14 | 2010-06-09 15:31:01 +0300 | [diff] [blame] | 4530 | /* Note: We get FRAMEDONE when DISPC has finished sending pixels and |
| 4531 | * turns itself off. However, DSI still has the pixels in its buffers, |
| 4532 | * and is sending the data. |
| 4533 | */ |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 4534 | |
Archit Taneja | f1da39d | 2011-05-12 17:26:27 +0530 | [diff] [blame] | 4535 | __cancel_delayed_work(&dsi->framedone_timeout_work); |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 4536 | |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 4537 | dsi_handle_framedone(dsidev, 0); |
Tomi Valkeinen | 18946f6 | 2010-01-12 14:16:41 +0200 | [diff] [blame] | 4538 | } |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 4539 | |
Tomi Valkeinen | 5476e74 | 2011-11-03 16:34:20 +0200 | [diff] [blame] | 4540 | int omap_dsi_update(struct omap_dss_device *dssdev, int channel, |
Tomi Valkeinen | 18946f6 | 2010-01-12 14:16:41 +0200 | [diff] [blame] | 4541 | void (*callback)(int, void *), void *data) |
| 4542 | { |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 4543 | struct platform_device *dsidev = dsi_get_dsidev_from_dssdev(dssdev); |
Archit Taneja | f1da39d | 2011-05-12 17:26:27 +0530 | [diff] [blame] | 4544 | struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev); |
Tomi Valkeinen | 5476e74 | 2011-11-03 16:34:20 +0200 | [diff] [blame] | 4545 | u16 dw, dh; |
| 4546 | |
| 4547 | dsi_perf_mark_setup(dsidev); |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 4548 | |
Archit Taneja | f1da39d | 2011-05-12 17:26:27 +0530 | [diff] [blame] | 4549 | dsi->update_channel = channel; |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 4550 | |
Tomi Valkeinen | 4a9e78a | 2011-08-15 11:22:21 +0300 | [diff] [blame] | 4551 | dsi->framedone_callback = callback; |
| 4552 | dsi->framedone_data = data; |
Tomi Valkeinen | 18946f6 | 2010-01-12 14:16:41 +0200 | [diff] [blame] | 4553 | |
Archit Taneja | e352574 | 2012-08-09 15:23:43 +0530 | [diff] [blame] | 4554 | dw = dsi->timings.x_res; |
| 4555 | dh = dsi->timings.y_res; |
Tomi Valkeinen | 18946f6 | 2010-01-12 14:16:41 +0200 | [diff] [blame] | 4556 | |
Tomi Valkeinen | 5476e74 | 2011-11-03 16:34:20 +0200 | [diff] [blame] | 4557 | #ifdef DEBUG |
| 4558 | dsi->update_bytes = dw * dh * |
Archit Taneja | 02c3960 | 2012-08-10 15:01:33 +0530 | [diff] [blame] | 4559 | dsi_get_pixel_size(dsi->pix_fmt) / 8; |
Tomi Valkeinen | 5476e74 | 2011-11-03 16:34:20 +0200 | [diff] [blame] | 4560 | #endif |
Archit Taneja | 55cd63a | 2012-08-09 15:41:13 +0530 | [diff] [blame] | 4561 | dsi_update_screen_dispc(dssdev); |
Tomi Valkeinen | 18946f6 | 2010-01-12 14:16:41 +0200 | [diff] [blame] | 4562 | |
| 4563 | return 0; |
| 4564 | } |
| 4565 | EXPORT_SYMBOL(omap_dsi_update); |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 4566 | |
| 4567 | /* Display funcs */ |
| 4568 | |
Archit Taneja | 7d2572f | 2012-06-29 14:31:07 +0530 | [diff] [blame] | 4569 | static int dsi_configure_dispc_clocks(struct omap_dss_device *dssdev) |
| 4570 | { |
| 4571 | struct platform_device *dsidev = dsi_get_dsidev_from_dssdev(dssdev); |
| 4572 | struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev); |
| 4573 | struct dispc_clock_info dispc_cinfo; |
| 4574 | int r; |
| 4575 | unsigned long long fck; |
| 4576 | |
| 4577 | fck = dsi_get_pll_hsdiv_dispc_rate(dsidev); |
| 4578 | |
| 4579 | dispc_cinfo.lck_div = dssdev->clocks.dispc.channel.lck_div; |
| 4580 | dispc_cinfo.pck_div = dssdev->clocks.dispc.channel.pck_div; |
| 4581 | |
| 4582 | r = dispc_calc_clock_rates(fck, &dispc_cinfo); |
| 4583 | if (r) { |
| 4584 | DSSERR("Failed to calc dispc clocks\n"); |
| 4585 | return r; |
| 4586 | } |
| 4587 | |
| 4588 | dsi->mgr_config.clock_info = dispc_cinfo; |
| 4589 | |
| 4590 | return 0; |
| 4591 | } |
| 4592 | |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 4593 | static int dsi_display_init_dispc(struct omap_dss_device *dssdev) |
| 4594 | { |
Archit Taneja | 7d2572f | 2012-06-29 14:31:07 +0530 | [diff] [blame] | 4595 | struct platform_device *dsidev = dsi_get_dsidev_from_dssdev(dssdev); |
| 4596 | struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev); |
Archit Taneja | 7d2572f | 2012-06-29 14:31:07 +0530 | [diff] [blame] | 4597 | int r; |
| 4598 | u32 irq = 0; |
Archit Taneja | 5a8b572 | 2011-05-12 17:26:29 +0530 | [diff] [blame] | 4599 | |
Archit Taneja | dca2b15 | 2012-08-16 18:02:00 +0530 | [diff] [blame] | 4600 | if (dsi->mode == OMAP_DSS_DSI_CMD_MODE) { |
Archit Taneja | e67458a | 2012-08-13 14:17:30 +0530 | [diff] [blame] | 4601 | dsi->timings.hsw = 1; |
| 4602 | dsi->timings.hfp = 1; |
| 4603 | dsi->timings.hbp = 1; |
| 4604 | dsi->timings.vsw = 1; |
| 4605 | dsi->timings.vfp = 0; |
| 4606 | dsi->timings.vbp = 0; |
Tomi Valkeinen | 5476e74 | 2011-11-03 16:34:20 +0200 | [diff] [blame] | 4607 | |
Chandrabhanu Mahapatra | efa70b3 | 2012-06-21 11:07:44 +0530 | [diff] [blame] | 4608 | irq = dispc_mgr_get_framedone_irq(dssdev->manager->id); |
Archit Taneja | 8af6ff0 | 2011-09-05 16:48:27 +0530 | [diff] [blame] | 4609 | |
| 4610 | r = omap_dispc_register_isr(dsi_framedone_irq_callback, |
| 4611 | (void *) dssdev, irq); |
| 4612 | if (r) { |
| 4613 | DSSERR("can't get FRAMEDONE irq\n"); |
Archit Taneja | 7d2572f | 2012-06-29 14:31:07 +0530 | [diff] [blame] | 4614 | goto err; |
Archit Taneja | 8af6ff0 | 2011-09-05 16:48:27 +0530 | [diff] [blame] | 4615 | } |
| 4616 | |
Archit Taneja | 7d2572f | 2012-06-29 14:31:07 +0530 | [diff] [blame] | 4617 | dsi->mgr_config.stallmode = true; |
| 4618 | dsi->mgr_config.fifohandcheck = true; |
Archit Taneja | 8af6ff0 | 2011-09-05 16:48:27 +0530 | [diff] [blame] | 4619 | } else { |
Archit Taneja | 7d2572f | 2012-06-29 14:31:07 +0530 | [diff] [blame] | 4620 | dsi->mgr_config.stallmode = false; |
| 4621 | dsi->mgr_config.fifohandcheck = false; |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 4622 | } |
| 4623 | |
Archit Taneja | bd5a7b1 | 2012-06-26 12:38:31 +0530 | [diff] [blame] | 4624 | /* |
| 4625 | * override interlace, logic level and edge related parameters in |
| 4626 | * omap_video_timings with default values |
| 4627 | */ |
Archit Taneja | e67458a | 2012-08-13 14:17:30 +0530 | [diff] [blame] | 4628 | dsi->timings.interlace = false; |
| 4629 | dsi->timings.hsync_level = OMAPDSS_SIG_ACTIVE_HIGH; |
| 4630 | dsi->timings.vsync_level = OMAPDSS_SIG_ACTIVE_HIGH; |
| 4631 | dsi->timings.data_pclk_edge = OMAPDSS_DRIVE_SIG_RISING_EDGE; |
| 4632 | dsi->timings.de_level = OMAPDSS_SIG_ACTIVE_HIGH; |
| 4633 | dsi->timings.sync_pclk_edge = OMAPDSS_DRIVE_SIG_OPPOSITE_EDGES; |
Archit Taneja | bd5a7b1 | 2012-06-26 12:38:31 +0530 | [diff] [blame] | 4634 | |
Archit Taneja | e67458a | 2012-08-13 14:17:30 +0530 | [diff] [blame] | 4635 | dss_mgr_set_timings(dssdev->manager, &dsi->timings); |
Archit Taneja | bd5a7b1 | 2012-06-26 12:38:31 +0530 | [diff] [blame] | 4636 | |
Archit Taneja | 7d2572f | 2012-06-29 14:31:07 +0530 | [diff] [blame] | 4637 | r = dsi_configure_dispc_clocks(dssdev); |
| 4638 | if (r) |
| 4639 | goto err1; |
| 4640 | |
| 4641 | dsi->mgr_config.io_pad_mode = DSS_IO_PAD_MODE_BYPASS; |
| 4642 | dsi->mgr_config.video_port_width = |
Archit Taneja | 02c3960 | 2012-08-10 15:01:33 +0530 | [diff] [blame] | 4643 | dsi_get_pixel_size(dsi->pix_fmt); |
Archit Taneja | 7d2572f | 2012-06-29 14:31:07 +0530 | [diff] [blame] | 4644 | dsi->mgr_config.lcden_sig_polarity = 0; |
| 4645 | |
Archit Taneja | f476ae9 | 2012-06-29 14:37:03 +0530 | [diff] [blame] | 4646 | dss_mgr_set_lcd_config(dssdev->manager, &dsi->mgr_config); |
Archit Taneja | d21f43b | 2012-06-21 09:45:11 +0530 | [diff] [blame] | 4647 | |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 4648 | return 0; |
Archit Taneja | 7d2572f | 2012-06-29 14:31:07 +0530 | [diff] [blame] | 4649 | err1: |
Archit Taneja | dca2b15 | 2012-08-16 18:02:00 +0530 | [diff] [blame] | 4650 | if (dsi->mode == OMAP_DSS_DSI_CMD_MODE) |
Archit Taneja | 7d2572f | 2012-06-29 14:31:07 +0530 | [diff] [blame] | 4651 | omap_dispc_unregister_isr(dsi_framedone_irq_callback, |
| 4652 | (void *) dssdev, irq); |
| 4653 | err: |
| 4654 | return r; |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 4655 | } |
| 4656 | |
| 4657 | static void dsi_display_uninit_dispc(struct omap_dss_device *dssdev) |
| 4658 | { |
Archit Taneja | dca2b15 | 2012-08-16 18:02:00 +0530 | [diff] [blame] | 4659 | struct platform_device *dsidev = dsi_get_dsidev_from_dssdev(dssdev); |
| 4660 | struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev); |
| 4661 | |
| 4662 | if (dsi->mode == OMAP_DSS_DSI_CMD_MODE) { |
Archit Taneja | 8af6ff0 | 2011-09-05 16:48:27 +0530 | [diff] [blame] | 4663 | u32 irq; |
Archit Taneja | 5a8b572 | 2011-05-12 17:26:29 +0530 | [diff] [blame] | 4664 | |
Chandrabhanu Mahapatra | efa70b3 | 2012-06-21 11:07:44 +0530 | [diff] [blame] | 4665 | irq = dispc_mgr_get_framedone_irq(dssdev->manager->id); |
Archit Taneja | 5a8b572 | 2011-05-12 17:26:29 +0530 | [diff] [blame] | 4666 | |
Archit Taneja | 8af6ff0 | 2011-09-05 16:48:27 +0530 | [diff] [blame] | 4667 | omap_dispc_unregister_isr(dsi_framedone_irq_callback, |
| 4668 | (void *) dssdev, irq); |
| 4669 | } |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 4670 | } |
| 4671 | |
| 4672 | static int dsi_configure_dsi_clocks(struct omap_dss_device *dssdev) |
| 4673 | { |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 4674 | struct platform_device *dsidev = dsi_get_dsidev_from_dssdev(dssdev); |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 4675 | struct dsi_clock_info cinfo; |
| 4676 | int r; |
| 4677 | |
Tomi Valkeinen | c6940a3 | 2011-02-22 13:36:10 +0200 | [diff] [blame] | 4678 | cinfo.regn = dssdev->clocks.dsi.regn; |
| 4679 | cinfo.regm = dssdev->clocks.dsi.regm; |
| 4680 | cinfo.regm_dispc = dssdev->clocks.dsi.regm_dispc; |
| 4681 | cinfo.regm_dsi = dssdev->clocks.dsi.regm_dsi; |
Tomi Valkeinen | b6e695a | 2012-03-15 15:22:58 +0200 | [diff] [blame] | 4682 | r = dsi_calc_clock_rates(dsidev, &cinfo); |
Ville Syrjälä | ebf0a3f | 2010-04-22 22:50:05 +0200 | [diff] [blame] | 4683 | if (r) { |
| 4684 | DSSERR("Failed to calc dsi clocks\n"); |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 4685 | return r; |
Ville Syrjälä | ebf0a3f | 2010-04-22 22:50:05 +0200 | [diff] [blame] | 4686 | } |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 4687 | |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 4688 | r = dsi_pll_set_clock_div(dsidev, &cinfo); |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 4689 | if (r) { |
| 4690 | DSSERR("Failed to set dsi clocks\n"); |
| 4691 | return r; |
| 4692 | } |
| 4693 | |
| 4694 | return 0; |
| 4695 | } |
| 4696 | |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 4697 | static int dsi_display_init_dsi(struct omap_dss_device *dssdev) |
| 4698 | { |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 4699 | struct platform_device *dsidev = dsi_get_dsidev_from_dssdev(dssdev); |
Tomi Valkeinen | 11ee960 | 2012-03-09 16:07:39 +0200 | [diff] [blame] | 4700 | struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev); |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 4701 | int r; |
| 4702 | |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 4703 | r = dsi_pll_init(dsidev, true, true); |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 4704 | if (r) |
| 4705 | goto err0; |
| 4706 | |
| 4707 | r = dsi_configure_dsi_clocks(dssdev); |
| 4708 | if (r) |
| 4709 | goto err1; |
| 4710 | |
Archit Taneja | e888166 | 2011-04-12 13:52:24 +0530 | [diff] [blame] | 4711 | dss_select_dispc_clk_source(dssdev->clocks.dispc.dispc_fclk_src); |
Tomi Valkeinen | 11ee960 | 2012-03-09 16:07:39 +0200 | [diff] [blame] | 4712 | dss_select_dsi_clk_source(dsi->module_id, dssdev->clocks.dsi.dsi_fclk_src); |
Archit Taneja | 9613c02 | 2011-03-22 06:33:36 -0500 | [diff] [blame] | 4713 | dss_select_lcd_clk_source(dssdev->manager->id, |
Archit Taneja | e888166 | 2011-04-12 13:52:24 +0530 | [diff] [blame] | 4714 | dssdev->clocks.dispc.channel.lcd_clk_src); |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 4715 | |
| 4716 | DSSDBG("PLL OK\n"); |
| 4717 | |
Tomi Valkeinen | cc5c185 | 2010-10-06 15:18:13 +0300 | [diff] [blame] | 4718 | r = dsi_cio_init(dssdev); |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 4719 | if (r) |
| 4720 | goto err2; |
| 4721 | |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 4722 | _dsi_print_reset_status(dsidev); |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 4723 | |
| 4724 | dsi_proto_timings(dssdev); |
| 4725 | dsi_set_lp_clk_divisor(dssdev); |
| 4726 | |
| 4727 | if (1) |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 4728 | _dsi_print_reset_status(dsidev); |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 4729 | |
| 4730 | r = dsi_proto_config(dssdev); |
| 4731 | if (r) |
| 4732 | goto err3; |
| 4733 | |
| 4734 | /* enable interface */ |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 4735 | dsi_vc_enable(dsidev, 0, 1); |
| 4736 | dsi_vc_enable(dsidev, 1, 1); |
| 4737 | dsi_vc_enable(dsidev, 2, 1); |
| 4738 | dsi_vc_enable(dsidev, 3, 1); |
| 4739 | dsi_if_enable(dsidev, 1); |
| 4740 | dsi_force_tx_stop_mode_io(dsidev); |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 4741 | |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 4742 | return 0; |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 4743 | err3: |
Tomi Valkeinen | 5bc416c | 2011-06-15 15:21:12 +0300 | [diff] [blame] | 4744 | dsi_cio_uninit(dssdev); |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 4745 | err2: |
Archit Taneja | 89a35e5 | 2011-04-12 13:52:23 +0530 | [diff] [blame] | 4746 | dss_select_dispc_clk_source(OMAP_DSS_CLK_SRC_FCK); |
Tomi Valkeinen | 11ee960 | 2012-03-09 16:07:39 +0200 | [diff] [blame] | 4747 | dss_select_dsi_clk_source(dsi->module_id, OMAP_DSS_CLK_SRC_FCK); |
Tomi Valkeinen | 5e78509 | 2011-08-10 11:25:36 +0300 | [diff] [blame] | 4748 | dss_select_lcd_clk_source(dssdev->manager->id, OMAP_DSS_CLK_SRC_FCK); |
| 4749 | |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 4750 | err1: |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 4751 | dsi_pll_uninit(dsidev, true); |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 4752 | err0: |
| 4753 | return r; |
| 4754 | } |
| 4755 | |
Tomi Valkeinen | 2a89dc1 | 2010-07-30 12:39:34 +0300 | [diff] [blame] | 4756 | static void dsi_display_uninit_dsi(struct omap_dss_device *dssdev, |
Tomi Valkeinen | 22d6d67 | 2010-10-11 11:33:30 +0300 | [diff] [blame] | 4757 | bool disconnect_lanes, bool enter_ulps) |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 4758 | { |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 4759 | struct platform_device *dsidev = dsi_get_dsidev_from_dssdev(dssdev); |
Archit Taneja | f1da39d | 2011-05-12 17:26:27 +0530 | [diff] [blame] | 4760 | struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev); |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 4761 | |
Archit Taneja | f1da39d | 2011-05-12 17:26:27 +0530 | [diff] [blame] | 4762 | if (enter_ulps && !dsi->ulps_enabled) |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 4763 | dsi_enter_ulps(dsidev); |
Tomi Valkeinen | 40885ab | 2010-07-28 15:53:38 +0300 | [diff] [blame] | 4764 | |
Ville Syrjälä | d737010 | 2010-04-22 22:50:09 +0200 | [diff] [blame] | 4765 | /* disable interface */ |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 4766 | dsi_if_enable(dsidev, 0); |
| 4767 | dsi_vc_enable(dsidev, 0, 0); |
| 4768 | dsi_vc_enable(dsidev, 1, 0); |
| 4769 | dsi_vc_enable(dsidev, 2, 0); |
| 4770 | dsi_vc_enable(dsidev, 3, 0); |
Ville Syrjälä | d737010 | 2010-04-22 22:50:09 +0200 | [diff] [blame] | 4771 | |
Archit Taneja | 89a35e5 | 2011-04-12 13:52:23 +0530 | [diff] [blame] | 4772 | dss_select_dispc_clk_source(OMAP_DSS_CLK_SRC_FCK); |
Tomi Valkeinen | 11ee960 | 2012-03-09 16:07:39 +0200 | [diff] [blame] | 4773 | dss_select_dsi_clk_source(dsi->module_id, OMAP_DSS_CLK_SRC_FCK); |
Tomi Valkeinen | 5e78509 | 2011-08-10 11:25:36 +0300 | [diff] [blame] | 4774 | dss_select_lcd_clk_source(dssdev->manager->id, OMAP_DSS_CLK_SRC_FCK); |
Tomi Valkeinen | 5bc416c | 2011-06-15 15:21:12 +0300 | [diff] [blame] | 4775 | dsi_cio_uninit(dssdev); |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 4776 | dsi_pll_uninit(dsidev, disconnect_lanes); |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 4777 | } |
| 4778 | |
Tomi Valkeinen | 37ac60e | 2010-01-12 15:12:07 +0200 | [diff] [blame] | 4779 | int omapdss_dsi_display_enable(struct omap_dss_device *dssdev) |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 4780 | { |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 4781 | struct platform_device *dsidev = dsi_get_dsidev_from_dssdev(dssdev); |
Archit Taneja | f1da39d | 2011-05-12 17:26:27 +0530 | [diff] [blame] | 4782 | struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev); |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 4783 | int r = 0; |
| 4784 | |
| 4785 | DSSDBG("dsi_display_enable\n"); |
| 4786 | |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 4787 | WARN_ON(!dsi_bus_is_locked(dsidev)); |
Tomi Valkeinen | 37ac60e | 2010-01-12 15:12:07 +0200 | [diff] [blame] | 4788 | |
Archit Taneja | f1da39d | 2011-05-12 17:26:27 +0530 | [diff] [blame] | 4789 | mutex_lock(&dsi->lock); |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 4790 | |
Tomi Valkeinen | 05e1d60 | 2011-06-23 16:38:21 +0300 | [diff] [blame] | 4791 | if (dssdev->manager == NULL) { |
| 4792 | DSSERR("failed to enable display: no manager\n"); |
| 4793 | r = -ENODEV; |
| 4794 | goto err_start_dev; |
| 4795 | } |
| 4796 | |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 4797 | r = omap_dss_start_device(dssdev); |
| 4798 | if (r) { |
| 4799 | DSSERR("failed to start device\n"); |
Tomi Valkeinen | 4fbafaf | 2011-05-27 10:52:19 +0300 | [diff] [blame] | 4800 | goto err_start_dev; |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 4801 | } |
| 4802 | |
Tomi Valkeinen | 4fbafaf | 2011-05-27 10:52:19 +0300 | [diff] [blame] | 4803 | r = dsi_runtime_get(dsidev); |
| 4804 | if (r) |
| 4805 | goto err_get_dsi; |
| 4806 | |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 4807 | dsi_enable_pll_clock(dsidev, 1); |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 4808 | |
Tomi Valkeinen | 4fbafaf | 2011-05-27 10:52:19 +0300 | [diff] [blame] | 4809 | _dsi_initialize_irq(dsidev); |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 4810 | |
| 4811 | r = dsi_display_init_dispc(dssdev); |
| 4812 | if (r) |
Tomi Valkeinen | 4fbafaf | 2011-05-27 10:52:19 +0300 | [diff] [blame] | 4813 | goto err_init_dispc; |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 4814 | |
| 4815 | r = dsi_display_init_dsi(dssdev); |
| 4816 | if (r) |
Tomi Valkeinen | 4fbafaf | 2011-05-27 10:52:19 +0300 | [diff] [blame] | 4817 | goto err_init_dsi; |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 4818 | |
Archit Taneja | f1da39d | 2011-05-12 17:26:27 +0530 | [diff] [blame] | 4819 | mutex_unlock(&dsi->lock); |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 4820 | |
| 4821 | return 0; |
| 4822 | |
Tomi Valkeinen | 4fbafaf | 2011-05-27 10:52:19 +0300 | [diff] [blame] | 4823 | err_init_dsi: |
Tomi Valkeinen | 37ac60e | 2010-01-12 15:12:07 +0200 | [diff] [blame] | 4824 | dsi_display_uninit_dispc(dssdev); |
Tomi Valkeinen | 4fbafaf | 2011-05-27 10:52:19 +0300 | [diff] [blame] | 4825 | err_init_dispc: |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 4826 | dsi_enable_pll_clock(dsidev, 0); |
Tomi Valkeinen | 4fbafaf | 2011-05-27 10:52:19 +0300 | [diff] [blame] | 4827 | dsi_runtime_put(dsidev); |
| 4828 | err_get_dsi: |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 4829 | omap_dss_stop_device(dssdev); |
Tomi Valkeinen | 4fbafaf | 2011-05-27 10:52:19 +0300 | [diff] [blame] | 4830 | err_start_dev: |
Archit Taneja | f1da39d | 2011-05-12 17:26:27 +0530 | [diff] [blame] | 4831 | mutex_unlock(&dsi->lock); |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 4832 | DSSDBG("dsi_display_enable FAILED\n"); |
| 4833 | return r; |
| 4834 | } |
Tomi Valkeinen | 37ac60e | 2010-01-12 15:12:07 +0200 | [diff] [blame] | 4835 | EXPORT_SYMBOL(omapdss_dsi_display_enable); |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 4836 | |
Tomi Valkeinen | 2a89dc1 | 2010-07-30 12:39:34 +0300 | [diff] [blame] | 4837 | void omapdss_dsi_display_disable(struct omap_dss_device *dssdev, |
Tomi Valkeinen | 22d6d67 | 2010-10-11 11:33:30 +0300 | [diff] [blame] | 4838 | bool disconnect_lanes, bool enter_ulps) |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 4839 | { |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 4840 | struct platform_device *dsidev = dsi_get_dsidev_from_dssdev(dssdev); |
Archit Taneja | f1da39d | 2011-05-12 17:26:27 +0530 | [diff] [blame] | 4841 | struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev); |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 4842 | |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 4843 | DSSDBG("dsi_display_disable\n"); |
| 4844 | |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 4845 | WARN_ON(!dsi_bus_is_locked(dsidev)); |
Tomi Valkeinen | 37ac60e | 2010-01-12 15:12:07 +0200 | [diff] [blame] | 4846 | |
Archit Taneja | f1da39d | 2011-05-12 17:26:27 +0530 | [diff] [blame] | 4847 | mutex_lock(&dsi->lock); |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 4848 | |
Tomi Valkeinen | 15ffa1d | 2011-06-16 14:34:06 +0300 | [diff] [blame] | 4849 | dsi_sync_vc(dsidev, 0); |
| 4850 | dsi_sync_vc(dsidev, 1); |
| 4851 | dsi_sync_vc(dsidev, 2); |
| 4852 | dsi_sync_vc(dsidev, 3); |
| 4853 | |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 4854 | dsi_display_uninit_dispc(dssdev); |
| 4855 | |
Tomi Valkeinen | 22d6d67 | 2010-10-11 11:33:30 +0300 | [diff] [blame] | 4856 | dsi_display_uninit_dsi(dssdev, disconnect_lanes, enter_ulps); |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 4857 | |
Tomi Valkeinen | 4fbafaf | 2011-05-27 10:52:19 +0300 | [diff] [blame] | 4858 | dsi_runtime_put(dsidev); |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 4859 | dsi_enable_pll_clock(dsidev, 0); |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 4860 | |
| 4861 | omap_dss_stop_device(dssdev); |
Tomi Valkeinen | 37ac60e | 2010-01-12 15:12:07 +0200 | [diff] [blame] | 4862 | |
Archit Taneja | f1da39d | 2011-05-12 17:26:27 +0530 | [diff] [blame] | 4863 | mutex_unlock(&dsi->lock); |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 4864 | } |
Tomi Valkeinen | 37ac60e | 2010-01-12 15:12:07 +0200 | [diff] [blame] | 4865 | EXPORT_SYMBOL(omapdss_dsi_display_disable); |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 4866 | |
Tomi Valkeinen | 225b650 | 2010-01-11 15:11:01 +0200 | [diff] [blame] | 4867 | int omapdss_dsi_enable_te(struct omap_dss_device *dssdev, bool enable) |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 4868 | { |
Archit Taneja | f1da39d | 2011-05-12 17:26:27 +0530 | [diff] [blame] | 4869 | struct platform_device *dsidev = dsi_get_dsidev_from_dssdev(dssdev); |
| 4870 | struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev); |
| 4871 | |
| 4872 | dsi->te_enabled = enable; |
Tomi Valkeinen | 225b650 | 2010-01-11 15:11:01 +0200 | [diff] [blame] | 4873 | return 0; |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 4874 | } |
Tomi Valkeinen | 225b650 | 2010-01-11 15:11:01 +0200 | [diff] [blame] | 4875 | EXPORT_SYMBOL(omapdss_dsi_enable_te); |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 4876 | |
Archit Taneja | e67458a | 2012-08-13 14:17:30 +0530 | [diff] [blame] | 4877 | void omapdss_dsi_set_timings(struct omap_dss_device *dssdev, |
| 4878 | struct omap_video_timings *timings) |
| 4879 | { |
| 4880 | struct platform_device *dsidev = dsi_get_dsidev_from_dssdev(dssdev); |
| 4881 | struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev); |
| 4882 | |
| 4883 | mutex_lock(&dsi->lock); |
| 4884 | |
| 4885 | dsi->timings = *timings; |
| 4886 | |
| 4887 | mutex_unlock(&dsi->lock); |
| 4888 | } |
| 4889 | EXPORT_SYMBOL(omapdss_dsi_set_timings); |
| 4890 | |
Archit Taneja | e352574 | 2012-08-09 15:23:43 +0530 | [diff] [blame] | 4891 | void omapdss_dsi_set_size(struct omap_dss_device *dssdev, u16 w, u16 h) |
| 4892 | { |
| 4893 | struct platform_device *dsidev = dsi_get_dsidev_from_dssdev(dssdev); |
| 4894 | struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev); |
| 4895 | |
| 4896 | mutex_lock(&dsi->lock); |
| 4897 | |
| 4898 | dsi->timings.x_res = w; |
| 4899 | dsi->timings.y_res = h; |
| 4900 | |
| 4901 | mutex_unlock(&dsi->lock); |
| 4902 | } |
| 4903 | EXPORT_SYMBOL(omapdss_dsi_set_size); |
| 4904 | |
Archit Taneja | 02c3960 | 2012-08-10 15:01:33 +0530 | [diff] [blame] | 4905 | void omapdss_dsi_set_pixel_format(struct omap_dss_device *dssdev, |
| 4906 | enum omap_dss_dsi_pixel_format fmt) |
| 4907 | { |
| 4908 | struct platform_device *dsidev = dsi_get_dsidev_from_dssdev(dssdev); |
| 4909 | struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev); |
| 4910 | |
| 4911 | mutex_lock(&dsi->lock); |
| 4912 | |
| 4913 | dsi->pix_fmt = fmt; |
| 4914 | |
| 4915 | mutex_unlock(&dsi->lock); |
| 4916 | } |
| 4917 | EXPORT_SYMBOL(omapdss_dsi_set_pixel_format); |
| 4918 | |
Archit Taneja | dca2b15 | 2012-08-16 18:02:00 +0530 | [diff] [blame] | 4919 | void omapdss_dsi_set_operation_mode(struct omap_dss_device *dssdev, |
| 4920 | enum omap_dss_dsi_mode mode) |
| 4921 | { |
| 4922 | struct platform_device *dsidev = dsi_get_dsidev_from_dssdev(dssdev); |
| 4923 | struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev); |
| 4924 | |
| 4925 | mutex_lock(&dsi->lock); |
| 4926 | |
| 4927 | dsi->mode = mode; |
| 4928 | |
| 4929 | mutex_unlock(&dsi->lock); |
| 4930 | } |
| 4931 | EXPORT_SYMBOL(omapdss_dsi_set_operation_mode); |
| 4932 | |
Archit Taneja | 0b3ffe3 | 2012-08-13 22:13:39 +0530 | [diff] [blame] | 4933 | void omapdss_dsi_set_videomode_timings(struct omap_dss_device *dssdev, |
| 4934 | struct omap_dss_dsi_videomode_timings *timings) |
| 4935 | { |
| 4936 | struct platform_device *dsidev = dsi_get_dsidev_from_dssdev(dssdev); |
| 4937 | struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev); |
| 4938 | |
| 4939 | mutex_lock(&dsi->lock); |
| 4940 | |
| 4941 | dsi->vm_timings = *timings; |
| 4942 | |
| 4943 | mutex_unlock(&dsi->lock); |
| 4944 | } |
| 4945 | EXPORT_SYMBOL(omapdss_dsi_set_videomode_timings); |
| 4946 | |
Tomi Valkeinen | 9d8232a | 2012-03-01 16:58:39 +0200 | [diff] [blame] | 4947 | static int __init dsi_init_display(struct omap_dss_device *dssdev) |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 4948 | { |
Archit Taneja | f1da39d | 2011-05-12 17:26:27 +0530 | [diff] [blame] | 4949 | struct platform_device *dsidev = dsi_get_dsidev_from_dssdev(dssdev); |
| 4950 | struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev); |
| 4951 | |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 4952 | DSSDBG("DSI init\n"); |
| 4953 | |
Archit Taneja | f1da39d | 2011-05-12 17:26:27 +0530 | [diff] [blame] | 4954 | if (dsi->vdds_dsi_reg == NULL) { |
Tomi Valkeinen | 5f42f2c | 2011-02-22 15:53:46 +0200 | [diff] [blame] | 4955 | struct regulator *vdds_dsi; |
| 4956 | |
Archit Taneja | f1da39d | 2011-05-12 17:26:27 +0530 | [diff] [blame] | 4957 | vdds_dsi = regulator_get(&dsi->pdev->dev, "vdds_dsi"); |
Tomi Valkeinen | 5f42f2c | 2011-02-22 15:53:46 +0200 | [diff] [blame] | 4958 | |
| 4959 | if (IS_ERR(vdds_dsi)) { |
| 4960 | DSSERR("can't get VDDS_DSI regulator\n"); |
| 4961 | return PTR_ERR(vdds_dsi); |
| 4962 | } |
| 4963 | |
Archit Taneja | f1da39d | 2011-05-12 17:26:27 +0530 | [diff] [blame] | 4964 | dsi->vdds_dsi_reg = vdds_dsi; |
Tomi Valkeinen | 5f42f2c | 2011-02-22 15:53:46 +0200 | [diff] [blame] | 4965 | } |
| 4966 | |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 4967 | return 0; |
| 4968 | } |
| 4969 | |
Archit Taneja | 5ee3c14 | 2011-03-02 12:35:53 +0530 | [diff] [blame] | 4970 | int omap_dsi_request_vc(struct omap_dss_device *dssdev, int *channel) |
| 4971 | { |
Archit Taneja | f1da39d | 2011-05-12 17:26:27 +0530 | [diff] [blame] | 4972 | struct platform_device *dsidev = dsi_get_dsidev_from_dssdev(dssdev); |
| 4973 | struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev); |
Archit Taneja | 5ee3c14 | 2011-03-02 12:35:53 +0530 | [diff] [blame] | 4974 | int i; |
| 4975 | |
Archit Taneja | f1da39d | 2011-05-12 17:26:27 +0530 | [diff] [blame] | 4976 | for (i = 0; i < ARRAY_SIZE(dsi->vc); i++) { |
| 4977 | if (!dsi->vc[i].dssdev) { |
| 4978 | dsi->vc[i].dssdev = dssdev; |
Archit Taneja | 5ee3c14 | 2011-03-02 12:35:53 +0530 | [diff] [blame] | 4979 | *channel = i; |
| 4980 | return 0; |
| 4981 | } |
| 4982 | } |
| 4983 | |
| 4984 | DSSERR("cannot get VC for display %s", dssdev->name); |
| 4985 | return -ENOSPC; |
| 4986 | } |
| 4987 | EXPORT_SYMBOL(omap_dsi_request_vc); |
| 4988 | |
| 4989 | int omap_dsi_set_vc_id(struct omap_dss_device *dssdev, int channel, int vc_id) |
| 4990 | { |
Archit Taneja | f1da39d | 2011-05-12 17:26:27 +0530 | [diff] [blame] | 4991 | struct platform_device *dsidev = dsi_get_dsidev_from_dssdev(dssdev); |
| 4992 | struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev); |
| 4993 | |
Archit Taneja | 5ee3c14 | 2011-03-02 12:35:53 +0530 | [diff] [blame] | 4994 | if (vc_id < 0 || vc_id > 3) { |
| 4995 | DSSERR("VC ID out of range\n"); |
| 4996 | return -EINVAL; |
| 4997 | } |
| 4998 | |
| 4999 | if (channel < 0 || channel > 3) { |
| 5000 | DSSERR("Virtual Channel out of range\n"); |
| 5001 | return -EINVAL; |
| 5002 | } |
| 5003 | |
Archit Taneja | f1da39d | 2011-05-12 17:26:27 +0530 | [diff] [blame] | 5004 | if (dsi->vc[channel].dssdev != dssdev) { |
Archit Taneja | 5ee3c14 | 2011-03-02 12:35:53 +0530 | [diff] [blame] | 5005 | DSSERR("Virtual Channel not allocated to display %s\n", |
| 5006 | dssdev->name); |
| 5007 | return -EINVAL; |
| 5008 | } |
| 5009 | |
Archit Taneja | f1da39d | 2011-05-12 17:26:27 +0530 | [diff] [blame] | 5010 | dsi->vc[channel].vc_id = vc_id; |
Archit Taneja | 5ee3c14 | 2011-03-02 12:35:53 +0530 | [diff] [blame] | 5011 | |
| 5012 | return 0; |
| 5013 | } |
| 5014 | EXPORT_SYMBOL(omap_dsi_set_vc_id); |
| 5015 | |
| 5016 | void omap_dsi_release_vc(struct omap_dss_device *dssdev, int channel) |
| 5017 | { |
Archit Taneja | f1da39d | 2011-05-12 17:26:27 +0530 | [diff] [blame] | 5018 | struct platform_device *dsidev = dsi_get_dsidev_from_dssdev(dssdev); |
| 5019 | struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev); |
| 5020 | |
Archit Taneja | 5ee3c14 | 2011-03-02 12:35:53 +0530 | [diff] [blame] | 5021 | if ((channel >= 0 && channel <= 3) && |
Archit Taneja | f1da39d | 2011-05-12 17:26:27 +0530 | [diff] [blame] | 5022 | dsi->vc[channel].dssdev == dssdev) { |
| 5023 | dsi->vc[channel].dssdev = NULL; |
| 5024 | dsi->vc[channel].vc_id = 0; |
Archit Taneja | 5ee3c14 | 2011-03-02 12:35:53 +0530 | [diff] [blame] | 5025 | } |
| 5026 | } |
| 5027 | EXPORT_SYMBOL(omap_dsi_release_vc); |
| 5028 | |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 5029 | void dsi_wait_pll_hsdiv_dispc_active(struct platform_device *dsidev) |
Tomi Valkeinen | e406f90 | 2010-06-09 15:28:12 +0300 | [diff] [blame] | 5030 | { |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 5031 | if (wait_for_bit_change(dsidev, DSI_PLL_STATUS, 7, 1) != 1) |
Archit Taneja | 067a57e | 2011-03-02 11:57:25 +0530 | [diff] [blame] | 5032 | DSSERR("%s (%s) not active\n", |
Archit Taneja | 89a35e5 | 2011-04-12 13:52:23 +0530 | [diff] [blame] | 5033 | dss_get_generic_clk_source_name(OMAP_DSS_CLK_SRC_DSI_PLL_HSDIV_DISPC), |
| 5034 | dss_feat_get_clk_source_name(OMAP_DSS_CLK_SRC_DSI_PLL_HSDIV_DISPC)); |
Tomi Valkeinen | e406f90 | 2010-06-09 15:28:12 +0300 | [diff] [blame] | 5035 | } |
| 5036 | |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 5037 | void dsi_wait_pll_hsdiv_dsi_active(struct platform_device *dsidev) |
Tomi Valkeinen | e406f90 | 2010-06-09 15:28:12 +0300 | [diff] [blame] | 5038 | { |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 5039 | if (wait_for_bit_change(dsidev, DSI_PLL_STATUS, 8, 1) != 1) |
Archit Taneja | 067a57e | 2011-03-02 11:57:25 +0530 | [diff] [blame] | 5040 | DSSERR("%s (%s) not active\n", |
Archit Taneja | 89a35e5 | 2011-04-12 13:52:23 +0530 | [diff] [blame] | 5041 | dss_get_generic_clk_source_name(OMAP_DSS_CLK_SRC_DSI_PLL_HSDIV_DSI), |
| 5042 | dss_feat_get_clk_source_name(OMAP_DSS_CLK_SRC_DSI_PLL_HSDIV_DSI)); |
Tomi Valkeinen | e406f90 | 2010-06-09 15:28:12 +0300 | [diff] [blame] | 5043 | } |
| 5044 | |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 5045 | static void dsi_calc_clock_param_ranges(struct platform_device *dsidev) |
Taneja, Archit | 4964111 | 2011-03-14 23:28:23 -0500 | [diff] [blame] | 5046 | { |
Archit Taneja | f1da39d | 2011-05-12 17:26:27 +0530 | [diff] [blame] | 5047 | struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev); |
| 5048 | |
| 5049 | dsi->regn_max = dss_feat_get_param_max(FEAT_PARAM_DSIPLL_REGN); |
| 5050 | dsi->regm_max = dss_feat_get_param_max(FEAT_PARAM_DSIPLL_REGM); |
| 5051 | dsi->regm_dispc_max = |
| 5052 | dss_feat_get_param_max(FEAT_PARAM_DSIPLL_REGM_DISPC); |
| 5053 | dsi->regm_dsi_max = dss_feat_get_param_max(FEAT_PARAM_DSIPLL_REGM_DSI); |
| 5054 | dsi->fint_min = dss_feat_get_param_min(FEAT_PARAM_DSIPLL_FINT); |
| 5055 | dsi->fint_max = dss_feat_get_param_max(FEAT_PARAM_DSIPLL_FINT); |
| 5056 | dsi->lpdiv_max = dss_feat_get_param_max(FEAT_PARAM_DSIPLL_LPDIV); |
Taneja, Archit | 4964111 | 2011-03-14 23:28:23 -0500 | [diff] [blame] | 5057 | } |
| 5058 | |
Tomi Valkeinen | 4fbafaf | 2011-05-27 10:52:19 +0300 | [diff] [blame] | 5059 | static int dsi_get_clocks(struct platform_device *dsidev) |
| 5060 | { |
| 5061 | struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev); |
| 5062 | struct clk *clk; |
| 5063 | |
| 5064 | clk = clk_get(&dsidev->dev, "fck"); |
| 5065 | if (IS_ERR(clk)) { |
| 5066 | DSSERR("can't get fck\n"); |
| 5067 | return PTR_ERR(clk); |
| 5068 | } |
| 5069 | |
| 5070 | dsi->dss_clk = clk; |
| 5071 | |
Tomi Valkeinen | bfe4f8d | 2011-08-04 11:22:54 +0300 | [diff] [blame] | 5072 | clk = clk_get(&dsidev->dev, "sys_clk"); |
Tomi Valkeinen | 4fbafaf | 2011-05-27 10:52:19 +0300 | [diff] [blame] | 5073 | if (IS_ERR(clk)) { |
| 5074 | DSSERR("can't get sys_clk\n"); |
| 5075 | clk_put(dsi->dss_clk); |
| 5076 | dsi->dss_clk = NULL; |
| 5077 | return PTR_ERR(clk); |
| 5078 | } |
| 5079 | |
| 5080 | dsi->sys_clk = clk; |
| 5081 | |
| 5082 | return 0; |
| 5083 | } |
| 5084 | |
| 5085 | static void dsi_put_clocks(struct platform_device *dsidev) |
| 5086 | { |
| 5087 | struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev); |
| 5088 | |
| 5089 | if (dsi->dss_clk) |
| 5090 | clk_put(dsi->dss_clk); |
| 5091 | if (dsi->sys_clk) |
| 5092 | clk_put(dsi->sys_clk); |
| 5093 | } |
| 5094 | |
Tomi Valkeinen | 38f3daf | 2012-05-02 14:55:12 +0300 | [diff] [blame] | 5095 | static void __init dsi_probe_pdata(struct platform_device *dsidev) |
| 5096 | { |
| 5097 | struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev); |
| 5098 | struct omap_dss_board_info *pdata = dsidev->dev.platform_data; |
| 5099 | int i, r; |
| 5100 | |
| 5101 | for (i = 0; i < pdata->num_devices; ++i) { |
| 5102 | struct omap_dss_device *dssdev = pdata->devices[i]; |
| 5103 | |
| 5104 | if (dssdev->type != OMAP_DISPLAY_TYPE_DSI) |
| 5105 | continue; |
| 5106 | |
| 5107 | if (dssdev->phy.dsi.module != dsi->module_id) |
| 5108 | continue; |
| 5109 | |
| 5110 | r = dsi_init_display(dssdev); |
| 5111 | if (r) { |
| 5112 | DSSERR("device %s init failed: %d\n", dssdev->name, r); |
| 5113 | continue; |
| 5114 | } |
| 5115 | |
| 5116 | r = omap_dss_register_device(dssdev, &dsidev->dev, i); |
| 5117 | if (r) |
| 5118 | DSSERR("device %s register failed: %d\n", |
| 5119 | dssdev->name, r); |
| 5120 | } |
| 5121 | } |
| 5122 | |
Tomi Valkeinen | b98482e | 2011-05-16 13:52:51 +0300 | [diff] [blame] | 5123 | /* DSI1 HW IP initialisation */ |
Tomi Valkeinen | 6e7e8f0 | 2012-02-17 17:41:13 +0200 | [diff] [blame] | 5124 | static int __init omap_dsihw_probe(struct platform_device *dsidev) |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 5125 | { |
| 5126 | u32 rev; |
Tomi Valkeinen | 11ee960 | 2012-03-09 16:07:39 +0200 | [diff] [blame] | 5127 | int r, i; |
Senthilvadivu Guruswamy | ea9da36 | 2011-01-24 06:22:04 +0000 | [diff] [blame] | 5128 | struct resource *dsi_mem; |
Archit Taneja | f1da39d | 2011-05-12 17:26:27 +0530 | [diff] [blame] | 5129 | struct dsi_data *dsi; |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 5130 | |
Julia Lawall | 6e2a14d | 2012-01-24 14:00:45 +0100 | [diff] [blame] | 5131 | dsi = devm_kzalloc(&dsidev->dev, sizeof(*dsi), GFP_KERNEL); |
Tomi Valkeinen | cd3b344 | 2012-01-25 13:31:04 +0200 | [diff] [blame] | 5132 | if (!dsi) |
| 5133 | return -ENOMEM; |
Archit Taneja | f1da39d | 2011-05-12 17:26:27 +0530 | [diff] [blame] | 5134 | |
Tomi Valkeinen | 11ee960 | 2012-03-09 16:07:39 +0200 | [diff] [blame] | 5135 | dsi->module_id = dsidev->id; |
Archit Taneja | f1da39d | 2011-05-12 17:26:27 +0530 | [diff] [blame] | 5136 | dsi->pdev = dsidev; |
Tomi Valkeinen | 11ee960 | 2012-03-09 16:07:39 +0200 | [diff] [blame] | 5137 | dsi_pdev_map[dsi->module_id] = dsidev; |
Archit Taneja | f1da39d | 2011-05-12 17:26:27 +0530 | [diff] [blame] | 5138 | dev_set_drvdata(&dsidev->dev, dsi); |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 5139 | |
Archit Taneja | f1da39d | 2011-05-12 17:26:27 +0530 | [diff] [blame] | 5140 | spin_lock_init(&dsi->irq_lock); |
| 5141 | spin_lock_init(&dsi->errors_lock); |
| 5142 | dsi->errors = 0; |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 5143 | |
Tomi Valkeinen | dfc0fd8 | 2009-12-17 14:35:21 +0200 | [diff] [blame] | 5144 | #ifdef CONFIG_OMAP2_DSS_COLLECT_IRQ_STATS |
Archit Taneja | f1da39d | 2011-05-12 17:26:27 +0530 | [diff] [blame] | 5145 | spin_lock_init(&dsi->irq_stats_lock); |
| 5146 | dsi->irq_stats.last_reset = jiffies; |
Tomi Valkeinen | dfc0fd8 | 2009-12-17 14:35:21 +0200 | [diff] [blame] | 5147 | #endif |
| 5148 | |
Archit Taneja | f1da39d | 2011-05-12 17:26:27 +0530 | [diff] [blame] | 5149 | mutex_init(&dsi->lock); |
| 5150 | sema_init(&dsi->bus_lock, 1); |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 5151 | |
Archit Taneja | f1da39d | 2011-05-12 17:26:27 +0530 | [diff] [blame] | 5152 | INIT_DELAYED_WORK_DEFERRABLE(&dsi->framedone_timeout_work, |
| 5153 | dsi_framedone_timeout_work_callback); |
| 5154 | |
| 5155 | #ifdef DSI_CATCH_MISSING_TE |
| 5156 | init_timer(&dsi->te_timer); |
| 5157 | dsi->te_timer.function = dsi_te_timeout; |
| 5158 | dsi->te_timer.data = 0; |
| 5159 | #endif |
| 5160 | dsi_mem = platform_get_resource(dsi->pdev, IORESOURCE_MEM, 0); |
| 5161 | if (!dsi_mem) { |
| 5162 | DSSERR("can't get IORESOURCE_MEM DSI\n"); |
Tomi Valkeinen | cd3b344 | 2012-01-25 13:31:04 +0200 | [diff] [blame] | 5163 | return -EINVAL; |
archit taneja | affe360 | 2011-02-23 08:41:03 +0000 | [diff] [blame] | 5164 | } |
Tomi Valkeinen | cd3b344 | 2012-01-25 13:31:04 +0200 | [diff] [blame] | 5165 | |
Julia Lawall | 6e2a14d | 2012-01-24 14:00:45 +0100 | [diff] [blame] | 5166 | dsi->base = devm_ioremap(&dsidev->dev, dsi_mem->start, |
| 5167 | resource_size(dsi_mem)); |
Archit Taneja | f1da39d | 2011-05-12 17:26:27 +0530 | [diff] [blame] | 5168 | if (!dsi->base) { |
| 5169 | DSSERR("can't ioremap DSI\n"); |
Tomi Valkeinen | cd3b344 | 2012-01-25 13:31:04 +0200 | [diff] [blame] | 5170 | return -ENOMEM; |
Archit Taneja | f1da39d | 2011-05-12 17:26:27 +0530 | [diff] [blame] | 5171 | } |
Tomi Valkeinen | cd3b344 | 2012-01-25 13:31:04 +0200 | [diff] [blame] | 5172 | |
Archit Taneja | f1da39d | 2011-05-12 17:26:27 +0530 | [diff] [blame] | 5173 | dsi->irq = platform_get_irq(dsi->pdev, 0); |
| 5174 | if (dsi->irq < 0) { |
| 5175 | DSSERR("platform_get_irq failed\n"); |
Tomi Valkeinen | cd3b344 | 2012-01-25 13:31:04 +0200 | [diff] [blame] | 5176 | return -ENODEV; |
Archit Taneja | f1da39d | 2011-05-12 17:26:27 +0530 | [diff] [blame] | 5177 | } |
archit taneja | affe360 | 2011-02-23 08:41:03 +0000 | [diff] [blame] | 5178 | |
Julia Lawall | 6e2a14d | 2012-01-24 14:00:45 +0100 | [diff] [blame] | 5179 | r = devm_request_irq(&dsidev->dev, dsi->irq, omap_dsi_irq_handler, |
| 5180 | IRQF_SHARED, dev_name(&dsidev->dev), dsi->pdev); |
archit taneja | affe360 | 2011-02-23 08:41:03 +0000 | [diff] [blame] | 5181 | if (r < 0) { |
| 5182 | DSSERR("request_irq failed\n"); |
Tomi Valkeinen | cd3b344 | 2012-01-25 13:31:04 +0200 | [diff] [blame] | 5183 | return r; |
archit taneja | affe360 | 2011-02-23 08:41:03 +0000 | [diff] [blame] | 5184 | } |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 5185 | |
Archit Taneja | 5ee3c14 | 2011-03-02 12:35:53 +0530 | [diff] [blame] | 5186 | /* DSI VCs initialization */ |
Archit Taneja | f1da39d | 2011-05-12 17:26:27 +0530 | [diff] [blame] | 5187 | for (i = 0; i < ARRAY_SIZE(dsi->vc); i++) { |
Archit Taneja | d604914 | 2011-08-22 11:58:08 +0530 | [diff] [blame] | 5188 | dsi->vc[i].source = DSI_VC_SOURCE_L4; |
Archit Taneja | f1da39d | 2011-05-12 17:26:27 +0530 | [diff] [blame] | 5189 | dsi->vc[i].dssdev = NULL; |
| 5190 | dsi->vc[i].vc_id = 0; |
Archit Taneja | 5ee3c14 | 2011-03-02 12:35:53 +0530 | [diff] [blame] | 5191 | } |
| 5192 | |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 5193 | dsi_calc_clock_param_ranges(dsidev); |
Taneja, Archit | 4964111 | 2011-03-14 23:28:23 -0500 | [diff] [blame] | 5194 | |
Tomi Valkeinen | cd3b344 | 2012-01-25 13:31:04 +0200 | [diff] [blame] | 5195 | r = dsi_get_clocks(dsidev); |
| 5196 | if (r) |
| 5197 | return r; |
| 5198 | |
| 5199 | pm_runtime_enable(&dsidev->dev); |
| 5200 | |
Tomi Valkeinen | 4fbafaf | 2011-05-27 10:52:19 +0300 | [diff] [blame] | 5201 | r = dsi_runtime_get(dsidev); |
| 5202 | if (r) |
Tomi Valkeinen | cd3b344 | 2012-01-25 13:31:04 +0200 | [diff] [blame] | 5203 | goto err_runtime_get; |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 5204 | |
Archit Taneja | a72b64b | 2011-05-12 17:26:26 +0530 | [diff] [blame] | 5205 | rev = dsi_read_reg(dsidev, DSI_REVISION); |
| 5206 | dev_dbg(&dsidev->dev, "OMAP DSI rev %d.%d\n", |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 5207 | FLD_GET(rev, 7, 4), FLD_GET(rev, 3, 0)); |
| 5208 | |
Tomi Valkeinen | d982085 | 2011-10-12 15:05:59 +0300 | [diff] [blame] | 5209 | /* DSI on OMAP3 doesn't have register DSI_GNQ, set number |
| 5210 | * of data to 3 by default */ |
| 5211 | if (dss_has_feature(FEAT_DSI_GNQ)) |
| 5212 | /* NB_DATA_LANES */ |
| 5213 | dsi->num_lanes_supported = 1 + REG_GET(dsidev, DSI_GNQ, 11, 9); |
| 5214 | else |
| 5215 | dsi->num_lanes_supported = 3; |
Archit Taneja | 75d7247 | 2011-05-16 15:17:08 +0530 | [diff] [blame] | 5216 | |
Tomi Valkeinen | 38f3daf | 2012-05-02 14:55:12 +0300 | [diff] [blame] | 5217 | dsi_probe_pdata(dsidev); |
Tomi Valkeinen | 35deca3 | 2012-03-01 15:45:53 +0200 | [diff] [blame] | 5218 | |
Tomi Valkeinen | 4fbafaf | 2011-05-27 10:52:19 +0300 | [diff] [blame] | 5219 | dsi_runtime_put(dsidev); |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 5220 | |
Tomi Valkeinen | 11ee960 | 2012-03-09 16:07:39 +0200 | [diff] [blame] | 5221 | if (dsi->module_id == 0) |
Tomi Valkeinen | e40402c | 2012-03-02 18:01:07 +0200 | [diff] [blame] | 5222 | dss_debugfs_create_file("dsi1_regs", dsi1_dump_regs); |
Tomi Valkeinen | 11ee960 | 2012-03-09 16:07:39 +0200 | [diff] [blame] | 5223 | else if (dsi->module_id == 1) |
Tomi Valkeinen | e40402c | 2012-03-02 18:01:07 +0200 | [diff] [blame] | 5224 | dss_debugfs_create_file("dsi2_regs", dsi2_dump_regs); |
| 5225 | |
| 5226 | #ifdef CONFIG_OMAP2_DSS_COLLECT_IRQ_STATS |
Tomi Valkeinen | 11ee960 | 2012-03-09 16:07:39 +0200 | [diff] [blame] | 5227 | if (dsi->module_id == 0) |
Tomi Valkeinen | e40402c | 2012-03-02 18:01:07 +0200 | [diff] [blame] | 5228 | dss_debugfs_create_file("dsi1_irqs", dsi1_dump_irqs); |
Tomi Valkeinen | 11ee960 | 2012-03-09 16:07:39 +0200 | [diff] [blame] | 5229 | else if (dsi->module_id == 1) |
Tomi Valkeinen | e40402c | 2012-03-02 18:01:07 +0200 | [diff] [blame] | 5230 | dss_debugfs_create_file("dsi2_irqs", dsi2_dump_irqs); |
| 5231 | #endif |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 5232 | return 0; |
Tomi Valkeinen | 4fbafaf | 2011-05-27 10:52:19 +0300 | [diff] [blame] | 5233 | |
Tomi Valkeinen | cd3b344 | 2012-01-25 13:31:04 +0200 | [diff] [blame] | 5234 | err_runtime_get: |
Tomi Valkeinen | 4fbafaf | 2011-05-27 10:52:19 +0300 | [diff] [blame] | 5235 | pm_runtime_disable(&dsidev->dev); |
Tomi Valkeinen | cd3b344 | 2012-01-25 13:31:04 +0200 | [diff] [blame] | 5236 | dsi_put_clocks(dsidev); |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 5237 | return r; |
| 5238 | } |
| 5239 | |
Tomi Valkeinen | 6e7e8f0 | 2012-02-17 17:41:13 +0200 | [diff] [blame] | 5240 | static int __exit omap_dsihw_remove(struct platform_device *dsidev) |
Tomi Valkeinen | 3de7a1d | 2009-10-28 11:59:56 +0200 | [diff] [blame] | 5241 | { |
Archit Taneja | f1da39d | 2011-05-12 17:26:27 +0530 | [diff] [blame] | 5242 | struct dsi_data *dsi = dsi_get_dsidrv_data(dsidev); |
| 5243 | |
Tomi Valkeinen | b98482e | 2011-05-16 13:52:51 +0300 | [diff] [blame] | 5244 | WARN_ON(dsi->scp_clk_refcount > 0); |
| 5245 | |
Tomi Valkeinen | 35deca3 | 2012-03-01 15:45:53 +0200 | [diff] [blame] | 5246 | omap_dss_unregister_child_devices(&dsidev->dev); |
| 5247 | |
Tomi Valkeinen | 4fbafaf | 2011-05-27 10:52:19 +0300 | [diff] [blame] | 5248 | pm_runtime_disable(&dsidev->dev); |
| 5249 | |
| 5250 | dsi_put_clocks(dsidev); |
| 5251 | |
Archit Taneja | f1da39d | 2011-05-12 17:26:27 +0530 | [diff] [blame] | 5252 | if (dsi->vdds_dsi_reg != NULL) { |
| 5253 | if (dsi->vdds_dsi_enabled) { |
| 5254 | regulator_disable(dsi->vdds_dsi_reg); |
| 5255 | dsi->vdds_dsi_enabled = false; |
Tomi Valkeinen | 88257b2 | 2010-12-20 16:26:22 +0200 | [diff] [blame] | 5256 | } |
| 5257 | |
Archit Taneja | f1da39d | 2011-05-12 17:26:27 +0530 | [diff] [blame] | 5258 | regulator_put(dsi->vdds_dsi_reg); |
| 5259 | dsi->vdds_dsi_reg = NULL; |
Senthilvadivu Guruswamy | c8aac01 | 2011-01-24 06:22:02 +0000 | [diff] [blame] | 5260 | } |
| 5261 | |
Senthilvadivu Guruswamy | c8aac01 | 2011-01-24 06:22:02 +0000 | [diff] [blame] | 5262 | return 0; |
| 5263 | } |
| 5264 | |
Tomi Valkeinen | 4fbafaf | 2011-05-27 10:52:19 +0300 | [diff] [blame] | 5265 | static int dsi_runtime_suspend(struct device *dev) |
| 5266 | { |
Tomi Valkeinen | 4fbafaf | 2011-05-27 10:52:19 +0300 | [diff] [blame] | 5267 | dispc_runtime_put(); |
Tomi Valkeinen | 4fbafaf | 2011-05-27 10:52:19 +0300 | [diff] [blame] | 5268 | |
| 5269 | return 0; |
| 5270 | } |
| 5271 | |
| 5272 | static int dsi_runtime_resume(struct device *dev) |
| 5273 | { |
Tomi Valkeinen | 4fbafaf | 2011-05-27 10:52:19 +0300 | [diff] [blame] | 5274 | int r; |
| 5275 | |
Tomi Valkeinen | 4fbafaf | 2011-05-27 10:52:19 +0300 | [diff] [blame] | 5276 | r = dispc_runtime_get(); |
| 5277 | if (r) |
Tomi Valkeinen | 852f083 | 2012-02-17 17:58:04 +0200 | [diff] [blame] | 5278 | return r; |
Tomi Valkeinen | 4fbafaf | 2011-05-27 10:52:19 +0300 | [diff] [blame] | 5279 | |
Tomi Valkeinen | 4fbafaf | 2011-05-27 10:52:19 +0300 | [diff] [blame] | 5280 | return 0; |
Tomi Valkeinen | 4fbafaf | 2011-05-27 10:52:19 +0300 | [diff] [blame] | 5281 | } |
| 5282 | |
| 5283 | static const struct dev_pm_ops dsi_pm_ops = { |
| 5284 | .runtime_suspend = dsi_runtime_suspend, |
| 5285 | .runtime_resume = dsi_runtime_resume, |
| 5286 | }; |
| 5287 | |
Tomi Valkeinen | 7c68dd9 | 2011-08-03 14:00:57 +0300 | [diff] [blame] | 5288 | static struct platform_driver omap_dsihw_driver = { |
Tomi Valkeinen | 6e7e8f0 | 2012-02-17 17:41:13 +0200 | [diff] [blame] | 5289 | .remove = __exit_p(omap_dsihw_remove), |
Senthilvadivu Guruswamy | c8aac01 | 2011-01-24 06:22:02 +0000 | [diff] [blame] | 5290 | .driver = { |
Tomi Valkeinen | 7c68dd9 | 2011-08-03 14:00:57 +0300 | [diff] [blame] | 5291 | .name = "omapdss_dsi", |
Senthilvadivu Guruswamy | c8aac01 | 2011-01-24 06:22:02 +0000 | [diff] [blame] | 5292 | .owner = THIS_MODULE, |
Tomi Valkeinen | 4fbafaf | 2011-05-27 10:52:19 +0300 | [diff] [blame] | 5293 | .pm = &dsi_pm_ops, |
Senthilvadivu Guruswamy | c8aac01 | 2011-01-24 06:22:02 +0000 | [diff] [blame] | 5294 | }, |
| 5295 | }; |
| 5296 | |
Tomi Valkeinen | 6e7e8f0 | 2012-02-17 17:41:13 +0200 | [diff] [blame] | 5297 | int __init dsi_init_platform_driver(void) |
Senthilvadivu Guruswamy | c8aac01 | 2011-01-24 06:22:02 +0000 | [diff] [blame] | 5298 | { |
Tomi Valkeinen | 61055d4 | 2012-03-07 12:53:38 +0200 | [diff] [blame] | 5299 | return platform_driver_probe(&omap_dsihw_driver, omap_dsihw_probe); |
Senthilvadivu Guruswamy | c8aac01 | 2011-01-24 06:22:02 +0000 | [diff] [blame] | 5300 | } |
| 5301 | |
Tomi Valkeinen | 6e7e8f0 | 2012-02-17 17:41:13 +0200 | [diff] [blame] | 5302 | void __exit dsi_uninit_platform_driver(void) |
Senthilvadivu Guruswamy | c8aac01 | 2011-01-24 06:22:02 +0000 | [diff] [blame] | 5303 | { |
Tomi Valkeinen | 04c742c | 2012-02-23 15:32:37 +0200 | [diff] [blame] | 5304 | platform_driver_unregister(&omap_dsihw_driver); |
Senthilvadivu Guruswamy | c8aac01 | 2011-01-24 06:22:02 +0000 | [diff] [blame] | 5305 | } |