Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 18988
b: refs/heads/master
c: 648bf4f
h: refs/heads/master
v: v3
  • Loading branch information
mark gross authored and Linus Torvalds committed Jan 19, 2006
1 parent df8d987 commit 6ed7056
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 36 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: da9bb1d27b21cb24cbb6a2efb5d3c464d357a01e
refs/heads/master: 648bf4fb21f5ce993403901ed82399abaa150b63
93 changes: 58 additions & 35 deletions trunk/drivers/char/tlclk.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
#include <linux/kernel.h> /* printk() */
#include <linux/fs.h> /* everything... */
#include <linux/errno.h> /* error codes */
#include <linux/delay.h> /* udelay */
#include <linux/slab.h>
#include <linux/ioport.h>
#include <linux/interrupt.h>
Expand Down Expand Up @@ -156,6 +155,8 @@ This directory exports the following interfaces. There operation is
documented in the MCPBL0010 TPS under the Telecom Clock API section, 11.4.
alarms :
current_ref :
received_ref_clk3a :
received_ref_clk3b :
enable_clk3a_output :
enable_clk3b_output :
enable_clka0_output :
Expand All @@ -165,15 +166,14 @@ enable_clkb1_output :
filter_select :
hardware_switching :
hardware_switching_mode :
interrupt_switch :
telclock_version :
mode_select :
refalign :
reset :
select_amcb1_transmit_clock :
select_amcb2_transmit_clock :
select_redundant_clock :
select_ref_frequency :
test_mode :
All sysfs interfaces are integers in hex format, i.e echo 99 > refalign
has the same effect as echo 0x99 > refalign.
Expand Down Expand Up @@ -226,7 +226,7 @@ static int tlclk_release(struct inode *inode, struct file *filp)
return 0;
}

ssize_t tlclk_read(struct file *filp, char __user *buf, size_t count,
static ssize_t tlclk_read(struct file *filp, char __user *buf, size_t count,
loff_t *f_pos)
{
if (count < sizeof(struct tlclk_alarms))
Expand All @@ -242,7 +242,7 @@ ssize_t tlclk_read(struct file *filp, char __user *buf, size_t count,
return sizeof(struct tlclk_alarms);
}

ssize_t tlclk_write(struct file *filp, const char __user *buf, size_t count,
static ssize_t tlclk_write(struct file *filp, const char __user *buf, size_t count,
loff_t *f_pos)
{
return 0;
Expand Down Expand Up @@ -278,21 +278,21 @@ static ssize_t show_current_ref(struct device *d,
static DEVICE_ATTR(current_ref, S_IRUGO, show_current_ref, NULL);


static ssize_t show_interrupt_switch(struct device *d,
static ssize_t show_telclock_version(struct device *d,
struct device_attribute *attr, char *buf)
{
unsigned long ret_val;
unsigned long flags;

spin_lock_irqsave(&event_lock, flags);
ret_val = inb(TLCLK_REG6);
ret_val = inb(TLCLK_REG5);
spin_unlock_irqrestore(&event_lock, flags);

return sprintf(buf, "0x%lX\n", ret_val);
}

static DEVICE_ATTR(interrupt_switch, S_IRUGO,
show_interrupt_switch, NULL);
static DEVICE_ATTR(telclock_version, S_IRUGO,
show_telclock_version, NULL);

static ssize_t show_alarms(struct device *d,
struct device_attribute *attr, char *buf)
Expand All @@ -309,6 +309,50 @@ static ssize_t show_alarms(struct device *d,

static DEVICE_ATTR(alarms, S_IRUGO, show_alarms, NULL);

static ssize_t store_received_ref_clk3a(struct device *d,
struct device_attribute *attr, const char *buf, size_t count)
{
unsigned long tmp;
unsigned char val;
unsigned long flags;

sscanf(buf, "%lX", &tmp);
dev_dbg(d, ": tmp = 0x%lX\n", tmp);

val = (unsigned char)tmp;
spin_lock_irqsave(&event_lock, flags);
SET_PORT_BITS(TLCLK_REG1, 0xef, val);
spin_unlock_irqrestore(&event_lock, flags);

return strnlen(buf, count);
}

static DEVICE_ATTR(received_ref_clk3a, S_IWUGO, NULL,
store_received_ref_clk3a);


static ssize_t store_received_ref_clk3b(struct device *d,
struct device_attribute *attr, const char *buf, size_t count)
{
unsigned long tmp;
unsigned char val;
unsigned long flags;

sscanf(buf, "%lX", &tmp);
dev_dbg(d, ": tmp = 0x%lX\n", tmp);

val = (unsigned char)tmp;
spin_lock_irqsave(&event_lock, flags);
SET_PORT_BITS(TLCLK_REG1, 0xef, val << 1);
spin_unlock_irqrestore(&event_lock, flags);

return strnlen(buf, count);
}

static DEVICE_ATTR(received_ref_clk3b, S_IWUGO, NULL,
store_received_ref_clk3b);


static ssize_t store_enable_clk3b_output(struct device *d,
struct device_attribute *attr, const char *buf, size_t count)
{
Expand Down Expand Up @@ -436,26 +480,6 @@ static ssize_t store_enable_clka0_output(struct device *d,
static DEVICE_ATTR(enable_clka0_output, S_IWUGO, NULL,
store_enable_clka0_output);

static ssize_t store_test_mode(struct device *d,
struct device_attribute *attr, const char *buf, size_t count)
{
unsigned long flags;
unsigned long tmp;
unsigned char val;

sscanf(buf, "%lX", &tmp);
dev_dbg(d, "tmp = 0x%lX\n", tmp);

val = (unsigned char)tmp;
spin_lock_irqsave(&event_lock, flags);
SET_PORT_BITS(TLCLK_REG4, 0xfd, 2);
spin_unlock_irqrestore(&event_lock, flags);

return strnlen(buf, count);
}

static DEVICE_ATTR(test_mode, S_IWUGO, NULL, store_test_mode);

static ssize_t store_select_amcb2_transmit_clock(struct device *d,
struct device_attribute *attr, const char *buf, size_t count)
{
Expand All @@ -475,7 +499,7 @@ static ssize_t store_select_amcb2_transmit_clock(struct device *d,
SET_PORT_BITS(TLCLK_REG3, 0xc7, 0x38);
switch (val) {
case CLK_8_592MHz:
SET_PORT_BITS(TLCLK_REG0, 0xfc, 1);
SET_PORT_BITS(TLCLK_REG0, 0xfc, 2);
break;
case CLK_11_184MHz:
SET_PORT_BITS(TLCLK_REG0, 0xfc, 0);
Expand All @@ -484,7 +508,7 @@ static ssize_t store_select_amcb2_transmit_clock(struct device *d,
SET_PORT_BITS(TLCLK_REG0, 0xfc, 3);
break;
case CLK_44_736MHz:
SET_PORT_BITS(TLCLK_REG0, 0xfc, 2);
SET_PORT_BITS(TLCLK_REG0, 0xfc, 1);
break;
}
} else
Expand Down Expand Up @@ -653,9 +677,7 @@ static ssize_t store_refalign (struct device *d,
dev_dbg(d, "tmp = 0x%lX\n", tmp);
spin_lock_irqsave(&event_lock, flags);
SET_PORT_BITS(TLCLK_REG0, 0xf7, 0);
udelay(2);
SET_PORT_BITS(TLCLK_REG0, 0xf7, 0x08);
udelay(2);
SET_PORT_BITS(TLCLK_REG0, 0xf7, 0);
spin_unlock_irqrestore(&event_lock, flags);

Expand Down Expand Up @@ -706,15 +728,16 @@ static DEVICE_ATTR(reset, S_IWUGO, NULL, store_reset);

static struct attribute *tlclk_sysfs_entries[] = {
&dev_attr_current_ref.attr,
&dev_attr_interrupt_switch.attr,
&dev_attr_telclock_version.attr,
&dev_attr_alarms.attr,
&dev_attr_received_ref_clk3a.attr,
&dev_attr_received_ref_clk3b.attr,
&dev_attr_enable_clk3a_output.attr,
&dev_attr_enable_clk3b_output.attr,
&dev_attr_enable_clkb1_output.attr,
&dev_attr_enable_clka1_output.attr,
&dev_attr_enable_clkb0_output.attr,
&dev_attr_enable_clka0_output.attr,
&dev_attr_test_mode.attr,
&dev_attr_select_amcb1_transmit_clock.attr,
&dev_attr_select_amcb2_transmit_clock.attr,
&dev_attr_select_redundant_clock.attr,
Expand Down

0 comments on commit 6ed7056

Please sign in to comment.