Home | History | Annotate | Line # | Download | only in pci
      1  1.17    andvar /*	$NetBSD: pciide_pdc202xx_reg.h,v 1.17 2024/02/09 22:08:36 andvar Exp $ */
      2   1.1    bouyer 
      3   1.1    bouyer /*
      4   1.1    bouyer  * Copyright (c) 1999 Manuel Bouyer.
      5   1.1    bouyer  *
      6   1.1    bouyer  * Redistribution and use in source and binary forms, with or without
      7   1.1    bouyer  * modification, are permitted provided that the following conditions
      8   1.1    bouyer  * are met:
      9   1.1    bouyer  * 1. Redistributions of source code must retain the above copyright
     10   1.1    bouyer  *    notice, this list of conditions and the following disclaimer.
     11   1.1    bouyer  * 2. Redistributions in binary form must reproduce the above copyright
     12   1.1    bouyer  *    notice, this list of conditions and the following disclaimer in the
     13   1.1    bouyer  *    documentation and/or other materials provided with the distribution.
     14   1.1    bouyer  *
     15   1.3    bouyer  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
     16   1.3    bouyer  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     17   1.3    bouyer  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     18  1.12     perry  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
     19   1.3    bouyer  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
     20   1.3    bouyer  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     21   1.3    bouyer  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     22   1.3    bouyer  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     23   1.3    bouyer  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
     24   1.3    bouyer  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     25   1.1    bouyer  *
     26   1.1    bouyer  */
     27   1.1    bouyer 
     28   1.1    bouyer /*
     29   1.2    bouyer  * Registers definitions for PROMISE PDC20246/PDC20262 PCI IDE controller.
     30  1.17    andvar  * Unfortunately the HW docs are not publicly available. I've been able
     31   1.2    bouyer  * to get a partial one for the PDC20246, and a better one for the PDC20262
     32   1.2    bouyer  * from Promise.
     33   1.1    bouyer  */
     34   1.1    bouyer 
     35   1.1    bouyer #define PDC2xx_STATE		0x50
     36   1.2    bouyer #define PDC2xx_STATE_IDERAID		0x0001
     37   1.1    bouyer #define PDC2xx_STATE_NATIVE		0x0080
     38  1.16       rin /* controller initial state values (PDC20246 only) */
     39   1.2    bouyer #define PDC246_STATE_SHIPID		0x8000
     40   1.2    bouyer #define PDC246_STATE_IOCHRDY		0x0400
     41   1.2    bouyer #define PDC246_STATE_LBA(channel)	(0x0100 << (channel))
     42   1.2    bouyer #define PDC246_STATE_ISAIRQ		0x0008
     43   1.2    bouyer #define PDC246_STATE_EN(channel)	(0x0002 << (channel))
     44  1.16       rin /* controller initial state values (PDC20262 only) */
     45   1.2    bouyer #define PDC262_STATE_EN(chan)		(0x1000 << (chan))
     46   1.2    bouyer #define PDC262_STATE_80P(chan)		(0x0400 << (chan))
     47   1.1    bouyer 
     48   1.1    bouyer /* per-drive timings */
     49   1.1    bouyer #define PDC2xx_TIM(channel, drive) (0x60 + 4 * (drive) + 8 * (channel))
     50   1.1    bouyer #define PDC2xx_TIM_SET_PA(r, x)	(((r) & 0xfffffff0) | ((x) & 0xf))
     51   1.1    bouyer #define PDC2xx_TIM_SET_PB(r, x)	(((r) & 0xffffe0ff) | (((x) & 0x1f) << 8))
     52   1.1    bouyer #define PDC2xx_TIM_SET_MB(r, x)	(((r) & 0xffff1fff) | (((x) & 0x7) << 13))
     53   1.1    bouyer #define PDC2xx_TIM_SET_MC(r, x)	(((r) & 0xfff0ffff) | (((x) & 0xf) << 16))
     54   1.1    bouyer #define PDC2xx_TIM_PRE		0x00000010
     55   1.1    bouyer #define PDC2xx_TIM_IORDY	0x00000020
     56   1.1    bouyer #define PDC2xx_TIM_ERRDY	0x00000040
     57   1.1    bouyer #define PDC2xx_TIM_SYNC		0x00000080
     58   1.1    bouyer #define PDC2xx_TIM_DMAW		0x00100000
     59   1.1    bouyer #define PDC2xx_TIM_DMAR		0x00200000
     60   1.1    bouyer #define PDC2xx_TIM_IORDYp	0x00400000
     61   1.1    bouyer #define PDC2xx_TIM_DMARQp	0x00800000
     62   1.1    bouyer 
     63   1.5    toshii /* The following are extensions of the DMA registers */
     64   1.1    bouyer 
     65   1.2    bouyer /* Ultra-DMA mode 3/4 control (PDC20262 only, 1 byte) */
     66   1.2    bouyer #define PDC262_U66	0x11
     67   1.4    bouyer #define PDC262_U66_EN(chan) (0x2 << ((chan) *2))
     68   1.1    bouyer /* primary mode (1 byte) */
     69   1.1    bouyer #define PDC2xx_PM	0x1a
     70   1.1    bouyer /* secondary mode (1 byte) */
     71   1.1    bouyer #define PDC2xx_SM	0x1b
     72   1.1    bouyer /* System control register (4 bytes) */
     73   1.1    bouyer #define PDC2xx_SCR	0x1c
     74   1.2    bouyer #define PDC2xx_SCR_SET_GEN(r,x) (((r) & 0xffffff00) | ((x) & 0xff))
     75   1.1    bouyer #define PDC2xx_SCR_EMPTY(channel) (0x00000100 << (4 * channel))
     76   1.1    bouyer #define PDC2xx_SCR_FULL(channel) (0x00000200 << (4 * channel))
     77   1.1    bouyer #define PDC2xx_SCR_INT(channel) (0x00000400 << (4 * channel))
     78   1.1    bouyer #define PDC2xx_SCR_ERR(channel) (0x00000800 << (4 * channel))
     79   1.1    bouyer #define PDC2xx_SCR_SET_I2C(r,x) (((r) & 0xfff0ffff) | (((x) & 0xf) << 16))
     80   1.1    bouyer #define PDC2xx_SCR_SET_POLL(r,x) (((r) & 0xff0fffff) | (((x) & 0xf) << 20))
     81   1.1    bouyer #define PDC2xx_SCR_DMA		0x01000000
     82   1.1    bouyer #define PDC2xx_SCR_IORDY	0x02000000
     83  1.12     perry #define PDC2xx_SCR_G2FD		0x04000000
     84   1.1    bouyer #define PDC2xx_SCR_FLOAT	0x08000000
     85   1.1    bouyer #define PDC2xx_SCR_RSET		0x10000000
     86   1.1    bouyer #define PDC2xx_SCR_TST		0x20000000
     87  1.10    bouyer /* Values for "General Purpose Register" (PDC2026{2|5} only) */
     88   1.2    bouyer #define PDC262_SCR_GEN_LAT	0x20
     89  1.10    bouyer #define PDC265_SCR_GEN_LAT	0x03
     90   1.2    bouyer 
     91  1.16       rin /* ATAPI port (PDC20262 only, 4 bytes) */
     92   1.2    bouyer #define PDC262_ATAPI(chan) (0x20 + (4 * (chan)))
     93   1.2    bouyer #define PDC262_ATAPI_WC_MASK	0x00000fff
     94   1.2    bouyer #define PDC262_ATAPI_DMA_READ	0x00001000
     95   1.2    bouyer #define PDC262_ATAPI_DMA_WRITE	0x00002000
     96   1.2    bouyer #define PDC262_ATAPI_UDMA	0x00004000
     97   1.9  nakayama #define PDC262_ATAPI_LBA48_READ  0x05000000
     98   1.9  nakayama #define PDC262_ATAPI_LBA48_WRITE 0x06000000
     99   1.1    bouyer 
    100   1.1    bouyer /*
    101  1.16       rin  * The timings provided here comes from the PDC20262 docs. I hope they are
    102   1.8       wiz  * right for the PDC20246 too ...
    103   1.1    bouyer  */
    104   1.1    bouyer 
    105  1.14     perry static const int8_t pdc2xx_pa[] __unused =
    106   1.6   thorpej     {0x9, 0x5, 0x3, 0x2, 0x1};
    107  1.14     perry static const int8_t pdc2xx_pb[] __unused =
    108   1.6   thorpej     {0x13, 0xc, 0x8, 0x6, 0x4};
    109  1.14     perry static const int8_t pdc2xx_dma_mb[] __unused =
    110   1.6   thorpej     {0x3, 0x3, 0x3};
    111  1.14     perry static const int8_t pdc2xx_dma_mc[] __unused =
    112   1.6   thorpej     {0x5, 0x4, 0x3};
    113  1.14     perry static const int8_t pdc2xx_udma_mb[] __unused =
    114   1.6   thorpej     {0x3, 0x2, 0x1, 0x2, 0x1, 0x1};
    115  1.14     perry static const int8_t pdc2xx_udma_mc[] __unused =
    116   1.6   thorpej     {0x3, 0x2, 0x1, 0x2, 0x1, 0x1};
    117