Lines Matching +full:bt1 +full:- +full:axi

1 // SPDX-License-Identifier: GPL-2.0-only
8 * Baikal-T1 AXI-bus driver
35 * struct bt1_axi - Baikal-T1 AXI-bus private data
37 * @qos_regs: AXI Interconnect QoS tuning registers.
38 * @sys_regs: Baikal-T1 System Controller registers map.
40 * @aclk: AXI reference clock.
41 * @arst: AXI Interconnect reset line.
60 struct bt1_axi *axi = data; in bt1_axi_isr() local
63 regmap_read(axi->sys_regs, BT1_AXI_WERRL, &low); in bt1_axi_isr()
64 regmap_read(axi->sys_regs, BT1_AXI_WERRH, &high); in bt1_axi_isr()
66 dev_crit_ratelimited(axi->dev, in bt1_axi_isr()
67 "AXI-bus fault %d: %s at 0x%x%08x\n", in bt1_axi_isr()
68 atomic_inc_return(&axi->count), in bt1_axi_isr()
86 struct bt1_axi *axi = data; in bt1_axi_clear_data() local
87 struct platform_device *pdev = to_platform_device(axi->dev); in bt1_axi_clear_data()
94 struct device *dev = &pdev->dev; in bt1_axi_create_data()
95 struct bt1_axi *axi; in bt1_axi_create_data() local
98 axi = devm_kzalloc(dev, sizeof(*axi), GFP_KERNEL); in bt1_axi_create_data()
99 if (!axi) in bt1_axi_create_data()
100 return ERR_PTR(-ENOMEM); in bt1_axi_create_data()
102 ret = devm_add_action(dev, bt1_axi_clear_data, axi); in bt1_axi_create_data()
104 dev_err(dev, "Can't add AXI EHB data clear action\n"); in bt1_axi_create_data()
108 axi->dev = dev; in bt1_axi_create_data()
109 atomic_set(&axi->count, 0); in bt1_axi_create_data()
110 platform_set_drvdata(pdev, axi); in bt1_axi_create_data()
112 return axi; in bt1_axi_create_data()
115 static int bt1_axi_request_regs(struct bt1_axi *axi) in bt1_axi_request_regs() argument
117 struct platform_device *pdev = to_platform_device(axi->dev); in bt1_axi_request_regs()
118 struct device *dev = axi->dev; in bt1_axi_request_regs()
120 axi->sys_regs = syscon_regmap_lookup_by_phandle(dev->of_node, "syscon"); in bt1_axi_request_regs()
121 if (IS_ERR(axi->sys_regs)) { in bt1_axi_request_regs()
123 return PTR_ERR(axi->sys_regs); in bt1_axi_request_regs()
126 axi->qos_regs = devm_platform_ioremap_resource_byname(pdev, "qos"); in bt1_axi_request_regs()
127 if (IS_ERR(axi->qos_regs)) in bt1_axi_request_regs()
128 dev_err(dev, "Couldn't map AXI-bus QoS registers\n"); in bt1_axi_request_regs()
130 return PTR_ERR_OR_ZERO(axi->qos_regs); in bt1_axi_request_regs()
133 static int bt1_axi_request_rst(struct bt1_axi *axi) in bt1_axi_request_rst() argument
137 axi->arst = devm_reset_control_get_optional_exclusive(axi->dev, "arst"); in bt1_axi_request_rst()
138 if (IS_ERR(axi->arst)) { in bt1_axi_request_rst()
139 dev_warn(axi->dev, "Couldn't get reset control line\n"); in bt1_axi_request_rst()
140 return PTR_ERR(axi->arst); in bt1_axi_request_rst()
143 ret = reset_control_deassert(axi->arst); in bt1_axi_request_rst()
145 dev_err(axi->dev, "Failed to deassert the reset line\n"); in bt1_axi_request_rst()
152 struct bt1_axi *axi = data; in bt1_axi_disable_clk() local
154 clk_disable_unprepare(axi->aclk); in bt1_axi_disable_clk()
157 static int bt1_axi_request_clk(struct bt1_axi *axi) in bt1_axi_request_clk() argument
161 axi->aclk = devm_clk_get(axi->dev, "aclk"); in bt1_axi_request_clk()
162 if (IS_ERR(axi->aclk)) { in bt1_axi_request_clk()
163 dev_err(axi->dev, "Couldn't get AXI Interconnect clock\n"); in bt1_axi_request_clk()
164 return PTR_ERR(axi->aclk); in bt1_axi_request_clk()
167 ret = clk_prepare_enable(axi->aclk); in bt1_axi_request_clk()
169 dev_err(axi->dev, "Couldn't enable the AXI clock\n"); in bt1_axi_request_clk()
173 ret = devm_add_action_or_reset(axi->dev, bt1_axi_disable_clk, axi); in bt1_axi_request_clk()
175 dev_err(axi->dev, "Can't add AXI clock disable action\n"); in bt1_axi_request_clk()
180 static int bt1_axi_request_irq(struct bt1_axi *axi) in bt1_axi_request_irq() argument
182 struct platform_device *pdev = to_platform_device(axi->dev); in bt1_axi_request_irq()
185 axi->irq = platform_get_irq(pdev, 0); in bt1_axi_request_irq()
186 if (axi->irq < 0) in bt1_axi_request_irq()
187 return axi->irq; in bt1_axi_request_irq()
189 ret = devm_request_irq(axi->dev, axi->irq, bt1_axi_isr, IRQF_SHARED, in bt1_axi_request_irq()
190 "bt1-axi", axi); in bt1_axi_request_irq()
192 dev_err(axi->dev, "Couldn't request AXI EHB IRQ\n"); in bt1_axi_request_irq()
200 struct bt1_axi *axi = dev_get_drvdata(dev); in count_show() local
202 return scnprintf(buf, PAGE_SIZE, "%d\n", atomic_read(&axi->count)); in count_show()
216 struct bt1_axi *axi = dev_get_drvdata(dev); in inject_error_store() local
220 * error while unaligned writing - the AXI bus write error handled in inject_error_store()
224 readb(axi->qos_regs); in inject_error_store()
226 writeb(0, axi->qos_regs); in inject_error_store()
228 return -EINVAL; in inject_error_store()
243 struct bt1_axi *axi = data; in bt1_axi_remove_sysfs() local
245 device_remove_groups(axi->dev, bt1_axi_sysfs_groups); in bt1_axi_remove_sysfs()
248 static int bt1_axi_init_sysfs(struct bt1_axi *axi) in bt1_axi_init_sysfs() argument
252 ret = device_add_groups(axi->dev, bt1_axi_sysfs_groups); in bt1_axi_init_sysfs()
254 dev_err(axi->dev, "Failed to add sysfs files group\n"); in bt1_axi_init_sysfs()
258 ret = devm_add_action_or_reset(axi->dev, bt1_axi_remove_sysfs, axi); in bt1_axi_init_sysfs()
260 dev_err(axi->dev, "Can't add AXI EHB sysfs remove action\n"); in bt1_axi_init_sysfs()
267 struct bt1_axi *axi; in bt1_axi_probe() local
270 axi = bt1_axi_create_data(pdev); in bt1_axi_probe()
271 if (IS_ERR(axi)) in bt1_axi_probe()
272 return PTR_ERR(axi); in bt1_axi_probe()
274 ret = bt1_axi_request_regs(axi); in bt1_axi_probe()
278 ret = bt1_axi_request_rst(axi); in bt1_axi_probe()
282 ret = bt1_axi_request_clk(axi); in bt1_axi_probe()
286 ret = bt1_axi_request_irq(axi); in bt1_axi_probe()
290 ret = bt1_axi_init_sysfs(axi); in bt1_axi_probe()
298 { .compatible = "baikal,bt1-axi" },
306 .name = "bt1-axi",
313 MODULE_DESCRIPTION("Baikal-T1 AXI-bus driver");