aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mfd
diff options
context:
space:
mode:
authorMicky Ching <micky_ching@realsil.com.cn>2013-12-17 21:03:12 -0500
committerLee Jones <lee.jones@linaro.org>2014-01-21 03:28:11 -0500
commit0da14eeba216932db2e4b8805ab58dae72e44a45 (patch)
treeca2b65702d6d2057787533da70358ece2dc62ed3 /drivers/mfd
parentc1ec8fc308bb8171c76b5bed7f4028b6290e53f9 (diff)
mfd: rtsx: Add set pull control macro and simplify rtl8411
Add set pull control macro to reduce code for setting pull control, and use a common init function to reduce code for rtl8411.c. So this patch is used to just simplify code. Signed-off-by: Micky Ching <micky_ching@realsil.com.cn> Reviewed-by: Dan Carpenter <dan.carpenter@oracle.com> Signed-off-by: Lee Jones <lee.jones@linaro.org>
Diffstat (limited to 'drivers/mfd')
-rw-r--r--drivers/mfd/rtl8411.c53
-rw-r--r--drivers/mfd/rtsx_pcr.h8
2 files changed, 21 insertions, 40 deletions
diff --git a/drivers/mfd/rtl8411.c b/drivers/mfd/rtl8411.c
index 1ee867591ee4..327c8894fd4a 100644
--- a/drivers/mfd/rtl8411.c
+++ b/drivers/mfd/rtl8411.c
@@ -441,12 +441,10 @@ static const u32 rtl8411b_qfn48_ms_pull_ctl_disable_tbl[] = {
441 0, 441 0,
442}; 442};
443 443
444void rtl8411_init_params(struct rtsx_pcr *pcr) 444void rtl8411_init_common_params(struct rtsx_pcr *pcr)
445{ 445{
446 pcr->extra_caps = EXTRA_CAPS_SD_SDR50 | EXTRA_CAPS_SD_SDR104; 446 pcr->extra_caps = EXTRA_CAPS_SD_SDR50 | EXTRA_CAPS_SD_SDR104;
447 pcr->num_slots = 2; 447 pcr->num_slots = 2;
448 pcr->ops = &rtl8411_pcr_ops;
449
450 pcr->flags = 0; 448 pcr->flags = 0;
451 pcr->card_drive_sel = RTL8411_CARD_DRIVE_DEFAULT; 449 pcr->card_drive_sel = RTL8411_CARD_DRIVE_DEFAULT;
452 pcr->sd30_drive_sel_1v8 = DRIVER_TYPE_B; 450 pcr->sd30_drive_sel_1v8 = DRIVER_TYPE_B;
@@ -454,47 +452,22 @@ void rtl8411_init_params(struct rtsx_pcr *pcr)
454 pcr->aspm_en = ASPM_L1_EN; 452 pcr->aspm_en = ASPM_L1_EN;
455 pcr->tx_initial_phase = SET_CLOCK_PHASE(23, 7, 14); 453 pcr->tx_initial_phase = SET_CLOCK_PHASE(23, 7, 14);
456 pcr->rx_initial_phase = SET_CLOCK_PHASE(4, 3, 10); 454 pcr->rx_initial_phase = SET_CLOCK_PHASE(4, 3, 10);
457
458 pcr->ic_version = rtl8411_get_ic_version(pcr); 455 pcr->ic_version = rtl8411_get_ic_version(pcr);
459 pcr->sd_pull_ctl_enable_tbl = rtl8411_sd_pull_ctl_enable_tbl; 456}
460 pcr->sd_pull_ctl_disable_tbl = rtl8411_sd_pull_ctl_disable_tbl; 457
461 pcr->ms_pull_ctl_enable_tbl = rtl8411_ms_pull_ctl_enable_tbl; 458void rtl8411_init_params(struct rtsx_pcr *pcr)
462 pcr->ms_pull_ctl_disable_tbl = rtl8411_ms_pull_ctl_disable_tbl; 459{
460 rtl8411_init_common_params(pcr);
461 pcr->ops = &rtl8411_pcr_ops;
462 set_pull_ctrl_tables(pcr, rtl8411);
463} 463}
464 464
465void rtl8411b_init_params(struct rtsx_pcr *pcr) 465void rtl8411b_init_params(struct rtsx_pcr *pcr)
466{ 466{
467 pcr->extra_caps = EXTRA_CAPS_SD_SDR50 | EXTRA_CAPS_SD_SDR104; 467 rtl8411_init_common_params(pcr);
468 pcr->num_slots = 2;
469 pcr->ops = &rtl8411b_pcr_ops; 468 pcr->ops = &rtl8411b_pcr_ops;
470 469 if (rtl8411b_is_qfn48(pcr))
471 pcr->flags = 0; 470 set_pull_ctrl_tables(pcr, rtl8411b_qfn48);
472 pcr->card_drive_sel = RTL8411_CARD_DRIVE_DEFAULT; 471 else
473 pcr->sd30_drive_sel_1v8 = DRIVER_TYPE_B; 472 set_pull_ctrl_tables(pcr, rtl8411b_qfn64);
474 pcr->sd30_drive_sel_3v3 = DRIVER_TYPE_D;
475 pcr->aspm_en = ASPM_L1_EN;
476 pcr->tx_initial_phase = SET_CLOCK_PHASE(23, 7, 14);
477 pcr->rx_initial_phase = SET_CLOCK_PHASE(4, 3, 10);
478
479 pcr->ic_version = rtl8411_get_ic_version(pcr);
480
481 if (rtl8411b_is_qfn48(pcr)) {
482 pcr->sd_pull_ctl_enable_tbl =
483 rtl8411b_qfn48_sd_pull_ctl_enable_tbl;
484 pcr->sd_pull_ctl_disable_tbl =
485 rtl8411b_qfn48_sd_pull_ctl_disable_tbl;
486 pcr->ms_pull_ctl_enable_tbl =
487 rtl8411b_qfn48_ms_pull_ctl_enable_tbl;
488 pcr->ms_pull_ctl_disable_tbl =
489 rtl8411b_qfn48_ms_pull_ctl_disable_tbl;
490 } else {
491 pcr->sd_pull_ctl_enable_tbl =
492 rtl8411b_qfn64_sd_pull_ctl_enable_tbl;
493 pcr->sd_pull_ctl_disable_tbl =
494 rtl8411b_qfn64_sd_pull_ctl_disable_tbl;
495 pcr->ms_pull_ctl_enable_tbl =
496 rtl8411b_qfn64_ms_pull_ctl_enable_tbl;
497 pcr->ms_pull_ctl_disable_tbl =
498 rtl8411b_qfn64_ms_pull_ctl_disable_tbl;
499 }
500} 473}
diff --git a/drivers/mfd/rtsx_pcr.h b/drivers/mfd/rtsx_pcr.h
index 947e79b05ceb..e9feadbfaf5c 100644
--- a/drivers/mfd/rtsx_pcr.h
+++ b/drivers/mfd/rtsx_pcr.h
@@ -63,4 +63,12 @@ static inline u8 map_sd_drive(int idx)
63#define rtl8411_reg_to_sd30_drive_sel_3v3(reg) (((reg) >> 5) & 0x07) 63#define rtl8411_reg_to_sd30_drive_sel_3v3(reg) (((reg) >> 5) & 0x07)
64#define rtl8411b_reg_to_sd30_drive_sel_3v3(reg) ((reg) & 0x03) 64#define rtl8411b_reg_to_sd30_drive_sel_3v3(reg) ((reg) & 0x03)
65 65
66#define set_pull_ctrl_tables(pcr, __device) \
67do { \
68 pcr->sd_pull_ctl_enable_tbl = __device##_sd_pull_ctl_enable_tbl; \
69 pcr->sd_pull_ctl_disable_tbl = __device##_sd_pull_ctl_disable_tbl; \
70 pcr->ms_pull_ctl_enable_tbl = __device##_ms_pull_ctl_enable_tbl; \
71 pcr->ms_pull_ctl_disable_tbl = __device##_ms_pull_ctl_disable_tbl; \
72} while (0)
73
66#endif 74#endif