Skip to contentSkip to conversation

rtsx patchset for MFD and MMC tree

PATCH In review [email protected] 4 participants 17 messages Jan 8, 2013 – Jan 23, 2013

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

v4 cover rtsx patchset for MFD and MMC tree

From: Wei WANG <[email protected]>

v2:
1. Add commit message for patch 2
2. Move pci_set_dma_mask before the pci_enable_device(pcidev) call

v3:
1. Add commit message for patch 3
2. Add patch 8: Use macro defines to replace some variables

v4:
1. Describe why patch 3 is needed
2. Modify a comment character in patch 7

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
#1 lore raw

PATCH v4 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
index 060b721..bebe9f9 100644
@@ -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
#2 lore raw

PATCH v4 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
index 3a44efa..fa2c2bc 100644
@@ -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
#3 lore raw

PATCH v4 3/8 MFD:rtsx: Declare that the DMA address limitation is 32bit explicitly

In reply to [email protected]

From: Wei WANG <[email protected]>

Realtek PCIe card reader only supports 32bit DMA.
This declaration can improve the readability

---
 drivers/mfd/rtsx_pcr.c |    4 ++++
 1 file changed, 4 insertions(+)
drivers/mfd/rtsx_pcr.c +4 -0
index fa2c2bc..1dc64bb 100644
@@ -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
#4 lore raw

PATCH v4 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
index 89f046c..5058ba8 100644
@@ -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
index 283a4f1..ba74de8 100644
@@ -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
index b9dbab2..ec1747a 100644
@@ -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
index 1dc64bb..99e12b8 100644
@@ -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
index bebe9f9..2e3e2e0 100644
@@ -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
#5 lore raw

PATCH v4 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
index 571915d..f74b5ad 100644
@@ -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
#6 lore raw

PATCH v4 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
index 5058ba8..3d3b4ad 100644
@@ -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
index ba74de8..98fe0f3 100644
@@ -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
index ec1747a..29d889c 100644
@@ -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
index 99e12b8..958b738 100644
@@ -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
index a8d393e..2b13970 100644
@@ -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
index 2e3e2e0..3f2bf26 100644
@@ -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
#7 lore raw

PATCH v4 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
index 958b738..69e8a1e 100644
@@ -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
#8 lore raw

PATCH v4 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
index 69e8a1e..ccdb026 100644
@@ -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
index 12462c1..33c210b 100644
@@ -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
author
#9 lore raw
In reply to [email protected]
Quoted 24 lines · 王炜

From: Wei WANG <[email protected]>

v2:
1. Add commit message for patch 2
2. Move pci_set_dma_mask before the pci_enable_device(pcidev) call

v3:
1. Add commit message for patch 3
2. Add patch 8: Use macro defines to replace some variables

v4:
1. Describe why patch 3 is needed
2. Modify a comment character in patch 7

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

Quoted 10 lines
 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(-)

Hi Chris and Samuel:

This patchset is trying to fix some bugs and some coding style issues. Would you please help to merge it to v3.8 kernel?

BR,
Wei WANG
_______________________________________________
devel mailing list
[email protected]
http://driverdev.linuxdriverproject.org/mailman/listinfo/devel

#10 lore raw

Hi Wei,

Quoted 35 lines · wwang
Quoted 24 lines · 王炜

From: Wei WANG <[email protected]>

v2:
1. Add commit message for patch 2
2. Move pci_set_dma_mask before the pci_enable_device(pcidev) call

v3:
1. Add commit message for patch 3
2. Add patch 8: Use macro defines to replace some variables

v4:
1. Describe why patch 3 is needed
2. Modify a comment character in patch 7

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

Quoted 10 lines
 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(-)
Quoted 4 lines

Hi Chris and Samuel:

This patchset is trying to fix some bugs and some coding style issues. Would you please help to merge it to v3.8 kernel?

I'll only take bug fixes for 3.8, even minor ones, and I don't see real bug fixes here. Am I missing something ?

Cheers,
Samuel.

Signature · 2 lines
Intel Open Source Technology Centre
http://oss.intel.com/
author
#11 lore raw
Quoted 40 lines · Samuel Ortiz

Hi Wei,

Quoted 37 lines · wwang
Quoted 24 lines · 王炜

From: Wei WANG <[email protected]>

v2:
1. Add commit message for patch 2
2. Move pci_set_dma_mask before the pci_enable_device(pcidev) call

v3:
1. Add commit message for patch 3
2. Add patch 8: Use macro defines to replace some variables

v4:
1. Describe why patch 3 is needed
2. Modify a comment character in patch 7

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

Quoted 10 lines
  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(-)

Hi Chris and Samuel:

Quoted 8 lines
Quoted 2 lines

This patchset is trying to fix some bugs and some coding style issues. Would you please help to merge it to v3.8 kernel?

I'll only take bug fixes for 3.8, even minor ones, and I don't see real bug fixes here. Am I missing something ?

Cheers,
Samuel.

Hi Samuel:

The commits below are all bug fix ( fix rtl8411 specifically)

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

The other commits are for coding style issues

BR,
Wei WANG

#12 lore raw
Quoted 30 lines · wwang
Quoted 22 lines
Quoted 22 lines
Quoted 10 lines

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

Quoted 10 lines
 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(-)

Hi Chris and Samuel:

Quoted 8 lines
Quoted 2 lines

This patchset is trying to fix some bugs and some coding style issues. Would you please help to merge it to v3.8 kernel?

I'll only take bug fixes for 3.8, even minor ones, and I don't see real bug fixes here. Am I missing something ?

Cheers,
Samuel.

Quoted 7 lines

Hi Samuel:

The commits below are all bug fix ( fix rtl8411 specifically)

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

Would you mind building a separate patchset for those 3, against e.g. a vanilla 3.8-rc4 kernel ? Otherwise they won't apply cleanly against my for-linus tree.

Cheers,
Samuel.

Signature · 2 lines
Intel Open Source Technology Centre
http://oss.intel.com/
#13 lore raw
Quoted 38 lines · Samuel Ortiz
Quoted 30 lines · wwang
Quoted 22 lines
Quoted 22 lines
Quoted 10 lines

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

Quoted 10 lines
 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(-)

Hi Chris and Samuel:

Quoted 8 lines
Quoted 2 lines

This patchset is trying to fix some bugs and some coding style issues. Would you please help to merge it to v3.8 kernel?

I'll only take bug fixes for 3.8, even minor ones, and I don't see real bug fixes here. Am I missing something ?

Cheers,
Samuel.

Quoted 7 lines

Hi Samuel:

The commits below are all bug fix ( fix rtl8411 specifically)

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

Quoted 7 lines

Would you mind building a separate patchset for those 3, against e.g. a vanilla 3.8-rc4 kernel ? Otherwise they won't apply cleanly against my for-linus tree.

Cheers,
Samuel.

Hi Samuel:

Sure. I will do it.
Does it mean that the other commits only can be submitted to 3.9-rc?

BR,
Wei WANG

author
#14 lore raw
Quoted 46 lines · pclinux
Quoted 38 lines · Samuel Ortiz
Quoted 30 lines · wwang
Quoted 22 lines
Quoted 22 lines
Quoted 10 lines

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

Quoted 10 lines
 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(-)

Hi Chris and Samuel:

Quoted 8 lines
Quoted 2 lines

This patchset is trying to fix some bugs and some coding style issues. Would you please help to merge it to v3.8 kernel?

I'll only take bug fixes for 3.8, even minor ones, and I don't see real bug fixes here. Am I missing something ?

Cheers,
Samuel.

Quoted 7 lines

Hi Samuel:

The commits below are all bug fix ( fix rtl8411 specifically)

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

Quoted 7 lines

Would you mind building a separate patchset for those 3, against e.g. a vanilla 3.8-rc4 kernel ? Otherwise they won't apply cleanly against my for-linus tree.

Cheers,
Samuel.

Quoted 7 lines

Hi Samuel:

Sure. I will do it.
Does it mean that the other commits only can be submitted to 3.9-rc?

BR,
Wei WANG

Hi Samuel:

Sorry, pclinux is also me. I always mess the two mail accounts up. I would like to repeat my question. Does it mean that the other commits only can be submitted to 3.9-rc?

BR,
Wei WANG

#15 lore raw

Hi Wei,

Quoted 5 lines · wwang

Hi Samuel:

Sorry, pclinux is also me. I always mess the two mail accounts up. I would like to repeat my question. Does it mean that the other commits only can be submitted to 3.9-rc?

Yes, that's how I prefer to handle it.

Cheers,
Samuel.

Signature · 2 lines
Intel Open Source Technology Centre
http://oss.intel.com/
#16 lore raw
In reply to pclinux
Quoted 3 lines · pclinux

Sure. I will do it.
Does it mean that the other commits only can be submitted to 3.9-rc?

Submit them now. They stay in Samuel's tree and are tested in linux-next until 3.8 is released. Then Samuel submits them during the 3.9 merge window.

The merge window is for Samuel => Linus, it's not for you => Samuel. If your code has not reached Samuel's tree before 3.8 has been released then it's too late and it will be delayed for another few months.

regards,
dan carpenter