pinctrl-abx500.c (33ca8a53f262b4af40611bea331b8c87d133af72) pinctrl-abx500.c (f42cf8d6a3ec934551ac0f20f4654dccb11fa30d)
1/*
2 * Copyright (C) ST-Ericsson SA 2013
3 *
4 * Author: Patrice Chotard <patrice.chotard@st.com>
5 * License terms: GNU General Public License (GPL) version 2
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 version 2 as

--- 452 unchanged lines hidden (view full) ---

461 if (ret < 0)
462 goto out;
463
464 ret = abx500_gpio_set_bits(chip, AB8500_GPIO_ALTFUN_REG,
465 af.alt_bit2, !!(af.altc_val & BIT(1)));
466 break;
467
468 default:
1/*
2 * Copyright (C) ST-Ericsson SA 2013
3 *
4 * Author: Patrice Chotard <patrice.chotard@st.com>
5 * License terms: GNU General Public License (GPL) version 2
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 version 2 as

--- 452 unchanged lines hidden (view full) ---

461 if (ret < 0)
462 goto out;
463
464 ret = abx500_gpio_set_bits(chip, AB8500_GPIO_ALTFUN_REG,
465 af.alt_bit2, !!(af.altc_val & BIT(1)));
466 break;
467
468 default:
469 dev_dbg(pct->dev, "unknow alt_setting %d\n", alt_setting);
469 dev_dbg(pct->dev, "unknown alt_setting %d\n", alt_setting);
470
471 return -EINVAL;
472 }
473out:
474 if (ret < 0)
475 dev_err(pct->dev, "%s failed (%d)\n", __func__, ret);
476
477 return ret;

--- 408 unchanged lines hidden (view full) ---

886 struct pinctrl_map **map,
887 unsigned *reserved_maps,
888 unsigned *num_maps)
889{
890 int ret;
891 const char *function = NULL;
892 unsigned long *configs;
893 unsigned int nconfigs = 0;
470
471 return -EINVAL;
472 }
473out:
474 if (ret < 0)
475 dev_err(pct->dev, "%s failed (%d)\n", __func__, ret);
476
477 return ret;

--- 408 unchanged lines hidden (view full) ---

886 struct pinctrl_map **map,
887 unsigned *reserved_maps,
888 unsigned *num_maps)
889{
890 int ret;
891 const char *function = NULL;
892 unsigned long *configs;
893 unsigned int nconfigs = 0;
894 bool has_config = 0;
894 struct property *prop;
895 struct property *prop;
896 const char *group, *gpio_name;
897 struct device_node *np_config;
895
898
896 ret = of_property_read_string(np, "function", &function);
899 ret = of_property_read_string(np, "ste,function", &function);
897 if (ret >= 0) {
900 if (ret >= 0) {
898 const char *group;
899
900 ret = of_property_count_strings(np, "groups");
901 ret = of_property_count_strings(np, "ste,pins");
901 if (ret < 0)
902 goto exit;
903
904 ret = pinctrl_utils_reserve_map(pctldev, map, reserved_maps,
905 num_maps, ret);
906 if (ret < 0)
907 goto exit;
908
902 if (ret < 0)
903 goto exit;
904
905 ret = pinctrl_utils_reserve_map(pctldev, map, reserved_maps,
906 num_maps, ret);
907 if (ret < 0)
908 goto exit;
909
909 of_property_for_each_string(np, "groups", prop, group) {
910 of_property_for_each_string(np, "ste,pins", prop, group) {
910 ret = abx500_dt_add_map_mux(map, reserved_maps,
911 num_maps, group, function);
912 if (ret < 0)
913 goto exit;
914 }
915 }
916
911 ret = abx500_dt_add_map_mux(map, reserved_maps,
912 num_maps, group, function);
913 if (ret < 0)
914 goto exit;
915 }
916 }
917
917 ret = pinconf_generic_parse_dt_config(np, pctldev, &configs, &nconfigs);
918 if (nconfigs) {
919 const char *gpio_name;
920 const char *pin;
921
922 ret = of_property_count_strings(np, "pins");
918 ret = pinconf_generic_parse_dt_config(np, &configs, &nconfigs);
919 if (nconfigs)
920 has_config = 1;
921 np_config = of_parse_phandle(np, "ste,config", 0);
922 if (np_config) {
923 ret = pinconf_generic_parse_dt_config(np_config, &configs,
924 &nconfigs);
925 if (ret)
926 goto exit;
927 has_config |= nconfigs;
928 }
929 if (has_config) {
930 ret = of_property_count_strings(np, "ste,pins");
923 if (ret < 0)
924 goto exit;
925
926 ret = pinctrl_utils_reserve_map(pctldev, map,
927 reserved_maps,
928 num_maps, ret);
929 if (ret < 0)
930 goto exit;
931
931 if (ret < 0)
932 goto exit;
933
934 ret = pinctrl_utils_reserve_map(pctldev, map,
935 reserved_maps,
936 num_maps, ret);
937 if (ret < 0)
938 goto exit;
939
932 of_property_for_each_string(np, "pins", prop, pin) {
933 gpio_name = abx500_find_pin_name(pctldev, pin);
940 of_property_for_each_string(np, "ste,pins", prop, group) {
941 gpio_name = abx500_find_pin_name(pctldev, group);
934
935 ret = abx500_dt_add_map_configs(map, reserved_maps,
936 num_maps, gpio_name, configs, 1);
937 if (ret < 0)
938 goto exit;
939 }
940 }
941

--- 157 unchanged lines hidden (view full) ---

1099 dev_err(pct->dev, "%s failed (%d)\n", __func__, ret);
1100
1101 return ret;
1102}
1103
1104static const struct pinconf_ops abx500_pinconf_ops = {
1105 .pin_config_get = abx500_pin_config_get,
1106 .pin_config_set = abx500_pin_config_set,
942
943 ret = abx500_dt_add_map_configs(map, reserved_maps,
944 num_maps, gpio_name, configs, 1);
945 if (ret < 0)
946 goto exit;
947 }
948 }
949

--- 157 unchanged lines hidden (view full) ---

1107 dev_err(pct->dev, "%s failed (%d)\n", __func__, ret);
1108
1109 return ret;
1110}
1111
1112static const struct pinconf_ops abx500_pinconf_ops = {
1113 .pin_config_get = abx500_pin_config_get,
1114 .pin_config_set = abx500_pin_config_set,
1107 .is_generic = true,
1108};
1109
1110static struct pinctrl_desc abx500_pinctrl_desc = {
1111 .name = "pinctrl-abx500",
1112 .pctlops = &abx500_pinctrl_ops,
1113 .pmxops = &abx500_pinmux_ops,
1114 .confops = &abx500_pinconf_ops,
1115 .owner = THIS_MODULE,

--- 157 unchanged lines hidden (view full) ---

1273
1274 gpiochip_remove(&pct->chip);
1275 return 0;
1276}
1277
1278static struct platform_driver abx500_gpio_driver = {
1279 .driver = {
1280 .name = "abx500-gpio",
1115};
1116
1117static struct pinctrl_desc abx500_pinctrl_desc = {
1118 .name = "pinctrl-abx500",
1119 .pctlops = &abx500_pinctrl_ops,
1120 .pmxops = &abx500_pinmux_ops,
1121 .confops = &abx500_pinconf_ops,
1122 .owner = THIS_MODULE,

--- 157 unchanged lines hidden (view full) ---

1280
1281 gpiochip_remove(&pct->chip);
1282 return 0;
1283}
1284
1285static struct platform_driver abx500_gpio_driver = {
1286 .driver = {
1287 .name = "abx500-gpio",
1288 .owner = THIS_MODULE,
1281 .of_match_table = abx500_gpio_match,
1282 },
1283 .probe = abx500_gpio_probe,
1284 .remove = abx500_gpio_remove,
1285};
1286
1287static int __init abx500_gpio_init(void)
1288{
1289 return platform_driver_register(&abx500_gpio_driver);
1290}
1291core_initcall(abx500_gpio_init);
1292
1293MODULE_AUTHOR("Patrice Chotard <patrice.chotard@st.com>");
1294MODULE_DESCRIPTION("Driver allows to use AxB5xx unused pins to be used as GPIO");
1295MODULE_ALIAS("platform:abx500-gpio");
1296MODULE_LICENSE("GPL v2");
1289 .of_match_table = abx500_gpio_match,
1290 },
1291 .probe = abx500_gpio_probe,
1292 .remove = abx500_gpio_remove,
1293};
1294
1295static int __init abx500_gpio_init(void)
1296{
1297 return platform_driver_register(&abx500_gpio_driver);
1298}
1299core_initcall(abx500_gpio_init);
1300
1301MODULE_AUTHOR("Patrice Chotard <patrice.chotard@st.com>");
1302MODULE_DESCRIPTION("Driver allows to use AxB5xx unused pins to be used as GPIO");
1303MODULE_ALIAS("platform:abx500-gpio");
1304MODULE_LICENSE("GPL v2");