summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlejandro Gonzalez <alex.gonzalez@digi.com>2010-05-27 10:30:55 +0200
committerAlejandro Gonzalez <alex.gonzalez@digi.com>2010-05-27 10:32:44 +0200
commit28e675ccc41df417f049f3129519eb034801db56 (patch)
treeb4f7c801fef5ae19583ef9dd358b41b3b8f4f9ad
parente67b7b69ff370aca48d898c2f5c2d387360e372a (diff)
ENGR00122465: Applying from 1004 release in FSL compass site.
They are not am formatted. ENGR00122465-1-spi-polling ENGR00122465-2-spi-poll-sync Signed-off-by: Alejandro Gonzalez <alex.gonzalez@digi.com>
-rw-r--r--drivers/mxc/pmic/core/pmic.h5
-rw-r--r--drivers/spi/mxc_spi.c7
2 files changed, 11 insertions, 1 deletions
diff --git a/drivers/mxc/pmic/core/pmic.h b/drivers/mxc/pmic/core/pmic.h
index 770fbb72a044..964c44a06bc1 100644
--- a/drivers/mxc/pmic/core/pmic.h
+++ b/drivers/mxc/pmic/core/pmic.h
@@ -48,6 +48,7 @@ struct mxc_pmic {
*
* @return Returns 0 on success -1 on failure.
*/
+int mxc_spi_poll_transfer(struct spi_device *spi, struct spi_transfer *t);
static inline int spi_rw(struct spi_device *spi, u8 * buf, size_t len)
{
struct spi_transfer t = {
@@ -57,6 +58,9 @@ static inline int spi_rw(struct spi_device *spi, u8 * buf, size_t len)
.cs_change = 0,
.delay_usecs = 0,
};
+ mxc_spi_poll_transfer(spi, &t);
+ return 0;
+#if 0
struct spi_message m;
spi_message_init(&m);
@@ -64,6 +68,7 @@ static inline int spi_rw(struct spi_device *spi, u8 * buf, size_t len)
if (spi_sync(spi, &m) != 0 || m.status != 0)
return PMIC_ERROR;
return (len - m.actual_length);
+#endif
}
/*!
diff --git a/drivers/spi/mxc_spi.c b/drivers/spi/mxc_spi.c
index 002e7c3ffa06..cfe40a4526a7 100644
--- a/drivers/spi/mxc_spi.c
+++ b/drivers/spi/mxc_spi.c
@@ -780,6 +780,7 @@ static int mxc_spi_setup_transfer(struct spi_device *spi, struct spi_transfer *t
return 0;
}
+static DECLARE_MUTEX(poll_mutex);
/*!
* This function is called when the data has to transfer from/to the
* current SPI device in poll mode
@@ -798,6 +799,8 @@ int mxc_spi_poll_transfer(struct spi_device *spi, struct spi_transfer *t)
u32 fifo_size;
int chipselect_status;
+ down(&poll_mutex);
+
mxc_spi_chipselect(spi, BITBANG_CS_ACTIVE);
/* Get the master controller driver data from spi device's master */
@@ -826,7 +829,7 @@ int mxc_spi_poll_transfer(struct spi_device *spi, struct spi_transfer *t)
while ((((status = __raw_readl(master_drv_data->test_addr)) &
master_drv_data->spi_ver_def->rx_cnt_mask) >> master_drv_data->
- spi_ver_def->rx_cnt_off) != count) ;
+ spi_ver_def->rx_cnt_off) != count);
for (i = 0; i < count; i++) {
rx_tmp = __raw_readl(master_drv_data->base + MXC_CSPIRXDATA);
@@ -839,6 +842,7 @@ int mxc_spi_poll_transfer(struct spi_device *spi, struct spi_transfer *t)
chipselect_status,
(spi->chip_select &
MXC_CSPICTRL_CSMASK) + 1);
+ up(&poll_mutex);
return 0;
}
@@ -1287,6 +1291,7 @@ static struct platform_driver mxc_spi_driver = {
static int __init mxc_spi_init(void)
{
pr_debug("Registering the SPI Controller Driver\n");
+ sema_init(&poll_mutex, 1);
return platform_driver_register(&mxc_spi_driver);
}