1/* 2 * Chassis LCD/LED driver for HP-PARISC workstations 3 * 4 * (c) Copyright 2000 Red Hat Software 5 * (c) Copyright 2000 Helge Deller <hdeller@redhat.com> 6 * (c) Copyright 2001-2002 Helge Deller <deller@gmx.de> 7 * (c) Copyright 2001 Randolph Chung <tausq@debian.org> 8 * 9 * This program is free software; you can redistribute it and/or modify 10 * it under the terms of the GNU General Public License as published by 11 * the Free Software Foundation; either version 2 of the License, or 12 * (at your option) any later version. 13 * 14 * TODO: 15 * - speed-up calculations with inlined assembler 16 * - interface to write to second row of LCD from /proc 17 */ 18 19#include <linux/config.h> 20#include <linux/module.h> 21#include <linux/stddef.h> /* for offsetof() */ 22#include <linux/init.h> 23#include <linux/types.h> 24#include <linux/ioport.h> 25#include <linux/bitops.h> 26#include <linux/version.h> 27#include <linux/delay.h> 28#include <linux/netdevice.h> 29#include <linux/interrupt.h> 30#include <linux/kernel_stat.h> 31#include <linux/reboot.h> 32#include <linux/proc_fs.h> 33#include <linux/ctype.h> 34#include <asm/io.h> 35#include <asm/gsc.h> 36#include <asm/processor.h> 37#include <asm/hardware.h> 38#include <asm/param.h> /* HZ */ 39#include <asm/led.h> 40#include <asm/pdc.h> 41#include <asm/uaccess.h> 42 43/* The control of the LEDs and LCDs on PARISC-machines have to be done 44 completely in software. The necessary calculations are done in a tasklet 45 which is scheduled at every timer interrupt and since the calculations 46 may consume relatively much CPU-time some of the calculations can be 47 turned off with the following variables (controlled via procfs) */ 48 49static int led_type = -1; 50static int led_heartbeat = 1; 51static int led_diskio = 1; 52static int led_lanrxtx = 1; 53static char lcd_text[32]; 54 55#define DPRINTK(x) 56 57 58#define CALC_ADD(val, comp, add) \ 59 (val<=(comp/8) ? add/16 : val<=(comp/4) ? add/8 : val<=(comp/2) ? add/4 : add) 60 61 62struct lcd_block { 63 unsigned char command; /* stores the command byte */ 64 unsigned char on; /* value for turning LED on */ 65 unsigned char off; /* value for turning LED off */ 66}; 67 68/* Structure returned by PDC_RETURN_CHASSIS_INFO */ 69/* NOTE: we use unsigned long:16 two times, since the following member 70 lcd_cmd_reg_addr needs to be 64bit aligned on 64bit PA2.0-machines */ 71struct pdc_chassis_lcd_info_ret_block { 72 unsigned long model:16; /* DISPLAY_MODEL_XXXX */ 73 unsigned long lcd_width:16; /* width of the LCD in chars (DISPLAY_MODEL_LCD only) */ 74 char *lcd_cmd_reg_addr; /* ptr to LCD cmd-register & data ptr for LED */ 75 char *lcd_data_reg_addr; /* ptr to LCD data-register (LCD only) */ 76 unsigned int min_cmd_delay; /* delay in uS after cmd-write (LCD only) */ 77 unsigned char reset_cmd1; /* command #1 for writing LCD string (LCD only) */ 78 unsigned char reset_cmd2; /* command #2 for writing LCD string (LCD only) */ 79 unsigned char act_enable; /* 0 = no activity (LCD only) */ 80 struct lcd_block heartbeat; 81 struct lcd_block disk_io; 82 struct lcd_block lan_rcv; 83 struct lcd_block lan_tx; 84 char _pad; 85}; 86 87 88/* LCD_CMD and LCD_DATA for KittyHawk machines */ 89#define KITTYHAWK_LCD_CMD (0xfffffffff0190000UL) /* 64bit-ready */ 90#define KITTYHAWK_LCD_DATA (KITTYHAWK_LCD_CMD+1) 91 92/* lcd_info is pre-initialized to the values needed to program KittyHawk LCD's 93 * HP seems to have used Sharp/Hitachi HD44780 LCDs most of the time. */ 94static struct pdc_chassis_lcd_info_ret_block 95lcd_info __attribute__((aligned(8))) = 96{ 97 model: DISPLAY_MODEL_LCD, 98 lcd_width: 16, 99 lcd_cmd_reg_addr: (char *) KITTYHAWK_LCD_CMD, 100 lcd_data_reg_addr:(char *) KITTYHAWK_LCD_DATA, 101 min_cmd_delay: 40, 102 reset_cmd1: 0x80, 103 reset_cmd2: 0xc0, 104}; 105 106 107/* direct access to some of the lcd_info variables */ 108#define LCD_CMD_REG lcd_info.lcd_cmd_reg_addr 109#define LCD_DATA_REG lcd_info.lcd_data_reg_addr 110#define LED_DATA_REG lcd_info.lcd_cmd_reg_addr /* LASI & ASP only */ 111 112 113/* ptr to LCD/LED-specific function */ 114static void (*led_func_ptr) (unsigned char); 115 116#define LED_HASLCD 1 117#define LED_NOLCD 0 118#ifdef CONFIG_PROC_FS 119static int led_proc_read(char *page, char **start, off_t off, int count, 120 int *eof, void *data) 121{ 122 char *out = page; 123 int len; 124 125 switch ((long)data) 126 { 127 case LED_NOLCD: 128 out += sprintf(out, "Heartbeat: %d\n", led_heartbeat); 129 out += sprintf(out, "Disk IO: %d\n", led_diskio); 130 out += sprintf(out, "LAN Rx/Tx: %d\n", led_lanrxtx); 131 break; 132 case LED_HASLCD: 133 out += sprintf(out, "%s\n", lcd_text); 134 break; 135 default: 136 *eof = 1; 137 return 0; 138 } 139 140 len = out - page - off; 141 if (len < count) { 142 *eof = 1; 143 if (len <= 0) return 0; 144 } else { 145 len = count; 146 } 147 *start = page + off; 148 return len; 149} 150 151static int led_proc_write(struct file *file, const char *buf, 152 unsigned long count, void *data) 153{ 154 char *cur, lbuf[count]; 155 int d; 156 157 if (!capable(CAP_SYS_ADMIN)) 158 return -EACCES; 159 160 memset(lbuf, 0, count); 161 162 copy_from_user(lbuf, buf, count); 163 cur = lbuf; 164 165 /* skip initial spaces */ 166 while (*cur && isspace(*cur)) 167 { 168 cur++; 169 } 170 171 switch ((long)data) 172 { 173 case LED_NOLCD: 174 d = *cur++ - '0'; 175 if (d != 0 && d != 1) goto parse_error; 176 led_heartbeat = d; 177 178 if (*cur++ != ' ') goto parse_error; 179 180 d = *cur++ - '0'; 181 if (d != 0 && d != 1) goto parse_error; 182 led_diskio = d; 183 184 if (*cur++ != ' ') goto parse_error; 185 186 d = *cur++ - '0'; 187 if (d != 0 && d != 1) goto parse_error; 188 led_lanrxtx = d; 189 190 break; 191 case LED_HASLCD: 192 if (*cur == 0) 193 { 194 /* reset to default */ 195 lcd_print("Linux " UTS_RELEASE); 196 } 197 else 198 { 199 /* chop off trailing \n.. if the user gives multiple 200 * \n then it's all their fault.. */ 201 if (*cur && cur[strlen(cur)-1] == '\n') 202 cur[strlen(cur)-1] = 0; 203 lcd_print(cur); 204 } 205 break; 206 default: 207 return 0; 208 } 209 210 return count; 211 212parse_error: 213 if ((long)data == LED_NOLCD) 214 printk(KERN_CRIT "Parse error: expect \"n n n\" (n == 0 or 1) for heartbeat,\ndisk io and lan tx/rx indicators\n"); 215 return -EINVAL; 216} 217 218static int __init led_create_procfs(void) 219{ 220 struct proc_dir_entry *proc_pdc_root = NULL; 221 struct proc_dir_entry *ent; 222 223 if (led_type == -1) return -1; 224 225 proc_pdc_root = proc_mkdir("pdc", 0); 226 if (!proc_pdc_root) return -1; 227 proc_pdc_root->owner = THIS_MODULE; 228 ent = create_proc_entry("led", S_IFREG|S_IRUGO|S_IWUSR, proc_pdc_root); 229 if (!ent) return -1; 230 ent->nlink = 1; 231 ent->data = (void *)LED_NOLCD; /* LED */ 232 ent->read_proc = led_proc_read; 233 ent->write_proc = led_proc_write; 234 ent->owner = THIS_MODULE; 235 236 if (led_type == LED_HASLCD) 237 { 238 ent = create_proc_entry("lcd", S_IFREG|S_IRUGO|S_IWUSR, proc_pdc_root); 239 if (!ent) return -1; 240 ent->nlink = 1; 241 ent->data = (void *)LED_HASLCD; /* LCD */ 242 ent->read_proc = led_proc_read; 243 ent->write_proc = led_proc_write; 244 ent->owner = THIS_MODULE; 245 } 246 247 return 0; 248} 249#endif 250 251/* 252 ** 253 ** led_ASP_driver() 254 ** 255 */ 256#define LED_DATA 0x01 /* data to shift (0:on 1:off) */ 257#define LED_STROBE 0x02 /* strobe to clock data */ 258static void led_ASP_driver(unsigned char leds) 259{ 260 int i; 261 262 leds = ~leds; 263 for (i = 0; i < 8; i++) { 264 unsigned char value; 265 value = (leds & 0x80) >> 7; 266 gsc_writeb( value, LED_DATA_REG ); 267 gsc_writeb( value | LED_STROBE, LED_DATA_REG ); 268 leds <<= 1; 269 } 270} 271 272 273/* 274 ** 275 ** led_LASI_driver() 276 ** 277 */ 278static void led_LASI_driver(unsigned char leds) 279{ 280 leds = ~leds; 281 gsc_writeb( leds, LED_DATA_REG ); 282} 283 284 285/* 286 ** 287 ** led_LCD_driver() 288 ** 289 ** The logic of the LCD driver is, that we write at every scheduled call 290 ** only to one of LCD_CMD_REG _or_ LCD_DATA_REG - registers. 291 ** That way we don't need to let this tasklet busywait for min_cmd_delay 292 ** milliseconds. 293 ** 294 ** TODO: check the value of "min_cmd_delay" against the value of HZ. 295 ** 296 */ 297static void led_LCD_driver(unsigned char leds) 298{ 299 static int last_index; /* 0:heartbeat, 1:disk, 2:lan_in, 3:lan_out */ 300 static int last_was_cmd;/* 0: CMD was written last, 1: DATA was last */ 301 struct lcd_block *block_ptr; 302 int value; 303 304 switch (last_index) { 305 case 0: block_ptr = &lcd_info.heartbeat; 306 value = leds & LED_HEARTBEAT; 307 break; 308 case 1: block_ptr = &lcd_info.disk_io; 309 value = leds & LED_DISK_IO; 310 break; 311 case 2: block_ptr = &lcd_info.lan_rcv; 312 value = leds & LED_LAN_RCV; 313 break; 314 case 3: block_ptr = &lcd_info.lan_tx; 315 value = leds & LED_LAN_TX; 316 break; 317 default: /* should never happen: */ 318 return; 319 } 320 321 if (last_was_cmd) { 322 /* write the value to the LCD data port */ 323 gsc_writeb( value ? block_ptr->on : block_ptr->off, LCD_DATA_REG ); 324 } else { 325 /* write the command-byte to the LCD command register */ 326 gsc_writeb( block_ptr->command, LCD_CMD_REG ); 327 } 328 329 /* now update the vars for the next interrupt iteration */ 330 if (++last_was_cmd == 2) { /* switch between cmd & data */ 331 last_was_cmd = 0; 332 if (++last_index == 4) 333 last_index = 0; /* switch back to heartbeat index */ 334 } 335} 336 337 338/* 339 ** 340 ** led_get_net_stats() 341 ** 342 ** calculate the TX- & RX-troughput on the network interfaces in 343 ** the system for usage in the LED code 344 ** 345 ** (analog to dev_get_info() from net/core/dev.c) 346 ** 347 */ 348static unsigned long led_net_rx_counter, led_net_tx_counter; 349 350static void led_get_net_stats(int addvalue) 351{ 352 static unsigned long rx_total_last, tx_total_last; 353 unsigned long rx_total, tx_total; 354 struct net_device *dev; 355 struct net_device_stats *stats; 356 357 rx_total = tx_total = 0; 358 359 /* we are running as a tasklet, so locking dev_base 360 * for reading should be OK */ 361 read_lock(&dev_base_lock); 362 for (dev = dev_base; dev != NULL; dev = dev->next) { 363 if (dev->get_stats) { 364 stats = dev->get_stats(dev); 365 rx_total += stats->rx_packets; 366 tx_total += stats->tx_packets; 367 } 368 } 369 read_unlock(&dev_base_lock); 370 371 rx_total -= rx_total_last; 372 tx_total -= tx_total_last; 373 374 if (rx_total) 375 led_net_rx_counter += CALC_ADD(rx_total, tx_total, addvalue); 376 377 if (tx_total) 378 led_net_tx_counter += CALC_ADD(tx_total, rx_total, addvalue); 379 380 rx_total_last += rx_total; 381 tx_total_last += tx_total; 382} 383 384 385/* 386 ** 387 ** led_get_diskio_stats() 388 ** 389 ** calculate the disk-io througput in the system 390 ** (analog to linux/fs/proc/proc_misc.c) 391 ** 392 */ 393static unsigned long led_diskio_counter; 394 395static void led_get_diskio_stats(int addvalue) 396{ 397 static unsigned int diskio_total_last, diskio_max; 398 int major, disk, total; 399 400 total = 0; 401 for (major = 0; major < DK_MAX_MAJOR; major++) { 402 for (disk = 0; disk < DK_MAX_DISK; disk++) 403 total += kstat.dk_drive[major][disk]; 404 } 405 total -= diskio_total_last; 406 407 if (total) { 408 if (total >= diskio_max) { 409 led_diskio_counter += addvalue; 410 diskio_max = total; /* new maximum value found */ 411 } else 412 led_diskio_counter += CALC_ADD(total, diskio_max, addvalue); 413 } 414 415 diskio_total_last += total; 416} 417 418 419 420/* 421 ** led_tasklet_func() 422 ** 423 ** is scheduled at every timer interrupt from time.c and 424 ** updates the chassis LCD/LED 425 426 TODO: 427 - display load average (older machines like 715/64 have 4 "free" LED's for that) 428 - optimizations 429 */ 430 431static unsigned char currentleds; /* stores current value of the LEDs */ 432 433#define HEARTBEAT_LEN (HZ*6/100) 434#define HEARTBEAT_2ND_RANGE_START (HZ*22/100) 435#define HEARTBEAT_2ND_RANGE_END (HEARTBEAT_2ND_RANGE_START + HEARTBEAT_LEN) 436 437static void led_tasklet_func(unsigned long unused) 438{ 439 static unsigned int count, count_HZ; 440 static unsigned char lastleds; 441 442 /* exit if not initialized */ 443 if (!led_func_ptr) 444 return; 445 446 /* increment the local counters */ 447 ++count; 448 if (++count_HZ == HZ) 449 count_HZ = 0; 450 451 if (led_heartbeat) 452 { 453 /* flash heartbeat-LED like a real heart (2 x short then a long delay) */ 454 if (count_HZ<HEARTBEAT_LEN || 455 (count_HZ>=HEARTBEAT_2ND_RANGE_START && count_HZ<HEARTBEAT_2ND_RANGE_END)) 456 currentleds |= LED_HEARTBEAT; 457 else 458 currentleds &= ~LED_HEARTBEAT; 459 } 460 461 /* gather network and diskio statistics and flash LEDs respectively */ 462 463 if (led_lanrxtx) 464 { 465 if ((count & 31) == 0) 466 led_get_net_stats(30); 467 468 if (led_net_rx_counter) { 469 led_net_rx_counter--; 470 currentleds |= LED_LAN_RCV; 471 } 472 else 473 currentleds &= ~LED_LAN_RCV; 474 475 if (led_net_tx_counter) { 476 led_net_tx_counter--; 477 currentleds |= LED_LAN_TX; 478 } 479 else 480 currentleds &= ~LED_LAN_TX; 481 } 482 483 if (led_diskio) 484 { 485 /* avoid to calculate diskio-stats at same irq as netio-stats ! */ 486 if ((count & 31) == 15) 487 led_get_diskio_stats(30); 488 489 if (led_diskio_counter) { 490 led_diskio_counter--; 491 currentleds |= LED_DISK_IO; 492 } 493 else 494 currentleds &= ~LED_DISK_IO; 495 } 496 497 /* update the LCD/LEDs */ 498 if (currentleds != lastleds) { 499 led_func_ptr(currentleds); 500 lastleds = currentleds; 501 } 502} 503 504/* main led tasklet struct (scheduled from time.c) */ 505DECLARE_TASKLET_DISABLED(led_tasklet, led_tasklet_func, 0); 506 507 508/* 509 ** led_halt() 510 ** 511 ** called by the reboot notifier chain at shutdown and stops all 512 ** LED/LCD activities. 513 ** 514 */ 515 516static int led_halt(struct notifier_block *, unsigned long, void *); 517 518static struct notifier_block led_notifier = { 519 notifier_call: led_halt, 520}; 521 522static int led_halt(struct notifier_block *nb, unsigned long event, void *buf) 523{ 524 char *txt; 525 526 switch (event) { 527 case SYS_RESTART: txt = "SYSTEM RESTART"; 528 break; 529 case SYS_HALT: txt = "SYSTEM HALT"; 530 break; 531 case SYS_POWER_OFF: txt = "SYSTEM POWER OFF"; 532 break; 533 default: return NOTIFY_DONE; 534 } 535 536 /* completely stop the LED/LCD tasklet */ 537 tasklet_disable(&led_tasklet); 538 539 if (lcd_info.model == DISPLAY_MODEL_LCD) 540 lcd_print(txt); 541 else 542 if (led_func_ptr) 543 led_func_ptr(0xff); /* turn all LEDs ON */ 544 545 unregister_reboot_notifier(&led_notifier); 546 return NOTIFY_OK; 547} 548 549/* 550 ** register_led_driver() 551 ** 552 ** registers an external LED or LCD for usage by this driver. 553 ** currently only LCD-, LASI- and ASP-style LCD/LED's are supported. 554 ** 555 */ 556 557int __init register_led_driver(int model, char *cmd_reg, char *data_reg) 558{ 559 static int initialized; 560 561 if (initialized || !data_reg) 562 return 1; 563 564 lcd_info.model = model; /* store the values */ 565 LCD_CMD_REG = (cmd_reg == LED_CMD_REG_NONE) ? NULL : cmd_reg; 566 567 switch (lcd_info.model) { 568 case DISPLAY_MODEL_LCD: 569 LCD_DATA_REG = data_reg; 570 printk(KERN_INFO "LCD display at %p,%p registered\n", 571 LCD_CMD_REG , LCD_DATA_REG); 572 led_func_ptr = led_LCD_driver; 573 lcd_print( "Linux " UTS_RELEASE ); 574 led_type = LED_HASLCD; 575 break; 576 577 case DISPLAY_MODEL_LASI: 578 LED_DATA_REG = data_reg; 579 led_func_ptr = led_LASI_driver; 580 printk(KERN_INFO "LED display at %p registered\n", LED_DATA_REG); 581 led_type = LED_NOLCD; 582 break; 583 584 case DISPLAY_MODEL_OLD_ASP: 585 LED_DATA_REG = data_reg; 586 led_func_ptr = led_ASP_driver; 587 printk(KERN_INFO "LED (ASP-style) display at %p registered\n", 588 LED_DATA_REG); 589 led_type = LED_NOLCD; 590 break; 591 592 default: 593 printk(KERN_ERR "%s: Wrong LCD/LED model %d !\n", 594 __FUNCTION__, lcd_info.model); 595 return 1; 596 } 597 598 /* mark the LCD/LED driver now as initialized and 599 * register to the reboot notifier chain */ 600 initialized++; 601 register_reboot_notifier(&led_notifier); 602 603 /* start the led tasklet for the first time */ 604 tasklet_enable(&led_tasklet); 605 606 return 0; 607} 608 609/* 610 ** register_led_regions() 611 ** 612 ** register_led_regions() registers the LCD/LED regions for /procfs. 613 ** At bootup - where the initialisation of the LCD/LED normally happens - 614 ** not all internal structures of request_region() are properly set up, 615 ** so that we delay the led-registration until after busdevices_init() 616 ** has been executed. 617 ** 618 */ 619 620void __init register_led_regions(void) 621{ 622 switch (lcd_info.model) { 623 case DISPLAY_MODEL_LCD: 624 request_mem_region((unsigned long)LCD_CMD_REG, 1, "lcd_cmd"); 625 request_mem_region((unsigned long)LCD_DATA_REG, 1, "lcd_data"); 626 break; 627 case DISPLAY_MODEL_LASI: 628 case DISPLAY_MODEL_OLD_ASP: 629 request_mem_region((unsigned long)LED_DATA_REG, 1, "led_data"); 630 break; 631 } 632} 633 634 635/* 636 ** 637 ** lcd_print() 638 ** 639 ** Displays the given string on the LCD-Display of newer machines. 640 ** lcd_print() disables the timer-based led tasklet during its 641 ** execution and enables it afterwards again. 642 ** 643 */ 644int lcd_print( char *str ) 645{ 646 int i; 647 648 if (!led_func_ptr || lcd_info.model != DISPLAY_MODEL_LCD) 649 return 0; 650 651 /* temporarily disable the led tasklet */ 652 tasklet_disable(&led_tasklet); 653 654 /* copy display string to buffer for procfs */ 655 strncpy(lcd_text, str, sizeof(lcd_text)-1); 656 657 /* Set LCD Cursor to 1st character */ 658 gsc_writeb(lcd_info.reset_cmd1, LCD_CMD_REG); 659 udelay(lcd_info.min_cmd_delay); 660 661 /* Print the string */ 662 for (i=0; i < lcd_info.lcd_width; i++) { 663 if (str && *str) 664 gsc_writeb(*str++, LCD_DATA_REG); 665 else 666 gsc_writeb(' ', LCD_DATA_REG); 667 udelay(lcd_info.min_cmd_delay); 668 } 669 670 /* re-enable the led tasklet */ 671 tasklet_enable(&led_tasklet); 672 673 return lcd_info.lcd_width; 674} 675 676/* 677 ** led_init() 678 ** 679 ** led_init() is called very early in the bootup-process from setup.c 680 ** and asks the PDC for an usable chassis LCD or LED. 681 ** If the PDC doesn't return any info, then the LED 682 ** is detected by lasi.c or asp.c and registered with the 683 ** above functions lasi_led_init() or asp_led_init(). 684 ** KittyHawk machines have often a buggy PDC, so that 685 ** we explicitly check for those machines here. 686 */ 687 688int __init led_init(void) 689{ 690 struct pdc_chassis_info chassis_info; 691 int ret; 692 693 /* Work around the buggy PDC of KittyHawk-machines */ 694 switch (CPU_HVERSION) { 695 case 0x580: /* KittyHawk DC2-100 (K100) */ 696 case 0x581: /* KittyHawk DC3-120 (K210) */ 697 case 0x582: /* KittyHawk DC3 100 (K400) */ 698 case 0x583: /* KittyHawk DC3 120 (K410) */ 699 case 0x58B: /* KittyHawk DC2 100 (K200) */ 700 printk(KERN_INFO "%s: KittyHawk-Machine (hversion 0x%x) found, " 701 "LED detection skipped.\n", __FILE__, CPU_HVERSION); 702 goto found; /* use the preinitialized values of lcd_info */ 703 } 704 705 /* initialize the struct, so that we can check for valid return values */ 706 lcd_info.model = DISPLAY_MODEL_NONE; 707 chassis_info.actcnt = chassis_info.maxcnt = 0; 708 709 if ((ret = pdc_chassis_info(&chassis_info, &lcd_info, sizeof(lcd_info))) == PDC_OK) { 710 DPRINTK((KERN_INFO "%s: chassis info: model=%d (%s), " 711 "lcd_width=%d, cmd_delay=%u,\n" 712 "%s: sizecnt=%d, actcnt=%ld, maxcnt=%ld\n", 713 __FILE__, lcd_info.model, 714 (lcd_info.model==DISPLAY_MODEL_LCD) ? "LCD" : 715 (lcd_info.model==DISPLAY_MODEL_LASI) ? "LED" : "unknown", 716 lcd_info.lcd_width, lcd_info.min_cmd_delay, 717 __FILE__, sizeof(lcd_info), 718 chassis_info.actcnt, chassis_info.maxcnt)); 719 DPRINTK((KERN_INFO "%s: cmd=%p, data=%p, reset1=%x, reset2=%x, act_enable=%d\n", 720 __FILE__, lcd_info.lcd_cmd_reg_addr, 721 lcd_info.lcd_data_reg_addr, lcd_info.reset_cmd1, 722 lcd_info.reset_cmd2, lcd_info.act_enable )); 723 724 /* check the results. Some machines have a buggy PDC */ 725 if (chassis_info.actcnt <= 0 || chassis_info.actcnt != chassis_info.maxcnt) 726 goto not_found; 727 728 switch (lcd_info.model) { 729 case DISPLAY_MODEL_LCD: /* LCD display */ 730 if (chassis_info.actcnt < 731 offsetof(struct pdc_chassis_lcd_info_ret_block, _pad)-1) 732 goto not_found; 733 if (!lcd_info.act_enable) { 734 DPRINTK((KERN_INFO "PDC prohibited usage of the LCD.\n")); 735 goto not_found; 736 } 737 break; 738 739 case DISPLAY_MODEL_NONE: /* no LED or LCD available */ 740 printk(KERN_INFO "PDC reported no LCD or LED.\n"); 741 goto not_found; 742 743 case DISPLAY_MODEL_LASI: /* Lasi style 8 bit LED display */ 744 if (chassis_info.actcnt != 8 && chassis_info.actcnt != 32) 745 goto not_found; 746 break; 747 748 default: 749 printk(KERN_WARNING "PDC reported unknown LCD/LED model %d\n", 750 lcd_info.model); 751 goto not_found; 752 } /* switch() */ 753 754found: 755 /* register the LCD/LED driver */ 756 register_led_driver(lcd_info.model, LCD_CMD_REG, LCD_DATA_REG); 757 return 0; 758 759 } else { /* if() */ 760 DPRINTK((KERN_INFO "pdc_chassis_info call failed with retval = %d\n", ret)); 761 } 762 763not_found: 764 lcd_info.model = DISPLAY_MODEL_NONE; 765 return 1; 766} 767 768#ifdef CONFIG_PROC_FS 769module_init(led_create_procfs) 770#endif 771