3434#include <linux/kernel.h> /* printk() */
3535#include <linux/fs.h> /* everything... */
3636#include <linux/errno.h> /* error codes */
37- #include <linux/delay.h> /* udelay */
3837#include <linux/slab.h>
3938#include <linux/ioport.h>
4039#include <linux/interrupt.h>
@@ -156,6 +155,8 @@ This directory exports the following interfaces. There operation is
156155documented in the MCPBL0010 TPS under the Telecom Clock API section, 11.4.
157156alarms :
158157current_ref :
158+ received_ref_clk3a :
159+ received_ref_clk3b :
159160enable_clk3a_output :
160161enable_clk3b_output :
161162enable_clka0_output :
@@ -165,15 +166,14 @@ enable_clkb1_output :
165166filter_select :
166167hardware_switching :
167168hardware_switching_mode :
168- interrupt_switch :
169+ telclock_version :
169170mode_select :
170171refalign :
171172reset :
172173select_amcb1_transmit_clock :
173174select_amcb2_transmit_clock :
174175select_redundant_clock :
175176select_ref_frequency :
176- test_mode :
177177
178178All sysfs interfaces are integers in hex format, i.e echo 99 > refalign
179179has the same effect as echo 0x99 > refalign.
@@ -226,7 +226,7 @@ static int tlclk_release(struct inode *inode, struct file *filp)
226226 return 0 ;
227227}
228228
229- ssize_t tlclk_read (struct file * filp , char __user * buf , size_t count ,
229+ static ssize_t tlclk_read (struct file * filp , char __user * buf , size_t count ,
230230 loff_t * f_pos )
231231{
232232 if (count < sizeof (struct tlclk_alarms ))
@@ -242,7 +242,7 @@ ssize_t tlclk_read(struct file *filp, char __user *buf, size_t count,
242242 return sizeof (struct tlclk_alarms );
243243}
244244
245- ssize_t tlclk_write (struct file * filp , const char __user * buf , size_t count ,
245+ static ssize_t tlclk_write (struct file * filp , const char __user * buf , size_t count ,
246246 loff_t * f_pos )
247247{
248248 return 0 ;
@@ -278,21 +278,21 @@ static ssize_t show_current_ref(struct device *d,
278278static DEVICE_ATTR (current_ref , S_IRUGO , show_current_ref , NULL) ;
279279
280280
281- static ssize_t show_interrupt_switch (struct device * d ,
281+ static ssize_t show_telclock_version (struct device * d ,
282282 struct device_attribute * attr , char * buf )
283283{
284284 unsigned long ret_val ;
285285 unsigned long flags ;
286286
287287 spin_lock_irqsave (& event_lock , flags );
288- ret_val = inb (TLCLK_REG6 );
288+ ret_val = inb (TLCLK_REG5 );
289289 spin_unlock_irqrestore (& event_lock , flags );
290290
291291 return sprintf (buf , "0x%lX\n" , ret_val );
292292}
293293
294- static DEVICE_ATTR (interrupt_switch , S_IRUGO ,
295- show_interrupt_switch , NULL) ;
294+ static DEVICE_ATTR (telclock_version , S_IRUGO ,
295+ show_telclock_version , NULL) ;
296296
297297static ssize_t show_alarms (struct device * d ,
298298 struct device_attribute * attr , char * buf )
@@ -309,6 +309,50 @@ static ssize_t show_alarms(struct device *d,
309309
310310static DEVICE_ATTR (alarms , S_IRUGO , show_alarms , NULL) ;
311311
312+ static ssize_t store_received_ref_clk3a (struct device * d ,
313+ struct device_attribute * attr , const char * buf , size_t count )
314+ {
315+ unsigned long tmp ;
316+ unsigned char val ;
317+ unsigned long flags ;
318+
319+ sscanf (buf , "%lX" , & tmp );
320+ dev_dbg (d , ": tmp = 0x%lX\n" , tmp );
321+
322+ val = (unsigned char )tmp ;
323+ spin_lock_irqsave (& event_lock , flags );
324+ SET_PORT_BITS (TLCLK_REG1 , 0xef , val );
325+ spin_unlock_irqrestore (& event_lock , flags );
326+
327+ return strnlen (buf , count );
328+ }
329+
330+ static DEVICE_ATTR (received_ref_clk3a , S_IWUGO , NULL,
331+ store_received_ref_clk3a ) ;
332+
333+
334+ static ssize_t store_received_ref_clk3b (struct device * d ,
335+ struct device_attribute * attr , const char * buf , size_t count )
336+ {
337+ unsigned long tmp ;
338+ unsigned char val ;
339+ unsigned long flags ;
340+
341+ sscanf (buf , "%lX" , & tmp );
342+ dev_dbg (d , ": tmp = 0x%lX\n" , tmp );
343+
344+ val = (unsigned char )tmp ;
345+ spin_lock_irqsave (& event_lock , flags );
346+ SET_PORT_BITS (TLCLK_REG1 , 0xef , val << 1 );
347+ spin_unlock_irqrestore (& event_lock , flags );
348+
349+ return strnlen (buf , count );
350+ }
351+
352+ static DEVICE_ATTR (received_ref_clk3b , S_IWUGO , NULL,
353+ store_received_ref_clk3b ) ;
354+
355+
312356static ssize_t store_enable_clk3b_output (struct device * d ,
313357 struct device_attribute * attr , const char * buf , size_t count )
314358{
@@ -436,26 +480,6 @@ static ssize_t store_enable_clka0_output(struct device *d,
436480static DEVICE_ATTR (enable_clka0_output , S_IWUGO , NULL,
437481 store_enable_clka0_output ) ;
438482
439- static ssize_t store_test_mode (struct device * d ,
440- struct device_attribute * attr , const char * buf , size_t count )
441- {
442- unsigned long flags ;
443- unsigned long tmp ;
444- unsigned char val ;
445-
446- sscanf (buf , "%lX" , & tmp );
447- dev_dbg (d , "tmp = 0x%lX\n" , tmp );
448-
449- val = (unsigned char )tmp ;
450- spin_lock_irqsave (& event_lock , flags );
451- SET_PORT_BITS (TLCLK_REG4 , 0xfd , 2 );
452- spin_unlock_irqrestore (& event_lock , flags );
453-
454- return strnlen (buf , count );
455- }
456-
457- static DEVICE_ATTR (test_mode , S_IWUGO , NULL, store_test_mode ) ;
458-
459483static ssize_t store_select_amcb2_transmit_clock (struct device * d ,
460484 struct device_attribute * attr , const char * buf , size_t count )
461485{
@@ -475,7 +499,7 @@ static ssize_t store_select_amcb2_transmit_clock(struct device *d,
475499 SET_PORT_BITS (TLCLK_REG3 , 0xc7 , 0x38 );
476500 switch (val ) {
477501 case CLK_8_592MHz :
478- SET_PORT_BITS (TLCLK_REG0 , 0xfc , 1 );
502+ SET_PORT_BITS (TLCLK_REG0 , 0xfc , 2 );
479503 break ;
480504 case CLK_11_184MHz :
481505 SET_PORT_BITS (TLCLK_REG0 , 0xfc , 0 );
@@ -484,7 +508,7 @@ static ssize_t store_select_amcb2_transmit_clock(struct device *d,
484508 SET_PORT_BITS (TLCLK_REG0 , 0xfc , 3 );
485509 break ;
486510 case CLK_44_736MHz :
487- SET_PORT_BITS (TLCLK_REG0 , 0xfc , 2 );
511+ SET_PORT_BITS (TLCLK_REG0 , 0xfc , 1 );
488512 break ;
489513 }
490514 } else
@@ -653,9 +677,7 @@ static ssize_t store_refalign (struct device *d,
653677 dev_dbg (d , "tmp = 0x%lX\n" , tmp );
654678 spin_lock_irqsave (& event_lock , flags );
655679 SET_PORT_BITS (TLCLK_REG0 , 0xf7 , 0 );
656- udelay (2 );
657680 SET_PORT_BITS (TLCLK_REG0 , 0xf7 , 0x08 );
658- udelay (2 );
659681 SET_PORT_BITS (TLCLK_REG0 , 0xf7 , 0 );
660682 spin_unlock_irqrestore (& event_lock , flags );
661683
@@ -706,15 +728,16 @@ static DEVICE_ATTR(reset, S_IWUGO, NULL, store_reset);
706728
707729static struct attribute * tlclk_sysfs_entries [] = {
708730 & dev_attr_current_ref .attr ,
709- & dev_attr_interrupt_switch .attr ,
731+ & dev_attr_telclock_version .attr ,
710732 & dev_attr_alarms .attr ,
733+ & dev_attr_received_ref_clk3a .attr ,
734+ & dev_attr_received_ref_clk3b .attr ,
711735 & dev_attr_enable_clk3a_output .attr ,
712736 & dev_attr_enable_clk3b_output .attr ,
713737 & dev_attr_enable_clkb1_output .attr ,
714738 & dev_attr_enable_clka1_output .attr ,
715739 & dev_attr_enable_clkb0_output .attr ,
716740 & dev_attr_enable_clka0_output .attr ,
717- & dev_attr_test_mode .attr ,
718741 & dev_attr_select_amcb1_transmit_clock .attr ,
719742 & dev_attr_select_amcb2_transmit_clock .attr ,
720743 & dev_attr_select_redundant_clock .attr ,
0 commit comments