|
32 | 32 | #define OV8856_MODE_STANDBY 0x00
|
33 | 33 | #define OV8856_MODE_STREAMING 0x01
|
34 | 34 |
|
| 35 | +/* module revisions */ |
| 36 | +#define OV8856_2A_MODULE 0x01 |
| 37 | +#define OV8856_1B_MODULE 0x02 |
| 38 | + |
| 39 | +/* the OTP read-out buffer is at 0x7000 and 0xf is the offset |
| 40 | + * of the byte in the OTP that means the module revision |
| 41 | + */ |
| 42 | +#define OV8856_MODULE_REVISION 0x700f |
| 43 | +#define OV8856_OTP_MODE_CTRL 0x3d84 |
| 44 | +#define OV8856_OTP_LOAD_CTRL 0x3d81 |
| 45 | +#define OV8856_OTP_MODE_AUTO 0x00 |
| 46 | +#define OV8856_OTP_LOAD_CTRL_ENABLE BIT(0) |
| 47 | + |
35 | 48 | /* vertical-timings from sensor */
|
36 | 49 | #define OV8856_REG_VTS 0x380e
|
37 | 50 | #define OV8856_VTS_MAX 0x7fff
|
@@ -1156,6 +1169,46 @@ static int ov8856_identify_module(struct ov8856 *ov8856)
|
1156 | 1169 | return -ENXIO;
|
1157 | 1170 | }
|
1158 | 1171 |
|
| 1172 | + ret = ov8856_write_reg(ov8856, OV8856_REG_MODE_SELECT, |
| 1173 | + OV8856_REG_VALUE_08BIT, OV8856_MODE_STREAMING); |
| 1174 | + if (ret) |
| 1175 | + return ret; |
| 1176 | + |
| 1177 | + ret = ov8856_write_reg(ov8856, OV8856_OTP_MODE_CTRL, |
| 1178 | + OV8856_REG_VALUE_08BIT, OV8856_OTP_MODE_AUTO); |
| 1179 | + if (ret) { |
| 1180 | + dev_err(&client->dev, "failed to set otp mode"); |
| 1181 | + return ret; |
| 1182 | + } |
| 1183 | + |
| 1184 | + ret = ov8856_write_reg(ov8856, OV8856_OTP_LOAD_CTRL, |
| 1185 | + OV8856_REG_VALUE_08BIT, |
| 1186 | + OV8856_OTP_LOAD_CTRL_ENABLE); |
| 1187 | + if (ret) { |
| 1188 | + dev_err(&client->dev, "failed to enable load control"); |
| 1189 | + return ret; |
| 1190 | + } |
| 1191 | + |
| 1192 | + ret = ov8856_read_reg(ov8856, OV8856_MODULE_REVISION, |
| 1193 | + OV8856_REG_VALUE_08BIT, &val); |
| 1194 | + if (ret) { |
| 1195 | + dev_err(&client->dev, "failed to read module revision"); |
| 1196 | + return ret; |
| 1197 | + } |
| 1198 | + |
| 1199 | + dev_info(&client->dev, "OV8856 revision %x (%s) at address 0x%02x\n", |
| 1200 | + val, |
| 1201 | + val == OV8856_2A_MODULE ? "2A" : |
| 1202 | + val == OV8856_1B_MODULE ? "1B" : "unknown revision", |
| 1203 | + client->addr); |
| 1204 | + |
| 1205 | + ret = ov8856_write_reg(ov8856, OV8856_REG_MODE_SELECT, |
| 1206 | + OV8856_REG_VALUE_08BIT, OV8856_MODE_STANDBY); |
| 1207 | + if (ret) { |
| 1208 | + dev_err(&client->dev, "failed to exit streaming mode"); |
| 1209 | + return ret; |
| 1210 | + } |
| 1211 | + |
1159 | 1212 | return 0;
|
1160 | 1213 | }
|
1161 | 1214 |
|
|
0 commit comments