10
10
#include <linux/clk.h>
11
11
#include <linux/delay.h>
12
12
#include <linux/firmware.h>
13
- #include <linux/gpio.h>
13
+ #include <linux/gpio/consumer .h>
14
14
#include <linux/i2c.h>
15
15
#include <linux/init.h>
16
16
#include <linux/media.h>
17
17
#include <linux/module.h>
18
- #include <linux/of_gpio.h>
19
18
#include <linux/of_graph.h>
20
19
#include <linux/regulator/consumer.h>
21
20
#include <linux/sizes.h>
@@ -1347,24 +1346,6 @@ static int s5c73m3_oif_open(struct v4l2_subdev *sd, struct v4l2_subdev_fh *fh)
1347
1346
return 0 ;
1348
1347
}
1349
1348
1350
- static int s5c73m3_gpio_set_value (struct s5c73m3 * priv , int id , u32 val )
1351
- {
1352
- if (!gpio_is_valid (priv -> gpio [id ].gpio ))
1353
- return 0 ;
1354
- gpio_set_value (priv -> gpio [id ].gpio , !!val );
1355
- return 1 ;
1356
- }
1357
-
1358
- static int s5c73m3_gpio_assert (struct s5c73m3 * priv , int id )
1359
- {
1360
- return s5c73m3_gpio_set_value (priv , id , priv -> gpio [id ].level );
1361
- }
1362
-
1363
- static int s5c73m3_gpio_deassert (struct s5c73m3 * priv , int id )
1364
- {
1365
- return s5c73m3_gpio_set_value (priv , id , !priv -> gpio [id ].level );
1366
- }
1367
-
1368
1349
static int __s5c73m3_power_on (struct s5c73m3 * state )
1369
1350
{
1370
1351
int i , ret ;
@@ -1386,10 +1367,9 @@ static int __s5c73m3_power_on(struct s5c73m3 *state)
1386
1367
v4l2_dbg (1 , s5c73m3_dbg , & state -> oif_sd , "clock frequency: %ld\n" ,
1387
1368
clk_get_rate (state -> clock ));
1388
1369
1389
- s5c73m3_gpio_deassert (state , STBY );
1370
+ gpiod_set_value (state -> stby , 0 );
1390
1371
usleep_range (100 , 200 );
1391
-
1392
- s5c73m3_gpio_deassert (state , RSET );
1372
+ gpiod_set_value (state -> reset , 0 );
1393
1373
usleep_range (50 , 100 );
1394
1374
1395
1375
return 0 ;
@@ -1404,11 +1384,10 @@ static int __s5c73m3_power_off(struct s5c73m3 *state)
1404
1384
{
1405
1385
int i , ret ;
1406
1386
1407
- if (s5c73m3_gpio_assert (state , RSET ))
1408
- usleep_range (10 , 50 );
1409
-
1410
- if (s5c73m3_gpio_assert (state , STBY ))
1411
- usleep_range (100 , 200 );
1387
+ gpiod_set_value (state -> reset , 1 );
1388
+ usleep_range (10 , 50 );
1389
+ gpiod_set_value (state -> stby , 1 );
1390
+ usleep_range (100 , 200 );
1412
1391
1413
1392
clk_disable_unprepare (state -> clock );
1414
1393
@@ -1543,58 +1522,10 @@ static const struct v4l2_subdev_ops oif_subdev_ops = {
1543
1522
.video = & s5c73m3_oif_video_ops ,
1544
1523
};
1545
1524
1546
- static int s5c73m3_configure_gpios (struct s5c73m3 * state )
1547
- {
1548
- static const char * const gpio_names [] = {
1549
- "S5C73M3_STBY" , "S5C73M3_RST"
1550
- };
1551
- struct i2c_client * c = state -> i2c_client ;
1552
- struct s5c73m3_gpio * g = state -> gpio ;
1553
- int ret , i ;
1554
-
1555
- for (i = 0 ; i < GPIO_NUM ; ++ i ) {
1556
- unsigned int flags = GPIOF_DIR_OUT ;
1557
- if (g [i ].level )
1558
- flags |= GPIOF_INIT_HIGH ;
1559
- ret = devm_gpio_request_one (& c -> dev , g [i ].gpio , flags ,
1560
- gpio_names [i ]);
1561
- if (ret ) {
1562
- v4l2_err (c , "failed to request gpio %s\n" ,
1563
- gpio_names [i ]);
1564
- return ret ;
1565
- }
1566
- }
1567
- return 0 ;
1568
- }
1569
-
1570
- static int s5c73m3_parse_gpios (struct s5c73m3 * state )
1571
- {
1572
- static const char * const prop_names [] = {
1573
- "standby-gpios" , "xshutdown-gpios" ,
1574
- };
1575
- struct device * dev = & state -> i2c_client -> dev ;
1576
- struct device_node * node = dev -> of_node ;
1577
- int ret , i ;
1578
-
1579
- for (i = 0 ; i < GPIO_NUM ; ++ i ) {
1580
- enum of_gpio_flags of_flags ;
1581
-
1582
- ret = of_get_named_gpio_flags (node , prop_names [i ],
1583
- 0 , & of_flags );
1584
- if (ret < 0 ) {
1585
- dev_err (dev , "failed to parse %s DT property\n" ,
1586
- prop_names [i ]);
1587
- return - EINVAL ;
1588
- }
1589
- state -> gpio [i ].gpio = ret ;
1590
- state -> gpio [i ].level = !(of_flags & OF_GPIO_ACTIVE_LOW );
1591
- }
1592
- return 0 ;
1593
- }
1594
-
1595
1525
static int s5c73m3_get_platform_data (struct s5c73m3 * state )
1596
1526
{
1597
- struct device * dev = & state -> i2c_client -> dev ;
1527
+ struct i2c_client * c = state -> i2c_client ;
1528
+ struct device * dev = & c -> dev ;
1598
1529
const struct s5c73m3_platform_data * pdata = dev -> platform_data ;
1599
1530
struct device_node * node = dev -> of_node ;
1600
1531
struct device_node * node_ep ;
@@ -1608,8 +1539,6 @@ static int s5c73m3_get_platform_data(struct s5c73m3 *state)
1608
1539
}
1609
1540
1610
1541
state -> mclk_frequency = pdata -> mclk_frequency ;
1611
- state -> gpio [STBY ] = pdata -> gpio_stby ;
1612
- state -> gpio [RSET ] = pdata -> gpio_reset ;
1613
1542
return 0 ;
1614
1543
}
1615
1544
@@ -1624,9 +1553,17 @@ static int s5c73m3_get_platform_data(struct s5c73m3 *state)
1624
1553
state -> mclk_frequency );
1625
1554
}
1626
1555
1627
- ret = s5c73m3_parse_gpios (state );
1628
- if (ret < 0 )
1629
- return - EINVAL ;
1556
+ /* Request GPIO lines asserted */
1557
+ state -> stby = devm_gpiod_get (dev , "standby" , GPIOD_OUT_HIGH );
1558
+ if (IS_ERR (state -> stby ))
1559
+ return dev_err_probe (dev , PTR_ERR (state -> stby ),
1560
+ "failed to request gpio S5C73M3_STBY\n" );
1561
+ gpiod_set_consumer_name (state -> stby , "S5C73M3_STBY" );
1562
+ state -> reset = devm_gpiod_get (dev , "xshutdown" , GPIOD_OUT_HIGH );
1563
+ if (IS_ERR (state -> reset ))
1564
+ return dev_err_probe (dev , PTR_ERR (state -> reset ),
1565
+ "failed to request gpio S5C73M3_RST\n" );
1566
+ gpiod_set_consumer_name (state -> reset , "S5C73M3_RST" );
1630
1567
1631
1568
node_ep = of_graph_get_next_endpoint (node , NULL );
1632
1569
if (!node_ep ) {
@@ -1708,10 +1645,6 @@ static int s5c73m3_probe(struct i2c_client *client)
1708
1645
if (ret < 0 )
1709
1646
return ret ;
1710
1647
1711
- ret = s5c73m3_configure_gpios (state );
1712
- if (ret )
1713
- goto out_err ;
1714
-
1715
1648
for (i = 0 ; i < S5C73M3_MAX_SUPPLIES ; i ++ )
1716
1649
state -> supplies [i ].supply = s5c73m3_supply_names [i ];
1717
1650
0 commit comments