Lines Matching +full:pmic +full:- +full:arbiter

1 // SPDX-License-Identifier: GPL-2.0-only
2 /* Copyright (c) 2009-2013, The Linux Foundation. All rights reserved.
8 * - Largely rewritten from original to not be an i2c driver.
46 /* SSBI PMIC Arbiter command registers */
77 return readl(ssbi->base + reg); in ssbi_readl()
82 writel(val, ssbi->base + reg); in ssbi_writel()
88 * case, is when using the arbiter and both other CPUs have just
99 while (timeout--) { in ssbi_wait_mask()
106 return -ETIMEDOUT; in ssbi_wait_mask()
115 if (ssbi->controller_type == MSM_SBI_CTRL_SSBI2) { in ssbi_read_bytes()
131 len--; in ssbi_read_bytes()
143 if (ssbi->controller_type == MSM_SBI_CTRL_SSBI2) { in ssbi_write_bytes()
159 len--; in ssbi_write_bytes()
178 while (timeout--) { in ssbi_pa_transfer()
182 return -EPERM; in ssbi_pa_transfer()
192 return -ETIMEDOUT; in ssbi_pa_transfer()
208 len--; in ssbi_pa_read_bytes()
227 len--; in ssbi_pa_write_bytes()
240 spin_lock_irqsave(&ssbi->lock, flags); in ssbi_read()
241 ret = ssbi->read(ssbi, addr, buf, len); in ssbi_read()
242 spin_unlock_irqrestore(&ssbi->lock, flags); in ssbi_read()
254 spin_lock_irqsave(&ssbi->lock, flags); in ssbi_write()
255 ret = ssbi->write(ssbi, addr, buf, len); in ssbi_write()
256 spin_unlock_irqrestore(&ssbi->lock, flags); in ssbi_write()
264 struct device_node *np = pdev->dev.of_node; in ssbi_probe()
268 ssbi = devm_kzalloc(&pdev->dev, sizeof(*ssbi), GFP_KERNEL); in ssbi_probe()
270 return -ENOMEM; in ssbi_probe()
272 ssbi->base = devm_platform_get_and_ioremap_resource(pdev, 0, NULL); in ssbi_probe()
273 if (IS_ERR(ssbi->base)) in ssbi_probe()
274 return PTR_ERR(ssbi->base); in ssbi_probe()
278 type = of_get_property(np, "qcom,controller-type", NULL); in ssbi_probe()
280 dev_err(&pdev->dev, "Missing qcom,controller-type property\n"); in ssbi_probe()
281 return -EINVAL; in ssbi_probe()
283 dev_info(&pdev->dev, "SSBI controller type: '%s'\n", type); in ssbi_probe()
285 ssbi->controller_type = MSM_SBI_CTRL_SSBI; in ssbi_probe()
287 ssbi->controller_type = MSM_SBI_CTRL_SSBI2; in ssbi_probe()
288 else if (strcmp(type, "pmic-arbiter") == 0) in ssbi_probe()
289 ssbi->controller_type = MSM_SBI_CTRL_PMIC_ARBITER; in ssbi_probe()
291 dev_err(&pdev->dev, "Unknown qcom,controller-type\n"); in ssbi_probe()
292 return -EINVAL; in ssbi_probe()
295 if (ssbi->controller_type == MSM_SBI_CTRL_PMIC_ARBITER) { in ssbi_probe()
296 ssbi->read = ssbi_pa_read_bytes; in ssbi_probe()
297 ssbi->write = ssbi_pa_write_bytes; in ssbi_probe()
299 ssbi->read = ssbi_read_bytes; in ssbi_probe()
300 ssbi->write = ssbi_write_bytes; in ssbi_probe()
303 spin_lock_init(&ssbi->lock); in ssbi_probe()
305 return devm_of_platform_populate(&pdev->dev); in ssbi_probe()