Permalink
Browse files

ddrdrive: add read/write functions

Also initialize the internal structure a bit, reading the device
information.

Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
  • Loading branch information...
1 parent 012556b commit e857eb40aa163b9230aba396cfbb44d14c3bcb83 @gregkh committed Jun 26, 2009
Showing with 33 additions and 0 deletions.
  1. +33 −0 ddrdrive.c
View
@@ -100,6 +100,37 @@ static struct pci_device_id ids[] = {
};
MODULE_DEVICE_TABLE(pci, ids);
+static void ddr_write32(struct ddr *ddr, u32 off, u32 val)
+{
+ writel(val, ddr->bar0 + off);
+}
+
+static u32 ddr_read32(struct ddr *ddr, u32 off)
+{
+ return (readl(ddr->bar0 + off));
+}
+
+static void ddr_init(struct ddr *ddr)
+{
+ u32 value;
+
+ value = ddr_read32(ddr, BACKUP_RESTORE_STATUS);
+ if (((value & 0x80000000) != 0x0) || ((value & 0x40000000) != 0x0))
+ ddr->hba_state = 0x01;
+ else
+ ddr->hba_state = 0x00;
+
+ ddr->queue_head = 0x00;
+ ddr->queue_tail = 0x00;
+ ddr->queue_count = 0x00;
+
+ ddr->brick_state = ddr_read32(ddr, AC_ADAPTER_REG) >> 0x1f;
+ ddr->last_sector = 0x007BFFFF;
+
+ ddr_write32(ddr, EXT_LED_CONTROL_REG, 0x20000001);
+ ddr_write32(ddr, INT_CONTROL_REG, 0xF0000000);
+}
+
static int __devinit ddr_probe(struct pci_dev *pdev,
const struct pci_device_id *id)
{
@@ -147,6 +178,8 @@ static int __devinit ddr_probe(struct pci_dev *pdev,
pci_set_drvdata(pdev, ddr);
+ ddr_init(ddr);
+
return 0;
error_free_ddr:

0 comments on commit e857eb4

Please sign in to comment.