Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

[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: Mark Gross <mark.gross@intel.com>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>

authored by

mark gross and committed by
Linus Torvalds
648bf4fb da9bb1d2

+58 -35
+58 -35
drivers/char/tlclk.c
··· 34 34 #include <linux/kernel.h> /* printk() */ 35 35 #include <linux/fs.h> /* everything... */ 36 36 #include <linux/errno.h> /* error codes */ 37 - #include <linux/delay.h> /* udelay */ 38 37 #include <linux/slab.h> 39 38 #include <linux/ioport.h> 40 39 #include <linux/interrupt.h> ··· 155 156 documented in the MCPBL0010 TPS under the Telecom Clock API section, 11.4. 156 157 alarms : 157 158 current_ref : 159 + received_ref_clk3a : 160 + received_ref_clk3b : 158 161 enable_clk3a_output : 159 162 enable_clk3b_output : 160 163 enable_clka0_output : ··· 166 165 filter_select : 167 166 hardware_switching : 168 167 hardware_switching_mode : 169 - interrupt_switch : 168 + telclock_version : 170 169 mode_select : 171 170 refalign : 172 171 reset : ··· 174 173 select_amcb2_transmit_clock : 175 174 select_redundant_clock : 176 175 select_ref_frequency : 177 - test_mode : 178 176 179 177 All sysfs interfaces are integers in hex format, i.e echo 99 > refalign 180 178 has the same effect as echo 0x99 > refalign. ··· 226 226 return 0; 227 227 } 228 228 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, 230 230 loff_t *f_pos) 231 231 { 232 232 if (count < sizeof(struct tlclk_alarms)) ··· 242 242 return sizeof(struct tlclk_alarms); 243 243 } 244 244 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, 246 246 loff_t *f_pos) 247 247 { 248 248 return 0; ··· 278 278 static DEVICE_ATTR(current_ref, S_IRUGO, show_current_ref, NULL); 279 279 280 280 281 - static ssize_t show_interrupt_switch(struct device *d, 281 + static ssize_t show_telclock_version(struct device *d, 282 282 struct device_attribute *attr, char *buf) 283 283 { 284 284 unsigned long ret_val; 285 285 unsigned long flags; 286 286 287 287 spin_lock_irqsave(&event_lock, flags); 288 - ret_val = inb(TLCLK_REG6); 288 + ret_val = inb(TLCLK_REG5); 289 289 spin_unlock_irqrestore(&event_lock, flags); 290 290 291 291 return sprintf(buf, "0x%lX\n", ret_val); 292 292 } 293 293 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); 296 296 297 297 static ssize_t show_alarms(struct device *d, 298 298 struct device_attribute *attr, char *buf) ··· 308 308 } 309 309 310 310 static DEVICE_ATTR(alarms, S_IRUGO, show_alarms, NULL); 311 + 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 + 311 355 312 356 static ssize_t store_enable_clk3b_output(struct device *d, 313 357 struct device_attribute *attr, const char *buf, size_t count) ··· 480 436 static DEVICE_ATTR(enable_clka0_output, S_IWUGO, NULL, 481 437 store_enable_clka0_output); 482 438 483 - static ssize_t store_test_mode(struct device *d, 484 - struct device_attribute *attr, const char *buf, size_t count) 485 - { 486 - unsigned long flags; 487 - unsigned long tmp; 488 - unsigned char val; 489 - 490 - sscanf(buf, "%lX", &tmp); 491 - dev_dbg(d, "tmp = 0x%lX\n", tmp); 492 - 493 - val = (unsigned char)tmp; 494 - spin_lock_irqsave(&event_lock, flags); 495 - SET_PORT_BITS(TLCLK_REG4, 0xfd, 2); 496 - spin_unlock_irqrestore(&event_lock, flags); 497 - 498 - return strnlen(buf, count); 499 - } 500 - 501 - static DEVICE_ATTR(test_mode, S_IWUGO, NULL, store_test_mode); 502 - 503 439 static ssize_t store_select_amcb2_transmit_clock(struct device *d, 504 440 struct device_attribute *attr, const char *buf, size_t count) 505 441 { ··· 499 475 SET_PORT_BITS(TLCLK_REG3, 0xc7, 0x38); 500 476 switch (val) { 501 477 case CLK_8_592MHz: 502 - SET_PORT_BITS(TLCLK_REG0, 0xfc, 1); 478 + SET_PORT_BITS(TLCLK_REG0, 0xfc, 2); 503 479 break; 504 480 case CLK_11_184MHz: 505 481 SET_PORT_BITS(TLCLK_REG0, 0xfc, 0); ··· 508 484 SET_PORT_BITS(TLCLK_REG0, 0xfc, 3); 509 485 break; 510 486 case CLK_44_736MHz: 511 - SET_PORT_BITS(TLCLK_REG0, 0xfc, 2); 487 + SET_PORT_BITS(TLCLK_REG0, 0xfc, 1); 512 488 break; 513 489 } 514 490 } else ··· 677 653 dev_dbg(d, "tmp = 0x%lX\n", tmp); 678 654 spin_lock_irqsave(&event_lock, flags); 679 655 SET_PORT_BITS(TLCLK_REG0, 0xf7, 0); 680 - udelay(2); 681 656 SET_PORT_BITS(TLCLK_REG0, 0xf7, 0x08); 682 - udelay(2); 683 657 SET_PORT_BITS(TLCLK_REG0, 0xf7, 0); 684 658 spin_unlock_irqrestore(&event_lock, flags); 685 659 ··· 728 706 729 707 static struct attribute *tlclk_sysfs_entries[] = { 730 708 &dev_attr_current_ref.attr, 731 - &dev_attr_interrupt_switch.attr, 709 + &dev_attr_telclock_version.attr, 732 710 &dev_attr_alarms.attr, 711 + &dev_attr_received_ref_clk3a.attr, 712 + &dev_attr_received_ref_clk3b.attr, 733 713 &dev_attr_enable_clk3a_output.attr, 734 714 &dev_attr_enable_clk3b_output.attr, 735 715 &dev_attr_enable_clkb1_output.attr, 736 716 &dev_attr_enable_clka1_output.attr, 737 717 &dev_attr_enable_clkb0_output.attr, 738 718 &dev_attr_enable_clka0_output.attr, 739 - &dev_attr_test_mode.attr, 740 719 &dev_attr_select_amcb1_transmit_clock.attr, 741 720 &dev_attr_select_amcb2_transmit_clock.attr, 742 721 &dev_attr_select_redundant_clock.attr,