Linux kernel and device drivers for NXP i.MX platforms
 help / color / mirror / Atom feed
From: kernel test robot <lkp@intel.com>
To: Xu Yang <xu.yang_2@nxp.com>,
	krzk@kernel.org, myungjoo.ham@samsung.com, cw00.choi@samsung.com,
	robh@kernel.org, conor+dt@kernel.org
Cc: oe-kbuild-all@lists.linux.dev, devicetree@vger.kernel.org,
	imx@lists.linux.dev, jun.li@nxp.com
Subject: Re: [PATCH 2/3] extcon: ptn5150: Add Type-C orientation switch support
Date: Thu, 17 Apr 2025 21:20:47 +0800	[thread overview]
Message-ID: <202504172148.DEw1gGPg-lkp@intel.com> (raw)
In-Reply-To: <20250416105940.1572672-2-xu.yang_2@nxp.com>

Hi Xu,

kernel test robot noticed the following build errors:

[auto build test ERROR on krzk-dt/for-next]
[also build test ERROR on linus/master v6.15-rc2 next-20250417]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Xu-Yang/extcon-ptn5150-Add-Type-C-orientation-switch-support/20250416-185917
base:   https://git.kernel.org/pub/scm/linux/kernel/git/krzk/linux-dt.git for-next
patch link:    https://lore.kernel.org/r/20250416105940.1572672-2-xu.yang_2%40nxp.com
patch subject: [PATCH 2/3] extcon: ptn5150: Add Type-C orientation switch support
config: parisc-randconfig-001-20250417 (https://download.01.org/0day-ci/archive/20250417/202504172148.DEw1gGPg-lkp@intel.com/config)
compiler: hppa-linux-gcc (GCC) 12.4.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20250417/202504172148.DEw1gGPg-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202504172148.DEw1gGPg-lkp@intel.com/

All errors (new ones prefixed by >>):

   hppa-linux-ld: drivers/extcon/extcon-ptn5150.o: in function `ptn5150_work_sync_and_put':
>> drivers/extcon/extcon-ptn5150.c:252:(.text+0x20): undefined reference to `typec_switch_put'
   hppa-linux-ld: drivers/extcon/extcon-ptn5150.o: in function `ptn5150_check_state':
>> drivers/extcon/extcon-ptn5150.c:104:(.text+0x94): undefined reference to `typec_switch_set'
   hppa-linux-ld: drivers/extcon/extcon-ptn5150.o: in function `ptn5150_irq_work':
   drivers/extcon/extcon-ptn5150.c:180:(.text+0x29c): undefined reference to `typec_switch_set'
   hppa-linux-ld: drivers/extcon/extcon-ptn5150.o: in function `ptn5150_i2c_probe':
>> drivers/extcon/extcon-ptn5150.c:348:(.text+0x618): undefined reference to `fwnode_typec_switch_get'


vim +252 drivers/extcon/extcon-ptn5150.c

    77	
    78	static void ptn5150_check_state(struct ptn5150_info *info)
    79	{
    80		unsigned int port_status, reg_data, vbus;
    81		enum typec_orientation orient = TYPEC_ORIENTATION_NONE;
    82		enum usb_role usb_role = USB_ROLE_NONE;
    83		int ret;
    84	
    85		ret = regmap_read(info->regmap, PTN5150_REG_CC_STATUS, &reg_data);
    86		if (ret) {
    87			dev_err(info->dev, "failed to read CC STATUS %d\n", ret);
    88			return;
    89		}
    90	
    91		orient = FIELD_GET(PTN5150_REG_CC_POLARITY, reg_data);
    92		switch (orient) {
    93		case PTN5150_POLARITY_CC1:
    94			orient = TYPEC_ORIENTATION_NORMAL;
    95			break;
    96		case PTN5150_POLARITY_CC2:
    97			orient = TYPEC_ORIENTATION_REVERSE;
    98			break;
    99		default:
   100			orient = TYPEC_ORIENTATION_NONE;
   101			break;
   102		}
   103	
 > 104		ret = typec_switch_set(info->orient_sw, orient);
   105		if (ret)
   106			dev_err(info->dev, "failed to set orientation: %d\n", ret);
   107	
   108		port_status = FIELD_GET(PTN5150_REG_CC_PORT_ATTACHMENT, reg_data);
   109	
   110		switch (port_status) {
   111		case PTN5150_DFP_ATTACHED:
   112			extcon_set_state_sync(info->edev, EXTCON_USB_HOST, false);
   113			gpiod_set_value_cansleep(info->vbus_gpiod, 0);
   114			extcon_set_state_sync(info->edev, EXTCON_USB, true);
   115			usb_role = USB_ROLE_DEVICE;
   116			break;
   117		case PTN5150_UFP_ATTACHED:
   118			extcon_set_state_sync(info->edev, EXTCON_USB, false);
   119			vbus = FIELD_GET(PTN5150_REG_CC_VBUS_DETECTION, reg_data);
   120			if (vbus)
   121				gpiod_set_value_cansleep(info->vbus_gpiod, 0);
   122			else
   123				gpiod_set_value_cansleep(info->vbus_gpiod, 1);
   124	
   125			extcon_set_state_sync(info->edev, EXTCON_USB_HOST, true);
   126			usb_role = USB_ROLE_HOST;
   127			break;
   128		default:
   129			break;
   130		}
   131	
   132		if (usb_role) {
   133			ret = usb_role_switch_set_role(info->role_sw, usb_role);
   134			if (ret)
   135				dev_err(info->dev, "failed to set %s role: %d\n",
   136					usb_role_string(usb_role), ret);
   137		}
   138	}
   139	
   140	static void ptn5150_irq_work(struct work_struct *work)
   141	{
   142		struct ptn5150_info *info = container_of(work,
   143				struct ptn5150_info, irq_work);
   144		int ret = 0;
   145		unsigned int int_status;
   146	
   147		if (!info->edev)
   148			return;
   149	
   150		mutex_lock(&info->mutex);
   151	
   152		/* Clear interrupt. Read would clear the register */
   153		ret = regmap_read(info->regmap, PTN5150_REG_INT_STATUS, &int_status);
   154		if (ret) {
   155			dev_err(info->dev, "failed to read INT STATUS %d\n", ret);
   156			mutex_unlock(&info->mutex);
   157			return;
   158		}
   159	
   160		if (int_status) {
   161			unsigned int cable_attach;
   162	
   163			cable_attach = int_status & PTN5150_REG_INT_CABLE_ATTACH_MASK;
   164			if (cable_attach) {
   165				ptn5150_check_state(info);
   166			} else {
   167				extcon_set_state_sync(info->edev,
   168						EXTCON_USB_HOST, false);
   169				extcon_set_state_sync(info->edev,
   170						EXTCON_USB, false);
   171				gpiod_set_value_cansleep(info->vbus_gpiod, 0);
   172	
   173				ret = usb_role_switch_set_role(info->role_sw,
   174							       USB_ROLE_NONE);
   175				if (ret)
   176					dev_err(info->dev,
   177						"failed to set none role: %d\n",
   178						ret);
   179	
   180				ret = typec_switch_set(info->orient_sw,
   181						       TYPEC_ORIENTATION_NONE);
   182				if (ret)
   183					dev_err(info->dev,
   184						"failed to set orientation: %d\n", ret);
   185			}
   186		}
   187	
   188		/* Clear interrupt. Read would clear the register */
   189		ret = regmap_read(info->regmap, PTN5150_REG_INT_REG_STATUS,
   190				&int_status);
   191		if (ret) {
   192			dev_err(info->dev,
   193				"failed to read INT REG STATUS %d\n", ret);
   194			mutex_unlock(&info->mutex);
   195			return;
   196		}
   197	
   198		mutex_unlock(&info->mutex);
   199	}
   200	
   201	
   202	static irqreturn_t ptn5150_irq_handler(int irq, void *data)
   203	{
   204		struct ptn5150_info *info = data;
   205	
   206		schedule_work(&info->irq_work);
   207	
   208		return IRQ_HANDLED;
   209	}
   210	
   211	static int ptn5150_init_dev_type(struct ptn5150_info *info)
   212	{
   213		unsigned int reg_data, vendor_id, version_id;
   214		int ret;
   215	
   216		ret = regmap_read(info->regmap, PTN5150_REG_DEVICE_ID, &reg_data);
   217		if (ret) {
   218			dev_err(info->dev, "failed to read DEVICE_ID %d\n", ret);
   219			return -EINVAL;
   220		}
   221	
   222		vendor_id = FIELD_GET(PTN5150_REG_DEVICE_ID_VENDOR, reg_data);
   223		version_id = FIELD_GET(PTN5150_REG_DEVICE_ID_VERSION, reg_data);
   224		dev_dbg(info->dev, "Device type: version: 0x%x, vendor: 0x%x\n",
   225			version_id, vendor_id);
   226	
   227		/* Clear any existing interrupts */
   228		ret = regmap_read(info->regmap, PTN5150_REG_INT_STATUS, &reg_data);
   229		if (ret) {
   230			dev_err(info->dev,
   231				"failed to read PTN5150_REG_INT_STATUS %d\n",
   232				ret);
   233			return -EINVAL;
   234		}
   235	
   236		ret = regmap_read(info->regmap, PTN5150_REG_INT_REG_STATUS, &reg_data);
   237		if (ret) {
   238			dev_err(info->dev,
   239				"failed to read PTN5150_REG_INT_REG_STATUS %d\n", ret);
   240			return -EINVAL;
   241		}
   242	
   243		return 0;
   244	}
   245	
   246	static void ptn5150_work_sync_and_put(void *data)
   247	{
   248		struct ptn5150_info *info = data;
   249	
   250		cancel_work_sync(&info->irq_work);
   251		usb_role_switch_put(info->role_sw);
 > 252		typec_switch_put(info->orient_sw);
   253	}
   254	
   255	static int ptn5150_i2c_probe(struct i2c_client *i2c)
   256	{
   257		struct device *dev = &i2c->dev;
   258		struct device_node *np = i2c->dev.of_node;
   259		struct fwnode_handle *connector;
   260		struct ptn5150_info *info;
   261		int ret;
   262	
   263		if (!np)
   264			return -EINVAL;
   265	
   266		info = devm_kzalloc(&i2c->dev, sizeof(*info), GFP_KERNEL);
   267		if (!info)
   268			return -ENOMEM;
   269		i2c_set_clientdata(i2c, info);
   270	
   271		info->dev = &i2c->dev;
   272		info->i2c = i2c;
   273		info->vbus_gpiod = devm_gpiod_get(&i2c->dev, "vbus", GPIOD_OUT_LOW);
   274		if (IS_ERR(info->vbus_gpiod)) {
   275			ret = PTR_ERR(info->vbus_gpiod);
   276			if (ret == -ENOENT) {
   277				dev_info(dev, "No VBUS GPIO, ignoring VBUS control\n");
   278				info->vbus_gpiod = NULL;
   279			} else {
   280				return dev_err_probe(dev, ret, "failed to get VBUS GPIO\n");
   281			}
   282		}
   283	
   284		mutex_init(&info->mutex);
   285	
   286		INIT_WORK(&info->irq_work, ptn5150_irq_work);
   287	
   288		info->regmap = devm_regmap_init_i2c(i2c, &ptn5150_regmap_config);
   289		if (IS_ERR(info->regmap)) {
   290			return dev_err_probe(info->dev, PTR_ERR(info->regmap),
   291					     "failed to allocate register map\n");
   292		}
   293	
   294		if (i2c->irq > 0) {
   295			info->irq = i2c->irq;
   296		} else {
   297			info->int_gpiod = devm_gpiod_get(&i2c->dev, "int", GPIOD_IN);
   298			if (IS_ERR(info->int_gpiod)) {
   299				return dev_err_probe(dev, PTR_ERR(info->int_gpiod),
   300						     "failed to get INT GPIO\n");
   301			}
   302	
   303			info->irq = gpiod_to_irq(info->int_gpiod);
   304			if (info->irq < 0) {
   305				dev_err(dev, "failed to get INTB IRQ\n");
   306				return info->irq;
   307			}
   308		}
   309	
   310		ret = devm_request_threaded_irq(dev, info->irq, NULL,
   311						ptn5150_irq_handler,
   312						IRQF_TRIGGER_FALLING |
   313						IRQF_ONESHOT,
   314						i2c->name, info);
   315		if (ret < 0) {
   316			dev_err(dev, "failed to request handler for INTB IRQ\n");
   317			return ret;
   318		}
   319	
   320		/* Allocate extcon device */
   321		info->edev = devm_extcon_dev_allocate(info->dev, ptn5150_extcon_cable);
   322		if (IS_ERR(info->edev)) {
   323			dev_err(info->dev, "failed to allocate memory for extcon\n");
   324			return -ENOMEM;
   325		}
   326	
   327		/* Register extcon device */
   328		ret = devm_extcon_dev_register(info->dev, info->edev);
   329		if (ret) {
   330			dev_err(info->dev, "failed to register extcon device\n");
   331			return ret;
   332		}
   333	
   334		extcon_set_property_capability(info->edev, EXTCON_USB,
   335						EXTCON_PROP_USB_VBUS);
   336		extcon_set_property_capability(info->edev, EXTCON_USB_HOST,
   337						EXTCON_PROP_USB_VBUS);
   338		extcon_set_property_capability(info->edev, EXTCON_USB_HOST,
   339						EXTCON_PROP_USB_TYPEC_POLARITY);
   340	
   341		/* Initialize PTN5150 device and print vendor id and version id */
   342		ret = ptn5150_init_dev_type(info);
   343		if (ret)
   344			return -EINVAL;
   345	
   346		connector = device_get_named_child_node(dev, "connector");
   347		if (connector) {
 > 348			info->orient_sw = fwnode_typec_switch_get(connector);
   349			if (IS_ERR(info->orient_sw))
   350				return dev_err_probe(info->dev, PTR_ERR(info->orient_sw),
   351						"failed to get orientation switch\n");
   352		}
   353	
   354		info->role_sw = usb_role_switch_get(info->dev);
   355		if (IS_ERR(info->role_sw))
   356			return dev_err_probe(info->dev, PTR_ERR(info->role_sw),
   357					     "failed to get role switch\n");
   358	
   359		ret = devm_add_action_or_reset(dev, ptn5150_work_sync_and_put, info);
   360		if (ret)
   361			return ret;
   362	
   363		/*
   364		 * Update current extcon state if for example OTG connection was there
   365		 * before the probe
   366		 */
   367		mutex_lock(&info->mutex);
   368		ptn5150_check_state(info);
   369		mutex_unlock(&info->mutex);
   370	
   371		return 0;
   372	}
   373	

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki

  parent reply	other threads:[~2025-04-17 13:21 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-04-16 10:59 [PATCH 1/3] dt-bindings: extcon: ptn5150: Allow "connector" node to present Xu Yang
2025-04-16 10:59 ` [PATCH 2/3] extcon: ptn5150: Add Type-C orientation switch support Xu Yang
2025-04-16 14:33   ` Frank Li
2025-04-17  2:16     ` Xu Yang
2025-04-17 12:38   ` kernel test robot
2025-04-17 13:20   ` kernel test robot [this message]
2025-04-16 10:59 ` [PATCH 3/3] extcon: ptn5150: Try to get usb role switch from connector fwnode Xu Yang
2025-04-16 14:37   ` Frank Li
2025-04-17  2:24     ` Xu Yang
2025-04-17 14:34       ` Frank Li
2025-04-16 14:23 ` [PATCH 1/3] dt-bindings: extcon: ptn5150: Allow "connector" node to present Frank Li
2025-04-17  1:53   ` Xu Yang
2025-04-22 12:19 ` Rob Herring (Arm)

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=202504172148.DEw1gGPg-lkp@intel.com \
    --to=lkp@intel.com \
    --cc=conor+dt@kernel.org \
    --cc=cw00.choi@samsung.com \
    --cc=devicetree@vger.kernel.org \
    --cc=imx@lists.linux.dev \
    --cc=jun.li@nxp.com \
    --cc=krzk@kernel.org \
    --cc=myungjoo.ham@samsung.com \
    --cc=oe-kbuild-all@lists.linux.dev \
    --cc=robh@kernel.org \
    --cc=xu.yang_2@nxp.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox