Re: [RESEND PATCH v2 7/9] mfd: rtsx: add support for rts524A

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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
_______________________________________________
devel mailing list
devel@xxxxxxxxxxxxxxxxxxxxxx
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel




[Index of Archives]     [Linux Driver Backports]     [DMA Engine]     [Linux GPIO]     [Linux SPI]     [Video for Linux]     [Linux USB Devel]     [Linux Coverity]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]
  Powered by Linux