mtk_spi_v1.h revision 297671
1297671Ssgalabov/*- 2297671Ssgalabov * Copyright (c) 2009, Oleksandr Tymoshenko <gonzo@FreeBSD.org> 3297671Ssgalabov * Copyright (c) 2011, Aleksandr Rybalko <ray@FreeBSD.org> 4297671Ssgalabov * Copyright (c) 2013, Alexander A. Mityaev <sansan@adm.ua> 5297671Ssgalabov * Copyright (c) 2016, Stanislav Galabov <sgalabov@gmail.com> 6297671Ssgalabov * All rights reserved. 7297671Ssgalabov * 8297671Ssgalabov * Redistribution and use in source and binary forms, with or without 9297671Ssgalabov * modification, are permitted provided that the following conditions 10297671Ssgalabov * are met: 11297671Ssgalabov * 1. Redistributions of source code must retain the above copyright 12297671Ssgalabov * notice unmodified, this list of conditions, and the following 13297671Ssgalabov * disclaimer. 14297671Ssgalabov * 2. Redistributions in binary form must reproduce the above copyright 15297671Ssgalabov * notice, this list of conditions and the following disclaimer in the 16297671Ssgalabov * documentation and/or other materials provided with the distribution. 17297671Ssgalabov * 18297671Ssgalabov * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 19297671Ssgalabov * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 20297671Ssgalabov * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 21297671Ssgalabov * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 22297671Ssgalabov * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 23297671Ssgalabov * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 24297671Ssgalabov * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 25297671Ssgalabov * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 26297671Ssgalabov * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 27297671Ssgalabov * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 28297671Ssgalabov * SUCH DAMAGE. 29297671Ssgalabov * 30297671Ssgalabov * $FreeBSD: head/sys/mips/mediatek/mtk_spi_v1.h 297671 2016-04-07 11:21:42Z sgalabov $ 31297671Ssgalabov */ 32297671Ssgalabov 33297671Ssgalabov#ifndef _MTK_SPIVAR_H_ 34297671Ssgalabov#define _MTK_SPIVAR_H_ 35297671Ssgalabov 36297671Ssgalabov/* SPI controller interface */ 37297671Ssgalabov 38297671Ssgalabov#define MTK_SPISTAT 0x00 39297671Ssgalabov/* SPIBUSY is alias for SPIBUSY, because SPISTAT have only BUSY bit*/ 40297671Ssgalabov#define MTK_SPIBUSY MTK_SPISTAT 41297671Ssgalabov 42297671Ssgalabov#define MTK_SPICFG 0x10 43297671Ssgalabov#define MSBFIRST (1<<8) 44297671Ssgalabov#define SPICLKPOL (1<<6) 45297671Ssgalabov#define CAPT_ON_CLK_FALL (1<<5) 46297671Ssgalabov#define TX_ON_CLK_FALL (1<<4) 47297671Ssgalabov#define HIZSPI (1<<3) /* Set SPI pins to Tri-state */ 48297671Ssgalabov#define SPI_CLK_SHIFT 0 /* SPI clock divide control */ 49297671Ssgalabov#define SPI_CLK_MASK 0x00000007 50297671Ssgalabov#define SPI_CLK_DIV2 0 51297671Ssgalabov#define SPI_CLK_DIV4 1 52297671Ssgalabov#define SPI_CLK_DIV8 2 53297671Ssgalabov#define SPI_CLK_DIV16 3 54297671Ssgalabov#define SPI_CLK_DIV32 4 55297671Ssgalabov#define SPI_CLK_DIV64 5 56297671Ssgalabov#define SPI_CLK_DIV128 6 57297671Ssgalabov#define SPI_CLK_DISABLED 7 58297671Ssgalabov 59297671Ssgalabov#define MTK_SPICTL 0x14 60297671Ssgalabov#define HIZSMOSI (1<<3) 61297671Ssgalabov#define START_WRITE (1<<2) 62297671Ssgalabov#define START_READ (1<<1) 63297671Ssgalabov#define CS_HIGH (1<<0) 64297671Ssgalabov 65297671Ssgalabov#define MTK_SPIDATA 0x20 66297671Ssgalabov#define SPIDATA_MASK 0x000000ff 67297671Ssgalabov 68297671Ssgalabov#define MTK_SPI_WRITE 1 69297671Ssgalabov#define MTK_SPI_READ 0 70297671Ssgalabov 71297671Ssgalabov#endif /* _MTK_SPIVAR_H_ */ 72