@@ -77,6 +77,7 @@ struct chip_desc {
77
77
pca954x_ismux = 0 ,
78
78
pca954x_isswi
79
79
} muxtype ;
80
+ struct i2c_device_identity id ;
80
81
};
81
82
82
83
struct pca954x {
@@ -97,59 +98,83 @@ static const struct chip_desc chips[] = {
97
98
.nchans = 2 ,
98
99
.enable = 0x4 ,
99
100
.muxtype = pca954x_ismux ,
101
+ .id = { .manufacturer_id = I2C_DEVICE_ID_NONE },
100
102
},
101
103
[pca_9542 ] = {
102
104
.nchans = 2 ,
103
105
.enable = 0x4 ,
104
106
.has_irq = 1 ,
105
107
.muxtype = pca954x_ismux ,
108
+ .id = { .manufacturer_id = I2C_DEVICE_ID_NONE },
106
109
},
107
110
[pca_9543 ] = {
108
111
.nchans = 2 ,
109
112
.has_irq = 1 ,
110
113
.muxtype = pca954x_isswi ,
114
+ .id = { .manufacturer_id = I2C_DEVICE_ID_NONE },
111
115
},
112
116
[pca_9544 ] = {
113
117
.nchans = 4 ,
114
118
.enable = 0x4 ,
115
119
.has_irq = 1 ,
116
120
.muxtype = pca954x_ismux ,
121
+ .id = { .manufacturer_id = I2C_DEVICE_ID_NONE },
117
122
},
118
123
[pca_9545 ] = {
119
124
.nchans = 4 ,
120
125
.has_irq = 1 ,
121
126
.muxtype = pca954x_isswi ,
127
+ .id = { .manufacturer_id = I2C_DEVICE_ID_NONE },
122
128
},
123
129
[pca_9546 ] = {
124
130
.nchans = 4 ,
125
131
.muxtype = pca954x_isswi ,
132
+ .id = { .manufacturer_id = I2C_DEVICE_ID_NONE },
126
133
},
127
134
[pca_9547 ] = {
128
135
.nchans = 8 ,
129
136
.enable = 0x8 ,
130
137
.muxtype = pca954x_ismux ,
138
+ .id = { .manufacturer_id = I2C_DEVICE_ID_NONE },
131
139
},
132
140
[pca_9548 ] = {
133
141
.nchans = 8 ,
134
142
.muxtype = pca954x_isswi ,
143
+ .id = { .manufacturer_id = I2C_DEVICE_ID_NONE },
135
144
},
136
145
[pca_9846 ] = {
137
146
.nchans = 4 ,
138
147
.muxtype = pca954x_isswi ,
148
+ .id = {
149
+ .manufacturer_id = I2C_DEVICE_ID_NXP_SEMICONDUCTORS ,
150
+ .part_id = 0x10b ,
151
+ },
139
152
},
140
153
[pca_9847 ] = {
141
154
.nchans = 8 ,
142
155
.enable = 0x8 ,
143
156
.muxtype = pca954x_ismux ,
157
+ .id = {
158
+ .manufacturer_id = I2C_DEVICE_ID_NXP_SEMICONDUCTORS ,
159
+ .part_id = 0x108 ,
160
+ },
144
161
},
145
162
[pca_9848 ] = {
146
163
.nchans = 8 ,
147
164
.muxtype = pca954x_isswi ,
165
+ .id = {
166
+ .manufacturer_id = I2C_DEVICE_ID_NXP_SEMICONDUCTORS ,
167
+ .part_id = 0x10a ,
168
+ },
148
169
},
149
170
[pca_9849 ] = {
150
171
.nchans = 4 ,
151
172
.enable = 0x4 ,
152
173
.muxtype = pca954x_ismux ,
174
+ .id = {
175
+ .manufacturer_id = I2C_DEVICE_ID_NXP_SEMICONDUCTORS ,
176
+ .part_id = 0x109 ,
177
+ },
153
178
},
154
179
};
155
180
@@ -369,6 +394,30 @@ static int pca954x_probe(struct i2c_client *client,
369
394
if (IS_ERR (gpio ))
370
395
return PTR_ERR (gpio );
371
396
397
+ match = of_match_device (of_match_ptr (pca954x_of_match ), & client -> dev );
398
+ if (match )
399
+ data -> chip = of_device_get_match_data (& client -> dev );
400
+ else
401
+ data -> chip = & chips [id -> driver_data ];
402
+
403
+ if (data -> chip -> id .manufacturer_id != I2C_DEVICE_ID_NONE ) {
404
+ struct i2c_device_identity id ;
405
+
406
+ ret = i2c_get_device_id (client , & id );
407
+ if (ret && ret != - EOPNOTSUPP )
408
+ return ret ;
409
+
410
+ if (!ret &&
411
+ (id .manufacturer_id != data -> chip -> id .manufacturer_id ||
412
+ id .part_id != data -> chip -> id .part_id )) {
413
+ dev_warn (& client -> dev ,
414
+ "unexpected device id %03x-%03x-%x\n" ,
415
+ id .manufacturer_id , id .part_id ,
416
+ id .die_revision );
417
+ return - ENODEV ;
418
+ }
419
+ }
420
+
372
421
/* Write the mux register at addr to verify
373
422
* that the mux is in fact present. This also
374
423
* initializes the mux to disconnected state.
@@ -378,12 +427,6 @@ static int pca954x_probe(struct i2c_client *client,
378
427
return - ENODEV ;
379
428
}
380
429
381
- match = of_match_device (of_match_ptr (pca954x_of_match ), & client -> dev );
382
- if (match )
383
- data -> chip = of_device_get_match_data (& client -> dev );
384
- else
385
- data -> chip = & chips [id -> driver_data ];
386
-
387
430
data -> last_chan = 0 ; /* force the first selection */
388
431
389
432
idle_disconnect_dt = of_node &&
0 commit comments