13 #include <linux/slab.h>
14 #include <linux/module.h>
48 static struct regmap_config mc13xxx_regmap_spi_config = {
52 .write_flag_mask = 0x80,
60 static int mc13xxx_spi_read(
void *
context,
const void *
reg,
size_t reg_size,
61 void *
val,
size_t val_size)
63 unsigned char w[4] = { *((
unsigned char *) reg), 0, 0, 0};
65 unsigned char *
p =
val;
77 if (val_size != 3 || reg_size != 1)
81 spi_message_add_tail(&t, &
m);
89 static int mc13xxx_spi_write(
void *context,
const void *
data,
size_t count)
97 return spi_write(spi, data, count);
115 static struct regmap_bus regmap_mc13xxx_bus = {
116 .write = mc13xxx_spi_write,
117 .read = mc13xxx_spi_read,
120 static int mc13xxx_spi_probe(
struct spi_device *spi)
138 &mc13xxx_regmap_spi_config);
139 if (IS_ERR(mc13xxx->
regmap)) {
140 ret = PTR_ERR(mc13xxx->
regmap);
141 dev_err(mc13xxx->
dev,
"Failed to initialize register map: %d\n",
154 if (!devid || devid->driver_data != mc13xxx->
ictype)
156 "device id doesn't match auto detection!\n");
171 static struct spi_driver mc13xxx_spi_driver = {
172 .id_table = mc13xxx_device_id,
176 .of_match_table = mc13xxx_dt_ids,
178 .probe = mc13xxx_spi_probe,
182 static int __init mc13xxx_init(
void)
188 static void __exit mc13xxx_exit(
void)
190 spi_unregister_driver(&mc13xxx_spi_driver);