nios2: Fix outx/writex parameter order in io.h
The outx/writex macros were using writex(addr, val) rather than the standard writex(val, addr), resulting in incompatibilty with architecture independent components. This change set uses standard parameter order. Signed-off-by: Scott McNutt <smcnutt@psyent.com>
This commit is contained in:
parent
64da04d24e
commit
3ea0037f23
|
@ -122,12 +122,12 @@ int flash_erase (flash_info_t * info, int s_first, int s_last)
|
||||||
for (sect = s_first; sect <= s_last; sect++) {
|
for (sect = s_first; sect <= s_last; sect++) {
|
||||||
if (info->protect[sect] == 0) { /* not protected */
|
if (info->protect[sect] == 0) { /* not protected */
|
||||||
addr2 = (unsigned char *) info->start[sect];
|
addr2 = (unsigned char *) info->start[sect];
|
||||||
writeb (addr, 0xaa);
|
writeb (0xaa, addr);
|
||||||
writeb (addr, 0x55);
|
writeb (0x55, addr);
|
||||||
writeb (addr, 0x80);
|
writeb (0x80, addr);
|
||||||
writeb (addr, 0xaa);
|
writeb (0xaa, addr);
|
||||||
writeb (addr, 0x55);
|
writeb (0x55, addr);
|
||||||
writeb (addr2, 0x30);
|
writeb (0x30, addr2);
|
||||||
/* Now just wait for 0xff & provide some user
|
/* Now just wait for 0xff & provide some user
|
||||||
* feedback while we wait.
|
* feedback while we wait.
|
||||||
*/
|
*/
|
||||||
|
@ -169,9 +169,9 @@ int write_buff (flash_info_t * info, uchar * src, ulong addr, ulong cnt)
|
||||||
return (2);
|
return (2);
|
||||||
}
|
}
|
||||||
|
|
||||||
writeb (cmd, 0xaa);
|
writeb (0xaa, cmd);
|
||||||
writeb (cmd, 0x55);
|
writeb (0x55, cmd);
|
||||||
writeb (cmd, 0xa0);
|
writeb (0xa0, cmd);
|
||||||
writeb (dst, b);
|
writeb (dst, b);
|
||||||
|
|
||||||
/* Verify write */
|
/* Verify write */
|
||||||
|
|
|
@ -39,7 +39,7 @@ void __led_init (led_id_t mask, int state)
|
||||||
val &= ~mask;
|
val &= ~mask;
|
||||||
else
|
else
|
||||||
val |= mask;
|
val |= mask;
|
||||||
writel (&pio->data, val);
|
writel (val, &pio->data);
|
||||||
}
|
}
|
||||||
|
|
||||||
void __led_set (led_id_t mask, int state)
|
void __led_set (led_id_t mask, int state)
|
||||||
|
@ -50,7 +50,7 @@ void __led_set (led_id_t mask, int state)
|
||||||
val &= ~mask;
|
val &= ~mask;
|
||||||
else
|
else
|
||||||
val |= mask;
|
val |= mask;
|
||||||
writel (&pio->data, val);
|
writel (val, &pio->data);
|
||||||
}
|
}
|
||||||
|
|
||||||
void __led_toggle (led_id_t mask)
|
void __led_toggle (led_id_t mask)
|
||||||
|
@ -58,5 +58,5 @@ void __led_toggle (led_id_t mask)
|
||||||
nios_pio_t *pio = (nios_pio_t *)CONFIG_SYS_LEDPIO_ADDR;
|
nios_pio_t *pio = (nios_pio_t *)CONFIG_SYS_LEDPIO_ADDR;
|
||||||
|
|
||||||
val ^= mask;
|
val ^= mask;
|
||||||
writel (&pio->data, val);
|
writel (val, &pio->data);
|
||||||
}
|
}
|
||||||
|
|
|
@ -122,12 +122,12 @@ int flash_erase (flash_info_t * info, int s_first, int s_last)
|
||||||
for (sect = s_first; sect <= s_last; sect++) {
|
for (sect = s_first; sect <= s_last; sect++) {
|
||||||
if (info->protect[sect] == 0) { /* not protected */
|
if (info->protect[sect] == 0) { /* not protected */
|
||||||
addr2 = (unsigned char *) info->start[sect];
|
addr2 = (unsigned char *) info->start[sect];
|
||||||
writeb (addr, 0xaa);
|
writeb (0xaa, addr);
|
||||||
writeb (addr, 0x55);
|
writeb (0x55, addr);
|
||||||
writeb (addr, 0x80);
|
writeb (0x80, addr);
|
||||||
writeb (addr, 0xaa);
|
writeb (0xaa, addr);
|
||||||
writeb (addr, 0x55);
|
writeb (0x55, addr);
|
||||||
writeb (addr2, 0x30);
|
writeb (0x30, addr2);
|
||||||
/* Now just wait for 0xff & provide some user
|
/* Now just wait for 0xff & provide some user
|
||||||
* feedback while we wait.
|
* feedback while we wait.
|
||||||
*/
|
*/
|
||||||
|
@ -169,9 +169,9 @@ int write_buff (flash_info_t * info, uchar * src, ulong addr, ulong cnt)
|
||||||
return (2);
|
return (2);
|
||||||
}
|
}
|
||||||
|
|
||||||
writeb (cmd, 0xaa);
|
writeb (0xaa, cmd);
|
||||||
writeb (cmd, 0x55);
|
writeb (0x55, cmd);
|
||||||
writeb (cmd, 0xa0);
|
writeb (0xa0, cmd);
|
||||||
writeb (dst, b);
|
writeb (dst, b);
|
||||||
|
|
||||||
/* Verify write */
|
/* Verify write */
|
||||||
|
|
|
@ -39,7 +39,7 @@ void __led_init (led_id_t mask, int state)
|
||||||
val &= ~mask;
|
val &= ~mask;
|
||||||
else
|
else
|
||||||
val |= mask;
|
val |= mask;
|
||||||
writel (&pio->data, val);
|
writel (val, &pio->data);
|
||||||
}
|
}
|
||||||
|
|
||||||
void __led_set (led_id_t mask, int state)
|
void __led_set (led_id_t mask, int state)
|
||||||
|
@ -50,7 +50,7 @@ void __led_set (led_id_t mask, int state)
|
||||||
val &= ~mask;
|
val &= ~mask;
|
||||||
else
|
else
|
||||||
val |= mask;
|
val |= mask;
|
||||||
writel (&pio->data, val);
|
writel (val, &pio->data);
|
||||||
}
|
}
|
||||||
|
|
||||||
void __led_toggle (led_id_t mask)
|
void __led_toggle (led_id_t mask)
|
||||||
|
@ -58,5 +58,5 @@ void __led_toggle (led_id_t mask)
|
||||||
nios_pio_t *pio = (nios_pio_t *)CONFIG_SYS_LEDPIO_ADDR;
|
nios_pio_t *pio = (nios_pio_t *)CONFIG_SYS_LEDPIO_ADDR;
|
||||||
|
|
||||||
val ^= mask;
|
val ^= mask;
|
||||||
writel (&pio->data, val);
|
writel (val, &pio->data);
|
||||||
}
|
}
|
||||||
|
|
|
@ -85,7 +85,7 @@ static int epcs_cs (int assert)
|
||||||
|
|
||||||
if (assert) {
|
if (assert) {
|
||||||
tmp = readl (&epcs->control);
|
tmp = readl (&epcs->control);
|
||||||
writel (&epcs->control, tmp | NIOS_SPI_SSO);
|
writel (tmp | NIOS_SPI_SSO, &epcs->control);
|
||||||
} else {
|
} else {
|
||||||
/* Let all bits shift out */
|
/* Let all bits shift out */
|
||||||
start = get_timer (0);
|
start = get_timer (0);
|
||||||
|
@ -93,7 +93,7 @@ static int epcs_cs (int assert)
|
||||||
if (get_timer (start) > EPCS_TIMEOUT)
|
if (get_timer (start) > EPCS_TIMEOUT)
|
||||||
return (-1);
|
return (-1);
|
||||||
tmp = readl (&epcs->control);
|
tmp = readl (&epcs->control);
|
||||||
writel (&epcs->control, tmp & ~NIOS_SPI_SSO);
|
writel (tmp & ~NIOS_SPI_SSO, &epcs->control);
|
||||||
}
|
}
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
@ -106,7 +106,7 @@ static int epcs_tx (unsigned char c)
|
||||||
while ((readl (&epcs->status) & NIOS_SPI_TRDY) == 0)
|
while ((readl (&epcs->status) & NIOS_SPI_TRDY) == 0)
|
||||||
if (get_timer (start) > EPCS_TIMEOUT)
|
if (get_timer (start) > EPCS_TIMEOUT)
|
||||||
return (-1);
|
return (-1);
|
||||||
writel (&epcs->txdata, c);
|
writel (c, &epcs->txdata);
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -81,7 +81,7 @@ void tmr_isr (void *arg)
|
||||||
/* Interrupt is cleared by writing anything to the
|
/* Interrupt is cleared by writing anything to the
|
||||||
* status register.
|
* status register.
|
||||||
*/
|
*/
|
||||||
writel (&tmr->status, 0);
|
writel (0, &tmr->status);
|
||||||
timestamp += CONFIG_SYS_NIOS_TMRMS;
|
timestamp += CONFIG_SYS_NIOS_TMRMS;
|
||||||
#ifdef CONFIG_STATUS_LED
|
#ifdef CONFIG_STATUS_LED
|
||||||
status_led_tick(timestamp);
|
status_led_tick(timestamp);
|
||||||
|
@ -92,16 +92,16 @@ static void tmr_init (void)
|
||||||
{
|
{
|
||||||
nios_timer_t *tmr =(nios_timer_t *)CONFIG_SYS_NIOS_TMRBASE;
|
nios_timer_t *tmr =(nios_timer_t *)CONFIG_SYS_NIOS_TMRBASE;
|
||||||
|
|
||||||
writel (&tmr->status, 0);
|
writel (0, &tmr->status);
|
||||||
writel (&tmr->control, 0);
|
writel (0, &tmr->control);
|
||||||
writel (&tmr->control, NIOS_TIMER_STOP);
|
writel (NIOS_TIMER_STOP, &tmr->control);
|
||||||
|
|
||||||
#if defined(CONFIG_SYS_NIOS_TMRCNT)
|
#if defined(CONFIG_SYS_NIOS_TMRCNT)
|
||||||
writel (&tmr->periodl, CONFIG_SYS_NIOS_TMRCNT & 0xffff);
|
writel (CONFIG_SYS_NIOS_TMRCNT & 0xffff, &tmr->periodl);
|
||||||
writel (&tmr->periodh, (CONFIG_SYS_NIOS_TMRCNT >> 16) & 0xffff);
|
writel ((CONFIG_SYS_NIOS_TMRCNT >> 16) & 0xffff, &tmr->periodh);
|
||||||
#endif
|
#endif
|
||||||
writel (&tmr->control, NIOS_TIMER_ITO | NIOS_TIMER_CONT |
|
writel (NIOS_TIMER_ITO | NIOS_TIMER_CONT | NIOS_TIMER_START,
|
||||||
NIOS_TIMER_START );
|
&tmr->control);
|
||||||
irq_install_handler (CONFIG_SYS_NIOS_TMRIRQ, tmr_isr, (void *)tmr);
|
irq_install_handler (CONFIG_SYS_NIOS_TMRIRQ, tmr_isr, (void *)tmr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -40,7 +40,7 @@ void serial_putc (char c)
|
||||||
{
|
{
|
||||||
while (NIOS_JTAG_WSPACE ( readl (&jtag->control)) == 0)
|
while (NIOS_JTAG_WSPACE ( readl (&jtag->control)) == 0)
|
||||||
WATCHDOG_RESET ();
|
WATCHDOG_RESET ();
|
||||||
writel (&jtag->data, (unsigned char)c);
|
writel ((unsigned char)c, &jtag->data);
|
||||||
}
|
}
|
||||||
|
|
||||||
void serial_puts (const char *s)
|
void serial_puts (const char *s)
|
||||||
|
|
|
@ -50,7 +50,7 @@ void serial_setbrg (void)
|
||||||
unsigned div;
|
unsigned div;
|
||||||
|
|
||||||
div = (CONFIG_SYS_CLK_FREQ/gd->baudrate)-1;
|
div = (CONFIG_SYS_CLK_FREQ/gd->baudrate)-1;
|
||||||
writel (&uart->divisor,div);
|
writel (div, &uart->divisor);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -71,7 +71,7 @@ void serial_putc (char c)
|
||||||
serial_putc ('\r');
|
serial_putc ('\r');
|
||||||
while ((readl (&uart->status) & NIOS_UART_TRDY) == 0)
|
while ((readl (&uart->status) & NIOS_UART_TRDY) == 0)
|
||||||
WATCHDOG_RESET ();
|
WATCHDOG_RESET ();
|
||||||
writel (&uart->txdata,(unsigned char)c);
|
writel ((unsigned char)c, &uart->txdata);
|
||||||
}
|
}
|
||||||
|
|
||||||
void serial_puts (const char *s)
|
void serial_puts (const char *s)
|
||||||
|
|
|
@ -61,7 +61,7 @@ void serial_setbrg (void)
|
||||||
((unsigned)CONFIG_SYS_CLK_FREQ >> k);
|
((unsigned)CONFIG_SYS_CLK_FREQ >> k);
|
||||||
|
|
||||||
baud = best_m + best_n * YANU_BAUDE;
|
baud = best_m + best_n * YANU_BAUDE;
|
||||||
writel(&uart->baud, baud);
|
writel(baud, &uart->baud);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -92,7 +92,7 @@ void serial_setbrg (void)
|
||||||
((unsigned)CONFIG_SYS_CLK_FREQ >> k);
|
((unsigned)CONFIG_SYS_CLK_FREQ >> k);
|
||||||
|
|
||||||
baud = best_m + best_n * YANU_BAUDE;
|
baud = best_m + best_n * YANU_BAUDE;
|
||||||
writel(&uart->baud, baud);
|
writel(baud, &uart->baud);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -113,7 +113,7 @@ int serial_init (void)
|
||||||
YANU_ACTION_RPE |
|
YANU_ACTION_RPE |
|
||||||
YANU_ACTION_RFE | YANU_ACTION_RFIFO_CLEAR | YANU_ACTION_TFIFO_CLEAR;
|
YANU_ACTION_RFE | YANU_ACTION_RFIFO_CLEAR | YANU_ACTION_TFIFO_CLEAR;
|
||||||
|
|
||||||
writel(&uart->action, action);
|
writel(action, &uart->action);
|
||||||
|
|
||||||
/* control register cleanup */
|
/* control register cleanup */
|
||||||
/* no interrupts enabled */
|
/* no interrupts enabled */
|
||||||
|
@ -127,7 +127,7 @@ int serial_init (void)
|
||||||
control |= YANU_CONTROL_RDYDLY * YANU_RXFIFO_DLY;
|
control |= YANU_CONTROL_RDYDLY * YANU_RXFIFO_DLY;
|
||||||
control |= YANU_CONTROL_TXTHR * YANU_TXFIFO_THR;
|
control |= YANU_CONTROL_TXTHR * YANU_TXFIFO_THR;
|
||||||
|
|
||||||
writel(&uart->control, control);
|
writel(control, &uart->control);
|
||||||
|
|
||||||
/* to set baud rate */
|
/* to set baud rate */
|
||||||
serial_setbrg();
|
serial_setbrg();
|
||||||
|
@ -156,7 +156,7 @@ void serial_putc (char c)
|
||||||
WATCHDOG_RESET ();
|
WATCHDOG_RESET ();
|
||||||
}
|
}
|
||||||
|
|
||||||
writel(&uart->data, (unsigned char)c);
|
writel((unsigned char)c, &uart->data);
|
||||||
}
|
}
|
||||||
|
|
||||||
void serial_puts (const char *s)
|
void serial_puts (const char *s)
|
||||||
|
@ -182,7 +182,7 @@ int serial_getc (void)
|
||||||
WATCHDOG_RESET ();
|
WATCHDOG_RESET ();
|
||||||
|
|
||||||
/* first we pull the char */
|
/* first we pull the char */
|
||||||
writel(&uart->action, YANU_ACTION_RFIFO_PULL);
|
writel(YANU_ACTION_RFIFO_PULL, &uart->action);
|
||||||
|
|
||||||
return(readl(&uart->data) & YANU_DATA_CHAR_MASK);
|
return(readl(&uart->data) & YANU_DATA_CHAR_MASK);
|
||||||
}
|
}
|
||||||
|
|
|
@ -80,19 +80,19 @@ extern unsigned inl (unsigned port);
|
||||||
({unsigned long val;\
|
({unsigned long val;\
|
||||||
asm volatile( "ldwio %0, 0(%1)" :"=r"(val) : "r" (addr)); val;})
|
asm volatile( "ldwio %0, 0(%1)" :"=r"(val) : "r" (addr)); val;})
|
||||||
|
|
||||||
#define writeb(addr,val)\
|
#define writeb(val,addr)\
|
||||||
asm volatile ("stbio %1, 0(%0)" : : "r" (addr), "r" (val))
|
asm volatile ("stbio %0, 0(%1)" : : "r" (val), "r" (addr))
|
||||||
#define writew(addr,val)\
|
#define writew(val,addr)\
|
||||||
asm volatile ("sthio %1, 0(%0)" : : "r" (addr), "r" (val))
|
asm volatile ("sthio %0, 0(%1)" : : "r" (val), "r" (addr))
|
||||||
#define writel(addr,val)\
|
#define writel(val,addr)\
|
||||||
asm volatile ("stwio %1, 0(%0)" : : "r" (addr), "r" (val))
|
asm volatile ("stwio %0, 0(%1)" : : "r" (val), "r" (addr))
|
||||||
|
|
||||||
#define inb(addr) readb(addr)
|
#define inb(addr) readb(addr)
|
||||||
#define inw(addr) readw(addr)
|
#define inw(addr) readw(addr)
|
||||||
#define inl(addr) readl(addr)
|
#define inl(addr) readl(addr)
|
||||||
#define outb(addr,val) writeb(addr,val)
|
#define outb(val, addr) writeb(val,addr)
|
||||||
#define outw(addr,val) writew(addr,val)
|
#define outw(val, addr) writew(val,addr)
|
||||||
#define outl(addr,val) writel(addr,val)
|
#define outl(val, addr) writel(val,addr)
|
||||||
|
|
||||||
static inline void insb (unsigned long port, void *dst, unsigned long count)
|
static inline void insb (unsigned long port, void *dst, unsigned long count)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue