Commit 648bf4fb authored by mark gross's avatar mark gross Committed by Linus Torvalds

[PATCH] tlclk driver update

some driver clean ups, and a re-posting of changes that are needed

to match the updated TPS.
Signed-off-by: default avatarMark Gross <mark.gross@intel.com>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent da9bb1d2
...@@ -34,7 +34,6 @@ ...@@ -34,7 +34,6 @@
#include <linux/kernel.h> /* printk() */ #include <linux/kernel.h> /* printk() */
#include <linux/fs.h> /* everything... */ #include <linux/fs.h> /* everything... */
#include <linux/errno.h> /* error codes */ #include <linux/errno.h> /* error codes */
#include <linux/delay.h> /* udelay */
#include <linux/slab.h> #include <linux/slab.h>
#include <linux/ioport.h> #include <linux/ioport.h>
#include <linux/interrupt.h> #include <linux/interrupt.h>
...@@ -156,6 +155,8 @@ This directory exports the following interfaces. There operation is ...@@ -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. documented in the MCPBL0010 TPS under the Telecom Clock API section, 11.4.
alarms : alarms :
current_ref : current_ref :
received_ref_clk3a :
received_ref_clk3b :
enable_clk3a_output : enable_clk3a_output :
enable_clk3b_output : enable_clk3b_output :
enable_clka0_output : enable_clka0_output :
...@@ -165,7 +166,7 @@ enable_clkb1_output : ...@@ -165,7 +166,7 @@ enable_clkb1_output :
filter_select : filter_select :
hardware_switching : hardware_switching :
hardware_switching_mode : hardware_switching_mode :
interrupt_switch : telclock_version :
mode_select : mode_select :
refalign : refalign :
reset : reset :
...@@ -173,7 +174,6 @@ select_amcb1_transmit_clock : ...@@ -173,7 +174,6 @@ select_amcb1_transmit_clock :
select_amcb2_transmit_clock : select_amcb2_transmit_clock :
select_redundant_clock : select_redundant_clock :
select_ref_frequency : select_ref_frequency :
test_mode :
All sysfs interfaces are integers in hex format, i.e echo 99 > refalign All sysfs interfaces are integers in hex format, i.e echo 99 > refalign
has the same effect as echo 0x99 > refalign. has the same effect as echo 0x99 > refalign.
...@@ -226,7 +226,7 @@ static int tlclk_release(struct inode *inode, struct file *filp) ...@@ -226,7 +226,7 @@ static int tlclk_release(struct inode *inode, struct file *filp)
return 0; 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) loff_t *f_pos)
{ {
if (count < sizeof(struct tlclk_alarms)) if (count < sizeof(struct tlclk_alarms))
...@@ -242,7 +242,7 @@ ssize_t tlclk_read(struct file *filp, char __user *buf, size_t count, ...@@ -242,7 +242,7 @@ ssize_t tlclk_read(struct file *filp, char __user *buf, size_t count,
return sizeof(struct tlclk_alarms); 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) loff_t *f_pos)
{ {
return 0; return 0;
...@@ -278,21 +278,21 @@ static ssize_t show_current_ref(struct device *d, ...@@ -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 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) struct device_attribute *attr, char *buf)
{ {
unsigned long ret_val; unsigned long ret_val;
unsigned long flags; unsigned long flags;
spin_lock_irqsave(&event_lock, flags); spin_lock_irqsave(&event_lock, flags);
ret_val = inb(TLCLK_REG6); ret_val = inb(TLCLK_REG5);
spin_unlock_irqrestore(&event_lock, flags); spin_unlock_irqrestore(&event_lock, flags);
return sprintf(buf, "0x%lX\n", ret_val); return sprintf(buf, "0x%lX\n", ret_val);
} }
static DEVICE_ATTR(interrupt_switch, S_IRUGO, static DEVICE_ATTR(telclock_version, S_IRUGO,
show_interrupt_switch, NULL); show_telclock_version, NULL);
static ssize_t show_alarms(struct device *d, static ssize_t show_alarms(struct device *d,
struct device_attribute *attr, char *buf) struct device_attribute *attr, char *buf)
...@@ -309,6 +309,50 @@ static ssize_t show_alarms(struct device *d, ...@@ -309,6 +309,50 @@ static ssize_t show_alarms(struct device *d,
static DEVICE_ATTR(alarms, S_IRUGO, show_alarms, NULL); 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, static ssize_t store_enable_clk3b_output(struct device *d,
struct device_attribute *attr, const char *buf, size_t count) struct device_attribute *attr, const char *buf, size_t count)
{ {
...@@ -436,26 +480,6 @@ static ssize_t store_enable_clka0_output(struct device *d, ...@@ -436,26 +480,6 @@ static ssize_t store_enable_clka0_output(struct device *d,
static DEVICE_ATTR(enable_clka0_output, S_IWUGO, NULL, static DEVICE_ATTR(enable_clka0_output, S_IWUGO, NULL,
store_enable_clka0_output); 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, static ssize_t store_select_amcb2_transmit_clock(struct device *d,
struct device_attribute *attr, const char *buf, size_t count) struct device_attribute *attr, const char *buf, size_t count)
{ {
...@@ -475,7 +499,7 @@ static ssize_t store_select_amcb2_transmit_clock(struct device *d, ...@@ -475,7 +499,7 @@ static ssize_t store_select_amcb2_transmit_clock(struct device *d,
SET_PORT_BITS(TLCLK_REG3, 0xc7, 0x38); SET_PORT_BITS(TLCLK_REG3, 0xc7, 0x38);
switch (val) { switch (val) {
case CLK_8_592MHz: case CLK_8_592MHz:
SET_PORT_BITS(TLCLK_REG0, 0xfc, 1); SET_PORT_BITS(TLCLK_REG0, 0xfc, 2);
break; break;
case CLK_11_184MHz: case CLK_11_184MHz:
SET_PORT_BITS(TLCLK_REG0, 0xfc, 0); SET_PORT_BITS(TLCLK_REG0, 0xfc, 0);
...@@ -484,7 +508,7 @@ static ssize_t store_select_amcb2_transmit_clock(struct device *d, ...@@ -484,7 +508,7 @@ static ssize_t store_select_amcb2_transmit_clock(struct device *d,
SET_PORT_BITS(TLCLK_REG0, 0xfc, 3); SET_PORT_BITS(TLCLK_REG0, 0xfc, 3);
break; break;
case CLK_44_736MHz: case CLK_44_736MHz:
SET_PORT_BITS(TLCLK_REG0, 0xfc, 2); SET_PORT_BITS(TLCLK_REG0, 0xfc, 1);
break; break;
} }
} else } else
...@@ -653,9 +677,7 @@ static ssize_t store_refalign (struct device *d, ...@@ -653,9 +677,7 @@ static ssize_t store_refalign (struct device *d,
dev_dbg(d, "tmp = 0x%lX\n", tmp); dev_dbg(d, "tmp = 0x%lX\n", tmp);
spin_lock_irqsave(&event_lock, flags); spin_lock_irqsave(&event_lock, flags);
SET_PORT_BITS(TLCLK_REG0, 0xf7, 0); SET_PORT_BITS(TLCLK_REG0, 0xf7, 0);
udelay(2);
SET_PORT_BITS(TLCLK_REG0, 0xf7, 0x08); SET_PORT_BITS(TLCLK_REG0, 0xf7, 0x08);
udelay(2);
SET_PORT_BITS(TLCLK_REG0, 0xf7, 0); SET_PORT_BITS(TLCLK_REG0, 0xf7, 0);
spin_unlock_irqrestore(&event_lock, flags); spin_unlock_irqrestore(&event_lock, flags);
...@@ -706,15 +728,16 @@ static DEVICE_ATTR(reset, S_IWUGO, NULL, store_reset); ...@@ -706,15 +728,16 @@ static DEVICE_ATTR(reset, S_IWUGO, NULL, store_reset);
static struct attribute *tlclk_sysfs_entries[] = { static struct attribute *tlclk_sysfs_entries[] = {
&dev_attr_current_ref.attr, &dev_attr_current_ref.attr,
&dev_attr_interrupt_switch.attr, &dev_attr_telclock_version.attr,
&dev_attr_alarms.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_clk3a_output.attr,
&dev_attr_enable_clk3b_output.attr, &dev_attr_enable_clk3b_output.attr,
&dev_attr_enable_clkb1_output.attr, &dev_attr_enable_clkb1_output.attr,
&dev_attr_enable_clka1_output.attr, &dev_attr_enable_clka1_output.attr,
&dev_attr_enable_clkb0_output.attr, &dev_attr_enable_clkb0_output.attr,
&dev_attr_enable_clka0_output.attr, &dev_attr_enable_clka0_output.attr,
&dev_attr_test_mode.attr,
&dev_attr_select_amcb1_transmit_clock.attr, &dev_attr_select_amcb1_transmit_clock.attr,
&dev_attr_select_amcb2_transmit_clock.attr, &dev_attr_select_amcb2_transmit_clock.attr,
&dev_attr_select_redundant_clock.attr, &dev_attr_select_redundant_clock.attr,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment