summaryrefslogtreecommitdiff
path: root/firmware/target/arm/imx233/ssp-imx233.h
diff options
context:
space:
mode:
authorAmaury Pouly <pamaury@rockbox.org>2011-06-17 22:30:58 +0000
committerAmaury Pouly <pamaury@rockbox.org>2011-06-17 22:30:58 +0000
commit2cf33133820ee17e4b5d2d622db15dedff1a1f6e (patch)
tree60eddf4c3f16d5d274bc111ce53db02cfe75a6e8 /firmware/target/arm/imx233/ssp-imx233.h
parentd4800fa3851d2d89c1be03ec99af81f277892579 (diff)
downloadrockbox-2cf33133820ee17e4b5d2d622db15dedff1a1f6e.tar.gz
rockbox-2cf33133820ee17e4b5d2d622db15dedff1a1f6e.zip
fuze+: add more clocking code, add dma code, add ssp code, add stub usb code, update storage to SD + MMC, beginning of the driver
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@30010 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'firmware/target/arm/imx233/ssp-imx233.h')
-rw-r--r--firmware/target/arm/imx233/ssp-imx233.h162
1 files changed, 162 insertions, 0 deletions
diff --git a/firmware/target/arm/imx233/ssp-imx233.h b/firmware/target/arm/imx233/ssp-imx233.h
new file mode 100644
index 0000000000..e9bdf62b27
--- /dev/null
+++ b/firmware/target/arm/imx233/ssp-imx233.h
@@ -0,0 +1,162 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2011 by amaury Pouly
11 *
12 * Based on Rockbox iriver bootloader by Linus Nielsen Feltzing
13 * and the ipodlinux bootloader by Daniel Palffy and Bernard Leach
14 *
15 * This program is free software; you can redistribute it and/or
16 * modify it under the terms of the GNU General Public License
17 * as published by the Free Software Foundation; either version 2
18 * of the License, or (at your option) any later version.
19 *
20 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
21 * KIND, either express or implied.
22 *
23 ****************************************************************************/
24#ifndef __SSP_IMX233_H__
25#define __SSP_IMX233_H__
26
27#include "cpu.h"
28#include "system.h"
29#include "system-target.h"
30
31/* ssp can value 1 or 2 */
32#define __SSP_SELECT(ssp, ssp1, ssp2) ((ssp) == 1 ? (ssp1) : (ssp2))
33
34#define INT_SRC_SSP_DMA(ssp) __SSP_SELECT(ssp, INT_SRC_SSP1_DMA, INT_SRC_SSP2_DMA)
35#define INT_SRC_SSP_ERROR(ssp) __SSP_SELECT(ssp, INT_SRC_SSP1_ERROR, INT_SRC_SSP2_ERROR)
36
37#define HW_SSP1_BASE 0x80010000
38#define HW_SSP2_BASE 0x80034000
39
40#define HW_SSP_BASE(ssp) __SSP_SELECT(ssp, HW_SSP1_BASE, HW_SSP2_BASE)
41
42#define HW_SSP_CTRL0(ssp) (*(volatile uint32_t *)(HW_SSP_BASE(ssp) + 0x0))
43#define HW_SSP_CTRL0__RUN (1 << 29)
44#define HW_SSP_CTRL0__SDIO_IRQ_CHECK (1 << 28)
45#define HW_SSP_CTRL0__LOCK_CS (1 << 27)
46#define HW_SSP_CTRL0__IGNORE_CRC (1 << 26)
47#define HW_SSP_CTRL0__READ (1 << 25)
48#define HW_SSP_CTRL0__DATA_XFER (1 << 24)
49#define HW_SSP_CTRL0__BUS_WIDTH_BM (3 << 22)
50#define HW_SSP_CTRL0__BUS_WIDTH_BP 22
51#define HW_SSP_CTRL0__BUS_WIDTH__ONE_BIT 0
52#define HW_SSP_CTRL0__BUS_WIDTH__FOUR_BIT 1
53#define HW_SSP_CTRL0__BUS_WIDTH__EIGHT_BIT 2
54#define HW_SSP_CTRL0__WAIT_FOR_IRQ (1 << 21)
55#define HW_SSP_CTRL0__WAIT_FOR_CMD (1 << 20)
56#define HW_SSP_CTRL0__LONG_RESP (1 << 19)
57#define HW_SSP_CTRL0__CHECK_RESP (1 << 18)
58#define HW_SSP_CTRL0__GET_RESP (1 << 17)
59#define HW_SSP_CTRL0__ENABLE (1 << 16)
60#define HW_SSP_CTRL0__XFER_COUNT_BM 0xffff
61
62
63#define HW_SSP_CMD0(ssp) (*(volatile uint32_t *)(HW_SSP_BASE(ssp) + 0x10))
64#define HW_SSP_CMD0__SLOW_CLKING_EN (1 << 22)
65#define HW_SSP_CMD0__CONT_CLKING_EN (1 << 21)
66#define HW_SSP_CMD0__APPEND_8CYC (1 << 20)
67#define HW_SSP_CMD0__BLOCK_SIZE_BM (0xf << 16)
68#define HW_SSP_CMD0__BLOCK_SIZE_BP 16
69#define HW_SSP_CMD0__BLOCK_COUNT_BM (0xff << 8)
70#define HW_SSP_CMD0__BLOCK_COUNT_BP 16
71#define HW_SSP_CMD0__CMD_BM 0xff
72
73#define HW_SSP_CMD1(ssp) (*(volatile uint32_t *)(HW_SSP_BASE(ssp) + 0x20))
74
75#define HW_SSP_TIMING(ssp) (*(volatile uint32_t *)(HW_SSP_BASE(ssp) + 0x50))
76#define HW_SSP_TIMING__CLOCK_TIMEOUT_BM 0xffff0000
77#define HW_SSP_TIMING__CLOCK_TIMEOUT_BP 16
78#define HW_SSP_TIMING__CLOCK_DIVIDE_BM 0xff00
79#define HW_SSP_TIMING__CLOCK_DIVIDE_BP 8
80#define HW_SSP_TIMING__CLOCK_RATE_BM 0xff
81
82#define HW_SSP_CTRL1(ssp) (*(volatile uint32_t *)(HW_SSP_BASE(ssp) + 0x60))
83#define HW_SSP_CTRL1__SDIO_IRQ (1 << 31)
84#define HW_SSP_CTRL1__SDIO_IRQ_EN (1 << 30)
85#define HW_SSP_CTRL1__RESP_ERR_IRQ (1 << 29)
86#define HW_SSP_CTRL1__RESP_ERR_IRQ_EN (1 << 28)
87#define HW_SSP_CTRL1__RESP_TIMEOUT_IRQ (1 << 27)
88#define HW_SSP_CTRL1__RESP_TIMEOUT_IRQ_EN (1 << 26)
89#define HW_SSP_CTRL1__DATA_TIMEOUT_IRQ (1 << 25)
90#define HW_SSP_CTRL1__DATA_TIMEOUT_IRQ_EN (1 << 24)
91#define HW_SSP_CTRL1__DATA_CRC_IRQ (1 << 23)
92#define HW_SSP_CTRL1__DATA_CRC_IRQ_EN (1 << 22)
93#define HW_SSP_CTRL1__FIFO_UNDERRUN_IRQ (1 << 21)
94#define HW_SSP_CTRL1__FIFO_UNDERRUN_IRQ_EN (1 << 20)
95#define HW_SSP_CTRL1__RECV_TIMEOUT_IRQ (1 << 17)
96#define HW_SSP_CTRL1__RECV_TIMEOUT_IRQ_EN (1 << 16)
97#define HW_SSP_CTRL1__FIFO_OVERRUN_IRQ (1 << 15)
98#define HW_SSP_CTRL1__FIFO_OVERRUN_IRQ_EN (1 << 14)
99#define HW_SSP_CTRL1__DMA_ENABLE (1 << 13)
100#define HW_SSP_CTRL1__SLAVE_OUT_DISABLE (1 << 11)
101#define HW_SSP_CTRL1__PHASE (1 << 10)
102#define HW_SSP_CTRL1__POLARITY (1 << 9)
103#define HW_SSP_CTRL1__SLAVE_MODE (1 << 8)
104#define HW_SSP_CTRL1__WORD_LENGTH_BM (0xf << 4)
105#define HW_SSP_CTRL1__WORD_LENGTH_BP 4
106#define HW_SSP_CTRL1__WORD_LENGTH__EIGHT_BITS 0x7
107#define HW_SSP_CTRL1__SSP_MODE_BM 0xf
108#define HW_SSP_CTRL1__SSP_MODE__SD_MMC 0x3
109#define HW_SSP_CTRL1__ALL_IRQ 0xaaa28000
110
111#define HW_SSP_DATA(ssp) (*(volatile uint32_t *)(HW_SSP_BASE(ssp) + 0x70))
112
113#define HW_SSP_SDRESP0(ssp) (*(volatile uint32_t *)(HW_SSP_BASE(ssp) + 0x80))
114#define HW_SSP_SDRESP1(ssp) (*(volatile uint32_t *)(HW_SSP_BASE(ssp) + 0x90))
115#define HW_SSP_SDRESP2(ssp) (*(volatile uint32_t *)(HW_SSP_BASE(ssp) + 0xA0))
116#define HW_SSP_SDRESP3(ssp) (*(volatile uint32_t *)(HW_SSP_BASE(ssp) + 0xB0))
117
118#define HW_SSP_STATUS(ssp) (*(volatile uint32_t *)(HW_SSP_BASE(ssp) + 0xC0))
119#define HW_SSP_STATUS__RECV_TIMEOUT_STAT (1 << 11)
120#define HW_SSP_STATUS__TIMEOUT (1 << 12)
121#define HW_SSP_STATUS__DATA_CRC_ERR (1 << 13)
122#define HW_SSP_STATUS__RESP_TIMEOUT (1 << 14)
123#define HW_SSP_STATUS__RESP_ERR (1 << 15)
124#define HW_SSP_STATUS__RESP_CRC_ERR (1 << 16)
125#define HW_SSP_STATUS__ALL_ERRORS 0x1f800
126
127#define HW_SSP_DEBUG(ssp) (*(volatile uint32_t *)(HW_SSP_BASE(ssp) + 0x100))
128
129#define HW_SSP_VERSION(ssp) (*(volatile uint32_t *)(HW_SSP_BASE(ssp) + 0x110))
130
131enum imx233_ssp_error_t
132{
133 SSP_SUCCESS = 0,
134 SSP_ERROR = -1,
135 SSP_TIMEOUT = -2,
136};
137
138enum imx233_ssp_resp_t
139{
140 SSP_NO_RESP = 0,
141 SSP_SHORT_RESP,
142 SSP_LONG_RESP
143};
144
145void imx233_ssp_init(void);
146void imx233_ssp_start(int ssp);
147void imx233_ssp_stop(int ssp);
148/* only softreset between start and stop or it might hang ! */
149void imx233_ssp_softreset(int ssp);
150void imx233_ssp_set_timings(int ssp, int divide, int rate);
151void imx233_ssp_set_timeout(int ssp, int timeout);
152void imx233_ssp_set_mode(int ssp, unsigned mode);
153/* SD/MMC facilities */
154enum imx233_ssp_error_t imx233_ssp_sd_mmc_transfer(int ssp, uint8_t cmd, uint32_t cmd_arg,
155 enum imx233_ssp_resp_t resp, void *buffer, int xfer_size, bool read, uint32_t *resp_ptr);
156void imx233_ssp_setup_ssp2_sd_mmc_pins(bool enable_pullups, unsigned bus_width,
157 unsigned drive_strength);
158/* SD/MMC requires that the card be provided the clock during an init sequence of
159 * at least 1msec (or 74 clocks). Does NOT touch the clock so it has to be correct. */
160void imx233_ssp_sd_mmc_power_up_sequence(int ssp);
161
162#endif /* __SSP_IMX233_H__ */