Lines Matching +full:mdio +full:- +full:pin
1 // SPDX-License-Identifier: GPL-2.0-only
3 * linux/drivers/pinctrl/pinmux-xway.c
4 * based on linux/drivers/pinctrl/pinmux-pxa910.c
21 #include "pinctrl-lantiq.h"
31 /* we have 2 mux bits that can be set for each pin */
66 .pin = a, \
110 /* --------- ase related code --------- */
114 /* pin f0 f1 f2 f3 */
139 MFP_XWAY(GPIO24, GPIO, EBU, EBU2, MDIO),
142 MFP_XWAY(GPIO27, GPIO, EBU, NONE, MDIO),
201 GRP_MUX("mdio", MDIO, ase_pins_mdio),
213 static const char * const ase_mdio_grps[] = {"mdio"};
233 {"mdio", ARRAY_AND_SIZE(ase_mdio_grps)},
238 /* --------- danube related code --------- */
242 /* pin f0 f1 f2 f3 */
413 /* --------- xrx100 related code --------- */
417 /* pin f0 f1 f2 f3 */
460 MFP_XWAY(GPIO42, GPIO, MDIO, NONE, NONE),
461 MFP_XWAY(GPIO43, GPIO, MDIO, NONE, NONE),
581 GRP_MUX("mdio", MDIO, xrx100_pins_mdio),
609 static const char * const xrx100_mdio_grps[] = {"mdio"};
622 {"mdio", ARRAY_AND_SIZE(xrx100_mdio_grps)},
626 /* --------- xrx200 related code --------- */
630 /* pin f0 f1 f2 f3 */
673 MFP_XWAY(GPIO42, GPIO, MDIO, NONE, NONE),
674 MFP_XWAY(GPIO43, GPIO, MDIO, NONE, NONE),
821 GRP_MUX("mdio", MDIO, xrx200_pins_mdio),
861 static const char * const xrx200_mdio_grps[] = {"mdio"};
877 {"mdio", ARRAY_AND_SIZE(xrx200_mdio_grps)},
882 /* --------- xrx300 related code --------- */
886 /* pin f0 f1 f2 f3 */
929 MFP_XWAY(GPIO42, GPIO, MDIO, NONE, NONE),
930 MFP_XWAY(GPIO43, GPIO, MDIO, NONE, NONE),
1050 GRP_MUX("mdio", MDIO, xrx300_pins_mdio),
1078 static const char * const xrx300_mdio_grps[] = {"mdio"};
1090 {"mdio", ARRAY_AND_SIZE(xrx300_mdio_grps)},
1095 /* --------- pinconf related code --------- */
1097 unsigned pin, in xway_pinconf_get() argument
1102 int port = PORT(pin); in xway_pinconf_get()
1110 reg = GPIO_OD(pin); in xway_pinconf_get()
1112 !gpio_getbit(info->membase[0], reg, PORT_PIN(pin))); in xway_pinconf_get()
1119 reg = GPIO_PUDEN(pin); in xway_pinconf_get()
1120 if (!gpio_getbit(info->membase[0], reg, PORT_PIN(pin))) { in xway_pinconf_get()
1128 reg = GPIO_PUDSEL(pin); in xway_pinconf_get()
1129 if (!gpio_getbit(info->membase[0], reg, PORT_PIN(pin))) in xway_pinconf_get()
1136 reg = GPIO_DIR(pin); in xway_pinconf_get()
1138 gpio_getbit(info->membase[0], reg, PORT_PIN(pin))); in xway_pinconf_get()
1141 dev_err(pctldev->dev, "Invalid config param %04x\n", param); in xway_pinconf_get()
1142 return -ENOTSUPP; in xway_pinconf_get()
1148 unsigned pin, in xway_pinconf_set() argument
1155 int port = PORT(pin); in xway_pinconf_set()
1168 reg = GPIO_OD(pin); in xway_pinconf_set()
1170 gpio_setbit(info->membase[0], in xway_pinconf_set()
1172 PORT_PIN(pin)); in xway_pinconf_set()
1174 gpio_clearbit(info->membase[0], in xway_pinconf_set()
1176 PORT_PIN(pin)); in xway_pinconf_set()
1183 reg = GPIO_PUDEN(pin); in xway_pinconf_set()
1185 gpio_clearbit(info->membase[0], in xway_pinconf_set()
1187 PORT_PIN(pin)); in xway_pinconf_set()
1190 gpio_setbit(info->membase[0], reg, PORT_PIN(pin)); in xway_pinconf_set()
1195 reg = GPIO_PUDSEL(pin); in xway_pinconf_set()
1197 gpio_clearbit(info->membase[0], in xway_pinconf_set()
1199 PORT_PIN(pin)); in xway_pinconf_set()
1201 gpio_setbit(info->membase[0], in xway_pinconf_set()
1203 PORT_PIN(pin)); in xway_pinconf_set()
1205 dev_err(pctldev->dev, in xway_pinconf_set()
1210 reg = GPIO_DIR(pin); in xway_pinconf_set()
1212 gpio_clearbit(info->membase[0], in xway_pinconf_set()
1214 PORT_PIN(pin)); in xway_pinconf_set()
1216 gpio_setbit(info->membase[0], in xway_pinconf_set()
1218 PORT_PIN(pin)); in xway_pinconf_set()
1222 dev_err(pctldev->dev, in xway_pinconf_set()
1224 return -ENOTSUPP; in xway_pinconf_set()
1239 for (i = 0; i < info->grps[selector].npins && !ret; i++) in xway_pinconf_group_set()
1241 info->grps[selector].pins[i], in xway_pinconf_group_set()
1260 int pin, int mux) in xway_mux_apply() argument
1263 int port = PORT(pin); in xway_mux_apply()
1264 u32 alt1_reg = GPIO_ALT1(pin); in xway_mux_apply()
1270 gpio_setbit(info->membase[0], GPIO_ALT0(pin), PORT_PIN(pin)); in xway_mux_apply()
1272 gpio_clearbit(info->membase[0], GPIO_ALT0(pin), PORT_PIN(pin)); in xway_mux_apply()
1275 gpio_setbit(info->membase[0], alt1_reg, PORT_PIN(pin)); in xway_mux_apply()
1277 gpio_clearbit(info->membase[0], alt1_reg, PORT_PIN(pin)); in xway_mux_apply()
1284 {"lantiq,open-drain", LTQ_PINCONF_PARAM_OPEN_DRAIN},
1295 /* --------- gpio_chip related code --------- */
1296 static void xway_gpio_set(struct gpio_chip *chip, unsigned int pin, int val) in xway_gpio_set() argument
1298 struct ltq_pinmux_info *info = dev_get_drvdata(chip->parent); in xway_gpio_set()
1301 gpio_setbit(info->membase[0], GPIO_OUT(pin), PORT_PIN(pin)); in xway_gpio_set()
1303 gpio_clearbit(info->membase[0], GPIO_OUT(pin), PORT_PIN(pin)); in xway_gpio_set()
1306 static int xway_gpio_get(struct gpio_chip *chip, unsigned int pin) in xway_gpio_get() argument
1308 struct ltq_pinmux_info *info = dev_get_drvdata(chip->parent); in xway_gpio_get()
1310 return !!gpio_getbit(info->membase[0], GPIO_IN(pin), PORT_PIN(pin)); in xway_gpio_get()
1313 static int xway_gpio_dir_in(struct gpio_chip *chip, unsigned int pin) in xway_gpio_dir_in() argument
1315 struct ltq_pinmux_info *info = dev_get_drvdata(chip->parent); in xway_gpio_dir_in()
1317 gpio_clearbit(info->membase[0], GPIO_DIR(pin), PORT_PIN(pin)); in xway_gpio_dir_in()
1322 static int xway_gpio_dir_out(struct gpio_chip *chip, unsigned int pin, int val) in xway_gpio_dir_out() argument
1324 struct ltq_pinmux_info *info = dev_get_drvdata(chip->parent); in xway_gpio_dir_out()
1326 if (PORT(pin) == PORT3) in xway_gpio_dir_out()
1327 gpio_setbit(info->membase[0], GPIO3_OD, PORT_PIN(pin)); in xway_gpio_dir_out()
1329 gpio_setbit(info->membase[0], GPIO_OD(pin), PORT_PIN(pin)); in xway_gpio_dir_out()
1330 gpio_setbit(info->membase[0], GPIO_DIR(pin), PORT_PIN(pin)); in xway_gpio_dir_out()
1331 xway_gpio_set(chip, pin, val); in xway_gpio_dir_out()
1338 * Returns the mapped IRQ (external interrupt) number for a given GPIO pin.
1342 struct ltq_pinmux_info *info = dev_get_drvdata(chip->parent); in xway_gpio_to_irq()
1345 for (i = 0; i < info->num_exin; i++) in xway_gpio_to_irq()
1346 if (info->exin[i] == offset) in xway_gpio_to_irq()
1349 return -1; in xway_gpio_to_irq()
1353 .label = "gpio-xway",
1361 .base = -1,
1365 /* --------- register the pinctrl layer --------- */
1443 { .compatible = "lantiq,ase-pinctrl", .data = &ase_pinctrl},
1444 { .compatible = "lantiq,danube-pinctrl", .data = &danube_pinctrl},
1445 { .compatible = "lantiq,xrx100-pinctrl", .data = &xrx100_pinctrl},
1446 { .compatible = "lantiq,xrx200-pinctrl", .data = &xrx200_pinctrl},
1447 { .compatible = "lantiq,xrx300-pinctrl", .data = &xrx300_pinctrl},
1462 xway_soc = device_get_match_data(&pdev->dev); in pinmux_xway_probe()
1467 xway_chip.ngpio = xway_soc->pin_count; in pinmux_xway_probe()
1470 xway_info.pads = devm_kcalloc(&pdev->dev, in pinmux_xway_probe()
1474 return -ENOMEM; in pinmux_xway_probe()
1477 char *name = devm_kasprintf(&pdev->dev, GFP_KERNEL, "io%d", i); in pinmux_xway_probe()
1480 return -ENOMEM; in pinmux_xway_probe()
1488 xway_pctrl_desc.name = dev_name(&pdev->dev); in pinmux_xway_probe()
1493 xway_info.mfp = xway_soc->mfp; in pinmux_xway_probe()
1494 xway_info.grps = xway_soc->grps; in pinmux_xway_probe()
1495 xway_info.num_grps = xway_soc->num_grps; in pinmux_xway_probe()
1496 xway_info.funcs = xway_soc->funcs; in pinmux_xway_probe()
1497 xway_info.num_funcs = xway_soc->num_funcs; in pinmux_xway_probe()
1498 xway_info.exin = xway_soc->exin; in pinmux_xway_probe()
1499 xway_info.num_exin = xway_soc->num_exin; in pinmux_xway_probe()
1504 dev_err(&pdev->dev, "Failed to register pinctrl driver\n"); in pinmux_xway_probe()
1509 xway_chip.parent = &pdev->dev; in pinmux_xway_probe()
1511 ret = devm_gpiochip_add_data(&pdev->dev, &xway_chip, NULL); in pinmux_xway_probe()
1513 dev_err(&pdev->dev, "Failed to register gpio chip\n"); in pinmux_xway_probe()
1518 * For DeviceTree-supported systems, the gpio core checks the in pinmux_xway_probe()
1519 * pinctrl's device node for the "gpio-ranges" property. in pinmux_xway_probe()
1520 * If it is present, it takes care of adding the pin ranges in pinmux_xway_probe()
1524 * files which don't set the "gpio-ranges" property or systems that in pinmux_xway_probe()
1527 if (!of_property_read_bool(pdev->dev.of_node, "gpio-ranges")) { in pinmux_xway_probe()
1534 dev_info(&pdev->dev, "Init done\n"); in pinmux_xway_probe()
1541 .name = "pinctrl-xway",