bit more work on PATA support

This commit is contained in:
Oliver Lehmann 2012-06-14 20:24:24 +00:00
parent edcf3936b0
commit 39eed1c045
5 changed files with 142 additions and 11 deletions

View File

@ -26,7 +26,7 @@
*/
/*
* $Id: wdc_avr.c,v 1.2 2012/06/13 20:17:45 olivleh1 Exp $
* $Id: wdc_avr.c,v 1.3 2012/06/14 20:24:24 olivleh1 Exp $
*/
@ -62,6 +62,23 @@ void wdc_init_avr()
configure_pin_sck();
configure_pin_mosi();
configure_pin_mmc_cs();
/* configure the ATA interface */
configure_ata_wr();
configure_ata_rd();
configure_ata_cs0();
configure_ata_cs1();
configure_ata_da0();
configure_ata_da1();
configure_ata_da2();
ata_wr_disable();
ata_rd_disable();
ata_cs0_disable();
ata_cs1_disable();
ata_da0_disable();
ata_da1_disable();
ata_da2_disable();
}
void wdc_get_sysconf()

View File

@ -26,7 +26,7 @@
*/
/*
* $Id: wdc_avr.h,v 1.2 2012/06/13 20:17:45 olivleh1 Exp $
* $Id: wdc_avr.h,v 1.3 2012/06/14 20:24:24 olivleh1 Exp $
*/
@ -57,6 +57,10 @@
#define init_addressdecoder() PORT_ADRDEC &= ~( ( 1 << PIN_ADRDEC_ADDR0 ) | ( 1 << PIN_ADRDEC_ADDR1 ) | ( 1 << PIN_ADRDEC_ADDR2 ) )
#define enable_p8000com() PORT_ADRDEC |= ( 1 << PIN_ADRDEC_ADDR0 )
#define disable_p8000com() PORT_ADRDEC &= ~( 1 << PIN_ADRDEC_ADDR0 )
#define enable_rdwrtoata() PORT_ADRDEC |= ( 1 << PIN_ADRDEC_ADDR1 )
#define disable_rdwrtoata() PORT_ADRDEC &= ~( 1 << PIN_ADRDEC_ADDR1 )
#define enable_atalatch() PORT_ADRDEC |= ( ( 1 << PIN_ADRDEC_ADDR0 ) | ( 1 << PIN_ADRDEC_ADDR1 ))
#define disable_atalatch() PORT_ADRDEC &= ~( ( 1 << PIN_ADRDEC_ADDR0 ) | ( 1 << PIN_ADRDEC_ADDR1 ))
#define enable_sysconf() PORT_ADRDEC |= ( ( 1 << PIN_ADRDEC_ADDR0 ) | ( 1 << PIN_ADRDEC_ADDR1 ) | ( 1 << PIN_ADRDEC_ADDR2 ) )
#define disable_sysconf() PORT_ADRDEC &= ~( ( 1 << PIN_ADRDEC_ADDR0 ) | ( 1 << PIN_ADRDEC_ADDR1 ) | ( 1 << PIN_ADRDEC_ADDR2 ) )
@ -75,6 +79,30 @@
#define jumper_nn3_set() ~port_data_get() & (1<<PIN_DATA_D2)
#define jumper_nn4_set() ~port_data_get() & (1<<PIN_DATA_D3)
/* functions dealing with the ATA interface */
#define configure_ata_wr() DDR_ATARDWR |= ( 1 << PIN_ATARDWR_WR )
#define configure_ata_rd() DDR_ATARDWR |= ( 1 << PIN_ATARDWR_RD )
#define configure_ata_cs0() DDR_ATACS |= ( 1 << PIN_ATACS_CS0 )
#define configure_ata_cs1() DDR_ATACS |= ( 1 << PIN_ATACS_CS1 )
#define configure_ata_da0() DDR_ATADA |= ( 1 << PIN_ATADA_DA0 )
#define configure_ata_da1() DDR_ATADA |= ( 1 << PIN_ATADA_DA1 )
#define configure_ata_da2() DDR_ATADA |= ( 1 << PIN_ATADA_DA2 )
#define ata_wr_disable() PORT_ATARDWR |= (1<<PIN_ATARDWR_WR)
#define ata_wr_enable() PORT_ATARDWR &= ~(1<<PIN_ATARDWR_WR)
#define ata_rd_disable() PORT_ATARDWR |= (1<<PIN_ATARDWR_RD)
#define ata_rd_enable() PORT_ATARDWR &= ~(1<<PIN_ATARDWR_RD)
#define ata_cs0_disable() PORT_ATACS |= (1<<PIN_ATACS_CS0)
#define ata_cs0_enable() PORT_ATACS &= ~(1<<PIN_ATACS_CS0)
#define ata_cs1_disable() PORT_ATACS |= (1<<PIN_ATACS_CS1)
#define ata_cs1_enable() PORT_ATACS &= ~(1<<PIN_ATACS_CS1)
#define ata_da0_disable() PORT_ATADA |= (1<<PIN_ATADA_DA0)
#define ata_da0_enable() PORT_ATADA &= ~(1<<PIN_ATADA_DA0)
#define ata_da1_disable() PORT_ATADA |= (1<<PIN_ATADA_DA1)
#define ata_da1_enable() PORT_ATADA &= ~(1<<PIN_ATADA_DA1)
#define ata_da2_disable() PORT_ATADA |= (1<<PIN_ATADA_DA2)
#define ata_da2_enable() PORT_ATADA &= ~(1<<PIN_ATADA_DA2)
extern void wdc_init_avr();
extern void wdc_get_sysconf();

View File

@ -26,7 +26,7 @@
*/
/*
* $Id: wdc_config.h,v 1.15 2012/06/13 20:17:45 olivleh1 Exp $
* $Id: wdc_config.h,v 1.16 2012/06/14 20:24:24 olivleh1 Exp $
*/
@ -51,6 +51,8 @@
#define PIN_ADRDEC PIND
#define DDR_ADRDEC DDRD
#define PIN_DATA_D0 PINA0
#define PIN_DATA_D1 PINA1
#define PIN_DATA_D2 PINA2
@ -71,6 +73,7 @@
#define PIN_ADRDEC_ADDR0 PIND5
#define PIN_ADRDEC_ADDR1 PIND6
#define PIN_ADRDEC_ADDR2 PIND7
/*
* SD-Card Interface
*/
@ -83,6 +86,30 @@
#define PIN_MMC_MISO PINB6 /* AVR Port: MISO / MMC Card: Data-Out */
#define PIN_MMC_SCK PINB7 /* AVR Port: SCk / MMC Card: CLK */
/*
* ATA Interface
*/
#define PORT_ATARDWR PORTB
#define PIN_ATARDWR PINB
#define DDR_ATARDWR DDRB
#define PORT_ATACS PORTB
#define PIN_ATACS PINB
#define DDR_ATACS DDRB
#define PORT_ATADA PORTD
#define PIN_ATADA PIND
#define DDR_ATADA DDRD
#define PIN_ATARDWR_WR PINB2
#define PIN_ATARDWR_RD PINB3
#define PIN_ATACS_CS0 PINB0
#define PIN_ATACS_CS1 PINB1
#define PIN_ATADA_DA0 PIND2
#define PIN_ATADA_DA1 PIND3
#define PIN_ATADA_DA2 PIND4
/*
* maximum performance with both turned off
*

View File

@ -26,14 +26,46 @@
*/
/*
* $Id: wdc_drv_pata.c,v 1.2 2012/06/13 20:17:45 olivleh1 Exp $
* $Id: wdc_drv_pata.c,v 1.3 2012/06/14 20:24:24 olivleh1 Exp $
*/
#include <avr/io.h>
#include "wdc_config.h"
#include <avr/io.h>
#include <util/delay.h>
#include "wdc_avr.h"
#include "uart.h"
void pata_set_highbyte ( uint8_t byte )
{
port_data_set ( byte );
enable_atalatch();
nop();
nop();
disable_atalatch();
}
void pata_set_lowbyte ( uint8_t byte )
{
port_data_set ( byte );
}
void pata_send_data()
{
enable_rdwrtoata();
_delay_us(10);
// disable_rdwrtoata();
}
uint8_t pata_init ()
{
uart_putc('1');
/* test write */
configure_port_data_write();
ata_wr_enable();
pata_set_highbyte ( 0xff );
pata_set_lowbyte ( 0x00 );
pata_send_data();
// ata_wr_disable();
return 1;
}

View File

@ -1,14 +1,41 @@
/*
* wdc_drv_pata.h
/*-
* Copyright (c) 2012 Oliver Lehmann
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer
* in this position and unchanged.
* 2. 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.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* Created: 12.06.2012 21:57:08
* Author: olivleh1
*/
/*
* $Id: wdc_drv_pata.h,v 1.3 2012/06/14 20:24:24 olivleh1 Exp $
*/
#ifndef WDC_DRV_PATA_H_
#define WDC_DRV_PATA_H_
extern void pata_set_highbyte(uint8_t byte);
extern void pata_set_lowbyte(uint8_t byte);
extern void pata_send_data();
extern uint8_t pata_init ();
extern uint8_t pata_read_block ( uint32_t addr, uint8_t *buffer );