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
This commit is contained in:
Michael Sevakis 2011-12-26 15:30:51 +00:00
parent 0726b17667
commit d56daa1f7e
4 changed files with 34 additions and 45 deletions

View file

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

View file

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

View file

@ -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);
}
}
}

View file

@ -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);