Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

mmc: sdhci-pci-o2micro: add Bayhub new chip GG8 support for UHS-I

Add Bayhub new chip GG8 support for UHS-I function

Signed-off-by: Chevron Li <chevron.li@bayhubtech.com>
Acked-by: Adrian Hunter <adrian.hunter@intel.com>
Link: https://lore.kernel.org/r/20230811033517.11532-1-chevron_li@126.com
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>

authored by

Chevron Li and committed by
Ulf Hansson
3d757ddb b4120b69

+118 -34
+4
drivers/mmc/host/sdhci-pci-core.c
··· 1898 1898 SDHCI_PCI_DEVICE(O2, SDS1, o2), 1899 1899 SDHCI_PCI_DEVICE(O2, SEABIRD0, o2), 1900 1900 SDHCI_PCI_DEVICE(O2, SEABIRD1, o2), 1901 + SDHCI_PCI_DEVICE(O2, GG8_9860, o2), 1902 + SDHCI_PCI_DEVICE(O2, GG8_9861, o2), 1903 + SDHCI_PCI_DEVICE(O2, GG8_9862, o2), 1904 + SDHCI_PCI_DEVICE(O2, GG8_9863, o2), 1901 1905 SDHCI_PCI_DEVICE(ARASAN, PHY_EMMC, arasan), 1902 1906 SDHCI_PCI_DEVICE(SYNOPSYS, DWC_MSHC, snps), 1903 1907 SDHCI_PCI_DEVICE(GLI, 9750, gl9750),
+110 -34
drivers/mmc/host/sdhci-pci-o2micro.c
··· 36 36 #define O2_SD_INF_MOD 0xF1 37 37 #define O2_SD_MISC_CTRL4 0xFC 38 38 #define O2_SD_MISC_CTRL 0x1C0 39 + #define O2_SD_EXP_INT_REG 0x1E0 39 40 #define O2_SD_PWR_FORCE_L0 0x0002 40 41 #define O2_SD_TUNING_CTRL 0x300 41 42 #define O2_SD_PLL_SETTING 0x304 ··· 50 49 #define O2_SD_UHS2_L1_CTRL 0x35C 51 50 #define O2_SD_FUNC_REG3 0x3E0 52 51 #define O2_SD_FUNC_REG4 0x3E4 52 + #define O2_SD_PARA_SET_REG1 0x444 53 + #define O2_SD_VDDX_CTRL_REG 0x508 54 + #define O2_SD_GPIO_CTRL_REG1 0x510 53 55 #define O2_SD_LED_ENABLE BIT(6) 54 56 #define O2_SD_FREG0_LEDOFF BIT(13) 55 57 #define O2_SD_SEL_DLL BIT(16) ··· 338 334 scratch |= O2_SD_PWR_FORCE_L0; 339 335 sdhci_writew(host, scratch, O2_SD_MISC_CTRL); 340 336 341 - /* Stop clk */ 342 - reg_val = sdhci_readw(host, SDHCI_CLOCK_CONTROL); 343 - reg_val &= ~SDHCI_CLOCK_CARD_EN; 344 - sdhci_writew(host, reg_val, SDHCI_CLOCK_CONTROL); 337 + /* Update output phase */ 338 + switch (chip->pdev->device) { 339 + case PCI_DEVICE_ID_O2_SDS0: 340 + case PCI_DEVICE_ID_O2_SEABIRD0: 341 + case PCI_DEVICE_ID_O2_SEABIRD1: 342 + case PCI_DEVICE_ID_O2_SDS1: 343 + case PCI_DEVICE_ID_O2_FUJIN2: 344 + /* Stop clk */ 345 + reg_val = sdhci_readw(host, SDHCI_CLOCK_CONTROL); 346 + reg_val &= ~SDHCI_CLOCK_CARD_EN; 347 + sdhci_writew(host, reg_val, SDHCI_CLOCK_CONTROL); 345 348 346 - if ((host->timing == MMC_TIMING_MMC_HS200) || 347 - (host->timing == MMC_TIMING_UHS_SDR104)) { 348 - /* UnLock WP */ 349 - pci_read_config_byte(chip->pdev, O2_SD_LOCK_WP, &scratch_8); 350 - scratch_8 &= 0x7f; 351 - pci_write_config_byte(chip->pdev, O2_SD_LOCK_WP, scratch_8); 349 + if (host->timing == MMC_TIMING_MMC_HS200 || 350 + host->timing == MMC_TIMING_UHS_SDR104) { 351 + /* UnLock WP */ 352 + pci_read_config_byte(chip->pdev, O2_SD_LOCK_WP, &scratch_8); 353 + scratch_8 &= 0x7f; 354 + pci_write_config_byte(chip->pdev, O2_SD_LOCK_WP, scratch_8); 352 355 353 - /* Set pcr 0x354[16] to choose dll clock, and set the default phase */ 354 - pci_read_config_dword(chip->pdev, O2_SD_OUTPUT_CLK_SOURCE_SWITCH, &reg_val); 355 - reg_val &= ~(O2_SD_SEL_DLL | O2_SD_PHASE_MASK); 356 - reg_val |= (O2_SD_SEL_DLL | O2_SD_FIX_PHASE); 357 - pci_write_config_dword(chip->pdev, O2_SD_OUTPUT_CLK_SOURCE_SWITCH, reg_val); 356 + /* Set pcr 0x354[16] to choose dll clock, and set the default phase */ 357 + pci_read_config_dword(chip->pdev, O2_SD_OUTPUT_CLK_SOURCE_SWITCH, &reg_val); 358 + reg_val &= ~(O2_SD_SEL_DLL | O2_SD_PHASE_MASK); 359 + reg_val |= (O2_SD_SEL_DLL | O2_SD_FIX_PHASE); 360 + pci_write_config_dword(chip->pdev, O2_SD_OUTPUT_CLK_SOURCE_SWITCH, reg_val); 358 361 359 - /* Lock WP */ 360 - pci_read_config_byte(chip->pdev, O2_SD_LOCK_WP, &scratch_8); 361 - scratch_8 |= 0x80; 362 - pci_write_config_byte(chip->pdev, O2_SD_LOCK_WP, scratch_8); 362 + /* Lock WP */ 363 + pci_read_config_byte(chip->pdev, O2_SD_LOCK_WP, &scratch_8); 364 + scratch_8 |= 0x80; 365 + pci_write_config_byte(chip->pdev, O2_SD_LOCK_WP, scratch_8); 366 + } 367 + 368 + /* Start clk */ 369 + reg_val = sdhci_readw(host, SDHCI_CLOCK_CONTROL); 370 + reg_val |= SDHCI_CLOCK_CARD_EN; 371 + sdhci_writew(host, reg_val, SDHCI_CLOCK_CONTROL); 372 + break; 373 + default: 374 + break; 363 375 } 364 - /* Start clk */ 365 - reg_val = sdhci_readw(host, SDHCI_CLOCK_CONTROL); 366 - reg_val |= SDHCI_CLOCK_CARD_EN; 367 - sdhci_writew(host, reg_val, SDHCI_CLOCK_CONTROL); 368 376 369 377 /* wait DLL lock, timeout value 5ms */ 370 378 if (readx_poll_timeout(sdhci_o2_pll_dll_wdt_control, host, ··· 579 563 u16 clk; 580 564 u8 scratch; 581 565 u32 scratch_32; 566 + u32 dmdn_208m, dmdn_200m; 582 567 struct sdhci_pci_slot *slot = sdhci_priv(host); 583 568 struct sdhci_pci_chip *chip = slot->chip; 584 569 ··· 595 578 scratch &= 0x7f; 596 579 pci_write_config_byte(chip->pdev, O2_SD_LOCK_WP, scratch); 597 580 581 + if (chip->pdev->device == PCI_DEVICE_ID_O2_GG8_9860 || 582 + chip->pdev->device == PCI_DEVICE_ID_O2_GG8_9861 || 583 + chip->pdev->device == PCI_DEVICE_ID_O2_GG8_9862 || 584 + chip->pdev->device == PCI_DEVICE_ID_O2_GG8_9863) { 585 + dmdn_208m = 0x2c500000; 586 + dmdn_200m = 0x25200000; 587 + } else { 588 + dmdn_208m = 0x2c280000; 589 + dmdn_200m = 0x25100000; 590 + } 591 + 598 592 if ((host->timing == MMC_TIMING_UHS_SDR104) && (clock == 200000000)) { 599 593 pci_read_config_dword(chip->pdev, O2_SD_PLL_SETTING, &scratch_32); 600 594 601 - if ((scratch_32 & 0xFFFF0000) != 0x2c280000) 602 - o2_pci_set_baseclk(chip, 0x2c280000); 595 + if ((scratch_32 & 0xFFFF0000) != dmdn_208m) 596 + o2_pci_set_baseclk(chip, dmdn_208m); 603 597 } else { 604 598 pci_read_config_dword(chip->pdev, O2_SD_PLL_SETTING, &scratch_32); 605 599 606 - if ((scratch_32 & 0xFFFF0000) != 0x25100000) 607 - o2_pci_set_baseclk(chip, 0x25100000); 600 + if ((scratch_32 & 0xFFFF0000) != dmdn_200m) 601 + o2_pci_set_baseclk(chip, dmdn_200m); 608 602 } 609 603 610 604 pci_read_config_dword(chip->pdev, O2_SD_OUTPUT_CLK_SOURCE_SWITCH, &scratch_32); ··· 652 624 if (caps & SDHCI_CAN_DO_8BIT) 653 625 host->mmc->caps |= MMC_CAP_8_BIT_DATA; 654 626 627 + host->quirks2 |= SDHCI_QUIRK2_BROKEN_DDR50; 628 + 629 + sdhci_pci_o2_enable_msi(chip, host); 630 + 631 + host->mmc_host_ops.execute_tuning = sdhci_o2_execute_tuning; 655 632 switch (chip->pdev->device) { 656 633 case PCI_DEVICE_ID_O2_SDS0: 657 634 case PCI_DEVICE_ID_O2_SEABIRD0: ··· 666 633 reg = sdhci_readl(host, O2_SD_VENDOR_SETTING); 667 634 if (reg & 0x1) 668 635 host->quirks |= SDHCI_QUIRK_MULTIBLOCK_READ_ACMD12; 669 - 670 - host->quirks2 |= SDHCI_QUIRK2_BROKEN_DDR50; 671 - 672 - sdhci_pci_o2_enable_msi(chip, host); 673 636 674 637 if (chip->pdev->device == PCI_DEVICE_ID_O2_SEABIRD0) { 675 638 ret = pci_read_config_dword(chip->pdev, ··· 692 663 host->quirks2 |= SDHCI_QUIRK2_PRESET_VALUE_BROKEN; 693 664 } 694 665 695 - host->mmc_host_ops.execute_tuning = sdhci_o2_execute_tuning; 696 - 697 666 if (chip->pdev->device != PCI_DEVICE_ID_O2_FUJIN2) 698 667 break; 699 668 /* set dll watch dog timer */ 700 669 reg = sdhci_readl(host, O2_SD_VENDOR_SETTING2); 701 670 reg |= (1 << 12); 702 671 sdhci_writel(host, reg, O2_SD_VENDOR_SETTING2); 703 - 672 + break; 673 + case PCI_DEVICE_ID_O2_GG8_9860: 674 + case PCI_DEVICE_ID_O2_GG8_9861: 675 + case PCI_DEVICE_ID_O2_GG8_9862: 676 + case PCI_DEVICE_ID_O2_GG8_9863: 677 + host->mmc->caps2 |= MMC_CAP2_NO_SDIO; 678 + host->mmc->caps |= MMC_CAP_HW_RESET; 679 + host->quirks2 |= SDHCI_QUIRK2_PRESET_VALUE_BROKEN; 680 + slot->host->mmc_host_ops.get_cd = sdhci_o2_get_cd; 704 681 break; 705 682 default: 706 683 break; ··· 719 684 { 720 685 int ret; 721 686 u8 scratch; 687 + u16 scratch16; 722 688 u32 scratch_32; 723 689 724 690 switch (chip->pdev->device) { ··· 924 888 /* Lock WP */ 925 889 ret = pci_read_config_byte(chip->pdev, 926 890 O2_SD_LOCK_WP, &scratch); 891 + if (ret) 892 + return ret; 893 + scratch |= 0x80; 894 + pci_write_config_byte(chip->pdev, O2_SD_LOCK_WP, scratch); 895 + break; 896 + case PCI_DEVICE_ID_O2_GG8_9860: 897 + case PCI_DEVICE_ID_O2_GG8_9861: 898 + case PCI_DEVICE_ID_O2_GG8_9862: 899 + case PCI_DEVICE_ID_O2_GG8_9863: 900 + /* UnLock WP */ 901 + ret = pci_read_config_byte(chip->pdev, O2_SD_LOCK_WP, &scratch); 902 + if (ret) 903 + return ret; 904 + scratch &= 0x7f; 905 + pci_write_config_byte(chip->pdev, O2_SD_LOCK_WP, scratch); 906 + 907 + /* Select mode switch source as software control */ 908 + pci_read_config_word(chip->pdev, O2_SD_PARA_SET_REG1, &scratch16); 909 + scratch16 &= 0xF8FF; 910 + scratch16 |= BIT(9); 911 + pci_write_config_word(chip->pdev, O2_SD_PARA_SET_REG1, scratch16); 912 + 913 + /* set VDD1 supply source */ 914 + pci_read_config_word(chip->pdev, O2_SD_VDDX_CTRL_REG, &scratch16); 915 + scratch16 &= 0xFFE3; 916 + scratch16 |= BIT(3); 917 + pci_write_config_word(chip->pdev, O2_SD_VDDX_CTRL_REG, scratch16); 918 + 919 + /* Set host drive strength*/ 920 + scratch16 = 0x0025; 921 + pci_write_config_word(chip->pdev, O2_SD_PLL_SETTING, scratch16); 922 + 923 + /* Set output delay*/ 924 + pci_read_config_dword(chip->pdev, O2_SD_OUTPUT_CLK_SOURCE_SWITCH, &scratch_32); 925 + scratch_32 &= 0xFF0FFF00; 926 + scratch_32 |= 0x00B0003B; 927 + pci_write_config_dword(chip->pdev, O2_SD_OUTPUT_CLK_SOURCE_SWITCH, scratch_32); 928 + 929 + /* Lock WP */ 930 + ret = pci_read_config_byte(chip->pdev, O2_SD_LOCK_WP, &scratch); 927 931 if (ret) 928 932 return ret; 929 933 scratch |= 0x80;
+4
drivers/mmc/host/sdhci-pci.h
··· 11 11 #define PCI_DEVICE_ID_O2_FUJIN2 0x8520 12 12 #define PCI_DEVICE_ID_O2_SEABIRD0 0x8620 13 13 #define PCI_DEVICE_ID_O2_SEABIRD1 0x8621 14 + #define PCI_DEVICE_ID_O2_GG8_9860 0x9860 15 + #define PCI_DEVICE_ID_O2_GG8_9861 0x9861 16 + #define PCI_DEVICE_ID_O2_GG8_9862 0x9862 17 + #define PCI_DEVICE_ID_O2_GG8_9863 0x9863 14 18 15 19 #define PCI_DEVICE_ID_INTEL_PCH_SDIO0 0x8809 16 20 #define PCI_DEVICE_ID_INTEL_PCH_SDIO1 0x880a