linux/drivers/w1/slaves/w1_ds28e17.c

// SPDX-License-Identifier: GPL-2.0-only
/*
 *	w1_ds28e17.c - w1 family 19 (DS28E17) driver
 *
 * Copyright (c) 2016 Jan Kandziora <[email protected]>
 */

#include <linux/crc16.h>
#include <linux/delay.h>
#include <linux/device.h>
#include <linux/i2c.h>
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/moduleparam.h>
#include <linux/slab.h>
#include <linux/types.h>
#include <linux/uaccess.h>

#define CRC16_INIT

#include <linux/w1.h>

#define W1_FAMILY_DS28E17

/* Module setup. */
MODULE_LICENSE();
MODULE_AUTHOR();
MODULE_DESCRIPTION();
MODULE_ALIAS();


/* Default I2C speed to be set when a DS28E17 is detected. */
static int i2c_speed =;
module_param_named(speed, i2c_speed, int, 0600);
MODULE_PARM_DESC();

/* Default I2C stretch value to be set when a DS28E17 is detected. */
static char i2c_stretch =;
module_param_named(stretch, i2c_stretch, byte, 0600);
MODULE_PARM_DESC();

/* DS28E17 device command codes. */
#define W1_F19_WRITE_DATA_WITH_STOP
#define W1_F19_WRITE_DATA_NO_STOP
#define W1_F19_WRITE_DATA_ONLY
#define W1_F19_WRITE_DATA_ONLY_WITH_STOP
#define W1_F19_READ_DATA_WITH_STOP
#define W1_F19_WRITE_READ_DATA_WITH_STOP
#define W1_F19_WRITE_CONFIGURATION
#define W1_F19_READ_CONFIGURATION
#define W1_F19_ENABLE_SLEEP_MODE
#define W1_F19_READ_DEVICE_REVISION

/* DS28E17 status bits */
#define W1_F19_STATUS_CRC
#define W1_F19_STATUS_ADDRESS
#define W1_F19_STATUS_START

/*
 * Maximum number of I2C bytes to transfer within one CRC16 protected onewire
 * command.
 */
#define W1_F19_WRITE_DATA_LIMIT

/* Maximum number of I2C bytes to read with one onewire command. */
#define W1_F19_READ_DATA_LIMIT

/* Constants for calculating the busy sleep. */
#define W1_F19_BUSY_TIMEBASES
#define W1_F19_BUSY_GRATUITY

/* Number of checks for the busy flag before timeout. */
#define W1_F19_BUSY_CHECKS


/* Slave specific data. */
struct w1_f19_data {};


/* Wait a while until the busy flag clears. */
static int w1_f19_i2c_busy_wait(struct w1_slave *sl, size_t count)
{}


/* Utility function: result. */
static size_t w1_f19_error(struct w1_slave *sl, u8 w1_buf[])
{}


/* Utility function: write data to I2C slave, single chunk. */
static int __w1_f19_i2c_write(struct w1_slave *sl,
	const u8 *command, size_t command_count,
	const u8 *buffer, size_t count)
{}


/* Write data to I2C slave. */
static int w1_f19_i2c_write(struct w1_slave *sl, u16 i2c_address,
	const u8 *buffer, size_t count, bool stop)
{}


/* Read data from I2C slave. */
static int w1_f19_i2c_read(struct w1_slave *sl, u16 i2c_address,
	u8 *buffer, size_t count)
{}


/* Write to, then read data from I2C slave. */
static int w1_f19_i2c_write_read(struct w1_slave *sl, u16 i2c_address,
	const u8 *wbuffer, size_t wcount, u8 *rbuffer, size_t rcount)
{}


/* Do an I2C master transfer. */
static int w1_f19_i2c_master_transfer(struct i2c_adapter *adapter,
	struct i2c_msg *msgs, int num)
{}


/* Get I2C adapter functionality. */
static u32 w1_f19_i2c_functionality(struct i2c_adapter *adapter)
{}


/* I2C adapter quirks. */
static const struct i2c_adapter_quirks w1_f19_i2c_adapter_quirks =;

/* I2C algorithm. */
static const struct i2c_algorithm w1_f19_i2c_algorithm =;


/* Read I2C speed from DS28E17. */
static int w1_f19_get_i2c_speed(struct w1_slave *sl)
{}


/* Set I2C speed on DS28E17. */
static int __w1_f19_set_i2c_speed(struct w1_slave *sl, u8 speed)
{}

static int w1_f19_set_i2c_speed(struct w1_slave *sl, u8 speed)
{}


/* Sysfs attributes. */

/* I2C speed attribute for a single chip. */
static ssize_t speed_show(struct device *dev, struct device_attribute *attr,
			     char *buf)
{}

static ssize_t speed_store(struct device *dev, struct device_attribute *attr,
			      const char *buf, size_t count)
{}

static DEVICE_ATTR_RW(speed);


/* Busy stretch attribute for a single chip. */
static ssize_t stretch_show(struct device *dev, struct device_attribute *attr,
			     char *buf)
{}

static ssize_t stretch_store(struct device *dev, struct device_attribute *attr,
			      const char *buf, size_t count)
{}

static DEVICE_ATTR_RW(stretch);


/* All attributes. */
static struct attribute *w1_f19_attrs[] =;

static const struct attribute_group w1_f19_group =;

static const struct attribute_group *w1_f19_groups[] =;


/* Slave add and remove functions. */
static int w1_f19_add_slave(struct w1_slave *sl)
{}

static void w1_f19_remove_slave(struct w1_slave *sl)
{}


/* Declarations within the w1 subsystem. */
static const struct w1_family_ops w1_f19_fops =;

static struct w1_family w1_family_19 =;

module_w1_family();