Date:2010-10-18 16:53:50 (9 years 8 months ago)
Author:Xiangfu Liu
Commit:ee76fb4f890f40f18832f5f0e93213a995efb17c
Message:remove useless functions in jz_mmc.c: mmc_block_write, mmc_write, mmc_ident, mmc2info

remove auto-generate file:
board/xburst/nanonote/config.tmp

cleanup the mmc_bread function:
since we always read block, no aligned problem.

Signed-off-by: Xiangfu Liu <xiangfu@sharism.cc>
Files: package/uboot-xburst/files/board/xburst/nanonote/config.tmp (1 diff)
package/uboot-xburst/files/drivers/mmc/jz_mmc.c (6 diffs)
package/uboot-xburst/files/drivers/mmc/jz_mmc.h (2 diffs)

Change Details

package/uboot-xburst/files/board/xburst/nanonote/config.tmp
1TEXT_BASE = 0x80100000
package/uboot-xburst/files/drivers/mmc/jz_mmc.c
2929#include <asm/jz4740.h>
3030#include "jz_mmc.h"
3131
32#define debug(...) ;
33
3432#define CFG_MMC_BASE 0x80600000
3533static int sd2_0 = 0;
34static uchar mmc_buf[1024];
35static int mmc_ready = 0;
36static int use_4bit; /* Use 4-bit data bus */
37/*
38 * MMC Events
39 */
40#define MMC_EVENT_NONE 0x00 /* No events */
41#define MMC_EVENT_RX_DATA_DONE 0x01 /* Rx data done */
42#define MMC_EVENT_TX_DATA_DONE 0x02 /* Tx data done */
43#define MMC_EVENT_PROG_DONE 0x04 /* Programming is done */
44
45
46#define MMC_IRQ_MASK() \
47do { \
48          REG_MSC_IMASK = 0xffff; \
49          REG_MSC_IREG = 0xffff; \
50} while (0)
3651
3752/*
3853 * GPIO definition
...... 
7792 * Local functions
7893 */
7994
80#ifdef CONFIG_MMC
8195extern int
8296fat_register_device(block_dev_desc_t *dev_desc, int part_no);
8397
...... 
88102    return ((block_dev_desc_t *)&mmc_dev);
89103}
90104
91/*
92 * FIXME needs to read cid and csd info to determine block size
93 * and other parameters
94 */
95static uchar mmc_buf[1024];
96static int mmc_ready = 0;
97static int use_4bit; /* Use 4-bit data bus */
98/*
99 * MMC Events
100 */
101#define MMC_EVENT_NONE 0x00 /* No events */
102#define MMC_EVENT_RX_DATA_DONE 0x01 /* Rx data done */
103#define MMC_EVENT_TX_DATA_DONE 0x02 /* Tx data done */
104#define MMC_EVENT_PROG_DONE 0x04 /* Programming is done */
105
106
107#define MMC_IRQ_MASK() \
108do { \
109          REG_MSC_IMASK = 0xffff; \
110          REG_MSC_IREG = 0xffff; \
111} while (0)
112
113105/* Stop the MMC clock and wait while it happens */
114106static inline int jz_mmc_stop_clock(void)
115107{
...... 
565557        goto exit;
566558
567559    mmc_simple_cmd(&request, MMC_CMD_SET_BLOCKLEN, len, RESPONSE_R1);
568    if ((retval = mmc_unpack_r1(&request, &r1, 0)))
560    if (retval = mmc_unpack_r1(&request, &r1, 0))
569561        goto exit;
570562
571563    if (sd2_0)
572564        src /= len;
573565
574    mmc_send_cmd(&request, MMC_CMD_READ_SINGLE_BLOCK, src, 1,len, RESPONSE_R1, dst);
575    if ((retval = mmc_unpack_r1(&request, &r1, 0)))
566    mmc_send_cmd(&request, MMC_CMD_READ_SINGLE_BLOCK, src, 1, len, RESPONSE_R1, dst);
567    if (retval = mmc_unpack_r1(&request, &r1, 0))
576568        goto exit;
577569
578570exit:
579571    return retval;
580572}
581573
582int mmc_block_write(ulong dst, uchar *src, int len)
583{
584    return 0;
585}
586
587int xburst_mmc_read(u64 src, uchar *dst, int size)
574ulong mmc_bread(int dev_num, ulong blkstart, ulong blkcnt, ulong *dst)
588575{
589    ulong end, part_start, part_end, part_len, aligned_start, aligned_end;
590    ulong mmc_block_size, mmc_block_address;
591
592    if (size == 0) {
593        return 0;
594    }
595
596    if (!mmc_ready) {
597        printf("Please initial the MMC first\n");
598        return -1;
599    }
600
601    debug("---- start %s ---- \n", __func__);
602
603    mmc_block_size = mmcinfo.block_len;
604    mmc_block_address = ~(mmc_block_size - 1);
605
606    end = src + size;
607    part_start = ~mmc_block_address & src;
608    part_end = ~mmc_block_address & end;
609    aligned_start = mmc_block_address & src;
610    aligned_end = mmc_block_address & end;
611    /* all block aligned accesses */
612    debug("src %lx dst %lx end %lx pstart %lx pend %lx astart %lx aend %lx\n",
613          src, (ulong)dst, end, part_start, part_end, aligned_start,
614          aligned_end);
615
616    if (part_start) {
617        part_len = mmc_block_size - part_start;
618        debug("ps src %lx dst %lx end %lx pstart %lx pend %lx astart %lx aend %lx\n",
619             src, (ulong) dst, end, part_start, part_end, aligned_start,
620             aligned_end);
621
622        if ((mmc_block_read(mmc_buf, aligned_start, mmc_block_size)) < 0) {
623
576       if (!mmc_ready) {
577               printf("Please initial the MMC first\n");
578               return -1;
579       }
580
581       int i = 0;
582       ulong src = blkstart * mmcinfo.block_len;
583       ulong dst_tmp = dst;
584
585       for (i = 0; i < blkcnt; i++) {
586               if ((mmc_block_read((uchar *)(dst_tmp), src, mmcinfo.block_len)) < 0)
624587            return -1;
625        }
626        memcpy(dst, mmc_buf + part_start, part_len);
627        dst += part_len;
628        src += part_len;
629    }
630
631    for (; src < aligned_end; src += mmc_block_size, dst += mmc_block_size) {
632        debug("src %lx dst %lx end %lx pstart %lx pend %lx astart %lx aend %lx\n",
633        src, (ulong)dst, end, part_start, part_end, aligned_start, aligned_end);
634588
635        if ((mmc_block_read((uchar *)(dst), src, mmc_block_size)) < 0) {
636            return -1;
637        }
589               dst_tmp += mmcinfo.block_len;
590               src += mmcinfo.block_len;
638591    }
639
640    debug("src %lx dst %lx end %lx pstart %lx pend %lx astart %lx aend %lx\n",
641          src, (ulong)dst, end, part_start, part_end, aligned_start, aligned_end);
642
643    if (part_end && src < end) {
644        if ((mmc_block_read(mmc_buf, aligned_end, mmc_block_size)) < 0) {
645            return -1;
646        }
647        memcpy(dst, mmc_buf, part_end);
648    }
649
650    debug("---- end %s ---- \n", __func__);
651    return 0;
652}
653
654int mmc_write(uchar *src, ulong dst, int size)
655{
656    ulong end, part_start, part_end, part_len, aligned_start, aligned_end;
657    ulong mmc_block_size, mmc_block_address;
658
659    if (size == 0) {
660        return 0;
661    }
662
663    if (!mmc_ready) {
664        printf("MMC card is not ready\n");
665        return -1;
666    }
667
668    mmc_block_size = mmcinfo.block_len;
669    mmc_block_address = ~(mmc_block_size - 1);
670
671    dst -= CFG_MMC_BASE;
672    end = dst + size;
673    part_start = ~mmc_block_address & dst;
674    part_end = ~mmc_block_address & end;
675    aligned_start = mmc_block_address & dst;
676    aligned_end = mmc_block_address & end;
677
678    /* all block aligned accesses */
679    debug("src %lx dst %lx end %lx pstart %lx pend %lx astart %lx aend %lx\n",
680    src, (ulong)dst, end, part_start, part_end, aligned_start, aligned_end);
681    if (part_start) {
682        part_len = mmc_block_size - part_start;
683        debug("ps src %lx dst %lx end %lx pstart %lx pend %lx astart %lx aend %lx\n",
684        (ulong)src, dst, end, part_start, part_end, aligned_start, aligned_end);
685        if ((mmc_block_read(mmc_buf, aligned_start, mmc_block_size)) < 0) {
686            return -1;
687        }
688        memcpy(mmc_buf+part_start, src, part_len);
689        if ((mmc_block_write(aligned_start, mmc_buf, mmc_block_size)) < 0) {
690            return -1;
691        }
692        dst += part_len;
693        src += part_len;
694    }
695    debug("src %lx dst %lx end %lx pstart %lx pend %lx astart %lx aend %lx\n",
696    src, (ulong)dst, end, part_start, part_end, aligned_start, aligned_end);
697    for (; dst < aligned_end; src += mmc_block_size, dst += mmc_block_size) {
698        debug("al src %lx dst %lx end %lx pstart %lx pend %lx astart %lx aend %lx\n",
699        src, (ulong)dst, end, part_start, part_end, aligned_start, aligned_end);
700        if ((mmc_block_write(dst, (uchar *)src, mmc_block_size)) < 0) {
701            return -1;
702        }
703    }
704    debug("src %lx dst %lx end %lx pstart %lx pend %lx astart %lx aend %lx\n",
705    src, (ulong)dst, end, part_start, part_end, aligned_start, aligned_end);
706    if (part_end && dst < end) {
707        debug("pe src %lx dst %lx end %lx pstart %lx pend %lx astart %lx aend %lx\n",
708        src, (ulong)dst, end, part_start, part_end, aligned_start, aligned_end);
709        if ((mmc_block_read(mmc_buf, aligned_end, mmc_block_size)) < 0) {
710            return -1;
711        }
712        memcpy(mmc_buf, src, part_end);
713        if ((mmc_block_write(aligned_end, mmc_buf, mmc_block_size)) < 0) {
714            return -1;
715        }
716    }
717    return 0;
718}
719
720ulong mmc_bread(int dev_num, ulong blknr, ulong blkcnt, ulong *dst)
721{
722    int mmc_block_size = mmcinfo.block_len;
723    ulong src = blknr * mmc_block_size ;//+ CFG_MMC_BASE;
724
725    xburst_mmc_read(src, (uchar *)dst, blkcnt*mmc_block_size);
726    return blkcnt;
592
593       return i;
727594}
728595
729596int mmc_select_card(void)
...... 
1008875    return 0;
1009876}
1010877
1011int mmc_ident(block_dev_desc_t *dev)
1012{
1013    return 0;
1014}
1015
1016int mmc2info(ulong addr)
1017{
1018    /* FIXME hard codes to 32 MB device */
1019    if (addr >= CFG_MMC_BASE && addr < CFG_MMC_BASE + 0x02000000) {
1020        return 1;
1021    }
1022    return 0;;
1023}
1024878/*
1025879 * Debugging functions
1026880 */
1027
1028881static char * mmc_result_strings[] = {
1029882    "NO_RESPONSE",
1030883    "NO_ERROR",
...... 
13261179
13271180    jz_mmc_exec_cmd(request);
13281181}
1329
1330#endif /* CONFIG_MMC */
package/uboot-xburst/files/drivers/mmc/jz_mmc.h
1313#ifndef __MMC_JZMMC_H__
1414#define __MMC_JZMMC_H__
1515
16#define MMC_DEBUG_LEVEL 0 /* Enable Debug: 0 - no debug */
1716#define ID_TO_RCA(x) ((x)+1)
1817#define MMC_OCR_ARG 0x00ff8000 /* Argument of OCR */
1918
...... 
174173    mmc_send_cmd( request, cmd, arg, 0, 0, rtype, 0);
175174}
176175
177int mmc2info(ulong addr);
178
179176#endif /* __MMC_JZMMC_H__ */

Archive Download the corresponding diff file



interactive