* [U-Boot] [PATCH 0/4] Marvell SDIO/MMC driver for Sheevaplug
@ 2012-09-21 10:15 DrEagle
2012-09-22 7:15 ` [U-Boot] [PATCH v2 0/5] " DrEagle
` (5 more replies)
0 siblings, 6 replies; 18+ messages in thread
From: DrEagle @ 2012-09-21 10:15 UTC (permalink / raw)
To: u-boot
This serie of patch add SDIO/MMC support to Sheevaplug board
drEagle (4):
Add Marvell SDIO/MMC driver for Kirkwood SoC
Add SDIO/MMC support for kirkwood SoC
Add SDIO/MMC support for Sheevaplug board
Fix env address for Sheevaplug board
arch/arm/include/asm/arch-kirkwood/kirkwood.h | 1 +
board/Marvell/sheevaplug/sheevaplug.c | 11 +
drivers/mmc/Makefile | 1 +
drivers/mmc/mrvl_mmc.c | 277 +++++++++++++++++++++++++
include/configs/sheevaplug.h | 17 +-
include/mrvl_mmc.h | 191 +++++++++++++++++
6 files changed, 495 insertions(+), 3 deletions(-)
create mode 100644 drivers/mmc/mrvl_mmc.c
create mode 100644 include/mrvl_mmc.h
--
1.7.10.4
^ permalink raw reply [flat|nested] 18+ messages in thread
* [U-Boot] [PATCH v2 0/5] Marvell SDIO/MMC driver for Sheevaplug
2012-09-21 10:15 [U-Boot] [PATCH 0/4] Marvell SDIO/MMC driver for Sheevaplug DrEagle
@ 2012-09-22 7:15 ` DrEagle
2012-09-22 7:34 ` DrEagle
` (2 more replies)
2012-09-22 7:15 ` [U-Boot] [PATCH v2 1/5] Add Marvell SDIO/MMC driver for Kirkwood SoC DrEagle
` (4 subsequent siblings)
5 siblings, 3 replies; 18+ messages in thread
From: DrEagle @ 2012-09-22 7:15 UTC (permalink / raw)
To: u-boot
This serie of patch add SDIO/MMC support to Sheevaplug board
Change from v1:
- Fix an issue with most SDHC cards because of timeout delay
drEagle (5):
Add Marvell SDIO/MMC driver for Kirkwood SoC
Add SDIO/MMC support for kirkwood SoC
Add SDIO/MMC support for Sheevaplug board
Fix env address for Sheevaplug board
Fix timeout in Marvell SDIO MMC driver
^ permalink raw reply [flat|nested] 18+ messages in thread
* [U-Boot] [PATCH v2 1/5] Add Marvell SDIO/MMC driver for Kirkwood SoC
2012-09-21 10:15 [U-Boot] [PATCH 0/4] Marvell SDIO/MMC driver for Sheevaplug DrEagle
2012-09-22 7:15 ` [U-Boot] [PATCH v2 0/5] " DrEagle
@ 2012-09-22 7:15 ` DrEagle
2012-09-24 8:42 ` Prafulla Wadaskar
2012-09-22 7:16 ` [U-Boot] [PATCH v2 2/5] Add SDIO/MMC support for kirkwood SoC DrEagle
` (3 subsequent siblings)
5 siblings, 1 reply; 18+ messages in thread
From: DrEagle @ 2012-09-22 7:15 UTC (permalink / raw)
To: u-boot
Add Marvell SDIO/MMC driver for Kirkwood SoC
Signed-off-by: G?rald Kerma <uboot@doukki.net>
Signed-off-by: Lior Amsalem <alior@marvell.com>
---
drivers/mmc/Makefile | 1 +
drivers/mmc/mrvl_mmc.c | 277 ++++++++++++++++++++++++++++++++++++++++++++++++
include/mrvl_mmc.h | 191 +++++++++++++++++++++++++++++++++
3 files changed, 469 insertions(+)
create mode 100644 drivers/mmc/mrvl_mmc.c
create mode 100644 include/mrvl_mmc.h
diff --git a/drivers/mmc/Makefile b/drivers/mmc/Makefile
index 2b96cdc..7f3b7c1 100644
--- a/drivers/mmc/Makefile
+++ b/drivers/mmc/Makefile
@@ -37,6 +37,7 @@ COBJS-$(CONFIG_GENERIC_MMC) += mmc.o
COBJS-$(CONFIG_GENERIC_ATMEL_MCI) += gen_atmel_mci.o
COBJS-$(CONFIG_MMC_SPI) += mmc_spi.o
COBJS-$(CONFIG_ARM_PL180_MMCI) += arm_pl180_mmci.o
+COBJS-$(CONFIG_MRVL_MMC) += mrvl_mmc.o
COBJS-$(CONFIG_MV_SDHCI) += mv_sdhci.o
COBJS-$(CONFIG_MXC_MMC) += mxcmmc.o
COBJS-$(CONFIG_MXS_MMC) += mxsmmc.o
diff --git a/drivers/mmc/mrvl_mmc.c b/drivers/mmc/mrvl_mmc.c
new file mode 100644
index 0000000..8127961
--- /dev/null
+++ b/drivers/mmc/mrvl_mmc.c
@@ -0,0 +1,277 @@
+/*
+ * Driver for Marvell SDIO/MMC controller
+ *
+ * (C) Copyright 2012
+ * Marvell Semiconductor <www.marvell.com>
+ * Written-by: Lior Amsalem <alior@marvell.com>
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ */
+
+#include <common.h>
+#include <malloc.h>
+#include <part.h>
+#include <mmc.h>
+
+#include <mrvl_mmc.h>
+#define MRVL_MMC_MAKE_CMD(c, f) (((c & 0xff) << 8) | (f & 0xff))
+
+
+static int mrvl_mmc_setup_data(struct mmc_data *data)
+{
+ if (data->flags & MMC_DATA_READ) {
+ SDIO_REG_WRITE16(SDIO_SYS_ADDR_LOW,((ulong)(data->dest)) & 0xffff);
+ SDIO_REG_WRITE16(SDIO_SYS_ADDR_HI,(((ulong)data->dest) >> 16) & 0xffff);
+ } else {
+ SDIO_REG_WRITE16(SDIO_SYS_ADDR_LOW,((ulong)(data->src)) & 0xffff);
+ SDIO_REG_WRITE16(SDIO_SYS_ADDR_HI,(((ulong)data->src) >> 16) & 0xffff);
+ }
+
+ SDIO_REG_WRITE16(SDIO_BLK_SIZE, data->blocksize);
+ SDIO_REG_WRITE16(SDIO_BLK_COUNT, data->blocks);
+
+ return 0;
+}
+
+static int mrvl_mmc_send_cmd (struct mmc *mmc, struct mmc_cmd *cmd, struct mmc_data *data)
+{
+ int timeout = 10;
+ ushort waittype = 0;
+ int err = 0 ;
+ ushort response[8], resp_indx = 0;
+ ushort resptype = 0;
+ ushort xfertype = 0;
+
+#ifdef DEBUG
+ printf("cmd [0x%x] resp_type[0x%x] arg[0x%x]\n", cmd->cmdidx, cmd->resp_type, cmd->cmdarg);
+#endif
+
+ /* clear status */
+ SDIO_REG_WRITE16(SDIO_NOR_INTR_STATUS, 0xffff);
+ SDIO_REG_WRITE16(SDIO_ERR_INTR_STATUS, 0xffff);
+
+ /* Checking if card is busy */
+ while ((SDIO_REG_READ16(SDIO_PRESENT_STATE0) & CARD_BUSY)) {
+ if (timeout == 0) {
+ printf("MRVL MMC: card busy!\n");
+ return -1;
+ }
+ timeout--;
+ udelay(1000);
+ }
+
+ /* Set up for a data transfer if we have one */
+ if (data) {
+ int err;
+ err = mrvl_mmc_setup_data(data);
+ if(err)
+ return err;
+ }
+
+ /* Analyzing resptype/xfertype/waittype for the command */
+ if (cmd->resp_type & MMC_RSP_BUSY)
+ resptype |= SDIO_CMD_RSP_48BUSY;
+ else if (cmd->resp_type & MMC_RSP_136)
+ resptype |= SDIO_CMD_RSP_136;
+ else if (cmd->resp_type & MMC_RSP_PRESENT)
+ resptype |= SDIO_CMD_RSP_48;
+ else
+ resptype |= SDIO_CMD_RSP_NONE;
+
+ if (cmd->resp_type & MMC_RSP_CRC)
+ resptype |= SDIO_CMD_CHECK_CMDCRC;
+
+ if (cmd->resp_type & MMC_RSP_OPCODE)
+ resptype |= SDIO_CMD_INDX_CHECK;
+
+ if (cmd->resp_type & MMC_RSP_PRESENT) {
+ resptype |= SDIO_UNEXPECTED_RESP;
+ waittype |= SDIO_NOR_UNEXP_RSP;
+ }
+
+ if (data) {
+ resptype |= SDIO_CMD_DATA_PRESENT | SDIO_CMD_CHECK_DATACRC16;
+ xfertype |= SDIO_XFER_MODE_HW_WR_DATA_EN;
+ if (data->flags & MMC_DATA_READ) {
+ xfertype |= SDIO_XFER_MODE_TO_HOST;
+ waittype = SDIO_NOR_DMA_INI;
+ } else
+ waittype |= SDIO_NOR_XFER_DONE;
+ } else {
+ waittype |= SDIO_NOR_CMD_DONE;
+ }
+
+ /* Setting cmd arguments */
+ SDIO_REG_WRITE16(SDIO_ARG_LOW, (ushort)(cmd->cmdarg & 0xffff));
+ SDIO_REG_WRITE16(SDIO_ARG_HI, (ushort)(cmd->cmdarg >> 16) );
+
+ /* Setting Xfer mode */
+ SDIO_REG_WRITE16(SDIO_XFER_MODE, xfertype);
+
+ /* Sending command */
+ SDIO_REG_WRITE16(SDIO_CMD, MRVL_MMC_MAKE_CMD(cmd->cmdidx, resptype));
+
+ /* Waiting for completion */
+ timeout = 1000000;
+
+ while (!((SDIO_REG_READ16(SDIO_NOR_INTR_STATUS)) & waittype)) {
+ udelay(1);
+ if (SDIO_REG_READ16(SDIO_NOR_INTR_STATUS) & SDIO_NOR_ERROR) {
+#ifdef DEBUG
+ printf("mrvl_mmc_send_cmd: error! cmd : %d, err reg: %04x\n", cmd->cmdidx, SDIO_REG_READ16(SDIO_ERR_INTR_STATUS));
+#endif
+ if (SDIO_REG_READ16(SDIO_ERR_INTR_STATUS) & (SDIO_ERR_CMD_TIMEOUT | SDIO_ERR_DATA_TIMEOUT))
+ return TIMEOUT;
+ return COMM_ERR;
+ }
+ timeout--;
+ if (timeout <= 0) {
+ printf("MRVL MMC: command timed out\n");
+ return TIMEOUT;
+ }
+ }
+
+ /* Handling response */
+ for (resp_indx = 0 ; resp_indx < 8; resp_indx++)
+ response[resp_indx] = SDIO_REG_READ16(SDIO_RSP(resp_indx));
+
+ /* Copy the response to the response buffer */
+ if (cmd->resp_type & MMC_RSP_PRESENT) {
+ cmd->response[0] = ((response[2] & 0x3f) << (8 - 8)) |
+ ((response[1] & 0xffff) << (14 - 8)) |
+ ((response[0] & 0x3ff) << (30 - 8));
+ if (cmd->resp_type & MMC_RSP_136) {
+ cmd->response[3] = ((response[7] & 0x3fff) << 8) |
+ ((response[6] & 0x3ff) << 22);
+ cmd->response[2] = ((response[6] & 0xfc00) >> 10) |
+ ((response[5] & 0xffff) << 6) |
+ ((response[4] & 0x3ff) << 22);
+ cmd->response[1] = ((response[4] & 0xfc00) >> 10) |
+ ((response[3] & 0xffff) << 6) |
+ ((response[2] & 0x3ff) << 22);
+ cmd->response[0] = ((response[2] & 0xfc00) >> 10) |
+ ((response[1] & 0xffff) << 6) |
+ ((response[0] & 0x3ff) << 22);
+ }
+ }
+
+#ifdef DEBUG
+ printf("resp index[0x%x] ", response[0] >> 10);
+ printf("[0x%x] ", cmd->response[0]);
+ printf("[0x%x] ", cmd->response[1]);
+ printf("[0x%x] ", cmd->response[2]);
+ printf("[0x%x] ", cmd->response[3]);
+ printf("\n");
+#endif
+
+ return 0;
+}
+
+static void mrvl_mmc_set_clk(unsigned long clk)
+{
+ unsigned int m;
+
+ m = MRVL_MMC_BASE_FAST_CLOCK/(2*clk) - 1;
+#ifdef DEBUG
+ printf("mrvl_mmc_set_clk: dividor = 0x%x clock=%d\n", m, clk);
+#endif
+ SDIO_REG_WRITE32(SDIO_CLK_DIV, m & 0x7ff);
+ udelay(10*1000);
+}
+
+static void mrvl_mmc_set_bus(unsigned int bus)
+{
+ ushort reg;
+
+#ifdef DEBUG
+ printf("mrvl_mmc_set_bus: bus = 0x%d\n", bus);
+#endif
+ reg = SDIO_REG_READ16(SDIO_HOST_CTRL);
+ reg &= ~(1 << 9);
+ switch (bus) {
+ case 4:
+ reg |= SDIO_HOST_CTRL_DATA_WIDTH_4_BITS;
+ break;
+ case 1:
+ default:
+ reg |= SDIO_HOST_CTRL_DATA_WIDTH_1_BIT;
+ }
+ SDIO_REG_WRITE16(SDIO_HOST_CTRL, reg);
+ udelay(10*1000);
+}
+static void mrvl_mmc_set_ios(struct mmc *mmc)
+{
+#ifdef DEBUG
+ printf("bus[%d] clock[%d]\n", mmc->bus_width, mmc->clock);
+#endif
+ mrvl_mmc_set_bus(mmc->bus_width);
+ mrvl_mmc_set_clk(mmc->clock);
+}
+
+static int mrvl_mmc_init(struct mmc *mmc)
+{
+#ifdef DEBUG
+ printf("mrvl_mmc_init\n");
+#endif
+
+ /* Setting host parameters */
+ SDIO_REG_WRITE16(SDIO_HOST_CTRL,
+ SDIO_HOST_CTRL_TMOUT(0xf) |
+ SDIO_HOST_CTRL_DATA_WIDTH_4_BITS |
+ SDIO_HOST_CTRL_BIG_ENDIAN |
+ SDIO_HOST_CTRL_PUSH_PULL_EN |
+ SDIO_HOST_CTRL_CARD_TYPE_MEM_ONLY );
+ SDIO_REG_WRITE16(SDIO_CLK_CTRL, 0);
+
+ /* enable status */
+ SDIO_REG_WRITE16(SDIO_NOR_STATUS_EN, 0xffff);
+ SDIO_REG_WRITE16(SDIO_ERR_STATUS_EN, 0xffff);
+
+ /* disable interrupts */
+ SDIO_REG_WRITE16(SDIO_NOR_INTR_EN, 0);
+ SDIO_REG_WRITE16(SDIO_ERR_INTR_EN, 0);
+
+ /* SW reset */
+ SDIO_REG_WRITE16(SDIO_SW_RESET,0x100);
+ udelay(10000);
+ return 0;
+}
+
+int mrvl_mmc_initialize(bd_t *bis)
+{
+ struct mmc *mmc = NULL;
+
+ mmc = malloc(sizeof(struct mmc));
+ if (!mmc)
+ return -1;
+
+ sprintf(mmc->name, "MRVL_MMC");
+ mmc->send_cmd = mrvl_mmc_send_cmd;
+ mmc->set_ios = mrvl_mmc_set_ios;
+ mmc->init = mrvl_mmc_init;
+
+ mmc->host_caps = MMC_MODE_4BIT | MMC_MODE_HS;
+ mmc->voltages = MMC_VDD_32_33 | MMC_VDD_33_34;
+ mmc->f_max = MRVL_MMC_CLOCKRATE_MAX;
+ mmc->f_min = MRVL_MMC_CLOCKRATE_MIN;
+ mmc->block_dev.part_type = PART_TYPE_DOS;
+
+ mmc_register(mmc);
+
+ return 0;
+}
diff --git a/include/mrvl_mmc.h b/include/mrvl_mmc.h
new file mode 100644
index 0000000..db3a15a
--- /dev/null
+++ b/include/mrvl_mmc.h
@@ -0,0 +1,191 @@
+/*
+ * (C) Copyright 2012
+ * Marvell Semiconductor <www.marvell.com>
+ * Written-by: Lior Amsalem <alior@marvell.com>
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ */
+#ifndef __MRVL_MMC_H__
+#define __MRVL_MMC_H__
+
+/* General definitions */
+#define P(x) (CONFIG_SYS_MMC_BASE + (x))
+#define SDIO_REG_WRITE32(addr,val) (*(volatile unsigned long*)(P(addr)) = val)
+#define SDIO_REG_WRITE16(addr,val) (*(volatile unsigned short*)(P(addr)) = val)
+#define SDIO_REG_READ16(addr) (*(volatile unsigned short*)(P(addr)))
+#define SDIO_REG_READ32(addr) (*(volatile unsigned long*)(P(addr)))
+
+//#define MVSDMMC_DMA_SIZE 65536
+//#define MVSDMMC_CMD_TIMEOUT 2 /* 100 usec*/
+
+/* The base MMC clock rate */
+#define MRVL_MMC_CLOCKRATE_MIN 250000
+#define MRVL_MMC_CLOCKRATE_MAX 50000000
+#define MRVL_MMC_BASE_FAST_CLOCK 200000000//100000000
+
+/* SDIO register */
+#define SDIO_SYS_ADDR_LOW 0x000
+#define SDIO_SYS_ADDR_HI 0x004
+#define SDIO_BLK_SIZE 0x008
+#define SDIO_BLK_COUNT 0x00c
+#define SDIO_ARG_LOW 0x010
+#define SDIO_ARG_HI 0x014
+#define SDIO_XFER_MODE 0x018
+#define SDIO_CMD 0x01c
+#define SDIO_RSP(i) (0x020 + ((i)<<2))
+#define SDIO_RSP0 0x020
+#define SDIO_RSP1 0x024
+#define SDIO_RSP2 0x028
+#define SDIO_RSP3 0x02c
+#define SDIO_RSP4 0x030
+#define SDIO_RSP5 0x034
+#define SDIO_RSP6 0x038
+#define SDIO_RSP7 0x03c
+#define SDIO_BUF_DATA_PORT 0x040
+#define SDIO_RSVED 0x044
+#define SDIO_PRESENT_STATE0 0x048
+#define SDIO_PRESENT_STATE1 0x04c
+#define SDIO_HOST_CTRL 0x050
+#define SDIO_BLK_GAP_CTRL 0x054
+#define SDIO_CLK_CTRL 0x058
+#define SDIO_SW_RESET 0x05c
+#define SDIO_NOR_INTR_STATUS 0x060
+#define SDIO_ERR_INTR_STATUS 0x064
+#define SDIO_NOR_STATUS_EN 0x068
+#define SDIO_ERR_STATUS_EN 0x06c
+#define SDIO_NOR_INTR_EN 0x070
+#define SDIO_ERR_INTR_EN 0x074
+#define SDIO_AUTOCMD12_ERR_STATUS 0x078
+#define SDIO_CURR_BYTE_LEFT 0x07c
+#define SDIO_CURR_BLK_LEFT 0x080
+#define SDIO_AUTOCMD12_ARG_LOW 0x084
+#define SDIO_AUTOCMD12_ARG_HI 0x088
+#define SDIO_AUTOCMD12_INDEX 0x08c
+#define SDIO_AUTO_RSP(i) (0x090 + ((i)<<2))
+#define SDIO_AUTO_RSP0 0x090
+#define SDIO_AUTO_RSP1 0x094
+#define SDIO_AUTO_RSP2 0x098
+#define SDIO_CLK_DIV 0x128
+
+#define WINDOW_CTRL(i) (0x108 + ((i) << 3))
+#define WINDOW_BASE(i) (0x10c + ((i) << 3))
+
+/* SDIO_PRESENT_STATE */
+#define CARD_BUSY (1 << 1)
+#define CMD_INHIBIT (1 << 0)
+#define CMD_TXACTIVE (1 << 8)
+#define CMD_RXACTIVE (1 << 9)
+#define CMD_AUTOCMD12ACTIVE (1 << 14)
+#define CMD_BUS_BUSY (CMD_AUTOCMD12ACTIVE | \
+ CMD_RXACTIVE | \
+ CMD_TXACTIVE | \
+ CMD_INHIBIT | \
+ CARD_BUSY)
+
+/* SDIO_CMD */
+#define SDIO_CMD_RSP_NONE (0 << 0)
+#define SDIO_CMD_RSP_136 (1 << 0)
+#define SDIO_CMD_RSP_48 (2 << 0)
+#define SDIO_CMD_RSP_48BUSY (3 << 0)
+#define SDIO_CMD_CHECK_DATACRC16 (1 << 2)
+#define SDIO_CMD_CHECK_CMDCRC (1 << 3)
+#define SDIO_CMD_INDX_CHECK (1 << 4)
+#define SDIO_CMD_DATA_PRESENT (1 << 5)
+#define SDIO_UNEXPECTED_RESP (1 << 7)
+
+/* SDIO_XFER_MODE */
+#define SDIO_XFER_MODE_STOP_CLK (1 << 5)
+#define SDIO_XFER_MODE_HW_WR_DATA_EN (1 << 1)
+#define SDIO_XFER_MODE_AUTO_CMD12 (1 << 2)
+#define SDIO_XFER_MODE_INT_CHK_EN (1 << 3)
+#define SDIO_XFER_MODE_TO_HOST (1 << 4)
+#define SDIO_XFER_MODE_DMA (0 << 6)
+
+/* SDIO_HOST_CTRL */
+#define SDIO_HOST_CTRL_PUSH_PULL_EN (1 << 0)
+#define SDIO_HOST_CTRL_CARD_TYPE_MEM_ONLY (0 << 1)
+#define SDIO_HOST_CTRL_CARD_TYPE_IO_ONLY (1 << 1)
+#define SDIO_HOST_CTRL_CARD_TYPE_IO_MEM_COMBO (2 << 1)
+#define SDIO_HOST_CTRL_CARD_TYPE_MMC (3 << 1)
+#define SDIO_HOST_CTRL_CARD_TYPE_MASK (3 << 1)
+#define SDIO_HOST_CTRL_BIG_ENDIAN (1 << 3)
+#define SDIO_HOST_CTRL_LSB_FIRST (1 << 4)
+#define SDIO_HOST_CTRL_ID_MODE_LOW_FREQ (1 << 5)
+#define SDIO_HOST_CTRL_HALF_SPEED (1 << 6)
+#define SDIO_HOST_CTRL_DATA_WIDTH_1_BIT (0 << 9)
+#define SDIO_HOST_CTRL_DATA_WIDTH_4_BITS (1 << 9)
+#define SDIO_HOST_CTRL_HI_SPEED_EN (1 << 10)
+#define SDIO_HOST_CTRL_TMOUT_MASK (0xf << 11)
+#define SDIO_HOST_CTRL_TMOUT_MAX (0xf << 11)
+#define SDIO_HOST_CTRL_TMOUT(x) ((x) << 11)
+#define SDIO_HOST_CTRL_TMOUT_EN (1 << 15)
+#define SDIO_HOST_CTRL_DFAULT_OPEN_DRAIN (SDIO_HOST_CTRL_TMOUT(x)(0xf))
+#define SDIO_HOST_CTRL_DFAULT_PUSH_PULL (SDIO_HOST_CTRL_TMOUT(x)(0xf) | SDIO_HOST_CTRL_PUSH_PULL_EN)
+
+/* NOR status bits */
+#define SDIO_NOR_ERROR (1 << 15)
+#define SDIO_NOR_UNEXP_RSP (1 << 14)
+#define SDIO_NOR_AUTOCMD12_DONE (1 << 13)
+#define SDIO_NOR_SUSPEND_ON (1 << 12)
+#define SDIO_NOR_LMB_FF_8W_AVAIL (1 << 11)
+#define SDIO_NOR_LMB_FF_8W_FILLED (1 << 10)
+#define SDIO_NOR_READ_WAIT_ON (1 << 9)
+#define SDIO_NOR_CARD_INT (1 << 8)
+#define SDIO_NOR_READ_READY (1 << 5)
+#define SDIO_NOR_WRITE_READY (1 << 4)
+#define SDIO_NOR_DMA_INI (1 << 3)
+#define SDIO_NOR_BLK_GAP_EVT (1 << 2)
+#define SDIO_NOR_XFER_DONE (1 << 1)
+#define SDIO_NOR_CMD_DONE (1 << 0)
+
+/* ERR status bits */
+#define SDIO_ERR_CRC_STATUS (1 << 14)
+#define SDIO_ERR_CRC_STARTBIT (1 << 13)
+#define SDIO_ERR_CRC_ENDBIT (1 << 12)
+#define SDIO_ERR_RESP_TBIT (1 << 11)
+#define SDIO_ERR_SIZE (1 << 10)
+#define SDIO_ERR_CMD_STARTBIT (1 << 9)
+#define SDIO_ERR_AUTOCMD12 (1 << 8)
+#define SDIO_ERR_DATA_ENDBIT (1 << 6)
+#define SDIO_ERR_DATA_CRC (1 << 5)
+#define SDIO_ERR_DATA_TIMEOUT (1 << 4)
+#define SDIO_ERR_CMD_INDEX (1 << 3)
+#define SDIO_ERR_CMD_ENDBIT (1 << 2)
+#define SDIO_ERR_CMD_CRC (1 << 1)
+#define SDIO_ERR_CMD_TIMEOUT (1 << 0)
+#define SDIO_POLL_MASK 0xffff /* enable all for polling */
+
+/* MMC commands */
+#define MMC_BLOCK_SIZE 512
+#define MMC_CMD_RESET 0
+#define MMC_CMD_SEND_OP_COND 1
+#define MMC_CMD_ALL_SEND_CID 2
+#define MMC_CMD_SET_RCA 3
+#define MMC_CMD_SELECT_CARD 7
+#define MMC_CMD_SEND_CSD 9
+#define MMC_CMD_SEND_CID 10
+#define MMC_CMD_SEND_STATUS 13
+#define MMC_CMD_SET_BLOCKLEN 16
+#define MMC_CMD_READ_BLOCK 17
+#define MMC_CMD_RD_BLK_MULTI 18
+#define MMC_CMD_WRITE_BLOCK 24
+#define MMC_MAX_BLOCK_SIZE 512
+
+#endif /* __MRVL_MMC_H__ */
+
+int mrvl_mmc_initialize(bd_t *bis);
--
1.7.10.4
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [U-Boot] [PATCH v2 2/5] Add SDIO/MMC support for kirkwood SoC
2012-09-21 10:15 [U-Boot] [PATCH 0/4] Marvell SDIO/MMC driver for Sheevaplug DrEagle
2012-09-22 7:15 ` [U-Boot] [PATCH v2 0/5] " DrEagle
2012-09-22 7:15 ` [U-Boot] [PATCH v2 1/5] Add Marvell SDIO/MMC driver for Kirkwood SoC DrEagle
@ 2012-09-22 7:16 ` DrEagle
2012-09-24 8:44 ` Prafulla Wadaskar
2012-09-22 7:17 ` [U-Boot] [PATCH v2 3/5] Add SDIO/MMC support for Sheevaplug board DrEagle
` (2 subsequent siblings)
5 siblings, 1 reply; 18+ messages in thread
From: DrEagle @ 2012-09-22 7:16 UTC (permalink / raw)
To: u-boot
Add SDIO/MMC support for kirkwood SoC
Signed-off-by: drEagle <dreagle@doukki.net>
---
arch/arm/include/asm/arch-kirkwood/kirkwood.h | 1 +
1 file changed, 1 insertion(+)
diff --git a/arch/arm/include/asm/arch-kirkwood/kirkwood.h b/arch/arm/include/asm/arch-kirkwood/kirkwood.h
index 47771d5..343214b 100644
--- a/arch/arm/include/asm/arch-kirkwood/kirkwood.h
+++ b/arch/arm/include/asm/arch-kirkwood/kirkwood.h
@@ -55,6 +55,7 @@
#define KW_EGIGA0_BASE (KW_REGISTER(0x72000))
#define KW_EGIGA1_BASE (KW_REGISTER(0x76000))
#define KW_SATA_BASE (KW_REGISTER(0x80000))
+#define KW_SDIO_BASE (KW_REGISTER(0x90000))
/* Kirkwood Sata controller has two ports */
#define KW_SATA_PORT0_OFFSET 0x2000
--
1.7.10.4
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [U-Boot] [PATCH v2 3/5] Add SDIO/MMC support for Sheevaplug board
2012-09-21 10:15 [U-Boot] [PATCH 0/4] Marvell SDIO/MMC driver for Sheevaplug DrEagle
` (2 preceding siblings ...)
2012-09-22 7:16 ` [U-Boot] [PATCH v2 2/5] Add SDIO/MMC support for kirkwood SoC DrEagle
@ 2012-09-22 7:17 ` DrEagle
2012-09-24 8:46 ` Prafulla Wadaskar
2012-09-22 7:18 ` [U-Boot] [PATCH v2 4/5] Fix env address " DrEagle
2012-09-22 7:18 ` [U-Boot] [PATCH v2 5/5] Fix timeout in Marvell SDIO MMC driver DrEagle
5 siblings, 1 reply; 18+ messages in thread
From: DrEagle @ 2012-09-22 7:17 UTC (permalink / raw)
To: u-boot
Add SDIO/MMC support for Sheevaplug board
Signed-off-by: drEagle <dreagle@doukki.net>
---
board/Marvell/sheevaplug/sheevaplug.c | 11 +++++++++++
include/configs/sheevaplug.h | 12 ++++++++++++
2 files changed, 23 insertions(+)
diff --git a/board/Marvell/sheevaplug/sheevaplug.c b/board/Marvell/sheevaplug/sheevaplug.c
index 688d308..db64a05 100644
--- a/board/Marvell/sheevaplug/sheevaplug.c
+++ b/board/Marvell/sheevaplug/sheevaplug.c
@@ -28,6 +28,9 @@
#include <asm/arch/kirkwood.h>
#include <asm/arch/mpp.h>
#include "sheevaplug.h"
+#ifdef CONFIG_MRVL_MMC
+#include <mrvl_mmc.h>
+#endif /* CONFIG_MRVL_MMC */
DECLARE_GLOBAL_DATA_PTR;
@@ -147,3 +150,11 @@ void reset_phy(void)
printf("88E1116 Initialized on %s\n", name);
}
#endif /* CONFIG_RESET_PHY_R */
+
+#ifdef CONFIG_MRVL_MMC
+int board_mmc_init(bd_t *bis)
+{
+ mrvl_mmc_initialize(bis);
+ return 0;
+}
+#endif /* CONFIG_MRVL_MMC */
diff --git a/include/configs/sheevaplug.h b/include/configs/sheevaplug.h
index 83dd8ff..7d710bf 100644
--- a/include/configs/sheevaplug.h
+++ b/include/configs/sheevaplug.h
@@ -47,6 +47,7 @@
#define CONFIG_CMD_DHCP
#define CONFIG_CMD_ENV
#define CONFIG_CMD_MII
+#define CONFIG_CMD_MMC
#define CONFIG_CMD_NAND
#define CONFIG_CMD_PING
#define CONFIG_CMD_USB
@@ -98,6 +99,17 @@
#endif /* CONFIG_CMD_NET */
/*
+ * SDIO/MMC Card Configuration
+ */
+#ifdef CONFIG_CMD_MMC
+#define CONFIG_MMC
+#define CONFIG_GENERIC_MMC
+#define CONFIG_MRVL_MMC
+#define CONFIG_SYS_MMC_BASE KW_SDIO_BASE
+#endif /* CONFIG_CMD_MMC */
+
+
+/*
* File system
*/
#define CONFIG_CMD_EXT2
--
1.7.10.4
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [U-Boot] [PATCH v2 4/5] Fix env address for Sheevaplug board
2012-09-21 10:15 [U-Boot] [PATCH 0/4] Marvell SDIO/MMC driver for Sheevaplug DrEagle
` (3 preceding siblings ...)
2012-09-22 7:17 ` [U-Boot] [PATCH v2 3/5] Add SDIO/MMC support for Sheevaplug board DrEagle
@ 2012-09-22 7:18 ` DrEagle
2012-09-24 8:46 ` Prafulla Wadaskar
2012-09-22 7:18 ` [U-Boot] [PATCH v2 5/5] Fix timeout in Marvell SDIO MMC driver DrEagle
5 siblings, 1 reply; 18+ messages in thread
From: DrEagle @ 2012-09-22 7:18 UTC (permalink / raw)
To: u-boot
Fix env address for Sheevaplug board
Move env address and offset from 0x60000 to 0x80000
Signed-off-by: drEagle <dreagle@doukki.net>
---
include/configs/sheevaplug.h | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/include/configs/sheevaplug.h b/include/configs/sheevaplug.h
index 7d710bf..a10e825 100644
--- a/include/configs/sheevaplug.h
+++ b/include/configs/sheevaplug.h
@@ -71,9 +71,8 @@
* it has to be rounded to sector size
*/
#define CONFIG_ENV_SIZE 0x20000 /* 128k */
-#define CONFIG_ENV_ADDR 0x60000
-#define CONFIG_ENV_OFFSET 0x60000 /* env starts here */
-
+#define CONFIG_ENV_ADDR 0x80000
+#define CONFIG_ENV_OFFSET 0x80000 /* env starts here */
/*
* Default environment variables
*/
--
1.7.10.4
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [U-Boot] [PATCH v2 5/5] Fix timeout in Marvell SDIO MMC driver
2012-09-21 10:15 [U-Boot] [PATCH 0/4] Marvell SDIO/MMC driver for Sheevaplug DrEagle
` (4 preceding siblings ...)
2012-09-22 7:18 ` [U-Boot] [PATCH v2 4/5] Fix env address " DrEagle
@ 2012-09-22 7:18 ` DrEagle
2012-09-24 8:44 ` Prafulla Wadaskar
5 siblings, 1 reply; 18+ messages in thread
From: DrEagle @ 2012-09-22 7:18 UTC (permalink / raw)
To: u-boot
Fix an issue with most SDHC cards because of timeout delay
Signed-off-by: drEagle <dreagle@doukki.net>
---
drivers/mmc/mrvl_mmc.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/drivers/mmc/mrvl_mmc.c b/drivers/mmc/mrvl_mmc.c
index 8127961..bdafbc7 100644
--- a/drivers/mmc/mrvl_mmc.c
+++ b/drivers/mmc/mrvl_mmc.c
@@ -4,6 +4,7 @@
* (C) Copyright 2012
* Marvell Semiconductor <www.marvell.com>
* Written-by: Lior Amsalem <alior@marvell.com>
+ * Written-by: G?rald Kerma <uboot@doukki.net>
* See file CREDITS for list of people who contributed to this
* project.
*
@@ -127,10 +128,9 @@ static int mrvl_mmc_send_cmd (struct mmc *mmc, struct mmc_cmd *cmd, struct mmc_d
SDIO_REG_WRITE16(SDIO_CMD, MRVL_MMC_MAKE_CMD(cmd->cmdidx, resptype));
/* Waiting for completion */
- timeout = 1000000;
+ timeout = 10000;
while (!((SDIO_REG_READ16(SDIO_NOR_INTR_STATUS)) & waittype)) {
- udelay(1);
if (SDIO_REG_READ16(SDIO_NOR_INTR_STATUS) & SDIO_NOR_ERROR) {
#ifdef DEBUG
printf("mrvl_mmc_send_cmd: error! cmd : %d, err reg: %04x\n", cmd->cmdidx, SDIO_REG_READ16(SDIO_ERR_INTR_STATUS));
@@ -139,6 +139,7 @@ static int mrvl_mmc_send_cmd (struct mmc *mmc, struct mmc_cmd *cmd, struct mmc_d
return TIMEOUT;
return COMM_ERR;
}
+ udelay(1000);
timeout--;
if (timeout <= 0) {
printf("MRVL MMC: command timed out\n");
--
1.7.10.4
^ permalink raw reply related [flat|nested] 18+ messages in thread
* [U-Boot] [PATCH v2 0/5] Marvell SDIO/MMC driver for Sheevaplug
2012-09-22 7:15 ` [U-Boot] [PATCH v2 0/5] " DrEagle
@ 2012-09-22 7:34 ` DrEagle
2012-09-24 8:50 ` Prafulla Wadaskar
2012-09-24 7:36 ` Prafulla Wadaskar
2012-09-24 8:48 ` Prafulla Wadaskar
2 siblings, 1 reply; 18+ messages in thread
From: DrEagle @ 2012-09-22 7:34 UTC (permalink / raw)
To: u-boot
Hi,
I found an issue of timeout problems.
Now all my cards read correctly, quickly and efficiently.
If someone need a precompiled u-boot binary for testing this version, fell free to ask.
I will put it available online.
Le 22/09/2012 09:15, DrEagle a ?crit :
>
> This serie of patch add SDIO/MMC support to Sheevaplug board
>
> Change from v1:
> - Fix an issue with most SDHC cards because of timeout delay
>
> drEagle (5):
> Add Marvell SDIO/MMC driver for Kirkwood SoC
> Add SDIO/MMC support for kirkwood SoC
> Add SDIO/MMC support for Sheevaplug board
> Fix env address for Sheevaplug board
> Fix timeout in Marvell SDIO MMC driver
>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 551 bytes
Desc: OpenPGP digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20120922/582bd240/attachment.pgp>
^ permalink raw reply [flat|nested] 18+ messages in thread
* [U-Boot] [PATCH v2 0/5] Marvell SDIO/MMC driver for Sheevaplug
2012-09-22 7:15 ` [U-Boot] [PATCH v2 0/5] " DrEagle
2012-09-22 7:34 ` DrEagle
@ 2012-09-24 7:36 ` Prafulla Wadaskar
2012-09-24 8:48 ` Prafulla Wadaskar
2 siblings, 0 replies; 18+ messages in thread
From: Prafulla Wadaskar @ 2012-09-24 7:36 UTC (permalink / raw)
To: u-boot
> -----Original Message-----
> From: u-boot-bounces at lists.denx.de [mailto:u-boot-
> bounces at lists.denx.de] On Behalf Of DrEagle
> Sent: 22 September 2012 12:45
> To: DrEagle
> Cc: Lior Amsalem; u-boot at lists.denx.de; uboot at doukki.net
> Subject: [U-Boot] [PATCH v2 0/5] Marvell SDIO/MMC driver for
> Sheevaplug
>
>
> This serie of patch add SDIO/MMC support to Sheevaplug board
>
> Change from v1:
> - Fix an issue with most SDHC cards because of timeout delay
>
> drEagle (5):
> Add Marvell SDIO/MMC driver for Kirkwood SoC
> Add SDIO/MMC support for kirkwood SoC
> Add SDIO/MMC support for Sheevaplug board
Hi DrEagle
Thanks for this patch series.
Copying Andy Fleming being MMC custodian
> Fix env address for Sheevaplug board
> Fix timeout in Marvell SDIO MMC driver
Below these could be standalone patch can be posted independently (not part of this patch series)
Regards...
Prafulla . . .
^ permalink raw reply [flat|nested] 18+ messages in thread
* [U-Boot] [PATCH v2 1/5] Add Marvell SDIO/MMC driver for Kirkwood SoC
2012-09-22 7:15 ` [U-Boot] [PATCH v2 1/5] Add Marvell SDIO/MMC driver for Kirkwood SoC DrEagle
@ 2012-09-24 8:42 ` Prafulla Wadaskar
0 siblings, 0 replies; 18+ messages in thread
From: Prafulla Wadaskar @ 2012-09-24 8:42 UTC (permalink / raw)
To: u-boot
> -----Original Message-----
> From: u-boot-bounces at lists.denx.de [mailto:u-boot-
> bounces at lists.denx.de] On Behalf Of DrEagle
> Sent: 22 September 2012 12:46
> To: DrEagle
> Cc: Lior Amsalem; u-boot at lists.denx.de; uboot at doukki.net
> Subject: [U-Boot] [PATCH v2 1/5] Add Marvell SDIO/MMC driver for
> Kirkwood SoC
>
>
> Add Marvell SDIO/MMC driver for Kirkwood SoC
>
> Signed-off-by: G?rald Kerma <uboot@doukki.net>
> Signed-off-by: Lior Amsalem <alior@marvell.com>
> ---
> drivers/mmc/Makefile | 1 +
> drivers/mmc/mrvl_mmc.c | 277
The file name should be kirkwood_mmc.*
> ++++++++++++++++++++++++++++++++++++++++++++++++
> include/mrvl_mmc.h | 191 +++++++++++++++++++++++++++++++++
Ditto
> 3 files changed, 469 insertions(+)
> create mode 100644 drivers/mmc/mrvl_mmc.c
> create mode 100644 include/mrvl_mmc.h
>
> diff --git a/drivers/mmc/Makefile b/drivers/mmc/Makefile
> index 2b96cdc..7f3b7c1 100644
> --- a/drivers/mmc/Makefile
> +++ b/drivers/mmc/Makefile
> @@ -37,6 +37,7 @@ COBJS-$(CONFIG_GENERIC_MMC) += mmc.o
> COBJS-$(CONFIG_GENERIC_ATMEL_MCI) += gen_atmel_mci.o
> COBJS-$(CONFIG_MMC_SPI) += mmc_spi.o
> COBJS-$(CONFIG_ARM_PL180_MMCI) += arm_pl180_mmci.o
> +COBJS-$(CONFIG_MRVL_MMC) += mrvl_mmc.o
This should be CONFIG_KIRKWOOD_MMC
> COBJS-$(CONFIG_MV_SDHCI) += mv_sdhci.o
> COBJS-$(CONFIG_MXC_MMC) += mxcmmc.o
> COBJS-$(CONFIG_MXS_MMC) += mxsmmc.o
> diff --git a/drivers/mmc/mrvl_mmc.c b/drivers/mmc/mrvl_mmc.c
> new file mode 100644
> index 0000000..8127961
> --- /dev/null
> +++ b/drivers/mmc/mrvl_mmc.c
> @@ -0,0 +1,277 @@
> +/*
> + * Driver for Marvell SDIO/MMC controller
> + *
> + * (C) Copyright 2012
> + * Marvell Semiconductor <www.marvell.com>
> + * Written-by: Lior Amsalem <alior@marvell.com>
> + * See file CREDITS for list of people who contributed to this
> + * project.
> + *
> + * This program is free software; you can redistribute it and/or
> + * modify it under the terms of the GNU General Public License as
> + * published by the Free Software Foundation; either version 2 of
> + * the License, or (at your option) any later version.
> + *
> + * This program is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
> + * GNU General Public License for more details.
> + *
> + * You should have received a copy of the GNU General Public License
> + * along with this program; if not, write to the Free Software
> + * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
> + * MA 02111-1307 USA
> + */
> +
> +#include <common.h>
> +#include <malloc.h>
> +#include <part.h>
> +#include <mmc.h>
> +
> +#include <mrvl_mmc.h>
> +#define MRVL_MMC_MAKE_CMD(c, f) (((c & 0xff) << 8) | (f & 0xff))
Since this is Kirkwood MMC driver you should use KW_ suffix for all macros and kw_ suffix for all function/variable names.
MRVL is generic to marvell and valid if this driver is applicable to all Marvell SOCs.
> +
> +
> +static int mrvl_mmc_setup_data(struct mmc_data *data)
> +{
> + if (data->flags & MMC_DATA_READ) {
> + SDIO_REG_WRITE16(SDIO_SYS_ADDR_LOW,((ulong)(data->dest)) &
No need to define these macros use standard readl/writel calls for register r/w operation.
> 0xffff);
> + SDIO_REG_WRITE16(SDIO_SYS_ADDR_HI,(((ulong)data->dest) >> 16)
> & 0xffff);
> + } else {
> + SDIO_REG_WRITE16(SDIO_SYS_ADDR_LOW,((ulong)(data->src)) &
> 0xffff);
> + SDIO_REG_WRITE16(SDIO_SYS_ADDR_HI,(((ulong)data->src) >> 16) &
> 0xffff);
> + }
> +
> + SDIO_REG_WRITE16(SDIO_BLK_SIZE, data->blocksize);
> + SDIO_REG_WRITE16(SDIO_BLK_COUNT, data->blocks);
> +
> + return 0;
> +}
> +
> +static int mrvl_mmc_send_cmd (struct mmc *mmc, struct mmc_cmd *cmd,
> struct mmc_data *data)
> +{
> + int timeout = 10;
> + ushort waittype = 0;
> + int err = 0 ;
> + ushort response[8], resp_indx = 0;
> + ushort resptype = 0;
> + ushort xfertype = 0;
> +
> +#ifdef DEBUG
> + printf("cmd [0x%x] resp_type[0x%x] arg[0x%x]\n", cmd->cmdidx, cmd-
> >resp_type, cmd->cmdarg);
> +#endif
> +
> + /* clear status */
> + SDIO_REG_WRITE16(SDIO_NOR_INTR_STATUS, 0xffff);
> + SDIO_REG_WRITE16(SDIO_ERR_INTR_STATUS, 0xffff);
> +
> + /* Checking if card is busy */
> + while ((SDIO_REG_READ16(SDIO_PRESENT_STATE0) & CARD_BUSY)) {
> + if (timeout == 0) {
> + printf("MRVL MMC: card busy!\n");
> + return -1;
> + }
> + timeout--;
> + udelay(1000);
Can you avoid this delay, may you increase timeout value and avoid this udelay?
> + }
> +
> + /* Set up for a data transfer if we have one */
> + if (data) {
> + int err;
Defined should be done at the top, but you can avoid this by directly using function call in if statement
> + err = mrvl_mmc_setup_data(data);
> + if(err)
> + return err;
You can reduce the code here to two lines.
> + }
> +
> + /* Analyzing resptype/xfertype/waittype for the command */
> + if (cmd->resp_type & MMC_RSP_BUSY)
> + resptype |= SDIO_CMD_RSP_48BUSY;
> + else if (cmd->resp_type & MMC_RSP_136)
> + resptype |= SDIO_CMD_RSP_136;
> + else if (cmd->resp_type & MMC_RSP_PRESENT)
> + resptype |= SDIO_CMD_RSP_48;
> + else
> + resptype |= SDIO_CMD_RSP_NONE;
> +
> + if (cmd->resp_type & MMC_RSP_CRC)
> + resptype |= SDIO_CMD_CHECK_CMDCRC;
> +
> + if (cmd->resp_type & MMC_RSP_OPCODE)
> + resptype |= SDIO_CMD_INDX_CHECK;
> +
> + if (cmd->resp_type & MMC_RSP_PRESENT) {
> + resptype |= SDIO_UNEXPECTED_RESP;
> + waittype |= SDIO_NOR_UNEXP_RSP;
> + }
> +
> + if (data) {
> + resptype |= SDIO_CMD_DATA_PRESENT | SDIO_CMD_CHECK_DATACRC16;
> + xfertype |= SDIO_XFER_MODE_HW_WR_DATA_EN;
> + if (data->flags & MMC_DATA_READ) {
> + xfertype |= SDIO_XFER_MODE_TO_HOST;
> + waittype = SDIO_NOR_DMA_INI;
> + } else
> + waittype |= SDIO_NOR_XFER_DONE;
> + } else {
> + waittype |= SDIO_NOR_CMD_DONE;
> + }
> +
> + /* Setting cmd arguments */
> + SDIO_REG_WRITE16(SDIO_ARG_LOW, (ushort)(cmd->cmdarg & 0xffff));
> + SDIO_REG_WRITE16(SDIO_ARG_HI, (ushort)(cmd->cmdarg >> 16) );
Avoid hard coding, use macros, some comments too
> +
> + /* Setting Xfer mode */
> + SDIO_REG_WRITE16(SDIO_XFER_MODE, xfertype);
> +
> + /* Sending command */
> + SDIO_REG_WRITE16(SDIO_CMD, MRVL_MMC_MAKE_CMD(cmd->cmdidx,
> resptype));
> +
> + /* Waiting for completion */
> + timeout = 1000000;
> +
> + while (!((SDIO_REG_READ16(SDIO_NOR_INTR_STATUS)) & waittype)) {
> + udelay(1);
> + if (SDIO_REG_READ16(SDIO_NOR_INTR_STATUS) & SDIO_NOR_ERROR) {
> +#ifdef DEBUG
> + printf("mrvl_mmc_send_cmd: error! cmd : %d, err reg:
> %04x\n", cmd->cmdidx, SDIO_REG_READ16(SDIO_ERR_INTR_STATUS));
> +#endif
> + if (SDIO_REG_READ16(SDIO_ERR_INTR_STATUS) &
> (SDIO_ERR_CMD_TIMEOUT | SDIO_ERR_DATA_TIMEOUT))
> + return TIMEOUT;
> + return COMM_ERR;
> + }
> + timeout--;
> + if (timeout <= 0) {
> + printf("MRVL MMC: command timed out\n");
> + return TIMEOUT;
> + }
> + }
> +
> + /* Handling response */
> + for (resp_indx = 0 ; resp_indx < 8; resp_indx++)
^ permalink raw reply [flat|nested] 18+ messages in thread
* [U-Boot] [PATCH v2 2/5] Add SDIO/MMC support for kirkwood SoC
2012-09-22 7:16 ` [U-Boot] [PATCH v2 2/5] Add SDIO/MMC support for kirkwood SoC DrEagle
@ 2012-09-24 8:44 ` Prafulla Wadaskar
0 siblings, 0 replies; 18+ messages in thread
From: Prafulla Wadaskar @ 2012-09-24 8:44 UTC (permalink / raw)
To: u-boot
> -----Original Message-----
> From: u-boot-bounces at lists.denx.de [mailto:u-boot-
> bounces at lists.denx.de] On Behalf Of DrEagle
> Sent: 22 September 2012 12:47
> To: DrEagle
> Cc: Lior Amsalem; u-boot at lists.denx.de; uboot at doukki.net
> Subject: [U-Boot] [PATCH v2 2/5] Add SDIO/MMC support for kirkwood SoC
>
>
> Add SDIO/MMC support for kirkwood SoC
>
> Signed-off-by: drEagle <dreagle@doukki.net>
> ---
> arch/arm/include/asm/arch-kirkwood/kirkwood.h | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/arch/arm/include/asm/arch-kirkwood/kirkwood.h
> b/arch/arm/include/asm/arch-kirkwood/kirkwood.h
> index 47771d5..343214b 100644
> --- a/arch/arm/include/asm/arch-kirkwood/kirkwood.h
> +++ b/arch/arm/include/asm/arch-kirkwood/kirkwood.h
> @@ -55,6 +55,7 @@
> #define KW_EGIGA0_BASE (KW_REGISTER(0x72000))
> #define KW_EGIGA1_BASE (KW_REGISTER(0x76000))
> #define KW_SATA_BASE (KW_REGISTER(0x80000))
> +#define KW_SDIO_BASE (KW_REGISTER(0x90000))
>
> /* Kirkwood Sata controller has two ports */
> #define KW_SATA_PORT0_OFFSET 0x2000
Acked-By: Prafulla Wadaskar <Prafulla@marvell.com>
Regards...
Prafulla . . .
> --
> 1.7.10.4
>
> _______________________________________________
> U-Boot mailing list
> U-Boot at lists.denx.de
> http://lists.denx.de/mailman/listinfo/u-boot
^ permalink raw reply [flat|nested] 18+ messages in thread
* [U-Boot] [PATCH v2 5/5] Fix timeout in Marvell SDIO MMC driver
2012-09-22 7:18 ` [U-Boot] [PATCH v2 5/5] Fix timeout in Marvell SDIO MMC driver DrEagle
@ 2012-09-24 8:44 ` Prafulla Wadaskar
0 siblings, 0 replies; 18+ messages in thread
From: Prafulla Wadaskar @ 2012-09-24 8:44 UTC (permalink / raw)
To: u-boot
> -----Original Message-----
> From: u-boot-bounces at lists.denx.de [mailto:u-boot-
> bounces at lists.denx.de] On Behalf Of DrEagle
> Sent: 22 September 2012 12:49
> To: DrEagle
> Cc: Lior Amsalem; u-boot at lists.denx.de; uboot at doukki.net
> Subject: [U-Boot] [PATCH v2 5/5] Fix timeout in Marvell SDIO MMC
> driver
>
>
> Fix an issue with most SDHC cards because of timeout delay
>
> Signed-off-by: drEagle <dreagle@doukki.net>
> ---
> drivers/mmc/mrvl_mmc.c | 5 +++--
> 1 file changed, 3 insertions(+), 2 deletions(-)
Well, you can make this as a part of your first patch since you are creating these files
Regards...
Prafulla . . .
^ permalink raw reply [flat|nested] 18+ messages in thread
* [U-Boot] [PATCH v2 3/5] Add SDIO/MMC support for Sheevaplug board
2012-09-22 7:17 ` [U-Boot] [PATCH v2 3/5] Add SDIO/MMC support for Sheevaplug board DrEagle
@ 2012-09-24 8:46 ` Prafulla Wadaskar
0 siblings, 0 replies; 18+ messages in thread
From: Prafulla Wadaskar @ 2012-09-24 8:46 UTC (permalink / raw)
To: u-boot
> -----Original Message-----
> From: u-boot-bounces at lists.denx.de [mailto:u-boot-
> bounces at lists.denx.de] On Behalf Of DrEagle
> Sent: 22 September 2012 12:47
> To: DrEagle
> Cc: Lior Amsalem; u-boot at lists.denx.de; uboot at doukki.net
> Subject: [U-Boot] [PATCH v2 3/5] Add SDIO/MMC support for Sheevaplug
> board
>
>
> Add SDIO/MMC support for Sheevaplug board
>
> Signed-off-by: drEagle <dreagle@doukki.net>
> ---
> board/Marvell/sheevaplug/sheevaplug.c | 11 +++++++++++
> include/configs/sheevaplug.h | 12 ++++++++++++
> 2 files changed, 23 insertions(+)
>
> diff --git a/board/Marvell/sheevaplug/sheevaplug.c
> b/board/Marvell/sheevaplug/sheevaplug.c
> index 688d308..db64a05 100644
> --- a/board/Marvell/sheevaplug/sheevaplug.c
> +++ b/board/Marvell/sheevaplug/sheevaplug.c
> @@ -28,6 +28,9 @@
> #include <asm/arch/kirkwood.h>
> #include <asm/arch/mpp.h>
> #include "sheevaplug.h"
> +#ifdef CONFIG_MRVL_MMC
> +#include <mrvl_mmc.h>
> +#endif /* CONFIG_MRVL_MMC */
>
> DECLARE_GLOBAL_DATA_PTR;
>
> @@ -147,3 +150,11 @@ void reset_phy(void)
> printf("88E1116 Initialized on %s\n", name);
> }
> #endif /* CONFIG_RESET_PHY_R */
> +
> +#ifdef CONFIG_MRVL_MMC
> +int board_mmc_init(bd_t *bis)
> +{
> + mrvl_mmc_initialize(bis);
> + return 0;
> +}
> +#endif /* CONFIG_MRVL_MMC */
> diff --git a/include/configs/sheevaplug.h
> b/include/configs/sheevaplug.h
> index 83dd8ff..7d710bf 100644
> --- a/include/configs/sheevaplug.h
> +++ b/include/configs/sheevaplug.h
> @@ -47,6 +47,7 @@
> #define CONFIG_CMD_DHCP
> #define CONFIG_CMD_ENV
> #define CONFIG_CMD_MII
> +#define CONFIG_CMD_MMC
> #define CONFIG_CMD_NAND
> #define CONFIG_CMD_PING
> #define CONFIG_CMD_USB
> @@ -98,6 +99,17 @@
> #endif /* CONFIG_CMD_NET */
>
> /*
> + * SDIO/MMC Card Configuration
> + */
> +#ifdef CONFIG_CMD_MMC
> +#define CONFIG_MMC
> +#define CONFIG_GENERIC_MMC
> +#define CONFIG_MRVL_MMC
> +#define CONFIG_SYS_MMC_BASE KW_SDIO_BASE
> +#endif /* CONFIG_CMD_MMC */
This should go in mv-common.h so that it can be shared across multiple boards
Regards...
Prafulla . . .
> +
> +
> +/*
> * File system
> */
> #define CONFIG_CMD_EXT2
> --
> 1.7.10.4
>
> _______________________________________________
> U-Boot mailing list
> U-Boot at lists.denx.de
> http://lists.denx.de/mailman/listinfo/u-boot
^ permalink raw reply [flat|nested] 18+ messages in thread
* [U-Boot] [PATCH v2 4/5] Fix env address for Sheevaplug board
2012-09-22 7:18 ` [U-Boot] [PATCH v2 4/5] Fix env address " DrEagle
@ 2012-09-24 8:46 ` Prafulla Wadaskar
2012-09-26 5:35 ` DrEagle
0 siblings, 1 reply; 18+ messages in thread
From: Prafulla Wadaskar @ 2012-09-24 8:46 UTC (permalink / raw)
To: u-boot
> -----Original Message-----
> From: u-boot-bounces at lists.denx.de [mailto:u-boot-
> bounces at lists.denx.de] On Behalf Of DrEagle
> Sent: 22 September 2012 12:48
> To: DrEagle
> Cc: Lior Amsalem; u-boot at lists.denx.de; uboot at doukki.net
> Subject: [U-Boot] [PATCH v2 4/5] Fix env address for Sheevaplug board
>
>
> Fix env address for Sheevaplug board
> Move env address and offset from 0x60000 to 0x80000
>
> Signed-off-by: drEagle <dreagle@doukki.net>
> ---
> include/configs/sheevaplug.h | 5 ++---
> 1 file changed, 2 insertions(+), 3 deletions(-)
>
> diff --git a/include/configs/sheevaplug.h
> b/include/configs/sheevaplug.h
> index 7d710bf..a10e825 100644
> --- a/include/configs/sheevaplug.h
> +++ b/include/configs/sheevaplug.h
> @@ -71,9 +71,8 @@
> * it has to be rounded to sector size
> */
> #define CONFIG_ENV_SIZE 0x20000 /* 128k */
> -#define CONFIG_ENV_ADDR 0x60000
> -#define CONFIG_ENV_OFFSET 0x60000 /* env starts here */
> -
> +#define CONFIG_ENV_ADDR 0x80000
> +#define CONFIG_ENV_OFFSET 0x80000 /* env starts here */
Why do you need this shift?
Regards...
Prafulla . ..
^ permalink raw reply [flat|nested] 18+ messages in thread
* [U-Boot] [PATCH v2 0/5] Marvell SDIO/MMC driver for Sheevaplug
2012-09-22 7:15 ` [U-Boot] [PATCH v2 0/5] " DrEagle
2012-09-22 7:34 ` DrEagle
2012-09-24 7:36 ` Prafulla Wadaskar
@ 2012-09-24 8:48 ` Prafulla Wadaskar
2 siblings, 0 replies; 18+ messages in thread
From: Prafulla Wadaskar @ 2012-09-24 8:48 UTC (permalink / raw)
To: u-boot
> -----Original Message-----
> From: u-boot-bounces at lists.denx.de [mailto:u-boot-
> bounces at lists.denx.de] On Behalf Of DrEagle
> Sent: 22 September 2012 12:45
> To: DrEagle
> Cc: Lior Amsalem; u-boot at lists.denx.de; uboot at doukki.net
> Subject: [U-Boot] [PATCH v2 0/5] Marvell SDIO/MMC driver for
> Sheevaplug
>
>
> This serie of patch add SDIO/MMC support to Sheevaplug board
>
> Change from v1:
> - Fix an issue with most SDHC cards because of timeout delay
>
> drEagle (5):
> Add Marvell SDIO/MMC driver for Kirkwood SoC
> Add SDIO/MMC support for kirkwood SoC
> Add SDIO/MMC support for Sheevaplug board
> Fix env address for Sheevaplug board
> Fix timeout in Marvell SDIO MMC driver
Hi DrEagle
I still request you to study mvsdhci.c which is similar framework used for Pantheon family of SoCs, try to use this infrastructure is possible for Kirkwood support.
Regards...
Prafulla . . .
^ permalink raw reply [flat|nested] 18+ messages in thread
* [U-Boot] [PATCH v2 0/5] Marvell SDIO/MMC driver for Sheevaplug
2012-09-22 7:34 ` DrEagle
@ 2012-09-24 8:50 ` Prafulla Wadaskar
0 siblings, 0 replies; 18+ messages in thread
From: Prafulla Wadaskar @ 2012-09-24 8:50 UTC (permalink / raw)
To: u-boot
> -----Original Message-----
> From: DrEagle [mailto:dreagle at doukki.net]
> Sent: 22 September 2012 13:05
> To: DrEagle
> Cc: u-boot at lists.denx.de; uboot at doukki.net; Lior Amsalem; Prafulla
> Wadaskar; Martin Michlmayr
> Subject: Re: [PATCH v2 0/5] Marvell SDIO/MMC driver for Sheevaplug
>
> Hi,
>
> I found an issue of timeout problems.
>
> Now all my cards read correctly, quickly and efficiently.
>
> If someone need a precompiled u-boot binary for testing this version,
> fell free to ask.
>
> I will put it available online.
Avoid top posting
>
> Le 22/09/2012 09:15, DrEagle a ?crit :
> >
> > This serie of patch add SDIO/MMC support to Sheevaplug board
> >
> > Change from v1:
> > - Fix an issue with most SDHC cards because of timeout delay
> >
> > drEagle (5):
> > Add Marvell SDIO/MMC driver for Kirkwood SoC
> > Add SDIO/MMC support for kirkwood SoC
> > Add SDIO/MMC support for Sheevaplug board
> > Fix env address for Sheevaplug board
> > Fix timeout in Marvell SDIO MMC driver
> >
>
^ permalink raw reply [flat|nested] 18+ messages in thread
* [U-Boot] [PATCH v2 4/5] Fix env address for Sheevaplug board
2012-09-24 8:46 ` Prafulla Wadaskar
@ 2012-09-26 5:35 ` DrEagle
2012-09-26 7:33 ` Prafulla Wadaskar
0 siblings, 1 reply; 18+ messages in thread
From: DrEagle @ 2012-09-26 5:35 UTC (permalink / raw)
To: u-boot
Le 24/09/2012 10:46, Prafulla Wadaskar a ?crit :
>
>
>> -----Original Message-----
>> From: u-boot-bounces at lists.denx.de [mailto:u-boot-
>> bounces at lists.denx.de] On Behalf Of DrEagle
>> Sent: 22 September 2012 12:48
>> To: DrEagle
>> Cc: Lior Amsalem; u-boot at lists.denx.de; uboot at doukki.net
>> Subject: [U-Boot] [PATCH v2 4/5] Fix env address for Sheevaplug board
>>
>>
>> Fix env address for Sheevaplug board
>> Move env address and offset from 0x60000 to 0x80000
>>
>> Signed-off-by: drEagle <dreagle@doukki.net>
>> ---
>> include/configs/sheevaplug.h | 5 ++---
>> 1 file changed, 2 insertions(+), 3 deletions(-)
>>
>> diff --git a/include/configs/sheevaplug.h
>> b/include/configs/sheevaplug.h
>> index 7d710bf..a10e825 100644
>> --- a/include/configs/sheevaplug.h
>> +++ b/include/configs/sheevaplug.h
>> @@ -71,9 +71,8 @@
>> * it has to be rounded to sector size
>> */
>> #define CONFIG_ENV_SIZE 0x20000 /* 128k */
>> -#define CONFIG_ENV_ADDR 0x60000
>> -#define CONFIG_ENV_OFFSET 0x60000 /* env starts here */
>> -
>> +#define CONFIG_ENV_ADDR 0x80000
>> +#define CONFIG_ENV_OFFSET 0x80000 /* env starts here */
>
> Why do you need this shift?
Because the size of the new u-boot binary overlap the actual env offset.
If you reset the env or save env with a new u-boot, the code is corrupt, and noo boot anymore.
This shift fix this.
> Regards...
> Prafulla . ..
>
^ permalink raw reply [flat|nested] 18+ messages in thread
* [U-Boot] [PATCH v2 4/5] Fix env address for Sheevaplug board
2012-09-26 5:35 ` DrEagle
@ 2012-09-26 7:33 ` Prafulla Wadaskar
0 siblings, 0 replies; 18+ messages in thread
From: Prafulla Wadaskar @ 2012-09-26 7:33 UTC (permalink / raw)
To: u-boot
> -----Original Message-----
> From: DrEagle [mailto:dreagle at doukki.net]
> Sent: 26 September 2012 11:06
> To: Prafulla Wadaskar
> Cc: DrEagle; u-boot at lists.denx.de; uboot at doukki.net
> Subject: Re: [U-Boot] [PATCH v2 4/5] Fix env address for Sheevaplug
> board
>
> Le 24/09/2012 10:46, Prafulla Wadaskar a ?crit :
> >
> >
> >> -----Original Message-----
> >> From: u-boot-bounces at lists.denx.de [mailto:u-boot-
> >> bounces at lists.denx.de] On Behalf Of DrEagle
> >> Sent: 22 September 2012 12:48
> >> To: DrEagle
> >> Cc: Lior Amsalem; u-boot at lists.denx.de; uboot at doukki.net
> >> Subject: [U-Boot] [PATCH v2 4/5] Fix env address for Sheevaplug
> board
> >>
> >>
> >> Fix env address for Sheevaplug board
> >> Move env address and offset from 0x60000 to 0x80000
> >>
> >> Signed-off-by: drEagle <dreagle@doukki.net>
> >> ---
> >> include/configs/sheevaplug.h | 5 ++---
> >> 1 file changed, 2 insertions(+), 3 deletions(-)
> >>
> >> diff --git a/include/configs/sheevaplug.h
> >> b/include/configs/sheevaplug.h
> >> index 7d710bf..a10e825 100644
> >> --- a/include/configs/sheevaplug.h
> >> +++ b/include/configs/sheevaplug.h
> >> @@ -71,9 +71,8 @@
> >> * it has to be rounded to sector size
> >> */
> >> #define CONFIG_ENV_SIZE 0x20000 /* 128k */
> >> -#define CONFIG_ENV_ADDR 0x60000
> >> -#define CONFIG_ENV_OFFSET 0x60000 /* env starts here */
> >> -
> >> +#define CONFIG_ENV_ADDR 0x80000
> >> +#define CONFIG_ENV_OFFSET 0x80000 /* env starts here */
> >
> > Why do you need this shift?
>
> Because the size of the new u-boot binary overlap the actual env
> offset.
> If you reset the env or save env with a new u-boot, the code is
> corrupt, and noo boot anymore.
>
> This shift fix this.
Then this will be valid for all the boards on which MMC support is being enabled, right?
In that case for sheevaplug, make this change in one patch in your next version (i.e. relocating ENV offset, and enabling MMC support)
Regards...
Prafulla . . .
^ permalink raw reply [flat|nested] 18+ messages in thread
end of thread, other threads:[~2012-09-26 7:33 UTC | newest]
Thread overview: 18+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-09-21 10:15 [U-Boot] [PATCH 0/4] Marvell SDIO/MMC driver for Sheevaplug DrEagle
2012-09-22 7:15 ` [U-Boot] [PATCH v2 0/5] " DrEagle
2012-09-22 7:34 ` DrEagle
2012-09-24 8:50 ` Prafulla Wadaskar
2012-09-24 7:36 ` Prafulla Wadaskar
2012-09-24 8:48 ` Prafulla Wadaskar
2012-09-22 7:15 ` [U-Boot] [PATCH v2 1/5] Add Marvell SDIO/MMC driver for Kirkwood SoC DrEagle
2012-09-24 8:42 ` Prafulla Wadaskar
2012-09-22 7:16 ` [U-Boot] [PATCH v2 2/5] Add SDIO/MMC support for kirkwood SoC DrEagle
2012-09-24 8:44 ` Prafulla Wadaskar
2012-09-22 7:17 ` [U-Boot] [PATCH v2 3/5] Add SDIO/MMC support for Sheevaplug board DrEagle
2012-09-24 8:46 ` Prafulla Wadaskar
2012-09-22 7:18 ` [U-Boot] [PATCH v2 4/5] Fix env address " DrEagle
2012-09-24 8:46 ` Prafulla Wadaskar
2012-09-26 5:35 ` DrEagle
2012-09-26 7:33 ` Prafulla Wadaskar
2012-09-22 7:18 ` [U-Boot] [PATCH v2 5/5] Fix timeout in Marvell SDIO MMC driver DrEagle
2012-09-24 8:44 ` Prafulla Wadaskar
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox