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)
100 lines
2.1 KiB
C
100 lines
2.1 KiB
C
/*
|
|
* Copyright (C) 2015 MediaTek Inc.
|
|
*
|
|
* This program is free software: you can redistribute it and/or modify
|
|
* it under the terms of the GNU General Public License version 2 as
|
|
* published by the Free Software Foundation.
|
|
*
|
|
* This program is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU General Public License for more details.
|
|
*/
|
|
|
|
#include "disp_dts_gpio.h"
|
|
#include "disp_helper.h"
|
|
#include "disp_drv_log.h"
|
|
#include <linux/kernel.h> /* printk */
|
|
|
|
#ifndef CONFIG_FPGA_EARLY_PORTING
|
|
static struct pinctrl *this_pctrl; /* static pinctrl instance */
|
|
#endif
|
|
|
|
/* DTS state mapping name */
|
|
static const char *this_state_name[DTS_GPIO_STATE_MAX] = {
|
|
"lcd_bias_enp1_gpio",
|
|
"lcd_bias_enp0_gpio",
|
|
"lcd_bias_enn1_gpio",
|
|
"lcd_bias_enn0_gpio",
|
|
"lcm_rst_out1_gpio",
|
|
"lcm_rst_out0_gpio",
|
|
"lcm1_rst_out1_gpio",
|
|
"lcm1_rst_out0_gpio",
|
|
"tp_rst_out1_gpio",
|
|
"tp_rst_out0_gpio",
|
|
"mode_te_gpio",
|
|
"mode_te_te",
|
|
"mode_te1_te",
|
|
};
|
|
|
|
/* pinctrl implementation */
|
|
static long _set_state(const char *name)
|
|
{
|
|
#ifndef CONFIG_FPGA_EARLY_PORTING
|
|
long ret = 0;
|
|
struct pinctrl_state *pState = 0;
|
|
|
|
if (!this_pctrl) {
|
|
pr_info("this pctrl is null\n");
|
|
return -1;
|
|
}
|
|
|
|
pState = pinctrl_lookup_state(this_pctrl, name);
|
|
if (IS_ERR(pState)) {
|
|
pr_info("lookup state '%s' failed\n", name);
|
|
ret = PTR_ERR(pState);
|
|
goto exit;
|
|
}
|
|
|
|
/* select state! */
|
|
pinctrl_select_state(this_pctrl, pState);
|
|
|
|
exit:
|
|
return ret; /* Good! */
|
|
#else
|
|
return 0;
|
|
#endif
|
|
}
|
|
|
|
long disp_dts_gpio_init(struct platform_device *pdev)
|
|
{
|
|
#ifndef CONFIG_FPGA_EARLY_PORTING
|
|
long ret = 0;
|
|
struct pinctrl *pctrl;
|
|
|
|
/* retrieve */
|
|
pctrl = devm_pinctrl_get(&pdev->dev);
|
|
if (IS_ERR(pctrl)) {
|
|
DISPMSG("Cannot find disp pinctrl!");
|
|
ret = PTR_ERR(pctrl);
|
|
goto exit;
|
|
}
|
|
|
|
this_pctrl = pctrl;
|
|
|
|
exit:
|
|
return ret;
|
|
#else
|
|
return 0;
|
|
#endif
|
|
}
|
|
|
|
long disp_dts_gpio_select_state(enum DTS_GPIO_STATE s)
|
|
{
|
|
if (!((unsigned int)(s) < (unsigned int)(DTS_GPIO_STATE_MAX))) {
|
|
pr_info("GPIO STATE is invalid,state=%d\n", (unsigned int)s);
|
|
return -1;
|
|
}
|
|
return _set_state(this_state_name[s]);
|
|
}
|