Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  1) // SPDX-License-Identifier: GPL-2.0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  2) //
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  3) // sky81452-regulator.c	SKY81452 regulator driver
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  4) //
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  5) // Copyright 2014 Skyworks Solutions Inc.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  6) // Author : Gyungoh Yoo <jack.yoo@skyworksinc.com>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  7) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  8) #include <linux/module.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  9) #include <linux/kernel.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) #include <linux/platform_device.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) #include <linux/init.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) #include <linux/err.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) #include <linux/of.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) #include <linux/regulator/driver.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) #include <linux/regulator/of_regulator.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) /* registers */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) #define SKY81452_REG1	0x01
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) #define SKY81452_REG3	0x03
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) /* bit mask */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) #define SKY81452_LEN	0x40
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) #define SKY81452_LOUT	0x1F
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) static const struct regulator_ops sky81452_reg_ops = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) 	.list_voltage = regulator_list_voltage_linear_range,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) 	.map_voltage = regulator_map_voltage_linear_range,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) 	.get_voltage_sel = regulator_get_voltage_sel_regmap,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) 	.set_voltage_sel = regulator_set_voltage_sel_regmap,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) 	.enable = regulator_enable_regmap,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) 	.disable = regulator_disable_regmap,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) 	.is_enabled = regulator_is_enabled_regmap,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) static const struct linear_range sky81452_reg_ranges[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) 	REGULATOR_LINEAR_RANGE(4500000, 0, 14, 250000),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) 	REGULATOR_LINEAR_RANGE(9000000, 15, 31, 1000000),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) static const struct regulator_desc sky81452_reg = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) 	.name = "LOUT",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) 	.of_match = of_match_ptr("lout"),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) 	.regulators_node = of_match_ptr("regulator"),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) 	.ops = &sky81452_reg_ops,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) 	.type = REGULATOR_VOLTAGE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) 	.owner = THIS_MODULE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) 	.n_voltages = SKY81452_LOUT + 1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) 	.linear_ranges = sky81452_reg_ranges,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) 	.n_linear_ranges = ARRAY_SIZE(sky81452_reg_ranges),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) 	.vsel_reg = SKY81452_REG3,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) 	.vsel_mask = SKY81452_LOUT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) 	.enable_reg = SKY81452_REG1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) 	.enable_mask = SKY81452_LEN,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) static int sky81452_reg_probe(struct platform_device *pdev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) 	struct device *dev = &pdev->dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) 	const struct regulator_init_data *init_data = dev_get_platdata(dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) 	struct regulator_config config = { };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) 	struct regulator_dev *rdev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) 	config.dev = dev->parent;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) 	config.init_data = init_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) 	config.of_node = dev->of_node;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) 	config.regmap = dev_get_drvdata(dev->parent);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) 	rdev = devm_regulator_register(dev, &sky81452_reg, &config);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) 	if (IS_ERR(rdev)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) 		dev_err(dev, "failed to register. err=%ld\n", PTR_ERR(rdev));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) 		return PTR_ERR(rdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) 	platform_set_drvdata(pdev, rdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) static struct platform_driver sky81452_reg_driver = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) 	.driver = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) 		.name = "sky81452-regulator",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) 	.probe = sky81452_reg_probe,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86) module_platform_driver(sky81452_reg_driver);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88) MODULE_DESCRIPTION("Skyworks SKY81452 Regulator driver");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89) MODULE_AUTHOR("Gyungoh Yoo <jack.yoo@skyworksinc.com>");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90) MODULE_LICENSE("GPL v2");