drivers: ps2: add Zephyr pinctrl support
Replace soc-specific pin functions with Zephyr pinctrl api functions for pin-mux configuration in ps2 driver. Signed-off-by: Mulin Chao <mlchao@nuvoton.com>
This commit is contained in:
parent
8f65bdabab
commit
95f6dc6c35
3 changed files with 15 additions and 15 deletions
|
@ -17,6 +17,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <zephyr/drivers/clock_control.h>
|
#include <zephyr/drivers/clock_control.h>
|
||||||
|
#include <zephyr/drivers/pinctrl.h>
|
||||||
#include <zephyr/drivers/ps2.h>
|
#include <zephyr/drivers/ps2.h>
|
||||||
#include <soc.h>
|
#include <soc.h>
|
||||||
|
|
||||||
|
@ -27,12 +28,11 @@ LOG_MODULE_REGISTER(ps2_npcx_channel, CONFIG_PS2_LOG_LEVEL);
|
||||||
|
|
||||||
/* Device config */
|
/* Device config */
|
||||||
struct ps2_npcx_ch_config {
|
struct ps2_npcx_ch_config {
|
||||||
/* pinmux configuration */
|
|
||||||
const uint8_t alts_size;
|
|
||||||
const struct npcx_alt *alts_list;
|
|
||||||
/* Indicate the channel's number of the PS/2 channel device */
|
/* Indicate the channel's number of the PS/2 channel device */
|
||||||
uint8_t channel_id;
|
uint8_t channel_id;
|
||||||
const struct device *ps2_ctrl;
|
const struct device *ps2_ctrl;
|
||||||
|
/* pinmux configuration */
|
||||||
|
const struct pinctrl_dev_config *pcfg;
|
||||||
};
|
};
|
||||||
|
|
||||||
/* PS/2 api functions */
|
/* PS/2 api functions */
|
||||||
|
@ -78,6 +78,7 @@ static int ps2_npcx_ch_inhibit_interface(const struct device *dev)
|
||||||
static int ps2_npcx_channel_init(const struct device *dev)
|
static int ps2_npcx_channel_init(const struct device *dev)
|
||||||
{
|
{
|
||||||
const struct ps2_npcx_ch_config *const config = dev->config;
|
const struct ps2_npcx_ch_config *const config = dev->config;
|
||||||
|
int ret;
|
||||||
|
|
||||||
if (!device_is_ready(config->ps2_ctrl)) {
|
if (!device_is_ready(config->ps2_ctrl)) {
|
||||||
LOG_ERR("%s device not ready", config->ps2_ctrl->name);
|
LOG_ERR("%s device not ready", config->ps2_ctrl->name);
|
||||||
|
@ -85,7 +86,11 @@ static int ps2_npcx_channel_init(const struct device *dev)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Configure pin-mux for PS/2 device */
|
/* Configure pin-mux for PS/2 device */
|
||||||
npcx_pinctrl_mux_configure(config->alts_list, config->alts_size, 1);
|
ret = pinctrl_apply_state(config->pcfg, PINCTRL_STATE_DEFAULT);
|
||||||
|
if (ret < 0) {
|
||||||
|
LOG_ERR("PS2 pinctrl setup failed (%d)", ret);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -101,14 +106,12 @@ static const struct ps2_driver_api ps2_channel_npcx_driver_api = {
|
||||||
/* PS/2 channel initialization macro functions */
|
/* PS/2 channel initialization macro functions */
|
||||||
#define NPCX_PS2_CHANNEL_INIT(inst) \
|
#define NPCX_PS2_CHANNEL_INIT(inst) \
|
||||||
\
|
\
|
||||||
static const struct npcx_alt ps2_channel_alts##inst[] = \
|
PINCTRL_DT_INST_DEFINE(inst); \
|
||||||
NPCX_DT_ALT_ITEMS_LIST(inst); \
|
|
||||||
\
|
\
|
||||||
static const struct ps2_npcx_ch_config ps2_npcx_ch_cfg_##inst = { \
|
static const struct ps2_npcx_ch_config ps2_npcx_ch_cfg_##inst = { \
|
||||||
.channel_id = DT_INST_PROP(inst, channel), \
|
.channel_id = DT_INST_PROP(inst, channel), \
|
||||||
.alts_size = ARRAY_SIZE(ps2_channel_alts##inst), \
|
|
||||||
.alts_list = ps2_channel_alts##inst, \
|
|
||||||
.ps2_ctrl = DEVICE_DT_GET(DT_INST_PARENT(inst)), \
|
.ps2_ctrl = DEVICE_DT_GET(DT_INST_PARENT(inst)), \
|
||||||
|
.pcfg = PINCTRL_DT_INST_DEV_CONFIG_GET(inst), \
|
||||||
}; \
|
}; \
|
||||||
\
|
\
|
||||||
DEVICE_DT_INST_DEFINE(inst, ps2_npcx_channel_init, NULL, NULL, \
|
DEVICE_DT_INST_DEFINE(inst, ps2_npcx_channel_init, NULL, NULL, \
|
||||||
|
|
|
@ -531,7 +531,6 @@
|
||||||
ps2_channel0: io_ps2_channel0 {
|
ps2_channel0: io_ps2_channel0 {
|
||||||
compatible = "nuvoton,npcx-ps2-channel";
|
compatible = "nuvoton,npcx-ps2-channel";
|
||||||
channel = <0x00>;
|
channel = <0x00>;
|
||||||
pinctrl-0 = <&alt3_ps2_0_sl>; /* PIN67.70 */
|
|
||||||
label = "PS2_CHANNEL_0";
|
label = "PS2_CHANNEL_0";
|
||||||
status = "disabled";
|
status = "disabled";
|
||||||
};
|
};
|
||||||
|
@ -539,7 +538,6 @@
|
||||||
ps2_channel1: io_ps2_channel1 {
|
ps2_channel1: io_ps2_channel1 {
|
||||||
compatible = "nuvoton,npcx-ps2-channel";
|
compatible = "nuvoton,npcx-ps2-channel";
|
||||||
channel = <0x01>;
|
channel = <0x01>;
|
||||||
pinctrl-0 = <&alt3_ps2_1_sl>; /* PIN62.63 */
|
|
||||||
label = "PS2_CHANNEL_1";
|
label = "PS2_CHANNEL_1";
|
||||||
status = "disabled";
|
status = "disabled";
|
||||||
};
|
};
|
||||||
|
@ -547,7 +545,6 @@
|
||||||
ps2_channel2: io_ps2_channel2 {
|
ps2_channel2: io_ps2_channel2 {
|
||||||
compatible = "nuvoton,npcx-ps2-channel";
|
compatible = "nuvoton,npcx-ps2-channel";
|
||||||
channel = <0x02>;
|
channel = <0x02>;
|
||||||
pinctrl-0 = <&alt3_ps2_2_sl>; /* PIN37.34 */
|
|
||||||
label = "PS2_CHANNEL_2";
|
label = "PS2_CHANNEL_2";
|
||||||
status = "disabled";
|
status = "disabled";
|
||||||
};
|
};
|
||||||
|
@ -555,7 +552,6 @@
|
||||||
ps2_channel3: io_ps2_channel3 {
|
ps2_channel3: io_ps2_channel3 {
|
||||||
compatible = "nuvoton,npcx-ps2-channel";
|
compatible = "nuvoton,npcx-ps2-channel";
|
||||||
channel = <0x03>;
|
channel = <0x03>;
|
||||||
pinctrl-0 = <&altc_ps2_3_sl2>; /* PINA6.A7 */
|
|
||||||
label = "PS2_CHANNEL_3";
|
label = "PS2_CHANNEL_3";
|
||||||
status = "disabled";
|
status = "disabled";
|
||||||
};
|
};
|
||||||
|
|
|
@ -5,7 +5,7 @@ description: Nuvoton, NPCX-PS/2 channel pads node
|
||||||
|
|
||||||
compatible: "nuvoton,npcx-ps2-channel"
|
compatible: "nuvoton,npcx-ps2-channel"
|
||||||
|
|
||||||
include: base.yaml
|
include: [base.yaml, pinctrl-device.yaml]
|
||||||
|
|
||||||
properties:
|
properties:
|
||||||
channel:
|
channel:
|
||||||
|
@ -14,6 +14,7 @@ properties:
|
||||||
description: index of i2c channel
|
description: index of i2c channel
|
||||||
|
|
||||||
pinctrl-0:
|
pinctrl-0:
|
||||||
type: phandles
|
|
||||||
required: true
|
required: true
|
||||||
description: configurations of pinmux controllers
|
|
||||||
|
pinctrl-names:
|
||||||
|
required: true
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue