Lines Matching +full:spi +full:- +full:crc
1 // SPDX-License-Identifier: GPL-2.0
3 * SPI access driver for the following TI PMICs:
4 * - LP8764
5 * - TPS65224
6 * - TPS652G1
7 * - TPS6593
8 * - TPS6594
10 * Copyright (C) 2023 BayLibre Incorporated - https://www.baylibre.com/
18 #include <linux/spi/spi.h>
27 MODULE_PARM_DESC(enable_crc, "Enable CRC feature for SPI interface");
33 struct spi_device *spi = context; in tps6594_spi_reg_read() local
34 struct tps6594 *tps = spi_get_drvdata(spi); in tps6594_spi_reg_read()
42 if (tps->use_crc) in tps6594_spi_reg_read()
45 ret = spi_write_then_read(spi, buf, 2, buf + 2, count_rx); in tps6594_spi_reg_read()
49 if (tps->use_crc && buf[3] != crc8(tps6594_spi_crc_table, buf, 3, CRC8_INIT_VALUE)) in tps6594_spi_reg_read()
50 return -EIO; in tps6594_spi_reg_read()
59 struct spi_device *spi = context; in tps6594_spi_reg_write() local
60 struct tps6594 *tps = spi_get_drvdata(spi); in tps6594_spi_reg_write()
68 if (tps->use_crc) in tps6594_spi_reg_write()
71 return spi_write(spi, buf, count); in tps6594_spi_reg_write()
86 { .compatible = "ti,tps6594-q1", .data = (void *)TPS6594, },
87 { .compatible = "ti,tps6593-q1", .data = (void *)TPS6593, },
88 { .compatible = "ti,lp8764-q1", .data = (void *)LP8764, },
89 { .compatible = "ti,tps65224-q1", .data = (void *)TPS65224, },
95 static int tps6594_spi_probe(struct spi_device *spi) in tps6594_spi_probe() argument
97 struct device *dev = &spi->dev; in tps6594_spi_probe()
103 return -ENOMEM; in tps6594_spi_probe()
105 spi_set_drvdata(spi, tps); in tps6594_spi_probe()
107 tps->dev = dev; in tps6594_spi_probe()
108 tps->reg = spi_get_chipselect(spi, 0); in tps6594_spi_probe()
109 tps->irq = spi->irq; in tps6594_spi_probe()
113 return dev_err_probe(dev, -EINVAL, "Failed to find matching chip ID\n"); in tps6594_spi_probe()
114 tps->chip_id = (unsigned long)match->data; in tps6594_spi_probe()
116 if (tps->chip_id == TPS65224 || tps->chip_id == TPS652G1) in tps6594_spi_probe()
119 tps->regmap = devm_regmap_init(dev, NULL, spi, &tps6594_spi_regmap_config); in tps6594_spi_probe()
120 if (IS_ERR(tps->regmap)) in tps6594_spi_probe()
121 return dev_err_probe(dev, PTR_ERR(tps->regmap), "Failed to init regmap\n"); in tps6594_spi_probe()
138 MODULE_DESCRIPTION("SPI Interface Driver for TPS65224, TPS6594/3, and LP8764");