aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/ata/ahci.c
diff options
context:
space:
mode:
authorMatthew Garrett <mjg@redhat.com>2009-07-17 14:13:47 -0400
committerJeff Garzik <jgarzik@redhat.com>2009-09-01 19:47:20 -0400
commit77cdec1ad527560b59ab8dbb063dbb3d0a138bf7 (patch)
tree32ce6a8907a05a0eaacf970b58b557c6243a6132 /drivers/ata/ahci.c
parentf17259a31237cf0fd5c6c8cf2a4f9e6df405744b (diff)
libata: Export AHCI capabilities
AHCI exports various capability bits that may be of interest to userspace such as whether the BIOS claims a port is hotpluggable or eSATA. Providing these via sysfs along with the version of the AHCI spec implemented by the host allows userspace to make policy decisions for things like ALPM. Signed-off-by: Matthew Garrett <mjg@redhat.com> Signed-off-by: Jeff Garzik <jgarzik@redhat.com>
Diffstat (limited to 'drivers/ata/ahci.c')
-rw-r--r--drivers/ata/ahci.c44
1 files changed, 44 insertions, 0 deletions
diff --git a/drivers/ata/ahci.c b/drivers/ata/ahci.c
index 7a3124a9abc6..be4c39f8ab81 100644
--- a/drivers/ata/ahci.c
+++ b/drivers/ata/ahci.c
@@ -329,10 +329,24 @@ static ssize_t ahci_activity_store(struct ata_device *dev,
329 enum sw_activity val); 329 enum sw_activity val);
330static void ahci_init_sw_activity(struct ata_link *link); 330static void ahci_init_sw_activity(struct ata_link *link);
331 331
332static ssize_t ahci_show_host_caps(struct device *dev,
333 struct device_attribute *attr, char *buf);
334static ssize_t ahci_show_host_version(struct device *dev,
335 struct device_attribute *attr, char *buf);
336static ssize_t ahci_show_port_cmd(struct device *dev,
337 struct device_attribute *attr, char *buf);
338
339DEVICE_ATTR(ahci_host_caps, S_IRUGO, ahci_show_host_caps, NULL);
340DEVICE_ATTR(ahci_host_version, S_IRUGO, ahci_show_host_version, NULL);
341DEVICE_ATTR(ahci_port_cmd, S_IRUGO, ahci_show_port_cmd, NULL);
342
332static struct device_attribute *ahci_shost_attrs[] = { 343static struct device_attribute *ahci_shost_attrs[] = {
333 &dev_attr_link_power_management_policy, 344 &dev_attr_link_power_management_policy,
334 &dev_attr_em_message_type, 345 &dev_attr_em_message_type,
335 &dev_attr_em_message, 346 &dev_attr_em_message,
347 &dev_attr_ahci_host_caps,
348 &dev_attr_ahci_host_version,
349 &dev_attr_ahci_port_cmd,
336 NULL 350 NULL
337}; 351};
338 352
@@ -702,6 +716,36 @@ static void ahci_enable_ahci(void __iomem *mmio)
702 WARN_ON(1); 716 WARN_ON(1);
703} 717}
704 718
719static ssize_t ahci_show_host_caps(struct device *dev,
720 struct device_attribute *attr, char *buf)
721{
722 struct Scsi_Host *shost = class_to_shost(dev);
723 struct ata_port *ap = ata_shost_to_port(shost);
724 struct ahci_host_priv *hpriv = ap->host->private_data;
725
726 return sprintf(buf, "%x\n", hpriv->cap);
727}
728
729static ssize_t ahci_show_host_version(struct device *dev,
730 struct device_attribute *attr, char *buf)
731{
732 struct Scsi_Host *shost = class_to_shost(dev);
733 struct ata_port *ap = ata_shost_to_port(shost);
734 void __iomem *mmio = ap->host->iomap[AHCI_PCI_BAR];
735
736 return sprintf(buf, "%x\n", readl(mmio + HOST_VERSION));
737}
738
739static ssize_t ahci_show_port_cmd(struct device *dev,
740 struct device_attribute *attr, char *buf)
741{
742 struct Scsi_Host *shost = class_to_shost(dev);
743 struct ata_port *ap = ata_shost_to_port(shost);
744 void __iomem *port_mmio = ahci_port_base(ap);
745
746 return sprintf(buf, "%x\n", readl(port_mmio + PORT_CMD));
747}
748
705/** 749/**
706 * ahci_save_initial_config - Save and fixup initial config values 750 * ahci_save_initial_config - Save and fixup initial config values
707 * @pdev: target PCI device 751 * @pdev: target PCI device