/* * SDRAM Access Routines for PIC32. * * Retromaster - 10.05.2010 * * This file is in the public domain. You can use, modify, and distribute the source code * and executable programs based on the source code. This file is provided "as is" and * without any express or implied warranties whatsoever. Use at your own risk! * * Changes by jmcgee for inclusion in the retrobsd project. */ /* SDRAM Used: HY57V281620 * SDRAM Pin to PIC32 Pin Mapping: * SDRAM PIC32 * ------ ------ * note: the order of An to RBn DOES matter * At the moment it is a bit of a mess and * needs to be cleaned up. * A0 23 RB11 * A1 24 RB12 * A2 25 RB13 * A3 26 RB14 * A4 29 RB5 * A5 30 RB4 * A6 31 RB3 * A7 32 RB2 * A8 33 RB6 * A9 34 RB7 * A10 22 RB15 * A11 35 RB9 * * BA0 20 RD4 * BA1 21 RD5 * * note: the order of DQn to RAn does not matter * DQ0 2 RA6 * DQ1 4 RA1 * DQ2 5 RA7 * DQ3 7 RA2 * DQ4 8 RA3 * DQ5 10 RA4 * DQ6 11 RA5 * DQ7 13 RA0 * CLK 38 OC1-RD0 * CKE 37 A10 * CS 19 RF12 * WE 16 RF0 * CAS 17 RF1 * RAS 18 RF13 * * SDRam 42, 44, 45, 47, 48, 50, 51, 53 - (d8-d15) should be pulled up, but * on the prototype board these were simply left floating * * Power connections not listed. */ /* * Retrobsd does not currently contain a good header * for pulling the pic32 port addresses into an assembly * file, so define some needed registers here for the moment. */ #define TRISA 0xBF886000 #define T2CON 0xBF800800 #define TMR2 0xBF800810 #define PR2 0xBF800820 #define T2CONSET 0xBF800808 #define OC1CON 0xBF803000 #define OC4CON 0xBF803600 #define OCXR_OFFSET 0x10 #define OCXRS_OFFSET 0x20 #define AD1PCFGSET 0xBF809068 /* Offsets (from TRISA) for the io ports */ #define SDR_OFFSET_A 0 #define SDR_OFFSET_B 0x40 #define SDR_OFFSET_C 0x80 #define SDR_OFFSET_D 0xc0 #define SDR_OFFSET_E 0x100 #define SDR_OFFSET_F 0x140 #define SDR_OFFSET_G 0x180 /* Offsets (from TRISA) for the various port control registers */ #define TRIS_OFFSET 0x0 #define PORT_OFFSET 0x10 #define LAT_OFFSET 0x20 #define ODCF_OFFSET 0x30 /* Offsets (from TRISA) for the various io port bit manipulator registers */ #define NOP_OP_OFFSET 0x0 #define CLR_OP_OFFSET 0x4 #define SET_OP_OFFSET 0x8 #define INV_OP_OFFSET 0xc /* * Specific assignments of ports ports used * Note: In general, it is not sufficient to * change the constants below - corresponding * changes to the code below will likely be * required if any of the following values * are changed. */ /* DATA_PORT_TRIS must be assigned to a TRIS of the port * that has the low 8 bits tied the 8 data bits on the ram. */ #define SDR_OCR OC1CON #define SDR_DATA_IO SDR_OFFSET_A #define SDR_DATA_TRIS SDR_OFFSET_A #define SDR_ADDRESS_IO SDR_OFFSET_B #define SDR_ADDRESS_TRIS SDR_OFFSET_B #define ADDRESS_MASK 0xfafc #define SDR_BANK_IO SDR_OFFSET_D #define SDR_BANK_TRIS SDR_OFFSET_D #define BANK_0_BIT 4 #define BANK_1_BIT 5 #define SDR_CONTROL_IO SDR_OFFSET_F #define SDR_CONTROL_TRIS SDR_OFFSET_F #define CONTROL_WE_BIT 0 #define CONTROL_CAS_BIT 1 #define CONTROL_CS_BIT 12 #define CONTROL_RAS_BIT 13 #define SDR_CKE_IO SDR_OFFSET_A #define SDR_CKE_TRIS SDR_OFFSET_A #define CKE_BIT 10 #define DATA_DIR_BIT 15 #define CONTROL_ALL_MASK ( (1<