forked from len0rd/rockbox
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:
parent
0726b17667
commit
d56daa1f7e
4 changed files with 34 additions and 45 deletions
|
|
@ -116,14 +116,7 @@ static void lcd_write_reg(unsigned reg, unsigned val)
|
||||||
|
|
||||||
static void lcd_enable_interface(bool enable)
|
static void lcd_enable_interface(bool enable)
|
||||||
{
|
{
|
||||||
if (enable)
|
spi_enable_module(&lcd_spi_node, enable);
|
||||||
{
|
|
||||||
spi_enable_module(&lcd_spi_node);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
spi_disable_module(&lcd_spi_node);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void lcd_set_power(bool powered)
|
static void lcd_set_power(bool powered)
|
||||||
|
|
|
||||||
|
|
@ -139,7 +139,7 @@ void INIT_ATTR mc13783_init(void)
|
||||||
semaphore_init(&mc13783_svc_wake, 1, 0);
|
semaphore_init(&mc13783_svc_wake, 1, 0);
|
||||||
|
|
||||||
/* Enable the PMIC SPI module */
|
/* 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
|
/* Mask any PMIC interrupts for now - modules will enable them as
|
||||||
* required */
|
* required */
|
||||||
|
|
@ -164,7 +164,7 @@ void mc13783_close(void)
|
||||||
mc13783_thread_id = 0;
|
mc13783_thread_id = 0;
|
||||||
semaphore_release(&mc13783_svc_wake);
|
semaphore_release(&mc13783_svc_wake);
|
||||||
thread_wait(thread_id);
|
thread_wait(thread_id);
|
||||||
spi_disable_module(&mc13783_spi);
|
spi_enable_module(&mc13783_spi, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool mc13783_enable_event(enum mc13783_event_ids id)
|
bool mc13783_enable_event(enum mc13783_event_ids id)
|
||||||
|
|
|
||||||
|
|
@ -55,7 +55,7 @@ static struct spi_module_desc
|
||||||
const struct spi_node *last_node; /* Last node used for module */
|
const struct spi_node *last_node; /* Last node used for module */
|
||||||
void (* const handler)(void); /* Interrupt handler */
|
void (* const handler)(void); /* Interrupt handler */
|
||||||
int rxcount; /* Independent copy of txcount */
|
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 */
|
int8_t byte_size; /* Size of transfers in bytes */
|
||||||
const int8_t cg; /* Clock-gating value */
|
const int8_t cg; /* Clock-gating value */
|
||||||
const int8_t ints; /* AVIC vector number */
|
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;
|
const struct spi_node * const node = xfer->node;
|
||||||
volatile unsigned long * const base = desc->base;
|
volatile unsigned long * const base = desc->base;
|
||||||
|
|
||||||
if (desc->enab == 0)
|
if (desc->enable == 0)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (node == desc->last_node)
|
if (node == desc->last_node)
|
||||||
|
|
@ -354,43 +354,42 @@ void INIT_ATTR spi_init(void)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Enable the specified module for the node */
|
/* Enable or disable the specified module for the node */
|
||||||
void spi_enable_module(const struct spi_node *node)
|
void spi_enable_module(const struct spi_node *node, bool enable)
|
||||||
{
|
{
|
||||||
struct spi_module_desc * const desc = &spi_descs[node->num];
|
struct spi_module_desc * const desc = &spi_descs[node->num];
|
||||||
|
|
||||||
if (++desc->enab == 1)
|
if (enable)
|
||||||
{
|
{
|
||||||
/* Enable clock-gating register */
|
if (++desc->enable == 1)
|
||||||
ccm_module_clock_gating(desc->cg, CGM_ON_RUN_WAIT);
|
{
|
||||||
/* Reset */
|
/* Enable clock-gating register */
|
||||||
spi_reset(desc);
|
ccm_module_clock_gating(desc->cg, CGM_ON_RUN_WAIT);
|
||||||
desc->last_node = NULL;
|
/* Reset */
|
||||||
/* Enable interrupt at controller level */
|
spi_reset(desc);
|
||||||
avic_enable_int(desc->ints, INT_TYPE_IRQ, INT_PRIO_DEFAULT,
|
desc->last_node = NULL;
|
||||||
desc->handler);
|
/* Enable interrupt at controller level */
|
||||||
|
avic_enable_int(desc->ints, INT_TYPE_IRQ, INT_PRIO_DEFAULT,
|
||||||
|
desc->handler);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
else
|
||||||
|
|
||||||
/* 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)
|
|
||||||
{
|
{
|
||||||
/* Last enable for this module */
|
if (desc->enable > 0 && --desc->enable == 0)
|
||||||
/* Wait for outstanding transactions */
|
{
|
||||||
while (*(void ** volatile)&desc->head != NULL);
|
/* Last enable for this module */
|
||||||
|
/* Wait for outstanding transactions */
|
||||||
|
while (*(void ** volatile)&desc->head != NULL);
|
||||||
|
|
||||||
/* Disable interrupt at controller level */
|
/* Disable interrupt at controller level */
|
||||||
avic_disable_int(desc->ints);
|
avic_disable_int(desc->ints);
|
||||||
|
|
||||||
/* Disable interface */
|
/* Disable interface */
|
||||||
desc->base[CONREG] &= ~CSPI_CONREG_EN;
|
desc->base[CONREG] &= ~CSPI_CONREG_EN;
|
||||||
|
|
||||||
/* Disable interface clock */
|
/* Disable interface clock */
|
||||||
ccm_module_clock_gating(desc->cg, CGM_OFF);
|
ccm_module_clock_gating(desc->cg, CGM_OFF);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -74,11 +74,8 @@ struct spi_transfer_desc
|
||||||
/* One-time init of SPI driver */
|
/* One-time init of SPI driver */
|
||||||
void spi_init(void);
|
void spi_init(void);
|
||||||
|
|
||||||
/* Enable the specified module for the node */
|
/* Enable or disable the specified module for the node */
|
||||||
void spi_enable_module(const struct spi_node *node);
|
void spi_enable_module(const struct spi_node *node, bool enable);
|
||||||
|
|
||||||
/* Disabled the specified module for the node */
|
|
||||||
void spi_disable_module(const struct spi_node *node);
|
|
||||||
|
|
||||||
/* Send and/or receive data on the specified node (asychronous) */
|
/* Send and/or receive data on the specified node (asychronous) */
|
||||||
bool spi_transfer(struct spi_transfer_desc *xfer);
|
bool spi_transfer(struct spi_transfer_desc *xfer);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue