Skip to contentSkip to conversation

phy: tusb1210: use bitmasks to set VENDOR_SPECIFIC2

PATCH Superseded Liam Beguin 3 participants 5 messages Jul 14, 2020 – Aug 5, 2020 1 message not in the archive Generic PHY framework

v2 of 5 Superseded Latest is v5 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 phy: tusb1210: use bitmasks to set VENDOR_SPECIFIC2

From: Liam Beguin <[email protected]>

Start by reading the content of the VENDOR_SPECIFIC2 register and update each bit field based on device properties when defined.

The use of bit masks prevents fields from overriding each other and enables users to clear bits which are set by default, like datapolarity in this instance.

---
 drivers/phy/ti/phy-tusb1210.c | 26 +++++++++++++-------------
 1 file changed, 13 insertions(+), 13 deletions(-)
drivers/phy/ti/phy-tusb1210.c +13 -13
index d8d0cc11d187..35baeb9deeee 100644
@@ -13,9 +13,9 @@
 #include <linux/phy/ulpi_phy.h>
 
 #define TUSB1210_VENDOR_SPECIFIC2		0x80
-#define TUSB1210_VENDOR_SPECIFIC2_IHSTX_SHIFT	0
-#define TUSB1210_VENDOR_SPECIFIC2_ZHSDRV_SHIFT	4
-#define TUSB1210_VENDOR_SPECIFIC2_DP_SHIFT	6
+#define TUSB1210_VENDOR_SPECIFIC2_IHSTX_MASK	GENMASK(3, 0)
+#define TUSB1210_VENDOR_SPECIFIC2_ZHSDRV_MASK	GENMASK(5, 4)
+#define TUSB1210_VENDOR_SPECIFIC2_DP_MASK	BIT(6)
 
 struct tusb1210 {
 	struct ulpi *ulpi;
@@ -118,22 +118,22 @@ static int tusb1210_probe(struct ulpi *ulpi)
 	 * diagram optimization and DP/DM swap.
 	 */
 
+	reg = ulpi_read(ulpi, TUSB1210_VENDOR_SPECIFIC2);
+
 	/* High speed output drive strength configuration */
-	device_property_read_u8(&ulpi->dev, "ihstx", &val);
-	reg = val << TUSB1210_VENDOR_SPECIFIC2_IHSTX_SHIFT;
+	if (!device_property_read_u8(&ulpi->dev, "ihstx", &val))
+		reg = set_mask_bits(&reg, TUSB1210_VENDOR_SPECIFIC2_IHSTX_MASK, val);
 
 	/* High speed output impedance configuration */
-	device_property_read_u8(&ulpi->dev, "zhsdrv", &val);
-	reg |= val << TUSB1210_VENDOR_SPECIFIC2_ZHSDRV_SHIFT;
+	if (!device_property_read_u8(&ulpi->dev, "zhsdrv", &val))
+		reg = set_mask_bits(&reg, TUSB1210_VENDOR_SPECIFIC2_ZHSDRV_MASK, val);
 
 	/* DP/DM swap control */
-	device_property_read_u8(&ulpi->dev, "datapolarity", &val);
-	reg |= val << TUSB1210_VENDOR_SPECIFIC2_DP_SHIFT;
+	if (!device_property_read_u8(&ulpi->dev, "datapolarity", &val))
+		reg = set_mask_bits(&reg, TUSB1210_VENDOR_SPECIFIC2_DP_MASK, val);
 
-	if (reg) {
-		ulpi_write(ulpi, TUSB1210_VENDOR_SPECIFIC2, reg);
-		tusb->vendor_specific2 = reg;
-	}
+	ulpi_write(ulpi, TUSB1210_VENDOR_SPECIFIC2, reg);
+	tusb->vendor_specific2 = reg;
 
 	tusb->phy = ulpi_phy_create(ulpi, &phy_ops);
 	if (IS_ERR(tusb->phy))

base-commit: 8f3d9f354286745c751374f5f1fcafee6b3f3136

Signature · 1 line
2.27.0
#1 lore raw
Thank you for the patch! Yet something to improve:

Hi Liam,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on 8f3d9f354286745c751374f5f1fcafee6b3f3136]

url:    https://github.com/0day-ci/linux/commits/Liam-Beguin/phy-tusb1210-use-bitmasks-to-set-VENDOR_SPECIFIC2/20200715-003517
base:    8f3d9f354286745c751374f5f1fcafee6b3f3136
config: parisc-allyesconfig (attached as .config)
compiler: hppa-linux-gcc (GCC) 9.3.0

reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross ARCH=parisc

If you fix the issue, kindly add following tag as appropriate

All errors (new ones prefixed by >>):

hppa-linux-ld: drivers/phy/ti/phy-tusb1210.o: in function `tusb1210_probe':

>> (.text+0x2f4): undefined reference to `__cmpxchg_called_with_bad_pointer'
>> hppa-linux-ld: (.text+0x324): undefined reference to `__cmpxchg_called_with_bad_pointer'

hppa-linux-ld: (.text+0x354): undefined reference to `__cmpxchg_called_with_bad_pointer'

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org

#2 lore raw
Quoted 17 lines · kernel test robot

Hi Liam,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on 8f3d9f354286745c751374f5f1fcafee6b3f3136]

url:    https://github.com/0day-ci/linux/commits/Liam-Beguin/phy-tusb1210-use-bitmasks-to-set-VENDOR_SPECIFIC2/20200715-003517
base:    8f3d9f354286745c751374f5f1fcafee6b3f3136
config: parisc-allyesconfig (attached as .config)
compiler: hppa-linux-gcc (GCC) 9.3.0

reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross ARCH=parisc

If you fix the issue, kindly add following tag as appropriate

Quoted 9 lines

All errors (new ones prefixed by >>):

   hppa-linux-ld: drivers/phy/ti/phy-tusb1210.o: in function `tusb1210_probe':
Quoted 2 lines
Quoted 2 lines

(.text+0x2f4): undefined reference to `__cmpxchg_called_with_bad_pointer'
hppa-linux-ld: (.text+0x324): undefined reference to `__cmpxchg_called_with_bad_pointer'

hppa-linux-ld: (.text+0x354): undefined reference to `__cmpxchg_called_with_bad_pointer'

Hi,

I sent another patch[1] to try to address this.

The issue seems to come from the fact that the parisc architecture doesn't support cmpxchg on u8 pointers. cmpxchg is called by set_mask_bits.

Thanks,
Liam

[1] https://lore.kernel.org/patchwork/patch/1272617/

Quoted 3 lines

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/[email protected]

#4 lore raw
In reply to a message not in the archive

Hi Vinod,

Quoted 10 lines · Liam Beguin

Hi,

I sent another patch[1] to try to address this.

The issue seems to come from the fact that the parisc architecture doesn't support cmpxchg on u8 pointers. cmpxchg is called by set_mask_bits.

This patch has been merged.

Quoted 8 lines

Thanks,
Liam

[1] https://lore.kernel.org/patchwork/patch/1272617/

Quoted 3 lines

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/[email protected]

Did you get a change to look at the initial tusb1210 patch?

Thanks,
Liam

maintainer
#5 lore raw

Hello Liam,

Quoted 7 lines · Liam Beguin

Hi Vinod,

Quoted 4 lines · Liam Beguin

Hi,

Quoted 8 lines
Quoted 6 lines

I sent another patch[1] to try to address this.

The issue seems to come from the fact that the parisc architecture doesn't support cmpxchg on u8 pointers. cmpxchg is called by set_mask_bits.

This patch has been merged.

Okay great

Quoted 11 lines
Quoted 9 lines

Thanks,
Liam

[1] https://lore.kernel.org/patchwork/patch/1272617/

Quoted 3 lines

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/[email protected]

Did you get a change to look at the initial tusb1210 patch?

Can you please repost after -rc1 is out and rebase on it

Thanks

Signature · 1 line
~Vinod