Commit 87943acf authored by David Milburn's avatar David Milburn Committed by Jeff Garzik

libata: ahci enclosure management bit mask

Enclosure management bit mask definitions.
Signed-off-by: default avatarDavid Milburn <dmilburn@redhat.com>
Signed-off-by: default avatarJeff Garzik <jgarzik@redhat.com>
parent eb40963c
...@@ -49,6 +49,17 @@ ...@@ -49,6 +49,17 @@
#define DRV_NAME "ahci" #define DRV_NAME "ahci"
#define DRV_VERSION "3.0" #define DRV_VERSION "3.0"
/* Enclosure Management Control */
#define EM_CTRL_MSG_TYPE 0x000f0000
/* Enclosure Management LED Message Type */
#define EM_MSG_LED_HBA_PORT 0x0000000f
#define EM_MSG_LED_PMP_SLOT 0x0000ff00
#define EM_MSG_LED_VALUE 0xffff0000
#define EM_MSG_LED_VALUE_ACTIVITY 0x00070000
#define EM_MSG_LED_VALUE_OFF 0xfff80000
#define EM_MSG_LED_VALUE_ON 0x00010000
static int ahci_skip_host_reset; static int ahci_skip_host_reset;
module_param_named(skip_host_reset, ahci_skip_host_reset, int, 0444); module_param_named(skip_host_reset, ahci_skip_host_reset, int, 0444);
MODULE_PARM_DESC(skip_host_reset, "skip global host reset (0=don't skip, 1=skip)"); MODULE_PARM_DESC(skip_host_reset, "skip global host reset (0=don't skip, 1=skip)");
...@@ -1225,7 +1236,7 @@ static void ahci_sw_activity_blink(unsigned long arg) ...@@ -1225,7 +1236,7 @@ static void ahci_sw_activity_blink(unsigned long arg)
u32 activity_led_state; u32 activity_led_state;
unsigned long flags; unsigned long flags;
led_message &= 0xffff0000; led_message &= EM_MSG_LED_VALUE;
led_message |= ap->port_no | (link->pmp << 8); led_message |= ap->port_no | (link->pmp << 8);
/* check to see if we've had activity. If so, /* check to see if we've had activity. If so,
...@@ -1236,7 +1247,7 @@ static void ahci_sw_activity_blink(unsigned long arg) ...@@ -1236,7 +1247,7 @@ static void ahci_sw_activity_blink(unsigned long arg)
if (emp->saved_activity != emp->activity) { if (emp->saved_activity != emp->activity) {
emp->saved_activity = emp->activity; emp->saved_activity = emp->activity;
/* get the current LED state */ /* get the current LED state */
activity_led_state = led_message & 0x00010000; activity_led_state = led_message & EM_MSG_LED_VALUE_ON;
if (activity_led_state) if (activity_led_state)
activity_led_state = 0; activity_led_state = 0;
...@@ -1244,14 +1255,14 @@ static void ahci_sw_activity_blink(unsigned long arg) ...@@ -1244,14 +1255,14 @@ static void ahci_sw_activity_blink(unsigned long arg)
activity_led_state = 1; activity_led_state = 1;
/* clear old state */ /* clear old state */
led_message &= 0xfff8ffff; led_message &= ~EM_MSG_LED_VALUE_ACTIVITY;
/* toggle state */ /* toggle state */
led_message |= (activity_led_state << 16); led_message |= (activity_led_state << 16);
mod_timer(&emp->timer, jiffies + msecs_to_jiffies(100)); mod_timer(&emp->timer, jiffies + msecs_to_jiffies(100));
} else { } else {
/* switch to idle */ /* switch to idle */
led_message &= 0xfff8ffff; led_message &= ~EM_MSG_LED_VALUE_ACTIVITY;
if (emp->blink_policy == BLINK_OFF) if (emp->blink_policy == BLINK_OFF)
led_message |= (1 << 16); led_message |= (1 << 16);
} }
...@@ -1300,7 +1311,7 @@ static ssize_t ahci_transmit_led_message(struct ata_port *ap, u32 state, ...@@ -1300,7 +1311,7 @@ static ssize_t ahci_transmit_led_message(struct ata_port *ap, u32 state,
struct ahci_em_priv *emp; struct ahci_em_priv *emp;
/* get the slot number from the message */ /* get the slot number from the message */
pmp = (state & 0x0000ff00) >> 8; pmp = (state & EM_MSG_LED_PMP_SLOT) >> 8;
if (pmp < MAX_SLOTS) if (pmp < MAX_SLOTS)
emp = &pp->em_priv[pmp]; emp = &pp->em_priv[pmp];
else else
...@@ -1325,7 +1336,7 @@ static ssize_t ahci_transmit_led_message(struct ata_port *ap, u32 state, ...@@ -1325,7 +1336,7 @@ static ssize_t ahci_transmit_led_message(struct ata_port *ap, u32 state,
message[0] |= (4 << 8); message[0] |= (4 << 8);
/* ignore 0:4 of byte zero, fill in port info yourself */ /* ignore 0:4 of byte zero, fill in port info yourself */
message[1] = ((state & 0xfffffff0) | ap->port_no); message[1] = ((state & ~EM_MSG_LED_HBA_PORT) | ap->port_no);
/* write message to EM_LOC */ /* write message to EM_LOC */
writel(message[0], mmio + hpriv->em_loc); writel(message[0], mmio + hpriv->em_loc);
...@@ -1368,7 +1379,7 @@ static ssize_t ahci_led_store(struct ata_port *ap, const char *buf, ...@@ -1368,7 +1379,7 @@ static ssize_t ahci_led_store(struct ata_port *ap, const char *buf,
state = simple_strtoul(buf, NULL, 0); state = simple_strtoul(buf, NULL, 0);
/* get the slot number from the message */ /* get the slot number from the message */
pmp = (state & 0x0000ff00) >> 8; pmp = (state & EM_MSG_LED_PMP_SLOT) >> 8;
if (pmp < MAX_SLOTS) if (pmp < MAX_SLOTS)
emp = &pp->em_priv[pmp]; emp = &pp->em_priv[pmp];
else else
...@@ -1379,7 +1390,7 @@ static ssize_t ahci_led_store(struct ata_port *ap, const char *buf, ...@@ -1379,7 +1390,7 @@ static ssize_t ahci_led_store(struct ata_port *ap, const char *buf,
* activity led through em_message * activity led through em_message
*/ */
if (emp->blink_policy) if (emp->blink_policy)
state &= 0xfff8ffff; state &= ~EM_MSG_LED_VALUE_ACTIVITY;
return ahci_transmit_led_message(ap, state, size); return ahci_transmit_led_message(ap, state, size);
} }
...@@ -1398,16 +1409,16 @@ static ssize_t ahci_activity_store(struct ata_device *dev, enum sw_activity val) ...@@ -1398,16 +1409,16 @@ static ssize_t ahci_activity_store(struct ata_device *dev, enum sw_activity val)
link->flags &= ~(ATA_LFLAG_SW_ACTIVITY); link->flags &= ~(ATA_LFLAG_SW_ACTIVITY);
/* set the LED to OFF */ /* set the LED to OFF */
port_led_state &= 0xfff80000; port_led_state &= EM_MSG_LED_VALUE_OFF;
port_led_state |= (ap->port_no | (link->pmp << 8)); port_led_state |= (ap->port_no | (link->pmp << 8));
ahci_transmit_led_message(ap, port_led_state, 4); ahci_transmit_led_message(ap, port_led_state, 4);
} else { } else {
link->flags |= ATA_LFLAG_SW_ACTIVITY; link->flags |= ATA_LFLAG_SW_ACTIVITY;
if (val == BLINK_OFF) { if (val == BLINK_OFF) {
/* set LED to ON for idle */ /* set LED to ON for idle */
port_led_state &= 0xfff80000; port_led_state &= EM_MSG_LED_VALUE_OFF;
port_led_state |= (ap->port_no | (link->pmp << 8)); port_led_state |= (ap->port_no | (link->pmp << 8));
port_led_state |= 0x00010000; /* check this */ port_led_state |= EM_MSG_LED_VALUE_ON; /* check this */
ahci_transmit_led_message(ap, port_led_state, 4); ahci_transmit_led_message(ap, port_led_state, 4);
} }
} }
...@@ -2618,7 +2629,7 @@ static int ahci_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) ...@@ -2618,7 +2629,7 @@ static int ahci_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
u32 em_loc = readl(mmio + HOST_EM_LOC); u32 em_loc = readl(mmio + HOST_EM_LOC);
u32 em_ctl = readl(mmio + HOST_EM_CTL); u32 em_ctl = readl(mmio + HOST_EM_CTL);
messages = (em_ctl & 0x000f0000) >> 16; messages = (em_ctl & EM_CTRL_MSG_TYPE) >> 16;
/* we only support LED message type right now */ /* we only support LED message type right now */
if ((messages & 0x01) && (ahci_em_messages == 1)) { if ((messages & 0x01) && (ahci_em_messages == 1)) {
......
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