aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/mfd/rtl8411.c132
-rw-r--r--drivers/mfd/rtsx_pcr.c5
-rw-r--r--drivers/mfd/rtsx_pcr.h1
-rw-r--r--include/linux/mfd/rtsx_pci.h1
4 files changed, 139 insertions, 0 deletions
diff --git a/drivers/mfd/rtl8411.c b/drivers/mfd/rtl8411.c
index 2a2d31687b72..c436bf27e78d 100644
--- a/drivers/mfd/rtl8411.c
+++ b/drivers/mfd/rtl8411.c
@@ -35,12 +35,33 @@ static u8 rtl8411_get_ic_version(struct rtsx_pcr *pcr)
35 return val & 0x0F; 35 return val & 0x0F;
36} 36}
37 37
38static int rtl8411b_is_qfn48(struct rtsx_pcr *pcr)
39{
40 u8 val = 0;
41
42 rtsx_pci_read_register(pcr, RTL8411B_PACKAGE_MODE, &val);
43
44 if (val & 0x2)
45 return 1;
46 else
47 return 0;
48}
49
38static int rtl8411_extra_init_hw(struct rtsx_pcr *pcr) 50static int rtl8411_extra_init_hw(struct rtsx_pcr *pcr)
39{ 51{
40 return rtsx_pci_write_register(pcr, CD_PAD_CTL, 52 return rtsx_pci_write_register(pcr, CD_PAD_CTL,
41 CD_DISABLE_MASK | CD_AUTO_DISABLE, CD_ENABLE); 53 CD_DISABLE_MASK | CD_AUTO_DISABLE, CD_ENABLE);
42} 54}
43 55
56static int rtl8411b_extra_init_hw(struct rtsx_pcr *pcr)
57{
58 if (rtl8411b_is_qfn48(pcr))
59 rtsx_pci_write_register(pcr, CARD_PULL_CTL3, 0xFF, 0xF5);
60
61 return rtsx_pci_write_register(pcr, CD_PAD_CTL,
62 CD_DISABLE_MASK | CD_AUTO_DISABLE, CD_ENABLE);
63}
64
44static int rtl8411_turn_on_led(struct rtsx_pcr *pcr) 65static int rtl8411_turn_on_led(struct rtsx_pcr *pcr)
45{ 66{
46 return rtsx_pci_write_register(pcr, CARD_GPIO, 0x01, 0x00); 67 return rtsx_pci_write_register(pcr, CARD_GPIO, 0x01, 0x00);
@@ -214,6 +235,20 @@ static const struct pcr_ops rtl8411_pcr_ops = {
214 .conv_clk_and_div_n = rtl8411_conv_clk_and_div_n, 235 .conv_clk_and_div_n = rtl8411_conv_clk_and_div_n,
215}; 236};
216 237
238static const struct pcr_ops rtl8411b_pcr_ops = {
239 .extra_init_hw = rtl8411b_extra_init_hw,
240 .optimize_phy = NULL,
241 .turn_on_led = rtl8411_turn_on_led,
242 .turn_off_led = rtl8411_turn_off_led,
243 .enable_auto_blink = rtl8411_enable_auto_blink,
244 .disable_auto_blink = rtl8411_disable_auto_blink,
245 .card_power_on = rtl8411_card_power_on,
246 .card_power_off = rtl8411_card_power_off,
247 .switch_output_voltage = rtl8411_switch_output_voltage,
248 .cd_deglitch = rtl8411_cd_deglitch,
249 .conv_clk_and_div_n = rtl8411_conv_clk_and_div_n,
250};
251
217/* SD Pull Control Enable: 252/* SD Pull Control Enable:
218 * SD_DAT[3:0] ==> pull up 253 * SD_DAT[3:0] ==> pull up
219 * SD_CD ==> pull up 254 * SD_CD ==> pull up
@@ -276,6 +311,74 @@ static const u32 rtl8411_ms_pull_ctl_disable_tbl[] = {
276 0, 311 0,
277}; 312};
278 313
314static const u32 rtl8411b_qfn64_sd_pull_ctl_enable_tbl[] = {
315 RTSX_REG_PAIR(CARD_PULL_CTL1, 0xAA),
316 RTSX_REG_PAIR(CARD_PULL_CTL2, 0xAA),
317 RTSX_REG_PAIR(CARD_PULL_CTL3, 0x09 | 0xD0),
318 RTSX_REG_PAIR(CARD_PULL_CTL4, 0x09 | 0x50),
319 RTSX_REG_PAIR(CARD_PULL_CTL5, 0x05 | 0x50),
320 RTSX_REG_PAIR(CARD_PULL_CTL6, 0x04 | 0x11),
321 0,
322};
323
324static const u32 rtl8411b_qfn48_sd_pull_ctl_enable_tbl[] = {
325 RTSX_REG_PAIR(CARD_PULL_CTL2, 0xAA),
326 RTSX_REG_PAIR(CARD_PULL_CTL3, 0x69 | 0x90),
327 RTSX_REG_PAIR(CARD_PULL_CTL6, 0x08 | 0x11),
328 0,
329};
330
331static const u32 rtl8411b_qfn64_sd_pull_ctl_disable_tbl[] = {
332 RTSX_REG_PAIR(CARD_PULL_CTL1, 0x65),
333 RTSX_REG_PAIR(CARD_PULL_CTL2, 0x55),
334 RTSX_REG_PAIR(CARD_PULL_CTL3, 0x05 | 0xD0),
335 RTSX_REG_PAIR(CARD_PULL_CTL4, 0x09 | 0x50),
336 RTSX_REG_PAIR(CARD_PULL_CTL5, 0x05 | 0x50),
337 RTSX_REG_PAIR(CARD_PULL_CTL6, 0x04 | 0x11),
338 0,
339};
340
341static const u32 rtl8411b_qfn48_sd_pull_ctl_disable_tbl[] = {
342 RTSX_REG_PAIR(CARD_PULL_CTL2, 0x55),
343 RTSX_REG_PAIR(CARD_PULL_CTL3, 0x65 | 0x90),
344 RTSX_REG_PAIR(CARD_PULL_CTL6, 0x04 | 0x11),
345 0,
346};
347
348static const u32 rtl8411b_qfn64_ms_pull_ctl_enable_tbl[] = {
349 RTSX_REG_PAIR(CARD_PULL_CTL1, 0x65),
350 RTSX_REG_PAIR(CARD_PULL_CTL2, 0x55),
351 RTSX_REG_PAIR(CARD_PULL_CTL3, 0x05 | 0xD0),
352 RTSX_REG_PAIR(CARD_PULL_CTL4, 0x05 | 0x50),
353 RTSX_REG_PAIR(CARD_PULL_CTL5, 0x05 | 0x50),
354 RTSX_REG_PAIR(CARD_PULL_CTL6, 0x04 | 0x11),
355 0,
356};
357
358static const u32 rtl8411b_qfn48_ms_pull_ctl_enable_tbl[] = {
359 RTSX_REG_PAIR(CARD_PULL_CTL2, 0x55),
360 RTSX_REG_PAIR(CARD_PULL_CTL3, 0x65 | 0x90),
361 RTSX_REG_PAIR(CARD_PULL_CTL6, 0x04 | 0x11),
362 0,
363};
364
365static const u32 rtl8411b_qfn64_ms_pull_ctl_disable_tbl[] = {
366 RTSX_REG_PAIR(CARD_PULL_CTL1, 0x65),
367 RTSX_REG_PAIR(CARD_PULL_CTL2, 0x55),
368 RTSX_REG_PAIR(CARD_PULL_CTL3, 0x05 | 0xD0),
369 RTSX_REG_PAIR(CARD_PULL_CTL4, 0x09 | 0x50),
370 RTSX_REG_PAIR(CARD_PULL_CTL5, 0x05 | 0x50),
371 RTSX_REG_PAIR(CARD_PULL_CTL6, 0x04 | 0x11),
372 0,
373};
374
375static const u32 rtl8411b_qfn48_ms_pull_ctl_disable_tbl[] = {
376 RTSX_REG_PAIR(CARD_PULL_CTL2, 0x55),
377 RTSX_REG_PAIR(CARD_PULL_CTL3, 0x65 | 0x90),
378 RTSX_REG_PAIR(CARD_PULL_CTL6, 0x04 | 0x11),
379 0,
380};
381
279void rtl8411_init_params(struct rtsx_pcr *pcr) 382void rtl8411_init_params(struct rtsx_pcr *pcr)
280{ 383{
281 pcr->extra_caps = EXTRA_CAPS_SD_SDR50 | EXTRA_CAPS_SD_SDR104; 384 pcr->extra_caps = EXTRA_CAPS_SD_SDR50 | EXTRA_CAPS_SD_SDR104;
@@ -288,3 +391,32 @@ void rtl8411_init_params(struct rtsx_pcr *pcr)
288 pcr->ms_pull_ctl_enable_tbl = rtl8411_ms_pull_ctl_enable_tbl; 391 pcr->ms_pull_ctl_enable_tbl = rtl8411_ms_pull_ctl_enable_tbl;
289 pcr->ms_pull_ctl_disable_tbl = rtl8411_ms_pull_ctl_disable_tbl; 392 pcr->ms_pull_ctl_disable_tbl = rtl8411_ms_pull_ctl_disable_tbl;
290} 393}
394
395void rtl8411b_init_params(struct rtsx_pcr *pcr)
396{
397 pcr->extra_caps = EXTRA_CAPS_SD_SDR50 | EXTRA_CAPS_SD_SDR104;
398 pcr->num_slots = 2;
399 pcr->ops = &rtl8411b_pcr_ops;
400
401 pcr->ic_version = rtl8411_get_ic_version(pcr);
402
403 if (rtl8411b_is_qfn48(pcr)) {
404 pcr->sd_pull_ctl_enable_tbl =
405 rtl8411b_qfn48_sd_pull_ctl_enable_tbl;
406 pcr->sd_pull_ctl_disable_tbl =
407 rtl8411b_qfn48_sd_pull_ctl_disable_tbl;
408 pcr->ms_pull_ctl_enable_tbl =
409 rtl8411b_qfn48_ms_pull_ctl_enable_tbl;
410 pcr->ms_pull_ctl_disable_tbl =
411 rtl8411b_qfn48_ms_pull_ctl_disable_tbl;
412 } else {
413 pcr->sd_pull_ctl_enable_tbl =
414 rtl8411b_qfn64_sd_pull_ctl_enable_tbl;
415 pcr->sd_pull_ctl_disable_tbl =
416 rtl8411b_qfn64_sd_pull_ctl_disable_tbl;
417 pcr->ms_pull_ctl_enable_tbl =
418 rtl8411b_qfn64_ms_pull_ctl_enable_tbl;
419 pcr->ms_pull_ctl_disable_tbl =
420 rtl8411b_qfn64_ms_pull_ctl_disable_tbl;
421 }
422}
diff --git a/drivers/mfd/rtsx_pcr.c b/drivers/mfd/rtsx_pcr.c
index e968c01ca2ac..dd186c4103c1 100644
--- a/drivers/mfd/rtsx_pcr.c
+++ b/drivers/mfd/rtsx_pcr.c
@@ -57,6 +57,7 @@ static DEFINE_PCI_DEVICE_TABLE(rtsx_pci_ids) = {
57 { PCI_DEVICE(0x10EC, 0x5289), PCI_CLASS_OTHERS << 16, 0xFF0000 }, 57 { PCI_DEVICE(0x10EC, 0x5289), PCI_CLASS_OTHERS << 16, 0xFF0000 },
58 { PCI_DEVICE(0x10EC, 0x5227), PCI_CLASS_OTHERS << 16, 0xFF0000 }, 58 { PCI_DEVICE(0x10EC, 0x5227), PCI_CLASS_OTHERS << 16, 0xFF0000 },
59 { PCI_DEVICE(0x10EC, 0x5249), PCI_CLASS_OTHERS << 16, 0xFF0000 }, 59 { PCI_DEVICE(0x10EC, 0x5249), PCI_CLASS_OTHERS << 16, 0xFF0000 },
60 { PCI_DEVICE(0x10EC, 0x5287), PCI_CLASS_OTHERS << 16, 0xFF0000 },
60 { 0, } 61 { 0, }
61}; 62};
62 63
@@ -1038,6 +1039,10 @@ static int rtsx_pci_init_chip(struct rtsx_pcr *pcr)
1038 case 0x5249: 1039 case 0x5249:
1039 rts5249_init_params(pcr); 1040 rts5249_init_params(pcr);
1040 break; 1041 break;
1042
1043 case 0x5287:
1044 rtl8411b_init_params(pcr);
1045 break;
1041 } 1046 }
1042 1047
1043 dev_dbg(&(pcr->pci->dev), "PID: 0x%04x, IC version: 0x%02x\n", 1048 dev_dbg(&(pcr->pci->dev), "PID: 0x%04x, IC version: 0x%02x\n",
diff --git a/drivers/mfd/rtsx_pcr.h b/drivers/mfd/rtsx_pcr.h
index 55fcfc25c4e4..c0cac7e8972f 100644
--- a/drivers/mfd/rtsx_pcr.h
+++ b/drivers/mfd/rtsx_pcr.h
@@ -33,5 +33,6 @@ void rts5229_init_params(struct rtsx_pcr *pcr);
33void rtl8411_init_params(struct rtsx_pcr *pcr); 33void rtl8411_init_params(struct rtsx_pcr *pcr);
34void rts5227_init_params(struct rtsx_pcr *pcr); 34void rts5227_init_params(struct rtsx_pcr *pcr);
35void rts5249_init_params(struct rtsx_pcr *pcr); 35void rts5249_init_params(struct rtsx_pcr *pcr);
36void rtl8411b_init_params(struct rtsx_pcr *pcr);
36 37
37#endif 38#endif
diff --git a/include/linux/mfd/rtsx_pci.h b/include/linux/mfd/rtsx_pci.h
index 86bc635f8385..7a9f7089435d 100644
--- a/include/linux/mfd/rtsx_pci.h
+++ b/include/linux/mfd/rtsx_pci.h
@@ -575,6 +575,7 @@
575 575
576#define CARD_PWR_CTL 0xFD50 576#define CARD_PWR_CTL 0xFD50
577#define CARD_CLK_SWITCH 0xFD51 577#define CARD_CLK_SWITCH 0xFD51
578#define RTL8411B_PACKAGE_MODE 0xFD51
578#define CARD_SHARE_MODE 0xFD52 579#define CARD_SHARE_MODE 0xFD52
579#define CARD_DRIVE_SEL 0xFD53 580#define CARD_DRIVE_SEL 0xFD53
580#define CARD_STOP 0xFD54 581#define CARD_STOP 0xFD54