📄 pcmcia_ide.c
字号:
/*===============================================================*\| Project: RTEMS MBX8xx PCMCIA IDE harddisc driver |+-----------------------------------------------------------------+| File: pcmcia_ide.c |+-----------------------------------------------------------------+| Copyright (c) 2003 IMD || Ingenieurbuero fuer Microcomputertechnik Th. Doerfler || <Thomas.Doerfler@imd-systems.de> || all rights reserved |+-----------------------------------------------------------------+| this file contains the BSP layer for PCMCIA IDE access below the|| libchip IDE harddisc driver || based on a board specific driver from || Eugeny S. Mints, Oktet || || The license and distribution terms for this file may be || found in the file LICENSE in this distribution or at || http://www.rtems.com/license/LICENSE. || |+-----------------------------------------------------------------+| date history ID || ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ || 01.14.03 creation doe |\*===============================================================*/#include <rtems.h>#include <bsp.h>#include <bsp/mbx.h>#include <mpc8xx.h>#include <libchip/ide_ctrl.h>#include <libchip/ide_ctrl_cfg.h>#include <libchip/ide_ctrl_io.h>/* #define DATAREG_16BIT */ /* 16 bit mode not yet working *//* #define DEBUG_OUT *//* * support functions for PCMCIA IDE IF *//*=========================================================================*\| Function: |\*-------------------------------------------------------------------------*/boolean mbx8xx_pcmciaide_probe(/*-------------------------------------------------------------------------*\| Purpose: || This function should probe, whether a PCMCIA flash disk is available |+---------------------------------------------------------------------------+| Input Parameters: |\*-------------------------------------------------------------------------*/ int minor )/*-------------------------------------------------------------------------*\| Return Value: || TRUE, when flash disk available |\*=========================================================================*/{ boolean ide_card_plugged = TRUE; /* assume: we have a card plugged in */ /* * check, that the CD# pins are low -> a PCMCIA card is plugged in */ if ((m8xx.pipr & (M8xx_PCMCIA_PIPR_CACD1 | M8xx_PCMCIA_PIPR_CACD2)) != 0x00) { ide_card_plugged = FALSE; } /* * set supply voltage to 3.3V * FIXME: this should be depending on state of VS1/2 pins * FIXME: there should be a shadow variable for the BSP for CSR2 access */ *((volatile unsigned8 *)MBX_CSR2) = 0xb0; /* * check card information service whether card is a ATA like disk * -> scan for tuple of type 0x21 with content 0x04 0xXX (fixed disk) * -> scan for tuple of type 0x22 with content 0x01 0x01 */ if (ide_card_plugged) {#define CIS_BYTE(pos) (((unsigned8 *)PCMCIA_ATTRB_ADDR)[(pos)*2]) int cis_pos = 0; boolean fixed_disk_tuple_found = FALSE; boolean ata_disk_tuple_found = FALSE; while ((cis_pos < 256) && (CIS_BYTE(cis_pos) != 0xff) && (!fixed_disk_tuple_found || !ata_disk_tuple_found)) { /* * check for neede tuples */ if ((CIS_BYTE(cis_pos ) == 0x21) && (CIS_BYTE(cis_pos+2) == 0x04)) { fixed_disk_tuple_found = TRUE; } else if ((CIS_BYTE(cis_pos ) == 0x22) && (CIS_BYTE(cis_pos+2) == 0x01) && (CIS_BYTE(cis_pos+3) == 0x01)) { ata_disk_tuple_found = TRUE; } /* * advance using the length field */ cis_pos += CIS_BYTE(cis_pos+1)+2; } ide_card_plugged = fixed_disk_tuple_found && ata_disk_tuple_found; } return ide_card_plugged;}/*=========================================================================*\| Function: |\*-------------------------------------------------------------------------*/void mbx8xx_pcmciaide_initialize(/*-------------------------------------------------------------------------*\| Purpose: || initialize PCMCIA IDE flash card access |+---------------------------------------------------------------------------+| Input Parameters: |\*-------------------------------------------------------------------------*/ int minor /* controller minor number */ )/*-------------------------------------------------------------------------*\| Return Value: || <none> |\*=========================================================================*/{ /* * FIXME: enable interrupts, if needed */ /* * FIXME: set programming voltage as requested */}/*=========================================================================*\| Function: |\*-------------------------------------------------------------------------*/void mbx8xx_pcmciaide_read_reg(/*-------------------------------------------------------------------------*\| Purpose: || read a PCMCIA IDE controller register |+---------------------------------------------------------------------------+| Input Parameters: |\*-------------------------------------------------------------------------*/ int minor, /* controller minor number */ int reg, /* register index to access */ unsigned16 *value /* ptr to return value location */ )/*-------------------------------------------------------------------------*\| Return Value: || <none> |\*=========================================================================*/{ unsigned32 port = IDE_Controller_Table[minor].port1; if (reg == IDE_REGISTER_DATA_WORD) {#ifdef DATAREG_16BIT *value = *(volatile unsigned16 *)(port+reg); #else *value = ((*(volatile unsigned8 *)(port+reg) << 8) + (*(volatile unsigned8 *)(port+reg+1) )); #endif } else { *value = *(volatile unsigned8 *)(port+reg); }#ifdef DEBUG_OUT printk("mbx8xx_pcmciaide_read_reg(0x%x)=0x%x\r\n",reg,*value & 0xff);#endif}/*=========================================================================*\| Function: |\*-------------------------------------------------------------------------*/void mbx8xx_pcmciaide_write_reg(/*-------------------------------------------------------------------------*\| Purpose: || write a PCMCIA IDE controller register |+---------------------------------------------------------------------------+| Input Parameters: |\*-------------------------------------------------------------------------*/ int minor, /* controller minor number */ int reg, /* register index to access */ unsigned16 value /* value to write */ )/*-------------------------------------------------------------------------*\| Return Value: || <none> |\*=========================================================================*/{ unsigned32 port = IDE_Controller_Table[minor].port1;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -