Unify MediaTek pinctrl in preparation for MT8183 and MT6765
Subsystems (4)
v2 cover Unify MediaTek pinctrl in preparation for MT8183 and MT6765
From: Sean Wang <[email protected]>
v2 and changes since v1:
add new patches
* Add additional patch 17 to 22 to support MT8183 SoC
update the existing patches
* Patch 2: Removed unnecessary blank line and headers included.
* Patch 4: Extended the size eint number can hold since it's possible more than 254 pins in certain SoC.
* Patch 11: Added cosmetic patch and fixed an error logic on invalid condition.
* Patch 14: Removed unused macro and given a better naming to the name of the default bases.
v1:
Irregular register arrangement and their logic access from various MediaTek SoCs being introduced already causes pinctrl-mtk-common to bloat and became really hard to maintain so that the patch creates pinctrl-mtk-common-v2 based on the core of mt7622 pinctrl to try make the register operations to be simple.
The goals pinctrl-mtk-common-v2 want to achieve are to hopefully support all of MediaTek SoCs, and two kinds of dt-bindings being supported, Linux generic pinctrl dt-binding which mt762x like to support and MediaTek vendor per-pin dt-binding the other SoCs support the MT8183 and MT6765 incline to make use of.
The patch starts to refactor MT7622 pinctrl driver first with splitting out these portable ways from there such as table-based register operation and the other operations in common in the both kinds of driver.
Sean Wang (19):
pinctrl: mediatek: add pinctrl-mtk-common-v2 for all MediaTek pinctrls
pinctrl: mediatek: add pinctrl-moore that implements the generic
pinctrl dt-bindings
pinctrl: mediatek: extend struct mtk_pin_field_calc to
pinctrl-mtk-common-v2.c
pinctrl: mediatek: extend struct mtk_pin_desc to
pinctrl-mtk-common-v2.c
pinctrl: mediatek: extend struct mtk_pin_soc to
pinctrl-mtk-common-v2.c
pinctrl: mediatek: add driving strength related support to
pinctrl-mtk-common-v2.c
pinctrl: mediatek: add drv register support to pinctrl-mtk-common-v2.c
pinctrl: mediatek: add pull related support to pinctrl-mtk-common-v2.c
pinctrl: mediatek: add advanced pull related support to
pinctrl-mtk-common-v2.c
pinctrl: mediatek: add ies register support to pinctrl-mtk-common-v2.c
pinctrl: mediatek: add pullen, pullsel register support to
pinctrl-mtk-common-v2.c
pinctrl: mediatek: add MT7623 pinctrl driver based on generic pinctrl
binding
pinctrl: mediatek: use pin descriptor all in pinctrl-mtk-common-v2.c
pinctrl: mediatek: add multiple register bases support to
pinctrl-mtk-common-v2.c
pinctrl: mediatek: adjust error code and message when some register
not supported is found
pinctrl: mediatek: extend struct mtk_pin_desc which per-pin driver
depends on
pinctrl: mediatek: extend advanced pull support in
pinctrl-mtk-common-v2.c
pinctrl: mediatek: extend eint build to pinctrl-mtk-common-v2.c
pinctrl: mediatek: add eint support to MT8183 pinctrl driver
Zhiyong Tao (3):
pinctrl: mediatek: add pinctrl-paris that implements the vendor
dt-bindings
pinctrl: mediatek: add MT8183 pinctrl driver
pintcrl: mediatek: add pull tweaks for I2C related pins on MT8183
drivers/pinctrl/mediatek/Kconfig | 41 +- drivers/pinctrl/mediatek/Makefile | 4 + drivers/pinctrl/mediatek/pinctrl-moore.c | 689 ++++++++ drivers/pinctrl/mediatek/pinctrl-moore.h | 53 + drivers/pinctrl/mediatek/pinctrl-mt7622.c | 1407 +++------------- drivers/pinctrl/mediatek/pinctrl-mt7623.c | 1441 ++++++++++++++++ drivers/pinctrl/mediatek/pinctrl-mt8183.c | 544 ++++++ drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.c | 670 ++++++++ drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.h | 288 ++++ drivers/pinctrl/mediatek/pinctrl-mtk-mt8183.h | 1916 ++++++++++++++++++++++ drivers/pinctrl/mediatek/pinctrl-paris.c | 906 ++++++++++ drivers/pinctrl/mediatek/pinctrl-paris.h | 65 + 12 files changed, 6833 insertions(+), 1191 deletions(-) create mode 100644 drivers/pinctrl/mediatek/pinctrl-moore.c create mode 100644 drivers/pinctrl/mediatek/pinctrl-moore.h create mode 100644 drivers/pinctrl/mediatek/pinctrl-mt7623.c create mode 100644 drivers/pinctrl/mediatek/pinctrl-mt8183.c create mode 100644 drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.c create mode 100644 drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.h create mode 100644 drivers/pinctrl/mediatek/pinctrl-mtk-mt8183.h create mode 100644 drivers/pinctrl/mediatek/pinctrl-paris.c create mode 100644 drivers/pinctrl/mediatek/pinctrl-paris.h
Signature · 1 line
2.7.4
PATCH v2 1/22 pinctrl: mediatek: add pinctrl-mtk-common-v2 for all MediaTek pinctrls
From: Sean Wang <[email protected]>
Irregular register arrangement and distinct logic access from various MediaTek SoCs would cause pinctrl-mtk-common to bloat and really hard to maintain in the future so that the patch creates pinctrl-mtk-common-v2 based on the core of mt7622-pinctrl.
The goals pinctrl-mtk-common-v2 want to achieve are to hopefully support all of MediaTek SoCs, and two kinds of dt-bindings being supported, Linux generic pinctrl dt-binding mt7622 supports and MediaTek per-pin dt-binding the other SoCs support the MT8183 and MT6765 incline to make use of.
The patch starts to refactor MT7622 pinctrl driver first with splitting out these portable ways from there such as table-based register operation and drive strength control that is common in both kinds of driver.
--- drivers/pinctrl/mediatek/Makefile | 2 +- drivers/pinctrl/mediatek/pinctrl-mt7622.c | 253 +---------------------- drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.c | 160 ++++++++++++++ drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.h | 108 ++++++++++ 4 files changed, 273 insertions(+), 250 deletions(-) create mode 100644 drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.c create mode 100644 drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.h
drivers/pinctrl/mediatek/Makefile +1 -1
@@ -8,6 +8,6 @@ obj-$(CONFIG_PINCTRL_MT2701) += pinctrl-mt2701.o obj-$(CONFIG_PINCTRL_MT2712) += pinctrl-mt2712.o obj-$(CONFIG_PINCTRL_MT8135) += pinctrl-mt8135.o obj-$(CONFIG_PINCTRL_MT8127) += pinctrl-mt8127.o -obj-$(CONFIG_PINCTRL_MT7622) += pinctrl-mt7622.o +obj-$(CONFIG_PINCTRL_MT7622) += pinctrl-mtk-common-v2.o pinctrl-mt7622.o obj-$(CONFIG_PINCTRL_MT8173) += pinctrl-mt8173.o obj-$(CONFIG_PINCTRL_MT6397) += pinctrl-mt6397.o
drivers/pinctrl/mediatek/pinctrl-mt7622.c +4 -249
281 lines not on this page · raw message
drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.c new file +160 -0
160 lines not on this page · raw message
drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.h new file +108 -0
108 lines not on this page · raw message
Signature · 1 line
2.7.4
PATCH v2 2/22 pinctrl: mediatek: add pinctrl-moore that implements the generic pinctrl dt-bindings
In reply to [email protected]From: Sean Wang <[email protected]>
Add a generic driver pinctrl-moore.c for MT762x SoC and any other SoC that would like to use generic dt-binding. The patch is furtherly refactored from pinctrl-mt7622.c that totally uses the functions back by the generic pinctrl core such as GENERIC_PINCONF, GENERIC_PINCTRL_GROUPS, and GENERIC_PINMUX_FUNCTIONS and its binding also completely follows up pinctrl-bindings.txt in Documentation/devicetree/bindings/pinctrl/ to implement.
--- drivers/pinctrl/mediatek/Kconfig | 19 +- drivers/pinctrl/mediatek/Makefile | 3 +- drivers/pinctrl/mediatek/pinctrl-moore.c | 687 ++++++++++++++++++++++++++++ drivers/pinctrl/mediatek/pinctrl-moore.h | 41 ++ drivers/pinctrl/mediatek/pinctrl-mt7622.c | 723 +----------------------------- 5 files changed, 754 insertions(+), 719 deletions(-) create mode 100644 drivers/pinctrl/mediatek/pinctrl-moore.c create mode 100644 drivers/pinctrl/mediatek/pinctrl-moore.h
drivers/pinctrl/mediatek/Kconfig +12 -7
@@ -3,7 +3,7 @@ menu "MediaTek pinctrl drivers" config EINT_MTK bool "MediaTek External Interrupt Support" - depends on PINCTRL_MTK || PINCTRL_MT7622 || COMPILE_TEST + depends on PINCTRL_MTK || PINCTRL_MTK_MOORE || COMPILE_TEST select IRQ_DOMAIN config PINCTRL_MTK
@@ -15,6 +15,15 @@ config PINCTRL_MTK select EINT_MTK select OF_GPIO +config PINCTRL_MTK_MOORE + bool "MediaTek Moore Core that implements generic binding" + depends on OF + select GENERIC_PINCONF + select GENERIC_PINCTRL_GROUPS + select GENERIC_PINMUX_FUNCTIONS + select GPIOLIB + select OF_GPIO + # For ARMv7 SoCs config PINCTRL_MT2701 bool "Mediatek MT2701 pin control"
@@ -47,13 +56,9 @@ config PINCTRL_MT2712 config PINCTRL_MT7622 bool "MediaTek MT7622 pin control" - depends on OF depends on ARM64 || COMPILE_TEST - select GENERIC_PINCONF - select GENERIC_PINCTRL_GROUPS - select GENERIC_PINMUX_FUNCTIONS - select GPIOLIB - select OF_GPIO + depends on PINCTRL_MTK_MOORE + default y config PINCTRL_MT8173 bool "Mediatek MT8173 pin control"
drivers/pinctrl/mediatek/Makefile +2 -1
@@ -2,12 +2,13 @@ # Core obj-$(CONFIG_EINT_MTK) += mtk-eint.o obj-$(CONFIG_PINCTRL_MTK) += pinctrl-mtk-common.o +obj-$(CONFIG_PINCTRL_MTK_MOORE) += pinctrl-moore.o pinctrl-mtk-common-v2.o # SoC Drivers obj-$(CONFIG_PINCTRL_MT2701) += pinctrl-mt2701.o obj-$(CONFIG_PINCTRL_MT2712) += pinctrl-mt2712.o obj-$(CONFIG_PINCTRL_MT8135) += pinctrl-mt8135.o obj-$(CONFIG_PINCTRL_MT8127) += pinctrl-mt8127.o -obj-$(CONFIG_PINCTRL_MT7622) += pinctrl-mtk-common-v2.o pinctrl-mt7622.o +obj-$(CONFIG_PINCTRL_MT7622) += pinctrl-mt7622.o obj-$(CONFIG_PINCTRL_MT8173) += pinctrl-mt8173.o obj-$(CONFIG_PINCTRL_MT6397) += pinctrl-mt6397.o
drivers/pinctrl/mediatek/pinctrl-moore.c new file +687 -0
687 lines not on this page · raw message
drivers/pinctrl/mediatek/pinctrl-moore.h new file +41 -0
41 lines not on this page · raw message
drivers/pinctrl/mediatek/pinctrl-mt7622.c +12 -711
750 lines not on this page · raw message
Signature · 1 line
2.7.4
PATCH v2 3/22 pinctrl: mediatek: extend struct mtk_pin_field_calc to pinctrl-mtk-common-v2.c
In reply to [email protected]From: Sean Wang <[email protected]>
This patch adds members sz_reg fixed in struct mtk_pin_field_calc
- The 'fixed' is used to represent the consecutive pins share the same bits within the same register with the 1st pin so that it can largely reduce the entry size a bit.
- The 'sz_reg' is used to indicate the range of bits we use in a register that may vary by SoC
The above changes make the code more generic and this is useful as there might be other existing or future chips all use the same logic to access their register set and then being a little more abstract could help in the long run.
--- drivers/pinctrl/mediatek/pinctrl-mt7622.c | 210 ++++++++++------------- drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.c | 17 +- drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.h | 25 +++ 3 files changed, 126 insertions(+), 126 deletions(-)
drivers/pinctrl/mediatek/pinctrl-mt7622.c +90 -120
@@ -9,159 +9,129 @@#include "pinctrl-moore.h" static const struct mtk_pin_field_calc mt7622_pin_mode_range[] = { - {0 ,0 ,0x320 ,0x10 ,16 ,4 }, - {1 ,4 ,0x3a0 ,0x10 ,16 ,4 }, - {5 ,5 ,0x320 ,0x10 ,0 ,4 }, - {6 ,6 ,0x300 ,0x10 ,4 ,4 }, - {7 ,7 ,0x300 ,0x10 ,4 ,4 }, - {8 ,9 ,0x350 ,0x10 ,20 ,4 }, - {10 ,10 ,0x300 ,0x10 ,8 ,4 }, - {11 ,11 ,0x300 ,0x10 ,8 ,4 }, - {12 ,12 ,0x300 ,0x10 ,8 ,4 }, - {13 ,13 ,0x300 ,0x10 ,8 ,4 }, - {14 ,15 ,0x320 ,0x10 ,4 ,4 }, - {16 ,17 ,0x320 ,0x10 ,20 ,4 }, - {18 ,21 ,0x310 ,0x10 ,16 ,4 }, - {22 ,22 ,0x380 ,0x10 ,16 ,4 }, - {23 ,23 ,0x300 ,0x10 ,24 ,4 }, - {24 ,24 ,0x300 ,0x10 ,24 ,4 }, - {25 ,25 ,0x300 ,0x10 ,12 ,4 }, - {25 ,25 ,0x300 ,0x10 ,12 ,4 }, - {26 ,26 ,0x300 ,0x10 ,12 ,4 }, - {27 ,27 ,0x300 ,0x10 ,12 ,4 }, - {28 ,28 ,0x300 ,0x10 ,12 ,4 }, - {29 ,29 ,0x300 ,0x10 ,12 ,4 }, - {30 ,30 ,0x300 ,0x10 ,12 ,4 }, - {31 ,31 ,0x300 ,0x10 ,12 ,4 }, - {32 ,32 ,0x300 ,0x10 ,12 ,4 }, - {33 ,33 ,0x300 ,0x10 ,12 ,4 }, - {34 ,34 ,0x300 ,0x10 ,12 ,4 }, - {35 ,35 ,0x300 ,0x10 ,12 ,4 }, - {36 ,36 ,0x300 ,0x10 ,12 ,4 }, - {37 ,37 ,0x300 ,0x10 ,20 ,4 }, - {38 ,38 ,0x300 ,0x10 ,20 ,4 }, - {39 ,39 ,0x300 ,0x10 ,20 ,4 }, - {40 ,40 ,0x300 ,0x10 ,20 ,4 }, - {41 ,41 ,0x300 ,0x10 ,20 ,4 }, - {42 ,42 ,0x300 ,0x10 ,20 ,4 }, - {43 ,43 ,0x300 ,0x10 ,20 ,4 }, - {44 ,44 ,0x300 ,0x10 ,20 ,4 }, - {45 ,46 ,0x300 ,0x10 ,20 ,4 }, - {47 ,47 ,0x300 ,0x10 ,20 ,4 }, - {48 ,48 ,0x300 ,0x10 ,20 ,4 }, - {49 ,49 ,0x300 ,0x10 ,20 ,4 }, - {50 ,50 ,0x300 ,0x10 ,20 ,4 }, - {51 ,70 ,0x330 ,0x10 ,4 ,4 }, - {71 ,71 ,0x300 ,0x10 ,16 ,4 }, - {72 ,72 ,0x300 ,0x10 ,16 ,4 }, - {73 ,76 ,0x310 ,0x10 ,0 ,4 }, - {77 ,77 ,0x320 ,0x10 ,28 ,4 }, - {78 ,78 ,0x320 ,0x10 ,12 ,4 }, - {79 ,82 ,0x3a0 ,0x10 ,0 ,4 }, - {83 ,83 ,0x350 ,0x10 ,28 ,4 }, - {84 ,84 ,0x330 ,0x10 ,0 ,4 }, - {85 ,90 ,0x360 ,0x10 ,4 ,4 }, - {91 ,94 ,0x390 ,0x10 ,16 ,4 }, - {95 ,97 ,0x380 ,0x10 ,20 ,4 }, - {98 ,101 ,0x390 ,0x10 ,0 ,4 }, - {102 ,102 ,0x360 ,0x10 ,0 ,4 }, +PIN_FIELD (0 ,0 ,0x320 ,0x10 ,16 ,4 ), +PIN_FIELD (1 ,4 ,0x3a0 ,0x10 ,16 ,4 ), +PIN_FIELD (5 ,5 ,0x320 ,0x10 ,0 ,4 ), +PINS_FIELD (6 ,7 ,0x300 ,0x10 ,4 ,4 ), +PIN_FIELD (8 ,9 ,0x350 ,0x10 ,20 ,4 ), +PINS_FIELD (10 ,13 ,0x300 ,0x10 ,8 ,4 ), +PIN_FIELD (14 ,15 ,0x320 ,0x10 ,4 ,4 ), +PIN_FIELD (16 ,17 ,0x320 ,0x10 ,20 ,4 ), +PIN_FIELD (18 ,21 ,0x310 ,0x10 ,16 ,4 ), +PIN_FIELD (22 ,22 ,0x380 ,0x10 ,16 ,4 ), +PINS_FIELD (23 ,24 ,0x300 ,0x10 ,24 ,4 ), +PINS_FIELD (25 ,36 ,0x300 ,0x10 ,12 ,4 ), +PINS_FIELD (37 ,50 ,0x300 ,0x10 ,20 ,4 ), +PIN_FIELD (51 ,70 ,0x330 ,0x10 ,4 ,4 ), +PINS_FIELD (71 ,72 ,0x300 ,0x10 ,16 ,4 ), +PIN_FIELD (73 ,76 ,0x310 ,0x10 ,0 ,4 ), +PIN_FIELD (77 ,77 ,0x320 ,0x10 ,28 ,4 ), +PIN_FIELD (78 ,78 ,0x320 ,0x10 ,12 ,4 ), +PIN_FIELD (79 ,82 ,0x3a0 ,0x10 ,0 ,4 ), +PIN_FIELD (83 ,83 ,0x350 ,0x10 ,28 ,4 ), +PIN_FIELD (84 ,84 ,0x330 ,0x10 ,0 ,4 ), +PIN_FIELD (85 ,90 ,0x360 ,0x10 ,4 ,4 ), +PIN_FIELD (91 ,94 ,0x390 ,0x10 ,16 ,4 ), +PIN_FIELD (95 ,97 ,0x380 ,0x10 ,20 ,4 ), +PIN_FIELD (98 ,101 ,0x390 ,0x10 ,0 ,4 ), +PIN_FIELD (102 ,102 ,0x360 ,0x10 ,0 ,4 ), };static const struct mtk_pin_field_calc mt7622_pin_dir_range[] = { - {0 ,102 ,0x0 ,0x10 ,0 ,1 }, +PIN_FIELD (0 ,102 ,0x0 ,0x10 ,0 ,1 ), };static const struct mtk_pin_field_calc mt7622_pin_di_range[] = { - {0 ,102 ,0x200 ,0x10 ,0 ,1 }, +PIN_FIELD (0 ,102 ,0x200 ,0x10 ,0 ,1 ), };static const struct mtk_pin_field_calc mt7622_pin_do_range[] = { - {0 ,102 ,0x100 ,0x10 ,0 ,1 }, +PIN_FIELD (0 ,102 ,0x100 ,0x10 ,0 ,1 ), };static const struct mtk_pin_field_calc mt7622_pin_sr_range[] = { - {0 ,31 ,0x910 ,0x10 ,0 ,1 }, - {32 ,50 ,0xa10 ,0x10 ,0 ,1 }, - {51 ,70 ,0x810 ,0x10 ,0 ,1 }, - {71 ,72 ,0xb10 ,0x10 ,0 ,1 }, - {73 ,86 ,0xb10 ,0x10 ,4 ,1 }, - {87 ,90 ,0xc10 ,0x10 ,0 ,1 }, - {91 ,102 ,0xb10 ,0x10 ,18 ,1 }, +PIN_FIELD (0 ,31 ,0x910 ,0x10 ,0 ,1 ), +PIN_FIELD (32 ,50 ,0xa10 ,0x10 ,0 ,1 ), +PIN_FIELD (51 ,70 ,0x810 ,0x10 ,0 ,1 ), +PIN_FIELD (71 ,72 ,0xb10 ,0x10 ,0 ,1 ), +PIN_FIELD (73 ,86 ,0xb10 ,0x10 ,4 ,1 ), +PIN_FIELD (87 ,90 ,0xc10 ,0x10 ,0 ,1 ), +PIN_FIELD (91 ,102 ,0xb10 ,0x10 ,18 ,1 ), };static const struct mtk_pin_field_calc mt7622_pin_smt_range[] = { - {0 ,31 ,0x920 ,0x10 ,0 ,1 }, - {32 ,50 ,0xa20 ,0x10 ,0 ,1 }, - {51 ,70 ,0x820 ,0x10 ,0 ,1 }, - {71 ,72 ,0xb20 ,0x10 ,0 ,1 }, - {73 ,86 ,0xb20 ,0x10 ,4 ,1 }, - {87 ,90 ,0xc20 ,0x10 ,0 ,1 }, - {91 ,102 ,0xb20 ,0x10 ,18 ,1 }, +PIN_FIELD (0 ,31 ,0x920 ,0x10 ,0 ,1 ), +PIN_FIELD (32 ,50 ,0xa20 ,0x10 ,0 ,1 ), +PIN_FIELD (51 ,70 ,0x820 ,0x10 ,0 ,1 ), +PIN_FIELD (71 ,72 ,0xb20 ,0x10 ,0 ,1 ), +PIN_FIELD (73 ,86 ,0xb20 ,0x10 ,4 ,1 ), +PIN_FIELD (87 ,90 ,0xc20 ,0x10 ,0 ,1 ), +PIN_FIELD (91 ,102 ,0xb20 ,0x10 ,18 ,1 ), };static const struct mtk_pin_field_calc mt7622_pin_pu_range[] = { - {0 ,31 ,0x930 ,0x10 ,0 ,1 }, - {32 ,50 ,0xa30 ,0x10 ,0 ,1 }, - {51 ,70 ,0x830 ,0x10 ,0 ,1 }, - {71 ,72 ,0xb30 ,0x10 ,0 ,1 }, - {73 ,86 ,0xb30 ,0x10 ,4 ,1 }, - {87 ,90 ,0xc30 ,0x10 ,0 ,1 }, - {91 ,102 ,0xb30 ,0x10 ,18 ,1 }, +PIN_FIELD (0 ,31 ,0x930 ,0x10 ,0 ,1 ), +PIN_FIELD (32 ,50 ,0xa30 ,0x10 ,0 ,1 ), +PIN_FIELD (51 ,70 ,0x830 ,0x10 ,0 ,1 ), +PIN_FIELD (71 ,72 ,0xb30 ,0x10 ,0 ,1 ), +PIN_FIELD (73 ,86 ,0xb30 ,0x10 ,4 ,1 ), +PIN_FIELD (87 ,90 ,0xc30 ,0x10 ,0 ,1 ), +PIN_FIELD (91 ,102 ,0xb30 ,0x10 ,18 ,1 ), };static const struct mtk_pin_field_calc mt7622_pin_pd_range[] = { - {0 ,31 ,0x940 ,0x10 ,0 ,1 }, - {32 ,50 ,0xa40 ,0x10 ,0 ,1 }, - {51 ,70 ,0x840 ,0x10 ,0 ,1 }, - {71 ,72 ,0xb40 ,0x10 ,0 ,1 }, - {73 ,86 ,0xb40 ,0x10 ,4 ,1 }, - {87 ,90 ,0xc40 ,0x10 ,0 ,1 }, - {91 ,102 ,0xb40 ,0x10 ,18 ,1 }, +PIN_FIELD (0 ,31 ,0x940 ,0x10 ,0 ,1 ), +PIN_FIELD (32 ,50 ,0xa40 ,0x10 ,0 ,1 ), +PIN_FIELD (51 ,70 ,0x840 ,0x10 ,0 ,1 ), +PIN_FIELD (71 ,72 ,0xb40 ,0x10 ,0 ,1 ), +PIN_FIELD (73 ,86 ,0xb40 ,0x10 ,4 ,1 ), +PIN_FIELD (87 ,90 ,0xc40 ,0x10 ,0 ,1 ), +PIN_FIELD (91 ,102 ,0xb40 ,0x10 ,18 ,1 ), };static const struct mtk_pin_field_calc mt7622_pin_e4_range[] = { - {0 ,31 ,0x960 ,0x10 ,0 ,1 }, - {32 ,50 ,0xa60 ,0x10 ,0 ,1 }, - {51 ,70 ,0x860 ,0x10 ,0 ,1 }, - {71 ,72 ,0xb60 ,0x10 ,0 ,1 }, - {73 ,86 ,0xb60 ,0x10 ,4 ,1 }, - {87 ,90 ,0xc60 ,0x10 ,0 ,1 }, - {91 ,102 ,0xb60 ,0x10 ,18 ,1 }, +PIN_FIELD (0 ,31 ,0x960 ,0x10 ,0 ,1 ), +PIN_FIELD (32 ,50 ,0xa60 ,0x10 ,0 ,1 ), +PIN_FIELD (51 ,70 ,0x860 ,0x10 ,0 ,1 ), +PIN_FIELD (71 ,72 ,0xb60 ,0x10 ,0 ,1 ), +PIN_FIELD (73 ,86 ,0xb60 ,0x10 ,4 ,1 ), +PIN_FIELD (87 ,90 ,0xc60 ,0x10 ,0 ,1 ), +PIN_FIELD (91 ,102 ,0xb60 ,0x10 ,18 ,1 ), };static const struct mtk_pin_field_calc mt7622_pin_e8_range[] = { - {0 ,31 ,0x970 ,0x10 ,0 ,1 }, - {32 ,50 ,0xa70 ,0x10 ,0 ,1 }, - {51 ,70 ,0x870 ,0x10 ,0 ,1 }, - {71 ,72 ,0xb70 ,0x10 ,0 ,1 }, - {73 ,86 ,0xb70 ,0x10 ,4 ,1 }, - {87 ,90 ,0xc70 ,0x10 ,0 ,1 }, - {91 ,102 ,0xb70 ,0x10 ,18 ,1 }, +PIN_FIELD (0 ,31 ,0x970 ,0x10 ,0 ,1 ), +PIN_FIELD (32 ,50 ,0xa70 ,0x10 ,0 ,1 ), +PIN_FIELD (51 ,70 ,0x870 ,0x10 ,0 ,1 ), +PIN_FIELD (71 ,72 ,0xb70 ,0x10 ,0 ,1 ), +PIN_FIELD (73 ,86 ,0xb70 ,0x10 ,4 ,1 ), +PIN_FIELD (87 ,90 ,0xc70 ,0x10 ,0 ,1 ), +PIN_FIELD (91 ,102 ,0xb70 ,0x10 ,18 ,1 ), };static const struct mtk_pin_field_calc mt7622_pin_tdsel_range[] = { - {0 ,31 ,0x980 ,0x4 ,0 ,4 }, - {32 ,50 ,0xa80 ,0x4 ,0 ,4 }, - {51 ,70 ,0x880 ,0x4 ,0 ,4 }, - {71 ,72 ,0xb80 ,0x4 ,0 ,4 }, - {73 ,86 ,0xb80 ,0x4 ,16 ,4 }, - {87 ,90 ,0xc80 ,0x4 ,0 ,4 }, - {91 ,102 ,0xb88 ,0x4 ,8 ,4 }, +PIN_FIELD (0 ,31 ,0x980 ,0x4 ,0 ,4 ), +PIN_FIELD (32 ,50 ,0xa80 ,0x4 ,0 ,4 ), +PIN_FIELD (51 ,70 ,0x880 ,0x4 ,0 ,4 ), +PIN_FIELD (71 ,72 ,0xb80 ,0x4 ,0 ,4 ), +PIN_FIELD (73 ,86 ,0xb80 ,0x4 ,16 ,4 ), +PIN_FIELD (87 ,90 ,0xc80 ,0x4 ,0 ,4 ), +PIN_FIELD (91 ,102 ,0xb88 ,0x4 ,8 ,4 ), };static const struct mtk_pin_field_calc mt7622_pin_rdsel_range[] = { - {0 ,31 ,0x990 ,0x4 ,0 ,6 }, - {32 ,50 ,0xa90 ,0x4 ,0 ,6 }, - {51 ,58 ,0x890 ,0x4 ,0 ,6 }, - {59 ,60 ,0x894 ,0x4 ,28 ,6 }, - {61 ,62 ,0x894 ,0x4 ,16 ,6 }, - {63 ,66 ,0x898 ,0x4 ,8 ,6 }, - {67 ,68 ,0x89c ,0x4 ,12 ,6 }, - {69 ,70 ,0x89c ,0x4 ,0 ,6 }, - {71 ,72 ,0xb90 ,0x4 ,0 ,6 }, - {73 ,86 ,0xb90 ,0x4 ,24 ,6 }, - {87 ,90 ,0xc90 ,0x4 ,0 ,6 }, - {91 ,102 ,0xb9c ,0x4 ,12 ,6 }, +PIN_FIELD (0 ,31 ,0x990 ,0x4 ,0 ,6 ), +PIN_FIELD (32 ,50 ,0xa90 ,0x4 ,0 ,6 ), +PIN_FIELD (51 ,58 ,0x890 ,0x4 ,0 ,6 ), +PIN_FIELD (59 ,60 ,0x894 ,0x4 ,28 ,6 ), +PIN_FIELD (61 ,62 ,0x894 ,0x4 ,16 ,6 ), +PIN_FIELD (63 ,66 ,0x898 ,0x4 ,8 ,6 ), +PIN_FIELD (67 ,68 ,0x89c ,0x4 ,12 ,6 ), +PIN_FIELD (69 ,70 ,0x89c ,0x4 ,0 ,6 ), +PIN_FIELD (71 ,72 ,0xb90 ,0x4 ,0 ,6 ), +PIN_FIELD (73 ,86 ,0xb90 ,0x4 ,24 ,6 ), +PIN_FIELD (87 ,90 ,0xc90 ,0x4 ,0 ,6 ), +PIN_FIELD (91 ,102 ,0xb9c ,0x4 ,12 ,6 ), };static const struct mtk_pin_reg_calc mt7622_reg_cals[PINCTRL_PIN_REG_MAX ] = {
drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.c +11 -6
@@ -54,19 +54,24 @@ static int mtk_hw_pin_field_lookup(struct mtk_pinctrl *hw, int pin,return -EINVAL ; } -/* Caculated bits as the overall offset the pin is located at */ - bits = c->s_bit + (pin - c->s_pin) * (c->x_bits); +/* Calculated bits as the overall offset the pin is located at, +* if c->fixed is held, that determines the all the pins in the +* range use the same field with the s_pin. +*/ + bits = c->fixed ? c->s_bit : c->s_bit + (pin - c->s_pin) * (c->x_bits); -/* Fill pfd from bits and 32-bit register applied is assumed */ - pfd->offset = c->s_addr + c->x_addrs * (bits /32 ); - pfd->bitpos = bits %32 ; +/* Fill pfd from bits. For example 32-bit register applied is assumed +* when c->sz_reg is equal to 32. +*/ + pfd->offset = c->s_addr + c->x_addrs * (bits / c->sz_reg); + pfd->bitpos = bits % c->sz_reg; pfd->mask = (1 << c->x_bits) -1 ;/* pfd->next is used for indicating that bit wrapping-around happens * which requires the manipulation for bit 0 starting in the next * register to form the complete field read/write. */ - pfd->next = pfd->bitpos + c->x_bits -1 >31 ? c->x_addrs :0 ; + pfd->next = pfd->bitpos + c->x_bits > c->sz_reg ? c->x_addrs :0 ;return 0 ; }
drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.h +25 -0
@@ -15,6 +15,26 @@#define MTK_DISABLE 0#define MTK_ENABLE 1 +#define PIN_FIELD_CALC (_s_pin, _e_pin, _s_addr, _x_addrs, _s_bit, \ + _x_bits, _sz_reg, _fixed) { \ + .s_pin = _s_pin, \ + .e_pin = _e_pin, \ + .s_addr = _s_addr, \ + .x_addrs = _x_addrs, \ + .s_bit = _s_bit, \ + .x_bits = _x_bits, \ + .sz_reg = _sz_reg, \ + .fixed = _fixed, \ + } + +#define PIN_FIELD (_s_pin, _e_pin, _s_addr, _x_addrs, _s_bit, _x_bits) \ + PIN_FIELD_CALC(_s_pin, _e_pin, _s_addr, _x_addrs, _s_bit, \ + _x_bits, 32, 0) + +#define PINS_FIELD (_s_pin, _e_pin, _s_addr, _x_addrs, _s_bit, _x_bits) \ + PIN_FIELD_CALC(_s_pin, _e_pin, _s_addr, _x_addrs, _s_bit, \ + _x_bits, 32, 1) +/* List these attributes which could be modified for the pin */ enum {PINCTRL_PIN_REG_MODE ,
@@ -57,6 +77,9 @@ struct mtk_pin_field {* @s_bit: the start bit for the first register within the range * @x_bits: the bit distance between two consecutive pins within * the range +* @sz_reg: the size of bits in a register +* @fixed: the consecutive pins share the same bits with the 1st +* pin */ struct mtk_pin_field_calc {u16 s_pin;
@@ -65,6 +88,8 @@ struct mtk_pin_field_calc {u8 x_addrs;u8 s_bit;u8 x_bits; +u8 sz_reg; +u8 fixed; };/* struct mtk_pin_reg_calc - the structure that holds all ranges used to
Signature · 1 line
2.7.4
PATCH v2 4/22 pinctrl: mediatek: extend struct mtk_pin_desc to pinctrl-mtk-common-v2.c
In reply to [email protected]From: Sean Wang <[email protected]>
This patch introduces a data structure mtk_pin_desc, which is used to provide information per pin characteristic such as driving current, eint number and a driving index, that is used to lookup table describing the details about the groups of driving current by which the pin is able to adjust the driving strength so that the driver could get the appropriate driving group when calls .pin_config_get()/set().
--- drivers/pinctrl/mediatek/pinctrl-moore.c | 49 ++++-- drivers/pinctrl/mediatek/pinctrl-moore.h | 8 + drivers/pinctrl/mediatek/pinctrl-mt7622.c | 213 ++++++++++++----------- drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.h | 28 +++ 4 files changed, 183 insertions(+), 115 deletions(-)
drivers/pinctrl/mediatek/pinctrl-moore.c +39 -10
@@ -402,31 +402,36 @@ static int mtk_gpio_direction_output(struct gpio_chip *chip, unsigned int gpio,static int mtk_gpio_to_irq (struct gpio_chip *chip,unsigned int offset) {struct mtk_pinctrl *hw =gpiochip_get_data (chip); -unsigned long eint_n; +const struct mtk_pin_desc *desc;if (!hw->eint)return -ENOTSUPP ; - eint_n = offset; + desc = (const struct mtk_pin_desc *)&hw->soc->pins[offset]; -return mtk_eint_find_irq (hw->eint, eint_n); +if (desc->eint_n ==EINT_NA ) +return -ENOTSUPP ; + +return mtk_eint_find_irq (hw->eint, desc->eint_n); }static int mtk_gpio_set_config (struct gpio_chip *chip,unsigned int offset,unsigned long config) {struct mtk_pinctrl *hw =gpiochip_get_data (chip); -unsigned long eint_n; +const struct mtk_pin_desc *desc;u32 debounce; + desc = (const struct mtk_pin_desc *)&hw->soc->pins[offset]; +if (!hw->eint || -pinconf_to_config_param (config) !=PIN_CONFIG_INPUT_DEBOUNCE ) +pinconf_to_config_param (config) !=PIN_CONFIG_INPUT_DEBOUNCE || + desc->eint_n ==EINT_NA )return -ENOTSUPP ; debounce =pinconf_to_config_argument (config); - eint_n = offset; -return mtk_eint_set_debounce (hw->eint, eint_n, debounce); +return mtk_eint_set_debounce (hw->eint, desc->eint_n, debounce); }static int mtk_build_gpiochip (struct mtk_pinctrl *hw,struct device_node *np)
@@ -513,16 +518,40 @@ static int mtk_build_functions(struct mtk_pinctrl *hw)return 0 ; } +static int mtk_xt_find_eint_num (struct mtk_pinctrl *hw, +unsigned long eint_n) +{ +const struct mtk_pin_desc *desc; +int i =0 ; + + desc = (const struct mtk_pin_desc *)hw->soc->pins; + +while (i < hw->soc->npins) { +if (desc[i].eint_n == eint_n) +return desc[i].number; + i++; + } + +return EINT_NA ; +} +static int mtk_xt_get_gpio_n (void *data,unsigned long eint_n,unsigned int *gpio_n,struct gpio_chip **gpio_chip) {struct mtk_pinctrl *hw = (struct mtk_pinctrl *)data; +const struct mtk_pin_desc *desc; + desc = (const struct mtk_pin_desc *)hw->soc->pins; *gpio_chip = &hw->chip; - *gpio_n = eint_n; -return 0 ; +/* Be greedy to guess first gpio_n is equal to eint_n */ +if (desc[eint_n].eint_n == eint_n) + *gpio_n = eint_n; +else + *gpio_n =mtk_xt_find_eint_num (hw, eint_n); + +return *gpio_n ==EINT_NA ? -EINVAL :0 ; }static int mtk_xt_get_gpio_state (void *data,unsigned long eint_n)
@@ -635,7 +664,7 @@ int mtk_moore_pinctrl_probe(struct platform_device *pdev,return PTR_ERR (hw->base);/* Setup pins descriptions per SoC types */ - mtk_desc.pins = hw->soc->pins; + mtk_desc.pins = (const struct pinctrl_pin_desc *)hw->soc->pins; mtk_desc.npins = hw->soc->npins; mtk_desc.num_custom_params =ARRAY_SIZE (mtk_custom_bindings); mtk_desc.custom_params = mtk_custom_bindings;
drivers/pinctrl/mediatek/pinctrl-moore.h +8 -0
@@ -27,6 +27,14 @@#include "pinctrl-mtk-common-v2.h" #define MTK_RANGE (_a) { .range = (_a), .nranges = ARRAY_SIZE(_a), } + +#define MTK_PIN (_number, _name, _eint_n, _drv_n) { \ + .number = _number, \ + .name = _name, \ + .eint_n = _eint_n, \ + .drv_n = _drv_n, \ + } +#define PINCTRL_PIN_GROUP (name, id) \ { \ name, \
drivers/pinctrl/mediatek/pinctrl-mt7622.c +108 -105
231 lines not on this page · raw message
drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.h +28 -0
@@ -15,6 +15,8 @@#define MTK_DISABLE 0#define MTK_ENABLE 1 +#define EINT_NA -1 +#define PIN_FIELD_CALC (_s_pin, _e_pin, _s_addr, _x_addrs, _s_bit, \ _x_bits, _sz_reg, _fixed) { \ .s_pin = _s_pin, \
@@ -52,6 +54,17 @@ enum { PINCTRL_PIN_REG_MAX, }; +/* Group the pins by the driving current */ +enum { +DRV_FIXED , +DRV_GRP0 , +DRV_GRP1 , +DRV_GRP2 , +DRV_GRP3 , +DRV_GRP4 , +DRV_GRP_MAX , +}; +/* struct mtk_pin_field - the structure that holds the information of the field * used to describe the attribute for the pin * @offset: the register offset relative to the base address
@@ -103,6 +116,21 @@ struct mtk_pin_reg_calc {unsigned int nranges; }; +/** +* struct mtk_pin_desc - the structure that providing information +* for each pin of chips +* @number: unique pin number from the global pin number space +* @name: name for this pin +* @eint_n: the eint number for this pin +* @drv_n: the index with the driving group +*/ +struct mtk_pin_desc { +unsigned int number; +const char *name; +u16 eint_n; +u8 drv_n; +}; +/* struct mtk_pin_soc - the structure that holds SoC-specific data */ struct mtk_pin_soc {const struct mtk_pin_reg_calc *reg_cal;
Signature · 1 line
2.7.4
PATCH v2 5/22 pinctrl: mediatek: extend struct mtk_pin_soc to pinctrl-mtk-common-v2.c
In reply to [email protected]From: Sean Wang <[email protected]>
Add two parameters gpio_m and eint_m for configuring GPIO mode and EINT mode, they might be varying depend on SoC.
--- drivers/pinctrl/mediatek/pinctrl-moore.c | 4 ++-- drivers/pinctrl/mediatek/pinctrl-mt7622.c | 2 ++ drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.h | 5 ++++- 3 files changed, 8 insertions(+), 3 deletions(-)
drivers/pinctrl/mediatek/pinctrl-moore.c +2 -2
@@ -63,7 +63,7 @@ static int mtk_pinmux_gpio_request_enable(struct pinctrl_dev *pctldev, {struct mtk_pinctrl *hw =pinctrl_dev_get_drvdata (pctldev); -return mtk_hw_set_value (hw, pin,PINCTRL_PIN_REG_MODE ,MTK_GPIO_MODE ); +return mtk_hw_set_value (hw, pin,PINCTRL_PIN_REG_MODE , hw->soc->gpio_m); } static int mtk_pinmux_gpio_set_direction(struct pinctrl_dev *pctldev,
@@ -580,7 +580,7 @@ static int mtk_xt_set_gpio_as_eint(void *data, unsigned long eint_n)return err; err =mtk_hw_set_value (hw, gpio_n,PINCTRL_PIN_REG_MODE , -MTK_GPIO_MODE ); + hw->soc->eint_m);if (err)return err;
drivers/pinctrl/mediatek/pinctrl-mt7622.c +2 -0
@@ -765,6 +765,8 @@ static const struct mtk_pin_soc mt7622_data = { .funcs = mt7622_functions, .nfuncs = ARRAY_SIZE(mt7622_functions), .eint_hw = &mt7622_eint_hw, + .gpio_m = 1, + .eint_m = 1, };static const struct of_device_id mt7622_pinctrl_of_match[] = {
drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.h +4 -1
@@ -9,7 +9,6 @@#ifndef __PINCTRL_MTK_COMMON_V2_H#define __PINCTRL_MTK_COMMON_V2_H -#define MTK_GPIO_MODE 1#define MTK_INPUT 0#define MTK_OUTPUT 1#define MTK_DISABLE 0
@@ -142,6 +141,10 @@ struct mtk_pin_soc {unsigned int nfuncs;const struct mtk_eint_regs *eint_regs;const struct mtk_eint_hw *eint_hw; + +/* Specific parameters per SoC */ +u8 gpio_m; +u8 eint_m; };struct mtk_pinctrl {
Signature · 1 line
2.7.4
PATCH v2 6/22 pinctrl: mediatek: add driving strength related support to pinctrl-mtk-common-v2.c
In reply to [email protected]From: Sean Wang <[email protected]>
Put driving strength support related functions to pinctrl-mtk-common-v2.c as these operations might be different by chips and allow different type of driver to reuse them.
--- drivers/pinctrl/mediatek/pinctrl-moore.c | 48 +++++--------- drivers/pinctrl/mediatek/pinctrl-mt7622.c | 2 + drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.c | 79 ++++++++++++++++++++++++ drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.h | 14 +++++ 4 files changed, 112 insertions(+), 31 deletions(-)
drivers/pinctrl/mediatek/pinctrl-moore.c +17 -31
@@ -82,6 +82,9 @@ static int mtk_pinconf_get(struct pinctrl_dev *pctldev,struct mtk_pinctrl *hw =pinctrl_dev_get_drvdata (pctldev);u32 param =pinconf_to_config_param (*config);int val, val2, err, reg, ret =1 ; +const struct mtk_pin_desc *desc; + + desc = (const struct mtk_pin_desc *)&hw->soc->pins[pin];switch (param) {case PIN_CONFIG_BIAS_DISABLE :
@@ -139,19 +142,13 @@ static int mtk_pinconf_get(struct pinctrl_dev *pctldev,break ;case PIN_CONFIG_DRIVE_STRENGTH : - err =mtk_hw_get_value (hw, pin,PINCTRL_PIN_REG_E4 , &val); -if (err) -return err; - - err =mtk_hw_get_value (hw, pin,PINCTRL_PIN_REG_E8 , &val2); -if (err) -return err; - -/* 4mA when (e8, e4) = (0, 0); 8mA when (e8, e4) = (0, 1) -* 12mA when (e8, e4) = (1, 0); 16mA when (e8, e4) = (1, 1) -*/ - ret = ((val2 <<1 ) + val +1 ) *4 ; - +if (hw->soc->drive_get) { + err = hw->soc->drive_get (hw, desc, &ret); +if (err) +return err; + }else { + err = -ENOTSUPP ; + }break ;case MTK_PIN_CONFIG_TDSEL :case MTK_PIN_CONFIG_RDSEL :
@@ -178,9 +175,12 @@ static int mtk_pinconf_set(struct pinctrl_dev *pctldev, unsigned int pin, unsigned long *configs, unsigned int num_configs) { struct mtk_pinctrl *hw = pinctrl_dev_get_drvdata(pctldev); +const struct mtk_pin_desc *desc;u32 reg, param, arg;int cfg, err =0 ; + desc = (const struct mtk_pin_desc *)&hw->soc->pins[pin]; +for (cfg =0 ; cfg < num_configs; cfg++) { param =pinconf_to_config_param (configs[cfg]); arg =pinconf_to_config_argument (configs[cfg]);
@@ -247,24 +247,10 @@ static int mtk_pinconf_set(struct pinctrl_dev *pctldev, unsigned int pin, goto err;break ;case PIN_CONFIG_DRIVE_STRENGTH : -/* 4mA when (e8, e4) = (0, 0); -* 8mA when (e8, e4) = (0, 1); -* 12mA when (e8, e4) = (1, 0); -* 16mA when (e8, e4) = (1, 1) -*/ -if (!(arg %4 ) && (arg >=4 && arg <=16 )) { - arg = arg /4 -1 ; - err =mtk_hw_set_value (hw, pin, -PINCTRL_PIN_REG_E4 , - arg &0x1 ); -if (err) - goto err; - - err =mtk_hw_set_value (hw, pin, -PINCTRL_PIN_REG_E8 , - (arg &0x2 ) >>1 ); -if (err) - goto err; +if (hw->soc->drive_set) { + err = hw->soc->drive_set (hw, desc, arg); +if (err) +return err; }else { err = -ENOTSUPP ; }
drivers/pinctrl/mediatek/pinctrl-mt7622.c +2 -0
@@ -767,6 +767,8 @@ static const struct mtk_pin_soc mt7622_data = { .eint_hw = &mt7622_eint_hw, .gpio_m = 1, .eint_m = 1, + .drive_set = mtk_pinconf_drive_set, + .drive_get = mtk_pinconf_drive_get, };static const struct of_device_id mt7622_pinctrl_of_match[] = {
drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.c +79 -0
88 lines not on this page · raw message
drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.h +14 -0
@@ -50,6 +50,7 @@ enum {PINCTRL_PIN_REG_E8 ,PINCTRL_PIN_REG_TDSEL ,PINCTRL_PIN_REG_RDSEL , +PINCTRL_PIN_REG_DRV , PINCTRL_PIN_REG_MAX, };
@@ -130,6 +131,8 @@ struct mtk_pin_desc {u8 drv_n; }; +struct mtk_pinctrl ; +/* struct mtk_pin_soc - the structure that holds SoC-specific data */ struct mtk_pin_soc {const struct mtk_pin_reg_calc *reg_cal;
@@ -145,6 +148,12 @@ struct mtk_pin_soc {/* Specific parameters per SoC */ u8 gpio_m;u8 eint_m; + +/* Specific pinconfig operations */ +int (*drive_set)(struct mtk_pinctrl *hw, +const struct mtk_pin_desc *desc,u32 arg); +int (*drive_get)(struct mtk_pinctrl *hw, +const struct mtk_pin_desc *desc,int *val); };struct mtk_pinctrl {
@@ -161,4 +170,9 @@ void mtk_rmw(struct mtk_pinctrl *pctl, u32 reg, u32 mask, u32 set);int mtk_hw_set_value (struct mtk_pinctrl *hw,int pin,int field,int value);int mtk_hw_get_value (struct mtk_pinctrl *hw,int pin,int field,int *value); +int mtk_pinconf_drive_set (struct mtk_pinctrl *hw, +const struct mtk_pin_desc *desc,u32 arg); +int mtk_pinconf_drive_get (struct mtk_pinctrl *hw, +const struct mtk_pin_desc *desc,int *val); +#endif /* __PINCTRL_MTK_COMMON_V2_H */
Signature · 1 line
2.7.4
PATCH v2 7/22 pinctrl: mediatek: add drv register support to pinctrl-mtk-common-v2.c
In reply to [email protected]From: Sean Wang <[email protected]>
Certain SoCs have to program DRV register to configure driving strength so that we add it in the existing path as an option.
--- drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.c | 38 ++++++++++++++++++++++++ drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.h | 5 ++++ 2 files changed, 43 insertions(+)
drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.c +38 -0
@@ -242,3 +242,41 @@ int mtk_pinconf_drive_get(struct mtk_pinctrl *hw,return 0 ; } + +/* Revision 1 */ +int mtk_pinconf_drive_set_rev1 (struct mtk_pinctrl *hw, +const struct mtk_pin_desc *desc,u32 arg) +{ +const struct mtk_drive_desc *tb; +int err = -ENOTSUPP ; + + tb = &mtk_drive[desc->drv_n]; + +if ((arg >= tb->min && arg <= tb->max) && !(arg % tb->step)) { + arg = (arg / tb->step -1 ) * tb->scal; + + err =mtk_hw_set_value (hw, desc->number,PINCTRL_PIN_REG_DRV , + arg); +if (err) +return err; + } + +return err; +} + +int mtk_pinconf_drive_get_rev1 (struct mtk_pinctrl *hw, +const struct mtk_pin_desc *desc,int *val) +{ +const struct mtk_drive_desc *tb; +int err, val1; + + tb = &mtk_drive[desc->drv_n]; + + err =mtk_hw_get_value (hw, desc->number,PINCTRL_PIN_REG_DRV , &val1); +if (err) +return err; + + *val = ((val1 &0x7 ) / tb->scal +1 ) * tb->step; + +return 0 ; +}
drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.h +5 -0
@@ -175,4 +175,9 @@ int mtk_pinconf_drive_set(struct mtk_pinctrl *hw,int mtk_pinconf_drive_get (struct mtk_pinctrl *hw,const struct mtk_pin_desc *desc,int *val); +int mtk_pinconf_drive_set_rev1 (struct mtk_pinctrl *hw, +const struct mtk_pin_desc *desc,u32 arg); +int mtk_pinconf_drive_get_rev1 (struct mtk_pinctrl *hw, +const struct mtk_pin_desc *desc,int *val); +#endif /* __PINCTRL_MTK_COMMON_V2_H */
Signature · 1 line
2.7.4
PATCH v2 8/22 pinctrl: mediatek: add pull related support to pinctrl-mtk-common-v2.c
In reply to [email protected]From: Sean Wang <[email protected]>
Put pull control support related functions to pinctrl-mtk-common-v2.c as these operations might be different by chips and allow different type of driver to reuse them.
--- drivers/pinctrl/mediatek/pinctrl-moore.c | 76 ++++++++++++++--------- drivers/pinctrl/mediatek/pinctrl-mt7622.c | 4 ++ drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.c | 78 ++++++++++++++++++++++++ drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.h | 19 ++++++ 4 files changed, 148 insertions(+), 29 deletions(-)
drivers/pinctrl/mediatek/pinctrl-moore.c +47 -29
@@ -88,27 +88,34 @@ static int mtk_pinconf_get(struct pinctrl_dev *pctldev,switch (param) {case PIN_CONFIG_BIAS_DISABLE : - err =mtk_hw_get_value (hw, pin,PINCTRL_PIN_REG_PU , &val); -if (err) -return err; - - err =mtk_hw_get_value (hw, pin,PINCTRL_PIN_REG_PD , &val2); -if (err) -return err; - -if (val || val2) -return -EINVAL ; - +if (hw->soc->bias_disable_get) { + err = hw->soc->bias_disable_get (hw, desc, &ret); +if (err) +return err; + }else { +return -ENOTSUPP ; + }break ;case PIN_CONFIG_BIAS_PULL_UP : +if (hw->soc->bias_get) { + err = hw->soc->bias_get (hw, desc,1 , &ret); +if (err) +return err; + }else { +return -ENOTSUPP ; + } +break ;case PIN_CONFIG_BIAS_PULL_DOWN : +if (hw->soc->bias_get) { + err = hw->soc->bias_get (hw, desc,0 , &ret); +if (err) +return err; + }else { +return -ENOTSUPP ; + } +break ;case PIN_CONFIG_SLEW_RATE : - reg = (param ==PIN_CONFIG_BIAS_PULL_UP ) ? -PINCTRL_PIN_REG_PU : - (param ==PIN_CONFIG_BIAS_PULL_DOWN ) ? -PINCTRL_PIN_REG_PD :PINCTRL_PIN_REG_SR ; - - err =mtk_hw_get_value (hw, pin, reg, &val); + err =mtk_hw_get_value (hw, pin,PINCTRL_PIN_REG_SR , &val);if (err)return err;
@@ -187,20 +194,31 @@ static int mtk_pinconf_set(struct pinctrl_dev *pctldev, unsigned int pin,switch (param) {case PIN_CONFIG_BIAS_DISABLE : +if (hw->soc->bias_disable_set) { + err = hw->soc->bias_disable_set (hw, desc); +if (err) +return err; + }else { +return -ENOTSUPP ; + } +break ;case PIN_CONFIG_BIAS_PULL_UP : +if (hw->soc->bias_set) { + err = hw->soc->bias_set (hw, desc,1 ); +if (err) +return err; + }else { +return -ENOTSUPP ; + } +break ;case PIN_CONFIG_BIAS_PULL_DOWN : - arg = (param ==PIN_CONFIG_BIAS_DISABLE ) ?0 : - (param ==PIN_CONFIG_BIAS_PULL_UP ) ?1 :2 ; - - err =mtk_hw_set_value (hw, pin,PINCTRL_PIN_REG_PU , - arg &1 ); -if (err) - goto err; - - err =mtk_hw_set_value (hw, pin,PINCTRL_PIN_REG_PD , - !!(arg &2 )); -if (err) - goto err; +if (hw->soc->bias_set) { + err = hw->soc->bias_set (hw, desc,0 ); +if (err) +return err; + }else { +return -ENOTSUPP ; + }break ;case PIN_CONFIG_OUTPUT_ENABLE : err = mtk_hw_set_value(hw, pin, PINCTRL_PIN_REG_SMT,
drivers/pinctrl/mediatek/pinctrl-mt7622.c +4 -0
@@ -767,6 +767,10 @@ static const struct mtk_pin_soc mt7622_data = { .eint_hw = &mt7622_eint_hw, .gpio_m = 1, .eint_m = 1, + .bias_disable_set = mtk_pinconf_bias_disable_set, + .bias_disable_get = mtk_pinconf_bias_disable_get, + .bias_set = mtk_pinconf_bias_set, + .bias_get = mtk_pinconf_bias_get, .drive_set = mtk_pinconf_drive_set, .drive_get = mtk_pinconf_drive_get, };
drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.c +78 -0
84 lines not on this page · raw message
drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.h +19 -0
@@ -150,6 +150,15 @@ struct mtk_pin_soc {u8 eint_m;/* Specific pinconfig operations */ +int (*bias_disable_set)(struct mtk_pinctrl *hw, +const struct mtk_pin_desc *desc); +int (*bias_disable_get)(struct mtk_pinctrl *hw, +const struct mtk_pin_desc *desc,int *res); +int (*bias_set)(struct mtk_pinctrl *hw, +const struct mtk_pin_desc *desc,bool pullup); +int (*bias_get)(struct mtk_pinctrl *hw, +const struct mtk_pin_desc *desc,bool pullup,int *res); +int (*drive_set)(struct mtk_pinctrl *hw,const struct mtk_pin_desc *desc,u32 arg); int (*drive_get)(struct mtk_pinctrl *hw,
@@ -170,6 +179,16 @@ void mtk_rmw(struct mtk_pinctrl *pctl, u32 reg, u32 mask, u32 set);int mtk_hw_set_value (struct mtk_pinctrl *hw,int pin,int field,int value);int mtk_hw_get_value (struct mtk_pinctrl *hw,int pin,int field,int *value); +int mtk_pinconf_bias_disable_set (struct mtk_pinctrl *hw, +const struct mtk_pin_desc *desc); +int mtk_pinconf_bias_disable_get (struct mtk_pinctrl *hw, +const struct mtk_pin_desc *desc,int *res); +int mtk_pinconf_bias_set (struct mtk_pinctrl *hw, +const struct mtk_pin_desc *desc,bool pullup); +int mtk_pinconf_bias_get (struct mtk_pinctrl *hw, +const struct mtk_pin_desc *desc,bool pullup, +int *res); +int mtk_pinconf_drive_set (struct mtk_pinctrl *hw,const struct mtk_pin_desc *desc,u32 arg); int mtk_pinconf_drive_get(struct mtk_pinctrl *hw,
Signature · 1 line
2.7.4
PATCH v2 9/22 pinctrl: mediatek: add advanced pull related support to pinctrl-mtk-common-v2.c
In reply to [email protected]From: Sean Wang <[email protected]>
There are some specific pins (i.e. MMC/SD) need specific registers to turn on/off the 10K & 50k(75K) resistors when pull up/down.
Therefore, this patch adds the custom prarmeters so that the user could control it through device tree.
--- drivers/pinctrl/mediatek/pinctrl-moore.c | 33 ++++++++++++++ drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.c | 55 ++++++++++++++++++++++++ drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.h | 17 ++++++++ 3 files changed, 105 insertions(+)
drivers/pinctrl/mediatek/pinctrl-moore.c +33 -0
@@ -15,16 +15,22 @@/* Custom pinconf parameters */ #define MTK_PIN_CONFIG_TDSEL (PIN_CONFIG_END + 1)#define MTK_PIN_CONFIG_RDSEL (PIN_CONFIG_END + 2) +#define MTK_PIN_CONFIG_PU_ADV (PIN_CONFIG_END + 3) +#define MTK_PIN_CONFIG_PD_ADV (PIN_CONFIG_END + 4)static const struct pinconf_generic_params mtk_custom_bindings[] = { {"mediatek,tdsel" ,MTK_PIN_CONFIG_TDSEL ,0 }, {"mediatek,rdsel" ,MTK_PIN_CONFIG_RDSEL ,0 }, + {"mediatek,pull-up-adv" ,MTK_PIN_CONFIG_PU_ADV ,1 }, + {"mediatek,pull-down-adv" ,MTK_PIN_CONFIG_PD_ADV ,1 }, };#ifdef CONFIG_DEBUG_FS static const struct pin_config_item mtk_conf_items[] = {PCONFDUMP (MTK_PIN_CONFIG_TDSEL ,"tdsel" ,NULL , true),PCONFDUMP (MTK_PIN_CONFIG_RDSEL ,"rdsel" ,NULL , true), +PCONFDUMP (MTK_PIN_CONFIG_PU_ADV ,"pu-adv" ,NULL , true), +PCONFDUMP (MTK_PIN_CONFIG_PD_ADV ,"pd-adv" ,NULL , true), };#endif
@@ -169,6 +175,19 @@ static int mtk_pinconf_get(struct pinctrl_dev *pctldev, ret = val;break ; +case MTK_PIN_CONFIG_PU_ADV : +case MTK_PIN_CONFIG_PD_ADV : +if (hw->soc->adv_pull_get) { +bool pullup; + + pullup = param ==MTK_PIN_CONFIG_PU_ADV ; + err = hw->soc->adv_pull_get (hw, desc, pullup, &ret); +if (err) +return err; + }else { +return -ENOTSUPP ; + } +break ;default :return -ENOTSUPP ; }
@@ -282,6 +301,20 @@ static int mtk_pinconf_set(struct pinctrl_dev *pctldev, unsigned int pin,if (err) goto err;break ; +case MTK_PIN_CONFIG_PU_ADV : +case MTK_PIN_CONFIG_PD_ADV : +if (hw->soc->adv_pull_set) { +bool pullup; + + pullup = param ==MTK_PIN_CONFIG_PU_ADV ; + err = hw->soc->adv_pull_set (hw, desc, pullup, + arg); +if (err) +return err; + }else { +return -ENOTSUPP ; + } +break ;default : err = -ENOTSUPP ; }
drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.c +55 -0
58 lines not on this page · raw message
drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.h +17 -0
@@ -51,6 +51,9 @@ enum {PINCTRL_PIN_REG_TDSEL ,PINCTRL_PIN_REG_RDSEL ,PINCTRL_PIN_REG_DRV , +PINCTRL_PIN_REG_PUPD , +PINCTRL_PIN_REG_R0 , +PINCTRL_PIN_REG_R1 , PINCTRL_PIN_REG_MAX, };
@@ -163,6 +166,13 @@ struct mtk_pin_soc { const struct mtk_pin_desc *desc, u32 arg);int (*drive_get)(struct mtk_pinctrl *hw,const struct mtk_pin_desc *desc,int *val); + +int (*adv_pull_set)(struct mtk_pinctrl *hw, +const struct mtk_pin_desc *desc,bool pullup, +u32 arg); +int (*adv_pull_get)(struct mtk_pinctrl *hw, +const struct mtk_pin_desc *desc,bool pullup, +u32 *val); };struct mtk_pinctrl {
@@ -199,4 +209,11 @@ int mtk_pinconf_drive_set_rev1(struct mtk_pinctrl *hw,int mtk_pinconf_drive_get_rev1 (struct mtk_pinctrl *hw,const struct mtk_pin_desc *desc,int *val); +int mtk_pinconf_adv_pull_set (struct mtk_pinctrl *hw, +const struct mtk_pin_desc *desc,bool pullup, +u32 arg); +int mtk_pinconf_adv_pull_get (struct mtk_pinctrl *hw, +const struct mtk_pin_desc *desc,bool pullup, +u32 *val); +#endif /* __PINCTRL_MTK_COMMON_V2_H */
Signature · 1 line
2.7.4
PATCH v2 10/22 pinctrl: mediatek: add ies register support to pinctrl-mtk-common-v2.c
In reply to [email protected]From: Sean Wang <[email protected]>
Certain SoCs have to program an extra IES register to configure input enabled mode so that we add it in the existing path as an option.
--- drivers/pinctrl/mediatek/pinctrl-moore.c | 26 +++++++++++++++++------- drivers/pinctrl/mediatek/pinctrl-mt7622.c | 1 + drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.h | 2 ++ 3 files changed, 22 insertions(+), 7 deletions(-)
drivers/pinctrl/mediatek/pinctrl-moore.c +19 -7
@@ -244,15 +244,27 @@ static int mtk_pinconf_set(struct pinctrl_dev *pctldev, unsigned int pin, MTK_DISABLE);if (err) goto err; -/* else: fall through */ + + err =mtk_hw_set_value (hw, pin,PINCTRL_PIN_REG_DIR , +MTK_OUTPUT ); +if (err) + goto err; +break ;case PIN_CONFIG_INPUT_ENABLE : -case PIN_CONFIG_SLEW_RATE : - reg = (param ==PIN_CONFIG_SLEW_RATE ) ? -PINCTRL_PIN_REG_SR :PINCTRL_PIN_REG_DIR ; - arg = (param ==PIN_CONFIG_INPUT_ENABLE ) ?0 : - (param ==PIN_CONFIG_OUTPUT_ENABLE ) ?1 : arg; - err =mtk_hw_set_value (hw, pin, reg, arg); +if (hw->soc->ies_present) { +mtk_hw_set_value (hw, pin,PINCTRL_PIN_REG_IES , +MTK_ENABLE ); + } + + err =mtk_hw_set_value (hw, pin,PINCTRL_PIN_REG_DIR , +MTK_INPUT ); +if (err) + goto err; +break ; +case PIN_CONFIG_SLEW_RATE : + err =mtk_hw_set_value (hw, pin,PINCTRL_PIN_REG_SR , + arg);if (err) goto err;
drivers/pinctrl/mediatek/pinctrl-mt7622.c +1 -0
@@ -767,6 +767,7 @@ static const struct mtk_pin_soc mt7622_data = { .eint_hw = &mt7622_eint_hw, .gpio_m = 1, .eint_m = 1, + .ies_present = false, .bias_disable_set = mtk_pinconf_bias_disable_set, .bias_disable_get = mtk_pinconf_bias_disable_get, .bias_set = mtk_pinconf_bias_set,
drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.h +2 -0
@@ -54,6 +54,7 @@ enum {PINCTRL_PIN_REG_PUPD ,PINCTRL_PIN_REG_R0 ,PINCTRL_PIN_REG_R1 , +PINCTRL_PIN_REG_IES , PINCTRL_PIN_REG_MAX, };
@@ -151,6 +152,7 @@ struct mtk_pin_soc {/* Specific parameters per SoC */ u8 gpio_m;u8 eint_m; +bool ies_present;/* Specific pinconfig operations */ int (*bias_disable_set)(struct mtk_pinctrl *hw,
Signature · 1 line
2.7.4
PATCH v2 11/22 pinctrl: mediatek: add pullen, pullsel register support to pinctrl-mtk-common-v2.c
In reply to [email protected]From: Sean Wang <[email protected]>
Certain SoCs have to program an extra PULLEN, PULLSEL register to configure bias related function so that we add it in the existing path.
--- drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.c | 76 ++++++++++++++++++++++++ drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.h | 15 +++++ 2 files changed, 91 insertions(+)
drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.c +76 -0
@@ -190,6 +190,7 @@ int mtk_hw_get_value(struct mtk_pinctrl *hw, int pin, int field, int *value)return 0 ; } +/* Revision 0 */ int mtk_pinconf_bias_disable_set (struct mtk_pinctrl *hw,const struct mtk_pin_desc *desc) {
@@ -268,6 +269,81 @@ int mtk_pinconf_bias_get(struct mtk_pinctrl *hw,return 0 ; } +/* Revision 1 */ +int mtk_pinconf_bias_disable_set_rev1 (struct mtk_pinctrl *hw, +const struct mtk_pin_desc *desc) +{ +int err; + + err =mtk_hw_set_value (hw, desc->number,PINCTRL_PIN_REG_PULLEN , +MTK_DISABLE ); +if (err) +return err; + +return 0 ; +} + +int mtk_pinconf_bias_disable_get_rev1 (struct mtk_pinctrl *hw, +const struct mtk_pin_desc *desc,int *res) +{ +int v, err; + + err =mtk_hw_get_value (hw, desc->number,PINCTRL_PIN_REG_PULLEN , &v); +if (err) +return err; + +if (v ==MTK_ENABLE ) +return -EINVAL ; + + *res =1 ; + +return 0 ; +} + +int mtk_pinconf_bias_set_rev1 (struct mtk_pinctrl *hw, +const struct mtk_pin_desc *desc,bool pullup) +{ +int err, arg; + + arg = pullup ?MTK_PULLUP :MTK_PULLDOWN ; + + err =mtk_hw_set_value (hw, desc->number,PINCTRL_PIN_REG_PULLEN , +MTK_ENABLE ); +if (err) +return err; + + err =mtk_hw_set_value (hw, desc->number,PINCTRL_PIN_REG_PULLSEL , arg); +if (err) +return err; + +return 0 ; +} + +int mtk_pinconf_bias_get_rev1 (struct mtk_pinctrl *hw, +const struct mtk_pin_desc *desc,bool pullup, +int *res) +{ +int err, v; + + err =mtk_hw_get_value (hw, desc->number,PINCTRL_PIN_REG_PULLEN , &v); +if (err) +return err; + +if (v ==MTK_DISABLE ) +return -EINVAL ; + + err =mtk_hw_get_value (hw, desc->number,PINCTRL_PIN_REG_PULLSEL , &v); +if (err) +return err; + +if (pullup ^ (v ==MTK_PULLUP )) +return -EINVAL ; + + *res =1 ; + +return 0 ; +} +/* Revision 0 */ int mtk_pinconf_drive_set (struct mtk_pinctrl *hw,const struct mtk_pin_desc *desc,u32 arg)
drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.h +15 -0
@@ -13,6 +13,8 @@#define MTK_OUTPUT 1#define MTK_DISABLE 0#define MTK_ENABLE 1 +#define MTK_PULLDOWN 0 +#define MTK_PULLUP 1#define EINT_NA -1
@@ -55,6 +57,8 @@ enum {PINCTRL_PIN_REG_R0 ,PINCTRL_PIN_REG_R1 ,PINCTRL_PIN_REG_IES , +PINCTRL_PIN_REG_PULLEN , +PINCTRL_PIN_REG_PULLSEL , PINCTRL_PIN_REG_MAX, };
@@ -201,6 +205,17 @@ int mtk_pinconf_bias_get(struct mtk_pinctrl *hw, const struct mtk_pin_desc *desc, bool pullup, int *res); +int mtk_pinconf_bias_disable_set_rev1 (struct mtk_pinctrl *hw, +const struct mtk_pin_desc *desc); +int mtk_pinconf_bias_disable_get_rev1 (struct mtk_pinctrl *hw, +const struct mtk_pin_desc *desc, +int *res); +int mtk_pinconf_bias_set_rev1 (struct mtk_pinctrl *hw, +const struct mtk_pin_desc *desc,bool pullup); +int mtk_pinconf_bias_get_rev1 (struct mtk_pinctrl *hw, +const struct mtk_pin_desc *desc,bool pullup, +int *res); +int mtk_pinconf_drive_set (struct mtk_pinctrl *hw,const struct mtk_pin_desc *desc,u32 arg); int mtk_pinconf_drive_get(struct mtk_pinctrl *hw,
Signature · 1 line
2.7.4
PATCH v2 12/22 pinctrl: mediatek: add MT7623 pinctrl driver based on generic pinctrl binding
In reply to [email protected]From: Sean Wang <[email protected]>
Adding MT7623 pinctrl driver based on generic pinctrl binding, that is good example and demonstrates how to port any other MediaTek SoCs pinctrl-moore core when people really would like to use the generic pinctrl binding to support these MediaTek SoCs.
--- drivers/pinctrl/mediatek/Kconfig | 6 + drivers/pinctrl/mediatek/Makefile | 1 + drivers/pinctrl/mediatek/pinctrl-mt7623.c | 1440 +++++++++++++++++++++++++++++ 3 files changed, 1447 insertions(+) create mode 100644 drivers/pinctrl/mediatek/pinctrl-mt7623.c
drivers/pinctrl/mediatek/Kconfig +6 -0
@@ -32,6 +32,12 @@ config PINCTRL_MT2701 default MACH_MT2701 select PINCTRL_MTK +config PINCTRL_MT7623 + bool "Mediatek MT7623 pin control with generic binding" + depends on MACH_MT7623 || COMPILE_TEST + depends on PINCTRL_MTK_MOORE + default y + config PINCTRL_MT8135 bool "Mediatek MT8135 pin control" depends on MACH_MT8135 || COMPILE_TEST
drivers/pinctrl/mediatek/Makefile +1 -0
@@ -10,5 +10,6 @@ obj-$(CONFIG_PINCTRL_MT2712) += pinctrl-mt2712.o obj-$(CONFIG_PINCTRL_MT8135) += pinctrl-mt8135.o obj-$(CONFIG_PINCTRL_MT8127) += pinctrl-mt8127.o obj-$(CONFIG_PINCTRL_MT7622) += pinctrl-mt7622.o +obj-$(CONFIG_PINCTRL_MT7623) += pinctrl-mt7623.o obj-$(CONFIG_PINCTRL_MT8173) += pinctrl-mt8173.o obj-$(CONFIG_PINCTRL_MT6397) += pinctrl-mt6397.o
drivers/pinctrl/mediatek/pinctrl-mt7623.c new file +1440 -0
1,440 lines not on this page · raw message
Signature · 1 line
2.7.4
PATCH v2 13/22 pinctrl: mediatek: use pin descriptor all in pinctrl-mtk-common-v2.c
In reply to [email protected]From: Sean Wang <[email protected]>
all use pin descriptor instead in pinctrl-mtk-common-v2.c for the consistency and extensibility.
--- drivers/pinctrl/mediatek/pinctrl-moore.c | 66 +++++++++++++------- drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.c | 76 +++++++++++++----------- drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.h | 6 +- 3 files changed, 88 insertions(+), 60 deletions(-)
drivers/pinctrl/mediatek/pinctrl-moore.c +43 -23
@@ -54,9 +54,13 @@ static int mtk_pinmux_set_mux(struct pinctrl_dev *pctldev, func->name, grp->name);for (i =0 ; i < grp->num_pins; i++) { +const struct mtk_pin_desc *desc;int *pin_modes = grp->data; +int pin = grp->pins[i]; -mtk_hw_set_value (hw, grp->pins[i],PINCTRL_PIN_REG_MODE , + desc = (const struct mtk_pin_desc *)&hw->soc->pins[pin]; + +mtk_hw_set_value (hw, desc,PINCTRL_PIN_REG_MODE , pin_modes[i]); }
@@ -68,8 +72,12 @@ static int mtk_pinmux_gpio_request_enable(struct pinctrl_dev *pctldev, unsigned int pin) {struct mtk_pinctrl *hw =pinctrl_dev_get_drvdata (pctldev); +const struct mtk_pin_desc *desc; + + desc = (const struct mtk_pin_desc *)&hw->soc->pins[pin]; -return mtk_hw_set_value (hw, pin,PINCTRL_PIN_REG_MODE , hw->soc->gpio_m); +return mtk_hw_set_value (hw, desc,PINCTRL_PIN_REG_MODE , + hw->soc->gpio_m); } static int mtk_pinmux_gpio_set_direction(struct pinctrl_dev *pctldev,
@@ -77,9 +85,12 @@ static int mtk_pinmux_gpio_set_direction(struct pinctrl_dev *pctldev, unsigned int pin, bool input) {struct mtk_pinctrl *hw =pinctrl_dev_get_drvdata (pctldev); +const struct mtk_pin_desc *desc; + + desc = (const struct mtk_pin_desc *)&hw->soc->pins[pin];/* hardware would take 0 as input direction */ -return mtk_hw_set_value (hw, pin,PINCTRL_PIN_REG_DIR , !input); +return mtk_hw_set_value (hw, desc,PINCTRL_PIN_REG_DIR , !input); } static int mtk_pinconf_get(struct pinctrl_dev *pctldev,
@@ -121,7 +132,7 @@ static int mtk_pinconf_get(struct pinctrl_dev *pctldev, }break ;case PIN_CONFIG_SLEW_RATE : - err =mtk_hw_get_value (hw, pin,PINCTRL_PIN_REG_SR , &val); + err =mtk_hw_get_value (hw, desc,PINCTRL_PIN_REG_SR , &val);if (err)return err;
@@ -131,7 +142,7 @@ static int mtk_pinconf_get(struct pinctrl_dev *pctldev,break ;case PIN_CONFIG_INPUT_ENABLE :case PIN_CONFIG_OUTPUT_ENABLE : - err =mtk_hw_get_value (hw, pin,PINCTRL_PIN_REG_DIR , &val); + err =mtk_hw_get_value (hw, desc,PINCTRL_PIN_REG_DIR , &val);if (err)return err;
@@ -142,11 +153,11 @@ static int mtk_pinconf_get(struct pinctrl_dev *pctldev,break ;case PIN_CONFIG_INPUT_SCHMITT_ENABLE : - err =mtk_hw_get_value (hw, pin,PINCTRL_PIN_REG_DIR , &val); + err =mtk_hw_get_value (hw, desc,PINCTRL_PIN_REG_DIR , &val);if (err)return err; - err =mtk_hw_get_value (hw, pin,PINCTRL_PIN_REG_SMT , &val2); + err =mtk_hw_get_value (hw, desc,PINCTRL_PIN_REG_SMT , &val2);if (err)return err;
@@ -168,7 +179,7 @@ static int mtk_pinconf_get(struct pinctrl_dev *pctldev, reg = (param ==MTK_PIN_CONFIG_TDSEL ) ?PINCTRL_PIN_REG_TDSEL :PINCTRL_PIN_REG_RDSEL ; - err =mtk_hw_get_value (hw, pin, reg, &val); + err =mtk_hw_get_value (hw, desc, reg, &val);if (err)return err;
@@ -240,12 +251,12 @@ static int mtk_pinconf_set(struct pinctrl_dev *pctldev, unsigned int pin, }break ;case PIN_CONFIG_OUTPUT_ENABLE : - err =mtk_hw_set_value (hw, pin,PINCTRL_PIN_REG_SMT , + err =mtk_hw_set_value (hw, desc,PINCTRL_PIN_REG_SMT ,MTK_DISABLE );if (err) goto err; - err =mtk_hw_set_value (hw, pin,PINCTRL_PIN_REG_DIR , + err =mtk_hw_set_value (hw, desc,PINCTRL_PIN_REG_DIR ,MTK_OUTPUT );if (err) goto err;
@@ -253,29 +264,29 @@ static int mtk_pinconf_set(struct pinctrl_dev *pctldev, unsigned int pin,case PIN_CONFIG_INPUT_ENABLE :if (hw->soc->ies_present) { -mtk_hw_set_value (hw, pin,PINCTRL_PIN_REG_IES , +mtk_hw_set_value (hw, desc,PINCTRL_PIN_REG_IES ,MTK_ENABLE ); } - err =mtk_hw_set_value (hw, pin,PINCTRL_PIN_REG_DIR , + err =mtk_hw_set_value (hw, desc,PINCTRL_PIN_REG_DIR ,MTK_INPUT );if (err) goto err;break ;case PIN_CONFIG_SLEW_RATE : - err =mtk_hw_set_value (hw, pin,PINCTRL_PIN_REG_SR , + err =mtk_hw_set_value (hw, desc,PINCTRL_PIN_REG_SR , arg);if (err) goto err;break ;case PIN_CONFIG_OUTPUT : - err =mtk_hw_set_value (hw, pin,PINCTRL_PIN_REG_DIR , + err =mtk_hw_set_value (hw, desc,PINCTRL_PIN_REG_DIR ,MTK_OUTPUT );if (err) goto err; - err =mtk_hw_set_value (hw, pin,PINCTRL_PIN_REG_DO , + err =mtk_hw_set_value (hw, desc,PINCTRL_PIN_REG_DO , arg);if (err) goto err;
@@ -285,12 +296,12 @@ static int mtk_pinconf_set(struct pinctrl_dev *pctldev, unsigned int pin,* arg = 0: Output mode & SMT disable */ arg = arg ?2 :1 ; - err =mtk_hw_set_value (hw, pin,PINCTRL_PIN_REG_DIR , + err =mtk_hw_set_value (hw, desc,PINCTRL_PIN_REG_DIR , arg &1 );if (err) goto err; - err =mtk_hw_set_value (hw, pin,PINCTRL_PIN_REG_SMT , + err =mtk_hw_set_value (hw, desc,PINCTRL_PIN_REG_SMT , !!(arg &2 ));if (err) goto err;
@@ -309,7 +320,7 @@ static int mtk_pinconf_set(struct pinctrl_dev *pctldev, unsigned int pin, reg = (param ==MTK_PIN_CONFIG_TDSEL ) ?PINCTRL_PIN_REG_TDSEL :PINCTRL_PIN_REG_RDSEL ; - err =mtk_hw_set_value (hw, pin, reg, arg); + err =mtk_hw_set_value (hw, desc, reg, arg);if (err) goto err;break ;
@@ -419,9 +430,12 @@ static struct pinctrl_desc mtk_desc = {static int mtk_gpio_get (struct gpio_chip *chip,unsigned int gpio) {struct mtk_pinctrl *hw =gpiochip_get_data (chip); +const struct mtk_pin_desc *desc;int value, err; - err =mtk_hw_get_value (hw, gpio,PINCTRL_PIN_REG_DI , &value); + desc = (const struct mtk_pin_desc *)&hw->soc->pins[gpio]; + + err =mtk_hw_get_value (hw, desc,PINCTRL_PIN_REG_DI , &value);if (err)return err;
@@ -431,8 +445,11 @@ static int mtk_gpio_get(struct gpio_chip *chip, unsigned int gpio)static void mtk_gpio_set (struct gpio_chip *chip,unsigned int gpio,int value) {struct mtk_pinctrl *hw =gpiochip_get_data (chip); +const struct mtk_pin_desc *desc; -mtk_hw_set_value (hw, gpio,PINCTRL_PIN_REG_DO , !!value); + desc = (const struct mtk_pin_desc *)&hw->soc->pins[gpio]; + +mtk_hw_set_value (hw, desc,PINCTRL_PIN_REG_DO , !!value); }static int mtk_gpio_direction_input (struct gpio_chip *chip,unsigned int gpio)
@@ -620,6 +637,7 @@ static int mtk_xt_get_gpio_state(void *data, unsigned long eint_n)static int mtk_xt_set_gpio_as_eint (void *data,unsigned long eint_n) {struct mtk_pinctrl *hw = (struct mtk_pinctrl *)data; +const struct mtk_pin_desc *desc;struct gpio_chip *gpio_chip;unsigned int gpio_n;int err;
@@ -628,16 +646,18 @@ static int mtk_xt_set_gpio_as_eint(void *data, unsigned long eint_n)if (err)return err; - err =mtk_hw_set_value (hw, gpio_n,PINCTRL_PIN_REG_MODE , + desc = (const struct mtk_pin_desc *)&hw->soc->pins[gpio_n]; + + err =mtk_hw_set_value (hw, desc,PINCTRL_PIN_REG_MODE , hw->soc->eint_m);if (err)return err; - err =mtk_hw_set_value (hw, gpio_n,PINCTRL_PIN_REG_DIR ,MTK_INPUT ); + err =mtk_hw_set_value (hw, desc,PINCTRL_PIN_REG_DIR ,MTK_INPUT );if (err)return err; - err =mtk_hw_set_value (hw, gpio_n,PINCTRL_PIN_REG_SMT ,MTK_ENABLE ); + err =mtk_hw_set_value (hw, desc,PINCTRL_PIN_REG_SMT ,MTK_ENABLE );if (err)return err;
drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.c +41 -35
260 lines not on this page · raw message
drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.h +4 -2
@@ -192,8 +192,10 @@ struct mtk_pinctrl {void mtk_rmw (struct mtk_pinctrl *pctl,u32 reg,u32 mask,u32 set); -int mtk_hw_set_value (struct mtk_pinctrl *hw,int pin,int field,int value); -int mtk_hw_get_value (struct mtk_pinctrl *hw,int pin,int field,int *value); +int mtk_hw_set_value (struct mtk_pinctrl *hw,const struct mtk_pin_desc *desc, +int field,int value); +int mtk_hw_get_value (struct mtk_pinctrl *hw,const struct mtk_pin_desc *desc, +int field,int *value);int mtk_pinconf_bias_disable_set (struct mtk_pinctrl *hw,const struct mtk_pin_desc *desc);
Signature · 1 line
2.7.4
PATCH v2 14/22 pinctrl: mediatek: add multiple register bases support to pinctrl-mtk-common-v2.c
In reply to [email protected]From: Sean Wang <[email protected]>
Certain SoC own multiple register base for accessing each pin groups, it's easy to be done with extend struct mtk_pin_field_calc to support the kind of SoC such as MT8183.
--- drivers/pinctrl/mediatek/pinctrl-moore.c | 30 +++++++++++++++----- drivers/pinctrl/mediatek/pinctrl-mt7622.c | 2 ++ drivers/pinctrl/mediatek/pinctrl-mt7623.c | 16 ++++++----- drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.c | 36 +++++++++++++++--------- drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.h | 24 ++++++++++++---- 5 files changed, 75 insertions(+), 33 deletions(-)
drivers/pinctrl/mediatek/pinctrl-moore.c +23 -7
@@ -713,25 +713,41 @@ int mtk_moore_pinctrl_probe(struct platform_device *pdev, {struct resource *res;struct mtk_pinctrl *hw; -int err; +int err, i; hw =devm_kzalloc (&pdev->dev,sizeof (*hw),GFP_KERNEL );if (!hw)return -ENOMEM ; hw->soc = soc; + hw->dev = &pdev->dev; - res =platform_get_resource (pdev,IORESOURCE_MEM ,0 ); -if (!res) { -dev_err (&pdev->dev,"missing IO resource\n" ); -return -ENXIO ; +if (!hw->soc->nbase_names) { +dev_err (&pdev->dev, +"SoC should be assigned at least one register base\n" ); +return -EINVAL ; } - hw->dev = &pdev->dev; - hw->base =devm_ioremap_resource (&pdev->dev, res); + hw->base =devm_kmalloc_array (&pdev->dev, hw->soc->nbase_names, +sizeof (*hw->base),GFP_KERNEL );if (IS_ERR (hw->base))return PTR_ERR (hw->base); +for (i =0 ; i < hw->soc->nbase_names; i++) { + res =platform_get_resource_byname (pdev,IORESOURCE_MEM , + hw->soc->base_names[i]); +if (!res) { +dev_err (&pdev->dev,"missing IO resource\n" ); +return -ENXIO ; + } + + hw->base[i] =devm_ioremap_resource (&pdev->dev, res); +if (IS_ERR (hw->base[i])) +return PTR_ERR (hw->base[i]); + } + + hw->nbase = hw->soc->nbase_names; +/* Setup pins descriptions per SoC types */ mtk_desc.pins = (const struct pinctrl_pin_desc *)hw->soc->pins; mtk_desc.npins = hw->soc->npins;
drivers/pinctrl/mediatek/pinctrl-mt7622.c +2 -0
@@ -768,6 +768,8 @@ static const struct mtk_pin_soc mt7622_data = { .gpio_m = 1, .eint_m = 1, .ies_present = false, + .base_names = mtk_default_register_base_names, + .nbase_names = ARRAY_SIZE(mtk_default_register_base_names), .bias_disable_set = mtk_pinconf_bias_disable_set, .bias_disable_get = mtk_pinconf_bias_disable_get, .bias_set = mtk_pinconf_bias_set,
drivers/pinctrl/mediatek/pinctrl-mt7623.c +9 -7
@@ -18,15 +18,15 @@#define BOND_MSDC0E_CLR 0x1#define PIN_FIELD15 (_s_pin, _e_pin, _s_addr, _x_addrs, _s_bit, _x_bits) \ - PIN_FIELD_CALC(_s_pin, _e_pin, _s_addr, _x_addrs, _s_bit, \ + PIN_FIELD_CALC(_s_pin, _e_pin, 0, _s_addr, _x_addrs, _s_bit, \ _x_bits, 15, false)#define PIN_FIELD16 (_s_pin, _e_pin, _s_addr, _x_addrs, _s_bit, _x_bits) \ - PIN_FIELD_CALC(_s_pin, _e_pin, _s_addr, _x_addrs, _s_bit, \ + PIN_FIELD_CALC(_s_pin, _e_pin, 0, _s_addr, _x_addrs, _s_bit, \ _x_bits, 16, 0) -#define PINS_FIELD16 (_s_pin, _e_pin, _s_addr, _x_addrs, _s_bit, _x_bits)\ - PIN_FIELD_CALC(_s_pin, _e_pin, _s_addr, _x_addrs, _s_bit, \ +#define PINS_FIELD16 (_s_pin, _e_pin, _s_addr, _x_addrs, _s_bit, _x_bits) \ + PIN_FIELD_CALC(_s_pin, _e_pin, 0, _s_addr, _x_addrs, _s_bit, \ _x_bits, 16, 1)#define MT7623_PIN (_number, _name, _eint_n, _drv_grp) \
@@ -1383,6 +1383,8 @@ static struct mtk_pin_soc mt7623_data = { .gpio_m = 0, .eint_m = 0, .ies_present = true, + .base_names = mtk_default_register_base_names, + .nbase_names = ARRAY_SIZE(mtk_default_register_base_names), .bias_disable_set = mtk_pinconf_bias_disable_set_rev1, .bias_disable_get = mtk_pinconf_bias_disable_get_rev1, .bias_set = mtk_pinconf_bias_set_rev1,
@@ -1402,9 +1404,9 @@ static void mt7623_bonding_disable(struct platform_device *pdev) {struct mtk_pinctrl *hw =platform_get_drvdata (pdev); -mtk_rmw (hw,PIN_BOND_REG0 ,BOND_PCIE_CLR ,BOND_PCIE_CLR ); -mtk_rmw (hw,PIN_BOND_REG1 ,BOND_I2S_CLR ,BOND_I2S_CLR ); -mtk_rmw (hw,PIN_BOND_REG2 ,BOND_MSDC0E_CLR ,BOND_MSDC0E_CLR ); +mtk_rmw (hw,0 ,PIN_BOND_REG0 ,BOND_PCIE_CLR ,BOND_PCIE_CLR ); +mtk_rmw (hw,0 ,PIN_BOND_REG1 ,BOND_I2S_CLR ,BOND_I2S_CLR ); +mtk_rmw (hw,0 ,PIN_BOND_REG2 ,BOND_MSDC0E_CLR ,BOND_MSDC0E_CLR ); }static const struct of_device_id mt7623_pctrl_match[] = {
drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.c +23 -13
@@ -39,24 +39,24 @@ const struct mtk_drive_desc mtk_drive[] = { [DRV_GRP4] = { 2, 16, 2, 1 }, }; -static void mtk_w32 (struct mtk_pinctrl *pctl,u32 reg,u32 val) +static void mtk_w32 (struct mtk_pinctrl *pctl,u8 i,u32 reg,u32 val) { -writel_relaxed (val, pctl->base + reg); +writel_relaxed (val, pctl->base[i] + reg); } -static u32 mtk_r32 (struct mtk_pinctrl *pctl,u32 reg) +static u32 mtk_r32 (struct mtk_pinctrl *pctl,u8 i,u32 reg) { -return readl_relaxed (pctl->base + reg); +return readl_relaxed (pctl->base[i] + reg); } -void mtk_rmw (struct mtk_pinctrl *pctl,u32 reg,u32 mask,u32 set) +void mtk_rmw (struct mtk_pinctrl *pctl,u8 i,u32 reg,u32 mask,u32 set) {u32 val; - val =mtk_r32 (pctl, reg); + val =mtk_r32 (pctl, i, reg); val &= ~mask; val |= set; -mtk_w32 (pctl, reg, val); +mtk_w32 (pctl, i, reg, val); } static int mtk_hw_pin_field_lookup(struct mtk_pinctrl *hw,
@@ -82,6 +82,12 @@ static int mtk_hw_pin_field_lookup(struct mtk_pinctrl *hw,return -EINVAL ; } +if (c->i_base > hw->nbase -1 ) { +dev_err (hw->dev,"Invalid base is found for pin = %d (%s)\n" , + desc->number, desc->name); +return -EINVAL ; + } +/* Calculated bits as the overall offset the pin is located at, * if c->fixed is held, that determines the all the pins in the * range use the same field with the s_pin.
@@ -92,6 +98,7 @@ static int mtk_hw_pin_field_lookup(struct mtk_pinctrl *hw,/* Fill pfd from bits. For example 32-bit register applied is assumed * when c->sz_reg is equal to 32. */ + pfd->index = c->i_base; pfd->offset = c->s_addr + c->x_addrs * (bits / c->sz_reg); pfd->bitpos = bits % c->sz_reg; pfd->mask = (1 << c->x_bits) -1 ;
@@ -139,10 +146,10 @@ static void mtk_hw_write_cross_field(struct mtk_pinctrl *hw,mtk_hw_bits_part (pf, &nbits_h, &nbits_l); -mtk_rmw (hw, pf->offset, pf->mask << pf->bitpos, +mtk_rmw (hw, pf->index, pf->offset, pf->mask << pf->bitpos, (value & pf->mask) << pf->bitpos); -mtk_rmw (hw, pf->offset + pf->next,BIT (nbits_h) -1 , +mtk_rmw (hw, pf->index, pf->offset + pf->next,BIT (nbits_h) -1 , (value & pf->mask) >> nbits_l); }
@@ -153,8 +160,10 @@ static void mtk_hw_read_cross_field(struct mtk_pinctrl *hw,mtk_hw_bits_part (pf, &nbits_h, &nbits_l); - l = (mtk_r32 (hw, pf->offset) >> pf->bitpos) & (BIT (nbits_l) -1 ); - h = (mtk_r32 (hw, pf->offset + pf->next)) & (BIT (nbits_h) -1 ); + l = (mtk_r32 (hw, pf->index, pf->offset) + >> pf->bitpos) & (BIT (nbits_l) -1 ); + h = (mtk_r32 (hw, pf->index, pf->offset + pf->next)) + & (BIT (nbits_h) -1 ); *value = (h << nbits_l) | l; }
@@ -170,7 +179,7 @@ int mtk_hw_set_value(struct mtk_pinctrl *hw, const struct mtk_pin_desc *desc,return err;if (!pf.next) -mtk_rmw (hw, pf.offset, pf.mask << pf.bitpos, +mtk_rmw (hw, pf.index, pf.offset, pf.mask << pf.bitpos, (value & pf.mask) << pf.bitpos);else mtk_hw_write_cross_field (hw, &pf, value);
@@ -189,7 +198,8 @@ int mtk_hw_get_value(struct mtk_pinctrl *hw, const struct mtk_pin_desc *desc,return err;if (!pf.next) - *value = (mtk_r32 (hw, pf.offset) >> pf.bitpos) & pf.mask; + *value = (mtk_r32 (hw, pf.index, pf.offset) + >> pf.bitpos) & pf.mask;else mtk_hw_read_cross_field (hw, &pf, value);
drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.h +18 -6
@@ -18,10 +18,11 @@#define EINT_NA -1 -#define PIN_FIELD_CALC (_s_pin, _e_pin, _s_addr, _x_addrs, _s_bit, \ - _x_bits, _sz_reg, _fixed) { \ +#define PIN_FIELD_CALC (_s_pin, _e_pin, _i_base, _s_addr, _x_addrs, \ + _s_bit, _x_bits, _sz_reg, _fixed) { \ .s_pin = _s_pin, \ .e_pin = _e_pin, \ + .i_base = _i_base, \ .s_addr = _s_addr, \ .x_addrs = _x_addrs, \ .s_bit = _s_bit, \
@@ -31,11 +32,11 @@ }#define PIN_FIELD (_s_pin, _e_pin, _s_addr, _x_addrs, _s_bit, _x_bits) \ - PIN_FIELD_CALC(_s_pin, _e_pin, _s_addr, _x_addrs, _s_bit, \ + PIN_FIELD_CALC(_s_pin, _e_pin, 0, _s_addr, _x_addrs, _s_bit, \ _x_bits, 32, 0)#define PINS_FIELD (_s_pin, _e_pin, _s_addr, _x_addrs, _s_bit, _x_bits) \ - PIN_FIELD_CALC(_s_pin, _e_pin, _s_addr, _x_addrs, _s_bit, \ + PIN_FIELD_CALC(_s_pin, _e_pin, 0, _s_addr, _x_addrs, _s_bit, \ _x_bits, 32, 1)/* List these attributes which could be modified for the pin */
@@ -73,8 +74,13 @@ enum { DRV_GRP_MAX, }; +static const char *const mtk_default_register_base_names[] = { +"base" , +}; +/* struct mtk_pin_field - the structure that holds the information of the field * used to describe the attribute for the pin +* @base: the index pointing to the entry in base address list * @offset: the register offset relative to the base address * @mask: the mask used to filter out the field from the register * @bitpos: the start bit relative to the register
@@ -82,6 +88,7 @@ enum {next register */ struct mtk_pin_field { +u8 index;u32 offset;u32 mask;u8 bitpos;
@@ -92,6 +99,7 @@ struct mtk_pin_field {* the guide used to look up the relevant field * @s_pin: the start pin within the range * @e_pin: the end pin within the range +* @i_base: the index pointing to the entry in base address list * @s_addr: the start address for the range * @x_addrs: the address distance between two consecutive registers * within the range
@@ -105,6 +113,7 @@ struct mtk_pin_field {struct mtk_pin_field_calc {u16 s_pin;u16 e_pin; +u8 i_base;u32 s_addr;u8 x_addrs;u8 s_bit;
@@ -157,6 +166,8 @@ struct mtk_pin_soc {u8 gpio_m;u8 eint_m;bool ies_present; +const char *const *base_names; +unsigned int nbase_names;/* Specific pinconfig operations */ int (*bias_disable_set)(struct mtk_pinctrl *hw,
@@ -183,14 +194,15 @@ struct mtk_pin_soc {struct mtk_pinctrl {struct pinctrl_dev *pctrl; -void __iomem *base; +void __iomem **base; +u8 nbase;struct device *dev;struct gpio_chip chip;const struct mtk_pin_soc *soc;struct mtk_eint *eint; }; -void mtk_rmw (struct mtk_pinctrl *pctl,u32 reg,u32 mask,u32 set); +void mtk_rmw (struct mtk_pinctrl *pctl,u8 i,u32 reg,u32 mask,u32 set);int mtk_hw_set_value (struct mtk_pinctrl *hw,const struct mtk_pin_desc *desc,int field,int value);
Signature · 1 line
2.7.4
PATCH v2 15/22 pinctrl: mediatek: adjust error code and message when some register not supported is found
In reply to [email protected]From: Sean Wang <[email protected]>
It's usual and not an error for there's some register not supported by a certain SoC or a pin so that in the case we have to adjust the message to print and the error code to get rid of unnecessary false alarm.
--- drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.c | 35 ++++++++++++------------ 1 file changed, 18 insertions(+), 17 deletions(-)
drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.c +18 -17
@@ -61,12 +61,21 @@ void mtk_rmw(struct mtk_pinctrl *pctl, u8 i, u32 reg, u32 mask, u32 set)static int mtk_hw_pin_field_lookup (struct mtk_pinctrl *hw,const struct mtk_pin_desc *desc, -const struct mtk_pin_reg_calc *rc, -struct mtk_pin_field *pfd) +int field,struct mtk_pin_field *pfd) {const struct mtk_pin_field_calc *c, *e; +const struct mtk_pin_reg_calc *rc;u32 bits; +if (hw->soc->reg_cal && hw->soc->reg_cal[field].range) { + rc = &hw->soc->reg_cal[field]; + }else { +dev_dbg (hw->dev, +"Not support field %d for pin %d (%s)\n" , + field, desc->number, desc->name); +return -ENOTSUPP ; + } + c = rc->range; e = c + rc->nranges;
@@ -77,14 +86,15 @@ static int mtk_hw_pin_field_lookup(struct mtk_pinctrl *hw, }if (c >= e) { -dev_err (hw->dev,"Out of range for pin = %d (%s)\n" , - desc->number, desc->name); -return -EINVAL ; +dev_dbg (hw->dev,"Not support field %d for pin = %d (%s)\n" , + field, desc->number, desc->name); +return -ENOTSUPP ; }if (c->i_base > hw->nbase -1 ) { -dev_err (hw->dev,"Invalid base is found for pin = %d (%s)\n" , - desc->number, desc->name); +dev_err (hw->dev, +"Invalid base for field %d for pin = %d (%s)\n" , + field, desc->number, desc->name);return -EINVAL ; }
@@ -116,21 +126,12 @@ static int mtk_hw_pin_field_get(struct mtk_pinctrl *hw,const struct mtk_pin_desc *desc, int field, struct mtk_pin_field *pfd) { - const struct mtk_pin_reg_calc *rc; - if (field < 0 || field >= PINCTRL_PIN_REG_MAX) { dev_err(hw->dev, "Invalid Field %d\n", field);return -EINVAL ; } -if (hw->soc->reg_cal && hw->soc->reg_cal[field].range) { - rc = &hw->soc->reg_cal[field]; - }else { -dev_err (hw->dev,"Undefined range for field %d\n" , field); -return -EINVAL ; - } - -return mtk_hw_pin_field_lookup (hw, desc, rc, pfd); +return mtk_hw_pin_field_lookup (hw, desc, field, pfd); }static void mtk_hw_bits_part (struct mtk_pin_field *pf,int *h,int *l)
Signature · 1 line
2.7.4
PATCH v2 16/22 pinctrl: mediatek: extend struct mtk_pin_desc which per-pin driver depends on
In reply to [email protected]From: Sean Wang <[email protected]>
Because the pincrl-mtk-common.c is an implementation for per-pin binding, its pin descriptor includes more information than pinctrl-mtk-common-v2 so far can support. So, we complement these data before writing a driver using pincrl-mtk-common-v2.c for per-pin binding. By the way, the size of struct mtk_pin_desc would be larger than struct pinctrl_pin_desc can hold, so it's necessary to have a copy before the pins information is being registered into the core.
--- drivers/pinctrl/mediatek/pinctrl-moore.c | 28 ++++++++++++------ drivers/pinctrl/mediatek/pinctrl-moore.h | 8 ++++-- drivers/pinctrl/mediatek/pinctrl-mt7622.c | 5 ++-- drivers/pinctrl/mediatek/pinctrl-mt7623.c | 5 ++-- drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.h | 36 +++++++++++++++++++++--- 5 files changed, 62 insertions(+), 20 deletions(-)
drivers/pinctrl/mediatek/pinctrl-moore.c +20 -8
@@ -475,10 +475,10 @@ static int mtk_gpio_to_irq(struct gpio_chip *chip, unsigned int offset) desc = (const struct mtk_pin_desc *)&hw->soc->pins[offset]; -if (desc->eint_n ==EINT_NA ) +if (desc->eint.eint_n ==EINT_NA )return -ENOTSUPP ; -return mtk_eint_find_irq (hw->eint, desc->eint_n); +return mtk_eint_find_irq (hw->eint, desc->eint.eint_n); } static int mtk_gpio_set_config(struct gpio_chip *chip, unsigned int offset,
@@ -492,12 +492,12 @@ static int mtk_gpio_set_config(struct gpio_chip *chip, unsigned int offset,if (!hw->eint ||pinconf_to_config_param (config) !=PIN_CONFIG_INPUT_DEBOUNCE || - desc->eint_n ==EINT_NA ) + desc->eint.eint_n ==EINT_NA )return -ENOTSUPP ; debounce =pinconf_to_config_argument (config); -return mtk_eint_set_debounce (hw->eint, desc->eint_n, debounce); +return mtk_eint_set_debounce (hw->eint, desc->eint.eint_n, debounce); }static int mtk_build_gpiochip (struct mtk_pinctrl *hw,struct device_node *np)
@@ -593,7 +593,7 @@ static int mtk_xt_find_eint_num(struct mtk_pinctrl *hw, desc = (const struct mtk_pin_desc *)hw->soc->pins;while (i < hw->soc->npins) { -if (desc[i].eint_n == eint_n) +if (desc[i].eint.eint_n == eint_n)return desc[i].number; i++; }
@@ -612,7 +612,7 @@ static int mtk_xt_get_gpio_n(void *data, unsigned long eint_n, *gpio_chip = &hw->chip;/* Be greedy to guess first gpio_n is equal to eint_n */ -if (desc[eint_n].eint_n == eint_n) +if (desc[eint_n].eint.eint_n == eint_n) *gpio_n = eint_n;else *gpio_n =mtk_xt_find_eint_num (hw, eint_n);
@@ -649,7 +649,7 @@ static int mtk_xt_set_gpio_as_eint(void *data, unsigned long eint_n) desc = (const struct mtk_pin_desc *)&hw->soc->pins[gpio_n]; err =mtk_hw_set_value (hw, desc,PINCTRL_PIN_REG_MODE , - hw->soc->eint_m); + desc->eint.eint_m);if (err)return err;
@@ -711,6 +711,7 @@ mtk_build_eint(struct mtk_pinctrl *hw, struct platform_device *pdev)int mtk_moore_pinctrl_probe (struct platform_device *pdev,const struct mtk_pin_soc *soc) { +struct pinctrl_pin_desc *pins;struct resource *res;struct mtk_pinctrl *hw;int err, i;
@@ -748,8 +749,19 @@ int mtk_moore_pinctrl_probe(struct platform_device *pdev, hw->nbase = hw->soc->nbase_names; +/* Copy from internal struct mtk_pin_desc to register to the core */ + pins =devm_kmalloc_array (&pdev->dev, hw->soc->npins,sizeof (*pins), +GFP_KERNEL ); +if (IS_ERR (pins)) +return PTR_ERR (pins); + +for (i =0 ; i < hw->soc->npins; i++) { + pins[i].number = hw->soc->pins[i].number; + pins[i].name = hw->soc->pins[i].name; + } +/* Setup pins descriptions per SoC types */ - mtk_desc.pins = (const struct pinctrl_pin_desc *)hw->soc->pins; + mtk_desc.pins = (const struct pinctrl_pin_desc *)pins; mtk_desc.npins = hw->soc->npins; mtk_desc.num_custom_params =ARRAY_SIZE (mtk_custom_bindings); mtk_desc.custom_params = mtk_custom_bindings;
drivers/pinctrl/mediatek/pinctrl-moore.h +6 -2
@@ -28,11 +28,15 @@#define MTK_RANGE (_a) { .range = (_a), .nranges = ARRAY_SIZE(_a), } -#define MTK_PIN (_number, _name, _eint_n, _drv_n) { \ +#define MTK_PIN (_number, _name, _eint_m, _eint_n, _drv_n) { \ .number = _number, \ .name = _name, \ - .eint_n = _eint_n, \ + .eint = { \ + .eint_m = _eint_m, \ + .eint_n = _eint_n, \ + }, \ .drv_n = _drv_n, \ + .funcs = NULL, \ }#define PINCTRL_PIN_GROUP (name, id) \
drivers/pinctrl/mediatek/pinctrl-mt7622.c +2 -3
@@ -9,7 +9,7 @@#include "pinctrl-moore.h" #define MT7622_PIN (_number, _name) \ - MTK_PIN(_number, _name, _number, DRV_GRP0) + MTK_PIN(_number, _name, 1, _number, DRV_GRP0)static const struct mtk_pin_field_calc mt7622_pin_mode_range[] = {PIN_FIELD (0 ,0 ,0x320 ,0x10 ,16 ,4 ),
@@ -758,7 +758,7 @@ static const struct mtk_eint_hw mt7622_eint_hw = {static const struct mtk_pin_soc mt7622_data = { .reg_cal = mt7622_reg_cals, - .pins = (const struct pinctrl_pin_desc *)mt7622_pins, + .pins = mt7622_pins, .npins =ARRAY_SIZE (mt7622_pins), .grps = mt7622_groups, .ngrps =ARRAY_SIZE (mt7622_groups),
@@ -766,7 +766,6 @@ static const struct mtk_pin_soc mt7622_data = { .nfuncs = ARRAY_SIZE(mt7622_functions), .eint_hw = &mt7622_eint_hw, .gpio_m = 1, - .eint_m = 1, .ies_present = false, .base_names = mtk_default_register_base_names, .nbase_names = ARRAY_SIZE(mtk_default_register_base_names),
drivers/pinctrl/mediatek/pinctrl-mt7623.c +2 -3
@@ -30,7 +30,7 @@ _x_bits, 16, 1)#define MT7623_PIN (_number, _name, _eint_n, _drv_grp) \ - MTK_PIN(_number, _name, _eint_n, _drv_grp) + MTK_PIN(_number, _name, 0, _eint_n, _drv_grp)static const struct mtk_pin_field_calc mt7623_pin_mode_range[] = {PIN_FIELD15 (0 ,278 ,0x760 ,0x10 ,0 ,3 ),
@@ -1373,7 +1373,7 @@ static const struct mtk_eint_hw mt7623_eint_hw = {static struct mtk_pin_soc mt7623_data = { .reg_cal = mt7623_reg_cals, - .pins = (const struct pinctrl_pin_desc *)mt7623_pins, + .pins = mt7623_pins, .npins =ARRAY_SIZE (mt7623_pins), .grps = mt7623_groups, .ngrps =ARRAY_SIZE (mt7623_groups),
@@ -1381,7 +1381,6 @@ static struct mtk_pin_soc mt7623_data = { .nfuncs = ARRAY_SIZE(mt7623_functions), .eint_hw = &mt7623_eint_hw, .gpio_m = 0, - .eint_m = 0, .ies_present = true, .base_names = mtk_default_register_base_names, .nbase_names = ARRAY_SIZE(mtk_default_register_base_names),
drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.h +32 -4
@@ -134,18 +134,44 @@ struct mtk_pin_reg_calc { };/** +* struct mtk_func_desc - the structure that providing information +* all the funcs for this pin +* @name: the name of function +* @muxval: the mux to the function +*/ +struct mtk_func_desc { +const char *name; +u8 muxval; +}; + +/** +* struct mtk_eint_desc - the structure that providing information +* for eint data per pin +* @eint_m: the eint mux for this pin +* @eitn_n: the eint number for this pin +*/ +struct mtk_eint_desc { +u8 eint_m; +u16 eint_n; +}; + +/** * struct mtk_pin_desc - the structure that providing information * for each pin of chips * @number: unique pin number from the global pin number space * @name: name for this pin -* @eint_n: the eint number for this pin +* @eint: the eint data for this pin * @drv_n: the index with the driving group +* @funcs: all available functions for this pins (only used in +* those drivers compatible to pinctrl-mtk-common.c-like +* ones) */ struct mtk_pin_desc {unsigned int number;const char *name; -u16 eint_n; +struct mtk_eint_desc eint;u8 drv_n; +struct mtk_func_desc *funcs; };struct mtk_pinctrl ;
@@ -153,7 +179,7 @@ struct mtk_pinctrl;/* struct mtk_pin_soc - the structure that holds SoC-specific data */ struct mtk_pin_soc {const struct mtk_pin_reg_calc *reg_cal; -const struct pinctrl_pin_desc *pins; +const struct mtk_pin_desc *pins;unsigned int npins;const struct group_desc *grps;unsigned int ngrps;
@@ -164,7 +190,6 @@ struct mtk_pin_soc {/* Specific parameters per SoC */ u8 gpio_m; -u8 eint_m;bool ies_present;const char *const *base_names;unsigned int nbase_names;
@@ -190,6 +215,9 @@ struct mtk_pin_soc {int (*adv_pull_get)(struct mtk_pinctrl *hw,const struct mtk_pin_desc *desc,bool pullup,u32 *val); + +/* Specific driver data */ +void *driver_data; };struct mtk_pinctrl {
Signature · 1 line
2.7.4
PATCH v2 17/22 pinctrl: mediatek: add pinctrl-paris that implements the vendor dt-bindings
In reply to [email protected]From: Zhiyong Tao <[email protected]>
Add pinctrl-paris core that implements vendor dt-binding which MediaTek tablet, box and smartphone-based SoCs such as MT81xx, MT27xx, and MT67xx SoCs really want to depend on. The driver is just completely rewritten according to pinctrl-mtk-common.c but uses the new logic from pinctrl-mtk-common-v2.c to have an elegant way to support new SoCs in the future.
--- drivers/pinctrl/mediatek/Kconfig | 9 + drivers/pinctrl/mediatek/Makefile | 1 + drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.h | 8 + drivers/pinctrl/mediatek/pinctrl-paris.c | 884 +++++++++++++++++++++++ drivers/pinctrl/mediatek/pinctrl-paris.h | 65 ++ 5 files changed, 967 insertions(+) create mode 100644 drivers/pinctrl/mediatek/pinctrl-paris.c create mode 100644 drivers/pinctrl/mediatek/pinctrl-paris.h
drivers/pinctrl/mediatek/Kconfig +9 -0
@@ -24,6 +24,15 @@ config PINCTRL_MTK_MOORE select GPIOLIB select OF_GPIO +config PINCTRL_MTK_PARIS + bool "MediaTek Paris Core that implements vendor binding" + depends on OF + select PINMUX + select GENERIC_PINCONF + select GPIOLIB + select EINT_MTK + select OF_GPIO + # For ARMv7 SoCs config PINCTRL_MT2701 bool "Mediatek MT2701 pin control"
drivers/pinctrl/mediatek/Makefile +1 -0
@@ -3,6 +3,7 @@ obj-$(CONFIG_EINT_MTK) += mtk-eint.o obj-$(CONFIG_PINCTRL_MTK) += pinctrl-mtk-common.o obj-$(CONFIG_PINCTRL_MTK_MOORE) += pinctrl-moore.o pinctrl-mtk-common-v2.o +obj-$(CONFIG_PINCTRL_MTK_PARIS) += pinctrl-paris.o pinctrl-mtk-common-v2.o # SoC Drivers obj-$(CONFIG_PINCTRL_MT2701) += pinctrl-mt2701.o
drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.h +8 -0
@@ -174,6 +174,12 @@ struct mtk_pin_desc {struct mtk_func_desc *funcs; }; +struct mtk_pinctrl_group { +const char *name; +unsigned long config; +unsigned pin; +}; +struct mtk_pinctrl ;/* struct mtk_pin_soc - the structure that holds SoC-specific data */
@@ -228,6 +234,8 @@ struct mtk_pinctrl {struct gpio_chip chip;const struct mtk_pin_soc *soc;struct mtk_eint *eint; +struct mtk_pinctrl_group *groups; +const char **grp_names; };void mtk_rmw (struct mtk_pinctrl *pctl,u8 i,u32 reg,u32 mask,u32 set);
drivers/pinctrl/mediatek/pinctrl-paris.c new file +884 -0
884 lines not on this page · raw message
drivers/pinctrl/mediatek/pinctrl-paris.h new file +65 -0
65 lines not on this page · raw message
Signature · 1 line
2.7.4
PATCH v2 18/22 pinctrl: mediatek: add MT8183 pinctrl driver
In reply to [email protected]From: Zhiyong Tao <[email protected]>
Add MT8183 pinctrl driver based on MediaTek pinctrl-paris core.
--- drivers/pinctrl/mediatek/Kconfig | 7 + drivers/pinctrl/mediatek/Makefile | 1 + drivers/pinctrl/mediatek/pinctrl-mt8183.c | 512 +++++++ drivers/pinctrl/mediatek/pinctrl-mtk-mt8183.h | 1916 +++++++++++++++++++++++++ 4 files changed, 2436 insertions(+) create mode 100644 drivers/pinctrl/mediatek/pinctrl-mt8183.c create mode 100644 drivers/pinctrl/mediatek/pinctrl-mtk-mt8183.h
drivers/pinctrl/mediatek/Kconfig +7 -0
@@ -82,6 +82,13 @@ config PINCTRL_MT8173 default ARM64 && ARCH_MEDIATEK select PINCTRL_MTK +config PINCTRL_MT8183 + bool "Mediatek MT8183 pin control" + depends on OF + depends on ARM64 || COMPILE_TEST + default ARM64 && ARCH_MEDIATEK + select PINCTRL_MTK_PARIS + # For PMIC config PINCTRL_MT6397 bool "Mediatek MT6397 pin control"
drivers/pinctrl/mediatek/Makefile +1 -0
@@ -13,4 +13,5 @@ obj-$(CONFIG_PINCTRL_MT8127) += pinctrl-mt8127.o obj-$(CONFIG_PINCTRL_MT7622) += pinctrl-mt7622.o obj-$(CONFIG_PINCTRL_MT7623) += pinctrl-mt7623.o obj-$(CONFIG_PINCTRL_MT8173) += pinctrl-mt8173.o +obj-$(CONFIG_PINCTRL_MT8183) += pinctrl-mt8183.o obj-$(CONFIG_PINCTRL_MT6397) += pinctrl-mt6397.o
drivers/pinctrl/mediatek/pinctrl-mt8183.c new file +512 -0
512 lines not on this page · raw message
drivers/pinctrl/mediatek/pinctrl-mtk-mt8183.h new file +1916 -0
1,916 lines not on this page · raw message
Signature · 1 line
2.7.4
PATCH v2 19/22 pinctrl: mediatek: extend advanced pull support in pinctrl-mtk-common-v2.c
In reply to [email protected]From: Sean Wang <[email protected]>
Extend the advanced pull based on the legacy bias plus additional r0 and r1 to tweak the resistor level.
--- drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.c | 37 ++++++++++++++++++++---- 1 file changed, 32 insertions(+), 5 deletions(-)
drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.c +32 -5
@@ -476,6 +476,19 @@ int mtk_pinconf_adv_pull_set(struct mtk_pinctrl *hw, err =mtk_hw_set_value (hw, desc,PINCTRL_PIN_REG_PUPD , arg); +/* If PUPD register is not supported for that pin, let's fallback to +* general bias control. +*/ +if (err == -ENOTSUPP ) { +if (hw->soc->bias_set) { + err = hw->soc->bias_set (hw, desc, pullup); +if (err) +return err; + }else { +return -ENOTSUPP ; + } + } +return err; }
@@ -487,12 +500,26 @@ int mtk_pinconf_adv_pull_get(struct mtk_pinctrl *hw,int err; err =mtk_hw_get_value (hw, desc,PINCTRL_PIN_REG_PUPD , &t); -if (err) -return err; -/* t == 0 supposes PULLUP for the customized PULL setup */ -if (pullup ^ !t) -return -EINVAL ; +/* If PUPD register is not supported for that pin, let's fallback to +* general bias control. +*/ +if (err == -ENOTSUPP ) { +if (hw->soc->bias_get) { + err = hw->soc->bias_get (hw, desc, pullup, val); +if (err) +return err; + }else { +return -ENOTSUPP ; + } + }else { +/* t == 0 supposes PULLUP for the customized PULL setup */ +if (err) +return err; + +if (pullup ^ !t) +return -EINVAL ; + } err =mtk_hw_get_value (hw, desc,PINCTRL_PIN_REG_R0 , &t);if (err)
Signature · 1 line
2.7.4
PATCH v2 20/22 pintcrl: mediatek: add pull tweaks for I2C related pins on MT8183
In reply to [email protected]From: Zhiyong Tao <[email protected]>
This patch provides the advanced pull for I2C used pins on MT8183.
--- drivers/pinctrl/mediatek/pinctrl-mt8183.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+)
drivers/pinctrl/mediatek/pinctrl-mt8183.c +24 -0
@@ -397,10 +397,22 @@ static const struct mtk_pin_field_calc mt8183_pin_r0_range[] = {PIN_FIELD_BASE (40 ,40 ,3 ,0x0C0 ,0x10 ,20 ,1 ),PIN_FIELD_BASE (41 ,41 ,3 ,0x0C0 ,0x10 ,24 ,1 ),PIN_FIELD_BASE (42 ,42 ,3 ,0x0C0 ,0x10 ,28 ,1 ), +PIN_FIELD_BASE (48 ,48 ,3 ,0x0F0 ,0x10 ,18 ,1 ), +PIN_FIELD_BASE (49 ,49 ,3 ,0x0F0 ,0x10 ,13 ,1 ), +PIN_FIELD_BASE (50 ,50 ,4 ,0x0F0 ,0x10 ,10 ,1 ), +PIN_FIELD_BASE (51 ,51 ,4 ,0x0F0 ,0x10 ,5 ,1 ), +PIN_FIELD_BASE (81 ,81 ,5 ,0x0F0 ,0x10 ,7 ,1 ), +PIN_FIELD_BASE (82 ,82 ,5 ,0x0F0 ,0x10 ,5 ,1 ), +PIN_FIELD_BASE (83 ,83 ,5 ,0x0F0 ,0x10 ,15 ,1 ), +PIN_FIELD_BASE (84 ,84 ,5 ,0x0F0 ,0x10 ,17 ,1 ),PIN_FIELD_BASE (91 ,91 ,6 ,0x0C0 ,0x10 ,0 ,1 ),PIN_FIELD_BASE (92 ,92 ,6 ,0x0C0 ,0x10 ,4 ,1 ),PIN_FIELD_BASE (93 ,93 ,6 ,0x0C0 ,0x10 ,8 ,1 ),PIN_FIELD_BASE (94 ,94 ,6 ,0x0C0 ,0x10 ,12 ,1 ), +PIN_FIELD_BASE (103 ,103 ,6 ,0x0F0 ,0x10 ,20 ,1 ), +PIN_FIELD_BASE (104 ,104 ,6 ,0x0F0 ,0x10 ,10 ,1 ), +PIN_FIELD_BASE (105 ,105 ,6 ,0x0F0 ,0x10 ,22 ,1 ), +PIN_FIELD_BASE (106 ,106 ,6 ,0x0F0 ,0x10 ,12 ,1 ),PIN_FIELD_BASE (122 ,122 ,8 ,0x0C0 ,0x10 ,0 ,1 ),PIN_FIELD_BASE (123 ,123 ,8 ,0x0C0 ,0x10 ,4 ,1 ), PIN_FIELD_BASE(124, 124, 8, 0x0C0, 0x10, 8, 1),
@@ -430,10 +442,22 @@ static const struct mtk_pin_field_calc mt8183_pin_r1_range[] = {PIN_FIELD_BASE (40 ,40 ,3 ,0x0C0 ,0x10 ,21 ,1 ),PIN_FIELD_BASE (41 ,41 ,3 ,0x0C0 ,0x10 ,25 ,1 ),PIN_FIELD_BASE (42 ,42 ,3 ,0x0C0 ,0x10 ,29 ,1 ), +PIN_FIELD_BASE (48 ,48 ,3 ,0x0F0 ,0x10 ,19 ,1 ), +PIN_FIELD_BASE (49 ,49 ,3 ,0x0F0 ,0x10 ,14 ,1 ), +PIN_FIELD_BASE (50 ,50 ,4 ,0x0F0 ,0x10 ,11 ,1 ), +PIN_FIELD_BASE (51 ,51 ,4 ,0x0F0 ,0x10 ,6 ,1 ), +PIN_FIELD_BASE (81 ,81 ,5 ,0x0F0 ,0x10 ,8 ,1 ), +PIN_FIELD_BASE (82 ,82 ,5 ,0x0F0 ,0x10 ,6 ,1 ), +PIN_FIELD_BASE (83 ,83 ,5 ,0x0F0 ,0x10 ,16 ,1 ), +PIN_FIELD_BASE (84 ,84 ,5 ,0x0F0 ,0x10 ,18 ,1 ),PIN_FIELD_BASE (91 ,91 ,6 ,0x0C0 ,0x10 ,1 ,1 ),PIN_FIELD_BASE (92 ,92 ,6 ,0x0C0 ,0x10 ,5 ,1 ),PIN_FIELD_BASE (93 ,93 ,6 ,0x0C0 ,0x10 ,9 ,1 ),PIN_FIELD_BASE (94 ,94 ,6 ,0x0C0 ,0x10 ,13 ,1 ), +PIN_FIELD_BASE (103 ,103 ,6 ,0x0F0 ,0x10 ,21 ,1 ), +PIN_FIELD_BASE (104 ,104 ,6 ,0x0F0 ,0x10 ,11 ,1 ), +PIN_FIELD_BASE (105 ,105 ,6 ,0x0F0 ,0x10 ,23 ,1 ), +PIN_FIELD_BASE (106 ,106 ,6 ,0x0F0 ,0x10 ,13 ,1 ),PIN_FIELD_BASE (122 ,122 ,8 ,0x0C0 ,0x10 ,1 ,1 ),PIN_FIELD_BASE (123 ,123 ,8 ,0x0C0 ,0x10 ,5 ,1 ), PIN_FIELD_BASE(124, 124, 8, 0x0C0, 0x10, 9, 1),
Signature · 1 line
2.7.4
PATCH v2 21/22 pinctrl: mediatek: extend eint build to pinctrl-mtk-common-v2.c
In reply to [email protected]From: Sean Wang <[email protected]>
Almost all MediaTek SoCs apply the exact same logic to build eint, so move the common functions into pinctrl-mtk-common-v2.c to allow each new pinctrl driver to reuse them. Also, add a protection checker on hw->soc->eint_hw to avoid invalid memory access when there's certain SoC not to define its eint_hw properly in the code flow.
--- drivers/pinctrl/mediatek/pinctrl-moore.c | 124 --------------------- drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.c | 135 +++++++++++++++++++++++ drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.h | 2 + 3 files changed, 137 insertions(+), 124 deletions(-)
drivers/pinctrl/mediatek/pinctrl-moore.c +0 -124
@@ -584,130 +584,6 @@ static int mtk_build_functions(struct mtk_pinctrl *hw)return 0 ; } -static int mtk_xt_find_eint_num (struct mtk_pinctrl *hw, -unsigned long eint_n) -{ -const struct mtk_pin_desc *desc; -int i =0 ; - - desc = (const struct mtk_pin_desc *)hw->soc->pins; - -while (i < hw->soc->npins) { -if (desc[i].eint.eint_n == eint_n) -return desc[i].number; - i++; - } - -return EINT_NA ; -} - -static int mtk_xt_get_gpio_n (void *data,unsigned long eint_n, -unsigned int *gpio_n, -struct gpio_chip **gpio_chip) -{ -struct mtk_pinctrl *hw = (struct mtk_pinctrl *)data; -const struct mtk_pin_desc *desc; - - desc = (const struct mtk_pin_desc *)hw->soc->pins; - *gpio_chip = &hw->chip; - -/* Be greedy to guess first gpio_n is equal to eint_n */ -if (desc[eint_n].eint.eint_n == eint_n) - *gpio_n = eint_n; -else - *gpio_n =mtk_xt_find_eint_num (hw, eint_n); - -return *gpio_n ==EINT_NA ? -EINVAL :0 ; -} - -static int mtk_xt_get_gpio_state (void *data,unsigned long eint_n) -{ -struct mtk_pinctrl *hw = (struct mtk_pinctrl *)data; -struct gpio_chip *gpio_chip; -unsigned int gpio_n; -int err; - - err =mtk_xt_get_gpio_n (hw, eint_n, &gpio_n, &gpio_chip); -if (err) -return err; - -return mtk_gpio_get (gpio_chip, gpio_n); -} - -static int mtk_xt_set_gpio_as_eint (void *data,unsigned long eint_n) -{ -struct mtk_pinctrl *hw = (struct mtk_pinctrl *)data; -const struct mtk_pin_desc *desc; -struct gpio_chip *gpio_chip; -unsigned int gpio_n; -int err; - - err =mtk_xt_get_gpio_n (hw, eint_n, &gpio_n, &gpio_chip); -if (err) -return err; - - desc = (const struct mtk_pin_desc *)&hw->soc->pins[gpio_n]; - - err =mtk_hw_set_value (hw, desc,PINCTRL_PIN_REG_MODE , - desc->eint.eint_m); -if (err) -return err; - - err =mtk_hw_set_value (hw, desc,PINCTRL_PIN_REG_DIR ,MTK_INPUT ); -if (err) -return err; - - err =mtk_hw_set_value (hw, desc,PINCTRL_PIN_REG_SMT ,MTK_ENABLE ); -if (err) -return err; - -return 0 ; -} - -static const struct mtk_eint_xt mtk_eint_xt = { - .get_gpio_n = mtk_xt_get_gpio_n, - .get_gpio_state = mtk_xt_get_gpio_state, - .set_gpio_as_eint = mtk_xt_set_gpio_as_eint, -}; - -static int -mtk_build_eint (struct mtk_pinctrl *hw,struct platform_device *pdev) -{ -struct device_node *np = pdev->dev.of_node; -struct resource *res; - -if (!IS_ENABLED (CONFIG_EINT_MTK )) -return 0 ; - -if (!of_property_read_bool (np,"interrupt-controller" )) -return -ENODEV ; - - hw->eint =devm_kzalloc (hw->dev,sizeof (*hw->eint),GFP_KERNEL ); -if (!hw->eint) -return -ENOMEM ; - - res =platform_get_resource_byname (pdev,IORESOURCE_MEM ,"eint" ); -if (!res) { -dev_err (&pdev->dev,"Unable to get eint resource\n" ); -return -ENODEV ; - } - - hw->eint->base =devm_ioremap_resource (&pdev->dev, res); -if (IS_ERR (hw->eint->base)) -return PTR_ERR (hw->eint->base); - - hw->eint->irq =irq_of_parse_and_map (np,0 ); -if (!hw->eint->irq) -return -EINVAL ; - - hw->eint->dev = &pdev->dev; - hw->eint->hw = hw->soc->eint_hw; - hw->eint->pctl = hw; - hw->eint->gpio_xlate = &mtk_eint_xt; - -return mtk_eint_do_init (hw->eint); -} -int mtk_moore_pinctrl_probe (struct platform_device *pdev,const struct mtk_pin_soc *soc) {
drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.c +135 -0
149 lines not on this page · raw message
drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.h +2 -0
@@ -245,6 +245,8 @@ int mtk_hw_set_value(struct mtk_pinctrl *hw, const struct mtk_pin_desc *desc,int mtk_hw_get_value (struct mtk_pinctrl *hw,const struct mtk_pin_desc *desc,int field,int *value); +int mtk_build_eint (struct mtk_pinctrl *hw,struct platform_device *pdev); +int mtk_pinconf_bias_disable_set (struct mtk_pinctrl *hw,const struct mtk_pin_desc *desc); int mtk_pinconf_bias_disable_get(struct mtk_pinctrl *hw,
Signature · 1 line
2.7.4
PATCH v2 22/22 pinctrl: mediatek: add eint support to MT8183 pinctrl driver
In reply to [email protected]From: Sean Wang <[email protected]>
Just add eint support to MT8183 pinctrl driver as usual as happens on the other SoCs.
--- drivers/pinctrl/mediatek/pinctrl-mt8183.c | 8 ++++++++ drivers/pinctrl/mediatek/pinctrl-paris.c | 22 ++++++++++++++++++++++ 2 files changed, 30 insertions(+)
drivers/pinctrl/mediatek/pinctrl-mt8183.c +8 -0
@@ -492,11 +492,19 @@ static const char * const mt8183_pinctrl_register_base_names[] = { "iocfg6", "iocfg7", "iocfg8", }; +static const struct mtk_eint_hw mt8183_eint_hw = { + .port_mask =7 , + .ports =6 , + .ap_num =212 , + .db_cnt =13 , +}; +static const struct mtk_pin_soc mt8183_data = { .reg_cal = mt8183_reg_cals, .pins = mtk_pins_mt8183, .npins =ARRAY_SIZE (mtk_pins_mt8183), .ngrps =ARRAY_SIZE (mtk_pins_mt8183), + .eint_hw = &mt8183_eint_hw, .gpio_m =0 , .ies_present = true, .base_names = mt8183_pinctrl_register_base_names,
drivers/pinctrl/mediatek/pinctrl-paris.c +22 -0
@@ -718,6 +718,22 @@ static int mtk_gpio_direction_output(struct gpio_chip *chip, unsigned int gpio,return pinctrl_gpio_direction_output (chip->base + gpio); } +static int mtk_gpio_to_irq (struct gpio_chip *chip,unsigned int offset) +{ +struct mtk_pinctrl *hw =gpiochip_get_data (chip); +const struct mtk_pin_desc *desc; + +if (!hw->eint) +return -ENOTSUPP ; + + desc = (const struct mtk_pin_desc *)&hw->soc->pins[offset]; + +if (desc->eint.eint_n ==EINT_NA ) +return -ENOTSUPP ; + +return mtk_eint_find_irq (hw->eint, desc->eint.eint_n); +} +static int mtk_gpio_set_config (struct gpio_chip *chip,unsigned int offset,unsigned long config) {
@@ -751,6 +767,7 @@ static int mtk_build_gpiochip(struct mtk_pinctrl *hw, struct device_node *np) chip->direction_output = mtk_gpio_direction_output; chip->get = mtk_gpio_get; chip->set = mtk_gpio_set; + chip->to_irq = mtk_gpio_to_irq, chip->set_config = mtk_gpio_set_config, chip->base =-1 ; chip->ngpio = hw->soc->npins;
@@ -871,6 +888,11 @@ int mtk_paris_pinctrl_probe(struct platform_device *pdev,if (err)return err; + err =mtk_build_eint (hw, pdev); +if (err) +dev_warn (&pdev->dev, +"Failed to add EINT, but pinctrl still can work\n" ); +/* Build gpiochip should be after pinctrl_enable is done */ err =mtk_build_gpiochip (hw, pdev->dev.of_node);if (err) {
Signature · 1 line
2.7.4
Re: [PATCH v2 01/22] pinctrl: mediatek: add pinctrl-mtk-common-v2 for all MediaTek pinctrls
In reply to sean.wang at mediatek.comQuoted 13 lines · On Sat, Sep 8, 2018 at 4:07 AM <[email protected]> wrote:
From: Sean Wang <[email protected]>
Irregular register arrangement and distinct logic access from various MediaTek SoCs would cause pinctrl-mtk-common to bloat and really hard to maintain in the future so that the patch creates pinctrl-mtk-common-v2 based on the core of mt7622-pinctrl.
The goals pinctrl-mtk-common-v2 want to achieve are to hopefully support all of MediaTek SoCs, and two kinds of dt-bindings being supported, Linux generic pinctrl dt-binding mt7622 supports and MediaTek per-pin dt-binding the other SoCs support the MT8183 and MT6765 incline to make use of.
Quoted 6 lines
The patch starts to refactor MT7622 pinctrl driver first with splitting out these portable ways from there such as table-based register operation and drive strength control that is common in both kinds of driver.
Signed-off-by Ryder.Lee <[email protected]>Signed-off-by Sean Wang <[email protected]>
Patch applied, had to use some fuzzing and removed a <linux/gpio.h> include that was not used.
Yours,
Linus Walleij
Re: [PATCH v2 02/22] pinctrl: mediatek: add pinctrl-moore that implements the generic pinctrl dt-bindings
In reply to sean.wang at mediatek.comQuoted 10 lines · On Sat, Sep 8, 2018 at 4:07 AM <[email protected]> wrote:
From: Sean Wang <[email protected]>
Add a generic driver
pinctrl-moore.cfor MT762x SoC and any other SoC that would like to use generic dt-binding. The patch is furtherly refactored frompinctrl-mt7622.cthat totally uses the functions back by the generic pinctrl core such asGENERIC_PINCONF,GENERIC_PINCTRL_GROUPS, andGENERIC_PINMUX_FUNCTIONSand its binding also completely follows up pinctrl-bindings.txt inDocumentation/devicetree/bindings/pinctrl/to implement.
Quoted 2 lines
Signed-off-by Ryder.Lee <[email protected]>Signed-off-by Sean Wang <[email protected]>
Patch applied with some fuzzing, and removing un unused <linux/gpio.h> include.
Yours,
Linus Walleij
Re: [PATCH v2 03/22] pinctrl: mediatek: extend struct mtk_pin_field_calc to pinctrl-mtk-common-v2.c
In reply to [email protected]Quoted 11 lines · On Sat, Sep 8, 2018 at 4:08 AM <[email protected]> wrote:
From: Sean Wang <[email protected]>
This patch adds members
sz_regfixed in structmtk_pin_field_calc- The 'fixed' is used to represent the consecutive pins share the same bits within the same register with the 1st pin so that it can largely reduce the entry size a bit.
- The '
sz_reg' is used to indicate the range of bits we use in a register that may vary by SoC
Quoted 7 lines
The above changes make the code more generic and this is useful as there might be other existing or future chips all use the same logic to access their register set and then being a little more abstract could help in the long run.
Signed-off-by Ryder Lee <[email protected]>Signed-off-by Sean Wang <[email protected]>
Patch applied.
Yours,
Linus Walleij
Re: [PATCH v2 04/22] pinctrl: mediatek: extend struct mtk_pin_desc to pinctrl-mtk-common-v2.c
In reply to sean.wang at mediatek.comQuoted 11 lines · On Sat, Sep 8, 2018 at 4:07 AM <[email protected]> wrote:
From: Sean Wang <[email protected]>
This patch introduces a data structure
mtk_pin_desc, which is used to provide information per pin characteristic such as driving current, eint number and a driving index, that is used to lookup table describing the details about the groups of driving current by which the pin is able to adjust the driving strength so that the driver could get the appropriate driving group when calls .pin_config_get()/set().Signed-off-by Ryder.Lee <[email protected]>Signed-off-by Sean Wang <[email protected]>
Patch applied.
Yours,
Linus Walleij
Re: [PATCH v2 05/22] pinctrl: mediatek: extend struct mtk_pin_soc to pinctrl-mtk-common-v2.c
In reply to sean.wang at mediatek.comQuoted 7 lines · On Sat, Sep 8, 2018 at 4:07 AM <[email protected]> wrote:
From: Sean Wang <[email protected]>
Add two parameters
gpio_mandeint_mfor configuring GPIO mode and EINT mode, they might be varying depend on SoC.Signed-off-by Ryder.Lee <[email protected]>Signed-off-by Sean Wang <[email protected]>
Patch applied.
Yours,
Linus Walleij
Re: [PATCH v2 06/22] pinctrl: mediatek: add driving strength related support to pinctrl-mtk-common-v2.c
In reply to sean.wang at mediatek.comQuoted 8 lines · On Sat, Sep 8, 2018 at 4:07 AM <[email protected]> wrote:
From: Sean Wang <[email protected]>
Put driving strength support related functions to
pinctrl-mtk-common-v2.cas these operations might be different by chips and allow different type of driver to reuse them.Signed-off-by Ryder.Lee <[email protected]>Signed-off-by Sean Wang <[email protected]>
Patch applied.
Yours,
Linus Walleij
Re: [PATCH v2 07/22] pinctrl: mediatek: add drv register support to pinctrl-mtk-common-v2.c
In reply to sean.wang at mediatek.comQuoted 7 lines · On Sat, Sep 8, 2018 at 4:07 AM <[email protected]> wrote:
From: Sean Wang <[email protected]>
Certain SoCs have to program DRV register to configure driving strength so that we add it in the existing path as an option.
Signed-off-by Ryder.Lee <[email protected]>Signed-off-by Sean Wang <[email protected]>
Patch applied.
Yours,
Linus Walleij
Re: [PATCH v2 08/22] pinctrl: mediatek: add pull related support to pinctrl-mtk-common-v2.c
In reply to sean.wang at mediatek.comQuoted 8 lines · On Sat, Sep 8, 2018 at 4:07 AM <[email protected]> wrote:
From: Sean Wang <[email protected]>
Put pull control support related functions to
pinctrl-mtk-common-v2.cas these operations might be different by chips and allow different type of driver to reuse them.Signed-off-by Ryder.Lee <[email protected]>Signed-off-by Sean Wang <[email protected]>
Patch applied.
Yours,
Linus Walleij
Re: [PATCH v2 09/22] pinctrl: mediatek: add advanced pull related support to pinctrl-mtk-common-v2.c
In reply to sean.wang at mediatek.comQuoted 10 lines · On Sat, Sep 8, 2018 at 4:07 AM <[email protected]> wrote:
From: Sean Wang <[email protected]>
There are some specific pins (i.e. MMC/SD) need specific registers to turn on/off the 10K & 50k(75K) resistors when pull up/down.
Therefore, this patch adds the custom prarmeters so that the user could control it through device tree.
Signed-off-by Ryder.Lee <[email protected]>Signed-off-by Sean Wang <[email protected]>
Patch applied.
Yours,
Linus Walleij
Re: [PATCH v2 10/22] pinctrl: mediatek: add ies register support to pinctrl-mtk-common-v2.c
In reply to sean.wang at mediatek.comQuoted 7 lines · On Sat, Sep 8, 2018 at 4:07 AM <[email protected]> wrote:
From: Sean Wang <[email protected]>
Certain SoCs have to program an extra IES register to configure input enabled mode so that we add it in the existing path as an option.
Signed-off-by Ryder.Lee <[email protected]>Signed-off-by Sean Wang <[email protected]>
Patch applied.
Yours,
Linus Walleij
Re: [PATCH v2 11/22] pinctrl: mediatek: add pullen, pullsel register support to pinctrl-mtk-common-v2.c
In reply to sean.wang at mediatek.comQuoted 7 lines · On Sat, Sep 8, 2018 at 4:07 AM <[email protected]> wrote:
From: Sean Wang <[email protected]>
Certain SoCs have to program an extra PULLEN, PULLSEL register to configure bias related function so that we add it in the existing path.
Signed-off-by Ryder.Lee <[email protected]>Signed-off-by Sean Wang <[email protected]>
Patch applied.
Yours,
Linus Walleij
Re: [PATCH v2 12/22] pinctrl: mediatek: add MT7623 pinctrl driver based on generic pinctrl binding
In reply to [email protected]Quoted 9 lines · On Sat, Sep 8, 2018 at 4:07 AM <[email protected]> wrote:
From: Sean Wang <[email protected]>
Adding MT7623 pinctrl driver based on generic pinctrl binding, that is good example and demonstrates how to port any other MediaTek SoCs pinctrl-moore core when people really would like to use the generic pinctrl binding to support these MediaTek SoCs.
Signed-off-by Ryder Lee <[email protected]>Signed-off-by Sean Wang <[email protected]>
Patch applied.
Yours,
Linus Walleij
Re: [PATCH v2 13/22] pinctrl: mediatek: use pin descriptor all in pinctrl-mtk-common-v2.c
In reply to [email protected]Quoted 6 lines · On Sat, Sep 8, 2018 at 4:07 AM <[email protected]> wrote:
From: Sean Wang <[email protected]>
all use pin descriptor instead in
pinctrl-mtk-common-v2.cfor the consistency and extensibility.Signed-off-by Sean Wang <[email protected]>
Patch applied.
Yours,
Linus Walleij
Re: [PATCH v2 14/22] pinctrl: mediatek: add multiple register bases support to pinctrl-mtk-common-v2.c
In reply to [email protected]Quoted 7 lines · On Sat, Sep 8, 2018 at 4:07 AM <[email protected]> wrote:
From: Sean Wang <[email protected]>
Certain SoC own multiple register base for accessing each pin groups, it's easy to be done with extend struct
mtk_pin_field_calcto support the kind of SoC such as MT8183.Signed-off-by Sean Wang <[email protected]>
Patch applied.
Yours,
Linus Walleij
Re: [PATCH v2 15/22] pinctrl: mediatek: adjust error code and message when some register not supported is found
In reply to [email protected]Quoted 7 lines · On Sat, Sep 8, 2018 at 4:07 AM <[email protected]> wrote:
From: Sean Wang <[email protected]>
It's usual and not an error for there's some register not supported by a certain SoC or a pin so that in the case we have to adjust the message to print and the error code to get rid of unnecessary false alarm.
Signed-off-by Sean Wang <[email protected]>
Patch applied.
Yours,
Linus Walleij
Re: [PATCH v2 16/22] pinctrl: mediatek: extend struct mtk_pin_desc which per-pin driver depends on
In reply to [email protected]Quoted 11 lines · On Sat, Sep 8, 2018 at 4:08 AM <[email protected]> wrote:
From: Sean Wang <[email protected]>
Because the
pincrl-mtk-common.cis an implementation for per-pin binding, its pin descriptor includes more information than pinctrl-mtk-common-v2 so far can support. So, we complement these data before writing a driver usingpincrl-mtk-common-v2.cfor per-pin binding. By the way, the size of structmtk_pin_descwould be larger than structpinctrl_pin_desccan hold, so it's necessary to have a copy before the pins information is being registered into the core.Signed-off-by Sean Wang <[email protected]>
Patch applied.
Yours,
Linus Walleij
Re: [PATCH v2 17/22] pinctrl: mediatek: add pinctrl-paris that implements the vendor dt-bindings
In reply to [email protected]Quoted 11 lines · On Sat, Sep 8, 2018 at 4:08 AM <[email protected]> wrote:
From: Zhiyong Tao <[email protected]>
Add pinctrl-paris core that implements vendor dt-binding which MediaTek tablet, box and smartphone-based SoCs such as MT81xx, MT27xx, and MT67xx SoCs really want to depend on. The driver is just completely rewritten according to
pinctrl-mtk-common.cbut uses the new logic frompinctrl-mtk-common-v2.cto have an elegant way to support new SoCs in the future.Signed-off-by Zhiyong Tao <[email protected]>Signed-off-by Sean Wang <[email protected]>
Patch applied.
Yours,
Linus Walleij
Re: [PATCH v2 18/22] pinctrl: mediatek: add MT8183 pinctrl driver
In reply to [email protected]Quoted 6 lines · On Sat, Sep 8, 2018 at 4:07 AM <[email protected]> wrote:
From: Zhiyong Tao <[email protected]>
Add MT8183 pinctrl driver based on MediaTek pinctrl-paris core.
Signed-off-by Zhiyong Tao <[email protected]>Signed-off-by Sean Wang <[email protected]>
Patch applied.
Yours,
Linus Walleij
Re: [PATCH v2 19/22] pinctrl: mediatek: extend advanced pull support in pinctrl-mtk-common-v2.c
In reply to [email protected]Quoted 7 lines · On Sat, Sep 8, 2018 at 4:08 AM <[email protected]> wrote:
From: Sean Wang <[email protected]>
Extend the advanced pull based on the legacy bias plus additional r0 and r1 to tweak the resistor level.
Signed-off-by Zhiyong Tao <[email protected]>Signed-off-by Sean Wang <[email protected]>
Patch applied.
Yours,
Linus Walleij
Re: [PATCH v2 20/22] pintcrl: mediatek: add pull tweaks for I2C related pins on MT8183
In reply to [email protected]Quoted 6 lines · On Sat, Sep 8, 2018 at 4:07 AM <[email protected]> wrote:
From: Zhiyong Tao <[email protected]>
This patch provides the advanced pull for I2C used pins on MT8183.
Signed-off-by Zhiyong Tao <[email protected]>Signed-off-by Sean Wang <[email protected]>
Patch applied.
Yours,
Linus Walleij
Quoted 1 line · On Sat, Sep 8, 2018 at 4:07 AM <[email protected]> wrote:
v2 and changes since v1:
I had trouble applying the last patches in the series so I applied all on an immutable branch (ib-mtk) then merged that into devel and added a patch on top to fix up some GPIO includes (just sent).
Please check the result!
Yours,
Linus Walleij
Quoted 10 lines · Linus Walleij
Quoted 1 line · On Sat, Sep 8, 2018 at 4:07 AM <[email protected]> wrote:
v2 and changes since v1:
I had trouble applying the last patches in the series so I applied all on an immutable branch (ib-mtk) then merged that into devel and added a patch on top to fix up some GPIO includes (just sent).
Please check the result!
Sure, I'll take a look and and test on the devel branch.
On the top, I'll add a fix for the issue recently reported by kbuild test robot about implicit declaration and a new MT6765 driver based on the series.
Quoted 2 lines
Yours,
Linus Walleij
Quoted 9 lines · Sean Wang
Quoted 8 lines · Linus Walleij
Quoted 1 line · On Sat, Sep 8, 2018 at 4:07 AM <[email protected]> wrote:
v2 and changes since v1:
I had trouble applying the last patches in the series so I applied all on an immutable branch (ib-mtk) then merged that into devel and added a patch on top to fix up some GPIO includes (just sent).
Quoted 9 lines
Quoted 2 lines
Please check the result!
Sure, I'll take a look and and test on the devel branch.
On the top, I'll add a fix for the issue recently reported by kbuild test robot about implicit declaration and a new MT6765 driver based on the series.
Hi Sean,
Do you have any plans to add support for MT6797?
Thanks,
Mani
Quoted 4 lines
Quoted 2 lines
Yours,
Linus Walleij
Quoted 15 lines · Manivannan Sadhasivam
Quoted 14 lines · Sean Wang
Quoted 10 lines · Linus Walleij
Quoted 1 line · On Sat, Sep 8, 2018 at 4:07 AM <[email protected]> wrote:
v2 and changes since v1:
I had trouble applying the last patches in the series so I applied all on an immutable branch (ib-mtk) then merged that into devel and added a patch on top to fix up some GPIO includes (just sent).
Please check the result!
Sure, I'll take a look and and test on the devel branch.
Quoted 9 lines
Quoted 4 lines
On the top, I'll add a fix for the issue recently reported by kbuild test robot about implicit declaration and a new MT6765 driver based on the series.
Hi Sean,
Do you have any plans to add support for MT6797?
I personally have no the plan to add support to MT6797 because I have no the device, but as I knew some of people in mediatek have interest to add them by volunteers and thus there is no clear schedule. Eventually, if they're really done, they would be still based on vendor binding not by generic binding.
Quoted 7 lines
Thanks,
ManiQuoted 4 lines
Quoted 2 lines
Yours,
Linus Walleij
Matthias Brugger
maintainerQuoted 23 lines · Sean Wang
Quoted 22 lines · Manivannan Sadhasivam
Quoted 9 lines · Sean Wang
Quoted 8 lines · Linus Walleij
Quoted 1 line · On Sat, Sep 8, 2018 at 4:07 AM <[email protected]> wrote:
v2 and changes since v1:
I had trouble applying the last patches in the series so I applied all on an immutable branch (ib-mtk) then merged that into devel and added a patch on top to fix up some GPIO includes (just sent).
Quoted 9 lines
Quoted 2 lines
Please check the result!
Sure, I'll take a look and and test on the devel branch.
On the top, I'll add a fix for the issue recently reported by kbuild test robot about implicit declaration and a new MT6765 driver based on the series.
Hi Sean,
Quoted 9 lines
Quoted 2 lines
Do you have any plans to add support for MT6797?
I personally have no the plan to add support to MT6797 because I have no the device, but as I knew some of people in mediatek have interest to add them by volunteers and thus there is no clear schedule. Eventually, if they're really done, they would be still based on vendor binding not by generic binding.
CCing Saber as he is working on the pinctrl for this device. Actually he as some questions regarding the register layout.
Sean maybe you can bring him in contact with someone inside Mediatek who could help him :)
Regards.
Matthias
Quoted 36 lines · Matthias Brugger
Quoted 23 lines · Sean Wang
Quoted 22 lines · Manivannan Sadhasivam
Quoted 9 lines · Sean Wang
Quoted 8 lines · Linus Walleij
Quoted 1 line · On Sat, Sep 8, 2018 at 4:07 AM <[email protected]> wrote:
v2 and changes since v1:
I had trouble applying the last patches in the series so I applied all on an immutable branch (ib-mtk) then merged that into devel and added a patch on top to fix up some GPIO includes (just sent).
Quoted 9 lines
Quoted 2 lines
Please check the result!
Sure, I'll take a look and and test on the devel branch.
On the top, I'll add a fix for the issue recently reported by kbuild test robot about implicit declaration and a new MT6765 driver based on the series.
Hi Sean,
Quoted 9 lines
Quoted 2 lines
Do you have any plans to add support for MT6797?
I personally have no the plan to add support to MT6797 because I have no the device, but as I knew some of people in mediatek have interest to add them by volunteers and thus there is no clear schedule. Eventually, if they're really done, they would be still based on vendor binding not by generic binding.
Quoted 6 lines
CCing Saber as he is working on the pinctrl for this device. Actually he as some questions regarding the register layout.
Sean maybe you can bring him in contact with someone inside Mediatek who could help him :)
FYI. I started working on MT6797 pinctrl support but never got time to finish it. You can find my initial work below. Eventhough it is based on the Mediatek SDK it should be fine IMO.
It would be great if someone (Saber) can took and finish it. The hard bit for me was lack of proper documentation :(
https://git.linaro.org/people/manivannan.sadhasivam/96b-common.git/log/?h=mt6797
Thanks,
Mani
Quoted 2 lines
Regards.
Matthias
Quoted 44 lines · Manivannan Sadhasivam
Quoted 36 lines · Matthias Brugger
Quoted 23 lines · Sean Wang
Quoted 22 lines · Manivannan Sadhasivam
Quoted 9 lines · Sean Wang
Quoted 8 lines · Linus Walleij
Quoted 1 line · On Sat, Sep 8, 2018 at 4:07 AM <[email protected]> wrote:
v2 and changes since v1:
I had trouble applying the last patches in the series so I applied all on an immutable branch (ib-mtk) then merged that into devel and added a patch on top to fix up some GPIO includes (just sent).
Quoted 9 lines
Quoted 2 lines
Please check the result!
Sure, I'll take a look and and test on the devel branch.
On the top, I'll add a fix for the issue recently reported by kbuild test robot about implicit declaration and a new MT6765 driver based on the series.
Hi Sean,
Quoted 9 lines
Quoted 2 lines
Do you have any plans to add support for MT6797?
I personally have no the plan to add support to MT6797 because I have no the device, but as I knew some of people in mediatek have interest to add them by volunteers and thus there is no clear schedule. Eventually, if they're really done, they would be still based on vendor binding not by generic binding.
Quoted 6 lines
CCing Saber as he is working on the pinctrl for this device. Actually he as some questions regarding the register layout.
Sean maybe you can bring him in contact with someone inside Mediatek who could help him :)
Quoted 7 lines
FYI. I started working on MT6797 pinctrl support but never got time to finish it. You can find my initial work below. Eventhough it is based on the Mediatek SDK it should be fine IMO.
It would be great if someone (Saber) can took and finish it. The hard bit for me was lack of proper documentation :(
s/documentation/datasheet
Quoted 7 lines
https://git.linaro.org/people/manivannan.sadhasivam/96b-common.git/log/?h=mt6797
Thanks,
ManiQuoted 2 lines
Regards.
Matthias