Skip to content

Commit 6e5fe5b

Browse files
hreineckejgarzik
authored andcommitted
ahci: EM supported message type sysfs attribute
This patch adds an sysfs attribute 'em_message_supported' to the ahci host device which prints out the supported enclosure management message types. Signed-off-by: Hannes Reinecke <[email protected]> Signed-off-by: Jeff Garzik <[email protected]>
1 parent 686c4cb commit 6e5fe5b

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

drivers/ata/ahci.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,10 @@ enum {
229229
EM_CTL_ALHD = (1 << 26), /* Activity LED */
230230
EM_CTL_XMT = (1 << 25), /* Transmit Only */
231231
EM_CTL_SMB = (1 << 24), /* Single Message Buffer */
232+
EM_CTL_SGPIO = (1 << 19), /* SGPIO messages supported */
233+
EM_CTL_SES = (1 << 18), /* SES-2 messages supported */
234+
EM_CTL_SAFTE = (1 << 17), /* SAF-TE messages supported */
235+
EM_CTL_LED = (1 << 16), /* LED messages supported */
232236

233237
/* em message type */
234238
EM_MSG_TYPE_LED = (1 << 0), /* LED */

drivers/ata/libahci.c

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,13 +109,16 @@ static ssize_t ahci_read_em_buffer(struct device *dev,
109109
static ssize_t ahci_store_em_buffer(struct device *dev,
110110
struct device_attribute *attr,
111111
const char *buf, size_t size);
112+
static ssize_t ahci_show_em_supported(struct device *dev,
113+
struct device_attribute *attr, char *buf);
112114

113115
static DEVICE_ATTR(ahci_host_caps, S_IRUGO, ahci_show_host_caps, NULL);
114116
static DEVICE_ATTR(ahci_host_cap2, S_IRUGO, ahci_show_host_cap2, NULL);
115117
static DEVICE_ATTR(ahci_host_version, S_IRUGO, ahci_show_host_version, NULL);
116118
static DEVICE_ATTR(ahci_port_cmd, S_IRUGO, ahci_show_port_cmd, NULL);
117119
static DEVICE_ATTR(em_buffer, S_IWUSR | S_IRUGO,
118120
ahci_read_em_buffer, ahci_store_em_buffer);
121+
static DEVICE_ATTR(em_message_supported, S_IRUGO, ahci_show_em_supported, NULL);
119122

120123
struct device_attribute *ahci_shost_attrs[] = {
121124
&dev_attr_link_power_management_policy,
@@ -126,6 +129,7 @@ struct device_attribute *ahci_shost_attrs[] = {
126129
&dev_attr_ahci_host_version,
127130
&dev_attr_ahci_port_cmd,
128131
&dev_attr_em_buffer,
132+
&dev_attr_em_message_supported,
129133
NULL
130134
};
131135
EXPORT_SYMBOL_GPL(ahci_shost_attrs);
@@ -343,6 +347,24 @@ static ssize_t ahci_store_em_buffer(struct device *dev,
343347
return size;
344348
}
345349

350+
static ssize_t ahci_show_em_supported(struct device *dev,
351+
struct device_attribute *attr, char *buf)
352+
{
353+
struct Scsi_Host *shost = class_to_shost(dev);
354+
struct ata_port *ap = ata_shost_to_port(shost);
355+
struct ahci_host_priv *hpriv = ap->host->private_data;
356+
void __iomem *mmio = hpriv->mmio;
357+
u32 em_ctl;
358+
359+
em_ctl = readl(mmio + HOST_EM_CTL);
360+
361+
return sprintf(buf, "%s%s%s%s\n",
362+
em_ctl & EM_CTL_LED ? "led " : "",
363+
em_ctl & EM_CTL_SAFTE ? "saf-te " : "",
364+
em_ctl & EM_CTL_SES ? "ses-2 " : "",
365+
em_ctl & EM_CTL_SGPIO ? "sgpio " : "");
366+
}
367+
346368
/**
347369
* ahci_save_initial_config - Save and fixup initial config values
348370
* @dev: target AHCI device

0 commit comments

Comments
 (0)