// SPDX-License-Identifier: GPL-2.0-only /* * max6875.c - driver for MAX6874/MAX6875 * * Copyright (C) 2005 Ben Gardner <[email protected]> * * Based on eeprom.c * * The MAX6875 has a bank of registers and two banks of EEPROM. * Address ranges are defined as follows: * * 0x0000 - 0x0046 = configuration registers * * 0x8000 - 0x8046 = configuration EEPROM * * 0x8100 - 0x82FF = user EEPROM * * This driver makes the user EEPROM available for read. * * The registers & config EEPROM should be accessed via i2c-dev. * * The MAX6875 ignores the lowest address bit, so each chip responds to * two addresses - 0x50/0x51 and 0x52/0x53. * * Note that the MAX6875 uses i2c_smbus_write_byte_data() to set the read * address, so this driver is destructive if loaded for the wrong EEPROM chip. */ #include <linux/kernel.h> #include <linux/module.h> #include <linux/slab.h> #include <linux/i2c.h> #include <linux/mutex.h> /* The MAX6875 can only read/write 16 bytes at a time */ #define SLICE_SIZE … #define SLICE_BITS … /* USER EEPROM is at addresses 0x8100 - 0x82FF */ #define USER_EEPROM_BASE … #define USER_EEPROM_SIZE … #define USER_EEPROM_SLICES … /* MAX6875 commands */ #define MAX6875_CMD_BLK_READ … /* Each client has this additional data */ struct max6875_data { … }; static void max6875_update_slice(struct i2c_client *client, int slice) { … } static ssize_t max6875_read(struct file *filp, struct kobject *kobj, struct bin_attribute *bin_attr, char *buf, loff_t off, size_t count) { … } static const struct bin_attribute user_eeprom_attr = …; static int max6875_probe(struct i2c_client *client) { … } static void max6875_remove(struct i2c_client *client) { … } static const struct i2c_device_id max6875_id[] = …; MODULE_DEVICE_TABLE(i2c, max6875_id); static struct i2c_driver max6875_driver = …; module_i2c_driver(…) …; MODULE_AUTHOR(…) …; MODULE_DESCRIPTION(…) …; MODULE_LICENSE(…) …;