summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Sevakis <jethead71@rockbox.org>2011-12-26 15:30:51 +0000
committerMichael Sevakis <jethead71@rockbox.org>2011-12-26 15:30:51 +0000
commitd56daa1f7e4e9d6e9fc16e65864b671971708009 (patch)
treeafafa546f315c75b1372fddf5838c225166d3bdc
parent0726b17667e55455e8af868c687fe11286cccaa2 (diff)
i.MX31: Silly little change to enable/disable a SPI
Unify spi_enable/disable_module into one spi_enable_module call for API consistency's sake with I2C driver. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@31441 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--firmware/target/arm/imx31/gigabeat-s/lcd-gigabeat-s.c9
-rw-r--r--firmware/target/arm/imx31/mc13783-imx31.c4
-rw-r--r--firmware/target/arm/imx31/spi-imx31.c59
-rw-r--r--firmware/target/arm/imx31/spi-imx31.h7
4 files changed, 34 insertions, 45 deletions
diff --git a/firmware/target/arm/imx31/gigabeat-s/lcd-gigabeat-s.c b/firmware/target/arm/imx31/gigabeat-s/lcd-gigabeat-s.c
index f0a2764851..78d8ba16c3 100644
--- a/firmware/target/arm/imx31/gigabeat-s/lcd-gigabeat-s.c
+++ b/firmware/target/arm/imx31/gigabeat-s/lcd-gigabeat-s.c
@@ -116,14 +116,7 @@ static void lcd_write_reg(unsigned reg, unsigned val)
static void lcd_enable_interface(bool enable)
{
- if (enable)
- {
- spi_enable_module(&lcd_spi_node);
- }
- else
- {
- spi_disable_module(&lcd_spi_node);
- }
+ spi_enable_module(&lcd_spi_node, enable);
}
static void lcd_set_power(bool powered)
diff --git a/firmware/target/arm/imx31/mc13783-imx31.c b/firmware/target/arm/imx31/mc13783-imx31.c
index 268c33a549..94021ac049 100644
--- a/firmware/target/arm/imx31/mc13783-imx31.c
+++ b/firmware/target/arm/imx31/mc13783-imx31.c
@@ -139,7 +139,7 @@ void INIT_ATTR mc13783_init(void)
semaphore_init(&mc13783_svc_wake, 1, 0);
/* Enable the PMIC SPI module */
- spi_enable_module(&mc13783_spi);
+ spi_enable_module(&mc13783_spi, true);
/* Mask any PMIC interrupts for now - modules will enable them as
* required */
@@ -164,7 +164,7 @@ void mc13783_close(void)
mc13783_thread_id = 0;
semaphore_release(&mc13783_svc_wake);
thread_wait(thread_id);
- spi_disable_module(&mc13783_spi);
+ spi_enable_module(&mc13783_spi, false);
}
bool mc13783_enable_event(enum mc13783_event_ids id)
diff --git a/firmware/target/arm/imx31/spi-imx31.c b/firmware/target/arm/imx31/spi-imx31.c
index ea3d2f8d77..076ce7cd7b 100644
--- a/firmware/target/arm/imx31/spi-imx31.c
+++ b/firmware/target/arm/imx31/spi-imx31.c
@@ -55,7 +55,7 @@ static struct spi_module_desc
const struct spi_node *last_node; /* Last node used for module */
void (* const handler)(void); /* Interrupt handler */
int rxcount; /* Independent copy of txcount */
- int8_t enab; /* Enable count */
+ int8_t enable; /* Enable count */
int8_t byte_size; /* Size of transfers in bytes */
const int8_t cg; /* Clock-gating value */
const int8_t ints; /* AVIC vector number */
@@ -102,7 +102,7 @@ static bool spi_set_context(struct spi_module_desc *desc,
const struct spi_node * const node = xfer->node;
volatile unsigned long * const base = desc->base;
- if (desc->enab == 0)
+ if (desc->enable == 0)
return false;
if (node == desc->last_node)
@@ -354,43 +354,42 @@ void INIT_ATTR spi_init(void)
}
}
-/* Enable the specified module for the node */
-void spi_enable_module(const struct spi_node *node)
+/* Enable or disable the specified module for the node */
+void spi_enable_module(const struct spi_node *node, bool enable)
{
struct spi_module_desc * const desc = &spi_descs[node->num];
- if (++desc->enab == 1)
+ if (enable)
{
- /* Enable clock-gating register */
- ccm_module_clock_gating(desc->cg, CGM_ON_RUN_WAIT);
- /* Reset */
- spi_reset(desc);
- desc->last_node = NULL;
- /* Enable interrupt at controller level */
- avic_enable_int(desc->ints, INT_TYPE_IRQ, INT_PRIO_DEFAULT,
- desc->handler);
+ if (++desc->enable == 1)
+ {
+ /* Enable clock-gating register */
+ ccm_module_clock_gating(desc->cg, CGM_ON_RUN_WAIT);
+ /* Reset */
+ spi_reset(desc);
+ desc->last_node = NULL;
+ /* Enable interrupt at controller level */
+ avic_enable_int(desc->ints, INT_TYPE_IRQ, INT_PRIO_DEFAULT,
+ desc->handler);
+ }
}
-}
-
-/* Disable the specified module for the node */
-void spi_disable_module(const struct spi_node *node)
-{
- struct spi_module_desc * const desc = &spi_descs[node->num];
-
- if (desc->enab > 0 && --desc->enab == 0)
+ else
{
- /* Last enable for this module */
- /* Wait for outstanding transactions */
- while (*(void ** volatile)&desc->head != NULL);
+ if (desc->enable > 0 && --desc->enable == 0)
+ {
+ /* Last enable for this module */
+ /* Wait for outstanding transactions */
+ while (*(void ** volatile)&desc->head != NULL);
- /* Disable interrupt at controller level */
- avic_disable_int(desc->ints);
+ /* Disable interrupt at controller level */
+ avic_disable_int(desc->ints);
- /* Disable interface */
- desc->base[CONREG] &= ~CSPI_CONREG_EN;
+ /* Disable interface */
+ desc->base[CONREG] &= ~CSPI_CONREG_EN;
- /* Disable interface clock */
- ccm_module_clock_gating(desc->cg, CGM_OFF);
+ /* Disable interface clock */
+ ccm_module_clock_gating(desc->cg, CGM_OFF);
+ }
}
}
diff --git a/firmware/target/arm/imx31/spi-imx31.h b/firmware/target/arm/imx31/spi-imx31.h
index 35b7d514cf..215093733b 100644
--- a/firmware/target/arm/imx31/spi-imx31.h
+++ b/firmware/target/arm/imx31/spi-imx31.h
@@ -74,11 +74,8 @@ struct spi_transfer_desc
/* One-time init of SPI driver */
void spi_init(void);
-/* Enable the specified module for the node */
-void spi_enable_module(const struct spi_node *node);
-
-/* Disabled the specified module for the node */
-void spi_disable_module(const struct spi_node *node);
+/* Enable or disable the specified module for the node */
+void spi_enable_module(const struct spi_node *node, bool enable);
/* Send and/or receive data on the specified node (asychronous) */
bool spi_transfer(struct spi_transfer_desc *xfer);