1 /* ----------------------------------------------------------------------------
\r
2 * SAM Software Package License
\r
3 * ----------------------------------------------------------------------------
\r
4 * Copyright (c) 2015, Atmel Corporation
\r
6 * All rights reserved.
\r
8 * Redistribution and use in source and binary forms, with or without
\r
9 * modification, are permitted provided that the following conditions are met:
\r
11 * - Redistributions of source code must retain the above copyright notice,
\r
12 * this list of conditions and the disclaimer below.
\r
14 * Atmel's name may not be used to endorse or promote products derived from
\r
15 * this software without specific prior written permission.
\r
17 * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR
\r
18 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
\r
19 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
\r
20 * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT,
\r
21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
\r
22 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
\r
23 * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
\r
24 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
\r
25 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
\r
26 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
\r
27 * ----------------------------------------------------------------------------
\r
33 * Definitions and function prototype for smc module
\r
39 /*----------------------------------------------------------------------------
\r
41 *----------------------------------------------------------------------------*/
\r
45 #include <stdbool.h>
\r
48 /*----------------------------------------------------------------------------
\r
50 *----------------------------------------------------------------------------*/
\r
52 #define hsmc_nfc_configure(mode) {HSMC->HSMC_CFG = mode ;}
\r
53 #define hsmc_nfc_enable() {HSMC->HSMC_CTRL |= HSMC_CTRL_NFCEN;}
\r
54 #define hsmc_nfc_disable() {HSMC->HSMC_CTRL |= HSMC_CTRL_NFCDIS;}
\r
55 #define hsmc_nfc_get_status() {HSMC->HSMC_SR;}
\r
57 #define hsmc_nfc_enable_spare_read() {HSMC->HSMC_CFG |= HSMC_CFG_RSPARE;}
\r
58 #define hsmc_nfc_disable_spare_read() {HSMC->HSMC_CFG &= (~HSMC_CFG_RSPARE);}
\r
59 #define hsmc_nfc_enable_spare_write() {HSMC->HSMC_CFG |= HSMC_CFG_WSPARE;}
\r
60 #define hsmc_nfc_disable_spare_write() {HSMC->HSMC_CFG &= (~HSMC_CFG_WSPARE);}
\r
62 #define hsmc_pmecc_reset() {HSMC->HSMC_PMECCTRL = HSMC_PMECCTRL_RST; }
\r
63 #define hsmc_pmecc_or_reset() {HSMC->HSMC_PMECCTRL |= HSMC_PMECCTRL_RST; }
\r
64 #define hsmc_pmecc_data_phase() {HSMC->HSMC_PMECCTRL |= HSMC_PMECCTRL_DATA; }
\r
65 #define hsmc_pmecc_enable_write() {HSMC->HSMC_PMECCFG |= HSMC_PMECCFG_NANDWR;}
\r
66 #define hsmc_pmecc_enable_read() {HSMC->HSMC_PMECCFG &= (~HSMC_PMECCFG_NANDWR);}
\r
68 #define hsmc_pmecc_error_status() (HSMC->HSMC_PMECCISR )
\r
69 #define hsmc_pmecc_enable() {HSMC->HSMC_PMECCTRL = HSMC_PMECCTRL_ENABLE;}
\r
70 #define hsmc_pmecc_disable() {HSMC->HSMC_PMECCTRL = HSMC_PMECCTRL_DISABLE;}
\r
71 #define hsmc_pmecc_auto_enable() {HSMC->HSMC_PMECCFG |= HSMC_PMECCFG_AUTO;}
\r
72 #define hsmc_pmecc_auto_disable() {HSMC->HSMC_PMECCFG &= (~HSMC_PMECCFG_AUTO);}
\r
73 #define hsmc_pmecc_auto_apare_en() ((HSMC->HSMC_PMECCFG & HSMC_PMECCFG_SPAREEN) == HSMC_PMECCFG_SPAREEN)
\r
74 #define hsmc_pmecc(i) (HSMC->SMC_PMECC[i])
\r
76 /*----------------------------------------------------------------------------
\r
78 *----------------------------------------------------------------------------*/
\r
80 #define HSMC_SR_RB_EDGE0 (0x1u << 24)
\r
82 /* -------- NFCADDR_CMD : NFC Address Command -------- */
\r
84 #define NFCADDR_CMD_CMD1 (0xFFu << 2) /* Command Register Value for Cycle 1 */
\r
85 #define NFCADDR_CMD_CMD2 (0xFFu << 10) /* Command Register Value for Cycle 2 */
\r
86 #define NFCADDR_CMD_VCMD2 (0x1u << 18) /* Valid Cycle 2 Command */
\r
87 #define NFCADDR_CMD_ACYCLE (0x7u << 19) /* Number of Address required for the current command */
\r
88 #define NFCADDR_CMD_ACYCLE_NONE (0x0u << 19) /* No address cycle */
\r
89 #define NFCADDR_CMD_ACYCLE_ONE (0x1u << 19) /* One address cycle */
\r
90 #define NFCADDR_CMD_ACYCLE_TWO (0x2u << 19) /* Two address cycles */
\r
91 #define NFCADDR_CMD_ACYCLE_THREE (0x3u << 19) /* Three address cycles */
\r
92 #define NFCADDR_CMD_ACYCLE_FOUR (0x4u << 19) /* Four address cycles */
\r
93 #define NFCADDR_CMD_ACYCLE_FIVE (0x5u << 19) /* Five address cycles */
\r
94 #define NFCADDR_CMD_CSID (0x7u << 22) /* Chip Select Identifier */
\r
95 #define NFCADDR_CMD_CSID_0 (0x0u << 22) /* CS0 */
\r
96 #define NFCADDR_CMD_CSID_1 (0x1u << 22) /* CS1 */
\r
97 #define NFCADDR_CMD_CSID_2 (0x2u << 22) /* CS2 */
\r
98 #define NFCADDR_CMD_CSID_3 (0x3u << 22) /* CS3 */
\r
99 #define NFCADDR_CMD_CSID_4 (0x4u << 22) /* CS4 */
\r
100 #define NFCADDR_CMD_CSID_5 (0x5u << 22) /* CS5 */
\r
101 #define NFCADDR_CMD_CSID_6 (0x6u << 22) /* CS6 */
\r
102 #define NFCADDR_CMD_CSID_7 (0x7u << 22) /* CS7 */
\r
103 #define NFCADDR_CMD_DATAEN (0x1u << 25) /* NFC Data Enable */
\r
104 #define NFCADDR_CMD_DATADIS (0x0u << 25) /* NFC Data disable */
\r
105 #define NFCADDR_CMD_NFCRD (0x0u << 26) /* NFC Read Enable */
\r
106 #define NFCADDR_CMD_NFCWR (0x1u << 26) /* NFC Write Enable */
\r
107 #define NFCADDR_CMD_NFCCMD (0x1u << 27) /* NFC Command Enable */
\r
109 /*----------------------------------------------------------------------------
\r
110 * Exported functions
\r
111 *----------------------------------------------------------------------------*/
\r
113 extern void hsmc_nand_configure(uint8_t cs, uint8_t bus_width);
\r
115 extern void hsmc_nor_configure(uint8_t cs, uint8_t bus_width);
\r
117 extern void hsmc_nfc_reset(void);
\r
119 extern bool hsmc_nfc_is_spare_read_enabled(void);
\r
121 extern bool hsmc_nfc_is_spare_write_enabled(void);
\r
123 extern bool hsmc_nfc_is_nfc_busy(void);
\r
125 extern void hsmc_wait_rb(void);
\r
127 extern void hsmc_nfc_send_cmd(uint32_t cmd, uint32_t address_cycle, uint32_t cycle0);
\r
129 extern void hsmc_nfc_wait_cmd_done(void);
\r
131 extern void hsmc_nfc_wait_xfr_done(void);
\r
133 extern void hsmc_nfc_wait_rb_busy(void);
\r
135 extern void hsmc_nfc_wait_hamming_ready(void);
\r
137 extern void hsmc_pmecc_wait_ready(void);
\r
139 #endif /* _HSMC_ */
\r