Lines Matching +full:spi +full:- +full:bus

1 // SPDX-License-Identifier: GPL-2.0
3 // Register map access API - SPI support
10 #include <linux/spi/spi.h>
25 regmap_async_complete_cb(&async->core, async->m.status); in regmap_spi_complete()
31 struct spi_device *spi = to_spi_device(dev); in regmap_spi_write() local
33 return spi_write(spi, data, count); in regmap_spi_write()
41 struct spi_device *spi = to_spi_device(dev); in regmap_spi_gather_write() local
50 return spi_sync(spi, &m); in regmap_spi_gather_write()
62 struct spi_device *spi = to_spi_device(dev); in regmap_spi_async_write() local
64 async->t[0].tx_buf = reg; in regmap_spi_async_write()
65 async->t[0].len = reg_len; in regmap_spi_async_write()
66 async->t[1].tx_buf = val; in regmap_spi_async_write()
67 async->t[1].len = val_len; in regmap_spi_async_write()
69 spi_message_init(&async->m); in regmap_spi_async_write()
70 spi_message_add_tail(&async->t[0], &async->m); in regmap_spi_async_write()
72 spi_message_add_tail(&async->t[1], &async->m); in regmap_spi_async_write()
74 async->m.complete = regmap_spi_complete; in regmap_spi_async_write()
75 async->m.context = async; in regmap_spi_async_write()
77 return spi_async(spi, &async->m); in regmap_spi_async_write()
88 return &async_spi->core; in regmap_spi_async_alloc()
96 struct spi_device *spi = to_spi_device(dev); in regmap_spi_read() local
98 return spi_write_then_read(spi, reg, reg_size, val, val_size); in regmap_spi_read()
112 static const struct regmap_bus *regmap_get_spi_bus(struct spi_device *spi, in regmap_get_spi_bus() argument
115 size_t max_size = spi_max_transfer_size(spi); in regmap_get_spi_bus()
117 struct regmap_bus *bus; in regmap_get_spi_bus() local
120 bus = kmemdup(&regmap_spi, sizeof(*bus), GFP_KERNEL); in regmap_get_spi_bus()
121 if (!bus) in regmap_get_spi_bus()
122 return ERR_PTR(-ENOMEM); in regmap_get_spi_bus()
124 max_msg_size = spi_max_message_size(spi); in regmap_get_spi_bus()
125 reg_reserve_size = (config->reg_bits + config->pad_bits) / BITS_PER_BYTE; in regmap_get_spi_bus()
127 max_size -= reg_reserve_size; in regmap_get_spi_bus()
129 bus->free_on_exit = true; in regmap_get_spi_bus()
130 bus->max_raw_read = max_size; in regmap_get_spi_bus()
131 bus->max_raw_write = max_size; in regmap_get_spi_bus()
133 return bus; in regmap_get_spi_bus()
139 struct regmap *__regmap_init_spi(struct spi_device *spi, in __regmap_init_spi() argument
144 const struct regmap_bus *bus = regmap_get_spi_bus(spi, config); in __regmap_init_spi() local
146 if (IS_ERR(bus)) in __regmap_init_spi()
147 return ERR_CAST(bus); in __regmap_init_spi()
149 return __regmap_init(&spi->dev, bus, &spi->dev, config, lock_key, lock_name); in __regmap_init_spi()
153 struct regmap *__devm_regmap_init_spi(struct spi_device *spi, in __devm_regmap_init_spi() argument
158 const struct regmap_bus *bus = regmap_get_spi_bus(spi, config); in __devm_regmap_init_spi() local
160 if (IS_ERR(bus)) in __devm_regmap_init_spi()
161 return ERR_CAST(bus); in __devm_regmap_init_spi()
163 return __devm_regmap_init(&spi->dev, bus, &spi->dev, config, lock_key, lock_name); in __devm_regmap_init_spi()
167 MODULE_DESCRIPTION("regmap SPI Module");