All of lore.kernel.org
 help / color / mirror / Atom feed
From: Philipp Zabel <philipp.zabel@gmail.com>
To: Ian Molton <ian@mnementh.co.uk>
Cc: linux-mmc@vger.kernel.org, magnus.damm@gmail.com,
	sameo@openedhand.com, pb@handhelds.org
Subject: Re: TMIO MMC: full patchset.
Date: Wed, 30 Sep 2009 18:59:15 +0200	[thread overview]
Message-ID: <1254329955.32349.1.camel@flow> (raw)
In-Reply-To: <c09aa50a0909290552j1c371ddfpc7444d5d87e66f76@mail.gmail.com>

Am Dienstag, den 29.09.2009, 13:52 +0100 schrieb Ian Molton: 
> Hi guys,
> 
> This is the full TMIO MMC patchset, compiled, tested, checkpatch passed.

With bus shift support dropped from the SD_CONFIG register accessors, I
can't use this as-is on ASIC3. What do you think about the following
(sketch of a) patch to add it back?

regards
Philipp 

diff --git a/include/linux/mfd/tmio.h b/include/linux/mfd/tmio.h
index a206a8d..89042d6 100644
--- a/include/linux/mfd/tmio.h
+++ b/include/linux/mfd/tmio.h
@@ -40,14 +40,38 @@
 
 #define   SDCREN 0x2   /* Enable access to MMC CTL regs. (flag in COMMAND_REG)*/
 
-#define sd_config_write8(a, b)  tmio_iowrite8((b), (a))
-#define sd_config_write16(a, b) tmio_iowrite16((b), (a))
-#define sd_config_write32(a, b) tmio_iowrite32((b), (a))
-
-int tmio_core_mmc_enable(void __iomem *cnf, unsigned long base);
-int tmio_core_mmc_resume(void __iomem *cnf, unsigned long base);
-void tmio_core_mmc_pwr(void __iomem *cnf, int state);
-void tmio_core_mmc_clk_div(void __iomem *cnf, int state);
+/*
+ * data for the tmio_core_mmc functions (CONFIG regs)
+ */
+struct tmio_core_mmc {
+	void __iomem *cnf;
+	int           bus_shift;
+	unsigned long base;
+};
+
+static inline void sd_config_write8(struct tmio_core_mmc *sd_config, int addr,
+		u8 val)
+{
+	writeb(val, sd_config->cnf + (addr << sd_config->bus_shift));
+}
+
+static inline void sd_config_write16(struct tmio_core_mmc *sd_config, int addr,
+		u16 val)
+{
+	writew(val, sd_config->cnf + (addr << sd_config->bus_shift));
+}
+
+static inline void sd_config_write32(struct tmio_core_mmc *sd_config, int addr,
+		u32 val)
+{
+	writew(val, sd_config->cnf + (addr << sd_config->bus_shift));
+	writew(val >> 16, sd_config->cnf + ((addr + 2) << sd_config->bus_shift));
+}
+
+int tmio_core_mmc_enable(struct tmio_core_mmc *sd_config);
+int tmio_core_mmc_resume(struct tmio_core_mmc *sd_config);
+void tmio_core_mmc_pwr(struct tmio_core_mmc *sd_config, int state);
+void tmio_core_mmc_clk_div(struct tmio_core_mmc *sd_config, int state);
 
 /*
  * data for the MMC controller
diff --git a/drivers/mfd/tmio_core.c b/drivers/mfd/tmio_core.c
index 483fbbb..7abb997 100644
--- a/drivers/mfd/tmio_core.c
+++ b/drivers/mfd/tmio_core.c
@@ -10,45 +10,45 @@
 
 #include <linux/mfd/tmio.h>
 
-int tmio_core_mmc_enable(void __iomem *cnf, unsigned long base)
+int tmio_core_mmc_enable(struct tmio_core_mmc *sd_config, unsigned long base)
 {
 	/* Enable the MMC/SD Control registers */
-	sd_config_write16(cnf + CNF_CMD, SDCREN);
-	sd_config_write32(cnf + CNF_CTL_BASE, base & 0xfffe);
+	sd_config_write16(sd_config, CNF_CMD, SDCREN);
+	sd_config_write32(sd_config, CNF_CTL_BASE, base & 0xfffe);
 
 	/* Disable SD power during suspend */
-	sd_config_write8(cnf + CNF_PWR_CTL_3, 0x01);
+	sd_config_write8(sd_config, CNF_PWR_CTL_3, 0x01);
 
 	/* The below is required but why? FIXME */
-	sd_config_write8(cnf + CNF_STOP_CLK_CTL, 0x1f);
+	sd_config_write8(sd_config, CNF_STOP_CLK_CTL, 0x1f);
 
 	/* Power down SD bus*/
-	sd_config_write8(cnf + CNF_PWR_CTL_2, 0x00);
+	sd_config_write8(sd_config, CNF_PWR_CTL_2, 0x00);
 
 	return 0;
 }
 EXPORT_SYMBOL(tmio_core_mmc_enable);
 
-int tmio_core_mmc_resume(void __iomem *cnf, unsigned long base)
+int tmio_core_mmc_resume(struct tmio_core_mmc *sd_config, unsigned long base)
 {
 
 	/* Enable the MMC/SD Control registers */
-	sd_config_write16(cnf + CNF_CMD, SDCREN);
-	sd_config_write32(cnf + CNF_CTL_BASE, base & 0xfffe);
+	sd_config_write16(sd_config, CNF_CMD, SDCREN);
+	sd_config_write32(sd_config, CNF_CTL_BASE, base & 0xfffe);
 
 	return 0;
 }
 EXPORT_SYMBOL(tmio_core_mmc_resume);
 
-void tmio_core_mmc_pwr(void __iomem *cnf, int state)
+void tmio_core_mmc_pwr(struct tmio_core_mmc *sd_config, int state)
 {
-	sd_config_write8(cnf + CNF_PWR_CTL_2, state ? 0x02 : 0x00);
+	sd_config_write8(sd_config, CNF_PWR_CTL_2, state ? 0x02 : 0x00);
 }
 EXPORT_SYMBOL(tmio_core_mmc_pwr);
 
-void tmio_core_mmc_clk_div(void __iomem *cnf, int state)
+void tmio_core_mmc_clk_div(struct tmio_core_mmc *sd_config, int state)
 {
-	sd_config_write8(cnf + CNF_SD_CLK_MODE, state ? 1 : 0);
+	sd_config_write8(sd_config, CNF_SD_CLK_MODE, state ? 1 : 0);
 }
 EXPORT_SYMBOL(tmio_core_mmc_clk_div);
 
diff --git a/drivers/mfd/tc6387xb.c b/drivers/mfd/tc6387xb.c
index fa8da02..520effe 100644
--- a/drivers/mfd/tc6387xb.c
+++ b/drivers/mfd/tc6387xb.c
@@ -26,10 +26,9 @@ struct tc6387xb {
 	void __iomem *scr;
 	struct clk *clk32k;
 	struct resource rscr;
+	struct tmio_core_mmc sd_config;
 };
 
-static struct resource tc6387xb_mmc_resources[];
-
 /*--------------------------------------------------------------------------*/
 
 #ifdef CONFIG_PM
@@ -54,8 +53,7 @@ static int tc6387xb_resume(struct platform_device *dev)
 	if (pdata && pdata->resume)
 		pdata->resume(dev);
 
-	tmio_core_mmc_resume(tc6387xb->scr + 0x200,
-		tc6387xb_mmc_resources[0].start & 0xfffe);
+	tmio_core_mmc_resume(&tc6387xb->sd_config);
 
 	return 0;
 }
@@ -71,7 +69,7 @@ static void tc6387xb_mmc_pwr(struct platform_device *mmc, int state)
 	struct platform_device *dev = to_platform_device(mmc->dev.parent);
 	struct tc6387xb *tc6387xb = platform_get_drvdata(dev);
 
-	tmio_core_mmc_pwr(tc6387xb->scr + 0x200, state);
+	tmio_core_mmc_pwr(&tc6387xb->sd_config, state);
 }
 
 static void tc6387xb_mmc_clk_div(struct platform_device *mmc, int state)
@@ -79,7 +77,7 @@ static void tc6387xb_mmc_clk_div(struct platform_device *mmc, int state)
 	struct platform_device *dev = to_platform_device(mmc->dev.parent);
 	struct tc6387xb *tc6387xb = platform_get_drvdata(dev);
 
-	tmio_core_mmc_clk_div(tc6387xb->scr + 0x200, state);
+	tmio_core_mmc_clk_div(&tc6387xb->sd_config, state);
 }
 

@@ -90,8 +88,7 @@ static int tc6387xb_mmc_enable(struct platform_device *mmc)
 
 	clk_enable(tc6387xb->clk32k);
 
-	tmio_core_mmc_enable(tc6387xb->scr + 0x200,
-		tc6387xb_mmc_resources[0].start & 0xfffe);
+	tmio_core_mmc_enable(&tc6387xb->sd_config);
 
 	return 0;
 }
@@ -196,6 +193,9 @@ static int tc6387xb_probe(struct platform_device *dev)
 	tc6387xb_cells[TC6387XB_CELL_MMC].data_size =
 		sizeof(tc6387xb_cells[TC6387XB_CELL_MMC]);
 
+	tc6387xb->sd_config.cnf = tc6387xb->scr + 0x200;
+	tc6387xb->sd_config.base = tc6387xb_mmc_resources[0].start & 0xfffe;
+
 	ret = mfd_add_devices(&dev->dev, dev->id, tc6387xb_cells,
 			      ARRAY_SIZE(tc6387xb_cells), iomem, irq);
 




  parent reply	other threads:[~2009-09-30 16:59 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-09-29 12:52 TMIO MMC: full patchset Ian Molton
2009-09-29 13:20 ` Matt Fleming
2009-09-29 18:32   ` Pierre Ossman
2009-09-30 11:41 ` Magnus Damm
2009-09-30 20:15   ` Ian Molton
2009-10-01  1:30     ` Magnus Damm
2009-10-01  1:39       ` Andrew Morton
2009-10-01 10:21         ` Ian Molton
2009-10-02  6:17         ` Magnus Damm
2009-10-02  7:23           ` Ian Molton
2009-10-02  7:55             ` pHilipp Zabel
2009-10-01 10:19       ` Ian Molton
2009-10-02  5:46         ` Magnus Damm
2009-10-02  7:31           ` Ian Molton
2009-10-02  7:57             ` Magnus Damm
2009-10-02 18:14               ` Ian Molton
2009-10-03 13:11                 ` Magnus Damm
2009-10-04  0:00                   ` Ian Molton
2009-10-04  5:05                     ` Magnus Damm
     [not found]                       ` <c09aa50a0910040851g51640678r5d1f79a50b01164a@mail.gmail.com>
2009-10-04 16:12                         ` Phil Blundell
2009-10-04 17:19                           ` Ian Molton
2009-10-05  6:49                         ` Magnus Damm
2009-09-30 16:59 ` Philipp Zabel [this message]
2009-09-30 21:49   ` Ian Molton

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=1254329955.32349.1.camel@flow \
    --to=philipp.zabel@gmail.com \
    --cc=ian@mnementh.co.uk \
    --cc=linux-mmc@vger.kernel.org \
    --cc=magnus.damm@gmail.com \
    --cc=pb@handhelds.org \
    --cc=sameo@openedhand.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.