Changeset 3741


Ignore:
Timestamp:
12/27/07 06:55:24 (5 years ago)
Author:
andrew
Message:

Implement byte and half-word reads/writes from S3C MMCI FIFO.
BlockMode? is in bit 27 instead of 28 in CMD53.
Make CMD53 return R5 instead of R1.
Replace receiving_state with transfer_state per the specs.

Location:
trunk/src/host/qemu-neo1973/hw
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/host/qemu-neo1973/hw/ar6000.c

    r3740 r3741  
    411411            if (unlikely(fun > ((sd->ioocr >> 28) & 7))) { 
    412412                sd->card_status |= ADDRESS_ERROR; 
    413                 return sd_r1b; 
     413                return sd_r5; 
    414414            } 
    415415 
     
    419419            sd->transfer.data_start = addr; 
    420420            sd->transfer.data_offset = 0; 
    421             if ((req.arg >> 28) & 1) {                          /* BlockMode */ 
     421            if ((req.arg >> 27) & 1) {                          /* BlockMode */ 
    422422                if (sd->blk_len[fun] < 1 || sd->blk_len[fun] > 2048) 
    423                     return sd_r1b; 
     423                    return sd_r1; 
    424424 
    425425                sd->transfer.blk_len = sd->blk_len[fun]; 
     
    427427                sd->transfer.blk_len = 1; 
    428428            sd->transfer.blk_num = ((req.arg >> 0) & 0x1ff) ?: 
    429                     ((req.arg >> 28) & 1) ? -1 : 0x200;         /* BlockMode */ 
    430  
     429                    ((req.arg >> 27) & 1) ? -1 : 0x200;         /* BlockMode */ 
     430 
     431            /* XXX The R5 on real cards indicates command state for some 
     432             * reason.  Is that because the transfer hasn't started yet or 
     433             * because it has already finished when the response is made?  */ 
    431434            sd->state = sd_transfer_state; 
    432             return sd_r1b; 
     435            sd->transfer.data[0] = 0x00; 
     436            return sd_r5; 
    433437 
    434438        default: 
     
    554558    uint8_t ret; 
    555559 
    556     if (sd->state != sd_receivingdata_state) { 
     560    if (sd->state != sd_transfer_state) { 
    557561        printf("%s: not in Transfer state\n", __FUNCTION__); 
    558562        return 0x00; 
  • trunk/src/host/qemu-neo1973/hw/s3c24xx_mmci.c

    r3736 r3741  
    208208#define S3C_SDIMAX      0x40 
    209209 
    210 static uint32_t s3c_mmci_read(void *opaque, target_phys_addr_t addr) 
     210static uint32_t s3c_mmci_readw(void *opaque, target_phys_addr_t addr) 
    211211{ 
    212212    struct s3c_mmci_state_s *s = (struct s3c_mmci_state_s *) opaque; 
     
    263263            return s->fifolen;                                  /* FFCNT */ 
    264264    case S3C_SDIDAT: 
    265         /* TODO: 8/16-bit access */ 
    266265        ret = 0; 
    267266        if (s->fifolen >= 4) { 
     
    290289} 
    291290 
    292 static void s3c_mmci_write(void *opaque, target_phys_addr_t addr, 
     291static void s3c_mmci_writew(void *opaque, target_phys_addr_t addr, 
    293292                uint32_t value) 
    294293{ 
     
    346345        break; 
    347346    case S3C_SDIDAT: 
    348         /* TODO: 8/16-bit access */ 
    349347        s->fifo[(s->fifostart + s->fifolen ++) & 63] = (value >> 0) & 0xff; 
    350348        s->fifo[(s->fifostart + s->fifolen ++) & 63] = (value >> 8) & 0xff; 
     
    362360} 
    363361 
     362static uint32_t s3c_mmci_readh(void *opaque, target_phys_addr_t addr) 
     363{ 
     364    struct s3c_mmci_state_s *s = (struct s3c_mmci_state_s *) opaque; 
     365    uint16_t ret = 0; 
     366 
     367    if (s->map[addr - s->base] == S3C_SDIDAT) { 
     368        if (s->fifolen >= 2) { 
     369            ret |= s->fifo[s->fifostart ++] << 0; 
     370            s->fifostart &= 63; 
     371            ret |= s->fifo[s->fifostart ++] << 8; 
     372            s->fifostart &= 63; 
     373            s->fifolen -= 2; 
     374            s3c_mmci_fifo_run(s); 
     375        } else 
     376            printf("%s: FIFO underrun\n", __FUNCTION__); 
     377 
     378        return ret; 
     379    } 
     380 
     381    printf("%s: Bad register 0x%lx\n", __FUNCTION__, addr - s->base); 
     382    return 0; 
     383} 
     384 
     385static void s3c_mmci_writeh(void *opaque, target_phys_addr_t addr, 
     386                uint32_t value) 
     387{ 
     388    struct s3c_mmci_state_s *s = (struct s3c_mmci_state_s *) opaque; 
     389 
     390    if (s->map[addr - s->base] == S3C_SDIDAT) { 
     391        s->fifo[(s->fifostart + s->fifolen ++) & 63] = (value >> 0) & 0xff; 
     392        s->fifo[(s->fifostart + s->fifolen ++) & 63] = (value >> 8) & 0xff; 
     393        s3c_mmci_fifo_run(s); 
     394    } else 
     395        printf("%s: Bad register 0x%lx\n", __FUNCTION__, addr - s->base); 
     396} 
     397 
     398static uint32_t s3c_mmci_readb(void *opaque, target_phys_addr_t addr) 
     399{ 
     400    struct s3c_mmci_state_s *s = (struct s3c_mmci_state_s *) opaque; 
     401    uint8_t ret = 0; 
     402 
     403    if (s->map[addr - s->base] == S3C_SDIDAT) { 
     404        if (s->fifolen > 0) { 
     405            ret = s->fifo[s->fifostart ++]; 
     406            s->fifostart &= 63; 
     407            s->fifolen --; 
     408            s3c_mmci_fifo_run(s); 
     409        } else 
     410            printf("%s: FIFO underrun\n", __FUNCTION__); 
     411 
     412        return ret; 
     413    } 
     414 
     415    printf("%s: Bad register 0x%lx\n", __FUNCTION__, addr - s->base); 
     416    return 0; 
     417} 
     418 
     419static void s3c_mmci_writeb(void *opaque, target_phys_addr_t addr, 
     420                uint32_t value) 
     421{ 
     422    struct s3c_mmci_state_s *s = (struct s3c_mmci_state_s *) opaque; 
     423 
     424    if (s->map[addr - s->base] == S3C_SDIDAT) { 
     425        s->fifo[(s->fifostart + s->fifolen ++) & 63] = value; 
     426        s3c_mmci_fifo_run(s); 
     427    } else 
     428        printf("%s: Bad register 0x%lx\n", __FUNCTION__, addr - s->base); 
     429} 
     430 
    364431static CPUReadMemoryFunc *s3c_mmci_readfn[] = { 
    365     s3c_mmci_read, 
    366     s3c_mmci_read, 
    367     s3c_mmci_read, 
     432    s3c_mmci_readb, 
     433    s3c_mmci_readh, 
     434    s3c_mmci_readw, 
    368435}; 
    369436 
    370437static CPUWriteMemoryFunc *s3c_mmci_writefn[] = { 
    371     s3c_mmci_write, 
    372     s3c_mmci_write, 
    373     s3c_mmci_write, 
     438    s3c_mmci_writeb, 
     439    s3c_mmci_writeh, 
     440    s3c_mmci_writew, 
    374441}; 
    375442 
Note: See TracChangeset for help on using the changeset viewer.