Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 349310
b: refs/heads/master
c: ab4e8f8
h: refs/heads/master
v: v3
  • Loading branch information
Wei WANG authored and Samuel Ortiz committed Jan 27, 2013
1 parent 7b10058 commit a37a5aa
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 3 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: ef85e736b1052d8c1e56990f0d08b6fce7cdbe41
refs/heads/master: ab4e8f8b7bdfeff0c961fdbbdacb262d68f094c0
13 changes: 13 additions & 0 deletions trunk/drivers/mfd/rtl8411.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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:
Expand Down
1 change: 1 addition & 0 deletions trunk/drivers/mfd/rts5209.c
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
1 change: 1 addition & 0 deletions trunk/drivers/mfd/rts5229.c
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
14 changes: 12 additions & 2 deletions trunk/drivers/mfd/rtsx_pcr.c
Original file line number Diff line number Diff line change
Expand Up @@ -630,7 +630,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;

Expand All @@ -641,7 +644,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);
Expand Down
3 changes: 3 additions & 0 deletions trunk/include/linux/mfd/rtsx_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
1 change: 1 addition & 0 deletions trunk/include/linux/mfd/rtsx_pci.h
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down

0 comments on commit a37a5aa

Please sign in to comment.