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 */
76 return readl(ssbi->base + reg); in ssbi_readl()
81 writel(val, ssbi->base + reg); in ssbi_writel()
87 * case, is when using the arbiter and both other CPUs have just
98 while (timeout--) { in ssbi_wait_mask()
105 return -ETIMEDOUT; in ssbi_wait_mask()
114 if (ssbi->controller_type == MSM_SBI_CTRL_SSBI2) { in ssbi_read_bytes()
130 len--; in ssbi_read_bytes()
142 if (ssbi->controller_type == MSM_SBI_CTRL_SSBI2) { in ssbi_write_bytes()
158 len--; in ssbi_write_bytes()
177 while (timeout--) { in ssbi_pa_transfer()
181 return -EPERM; in ssbi_pa_transfer()
191 return -ETIMEDOUT; in ssbi_pa_transfer()
207 len--; in ssbi_pa_read_bytes()
226 len--; in ssbi_pa_write_bytes()
239 spin_lock_irqsave(&ssbi->lock, flags); in ssbi_read()
240 ret = ssbi->read(ssbi, addr, buf, len); in ssbi_read()
241 spin_unlock_irqrestore(&ssbi->lock, flags); in ssbi_read()
253 spin_lock_irqsave(&ssbi->lock, flags); in ssbi_write()
254 ret = ssbi->write(ssbi, addr, buf, len); in ssbi_write()
255 spin_unlock_irqrestore(&ssbi->lock, flags); in ssbi_write()
263 struct device_node *np = pdev->dev.of_node; in ssbi_probe()
267 ssbi = devm_kzalloc(&pdev->dev, sizeof(*ssbi), GFP_KERNEL); in ssbi_probe()
269 return -ENOMEM; in ssbi_probe()
271 ssbi->base = devm_platform_get_and_ioremap_resource(pdev, 0, NULL); in ssbi_probe()
272 if (IS_ERR(ssbi->base)) in ssbi_probe()
273 return PTR_ERR(ssbi->base); in ssbi_probe()
277 type = of_get_property(np, "qcom,controller-type", NULL); in ssbi_probe()
279 dev_err(&pdev->dev, "Missing qcom,controller-type property\n"); in ssbi_probe()
280 return -EINVAL; in ssbi_probe()
282 dev_info(&pdev->dev, "SSBI controller type: '%s'\n", type); in ssbi_probe()
284 ssbi->controller_type = MSM_SBI_CTRL_SSBI; in ssbi_probe()
286 ssbi->controller_type = MSM_SBI_CTRL_SSBI2; in ssbi_probe()
287 else if (strcmp(type, "pmic-arbiter") == 0) in ssbi_probe()
288 ssbi->controller_type = MSM_SBI_CTRL_PMIC_ARBITER; in ssbi_probe()
290 dev_err(&pdev->dev, "Unknown qcom,controller-type\n"); in ssbi_probe()
291 return -EINVAL; in ssbi_probe()
294 if (ssbi->controller_type == MSM_SBI_CTRL_PMIC_ARBITER) { in ssbi_probe()
295 ssbi->read = ssbi_pa_read_bytes; in ssbi_probe()
296 ssbi->write = ssbi_pa_write_bytes; in ssbi_probe()
298 ssbi->read = ssbi_read_bytes; in ssbi_probe()
299 ssbi->write = ssbi_write_bytes; in ssbi_probe()
302 spin_lock_init(&ssbi->lock); in ssbi_probe()
304 return devm_of_platform_populate(&pdev->dev); in ssbi_probe()
322 MODULE_DESCRIPTION("Qualcomm Single-wire Serial Bus Interface (SSBI) driver");