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:
parent
8ecd5bb2f7
commit
5551872047
6 changed files with 34 additions and 44 deletions
|
@ -147,6 +147,8 @@
|
|||
status = "okay";
|
||||
channel = <IT8XXX2_TACH_CHANNEL_A>;
|
||||
pulses-per-round = <2>;
|
||||
pinctrl-0 = <&tach0a_gpd6_default>;
|
||||
pinctrl-names = "default";
|
||||
};
|
||||
&kscan0 {
|
||||
status = "okay";
|
||||
|
|
|
@ -42,7 +42,7 @@
|
|||
*/
|
||||
|
||||
#include <device.h>
|
||||
#include <drivers/pinmux.h>
|
||||
#include <drivers/pinctrl.h>
|
||||
#include <drivers/sensor.h>
|
||||
#include <dt-bindings/sensor/it8xxx2_tach.h>
|
||||
#include <errno.h>
|
||||
|
@ -58,16 +58,6 @@ LOG_MODULE_REGISTER(tach_ite_it8xxx2, CONFIG_SENSOR_LOG_LEVEL);
|
|||
*/
|
||||
#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 {
|
||||
/* Fan x tachometer LSB reading register */
|
||||
uintptr_t reg_fxtlrr;
|
||||
|
@ -79,8 +69,8 @@ struct tach_it8xxx2_config {
|
|||
int dvs_bit;
|
||||
/* Tachometer data valid status bit of tswctlr register */
|
||||
int chsel_bit;
|
||||
/* Tachometer alternate configuration list */
|
||||
const struct tach_alt_cfg *alt_list;
|
||||
/* Tachometer alternate configuration */
|
||||
const struct pinctrl_dev_config *pcfg;
|
||||
/* Select channel of tachometer */
|
||||
int channel;
|
||||
/* 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;
|
||||
volatile uint8_t *reg_tswctlr = (uint8_t *)config->reg_tswctlr;
|
||||
int tach_ch = config->channel;
|
||||
int status;
|
||||
|
||||
if (tach_ch > IT8XXX2_TACH_CHANNEL_B) {
|
||||
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 */
|
||||
pinmux_pin_set(config->alt_list[tach_ch].pinctrls,
|
||||
config->alt_list[tach_ch].pin,
|
||||
config->alt_list[tach_ch].alt_fun);
|
||||
status = pinctrl_apply_state(config->pcfg, PINCTRL_STATE_DEFAULT);
|
||||
if (status < 0) {
|
||||
LOG_ERR("Failed to configure TACH pins");
|
||||
return status;
|
||||
}
|
||||
|
||||
if (tach_ch == IT8XXX2_TACH_CHANNEL_A) {
|
||||
/* 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) \
|
||||
static const struct tach_alt_cfg \
|
||||
tach_alt_##inst[DT_INST_NUM_PINCTRLS_BY_IDX(inst, 0)] = \
|
||||
IT8XXX2_DT_ALT_ITEMS_LIST(inst); \
|
||||
PINCTRL_DT_INST_DEFINE(inst); \
|
||||
\
|
||||
static const struct tach_it8xxx2_config tach_it8xxx2_cfg_##inst = { \
|
||||
.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), \
|
||||
.dvs_bit = DT_INST_PROP(inst, dvs_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), \
|
||||
.pulses_per_round = DT_INST_PROP(inst, pulses_per_round), \
|
||||
}; \
|
||||
|
|
|
@ -5,7 +5,7 @@ description: ITE, it8xxx2 Tachometer node
|
|||
|
||||
compatible: "ite,it8xxx2-tach"
|
||||
|
||||
include: tach.yaml
|
||||
include: [tach.yaml, pinctrl-device.yaml]
|
||||
|
||||
properties:
|
||||
reg:
|
||||
|
@ -21,11 +21,6 @@ properties:
|
|||
required: true
|
||||
description: tachometer data valid status bit of tswctlr register
|
||||
|
||||
pinctrl-0:
|
||||
type: phandles
|
||||
required: true
|
||||
description: configuration of tachometer pinmux controller
|
||||
|
||||
channel:
|
||||
type: int
|
||||
required: true
|
||||
|
@ -38,3 +33,9 @@ properties:
|
|||
type: int
|
||||
required: true
|
||||
description: number of pulses per round of tachometer's input
|
||||
|
||||
pinctrl-0:
|
||||
required: true
|
||||
|
||||
pinctrl-names:
|
||||
required: true
|
||||
|
|
|
@ -10,20 +10,6 @@
|
|||
it8xxx2_alts_map {
|
||||
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 */
|
||||
pinctrl_shi_mosi: shi_mosi {
|
||||
pinctrls = <&pinmuxm 0 IT8XXX2_PINMUX_FUNC_1>;
|
||||
|
|
|
@ -1372,8 +1372,6 @@
|
|||
chsel-bit = <BIT(2)>;
|
||||
label = "TACH_0";
|
||||
status = "disabled";
|
||||
pinctrl-0 = <&pinctrl_tach0a /* GPD6 */
|
||||
&pinctrl_tach0b>; /* GPJ2 */
|
||||
};
|
||||
tach1: tach@f01820 {
|
||||
compatible = "ite,it8xxx2-tach";
|
||||
|
@ -1384,8 +1382,6 @@
|
|||
chsel-bit = <BIT(0)>;
|
||||
label = "TACH_1";
|
||||
status = "disabled";
|
||||
pinctrl-0 = <&pinctrl_tach1a /* GPD7 */
|
||||
&pinctrl_tach1b>; /* GPJ3 */
|
||||
};
|
||||
|
||||
gctrl: general-control@f02000 {
|
||||
|
|
|
@ -115,6 +115,20 @@
|
|||
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 */
|
||||
uart1_rx_gpb0_default: uart1_rx_gpb0_default {
|
||||
pinmuxs = <&pinctrlb 0 IT8XXX2_ALT_FUNC_3>;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue