7
7
8
8
#include <linux/kernel.h>
9
9
#include <linux/err.h>
10
+ #include <linux/mod_devicetable.h>
10
11
#include <linux/module.h>
11
12
#include <linux/spi/spi.h>
12
13
#include <linux/i2c.h>
13
14
#include <linux/delay.h>
14
15
#include <linux/pm_runtime.h>
15
- #include <linux/of.h>
16
16
#include <linux/platform_data/sc18is602.h>
17
+ #include <linux/property.h>
18
+
17
19
#include <linux/gpio/consumer.h>
18
20
19
21
enum chips { sc18is602 , sc18is602b , sc18is603 };
@@ -236,9 +238,7 @@ static int sc18is602_setup(struct spi_device *spi)
236
238
237
239
static int sc18is602_probe (struct i2c_client * client )
238
240
{
239
- const struct i2c_device_id * id = i2c_client_get_device_id (client );
240
241
struct device * dev = & client -> dev ;
241
- struct device_node * np = dev -> of_node ;
242
242
struct sc18is602_platform_data * pdata = dev_get_platdata (dev );
243
243
struct sc18is602 * hw ;
244
244
struct spi_controller * host ;
@@ -251,8 +251,9 @@ static int sc18is602_probe(struct i2c_client *client)
251
251
if (!host )
252
252
return - ENOMEM ;
253
253
254
+ device_set_node (& host -> dev , dev_fwnode (dev ));
255
+
254
256
hw = spi_controller_get_devdata (host );
255
- i2c_set_clientdata (client , hw );
256
257
257
258
/* assert reset and then release */
258
259
hw -> reset = devm_gpiod_get_optional (dev , "reset" , GPIOD_OUT_HIGH );
@@ -265,11 +266,7 @@ static int sc18is602_probe(struct i2c_client *client)
265
266
hw -> dev = dev ;
266
267
hw -> ctrl = 0xff ;
267
268
268
- if (client -> dev .of_node )
269
- hw -> id = (uintptr_t )of_device_get_match_data (& client -> dev );
270
- else
271
- hw -> id = id -> driver_data ;
272
-
269
+ hw -> id = (uintptr_t )i2c_get_match_data (client );
273
270
switch (hw -> id ) {
274
271
case sc18is602 :
275
272
case sc18is602b :
@@ -278,28 +275,21 @@ static int sc18is602_probe(struct i2c_client *client)
278
275
break ;
279
276
case sc18is603 :
280
277
host -> num_chipselect = 2 ;
281
- if (pdata ) {
278
+ if (pdata )
282
279
hw -> freq = pdata -> clock_frequency ;
283
- } else {
284
- const __be32 * val ;
285
- int len ;
286
-
287
- val = of_get_property (np , "clock-frequency" , & len );
288
- if (val && len >= sizeof (__be32 ))
289
- hw -> freq = be32_to_cpup (val );
290
- }
280
+ else
281
+ device_property_read_u32 (dev , "clock-frequency" , & hw -> freq );
291
282
if (!hw -> freq )
292
283
hw -> freq = SC18IS602_CLOCK ;
293
284
break ;
294
285
}
295
- host -> bus_num = np ? -1 : client -> adapter -> nr ;
286
+ host -> bus_num = dev_fwnode ( dev ) ? -1 : client -> adapter -> nr ;
296
287
host -> mode_bits = SPI_CPHA | SPI_CPOL | SPI_LSB_FIRST ;
297
288
host -> bits_per_word_mask = SPI_BPW_MASK (8 );
298
289
host -> setup = sc18is602_setup ;
299
290
host -> transfer_one_message = sc18is602_transfer_one ;
300
291
host -> max_transfer_size = sc18is602_max_transfer_size ;
301
292
host -> max_message_size = sc18is602_max_transfer_size ;
302
- host -> dev .of_node = np ;
303
293
host -> min_speed_hz = hw -> freq / 128 ;
304
294
host -> max_speed_hz = hw -> freq / 4 ;
305
295
@@ -314,7 +304,7 @@ static const struct i2c_device_id sc18is602_id[] = {
314
304
};
315
305
MODULE_DEVICE_TABLE (i2c , sc18is602_id );
316
306
317
- static const struct of_device_id sc18is602_of_match [] __maybe_unused = {
307
+ static const struct of_device_id sc18is602_of_match [] = {
318
308
{
319
309
.compatible = "nxp,sc18is602" ,
320
310
.data = (void * )sc18is602
@@ -334,7 +324,7 @@ MODULE_DEVICE_TABLE(of, sc18is602_of_match);
334
324
static struct i2c_driver sc18is602_driver = {
335
325
.driver = {
336
326
.name = "sc18is602" ,
337
- .of_match_table = of_match_ptr ( sc18is602_of_match ) ,
327
+ .of_match_table = sc18is602_of_match ,
338
328
},
339
329
.probe = sc18is602_probe ,
340
330
.id_table = sc18is602_id ,
0 commit comments