@@ -261,11 +261,13 @@ static const struct sdhci_pci_fixes sdhci_intel_pch_sdio = {
261
261
262
262
enum {
263
263
INTEL_DSM_FNS = 0 ,
264
+ INTEL_DSM_DRV_STRENGTH = 9 ,
264
265
INTEL_DSM_D3_RETUNE = 10 ,
265
266
};
266
267
267
268
struct intel_host {
268
269
u32 dsm_fns ;
270
+ int drv_strength ;
269
271
bool d3_retune ;
270
272
};
271
273
@@ -326,6 +328,9 @@ static void intel_dsm_init(struct intel_host *intel_host, struct device *dev,
326
328
pr_debug ("%s: DSM function mask %#x\n" ,
327
329
mmc_hostname (mmc ), intel_host -> dsm_fns );
328
330
331
+ err = intel_dsm (intel_host , dev , INTEL_DSM_DRV_STRENGTH , & val );
332
+ intel_host -> drv_strength = err ? 0 : val ;
333
+
329
334
err = intel_dsm (intel_host , dev , INTEL_DSM_D3_RETUNE , & val );
330
335
intel_host -> d3_retune = err ? true : !!val ;
331
336
}
@@ -345,67 +350,15 @@ static void sdhci_pci_int_hw_reset(struct sdhci_host *host)
345
350
usleep_range (300 , 1000 );
346
351
}
347
352
348
- static int spt_select_drive_strength (struct sdhci_host * host ,
349
- struct mmc_card * card ,
350
- unsigned int max_dtr ,
351
- int host_drv , int card_drv , int * drv_type )
353
+ static int intel_select_drive_strength (struct mmc_card * card ,
354
+ unsigned int max_dtr , int host_drv ,
355
+ int card_drv , int * drv_type )
352
356
{
353
- int drive_strength ;
354
-
355
- if (sdhci_pci_spt_drive_strength > 0 )
356
- drive_strength = sdhci_pci_spt_drive_strength & 0xf ;
357
- else
358
- drive_strength = 0 ; /* Default 50-ohm */
359
-
360
- if ((mmc_driver_type_mask (drive_strength ) & card_drv ) == 0 )
361
- drive_strength = 0 ; /* Default 50-ohm */
362
-
363
- return drive_strength ;
364
- }
365
-
366
- /* Try to read the drive strength from the card */
367
- static void spt_read_drive_strength (struct sdhci_host * host )
368
- {
369
- u32 val , i , t ;
370
- u16 m ;
371
-
372
- if (sdhci_pci_spt_drive_strength )
373
- return ;
374
-
375
- sdhci_pci_spt_drive_strength = -1 ;
376
-
377
- m = sdhci_readw (host , SDHCI_HOST_CONTROL2 ) & 0x7 ;
378
- if (m != 3 && m != 5 )
379
- return ;
380
- val = sdhci_readl (host , SDHCI_PRESENT_STATE );
381
- if (val & 0x3 )
382
- return ;
383
- sdhci_writel (host , 0x007f0023 , SDHCI_INT_ENABLE );
384
- sdhci_writel (host , 0 , SDHCI_SIGNAL_ENABLE );
385
- sdhci_writew (host , 0x10 , SDHCI_TRANSFER_MODE );
386
- sdhci_writeb (host , 0xe , SDHCI_TIMEOUT_CONTROL );
387
- sdhci_writew (host , 512 , SDHCI_BLOCK_SIZE );
388
- sdhci_writew (host , 1 , SDHCI_BLOCK_COUNT );
389
- sdhci_writel (host , 0 , SDHCI_ARGUMENT );
390
- sdhci_writew (host , 0x83b , SDHCI_COMMAND );
391
- for (i = 0 ; i < 1000 ; i ++ ) {
392
- val = sdhci_readl (host , SDHCI_INT_STATUS );
393
- if (val & 0xffff8000 )
394
- return ;
395
- if (val & 0x20 )
396
- break ;
397
- udelay (1 );
398
- }
399
- val = sdhci_readl (host , SDHCI_PRESENT_STATE );
400
- if (!(val & 0x800 ))
401
- return ;
402
- for (i = 0 ; i < 47 ; i ++ )
403
- val = sdhci_readl (host , SDHCI_BUFFER );
404
- t = val & 0xf00 ;
405
- if (t != 0x200 && t != 0x300 )
406
- return ;
357
+ struct sdhci_host * host = mmc_priv (card -> host );
358
+ struct sdhci_pci_slot * slot = sdhci_priv (host );
359
+ struct intel_host * intel_host = sdhci_pci_priv (slot );
407
360
408
- sdhci_pci_spt_drive_strength = 0x10 | (( val >> 12 ) & 0xf ) ;
361
+ return intel_host -> drv_strength ;
409
362
}
410
363
411
364
static int bxt_get_cd (struct mmc_host * mmc )
@@ -451,10 +404,8 @@ static int byt_emmc_probe_slot(struct sdhci_pci_slot *slot)
451
404
slot -> hw_reset = sdhci_pci_int_hw_reset ;
452
405
if (slot -> chip -> pdev -> device == PCI_DEVICE_ID_INTEL_BSW_EMMC )
453
406
slot -> host -> timeout_clk = 1000 ; /* 1000 kHz i.e. 1 MHz */
454
- if (slot -> chip -> pdev -> device == PCI_DEVICE_ID_INTEL_SPT_EMMC ) {
455
- spt_read_drive_strength (slot -> host );
456
- slot -> select_drive_strength = spt_select_drive_strength ;
457
- }
407
+ slot -> host -> mmc_host_ops .select_drive_strength =
408
+ intel_select_drive_strength ;
458
409
return 0 ;
459
410
}
460
411
0 commit comments