Lines Matching +full:ast2600 +full:- +full:gpio
1 // SPDX-License-Identifier: GPL-2.0-or-later
3 // FSI master driver for AST2600
17 #include <linux/gpio/consumer.h>
19 #include "fsi-master.h"
100 void __iomem *base = aspeed->base; in __opb_write()
129 return -EIO; in __opb_write()
152 void __iomem *base = aspeed->base; in __opb_read()
184 return -EIO; in __opb_read()
198 return -EINVAL; in __opb_read()
238 if (err == -EIO) { in check_errors()
262 return -EINVAL; in aspeed_master_read()
267 mutex_lock(&aspeed->lock); in aspeed_master_read()
280 ret = -EINVAL; in aspeed_master_read()
286 mutex_unlock(&aspeed->lock); in aspeed_master_read()
297 return -EINVAL; in aspeed_master_write()
302 mutex_lock(&aspeed->lock); in aspeed_master_write()
315 ret = -EINVAL; in aspeed_master_write()
321 mutex_unlock(&aspeed->lock); in aspeed_master_write()
337 mutex_lock(&aspeed->lock); in aspeed_master_link_enable()
350 mutex_unlock(&aspeed->lock); in aspeed_master_link_enable()
415 dev_info(aspeed->dev, "mmode set to %08x (divisor %d)\n", in aspeed_master_init()
453 mutex_lock(&aspeed->lock); in cfam_reset_store()
454 gpiod_set_value(aspeed->cfam_reset_gpio, 1); in cfam_reset_store()
456 gpiod_set_value(aspeed->cfam_reset_gpio, 0); in cfam_reset_store()
459 mutex_unlock(&aspeed->lock); in cfam_reset_store()
469 struct device *dev = aspeed->dev; in setup_cfam_reset()
470 struct gpio_desc *gpio; in setup_cfam_reset() local
473 gpio = devm_gpiod_get_optional(dev, "cfam-reset", GPIOD_OUT_LOW); in setup_cfam_reset()
474 if (IS_ERR(gpio)) in setup_cfam_reset()
475 return PTR_ERR(gpio); in setup_cfam_reset()
476 if (!gpio) in setup_cfam_reset()
479 aspeed->cfam_reset_gpio = gpio; in setup_cfam_reset()
483 devm_gpiod_put(dev, gpio); in setup_cfam_reset()
493 int gpio; in tacoma_cabled_fsi_fixup() local
496 * The routing GPIO is a jumper indicating we should mux for the in tacoma_cabled_fsi_fixup()
499 routing_gpio = devm_gpiod_get_optional(dev, "fsi-routing", in tacoma_cabled_fsi_fixup()
506 mux_gpio = devm_gpiod_get_optional(dev, "fsi-mux", GPIOD_ASIS); in tacoma_cabled_fsi_fixup()
512 gpio = gpiod_get_value(routing_gpio); in tacoma_cabled_fsi_fixup()
513 if (gpio < 0) in tacoma_cabled_fsi_fixup()
514 return gpio; in tacoma_cabled_fsi_fixup()
516 /* If the routing GPIO is high we should set the mux to low. */ in tacoma_cabled_fsi_fixup()
517 if (gpio) { in tacoma_cabled_fsi_fixup()
543 rc = tacoma_cabled_fsi_fixup(&pdev->dev); in fsi_master_aspeed_probe()
545 dev_err(&pdev->dev, "Tacoma FSI cable fixup failed\n"); in fsi_master_aspeed_probe()
551 return -ENOMEM; in fsi_master_aspeed_probe()
553 aspeed->dev = &pdev->dev; in fsi_master_aspeed_probe()
555 aspeed->base = devm_platform_ioremap_resource(pdev, 0); in fsi_master_aspeed_probe()
556 if (IS_ERR(aspeed->base)) { in fsi_master_aspeed_probe()
557 rc = PTR_ERR(aspeed->base); in fsi_master_aspeed_probe()
561 aspeed->clk = devm_clk_get(aspeed->dev, NULL); in fsi_master_aspeed_probe()
562 if (IS_ERR(aspeed->clk)) { in fsi_master_aspeed_probe()
563 dev_err(aspeed->dev, "couldn't get clock\n"); in fsi_master_aspeed_probe()
564 rc = PTR_ERR(aspeed->clk); in fsi_master_aspeed_probe()
567 rc = clk_prepare_enable(aspeed->clk); in fsi_master_aspeed_probe()
569 dev_err(aspeed->dev, "couldn't enable clock\n"); in fsi_master_aspeed_probe()
575 dev_err(&pdev->dev, "CFAM reset GPIO setup failed\n"); in fsi_master_aspeed_probe()
578 writel(0x1, aspeed->base + OPB_CLK_SYNC); in fsi_master_aspeed_probe()
580 aspeed->base + OPB_IRQ_MASK); in fsi_master_aspeed_probe()
583 writel(0x10, aspeed->base + OPB_RETRY_COUNTER); in fsi_master_aspeed_probe()
585 writel(ctrl_base, aspeed->base + OPB_CTRL_BASE); in fsi_master_aspeed_probe()
586 writel(fsi_base, aspeed->base + OPB_FSI_BASE); in fsi_master_aspeed_probe()
589 writel(0x00030b1b, aspeed->base + OPB0_READ_ORDER1); in fsi_master_aspeed_probe()
592 writel(0x0011101b, aspeed->base + OPB0_WRITE_ORDER1); in fsi_master_aspeed_probe()
593 writel(0x0c330f3f, aspeed->base + OPB0_WRITE_ORDER2); in fsi_master_aspeed_probe()
600 writel(0x1, aspeed->base + OPB0_SELECT); in fsi_master_aspeed_probe()
604 dev_err(&pdev->dev, "failed to read hub version\n"); in fsi_master_aspeed_probe()
610 dev_info(&pdev->dev, "hub version %08x (%d links)\n", reg, links); in fsi_master_aspeed_probe()
612 aspeed->master.dev.parent = &pdev->dev; in fsi_master_aspeed_probe()
613 aspeed->master.dev.release = aspeed_master_release; in fsi_master_aspeed_probe()
614 aspeed->master.dev.of_node = of_node_get(dev_of_node(&pdev->dev)); in fsi_master_aspeed_probe()
616 aspeed->master.n_links = links; in fsi_master_aspeed_probe()
617 aspeed->master.read = aspeed_master_read; in fsi_master_aspeed_probe()
618 aspeed->master.write = aspeed_master_write; in fsi_master_aspeed_probe()
619 aspeed->master.send_break = aspeed_master_break; in fsi_master_aspeed_probe()
620 aspeed->master.term = aspeed_master_term; in fsi_master_aspeed_probe()
621 aspeed->master.link_enable = aspeed_master_link_enable; in fsi_master_aspeed_probe()
623 dev_set_drvdata(&pdev->dev, aspeed); in fsi_master_aspeed_probe()
625 mutex_init(&aspeed->lock); in fsi_master_aspeed_probe()
628 rc = fsi_master_register(&aspeed->master); in fsi_master_aspeed_probe()
634 * will be freed (via ->release) during any subsequent call to in fsi_master_aspeed_probe()
639 get_device(&aspeed->master.dev); in fsi_master_aspeed_probe()
643 clk_disable_unprepare(aspeed->clk); in fsi_master_aspeed_probe()
653 fsi_master_unregister(&aspeed->master); in fsi_master_aspeed_remove()
654 clk_disable_unprepare(aspeed->clk); in fsi_master_aspeed_remove()
658 { .compatible = "aspeed,ast2600-fsi-master" },
665 .name = "fsi-master-aspeed",
673 MODULE_DESCRIPTION("FSI master driver for AST2600");