From: Magnus Damm <magnus.damm@gmail.com>
To: linux-kernel@vger.kernel.org
Cc: drzeus-wbsd@drzeus.cx, Magnus Damm <magnus.damm@gmail.com>,
ian@mnementh.co.uk, akpm@linux-foundation.org
Subject: [PATCH 03/05] tmio_mmc: Break out cnf area operations
Date: Wed, 11 Mar 2009 21:59:11 +0900 [thread overview]
Message-ID: <20090311125911.1563.27785.sendpatchset@rx1.opensource.se> (raw)
In-Reply-To: <20090311125845.1563.31960.sendpatchset@rx1.opensource.se>
From: Magnus Damm <damm@opensource.se>
Break out tmio_mmc io operations for the cnf area.
This moves similar register operations into one place.
Signed-off-by: Magnus Damm <damm@opensource.se>
---
drivers/mmc/host/tmio_mmc.c | 59 ++++++++++++++++++++++++++++---------------
1 file changed, 39 insertions(+), 20 deletions(-)
--- 0011/drivers/mmc/host/tmio_mmc.c
+++ work/drivers/mmc/host/tmio_mmc.c 2009-03-11 19:31:58.000000000 +0900
@@ -35,6 +35,36 @@
#include "tmio_mmc.h"
+static void tmio_mmc_cnf_power(struct tmio_mmc_host *host, int on)
+{
+ tmio_iowrite8(on ? 0x02 : 0x00, host->cnf + CNF_PWR_CTL_2);
+}
+
+static void tmio_mmc_cnf_setup_regs(struct tmio_mmc_host *host,
+ struct platform_device *dev)
+{
+ /* Enable the MMC/SD Control registers */
+ tmio_iowrite16(SDCREN, host->cnf + CNF_CMD);
+ tmio_iowrite32(dev->resource[0].start & 0xfffe,
+ host->cnf + CNF_CTL_BASE);
+}
+
+static void tmio_mmc_cnf_setup_clock(struct tmio_mmc_host *host,
+ int divide_by_one)
+{
+ tmio_iowrite8(divide_by_one ? 0 : 1,
+ host->cnf + CNF_SD_CLK_MODE);
+}
+
+static void tmio_mmc_cnf_setup_late(struct tmio_mmc_host *host)
+{
+ /* Disable SD power during suspend */
+ tmio_iowrite8(0x01, host->cnf + CNF_PWR_CTL_3);
+
+ /* The below is required but why? FIXME */
+ tmio_iowrite8(0x1f, host->cnf + CNF_STOP_CLK_CTL);
+}
+
/*
* Fixme - documentation conflicts on what the clock values are for the
* various dividers.
@@ -46,7 +76,6 @@
static void tmio_mmc_set_clock(struct tmio_mmc_host *host, int new_clock)
{
- void __iomem *cnf = host->cnf;
void __iomem *ctl = host->ctl;
u32 clk = 0, clock;
@@ -59,7 +88,8 @@ static void tmio_mmc_set_clock(struct tm
clk = 0x20000;
clk >>= 2;
- tmio_iowrite8((clk & 0x8000) ? 0 : 1, cnf + CNF_SD_CLK_MODE);
+
+ tmio_mmc_cnf_setup_clock(host, clk & 0x8000);
clk |= 0x100;
}
@@ -449,7 +479,6 @@ fail:
static void tmio_mmc_set_ios(struct mmc_host *mmc, struct mmc_ios *ios)
{
struct tmio_mmc_host *host = mmc_priv(mmc);
- void __iomem *cnf = host->cnf;
void __iomem *ctl = host->ctl;
if (ios->clock)
@@ -458,12 +487,11 @@ static void tmio_mmc_set_ios(struct mmc_
/* Power sequence - OFF -> ON -> UP */
switch (ios->power_mode) {
case MMC_POWER_OFF: /* power down SD bus */
- tmio_iowrite8(0x00, cnf + CNF_PWR_CTL_2);
+ tmio_mmc_cnf_power(host, 0);
tmio_mmc_clk_stop(host);
break;
case MMC_POWER_ON: /* power up SD bus */
-
- tmio_iowrite8(0x02, cnf + CNF_PWR_CTL_2);
+ tmio_mmc_cnf_power(host, 1);
break;
case MMC_POWER_UP: /* start bus clock */
tmio_mmc_clk_start(host);
@@ -518,12 +546,10 @@ static int tmio_mmc_resume(struct platfo
struct mfd_cell *cell = (struct mfd_cell *)dev->dev.platform_data;
struct mmc_host *mmc = platform_get_drvdata(dev);
struct tmio_mmc_host *host = mmc_priv(mmc);
- void __iomem *cnf = host->cnf;
int ret = 0;
/* Enable the MMC/SD Control registers */
- tmio_iowrite16(SDCREN, cnf + CNF_CMD);
- tmio_iowrite32(dev->resource[0].start & 0xfffe, cnf + CNF_CTL_BASE);
+ tmio_mmc_cnf_setup_regs(host, dev);
/* Tell the MFD core we are ready to be enabled */
if (cell->enable) {
@@ -583,9 +609,7 @@ static int __devinit tmio_mmc_probe(stru
mmc->ocr_avail = MMC_VDD_32_33 | MMC_VDD_33_34;
/* Enable the MMC/SD Control registers */
- tmio_iowrite16(SDCREN, host->cnf + CNF_CMD);
- tmio_iowrite32(dev->resource[0].start & 0xfffe,
- host->cnf + CNF_CTL_BASE);
+ tmio_mmc_cnf_setup_regs(host, dev);
/* Tell the MFD core we are ready to be enabled */
if (cell->enable) {
@@ -594,15 +618,10 @@ static int __devinit tmio_mmc_probe(stru
goto unmap_cnf;
}
- /* Disable SD power during suspend */
- tmio_iowrite8(0x01, host->cnf + CNF_PWR_CTL_3);
-
- /* The below is required but why? FIXME */
- tmio_iowrite8(0x1f, host->cnf + CNF_STOP_CLK_CTL);
-
- /* Power down SD bus*/
- tmio_iowrite8(0x0, host->cnf + CNF_PWR_CTL_2);
+ tmio_mmc_cnf_setup_late(host);
+ /* Power down SD bus */
+ tmio_mmc_cnf_power(host, 0);
tmio_mmc_clk_stop(host);
reset(host);
next prev parent reply other threads:[~2009-03-11 13:02 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-03-11 12:58 [PATCH 00/05] tmio_mmc: Minor fixes and cnf/irq changes Magnus Damm
2009-03-11 12:58 ` [PATCH 01/05] tmio_mmc: Fix one off, use resource_size() in probe() Magnus Damm
2009-03-11 14:26 ` Ian Molton
2009-03-11 12:59 ` [PATCH 02/05] tmio_mmc: Fix use after free in remove() Magnus Damm
2009-03-11 14:28 ` Ian Molton
2009-03-11 12:59 ` Magnus Damm [this message]
2009-03-11 14:39 ` [PATCH 03/05] tmio_mmc: Break out cnf area operations Ian Molton
2009-03-12 2:13 ` Magnus Damm
2009-03-11 12:59 ` [PATCH 04/05] tmio_mmc: Make cnf area optional Magnus Damm
2009-03-11 12:59 ` [PATCH 05/05] tmio_mmc: Support multiple interrupts Magnus Damm
2009-03-11 14:21 ` Ian Molton
2009-03-12 1:45 ` Magnus Damm
2009-03-16 18:30 ` [PATCH 00/05] tmio_mmc: Minor fixes and cnf/irq changes Pierre Ossman
2009-03-18 1:58 ` Magnus Damm
2009-03-24 2:07 ` Ian Molton
2009-03-25 8:56 ` Magnus Damm
2009-03-31 2:51 ` Magnus Damm
2009-03-31 18:37 ` Ian Molton
2009-04-01 2:20 ` Magnus Damm
2009-04-01 19:00 ` Ian Molton
2009-03-24 2:00 ` Ian Molton
2009-03-24 20:05 ` Pierre Ossman
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20090311125911.1563.27785.sendpatchset@rx1.opensource.se \
--to=magnus.damm@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=drzeus-wbsd@drzeus.cx \
--cc=ian@mnementh.co.uk \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox