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) #include <linux/slab.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  3) #include <linux/string.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  4) #include <linux/platform_device.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  5) #include <linux/regulator/machine.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  6) #include <linux/regulator/fixed.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  7) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  8) struct fixed_regulator_data {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  9) 	struct fixed_voltage_config cfg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) 	struct regulator_init_data init_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) 	struct platform_device pdev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) static void regulator_fixed_release(struct device *dev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) 	struct fixed_regulator_data *data = container_of(dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) 			struct fixed_regulator_data, pdev.dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) 	kfree(data->cfg.supply_name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) 	kfree(data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23)  * regulator_register_fixed_name - register a no-op fixed regulator
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24)  * @id: platform device id
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25)  * @name: name to be used for the regulator
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26)  * @supplies: consumers for this regulator
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27)  * @num_supplies: number of consumers
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28)  * @uv: voltage in microvolts
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) struct platform_device *regulator_register_always_on(int id, const char *name,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) 	struct regulator_consumer_supply *supplies, int num_supplies, int uv)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) 	struct fixed_regulator_data *data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) 	data = kzalloc(sizeof(*data), GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) 	if (!data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) 		return NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) 	data->cfg.supply_name = kstrdup(name, GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) 	if (!data->cfg.supply_name) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) 		kfree(data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) 		return NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) 	data->cfg.microvolts = uv;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) 	data->cfg.enabled_at_boot = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) 	data->cfg.init_data = &data->init_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) 	data->init_data.constraints.always_on = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) 	data->init_data.consumer_supplies = supplies;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) 	data->init_data.num_consumer_supplies = num_supplies;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) 	data->pdev.name = "reg-fixed-voltage";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) 	data->pdev.id = id;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) 	data->pdev.dev.platform_data = &data->cfg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) 	data->pdev.dev.release = regulator_fixed_release;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) 	platform_device_register(&data->pdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) 	return &data->pdev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) }