Files
android/drivers/misc/mediatek/connectivity/gps/gps_stp/gps_mt3337.c
T
threeeye bc1d038eac REVVL 6 Pro kernel bring-up: full working tree snapshot (2026-09-12)
Squashed backup commit (no shallow-clone history issues) of
xiaomi-mt6833-dev/kernel_xiaomi_mt6833 (lineage-23.2 branch, upstream
commit 9eece662e) plus all fixes applied to get everpal_defconfig building
clean against a modern (GCC 15.2.0) toolchain -- see the previous commit
message on the lineage-23.2 branch (also in this repo history is not
available here since this is a squashed snapshot; full incremental history
lives in the local DL380 checkout and the upstream GitHub remote).

Upstream: https://github.com/xiaomi-mt6833-dev/kernel_xiaomi_mt6833 (lineage-23.2)
2026-09-12 13:36:46 +00:00

95 lines
1.9 KiB
C

/* SPDX-License-Identifier: GPL-2.0 */
/*
* Copyright (c) 2019 - 2021 MediaTek Inc.
*/
#include <linux/device.h>
#include <linux/fs.h>
#include <linux/ioctl.h>
#include <linux/kernel.h>
#include <linux/miscdevice.h>
#include <linux/module.h>
#include <linux/of.h>
#include <linux/platform_device.h>
#include <linux/regulator/consumer.h>
#define DEVICE_NAME "mt3337_gpsonly"
#ifdef pr_fmt
#undef pr_fmt
#endif
#define pr_fmt(fmt) "["KBUILD_MODNAME"]" fmt
#define GPS_POWER_IOCTL _IOW('G', 0, int)
static long gps_ioctrl(struct file *filp, unsigned int cmd, unsigned long arg)
{
struct miscdevice *dev;
struct regulator *reg;
int ret;
switch (cmd) {
case GPS_POWER_IOCTL:
dev = (struct miscdevice *)filp->private_data;
reg = dev_get_drvdata(dev->this_device);
if (arg)
ret = regulator_enable(reg);
else
ret = regulator_disable(reg);
return ret;
default:
return -EINVAL;
}
return 0;
}
static const struct file_operations gps_fops = {
.owner = THIS_MODULE,
.unlocked_ioctl = gps_ioctrl,
.compat_ioctl = gps_ioctrl,
};
static struct miscdevice mt3337_gps_driver = {
.minor = MISC_DYNAMIC_MINOR,
.name = DEVICE_NAME,
.fops = &gps_fops,
};
static int mt3337_gps_probe(struct platform_device *pdev)
{
int ret;
struct regulator *regulator;
regulator = devm_regulator_get(&pdev->dev, "power");
if (IS_ERR(regulator))
return PTR_ERR(regulator);
ret = misc_register(&mt3337_gps_driver);
if (ret < 0)
return ret;
dev_set_drvdata(mt3337_gps_driver.this_device, regulator);
return 0;
}
static const struct of_device_id mt3337_gps_of_match[] = {
{ .compatible = "mediatek,mt3337" },
{},
};
static struct platform_driver mt3337_gps_pdriver = {
.probe = mt3337_gps_probe,
.driver = {
.name = DEVICE_NAME,
.of_match_table = of_match_ptr(mt3337_gps_of_match),
},
};
module_platform_driver(mt3337_gps_pdriver);
MODULE_AUTHOR("Hao Dong <hao.dong@mediatek.com>");
MODULE_DESCRIPTION("MT3337 GPS Driver");
MODULE_LICENSE("GPL");