FILE
renesas-usb-vbus-regulator.c
File preview with syntax highlighting.
linux-6.19.14/drivers/regulator/renesas-usb-vbus-regulator.c
1// SPDX-License-Identifier: GPL-2.0 2// 3// Renesas USB VBUS output regulator driver 4// 5// Copyright (C) 2024 Renesas Electronics Corporation 6// 7 8#include <linux/module.h> 9#include <linux/err.h> 10#include <linux/of.h> 11#include <linux/platform_device.h> 12#include <linux/regmap.h> 13#include <linux/regulator/driver.h> 14 15static const struct regulator_ops rzg2l_usb_vbus_reg_ops = { 16 .enable = regulator_enable_regmap, 17 .disable = regulator_disable_regmap, 18 .is_enabled = regulator_is_enabled_regmap, 19}; 20 21static const struct regulator_desc rzg2l_usb_vbus_rdesc = { 22 .name = "vbus", 23 .of_match = of_match_ptr("regulator-vbus"), 24 .ops = &rzg2l_usb_vbus_reg_ops, 25 .type = REGULATOR_VOLTAGE, 26 .owner = THIS_MODULE, 27 .enable_reg = 0, 28 .enable_mask = BIT(0), 29 .enable_is_inverted = true, 30 .fixed_uV = 5000000, 31 .n_voltages = 1, 32}; 33 34static int rzg2l_usb_vbus_regulator_probe(struct platform_device *pdev) 35{ 36 struct regulator_config config = { }; 37 struct device *dev = &pdev->dev; 38 struct regulator_dev *rdev; 39 40 config.regmap = dev_get_regmap(dev->parent, NULL); 41 if (!config.regmap) 42 return dev_err_probe(dev, -ENOENT, "Failed to get regmap\n"); 43 44 config.dev = dev; 45 config.of_node = of_get_child_by_name(dev->parent->of_node, "regulator-vbus"); 46 if (!config.of_node) 47 return dev_err_probe(dev, -ENODEV, "regulator node not found\n"); 48 49 rdev = devm_regulator_register(dev, &rzg2l_usb_vbus_rdesc, &config); 50 of_node_put(config.of_node); 51 if (IS_ERR(rdev)) 52 return dev_err_probe(dev, PTR_ERR(rdev), 53 "not able to register vbus regulator\n"); 54 55 return 0; 56} 57 58static struct platform_driver rzg2l_usb_vbus_regulator_driver = { 59 .probe = rzg2l_usb_vbus_regulator_probe, 60 .driver = { 61 .name = "rzg2l-usb-vbus-regulator", 62 .probe_type = PROBE_PREFER_ASYNCHRONOUS, 63 }, 64}; 65module_platform_driver(rzg2l_usb_vbus_regulator_driver); 66 67MODULE_AUTHOR("Biju Das <biju.das.jz@bp.renesas.com>"); 68MODULE_DESCRIPTION("Renesas RZ/G2L USB Vbus Regulator Driver"); 69MODULE_LICENSE("GPL");
~/
Read-only file preview.