Add driver for S-ATA-controller on Intel processors with South
Bridge, ICH-5, ICH-6 and ICH-7.
Implementation:
1. Code is divided in to two files. All functions, which are
controller specific are kept in "drivers/ata_piix.c" file and
functions, which are not controller specific, are kept in
"common/cmd_sata.c" file.
2. Reading and Writing from the S-ATA drive is done using PIO method.
3. Driver can be configured for 48-bit addressing by defining macro
CONFIG_LBA48, if this macro is not defined driver uses the 28-bit
addressing.
4. S-ATA read function is hooked to the File system, commands like
ext2ls and ext2load file can be used. This has been tested.
5. U-Boot command "SATA_init" is added, which initializes the S-ATA
controller and identifies the S-ATA drives connected to it.
6. U-Boot command "sata" is added, which is used to read/write, print
partition table and get info about the drives present. This I have
implemented in same way as "ide" command is implemented in U-Boot.
7. This driver is for S-ATA in native mode.
8. This driver does not support the Native command queuing and
Hot-plugging.
Signed-off-by: Mushtaq Khan <mushtaq_k@procsys.com>
2007-04-20 08:53:02 +00:00
|
|
|
/*
|
2007-05-15 21:38:05 +00:00
|
|
|
* Copyright (C) Procsys. All rights reserved.
|
|
|
|
* Author: Mushtaq Khan <mushtaq_k@procsys.com>
|
|
|
|
* <mushtaqk_921@yahoo.co.in>
|
|
|
|
*
|
2013-07-08 07:37:19 +00:00
|
|
|
* SPDX-License-Identifier: GPL-2.0+
|
2007-05-15 21:38:05 +00:00
|
|
|
*
|
|
|
|
* with the reference to ata_piix driver in kernel 2.4.32
|
|
|
|
*/
|
Add driver for S-ATA-controller on Intel processors with South
Bridge, ICH-5, ICH-6 and ICH-7.
Implementation:
1. Code is divided in to two files. All functions, which are
controller specific are kept in "drivers/ata_piix.c" file and
functions, which are not controller specific, are kept in
"common/cmd_sata.c" file.
2. Reading and Writing from the S-ATA drive is done using PIO method.
3. Driver can be configured for 48-bit addressing by defining macro
CONFIG_LBA48, if this macro is not defined driver uses the 28-bit
addressing.
4. S-ATA read function is hooked to the File system, commands like
ext2ls and ext2load file can be used. This has been tested.
5. U-Boot command "SATA_init" is added, which initializes the S-ATA
controller and identifies the S-ATA drives connected to it.
6. U-Boot command "sata" is added, which is used to read/write, print
partition table and get info about the drives present. This I have
implemented in same way as "ide" command is implemented in U-Boot.
7. This driver is for S-ATA in native mode.
8. This driver does not support the Native command queuing and
Hot-plugging.
Signed-off-by: Mushtaq Khan <mushtaq_k@procsys.com>
2007-04-20 08:53:02 +00:00
|
|
|
|
|
|
|
/*
|
2007-05-15 21:38:05 +00:00
|
|
|
* This file contains SATA controller and SATA drive initialization functions
|
|
|
|
*/
|
Add driver for S-ATA-controller on Intel processors with South
Bridge, ICH-5, ICH-6 and ICH-7.
Implementation:
1. Code is divided in to two files. All functions, which are
controller specific are kept in "drivers/ata_piix.c" file and
functions, which are not controller specific, are kept in
"common/cmd_sata.c" file.
2. Reading and Writing from the S-ATA drive is done using PIO method.
3. Driver can be configured for 48-bit addressing by defining macro
CONFIG_LBA48, if this macro is not defined driver uses the 28-bit
addressing.
4. S-ATA read function is hooked to the File system, commands like
ext2ls and ext2load file can be used. This has been tested.
5. U-Boot command "SATA_init" is added, which initializes the S-ATA
controller and identifies the S-ATA drives connected to it.
6. U-Boot command "sata" is added, which is used to read/write, print
partition table and get info about the drives present. This I have
implemented in same way as "ide" command is implemented in U-Boot.
7. This driver is for S-ATA in native mode.
8. This driver does not support the Native command queuing and
Hot-plugging.
Signed-off-by: Mushtaq Khan <mushtaq_k@procsys.com>
2007-04-20 08:53:02 +00:00
|
|
|
|
|
|
|
#include <common.h>
|
2008-03-26 14:47:06 +00:00
|
|
|
#include <asm/io.h>
|
Add driver for S-ATA-controller on Intel processors with South
Bridge, ICH-5, ICH-6 and ICH-7.
Implementation:
1. Code is divided in to two files. All functions, which are
controller specific are kept in "drivers/ata_piix.c" file and
functions, which are not controller specific, are kept in
"common/cmd_sata.c" file.
2. Reading and Writing from the S-ATA drive is done using PIO method.
3. Driver can be configured for 48-bit addressing by defining macro
CONFIG_LBA48, if this macro is not defined driver uses the 28-bit
addressing.
4. S-ATA read function is hooked to the File system, commands like
ext2ls and ext2load file can be used. This has been tested.
5. U-Boot command "SATA_init" is added, which initializes the S-ATA
controller and identifies the S-ATA drives connected to it.
6. U-Boot command "sata" is added, which is used to read/write, print
partition table and get info about the drives present. This I have
implemented in same way as "ide" command is implemented in U-Boot.
7. This driver is for S-ATA in native mode.
8. This driver does not support the Native command queuing and
Hot-plugging.
Signed-off-by: Mushtaq Khan <mushtaq_k@procsys.com>
2007-04-20 08:53:02 +00:00
|
|
|
#include <pci.h>
|
|
|
|
#include <command.h>
|
|
|
|
#include <config.h>
|
|
|
|
#include <asm/byteorder.h>
|
2008-03-26 14:47:06 +00:00
|
|
|
#include <part.h>
|
Add driver for S-ATA-controller on Intel processors with South
Bridge, ICH-5, ICH-6 and ICH-7.
Implementation:
1. Code is divided in to two files. All functions, which are
controller specific are kept in "drivers/ata_piix.c" file and
functions, which are not controller specific, are kept in
"common/cmd_sata.c" file.
2. Reading and Writing from the S-ATA drive is done using PIO method.
3. Driver can be configured for 48-bit addressing by defining macro
CONFIG_LBA48, if this macro is not defined driver uses the 28-bit
addressing.
4. S-ATA read function is hooked to the File system, commands like
ext2ls and ext2load file can be used. This has been tested.
5. U-Boot command "SATA_init" is added, which initializes the S-ATA
controller and identifies the S-ATA drives connected to it.
6. U-Boot command "sata" is added, which is used to read/write, print
partition table and get info about the drives present. This I have
implemented in same way as "ide" command is implemented in U-Boot.
7. This driver is for S-ATA in native mode.
8. This driver does not support the Native command queuing and
Hot-plugging.
Signed-off-by: Mushtaq Khan <mushtaq_k@procsys.com>
2007-04-20 08:53:02 +00:00
|
|
|
#include <ide.h>
|
|
|
|
#include <ata.h>
|
2012-09-27 23:18:04 +00:00
|
|
|
#include <sata.h>
|
2008-03-26 14:50:45 +00:00
|
|
|
|
2012-09-29 14:35:12 +00:00
|
|
|
#define DEBUG_SATA 0 /* For debug prints set DEBUG_SATA to 1 */
|
Add driver for S-ATA-controller on Intel processors with South
Bridge, ICH-5, ICH-6 and ICH-7.
Implementation:
1. Code is divided in to two files. All functions, which are
controller specific are kept in "drivers/ata_piix.c" file and
functions, which are not controller specific, are kept in
"common/cmd_sata.c" file.
2. Reading and Writing from the S-ATA drive is done using PIO method.
3. Driver can be configured for 48-bit addressing by defining macro
CONFIG_LBA48, if this macro is not defined driver uses the 28-bit
addressing.
4. S-ATA read function is hooked to the File system, commands like
ext2ls and ext2load file can be used. This has been tested.
5. U-Boot command "SATA_init" is added, which initializes the S-ATA
controller and identifies the S-ATA drives connected to it.
6. U-Boot command "sata" is added, which is used to read/write, print
partition table and get info about the drives present. This I have
implemented in same way as "ide" command is implemented in U-Boot.
7. This driver is for S-ATA in native mode.
8. This driver does not support the Native command queuing and
Hot-plugging.
Signed-off-by: Mushtaq Khan <mushtaq_k@procsys.com>
2007-04-20 08:53:02 +00:00
|
|
|
|
2008-03-26 14:47:06 +00:00
|
|
|
#define SATA_DECL
|
2012-09-29 14:35:12 +00:00
|
|
|
#define DRV_DECL /* For file specific declarations */
|
2008-03-26 14:48:18 +00:00
|
|
|
#include "ata_piix.h"
|
Add driver for S-ATA-controller on Intel processors with South
Bridge, ICH-5, ICH-6 and ICH-7.
Implementation:
1. Code is divided in to two files. All functions, which are
controller specific are kept in "drivers/ata_piix.c" file and
functions, which are not controller specific, are kept in
"common/cmd_sata.c" file.
2. Reading and Writing from the S-ATA drive is done using PIO method.
3. Driver can be configured for 48-bit addressing by defining macro
CONFIG_LBA48, if this macro is not defined driver uses the 28-bit
addressing.
4. S-ATA read function is hooked to the File system, commands like
ext2ls and ext2load file can be used. This has been tested.
5. U-Boot command "SATA_init" is added, which initializes the S-ATA
controller and identifies the S-ATA drives connected to it.
6. U-Boot command "sata" is added, which is used to read/write, print
partition table and get info about the drives present. This I have
implemented in same way as "ide" command is implemented in U-Boot.
7. This driver is for S-ATA in native mode.
8. This driver does not support the Native command queuing and
Hot-plugging.
Signed-off-by: Mushtaq Khan <mushtaq_k@procsys.com>
2007-04-20 08:53:02 +00:00
|
|
|
|
2012-09-29 14:35:12 +00:00
|
|
|
/* Macros realted to PCI */
|
Add driver for S-ATA-controller on Intel processors with South
Bridge, ICH-5, ICH-6 and ICH-7.
Implementation:
1. Code is divided in to two files. All functions, which are
controller specific are kept in "drivers/ata_piix.c" file and
functions, which are not controller specific, are kept in
"common/cmd_sata.c" file.
2. Reading and Writing from the S-ATA drive is done using PIO method.
3. Driver can be configured for 48-bit addressing by defining macro
CONFIG_LBA48, if this macro is not defined driver uses the 28-bit
addressing.
4. S-ATA read function is hooked to the File system, commands like
ext2ls and ext2load file can be used. This has been tested.
5. U-Boot command "SATA_init" is added, which initializes the S-ATA
controller and identifies the S-ATA drives connected to it.
6. U-Boot command "sata" is added, which is used to read/write, print
partition table and get info about the drives present. This I have
implemented in same way as "ide" command is implemented in U-Boot.
7. This driver is for S-ATA in native mode.
8. This driver does not support the Native command queuing and
Hot-plugging.
Signed-off-by: Mushtaq Khan <mushtaq_k@procsys.com>
2007-04-20 08:53:02 +00:00
|
|
|
#define PCI_SATA_BUS 0x00
|
|
|
|
#define PCI_SATA_DEV 0x1f
|
|
|
|
#define PCI_SATA_FUNC 0x02
|
|
|
|
|
|
|
|
#define PCI_SATA_BASE1 0x10
|
|
|
|
#define PCI_SATA_BASE2 0x14
|
|
|
|
#define PCI_SATA_BASE3 0x18
|
|
|
|
#define PCI_SATA_BASE4 0x1c
|
|
|
|
#define PCI_SATA_BASE5 0x20
|
|
|
|
#define PCI_PMR 0x90
|
|
|
|
#define PCI_PI 0x09
|
|
|
|
#define PCI_PCS 0x92
|
|
|
|
#define PCI_DMA_CTL 0x48
|
|
|
|
|
|
|
|
#define PORT_PRESENT (1<<0)
|
|
|
|
#define PORT_ENABLED (1<<4)
|
|
|
|
|
|
|
|
u32 bdf;
|
2012-09-29 14:35:12 +00:00
|
|
|
u32 iobase1; /* Primary cmd block */
|
|
|
|
u32 iobase2; /* Primary ctl block */
|
|
|
|
u32 iobase3; /* Sec cmd block */
|
|
|
|
u32 iobase4; /* sec ctl block */
|
|
|
|
u32 iobase5; /* BMDMA*/
|
|
|
|
|
|
|
|
int pci_sata_init(void)
|
Add driver for S-ATA-controller on Intel processors with South
Bridge, ICH-5, ICH-6 and ICH-7.
Implementation:
1. Code is divided in to two files. All functions, which are
controller specific are kept in "drivers/ata_piix.c" file and
functions, which are not controller specific, are kept in
"common/cmd_sata.c" file.
2. Reading and Writing from the S-ATA drive is done using PIO method.
3. Driver can be configured for 48-bit addressing by defining macro
CONFIG_LBA48, if this macro is not defined driver uses the 28-bit
addressing.
4. S-ATA read function is hooked to the File system, commands like
ext2ls and ext2load file can be used. This has been tested.
5. U-Boot command "SATA_init" is added, which initializes the S-ATA
controller and identifies the S-ATA drives connected to it.
6. U-Boot command "sata" is added, which is used to read/write, print
partition table and get info about the drives present. This I have
implemented in same way as "ide" command is implemented in U-Boot.
7. This driver is for S-ATA in native mode.
8. This driver does not support the Native command queuing and
Hot-plugging.
Signed-off-by: Mushtaq Khan <mushtaq_k@procsys.com>
2007-04-20 08:53:02 +00:00
|
|
|
{
|
|
|
|
u32 bus = PCI_SATA_BUS;
|
|
|
|
u32 dev = PCI_SATA_DEV;
|
|
|
|
u32 fun = PCI_SATA_FUNC;
|
|
|
|
u16 cmd = 0;
|
|
|
|
u8 lat = 0, pcibios_max_latency = 0xff;
|
2012-09-29 14:35:12 +00:00
|
|
|
u8 pmr; /* Port mapping reg */
|
|
|
|
u8 pi; /* Prgming Interface reg */
|
Add driver for S-ATA-controller on Intel processors with South
Bridge, ICH-5, ICH-6 and ICH-7.
Implementation:
1. Code is divided in to two files. All functions, which are
controller specific are kept in "drivers/ata_piix.c" file and
functions, which are not controller specific, are kept in
"common/cmd_sata.c" file.
2. Reading and Writing from the S-ATA drive is done using PIO method.
3. Driver can be configured for 48-bit addressing by defining macro
CONFIG_LBA48, if this macro is not defined driver uses the 28-bit
addressing.
4. S-ATA read function is hooked to the File system, commands like
ext2ls and ext2load file can be used. This has been tested.
5. U-Boot command "SATA_init" is added, which initializes the S-ATA
controller and identifies the S-ATA drives connected to it.
6. U-Boot command "sata" is added, which is used to read/write, print
partition table and get info about the drives present. This I have
implemented in same way as "ide" command is implemented in U-Boot.
7. This driver is for S-ATA in native mode.
8. This driver does not support the Native command queuing and
Hot-plugging.
Signed-off-by: Mushtaq Khan <mushtaq_k@procsys.com>
2007-04-20 08:53:02 +00:00
|
|
|
|
2012-09-29 14:35:12 +00:00
|
|
|
bdf = PCI_BDF(bus, dev, fun);
|
|
|
|
pci_read_config_dword(bdf, PCI_SATA_BASE1, &iobase1);
|
|
|
|
pci_read_config_dword(bdf, PCI_SATA_BASE2, &iobase2);
|
|
|
|
pci_read_config_dword(bdf, PCI_SATA_BASE3, &iobase3);
|
|
|
|
pci_read_config_dword(bdf, PCI_SATA_BASE4, &iobase4);
|
|
|
|
pci_read_config_dword(bdf, PCI_SATA_BASE5, &iobase5);
|
Add driver for S-ATA-controller on Intel processors with South
Bridge, ICH-5, ICH-6 and ICH-7.
Implementation:
1. Code is divided in to two files. All functions, which are
controller specific are kept in "drivers/ata_piix.c" file and
functions, which are not controller specific, are kept in
"common/cmd_sata.c" file.
2. Reading and Writing from the S-ATA drive is done using PIO method.
3. Driver can be configured for 48-bit addressing by defining macro
CONFIG_LBA48, if this macro is not defined driver uses the 28-bit
addressing.
4. S-ATA read function is hooked to the File system, commands like
ext2ls and ext2load file can be used. This has been tested.
5. U-Boot command "SATA_init" is added, which initializes the S-ATA
controller and identifies the S-ATA drives connected to it.
6. U-Boot command "sata" is added, which is used to read/write, print
partition table and get info about the drives present. This I have
implemented in same way as "ide" command is implemented in U-Boot.
7. This driver is for S-ATA in native mode.
8. This driver does not support the Native command queuing and
Hot-plugging.
Signed-off-by: Mushtaq Khan <mushtaq_k@procsys.com>
2007-04-20 08:53:02 +00:00
|
|
|
|
|
|
|
if ((iobase1 == 0xFFFFFFFF) || (iobase2 == 0xFFFFFFFF) ||
|
|
|
|
(iobase3 == 0xFFFFFFFF) || (iobase4 == 0xFFFFFFFF) ||
|
|
|
|
(iobase5 == 0xFFFFFFFF)) {
|
2012-09-29 14:35:12 +00:00
|
|
|
/* ERROR */
|
|
|
|
printf("error no base addr for SATA controller\n");
|
Add driver for S-ATA-controller on Intel processors with South
Bridge, ICH-5, ICH-6 and ICH-7.
Implementation:
1. Code is divided in to two files. All functions, which are
controller specific are kept in "drivers/ata_piix.c" file and
functions, which are not controller specific, are kept in
"common/cmd_sata.c" file.
2. Reading and Writing from the S-ATA drive is done using PIO method.
3. Driver can be configured for 48-bit addressing by defining macro
CONFIG_LBA48, if this macro is not defined driver uses the 28-bit
addressing.
4. S-ATA read function is hooked to the File system, commands like
ext2ls and ext2load file can be used. This has been tested.
5. U-Boot command "SATA_init" is added, which initializes the S-ATA
controller and identifies the S-ATA drives connected to it.
6. U-Boot command "sata" is added, which is used to read/write, print
partition table and get info about the drives present. This I have
implemented in same way as "ide" command is implemented in U-Boot.
7. This driver is for S-ATA in native mode.
8. This driver does not support the Native command queuing and
Hot-plugging.
Signed-off-by: Mushtaq Khan <mushtaq_k@procsys.com>
2007-04-20 08:53:02 +00:00
|
|
|
return 1;
|
2012-09-29 14:35:12 +00:00
|
|
|
}
|
Add driver for S-ATA-controller on Intel processors with South
Bridge, ICH-5, ICH-6 and ICH-7.
Implementation:
1. Code is divided in to two files. All functions, which are
controller specific are kept in "drivers/ata_piix.c" file and
functions, which are not controller specific, are kept in
"common/cmd_sata.c" file.
2. Reading and Writing from the S-ATA drive is done using PIO method.
3. Driver can be configured for 48-bit addressing by defining macro
CONFIG_LBA48, if this macro is not defined driver uses the 28-bit
addressing.
4. S-ATA read function is hooked to the File system, commands like
ext2ls and ext2load file can be used. This has been tested.
5. U-Boot command "SATA_init" is added, which initializes the S-ATA
controller and identifies the S-ATA drives connected to it.
6. U-Boot command "sata" is added, which is used to read/write, print
partition table and get info about the drives present. This I have
implemented in same way as "ide" command is implemented in U-Boot.
7. This driver is for S-ATA in native mode.
8. This driver does not support the Native command queuing and
Hot-plugging.
Signed-off-by: Mushtaq Khan <mushtaq_k@procsys.com>
2007-04-20 08:53:02 +00:00
|
|
|
|
|
|
|
iobase1 &= 0xFFFFFFFE;
|
|
|
|
iobase2 &= 0xFFFFFFFE;
|
|
|
|
iobase3 &= 0xFFFFFFFE;
|
|
|
|
iobase4 &= 0xFFFFFFFE;
|
|
|
|
iobase5 &= 0xFFFFFFFE;
|
|
|
|
|
2012-09-29 14:35:12 +00:00
|
|
|
/* check for mode */
|
|
|
|
pci_read_config_byte(bdf, PCI_PMR, &pmr);
|
Add driver for S-ATA-controller on Intel processors with South
Bridge, ICH-5, ICH-6 and ICH-7.
Implementation:
1. Code is divided in to two files. All functions, which are
controller specific are kept in "drivers/ata_piix.c" file and
functions, which are not controller specific, are kept in
"common/cmd_sata.c" file.
2. Reading and Writing from the S-ATA drive is done using PIO method.
3. Driver can be configured for 48-bit addressing by defining macro
CONFIG_LBA48, if this macro is not defined driver uses the 28-bit
addressing.
4. S-ATA read function is hooked to the File system, commands like
ext2ls and ext2load file can be used. This has been tested.
5. U-Boot command "SATA_init" is added, which initializes the S-ATA
controller and identifies the S-ATA drives connected to it.
6. U-Boot command "sata" is added, which is used to read/write, print
partition table and get info about the drives present. This I have
implemented in same way as "ide" command is implemented in U-Boot.
7. This driver is for S-ATA in native mode.
8. This driver does not support the Native command queuing and
Hot-plugging.
Signed-off-by: Mushtaq Khan <mushtaq_k@procsys.com>
2007-04-20 08:53:02 +00:00
|
|
|
if (pmr > 1) {
|
2012-09-29 14:35:12 +00:00
|
|
|
puts("combined mode not supported\n");
|
Add driver for S-ATA-controller on Intel processors with South
Bridge, ICH-5, ICH-6 and ICH-7.
Implementation:
1. Code is divided in to two files. All functions, which are
controller specific are kept in "drivers/ata_piix.c" file and
functions, which are not controller specific, are kept in
"common/cmd_sata.c" file.
2. Reading and Writing from the S-ATA drive is done using PIO method.
3. Driver can be configured for 48-bit addressing by defining macro
CONFIG_LBA48, if this macro is not defined driver uses the 28-bit
addressing.
4. S-ATA read function is hooked to the File system, commands like
ext2ls and ext2load file can be used. This has been tested.
5. U-Boot command "SATA_init" is added, which initializes the S-ATA
controller and identifies the S-ATA drives connected to it.
6. U-Boot command "sata" is added, which is used to read/write, print
partition table and get info about the drives present. This I have
implemented in same way as "ide" command is implemented in U-Boot.
7. This driver is for S-ATA in native mode.
8. This driver does not support the Native command queuing and
Hot-plugging.
Signed-off-by: Mushtaq Khan <mushtaq_k@procsys.com>
2007-04-20 08:53:02 +00:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2012-09-29 14:35:12 +00:00
|
|
|
pci_read_config_byte(bdf, PCI_PI, &pi);
|
Add driver for S-ATA-controller on Intel processors with South
Bridge, ICH-5, ICH-6 and ICH-7.
Implementation:
1. Code is divided in to two files. All functions, which are
controller specific are kept in "drivers/ata_piix.c" file and
functions, which are not controller specific, are kept in
"common/cmd_sata.c" file.
2. Reading and Writing from the S-ATA drive is done using PIO method.
3. Driver can be configured for 48-bit addressing by defining macro
CONFIG_LBA48, if this macro is not defined driver uses the 28-bit
addressing.
4. S-ATA read function is hooked to the File system, commands like
ext2ls and ext2load file can be used. This has been tested.
5. U-Boot command "SATA_init" is added, which initializes the S-ATA
controller and identifies the S-ATA drives connected to it.
6. U-Boot command "sata" is added, which is used to read/write, print
partition table and get info about the drives present. This I have
implemented in same way as "ide" command is implemented in U-Boot.
7. This driver is for S-ATA in native mode.
8. This driver does not support the Native command queuing and
Hot-plugging.
Signed-off-by: Mushtaq Khan <mushtaq_k@procsys.com>
2007-04-20 08:53:02 +00:00
|
|
|
if ((pi & 0x05) != 0x05) {
|
2012-09-29 14:35:12 +00:00
|
|
|
puts("Sata is in Legacy mode\n");
|
Add driver for S-ATA-controller on Intel processors with South
Bridge, ICH-5, ICH-6 and ICH-7.
Implementation:
1. Code is divided in to two files. All functions, which are
controller specific are kept in "drivers/ata_piix.c" file and
functions, which are not controller specific, are kept in
"common/cmd_sata.c" file.
2. Reading and Writing from the S-ATA drive is done using PIO method.
3. Driver can be configured for 48-bit addressing by defining macro
CONFIG_LBA48, if this macro is not defined driver uses the 28-bit
addressing.
4. S-ATA read function is hooked to the File system, commands like
ext2ls and ext2load file can be used. This has been tested.
5. U-Boot command "SATA_init" is added, which initializes the S-ATA
controller and identifies the S-ATA drives connected to it.
6. U-Boot command "sata" is added, which is used to read/write, print
partition table and get info about the drives present. This I have
implemented in same way as "ide" command is implemented in U-Boot.
7. This driver is for S-ATA in native mode.
8. This driver does not support the Native command queuing and
Hot-plugging.
Signed-off-by: Mushtaq Khan <mushtaq_k@procsys.com>
2007-04-20 08:53:02 +00:00
|
|
|
return 1;
|
2012-09-29 14:35:12 +00:00
|
|
|
} else
|
|
|
|
puts("sata is in Native mode\n");
|
Add driver for S-ATA-controller on Intel processors with South
Bridge, ICH-5, ICH-6 and ICH-7.
Implementation:
1. Code is divided in to two files. All functions, which are
controller specific are kept in "drivers/ata_piix.c" file and
functions, which are not controller specific, are kept in
"common/cmd_sata.c" file.
2. Reading and Writing from the S-ATA drive is done using PIO method.
3. Driver can be configured for 48-bit addressing by defining macro
CONFIG_LBA48, if this macro is not defined driver uses the 28-bit
addressing.
4. S-ATA read function is hooked to the File system, commands like
ext2ls and ext2load file can be used. This has been tested.
5. U-Boot command "SATA_init" is added, which initializes the S-ATA
controller and identifies the S-ATA drives connected to it.
6. U-Boot command "sata" is added, which is used to read/write, print
partition table and get info about the drives present. This I have
implemented in same way as "ide" command is implemented in U-Boot.
7. This driver is for S-ATA in native mode.
8. This driver does not support the Native command queuing and
Hot-plugging.
Signed-off-by: Mushtaq Khan <mushtaq_k@procsys.com>
2007-04-20 08:53:02 +00:00
|
|
|
|
2012-09-29 14:35:12 +00:00
|
|
|
/* MASTER CFG AND IO CFG */
|
|
|
|
pci_read_config_word(bdf, PCI_COMMAND, &cmd);
|
Add driver for S-ATA-controller on Intel processors with South
Bridge, ICH-5, ICH-6 and ICH-7.
Implementation:
1. Code is divided in to two files. All functions, which are
controller specific are kept in "drivers/ata_piix.c" file and
functions, which are not controller specific, are kept in
"common/cmd_sata.c" file.
2. Reading and Writing from the S-ATA drive is done using PIO method.
3. Driver can be configured for 48-bit addressing by defining macro
CONFIG_LBA48, if this macro is not defined driver uses the 28-bit
addressing.
4. S-ATA read function is hooked to the File system, commands like
ext2ls and ext2load file can be used. This has been tested.
5. U-Boot command "SATA_init" is added, which initializes the S-ATA
controller and identifies the S-ATA drives connected to it.
6. U-Boot command "sata" is added, which is used to read/write, print
partition table and get info about the drives present. This I have
implemented in same way as "ide" command is implemented in U-Boot.
7. This driver is for S-ATA in native mode.
8. This driver does not support the Native command queuing and
Hot-plugging.
Signed-off-by: Mushtaq Khan <mushtaq_k@procsys.com>
2007-04-20 08:53:02 +00:00
|
|
|
cmd |= PCI_COMMAND_MASTER | PCI_COMMAND_IO;
|
2012-09-29 14:35:12 +00:00
|
|
|
pci_write_config_word(bdf, PCI_COMMAND, cmd);
|
|
|
|
pci_read_config_byte(dev, PCI_LATENCY_TIMER, &lat);
|
Add driver for S-ATA-controller on Intel processors with South
Bridge, ICH-5, ICH-6 and ICH-7.
Implementation:
1. Code is divided in to two files. All functions, which are
controller specific are kept in "drivers/ata_piix.c" file and
functions, which are not controller specific, are kept in
"common/cmd_sata.c" file.
2. Reading and Writing from the S-ATA drive is done using PIO method.
3. Driver can be configured for 48-bit addressing by defining macro
CONFIG_LBA48, if this macro is not defined driver uses the 28-bit
addressing.
4. S-ATA read function is hooked to the File system, commands like
ext2ls and ext2load file can be used. This has been tested.
5. U-Boot command "SATA_init" is added, which initializes the S-ATA
controller and identifies the S-ATA drives connected to it.
6. U-Boot command "sata" is added, which is used to read/write, print
partition table and get info about the drives present. This I have
implemented in same way as "ide" command is implemented in U-Boot.
7. This driver is for S-ATA in native mode.
8. This driver does not support the Native command queuing and
Hot-plugging.
Signed-off-by: Mushtaq Khan <mushtaq_k@procsys.com>
2007-04-20 08:53:02 +00:00
|
|
|
|
|
|
|
if (lat < 16)
|
|
|
|
lat = (64 <= pcibios_max_latency) ? 64 : pcibios_max_latency;
|
|
|
|
else if (lat > pcibios_max_latency)
|
|
|
|
lat = pcibios_max_latency;
|
2012-09-29 14:35:12 +00:00
|
|
|
pci_write_config_byte(dev, PCI_LATENCY_TIMER, lat);
|
Add driver for S-ATA-controller on Intel processors with South
Bridge, ICH-5, ICH-6 and ICH-7.
Implementation:
1. Code is divided in to two files. All functions, which are
controller specific are kept in "drivers/ata_piix.c" file and
functions, which are not controller specific, are kept in
"common/cmd_sata.c" file.
2. Reading and Writing from the S-ATA drive is done using PIO method.
3. Driver can be configured for 48-bit addressing by defining macro
CONFIG_LBA48, if this macro is not defined driver uses the 28-bit
addressing.
4. S-ATA read function is hooked to the File system, commands like
ext2ls and ext2load file can be used. This has been tested.
5. U-Boot command "SATA_init" is added, which initializes the S-ATA
controller and identifies the S-ATA drives connected to it.
6. U-Boot command "sata" is added, which is used to read/write, print
partition table and get info about the drives present. This I have
implemented in same way as "ide" command is implemented in U-Boot.
7. This driver is for S-ATA in native mode.
8. This driver does not support the Native command queuing and
Hot-plugging.
Signed-off-by: Mushtaq Khan <mushtaq_k@procsys.com>
2007-04-20 08:53:02 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2012-09-29 14:35:12 +00:00
|
|
|
int sata_bus_probe(int port_no)
|
Add driver for S-ATA-controller on Intel processors with South
Bridge, ICH-5, ICH-6 and ICH-7.
Implementation:
1. Code is divided in to two files. All functions, which are
controller specific are kept in "drivers/ata_piix.c" file and
functions, which are not controller specific, are kept in
"common/cmd_sata.c" file.
2. Reading and Writing from the S-ATA drive is done using PIO method.
3. Driver can be configured for 48-bit addressing by defining macro
CONFIG_LBA48, if this macro is not defined driver uses the 28-bit
addressing.
4. S-ATA read function is hooked to the File system, commands like
ext2ls and ext2load file can be used. This has been tested.
5. U-Boot command "SATA_init" is added, which initializes the S-ATA
controller and identifies the S-ATA drives connected to it.
6. U-Boot command "sata" is added, which is used to read/write, print
partition table and get info about the drives present. This I have
implemented in same way as "ide" command is implemented in U-Boot.
7. This driver is for S-ATA in native mode.
8. This driver does not support the Native command queuing and
Hot-plugging.
Signed-off-by: Mushtaq Khan <mushtaq_k@procsys.com>
2007-04-20 08:53:02 +00:00
|
|
|
{
|
|
|
|
int orig_mask, mask;
|
|
|
|
u16 pcs;
|
|
|
|
|
|
|
|
mask = (PORT_PRESENT << port_no);
|
2012-09-29 14:35:12 +00:00
|
|
|
pci_read_config_word(bdf, PCI_PCS, &pcs);
|
Add driver for S-ATA-controller on Intel processors with South
Bridge, ICH-5, ICH-6 and ICH-7.
Implementation:
1. Code is divided in to two files. All functions, which are
controller specific are kept in "drivers/ata_piix.c" file and
functions, which are not controller specific, are kept in
"common/cmd_sata.c" file.
2. Reading and Writing from the S-ATA drive is done using PIO method.
3. Driver can be configured for 48-bit addressing by defining macro
CONFIG_LBA48, if this macro is not defined driver uses the 28-bit
addressing.
4. S-ATA read function is hooked to the File system, commands like
ext2ls and ext2load file can be used. This has been tested.
5. U-Boot command "SATA_init" is added, which initializes the S-ATA
controller and identifies the S-ATA drives connected to it.
6. U-Boot command "sata" is added, which is used to read/write, print
partition table and get info about the drives present. This I have
implemented in same way as "ide" command is implemented in U-Boot.
7. This driver is for S-ATA in native mode.
8. This driver does not support the Native command queuing and
Hot-plugging.
Signed-off-by: Mushtaq Khan <mushtaq_k@procsys.com>
2007-04-20 08:53:02 +00:00
|
|
|
orig_mask = (int) pcs & 0xff;
|
|
|
|
if ((orig_mask & mask) != mask)
|
|
|
|
return 0;
|
|
|
|
else
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2012-09-29 14:35:12 +00:00
|
|
|
int init_sata(int dev)
|
Add driver for S-ATA-controller on Intel processors with South
Bridge, ICH-5, ICH-6 and ICH-7.
Implementation:
1. Code is divided in to two files. All functions, which are
controller specific are kept in "drivers/ata_piix.c" file and
functions, which are not controller specific, are kept in
"common/cmd_sata.c" file.
2. Reading and Writing from the S-ATA drive is done using PIO method.
3. Driver can be configured for 48-bit addressing by defining macro
CONFIG_LBA48, if this macro is not defined driver uses the 28-bit
addressing.
4. S-ATA read function is hooked to the File system, commands like
ext2ls and ext2load file can be used. This has been tested.
5. U-Boot command "SATA_init" is added, which initializes the S-ATA
controller and identifies the S-ATA drives connected to it.
6. U-Boot command "sata" is added, which is used to read/write, print
partition table and get info about the drives present. This I have
implemented in same way as "ide" command is implemented in U-Boot.
7. This driver is for S-ATA in native mode.
8. This driver does not support the Native command queuing and
Hot-plugging.
Signed-off-by: Mushtaq Khan <mushtaq_k@procsys.com>
2007-04-20 08:53:02 +00:00
|
|
|
{
|
2012-09-29 14:35:12 +00:00
|
|
|
static int done;
|
Add driver for S-ATA-controller on Intel processors with South
Bridge, ICH-5, ICH-6 and ICH-7.
Implementation:
1. Code is divided in to two files. All functions, which are
controller specific are kept in "drivers/ata_piix.c" file and
functions, which are not controller specific, are kept in
"common/cmd_sata.c" file.
2. Reading and Writing from the S-ATA drive is done using PIO method.
3. Driver can be configured for 48-bit addressing by defining macro
CONFIG_LBA48, if this macro is not defined driver uses the 28-bit
addressing.
4. S-ATA read function is hooked to the File system, commands like
ext2ls and ext2load file can be used. This has been tested.
5. U-Boot command "SATA_init" is added, which initializes the S-ATA
controller and identifies the S-ATA drives connected to it.
6. U-Boot command "sata" is added, which is used to read/write, print
partition table and get info about the drives present. This I have
implemented in same way as "ide" command is implemented in U-Boot.
7. This driver is for S-ATA in native mode.
8. This driver does not support the Native command queuing and
Hot-plugging.
Signed-off-by: Mushtaq Khan <mushtaq_k@procsys.com>
2007-04-20 08:53:02 +00:00
|
|
|
u8 i, rv = 0;
|
|
|
|
|
2008-03-26 14:50:45 +00:00
|
|
|
if (!done)
|
|
|
|
done = 1;
|
|
|
|
else
|
|
|
|
return 0;
|
Add driver for S-ATA-controller on Intel processors with South
Bridge, ICH-5, ICH-6 and ICH-7.
Implementation:
1. Code is divided in to two files. All functions, which are
controller specific are kept in "drivers/ata_piix.c" file and
functions, which are not controller specific, are kept in
"common/cmd_sata.c" file.
2. Reading and Writing from the S-ATA drive is done using PIO method.
3. Driver can be configured for 48-bit addressing by defining macro
CONFIG_LBA48, if this macro is not defined driver uses the 28-bit
addressing.
4. S-ATA read function is hooked to the File system, commands like
ext2ls and ext2load file can be used. This has been tested.
5. U-Boot command "SATA_init" is added, which initializes the S-ATA
controller and identifies the S-ATA drives connected to it.
6. U-Boot command "sata" is added, which is used to read/write, print
partition table and get info about the drives present. This I have
implemented in same way as "ide" command is implemented in U-Boot.
7. This driver is for S-ATA in native mode.
8. This driver does not support the Native command queuing and
Hot-plugging.
Signed-off-by: Mushtaq Khan <mushtaq_k@procsys.com>
2007-04-20 08:53:02 +00:00
|
|
|
|
2012-09-29 14:35:12 +00:00
|
|
|
rv = pci_sata_init();
|
Add driver for S-ATA-controller on Intel processors with South
Bridge, ICH-5, ICH-6 and ICH-7.
Implementation:
1. Code is divided in to two files. All functions, which are
controller specific are kept in "drivers/ata_piix.c" file and
functions, which are not controller specific, are kept in
"common/cmd_sata.c" file.
2. Reading and Writing from the S-ATA drive is done using PIO method.
3. Driver can be configured for 48-bit addressing by defining macro
CONFIG_LBA48, if this macro is not defined driver uses the 28-bit
addressing.
4. S-ATA read function is hooked to the File system, commands like
ext2ls and ext2load file can be used. This has been tested.
5. U-Boot command "SATA_init" is added, which initializes the S-ATA
controller and identifies the S-ATA drives connected to it.
6. U-Boot command "sata" is added, which is used to read/write, print
partition table and get info about the drives present. This I have
implemented in same way as "ide" command is implemented in U-Boot.
7. This driver is for S-ATA in native mode.
8. This driver does not support the Native command queuing and
Hot-plugging.
Signed-off-by: Mushtaq Khan <mushtaq_k@procsys.com>
2007-04-20 08:53:02 +00:00
|
|
|
if (rv == 1) {
|
2012-09-29 14:35:12 +00:00
|
|
|
puts("pci initialization failed\n");
|
Add driver for S-ATA-controller on Intel processors with South
Bridge, ICH-5, ICH-6 and ICH-7.
Implementation:
1. Code is divided in to two files. All functions, which are
controller specific are kept in "drivers/ata_piix.c" file and
functions, which are not controller specific, are kept in
"common/cmd_sata.c" file.
2. Reading and Writing from the S-ATA drive is done using PIO method.
3. Driver can be configured for 48-bit addressing by defining macro
CONFIG_LBA48, if this macro is not defined driver uses the 28-bit
addressing.
4. S-ATA read function is hooked to the File system, commands like
ext2ls and ext2load file can be used. This has been tested.
5. U-Boot command "SATA_init" is added, which initializes the S-ATA
controller and identifies the S-ATA drives connected to it.
6. U-Boot command "sata" is added, which is used to read/write, print
partition table and get info about the drives present. This I have
implemented in same way as "ide" command is implemented in U-Boot.
7. This driver is for S-ATA in native mode.
8. This driver does not support the Native command queuing and
Hot-plugging.
Signed-off-by: Mushtaq Khan <mushtaq_k@procsys.com>
2007-04-20 08:53:02 +00:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
port[0].port_no = 0;
|
|
|
|
port[0].ioaddr.cmd_addr = iobase1;
|
|
|
|
port[0].ioaddr.altstatus_addr = port[0].ioaddr.ctl_addr =
|
|
|
|
iobase2 | ATA_PCI_CTL_OFS;
|
|
|
|
port[0].ioaddr.bmdma_addr = iobase5;
|
|
|
|
|
|
|
|
port[1].port_no = 1;
|
|
|
|
port[1].ioaddr.cmd_addr = iobase3;
|
|
|
|
port[1].ioaddr.altstatus_addr = port[1].ioaddr.ctl_addr =
|
|
|
|
iobase4 | ATA_PCI_CTL_OFS;
|
|
|
|
port[1].ioaddr.bmdma_addr = iobase5 + 0x8;
|
|
|
|
|
2008-10-16 13:01:15 +00:00
|
|
|
for (i = 0; i < CONFIG_SYS_SATA_MAXBUS; i++)
|
2012-09-29 14:35:12 +00:00
|
|
|
sata_port(&port[i].ioaddr);
|
Add driver for S-ATA-controller on Intel processors with South
Bridge, ICH-5, ICH-6 and ICH-7.
Implementation:
1. Code is divided in to two files. All functions, which are
controller specific are kept in "drivers/ata_piix.c" file and
functions, which are not controller specific, are kept in
"common/cmd_sata.c" file.
2. Reading and Writing from the S-ATA drive is done using PIO method.
3. Driver can be configured for 48-bit addressing by defining macro
CONFIG_LBA48, if this macro is not defined driver uses the 28-bit
addressing.
4. S-ATA read function is hooked to the File system, commands like
ext2ls and ext2load file can be used. This has been tested.
5. U-Boot command "SATA_init" is added, which initializes the S-ATA
controller and identifies the S-ATA drives connected to it.
6. U-Boot command "sata" is added, which is used to read/write, print
partition table and get info about the drives present. This I have
implemented in same way as "ide" command is implemented in U-Boot.
7. This driver is for S-ATA in native mode.
8. This driver does not support the Native command queuing and
Hot-plugging.
Signed-off-by: Mushtaq Khan <mushtaq_k@procsys.com>
2007-04-20 08:53:02 +00:00
|
|
|
|
2008-10-16 13:01:15 +00:00
|
|
|
for (i = 0; i < CONFIG_SYS_SATA_MAXBUS; i++) {
|
2012-09-29 14:35:12 +00:00
|
|
|
if (!(sata_bus_probe(i))) {
|
Add driver for S-ATA-controller on Intel processors with South
Bridge, ICH-5, ICH-6 and ICH-7.
Implementation:
1. Code is divided in to two files. All functions, which are
controller specific are kept in "drivers/ata_piix.c" file and
functions, which are not controller specific, are kept in
"common/cmd_sata.c" file.
2. Reading and Writing from the S-ATA drive is done using PIO method.
3. Driver can be configured for 48-bit addressing by defining macro
CONFIG_LBA48, if this macro is not defined driver uses the 28-bit
addressing.
4. S-ATA read function is hooked to the File system, commands like
ext2ls and ext2load file can be used. This has been tested.
5. U-Boot command "SATA_init" is added, which initializes the S-ATA
controller and identifies the S-ATA drives connected to it.
6. U-Boot command "sata" is added, which is used to read/write, print
partition table and get info about the drives present. This I have
implemented in same way as "ide" command is implemented in U-Boot.
7. This driver is for S-ATA in native mode.
8. This driver does not support the Native command queuing and
Hot-plugging.
Signed-off-by: Mushtaq Khan <mushtaq_k@procsys.com>
2007-04-20 08:53:02 +00:00
|
|
|
port[i].port_state = 0;
|
2012-09-29 14:35:12 +00:00
|
|
|
printf("SATA#%d port is not present\n", i);
|
Add driver for S-ATA-controller on Intel processors with South
Bridge, ICH-5, ICH-6 and ICH-7.
Implementation:
1. Code is divided in to two files. All functions, which are
controller specific are kept in "drivers/ata_piix.c" file and
functions, which are not controller specific, are kept in
"common/cmd_sata.c" file.
2. Reading and Writing from the S-ATA drive is done using PIO method.
3. Driver can be configured for 48-bit addressing by defining macro
CONFIG_LBA48, if this macro is not defined driver uses the 28-bit
addressing.
4. S-ATA read function is hooked to the File system, commands like
ext2ls and ext2load file can be used. This has been tested.
5. U-Boot command "SATA_init" is added, which initializes the S-ATA
controller and identifies the S-ATA drives connected to it.
6. U-Boot command "sata" is added, which is used to read/write, print
partition table and get info about the drives present. This I have
implemented in same way as "ide" command is implemented in U-Boot.
7. This driver is for S-ATA in native mode.
8. This driver does not support the Native command queuing and
Hot-plugging.
Signed-off-by: Mushtaq Khan <mushtaq_k@procsys.com>
2007-04-20 08:53:02 +00:00
|
|
|
} else {
|
2012-09-29 14:35:12 +00:00
|
|
|
printf("SATA#%d port is present\n", i);
|
|
|
|
if (sata_bus_softreset(i))
|
Add driver for S-ATA-controller on Intel processors with South
Bridge, ICH-5, ICH-6 and ICH-7.
Implementation:
1. Code is divided in to two files. All functions, which are
controller specific are kept in "drivers/ata_piix.c" file and
functions, which are not controller specific, are kept in
"common/cmd_sata.c" file.
2. Reading and Writing from the S-ATA drive is done using PIO method.
3. Driver can be configured for 48-bit addressing by defining macro
CONFIG_LBA48, if this macro is not defined driver uses the 28-bit
addressing.
4. S-ATA read function is hooked to the File system, commands like
ext2ls and ext2load file can be used. This has been tested.
5. U-Boot command "SATA_init" is added, which initializes the S-ATA
controller and identifies the S-ATA drives connected to it.
6. U-Boot command "sata" is added, which is used to read/write, print
partition table and get info about the drives present. This I have
implemented in same way as "ide" command is implemented in U-Boot.
7. This driver is for S-ATA in native mode.
8. This driver does not support the Native command queuing and
Hot-plugging.
Signed-off-by: Mushtaq Khan <mushtaq_k@procsys.com>
2007-04-20 08:53:02 +00:00
|
|
|
port[i].port_state = 0;
|
2012-09-29 14:35:12 +00:00
|
|
|
else
|
Add driver for S-ATA-controller on Intel processors with South
Bridge, ICH-5, ICH-6 and ICH-7.
Implementation:
1. Code is divided in to two files. All functions, which are
controller specific are kept in "drivers/ata_piix.c" file and
functions, which are not controller specific, are kept in
"common/cmd_sata.c" file.
2. Reading and Writing from the S-ATA drive is done using PIO method.
3. Driver can be configured for 48-bit addressing by defining macro
CONFIG_LBA48, if this macro is not defined driver uses the 28-bit
addressing.
4. S-ATA read function is hooked to the File system, commands like
ext2ls and ext2load file can be used. This has been tested.
5. U-Boot command "SATA_init" is added, which initializes the S-ATA
controller and identifies the S-ATA drives connected to it.
6. U-Boot command "sata" is added, which is used to read/write, print
partition table and get info about the drives present. This I have
implemented in same way as "ide" command is implemented in U-Boot.
7. This driver is for S-ATA in native mode.
8. This driver does not support the Native command queuing and
Hot-plugging.
Signed-off-by: Mushtaq Khan <mushtaq_k@procsys.com>
2007-04-20 08:53:02 +00:00
|
|
|
port[i].port_state = 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-10-16 13:01:15 +00:00
|
|
|
for (i = 0; i < CONFIG_SYS_SATA_MAXBUS; i++) {
|
Add driver for S-ATA-controller on Intel processors with South
Bridge, ICH-5, ICH-6 and ICH-7.
Implementation:
1. Code is divided in to two files. All functions, which are
controller specific are kept in "drivers/ata_piix.c" file and
functions, which are not controller specific, are kept in
"common/cmd_sata.c" file.
2. Reading and Writing from the S-ATA drive is done using PIO method.
3. Driver can be configured for 48-bit addressing by defining macro
CONFIG_LBA48, if this macro is not defined driver uses the 28-bit
addressing.
4. S-ATA read function is hooked to the File system, commands like
ext2ls and ext2load file can be used. This has been tested.
5. U-Boot command "SATA_init" is added, which initializes the S-ATA
controller and identifies the S-ATA drives connected to it.
6. U-Boot command "sata" is added, which is used to read/write, print
partition table and get info about the drives present. This I have
implemented in same way as "ide" command is implemented in U-Boot.
7. This driver is for S-ATA in native mode.
8. This driver does not support the Native command queuing and
Hot-plugging.
Signed-off-by: Mushtaq Khan <mushtaq_k@procsys.com>
2007-04-20 08:53:02 +00:00
|
|
|
u8 j, devno;
|
|
|
|
|
|
|
|
if (port[i].port_state == 0)
|
|
|
|
continue;
|
2008-10-16 13:01:15 +00:00
|
|
|
for (j = 0; j < CONFIG_SYS_SATA_DEVS_PER_BUS; j++) {
|
2012-09-29 14:35:12 +00:00
|
|
|
sata_identify(i, j);
|
|
|
|
set_Feature_cmd(i, j);
|
2008-10-16 13:01:15 +00:00
|
|
|
devno = i * CONFIG_SYS_SATA_DEVS_PER_BUS + j;
|
Add driver for S-ATA-controller on Intel processors with South
Bridge, ICH-5, ICH-6 and ICH-7.
Implementation:
1. Code is divided in to two files. All functions, which are
controller specific are kept in "drivers/ata_piix.c" file and
functions, which are not controller specific, are kept in
"common/cmd_sata.c" file.
2. Reading and Writing from the S-ATA drive is done using PIO method.
3. Driver can be configured for 48-bit addressing by defining macro
CONFIG_LBA48, if this macro is not defined driver uses the 28-bit
addressing.
4. S-ATA read function is hooked to the File system, commands like
ext2ls and ext2load file can be used. This has been tested.
5. U-Boot command "SATA_init" is added, which initializes the S-ATA
controller and identifies the S-ATA drives connected to it.
6. U-Boot command "sata" is added, which is used to read/write, print
partition table and get info about the drives present. This I have
implemented in same way as "ide" command is implemented in U-Boot.
7. This driver is for S-ATA in native mode.
8. This driver does not support the Native command queuing and
Hot-plugging.
Signed-off-by: Mushtaq Khan <mushtaq_k@procsys.com>
2007-04-20 08:53:02 +00:00
|
|
|
if ((sata_dev_desc[devno].lba > 0) &&
|
|
|
|
(sata_dev_desc[devno].blksz > 0)) {
|
2012-09-29 14:35:12 +00:00
|
|
|
dev_print(&sata_dev_desc[devno]);
|
Add driver for S-ATA-controller on Intel processors with South
Bridge, ICH-5, ICH-6 and ICH-7.
Implementation:
1. Code is divided in to two files. All functions, which are
controller specific are kept in "drivers/ata_piix.c" file and
functions, which are not controller specific, are kept in
"common/cmd_sata.c" file.
2. Reading and Writing from the S-ATA drive is done using PIO method.
3. Driver can be configured for 48-bit addressing by defining macro
CONFIG_LBA48, if this macro is not defined driver uses the 28-bit
addressing.
4. S-ATA read function is hooked to the File system, commands like
ext2ls and ext2load file can be used. This has been tested.
5. U-Boot command "SATA_init" is added, which initializes the S-ATA
controller and identifies the S-ATA drives connected to it.
6. U-Boot command "sata" is added, which is used to read/write, print
partition table and get info about the drives present. This I have
implemented in same way as "ide" command is implemented in U-Boot.
7. This driver is for S-ATA in native mode.
8. This driver does not support the Native command queuing and
Hot-plugging.
Signed-off-by: Mushtaq Khan <mushtaq_k@procsys.com>
2007-04-20 08:53:02 +00:00
|
|
|
/* initialize partition type */
|
2012-09-29 14:35:12 +00:00
|
|
|
init_part(&sata_dev_desc[devno]);
|
Add driver for S-ATA-controller on Intel processors with South
Bridge, ICH-5, ICH-6 and ICH-7.
Implementation:
1. Code is divided in to two files. All functions, which are
controller specific are kept in "drivers/ata_piix.c" file and
functions, which are not controller specific, are kept in
"common/cmd_sata.c" file.
2. Reading and Writing from the S-ATA drive is done using PIO method.
3. Driver can be configured for 48-bit addressing by defining macro
CONFIG_LBA48, if this macro is not defined driver uses the 28-bit
addressing.
4. S-ATA read function is hooked to the File system, commands like
ext2ls and ext2load file can be used. This has been tested.
5. U-Boot command "SATA_init" is added, which initializes the S-ATA
controller and identifies the S-ATA drives connected to it.
6. U-Boot command "sata" is added, which is used to read/write, print
partition table and get info about the drives present. This I have
implemented in same way as "ide" command is implemented in U-Boot.
7. This driver is for S-ATA in native mode.
8. This driver does not support the Native command queuing and
Hot-plugging.
Signed-off-by: Mushtaq Khan <mushtaq_k@procsys.com>
2007-04-20 08:53:02 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
2008-03-26 14:47:06 +00:00
|
|
|
|
2014-11-21 10:47:23 +00:00
|
|
|
int reset_sata(int dev)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2012-09-29 14:35:12 +00:00
|
|
|
static inline u8 sata_inb(unsigned long ioaddr)
|
2008-03-26 14:47:06 +00:00
|
|
|
{
|
2012-09-29 14:35:12 +00:00
|
|
|
return inb(ioaddr);
|
2008-03-26 14:47:06 +00:00
|
|
|
}
|
|
|
|
|
2012-09-29 14:35:12 +00:00
|
|
|
static inline void sata_outb(unsigned char val, unsigned long ioaddr)
|
2008-03-26 14:47:06 +00:00
|
|
|
{
|
2012-09-29 14:35:12 +00:00
|
|
|
outb(val, ioaddr);
|
2008-03-26 14:47:06 +00:00
|
|
|
}
|
|
|
|
|
2012-09-29 14:35:12 +00:00
|
|
|
static void output_data(struct sata_ioports *ioaddr, ulong * sect_buf,
|
|
|
|
int words)
|
2008-03-26 14:47:06 +00:00
|
|
|
{
|
2012-09-29 14:35:12 +00:00
|
|
|
outsw(ioaddr->data_addr, sect_buf, words << 1);
|
2008-03-26 14:47:06 +00:00
|
|
|
}
|
|
|
|
|
2012-09-29 14:35:12 +00:00
|
|
|
static int input_data(struct sata_ioports *ioaddr, ulong * sect_buf, int words)
|
2008-03-26 14:47:06 +00:00
|
|
|
{
|
2012-09-29 14:35:12 +00:00
|
|
|
insw(ioaddr->data_addr, sect_buf, words << 1);
|
2008-03-26 14:47:06 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2012-09-29 14:35:12 +00:00
|
|
|
static void sata_cpy(unsigned char *dst, unsigned char *src, unsigned int len)
|
2008-03-26 14:47:06 +00:00
|
|
|
{
|
|
|
|
unsigned char *end, *last;
|
|
|
|
|
|
|
|
last = dst;
|
|
|
|
end = src + len - 1;
|
|
|
|
|
|
|
|
/* reserve space for '\0' */
|
|
|
|
if (len < 2)
|
|
|
|
goto OUT;
|
|
|
|
|
|
|
|
/* skip leading white space */
|
|
|
|
while ((*src) && (src < end) && (*src == ' '))
|
|
|
|
++src;
|
|
|
|
|
|
|
|
/* copy string, omitting trailing white space */
|
|
|
|
while ((*src) && (src < end)) {
|
|
|
|
*dst++ = *src;
|
|
|
|
if (*src++ != ' ')
|
|
|
|
last = dst;
|
|
|
|
}
|
2012-09-29 14:35:12 +00:00
|
|
|
OUT:
|
2008-03-26 14:47:06 +00:00
|
|
|
*last = '\0';
|
|
|
|
}
|
|
|
|
|
2012-09-29 14:35:12 +00:00
|
|
|
int sata_bus_softreset(int num)
|
2008-03-26 14:47:06 +00:00
|
|
|
{
|
|
|
|
u8 dev = 0, status = 0, i;
|
|
|
|
|
|
|
|
port[num].dev_mask = 0;
|
|
|
|
|
2008-10-16 13:01:15 +00:00
|
|
|
for (i = 0; i < CONFIG_SYS_SATA_DEVS_PER_BUS; i++) {
|
2012-09-29 14:35:12 +00:00
|
|
|
if (!(sata_devchk(&port[num].ioaddr, i))) {
|
|
|
|
debug("dev_chk failed for dev#%d\n", i);
|
2008-03-26 14:47:06 +00:00
|
|
|
} else {
|
|
|
|
port[num].dev_mask |= (1 << i);
|
2012-09-29 14:35:12 +00:00
|
|
|
debug("dev_chk passed for dev#%d\n", i);
|
2008-03-26 14:47:06 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!(port[num].dev_mask)) {
|
2012-09-29 14:35:12 +00:00
|
|
|
printf("no devices on port%d\n", num);
|
2008-03-26 14:47:06 +00:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2012-09-29 14:35:12 +00:00
|
|
|
dev_select(&port[num].ioaddr, dev);
|
2008-03-26 14:47:06 +00:00
|
|
|
|
2012-09-29 14:35:12 +00:00
|
|
|
port[num].ctl_reg = 0x08; /* Default value of control reg */
|
|
|
|
sata_outb(port[num].ctl_reg, port[num].ioaddr.ctl_addr);
|
|
|
|
udelay(10);
|
|
|
|
sata_outb(port[num].ctl_reg | ATA_SRST, port[num].ioaddr.ctl_addr);
|
|
|
|
udelay(10);
|
|
|
|
sata_outb(port[num].ctl_reg, port[num].ioaddr.ctl_addr);
|
2008-03-26 14:47:06 +00:00
|
|
|
|
2012-09-29 14:35:12 +00:00
|
|
|
/*
|
|
|
|
* spec mandates ">= 2ms" before checking status.
|
2008-03-26 14:47:06 +00:00
|
|
|
* 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
|
|
|
|
* checking status is fine, post SRST, we perform this magic
|
|
|
|
* delay here as well.
|
|
|
|
*/
|
2012-09-29 14:35:12 +00:00
|
|
|
mdelay(150);
|
|
|
|
status = sata_busy_wait(&port[num].ioaddr, ATA_BUSY, 300);
|
2008-03-26 14:47:06 +00:00
|
|
|
while ((status & ATA_BUSY)) {
|
2012-09-29 14:35:12 +00:00
|
|
|
mdelay(100);
|
|
|
|
status = sata_busy_wait(&port[num].ioaddr, ATA_BUSY, 3);
|
2008-03-26 14:47:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (status & ATA_BUSY)
|
2012-09-29 14:35:12 +00:00
|
|
|
printf("ata%u is slow to respond,plz be patient\n", num);
|
2008-03-26 14:47:06 +00:00
|
|
|
|
|
|
|
while ((status & ATA_BUSY)) {
|
2012-09-29 14:35:12 +00:00
|
|
|
mdelay(100);
|
|
|
|
status = sata_chk_status(&port[num].ioaddr);
|
2008-03-26 14:47:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (status & ATA_BUSY) {
|
2012-09-29 14:35:12 +00:00
|
|
|
printf("ata%u failed to respond : bus reset failed\n", num);
|
2008-03-26 14:47:06 +00:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2012-09-29 14:35:12 +00:00
|
|
|
void sata_identify(int num, int dev)
|
2008-03-26 14:47:06 +00:00
|
|
|
{
|
2012-09-29 14:35:12 +00:00
|
|
|
u8 cmd = 0, status = 0;
|
|
|
|
u8 devno = num * CONFIG_SYS_SATA_DEVS_PER_BUS + dev;
|
2008-03-26 14:47:06 +00:00
|
|
|
u16 iobuf[ATA_SECT_SIZE];
|
|
|
|
u64 n_sectors = 0;
|
|
|
|
u8 mask = 0;
|
|
|
|
|
2012-09-29 14:35:12 +00:00
|
|
|
memset(iobuf, 0, sizeof(iobuf));
|
2008-03-26 14:47:06 +00:00
|
|
|
hd_driveid_t *iop = (hd_driveid_t *) iobuf;
|
|
|
|
|
|
|
|
if (dev == 0)
|
|
|
|
mask = 0x01;
|
|
|
|
else
|
|
|
|
mask = 0x02;
|
|
|
|
|
|
|
|
if (!(port[num].dev_mask & mask)) {
|
2012-09-29 14:35:12 +00:00
|
|
|
printf("dev%d is not present on port#%d\n", dev, num);
|
2008-03-26 14:47:06 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2012-09-29 14:35:12 +00:00
|
|
|
printf("port=%d dev=%d\n", num, dev);
|
2008-03-26 14:47:06 +00:00
|
|
|
|
2012-09-29 14:35:12 +00:00
|
|
|
dev_select(&port[num].ioaddr, dev);
|
2008-03-26 14:47:06 +00:00
|
|
|
|
|
|
|
status = 0;
|
2012-09-29 14:35:12 +00:00
|
|
|
cmd = ATA_CMD_IDENT; /* Device Identify Command */
|
|
|
|
sata_outb(cmd, port[num].ioaddr.command_addr);
|
|
|
|
sata_inb(port[num].ioaddr.altstatus_addr);
|
|
|
|
udelay(10);
|
2008-03-26 14:47:06 +00:00
|
|
|
|
2012-09-29 14:35:12 +00:00
|
|
|
status = sata_busy_wait(&port[num].ioaddr, ATA_BUSY, 1000);
|
2008-03-26 14:47:06 +00:00
|
|
|
if (status & ATA_ERR) {
|
2012-09-29 14:35:12 +00:00
|
|
|
puts("\ndevice not responding\n");
|
2008-03-26 14:47:06 +00:00
|
|
|
port[num].dev_mask &= ~mask;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2012-09-29 14:35:12 +00:00
|
|
|
input_data(&port[num].ioaddr, (ulong *) iobuf, ATA_SECTORWORDS);
|
2008-03-26 14:47:06 +00:00
|
|
|
|
2012-09-29 14:35:12 +00:00
|
|
|
debug("\nata%u: dev %u cfg 49:%04x 82:%04x 83:%04x 84:%04x85:%04x"
|
2008-03-26 14:47:06 +00:00
|
|
|
"86:%04x" "87:%04x 88:%04x\n", num, dev, iobuf[49],
|
|
|
|
iobuf[82], iobuf[83], iobuf[84], iobuf[85], iobuf[86],
|
|
|
|
iobuf[87], iobuf[88]);
|
|
|
|
|
|
|
|
/* we require LBA and DMA support (bits 8 & 9 of word 49) */
|
2012-09-29 14:35:12 +00:00
|
|
|
if (!ata_id_has_dma(iobuf) || !ata_id_has_lba(iobuf))
|
|
|
|
debug("ata%u: no dma/lba\n", num);
|
|
|
|
ata_dump_id(iobuf);
|
2008-03-26 14:47:06 +00:00
|
|
|
|
2012-09-29 14:35:12 +00:00
|
|
|
if (ata_id_has_lba48(iobuf))
|
|
|
|
n_sectors = ata_id_u64(iobuf, 100);
|
|
|
|
else
|
|
|
|
n_sectors = ata_id_u32(iobuf, 60);
|
|
|
|
debug("no. of sectors %u\n", ata_id_u64(iobuf, 100));
|
|
|
|
debug("no. of sectors %u\n", ata_id_u32(iobuf, 60));
|
2008-03-26 14:47:06 +00:00
|
|
|
|
|
|
|
if (n_sectors == 0) {
|
|
|
|
port[num].dev_mask &= ~mask;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2012-09-29 14:35:12 +00:00
|
|
|
sata_cpy((unsigned char *)sata_dev_desc[devno].revision, iop->fw_rev,
|
|
|
|
sizeof(sata_dev_desc[devno].revision));
|
|
|
|
sata_cpy((unsigned char *)sata_dev_desc[devno].vendor, iop->model,
|
|
|
|
sizeof(sata_dev_desc[devno].vendor));
|
|
|
|
sata_cpy((unsigned char *)sata_dev_desc[devno].product, iop->serial_no,
|
|
|
|
sizeof(sata_dev_desc[devno].product));
|
|
|
|
strswab(sata_dev_desc[devno].revision);
|
|
|
|
strswab(sata_dev_desc[devno].vendor);
|
2008-03-26 14:47:06 +00:00
|
|
|
|
2012-09-29 14:35:12 +00:00
|
|
|
if ((iop->config & 0x0080) == 0x0080)
|
2008-03-26 14:47:06 +00:00
|
|
|
sata_dev_desc[devno].removable = 1;
|
2012-09-29 14:35:12 +00:00
|
|
|
else
|
2008-03-26 14:47:06 +00:00
|
|
|
sata_dev_desc[devno].removable = 0;
|
|
|
|
|
|
|
|
sata_dev_desc[devno].lba = iop->lba_capacity;
|
2012-09-29 14:35:12 +00:00
|
|
|
debug("lba=0x%x", sata_dev_desc[devno].lba);
|
2008-03-26 14:47:06 +00:00
|
|
|
|
|
|
|
#ifdef CONFIG_LBA48
|
|
|
|
if (iop->command_set_2 & 0x0400) {
|
|
|
|
sata_dev_desc[devno].lba48 = 1;
|
|
|
|
lba = (unsigned long long) iop->lba48_capacity[0] |
|
|
|
|
((unsigned long long) iop->lba48_capacity[1] << 16) |
|
|
|
|
((unsigned long long) iop->lba48_capacity[2] << 32) |
|
|
|
|
((unsigned long long) iop->lba48_capacity[3] << 48);
|
|
|
|
} else {
|
|
|
|
sata_dev_desc[devno].lba48 = 0;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* assuming HD */
|
|
|
|
sata_dev_desc[devno].type = DEV_TYPE_HARDDISK;
|
|
|
|
sata_dev_desc[devno].blksz = ATA_BLOCKSIZE;
|
2013-04-09 21:11:56 +00:00
|
|
|
sata_dev_desc[devno].log2blksz = LOG2(sata_dev_desc[devno].blksz);
|
2008-03-26 14:47:06 +00:00
|
|
|
sata_dev_desc[devno].lun = 0; /* just to fill something in... */
|
|
|
|
}
|
|
|
|
|
2012-09-29 14:35:12 +00:00
|
|
|
void set_Feature_cmd(int num, int dev)
|
2008-03-26 14:47:06 +00:00
|
|
|
{
|
|
|
|
u8 mask = 0x00, status = 0;
|
|
|
|
|
|
|
|
if (dev == 0)
|
|
|
|
mask = 0x01;
|
|
|
|
else
|
|
|
|
mask = 0x02;
|
|
|
|
|
|
|
|
if (!(port[num].dev_mask & mask)) {
|
2012-09-29 14:35:12 +00:00
|
|
|
debug("dev%d is not present on port#%d\n", dev, num);
|
2008-03-26 14:47:06 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2012-09-29 14:35:12 +00:00
|
|
|
dev_select(&port[num].ioaddr, dev);
|
2008-03-26 14:47:06 +00:00
|
|
|
|
2012-09-29 14:35:12 +00:00
|
|
|
sata_outb(SETFEATURES_XFER, port[num].ioaddr.feature_addr);
|
|
|
|
sata_outb(XFER_PIO_4, port[num].ioaddr.nsect_addr);
|
|
|
|
sata_outb(0, port[num].ioaddr.lbal_addr);
|
|
|
|
sata_outb(0, port[num].ioaddr.lbam_addr);
|
|
|
|
sata_outb(0, port[num].ioaddr.lbah_addr);
|
2008-03-26 14:47:06 +00:00
|
|
|
|
2012-09-29 14:35:12 +00:00
|
|
|
sata_outb(ATA_DEVICE_OBS, port[num].ioaddr.device_addr);
|
|
|
|
sata_outb(ATA_CMD_SETF, port[num].ioaddr.command_addr);
|
2008-03-26 14:47:06 +00:00
|
|
|
|
2012-09-29 14:35:12 +00:00
|
|
|
udelay(50);
|
|
|
|
mdelay(150);
|
2008-03-26 14:47:06 +00:00
|
|
|
|
2012-09-29 14:35:12 +00:00
|
|
|
status = sata_busy_wait(&port[num].ioaddr, ATA_BUSY, 5000);
|
2008-03-26 14:47:06 +00:00
|
|
|
if ((status & (ATA_STAT_BUSY | ATA_STAT_ERR))) {
|
2012-09-29 14:35:12 +00:00
|
|
|
printf("Error : status 0x%02x\n", status);
|
2008-03-26 14:47:06 +00:00
|
|
|
port[num].dev_mask &= ~mask;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-09-29 14:35:12 +00:00
|
|
|
void sata_port(struct sata_ioports *ioport)
|
2008-03-26 14:47:06 +00:00
|
|
|
{
|
|
|
|
ioport->data_addr = ioport->cmd_addr + ATA_REG_DATA;
|
|
|
|
ioport->error_addr = ioport->cmd_addr + ATA_REG_ERR;
|
|
|
|
ioport->feature_addr = ioport->cmd_addr + ATA_REG_FEATURE;
|
|
|
|
ioport->nsect_addr = ioport->cmd_addr + ATA_REG_NSECT;
|
|
|
|
ioport->lbal_addr = ioport->cmd_addr + ATA_REG_LBAL;
|
|
|
|
ioport->lbam_addr = ioport->cmd_addr + ATA_REG_LBAM;
|
|
|
|
ioport->lbah_addr = ioport->cmd_addr + ATA_REG_LBAH;
|
|
|
|
ioport->device_addr = ioport->cmd_addr + ATA_REG_DEVICE;
|
|
|
|
ioport->status_addr = ioport->cmd_addr + ATA_REG_STATUS;
|
|
|
|
ioport->command_addr = ioport->cmd_addr + ATA_REG_CMD;
|
|
|
|
}
|
|
|
|
|
2012-09-29 14:35:12 +00:00
|
|
|
int sata_devchk(struct sata_ioports *ioaddr, int dev)
|
2008-03-26 14:47:06 +00:00
|
|
|
{
|
|
|
|
u8 nsect, lbal;
|
|
|
|
|
2012-09-29 14:35:12 +00:00
|
|
|
dev_select(ioaddr, dev);
|
2008-03-26 14:47:06 +00:00
|
|
|
|
2012-09-29 14:35:12 +00:00
|
|
|
sata_outb(0x55, ioaddr->nsect_addr);
|
|
|
|
sata_outb(0xaa, ioaddr->lbal_addr);
|
2008-03-26 14:47:06 +00:00
|
|
|
|
2012-09-29 14:35:12 +00:00
|
|
|
sata_outb(0xaa, ioaddr->nsect_addr);
|
|
|
|
sata_outb(0x55, ioaddr->lbal_addr);
|
2008-03-26 14:47:06 +00:00
|
|
|
|
2012-09-29 14:35:12 +00:00
|
|
|
sata_outb(0x55, ioaddr->nsect_addr);
|
|
|
|
sata_outb(0xaa, ioaddr->lbal_addr);
|
2008-03-26 14:47:06 +00:00
|
|
|
|
2012-09-29 14:35:12 +00:00
|
|
|
nsect = sata_inb(ioaddr->nsect_addr);
|
|
|
|
lbal = sata_inb(ioaddr->lbal_addr);
|
2008-03-26 14:47:06 +00:00
|
|
|
|
|
|
|
if ((nsect == 0x55) && (lbal == 0xaa))
|
|
|
|
return 1; /* we found a device */
|
|
|
|
else
|
|
|
|
return 0; /* nothing found */
|
|
|
|
}
|
|
|
|
|
2012-09-29 14:35:12 +00:00
|
|
|
void dev_select(struct sata_ioports *ioaddr, int dev)
|
2008-03-26 14:47:06 +00:00
|
|
|
{
|
|
|
|
u8 tmp = 0;
|
|
|
|
|
|
|
|
if (dev == 0)
|
|
|
|
tmp = ATA_DEVICE_OBS;
|
|
|
|
else
|
|
|
|
tmp = ATA_DEVICE_OBS | ATA_DEV1;
|
|
|
|
|
2012-09-29 14:35:12 +00:00
|
|
|
sata_outb(tmp, ioaddr->device_addr);
|
|
|
|
sata_inb(ioaddr->altstatus_addr);
|
|
|
|
udelay(5);
|
2008-03-26 14:47:06 +00:00
|
|
|
}
|
|
|
|
|
2012-09-29 14:35:12 +00:00
|
|
|
u8 sata_busy_wait(struct sata_ioports *ioaddr, int bits, unsigned int max)
|
2008-03-26 14:47:06 +00:00
|
|
|
{
|
|
|
|
u8 status;
|
|
|
|
|
|
|
|
do {
|
2012-09-29 14:35:12 +00:00
|
|
|
udelay(1000);
|
|
|
|
status = sata_chk_status(ioaddr);
|
2008-03-26 14:47:06 +00:00
|
|
|
max--;
|
|
|
|
} while ((status & bits) && (max > 0));
|
|
|
|
|
|
|
|
return status;
|
|
|
|
}
|
|
|
|
|
2012-09-29 14:35:12 +00:00
|
|
|
u8 sata_chk_status(struct sata_ioports *ioaddr)
|
2008-03-26 14:47:06 +00:00
|
|
|
{
|
2012-09-29 14:35:12 +00:00
|
|
|
return sata_inb(ioaddr->status_addr);
|
2008-03-26 14:47:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-09-29 14:35:12 +00:00
|
|
|
ulong sata_read(int device, ulong blknr, lbaint_t blkcnt, void *buff)
|
2008-03-26 14:47:06 +00:00
|
|
|
{
|
|
|
|
ulong n = 0, *buffer = (ulong *)buff;
|
|
|
|
u8 dev = 0, num = 0, mask = 0, status = 0;
|
|
|
|
|
|
|
|
#ifdef CONFIG_LBA48
|
|
|
|
unsigned char lba48 = 0;
|
|
|
|
|
|
|
|
if (blknr & 0x0000fffff0000000) {
|
|
|
|
if (!sata_dev_desc[devno].lba48) {
|
2012-09-29 14:35:12 +00:00
|
|
|
printf("Drive doesn't support 48-bit addressing\n");
|
2008-03-26 14:47:06 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
/* more than 28 bits used, use 48bit mode */
|
|
|
|
lba48 = 1;
|
|
|
|
}
|
|
|
|
#endif
|
2012-09-29 14:35:12 +00:00
|
|
|
/* Port Number */
|
2008-10-16 13:01:15 +00:00
|
|
|
num = device / CONFIG_SYS_SATA_DEVS_PER_BUS;
|
2012-09-29 14:35:12 +00:00
|
|
|
/* dev on the port */
|
2008-10-16 13:01:15 +00:00
|
|
|
if (device >= CONFIG_SYS_SATA_DEVS_PER_BUS)
|
|
|
|
dev = device - CONFIG_SYS_SATA_DEVS_PER_BUS;
|
2008-03-26 14:47:06 +00:00
|
|
|
else
|
|
|
|
dev = device;
|
|
|
|
|
|
|
|
if (dev == 0)
|
|
|
|
mask = 0x01;
|
|
|
|
else
|
|
|
|
mask = 0x02;
|
|
|
|
|
|
|
|
if (!(port[num].dev_mask & mask)) {
|
2012-09-29 14:35:12 +00:00
|
|
|
printf("dev%d is not present on port#%d\n", dev, num);
|
2008-03-26 14:47:06 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Select device */
|
2012-09-29 14:35:12 +00:00
|
|
|
dev_select(&port[num].ioaddr, dev);
|
2008-03-26 14:47:06 +00:00
|
|
|
|
2012-09-29 14:35:12 +00:00
|
|
|
status = sata_busy_wait(&port[num].ioaddr, ATA_BUSY, 500);
|
2008-03-26 14:47:06 +00:00
|
|
|
if (status & ATA_BUSY) {
|
2012-09-29 14:35:12 +00:00
|
|
|
printf("ata%u failed to respond\n", port[num].port_no);
|
2008-03-26 14:47:06 +00:00
|
|
|
return n;
|
|
|
|
}
|
|
|
|
while (blkcnt-- > 0) {
|
2012-09-29 14:35:12 +00:00
|
|
|
status = sata_busy_wait(&port[num].ioaddr, ATA_BUSY, 500);
|
2008-03-26 14:47:06 +00:00
|
|
|
if (status & ATA_BUSY) {
|
2012-09-29 14:35:12 +00:00
|
|
|
printf("ata%u failed to respond\n", 0);
|
2008-03-26 14:47:06 +00:00
|
|
|
return n;
|
|
|
|
}
|
|
|
|
#ifdef CONFIG_LBA48
|
|
|
|
if (lba48) {
|
|
|
|
/* write high bits */
|
2012-09-29 14:35:12 +00:00
|
|
|
sata_outb(0, port[num].ioaddr.nsect_addr);
|
|
|
|
sata_outb((blknr >> 24) & 0xFF,
|
2008-03-26 14:47:06 +00:00
|
|
|
port[num].ioaddr.lbal_addr);
|
2012-09-29 14:35:12 +00:00
|
|
|
sata_outb((blknr >> 32) & 0xFF,
|
2008-03-26 14:47:06 +00:00
|
|
|
port[num].ioaddr.lbam_addr);
|
2012-09-29 14:35:12 +00:00
|
|
|
sata_outb((blknr >> 40) & 0xFF,
|
2008-03-26 14:47:06 +00:00
|
|
|
port[num].ioaddr.lbah_addr);
|
|
|
|
}
|
|
|
|
#endif
|
2012-09-29 14:35:12 +00:00
|
|
|
sata_outb(1, port[num].ioaddr.nsect_addr);
|
|
|
|
sata_outb(((blknr) >> 0) & 0xFF,
|
2008-03-26 14:47:06 +00:00
|
|
|
port[num].ioaddr.lbal_addr);
|
2012-09-29 14:35:12 +00:00
|
|
|
sata_outb((blknr >> 8) & 0xFF, port[num].ioaddr.lbam_addr);
|
|
|
|
sata_outb((blknr >> 16) & 0xFF, port[num].ioaddr.lbah_addr);
|
2008-03-26 14:47:06 +00:00
|
|
|
|
|
|
|
#ifdef CONFIG_LBA48
|
|
|
|
if (lba48) {
|
2012-09-29 14:35:12 +00:00
|
|
|
sata_outb(ATA_LBA, port[num].ioaddr.device_addr);
|
|
|
|
sata_outb(ATA_CMD_READ_EXT,
|
2008-03-26 14:47:06 +00:00
|
|
|
port[num].ioaddr.command_addr);
|
|
|
|
} else
|
|
|
|
#endif
|
|
|
|
{
|
2012-09-29 14:35:12 +00:00
|
|
|
sata_outb(ATA_LBA | ((blknr >> 24) & 0xF),
|
2008-03-26 14:47:06 +00:00
|
|
|
port[num].ioaddr.device_addr);
|
2012-09-29 14:35:12 +00:00
|
|
|
sata_outb(ATA_CMD_READ,
|
2008-03-26 14:47:06 +00:00
|
|
|
port[num].ioaddr.command_addr);
|
|
|
|
}
|
|
|
|
|
2012-09-29 14:35:12 +00:00
|
|
|
mdelay(50);
|
|
|
|
/* may take up to 4 sec */
|
|
|
|
status = sata_busy_wait(&port[num].ioaddr, ATA_BUSY, 4000);
|
2008-03-26 14:47:06 +00:00
|
|
|
|
|
|
|
if ((status & (ATA_STAT_DRQ | ATA_STAT_BUSY | ATA_STAT_ERR))
|
|
|
|
!= ATA_STAT_DRQ) {
|
|
|
|
u8 err = 0;
|
|
|
|
|
2012-09-29 14:35:12 +00:00
|
|
|
printf("Error no DRQ dev %d blk %ld: sts 0x%02x\n",
|
2008-03-26 14:47:06 +00:00
|
|
|
device, (ulong) blknr, status);
|
2012-09-29 14:35:12 +00:00
|
|
|
err = sata_inb(port[num].ioaddr.error_addr);
|
|
|
|
printf("Error reg = 0x%x\n", err);
|
|
|
|
return n;
|
2008-03-26 14:47:06 +00:00
|
|
|
}
|
2012-09-29 14:35:12 +00:00
|
|
|
input_data(&port[num].ioaddr, buffer, ATA_SECTORWORDS);
|
|
|
|
sata_inb(port[num].ioaddr.altstatus_addr);
|
|
|
|
udelay(50);
|
2008-03-26 14:47:06 +00:00
|
|
|
|
|
|
|
++n;
|
|
|
|
++blknr;
|
|
|
|
buffer += ATA_SECTORWORDS;
|
|
|
|
}
|
|
|
|
return n;
|
|
|
|
}
|
|
|
|
|
2012-09-29 14:52:48 +00:00
|
|
|
ulong sata_write(int device, ulong blknr, lbaint_t blkcnt, const void *buff)
|
2008-03-26 14:47:06 +00:00
|
|
|
{
|
|
|
|
ulong n = 0, *buffer = (ulong *)buff;
|
|
|
|
unsigned char status = 0, num = 0, dev = 0, mask = 0;
|
|
|
|
|
|
|
|
#ifdef CONFIG_LBA48
|
|
|
|
unsigned char lba48 = 0;
|
|
|
|
|
|
|
|
if (blknr & 0x0000fffff0000000) {
|
|
|
|
if (!sata_dev_desc[devno].lba48) {
|
2012-09-29 14:35:12 +00:00
|
|
|
printf("Drive doesn't support 48-bit addressing\n");
|
2008-03-26 14:47:06 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
/* more than 28 bits used, use 48bit mode */
|
|
|
|
lba48 = 1;
|
|
|
|
}
|
|
|
|
#endif
|
2012-09-29 14:35:12 +00:00
|
|
|
/* Port Number */
|
2008-10-16 13:01:15 +00:00
|
|
|
num = device / CONFIG_SYS_SATA_DEVS_PER_BUS;
|
2012-09-29 14:35:12 +00:00
|
|
|
/* dev on the Port */
|
2008-10-16 13:01:15 +00:00
|
|
|
if (device >= CONFIG_SYS_SATA_DEVS_PER_BUS)
|
|
|
|
dev = device - CONFIG_SYS_SATA_DEVS_PER_BUS;
|
2008-03-26 14:47:06 +00:00
|
|
|
else
|
|
|
|
dev = device;
|
|
|
|
|
|
|
|
if (dev == 0)
|
|
|
|
mask = 0x01;
|
|
|
|
else
|
|
|
|
mask = 0x02;
|
|
|
|
|
|
|
|
/* Select device */
|
2012-09-29 14:35:12 +00:00
|
|
|
dev_select(&port[num].ioaddr, dev);
|
2008-03-26 14:47:06 +00:00
|
|
|
|
2012-09-29 14:35:12 +00:00
|
|
|
status = sata_busy_wait(&port[num].ioaddr, ATA_BUSY, 500);
|
2008-03-26 14:47:06 +00:00
|
|
|
if (status & ATA_BUSY) {
|
2012-09-29 14:35:12 +00:00
|
|
|
printf("ata%u failed to respond\n", port[num].port_no);
|
2008-03-26 14:47:06 +00:00
|
|
|
return n;
|
|
|
|
}
|
|
|
|
|
|
|
|
while (blkcnt-- > 0) {
|
2012-09-29 14:35:12 +00:00
|
|
|
status = sata_busy_wait(&port[num].ioaddr, ATA_BUSY, 500);
|
2008-03-26 14:47:06 +00:00
|
|
|
if (status & ATA_BUSY) {
|
2012-09-29 14:35:12 +00:00
|
|
|
printf("ata%u failed to respond\n",
|
2008-03-26 14:47:06 +00:00
|
|
|
port[num].port_no);
|
|
|
|
return n;
|
|
|
|
}
|
|
|
|
#ifdef CONFIG_LBA48
|
|
|
|
if (lba48) {
|
|
|
|
/* write high bits */
|
2012-09-29 14:35:12 +00:00
|
|
|
sata_outb(0, port[num].ioaddr.nsect_addr);
|
|
|
|
sata_outb((blknr >> 24) & 0xFF,
|
2008-03-26 14:47:06 +00:00
|
|
|
port[num].ioaddr.lbal_addr);
|
2012-09-29 14:35:12 +00:00
|
|
|
sata_outb((blknr >> 32) & 0xFF,
|
2008-03-26 14:47:06 +00:00
|
|
|
port[num].ioaddr.lbam_addr);
|
2012-09-29 14:35:12 +00:00
|
|
|
sata_outb((blknr >> 40) & 0xFF,
|
2008-03-26 14:47:06 +00:00
|
|
|
port[num].ioaddr.lbah_addr);
|
|
|
|
}
|
|
|
|
#endif
|
2012-09-29 14:35:12 +00:00
|
|
|
sata_outb(1, port[num].ioaddr.nsect_addr);
|
|
|
|
sata_outb((blknr >> 0) & 0xFF, port[num].ioaddr.lbal_addr);
|
|
|
|
sata_outb((blknr >> 8) & 0xFF, port[num].ioaddr.lbam_addr);
|
|
|
|
sata_outb((blknr >> 16) & 0xFF, port[num].ioaddr.lbah_addr);
|
2008-03-26 14:47:06 +00:00
|
|
|
#ifdef CONFIG_LBA48
|
|
|
|
if (lba48) {
|
2012-09-29 14:35:12 +00:00
|
|
|
sata_outb(ATA_LBA, port[num].ioaddr.device_addr);
|
|
|
|
sata_outb(ATA_CMD_WRITE_EXT,
|
2008-03-26 14:47:06 +00:00
|
|
|
port[num].ioaddr.command_addr);
|
|
|
|
} else
|
|
|
|
#endif
|
|
|
|
{
|
2012-09-29 14:35:12 +00:00
|
|
|
sata_outb(ATA_LBA | ((blknr >> 24) & 0xF),
|
2008-03-26 14:47:06 +00:00
|
|
|
port[num].ioaddr.device_addr);
|
2012-09-29 14:35:12 +00:00
|
|
|
sata_outb(ATA_CMD_WRITE,
|
2008-03-26 14:47:06 +00:00
|
|
|
port[num].ioaddr.command_addr);
|
|
|
|
}
|
|
|
|
|
2012-09-29 14:35:12 +00:00
|
|
|
mdelay(50);
|
|
|
|
/* may take up to 4 sec */
|
|
|
|
status = sata_busy_wait(&port[num].ioaddr, ATA_BUSY, 4000);
|
2008-03-26 14:47:06 +00:00
|
|
|
if ((status & (ATA_STAT_DRQ | ATA_STAT_BUSY | ATA_STAT_ERR))
|
|
|
|
!= ATA_STAT_DRQ) {
|
2012-09-29 14:35:12 +00:00
|
|
|
printf("Error no DRQ dev %d blk %ld: sts 0x%02x\n",
|
2008-03-26 14:47:06 +00:00
|
|
|
device, (ulong) blknr, status);
|
2012-09-29 14:35:12 +00:00
|
|
|
return n;
|
2008-03-26 14:47:06 +00:00
|
|
|
}
|
|
|
|
|
2012-09-29 14:35:12 +00:00
|
|
|
output_data(&port[num].ioaddr, buffer, ATA_SECTORWORDS);
|
|
|
|
sata_inb(port[num].ioaddr.altstatus_addr);
|
|
|
|
udelay(50);
|
2008-03-26 14:47:06 +00:00
|
|
|
|
|
|
|
++n;
|
|
|
|
++blknr;
|
|
|
|
buffer += ATA_SECTORWORDS;
|
|
|
|
}
|
|
|
|
return n;
|
|
|
|
}
|
|
|
|
|
2008-03-26 14:50:45 +00:00
|
|
|
int scan_sata(int dev)
|
2008-03-26 14:47:06 +00:00
|
|
|
{
|
2008-03-26 14:50:45 +00:00
|
|
|
return 0;
|
2008-03-26 14:47:06 +00:00
|
|
|
}
|