support for Cobalt Networks (x86 only) systems (for real this time)
Subsystems (3)
PATCH 1/1 support for Cobalt Networks (x86 only) systems (for real this time)
apparently, LKML silently (!) bounces messages > a certain size. So I'll try smaller patches. This is part 2/2 of the general Cobalt support.
Alan,
Aattached is a (large, but self contained) patch for Cobalt Networks suport for x86 systems (RaQ3, RaQ4, Qube3, RaQXTR). Please let me know if there is anything that would prevent this from general inclusion in the next release.
(patch against 2.4.5)
Thanks
Tim
Signature · 4 lines
Tim Hockin Systems Software Engineer Sun Microsystems, Cobalt Server Appliances [email protected]
drivers/cobalt/README +19 -0
@@ -0,0 +1,19 @@ +Notes on Cobalt's drivers: + +You will notice in several places constructs such as this: + + if (cobt_is_3k()) { + foo(); + } else if (cobt_is_5k()) { + bar(); + } + +The goal here is to only compile in code that is needed, but to allow one to +define support for both 3k and 5k (and more?) style systems. The systype +check macros are very simple and clean. They check whether config-time +support for the generation has been enabled, and (if so) whether systype +detected the specified generation. This leaves the code free from #ifdef +cruft, but lets the compiler throw out unsupported generation-specific code +with if (0) detection. + +--
drivers/cobalt/ruler.c +393 -0
393 lines not on this page · raw message
drivers/cobalt/serialnum.c +476 -0
476 lines not on this page · raw message
drivers/cobalt/systype.c +141 -0
141 lines not on this page · raw message
drivers/cobalt/thermal.c +144 -0
144 lines not on this page · raw message
drivers/cobalt/wdt.c +371 -0
371 lines not on this page · raw message
include/linux/cobalt-acpi.h +16 -0
@@ -0,0 +1,16 @@ +/* +* $Id: $ +* cobalt-acpi.h : support for ACPI interrupts +* +* Copyright 2000 Cobalt Networks, Inc. +* Copyright 2001 Sun Microsystems, Inc. +*/ +#ifndef COBALT_ACPI_H +#define COBALT_ACPI_H + +extern int cobalt_acpi_register_handler (void (*function) + (int ,void *,struct pt_regs *)); +extern int cobalt_acpi_unregister_handler (void (*function) + (int ,void *,struct pt_regs *)); + +#endif /* COBALT_ACPI_H */
include/linux/cobalt.h +76 -0
76 lines not on this page · raw message
include/linux/cobalt-i2c.h +37 -0
@@ -0,0 +1,37 @@ +/* +* $Id: cobalt-i2c.h,v 1.1 2001/03/07 01:58:24 thockin Exp $ +* cobalt-i2c.h : I2C support for LCD/Front Panel +* +* Copyright 2000 Cobalt Networks, Inc. +* Copyright 2001 Sun Microsystems, Inc. +*/ +#ifndef COBALT_I2C_H +#define COBALT_I2C_H + +#include <linux/types.h> +#include <linux/cobalt.h> + +#define COBALT_I2C_DEV_LED_I 0x40 +#define COBALT_I2C_DEV_LED_II 0x42 +#define COBALT_I2C_DEV_LCD_DATA 0x4a +#define COBALT_I2C_DEV_LCD_INST 0x48 +#define COBALT_I2C_DEV_FP_BUTTONS 0x41 +#define COBALT_I2C_DEV_DRV_SWITCH 0x45 +#define COBALT_I2C_DEV_RULER 0x46 +#define COBALT_I2C_DEV_TEMP 0x90 +#define COBALT_I2C_READ 0x01 +#define COBALT_I2C_WRITE 0x00 + +extern int cobalt_i2c_reset (void ); +extern int cobalt_i2c_read_byte (const int dev,const int index); +extern int cobalt_i2c_read_word (const int dev,const int index); +extern int cobalt_i2c_read_block (const int dev,const int index, +unsigned char *data,int count); +extern int cobalt_i2c_write_byte (const int dev,const int index, +const u8 val); +extern int cobalt_i2c_write_word (const int dev,const int index, +const u16 val); +extern int cobalt_i2c_write_block (const int dev,const int index, +unsigned char *data,int count); + +#endif /* COBALT_I2C_H */
include/linux/cobalt-lcd.h +90 -0
90 lines not on this page · raw message
include/linux/cobalt-led.h +45 -0
45 lines not on this page · raw message
include/linux/cobalt-misc.h +11 -0
@@ -0,0 +1,11 @@ +/* $Id: $ */ +/* Copyright 2001 Sun Microsystems, Inc. */ +#ifndef COBALT_MISC_H +#define COBALT_MISC_H + +void cobalt_nmi (unsigned char reason,struct pt_regs *regs); +void cobalt_restart (void ); +void cobalt_halt (void ); +void cobalt_power_off (void ); + +#endif
include/linux/cobalt-net.h +11 -0
@@ -0,0 +1,11 @@ +/* $Id: cobalt-net.h,v 1.1 2001/04/13 02:15:35 thockin Exp $ */ +/* Copyright 2001 Sun Microsystems, Inc. */ +#ifndef COBALT_NET_H +#define COBALT_NET_H + +#include <linux/netdevice.h> + +void cobalt_net_register (struct net_device *ndev); +void cobalt_net_unregister (struct net_device *ndev); + +#endif
include/linux/cobalt-ruler.h +12 -0
@@ -0,0 +1,12 @@ +/* $Id: cobalt-ruler.h,v 1.2 2001/04/27 03:13:53 thockin Exp $ */ +/* Copyright 2001 Sun Microsystems, Inc. */ +#ifndef COBALT_RULER_H +#define COBALT_RULER_H + +#include <linux/ide.h> + +void cobalt_ruler_register (ide_hwif_t *hwif); +void cobalt_ruler_unregister (ide_hwif_t *hwif); +void cobalt_ruler_powerdown (void ); + +#endif
include/linux/cobalt-serialnum.h +16 -0
@@ -0,0 +1,16 @@ +/* +* $Id: $ +* cobalt-serialnum.h : access to the DS2401 serial number +* +* Copyright 2000 Cobalt Networks, Inc. +* Copyright 2001 Sun Microsystems, Inc. +*/ +#ifndef COBALT_SERIALNUM_H +#define COBALT_SERIALNUM_H + +#include <linux/cobalt.h> + +char *cobalt_serialnum_get (void ); +unsigned long cobalt_hostid_get (void ); + +#endif /* COBALT_SERIALNUM_H */
include/linux/cobalt-superio.h +41 -0
41 lines not on this page · raw message
include/linux/cobalt-systype.h +29 -0
@@ -0,0 +1,29 @@ +/* +* $Id: cobalt-systype.h,v 1.1 2001/03/07 01:58:24 thockin Exp $ +* cobalt-systype.h : figure out what Cobalt system we are on +* +* Copyright 2000 Cobalt Networks, Inc. +* Copyright 2001 Sun Microsystems, Inc. +*/ +#ifndef COBALT_SYSTYPE_H +#define COBALT_SYSTYPE_H + +#include <linux/cobalt.h> + +typedef enum { +COBT_UNKNOWN , +COBT_RAQ3 , +COBT_QUBE3 , +COBT_RAQXTR , +}cobt_sys_t ; + +extern cobt_sys_t cobt_type; +/* one for each major board-type - COBT_SUPPORT_* from <linux/cobalt.h> */ +#define cobt_is_raq3 () (COBT_SUPPORT_GEN_III && cobt_type == COBT_RAQ3) +#define cobt_is_qube3 () (COBT_SUPPORT_GEN_III && cobt_type == COBT_QUBE3) +#define cobt_is_raqxtr () (COBT_SUPPORT_GEN_V && cobt_type == COBT_RAQXTR) +/* one for each major generation */ +#define cobt_is_3k () (cobt_is_raq3() || cobt_is_qube3()) +#define cobt_is_5k () (cobt_is_raqxtr()) + +#endif
include/linux/cobalt-thermal.h +12 -0
@@ -0,0 +1,12 @@ +/* $Id: $ */ +/* Copyright 2001 Sun Microsystems, Inc. */ +#ifndef COBALT_THERMAL_H +#define COBALT_THERMAL_H + +#include <linux/cobalt.h> + +extern unsigned int cobalt_thermal_id_max; + +char *cobalt_temp_read (unsigned int sensor); + +#endif
include/linux/cobalt-wdt.h +16 -0
@@ -0,0 +1,16 @@ +/* $Id: $ */ +/* Copyright 2001 Sun Microsystems, Inc. */ +#ifndef COBALT_WDT_H +#define COBALT_WDT_H + +#include <linux/cobalt.h> + +void cobalt_wdt_refresh (unsigned long refresh_timer); +void cobalt_wdt_trigger_reboot (void ); + +void cobalt_wdt_disable (void ); +void cobalt_wdt_reenable (void ); + +void cobalt_wdt_cleardog (void ); + +#endif
arch/i386/config.in +1 -0
@@ -192,6 +192,7 @@ define_bool CONFIG_X86_LOCAL_APIC y define_bool CONFIG_PCI y else + source drivers/cobalt/Config.in if [ "$CONFIG_SMP" = "y" ]; then define_bool CONFIG_X86_IO_APIC y define_bool CONFIG_X86_LOCAL_APIC y
Documentation/Configure.help +115 -0
121 lines not on this page · raw message
arch/i386/kernel/Makefile +1 -0
@@ -40,5 +40,6 @@ obj-$(CONFIG_X86_LOCAL_APIC) += apic.o obj-$(CONFIG_X86_IO_APIC) += io_apic.o mpparse.o obj-$(CONFIG_X86_VISWS_APIC) += visws_apic.o +obj-$(CONFIG_COBALT) += cobalt.o include $(TOPDIR)/Rules.make
arch/i386/kernel/cobalt.c +168 -0
168 lines not on this page · raw message
arch/i386/kernel/process.c +14 -0
@@ -46,6 +46,9 @@#ifdef CONFIG_MATH_EMULATION #include <asm/math_emu.h> #endif +#ifdef CONFIG_COBALT +#include <linux/cobalt-misc.h> +#endif #include <linux/irq.h>
@@ -354,6 +357,10 @@disable_IO_APIC ();#endif +#ifdef CONFIG_COBALT +cobalt_restart (); +#endif +if (!reboot_thru_bios) {/* rebooting needs to touch the page at absolute addr 0 */ *((unsigned short *)__va (0x472 )) = reboot_mode;
@@ -376,10 +383,17 @@void machine_halt (void ) { +#ifdef CONFIG_COBALT +cobalt_halt (); +#endif }void machine_power_off (void ) { +#ifdef CONFIG_COBALT +cobalt_power_off (); +#endif +if (pm_power_off)pm_power_off (); }
arch/i386/kernel/setup.c +9 -1
@@ -104,6 +104,10 @@#include <asm/dma.h> #include <asm/mpspec.h> #include <asm/mmu_context.h> +#ifdef CONFIG_COBALT +#include <linux/cobalt-thermal.h> +#endif +/* * Machine setup.. */
@@ -2441,9 +2445,13 @@ x86_cap_flags[i] != NULL ) p +=sprintf (p," %s" , x86_cap_flags[i]); - p +=sprintf (p,"\nbogomips\t: %lu.%02lu\n\n" , + p +=sprintf (p,"\nbogomips\t: %lu.%02lu\n" , c->loops_per_jiffy/(500000 /HZ ), (c->loops_per_jiffy/(5000 /HZ )) %100 ); +#ifdef CONFIG_COBALT + p +=sprintf (p,"temperature\t: %s\n" ,cobalt_temp_read (n)); +#endif + p +=sprintf (p,"\n" ); }return p - buffer; }
arch/i386/kernel/traps.c +12 -3
@@ -46,6 +46,9 @@#include <asm/cobalt.h> #include <asm/lithium.h> #endif +#ifdef CONFIG_COBALT +#include <linux/cobalt-misc.h> +#endif #include <linux/irq.h>
@@ -347,12 +350,18 @@static void mem_parity_error (unsigned char reason,struct pt_regs * regs) { +#if defined(CONFIG_COBALT_GEN_V ) +cobalt_nmi (reason, regs); +#else printk ("Uhhuh. NMI received. Dazed and confused, but trying to continue\n" );printk ("You probably have a hardware problem with your RAM chips\n" ); +#endif -/* Clear and disable the memory parity error line. */ - reason = (reason &0xf ) |4 ; -outb (reason,0x61 ); +/* Clear and re-enable the memory parity error line. */ + reason &=0xf ; +outb (reason |4 ,0x61 ); +outb (reason & ~4 ,0x61 ); + }static void io_check_error (unsigned char reason,struct pt_regs * regs)
drivers/Makefile +2 -1
@@ -7,7 +7,7 @@ mod-subdirs := dio mtd sbus video macintosh usb input telephony sgi i2o ide \ - scsi md ieee1394 pnp isdn atm fc4 net/hamradio i2c acpi + scsi md ieee1394 pnp isdn atm fc4 net/hamradio i2c acpi cobalt subdir-y := parport char block net sound misc media cdrom subdir-m := $(subdir-y)
@@ -42,6 +42,7 @@ subdir-$(CONFIG_HAMRADIO) += net/hamradio subdir-$(CONFIG_I2C) += i2c subdir-$(CONFIG_ACPI) += acpi +subdir-$(CONFIG_COBALT) += cobalt include $(TOPDIR)/Rules.make
drivers/char/mem.c +6 -0
@@ -26,6 +26,9 @@#include <asm/io.h> #include <asm/pgalloc.h> +#ifdef CONFIG_COBALT +extern int cobalt_init (void ); +#endif #ifdef CONFIG_I2C extern int i2c_init_all (void );#endif
@@ -644,6 +647,9 @@#endif #if defined(CONFIG_ADB )adbdev_init (); +#endif +#ifdef CONFIG_COBALT +cobalt_init ();#endif return 0 ; }
Makefile +5 -0
@@ -177,6 +177,7 @@ DRIVERS-$(CONFIG_PHONE) += drivers/telephony/telephony.o DRIVERS-$(CONFIG_ACPI) += drivers/acpi/acpi.o DRIVERS-$(CONFIG_MD) += drivers/md/mddev.o +DRIVERS-$(CONFIG_COBALT) += drivers/cobalt/cobalt.o DRIVERS := $(DRIVERS-y)
@@ -193,6 +194,10 @@ drivers/zorro/devlist.h drivers/zorro/gen-devlist \ drivers/sound/bin2hex drivers/sound/hex2hex \ drivers/atm/fore200e_mkfirm drivers/atm/{pca,sba}*{.bin,.bin1,.bin2} \ + drivers/scsi/aic7xxx/aicasm/aicasm_gram.c \ + drivers/scsi/aic7xxx/aicasm/aicasm_scan.c \ + drivers/scsi/aic7xxx/aicasm/y.tab.h \ + drivers/scsi/aic7xxx/aicasm/aicasm \ net/khttpd/make_times_h \ net/khttpd/times.h \ submenu*
Tim Hockin said once upon a time (Thu, 31 May 2001):
Quoted 4 lines
Aattached is a (large, but self contained) patch for Cobalt Networks suport for x86 systems (RaQ3, RaQ4, Qube3, RaQXTR). Please let me know if there is anything that would prevent this from general inclusion in the next release.
I can vouch for these patches stability wise. I've been running an earlier version of these patches (for 2.4.4) on a Qube 3 acting as a firewall for 3 weeks without any problems.
Incidently, that Qube 3 is running Red Hat 7.1 and using reiserfs on all filesystems except for /boot.
Dax
General comments:
* Code looks really clean. Nice work.
* Use module_init/exit. I know, I know, you heard it before :)
* I dunno if Linus will take it as-is because he has been threatening to stop taking PCI drives that use old-style PCI init for no good reason. (he even made me change a driver that used old-style PCI init for a good reason :))
* There is a ton of procfs stuff in there. I suppose !CONFIG_PROC_FS is not a supported configuration on Cobalt? :)
Quoted 3 lines · Tim Hockin
drivers/cobalt/ruler.c +3
-0+/* this is essentially an exported function - it is in the hwif structs */ +static int +ruler_busproc_fn (ide_hwif_t *hwif,int arg)
[...]
Quoted 1 line
+
read_lock(&ruler_lock);
[...]
Quoted 1 line
+
read_unlock(&ruler_lock);
Should this be read_lock_bh, since other uses are in a timer function or _irqsave/restore?
drivers/cobalt/serialnum.c line 141
Quoted 3 lines
drivers/cobalt/serialnum.c +3
-0+/* The GPIO tied to the ID chip is on the PMU */ + id_dev =pci_find_device (PCI_VENDOR_ID_AL , +PCI_DEVICE_ID_AL_M7101 ,NULL );
as mentioned earlier, pci_register_driver is preferred over "old style" PCI.
drivers/cobalt/serialnum.c line 179
Quoted 8 lines
drivers/cobalt/serialnum.c +8
-0+spin_lock_irqsave (&cobalt_superio_lock, flags); +outb (SUPERIO_LOGICAL_DEV ,SUPERIO_INDEX_PORT ); +outb (SUPERIO_DEV_GPIO ,SUPERIO_DATA_PORT ); +outb (SUPERIO_ADDR_HIGH ,SUPERIO_INDEX_PORT ); + addr =inb (SUPERIO_DATA_PORT ) <<8 ; +outb (SUPERIO_ADDR_LOW ,SUPERIO_INDEX_PORT ); + addr |=inb (SUPERIO_DATA_PORT ); +spin_unlock_irqrestore (&cobalt_superio_lock, flags);
Nothing wrong here, just commenting that I wish other superio did this sometimes in some cases... :)
Quoted 12 lines
drivers/cobalt/serialnum.c +12
-0+static void __init +io_write_byte (unsigned char c) +{ +int i; +unsigned long flags; + +save_flags (flags); + +for (i =0 ; i <8 ; i++, c >>=1 ) { +cli (); +if (c &1 ) { +/* Transmit a 1 */
drivers/cobalt/serialnum.c line 265
Quoted 10 lines
drivers/cobalt/serialnum.c +10
-0+io_write (5 ); +udelay (80 ); + }else { +/* Transmit a 0 */ +io_write (80 ); +udelay (10 ); + } +restore_flags (flags); + } +}
Can save/restore flags be replaced with a spinlock?
drivers/cobalt/serialnum.c line 382
Quoted 12 lines
drivers/cobalt/serialnum.c +12
-0+/* get version from CVS */ + version =strchr ("$Revision: 1.4 $" ,':' ) +2 ; +if (version) { +char *p; + +strncpy (vstring, version,sizeof (vstring)); +if ((p =strchr (vstring,' ' ))) { + *p ='\0' ; + } + }else { +strncpy (vstring,"unknown" ,sizeof (vstring)); + }
ug :) It would be nice if this could be done at compile time
Quoted 5 lines
drivers/cobalt/serialnum.c +5
-0+ proc_serialnum =create_proc_read_entry ("serialnumber" ,0 ,NULL , + serialnum_read,NULL ); +if (!proc_serialnum) { +EPRINTK ("can't create /proc/serialnumber\n" ); + }
drivers/cobalt/serialnum.c line 430
Quoted 10 lines
drivers/cobalt/serialnum.c +10
-0+#endif + proc_chostid =create_proc_read_entry ("hostid" ,0 , proc_cobalt, + hostid_read,NULL ); +if (!proc_chostid) { +EPRINTK ("can't create /proc/cobalt/hostid\n" ); + } + proc_cserialnum =create_proc_read_entry ("serialnumber" ,0 , + proc_cobalt, serialnum_read,NULL ); +if (!proc_cserialnum) { +EPRINTK ("can't create /proc/cobalt/serialnumber\n" );
security concern?
We disable CPU processor serial numbers on x86, maybe you want to make everything except the output of /usr/bin/hostid priveleged?
drivers/cobalt/wdt.c Thu May 31 14:32:15 2001
Quoted 3 lines
diff -ruN
dist-2.4.5/drivers/cobalt/wdt.ccobalt-2.4.5/drivers/cobalt/wdt.cdrivers/cobalt/wdt.c Thu May 31 14:32:15 2001 renamed from drivers/cobalt/wdt.c Wed Dec 31 16:00:00 1969 +0
-0
Shouldn't this be stored with other watchdog timers?
include/linux/cobalt-acpi.h Thu May 31 14:33:16 2001
Quoted 3 lines
diff -ruN
dist-2.4.5/include/linux/cobalt-acpi.hcobalt-2.4.5/include/linux/cobalt-acpi.hinclude/linux/cobalt-acpi.h Thu May 31 14:33:16 2001 renamed from include/linux/cobalt-acpi.h Wed Dec 31 16:00:00 1969 +0
-0
Another ACPI user... neat!
include/linux/cobalt-acpi.h Thu May 31 14:33:16 2001
Quoted 2 lines
include/linux/cobalt-acpi.h Thu May 31 14:33:16 2001 renamed from include/linux/cobalt-acpi.h Wed Dec 31 16:00:00 1969 +2
-0+/* the root of /proc/cobalt */ +extern struct proc_dir_entry *proc_cobalt;
I am wondering if some of this stuff can be a sysctl instead of procfs???
include/linux/cobalt-i2c.h Thu May 31 14:33:16 2001
Quoted 5 lines
include/linux/cobalt-acpi.h Thu May 31 14:33:16 2001 renamed from include/linux/cobalt-acpi.h Wed Dec 31 16:00:00 1969 +2
-0+ +#endifdiff -ruN
dist-2.4.5/include/linux/cobalt-i2c.hcobalt-2.4.5/include/linux/cobalt-i2c.hinclude/linux/cobalt-i2c.h Thu May 31 14:33:16 2001 renamed from include/linux/cobalt-i2c.h Wed Dec 31 16:00:00 1969 +0
-0
Sometimes I wish for a directory structure with:
* arch-specific includes
* platform-specific includes
* generic core includes
Then we could put this stuff in include/cobalt/* or platform/cobalt/include or somesuch.
include/linux/cobalt-i2c.h Thu May 31 14:33:16 2001
Quoted 8 lines
include/linux/cobalt-i2c.h Thu May 31 14:33:16 2001 renamed from include/linux/cobalt-i2c.h Wed Dec 31 16:00:00 1969 +8
-0+extern cobt_sys_t cobt_type; +/* one for each major board-type - COBT_SUPPORT_* from <linux/cobalt.h> */ +#define cobt_is_raq3() (COBT_SUPPORT_GEN_III && cobt_type == COBT_RAQ3) +#define cobt_is_qube3() (COBT_SUPPORT_GEN_III && cobt_type == COBT_QUBE3) +#define cobt_is_raqxtr() (COBT_SUPPORT_GEN_V && cobt_type == COBT_RAQXTR) +/* one for each major generation */ +#define cobt_is_3k() (cobt_is_raq3() || cobt_is_qube3()) +#define cobt_is_5k() (cobt_is_raqxtr())
Is they look like functions, why not make them static inline?
Quoted 8 lines
static void
mem_parity_error(unsigned char reason, struct pt_regs * regs){include/linux/cobalt-i2c.h Thu May 31 14:33:16 2001 renamed from include/linux/cobalt-i2c.h Wed Dec 31 16:00:00 1969 +4
-0+#if defined(CONFIG_COBALT_GEN_V) + cobalt_nmi(reason, regs); +#else printk("Uhhuh. NMI received. Dazed and confused, but trying to continue\n"); printk("You probably have a hardware problem with your RAM chips\n"); +#endif
include/linux/cobalt-i2c.h Thu May 31 14:33:16 2001
Quoted 10 lines
include/linux/cobalt-i2c.h Thu May 31 14:33:16 2001 renamed from include/linux/cobalt-i2c.h Wed Dec 31 16:00:00 1969 +5
-3- /* Clear and disable the memory parity error line. */ - reason = (reason & 0xf) | 4; - outb(reason, 0x61); + /* Clear and re-enable the memory parity error line. */ + reason &= 0xf; + outb(reason | 4, 0x61); + outb(reason & ~4, 0x61); + }
Interesting. I wonder if this positively affects anyone else.
Signature · 3 lines
Jeff Garzik | Disbelief, that's why you fail. Building 1024 | MandrakeSoft |