Lines Matching +full:at91rm9200 +full:- +full:tcb

1 // SPDX-License-Identifier: GPL-2.0-only
37 * atmel_tc_alloc - allocate a specified TC block
41 * pre-initialized struct atmel_tc is returned. The caller can access
51 if (tc->allocated) in atmel_tc_alloc()
54 if ((tc->pdev->dev.of_node && tc->id == block) || in atmel_tc_alloc()
55 (tc->pdev->id == block)) { in atmel_tc_alloc()
56 pdev = tc->pdev; in atmel_tc_alloc()
57 tc->allocated = true; in atmel_tc_alloc()
68 * atmel_tc_free - release a specified TC block
77 if (tc->allocated) in atmel_tc_free()
78 tc->allocated = false; in atmel_tc_free()
94 .compatible = "atmel,at91rm9200-tcb",
97 .compatible = "atmel,at91sam9x5-tcb",
114 if (of_get_child_count(pdev->dev.of_node)) in tc_probe()
115 return -EBUSY; in tc_probe()
119 return -EINVAL; in tc_probe()
121 tc = devm_kzalloc(&pdev->dev, sizeof(struct atmel_tc), GFP_KERNEL); in tc_probe()
123 return -ENOMEM; in tc_probe()
125 tc->pdev = pdev; in tc_probe()
127 clk = devm_clk_get(&pdev->dev, "t0_clk"); in tc_probe()
131 tc->slow_clk = devm_clk_get(&pdev->dev, "slow_clk"); in tc_probe()
132 if (IS_ERR(tc->slow_clk)) in tc_probe()
133 return PTR_ERR(tc->slow_clk); in tc_probe()
135 tc->regs = devm_platform_ioremap_resource(pdev, 0); in tc_probe()
136 if (IS_ERR(tc->regs)) in tc_probe()
137 return PTR_ERR(tc->regs); in tc_probe()
140 if (pdev->dev.of_node) { in tc_probe()
142 match = of_match_node(atmel_tcb_dt_ids, pdev->dev.of_node); in tc_probe()
144 tc->tcb_config = match->data; in tc_probe()
146 tc->id = of_alias_get_id(tc->pdev->dev.of_node, "tcb"); in tc_probe()
148 tc->id = pdev->id; in tc_probe()
151 tc->clk[0] = clk; in tc_probe()
152 tc->clk[1] = devm_clk_get(&pdev->dev, "t1_clk"); in tc_probe()
153 if (IS_ERR(tc->clk[1])) in tc_probe()
154 tc->clk[1] = clk; in tc_probe()
155 tc->clk[2] = devm_clk_get(&pdev->dev, "t2_clk"); in tc_probe()
156 if (IS_ERR(tc->clk[2])) in tc_probe()
157 tc->clk[2] = clk; in tc_probe()
159 tc->irq[0] = irq; in tc_probe()
160 tc->irq[1] = platform_get_irq(pdev, 1); in tc_probe()
161 if (tc->irq[1] < 0) in tc_probe()
162 tc->irq[1] = irq; in tc_probe()
163 tc->irq[2] = platform_get_irq(pdev, 2); in tc_probe()
164 if (tc->irq[2] < 0) in tc_probe()
165 tc->irq[2] = irq; in tc_probe()
168 writel(ATMEL_TC_ALL_IRQ, tc->regs + ATMEL_TC_REG(i, IDR)); in tc_probe()
171 list_add_tail(&tc->node, &tc_list); in tc_probe()
185 writel(ATMEL_TC_ALL_IRQ, tc->regs + ATMEL_TC_REG(i, IDR)); in tc_shutdown()