IDE fixes for PPC (Laurent Vivier)

git-svn-id: svn://coreboot.org/openbios/openbios-devel@292 f158a5a8-5612-0410-a976-696ce0be7e32
This commit is contained in:
Blue Swirl
2008-12-20 14:48:40 +00:00
parent 5766c8fb3a
commit edafcf6e86
18 changed files with 388 additions and 72 deletions

View File

@@ -17,7 +17,6 @@
#include "relocate.h"
void boot(void);
void ob_ide_init(void);
static char intdict[256 * 1024];
@@ -42,7 +41,7 @@ arch_init( void )
modules_init();
#ifdef CONFIG_DRIVER_IDE
setup_timers();
ob_ide_init();
ob_ide_init("/pci/pci-ata", 0x1f0, 0x3f4, 0x170, 0x374);
#endif
device_end();
bind_func("platform-boot", boot );

View File

@@ -27,7 +27,6 @@
#include "openbios-version.h"
extern void unexpected_excep( int vector );
extern void ob_ide_init( void );
extern void setup_timers( void );
#if 0
@@ -91,15 +90,11 @@ arch_of_init( void )
devtree_init();
node_methods_init();
nvram_init("/pci/mac-io/nvram");
modules_init();
setup_timers();
#ifdef CONFIG_DRIVER_PCI
ob_pci_init();
#endif
#ifdef CONFIG_DRIVER_IDE
setup_timers();
ob_ide_init();
#endif
#if USE_RTAS
if( !(ph=find_dev("/rtas")) )

View File

@@ -81,6 +81,65 @@ finish-device
h# FF500000 encode-int h# 100000 encode-int encode+ " reg" property
0 encode-int 0 encode-int encode+ " bus-range" property
new-device
" isa" device-name
" isa" device-type
2 encode-int " #address-cells" property
1 encode-int " #size-cells" property
external
: open true ;
: close ;
finish-device
: ?devalias ( alias-str alias-len device-str device-len --
\ alias-str alias-len false | true )
active-package >r
" /aliases" find-device
\ 2dup ." Checking " type
2dup find-dev if \ check if device exists
drop
2over find-dev if \ do we already have an alias?
\ ." alias exists" cr
drop 2drop false
else
\ ." device exists" cr
encode-string
2swap property
true
then
else
\ ." device doesn't exist" cr
2drop false
then
r> active-package!
;
:noname
" hd"
" /pci/pci-ata/ata-1/disk@0" ?devalias not if
" /pci/pci-ata/ata-1/disk@1" ?devalias not if
" /pci/pci-ata/ata-2/disk@0" ?devalias not if
" /pci/pci-ata/ata-2/disk@1" ?devalias not if
2drop ." No disk found." cr
then
then
then
then
" cdrom"
" /pci/pci-ata/ata-1/cdrom@0" ?devalias not if
" /pci/pci-ata/ata-1/cdrom@1" ?devalias not if
" /pci/pci-ata/ata-2/cdrom@0" ?devalias not if
" /pci/pci-ata/ata-2/cdrom@1" ?devalias not if
2drop ." No cdrom found" cr
then
then
then
then
; SYSTEM-initializer
new-device
" ide" device-name
" ide" device-type

View File

@@ -28,7 +28,6 @@
#include "openbios-version.h"
extern void unexpected_excep( int vector );
extern void ob_ide_init( void );
extern void ob_pci_init( void );
extern void ob_adb_init( void );
extern void setup_timers( void );
@@ -95,17 +94,10 @@ arch_of_init( void )
devtree_init();
nvram_init("/pci/mac-io/nvram");
modules_init();
setup_timers();
#ifdef CONFIG_DRIVER_PCI
ob_pci_init();
#endif
#ifdef CONFIG_DRIVER_IDE
setup_timers();
ob_ide_init();
#endif
#ifdef CONFIG_DRIVER_ADB
ob_adb_init();
#endif
node_methods_init();
init_video();

View File

@@ -81,6 +81,65 @@ finish-device
h# FEC00000 encode-int h# 100000 encode-int encode+ " reg" property
0 encode-int 0 encode-int encode+ " bus-range" property
new-device
" isa" device-name
" isa" device-type
2 encode-int " #address-cells" property
1 encode-int " #size-cells" property
external
: open true ;
: close ;
finish-device
: ?devalias ( alias-str alias-len device-str device-len --
\ alias-str alias-len false | true )
active-package >r
" /aliases" find-device
\ 2dup ." Checking " type
2dup find-dev if \ check if device exists
drop
2over find-dev if \ do we already have an alias?
\ ." alias exists" cr
drop 2drop false
else
\ ." device exists" cr
encode-string
2swap property
true
then
else
\ ." device doesn't exist" cr
2drop false
then
r> active-package!
;
:noname
" hd"
" /pci/pci-ata/ata-1/disk@0" ?devalias not if
" /pci/pci-ata/ata-1/disk@1" ?devalias not if
" /pci/pci-ata/ata-2/disk@0" ?devalias not if
" /pci/pci-ata/ata-2/disk@1" ?devalias not if
2drop ." No disk found." cr
then
then
then
then
" cdrom"
" /pci/pci-ata/ata-1/cdrom@0" ?devalias not if
" /pci/pci-ata/ata-1/cdrom@1" ?devalias not if
" /pci/pci-ata/ata-2/cdrom@0" ?devalias not if
" /pci/pci-ata/ata-2/cdrom@1" ?devalias not if
2drop ." No cdrom found" cr
then
then
then
then
; SYSTEM-initializer
new-device
" ide" device-name
" ide" device-type

View File

@@ -29,7 +29,6 @@
#include "openbios-version.h"
extern void unexpected_excep( int vector );
extern void ob_ide_init( void );
extern void ob_pci_init( void );
extern void setup_timers( void );
@@ -108,10 +107,6 @@ arch_of_init( void )
#ifdef CONFIG_DRIVER_PCI
ob_pci_init();
#endif
#ifdef CONFIG_DRIVER_IDE
ob_ide_init();
#endif
node_methods_init();
#ifdef USE_RTAS

View File

@@ -81,6 +81,65 @@ finish-device
h# FEC00000 encode-int h# 100000 encode-int encode+ " reg" property
0 encode-int 0 encode-int encode+ " bus-range" property
new-device
" isa" device-name
" isa" device-type
2 encode-int " #address-cells" property
1 encode-int " #size-cells" property
external
: open true ;
: close ;
finish-device
: ?devalias ( alias-str alias-len device-str device-len --
\ alias-str alias-len false | true )
active-package >r
" /aliases" find-device
\ 2dup ." Checking " type
2dup find-dev if \ check if device exists
drop
2over find-dev if \ do we already have an alias?
\ ." alias exists" cr
drop 2drop false
else
\ ." device exists" cr
encode-string
2swap property
true
then
else
\ ." device doesn't exist" cr
2drop false
then
r> active-package!
;
:noname
" hd"
" /pci/pci-ata/ata-1/disk@0" ?devalias not if
" /pci/pci-ata/ata-1/disk@1" ?devalias not if
" /pci/pci-ata/ata-2/disk@0" ?devalias not if
" /pci/pci-ata/ata-2/disk@1" ?devalias not if
2drop ." No disk found." cr
then
then
then
then
" cdrom"
" /pci/pci-ata/ata-1/cdrom@0" ?devalias not if
" /pci/pci-ata/ata-1/cdrom@1" ?devalias not if
" /pci/pci-ata/ata-2/cdrom@0" ?devalias not if
" /pci/pci-ata/ata-2/cdrom@1" ?devalias not if
2drop ." No cdrom found" cr
then
then
then
then
; SYSTEM-initializer
new-device
" ide" device-name
" ide" device-type

View File

@@ -865,7 +865,7 @@ arch_init( void )
#endif
#ifdef CONFIG_DRIVER_IDE
setup_timers();
ob_ide_init();
ob_ide_init("/pci/isa", 0x1f0, 0x3f4, 0x170, 0x374);
#endif
#ifdef CONFIG_DRIVER_FLOPPY
ob_floppy_init();

View File

@@ -32,3 +32,65 @@ finish-device
" /openprom" find-device
" OBP 3.10.24 1999/01/01 01:01" encode-string " version" property
dev /pci
\ simple isa bus node
new-device
" isa" device-name
" isa" device-type
2 encode-int " #address-cells" property
1 encode-int " #size-cells" property
external
: open true ;
: close ;
finish-device
: ?devalias ( alias-str alias-len device-str device-len --
\ alias-str alias-len false | true )
active-package >r
" /aliases" find-device
\ 2dup ." Checking " type
2dup find-dev if \ check if device exists
drop
2over find-dev if \ do we already have an alias?
\ ." alias exists" cr
drop 2drop false
else
\ ." device exists" cr
encode-string
2swap property
true
then
else
\ ." device doesn't exist" cr
2drop false
then
r> active-package!
;
:noname
" hd"
" /pci/isa/ide0/disk@0" ?devalias not if
" /pci/isa/ide0/disk@1" ?devalias not if
" /pci/isa/ide1/disk@0" ?devalias not if
" /pci/isa/ide1/disk@1" ?devalias not if
2drop ." No disk found." cr
then
then
then
then
" cdrom"
" /pci/isa/ide0/cdrom@0" ?devalias not if
" /pci/isa/ide0/cdrom@1" ?devalias not if
" /pci/isa/ide1/cdrom@0" ?devalias not if
" /pci/isa/ide1/cdrom@1" ?devalias not if
2drop ." No cdrom found" cr
then
then
then
then
; SYSTEM-initializer

View File

@@ -75,3 +75,65 @@ finish-device
" keyboard" input
; CONSOLE-IN-initializer
dev /pci
\ simple isa bus node
new-device
" isa" device-name
" isa" device-type
2 encode-int " #address-cells" property
1 encode-int " #size-cells" property
external
: open true ;
: close ;
finish-device
: ?devalias ( alias-str alias-len device-str device-len --
\ alias-str alias-len false | true )
active-package >r
" /aliases" find-device
\ 2dup ." Checking " type
2dup find-dev if \ check if device exists
drop
2over find-dev if \ do we already have an alias?
\ ." alias exists" cr
drop 2drop false
else
\ ." device exists" cr
encode-string
2swap property
true
then
else
\ ." device doesn't exist" cr
2drop false
then
r> active-package!
;
:noname
" hd"
" /pci/isa/ide0/disk@0" ?devalias not if
" /pci/isa/ide0/disk@1" ?devalias not if
" /pci/isa/ide1/disk@0" ?devalias not if
" /pci/isa/ide1/disk@1" ?devalias not if
2drop ." No disk found." cr
then
then
then
then
" cdrom"
" /pci/isa/ide0/cdrom@0" ?devalias not if
" /pci/isa/ide0/cdrom@1" ?devalias not if
" /pci/isa/ide1/cdrom@0" ?devalias not if
" /pci/isa/ide1/cdrom@1" ?devalias not if
2drop ." No cdrom found" cr
then
then
then
then
; SYSTEM-initializer

View File

@@ -45,7 +45,7 @@ arch_init( void )
#endif
#ifdef CONFIG_DRIVER_IDE
setup_timers();
ob_ide_init();
ob_ide_init("/pci/isa", 0x1f0, 0x3f4, 0x170, 0x374);
#endif
#ifdef CONFIG_DRIVER_FLOPPY
ob_floppy_init();

View File

@@ -66,7 +66,10 @@
<option name="CONFIG_DRIVER_PCI" type="boolean" value="true"/>
<option name="CONFIG_DEBUG_PCI" type="boolean" value="true"/>
<option name="CONFIG_DRIVER_IDE" type="boolean" value="true"/>
<option name="CONFIG_IDE_NUM_CHANNELS" type="integer" value="4"/>
<option name="CONFIG_IDE_NUM_CHANNELS" type="integer" value="2"/>
<option name="CONFIG_IDE_FIRST_UNIT" type="integer" value="1"/>
<option name="CONFIG_IDE_DEV_NAME" type="string" value="ata-%d"/>
<option name="CONFIG_IDE_DEV_TYPE" type="string" value="ata"/>
<option name="CONFIG_DEBUG_IDE" type="boolean" value="false"/>
<option name="CONFIG_DRIVER_ADB" type="boolean" value="true"/>
<option name="CONFIG_DRIVER_VGA" type="boolean" value="true"/>

View File

@@ -34,6 +34,11 @@
<xsl:value-of select="@name"/><xsl:text> </xsl:text>
<xsl:value-of select="@value"/>
</xsl:when>
<!-- config option "string" -->
<xsl:when test="@type='string'">
<xsl:text>#define </xsl:text>
<xsl:value-of select="@name"/><xsl:text> </xsl:text> "<xsl:value-of select="@value"/>" </xsl:when>
<!-- unsupported config option: bail out -->
<xsl:otherwise>

View File

@@ -26,6 +26,9 @@
<xsl:value-of select="@name"/>
<xsl:text>&#10;</xsl:text>
</xsl:when>
<!-- config option "string" -->
<xsl:when test="@type='string'">
</xsl:when>
<xsl:otherwise>
<xsl:message terminate="yes">&#10;ERROR: configuration option '<xsl:value-of select="@name"/>' has unsupported type '<xsl:value-of select="@type"/>'.</xsl:message>
</xsl:otherwise>

View File

@@ -19,7 +19,6 @@
<dictionary name="openbios" target="forth">
<object source="pci.fs" condition="DRIVER_PCI"/>
<object source="ide.fs" condition="DRIVER_IDE"/>
<object source="sbus.fs" condition="DRIVER_SBUS"/>
<object source="esp.fs" condition="DRIVER_ESP"/>
</dictionary>

View File

@@ -13,11 +13,6 @@
*
*/
/*
* TODO:
* - Really probe for interfaces, don't just rely on legacy
*/
#include "openbios/config.h"
#include "openbios/bindings.h"
#include "openbios/kernel.h"
@@ -43,13 +38,30 @@ DECLARE_UNNAMED_NODE( ob_ide_ctrl, INSTALL_OPEN, sizeof(int));
#endif
#define IDE_MAX_CHANNELS 4
#ifndef CONFIG_IDE_FIRST_UNIT
#define FIRST_UNIT 0
#else
#define FIRST_UNIT CONFIG_IDE_FIRST_UNIT
#endif
#ifndef CONFIG_IDE_DEV_TYPE
#define DEV_TYPE "ide"
#else
#define DEV_TYPE CONFIG_IDE_DEV_TYPE
#endif
#ifndef CONFIG_IDE_DEV_NAME
#define DEV_NAME "ide%d"
#else
#define DEV_NAME CONFIG_IDE_DEV_NAME
#endif
static int current_channel = FIRST_UNIT;
static struct ide_channel ob_ide_channels[IDE_MAX_CHANNELS];
/*
* FIXME: probe, we just hardwire legacy ports for now
*/
static const int io_ports[IDE_MAX_CHANNELS] = { 0x1f0, 0x170, 0x1e8, 0x168 };
static const int ctl_ports[IDE_MAX_CHANNELS] = { 0x3f6, 0x376, 0x3ee, 0x36e };
static int io_ports[IDE_MAX_CHANNELS];
static int ctl_ports[IDE_MAX_CHANNELS];
/*
* don't be pedantic
@@ -634,6 +646,9 @@ ob_ide_atapi_drive_ready(struct ide_drive *drive)
struct atapi_command *cmd = &drive->channel->atapi_cmd;
struct atapi_capacity cap;
#ifdef CONFIG_DEBUG_IDE
printk("ob_ide_atapi_drive_ready\n");
#endif
/*
* Test Unit Ready is like a ping
*/
@@ -835,7 +850,8 @@ ob_ide_read_sectors(struct ide_drive *drive, unsigned long long block,
return 1;
#ifdef CONFIG_DEBUG_IDE
printk("ob_ide_read_sectors: block=%Ld sectors=%u\n", (unsigned long) block, sectors);
printk("ob_ide_read_sectors: block=%lu sectors=%u\n",
(unsigned long) block, sectors);
#endif
if (drive->type == ide_type_ata)
@@ -1133,6 +1149,9 @@ static void
ob_ide_max_transfer(int *idx)
{
struct ide_drive *drive=&ob_ide_channels[idx[1]].drives[idx[0]];
#ifdef CONFIG_DEBUG_IDE
printk("max_transfer %x\n", drive->max_sectors * drive->bs);
#endif
PUSH(drive->max_sectors * drive->bs);
}
@@ -1171,6 +1190,9 @@ static void
ob_ide_block_size(int *idx)
{
struct ide_drive *drive=&ob_ide_channels[idx[1]].drives[idx[0]];
#ifdef CONFIG_DEBUG_IDE
printk("ob_ide_block_size: block size %x\n", drive->bs);
#endif
PUSH(drive->bs);
}
@@ -1184,6 +1206,10 @@ ob_ide_initialize(int *idx)
fword("device-type");
// Set dummy reg properties
set_int_property(ph, "#address-cells", 1);
set_int_property(ph, "#size-cells", 0);
props[0] = __cpu_to_be32(0); props[1] = __cpu_to_be32(0); props[2] = __cpu_to_be32(0);
set_property(ph, "reg", (char *)&props, 3*sizeof(int));
@@ -1205,7 +1231,7 @@ ob_ide_open(int *idx)
fword("ihandle>phandle");
ph=(phandle_t)POP();
idename=get_property(ph, "name", &len);
idx[1]=idename[3]-0x30;
idx[1]=(idename[strlen(idename) - 1] - '0' - FIRST_UNIT) % 2;
#ifdef CONFIG_DEBUG_IDE
printk("opening channel %d unit %d\n", idx[1], idx[0]);
@@ -1249,20 +1275,21 @@ ob_ide_ctrl_initialize(int *idx)
phandle_t ph=get_cur_dev();
char *idename;
set_int_property(ph, "#address-cells", 1);
set_int_property(ph, "#size-cells", 0);
/* set device type */
push_str("ide");
push_str(DEV_TYPE);
fword("device-type");
idename=get_property(ph, "name", &len);
devnum=idename[3]-0x30;
devnum=idename[strlen(idename) - 1] - '0' - FIRST_UNIT;
/* Create interrupt properties. */
props[0]=14; props[1]=0;
set_property(ph, "interrupts", (char *)&props, 2*sizeof(int));
set_property(ph, "compatible", "pci1095,646\0pci1095,646\0pciclass,01018f", 40);
set_int_property(ph, "#address-cells", 1);
set_int_property(ph, "#size-cells", 0);
props[0] = __cpu_to_be32(io_ports[devnum]);
props[1] = __cpu_to_be32(1); props[2] = __cpu_to_be32(8);
props[3] = __cpu_to_be32(ctl_ports[devnum]);
@@ -1281,16 +1308,21 @@ NODE_METHODS(ob_ide_ctrl) = {
{ "decode-unit", ob_ide_ctrl_decodeunit },
};
int ob_ide_init(void)
int ob_ide_init(const char *path, uint32_t io_port0, uint32_t ctl_port0,
uint32_t io_port1, uint32_t ctl_port1)
{
int i, j;
const char *nodetemp_chan = "/pci/isa/ide%d";
const char *nodetemp = "/pci/isa/ide%d/%s";
const char * nodetemp_chan = "%s/"DEV_NAME;
const char * nodetemp = "%s/"DEV_NAME"/%s";
char nodebuff[32];
phandle_t dnode;
for (i = 0; i < IDE_NUM_CHANNELS; i++) {
io_ports[0] = io_port0;
ctl_ports[0] = ctl_port0 + 2;
io_ports[1] = io_port1;
ctl_ports[1] = ctl_port1 + 2;
for (i = 0; i < IDE_NUM_CHANNELS; i++, current_channel++) {
struct ide_channel *chan = &ob_ide_channels[i];
chan->mmio = 0;
@@ -1330,10 +1362,13 @@ int ob_ide_init(void)
ob_ide_identify_drives(chan);
snprintf(nodebuff, sizeof(nodebuff), nodetemp_chan, i);
snprintf(nodebuff, sizeof(nodebuff), nodetemp_chan, path,
current_channel);
REGISTER_NAMED_NODE(ob_ide_ctrl, nodebuff);
printk(DEV_NAME": [io ports 0x%x-0x%x,0x%x]\n",
current_channel, chan->io_regs[0],
chan->io_regs[0] + 7, chan->io_regs[8]);
printk("ide%d: [io ports 0x%x-0x%x,0x%x]\n", i, chan->io_regs[0], chan->io_regs[0] + 7, chan->io_regs[8]);
for (j = 0; j < 2; j++) {
struct ide_drive *drive = &chan->drives[j];
const char *media = "UNKNOWN";
@@ -1357,8 +1392,8 @@ int ob_ide_init(void)
break;
}
printk("%s]: %s\n", media, drive->model);
snprintf(nodebuff, sizeof(nodebuff), nodetemp, i,
media);
snprintf(nodebuff, sizeof(nodebuff), nodetemp, path,
current_channel, media);
REGISTER_NAMED_NODE(ob_ide, nodebuff);
dnode=find_dev(nodebuff);
set_int_property(dnode, "reg", j);

View File

@@ -147,13 +147,11 @@ static const pci_subclass_t undef_subclass[] = {
static int ide_config_cb2 (const pci_config_t *config)
{
#if 0
ide_init(config->path,
config->regions[0] & ~0x0000000F,
config->regions[1] & ~0x0000000F,
config->regions[2] & ~0x0000000F,
config->regions[3] & ~0x0000000F);
#endif
ob_ide_init(config->path,
config->regions[0] & ~0x0000000F,
config->regions[1] & ~0x0000000F,
config->regions[2] & ~0x0000000F,
config->regions[3] & ~0x0000000F);
return 0;
}
@@ -1092,6 +1090,7 @@ static const pci_class_t pci_classes[] = {
phandle_t pic_handle;
static int macio_config_cb (const pci_config_t *config)
{
#ifdef CONFIG_PPC
char buf[64];
phandle_t ph;
cell props[2];
@@ -1108,21 +1107,10 @@ static int macio_config_cb (const pci_config_t *config)
set_property(ph, "reg", &props, sizeof(props));
pic_handle = ph;
#if 0
cuda_init(config->path, config->regions[0]);
macio_nvram_init(config->path, config->regions[0]);
ide_init(config->path,
config->regions[0] + 0x1f000,
config->regions[0] + 0x1f000 + 0x1000,
config->regions[0] + 0x1f000 + 0x2000,
config->regions[0] + 0x1f000 + 0x3000);
#endif
#if 0
OF_finalize_pci_macio(device->common.OF_private,
device->regions[0] & ~0x0000000F, device->sizes[0],
private_data);
#endif
return 0;
return 0;
}
static const pci_dev_t misc_pci[] = {

View File

@@ -26,7 +26,8 @@ void init_video(unsigned long fb, int width, int height, int depth, int rb);
#endif
#endif
#ifdef CONFIG_DRIVER_IDE
int ob_ide_init(void);
int ob_ide_init(const char *path, uint32_t io_port0, uint32_t ctl_port0,
uint32_t io_port1, uint32_t ctl_port1);
#endif
#ifdef CONFIG_DRIVER_ESP
int ob_esp_init(unsigned int slot, uint64_t base, unsigned long espoffset,