ITE: drivers/kscan: Use pinctrl instead of pinmux driver
Use pinctrl instead of pinmux driver. Signed-off-by: Tim Lin <tim2.lin@ite.corp-partner.google.com>
This commit is contained in:
parent
3670977158
commit
bd8afe7ef0
6 changed files with 53 additions and 48 deletions
|
@ -152,6 +152,9 @@
|
|||
};
|
||||
&kscan0 {
|
||||
status = "okay";
|
||||
pinctrl-0 = <&kso16_gpc3_default
|
||||
&kso17_gpc5_default>;
|
||||
pinctrl-names = "default";
|
||||
};
|
||||
&peci0 {
|
||||
status = "okay";
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
#include <drivers/gpio.h>
|
||||
#include <drivers/interrupt_controller/wuc_ite_it8xxx2.h>
|
||||
#include <drivers/kscan.h>
|
||||
#include <drivers/pinmux.h>
|
||||
#include <drivers/pinctrl.h>
|
||||
#include <dt-bindings/interrupt-controller/it8xxx2-wuc.h>
|
||||
#include <errno.h>
|
||||
#include <kernel.h>
|
||||
|
@ -48,15 +48,6 @@ struct kscan_wuc_map_cfg {
|
|||
uint8_t mask;
|
||||
};
|
||||
|
||||
struct kscan_alt_cfg {
|
||||
/* Pinmux control device structure */
|
||||
const struct device *pinctrls;
|
||||
/* GPIO pin */
|
||||
uint8_t pin;
|
||||
/* Alternate function */
|
||||
uint8_t alt_fun;
|
||||
};
|
||||
|
||||
struct kscan_it8xxx2_config {
|
||||
/* Keyboard scan controller base address */
|
||||
struct kscan_it8xxx2_regs *base;
|
||||
|
@ -64,10 +55,12 @@ struct kscan_it8xxx2_config {
|
|||
int irq;
|
||||
/* KSI[7:0] wake-up input source configuration list */
|
||||
const struct kscan_wuc_map_cfg *wuc_map_list;
|
||||
/* GPIO control device structure */
|
||||
const struct device *gpio_dev;
|
||||
/* Keyboard scan alternate configuration list */
|
||||
const struct kscan_alt_cfg *alt_list;
|
||||
/* Keyboard scan alternate configuration */
|
||||
const struct pinctrl_dev_config *pcfg;
|
||||
/* KSO16 GPIO cells */
|
||||
struct gpio_dt_spec kso16_gpios;
|
||||
/* KSO17 GPIO cells */
|
||||
struct gpio_dt_spec kso17_gpios;
|
||||
};
|
||||
|
||||
/* Device data */
|
||||
|
@ -440,6 +433,8 @@ static int kscan_it8xxx2_init(const struct device *dev)
|
|||
inst->KBS_KSOCTRL = (IT8XXX2_KBS_KSOOD | IT8XXX2_KBS_KSOPU);
|
||||
|
||||
#if (CONFIG_KSCAN_ITE_IT8XXX2_COLUMN_SIZE > 16)
|
||||
int status;
|
||||
|
||||
/*
|
||||
* For KSO[16] and KSO[17]:
|
||||
* 1.GPOTRC:
|
||||
|
@ -451,18 +446,14 @@ static int kscan_it8xxx2_init(const struct device *dev)
|
|||
* NOTE: Set input temporarily for gpio_pin_configure(), after that
|
||||
* pinmux_pin_set() set to alternate function immediately.
|
||||
*/
|
||||
gpio_pin_configure(config->gpio_dev,
|
||||
config->alt_list[KSO16].pin,
|
||||
(GPIO_OPEN_DRAIN | GPIO_INPUT | GPIO_PULL_UP));
|
||||
gpio_pin_configure(config->gpio_dev,
|
||||
config->alt_list[KSO17].pin,
|
||||
(GPIO_OPEN_DRAIN | GPIO_INPUT | GPIO_PULL_UP));
|
||||
pinmux_pin_set(config->alt_list[KSO16].pinctrls,
|
||||
config->alt_list[KSO16].pin,
|
||||
config->alt_list[KSO16].alt_fun);
|
||||
pinmux_pin_set(config->alt_list[KSO17].pinctrls,
|
||||
config->alt_list[KSO17].pin,
|
||||
config->alt_list[KSO17].alt_fun);
|
||||
gpio_pin_configure_dt(&config->kso16_gpios, GPIO_INPUT);
|
||||
gpio_pin_configure_dt(&config->kso17_gpios, GPIO_INPUT);
|
||||
status = pinctrl_apply_state(config->pcfg, PINCTRL_STATE_DEFAULT);
|
||||
if (status < 0) {
|
||||
LOG_ERR("Failed to configure kscan pins");
|
||||
return status;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
/* Bit[2] = 1: Enable the internal pull-up of KSI[7:0] pins */
|
||||
|
@ -578,15 +569,15 @@ static const struct kscan_driver_api kscan_it8xxx2_driver_api = {
|
|||
static const struct kscan_wuc_map_cfg kscan_wuc_0[IT8XXX2_DT_INST_WUCCTRL_LEN(0)] =
|
||||
IT8XXX2_DT_WUC_ITEMS_LIST(0);
|
||||
|
||||
static const struct kscan_alt_cfg kscan_alt_0[DT_INST_NUM_PINCTRLS_BY_IDX(0, 0)] =
|
||||
IT8XXX2_DT_ALT_ITEMS_LIST(0);
|
||||
PINCTRL_DT_INST_DEFINE(0);
|
||||
|
||||
static const struct kscan_it8xxx2_config kscan_it8xxx2_cfg_0 = {
|
||||
.base = (struct kscan_it8xxx2_regs *)DT_INST_REG_ADDR_BY_IDX(0, 0),
|
||||
.irq = DT_INST_IRQN(0),
|
||||
.wuc_map_list = kscan_wuc_0,
|
||||
.gpio_dev = DEVICE_DT_GET(DT_INST_PHANDLE_BY_IDX(0, gpio_dev, 0)),
|
||||
.alt_list = kscan_alt_0,
|
||||
.pcfg = PINCTRL_DT_INST_DEV_CONFIG_GET(0),
|
||||
.kso16_gpios = GPIO_DT_SPEC_INST_GET(0, kso16_gpios),
|
||||
.kso17_gpios = GPIO_DT_SPEC_INST_GET(0, kso17_gpios),
|
||||
};
|
||||
|
||||
static struct kscan_it8xxx2_data kscan_it8xxx2_kbd_data;
|
||||
|
|
|
@ -5,7 +5,7 @@ description: ITE it8xxx2 keyboard matrix controller
|
|||
|
||||
compatible: "ite,it8xxx2-kscan"
|
||||
|
||||
include: kscan.yaml
|
||||
include: [kscan.yaml, pinctrl-device.yaml]
|
||||
|
||||
properties:
|
||||
reg:
|
||||
|
@ -23,12 +23,20 @@ properties:
|
|||
enable, disable, and clear wakeup status for the specific pin which
|
||||
may be gpio pins or alternate pins.
|
||||
|
||||
gpio-dev:
|
||||
type: phandle
|
||||
required: true
|
||||
description: configure GPIO controller
|
||||
kso16-gpios:
|
||||
type: phandle-array
|
||||
required: true
|
||||
description: |
|
||||
The KSO16 pin for the selected port.
|
||||
|
||||
kso17-gpios:
|
||||
type: phandle-array
|
||||
required: true
|
||||
description: |
|
||||
The KSO17 pin for the selected port.
|
||||
|
||||
pinctrl-0:
|
||||
type: phandles
|
||||
required: true
|
||||
description: configure KSO pinmux controller
|
||||
required: true
|
||||
|
||||
pinctrl-names:
|
||||
required: true
|
||||
|
|
|
@ -24,12 +24,5 @@
|
|||
pinctrls = <&pinmuxm 5 IT8XXX2_PINMUX_FUNC_1>;
|
||||
};
|
||||
|
||||
/* Keyboard alternate function */
|
||||
pinctrl_kso16: kso16 {
|
||||
pinctrls = <&pinmuxc 3 IT8XXX2_PINMUX_FUNC_1>;
|
||||
};
|
||||
pinctrl_kso17: kso17 {
|
||||
pinctrls = <&pinmuxc 5 IT8XXX2_PINMUX_FUNC_1>;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
#include <dt-bindings/pwm/it8xxx2_pwm.h>
|
||||
#include <dt-bindings/sensor/it8xxx2_vcmp.h>
|
||||
#include <dt-bindings/sensor/it8xxx2_tach.h>
|
||||
#include <zephyr/dt-bindings/gpio/gpio.h>
|
||||
#include "it8xxx2-alts-map.dtsi"
|
||||
#include "ite/it8xxx2-wuc-map.dtsi"
|
||||
|
||||
|
@ -1416,9 +1417,8 @@
|
|||
&wuc_wu35 /* KSI[5] */
|
||||
&wuc_wu36 /* KSI[6] */
|
||||
&wuc_wu37>; /* KSI[7] */
|
||||
gpio-dev = <&gpioc>;
|
||||
pinctrl-0 = <&pinctrl_kso16 /* GPC3 */
|
||||
&pinctrl_kso17>; /* GPC5 */
|
||||
kso16-gpios = <&gpioc 3 (GPIO_OPEN_DRAIN | GPIO_PULL_UP)>;
|
||||
kso17-gpios = <&gpioc 5 (GPIO_OPEN_DRAIN | GPIO_PULL_UP)>;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
|
|
@ -89,6 +89,16 @@
|
|||
pinmuxs = <&pinctrla 5 IT8XXX2_ALT_FUNC_3>;
|
||||
};
|
||||
|
||||
/* Keyboard alternate function */
|
||||
kso16_gpc3_default: kso16_gpc3_default {
|
||||
pinmuxs = <&pinctrlc 3 IT8XXX2_ALT_FUNC_1>;
|
||||
bias-pull-up;
|
||||
};
|
||||
kso17_gpc5_default: kso17_gpc5_default {
|
||||
pinmuxs = <&pinctrlc 5 IT8XXX2_ALT_FUNC_1>;
|
||||
bias-pull-up;
|
||||
};
|
||||
|
||||
/* PECI alternate function */
|
||||
peci_gpf6_default: peci_gpf6_default {
|
||||
pinmuxs = <&pinctrlf 6 IT8XXX2_ALT_FUNC_3>;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue