diff options
author | Micky Ching <micky_ching@realsil.com.cn> | 2015-06-28 21:19:39 -0400 |
---|---|---|
committer | Lee Jones <lee.jones@linaro.org> | 2015-10-30 13:19:51 -0400 |
commit | ce6a5acc93876f619f32f8f60c7c6e549e46d962 (patch) | |
tree | d89dbff3343ad44de6bcc01238734916e5381de3 | |
parent | 6f44b14870520e2758b758cc3b3b4c09c4b715ab (diff) |
mfd: rtsx: Add support for rts522A
rts522a(rts5227s) is derived from rts5227, and mainly same with rts5227.
Add it to file mfd/rts5227.c to support this chip.
Signed-off-by: Micky Ching <micky_ching@realsil.com.cn>
Signed-off-by: Lee Jones <lee.jones@linaro.org>
-rw-r--r-- | drivers/mfd/Kconfig | 7 | ||||
-rw-r--r-- | drivers/mfd/rts5227.c | 77 | ||||
-rw-r--r-- | drivers/mfd/rtsx_pcr.c | 5 | ||||
-rw-r--r-- | drivers/mfd/rtsx_pcr.h | 3 | ||||
-rw-r--r-- | include/linux/mfd/rtsx_pci.h | 6 |
5 files changed, 93 insertions, 5 deletions
diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig index d6514fb35f78..2db1337432cf 100644 --- a/drivers/mfd/Kconfig +++ b/drivers/mfd/Kconfig | |||
@@ -736,9 +736,10 @@ config MFD_RTSX_PCI | |||
736 | select MFD_CORE | 736 | select MFD_CORE |
737 | help | 737 | help |
738 | This supports for Realtek PCI-Express card reader including rts5209, | 738 | This supports for Realtek PCI-Express card reader including rts5209, |
739 | rts5229, rtl8411, etc. Realtek card reader supports access to many | 739 | rts5227, rts522A, rts5229, rts5249, rts524A, rts525A, rtl8411, etc. |
740 | types of memory cards, such as Memory Stick, Memory Stick Pro, | 740 | Realtek card reader supports access to many types of memory cards, |
741 | Secure Digital and MultiMediaCard. | 741 | such as Memory Stick, Memory Stick Pro, Secure Digital and |
742 | MultiMediaCard. | ||
742 | 743 | ||
743 | config MFD_RT5033 | 744 | config MFD_RT5033 |
744 | tristate "Richtek RT5033 Power Management IC" | 745 | tristate "Richtek RT5033 Power Management IC" |
diff --git a/drivers/mfd/rts5227.c b/drivers/mfd/rts5227.c index c5a65298c781..ff296a4bf3d2 100644 --- a/drivers/mfd/rts5227.c +++ b/drivers/mfd/rts5227.c | |||
@@ -26,6 +26,14 @@ | |||
26 | 26 | ||
27 | #include "rtsx_pcr.h" | 27 | #include "rtsx_pcr.h" |
28 | 28 | ||
29 | static u8 rts5227_get_ic_version(struct rtsx_pcr *pcr) | ||
30 | { | ||
31 | u8 val; | ||
32 | |||
33 | rtsx_pci_read_register(pcr, DUMMY_REG_RESET_0, &val); | ||
34 | return val & 0x0F; | ||
35 | } | ||
36 | |||
29 | static void rts5227_fill_driving(struct rtsx_pcr *pcr, u8 voltage) | 37 | static void rts5227_fill_driving(struct rtsx_pcr *pcr, u8 voltage) |
30 | { | 38 | { |
31 | u8 driving_3v3[4][3] = { | 39 | u8 driving_3v3[4][3] = { |
@@ -88,7 +96,7 @@ static void rts5227_force_power_down(struct rtsx_pcr *pcr, u8 pm_state) | |||
88 | rtsx_pci_write_register(pcr, AUTOLOAD_CFG_BASE + 3, 0x01, 0); | 96 | rtsx_pci_write_register(pcr, AUTOLOAD_CFG_BASE + 3, 0x01, 0); |
89 | 97 | ||
90 | if (pm_state == HOST_ENTER_S3) | 98 | if (pm_state == HOST_ENTER_S3) |
91 | rtsx_pci_write_register(pcr, PM_CTRL3, 0x10, 0x10); | 99 | rtsx_pci_write_register(pcr, pcr->reg_pm_ctrl3, 0x10, 0x10); |
92 | 100 | ||
93 | rtsx_pci_write_register(pcr, FPDCTL, 0x03, 0x03); | 101 | rtsx_pci_write_register(pcr, FPDCTL, 0x03, 0x03); |
94 | } | 102 | } |
@@ -121,7 +129,7 @@ static int rts5227_extra_init_hw(struct rtsx_pcr *pcr) | |||
121 | rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, PETXCFG, 0xB8, 0xB8); | 129 | rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, PETXCFG, 0xB8, 0xB8); |
122 | else | 130 | else |
123 | rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, PETXCFG, 0xB8, 0x88); | 131 | rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, PETXCFG, 0xB8, 0x88); |
124 | rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, PM_CTRL3, 0x10, 0x00); | 132 | rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, pcr->reg_pm_ctrl3, 0x10, 0x00); |
125 | 133 | ||
126 | return rtsx_pci_send_cmd(pcr, 100); | 134 | return rtsx_pci_send_cmd(pcr, 100); |
127 | } | 135 | } |
@@ -294,8 +302,73 @@ void rts5227_init_params(struct rtsx_pcr *pcr) | |||
294 | pcr->tx_initial_phase = SET_CLOCK_PHASE(27, 27, 15); | 302 | pcr->tx_initial_phase = SET_CLOCK_PHASE(27, 27, 15); |
295 | pcr->rx_initial_phase = SET_CLOCK_PHASE(30, 7, 7); | 303 | pcr->rx_initial_phase = SET_CLOCK_PHASE(30, 7, 7); |
296 | 304 | ||
305 | pcr->ic_version = rts5227_get_ic_version(pcr); | ||
297 | pcr->sd_pull_ctl_enable_tbl = rts5227_sd_pull_ctl_enable_tbl; | 306 | pcr->sd_pull_ctl_enable_tbl = rts5227_sd_pull_ctl_enable_tbl; |
298 | pcr->sd_pull_ctl_disable_tbl = rts5227_sd_pull_ctl_disable_tbl; | 307 | pcr->sd_pull_ctl_disable_tbl = rts5227_sd_pull_ctl_disable_tbl; |
299 | pcr->ms_pull_ctl_enable_tbl = rts5227_ms_pull_ctl_enable_tbl; | 308 | pcr->ms_pull_ctl_enable_tbl = rts5227_ms_pull_ctl_enable_tbl; |
300 | pcr->ms_pull_ctl_disable_tbl = rts5227_ms_pull_ctl_disable_tbl; | 309 | pcr->ms_pull_ctl_disable_tbl = rts5227_ms_pull_ctl_disable_tbl; |
310 | |||
311 | pcr->reg_pm_ctrl3 = PM_CTRL3; | ||
312 | } | ||
313 | |||
314 | static int rts522a_optimize_phy(struct rtsx_pcr *pcr) | ||
315 | { | ||
316 | int err; | ||
317 | |||
318 | err = rtsx_pci_write_register(pcr, RTS522A_PM_CTRL3, D3_DELINK_MODE_EN, | ||
319 | 0x00); | ||
320 | if (err < 0) | ||
321 | return err; | ||
322 | |||
323 | if (is_version(pcr, 0x522A, IC_VER_A)) { | ||
324 | err = rtsx_pci_write_phy_register(pcr, PHY_RCR2, | ||
325 | PHY_RCR2_INIT_27S); | ||
326 | if (err) | ||
327 | return err; | ||
328 | |||
329 | rtsx_pci_write_phy_register(pcr, PHY_RCR1, PHY_RCR1_INIT_27S); | ||
330 | rtsx_pci_write_phy_register(pcr, PHY_FLD0, PHY_FLD0_INIT_27S); | ||
331 | rtsx_pci_write_phy_register(pcr, PHY_FLD3, PHY_FLD3_INIT_27S); | ||
332 | rtsx_pci_write_phy_register(pcr, PHY_FLD4, PHY_FLD4_INIT_27S); | ||
333 | } | ||
334 | |||
335 | return 0; | ||
336 | } | ||
337 | |||
338 | static int rts522a_extra_init_hw(struct rtsx_pcr *pcr) | ||
339 | { | ||
340 | rts5227_extra_init_hw(pcr); | ||
341 | |||
342 | rtsx_pci_write_register(pcr, FUNC_FORCE_CTL, FUNC_FORCE_UPME_XMT_DBG, | ||
343 | FUNC_FORCE_UPME_XMT_DBG); | ||
344 | rtsx_pci_write_register(pcr, PCLK_CTL, 0x04, 0x04); | ||
345 | rtsx_pci_write_register(pcr, PM_EVENT_DEBUG, PME_DEBUG_0, PME_DEBUG_0); | ||
346 | rtsx_pci_write_register(pcr, PM_CLK_FORCE_CTL, 0xFF, 0x11); | ||
347 | |||
348 | return 0; | ||
349 | } | ||
350 | |||
351 | /* rts522a operations mainly derived from rts5227, except phy/hw init setting. | ||
352 | */ | ||
353 | static const struct pcr_ops rts522a_pcr_ops = { | ||
354 | .fetch_vendor_settings = rts5227_fetch_vendor_settings, | ||
355 | .extra_init_hw = rts522a_extra_init_hw, | ||
356 | .optimize_phy = rts522a_optimize_phy, | ||
357 | .turn_on_led = rts5227_turn_on_led, | ||
358 | .turn_off_led = rts5227_turn_off_led, | ||
359 | .enable_auto_blink = rts5227_enable_auto_blink, | ||
360 | .disable_auto_blink = rts5227_disable_auto_blink, | ||
361 | .card_power_on = rts5227_card_power_on, | ||
362 | .card_power_off = rts5227_card_power_off, | ||
363 | .switch_output_voltage = rts5227_switch_output_voltage, | ||
364 | .cd_deglitch = NULL, | ||
365 | .conv_clk_and_div_n = NULL, | ||
366 | .force_power_down = rts5227_force_power_down, | ||
367 | }; | ||
368 | |||
369 | void rts522a_init_params(struct rtsx_pcr *pcr) | ||
370 | { | ||
371 | rts5227_init_params(pcr); | ||
372 | |||
373 | pcr->reg_pm_ctrl3 = RTS522A_PM_CTRL3; | ||
301 | } | 374 | } |
diff --git a/drivers/mfd/rtsx_pcr.c b/drivers/mfd/rtsx_pcr.c index b98cf1de0a55..f3820d08c9a3 100644 --- a/drivers/mfd/rtsx_pcr.c +++ b/drivers/mfd/rtsx_pcr.c | |||
@@ -55,6 +55,7 @@ static const struct pci_device_id rtsx_pci_ids[] = { | |||
55 | { PCI_DEVICE(0x10EC, 0x5229), PCI_CLASS_OTHERS << 16, 0xFF0000 }, | 55 | { PCI_DEVICE(0x10EC, 0x5229), PCI_CLASS_OTHERS << 16, 0xFF0000 }, |
56 | { PCI_DEVICE(0x10EC, 0x5289), PCI_CLASS_OTHERS << 16, 0xFF0000 }, | 56 | { PCI_DEVICE(0x10EC, 0x5289), PCI_CLASS_OTHERS << 16, 0xFF0000 }, |
57 | { PCI_DEVICE(0x10EC, 0x5227), PCI_CLASS_OTHERS << 16, 0xFF0000 }, | 57 | { PCI_DEVICE(0x10EC, 0x5227), PCI_CLASS_OTHERS << 16, 0xFF0000 }, |
58 | { PCI_DEVICE(0x10EC, 0x522A), PCI_CLASS_OTHERS << 16, 0xFF0000 }, | ||
58 | { PCI_DEVICE(0x10EC, 0x5249), PCI_CLASS_OTHERS << 16, 0xFF0000 }, | 59 | { PCI_DEVICE(0x10EC, 0x5249), PCI_CLASS_OTHERS << 16, 0xFF0000 }, |
59 | { PCI_DEVICE(0x10EC, 0x5287), PCI_CLASS_OTHERS << 16, 0xFF0000 }, | 60 | { PCI_DEVICE(0x10EC, 0x5287), PCI_CLASS_OTHERS << 16, 0xFF0000 }, |
60 | { PCI_DEVICE(0x10EC, 0x5286), PCI_CLASS_OTHERS << 16, 0xFF0000 }, | 61 | { PCI_DEVICE(0x10EC, 0x5286), PCI_CLASS_OTHERS << 16, 0xFF0000 }, |
@@ -1098,6 +1099,10 @@ static int rtsx_pci_init_chip(struct rtsx_pcr *pcr) | |||
1098 | rts5227_init_params(pcr); | 1099 | rts5227_init_params(pcr); |
1099 | break; | 1100 | break; |
1100 | 1101 | ||
1102 | case 0x522A: | ||
1103 | rts522a_init_params(pcr); | ||
1104 | break; | ||
1105 | |||
1101 | case 0x5249: | 1106 | case 0x5249: |
1102 | rts5249_init_params(pcr); | 1107 | rts5249_init_params(pcr); |
1103 | break; | 1108 | break; |
diff --git a/drivers/mfd/rtsx_pcr.h b/drivers/mfd/rtsx_pcr.h index ce48842570d7..931d1ae3ce32 100644 --- a/drivers/mfd/rtsx_pcr.h +++ b/drivers/mfd/rtsx_pcr.h | |||
@@ -27,6 +27,8 @@ | |||
27 | #define MIN_DIV_N_PCR 80 | 27 | #define MIN_DIV_N_PCR 80 |
28 | #define MAX_DIV_N_PCR 208 | 28 | #define MAX_DIV_N_PCR 208 |
29 | 29 | ||
30 | #define RTS522A_PM_CTRL3 0xFF7E | ||
31 | |||
30 | #define RTS524A_PME_FORCE_CTL 0xFF78 | 32 | #define RTS524A_PME_FORCE_CTL 0xFF78 |
31 | #define RTS524A_PM_CTRL3 0xFF7E | 33 | #define RTS524A_PM_CTRL3 0xFF7E |
32 | 34 | ||
@@ -38,6 +40,7 @@ void rts5229_init_params(struct rtsx_pcr *pcr); | |||
38 | void rtl8411_init_params(struct rtsx_pcr *pcr); | 40 | void rtl8411_init_params(struct rtsx_pcr *pcr); |
39 | void rtl8402_init_params(struct rtsx_pcr *pcr); | 41 | void rtl8402_init_params(struct rtsx_pcr *pcr); |
40 | void rts5227_init_params(struct rtsx_pcr *pcr); | 42 | void rts5227_init_params(struct rtsx_pcr *pcr); |
43 | void rts522a_init_params(struct rtsx_pcr *pcr); | ||
41 | void rts5249_init_params(struct rtsx_pcr *pcr); | 44 | void rts5249_init_params(struct rtsx_pcr *pcr); |
42 | void rts524a_init_params(struct rtsx_pcr *pcr); | 45 | void rts524a_init_params(struct rtsx_pcr *pcr); |
43 | void rts525a_init_params(struct rtsx_pcr *pcr); | 46 | void rts525a_init_params(struct rtsx_pcr *pcr); |
diff --git a/include/linux/mfd/rtsx_pci.h b/include/linux/mfd/rtsx_pci.h index ff843e7ca23d..7eb7cbac0a9a 100644 --- a/include/linux/mfd/rtsx_pci.h +++ b/include/linux/mfd/rtsx_pci.h | |||
@@ -589,6 +589,7 @@ | |||
589 | #define FORCE_ASPM_NO_ASPM 0x00 | 589 | #define FORCE_ASPM_NO_ASPM 0x00 |
590 | #define PM_CLK_FORCE_CTL 0xFE58 | 590 | #define PM_CLK_FORCE_CTL 0xFE58 |
591 | #define FUNC_FORCE_CTL 0xFE59 | 591 | #define FUNC_FORCE_CTL 0xFE59 |
592 | #define FUNC_FORCE_UPME_XMT_DBG 0x02 | ||
592 | #define PERST_GLITCH_WIDTH 0xFE5C | 593 | #define PERST_GLITCH_WIDTH 0xFE5C |
593 | #define CHANGE_LINK_STATE 0xFE5B | 594 | #define CHANGE_LINK_STATE 0xFE5B |
594 | #define RESET_LOAD_REG 0xFE5E | 595 | #define RESET_LOAD_REG 0xFE5E |
@@ -712,6 +713,7 @@ | |||
712 | #define PHY_RCR1 0x02 | 713 | #define PHY_RCR1 0x02 |
713 | #define PHY_RCR1_ADP_TIME_4 0x0400 | 714 | #define PHY_RCR1_ADP_TIME_4 0x0400 |
714 | #define PHY_RCR1_VCO_COARSE 0x001F | 715 | #define PHY_RCR1_VCO_COARSE 0x001F |
716 | #define PHY_RCR1_INIT_27S 0x0A1F | ||
715 | #define PHY_SSCCR2 0x02 | 717 | #define PHY_SSCCR2 0x02 |
716 | #define PHY_SSCCR2_PLL_NCODE 0x0A00 | 718 | #define PHY_SSCCR2_PLL_NCODE 0x0A00 |
717 | #define PHY_SSCCR2_TIME0 0x001C | 719 | #define PHY_SSCCR2_TIME0 0x001C |
@@ -724,6 +726,7 @@ | |||
724 | #define PHY_RCR2_FREQSEL_12 0x0040 | 726 | #define PHY_RCR2_FREQSEL_12 0x0040 |
725 | #define PHY_RCR2_CDR_SC_12P 0x0010 | 727 | #define PHY_RCR2_CDR_SC_12P 0x0010 |
726 | #define PHY_RCR2_CALIB_LATE 0x0002 | 728 | #define PHY_RCR2_CALIB_LATE 0x0002 |
729 | #define PHY_RCR2_INIT_27S 0xC152 | ||
727 | #define PHY_SSCCR3 0x03 | 730 | #define PHY_SSCCR3 0x03 |
728 | #define PHY_SSCCR3_STEP_IN 0x2740 | 731 | #define PHY_SSCCR3_STEP_IN 0x2740 |
729 | #define PHY_SSCCR3_CHECK_DELAY 0x0008 | 732 | #define PHY_SSCCR3_CHECK_DELAY 0x0008 |
@@ -800,12 +803,14 @@ | |||
800 | #define PHY_ANA1A_RXT_BIST 0x0500 | 803 | #define PHY_ANA1A_RXT_BIST 0x0500 |
801 | #define PHY_ANA1A_TXR_BIST 0x0040 | 804 | #define PHY_ANA1A_TXR_BIST 0x0040 |
802 | #define PHY_ANA1A_REV 0x0006 | 805 | #define PHY_ANA1A_REV 0x0006 |
806 | #define PHY_FLD0_INIT_27S 0x2546 | ||
803 | #define PHY_FLD1 0x1B | 807 | #define PHY_FLD1 0x1B |
804 | #define PHY_FLD2 0x1C | 808 | #define PHY_FLD2 0x1C |
805 | #define PHY_FLD3 0x1D | 809 | #define PHY_FLD3 0x1D |
806 | #define PHY_FLD3_TIMER_4 0x0800 | 810 | #define PHY_FLD3_TIMER_4 0x0800 |
807 | #define PHY_FLD3_TIMER_6 0x0020 | 811 | #define PHY_FLD3_TIMER_6 0x0020 |
808 | #define PHY_FLD3_RXDELINK 0x0004 | 812 | #define PHY_FLD3_RXDELINK 0x0004 |
813 | #define PHY_FLD3_INIT_27S 0x0004 | ||
809 | #define PHY_ANA1D 0x1D | 814 | #define PHY_ANA1D 0x1D |
810 | #define PHY_ANA1D_DEBUG_ADDR 0x0004 | 815 | #define PHY_ANA1D_DEBUG_ADDR 0x0004 |
811 | #define _PHY_FLD0 0x1D | 816 | #define _PHY_FLD0 0x1D |
@@ -824,6 +829,7 @@ | |||
824 | #define PHY_FLD4_BER_COUNT 0x00E0 | 829 | #define PHY_FLD4_BER_COUNT 0x00E0 |
825 | #define PHY_FLD4_BER_TIMER 0x000A | 830 | #define PHY_FLD4_BER_TIMER 0x000A |
826 | #define PHY_FLD4_BER_CHK_EN 0x0001 | 831 | #define PHY_FLD4_BER_CHK_EN 0x0001 |
832 | #define PHY_FLD4_INIT_27S 0x5C7F | ||
827 | #define PHY_DIG1E 0x1E | 833 | #define PHY_DIG1E 0x1E |
828 | #define PHY_DIG1E_REV 0x4000 | 834 | #define PHY_DIG1E_REV 0x4000 |
829 | #define PHY_DIG1E_D0_X_D1 0x1000 | 835 | #define PHY_DIG1E_D0_X_D1 0x1000 |