Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752716AbbBYD2O (ORCPT ); Tue, 24 Feb 2015 22:28:14 -0500 Received: from rtits2.realtek.com ([60.250.210.242]:49779 "EHLO rtits2.realtek.com.tw" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751179AbbBYD2N (ORCPT ); Tue, 24 Feb 2015 22:28:13 -0500 Authenticated-By: X-SpamFilter-By: BOX Solutions SpamTrap 5.52 with qID t1P3Rt6b003585, This message is accepted by code: ctloc85258 From: =?utf-8?B?5pWs6ZSQ?= To: Lee Jones CC: "sameo@linux.intel.com" , "devel@linuxdriverproject.org" , "linux-kernel@vger.kernel.org" , "gregkh@linuxfoundation.org" , "rogerable@realtek.com" , =?utf-8?B?546L54Kc?= Subject: Re: [RESEND PATCH v2 7/9] mfd: rtsx: add support for rts524A Thread-Topic: [RESEND PATCH v2 7/9] mfd: rtsx: add support for rts524A Thread-Index: AQHQUKsLd6WBdXm7gE+w8M0xGutoxw== Date: Wed, 25 Feb 2015 03:27:55 +0000 Message-ID: <54ED413B.8080000@realsil.com.cn> References: <2383fa8aa98f0ca626f51ceb0143afc81bb7da42.1421911636.git.micky_ching@realsil.com.cn> <20150216142823.GL14545@x1> In-Reply-To: <20150216142823.GL14545@x1> Accept-Language: zh-CN, en-US Content-Language: zh-CN X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [172.29.41.103] Content-Type: text/plain; charset="utf-8" Content-ID: <034230F44E45F941BA98BA0EA56BE392@realsil.com.cn> MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from base64 to 8bit by nfs id t1P3SKWg024312 Content-Length: 4826 Lines: 126 On 02/16/2015 10:28 PM, Lee Jones wrote: > > +static int rts524a_optimize_phy(struct rtsx_pcr *pcr) > +{ > + int err; > + > + err = rtsx_pci_write_register(pcr, RTS524A_PM_CTRL3, > + D3_DELINK_MODE_EN, 0x00); > + if (err < 0) > + return err; > + > + rtsx_pci_write_phy_register(pcr, PHY_PCR, > + PHY_PCR_FORCE_CODE | PHY_PCR_OOBS_CALI_50 | > + PHY_PCR_OOBS_VCM_08 | PHY_PCR_OOBS_SEN_90 | PHY_PCR_RSSI_EN); > + rtsx_pci_write_phy_register(pcr, PHY_SSCCR3, > + PHY_SSCCR3_STEP_IN | PHY_SSCCR3_CHECK_DELAY); > + > + if (is_version(pcr, 0x524A, IC_VER_A)) { > + rtsx_pci_write_phy_register(pcr, PHY_SSCCR3, > + PHY_SSCCR3_STEP_IN | PHY_SSCCR3_CHECK_DELAY); > + rtsx_pci_write_phy_register(pcr, PHY_SSCCR2, > + PHY_SSCCR2_PLL_NCODE | PHY_SSCCR2_TIME0 | > + PHY_SSCCR2_TIME2_WIDTH); > + rtsx_pci_write_phy_register(pcr, PHY_ANA1A, > + PHY_ANA1A_TXR_LOOPBACK | PHY_ANA1A_RXT_BIST | > + PHY_ANA1A_TXR_BIST | PHY_ANA1A_REV); > + rtsx_pci_write_phy_register(pcr, PHY_ANA1D, > + PHY_ANA1D_DEBUG_ADDR); > + rtsx_pci_write_phy_register(pcr, PHY_DIG1E, > + PHY_DIG1E_REV | PHY_DIG1E_D0_X_D1 | > + PHY_DIG1E_RX_ON_HOST | PHY_DIG1E_RCLK_REF_HOST | > + PHY_DIG1E_RCLK_TX_EN_KEEP | > + PHY_DIG1E_RCLK_TX_TERM_KEEP | > + PHY_DIG1E_RCLK_RX_EIDLE_ON | PHY_DIG1E_TX_TERM_KEEP | > + PHY_DIG1E_RX_TERM_KEEP | PHY_DIG1E_TX_EN_KEEP | > + PHY_DIG1E_RX_EN_KEEP); > + } > + > + rtsx_pci_write_phy_register(pcr, PHY_ANA08, > + PHY_ANA08_RX_EQ_DCGAIN | PHY_ANA08_SEL_RX_EN | > + PHY_ANA08_RX_EQ_VAL | PHY_ANA08_SCP | PHY_ANA08_SEL_IPI); > To the uninitiated this function is mostly randomness. How about some > nice comments to illuminate? I'm not clear with these setting either, it is used to fix some phy setting, the default phy setting it not stable on some special platform, so we have to modify them by driver, newer version of chip will change its default value to more stable configure, so some value is no need to setting for Version B/C... > >> diff --git a/drivers/mfd/rtsx_pcr.h b/drivers/mfd/rtsx_pcr.h >> index fe2bbb6..e7daf6f 100644 >> --- a/drivers/mfd/rtsx_pcr.h >> +++ b/drivers/mfd/rtsx_pcr.h >> @@ -27,12 +27,19 @@ >> #define MIN_DIV_N_PCR 80 >> #define MAX_DIV_N_PCR 208 >> >> +#define RTS524A_PME_FORCE_CTL 0xFF78 >> +#define RTS524A_PM_CTRL3 0xFF7E >> + >> +int __rtsx_pci_write_phy_register(struct rtsx_pcr *pcr, u8 addr, u16 val); >> +int __rtsx_pci_read_phy_register(struct rtsx_pcr *pcr, u8 addr, u16 *val); >> + >> void rts5209_init_params(struct rtsx_pcr *pcr); >> void rts5229_init_params(struct rtsx_pcr *pcr); >> void rtl8411_init_params(struct rtsx_pcr *pcr); >> void rtl8402_init_params(struct rtsx_pcr *pcr); >> void rts5227_init_params(struct rtsx_pcr *pcr); >> void rts5249_init_params(struct rtsx_pcr *pcr); >> +void rts524a_init_params(struct rtsx_pcr *pcr); >> void rtl8411b_init_params(struct rtsx_pcr *pcr); >> >> static inline u8 map_sd_drive(int idx) >> diff --git a/include/linux/mfd/rtsx_pci.h b/include/linux/mfd/rtsx_pci.h >> index 33cc63c..a392546 100644 >> --- a/include/linux/mfd/rtsx_pci.h >> +++ b/include/linux/mfd/rtsx_pci.h >> @@ -577,8 +577,16 @@ >> >> >> #define PCR_SETTING_REG1 0x724 >> @@ -729,6 +831,8 @@ struct pcr_handle { >> }; >> >> struct pcr_ops { >> + int (*write_phy)(struct rtsx_pcr *pcr, u8 addr, u16 val); >> + int (*read_phy)(struct rtsx_pcr *pcr, u8 addr, u16 *val); >> int (*extra_init_hw)(struct rtsx_pcr *pcr); >> int (*optimize_phy)(struct rtsx_pcr *pcr); >> int (*turn_on_led)(struct rtsx_pcr *pcr); >> @@ -830,6 +934,10 @@ struct rtsx_pcr { >> #define CHK_PCI_PID(pcr, pid) ((pcr)->pci->device == (pid)) >> #define PCI_VID(pcr) ((pcr)->pci->vendor) >> #define PCI_PID(pcr) ((pcr)->pci->device) >> +#define is_version(pcr, pid, ver) \ >> + (CHK_PCI_PID(pcr, pid) && (pcr)->ic_version == (ver)) >> +#define pcr_dbg(pcr, fmt, arg...) \ >> + dev_dbg(&(pcr)->pci->dev, fmt, ##arg) >> >> #define SDR104_PHASE(val) ((val) & 0xFF) >> #define SDR50_PHASE(val) (((val) >> 8) & 0xFF) >> @@ -899,4 +1007,17 @@ static inline void rtsx_pci_write_be32(struct rtsx_pcr *pcr, u16 reg, u32 val) >> rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, reg + 3, 0xFF, val); >> } >> >> +static inline int rtsx_pci_update_phy(struct rtsx_pcr *pcr, u8 addr, >> + u16 mask, u16 append) >> +{ >> + int err; >> + u16 val; >> + >> + err = rtsx_pci_read_phy_register(pcr, addr, &val); >> + if (err < 0) >> + return err; >> + >> + return rtsx_pci_write_phy_register(pcr, addr, (val & mask) | append); >> +} > Why is this in here? This is a good api for update phy register, mmc/ms driver can use this function. > >> #endif ????{.n?+???????+%?????ݶ??w??{.n?+????{??G?????{ay?ʇڙ?,j??f???h?????????z_??(?階?ݢj"???m??????G????????????&???~???iO???z??v?^?m???? ????????I?