From patchwork Sat Jun 29 06:56:52 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anup Patel X-Patchwork-Id: 1124715 X-Patchwork-Delegate: van.freenix@gmail.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=wdc.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=wdc.com header.i=@wdc.com header.b="fncqdfHR"; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=sharedspace.onmicrosoft.com header.i=@sharedspace.onmicrosoft.com header.b="tz0Nu5hC"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 45bPbH646bz9s5c for ; Sat, 29 Jun 2019 16:57:47 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id 74BAAC21DC1; Sat, 29 Jun 2019 06:57:13 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id 695ACC21E07; Sat, 29 Jun 2019 06:57:00 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id E0E19C21C8B; Sat, 29 Jun 2019 06:56:56 +0000 (UTC) Received: from esa4.hgst.iphmx.com (esa4.hgst.iphmx.com [216.71.154.42]) by lists.denx.de (Postfix) with ESMTPS id C1182C21C27 for ; Sat, 29 Jun 2019 06:56:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1561791416; x=1593327416; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-transfer-encoding:mime-version; bh=LC/3rOb4j+2FmeWb16wW/Fj68irVrlug7UhGVHJ9hZU=; b=fncqdfHRoSaD7xLwIy+ds2vejuEXBd0bIGTcSX7IROZDVBGSY5RLfdTQ rPTLvNGEXEn9sOFwly3HMxPjFQdT8AXKsigxDNbJbUGryNNx0MRRgb7Gv CIArODUuPSSmoMeddHOnAaspO900OuHHR8owMEfk+7WHnoLrOnTM+7GTp BrfguO3hVNxSInALJtFNMn28ipU6vdc4Hx+0TacbQqOqTYUh16Ome//Cw crS7MoPdPxJh+I+pKU71do2aIug2dDQkCTG9mwcRfIytRB7zJLP50drpI hz0GpKWipBbvl1/V8XMcbTHNonvjv6wTT4eXkLlkVk+DG7xIZ5gCnlaD5 g==; X-IronPort-AV: E=Sophos;i="5.63,430,1557158400"; d="scan'208";a="111832598" Received: from mail-co1nam03lp2053.outbound.protection.outlook.com (HELO NAM03-CO1-obe.outbound.protection.outlook.com) ([104.47.40.53]) by ob1.hgst.iphmx.com with ESMTP; 29 Jun 2019 14:56:54 +0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sharedspace.onmicrosoft.com; s=selector2-sharedspace-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=LC/3rOb4j+2FmeWb16wW/Fj68irVrlug7UhGVHJ9hZU=; b=tz0Nu5hC8Pqq+B7bE3A+KGWPBB50Mr3zj0J1Sh/jPp7006Xeb1Tepcsw/hms8osGkxptKfZ5rc6cZQyCBONe/IC+qoQMgAsFMIVoj1ZAn9NqQNZe8ah+uwR2SX8+jRS9EWd35BoVQFEV1D/iG82CfxtIELfd/Z2vBjvctQEGkSA= Received: from MN2PR04MB6061.namprd04.prod.outlook.com (20.178.246.15) by MN2PR04MB7005.namprd04.prod.outlook.com (10.186.144.85) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2032.18; Sat, 29 Jun 2019 06:56:52 +0000 Received: from MN2PR04MB6061.namprd04.prod.outlook.com ([fe80::84da:b4e7:4612:48b]) by MN2PR04MB6061.namprd04.prod.outlook.com ([fe80::84da:b4e7:4612:48b%7]) with mapi id 15.20.2032.018; Sat, 29 Jun 2019 06:56:52 +0000 From: Anup Patel To: Rick Chen , Bin Meng , Lukas Auer , Peng Fan , Jagan Teki Thread-Topic: [PATCH v2 1/5] spi: Add SiFive SPI driver Thread-Index: AQHVLkfU0apdGQPQaE+XDNKdBmZLqg== Date: Sat, 29 Jun 2019 06:56:52 +0000 Message-ID: <20190629065621.65587-2-anup.patel@wdc.com> References: <20190629065621.65587-1-anup.patel@wdc.com> In-Reply-To: <20190629065621.65587-1-anup.patel@wdc.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: PN1PR0101CA0046.INDPRD01.PROD.OUTLOOK.COM (2603:1096:c00:c::32) To MN2PR04MB6061.namprd04.prod.outlook.com (2603:10b6:208:d8::15) authentication-results: spf=none (sender IP is ) smtp.mailfrom=Anup.Patel@wdc.com; x-ms-exchange-messagesentrepresentingtype: 1 x-mailer: git-send-email 2.17.1 x-originating-ip: [49.207.53.251] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 7337865d-df42-4874-a470-08d6fc5ef73c x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(7168020)(4627221)(201703031133081)(201702281549075)(8990200)(5600148)(711020)(4605104)(1401327)(4618075)(2017052603328)(7193020); SRVR:MN2PR04MB7005; x-ms-traffictypediagnostic: MN2PR04MB7005: wdcipoutbound: EOP-TRUE x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:2043; x-forefront-prvs: 0083A7F08A x-forefront-antispam-report: SFV:NSPM; SFS:(10019020)(6029001)(4636009)(366004)(376002)(136003)(346002)(396003)(39860400002)(199004)(189003)(68736007)(81156014)(71190400001)(8936002)(52116002)(110136005)(386003)(6116002)(486006)(186003)(25786009)(6506007)(4326008)(7416002)(8676002)(1076003)(54906003)(476003)(2616005)(316002)(36756003)(11346002)(44832011)(99286004)(26005)(102836004)(478600001)(55236004)(66066001)(76176011)(66946007)(2906002)(7736002)(3846002)(30864003)(71200400001)(50226002)(14454004)(81166006)(14444005)(256004)(6436002)(73956011)(305945005)(446003)(6512007)(6486002)(64756008)(66556008)(66476007)(86362001)(53936002)(66446008)(72206003)(5660300002); DIR:OUT; SFP:1102; SCL:1; SRVR:MN2PR04MB7005; H:MN2PR04MB6061.namprd04.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; x-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: X7ZzVZxcWv8GGRyVKfTY0xruc78b7RrT0+eFg3Pb/49EuyozblzfrMBOa9oX00j6B6hdv25HjaJu7Mg5LFyxXjrUkeh0ldk2tl+zXbkVUZbRs1LtfcSD7Yn9Csnq9vVxRGHKDzBS1L+A5CglxZJ9Krn7/gIlcyC2VA0W+GCpHeH1Rpgzb59rmduJis7LOsvsVWtKKeAvqVWVZlgx/RxoS8auQoUS7Rga0xBBGiev7AqETxA81B+VdJ2dGXWHkrrRUO8jBwSJyLxCcaKbhdQGZ3sXHAzukElMgBfxqV5ivY/3QAoZcWeA9W8WZgmTgJ2CgUFTQKl+6TkXo0IfHQYSul6V0hPQhpYL/NM06ENGHqqSBLoK8XPe1h5AOMPLokzQ345gQlaUke0puDLmyECXEXoqzSV9Qf9eh9O9+3wIGp8= MIME-Version: 1.0 X-OriginatorOrg: wdc.com X-MS-Exchange-CrossTenant-Network-Message-Id: 7337865d-df42-4874-a470-08d6fc5ef73c X-MS-Exchange-CrossTenant-originalarrivaltime: 29 Jun 2019 06:56:52.7424 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: b61c8803-16f3-4c35-9b17-6f65f441df86 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: Anup.Patel@wdc.com X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR04MB7005 Cc: Palmer Dabbelt , U-Boot Mailing List , Bhargav Shah Subject: [U-Boot] [PATCH v2 1/5] spi: Add SiFive SPI driver X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" From: Bhargav Shah This patch adds SiFive SPI driver. The driver is 100% DM driver and it determines input clock using clk framework. The SiFive SPI block is found on SiFive FU540 SOC and is used to access flash and MMC devices on SiFive Unleashed board. This driver implementation is inspired from the Linux SiFive SPI driver available in Linux-5.2 or higher and SiFive FSBL sources. Signed-off-by: Bhargav Shah Signed-off-by: Anup Patel Reviewed-by: Bin Meng Tested-by: Bin Meng --- drivers/spi/Kconfig | 8 + drivers/spi/Makefile | 1 + drivers/spi/spi-sifive.c | 405 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 414 insertions(+) create mode 100644 drivers/spi/spi-sifive.c diff --git a/drivers/spi/Kconfig b/drivers/spi/Kconfig index eb32f082fe..2712bad310 100644 --- a/drivers/spi/Kconfig +++ b/drivers/spi/Kconfig @@ -224,6 +224,14 @@ config SANDBOX_SPI }; }; +config SIFIVE_SPI + bool "SiFive SPI driver" + help + This driver supports the SiFive SPI IP. If unsure say N. + Enable the SiFive SPI controller driver. + + The SiFive SPI controller driver is found on various SiFive SoCs. + config SPI_SUNXI bool "Allwinner SoC SPI controllers" help diff --git a/drivers/spi/Makefile b/drivers/spi/Makefile index 8be9a4baa2..09a9d3697e 100644 --- a/drivers/spi/Makefile +++ b/drivers/spi/Makefile @@ -49,6 +49,7 @@ obj-$(CONFIG_PL022_SPI) += pl022_spi.o obj-$(CONFIG_RENESAS_RPC_SPI) += renesas_rpc_spi.o obj-$(CONFIG_ROCKCHIP_SPI) += rk_spi.o obj-$(CONFIG_SANDBOX_SPI) += sandbox_spi.o +obj-$(CONFIG_SIFIVE_SPI) += spi-sifive.o obj-$(CONFIG_SPI_SUNXI) += spi-sunxi.o obj-$(CONFIG_SH_SPI) += sh_spi.o obj-$(CONFIG_SH_QSPI) += sh_qspi.o diff --git a/drivers/spi/spi-sifive.c b/drivers/spi/spi-sifive.c new file mode 100644 index 0000000000..70eebc0463 --- /dev/null +++ b/drivers/spi/spi-sifive.c @@ -0,0 +1,405 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Copyright 2018 SiFive, Inc. + * Copyright 2019 Bhargav Shah + * + * SiFive SPI controller driver (master mode only) + */ + +#include +#include +#include +#include +#include +#include +#include + +DECLARE_GLOBAL_DATA_PTR; + +#define SIFIVE_SPI_MAX_CS 32 + +#define SIFIVE_SPI_DEFAULT_DEPTH 8 +#define SIFIVE_SPI_DEFAULT_BITS 8 + +/* register offsets */ +#define SIFIVE_SPI_REG_SCKDIV 0x00 /* Serial clock divisor */ +#define SIFIVE_SPI_REG_SCKMODE 0x04 /* Serial clock mode */ +#define SIFIVE_SPI_REG_CSID 0x10 /* Chip select ID */ +#define SIFIVE_SPI_REG_CSDEF 0x14 /* Chip select default */ +#define SIFIVE_SPI_REG_CSMODE 0x18 /* Chip select mode */ +#define SIFIVE_SPI_REG_DELAY0 0x28 /* Delay control 0 */ +#define SIFIVE_SPI_REG_DELAY1 0x2c /* Delay control 1 */ +#define SIFIVE_SPI_REG_FMT 0x40 /* Frame format */ +#define SIFIVE_SPI_REG_TXDATA 0x48 /* Tx FIFO data */ +#define SIFIVE_SPI_REG_RXDATA 0x4c /* Rx FIFO data */ +#define SIFIVE_SPI_REG_TXMARK 0x50 /* Tx FIFO watermark */ +#define SIFIVE_SPI_REG_RXMARK 0x54 /* Rx FIFO watermark */ +#define SIFIVE_SPI_REG_FCTRL 0x60 /* SPI flash interface control */ +#define SIFIVE_SPI_REG_FFMT 0x64 /* SPI flash instruction format */ +#define SIFIVE_SPI_REG_IE 0x70 /* Interrupt Enable Register */ +#define SIFIVE_SPI_REG_IP 0x74 /* Interrupt Pendings Register */ + +/* sckdiv bits */ +#define SIFIVE_SPI_SCKDIV_DIV_MASK 0xfffU + +/* sckmode bits */ +#define SIFIVE_SPI_SCKMODE_PHA BIT(0) +#define SIFIVE_SPI_SCKMODE_POL BIT(1) +#define SIFIVE_SPI_SCKMODE_MODE_MASK (SIFIVE_SPI_SCKMODE_PHA | \ + SIFIVE_SPI_SCKMODE_POL) + +/* csmode bits */ +#define SIFIVE_SPI_CSMODE_MODE_AUTO 0U +#define SIFIVE_SPI_CSMODE_MODE_HOLD 2U +#define SIFIVE_SPI_CSMODE_MODE_OFF 3U + +/* delay0 bits */ +#define SIFIVE_SPI_DELAY0_CSSCK(x) ((u32)(x)) +#define SIFIVE_SPI_DELAY0_CSSCK_MASK 0xffU +#define SIFIVE_SPI_DELAY0_SCKCS(x) ((u32)(x) << 16) +#define SIFIVE_SPI_DELAY0_SCKCS_MASK (0xffU << 16) + +/* delay1 bits */ +#define SIFIVE_SPI_DELAY1_INTERCS(x) ((u32)(x)) +#define SIFIVE_SPI_DELAY1_INTERCS_MASK 0xffU +#define SIFIVE_SPI_DELAY1_INTERXFR(x) ((u32)(x) << 16) +#define SIFIVE_SPI_DELAY1_INTERXFR_MASK (0xffU << 16) + +/* fmt bits */ +#define SIFIVE_SPI_FMT_PROTO_SINGLE 0U +#define SIFIVE_SPI_FMT_PROTO_DUAL 1U +#define SIFIVE_SPI_FMT_PROTO_QUAD 2U +#define SIFIVE_SPI_FMT_PROTO_MASK 3U +#define SIFIVE_SPI_FMT_ENDIAN BIT(2) +#define SIFIVE_SPI_FMT_DIR BIT(3) +#define SIFIVE_SPI_FMT_LEN(x) ((u32)(x) << 16) +#define SIFIVE_SPI_FMT_LEN_MASK (0xfU << 16) + +/* txdata bits */ +#define SIFIVE_SPI_TXDATA_DATA_MASK 0xffU +#define SIFIVE_SPI_TXDATA_FULL BIT(31) + +/* rxdata bits */ +#define SIFIVE_SPI_RXDATA_DATA_MASK 0xffU +#define SIFIVE_SPI_RXDATA_EMPTY BIT(31) + +/* ie and ip bits */ +#define SIFIVE_SPI_IP_TXWM BIT(0) +#define SIFIVE_SPI_IP_RXWM BIT(1) + +struct sifive_spi { + void *regs; /* base address of the registers */ + u32 fifo_depth; + u32 bits_per_word; + u32 cs_inactive; /* Level of the CS pins when inactive*/ + u32 freq; + u32 num_cs; +}; + +static void sifive_spi_write(struct sifive_spi *spi, int offset, u32 value) +{ + writel(value, spi->regs + offset); +} + +static u32 sifive_spi_read(struct sifive_spi *spi, int offset) +{ + return readl(spi->regs + offset); +} + +static void sifive_spi_prep_device(struct sifive_spi *spi, + struct dm_spi_slave_platdata *slave) +{ + /* Update the chip select polarity */ + if (slave->mode & SPI_CS_HIGH) + spi->cs_inactive &= ~BIT(slave->cs); + else + spi->cs_inactive |= BIT(slave->cs); + sifive_spi_write(spi, SIFIVE_SPI_REG_CSDEF, spi->cs_inactive); + + /* Select the correct device */ + sifive_spi_write(spi, SIFIVE_SPI_REG_CSID, slave->cs); +} + +static int sifive_spi_set_cs(struct sifive_spi *spi, + struct dm_spi_slave_platdata *slave) +{ + u32 cs_mode = SIFIVE_SPI_CSMODE_MODE_HOLD; + + if (slave->cs > spi->num_cs) + return -EINVAL; + + if (slave->mode & SPI_CS_HIGH) + cs_mode = SIFIVE_SPI_CSMODE_MODE_AUTO; + + sifive_spi_write(spi, SIFIVE_SPI_REG_CSMODE, cs_mode); + + return 0; +} + +static void sifive_spi_clear_cs(struct sifive_spi *spi) +{ + sifive_spi_write(spi, SIFIVE_SPI_REG_CSMODE, + SIFIVE_SPI_CSMODE_MODE_AUTO); +} + +static void sifive_spi_prep_transfer(struct sifive_spi *spi, + bool is_rx_xfer, + struct dm_spi_slave_platdata *slave) +{ + u32 cr; + + /* Modify the SPI protocol mode */ + cr = sifive_spi_read(spi, SIFIVE_SPI_REG_FMT); + + /* Bits per word ? */ + cr &= ~SIFIVE_SPI_FMT_LEN_MASK; + cr |= SIFIVE_SPI_FMT_LEN(SIFIVE_SPI_DEFAULT_BITS); + + /* LSB first? */ + cr &= ~SIFIVE_SPI_FMT_ENDIAN; + if (slave->mode & SPI_LSB_FIRST) + cr |= SIFIVE_SPI_FMT_ENDIAN; + + /* Number of wires ? */ + cr &= ~SIFIVE_SPI_FMT_PROTO_MASK; + if ((slave->mode & SPI_TX_QUAD) || (slave->mode & SPI_RX_QUAD)) + cr |= SIFIVE_SPI_FMT_PROTO_QUAD; + else if ((slave->mode & SPI_TX_DUAL) || (slave->mode & SPI_RX_DUAL)) + cr |= SIFIVE_SPI_FMT_PROTO_DUAL; + else + cr |= SIFIVE_SPI_FMT_PROTO_SINGLE; + + /* SPI direction in/out ? */ + cr &= ~SIFIVE_SPI_FMT_DIR; + if (!is_rx_xfer) + cr |= SIFIVE_SPI_FMT_DIR; + + sifive_spi_write(spi, SIFIVE_SPI_REG_FMT, cr); +} + +static void sifive_spi_rx(struct sifive_spi *spi, u8 *rx_ptr) +{ + u32 data; + + do { + data = sifive_spi_read(spi, SIFIVE_SPI_REG_RXDATA); + } while (data & SIFIVE_SPI_RXDATA_EMPTY); + + if (rx_ptr) + *rx_ptr = data & SIFIVE_SPI_RXDATA_DATA_MASK; +} + +static void sifive_spi_tx(struct sifive_spi *spi, const u8 *tx_ptr) +{ + u32 data; + u8 tx_data = (tx_ptr) ? *tx_ptr & SIFIVE_SPI_TXDATA_DATA_MASK : + SIFIVE_SPI_TXDATA_DATA_MASK; + + do { + data = sifive_spi_read(spi, SIFIVE_SPI_REG_TXDATA); + } while (data & SIFIVE_SPI_TXDATA_FULL); + + sifive_spi_write(spi, SIFIVE_SPI_REG_TXDATA, tx_data); +} + +static u8 sifive_spi_txrx(struct sifive_spi *spi, const u8 *tx_ptr) +{ + u8 rx = 0; + + sifive_spi_tx(spi, tx_ptr); + sifive_spi_rx(spi, &rx); + + return rx; +} + +static int sifive_spi_claim_bus(struct udevice *dev) +{ + int ret; + struct udevice *bus = dev->parent; + struct sifive_spi *spi = dev_get_priv(bus); + struct dm_spi_slave_platdata *slave = dev_get_parent_platdata(dev); + + sifive_spi_prep_device(spi, slave); + + ret = sifive_spi_set_cs(spi, slave); + if (ret) + return ret; + + return 0; +} + +static int sifive_spi_release_bus(struct udevice *dev) +{ + struct sifive_spi *spi = dev_get_priv(dev->parent); + + sifive_spi_clear_cs(spi); + + return 0; +} + +static int sifive_spi_xfer(struct udevice *dev, unsigned int bitlen, + const void *dout, void *din, unsigned long flags) +{ + struct udevice *bus = dev->parent; + struct sifive_spi *spi = dev_get_priv(bus); + struct dm_spi_slave_platdata *slave = dev_get_parent_platdata(dev); + const unsigned char *tx_ptr = dout; + unsigned char *rx_ptr = din; + u32 remaining_len; + + sifive_spi_prep_transfer(spi, true, slave); + + remaining_len = bitlen / 8; + + while (remaining_len) { + int n_words, tx_words, rx_words; + + n_words = min(remaining_len, spi->fifo_depth); + + /* Enqueue n_words for transmission */ + if (tx_ptr) { + for (tx_words = 0; tx_words < n_words; ++tx_words) { + sifive_spi_txrx(spi, tx_ptr); + tx_ptr++; + } + } + + /* Read out all the data from the RX FIFO */ + if (rx_ptr) { + for (rx_words = 0; rx_words < n_words; ++rx_words) { + *rx_ptr = sifive_spi_txrx(spi, NULL); + rx_ptr++; + } + } + + remaining_len -= n_words; + } + + return 0; +} + +static int sifive_spi_set_speed(struct udevice *bus, uint speed) +{ + struct sifive_spi *spi = dev_get_priv(bus); + u32 scale; + + if (speed > spi->freq) + speed = spi->freq; + + /* Cofigure max speed */ + scale = (DIV_ROUND_UP(spi->freq >> 1, speed) - 1) + & SIFIVE_SPI_SCKDIV_DIV_MASK; + sifive_spi_write(spi, SIFIVE_SPI_REG_SCKDIV, scale); + return 0; +} + +static int sifive_spi_set_mode(struct udevice *bus, uint mode) +{ + struct sifive_spi *spi = dev_get_priv(bus); + u32 cr; + + /* Switch clock mode bits */ + cr = sifive_spi_read(spi, SIFIVE_SPI_REG_SCKMODE) & + ~SIFIVE_SPI_SCKMODE_MODE_MASK; + if (mode & SPI_CPHA) + cr |= SIFIVE_SPI_SCKMODE_PHA; + if (mode & SPI_CPOL) + cr |= SIFIVE_SPI_SCKMODE_POL; + + sifive_spi_write(spi, SIFIVE_SPI_REG_SCKMODE, cr); + + return 0; +} + +static int sifive_cs_info(struct udevice *bus, uint cs, + struct spi_cs_info *info) +{ + return 0; +} + +static void sifive_spi_init_hw(struct sifive_spi *spi) +{ + u32 cs_bits; + + /* probe the number of CS lines */ + spi->cs_inactive = sifive_spi_read(spi, SIFIVE_SPI_REG_CSDEF); + sifive_spi_write(spi, SIFIVE_SPI_REG_CSDEF, 0xffffffffU); + cs_bits = sifive_spi_read(spi, SIFIVE_SPI_REG_CSDEF); + sifive_spi_write(spi, SIFIVE_SPI_REG_CSDEF, spi->cs_inactive); + if (!cs_bits) { + printf("Could not auto probe CS lines\n"); + return; + } + + spi->num_cs = ilog2(cs_bits) + 1; + if (spi->num_cs > SIFIVE_SPI_MAX_CS) { + printf("Invalid number of spi slaves\n"); + return; + } + + /* Watermark interrupts are disabled by default */ + sifive_spi_write(spi, SIFIVE_SPI_REG_IE, 0); + + /* Set CS/SCK Delays and Inactive Time to defaults */ + sifive_spi_write(spi, SIFIVE_SPI_REG_DELAY0, + SIFIVE_SPI_DELAY0_CSSCK(1) | + SIFIVE_SPI_DELAY0_SCKCS(1)); + sifive_spi_write(spi, SIFIVE_SPI_REG_DELAY1, + SIFIVE_SPI_DELAY1_INTERCS(1) | + SIFIVE_SPI_DELAY1_INTERXFR(0)); + + /* Exit specialized memory-mapped SPI flash mode */ + sifive_spi_write(spi, SIFIVE_SPI_REG_FCTRL, 0); +} + +static int sifive_spi_probe(struct udevice *bus) +{ + struct sifive_spi *spi = dev_get_priv(bus); + struct clk clkdev; + int ret; + + spi->regs = (void *)(ulong)dev_remap_addr(bus); + if (!spi->regs) + return -ENODEV; + + spi->fifo_depth = dev_read_u32_default(bus, + "sifive,fifo-depth", + SIFIVE_SPI_DEFAULT_DEPTH); + + spi->bits_per_word = dev_read_u32_default(bus, + "sifive,max-bits-per-word", + SIFIVE_SPI_DEFAULT_BITS); + + ret = clk_get_by_index(bus, 0, &clkdev); + if (ret) + return ret; + spi->freq = clk_get_rate(&clkdev); + + /* init the sifive spi hw */ + sifive_spi_init_hw(spi); + + return 0; +} + +static const struct dm_spi_ops sifive_spi_ops = { + .claim_bus = sifive_spi_claim_bus, + .release_bus = sifive_spi_release_bus, + .xfer = sifive_spi_xfer, + .set_speed = sifive_spi_set_speed, + .set_mode = sifive_spi_set_mode, + .cs_info = sifive_cs_info, +}; + +static const struct udevice_id sifive_spi_ids[] = { + { .compatible = "sifive,spi0" }, + { } +}; + +U_BOOT_DRIVER(sifive_spi) = { + .name = "sifive_spi", + .id = UCLASS_SPI, + .of_match = sifive_spi_ids, + .ops = &sifive_spi_ops, + .priv_auto_alloc_size = sizeof(struct sifive_spi), + .probe = sifive_spi_probe, +}; From patchwork Sat Jun 29 06:56:57 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anup Patel X-Patchwork-Id: 1124716 X-Patchwork-Delegate: van.freenix@gmail.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=wdc.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=wdc.com header.i=@wdc.com header.b="lZOL4Jvg"; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=sharedspace.onmicrosoft.com header.i=@sharedspace.onmicrosoft.com header.b="hE0PCUyr"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 45bPc52zVFz9s3C for ; Sat, 29 Jun 2019 16:58:29 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id 01AFDC21D74; Sat, 29 Jun 2019 06:57:35 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id 16986C21DF3; Sat, 29 Jun 2019 06:57:27 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 1F27BC21C27; Sat, 29 Jun 2019 06:57:07 +0000 (UTC) Received: from esa2.hgst.iphmx.com (esa2.hgst.iphmx.com [68.232.143.124]) by lists.denx.de (Postfix) with ESMTPS id 2AA69C21D74 for ; Sat, 29 Jun 2019 06:57:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1561791447; x=1593327447; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-transfer-encoding:mime-version; bh=HRrWYSKxqIST98aH5yYZo/5JfWfcVZ3ZX1c42HNQGuM=; b=lZOL4Jvgq5ueLiCTBq16ZbC66y8NrtJ5/QzovnG2/meO8MGcMnOIezh9 RsJkQVBZs2hmLO3IE9tDeNBw9dzBh4XBhyWgSQALiIM0ZZO16seBxzDJ9 Ko03+MADX8FIDq265iw1ry7GB/gtZ06I1yI0lej05IoBVldvxPMoQgQXQ qtJ8QQZJ2MmiZCeKFqskvAVK0EOsAgn1Q8K/S3t9bCFOX5Ct0b2vZ+9LU gacg1hgUg2883kRDhUbjTHQ+lmFk4b2CTXVs9qLbcY0EeQ4vrisOgyRpN Dlu2Ov/RVGR3KYZcUu8d99Aga5DeNXlvInyeZjM446D2iF2+IeWuN9RRl Q==; X-IronPort-AV: E=Sophos;i="5.63,430,1557158400"; d="scan'208";a="211661201" Received: from mail-cys01nam02lp2057.outbound.protection.outlook.com (HELO NAM02-CY1-obe.outbound.protection.outlook.com) ([104.47.37.57]) by ob1.hgst.iphmx.com with ESMTP; 29 Jun 2019 14:57:22 +0800 ARC-Seal: i=1; a=rsa-sha256; s=testarcselector01; d=microsoft.com; cv=none; b=xRymxGvv/8oCFcChIInWc3YIy8UoOKWU5j0xOZSXLeqSWV/TUxG59rA0VeiFMqiGXQRf+cNU6S+eccSJuhORiCVJzCU7o8OYrBPO6cPEox00NI0OfWpSGRPUYRMdAsnqtAfdJhbS7G3Ka3Kf6dbyIntizvcwRUPLAB5JA6Au6zA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=testarcselector01; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=HRrWYSKxqIST98aH5yYZo/5JfWfcVZ3ZX1c42HNQGuM=; b=izm1bMxHGHVyDO7BWSiy9Cw8PeFv1INyrHI9VAkxZCrEP9hHZ9FLb/xmM2Hjz0qqvl/MOleqWJd9dluX9F8JBY72QKJhI51OT+bIWtl57tYaMG7j9Gfej3NMR1BysTgqTphzHiyGxvOUGrKDa3T46xifJwZQ4VLcD04qVq5ZaJg= ARC-Authentication-Results: i=1; test.office365.com 1;spf=none;dmarc=none;dkim=none;arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sharedspace.onmicrosoft.com; s=selector2-sharedspace-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=HRrWYSKxqIST98aH5yYZo/5JfWfcVZ3ZX1c42HNQGuM=; b=hE0PCUyrA/ZNi9oGOC7JC0XDzQLnUjsoxqRCiLnMPpnNLkV3YnKKti0jq3irDj2ebt6JH5hkaISL3SSKPFPjfhcr71M0zBDdHiczn/l3z8LuYw9iC6GyWDJZzumCHwG9QoDj+LlbvKY8DXN14MiLTuJ/dgoDzzbh5xLMOihLoho= Received: from MN2PR04MB6061.namprd04.prod.outlook.com (20.178.246.15) by MN2PR04MB6062.namprd04.prod.outlook.com (20.178.247.149) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2008.18; Sat, 29 Jun 2019 06:56:58 +0000 Received: from MN2PR04MB6061.namprd04.prod.outlook.com ([fe80::84da:b4e7:4612:48b]) by MN2PR04MB6061.namprd04.prod.outlook.com ([fe80::84da:b4e7:4612:48b%7]) with mapi id 15.20.2032.018; Sat, 29 Jun 2019 06:56:58 +0000 From: Anup Patel To: Rick Chen , Bin Meng , Lukas Auer , Peng Fan , Jagan Teki Thread-Topic: [PATCH v2 2/5] mmc: skip select_mode_and_width for MMC SPI host Thread-Index: AQHVLkfY6oaZXmZU/kWeLYImyumi5g== Date: Sat, 29 Jun 2019 06:56:57 +0000 Message-ID: <20190629065621.65587-3-anup.patel@wdc.com> References: <20190629065621.65587-1-anup.patel@wdc.com> In-Reply-To: <20190629065621.65587-1-anup.patel@wdc.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: PN1PR0101CA0046.INDPRD01.PROD.OUTLOOK.COM (2603:1096:c00:c::32) To MN2PR04MB6061.namprd04.prod.outlook.com (2603:10b6:208:d8::15) authentication-results: spf=none (sender IP is ) smtp.mailfrom=Anup.Patel@wdc.com; x-ms-exchange-messagesentrepresentingtype: 1 x-mailer: git-send-email 2.17.1 x-originating-ip: [49.207.53.251] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 4b176692-9414-4570-6dcf-08d6fc5efa4b x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(7168020)(4627221)(201703031133081)(201702281549075)(8990200)(5600148)(711020)(4605104)(1401327)(4618075)(2017052603328)(7193020); SRVR:MN2PR04MB6062; x-ms-traffictypediagnostic: MN2PR04MB6062: x-microsoft-antispam-prvs: wdcipoutbound: EOP-TRUE x-ms-oob-tlc-oobclassifiers: OLM:5516; x-forefront-prvs: 0083A7F08A x-forefront-antispam-report: SFV:NSPM; SFS:(10019020)(4636009)(376002)(366004)(346002)(39860400002)(396003)(136003)(189003)(199004)(52116002)(71190400001)(54906003)(478600001)(71200400001)(50226002)(2616005)(110136005)(86362001)(11346002)(6486002)(316002)(6436002)(99286004)(446003)(36756003)(72206003)(256004)(6116002)(3846002)(14454004)(186003)(68736007)(7416002)(81156014)(486006)(26005)(476003)(76176011)(81166006)(44832011)(8676002)(8936002)(102836004)(6506007)(66946007)(73956011)(386003)(2906002)(66446008)(66556008)(66476007)(305945005)(1076003)(7736002)(6512007)(5660300002)(55236004)(64756008)(4326008)(66066001)(53936002)(25786009); DIR:OUT; SFP:1102; SCL:1; SRVR:MN2PR04MB6062; H:MN2PR04MB6061.namprd04.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A:1; x-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: R95HWl5uTlfgu5Qfv3IqJoZTHNWlQJiOHTZhm4n3os858GOJuimj/IOF6sFZ9g02IfpjExplvTkJLaIGm9LAkZt+Bq0ouqA9tX3uY4NVYAtI4oyGjhuslXWF+dSs1ywbHtE7MvGrwW0e0hDRdr2RXQLKpvLGuXT7x3+iVN6wjAQcjBteK61n1bKliNKdHGaSQYdsnJzNO/uyLU/FO2ELc2nrISLugOEbYec7Wq7Ot9dOEUVJpQwzzJfJWIbv8kW1JZIcBzufagng3pSMQMLtm590Qx5JMsW6iBPTm0pZIAwNnrdyJvb0SMNDzUn3Ws1FFLb2x1fSA/NXF9UaRAsmBrBOrUWJuKiEFHEjJoiYhe94ie91SkXFDhHz3lgnOygkTPjEiU6eeAFsxly0YRDynSnnl+8jq/flzPZPZ5g4m1g= MIME-Version: 1.0 X-OriginatorOrg: wdc.com X-MS-Exchange-CrossTenant-Network-Message-Id: 4b176692-9414-4570-6dcf-08d6fc5efa4b X-MS-Exchange-CrossTenant-originalarrivaltime: 29 Jun 2019 06:56:58.0064 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: b61c8803-16f3-4c35-9b17-6f65f441df86 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: Anup.Patel@wdc.com X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR04MB6062 Cc: Palmer Dabbelt , U-Boot Mailing List , Bhargav Shah Subject: [U-Boot] [PATCH v2 2/5] mmc: skip select_mode_and_width for MMC SPI host X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" The MMC mode and width are fixed for MMC SPI host hence we skip sd_select_mode_and_width() and mmc_select_mode_and_width() for MMC SPI host. Signed-off-by: Anup Patel Reviewed-by: Bin Meng Tested-by: Bin Meng --- drivers/mmc/mmc.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/drivers/mmc/mmc.c b/drivers/mmc/mmc.c index 456c1b4cc9..95008c72c3 100644 --- a/drivers/mmc/mmc.c +++ b/drivers/mmc/mmc.c @@ -1672,6 +1672,13 @@ static int sd_select_mode_and_width(struct mmc *mmc, uint card_caps) mmc_dump_capabilities("host", mmc->host_caps); #endif + if (mmc_host_is_spi(mmc)) { + mmc_set_bus_width(mmc, 1); + mmc_select_mode(mmc, SD_LEGACY); + mmc_set_clock(mmc, mmc->tran_speed, MMC_CLK_ENABLE); + return 0; + } + /* Restrict card's capabilities by what the host can do */ caps = card_caps & mmc->host_caps; @@ -1934,6 +1941,13 @@ static int mmc_select_mode_and_width(struct mmc *mmc, uint card_caps) mmc_dump_capabilities("host", mmc->host_caps); #endif + if (mmc_host_is_spi(mmc)) { + mmc_set_bus_width(mmc, 1); + mmc_select_mode(mmc, MMC_LEGACY); + mmc_set_clock(mmc, mmc->tran_speed, MMC_CLK_ENABLE); + return 0; + } + /* Restrict card's capabilities by what the host can do */ card_caps &= mmc->host_caps; From patchwork Sat Jun 29 06:57:03 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anup Patel X-Patchwork-Id: 1124717 X-Patchwork-Delegate: van.freenix@gmail.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=wdc.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=wdc.com header.i=@wdc.com header.b="UlR3mHTB"; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=sharedspace.onmicrosoft.com header.i=@sharedspace.onmicrosoft.com header.b="txvBRhM+"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 45bPcH0GTBz9s3C for ; Sat, 29 Jun 2019 16:58:38 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id 80CA6C21D83; Sat, 29 Jun 2019 06:57:51 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id 98D56C21DD9; Sat, 29 Jun 2019 06:57:33 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id E0CEDC21DD7; Sat, 29 Jun 2019 06:57:14 +0000 (UTC) Received: from esa1.hgst.iphmx.com (esa1.hgst.iphmx.com [68.232.141.245]) by lists.denx.de (Postfix) with ESMTPS id C5B16C21E0B for ; Sat, 29 Jun 2019 06:57:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1561791429; x=1593327429; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-transfer-encoding:mime-version; bh=7yrd4B6ipz6nMZG77pxDPCjkDw3jbcf1+1FbawTtdeQ=; b=UlR3mHTB9vtnYoypJ+/D4m+8abGXwcJjDVyRaa/iFJwSUqox6LQe202U mBRuyNRg1S8RjD74Cw35Mg3/ed/wvtvyORKlJUb4kmH5cs8AFAPH5UV2M HKrSvBOZkGJ/I7oGjcF4D13nSy3bKU/XyIoEuO2OalVANwXC9TQIdMSY9 0sSluZ5NYKzoYigQ3tZ6xpWJNO7I2JxEmn3sNIdxwyqkLr6SKAHVLsDcb YuxEz8DVa8gQaQmNo582rTz2jDvuAUXyKXrNDvZD0HJTGITctf29tDg/v CB2aK8p2iZtOc8TxnJagz2IhzEV5DnS0AEvrDBEJ5jvszfpSTd8xhwris A==; X-IronPort-AV: E=Sophos;i="5.63,430,1557158400"; d="scan'208";a="218211387" Received: from mail-cys01nam02lp2053.outbound.protection.outlook.com (HELO NAM02-CY1-obe.outbound.protection.outlook.com) ([104.47.37.53]) by ob1.hgst.iphmx.com with ESMTP; 29 Jun 2019 14:57:04 +0800 ARC-Seal: i=1; a=rsa-sha256; s=testarcselector01; d=microsoft.com; cv=none; b=lmnbVIdtEhetDWp5ovJcbFP/fv60/iLdNz6trkGPCY5lhsRUSsfKn6ryxYa8X6Nw5enuv+q7lRebSBOIcIGwB8N5D8DwiJl3p/0kJFmIWoav0OZFBKCP3Ztq5BuDgU4Kpi9r775zTUZtuJpnXUIx/a7mELtSscwMju/1FhsmbpA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=testarcselector01; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=7yrd4B6ipz6nMZG77pxDPCjkDw3jbcf1+1FbawTtdeQ=; b=yG/n8Sd2YJBHPiHxF55bN3iR1ZF99KmAZfJkmLsUKscPFHEGMBES2oA1uHhdYxtzacJxPhIngUx8Yk9+2Q/OT7T3ZXH1deKDvZzJgtn3qWSv6TpsIhmZpG6aCtunjMxKkb9zwDe1s2aof/sz0Xk0URg9mf53rBuIE0YS9+Ny8Qs= ARC-Authentication-Results: i=1; test.office365.com 1;spf=none;dmarc=none;dkim=none;arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sharedspace.onmicrosoft.com; s=selector2-sharedspace-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=7yrd4B6ipz6nMZG77pxDPCjkDw3jbcf1+1FbawTtdeQ=; b=txvBRhM+MW5tlwM2q++qIums/cePyrnwCu3o/q4htz62tK+ERTL7/kPcHHgHcU/oGnwm0ym9G1A6qz5veMiHajA9JT6XhMdAYTDi5HYLu5IWKjdQii/I7OWMHdAyfsjpB7skywD8280i8TZBXg7kmhgYbAnh4dNH5VN8pt81bJU= Received: from MN2PR04MB6061.namprd04.prod.outlook.com (20.178.246.15) by MN2PR04MB6062.namprd04.prod.outlook.com (20.178.247.149) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2008.18; Sat, 29 Jun 2019 06:57:03 +0000 Received: from MN2PR04MB6061.namprd04.prod.outlook.com ([fe80::84da:b4e7:4612:48b]) by MN2PR04MB6061.namprd04.prod.outlook.com ([fe80::84da:b4e7:4612:48b%7]) with mapi id 15.20.2032.018; Sat, 29 Jun 2019 06:57:03 +0000 From: Anup Patel To: Rick Chen , Bin Meng , Lukas Auer , Peng Fan , Jagan Teki Thread-Topic: [PATCH v2 3/5] mmc: mmc_spi: Re-write driver using DM framework Thread-Index: AQHVLkfbIaVAWHLVgkaDnPuDhyxsbw== Date: Sat, 29 Jun 2019 06:57:03 +0000 Message-ID: <20190629065621.65587-4-anup.patel@wdc.com> References: <20190629065621.65587-1-anup.patel@wdc.com> In-Reply-To: <20190629065621.65587-1-anup.patel@wdc.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: PN1PR0101CA0046.INDPRD01.PROD.OUTLOOK.COM (2603:1096:c00:c::32) To MN2PR04MB6061.namprd04.prod.outlook.com (2603:10b6:208:d8::15) authentication-results: spf=none (sender IP is ) smtp.mailfrom=Anup.Patel@wdc.com; x-ms-exchange-messagesentrepresentingtype: 1 x-mailer: git-send-email 2.17.1 x-originating-ip: [49.207.53.251] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 11438fd2-a3a7-4736-6550-08d6fc5efd71 x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(7168020)(4627221)(201703031133081)(201702281549075)(8990200)(5600148)(711020)(4605104)(1401327)(4618075)(2017052603328)(7193020); SRVR:MN2PR04MB6062; x-ms-traffictypediagnostic: MN2PR04MB6062: x-microsoft-antispam-prvs: wdcipoutbound: EOP-TRUE x-ms-oob-tlc-oobclassifiers: OLM:15; x-forefront-prvs: 0083A7F08A x-forefront-antispam-report: SFV:NSPM; SFS:(10019020)(4636009)(376002)(366004)(346002)(39860400002)(396003)(136003)(189003)(199004)(52116002)(71190400001)(54906003)(478600001)(71200400001)(50226002)(2616005)(110136005)(86362001)(11346002)(6486002)(316002)(6436002)(99286004)(446003)(36756003)(72206003)(256004)(14444005)(6116002)(3846002)(14454004)(186003)(68736007)(7416002)(81156014)(486006)(26005)(476003)(76176011)(81166006)(44832011)(8676002)(8936002)(102836004)(6506007)(66946007)(73956011)(386003)(2906002)(66446008)(66556008)(66476007)(305945005)(1076003)(7736002)(6512007)(5660300002)(55236004)(64756008)(53946003)(30864003)(4326008)(66066001)(53936002)(25786009); DIR:OUT; SFP:1102; SCL:1; SRVR:MN2PR04MB6062; H:MN2PR04MB6061.namprd04.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A:1; x-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: m5sd8SXuRqorKxG37ZDYiToxBCNtA6FP8c6wAPdQKDJZPeHLZu0CIytuFVTnTyaCorteOsQmYXF9rE1985298VVyActNo2mUmgf8I5IAIVJMOj+j65Du+TM1UyUXw+zeixhiYlFmyp9+cYYr//cEK8vtwDmC9co8fS1RdKFOThTOCJ08yyqed0u2NL4h+zLOGqil8JFiRSUjCVVCDCf3qLoT7hlhjLo4FiFAQleg3hujlNQ/Kz9JBm68v1VYKc/E2cY9ttjsXB7PdDku78Up46gkSZw/glW2tB2o3EdCeEJ/MvcBPxNEk+h8mTUhQf0jLUYhbfQM6JOzRyG+bdmzCRjIFz4878MJVcrj4lzas4fZyrY5bgjP3RcAyhzVrlWcM5Wn7gELg6qUUTYGo3+YfD8NNhDdscnF7FeEG8TBeBU= MIME-Version: 1.0 X-OriginatorOrg: wdc.com X-MS-Exchange-CrossTenant-Network-Message-Id: 11438fd2-a3a7-4736-6550-08d6fc5efd71 X-MS-Exchange-CrossTenant-originalarrivaltime: 29 Jun 2019 06:57:03.1544 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: b61c8803-16f3-4c35-9b17-6f65f441df86 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: Anup.Patel@wdc.com X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR04MB6062 Cc: Palmer Dabbelt , U-Boot Mailing List , Bhargav Shah Subject: [U-Boot] [PATCH v2 3/5] mmc: mmc_spi: Re-write driver using DM framework X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" From: Bhargav Shah This patch rewrites MMC SPI driver using U-Boot DM framework and get it's working on SiFive Unleashed board. Signed-off-by: Bhargav Shah Signed-off-by: Anup Patel Reviewed-by: Bin Meng Tested-by: Bin Meng --- drivers/mmc/Kconfig | 18 ++ drivers/mmc/mmc_spi.c | 469 +++++++++++++++++++++++++++--------------- 2 files changed, 320 insertions(+), 167 deletions(-) diff --git a/drivers/mmc/Kconfig b/drivers/mmc/Kconfig index c23299ea96..f750dad00a 100644 --- a/drivers/mmc/Kconfig +++ b/drivers/mmc/Kconfig @@ -46,6 +46,24 @@ config SPL_DM_MMC if MMC +config MMC_SPI + bool "Support for SPI-based MMC controller" + depends on DM_MMC && DM_SPI + help + This selects SPI-based MMC controllers. + If you have an MMC controller on a SPI bus, say Y here. + + If unsure, say N. + +config MMC_SPI_CRC_ON + bool "Support CRC for SPI-based MMC controller" + depends on MMC_SPI + default y + help + This enables CRC for SPI-based MMC controllers. + + If unsure, say N. + config ARM_PL180_MMCI bool "ARM AMBA Multimedia Card Interface and compatible support" depends on DM_MMC && OF_CONTROL diff --git a/drivers/mmc/mmc_spi.c b/drivers/mmc/mmc_spi.c index 4f57990d9c..f3d687ae80 100644 --- a/drivers/mmc/mmc_spi.c +++ b/drivers/mmc/mmc_spi.c @@ -2,6 +2,8 @@ * generic mmc spi driver * * Copyright (C) 2010 Thomas Chou + * Copyright 2019 Bhargav Shah + * * Licensed under the GPL-2 or later. */ #include @@ -9,21 +11,23 @@ #include #include #include -#include +#include #include #include #include +#include +#include /* MMC/SD in SPI mode reports R1 status always */ -#define R1_SPI_IDLE (1 << 0) -#define R1_SPI_ERASE_RESET (1 << 1) -#define R1_SPI_ILLEGAL_COMMAND (1 << 2) -#define R1_SPI_COM_CRC (1 << 3) -#define R1_SPI_ERASE_SEQ (1 << 4) -#define R1_SPI_ADDRESS (1 << 5) -#define R1_SPI_PARAMETER (1 << 6) +#define R1_SPI_IDLE BIT(0) +#define R1_SPI_ERASE_RESET BIT(1) +#define R1_SPI_ILLEGAL_COMMAND BIT(2) +#define R1_SPI_COM_CRC BIT(3) +#define R1_SPI_ERASE_SEQ BIT(4) +#define R1_SPI_ADDRESS BIT(5) +#define R1_SPI_PARAMETER BIT(6) /* R1 bit 7 is always zero, reuse this bit for error */ -#define R1_SPI_ERROR (1 << 7) +#define R1_SPI_ERROR BIT(7) /* Response tokens used to ack each block written: */ #define SPI_MMC_RESPONSE_CODE(x) ((x) & 0x1f) @@ -34,28 +38,45 @@ /* Read and write blocks start with these tokens and end with crc; * on error, read tokens act like a subset of R2_SPI_* values. */ -#define SPI_TOKEN_SINGLE 0xfe /* single block r/w, multiblock read */ -#define SPI_TOKEN_MULTI_WRITE 0xfc /* multiblock write */ -#define SPI_TOKEN_STOP_TRAN 0xfd /* terminate multiblock write */ +/* single block write multiblock read */ +#define SPI_TOKEN_SINGLE 0xfe +/* multiblock write */ +#define SPI_TOKEN_MULTI_WRITE 0xfc +/* terminate multiblock write */ +#define SPI_TOKEN_STOP_TRAN 0xfd /* MMC SPI commands start with a start bit "0" and a transmit bit "1" */ -#define MMC_SPI_CMD(x) (0x40 | (x & 0x3f)) +#define MMC_SPI_CMD(x) (0x40 | (x)) /* bus capability */ -#define MMC_SPI_VOLTAGE (MMC_VDD_32_33 | MMC_VDD_33_34) -#define MMC_SPI_MIN_CLOCK 400000 /* 400KHz to meet MMC spec */ +#define MMC_SPI_VOLTAGE (MMC_VDD_32_33 | MMC_VDD_33_34) +#define MMC_SPI_MIN_CLOCK 400000 /* 400KHz to meet MMC spec */ +#define MMC_SPI_MAX_CLOCK 25000000 /* SD/MMC legacy speed */ /* timeout value */ -#define CTOUT 8 -#define RTOUT 3000000 /* 1 sec */ -#define WTOUT 3000000 /* 1 sec */ +#define CMD_TIMEOUT 8 +#define READ_TIMEOUT 3000000 /* 1 sec */ +#define WRITE_TIMEOUT 3000000 /* 1 sec */ -static uint mmc_spi_sendcmd(struct mmc *mmc, ushort cmdidx, u32 cmdarg) +struct mmc_spi_priv { + struct spi_slave *spi; + struct mmc_config cfg; + struct mmc mmc; +}; + +static int mmc_spi_sendcmd(struct udevice *dev, + ushort cmdidx, u32 cmdarg, u32 resp_type, + u8 *resp, u32 resp_size, + bool resp_match, u8 resp_match_value) { - struct spi_slave *spi = mmc->priv; - u8 cmdo[7]; - u8 r1; - int i; + int i, rpos = 0, ret = 0; + u8 cmdo[7], r; + + debug("%s: cmd%d cmdarg=0x%x resp_type=0x%x " + "resp_size=%d resp_match=%d resp_match_value=0x%x\n", + __func__, cmdidx, cmdarg, resp_type, + resp_size, resp_match, resp_match_value); + cmdo[0] = 0xff; cmdo[1] = MMC_SPI_CMD(cmdidx); cmdo[2] = cmdarg >> 24; @@ -63,37 +84,79 @@ static uint mmc_spi_sendcmd(struct mmc *mmc, ushort cmdidx, u32 cmdarg) cmdo[4] = cmdarg >> 8; cmdo[5] = cmdarg; cmdo[6] = (crc7(0, &cmdo[1], 5) << 1) | 0x01; - spi_xfer(spi, sizeof(cmdo) * 8, cmdo, NULL, 0); - for (i = 0; i < CTOUT; i++) { - spi_xfer(spi, 1 * 8, NULL, &r1, 0); - if (i && (r1 & 0x80) == 0) /* r1 response */ - break; + ret = dm_spi_xfer(dev, sizeof(cmdo) * 8, cmdo, NULL, 0); + if (ret) + return ret; + + ret = dm_spi_xfer(dev, 1 * 8, NULL, &r, 0); + if (ret) + return ret; + + if (!resp || !resp_size) + return 0; + + debug("%s: cmd%d", __func__, cmdidx); + + if (resp_match) { + r = ~resp_match_value; + i = CMD_TIMEOUT; + while (i--) { + ret = dm_spi_xfer(dev, 1 * 8, NULL, &r, 0); + if (ret) + return ret; + debug(" resp%d=0x%x", rpos, r); + rpos++; + if (r == resp_match_value) + break; + } + if (!i && (r != resp_match_value)) + return -ETIMEDOUT; + } + + for (i = 0; i < resp_size; i++) { + if (i == 0 && resp_match) { + resp[i] = resp_match_value; + continue; + } + ret = dm_spi_xfer(dev, 1 * 8, NULL, &r, 0); + if (ret) + return ret; + debug(" resp%d=0x%x", rpos, r); + rpos++; + resp[i] = r; } - debug("%s:cmd%d resp%d %x\n", __func__, cmdidx, i, r1); - return r1; + + debug("\n"); + + return 0; } -static uint mmc_spi_readdata(struct mmc *mmc, void *xbuf, - u32 bcnt, u32 bsize) +static int mmc_spi_readdata(struct udevice *dev, + void *xbuf, u32 bcnt, u32 bsize) { - struct spi_slave *spi = mmc->priv; - u8 *buf = xbuf; - u8 r1; u16 crc; - int i; + u8 *buf = xbuf, r1; + int i, ret = 0; + while (bcnt--) { - for (i = 0; i < RTOUT; i++) { - spi_xfer(spi, 1 * 8, NULL, &r1, 0); - if (r1 != 0xff) /* data token */ + for (i = 0; i < READ_TIMEOUT; i++) { + ret = dm_spi_xfer(dev, 1 * 8, NULL, &r1, 0); + if (ret) + return ret; + if (r1 == SPI_TOKEN_SINGLE) break; } - debug("%s:tok%d %x\n", __func__, i, r1); + debug("%s: data tok%d 0x%x\n", __func__, i, r1); if (r1 == SPI_TOKEN_SINGLE) { - spi_xfer(spi, bsize * 8, NULL, buf, 0); - spi_xfer(spi, 2 * 8, NULL, &crc, 0); + ret = dm_spi_xfer(dev, bsize * 8, NULL, buf, 0); + if (ret) + return ret; + ret = dm_spi_xfer(dev, 2 * 8, NULL, &crc, 0); + if (ret) + return ret; #ifdef CONFIG_MMC_SPI_CRC_ON - if (be_to_cpu16(crc16_ccitt(0, buf, bsize)) != crc) { - debug("%s: CRC error\n", mmc->cfg->name); + if (be16_to_cpu(crc16_ccitt(0, buf, bsize)) != crc) { + debug("%s: data crc error\n", __func__); r1 = R1_SPI_COM_CRC; break; } @@ -105,48 +168,56 @@ static uint mmc_spi_readdata(struct mmc *mmc, void *xbuf, } buf += bsize; } - return r1; + + if (r1 & R1_SPI_COM_CRC) + ret = -ECOMM; + else if (r1) /* other errors */ + ret = -ETIMEDOUT; + + return ret; } -static uint mmc_spi_writedata(struct mmc *mmc, const void *xbuf, - u32 bcnt, u32 bsize, int multi) +static int mmc_spi_writedata(struct udevice *dev, const void *xbuf, + u32 bcnt, u32 bsize, int multi) { - struct spi_slave *spi = mmc->priv; const u8 *buf = xbuf; - u8 r1; + u8 r1, tok[2]; u16 crc; - u8 tok[2]; - int i; + int i, ret = 0; + tok[0] = 0xff; tok[1] = multi ? SPI_TOKEN_MULTI_WRITE : SPI_TOKEN_SINGLE; + while (bcnt--) { #ifdef CONFIG_MMC_SPI_CRC_ON crc = cpu_to_be16(crc16_ccitt(0, (u8 *)buf, bsize)); #endif - spi_xfer(spi, 2 * 8, tok, NULL, 0); - spi_xfer(spi, bsize * 8, buf, NULL, 0); - spi_xfer(spi, 2 * 8, &crc, NULL, 0); - for (i = 0; i < CTOUT; i++) { - spi_xfer(spi, 1 * 8, NULL, &r1, 0); + dm_spi_xfer(dev, 2 * 8, tok, NULL, 0); + dm_spi_xfer(dev, bsize * 8, buf, NULL, 0); + dm_spi_xfer(dev, 2 * 8, &crc, NULL, 0); + for (i = 0; i < CMD_TIMEOUT; i++) { + dm_spi_xfer(dev, 1 * 8, NULL, &r1, 0); if ((r1 & 0x10) == 0) /* response token */ break; } - debug("%s:tok%d %x\n", __func__, i, r1); + debug("%s: data tok%d 0x%x\n", __func__, i, r1); if (SPI_MMC_RESPONSE_CODE(r1) == SPI_RESPONSE_ACCEPTED) { - for (i = 0; i < WTOUT; i++) { /* wait busy */ - spi_xfer(spi, 1 * 8, NULL, &r1, 0); + debug("%s: data accepted\n", __func__); + for (i = 0; i < WRITE_TIMEOUT; i++) { /* wait busy */ + dm_spi_xfer(dev, 1 * 8, NULL, &r1, 0); if (i && r1 == 0xff) { r1 = 0; break; } } - if (i == WTOUT) { - debug("%s:wtout %x\n", __func__, r1); + if (i == WRITE_TIMEOUT) { + debug("%s: data write timeout 0x%x\n", + __func__, r1); r1 = R1_SPI_ERROR; break; } } else { - debug("%s: err %x\n", __func__, r1); + debug("%s: data error 0x%x\n", __func__, r1); r1 = R1_SPI_COM_CRC; break; } @@ -154,140 +225,204 @@ static uint mmc_spi_writedata(struct mmc *mmc, const void *xbuf, } if (multi && bcnt == -1) { /* stop multi write */ tok[1] = SPI_TOKEN_STOP_TRAN; - spi_xfer(spi, 2 * 8, tok, NULL, 0); - for (i = 0; i < WTOUT; i++) { /* wait busy */ - spi_xfer(spi, 1 * 8, NULL, &r1, 0); + dm_spi_xfer(dev, 2 * 8, tok, NULL, 0); + for (i = 0; i < WRITE_TIMEOUT; i++) { /* wait busy */ + dm_spi_xfer(dev, 1 * 8, NULL, &r1, 0); if (i && r1 == 0xff) { r1 = 0; break; } } - if (i == WTOUT) { - debug("%s:wstop %x\n", __func__, r1); + if (i == WRITE_TIMEOUT) { + debug("%s: data write timeout 0x%x\n", __func__, r1); r1 = R1_SPI_ERROR; } } - return r1; -} -static int mmc_spi_request(struct mmc *mmc, struct mmc_cmd *cmd, - struct mmc_data *data) -{ - struct spi_slave *spi = mmc->priv; - u8 r1; - int i; - int ret = 0; - debug("%s:cmd%d %x %x\n", __func__, - cmd->cmdidx, cmd->resp_type, cmd->cmdarg); - spi_claim_bus(spi); - spi_cs_activate(spi); - r1 = mmc_spi_sendcmd(mmc, cmd->cmdidx, cmd->cmdarg); - if (r1 == 0xff) { /* no response */ - ret = -ENOMEDIUM; - goto done; - } else if (r1 & R1_SPI_COM_CRC) { + if (r1 & R1_SPI_COM_CRC) ret = -ECOMM; - goto done; - } else if (r1 & ~R1_SPI_IDLE) { /* other errors */ + else if (r1) /* other errors */ ret = -ETIMEDOUT; + + return ret; +} + +static int dm_mmc_spi_set_ios(struct udevice *dev) +{ + return 0; +} + +static int dm_mmc_spi_request(struct udevice *dev, struct mmc_cmd *cmd, + struct mmc_data *data) +{ + int i, multi, ret = 0; + u8 *resp = NULL; + u32 resp_size = 0; + bool resp_match = false; + u8 resp8 = 0, resp40[5] = { 0 }, resp_match_value = 0; + + dm_spi_claim_bus(dev); + + for (i = 0; i < 4; i++) + cmd->response[i] = 0; + + switch (cmd->cmdidx) { + case SD_CMD_APP_SEND_OP_COND: + case MMC_CMD_SEND_OP_COND: + resp = &resp8; + resp_size = sizeof(resp8); + cmd->cmdarg = 0x40000000; + break; + case SD_CMD_SEND_IF_COND: + resp = (u8 *)&resp40[0]; + resp_size = sizeof(resp40); + resp_match = true; + resp_match_value = R1_SPI_IDLE; + break; + case MMC_CMD_SPI_READ_OCR: + resp = (u8 *)&resp40[0]; + resp_size = sizeof(resp40); + break; + case MMC_CMD_SEND_STATUS: + case MMC_CMD_SET_BLOCKLEN: + case MMC_CMD_SPI_CRC_ON_OFF: + case MMC_CMD_STOP_TRANSMISSION: + resp = &resp8; + resp_size = sizeof(resp8); + resp_match = true; + resp_match_value = 0x0; + break; + case MMC_CMD_SEND_CSD: + case MMC_CMD_SEND_CID: + case MMC_CMD_READ_SINGLE_BLOCK: + case MMC_CMD_READ_MULTIPLE_BLOCK: + case MMC_CMD_WRITE_SINGLE_BLOCK: + case MMC_CMD_WRITE_MULTIPLE_BLOCK: + break; + default: + resp = &resp8; + resp_size = sizeof(resp8); + resp_match = true; + resp_match_value = R1_SPI_IDLE; + break; + }; + + ret = mmc_spi_sendcmd(dev, cmd->cmdidx, cmd->cmdarg, cmd->resp_type, + resp, resp_size, resp_match, resp_match_value); + if (ret) goto done; - } else if (cmd->resp_type == MMC_RSP_R2) { - r1 = mmc_spi_readdata(mmc, cmd->response, 1, 16); + + switch (cmd->cmdidx) { + case SD_CMD_APP_SEND_OP_COND: + case MMC_CMD_SEND_OP_COND: + cmd->response[0] = (resp8 & R1_SPI_IDLE) ? 0 : OCR_BUSY; + break; + case SD_CMD_SEND_IF_COND: + case MMC_CMD_SPI_READ_OCR: + cmd->response[0] = resp40[4]; + cmd->response[0] |= (uint)resp40[3] << 8; + cmd->response[0] |= (uint)resp40[2] << 16; + cmd->response[0] |= (uint)resp40[1] << 24; + break; + case MMC_CMD_SEND_STATUS: + cmd->response[0] = (resp8 & 0xff) ? + MMC_STATUS_ERROR : MMC_STATUS_RDY_FOR_DATA; + break; + case MMC_CMD_SEND_CID: + case MMC_CMD_SEND_CSD: + ret = mmc_spi_readdata(dev, cmd->response, 1, 16); + if (ret) + return ret; for (i = 0; i < 4; i++) - cmd->response[i] = be32_to_cpu(cmd->response[i]); - debug("r128 %x %x %x %x\n", cmd->response[0], cmd->response[1], - cmd->response[2], cmd->response[3]); - } else if (!data) { - switch (cmd->cmdidx) { - case SD_CMD_APP_SEND_OP_COND: - case MMC_CMD_SEND_OP_COND: - cmd->response[0] = (r1 & R1_SPI_IDLE) ? 0 : OCR_BUSY; - break; - case SD_CMD_SEND_IF_COND: - case MMC_CMD_SPI_READ_OCR: - spi_xfer(spi, 4 * 8, NULL, cmd->response, 0); - cmd->response[0] = be32_to_cpu(cmd->response[0]); - debug("r32 %x\n", cmd->response[0]); - break; - case MMC_CMD_SEND_STATUS: - spi_xfer(spi, 1 * 8, NULL, cmd->response, 0); - cmd->response[0] = (cmd->response[0] & 0xff) ? - MMC_STATUS_ERROR : MMC_STATUS_RDY_FOR_DATA; - break; - } - } else { - debug("%s:data %x %x %x\n", __func__, - data->flags, data->blocks, data->blocksize); + cmd->response[i] = + cpu_to_be32(cmd->response[i]); + break; + default: + cmd->response[0] = resp8; + break; + } + + debug("%s: cmd%d resp0=0x%x resp1=0x%x resp2=0x%x resp3=0x%x\n", + __func__, cmd->cmdidx, cmd->response[0], cmd->response[1], + cmd->response[2], cmd->response[3]); + + if (data) { + debug("%s: data flags=0x%x blocks=%d block_size=%d\n", + __func__, data->flags, data->blocks, data->blocksize); + multi = (cmd->cmdidx == MMC_CMD_WRITE_MULTIPLE_BLOCK); if (data->flags == MMC_DATA_READ) - r1 = mmc_spi_readdata(mmc, data->dest, - data->blocks, data->blocksize); + ret = mmc_spi_readdata(dev, data->dest, + data->blocks, data->blocksize); else if (data->flags == MMC_DATA_WRITE) - r1 = mmc_spi_writedata(mmc, data->src, - data->blocks, data->blocksize, - (cmd->cmdidx == MMC_CMD_WRITE_MULTIPLE_BLOCK)); - if (r1 & R1_SPI_COM_CRC) - ret = -ECOMM; - else if (r1) /* other errors */ - ret = -ETIMEDOUT; + ret = mmc_spi_writedata(dev, data->src, + data->blocks, data->blocksize, + multi); } + done: - spi_cs_deactivate(spi); - spi_release_bus(spi); + dm_spi_release_bus(dev); + return ret; } -static int mmc_spi_set_ios(struct mmc *mmc) +static int mmc_spi_probe(struct udevice *dev) { - struct spi_slave *spi = mmc->priv; + struct mmc_spi_priv *priv = dev_get_priv(dev); + struct mmc_uclass_priv *upriv = dev_get_uclass_priv(dev); + char *name; + + priv->spi = dev_get_parent_priv(dev); + if (!priv->spi->max_hz) + priv->spi->max_hz = MMC_SPI_MAX_CLOCK; + priv->spi->speed = 0; + priv->spi->mode = SPI_MODE_0; + priv->spi->wordlen = 8; + + name = malloc(strlen(dev->parent->name) + strlen(dev->name) + 4); + if (!name) + return -ENOMEM; + sprintf(name, "%s:%s", dev->parent->name, dev->name); + + priv->cfg.name = name; + priv->cfg.host_caps = MMC_MODE_SPI; + priv->cfg.voltages = MMC_SPI_VOLTAGE; + priv->cfg.f_min = MMC_SPI_MIN_CLOCK; + priv->cfg.f_max = priv->spi->max_hz; + priv->cfg.part_type = PART_TYPE_DOS; + priv->cfg.b_max = CONFIG_SYS_MMC_MAX_BLK_COUNT; + + priv->mmc.cfg = &priv->cfg; + priv->mmc.priv = priv; + priv->mmc.dev = dev; + + upriv->mmc = &priv->mmc; - debug("%s: clock %u\n", __func__, mmc->clock); - if (mmc->clock) - spi_set_speed(spi, mmc->clock); return 0; } -static int mmc_spi_init_p(struct mmc *mmc) +static int mmc_spi_bind(struct udevice *dev) { - struct spi_slave *spi = mmc->priv; - spi_set_speed(spi, MMC_SPI_MIN_CLOCK); - spi_claim_bus(spi); - /* cs deactivated for 100+ clock */ - spi_xfer(spi, 18 * 8, NULL, NULL, 0); - spi_release_bus(spi); - return 0; + struct mmc_spi_priv *priv = dev_get_priv(dev); + + return mmc_bind(dev, &priv->mmc, &priv->cfg); } -static const struct mmc_ops mmc_spi_ops = { - .send_cmd = mmc_spi_request, - .set_ios = mmc_spi_set_ios, - .init = mmc_spi_init_p, +static const struct dm_mmc_ops mmc_spi_ops = { + .send_cmd = dm_mmc_spi_request, + .set_ios = dm_mmc_spi_set_ios, }; -static struct mmc_config mmc_spi_cfg = { - .name = "MMC_SPI", - .ops = &mmc_spi_ops, - .host_caps = MMC_MODE_SPI, - .voltages = MMC_SPI_VOLTAGE, - .f_min = MMC_SPI_MIN_CLOCK, - .part_type = PART_TYPE_DOS, - .b_max = CONFIG_SYS_MMC_MAX_BLK_COUNT, +static const struct udevice_id dm_mmc_spi_match[] = { + { .compatible = "mmc-spi-slot" }, + { /* sentinel */ } }; -struct mmc *mmc_spi_init(uint bus, uint cs, uint speed, uint mode) -{ - struct mmc *mmc; - struct spi_slave *spi; - - spi = spi_setup_slave(bus, cs, speed, mode); - if (spi == NULL) - return NULL; - - mmc_spi_cfg.f_max = speed; - - mmc = mmc_create(&mmc_spi_cfg, spi); - if (mmc == NULL) { - spi_free_slave(spi); - return NULL; - } - return mmc; -} +U_BOOT_DRIVER(mmc_spi) = { + .name = "mmc_spi", + .id = UCLASS_MMC, + .of_match = dm_mmc_spi_match, + .ops = &mmc_spi_ops, + .probe = mmc_spi_probe, + .bind = mmc_spi_bind, + .priv_auto_alloc_size = sizeof(struct mmc_spi_priv), +}; From patchwork Sat Jun 29 06:57:08 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anup Patel X-Patchwork-Id: 1124719 X-Patchwork-Delegate: van.freenix@gmail.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=wdc.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=wdc.com header.i=@wdc.com header.b="QNb7kiZb"; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=sharedspace.onmicrosoft.com header.i=@sharedspace.onmicrosoft.com header.b="aNmSBJwu"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 45bPd43MGgz9s3C for ; Sat, 29 Jun 2019 16:59:20 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id 27E9BC21E0F; Sat, 29 Jun 2019 06:58:18 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id 39750C21E07; Sat, 29 Jun 2019 06:57:35 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 009F7C21DDC; Sat, 29 Jun 2019 06:57:17 +0000 (UTC) Received: from esa1.hgst.iphmx.com (esa1.hgst.iphmx.com [68.232.141.245]) by lists.denx.de (Postfix) with ESMTPS id D1CFAC21DA6 for ; Sat, 29 Jun 2019 06:57:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1561791431; x=1593327431; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-transfer-encoding:mime-version; bh=yeFAPMUP34Ns0vjXqYtzT91ZsTGvP3+hejd4YsyhBBo=; b=QNb7kiZbGZ9XWHTyBsMkiL1skaYLhAgL+OvIsHZZDR+L7nVg4ENs3ZOe /9surZv9TDbMu+iVJ++bLDk7FlAvSeRC9W6kokJqYnMzbE5OTEj/BafnJ Zd9Qxj5IGPzLzInETj9f5G2lrdjgATifRuRsIGg376IgjLaPW6C3+X30i 0mYz1o+MwEqDKqS1KW3zyNFI1wZgFR73czy0bgJCDMsf9YpQXrTVu29HK NB63Zf8RLD2QbrCgbzXW6XAnxOQ/raQVbsGEpFLtIHov3a1b8XSp5Hoyi QWBzax2G/cg3TMKv/9zeaaz1UP+9AzNIlG0GOj6c3WbXn59I39wvEYhHd g==; X-IronPort-AV: E=Sophos;i="5.63,430,1557158400"; d="scan'208";a="218211391" Received: from mail-cys01nam02lp2057.outbound.protection.outlook.com (HELO NAM02-CY1-obe.outbound.protection.outlook.com) ([104.47.37.57]) by ob1.hgst.iphmx.com with ESMTP; 29 Jun 2019 14:57:09 +0800 ARC-Seal: i=1; a=rsa-sha256; s=testarcselector01; d=microsoft.com; cv=none; b=VZrIUAgkXQLLpPk/xJLUk/dLdixJmP/x820DOBhjSInWuFbWFgExSLCH8BmvUnDRfYA2C5dpmcVoOospiYOlM7LsQUYfSoOYaizfxnZUT4wZvJMHlLHpzGcBN119xbANRx1Zf195KrSlw+kYhuLzY10d5UKBBcnvXpr8Vs40nFc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=testarcselector01; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=yeFAPMUP34Ns0vjXqYtzT91ZsTGvP3+hejd4YsyhBBo=; b=ZEQ8almh/4gq5mKIKJKZpj4SXBNnNE0AF1j4tv97VGvh1Jxjf7/T83HNK3uE/9SU9QbyVwZrlwy+3002RCOJA28YykyEVJUeTkEbYhUrZuiC6y03I7KqUnKDotpwL6eyieMj6IR739q6dUnAfOEmAIvSoTxS4HxyDxITov5ALSc= ARC-Authentication-Results: i=1; test.office365.com 1;spf=none;dmarc=none;dkim=none;arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sharedspace.onmicrosoft.com; s=selector2-sharedspace-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=yeFAPMUP34Ns0vjXqYtzT91ZsTGvP3+hejd4YsyhBBo=; b=aNmSBJwuTNDLV7hoFp/Bg4oYP2zjdeTlDQIuTsrQF9Y/QMPDb3pzEL2H11kRBRxGFFc8P1IHJli73WLQB1+eL0fm7laLjPdIz5nds1WP2BfyWsHrgZZRGkoSTFqFoXGOK21Q81X0GHKUBF/Q/E2rJaQ046QLKa3qCexgVBlyaTo= Received: from MN2PR04MB6061.namprd04.prod.outlook.com (20.178.246.15) by MN2PR04MB6062.namprd04.prod.outlook.com (20.178.247.149) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2008.18; Sat, 29 Jun 2019 06:57:08 +0000 Received: from MN2PR04MB6061.namprd04.prod.outlook.com ([fe80::84da:b4e7:4612:48b]) by MN2PR04MB6061.namprd04.prod.outlook.com ([fe80::84da:b4e7:4612:48b%7]) with mapi id 15.20.2032.018; Sat, 29 Jun 2019 06:57:08 +0000 From: Anup Patel To: Rick Chen , Bin Meng , Lukas Auer , Peng Fan , Jagan Teki Thread-Topic: [PATCH v2 4/5] riscv: sifive: fu540: Enable SiFive SPI and MMC SPI drivers Thread-Index: AQHVLkfeUsZ3wFkyVkSDwc/OqbTFRw== Date: Sat, 29 Jun 2019 06:57:08 +0000 Message-ID: <20190629065621.65587-5-anup.patel@wdc.com> References: <20190629065621.65587-1-anup.patel@wdc.com> In-Reply-To: <20190629065621.65587-1-anup.patel@wdc.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: PN1PR0101CA0046.INDPRD01.PROD.OUTLOOK.COM (2603:1096:c00:c::32) To MN2PR04MB6061.namprd04.prod.outlook.com (2603:10b6:208:d8::15) authentication-results: spf=none (sender IP is ) smtp.mailfrom=Anup.Patel@wdc.com; x-ms-exchange-messagesentrepresentingtype: 1 x-mailer: git-send-email 2.17.1 x-originating-ip: [49.207.53.251] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 471b8b4b-59f3-4b9c-86fb-08d6fc5f006a x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(7168020)(4627221)(201703031133081)(201702281549075)(8990200)(5600148)(711020)(4605104)(1401327)(4618075)(2017052603328)(7193020); SRVR:MN2PR04MB6062; x-ms-traffictypediagnostic: MN2PR04MB6062: x-microsoft-antispam-prvs: wdcipoutbound: EOP-TRUE x-ms-oob-tlc-oobclassifiers: OLM:2449; x-forefront-prvs: 0083A7F08A x-forefront-antispam-report: SFV:NSPM; SFS:(10019020)(6029001)(4636009)(376002)(366004)(346002)(39860400002)(396003)(136003)(189003)(199004)(52116002)(71190400001)(54906003)(478600001)(71200400001)(50226002)(2616005)(110136005)(86362001)(11346002)(6486002)(316002)(6436002)(99286004)(446003)(36756003)(72206003)(256004)(6116002)(3846002)(14454004)(186003)(68736007)(7416002)(81156014)(486006)(26005)(476003)(76176011)(81166006)(44832011)(8676002)(8936002)(102836004)(6506007)(66946007)(73956011)(386003)(2906002)(66446008)(66556008)(66476007)(305945005)(1076003)(7736002)(6512007)(5660300002)(4744005)(55236004)(64756008)(4326008)(66066001)(53936002)(25786009); DIR:OUT; SFP:1102; SCL:1; SRVR:MN2PR04MB6062; H:MN2PR04MB6061.namprd04.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A:1; x-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: Uy/VkHsyn/sGYFrDhFWvf4AUYgjnyndVtfUZqYIMGW0SW9Zyxk6SXKfoauu9t8xfXTB4W0WQOqjK8HhSKXV8RK37CWMIdhZyLJ90nMLgQ666h2tWL2sEX8rcoHlBwB2kfnTE2riZHULfDn+yNb/jJ8V89tj/CIW/HNYdXgo/UGO0LkchhL3fDGl/D99nUWXx8JXKM1o9DpBscdqSohwLq6yFt9zlzldLly+69GFsm3I7ySwmHVy8QoFrVTykHEI05c1C2MBgnjwwqgt41fNBCOl5jq5URr+6J0JauQM3ZUsH8Oqi1IDVqcC5XrvQJaiRFwbgrysy3xDA/1Pv0l/GjWoQv9zX5/6wMvZ12e+J0IQ02RAxfju6XAho2BG0kVlZsq0bKHrNjnbMBbWl3XICIyUKpO7KkMBQsWxYjlVkWG8= MIME-Version: 1.0 X-OriginatorOrg: wdc.com X-MS-Exchange-CrossTenant-Network-Message-Id: 471b8b4b-59f3-4b9c-86fb-08d6fc5f006a X-MS-Exchange-CrossTenant-originalarrivaltime: 29 Jun 2019 06:57:08.2585 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: b61c8803-16f3-4c35-9b17-6f65f441df86 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: Anup.Patel@wdc.com X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR04MB6062 Cc: Palmer Dabbelt , U-Boot Mailing List , Bhargav Shah Subject: [U-Boot] [PATCH v2 4/5] riscv: sifive: fu540: Enable SiFive SPI and MMC SPI drivers X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" From: Bhargav Shah This patch enables SiFive SPI and MMC SPI drivers for the SiFive Unleashed board. Signed-off-by: Bhargav Shah Signed-off-by: Anup Patel Reviewed-by: Bin Meng Tested-by: Bin Meng --- board/sifive/fu540/Kconfig | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/board/sifive/fu540/Kconfig b/board/sifive/fu540/Kconfig index f46437901d..d6d5c7d170 100644 --- a/board/sifive/fu540/Kconfig +++ b/board/sifive/fu540/Kconfig @@ -38,6 +38,14 @@ config BOARD_SPECIFIC_OPTIONS # dummy imply PHY_LIB imply PHY_MSCC imply SIFIVE_SERIAL + imply SPI + imply DM_SPI + imply SIFIVE_SPI + imply MMC + imply DM_MMC + imply MMC_SPI + imply MMC_BROKEN_CD + imply CMD_MMC imply SMP endif From patchwork Sat Jun 29 06:57:13 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anup Patel X-Patchwork-Id: 1124718 X-Patchwork-Delegate: van.freenix@gmail.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=wdc.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=wdc.com header.i=@wdc.com header.b="RLYo7v+w"; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=sharedspace.onmicrosoft.com header.i=@sharedspace.onmicrosoft.com header.b="Kg5fVo0S"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 45bPcs5qtvz9s3C for ; Sat, 29 Jun 2019 16:59:09 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id 7CDCFC21D8A; Sat, 29 Jun 2019 06:58:31 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id 7521CC21C8B; Sat, 29 Jun 2019 06:57:46 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id A155DC21D9A; Sat, 29 Jun 2019 06:57:22 +0000 (UTC) Received: from esa1.hgst.iphmx.com (esa1.hgst.iphmx.com [68.232.141.245]) by lists.denx.de (Postfix) with ESMTPS id CD3B4C21E13 for ; Sat, 29 Jun 2019 06:57:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1561791436; x=1593327436; h=from:to:cc:subject:date:message-id:references: in-reply-to:content-transfer-encoding:mime-version; bh=rWEo8avbuZ3wwsXmsx07PaTz2ldQ/mjaOmUa83QQe3M=; b=RLYo7v+wV+xlVyXwRr41fT6U06MARROuMn0rpuprG2nva5oKkwPsfIEO v3CUZDiVt8z1VEfY7l7XblbBrUznxmXPEQuStl0YJqoOUCWEjLMd1flcA lUUiOV9su0/YlRUYfJzS5NeFUDZcPY8lClpATfAQd4F/KgmW0xNq+s6ET JLJCKTJyPbi2oB4AqSfRvS/LUHeX1xZQq6RGoQEtWogdBSd879zQGIHP3 ZbCC8ImZKA3WP5B9XisdxlTh2QVwDB9RSTAx3fQzV3zd6qVlazbC+gRyr rJXBEzMeAANo+RIQWOgFOG/7TX0Ixo60wFpWNYNjibLZDSNTHHJ39EjJ7 A==; X-IronPort-AV: E=Sophos;i="5.63,430,1557158400"; d="scan'208";a="218211392" Received: from mail-cys01nam02lp2053.outbound.protection.outlook.com (HELO NAM02-CY1-obe.outbound.protection.outlook.com) ([104.47.37.53]) by ob1.hgst.iphmx.com with ESMTP; 29 Jun 2019 14:57:14 +0800 ARC-Seal: i=1; a=rsa-sha256; s=testarcselector01; d=microsoft.com; cv=none; b=tJtmT4ADV/UPyTb6lngJJeaXP294cBwTARo2gtoR5GsjPOGaPwCCv6rDW+wL11ySCyhvkErlqXT8lYcjtAIp7+HQnY/ndQbiy21zkmNVUMjW3j0/wbpHMiHwyVSh65ww9HqznT/94nDcEVOytZa7+2F8iQPnJqKo8EBuY69TpjE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=testarcselector01; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=rWEo8avbuZ3wwsXmsx07PaTz2ldQ/mjaOmUa83QQe3M=; b=PY4QxpGDBLOfU6/dQ63Z59c7YVWylTs8eNFQkh9q6Nd09PLikjDQtL5WvoSpNv0pMzEGtrX4TSRUTGEHX8YwXlGv/zPpBbiVo5dusgtdcbY0KZiPHq/xh/sWcv626xJzBhqO8zynG+hldgE8xlO90/O9PINqL5iFAnsOD2RH5JM= ARC-Authentication-Results: i=1; test.office365.com 1;spf=none;dmarc=none;dkim=none;arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sharedspace.onmicrosoft.com; s=selector2-sharedspace-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=rWEo8avbuZ3wwsXmsx07PaTz2ldQ/mjaOmUa83QQe3M=; b=Kg5fVo0SPWVeSRzxHYs8lgh69LxmzAYBeQiwvADWyeKQwZETbvVohvh7GU4VFLmk1lJM85H4rHztaHf9FYJxGhsqGZIGhb9HRFxhOFAOzUuJj0fPYCU0YO0+VHNDo7NR87rKvFi0cM1xZ4qzu+m36q75jDOYJ8jAc7MINfazMDM= Received: from MN2PR04MB6061.namprd04.prod.outlook.com (20.178.246.15) by MN2PR04MB6062.namprd04.prod.outlook.com (20.178.247.149) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2008.18; Sat, 29 Jun 2019 06:57:13 +0000 Received: from MN2PR04MB6061.namprd04.prod.outlook.com ([fe80::84da:b4e7:4612:48b]) by MN2PR04MB6061.namprd04.prod.outlook.com ([fe80::84da:b4e7:4612:48b%7]) with mapi id 15.20.2032.018; Sat, 29 Jun 2019 06:57:13 +0000 From: Anup Patel To: Rick Chen , Bin Meng , Lukas Auer , Peng Fan , Jagan Teki Thread-Topic: [PATCH v2 5/5] doc: sifive-fu540: Update README for SiFive SPI and MMC SPI drivers Thread-Index: AQHVLkfhVFZgvBGeEUSap5UxHbCLcA== Date: Sat, 29 Jun 2019 06:57:13 +0000 Message-ID: <20190629065621.65587-6-anup.patel@wdc.com> References: <20190629065621.65587-1-anup.patel@wdc.com> In-Reply-To: <20190629065621.65587-1-anup.patel@wdc.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-clientproxiedby: PN1PR0101CA0046.INDPRD01.PROD.OUTLOOK.COM (2603:1096:c00:c::32) To MN2PR04MB6061.namprd04.prod.outlook.com (2603:10b6:208:d8::15) authentication-results: spf=none (sender IP is ) smtp.mailfrom=Anup.Patel@wdc.com; x-ms-exchange-messagesentrepresentingtype: 1 x-mailer: git-send-email 2.17.1 x-originating-ip: [49.207.53.251] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: 2fe02944-a1c4-46ae-3b3b-08d6fc5f0371 x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: BCL:0; PCL:0; RULEID:(2390118)(7020095)(4652040)(8989299)(4534185)(7168020)(4627221)(201703031133081)(201702281549075)(8990200)(5600148)(711020)(4605104)(1401327)(4618075)(2017052603328)(7193020); SRVR:MN2PR04MB6062; x-ms-traffictypediagnostic: MN2PR04MB6062: x-microsoft-antispam-prvs: wdcipoutbound: EOP-TRUE x-ms-oob-tlc-oobclassifiers: OLM:3826; x-forefront-prvs: 0083A7F08A x-forefront-antispam-report: SFV:NSPM; SFS:(10019020)(6029001)(4636009)(376002)(366004)(346002)(39860400002)(396003)(136003)(189003)(199004)(52116002)(71190400001)(54906003)(478600001)(71200400001)(50226002)(2616005)(110136005)(86362001)(11346002)(6486002)(316002)(6436002)(99286004)(446003)(36756003)(72206003)(256004)(6116002)(3846002)(14454004)(186003)(68736007)(7416002)(81156014)(486006)(26005)(476003)(76176011)(81166006)(44832011)(8676002)(8936002)(102836004)(6506007)(66946007)(73956011)(386003)(2906002)(66446008)(66556008)(66476007)(305945005)(1076003)(7736002)(6512007)(5660300002)(4744005)(55236004)(64756008)(4326008)(66066001)(53936002)(25786009); DIR:OUT; SFP:1102; SCL:1; SRVR:MN2PR04MB6062; H:MN2PR04MB6061.namprd04.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A:1; x-ms-exchange-senderadcheck: 1 x-microsoft-antispam-message-info: 2MoTYhhoWxBFSdexBuQsjodAXrSdBUaCrES2n2IccznQlS+RwAiUAPxpS5bEg07MfnjrQNWkUT/3Swo7KkBHcDpQYAZUe5nwboXGZw0FD8lfquptOOQ6B2gIGFWvAQQyWz6NdcorAKuWveXv03C8i+RI6FBXqkswMNZ6H3e7wJN426bGCdZNQndc1e9yC6tWAkSFjEkXpsn0BKecQfsUva3wwi/XnNY+5XK6PCVyD5Ujx8hepNWwfE7vBMJRn/5rkvlCzUuZgfKfn/M+bNp+WDFlIqDxFocEv7PV3j5ZSXlFp7bmtZjWRvpYZJpG7kP34LuG59H7jvwhuLH1Y/YNLK65aNj2qURc9IX8Jq8pjURBZJ894cTMonKmm9jh4V9XJhngBu8q24UaIaDKjW95zcoYljhCqv7qINvRbv70Sn8= MIME-Version: 1.0 X-OriginatorOrg: wdc.com X-MS-Exchange-CrossTenant-Network-Message-Id: 2fe02944-a1c4-46ae-3b3b-08d6fc5f0371 X-MS-Exchange-CrossTenant-originalarrivaltime: 29 Jun 2019 06:57:13.3776 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: b61c8803-16f3-4c35-9b17-6f65f441df86 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: Anup.Patel@wdc.com X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR04MB6062 Cc: Palmer Dabbelt , U-Boot Mailing List , Bhargav Shah Subject: [U-Boot] [PATCH v2 5/5] doc: sifive-fu540: Update README for SiFive SPI and MMC SPI drivers X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" This patch removes SiFive SPI driver and MMC SPI drive from the TODO list in SiFive FU540 README. Signed-off-by: Anup Patel Reviewed-by: Bin Meng Tested-by: Bin Meng --- doc/README.sifive-fu540 | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/doc/README.sifive-fu540 b/doc/README.sifive-fu540 index 33e03dc861..944ba1c8a0 100644 --- a/doc/README.sifive-fu540 +++ b/doc/README.sifive-fu540 @@ -13,9 +13,7 @@ The support for following drivers are already enabled: 3. Cadence MACB ethernet driver for networking support. TODO: -1. SPI host driver is still missing. -2. SPI MMC driver does not compile and needs a re-write using U-Boot DM. -2. U-Boot expects the serial console device entry to be present under /chosen +1. U-Boot expects the serial console device entry to be present under /chosen DT node. Example: chosen { stdout-path = "/soc/serial@10010000:115200";