| .. | .. |
|---|
| 1 | | -// SPDX-License-Identifier: GPL-2.0 |
|---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-only |
|---|
| 2 | 2 | /* |
|---|
| 3 | 3 | * Pinctrl for Cirrus Logic Madera codecs |
|---|
| 4 | 4 | * |
|---|
| 5 | 5 | * Copyright (C) 2016-2018 Cirrus Logic |
|---|
| 6 | | - * |
|---|
| 7 | | - * This program is free software; you can redistribute it and/or modify |
|---|
| 8 | | - * it under the terms of the GNU General Public License as published by the |
|---|
| 9 | | - * Free Software Foundation; version 2. |
|---|
| 10 | 6 | */ |
|---|
| 11 | 7 | |
|---|
| 12 | 8 | #include <linux/err.h> |
|---|
| .. | .. |
|---|
| 14 | 10 | #include <linux/platform_device.h> |
|---|
| 15 | 11 | #include <linux/regmap.h> |
|---|
| 16 | 12 | #include <linux/slab.h> |
|---|
| 13 | +#include <linux/pinctrl/machine.h> |
|---|
| 17 | 14 | #include <linux/pinctrl/pinctrl.h> |
|---|
| 18 | 15 | #include <linux/pinctrl/pinmux.h> |
|---|
| 19 | 16 | #include <linux/pinctrl/pinconf.h> |
|---|
| .. | .. |
|---|
| 399 | 396 | .group_names = madera_pin_single_group_names, |
|---|
| 400 | 397 | .func = 0x157 |
|---|
| 401 | 398 | }, |
|---|
| 399 | + { |
|---|
| 400 | + .name = "aux-pdm-clk", |
|---|
| 401 | + .group_names = madera_pin_single_group_names, |
|---|
| 402 | + .func = 0x280 |
|---|
| 403 | + }, |
|---|
| 404 | + { |
|---|
| 405 | + .name = "aux-pdm-dat", |
|---|
| 406 | + .group_names = madera_pin_single_group_names, |
|---|
| 407 | + .func = 0x281 |
|---|
| 408 | + }, |
|---|
| 402 | 409 | }; |
|---|
| 403 | 410 | |
|---|
| 404 | 411 | static u16 madera_pin_make_drv_str(struct madera_pin_private *priv, |
|---|
| .. | .. |
|---|
| 550 | 557 | seq_printf(s, " DRV=%umA", madera_pin_unmake_drv_str(priv, conf[1])); |
|---|
| 551 | 558 | |
|---|
| 552 | 559 | if (conf[0] & MADERA_GP1_IP_CFG_MASK) |
|---|
| 553 | | - seq_puts(s, "SCHMITT"); |
|---|
| 560 | + seq_puts(s, " SCHMITT"); |
|---|
| 554 | 561 | } |
|---|
| 555 | | - |
|---|
| 556 | 562 | |
|---|
| 557 | 563 | static const struct pinctrl_ops madera_pin_group_ops = { |
|---|
| 558 | 564 | .get_groups_count = madera_get_groups_count, |
|---|
| .. | .. |
|---|
| 801 | 807 | result = 1; |
|---|
| 802 | 808 | break; |
|---|
| 803 | 809 | default: |
|---|
| 804 | | - break; |
|---|
| 810 | + return -ENOTSUPP; |
|---|
| 805 | 811 | } |
|---|
| 806 | 812 | |
|---|
| 807 | 813 | *config = pinconf_to_config_packed(param, result); |
|---|
| .. | .. |
|---|
| 905 | 911 | conf[1] &= ~MADERA_GP1_DIR; |
|---|
| 906 | 912 | break; |
|---|
| 907 | 913 | default: |
|---|
| 908 | | - break; |
|---|
| 914 | + return -ENOTSUPP; |
|---|
| 909 | 915 | } |
|---|
| 910 | 916 | |
|---|
| 911 | 917 | ++configs; |
|---|
| .. | .. |
|---|
| 971 | 977 | } |
|---|
| 972 | 978 | |
|---|
| 973 | 979 | static const struct pinconf_ops madera_pin_conf_ops = { |
|---|
| 980 | + .is_generic = true, |
|---|
| 974 | 981 | .pin_config_get = madera_pin_conf_get, |
|---|
| 975 | 982 | .pin_config_set = madera_pin_conf_set, |
|---|
| 976 | 983 | .pin_config_group_set = madera_pin_conf_group_set, |
|---|
| 977 | | - |
|---|
| 978 | 984 | }; |
|---|
| 979 | 985 | |
|---|
| 980 | 986 | static struct pinctrl_desc madera_pin_desc = { |
|---|
| .. | .. |
|---|
| 989 | 995 | static int madera_pin_probe(struct platform_device *pdev) |
|---|
| 990 | 996 | { |
|---|
| 991 | 997 | struct madera *madera = dev_get_drvdata(pdev->dev.parent); |
|---|
| 992 | | - const struct madera_pdata *pdata = dev_get_platdata(madera->dev); |
|---|
| 998 | + const struct madera_pdata *pdata = &madera->pdata; |
|---|
| 993 | 999 | struct madera_pin_private *priv; |
|---|
| 994 | 1000 | int ret; |
|---|
| 995 | 1001 | |
|---|
| .. | .. |
|---|
| 1007 | 1013 | pdev->dev.of_node = madera->dev->of_node; |
|---|
| 1008 | 1014 | |
|---|
| 1009 | 1015 | switch (madera->type) { |
|---|
| 1016 | + case CS47L15: |
|---|
| 1017 | + if (IS_ENABLED(CONFIG_PINCTRL_CS47L15)) |
|---|
| 1018 | + priv->chip = &cs47l15_pin_chip; |
|---|
| 1019 | + break; |
|---|
| 1010 | 1020 | case CS47L35: |
|---|
| 1011 | 1021 | if (IS_ENABLED(CONFIG_PINCTRL_CS47L35)) |
|---|
| 1012 | 1022 | priv->chip = &cs47l35_pin_chip; |
|---|
| .. | .. |
|---|
| 1020 | 1030 | case CS47L91: |
|---|
| 1021 | 1031 | if (IS_ENABLED(CONFIG_PINCTRL_CS47L90)) |
|---|
| 1022 | 1032 | priv->chip = &cs47l90_pin_chip; |
|---|
| 1033 | + break; |
|---|
| 1034 | + case CS42L92: |
|---|
| 1035 | + case CS47L92: |
|---|
| 1036 | + case CS47L93: |
|---|
| 1037 | + if (IS_ENABLED(CONFIG_PINCTRL_CS47L92)) |
|---|
| 1038 | + priv->chip = &cs47l92_pin_chip; |
|---|
| 1023 | 1039 | break; |
|---|
| 1024 | 1040 | default: |
|---|
| 1025 | 1041 | break; |
|---|
| .. | .. |
|---|
| 1040 | 1056 | } |
|---|
| 1041 | 1057 | |
|---|
| 1042 | 1058 | /* if the configuration is provided through pdata, apply it */ |
|---|
| 1043 | | - if (pdata && pdata->gpio_configs) { |
|---|
| 1059 | + if (pdata->gpio_configs) { |
|---|
| 1044 | 1060 | ret = pinctrl_register_mappings(pdata->gpio_configs, |
|---|
| 1045 | 1061 | pdata->n_gpio_configs); |
|---|
| 1046 | 1062 | if (ret) { |
|---|
| .. | .. |
|---|
| 1057 | 1073 | return ret; |
|---|
| 1058 | 1074 | } |
|---|
| 1059 | 1075 | |
|---|
| 1076 | + platform_set_drvdata(pdev, priv); |
|---|
| 1077 | + |
|---|
| 1060 | 1078 | dev_dbg(priv->dev, "pinctrl probed ok\n"); |
|---|
| 1079 | + |
|---|
| 1080 | + return 0; |
|---|
| 1081 | +} |
|---|
| 1082 | + |
|---|
| 1083 | +static int madera_pin_remove(struct platform_device *pdev) |
|---|
| 1084 | +{ |
|---|
| 1085 | + struct madera_pin_private *priv = platform_get_drvdata(pdev); |
|---|
| 1086 | + |
|---|
| 1087 | + if (priv->madera->pdata.gpio_configs) |
|---|
| 1088 | + pinctrl_unregister_mappings(priv->madera->pdata.gpio_configs); |
|---|
| 1061 | 1089 | |
|---|
| 1062 | 1090 | return 0; |
|---|
| 1063 | 1091 | } |
|---|
| 1064 | 1092 | |
|---|
| 1065 | 1093 | static struct platform_driver madera_pin_driver = { |
|---|
| 1066 | 1094 | .probe = madera_pin_probe, |
|---|
| 1095 | + .remove = madera_pin_remove, |
|---|
| 1067 | 1096 | .driver = { |
|---|
| 1068 | 1097 | .name = "madera-pinctrl", |
|---|
| 1069 | 1098 | }, |
|---|