summaryrefslogtreecommitdiff
path: root/drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.h
AgeCommit message (Collapse)Author
2020-08-04pinctrl: mediatek: avoid virtual gpio trying to set regHanks Chen
for virtual gpios, they should not do reg setting and should behave as expected for eint function. Signed-off-by: Mars Cheng <mars.cheng@mediatek.com> Signed-off-by: Hanks Chen <hanks.chen@mediatek.com> Acked-by: Sean Wang <sean.wang@kernel.org> Link: https://lore.kernel.org/r/1595503197-15246-4-git-send-email-hanks.chen@mediatek.com Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
2020-07-16pinctrl: mediatek: pinctrl-mtk-common-v2: Mark ↵Lee Jones
'mtk_default_register_base_names' as __maybe_unused Not all sourcefiles which end up including pinctrl-mtk-common-v2.h make use of 'mtk_default_register_base_names' and there is nowhere we can place the definition to void the need for __maybe_unused except its own headerfile, which seems like overkill. So instead we tell the compiler that it's okay for it to be unused by some of the consumers. Fixes the following W=1 kernel build warning(s): In file included from drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.c:19: drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.h:83:27: warning: ‘mtk_default_register_base_names’ defined but not used [-Wunused-const-variable=] 83 | static const char const mtk_default_register_base_names[] = { | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ In file included from drivers/pinctrl/mediatek/pinctrl-moore.h:25, from drivers/pinctrl/mediatek/pinctrl-moore.c:12: drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.h:83:27: warning: ‘mtk_default_register_base_names’ defined but not used [-Wunused-const-variable=] 83 | static const char const mtk_default_register_base_names[] = { | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ In file included from drivers/pinctrl/mediatek/pinctrl-paris.h:27, from drivers/pinctrl/mediatek/pinctrl-paris.c:15: drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.h:83:27: warning: ‘mtk_default_register_base_names’ defined but not used [-Wunused-const-variable=] 83 | static const char const mtk_default_register_base_names[] = { | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ In file included from drivers/pinctrl/mediatek/pinctrl-paris.h:27, from drivers/pinctrl/mediatek/pinctrl-mtk-mt6797.h:15, from drivers/pinctrl/mediatek/pinctrl-mt6797.c:13: drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.h:83:27: warning: ‘mtk_default_register_base_names’ defined but not used [-Wunused-const-variable=] 83 | static const char const mtk_default_register_base_names[] = { | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ In file included from drivers/pinctrl/mediatek/pinctrl-paris.h:27, from drivers/pinctrl/mediatek/pinctrl-mtk-mt8183.h:12, from drivers/pinctrl/mediatek/pinctrl-mt8183.c:9: drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.h:83:27: warning: ‘mtk_default_register_base_names’ defined but not used [-Wunused-const-variable=] 83 | static const char const mtk_default_register_base_names[] = { | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ In file included from drivers/pinctrl/mediatek/pinctrl-paris.h:27, from drivers/pinctrl/mediatek/pinctrl-mtk-mt6765.h:12, from drivers/pinctrl/mediatek/pinctrl-mt6765.c:10: drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.h:83:27: warning: ‘mtk_default_register_base_names’ defined but not used [-Wunused-const-variable=] 83 | static const char const mtk_default_register_base_names[] = { | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Signed-off-by: Lee Jones <lee.jones@linaro.org> Acked-by: Sean Wang <sean.wang@kernel.org> Cc: Sean Wang <sean.wang@kernel.org> Cc: Matthias Brugger <matthias.bgg@gmail.com> Cc: linux-mediatek@lists.infradead.org Link: https://lore.kernel.org/r/20200713144930.1034632-11-lee.jones@linaro.org Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
2020-02-14pinctrl: mediatek: Backward compatible to previous Mediatek's bias-pull usageLight Hsieh
Refine mtk_pinconf_set()/mtk_pinconf_get() for backward compatibility to previous MediaTek's bias-pull usage. In PINCTRL_MTK that use pinctrl-mtk-common.c, bias-pull setting for pins with 2 pull resistors can be specified as value for bias-pull-up and bias-pull-down. For example: bias-pull-up = <MTK_PUPD_SET_R1R0_00>; bias-pull-up = <MTK_PUPD_SET_R1R0_01>; bias-pull-up = <MTK_PUPD_SET_R1R0_10>; bias-pull-up = <MTK_PUPD_SET_R1R0_11>; bias-pull-down = <MTK_PUPD_SET_R1R0_00>; bias-pull-down = <MTK_PUPD_SET_R1R0_01>; bias-pull-down = <MTK_PUPD_SET_R1R0_10>; bias-pull-down = <MTK_PUPD_SET_R1R0_11>; On the other hand, PINCTRL_MTK_PARIS use customized properties "mediatek,pull-up-adv" and "mediatek,pull-down-adv" to specify bias-pull setting for pins with 2 pull resistors. This introduce in-compatibility in device tree and increase porting effort to MediaTek's customer that had already used PINCTRL_MTK version. Besides, if customers are not aware of this change and still write devicetree for PINCTRL_MTK version, they may encounter runtime failure with pinctrl and spent time to debug. This patch adds backward compatible to previous MediaTek's bias-pull usage so that Mediatek's customer need not use a new devicetree property name. The rationale is that: changing driver implementation had better leave interface unchanged. Signed-off-by: Light Hsieh <light.hsieh@mediatek.com> Link: https://lore.kernel.org/r/1579675994-7001-5-git-send-email-light.hsieh@mediatek.com Acked-by: Sean Wang <sean.wang@kernel.org> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
2020-02-14pinctrl: mediatek: Supporting driving setting without mapping current to ↵Light Hsieh
register value MediaTek's smartphone project actual usage does need to know current value (in mA) in procedure of finding the best driving setting. The steps in the procedure is like as follow: 1. set driving setting field in setting register as 0, measure waveform, perform test, and etc. 2. set driving setting field in setting register as 1, measure waveform, perform test, and etc. ... n. set driving setting field in setting register as n-1, measure waveform, perform test, and etc. Check the results of steps 1~n and adopt the setting that get best result. This procedure does need to know the mapping between current to register value. Therefore, setting driving without mapping current is more practical for MediaTek's smartphone usage. Signed-off-by: Light Hsieh <light.hsieh@mediatek.com> Link: https://lore.kernel.org/r/1579675994-7001-2-git-send-email-light.hsieh@mediatek.com Acked-by: Sean Wang <sean.wang@kernel.org> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
2019-04-08pinctrl: add drive for I2C related pins on MT8183Zhiyong Tao
This patch provides the advanced drive for I2C used pins on MT8183. The detail strength specification description of the I2C pin: When E1=0/E0=0, the strength is 0.125mA. When E1=0/E0=1, the strength is 0.25mA. When E1=1/E0=0, the strength is 0.5mA. When E1=1/E0=1, the strength is 1mA. For I2C pins, there are existing generic driving setup and the above specific driving setup. I2C pins can only support 2/4/6/8/10/12/14/16mA driving adjustment in generic driving setup. But in specific driving setup, they can support 0.125/0.25/0.5/1mA adjustment. If we enable specific driving setup for I2C pins, the existing generic driving setup will be disabled. For some special features, we need the I2C pins specific driving setup. The specific driving setup is controlled by E1E0EN. So we need add extra vendor driving preperty instead of the generic driving property. We can add "mediatek,drive-strength-adv = <XXX>;" to describe the specific driving setup property. "XXX" means the value of E1E0EN. So the valid arguments of "mediatek,drive-strength-adv" are from 0 to 7. Signed-off-by: Zhiyong Tao <zhiyong.tao@mediatek.com> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
2018-10-15pinctrl: mediatek: Make eint_m u16Manivannan Sadhasivam
For SoC's which lacks EINT support, U16_MAX is assigned to both eint_m and eint_n through macro NO_EINT_SUPPORT. This will generate integer overflow warning because eint_m is declared as u8 type. Hence modify the eint_m type to u16. Signed-off-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org> Reviewed-by: Matthias Brugger <matthias.bgg@gmail.com> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
2018-09-21pinctrl: mediatek: add no eint function for pin defineMars Cheng
Add NO_EINT_SUPPORT back to pinctrl-mtk-common-v2.h as the alias of EINT_NA to indicate that some pin not capable of being controlled as eint and that is required by pinctrl-paris based driver as old pinctrl-mtk-common.h already had. Signed-off-by: Mars Cheng <mars.cheng@mediatek.com> Signed-off-by: Sean Wang <sean.wang@mediatek.com> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
2018-09-21pinctrl: mediatek: fix static checker warning caused by EINT_NASean Wang
EINT_NA is an u16 number, so it should be U16_MAX instead of -1 to fix up drivers/pinctrl/mediatek/pinctrl-paris.c:732 mtk_gpio_to_irq() warn: impossible condition (desc->eint.eint_n == -1) => (0-u16max == (-1)) Also happens in drivers/pinctrl/mediatek/pinctrl-paris.c:749 mtk_gpio_set_config() warn: impossible condition (desc->eint.eint_n == -1) => (0-u16max == (-1)) drivers/pinctrl/mediatek/pinctrl-moore.c:479 mtk_gpio_to_irq() warn: impossible condition (desc->eint.eint_n == -1) => (0-u16max == (-1)) drivers/pinctrl/mediatek/pinctrl-moore.c:496 mtk_gpio_set_config() warn: impossible condition '(desc->eint.eint_n == -1) => (0-u16max == (-1)) Fixes: 6561859b067f ("pinctrl: mediatek: add eint support to MT8183 pinctrl driver") Reported-by: Dan Carpenter <dan.carpenter@oracle.com> Signed-off-by: Sean Wang <sean.wang@mediatek.com> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
2018-09-18pinctrl: mtk: Fix up GPIO includesLinus Walleij
Include only <linux/gpio/driver.h> since this is a driver, not a consumer. Cc: Sean Wang <sean.wang@mediatek.com> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
2018-09-18pinctrl: mediatek: extend eint build to pinctrl-mtk-common-v2.cSean Wang
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. Signed-off-by: Sean Wang <sean.wang@mediatek.com> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
2018-09-18pinctrl: mediatek: add pinctrl-paris that implements the vendor dt-bindingsZhiyong Tao
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. Signed-off-by: Zhiyong Tao <zhiyong.tao@mediatek.com> Signed-off-by: Sean Wang <sean.wang@mediatek.com> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
2018-09-18pinctrl: mediatek: extend struct mtk_pin_desc which per-pin driver depends onSean Wang
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. Signed-off-by: Sean Wang <sean.wang@mediatek.com> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
2018-09-18pinctrl: mediatek: add multiple register bases support to ↵Sean Wang
pinctrl-mtk-common-v2.c 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. Signed-off-by: Sean Wang <sean.wang@mediatek.com> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
2018-09-18pinctrl: mediatek: use pin descriptor all in pinctrl-mtk-common-v2.cSean Wang
all use pin descriptor instead in pinctrl-mtk-common-v2.c for the consistency and extensibility. Signed-off-by: Sean Wang <sean.wang@mediatek.com> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
2018-09-18pinctrl: mediatek: add pullen, pullsel register support to ↵Sean Wang
pinctrl-mtk-common-v2.c 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 <ryder.lee@mediatek.com> Signed-off-by: Sean Wang <sean.wang@mediatek.com> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
2018-09-18pinctrl: mediatek: add ies register support to pinctrl-mtk-common-v2.cSean Wang
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 <ryder.lee@mediatek.com> Signed-off-by: Sean Wang <sean.wang@mediatek.com> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
2018-09-18pinctrl: mediatek: add advanced pull related support to pinctrl-mtk-common-v2.cSean Wang
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 <ryder.lee@mediatek.com> Signed-off-by: Sean Wang <sean.wang@mediatek.com> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
2018-09-18pinctrl: mediatek: add pull related support to pinctrl-mtk-common-v2.cSean Wang
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. Signed-off-by: Ryder.Lee <ryder.lee@mediatek.com> Signed-off-by: Sean Wang <sean.wang@mediatek.com> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
2018-09-18pinctrl: mediatek: add drv register support to pinctrl-mtk-common-v2.cSean Wang
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 <ryder.lee@mediatek.com> Signed-off-by: Sean Wang <sean.wang@mediatek.com> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
2018-09-18pinctrl: mediatek: add driving strength related support to ↵Sean Wang
pinctrl-mtk-common-v2.c 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. Signed-off-by: Ryder.Lee <ryder.lee@mediatek.com> Signed-off-by: Sean Wang <sean.wang@mediatek.com> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
2018-09-18pinctrl: mediatek: extend struct mtk_pin_soc to pinctrl-mtk-common-v2.cSean Wang
Add two parameters gpio_m and eint_m for configuring GPIO mode and EINT mode, they might be varying depend on SoC. Signed-off-by: Ryder.Lee <ryder.lee@mediatek.com> Signed-off-by: Sean Wang <sean.wang@mediatek.com> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
2018-09-18pinctrl: mediatek: extend struct mtk_pin_desc to pinctrl-mtk-common-v2.cSean Wang
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 <ryder.lee@mediatek.com> Signed-off-by: Sean Wang <sean.wang@mediatek.com> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
2018-09-18pinctrl: mediatek: extend struct mtk_pin_field_calc to pinctrl-mtk-common-v2.cSean Wang
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. Signed-off-by: Ryder Lee <ryder.lee@mediatek.com> Signed-off-by: Sean Wang <sean.wang@mediatek.com> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
2018-09-18pinctrl: mediatek: add pinctrl-mtk-common-v2 for all MediaTek pinctrlsSean Wang
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. Signed-off-by: Ryder.Lee <ryder.lee@mediatek.com> Signed-off-by: Sean Wang <sean.wang@mediatek.com> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>