From 6b2a1af1cd33c1ffdd1490bcccf88544bb9848df Mon Sep 17 00:00:00 2001 From: Paul Sokolovsky Date: Fri, 11 Nov 2016 18:13:59 +0300 Subject: [PATCH] pinmux: Make default init priority be between GPIO's prio and device prio. Pinmux driver almost certainly should be initialized before the rest of hardware devices (which may need specific pins already configured for them), and usually after generic GPIO drivers. Thus, its priority should be between KERNEL_INIT_PRIORITY_DEFAULT (default 40) and KERNEL_INIT_PRIORITY_DEVICE (default 50). Thus, we set PINMUX_INIT_PRIORITY to 45. There are exceptions to the rule above for particular boards. For example, BOARD=galileo has GPIO and pinmuxer on I2C bus and thus overrides PINMUX_INIT_PRIORITY to be much higher. Note that while PINMUX_INIT_PRIORITY was defined previously (at 60), it was used only for galileo, which overrides it anyway. This fix was prompted by investigation why eth_ksdk driver was non-functional after kernel priorities re-hashing: both eth_ksdk and pinmux used the same priority, and eth_ksdk happened to run before pinmux. While bumping eth_ksdk priority would help in the particular case, the same would likely reoccur with other drivers like I2C, SPI, etc. Change-Id: Ie5ca3135c1ee2fe8d9cf48d5c12e62eac63487f7 Signed-off-by: Paul Sokolovsky --- drivers/pinmux/Kconfig | 13 +++++++++---- drivers/pinmux/dev/pinmux_dev_k64.c | 2 +- drivers/pinmux/k64/pinmux_board_frdm_k64f.c | 2 +- drivers/pinmux/k64/pinmux_board_hexiwear.c | 2 +- 4 files changed, 12 insertions(+), 7 deletions(-) diff --git a/drivers/pinmux/Kconfig b/drivers/pinmux/Kconfig index 7ee58bf3643..f4a904042bc 100644 --- a/drivers/pinmux/Kconfig +++ b/drivers/pinmux/Kconfig @@ -37,12 +37,17 @@ config PINMUX_NAME config PINMUX_INIT_PRIORITY int prompt "Init priority" - default 60 + default 45 depends on PINMUX help - Device driver initialization priority. - The device needs to be initialized after all the devices it - uses. + Pinmux driver initialization priority. + Pinmux driver almost certainly should be initialized before the + rest of hardware devices (which may need specific pins already + configured for them), and usually after generic GPIO drivers. + Thus, its priority should be between KERNEL_INIT_PRIORITY_DEFAULT + and KERNEL_INIT_PRIORITY_DEVICE. There are exceptions to this + rule for particular boards. Don't change this value unless you + know what you are doing. config PINMUX_K64 bool "Freescale K64-based Pin multiplexer driver" diff --git a/drivers/pinmux/dev/pinmux_dev_k64.c b/drivers/pinmux/dev/pinmux_dev_k64.c index ae64da34f58..1b1773075ce 100644 --- a/drivers/pinmux/dev/pinmux_dev_k64.c +++ b/drivers/pinmux/dev/pinmux_dev_k64.c @@ -53,5 +53,5 @@ int pinmux_fsl_k64_initialize(struct device *port) /* must be initialized after GPIO */ DEVICE_AND_API_INIT(pmux, CONFIG_PINMUX_DEV_NAME, &pinmux_fsl_k64_initialize, NULL, NULL, - POST_KERNEL, CONFIG_KERNEL_INIT_PRIORITY_DEVICE, + POST_KERNEL, CONFIG_PINMUX_INIT_PRIORITY, &api_funcs); diff --git a/drivers/pinmux/k64/pinmux_board_frdm_k64f.c b/drivers/pinmux/k64/pinmux_board_frdm_k64f.c index e8d33a36cae..9b61b6859ca 100644 --- a/drivers/pinmux/k64/pinmux_board_frdm_k64f.c +++ b/drivers/pinmux/k64/pinmux_board_frdm_k64f.c @@ -114,4 +114,4 @@ static int fsl_frdm_k64f_pin_init(struct device *arg) return 0; } -SYS_INIT(fsl_frdm_k64f_pin_init, POST_KERNEL, CONFIG_KERNEL_INIT_PRIORITY_DEVICE); +SYS_INIT(fsl_frdm_k64f_pin_init, POST_KERNEL, CONFIG_PINMUX_INIT_PRIORITY); diff --git a/drivers/pinmux/k64/pinmux_board_hexiwear.c b/drivers/pinmux/k64/pinmux_board_hexiwear.c index 2f37e603bf3..6de6ad681a5 100644 --- a/drivers/pinmux/k64/pinmux_board_hexiwear.c +++ b/drivers/pinmux/k64/pinmux_board_hexiwear.c @@ -66,4 +66,4 @@ static int hexiwear_pin_init(struct device *arg) return 0; } -SYS_INIT(hexiwear_pin_init, POST_KERNEL, CONFIG_KERNEL_INIT_PRIORITY_DEVICE); +SYS_INIT(hexiwear_pin_init, POST_KERNEL, CONFIG_PINMUX_INIT_PRIORITY);