| .. | .. |
|---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-only |
|---|
| 1 | 2 | /* |
|---|
| 2 | 3 | * mt65xx pinctrl driver based on Allwinner A1X pinctrl driver. |
|---|
| 3 | 4 | * Copyright (c) 2014 MediaTek Inc. |
|---|
| 4 | 5 | * Author: Hongzhou.Yang <hongzhou.yang@mediatek.com> |
|---|
| 5 | | - * |
|---|
| 6 | | - * This program is free software; you can redistribute it and/or modify |
|---|
| 7 | | - * it under the terms of the GNU General Public License version 2 as |
|---|
| 8 | | - * published by the Free Software Foundation. |
|---|
| 9 | | - * |
|---|
| 10 | | - * This program is distributed in the hope that it will be useful, |
|---|
| 11 | | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|---|
| 12 | | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|---|
| 13 | | - * GNU General Public License for more details. |
|---|
| 14 | 6 | */ |
|---|
| 15 | 7 | |
|---|
| 16 | 8 | #include <linux/io.h> |
|---|
| .. | .. |
|---|
| 514 | 506 | |
|---|
| 515 | 507 | pins = of_find_property(node, "pinmux", NULL); |
|---|
| 516 | 508 | if (!pins) { |
|---|
| 517 | | - dev_err(pctl->dev, "missing pins property in node %s .\n", |
|---|
| 518 | | - node->name); |
|---|
| 509 | + dev_err(pctl->dev, "missing pins property in node %pOFn .\n", |
|---|
| 510 | + node); |
|---|
| 519 | 511 | return -EINVAL; |
|---|
| 520 | 512 | } |
|---|
| 521 | 513 | |
|---|
| .. | .. |
|---|
| 812 | 804 | pctl->devdata->spec_dir_set(®_addr, offset); |
|---|
| 813 | 805 | |
|---|
| 814 | 806 | regmap_read(pctl->regmap1, reg_addr, &read_val); |
|---|
| 815 | | - return !(read_val & bit); |
|---|
| 807 | + if (read_val & bit) |
|---|
| 808 | + return GPIO_LINE_DIRECTION_OUT; |
|---|
| 809 | + |
|---|
| 810 | + return GPIO_LINE_DIRECTION_IN; |
|---|
| 816 | 811 | } |
|---|
| 817 | 812 | |
|---|
| 818 | 813 | static int mtk_gpio_get(struct gpio_chip *chip, unsigned offset) |
|---|
| .. | .. |
|---|
| 990 | 985 | static int mtk_eint_init(struct mtk_pinctrl *pctl, struct platform_device *pdev) |
|---|
| 991 | 986 | { |
|---|
| 992 | 987 | struct device_node *np = pdev->dev.of_node; |
|---|
| 993 | | - struct resource *res; |
|---|
| 994 | 988 | |
|---|
| 995 | 989 | if (!of_property_read_bool(np, "interrupt-controller")) |
|---|
| 996 | 990 | return -ENODEV; |
|---|
| .. | .. |
|---|
| 999 | 993 | if (!pctl->eint) |
|---|
| 1000 | 994 | return -ENOMEM; |
|---|
| 1001 | 995 | |
|---|
| 1002 | | - res = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
|---|
| 1003 | | - pctl->eint->base = devm_ioremap_resource(&pdev->dev, res); |
|---|
| 996 | + pctl->eint->base = devm_platform_ioremap_resource(pdev, 0); |
|---|
| 1004 | 997 | if (IS_ERR(pctl->eint->base)) |
|---|
| 1005 | 998 | return PTR_ERR(pctl->eint->base); |
|---|
| 1006 | 999 | |
|---|
| .. | .. |
|---|
| 1046 | 1039 | node = of_parse_phandle(np, "mediatek,pctl-regmap", 0); |
|---|
| 1047 | 1040 | if (node) { |
|---|
| 1048 | 1041 | pctl->regmap1 = syscon_node_to_regmap(node); |
|---|
| 1042 | + of_node_put(node); |
|---|
| 1049 | 1043 | if (IS_ERR(pctl->regmap1)) |
|---|
| 1050 | 1044 | return PTR_ERR(pctl->regmap1); |
|---|
| 1051 | 1045 | } else if (regmap) { |
|---|
| .. | .. |
|---|
| 1059 | 1053 | node = of_parse_phandle(np, "mediatek,pctl-regmap", 1); |
|---|
| 1060 | 1054 | if (node) { |
|---|
| 1061 | 1055 | pctl->regmap2 = syscon_node_to_regmap(node); |
|---|
| 1056 | + of_node_put(node); |
|---|
| 1062 | 1057 | if (IS_ERR(pctl->regmap2)) |
|---|
| 1063 | 1058 | return PTR_ERR(pctl->regmap2); |
|---|
| 1064 | 1059 | } |
|---|