Linux kernel & device driver programming

Cross-Referenced Linux and Device Driver Code

[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ]
Version: [ 2.6.11.8 ] [ 2.6.25 ] [ 2.6.25.8 ] [ 2.6.31.13 ] Architecture: [ i386 ]

Diff markup

Differences between /linux/drivers/ide/tx4938ide.c (Version 2.6.31.13) and /linux/drivers/ide/tx4938ide.c (Version 2.6.25)


  1 /*                                                  1 
  2  * TX4938 internal IDE driver                     
  3  * Based on tx4939ide.c.                          
  4  *                                                
  5  * This file is subject to the terms and condi    
  6  * License.  See the file "COPYING" in the mai    
  7  * for more details.                              
  8  *                                                
  9  * (C) Copyright TOSHIBA CORPORATION 2005-2007    
 10  */                                               
 11                                                   
 12 #include <linux/module.h>                         
 13 #include <linux/types.h>                          
 14 #include <linux/ide.h>                            
 15 #include <linux/init.h>                           
 16 #include <linux/platform_device.h>                
 17 #include <linux/io.h>                             
 18                                                   
 19 #include <asm/ide.h>                              
 20 #include <asm/txx9/tx4938.h>                      
 21                                                   
 22 static void tx4938ide_tune_ebusc(unsigned int     
 23                                  unsigned int     
 24                                  u8 pio)          
 25 {                                                 
 26         struct ide_timing *t = ide_timing_find    
 27         u64 cr = __raw_readq(&tx4938_ebuscptr-    
 28         unsigned int sp = (cr >> 4) & 3;          
 29         unsigned int clock = gbus_clock / (4 -    
 30         unsigned int cycle = 1000000000 / cloc    
 31         unsigned int shwt;                        
 32         int wt;                                   
 33                                                   
 34         /* Minimum DIOx- active time */           
 35         wt = DIV_ROUND_UP(t->act8b, cycle) - 2    
 36         /* IORDY setup time: 35ns */              
 37         wt = max_t(int, wt, DIV_ROUND_UP(35, c    
 38         /* actual wait-cycle is max(wt & ~1, 1    
 39         if (wt > 2 && (wt & 1))                   
 40                 wt++;                             
 41         wt &= ~1;                                 
 42         /* Address-valid to DIOR/DIOW setup */    
 43         shwt = DIV_ROUND_UP(t->setup, cycle);     
 44                                                   
 45         /* -DIOx recovery time (SHWT * 4) and     
 46         while ((shwt * 4 + wt + (wt ? 2 : 3))     
 47                 shwt++;                           
 48         if (shwt > 7) {                           
 49                 pr_warning("tx4938ide: SHWT vi    
 50                 shwt = 7;                         
 51         }                                         
 52         pr_debug("tx4938ide: ebus %d, bus cycl    
 53                  ebus_ch, cycle, wt, shwt);       
 54                                                   
 55         __raw_writeq((cr & ~0x3f007ull) | (wt     
 56                      &tx4938_ebuscptr->cr[ebus    
 57 }                                                 
 58                                                   
 59 static void tx4938ide_set_pio_mode(ide_drive_t    
 60 {                                                 
 61         ide_hwif_t *hwif = drive->hwif;           
 62         struct tx4938ide_platform_info *pdata     
 63         u8 safe = pio;                            
 64         ide_drive_t *pair;                        
 65                                                   
 66         pair = ide_get_pair_dev(drive);           
 67         if (pair)                                 
 68                 safe = min(safe, ide_get_best_    
 69         tx4938ide_tune_ebusc(pdata->ebus_ch, p    
 70 }                                                 
 71                                                   
 72 #ifdef __BIG_ENDIAN                               
 73                                                   
 74 /* custom iops (independent from SWAP_IO_SPACE    
 75 static void tx4938ide_input_data_swap(ide_driv    
 76                                 void *buf, uns    
 77 {                                                 
 78         unsigned long port = drive->hwif->io_p    
 79         unsigned short *ptr = buf;                
 80         unsigned int count = (len + 1) / 2;       
 81                                                   
 82         while (count--)                           
 83                 *ptr++ = cpu_to_le16(__raw_rea    
 84         __ide_flush_dcache_range((unsigned lon    
 85 }                                                 
 86                                                   
 87 static void tx4938ide_output_data_swap(ide_dri    
 88                                 void *buf, uns    
 89 {                                                 
 90         unsigned long port = drive->hwif->io_p    
 91         unsigned short *ptr = buf;                
 92         unsigned int count = (len + 1) / 2;       
 93                                                   
 94         while (count--) {                         
 95                 __raw_writew(le16_to_cpu(*ptr)    
 96                 ptr++;                            
 97         }                                         
 98         __ide_flush_dcache_range((unsigned lon    
 99 }                                                 
100                                                   
101 static const struct ide_tp_ops tx4938ide_tp_op    
102         .exec_command           = ide_exec_com    
103         .read_status            = ide_read_sta    
104         .read_altstatus         = ide_read_alt    
105         .write_devctl           = ide_write_de    
106                                                   
107         .dev_select             = ide_dev_sele    
108         .tf_load                = ide_tf_load,    
109         .tf_read                = ide_tf_read,    
110                                                   
111         .input_data             = tx4938ide_in    
112         .output_data            = tx4938ide_ou    
113 };                                                
114                                                   
115 #endif  /* __BIG_ENDIAN */                        
116                                                   
117 static const struct ide_port_ops tx4938ide_por    
118         .set_pio_mode           = tx4938ide_se    
119 };                                                
120                                                   
121 static const struct ide_port_info tx4938ide_po    
122         .port_ops               = &tx4938ide_p    
123 #ifdef __BIG_ENDIAN                               
124         .tp_ops                 = &tx4938ide_t    
125 #endif                                            
126         .host_flags             = IDE_HFLAG_MM    
127         .pio_mask               = ATA_PIO5,       
128         .chipset                = ide_generic,    
129 };                                                
130                                                   
131 static int __init tx4938ide_probe(struct platf    
132 {                                                 
133         struct ide_hw hw, *hws[] = { &hw };       
134         struct ide_host *host;                    
135         struct resource *res;                     
136         struct tx4938ide_platform_info *pdata     
137         int irq, ret, i;                          
138         unsigned long mapbase, mapctl;            
139         struct ide_port_info d = tx4938ide_por    
140                                                   
141         irq = platform_get_irq(pdev, 0);          
142         if (irq < 0)                              
143                 return -ENODEV;                   
144         res = platform_get_resource(pdev, IORE    
145         if (!res)                                 
146                 return -ENODEV;                   
147                                                   
148         if (!devm_request_mem_region(&pdev->de    
149                                      res->end     
150                 return -EBUSY;                    
151         mapbase = (unsigned long)devm_ioremap(    
152                                                   
153         mapctl = (unsigned long)devm_ioremap(&    
154                                              r    
155                                              (    
156                                              1    
157         if (!mapbase || !mapctl)                  
158                 return -EBUSY;                    
159                                                   
160         memset(&hw, 0, sizeof(hw));               
161         if (pdata->ioport_shift) {                
162                 unsigned long port = mapbase;     
163                 unsigned long ctl = mapctl;       
164                                                   
165                 hw.io_ports_array[0] = port;      
166 #ifdef __BIG_ENDIAN                               
167                 port++;                           
168                 ctl++;                            
169 #endif                                            
170                 for (i = 1; i <= 7; i++)          
171                         hw.io_ports_array[i] =    
172                                 port + (i << p    
173                 hw.io_ports.ctl_addr = ctl;       
174         } else                                    
175                 ide_std_init_ports(&hw, mapbas    
176         hw.irq = irq;                             
177         hw.dev = &pdev->dev;                      
178                                                   
179         pr_info("TX4938 IDE interface (base %#    
180                 mapbase, mapctl, hw.irq);         
181         if (pdata->gbus_clock)                    
182                 tx4938ide_tune_ebusc(pdata->eb    
183         else                                      
184                 d.port_ops = NULL;                
185         ret = ide_host_add(&d, hws, 1, &host);    
186         if (!ret)                                 
187                 platform_set_drvdata(pdev, hos    
188         return ret;                               
189 }                                                 
190                                                   
191 static int __exit tx4938ide_remove(struct plat    
192 {                                                 
193         struct ide_host *host = platform_get_d    
194                                                   
195         ide_host_remove(host);                    
196         return 0;                                 
197 }                                                 
198                                                   
199 static struct platform_driver tx4938ide_driver    
200         .driver         = {                       
201                 .name   = "tx4938ide",            
202                 .owner  = THIS_MODULE,            
203         },                                        
204         .remove = __exit_p(tx4938ide_remove),     
205 };                                                
206                                                   
207 static int __init tx4938ide_init(void)            
208 {                                                 
209         return platform_driver_probe(&tx4938id    
210 }                                                 
211                                                   
212 static void __exit tx4938ide_exit(void)           
213 {                                                 
214         platform_driver_unregister(&tx4938ide_    
215 }                                                 
216                                                   
217 module_init(tx4938ide_init);                      
218 module_exit(tx4938ide_exit);                      
219                                                   
220 MODULE_DESCRIPTION("TX4938 internal IDE driver    
221 MODULE_LICENSE("GPL");                            
222 MODULE_ALIAS("platform:tx4938ide");               
223                                                   
  This page was automatically generated by the LXR engine.