Skip to contentSkip to conversation

LED driver for Intel NAS SS4200 series

PATCH In review Dave Hansen 4 participants 6 messages Sep 16, 2009 – Oct 1, 2009 LED

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 LED driver for Intel NAS SS4200 series

Changes from last version
* Added dmi-basd hardware detection, and modparam
override for it
* replaced DRIVER_NAME with KBUILD_MODNAME

--

This code is based on a driver that came in the "Open-source and GPL components" download here:

http://downloadcenter.intel.com/SearchResult.aspx?lang=eng&ProductFamily=Server+Products&ProductLine=Intel%C2%AE+Storage+Systems&ProductProduct=Intel%C2%AE+Entry+Storage+System+SS4200-E&OSVersion=OS+Independent

It was in a file called nasgpio.c inside of a second zip file.

That code used an ioctl() call to operate the LEDs. It also created a new top-level /proc file just to let userspace locate which dynamic major number had been allocated to the device. Lovely.

I ripped out all of the hardware monitor support from nasgpio.c as well as the smbus code that controls the LED brightness. I then converted the code to use the existing LED interfaces rather than the ioctl().

Except for the probe routines, I rewrote most of it.

Thanks go to Arjan for his help in getting the original source for this released and for chasing down some licensing issues.

---
 drivers/leds/Kconfig       |    9 +
 drivers/leds/Makefile      |    1 +
 drivers/leds/leds-ss4200.c |  551 ++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 561 insertions(+), 0 deletions(-)
 create mode 100644 drivers/leds/leds-ss4200.c
drivers/leds/Kconfig +9 -0
index 7c8e712..ae6ed6e 100644
@@ -229,6 +229,15 @@ config LEDS_BD2802
 	  This option enables support for BD2802GU RGB LED driver chips
 	  accessed via the I2C bus.
 
+config LEDS_INTEL_SS4200
+	tristate "LED driver for Intel NAS SS4200 series"
+	depends on LEDS_CLASS && PCI
+	help
+	  This option enables support for the Intel SS4200 series of
+	  Network Attached Storage servers.  You may control the hard
+	  drive or power LEDs on the front panel.  Using this driver
+	  can stop the front LED from blinking after startup.
+
 comment "LED Triggers"
 
 config LEDS_TRIGGERS
drivers/leds/Makefile +1 -0
index e8cdcf7..6af2f99 100644
@@ -28,6 +28,7 @@ obj-$(CONFIG_LEDS_PCA955X)		+= leds-pca955x.o
 obj-$(CONFIG_LEDS_DA903X)		+= leds-da903x.o
 obj-$(CONFIG_LEDS_WM8350)		+= leds-wm8350.o
 obj-$(CONFIG_LEDS_PWM)			+= leds-pwm.o
+obj-$(CONFIG_LEDS_INTEL_SS4200)		+= leds-ss4200.o
 
 # LED SPI Drivers
 obj-$(CONFIG_LEDS_DAC124S085)		+= leds-dac124s085.o
drivers/leds/leds-ss4200.c new file +551 -0

551 lines not on this page · raw message

Signature · 1 line
1.6.5.rc1.13.g2b621c
#1 lore raw
Quoted 4 lines · Dave Hansen

Changes from last version
* Added dmi-basd hardware detection, and modparam
override for it
* replaced DRIVER_NAME with KBUILD_MODNAME

Thanks for the DMI fix, I've queued this in the LEDs tree.

Cheers,

Richard

Signature · 2 lines
Richard Purdie
Intel Open Source Technology Centre
#2 lore raw
In reply to Dave Hansen
Quoted 24 lines · On Wed, 16 Sep 2009 09:32:12 -0700 Dave Hansen <[email protected]> wrote:

Changes from last version
* Added dmi-basd hardware detection, and modparam
override for it
* replaced DRIVER_NAME with KBUILD_MODNAME

--

This code is based on a driver that came in the "Open-source and GPL components" download here:

http://downloadcenter.intel.com/SearchResult.aspx?lang=eng&ProductFamily=Server+Products&ProductLine=Intel%C2%AE+Storage+Systems&ProductProduct=Intel%C2%AE+Entry+Storage+System+SS4200-E&OSVersion=OS+Independent

It was in a file called nasgpio.c inside of a second zip file.

That code used an ioctl() call to operate the LEDs. It also created a new top-level /proc file just to let userspace locate which dynamic major number had been allocated to the device. Lovely.

I ripped out all of the hardware monitor support from nasgpio.c as well as the smbus code that controls the LED brightness. I then converted the code to use the existing LED interfaces rather than the ioctl().

Quoted 6 lines

Except for the probe routines, I rewrote most of it.

Thanks go to Arjan for his help in getting the original source for this released and for chasing down some licensing issues.

We don't have Rodney's Signed-off-by:?

Quoted 12 lines
---
 drivers/leds/Kconfig       |    9 +
 drivers/leds/Makefile      |    1 +
 drivers/leds/leds-ss4200.c |  551 ++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 561 insertions(+), 0 deletions(-)
 create mode 100644 drivers/leds/leds-ss4200.c
drivers/leds/Kconfig +0 -0
index 7c8e712..ae6ed6e 100644

drivers/leds/Kconfig config LEDS_BD2802 · line 234

Quoted 6 lines
drivers/leds/Kconfig +3 -0
@@ -229,6 +229,15 @@ config LEDS_BD2802
 	  This option enables support for BD2802GU RGB LED driver chips
 	  accessed via the I2C bus.
 
+config LEDS_INTEL_SS4200
+	tristate "LED driver for Intel NAS SS4200 series"
+	depends on LEDS_CLASS && PCI

Does it need a dependency on DMI?

Quoted 12 lines
drivers/leds/Kconfig +9 -0
+	help
+	  This option enables support for the Intel SS4200 series of
+	  Network Attached Storage servers.  You may control the hard
+	  drive or power LEDs on the front panel.  Using this driver
+	  can stop the front LED from blinking after startup.
+
 
...
 
+void nasgpio_led_set_attr(struct led_classdev *led_cdev, u32 port, u32 value)
+{
+	struct nasgpio_led *led = led_classdev_to_nasgpio_led(led_cdev);

drivers/leds/Kconfig config LEDS_BD2802

Quoted 10 lines
drivers/leds/Kconfig +10 -0
+	u32 gpio_out;
+
+	gpio_out = inl(nas_gpio_io_base + port);
+	if (value)
+		gpio_out |= (1<<led->gpio_bit);
+	else
+		gpio_out &= ~(1<<led->gpio_bit);
+
+	outl(gpio_out, nas_gpio_io_base + port);
+}

This function needs locking, but doesn't have it.

drivers/leds/Kconfig

Quoted 12 lines
drivers/leds/Kconfig +12 -0
+u32 nasgpio_led_get_attr(struct led_classdev *led_cdev, u32 port)
+{
+	struct nasgpio_led *led = led_classdev_to_nasgpio_led(led_cdev);
+	u32 gpio_in;
+
+	spin_lock(&nasgpio_gpio_lock);
+	gpio_in = inl(nas_gpio_io_base + port);
+	spin_unlock(&nasgpio_gpio_lock);
+	if (gpio_in & (1<<led->gpio_bit))
+		return 1;
+	return 0;
+}

This function doesn't need locking, but has it.

Quoted 16 lines
drivers/leds/Kconfig +16 -0
+/*
+ * There is actual brightness control in the hardware,
+ * but it is via smbus commands and not implemented
+ * in this driver.
+ */
+static void nasgpio_led_set_brightness(struct led_classdev *led_cdev,
+				       enum led_brightness brightness)
+{
+	u32 setting = 0;
+	if (brightness >= LED_HALF)
+		setting = 1;
+	/*
+	 * Hold the lock across both operations.  This ensures
+	 * consistency so that both the "turn off blinking"
+	 * and "turn light off" operations complete as a set.
+	 */

drivers/leds/Kconfig

Quoted 10 lines
drivers/leds/Kconfig +10 -0
+	spin_lock(&nasgpio_gpio_lock);
+	/*
+	 * LED class documentation asks that past blink state
+	 * be disabled when brightness is turned to zero.
+	 */
+	if (brightness == 0)
+		nasgpio_led_set_attr(led_cdev, GPO_BLINK, 0);
+	nasgpio_led_set_attr(led_cdev, GP_LVL, setting);
+	spin_unlock(&nasgpio_gpio_lock);
+}

Oh. There's the locking. How weird.

Quoted 10 lines
drivers/leds/Kconfig +10 -0
+static int nasgpio_led_set_blink(struct led_classdev *led_cdev,
+				 unsigned long *delay_on,
+				 unsigned long *delay_off)
+{
+	u32 setting = 1;
+	if (!(*delay_on == 0 && *delay_off == 0) &&
+	    !(*delay_on == 500 && *delay_off == 500))
+		return -EINVAL;
+	/*
+	 * These are very approximate.

drivers/leds/Kconfig

Quoted 10 lines
drivers/leds/Kconfig +10 -0
+	 */
+	*delay_on = 500;
+	*delay_off = 500;
+
+	spin_lock(&nasgpio_gpio_lock);
+	nasgpio_led_set_attr(led_cdev, GPO_BLINK, setting);
+	spin_unlock(&nasgpio_gpio_lock);
+
+	return 0;
+}

And again.

Quoted 62 lines
drivers/leds/Kconfig +62 -0
+
+/*
+ * Initialize the ICH7 GPIO registers for NAS usage.  The BIOS should have
+ * already taken care of this, but we will do so in a non destructive manner
+ * so that we have what we need whether the BIOS did it or not.
+ */
+static int ich7_gpio_init(struct device *dev)
+{
+	int i;
+	u32 config_data = 0;
+	u32 all_nas_led = 0;
+
+	for (i = 0; i < ARRAY_SIZE(nasgpio_leds); i++)
+		all_nas_led |= (1<<nasgpio_leds[i].gpio_bit);
+
+	spin_lock(&nasgpio_gpio_lock);
+	/*
+	 * We need to enable all of the GPIO lines used by the NAS box,
+	 * so we will read the current Use Selection and add our usage
+	 * to it.  This should be benign with regard to the original
+	 * BIOS configuration.
+	 */
+	config_data = inl(nas_gpio_io_base + GPIO_USE_SEL);
+	dev_printk(KERN_DEBUG, dev, "Data read from GPIO_USE_SEL = 0x%08x\n",
+					config_data);
+	config_data |= all_nas_led + NAS_RECOVERY;
+	outl(config_data, nas_gpio_io_base + GPIO_USE_SEL);
+	config_data = inl(nas_gpio_io_base + GPIO_USE_SEL);
+	dev_printk(KERN_DEBUG, dev, "GPIO_USE_SEL = 0x%08x\n\n",
+					config_data);
+
+	/*
+	 * The LED GPIO outputs need to be configured for output, so we
+	 * will ensure that all LED lines are cleared for output and the
+	 * RECOVERY line ready for input.  This too should be benign with
+	 * regard to BIOS configuration.
+	 */
+	config_data = inl(nas_gpio_io_base + GP_IO_SEL);
+	dev_printk(KERN_DEBUG, dev, "Data read from GP_IO_SEL = 0x%08x\n",
+					config_data);
+	config_data &= ~all_nas_led;
+	config_data |= NAS_RECOVERY;
+	outl(config_data, nas_gpio_io_base + GP_IO_SEL);
+	config_data = inl(nas_gpio_io_base + GP_IO_SEL);
+	dev_printk(KERN_DEBUG, dev, "GP_IO_SEL = 0x%08x\n\n",
+					config_data);
+
+	/*
+	 * In our final system, the BIOS will initialize the state of all
+	 * of the LEDs.  For now, we turn them all off (or Low).
+	 */
+	config_data = inl(nas_gpio_io_base + GP_LVL);
+	dev_printk(KERN_DEBUG, dev, "Data read from GP_LVL = 0x%08x\n",
+				   config_data);
+	/*
+	 * In our final system, the BIOS will initialize the blink state of all
+	 * of the LEDs.  For now, we turn blink off for all of them.
+	 */
+	config_data = inl(nas_gpio_io_base + GPO_BLINK);
+	dev_printk(KERN_DEBUG, dev, "Data read from GPO_BLINK = 0x%08x\n",
+					config_data);
+

drivers/leds/Kconfig

Quoted 10 lines
drivers/leds/Kconfig +10 -0
+	/*
+	 * At this moment, I am unsure if anything needs to happen with GPI_INV
+	 */
+	config_data = inl(nas_gpio_io_base + GPI_INV);
+	dev_printk(KERN_DEBUG, dev, "Data read from GPI_INV = 0x%08x\n",
+					config_data);
+
+	spin_unlock(&nasgpio_gpio_lock);
+	return 0;
+}

I wonder if this (and ich7_lpc_probe()) could be __devinit.

Quoted 14 lines
drivers/leds/Kconfig +14 -0
+static void ich7_lpc_cleanup(struct device *dev)
+{
+	/*
+	 * If we were given exclusive use of the GPIO
+	 * I/O Address range, we must return it.
+	 */
+	if (gp_gpio_resource) {
+		dev_printk(KERN_DEBUG, dev, "Releasing GPIO I/O addresses\n");
+		release_region(nas_gpio_io_base, ICH7_GPIO_SIZE);
+		gp_gpio_resource = NULL;
+	}
+}
+
+/*

drivers/leds/Kconfig

Quoted 10 lines
drivers/leds/Kconfig +10 -0
+ * The OS has determined that the LPC of the Intel ICH7 Southbridge is present
+ * so we can retrive the required operational information and prepare the GPIO.
+ */
+static struct pci_dev *nas_gpio_pci_dev;
+static int ich7_lpc_probe(struct pci_dev *dev, const struct pci_device_id *id)
+{
+	int status = 0;
+	u32 gc = 0;
+
+	pci_enable_device(dev);

Shouldn't we disable it again if this function fails?

Quoted 41 lines
drivers/leds/Kconfig +41 -0
+	nas_gpio_pci_dev = dev;
+	status = pci_read_config_dword(dev, PMBASE, &g_pm_io_base);
+	if (status)
+		goto out;
+	g_pm_io_base &= 0x00000ff80;
+
+	status = pci_read_config_dword(dev, GPIO_CTRL, &gc);
+	if (!(GPIO_EN & gc)) {
+		status = -EEXIST;
+		dev_printk(KERN_INFO, &dev->dev,
+			   "ERROR: The LPC GPIO Block has not been enabled.\n");
+		goto out;
+	}
+
+	status = pci_read_config_dword(dev, GPIO_BASE, &nas_gpio_io_base);
+	if (0 > status) {
+		dev_printk(KERN_INFO, &dev->dev, "Unable to read GPIOBASE.\n");
+		goto out;
+	}
+	dev_printk(KERN_DEBUG, &dev->dev,
+		   "GPIOBASE = 0x%08x\n", nas_gpio_io_base);
+	nas_gpio_io_base &= 0x00000ffc0;
+
+	/*
+	 * Insure that we have exclusive access to the GPIO I/O address range.
+	 */
+	gp_gpio_resource = request_region(nas_gpio_io_base,
+					  ICH7_GPIO_SIZE, KBUILD_MODNAME);
+	if (NULL == gp_gpio_resource) {
+		dev_printk(KERN_INFO, &dev->dev,
+			   "ERROR Unable to register GPIO I/O addresses.\n");
+		status = -1;
+		goto out;
+	}
+
+	/*
+	 * Initialize the GPIO for NAS/Home Server Use
+	 */
+	ich7_gpio_init(&dev->dev);
+
+out:

drivers/leds/Kconfig

Quoted 10 lines
drivers/leds/Kconfig +7 -0
+	if (status)
+		ich7_lpc_cleanup(&dev->dev);
+	return status;
+}
+
 
...
 
+
+void set_power_light_amber_noblink(void)

Please check that any/all global symbols really needed to be global.

Quoted 23 lines
drivers/leds/Kconfig +20 -0
+{
+	struct nasgpio_led *amber = get_led_named("power:amber:power");
+	struct nasgpio_led *blue = get_led_named("power:blue:power");
+
+	if (!amber || !blue)
+		return;
+	/*
+	 * LED_OFF implies disabling future blinking
+	 */
+	printk(KERN_DEBUG "setting blue off and amber on\n");
+
+	nasgpio_led_set_brightness(&blue->led_cdev, LED_OFF);
+	nasgpio_led_set_brightness(&amber->led_cdev, LED_FULL);
+}
+
 
...
 
+static ssize_t nas_led_blink_store(struct device *dev,
+				   struct device_attribute *attr,
+				   const char *buf, size_t size)
+{
+	int ret;

drivers/leds/Kconfig

Quoted 10 lines
drivers/leds/Kconfig +10 -0
+	struct led_classdev *led = dev_get_drvdata(dev);
+	unsigned long blink_state;
+
+	ret = strict_strtoul(buf, 10, &blink_state);
+	if (ret)
+		return ret;
+
+	spin_lock(&nasgpio_gpio_lock);
+	nasgpio_led_set_attr(led, GPO_BLINK, blink_state);
+	spin_unlock(&nasgpio_gpio_lock);

It still looks like this locking could be moved into the callee.

Quoted 6 lines
drivers/leds/Kconfig +3 -0
+	return size;
+}
+
 
...
#3 lore raw

PATCH 1/1 LED driver for Intel NAS SS4200 series (v3)

Quoted 27 lines · Andrew Morton
Quoted 24 lines · On Wed, 16 Sep 2009 09:32:12 -0700 Dave Hansen <[email protected]> wrote:

Changes from last version
* Added dmi-basd hardware detection, and modparam
override for it
* replaced DRIVER_NAME with KBUILD_MODNAME

--

This code is based on a driver that came in the "Open-source and GPL components" download here:

http://downloadcenter.intel.com/SearchResult.aspx?lang=eng&ProductFamily=Server+Products&ProductLine=Intel%C2%AE+Storage+Systems&ProductProduct=Intel%C2%AE+Entry+Storage+System+SS4200-E&OSVersion=OS+Independent

It was in a file called nasgpio.c inside of a second zip file.

That code used an ioctl() call to operate the LEDs. It also created a new top-level /proc file just to let userspace locate which dynamic major number had been allocated to the device. Lovely.

I ripped out all of the hardware monitor support from nasgpio.c as well as the smbus code that controls the LED brightness. I then converted the code to use the existing LED interfaces rather than the ioctl().

Quoted 8 lines
Quoted 6 lines

Except for the probe routines, I rewrote most of it.

Thanks go to Arjan for his help in getting the original source for this released and for chasing down some licensing issues.

We don't have Rodney's Signed-off-by:?

Unfortunately, no. I'm not sure what Rodney's involvement with the driver he wrote is at this point. I've never had any contact with him, although I cc'd him on this out of courtesy since I'd want to know if it was my code.

I actually did a bit of work to ensure that there was source for this available in any form. I then actually contacted some folks at Intel to resolve a licensing ambiguity with their source release. I'm convinced now that it is released under GPLv2. I trust that, coming from Intel directly, it is in good faith.

I do believe I have the rights to submit it, and I did re-read the DCO just now to make sure that I feel this way.

I'd appreciate if Arjan or someone else at Intel could sign off on it. That would probably remove any and all confusion.

Quoted 5 lines

Review

Quoted 3 lines
(quoted diff) +3 -0
+config LEDS_INTEL_SS4200
+	tristate "LED driver for Intel NAS SS4200 series"
+	depends on LEDS_CLASS && PCI

Does it need a dependency on DMI?

Yes. I'll add it.

Quoted 9 lines
Quoted 9 lines
(quoted diff) +6 -0
+	help
+	  This option enables support for the Intel SS4200 series of
+	  Network Attached Storage servers.  You may control the hard
+	  drive or power LEDs on the front panel.  Using this driver
+	  can stop the front LED from blinking after startup.
+
 
...
Quoted 15 lines

Review

Quoted 13 lines
(quoted diff) +13 -0
+void nasgpio_led_set_attr(struct led_classdev *led_cdev, u32 port, u32 value)
+{
+	struct nasgpio_led *led = led_classdev_to_nasgpio_led(led_cdev);
+	u32 gpio_out;
+
+	gpio_out = inl(nas_gpio_io_base + port);
+	if (value)
+		gpio_out |= (1<<led->gpio_bit);
+	else
+		gpio_out &= ~(1<<led->gpio_bit);
+
+	outl(gpio_out, nas_gpio_io_base + port);
+}

This function needs locking, but doesn't have it.

The locking is done by the callers. I noted it in the function comments. It needs to be done by callers since this function can effectively do two things: make an LED be powered on or off, or make it blink. When a user requests that the state of both of those be changed, I tried to do it atomically.

There was a comment on this:
/*
* Hold the lock across both operations. This ensures
* consistency so that both the "turn off blinking"
* and "turn light off" operations complete as a set. */

Perhaps an __ prefix would help it be more clear that the function can't just be called without locking? I've done that, btw.

Quoted 7 lines

Review

Quoted 5 lines
(quoted diff) +5 -0
+	if (brightness == 0)
+		nasgpio_led_set_attr(led_cdev, GPO_BLINK, 0);
+	nasgpio_led_set_attr(led_cdev, GP_LVL, setting);
+	spin_unlock(&nasgpio_gpio_lock);
+}

Oh. There's the locking. How weird.

Point taken. :)

Quoted 9 lines

Review

Quoted 7 lines
(quoted diff) +7 -0
+	config_data = inl(nas_gpio_io_base + GPI_INV);
+	dev_printk(KERN_DEBUG, dev, "Data read from GPI_INV = 0x%08x\n",
+					config_data);
+
+	spin_unlock(&nasgpio_gpio_lock);
+	return 0;
+}

I wonder if this (and ich7_lpc_probe()) could be __devinit.

Yes, I believe they can.

Quoted 18 lines
Quoted 18 lines
(quoted diff) +18 -0
+static void ich7_lpc_cleanup(struct device *dev)
+{
+	/*
+	 * If we were given exclusive use of the GPIO
+	 * I/O Address range, we must return it.
+	 */
+	if (gp_gpio_resource) {
+		dev_printk(KERN_DEBUG, dev, "Releasing GPIO I/O addresses\n");
+		release_region(nas_gpio_io_base, ICH7_GPIO_SIZE);
+		gp_gpio_resource = NULL;
+	}
+}
+
+/*
+ * The OS has determined that the LPC of the Intel ICH7 Southbridge is present
+ * so we can retrive the required operational information and prepare the GPIO.
+ */
+static struct pci_dev *nas_gpio_pci_dev;
Quoted 8 lines

Review

Quoted 6 lines
(quoted diff) +6 -0
+static int ich7_lpc_probe(struct pci_dev *dev, const struct pci_device_id *id)
+{
+	int status = 0;
+	u32 gc = 0;
+
+	pci_enable_device(dev);

Shouldn't we disable it again if this function fails?

Yes. I've also added it to the device removal path.

Quoted 8 lines

Review

Quoted 6 lines
(quoted diff) +3 -0
+
 
...
 
+
+void set_power_light_amber_noblink(void)

Please check that any/all global symbols really needed to be global.

Will do. I found a few others.

Quoted 9 lines
Quoted 9 lines
(quoted diff) +9 -0
+static ssize_t nas_led_blink_store(struct device *dev,
+				   struct device_attribute *attr,
+				   const char *buf, size_t size)
+{
+	int ret;
+	struct led_classdev *led = dev_get_drvdata(dev);
+	unsigned long blink_state;
+
+	ret = strict_strtoul(buf, 10, &blink_state);
Quoted 8 lines

Review

Quoted 6 lines
(quoted diff) +6 -0
+	if (ret)
+		return ret;
+
+	spin_lock(&nasgpio_gpio_lock);
+	nasgpio_led_set_attr(led, GPO_BLINK, blink_state);
+	spin_unlock(&nasgpio_gpio_lock);

It still looks like this locking could be moved into the callee.

That makes sense for two of the cases. The other one is the probe-time function. It probably doesn't strictly need locking, but I think it is nice to have.

the other is the one where we're setting blink and on/off state at the same time. nasgpio_led_set_attr() can only do one at once, so I need to hold the lock over both calls.

Fixed up patch is appended. It appears to be behaving itself on the real hardware.

-- Dave

Changes from last version
* created non-lock-taking __nasgpio_led_set_attr() and a lock-taking version with no '__'.
* added Kconfig dependency on DMI
* Added some 'static's to functions
* Added __devinit to init-time functions
* Add missed pci_disable_device() on probe error and device removal

Previous changes:
* Added dmi-basd hardware detection, and modparam
override for it
* replaced DRIVER_NAME with KBUILD_MODNAME

--

This code is based on a driver that came in the "Open-source and GPL components" download here:

http://downloadcenter.intel.com/SearchResult.aspx?lang=eng&ProductFamily=Server+Products&ProductLine=Intel%C2%AE+Storage+Systems&ProductProduct=Intel%C2%AE+Entry+Storage+System+SS4200-E&OSVersion=OS+Independent

It was in a file called nasgpio.c inside of a second zip file called SS4200-E_Linux_SIO_Driver-v1.4.zip.

That code used an ioctl() call to operate the LEDs. It also created a new top-level /proc file just to let userspace locate which dynamic major number had been allocated to the device. I decided that the interface probably wasn't mergeable in that form. :)

I ripped out all of the hardware monitor support from nasgpio.c as well as the smbus code that controls the LED brightness. I then converted the code to use the existing LED interfaces rather than the ioctl(). I don't have any need for brightness control, and its code is *completely* separate from the on/off controls implemented here. If anyone else wants it, I'd be happy to look into adding it, but I don't care enough for now.

Except for the probe routines, I rewrote most of it. I also Note that I don't have any hardware documentation except for the original driver.

Thanks go to Arjan for his help in getting the original source for this released and for chasing down some licensing issues.

---

 linux-2.6.git-dave/drivers/leds/Kconfig       |    9 
 linux-2.6.git-dave/drivers/leds/Makefile      |    1 
 linux-2.6.git-dave/drivers/leds/leds-ss4200.c |  560 ++++++++++++++++++++++++++
 3 files changed, 570 insertions(+)
drivers/leds/Kconfig renamed from drivers/leds/Kconfig~driver_for_Intel_NAS_SS4200_series +9 -0
diff -puN drivers/leds/Kconfig~driver_for_Intel_NAS_SS4200_series drivers/leds/Kconfig
@@ -229,6 +229,15 @@ config LEDS_BD2802
 	  This option enables support for BD2802GU RGB LED driver chips
 	  accessed via the I2C bus.
 
+config LEDS_INTEL_SS4200
+	tristate "LED driver for Intel NAS SS4200 series"
+	depends on LEDS_CLASS && PCI && DMI
+	help
+	  This option enables support for the Intel SS4200 series of
+	  Network Attached Storage servers.  You may control the hard
+	  drive or power LEDs on the front panel.  Using this driver
+	  can stop the front LED from blinking after startup.
+
 comment "LED Triggers"
 
 config LEDS_TRIGGERS
drivers/leds/leds-ss4200.c new file +560 -0

560 lines not on this page · raw message

drivers/leds/Makefile renamed from drivers/leds/Makefile~driver_for_Intel_NAS_SS4200_series +1 -0
diff -puN drivers/leds/Makefile~driver_for_Intel_NAS_SS4200_series drivers/leds/Makefile
@@ -28,6 +28,7 @@ obj-$(CONFIG_LEDS_PCA955X)		+= leds-pca9
 obj-$(CONFIG_LEDS_DA903X)		+= leds-da903x.o
 obj-$(CONFIG_LEDS_WM8350)		+= leds-wm8350.o
 obj-$(CONFIG_LEDS_PWM)			+= leds-pwm.o
+obj-$(CONFIG_LEDS_INTEL_SS4200)		+= leds-ss4200.o
 
 # LED SPI Drivers
 obj-$(CONFIG_LEDS_DAC124S085)		+= leds-dac124s085.o

diff -puN drivers/leds/leds-clevo-mail.c~driver_for_Intel_NAS_SS4200_series drivers/leds/leds-clevo-mail.c _

#4 lore raw

Re: [PATCH] LED driver for Intel NAS SS4200 series (v3)

Quoted 1 line · Dave Hansen

On Thu, 2009-09-24 at 17:19 -0700, Andrew Morton wrote:

Trivial logging comments:

One of the printks is not prefaced and the printks and dev_printks are not consistently using either periods or no periods.

Some possible substitutions:

s/dev_printk(KERN_INFO/dev_info(/
s/dev_printk(KERN_DEBUG/dev_dbg(/
s/printk(KERN_INFO/pr_info(/

I think it would be better to use:
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt and remove the "%s: " ... KBUILD_MODNAME

drivers/leds/leds-ss4200.c line 76

Quoted 1 line
drivers/leds/leds-ss4200.c new file +1 -0
+	printk(KERN_INFO KBUILD_MODNAME ": '%s' found\n", id->ident);

Perhaps

	pr_info("Found a '%s'\n", id->ident);

drivers/leds/leds-ss4200.c line 438

Quoted 1 line
drivers/leds/leds-ss4200.c new file +1 -0
+	printk(KERN_DEBUG "setting blue off and amber on\n");

pr_debug?

drivers/leds/leds-ss4200.c line 514

Quoted 4 lines
drivers/leds/leds-ss4200.c new file +4 -0
+		printk(KERN_INFO "%s: skipping hardware autodetection\n",
+				KBUILD_MODNAME);
+		printk(KERN_INFO "\tif this works, please send the output ");
+		printk(KERN_INFO "of 'dmidecode' to [email protected]\n");

I think this will look odd when printed. There's a tab on the second line, not on third. Perhaps:

		pr_info("Skipping hardware detection.\n");
		pr_info("Please send 'dmidecode' output to [email protected]\n");

drivers/leds/leds-ss4200.c line 553

Quoted 4 lines
drivers/leds/leds-ss4200.c new file +4 -0
+		printk(KERN_INFO "%s: no LED devices found\n",
+				KBUILD_MODNAME);
+	printk(KERN_INFO "registering %s PCI driver\n", KBUILD_MODNAME);
+	printk(KERN_INFO "Unregistering %s driver\n", KBUILD_MODNAME);
	pr_info("No LED devices found\n");
	pr_info("Registering PCI driver\n");
	pr_info("Unregistering PCI driver\n");
#5 lore raw

Re: [PATCH] LED driver for Intel NAS SS4200 series (v3)

Quoted 11 lines · Joe Perches
Quoted 1 line · Dave Hansen

On Thu, 2009-09-24 at 17:19 -0700, Andrew Morton wrote:

Trivial logging comments:

One of the printks is not prefaced and the printks and dev_printks are not consistently using either periods or no periods.

Some possible substitutions:

Quoted 7 lines

s/dev_printk(KERN_INFO/dev_info(/
s/dev_printk(KERN_DEBUG/dev_dbg(/
s/printk(KERN_INFO/pr_info(/

I think it would be better to use:
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt and remove the "%s: " ... KBUILD_MODNAME

Those all sound like good suggestions and should clean things up.

Quoted 20 lines

drivers/leds/leds-ss4200.c line 76

Quoted 1 line
drivers/leds/leds-ss4200.c new file +1 -0
+	printk(KERN_INFO KBUILD_MODNAME ": '%s' found\n", id->ident);

Perhaps

	pr_info("Found a '%s'\n", id->ident);

drivers/leds/leds-ss4200.c line 438

Quoted 1 line
drivers/leds/leds-ss4200.c new file +1 -0
+	printk(KERN_DEBUG "setting blue off and amber on\n");

pr_debug?

drivers/leds/leds-ss4200.c line 514

Quoted 4 lines
drivers/leds/leds-ss4200.c new file +4 -0
+		printk(KERN_INFO "%s: skipping hardware autodetection\n",
+				KBUILD_MODNAME);
+		printk(KERN_INFO "\tif this works, please send the output ");
+		printk(KERN_INFO "of 'dmidecode' to [email protected]\n");

I think this will look odd when printed. There's a tab on the second line, not on third. Perhaps:

		pr_info("Skipping hardware detection.\n");
		pr_info("Please send 'dmidecode' output to [email protected]\n");
Quoted 8 lines

drivers/leds/leds-ss4200.c line 553

Quoted 4 lines
drivers/leds/leds-ss4200.c new file +4 -0
+		printk(KERN_INFO "%s: no LED devices found\n",
+				KBUILD_MODNAME);
+	printk(KERN_INFO "registering %s PCI driver\n", KBUILD_MODNAME);
+	printk(KERN_INFO "Unregistering %s driver\n", KBUILD_MODNAME);
	pr_info("No LED devices found\n");
	pr_info("Registering PCI driver\n");
	pr_info("Unregistering PCI driver\n");

Doing that really cleans things up nicely. Thanks for the suggestions!

-- Dave