/*
* Aic94xx SAS/SATA driver access to shared data structures and memory
* maps.
*
* Copyright (C) 2005 Adaptec, Inc. All rights reserved.
* Copyright (C) 2005 Luben Tuikov <luben_tuikov@adaptec.com>
*
* This file is licensed under GPLv2.
*
* This file is part of the aic94xx driver.
*
* The aic94xx driver is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
* published by the Free Software Foundation; version 2 of the
* License.
*
* The aic94xx driver is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with the aic94xx driver; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
*/
#include <linux/pci.h>
#include <linux/delay.h>
#include "aic94xx.h"
#include "aic94xx_reg.h"
/* ---------- OCM stuff ---------- */
struct asd_ocm_dir_ent {
u8 type;
u8 offs[3];
u8 _r1;
u8 size[3];
} __attribute__ ((packed));
struct asd_ocm_dir {
char sig[2];
u8 _r1[2];
u8 major; /* 0 */
u8 minor; /* 0 */
u8 _r2;
u8 num_de;
struct asd_ocm_dir_ent entry[15];
} __attribute__ ((packed));
#define OCM_DE_OCM_DIR 0x00
#define OCM_DE_WIN_DRVR 0x01
#define OCM_DE_BIOS_CHIM 0x02
#define OCM_DE_RAID_ENGN 0x03
#define OCM_DE_BIOS_INTL 0x04
#define OCM_DE_BIOS_CHIM_OSM 0x05
#define OCM_DE_BIOS_CHIM_DYNAMIC 0x06
#define OCM_DE_ADDC2C_RES0 0x07
#define OCM_DE_ADDC2C_RES1 0x08
#define OCM_DE_ADDC2C_RES2 0x09
#define OCM_DE_ADDC2C_RES3 0x0A
#define OCM_INIT_DIR_ENTRIES 5
/***************************************************************************
* OCM directory default
***************************************************************************/
static struct asd_ocm_dir OCMDirInit =
{
.sig = {0x4D, 0x4F}, /* signature */
.num_de = OCM_INIT_DIR_ENTRIES, /* no. of directory entries */
};
/***************************************************************************
* OCM directory Entries default
***************************************************************************/
static struct asd_ocm_dir_ent OCMDirEntriesInit[OCM_INIT_DIR_ENTRIES] =
{
{
.type = (OCM_DE_ADDC2C_RES0), /* Entry type */
.offs = {128}, /* Offset */
.size = {0, 4}, /* size */
},
{
.type = (OCM_DE_ADDC2C_RES1), /* Entry type */
.offs = {128, 4}, /* Offset */
.size = {0, 4}, /* size */
},
{
.type = (OCM_DE_ADDC2C_RES2), /* Entry type */
.offs = {128, 8}, /* Offset */
.size = {0, 4}, /* size */
},
{
.type = (OCM_DE_ADDC2C_RES3), /* Entry type */
.offs = {128, 12}, /* Offset */
.size = {0, 4}, /* size */
},
{
.type = (OCM_DE_WIN_DRVR), /* Entry type */
.offs = {128, 16}, /* Offset */
.size = {128, 235, 1}, /* size */
},
};
struct asd_bios_chim_struct {
char sig[4];
u8 major; /* 1 */
u8 minor; /* 0 */
u8 bios_major;
u8 bios_minor;
__le32 bios_build;
u8 flags;
u8 pci_slot;
__le16 ue_num;
__le16 ue_size;
u8 _r[14];
/* The unit element array is right here.
*/
} __attribute__ ((packed));
/**
* asd_read_ocm_seg - read an on chip memory (OCM) segment
* @asd_ha: pointer to the host adapter structure
* @buffer: where to write the read data
* @offs: offset into OCM where to read from
* @size: how many bytes to read
*
* Return the number of bytes not read. Return 0 on success.
*/
static int asd_read_ocm_seg(struct asd_ha_struct *asd_ha, void *buffer,
u32 offs, int size)
{
u8 *p = buffer;
if (unlikely(asd_ha->iospace))
asd_read_reg_string(asd_ha, buffer, offs+OCM_BASE_ADDR, size);
else {
for ( ; size > 0; size--, offs++, p++)
*p = asd_read_ocm_byte(asd_ha, offs);
}
return size;
}
static int asd_read_ocm_dir(struct asd_ha_struct *asd_ha,
struct asd_ocm_dir *dir, u32 offs)
{
int err = asd_read_ocm_seg(asd_ha, dir, offs, sizeof(*dir));