[PATCH 01/25] spi/imx: make spi_imx_data.devtype_data member point to const data

2012-07-23 Thread Uwe Kleine-König
This prepares *of_device_id.data becoming const. Without this change the
following warning would occur:

drivers/spi/spi-imx.c: In function spi_imx_probe:
drivers/spi/spi-imx.c:814:24: warning: assignment discards const 
qualifier from pointer target type [enabled by default]

Signed-off-by: Uwe Kleine-König u.kleine-koe...@pengutronix.de
---
 drivers/spi/spi-imx.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/spi/spi-imx.c b/drivers/spi/spi-imx.c
index 47877d6..b09fc77 100644
--- a/drivers/spi/spi-imx.c
+++ b/drivers/spi/spi-imx.c
@@ -97,7 +97,7 @@ struct spi_imx_data {
const void *tx_buf;
unsigned int txfifo; /* number of words pushed in tx FIFO */
 
-   struct spi_imx_devtype_data *devtype_data;
+   const struct spi_imx_devtype_data *devtype_data;
int chipselect[0];
 };
 
-- 
1.7.10.4


--
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 02/25] spi/spi-omap2-mcspi: add a const qualifier

2012-07-23 Thread Uwe Kleine-König
This prepares *of_device_id.data becoming const. Without this change
the following warning would occur:

drivers/spi/spi-omap2-mcspi.c: In function 'omap2_mcspi_probe':
drivers/spi/spi-omap2-mcspi.c:1118: warning: assignment discards 
qualifiers from pointer target type

Signed-off-by: Uwe Kleine-König u.kleine-koe...@pengutronix.de
---
 drivers/spi/spi-omap2-mcspi.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/spi/spi-omap2-mcspi.c b/drivers/spi/spi-omap2-mcspi.c
index 0c73dd4..3455769 100644
--- a/drivers/spi/spi-omap2-mcspi.c
+++ b/drivers/spi/spi-omap2-mcspi.c
@@ -1087,7 +1087,7 @@ MODULE_DEVICE_TABLE(of, omap_mcspi_of_match);
 static int __devinit omap2_mcspi_probe(struct platform_device *pdev)
 {
struct spi_master   *master;
-   struct omap2_mcspi_platform_config *pdata;
+   const struct omap2_mcspi_platform_config *pdata;
struct omap2_mcspi  *mcspi;
struct resource *r;
int status = 0, i;
-- 
1.7.10.4


--
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 19/25] of: add const to struct *of_device_id.data

2012-07-23 Thread Uwe Kleine-König
Drivers should never need to modify the data of a device id. So it can
be const which in turn allows more consts in the driver.

Signed-off-by: Uwe Kleine-König u.kleine-koe...@pengutronix.de
---
 include/linux/mod_devicetable.h |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/linux/mod_devicetable.h b/include/linux/mod_devicetable.h
index 5db9382..98fb3fe 100644
--- a/include/linux/mod_devicetable.h
+++ b/include/linux/mod_devicetable.h
@@ -224,7 +224,7 @@ struct of_device_id
chartype[32];
charcompatible[128];
 #ifdef __KERNEL__
-   void*data;
+   const void *data;
 #else
kernel_ulong_t data;
 #endif
-- 
1.7.10.4


--
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 v2 00/25] make *struct of_device_id.data const

2012-07-23 Thread Uwe Kleine-König
Hello,

this is the 2nd version of this series whose goal is to make struct
of_device_id.data const. Conceptually a driver must not modify the data
contained there so making it const is the right thing.

v1 of this series was sent with Message-id:
1342182734-321-1-git-send-email-y. Changes since then are:
 - powerpc fixes
 - several new consts that were found by Arnd that are possible after
   patch 19.
   
Arnd suggested to take this series via arm-soc late for 3.6 in one go
because patch 19 depends on the former patches but is a precondition to
the latter and it fixes a few warnings. So getting it in via the
respective maintainer trees would need a much bigger coordination
effort. That means I prefer getting Acks over you taking the patch.

Vinod Koul already took
dmaengine: at_hdmac: add a few const qualifiers
that is in next-20120723 as 7fd63ccdad72 now. Vinod, I don't follow your
pull requests, but assuming you didn't let it already pull for 3.6 I
suggest you drop it from your queue and I just take your Ack.

This series was build tested for arm (all defconfigs) and powerpc (all
defconfigs and an allyesconfig) and grep didn't find more issues. As
before it introduces a warning in drivers/regulator/twl-regulator.c.
This driver does modify its .of_match_table when a device is bound which
doesn't fits the concept of independant devices. Arnd noticed another
new warning in drivers/scsi/qlogicpti.c that isn't that easy to resolve,
because the pointer to (now) const data is passed as first argument to
scsi_host_alloc. To fix that properly struct Scsi_Host.hostt needs to
get a const, too. Alternatively I could introduce a cast removing the
const, but I don't like that.

This series is also available at:

git://git.pengutronix.de/git/ukl/linux.git ofdeviceiddata

and I will modify it there for the Acks I'm getting.

Arnd Bergmann (6):
  watchdog/mpc8xxx: add a const qualifier
  powerpc/fsl_msi: drop unneeded cast to non-const pointer
  mfd/da9052: make i2c_device_id array const
  i2c/mpc: make data used as *of_device_id.data const
  macintosh/mediabay: make data used as *of_device_id.data const
  can: mpc5xxx_can: make data used as *of_device_id.data const

Marc Kleine-Budde (1):
  can: mpc5xxx_can: make data in mpc5xxx_can_probe const

Uwe Kleine-König (18):
  spi/imx: make spi_imx_data.devtype_data member point to const data
  spi/spi-omap2-mcspi: add a const qualifier
  serial/imx: make imx_port.devdata member point to const data
  serial/mpc52xx_uart: add a const qualifier
  ARM: cache-l2x0: add a const qualifier
  misc/atmel_tc: make atmel_tc.tcb_config member point to const data
  gpio/gpio-omap.c: add a const qualifier
  gpio/mpc8xxx: add a const qualifier
  i2c/i2c-omap: add a const qualifier
  i2c/mpc: add a const qualifier
  dmaengine: at_hdmac: add a few const qualifiers
  mmc/omap_hsmmc: add a const qualifier
  macintosh/mediabay: add a const qualifier
  powerpc/83xx: add a const qualifier
  powerpc/fsl_msi: add a const qualifier
  powerpc/celleb_pci: add a const qualifier
  of: add const to struct *of_device_id.data
  gpio/gpio-omap: make platformdata used as *of_device_id.data const

 arch/arm/mm/cache-l2x0.c |2 +-
 arch/powerpc/platforms/83xx/suspend.c|2 +-
 arch/powerpc/platforms/cell/celleb_pci.c |2 +-
 arch/powerpc/sysdev/fsl_msi.c|8 
 drivers/dma/at_hdmac.c   |4 ++--
 drivers/gpio/gpio-mpc8xxx.c  |2 +-
 drivers/gpio/gpio-omap.c |8 
 drivers/i2c/busses/i2c-mpc.c |   12 ++--
 drivers/i2c/busses/i2c-omap.c|3 ++-
 drivers/macintosh/mediabay.c |8 
 drivers/mfd/da9052-i2c.c |4 ++--
 drivers/mmc/host/omap_hsmmc.c|2 +-
 drivers/net/can/mscan/mpc5xxx_can.c  |6 +++---
 drivers/spi/spi-imx.c|2 +-
 drivers/spi/spi-omap2-mcspi.c|2 +-
 drivers/tty/serial/imx.c |2 +-
 drivers/tty/serial/mpc52xx_uart.c|2 +-
 drivers/watchdog/mpc8xxx_wdt.c   |2 +-
 include/linux/atmel_tc.h |2 +-
 include/linux/mod_devicetable.h  |2 +-
 20 files changed, 39 insertions(+), 38 deletions(-)

-- 
1.7.10.4


--
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 19/25] of: add const to struct *of_device_id.data

2012-07-23 Thread Greg Kroah-Hartman
On Mon, Jul 23, 2012 at 11:13:24AM +0200, Uwe Kleine-König wrote:
 Drivers should never need to modify the data of a device id. So it can
 be const which in turn allows more consts in the driver.
 
 Signed-off-by: Uwe Kleine-König u.kleine-koe...@pengutronix.de

Acked-by: Greg Kroah-Hartman gre...@linuxfoundation.org

--
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 2/2] kthread_worker: reimplement flush_kthread_work() to allow freeing the work item being executed

2012-07-23 Thread Tejun Heo
Hello,

On Sun, Jul 22, 2012 at 04:46:54PM -0400, Andy Walls wrote:
 Hmmm, I didn't know about the constraint about 'known to be alive' in
 the other email I just sent.
 
 That might make calling flush_kthread_work() hard for a user to use, if
 the user lets the work get freed by another thread executing the work.

Umm... flushing a freed work item doesn't make any sense at all.  The
pointer itself loses the ability to identify anything.  What if it
gets recycled to another work item which happens to depend on the
flusher to make forward progress?  You now have a circular dependency
through a recycled memory area.  Good luck hunting that down.

For pretty much any API, allowing dangling pointers as argument is
insane.  If you want to flush self-freeing work items, flush the
kthread_worker.  That's how it is with workqueue and how it should be
with kthread_worker too.

Thanks.

-- 
tejun

--
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-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 ma...@denx.de
Cc: Attila Kinali att...@kinali.ch
Cc: Chris Ball c...@laptop.org
CC: Dong Aisheng b29...@freescale.com
Cc: Fabio Estevam fabio.este...@freescale.com
Cc: Grant Likely grant.lik...@secretlab.ca
Cc: Linux ARM kernel linux-arm-ker...@lists.infradead.org
Cc: Mark Brown broo...@opensource.wolfsonmicro.com
CC: Shawn Guo shawn@linaro.org
---
 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);
+  

[PATCH 01/10 RESEND] mmc: spi: Move SSP register definitions into separate file

2012-07-23 Thread Marek Vasut
Move the definitions into separate file so separate SPI driver can be
implemented. The SSP controller in MXS can act both as a MMC host and
as a SPI host.

Based on previous attempt by:
Fabio Estevam fabio.este...@freescale.com

Signed-off-by: Fabio Estevam fabio.este...@freescale.com
Signed-off-by: Marek Vasut ma...@denx.de
Cc: Attila Kinali att...@kinali.ch
Cc: Chris Ball c...@laptop.org
CC: Dong Aisheng b29...@freescale.com
Cc: Grant Likely grant.lik...@secretlab.ca
Cc: Linux ARM kernel linux-arm-ker...@lists.infradead.org
Cc: Mark Brown broo...@opensource.wolfsonmicro.com
CC: Shawn Guo shawn@linaro.org
---
 drivers/mmc/host/mxs-mmc.c  |   87 ++
 include/linux/spi/mxs-spi.h |  109 +++
 2 files changed, 112 insertions(+), 84 deletions(-)
 create mode 100644 include/linux/spi/mxs-spi.h

diff --git a/drivers/mmc/host/mxs-mmc.c b/drivers/mmc/host/mxs-mmc.c
index a51f930..26c95dc 100644
--- a/drivers/mmc/host/mxs-mmc.c
+++ b/drivers/mmc/host/mxs-mmc.c
@@ -45,87 +45,10 @@
 #include linux/pinctrl/consumer.h
 #include linux/stmp_device.h
 #include linux/mmc/mxs-mmc.h
+#include linux/spi/mxs-spi.h
 
 #define DRIVER_NAMEmxs-mmc
 
-/* card detect polling timeout */
-#define MXS_MMC_DETECT_TIMEOUT (HZ/2)
-
-#define ssp_is_old(host)   ((host)-devid == IMX23_MMC)
-
-/* SSP registers */
-#define HW_SSP_CTRL0   0x000
-#define  BM_SSP_CTRL0_RUN  (1  29)
-#define  BM_SSP_CTRL0_SDIO_IRQ_CHECK   (1  28)
-#define  BM_SSP_CTRL0_IGNORE_CRC   (1  26)
-#define  BM_SSP_CTRL0_READ (1  25)
-#define  BM_SSP_CTRL0_DATA_XFER(1  24)
-#define  BP_SSP_CTRL0_BUS_WIDTH(22)
-#define  BM_SSP_CTRL0_BUS_WIDTH(0x3  22)
-#define  BM_SSP_CTRL0_WAIT_FOR_IRQ (1  21)
-#define  BM_SSP_CTRL0_LONG_RESP(1  19)
-#define  BM_SSP_CTRL0_GET_RESP (1  17)
-#define  BM_SSP_CTRL0_ENABLE   (1  16)
-#define  BP_SSP_CTRL0_XFER_COUNT   (0)
-#define  BM_SSP_CTRL0_XFER_COUNT   (0x)
-#define HW_SSP_CMD00x010
-#define  BM_SSP_CMD0_DBL_DATA_RATE_EN  (1  25)
-#define  BM_SSP_CMD0_SLOW_CLKING_EN(1  22)
-#define  BM_SSP_CMD0_CONT_CLKING_EN(1  21)
-#define  BM_SSP_CMD0_APPEND_8CYC   (1  20)
-#define  BP_SSP_CMD0_BLOCK_SIZE(16)
-#define  BM_SSP_CMD0_BLOCK_SIZE(0xf  16)
-#define  BP_SSP_CMD0_BLOCK_COUNT   (8)
-#define  BM_SSP_CMD0_BLOCK_COUNT   (0xff  8)
-#define  BP_SSP_CMD0_CMD   (0)
-#define  BM_SSP_CMD0_CMD   (0xff)
-#define HW_SSP_CMD10x020
-#define HW_SSP_XFER_SIZE   0x030
-#define HW_SSP_BLOCK_SIZE  0x040
-#define  BP_SSP_BLOCK_SIZE_BLOCK_COUNT (4)
-#define  BM_SSP_BLOCK_SIZE_BLOCK_COUNT (0xff  4)
-#define  BP_SSP_BLOCK_SIZE_BLOCK_SIZE  (0)
-#define  BM_SSP_BLOCK_SIZE_BLOCK_SIZE  (0xf)
-#define HW_SSP_TIMING(h)   (ssp_is_old(h) ? 0x050 : 0x070)
-#define  BP_SSP_TIMING_TIMEOUT (16)
-#define  BM_SSP_TIMING_TIMEOUT (0x  16)
-#define  BP_SSP_TIMING_CLOCK_DIVIDE(8)
-#define  BM_SSP_TIMING_CLOCK_DIVIDE(0xff  8)
-#define  BP_SSP_TIMING_CLOCK_RATE  (0)
-#define  BM_SSP_TIMING_CLOCK_RATE  (0xff)
-#define HW_SSP_CTRL1(h)(ssp_is_old(h) ? 0x060 
: 0x080)
-#define  BM_SSP_CTRL1_SDIO_IRQ (1  31)
-#define  BM_SSP_CTRL1_SDIO_IRQ_EN  (1  30)
-#define  BM_SSP_CTRL1_RESP_ERR_IRQ (1  29)
-#define  BM_SSP_CTRL1_RESP_ERR_IRQ_EN  (1  28)
-#define  BM_SSP_CTRL1_RESP_TIMEOUT_IRQ (1  27)
-#define  BM_SSP_CTRL1_RESP_TIMEOUT_IRQ_EN  (1  26)
-#define  BM_SSP_CTRL1_DATA_TIMEOUT_IRQ (1  25)
-#define  BM_SSP_CTRL1_DATA_TIMEOUT_IRQ_EN  (1  24)
-#define  BM_SSP_CTRL1_DATA_CRC_IRQ (1  23)
-#define  BM_SSP_CTRL1_DATA_CRC_IRQ_EN  (1  22)
-#define  BM_SSP_CTRL1_FIFO_UNDERRUN_IRQ(1  21)
-#define  BM_SSP_CTRL1_FIFO_UNDERRUN_IRQ_EN (1  20)
-#define  BM_SSP_CTRL1_RECV_TIMEOUT_IRQ (1  17)
-#define  BM_SSP_CTRL1_RECV_TIMEOUT_IRQ_EN  (1  16)
-#define  BM_SSP_CTRL1_FIFO_OVERRUN_IRQ (1  15)
-#define  BM_SSP_CTRL1_FIFO_OVERRUN_IRQ_EN  (1  14)
-#define  BM_SSP_CTRL1_DMA_ENABLE   (1  13)
-#define  BM_SSP_CTRL1_POLARITY (1  9)
-#define  BP_SSP_CTRL1_WORD_LENGTH  (4)
-#define  BM_SSP_CTRL1_WORD_LENGTH  (0xf  4)
-#define  BP_SSP_CTRL1_SSP_MODE (0)
-#define  BM_SSP_CTRL1_SSP_MODE (0xf)
-#define HW_SSP_SDRESP0(h)  

[PATCH 03/10 V2] mmc: spi: Add necessary bits into mxs-spi.h

2012-07-23 Thread Marek Vasut
Add missing register bits and registers into mxs-spi.h .
These will be used by the SPI driver.

Based on previous attempt by:
Fabio Estevam fabio.este...@freescale.com

Signed-off-by: Fabio Estevam fabio.este...@freescale.com
Signed-off-by: Marek Vasut ma...@denx.de
Cc: Attila Kinali att...@kinali.ch
Cc: Chris Ball c...@laptop.org
CC: Dong Aisheng b29...@freescale.com
Cc: Grant Likely grant.lik...@secretlab.ca
Cc: Linux ARM kernel linux-arm-ker...@lists.infradead.org
Cc: Mark Brown broo...@opensource.wolfsonmicro.com
CC: Shawn Guo shawn@linaro.org
---
 include/linux/spi/mxs-spi.h |   22 ++
 1 file changed, 22 insertions(+)

V2: Location of HW_SSP_DATA register differs on MX233 and MX28,
handle accordingly. (Thanks to Attila Kinali for finding this).

diff --git a/include/linux/spi/mxs-spi.h b/include/linux/spi/mxs-spi.h
index c08aef5..7dfa1d7 100644
--- a/include/linux/spi/mxs-spi.h
+++ b/include/linux/spi/mxs-spi.h
@@ -30,12 +30,14 @@
 #define HW_SSP_CTRL0   0x000
 #define  BM_SSP_CTRL0_RUN  (1  29)
 #define  BM_SSP_CTRL0_SDIO_IRQ_CHECK   (1  28)
+#define  BM_SSP_CTRL0_LOCK_CS  (1  27)
 #define  BM_SSP_CTRL0_IGNORE_CRC   (1  26)
 #define  BM_SSP_CTRL0_READ (1  25)
 #define  BM_SSP_CTRL0_DATA_XFER(1  24)
 #define  BP_SSP_CTRL0_BUS_WIDTH22
 #define  BM_SSP_CTRL0_BUS_WIDTH(0x3  22)
 #define  BM_SSP_CTRL0_WAIT_FOR_IRQ (1  21)
+#define  BM_SSP_CTRL0_WAIT_FOR_CMD (1  20)
 #define  BM_SSP_CTRL0_LONG_RESP(1  19)
 #define  BM_SSP_CTRL0_GET_RESP (1  17)
 #define  BM_SSP_CTRL0_ENABLE   (1  16)
@@ -64,8 +66,12 @@
 #define  BM_SSP_TIMING_TIMEOUT (0x  16)
 #define  BP_SSP_TIMING_CLOCK_DIVIDE8
 #define  BM_SSP_TIMING_CLOCK_DIVIDE(0xff  8)
+#define  BF_SSP_TIMING_CLOCK_DIVIDE(v) \
+   (((v)  8)  BM_SSP_TIMING_CLOCK_DIVIDE)
 #define  BP_SSP_TIMING_CLOCK_RATE  0
 #define  BM_SSP_TIMING_CLOCK_RATE  0xff
+#define BF_SSP_TIMING_CLOCK_RATE(v)\
+   (((v)  0)  BM_SSP_TIMING_CLOCK_RATE)
 #define HW_SSP_CTRL1(h)(ssp_is_old(h) ? 0x060 
: 0x080)
 #define  BM_SSP_CTRL1_SDIO_IRQ (1  31)
 #define  BM_SSP_CTRL1_SDIO_IRQ_EN  (1  30)
@@ -84,11 +90,26 @@
 #define  BM_SSP_CTRL1_FIFO_OVERRUN_IRQ (1  15)
 #define  BM_SSP_CTRL1_FIFO_OVERRUN_IRQ_EN  (1  14)
 #define  BM_SSP_CTRL1_DMA_ENABLE   (1  13)
+#define  BM_SSP_CTRL1_PHASE(1  10)
 #define  BM_SSP_CTRL1_POLARITY (1  9)
 #define  BP_SSP_CTRL1_WORD_LENGTH  4
 #define  BM_SSP_CTRL1_WORD_LENGTH  (0xf  4)
+#define  BF_SSP_CTRL1_WORD_LENGTH(v)   \
+   (((v)  4)  BM_SSP_CTRL1_WORD_LENGTH)
+#define  BV_SSP_CTRL1_WORD_LENGTH__FOUR_BITS   0x3
+#define  BV_SSP_CTRL1_WORD_LENGTH__EIGHT_BITS  0x7
+#define  BV_SSP_CTRL1_WORD_LENGTH__SIXTEEN_BITS0xF
 #define  BP_SSP_CTRL1_SSP_MODE 0
 #define  BM_SSP_CTRL1_SSP_MODE 0xf
+#define  BF_SSP_CTRL1_SSP_MODE(v)  \
+   (((v)  0)  BM_SSP_CTRL1_SSP_MODE)
+#define  BV_SSP_CTRL1_SSP_MODE__SPI0x0
+#define  BV_SSP_CTRL1_SSP_MODE__SSI0x1
+#define  BV_SSP_CTRL1_SSP_MODE__SD_MMC 0x3
+#define  BV_SSP_CTRL1_SSP_MODE__MS 0x4
+
+#define HW_SSP_DATA(h) (ssp_is_old(h) ? 0x070 : 0x090)
+
 #define HW_SSP_SDRESP0(h)  (ssp_is_old(h) ? 0x080 : 0x0a0)
 #define HW_SSP_SDRESP1(h)  (ssp_is_old(h) ? 0x090 : 0x0b0)
 #define HW_SSP_SDRESP2(h)  (ssp_is_old(h) ? 0x0a0 : 0x0c0)
@@ -96,6 +117,7 @@
 #define HW_SSP_STATUS(h)   (ssp_is_old(h) ? 0x0c0 : 0x100)
 #define  BM_SSP_STATUS_CARD_DETECT (1  28)
 #define  BM_SSP_STATUS_SDIO_IRQ(1  17)
+#define  BM_SSP_STATUS_FIFO_EMPTY  (1  5)
 
 #define BF_SSP(value, field)   (((value)  BP_SSP_##field)  BM_SSP_##field)
 
-- 
1.7.10.4


--
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 05/10 V2] mmc: spi: Pull out the SSP clock configuration function

2012-07-23 Thread Marek Vasut
Pull out the MMC clock configuration function and make it
into SSP clock configuration function, so it can be used by
the SPI driver too.

Signed-off-by: Marek Vasut ma...@denx.de
Cc: Attila Kinali att...@kinali.ch
Cc: Chris Ball c...@laptop.org
CC: Dong Aisheng b29...@freescale.com
Cc: Fabio Estevam fabio.este...@freescale.com
Cc: Grant Likely grant.lik...@secretlab.ca
Cc: Linux ARM kernel linux-arm-ker...@lists.infradead.org
Cc: Mark Brown broo...@opensource.wolfsonmicro.com
CC: Shawn Guo shawn@linaro.org
---
 drivers/clk/mxs/Makefile|2 +-
 drivers/clk/mxs/clk-ssp.c   |   62 +++
 drivers/mmc/host/mxs-mmc.c  |   39 +--
 include/linux/spi/mxs-spi.h |2 ++
 4 files changed, 66 insertions(+), 39 deletions(-)
 create mode 100644 drivers/clk/mxs/clk-ssp.c

V2: Add EXPORT_SYMBOL_GPL(mxs_ssp_set_clk_rate); to allow compiling as a module.
(Thanks to Attila Kinali).

diff --git a/drivers/clk/mxs/Makefile b/drivers/clk/mxs/Makefile
index 7bedeec..a6a2223 100644
--- a/drivers/clk/mxs/Makefile
+++ b/drivers/clk/mxs/Makefile
@@ -2,7 +2,7 @@
 # Makefile for mxs specific clk
 #
 
-obj-y += clk.o clk-pll.o clk-ref.o clk-div.o clk-frac.o
+obj-y += clk.o clk-pll.o clk-ref.o clk-div.o clk-frac.o clk-ssp.o
 
 obj-$(CONFIG_SOC_IMX23) += clk-imx23.o
 obj-$(CONFIG_SOC_IMX28) += clk-imx28.o
diff --git a/drivers/clk/mxs/clk-ssp.c b/drivers/clk/mxs/clk-ssp.c
new file mode 100644
index 000..af7bdbf
--- /dev/null
+++ b/drivers/clk/mxs/clk-ssp.c
@@ -0,0 +1,62 @@
+/*
+ * Copyright 2012 DENX Software Engineering, GmbH
+ *
+ * Pulled from code:
+ * Portions copyright (C) 2003 Russell King, PXA MMCI Driver
+ * Portions copyright (C) 2004-2005 Pierre Ossman, W83L51xD SD/MMC driver
+ *
+ * Copyright 2008 Embedded Alley Solutions, Inc.
+ * Copyright 2009-2011 Freescale Semiconductor, Inc.
+ *
+ * The code contained herein is licensed under the GNU General Public
+ * License. You may obtain a copy of the GNU General Public License
+ * Version 2 or later at the following locations:
+ *
+ * http://www.opensource.org/licenses/gpl-license.html
+ * http://www.gnu.org/copyleft/gpl.html
+ */
+
+#include linux/kernel.h
+#include linux/init.h
+#include linux/clk.h
+#include linux/module.h
+#include linux/device.h
+#include linux/io.h
+#include linux/spi/mxs-spi.h
+
+void mxs_ssp_set_clk_rate(struct mxs_ssp *ssp, unsigned int rate)
+{
+   unsigned int ssp_clk, ssp_sck;
+   u32 clock_divide, clock_rate;
+   u32 val;
+
+   ssp_clk = clk_get_rate(ssp-clk);
+
+   for (clock_divide = 2; clock_divide = 254; clock_divide += 2) {
+   clock_rate = DIV_ROUND_UP(ssp_clk, rate * clock_divide);
+   clock_rate = (clock_rate  0) ? clock_rate - 1 : 0;
+   if (clock_rate = 255)
+   break;
+   }
+
+   if (clock_divide  254) {
+   dev_err(ssp-dev,
+   %s: cannot set clock to %d\n, __func__, rate);
+   return;
+   }
+
+   ssp_sck = ssp_clk / clock_divide / (1 + clock_rate);
+
+   val = readl(ssp-base + HW_SSP_TIMING(ssp));
+   val = ~(BM_SSP_TIMING_CLOCK_DIVIDE | BM_SSP_TIMING_CLOCK_RATE);
+   val |= BF_SSP(clock_divide, TIMING_CLOCK_DIVIDE);
+   val |= BF_SSP(clock_rate, TIMING_CLOCK_RATE);
+   writel(val, ssp-base + HW_SSP_TIMING(ssp));
+
+   ssp-clk_rate = ssp_sck;
+
+   dev_dbg(ssp-dev,
+   %s: clock_divide %d, clock_rate %d, ssp_clk %d, rate_actual 
%d, rate_requested %d\n,
+   __func__, clock_divide, clock_rate, ssp_clk, ssp_sck, rate);
+}
+EXPORT_SYMBOL_GPL(mxs_ssp_set_clk_rate);
diff --git a/drivers/mmc/host/mxs-mmc.c b/drivers/mmc/host/mxs-mmc.c
index 7b85e03..0813340 100644
--- a/drivers/mmc/host/mxs-mmc.c
+++ b/drivers/mmc/host/mxs-mmc.c
@@ -501,43 +501,6 @@ static void mxs_mmc_request(struct mmc_host *mmc, struct 
mmc_request *mrq)
mxs_mmc_start_cmd(host, mrq-cmd);
 }
 
-static void mxs_mmc_set_clk_rate(struct mxs_mmc_host *host, unsigned int rate)
-{
-   struct mxs_ssp *ssp = host-ssp;
-   unsigned int ssp_clk, ssp_sck;
-   u32 clock_divide, clock_rate;
-   u32 val;
-
-   ssp_clk = clk_get_rate(ssp-clk);
-
-   for (clock_divide = 2; clock_divide = 254; clock_divide += 2) {
-   clock_rate = DIV_ROUND_UP(ssp_clk, rate * clock_divide);
-   clock_rate = (clock_rate  0) ? clock_rate - 1 : 0;
-   if (clock_rate = 255)
-   break;
-   }
-
-   if (clock_divide  254) {
-   dev_err(mmc_dev(host-mmc),
-   %s: cannot set clock to %d\n, __func__, rate);
-   return;
-   }
-
-   ssp_sck = ssp_clk / clock_divide / (1 + clock_rate);
-
-   val = readl(ssp-base + HW_SSP_TIMING(ssp));
-   val = ~(BM_SSP_TIMING_CLOCK_DIVIDE | BM_SSP_TIMING_CLOCK_RATE);
-   val |= BF_SSP(clock_divide, TIMING_CLOCK_DIVIDE);
-   val |= BF_SSP(clock_rate, 

[PATCH 07/10 RESEND] mmc: spi: Pull out common DMA parts from MXS MMC

2012-07-23 Thread Marek Vasut
These parts will be used by the MXS SPI driver too.

Signed-off-by: Marek Vasut ma...@denx.de
Cc: Attila Kinali att...@kinali.ch
Cc: Chris Ball c...@laptop.org
CC: Dong Aisheng b29...@freescale.com
Cc: Fabio Estevam fabio.este...@freescale.com
Cc: Grant Likely grant.lik...@secretlab.ca
Cc: Linux ARM kernel linux-arm-ker...@lists.infradead.org
Cc: Mark Brown broo...@opensource.wolfsonmicro.com
CC: Shawn Guo shawn@linaro.org
---
 drivers/mmc/host/mxs-mmc.c  |   88 +--
 drivers/spi/spi-mxs.c   |1 -
 include/linux/spi/mxs-spi.h |9 +
 3 files changed, 51 insertions(+), 47 deletions(-)

diff --git a/drivers/mmc/host/mxs-mmc.c b/drivers/mmc/host/mxs-mmc.c
index 0813340..4da9966 100644
--- a/drivers/mmc/host/mxs-mmc.c
+++ b/drivers/mmc/host/mxs-mmc.c
@@ -41,7 +41,6 @@
 #include linux/gpio.h
 #include linux/regulator/consumer.h
 #include linux/module.h
-#include linux/fsl/mxs-dma.h
 #include linux/pinctrl/consumer.h
 #include linux/stmp_device.h
 #include linux/mmc/mxs-mmc.h
@@ -69,13 +68,6 @@ struct mxs_mmc_host {
struct mmc_command  *cmd;
struct mmc_data *data;
 
-   int dma_channel;
-   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];
-
unsigned char   bus_width;
spinlock_t  lock;
int sdio_irq_en;
@@ -163,7 +155,7 @@ static void mxs_mmc_request_done(struct mxs_mmc_host *host)
 
if (data) {
dma_unmap_sg(mmc_dev(host-mmc), data-sg,
-data-sg_len, host-dma_dir);
+data-sg_len, ssp-dma_dir);
/*
 * If there was an error on any block, we mark all
 * data blocks as being in error.
@@ -232,6 +224,7 @@ static irqreturn_t mxs_mmc_irq_handler(int irq, void 
*dev_id)
 static struct dma_async_tx_descriptor *mxs_mmc_prep_dma(
struct mxs_mmc_host *host, unsigned long flags)
 {
+   struct mxs_ssp *ssp = host-ssp;
struct dma_async_tx_descriptor *desc;
struct mmc_data *data = host-data;
struct scatterlist * sgl;
@@ -240,24 +233,24 @@ static struct dma_async_tx_descriptor *mxs_mmc_prep_dma(
if (data) {
/* data */
dma_map_sg(mmc_dev(host-mmc), data-sg,
-  data-sg_len, host-dma_dir);
+  data-sg_len, ssp-dma_dir);
sgl = data-sg;
sg_len = data-sg_len;
} else {
/* pio */
-   sgl = (struct scatterlist *) host-ssp_pio_words;
+   sgl = (struct scatterlist *) ssp-ssp_pio_words;
sg_len = SSP_PIO_NUM;
}
 
-   desc = dmaengine_prep_slave_sg(host-dmach,
-   sgl, sg_len, host-slave_dirn, flags);
+   desc = dmaengine_prep_slave_sg(ssp-dmach,
+   sgl, sg_len, ssp-slave_dirn, flags);
if (desc) {
desc-callback = mxs_mmc_dma_irq_callback;
desc-callback_param = host;
} else {
if (data)
dma_unmap_sg(mmc_dev(host-mmc), data-sg,
-data-sg_len, host-dma_dir);
+data-sg_len, ssp-dma_dir);
}
 
return desc;
@@ -265,6 +258,7 @@ static struct dma_async_tx_descriptor *mxs_mmc_prep_dma(
 
 static void mxs_mmc_bc(struct mxs_mmc_host *host)
 {
+   struct mxs_ssp *ssp = host-ssp;
struct mmc_command *cmd = host-cmd;
struct dma_async_tx_descriptor *desc;
u32 ctrl0, cmd0, cmd1;
@@ -278,17 +272,17 @@ static void mxs_mmc_bc(struct mxs_mmc_host *host)
cmd0 |= BM_SSP_CMD0_CONT_CLKING_EN | BM_SSP_CMD0_SLOW_CLKING_EN;
}
 
-   host-ssp_pio_words[0] = ctrl0;
-   host-ssp_pio_words[1] = cmd0;
-   host-ssp_pio_words[2] = cmd1;
-   host-dma_dir = DMA_NONE;
-   host-slave_dirn = DMA_TRANS_NONE;
+   ssp-ssp_pio_words[0] = ctrl0;
+   ssp-ssp_pio_words[1] = cmd0;
+   ssp-ssp_pio_words[2] = cmd1;
+   ssp-dma_dir = DMA_NONE;
+   ssp-slave_dirn = DMA_TRANS_NONE;
desc = mxs_mmc_prep_dma(host, DMA_CTRL_ACK);
if (!desc)
goto out;
 
dmaengine_submit(desc);
-   dma_async_issue_pending(host-dmach);
+   dma_async_issue_pending(ssp-dmach);
return;
 
 out:
@@ -298,6 +292,7 @@ out:
 
 static void mxs_mmc_ac(struct mxs_mmc_host *host)
 {
+   struct mxs_ssp *ssp = host-ssp;
struct mmc_command *cmd = host-cmd;
struct dma_async_tx_descriptor *desc;
u32 ignore_crc, get_resp, long_resp;
@@ -319,17 +314,17 @@ static 

[PATCH 10/10 RESEND] ARM: mx28: Add SPI pinmux into imx28.dtsi

2012-07-23 Thread Marek Vasut
Signed-off-by: Marek Vasut ma...@denx.de
Cc: Attila Kinali att...@kinali.ch
Cc: Chris Ball c...@laptop.org
CC: Dong Aisheng b29...@freescale.com
Cc: Fabio Estevam fabio.este...@freescale.com
Cc: Grant Likely grant.lik...@secretlab.ca
Cc: Linux ARM kernel linux-arm-ker...@lists.infradead.org
Cc: Mark Brown broo...@opensource.wolfsonmicro.com
CC: Shawn Guo shawn@linaro.org
---
 arch/arm/boot/dts/imx28.dtsi |   39 +++
 1 file changed, 39 insertions(+)

diff --git a/arch/arm/boot/dts/imx28.dtsi b/arch/arm/boot/dts/imx28.dtsi
index badc76a..4a0f12c 100644
--- a/arch/arm/boot/dts/imx28.dtsi
+++ b/arch/arm/boot/dts/imx28.dtsi
@@ -507,6 +507,45 @@
fsl,voltage = 1;
fsl,pull-up = 0;
};
+
+   spi0_pins_a: spi0@0 {
+   reg = 0;
+   fsl,pinmux-ids =
+   0x2000 0x2010 0x2020 0x2030
+   0x2040 0x2050 0x2060 0x2070
+   0x2080 0x2090 0x20a0;
+   fsl,drive-strength = 1;
+   fsl,voltage = 1;
+   fsl,pull-up = 1;
+   };
+
+   spi1_pins_a: spi1@0 {
+   reg = 0;
+   fsl,pinmux-ids =
+   0x20c0 0x20d0 0x20e0 0x20f0;
+   fsl,drive-strength = 1;
+   fsl,voltage = 1;
+   fsl,pull-up = 1;
+   };
+
+   spi2_pins_a: spi2@0 {
+   reg = 0;
+   fsl,pinmux-ids =
+   0x2100 0x2110 0x2120
+   0x2130 0x2140 0x2150;
+   fsl,drive-strength = 1;
+   fsl,voltage = 1;
+   fsl,pull-up = 1;
+   };
+
+   spi3_pins_a: spi3@0 {
+   reg = 0;
+   fsl,pinmux-ids =
+   0x2180 0x2190 0x21a0 0x21b0;
+   fsl,drive-strength = 1;
+   fsl,voltage = 1;
+   fsl,pull-up = 1;
+   };
};
 
digctl@8001c000 {
-- 
1.7.10.4


--
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


Téléchargez le guide des radiateurs à inertie

2012-07-23 Thread Meilleur Choix par Duano
Pour voir le message, veuillez utiliser un lecteur de mail compatible HTML

Lien miroir : 
http://m10-fr.com/mc10_m/YT0xMyZiPTE2NjI0JmM9NDgzNjEyJmQ9MjAxMi0wNy0yNCAwMDoxMDowMSZlPTEmaD0xNjYyMyZmPTE2NjI0Jmc9MTY2MjQ=

Lien de désinscription : 
http://m10-fr.com/mc10_unsub/YT0xMyZiPTE2NjI0JmM9NDgzNjEyJmQ9MjAxMi0wNy0yNCAwMDoxMDowMSZlPTEmaD0xNjYyMyZmPTE2NjI0Jmc9MTY2MjQ=


--
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