mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* mmc: i.MX23/28 patches
@ 2011-02-28  9:43 Sascha Hauer
  2011-02-28  9:43 ` [PATCH 1/7] mci i.MX23/28: rename driver to mxs.c Sascha Hauer
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: Sascha Hauer @ 2011-02-28  9:43 UTC (permalink / raw)
  To: barebox

The following series cleans up the i.MX23/28 mmc driver.

Sascha Hauer (7):
      mci i.MX23/28: rename driver to mxs.c
      mci mxs: put only once used function inline
      mci mxs: give functions a uniq mxs_mci_ namespace
      mci mxs: rename mci_pdata to host
      mci mxs: make the mci_host a member of mxs_mci_host
      mci mxs: no need to call mxs_mci_setup_clock_speed in init
      ARM tx28stk5: limit mmc max frequency to 25MHz

 arch/arm/boards/chumby_falconwing/falconwing.c |    4 +-
 arch/arm/boards/karo-tx28/tx28-stk5.c          |    7 +-
 arch/arm/mach-mxs/include/mach/mci.h           |    2 +-
 drivers/mci/Kconfig                            |    2 +-
 drivers/mci/Makefile                           |    2 +-
 drivers/mci/{stm378x.c => mxs.c}               |  266 +++++++++++-------------
 6 files changed, 135 insertions(+), 148 deletions(-)
 rename drivers/mci/{stm378x.c => mxs.c} (71%)


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH 1/7] mci i.MX23/28: rename driver to mxs.c
  2011-02-28  9:43 mmc: i.MX23/28 patches Sascha Hauer
@ 2011-02-28  9:43 ` Sascha Hauer
  2011-02-28  9:43 ` [PATCH 2/7] mci mxs: put only once used function inline Sascha Hauer
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: Sascha Hauer @ 2011-02-28  9:43 UTC (permalink / raw)
  To: barebox

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 drivers/mci/Kconfig              |    2 +-
 drivers/mci/Makefile             |    2 +-
 drivers/mci/{stm378x.c => mxs.c} |    0
 3 files changed, 2 insertions(+), 2 deletions(-)
 rename drivers/mci/{stm378x.c => mxs.c} (100%)

diff --git a/drivers/mci/Kconfig b/drivers/mci/Kconfig
index 7d214ac..b11f267 100644
--- a/drivers/mci/Kconfig
+++ b/drivers/mci/Kconfig
@@ -27,7 +27,7 @@ config MCI_INFO
 
 comment "--- MCI host drivers ---"
 
-config MCI_STM378X
+config MCI_MXS
 	bool "i.MX23/i.MX28"
 	depends on ARCH_MXS
 	help
diff --git a/drivers/mci/Makefile b/drivers/mci/Makefile
index a10cb47..f175bba 100644
--- a/drivers/mci/Makefile
+++ b/drivers/mci/Makefile
@@ -1,5 +1,5 @@
 obj-$(CONFIG_MCI)	+= mci-core.o
-obj-$(CONFIG_MCI_STM378X) += stm378x.o
+obj-$(CONFIG_MCI_MXS) += mxs.o
 obj-$(CONFIG_MCI_S3C) += s3c.o
 obj-$(CONFIG_MCI_IMX) += imx.o
 obj-$(CONFIG_MCI_IMX_ESDHC) += imx-esdhc.o
diff --git a/drivers/mci/stm378x.c b/drivers/mci/mxs.c
similarity index 100%
rename from drivers/mci/stm378x.c
rename to drivers/mci/mxs.c
-- 
1.7.2.3


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH 2/7] mci mxs: put only once used function inline
  2011-02-28  9:43 mmc: i.MX23/28 patches Sascha Hauer
  2011-02-28  9:43 ` [PATCH 1/7] mci i.MX23/28: rename driver to mxs.c Sascha Hauer
@ 2011-02-28  9:43 ` Sascha Hauer
  2011-02-28  9:43 ` [PATCH 3/7] mci mxs: give functions a uniq mxs_mci_ namespace Sascha Hauer
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: Sascha Hauer @ 2011-02-28  9:43 UTC (permalink / raw)
  To: barebox

Also, rename mci_rename after the callback it implements: stm_mci_initialize.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 drivers/mci/mxs.c |   27 ++++++++-------------------
 1 files changed, 8 insertions(+), 19 deletions(-)

diff --git a/drivers/mci/mxs.c b/drivers/mci/mxs.c
index 94b0f4a..db789e7 100644
--- a/drivers/mci/mxs.c
+++ b/drivers/mci/mxs.c
@@ -595,13 +595,17 @@ static void stm_mci_reset(struct device_d *hw_dev)
 		;
 }
 
+/* ------------------------- MCI API -------------------------------------- */
+
 /**
- * Initialize the engine
- * @param hw_dev Host interface instance
+ * Keep the attached MMC/SD unit in a well know state
+ * @param mci_pdata MCI platform data
  * @param mci_dev MCI device instance
+ * @return 0 on success, negative value else
  */
-static int stm_mci_initialize(struct device_d *hw_dev, struct device_d *mci_dev)
+static int stm_mci_initialize(struct mci_host *mci_pdata, struct device_d *mci_dev)
 {
+	struct device_d *hw_dev = mci_pdata->hw_dev;
 	struct mci_host *host = GET_MCI_PDATA(mci_dev);
 	struct stm_mci_host *host_data = (struct stm_mci_host*)GET_HOST_DATA(hw_dev);
 
@@ -624,21 +628,6 @@ static int stm_mci_initialize(struct device_d *hw_dev, struct device_d *mci_dev)
 	return 0;
 }
 
-/* ------------------------- MCI API -------------------------------------- */
-
-/**
- * Keep the attached MMC/SD unit in a well know state
- * @param mci_pdata MCI platform data
- * @param mci_dev MCI device instance
- * @return 0 on success, negative value else
- */
-static int mci_reset(struct mci_host *mci_pdata, struct device_d *mci_dev)
-{
-	struct device_d *hw_dev = mci_pdata->hw_dev;
-
-	return stm_mci_initialize(hw_dev, mci_dev);
-}
-
 /**
  * Process one command to the MCI card
  * @param mci_pdata MCI platform data
@@ -733,7 +722,7 @@ static int stm_mci_probe(struct device_d *hw_dev)
 	host->hw_dev = hw_dev;
 	host->send_cmd = mci_request,
 	host->set_ios = mci_set_ios,
-	host->init = mci_reset,
+	host->init = stm_mci_initialize,
 
 	/* feed forward the platform specific values */
 	host->voltages = pd->voltages;
-- 
1.7.2.3


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH 3/7] mci mxs: give functions a uniq mxs_mci_ namespace
  2011-02-28  9:43 mmc: i.MX23/28 patches Sascha Hauer
  2011-02-28  9:43 ` [PATCH 1/7] mci i.MX23/28: rename driver to mxs.c Sascha Hauer
  2011-02-28  9:43 ` [PATCH 2/7] mci mxs: put only once used function inline Sascha Hauer
@ 2011-02-28  9:43 ` Sascha Hauer
  2011-02-28  9:43 ` [PATCH 4/7] mci mxs: rename mci_pdata to host Sascha Hauer
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: Sascha Hauer @ 2011-02-28  9:43 UTC (permalink / raw)
  To: barebox

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 arch/arm/boards/chumby_falconwing/falconwing.c |    4 +-
 arch/arm/boards/karo-tx28/tx28-stk5.c          |    4 +-
 arch/arm/mach-mxs/include/mach/mci.h           |    2 +-
 drivers/mci/mxs.c                              |  124 ++++++++++++------------
 4 files changed, 67 insertions(+), 67 deletions(-)

diff --git a/arch/arm/boards/chumby_falconwing/falconwing.c b/arch/arm/boards/chumby_falconwing/falconwing.c
index d46431c..84aa837 100644
--- a/arch/arm/boards/chumby_falconwing/falconwing.c
+++ b/arch/arm/boards/chumby_falconwing/falconwing.c
@@ -46,13 +46,13 @@ static struct device_d sdram_dev = {
 	.platform_data = &ram_pdata,
 };
 
-static struct stm_mci_platform_data mci_pdata = {
+static struct mxs_mci_platform_data mci_pdata = {
 	.caps = MMC_MODE_4BIT | MMC_MODE_HS | MMC_MODE_HS_52MHz,
 	.voltages = MMC_VDD_32_33 | MMC_VDD_33_34,	/* fixed to 3.3 V */
 };
 
 static struct device_d mci_dev = {
-	.name     = "stm_mci",
+	.name     = "mxs_mci",
 	.map_base = IMX_SSP1_BASE,
 	.platform_data = &mci_pdata,
 };
diff --git a/arch/arm/boards/karo-tx28/tx28-stk5.c b/arch/arm/boards/karo-tx28/tx28-stk5.c
index 9258442..a3f4a28 100644
--- a/arch/arm/boards/karo-tx28/tx28-stk5.c
+++ b/arch/arm/boards/karo-tx28/tx28-stk5.c
@@ -28,14 +28,14 @@
 #include <mach/mci.h>
 #include <mach/fb.h>
 
-static struct stm_mci_platform_data mci_pdata = {
+static struct mxs_mci_platform_data mci_pdata = {
 	.caps = MMC_MODE_4BIT | MMC_MODE_HS | MMC_MODE_HS_52MHz,
 	.voltages = MMC_VDD_32_33 | MMC_VDD_33_34,	/* fixed to 3.3 V */
 	.f_min = 400 * 1000,
 };
 
 static struct device_d mci_socket = {
-	.name = "stm_mci",
+	.name = "mxs_mci",
 	.map_base = IMX_SSP0_BASE,
 	.platform_data = &mci_pdata,
 };
diff --git a/arch/arm/mach-mxs/include/mach/mci.h b/arch/arm/mach-mxs/include/mach/mci.h
index b924908..1090c1a 100644
--- a/arch/arm/mach-mxs/include/mach/mci.h
+++ b/arch/arm/mach-mxs/include/mach/mci.h
@@ -18,7 +18,7 @@
 #ifndef __MACH_MMC_H
 #define __MACH_MMC_H
 
-struct stm_mci_platform_data {
+struct mxs_mci_platform_data {
 	unsigned caps;	/**< supported operating modes (MMC_MODE_*) */
 	unsigned voltages; /**< supported voltage range (MMC_VDD_*) */
 	unsigned f_min;	/**< min operating frequency in Hz (0 -> no limit) */
diff --git a/drivers/mci/mxs.c b/drivers/mci/mxs.c
index db789e7..af69357 100644
--- a/drivers/mci/mxs.c
+++ b/drivers/mci/mxs.c
@@ -165,7 +165,7 @@
 # define HW_SSP_VERSION 0x130
 #endif
 
-struct stm_mci_host {
+struct mxs_mci_host {
 	unsigned	clock;	/* current clock speed in Hz ("0" if disabled) */
 	unsigned	index;
 #ifdef CONFIG_MCI_INFO
@@ -180,9 +180,9 @@ struct stm_mci_host {
  * @param hw_dev Host interface device instance
  * @return Unit's clock in [Hz]
  */
-static unsigned get_unit_clock(struct device_d *hw_dev)
+static unsigned mxs_mci_get_unit_clock(struct device_d *hw_dev)
 {
-	struct stm_mci_host *host_data = GET_HOST_DATA(hw_dev);
+	struct mxs_mci_host *host_data = GET_HOST_DATA(hw_dev);
 
 	return imx_get_sspclk(host_data->index);
 }
@@ -193,7 +193,7 @@ static unsigned get_unit_clock(struct device_d *hw_dev)
  * @param cmd Command description
  * @return Response bytes count, -EINVAL for unsupported response types
  */
-static int get_cards_response(struct device_d *hw_dev, struct mci_cmd *cmd)
+static int mxs_mci_get_cards_response(struct device_d *hw_dev, struct mci_cmd *cmd)
 {
 	switch (cmd->resp_type) {
 	case MMC_RSP_NONE:
@@ -222,7 +222,7 @@ static int get_cards_response(struct device_d *hw_dev, struct mci_cmd *cmd)
  *
  * Can also stop the clock to save power
  */
-static void finish_request(struct device_d *hw_dev)
+static void mxs_mci_finish_request(struct device_d *hw_dev)
 {
 	/* stop the engines (normaly already done) */
 	writel(SSP_CTRL0_RUN, hw_dev->map_base + HW_SSP_CTRL0 + 8);
@@ -233,7 +233,7 @@ static void finish_request(struct device_d *hw_dev)
  * @param status HW_SSP_STATUS's content
  * @return 0 if no error, negative values else
  */
-static int get_cmd_error(unsigned status)
+static int mxs_mci_get_cmd_error(unsigned status)
 {
 	if (status & SSP_STATUS_ERROR)
 		pr_debug("Status Reg reports %08X\n", status);
@@ -260,7 +260,7 @@ static int get_cmd_error(unsigned status)
  * @param hw_dev Host interface device instance
  * @param to Timeout value in MCI card's bus clocks
  */
-static void stm_setup_timout(struct device_d *hw_dev, unsigned to)
+static void mxs_mci_setup_timeout(struct device_d *hw_dev, unsigned to)
 {
 	uint32_t reg;
 
@@ -280,7 +280,7 @@ static void stm_setup_timout(struct device_d *hw_dev, unsigned to)
  * may fail whith high clock speeds. If you receive -EIO errors you can try
  * again with reduced clock speeds.
  */
-static int read_data(struct device_d *hw_dev, void *buffer, unsigned length)
+static int mxs_mci_read_data(struct device_d *hw_dev, void *buffer, unsigned length)
 {
 	uint32_t *p = buffer;
 
@@ -318,7 +318,7 @@ static int read_data(struct device_d *hw_dev, void *buffer, unsigned length)
  * may fail with high clock speeds. If you receive -EIO errors you can try
  * again with reduced clock speeds.
  */
-static int write_data(struct device_d *hw_dev, const void *buffer, unsigned length)
+static int mxs_mci_write_data(struct device_d *hw_dev, const void *buffer, unsigned length)
 {
 	const uint32_t *p = buffer;
 
@@ -349,7 +349,7 @@ static int write_data(struct device_d *hw_dev, const void *buffer, unsigned leng
  * @param data Data transfer description (might be NULL)
  * @return 0 on success
  */
-static int transfer_data(struct device_d *hw_dev, struct mci_data *data)
+static int mxs_mci_transfer_data(struct device_d *hw_dev, struct mci_data *data)
 {
 	unsigned length;
 
@@ -363,7 +363,7 @@ static int transfer_data(struct device_d *hw_dev, struct mci_data *data)
 		 * But last time I tried it, it failed badly. Don't know why yet
 		 */
 		if (data->flags & MMC_DATA_WRITE) {
-			err = write_data(host, data->src, 16);
+			err = mxs_mci_write_data(host, data->src, 16);
 			data->src += 16;
 			length -= 16;
 		}
@@ -381,9 +381,9 @@ static int transfer_data(struct device_d *hw_dev, struct mci_data *data)
 
 	if (data != NULL) {
 		if (data->flags & MMC_DATA_READ)
-			return read_data(hw_dev, data->dest, length);
+			return mxs_mci_read_data(hw_dev, data->dest, length);
 		else
-			return write_data(hw_dev, data->src, length);
+			return mxs_mci_write_data(hw_dev, data->src, length);
 	}
 
 	return 0;
@@ -395,7 +395,7 @@ static int transfer_data(struct device_d *hw_dev, struct mci_data *data)
  * @param data_flags Data information (may be 0)
  * @return Corresponding setting for the SSP_CTRL0 register
  */
-static uint32_t prepare_transfer_setup(unsigned cmd_flags, unsigned data_flags)
+static uint32_t mxs_mci_prepare_transfer_setup(unsigned cmd_flags, unsigned data_flags)
 {
 	uint32_t reg = 0;
 
@@ -428,10 +428,10 @@ static uint32_t prepare_transfer_setup(unsigned cmd_flags, unsigned data_flags)
  * - "broadcast commands with response (BCR)"
  * - "addressed command (AC)" with response, but without data
  */
-static int stm_mci_std_cmds(struct device_d *hw_dev, struct mci_cmd *cmd)
+static int mxs_mci_std_cmds(struct device_d *hw_dev, struct mci_cmd *cmd)
 {
 	/* setup command and transfer parameters */
-	writel(prepare_transfer_setup(cmd->resp_type, 0) |
+	writel(mxs_mci_prepare_transfer_setup(cmd->resp_type, 0) |
 		SSP_CTRL0_ENABLE, hw_dev->map_base + HW_SSP_CTRL0);
 
 	/* prepare the command, when no response is expected add a few trailing clocks */
@@ -442,7 +442,7 @@ static int stm_mci_std_cmds(struct device_d *hw_dev, struct mci_cmd *cmd)
 	/* prepare command's arguments */
 	writel(cmd->cmdarg, hw_dev->map_base + HW_SSP_CMD1);
 
-	stm_setup_timout(hw_dev, 0xffff);
+	mxs_mci_setup_timeout(hw_dev, 0xffff);
 
 	/* start the transfer */
 	writel(SSP_CTRL0_RUN, hw_dev->map_base + HW_SSP_CTRL0 + 4);
@@ -452,9 +452,9 @@ static int stm_mci_std_cmds(struct device_d *hw_dev, struct mci_cmd *cmd)
 		;
 
 	if (cmd->resp_type & MMC_RSP_PRESENT)
-		get_cards_response(hw_dev, cmd);
+		mxs_mci_get_cards_response(hw_dev, cmd);
 
-	return get_cmd_error(readl(hw_dev->map_base + HW_SSP_STATUS));
+	return mxs_mci_get_cmd_error(readl(hw_dev->map_base + HW_SSP_STATUS));
 }
 
 /**
@@ -464,10 +464,10 @@ static int stm_mci_std_cmds(struct device_d *hw_dev, struct mci_cmd *cmd)
  * @param data The data information (buffer, direction aso.) May be NULL
  * @return 0 on success
  */
-static int stm_mci_adtc(struct device_d *hw_dev, struct mci_cmd *cmd,
+static int mxs_mci_adtc(struct device_d *hw_dev, struct mci_cmd *cmd,
 			struct mci_data *data)
 {
-	struct stm_mci_host *host_data = (struct stm_mci_host*)GET_HOST_DATA(hw_dev);
+	struct mxs_mci_host *host_data = (struct mxs_mci_host*)GET_HOST_DATA(hw_dev);
 	uint32_t xfer_cnt, log2blocksize, block_cnt;
 	int err;
 
@@ -482,7 +482,7 @@ static int stm_mci_adtc(struct device_d *hw_dev, struct mci_cmd *cmd,
 
 	/* setup command and transfer parameters */
 #ifdef CONFIG_ARCH_IMX23
-	writel(prepare_transfer_setup(cmd->resp_type, data != NULL ? data->flags : 0) |
+	writel(mxs_mci_prepare_transfer_setup(cmd->resp_type, data != NULL ? data->flags : 0) |
 		SSP_CTRL0_BUS_WIDTH(host_data->bus_width) |
 		(xfer_cnt != 0 ? SSP_CTRL0_DATA_XFER : 0) | /* command plus data */
 		SSP_CTRL0_ENABLE |
@@ -497,7 +497,7 @@ static int stm_mci_adtc(struct device_d *hw_dev, struct mci_cmd *cmd,
 		hw_dev->map_base + HW_SSP_CMD0);
 #endif
 #ifdef CONFIG_ARCH_IMX28
-	writel(prepare_transfer_setup(cmd->resp_type, data != NULL ? data->flags : 0) |
+	writel(mxs_mci_prepare_transfer_setup(cmd->resp_type, data != NULL ? data->flags : 0) |
 		SSP_CTRL0_BUS_WIDTH(host_data->bus_width) |
 		(xfer_cnt != 0 ? SSP_CTRL0_DATA_XFER : 0) | /* command plus data */
 		SSP_CTRL0_ENABLE,
@@ -516,9 +516,9 @@ static int stm_mci_adtc(struct device_d *hw_dev, struct mci_cmd *cmd,
 	/* prepare command's arguments */
 	writel(cmd->cmdarg, hw_dev->map_base + HW_SSP_CMD1);
 
-	stm_setup_timout(hw_dev, 0xffff);
+	mxs_mci_setup_timeout(hw_dev, 0xffff);
 
-	err = transfer_data(hw_dev, data);
+	err = mxs_mci_transfer_data(hw_dev, data);
 	if (err != 0) {
 		pr_debug(" Transfering data failed\n");
 		return err;
@@ -528,7 +528,7 @@ static int stm_mci_adtc(struct device_d *hw_dev, struct mci_cmd *cmd,
 	while (readl(hw_dev->map_base + HW_SSP_CTRL0) & SSP_CTRL0_RUN)
 		;
 
-	get_cards_response(hw_dev, cmd);
+	mxs_mci_get_cards_response(hw_dev, cmd);
 
 	return 0;
 }
@@ -554,7 +554,7 @@ static int stm_mci_adtc(struct device_d *hw_dev, struct mci_cmd *cmd,
  * @note Up to "SSP unit DIV" the outer world must care. This routine only
  * handles the "SSP DIV".
  */
-static unsigned setup_clock_speed(struct device_d *hw_dev, unsigned nc)
+static unsigned mxs_mci_setup_clock_speed(struct device_d *hw_dev, unsigned nc)
 {
 	unsigned ssp, div, rate, reg;
 
@@ -563,7 +563,7 @@ static unsigned setup_clock_speed(struct device_d *hw_dev, unsigned nc)
 		return 0;
 	}
 
-	ssp = get_unit_clock(hw_dev);
+	ssp = mxs_mci_get_unit_clock(hw_dev);
 
 	for (div = 2; div < 255; div += 2) {
 		rate = DIV_ROUND_CLOSEST(DIV_ROUND_CLOSEST(ssp, nc), div);
@@ -588,7 +588,7 @@ static unsigned setup_clock_speed(struct device_d *hw_dev, unsigned nc)
  *
  * This will reset everything in all registers of this unit! (FIXME)
  */
-static void stm_mci_reset(struct device_d *hw_dev)
+static void mxs_mci_reset(struct device_d *hw_dev)
 {
 	writel(SSP_CTRL0_SFTRST, hw_dev->map_base + HW_SSP_CTRL0 + 8);
 	while (readl(hw_dev->map_base + HW_SSP_CTRL0) & SSP_CTRL0_SFTRST)
@@ -603,21 +603,21 @@ static void stm_mci_reset(struct device_d *hw_dev)
  * @param mci_dev MCI device instance
  * @return 0 on success, negative value else
  */
-static int stm_mci_initialize(struct mci_host *mci_pdata, struct device_d *mci_dev)
+static int mxs_mci_initialize(struct mci_host *mci_pdata, struct device_d *mci_dev)
 {
 	struct device_d *hw_dev = mci_pdata->hw_dev;
 	struct mci_host *host = GET_MCI_PDATA(mci_dev);
-	struct stm_mci_host *host_data = (struct stm_mci_host*)GET_HOST_DATA(hw_dev);
+	struct mxs_mci_host *host_data = (struct mxs_mci_host*)GET_HOST_DATA(hw_dev);
 
 	/* enable the clock to this unit to be able to reset it */
 	writel(SSP_CTRL0_CLKGATE, hw_dev->map_base + HW_SSP_CTRL0 + 8);
 
 	/* reset the unit */
-	stm_mci_reset(hw_dev);
+	mxs_mci_reset(hw_dev);
 
 	/* restore the last settings */
-	host->clock = host_data->clock = setup_clock_speed(hw_dev, host->clock);
-	stm_setup_timout(hw_dev, 0xffff);
+	host->clock = host_data->clock = mxs_mci_setup_clock_speed(hw_dev, host->clock);
+	mxs_mci_setup_timeout(hw_dev, 0xffff);
 	writel(SSP_CTRL0_IGNORE_CRC |
 		SSP_CTRL0_BUS_WIDTH(host_data->bus_width),
 		hw_dev->map_base + HW_SSP_CTRL0);
@@ -635,18 +635,18 @@ static int stm_mci_initialize(struct mci_host *mci_pdata, struct device_d *mci_d
  * @param data The data to handle in the command (can be NULL)
  * @return 0 on success, negative value else
  */
-static int mci_request(struct mci_host *mci_pdata, struct mci_cmd *cmd,
+static int mxs_mci_request(struct mci_host *mci_pdata, struct mci_cmd *cmd,
 			struct mci_data *data)
 {
 	struct device_d *hw_dev = mci_pdata->hw_dev;
 	int rc;
 
 	if ((cmd->resp_type == 0) || (data == NULL))
-		rc = stm_mci_std_cmds(hw_dev, cmd);
+		rc = mxs_mci_std_cmds(hw_dev, cmd);
 	else
-		rc = stm_mci_adtc(hw_dev, cmd, data);	/* with response and data */
+		rc = mxs_mci_adtc(hw_dev, cmd, data);	/* with response and data */
 
-	finish_request(hw_dev);	/* TODO */
+	mxs_mci_finish_request(hw_dev);	/* TODO */
 	return rc;
 }
 
@@ -659,11 +659,11 @@ static int mci_request(struct mci_host *mci_pdata, struct mci_cmd *cmd,
  *
  * Drivers currently realized values are stored in MCI's platformdata
  */
-static void mci_set_ios(struct mci_host *mci_pdata, struct device_d *mci_dev,
+static void mxs_mci_set_ios(struct mci_host *mci_pdata, struct device_d *mci_dev,
 			unsigned bus_width, unsigned clock)
 {
 	struct device_d *hw_dev = mci_pdata->hw_dev;
-	struct stm_mci_host *host_data = (struct stm_mci_host*)GET_HOST_DATA(hw_dev);
+	struct mxs_mci_host *host_data = (struct mxs_mci_host*)GET_HOST_DATA(hw_dev);
 	struct mci_host *host = GET_MCI_PDATA(mci_dev);
 
 	switch (bus_width) {
@@ -681,7 +681,7 @@ static void mci_set_ios(struct mci_host *mci_pdata, struct device_d *mci_dev,
 		break;
 	}
 
-	host->clock = host_data->clock = setup_clock_speed(hw_dev, clock);
+	host->clock = host_data->clock = mxs_mci_setup_clock_speed(hw_dev, clock);
 	pr_debug("IO settings: bus width=%d, frequency=%u Hz\n", host->bus_width,
 			host->clock);
 }
@@ -691,9 +691,9 @@ static void mci_set_ios(struct mci_host *mci_pdata, struct device_d *mci_dev,
 #ifdef CONFIG_MCI_INFO
 const unsigned char bus_width[3] = { 1, 4, 8 };
 
-static void stm_info(struct device_d *hw_dev)
+static void mxs_mci_info(struct device_d *hw_dev)
 {
-	struct stm_mci_host *host_data = GET_HOST_DATA(hw_dev);
+	struct mxs_mci_host *host_data = GET_HOST_DATA(hw_dev);
 
 	printf(" Interface\n");
 	printf("  Min. bus clock: %u Hz\n", host_data->f_min);
@@ -704,10 +704,10 @@ static void stm_info(struct device_d *hw_dev)
 }
 #endif
 
-static int stm_mci_probe(struct device_d *hw_dev)
+static int mxs_mci_probe(struct device_d *hw_dev)
 {
-	struct stm_mci_platform_data *pd = hw_dev->platform_data;
-	struct stm_mci_host *host_data;
+	struct mxs_mci_platform_data *pd = hw_dev->platform_data;
+	struct mxs_mci_host *host_data;
 	struct mci_host *host;
 
 	if (hw_dev->platform_data == NULL) {
@@ -715,14 +715,14 @@ static int stm_mci_probe(struct device_d *hw_dev)
 		return -EINVAL;
 	}
 
-	host = xzalloc(sizeof(struct stm_mci_host) + sizeof(struct mci_host));
-	host_data = (struct stm_mci_host*)&host[1];
+	host = xzalloc(sizeof(struct mxs_mci_host) + sizeof(struct mci_host));
+	host_data = (struct mxs_mci_host*)&host[1];
 
 	hw_dev->priv = host_data;
 	host->hw_dev = hw_dev;
-	host->send_cmd = mci_request,
-	host->set_ios = mci_set_ios,
-	host->init = stm_mci_initialize,
+	host->send_cmd = mxs_mci_request,
+	host->set_ios = mxs_mci_set_ios,
+	host->init = mxs_mci_initialize,
 
 	/* feed forward the platform specific values */
 	host->voltages = pd->voltages;
@@ -752,20 +752,20 @@ static int stm_mci_probe(struct device_d *hw_dev)
 	}
 #endif
 	if (pd->f_min == 0) {
-		host->f_min = get_unit_clock(hw_dev) / 254 / 256;
+		host->f_min = mxs_mci_get_unit_clock(hw_dev) / 254 / 256;
 		pr_debug("Min. frequency is %u Hz\n", host->f_min);
 	} else {
 		host->f_min = pd->f_min;
 		pr_debug("Min. frequency is %u Hz, could be %u Hz\n",
-			host->f_min, get_unit_clock(hw_dev) / 254 / 256);
+			host->f_min, mxs_mci_get_unit_clock(hw_dev) / 254 / 256);
 	}
 	if (pd->f_max == 0) {
-		host->f_max = get_unit_clock(hw_dev) / 2 / 1;
+		host->f_max = mxs_mci_get_unit_clock(hw_dev) / 2 / 1;
 		pr_debug("Max. frequency is %u Hz\n", host->f_max);
 	} else {
 		host->f_max =  pd->f_max;
 		pr_debug("Max. frequency is %u Hz, could be %u Hz\n",
-			host->f_max, get_unit_clock(hw_dev) / 2 / 1);
+			host->f_max, mxs_mci_get_unit_clock(hw_dev) / 2 / 1);
 	}
 
 #ifdef CONFIG_MCI_INFO
@@ -776,18 +776,18 @@ static int stm_mci_probe(struct device_d *hw_dev)
 	return mci_register(host);
 }
 
-static struct driver_d stm_mci_driver = {
-        .name  = "stm_mci",
-        .probe = stm_mci_probe,
+static struct driver_d mxs_mci_driver = {
+        .name  = "mxs_mci",
+        .probe = mxs_mci_probe,
 #ifdef CONFIG_MCI_INFO
-	.info = stm_info,
+	.info = mxs_mci_info,
 #endif
 };
 
-static int stm_mci_init_driver(void)
+static int mxs_mci_init_driver(void)
 {
-        register_driver(&stm_mci_driver);
+        register_driver(&mxs_mci_driver);
         return 0;
 }
 
-device_initcall(stm_mci_init_driver);
+device_initcall(mxs_mci_init_driver);
-- 
1.7.2.3


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH 4/7] mci mxs: rename mci_pdata to host
  2011-02-28  9:43 mmc: i.MX23/28 patches Sascha Hauer
                   ` (2 preceding siblings ...)
  2011-02-28  9:43 ` [PATCH 3/7] mci mxs: give functions a uniq mxs_mci_ namespace Sascha Hauer
@ 2011-02-28  9:43 ` Sascha Hauer
  2011-02-28  9:43 ` [PATCH 5/7] mci mxs: make the mci_host a member of mxs_mci_host Sascha Hauer
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: Sascha Hauer @ 2011-02-28  9:43 UTC (permalink / raw)
  To: barebox

struct mci_host is named host in the rest of the driver, so
name it like this consistently.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 drivers/mci/mxs.c |   14 ++++++--------
 1 files changed, 6 insertions(+), 8 deletions(-)

diff --git a/drivers/mci/mxs.c b/drivers/mci/mxs.c
index af69357..bc177f5 100644
--- a/drivers/mci/mxs.c
+++ b/drivers/mci/mxs.c
@@ -603,10 +603,9 @@ static void mxs_mci_reset(struct device_d *hw_dev)
  * @param mci_dev MCI device instance
  * @return 0 on success, negative value else
  */
-static int mxs_mci_initialize(struct mci_host *mci_pdata, struct device_d *mci_dev)
+static int mxs_mci_initialize(struct mci_host *host, struct device_d *mci_dev)
 {
-	struct device_d *hw_dev = mci_pdata->hw_dev;
-	struct mci_host *host = GET_MCI_PDATA(mci_dev);
+	struct device_d *hw_dev = host->hw_dev;
 	struct mxs_mci_host *host_data = (struct mxs_mci_host*)GET_HOST_DATA(hw_dev);
 
 	/* enable the clock to this unit to be able to reset it */
@@ -635,10 +634,10 @@ static int mxs_mci_initialize(struct mci_host *mci_pdata, struct device_d *mci_d
  * @param data The data to handle in the command (can be NULL)
  * @return 0 on success, negative value else
  */
-static int mxs_mci_request(struct mci_host *mci_pdata, struct mci_cmd *cmd,
+static int mxs_mci_request(struct mci_host *host, struct mci_cmd *cmd,
 			struct mci_data *data)
 {
-	struct device_d *hw_dev = mci_pdata->hw_dev;
+	struct device_d *hw_dev = host->hw_dev;
 	int rc;
 
 	if ((cmd->resp_type == 0) || (data == NULL))
@@ -659,12 +658,11 @@ static int mxs_mci_request(struct mci_host *mci_pdata, struct mci_cmd *cmd,
  *
  * Drivers currently realized values are stored in MCI's platformdata
  */
-static void mxs_mci_set_ios(struct mci_host *mci_pdata, struct device_d *mci_dev,
+static void mxs_mci_set_ios(struct mci_host *host, struct device_d *mci_dev,
 			unsigned bus_width, unsigned clock)
 {
-	struct device_d *hw_dev = mci_pdata->hw_dev;
+	struct device_d *hw_dev = host->hw_dev;
 	struct mxs_mci_host *host_data = (struct mxs_mci_host*)GET_HOST_DATA(hw_dev);
-	struct mci_host *host = GET_MCI_PDATA(mci_dev);
 
 	switch (bus_width) {
 	case 8:
-- 
1.7.2.3


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH 5/7] mci mxs: make the mci_host a member of mxs_mci_host
  2011-02-28  9:43 mmc: i.MX23/28 patches Sascha Hauer
                   ` (3 preceding siblings ...)
  2011-02-28  9:43 ` [PATCH 4/7] mci mxs: rename mci_pdata to host Sascha Hauer
@ 2011-02-28  9:43 ` Sascha Hauer
  2011-02-28  9:43 ` [PATCH 6/7] mci mxs: no need to call mxs_mci_setup_clock_speed in init Sascha Hauer
  2011-02-28  9:43 ` [PATCH 7/7] ARM tx28stk5: limit mmc max frequency to 25MHz Sascha Hauer
  6 siblings, 0 replies; 8+ messages in thread
From: Sascha Hauer @ 2011-02-28  9:43 UTC (permalink / raw)
  To: barebox

This allows for more type safety. passing a struct device_d
internally in the driver is not a good idea. Also, this
patch adds a void __iomem *regs to mxs_mci_host. dev->map_base
should not be used for register accesses.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 drivers/mci/mxs.c |  196 ++++++++++++++++++++++++++--------------------------
 1 files changed, 98 insertions(+), 98 deletions(-)

diff --git a/drivers/mci/mxs.c b/drivers/mci/mxs.c
index bc177f5..7f8f3f8 100644
--- a/drivers/mci/mxs.c
+++ b/drivers/mci/mxs.c
@@ -166,6 +166,8 @@
 #endif
 
 struct mxs_mci_host {
+	struct mci_host	host;
+	void __iomem	*regs;
 	unsigned	clock;	/* current clock speed in Hz ("0" if disabled) */
 	unsigned	index;
 #ifdef CONFIG_MCI_INFO
@@ -175,16 +177,16 @@ struct mxs_mci_host {
 	int		bus_width:2; /* 0 = 1 bit, 1 = 4 bit, 2 = 8 bit */
 };
 
+#define to_mxs_mci(mxs) container_of(mxs, struct mxs_mci_host, host)
+
 /**
  * Get the SSP clock rate
  * @param hw_dev Host interface device instance
  * @return Unit's clock in [Hz]
  */
-static unsigned mxs_mci_get_unit_clock(struct device_d *hw_dev)
+static unsigned mxs_mci_get_unit_clock(struct mxs_mci_host *mxs_mci)
 {
-	struct mxs_mci_host *host_data = GET_HOST_DATA(hw_dev);
-
-	return imx_get_sspclk(host_data->index);
+	return imx_get_sspclk(mxs_mci->index);
 }
 
 /**
@@ -193,7 +195,7 @@ static unsigned mxs_mci_get_unit_clock(struct device_d *hw_dev)
  * @param cmd Command description
  * @return Response bytes count, -EINVAL for unsupported response types
  */
-static int mxs_mci_get_cards_response(struct device_d *hw_dev, struct mci_cmd *cmd)
+static int mxs_mci_get_cards_response(struct mxs_mci_host *mxs_mci, struct mci_cmd *cmd)
 {
 	switch (cmd->resp_type) {
 	case MMC_RSP_NONE:
@@ -202,14 +204,14 @@ static int mxs_mci_get_cards_response(struct device_d *hw_dev, struct mci_cmd *c
 	case MMC_RSP_R1:
 	case MMC_RSP_R1b:
 	case MMC_RSP_R3:
-		cmd->response[0] = readl(hw_dev->map_base + HW_SSP_SDRESP0);
+		cmd->response[0] = readl(mxs_mci->regs + HW_SSP_SDRESP0);
 		return 1;
 
 	case MMC_RSP_R2:
-		cmd->response[3] = readl(hw_dev->map_base + HW_SSP_SDRESP0);
-		cmd->response[2] = readl(hw_dev->map_base + HW_SSP_SDRESP1);
-		cmd->response[1] = readl(hw_dev->map_base + HW_SSP_SDRESP2);
-		cmd->response[0] = readl(hw_dev->map_base + HW_SSP_SDRESP3);
+		cmd->response[3] = readl(mxs_mci->regs + HW_SSP_SDRESP0);
+		cmd->response[2] = readl(mxs_mci->regs + HW_SSP_SDRESP1);
+		cmd->response[1] = readl(mxs_mci->regs + HW_SSP_SDRESP2);
+		cmd->response[0] = readl(mxs_mci->regs + HW_SSP_SDRESP3);
 		return 4;
 	}
 
@@ -222,10 +224,10 @@ static int mxs_mci_get_cards_response(struct device_d *hw_dev, struct mci_cmd *c
  *
  * Can also stop the clock to save power
  */
-static void mxs_mci_finish_request(struct device_d *hw_dev)
+static void mxs_mci_finish_request(struct mxs_mci_host *mxs_mci)
 {
 	/* stop the engines (normaly already done) */
-	writel(SSP_CTRL0_RUN, hw_dev->map_base + HW_SSP_CTRL0 + 8);
+	writel(SSP_CTRL0_RUN, mxs_mci->regs + HW_SSP_CTRL0 + 8);
 }
 
 /**
@@ -260,13 +262,13 @@ static int mxs_mci_get_cmd_error(unsigned status)
  * @param hw_dev Host interface device instance
  * @param to Timeout value in MCI card's bus clocks
  */
-static void mxs_mci_setup_timeout(struct device_d *hw_dev, unsigned to)
+static void mxs_mci_setup_timeout(struct mxs_mci_host *mxs_mci, unsigned to)
 {
 	uint32_t reg;
 
-	reg = readl(hw_dev->map_base + HW_SSP_TIMING) & ~SSP_TIMING_TIMEOUT_MASK;
+	reg = readl(mxs_mci->regs + HW_SSP_TIMING) & ~SSP_TIMING_TIMEOUT_MASK;
 	reg |= SSP_TIMING_TIMEOUT(to);
-	writel(reg, hw_dev->map_base + HW_SSP_TIMING);
+	writel(reg, mxs_mci->regs + HW_SSP_TIMING);
 }
 
 /**
@@ -280,7 +282,7 @@ static void mxs_mci_setup_timeout(struct device_d *hw_dev, unsigned to)
  * may fail whith high clock speeds. If you receive -EIO errors you can try
  * again with reduced clock speeds.
  */
-static int mxs_mci_read_data(struct device_d *hw_dev, void *buffer, unsigned length)
+static int mxs_mci_read_data(struct mxs_mci_host *mxs_mci, void *buffer, unsigned length)
 {
 	uint32_t *p = buffer;
 
@@ -291,10 +293,10 @@ static int mxs_mci_read_data(struct device_d *hw_dev, void *buffer, unsigned len
 	}
 
 	while ((length != 0) &&
-		((readl(hw_dev->map_base + HW_SSP_STATUS) & SSP_STATUS_ERROR) == 0)) {
+		((readl(mxs_mci->regs + HW_SSP_STATUS) & SSP_STATUS_ERROR) == 0)) {
 		/* TODO sort out FIFO overflows and emit -EOI for this case */
-		if ((readl(hw_dev->map_base + HW_SSP_STATUS) & SSP_STATUS_FIFO_EMPTY) == 0) {
-			*p = readl(hw_dev->map_base + HW_SSP_DATA);
+		if ((readl(mxs_mci->regs + HW_SSP_STATUS) & SSP_STATUS_FIFO_EMPTY) == 0) {
+			*p = readl(mxs_mci->regs + HW_SSP_DATA);
 			p++;
 			length -= 4;
 		}
@@ -318,7 +320,7 @@ static int mxs_mci_read_data(struct device_d *hw_dev, void *buffer, unsigned len
  * may fail with high clock speeds. If you receive -EIO errors you can try
  * again with reduced clock speeds.
  */
-static int mxs_mci_write_data(struct device_d *hw_dev, const void *buffer, unsigned length)
+static int mxs_mci_write_data(struct mxs_mci_host *mxs_mci, const void *buffer, unsigned length)
 {
 	const uint32_t *p = buffer;
 
@@ -329,10 +331,10 @@ static int mxs_mci_write_data(struct device_d *hw_dev, const void *buffer, unsig
 	}
 
 	while ((length != 0) &&
-		((readl(hw_dev->map_base + HW_SSP_STATUS) & SSP_STATUS_ERROR) == 0)) {
+		((readl(mxs_mci->regs + HW_SSP_STATUS) & SSP_STATUS_ERROR) == 0)) {
 		/* TODO sort out FIFO overflows and emit -EOI for this case */
-		if ((readl(hw_dev->map_base + HW_SSP_STATUS) & SSP_STATUS_FIFO_FULL) == 0) {
-			writel(*p, hw_dev->map_base + HW_SSP_DATA);
+		if ((readl(mxs_mci->regs + HW_SSP_STATUS) & SSP_STATUS_FIFO_FULL) == 0) {
+			writel(*p, mxs_mci->regs + HW_SSP_DATA);
 			p++;
 			length -= 4;
 		}
@@ -349,7 +351,7 @@ static int mxs_mci_write_data(struct device_d *hw_dev, const void *buffer, unsig
  * @param data Data transfer description (might be NULL)
  * @return 0 on success
  */
-static int mxs_mci_transfer_data(struct device_d *hw_dev, struct mci_data *data)
+static int mxs_mci_transfer_data(struct mxs_mci_host *mxs_mci, struct mci_data *data)
 {
 	unsigned length;
 
@@ -377,13 +379,13 @@ static int mxs_mci_transfer_data(struct device_d *hw_dev, struct mci_data *data)
 	 *
 	 * Start the transaction right now
 	 */
-	writel(SSP_CTRL0_RUN, hw_dev->map_base + HW_SSP_CTRL0 + 4);
+	writel(SSP_CTRL0_RUN, mxs_mci->regs + HW_SSP_CTRL0 + 4);
 
 	if (data != NULL) {
 		if (data->flags & MMC_DATA_READ)
-			return mxs_mci_read_data(hw_dev, data->dest, length);
+			return mxs_mci_read_data(mxs_mci, data->dest, length);
 		else
-			return mxs_mci_write_data(hw_dev, data->src, length);
+			return mxs_mci_write_data(mxs_mci, data->src, length);
 	}
 
 	return 0;
@@ -428,33 +430,33 @@ static uint32_t mxs_mci_prepare_transfer_setup(unsigned cmd_flags, unsigned data
  * - "broadcast commands with response (BCR)"
  * - "addressed command (AC)" with response, but without data
  */
-static int mxs_mci_std_cmds(struct device_d *hw_dev, struct mci_cmd *cmd)
+static int mxs_mci_std_cmds(struct mxs_mci_host *mxs_mci, struct mci_cmd *cmd)
 {
 	/* setup command and transfer parameters */
 	writel(mxs_mci_prepare_transfer_setup(cmd->resp_type, 0) |
-		SSP_CTRL0_ENABLE, hw_dev->map_base + HW_SSP_CTRL0);
+		SSP_CTRL0_ENABLE, mxs_mci->regs + HW_SSP_CTRL0);
 
 	/* prepare the command, when no response is expected add a few trailing clocks */
 	writel(SSP_CMD0_CMD(cmd->cmdidx) |
 		(cmd->resp_type & MMC_RSP_PRESENT ? 0 : SSP_CMD0_APPEND_8CYC),
-		hw_dev->map_base + HW_SSP_CMD0);
+		mxs_mci->regs + HW_SSP_CMD0);
 
 	/* prepare command's arguments */
-	writel(cmd->cmdarg, hw_dev->map_base + HW_SSP_CMD1);
+	writel(cmd->cmdarg, mxs_mci->regs + HW_SSP_CMD1);
 
-	mxs_mci_setup_timeout(hw_dev, 0xffff);
+	mxs_mci_setup_timeout(mxs_mci, 0xffff);
 
 	/* start the transfer */
-	writel(SSP_CTRL0_RUN, hw_dev->map_base + HW_SSP_CTRL0 + 4);
+	writel(SSP_CTRL0_RUN, mxs_mci->regs + HW_SSP_CTRL0 + 4);
 
 	/* wait until finished */
-	while (readl(hw_dev->map_base + HW_SSP_CTRL0) & SSP_CTRL0_RUN)
+	while (readl(mxs_mci->regs + HW_SSP_CTRL0) & SSP_CTRL0_RUN)
 		;
 
 	if (cmd->resp_type & MMC_RSP_PRESENT)
-		mxs_mci_get_cards_response(hw_dev, cmd);
+		mxs_mci_get_cards_response(mxs_mci, cmd);
 
-	return mxs_mci_get_cmd_error(readl(hw_dev->map_base + HW_SSP_STATUS));
+	return mxs_mci_get_cmd_error(readl(mxs_mci->regs + HW_SSP_STATUS));
 }
 
 /**
@@ -464,10 +466,9 @@ static int mxs_mci_std_cmds(struct device_d *hw_dev, struct mci_cmd *cmd)
  * @param data The data information (buffer, direction aso.) May be NULL
  * @return 0 on success
  */
-static int mxs_mci_adtc(struct device_d *hw_dev, struct mci_cmd *cmd,
+static int mxs_mci_adtc(struct mxs_mci_host *mxs_mci, struct mci_cmd *cmd,
 			struct mci_data *data)
 {
-	struct mxs_mci_host *host_data = (struct mxs_mci_host*)GET_HOST_DATA(hw_dev);
 	uint32_t xfer_cnt, log2blocksize, block_cnt;
 	int err;
 
@@ -483,52 +484,52 @@ static int mxs_mci_adtc(struct device_d *hw_dev, struct mci_cmd *cmd,
 	/* setup command and transfer parameters */
 #ifdef CONFIG_ARCH_IMX23
 	writel(mxs_mci_prepare_transfer_setup(cmd->resp_type, data != NULL ? data->flags : 0) |
-		SSP_CTRL0_BUS_WIDTH(host_data->bus_width) |
+		SSP_CTRL0_BUS_WIDTH(mxs_mci->bus_width) |
 		(xfer_cnt != 0 ? SSP_CTRL0_DATA_XFER : 0) | /* command plus data */
 		SSP_CTRL0_ENABLE |
 		SSP_CTRL0_XFER_COUNT(xfer_cnt), /* byte count to be transfered */
-		hw_dev->map_base + HW_SSP_CTRL0);
+		mxs_mci->regs + HW_SSP_CTRL0);
 
 	/* prepare the command and the transfered data count */
 	writel(SSP_CMD0_CMD(cmd->cmdidx) |
 		SSP_CMD0_BLOCK_SIZE(log2blocksize) |
 		SSP_CMD0_BLOCK_COUNT(block_cnt) |
 		(cmd->cmdidx == MMC_CMD_STOP_TRANSMISSION ? SSP_CMD0_APPEND_8CYC : 0),
-		hw_dev->map_base + HW_SSP_CMD0);
+		mxs_mci->regs + HW_SSP_CMD0);
 #endif
 #ifdef CONFIG_ARCH_IMX28
 	writel(mxs_mci_prepare_transfer_setup(cmd->resp_type, data != NULL ? data->flags : 0) |
-		SSP_CTRL0_BUS_WIDTH(host_data->bus_width) |
+		SSP_CTRL0_BUS_WIDTH(mxs_mci->bus_width) |
 		(xfer_cnt != 0 ? SSP_CTRL0_DATA_XFER : 0) | /* command plus data */
 		SSP_CTRL0_ENABLE,
-		hw_dev->map_base + HW_SSP_CTRL0);
-	writel(xfer_cnt, hw_dev->map_base + HW_SSP_XFER_COUNT);
+		mxs_mci->regs + HW_SSP_CTRL0);
+	writel(xfer_cnt, mxs_mci->regs + HW_SSP_XFER_COUNT);
 
 	/* prepare the command and the transfered data count */
 	writel(SSP_CMD0_CMD(cmd->cmdidx) |
 		(cmd->cmdidx == MMC_CMD_STOP_TRANSMISSION ? SSP_CMD0_APPEND_8CYC : 0),
-		hw_dev->map_base + HW_SSP_CMD0);
+		mxs_mci->regs + HW_SSP_CMD0);
 	writel(SSP_BLOCK_SIZE(log2blocksize) |
 		SSP_BLOCK_COUNT(block_cnt),
-		hw_dev->map_base + HW_SSP_BLOCK_SIZE);
+		mxs_mci->regs + HW_SSP_BLOCK_SIZE);
 #endif
 
 	/* prepare command's arguments */
-	writel(cmd->cmdarg, hw_dev->map_base + HW_SSP_CMD1);
+	writel(cmd->cmdarg, mxs_mci->regs + HW_SSP_CMD1);
 
-	mxs_mci_setup_timeout(hw_dev, 0xffff);
+	mxs_mci_setup_timeout(mxs_mci, 0xffff);
 
-	err = mxs_mci_transfer_data(hw_dev, data);
+	err = mxs_mci_transfer_data(mxs_mci, data);
 	if (err != 0) {
 		pr_debug(" Transfering data failed\n");
 		return err;
 	}
 
 	/* wait until finished */
-	while (readl(hw_dev->map_base + HW_SSP_CTRL0) & SSP_CTRL0_RUN)
+	while (readl(mxs_mci->regs + HW_SSP_CTRL0) & SSP_CTRL0_RUN)
 		;
 
-	mxs_mci_get_cards_response(hw_dev, cmd);
+	mxs_mci_get_cards_response(mxs_mci, cmd);
 
 	return 0;
 }
@@ -554,7 +555,7 @@ static int mxs_mci_adtc(struct device_d *hw_dev, struct mci_cmd *cmd,
  * @note Up to "SSP unit DIV" the outer world must care. This routine only
  * handles the "SSP DIV".
  */
-static unsigned mxs_mci_setup_clock_speed(struct device_d *hw_dev, unsigned nc)
+static unsigned mxs_mci_setup_clock_speed(struct mxs_mci_host *mxs_mci, unsigned nc)
 {
 	unsigned ssp, div, rate, reg;
 
@@ -563,7 +564,7 @@ static unsigned mxs_mci_setup_clock_speed(struct device_d *hw_dev, unsigned nc)
 		return 0;
 	}
 
-	ssp = mxs_mci_get_unit_clock(hw_dev);
+	ssp = mxs_mci_get_unit_clock(mxs_mci);
 
 	for (div = 2; div < 255; div += 2) {
 		rate = DIV_ROUND_CLOSEST(DIV_ROUND_CLOSEST(ssp, nc), div);
@@ -575,9 +576,9 @@ static unsigned mxs_mci_setup_clock_speed(struct device_d *hw_dev, unsigned nc)
 		return 0;
 	}
 
-	reg = readl(hw_dev->map_base + HW_SSP_TIMING) & SSP_TIMING_TIMEOUT_MASK;
+	reg = readl(mxs_mci->regs + HW_SSP_TIMING) & SSP_TIMING_TIMEOUT_MASK;
 	reg |= SSP_TIMING_CLOCK_DIVIDE(div) | SSP_TIMING_CLOCK_RATE(rate - 1);
-	writel(reg, hw_dev->map_base + HW_SSP_TIMING);
+	writel(reg, mxs_mci->regs + HW_SSP_TIMING);
 
 	return ssp / div / rate;
 }
@@ -588,10 +589,10 @@ static unsigned mxs_mci_setup_clock_speed(struct device_d *hw_dev, unsigned nc)
  *
  * This will reset everything in all registers of this unit! (FIXME)
  */
-static void mxs_mci_reset(struct device_d *hw_dev)
+static void mxs_mci_reset(struct mxs_mci_host *mxs_mci)
 {
-	writel(SSP_CTRL0_SFTRST, hw_dev->map_base + HW_SSP_CTRL0 + 8);
-	while (readl(hw_dev->map_base + HW_SSP_CTRL0) & SSP_CTRL0_SFTRST)
+	writel(SSP_CTRL0_SFTRST, mxs_mci->regs + HW_SSP_CTRL0 + 8);
+	while (readl(mxs_mci->regs + HW_SSP_CTRL0) & SSP_CTRL0_SFTRST)
 		;
 }
 
@@ -605,24 +606,23 @@ static void mxs_mci_reset(struct device_d *hw_dev)
  */
 static int mxs_mci_initialize(struct mci_host *host, struct device_d *mci_dev)
 {
-	struct device_d *hw_dev = host->hw_dev;
-	struct mxs_mci_host *host_data = (struct mxs_mci_host*)GET_HOST_DATA(hw_dev);
+	struct mxs_mci_host *mxs_mci = to_mxs_mci(host);
 
 	/* enable the clock to this unit to be able to reset it */
-	writel(SSP_CTRL0_CLKGATE, hw_dev->map_base + HW_SSP_CTRL0 + 8);
+	writel(SSP_CTRL0_CLKGATE, mxs_mci->regs + HW_SSP_CTRL0 + 8);
 
 	/* reset the unit */
-	mxs_mci_reset(hw_dev);
+	mxs_mci_reset(mxs_mci);
 
 	/* restore the last settings */
-	host->clock = host_data->clock = mxs_mci_setup_clock_speed(hw_dev, host->clock);
-	mxs_mci_setup_timeout(hw_dev, 0xffff);
+	host->clock = mxs_mci->clock = mxs_mci_setup_clock_speed(mxs_mci, host->clock);
+	mxs_mci_setup_timeout(mxs_mci, 0xffff);
 	writel(SSP_CTRL0_IGNORE_CRC |
-		SSP_CTRL0_BUS_WIDTH(host_data->bus_width),
-		hw_dev->map_base + HW_SSP_CTRL0);
+		SSP_CTRL0_BUS_WIDTH(mxs_mci->bus_width),
+		mxs_mci->regs + HW_SSP_CTRL0);
 	writel(SSP_CTRL1_POLARITY |
 		SSP_CTRL1_SSP_MODE(3) |
-		SSP_CTRL1_WORD_LENGTH(7), hw_dev->map_base + HW_SSP_CTRL1);
+		SSP_CTRL1_WORD_LENGTH(7), mxs_mci->regs + HW_SSP_CTRL1);
 
 	return 0;
 }
@@ -637,15 +637,15 @@ static int mxs_mci_initialize(struct mci_host *host, struct device_d *mci_dev)
 static int mxs_mci_request(struct mci_host *host, struct mci_cmd *cmd,
 			struct mci_data *data)
 {
-	struct device_d *hw_dev = host->hw_dev;
+	struct mxs_mci_host *mxs_mci = to_mxs_mci(host);
 	int rc;
 
 	if ((cmd->resp_type == 0) || (data == NULL))
-		rc = mxs_mci_std_cmds(hw_dev, cmd);
+		rc = mxs_mci_std_cmds(mxs_mci, cmd);
 	else
-		rc = mxs_mci_adtc(hw_dev, cmd, data);	/* with response and data */
+		rc = mxs_mci_adtc(mxs_mci, cmd, data);	/* with response and data */
 
-	mxs_mci_finish_request(hw_dev);	/* TODO */
+	mxs_mci_finish_request(mxs_mci);	/* TODO */
 	return rc;
 }
 
@@ -661,25 +661,24 @@ static int mxs_mci_request(struct mci_host *host, struct mci_cmd *cmd,
 static void mxs_mci_set_ios(struct mci_host *host, struct device_d *mci_dev,
 			unsigned bus_width, unsigned clock)
 {
-	struct device_d *hw_dev = host->hw_dev;
-	struct mxs_mci_host *host_data = (struct mxs_mci_host*)GET_HOST_DATA(hw_dev);
+	struct mxs_mci_host *mxs_mci = to_mxs_mci(host);
 
 	switch (bus_width) {
 	case 8:
-		host_data->bus_width = 2;
+		mxs_mci->bus_width = 2;
 		host->bus_width = 8;	/* 8 bit is possible */
 		break;
 	case 4:
-		host_data->bus_width = 1;
+		mxs_mci->bus_width = 1;
 		host->bus_width = 4;	/* 4 bit is possible */
 		break;
 	default:
-		host_data->bus_width = 0;
+		mxs_mci->bus_width = 0;
 		host->bus_width = 1;	/* 1 bit is possible */
 		break;
 	}
 
-	host->clock = host_data->clock = mxs_mci_setup_clock_speed(hw_dev, clock);
+	host->clock = mxs_mci->clock = mxs_mci_setup_clock_speed(mxs_mci, clock);
 	pr_debug("IO settings: bus width=%d, frequency=%u Hz\n", host->bus_width,
 			host->clock);
 }
@@ -691,13 +690,13 @@ const unsigned char bus_width[3] = { 1, 4, 8 };
 
 static void mxs_mci_info(struct device_d *hw_dev)
 {
-	struct mxs_mci_host *host_data = GET_HOST_DATA(hw_dev);
+	struct mxs_mci_host *mxs_mci = GET_HOST_DATA(hw_dev);
 
 	printf(" Interface\n");
-	printf("  Min. bus clock: %u Hz\n", host_data->f_min);
-	printf("  Max. bus clock: %u Hz\n", host_data->f_max);
-	printf("  Current bus clock: %u Hz\n", host_data->clock);
-	printf("  Bus width: %u bit\n", bus_width[host_data->bus_width]);
+	printf("  Min. bus clock: %u Hz\n", mxs_mci->f_min);
+	printf("  Max. bus clock: %u Hz\n", mxs_mci->f_max);
+	printf("  Current bus clock: %u Hz\n", mxs_mci->clock);
+	printf("  Bus width: %u bit\n", bus_width[mxs_mci->bus_width]);
 	printf("\n");
 }
 #endif
@@ -705,7 +704,7 @@ static void mxs_mci_info(struct device_d *hw_dev)
 static int mxs_mci_probe(struct device_d *hw_dev)
 {
 	struct mxs_mci_platform_data *pd = hw_dev->platform_data;
-	struct mxs_mci_host *host_data;
+	struct mxs_mci_host *mxs_mci;
 	struct mci_host *host;
 
 	if (hw_dev->platform_data == NULL) {
@@ -713,62 +712,63 @@ static int mxs_mci_probe(struct device_d *hw_dev)
 		return -EINVAL;
 	}
 
-	host = xzalloc(sizeof(struct mxs_mci_host) + sizeof(struct mci_host));
-	host_data = (struct mxs_mci_host*)&host[1];
+	mxs_mci = xzalloc(sizeof(*mxs_mci));
+	host = &mxs_mci->host;
 
-	hw_dev->priv = host_data;
+	hw_dev->priv = mxs_mci;
 	host->hw_dev = hw_dev;
 	host->send_cmd = mxs_mci_request,
 	host->set_ios = mxs_mci_set_ios,
 	host->init = mxs_mci_initialize,
+	mxs_mci->regs = (void *)hw_dev->map_base;
 
 	/* feed forward the platform specific values */
 	host->voltages = pd->voltages;
 	host->host_caps = pd->caps;
 
 #ifdef CONFIG_ARCH_IMX23
-	host_data->index = 0;	/* there is only one clock for all */
+	mxs_mci->index = 0;	/* there is only one clock for all */
 #endif
 #ifdef CONFIG_ARCH_IMX28
 	/* one dedicated clock per unit */
 	switch (hw_dev->map_base) {
 	case IMX_SSP0_BASE:
-		host_data->index = 0;
+		mxs_mci->index = 0;
 		break;
 	case IMX_SSP1_BASE:
-		host_data->index = 1;
+		mxs_mci->index = 1;
 		break;
 	case IMX_SSP2_BASE:
-		host_data->index = 2;
+		mxs_mci->index = 2;
 		break;
 	case IMX_SSP3_BASE:
-		host_data->index = 3;
+		mxs_mci->index = 3;
 		break;
 	default:
-		pr_debug("Unknown SSP unit at address 0x%08x\n", hw_dev->map_base);
+		pr_debug("Unknown SSP unit at address 0x%08x\n", mxs_mci->regs);
 		return 0;
 	}
 #endif
 	if (pd->f_min == 0) {
-		host->f_min = mxs_mci_get_unit_clock(hw_dev) / 254 / 256;
+		host->f_min = mxs_mci_get_unit_clock(mxs_mci) / 254 / 256;
 		pr_debug("Min. frequency is %u Hz\n", host->f_min);
 	} else {
 		host->f_min = pd->f_min;
 		pr_debug("Min. frequency is %u Hz, could be %u Hz\n",
-			host->f_min, mxs_mci_get_unit_clock(hw_dev) / 254 / 256);
+			host->f_min, mxs_mci_get_unit_clock(mxs_mci) / 254 / 256);
 	}
 	if (pd->f_max == 0) {
-		host->f_max = mxs_mci_get_unit_clock(hw_dev) / 2 / 1;
+		host->f_max = mxs_mci_get_unit_clock(mxs_mci) / 2 / 1;
 		pr_debug("Max. frequency is %u Hz\n", host->f_max);
 	} else {
 		host->f_max =  pd->f_max;
 		pr_debug("Max. frequency is %u Hz, could be %u Hz\n",
-			host->f_max, mxs_mci_get_unit_clock(hw_dev) / 2 / 1);
+			host->f_max, mxs_mci_get_unit_clock(mxs_mci) / 2 / 1);
 	}
 
 #ifdef CONFIG_MCI_INFO
-	host_data->f_min = host->f_min;
-	host_data->f_max = host->f_max;
+	mxs_mci->f_min = host->f_min;
+	mxs_mci->f_max = host->f_max;
 #endif
 
 	return mci_register(host);
-- 
1.7.2.3


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH 6/7] mci mxs: no need to call mxs_mci_setup_clock_speed in init
  2011-02-28  9:43 mmc: i.MX23/28 patches Sascha Hauer
                   ` (4 preceding siblings ...)
  2011-02-28  9:43 ` [PATCH 5/7] mci mxs: make the mci_host a member of mxs_mci_host Sascha Hauer
@ 2011-02-28  9:43 ` Sascha Hauer
  2011-02-28  9:43 ` [PATCH 7/7] ARM tx28stk5: limit mmc max frequency to 25MHz Sascha Hauer
  6 siblings, 0 replies; 8+ messages in thread
From: Sascha Hauer @ 2011-02-28  9:43 UTC (permalink / raw)
  To: barebox

It will be called by set_ios anyway later. Also, do not
alter host->clock field, this is none of our business.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 drivers/mci/mxs.c |    5 ++---
 1 files changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/mci/mxs.c b/drivers/mci/mxs.c
index 7f8f3f8..814eba3 100644
--- a/drivers/mci/mxs.c
+++ b/drivers/mci/mxs.c
@@ -615,7 +615,6 @@ static int mxs_mci_initialize(struct mci_host *host, struct device_d *mci_dev)
 	mxs_mci_reset(mxs_mci);
 
 	/* restore the last settings */
-	host->clock = mxs_mci->clock = mxs_mci_setup_clock_speed(mxs_mci, host->clock);
 	mxs_mci_setup_timeout(mxs_mci, 0xffff);
 	writel(SSP_CTRL0_IGNORE_CRC |
 		SSP_CTRL0_BUS_WIDTH(mxs_mci->bus_width),
@@ -678,9 +677,9 @@ static void mxs_mci_set_ios(struct mci_host *host, struct device_d *mci_dev,
 		break;
 	}
 
-	host->clock = mxs_mci->clock = mxs_mci_setup_clock_speed(mxs_mci, clock);
+	mxs_mci->clock = mxs_mci_setup_clock_speed(mxs_mci, clock);
 	pr_debug("IO settings: bus width=%d, frequency=%u Hz\n", host->bus_width,
-			host->clock);
+			mxs_mci->clock);
 }
 
 /* ----------------------------------------------------------------------- */
-- 
1.7.2.3


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH 7/7] ARM tx28stk5: limit mmc max frequency to 25MHz
  2011-02-28  9:43 mmc: i.MX23/28 patches Sascha Hauer
                   ` (5 preceding siblings ...)
  2011-02-28  9:43 ` [PATCH 6/7] mci mxs: no need to call mxs_mci_setup_clock_speed in init Sascha Hauer
@ 2011-02-28  9:43 ` Sascha Hauer
  6 siblings, 0 replies; 8+ messages in thread
From: Sascha Hauer @ 2011-02-28  9:43 UTC (permalink / raw)
  To: barebox

Higher frequencies do not seem to work.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 arch/arm/boards/karo-tx28/tx28-stk5.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/arch/arm/boards/karo-tx28/tx28-stk5.c b/arch/arm/boards/karo-tx28/tx28-stk5.c
index a3f4a28..81cb80c 100644
--- a/arch/arm/boards/karo-tx28/tx28-stk5.c
+++ b/arch/arm/boards/karo-tx28/tx28-stk5.c
@@ -29,9 +29,10 @@
 #include <mach/fb.h>
 
 static struct mxs_mci_platform_data mci_pdata = {
-	.caps = MMC_MODE_4BIT | MMC_MODE_HS | MMC_MODE_HS_52MHz,
+	.caps = MMC_MODE_4BIT,
 	.voltages = MMC_VDD_32_33 | MMC_VDD_33_34,	/* fixed to 3.3 V */
 	.f_min = 400 * 1000,
+	.f_max = 25000000,
 };
 
 static struct device_d mci_socket = {
-- 
1.7.2.3


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2011-02-28  9:44 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-02-28  9:43 mmc: i.MX23/28 patches Sascha Hauer
2011-02-28  9:43 ` [PATCH 1/7] mci i.MX23/28: rename driver to mxs.c Sascha Hauer
2011-02-28  9:43 ` [PATCH 2/7] mci mxs: put only once used function inline Sascha Hauer
2011-02-28  9:43 ` [PATCH 3/7] mci mxs: give functions a uniq mxs_mci_ namespace Sascha Hauer
2011-02-28  9:43 ` [PATCH 4/7] mci mxs: rename mci_pdata to host Sascha Hauer
2011-02-28  9:43 ` [PATCH 5/7] mci mxs: make the mci_host a member of mxs_mci_host Sascha Hauer
2011-02-28  9:43 ` [PATCH 6/7] mci mxs: no need to call mxs_mci_setup_clock_speed in init Sascha Hauer
2011-02-28  9:43 ` [PATCH 7/7] ARM tx28stk5: limit mmc max frequency to 25MHz Sascha Hauer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox