From 28e675ccc41df417f049f3129519eb034801db56 Mon Sep 17 00:00:00 2001 From: Alejandro Gonzalez Date: Thu, 27 May 2010 10:30:55 +0200 Subject: 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 --- drivers/mxc/pmic/core/pmic.h | 5 +++++ drivers/spi/mxc_spi.c | 7 ++++++- 2 files changed, 11 insertions(+), 1 deletion(-) 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); } -- cgit v1.2.3