<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>Kinetis Microcontrollers中的主题 Re: FSL_DSPI driver in uboot 2017</title>
    <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/FSL-DSPI-driver-in-uboot-2017/m-p/691986#M42628</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Could you provide the fsl_dspi driver source code?&lt;/P&gt;&lt;P&gt;I could check if it works with Kinetis DSPI module or not.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Have a great day,&lt;BR /&gt;Ma Hui&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;-----------------------------------------------------------------------------------------------------------------------&lt;BR /&gt;Note: If this post answers your question, please click the Correct Answer button. Thank you!&lt;BR /&gt;-----------------------------------------------------------------------------------------------------------------------&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 12 Jul 2017 05:06:15 GMT</pubDate>
    <dc:creator>Hui_Ma</dc:creator>
    <dc:date>2017-07-12T05:06:15Z</dc:date>
    <item>
      <title>FSL_DSPI driver in uboot 2017</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/FSL-DSPI-driver-in-uboot-2017/m-p/691985#M42627</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;the fsl_dspi driver in uboot 2017 is same for all nxp devices having dspi &amp;nbsp; ?&lt;/P&gt;&lt;P&gt;Can i use it for kinetis k70 dspi ,or is it defined for some other processor .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 11 Jul 2017 02:30:30 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/FSL-DSPI-driver-in-uboot-2017/m-p/691985#M42627</guid>
      <dc:creator>sameerarvikar</dc:creator>
      <dc:date>2017-07-11T02:30:30Z</dc:date>
    </item>
    <item>
      <title>Re: FSL_DSPI driver in uboot 2017</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/FSL-DSPI-driver-in-uboot-2017/m-p/691986#M42628</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Could you provide the fsl_dspi driver source code?&lt;/P&gt;&lt;P&gt;I could check if it works with Kinetis DSPI module or not.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Have a great day,&lt;BR /&gt;Ma Hui&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;-----------------------------------------------------------------------------------------------------------------------&lt;BR /&gt;Note: If this post answers your question, please click the Correct Answer button. Thank you!&lt;BR /&gt;-----------------------------------------------------------------------------------------------------------------------&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 12 Jul 2017 05:06:15 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/FSL-DSPI-driver-in-uboot-2017/m-p/691986#M42628</guid>
      <dc:creator>Hui_Ma</dc:creator>
      <dc:date>2017-07-12T05:06:15Z</dc:date>
    </item>
    <item>
      <title>Re: FSL_DSPI driver in uboot 2017</title>
      <link>https://community.nxp.com/t5/Kinetis-Microcontrollers/FSL-DSPI-driver-in-uboot-2017/m-p/691987#M42629</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Ok --&amp;gt; following is the source code&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;BLOCKQUOTE class="jive_macro_quote jive-quote jive_text_macro"&gt;&lt;P&gt;/*&lt;BR /&gt; * (C) Copyright 2000-2003&lt;BR /&gt;&lt;SPAN&gt; * Wolfgang Denk, DENX Software Engineering, &lt;/SPAN&gt;&lt;A class="jive-link-email-small" href="mailto:wd@denx.de"&gt;wd@denx.de&lt;/A&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;BR /&gt; *&lt;BR /&gt; * Copyright (C) 2004-2009, 2015 Freescale Semiconductor, Inc.&lt;BR /&gt;&lt;SPAN&gt; * TsiChung Liew (&lt;/SPAN&gt;&lt;A class="jive-link-email-small" href="mailto:Tsi-Chung.Liew@freescale.com"&gt;Tsi-Chung.Liew@freescale.com&lt;/A&gt;&lt;SPAN&gt;)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; * Chao Fu (&lt;/SPAN&gt;&lt;A class="jive-link-email-small" href="mailto:B44548@freescale.com"&gt;B44548@freescale.com&lt;/A&gt;&lt;SPAN&gt;)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; * Haikun Wang (&lt;/SPAN&gt;&lt;A class="jive-link-email-small" href="mailto:B53464@freescale.com"&gt;B53464@freescale.com&lt;/A&gt;&lt;SPAN&gt;)&lt;/SPAN&gt;&lt;BR /&gt; *&lt;BR /&gt; * SPDX-License-Identifier: GPL-2.0+&lt;BR /&gt; */&lt;BR /&gt;#include &amp;lt;dm.h&amp;gt;&lt;BR /&gt;#include &amp;lt;errno.h&amp;gt;&lt;BR /&gt;#include &amp;lt;common.h&amp;gt;&lt;BR /&gt;#include &amp;lt;spi.h&amp;gt;&lt;BR /&gt;#include &amp;lt;malloc.h&amp;gt;&lt;BR /&gt;#include &amp;lt;asm/io.h&amp;gt;&lt;BR /&gt;#include &amp;lt;fdtdec.h&amp;gt;&lt;BR /&gt;#ifndef CONFIG_M68K&lt;BR /&gt;#include &amp;lt;asm/arch/clock.h&amp;gt;&lt;BR /&gt;#endif&lt;BR /&gt;#include &amp;lt;fsl_dspi.h&amp;gt;&lt;/P&gt;&lt;P&gt;DECLARE_GLOBAL_DATA_PTR;&lt;/P&gt;&lt;P&gt;/* fsl_dspi_platdata flags */&lt;BR /&gt;#define DSPI_FLAG_REGMAP_ENDIAN_BIG BIT(0)&lt;/P&gt;&lt;P&gt;/* idle data value */&lt;BR /&gt;#define DSPI_IDLE_VAL 0x0&lt;/P&gt;&lt;P&gt;/* max chipselect signals number */&lt;BR /&gt;#define FSL_DSPI_MAX_CHIPSELECT 6&lt;/P&gt;&lt;P&gt;/* default SCK frequency, unit: HZ */&lt;BR /&gt;#define FSL_DSPI_DEFAULT_SCK_FREQ 10000000&lt;/P&gt;&lt;P&gt;/* tx/rx data wait timeout value, unit: us */&lt;BR /&gt;#define DSPI_TXRX_WAIT_TIMEOUT 1000000&lt;/P&gt;&lt;P&gt;/* CTAR register pre-configure value */&lt;BR /&gt;#define DSPI_CTAR_DEFAULT_VALUE (DSPI_CTAR_TRSZ(7) | \&lt;BR /&gt; DSPI_CTAR_PCSSCK_1CLK | \&lt;BR /&gt; DSPI_CTAR_PASC(0) | \&lt;BR /&gt; DSPI_CTAR_PDT(0) | \&lt;BR /&gt; DSPI_CTAR_CSSCK(0) | \&lt;BR /&gt; DSPI_CTAR_ASC(0) | \&lt;BR /&gt; DSPI_CTAR_DT(0))&lt;/P&gt;&lt;P&gt;/* CTAR register pre-configure mask */&lt;BR /&gt;#define DSPI_CTAR_SET_MODE_MASK (DSPI_CTAR_TRSZ(15) | \&lt;BR /&gt; DSPI_CTAR_PCSSCK(3) | \&lt;BR /&gt; DSPI_CTAR_PASC(3) | \&lt;BR /&gt; DSPI_CTAR_PDT(3) | \&lt;BR /&gt; DSPI_CTAR_CSSCK(15) | \&lt;BR /&gt; DSPI_CTAR_ASC(15) | \&lt;BR /&gt; DSPI_CTAR_DT(15))&lt;/P&gt;&lt;P&gt;/**&lt;BR /&gt; * struct fsl_dspi_platdata - platform data for Freescale DSPI&lt;BR /&gt; *&lt;BR /&gt; * @flags: Flags for DSPI DSPI_FLAG_...&lt;BR /&gt; * @speed_hz: Default SCK frequency&lt;BR /&gt; * @num_chipselect: Number of DSPI chipselect signals&lt;BR /&gt; * @regs_addr: Base address of DSPI registers&lt;BR /&gt; */&lt;BR /&gt;struct fsl_dspi_platdata {&lt;BR /&gt; uint flags;&lt;BR /&gt; uint speed_hz;&lt;BR /&gt; uint num_chipselect;&lt;BR /&gt; fdt_addr_t regs_addr;&lt;BR /&gt;};&lt;/P&gt;&lt;P&gt;/**&lt;BR /&gt; * struct fsl_dspi_priv - private data for Freescale DSPI&lt;BR /&gt; *&lt;BR /&gt; * @flags: Flags for DSPI DSPI_FLAG_...&lt;BR /&gt; * @mode: SPI mode to use for slave device (see SPI mode flags)&lt;BR /&gt; * @mcr_val: MCR register configure value&lt;BR /&gt; * @bus_clk: DSPI input clk frequency&lt;BR /&gt; * @speed_hz: Default SCK frequency&lt;BR /&gt; * @charbit: How many bits in every transfer&lt;BR /&gt; * @num_chipselect: Number of DSPI chipselect signals&lt;BR /&gt; * @ctar_val: CTAR register configure value of per chipselect slave device&lt;BR /&gt; * @regs: Point to DSPI register structure for I/O access&lt;BR /&gt; */&lt;BR /&gt;struct fsl_dspi_priv {&lt;BR /&gt; uint flags;&lt;BR /&gt; uint mode;&lt;BR /&gt; uint mcr_val;&lt;BR /&gt; uint bus_clk;&lt;BR /&gt; uint speed_hz;&lt;BR /&gt; uint charbit;&lt;BR /&gt; uint num_chipselect;&lt;BR /&gt; uint ctar_val[FSL_DSPI_MAX_CHIPSELECT];&lt;BR /&gt; struct dspi *regs;&lt;BR /&gt;};&lt;/P&gt;&lt;P&gt;#ifndef CONFIG_DM_SPI&lt;BR /&gt;struct fsl_dspi {&lt;BR /&gt; struct spi_slave slave;&lt;BR /&gt; struct fsl_dspi_priv priv;&lt;BR /&gt;};&lt;BR /&gt;#endif&lt;/P&gt;&lt;P&gt;__weak void cpu_dspi_port_conf(void)&lt;BR /&gt;{&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;__weak int cpu_dspi_claim_bus(uint bus, uint cs)&lt;BR /&gt;{&lt;BR /&gt; return 0;&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;__weak void cpu_dspi_release_bus(uint bus, uint cs)&lt;BR /&gt;{&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;static uint dspi_read32(uint flags, uint *addr)&lt;BR /&gt;{&lt;BR /&gt; return flags &amp;amp; DSPI_FLAG_REGMAP_ENDIAN_BIG ?&lt;BR /&gt; in_be32(addr) : in_le32(addr);&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;static void dspi_write32(uint flags, uint *addr, uint val)&lt;BR /&gt;{&lt;BR /&gt; flags &amp;amp; DSPI_FLAG_REGMAP_ENDIAN_BIG ?&lt;BR /&gt; out_be32(addr, val) : out_le32(addr, val);&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;static void dspi_halt(struct fsl_dspi_priv *priv, u8 halt)&lt;BR /&gt;{&lt;BR /&gt; uint mcr_val;&lt;/P&gt;&lt;P&gt;mcr_val = dspi_read32(priv-&amp;gt;flags, &amp;amp;priv-&amp;gt;regs-&amp;gt;mcr);&lt;/P&gt;&lt;P&gt;if (halt)&lt;BR /&gt; mcr_val |= DSPI_MCR_HALT;&lt;BR /&gt; else&lt;BR /&gt; mcr_val &amp;amp;= ~DSPI_MCR_HALT;&lt;/P&gt;&lt;P&gt;dspi_write32(priv-&amp;gt;flags, &amp;amp;priv-&amp;gt;regs-&amp;gt;mcr, mcr_val);&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;static void fsl_dspi_init_mcr(struct fsl_dspi_priv *priv, uint cfg_val)&lt;BR /&gt;{&lt;BR /&gt; /* halt DSPI module */&lt;BR /&gt; dspi_halt(priv, 1);&lt;/P&gt;&lt;P&gt;dspi_write32(priv-&amp;gt;flags, &amp;amp;priv-&amp;gt;regs-&amp;gt;mcr, cfg_val);&lt;/P&gt;&lt;P&gt;/* resume module */&lt;BR /&gt; dspi_halt(priv, 0);&lt;/P&gt;&lt;P&gt;priv-&amp;gt;mcr_val = cfg_val;&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;static void fsl_dspi_cfg_cs_active_state(struct fsl_dspi_priv *priv,&lt;BR /&gt; uint cs, uint state)&lt;BR /&gt;{&lt;BR /&gt; uint mcr_val;&lt;/P&gt;&lt;P&gt;dspi_halt(priv, 1);&lt;/P&gt;&lt;P&gt;mcr_val = dspi_read32(priv-&amp;gt;flags, &amp;amp;priv-&amp;gt;regs-&amp;gt;mcr);&lt;BR /&gt; if (state &amp;amp; SPI_CS_HIGH)&lt;BR /&gt; /* CSx inactive state is low */&lt;BR /&gt; mcr_val &amp;amp;= ~DSPI_MCR_PCSIS(cs);&lt;BR /&gt; else&lt;BR /&gt; /* CSx inactive state is high */&lt;BR /&gt; mcr_val |= DSPI_MCR_PCSIS(cs);&lt;BR /&gt; dspi_write32(priv-&amp;gt;flags, &amp;amp;priv-&amp;gt;regs-&amp;gt;mcr, mcr_val);&lt;/P&gt;&lt;P&gt;dspi_halt(priv, 0);&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;static int fsl_dspi_cfg_ctar_mode(struct fsl_dspi_priv *priv,&lt;BR /&gt; uint cs, uint mode)&lt;BR /&gt;{&lt;BR /&gt; uint bus_setup;&lt;/P&gt;&lt;P&gt;bus_setup = dspi_read32(priv-&amp;gt;flags, &amp;amp;priv-&amp;gt;regs-&amp;gt;ctar[0]);&lt;/P&gt;&lt;P&gt;bus_setup &amp;amp;= ~DSPI_CTAR_SET_MODE_MASK;&lt;BR /&gt; bus_setup |= priv-&amp;gt;ctar_val[cs];&lt;BR /&gt; bus_setup &amp;amp;= ~(DSPI_CTAR_CPOL | DSPI_CTAR_CPHA | DSPI_CTAR_LSBFE);&lt;/P&gt;&lt;P&gt;if (mode &amp;amp; SPI_CPOL)&lt;BR /&gt; bus_setup |= DSPI_CTAR_CPOL;&lt;BR /&gt; if (mode &amp;amp; SPI_CPHA)&lt;BR /&gt; bus_setup |= DSPI_CTAR_CPHA;&lt;BR /&gt; if (mode &amp;amp; SPI_LSB_FIRST)&lt;BR /&gt; bus_setup |= DSPI_CTAR_LSBFE;&lt;/P&gt;&lt;P&gt;dspi_write32(priv-&amp;gt;flags, &amp;amp;priv-&amp;gt;regs-&amp;gt;ctar[0], bus_setup);&lt;/P&gt;&lt;P&gt;priv-&amp;gt;charbit =&lt;BR /&gt; ((dspi_read32(priv-&amp;gt;flags, &amp;amp;priv-&amp;gt;regs-&amp;gt;ctar[0]) &amp;amp;&lt;BR /&gt; DSPI_CTAR_TRSZ(15)) == DSPI_CTAR_TRSZ(15)) ? 16 : 8;&lt;/P&gt;&lt;P&gt;return 0;&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;static void fsl_dspi_clr_fifo(struct fsl_dspi_priv *priv)&lt;BR /&gt;{&lt;BR /&gt; uint mcr_val;&lt;/P&gt;&lt;P&gt;dspi_halt(priv, 1);&lt;BR /&gt; mcr_val = dspi_read32(priv-&amp;gt;flags, &amp;amp;priv-&amp;gt;regs-&amp;gt;mcr);&lt;BR /&gt; /* flush RX and TX FIFO */&lt;BR /&gt; mcr_val |= (DSPI_MCR_CTXF | DSPI_MCR_CRXF);&lt;BR /&gt; dspi_write32(priv-&amp;gt;flags, &amp;amp;priv-&amp;gt;regs-&amp;gt;mcr, mcr_val);&lt;BR /&gt; dspi_halt(priv, 0);&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;static void dspi_tx(struct fsl_dspi_priv *priv, u32 ctrl, u16 data)&lt;BR /&gt;{&lt;BR /&gt; int timeout = DSPI_TXRX_WAIT_TIMEOUT;&lt;/P&gt;&lt;P&gt;/* wait for empty entries in TXFIFO or timeout */&lt;BR /&gt; while (DSPI_SR_TXCTR(dspi_read32(priv-&amp;gt;flags, &amp;amp;priv-&amp;gt;regs-&amp;gt;sr)) &amp;gt;= 4 &amp;amp;&amp;amp;&lt;BR /&gt; timeout--)&lt;BR /&gt; udelay(1);&lt;/P&gt;&lt;P&gt;if (timeout &amp;gt;= 0)&lt;BR /&gt; dspi_write32(priv-&amp;gt;flags, &amp;amp;priv-&amp;gt;regs-&amp;gt;tfr, (ctrl | data));&lt;BR /&gt; else&lt;BR /&gt; debug("dspi_tx: waiting timeout!\n");&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;static u16 dspi_rx(struct fsl_dspi_priv *priv)&lt;BR /&gt;{&lt;BR /&gt; int timeout = DSPI_TXRX_WAIT_TIMEOUT;&lt;/P&gt;&lt;P&gt;/* wait for valid entries in RXFIFO or timeout */&lt;BR /&gt; while (DSPI_SR_RXCTR(dspi_read32(priv-&amp;gt;flags, &amp;amp;priv-&amp;gt;regs-&amp;gt;sr)) == 0 &amp;amp;&amp;amp;&lt;BR /&gt; timeout--)&lt;BR /&gt; udelay(1);&lt;/P&gt;&lt;P&gt;if (timeout &amp;gt;= 0)&lt;BR /&gt; return (u16)DSPI_RFR_RXDATA(&lt;BR /&gt; dspi_read32(priv-&amp;gt;flags, &amp;amp;priv-&amp;gt;regs-&amp;gt;rfr));&lt;BR /&gt; else {&lt;BR /&gt; debug("dspi_rx: waiting timeout!\n");&lt;BR /&gt; return (u16)(~0);&lt;BR /&gt; }&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;static int dspi_xfer(struct fsl_dspi_priv *priv, uint cs, unsigned int bitlen,&lt;BR /&gt; const void *dout, void *din, unsigned long flags)&lt;BR /&gt;{&lt;BR /&gt; u16 *spi_rd16 = NULL, *spi_wr16 = NULL;&lt;BR /&gt; u8 *spi_rd = NULL, *spi_wr = NULL;&lt;BR /&gt; static u32 ctrl;&lt;BR /&gt; uint len = bitlen &amp;gt;&amp;gt; 3;&lt;/P&gt;&lt;P&gt;if (priv-&amp;gt;charbit == 16) {&lt;BR /&gt; bitlen &amp;gt;&amp;gt;= 1;&lt;BR /&gt; spi_wr16 = (u16 *)dout;&lt;BR /&gt; spi_rd16 = (u16 *)din;&lt;BR /&gt; } else {&lt;BR /&gt; spi_wr = (u8 *)dout;&lt;BR /&gt; spi_rd = (u8 *)din;&lt;BR /&gt; }&lt;/P&gt;&lt;P&gt;if ((flags &amp;amp; SPI_XFER_BEGIN) == SPI_XFER_BEGIN)&lt;BR /&gt; ctrl |= DSPI_TFR_CONT;&lt;/P&gt;&lt;P&gt;ctrl = ctrl &amp;amp; DSPI_TFR_CONT;&lt;BR /&gt; ctrl = ctrl | DSPI_TFR_CTAS(0) | DSPI_TFR_PCS(cs);&lt;/P&gt;&lt;P&gt;if (len &amp;gt; 1) {&lt;BR /&gt; int tmp_len = len - 1;&lt;BR /&gt; while (tmp_len--) {&lt;BR /&gt; if (dout != NULL) {&lt;BR /&gt; if (priv-&amp;gt;charbit == 16)&lt;BR /&gt; dspi_tx(priv, ctrl, *spi_wr16++);&lt;BR /&gt; else&lt;BR /&gt; dspi_tx(priv, ctrl, *spi_wr++);&lt;BR /&gt; dspi_rx(priv);&lt;BR /&gt; }&lt;/P&gt;&lt;P&gt;if (din != NULL) {&lt;BR /&gt; dspi_tx(priv, ctrl, DSPI_IDLE_VAL);&lt;BR /&gt; if (priv-&amp;gt;charbit == 16)&lt;BR /&gt; *spi_rd16++ = dspi_rx(priv);&lt;BR /&gt; else&lt;BR /&gt; *spi_rd++ = dspi_rx(priv);&lt;BR /&gt; }&lt;BR /&gt; }&lt;/P&gt;&lt;P&gt;len = 1; /* remaining byte */&lt;BR /&gt; }&lt;/P&gt;&lt;P&gt;if ((flags &amp;amp; SPI_XFER_END) == SPI_XFER_END)&lt;BR /&gt; ctrl &amp;amp;= ~DSPI_TFR_CONT;&lt;/P&gt;&lt;P&gt;if (len) {&lt;BR /&gt; if (dout != NULL) {&lt;BR /&gt; if (priv-&amp;gt;charbit == 16)&lt;BR /&gt; dspi_tx(priv, ctrl, *spi_wr16);&lt;BR /&gt; else&lt;BR /&gt; dspi_tx(priv, ctrl, *spi_wr);&lt;BR /&gt; dspi_rx(priv);&lt;BR /&gt; }&lt;/P&gt;&lt;P&gt;if (din != NULL) {&lt;BR /&gt; dspi_tx(priv, ctrl, DSPI_IDLE_VAL);&lt;BR /&gt; if (priv-&amp;gt;charbit == 16)&lt;BR /&gt; *spi_rd16 = dspi_rx(priv);&lt;BR /&gt; else&lt;BR /&gt; *spi_rd = dspi_rx(priv);&lt;BR /&gt; }&lt;BR /&gt; } else {&lt;BR /&gt; /* dummy read */&lt;BR /&gt; dspi_tx(priv, ctrl, DSPI_IDLE_VAL);&lt;BR /&gt; dspi_rx(priv);&lt;BR /&gt; }&lt;/P&gt;&lt;P&gt;return 0;&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;/**&lt;BR /&gt; * Calculate the divide value between input clk frequency and expected SCK frequency&lt;BR /&gt; * Formula: SCK = (clkrate/pbr) x ((1+dbr)/br)&lt;BR /&gt; * Dbr: use default value 0&lt;BR /&gt; *&lt;BR /&gt; * @pbr: return Baud Rate Prescaler value&lt;BR /&gt; * @br: return Baud Rate Scaler value&lt;BR /&gt; * @speed_hz: expected SCK frequency&lt;BR /&gt; * @clkrate: input clk frequency&lt;BR /&gt; */&lt;BR /&gt;static int fsl_dspi_hz_to_spi_baud(int *pbr, int *br,&lt;BR /&gt; int speed_hz, uint clkrate)&lt;BR /&gt;{&lt;BR /&gt; /* Valid baud rate pre-scaler values */&lt;BR /&gt; int pbr_tbl[4] = {2, 3, 5, 7};&lt;BR /&gt; int brs[16] = {2, 4, 6, 8,&lt;BR /&gt; 16, 32, 64, 128,&lt;BR /&gt; 256, 512, 1024, 2048,&lt;BR /&gt; 4096, 8192, 16384, 32768};&lt;BR /&gt; int temp, i = 0, j = 0;&lt;/P&gt;&lt;P&gt;temp = clkrate / speed_hz;&lt;/P&gt;&lt;P&gt;for (i = 0; i &amp;lt; ARRAY_SIZE(pbr_tbl); i++)&lt;BR /&gt; for (j = 0; j &amp;lt; ARRAY_SIZE(brs); j++) {&lt;BR /&gt; if (pbr_tbl[i] * brs[j] &amp;gt;= temp) {&lt;BR /&gt; *pbr = i;&lt;BR /&gt; *br = j;&lt;BR /&gt; return 0;&lt;BR /&gt; }&lt;BR /&gt; }&lt;/P&gt;&lt;P&gt;debug("Can not find valid baud rate,speed_hz is %d, ", speed_hz);&lt;BR /&gt; debug("clkrate is %d, we use the max prescaler value.\n", clkrate);&lt;/P&gt;&lt;P&gt;*pbr = ARRAY_SIZE(pbr_tbl) - 1;&lt;BR /&gt; *br = ARRAY_SIZE(brs) - 1;&lt;BR /&gt; return -EINVAL;&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;static int fsl_dspi_cfg_speed(struct fsl_dspi_priv *priv, uint speed)&lt;BR /&gt;{&lt;BR /&gt; int ret;&lt;BR /&gt; uint bus_setup;&lt;BR /&gt; int best_i, best_j, bus_clk;&lt;/P&gt;&lt;P&gt;bus_clk = priv-&amp;gt;bus_clk;&lt;/P&gt;&lt;P&gt;debug("DSPI set_speed: expected SCK speed %u, bus_clk %u.\n",&lt;BR /&gt; speed, bus_clk);&lt;/P&gt;&lt;P&gt;bus_setup = dspi_read32(priv-&amp;gt;flags, &amp;amp;priv-&amp;gt;regs-&amp;gt;ctar[0]);&lt;BR /&gt; bus_setup &amp;amp;= ~(DSPI_CTAR_DBR | DSPI_CTAR_PBR(0x3) | DSPI_CTAR_BR(0xf));&lt;/P&gt;&lt;P&gt;ret = fsl_dspi_hz_to_spi_baud(&amp;amp;best_i, &amp;amp;best_j, speed, bus_clk);&lt;BR /&gt; if (ret) {&lt;BR /&gt; speed = priv-&amp;gt;speed_hz;&lt;BR /&gt; debug("DSPI set_speed use default SCK rate %u.\n", speed);&lt;BR /&gt; fsl_dspi_hz_to_spi_baud(&amp;amp;best_i, &amp;amp;best_j, speed, bus_clk);&lt;BR /&gt; }&lt;/P&gt;&lt;P&gt;bus_setup |= (DSPI_CTAR_PBR(best_i) | DSPI_CTAR_BR(best_j));&lt;BR /&gt; dspi_write32(priv-&amp;gt;flags, &amp;amp;priv-&amp;gt;regs-&amp;gt;ctar[0], bus_setup);&lt;/P&gt;&lt;P&gt;priv-&amp;gt;speed_hz = speed;&lt;/P&gt;&lt;P&gt;return 0;&lt;BR /&gt;}&lt;BR /&gt;#ifndef CONFIG_DM_SPI&lt;BR /&gt;void spi_init(void)&lt;BR /&gt;{&lt;BR /&gt; /* Nothing to do */&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;void spi_init_f(void)&lt;BR /&gt;{&lt;BR /&gt; /* Nothing to do */&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;void spi_init_r(void)&lt;BR /&gt;{&lt;BR /&gt; /* Nothing to do */&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;int spi_cs_is_valid(unsigned int bus, unsigned int cs)&lt;BR /&gt;{&lt;BR /&gt; if (((cs &amp;gt;= 0) &amp;amp;&amp;amp; (cs &amp;lt; 8)) &amp;amp;&amp;amp; ((bus &amp;gt;= 0) &amp;amp;&amp;amp; (bus &amp;lt; 8)))&lt;BR /&gt; return 1;&lt;BR /&gt; else&lt;BR /&gt; return 0;&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;struct spi_slave *spi_setup_slave(unsigned int bus, unsigned int cs,&lt;BR /&gt; unsigned int max_hz, unsigned int mode)&lt;BR /&gt;{&lt;BR /&gt; struct fsl_dspi *dspi;&lt;BR /&gt; uint mcr_cfg_val;&lt;/P&gt;&lt;P&gt;dspi = spi_alloc_slave(struct fsl_dspi, bus, cs);&lt;BR /&gt; if (!dspi)&lt;BR /&gt; return NULL;&lt;/P&gt;&lt;P&gt;cpu_dspi_port_conf();&lt;/P&gt;&lt;P&gt;#ifdef CONFIG_SYS_FSL_DSPI_BE&lt;BR /&gt; dspi-&amp;gt;priv.flags |= DSPI_FLAG_REGMAP_ENDIAN_BIG;&lt;BR /&gt;#endif&lt;/P&gt;&lt;P&gt;dspi-&amp;gt;priv.regs = (struct dspi *)MMAP_DSPI;&lt;/P&gt;&lt;P&gt;#ifdef CONFIG_M68K&lt;BR /&gt; dspi-&amp;gt;priv.bus_clk = gd-&amp;gt;bus_clk;&lt;BR /&gt;#else&lt;BR /&gt; dspi-&amp;gt;priv.bus_clk = mxc_get_clock(MXC_DSPI_CLK);&lt;BR /&gt;#endif&lt;BR /&gt; dspi-&amp;gt;priv.speed_hz = FSL_DSPI_DEFAULT_SCK_FREQ;&lt;/P&gt;&lt;P&gt;/* default: all CS signals inactive state is high */&lt;BR /&gt; mcr_cfg_val = DSPI_MCR_MSTR | DSPI_MCR_PCSIS_MASK |&lt;BR /&gt; DSPI_MCR_CRXF | DSPI_MCR_CTXF;&lt;BR /&gt; fsl_dspi_init_mcr(&amp;amp;dspi-&amp;gt;priv, mcr_cfg_val);&lt;/P&gt;&lt;P&gt;for (i = 0; i &amp;lt; FSL_DSPI_MAX_CHIPSELECT; i++)&lt;BR /&gt; dspi-&amp;gt;priv.ctar_val[i] = DSPI_CTAR_DEFAULT_VALUE;&lt;/P&gt;&lt;P&gt;#ifdef CONFIG_SYS_DSPI_CTAR0&lt;BR /&gt; if (FSL_DSPI_MAX_CHIPSELECT &amp;gt; 0)&lt;BR /&gt; dspi-&amp;gt;priv.ctar_val[0] = CONFIG_SYS_DSPI_CTAR0;&lt;BR /&gt;#endif&lt;BR /&gt;#ifdef CONFIG_SYS_DSPI_CTAR1&lt;BR /&gt; if (FSL_DSPI_MAX_CHIPSELECT &amp;gt; 1)&lt;BR /&gt; dspi-&amp;gt;priv.ctar_val[1] = CONFIG_SYS_DSPI_CTAR1;&lt;BR /&gt;#endif&lt;BR /&gt;#ifdef CONFIG_SYS_DSPI_CTAR2&lt;BR /&gt; if (FSL_DSPI_MAX_CHIPSELECT &amp;gt; 2)&lt;BR /&gt; dspi-&amp;gt;priv.ctar_val[2] = CONFIG_SYS_DSPI_CTAR2;&lt;BR /&gt;#endif&lt;BR /&gt;#ifdef CONFIG_SYS_DSPI_CTAR3&lt;BR /&gt; if (FSL_DSPI_MAX_CHIPSELECT &amp;gt; 3)&lt;BR /&gt; dspi-&amp;gt;priv.ctar_val[3] = CONFIG_SYS_DSPI_CTAR3;&lt;BR /&gt;#endif&lt;BR /&gt;#ifdef CONFIG_SYS_DSPI_CTAR4&lt;BR /&gt; if (FSL_DSPI_MAX_CHIPSELECT &amp;gt; 4)&lt;BR /&gt; dspi-&amp;gt;priv.ctar_val[4] = CONFIG_SYS_DSPI_CTAR4;&lt;BR /&gt;#endif&lt;BR /&gt;#ifdef CONFIG_SYS_DSPI_CTAR5&lt;BR /&gt; if (FSL_DSPI_MAX_CHIPSELECT &amp;gt; 5)&lt;BR /&gt; dspi-&amp;gt;priv.ctar_val[5] = CONFIG_SYS_DSPI_CTAR5;&lt;BR /&gt;#endif&lt;BR /&gt;#ifdef CONFIG_SYS_DSPI_CTAR6&lt;BR /&gt; if (FSL_DSPI_MAX_CHIPSELECT &amp;gt; 6)&lt;BR /&gt; dspi-&amp;gt;priv.ctar_val[6] = CONFIG_SYS_DSPI_CTAR6;&lt;BR /&gt;#endif&lt;BR /&gt;#ifdef CONFIG_SYS_DSPI_CTAR7&lt;BR /&gt; if (FSL_DSPI_MAX_CHIPSELECT &amp;gt; 7)&lt;BR /&gt; dspi-&amp;gt;priv.ctar_val[7] = CONFIG_SYS_DSPI_CTAR7;&lt;BR /&gt;#endif&lt;/P&gt;&lt;P&gt;fsl_dspi_cfg_speed(&amp;amp;dspi-&amp;gt;priv, max_hz);&lt;/P&gt;&lt;P&gt;/* configure transfer mode */&lt;BR /&gt; fsl_dspi_cfg_ctar_mode(&amp;amp;dspi-&amp;gt;priv, cs, mode);&lt;/P&gt;&lt;P&gt;/* configure active state of CSX */&lt;BR /&gt; fsl_dspi_cfg_cs_active_state(&amp;amp;dspi-&amp;gt;priv, cs, mode);&lt;/P&gt;&lt;P&gt;return &amp;amp;dspi-&amp;gt;slave;&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;void spi_free_slave(struct spi_slave *slave)&lt;BR /&gt;{&lt;BR /&gt; free(slave);&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;int spi_claim_bus(struct spi_slave *slave)&lt;BR /&gt;{&lt;BR /&gt; uint sr_val;&lt;BR /&gt; struct fsl_dspi *dspi = (struct fsl_dspi *)slave;&lt;/P&gt;&lt;P&gt;cpu_dspi_claim_bus(slave-&amp;gt;bus, slave-&amp;gt;cs);&lt;/P&gt;&lt;P&gt;fsl_dspi_clr_fifo(&amp;amp;dspi-&amp;gt;priv);&lt;/P&gt;&lt;P&gt;/* check module TX and RX status */&lt;BR /&gt; sr_val = dspi_read32(dspi-&amp;gt;priv.flags, &amp;amp;dspi-&amp;gt;priv.regs-&amp;gt;sr);&lt;BR /&gt; if ((sr_val &amp;amp; DSPI_SR_TXRXS) != DSPI_SR_TXRXS) {&lt;BR /&gt; debug("DSPI RX/TX not ready!\n");&lt;BR /&gt; return -EIO;&lt;BR /&gt; }&lt;/P&gt;&lt;P&gt;return 0;&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;void spi_release_bus(struct spi_slave *slave)&lt;BR /&gt;{&lt;BR /&gt; struct fsl_dspi *dspi = (struct fsl_dspi *)slave;&lt;/P&gt;&lt;P&gt;dspi_halt(&amp;amp;dspi-&amp;gt;priv, 1);&lt;BR /&gt; cpu_dspi_release_bus(slave-&amp;gt;bus.slave-&amp;gt;cs);&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;int spi_xfer(struct spi_slave *slave, unsigned int bitlen, const void *dout,&lt;BR /&gt; void *din, unsigned long flags)&lt;BR /&gt;{&lt;BR /&gt; struct fsl_dspi *dspi = (struct fsl_dspi *)slave;&lt;BR /&gt; return dspi_xfer(&amp;amp;dspi-&amp;gt;priv, slave-&amp;gt;cs, bitlen, dout, din, flags);&lt;BR /&gt;}&lt;BR /&gt;#else&lt;BR /&gt;static int fsl_dspi_child_pre_probe(struct udevice *dev)&lt;BR /&gt;{&lt;BR /&gt; struct dm_spi_slave_platdata *slave_plat = dev_get_parent_platdata(dev);&lt;BR /&gt; struct fsl_dspi_priv *priv = dev_get_priv(dev-&amp;gt;parent);&lt;/P&gt;&lt;P&gt;if (slave_plat-&amp;gt;cs &amp;gt;= priv-&amp;gt;num_chipselect) {&lt;BR /&gt; debug("DSPI invalid chipselect number %d(max %d)!\n",&lt;BR /&gt; slave_plat-&amp;gt;cs, priv-&amp;gt;num_chipselect - 1);&lt;BR /&gt; return -EINVAL;&lt;BR /&gt; }&lt;/P&gt;&lt;P&gt;priv-&amp;gt;ctar_val[slave_plat-&amp;gt;cs] = DSPI_CTAR_DEFAULT_VALUE;&lt;/P&gt;&lt;P&gt;debug("DSPI pre_probe slave device on CS %u, max_hz %u, mode 0x%x.\n",&lt;BR /&gt; slave_plat-&amp;gt;cs, slave_plat-&amp;gt;max_hz, slave_plat-&amp;gt;mode);&lt;/P&gt;&lt;P&gt;return 0;&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;static int fsl_dspi_probe(struct udevice *bus)&lt;BR /&gt;{&lt;BR /&gt; struct fsl_dspi_platdata *plat = dev_get_platdata(bus);&lt;BR /&gt; struct fsl_dspi_priv *priv = dev_get_priv(bus);&lt;BR /&gt; struct dm_spi_bus *dm_spi_bus;&lt;BR /&gt; uint mcr_cfg_val;&lt;/P&gt;&lt;P&gt;dm_spi_bus = bus-&amp;gt;uclass_priv;&lt;/P&gt;&lt;P&gt;/* cpu speical pin muxing configure */&lt;BR /&gt; cpu_dspi_port_conf();&lt;/P&gt;&lt;P&gt;/* get input clk frequency */&lt;BR /&gt; priv-&amp;gt;regs = (struct dspi *)plat-&amp;gt;regs_addr;&lt;BR /&gt; priv-&amp;gt;flags = plat-&amp;gt;flags;&lt;BR /&gt;#ifdef CONFIG_M68K&lt;BR /&gt; priv-&amp;gt;bus_clk = gd-&amp;gt;bus_clk;&lt;BR /&gt;#else&lt;BR /&gt; priv-&amp;gt;bus_clk = mxc_get_clock(MXC_DSPI_CLK);&lt;BR /&gt;#endif&lt;BR /&gt; priv-&amp;gt;num_chipselect = plat-&amp;gt;num_chipselect;&lt;BR /&gt; priv-&amp;gt;speed_hz = plat-&amp;gt;speed_hz;&lt;BR /&gt; /* frame data length in bits, default 8bits */&lt;BR /&gt; priv-&amp;gt;charbit = 8;&lt;/P&gt;&lt;P&gt;dm_spi_bus-&amp;gt;max_hz = plat-&amp;gt;speed_hz;&lt;/P&gt;&lt;P&gt;/* default: all CS signals inactive state is high */&lt;BR /&gt; mcr_cfg_val = DSPI_MCR_MSTR | DSPI_MCR_PCSIS_MASK |&lt;BR /&gt; DSPI_MCR_CRXF | DSPI_MCR_CTXF;&lt;BR /&gt; fsl_dspi_init_mcr(priv, mcr_cfg_val);&lt;/P&gt;&lt;P&gt;debug("%s probe done, bus-num %d.\n", bus-&amp;gt;name, bus-&amp;gt;seq);&lt;/P&gt;&lt;P&gt;return 0;&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;static int fsl_dspi_claim_bus(struct udevice *dev)&lt;BR /&gt;{&lt;BR /&gt; uint sr_val;&lt;BR /&gt; struct fsl_dspi_priv *priv;&lt;BR /&gt; struct udevice *bus = dev-&amp;gt;parent;&lt;BR /&gt; struct dm_spi_slave_platdata *slave_plat =&lt;BR /&gt; dev_get_parent_platdata(dev);&lt;/P&gt;&lt;P&gt;priv = dev_get_priv(bus);&lt;/P&gt;&lt;P&gt;/* processor special preparation work */&lt;BR /&gt; cpu_dspi_claim_bus(bus-&amp;gt;seq, slave_plat-&amp;gt;cs);&lt;/P&gt;&lt;P&gt;/* configure transfer mode */&lt;BR /&gt; fsl_dspi_cfg_ctar_mode(priv, slave_plat-&amp;gt;cs, priv-&amp;gt;mode);&lt;/P&gt;&lt;P&gt;/* configure active state of CSX */&lt;BR /&gt; fsl_dspi_cfg_cs_active_state(priv, slave_plat-&amp;gt;cs,&lt;BR /&gt; priv-&amp;gt;mode);&lt;/P&gt;&lt;P&gt;fsl_dspi_clr_fifo(priv);&lt;/P&gt;&lt;P&gt;/* check module TX and RX status */&lt;BR /&gt; sr_val = dspi_read32(priv-&amp;gt;flags, &amp;amp;priv-&amp;gt;regs-&amp;gt;sr);&lt;BR /&gt; if ((sr_val &amp;amp; DSPI_SR_TXRXS) != DSPI_SR_TXRXS) {&lt;BR /&gt; debug("DSPI RX/TX not ready!\n");&lt;BR /&gt; return -EIO;&lt;BR /&gt; }&lt;/P&gt;&lt;P&gt;return 0;&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;static int fsl_dspi_release_bus(struct udevice *dev)&lt;BR /&gt;{&lt;BR /&gt; struct udevice *bus = dev-&amp;gt;parent;&lt;BR /&gt; struct fsl_dspi_priv *priv = dev_get_priv(bus);&lt;BR /&gt; struct dm_spi_slave_platdata *slave_plat =&lt;BR /&gt; dev_get_parent_platdata(dev);&lt;/P&gt;&lt;P&gt;/* halt module */&lt;BR /&gt; dspi_halt(priv, 1);&lt;/P&gt;&lt;P&gt;/* processor special release work */&lt;BR /&gt; cpu_dspi_release_bus(bus-&amp;gt;seq, slave_plat-&amp;gt;cs);&lt;/P&gt;&lt;P&gt;return 0;&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;/**&lt;BR /&gt; * This function doesn't do anything except help with debugging&lt;BR /&gt; */&lt;BR /&gt;static int fsl_dspi_bind(struct udevice *bus)&lt;BR /&gt;{&lt;BR /&gt; debug("%s assigned req_seq %d.\n", bus-&amp;gt;name, bus-&amp;gt;req_seq);&lt;BR /&gt; return 0;&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;static int fsl_dspi_ofdata_to_platdata(struct udevice *bus)&lt;BR /&gt;{&lt;BR /&gt; fdt_addr_t addr;&lt;BR /&gt; struct fsl_dspi_platdata *plat = bus-&amp;gt;platdata;&lt;BR /&gt; const void *blob = gd-&amp;gt;fdt_blob;&lt;BR /&gt; int node = bus-&amp;gt;of_offset;&lt;/P&gt;&lt;P&gt;if (fdtdec_get_bool(blob, node, "big-endian"))&lt;BR /&gt; plat-&amp;gt;flags |= DSPI_FLAG_REGMAP_ENDIAN_BIG;&lt;/P&gt;&lt;P&gt;plat-&amp;gt;num_chipselect =&lt;BR /&gt; fdtdec_get_int(blob, node, "num-cs", FSL_DSPI_MAX_CHIPSELECT);&lt;/P&gt;&lt;P&gt;addr = dev_get_addr(bus);&lt;BR /&gt; if (addr == FDT_ADDR_T_NONE) {&lt;BR /&gt; debug("DSPI: Can't get base address or size\n");&lt;BR /&gt; return -ENOMEM;&lt;BR /&gt; }&lt;BR /&gt; plat-&amp;gt;regs_addr = addr;&lt;/P&gt;&lt;P&gt;plat-&amp;gt;speed_hz = fdtdec_get_int(blob,&lt;BR /&gt; node, "spi-max-frequency", FSL_DSPI_DEFAULT_SCK_FREQ);&lt;/P&gt;&lt;P&gt;debug("DSPI: regs=%pa, max-frequency=%d, endianess=%s, num-cs=%d\n",&lt;BR /&gt; &amp;amp;plat-&amp;gt;regs_addr, plat-&amp;gt;speed_hz,&lt;BR /&gt; plat-&amp;gt;flags &amp;amp; DSPI_FLAG_REGMAP_ENDIAN_BIG ? "be" : "le",&lt;BR /&gt; plat-&amp;gt;num_chipselect);&lt;/P&gt;&lt;P&gt;return 0;&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;static int fsl_dspi_xfer(struct udevice *dev, unsigned int bitlen,&lt;BR /&gt; const void *dout, void *din, unsigned long flags)&lt;BR /&gt;{&lt;BR /&gt; struct fsl_dspi_priv *priv;&lt;BR /&gt; struct dm_spi_slave_platdata *slave_plat = dev_get_parent_platdata(dev);&lt;BR /&gt; struct udevice *bus;&lt;/P&gt;&lt;P&gt;bus = dev-&amp;gt;parent;&lt;BR /&gt; priv = dev_get_priv(bus);&lt;/P&gt;&lt;P&gt;return dspi_xfer(priv, slave_plat-&amp;gt;cs, bitlen, dout, din, flags);&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;static int fsl_dspi_set_speed(struct udevice *bus, uint speed)&lt;BR /&gt;{&lt;BR /&gt; struct fsl_dspi_priv *priv = dev_get_priv(bus);&lt;/P&gt;&lt;P&gt;return fsl_dspi_cfg_speed(priv, speed);&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;static int fsl_dspi_set_mode(struct udevice *bus, uint mode)&lt;BR /&gt;{&lt;BR /&gt; struct fsl_dspi_priv *priv = dev_get_priv(bus);&lt;/P&gt;&lt;P&gt;debug("DSPI set_mode: mode 0x%x.\n", mode);&lt;/P&gt;&lt;P&gt;/*&lt;BR /&gt; * We store some chipselect special configure value in priv-&amp;gt;ctar_val,&lt;BR /&gt; * and we can't get the correct chipselect number here,&lt;BR /&gt; * so just store mode value.&lt;BR /&gt; * Do really configuration when claim_bus.&lt;BR /&gt; */&lt;BR /&gt; priv-&amp;gt;mode = mode;&lt;/P&gt;&lt;P&gt;return 0;&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;static const struct dm_spi_ops fsl_dspi_ops = {&lt;BR /&gt; .claim_bus = fsl_dspi_claim_bus,&lt;BR /&gt; .release_bus = fsl_dspi_release_bus,&lt;BR /&gt; .xfer = fsl_dspi_xfer,&lt;BR /&gt; .set_speed = fsl_dspi_set_speed,&lt;BR /&gt; .set_mode = fsl_dspi_set_mode,&lt;BR /&gt;};&lt;/P&gt;&lt;P&gt;static const struct udevice_id fsl_dspi_ids[] = {&lt;BR /&gt; { .compatible = "fsl,vf610-dspi" },&lt;BR /&gt; { }&lt;BR /&gt;};&lt;/P&gt;&lt;P&gt;U_BOOT_DRIVER(fsl_dspi) = {&lt;BR /&gt; .name = "fsl_dspi",&lt;BR /&gt; .id = UCLASS_SPI,&lt;BR /&gt; .of_match = fsl_dspi_ids,&lt;BR /&gt; .ops = &amp;amp;fsl_dspi_ops,&lt;BR /&gt; .ofdata_to_platdata = fsl_dspi_ofdata_to_platdata,&lt;BR /&gt; .platdata_auto_alloc_size = sizeof(struct fsl_dspi_platdata),&lt;BR /&gt; .priv_auto_alloc_size = sizeof(struct fsl_dspi_priv),&lt;BR /&gt; .probe = fsl_dspi_probe,&lt;BR /&gt; .child_pre_probe = fsl_dspi_child_pre_probe,&lt;BR /&gt; .bind = fsl_dspi_bind,&lt;BR /&gt;};&lt;BR /&gt;#endif&lt;/P&gt;&lt;/BLOCKQUOTE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 12 Jul 2017 05:23:37 GMT</pubDate>
      <guid>https://community.nxp.com/t5/Kinetis-Microcontrollers/FSL-DSPI-driver-in-uboot-2017/m-p/691987#M42629</guid>
      <dc:creator>sameerarvikar</dc:creator>
      <dc:date>2017-07-12T05:23:37Z</dc:date>
    </item>
  </channel>
</rss>

