ITE: drivers/sensor: 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:
Tim Lin 2022-03-26 14:19:25 +08:00 committed by Carles Cufí
commit 5551872047
6 changed files with 34 additions and 44 deletions

View file

@ -147,6 +147,8 @@
status = "okay"; status = "okay";
channel = <IT8XXX2_TACH_CHANNEL_A>; channel = <IT8XXX2_TACH_CHANNEL_A>;
pulses-per-round = <2>; pulses-per-round = <2>;
pinctrl-0 = <&tach0a_gpd6_default>;
pinctrl-names = "default";
}; };
&kscan0 { &kscan0 {
status = "okay"; status = "okay";

View file

@ -42,7 +42,7 @@
*/ */
#include <device.h> #include <device.h>
#include <drivers/pinmux.h> #include <drivers/pinctrl.h>
#include <drivers/sensor.h> #include <drivers/sensor.h>
#include <dt-bindings/sensor/it8xxx2_tach.h> #include <dt-bindings/sensor/it8xxx2_tach.h>
#include <errno.h> #include <errno.h>
@ -58,16 +58,6 @@ LOG_MODULE_REGISTER(tach_ite_it8xxx2, CONFIG_SENSOR_LOG_LEVEL);
*/ */
#define TACH_FREQ EC_FREQ #define TACH_FREQ EC_FREQ
/* Device config */
struct tach_alt_cfg {
/* Pinmux control device structure */
const struct device *pinctrls;
/* GPIO pin */
uint8_t pin;
/* Alternate function */
uint8_t alt_fun;
};
struct tach_it8xxx2_config { struct tach_it8xxx2_config {
/* Fan x tachometer LSB reading register */ /* Fan x tachometer LSB reading register */
uintptr_t reg_fxtlrr; uintptr_t reg_fxtlrr;
@ -79,8 +69,8 @@ struct tach_it8xxx2_config {
int dvs_bit; int dvs_bit;
/* Tachometer data valid status bit of tswctlr register */ /* Tachometer data valid status bit of tswctlr register */
int chsel_bit; int chsel_bit;
/* Tachometer alternate configuration list */ /* Tachometer alternate configuration */
const struct tach_alt_cfg *alt_list; const struct pinctrl_dev_config *pcfg;
/* Select channel of tachometer */ /* Select channel of tachometer */
int channel; int channel;
/* Number of pulses per round of tachometer's input */ /* Number of pulses per round of tachometer's input */
@ -193,6 +183,7 @@ static int tach_it8xxx2_init(const struct device *dev)
const struct tach_it8xxx2_config *const config = dev->config; const struct tach_it8xxx2_config *const config = dev->config;
volatile uint8_t *reg_tswctlr = (uint8_t *)config->reg_tswctlr; volatile uint8_t *reg_tswctlr = (uint8_t *)config->reg_tswctlr;
int tach_ch = config->channel; int tach_ch = config->channel;
int status;
if (tach_ch > IT8XXX2_TACH_CHANNEL_B) { if (tach_ch > IT8XXX2_TACH_CHANNEL_B) {
LOG_ERR("Tach channel %d, only support 0 or 1", tach_ch); LOG_ERR("Tach channel %d, only support 0 or 1", tach_ch);
@ -200,9 +191,11 @@ static int tach_it8xxx2_init(const struct device *dev)
} }
/* Select pin to alternate mode for tachometer */ /* Select pin to alternate mode for tachometer */
pinmux_pin_set(config->alt_list[tach_ch].pinctrls, status = pinctrl_apply_state(config->pcfg, PINCTRL_STATE_DEFAULT);
config->alt_list[tach_ch].pin, if (status < 0) {
config->alt_list[tach_ch].alt_fun); LOG_ERR("Failed to configure TACH pins");
return status;
}
if (tach_ch == IT8XXX2_TACH_CHANNEL_A) { if (tach_ch == IT8XXX2_TACH_CHANNEL_A) {
/* Select IT8XXX2_TACH_CHANNEL_A output to tachometer */ /* Select IT8XXX2_TACH_CHANNEL_A output to tachometer */
@ -226,9 +219,7 @@ static const struct sensor_driver_api tach_it8xxx2_driver_api = {
}; };
#define TACH_IT8XXX2_INIT(inst) \ #define TACH_IT8XXX2_INIT(inst) \
static const struct tach_alt_cfg \ PINCTRL_DT_INST_DEFINE(inst); \
tach_alt_##inst[DT_INST_NUM_PINCTRLS_BY_IDX(inst, 0)] = \
IT8XXX2_DT_ALT_ITEMS_LIST(inst); \
\ \
static const struct tach_it8xxx2_config tach_it8xxx2_cfg_##inst = { \ static const struct tach_it8xxx2_config tach_it8xxx2_cfg_##inst = { \
.reg_fxtlrr = DT_INST_REG_ADDR_BY_IDX(inst, 0), \ .reg_fxtlrr = DT_INST_REG_ADDR_BY_IDX(inst, 0), \
@ -236,7 +227,7 @@ static const struct sensor_driver_api tach_it8xxx2_driver_api = {
.reg_tswctlr = DT_INST_REG_ADDR_BY_IDX(inst, 2), \ .reg_tswctlr = DT_INST_REG_ADDR_BY_IDX(inst, 2), \
.dvs_bit = DT_INST_PROP(inst, dvs_bit), \ .dvs_bit = DT_INST_PROP(inst, dvs_bit), \
.chsel_bit = DT_INST_PROP(inst, chsel_bit), \ .chsel_bit = DT_INST_PROP(inst, chsel_bit), \
.alt_list = tach_alt_##inst, \ .pcfg = PINCTRL_DT_INST_DEV_CONFIG_GET(inst), \
.channel = DT_INST_PROP(inst, channel), \ .channel = DT_INST_PROP(inst, channel), \
.pulses_per_round = DT_INST_PROP(inst, pulses_per_round), \ .pulses_per_round = DT_INST_PROP(inst, pulses_per_round), \
}; \ }; \

View file

@ -5,7 +5,7 @@ description: ITE, it8xxx2 Tachometer node
compatible: "ite,it8xxx2-tach" compatible: "ite,it8xxx2-tach"
include: tach.yaml include: [tach.yaml, pinctrl-device.yaml]
properties: properties:
reg: reg:
@ -21,11 +21,6 @@ properties:
required: true required: true
description: tachometer data valid status bit of tswctlr register description: tachometer data valid status bit of tswctlr register
pinctrl-0:
type: phandles
required: true
description: configuration of tachometer pinmux controller
channel: channel:
type: int type: int
required: true required: true
@ -38,3 +33,9 @@ properties:
type: int type: int
required: true required: true
description: number of pulses per round of tachometer's input description: number of pulses per round of tachometer's input
pinctrl-0:
required: true
pinctrl-names:
required: true

View file

@ -10,20 +10,6 @@
it8xxx2_alts_map { it8xxx2_alts_map {
compatible = "ite,it8xxx2-pinctrl-conf"; compatible = "ite,it8xxx2-pinctrl-conf";
/* Tachometer alternate function */
pinctrl_tach0a: tach0a {
pinctrls = <&pinmuxd 6 IT8XXX2_PINMUX_FUNC_1>;
};
pinctrl_tach0b: tach0b {
pinctrls = <&pinmuxj 2 IT8XXX2_PINMUX_FUNC_3>;
};
pinctrl_tach1a: tach1a {
pinctrls = <&pinmuxd 7 IT8XXX2_PINMUX_FUNC_1>;
};
pinctrl_tach1b: tach1b {
pinctrls = <&pinmuxj 3 IT8XXX2_PINMUX_FUNC_3>;
};
/* SHI alternate function */ /* SHI alternate function */
pinctrl_shi_mosi: shi_mosi { pinctrl_shi_mosi: shi_mosi {
pinctrls = <&pinmuxm 0 IT8XXX2_PINMUX_FUNC_1>; pinctrls = <&pinmuxm 0 IT8XXX2_PINMUX_FUNC_1>;

View file

@ -1372,8 +1372,6 @@
chsel-bit = <BIT(2)>; chsel-bit = <BIT(2)>;
label = "TACH_0"; label = "TACH_0";
status = "disabled"; status = "disabled";
pinctrl-0 = <&pinctrl_tach0a /* GPD6 */
&pinctrl_tach0b>; /* GPJ2 */
}; };
tach1: tach@f01820 { tach1: tach@f01820 {
compatible = "ite,it8xxx2-tach"; compatible = "ite,it8xxx2-tach";
@ -1384,8 +1382,6 @@
chsel-bit = <BIT(0)>; chsel-bit = <BIT(0)>;
label = "TACH_1"; label = "TACH_1";
status = "disabled"; status = "disabled";
pinctrl-0 = <&pinctrl_tach1a /* GPD7 */
&pinctrl_tach1b>; /* GPJ3 */
}; };
gctrl: general-control@f02000 { gctrl: general-control@f02000 {

View file

@ -115,6 +115,20 @@
pinmuxs = <&pinctrla 7 IT8XXX2_ALT_FUNC_1>; pinmuxs = <&pinctrla 7 IT8XXX2_ALT_FUNC_1>;
}; };
/* Tachometer alternate function */
tach0a_gpd6_default: tach0a_gpd6_default {
pinmuxs = <&pinctrld 6 IT8XXX2_ALT_FUNC_1>;
};
tach0b_gpj2_default: tach0b_gpj2_default {
pinmuxs = <&pinctrlj 2 IT8XXX2_ALT_FUNC_3>;
};
tach1a_gpd7_default: tach1a_gpd7_default {
pinmuxs = <&pinctrld 7 IT8XXX2_ALT_FUNC_1>;
};
tach1b_gpj3_default: tach1b_gpj3_default {
pinmuxs = <&pinctrlj 3 IT8XXX2_ALT_FUNC_3>;
};
/* UART alternate function */ /* UART alternate function */
uart1_rx_gpb0_default: uart1_rx_gpb0_default { uart1_rx_gpb0_default: uart1_rx_gpb0_default {
pinmuxs = <&pinctrlb 0 IT8XXX2_ALT_FUNC_3>; pinmuxs = <&pinctrlb 0 IT8XXX2_ALT_FUNC_3>;