17 #include <linux/i2c.h>
21 #include <linux/module.h>
24 #include <linux/slab.h>
26 #include <mach/gpio.h>
66 ret = (ret & ~mask) | (value & mask);
70 static inline int sii9234_readb_idx(
struct i2c_client *client,
int addr)
82 static inline int sii9234_writeb_idx(
struct i2c_client *client,
int addr,
96 static inline int sii9234_writeb_idx_mask(
struct i2c_client *client,
int addr,
101 ret = sii9234_readb_idx(client, addr);
104 ret = (ret & ~mask) | (value & mask);
105 return sii9234_writeb_idx(client, addr, ret);
122 ret = sii9234_writeb(client, 0xc7, 0);
124 dev_err(dev,
"failed to set TTPI mode\n");
127 for (tries = 0; tries < 100 ; ++tries) {
128 ret = sii9234_readb(client, 0x1b);
132 dev_err(dev,
"failed to reset device\n");
138 dev_err(dev,
"maximal number of tries reached\n");
145 static int sii9234_verify_version(
struct i2c_client *client)
150 family = sii9234_readb(client, 0x1b);
151 rev = sii9234_readb(client, 0x1c) & 0x0f;
152 tpi_rev = sii9234_readb(client, 0x1d) & 0x7f;
153 dev_id = sii9234_readb_idx(client, 0x0103);
154 sub_id = sii9234_readb_idx(client, 0x0102);
155 hdcp = sii9234_readb(client, 0x30);
157 if (family < 0 || rev < 0 || tpi_rev < 0 || dev_id < 0 ||
158 sub_id < 0 || hdcp < 0) {
159 dev_err(dev,
"failed to read chip's version\n");
163 id = (dev_id << 8) | sub_id;
165 dev_info(dev,
"chip: SiL%02x family: %02x, rev: %02x\n",
167 dev_info(dev,
"tpi_rev:%02x, hdcp: %02x\n", tpi_rev, hdcp);
169 dev_err(dev,
"not supported chip\n");
178 { 0x01, 0x05, 0x04 },
179 { 0x01, 0x08, 0x35 },
180 { 0x01, 0x0d, 0x1c },
181 { 0x01, 0x2b, 0x01 },
182 { 0x01, 0x79, 0x40 },
183 { 0x01, 0x80, 0x34 },
184 { 0x01, 0x90, 0x27 },
185 { 0x01, 0x91, 0xe5 },
186 { 0x01, 0x92, 0x46 },
187 { 0x01, 0x93, 0xdc },
188 { 0x01, 0x94, 0x66 },
189 { 0x01, 0x95, 0x31 },
190 { 0x01, 0x96, 0x22 },
191 { 0x01, 0xa0, 0x10 },
192 { 0x01, 0xa1, 0xfc },
193 { 0x01, 0xa3, 0xfa },
194 { 0x01, 0xa5, 0x80 },
195 { 0x01, 0xa6, 0x0c },
196 { 0x02, 0x3d, 0x3f },
197 { 0x03, 0x00, 0x00 },
198 { 0x03, 0x11, 0x01 },
199 { 0x03, 0x12, 0x15 },
200 { 0x03, 0x13, 0x60 },
201 { 0x03, 0x14, 0xf0 },
202 { 0x03, 0x17, 0x07 },
203 { 0x03, 0x1a, 0x20 },
204 { 0x03, 0x22, 0xe0 },
205 { 0x03, 0x23, 0xc0 },
206 { 0x03, 0x24, 0xa0 },
207 { 0x03, 0x25, 0x80 },
208 { 0x03, 0x26, 0x60 },
209 { 0x03, 0x27, 0x40 },
210 { 0x03, 0x28, 0x20 },
211 { 0x03, 0x29, 0x00 },
212 { 0x03, 0x31, 0x0b },
213 { 0x03, 0x45, 0x06 },
214 { 0x03, 0x4b, 0x06 },
215 { 0x03, 0x4c, 0xa0 },
216 { 0x03, 0x4d, 0x02 },
225 int addr = (data[
i][0] << 8) | data[i][1];
226 ret = sii9234_writeb_idx(client, addr, data[i][2]);
233 static int sii9234_runtime_suspend(
struct device *dev)
241 sii9234_writeb_mask(client, 0x1e, 3, 3);
247 static int sii9234_runtime_resume(
struct device *dev)
257 ret = sii9234_reset(ctx);
262 ret = sii9234_writeb_mask(client, 0x1e, 1, 0);
265 ret = sii9234_set_internal(ctx);
272 dev_err(dev,
"failed to resume\n");
278 static const struct dev_pm_ops sii9234_pm_ops = {
279 .runtime_suspend = sii9234_runtime_suspend,
280 .runtime_resume = sii9234_runtime_resume,
283 static int sii9234_s_power(
struct v4l2_subdev *sd,
int on)
289 ret = pm_runtime_get_sync(&ctx->
client->dev);
291 ret = pm_runtime_put(&ctx->
client->dev);
301 sii9234_writeb_mask(ctx->
client, 0x1a, enable ? 0 : ~0 , 1 << 4);
306 .s_power = sii9234_s_power,
310 .s_stream = sii9234_s_stream,
314 .core = &sii9234_core_ops,
315 .video = &sii9234_video_ops,
328 dev_err(dev,
"out of memory\n");
335 if (IS_ERR(ctx->
power)) {
336 dev_err(dev,
"failed to acquire regulator hdmi-en\n");
337 return PTR_ERR(ctx->
power);
343 dev_err(dev,
"failed to acquire MHL_RST gpio\n");
352 ret = pm_runtime_get_sync(dev);
357 ret = sii9234_verify_version(client);
364 dev_info(dev,
"probe successful\n");
369 pm_runtime_put_sync(dev);
372 pm_runtime_disable(dev);
376 dev_err(dev,
"probe failed\n");
384 struct v4l2_subdev *sd = i2c_get_clientdata(client);
387 pm_runtime_disable(dev);
390 dev_info(dev,
"remove successful\n");
406 .pm = &sii9234_pm_ops,
408 .probe = sii9234_probe,
410 .id_table = sii9234_id,