Skip to contentSkip to conversation

Add sata sil3114 support

PATCH New Tor Krill 2 participants 2 messages May 27, 2008 Block layer

lore
Share & tools
lore

Tor Krill

author
#0 lore raw

PATCH 1/1 Add sata sil3114 support

Add support for Silicon Images sil3114 sata chip using libata

---
 drivers/block/Makefile       |    1 +
 drivers/block/sata_sil3114.c |  845 ++++++++++++++++++++++++++++++++++++++++++
 drivers/block/sata_sil3114.h |  148 ++++++++
 3 files changed, 994 insertions(+), 0 deletions(-)
 create mode 100644 drivers/block/sata_sil3114.c
 create mode 100644 drivers/block/sata_sil3114.h
drivers/block/Makefile +1 -0
index 5f1298d..a09cd2a 100644
@@ -29,6 +29,7 @@ COBJS-y += ahci.o
 COBJS-y += ata_piix.o
 COBJS-$(CONFIG_FSL_SATA) += fsl_sata.o
 COBJS-$(CONFIG_LIBATA) += libata.o
+COBJS-$(CONFIG_SATA_SIL3114) += sata_sil3114.o
 COBJS-y += sil680.o
 COBJS-y += sym53c8xx.o
 COBJS-y += systemace.o
drivers/block/sata_sil3114.c new file +845 -0

845 lines not on this page · raw message

drivers/block/sata_sil3114.h new file +148 -0

148 lines not on this page · raw message

Signature · 1 line
1.5.5.1
#1 lore raw

PATCH 1/1 Add sata sil3114 support

Quoted 64 lines · Tor Krill

Add support for Silicon Images sil3114 sata chip using libata

---
 drivers/block/Makefile       |    1 +
 drivers/block/sata_sil3114.c |  845 ++++++++++++++++++++++++++++++++++++++++++
 drivers/block/sata_sil3114.h |  148 ++++++++
 3 files changed, 994 insertions(+), 0 deletions(-)
 create mode 100644 drivers/block/sata_sil3114.c
 create mode 100644 drivers/block/sata_sil3114.h
drivers/block/Makefile +1 -0
index 5f1298d..a09cd2a 100644
@@ -29,6 +29,7 @@ COBJS-y += ahci.o
 COBJS-y += ata_piix.o
 COBJS-$(CONFIG_FSL_SATA) += fsl_sata.o
 COBJS-$(CONFIG_LIBATA) += libata.o
+COBJS-$(CONFIG_SATA_SIL3114) += sata_sil3114.o
 COBJS-y += sil680.o
 COBJS-y += sym53c8xx.o
 COBJS-y += systemace.o
drivers/block/sata_sil3114.c new file +35 -0
new file mode 100644
index 0000000..bdc22d3
@@ -0,0 +1,845 @@
+/*
+ * Copyright (C) Excito Elektronik i Sk?ne AB, All rights reserved.
+ * Author: Tor Krill <[email protected]>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ * This is a driver for Silicon Image sil3114 sata chip modelled on
+ * the ata_piix driver
+ */
+
+
+#include <common.h>
+#include <pci.h>
+#include <command.h>
+#include <config.h>
+#include <asm/byteorder.h>
+#include <asm/io.h>
+#include <ide.h>
+#include <libata.h>
+#include "sata_sil3114.h"
+
+/* Convert sectorsize to wordsize */

drivers/block/sata_sil3114.c line 45

Quoted 10 lines
drivers/block/sata_sil3114.c new file +10 -0
+#define ATA_SECTOR_WORDS (ATA_SECT_SIZE/2)
+
+/* Excerpts from sata.h and cmd_sata.c */
+#define DEBUG_SATA	0		/*For debug prints set DEBUG_SATA to 1 */
+
+#if (DEBUG_SATA)
+#define PRINTF(fmt,args...)	printf (fmt ,##args)
+#else
+#define PRINTF(fmt,args...)
+#endif

Is it possible to use debug() instead of PRINTF?

Quoted 4 lines
drivers/block/sata_sil3114.c new file +4 -0
+
+/* Forwards */
+u8 sil3114_spin_up(int num);
+u8 sil3114_spin_down(int num);

drivers/block/sata_sil3114.c line 59

Quoted 10 lines
drivers/block/sata_sil3114.c new file +10 -0
+static int sata_bus_softreset(int num);
+static void sata_identify(int num, int dev);
+static u8 check_power_mode(int num);
+static void sata_port(struct sata_ioports *ioport);
+static void set_Feature_cmd(int num, int dev);
+static u8 sata_busy_wait(struct sata_ioports *ioaddr, int bits, unsigned int max, u8 usealtstatus);
+static u8 sata_chk_status(struct sata_ioports * ioaddr, u8 usealtstatus);
+static void msleep(int count);
+
+static u32 iobase[6]={0,0,0,0,0,0}; /* PCI BAR registers for our device */

please replace with
static u32 iobase[6] = {0, 0, 0, 0, 0, 0}; /* PCI BAR registers for our device */

drivers/block/sata_sil3114.c line 66

Quoted 7 lines
drivers/block/sata_sil3114.c new file +7 -0
+extern block_dev_desc_t sata_dev_desc[CFG_SATA_MAX_DEVICE];
+
+static struct sata_port port[CFG_SATA_MAX_DEVICE];
+
+static void output_data(struct sata_ioports *ioaddr, u16 * sect_buf, int words)
+{
+	while(words--){
                      ^

please add a space

drivers/block/sata_sil3114.c line 67

Quoted 1 line
drivers/block/sata_sil3114.c new file +1 -0
+		__raw_writew(*sect_buf++,(void *)ioaddr->data_addr);
                                         ^

same

Quoted 29 lines
drivers/block/sata_sil3114.c new file +29 -0
+	}
+}
+
+static int input_data(struct sata_ioports *ioaddr, u16 * sect_buf, int words)
+{
+	while(words--){
+		*sect_buf++=__raw_readw((void *)ioaddr->data_addr);
+	}
+	return 0;
+}
+
+static int sata_bus_softreset(int num)
+{
+	u8 status = 0;
+
+	port[num].dev_mask = 1;
+
+	port[num].ctl_reg = 0x08;	/*Default value of control reg */
+	writeb(port[num].ctl_reg, port[num].ioaddr.ctl_addr);
+	udelay(10);
+	writeb(port[num].ctl_reg | ATA_SRST, port[num].ioaddr.ctl_addr);
+	udelay(10);
+	writeb(port[num].ctl_reg, port[num].ioaddr.ctl_addr);
+
+	/* spec mandates ">= 2ms" before checking status.
+	 * We wait 150ms, because that was the magic delay used for
+	 * ATAPI devices in Hale Landis's ATADRVR, for the period of time
+	 * between when the ATA command register is written, and then
+	 * status is checked.  Because waiting for "a while" before

drivers/block/sata_sil3114.c line 106

Quoted 10 lines
drivers/block/sata_sil3114.c new file +10 -0
+	 * checking status is fine, post SRST, we perform this magic
+	 * delay here as well.
+	 */
+	msleep(150);
+	status = sata_busy_wait(&port[num].ioaddr, ATA_BUSY, 300, 0);
+	while((status & ATA_BUSY)) {
+		msleep(100);
+		status = sata_busy_wait(&port[num].ioaddr, ATA_BUSY, 3, 0);
+	}
+

Could you check the coding style, there is also some whitespace issue

Best Regards,
J.