[PATCH 04/10 RESEND] mmc: spi: Pull out parts shared between MMC and SPI

2012-07-23 Thread Marek Vasut
Abstract out the common part of private data shared between MMC
and SPI. These shall later allow to use common clock configuration
function.

Signed-off-by: Marek Vasut 
Cc: Attila Kinali 
Cc: Chris Ball 
CC: Dong Aisheng 
Cc: Fabio Estevam 
Cc: Grant Likely 
Cc: Linux ARM kernel 
Cc: Mark Brown 
CC: Shawn Guo 
---
 drivers/mmc/host/mxs-mmc.c  |  107 ---
 include/linux/spi/mxs-spi.h |8 
 2 files changed, 67 insertions(+), 48 deletions(-)

diff --git a/drivers/mmc/host/mxs-mmc.c b/drivers/mmc/host/mxs-mmc.c
index e80c2b6..7b85e03 100644
--- a/drivers/mmc/host/mxs-mmc.c
+++ b/drivers/mmc/host/mxs-mmc.c
@@ -62,23 +62,20 @@
 #define MXS_MMC_DETECT_TIMEOUT (HZ/2)
 
 struct mxs_mmc_host {
+   struct mxs_ssp  ssp;
+
struct mmc_host *mmc;
struct mmc_request  *mrq;
struct mmc_command  *cmd;
struct mmc_data *data;
 
-   void __iomem*base;
int dma_channel;
-   struct clk  *clk;
-   unsigned intclk_rate;
-
struct dma_chan *dmach;
struct mxs_dma_data dma_data;
unsigned intdma_dir;
enum dma_transfer_direction slave_dirn;
u32 ssp_pio_words[SSP_PIO_NUM];
 
-   enum mxs_ssp_id devid;
unsigned char   bus_width;
spinlock_t  lock;
int sdio_irq_en;
@@ -105,16 +102,18 @@ static int mxs_mmc_get_ro(struct mmc_host *mmc)
 static int mxs_mmc_get_cd(struct mmc_host *mmc)
 {
struct mxs_mmc_host *host = mmc_priv(mmc);
+   struct mxs_ssp *ssp = &host->ssp;
 
-   return !(readl(host->base + HW_SSP_STATUS(host)) &
+   return !(readl(ssp->base + HW_SSP_STATUS(ssp)) &
 BM_SSP_STATUS_CARD_DETECT);
 }
 
 static void mxs_mmc_reset(struct mxs_mmc_host *host)
 {
+   struct mxs_ssp *ssp = &host->ssp;
u32 ctrl0, ctrl1;
 
-   stmp_reset_block(host->base);
+   stmp_reset_block(ssp->base);
 
ctrl0 = BM_SSP_CTRL0_IGNORE_CRC;
ctrl1 = BF_SSP(0x3, CTRL1_SSP_MODE) |
@@ -130,15 +129,15 @@ static void mxs_mmc_reset(struct mxs_mmc_host *host)
writel(BF_SSP(0x, TIMING_TIMEOUT) |
   BF_SSP(2, TIMING_CLOCK_DIVIDE) |
   BF_SSP(0, TIMING_CLOCK_RATE),
-  host->base + HW_SSP_TIMING(host));
+  ssp->base + HW_SSP_TIMING(ssp));
 
if (host->sdio_irq_en) {
ctrl0 |= BM_SSP_CTRL0_SDIO_IRQ_CHECK;
ctrl1 |= BM_SSP_CTRL1_SDIO_IRQ_EN;
}
 
-   writel(ctrl0, host->base + HW_SSP_CTRL0);
-   writel(ctrl1, host->base + HW_SSP_CTRL1(host));
+   writel(ctrl0, ssp->base + HW_SSP_CTRL0);
+   writel(ctrl1, ssp->base + HW_SSP_CTRL1(ssp));
 }
 
 static void mxs_mmc_start_cmd(struct mxs_mmc_host *host,
@@ -149,15 +148,16 @@ static void mxs_mmc_request_done(struct mxs_mmc_host 
*host)
struct mmc_command *cmd = host->cmd;
struct mmc_data *data = host->data;
struct mmc_request *mrq = host->mrq;
+   struct mxs_ssp *ssp = &host->ssp;
 
if (mmc_resp_type(cmd) & MMC_RSP_PRESENT) {
if (mmc_resp_type(cmd) & MMC_RSP_136) {
-   cmd->resp[3] = readl(host->base + HW_SSP_SDRESP0(host));
-   cmd->resp[2] = readl(host->base + HW_SSP_SDRESP1(host));
-   cmd->resp[1] = readl(host->base + HW_SSP_SDRESP2(host));
-   cmd->resp[0] = readl(host->base + HW_SSP_SDRESP3(host));
+   cmd->resp[3] = readl(ssp->base + HW_SSP_SDRESP0(ssp));
+   cmd->resp[2] = readl(ssp->base + HW_SSP_SDRESP1(ssp));
+   cmd->resp[1] = readl(ssp->base + HW_SSP_SDRESP2(ssp));
+   cmd->resp[0] = readl(ssp->base + HW_SSP_SDRESP3(ssp));
} else {
-   cmd->resp[0] = readl(host->base + HW_SSP_SDRESP0(host));
+   cmd->resp[0] = readl(ssp->base + HW_SSP_SDRESP0(ssp));
}
}
 
@@ -196,13 +196,14 @@ static irqreturn_t mxs_mmc_irq_handler(int irq, void 
*dev_id)
struct mxs_mmc_host *host = dev_id;
struct mmc_command *cmd = host->cmd;
struct mmc_data *data = host->data;
+   struct mxs_ssp *ssp = &host->ssp;
u32 stat;
 
spin_lock(&host->lock);
 
-   stat = readl(host->base + HW_SSP_CTRL1(host));
+   stat = readl(ssp->base + HW_SSP_CTRL1(ssp));
writel(stat & MXS_MMC_IRQ_BITS,
-  host->base + HW_SSP_CTRL1(host) + STMP_OFFSET_REG_CLR);
+  ssp->base + HW_SSP_CTRL1(ssp) + STMP_OFFSET_REG_CLR);
 
if ((stat & BM_SSP_CTRL1_SDIO_IRQ) && (stat & BM_SSP_CTRL1_SDIO_IRQ_EN))
mmc_sign

Re: [PATCH 04/10 RESEND] mmc: spi: Pull out parts shared between MMC and SPI

2012-07-16 Thread Attila Kinali
Moin Marek,

On Mon, 16 Jul 2012 12:59:14 +0200
Marek Vasut  wrote:

> Well I have it rebased on top of current -next, but ... will some of the SPI 
> maintainers possibly apply it to their -next tree any soon? Or why are these 
> patches stuck as they are without much review ?

Do you have somewhere a public git repo with the patches?
I'd like to give them a try.

Attila Kinali

-- 
The trouble with you, Shev, is you don't say anything until you've saved
up a whole truckload of damned heavy brick arguments and then you dump
them all out and never look at the bleeding body mangled beneath the heap
-- Tirin, The Dispossessed, U. Le Guin

--
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
___
spi-devel-general mailing list
spi-devel-general@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/spi-devel-general


Re: [PATCH 04/10 RESEND] mmc: spi: Pull out parts shared between MMC and SPI

2012-07-16 Thread Marek Vasut
Dear Attila Kinali,

> Moin,
> 
> I just wanted to try out this patchset as i have a use for proper spi
> support on i.mx23. But this patch (4/10) fails to apply at line 635
> 
[...]

> > +   struct mxs_ssp *ssp;
> > 
> > iores = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> > dmares = platform_get_resource(pdev, IORESOURCE_DMA, 0);
> 
> The function variables do not match.
> 
> Also a 3way merge didnt work as the comit on which this patchset was
> based on wasnt found. I tried linux, linux-next, and the imx repos
> from pengutronix and Shawn, to no avail.
> 
> Is there any other repo around that i'm not aware of?
> 
>   Attila Kinali

Well I have it rebased on top of current -next, but ... will some of the SPI 
maintainers possibly apply it to their -next tree any soon? Or why are these 
patches stuck as they are without much review ?

It seems Shawn is OK with the latest version, so can these be applied? I'll 
post 
the rebased version again if necessary.

Best regards,
Marek Vasut

--
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
___
spi-devel-general mailing list
spi-devel-general@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/spi-devel-general


Re: [PATCH 04/10 RESEND] mmc: spi: Pull out parts shared between MMC and SPI

2012-07-16 Thread Attila Kinali
Moin,

I just wanted to try out this patchset as i have a use for proper spi
support on i.mx23. But this patch (4/10) fails to apply at line 635

On Fri,  6 Jul 2012 08:17:23 +0200
Marek Vasut  wrote:

> diff --git a/drivers/mmc/host/mxs-mmc.c b/drivers/mmc/host/mxs-mmc.c
> index f9509e8..1ea1cba 100644
> --- a/drivers/mmc/host/mxs-mmc.c
> +++ b/drivers/mmc/host/mxs-mmc.c
> @@ -635,6 +640,7 @@ static int mxs_mmc_probe(struct platform_device *pdev)
>   dma_cap_mask_t mask;
>   struct regulator *reg_vmmc;
>   enum of_gpio_flags flags;
> + struct mxs_ssp *ssp;
>  
>   iores = platform_get_resource(pdev, IORESOURCE_MEM, 0);
>   dmares = platform_get_resource(pdev, IORESOURCE_DMA, 0);

The function variables do not match.

Also a 3way merge didnt work as the comit on which this patchset was
based on wasnt found. I tried linux, linux-next, and the imx repos
from pengutronix and Shawn, to no avail.

Is there any other repo around that i'm not aware of?

Attila Kinali

-- 
The trouble with you, Shev, is you don't say anything until you've saved
up a whole truckload of damned heavy brick arguments and then you dump
them all out and never look at the bleeding body mangled beneath the heap
-- Tirin, The Dispossessed, U. Le Guin

--
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
___
spi-devel-general mailing list
spi-devel-general@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/spi-devel-general


[PATCH 04/10 RESEND] mmc: spi: Pull out parts shared between MMC and SPI

2012-07-05 Thread Marek Vasut
Abstract out the common part of private data shared between MMC
and SPI. These shall later allow to use common clock configuration
function.

Signed-off-by: Marek Vasut 
Cc: Chris Ball 
Cc: Detlev Zundel 
CC: Dong Aisheng 
Cc: Fabio Estevam 
Cc: Grant Likely 
Cc: Linux ARM kernel 
Cc: Rob Herring 
CC: Shawn Guo 
Cc: Stefano Babic 
Cc: Wolfgang Denk 
---
 drivers/mmc/host/mxs-mmc.c  |  107 ---
 include/linux/spi/mxs-spi.h |8 
 2 files changed, 67 insertions(+), 48 deletions(-)

diff --git a/drivers/mmc/host/mxs-mmc.c b/drivers/mmc/host/mxs-mmc.c
index f9509e8..1ea1cba 100644
--- a/drivers/mmc/host/mxs-mmc.c
+++ b/drivers/mmc/host/mxs-mmc.c
@@ -62,23 +62,20 @@
 #define MXS_MMC_DETECT_TIMEOUT (HZ/2)
 
 struct mxs_mmc_host {
+   struct mxs_ssp  ssp;
+
struct mmc_host *mmc;
struct mmc_request  *mrq;
struct mmc_command  *cmd;
struct mmc_data *data;
 
-   void __iomem*base;
int dma_channel;
-   struct clk  *clk;
-   unsigned intclk_rate;
-
struct dma_chan *dmach;
struct mxs_dma_data dma_data;
unsigned intdma_dir;
enum dma_transfer_direction slave_dirn;
u32 ssp_pio_words[SSP_PIO_NUM];
 
-   enum mxs_ssp_id devid;
unsigned char   bus_width;
spinlock_t  lock;
int sdio_irq_en;
@@ -105,16 +102,18 @@ static int mxs_mmc_get_ro(struct mmc_host *mmc)
 static int mxs_mmc_get_cd(struct mmc_host *mmc)
 {
struct mxs_mmc_host *host = mmc_priv(mmc);
+   struct mxs_ssp *ssp = &host->ssp;
 
-   return !(readl(host->base + HW_SSP_STATUS(host)) &
+   return !(readl(ssp->base + HW_SSP_STATUS(ssp)) &
 BM_SSP_STATUS_CARD_DETECT);
 }
 
 static void mxs_mmc_reset(struct mxs_mmc_host *host)
 {
+   struct mxs_ssp *ssp = &host->ssp;
u32 ctrl0, ctrl1;
 
-   stmp_reset_block(host->base);
+   stmp_reset_block(ssp->base);
 
ctrl0 = BM_SSP_CTRL0_IGNORE_CRC;
ctrl1 = BF_SSP(0x3, CTRL1_SSP_MODE) |
@@ -130,15 +129,15 @@ static void mxs_mmc_reset(struct mxs_mmc_host *host)
writel(BF_SSP(0x, TIMING_TIMEOUT) |
   BF_SSP(2, TIMING_CLOCK_DIVIDE) |
   BF_SSP(0, TIMING_CLOCK_RATE),
-  host->base + HW_SSP_TIMING(host));
+  ssp->base + HW_SSP_TIMING(ssp));
 
if (host->sdio_irq_en) {
ctrl0 |= BM_SSP_CTRL0_SDIO_IRQ_CHECK;
ctrl1 |= BM_SSP_CTRL1_SDIO_IRQ_EN;
}
 
-   writel(ctrl0, host->base + HW_SSP_CTRL0);
-   writel(ctrl1, host->base + HW_SSP_CTRL1(host));
+   writel(ctrl0, ssp->base + HW_SSP_CTRL0);
+   writel(ctrl1, ssp->base + HW_SSP_CTRL1(ssp));
 }
 
 static void mxs_mmc_start_cmd(struct mxs_mmc_host *host,
@@ -149,15 +148,16 @@ static void mxs_mmc_request_done(struct mxs_mmc_host 
*host)
struct mmc_command *cmd = host->cmd;
struct mmc_data *data = host->data;
struct mmc_request *mrq = host->mrq;
+   struct mxs_ssp *ssp = &host->ssp;
 
if (mmc_resp_type(cmd) & MMC_RSP_PRESENT) {
if (mmc_resp_type(cmd) & MMC_RSP_136) {
-   cmd->resp[3] = readl(host->base + HW_SSP_SDRESP0(host));
-   cmd->resp[2] = readl(host->base + HW_SSP_SDRESP1(host));
-   cmd->resp[1] = readl(host->base + HW_SSP_SDRESP2(host));
-   cmd->resp[0] = readl(host->base + HW_SSP_SDRESP3(host));
+   cmd->resp[3] = readl(ssp->base + HW_SSP_SDRESP0(ssp));
+   cmd->resp[2] = readl(ssp->base + HW_SSP_SDRESP1(ssp));
+   cmd->resp[1] = readl(ssp->base + HW_SSP_SDRESP2(ssp));
+   cmd->resp[0] = readl(ssp->base + HW_SSP_SDRESP3(ssp));
} else {
-   cmd->resp[0] = readl(host->base + HW_SSP_SDRESP0(host));
+   cmd->resp[0] = readl(ssp->base + HW_SSP_SDRESP0(ssp));
}
}
 
@@ -196,13 +196,14 @@ static irqreturn_t mxs_mmc_irq_handler(int irq, void 
*dev_id)
struct mxs_mmc_host *host = dev_id;
struct mmc_command *cmd = host->cmd;
struct mmc_data *data = host->data;
+   struct mxs_ssp *ssp = &host->ssp;
u32 stat;
 
spin_lock(&host->lock);
 
-   stat = readl(host->base + HW_SSP_CTRL1(host));
+   stat = readl(ssp->base + HW_SSP_CTRL1(ssp));
writel(stat & MXS_MMC_IRQ_BITS,
-  host->base + HW_SSP_CTRL1(host) + STMP_OFFSET_REG_CLR);
+  ssp->base + HW_SSP_CTRL1(ssp) + STMP_OFFSET_REG_CLR);
 
if ((stat & BM_SSP_CTRL1_SDIO_IRQ) && (stat & BM_SSP_CTRL1