Changeset 3686


Ignore:
Timestamp:
12/19/07 11:03:34 (5 years ago)
Author:
laforge
Message:

s3c_mci: major codingstyle cleanup (based on checkpatch.pl)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/src/target/kernel/2.6.24.x/patches/s3c_mci.patch

    r3676 r3686  
    11This is the latest S3C MMC/SD driver by Thomas Kleffel 
     2 
     3Signed-off-by: Harald Welte <laforge@openmoko.org> 
    24 
    35Index: linux-2.6/include/asm-arm/arch-s3c2410/regs-sdi.h 
     
    7274 #define S3C2410_SDIFSTA_RFFULL         (1<<8) 
    7375 #define S3C2410_SDIFSTA_RFHALF         (1<<7) 
    74 Index: linux-2.6/drivers/mmc/host/mmc_debug.c 
    75 =================================================================== 
    76 --- /dev/null 
    77 +++ linux-2.6/drivers/mmc/host/mmc_debug.c 
    78 @@ -0,0 +1,57 @@ 
    79 +/* 
    80 + *  linux/drivers/mmc/mmc_debug.c 
    81 + * 
    82 + *  Copyright (C) 2003 maintech GmbH, Thomas Kleffel <tk@maintech.de> 
    83 + * 
    84 + * This file contains debug helper functions for the MMC/SD stack 
    85 + * 
    86 + * This program is free software; you can redistribute it and/or modify 
    87 + * it under the terms of the GNU General Public License version 2 as 
    88 + * published by the Free Software Foundation. 
    89 + * 
    90 + */ 
    91 + 
    92 +#include <linux/module.h> 
    93 +#include <linux/mmc/core.h> 
    94 +#include <linux/mmc/mmc.h> 
    95 +#include "mmc_debug.h" 
    96 + 
    97 +char *mmc_cmd2str(int cmd) 
    98 +{ 
    99 +       switch(cmd) { 
    100 +               case  0: return "GO_IDLE_STATE"; 
    101 +               case  1: return "ALL_SEND_OCR"; 
    102 +               case  2: return "ALL_SEND_CID"; 
    103 +               case  3: return "ALL_SEND_RELATIVE_ADD"; 
    104 +               case  6: return "ACMD: SD_SET_BUSWIDTH"; 
    105 +               case  7: return "SEL_DESEL_CARD"; 
    106 +               case  9: return "SEND_CSD"; 
    107 +               case 10: return "SEND_CID"; 
    108 +               case 11: return "READ_UNTIL_STOP"; 
    109 +               case 12: return "STOP_TRANSMISSION"; 
    110 +               case 13: return "SEND_STATUS"; 
    111 +               case 15: return "GO_INACTIVE_STATE"; 
    112 +               case 16: return "SET_BLOCKLEN"; 
    113 +               case 17: return "READ_SINGLE_BLOCK"; 
    114 +               case 18: return "READ_MULTIPLE_BLOCK"; 
    115 +               case 24: return "WRITE_SINGLE_BLOCK"; 
    116 +               case 25: return "WRITE_MULTIPLE_BLOCK"; 
    117 +               case 41: return "ACMD: SD_APP_OP_COND"; 
    118 +               case 55: return "APP_CMD"; 
    119 +               default: return "UNKNOWN"; 
    120 +       } 
    121 +} 
    122 +EXPORT_SYMBOL(mmc_cmd2str); 
    123 + 
    124 +char *mmc_err2str(int err) 
    125 +{ 
    126 +       switch(err) { 
    127 +               case 0: return "OK"; 
    128 +               case -ETIMEDOUT:        return "TIMEOUT"; 
    129 +               case -EILSEQ:           return "BADCRC"; 
    130 +               case -EINVAL:           return "EINVAL"; 
    131 +               case -ENOMEDIUM:        return "NOMEDIUM"; 
    132 +               default: return "UNKNOWN"; 
    133 +       } 
    134 +} 
    135 +EXPORT_SYMBOL(mmc_err2str); 
    136 Index: linux-2.6/drivers/mmc/host/mmc_debug.h 
    137 =================================================================== 
    138 --- /dev/null 
    139 +++ linux-2.6/drivers/mmc/host/mmc_debug.h 
    140 @@ -0,0 +1,7 @@ 
    141 +#ifndef MMC_DEBUG_H 
    142 +#define MMC_DEBUG_H 
    143 + 
    144 +char *mmc_cmd2str(int err); 
    145 +char *mmc_err2str(int err); 
    146 + 
    147 +#endif /* MMC_DEBUG_H */ 
    14876Index: linux-2.6/drivers/mmc/host/s3cmci.c 
    14977=================================================================== 
    15078--- /dev/null 
    15179+++ linux-2.6/drivers/mmc/host/s3cmci.c 
    152 @@ -0,0 +1,1384 @@ 
     80@@ -0,0 +1,1409 @@ 
    15381+/* 
    15482+ *  linux/drivers/mmc/s3cmci.h - Samsung S3C MCI driver 
     
    178106+#include <asm/arch/mci.h> 
    179107+ 
    180 +#include "mmc_debug.h" 
    181108+#include "s3cmci.h" 
    182109+ 
     
    200127+ 
    201128+#define dbg(host, channels, args...)            \ 
     129+       do {                                     \ 
    202130+       if (dbgmap_err & channels)               \ 
    203131+               dev_err(&host->pdev->dev, args); \ 
     
    205133+               dev_info(&host->pdev->dev, args);\ 
    206134+       else if (dbgmap_debug & channels)        \ 
    207 +               dev_dbg(&host->pdev->dev, args); 
     135+               dev_dbg(&host->pdev->dev, args); \ 
     136+       } while (0) 
    208137+ 
    209138+#define RESSIZE(ressource) (((ressource)->end - (ressource)->start)+1) 
     
    218147+ 
    219148+#ifdef CONFIG_MMC_DEBUG 
     149+ 
     150+static char *mmc_cmd2str(int cmd) 
     151+{ 
     152+       switch (cmd) { 
     153+       case  0: return "GO_IDLE_STATE"; 
     154+       case  1: return "ALL_SEND_OCR"; 
     155+       case  2: return "ALL_SEND_CID"; 
     156+       case  3: return "ALL_SEND_RELATIVE_ADD"; 
     157+       case  6: return "ACMD: SD_SET_BUSWIDTH"; 
     158+       case  7: return "SEL_DESEL_CARD"; 
     159+       case  9: return "SEND_CSD"; 
     160+       case 10: return "SEND_CID"; 
     161+       case 11: return "READ_UNTIL_STOP"; 
     162+       case 12: return "STOP_TRANSMISSION"; 
     163+       case 13: return "SEND_STATUS"; 
     164+       case 15: return "GO_INACTIVE_STATE"; 
     165+       case 16: return "SET_BLOCKLEN"; 
     166+       case 17: return "READ_SINGLE_BLOCK"; 
     167+       case 18: return "READ_MULTIPLE_BLOCK"; 
     168+       case 24: return "WRITE_SINGLE_BLOCK"; 
     169+       case 25: return "WRITE_MULTIPLE_BLOCK"; 
     170+       case 41: return "ACMD: SD_APP_OP_COND"; 
     171+       case 55: return "APP_CMD"; 
     172+       default: return "UNKNOWN"; 
     173+       } 
     174+} 
     175+ 
     176+static char *mmc_err2str(int err) 
     177+{ 
     178+       switch (err) { 
     179+       case 0:                 return "OK"; 
     180+       case -ETIMEDOUT:        return "TIMEOUT"; 
     181+       case -EILSEQ:           return "BADCRC"; 
     182+       case -EINVAL:           return "EINVAL"; 
     183+       case -ENOMEDIUM:        return "NOMEDIUM"; 
     184+       default:                return "UNKNOWN"; 
     185+       } 
     186+} 
    220187+ 
    221188+static inline void dbg_dumpregs(struct s3cmci_host *host, char *prefix) 
     
    259226+                                                               int stop) 
    260227+{ 
    261 +       snprintf(host->dbgmsg_cmd, 300, 
     228+       snprintf(host->dbgmsg_cmd, 300, 
    262229+               "#%u%s op:%s(%i) arg:0x%08x flags:0x08%x retries:%u", 
    263230+               host->ccnt, (stop?" (STOP)":""), mmc_cmd2str(cmd->opcode), 
     
    312279+ 
    313280+       newmask = readl(host->base + host->sdiimsk); 
    314 +       newmask|= imask; 
     281+       newmask |= imask; 
    315282+ 
    316283+       writel(newmask, host->base + host->sdiimsk); 
     
    324291+ 
    325292+       newmask = readl(host->base + host->sdiimsk); 
    326 +       newmask&= ~imask; 
     293+       newmask &= ~imask; 
    327294+ 
    328295+       writel(newmask, host->base + host->sdiimsk); 
     
    337304+ 
    338305+static inline int get_data_buffer(struct s3cmci_host *host, 
    339 +                       volatile u32 *words, volatile u32 **pointer) 
     306+                                 u32 *words, u32 **pointer) 
    340307+{ 
    341308+       struct scatterlist *sg; 
     
    354321+       sg = &host->mrq->data->sg[host->pio_sgptr]; 
    355322+ 
    356 +       *words  = sg->length >> 2; 
    357 +       *pointer= page_address(sg_page(sg)) + sg->offset; 
     323+       *words = sg->length >> 2; 
     324+       *pointer = page_address(sg_page(sg)) + sg->offset; 
    358325+ 
    359326+       host->pio_sgptr++; 
     
    365332+} 
    366333+ 
    367 +#define FIFO_FILL(host) ((readl(host->base + S3C2410_SDIFSTA) & S3C2410_SDIFSTA_COUNTMASK) >> 2) 
    368 +#define FIFO_FREE(host) ((63 - (readl(host->base + S3C2410_SDIFSTA) & S3C2410_SDIFSTA_COUNTMASK)) >> 2) 
     334+#define FIFO_FILL(host) ((readl(host->base + S3C2410_SDIFSTA) &        \ 
     335+                               S3C2410_SDIFSTA_COUNTMASK) >> 2) 
     336+#define FIFO_FREE(host) ((63 - (readl(host->base + S3C2410_SDIFSTA)    \ 
     337+                               & S3C2410_SDIFSTA_COUNTMASK)) >> 2) 
    369338+ 
    370339+static inline void do_pio_read(struct s3cmci_host *host) 
     
    374343+       void __iomem *from_ptr; 
    375344+ 
    376 +       //write real prescaler to host, it might be set slow to fix 
     345+       /* write real prescaler to host, it might be set slow to fix */ 
    377346+       writel(host->prescaler, host->base + S3C2410_SDIPRE); 
    378347+ 
     
    388357+ 
    389358+                               dbg(host, dbg_pio, "pio_read(): " 
    390 +                                       "complete (no more data).\n"); 
     359+                                   "complete (no more data).\n"); 
    391360+                               return; 
    392361+                       } 
    393362+ 
    394 +                       dbg(host, dbg_pio, "pio_read(): new target: [%i]@[%p]\n", 
    395 +                             host->pio_words, host->pio_ptr); 
     363+                       dbg(host, dbg_pio, "pio_read(): new target: " 
     364+                           "[%i]@[%p]\n", host->pio_words, host->pio_ptr); 
    396365+               } 
    397366+ 
    398367+               dbg(host, dbg_pio, "pio_read(): fifo:[%02i] " 
    399 +                                  "buffer:[%03i] dcnt:[%08X]\n", 
    400 +                                  fifo, host->pio_words, 
    401 +                                  readl(host->base + S3C2410_SDIDCNT)); 
     368+                   "buffer:[%03i] dcnt:[%08X]\n", fifo, host->pio_words, 
     369+                   readl(host->base + S3C2410_SDIDCNT)); 
    402370+ 
    403371+               if (fifo > host->pio_words) 
    404372+                       fifo = host->pio_words; 
    405373+ 
    406 +               host->pio_words-= fifo; 
    407 +               host->pio_count+= fifo; 
    408 + 
    409 +               while(fifo--) { 
     374+               host->pio_words -= fifo; 
     375+               host->pio_count += fifo; 
     376+ 
     377+               while (fifo--) 
    410378+                       *(host->pio_ptr++) = readl(from_ptr); 
    411 +               } 
    412379+       } 
    413380+ 
     
    416383+               if (res) { 
    417384+                       dbg(host, dbg_pio, "pio_read(): " 
    418 +                               "complete (no more buffers).\n"); 
     385+                           "complete (no more buffers).\n"); 
    419386+                       host->pio_active = XFER_NONE; 
    420387+                       host->complete_what = COMPLETION_FINALIZE; 
     
    424391+       } 
    425392+ 
    426 +       enable_imask(host, S3C2410_SDIIMSK_RXFIFOHALF | S3C2410_SDIIMSK_RXFIFOLAST); 
     393+       enable_imask(host, S3C2410_SDIIMSK_RXFIFOHALF 
     394+                                               | S3C2410_SDIIMSK_RXFIFOLAST); 
    427395+} 
    428396+ 
     
    457425+                       fifo = host->pio_words; 
    458426+ 
    459 +               host->pio_words-= fifo; 
    460 +               host->pio_count+= fifo; 
    461 + 
    462 +               while(fifo--) { 
     427+               host->pio_words -= fifo; 
     428+               host->pio_count += fifo; 
     429+ 
     430+               while (fifo--) 
    463431+                       writel(*(host->pio_ptr++), to_ptr); 
    464 +               } 
    465432+       } 
    466433+ 
     
    500467+ * Communication between driver and ISR works as follows: 
    501468+ *   host->mrq                         points to current request 
    502 + *   host->complete_what       tells the ISR when the request is considered done 
     469+ *   host->complete_what       tells ISR when the request is considered done 
    503470+ *     COMPLETION_CMDSENT        when the command was sent 
    504471+ *     COMPLETION_RSPFIN          when a response was received 
     
    576543+                               (mci_fsta & S3C2410_SDIFSTA_RFDET)) { 
    577544+ 
    578 +                       disable_imask(host, 
    579 +                               S3C2410_SDIIMSK_RXFIFOHALF | S3C2410_SDIIMSK_RXFIFOLAST); 
     545+                       disable_imask(host, S3C2410_SDIIMSK_RXFIFOHALF | 
     546+                                               S3C2410_SDIIMSK_RXFIFOLAST); 
    580547+ 
    581548+                       tasklet_schedule(&host->pio_tasklet); 
     
    671638+               } 
    672639+ 
    673 +               if (host->complete_what == COMPLETION_XFERFINISH_RSPFIN) { 
     640+               if (host->complete_what == COMPLETION_XFERFINISH_RSPFIN) 
    674641+                       host->complete_what = COMPLETION_RSPFIN; 
    675 +               } 
    676642+ 
    677643+               mci_dclear |= S3C2410_SDIDSTA_XFERFINISH; 
     
    799765+       } 
    800766+ 
    801 +       // Read response 
     767+       /* Read response */ 
    802768+       cmd->resp[0] = readl(host->base + S3C2410_SDIRSP0); 
    803769+       cmd->resp[1] = readl(host->base + S3C2410_SDIRSP1); 
     
    805771+       cmd->resp[3] = readl(host->base + S3C2410_SDIRSP3); 
    806772+ 
    807 +       // reset clock speed, as it could still be set low for 
     773+       /* reset clock speed, as it could still be set low for */ 
    808774+       writel(host->prescaler, host->base + S3C2410_SDIPRE); 
    809775+ 
     
    813779+       if (cmd->data && cmd->data->error) 
    814780+               debug_as_failure = 1; 
    815 + 
    816 +       //if(cmd->flags & MMC_RSP_MAYFAIL) debug_as_failure = 0; 
    817781+ 
    818782+#ifdef CONFIG_MMC_DEBUG 
    819783+       dbg_dumpcmd(host, cmd, debug_as_failure); 
    820784+#endif 
    821 +       //Cleanup controller 
     785+       /* Cleanup controller */ 
    822786+       writel(0, host->base + S3C2410_SDICMDARG); 
    823787+       writel(S3C2410_SDIDCON_STOP, host->base + S3C2410_SDIDCON); 
     
    834798+       } 
    835799+ 
    836 +       // If we have no data transfer we are finished here 
     800+       /* If we have no data transfer we are finished here */ 
    837801+       if (!mrq->data) 
    838802+               goto request_done; 
    839803+ 
    840 +       // Calulate the amout of bytes transfer, but only if there was 
    841 +       // no error 
    842 +       if (mrq->data->error == 0) { 
     804+       /* Calulate the amout of bytes transfer, but only if there was 
     805+        * no error */ 
     806+       if (mrq->data->error == 0) 
    843807+               mrq->data->bytes_xfered = 
    844808+                       (mrq->data->blocks * mrq->data->blksz); 
    845 +       } else { 
     809+       else 
    846810+               mrq->data->bytes_xfered = 0; 
    847 +       } 
    848 + 
    849 +       // If we had an error while transfering data we flush the 
    850 +       // DMA channel and the fifo to clear out any garbage 
     811+ 
     812+       /* If we had an error while transfering data we flush the 
     813+        * DMA channel and the fifo to clear out any garbage */ 
    851814+       if (mrq->data->error) { 
    852815+               if (host->dodma) 
     
    854817+ 
    855818+               if (host->is2440) { 
    856 +                       //Clear failure register and reset fifo 
     819+                       /* Clear failure register and reset fifo */ 
    857820+                       writel(S3C2440_SDIFSTA_FIFORESET | 
    858821+                              S3C2440_SDIFSTA_FIFOFAIL, 
     
    861824+                       u32 mci_con; 
    862825+ 
    863 +                       //reset fifo 
     826+                       /* reset fifo */ 
    864827+                       mci_con = readl(host->base + S3C2410_SDICON); 
    865 +                       mci_con|= S3C2410_SDICON_FIFORESET; 
     828+                       mci_con |= S3C2410_SDICON_FIFORESET; 
    866829+ 
    867830+                       writel(mci_con, host->base + S3C2410_SDICON); 
     
    878841+void s3cmci_dma_setup(struct s3cmci_host *host, enum s3c2410_dmasrc source) 
    879842+{ 
    880 +       static int setup_ok = 0; 
     843+       static int setup_ok; 
    881844+       static enum s3c2410_dmasrc last_source = -1; 
    882845+ 
     
    892855+               s3c2410_dma_config(host->dma, 4, 
    893856+                       (S3C2410_DCON_HWTRIG | S3C2410_DCON_CH0_SDI)); 
    894 +               s3c2410_dma_set_buffdone_fn(host->dma, s3cmci_dma_done_callback); 
     857+               s3c2410_dma_set_buffdone_fn(host->dma, 
     858+                                           s3cmci_dma_done_callback); 
    895859+               s3c2410_dma_setflags(host->dma, S3C2410_DMAF_AUTOSTART); 
    896860+               setup_ok = 1; 
     
    909873+       enable_imask(host, imsk); 
    910874+ 
    911 +       if (cmd->data) { 
     875+       if (cmd->data) 
    912876+               host->complete_what = COMPLETION_XFERFINISH_RSPFIN; 
    913 +       } else if (cmd->flags & MMC_RSP_PRESENT) { 
     877+       else if (cmd->flags & MMC_RSP_PRESENT) 
    914878+               host->complete_what = COMPLETION_RSPFIN; 
    915 +       } else { 
     879+       else 
    916880+               host->complete_what = COMPLETION_CMDSENT; 
    917 +       } 
    918881+ 
    919882+       writel(cmd->arg, host->base + S3C2410_SDICMDARG); 
    920883+ 
    921884+       ccon = cmd->opcode & S3C2410_SDICMDCON_INDEX; 
    922 +       ccon|= S3C2410_SDICMDCON_SENDERHOST | S3C2410_SDICMDCON_CMDSTART; 
     885+       ccon |= S3C2410_SDICMDCON_SENDERHOST | S3C2410_SDICMDCON_CMDSTART; 
    923886+ 
    924887+       if (cmd->flags & MMC_RSP_PRESENT) 
     
    926889+ 
    927890+       if (cmd->flags & MMC_RSP_136) 
    928 +               ccon|= S3C2410_SDICMDCON_LONGRSP; 
     891+               ccon |= S3C2410_SDICMDCON_LONGRSP; 
    929892+ 
    930893+       writel(ccon, host->base + S3C2410_SDICMDCON); 
     
    933896+static int s3cmci_setup_data(struct s3cmci_host *host, struct mmc_data *data) 
    934897+{ 
    935 +       u32 dcon, imsk, stoptries=3; 
     898+       u32 dcon, imsk, stoptries = 3; 
    936899+ 
    937900+       /* write DCON register */ 
     
    942905+       } 
    943906+ 
    944 +       while(readl(host->base + S3C2410_SDIDSTA) & 
     907+       while (readl(host->base + S3C2410_SDIDSTA) & 
    945908+               (S3C2410_SDIDSTA_TXDATAON | S3C2410_SDIDSTA_RXDATAON)) { 
    946909+ 
    947910+               dbg(host, dbg_err, 
    948 +                       "mci_setup_data() transfer stillin progress.\n"); 
     911+                   "mci_setup_data() transfer stillin progress.\n"); 
    949912+ 
    950913+               writel(S3C2410_SDIDCON_STOP, host->base + S3C2410_SDIDCON); 
     
    962925+       dcon  = data->blocks & S3C2410_SDIDCON_BLKNUM_MASK; 
    963926+ 
    964 +       if (host->dodma) { 
     927+       if (host->dodma) 
    965928+               dcon |= S3C2410_SDIDCON_DMAEN; 
    966 +       } 
    967 + 
    968 +       if (host->bus_width == MMC_BUS_WIDTH_4) { 
     929+ 
     930+       if (host->bus_width == MMC_BUS_WIDTH_4) 
    969931+               dcon |= S3C2410_SDIDCON_WIDEBUS; 
    970 +       } 
    971 + 
    972 +       if (!(data->flags & MMC_DATA_STREAM)) { 
     932+ 
     933+       if (!(data->flags & MMC_DATA_STREAM)) 
    973934+               dcon |= S3C2410_SDIDCON_BLOCKMODE; 
    974 +       } 
    975935+ 
    976936+       if (data->flags & MMC_DATA_WRITE) { 
     
    1008968+               writel(0x0000FFFF, host->base + S3C2410_SDITIMER); 
    1009969+ 
    1010 +               //FIX: set slow clock to prevent timeouts on read 
    1011 +               if (data->flags & MMC_DATA_READ) { 
     970+               /* FIX: set slow clock to prevent timeouts on read */ 
     971+               if (data->flags & MMC_DATA_READ) 
    1012972+                       writel(0xFF, host->base + S3C2410_SDIPRE); 
    1013 +               } 
    1014 +       } 
    1015 + 
    1016 +       //debug_dump_registers(host, "Data setup:"); 
     973+       } 
    1017974+ 
    1018975+       return 0; 
     
    10791036+                       return -EBUSY; 
    10801037+               } 
    1081 +       } 
     1038+       } 
    10821039+ 
    10831040+       s3c2410_dma_ctrl(host->dma, S3C2410_DMAOP_START); 
     
    10961053+       prepare_dbgmsg(host, cmd, host->cmd_is_stop); 
    10971054+#endif 
    1098 +       //Clear command, data and fifo status registers 
    1099 +       //Fifo clear only necessary on 2440, but doesn't hurt on 2410 
     1055+       /* clear command, data and fifo status registers; 
     1056+        * Fifo clear only necessary on 2440, but doesn't hurt on 2410 */ 
    11001057+       writel(0xFFFFFFFF, host->base + S3C2410_SDICMDSTAT); 
    11011058+       writel(0xFFFFFFFF, host->base + S3C2410_SDIDSTA); 
     
    11171074+ 
    11181075+ 
    1119 +               if (host->dodma) { 
     1076+               if (host->dodma) 
    11201077+                       res = s3cmci_prepare_dma(host, cmd->data); 
    1121 +               } else { 
     1078+               else 
    11221079+                       res = s3cmci_prepare_pio(host, cmd->data); 
    1123 +               } 
    11241080+ 
    11251081+               if (res) { 
     
    11331089+       } 
    11341090+ 
    1135 +       // Send command 
    11361091+       s3cmci_send_command(host, cmd); 
    1137 + 
    1138 +       // Enable Interrupt 
    11391092+       enable_irq(host->irq); 
    11401093+} 
     
    11421095+static void s3cmci_request(struct mmc_host *mmc, struct mmc_request *mrq) 
    11431096+{ 
    1144 +       struct s3cmci_host *host = mmc_priv(mmc); 
     1097+       struct s3cmci_host *host = mmc_priv(mmc); 
    11451098+ 
    11461099+       host->cmd_is_stop = 0; 
     
    11551108+       u32 mci_psc, mci_con; 
    11561109+ 
    1157 +       //Set power 
     1110+       /* Set power */ 
    11581111+       mci_con = readl(host->base + S3C2410_SDICON); 
    1159 +       switch(ios->power_mode) { 
    1160 +               case MMC_POWER_ON: 
    1161 +               case MMC_POWER_UP: 
    1162 +                       s3c2410_gpio_cfgpin(S3C2410_GPE5, S3C2410_GPE5_SDCLK); 
    1163 +                       s3c2410_gpio_cfgpin(S3C2410_GPE6, S3C2410_GPE6_SDCMD); 
    1164 +                       s3c2410_gpio_cfgpin(S3C2410_GPE7, S3C2410_GPE7_SDDAT0); 
    1165 +                       s3c2410_gpio_cfgpin(S3C2410_GPE8, S3C2410_GPE8_SDDAT1); 
    1166 +                       s3c2410_gpio_cfgpin(S3C2410_GPE9, S3C2410_GPE9_SDDAT2); 
    1167 +                       s3c2410_gpio_cfgpin(S3C2410_GPE10, S3C2410_GPE10_SDDAT3); 
    1168 + 
    1169 +                       if (host->pdata->set_power) 
    1170 +                               host->pdata->set_power(ios->power_mode, ios->vdd); 
    1171 + 
    1172 +                       if (!host->is2440) 
    1173 +                               mci_con|=S3C2410_SDICON_FIFORESET; 
    1174 + 
    1175 +                       break; 
    1176 + 
    1177 +               case MMC_POWER_OFF: 
    1178 +               default: 
    1179 +                       s3c2410_gpio_setpin(S3C2410_GPE5, 0); 
    1180 +                       s3c2410_gpio_cfgpin(S3C2410_GPE5, S3C2410_GPE5_OUTP); 
    1181 + 
    1182 +                       if (host->pdata->set_power) 
    1183 +                               host->pdata->set_power(ios->power_mode, ios->vdd); 
    1184 + 
    1185 +                       if (host->is2440) 
    1186 +                               mci_con|=S3C2440_SDICON_SDRESET; 
    1187 + 
    1188 +                       break; 
    1189 +       } 
    1190 + 
    1191 +       //Set clock 
    1192 +       for (mci_psc=0; mci_psc<255; mci_psc++) { 
     1112+       switch (ios->power_mode) { 
     1113+       case MMC_POWER_ON: 
     1114+       case MMC_POWER_UP: 
     1115+               s3c2410_gpio_cfgpin(S3C2410_GPE5, S3C2410_GPE5_SDCLK); 
     1116+               s3c2410_gpio_cfgpin(S3C2410_GPE6, S3C2410_GPE6_SDCMD); 
     1117+               s3c2410_gpio_cfgpin(S3C2410_GPE7, S3C2410_GPE7_SDDAT0); 
     1118+               s3c2410_gpio_cfgpin(S3C2410_GPE8, S3C2410_GPE8_SDDAT1); 
     1119+               s3c2410_gpio_cfgpin(S3C2410_GPE9, S3C2410_GPE9_SDDAT2); 
     1120+               s3c2410_gpio_cfgpin(S3C2410_GPE10, S3C2410_GPE10_SDDAT3); 
     1121+ 
     1122+               if (host->pdata->set_power) 
     1123+                       host->pdata->set_power(ios->power_mode, ios->vdd); 
     1124+ 
     1125+               if (!host->is2440) 
     1126+                       mci_con |= S3C2410_SDICON_FIFORESET; 
     1127+ 
     1128+               break; 
     1129+ 
     1130+       case MMC_POWER_OFF: 
     1131+       default: 
     1132+               s3c2410_gpio_setpin(S3C2410_GPE5, 0); 
     1133+               s3c2410_gpio_cfgpin(S3C2410_GPE5, S3C2410_GPE5_OUTP); 
     1134+ 
     1135+               if (host->pdata->set_power) 
     1136+                       host->pdata->set_power(ios->power_mode, ios->vdd); 
     1137+ 
     1138+               if (host->is2440) 
     1139+                       mci_con |= S3C2440_SDICON_SDRESET; 
     1140+ 
     1141+               break; 
     1142+       } 
     1143+ 
     1144+       /* Set clock */ 
     1145+       for (mci_psc = 0; mci_psc < 255; mci_psc++) { 
    11931146+               host->real_rate = host->clk_rate / (host->clk_div*(mci_psc+1)); 
    11941147+ 
     
    11971150+       } 
    11981151+ 
    1199 +       if(mci_psc > 255) mci_psc = 255; 
     1152+       if (mci_psc > 255) 
     1153+               mci_psc = 255; 
    12001154+       host->prescaler = mci_psc; 
    12011155+ 
    12021156+       writel(host->prescaler, host->base + S3C2410_SDIPRE); 
    12031157+ 
    1204 +       //If requested clock is 0, real_rate will be 0, too 
     1158+       /* If requested clock is 0, real_rate will be 0, too */ 
    12051159+       if (ios->clock == 0) 
    12061160+               host->real_rate = 0; 
    12071161+ 
    1208 +       //Set CLOCK_ENABLE 
     1162+       /* Set CLOCK_ENABLE */ 
    12091163+       if (ios->clock) 
    12101164+               mci_con |= S3C2410_SDICON_CLOCKTYPE; 
    12111165+       else 
    1212 +               mci_con &=~S3C2410_SDICON_CLOCKTYPE; 
     1166+               mci_con &= ~S3C2410_SDICON_CLOCKTYPE; 
    12131167+ 
    12141168+       writel(mci_con, host->base + S3C2410_SDICON); 
    12151169+ 
    1216 +       if ((ios->power_mode==MMC_POWER_ON) 
    1217 +               || (ios->power_mode==MMC_POWER_UP)) { 
     1170+       if ((ios->power_mode == MMC_POWER_ON) 
     1171+               || (ios->power_mode == MMC_POWER_UP)) { 
    12181172+ 
    12191173+               dbg(host, dbg_conf, "running at %lukHz (requested: %ukHz).\n", 
    1220 +                       host->real_rate/1000, ios->clock/1000); 
     1174+                   host->real_rate/1000, ios->clock/1000); 
    12211175+       } else { 
    12221176+               dbg(host, dbg_conf, "powered down.\n"); 
     
    13711325+       } 
    13721326+ 
    1373 +       if ((ret = clk_enable(host->clk))) { 
     1327+       ret = clk_enable(host->clk); 
     1328+       if (ret) { 
    13741329+               dev_err(&pdev->dev, "failed to enable clock source.\n"); 
    13751330+               goto clk_free; 
     
    13921347+       mmc->max_hw_segs        = 128; 
    13931348+ 
    1394 +       dbg(host, dbg_debug, "probe: mode:%s mapped mci_base:%p irq:%u irq_cd:%u dma:%u.\n", 
    1395 +               (host->is2440?"2440":""), 
    1396 +               host->base, host->irq, host->irq_cd, host->dma); 
    1397 + 
    1398 +       if ((ret = mmc_add_host(mmc))) { 
     1349+       dbg(host, dbg_debug, "probe: mode:%s mapped mci_base:%p irq:%u " 
     1350+           "irq_cd:%u dma:%u.\n", (host->is2440?"2440":""), 
     1351+           host->base, host->irq, host->irq_cd, host->dma); 
     1352+ 
     1353+       ret = mmc_add_host(mmc); 
     1354+       if (ret) { 
    13991355+               dev_err(&pdev->dev, "failed to add mmc host.\n"); 
    14001356+               goto free_dmabuf; 
     
    14031359+       platform_set_drvdata(pdev, mmc); 
    14041360+ 
    1405 +       dev_info(&pdev->dev,"initialisation done.\n"); 
     1361+       dev_info(&pdev->dev, "initialisation done.\n"); 
    14061362+       return 0; 
    14071363+ 
     
    14131369+ 
    14141370+ probe_free_irq_cd: 
    1415 +       free_irq(host->irq_cd, host); 
     1371+       free_irq(host->irq_cd, host); 
    14161372+ 
    14171373+ probe_free_irq: 
    1418 +       free_irq(host->irq, host); 
     1374+       free_irq(host->irq, host); 
    14191375+ 
    14201376+ probe_iounmap: 
     
    14391395+       clk_put(host->clk); 
    14401396+       s3c2410_dma_free(S3CMCI_DMA, &s3cmci_dma_client); 
    1441 +       free_irq(host->irq_cd, host); 
    1442 +       free_irq(host->irq, host); 
     1397+       free_irq(host->irq_cd, host); 
     1398+       free_irq(host->irq, host); 
    14431399+       iounmap(host->base); 
    14441400+       release_mem_region(host->mem->start, RESSIZE(host->mem)); 
     
    14851441+ 
    14861442+ 
    1487 +static struct platform_driver s3cmci_driver_2410 = 
    1488 +{ 
     1443+static struct platform_driver s3cmci_driver_2410 = { 
    14891444+       .driver.name    = "s3c2410-sdi", 
    14901445+       .probe          = s3cmci_probe_2410, 
     
    14941449+}; 
    14951450+ 
    1496 +static struct platform_driver s3cmci_driver_2412 = 
    1497 +{ 
     1451+static struct platform_driver s3cmci_driver_2412 = { 
    14981452+       .driver.name    = "s3c2412-sdi", 
    14991453+       .probe          = s3cmci_probe_2412, 
     
    15031457+}; 
    15041458+ 
    1505 +static struct platform_driver s3cmci_driver_2440 = 
    1506 +{ 
     1459+static struct platform_driver s3cmci_driver_2440 = { 
    15071460+       .driver.name    = "s3c2440-sdi", 
    15081461+       .probe          = s3cmci_probe_2440, 
     
    15391492--- /dev/null 
    15401493+++ linux-2.6/drivers/mmc/host/s3cmci.h 
    1541 @@ -0,0 +1,72 @@ 
     1494@@ -0,0 +1,71 @@ 
    15421495+/* 
    15431496+ *  linux/drivers/mmc/s3cmci.h - Samsung S3C MCI driver 
     
    15501503+ */ 
    15511504+ 
    1552 +//FIXME: DMA Resource management ?! 
     1505+/* FIXME: DMA Resource management ?! */ 
    15531506+#define S3CMCI_DMA 0 
    15541507+ 
     
    15831536+       int                     dodma; 
    15841537+ 
    1585 +       volatile int            dmatogo; 
     1538+       int                     dmatogo; 
    15861539+ 
    15871540+       struct mmc_request      *mrq; 
     
    15891542+ 
    15901543+       spinlock_t              complete_lock; 
    1591 +       volatile enum s3cmci_waitfor 
    1592 +                               complete_what; 
    1593 + 
    1594 +       volatile int            dma_complete; 
    1595 + 
    1596 +       volatile u32            pio_sgptr; 
    1597 +       volatile u32            pio_words; 
    1598 +       volatile u32            pio_count; 
    1599 +       volatile u32            *pio_ptr; 
     1544+       enum s3cmci_waitfor     complete_what; 
     1545+ 
     1546+       int                     dma_complete; 
     1547+ 
     1548+       u32                     pio_sgptr; 
     1549+       u32                     pio_words; 
     1550+       u32                     pio_count; 
     1551+       u32                     *pio_ptr; 
    16001552+#define XFER_NONE 0 
    16011553+#define XFER_READ 1 
    16021554+#define XFER_WRITE 2 
    1603 +       volatile u32            pio_active; 
     1555+       u32                     pio_active; 
    16041556+ 
    16051557+       int                     bus_width; 
     
    16071559+       char                    dbgmsg_cmd[301]; 
    16081560+       char                    dbgmsg_dat[301]; 
    1609 +       volatile char           *status; 
     1561+       char                    *status; 
    16101562+ 
    16111563+       unsigned int            ccnt, dcnt; 
     
    16351587--- linux-2.6.orig/drivers/mmc/host/Makefile 
    16361588+++ linux-2.6/drivers/mmc/host/Makefile 
    1637 @@ -17,4 +17,5 @@ 
     1589@@ -17,4 +17,4 @@ 
    16381590 obj-$(CONFIG_MMC_AT91)         += at91_mci.o 
    16391591 obj-$(CONFIG_MMC_TIFM_SD)      += tifm_sd.o 
     
    16411593- 
    16421594+obj-$(CONFIG_MMC_S3C)          += s3cmci.o 
    1643 +obj-$(CONFIG_MMC)              += mmc_debug.o 
Note: See TracChangeset for help on using the changeset viewer.