Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge tag 'extcon-next-for-7.1' of ssh://gitolite.kernel.org/pub/scm/linux/kernel/git/chanwoo/extcon into char-misc-next

Chanwoo writes:

Update extcon next for v7.1

Detailed description for this pull request:
- Fix sysfs duplicate filename issue on extcon core
: Adjust ida_free timing after device_unregister
to prevent duplicate filename error when re-allocating id

- Update NXP PTN5150 extcon driver and dt-binding document
: Handle pending IRQ events during system resume
: Allow "connector" node to present in devicetree
: Add Type-C orientation switch support to correctly
set orientation of multiplexer according to CC status
: Support USB role switch via connector fwnode

- Replace use of system_wq with system_percpu_wq on int3496 driver

- Make typec-power-opmode optional on usbc-tusb320 driver
: Prevent probe error when usb-c connector is configured
in the DT without "typec-power-opmode" property

* tag 'extcon-next-for-7.1' of ssh://gitolite.kernel.org/pub/scm/linux/kernel/git/chanwoo/extcon:
extcon: usbc-tusb320: Make typec-power-opmode optional
extcon: ptn5150: Support USB role switch via connector fwnode
extcon: ptn5150: Add Type-C orientation switch support
dt-bindings: extcon: ptn5150: Allow "connector" node to present
extcon: Fixed sysfs duplicate filename issue
extcon: int3496: replace use of system_wq with system_percpu_wq
extcon: ptn5150: handle pending IRQ events during system resume

+75 -17
+3
Documentation/devicetree/bindings/extcon/extcon-ptn5150.yaml
··· 42 42 description: 43 43 A port node to link the usb controller for the dual role switch. 44 44 45 + connector: 46 + $ref: /schemas/connector/usb-connector.yaml# 47 + 45 48 required: 46 49 - compatible 47 50 - interrupts
+1
drivers/extcon/Kconfig
··· 158 158 tristate "NXP PTN5150 CC LOGIC USB EXTCON support" 159 159 depends on I2C && (GPIOLIB || COMPILE_TEST) 160 160 depends on USB_ROLE_SWITCH || !USB_ROLE_SWITCH 161 + depends on TYPEC || !TYPEC 161 162 select REGMAP_I2C 162 163 help 163 164 Say Y here to enable support for USB peripheral and USB host
+2 -2
drivers/extcon/extcon-intel-int3496.c
··· 106 106 struct int3496_data *data = priv; 107 107 108 108 /* Let the pin settle before processing it */ 109 - mod_delayed_work(system_wq, &data->work, DEBOUNCE_TIME); 109 + mod_delayed_work(system_percpu_wq, &data->work, DEBOUNCE_TIME); 110 110 111 111 return IRQ_HANDLED; 112 112 } ··· 181 181 } 182 182 183 183 /* process id-pin so that we start with the right status */ 184 - queue_delayed_work(system_wq, &data->work, 0); 184 + queue_delayed_work(system_percpu_wq, &data->work, 0); 185 185 flush_delayed_work(&data->work); 186 186 187 187 platform_set_drvdata(pdev, data);
+56
drivers/extcon/extcon-ptn5150.c
··· 18 18 #include <linux/extcon-provider.h> 19 19 #include <linux/gpio/consumer.h> 20 20 #include <linux/usb/role.h> 21 + #include <linux/usb/typec_mux.h> 21 22 22 23 /* PTN5150 registers */ 23 24 #define PTN5150_REG_DEVICE_ID 0x01 ··· 39 38 #define PTN5150_REG_DEVICE_ID_VERSION GENMASK(7, 3) 40 39 #define PTN5150_REG_DEVICE_ID_VENDOR GENMASK(2, 0) 41 40 41 + #define PTN5150_POLARITY_CC1 0x1 42 + #define PTN5150_POLARITY_CC2 0x2 43 + 42 44 #define PTN5150_REG_CC_PORT_ATTACHMENT GENMASK(4, 2) 45 + #define PTN5150_REG_CC_POLARITY GENMASK(1, 0) 43 46 #define PTN5150_REG_CC_VBUS_DETECTION BIT(7) 44 47 #define PTN5150_REG_INT_CABLE_ATTACH_MASK BIT(0) 45 48 #define PTN5150_REG_INT_CABLE_DETACH_MASK BIT(1) ··· 58 53 int irq; 59 54 struct work_struct irq_work; 60 55 struct mutex mutex; 56 + struct typec_switch *orient_sw; 61 57 struct usb_role_switch *role_sw; 62 58 }; 63 59 ··· 77 71 78 72 static void ptn5150_check_state(struct ptn5150_info *info) 79 73 { 74 + enum typec_orientation orient = TYPEC_ORIENTATION_NONE; 80 75 unsigned int port_status, reg_data, vbus; 81 76 enum usb_role usb_role = USB_ROLE_NONE; 82 77 int ret; ··· 87 80 dev_err(info->dev, "failed to read CC STATUS %d\n", ret); 88 81 return; 89 82 } 83 + 84 + orient = FIELD_GET(PTN5150_REG_CC_POLARITY, reg_data); 85 + switch (orient) { 86 + case PTN5150_POLARITY_CC1: 87 + orient = TYPEC_ORIENTATION_NORMAL; 88 + break; 89 + case PTN5150_POLARITY_CC2: 90 + orient = TYPEC_ORIENTATION_REVERSE; 91 + break; 92 + default: 93 + orient = TYPEC_ORIENTATION_NONE; 94 + break; 95 + } 96 + 97 + ret = typec_switch_set(info->orient_sw, orient); 98 + if (ret) 99 + dev_err(info->dev, "failed to set orientation: %d\n", ret); 90 100 91 101 port_status = FIELD_GET(PTN5150_REG_CC_PORT_ATTACHMENT, reg_data); 92 102 ··· 176 152 dev_err(info->dev, 177 153 "failed to set none role: %d\n", 178 154 ret); 155 + 156 + ret = typec_switch_set(info->orient_sw, 157 + TYPEC_ORIENTATION_NONE); 158 + if (ret) 159 + dev_err(info->dev, 160 + "failed to set orientation: %d\n", ret); 179 161 } 180 162 } 181 163 ··· 249 219 250 220 cancel_work_sync(&info->irq_work); 251 221 usb_role_switch_put(info->role_sw); 222 + typec_switch_put(info->orient_sw); 252 223 } 253 224 254 225 static int ptn5150_i2c_probe(struct i2c_client *i2c) 255 226 { 256 227 struct device *dev = &i2c->dev; 257 228 struct device_node *np = i2c->dev.of_node; 229 + struct fwnode_handle *connector; 258 230 struct ptn5150_info *info; 259 231 int ret; 260 232 ··· 343 311 if (ret) 344 312 return -EINVAL; 345 313 314 + connector = device_get_named_child_node(dev, "connector"); 315 + if (connector) { 316 + info->orient_sw = fwnode_typec_switch_get(connector); 317 + if (IS_ERR(info->orient_sw)) 318 + return dev_err_probe(info->dev, PTR_ERR(info->orient_sw), 319 + "failed to get orientation switch\n"); 320 + } 321 + 346 322 info->role_sw = usb_role_switch_get(info->dev); 323 + if (!info->role_sw && connector) 324 + info->role_sw = fwnode_usb_role_switch_get(connector); 347 325 if (IS_ERR(info->role_sw)) 348 326 return dev_err_probe(info->dev, PTR_ERR(info->role_sw), 349 327 "failed to get role switch\n"); ··· 373 331 return 0; 374 332 } 375 333 334 + static int ptn5150_resume(struct device *dev) 335 + { 336 + struct i2c_client *i2c = to_i2c_client(dev); 337 + struct ptn5150_info *info = i2c_get_clientdata(i2c); 338 + 339 + /* Need to check possible pending interrupt events */ 340 + schedule_work(&info->irq_work); 341 + 342 + return 0; 343 + } 344 + 345 + static DEFINE_SIMPLE_DEV_PM_OPS(ptn5150_pm_ops, NULL, ptn5150_resume); 346 + 376 347 static const struct of_device_id ptn5150_dt_match[] = { 377 348 { .compatible = "nxp,ptn5150" }, 378 349 { }, ··· 401 346 static struct i2c_driver ptn5150_i2c_driver = { 402 347 .driver = { 403 348 .name = "ptn5150", 349 + .pm = pm_sleep_ptr(&ptn5150_pm_ops), 404 350 .of_match_table = ptn5150_dt_match, 405 351 }, 406 352 .probe = ptn5150_i2c_probe,
+11 -13
drivers/extcon/extcon-usbc-tusb320.c
··· 454 454 priv->port_type = priv->cap.type; 455 455 456 456 /* This goes into register 0x8 field CURRENT_MODE_ADVERTISE */ 457 - ret = fwnode_property_read_string(connector, "typec-power-opmode", &cap_str); 458 - if (ret) 459 - goto err_put; 457 + if (!fwnode_property_read_string(connector, "typec-power-opmode", 458 + &cap_str)) { 459 + ret = typec_find_pwr_opmode(cap_str); 460 + if (ret < 0) 461 + goto err_put; 462 + priv->pwr_opmode = ret; 460 463 461 - ret = typec_find_pwr_opmode(cap_str); 462 - if (ret < 0) 463 - goto err_put; 464 - 465 - priv->pwr_opmode = ret; 466 - 467 - /* Initialize the hardware with the devicetree settings. */ 468 - ret = tusb320_set_adv_pwr_mode(priv); 469 - if (ret) 470 - goto err_put; 464 + /* Initialize the hardware with the devicetree settings. */ 465 + ret = tusb320_set_adv_pwr_mode(priv); 466 + if (ret) 467 + goto err_put; 468 + } 471 469 472 470 priv->cap.revision = USB_TYPEC_REV_1_1; 473 471 priv->cap.accessory[0] = TYPEC_ACCESSORY_AUDIO;
+2 -2
drivers/extcon/extcon.c
··· 1366 1366 return; 1367 1367 } 1368 1368 1369 - ida_free(&extcon_dev_ids, edev->id); 1370 - 1371 1369 device_unregister(&edev->dev); 1370 + 1371 + ida_free(&extcon_dev_ids, edev->id); 1372 1372 1373 1373 if (edev->mutually_exclusive && edev->max_supported) { 1374 1374 for (index = 0; edev->mutually_exclusive[index];