mirror of
https://git.rtems.org/rtems-libbsd/
synced 2025-06-29 08:59:13 +08:00
at91_mci: Import from FreeBSD
This commit is contained in:
parent
589220752b
commit
ea5880a3cc
1408
freebsd/sys/arm/at91/at91_mci.c
Normal file
1408
freebsd/sys/arm/at91/at91_mci.c
Normal file
File diff suppressed because it is too large
Load Diff
156
freebsd/sys/arm/at91/at91_mcireg.h
Normal file
156
freebsd/sys/arm/at91/at91_mcireg.h
Normal file
@ -0,0 +1,156 @@
|
||||
/*-
|
||||
* Copyright (c) 2006 Berndt Walter. All rights reserved.
|
||||
* Copyright (c) 2006 M. Warner Losh. 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.
|
||||
* 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 AUTHOR AND CONTRIBUTORS ``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 AUTHOR OR CONTRIBUTORS 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.
|
||||
*/
|
||||
|
||||
/* $FreeBSD$ */
|
||||
|
||||
#ifndef ARM_AT91_AT91_MCIREG_H
|
||||
#define ARM_AT91_AT91_MCIREG_H
|
||||
|
||||
#define MMC_MAX 30
|
||||
|
||||
#define MCI_CR 0x00 /* MCI Control Register */
|
||||
#define MCI_MR 0x04 /* MCI Mode Register */
|
||||
#define MCI_DTOR 0x08 /* MCI Data Timeout Register */
|
||||
#define MCI_SDCR 0x0c /* MCI SD Card Register */
|
||||
#define MCI_ARGR 0x10 /* MCI Argument Register */
|
||||
#define MCI_CMDR 0x14 /* MCI Command Register */
|
||||
#define MCI_RSPR 0x20 /* MCI Response Registers - 4 of them */
|
||||
#define MCI_RDR 0x30 /* MCI Receive Data Register */
|
||||
#define MCI_TDR 0x34 /* MCI Transmit Data Register */
|
||||
#define MCI_SR 0x40 /* MCI Status Register */
|
||||
#define MCI_IER 0x44 /* MCI Interrupt Enable Register */
|
||||
#define MCI_IDR 0x48 /* MCI Interrupt Disable Register */
|
||||
#define MCI_IMR 0x4c /* MCI Interrupt Mask Register */
|
||||
|
||||
/* -------- MCI_CR : (MCI Offset: 0x0) MCI Control Register -------- */
|
||||
#define MCI_CR_MCIEN (0x1u << 0) /* (MCI) Multimedia Interface Enable */
|
||||
#define MCI_CR_MCIDIS (0x1u << 1) /* (MCI) Multimedia Interface Disable */
|
||||
#define MCI_CR_PWSEN (0x1u << 2) /* (MCI) Power Save Mode Enable */
|
||||
#define MCI_CR_PWSDIS (0x1u << 3) /* (MCI) Power Save Mode Disable */
|
||||
#define MCI_CR_SWRST (0x1u << 7) /* (MCI) Software Reset */
|
||||
/* -------- MCI_MR : (MCI Offset: 0x4) MCI Mode Register -------- */
|
||||
#define MCI_MR_CLKDIV (0xffu << 0) /* (MCI) Clock Divider */
|
||||
#define MCI_MR_PWSDIV (0x3fu << 8) /* (MCI) Power Saving Divider */
|
||||
#define MCI_MR_RDPROOF (0x1u << 11) /* (MCI) Read Proof Enable */
|
||||
#define MCI_MR_WRPROOF (0x1u << 12) /* (MCI) Write Proof Enable */
|
||||
#define MCI_MR_PDCFBYTE (0x1u << 13) /* (MCI) PDC Force Byte Transfer */
|
||||
#define MCI_MR_PDCPADV (0x1u << 14) /* (MCI) PDC Padding Value */
|
||||
#define MCI_MR_PDCMODE (0x1u << 15) /* (MCI) PDC Oriented Mode */
|
||||
#define MCI_MR_BLKLEN 0x3fff0000ul /* (MCI) Data Block Length */
|
||||
/* -------- MCI_DTOR : (MCI Offset: 0x8) MCI Data Timeout Register -------- */
|
||||
#define MCI_DTOR_DTOCYC (0xfu << 0) /* (MCI) Data Timeout Cycle Number */
|
||||
#define MCI_DTOR_DTOMUL (0x7u << 4) /* (MCI) Data Timeout Multiplier */
|
||||
#define MCI_DTOR_DTOMUL_1 (0x0u << 4) /* (MCI) DTOCYC x 1 */
|
||||
#define MCI_DTOR_DTOMUL_16 (0x1u << 4) /* (MCI) DTOCYC x 16 */
|
||||
#define MCI_DTOR_DTOMUL_128 (0x2u << 4) /* (MCI) DTOCYC x 128 */
|
||||
#define MCI_DTOR_DTOMUL_256 (0x3u << 4) /* (MCI) DTOCYC x 256 */
|
||||
#define MCI_DTOR_DTOMUL_1k (0x4u << 4) /* (MCI) DTOCYC x 1024 */
|
||||
#define MCI_DTOR_DTOMUL_4k (0x5u << 4) /* (MCI) DTOCYC x 4096 */
|
||||
#define MCI_DTOR_DTOMUL_64k (0x6u << 4) /* (MCI) DTOCYC x 65536 */
|
||||
#define MCI_DTOR_DTOMUL_1M (0x7u << 4) /* (MCI) DTOCYC x 1048576 */
|
||||
/* -------- MCI_SDCR : (MCI Offset: 0xc) MCI SD Card Register -------- */
|
||||
#define MCI_SDCR_SDCSEL (0x1u << 0) /* (MCI) SD Card Selector */
|
||||
#define MCI_SDCR_SDCBUS (0x1u << 7) /* (MCI) SD Card Bus Width */
|
||||
/* -------- MCI_CMDR : (MCI Offset: 0x14) MCI Command Register -------- */
|
||||
#define MCI_CMDR_CMDNB (0x1Fu << 0) /* (MCI) Command Number */
|
||||
#define MCI_CMDR_RSPTYP (0x3u << 6) /* (MCI) Response Type */
|
||||
#define MCI_CMDR_RSPTYP_NO (0x0u << 6) /* (MCI) No response */
|
||||
#define MCI_CMDR_RSPTYP_48 (0x1u << 6) /* (MCI) 48-bit response */
|
||||
#define MCI_CMDR_RSPTYP_136 (0x2u << 6) /* (MCI) 136-bit response */
|
||||
#define MCI_CMDR_SPCMD (0x7u << 8) /* (MCI) Special CMD */
|
||||
#define MCI_CMDR_SPCMD_NONE (0x0u << 8) /* (MCI) Not a special CMD */
|
||||
#define MCI_CMDR_SPCMD_INIT (0x1u << 8) /* (MCI) Initialization CMD */
|
||||
#define MCI_CMDR_SPCMD_SYNC (0x2u << 8) /* (MCI) Synchronized CMD */
|
||||
#define MCI_CMDR_SPCMD_IT_CMD (0x4u << 8) /* (MCI) Interrupt command */
|
||||
#define MCI_CMDR_SPCMD_IT_REP (0x5u << 8) /* (MCI) Interrupt response */
|
||||
#define MCI_CMDR_OPDCMD (0x1u << 11) /* (MCI) Open Drain Command */
|
||||
#define MCI_CMDR_MAXLAT (0x1u << 12) /* (MCI) Maximum Latency for Command to respond */
|
||||
#define MCI_CMDR_TRCMD (0x3u << 16) /* (MCI) Transfer CMD */
|
||||
#define MCI_CMDR_TRCMD_NO (0x0u << 16) /* (MCI) No transfer */
|
||||
#define MCI_CMDR_TRCMD_START (0x1u << 16) /* (MCI) Start transfer */
|
||||
#define MCI_CMDR_TRCMD_STOP (0x2u << 16) /* (MCI) Stop transfer */
|
||||
#define MCI_CMDR_TRDIR (0x1u << 18) /* (MCI) Transfer Direction */
|
||||
#define MCI_CMDR_TRTYP (0x3u << 19) /* (MCI) Transfer Type */
|
||||
#define MCI_CMDR_TRTYP_BLOCK (0x0u << 19) /* (MCI) Block Transfer type */
|
||||
#define MCI_CMDR_TRTYP_MULTIPLE (0x1u << 19) /* (MCI) Multiple Block transfer type */
|
||||
#define MCI_CMDR_TRTYP_STREAM (0x2u << 19) /* (MCI) Stream transfer type */
|
||||
/* -------- MCI_SR : (MCI Offset: 0x40) MCI Status Register -------- */
|
||||
#define MCI_SR_CMDRDY (0x1u << 0) /* (MCI) Command Ready flag */
|
||||
#define MCI_SR_RXRDY (0x1u << 1) /* (MCI) RX Ready flag */
|
||||
#define MCI_SR_TXRDY (0x1u << 2) /* (MCI) TX Ready flag */
|
||||
#define MCI_SR_BLKE (0x1u << 3) /* (MCI) Data Block Transfer Ended flag */
|
||||
#define MCI_SR_DTIP (0x1u << 4) /* (MCI) Data Transfer in Progress flag */
|
||||
#define MCI_SR_NOTBUSY (0x1u << 5) /* (MCI) Data Line Not Busy flag */
|
||||
#define MCI_SR_ENDRX (0x1u << 6) /* (MCI) End of RX Buffer flag */
|
||||
#define MCI_SR_ENDTX (0x1u << 7) /* (MCI) End of TX Buffer flag */
|
||||
#define MCI_SR_RXBUFF (0x1u << 14) /* (MCI) RX Buffer Full flag */
|
||||
#define MCI_SR_TXBUFE (0x1u << 15) /* (MCI) TX Buffer Empty flag */
|
||||
#define MCI_SR_RINDE (0x1u << 16) /* (MCI) Response Index Error flag */
|
||||
#define MCI_SR_RDIRE (0x1u << 17) /* (MCI) Response Direction Error flag */
|
||||
#define MCI_SR_RCRCE (0x1u << 18) /* (MCI) Response CRC Error flag */
|
||||
#define MCI_SR_RENDE (0x1u << 19) /* (MCI) Response End Bit Error flag */
|
||||
#define MCI_SR_RTOE (0x1u << 20) /* (MCI) Response Time-out Error flag */
|
||||
#define MCI_SR_DCRCE (0x1u << 21) /* (MCI) data CRC Error flag */
|
||||
#define MCI_SR_DTOE (0x1u << 22) /* (MCI) Data timeout Error flag */
|
||||
#define MCI_SR_OVRE (0x1u << 30) /* (MCI) Overrun flag */
|
||||
#define MCI_SR_UNRE (0x1u << 31) /* (MCI) Underrun flag */
|
||||
|
||||
/* TXRDY,DTIP,ENDTX,TXBUFE,RTOE */
|
||||
|
||||
#define MCI_SR_BITSTRING \
|
||||
"\020" \
|
||||
"\001CMDRDY" \
|
||||
"\002RXRDY" \
|
||||
"\003TXRDY" \
|
||||
"\004BLKE" \
|
||||
"\005DTIP" \
|
||||
"\006NOTBUSY" \
|
||||
"\007ENDRX" \
|
||||
"\010ENDTX" \
|
||||
"\017RXBUFF" \
|
||||
"\020TXBUFE" \
|
||||
"\021RINDE" \
|
||||
"\022RDIRE" \
|
||||
"\023RCRCE" \
|
||||
"\024RENDE" \
|
||||
"\025RTOE" \
|
||||
"\026DCRCE" \
|
||||
"\027DTOE" \
|
||||
"\037OVRE" \
|
||||
"\040UNRE"
|
||||
|
||||
/* -------- MCI_IER : (MCI Offset: 0x44) MCI Interrupt Enable Register -------- */
|
||||
/* -------- MCI_IDR : (MCI Offset: 0x48) MCI Interrupt Disable Register -------- */
|
||||
/* -------- MCI_IMR : (MCI Offset: 0x4c) MCI Interrupt Mask Register -------- */
|
||||
|
||||
#define MCI_SR_ERROR (MCI_SR_UNRE | MCI_SR_OVRE | MCI_SR_DTOE | \
|
||||
MCI_SR_DCRCE | MCI_SR_RTOE | MCI_SR_RENDE | \
|
||||
MCI_SR_RCRCE | MCI_SR_RDIRE | MCI_SR_RINDE)
|
||||
|
||||
#define AT91C_BUS_WIDTH_1BIT 0x00
|
||||
#define AT91C_BUS_WIDTH_4BITS 0x02
|
||||
|
||||
#endif /* ARM_AT91_AT91_MCIREG_H */
|
48
freebsd/sys/arm/at91/at91_pdcreg.h
Normal file
48
freebsd/sys/arm/at91/at91_pdcreg.h
Normal file
@ -0,0 +1,48 @@
|
||||
/*-
|
||||
* Copyright (c) 2006 M. Warner Losh. 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.
|
||||
* 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 AUTHOR AND CONTRIBUTORS ``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 AUTHOR OR CONTRIBUTORS 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.
|
||||
*/
|
||||
|
||||
/* $FreeBSD$ */
|
||||
|
||||
#ifndef ARM_AT91_AT91_PDCREG_H
|
||||
#define ARM_AT91_AT91_PDCREG_H
|
||||
|
||||
#define PDC_RPR 0x100 /* PDC Receive Pointer Register */
|
||||
#define PDC_RCR 0x104 /* PDC Receive Counter Register */
|
||||
#define PDC_TPR 0x108 /* PDC Transmit Pointer Register */
|
||||
#define PDC_TCR 0x10c /* PDC Transmit Counter Register */
|
||||
#define PDC_RNPR 0x110 /* PDC Receive Next Pointer Register */
|
||||
#define PDC_RNCR 0x114 /* PDC Receive Next Counter Register */
|
||||
#define PDC_TNPR 0x118 /* PDC Transmit Next Pointer Reg */
|
||||
#define PDC_TNCR 0x11c /* PDC Transmit Next Counter Reg */
|
||||
#define PDC_PTCR 0x120 /* PDC Transfer Control Register */
|
||||
#define PDC_PTSR 0x124 /* PDC Transfer Status Register */
|
||||
|
||||
/* PTCR/PTSR */
|
||||
#define PDC_PTCR_RXTEN (1UL << 0) /* RXTEN: Receiver Transfer Enable */
|
||||
#define PDC_PTCR_RXTDIS (1UL << 1) /* RXTDIS: Receiver Transfer Disable */
|
||||
#define PDC_PTCR_TXTEN (1UL << 8) /* TXTEN: Transmitter Transfer En */
|
||||
#define PDC_PTCR_TXTDIS (1UL << 9) /* TXTDIS: Transmitter Transmit Dis */
|
||||
|
||||
#endif /* ARM_AT91_AT91_PDCREG_H */
|
90
freebsd/sys/arm/at91/at91reg.h
Normal file
90
freebsd/sys/arm/at91/at91reg.h
Normal file
@ -0,0 +1,90 @@
|
||||
/*-
|
||||
* Copyright (c) 2009 Greg Ansley 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.
|
||||
* 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 AUTHOR AND CONTRIBUTORS ``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 AUTHOR OR CONTRIBUTORS 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
* $FreeBSD$
|
||||
*/
|
||||
|
||||
#ifndef _AT91REG_H_
|
||||
#define _AT91REG_H_
|
||||
|
||||
#include <rtems/bsd/local/opt_at91.h>
|
||||
|
||||
/* Where builtin peripherals start in KVM */
|
||||
#define AT91_BASE 0xd0000000
|
||||
|
||||
/* Where builtin peripherals start PA */
|
||||
#define AT91_PA_BASE 0xf0000000
|
||||
|
||||
/* A few things that we count on being the same
|
||||
* throughout the whole family of SOCs */
|
||||
|
||||
/* SYSC System Controller */
|
||||
/* System Registers */
|
||||
#define AT91_SYS_BASE 0xffff000
|
||||
#define AT91_SYS_SIZE 0x1000
|
||||
|
||||
#define AT91_DBGU0 0x0ffff200 /* Most */
|
||||
#define AT91_DBGU1 0x0fffee00 /* SAM9263, CAP9, and SAM9G45 */
|
||||
|
||||
#define AT91_DBGU_SIZE 0x200
|
||||
#define DBGU_C1R (64) /* Chip ID1 Register */
|
||||
#define DBGU_C2R (68) /* Chip ID2 Register */
|
||||
#define DBGU_FNTR (72) /* Force NTRST Register */
|
||||
|
||||
#define AT91_CPU_VERSION_MASK 0x0000001f
|
||||
#define AT91_CPU_FAMILY_MASK 0x0ff00000
|
||||
|
||||
#define AT91_CPU_RM9200 0x09290780
|
||||
#define AT91_CPU_SAM9260 0x019803a0
|
||||
#define AT91_CPU_SAM9261 0x019703a0
|
||||
#define AT91_CPU_SAM9263 0x019607a0
|
||||
#define AT91_CPU_SAM9G10 0x819903a0
|
||||
#define AT91_CPU_SAM9G20 0x019905a0
|
||||
#define AT91_CPU_SAM9G45 0x819b05a0
|
||||
#define AT91_CPU_SAM9N12 0x819a07a0
|
||||
#define AT91_CPU_SAM9RL64 0x019b03a0
|
||||
#define AT91_CPU_SAM9X5 0x819a05a0
|
||||
|
||||
#define AT91_CPU_SAM9XE128 0x329973a0
|
||||
#define AT91_CPU_SAM9XE256 0x329a93a0
|
||||
#define AT91_CPU_SAM9XE512 0x329aa3a0
|
||||
|
||||
#define AT91_CPU_CAP9 0x039a03a0
|
||||
|
||||
#define AT91_EXID_SAM9M11 0x00000001
|
||||
#define AT91_EXID_SAM9M10 0x00000002
|
||||
#define AT91_EXID_SAM9G46 0x00000003
|
||||
#define AT91_EXID_SAM9G45 0x00000004
|
||||
|
||||
#define AT91_EXID_SAM9G15 0x00000000
|
||||
#define AT91_EXID_SAM9G35 0x00000001
|
||||
#define AT91_EXID_SAM9X35 0x00000002
|
||||
#define AT91_EXID_SAM9G25 0x00000003
|
||||
#define AT91_EXID_SAM9X25 0x00000004
|
||||
|
||||
#define AT91_IRQ_SYSTEM 1
|
||||
|
||||
#endif /* _AT91REG_H_ */
|
173
freebsd/sys/arm/at91/at91var.h
Normal file
173
freebsd/sys/arm/at91/at91var.h
Normal file
@ -0,0 +1,173 @@
|
||||
/*-
|
||||
* Copyright (c) 2005 Olivier Houchard. 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.
|
||||
* 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 AUTHOR AND CONTRIBUTORS ``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 AUTHOR OR CONTRIBUTORS 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.
|
||||
*/
|
||||
|
||||
/* $FreeBSD$ */
|
||||
|
||||
#ifndef _AT91VAR_H_
|
||||
#define _AT91VAR_H_
|
||||
|
||||
#include <sys/bus.h>
|
||||
#include <sys/rman.h>
|
||||
|
||||
#include <arm/at91/at91reg.h>
|
||||
|
||||
struct at91_softc {
|
||||
device_t dev;
|
||||
bus_space_tag_t sc_st;
|
||||
bus_space_handle_t sc_sh;
|
||||
bus_space_handle_t sc_aic_sh;
|
||||
struct rman sc_irq_rman;
|
||||
struct rman sc_mem_rman;
|
||||
};
|
||||
|
||||
struct at91_ivar {
|
||||
struct resource_list resources;
|
||||
};
|
||||
|
||||
struct cpu_devs
|
||||
{
|
||||
const char *name;
|
||||
int unit;
|
||||
bus_addr_t mem_base;
|
||||
bus_size_t mem_len;
|
||||
int irq0;
|
||||
int irq1;
|
||||
int irq2;
|
||||
const char *parent_clk;
|
||||
};
|
||||
|
||||
enum at91_soc_type {
|
||||
AT91_T_NONE = 0,
|
||||
AT91_T_CAP9,
|
||||
AT91_T_RM9200,
|
||||
AT91_T_SAM9260,
|
||||
AT91_T_SAM9261,
|
||||
AT91_T_SAM9263,
|
||||
AT91_T_SAM9G10,
|
||||
AT91_T_SAM9G20,
|
||||
AT91_T_SAM9G45,
|
||||
AT91_T_SAM9N12,
|
||||
AT91_T_SAM9RL,
|
||||
AT91_T_SAM9X5,
|
||||
};
|
||||
|
||||
enum at91_soc_subtype {
|
||||
AT91_ST_ANY = -1, /* Match any type */
|
||||
AT91_ST_NONE = 0,
|
||||
/* AT91RM9200 */
|
||||
AT91_ST_RM9200_BGA,
|
||||
AT91_ST_RM9200_PQFP,
|
||||
/* AT91SAM9260 */
|
||||
AT91_ST_SAM9XE,
|
||||
/* AT91SAM9G45 */
|
||||
AT91_ST_SAM9G45,
|
||||
AT91_ST_SAM9M10,
|
||||
AT91_ST_SAM9G46,
|
||||
AT91_ST_SAM9M11,
|
||||
/* AT91SAM9X5 */
|
||||
AT91_ST_SAM9G15,
|
||||
AT91_ST_SAM9G25,
|
||||
AT91_ST_SAM9G35,
|
||||
AT91_ST_SAM9X25,
|
||||
AT91_ST_SAM9X35,
|
||||
};
|
||||
|
||||
enum at91_soc_family {
|
||||
AT91_FAMILY_SAM9 = 0x19,
|
||||
AT91_FAMILY_SAM9XE = 0x29,
|
||||
AT91_FAMILY_RM92 = 0x92,
|
||||
};
|
||||
|
||||
#define AT91_SOC_NAME_MAX 50
|
||||
|
||||
typedef void (*DELAY_t)(int);
|
||||
typedef void (*cpu_reset_t)(void);
|
||||
typedef void (*clk_init_t)(void);
|
||||
|
||||
struct at91_soc_data {
|
||||
DELAY_t soc_delay; /* SoC specific delay function */
|
||||
cpu_reset_t soc_reset; /* SoC specific reset function */
|
||||
clk_init_t soc_clock_init; /* SoC specific clock init function */
|
||||
const int *soc_irq_prio; /* SoC specific IRQ priorities */
|
||||
const struct cpu_devs *soc_children; /* SoC specific children list */
|
||||
const uint32_t *soc_pio_base; /* SoC specific PIO base registers */
|
||||
size_t soc_pio_count; /* Count of PIO units (not pins) in SoC */
|
||||
};
|
||||
|
||||
struct at91_soc_info {
|
||||
enum at91_soc_type type;
|
||||
enum at91_soc_subtype subtype;
|
||||
enum at91_soc_family family;
|
||||
uint32_t cidr;
|
||||
uint32_t exid;
|
||||
char name[AT91_SOC_NAME_MAX];
|
||||
uint32_t dbgu_base;
|
||||
struct at91_soc_data *soc_data;
|
||||
};
|
||||
|
||||
extern struct at91_soc_info soc_info;
|
||||
|
||||
static inline int at91_is_rm92(void);
|
||||
static inline int at91_is_sam9(void);
|
||||
static inline int at91_is_sam9xe(void);
|
||||
static inline int at91_cpu_is(u_int cpu);
|
||||
|
||||
static inline int
|
||||
at91_is_rm92(void)
|
||||
{
|
||||
|
||||
return (soc_info.type == AT91_T_RM9200);
|
||||
}
|
||||
|
||||
static inline int
|
||||
at91_is_sam9(void)
|
||||
{
|
||||
|
||||
return (soc_info.family == AT91_FAMILY_SAM9);
|
||||
}
|
||||
|
||||
static inline int
|
||||
at91_is_sam9xe(void)
|
||||
{
|
||||
|
||||
return (soc_info.family == AT91_FAMILY_SAM9XE);
|
||||
}
|
||||
|
||||
static inline int
|
||||
at91_cpu_is(u_int cpu)
|
||||
{
|
||||
|
||||
return (soc_info.type == cpu);
|
||||
}
|
||||
|
||||
void at91_add_child(device_t dev, int prio, const char *name, int unit,
|
||||
bus_addr_t addr, bus_size_t size, int irq0, int irq1, int irq2);
|
||||
|
||||
extern uint32_t at91_irq_system;
|
||||
extern uint32_t at91_master_clock;
|
||||
void at91_pmc_init_clock(void);
|
||||
void at91_soc_id(void);
|
||||
|
||||
#endif /* _AT91VAR_H_ */
|
Loading…
x
Reference in New Issue
Block a user