rtsx patchset for MFD and MMC tree
Subsystems (2)
v2 cover rtsx patchset for MFD and MMC tree
From: Wei WANG <[email protected]>
Wei WANG (8):
MFD:rtsx: Fix typo in comment
MFD:rtsx: Remove redundant code
MFD:rtsx: Declare that the DMA address limitation is 32bit explicitly MFD:rtsx: Add callback function switch_output_voltage MMC:rtsx: Using callback function to switch output voltage MFD:rtsx: Add callback function conv_clk_and_div_n MFD:rtsx: Fix checkpatch warning
MFD:rtsx: Use macro defines to replace some variables
drivers/mfd/rtl8411.c | 29 ++++++++++++++++++++++++ drivers/mfd/rts5209.c | 21 +++++++++++++++++ drivers/mfd/rts5229.c | 21 +++++++++++++++++ drivers/mfd/rtsx_pcr.c | 45 +++++++++++++++++++++++++------------ drivers/mfd/rtsx_pcr.h | 3 +++ drivers/mmc/host/rtsx_pci_sdmmc.c | 30 +++++-------------------- include/linux/mfd/rtsx_common.h | 3 +++ include/linux/mfd/rtsx_pci.h | 27 +++++++++++++++++----- 8 files changed, 135 insertions(+), 44 deletions(-)
Signature · 1 line
1.7.9.5
PATCH v2 1/8 MFD:rtsx: Fix typo in comment
From: Wei WANG <[email protected]>
Fix a misspelling word in comment
--- include/linux/mfd/rtsx_pci.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
include/linux/mfd/rtsx_pci.h +1 -1
@@ -452,7 +452,7 @@#define SD_RSP_TYPE_R6 0x01#define SD_RSP_TYPE_R7 0x01 -/* SD_CONFIURE3 */ +/* SD_CONFIGURE3 */ #define SD_RSP_80CLK_TIMEOUT_EN 0x01/* Card Transfer Reset Register */
Signature · 1 line
1.7.9.5
PATCH v2 2/8 MFD:rtsx: Remove redundant code
In reply to [email protected]From: Wei WANG <[email protected]>
In function rtsx_pci_add_sg_tbl, the statement "ptr++" is useless.
--- drivers/mfd/rtsx_pcr.c | 1 - 1 file changed, 1 deletion(-)
drivers/mfd/rtsx_pcr.c +0 -1
@@ -325,7 +325,6 @@ static void rtsx_pci_add_sg_tbl(struct rtsx_pcr *pcr, val = ((u64 )addr <<32 ) | ((u64 )len <<12 ) | option;put_unaligned_le64 (val, ptr); - ptr++; pcr->sgi++; }
Signature · 1 line
1.7.9.5
Re: [PATCH v2 2/8] MFD:rtsx: Remove redundant code
Quoted 5 lines · On Tue, Dec 25, 2012 at 10:43:03AM +0800, [email protected] wrote:
From: Wei WANG <[email protected]>
In function
rtsx_pci_add_sg_tbl, the statement "ptr++" is useless.Signed-off-by Wei WANG <[email protected]>
Signature · 5 lines
Regards/Gruss,
Boris.
Sent from a fat crate under my desk. Formatting is fine.
--PATCH v2 3/8 MFD:rtsx: Declare that the DMA address limitation is 32bit explicitly
In reply to [email protected]From: Wei WANG <[email protected]>
--- drivers/mfd/rtsx_pcr.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/mfd/rtsx_pcr.c +4 -0
@@ -1010,6 +1010,10 @@ static int __devinit rtsx_pci_probe(struct pci_dev *pcidev,pci_name (pcidev), (int )pcidev->vendor, (int )pcidev->device, (int)pcidev->revision); + ret =pci_set_dma_mask (pcidev,DMA_BIT_MASK (32 )); +if (ret <0 ) +return ret; + ret =pci_enable_device (pcidev);if (ret)return ret;
Signature · 1 line
1.7.9.5
Re: [PATCH v2 3/8] MFD:rtsx: Declare that the DMA address limitation is 32bit explicitly
Quoted 3 lines · On Tue, Dec 25, 2012 at 10:43:09AM +0800, [email protected] wrote:
From: Wei WANG <[email protected]>
Signed-off-by Wei WANG <[email protected]>
This one is still missing a commit message. You might want to write some blubber about the hardware supporting only 32-bit DMA or whatever the real reason is.
Also, with the whole patchset, please don't send it the very next day but do wait a couple of days to collect all feedback from people - especially now I'd wait even longer since everyone except you and me are away :) - and then resend it after incorporating all feedback.
Thanks.
Signature · 5 lines
Regards/Gruss,
Boris.
Sent from a fat crate under my desk. Formatting is fine.
--PATCH v2 4/8 MFD:rtsx: Add callback function switch_output_voltage
In reply to [email protected]From: Wei WANG <[email protected]>
Different card reader has different method to switch output voltage, add this callback to let the card reader implement its individual switch function.
--- drivers/mfd/rtl8411.c | 16 ++++++++++++++++ drivers/mfd/rts5209.c | 20 ++++++++++++++++++++ drivers/mfd/rts5229.c | 20 ++++++++++++++++++++ drivers/mfd/rtsx_pcr.c | 9 +++++++++ include/linux/mfd/rtsx_pci.h | 24 ++++++++++++++++++++---- 5 files changed, 85 insertions(+), 4 deletions(-)
drivers/mfd/rtl8411.c +16 -0
@@ -112,6 +112,21 @@ static int rtl8411_card_power_off(struct rtsx_pcr *pcr, int card) BPP_LDO_POWB, BPP_LDO_SUSPEND); } +static int rtl8411_switch_output_voltage (struct rtsx_pcr *pcr,u8 voltage) +{ +u8 mask, val; + + mask = (BPP_REG_TUNED18 <<BPP_TUNED18_SHIFT_8411 ) |BPP_PAD_MASK ; +if (voltage ==OUTPUT_3V3 ) + val = (BPP_ASIC_3V3 <<BPP_TUNED18_SHIFT_8411 ) |BPP_PAD_3V3 ; +else if (voltage ==OUTPUT_1V8 ) + val = (BPP_ASIC_1V8 <<BPP_TUNED18_SHIFT_8411 ) |BPP_PAD_1V8 ; +else +return -EINVAL ; + +return rtsx_pci_write_register (pcr,LDO_CTL , mask, val); +} +static unsigned int rtl8411_cd_deglitch (struct rtsx_pcr *pcr) {unsigned int card_exist;
@@ -172,6 +187,7 @@ static const struct pcr_ops rtl8411_pcr_ops = { .disable_auto_blink = rtl8411_disable_auto_blink, .card_power_on = rtl8411_card_power_on, .card_power_off = rtl8411_card_power_off, + .switch_output_voltage = rtl8411_switch_output_voltage, .cd_deglitch = rtl8411_cd_deglitch, };
drivers/mfd/rts5209.c +20 -0
@@ -144,6 +144,25 @@ static int rts5209_card_power_off(struct rtsx_pcr *pcr, int card)return rtsx_pci_send_cmd (pcr,100 ); } +static int rts5209_switch_output_voltage (struct rtsx_pcr *pcr,u8 voltage) +{ +int err; + +if (voltage ==OUTPUT_3V3 ) { + err =rtsx_pci_write_phy_register (pcr,0x08 ,0x4FC0 |0x24 ); +if (err <0 ) +return err; + }else if (voltage ==OUTPUT_1V8 ) { + err =rtsx_pci_write_phy_register (pcr,0x08 ,0x4C40 |0x24 ); +if (err <0 ) +return err; + }else { +return -EINVAL ; + } + +return 0 ; +} +static const struct pcr_ops rts5209_pcr_ops = { .extra_init_hw = rts5209_extra_init_hw, .optimize_phy = rts5209_optimize_phy,
@@ -153,6 +172,7 @@ static const struct pcr_ops rts5209_pcr_ops = { .disable_auto_blink = rts5209_disable_auto_blink, .card_power_on = rts5209_card_power_on, .card_power_off = rts5209_card_power_off, + .switch_output_voltage = rts5209_switch_output_voltage, .cd_deglitch = NULL, };
drivers/mfd/rts5229.c +20 -0
@@ -114,6 +114,25 @@ static int rts5229_card_power_off(struct rtsx_pcr *pcr, int card)return rtsx_pci_send_cmd (pcr,100 ); } +static int rts5229_switch_output_voltage (struct rtsx_pcr *pcr,u8 voltage) +{ +int err; + +if (voltage ==OUTPUT_3V3 ) { + err =rtsx_pci_write_phy_register (pcr,0x08 ,0x4FC0 |0x24 ); +if (err <0 ) +return err; + }else if (voltage ==OUTPUT_1V8 ) { + err =rtsx_pci_write_phy_register (pcr,0x08 ,0x4C40 |0x24 ); +if (err <0 ) +return err; + }else { +return -EINVAL ; + } + +return 0 ; +} +static const struct pcr_ops rts5229_pcr_ops = { .extra_init_hw = rts5229_extra_init_hw, .optimize_phy = rts5229_optimize_phy,
@@ -123,6 +142,7 @@ static const struct pcr_ops rts5229_pcr_ops = { .disable_auto_blink = rts5229_disable_auto_blink, .card_power_on = rts5229_card_power_on, .card_power_off = rts5229_card_power_off, + .switch_output_voltage = rts5229_switch_output_voltage, .cd_deglitch = NULL, };
drivers/mfd/rtsx_pcr.c +9 -0
@@ -702,6 +702,15 @@ int rtsx_pci_card_power_off(struct rtsx_pcr *pcr, int card) }EXPORT_SYMBOL_GPL (rtsx_pci_card_power_off); +int rtsx_pci_switch_output_voltage (struct rtsx_pcr *pcr,u8 voltage) +{ +if (pcr->ops->switch_output_voltage) +return pcr->ops->switch_output_voltage (pcr, voltage); + +return 0 ; +} +EXPORT_SYMBOL_GPL (rtsx_pci_switch_output_voltage); +unsigned int rtsx_pci_card_exist (struct rtsx_pcr *pcr) {unsigned int val;
include/linux/mfd/rtsx_pci.h +20 -4
@@ -158,10 +158,9 @@#define SG_TRANS_DATA (0x02 << 4)#define SG_LINK_DESC (0x03 << 4) -/* SD bank voltage */ -#define SD_IO_3V3 0 -#define SD_IO_1V8 1 - +/* Output voltage */ +#define OUTPUT_3V3 0 +#define OUTPUT_1V8 1/* Card Clock Enable Register */ #define SD_CLK_EN 0x04
@@ -201,6 +200,20 @@#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
@@ -688,6 +701,8 @@ struct pcr_ops {int (*disable_auto_blink)(struct rtsx_pcr *pcr);int (*card_power_on)(struct rtsx_pcr *pcr,int card);int (*card_power_off)(struct rtsx_pcr *pcr,int card); +int (*switch_output_voltage)(struct rtsx_pcr *pcr, +u8 voltage);unsigned int (*cd_deglitch)(struct rtsx_pcr *pcr); };
@@ -783,6 +798,7 @@ int rtsx_pci_switch_clock(struct rtsx_pcr *pcr, unsigned int card_clock, u8 ssc_depth, bool initial_mode, bool double_clk, bool vpclk);int rtsx_pci_card_power_on (struct rtsx_pcr *pcr,int card);int rtsx_pci_card_power_off (struct rtsx_pcr *pcr,int card); +int rtsx_pci_switch_output_voltage (struct rtsx_pcr *pcr,u8 voltage);unsigned int rtsx_pci_card_exist (struct rtsx_pcr *pcr);void rtsx_pci_complete_unfinished_transfer (struct rtsx_pcr *pcr);
Signature · 1 line
1.7.9.5
PATCH v2 5/8 MMC:rtsx: Using callback function to switch output voltage
In reply to [email protected]From: Wei WANG <[email protected]>
Different card reader has different method to switch output voltage, so we have to use the callback function provided by MFD driver to switch output pad voltage.
--- drivers/mmc/host/rtsx_pci_sdmmc.c | 30 +++++------------------------- 1 file changed, 5 insertions(+), 25 deletions(-)
drivers/mmc/host/rtsx_pci_sdmmc.c +5 -25
@@ -1060,26 +1060,6 @@ static int sd_wait_voltage_stable_2(struct realtek_pci_sdmmc *host)return 0 ; } -static int sd_change_bank_voltage (struct realtek_pci_sdmmc *host,u8 voltage) -{ -struct rtsx_pcr *pcr = host->pcr; -int err; - -if (voltage ==SD_IO_3V3 ) { - err =rtsx_pci_write_phy_register (pcr,0x08 ,0x4FC0 |0x24 ); -if (err <0 ) -return err; - }else if (voltage ==SD_IO_1V8 ) { - err =rtsx_pci_write_phy_register (pcr,0x08 ,0x4C40 |0x24 ); -if (err <0 ) -return err; - }else { -return -EINVAL ; - } - -return 0 ; -} -static int sdmmc_switch_voltage (struct mmc_host *mmc,struct mmc_ios *ios) {struct realtek_pci_sdmmc *host =mmc_priv (mmc);
@@ -1098,11 +1078,11 @@ static int sdmmc_switch_voltage(struct mmc_host *mmc, struct mmc_ios *ios)rtsx_pci_start_run (pcr);if (ios->signal_voltage ==MMC_SIGNAL_VOLTAGE_330 ) - voltage =SD_IO_3V3 ; + voltage =OUTPUT_3V3 ;else - voltage =SD_IO_1V8 ; + voltage =OUTPUT_1V8 ; -if (voltage ==SD_IO_1V8 ) { +if (voltage ==OUTPUT_1V8 ) { err =rtsx_pci_write_register (pcr,SD30_DRIVE_SEL ,0x07 ,DRIVER_TYPE_B );if (err <0 )
@@ -1113,11 +1093,11 @@ static int sdmmc_switch_voltage(struct mmc_host *mmc, struct mmc_ios *ios) goto out; } - err =sd_change_bank_voltage (host, voltage); + err =rtsx_pci_switch_output_voltage (pcr, voltage);if (err <0 ) goto out; -if (voltage ==SD_IO_1V8 ) { +if (voltage ==OUTPUT_1V8 ) { err =sd_wait_voltage_stable_2 (host);if (err <0 ) goto out;
Signature · 1 line
1.7.9.5
PATCH v2 6/8 MFD:rtsx: Add callback function conv_clk_and_div_n
In reply to [email protected]From: Wei WANG <[email protected]>
Add callback function conv_clk_and_div_n to convert between SSC clock and its divider N.
For rtl8411, the formula to calculate SSC clock divider N is different with the other card reader models.
--- drivers/mfd/rtl8411.c | 13 +++++++++++++ drivers/mfd/rts5209.c | 1 + drivers/mfd/rts5229.c | 1 + drivers/mfd/rtsx_pcr.c | 14 ++++++++++++-- include/linux/mfd/rtsx_common.h | 3 +++ include/linux/mfd/rtsx_pci.h | 1 + 6 files changed, 31 insertions(+), 2 deletions(-)
drivers/mfd/rtl8411.c +13 -0
@@ -178,6 +178,18 @@ static unsigned int rtl8411_cd_deglitch(struct rtsx_pcr *pcr)return card_exist; } +static int rtl8411_conv_clk_and_div_n (int input,int dir) +{ +int output; + +if (dir ==CLK_TO_DIV_N ) + output = input *4 /5 -2 ; +else + output = (input +2 ) *5 /4 ; + +return output; +} +static const struct pcr_ops rtl8411_pcr_ops = { .extra_init_hw = rtl8411_extra_init_hw, .optimize_phy =NULL ,
@@ -189,6 +201,7 @@ static const struct pcr_ops rtl8411_pcr_ops = { .card_power_off = rtl8411_card_power_off, .switch_output_voltage = rtl8411_switch_output_voltage, .cd_deglitch = rtl8411_cd_deglitch, + .conv_clk_and_div_n = rtl8411_conv_clk_and_div_n, };/* SD Pull Control Enable:
drivers/mfd/rts5209.c +1 -0
@@ -174,6 +174,7 @@ static const struct pcr_ops rts5209_pcr_ops = { .card_power_off = rts5209_card_power_off, .switch_output_voltage = rts5209_switch_output_voltage, .cd_deglitch = NULL, + .conv_clk_and_div_n = NULL, };/* SD Pull Control Enable:
drivers/mfd/rts5229.c +1 -0
@@ -144,6 +144,7 @@ static const struct pcr_ops rts5229_pcr_ops = { .card_power_off = rts5229_card_power_off, .switch_output_voltage = rts5229_switch_output_voltage, .cd_deglitch = NULL, + .conv_clk_and_div_n = NULL, };/* SD Pull Control Enable:
drivers/mfd/rtsx_pcr.c +12 -2
@@ -629,7 +629,10 @@ int rtsx_pci_switch_clock(struct rtsx_pcr *pcr, unsigned int card_clock,if (clk == pcr->cur_clock)return 0 ; -N = (u8)(clk -2 ); +if (pcr->ops->conv_clk_and_div_n) +N = (u8 )pcr->ops->conv_clk_and_div_n (clk,CLK_TO_DIV_N ); +else +N = (u8)(clk -2 );if ((clk <=2 ) || (N > max_N))return -EINVAL ;
@@ -640,7 +643,14 @@ int rtsx_pci_switch_clock(struct rtsx_pcr *pcr, unsigned int card_clock,/* Make sure that the SSC clock div_n is equal or greater than min_N */ div =CLK_DIV_1 ;while ((N < min_N) && (div < max_div)) { -N = (N +2 ) *2 -2 ; +if (pcr->ops->conv_clk_and_div_n) { +int dbl_clk = pcr->ops->conv_clk_and_div_n (N , +DIV_N_TO_CLK ) *2 ; +N = (u8 )pcr->ops->conv_clk_and_div_n (dbl_clk, +CLK_TO_DIV_N ); + }else { +N = (N +2 ) *2 -2 ; + } div++; }dev_dbg (&(pcr->pci->dev),"N = %d, div = %d\n" ,N , div);
include/linux/mfd/rtsx_common.h +3 -0
@@ -38,6 +38,9 @@#define RTSX_SD_CARD 0#define RTSX_MS_CARD 1 +#define CLK_TO_DIV_N 0 +#define DIV_N_TO_CLK 1 +struct platform_device ;struct rtsx_slot {
include/linux/mfd/rtsx_pci.h +1 -0
@@ -704,6 +704,7 @@ struct pcr_ops {int (*switch_output_voltage)(struct rtsx_pcr *pcr,u8 voltage);unsigned int (*cd_deglitch)(struct rtsx_pcr *pcr); +int (*conv_clk_and_div_n)(int clk,int dir); };enum PDEV_STAT {PDEV_STAT_IDLE ,PDEV_STAT_RUN };
Signature · 1 line
1.7.9.5
PATCH v2 7/8 MFD:rtsx: Fix checkpatch warning
In reply to [email protected]From: Wei WANG <[email protected]>
WARNING: Avoid CamelCase: <min_N>
+ u8 N, min_N, max_N, clk_divider;
WARNING: Avoid CamelCase: <max_N>
+ u8 N, min_N, max_N, clk_divider;
--- drivers/mfd/rtsx_pcr.c | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-)
drivers/mfd/rtsx_pcr.c +13 -13
@@ -590,7 +590,7 @@ int rtsx_pci_switch_clock(struct rtsx_pcr *pcr, unsigned int card_clock, u8 ssc_depth, bool initial_mode, bool double_clk, bool vpclk) { int err, clk; -u8 N , min_N, max_N, clk_divider; +u8 n, min_n, max_n, clk_divider;u8 mcu_cnt, div, max_div; u8 depth[] = { [RTSX_SSC_DEPTH_4M] = SSC_DEPTH_4M,
@@ -615,8 +615,8 @@ int rtsx_pci_switch_clock(struct rtsx_pcr *pcr, unsigned int card_clock, card_clock /=1000000 ;dev_dbg (&(pcr->pci->dev),"Switch card clock to %dMHz\n" , card_clock); - min_N =80 ; - max_N =208 ; + min_n =80 ; + max_n =208 ; max_div =CLK_DIV_8 ; clk = card_clock;
@@ -630,30 +630,30 @@ int rtsx_pci_switch_clock(struct rtsx_pcr *pcr, unsigned int card_clock,return 0 ;if (pcr->ops->conv_clk_and_div_n) -N = (u8 )pcr->ops->conv_clk_and_div_n (clk,CLK_TO_DIV_N ); + n = (u8 )pcr->ops->conv_clk_and_div_n (clk,CLK_TO_DIV_N );else -N = (u8)(clk -2 ); -if ((clk <=2 ) || (N > max_N)) + n = (u8)(clk -2 ); +if ((clk <=2 ) || (n > max_n))return -EINVAL ; mcu_cnt = (u8)(125 /clk +3 );if (mcu_cnt >15 ) mcu_cnt =15 ; -/* Make sure that the SSC clock div_n is equal or greater than min_N */ +/* Make sure that the SSC clock div_n is equal or greater than min_n */ div =CLK_DIV_1 ; -while ((N < min_N) && (div < max_div)) { +while ((n < min_n) && (div < max_div)) {if (pcr->ops->conv_clk_and_div_n) { -int dbl_clk = pcr->ops->conv_clk_and_div_n (N , +int dbl_clk = pcr->ops->conv_clk_and_div_n (n,DIV_N_TO_CLK ) *2 ; -N = (u8 )pcr->ops->conv_clk_and_div_n (dbl_clk, + n = (u8 )pcr->ops->conv_clk_and_div_n (dbl_clk,CLK_TO_DIV_N ); }else { -N = (N +2 ) *2 -2 ; + n = (n +2 ) *2 -2 ; } div++; } -dev_dbg (&(pcr->pci->dev),"N = %d, div = %d\n" ,N , div); +dev_dbg (&(pcr->pci->dev),"N = %d, div = %d\n" , n, div); ssc_depth = depth[ssc_depth];if (double_clk)
@@ -670,7 +670,7 @@ int rtsx_pci_switch_clock(struct rtsx_pcr *pcr, unsigned int card_clock,rtsx_pci_add_cmd (pcr,WRITE_REG_CMD ,SSC_CTL1 ,SSC_RSTB ,0 );rtsx_pci_add_cmd (pcr,WRITE_REG_CMD ,SSC_CTL2 ,SSC_DEPTH_MASK , ssc_depth); -rtsx_pci_add_cmd (pcr,WRITE_REG_CMD ,SSC_DIV_N_0 ,0xFF ,N ); +rtsx_pci_add_cmd (pcr,WRITE_REG_CMD ,SSC_DIV_N_0 ,0xFF , n);rtsx_pci_add_cmd (pcr,WRITE_REG_CMD ,SSC_CTL1 ,SSC_RSTB ,SSC_RSTB );if (vpclk) { rtsx_pci_add_cmd(pcr, WRITE_REG_CMD, SD_VPCLK0_CTL,
Signature · 1 line
1.7.9.5
PATCH v2 8/8 MFD:rtsx: Use macro defines to replace some variables
In reply to [email protected]From: Wei WANG <[email protected]>
In function rtsx_pci_switch_clock, some variables, such as min_n, max_n, and max_div, are not necessary. And those assigned values look very obscure for others. It's more proper to use macro definitions here to replace these variables.
--- drivers/mfd/rtsx_pcr.c | 13 ++++--------- drivers/mfd/rtsx_pcr.h | 3 +++ 2 files changed, 7 insertions(+), 9 deletions(-)
drivers/mfd/rtsx_pcr.c +4 -9
@@ -590,8 +590,7 @@ int rtsx_pci_switch_clock(struct rtsx_pcr *pcr, unsigned int card_clock, u8 ssc_depth, bool initial_mode, bool double_clk, bool vpclk) { int err, clk; -u8 n, min_n, max_n, clk_divider; -u8 mcu_cnt, div, max_div; +u8 n, clk_divider, mcu_cnt, div; u8 depth[] = { [RTSX_SSC_DEPTH_4M] = SSC_DEPTH_4M, [RTSX_SSC_DEPTH_2M] = SSC_DEPTH_2M,
@@ -615,10 +614,6 @@ int rtsx_pci_switch_clock(struct rtsx_pcr *pcr, unsigned int card_clock, card_clock /=1000000 ;dev_dbg (&(pcr->pci->dev),"Switch card clock to %dMHz\n" , card_clock); - min_n =80 ; - max_n =208 ; - max_div =CLK_DIV_8 ; - clk = card_clock;if (!initial_mode && double_clk) clk = card_clock *2 ;
@@ -633,16 +628,16 @@ int rtsx_pci_switch_clock(struct rtsx_pcr *pcr, unsigned int card_clock, n = (u8 )pcr->ops->conv_clk_and_div_n (clk,CLK_TO_DIV_N ); else n = (u8)(clk -2 ); -if ((clk <=2 ) || (n > max_n)) +if ((clk <=2 ) || (n >MAX_DIV_N_PCR ))return -EINVAL ; mcu_cnt = (u8)(125 /clk +3 );if (mcu_cnt >15 ) mcu_cnt =15 ; -/* Make sure that the SSC clock div_n is equal or greater than min_n */ +/* Make sure that the SSC clock div_n is not less than MIN_DIV_N_PCR */ div =CLK_DIV_1 ; -while ((n < min_n) && (div < max_div)) { +while ((n <MIN_DIV_N_PCR ) && (div <CLK_DIV_8 )) {if (pcr->ops->conv_clk_and_div_n) {int dbl_clk = pcr->ops->conv_clk_and_div_n (n,DIV_N_TO_CLK ) *2 ;
drivers/mfd/rtsx_pcr.h +3 -0
@@ -25,6 +25,9 @@#include <linux/mfd/rtsx_pci.h> +#define MIN_DIV_N_PCR 80 +#define MAX_DIV_N_PCR 208 +void rts5209_init_params (struct rtsx_pcr *pcr);void rts5229_init_params (struct rtsx_pcr *pcr);void rtl8411_init_params (struct rtsx_pcr *pcr);
Signature · 1 line
1.7.9.5
Re: [PATCH v2 8/8] MFD:rtsx: Use macro defines to replace some variables
Quoted 8 lines · On Tue, Dec 25, 2012 at 10:43:40AM +0800, [email protected] wrote:
From: Wei WANG <[email protected]>
In function
rtsx_pci_switch_clock, some variables, such asmin_n,max_n, andmax_div, are not necessary. And those assigned values look very obscure for others. It's more proper to use macro definitions here to replace these variables.Signed-off-by Wei WANG <[email protected]>
Signature · 5 lines
Regards/Gruss,
Boris.
Sent from a fat crate under my desk. Formatting is fine.
--