@@ -92,13 +92,22 @@ struct clk_si5341_output_config {
92
92
#define SI5341_PN_BASE 0x0002
93
93
#define SI5341_DEVICE_REV 0x0005
94
94
#define SI5341_STATUS 0x000C
95
+ #define SI5341_LOS 0x000D
96
+ #define SI5341_STATUS_STICKY 0x0011
97
+ #define SI5341_LOS_STICKY 0x0012
95
98
#define SI5341_SOFT_RST 0x001C
96
99
#define SI5341_IN_SEL 0x0021
97
100
#define SI5341_DEVICE_READY 0x00FE
98
101
#define SI5341_XAXB_CFG 0x090E
99
102
#define SI5341_IN_EN 0x0949
100
103
#define SI5341_INX_TO_PFD_EN 0x094A
101
104
105
+ /* Status bits */
106
+ #define SI5341_STATUS_SYSINCAL BIT(0)
107
+ #define SI5341_STATUS_LOSXAXB BIT(1)
108
+ #define SI5341_STATUS_LOSREF BIT(2)
109
+ #define SI5341_STATUS_LOL BIT(3)
110
+
102
111
/* Input selection */
103
112
#define SI5341_IN_SEL_MASK 0x06
104
113
#define SI5341_IN_SEL_SHIFT 1
@@ -1416,6 +1425,7 @@ static int si5341_probe(struct i2c_client *client,
1416
1425
unsigned int i ;
1417
1426
struct clk_si5341_output_config config [SI5341_MAX_NUM_OUTPUTS ];
1418
1427
bool initialization_required ;
1428
+ u32 status ;
1419
1429
1420
1430
data = devm_kzalloc (& client -> dev , sizeof (* data ), GFP_KERNEL );
1421
1431
if (!data )
@@ -1583,6 +1593,22 @@ static int si5341_probe(struct i2c_client *client,
1583
1593
return err ;
1584
1594
}
1585
1595
1596
+ /* wait for device to report input clock present and PLL lock */
1597
+ err = regmap_read_poll_timeout (data -> regmap , SI5341_STATUS , status ,
1598
+ !(status & (SI5341_STATUS_LOSREF | SI5341_STATUS_LOL )),
1599
+ 10000 , 250000 );
1600
+ if (err ) {
1601
+ dev_err (& client -> dev , "Error waiting for input clock or PLL lock\n" );
1602
+ return err ;
1603
+ }
1604
+
1605
+ /* clear sticky alarm bits from initialization */
1606
+ err = regmap_write (data -> regmap , SI5341_STATUS_STICKY , 0 );
1607
+ if (err ) {
1608
+ dev_err (& client -> dev , "unable to clear sticky status\n" );
1609
+ return err ;
1610
+ }
1611
+
1586
1612
/* Free the names, clk framework makes copies */
1587
1613
for (i = 0 ; i < data -> num_synth ; ++ i )
1588
1614
devm_kfree (& client -> dev , (void * )synth_clock_names [i ]);
0 commit comments