2010-01-28 20:46:40 +00:00
|
|
|
/***********************license start***************
|
|
|
|
* Copyright (c) 2003-2008 Cavium Networks (support@cavium.com). All rights
|
|
|
|
* reserved.
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions are
|
|
|
|
* met:
|
|
|
|
*
|
|
|
|
* * Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
*
|
|
|
|
* * Redistributions in binary form must reproduce the above
|
|
|
|
* copyright notice, this list of conditions and the following
|
|
|
|
* disclaimer in the documentation and/or other materials provided
|
|
|
|
* with the distribution.
|
|
|
|
*
|
|
|
|
* * Neither the name of Cavium Networks nor the names of
|
|
|
|
* its contributors may be used to endorse or promote products
|
|
|
|
* derived from this software without specific prior written
|
|
|
|
* permission.
|
|
|
|
*
|
|
|
|
* TO THE MAXIMUM EXTENT PERMITTED BY LAW, THE SOFTWARE IS PROVIDED "AS IS"
|
|
|
|
* AND WITH ALL FAULTS AND CAVIUM NETWORKS MAKES NO PROMISES, REPRESENTATIONS
|
|
|
|
* OR WARRANTIES, EITHER EXPRESS, IMPLIED, STATUTORY, OR OTHERWISE, WITH
|
|
|
|
* RESPECT TO THE SOFTWARE, INCLUDING ITS CONDITION, ITS CONFORMITY TO ANY
|
|
|
|
* REPRESENTATION OR DESCRIPTION, OR THE EXISTENCE OF ANY LATENT OR PATENT
|
|
|
|
* DEFECTS, AND CAVIUM SPECIFICALLY DISCLAIMS ALL IMPLIED (IF ANY) WARRANTIES
|
|
|
|
* OF TITLE, MERCHANTABILITY, NONINFRINGEMENT, FITNESS FOR A PARTICULAR
|
|
|
|
* PURPOSE, LACK OF VIRUSES, ACCURACY OR COMPLETENESS, QUIET ENJOYMENT, QUIET
|
|
|
|
* POSSESSION OR CORRESPONDENCE TO DESCRIPTION. THE ENTIRE RISK ARISING OUT
|
|
|
|
* OF USE OR PERFORMANCE OF THE SOFTWARE LIES WITH YOU.
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* For any questions regarding licensing please contact marketing@caviumnetworks.com
|
|
|
|
*
|
|
|
|
***********************license end**************************************/
|
|
|
|
|
2009-06-14 03:47:44 +00:00
|
|
|
/*
|
|
|
|
* octeon_ebt3000_cf.c
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <sys/cdefs.h>
|
|
|
|
__FBSDID("$FreeBSD$");
|
|
|
|
|
|
|
|
#include <sys/param.h>
|
|
|
|
#include <sys/bio.h>
|
|
|
|
#include <sys/systm.h>
|
|
|
|
#include <sys/sysctl.h>
|
Update the port of FreeBSD to Cavium Octeon to use the Cavium Simple Executive
library:
o) Increase inline unit / large function growth limits for MIPS to accommodate
the needs of the Simple Executive, which uses a shocking amount of inlining.
o) Remove TARGET_OCTEON and use CPU_CNMIPS to do things required by cnMIPS and
the Octeon SoC.
o) Add OCTEON_VENDOR_LANNER to use Lanner's allocation of vendor-specific
board numbers, specifically to support the MR320.
o) Add OCTEON_BOARD_CAPK_0100ND to hard-wire configuration for the CAPK-0100nd,
which improperly uses an evaluation board's board number and breaks board
detection at runtime. This board is sold by Portwell as the CAM-0100.
o) Add support for the RTC available on some Octeon boards.
o) Add support for the Octeon PCI bus. Note that rman_[sg]et_virtual for IO
ports can not work unless building for n64.
o) Clean up the CompactFlash driver to use Simple Executive macros and
structures where possible (it would be advisable to use the Simple Executive
API to set the PIO mode, too, but that is not done presently.) Also use
structures from FreeBSD's ATA layer rather than structures copied from
Linux.
o) Print available Octeon SoC features on boot.
o) Add support for the Octeon timecounter.
o) Use the Simple Executive's routines rather than local copies for doing reads
and writes to 64-bit addresses and use its macros for various device
addresses rather than using local copies.
o) Rename octeon_board_real to octeon_is_simulation to reduce differences with
Cavium-provided code originally written for Linux. Also make it use the
same simplified test that the Simple Executive and Linux both use rather
than our complex one.
o) Add support for the Octeon CIU, which is the main interrupt unit, as a bus
to use normal interrupt allocation and setup routines.
o) Use the Simple Executive's bootmem facility to allocate physical memory for
the kernel, rather than assuming we know which addresses we can steal.
NB: This may reduce the amount of RAM the kernel reports you as having if
you are leaving large temporary allocations made by U-Boot allocated
when starting FreeBSD.
o) Add a port of the Cavium-provided Ethernet driver for Linux. This changes
Ethernet interface naming from rgmxN to octeN. The new driver has vast
improvements over the old one, both in performance and functionality, but
does still have some features which have not been ported entirely and there
may be unimplemented code that can be hit in everyday use. I will make
every effort to correct those as they are reported.
o) Support loading the kernel on non-contiguous cores.
o) Add very conservative support for harvesting randomness from the Octeon
random number device.
o) Turn SMP on by default.
o) Clean up the style of the Octeon kernel configurations a little and make
them compile with -march=octeon.
o) Add support for the Lanner MR320 and the CAPK-0100nd to the Simple
Executive.
o) Modify the Simple Executive to build on FreeBSD and to build without
executive-config.h or cvmx-config.h. In the future we may want to
revert part of these changes and supply executive-config.h and
cvmx-config.h and access to the options contained in those files via
kernel configuration files.
o) Modify the Simple Executive USB routines to support getting and setting
of the USB PID.
2010-07-20 19:25:11 +00:00
|
|
|
#include <sys/ata.h>
|
2009-06-14 03:47:44 +00:00
|
|
|
#include <sys/bus.h>
|
|
|
|
#include <sys/kernel.h>
|
|
|
|
#include <sys/module.h>
|
|
|
|
#include <sys/rman.h>
|
|
|
|
#include <sys/power.h>
|
|
|
|
#include <sys/smp.h>
|
|
|
|
#include <sys/time.h>
|
|
|
|
#include <sys/timetc.h>
|
|
|
|
#include <sys/malloc.h>
|
|
|
|
|
|
|
|
#include <geom/geom.h>
|
|
|
|
|
|
|
|
#include <machine/clock.h>
|
|
|
|
#include <machine/locore.h>
|
|
|
|
#include <machine/md_var.h>
|
|
|
|
#include <machine/cpuregs.h>
|
|
|
|
|
2010-01-11 04:29:26 +00:00
|
|
|
#include <mips/cavium/octeon_pcmap_regs.h>
|
2009-06-14 03:47:44 +00:00
|
|
|
|
Update the port of FreeBSD to Cavium Octeon to use the Cavium Simple Executive
library:
o) Increase inline unit / large function growth limits for MIPS to accommodate
the needs of the Simple Executive, which uses a shocking amount of inlining.
o) Remove TARGET_OCTEON and use CPU_CNMIPS to do things required by cnMIPS and
the Octeon SoC.
o) Add OCTEON_VENDOR_LANNER to use Lanner's allocation of vendor-specific
board numbers, specifically to support the MR320.
o) Add OCTEON_BOARD_CAPK_0100ND to hard-wire configuration for the CAPK-0100nd,
which improperly uses an evaluation board's board number and breaks board
detection at runtime. This board is sold by Portwell as the CAM-0100.
o) Add support for the RTC available on some Octeon boards.
o) Add support for the Octeon PCI bus. Note that rman_[sg]et_virtual for IO
ports can not work unless building for n64.
o) Clean up the CompactFlash driver to use Simple Executive macros and
structures where possible (it would be advisable to use the Simple Executive
API to set the PIO mode, too, but that is not done presently.) Also use
structures from FreeBSD's ATA layer rather than structures copied from
Linux.
o) Print available Octeon SoC features on boot.
o) Add support for the Octeon timecounter.
o) Use the Simple Executive's routines rather than local copies for doing reads
and writes to 64-bit addresses and use its macros for various device
addresses rather than using local copies.
o) Rename octeon_board_real to octeon_is_simulation to reduce differences with
Cavium-provided code originally written for Linux. Also make it use the
same simplified test that the Simple Executive and Linux both use rather
than our complex one.
o) Add support for the Octeon CIU, which is the main interrupt unit, as a bus
to use normal interrupt allocation and setup routines.
o) Use the Simple Executive's bootmem facility to allocate physical memory for
the kernel, rather than assuming we know which addresses we can steal.
NB: This may reduce the amount of RAM the kernel reports you as having if
you are leaving large temporary allocations made by U-Boot allocated
when starting FreeBSD.
o) Add a port of the Cavium-provided Ethernet driver for Linux. This changes
Ethernet interface naming from rgmxN to octeN. The new driver has vast
improvements over the old one, both in performance and functionality, but
does still have some features which have not been ported entirely and there
may be unimplemented code that can be hit in everyday use. I will make
every effort to correct those as they are reported.
o) Support loading the kernel on non-contiguous cores.
o) Add very conservative support for harvesting randomness from the Octeon
random number device.
o) Turn SMP on by default.
o) Clean up the style of the Octeon kernel configurations a little and make
them compile with -march=octeon.
o) Add support for the Lanner MR320 and the CAPK-0100nd to the Simple
Executive.
o) Modify the Simple Executive to build on FreeBSD and to build without
executive-config.h or cvmx-config.h. In the future we may want to
revert part of these changes and supply executive-config.h and
cvmx-config.h and access to the options contained in those files via
kernel configuration files.
o) Modify the Simple Executive USB routines to support getting and setting
of the USB PID.
2010-07-20 19:25:11 +00:00
|
|
|
#include <contrib/octeon-sdk/cvmx.h>
|
|
|
|
|
2009-06-14 03:47:44 +00:00
|
|
|
/* ATA Commands */
|
|
|
|
#define CMD_READ_SECTOR 0x20
|
|
|
|
#define CMD_WRITE_SECTOR 0x30
|
|
|
|
#define CMD_IDENTIFY 0xEC
|
|
|
|
|
|
|
|
/* The ATA Task File */
|
|
|
|
#define TF_DATA 0x00
|
|
|
|
#define TF_ERROR 0x01
|
|
|
|
#define TF_PRECOMP 0x01
|
|
|
|
#define TF_SECTOR_COUNT 0x02
|
|
|
|
#define TF_SECTOR_NUMBER 0x03
|
|
|
|
#define TF_CYL_LSB 0x04
|
|
|
|
#define TF_CYL_MSB 0x05
|
|
|
|
#define TF_DRV_HEAD 0x06
|
|
|
|
#define TF_STATUS 0x07
|
|
|
|
#define TF_COMMAND 0x07
|
|
|
|
|
|
|
|
/* Status Register */
|
|
|
|
#define STATUS_BSY 0x80 /* Drive is busy */
|
|
|
|
#define STATUS_RDY 0x40 /* Drive is ready */
|
2010-03-06 05:49:15 +00:00
|
|
|
#define STATUS_DF 0x20 /* Device fault */
|
2009-06-14 03:47:44 +00:00
|
|
|
#define STATUS_DRQ 0x08 /* Data can be transferred */
|
|
|
|
|
|
|
|
/* Miscelaneous */
|
|
|
|
#define SECTOR_SIZE 512
|
|
|
|
#define WAIT_DELAY 1000
|
|
|
|
#define NR_TRIES 1000
|
|
|
|
#define SWAP_SHORT(x) ((x << 8) | (x >> 8))
|
|
|
|
#define MODEL_STR_SIZE 40
|
|
|
|
|
|
|
|
/* Globals */
|
Add support for True IDE mode to the Octeon CF driver. This mode is
signalled when the attribute address for the CF is 0 in the octeon
sysinfo structure. In this mode, the DATA port is 16-bits, but the
other ports are 8-bits, but on a 16-bit bus (so you have to access it
a short at a time, but only believe the lower byte). See the code for
more details on this slightly odd arrangement. I'm still not 100%
happy with the abstractions here on many levels (starting with the
globals for these settings, on down to no bus_space use, etc), but the
driver had these problems before the change.
Also, clean up the code a bit to make this support easier, and the
code a bit easier to read. I tried to follow existing style, but may
have missed a few spots. Add some comments.
Fix probe/attach routine to return a proper error for the simulator.
With this change, my EBH5200 eval board now recognizes the CF well
enough to boot to the login prompt. Before it would say it never
became ready. My CN3010-EVB-HS5 still boots properly. My older
CN3860-based board won't load the 64-bit kernel, either before or
after the change, and I didn't chase that down.
2011-06-04 07:06:05 +00:00
|
|
|
/*
|
|
|
|
* There's three bus types supported by this driver.
|
|
|
|
*
|
|
|
|
* CF_8 -- Traditional PC Card IDE interface on an 8-bit wide bus. We assume
|
|
|
|
* the bool loader has configure attribute memory properly. We then access
|
|
|
|
* the device like old-school 8-bit IDE card (which is all a traditional PC Card
|
|
|
|
* interface really is).
|
|
|
|
* CF_16 -- Traditional PC Card IDE interface on a 16-bit wide bus. Registers on
|
|
|
|
* this bus are 16-bits wide too. When accessing registers in the task file, you
|
|
|
|
* have to do it in 16-bit chunks, and worry about masking out what you don't want
|
|
|
|
* or ORing together the traditional 8-bit values. We assume the bootloader does
|
|
|
|
* the right attribute memory initialization dance.
|
|
|
|
* CF_TRUE_IDE_8 - CF Card wired to True IDE mode. There's no Attribute memory
|
|
|
|
* space at all. Instead all the traditional 8-bit registers are there, but
|
|
|
|
* on a 16-bit bus where addr0 isn't wired. This means we need to read/write them
|
|
|
|
* 16-bit chunks, but only the lower 8 bits are valid. We do not (and can not)
|
|
|
|
* access this like CF_16 with the comingled registers. Yet we can't access
|
|
|
|
* this like CF_8 because of the register offset. Except the TF_DATA register
|
|
|
|
* appears to be full width?
|
|
|
|
*/
|
2009-06-14 03:47:44 +00:00
|
|
|
void *base_addr;
|
Add support for True IDE mode to the Octeon CF driver. This mode is
signalled when the attribute address for the CF is 0 in the octeon
sysinfo structure. In this mode, the DATA port is 16-bits, but the
other ports are 8-bits, but on a 16-bit bus (so you have to access it
a short at a time, but only believe the lower byte). See the code for
more details on this slightly odd arrangement. I'm still not 100%
happy with the abstractions here on many levels (starting with the
globals for these settings, on down to no bus_space use, etc), but the
driver had these problems before the change.
Also, clean up the code a bit to make this support easier, and the
code a bit easier to read. I tried to follow existing style, but may
have missed a few spots. Add some comments.
Fix probe/attach routine to return a proper error for the simulator.
With this change, my EBH5200 eval board now recognizes the CF well
enough to boot to the login prompt. Before it would say it never
became ready. My CN3010-EVB-HS5 still boots properly. My older
CN3860-based board won't load the 64-bit kernel, either before or
after the change, and I didn't chase that down.
2011-06-04 07:06:05 +00:00
|
|
|
int bus_type;
|
|
|
|
#define CF_8 1 /* 8-bit bus, no offsets - PC Card */
|
|
|
|
#define CF_16 2 /* 16-bit bus, registers shared - PC Card */
|
|
|
|
#define CF_TRUE_IDE_8 3 /* 16-bit bus, only lower 8-bits, TrueIDE */
|
|
|
|
const char *const cf_type[] = {
|
|
|
|
"impossible type",
|
|
|
|
"CF 8-bit",
|
|
|
|
"CF 16-bit",
|
|
|
|
"True IDE"
|
|
|
|
};
|
2009-06-14 03:47:44 +00:00
|
|
|
|
|
|
|
/* Device parameters */
|
|
|
|
struct drive_param{
|
|
|
|
union {
|
|
|
|
char buf[SECTOR_SIZE];
|
Update the port of FreeBSD to Cavium Octeon to use the Cavium Simple Executive
library:
o) Increase inline unit / large function growth limits for MIPS to accommodate
the needs of the Simple Executive, which uses a shocking amount of inlining.
o) Remove TARGET_OCTEON and use CPU_CNMIPS to do things required by cnMIPS and
the Octeon SoC.
o) Add OCTEON_VENDOR_LANNER to use Lanner's allocation of vendor-specific
board numbers, specifically to support the MR320.
o) Add OCTEON_BOARD_CAPK_0100ND to hard-wire configuration for the CAPK-0100nd,
which improperly uses an evaluation board's board number and breaks board
detection at runtime. This board is sold by Portwell as the CAM-0100.
o) Add support for the RTC available on some Octeon boards.
o) Add support for the Octeon PCI bus. Note that rman_[sg]et_virtual for IO
ports can not work unless building for n64.
o) Clean up the CompactFlash driver to use Simple Executive macros and
structures where possible (it would be advisable to use the Simple Executive
API to set the PIO mode, too, but that is not done presently.) Also use
structures from FreeBSD's ATA layer rather than structures copied from
Linux.
o) Print available Octeon SoC features on boot.
o) Add support for the Octeon timecounter.
o) Use the Simple Executive's routines rather than local copies for doing reads
and writes to 64-bit addresses and use its macros for various device
addresses rather than using local copies.
o) Rename octeon_board_real to octeon_is_simulation to reduce differences with
Cavium-provided code originally written for Linux. Also make it use the
same simplified test that the Simple Executive and Linux both use rather
than our complex one.
o) Add support for the Octeon CIU, which is the main interrupt unit, as a bus
to use normal interrupt allocation and setup routines.
o) Use the Simple Executive's bootmem facility to allocate physical memory for
the kernel, rather than assuming we know which addresses we can steal.
NB: This may reduce the amount of RAM the kernel reports you as having if
you are leaving large temporary allocations made by U-Boot allocated
when starting FreeBSD.
o) Add a port of the Cavium-provided Ethernet driver for Linux. This changes
Ethernet interface naming from rgmxN to octeN. The new driver has vast
improvements over the old one, both in performance and functionality, but
does still have some features which have not been ported entirely and there
may be unimplemented code that can be hit in everyday use. I will make
every effort to correct those as they are reported.
o) Support loading the kernel on non-contiguous cores.
o) Add very conservative support for harvesting randomness from the Octeon
random number device.
o) Turn SMP on by default.
o) Clean up the style of the Octeon kernel configurations a little and make
them compile with -march=octeon.
o) Add support for the Lanner MR320 and the CAPK-0100nd to the Simple
Executive.
o) Modify the Simple Executive to build on FreeBSD and to build without
executive-config.h or cvmx-config.h. In the future we may want to
revert part of these changes and supply executive-config.h and
cvmx-config.h and access to the options contained in those files via
kernel configuration files.
o) Modify the Simple Executive USB routines to support getting and setting
of the USB PID.
2010-07-20 19:25:11 +00:00
|
|
|
struct ata_params driveid;
|
2009-06-14 03:47:44 +00:00
|
|
|
} u;
|
|
|
|
|
|
|
|
char model[MODEL_STR_SIZE];
|
|
|
|
uint32_t nr_sectors;
|
|
|
|
uint16_t sector_size;
|
|
|
|
uint16_t heads;
|
|
|
|
uint16_t tracks;
|
|
|
|
uint16_t sec_track;
|
2012-03-21 10:27:12 +00:00
|
|
|
};
|
2009-06-14 03:47:44 +00:00
|
|
|
|
2012-03-21 10:27:12 +00:00
|
|
|
/* Device softc */
|
|
|
|
struct cf_priv {
|
|
|
|
device_t dev;
|
|
|
|
struct drive_param drive_param;
|
|
|
|
|
|
|
|
struct bio_queue_head cf_bq;
|
|
|
|
struct g_geom *cf_geom;
|
|
|
|
struct g_provider *cf_provider;
|
|
|
|
|
|
|
|
};
|
2009-06-14 03:47:44 +00:00
|
|
|
|
|
|
|
/* GEOM class implementation */
|
|
|
|
static g_access_t cf_access;
|
|
|
|
static g_start_t cf_start;
|
|
|
|
static g_ioctl_t cf_ioctl;
|
|
|
|
|
|
|
|
struct g_class g_cf_class = {
|
|
|
|
.name = "CF",
|
|
|
|
.version = G_VERSION,
|
|
|
|
.start = cf_start,
|
|
|
|
.access = cf_access,
|
|
|
|
.ioctl = cf_ioctl,
|
|
|
|
};
|
|
|
|
|
2010-11-02 23:43:44 +00:00
|
|
|
DECLARE_GEOM_CLASS(g_cf_class, g_cf);
|
|
|
|
|
2009-06-14 03:47:44 +00:00
|
|
|
/* Device methods */
|
|
|
|
static int cf_probe(device_t);
|
|
|
|
static void cf_identify(driver_t *, device_t);
|
|
|
|
static int cf_attach(device_t);
|
2012-03-21 10:27:12 +00:00
|
|
|
static void cf_attach_geom(void *, int);
|
2009-06-14 03:47:44 +00:00
|
|
|
|
|
|
|
/* ATA methods */
|
2012-03-21 10:27:12 +00:00
|
|
|
static int cf_cmd_identify(struct cf_priv *);
|
2010-03-06 05:49:15 +00:00
|
|
|
static int cf_cmd_write(uint32_t, uint32_t, void *);
|
|
|
|
static int cf_cmd_read(uint32_t, uint32_t, void *);
|
|
|
|
static int cf_wait_busy(void);
|
|
|
|
static int cf_send_cmd(uint32_t, uint8_t);
|
2009-06-14 03:47:44 +00:00
|
|
|
|
|
|
|
/* Miscelenous */
|
|
|
|
static void cf_swap_ascii(unsigned char[], char[]);
|
|
|
|
|
|
|
|
|
|
|
|
/* ------------------------------------------------------------------- *
|
|
|
|
* cf_access() *
|
|
|
|
* ------------------------------------------------------------------- */
|
|
|
|
static int cf_access (struct g_provider *pp, int r, int w, int e)
|
|
|
|
{
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* ------------------------------------------------------------------- *
|
|
|
|
* cf_start() *
|
|
|
|
* ------------------------------------------------------------------- */
|
|
|
|
static void cf_start (struct bio *bp)
|
|
|
|
{
|
2012-03-21 10:27:12 +00:00
|
|
|
struct cf_priv *cf_priv;
|
2010-03-06 05:49:15 +00:00
|
|
|
int error;
|
|
|
|
|
2012-03-21 10:27:12 +00:00
|
|
|
cf_priv = bp->bio_to->geom->softc;
|
|
|
|
|
2009-06-14 03:47:44 +00:00
|
|
|
/*
|
|
|
|
* Handle actual I/O requests. The request is passed down through
|
|
|
|
* the bio struct.
|
|
|
|
*/
|
|
|
|
|
2016-03-10 06:25:47 +00:00
|
|
|
switch (bp->bio_cmd) {
|
|
|
|
case BIO_GETATTR:
|
2012-03-21 10:27:12 +00:00
|
|
|
if (g_handleattr_int(bp, "GEOM::fwsectors", cf_priv->drive_param.sec_track))
|
2009-06-14 03:47:44 +00:00
|
|
|
return;
|
2012-03-21 10:27:12 +00:00
|
|
|
if (g_handleattr_int(bp, "GEOM::fwheads", cf_priv->drive_param.heads))
|
2009-06-14 03:47:44 +00:00
|
|
|
return;
|
|
|
|
g_io_deliver(bp, ENOIOCTL);
|
|
|
|
return;
|
2016-03-10 06:25:47 +00:00
|
|
|
|
|
|
|
case BIO_READ:
|
|
|
|
error = cf_cmd_read(bp->bio_length / cf_priv->drive_param.sector_size,
|
|
|
|
bp->bio_offset / cf_priv->drive_param.sector_size, bp->bio_data);
|
|
|
|
break;
|
|
|
|
case BIO_WRITE:
|
|
|
|
error = cf_cmd_write(bp->bio_length / cf_priv->drive_param.sector_size,
|
|
|
|
bp->bio_offset/cf_priv->drive_param.sector_size, bp->bio_data);
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
printf("%s: unrecognized bio_cmd %x.\n", __func__, bp->bio_cmd);
|
|
|
|
error = ENOTSUP;
|
|
|
|
break;
|
2009-06-14 03:47:44 +00:00
|
|
|
}
|
|
|
|
|
2016-03-10 06:25:47 +00:00
|
|
|
if (error != 0) {
|
|
|
|
g_io_deliver(bp, error);
|
|
|
|
return;
|
2009-06-14 03:47:44 +00:00
|
|
|
}
|
2016-03-10 06:25:47 +00:00
|
|
|
|
|
|
|
bp->bio_resid = 0;
|
|
|
|
bp->bio_completed = bp->bio_length;
|
|
|
|
g_io_deliver(bp, 0);
|
2009-06-14 03:47:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static int cf_ioctl (struct g_provider *pp, u_long cmd, void *data, int fflag, struct thread *td)
|
|
|
|
{
|
Add support for True IDE mode to the Octeon CF driver. This mode is
signalled when the attribute address for the CF is 0 in the octeon
sysinfo structure. In this mode, the DATA port is 16-bits, but the
other ports are 8-bits, but on a 16-bit bus (so you have to access it
a short at a time, but only believe the lower byte). See the code for
more details on this slightly odd arrangement. I'm still not 100%
happy with the abstractions here on many levels (starting with the
globals for these settings, on down to no bus_space use, etc), but the
driver had these problems before the change.
Also, clean up the code a bit to make this support easier, and the
code a bit easier to read. I tried to follow existing style, but may
have missed a few spots. Add some comments.
Fix probe/attach routine to return a proper error for the simulator.
With this change, my EBH5200 eval board now recognizes the CF well
enough to boot to the login prompt. Before it would say it never
became ready. My CN3010-EVB-HS5 still boots properly. My older
CN3860-based board won't load the 64-bit kernel, either before or
after the change, and I didn't chase that down.
2011-06-04 07:06:05 +00:00
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static uint8_t cf_inb_8(int port)
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
* Traditional 8-bit PC Card/CF bus access.
|
|
|
|
*/
|
|
|
|
if (bus_type == CF_8) {
|
|
|
|
volatile uint8_t *task_file = (volatile uint8_t *)base_addr;
|
|
|
|
return task_file[port];
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* True IDE access. lower 8 bits on a 16-bit bus (see above).
|
|
|
|
*/
|
|
|
|
volatile uint16_t *task_file = (volatile uint16_t *)base_addr;
|
|
|
|
return task_file[port] & 0xff;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void cf_outb_8(int port, uint8_t val)
|
|
|
|
{
|
|
|
|
/*
|
|
|
|
* Traditional 8-bit PC Card/CF bus access.
|
|
|
|
*/
|
|
|
|
if (bus_type == CF_8) {
|
|
|
|
volatile uint8_t *task_file = (volatile uint8_t *)base_addr;
|
|
|
|
task_file[port] = val;
|
2012-10-27 23:36:41 +00:00
|
|
|
return;
|
Add support for True IDE mode to the Octeon CF driver. This mode is
signalled when the attribute address for the CF is 0 in the octeon
sysinfo structure. In this mode, the DATA port is 16-bits, but the
other ports are 8-bits, but on a 16-bit bus (so you have to access it
a short at a time, but only believe the lower byte). See the code for
more details on this slightly odd arrangement. I'm still not 100%
happy with the abstractions here on many levels (starting with the
globals for these settings, on down to no bus_space use, etc), but the
driver had these problems before the change.
Also, clean up the code a bit to make this support easier, and the
code a bit easier to read. I tried to follow existing style, but may
have missed a few spots. Add some comments.
Fix probe/attach routine to return a proper error for the simulator.
With this change, my EBH5200 eval board now recognizes the CF well
enough to boot to the login prompt. Before it would say it never
became ready. My CN3010-EVB-HS5 still boots properly. My older
CN3860-based board won't load the 64-bit kernel, either before or
after the change, and I didn't chase that down.
2011-06-04 07:06:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* True IDE access. lower 8 bits on a 16-bit bus (see above).
|
|
|
|
*/
|
|
|
|
volatile uint16_t *task_file = (volatile uint16_t *)base_addr;
|
|
|
|
task_file[port] = val & 0xff;
|
|
|
|
}
|
|
|
|
|
|
|
|
static uint8_t cf_inb_16(int port)
|
|
|
|
{
|
|
|
|
volatile uint16_t *task_file = (volatile uint16_t *)base_addr;
|
|
|
|
uint16_t val = task_file[port / 2];
|
|
|
|
if (port & 1)
|
|
|
|
return (val >> 8) & 0xff;
|
|
|
|
return val & 0xff;
|
2009-06-14 03:47:44 +00:00
|
|
|
}
|
|
|
|
|
Add support for True IDE mode to the Octeon CF driver. This mode is
signalled when the attribute address for the CF is 0 in the octeon
sysinfo structure. In this mode, the DATA port is 16-bits, but the
other ports are 8-bits, but on a 16-bit bus (so you have to access it
a short at a time, but only believe the lower byte). See the code for
more details on this slightly odd arrangement. I'm still not 100%
happy with the abstractions here on many levels (starting with the
globals for these settings, on down to no bus_space use, etc), but the
driver had these problems before the change.
Also, clean up the code a bit to make this support easier, and the
code a bit easier to read. I tried to follow existing style, but may
have missed a few spots. Add some comments.
Fix probe/attach routine to return a proper error for the simulator.
With this change, my EBH5200 eval board now recognizes the CF well
enough to boot to the login prompt. Before it would say it never
became ready. My CN3010-EVB-HS5 still boots properly. My older
CN3860-based board won't load the 64-bit kernel, either before or
after the change, and I didn't chase that down.
2011-06-04 07:06:05 +00:00
|
|
|
static uint16_t cf_inw_16(int port)
|
|
|
|
{
|
|
|
|
volatile uint16_t *task_file = (volatile uint16_t *)base_addr;
|
|
|
|
uint16_t val = task_file[port / 2];
|
|
|
|
return val;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void cf_outw_16(int port, uint16_t val)
|
|
|
|
{
|
|
|
|
volatile uint16_t *task_file = (volatile uint16_t *)base_addr;
|
|
|
|
task_file[port / 2] = val;
|
|
|
|
}
|
2009-06-14 03:47:44 +00:00
|
|
|
|
|
|
|
/* ------------------------------------------------------------------- *
|
|
|
|
* cf_cmd_read() *
|
|
|
|
* ------------------------------------------------------------------- *
|
|
|
|
*
|
|
|
|
* Read nr_sectors from the device starting from start_sector.
|
|
|
|
*/
|
2010-03-06 05:49:15 +00:00
|
|
|
static int cf_cmd_read (uint32_t nr_sectors, uint32_t start_sector, void *buf)
|
2009-06-14 03:47:44 +00:00
|
|
|
{
|
|
|
|
unsigned long lba;
|
|
|
|
uint32_t count;
|
|
|
|
uint16_t *ptr_16;
|
|
|
|
uint8_t *ptr_8;
|
2010-03-06 05:49:15 +00:00
|
|
|
int error;
|
2009-06-14 03:47:44 +00:00
|
|
|
|
|
|
|
ptr_8 = (uint8_t*)buf;
|
|
|
|
ptr_16 = (uint16_t*)buf;
|
|
|
|
lba = start_sector;
|
|
|
|
|
|
|
|
while (nr_sectors--) {
|
2010-03-06 05:49:15 +00:00
|
|
|
error = cf_send_cmd(lba, CMD_READ_SECTOR);
|
|
|
|
if (error != 0) {
|
|
|
|
printf("%s: cf_send_cmd(CMD_READ_SECTOR) failed: %d\n", __func__, error);
|
|
|
|
return (error);
|
|
|
|
}
|
2009-06-14 03:47:44 +00:00
|
|
|
|
Add support for True IDE mode to the Octeon CF driver. This mode is
signalled when the attribute address for the CF is 0 in the octeon
sysinfo structure. In this mode, the DATA port is 16-bits, but the
other ports are 8-bits, but on a 16-bit bus (so you have to access it
a short at a time, but only believe the lower byte). See the code for
more details on this slightly odd arrangement. I'm still not 100%
happy with the abstractions here on many levels (starting with the
globals for these settings, on down to no bus_space use, etc), but the
driver had these problems before the change.
Also, clean up the code a bit to make this support easier, and the
code a bit easier to read. I tried to follow existing style, but may
have missed a few spots. Add some comments.
Fix probe/attach routine to return a proper error for the simulator.
With this change, my EBH5200 eval board now recognizes the CF well
enough to boot to the login prompt. Before it would say it never
became ready. My CN3010-EVB-HS5 still boots properly. My older
CN3860-based board won't load the 64-bit kernel, either before or
after the change, and I didn't chase that down.
2011-06-04 07:06:05 +00:00
|
|
|
switch (bus_type)
|
|
|
|
{
|
|
|
|
case CF_8:
|
2009-06-14 03:47:44 +00:00
|
|
|
for (count = 0; count < SECTOR_SIZE; count++) {
|
Add support for True IDE mode to the Octeon CF driver. This mode is
signalled when the attribute address for the CF is 0 in the octeon
sysinfo structure. In this mode, the DATA port is 16-bits, but the
other ports are 8-bits, but on a 16-bit bus (so you have to access it
a short at a time, but only believe the lower byte). See the code for
more details on this slightly odd arrangement. I'm still not 100%
happy with the abstractions here on many levels (starting with the
globals for these settings, on down to no bus_space use, etc), but the
driver had these problems before the change.
Also, clean up the code a bit to make this support easier, and the
code a bit easier to read. I tried to follow existing style, but may
have missed a few spots. Add some comments.
Fix probe/attach routine to return a proper error for the simulator.
With this change, my EBH5200 eval board now recognizes the CF well
enough to boot to the login prompt. Before it would say it never
became ready. My CN3010-EVB-HS5 still boots properly. My older
CN3860-based board won't load the 64-bit kernel, either before or
after the change, and I didn't chase that down.
2011-06-04 07:06:05 +00:00
|
|
|
*ptr_8++ = cf_inb_8(TF_DATA);
|
|
|
|
if ((count & 0xf) == 0)
|
|
|
|
(void)cf_inb_8(TF_STATUS);
|
2009-06-14 03:47:44 +00:00
|
|
|
}
|
Add support for True IDE mode to the Octeon CF driver. This mode is
signalled when the attribute address for the CF is 0 in the octeon
sysinfo structure. In this mode, the DATA port is 16-bits, but the
other ports are 8-bits, but on a 16-bit bus (so you have to access it
a short at a time, but only believe the lower byte). See the code for
more details on this slightly odd arrangement. I'm still not 100%
happy with the abstractions here on many levels (starting with the
globals for these settings, on down to no bus_space use, etc), but the
driver had these problems before the change.
Also, clean up the code a bit to make this support easier, and the
code a bit easier to read. I tried to follow existing style, but may
have missed a few spots. Add some comments.
Fix probe/attach routine to return a proper error for the simulator.
With this change, my EBH5200 eval board now recognizes the CF well
enough to boot to the login prompt. Before it would say it never
became ready. My CN3010-EVB-HS5 still boots properly. My older
CN3860-based board won't load the 64-bit kernel, either before or
after the change, and I didn't chase that down.
2011-06-04 07:06:05 +00:00
|
|
|
break;
|
|
|
|
case CF_TRUE_IDE_8:
|
|
|
|
case CF_16:
|
|
|
|
default:
|
2009-06-14 03:47:44 +00:00
|
|
|
for (count = 0; count < SECTOR_SIZE; count+=2) {
|
|
|
|
uint16_t temp;
|
Add support for True IDE mode to the Octeon CF driver. This mode is
signalled when the attribute address for the CF is 0 in the octeon
sysinfo structure. In this mode, the DATA port is 16-bits, but the
other ports are 8-bits, but on a 16-bit bus (so you have to access it
a short at a time, but only believe the lower byte). See the code for
more details on this slightly odd arrangement. I'm still not 100%
happy with the abstractions here on many levels (starting with the
globals for these settings, on down to no bus_space use, etc), but the
driver had these problems before the change.
Also, clean up the code a bit to make this support easier, and the
code a bit easier to read. I tried to follow existing style, but may
have missed a few spots. Add some comments.
Fix probe/attach routine to return a proper error for the simulator.
With this change, my EBH5200 eval board now recognizes the CF well
enough to boot to the login prompt. Before it would say it never
became ready. My CN3010-EVB-HS5 still boots properly. My older
CN3860-based board won't load the 64-bit kernel, either before or
after the change, and I didn't chase that down.
2011-06-04 07:06:05 +00:00
|
|
|
temp = cf_inw_16(TF_DATA);
|
2009-06-14 03:47:44 +00:00
|
|
|
*ptr_16++ = SWAP_SHORT(temp);
|
Add support for True IDE mode to the Octeon CF driver. This mode is
signalled when the attribute address for the CF is 0 in the octeon
sysinfo structure. In this mode, the DATA port is 16-bits, but the
other ports are 8-bits, but on a 16-bit bus (so you have to access it
a short at a time, but only believe the lower byte). See the code for
more details on this slightly odd arrangement. I'm still not 100%
happy with the abstractions here on many levels (starting with the
globals for these settings, on down to no bus_space use, etc), but the
driver had these problems before the change.
Also, clean up the code a bit to make this support easier, and the
code a bit easier to read. I tried to follow existing style, but may
have missed a few spots. Add some comments.
Fix probe/attach routine to return a proper error for the simulator.
With this change, my EBH5200 eval board now recognizes the CF well
enough to boot to the login prompt. Before it would say it never
became ready. My CN3010-EVB-HS5 still boots properly. My older
CN3860-based board won't load the 64-bit kernel, either before or
after the change, and I didn't chase that down.
2011-06-04 07:06:05 +00:00
|
|
|
if ((count & 0xf) == 0)
|
|
|
|
(void)cf_inb_16(TF_STATUS);
|
2009-06-14 03:47:44 +00:00
|
|
|
}
|
Add support for True IDE mode to the Octeon CF driver. This mode is
signalled when the attribute address for the CF is 0 in the octeon
sysinfo structure. In this mode, the DATA port is 16-bits, but the
other ports are 8-bits, but on a 16-bit bus (so you have to access it
a short at a time, but only believe the lower byte). See the code for
more details on this slightly odd arrangement. I'm still not 100%
happy with the abstractions here on many levels (starting with the
globals for these settings, on down to no bus_space use, etc), but the
driver had these problems before the change.
Also, clean up the code a bit to make this support easier, and the
code a bit easier to read. I tried to follow existing style, but may
have missed a few spots. Add some comments.
Fix probe/attach routine to return a proper error for the simulator.
With this change, my EBH5200 eval board now recognizes the CF well
enough to boot to the login prompt. Before it would say it never
became ready. My CN3010-EVB-HS5 still boots properly. My older
CN3860-based board won't load the 64-bit kernel, either before or
after the change, and I didn't chase that down.
2011-06-04 07:06:05 +00:00
|
|
|
break;
|
2009-06-14 03:47:44 +00:00
|
|
|
}
|
|
|
|
|
Add support for True IDE mode to the Octeon CF driver. This mode is
signalled when the attribute address for the CF is 0 in the octeon
sysinfo structure. In this mode, the DATA port is 16-bits, but the
other ports are 8-bits, but on a 16-bit bus (so you have to access it
a short at a time, but only believe the lower byte). See the code for
more details on this slightly odd arrangement. I'm still not 100%
happy with the abstractions here on many levels (starting with the
globals for these settings, on down to no bus_space use, etc), but the
driver had these problems before the change.
Also, clean up the code a bit to make this support easier, and the
code a bit easier to read. I tried to follow existing style, but may
have missed a few spots. Add some comments.
Fix probe/attach routine to return a proper error for the simulator.
With this change, my EBH5200 eval board now recognizes the CF well
enough to boot to the login prompt. Before it would say it never
became ready. My CN3010-EVB-HS5 still boots properly. My older
CN3860-based board won't load the 64-bit kernel, either before or
after the change, and I didn't chase that down.
2011-06-04 07:06:05 +00:00
|
|
|
lba++;
|
2009-06-14 03:47:44 +00:00
|
|
|
}
|
2010-03-06 05:49:15 +00:00
|
|
|
return (0);
|
2009-06-14 03:47:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* ------------------------------------------------------------------- *
|
|
|
|
* cf_cmd_write() *
|
|
|
|
* ------------------------------------------------------------------- *
|
|
|
|
*
|
|
|
|
* Write nr_sectors to the device starting from start_sector.
|
|
|
|
*/
|
2010-03-06 05:49:15 +00:00
|
|
|
static int cf_cmd_write (uint32_t nr_sectors, uint32_t start_sector, void *buf)
|
2009-06-14 03:47:44 +00:00
|
|
|
{
|
|
|
|
uint32_t lba;
|
|
|
|
uint32_t count;
|
|
|
|
uint16_t *ptr_16;
|
|
|
|
uint8_t *ptr_8;
|
2010-03-06 05:49:15 +00:00
|
|
|
int error;
|
2009-06-14 03:47:44 +00:00
|
|
|
|
|
|
|
lba = start_sector;
|
|
|
|
ptr_8 = (uint8_t*)buf;
|
|
|
|
ptr_16 = (uint16_t*)buf;
|
|
|
|
|
|
|
|
while (nr_sectors--) {
|
2010-03-06 05:49:15 +00:00
|
|
|
error = cf_send_cmd(lba, CMD_WRITE_SECTOR);
|
|
|
|
if (error != 0) {
|
|
|
|
printf("%s: cf_send_cmd(CMD_WRITE_SECTOR) failed: %d\n", __func__, error);
|
|
|
|
return (error);
|
|
|
|
}
|
2009-06-14 03:47:44 +00:00
|
|
|
|
Add support for True IDE mode to the Octeon CF driver. This mode is
signalled when the attribute address for the CF is 0 in the octeon
sysinfo structure. In this mode, the DATA port is 16-bits, but the
other ports are 8-bits, but on a 16-bit bus (so you have to access it
a short at a time, but only believe the lower byte). See the code for
more details on this slightly odd arrangement. I'm still not 100%
happy with the abstractions here on many levels (starting with the
globals for these settings, on down to no bus_space use, etc), but the
driver had these problems before the change.
Also, clean up the code a bit to make this support easier, and the
code a bit easier to read. I tried to follow existing style, but may
have missed a few spots. Add some comments.
Fix probe/attach routine to return a proper error for the simulator.
With this change, my EBH5200 eval board now recognizes the CF well
enough to boot to the login prompt. Before it would say it never
became ready. My CN3010-EVB-HS5 still boots properly. My older
CN3860-based board won't load the 64-bit kernel, either before or
after the change, and I didn't chase that down.
2011-06-04 07:06:05 +00:00
|
|
|
switch (bus_type)
|
|
|
|
{
|
|
|
|
case CF_8:
|
2009-06-14 03:47:44 +00:00
|
|
|
for (count = 0; count < SECTOR_SIZE; count++) {
|
Add support for True IDE mode to the Octeon CF driver. This mode is
signalled when the attribute address for the CF is 0 in the octeon
sysinfo structure. In this mode, the DATA port is 16-bits, but the
other ports are 8-bits, but on a 16-bit bus (so you have to access it
a short at a time, but only believe the lower byte). See the code for
more details on this slightly odd arrangement. I'm still not 100%
happy with the abstractions here on many levels (starting with the
globals for these settings, on down to no bus_space use, etc), but the
driver had these problems before the change.
Also, clean up the code a bit to make this support easier, and the
code a bit easier to read. I tried to follow existing style, but may
have missed a few spots. Add some comments.
Fix probe/attach routine to return a proper error for the simulator.
With this change, my EBH5200 eval board now recognizes the CF well
enough to boot to the login prompt. Before it would say it never
became ready. My CN3010-EVB-HS5 still boots properly. My older
CN3860-based board won't load the 64-bit kernel, either before or
after the change, and I didn't chase that down.
2011-06-04 07:06:05 +00:00
|
|
|
cf_outb_8(TF_DATA, *ptr_8++);
|
|
|
|
if ((count & 0xf) == 0)
|
|
|
|
(void)cf_inb_8(TF_STATUS);
|
2009-06-14 03:47:44 +00:00
|
|
|
}
|
Add support for True IDE mode to the Octeon CF driver. This mode is
signalled when the attribute address for the CF is 0 in the octeon
sysinfo structure. In this mode, the DATA port is 16-bits, but the
other ports are 8-bits, but on a 16-bit bus (so you have to access it
a short at a time, but only believe the lower byte). See the code for
more details on this slightly odd arrangement. I'm still not 100%
happy with the abstractions here on many levels (starting with the
globals for these settings, on down to no bus_space use, etc), but the
driver had these problems before the change.
Also, clean up the code a bit to make this support easier, and the
code a bit easier to read. I tried to follow existing style, but may
have missed a few spots. Add some comments.
Fix probe/attach routine to return a proper error for the simulator.
With this change, my EBH5200 eval board now recognizes the CF well
enough to boot to the login prompt. Before it would say it never
became ready. My CN3010-EVB-HS5 still boots properly. My older
CN3860-based board won't load the 64-bit kernel, either before or
after the change, and I didn't chase that down.
2011-06-04 07:06:05 +00:00
|
|
|
break;
|
|
|
|
case CF_TRUE_IDE_8:
|
|
|
|
case CF_16:
|
|
|
|
default:
|
2009-06-14 03:47:44 +00:00
|
|
|
for (count = 0; count < SECTOR_SIZE; count+=2) {
|
|
|
|
uint16_t temp = *ptr_16++;
|
Add support for True IDE mode to the Octeon CF driver. This mode is
signalled when the attribute address for the CF is 0 in the octeon
sysinfo structure. In this mode, the DATA port is 16-bits, but the
other ports are 8-bits, but on a 16-bit bus (so you have to access it
a short at a time, but only believe the lower byte). See the code for
more details on this slightly odd arrangement. I'm still not 100%
happy with the abstractions here on many levels (starting with the
globals for these settings, on down to no bus_space use, etc), but the
driver had these problems before the change.
Also, clean up the code a bit to make this support easier, and the
code a bit easier to read. I tried to follow existing style, but may
have missed a few spots. Add some comments.
Fix probe/attach routine to return a proper error for the simulator.
With this change, my EBH5200 eval board now recognizes the CF well
enough to boot to the login prompt. Before it would say it never
became ready. My CN3010-EVB-HS5 still boots properly. My older
CN3860-based board won't load the 64-bit kernel, either before or
after the change, and I didn't chase that down.
2011-06-04 07:06:05 +00:00
|
|
|
cf_outw_16(TF_DATA, SWAP_SHORT(temp));
|
|
|
|
if ((count & 0xf) == 0)
|
|
|
|
(void)cf_inb_16(TF_STATUS);
|
2009-06-14 03:47:44 +00:00
|
|
|
}
|
Add support for True IDE mode to the Octeon CF driver. This mode is
signalled when the attribute address for the CF is 0 in the octeon
sysinfo structure. In this mode, the DATA port is 16-bits, but the
other ports are 8-bits, but on a 16-bit bus (so you have to access it
a short at a time, but only believe the lower byte). See the code for
more details on this slightly odd arrangement. I'm still not 100%
happy with the abstractions here on many levels (starting with the
globals for these settings, on down to no bus_space use, etc), but the
driver had these problems before the change.
Also, clean up the code a bit to make this support easier, and the
code a bit easier to read. I tried to follow existing style, but may
have missed a few spots. Add some comments.
Fix probe/attach routine to return a proper error for the simulator.
With this change, my EBH5200 eval board now recognizes the CF well
enough to boot to the login prompt. Before it would say it never
became ready. My CN3010-EVB-HS5 still boots properly. My older
CN3860-based board won't load the 64-bit kernel, either before or
after the change, and I didn't chase that down.
2011-06-04 07:06:05 +00:00
|
|
|
break;
|
2009-06-14 03:47:44 +00:00
|
|
|
}
|
|
|
|
|
Add support for True IDE mode to the Octeon CF driver. This mode is
signalled when the attribute address for the CF is 0 in the octeon
sysinfo structure. In this mode, the DATA port is 16-bits, but the
other ports are 8-bits, but on a 16-bit bus (so you have to access it
a short at a time, but only believe the lower byte). See the code for
more details on this slightly odd arrangement. I'm still not 100%
happy with the abstractions here on many levels (starting with the
globals for these settings, on down to no bus_space use, etc), but the
driver had these problems before the change.
Also, clean up the code a bit to make this support easier, and the
code a bit easier to read. I tried to follow existing style, but may
have missed a few spots. Add some comments.
Fix probe/attach routine to return a proper error for the simulator.
With this change, my EBH5200 eval board now recognizes the CF well
enough to boot to the login prompt. Before it would say it never
became ready. My CN3010-EVB-HS5 still boots properly. My older
CN3860-based board won't load the 64-bit kernel, either before or
after the change, and I didn't chase that down.
2011-06-04 07:06:05 +00:00
|
|
|
lba++;
|
2009-06-14 03:47:44 +00:00
|
|
|
}
|
2010-03-06 05:49:15 +00:00
|
|
|
return (0);
|
2009-06-14 03:47:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* ------------------------------------------------------------------- *
|
|
|
|
* cf_cmd_identify() *
|
|
|
|
* ------------------------------------------------------------------- *
|
|
|
|
*
|
|
|
|
* Read parameters and other information from the drive and store
|
|
|
|
* it in the drive_param structure
|
|
|
|
*
|
|
|
|
*/
|
2012-03-21 10:27:12 +00:00
|
|
|
static int cf_cmd_identify(struct cf_priv *cf_priv)
|
2009-06-14 03:47:44 +00:00
|
|
|
{
|
|
|
|
int count;
|
2010-03-06 05:49:15 +00:00
|
|
|
int error;
|
2009-06-14 03:47:44 +00:00
|
|
|
|
Add support for True IDE mode to the Octeon CF driver. This mode is
signalled when the attribute address for the CF is 0 in the octeon
sysinfo structure. In this mode, the DATA port is 16-bits, but the
other ports are 8-bits, but on a 16-bit bus (so you have to access it
a short at a time, but only believe the lower byte). See the code for
more details on this slightly odd arrangement. I'm still not 100%
happy with the abstractions here on many levels (starting with the
globals for these settings, on down to no bus_space use, etc), but the
driver had these problems before the change.
Also, clean up the code a bit to make this support easier, and the
code a bit easier to read. I tried to follow existing style, but may
have missed a few spots. Add some comments.
Fix probe/attach routine to return a proper error for the simulator.
With this change, my EBH5200 eval board now recognizes the CF well
enough to boot to the login prompt. Before it would say it never
became ready. My CN3010-EVB-HS5 still boots properly. My older
CN3860-based board won't load the 64-bit kernel, either before or
after the change, and I didn't chase that down.
2011-06-04 07:06:05 +00:00
|
|
|
error = cf_send_cmd(0, CMD_IDENTIFY);
|
2010-03-06 05:49:15 +00:00
|
|
|
if (error != 0) {
|
|
|
|
printf("%s: identify failed: %d\n", __func__, error);
|
|
|
|
return (error);
|
|
|
|
}
|
Add support for True IDE mode to the Octeon CF driver. This mode is
signalled when the attribute address for the CF is 0 in the octeon
sysinfo structure. In this mode, the DATA port is 16-bits, but the
other ports are 8-bits, but on a 16-bit bus (so you have to access it
a short at a time, but only believe the lower byte). See the code for
more details on this slightly odd arrangement. I'm still not 100%
happy with the abstractions here on many levels (starting with the
globals for these settings, on down to no bus_space use, etc), but the
driver had these problems before the change.
Also, clean up the code a bit to make this support easier, and the
code a bit easier to read. I tried to follow existing style, but may
have missed a few spots. Add some comments.
Fix probe/attach routine to return a proper error for the simulator.
With this change, my EBH5200 eval board now recognizes the CF well
enough to boot to the login prompt. Before it would say it never
became ready. My CN3010-EVB-HS5 still boots properly. My older
CN3860-based board won't load the 64-bit kernel, either before or
after the change, and I didn't chase that down.
2011-06-04 07:06:05 +00:00
|
|
|
switch (bus_type)
|
|
|
|
{
|
|
|
|
case CF_8:
|
|
|
|
for (count = 0; count < SECTOR_SIZE; count++)
|
2012-03-21 10:27:12 +00:00
|
|
|
cf_priv->drive_param.u.buf[count] = cf_inb_8(TF_DATA);
|
Add support for True IDE mode to the Octeon CF driver. This mode is
signalled when the attribute address for the CF is 0 in the octeon
sysinfo structure. In this mode, the DATA port is 16-bits, but the
other ports are 8-bits, but on a 16-bit bus (so you have to access it
a short at a time, but only believe the lower byte). See the code for
more details on this slightly odd arrangement. I'm still not 100%
happy with the abstractions here on many levels (starting with the
globals for these settings, on down to no bus_space use, etc), but the
driver had these problems before the change.
Also, clean up the code a bit to make this support easier, and the
code a bit easier to read. I tried to follow existing style, but may
have missed a few spots. Add some comments.
Fix probe/attach routine to return a proper error for the simulator.
With this change, my EBH5200 eval board now recognizes the CF well
enough to boot to the login prompt. Before it would say it never
became ready. My CN3010-EVB-HS5 still boots properly. My older
CN3860-based board won't load the 64-bit kernel, either before or
after the change, and I didn't chase that down.
2011-06-04 07:06:05 +00:00
|
|
|
break;
|
|
|
|
case CF_TRUE_IDE_8:
|
|
|
|
case CF_16:
|
|
|
|
default:
|
|
|
|
for (count = 0; count < SECTOR_SIZE; count += 2) {
|
|
|
|
uint16_t temp;
|
|
|
|
temp = cf_inw_16(TF_DATA);
|
|
|
|
|
|
|
|
/* endianess will be swapped below */
|
2012-03-21 10:27:12 +00:00
|
|
|
cf_priv->drive_param.u.buf[count] = (temp & 0xff);
|
|
|
|
cf_priv->drive_param.u.buf[count + 1] = (temp & 0xff00) >> 8;
|
Add support for True IDE mode to the Octeon CF driver. This mode is
signalled when the attribute address for the CF is 0 in the octeon
sysinfo structure. In this mode, the DATA port is 16-bits, but the
other ports are 8-bits, but on a 16-bit bus (so you have to access it
a short at a time, but only believe the lower byte). See the code for
more details on this slightly odd arrangement. I'm still not 100%
happy with the abstractions here on many levels (starting with the
globals for these settings, on down to no bus_space use, etc), but the
driver had these problems before the change.
Also, clean up the code a bit to make this support easier, and the
code a bit easier to read. I tried to follow existing style, but may
have missed a few spots. Add some comments.
Fix probe/attach routine to return a proper error for the simulator.
With this change, my EBH5200 eval board now recognizes the CF well
enough to boot to the login prompt. Before it would say it never
became ready. My CN3010-EVB-HS5 still boots properly. My older
CN3860-based board won't load the 64-bit kernel, either before or
after the change, and I didn't chase that down.
2011-06-04 07:06:05 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
2009-06-14 03:47:44 +00:00
|
|
|
|
2012-03-21 10:27:12 +00:00
|
|
|
cf_swap_ascii(cf_priv->drive_param.u.driveid.model, cf_priv->drive_param.model);
|
2009-06-14 03:47:44 +00:00
|
|
|
|
2012-03-21 10:27:12 +00:00
|
|
|
cf_priv->drive_param.sector_size = 512; //= SWAP_SHORT (cf_priv->drive_param.u.driveid.sector_bytes);
|
|
|
|
cf_priv->drive_param.heads = SWAP_SHORT (cf_priv->drive_param.u.driveid.current_heads);
|
|
|
|
cf_priv->drive_param.tracks = SWAP_SHORT (cf_priv->drive_param.u.driveid.current_cylinders);
|
|
|
|
cf_priv->drive_param.sec_track = SWAP_SHORT (cf_priv->drive_param.u.driveid.current_sectors);
|
|
|
|
cf_priv->drive_param.nr_sectors = (uint32_t)SWAP_SHORT (cf_priv->drive_param.u.driveid.lba_size_1) |
|
|
|
|
((uint32_t)SWAP_SHORT (cf_priv->drive_param.u.driveid.lba_size_2));
|
2011-10-04 18:03:55 +00:00
|
|
|
if (bootverbose) {
|
2012-03-21 10:27:12 +00:00
|
|
|
printf(" model %s\n", cf_priv->drive_param.model);
|
2011-10-04 18:03:55 +00:00
|
|
|
printf(" heads %d tracks %d sec_tracks %d sectors %d\n",
|
2012-03-21 10:27:12 +00:00
|
|
|
cf_priv->drive_param.heads, cf_priv->drive_param.tracks,
|
|
|
|
cf_priv->drive_param.sec_track, cf_priv->drive_param.nr_sectors);
|
2011-10-04 18:03:55 +00:00
|
|
|
}
|
2009-06-14 03:47:44 +00:00
|
|
|
|
2010-03-06 05:49:15 +00:00
|
|
|
return (0);
|
2009-06-14 03:47:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* ------------------------------------------------------------------- *
|
|
|
|
* cf_send_cmd() *
|
|
|
|
* ------------------------------------------------------------------- *
|
|
|
|
*
|
|
|
|
* Send command to read/write one sector specified by lba.
|
|
|
|
*
|
|
|
|
*/
|
2010-03-06 05:49:15 +00:00
|
|
|
static int cf_send_cmd (uint32_t lba, uint8_t cmd)
|
2009-06-14 03:47:44 +00:00
|
|
|
{
|
Add support for True IDE mode to the Octeon CF driver. This mode is
signalled when the attribute address for the CF is 0 in the octeon
sysinfo structure. In this mode, the DATA port is 16-bits, but the
other ports are 8-bits, but on a 16-bit bus (so you have to access it
a short at a time, but only believe the lower byte). See the code for
more details on this slightly odd arrangement. I'm still not 100%
happy with the abstractions here on many levels (starting with the
globals for these settings, on down to no bus_space use, etc), but the
driver had these problems before the change.
Also, clean up the code a bit to make this support easier, and the
code a bit easier to read. I tried to follow existing style, but may
have missed a few spots. Add some comments.
Fix probe/attach routine to return a proper error for the simulator.
With this change, my EBH5200 eval board now recognizes the CF well
enough to boot to the login prompt. Before it would say it never
became ready. My CN3010-EVB-HS5 still boots properly. My older
CN3860-based board won't load the 64-bit kernel, either before or
after the change, and I didn't chase that down.
2011-06-04 07:06:05 +00:00
|
|
|
switch (bus_type)
|
|
|
|
{
|
|
|
|
case CF_8:
|
|
|
|
case CF_TRUE_IDE_8:
|
|
|
|
while (cf_inb_8(TF_STATUS) & STATUS_BSY)
|
2009-06-14 03:47:44 +00:00
|
|
|
DELAY(WAIT_DELAY);
|
Add support for True IDE mode to the Octeon CF driver. This mode is
signalled when the attribute address for the CF is 0 in the octeon
sysinfo structure. In this mode, the DATA port is 16-bits, but the
other ports are 8-bits, but on a 16-bit bus (so you have to access it
a short at a time, but only believe the lower byte). See the code for
more details on this slightly odd arrangement. I'm still not 100%
happy with the abstractions here on many levels (starting with the
globals for these settings, on down to no bus_space use, etc), but the
driver had these problems before the change.
Also, clean up the code a bit to make this support easier, and the
code a bit easier to read. I tried to follow existing style, but may
have missed a few spots. Add some comments.
Fix probe/attach routine to return a proper error for the simulator.
With this change, my EBH5200 eval board now recognizes the CF well
enough to boot to the login prompt. Before it would say it never
became ready. My CN3010-EVB-HS5 still boots properly. My older
CN3860-based board won't load the 64-bit kernel, either before or
after the change, and I didn't chase that down.
2011-06-04 07:06:05 +00:00
|
|
|
cf_outb_8(TF_SECTOR_COUNT, 1);
|
|
|
|
cf_outb_8(TF_SECTOR_NUMBER, lba & 0xff);
|
|
|
|
cf_outb_8(TF_CYL_LSB, (lba >> 8) & 0xff);
|
|
|
|
cf_outb_8(TF_CYL_MSB, (lba >> 16) & 0xff);
|
|
|
|
cf_outb_8(TF_DRV_HEAD, ((lba >> 24) & 0xff) | 0xe0);
|
|
|
|
cf_outb_8(TF_COMMAND, cmd);
|
|
|
|
break;
|
|
|
|
case CF_16:
|
|
|
|
default:
|
|
|
|
while (cf_inb_16(TF_STATUS) & STATUS_BSY)
|
2009-06-14 03:47:44 +00:00
|
|
|
DELAY(WAIT_DELAY);
|
Add support for True IDE mode to the Octeon CF driver. This mode is
signalled when the attribute address for the CF is 0 in the octeon
sysinfo structure. In this mode, the DATA port is 16-bits, but the
other ports are 8-bits, but on a 16-bit bus (so you have to access it
a short at a time, but only believe the lower byte). See the code for
more details on this slightly odd arrangement. I'm still not 100%
happy with the abstractions here on many levels (starting with the
globals for these settings, on down to no bus_space use, etc), but the
driver had these problems before the change.
Also, clean up the code a bit to make this support easier, and the
code a bit easier to read. I tried to follow existing style, but may
have missed a few spots. Add some comments.
Fix probe/attach routine to return a proper error for the simulator.
With this change, my EBH5200 eval board now recognizes the CF well
enough to boot to the login prompt. Before it would say it never
became ready. My CN3010-EVB-HS5 still boots properly. My older
CN3860-based board won't load the 64-bit kernel, either before or
after the change, and I didn't chase that down.
2011-06-04 07:06:05 +00:00
|
|
|
cf_outw_16(TF_SECTOR_COUNT, 1 | ((lba & 0xff) << 8));
|
|
|
|
cf_outw_16(TF_CYL_LSB, ((lba >> 8) & 0xff) | (((lba >> 16) & 0xff) << 8));
|
|
|
|
cf_outw_16(TF_DRV_HEAD, (((lba >> 24) & 0xff) | 0xe0) | (cmd << 8));
|
|
|
|
break;
|
2009-06-14 03:47:44 +00:00
|
|
|
}
|
|
|
|
|
2010-03-06 05:49:15 +00:00
|
|
|
return (cf_wait_busy());
|
2009-06-14 03:47:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* ------------------------------------------------------------------- *
|
|
|
|
* cf_wait_busy() *
|
|
|
|
* ------------------------------------------------------------------- *
|
|
|
|
*
|
|
|
|
* Wait until the drive finishes a given command and data is
|
|
|
|
* ready to be transferred. This is done by repeatedly checking
|
2010-03-06 05:49:15 +00:00
|
|
|
* the BSY bit of the status register. When the controller is ready for
|
|
|
|
* data transfer, it clears the BSY bit and sets the DRQ bit.
|
2009-06-14 03:47:44 +00:00
|
|
|
*
|
2010-03-06 05:49:15 +00:00
|
|
|
* If the DF bit is ever set, we return error.
|
|
|
|
*
|
|
|
|
* This code originally spun on DRQ. If that behavior turns out to be
|
|
|
|
* necessary, a flag can be added or this function can be called
|
|
|
|
* repeatedly as long as it is returning ENXIO.
|
2009-06-14 03:47:44 +00:00
|
|
|
*/
|
2010-03-06 05:49:15 +00:00
|
|
|
static int cf_wait_busy (void)
|
2009-06-14 03:47:44 +00:00
|
|
|
{
|
|
|
|
uint8_t status;
|
|
|
|
|
Add support for True IDE mode to the Octeon CF driver. This mode is
signalled when the attribute address for the CF is 0 in the octeon
sysinfo structure. In this mode, the DATA port is 16-bits, but the
other ports are 8-bits, but on a 16-bit bus (so you have to access it
a short at a time, but only believe the lower byte). See the code for
more details on this slightly odd arrangement. I'm still not 100%
happy with the abstractions here on many levels (starting with the
globals for these settings, on down to no bus_space use, etc), but the
driver had these problems before the change.
Also, clean up the code a bit to make this support easier, and the
code a bit easier to read. I tried to follow existing style, but may
have missed a few spots. Add some comments.
Fix probe/attach routine to return a proper error for the simulator.
With this change, my EBH5200 eval board now recognizes the CF well
enough to boot to the login prompt. Before it would say it never
became ready. My CN3010-EVB-HS5 still boots properly. My older
CN3860-based board won't load the 64-bit kernel, either before or
after the change, and I didn't chase that down.
2011-06-04 07:06:05 +00:00
|
|
|
switch (bus_type)
|
|
|
|
{
|
|
|
|
case CF_8:
|
|
|
|
case CF_TRUE_IDE_8:
|
|
|
|
status = cf_inb_8(TF_STATUS);
|
2010-03-06 05:49:15 +00:00
|
|
|
while ((status & STATUS_BSY) == STATUS_BSY) {
|
|
|
|
if ((status & STATUS_DF) != 0) {
|
|
|
|
printf("%s: device fault (status=%x)\n", __func__, status);
|
|
|
|
return (EIO);
|
|
|
|
}
|
2009-06-14 03:47:44 +00:00
|
|
|
DELAY(WAIT_DELAY);
|
Add support for True IDE mode to the Octeon CF driver. This mode is
signalled when the attribute address for the CF is 0 in the octeon
sysinfo structure. In this mode, the DATA port is 16-bits, but the
other ports are 8-bits, but on a 16-bit bus (so you have to access it
a short at a time, but only believe the lower byte). See the code for
more details on this slightly odd arrangement. I'm still not 100%
happy with the abstractions here on many levels (starting with the
globals for these settings, on down to no bus_space use, etc), but the
driver had these problems before the change.
Also, clean up the code a bit to make this support easier, and the
code a bit easier to read. I tried to follow existing style, but may
have missed a few spots. Add some comments.
Fix probe/attach routine to return a proper error for the simulator.
With this change, my EBH5200 eval board now recognizes the CF well
enough to boot to the login prompt. Before it would say it never
became ready. My CN3010-EVB-HS5 still boots properly. My older
CN3860-based board won't load the 64-bit kernel, either before or
after the change, and I didn't chase that down.
2011-06-04 07:06:05 +00:00
|
|
|
status = cf_inb_8(TF_STATUS);
|
2009-06-14 03:47:44 +00:00
|
|
|
}
|
Add support for True IDE mode to the Octeon CF driver. This mode is
signalled when the attribute address for the CF is 0 in the octeon
sysinfo structure. In this mode, the DATA port is 16-bits, but the
other ports are 8-bits, but on a 16-bit bus (so you have to access it
a short at a time, but only believe the lower byte). See the code for
more details on this slightly odd arrangement. I'm still not 100%
happy with the abstractions here on many levels (starting with the
globals for these settings, on down to no bus_space use, etc), but the
driver had these problems before the change.
Also, clean up the code a bit to make this support easier, and the
code a bit easier to read. I tried to follow existing style, but may
have missed a few spots. Add some comments.
Fix probe/attach routine to return a proper error for the simulator.
With this change, my EBH5200 eval board now recognizes the CF well
enough to boot to the login prompt. Before it would say it never
became ready. My CN3010-EVB-HS5 still boots properly. My older
CN3860-based board won't load the 64-bit kernel, either before or
after the change, and I didn't chase that down.
2011-06-04 07:06:05 +00:00
|
|
|
break;
|
|
|
|
case CF_16:
|
|
|
|
default:
|
|
|
|
status = cf_inb_16(TF_STATUS);
|
2010-03-06 05:49:15 +00:00
|
|
|
while ((status & STATUS_BSY) == STATUS_BSY) {
|
|
|
|
if ((status & STATUS_DF) != 0) {
|
|
|
|
printf("%s: device fault (status=%x)\n", __func__, status);
|
|
|
|
return (EIO);
|
|
|
|
}
|
2009-06-14 03:47:44 +00:00
|
|
|
DELAY(WAIT_DELAY);
|
Add support for True IDE mode to the Octeon CF driver. This mode is
signalled when the attribute address for the CF is 0 in the octeon
sysinfo structure. In this mode, the DATA port is 16-bits, but the
other ports are 8-bits, but on a 16-bit bus (so you have to access it
a short at a time, but only believe the lower byte). See the code for
more details on this slightly odd arrangement. I'm still not 100%
happy with the abstractions here on many levels (starting with the
globals for these settings, on down to no bus_space use, etc), but the
driver had these problems before the change.
Also, clean up the code a bit to make this support easier, and the
code a bit easier to read. I tried to follow existing style, but may
have missed a few spots. Add some comments.
Fix probe/attach routine to return a proper error for the simulator.
With this change, my EBH5200 eval board now recognizes the CF well
enough to boot to the login prompt. Before it would say it never
became ready. My CN3010-EVB-HS5 still boots properly. My older
CN3860-based board won't load the 64-bit kernel, either before or
after the change, and I didn't chase that down.
2011-06-04 07:06:05 +00:00
|
|
|
status = cf_inb_16(TF_STATUS);
|
2009-06-14 03:47:44 +00:00
|
|
|
}
|
Add support for True IDE mode to the Octeon CF driver. This mode is
signalled when the attribute address for the CF is 0 in the octeon
sysinfo structure. In this mode, the DATA port is 16-bits, but the
other ports are 8-bits, but on a 16-bit bus (so you have to access it
a short at a time, but only believe the lower byte). See the code for
more details on this slightly odd arrangement. I'm still not 100%
happy with the abstractions here on many levels (starting with the
globals for these settings, on down to no bus_space use, etc), but the
driver had these problems before the change.
Also, clean up the code a bit to make this support easier, and the
code a bit easier to read. I tried to follow existing style, but may
have missed a few spots. Add some comments.
Fix probe/attach routine to return a proper error for the simulator.
With this change, my EBH5200 eval board now recognizes the CF well
enough to boot to the login prompt. Before it would say it never
became ready. My CN3010-EVB-HS5 still boots properly. My older
CN3860-based board won't load the 64-bit kernel, either before or
after the change, and I didn't chase that down.
2011-06-04 07:06:05 +00:00
|
|
|
break;
|
2009-06-14 03:47:44 +00:00
|
|
|
}
|
2011-10-04 18:03:55 +00:00
|
|
|
|
|
|
|
/* DRQ is only for when read data is actually available; check BSY */
|
|
|
|
/* Some vendors do assert DRQ, but not all. Check BSY instead. */
|
|
|
|
if (status & STATUS_BSY) {
|
2010-03-06 05:49:15 +00:00
|
|
|
printf("%s: device not ready (status=%x)\n", __func__, status);
|
|
|
|
return (ENXIO);
|
|
|
|
}
|
2009-06-14 03:47:44 +00:00
|
|
|
|
2010-03-06 05:49:15 +00:00
|
|
|
return (0);
|
2009-06-14 03:47:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* ------------------------------------------------------------------- *
|
|
|
|
* cf_swap_ascii() *
|
|
|
|
* ------------------------------------------------------------------- *
|
|
|
|
*
|
|
|
|
* The ascii string returned by the controller specifying
|
|
|
|
* the model of the drive is byte-swaped. This routine
|
|
|
|
* corrects the byte ordering.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
static void cf_swap_ascii (unsigned char str1[], char str2[])
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
Add support for True IDE mode to the Octeon CF driver. This mode is
signalled when the attribute address for the CF is 0 in the octeon
sysinfo structure. In this mode, the DATA port is 16-bits, but the
other ports are 8-bits, but on a 16-bit bus (so you have to access it
a short at a time, but only believe the lower byte). See the code for
more details on this slightly odd arrangement. I'm still not 100%
happy with the abstractions here on many levels (starting with the
globals for these settings, on down to no bus_space use, etc), but the
driver had these problems before the change.
Also, clean up the code a bit to make this support easier, and the
code a bit easier to read. I tried to follow existing style, but may
have missed a few spots. Add some comments.
Fix probe/attach routine to return a proper error for the simulator.
With this change, my EBH5200 eval board now recognizes the CF well
enough to boot to the login prompt. Before it would say it never
became ready. My CN3010-EVB-HS5 still boots properly. My older
CN3860-based board won't load the 64-bit kernel, either before or
after the change, and I didn't chase that down.
2011-06-04 07:06:05 +00:00
|
|
|
for(i = 0; i < MODEL_STR_SIZE; i++)
|
|
|
|
str2[i] = str1[i ^ 1];
|
2009-06-14 03:47:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* ------------------------------------------------------------------- *
|
|
|
|
* cf_probe() *
|
|
|
|
* ------------------------------------------------------------------- */
|
|
|
|
|
|
|
|
static int cf_probe (device_t dev)
|
|
|
|
{
|
2012-10-30 06:36:14 +00:00
|
|
|
if (cvmx_sysinfo_get()->board_type == CVMX_BOARD_TYPE_SIM)
|
Add support for True IDE mode to the Octeon CF driver. This mode is
signalled when the attribute address for the CF is 0 in the octeon
sysinfo structure. In this mode, the DATA port is 16-bits, but the
other ports are 8-bits, but on a 16-bit bus (so you have to access it
a short at a time, but only believe the lower byte). See the code for
more details on this slightly odd arrangement. I'm still not 100%
happy with the abstractions here on many levels (starting with the
globals for these settings, on down to no bus_space use, etc), but the
driver had these problems before the change.
Also, clean up the code a bit to make this support easier, and the
code a bit easier to read. I tried to follow existing style, but may
have missed a few spots. Add some comments.
Fix probe/attach routine to return a proper error for the simulator.
With this change, my EBH5200 eval board now recognizes the CF well
enough to boot to the login prompt. Before it would say it never
became ready. My CN3010-EVB-HS5 still boots properly. My older
CN3860-based board won't load the 64-bit kernel, either before or
after the change, and I didn't chase that down.
2011-06-04 07:06:05 +00:00
|
|
|
return (ENXIO);
|
2009-06-14 03:47:44 +00:00
|
|
|
|
|
|
|
if (device_get_unit(dev) != 0) {
|
|
|
|
panic("can't attach more devices\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
device_set_desc(dev, "Octeon Compact Flash Driver");
|
|
|
|
|
2013-10-29 14:07:31 +00:00
|
|
|
return (BUS_PROBE_NOWILDCARD);
|
2009-06-14 03:47:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* ------------------------------------------------------------------- *
|
|
|
|
* cf_identify() *
|
|
|
|
* ------------------------------------------------------------------- *
|
|
|
|
*
|
|
|
|
* Find the bootbus region for the CF to determine
|
|
|
|
* 16 or 8 bit and check to see if device is
|
|
|
|
* inserted.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
static void cf_identify (driver_t *drv, device_t parent)
|
|
|
|
{
|
2011-10-04 18:03:55 +00:00
|
|
|
int bus_region;
|
2009-06-14 03:47:44 +00:00
|
|
|
int count = 0;
|
2011-10-04 18:03:55 +00:00
|
|
|
cvmx_mio_boot_reg_cfgx_t cfg;
|
2012-03-21 10:27:12 +00:00
|
|
|
uint64_t phys_base;
|
|
|
|
|
2012-10-30 06:36:14 +00:00
|
|
|
if (cvmx_sysinfo_get()->board_type == CVMX_BOARD_TYPE_SIM)
|
2009-06-14 06:49:13 +00:00
|
|
|
return;
|
2009-06-14 03:47:44 +00:00
|
|
|
|
2012-03-21 10:27:12 +00:00
|
|
|
phys_base = cvmx_sysinfo_get()->compact_flash_common_base_addr;
|
2012-10-31 04:23:36 +00:00
|
|
|
if (phys_base == 0)
|
|
|
|
return;
|
2011-10-04 18:03:55 +00:00
|
|
|
base_addr = cvmx_phys_to_ptr(phys_base);
|
2009-06-14 03:47:44 +00:00
|
|
|
|
|
|
|
for (bus_region = 0; bus_region < 8; bus_region++)
|
|
|
|
{
|
Update the port of FreeBSD to Cavium Octeon to use the Cavium Simple Executive
library:
o) Increase inline unit / large function growth limits for MIPS to accommodate
the needs of the Simple Executive, which uses a shocking amount of inlining.
o) Remove TARGET_OCTEON and use CPU_CNMIPS to do things required by cnMIPS and
the Octeon SoC.
o) Add OCTEON_VENDOR_LANNER to use Lanner's allocation of vendor-specific
board numbers, specifically to support the MR320.
o) Add OCTEON_BOARD_CAPK_0100ND to hard-wire configuration for the CAPK-0100nd,
which improperly uses an evaluation board's board number and breaks board
detection at runtime. This board is sold by Portwell as the CAM-0100.
o) Add support for the RTC available on some Octeon boards.
o) Add support for the Octeon PCI bus. Note that rman_[sg]et_virtual for IO
ports can not work unless building for n64.
o) Clean up the CompactFlash driver to use Simple Executive macros and
structures where possible (it would be advisable to use the Simple Executive
API to set the PIO mode, too, but that is not done presently.) Also use
structures from FreeBSD's ATA layer rather than structures copied from
Linux.
o) Print available Octeon SoC features on boot.
o) Add support for the Octeon timecounter.
o) Use the Simple Executive's routines rather than local copies for doing reads
and writes to 64-bit addresses and use its macros for various device
addresses rather than using local copies.
o) Rename octeon_board_real to octeon_is_simulation to reduce differences with
Cavium-provided code originally written for Linux. Also make it use the
same simplified test that the Simple Executive and Linux both use rather
than our complex one.
o) Add support for the Octeon CIU, which is the main interrupt unit, as a bus
to use normal interrupt allocation and setup routines.
o) Use the Simple Executive's bootmem facility to allocate physical memory for
the kernel, rather than assuming we know which addresses we can steal.
NB: This may reduce the amount of RAM the kernel reports you as having if
you are leaving large temporary allocations made by U-Boot allocated
when starting FreeBSD.
o) Add a port of the Cavium-provided Ethernet driver for Linux. This changes
Ethernet interface naming from rgmxN to octeN. The new driver has vast
improvements over the old one, both in performance and functionality, but
does still have some features which have not been ported entirely and there
may be unimplemented code that can be hit in everyday use. I will make
every effort to correct those as they are reported.
o) Support loading the kernel on non-contiguous cores.
o) Add very conservative support for harvesting randomness from the Octeon
random number device.
o) Turn SMP on by default.
o) Clean up the style of the Octeon kernel configurations a little and make
them compile with -march=octeon.
o) Add support for the Lanner MR320 and the CAPK-0100nd to the Simple
Executive.
o) Modify the Simple Executive to build on FreeBSD and to build without
executive-config.h or cvmx-config.h. In the future we may want to
revert part of these changes and supply executive-config.h and
cvmx-config.h and access to the options contained in those files via
kernel configuration files.
o) Modify the Simple Executive USB routines to support getting and setting
of the USB PID.
2010-07-20 19:25:11 +00:00
|
|
|
cfg.u64 = cvmx_read_csr(CVMX_MIO_BOOT_REG_CFGX(bus_region));
|
2011-10-04 18:03:55 +00:00
|
|
|
if (cfg.s.base == phys_base >> 16)
|
2009-06-14 03:47:44 +00:00
|
|
|
{
|
2011-10-04 18:03:55 +00:00
|
|
|
if (cvmx_sysinfo_get()->compact_flash_attribute_base_addr == 0)
|
Add support for True IDE mode to the Octeon CF driver. This mode is
signalled when the attribute address for the CF is 0 in the octeon
sysinfo structure. In this mode, the DATA port is 16-bits, but the
other ports are 8-bits, but on a 16-bit bus (so you have to access it
a short at a time, but only believe the lower byte). See the code for
more details on this slightly odd arrangement. I'm still not 100%
happy with the abstractions here on many levels (starting with the
globals for these settings, on down to no bus_space use, etc), but the
driver had these problems before the change.
Also, clean up the code a bit to make this support easier, and the
code a bit easier to read. I tried to follow existing style, but may
have missed a few spots. Add some comments.
Fix probe/attach routine to return a proper error for the simulator.
With this change, my EBH5200 eval board now recognizes the CF well
enough to boot to the login prompt. Before it would say it never
became ready. My CN3010-EVB-HS5 still boots properly. My older
CN3860-based board won't load the 64-bit kernel, either before or
after the change, and I didn't chase that down.
2011-06-04 07:06:05 +00:00
|
|
|
bus_type = CF_TRUE_IDE_8;
|
|
|
|
else
|
|
|
|
bus_type = (cfg.s.width) ? CF_16 : CF_8;
|
|
|
|
printf("Compact flash found in bootbus region %d (%s).\n", bus_region, cf_type[bus_type]);
|
2009-06-14 03:47:44 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
Add support for True IDE mode to the Octeon CF driver. This mode is
signalled when the attribute address for the CF is 0 in the octeon
sysinfo structure. In this mode, the DATA port is 16-bits, but the
other ports are 8-bits, but on a 16-bit bus (so you have to access it
a short at a time, but only believe the lower byte). See the code for
more details on this slightly odd arrangement. I'm still not 100%
happy with the abstractions here on many levels (starting with the
globals for these settings, on down to no bus_space use, etc), but the
driver had these problems before the change.
Also, clean up the code a bit to make this support easier, and the
code a bit easier to read. I tried to follow existing style, but may
have missed a few spots. Add some comments.
Fix probe/attach routine to return a proper error for the simulator.
With this change, my EBH5200 eval board now recognizes the CF well
enough to boot to the login prompt. Before it would say it never
became ready. My CN3010-EVB-HS5 still boots properly. My older
CN3860-based board won't load the 64-bit kernel, either before or
after the change, and I didn't chase that down.
2011-06-04 07:06:05 +00:00
|
|
|
switch (bus_type)
|
|
|
|
{
|
|
|
|
case CF_8:
|
|
|
|
case CF_TRUE_IDE_8:
|
2009-06-14 03:47:44 +00:00
|
|
|
/* Check if CF is inserted */
|
Add support for True IDE mode to the Octeon CF driver. This mode is
signalled when the attribute address for the CF is 0 in the octeon
sysinfo structure. In this mode, the DATA port is 16-bits, but the
other ports are 8-bits, but on a 16-bit bus (so you have to access it
a short at a time, but only believe the lower byte). See the code for
more details on this slightly odd arrangement. I'm still not 100%
happy with the abstractions here on many levels (starting with the
globals for these settings, on down to no bus_space use, etc), but the
driver had these problems before the change.
Also, clean up the code a bit to make this support easier, and the
code a bit easier to read. I tried to follow existing style, but may
have missed a few spots. Add some comments.
Fix probe/attach routine to return a proper error for the simulator.
With this change, my EBH5200 eval board now recognizes the CF well
enough to boot to the login prompt. Before it would say it never
became ready. My CN3010-EVB-HS5 still boots properly. My older
CN3860-based board won't load the 64-bit kernel, either before or
after the change, and I didn't chase that down.
2011-06-04 07:06:05 +00:00
|
|
|
while (cf_inb_8(TF_STATUS) & STATUS_BSY) {
|
|
|
|
if ((count++) == NR_TRIES ) {
|
2009-06-14 03:47:44 +00:00
|
|
|
printf("Compact Flash not present\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
DELAY(WAIT_DELAY);
|
|
|
|
}
|
Add support for True IDE mode to the Octeon CF driver. This mode is
signalled when the attribute address for the CF is 0 in the octeon
sysinfo structure. In this mode, the DATA port is 16-bits, but the
other ports are 8-bits, but on a 16-bit bus (so you have to access it
a short at a time, but only believe the lower byte). See the code for
more details on this slightly odd arrangement. I'm still not 100%
happy with the abstractions here on many levels (starting with the
globals for these settings, on down to no bus_space use, etc), but the
driver had these problems before the change.
Also, clean up the code a bit to make this support easier, and the
code a bit easier to read. I tried to follow existing style, but may
have missed a few spots. Add some comments.
Fix probe/attach routine to return a proper error for the simulator.
With this change, my EBH5200 eval board now recognizes the CF well
enough to boot to the login prompt. Before it would say it never
became ready. My CN3010-EVB-HS5 still boots properly. My older
CN3860-based board won't load the 64-bit kernel, either before or
after the change, and I didn't chase that down.
2011-06-04 07:06:05 +00:00
|
|
|
break;
|
|
|
|
case CF_16:
|
|
|
|
default:
|
2009-06-14 03:47:44 +00:00
|
|
|
/* Check if CF is inserted */
|
Add support for True IDE mode to the Octeon CF driver. This mode is
signalled when the attribute address for the CF is 0 in the octeon
sysinfo structure. In this mode, the DATA port is 16-bits, but the
other ports are 8-bits, but on a 16-bit bus (so you have to access it
a short at a time, but only believe the lower byte). See the code for
more details on this slightly odd arrangement. I'm still not 100%
happy with the abstractions here on many levels (starting with the
globals for these settings, on down to no bus_space use, etc), but the
driver had these problems before the change.
Also, clean up the code a bit to make this support easier, and the
code a bit easier to read. I tried to follow existing style, but may
have missed a few spots. Add some comments.
Fix probe/attach routine to return a proper error for the simulator.
With this change, my EBH5200 eval board now recognizes the CF well
enough to boot to the login prompt. Before it would say it never
became ready. My CN3010-EVB-HS5 still boots properly. My older
CN3860-based board won't load the 64-bit kernel, either before or
after the change, and I didn't chase that down.
2011-06-04 07:06:05 +00:00
|
|
|
while (cf_inb_16(TF_STATUS) & STATUS_BSY) {
|
|
|
|
if ((count++) == NR_TRIES ) {
|
2009-06-14 03:47:44 +00:00
|
|
|
printf("Compact Flash not present\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
DELAY(WAIT_DELAY);
|
|
|
|
}
|
Add support for True IDE mode to the Octeon CF driver. This mode is
signalled when the attribute address for the CF is 0 in the octeon
sysinfo structure. In this mode, the DATA port is 16-bits, but the
other ports are 8-bits, but on a 16-bit bus (so you have to access it
a short at a time, but only believe the lower byte). See the code for
more details on this slightly odd arrangement. I'm still not 100%
happy with the abstractions here on many levels (starting with the
globals for these settings, on down to no bus_space use, etc), but the
driver had these problems before the change.
Also, clean up the code a bit to make this support easier, and the
code a bit easier to read. I tried to follow existing style, but may
have missed a few spots. Add some comments.
Fix probe/attach routine to return a proper error for the simulator.
With this change, my EBH5200 eval board now recognizes the CF well
enough to boot to the login prompt. Before it would say it never
became ready. My CN3010-EVB-HS5 still boots properly. My older
CN3860-based board won't load the 64-bit kernel, either before or
after the change, and I didn't chase that down.
2011-06-04 07:06:05 +00:00
|
|
|
break;
|
2009-06-14 03:47:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
BUS_ADD_CHILD(parent, 0, "cf", 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* ------------------------------------------------------------------- *
|
|
|
|
* cf_attach_geom() *
|
|
|
|
* ------------------------------------------------------------------- */
|
|
|
|
|
2012-03-21 10:27:12 +00:00
|
|
|
static void cf_attach_geom (void *arg, int flag)
|
2009-06-14 03:47:44 +00:00
|
|
|
{
|
|
|
|
struct cf_priv *cf_priv;
|
|
|
|
|
|
|
|
cf_priv = (struct cf_priv *) arg;
|
|
|
|
cf_priv->cf_geom = g_new_geomf(&g_cf_class, "cf%d", device_get_unit(cf_priv->dev));
|
|
|
|
cf_priv->cf_geom->softc = cf_priv;
|
2012-03-21 10:27:12 +00:00
|
|
|
cf_priv->cf_provider = g_new_providerf(cf_priv->cf_geom, cf_priv->cf_geom->name);
|
|
|
|
cf_priv->cf_provider->sectorsize = cf_priv->drive_param.sector_size;
|
|
|
|
cf_priv->cf_provider->mediasize = cf_priv->drive_param.nr_sectors * cf_priv->cf_provider->sectorsize;
|
2009-06-14 03:47:44 +00:00
|
|
|
g_error_provider(cf_priv->cf_provider, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* ------------------------------------------------------------------- *
|
|
|
|
* cf_attach() *
|
|
|
|
* ------------------------------------------------------------------- */
|
|
|
|
|
|
|
|
static int cf_attach (device_t dev)
|
|
|
|
{
|
|
|
|
struct cf_priv *cf_priv;
|
2012-03-21 10:27:12 +00:00
|
|
|
int error;
|
2009-06-14 03:47:44 +00:00
|
|
|
|
2012-10-30 06:36:14 +00:00
|
|
|
if (cvmx_sysinfo_get()->board_type == CVMX_BOARD_TYPE_SIM)
|
Add support for True IDE mode to the Octeon CF driver. This mode is
signalled when the attribute address for the CF is 0 in the octeon
sysinfo structure. In this mode, the DATA port is 16-bits, but the
other ports are 8-bits, but on a 16-bit bus (so you have to access it
a short at a time, but only believe the lower byte). See the code for
more details on this slightly odd arrangement. I'm still not 100%
happy with the abstractions here on many levels (starting with the
globals for these settings, on down to no bus_space use, etc), but the
driver had these problems before the change.
Also, clean up the code a bit to make this support easier, and the
code a bit easier to read. I tried to follow existing style, but may
have missed a few spots. Add some comments.
Fix probe/attach routine to return a proper error for the simulator.
With this change, my EBH5200 eval board now recognizes the CF well
enough to boot to the login prompt. Before it would say it never
became ready. My CN3010-EVB-HS5 still boots properly. My older
CN3860-based board won't load the 64-bit kernel, either before or
after the change, and I didn't chase that down.
2011-06-04 07:06:05 +00:00
|
|
|
return (ENXIO);
|
2009-06-14 03:47:44 +00:00
|
|
|
|
|
|
|
cf_priv = device_get_softc(dev);
|
|
|
|
cf_priv->dev = dev;
|
|
|
|
|
2012-03-21 10:27:12 +00:00
|
|
|
error = cf_cmd_identify(cf_priv);
|
|
|
|
if (error != 0) {
|
|
|
|
device_printf(dev, "cf_cmd_identify failed: %d\n", error);
|
|
|
|
return (error);
|
|
|
|
}
|
|
|
|
|
|
|
|
g_post_event(cf_attach_geom, cf_priv, M_WAITOK, NULL);
|
2009-06-14 03:47:44 +00:00
|
|
|
bioq_init(&cf_priv->cf_bq);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static device_method_t cf_methods[] = {
|
|
|
|
/* Device interface */
|
|
|
|
DEVMETHOD(device_probe, cf_probe),
|
|
|
|
DEVMETHOD(device_identify, cf_identify),
|
|
|
|
DEVMETHOD(device_attach, cf_attach),
|
|
|
|
DEVMETHOD(device_detach, bus_generic_detach),
|
|
|
|
DEVMETHOD(device_shutdown, bus_generic_shutdown),
|
|
|
|
|
|
|
|
{ 0, 0 }
|
|
|
|
};
|
|
|
|
|
|
|
|
static driver_t cf_driver = {
|
|
|
|
"cf",
|
|
|
|
cf_methods,
|
|
|
|
sizeof(struct cf_priv)
|
|
|
|
};
|
|
|
|
|
|
|
|
static devclass_t cf_devclass;
|
|
|
|
|
|
|
|
DRIVER_MODULE(cf, nexus, cf_driver, cf_devclass, 0, 0);
|