mfd: rtsx: add support for new rts524A and rts525A
v2 cover mfd: rtsx: add support for new rts524A and rts525A
From: Micky Ching <[email protected]>
v2:
- remove debug info when access failed.
- using macro list for phy register init.
- rename function for multi chip prefix with rtsx_base_
- save pcie_cap offset when init chip, not calling pci_find_capacity() every time.
- add pcr->ops: write_phy/read_phy for special chip.
This patchset including re-format some coding-style and add two new chip rts524A and rts525A.
Micky Ching (9):
mfd: rtsx: replace TAB by SPC after #define
mfd: rtsx: place register address and values togather
mfd: rtsx: update PETXCFG address
mfd: rtsx: update driving settings
mfd: rtsx: update phy register
mfd: rtsx: remove LCTLR defination
mfd: rtsx: add support for rts524A
mfd: rtsx: add support for rts525A
mfd: rtsx: using pcr_dbg replace dev_dbg
drivers/mfd/Makefile | 2 +- drivers/mfd/rtl8411.c | 11 +- drivers/mfd/rts5209.c | 4 +- drivers/mfd/rts5227.c | 12 +- drivers/mfd/rts5229.c | 4 +- drivers/mfd/rts5249.c | 368 +++++++++++--- drivers/mfd/rtsx_gops.c | 37 -- drivers/mfd/rtsx_pcr.c | 110 +++-- drivers/mfd/rtsx_pcr.h | 8 + include/linux/mfd/rtsx_pci.h | 1109 ++++++++++++++++++++++-------------------- 10 files changed, 966 insertions(+), 699 deletions(-) delete mode 100644 drivers/mfd/rtsx_gops.c
Signature · 1 line
1.9.1
PATCH v2 1/9 mfd: rtsx: replace TAB by SPC after #define
From: Micky Ching <[email protected]>
Re-format coding-style, using uniform SPC after "#define" keyword instead of mixing using TAB and SPC.
--- include/linux/mfd/rtsx_pci.h | 254 +++++++++++++++++++++---------------------- 1 file changed, 127 insertions(+), 127 deletions(-)
include/linux/mfd/rtsx_pci.h +127 -127
@@ -175,9 +175,9 @@/* CARD_SHARE_MODE */ #define CARD_SHARE_MASK 0x0F#define CARD_SHARE_MULTI_LUN 0x00 -#define CARD_SHARE_NORMAL 0x00 -#define CARD_SHARE_48_SD 0x04 -#define CARD_SHARE_48_MS 0x08 +#define CARD_SHARE_NORMAL 0x00 +#define CARD_SHARE_48_SD 0x04 +#define CARD_SHARE_48_MS 0x08/* CARD_SHARE_MODE for barossa */ #define CARD_SHARE_BAROSSA_SD 0x01#define CARD_SHARE_BAROSSA_MS 0x02
@@ -249,76 +249,76 @@#define CD_AUTO_DISABLE 0x40/* SD_STAT1 */ -#define SD_CRC7_ERR 0x80 -#define SD_CRC16_ERR 0x40 -#define SD_CRC_WRITE_ERR 0x20 -#define SD_CRC_WRITE_ERR_MASK 0x1C -#define GET_CRC_TIME_OUT 0x02 -#define SD_TUNING_COMPARE_ERR 0x01 +#define SD_CRC7_ERR 0x80 +#define SD_CRC16_ERR 0x40 +#define SD_CRC_WRITE_ERR 0x20 +#define SD_CRC_WRITE_ERR_MASK 0x1C +#define GET_CRC_TIME_OUT 0x02 +#define SD_TUNING_COMPARE_ERR 0x01/* SD_STAT2 */ -#define SD_RSP_80CLK_TIMEOUT 0x01 +#define SD_RSP_80CLK_TIMEOUT 0x01/* SD_BUS_STAT */ -#define SD_CLK_TOGGLE_EN 0x80 -#define SD_CLK_FORCE_STOP 0x40 -#define SD_DAT3_STATUS 0x10 -#define SD_DAT2_STATUS 0x08 -#define SD_DAT1_STATUS 0x04 -#define SD_DAT0_STATUS 0x02 -#define SD_CMD_STATUS 0x01 +#define SD_CLK_TOGGLE_EN 0x80 +#define SD_CLK_FORCE_STOP 0x40 +#define SD_DAT3_STATUS 0x10 +#define SD_DAT2_STATUS 0x08 +#define SD_DAT1_STATUS 0x04 +#define SD_DAT0_STATUS 0x02 +#define SD_CMD_STATUS 0x01/* SD_PAD_CTL */ -#define SD_IO_USING_1V8 0x80 -#define SD_IO_USING_3V3 0x7F -#define TYPE_A_DRIVING 0x00 -#define TYPE_B_DRIVING 0x01 -#define TYPE_C_DRIVING 0x02 -#define TYPE_D_DRIVING 0x03 +#define SD_IO_USING_1V8 0x80 +#define SD_IO_USING_3V3 0x7F +#define TYPE_A_DRIVING 0x00 +#define TYPE_B_DRIVING 0x01 +#define TYPE_C_DRIVING 0x02 +#define TYPE_D_DRIVING 0x03/* SD_SAMPLE_POINT_CTL */ -#define DDR_FIX_RX_DAT 0x00 -#define DDR_VAR_RX_DAT 0x80 -#define DDR_FIX_RX_DAT_EDGE 0x00 -#define DDR_FIX_RX_DAT_14_DELAY 0x40 -#define DDR_FIX_RX_CMD 0x00 -#define DDR_VAR_RX_CMD 0x20 -#define DDR_FIX_RX_CMD_POS_EDGE 0x00 -#define DDR_FIX_RX_CMD_14_DELAY 0x10 -#define SD20_RX_POS_EDGE 0x00 -#define SD20_RX_14_DELAY 0x08 +#define DDR_FIX_RX_DAT 0x00 +#define DDR_VAR_RX_DAT 0x80 +#define DDR_FIX_RX_DAT_EDGE 0x00 +#define DDR_FIX_RX_DAT_14_DELAY 0x40 +#define DDR_FIX_RX_CMD 0x00 +#define DDR_VAR_RX_CMD 0x20 +#define DDR_FIX_RX_CMD_POS_EDGE 0x00 +#define DDR_FIX_RX_CMD_14_DELAY 0x10 +#define SD20_RX_POS_EDGE 0x00 +#define SD20_RX_14_DELAY 0x08#define SD20_RX_SEL_MASK 0x08/* SD_PUSH_POINT_CTL */ -#define DDR_FIX_TX_CMD_DAT 0x00 -#define DDR_VAR_TX_CMD_DAT 0x80 -#define DDR_FIX_TX_DAT_14_TSU 0x00 -#define DDR_FIX_TX_DAT_12_TSU 0x40 -#define DDR_FIX_TX_CMD_NEG_EDGE 0x00 -#define DDR_FIX_TX_CMD_14_AHEAD 0x20 -#define SD20_TX_NEG_EDGE 0x00 -#define SD20_TX_14_AHEAD 0x10 +#define DDR_FIX_TX_CMD_DAT 0x00 +#define DDR_VAR_TX_CMD_DAT 0x80 +#define DDR_FIX_TX_DAT_14_TSU 0x00 +#define DDR_FIX_TX_DAT_12_TSU 0x40 +#define DDR_FIX_TX_CMD_NEG_EDGE 0x00 +#define DDR_FIX_TX_CMD_14_AHEAD 0x20 +#define SD20_TX_NEG_EDGE 0x00 +#define SD20_TX_14_AHEAD 0x10#define SD20_TX_SEL_MASK 0x10 -#define DDR_VAR_SDCLK_POL_SWAP 0x01 +#define DDR_VAR_SDCLK_POL_SWAP 0x01/* SD_TRANSFER */ -#define SD_TRANSFER_START 0x80 -#define SD_TRANSFER_END 0x40 +#define SD_TRANSFER_START 0x80 +#define SD_TRANSFER_END 0x40#define SD_STAT_IDLE 0x20 -#define SD_TRANSFER_ERR 0x10 +#define SD_TRANSFER_ERR 0x10/* SD Transfer Mode definition */ -#define SD_TM_NORMAL_WRITE 0x00 -#define SD_TM_AUTO_WRITE_3 0x01 -#define SD_TM_AUTO_WRITE_4 0x02 -#define SD_TM_AUTO_READ_3 0x05 -#define SD_TM_AUTO_READ_4 0x06 -#define SD_TM_CMD_RSP 0x08 -#define SD_TM_AUTO_WRITE_1 0x09 -#define SD_TM_AUTO_WRITE_2 0x0A -#define SD_TM_NORMAL_READ 0x0C -#define SD_TM_AUTO_READ_1 0x0D -#define SD_TM_AUTO_READ_2 0x0E -#define SD_TM_AUTO_TUNING 0x0F +#define SD_TM_NORMAL_WRITE 0x00 +#define SD_TM_AUTO_WRITE_3 0x01 +#define SD_TM_AUTO_WRITE_4 0x02 +#define SD_TM_AUTO_READ_3 0x05 +#define SD_TM_AUTO_READ_4 0x06 +#define SD_TM_CMD_RSP 0x08 +#define SD_TM_AUTO_WRITE_1 0x09 +#define SD_TM_AUTO_WRITE_2 0x0A +#define SD_TM_NORMAL_READ 0x0C +#define SD_TM_AUTO_READ_1 0x0D +#define SD_TM_AUTO_READ_2 0x0E +#define SD_TM_AUTO_TUNING 0x0F/* SD_VPTX_CTL / SD_VPRX_CTL */ #define PHASE_CHANGE 0x80
@@ -332,15 +332,15 @@/* SD Configure 1 Register */ #define SD_CLK_DIVIDE_0 0x00 -#define SD_CLK_DIVIDE_256 0xC0 -#define SD_CLK_DIVIDE_128 0x80 -#define SD_BUS_WIDTH_1BIT 0x00 -#define SD_BUS_WIDTH_4BIT 0x01 -#define SD_BUS_WIDTH_8BIT 0x02 -#define SD_ASYNC_FIFO_NOT_RST 0x10 -#define SD_20_MODE 0x00 -#define SD_DDR_MODE 0x04 -#define SD_30_MODE 0x08 +#define SD_CLK_DIVIDE_256 0xC0 +#define SD_CLK_DIVIDE_128 0x80 +#define SD_BUS_WIDTH_1BIT 0x00 +#define SD_BUS_WIDTH_4BIT 0x01 +#define SD_BUS_WIDTH_8BIT 0x02 +#define SD_ASYNC_FIFO_NOT_RST 0x10 +#define SD_20_MODE 0x00 +#define SD_DDR_MODE 0x04 +#define SD_30_MODE 0x08#define SD_CLK_DIVIDE_MASK 0xC0
@@ -415,71 +415,71 @@#define CLK_DIV_8 0x04/* MS_CFG */ -#define SAMPLE_TIME_RISING 0x00 -#define SAMPLE_TIME_FALLING 0x80 -#define PUSH_TIME_DEFAULT 0x00 -#define PUSH_TIME_ODD 0x40 -#define NO_EXTEND_TOGGLE 0x00 -#define EXTEND_TOGGLE_CHK 0x20 -#define MS_BUS_WIDTH_1 0x00 -#define MS_BUS_WIDTH_4 0x10 -#define MS_BUS_WIDTH_8 0x18 -#define MS_2K_SECTOR_MODE 0x04 -#define MS_512_SECTOR_MODE 0x00 -#define MS_TOGGLE_TIMEOUT_EN 0x00 -#define MS_TOGGLE_TIMEOUT_DISEN 0x01 +#define SAMPLE_TIME_RISING 0x00 +#define SAMPLE_TIME_FALLING 0x80 +#define PUSH_TIME_DEFAULT 0x00 +#define PUSH_TIME_ODD 0x40 +#define NO_EXTEND_TOGGLE 0x00 +#define EXTEND_TOGGLE_CHK 0x20 +#define MS_BUS_WIDTH_1 0x00 +#define MS_BUS_WIDTH_4 0x10 +#define MS_BUS_WIDTH_8 0x18 +#define MS_2K_SECTOR_MODE 0x04 +#define MS_512_SECTOR_MODE 0x00 +#define MS_TOGGLE_TIMEOUT_EN 0x00 +#define MS_TOGGLE_TIMEOUT_DISEN 0x01#define MS_NO_CHECK_INT 0x02/* MS_TRANS_CFG */ -#define WAIT_INT 0x80 -#define NO_WAIT_INT 0x00 -#define NO_AUTO_READ_INT_REG 0x00 -#define AUTO_READ_INT_REG 0x40 -#define MS_CRC16_ERR 0x20 -#define MS_RDY_TIMEOUT 0x10 -#define MS_INT_CMDNK 0x08 -#define MS_INT_BREQ 0x04 -#define MS_INT_ERR 0x02 -#define MS_INT_CED 0x01 +#define WAIT_INT 0x80 +#define NO_WAIT_INT 0x00 +#define NO_AUTO_READ_INT_REG 0x00 +#define AUTO_READ_INT_REG 0x40 +#define MS_CRC16_ERR 0x20 +#define MS_RDY_TIMEOUT 0x10 +#define MS_INT_CMDNK 0x08 +#define MS_INT_BREQ 0x04 +#define MS_INT_ERR 0x02 +#define MS_INT_CED 0x01/* MS_TRANSFER */ -#define MS_TRANSFER_START 0x80 -#define MS_TRANSFER_END 0x40 -#define MS_TRANSFER_ERR 0x20 -#define MS_BS_STATE 0x10 -#define MS_TM_READ_BYTES 0x00 -#define MS_TM_NORMAL_READ 0x01 -#define MS_TM_WRITE_BYTES 0x04 -#define MS_TM_NORMAL_WRITE 0x05 -#define MS_TM_AUTO_READ 0x08 -#define MS_TM_AUTO_WRITE 0x0C +#define MS_TRANSFER_START 0x80 +#define MS_TRANSFER_END 0x40 +#define MS_TRANSFER_ERR 0x20 +#define MS_BS_STATE 0x10 +#define MS_TM_READ_BYTES 0x00 +#define MS_TM_NORMAL_READ 0x01 +#define MS_TM_WRITE_BYTES 0x04 +#define MS_TM_NORMAL_WRITE 0x05 +#define MS_TM_AUTO_READ 0x08 +#define MS_TM_AUTO_WRITE 0x0C/* SD Configure 2 Register */ -#define SD_CALCULATE_CRC7 0x00 -#define SD_NO_CALCULATE_CRC7 0x80 -#define SD_CHECK_CRC16 0x00 -#define SD_NO_CHECK_CRC16 0x40 +#define SD_CALCULATE_CRC7 0x00 +#define SD_NO_CALCULATE_CRC7 0x80 +#define SD_CHECK_CRC16 0x00 +#define SD_NO_CHECK_CRC16 0x40#define SD_NO_CHECK_WAIT_CRC_TO 0x20 -#define SD_WAIT_BUSY_END 0x08 -#define SD_NO_WAIT_BUSY_END 0x00 -#define SD_CHECK_CRC7 0x00 -#define SD_NO_CHECK_CRC7 0x04 -#define SD_RSP_LEN_0 0x00 -#define SD_RSP_LEN_6 0x01 -#define SD_RSP_LEN_17 0x02 +#define SD_WAIT_BUSY_END 0x08 +#define SD_NO_WAIT_BUSY_END 0x00 +#define SD_CHECK_CRC7 0x00 +#define SD_NO_CHECK_CRC7 0x04 +#define SD_RSP_LEN_0 0x00 +#define SD_RSP_LEN_6 0x01 +#define SD_RSP_LEN_17 0x02/* SD/MMC Response Type Definition */ -#define SD_RSP_TYPE_R0 0x04 -#define SD_RSP_TYPE_R1 0x01 -#define SD_RSP_TYPE_R1b 0x09 -#define SD_RSP_TYPE_R2 0x02 -#define SD_RSP_TYPE_R3 0x05 -#define SD_RSP_TYPE_R4 0x05 -#define SD_RSP_TYPE_R5 0x01 -#define SD_RSP_TYPE_R6 0x01 -#define SD_RSP_TYPE_R7 0x01 +#define SD_RSP_TYPE_R0 0x04 +#define SD_RSP_TYPE_R1 0x01 +#define SD_RSP_TYPE_R1b 0x09 +#define SD_RSP_TYPE_R2 0x02 +#define SD_RSP_TYPE_R3 0x05 +#define SD_RSP_TYPE_R4 0x05 +#define SD_RSP_TYPE_R5 0x01 +#define SD_RSP_TYPE_R6 0x01 +#define SD_RSP_TYPE_R7 0x01/* SD_CONFIGURE3 */ -#define SD_RSP_80CLK_TIMEOUT_EN 0x01 +#define SD_RSP_80CLK_TIMEOUT_EN 0x01/* Card Transfer Reset Register */ #define SPI_STOP 0x01
@@ -574,13 +574,13 @@#define SRCTL 0xFC13 -#define DCM_DRP_CTL 0xFC23 -#define DCM_DRP_TRIG 0xFC24 -#define DCM_DRP_CFG 0xFC25 -#define DCM_DRP_WR_DATA_L 0xFC26 -#define DCM_DRP_WR_DATA_H 0xFC27 -#define DCM_DRP_RD_DATA_L 0xFC28 -#define DCM_DRP_RD_DATA_H 0xFC29 +#define DCM_DRP_CTL 0xFC23 +#define DCM_DRP_TRIG 0xFC24 +#define DCM_DRP_CFG 0xFC25 +#define DCM_DRP_WR_DATA_L 0xFC26 +#define DCM_DRP_WR_DATA_H 0xFC27 +#define DCM_DRP_RD_DATA_L 0xFC28 +#define DCM_DRP_RD_DATA_H 0xFC29#define SD_VPCLK0_CTL 0xFC2A#define SD_VPCLK1_CTL 0xFC2B#define SD_DCMPS0_CTL 0xFC2C
Signature · 1 line
1.9.1
PATCH v2 7/9 mfd: rtsx: add support for rts524A
In reply to [email protected]From: Micky Ching <[email protected]>
add support for new chip rts524A.
--- drivers/mfd/rts5249.c | 186 ++++++++++++++++++++++++++++++++++++------- drivers/mfd/rtsx_pcr.c | 25 +++++- drivers/mfd/rtsx_pcr.h | 7 ++ include/linux/mfd/rtsx_pci.h | 125 ++++++++++++++++++++++++++++- 4 files changed, 310 insertions(+), 33 deletions(-)
drivers/mfd/rts5249.c +157 -29
@@ -65,15 +65,17 @@ static void rts5249_fill_driving(struct rtsx_pcr *pcr, u8 voltage) 0xFF, driving[drive_sel][2]); } -static void rts5249_fetch_vendor_settings (struct rtsx_pcr *pcr) +static void rtsx_base_fetch_vendor_settings (struct rtsx_pcr *pcr) {u32 reg;rtsx_pci_read_config_dword (pcr,PCR_SETTING_REG1 , ®);dev_dbg (&(pcr->pci->dev),"Cfg 0x%x: 0x%x\n" ,PCR_SETTING_REG1 , reg); -if (!rtsx_vendor_setting_valid (reg)) +if (!rtsx_vendor_setting_valid (reg)) { +pcr_dbg (pcr,"skip fetch vendor setting\n" );return ; + } pcr->aspm_en =rtsx_reg_to_aspm (reg); pcr->sd30_drive_sel_1v8 =rtsx_reg_to_sd30_drive_sel_1v8 (reg);
@@ -87,15 +89,21 @@ static void rts5249_fetch_vendor_settings(struct rtsx_pcr *pcr) pcr->flags |=PCR_REVERSE_SOCKET ; } -static void rts5249_force_power_down (struct rtsx_pcr *pcr,u8 pm_state) +static void rtsx_base_force_power_down (struct rtsx_pcr *pcr,u8 pm_state) {/* Set relink_time to 0 */ rtsx_pci_write_register (pcr,AUTOLOAD_CFG_BASE +1 ,0xFF ,0 );rtsx_pci_write_register (pcr,AUTOLOAD_CFG_BASE +2 ,0xFF ,0 );rtsx_pci_write_register (pcr,AUTOLOAD_CFG_BASE +3 ,0x01 ,0 ); -if (pm_state ==HOST_ENTER_S3 ) -rtsx_pci_write_register (pcr,PM_CTRL3 ,0x10 ,0x10 ); +if (pm_state ==HOST_ENTER_S3 ) { +if (PCI_PID (pcr) ==0x524A ) +rtsx_pci_write_register (pcr,RTS524A_PM_CTRL3 , +D3_DELINK_MODE_EN ,D3_DELINK_MODE_EN ); +else if (PCI_PID (pcr) ==0x5249 ) +rtsx_pci_write_register (pcr,PM_CTRL3 , +D3_DELINK_MODE_EN ,D3_DELINK_MODE_EN ); + }rtsx_pci_write_register (pcr,FPDCTL ,0x03 ,0x03 ); }
@@ -104,6 +112,8 @@ static int rts5249_extra_init_hw(struct rtsx_pcr *pcr) {rtsx_pci_init_cmd (pcr); +/* Rest L1SUB Config */ +rtsx_pci_add_cmd (pcr,WRITE_REG_CMD ,L1SUB_CONFIG3 ,0xFF ,0x00 );/* Configure GPIO as output */ rtsx_pci_add_cmd (pcr,WRITE_REG_CMD ,GPIO_CTL ,0x02 ,0x02 );/* Reset ASPM state to default value */
@@ -189,27 +199,27 @@ static int rts5249_optimize_phy(struct rtsx_pcr *pcr) PHY_TUNE_TUNED12 | PHY_TUNE_TUNEA12); } -static int rts5249_turn_on_led (struct rtsx_pcr *pcr) +static int rtsx_base_turn_on_led (struct rtsx_pcr *pcr) {return rtsx_pci_write_register (pcr,GPIO_CTL ,0x02 ,0x02 ); } -static int rts5249_turn_off_led (struct rtsx_pcr *pcr) +static int rtsx_base_turn_off_led (struct rtsx_pcr *pcr) {return rtsx_pci_write_register (pcr,GPIO_CTL ,0x02 ,0x00 ); } -static int rts5249_enable_auto_blink (struct rtsx_pcr *pcr) +static int rtsx_base_enable_auto_blink (struct rtsx_pcr *pcr) {return rtsx_pci_write_register (pcr,OLT_LED_CTL ,0x08 ,0x08 ); } -static int rts5249_disable_auto_blink (struct rtsx_pcr *pcr) +static int rtsx_base_disable_auto_blink (struct rtsx_pcr *pcr) {return rtsx_pci_write_register (pcr,OLT_LED_CTL ,0x08 ,0x00 ); } -static int rts5249_card_power_on (struct rtsx_pcr *pcr,int card) +static int rtsx_base_card_power_on (struct rtsx_pcr *pcr,int card) {int err;
@@ -236,7 +246,7 @@ static int rts5249_card_power_on(struct rtsx_pcr *pcr, int card)return 0 ; } -static int rts5249_card_power_off (struct rtsx_pcr *pcr,int card) +static int rtsx_base_card_power_off (struct rtsx_pcr *pcr,int card) {rtsx_pci_init_cmd (pcr); rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, CARD_PWR_CTL,
@@ -246,22 +256,31 @@ static int rts5249_card_power_off(struct rtsx_pcr *pcr, int card)return rtsx_pci_send_cmd (pcr,100 ); } -static int rts5249_switch_output_voltage (struct rtsx_pcr *pcr,u8 voltage) +static int rtsx_base_switch_output_voltage (struct rtsx_pcr *pcr,u8 voltage) {int err; +u16 append; -if (voltage ==OUTPUT_3V3 ) { - err =rtsx_pci_write_phy_register (pcr,PHY_TUNE ,0x4FC0 |0x24 ); -if (err <0 ) -return err; - }else if (voltage ==OUTPUT_1V8 ) { - err =rtsx_pci_write_phy_register (pcr,PHY_BACR ,0x3C02 ); +switch (voltage) { +case OUTPUT_3V3 : + err =rtsx_pci_update_phy (pcr,PHY_TUNE ,0xFC3F ,0x03C0 );if (err <0 )return err; - err =rtsx_pci_write_phy_register (pcr,PHY_TUNE ,0x4C40 |0x24 ); +break ; +case OUTPUT_1V8 : + append =0x0100 ; +if (PCI_PID (pcr) ==0x5249 ) { + err =rtsx_pci_update_phy (pcr,PHY_BACR ,0xFFF3 ,0 ); +if (err <0 ) +return err; + append =0x0080 ; + } + + err =rtsx_pci_update_phy (pcr,PHY_TUNE ,0xFC3F , append);if (err <0 )return err; - }else { +break ; +default :return -EINVAL ; }
@@ -272,17 +291,17 @@ static int rts5249_switch_output_voltage(struct rtsx_pcr *pcr, u8 voltage) }static const struct pcr_ops rts5249_pcr_ops = { - .fetch_vendor_settings = rts5249_fetch_vendor_settings, + .fetch_vendor_settings = rtsx_base_fetch_vendor_settings, .extra_init_hw = rts5249_extra_init_hw, .optimize_phy = rts5249_optimize_phy, - .turn_on_led = rts5249_turn_on_led, - .turn_off_led = rts5249_turn_off_led, - .enable_auto_blink = rts5249_enable_auto_blink, - .disable_auto_blink = rts5249_disable_auto_blink, - .card_power_on = rts5249_card_power_on, - .card_power_off = rts5249_card_power_off, - .switch_output_voltage = rts5249_switch_output_voltage, - .force_power_down = rts5249_force_power_down, + .turn_on_led = rtsx_base_turn_on_led, + .turn_off_led = rtsx_base_turn_off_led, + .enable_auto_blink = rtsx_base_enable_auto_blink, + .disable_auto_blink = rtsx_base_disable_auto_blink, + .card_power_on = rtsx_base_card_power_on, + .card_power_off = rtsx_base_card_power_off, + .switch_output_voltage = rtsx_base_switch_output_voltage, + .force_power_down = rtsx_base_force_power_down, };/* SD Pull Control Enable:
@@ -357,3 +376,112 @@ void rts5249_init_params(struct rtsx_pcr *pcr) pcr->ms_pull_ctl_enable_tbl = rts5249_ms_pull_ctl_enable_tbl; pcr->ms_pull_ctl_disable_tbl = rts5249_ms_pull_ctl_disable_tbl; } + +static int rts524a_write_phy (struct rtsx_pcr *pcr,u8 addr,u16 val) +{ + addr = addr &0x80 ? (addr &0x7F ) |0x40 : addr; + +return __rtsx_pci_write_phy_register (pcr, addr, val); +} + +static int rts524a_read_phy (struct rtsx_pcr *pcr,u8 addr,u16 *val) +{ + addr = addr &0x80 ? (addr &0x7F ) |0x40 : addr; + +return __rtsx_pci_read_phy_register (pcr, addr, val); +} + +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 ); + +return 0 ; +} + +static int rts524a_extra_init_hw (struct rtsx_pcr *pcr) +{ +rts5249_extra_init_hw (pcr); + +rtsx_pci_write_register (pcr,FUNC_FORCE_CTL , +FORCE_ASPM_L1_EN ,FORCE_ASPM_L1_EN ); +rtsx_pci_write_register (pcr,PM_EVENT_DEBUG ,PME_DEBUG_0 ,PME_DEBUG_0 ); +rtsx_pci_write_register (pcr,LDO_VCC_CFG1 ,LDO_VCC_LMT_EN , +LDO_VCC_LMT_EN ); +rtsx_pci_write_register (pcr,PCLK_CTL ,PCLK_MODE_SEL ,PCLK_MODE_SEL ); +if (is_version (pcr,0x524A ,IC_VER_A )) { +rtsx_pci_write_register (pcr,LDO_DV18_CFG , +LDO_DV18_SR_MASK ,LDO_DV18_SR_DF ); +rtsx_pci_write_register (pcr,LDO_VCC_CFG1 , +LDO_VCC_REF_TUNE_MASK ,LDO_VCC_REF_1V2 ); +rtsx_pci_write_register (pcr,LDO_VIO_CFG , +LDO_VIO_REF_TUNE_MASK ,LDO_VIO_REF_1V2 ); +rtsx_pci_write_register (pcr,LDO_VIO_CFG , +LDO_VIO_SR_MASK ,LDO_VIO_SR_DF ); +rtsx_pci_write_register (pcr,LDO_DV12S_CFG , +LDO_REF12_TUNE_MASK ,LDO_REF12_TUNE_DF ); +rtsx_pci_write_register (pcr,SD40_LDO_CTL1 , +SD40_VIO_TUNE_MASK ,SD40_VIO_TUNE_1V7 ); + } + +return 0 ; +} + +static const struct pcr_ops rts524a_pcr_ops = { + .write_phy = rts524a_write_phy, + .read_phy = rts524a_read_phy, + .fetch_vendor_settings = rtsx_base_fetch_vendor_settings, + .extra_init_hw = rts524a_extra_init_hw, + .optimize_phy = rts524a_optimize_phy, + .turn_on_led = rtsx_base_turn_on_led, + .turn_off_led = rtsx_base_turn_off_led, + .enable_auto_blink = rtsx_base_enable_auto_blink, + .disable_auto_blink = rtsx_base_disable_auto_blink, + .card_power_on = rtsx_base_card_power_on, + .card_power_off = rtsx_base_card_power_off, + .switch_output_voltage = rtsx_base_switch_output_voltage, + .force_power_down = rtsx_base_force_power_down, +}; + +void rts524a_init_params (struct rtsx_pcr *pcr) +{ +rts5249_init_params (pcr); + + pcr->ops = &rts524a_pcr_ops; +} +
drivers/mfd/rtsx_pcr.c +23 -2
@@ -58,6 +58,7 @@ static const struct pci_device_id rtsx_pci_ids[] = { { PCI_DEVICE(0x10EC, 0x5249), PCI_CLASS_OTHERS << 16, 0xFF0000 }, { PCI_DEVICE(0x10EC, 0x5287), PCI_CLASS_OTHERS << 16, 0xFF0000 }, { PCI_DEVICE(0x10EC, 0x5286), PCI_CLASS_OTHERS << 16, 0xFF0000 }, + { PCI_DEVICE(0x10EC, 0x524A), PCI_CLASS_OTHERS << 16, 0xFF0000 }, { 0, } };
@@ -143,7 +144,7 @@ int rtsx_pci_read_register(struct rtsx_pcr *pcr, u16 addr, u8 *data) }EXPORT_SYMBOL_GPL (rtsx_pci_read_register); -int rtsx_pci_write_phy_register (struct rtsx_pcr *pcr,u8 addr,u16 val) +int __rtsx_pci_write_phy_register (struct rtsx_pcr *pcr,u8 addr,u16 val) {int err, i, finished =0 ;u8 tmp;
@@ -175,9 +176,17 @@ int rtsx_pci_write_phy_register(struct rtsx_pcr *pcr, u8 addr, u16 val)return 0 ; } + +int rtsx_pci_write_phy_register (struct rtsx_pcr *pcr,u8 addr,u16 val) +{ +if (pcr->ops->write_phy) +return pcr->ops->write_phy (pcr, addr, val); + +return __rtsx_pci_write_phy_register (pcr, addr, val); +}EXPORT_SYMBOL_GPL (rtsx_pci_write_phy_register); -int rtsx_pci_read_phy_register (struct rtsx_pcr *pcr,u8 addr,u16 *val) +int __rtsx_pci_read_phy_register (struct rtsx_pcr *pcr,u8 addr,u16 *val) {int err, i, finished =0 ;u16 data;
@@ -223,6 +232,14 @@ int rtsx_pci_read_phy_register(struct rtsx_pcr *pcr, u8 addr, u16 *val)return 0 ; } + +int rtsx_pci_read_phy_register (struct rtsx_pcr *pcr,u8 addr,u16 *val) +{ +if (pcr->ops->read_phy) +return pcr->ops->read_phy (pcr, addr, val); + +return __rtsx_pci_read_phy_register (pcr, addr, val); +}EXPORT_SYMBOL_GPL (rtsx_pci_read_phy_register);void rtsx_pci_stop_cmd (struct rtsx_pcr *pcr)
@@ -1094,6 +1111,10 @@ static int rtsx_pci_init_chip(struct rtsx_pcr *pcr)rts5249_init_params (pcr);break ; +case 0x524A : +rts524a_init_params (pcr); +break ; +case 0x5287 :rtl8411b_init_params (pcr);break ;
drivers/mfd/rtsx_pcr.h +7 -0
@@ -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)
include/linux/mfd/rtsx_pci.h +123 -2
209 lines not on this page · raw message
Signature · 1 line
1.9.1
PATCH v2 2/9 mfd: rtsx: place register address and values togather
In reply to [email protected]From: Micky Ching <[email protected]>
It is more readable to place register address and values define togather. The values define add two leading space indicate belong to the register address defined above.
--- include/linux/mfd/rtsx_pci.h | 836 +++++++++++++++++++------------------------ 1 file changed, 369 insertions(+), 467 deletions(-)
include/linux/mfd/rtsx_pci.h +369 -467
@@ -28,74 +28,72 @@#define MAX_RW_REG_CNT 1024 -/* PCI Operation Register Address */ #define RTSX_HCBAR 0x00#define RTSX_HCBCTLR 0x04 +#define STOP_CMD (0x01 << 28) +#define READ_REG_CMD 0 +#define WRITE_REG_CMD 1 +#define CHECK_REG_CMD 2 +#define RTSX_HDBAR 0x08 +#define SG_INT 0x04 +#define SG_END 0x02 +#define SG_VALID 0x01 +#define SG_NO_OP 0x00 +#define SG_TRANS_DATA (0x02 << 4) +#define SG_LINK_DESC (0x03 << 4)#define RTSX_HDBCTLR 0x0C +#define SDMA_MODE 0x00 +#define ADMA_MODE (0x02 << 26) +#define STOP_DMA (0x01 << 28) +#define TRIG_DMA (0x01 << 31) +#define RTSX_HAIMR 0x10 -#define RTSX_BIPR 0x14 -#define RTSX_BIER 0x18 +#define HAIMR_TRANS_START (0x01 << 31) +#define HAIMR_READ 0x00 +#define HAIMR_WRITE (0x01 << 30) +#define HAIMR_READ_START (HAIMR_TRANS_START | HAIMR_READ) +#define HAIMR_WRITE_START (HAIMR_TRANS_START | HAIMR_WRITE) +#define HAIMR_TRANS_END (HAIMR_TRANS_START) -/* Host command buffer control register */ -#define STOP_CMD (0x01 << 28) - -/* Host data buffer control register */ -#define SDMA_MODE 0x00 -#define ADMA_MODE (0x02 << 26) -#define STOP_DMA (0x01 << 28) -#define TRIG_DMA (0x01 << 31) - -/* Host access internal memory register */ -#define HAIMR_TRANS_START (0x01 << 31) -#define HAIMR_READ 0x00 -#define HAIMR_WRITE (0x01 << 30) -#define HAIMR_READ_START (HAIMR_TRANS_START | HAIMR_READ) -#define HAIMR_WRITE_START (HAIMR_TRANS_START | HAIMR_WRITE) -#define HAIMR_TRANS_END (HAIMR_TRANS_START) - -/* Bus interrupt pending register */ -#define CMD_DONE_INT (1 << 31) -#define DATA_DONE_INT (1 << 30) -#define TRANS_OK_INT (1 << 29) -#define TRANS_FAIL_INT (1 << 28) -#define XD_INT (1 << 27) -#define MS_INT (1 << 26) -#define SD_INT (1 << 25) -#define GPIO0_INT (1 << 24) -#define OC_INT (1 << 23) -#define SD_WRITE_PROTECT (1 << 19) -#define XD_EXIST (1 << 18) -#define MS_EXIST (1 << 17) -#define SD_EXIST (1 << 16) -#define DELINK_INT GPIO0_INT -#define MS_OC_INT (1 << 23) -#define SD_OC_INT (1 << 22) +#define RTSX_BIPR 0x14 +#define CMD_DONE_INT (1 << 31) +#define DATA_DONE_INT (1 << 30) +#define TRANS_OK_INT (1 << 29) +#define TRANS_FAIL_INT (1 << 28) +#define XD_INT (1 << 27) +#define MS_INT (1 << 26) +#define SD_INT (1 << 25) +#define GPIO0_INT (1 << 24) +#define OC_INT (1 << 23) +#define SD_WRITE_PROTECT (1 << 19) +#define XD_EXIST (1 << 18) +#define MS_EXIST (1 << 17) +#define SD_EXIST (1 << 16) +#define DELINK_INT GPIO0_INT +#define MS_OC_INT (1 << 23) +#define SD_OC_INT (1 << 22)#define CARD_INT (XD_INT | MS_INT | SD_INT)#define NEED_COMPLETE_INT (DATA_DONE_INT | TRANS_OK_INT | TRANS_FAIL_INT)#define RTSX_INT (CMD_DONE_INT | NEED_COMPLETE_INT | \ CARD_INT | GPIO0_INT | OC_INT) -#define CARD_EXIST (XD_EXIST | MS_EXIST | SD_EXIST) -/* Bus interrupt enable register */ -#define CMD_DONE_INT_EN (1 << 31) -#define DATA_DONE_INT_EN (1 << 30) -#define TRANS_OK_INT_EN (1 << 29) -#define TRANS_FAIL_INT_EN (1 << 28) -#define XD_INT_EN (1 << 27) -#define MS_INT_EN (1 << 26) -#define SD_INT_EN (1 << 25) -#define GPIO0_INT_EN (1 << 24) -#define OC_INT_EN (1 << 23) -#define DELINK_INT_EN GPIO0_INT_EN -#define MS_OC_INT_EN (1 << 23) -#define SD_OC_INT_EN (1 << 22) - -#define READ_REG_CMD 0 -#define WRITE_REG_CMD 1 -#define CHECK_REG_CMD 2 +#define RTSX_BIER 0x18 +#define CMD_DONE_INT_EN (1 << 31) +#define DATA_DONE_INT_EN (1 << 30) +#define TRANS_OK_INT_EN (1 << 29) +#define TRANS_FAIL_INT_EN (1 << 28) +#define XD_INT_EN (1 << 27) +#define MS_INT_EN (1 << 26) +#define SD_INT_EN (1 << 25) +#define GPIO0_INT_EN (1 << 24) +#define OC_INT_EN (1 << 23) +#define DELINK_INT_EN GPIO0_INT_EN +#define MS_OC_INT_EN (1 << 23) +#define SD_OC_INT_EN (1 << 22) +/* * macros for easy use
@@ -125,423 +123,68 @@#define rtsx_pci_write_config_dword (pcr, where, val) \ pci_write_config_dword((pcr)->pci, where, val) -#define STATE_TRANS_NONE 0 -#define STATE_TRANS_CMD 1 -#define STATE_TRANS_BUF 2 -#define STATE_TRANS_SG 3 - -#define TRANS_NOT_READY 0 -#define TRANS_RESULT_OK 1 -#define TRANS_RESULT_FAIL 2 -#define TRANS_NO_DEVICE 3 - -#define RTSX_RESV_BUF_LEN 4096 -#define HOST_CMDS_BUF_LEN 1024 -#define HOST_SG_TBL_BUF_LEN (RTSX_RESV_BUF_LEN - HOST_CMDS_BUF_LEN) -#define HOST_SG_TBL_ITEMS (HOST_SG_TBL_BUF_LEN / 8) -#define MAX_SG_ITEM_LEN 0x80000 - -#define HOST_TO_DEVICE 0 -#define DEVICE_TO_HOST 1 - -#define RTSX_PHASE_MAX 32 -#define RX_TUNING_CNT 3 - -/* SG descriptor */ -#define SG_INT 0x04 -#define SG_END 0x02 -#define SG_VALID 0x01 - -#define SG_NO_OP 0x00 -#define SG_TRANS_DATA (0x02 << 4) -#define SG_LINK_DESC (0x03 << 4) - -/* Output voltage */ -#define OUTPUT_3V3 0 -#define OUTPUT_1V8 1 - -/* Card Clock Enable Register */ -#define SD_CLK_EN 0x04 -#define MS_CLK_EN 0x08 - -/* Card Select Register */ -#define SD_MOD_SEL 2 -#define MS_MOD_SEL 3 - -/* Card Output Enable Register */ -#define SD_OUTPUT_EN 0x04 -#define MS_OUTPUT_EN 0x08 - -/* CARD_SHARE_MODE */ -#define CARD_SHARE_MASK 0x0F -#define CARD_SHARE_MULTI_LUN 0x00 -#define CARD_SHARE_NORMAL 0x00 -#define CARD_SHARE_48_SD 0x04 -#define CARD_SHARE_48_MS 0x08 -/* CARD_SHARE_MODE for barossa */ -#define CARD_SHARE_BAROSSA_SD 0x01 -#define CARD_SHARE_BAROSSA_MS 0x02 - -/* CARD_DRIVE_SEL */ -#define MS_DRIVE_8mA (0x01 << 6) -#define MMC_DRIVE_8mA (0x01 << 4) -#define XD_DRIVE_8mA (0x01 << 2) -#define GPIO_DRIVE_8mA 0x01 -#define RTS5209_CARD_DRIVE_DEFAULT (MS_DRIVE_8mA | MMC_DRIVE_8mA |\ - XD_DRIVE_8mA | GPIO_DRIVE_8mA) -#define RTL8411_CARD_DRIVE_DEFAULT (MS_DRIVE_8mA | MMC_DRIVE_8mA |\ - XD_DRIVE_8mA) -#define RTSX_CARD_DRIVE_DEFAULT (MS_DRIVE_8mA | GPIO_DRIVE_8mA) +#define STATE_TRANS_NONE 0 +#define STATE_TRANS_CMD 1 +#define STATE_TRANS_BUF 2 +#define STATE_TRANS_SG 3 -/* SD30_DRIVE_SEL */ -#define DRIVER_TYPE_A 0x05 -#define DRIVER_TYPE_B 0x03 -#define DRIVER_TYPE_C 0x02 -#define DRIVER_TYPE_D 0x01 -#define CFG_DRIVER_TYPE_A 0x02 -#define CFG_DRIVER_TYPE_B 0x03 -#define CFG_DRIVER_TYPE_C 0x01 -#define CFG_DRIVER_TYPE_D 0x00 - -/* FPDCTL */ -#define SSC_POWER_DOWN 0x01 -#define SD_OC_POWER_DOWN 0x02 -#define ALL_POWER_DOWN 0x07 -#define OC_POWER_DOWN 0x06 - -/* CLK_CTL */ -#define CHANGE_CLK 0x01 - -/* LDO_CTL */ -#define BPP_ASIC_1V7 0x00 -#define BPP_ASIC_1V8 0x01 -#define BPP_ASIC_1V9 0x02 -#define BPP_ASIC_2V0 0x03 -#define BPP_ASIC_2V7 0x04 -#define BPP_ASIC_2V8 0x05 -#define BPP_ASIC_3V2 0x06 -#define BPP_ASIC_3V3 0x07 -#define BPP_REG_TUNED18 0x07 -#define BPP_TUNED18_SHIFT_8402 5 -#define BPP_TUNED18_SHIFT_8411 4 -#define BPP_PAD_MASK 0x04 -#define BPP_PAD_3V3 0x04 -#define BPP_PAD_1V8 0x00 -#define BPP_LDO_POWB 0x03 -#define BPP_LDO_ON 0x00 -#define BPP_LDO_SUSPEND 0x02 -#define BPP_LDO_OFF 0x03 - -/* CD_PAD_CTL */ -#define CD_DISABLE_MASK 0x07 -#define MS_CD_DISABLE 0x04 -#define SD_CD_DISABLE 0x02 -#define XD_CD_DISABLE 0x01 -#define CD_DISABLE 0x07 -#define CD_ENABLE 0x00 -#define MS_CD_EN_ONLY 0x03 -#define SD_CD_EN_ONLY 0x05 -#define XD_CD_EN_ONLY 0x06 -#define FORCE_CD_LOW_MASK 0x38 -#define FORCE_CD_XD_LOW 0x08 -#define FORCE_CD_SD_LOW 0x10 -#define FORCE_CD_MS_LOW 0x20 -#define CD_AUTO_DISABLE 0x40 - -/* SD_STAT1 */ -#define SD_CRC7_ERR 0x80 -#define SD_CRC16_ERR 0x40 -#define SD_CRC_WRITE_ERR 0x20 -#define SD_CRC_WRITE_ERR_MASK 0x1C -#define GET_CRC_TIME_OUT 0x02 -#define SD_TUNING_COMPARE_ERR 0x01 - -/* SD_STAT2 */ -#define SD_RSP_80CLK_TIMEOUT 0x01 - -/* SD_BUS_STAT */ -#define SD_CLK_TOGGLE_EN 0x80 -#define SD_CLK_FORCE_STOP 0x40 -#define SD_DAT3_STATUS 0x10 -#define SD_DAT2_STATUS 0x08 -#define SD_DAT1_STATUS 0x04 -#define SD_DAT0_STATUS 0x02 -#define SD_CMD_STATUS 0x01 - -/* SD_PAD_CTL */ -#define SD_IO_USING_1V8 0x80 -#define SD_IO_USING_3V3 0x7F -#define TYPE_A_DRIVING 0x00 -#define TYPE_B_DRIVING 0x01 -#define TYPE_C_DRIVING 0x02 -#define TYPE_D_DRIVING 0x03 - -/* SD_SAMPLE_POINT_CTL */ -#define DDR_FIX_RX_DAT 0x00 -#define DDR_VAR_RX_DAT 0x80 -#define DDR_FIX_RX_DAT_EDGE 0x00 -#define DDR_FIX_RX_DAT_14_DELAY 0x40 -#define DDR_FIX_RX_CMD 0x00 -#define DDR_VAR_RX_CMD 0x20 -#define DDR_FIX_RX_CMD_POS_EDGE 0x00 -#define DDR_FIX_RX_CMD_14_DELAY 0x10 -#define SD20_RX_POS_EDGE 0x00 -#define SD20_RX_14_DELAY 0x08 -#define SD20_RX_SEL_MASK 0x08 +#define TRANS_NOT_READY 0 +#define TRANS_RESULT_OK 1 +#define TRANS_RESULT_FAIL 2 +#define TRANS_NO_DEVICE 3 -/* SD_PUSH_POINT_CTL */ -#define DDR_FIX_TX_CMD_DAT 0x00 -#define DDR_VAR_TX_CMD_DAT 0x80 -#define DDR_FIX_TX_DAT_14_TSU 0x00 -#define DDR_FIX_TX_DAT_12_TSU 0x40 -#define DDR_FIX_TX_CMD_NEG_EDGE 0x00 -#define DDR_FIX_TX_CMD_14_AHEAD 0x20 -#define SD20_TX_NEG_EDGE 0x00 -#define SD20_TX_14_AHEAD 0x10 -#define SD20_TX_SEL_MASK 0x10 -#define DDR_VAR_SDCLK_POL_SWAP 0x01 - -/* SD_TRANSFER */ -#define SD_TRANSFER_START 0x80 -#define SD_TRANSFER_END 0x40 -#define SD_STAT_IDLE 0x20 -#define SD_TRANSFER_ERR 0x10 -/* SD Transfer Mode definition */ -#define SD_TM_NORMAL_WRITE 0x00 -#define SD_TM_AUTO_WRITE_3 0x01 -#define SD_TM_AUTO_WRITE_4 0x02 -#define SD_TM_AUTO_READ_3 0x05 -#define SD_TM_AUTO_READ_4 0x06 -#define SD_TM_CMD_RSP 0x08 -#define SD_TM_AUTO_WRITE_1 0x09 -#define SD_TM_AUTO_WRITE_2 0x0A -#define SD_TM_NORMAL_READ 0x0C -#define SD_TM_AUTO_READ_1 0x0D -#define SD_TM_AUTO_READ_2 0x0E -#define SD_TM_AUTO_TUNING 0x0F - -/* SD_VPTX_CTL / SD_VPRX_CTL */ -#define PHASE_CHANGE 0x80 -#define PHASE_NOT_RESET 0x40 - -/* SD_DCMPS_TX_CTL / SD_DCMPS_RX_CTL */ -#define DCMPS_CHANGE 0x80 -#define DCMPS_CHANGE_DONE 0x40 -#define DCMPS_ERROR 0x20 -#define DCMPS_CURRENT_PHASE 0x1F - -/* SD Configure 1 Register */ -#define SD_CLK_DIVIDE_0 0x00 -#define SD_CLK_DIVIDE_256 0xC0 -#define SD_CLK_DIVIDE_128 0x80 -#define SD_BUS_WIDTH_1BIT 0x00 -#define SD_BUS_WIDTH_4BIT 0x01 -#define SD_BUS_WIDTH_8BIT 0x02 -#define SD_ASYNC_FIFO_NOT_RST 0x10 -#define SD_20_MODE 0x00 -#define SD_DDR_MODE 0x04 -#define SD_30_MODE 0x08 - -#define SD_CLK_DIVIDE_MASK 0xC0 - -/* SD_CMD_STATE */ -#define SD_CMD_IDLE 0x80 - -/* SD_DATA_STATE */ -#define SD_DATA_IDLE 0x80 - -/* DCM_DRP_CTL */ -#define DCM_RESET 0x08 -#define DCM_LOCKED 0x04 -#define DCM_208M 0x00 -#define DCM_TX 0x01 -#define DCM_RX 0x02 - -/* DCM_DRP_TRIG */ -#define DRP_START 0x80 -#define DRP_DONE 0x40 - -/* DCM_DRP_CFG */ -#define DRP_WRITE 0x80 -#define DRP_READ 0x00 -#define DCM_WRITE_ADDRESS_50 0x50 -#define DCM_WRITE_ADDRESS_51 0x51 -#define DCM_READ_ADDRESS_00 0x00 -#define DCM_READ_ADDRESS_51 0x51 - -/* IRQSTAT0 */ -#define DMA_DONE_INT 0x80 -#define SUSPEND_INT 0x40 -#define LINK_RDY_INT 0x20 -#define LINK_DOWN_INT 0x10 - -/* DMACTL */ -#define DMA_RST 0x80 -#define DMA_BUSY 0x04 -#define DMA_DIR_TO_CARD 0x00 -#define DMA_DIR_FROM_CARD 0x02 -#define DMA_EN 0x01 -#define DMA_128 (0 << 4) -#define DMA_256 (1 << 4) -#define DMA_512 (2 << 4) -#define DMA_1024 (3 << 4) -#define DMA_PACK_SIZE_MASK 0x30 - -/* SSC_CTL1 */ -#define SSC_RSTB 0x80 -#define SSC_8X_EN 0x40 -#define SSC_FIX_FRAC 0x20 -#define SSC_SEL_1M 0x00 -#define SSC_SEL_2M 0x08 -#define SSC_SEL_4M 0x10 -#define SSC_SEL_8M 0x18 - -/* SSC_CTL2 */ -#define SSC_DEPTH_MASK 0x07 -#define SSC_DEPTH_DISALBE 0x00 -#define SSC_DEPTH_4M 0x01 -#define SSC_DEPTH_2M 0x02 -#define SSC_DEPTH_1M 0x03 -#define SSC_DEPTH_500K 0x04 -#define SSC_DEPTH_250K 0x05 - -/* System Clock Control Register */ -#define CLK_LOW_FREQ 0x01 - -/* System Clock Divider Register */ -#define CLK_DIV_1 0x01 -#define CLK_DIV_2 0x02 -#define CLK_DIV_4 0x03 -#define CLK_DIV_8 0x04 - -/* MS_CFG */ -#define SAMPLE_TIME_RISING 0x00 -#define SAMPLE_TIME_FALLING 0x80 -#define PUSH_TIME_DEFAULT 0x00 -#define PUSH_TIME_ODD 0x40 -#define NO_EXTEND_TOGGLE 0x00 -#define EXTEND_TOGGLE_CHK 0x20 -#define MS_BUS_WIDTH_1 0x00 -#define MS_BUS_WIDTH_4 0x10 -#define MS_BUS_WIDTH_8 0x18 -#define MS_2K_SECTOR_MODE 0x04 -#define MS_512_SECTOR_MODE 0x00 -#define MS_TOGGLE_TIMEOUT_EN 0x00 -#define MS_TOGGLE_TIMEOUT_DISEN 0x01 -#define MS_NO_CHECK_INT 0x02 +#define RTSX_RESV_BUF_LEN 4096 +#define HOST_CMDS_BUF_LEN 1024 +#define HOST_SG_TBL_BUF_LEN (RTSX_RESV_BUF_LEN - HOST_CMDS_BUF_LEN) +#define HOST_SG_TBL_ITEMS (HOST_SG_TBL_BUF_LEN / 8) +#define MAX_SG_ITEM_LEN 0x80000 +#define HOST_TO_DEVICE 0 +#define DEVICE_TO_HOST 1 + +#define OUTPUT_3V3 0 +#define OUTPUT_1V8 1 -/* MS_TRANS_CFG */ -#define WAIT_INT 0x80 -#define NO_WAIT_INT 0x00 -#define NO_AUTO_READ_INT_REG 0x00 -#define AUTO_READ_INT_REG 0x40 -#define MS_CRC16_ERR 0x20 -#define MS_RDY_TIMEOUT 0x10 -#define MS_INT_CMDNK 0x08 -#define MS_INT_BREQ 0x04 -#define MS_INT_ERR 0x02 -#define MS_INT_CED 0x01 - -/* MS_TRANSFER */ -#define MS_TRANSFER_START 0x80 -#define MS_TRANSFER_END 0x40 -#define MS_TRANSFER_ERR 0x20 -#define MS_BS_STATE 0x10 -#define MS_TM_READ_BYTES 0x00 -#define MS_TM_NORMAL_READ 0x01 -#define MS_TM_WRITE_BYTES 0x04 -#define MS_TM_NORMAL_WRITE 0x05 -#define MS_TM_AUTO_READ 0x08 -#define MS_TM_AUTO_WRITE 0x0C - -/* SD Configure 2 Register */ -#define SD_CALCULATE_CRC7 0x00 -#define SD_NO_CALCULATE_CRC7 0x80 -#define SD_CHECK_CRC16 0x00 -#define SD_NO_CHECK_CRC16 0x40 -#define SD_NO_CHECK_WAIT_CRC_TO 0x20 -#define SD_WAIT_BUSY_END 0x08 -#define SD_NO_WAIT_BUSY_END 0x00 -#define SD_CHECK_CRC7 0x00 -#define SD_NO_CHECK_CRC7 0x04 -#define SD_RSP_LEN_0 0x00 -#define SD_RSP_LEN_6 0x01 -#define SD_RSP_LEN_17 0x02 -/* SD/MMC Response Type Definition */ -#define SD_RSP_TYPE_R0 0x04 -#define SD_RSP_TYPE_R1 0x01 -#define SD_RSP_TYPE_R1b 0x09 -#define SD_RSP_TYPE_R2 0x02 -#define SD_RSP_TYPE_R3 0x05 -#define SD_RSP_TYPE_R4 0x05 -#define SD_RSP_TYPE_R5 0x01 -#define SD_RSP_TYPE_R6 0x01 -#define SD_RSP_TYPE_R7 0x01 - -/* SD_CONFIGURE3 */ -#define SD_RSP_80CLK_TIMEOUT_EN 0x01 - -/* Card Transfer Reset Register */ -#define SPI_STOP 0x01 -#define XD_STOP 0x02 -#define SD_STOP 0x04 -#define MS_STOP 0x08 -#define SPI_CLR_ERR 0x10 -#define XD_CLR_ERR 0x20 -#define SD_CLR_ERR 0x40 -#define MS_CLR_ERR 0x80 - -/* Card Data Source Register */ -#define PINGPONG_BUFFER 0x01 -#define RING_BUFFER 0x00 - -/* Card Power Control Register */ -#define PMOS_STRG_MASK 0x10 -#define PMOS_STRG_800mA 0x10 -#define PMOS_STRG_400mA 0x00 -#define SD_POWER_OFF 0x03 -#define SD_PARTIAL_POWER_ON 0x01 -#define SD_POWER_ON 0x00 -#define SD_POWER_MASK 0x03 -#define MS_POWER_OFF 0x0C -#define MS_PARTIAL_POWER_ON 0x04 -#define MS_POWER_ON 0x00 -#define MS_POWER_MASK 0x0C -#define BPP_POWER_OFF 0x0F -#define BPP_POWER_5_PERCENT_ON 0x0E -#define BPP_POWER_10_PERCENT_ON 0x0C -#define BPP_POWER_15_PERCENT_ON 0x08 -#define BPP_POWER_ON 0x00 -#define BPP_POWER_MASK 0x0F -#define SD_VCC_PARTIAL_POWER_ON 0x02 -#define SD_VCC_POWER_ON 0x00 - -/* PWR_GATE_CTRL */ -#define PWR_GATE_EN 0x01 -#define LDO3318_PWR_MASK 0x06 -#define LDO_ON 0x00 -#define LDO_SUSPEND 0x04 -#define LDO_OFF 0x06 - -/* CARD_CLK_SOURCE */ -#define CRC_FIX_CLK (0x00 << 0) -#define CRC_VAR_CLK0 (0x01 << 0) -#define CRC_VAR_CLK1 (0x02 << 0) -#define SD30_FIX_CLK (0x00 << 2) -#define SD30_VAR_CLK0 (0x01 << 2) -#define SD30_VAR_CLK1 (0x02 << 2) -#define SAMPLE_FIX_CLK (0x00 << 4) -#define SAMPLE_VAR_CLK0 (0x01 << 4) -#define SAMPLE_VAR_CLK1 (0x02 << 4) - -/* HOST_SLEEP_STATE */ -#define HOST_ENTER_S1 1 -#define HOST_ENTER_S3 2 +#define RTSX_PHASE_MAX 32 +#define RX_TUNING_CNT 3#define MS_CFG 0xFD40 +#define SAMPLE_TIME_RISING 0x00 +#define SAMPLE_TIME_FALLING 0x80 +#define PUSH_TIME_DEFAULT 0x00 +#define PUSH_TIME_ODD 0x40 +#define NO_EXTEND_TOGGLE 0x00 +#define EXTEND_TOGGLE_CHK 0x20 +#define MS_BUS_WIDTH_1 0x00 +#define MS_BUS_WIDTH_4 0x10 +#define MS_BUS_WIDTH_8 0x18 +#define MS_2K_SECTOR_MODE 0x04 +#define MS_512_SECTOR_MODE 0x00 +#define MS_TOGGLE_TIMEOUT_EN 0x00 +#define MS_TOGGLE_TIMEOUT_DISEN 0x01 +#define MS_NO_CHECK_INT 0x02#define MS_TPC 0xFD41#define MS_TRANS_CFG 0xFD42 +#define WAIT_INT 0x80 +#define NO_WAIT_INT 0x00 +#define NO_AUTO_READ_INT_REG 0x00 +#define AUTO_READ_INT_REG 0x40 +#define MS_CRC16_ERR 0x20 +#define MS_RDY_TIMEOUT 0x10 +#define MS_INT_CMDNK 0x08 +#define MS_INT_BREQ 0x04 +#define MS_INT_ERR 0x02 +#define MS_INT_CED 0x01#define MS_TRANSFER 0xFD43 +#define MS_TRANSFER_START 0x80 +#define MS_TRANSFER_END 0x40 +#define MS_TRANSFER_ERR 0x20 +#define MS_BS_STATE 0x10 +#define MS_TM_READ_BYTES 0x00 +#define MS_TM_NORMAL_READ 0x01 +#define MS_TM_WRITE_BYTES 0x04 +#define MS_TM_NORMAL_WRITE 0x05 +#define MS_TM_AUTO_READ 0x08 +#define MS_TM_AUTO_WRITE 0x0C#define MS_INT_REG 0xFD44#define MS_BYTE_CNT 0xFD45#define MS_SECTOR_CNT_L 0xFD46
@@ -549,14 +192,90 @@#define MS_DBUS_H 0xFD48#define SD_CFG1 0xFDA0 +#define SD_CLK_DIVIDE_0 0x00 +#define SD_CLK_DIVIDE_256 0xC0 +#define SD_CLK_DIVIDE_128 0x80 +#define SD_BUS_WIDTH_1BIT 0x00 +#define SD_BUS_WIDTH_4BIT 0x01 +#define SD_BUS_WIDTH_8BIT 0x02 +#define SD_ASYNC_FIFO_NOT_RST 0x10 +#define SD_20_MODE 0x00 +#define SD_DDR_MODE 0x04 +#define SD_30_MODE 0x08 +#define SD_CLK_DIVIDE_MASK 0xC0#define SD_CFG2 0xFDA1 +#define SD_CALCULATE_CRC7 0x00 +#define SD_NO_CALCULATE_CRC7 0x80 +#define SD_CHECK_CRC16 0x00 +#define SD_NO_CHECK_CRC16 0x40 +#define SD_NO_CHECK_WAIT_CRC_TO 0x20 +#define SD_WAIT_BUSY_END 0x08 +#define SD_NO_WAIT_BUSY_END 0x00 +#define SD_CHECK_CRC7 0x00 +#define SD_NO_CHECK_CRC7 0x04 +#define SD_RSP_LEN_0 0x00 +#define SD_RSP_LEN_6 0x01 +#define SD_RSP_LEN_17 0x02 +#define SD_RSP_TYPE_R0 0x04 +#define SD_RSP_TYPE_R1 0x01 +#define SD_RSP_TYPE_R1b 0x09 +#define SD_RSP_TYPE_R2 0x02 +#define SD_RSP_TYPE_R3 0x05 +#define SD_RSP_TYPE_R4 0x05 +#define SD_RSP_TYPE_R5 0x01 +#define SD_RSP_TYPE_R6 0x01 +#define SD_RSP_TYPE_R7 0x01#define SD_CFG3 0xFDA2 +#define SD_RSP_80CLK_TIMEOUT_EN 0x01 +#define SD_STAT1 0xFDA3 +#define SD_CRC7_ERR 0x80 +#define SD_CRC16_ERR 0x40 +#define SD_CRC_WRITE_ERR 0x20 +#define SD_CRC_WRITE_ERR_MASK 0x1C +#define GET_CRC_TIME_OUT 0x02 +#define SD_TUNING_COMPARE_ERR 0x01#define SD_STAT2 0xFDA4 +#define SD_RSP_80CLK_TIMEOUT 0x01 +#define SD_BUS_STAT 0xFDA5 +#define SD_CLK_TOGGLE_EN 0x80 +#define SD_CLK_FORCE_STOP 0x40 +#define SD_DAT3_STATUS 0x10 +#define SD_DAT2_STATUS 0x08 +#define SD_DAT1_STATUS 0x04 +#define SD_DAT0_STATUS 0x02 +#define SD_CMD_STATUS 0x01#define SD_PAD_CTL 0xFDA6 +#define SD_IO_USING_1V8 0x80 +#define SD_IO_USING_3V3 0x7F +#define TYPE_A_DRIVING 0x00 +#define TYPE_B_DRIVING 0x01 +#define TYPE_C_DRIVING 0x02 +#define TYPE_D_DRIVING 0x03#define SD_SAMPLE_POINT_CTL 0xFDA7 +#define DDR_FIX_RX_DAT 0x00 +#define DDR_VAR_RX_DAT 0x80 +#define DDR_FIX_RX_DAT_EDGE 0x00 +#define DDR_FIX_RX_DAT_14_DELAY 0x40 +#define DDR_FIX_RX_CMD 0x00 +#define DDR_VAR_RX_CMD 0x20 +#define DDR_FIX_RX_CMD_POS_EDGE 0x00 +#define DDR_FIX_RX_CMD_14_DELAY 0x10 +#define SD20_RX_POS_EDGE 0x00 +#define SD20_RX_14_DELAY 0x08 +#define SD20_RX_SEL_MASK 0x08#define SD_PUSH_POINT_CTL 0xFDA8 +#define DDR_FIX_TX_CMD_DAT 0x00 +#define DDR_VAR_TX_CMD_DAT 0x80 +#define DDR_FIX_TX_DAT_14_TSU 0x00 +#define DDR_FIX_TX_DAT_12_TSU 0x40 +#define DDR_FIX_TX_CMD_NEG_EDGE 0x00 +#define DDR_FIX_TX_CMD_14_AHEAD 0x20 +#define SD20_TX_NEG_EDGE 0x00 +#define SD20_TX_14_AHEAD 0x10 +#define SD20_TX_SEL_MASK 0x10 +#define DDR_VAR_SDCLK_POL_SWAP 0x01#define SD_CMD0 0xFDA9#define SD_CMD_START 0x40#define SD_CMD1 0xFDAA
@@ -569,14 +288,46 @@#define SD_BLOCK_CNT_L 0xFDB1#define SD_BLOCK_CNT_H 0xFDB2#define SD_TRANSFER 0xFDB3 +#define SD_TRANSFER_START 0x80 +#define SD_TRANSFER_END 0x40 +#define SD_STAT_IDLE 0x20 +#define SD_TRANSFER_ERR 0x10 +#define SD_TM_NORMAL_WRITE 0x00 +#define SD_TM_AUTO_WRITE_3 0x01 +#define SD_TM_AUTO_WRITE_4 0x02 +#define SD_TM_AUTO_READ_3 0x05 +#define SD_TM_AUTO_READ_4 0x06 +#define SD_TM_CMD_RSP 0x08 +#define SD_TM_AUTO_WRITE_1 0x09 +#define SD_TM_AUTO_WRITE_2 0x0A +#define SD_TM_NORMAL_READ 0x0C +#define SD_TM_AUTO_READ_1 0x0D +#define SD_TM_AUTO_READ_2 0x0E +#define SD_TM_AUTO_TUNING 0x0F#define SD_CMD_STATE 0xFDB5 +#define SD_CMD_IDLE 0x80 +#define SD_DATA_STATE 0xFDB6 +#define SD_DATA_IDLE 0x80#define SRCTL 0xFC13#define DCM_DRP_CTL 0xFC23 +#define DCM_RESET 0x08 +#define DCM_LOCKED 0x04 +#define DCM_208M 0x00 +#define DCM_TX 0x01 +#define DCM_RX 0x02#define DCM_DRP_TRIG 0xFC24 +#define DRP_START 0x80 +#define DRP_DONE 0x40#define DCM_DRP_CFG 0xFC25 +#define DRP_WRITE 0x80 +#define DRP_READ 0x00 +#define DCM_WRITE_ADDRESS_50 0x50 +#define DCM_WRITE_ADDRESS_51 0x51 +#define DCM_READ_ADDRESS_00 0x00 +#define DCM_READ_ADDRESS_51 0x51#define DCM_DRP_WR_DATA_L 0xFC26#define DCM_DRP_WR_DATA_H 0xFC27#define DCM_DRP_RD_DATA_L 0xFC28
@@ -587,42 +338,153 @@#define SD_DCMPS1_CTL 0xFC2D#define SD_VPTX_CTL SD_VPCLK0_CTL#define SD_VPRX_CTL SD_VPCLK1_CTL +#define PHASE_CHANGE 0x80 +#define PHASE_NOT_RESET 0x40#define SD_DCMPS_TX_CTL SD_DCMPS0_CTL#define SD_DCMPS_RX_CTL SD_DCMPS1_CTL +#define DCMPS_CHANGE 0x80 +#define DCMPS_CHANGE_DONE 0x40 +#define DCMPS_ERROR 0x20 +#define DCMPS_CURRENT_PHASE 0x1F#define CARD_CLK_SOURCE 0xFC2E - +#define CRC_FIX_CLK (0x00 << 0) +#define CRC_VAR_CLK0 (0x01 << 0) +#define CRC_VAR_CLK1 (0x02 << 0) +#define SD30_FIX_CLK (0x00 << 2) +#define SD30_VAR_CLK0 (0x01 << 2) +#define SD30_VAR_CLK1 (0x02 << 2) +#define SAMPLE_FIX_CLK (0x00 << 4) +#define SAMPLE_VAR_CLK0 (0x01 << 4) +#define SAMPLE_VAR_CLK1 (0x02 << 4)#define CARD_PWR_CTL 0xFD50 +#define PMOS_STRG_MASK 0x10 +#define PMOS_STRG_800mA 0x10 +#define PMOS_STRG_400mA 0x00 +#define SD_POWER_OFF 0x03 +#define SD_PARTIAL_POWER_ON 0x01 +#define SD_POWER_ON 0x00 +#define SD_POWER_MASK 0x03 +#define MS_POWER_OFF 0x0C +#define MS_PARTIAL_POWER_ON 0x04 +#define MS_POWER_ON 0x00 +#define MS_POWER_MASK 0x0C +#define BPP_POWER_OFF 0x0F +#define BPP_POWER_5_PERCENT_ON 0x0E +#define BPP_POWER_10_PERCENT_ON 0x0C +#define BPP_POWER_15_PERCENT_ON 0x08 +#define BPP_POWER_ON 0x00 +#define BPP_POWER_MASK 0x0F +#define SD_VCC_PARTIAL_POWER_ON 0x02 +#define SD_VCC_POWER_ON 0x00#define CARD_CLK_SWITCH 0xFD51#define RTL8411B_PACKAGE_MODE 0xFD51#define CARD_SHARE_MODE 0xFD52 +#define CARD_SHARE_MASK 0x0F +#define CARD_SHARE_MULTI_LUN 0x00 +#define CARD_SHARE_NORMAL 0x00 +#define CARD_SHARE_48_SD 0x04 +#define CARD_SHARE_48_MS 0x08 +#define CARD_SHARE_BAROSSA_SD 0x01 +#define CARD_SHARE_BAROSSA_MS 0x02#define CARD_DRIVE_SEL 0xFD53 +#define MS_DRIVE_8mA (0x01 << 6) +#define MMC_DRIVE_8mA (0x01 << 4) +#define XD_DRIVE_8mA (0x01 << 2) +#define GPIO_DRIVE_8mA 0x01 +#define RTS5209_CARD_DRIVE_DEFAULT (MS_DRIVE_8mA | MMC_DRIVE_8mA |\ + XD_DRIVE_8mA | GPIO_DRIVE_8mA) +#define RTL8411_CARD_DRIVE_DEFAULT (MS_DRIVE_8mA | MMC_DRIVE_8mA |\ + XD_DRIVE_8mA) +#define RTSX_CARD_DRIVE_DEFAULT (MS_DRIVE_8mA | GPIO_DRIVE_8mA) +#define CARD_STOP 0xFD54 +#define SPI_STOP 0x01 +#define XD_STOP 0x02 +#define SD_STOP 0x04 +#define MS_STOP 0x08 +#define SPI_CLR_ERR 0x10 +#define XD_CLR_ERR 0x20 +#define SD_CLR_ERR 0x40 +#define MS_CLR_ERR 0x80#define CARD_OE 0xFD55 +#define SD_OUTPUT_EN 0x04 +#define MS_OUTPUT_EN 0x08#define CARD_AUTO_BLINK 0xFD56#define CARD_GPIO_DIR 0xFD57#define CARD_GPIO 0xFD58#define CARD_DATA_SOURCE 0xFD5B +#define PINGPONG_BUFFER 0x01 +#define RING_BUFFER 0x00#define SD30_CLK_DRIVE_SEL 0xFD5A +#define DRIVER_TYPE_A 0x05 +#define DRIVER_TYPE_B 0x03 +#define DRIVER_TYPE_C 0x02 +#define DRIVER_TYPE_D 0x01#define CARD_SELECT 0xFD5C +#define SD_MOD_SEL 2 +#define MS_MOD_SEL 3#define SD30_DRIVE_SEL 0xFD5E +#define CFG_DRIVER_TYPE_A 0x02 +#define CFG_DRIVER_TYPE_B 0x03 +#define CFG_DRIVER_TYPE_C 0x01 +#define CFG_DRIVER_TYPE_D 0x00#define SD30_CMD_DRIVE_SEL 0xFD5E#define SD30_DAT_DRIVE_SEL 0xFD5F#define CARD_CLK_EN 0xFD69 +#define SD_CLK_EN 0x04 +#define MS_CLK_EN 0x08#define SDIO_CTRL 0xFD6B#define CD_PAD_CTL 0xFD73 - +#define CD_DISABLE_MASK 0x07 +#define MS_CD_DISABLE 0x04 +#define SD_CD_DISABLE 0x02 +#define XD_CD_DISABLE 0x01 +#define CD_DISABLE 0x07 +#define CD_ENABLE 0x00 +#define MS_CD_EN_ONLY 0x03 +#define SD_CD_EN_ONLY 0x05 +#define XD_CD_EN_ONLY 0x06 +#define FORCE_CD_LOW_MASK 0x38 +#define FORCE_CD_XD_LOW 0x08 +#define FORCE_CD_SD_LOW 0x10 +#define FORCE_CD_MS_LOW 0x20 +#define CD_AUTO_DISABLE 0x40#define FPDCTL 0xFC00 +#define SSC_POWER_DOWN 0x01 +#define SD_OC_POWER_DOWN 0x02 +#define ALL_POWER_DOWN 0x07 +#define OC_POWER_DOWN 0x06#define PDINFO 0xFC01#define CLK_CTL 0xFC02 +#define CHANGE_CLK 0x01 +#define CLK_LOW_FREQ 0x01 +#define CLK_DIV 0xFC03 +#define CLK_DIV_1 0x01 +#define CLK_DIV_2 0x02 +#define CLK_DIV_4 0x03 +#define CLK_DIV_8 0x04#define CLK_SEL 0xFC04#define SSC_DIV_N_0 0xFC0F#define SSC_DIV_N_1 0xFC10#define SSC_CTL1 0xFC11 +#define SSC_RSTB 0x80 +#define SSC_8X_EN 0x40 +#define SSC_FIX_FRAC 0x20 +#define SSC_SEL_1M 0x00 +#define SSC_SEL_2M 0x08 +#define SSC_SEL_4M 0x10 +#define SSC_SEL_8M 0x18#define SSC_CTL2 0xFC12 - +#define SSC_DEPTH_MASK 0x07 +#define SSC_DEPTH_DISALBE 0x00 +#define SSC_DEPTH_4M 0x01 +#define SSC_DEPTH_2M 0x02 +#define SSC_DEPTH_1M 0x03 +#define SSC_DEPTH_500K 0x04 +#define SSC_DEPTH_250K 0x05#define RCCTL 0xFC14#define FPGA_PULL_CTL 0xFC1D
@@ -630,6 +492,24 @@#define GPIO_CTL 0xFC1F#define LDO_CTL 0xFC1E +#define BPP_ASIC_1V7 0x00 +#define BPP_ASIC_1V8 0x01 +#define BPP_ASIC_1V9 0x02 +#define BPP_ASIC_2V0 0x03 +#define BPP_ASIC_2V7 0x04 +#define BPP_ASIC_2V8 0x05 +#define BPP_ASIC_3V2 0x06 +#define BPP_ASIC_3V3 0x07 +#define BPP_REG_TUNED18 0x07 +#define BPP_TUNED18_SHIFT_8402 5 +#define BPP_TUNED18_SHIFT_8411 4 +#define BPP_PAD_MASK 0x04 +#define BPP_PAD_3V3 0x04 +#define BPP_PAD_1V8 0x00 +#define BPP_LDO_POWB 0x03 +#define BPP_LDO_ON 0x00 +#define BPP_LDO_SUSPEND 0x02 +#define BPP_LDO_OFF 0x03#define SYS_VER 0xFC32#define CARD_PULL_CTL1 0xFD60
@@ -642,6 +522,10 @@/* PCI Express Related Registers */ #define IRQEN0 0xFE20#define IRQSTAT0 0xFE21 +#define DMA_DONE_INT 0x80 +#define SUSPEND_INT 0x40 +#define LINK_RDY_INT 0x20 +#define LINK_DOWN_INT 0x10#define IRQEN1 0xFE22#define IRQSTAT1 0xFE23#define TLPRIEN 0xFE24
@@ -653,6 +537,16 @@#define DMATC2 0xFE2A#define DMATC3 0xFE2B#define DMACTL 0xFE2C +#define DMA_RST 0x80 +#define DMA_BUSY 0x04 +#define DMA_DIR_TO_CARD 0x00 +#define DMA_DIR_FROM_CARD 0x02 +#define DMA_EN 0x01 +#define DMA_128 (0 << 4) +#define DMA_256 (1 << 4) +#define DMA_512 (2 << 4) +#define DMA_1024 (3 << 4) +#define DMA_PACK_SIZE_MASK 0x30#define BCTL 0xFE2D#define RBBC0 0xFE2E#define RBBC1 0xFE2F
@@ -693,11 +587,19 @@#define RESET_LOAD_REG 0xFE5E#define EFUSE_CONTENT 0xFE5F#define HOST_SLEEP_STATE 0xFE60 +#define HOST_ENTER_S1 1 +#define HOST_ENTER_S3 2 +#define SDIO_CFG 0xFE70#define NFTS_TX_CTRL 0xFE72#define PWR_GATE_CTRL 0xFE75 +#define PWR_GATE_EN 0x01 +#define LDO3318_PWR_MASK 0x06 +#define LDO_ON 0x00 +#define LDO_SUSPEND 0x04 +#define LDO_OFF 0x06#define PWD_SUSPEND_EN 0xFE76#define LDO_PWR_SEL 0xFE78
Signature · 1 line
1.9.1
PATCH v2 9/9 mfd: rtsx: using pcr_dbg replace dev_dbg
In reply to [email protected]From: Micky Ching <[email protected]>
pcr_dbg is a wrapper of dev_dbg, which can save some code, and help to enable/disable debug message static.
--- drivers/mfd/rtl8411.c | 11 +++++------ drivers/mfd/rts5209.c | 4 ++-- drivers/mfd/rts5227.c | 4 ++-- drivers/mfd/rts5229.c | 4 ++-- drivers/mfd/rts5249.c | 4 ++-- drivers/mfd/rtsx_pcr.c | 49 ++++++++++++++++++++++--------------------------- 6 files changed, 35 insertions(+), 41 deletions(-)
drivers/mfd/rtl8411.c +5 -6
@@ -53,7 +53,7 @@ static void rtl8411_fetch_vendor_settings(struct rtsx_pcr *pcr)u8 reg3 =0 ;rtsx_pci_read_config_dword (pcr,PCR_SETTING_REG1 , ®1); -dev_dbg (&(pcr->pci->dev),"Cfg 0x%x: 0x%x\n" ,PCR_SETTING_REG1 , reg1); +pcr_dbg (pcr,"Cfg 0x%x: 0x%x\n" ,PCR_SETTING_REG1 , reg1);if (!rtsx_vendor_setting_valid (reg1))return ;
@@ -65,7 +65,7 @@ static void rtl8411_fetch_vendor_settings(struct rtsx_pcr *pcr) pcr->card_drive_sel |=rtsx_reg_to_card_drive_sel (reg1);rtsx_pci_read_config_byte (pcr,PCR_SETTING_REG3 , ®3); -dev_dbg (&(pcr->pci->dev),"Cfg 0x%x: 0x%x\n" ,PCR_SETTING_REG3 , reg3); +pcr_dbg (pcr,"Cfg 0x%x: 0x%x\n" ,PCR_SETTING_REG3 , reg3); pcr->sd30_drive_sel_3v3 =rtl8411_reg_to_sd30_drive_sel_3v3 (reg3); }
@@ -74,7 +74,7 @@ static void rtl8411b_fetch_vendor_settings(struct rtsx_pcr *pcr)u32 reg =0 ;rtsx_pci_read_config_dword (pcr,PCR_SETTING_REG1 , ®); -dev_dbg (&(pcr->pci->dev),"Cfg 0x%x: 0x%x\n" ,PCR_SETTING_REG1 , reg); +pcr_dbg (pcr,"Cfg 0x%x: 0x%x\n" ,PCR_SETTING_REG1 , reg);if (!rtsx_vendor_setting_valid (reg))return ;
@@ -260,9 +260,8 @@ static unsigned int rtl8411_cd_deglitch(struct rtsx_pcr *pcr)rtsx_pci_write_register (pcr,CARD_PWR_CTL ,BPP_POWER_MASK ,BPP_POWER_OFF ); -dev_dbg (&(pcr->pci->dev), -"After CD deglitch, card_exist = 0x%x\n" , - card_exist); +pcr_dbg (pcr,"After CD deglitch, card_exist = 0x%x\n" , + card_exist); }if (card_exist &MS_EXIST ) {
drivers/mfd/rts5209.c +2 -2
@@ -38,7 +38,7 @@ static void rts5209_fetch_vendor_settings(struct rtsx_pcr *pcr)u32 reg;rtsx_pci_read_config_dword (pcr,PCR_SETTING_REG1 , ®); -dev_dbg (&(pcr->pci->dev),"Cfg 0x%x: 0x%x\n" ,PCR_SETTING_REG1 , reg); +pcr_dbg (pcr,"Cfg 0x%x: 0x%x\n" ,PCR_SETTING_REG1 , reg);if (rts5209_vendor_setting1_valid (reg)) {if (rts5209_reg_check_ms_pmos (reg))
@@ -47,7 +47,7 @@ static void rts5209_fetch_vendor_settings(struct rtsx_pcr *pcr) }rtsx_pci_read_config_dword (pcr,PCR_SETTING_REG2 , ®); -dev_dbg (&(pcr->pci->dev),"Cfg 0x%x: 0x%x\n" ,PCR_SETTING_REG2 , reg); +pcr_dbg (pcr,"Cfg 0x%x: 0x%x\n" ,PCR_SETTING_REG2 , reg);if (rts5209_vendor_setting2_valid (reg)) { pcr->sd30_drive_sel_1v8 =
drivers/mfd/rts5227.c +2 -2
@@ -63,7 +63,7 @@ static void rts5227_fetch_vendor_settings(struct rtsx_pcr *pcr)u32 reg;rtsx_pci_read_config_dword (pcr,PCR_SETTING_REG1 , ®); -dev_dbg (&(pcr->pci->dev),"Cfg 0x%x: 0x%x\n" ,PCR_SETTING_REG1 , reg); +pcr_dbg (pcr,"Cfg 0x%x: 0x%x\n" ,PCR_SETTING_REG1 , reg);if (!rtsx_vendor_setting_valid (reg))return ;
@@ -74,7 +74,7 @@ static void rts5227_fetch_vendor_settings(struct rtsx_pcr *pcr) pcr->card_drive_sel |=rtsx_reg_to_card_drive_sel (reg);rtsx_pci_read_config_dword (pcr,PCR_SETTING_REG2 , ®); -dev_dbg (&(pcr->pci->dev),"Cfg 0x%x: 0x%x\n" ,PCR_SETTING_REG2 , reg); +pcr_dbg (pcr,"Cfg 0x%x: 0x%x\n" ,PCR_SETTING_REG2 , reg); pcr->sd30_drive_sel_3v3 =rtsx_reg_to_sd30_drive_sel_3v3 (reg);if (rtsx_reg_check_reverse_socket (reg)) pcr->flags |=PCR_REVERSE_SOCKET ;
drivers/mfd/rts5229.c +2 -2
@@ -38,7 +38,7 @@ static void rts5229_fetch_vendor_settings(struct rtsx_pcr *pcr)u32 reg;rtsx_pci_read_config_dword (pcr,PCR_SETTING_REG1 , ®); -dev_dbg (&(pcr->pci->dev),"Cfg 0x%x: 0x%x\n" ,PCR_SETTING_REG1 , reg); +pcr_dbg (pcr,"Cfg 0x%x: 0x%x\n" ,PCR_SETTING_REG1 , reg);if (!rtsx_vendor_setting_valid (reg))return ;
@@ -50,7 +50,7 @@ static void rts5229_fetch_vendor_settings(struct rtsx_pcr *pcr) pcr->card_drive_sel |=rtsx_reg_to_card_drive_sel (reg);rtsx_pci_read_config_dword (pcr,PCR_SETTING_REG2 , ®); -dev_dbg (&(pcr->pci->dev),"Cfg 0x%x: 0x%x\n" ,PCR_SETTING_REG2 , reg); +pcr_dbg (pcr,"Cfg 0x%x: 0x%x\n" ,PCR_SETTING_REG2 , reg); pcr->sd30_drive_sel_3v3 =map_sd_drive (rtsx_reg_to_sd30_drive_sel_3v3 (reg)); }
drivers/mfd/rts5249.c +2 -2
@@ -70,7 +70,7 @@ static void rtsx_base_fetch_vendor_settings(struct rtsx_pcr *pcr)u32 reg;rtsx_pci_read_config_dword (pcr,PCR_SETTING_REG1 , ®); -dev_dbg (&(pcr->pci->dev),"Cfg 0x%x: 0x%x\n" ,PCR_SETTING_REG1 , reg); +pcr_dbg (pcr,"Cfg 0x%x: 0x%x\n" ,PCR_SETTING_REG1 , reg);if (!rtsx_vendor_setting_valid (reg)) {pcr_dbg (pcr,"skip fetch vendor setting\n" );
@@ -83,7 +83,7 @@ static void rtsx_base_fetch_vendor_settings(struct rtsx_pcr *pcr) pcr->card_drive_sel |=rtsx_reg_to_card_drive_sel (reg);rtsx_pci_read_config_dword (pcr,PCR_SETTING_REG2 , ®); -dev_dbg (&(pcr->pci->dev),"Cfg 0x%x: 0x%x\n" ,PCR_SETTING_REG2 , reg); +pcr_dbg (pcr,"Cfg 0x%x: 0x%x\n" ,PCR_SETTING_REG2 , reg); pcr->sd30_drive_sel_3v3 =rtsx_reg_to_sd30_drive_sel_3v3 (reg);if (rtsx_reg_check_reverse_socket (reg)) pcr->flags |=PCR_REVERSE_SOCKET ;
drivers/mfd/rtsx_pcr.c +22 -27
142 lines not on this page · raw message
Signature · 1 line
1.9.1
PATCH v2 5/9 mfd: rtsx: update phy register
In reply to [email protected]From: Micky Ching <[email protected]>
update phy register value and using direct value instead of macros. It is much easier to debug using constant value than a lot of macros. We usually need compare the value directly to check the configure.
--- drivers/mfd/rts5249.c | 55 ++++++++++++---------- include/linux/mfd/rtsx_pci.h | 109 ++++++++++++++++++++++--------------------- 2 files changed, 85 insertions(+), 79 deletions(-)
drivers/mfd/rts5249.c +30 -25
@@ -132,57 +132,62 @@ static int rts5249_optimize_phy(struct rtsx_pcr *pcr)if (err <0 )return err; - err =rtsx_pci_write_phy_register (pcr,PHY_REG_REV , -PHY_REG_REV_RESV |PHY_REG_REV_RXIDLE_LATCHED | -PHY_REG_REV_P1_EN |PHY_REG_REV_RXIDLE_EN | -PHY_REG_REV_RX_PWST |PHY_REG_REV_CLKREQ_DLY_TIMER_1_0 | -PHY_REG_REV_STOP_CLKRD |PHY_REG_REV_STOP_CLKWR ); + err =rtsx_pci_write_phy_register (pcr,PHY_REV , +PHY_REV_RESV |PHY_REV_RXIDLE_LATCHED | +PHY_REV_P1_EN |PHY_REV_RXIDLE_EN | +PHY_REV_CLKREQ_TX_EN |PHY_REV_RX_PWST | +PHY_REV_CLKREQ_DT_1_0 |PHY_REV_STOP_CLKRD | +PHY_REV_STOP_CLKWR );if (err <0 )return err;msleep (1 ); err =rtsx_pci_write_phy_register (pcr,PHY_BPCR , -PHY_BPCR_IBRXSEL |PHY_BPCR_IBTXSEL | -PHY_BPCR_IB_FILTER |PHY_BPCR_CMIRROR_EN ); +PHY_BPCR_IBRXSEL |PHY_BPCR_IBTXSEL | +PHY_BPCR_IB_FILTER |PHY_BPCR_CMIRROR_EN );if (err <0 )return err; + 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 ); +PHY_PCR_FORCE_CODE |PHY_PCR_OOBS_CALI_50 | +PHY_PCR_OOBS_VCM_08 |PHY_PCR_OOBS_SEN_90 | +PHY_PCR_RSSI_EN |PHY_PCR_RX10K );if (err <0 )return err; + err =rtsx_pci_write_phy_register (pcr,PHY_RCR2 , -PHY_RCR2_EMPHASE_EN |PHY_RCR2_NADJR | -PHY_RCR2_CDR_CP_10 |PHY_RCR2_CDR_SR_2 | -PHY_RCR2_FREQSEL_12 |PHY_RCR2_CPADJEN | -PHY_RCR2_CDR_SC_8 |PHY_RCR2_CALIB_LATE ); +PHY_RCR2_EMPHASE_EN |PHY_RCR2_NADJR | +PHY_RCR2_CDR_SR_2 |PHY_RCR2_FREQSEL_12 | +PHY_RCR2_CDR_SC_12P |PHY_RCR2_CALIB_LATE );if (err <0 )return err; + err =rtsx_pci_write_phy_register (pcr,PHY_FLD4 , -PHY_FLD4_FLDEN_SEL |PHY_FLD4_REQ_REF | -PHY_FLD4_RXAMP_OFF |PHY_FLD4_REQ_ADDA | -PHY_FLD4_BER_COUNT |PHY_FLD4_BER_TIMER | -PHY_FLD4_BER_CHK_EN ); +PHY_FLD4_FLDEN_SEL |PHY_FLD4_REQ_REF | +PHY_FLD4_RXAMP_OFF |PHY_FLD4_REQ_ADDA | +PHY_FLD4_BER_COUNT |PHY_FLD4_BER_TIMER | +PHY_FLD4_BER_CHK_EN );if (err <0 )return err; - err =rtsx_pci_write_phy_register (pcr,PHY_RDR ,PHY_RDR_RXDSEL_1_9 ); + err =rtsx_pci_write_phy_register (pcr,PHY_RDR , +PHY_RDR_RXDSEL_1_9 |PHY_SSC_AUTO_PWD );if (err <0 )return err; err =rtsx_pci_write_phy_register (pcr,PHY_RCR1 , -PHY_RCR1_ADP_TIME |PHY_RCR1_VCO_COARSE ); +PHY_RCR1_ADP_TIME_4 |PHY_RCR1_VCO_COARSE );if (err <0 )return err; err =rtsx_pci_write_phy_register (pcr,PHY_FLD3 , -PHY_FLD3_TIMER_4 |PHY_FLD3_TIMER_6 | -PHY_FLD3_RXDELINK ); +PHY_FLD3_TIMER_4 |PHY_FLD3_TIMER_6 | +PHY_FLD3_RXDELINK );if (err <0 )return err; +return rtsx_pci_write_phy_register (pcr,PHY_TUNE , -PHY_TUNE_TUNEREF_1_0 |PHY_TUNE_VBGSEL_1252 | -PHY_TUNE_SDBUS_33 |PHY_TUNE_TUNED18 | -PHY_TUNE_TUNED12 ); +PHY_TUNE_TUNEREF_1_0 |PHY_TUNE_VBGSEL_1252 | +PHY_TUNE_SDBUS_33 |PHY_TUNE_TUNED18 | +PHY_TUNE_TUNED12 |PHY_TUNE_TUNEA12 ); }static int rts5249_turn_on_led (struct rtsx_pcr *pcr)
include/linux/mfd/rtsx_pci.h +55 -54
142 lines not on this page · raw message
Signature · 1 line
1.9.1
PATCH v2 6/9 mfd: rtsx: remove LCTLR defination
In reply to [email protected]From: Micky Ching <[email protected]>
To enable/disable ASPM we should find LINK CONTROL register in PCI config space. All old chip use 0x80 address, but new chip may use another address, so we using pci_find_capability() to get LINK CONTROL address.
rtsx_gops.c was removed, we consider to put some common operations to this file, but the actual thing is, only a group of chips are in common ops1, and another group of chips in common ops2, it is hard to decide put which ops into generic ops file.
--- drivers/mfd/Makefile | 2 +- drivers/mfd/rts5227.c | 2 +- drivers/mfd/rts5249.c | 3 +-- drivers/mfd/rtsx_gops.c | 37 ------------------------------------- drivers/mfd/rtsx_pcr.c | 23 ++++++++++++++++++----- include/linux/mfd/rtsx_pci.h | 10 +--------- 6 files changed, 22 insertions(+), 55 deletions(-) delete mode 100644 drivers/mfd/rtsx_gops.c
drivers/mfd/Makefile +1 -1
@@ -13,7 +13,7 @@ obj-$(CONFIG_MFD_CROS_EC) += cros_ec.o obj-$(CONFIG_MFD_CROS_EC_I2C) += cros_ec_i2c.o obj-$(CONFIG_MFD_CROS_EC_SPI) += cros_ec_spi.o -rtsx_pci-objs := rtsx_pcr.o rtsx_gops.o rts5209.o rts5229.o rtl8411.o rts5227.o rts5249.o +rtsx_pci-objs := rtsx_pcr.o rts5209.o rts5229.o rtl8411.o rts5227.o rts5249.o obj-$(CONFIG_MFD_RTSX_PCI) += rtsx_pci.o obj-$(CONFIG_MFD_RTSX_USB) += rtsx_usb.o
drivers/mfd/rts5227.c +1 -1
@@ -130,7 +130,7 @@ static int rts5227_optimize_phy(struct rtsx_pcr *pcr) {int err; - err =rtsx_gops_pm_reset (pcr); + err =rtsx_pci_write_register (pcr,PM_CTRL3 ,D3_DELINK_MODE_EN ,0x00 );if (err <0 )return err;
drivers/mfd/rts5249.c +1 -2
@@ -119,7 +119,6 @@ static int rts5249_extra_init_hw(struct rtsx_pcr *pcr)rtsx_pci_add_cmd (pcr,WRITE_REG_CMD ,PETXCFG ,0xB0 ,0xB0 ); else rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, PETXCFG, 0xB0, 0x80); - rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, PM_CTRL3, 0x10, 0x00); return rtsx_pci_send_cmd(pcr, 100); }
@@ -128,7 +127,7 @@ static int rts5249_optimize_phy(struct rtsx_pcr *pcr) {int err; - err =rtsx_gops_pm_reset (pcr); + err =rtsx_pci_write_register (pcr,PM_CTRL3 ,D3_DELINK_MODE_EN ,0x00 );if (err <0 )return err;
drivers/mfd/rtsx_gops.c deleted +0 -37
@@ -1,37 +0,0 @@ -/* Driver for Realtek PCI-Express card reader -* -* Copyright(c) 2009-2013 Realtek Semiconductor Corp. All rights reserved. -* -* This program is free software; you can redistribute it and/or modify it -* under the terms of the GNU General Public License as published by the -* Free Software Foundation; either version 2, or (at your option) any -* later version. -* -* This program is distributed in the hope that it will be useful, but -* WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -* General Public License for more details. -* -* You should have received a copy of the GNU General Public License along -* with this program; if not, see <http://www.gnu.org/licenses/>. -* -* Author: -* Micky Ching <[email protected]> -*/ - -#include <linux/mfd/rtsx_pci.h> -#include "rtsx_pcr.h" - -int rtsx_gops_pm_reset (struct rtsx_pcr *pcr) -{ -int err; - -/* init aspm */ -rtsx_pci_write_register (pcr,ASPM_FORCE_CTL ,0xFF ,0x00 ); - err =rtsx_pci_update_cfg_byte (pcr,LCTLR , ~LCTLR_ASPM_CTL_MASK ,0x00 ); -if (err <0 ) -return err; - -/* reset PM_CTRL3 before send buffer cmd */ -return rtsx_pci_write_register (pcr,PM_CTRL3 ,D3_DELINK_MODE_EN ,0x00 ); -}
drivers/mfd/rtsx_pcr.c +18 -5
@@ -63,6 +63,18 @@ static const struct pci_device_id rtsx_pci_ids[] = {MODULE_DEVICE_TABLE (pci, rtsx_pci_ids); +static inline void rtsx_pci_enable_aspm (struct rtsx_pcr *pcr) +{ +rtsx_pci_update_cfg_byte (pcr, pcr->pcie_cap +PCI_EXP_LNKCTL , +0xFC , pcr->aspm_en); +} + +static inline void rtsx_pci_disable_aspm (struct rtsx_pcr *pcr) +{ +rtsx_pci_update_cfg_byte (pcr, pcr->pcie_cap +PCI_EXP_LNKCTL , +0xFC ,0 ); +} +void rtsx_pci_start_run (struct rtsx_pcr *pcr) {/* If pci device removed, don't queue idle work any more */
@@ -75,7 +87,8 @@ void rtsx_pci_start_run(struct rtsx_pcr *pcr) pcr->ops->enable_auto_blink (pcr);if (pcr->aspm_en) -rtsx_pci_write_config_byte (pcr,LCTLR ,0 ); +rtsx_pci_disable_aspm (pcr); + }mod_delayed_work (system_wq, &pcr->idle_work,msecs_to_jiffies (200 ));
@@ -942,7 +955,7 @@ static void rtsx_pci_idle_work(struct work_struct *work) pcr->ops->turn_off_led (pcr);if (pcr->aspm_en) -rtsx_pci_write_config_byte (pcr,LCTLR , pcr->aspm_en); +rtsx_pci_enable_aspm (pcr);mutex_unlock (&pcr->pcr_mutex); }
@@ -968,6 +981,7 @@ static int rtsx_pci_init_hw(struct rtsx_pcr *pcr) {int err; + pcr->pcie_cap =pci_find_capability (pcr->pci,PCI_CAP_ID_EXP );rtsx_pci_writel (pcr,RTSX_HCBAR , pcr->host_cmds_addr);rtsx_pci_enable_bus_int (pcr);
@@ -980,6 +994,7 @@ static int rtsx_pci_init_hw(struct rtsx_pcr *pcr)/* Wait SSC power stable */ udelay (200 ); +rtsx_pci_disable_aspm (pcr);if (pcr->ops->optimize_phy) { err = pcr->ops->optimize_phy (pcr);if (err <0 )
@@ -1028,10 +1043,8 @@ static int rtsx_pci_init_hw(struct rtsx_pcr *pcr)if (err <0 )return err; -rtsx_pci_write_config_byte (pcr,LCTLR ,0 ); -/* Enable clk_request_n to enable clock power management */ -rtsx_pci_write_config_byte (pcr,0x81 ,1 ); +rtsx_pci_write_config_byte (pcr, pcr->pcie_cap +PCI_EXP_LNKCTL +1 ,1 );/* Enter L1 when host tx idle */ rtsx_pci_write_config_byte (pcr,0x70F ,0x5B );
include/linux/mfd/rtsx_pci.h +1 -9
@@ -716,15 +716,6 @@#define PHY_DUM_REG 0x1F -#define LCTLR 0x80 -#define LCTLR_EXT_SYNC 0x80 -#define LCTLR_COMMON_CLOCK_CFG 0x40 -#define LCTLR_RETRAIN_LINK 0x20 -#define LCTLR_LINK_DISABLE 0x10 -#define LCTLR_RCB 0x08 -#define LCTLR_RESERVED 0x04 -#define LCTLR_ASPM_CTL_MASK 0x03 -#define PCR_SETTING_REG1 0x724#define PCR_SETTING_REG2 0x814#define PCR_SETTING_REG3 0x747
@@ -759,6 +750,7 @@ enum PDEV_STAT {PDEV_STAT_IDLE, PDEV_STAT_RUN};struct rtsx_pcr {struct pci_dev *pci;unsigned int id; +int pcie_cap;/* pci resources */ unsigned long addr;
Signature · 1 line
1.9.1
PATCH v2 8/9 mfd: rtsx: add support for rts525A
In reply to [email protected]From: Micky Ching <[email protected]>
add support for new chip rts525A.
--- drivers/mfd/rts5249.c | 104 ++++++++++++++++++++++++++++++++++++++++++- drivers/mfd/rtsx_pcr.c | 13 ++++-- drivers/mfd/rtsx_pcr.h | 1 + include/linux/mfd/rtsx_pci.h | 15 +++++++ 4 files changed, 129 insertions(+), 4 deletions(-)
drivers/mfd/rts5249.c +103 -1
@@ -97,7 +97,7 @@ static void rtsx_base_force_power_down(struct rtsx_pcr *pcr, u8 pm_state)rtsx_pci_write_register (pcr,AUTOLOAD_CFG_BASE +3 ,0x01 ,0 );if (pm_state ==HOST_ENTER_S3 ) { -if (PCI_PID (pcr) ==0x524A ) +if (PCI_PID (pcr) ==0x524A ||PCI_PID (pcr) ==0x525A )rtsx_pci_write_register (pcr,RTS524A_PM_CTRL3 ,D3_DELINK_MODE_EN ,D3_DELINK_MODE_EN );else if (PCI_PID (pcr) ==0x5249 )
@@ -485,3 +485,105 @@ void rts524a_init_params(struct rtsx_pcr *pcr) pcr->ops = &rts524a_pcr_ops; } +static int rts525a_card_power_on (struct rtsx_pcr *pcr,int card) +{ +rtsx_pci_write_register (pcr,LDO_VCC_CFG1 , +LDO_VCC_TUNE_MASK ,LDO_VCC_3V3 ); +return rtsx_base_card_power_on (pcr, card); +} + +static int rts525a_switch_output_voltage (struct rtsx_pcr *pcr,u8 voltage) +{ +switch (voltage) { +case OUTPUT_3V3 : +rtsx_pci_write_register (pcr,LDO_CONFIG2 , +LDO_D3318_MASK ,LDO_D3318_33V ); +rtsx_pci_write_register (pcr,SD_PAD_CTL ,SD_IO_USING_1V8 ,0 ); +break ; +case OUTPUT_1V8 : +rtsx_pci_write_register (pcr,LDO_CONFIG2 , +LDO_D3318_MASK ,LDO_D3318_18V ); +rtsx_pci_write_register (pcr,SD_PAD_CTL ,SD_IO_USING_1V8 , +SD_IO_USING_1V8 ); +break ; +default : +return -EINVAL ; + } + +rtsx_pci_init_cmd (pcr); +rts5249_fill_driving (pcr, voltage); +return rtsx_pci_send_cmd (pcr,100 ); +} + +static int rts525a_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_FLD0, + _PHY_FLD0_CLK_REQ_20C | _PHY_FLD0_RX_IDLE_EN | + _PHY_FLD0_BIT_ERR_RSTN | _PHY_FLD0_BER_COUNT | + _PHY_FLD0_BER_TIMER | _PHY_FLD0_CHECK_EN); + +rtsx_pci_write_phy_register (pcr, _PHY_ANA03, + _PHY_ANA03_TIMER_MAX | _PHY_ANA03_OOBS_DEB_EN | + _PHY_CMU_DEBUG_EN); + +if (is_version (pcr,0x525A ,IC_VER_A )) +rtsx_pci_write_phy_register (pcr, _PHY_REV0, + _PHY_REV0_FILTER_OUT | _PHY_REV0_CDR_BYPASS_PFD | + _PHY_REV0_CDR_RX_IDLE_BYPASS); + +return 0 ; +} + +static int rts525a_extra_init_hw (struct rtsx_pcr *pcr) +{ +rts5249_extra_init_hw (pcr); + +rtsx_pci_write_register (pcr,PCLK_CTL ,PCLK_MODE_SEL ,PCLK_MODE_SEL ); +if (is_version (pcr,0x525A ,IC_VER_A )) { +rtsx_pci_write_register (pcr,L1SUB_CONFIG2 , +L1SUB_AUTO_CFG ,L1SUB_AUTO_CFG ); +rtsx_pci_write_register (pcr,RREF_CFG , +RREF_VBGSEL_MASK ,RREF_VBGSEL_1V25 ); +rtsx_pci_write_register (pcr,LDO_VIO_CFG , +LDO_VIO_TUNE_MASK ,LDO_VIO_1V7 ); +rtsx_pci_write_register (pcr,LDO_DV12S_CFG , +LDO_D12_TUNE_MASK ,LDO_D12_TUNE_DF ); +rtsx_pci_write_register (pcr,LDO_AV12S_CFG , +LDO_AV12S_TUNE_MASK ,LDO_AV12S_TUNE_DF ); +rtsx_pci_write_register (pcr,LDO_VCC_CFG0 , +LDO_VCC_LMTVTH_MASK ,LDO_VCC_LMTVTH_2A ); +rtsx_pci_write_register (pcr,OOBS_CONFIG , +OOBS_AUTOK_DIS |OOBS_VAL_MASK ,0x89 ); + } + +return 0 ; +} + +static const struct pcr_ops rts525a_pcr_ops = { + .fetch_vendor_settings = rtsx_base_fetch_vendor_settings, + .extra_init_hw = rts525a_extra_init_hw, + .optimize_phy = rts525a_optimize_phy, + .turn_on_led = rtsx_base_turn_on_led, + .turn_off_led = rtsx_base_turn_off_led, + .enable_auto_blink = rtsx_base_enable_auto_blink, + .disable_auto_blink = rtsx_base_disable_auto_blink, + .card_power_on = rts525a_card_power_on, + .card_power_off = rtsx_base_card_power_off, + .switch_output_voltage = rts525a_switch_output_voltage, + .force_power_down = rtsx_base_force_power_down, +}; + +void rts525a_init_params (struct rtsx_pcr *pcr) +{ +rts5249_init_params (pcr); + + pcr->ops = &rts525a_pcr_ops; +} +
drivers/mfd/rtsx_pcr.c +10 -3
@@ -59,6 +59,7 @@ static const struct pci_device_id rtsx_pci_ids[] = { { PCI_DEVICE(0x10EC, 0x5287), PCI_CLASS_OTHERS << 16, 0xFF0000 }, { PCI_DEVICE(0x10EC, 0x5286), PCI_CLASS_OTHERS << 16, 0xFF0000 }, { PCI_DEVICE(0x10EC, 0x524A), PCI_CLASS_OTHERS << 16, 0xFF0000 }, + { PCI_DEVICE(0x10EC, 0x525A), PCI_CLASS_OTHERS << 16, 0xFF0000 }, { 0, } };
@@ -1115,6 +1116,10 @@ static int rtsx_pci_init_chip(struct rtsx_pcr *pcr)rts524a_init_params (pcr);break ; +case 0x525A : +rts525a_init_params (pcr); +break ; +case 0x5287 :rtl8411b_init_params (pcr);break ;
@@ -1160,7 +1165,7 @@ static int rtsx_pci_probe(struct pci_dev *pcidev,struct rtsx_pcr *pcr;struct pcr_handle *handle;u32 base, len; -int ret, i; +int ret, i, bar =0 ; dev_dbg(&(pcidev->dev), ": Realtek PCI-E Card Reader found at %s [%04x:%04x] (rev %x)\n",
@@ -1205,8 +1210,10 @@ static int rtsx_pci_probe(struct pci_dev *pcidev, pcr->pci = pcidev;dev_set_drvdata (&pcidev->dev, handle); - len =pci_resource_len (pcidev,0 ); - base =pci_resource_start (pcidev,0 ); +if (PCI_PID (pcr) ==0x525A ) + bar =1 ; + len =pci_resource_len (pcidev, bar); + base =pci_resource_start (pcidev, bar); pcr->remap_addr =ioremap_nocache (base, len);if (!pcr->remap_addr) { ret = -ENOMEM ;
drivers/mfd/rtsx_pcr.h +1 -0
@@ -40,6 +40,7 @@ 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 rts525a_init_params (struct rtsx_pcr *pcr);void rtl8411b_init_params (struct rtsx_pcr *pcr);static inline u8 map_sd_drive (int idx)
include/linux/mfd/rtsx_pci.h +15 -0
@@ -727,6 +727,10 @@#define PHY_SSCCR3 0x03#define PHY_SSCCR3_STEP_IN 0x2740#define PHY_SSCCR3_CHECK_DELAY 0x0008 +#define _PHY_ANA03 0x03 +#define _PHY_ANA03_TIMER_MAX 0x2700 +#define _PHY_ANA03_OOBS_DEB_EN 0x0040 +#define _PHY_CMU_DEBUG_EN 0x0008#define PHY_RTCR 0x04#define PHY_RDR 0x05
@@ -780,6 +784,10 @@#define PHY_REV_STOP_CLKRD 0x0020#define PHY_REV_RX_PWST 0x0008#define PHY_REV_STOP_CLKWR 0x0004 +#define _PHY_REV0 0x19 +#define _PHY_REV0_FILTER_OUT 0x3800 +#define _PHY_REV0_CDR_BYPASS_PFD 0x0100 +#define _PHY_REV0_CDR_RX_IDLE_BYPASS 0x0002#define PHY_FLD0 0x1A#define PHY_ANA1A 0x1A
@@ -795,6 +803,13 @@#define PHY_FLD3_RXDELINK 0x0004#define PHY_ANA1D 0x1D#define PHY_ANA1D_DEBUG_ADDR 0x0004 +#define _PHY_FLD0 0x1D +#define _PHY_FLD0_CLK_REQ_20C 0x8000 +#define _PHY_FLD0_RX_IDLE_EN 0x1000 +#define _PHY_FLD0_BIT_ERR_RSTN 0x0800 +#define _PHY_FLD0_BER_COUNT 0x01E0 +#define _PHY_FLD0_BER_TIMER 0x001E +#define _PHY_FLD0_CHECK_EN 0x0001#define PHY_FLD4 0x1E#define PHY_FLD4_FLDEN_SEL 0x4000
Signature · 1 line
1.9.1
PATCH v2 4/9 mfd: rtsx: update driving settings
In reply to [email protected]From: Micky Ching <[email protected]>
update card drive settings, This setting can be used for rts5249 rts524A and rts525A.
--- drivers/mfd/rts5249.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
drivers/mfd/rts5249.c +6 -6
@@ -36,16 +36,16 @@ static u8 rts5249_get_ic_version(struct rtsx_pcr *pcr)static void rts5249_fill_driving (struct rtsx_pcr *pcr,u8 voltage) {u8 driving_3v3[4 ][3 ] = { - {0x11 ,0x11 ,0x11 }, + {0x11 ,0x11 ,0x18 }, {0x55 ,0x55 ,0x5C }, - {0x99 ,0x99 ,0x92 }, - {0x99 ,0x99 ,0x92 }, + {0xFF ,0xFF ,0xFF }, + {0x96 ,0x96 ,0x96 }, };u8 driving_1v8[4 ][3 ] = { + {0xC4 ,0xC4 ,0xC4 }, {0x3C ,0x3C ,0x3C }, - {0xB3 ,0xB3 ,0xB3 }, {0xFE ,0xFE ,0xFE }, - {0xC4 ,0xC4 ,0xC4 }, + {0xB3 ,0xB3 ,0xB3 }, };u8 (*driving)[3 ], drive_sel;
@@ -341,7 +341,7 @@ void rts5249_init_params(struct rtsx_pcr *pcr) pcr->flags =0 ; pcr->card_drive_sel =RTSX_CARD_DRIVE_DEFAULT ; - pcr->sd30_drive_sel_1v8 =CFG_DRIVER_TYPE_C ; + pcr->sd30_drive_sel_1v8 =CFG_DRIVER_TYPE_B ; pcr->sd30_drive_sel_3v3 =CFG_DRIVER_TYPE_B ; pcr->aspm_en =ASPM_L1_EN ; pcr->tx_initial_phase =SET_CLOCK_PHASE (1 ,29 ,16 );
Signature · 1 line
1.9.1
PATCH v2 3/9 mfd: rtsx: update PETXCFG address
In reply to [email protected]From: Micky Ching <[email protected]>
PETXCFG is defined at 0xFF03, the old 0xFE49 not used any more.
--- drivers/mfd/rts5227.c | 6 ++---- drivers/mfd/rts5249.c | 6 ++---- include/linux/mfd/rtsx_pci.h | 2 +- 3 files changed, 5 insertions(+), 9 deletions(-)
drivers/mfd/rts5227.c +2 -4
@@ -118,11 +118,9 @@ static int rts5227_extra_init_hw(struct rtsx_pcr *pcr)rts5227_fill_driving (pcr,OUTPUT_3V3 );/* Configure force_clock_req */ if (pcr->flags &PCR_REVERSE_SOCKET ) -rtsx_pci_add_cmd (pcr,WRITE_REG_CMD , -AUTOLOAD_CFG_BASE +3 ,0xB8 ,0xB8 ); +rtsx_pci_add_cmd (pcr,WRITE_REG_CMD ,PETXCFG ,0xB8 ,0xB8 );else -rtsx_pci_add_cmd (pcr,WRITE_REG_CMD , -AUTOLOAD_CFG_BASE +3 ,0xB8 ,0x88 ); +rtsx_pci_add_cmd (pcr,WRITE_REG_CMD ,PETXCFG ,0xB8 ,0x88 );rtsx_pci_add_cmd (pcr,WRITE_REG_CMD ,PM_CTRL3 ,0x10 ,0x00 );return rtsx_pci_send_cmd (pcr,100 );
drivers/mfd/rts5249.c +2 -4
@@ -116,11 +116,9 @@ static int rts5249_extra_init_hw(struct rtsx_pcr *pcr)/* Configure driving */ rts5249_fill_driving (pcr,OUTPUT_3V3 );if (pcr->flags &PCR_REVERSE_SOCKET ) -rtsx_pci_add_cmd (pcr,WRITE_REG_CMD , -AUTOLOAD_CFG_BASE +3 ,0xB0 ,0xB0 ); +rtsx_pci_add_cmd (pcr,WRITE_REG_CMD ,PETXCFG ,0xB0 ,0xB0 );else -rtsx_pci_add_cmd (pcr,WRITE_REG_CMD , -AUTOLOAD_CFG_BASE +3 ,0xB0 ,0x80 ); +rtsx_pci_add_cmd (pcr,WRITE_REG_CMD ,PETXCFG ,0xB0 ,0x80 );rtsx_pci_add_cmd (pcr,WRITE_REG_CMD ,PM_CTRL3 ,0x10 ,0x00 );return rtsx_pci_send_cmd (pcr,100 );
include/linux/mfd/rtsx_pci.h +1 -1
@@ -572,7 +572,6 @@#define MSGTXDATA2 0xFE46#define MSGTXDATA3 0xFE47#define MSGTXCTL 0xFE48 -#define PETXCFG 0xFE49#define LTR_CTL 0xFE4A#define OBFF_CFG 0xFE4C
@@ -606,6 +605,7 @@#define DUMMY_REG_RESET_0 0xFE90#define AUTOLOAD_CFG_BASE 0xFF00 +#define PETXCFG 0xFF03#define PM_CTRL1 0xFF44#define PM_CTRL2 0xFF45
Signature · 1 line
1.9.1
Have you reworked all of these patches?
If not, why haven't my Acks been carried forward?
Please [RESEND] with the Acks applied.
Quoted 38 lines
From: Micky Ching <[email protected]>
v2:
- remove debug info when access failed.
- using macro list for phy register init.
- rename function for multi chip prefix withrtsx_base_
- savepcie_capoffset when init chip, not callingpci_find_capacity()every time.
- addpcr->ops: write_phy/read_phy for special chip.This patchset including re-format some coding-style and add two new chip rts524A and rts525A.
Micky Ching (9):
mfd: rtsx: replace TAB by SPC after #define
mfd: rtsx: place register address and values togather
mfd: rtsx: update PETXCFG address
mfd: rtsx: update driving settings
mfd: rtsx: update phy register
mfd: rtsx: remove LCTLR defination
mfd: rtsx: add support for rts524A
mfd: rtsx: add support for rts525A
mfd: rtsx: usingpcr_dbgreplacedev_dbgdrivers/mfd/Makefile | 2 +- drivers/mfd/rtl8411.c | 11 +- drivers/mfd/rts5209.c | 4 +- drivers/mfd/rts5227.c | 12 +- drivers/mfd/rts5229.c | 4 +- drivers/mfd/rts5249.c | 368 +++++++++++--- drivers/mfd/rtsx_gops.c | 37 -- drivers/mfd/rtsx_pcr.c | 110 +++-- drivers/mfd/rtsx_pcr.h | 8 + include/linux/mfd/rtsx_pci.h | 1109 ++++++++++++++++++++++-------------------- 10 files changed, 966 insertions(+), 699 deletions(-) delete mode 100644 drivers/mfd/rtsx_gops.c
Signature · 4 lines
Lee Jones Linaro STMicroelectronics Landing Team Lead Linaro.org │ Open source software for ARM SoCs Follow Linaro: Facebook | Twitter | Blog