• Home
  • Raw
  • Download

Lines Matching refs:apb

71 static inline unsigned long bt1_apb_n_to_timeout_us(struct bt1_apb *apb, u32 n)  in bt1_apb_n_to_timeout_us()  argument
75 do_div(timeout, apb->rate); in bt1_apb_n_to_timeout_us()
81 static inline unsigned long bt1_apb_timeout_to_n_us(struct bt1_apb *apb, in bt1_apb_timeout_to_n_us() argument
84 u64 n = (u64)timeout * apb->rate; in bt1_apb_timeout_to_n_us()
94 struct bt1_apb *apb = data; in bt1_apb_isr() local
97 regmap_read(apb->regs, APB_EHB_ADDR, &addr); in bt1_apb_isr()
99 dev_crit_ratelimited(apb->dev, in bt1_apb_isr()
101 atomic_inc_return(&apb->count), in bt1_apb_isr()
113 regmap_update_bits(apb->regs, APB_EHB_ISR, APB_EHB_ISR_PENDING, 0); in bt1_apb_isr()
120 struct bt1_apb *apb = data; in bt1_apb_clear_data() local
121 struct platform_device *pdev = to_platform_device(apb->dev); in bt1_apb_clear_data()
129 struct bt1_apb *apb; in bt1_apb_create_data() local
132 apb = devm_kzalloc(dev, sizeof(*apb), GFP_KERNEL); in bt1_apb_create_data()
133 if (!apb) in bt1_apb_create_data()
136 ret = devm_add_action(dev, bt1_apb_clear_data, apb); in bt1_apb_create_data()
142 apb->dev = dev; in bt1_apb_create_data()
143 atomic_set(&apb->count, 0); in bt1_apb_create_data()
144 platform_set_drvdata(pdev, apb); in bt1_apb_create_data()
146 return apb; in bt1_apb_create_data()
149 static int bt1_apb_request_regs(struct bt1_apb *apb) in bt1_apb_request_regs() argument
151 struct platform_device *pdev = to_platform_device(apb->dev); in bt1_apb_request_regs()
156 dev_err(apb->dev, "Couldn't map APB EHB registers\n"); in bt1_apb_request_regs()
160 apb->regs = devm_regmap_init_mmio(apb->dev, regs, &bt1_apb_regmap_cfg); in bt1_apb_request_regs()
161 if (IS_ERR(apb->regs)) { in bt1_apb_request_regs()
162 dev_err(apb->dev, "Couldn't create APB EHB regmap\n"); in bt1_apb_request_regs()
163 return PTR_ERR(apb->regs); in bt1_apb_request_regs()
166 apb->res = devm_platform_ioremap_resource_byname(pdev, "nodev"); in bt1_apb_request_regs()
167 if (IS_ERR(apb->res)) in bt1_apb_request_regs()
168 dev_err(apb->dev, "Couldn't map reserved region\n"); in bt1_apb_request_regs()
170 return PTR_ERR_OR_ZERO(apb->res); in bt1_apb_request_regs()
173 static int bt1_apb_request_rst(struct bt1_apb *apb) in bt1_apb_request_rst() argument
177 apb->prst = devm_reset_control_get_optional_exclusive(apb->dev, "prst"); in bt1_apb_request_rst()
178 if (IS_ERR(apb->prst)) { in bt1_apb_request_rst()
179 dev_warn(apb->dev, "Couldn't get reset control line\n"); in bt1_apb_request_rst()
180 return PTR_ERR(apb->prst); in bt1_apb_request_rst()
183 ret = reset_control_deassert(apb->prst); in bt1_apb_request_rst()
185 dev_err(apb->dev, "Failed to deassert the reset line\n"); in bt1_apb_request_rst()
192 struct bt1_apb *apb = data; in bt1_apb_disable_clk() local
194 clk_disable_unprepare(apb->pclk); in bt1_apb_disable_clk()
197 static int bt1_apb_request_clk(struct bt1_apb *apb) in bt1_apb_request_clk() argument
201 apb->pclk = devm_clk_get(apb->dev, "pclk"); in bt1_apb_request_clk()
202 if (IS_ERR(apb->pclk)) { in bt1_apb_request_clk()
203 dev_err(apb->dev, "Couldn't get APB clock descriptor\n"); in bt1_apb_request_clk()
204 return PTR_ERR(apb->pclk); in bt1_apb_request_clk()
207 ret = clk_prepare_enable(apb->pclk); in bt1_apb_request_clk()
209 dev_err(apb->dev, "Couldn't enable the APB clock\n"); in bt1_apb_request_clk()
213 ret = devm_add_action_or_reset(apb->dev, bt1_apb_disable_clk, apb); in bt1_apb_request_clk()
215 dev_err(apb->dev, "Can't add APB EHB clocks disable action\n"); in bt1_apb_request_clk()
219 apb->rate = clk_get_rate(apb->pclk); in bt1_apb_request_clk()
220 if (!apb->rate) { in bt1_apb_request_clk()
221 dev_err(apb->dev, "Invalid clock rate\n"); in bt1_apb_request_clk()
230 struct bt1_apb *apb = data; in bt1_apb_clear_irq() local
232 regmap_update_bits(apb->regs, APB_EHB_ISR, APB_EHB_ISR_MASK, 0); in bt1_apb_clear_irq()
235 static int bt1_apb_request_irq(struct bt1_apb *apb) in bt1_apb_request_irq() argument
237 struct platform_device *pdev = to_platform_device(apb->dev); in bt1_apb_request_irq()
240 apb->irq = platform_get_irq(pdev, 0); in bt1_apb_request_irq()
241 if (apb->irq < 0) in bt1_apb_request_irq()
242 return apb->irq; in bt1_apb_request_irq()
244 ret = devm_request_irq(apb->dev, apb->irq, bt1_apb_isr, IRQF_SHARED, in bt1_apb_request_irq()
245 "bt1-apb", apb); in bt1_apb_request_irq()
247 dev_err(apb->dev, "Couldn't request APB EHB IRQ\n"); in bt1_apb_request_irq()
251 ret = devm_add_action(apb->dev, bt1_apb_clear_irq, apb); in bt1_apb_request_irq()
253 dev_err(apb->dev, "Can't add APB EHB IRQs clear action\n"); in bt1_apb_request_irq()
258 regmap_update_bits(apb->regs, APB_EHB_ISR, in bt1_apb_request_irq()
268 struct bt1_apb *apb = dev_get_drvdata(dev); in count_show() local
270 return scnprintf(buf, PAGE_SIZE, "%d\n", atomic_read(&apb->count)); in count_show()
277 struct bt1_apb *apb = dev_get_drvdata(dev); in timeout_show() local
282 ret = regmap_read(apb->regs, APB_EHB_TIMEOUT, &n); in timeout_show()
286 timeout = bt1_apb_n_to_timeout_us(apb, n); in timeout_show()
295 struct bt1_apb *apb = dev_get_drvdata(dev); in timeout_store() local
303 n = bt1_apb_timeout_to_n_us(apb, timeout); in timeout_store()
306 ret = regmap_write(apb->regs, APB_EHB_TIMEOUT, n); in timeout_store()
322 struct bt1_apb *apb = dev_get_drvdata(dev); in inject_error_store() local
329 readl(apb->res); in inject_error_store()
331 regmap_update_bits(apb->regs, APB_EHB_ISR, APB_EHB_ISR_PENDING, in inject_error_store()
350 struct bt1_apb *apb = data; in bt1_apb_remove_sysfs() local
352 device_remove_groups(apb->dev, bt1_apb_sysfs_groups); in bt1_apb_remove_sysfs()
355 static int bt1_apb_init_sysfs(struct bt1_apb *apb) in bt1_apb_init_sysfs() argument
359 ret = device_add_groups(apb->dev, bt1_apb_sysfs_groups); in bt1_apb_init_sysfs()
361 dev_err(apb->dev, "Failed to create EHB APB sysfs nodes\n"); in bt1_apb_init_sysfs()
365 ret = devm_add_action_or_reset(apb->dev, bt1_apb_remove_sysfs, apb); in bt1_apb_init_sysfs()
367 dev_err(apb->dev, "Can't add APB EHB sysfs remove action\n"); in bt1_apb_init_sysfs()
374 struct bt1_apb *apb; in bt1_apb_probe() local
377 apb = bt1_apb_create_data(pdev); in bt1_apb_probe()
378 if (IS_ERR(apb)) in bt1_apb_probe()
379 return PTR_ERR(apb); in bt1_apb_probe()
381 ret = bt1_apb_request_regs(apb); in bt1_apb_probe()
385 ret = bt1_apb_request_rst(apb); in bt1_apb_probe()
389 ret = bt1_apb_request_clk(apb); in bt1_apb_probe()
393 ret = bt1_apb_request_irq(apb); in bt1_apb_probe()
397 ret = bt1_apb_init_sysfs(apb); in bt1_apb_probe()