.. | .. |
---|
2 | 2 | /* |
---|
3 | 3 | * max96722 GMSL2/GMSL1 to CSI-2 Deserializer driver |
---|
4 | 4 | * |
---|
5 | | - * Copyright (C) 2022 Rockchip Electronics Co., Ltd. |
---|
| 5 | + * Copyright (C) 2023 Rockchip Electronics Co., Ltd. |
---|
6 | 6 | * |
---|
7 | 7 | * V0.0X01.0X00 first version. |
---|
| 8 | + * V1.0X00.0X00 Support New Driver Framework. |
---|
| 9 | + * V1.0X01.0X00 serdes read /write api depend on i2c id index. |
---|
8 | 10 | * |
---|
9 | 11 | */ |
---|
10 | 12 | |
---|
11 | 13 | #include <linux/clk.h> |
---|
12 | 14 | #include <linux/device.h> |
---|
13 | 15 | #include <linux/delay.h> |
---|
| 16 | +#include <linux/iopoll.h> |
---|
14 | 17 | #include <linux/gpio/consumer.h> |
---|
| 18 | +#include <linux/pinctrl/consumer.h> |
---|
15 | 19 | #include <linux/i2c.h> |
---|
| 20 | +#include <linux/regmap.h> |
---|
16 | 21 | #include <linux/module.h> |
---|
17 | 22 | #include <linux/pm_runtime.h> |
---|
18 | 23 | #include <linux/regulator/consumer.h> |
---|
.. | .. |
---|
21 | 26 | #include <linux/version.h> |
---|
22 | 27 | #include <linux/compat.h> |
---|
23 | 28 | #include <linux/rk-camera-module.h> |
---|
| 29 | +#include <linux/of_graph.h> |
---|
24 | 30 | #include <media/media-entity.h> |
---|
25 | 31 | #include <media/v4l2-async.h> |
---|
26 | 32 | #include <media/v4l2-ctrls.h> |
---|
27 | 33 | #include <media/v4l2-subdev.h> |
---|
28 | | -#include <linux/pinctrl/consumer.h> |
---|
| 34 | +#include <media/v4l2-ctrls.h> |
---|
| 35 | +#include <media/v4l2-fwnode.h> |
---|
| 36 | +#include <media/v4l2-subdev.h> |
---|
29 | 37 | |
---|
30 | | -#define DRIVER_VERSION KERNEL_VERSION(0, 0x01, 0x00) |
---|
| 38 | +#define DRIVER_VERSION KERNEL_VERSION(1, 0x01, 0x00) |
---|
31 | 39 | |
---|
32 | 40 | #ifndef V4L2_CID_DIGITAL_GAIN |
---|
33 | 41 | #define V4L2_CID_DIGITAL_GAIN V4L2_CID_GAIN |
---|
34 | 42 | #endif |
---|
35 | 43 | |
---|
36 | | -#define MAX96722_LINK_FREQ_400MHZ 400000000UL |
---|
37 | | -/* pixel rate = link frequency * 2 * lanes / BITS_PER_SAMPLE */ |
---|
38 | | -#define MAX96722_PIXEL_RATE (MAX96722_LINK_FREQ_400MHZ * 2LL * 4LL / 24LL) |
---|
39 | | -#define MAX96722_XVCLK_FREQ 24000000 |
---|
| 44 | +#define MAX96722_LINK_FREQ_MHZ(x) ((x) * 1000000UL) |
---|
| 45 | +#define MAX96722_XVCLK_FREQ 25000000 |
---|
40 | 46 | |
---|
41 | | -#define CHIP_ID 0xA1 |
---|
| 47 | +#define MAX96722_CHIP_ID 0xA1 |
---|
42 | 48 | #define MAX96722_REG_CHIP_ID 0x0D |
---|
43 | 49 | |
---|
44 | | -#define MAX96722_REG_CTRL_MODE 0x08a0 |
---|
45 | | -#define MAX96722_MODE_SW_STANDBY 0x4 |
---|
46 | | -#define MAX96722_MODE_STREAMING 0xa4 |
---|
| 50 | +#define MAX96715_CHIP_ID 0x45 |
---|
| 51 | +#define MAX96715_REG_CHIP_ID 0x1E |
---|
47 | 52 | |
---|
48 | | -#define MAX96722_REMOTE_CTRL 0x0003 |
---|
49 | | -#define MAX96722_REMOTE_DISABLE 0xFF |
---|
| 53 | +#define MAX9295_CHIP_ID 0x91 |
---|
| 54 | +#define MAX9295_REG_CHIP_ID 0x0D |
---|
50 | 55 | |
---|
51 | | -#define REG_NULL 0xFFFF |
---|
| 56 | +#define MAX96717_CHIP_ID 0xBF |
---|
| 57 | +#define MAX96717_REG_CHIP_ID 0x0D |
---|
52 | 58 | |
---|
53 | | -#define MAX96722_LANES 4 |
---|
| 59 | +/* max96722->link mask: link type = bit[7:4], link mask = bit[3:0] */ |
---|
| 60 | +#define MAXIM_GMSL_TYPE_LINK_A BIT(4) |
---|
| 61 | +#define MAXIM_GMSL_TYPE_LINK_B BIT(5) |
---|
| 62 | +#define MAXIM_GMSL_TYPE_LINK_C BIT(6) |
---|
| 63 | +#define MAXIM_GMSL_TYPE_LINK_D BIT(7) |
---|
| 64 | +#define MAXIM_GMSL_TYPE_MASK 0xF0 /* bit[7:4], GMSL link type: 0 = GMSL1, 1 = GMSL2 */ |
---|
| 65 | + |
---|
| 66 | +#define MAXIM_GMSL_LOCK_LINK_A BIT(0) |
---|
| 67 | +#define MAXIM_GMSL_LOCK_LINK_B BIT(1) |
---|
| 68 | +#define MAXIM_GMSL_LOCK_LINK_C BIT(2) |
---|
| 69 | +#define MAXIM_GMSL_LOCK_LINK_D BIT(3) |
---|
| 70 | +#define MAXIM_GMSL_LOCK_MASK 0x0F /* bit[3:0], GMSL link mask: 1 = disable, 1 = enable */ |
---|
| 71 | + |
---|
| 72 | +#define MAXIM_FORCE_ALL_CLOCK_EN 1 /* 1: enable, 0: disable */ |
---|
54 | 73 | |
---|
55 | 74 | #define OF_CAMERA_PINCTRL_STATE_DEFAULT "rockchip,camera_default" |
---|
56 | 75 | #define OF_CAMERA_PINCTRL_STATE_SLEEP "rockchip,camera_sleep" |
---|
57 | 76 | |
---|
58 | | -#define MAX96722_REG_VALUE_08BIT 1 |
---|
59 | | -#define MAX96722_REG_VALUE_16BIT 2 |
---|
60 | | -#define MAX96722_REG_VALUE_24BIT 3 |
---|
61 | | - |
---|
62 | 77 | #define MAX96722_NAME "max96722" |
---|
63 | | -#define MAX96722_MEDIA_BUS_FMT MEDIA_BUS_FMT_RGB888_1X24 |
---|
64 | 78 | |
---|
65 | | -static const char * const max96722_supply_names[] = { |
---|
66 | | - "avdd", /* Analog power */ |
---|
67 | | - "dovdd", /* Digital I/O power */ |
---|
68 | | - "dvdd", /* Digital core power */ |
---|
| 79 | +#define REG_NULL 0xFFFF |
---|
| 80 | + |
---|
| 81 | +/* register length: 8bit or 16bit */ |
---|
| 82 | +#define DEV_REG_LENGTH_08BITS 1 |
---|
| 83 | +#define DEV_REG_LENGTH_16BITS 2 |
---|
| 84 | + |
---|
| 85 | +/* register value: 8bit or 16bit or 24bit */ |
---|
| 86 | +#define DEV_REG_VALUE_08BITS 1 |
---|
| 87 | +#define DEV_REG_VALUE_16BITS 2 |
---|
| 88 | +#define DEV_REG_VALUE_24BITS 3 |
---|
| 89 | + |
---|
| 90 | +/* i2c device default address */ |
---|
| 91 | +#define SER_I2C_ADDR (0x40) |
---|
| 92 | +#define CAM_I2C_ADDR (0x30) |
---|
| 93 | + |
---|
| 94 | +/* Maxim Serdes I2C Device ID */ |
---|
| 95 | +enum { |
---|
| 96 | + I2C_DEV_DES = 0, |
---|
| 97 | + I2C_DEV_SER, |
---|
| 98 | + I2C_DEV_CAM, |
---|
| 99 | + I2C_DEV_MAX |
---|
69 | 100 | }; |
---|
70 | 101 | |
---|
71 | | -#define MAX96722_NUM_SUPPLIES ARRAY_SIZE(max96722_supply_names) |
---|
| 102 | + |
---|
| 103 | +static const char *const max96722_supply_names[] = { |
---|
| 104 | + "avdd", /* Analog power */ |
---|
| 105 | + "dovdd", /* Digital I/O power */ |
---|
| 106 | + "dvdd", /* Digital core power */ |
---|
| 107 | +}; |
---|
| 108 | + |
---|
| 109 | +#define MAX96722_NUM_SUPPLIES ARRAY_SIZE(max96722_supply_names) |
---|
72 | 110 | |
---|
73 | 111 | struct regval { |
---|
74 | | - u16 i2c_addr; |
---|
75 | | - u16 addr; |
---|
| 112 | + u16 i2c_id; |
---|
| 113 | + u16 reg_len; |
---|
| 114 | + u16 reg; |
---|
76 | 115 | u8 val; |
---|
| 116 | + u8 mask; |
---|
77 | 117 | u16 delay; |
---|
78 | 118 | }; |
---|
79 | 119 | |
---|
.. | .. |
---|
85 | 125 | u32 vts_def; |
---|
86 | 126 | u32 exp_def; |
---|
87 | 127 | u32 link_freq_idx; |
---|
| 128 | + u32 bus_fmt; |
---|
88 | 129 | u32 bpp; |
---|
89 | 130 | const struct regval *reg_list; |
---|
| 131 | + u32 vc[PAD_MAX]; |
---|
90 | 132 | }; |
---|
91 | 133 | |
---|
92 | 134 | struct max96722 { |
---|
93 | | - struct i2c_client *client; |
---|
94 | | - struct clk *xvclk; |
---|
95 | | - struct gpio_desc *power_gpio; |
---|
96 | | - struct gpio_desc *reset_gpio; |
---|
97 | | - struct gpio_desc *pwdn_gpio; |
---|
| 135 | + struct i2c_client *client; |
---|
| 136 | + u16 i2c_addr[I2C_DEV_MAX]; |
---|
| 137 | + struct clk *xvclk; |
---|
| 138 | + struct gpio_desc *power_gpio; |
---|
| 139 | + struct gpio_desc *reset_gpio; |
---|
| 140 | + struct gpio_desc *pwdn_gpio; |
---|
| 141 | + struct gpio_desc *pocen_gpio; |
---|
| 142 | + struct gpio_desc *lock_gpio; |
---|
98 | 143 | struct regulator_bulk_data supplies[MAX96722_NUM_SUPPLIES]; |
---|
99 | 144 | |
---|
100 | | - struct pinctrl *pinctrl; |
---|
101 | | - struct pinctrl_state *pins_default; |
---|
102 | | - struct pinctrl_state *pins_sleep; |
---|
| 145 | + struct pinctrl *pinctrl; |
---|
| 146 | + struct pinctrl_state *pins_default; |
---|
| 147 | + struct pinctrl_state *pins_sleep; |
---|
103 | 148 | |
---|
104 | | - struct v4l2_subdev subdev; |
---|
105 | | - struct media_pad pad; |
---|
| 149 | + struct v4l2_subdev subdev; |
---|
| 150 | + struct media_pad pad; |
---|
106 | 151 | struct v4l2_ctrl_handler ctrl_handler; |
---|
107 | | - struct v4l2_ctrl *exposure; |
---|
108 | | - struct v4l2_ctrl *anal_gain; |
---|
109 | | - struct v4l2_ctrl *digi_gain; |
---|
110 | | - struct v4l2_ctrl *hblank; |
---|
111 | | - struct v4l2_ctrl *vblank; |
---|
112 | | - struct v4l2_ctrl *pixel_rate; |
---|
113 | | - struct v4l2_ctrl *link_freq; |
---|
114 | | - struct v4l2_ctrl *test_pattern; |
---|
115 | | - struct mutex mutex; |
---|
116 | | - bool streaming; |
---|
117 | | - bool power_on; |
---|
118 | | - bool hot_plug; |
---|
119 | | - u8 is_reset; |
---|
| 152 | + struct v4l2_ctrl *exposure; |
---|
| 153 | + struct v4l2_ctrl *anal_gain; |
---|
| 154 | + struct v4l2_ctrl *digi_gain; |
---|
| 155 | + struct v4l2_ctrl *hblank; |
---|
| 156 | + struct v4l2_ctrl *vblank; |
---|
| 157 | + struct v4l2_ctrl *pixel_rate; |
---|
| 158 | + struct v4l2_ctrl *link_freq; |
---|
| 159 | + struct v4l2_ctrl *test_pattern; |
---|
| 160 | + struct v4l2_fwnode_endpoint bus_cfg; |
---|
| 161 | + |
---|
| 162 | + struct mutex mutex; |
---|
| 163 | + bool streaming; |
---|
| 164 | + bool power_on; |
---|
| 165 | + bool hot_plug; |
---|
| 166 | + u8 is_reset; |
---|
| 167 | + int hot_plug_irq; |
---|
| 168 | + u32 link_mask; |
---|
| 169 | + const struct max96722_mode *supported_modes; |
---|
120 | 170 | const struct max96722_mode *cur_mode; |
---|
121 | | - u32 module_index; |
---|
122 | | - const char *module_facing; |
---|
123 | | - const char *module_name; |
---|
124 | | - const char *len_name; |
---|
| 171 | + u32 cfg_modes_num; |
---|
| 172 | + u32 module_index; |
---|
| 173 | + u32 auto_init_deskew_mask; |
---|
| 174 | + u32 frame_sync_period; |
---|
| 175 | + const char *module_facing; |
---|
| 176 | + const char *module_name; |
---|
| 177 | + const char *len_name; |
---|
| 178 | + struct regmap *regmap; |
---|
125 | 179 | }; |
---|
126 | 180 | |
---|
127 | | -#define to_max96722(sd) container_of(sd, struct max96722, subdev) |
---|
| 181 | +static const struct regmap_config max96722_regmap_config = { |
---|
| 182 | + .reg_bits = 16, |
---|
| 183 | + .val_bits = 8, |
---|
| 184 | + .max_register = 0x1F17, |
---|
| 185 | +}; |
---|
128 | 186 | |
---|
129 | | -static const struct regval max96722_mipi_init[] = { |
---|
130 | | - {0x6b, 0x0006, 0xF0, 0x00}, |
---|
131 | | - // Disable MIPI output |
---|
132 | | - {0x6b, 0x040B, 0x00, 0x00}, |
---|
133 | | - // RGB888 software override for all pipes since connected GMSL1 is under parallel mode |
---|
134 | | - {0x6b, 0x040B, 0xC0, 0x00}, //0b11000-000, bpp0=0x18 |
---|
135 | | - {0x6b, 0x040E, 0xA4, 0x00}, //0b10-100100, DT0=0x24 |
---|
136 | | - {0x6b, 0x040F, 0x04, 0x00}, //0b0000-0100, DT1=0x24 |
---|
137 | | - {0x6b, 0x0411, 0x18, 0x00}, //0b000-11000, bpp1=0x18 |
---|
138 | | - //Video pipe sel |
---|
139 | | - {0x6b, 0x00F0, 0x40, 0x00}, //LINKA-pipex=pipe0, LINKB-pipex=pipe1 |
---|
140 | | - // Send RGB888, FS, and FE from Pipe 0 to Controller 1 |
---|
141 | | - {0x6b, 0x090B, 0x07, 0x00}, // Enable 3 Mappings |
---|
142 | | - {0x6b, 0x092D, 0x15, 0x00}, //Map Data to Port A |
---|
143 | | - // For the following MSB 2 bits = VC, LSB 6 bits =DT |
---|
144 | | - {0x6b, 0x090D, 0x24, 0x00}, // SRC DT = RGB888 |
---|
145 | | - {0x6b, 0x090E, 0x24, 0x00}, // DEST DT = RGB888 |
---|
146 | | - {0x6b, 0x090F, 0x00, 0x00}, // SRC DT = Frame Start |
---|
147 | | - {0x6b, 0x0910, 0x00, 0x00}, // DEST DT = Frame Start |
---|
148 | | - {0x6b, 0x0911, 0x01, 0x00}, // SRC DT = Frame End |
---|
149 | | - {0x6b, 0x0912, 0x01, 0x00}, // DEST DT = Frame End |
---|
150 | | - //Send RGB888, FS, and FE from Pipe 1 to Controller 2 |
---|
151 | | - {0x6b, 0x094B, 0x07, 0x00}, |
---|
152 | | - {0x6b, 0x096D, 0xAA, 0x00}, // map to MIPI Controller 2 |
---|
153 | | - // For the following MSB 2 bits = VC, LSB 6 bits =DT |
---|
154 | | - {0x6b, 0x094D, 0x24, 0x00}, |
---|
155 | | - {0x6b, 0x094E, 0x24, 0x00}, // map to VC0 |
---|
156 | | - {0x6b, 0x094F, 0x00, 0x00}, // frame start |
---|
157 | | - {0x6b, 0x0950, 0x00, 0x00}, |
---|
158 | | - {0x6b, 0x0951, 0x01, 0x00}, |
---|
159 | | - {0x6b, 0x0952, 0x01, 0x00}, |
---|
| 187 | +static struct rkmodule_csi_dphy_param rk3588_dcphy_param = { |
---|
| 188 | + .vendor = PHY_VENDOR_SAMSUNG, |
---|
| 189 | + .lp_vol_ref = 3, |
---|
| 190 | + .lp_hys_sw = {3, 0, 0, 0}, |
---|
| 191 | + .lp_escclk_pol_sel = {1, 0, 0, 0}, |
---|
| 192 | + .skew_data_cal_clk = {0, 0, 0, 0}, |
---|
| 193 | + .clk_hs_term_sel = 2, |
---|
| 194 | + .data_hs_term_sel = {2, 2, 2, 2}, |
---|
| 195 | + .reserved = {0}, |
---|
| 196 | +}; |
---|
| 197 | + |
---|
| 198 | +/* Max96715 */ |
---|
| 199 | +static const struct regval max96722_mipi_4lane_1280x800_30fps[] = { |
---|
| 200 | + // Link A/B/C/D all use GMSL1, and disabled |
---|
| 201 | + { I2C_DEV_DES, 2, 0x0006, 0x00, 0x00, 0x00 }, // Link A/B/C/D: select GMSL1, Disabled |
---|
| 202 | + // Disable MIPI CSI output |
---|
| 203 | + { I2C_DEV_DES, 2, 0x040B, 0x00, 0x00, 0x00 }, // CSI_OUT_EN=0, CSI output disabled |
---|
| 204 | + // Increase CMU voltage |
---|
| 205 | + { I2C_DEV_DES, 2, 0x06C2, 0x10, 0x00, 0x0a }, // Increase CMU voltage to for wide temperature range |
---|
| 206 | + // VGAHiGain |
---|
| 207 | + { I2C_DEV_DES, 2, 0x14D1, 0x03, 0x00, 0x00 }, // VGAHiGain |
---|
| 208 | + { I2C_DEV_DES, 2, 0x15D1, 0x03, 0x00, 0x00 }, // VGAHiGain |
---|
| 209 | + { I2C_DEV_DES, 2, 0x16D1, 0x03, 0x00, 0x00 }, // VGAHiGain |
---|
| 210 | + { I2C_DEV_DES, 2, 0x17D1, 0x03, 0x00, 0x0a }, // VGAHiGain |
---|
| 211 | + // SSC Configuration |
---|
| 212 | + { I2C_DEV_DES, 2, 0x1445, 0x00, 0x00, 0x00 }, // Disable SSC |
---|
| 213 | + { I2C_DEV_DES, 2, 0x1545, 0x00, 0x00, 0x00 }, // Disable SSC |
---|
| 214 | + { I2C_DEV_DES, 2, 0x1645, 0x00, 0x00, 0x00 }, // Disable SSC |
---|
| 215 | + { I2C_DEV_DES, 2, 0x1745, 0x00, 0x00, 0x0a }, // Disable SSC |
---|
| 216 | + // GMSL1 configuration to match serializer |
---|
| 217 | + { I2C_DEV_DES, 2, 0x0B07, 0x84, 0x00, 0x00 }, // Enable HVEN and DBL (application specific) |
---|
| 218 | + { I2C_DEV_DES, 2, 0x0C07, 0x84, 0x00, 0x00 }, // Enable HVEN and DBL (application specific) |
---|
| 219 | + { I2C_DEV_DES, 2, 0x0D07, 0x84, 0x00, 0x00 }, // Enable HVEN and DBL (application specific) |
---|
| 220 | + { I2C_DEV_DES, 2, 0x0E07, 0x84, 0x00, 0x00 }, // Enable HVEN and DBL (application specific) |
---|
| 221 | + { I2C_DEV_DES, 2, 0x0B0F, 0x01, 0x00, 0x00 }, // Disable processing HS and DE signals(required when paring with GMSL1 parallel serializers) |
---|
| 222 | + { I2C_DEV_DES, 2, 0x0C0F, 0x01, 0x00, 0x00 }, // Disable processing HS and DE signals(required when paring with GMSL1 parallel serializers) |
---|
| 223 | + { I2C_DEV_DES, 2, 0x0D0F, 0x01, 0x00, 0x00 }, // Disable processing HS and DE signals(required when paring with GMSL1 parallel serializers) |
---|
| 224 | + { I2C_DEV_DES, 2, 0x0E0F, 0x01, 0x00, 0x00 }, // Disable processing HS and DE signals(required when paring with GMSL1 parallel serializers) |
---|
| 225 | + // Send YUV422, FS, and FE from Video Pipe 0 to Controller 1 |
---|
| 226 | + { I2C_DEV_DES, 2, 0x090B, 0x07, 0x00, 0x00 }, // Enable 0/1/2 SRC/DST Mappings |
---|
| 227 | + { I2C_DEV_DES, 2, 0x092D, 0x15, 0x00, 0x00 }, // SRC/DST 0/1/2 -> CSI2 Controller 1; |
---|
| 228 | + // For the following MSB 2 bits = VC, LSB 6 bits = DT |
---|
| 229 | + { I2C_DEV_DES, 2, 0x090D, 0x1e, 0x00, 0x00 }, // SRC0 VC = 0, DT = YUV422 8bit |
---|
| 230 | + { I2C_DEV_DES, 2, 0x090E, 0x1e, 0x00, 0x00 }, // DST0 VC = 0, DT = YUV422 8bit |
---|
| 231 | + { I2C_DEV_DES, 2, 0x090F, 0x00, 0x00, 0x00 }, // SRC1 VC = 0, DT = Frame Start |
---|
| 232 | + { I2C_DEV_DES, 2, 0x0910, 0x00, 0x00, 0x00 }, // DST1 VC = 0, DT = Frame Start |
---|
| 233 | + { I2C_DEV_DES, 2, 0x0911, 0x01, 0x00, 0x00 }, // SRC2 VC = 0, DT = Frame End |
---|
| 234 | + { I2C_DEV_DES, 2, 0x0912, 0x01, 0x00, 0x00 }, // DST2 VC = 0, DT = Frame End |
---|
| 235 | + // Send YUV422, FS, and FE from Video Pipe 1 to Controller 1 |
---|
| 236 | + { I2C_DEV_DES, 2, 0x094B, 0x07, 0x00, 0x00 }, // Enable 0/1/2 SRC/DST Mappings |
---|
| 237 | + { I2C_DEV_DES, 2, 0x096D, 0x15, 0x00, 0x00 }, // SRC/DST 0/1/2 -> CSI2 Controller 1; |
---|
| 238 | + // For the following MSB 2 bits = VC, LSB 6 bits = DT |
---|
| 239 | + { I2C_DEV_DES, 2, 0x094D, 0x1e, 0x00, 0x00 }, // SRC0 VC = 0, DT = YUV422 8bit |
---|
| 240 | + { I2C_DEV_DES, 2, 0x094E, 0x5e, 0x00, 0x00 }, // DST0 VC = 1, DT = YUV422 8bit |
---|
| 241 | + { I2C_DEV_DES, 2, 0x094F, 0x00, 0x00, 0x00 }, // SRC1 VC = 0, DT = Frame Start |
---|
| 242 | + { I2C_DEV_DES, 2, 0x0950, 0x40, 0x00, 0x00 }, // DST1 VC = 1, DT = Frame Start |
---|
| 243 | + { I2C_DEV_DES, 2, 0x0951, 0x01, 0x00, 0x00 }, // SRC2 VC = 0, DT = Frame End |
---|
| 244 | + { I2C_DEV_DES, 2, 0x0952, 0x41, 0x00, 0x00 }, // DST2 VC = 1, DT = Frame End |
---|
| 245 | + // Send YUV422, FS, and FE from Video Pipe 2 to Controller 1 |
---|
| 246 | + { I2C_DEV_DES, 2, 0x098B, 0x07, 0x00, 0x00 }, // Enable 0/1/2 SRC/DST Mappings |
---|
| 247 | + { I2C_DEV_DES, 2, 0x09AD, 0x15, 0x00, 0x00 }, // SRC/DST 0/1/2 -> CSI2 Controller 1; |
---|
| 248 | + // For the following MSB 2 bits = VC, LSB 6 bits = DT |
---|
| 249 | + { I2C_DEV_DES, 2, 0x098D, 0x1e, 0x00, 0x00 }, // SRC0 VC = 0, DT = YUV422 8bit |
---|
| 250 | + { I2C_DEV_DES, 2, 0x098E, 0x9e, 0x00, 0x00 }, // DST0 VC = 2, DT = YUV422 8bit |
---|
| 251 | + { I2C_DEV_DES, 2, 0x098F, 0x00, 0x00, 0x00 }, // SRC1 VC = 0, DT = Frame Start |
---|
| 252 | + { I2C_DEV_DES, 2, 0x0990, 0x80, 0x00, 0x00 }, // DST1 VC = 2, DT = Frame Start |
---|
| 253 | + { I2C_DEV_DES, 2, 0x0991, 0x01, 0x00, 0x00 }, // SRC2 VC = 0, DT = Frame End |
---|
| 254 | + { I2C_DEV_DES, 2, 0x0992, 0x81, 0x00, 0x00 }, // DST2 VC = 2, DT = Frame End |
---|
| 255 | + // Send YUV422, FS, and FE from Video Pipe 3 to Controller 1 |
---|
| 256 | + { I2C_DEV_DES, 2, 0x09CB, 0x07, 0x00, 0x00 }, // Enable 0/1/2 SRC/DST Mappings |
---|
| 257 | + { I2C_DEV_DES, 2, 0x09ED, 0x15, 0x00, 0x00 }, // SRC/DST 0/1/2 -> CSI2 Controller 1; |
---|
| 258 | + // For the following MSB 2 bits = VC, LSB 6 bits = DT |
---|
| 259 | + { I2C_DEV_DES, 2, 0x09CD, 0x1e, 0x00, 0x00 }, // SRC0 VC = 0, DT = YUV422 8bit |
---|
| 260 | + { I2C_DEV_DES, 2, 0x09CE, 0xde, 0x00, 0x00 }, // DST0 VC = 3, DT = YUV422 8bit |
---|
| 261 | + { I2C_DEV_DES, 2, 0x09CF, 0x00, 0x00, 0x00 }, // SRC1 VC = 0, DT = Frame Start |
---|
| 262 | + { I2C_DEV_DES, 2, 0x09D0, 0xc0, 0x00, 0x00 }, // DST1 VC = 3, DT = Frame Start |
---|
| 263 | + { I2C_DEV_DES, 2, 0x09D1, 0x01, 0x00, 0x00 }, // SRC2 VC = 0, DT = Frame End |
---|
| 264 | + { I2C_DEV_DES, 2, 0x09D2, 0xc1, 0x00, 0x00 }, // DST2 VC = 3, DT = Frame End |
---|
160 | 265 | // MIPI PHY Setting |
---|
161 | | - // Set Des in 2x4 mode |
---|
162 | | - {0x6b, 0x08A0, 0x04, 0x00}, |
---|
| 266 | + { I2C_DEV_DES, 2, 0x08A0, 0x24, 0x00, 0x00 }, // DPHY0 enabled as clock, MIPI PHY Mode: 2x4 mode |
---|
163 | 267 | // Set Lane Mapping for 4-lane port A |
---|
164 | | - {0x6b, 0x08A3, 0xE4, 0x00}, |
---|
165 | | - {0x6b, 0x08A4, 0xE4, 0x00}, |
---|
166 | | - // Set 4 lane D-PHY |
---|
167 | | - {0x6b, 0x090A, 0xC0, 0x00}, |
---|
168 | | - {0x6b, 0x094A, 0xC0, 0x00}, |
---|
169 | | - {0x6b, 0x098A, 0xC0, 0x00}, |
---|
170 | | - {0x6b, 0x09CA, 0xC0, 0x00}, |
---|
| 268 | + { I2C_DEV_DES, 2, 0x08A3, 0xe4, 0x00, 0x00 }, // PHY1 D1->D3, D0->D2; PHY0 D1->D1, D0->D0 |
---|
| 269 | + // Set 4 lane D-PHY, 2bit VC |
---|
| 270 | + { I2C_DEV_DES, 2, 0x090A, 0xc0, 0x00, 0x00 }, // MIPI PHY 0: 4 lanes, DPHY, 2bit VC |
---|
| 271 | + { I2C_DEV_DES, 2, 0x094A, 0xc0, 0x00, 0x00 }, // MIPI PHY 1: 4 lanes, DPHY, 2bit VC |
---|
171 | 272 | // Turn on MIPI PHYs |
---|
172 | | - {0x6b, 0x08A2, 0xF0, 0x00}, |
---|
173 | | - // Hold DPLL in reset (config_soft_rst_n = 0) before changing the rate |
---|
174 | | - {0x6b, 0x1C00, 0xF4, 0x00}, |
---|
175 | | - {0x6b, 0x1D00, 0xF4, 0x00}, |
---|
176 | | - {0x6b, 0x1E00, 0xF4, 0x00}, |
---|
177 | | - {0x6b, 0x1F00, 0xF4, 0x00}, |
---|
178 | | - // Set Data rate to be 800Mbps/lane for port A and enable software override |
---|
179 | | - {0x6b, 0x0415, 0xE8, 0x00}, //override pipe0/1 |
---|
180 | | - {0x6b, 0x0418, 0x28, 0x00}, |
---|
181 | | - {0x6b, 0x041B, 0x28, 0x00}, |
---|
182 | | - {0x6b, 0x041E, 0x28, 0x00}, |
---|
183 | | - // Release reset to DPLL (config_soft_rst_n = 1) |
---|
184 | | - {0x6b, 0x1C00, 0xF5, 0x00}, |
---|
185 | | - {0x6b, 0x1D00, 0xF5, 0x00}, |
---|
186 | | - {0x6b, 0x1E00, 0xF5, 0x00}, |
---|
187 | | - {0x6b, 0x1F00, 0xF5, 0x00}, |
---|
188 | | - {0x6b, 0x0003, 0xFF, 0x00}, |
---|
189 | | - {0x6b, 0x0006, 0xF3, 0x0a}, |
---|
190 | | - // {0x6b, 0x08A0, 0x84}, |
---|
191 | | - {0x6b, REG_NULL, 0x00, 0x00}, |
---|
| 273 | + { I2C_DEV_DES, 2, 0x08A2, 0x34, 0x00, 0x00 }, // Enable MIPI PHY 0/1, t_lpx = 106.7ns |
---|
| 274 | + // Enable software override for all pipes since GMSL1 data is parallel mode, bpp=8, dt=0x1e(yuv-8) |
---|
| 275 | + { I2C_DEV_DES, 2, 0x040B, 0x40, 0x00, 0x00 }, // pipe 0 bpp=0x08: Datatypes = 0x2A, 0x10-12, 0x31-37 |
---|
| 276 | + { I2C_DEV_DES, 2, 0x040C, 0x00, 0x00, 0x00 }, // pipe 0 and 1 VC software override: 0x00 |
---|
| 277 | + { I2C_DEV_DES, 2, 0x040D, 0x00, 0x00, 0x00 }, // pipe 2 and 3 VC software override: 0x00 |
---|
| 278 | + { I2C_DEV_DES, 2, 0x040E, 0x5e, 0x00, 0x00 }, // pipe 0 DT=0x1E: YUV422 8-bit |
---|
| 279 | + { I2C_DEV_DES, 2, 0x040F, 0x7e, 0x00, 0x00 }, // pipe 1 DT=0x1E: YUV422 8-bit |
---|
| 280 | + { I2C_DEV_DES, 2, 0x0410, 0x7a, 0x00, 0x00 }, // pipe 2 DT=0x1E, pipe 3 DT=0x1E: YUV422 8-bit |
---|
| 281 | + { I2C_DEV_DES, 2, 0x0411, 0x48, 0x00, 0x00 }, // pipe 1 bpp=0x08: Datatypes = 0x2A, 0x10-12, 0x31-37 |
---|
| 282 | + { I2C_DEV_DES, 2, 0x0412, 0x20, 0x00, 0x00 }, // pipe 2 bpp=0x08, pipe 3 bpp=0x08: Datatypes = 0x2A, 0x10-12, 0x31-37 |
---|
| 283 | + { I2C_DEV_DES, 2, 0x0415, 0xc0, 0xc0, 0x00 }, // pipe 0/1 enable software overide |
---|
| 284 | + { I2C_DEV_DES, 2, 0x0418, 0xc0, 0xc0, 0x00 }, // pipe 2/3 enable software overide |
---|
| 285 | + { I2C_DEV_DES, 2, 0x041A, 0xf0, 0x00, 0x00 }, // pipe 0/1/2/3: Enable YUV8-/10-bit mux mode |
---|
| 286 | + // Enable all links and pipes |
---|
| 287 | + { I2C_DEV_DES, 2, 0x0003, 0xaa, 0x00, 0x00 }, // Enable Remote Control Channel Link A/B/C/D for Port 0 |
---|
| 288 | + { I2C_DEV_DES, 2, 0x0006, 0x0f, 0x00, 0x64 }, // Enable all links and pipes |
---|
| 289 | + // Serializer Setting |
---|
| 290 | + { I2C_DEV_SER, 1, 0x04, 0x47, 0x00, 0x05 }, // main_control: Enable CLINK |
---|
| 291 | + { I2C_DEV_SER, 1, 0x07, 0x84, 0x00, 0x00 }, // Config SerDes: DBL=1, BWS=0, HIBW=0, PXL_CRC=0, HVEN=1 |
---|
| 292 | + { I2C_DEV_SER, 1, 0x67, 0xc4, 0x00, 0x00 }, // Double Alignment Mode: Align at each rising edge of HS |
---|
| 293 | + { I2C_DEV_SER, 1, 0x0F, 0xbf, 0x00, 0x00 }, // Enable Set GPO, GPO Output High |
---|
| 294 | + { I2C_DEV_SER, 1, 0x3F, 0x08, 0x00, 0x00 }, // Crossbar HS: DIN8 |
---|
| 295 | + { I2C_DEV_SER, 1, 0x40, 0x2d, 0x00, 0x00 }, // Crossbar VS: DIN13, INVERT_MUX_VS |
---|
| 296 | + { I2C_DEV_SER, 1, 0x20, 0x10, 0x00, 0x00 }, |
---|
| 297 | + { I2C_DEV_SER, 1, 0x21, 0x11, 0x00, 0x00 }, |
---|
| 298 | + { I2C_DEV_SER, 1, 0x22, 0x12, 0x00, 0x00 }, |
---|
| 299 | + { I2C_DEV_SER, 1, 0x23, 0x13, 0x00, 0x00 }, |
---|
| 300 | + { I2C_DEV_SER, 1, 0x24, 0x14, 0x00, 0x00 }, |
---|
| 301 | + { I2C_DEV_SER, 1, 0x25, 0x15, 0x00, 0x00 }, |
---|
| 302 | + { I2C_DEV_SER, 1, 0x26, 0x16, 0x00, 0x00 }, |
---|
| 303 | + { I2C_DEV_SER, 1, 0x27, 0x17, 0x00, 0x00 }, |
---|
| 304 | + { I2C_DEV_SER, 1, 0x30, 0x00, 0x00, 0x00 }, |
---|
| 305 | + { I2C_DEV_SER, 1, 0x31, 0x01, 0x00, 0x00 }, |
---|
| 306 | + { I2C_DEV_SER, 1, 0x32, 0x02, 0x00, 0x00 }, |
---|
| 307 | + { I2C_DEV_SER, 1, 0x33, 0x03, 0x00, 0x00 }, |
---|
| 308 | + { I2C_DEV_SER, 1, 0x34, 0x04, 0x00, 0x00 }, |
---|
| 309 | + { I2C_DEV_SER, 1, 0x35, 0x05, 0x00, 0x00 }, |
---|
| 310 | + { I2C_DEV_SER, 1, 0x36, 0x06, 0x00, 0x00 }, |
---|
| 311 | + { I2C_DEV_SER, 1, 0x37, 0x07, 0x00, 0x00 }, |
---|
| 312 | + { I2C_DEV_SER, 1, 0x04, 0x87, 0x00, 0x05 }, // main_control: Enable Serialization |
---|
| 313 | + { I2C_DEV_DES, 2, REG_NULL, 0x00, 0x00, 0x00 }, |
---|
192 | 314 | }; |
---|
193 | 315 | |
---|
194 | | -static const struct max96722_mode supported_modes[] = { |
---|
| 316 | +static const struct max96722_mode supported_modes_4lane[] = { |
---|
195 | 317 | { |
---|
196 | | - .width = 1920, |
---|
197 | | - .height = 1080, |
---|
| 318 | + .width = 1280, |
---|
| 319 | + .height = 800, |
---|
198 | 320 | .max_fps = { |
---|
199 | 321 | .numerator = 10000, |
---|
200 | 322 | .denominator = 300000, |
---|
201 | 323 | }, |
---|
202 | | - .reg_list = max96722_mipi_init, |
---|
203 | | - .link_freq_idx = 0, |
---|
| 324 | + .reg_list = max96722_mipi_4lane_1280x800_30fps, |
---|
| 325 | + .link_freq_idx = 20, |
---|
| 326 | + .bus_fmt = MEDIA_BUS_FMT_UYVY8_2X8, |
---|
| 327 | + .bpp = 16, |
---|
| 328 | + .vc[PAD0] = V4L2_MBUS_CSI2_CHANNEL_0, |
---|
| 329 | + .vc[PAD1] = V4L2_MBUS_CSI2_CHANNEL_1, |
---|
| 330 | + .vc[PAD2] = V4L2_MBUS_CSI2_CHANNEL_2, |
---|
| 331 | + .vc[PAD3] = V4L2_MBUS_CSI2_CHANNEL_3, |
---|
204 | 332 | }, |
---|
205 | 333 | }; |
---|
206 | 334 | |
---|
| 335 | +/* link freq = index * MAX96722_LINK_FREQ_MHZ(50) */ |
---|
207 | 336 | static const s64 link_freq_items[] = { |
---|
208 | | - MAX96722_LINK_FREQ_400MHZ, |
---|
| 337 | + MAX96722_LINK_FREQ_MHZ(0), |
---|
| 338 | + MAX96722_LINK_FREQ_MHZ(50), |
---|
| 339 | + MAX96722_LINK_FREQ_MHZ(100), |
---|
| 340 | + MAX96722_LINK_FREQ_MHZ(150), |
---|
| 341 | + MAX96722_LINK_FREQ_MHZ(200), |
---|
| 342 | + MAX96722_LINK_FREQ_MHZ(250), |
---|
| 343 | + MAX96722_LINK_FREQ_MHZ(300), |
---|
| 344 | + MAX96722_LINK_FREQ_MHZ(350), |
---|
| 345 | + MAX96722_LINK_FREQ_MHZ(400), |
---|
| 346 | + MAX96722_LINK_FREQ_MHZ(450), |
---|
| 347 | + MAX96722_LINK_FREQ_MHZ(500), |
---|
| 348 | + MAX96722_LINK_FREQ_MHZ(550), |
---|
| 349 | + MAX96722_LINK_FREQ_MHZ(600), |
---|
| 350 | + MAX96722_LINK_FREQ_MHZ(650), |
---|
| 351 | + MAX96722_LINK_FREQ_MHZ(700), |
---|
| 352 | + MAX96722_LINK_FREQ_MHZ(750), |
---|
| 353 | + MAX96722_LINK_FREQ_MHZ(800), |
---|
| 354 | + MAX96722_LINK_FREQ_MHZ(850), |
---|
| 355 | + MAX96722_LINK_FREQ_MHZ(900), |
---|
| 356 | + MAX96722_LINK_FREQ_MHZ(950), |
---|
| 357 | + MAX96722_LINK_FREQ_MHZ(1000), |
---|
| 358 | + MAX96722_LINK_FREQ_MHZ(1050), |
---|
| 359 | + MAX96722_LINK_FREQ_MHZ(1100), |
---|
| 360 | + MAX96722_LINK_FREQ_MHZ(1150), |
---|
| 361 | + MAX96722_LINK_FREQ_MHZ(1200), |
---|
| 362 | + MAX96722_LINK_FREQ_MHZ(1250), |
---|
209 | 363 | }; |
---|
210 | 364 | |
---|
211 | | -/* Write registers up to 4 at a time */ |
---|
212 | | -static int max96722_write_reg(struct i2c_client *client, u16 reg, |
---|
213 | | - u32 len, u32 val) |
---|
| 365 | +static int max96722_write_reg(struct max96722 *max96722, u8 i2c_id, |
---|
| 366 | + u16 reg, u16 reg_len, u16 val_len, u32 val) |
---|
214 | 367 | { |
---|
| 368 | + struct i2c_client *client = max96722->client; |
---|
| 369 | + u16 client_addr = max96722->i2c_addr[i2c_id]; |
---|
215 | 370 | u32 buf_i, val_i; |
---|
216 | 371 | u8 buf[6]; |
---|
217 | 372 | u8 *val_p; |
---|
218 | 373 | __be32 val_be; |
---|
219 | 374 | |
---|
220 | | - dev_dbg(&client->dev, "write reg(0x%x val:0x%x)!\n", reg, val); |
---|
| 375 | + dev_info(&client->dev, "addr(0x%02x) write reg(0x%04x, %d, 0x%02x)\n", |
---|
| 376 | + client_addr, reg, reg_len, val); |
---|
221 | 377 | |
---|
222 | | - if (len > 4) |
---|
| 378 | + if (val_len > 4) |
---|
223 | 379 | return -EINVAL; |
---|
224 | 380 | |
---|
225 | | - buf[0] = reg >> 8; |
---|
226 | | - buf[1] = reg & 0xff; |
---|
| 381 | + if (reg_len == 2) { |
---|
| 382 | + buf[0] = reg >> 8; |
---|
| 383 | + buf[1] = reg & 0xff; |
---|
| 384 | + |
---|
| 385 | + buf_i = 2; |
---|
| 386 | + } else { |
---|
| 387 | + buf[0] = reg & 0xff; |
---|
| 388 | + |
---|
| 389 | + buf_i = 1; |
---|
| 390 | + } |
---|
227 | 391 | |
---|
228 | 392 | val_be = cpu_to_be32(val); |
---|
229 | 393 | val_p = (u8 *)&val_be; |
---|
230 | | - buf_i = 2; |
---|
231 | | - val_i = 4 - len; |
---|
| 394 | + val_i = 4 - val_len; |
---|
232 | 395 | |
---|
233 | 396 | while (val_i < 4) |
---|
234 | 397 | buf[buf_i++] = val_p[val_i++]; |
---|
235 | 398 | |
---|
236 | | - if (i2c_master_send(client, buf, len + 2) != len + 2) { |
---|
237 | | - dev_err(&client->dev, "%s: writing register 0x%x from 0x%x failed\n", |
---|
238 | | - __func__, reg, client->addr); |
---|
| 399 | + client->addr = client_addr; |
---|
| 400 | + |
---|
| 401 | + if (i2c_master_send(client, buf, (val_len + reg_len)) != (val_len + reg_len)) { |
---|
| 402 | + dev_err(&client->dev, |
---|
| 403 | + "%s: writing register 0x%04x from 0x%02x failed\n", |
---|
| 404 | + __func__, reg, client->addr); |
---|
239 | 405 | return -EIO; |
---|
240 | 406 | } |
---|
241 | 407 | |
---|
242 | 408 | return 0; |
---|
243 | 409 | } |
---|
244 | 410 | |
---|
245 | | -static int max96722_write_array(struct i2c_client *client, |
---|
246 | | - const struct regval *regs) |
---|
| 411 | +static int max96722_read_reg(struct max96722 *max96722, u8 i2c_id, |
---|
| 412 | + u16 reg, u16 reg_len, u16 val_len, u8 *val) |
---|
247 | 413 | { |
---|
248 | | - u32 i; |
---|
249 | | - int ret = 0; |
---|
250 | | - |
---|
251 | | - for (i = 0; ret == 0 && regs[i].addr != REG_NULL; i++) { |
---|
252 | | - client->addr = regs[i].i2c_addr; |
---|
253 | | - ret = max96722_write_reg(client, regs[i].addr, |
---|
254 | | - MAX96722_REG_VALUE_08BIT, |
---|
255 | | - regs[i].val); |
---|
256 | | - msleep(regs[i].delay); |
---|
257 | | - } |
---|
258 | | - |
---|
259 | | - return ret; |
---|
260 | | -} |
---|
261 | | - |
---|
262 | | -/* Read registers up to 4 at a time */ |
---|
263 | | -static int max96722_read_reg(struct i2c_client *client, u16 reg, |
---|
264 | | - unsigned int len, u32 *val) |
---|
265 | | -{ |
---|
| 414 | + struct i2c_client *client = max96722->client; |
---|
| 415 | + u16 client_addr = max96722->i2c_addr[i2c_id]; |
---|
266 | 416 | struct i2c_msg msgs[2]; |
---|
267 | 417 | u8 *data_be_p; |
---|
268 | 418 | __be32 data_be = 0; |
---|
269 | 419 | __be16 reg_addr_be = cpu_to_be16(reg); |
---|
| 420 | + u8 *reg_be_p; |
---|
270 | 421 | int ret; |
---|
271 | 422 | |
---|
272 | | - if (len > 4 || !len) |
---|
| 423 | + if (val_len > 4 || !val_len) |
---|
273 | 424 | return -EINVAL; |
---|
274 | 425 | |
---|
| 426 | + client->addr = client_addr; |
---|
275 | 427 | data_be_p = (u8 *)&data_be; |
---|
| 428 | + reg_be_p = (u8 *)®_addr_be; |
---|
| 429 | + |
---|
276 | 430 | /* Write register address */ |
---|
277 | 431 | msgs[0].addr = client->addr; |
---|
278 | 432 | msgs[0].flags = 0; |
---|
279 | | - msgs[0].len = 2; |
---|
280 | | - msgs[0].buf = (u8 *)®_addr_be; |
---|
| 433 | + msgs[0].len = reg_len; |
---|
| 434 | + msgs[0].buf = ®_be_p[2 - reg_len]; |
---|
281 | 435 | |
---|
282 | 436 | /* Read data from register */ |
---|
283 | 437 | msgs[1].addr = client->addr; |
---|
284 | 438 | msgs[1].flags = I2C_M_RD; |
---|
285 | | - msgs[1].len = len; |
---|
286 | | - msgs[1].buf = &data_be_p[4 - len]; |
---|
| 439 | + msgs[1].len = val_len; |
---|
| 440 | + msgs[1].buf = &data_be_p[4 - val_len]; |
---|
287 | 441 | |
---|
288 | 442 | ret = i2c_transfer(client->adapter, msgs, ARRAY_SIZE(msgs)); |
---|
289 | 443 | if (ret != ARRAY_SIZE(msgs)) { |
---|
290 | | - dev_err(&client->dev, "%s: reading register 0x%x from 0x%x failed\n", |
---|
291 | | - __func__, reg, client->addr); |
---|
| 444 | + dev_err(&client->dev, |
---|
| 445 | + "%s: reading register 0x%x from 0x%x failed\n", |
---|
| 446 | + __func__, reg, client->addr); |
---|
292 | 447 | return -EIO; |
---|
293 | 448 | } |
---|
294 | 449 | |
---|
295 | 450 | *val = be32_to_cpu(data_be); |
---|
296 | 451 | |
---|
| 452 | +#if 0 |
---|
| 453 | + dev_info(&client->dev, "addr(0x%02x) read reg(0x%04x, %d, 0x%02x)\n", |
---|
| 454 | + client_addr, reg, reg_len, *val); |
---|
| 455 | +#endif |
---|
| 456 | + |
---|
297 | 457 | return 0; |
---|
298 | 458 | } |
---|
299 | 459 | |
---|
| 460 | +static int max96722_update_reg_bits(struct max96722 *max96722, u8 i2c_id, |
---|
| 461 | + u16 reg, u16 reg_len, u8 mask, u8 val) |
---|
| 462 | +{ |
---|
| 463 | + u8 value; |
---|
| 464 | + u32 val_len = DEV_REG_VALUE_08BITS; |
---|
| 465 | + int ret; |
---|
| 466 | + |
---|
| 467 | + ret = max96722_read_reg(max96722, i2c_id, reg, reg_len, val_len, &value); |
---|
| 468 | + if (ret) |
---|
| 469 | + return ret; |
---|
| 470 | + |
---|
| 471 | + value &= ~mask; |
---|
| 472 | + value |= (val & mask); |
---|
| 473 | + ret = max96722_write_reg(max96722, i2c_id, reg, reg_len, val_len, value); |
---|
| 474 | + if (ret) |
---|
| 475 | + return ret; |
---|
| 476 | + |
---|
| 477 | + return 0; |
---|
| 478 | +} |
---|
| 479 | + |
---|
| 480 | +static int max96722_write_array(struct max96722 *max96722, |
---|
| 481 | + const struct regval *regs) |
---|
| 482 | +{ |
---|
| 483 | + u32 i; |
---|
| 484 | + int ret = 0; |
---|
| 485 | + |
---|
| 486 | + for (i = 0; ret == 0 && regs[i].reg != REG_NULL; i++) { |
---|
| 487 | + if (regs[i].mask != 0) |
---|
| 488 | + ret = max96722_update_reg_bits(max96722, regs[i].i2c_id, |
---|
| 489 | + regs[i].reg, regs[i].reg_len, |
---|
| 490 | + regs[i].mask, regs[i].val); |
---|
| 491 | + else |
---|
| 492 | + ret = max96722_write_reg(max96722, regs[i].i2c_id, |
---|
| 493 | + regs[i].reg, regs[i].reg_len, |
---|
| 494 | + DEV_REG_VALUE_08BITS, regs[i].val); |
---|
| 495 | + |
---|
| 496 | + if (regs[i].delay != 0) |
---|
| 497 | + msleep(regs[i].delay); |
---|
| 498 | + } |
---|
| 499 | + |
---|
| 500 | + return ret; |
---|
| 501 | +} |
---|
| 502 | + |
---|
| 503 | +static int max96722_check_local_chipid(struct max96722 *max96722) |
---|
| 504 | +{ |
---|
| 505 | + struct device *dev = &max96722->client->dev; |
---|
| 506 | + int ret; |
---|
| 507 | + u8 id = 0; |
---|
| 508 | + |
---|
| 509 | + ret = max96722_read_reg(max96722, I2C_DEV_DES, |
---|
| 510 | + MAX96722_REG_CHIP_ID, DEV_REG_LENGTH_16BITS, |
---|
| 511 | + DEV_REG_VALUE_08BITS, &id); |
---|
| 512 | + if ((ret != 0) || (id != MAX96722_CHIP_ID)) { |
---|
| 513 | + dev_err(dev, "Unexpected MAX96722 chip id(%02x), ret(%d)\n", id, ret); |
---|
| 514 | + return -ENODEV; |
---|
| 515 | + } |
---|
| 516 | + |
---|
| 517 | + dev_info(dev, "Detected MAX96722 chipid: %02x\n", id); |
---|
| 518 | + |
---|
| 519 | + return 0; |
---|
| 520 | +} |
---|
| 521 | + |
---|
| 522 | +static int __maybe_unused max96722_check_remote_chipid(struct max96722 *max96722) |
---|
| 523 | +{ |
---|
| 524 | + struct device *dev = &max96722->client->dev; |
---|
| 525 | + int ret = 0; |
---|
| 526 | + u8 id; |
---|
| 527 | + |
---|
| 528 | + dev_info(dev, "Check remote chipid\n"); |
---|
| 529 | + |
---|
| 530 | + id = 0; |
---|
| 531 | +#if 0 |
---|
| 532 | + // max96717 |
---|
| 533 | + ret = max96722_read_reg(max96722, I2C_DEV_SER, |
---|
| 534 | + MAX96717_REG_CHIP_ID, DEV_REG_LENGTH_16BITS, |
---|
| 535 | + DEV_REG_VALUE_08BITS, &id); |
---|
| 536 | + if ((ret != 0) || (id != MAX96717_CHIP_ID)) { |
---|
| 537 | + dev_err(dev, "Unexpected MAX96717 chip id(%02x), ret(%d)\n", id, ret); |
---|
| 538 | + return -ENODEV; |
---|
| 539 | + } |
---|
| 540 | + dev_info(dev, "Detected MAX96717 chipid: 0x%02x\n", id); |
---|
| 541 | +#endif |
---|
| 542 | + |
---|
| 543 | +#if 0 |
---|
| 544 | + // max9295 |
---|
| 545 | + ret = max96722_read_reg(max96722, I2C_DEV_SER, |
---|
| 546 | + MAX9295_REG_CHIP_ID, DEV_REG_LENGTH_16BITS, |
---|
| 547 | + DEV_REG_VALUE_08BITS, &id); |
---|
| 548 | + if ((ret != 0) || (id != MAX9295_CHIP_ID)) { |
---|
| 549 | + dev_err(dev, "Unexpected MAX9295 chip id(%02x), ret(%d)\n", id, ret); |
---|
| 550 | + return -ENODEV; |
---|
| 551 | + } |
---|
| 552 | + dev_info(dev, "Detected MAX9295 chipid: 0x%02x\n", id); |
---|
| 553 | +#endif |
---|
| 554 | + |
---|
| 555 | +#if 0 |
---|
| 556 | + // max96715 |
---|
| 557 | + ret = max96722_read_reg(max96722, I2C_DEV_SER, |
---|
| 558 | + MAX96715_REG_CHIP_ID, DEV_REG_LENGTH_08BITS, |
---|
| 559 | + DEV_REG_VALUE_08BITS, &id); |
---|
| 560 | + if ((ret != 0) || (id != MAX96715_CHIP_ID)) { |
---|
| 561 | + dev_err(dev, "Unexpected MAX96715 chip id(%02x), ret(%d)\n", id, ret); |
---|
| 562 | + return -ENODEV; |
---|
| 563 | + } |
---|
| 564 | + dev_info(dev, "Detected MAX96715 chipid: 0x%02x\n", id); |
---|
| 565 | +#endif |
---|
| 566 | + |
---|
| 567 | + return ret; |
---|
| 568 | +} |
---|
| 569 | + |
---|
| 570 | +static u8 max96722_get_link_lock_state(struct max96722 *max96722, u8 link_mask) |
---|
| 571 | +{ |
---|
| 572 | + struct device *dev = &max96722->client->dev; |
---|
| 573 | + u8 lock = 0, lock_state = 0; |
---|
| 574 | + u8 link_type = 0; |
---|
| 575 | + |
---|
| 576 | + link_type = max96722->link_mask & MAXIM_GMSL_TYPE_MASK; |
---|
| 577 | + |
---|
| 578 | + if (link_mask & MAXIM_GMSL_LOCK_LINK_A) { |
---|
| 579 | + if (link_type & MAXIM_GMSL_TYPE_LINK_A) { |
---|
| 580 | + // GMSL2 LinkA |
---|
| 581 | + max96722_read_reg(max96722, I2C_DEV_DES, |
---|
| 582 | + 0x001a, DEV_REG_LENGTH_16BITS, |
---|
| 583 | + DEV_REG_VALUE_08BITS, &lock); |
---|
| 584 | + if (lock & BIT(3)) { |
---|
| 585 | + lock_state |= MAXIM_GMSL_LOCK_LINK_A; |
---|
| 586 | + dev_info(dev, "GMSL2 LinkA locked\n"); |
---|
| 587 | + } |
---|
| 588 | + } else { |
---|
| 589 | + // GMSL1 LinkA |
---|
| 590 | + max96722_read_reg(max96722, I2C_DEV_DES, |
---|
| 591 | + 0x0bcb, DEV_REG_LENGTH_16BITS, |
---|
| 592 | + DEV_REG_VALUE_08BITS, &lock); |
---|
| 593 | + if (lock & BIT(0)) { |
---|
| 594 | + lock_state |= MAXIM_GMSL_LOCK_LINK_A; |
---|
| 595 | + dev_info(dev, "GMSL1 LinkA locked\n"); |
---|
| 596 | + } |
---|
| 597 | + } |
---|
| 598 | + } |
---|
| 599 | + |
---|
| 600 | + if (link_mask & MAXIM_GMSL_LOCK_LINK_B) { |
---|
| 601 | + if (link_type & MAXIM_GMSL_TYPE_LINK_B) { |
---|
| 602 | + // GMSL2 LinkB |
---|
| 603 | + max96722_read_reg(max96722, I2C_DEV_DES, |
---|
| 604 | + 0x000a, DEV_REG_LENGTH_16BITS, |
---|
| 605 | + DEV_REG_VALUE_08BITS, &lock); |
---|
| 606 | + if (lock & BIT(3)) { |
---|
| 607 | + lock_state |= MAXIM_GMSL_LOCK_LINK_B; |
---|
| 608 | + dev_info(dev, "GMSL2 LinkB locked\n"); |
---|
| 609 | + } |
---|
| 610 | + } else { |
---|
| 611 | + // GMSL1 LinkB |
---|
| 612 | + max96722_read_reg(max96722, I2C_DEV_DES, |
---|
| 613 | + 0x0ccb, DEV_REG_LENGTH_16BITS, |
---|
| 614 | + DEV_REG_VALUE_08BITS, &lock); |
---|
| 615 | + if (lock & BIT(0)) { |
---|
| 616 | + lock_state |= MAXIM_GMSL_LOCK_LINK_B; |
---|
| 617 | + dev_info(dev, "GMSL1 LinkB locked\n"); |
---|
| 618 | + } |
---|
| 619 | + } |
---|
| 620 | + } |
---|
| 621 | + |
---|
| 622 | + if (link_mask & MAXIM_GMSL_LOCK_LINK_C) { |
---|
| 623 | + if (link_type & MAXIM_GMSL_TYPE_LINK_C) { |
---|
| 624 | + // GMSL2 LinkC |
---|
| 625 | + max96722_read_reg(max96722, I2C_DEV_DES, |
---|
| 626 | + 0x000b, DEV_REG_LENGTH_16BITS, |
---|
| 627 | + DEV_REG_VALUE_08BITS, &lock); |
---|
| 628 | + if (lock & BIT(3)) { |
---|
| 629 | + lock_state |= MAXIM_GMSL_LOCK_LINK_C; |
---|
| 630 | + dev_info(dev, "GMSL2 LinkC locked\n"); |
---|
| 631 | + } |
---|
| 632 | + } else { |
---|
| 633 | + // GMSL1 LinkC |
---|
| 634 | + max96722_read_reg(max96722, I2C_DEV_DES, |
---|
| 635 | + 0x0dcb, DEV_REG_LENGTH_16BITS, |
---|
| 636 | + DEV_REG_VALUE_08BITS, &lock); |
---|
| 637 | + if (lock & BIT(0)) { |
---|
| 638 | + lock_state |= MAXIM_GMSL_LOCK_LINK_C; |
---|
| 639 | + dev_info(dev, "GMSL1 LinkC locked\n"); |
---|
| 640 | + } |
---|
| 641 | + } |
---|
| 642 | + } |
---|
| 643 | + |
---|
| 644 | + if (link_mask & MAXIM_GMSL_LOCK_LINK_D) { |
---|
| 645 | + if (link_type & MAXIM_GMSL_TYPE_LINK_D) { |
---|
| 646 | + // GMSL2 LinkD |
---|
| 647 | + max96722_read_reg(max96722, I2C_DEV_DES, |
---|
| 648 | + 0x000c, DEV_REG_LENGTH_16BITS, |
---|
| 649 | + DEV_REG_VALUE_08BITS, &lock); |
---|
| 650 | + if (lock & BIT(3)) { |
---|
| 651 | + lock_state |= MAXIM_GMSL_LOCK_LINK_D; |
---|
| 652 | + dev_info(dev, "GMSL2 LinkD locked\n"); |
---|
| 653 | + } |
---|
| 654 | + } else { |
---|
| 655 | + // GMSL1 LinkD |
---|
| 656 | + max96722_read_reg(max96722, I2C_DEV_DES, |
---|
| 657 | + 0x0ecb, DEV_REG_LENGTH_16BITS, |
---|
| 658 | + DEV_REG_VALUE_08BITS, &lock); |
---|
| 659 | + if (lock & BIT(0)) { |
---|
| 660 | + lock_state |= MAXIM_GMSL_LOCK_LINK_D; |
---|
| 661 | + dev_info(dev, "GMSL1 LinkD locked\n"); |
---|
| 662 | + } |
---|
| 663 | + } |
---|
| 664 | + } |
---|
| 665 | + |
---|
| 666 | + return lock_state; |
---|
| 667 | +} |
---|
| 668 | + |
---|
| 669 | +static int max96722_check_link_lock_state(struct max96722 *max96722) |
---|
| 670 | +{ |
---|
| 671 | + struct device *dev = &max96722->client->dev; |
---|
| 672 | + u8 lock_state = 0, link_mask = 0, link_type = 0; |
---|
| 673 | + int ret, i, time_ms; |
---|
| 674 | + |
---|
| 675 | + ret = max96722_check_local_chipid(max96722); |
---|
| 676 | + if (ret) |
---|
| 677 | + return ret; |
---|
| 678 | + |
---|
| 679 | + /* IF VDD = 1.2V: Enable REG_ENABLE and REG_MNL |
---|
| 680 | + * CTRL0: Enable REG_ENABLE |
---|
| 681 | + * CTRL2: Enable REG_MNL |
---|
| 682 | + */ |
---|
| 683 | + max96722_update_reg_bits(max96722, I2C_DEV_DES, |
---|
| 684 | + 0x0017, DEV_REG_LENGTH_16BITS, BIT(2), BIT(2)); |
---|
| 685 | + max96722_update_reg_bits(max96722, I2C_DEV_DES, |
---|
| 686 | + 0x0019, DEV_REG_LENGTH_16BITS, BIT(4), BIT(4)); |
---|
| 687 | + |
---|
| 688 | + // CSI output disabled |
---|
| 689 | + max96722_write_reg(max96722, I2C_DEV_DES, |
---|
| 690 | + 0x040B, DEV_REG_LENGTH_16BITS, |
---|
| 691 | + DEV_REG_VALUE_08BITS, 0x00); |
---|
| 692 | + |
---|
| 693 | + // All links select mode by link_type and disable at beginning. |
---|
| 694 | + link_type = max96722->link_mask & MAXIM_GMSL_TYPE_MASK; |
---|
| 695 | + max96722_write_reg(max96722, I2C_DEV_DES, |
---|
| 696 | + 0x0006, DEV_REG_LENGTH_16BITS, |
---|
| 697 | + DEV_REG_VALUE_08BITS, link_type); |
---|
| 698 | + |
---|
| 699 | + // Link Rate |
---|
| 700 | + // Link A ~ Link D Transmitter Rate: 187.5Mbps, Receiver Rate: 3Gbps |
---|
| 701 | + max96722_write_reg(max96722, I2C_DEV_DES, |
---|
| 702 | + 0x0010, DEV_REG_LENGTH_16BITS, |
---|
| 703 | + DEV_REG_VALUE_08BITS, 0x11); |
---|
| 704 | + max96722_write_reg(max96722, I2C_DEV_DES, |
---|
| 705 | + 0x0011, DEV_REG_LENGTH_16BITS, |
---|
| 706 | + DEV_REG_VALUE_08BITS, 0x11); |
---|
| 707 | + |
---|
| 708 | + // GMSL1: Enable HIM on deserializer on Link A/B/C/D |
---|
| 709 | + if ((link_type & MAXIM_GMSL_TYPE_LINK_A) == 0) { |
---|
| 710 | + max96722_write_reg(max96722, I2C_DEV_DES, |
---|
| 711 | + 0x0B06, DEV_REG_LENGTH_16BITS, |
---|
| 712 | + DEV_REG_VALUE_08BITS, 0xEF); |
---|
| 713 | + } |
---|
| 714 | + if ((link_type & MAXIM_GMSL_TYPE_LINK_B) == 0) { |
---|
| 715 | + max96722_write_reg(max96722, I2C_DEV_DES, |
---|
| 716 | + 0x0C06, DEV_REG_LENGTH_16BITS, |
---|
| 717 | + DEV_REG_VALUE_08BITS, 0xEF); |
---|
| 718 | + } |
---|
| 719 | + if ((link_type & MAXIM_GMSL_TYPE_LINK_C) == 0) { |
---|
| 720 | + max96722_write_reg(max96722, I2C_DEV_DES, |
---|
| 721 | + 0x0D06, DEV_REG_LENGTH_16BITS, |
---|
| 722 | + DEV_REG_VALUE_08BITS, 0xEF); |
---|
| 723 | + } |
---|
| 724 | + if ((link_type & MAXIM_GMSL_TYPE_LINK_D) == 0) { |
---|
| 725 | + max96722_write_reg(max96722, I2C_DEV_DES, |
---|
| 726 | + 0x0E06, DEV_REG_LENGTH_16BITS, |
---|
| 727 | + DEV_REG_VALUE_08BITS, 0xEF); |
---|
| 728 | + } |
---|
| 729 | + |
---|
| 730 | + // Link A ~ Link D One-Shot Reset depend on link_mask |
---|
| 731 | + link_mask = max96722->link_mask & MAXIM_GMSL_LOCK_MASK; |
---|
| 732 | + max96722_write_reg(max96722, I2C_DEV_DES, |
---|
| 733 | + 0x0018, DEV_REG_LENGTH_16BITS, |
---|
| 734 | + DEV_REG_VALUE_08BITS, link_mask); |
---|
| 735 | + |
---|
| 736 | + // Link A ~ Link D enable depend on link_type and link_mask |
---|
| 737 | + max96722_write_reg(max96722, I2C_DEV_DES, |
---|
| 738 | + 0x0006, DEV_REG_LENGTH_16BITS, |
---|
| 739 | + DEV_REG_VALUE_08BITS, link_type | link_mask); |
---|
| 740 | + |
---|
| 741 | + time_ms = 50; |
---|
| 742 | + msleep(time_ms); |
---|
| 743 | + |
---|
| 744 | + for (i = 0; i < 20; i++) { |
---|
| 745 | + if ((lock_state & MAXIM_GMSL_LOCK_LINK_A) == 0) |
---|
| 746 | + if (max96722_get_link_lock_state(max96722, MAXIM_GMSL_LOCK_LINK_A)) { |
---|
| 747 | + lock_state |= MAXIM_GMSL_LOCK_LINK_A; |
---|
| 748 | + dev_info(dev, "LinkA locked time: %d ms\n", time_ms); |
---|
| 749 | + } |
---|
| 750 | + |
---|
| 751 | + if ((lock_state & MAXIM_GMSL_LOCK_LINK_B) == 0) |
---|
| 752 | + if (max96722_get_link_lock_state(max96722, MAXIM_GMSL_LOCK_LINK_B)) { |
---|
| 753 | + lock_state |= MAXIM_GMSL_LOCK_LINK_B; |
---|
| 754 | + dev_info(dev, "LinkB locked time: %d ms\n", time_ms); |
---|
| 755 | + } |
---|
| 756 | + |
---|
| 757 | + if ((lock_state & MAXIM_GMSL_LOCK_LINK_C) == 0) |
---|
| 758 | + if (max96722_get_link_lock_state(max96722, MAXIM_GMSL_LOCK_LINK_C)) { |
---|
| 759 | + lock_state |= MAXIM_GMSL_LOCK_LINK_C; |
---|
| 760 | + dev_info(dev, "LinkC locked time: %d ms\n", time_ms); |
---|
| 761 | + } |
---|
| 762 | + |
---|
| 763 | + if ((lock_state & MAXIM_GMSL_LOCK_LINK_D) == 0) |
---|
| 764 | + if (max96722_get_link_lock_state(max96722, MAXIM_GMSL_LOCK_LINK_D)) { |
---|
| 765 | + lock_state |= MAXIM_GMSL_LOCK_LINK_D; |
---|
| 766 | + dev_info(dev, "LinkD locked time: %d ms\n", time_ms); |
---|
| 767 | + } |
---|
| 768 | + |
---|
| 769 | + if ((lock_state & link_mask) == link_mask) { |
---|
| 770 | + dev_info(dev, "All Links are locked: 0x%x, time_ms = %d\n", lock_state, time_ms); |
---|
| 771 | +#if 0 |
---|
| 772 | + max96722_check_remote_chipid(max96722); |
---|
| 773 | +#endif |
---|
| 774 | + return 0; |
---|
| 775 | + } |
---|
| 776 | + |
---|
| 777 | + msleep(10); |
---|
| 778 | + time_ms += 10; |
---|
| 779 | + } |
---|
| 780 | + |
---|
| 781 | + if ((lock_state & link_mask) != 0) { |
---|
| 782 | + dev_info(dev, "Partial links are locked: 0x%x, time_ms = %d\n", lock_state, time_ms); |
---|
| 783 | + return 0; |
---|
| 784 | + } else { |
---|
| 785 | + dev_err(dev, "Failed to detect camera link, time_ms = %d!\n", time_ms); |
---|
| 786 | + return -ENODEV; |
---|
| 787 | + } |
---|
| 788 | +} |
---|
| 789 | + |
---|
| 790 | +static irqreturn_t max96722_hot_plug_detect_irq_handler(int irq, void *dev_id) |
---|
| 791 | +{ |
---|
| 792 | + struct max96722 *max96722 = dev_id; |
---|
| 793 | + struct device *dev = &max96722->client->dev; |
---|
| 794 | + u8 lock_state = 0, link_mask = 0; |
---|
| 795 | + |
---|
| 796 | + link_mask = max96722->link_mask & MAXIM_GMSL_LOCK_MASK; |
---|
| 797 | + if (max96722->streaming) { |
---|
| 798 | + lock_state = max96722_get_link_lock_state(max96722, link_mask); |
---|
| 799 | + if (lock_state == link_mask) { |
---|
| 800 | + dev_info(dev, "serializer plug in, lock_state = 0x%02x\n", lock_state); |
---|
| 801 | + } else { |
---|
| 802 | + dev_info(dev, "serializer plug out, lock_state = 0x%02x\n", lock_state); |
---|
| 803 | + } |
---|
| 804 | + } |
---|
| 805 | + |
---|
| 806 | + return IRQ_HANDLED; |
---|
| 807 | +} |
---|
| 808 | + |
---|
| 809 | +static int max96722_dphy_dpll_predef_set(struct max96722 *max96722, u32 link_freq_mhz) |
---|
| 810 | +{ |
---|
| 811 | + struct device *dev = &max96722->client->dev; |
---|
| 812 | + int ret = 0; |
---|
| 813 | + u8 dpll_val = 0, dpll_lock = 0; |
---|
| 814 | + u8 mipi_tx_phy_enable = 0; |
---|
| 815 | + |
---|
| 816 | + ret = max96722_read_reg(max96722, I2C_DEV_DES, |
---|
| 817 | + 0x08A2, DEV_REG_LENGTH_16BITS, |
---|
| 818 | + DEV_REG_VALUE_08BITS, &mipi_tx_phy_enable); |
---|
| 819 | + if (ret) |
---|
| 820 | + return ret; |
---|
| 821 | + mipi_tx_phy_enable = (mipi_tx_phy_enable & 0xF0) >> 4; |
---|
| 822 | + |
---|
| 823 | + dev_info(dev, "DPLL predef set: mipi_tx_phy_enable = 0x%02x, link_freq_mhz = %d\n", |
---|
| 824 | + mipi_tx_phy_enable, link_freq_mhz); |
---|
| 825 | + |
---|
| 826 | + // dphy max data rate is 2500MHz |
---|
| 827 | + if (link_freq_mhz > (2500 >> 1)) |
---|
| 828 | + link_freq_mhz = (2500 >> 1); |
---|
| 829 | + |
---|
| 830 | + dpll_val = DIV_ROUND_UP(link_freq_mhz * 2, 100) & 0x1F; |
---|
| 831 | + // Disable software override for frequency fine tuning |
---|
| 832 | + dpll_val |= BIT(5); |
---|
| 833 | + |
---|
| 834 | + // MIPI PHY0 |
---|
| 835 | + if (mipi_tx_phy_enable & BIT(0)) { |
---|
| 836 | + // Hold DPLL in reset (config_soft_rst_n = 0) before changing the rate |
---|
| 837 | + ret |= max96722_write_reg(max96722, I2C_DEV_DES, |
---|
| 838 | + 0x1C00, DEV_REG_LENGTH_16BITS, |
---|
| 839 | + DEV_REG_VALUE_08BITS, 0xf4); |
---|
| 840 | + // Set data rate and enable software override |
---|
| 841 | + ret |= max96722_update_reg_bits(max96722, I2C_DEV_DES, |
---|
| 842 | + 0x0415, DEV_REG_LENGTH_16BITS, 0x3F, dpll_val); |
---|
| 843 | + // Release reset to DPLL (config_soft_rst_n = 1) |
---|
| 844 | + ret |= max96722_write_reg(max96722, I2C_DEV_DES, |
---|
| 845 | + 0x1C00, DEV_REG_LENGTH_16BITS, |
---|
| 846 | + DEV_REG_VALUE_08BITS, 0xf5); |
---|
| 847 | + } |
---|
| 848 | + |
---|
| 849 | + // MIPI PHY1 |
---|
| 850 | + if (mipi_tx_phy_enable & BIT(1)) { |
---|
| 851 | + // Hold DPLL in reset (config_soft_rst_n = 0) before changing the rate |
---|
| 852 | + ret |= max96722_write_reg(max96722, I2C_DEV_DES, |
---|
| 853 | + 0x1D00, DEV_REG_LENGTH_16BITS, |
---|
| 854 | + DEV_REG_VALUE_08BITS, 0xf4); |
---|
| 855 | + // Set data rate and enable software override |
---|
| 856 | + ret |= max96722_update_reg_bits(max96722, I2C_DEV_DES, |
---|
| 857 | + 0x0418, DEV_REG_LENGTH_16BITS, 0x3F, dpll_val); |
---|
| 858 | + // Release reset to DPLL (config_soft_rst_n = 1) |
---|
| 859 | + ret |= max96722_write_reg(max96722, I2C_DEV_DES, |
---|
| 860 | + 0x1D00, DEV_REG_LENGTH_16BITS, |
---|
| 861 | + DEV_REG_VALUE_08BITS, 0xf5); |
---|
| 862 | + } |
---|
| 863 | + |
---|
| 864 | + // MIPI PHY2 |
---|
| 865 | + if (mipi_tx_phy_enable & BIT(2)) { |
---|
| 866 | + // Hold DPLL in reset (config_soft_rst_n = 0) before changing the rate |
---|
| 867 | + ret |= max96722_write_reg(max96722, I2C_DEV_DES, |
---|
| 868 | + 0x1E00, DEV_REG_LENGTH_16BITS, |
---|
| 869 | + DEV_REG_VALUE_08BITS, 0xf4); |
---|
| 870 | + // Set data rate and enable software override |
---|
| 871 | + ret |= max96722_update_reg_bits(max96722, I2C_DEV_DES, |
---|
| 872 | + 0x041B, DEV_REG_LENGTH_16BITS, 0x3F, dpll_val); |
---|
| 873 | + // Release reset to DPLL (config_soft_rst_n = 1) |
---|
| 874 | + ret |= max96722_write_reg(max96722, I2C_DEV_DES, |
---|
| 875 | + 0x1E00, DEV_REG_LENGTH_16BITS, |
---|
| 876 | + DEV_REG_VALUE_08BITS, 0xf5); |
---|
| 877 | + } |
---|
| 878 | + |
---|
| 879 | + // MIPI PHY3 |
---|
| 880 | + if (mipi_tx_phy_enable & BIT(3)) { |
---|
| 881 | + // Hold DPLL in reset (config_soft_rst_n = 0) before changing the rate |
---|
| 882 | + ret |= max96722_write_reg(max96722, I2C_DEV_DES, |
---|
| 883 | + 0x1F00, DEV_REG_LENGTH_16BITS, |
---|
| 884 | + DEV_REG_VALUE_08BITS, 0xf4); |
---|
| 885 | + // Set data rate and enable software override |
---|
| 886 | + ret |= max96722_update_reg_bits(max96722, I2C_DEV_DES, |
---|
| 887 | + 0x041E, DEV_REG_LENGTH_16BITS, 0x3F, dpll_val); |
---|
| 888 | + // Release reset to DPLL (config_soft_rst_n = 1) |
---|
| 889 | + ret |= max96722_write_reg(max96722, I2C_DEV_DES, |
---|
| 890 | + 0x1F00, DEV_REG_LENGTH_16BITS, |
---|
| 891 | + DEV_REG_VALUE_08BITS, 0xf5); |
---|
| 892 | + } |
---|
| 893 | + |
---|
| 894 | + if (ret) { |
---|
| 895 | + dev_err(dev, "DPLL predef set error!\n"); |
---|
| 896 | + return ret; |
---|
| 897 | + } |
---|
| 898 | + |
---|
| 899 | + ret = read_poll_timeout(max96722_read_reg, ret, |
---|
| 900 | + !(ret < 0) && (dpll_lock & 0xF0), |
---|
| 901 | + 1000, 10000, false, |
---|
| 902 | + max96722, I2C_DEV_DES, |
---|
| 903 | + 0x0400, DEV_REG_LENGTH_16BITS, |
---|
| 904 | + DEV_REG_VALUE_08BITS, &dpll_lock); |
---|
| 905 | + if (ret < 0) { |
---|
| 906 | + dev_err(dev, "DPLL is not locked, dpll_lock = 0x%02x\n", dpll_lock); |
---|
| 907 | + return ret; |
---|
| 908 | + } else { |
---|
| 909 | + dev_err(dev, "DPLL is locked, dpll_lock = 0x%02x\n", dpll_lock); |
---|
| 910 | + return 0; |
---|
| 911 | + } |
---|
| 912 | +} |
---|
| 913 | + |
---|
| 914 | +static int max96722_auto_init_deskew(struct max96722 *max96722, u32 deskew_mask) |
---|
| 915 | +{ |
---|
| 916 | + struct device *dev = &max96722->client->dev; |
---|
| 917 | + int ret = 0; |
---|
| 918 | + |
---|
| 919 | + dev_info(dev, "Auto initial deskew: deskew_mask = 0x%02x\n", deskew_mask); |
---|
| 920 | + |
---|
| 921 | + // D-PHY Deskew Initial Calibration Control |
---|
| 922 | + if (deskew_mask & BIT(0)) // MIPI PHY0 |
---|
| 923 | + ret |= max96722_write_reg(max96722, I2C_DEV_DES, |
---|
| 924 | + 0x0903, DEV_REG_LENGTH_16BITS, |
---|
| 925 | + DEV_REG_VALUE_08BITS, 0x80); |
---|
| 926 | + |
---|
| 927 | + if (deskew_mask & BIT(1)) // MIPI PHY1 |
---|
| 928 | + ret |= max96722_write_reg(max96722, I2C_DEV_DES, |
---|
| 929 | + 0x0943, DEV_REG_LENGTH_16BITS, |
---|
| 930 | + DEV_REG_VALUE_08BITS, 0x80); |
---|
| 931 | + |
---|
| 932 | + if (deskew_mask & BIT(2)) // MIPI PHY2 |
---|
| 933 | + ret |= max96722_write_reg(max96722, I2C_DEV_DES, |
---|
| 934 | + 0x0983, DEV_REG_LENGTH_16BITS, |
---|
| 935 | + DEV_REG_VALUE_08BITS, 0x80); |
---|
| 936 | + |
---|
| 937 | + if (deskew_mask & BIT(3)) // MIPI PHY3 |
---|
| 938 | + ret |= max96722_write_reg(max96722, I2C_DEV_DES, |
---|
| 939 | + 0x09C3, DEV_REG_LENGTH_16BITS, |
---|
| 940 | + DEV_REG_VALUE_08BITS, 0x80); |
---|
| 941 | + |
---|
| 942 | + return ret; |
---|
| 943 | +} |
---|
| 944 | + |
---|
| 945 | +static int max96722_frame_sync_period(struct max96722 *max96722, u32 period) |
---|
| 946 | +{ |
---|
| 947 | + struct device *dev = &max96722->client->dev; |
---|
| 948 | + u32 pclk, fsync_peroid; |
---|
| 949 | + u8 fsync_peroid_h, fsync_peroid_m, fsync_peroid_l; |
---|
| 950 | + int ret = 0; |
---|
| 951 | + |
---|
| 952 | + if (period == 0) |
---|
| 953 | + return 0; |
---|
| 954 | + |
---|
| 955 | + dev_info(dev, "Frame sync period = %d\n", period); |
---|
| 956 | + |
---|
| 957 | +#if 1 // TODO: Sensor slave mode |
---|
| 958 | + // sendor slave mode enable |
---|
| 959 | +#endif |
---|
| 960 | + |
---|
| 961 | + // Master link Video 0 for frame sync generation |
---|
| 962 | + ret |= max96722_write_reg(max96722, I2C_DEV_DES, |
---|
| 963 | + 0x04A2, DEV_REG_LENGTH_16BITS, |
---|
| 964 | + DEV_REG_VALUE_08BITS, 0x00); |
---|
| 965 | + // Disable Vsync-Fsync overlap window |
---|
| 966 | + ret |= max96722_write_reg(max96722, I2C_DEV_DES, |
---|
| 967 | + 0x04AA, DEV_REG_LENGTH_16BITS, |
---|
| 968 | + DEV_REG_VALUE_08BITS, 0x00); |
---|
| 969 | + ret |= max96722_write_reg(max96722, I2C_DEV_DES, |
---|
| 970 | + 0x04AB, DEV_REG_LENGTH_16BITS, |
---|
| 971 | + DEV_REG_VALUE_08BITS, 0x00); |
---|
| 972 | + |
---|
| 973 | + // Set FSYNC period to 25M/30 clock cycles. PCLK = 25MHz. Sync freq = 30Hz |
---|
| 974 | + pclk = 25 * 1000 * 1000; |
---|
| 975 | + fsync_peroid = DIV_ROUND_UP(pclk, period) - 1; |
---|
| 976 | + fsync_peroid_l = (fsync_peroid >> 0) & 0xFF; |
---|
| 977 | + fsync_peroid_m = (fsync_peroid >> 8) & 0xFF; |
---|
| 978 | + fsync_peroid_h = (fsync_peroid >> 16) & 0xFF; |
---|
| 979 | + dev_info(dev, "Frame sync period: H = 0x%02x, M = 0x%02x, L = 0x%02x\n", |
---|
| 980 | + fsync_peroid_h, fsync_peroid_m, fsync_peroid_l); |
---|
| 981 | + // FSYNC_PERIOD_H |
---|
| 982 | + ret |= max96722_write_reg(max96722, I2C_DEV_DES, |
---|
| 983 | + 0x04A7, DEV_REG_LENGTH_16BITS, |
---|
| 984 | + DEV_REG_VALUE_08BITS, fsync_peroid_h); |
---|
| 985 | + // FSYNC_PERIOD_M |
---|
| 986 | + ret |= max96722_write_reg(max96722, I2C_DEV_DES, |
---|
| 987 | + 0x04A6, DEV_REG_LENGTH_16BITS, |
---|
| 988 | + DEV_REG_VALUE_08BITS, fsync_peroid_m); |
---|
| 989 | + // FSYNC_PERIOD_L |
---|
| 990 | + ret |= max96722_write_reg(max96722, I2C_DEV_DES, |
---|
| 991 | + 0x04A5, DEV_REG_LENGTH_16BITS, |
---|
| 992 | + DEV_REG_VALUE_08BITS, fsync_peroid_l); |
---|
| 993 | + |
---|
| 994 | + // FSYNC is GMSL2 type, use osc for fsync, include all links/pipes in fsync gen |
---|
| 995 | + ret |= max96722_write_reg(max96722, I2C_DEV_DES, |
---|
| 996 | + 0x04AF, DEV_REG_LENGTH_16BITS, |
---|
| 997 | + DEV_REG_VALUE_08BITS, 0xcf); |
---|
| 998 | + |
---|
| 999 | +#if 1 // TODO: Desrializer MFP |
---|
| 1000 | + // FSYNC_TX_ID: set 4 to match MFP4 on serializer side |
---|
| 1001 | + ret |= max96722_write_reg(max96722, I2C_DEV_DES, |
---|
| 1002 | + 0x04B1, DEV_REG_LENGTH_16BITS, |
---|
| 1003 | + DEV_REG_VALUE_08BITS, 0x20); |
---|
| 1004 | +#endif |
---|
| 1005 | + |
---|
| 1006 | +#if 1 // TODO: Serializer MFP |
---|
| 1007 | + // Enable GPIO_RX_EN on serializer MFP4 |
---|
| 1008 | + ret |= max96722_write_reg(max96722, I2C_DEV_SER, |
---|
| 1009 | + 0x02CA, DEV_REG_LENGTH_16BITS, |
---|
| 1010 | + DEV_REG_VALUE_08BITS, 0x84); |
---|
| 1011 | +#endif |
---|
| 1012 | + |
---|
| 1013 | + // MFP2, VS not gen internally, GPIO not used to gen fsync, manual mode |
---|
| 1014 | + ret |= max96722_write_reg(max96722, I2C_DEV_DES, |
---|
| 1015 | + 0x04A0, DEV_REG_LENGTH_16BITS, |
---|
| 1016 | + DEV_REG_VALUE_08BITS, 0x04); |
---|
| 1017 | + |
---|
| 1018 | + return ret; |
---|
| 1019 | +} |
---|
| 1020 | + |
---|
| 1021 | +static int max96722_mipi_enable(struct max96722 *max96722, bool enable) |
---|
| 1022 | +{ |
---|
| 1023 | + int ret = 0; |
---|
| 1024 | + |
---|
| 1025 | + if (enable) { |
---|
| 1026 | +#if MAXIM_FORCE_ALL_CLOCK_EN |
---|
| 1027 | + // Force all MIPI clocks running |
---|
| 1028 | + ret |= max96722_update_reg_bits(max96722, I2C_DEV_DES, |
---|
| 1029 | + 0x08A0, DEV_REG_LENGTH_16BITS, BIT(7), BIT(7)); |
---|
| 1030 | +#endif |
---|
| 1031 | + // CSI output enabled |
---|
| 1032 | + ret |= max96722_update_reg_bits(max96722, I2C_DEV_DES, |
---|
| 1033 | + 0x040B, DEV_REG_LENGTH_16BITS, BIT(1), BIT(1)); |
---|
| 1034 | + } else { |
---|
| 1035 | +#if MAXIM_FORCE_ALL_CLOCK_EN |
---|
| 1036 | + // Normal mode |
---|
| 1037 | + ret |= max96722_update_reg_bits(max96722, I2C_DEV_DES, |
---|
| 1038 | + 0x08A0, DEV_REG_LENGTH_16BITS, BIT(7), 0x00); |
---|
| 1039 | +#endif |
---|
| 1040 | + // CSI output disabled |
---|
| 1041 | + ret |= max96722_update_reg_bits(max96722, I2C_DEV_DES, |
---|
| 1042 | + 0x040B, DEV_REG_LENGTH_16BITS, BIT(1), 0x00); |
---|
| 1043 | + } |
---|
| 1044 | + |
---|
| 1045 | + return ret; |
---|
| 1046 | +} |
---|
| 1047 | + |
---|
300 | 1048 | static int max96722_get_reso_dist(const struct max96722_mode *mode, |
---|
301 | | - struct v4l2_mbus_framefmt *framefmt) |
---|
| 1049 | + struct v4l2_mbus_framefmt *framefmt) |
---|
302 | 1050 | { |
---|
303 | 1051 | return abs(mode->width - framefmt->width) + |
---|
304 | | - abs(mode->height - framefmt->height); |
---|
| 1052 | + abs(mode->height - framefmt->height); |
---|
305 | 1053 | } |
---|
306 | 1054 | |
---|
307 | 1055 | static const struct max96722_mode * |
---|
308 | | -max96722_find_best_fit(struct v4l2_subdev_format *fmt) |
---|
| 1056 | +max96722_find_best_fit(struct max96722 *max96722, struct v4l2_subdev_format *fmt) |
---|
309 | 1057 | { |
---|
310 | 1058 | struct v4l2_mbus_framefmt *framefmt = &fmt->format; |
---|
311 | 1059 | int dist; |
---|
.. | .. |
---|
313 | 1061 | int cur_best_fit_dist = -1; |
---|
314 | 1062 | unsigned int i; |
---|
315 | 1063 | |
---|
316 | | - for (i = 0; i < ARRAY_SIZE(supported_modes); i++) { |
---|
317 | | - dist = max96722_get_reso_dist(&supported_modes[i], framefmt); |
---|
318 | | - if (cur_best_fit_dist == -1 || dist < cur_best_fit_dist) { |
---|
| 1064 | + for (i = 0; i < max96722->cfg_modes_num; i++) { |
---|
| 1065 | + dist = max96722_get_reso_dist(&max96722->supported_modes[i], framefmt); |
---|
| 1066 | + if ((cur_best_fit_dist == -1 || dist < cur_best_fit_dist) |
---|
| 1067 | + && (max96722->supported_modes[i].bus_fmt == framefmt->code)) { |
---|
319 | 1068 | cur_best_fit_dist = dist; |
---|
320 | 1069 | cur_best_fit = i; |
---|
321 | 1070 | } |
---|
322 | 1071 | } |
---|
323 | 1072 | |
---|
324 | | - return &supported_modes[cur_best_fit]; |
---|
| 1073 | + return &max96722->supported_modes[cur_best_fit]; |
---|
325 | 1074 | } |
---|
326 | 1075 | |
---|
327 | 1076 | static int max96722_set_fmt(struct v4l2_subdev *sd, |
---|
328 | | - struct v4l2_subdev_pad_config *cfg, |
---|
329 | | - struct v4l2_subdev_format *fmt) |
---|
| 1077 | + struct v4l2_subdev_pad_config *cfg, |
---|
| 1078 | + struct v4l2_subdev_format *fmt) |
---|
330 | 1079 | { |
---|
331 | | - struct max96722 *max96722 = to_max96722(sd); |
---|
| 1080 | + struct max96722 *max96722 = v4l2_get_subdevdata(sd); |
---|
332 | 1081 | const struct max96722_mode *mode; |
---|
| 1082 | + u64 pixel_rate = 0; |
---|
| 1083 | + u8 data_lanes; |
---|
333 | 1084 | |
---|
334 | 1085 | mutex_lock(&max96722->mutex); |
---|
335 | 1086 | |
---|
336 | | - mode = max96722_find_best_fit(fmt); |
---|
337 | | - fmt->format.code = MAX96722_MEDIA_BUS_FMT; |
---|
| 1087 | + mode = max96722_find_best_fit(max96722, fmt); |
---|
| 1088 | + |
---|
| 1089 | + fmt->format.code = mode->bus_fmt; |
---|
338 | 1090 | fmt->format.width = mode->width; |
---|
339 | 1091 | fmt->format.height = mode->height; |
---|
340 | 1092 | fmt->format.field = V4L2_FIELD_NONE; |
---|
.. | .. |
---|
350 | 1102 | mutex_unlock(&max96722->mutex); |
---|
351 | 1103 | return -EBUSY; |
---|
352 | 1104 | } |
---|
| 1105 | + |
---|
| 1106 | + max96722->cur_mode = mode; |
---|
| 1107 | + |
---|
| 1108 | + __v4l2_ctrl_s_ctrl(max96722->link_freq, mode->link_freq_idx); |
---|
| 1109 | + /* pixel rate = link frequency * 2 * lanes / BITS_PER_SAMPLE */ |
---|
| 1110 | + data_lanes = max96722->bus_cfg.bus.mipi_csi2.num_data_lanes; |
---|
| 1111 | + pixel_rate = (u32)link_freq_items[mode->link_freq_idx] / mode->bpp * 2 * data_lanes; |
---|
| 1112 | + __v4l2_ctrl_s_ctrl_int64(max96722->pixel_rate, pixel_rate); |
---|
| 1113 | + |
---|
| 1114 | + dev_info(&max96722->client->dev, "mipi_freq_idx = %d, mipi_link_freq = %lld\n", |
---|
| 1115 | + mode->link_freq_idx, link_freq_items[mode->link_freq_idx]); |
---|
| 1116 | + dev_info(&max96722->client->dev, "pixel_rate = %lld, bpp = %d\n", |
---|
| 1117 | + pixel_rate, mode->bpp); |
---|
353 | 1118 | } |
---|
354 | 1119 | |
---|
355 | 1120 | mutex_unlock(&max96722->mutex); |
---|
.. | .. |
---|
358 | 1123 | } |
---|
359 | 1124 | |
---|
360 | 1125 | static int max96722_get_fmt(struct v4l2_subdev *sd, |
---|
361 | | - struct v4l2_subdev_pad_config *cfg, |
---|
362 | | - struct v4l2_subdev_format *fmt) |
---|
| 1126 | + struct v4l2_subdev_pad_config *cfg, |
---|
| 1127 | + struct v4l2_subdev_format *fmt) |
---|
363 | 1128 | { |
---|
364 | | - struct max96722 *max96722 = to_max96722(sd); |
---|
| 1129 | + struct max96722 *max96722 = v4l2_get_subdevdata(sd); |
---|
365 | 1130 | const struct max96722_mode *mode = max96722->cur_mode; |
---|
366 | 1131 | |
---|
367 | 1132 | mutex_lock(&max96722->mutex); |
---|
.. | .. |
---|
375 | 1140 | } else { |
---|
376 | 1141 | fmt->format.width = mode->width; |
---|
377 | 1142 | fmt->format.height = mode->height; |
---|
378 | | - fmt->format.code = MAX96722_MEDIA_BUS_FMT; |
---|
| 1143 | + fmt->format.code = mode->bus_fmt; |
---|
379 | 1144 | fmt->format.field = V4L2_FIELD_NONE; |
---|
| 1145 | + if (fmt->pad < PAD_MAX && fmt->pad >= PAD0) |
---|
| 1146 | + fmt->reserved[0] = mode->vc[fmt->pad]; |
---|
| 1147 | + else |
---|
| 1148 | + fmt->reserved[0] = mode->vc[PAD0]; |
---|
380 | 1149 | } |
---|
381 | 1150 | mutex_unlock(&max96722->mutex); |
---|
382 | 1151 | |
---|
.. | .. |
---|
384 | 1153 | } |
---|
385 | 1154 | |
---|
386 | 1155 | static int max96722_enum_mbus_code(struct v4l2_subdev *sd, |
---|
387 | | - struct v4l2_subdev_pad_config *cfg, |
---|
388 | | - struct v4l2_subdev_mbus_code_enum *code) |
---|
| 1156 | + struct v4l2_subdev_pad_config *cfg, |
---|
| 1157 | + struct v4l2_subdev_mbus_code_enum *code) |
---|
389 | 1158 | { |
---|
| 1159 | + struct max96722 *max96722 = v4l2_get_subdevdata(sd); |
---|
| 1160 | + const struct max96722_mode *mode = max96722->cur_mode; |
---|
| 1161 | + |
---|
390 | 1162 | if (code->index != 0) |
---|
391 | 1163 | return -EINVAL; |
---|
392 | | - code->code = MAX96722_MEDIA_BUS_FMT; |
---|
| 1164 | + code->code = mode->bus_fmt; |
---|
393 | 1165 | |
---|
394 | 1166 | return 0; |
---|
395 | 1167 | } |
---|
396 | 1168 | |
---|
397 | 1169 | static int max96722_enum_frame_sizes(struct v4l2_subdev *sd, |
---|
398 | | - struct v4l2_subdev_pad_config *cfg, |
---|
399 | | - struct v4l2_subdev_frame_size_enum *fse) |
---|
| 1170 | + struct v4l2_subdev_pad_config *cfg, |
---|
| 1171 | + struct v4l2_subdev_frame_size_enum *fse) |
---|
400 | 1172 | { |
---|
401 | | - if (fse->index >= ARRAY_SIZE(supported_modes)) |
---|
| 1173 | + struct max96722 *max96722 = v4l2_get_subdevdata(sd); |
---|
| 1174 | + |
---|
| 1175 | + if (fse->index >= max96722->cfg_modes_num) |
---|
402 | 1176 | return -EINVAL; |
---|
403 | 1177 | |
---|
404 | | - if (fse->code != MAX96722_MEDIA_BUS_FMT) |
---|
| 1178 | + if (fse->code != max96722->supported_modes[fse->index].bus_fmt) |
---|
405 | 1179 | return -EINVAL; |
---|
406 | 1180 | |
---|
407 | | - fse->min_width = supported_modes[fse->index].width; |
---|
408 | | - fse->max_width = supported_modes[fse->index].width; |
---|
409 | | - fse->max_height = supported_modes[fse->index].height; |
---|
410 | | - fse->min_height = supported_modes[fse->index].height; |
---|
| 1181 | + fse->min_width = max96722->supported_modes[fse->index].width; |
---|
| 1182 | + fse->max_width = max96722->supported_modes[fse->index].width; |
---|
| 1183 | + fse->max_height = max96722->supported_modes[fse->index].height; |
---|
| 1184 | + fse->min_height = max96722->supported_modes[fse->index].height; |
---|
411 | 1185 | |
---|
412 | 1186 | return 0; |
---|
413 | 1187 | } |
---|
414 | 1188 | |
---|
415 | 1189 | static int max96722_g_frame_interval(struct v4l2_subdev *sd, |
---|
416 | | - struct v4l2_subdev_frame_interval *fi) |
---|
| 1190 | + struct v4l2_subdev_frame_interval *fi) |
---|
417 | 1191 | { |
---|
418 | | - struct max96722 *max96722 = to_max96722(sd); |
---|
| 1192 | + struct max96722 *max96722 = v4l2_get_subdevdata(sd); |
---|
419 | 1193 | const struct max96722_mode *mode = max96722->cur_mode; |
---|
420 | 1194 | |
---|
421 | 1195 | mutex_lock(&max96722->mutex); |
---|
.. | .. |
---|
426 | 1200 | } |
---|
427 | 1201 | |
---|
428 | 1202 | static void max96722_get_module_inf(struct max96722 *max96722, |
---|
429 | | - struct rkmodule_inf *inf) |
---|
| 1203 | + struct rkmodule_inf *inf) |
---|
430 | 1204 | { |
---|
431 | 1205 | memset(inf, 0, sizeof(*inf)); |
---|
432 | 1206 | strscpy(inf->base.sensor, MAX96722_NAME, sizeof(inf->base.sensor)); |
---|
.. | .. |
---|
435 | 1209 | strscpy(inf->base.lens, max96722->len_name, sizeof(inf->base.lens)); |
---|
436 | 1210 | } |
---|
437 | 1211 | |
---|
438 | | -static void max96722_get_vicap_rst_inf(struct max96722 *max96722, |
---|
439 | | - struct rkmodule_vicap_reset_info *rst_info) |
---|
| 1212 | +static void |
---|
| 1213 | +max96722_get_vicap_rst_inf(struct max96722 *max96722, |
---|
| 1214 | + struct rkmodule_vicap_reset_info *rst_info) |
---|
440 | 1215 | { |
---|
441 | 1216 | struct i2c_client *client = max96722->client; |
---|
442 | 1217 | |
---|
443 | 1218 | rst_info->is_reset = max96722->hot_plug; |
---|
444 | 1219 | max96722->hot_plug = false; |
---|
445 | 1220 | rst_info->src = RKCIF_RESET_SRC_ERR_HOTPLUG; |
---|
446 | | - dev_info(&client->dev, "%s: rst_info->is_reset:%d.\n", __func__, rst_info->is_reset); |
---|
| 1221 | + dev_info(&client->dev, "%s: rst_info->is_reset:%d.\n", __func__, |
---|
| 1222 | + rst_info->is_reset); |
---|
447 | 1223 | } |
---|
448 | 1224 | |
---|
449 | | -static void max96722_set_vicap_rst_inf(struct max96722 *max96722, |
---|
450 | | - struct rkmodule_vicap_reset_info rst_info) |
---|
| 1225 | +static void |
---|
| 1226 | +max96722_set_vicap_rst_inf(struct max96722 *max96722, |
---|
| 1227 | + struct rkmodule_vicap_reset_info rst_info) |
---|
451 | 1228 | { |
---|
452 | 1229 | max96722->is_reset = rst_info.is_reset; |
---|
453 | 1230 | } |
---|
454 | 1231 | |
---|
455 | 1232 | static long max96722_ioctl(struct v4l2_subdev *sd, unsigned int cmd, void *arg) |
---|
456 | 1233 | { |
---|
457 | | - struct max96722 *max96722 = to_max96722(sd); |
---|
| 1234 | + struct max96722 *max96722 = v4l2_get_subdevdata(sd); |
---|
| 1235 | + struct rkmodule_csi_dphy_param *dphy_param; |
---|
458 | 1236 | long ret = 0; |
---|
459 | 1237 | u32 stream = 0; |
---|
460 | 1238 | |
---|
.. | .. |
---|
463 | 1241 | max96722_get_module_inf(max96722, (struct rkmodule_inf *)arg); |
---|
464 | 1242 | break; |
---|
465 | 1243 | case RKMODULE_SET_QUICK_STREAM: |
---|
466 | | - |
---|
467 | 1244 | stream = *((u32 *)arg); |
---|
468 | 1245 | |
---|
469 | 1246 | if (stream) |
---|
470 | | - ret = max96722_write_reg(max96722->client, |
---|
471 | | - MAX96722_REG_CTRL_MODE, |
---|
472 | | - MAX96722_REG_VALUE_08BIT, |
---|
473 | | - MAX96722_MODE_STREAMING); |
---|
| 1247 | + ret = max96722_mipi_enable(max96722, true); |
---|
474 | 1248 | else |
---|
475 | | - ret = max96722_write_reg(max96722->client, |
---|
476 | | - MAX96722_REG_CTRL_MODE, |
---|
477 | | - MAX96722_REG_VALUE_08BIT, |
---|
478 | | - MAX96722_MODE_SW_STANDBY); |
---|
| 1249 | + ret = max96722_mipi_enable(max96722, false); |
---|
479 | 1250 | break; |
---|
480 | 1251 | case RKMODULE_GET_VICAP_RST_INFO: |
---|
481 | | - max96722_get_vicap_rst_inf(max96722, |
---|
482 | | - (struct rkmodule_vicap_reset_info *)arg); |
---|
| 1252 | + max96722_get_vicap_rst_inf( |
---|
| 1253 | + max96722, (struct rkmodule_vicap_reset_info *)arg); |
---|
483 | 1254 | break; |
---|
484 | 1255 | case RKMODULE_SET_VICAP_RST_INFO: |
---|
485 | | - max96722_set_vicap_rst_inf(max96722, |
---|
486 | | - *(struct rkmodule_vicap_reset_info *)arg); |
---|
| 1256 | + max96722_set_vicap_rst_inf( |
---|
| 1257 | + max96722, *(struct rkmodule_vicap_reset_info *)arg); |
---|
487 | 1258 | break; |
---|
488 | | - case RKMODULE_GET_CSI_DSI_INFO: |
---|
489 | | - *(int *)arg = RKMODULE_CSI_INPUT; |
---|
| 1259 | + case RKMODULE_GET_START_STREAM_SEQ: |
---|
| 1260 | + break; |
---|
| 1261 | + case RKMODULE_SET_CSI_DPHY_PARAM: |
---|
| 1262 | + dphy_param = (struct rkmodule_csi_dphy_param *)arg; |
---|
| 1263 | + if (dphy_param->vendor == rk3588_dcphy_param.vendor) |
---|
| 1264 | + rk3588_dcphy_param = *dphy_param; |
---|
| 1265 | + dev_dbg(&max96722->client->dev, "sensor set dphy param\n"); |
---|
| 1266 | + break; |
---|
| 1267 | + case RKMODULE_GET_CSI_DPHY_PARAM: |
---|
| 1268 | + dphy_param = (struct rkmodule_csi_dphy_param *)arg; |
---|
| 1269 | + if (dphy_param->vendor == rk3588_dcphy_param.vendor) |
---|
| 1270 | + *dphy_param = rk3588_dcphy_param; |
---|
| 1271 | + dev_dbg(&max96722->client->dev, "sensor get dphy param\n"); |
---|
490 | 1272 | break; |
---|
491 | 1273 | default: |
---|
492 | 1274 | ret = -ENOIOCTLCMD; |
---|
.. | .. |
---|
497 | 1279 | } |
---|
498 | 1280 | |
---|
499 | 1281 | #ifdef CONFIG_COMPAT |
---|
500 | | -static long max96722_compat_ioctl32(struct v4l2_subdev *sd, |
---|
501 | | - unsigned int cmd, unsigned long arg) |
---|
| 1282 | +static long max96722_compat_ioctl32(struct v4l2_subdev *sd, unsigned int cmd, |
---|
| 1283 | + unsigned long arg) |
---|
502 | 1284 | { |
---|
503 | 1285 | void __user *up = compat_ptr(arg); |
---|
504 | 1286 | struct rkmodule_inf *inf; |
---|
505 | 1287 | struct rkmodule_awb_cfg *cfg; |
---|
506 | 1288 | struct rkmodule_vicap_reset_info *vicap_rst_inf; |
---|
| 1289 | + struct rkmodule_csi_dphy_param *dphy_param; |
---|
507 | 1290 | long ret = 0; |
---|
508 | 1291 | int *seq; |
---|
509 | 1292 | u32 stream = 0; |
---|
.. | .. |
---|
547 | 1330 | |
---|
548 | 1331 | ret = max96722_ioctl(sd, cmd, vicap_rst_inf); |
---|
549 | 1332 | if (!ret) { |
---|
550 | | - ret = copy_to_user(up, vicap_rst_inf, sizeof(*vicap_rst_inf)); |
---|
| 1333 | + ret = copy_to_user(up, vicap_rst_inf, |
---|
| 1334 | + sizeof(*vicap_rst_inf)); |
---|
551 | 1335 | if (ret) |
---|
552 | 1336 | ret = -EFAULT; |
---|
553 | 1337 | } |
---|
.. | .. |
---|
589 | 1373 | else |
---|
590 | 1374 | ret = -EFAULT; |
---|
591 | 1375 | break; |
---|
592 | | - case RKMODULE_GET_CSI_DSI_INFO: |
---|
593 | | - seq = kzalloc(sizeof(*seq), GFP_KERNEL); |
---|
594 | | - if (!seq) { |
---|
| 1376 | + case RKMODULE_SET_CSI_DPHY_PARAM: |
---|
| 1377 | + dphy_param = kzalloc(sizeof(*dphy_param), GFP_KERNEL); |
---|
| 1378 | + if (!dphy_param) { |
---|
595 | 1379 | ret = -ENOMEM; |
---|
596 | 1380 | return ret; |
---|
597 | 1381 | } |
---|
598 | 1382 | |
---|
599 | | - ret = max96722_ioctl(sd, cmd, seq); |
---|
| 1383 | + ret = copy_from_user(dphy_param, up, sizeof(*dphy_param)); |
---|
| 1384 | + if (!ret) |
---|
| 1385 | + ret = max96722_ioctl(sd, cmd, dphy_param); |
---|
| 1386 | + else |
---|
| 1387 | + ret = -EFAULT; |
---|
| 1388 | + kfree(dphy_param); |
---|
| 1389 | + break; |
---|
| 1390 | + case RKMODULE_GET_CSI_DPHY_PARAM: |
---|
| 1391 | + dphy_param = kzalloc(sizeof(*dphy_param), GFP_KERNEL); |
---|
| 1392 | + if (!dphy_param) { |
---|
| 1393 | + ret = -ENOMEM; |
---|
| 1394 | + return ret; |
---|
| 1395 | + } |
---|
| 1396 | + |
---|
| 1397 | + ret = max96722_ioctl(sd, cmd, dphy_param); |
---|
600 | 1398 | if (!ret) { |
---|
601 | | - ret = copy_to_user(up, seq, sizeof(*seq)); |
---|
| 1399 | + ret = copy_to_user(up, dphy_param, sizeof(*dphy_param)); |
---|
602 | 1400 | if (ret) |
---|
603 | 1401 | ret = -EFAULT; |
---|
604 | 1402 | } |
---|
605 | | - kfree(seq); |
---|
| 1403 | + kfree(dphy_param); |
---|
606 | 1404 | break; |
---|
607 | 1405 | default: |
---|
608 | 1406 | ret = -ENOIOCTLCMD; |
---|
.. | .. |
---|
616 | 1414 | static int __max96722_start_stream(struct max96722 *max96722) |
---|
617 | 1415 | { |
---|
618 | 1416 | int ret; |
---|
| 1417 | + u32 link_freq_mhz, link_freq_idx; |
---|
619 | 1418 | |
---|
620 | | - ret = max96722_write_array(max96722->client, max96722->cur_mode->reg_list); |
---|
| 1419 | + ret = max96722_check_link_lock_state(max96722); |
---|
621 | 1420 | if (ret) |
---|
622 | 1421 | return ret; |
---|
| 1422 | + |
---|
| 1423 | + if (max96722->hot_plug_irq > 0) |
---|
| 1424 | + enable_irq(max96722->hot_plug_irq); |
---|
| 1425 | + |
---|
| 1426 | + ret = max96722_write_array(max96722, |
---|
| 1427 | + max96722->cur_mode->reg_list); |
---|
| 1428 | + if (ret) |
---|
| 1429 | + return ret; |
---|
| 1430 | + |
---|
| 1431 | + link_freq_idx = max96722->cur_mode->link_freq_idx; |
---|
| 1432 | + link_freq_mhz = (u32)div_s64(link_freq_items[link_freq_idx], 1000000L); |
---|
| 1433 | + ret = max96722_dphy_dpll_predef_set(max96722, link_freq_mhz); |
---|
| 1434 | + if (ret) |
---|
| 1435 | + return ret; |
---|
| 1436 | + |
---|
| 1437 | + if (max96722->auto_init_deskew_mask != 0) { |
---|
| 1438 | + ret = max96722_auto_init_deskew(max96722, |
---|
| 1439 | + max96722->auto_init_deskew_mask); |
---|
| 1440 | + if (ret) |
---|
| 1441 | + return ret; |
---|
| 1442 | + } |
---|
| 1443 | + |
---|
| 1444 | + if (max96722->frame_sync_period != 0) { |
---|
| 1445 | + ret = max96722_frame_sync_period(max96722, |
---|
| 1446 | + max96722->frame_sync_period); |
---|
| 1447 | + if (ret) |
---|
| 1448 | + return ret; |
---|
| 1449 | + } |
---|
623 | 1450 | |
---|
624 | 1451 | /* In case these controls are set before streaming */ |
---|
625 | 1452 | mutex_unlock(&max96722->mutex); |
---|
.. | .. |
---|
628 | 1455 | if (ret) |
---|
629 | 1456 | return ret; |
---|
630 | 1457 | |
---|
631 | | - return max96722_write_reg(max96722->client, |
---|
632 | | - MAX96722_REG_CTRL_MODE, |
---|
633 | | - MAX96722_REG_VALUE_08BIT, |
---|
634 | | - MAX96722_MODE_STREAMING); |
---|
| 1458 | + return max96722_mipi_enable(max96722, true); |
---|
| 1459 | + |
---|
635 | 1460 | } |
---|
636 | 1461 | |
---|
637 | 1462 | static int __max96722_stop_stream(struct max96722 *max96722) |
---|
638 | 1463 | { |
---|
639 | | - return max96722_write_reg(max96722->client, |
---|
640 | | - MAX96722_REG_CTRL_MODE, |
---|
641 | | - MAX96722_REG_VALUE_08BIT, |
---|
642 | | - MAX96722_MODE_SW_STANDBY); |
---|
| 1464 | + if (max96722->hot_plug_irq > 0) |
---|
| 1465 | + disable_irq(max96722->hot_plug_irq); |
---|
| 1466 | + |
---|
| 1467 | + return max96722_mipi_enable(max96722, false); |
---|
643 | 1468 | } |
---|
644 | 1469 | |
---|
645 | 1470 | static int max96722_s_stream(struct v4l2_subdev *sd, int on) |
---|
646 | 1471 | { |
---|
647 | | - struct max96722 *max96722 = to_max96722(sd); |
---|
| 1472 | + struct max96722 *max96722 = v4l2_get_subdevdata(sd); |
---|
648 | 1473 | struct i2c_client *client = max96722->client; |
---|
649 | 1474 | int ret = 0; |
---|
650 | 1475 | |
---|
651 | 1476 | dev_info(&client->dev, "%s: on: %d, %dx%d@%d\n", __func__, on, |
---|
652 | | - max96722->cur_mode->width, |
---|
653 | | - max96722->cur_mode->height, |
---|
| 1477 | + max96722->cur_mode->width, max96722->cur_mode->height, |
---|
654 | 1478 | DIV_ROUND_CLOSEST(max96722->cur_mode->max_fps.denominator, |
---|
655 | | - max96722->cur_mode->max_fps.numerator)); |
---|
| 1479 | + max96722->cur_mode->max_fps.numerator)); |
---|
656 | 1480 | |
---|
657 | 1481 | mutex_lock(&max96722->mutex); |
---|
658 | 1482 | on = !!on; |
---|
.. | .. |
---|
687 | 1511 | |
---|
688 | 1512 | static int max96722_s_power(struct v4l2_subdev *sd, int on) |
---|
689 | 1513 | { |
---|
690 | | - struct max96722 *max96722 = to_max96722(sd); |
---|
| 1514 | + struct max96722 *max96722 = v4l2_get_subdevdata(sd); |
---|
691 | 1515 | struct i2c_client *client = max96722->client; |
---|
692 | 1516 | int ret = 0; |
---|
693 | 1517 | |
---|
.. | .. |
---|
728 | 1552 | u32 delay_us; |
---|
729 | 1553 | struct device *dev = &max96722->client->dev; |
---|
730 | 1554 | |
---|
731 | | - if (!IS_ERR(max96722->power_gpio)) |
---|
| 1555 | + if (!IS_ERR(max96722->power_gpio)) { |
---|
732 | 1556 | gpiod_set_value_cansleep(max96722->power_gpio, 1); |
---|
| 1557 | + usleep_range(5000, 10000); |
---|
| 1558 | + } |
---|
733 | 1559 | |
---|
734 | | - usleep_range(1000, 2000); |
---|
| 1560 | + if (!IS_ERR(max96722->pocen_gpio)) { |
---|
| 1561 | + gpiod_set_value_cansleep(max96722->pocen_gpio, 1); |
---|
| 1562 | + usleep_range(5000, 10000); |
---|
| 1563 | + } |
---|
735 | 1564 | |
---|
736 | 1565 | if (!IS_ERR_OR_NULL(max96722->pins_default)) { |
---|
737 | 1566 | ret = pinctrl_select_state(max96722->pinctrl, |
---|
738 | | - max96722->pins_default); |
---|
| 1567 | + max96722->pins_default); |
---|
739 | 1568 | if (ret < 0) |
---|
740 | 1569 | dev_err(dev, "could not set pins\n"); |
---|
741 | 1570 | } |
---|
.. | .. |
---|
748 | 1577 | dev_err(dev, "Failed to enable regulators\n"); |
---|
749 | 1578 | goto disable_clk; |
---|
750 | 1579 | } |
---|
751 | | - |
---|
752 | | - if (!IS_ERR(max96722->reset_gpio)) |
---|
| 1580 | + if (!IS_ERR(max96722->reset_gpio)) { |
---|
753 | 1581 | gpiod_set_value_cansleep(max96722->reset_gpio, 1); |
---|
| 1582 | + usleep_range(500, 1000); |
---|
| 1583 | + } |
---|
754 | 1584 | |
---|
755 | | - usleep_range(500, 1000); |
---|
756 | 1585 | if (!IS_ERR(max96722->pwdn_gpio)) |
---|
757 | 1586 | gpiod_set_value_cansleep(max96722->pwdn_gpio, 1); |
---|
758 | 1587 | |
---|
.. | .. |
---|
776 | 1605 | if (!IS_ERR(max96722->pwdn_gpio)) |
---|
777 | 1606 | gpiod_set_value_cansleep(max96722->pwdn_gpio, 0); |
---|
778 | 1607 | clk_disable_unprepare(max96722->xvclk); |
---|
| 1608 | + |
---|
779 | 1609 | if (!IS_ERR(max96722->reset_gpio)) |
---|
780 | 1610 | gpiod_set_value_cansleep(max96722->reset_gpio, 0); |
---|
781 | 1611 | |
---|
.. | .. |
---|
785 | 1615 | if (ret < 0) |
---|
786 | 1616 | dev_dbg(dev, "could not set pins\n"); |
---|
787 | 1617 | } |
---|
788 | | - if (!IS_ERR(max96722->power_gpio)) |
---|
789 | | - gpiod_set_value_cansleep(max96722->power_gpio, 0); |
---|
790 | 1618 | |
---|
791 | 1619 | regulator_bulk_disable(MAX96722_NUM_SUPPLIES, max96722->supplies); |
---|
| 1620 | + |
---|
| 1621 | + if (!IS_ERR(max96722->pocen_gpio)) |
---|
| 1622 | + gpiod_set_value_cansleep(max96722->pocen_gpio, 0); |
---|
| 1623 | + |
---|
| 1624 | + if (!IS_ERR(max96722->power_gpio)) |
---|
| 1625 | + gpiod_set_value_cansleep(max96722->power_gpio, 0); |
---|
792 | 1626 | } |
---|
793 | 1627 | |
---|
794 | 1628 | static int max96722_runtime_resume(struct device *dev) |
---|
795 | 1629 | { |
---|
796 | 1630 | struct i2c_client *client = to_i2c_client(dev); |
---|
797 | 1631 | struct v4l2_subdev *sd = i2c_get_clientdata(client); |
---|
798 | | - struct max96722 *max96722 = to_max96722(sd); |
---|
| 1632 | + struct max96722 *max96722 = v4l2_get_subdevdata(sd); |
---|
799 | 1633 | |
---|
800 | 1634 | return __max96722_power_on(max96722); |
---|
801 | 1635 | } |
---|
.. | .. |
---|
804 | 1638 | { |
---|
805 | 1639 | struct i2c_client *client = to_i2c_client(dev); |
---|
806 | 1640 | struct v4l2_subdev *sd = i2c_get_clientdata(client); |
---|
807 | | - struct max96722 *max96722 = to_max96722(sd); |
---|
| 1641 | + struct max96722 *max96722 = v4l2_get_subdevdata(sd); |
---|
808 | 1642 | |
---|
809 | 1643 | __max96722_power_off(max96722); |
---|
810 | 1644 | |
---|
.. | .. |
---|
814 | 1648 | #ifdef CONFIG_VIDEO_V4L2_SUBDEV_API |
---|
815 | 1649 | static int max96722_open(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh) |
---|
816 | 1650 | { |
---|
817 | | - struct max96722 *max96722 = to_max96722(sd); |
---|
| 1651 | + struct max96722 *max96722 = v4l2_get_subdevdata(sd); |
---|
818 | 1652 | struct v4l2_mbus_framefmt *try_fmt = |
---|
819 | | - v4l2_subdev_get_try_format(sd, fh->pad, 0); |
---|
820 | | - const struct max96722_mode *def_mode = &supported_modes[0]; |
---|
| 1653 | + v4l2_subdev_get_try_format(sd, fh->pad, 0); |
---|
| 1654 | + const struct max96722_mode *def_mode = &max96722->supported_modes[0]; |
---|
821 | 1655 | |
---|
822 | 1656 | mutex_lock(&max96722->mutex); |
---|
823 | 1657 | /* Initialize try_fmt */ |
---|
824 | 1658 | try_fmt->width = def_mode->width; |
---|
825 | 1659 | try_fmt->height = def_mode->height; |
---|
826 | | - try_fmt->code = MAX96722_MEDIA_BUS_FMT; |
---|
| 1660 | + try_fmt->code = def_mode->bus_fmt; |
---|
827 | 1661 | try_fmt->field = V4L2_FIELD_NONE; |
---|
828 | 1662 | |
---|
829 | 1663 | mutex_unlock(&max96722->mutex); |
---|
.. | .. |
---|
833 | 1667 | } |
---|
834 | 1668 | #endif |
---|
835 | 1669 | |
---|
836 | | -static int max96722_enum_frame_interval(struct v4l2_subdev *sd, |
---|
837 | | - struct v4l2_subdev_pad_config *cfg, |
---|
838 | | - struct v4l2_subdev_frame_interval_enum *fie) |
---|
| 1670 | +static int |
---|
| 1671 | +max96722_enum_frame_interval(struct v4l2_subdev *sd, |
---|
| 1672 | + struct v4l2_subdev_pad_config *cfg, |
---|
| 1673 | + struct v4l2_subdev_frame_interval_enum *fie) |
---|
839 | 1674 | { |
---|
840 | | - if (fie->index >= ARRAY_SIZE(supported_modes)) |
---|
| 1675 | + struct max96722 *max96722 = v4l2_get_subdevdata(sd); |
---|
| 1676 | + |
---|
| 1677 | + if (fie->index >= max96722->cfg_modes_num) |
---|
841 | 1678 | return -EINVAL; |
---|
842 | 1679 | |
---|
843 | | - fie->code = MAX96722_MEDIA_BUS_FMT; |
---|
844 | | - |
---|
845 | | - fie->width = supported_modes[fie->index].width; |
---|
846 | | - fie->height = supported_modes[fie->index].height; |
---|
847 | | - fie->interval = supported_modes[fie->index].max_fps; |
---|
| 1680 | + fie->code = max96722->supported_modes[fie->index].bus_fmt; |
---|
| 1681 | + fie->width = max96722->supported_modes[fie->index].width; |
---|
| 1682 | + fie->height = max96722->supported_modes[fie->index].height; |
---|
| 1683 | + fie->interval = max96722->supported_modes[fie->index].max_fps; |
---|
848 | 1684 | |
---|
849 | 1685 | return 0; |
---|
850 | 1686 | } |
---|
851 | 1687 | |
---|
852 | 1688 | static int max96722_g_mbus_config(struct v4l2_subdev *sd, unsigned int pad, |
---|
853 | | - struct v4l2_mbus_config *config) |
---|
| 1689 | + struct v4l2_mbus_config *config) |
---|
854 | 1690 | { |
---|
| 1691 | + struct max96722 *max96722 = v4l2_get_subdevdata(sd); |
---|
| 1692 | + u32 val = 0; |
---|
| 1693 | + u8 data_lanes = max96722->bus_cfg.bus.mipi_csi2.num_data_lanes; |
---|
| 1694 | + |
---|
| 1695 | + val |= V4L2_MBUS_CSI2_CONTINUOUS_CLOCK; |
---|
| 1696 | + val |= (1 << (data_lanes - 1)); |
---|
| 1697 | + switch (data_lanes) { |
---|
| 1698 | + case 4: |
---|
| 1699 | + val |= V4L2_MBUS_CSI2_CHANNEL_3; |
---|
| 1700 | + fallthrough; |
---|
| 1701 | + case 3: |
---|
| 1702 | + val |= V4L2_MBUS_CSI2_CHANNEL_2; |
---|
| 1703 | + fallthrough; |
---|
| 1704 | + case 2: |
---|
| 1705 | + val |= V4L2_MBUS_CSI2_CHANNEL_1; |
---|
| 1706 | + fallthrough; |
---|
| 1707 | + case 1: |
---|
| 1708 | + default: |
---|
| 1709 | + val |= V4L2_MBUS_CSI2_CHANNEL_0; |
---|
| 1710 | + break; |
---|
| 1711 | + } |
---|
| 1712 | + |
---|
855 | 1713 | config->type = V4L2_MBUS_CSI2_DPHY; |
---|
856 | | - config->flags = V4L2_MBUS_CSI2_4_LANE | |
---|
857 | | - V4L2_MBUS_CSI2_CHANNEL_0 | |
---|
858 | | - V4L2_MBUS_CSI2_CONTINUOUS_CLOCK; |
---|
| 1714 | + config->flags = val; |
---|
859 | 1715 | |
---|
860 | 1716 | return 0; |
---|
861 | 1717 | } |
---|
862 | 1718 | |
---|
863 | 1719 | static int max96722_get_selection(struct v4l2_subdev *sd, |
---|
864 | | - struct v4l2_subdev_pad_config *cfg, |
---|
865 | | - struct v4l2_subdev_selection *sel) |
---|
| 1720 | + struct v4l2_subdev_pad_config *cfg, |
---|
| 1721 | + struct v4l2_subdev_selection *sel) |
---|
866 | 1722 | { |
---|
867 | | - struct max96722 *max96722 = to_max96722(sd); |
---|
| 1723 | + struct max96722 *max96722 = v4l2_get_subdevdata(sd); |
---|
868 | 1724 | |
---|
869 | 1725 | if (sel->target == V4L2_SEL_TGT_CROP_BOUNDS) { |
---|
870 | 1726 | sel->r.left = 0; |
---|
.. | .. |
---|
877 | 1733 | return -EINVAL; |
---|
878 | 1734 | } |
---|
879 | 1735 | |
---|
880 | | -static const struct dev_pm_ops max96722_pm_ops = { |
---|
881 | | - SET_RUNTIME_PM_OPS(max96722_runtime_suspend, |
---|
882 | | - max96722_runtime_resume, NULL) |
---|
883 | | -}; |
---|
| 1736 | +static const struct dev_pm_ops max96722_pm_ops = { SET_RUNTIME_PM_OPS( |
---|
| 1737 | + max96722_runtime_suspend, max96722_runtime_resume, NULL) }; |
---|
884 | 1738 | |
---|
885 | 1739 | #ifdef CONFIG_VIDEO_V4L2_SUBDEV_API |
---|
886 | 1740 | static const struct v4l2_subdev_internal_ops max96722_internal_ops = { |
---|
.. | .. |
---|
912 | 1766 | }; |
---|
913 | 1767 | |
---|
914 | 1768 | static const struct v4l2_subdev_ops max96722_subdev_ops = { |
---|
915 | | - .core = &max96722_core_ops, |
---|
916 | | - .video = &max96722_video_ops, |
---|
917 | | - .pad = &max96722_pad_ops, |
---|
| 1769 | + .core = &max96722_core_ops, |
---|
| 1770 | + .video = &max96722_video_ops, |
---|
| 1771 | + .pad = &max96722_pad_ops, |
---|
918 | 1772 | }; |
---|
919 | 1773 | |
---|
920 | 1774 | static int max96722_initialize_controls(struct max96722 *max96722) |
---|
921 | 1775 | { |
---|
922 | 1776 | const struct max96722_mode *mode; |
---|
923 | 1777 | struct v4l2_ctrl_handler *handler; |
---|
| 1778 | + u64 pixel_rate; |
---|
| 1779 | + u8 data_lanes; |
---|
924 | 1780 | int ret; |
---|
925 | 1781 | |
---|
926 | 1782 | handler = &max96722->ctrl_handler; |
---|
.. | .. |
---|
932 | 1788 | handler->lock = &max96722->mutex; |
---|
933 | 1789 | |
---|
934 | 1790 | max96722->link_freq = v4l2_ctrl_new_int_menu(handler, NULL, |
---|
935 | | - V4L2_CID_LINK_FREQ, |
---|
936 | | - 1, 0, link_freq_items); |
---|
| 1791 | + V4L2_CID_LINK_FREQ, |
---|
| 1792 | + ARRAY_SIZE(link_freq_items) - 1, 0, |
---|
| 1793 | + link_freq_items); |
---|
| 1794 | + __v4l2_ctrl_s_ctrl(max96722->link_freq, mode->link_freq_idx); |
---|
| 1795 | + dev_info(&max96722->client->dev, "mipi_freq_idx = %d, mipi_link_freq = %lld\n", |
---|
| 1796 | + mode->link_freq_idx, link_freq_items[mode->link_freq_idx]); |
---|
937 | 1797 | |
---|
938 | | - max96722->pixel_rate = v4l2_ctrl_new_std(handler, NULL, |
---|
939 | | - V4L2_CID_PIXEL_RATE, |
---|
940 | | - 0, MAX96722_PIXEL_RATE, |
---|
941 | | - 1, MAX96722_PIXEL_RATE); |
---|
942 | | - |
---|
943 | | - __v4l2_ctrl_s_ctrl(max96722->link_freq, |
---|
944 | | - mode->link_freq_idx); |
---|
| 1798 | + /* pixel rate = link frequency * 2 * lanes / BITS_PER_SAMPLE */ |
---|
| 1799 | + data_lanes = max96722->bus_cfg.bus.mipi_csi2.num_data_lanes; |
---|
| 1800 | + pixel_rate = (u32)link_freq_items[mode->link_freq_idx] / mode->bpp * 2 * data_lanes; |
---|
| 1801 | + max96722->pixel_rate = |
---|
| 1802 | + v4l2_ctrl_new_std(handler, NULL, V4L2_CID_PIXEL_RATE, 0, |
---|
| 1803 | + pixel_rate, 1, pixel_rate); |
---|
| 1804 | + dev_info(&max96722->client->dev, "pixel_rate = %lld, bpp = %d\n", |
---|
| 1805 | + pixel_rate, mode->bpp); |
---|
945 | 1806 | |
---|
946 | 1807 | if (handler->error) { |
---|
947 | 1808 | ret = handler->error; |
---|
948 | | - dev_err(&max96722->client->dev, |
---|
949 | | - "Failed to init controls(%d)\n", ret); |
---|
| 1809 | + dev_err(&max96722->client->dev, "Failed to init controls(%d)\n", ret); |
---|
950 | 1810 | goto err_free_handler; |
---|
951 | 1811 | } |
---|
952 | 1812 | |
---|
.. | .. |
---|
960 | 1820 | return ret; |
---|
961 | 1821 | } |
---|
962 | 1822 | |
---|
963 | | -static int max96722_check_sensor_id(struct max96722 *max96722, |
---|
964 | | - struct i2c_client *client) |
---|
965 | | -{ |
---|
966 | | - struct device *dev = &max96722->client->dev; |
---|
967 | | - u32 id = 0; |
---|
968 | | - int ret; |
---|
969 | | - |
---|
970 | | - ret = max96722_read_reg(client, MAX96722_REG_CHIP_ID, |
---|
971 | | - MAX96722_REG_VALUE_08BIT, &id); |
---|
972 | | - if (id != CHIP_ID) { |
---|
973 | | - dev_err(dev, "Unexpected sensor id(%02x), ret(%d)\n", id, ret); |
---|
974 | | - return -ENODEV; |
---|
975 | | - } |
---|
976 | | - |
---|
977 | | - dev_info(dev, "Detected %02x sensor\n", id); |
---|
978 | | - |
---|
979 | | - return 0; |
---|
980 | | -} |
---|
981 | | - |
---|
982 | 1823 | static int max96722_configure_regulators(struct max96722 *max96722) |
---|
983 | 1824 | { |
---|
984 | 1825 | unsigned int i; |
---|
.. | .. |
---|
987 | 1828 | max96722->supplies[i].supply = max96722_supply_names[i]; |
---|
988 | 1829 | |
---|
989 | 1830 | return devm_regulator_bulk_get(&max96722->client->dev, |
---|
990 | | - MAX96722_NUM_SUPPLIES, |
---|
991 | | - max96722->supplies); |
---|
| 1831 | + MAX96722_NUM_SUPPLIES, |
---|
| 1832 | + max96722->supplies); |
---|
| 1833 | +} |
---|
| 1834 | + |
---|
| 1835 | +static int max96722_parse_dt(struct max96722 *max96722) |
---|
| 1836 | +{ |
---|
| 1837 | + struct device *dev = &max96722->client->dev; |
---|
| 1838 | + struct device_node *node = dev->of_node; |
---|
| 1839 | + u8 mipi_data_lanes = max96722->bus_cfg.bus.mipi_csi2.num_data_lanes; |
---|
| 1840 | + u32 value = 0; |
---|
| 1841 | + int ret = 0; |
---|
| 1842 | + |
---|
| 1843 | + /* serializer i2c address */ |
---|
| 1844 | + ret = of_property_read_u32(node, "ser-i2c-addr", &value); |
---|
| 1845 | + if (ret) { |
---|
| 1846 | + max96722->i2c_addr[I2C_DEV_SER] = SER_I2C_ADDR; |
---|
| 1847 | + } else { |
---|
| 1848 | + dev_info(dev, "ser-i2c-addr property: %d\n", value); |
---|
| 1849 | + max96722->i2c_addr[I2C_DEV_SER] = value; |
---|
| 1850 | + } |
---|
| 1851 | + dev_info(dev, "serializer i2c address: 0x%02x\n", max96722->i2c_addr[I2C_DEV_SER]); |
---|
| 1852 | + |
---|
| 1853 | + /* max96722 link mask: |
---|
| 1854 | + * bit[3:0] = link enable mask: 0 = disable, 1 = enable: |
---|
| 1855 | + * bit0 - LinkA, bit1 - LinkB, bit2 - LinkC, bit3 - LinkD |
---|
| 1856 | + * bit[7:4] = link type, 0 = GMSL1, 1 = GMSL2: |
---|
| 1857 | + * bit4 - LinkA, bit5 - LinkB, bit6 - LinkC, bit7 = LinkD |
---|
| 1858 | + */ |
---|
| 1859 | + ret = of_property_read_u32(node, "link-mask", &max96722->link_mask); |
---|
| 1860 | + if (ret) { |
---|
| 1861 | + /* default link mask */ |
---|
| 1862 | + if (mipi_data_lanes == 4) |
---|
| 1863 | + max96722->link_mask = 0xFF; /* Link A/B/C/D: GMSL2 and enable */ |
---|
| 1864 | + else |
---|
| 1865 | + max96722->link_mask = 0x33; /* Link A/B: GMSL2 and enable */ |
---|
| 1866 | + } else { |
---|
| 1867 | + dev_info(dev, "link-mask property: 0x%08x\n", max96722->link_mask); |
---|
| 1868 | + } |
---|
| 1869 | + dev_info(dev, "serdes link mask: 0x%02x\n", max96722->link_mask); |
---|
| 1870 | + |
---|
| 1871 | + /* auto initial deskew mask */ |
---|
| 1872 | + ret = of_property_read_u32(node, "auto-init-deskew-mask", |
---|
| 1873 | + &max96722->auto_init_deskew_mask); |
---|
| 1874 | + if (ret) |
---|
| 1875 | + max96722->auto_init_deskew_mask = 0x0F; // 0x0F: default enable all |
---|
| 1876 | + dev_info(dev, "auto init deskew mask: 0x%02x\n", max96722->auto_init_deskew_mask); |
---|
| 1877 | + |
---|
| 1878 | + /* FSYNC period config */ |
---|
| 1879 | + ret = of_property_read_u32(node, "frame-sync-period", |
---|
| 1880 | + &max96722->frame_sync_period); |
---|
| 1881 | + if (ret) |
---|
| 1882 | + max96722->frame_sync_period = 0; // 0: disable (default) |
---|
| 1883 | + dev_info(dev, "frame sync period: %d\n", max96722->frame_sync_period); |
---|
| 1884 | + |
---|
| 1885 | + return 0; |
---|
992 | 1886 | } |
---|
993 | 1887 | |
---|
994 | 1888 | static int max96722_probe(struct i2c_client *client, |
---|
995 | | - const struct i2c_device_id *id) |
---|
| 1889 | + const struct i2c_device_id *id) |
---|
996 | 1890 | { |
---|
997 | 1891 | struct device *dev = &client->dev; |
---|
998 | 1892 | struct device_node *node = dev->of_node; |
---|
999 | 1893 | struct max96722 *max96722; |
---|
1000 | 1894 | struct v4l2_subdev *sd; |
---|
| 1895 | + struct device_node *endpoint; |
---|
1001 | 1896 | char facing[2]; |
---|
| 1897 | + u8 mipi_data_lanes; |
---|
1002 | 1898 | int ret; |
---|
1003 | 1899 | |
---|
1004 | | - dev_info(dev, "driver version: %02x.%02x.%02x", |
---|
1005 | | - DRIVER_VERSION >> 16, |
---|
1006 | | - (DRIVER_VERSION & 0xff00) >> 8, |
---|
1007 | | - DRIVER_VERSION & 0x00ff); |
---|
| 1900 | + dev_info(dev, "driver version: %02x.%02x.%02x", DRIVER_VERSION >> 16, |
---|
| 1901 | + (DRIVER_VERSION & 0xff00) >> 8, DRIVER_VERSION & 0x00ff); |
---|
1008 | 1902 | |
---|
1009 | 1903 | max96722 = devm_kzalloc(dev, sizeof(*max96722), GFP_KERNEL); |
---|
1010 | 1904 | if (!max96722) |
---|
1011 | 1905 | return -ENOMEM; |
---|
1012 | 1906 | |
---|
1013 | 1907 | ret = of_property_read_u32(node, RKMODULE_CAMERA_MODULE_INDEX, |
---|
1014 | | - &max96722->module_index); |
---|
| 1908 | + &max96722->module_index); |
---|
1015 | 1909 | ret |= of_property_read_string(node, RKMODULE_CAMERA_MODULE_FACING, |
---|
1016 | | - &max96722->module_facing); |
---|
| 1910 | + &max96722->module_facing); |
---|
1017 | 1911 | ret |= of_property_read_string(node, RKMODULE_CAMERA_MODULE_NAME, |
---|
1018 | | - &max96722->module_name); |
---|
| 1912 | + &max96722->module_name); |
---|
1019 | 1913 | ret |= of_property_read_string(node, RKMODULE_CAMERA_LENS_NAME, |
---|
1020 | | - &max96722->len_name); |
---|
| 1914 | + &max96722->len_name); |
---|
1021 | 1915 | if (ret) { |
---|
1022 | 1916 | dev_err(dev, "could not get module information!\n"); |
---|
1023 | 1917 | return -EINVAL; |
---|
1024 | 1918 | } |
---|
1025 | 1919 | |
---|
| 1920 | + max96722->regmap = devm_regmap_init_i2c(client, &max96722_regmap_config); |
---|
| 1921 | + if (IS_ERR(max96722->regmap)) { |
---|
| 1922 | + dev_err(dev, "Failed to regmap initialize I2C\n"); |
---|
| 1923 | + return PTR_ERR(max96722->regmap); |
---|
| 1924 | + } |
---|
| 1925 | + |
---|
1026 | 1926 | max96722->client = client; |
---|
1027 | | - max96722->cur_mode = &supported_modes[0]; |
---|
| 1927 | + i2c_set_clientdata(client, max96722); |
---|
| 1928 | + |
---|
| 1929 | + /* i2c default address init */ |
---|
| 1930 | + max96722->i2c_addr[I2C_DEV_DES] = client->addr; |
---|
| 1931 | + max96722->i2c_addr[I2C_DEV_SER] = SER_I2C_ADDR; |
---|
| 1932 | + max96722->i2c_addr[I2C_DEV_CAM] = CAM_I2C_ADDR; |
---|
| 1933 | + |
---|
| 1934 | + endpoint = of_graph_get_next_endpoint(dev->of_node, NULL); |
---|
| 1935 | + if (!endpoint) { |
---|
| 1936 | + dev_err(dev, "Failed to get endpoint\n"); |
---|
| 1937 | + return -EINVAL; |
---|
| 1938 | + } |
---|
| 1939 | + |
---|
| 1940 | + ret = v4l2_fwnode_endpoint_parse(of_fwnode_handle(endpoint), |
---|
| 1941 | + &max96722->bus_cfg); |
---|
| 1942 | + if (ret) { |
---|
| 1943 | + dev_err(dev, "Failed to get bus config\n"); |
---|
| 1944 | + return -EINVAL; |
---|
| 1945 | + } |
---|
| 1946 | + mipi_data_lanes = max96722->bus_cfg.bus.mipi_csi2.num_data_lanes; |
---|
| 1947 | + dev_info(dev, "mipi csi2 phy data lanes %d\n", mipi_data_lanes); |
---|
| 1948 | + |
---|
| 1949 | + if (mipi_data_lanes == 4) { |
---|
| 1950 | + max96722->supported_modes = supported_modes_4lane; |
---|
| 1951 | + max96722->cfg_modes_num = ARRAY_SIZE(supported_modes_4lane); |
---|
| 1952 | + } else { |
---|
| 1953 | + dev_err(dev, "Not support mipi data lane: %d\n", mipi_data_lanes); |
---|
| 1954 | + return -EINVAL; |
---|
| 1955 | + } |
---|
| 1956 | + max96722->cur_mode = &max96722->supported_modes[0]; |
---|
1028 | 1957 | |
---|
1029 | 1958 | max96722->power_gpio = devm_gpiod_get(dev, "power", GPIOD_OUT_LOW); |
---|
1030 | 1959 | if (IS_ERR(max96722->power_gpio)) |
---|
.. | .. |
---|
1038 | 1967 | if (IS_ERR(max96722->pwdn_gpio)) |
---|
1039 | 1968 | dev_warn(dev, "Failed to get pwdn-gpios\n"); |
---|
1040 | 1969 | |
---|
| 1970 | + max96722->pocen_gpio = devm_gpiod_get(dev, "pocen", GPIOD_OUT_LOW); |
---|
| 1971 | + if (IS_ERR(max96722->pocen_gpio)) |
---|
| 1972 | + dev_warn(dev, "Failed to get pocen-gpios\n"); |
---|
| 1973 | + |
---|
| 1974 | + max96722->lock_gpio = devm_gpiod_get(dev, "lock", GPIOD_IN); |
---|
| 1975 | + if (IS_ERR(max96722->lock_gpio)) |
---|
| 1976 | + dev_warn(dev, "Failed to get lock-gpios\n"); |
---|
| 1977 | + |
---|
1041 | 1978 | ret = max96722_configure_regulators(max96722); |
---|
1042 | 1979 | if (ret) { |
---|
1043 | 1980 | dev_err(dev, "Failed to get power regulators\n"); |
---|
.. | .. |
---|
1046 | 1983 | |
---|
1047 | 1984 | max96722->pinctrl = devm_pinctrl_get(dev); |
---|
1048 | 1985 | if (!IS_ERR(max96722->pinctrl)) { |
---|
1049 | | - max96722->pins_default = |
---|
1050 | | - pinctrl_lookup_state(max96722->pinctrl, |
---|
1051 | | - OF_CAMERA_PINCTRL_STATE_DEFAULT); |
---|
| 1986 | + max96722->pins_default = pinctrl_lookup_state( |
---|
| 1987 | + max96722->pinctrl, OF_CAMERA_PINCTRL_STATE_DEFAULT); |
---|
1052 | 1988 | if (IS_ERR(max96722->pins_default)) |
---|
1053 | 1989 | dev_err(dev, "could not get default pinstate\n"); |
---|
1054 | 1990 | |
---|
1055 | | - max96722->pins_sleep = |
---|
1056 | | - pinctrl_lookup_state(max96722->pinctrl, |
---|
1057 | | - OF_CAMERA_PINCTRL_STATE_SLEEP); |
---|
| 1991 | + max96722->pins_sleep = pinctrl_lookup_state( |
---|
| 1992 | + max96722->pinctrl, OF_CAMERA_PINCTRL_STATE_SLEEP); |
---|
1058 | 1993 | if (IS_ERR(max96722->pins_sleep)) |
---|
1059 | 1994 | dev_err(dev, "could not get sleep pinstate\n"); |
---|
1060 | 1995 | } |
---|
| 1996 | + |
---|
| 1997 | + max96722_parse_dt(max96722); |
---|
1061 | 1998 | |
---|
1062 | 1999 | mutex_init(&max96722->mutex); |
---|
1063 | 2000 | |
---|
.. | .. |
---|
1071 | 2008 | if (ret) |
---|
1072 | 2009 | goto err_free_handler; |
---|
1073 | 2010 | |
---|
1074 | | - ret = max96722_write_reg(max96722->client, |
---|
1075 | | - MAX96722_REMOTE_CTRL, |
---|
1076 | | - MAX96722_REG_VALUE_08BIT, |
---|
1077 | | - MAX96722_REMOTE_DISABLE); |
---|
1078 | | - if (ret) { |
---|
1079 | | - dev_err(dev, "disable i2c remote control error\n"); |
---|
1080 | | - goto err_power_off; |
---|
1081 | | - } |
---|
1082 | | - |
---|
1083 | | - ret = max96722_check_sensor_id(max96722, client); |
---|
| 2011 | + ret = max96722_check_local_chipid(max96722); |
---|
1084 | 2012 | if (ret) |
---|
1085 | 2013 | goto err_power_off; |
---|
1086 | 2014 | |
---|
.. | .. |
---|
1102 | 2030 | else |
---|
1103 | 2031 | facing[0] = 'f'; |
---|
1104 | 2032 | |
---|
| 2033 | + v4l2_set_subdevdata(sd, max96722); |
---|
| 2034 | + |
---|
1105 | 2035 | snprintf(sd->name, sizeof(sd->name), "m%02d_%s_%s %s", |
---|
1106 | | - max96722->module_index, facing, |
---|
1107 | | - MAX96722_NAME, dev_name(sd->dev)); |
---|
| 2036 | + max96722->module_index, facing, MAX96722_NAME, |
---|
| 2037 | + dev_name(sd->dev)); |
---|
1108 | 2038 | ret = v4l2_async_register_subdev_sensor_common(sd); |
---|
1109 | 2039 | if (ret) { |
---|
1110 | 2040 | dev_err(dev, "v4l2 async register subdev failed\n"); |
---|
1111 | 2041 | goto err_clean_entity; |
---|
| 2042 | + } |
---|
| 2043 | + |
---|
| 2044 | + if (!IS_ERR(max96722->lock_gpio)) { |
---|
| 2045 | + max96722->hot_plug_irq = gpiod_to_irq(max96722->lock_gpio); |
---|
| 2046 | + if (max96722->hot_plug_irq < 0) { |
---|
| 2047 | + dev_err(dev, "failed to get hot plug irq\n"); |
---|
| 2048 | + } else { |
---|
| 2049 | + ret = devm_request_threaded_irq(dev, |
---|
| 2050 | + max96722->hot_plug_irq, |
---|
| 2051 | + NULL, |
---|
| 2052 | + max96722_hot_plug_detect_irq_handler, |
---|
| 2053 | + IRQF_TRIGGER_FALLING | IRQF_TRIGGER_RISING | IRQF_ONESHOT, |
---|
| 2054 | + "max96722_hot_plug", |
---|
| 2055 | + max96722); |
---|
| 2056 | + if (ret) { |
---|
| 2057 | + dev_err(dev, "failed to request hot plug irq (%d)\n", ret); |
---|
| 2058 | + max96722->hot_plug_irq = -1; |
---|
| 2059 | + } else { |
---|
| 2060 | + disable_irq(max96722->hot_plug_irq); |
---|
| 2061 | + } |
---|
| 2062 | + } |
---|
1112 | 2063 | } |
---|
1113 | 2064 | |
---|
1114 | 2065 | pm_runtime_set_active(dev); |
---|
.. | .. |
---|
1134 | 2085 | static int max96722_remove(struct i2c_client *client) |
---|
1135 | 2086 | { |
---|
1136 | 2087 | struct v4l2_subdev *sd = i2c_get_clientdata(client); |
---|
1137 | | - struct max96722 *max96722 = to_max96722(sd); |
---|
| 2088 | + struct max96722 *max96722 = v4l2_get_subdevdata(sd); |
---|
1138 | 2089 | |
---|
1139 | 2090 | v4l2_async_unregister_subdev(sd); |
---|
1140 | 2091 | #if defined(CONFIG_MEDIA_CONTROLLER) |
---|
.. | .. |
---|
1185 | 2136 | i2c_del_driver(&max96722_i2c_driver); |
---|
1186 | 2137 | } |
---|
1187 | 2138 | |
---|
1188 | | -device_initcall_sync(sensor_mod_init); |
---|
| 2139 | +module_init(sensor_mod_init); |
---|
1189 | 2140 | module_exit(sensor_mod_exit); |
---|
1190 | 2141 | |
---|
1191 | 2142 | MODULE_DESCRIPTION("Maxim max96722 deserializer driver"); |
---|