text: /*
   * sys-spi.c
   *
   * Copyright(c) 2007-2021 Jianjun Jiang <8192542@qq.com>
   * Official site: http://xboot.org
   * Mobile phone: +86-18665388956
   * QQ: 8192542
   *
   * Permission is hereby granted, free of charge, to any person obtaining a copy
   * of this software and associated documentation files (the "Software"), to deal
   * in the Software without restriction, including without limitation the rights
   * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
   * copies of the Software, and to permit persons to whom the Software is
   * furnished to do so, subject to the following conditions:
   *
   * The above copyright notice and this permission notice shall be included in all
   * copies or substantial portions of the Software.
   *
   * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
   * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
   * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
   * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
   * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
   * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
   * SOFTWARE.
   *
   */
  
  #include <xboot.h>
  
  enum {
  	SPI_GCR	= 0x04,
  	SPI_TCR	= 0x08,
  	SPI_IER	= 0x10,
  	SPI_ISR	= 0x14,
  	SPI_FCR	= 0x18,
  	SPI_FSR	= 0x1c,
  	SPI_WCR	= 0x20,
  	SPI_CCR	= 0x24,
  	SPI_MBC	= 0x30,
  	SPI_MTC	= 0x34,
  	SPI_BCC	= 0x38,
  	SPI_TXD	= 0x200,
  	SPI_RXD	= 0x300,
  };
  
  void sys_spi_deselect(void)
  {
  	virtual_addr_t addr = 0x05010000;
  	u32_t val;
  
  	val = read32(addr + SPI_TCR);
  	val &= ~((0x3 << 4) | (0x1 << 7));
  	val |= ((0 & 0x3) << 4) | (0x1 << 7);
  	write32(addr + SPI_TCR, val);
  }
  
  