aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mfd/rts5229.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/mfd/rts5229.c')
-rw-r--r--drivers/mfd/rts5229.c38
1 files changed, 35 insertions, 3 deletions
diff --git a/drivers/mfd/rts5229.c b/drivers/mfd/rts5229.c
index 58af4dbe3586..7a1ad6dd2917 100644
--- a/drivers/mfd/rts5229.c
+++ b/drivers/mfd/rts5229.c
@@ -34,6 +34,28 @@ static u8 rts5229_get_ic_version(struct rtsx_pcr *pcr)
34 return val & 0x0F; 34 return val & 0x0F;
35} 35}
36 36
37static void rts5229_fetch_vendor_settings(struct rtsx_pcr *pcr)
38{
39 u32 reg;
40
41 rtsx_pci_read_config_dword(pcr, PCR_SETTING_REG1, &reg);
42 dev_dbg(&(pcr->pci->dev), "Cfg 0x%x: 0x%x\n", PCR_SETTING_REG1, reg);
43
44 if (!rtsx_vendor_setting_valid(reg))
45 return;
46
47 pcr->aspm_en = rtsx_reg_to_aspm(reg);
48 pcr->sd30_drive_sel_1v8 =
49 map_sd_drive(rtsx_reg_to_sd30_drive_sel_1v8(reg));
50 pcr->card_drive_sel &= 0x3F;
51 pcr->card_drive_sel |= rtsx_reg_to_card_drive_sel(reg);
52
53 rtsx_pci_read_config_dword(pcr, PCR_SETTING_REG2, &reg);
54 dev_dbg(&(pcr->pci->dev), "Cfg 0x%x: 0x%x\n", PCR_SETTING_REG2, reg);
55 pcr->sd30_drive_sel_3v3 =
56 map_sd_drive(rtsx_reg_to_sd30_drive_sel_3v3(reg));
57}
58
37static int rts5229_extra_init_hw(struct rtsx_pcr *pcr) 59static int rts5229_extra_init_hw(struct rtsx_pcr *pcr)
38{ 60{
39 rtsx_pci_init_cmd(pcr); 61 rtsx_pci_init_cmd(pcr);
@@ -45,6 +67,9 @@ static int rts5229_extra_init_hw(struct rtsx_pcr *pcr)
45 rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, LDO_PWR_SEL, 0x03, 0x01); 67 rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, LDO_PWR_SEL, 0x03, 0x01);
46 /* LED shine disabled, set initial shine cycle period */ 68 /* LED shine disabled, set initial shine cycle period */
47 rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, OLT_LED_CTL, 0x0F, 0x02); 69 rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, OLT_LED_CTL, 0x0F, 0x02);
70 /* Configure driving */
71 rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, SD30_DRIVE_SEL,
72 0xFF, pcr->sd30_drive_sel_3v3);
48 73
49 return rtsx_pci_send_cmd(pcr, 100); 74 return rtsx_pci_send_cmd(pcr, 100);
50} 75}
@@ -110,7 +135,7 @@ static int rts5229_card_power_off(struct rtsx_pcr *pcr, int card)
110 SD_POWER_MASK | PMOS_STRG_MASK, 135 SD_POWER_MASK | PMOS_STRG_MASK,
111 SD_POWER_OFF | PMOS_STRG_400mA); 136 SD_POWER_OFF | PMOS_STRG_400mA);
112 rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, PWR_GATE_CTRL, 137 rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, PWR_GATE_CTRL,
113 LDO3318_PWR_MASK, 0X00); 138 LDO3318_PWR_MASK, 0x00);
114 return rtsx_pci_send_cmd(pcr, 100); 139 return rtsx_pci_send_cmd(pcr, 100);
115} 140}
116 141
@@ -120,7 +145,7 @@ static int rts5229_switch_output_voltage(struct rtsx_pcr *pcr, u8 voltage)
120 145
121 if (voltage == OUTPUT_3V3) { 146 if (voltage == OUTPUT_3V3) {
122 err = rtsx_pci_write_register(pcr, 147 err = rtsx_pci_write_register(pcr,
123 SD30_DRIVE_SEL, 0x07, DRIVER_TYPE_D); 148 SD30_DRIVE_SEL, 0x07, pcr->sd30_drive_sel_3v3);
124 if (err < 0) 149 if (err < 0)
125 return err; 150 return err;
126 err = rtsx_pci_write_phy_register(pcr, 0x08, 0x4FC0 | 0x24); 151 err = rtsx_pci_write_phy_register(pcr, 0x08, 0x4FC0 | 0x24);
@@ -128,7 +153,7 @@ static int rts5229_switch_output_voltage(struct rtsx_pcr *pcr, u8 voltage)
128 return err; 153 return err;
129 } else if (voltage == OUTPUT_1V8) { 154 } else if (voltage == OUTPUT_1V8) {
130 err = rtsx_pci_write_register(pcr, 155 err = rtsx_pci_write_register(pcr,
131 SD30_DRIVE_SEL, 0x07, DRIVER_TYPE_B); 156 SD30_DRIVE_SEL, 0x07, pcr->sd30_drive_sel_1v8);
132 if (err < 0) 157 if (err < 0)
133 return err; 158 return err;
134 err = rtsx_pci_write_phy_register(pcr, 0x08, 0x4C40 | 0x24); 159 err = rtsx_pci_write_phy_register(pcr, 0x08, 0x4C40 | 0x24);
@@ -142,6 +167,7 @@ static int rts5229_switch_output_voltage(struct rtsx_pcr *pcr, u8 voltage)
142} 167}
143 168
144static const struct pcr_ops rts5229_pcr_ops = { 169static const struct pcr_ops rts5229_pcr_ops = {
170 .fetch_vendor_settings = rts5229_fetch_vendor_settings,
145 .extra_init_hw = rts5229_extra_init_hw, 171 .extra_init_hw = rts5229_extra_init_hw,
146 .optimize_phy = rts5229_optimize_phy, 172 .optimize_phy = rts5229_optimize_phy,
147 .turn_on_led = rts5229_turn_on_led, 173 .turn_on_led = rts5229_turn_on_led,
@@ -221,6 +247,12 @@ void rts5229_init_params(struct rtsx_pcr *pcr)
221 pcr->num_slots = 2; 247 pcr->num_slots = 2;
222 pcr->ops = &rts5229_pcr_ops; 248 pcr->ops = &rts5229_pcr_ops;
223 249
250 pcr->flags = 0;
251 pcr->card_drive_sel = RTSX_CARD_DRIVE_DEFAULT;
252 pcr->sd30_drive_sel_1v8 = DRIVER_TYPE_B;
253 pcr->sd30_drive_sel_3v3 = DRIVER_TYPE_D;
254 pcr->aspm_en = ASPM_L1_EN;
255
224 pcr->ic_version = rts5229_get_ic_version(pcr); 256 pcr->ic_version = rts5229_get_ic_version(pcr);
225 if (pcr->ic_version == IC_VER_C) { 257 if (pcr->ic_version == IC_VER_C) {
226 pcr->sd_pull_ctl_enable_tbl = rts5229_sd_pull_ctl_enable_tbl2; 258 pcr->sd_pull_ctl_enable_tbl = rts5229_sd_pull_ctl_enable_tbl2;