static unsigned bfin_ppi_io_read_buffer (struct hw *me, void *dest, int space, address_word addr, unsigned nr_bytes) { struct bfin_ppi *ppi = hw_data (me); bu32 mmr_off; bu16 *valuep; mmr_off = addr - ppi->base; valuep = (void *)((unsigned long)ppi + mmr_base() + mmr_off); HW_TRACE_READ (); dv_bfin_mmr_require_16 (me, addr, nr_bytes, false); switch (mmr_off) { case mmr_offset(control): case mmr_offset(count): case mmr_offset(delay): case mmr_offset(frame): case mmr_offset(status): dv_store_2 (dest, *valuep); break; default: dv_bfin_mmr_invalid (me, addr, nr_bytes, false); break; } return nr_bytes; }
static unsigned bfin_ebiu_ddrc_io_read_buffer (struct hw *me, void *dest, int space, address_word addr, unsigned nr_bytes) { struct bfin_ebiu_ddrc *ddrc = hw_data (me); bu32 mmr_off; bu32 *value32p; bu16 *value16p; void *valuep; mmr_off = addr - ddrc->base; valuep = (void *)((unsigned long)ddrc + mmr_base() + mmr_off); value16p = valuep; value32p = valuep; HW_TRACE_READ (); switch (mmr_off) { case mmr_offset(errmst): case mmr_offset(rstctl): dv_bfin_mmr_require_16 (me, addr, nr_bytes, false); dv_store_2 (dest, *value16p); break; default: dv_bfin_mmr_require_32 (me, addr, nr_bytes, false); dv_store_4 (dest, *value32p); break; } return nr_bytes; }
static unsigned bfin_ctimer_io_read_buffer (struct hw *me, void *dest, int space, address_word addr, unsigned nr_bytes) { struct bfin_ctimer *ctimer = hw_data (me); bu32 mmr_off; bu32 *valuep; mmr_off = addr - ctimer->base; valuep = (void *)((unsigned long)ctimer + mmr_base() + mmr_off); HW_TRACE_READ (); switch (mmr_off) { case mmr_offset(tcount): /* Since we're optimizing events here, we need to calculate the new tcount value. */ if (bfin_ctimer_enabled (ctimer)) bfin_ctimer_update_count (me, ctimer); break; } dv_store_4 (dest, *valuep); return nr_bytes; }
static unsigned bfin_wdog_io_read_buffer (struct hw *me, void *dest, int space, address_word addr, unsigned nr_bytes) { struct bfin_wdog *wdog = hw_data (me); bu32 mmr_off; bu16 *value16p; bu32 *value32p; void *valuep; mmr_off = addr - wdog->base; valuep = (void *)((unsigned long)wdog + mmr_base() + mmr_off); value16p = valuep; value32p = valuep; HW_TRACE_READ (); switch (mmr_off) { case mmr_offset(ctl): dv_bfin_mmr_require_16 (me, addr, nr_bytes, false); dv_store_2 (dest, *value16p); break; case mmr_offset(cnt): case mmr_offset(stat): dv_store_4 (dest, *value32p); break; } return nr_bytes; }
static unsigned bfin_jtag_io_read_buffer (struct hw *me, void *dest, int space, address_word addr, unsigned nr_bytes) { struct bfin_jtag *jtag = hw_data (me); bu32 mmr_off; bu32 value; bu32 *valuep; mmr_off = addr - jtag->base; valuep = (void *)((unsigned long)jtag + mmr_base() + mmr_off); HW_TRACE_READ (); switch (mmr_off) { case mmr_offset(dbgstat): case mmr_offset(dspid): value = *valuep; break; default: while (1) /* Core MMRs -> exception -> doesn't return. */ dv_bfin_mmr_invalid (me, addr, nr_bytes, false); break; } dv_store_4 (dest, value); return nr_bytes; }
static unsigned bfin_uart_io_read_buffer (struct hw *me, void *dest, int space, address_word addr, unsigned nr_bytes) { struct bfin_uart *uart = hw_data (me); bu32 mmr_off; bu16 *valuep; mmr_off = addr - uart->base; valuep = (void *)((unsigned long)uart + mmr_base() + mmr_off); HW_TRACE_READ (); dv_bfin_mmr_require_16 (me, addr, nr_bytes, false); switch (mmr_off) { case mmr_offset(dll): if (uart->lcr & DLAB) dv_store_2 (dest, uart->dll); else { uart->rbr = bfin_uart_get_next_byte (me, uart->rbr, uart->mcr, NULL); dv_store_2 (dest, uart->rbr); } break; case mmr_offset(dlh): if (uart->lcr & DLAB) dv_store_2 (dest, uart->dlh); else dv_store_2 (dest, uart->ier); break; case mmr_offset(lsr): /* XXX: Reads are destructive on most parts, but not all ... */ uart->lsr |= bfin_uart_get_status (me); dv_store_2 (dest, *valuep); uart->lsr = 0; break; case mmr_offset(iir): /* XXX: Reads are destructive ... */ case mmr_offset(lcr): case mmr_offset(mcr): case mmr_offset(scr): case mmr_offset(gctl): dv_store_2 (dest, *valuep); break; default: dv_bfin_mmr_invalid (me, addr, nr_bytes, false); break; } return nr_bytes; }
static unsigned bfin_eppi_io_read_buffer (struct hw *me, void *dest, int space, address_word addr, unsigned nr_bytes) { struct bfin_eppi *eppi = hw_data (me); bu32 mmr_off; bu16 *value16p; bu32 *value32p; void *valuep; /* Invalid access mode is higher priority than missing register. */ if (!dv_bfin_mmr_require_16_32 (me, addr, nr_bytes, true)) return 0; mmr_off = addr - eppi->base; valuep = (void *)((unsigned long)eppi + mmr_base() + mmr_off); value16p = valuep; value32p = valuep; HW_TRACE_READ (); switch (mmr_off) { case mmr_offset(status): case mmr_offset(hcount): case mmr_offset(hdelay): case mmr_offset(vcount): case mmr_offset(vdelay): case mmr_offset(frame): case mmr_offset(line): case mmr_offset(clkdiv): if (!dv_bfin_mmr_require_16 (me, addr, nr_bytes, false)) return 0; dv_store_2 (dest, *value16p); break; case mmr_offset(control): case mmr_offset(fs1w_hbl): case mmr_offset(fs1p_avpl): case mmr_offset(fsw2_lvb): case mmr_offset(fs2p_lavf): case mmr_offset(clip): case mmr_offset(err): if (!dv_bfin_mmr_require_32 (me, addr, nr_bytes, false)) return 0; dv_store_4 (dest, *value32p); break; default: dv_bfin_mmr_invalid (me, addr, nr_bytes, false); return 0; } return nr_bytes; }
static unsigned bfin_gpio_io_read_buffer (struct hw *me, void *dest, int space, address_word addr, unsigned nr_bytes) { struct bfin_gpio *port = hw_data (me); bu32 mmr_off; bu16 *value16p; bu32 *value32p; void *valuep; mmr_off = addr - port->base; /* Invalid access mode is higher priority than missing register. */ if (mmr_off == mmr_offset (mux)) { if (!dv_bfin_mmr_require_32 (me, addr, nr_bytes, false)) return 0; } else if (!dv_bfin_mmr_require_16 (me, addr, nr_bytes, false)) return 0; valuep = (void *)((unsigned long)port + mmr_base() + mmr_off); value16p = valuep; value32p = valuep; HW_TRACE_READ (); switch (mmr_off) { case mmr_offset(data): case mmr_offset(clear): case mmr_offset(set): dv_store_2 (dest, port->data); break; case mmr_offset(dir_clear): case mmr_offset(dir_set): dv_store_2 (dest, port->dir); break; case mmr_offset(fer): case mmr_offset(inen): dv_store_2 (dest, *value16p); break; case mmr_offset(mux): dv_store_4 (dest, *value32p); break; default: dv_bfin_mmr_invalid (me, addr, nr_bytes, false); return 0; } return nr_bytes; }
static unsigned bfin_uart_io_read_buffer (struct hw *me, void *dest, int space, address_word addr, unsigned nr_bytes) { struct bfin_uart *uart = hw_data (me); bu32 mmr_off; bu16 *valuep; /* Invalid access mode is higher priority than missing register. */ if (!dv_bfin_mmr_require_16 (me, addr, nr_bytes, false)) return 0; mmr_off = addr - uart->base; valuep = (void *)((unsigned long)uart + mmr_base() + mmr_off); HW_TRACE_READ (); switch (mmr_off) { case mmr_offset(rbr): uart->rbr = bfin_uart_get_next_byte (me, uart->rbr, uart->mcr, NULL); dv_store_2 (dest, uart->rbr); break; case mmr_offset(ier_set): case mmr_offset(ier_clear): dv_store_2 (dest, uart->ier); bfin_uart_reschedule (me); break; case mmr_offset(lsr): uart->lsr &= ~(DR | THRE | TEMT); uart->lsr |= bfin_uart_get_status (me); case mmr_offset(thr): case mmr_offset(msr): case mmr_offset(dll): case mmr_offset(dlh): case mmr_offset(gctl): case mmr_offset(lcr): case mmr_offset(mcr): case mmr_offset(scr): dv_store_2 (dest, *valuep); break; default: dv_bfin_mmr_invalid (me, addr, nr_bytes, false); return 0; } return nr_bytes; }
static unsigned bfin_cec_io_read_buffer (struct hw *me, void *dest, int space, address_word addr, unsigned nr_bytes) { struct bfin_cec *cec = hw_data (me); bu32 mmr_off; bu32 *valuep; mmr_off = addr - cec->base; valuep = (void *)((unsigned long)cec + mmr_base() + mmr_off); HW_TRACE_READ (); dv_store_4 (dest, *valuep); return nr_bytes; }
static unsigned bfin_rtc_io_read_buffer (struct hw *me, void *dest, int space, address_word addr, unsigned nr_bytes) { struct bfin_rtc *rtc = hw_data (me); bu32 mmr_off; bu16 *value16p; bu32 *value32p; void *valuep; mmr_off = addr - rtc->base; valuep = (void *)((unsigned long)rtc + mmr_base() + mmr_off); value16p = valuep; value32p = valuep; HW_TRACE_READ (); switch (mmr_off) { case mmr_offset(stat): { time_t t = time (NULL); struct tm *tm = localtime (&t); bu32 value = (((tm->tm_year - 70) * 365 + tm->tm_yday) << 17) | (tm->tm_hour << 12) | (tm->tm_min << 6) | (tm->tm_sec << 0); dv_store_4 (dest, value); break; } case mmr_offset(alarm): dv_store_4 (dest, *value32p); break; case mmr_offset(istat): case mmr_offset(ictl): case mmr_offset(swcnt): case mmr_offset(pren): dv_store_2 (dest, *value16p); break; } return nr_bytes; }
static unsigned bfin_ebiu_sdc_io_read_buffer (struct hw *me, void *dest, int space, address_word addr, unsigned nr_bytes) { struct bfin_ebiu_sdc *sdc = hw_data (me); bu32 mmr_off; bu32 *value32p; bu16 *value16p; void *valuep; mmr_off = addr - sdc->base; valuep = (void *)((unsigned long)sdc + mmr_base() + mmr_off); value16p = valuep; value32p = valuep; HW_TRACE_READ (); switch (mmr_off) { case mmr_offset(sdgctl): dv_store_4 (dest, *value32p); break; case mmr_offset(sdbctl): if (sdc->type == 561) { dv_bfin_mmr_require_32 (me, addr, nr_bytes, false); dv_store_4 (dest, *value32p); } else { dv_bfin_mmr_require_16 (me, addr, nr_bytes, false); dv_store_2 (dest, *value16p); } break; case mmr_offset(sdrrc): case mmr_offset(sdstat): dv_bfin_mmr_require_16 (me, addr, nr_bytes, false); dv_store_2 (dest, *value16p); break; } return nr_bytes; }
static unsigned bfin_gptimer_io_read_buffer (struct hw *me, void *dest, int space, address_word addr, unsigned nr_bytes) { struct bfin_gptimer *gptimer = hw_data (me); bu32 mmr_off; bu16 *value16p; bu32 *value32p; void *valuep; /* Invalid access mode is higher priority than missing register. */ if (!dv_bfin_mmr_require_16_32 (me, addr, nr_bytes, false)) return 0; mmr_off = addr - gptimer->base; valuep = (void *)((unsigned long)gptimer + mmr_base() + mmr_off); value16p = valuep; value32p = valuep; HW_TRACE_READ (); switch (mmr_off) { case mmr_offset(config): if (!dv_bfin_mmr_require_16 (me, addr, nr_bytes, false)) return 0; dv_store_2 (dest, *value16p); break; case mmr_offset(counter): case mmr_offset(period): case mmr_offset(width): if (!dv_bfin_mmr_require_32 (me, addr, nr_bytes, false)) return 0; dv_store_4 (dest, *value32p); break; default: dv_bfin_mmr_invalid (me, addr, nr_bytes, false); return 0; } return nr_bytes; }
static unsigned bfin_cec_io_read_buffer (struct hw *me, void *dest, int space, address_word addr, unsigned nr_bytes) { struct bfin_cec *cec = hw_data (me); bu32 mmr_off; bu32 *valuep; /* Invalid access mode is higher priority than missing register. */ if (!dv_bfin_mmr_require_32 (me, addr, nr_bytes, false)) return 0; mmr_off = addr - cec->base; valuep = (void *)((unsigned long)cec + mmr_base() + mmr_off); HW_TRACE_READ (); dv_store_4 (dest, *valuep); return nr_bytes; }
static unsigned bfin_spi_io_read_buffer (struct hw *me, void *dest, int space, address_word addr, unsigned nr_bytes) { struct bfin_spi *spi = hw_data (me); bu32 mmr_off; bu16 *valuep; /* Invalid access mode is higher priority than missing register. */ if (!dv_bfin_mmr_require_16 (me, addr, nr_bytes, false)) return 0; mmr_off = addr - spi->base; valuep = (void *)((unsigned long)spi + mmr_base() + mmr_off); HW_TRACE_READ (); switch (mmr_off) { case mmr_offset(rdbr): dv_store_2 (dest, *valuep); if (bfin_spi_enabled (spi) && bfin_spi_timod (spi) == RDBR_CORE) spi->stat &= ~(RXS | TXS); break; case mmr_offset(ctl): case mmr_offset(stat): case mmr_offset(flg): case mmr_offset(tdbr): case mmr_offset(baud): case mmr_offset(shadow): dv_store_2 (dest, *valuep); break; default: dv_bfin_mmr_invalid (me, addr, nr_bytes, false); return 0; } return nr_bytes; }
static unsigned bfin_ebiu_ddrc_io_read_buffer (struct hw *me, void *dest, int space, address_word addr, unsigned nr_bytes) { struct bfin_ebiu_ddrc *ddrc = hw_data (me); bu32 mmr_off; bu32 *value32p; bu16 *value16p; void *valuep; /* Invalid access mode is higher priority than missing register. */ if (!dv_bfin_mmr_require_16_32 (me, addr, nr_bytes, true)) return 0; mmr_off = addr - ddrc->base; valuep = (void *)((unsigned long)ddrc + mmr_base() + mmr_off); value16p = valuep; value32p = valuep; HW_TRACE_READ (); switch (mmr_off) { case mmr_offset(errmst): case mmr_offset(rstctl): if (!dv_bfin_mmr_require_16 (me, addr, nr_bytes, false)) return 0; dv_store_2 (dest, *value16p); break; default: if (!dv_bfin_mmr_require_32 (me, addr, nr_bytes, false)) return 0; dv_store_4 (dest, *value32p); break; } return nr_bytes; }