Lines Matching +full:ums512 +full:- +full:thermal
4 * SPDX-License-Identifier: GPL-2.0
37 #define REG_ADI_CHN_ADDR(id) (0x44 + (id - 2) * 4)
54 * ADI slave devices include RTC, ADC, regulator, charger, thermal and so on.
160 if (reg >= sadi->data->slave_addr_size) { in sprd_adi_check_addr()
161 dev_err(sadi->dev, in sprd_adi_check_addr()
164 return -EINVAL; in sprd_adi_check_addr()
176 sts = readl_relaxed(sadi->base + REG_ADI_ARM_FIFO_STS); in sprd_adi_drain_fifo()
181 } while (--timeout); in sprd_adi_drain_fifo()
184 dev_err(sadi->dev, "drain write fifo timeout\n"); in sprd_adi_drain_fifo()
185 return -EBUSY; in sprd_adi_drain_fifo()
193 return readl_relaxed(sadi->base + REG_ADI_ARM_FIFO_STS) & BIT_FIFO_FULL; in sprd_adi_fifo_is_full()
204 return -EIO; in sprd_adi_read_check()
227 if (sadi->hwlock) { in sprd_adi_read()
228 ret = hwspin_lock_timeout_irqsave(sadi->hwlock, in sprd_adi_read()
232 dev_err(sadi->dev, "get the hw lock failed\n"); in sprd_adi_read()
245 writel_relaxed(reg, sadi->base + REG_ADI_RD_CMD); in sprd_adi_read()
254 val = readl_relaxed(sadi->base + REG_ADI_RD_DATA); in sprd_adi_read()
259 } while (--read_timeout); in sprd_adi_read()
262 dev_err(sadi->dev, "ADI read timeout\n"); in sprd_adi_read()
263 ret = -EBUSY; in sprd_adi_read()
273 if (sadi->data->read_check) { in sprd_adi_read()
274 ret = sadi->data->read_check(val, reg); in sprd_adi_read()
282 if (sadi->hwlock) in sprd_adi_read()
283 hwspin_unlock_irqrestore(sadi->hwlock, &flags); in sprd_adi_read()
293 if (sadi->hwlock) { in sprd_adi_write()
294 ret = hwspin_lock_timeout_irqsave(sadi->hwlock, in sprd_adi_write()
298 dev_err(sadi->dev, "get the hw lock failed\n"); in sprd_adi_write()
318 writel_relaxed(val, (void __iomem *)(sadi->slave_vbase + reg)); in sprd_adi_write()
323 } while (--timeout); in sprd_adi_write()
326 dev_err(sadi->dev, "write fifo is full\n"); in sprd_adi_write()
327 ret = -EBUSY; in sprd_adi_write()
331 if (sadi->hwlock) in sprd_adi_write()
332 hwspin_unlock_irqrestore(sadi->hwlock, &flags); in sprd_adi_write()
344 if (t->rx_buf) { in sprd_adi_transfer_one()
345 reg = *(u32 *)t->rx_buf; in sprd_adi_transfer_one()
347 *(u32 *)t->rx_buf = val; in sprd_adi_transfer_one()
348 } else if (t->tx_buf) { in sprd_adi_transfer_one()
349 u32 *p = (u32 *)t->tx_buf; in sprd_adi_transfer_one()
354 dev_err(sadi->dev, "no buffer for transfer\n"); in sprd_adi_transfer_one()
355 ret = -EINVAL; in sprd_adi_transfer_one()
411 sprd_adi_read(sadi, wdg->rst_sts, &val); in sprd_adi_restart()
414 sprd_adi_write(sadi, wdg->rst_sts, val); in sprd_adi_restart()
417 sprd_adi_read(sadi, wdg->wdg_en, &val); in sprd_adi_restart()
419 sprd_adi_write(sadi, wdg->wdg_en, val); in sprd_adi_restart()
422 sprd_adi_read(sadi, wdg->wdg_clk, &val); in sprd_adi_restart()
424 sprd_adi_write(sadi, wdg->wdg_clk, val); in sprd_adi_restart()
427 sprd_adi_write(sadi, wdg->base + REG_WDG_LOCK, WDG_UNLOCK_KEY); in sprd_adi_restart()
429 sprd_adi_read(sadi, wdg->base + REG_WDG_CTRL, &val); in sprd_adi_restart()
431 sprd_adi_write(sadi, wdg->base + REG_WDG_CTRL, val); in sprd_adi_restart()
434 sprd_adi_write(sadi, wdg->base + REG_WDG_LOAD_HIGH, 0); in sprd_adi_restart()
435 sprd_adi_write(sadi, wdg->base + REG_WDG_LOAD_LOW, in sprd_adi_restart()
439 sprd_adi_read(sadi, wdg->base + REG_WDG_CTRL, &val); in sprd_adi_restart()
441 sprd_adi_write(sadi, wdg->base + REG_WDG_CTRL, val); in sprd_adi_restart()
444 sprd_adi_write(sadi, wdg->base + REG_WDG_LOCK, ~WDG_UNLOCK_KEY); in sprd_adi_restart()
448 dev_emerg(sadi->dev, "Unable to restart system\n"); in sprd_adi_restart()
467 struct device_node *np = sadi->dev->of_node; in sprd_adi_hw_init()
473 writel_relaxed(0, sadi->base + REG_ADI_CHN_PRIL); in sprd_adi_hw_init()
474 writel_relaxed(0, sadi->base + REG_ADI_CHN_PRIH); in sprd_adi_hw_init()
477 tmp = readl_relaxed(sadi->base + REG_ADI_GSSI_CFG0); in sprd_adi_hw_init()
479 writel_relaxed(tmp, sadi->base + REG_ADI_GSSI_CFG0); in sprd_adi_hw_init()
482 list = of_get_property(np, "sprd,hw-channels", &size); in sprd_adi_hw_init()
484 dev_info(sadi->dev, "no hw channels setting in node\n"); in sprd_adi_hw_init()
498 writel_relaxed(chn_config, sadi->base + in sprd_adi_hw_init()
502 value = readl_relaxed(sadi->base + REG_ADI_CHN_EN); in sprd_adi_hw_init()
504 writel_relaxed(value, sadi->base + REG_ADI_CHN_EN); in sprd_adi_hw_init()
506 value = readl_relaxed(sadi->base + REG_ADI_CHN_EN1); in sprd_adi_hw_init()
507 value |= BIT(chn_id - 32); in sprd_adi_hw_init()
508 writel_relaxed(value, sadi->base + REG_ADI_CHN_EN1); in sprd_adi_hw_init()
515 struct device_node *np = pdev->dev.of_node; in sprd_adi_probe()
524 dev_err(&pdev->dev, "can not find the adi bus node\n"); in sprd_adi_probe()
525 return -ENODEV; in sprd_adi_probe()
528 data = of_device_get_match_data(&pdev->dev); in sprd_adi_probe()
530 dev_err(&pdev->dev, "no matching driver data found\n"); in sprd_adi_probe()
531 return -EINVAL; in sprd_adi_probe()
534 pdev->id = of_alias_get_id(np, "spi"); in sprd_adi_probe()
537 ctlr = spi_alloc_master(&pdev->dev, sizeof(struct sprd_adi)); in sprd_adi_probe()
539 return -ENOMEM; in sprd_adi_probe()
541 dev_set_drvdata(&pdev->dev, ctlr); in sprd_adi_probe()
545 sadi->base = devm_ioremap_resource(&pdev->dev, res); in sprd_adi_probe()
546 if (IS_ERR(sadi->base)) { in sprd_adi_probe()
547 ret = PTR_ERR(sadi->base); in sprd_adi_probe()
551 sadi->slave_vbase = (unsigned long)sadi->base + in sprd_adi_probe()
552 data->slave_offset; in sprd_adi_probe()
553 sadi->slave_pbase = res->start + data->slave_offset; in sprd_adi_probe()
554 sadi->ctlr = ctlr; in sprd_adi_probe()
555 sadi->dev = &pdev->dev; in sprd_adi_probe()
556 sadi->data = data; in sprd_adi_probe()
559 sadi->hwlock = in sprd_adi_probe()
560 devm_hwspin_lock_request_specific(&pdev->dev, ret); in sprd_adi_probe()
561 if (!sadi->hwlock) { in sprd_adi_probe()
562 ret = -ENXIO; in sprd_adi_probe()
567 case -ENOENT: in sprd_adi_probe()
568 dev_info(&pdev->dev, "no hardware spinlock supplied\n"); in sprd_adi_probe()
571 dev_err_probe(&pdev->dev, ret, "failed to find hwlock id\n"); in sprd_adi_probe()
578 if (sadi->data->wdg_rst) in sprd_adi_probe()
579 sadi->data->wdg_rst(sadi); in sprd_adi_probe()
581 ctlr->dev.of_node = pdev->dev.of_node; in sprd_adi_probe()
582 ctlr->bus_num = pdev->id; in sprd_adi_probe()
583 ctlr->num_chipselect = num_chipselect; in sprd_adi_probe()
584 ctlr->flags = SPI_MASTER_HALF_DUPLEX; in sprd_adi_probe()
585 ctlr->bits_per_word_mask = 0; in sprd_adi_probe()
586 ctlr->transfer_one = sprd_adi_transfer_one; in sprd_adi_probe()
588 ret = devm_spi_register_controller(&pdev->dev, ctlr); in sprd_adi_probe()
590 dev_err(&pdev->dev, "failed to register SPI controller\n"); in sprd_adi_probe()
594 if (sadi->data->restart) { in sprd_adi_probe()
595 sadi->restart_handler.notifier_call = sadi->data->restart; in sprd_adi_probe()
596 sadi->restart_handler.priority = 128; in sprd_adi_probe()
597 ret = register_restart_handler(&sadi->restart_handler); in sprd_adi_probe()
599 dev_err(&pdev->dev, "can not register restart handler\n"); in sprd_adi_probe()
613 struct spi_controller *ctlr = dev_get_drvdata(&pdev->dev); in sprd_adi_remove()
616 unregister_restart_handler(&sadi->restart_handler); in sprd_adi_remove()
642 .compatible = "sprd,sc9860-adi",
646 .compatible = "sprd,sc9863-adi",
650 .compatible = "sprd,ums512-adi",
659 .name = "sprd-adi",